Merge branch 'master' of github.com:badvision/lawless-legends

This commit is contained in:
Martin Haye 2020-07-28 07:35:39 -07:00
commit e6f16f608f
5 changed files with 59 additions and 38 deletions

View File

@ -1,13 +1,12 @@
/*
* Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
* Copyright (C) 2015 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.badvision.outlaweditor.ui;
import java.net.URL;
@ -15,6 +14,8 @@ import java.util.ListResourceBundle;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import javafx.application.Platform;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@ -22,6 +23,7 @@ import javafx.fxml.Initializable;
import javafx.scene.control.MenuItem;
import javafx.scene.web.PromptData;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;
import org.badvision.outlaweditor.MythosEditor;
@ -111,12 +113,22 @@ public class MythosScriptEditorController
editorView.getEngine().executeScript(loadScript);
}
});
editorView.getEngine().setPromptHandler((PromptData prompt) -> {
return UIAction.getText(prompt.getMessage(), prompt.getDefaultValue());
});
}
// JavaFX8 has a bug where stage maximize events do not trigger resize events to webview components
Platform.runLater(() -> {
Stage stage = (Stage) editorView.getScene().getWindow();
if (stage != null) {
stage.maximizedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
Platform.runLater(()->editorView.getEngine().executeScript("window.dispatchEvent(new Event('resize'));"));
});
}
});
//TODO: Verify the path conversion works in Win7 with a jar file
// Affected by https://bugs.openjdk.java.net/browse/JDK-8136466
editorView.getEngine().load(getClass().getResource(MYTHOS_EDITOR).toExternalForm());
@ -141,4 +153,4 @@ public class MythosScriptEditorController
public String getScriptXml() {
return String.valueOf(editorView.getEngine().executeScript("Mythos.getScriptXml();"));
}
}
}

View File

@ -760,26 +760,25 @@
var blocklyDiv = document.getElementById('blocklyDiv');
Mythos.initBlocks();
Mythos.workspace = Blockly.inject(blocklyDiv,
{path: '../../', toolbox: document.getElementById('toolbox'), sounds: false});
{path: '../../', toolbox: document.getElementById('toolbox'), sounds: false});
var onresize = function (e) {
// Compute the absolute coordinates and dimensions of blocklyArea.
var element = blocklyArea;
var x = 0;
var y = 0;
do {
x += element.offsetLeft;
y += element.offsetTop;
element = element.offsetParent;
} while (element);
// Position blocklyDiv over blocklyArea.
blocklyDiv.style.left = x + 'px';
blocklyDiv.style.top = y + 'px';
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
// Compute the absolute coordinates and dimensions of blocklyArea.
var element = blocklyArea;
var x = 0;
var y = 0;
do {
x += element.offsetLeft;
y += element.offsetTop;
element = element.offsetParent;
} while (element);
// Position blocklyDiv over blocklyArea.
blocklyDiv.style.left = x + 'px';
blocklyDiv.style.top = y + 'px';
blocklyDiv.style.width = blocklyArea.offsetWidth + 'px';
blocklyDiv.style.height = blocklyArea.offsetHeight + 'px';
};
window.addEventListener('resize', onresize, false);
onresize();
</script>
</body>
</html>

View File

@ -5,15 +5,14 @@
*/
package jace;
import jace.apple2e.VideoNTSC;
import jace.config.Configuration;
import jace.core.RAMEvent;
import jace.core.RAMListener;
import jace.core.Utility;
import jace.hardware.CardDiskII;
import jace.hardware.CardMockingboard;
import jace.hardware.CardRamFactor;
import jace.hardware.CardRamworks;
import jace.hardware.PassportMidiInterface;
import jace.hardware.massStorage.CardMassStorage;
import jace.lawless.LawlessHacks;
import jace.lawless.LawlessImageTool;
@ -155,11 +154,12 @@ public class LawlessLegends extends Application {
Emulator.computer.card7.setValue(CardMassStorage.class);
Emulator.computer.card6.setValue(CardDiskII.class);
Emulator.computer.card5.setValue(CardRamFactor.class);
Emulator.computer.card4.setValue(CardMockingboard.class);
Emulator.computer.card2.setValue(PassportMidiInterface.class);
Emulator.computer.card4.setValue(null);
Emulator.computer.card2.setValue(null);
Emulator.computer.cheatEngine.setValue(LawlessHacks.class);
Configuration.buildTree();
Emulator.computer.reconfigure();
VideoNTSC.setVideoMode(VideoNTSC.VideoMode.TextFriendly, false);
((LawlessImageTool) Emulator.computer.getUpgradeHandler()).loadGame();
}
}

