Skip to content

Commit

Permalink
Enhancement - Video Backgrounds
Browse files Browse the repository at this point in the history
 * POC to add video as a background map

49: Add proper pathfinding taking VBL into account

Task-Url: #49

Signed-off-by: Jamz <[email protected]>
  • Loading branch information
JamzTheMan committed Jun 1, 2018
1 parent 0be2afe commit c4b321d
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 197 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

// Access Git info from build script
plugins {
id "org.ajoberstar.grgit" version "2.1.0"
id "org.ajoberstar.grgit" version "2.2.0"
}

// Apply the java plugin to add support for Java
Expand All @@ -29,12 +29,12 @@ apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'javafx-gradle-plugin'

// Current Build version
version = '1.4.4.3'
version = '1.4.5.0'

// Definitions
defaultTasks 'clean', 'build'
sourceCompatibility = 1.9
targetCompatibility = 1.9
sourceCompatibility = 9
targetCompatibility = 9

// Don't fail build if tests fail until tests are cleaned up
test.ignoreFailures = true
Expand Down Expand Up @@ -353,5 +353,5 @@ jfx {
}

task wrapper(type: Wrapper) {
gradleVersion = '4.6'
gradleVersion = '4.7'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion src/main/java/net/rptools/maptool/client/MapTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,6 @@ public static void main(String[] args) {

// Set MapTool version
sentry.setRelease(getVersion());
// sentry.setEnvironment("Development");
sentry.addTag("os", System.getProperty("os.name"));
sentry.addTag("version", MapTool.getVersion());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ private static String toString(Throwable t) {
}

private static void reportToSentryIO(Throwable thrown) {
if(Sentry.getStoredClient().getEnvironment().equalsIgnoreCase("development")) {
if (Sentry.getStoredClient().getEnvironment().equalsIgnoreCase("development")) {
log.info("Sentry.IO stacktrace logging skipped in development environment.");
return;
}

log.error("Logging stacktrace to Sentry.IO!");

// Note that all fields set on the context are optional. Context data is copied onto all future events in the
Expand Down
15 changes: 1 addition & 14 deletions src/main/java/net/rptools/maptool/client/tool/PointerTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,12 @@ public void startTokenDrag(Token keyToken) {
return;
}

// TokenDragWorker tdw = new TokenDragWorker();
// tdw.execute();

renderer.addMoveSelectionSet(p.getName(), tokenBeingDragged.getId(), renderer.getOwnedTokens(renderer.getSelectedTokenSet()), false, true);
renderer.addMoveSelectionSet(p.getName(), tokenBeingDragged.getId(), renderer.getOwnedTokens(renderer.getSelectedTokenSet()), false);
MapTool.serverCommand().startTokenMove(p.getName(), renderer.getZone().getId(), tokenBeingDragged.getId(), renderer.getOwnedTokens(renderer.getSelectedTokenSet()));

isDraggingToken = true;
}

// public class TokenDragWorker extends SwingWorker<Void, Void> {
// @Override
// protected Void doInBackground() throws Exception {
// Player p = MapTool.getPlayer();
// renderer.addMoveSelectionSet(p.getName(), tokenBeingDragged.getId(), renderer.getOwnedTokens(renderer.getSelectedTokenSet()), false, true);
// //MapTool.serverCommand().startTokenMove(p.getName(), renderer.getZone().getId(), tokenBeingDragged.getId(), renderer.getOwnedTokens(renderer.getSelectedTokenSet()));
// return null;
// }
// }

public void stopTokenDrag() {
renderer.commitMoveSelectionSet(tokenBeingDragged.getId()); // TODO: figure out a better way
isDraggingToken = false;
Expand Down
86 changes: 82 additions & 4 deletions src/main/java/net/rptools/maptool/client/ui/MapToolFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -150,6 +152,16 @@
import com.jidesoft.docking.DefaultDockableHolder;
import com.jidesoft.docking.DockableFrame;

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;

/**
*/
public class MapToolFrame extends DefaultDockableHolder implements WindowListener, AppEventListener {
Expand Down Expand Up @@ -188,6 +200,7 @@ public class MapToolFrame extends DefaultDockableHolder implements WindowListene
private JPanel visibleControlPanel;
private FullScreenFrame fullScreenFrame;
private final JPanel rendererBorderPanel;
private final JLayeredPane rendererMediaPanel;
private final List<ZoneRenderer> zoneRendererList;
private final JMenuBar menuBar;
private final StatusPanel statusPanel;
Expand Down Expand Up @@ -355,14 +368,31 @@ public MapToolFrame(JMenuBar menuBar) {
statusPanel.addPanel(new SpacerStatusBar(25));

zoneMiniMapPanel = new ZoneMiniMapPanel();
zoneMiniMapPanel.setSize(100, 100);
// zoneMiniMapPanel.setSize(100, 100);

zoneRendererPanel = new JPanel(new PositionalLayout(5));
zoneRendererPanel.setBackground(Color.black);
// zoneRendererPanel.setBackground(Color.black);
// zoneRendererPanel.add(zoneMiniMapPanel, PositionalLayout.Position.SE);
// zoneRendererPanel.add(getChatTypingLabel(), PositionalLayout.Position.NW);
zoneRendererPanel.add(getChatTypingPanel(), PositionalLayout.Position.NW);
zoneRendererPanel.add(getChatActionLabel(), PositionalLayout.Position.SW);
// zoneRendererPanel.setOpaque(false);
// zoneRendererPanel.setSize(2100, 1600);

rendererMediaPanel = new JLayeredPane();
fxPanel = new JFXPanel();
fxPanel.setSize(1024, 768);
// fxPanel.setOpaque(false);

// rendererMediaPanel.add(fxPanel);

// zoneRendererPanel.add(fxPanel, PositionalLayout.Position.NW);
Platform.runLater(new Runnable() {
@Override
public void run() {
initFX(fxPanel);
}
});

commandPanel = new CommandPanel();
MapTool.getMessageList().addObserver(commandPanel);
Expand Down Expand Up @@ -414,6 +444,49 @@ public MapToolFrame(JMenuBar menuBar) {
setChatTypingLabelColor(AppPreferences.getChatNotificationColor());
}

private static void initFX(JFXPanel fxPanel) {
// This method is invoked on the JavaFX thread
Scene scene = createScene();
fxPanel.setScene(scene);
}

private static Scene createScene() {
Group root = new Group();
Scene scene = new Scene(root);

root.setMouseTransparent(true);
root.setAutoSizeChildren(true);

WebView webview = new WebView();
WebEngine webEngine = webview.getEngine();
webEngine.load("http://www.youtube.com/embed/3Z6Mkfetay8?autoplay=1");

// webview.setMinWidth(2100);
// webview.setMinHeight(1280);
// webview.autosize();
// webview.setZoom(webview.getZoom() * 2);
// webview.setMouseTransparent(true);

// root.getChildren().add(webview);

try {
URL test = new File("d:/dynamic_map_test.mp4").toURI().toURL();
Media media = new Media(test.toExternalForm());
MediaPlayer mediaPlayer = new MediaPlayer(media);
MediaView mediaView = new MediaView(mediaPlayer);
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(-1);

root.getChildren().add(mediaView);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
return (scene);
}

public ChatNotificationTimers getChatNotificationTimers() {
return chatTyperTimers;
}
Expand Down Expand Up @@ -512,6 +585,7 @@ private void configureDocking() {

// Main panel
getDockingManager().getWorkspace().add(rendererBorderPanel);
// getDockingManager().getWorkspace().add(rendererMediaPanel);

// Docked frames
getDockingManager().addFrame(getFrame(MTFrame.CONNECTIONS));
Expand Down Expand Up @@ -1608,8 +1682,8 @@ private void updateKeyStrokes(JComponent c) {
for (Object o : c.getActionMap().keys()) {
// We're looking for MacroButton here, but we're adding AbstractActions below... Is this right? XXX
if (o instanceof MacroButton) {
if (log.isInfoEnabled())
log.info("Removing MacroButton " + ((MacroButton) o).getButtonText());
if (log.isDebugEnabled())
log.debug("Removing MacroButton " + ((MacroButton) o).getButtonText());
c.getActionMap().remove(o);
}
}
Expand Down Expand Up @@ -1718,6 +1792,10 @@ public JFileChooser getLoadMacroSetFileChooser() {

private JFileChooser saveTableFileChooser;
private JFileChooser loadTableFileChooser;
private JFXPanel fxPanel;
public JFXPanel getFxPanel() {
return fxPanel;
}

public JFileChooser getSaveTableFileChooser() {
if (saveTableFileChooser == null) {
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/net/rptools/maptool/client/ui/ToolbarPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public ToolbarPanel(Toolbox tbox) {
add(optionPanel);
add(Box.createGlue());

// New button to toggle AI on/off
add(createAiButton(
"net/rptools/maptool/client/image/tool/ai-blue-green.png",
"net/rptools/maptool/client/image/tool/ai-blue-off.png",
I18N.getText("tools.ai_selector.tooltip")));

add(Box.createHorizontalStrut(10));
add(new JSeparator(JSeparator.VERTICAL));
add(Box.createHorizontalStrut(10));
Expand Down Expand Up @@ -257,6 +263,25 @@ public void actionPerformed(ActionEvent e) {
return button;
}

private JToggleButton createAiButton(final String icon, final String offIcon, String tooltip) {
final JToggleButton button = new JToggleButton();
button.setToolTipText(tooltip);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MapTool.getFrame().getCurrentZoneRenderer().setUseAStarPathfinding(button.isSelected());
}
});

try {
button.setIcon(new ImageIcon(ImageUtil.getImage(offIcon)));
button.setSelectedIcon(new ImageIcon(ImageUtil.getImage(icon)));
} catch (IOException ioe) {
ioe.printStackTrace();
}

return button;
}

private JToggleButton createTokenSelectionButton(final String icon, final String offIcon, String tooltip,
TokenSelection tokenSelection) {
final JToggleButton button = new JToggleButton();
Expand Down
Loading

0 comments on commit c4b321d

Please sign in to comment.