View File

@ -20,7 +20,6 @@ package jace.apple2e;
import jace.Emulator;
import jace.EmulatorUILogic;
import static jace.apple2e.VideoDHGR.BLACK;
import jace.config.ConfigurableField;
import jace.config.InvokableAction;
import jace.core.Computer;
@ -34,6 +33,8 @@ import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.paint.Color;
import static jace.apple2e.VideoDHGR.BLACK;
/**
* Provides a clean color monitor simulation, complete with text-friendly
* palette and mixed color/bw (mode 7) rendering. This class extends the
@ -81,25 +82,28 @@ public class VideoNTSC extends VideoDHGR {
Greenscreen("Green"),
Amber("Amber");
String name;
VideoMode(String n) {
name = n;
}
}
static int currentMode = -1;
@InvokableAction(name = "Toggle video mode",
category = "video",
alternatives = "Gfx mode;color;b&w;monochrome",
defaultKeyMapping = {"ctrl+shift+g"})
public static void changeVideoMode() {
currentMode = (currentMode + 1) % VideoMode.values().length;
setVideoMode(VideoMode.values()[currentMode], true);
}
public static void setVideoMode(VideoMode newMode, boolean showNotification) {
VideoNTSC thiss = (VideoNTSC) Emulator.computer.video;
currentMode++;
if (currentMode >= VideoMode.values().length) {
currentMode = 0;
}
thiss.monochomeMode = false;
WHITE = Color.WHITE;
switch (VideoMode.values()[currentMode]) {
switch (newMode) {
case Amber:
thiss.monochomeMode = true;
WHITE = Color.web("ff8000");
@ -129,10 +133,12 @@ public class VideoNTSC extends VideoDHGR {
break;
}
thiss.activePalette = thiss.useTextPalette ? TEXT_PALETTE : SOLID_PALETTE;
EmulatorUILogic.notify("Video mode: "+VideoMode.values()[currentMode].name);
if (showNotification) {
EmulatorUILogic.notify("Video mode: " + newMode.name);
}
forceRefresh();
}
@Override
protected void showBW(WritableImage screen, int x, int y, int dhgrWord) {
int pos = divBy28[x];
@ -235,6 +241,7 @@ public class VideoNTSC extends VideoDHGR {
}
boolean monochomeMode = false;
private void renderScanline(WritableImage screen, int y) {
int p = 0;
if (rowStart != 0) {
@ -369,7 +376,7 @@ public class VideoNTSC extends VideoDHGR {
}
// The following section captures changes to the RGB mode
// The details of this are in Brodener's patent application #4631692
// http://www.freepatentsonline.com/4631692.pdf
// http://www.freepatentsonline.com/4631692.pdf
// as well as the AppleColor adapter card manual
// http://apple2.info/download/Ext80ColumnAppleColorCardHR.pdf
rgbMode graphicsMode = rgbMode.MIX;
@ -426,7 +433,7 @@ public class VideoNTSC extends VideoDHGR {
}));
rgbStateListeners.add(memory.observe(RAMEvent.TYPE.EXECUTE, 0x0fa62, (e) -> {
// When reset hook is called, reset the graphics mode
// This is useful in case a program is running that
// This is useful in case a program is running that
// is totally clueless how to set the RGB state correctly.
f1 = true;
f2 = true;

View File

@ -44,6 +44,9 @@ public class LawlessVideo extends VideoNTSC {
0, 0, 39, 191,
39, 130, 78, 191
}),
TITLE(new int[]{
56, 162, 224, 190
}),
UNKNOWN;
boolean[][] colorMask;