From c5b61afa2805abcaac8bf52cd099e6e977731dec Mon Sep 17 00:00:00 2001 From: Retera Date: Thu, 2 Jun 2022 01:13:26 -0400 Subject: [PATCH] Some small updates, fix shimmering portal render --- .../WarsmashGdxFDFTestRenderScreen.java | 33 ++++++------ .../warsmash/WarsmashGdxMenuScreen.java | 6 +-- .../parsers/fdf/frames/SingleStringFrame.java | 6 +++ .../etheller/warsmash/parsers/jass/Jass2.java | 51 +++++++++++++++++++ .../warsmash/util/WarsmashConstants.java | 4 +- .../warsmash/viewer5/SkeletalNode.java | 3 +- .../w3x/ui/mapsetup/PlayerSlotPane.java | 10 ++-- .../w3x/ui/mapsetup/TeamSetupPane.java | 5 +- desktop/build.gradle | 9 ++++ .../warsmash/desktop/DesktopLauncher.java | 5 +- jassparser/antlr-src/Jass.g4 | 6 +-- 11 files changed, 101 insertions(+), 37 deletions(-) diff --git a/core/src/com/etheller/warsmash/WarsmashGdxFDFTestRenderScreen.java b/core/src/com/etheller/warsmash/WarsmashGdxFDFTestRenderScreen.java index 5277f72..36c8e37 100644 --- a/core/src/com/etheller/warsmash/WarsmashGdxFDFTestRenderScreen.java +++ b/core/src/com/etheller/warsmash/WarsmashGdxFDFTestRenderScreen.java @@ -135,7 +135,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S this.uiViewport = new FitViewport(aspect3By4Width, aspect3By4Height, this.uiCamera); this.uiViewport.update(width, height); - this.uiCamera.position.set(this.getMinWorldWidth() / 2, this.getMinWorldHeight() / 2, 0); + this.uiCamera.position.set(getMinWorldWidth() / 2, getMinWorldHeight() / 2, 0); this.uiCamera.update(); this.batch = new SpriteBatch(); @@ -166,8 +166,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S // WarsmashGdxMapGame.this.viewer.setGameUI(rootFrame); if (WarsmashConstants.ENABLE_MUSIC) { - final String musicField = rootFrame - .getSkinField("GlueMusic_V" + WarsmashConstants.GAME_VERSION); + final String musicField = rootFrame.getSkinField("GlueMusic"); final String[] musics = musicField.split(";"); String musicPath = musics[(int) (Math.random() * musics.length)]; if (musicSLK.get(musicPath) != null) { @@ -184,11 +183,9 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S WarsmashGdxFDFTestRenderScreen.this.currentMusic = music; } - WarsmashGdxFDFTestRenderScreen.this - .singleModelScene(WarsmashGdxFDFTestRenderScreen.this.scene, - War3MapViewer.mdx(rootFrame.getSkinField( - "GlueSpriteLayerBackground_V" + WarsmashConstants.GAME_VERSION)), - "Stand"); + WarsmashGdxFDFTestRenderScreen.this.singleModelScene( + WarsmashGdxFDFTestRenderScreen.this.scene, + War3MapViewer.mdx(rootFrame.getSkinField("GlueSpriteLayerBackground")), "Stand"); WarsmashGdxFDFTestRenderScreen.this.modelCamera = WarsmashGdxFDFTestRenderScreen.this.mainModel.cameras .get(0); } @@ -200,9 +197,9 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S libgdxContentInstance.setScene(this.uiScene); this.menuUI.main(); - this.updateUIScene(); + updateUIScene(); - this.resize(width, height); + resize(width, height); } Gdx.input.setInputProcessor(this); @@ -234,8 +231,8 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S this.uiScene.camera.viewport(this.tempRect); final float worldWidth = this.uiViewport.getWorldWidth(); final float worldHeight = this.uiViewport.getWorldHeight(); - final float xScale = worldWidth / this.getMinWorldWidth(); - final float yScale = worldHeight / this.getMinWorldHeight(); + final float xScale = worldWidth / getMinWorldWidth(); + final float yScale = worldHeight / getMinWorldHeight(); final float uiSceneWidth = 0.8f * xScale; final float uiSceneHeight = 0.6f * yScale; final float uiSceneX = (0.8f - uiSceneWidth) / 2; @@ -251,7 +248,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S return new SolvedPath(src, src.substring(src.lastIndexOf('.')), true); } }, null); - this.makePerfectSquare(scene, model2, 15); + makePerfectSquare(scene, model2, 15); } private void singleAcolyteScene(final Scene scene) { @@ -314,7 +311,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S this.mainModel = null; } else { - this.singleModelScene(this.scene, War3MapViewer.mdx(path), "birth"); + singleModelScene(this.scene, War3MapViewer.mdx(path), "birth"); WarsmashGdxFDFTestRenderScreen.this.modelCamera = WarsmashGdxFDFTestRenderScreen.this.mainModel.cameras .get(0); // this hack is because we only have the queued animation system in RenderWidget @@ -569,10 +566,10 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S // super.resize(width, height); this.uiViewport.update(width, height); - this.uiCamera.position.set(this.getMinWorldWidth() / 2, this.getMinWorldHeight() / 2, 0); + this.uiCamera.position.set(getMinWorldWidth() / 2, getMinWorldHeight() / 2, 0); this.menuUI.resize(); - this.updateUIScene(); + updateUIScene(); } @@ -615,7 +612,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S this.quatHeap = new Quaternion(); this.quatHeap2 = new Quaternion(); - this.updateCamera(); + updateCamera(); // cameraUpdate(); } @@ -793,7 +790,7 @@ public class WarsmashGdxFDFTestRenderScreen implements InputProcessor, Screen, S @Override public void renderTranslucent() { - WarsmashGdxFDFTestRenderScreen.this.renderLibGDXContent(); + renderLibGDXContent(); } @Override diff --git a/core/src/com/etheller/warsmash/WarsmashGdxMenuScreen.java b/core/src/com/etheller/warsmash/WarsmashGdxMenuScreen.java index 8c2161d..710b63f 100644 --- a/core/src/com/etheller/warsmash/WarsmashGdxMenuScreen.java +++ b/core/src/com/etheller/warsmash/WarsmashGdxMenuScreen.java @@ -31,7 +31,6 @@ import com.etheller.warsmash.units.DataTable; import com.etheller.warsmash.units.Element; import com.etheller.warsmash.util.ImageUtils; import com.etheller.warsmash.util.StringBundle; -import com.etheller.warsmash.util.WarsmashConstants; import com.etheller.warsmash.viewer5.Camera; import com.etheller.warsmash.viewer5.CanvasProvider; import com.etheller.warsmash.viewer5.Model; @@ -207,9 +206,8 @@ public class WarsmashGdxMenuScreen implements InputProcessor, Screen, SingleMode public void onCreate(final GameUI rootFrame) { // WarsmashGdxMapGame.this.viewer.setGameUI(rootFrame); - singleModelScene(WarsmashGdxMenuScreen.this.scene, War3MapViewer.mdx(rootFrame - .getSkinField("GlueSpriteLayerBackground_V" + WarsmashConstants.GAME_VERSION)), - "Stand"); + singleModelScene(WarsmashGdxMenuScreen.this.scene, + War3MapViewer.mdx(rootFrame.getSkinField("GlueSpriteLayerBackground")), "Stand"); if (!WarsmashGdxMenuScreen.this.mainModel.cameras.isEmpty()) { WarsmashGdxMenuScreen.this.modelCamera = WarsmashGdxMenuScreen.this.mainModel.cameras .get(0); diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/SingleStringFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/SingleStringFrame.java index b6968d4..d39765c 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/SingleStringFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/SingleStringFrame.java @@ -22,6 +22,9 @@ public class SingleStringFrame extends AbstractRenderableFrame { public SingleStringFrame(final String name, final UIFrame parent, final Color color, final TextJustify justifyH, final TextJustify justifyV, final BitmapFont frameFont) { super(name, parent); + if (color == null) { + throw new IllegalArgumentException(); + } this.color = color; this.justifyH = justifyH; this.justifyV = justifyV; @@ -37,6 +40,9 @@ public class SingleStringFrame extends AbstractRenderableFrame { } public void setColor(final Color color) { + if (color == null) { + throw new IllegalArgumentException(); + } this.color = color; } diff --git a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java index 02c165b..14521c1 100644 --- a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java +++ b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java @@ -82,6 +82,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CWidget; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.GetAbilityByRawcodeVisitor; +import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.AbstractGenericAliasedAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.generic.CLevelingAbility; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.inventory.CAbilityInventory; import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.mine.CAbilityBlightedGoldMine; @@ -649,6 +650,53 @@ public class Jass2 { return new StringJassValue(""); } }); + jassProgramVisitor.getJassNativeManager().createNative("BlzGetUnitAbilityByIndex", new JassFunction() { + @Override + public JassValue call(final List arguments, final GlobalScope globalScope, + final TriggerExecutionScope triggerScope) { + final CUnit whichUnit = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); + final int whichAbilityIndex = arguments.get(1).visit(IntegerJassValueVisitor.getInstance()); + + final List abilities = whichUnit.getAbilities(); + if (whichAbilityIndex < abilities.size()) { + return new HandleJassValue(abilityType, abilities.get(whichAbilityIndex)); + } + else { + return new HandleJassValue(abilityType, null); + } + } + }); + jassProgramVisitor.getJassNativeManager().createNative("WarsmashGetAbilityTypeId", new JassFunction() { + + @Override + public JassValue call(final List arguments, final GlobalScope globalScope, + final TriggerExecutionScope triggerScope) { + final CAbility ability = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); + if (ability instanceof AbstractGenericAliasedAbility) { + final AbstractGenericAliasedAbility aliasedAbility = (AbstractGenericAliasedAbility) ability; + return new IntegerJassValue(aliasedAbility.getAlias().getValue()); + } + return IntegerJassValue.ZERO; + } + }); + jassProgramVisitor.getJassNativeManager().createNative("WarsmashGetAbilityClassName", new JassFunction() { + + @Override + public JassValue call(final List arguments, final GlobalScope globalScope, + final TriggerExecutionScope triggerScope) { + final CAbility ability = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); + return new StringJassValue(ability.getClass().getSimpleName()); + } + }); + jassProgramVisitor.getJassNativeManager().createNative("WarsmashGetRawcode2String", new JassFunction() { + + @Override + public JassValue call(final List arguments, final GlobalScope globalScope, + final TriggerExecutionScope triggerScope) { + final int rawcode = arguments.get(0).visit(IntegerJassValueVisitor.getInstance()); + return new StringJassValue(new War3ID(rawcode).toString()); + } + }); jassProgramVisitor.getJassNativeManager().createNative("GetObjectName", new JassFunction() { @Override public JassValue call(final List arguments, final GlobalScope globalScope, @@ -1325,6 +1373,9 @@ public class Jass2 { .visit(ObjectJassValueVisitor.>getInstance()); final CPlayerJass player = arguments.get(1) .visit(ObjectJassValueVisitor.getInstance()); + if (force == null) { + throw new JassException(globalScope, "force is null", new NullPointerException()); + } force.add(player); return null; } diff --git a/core/src/com/etheller/warsmash/util/WarsmashConstants.java b/core/src/com/etheller/warsmash/util/WarsmashConstants.java index d1f8649..56d7b60 100644 --- a/core/src/com/etheller/warsmash/util/WarsmashConstants.java +++ b/core/src/com/etheller/warsmash/util/WarsmashConstants.java @@ -27,7 +27,7 @@ public class WarsmashConstants { // find it yet so I used this public static final String DEFAULT_STRING = "Default string"; - public static final boolean CATCH_CURSOR = false; + public static final boolean CATCH_CURSOR = true; public static final boolean VERBOSE_LOGGING = false; public static final boolean ENABLE_DEBUG = false; public static final char SPECIAL_ESCAPE_KEYCODE = 0x7E; @@ -38,7 +38,7 @@ public class WarsmashConstants { // workaround to fix it if you need the local files // to take priority over built-ins for tilesets. public static final boolean FIX_FLAT_FILES_TILESET_LOADING = false; - public static final boolean ENABLE_MUSIC = false; + public static final boolean ENABLE_MUSIC = true; public static final boolean LOAD_UNITS_FROM_WORLDEDIT_DATA = false; public static final boolean CRASH_ON_INCOMPATIBLE_132_FEATURES = false; public static final boolean FIRE_DEATH_EVENTS_ON_REMOVEUNIT = false; diff --git a/core/src/com/etheller/warsmash/viewer5/SkeletalNode.java b/core/src/com/etheller/warsmash/viewer5/SkeletalNode.java index ad0793e..ba69f73 100644 --- a/core/src/com/etheller/warsmash/viewer5/SkeletalNode.java +++ b/core/src/com/etheller/warsmash/viewer5/SkeletalNode.java @@ -119,7 +119,8 @@ public abstract class SkeletalNode extends GenericNode { computedRotation.mul(scene.camera.inverseRotation); } - this.convertBasis(computedRotation); + convertBasis(computedRotation); + computedRotation.mul(this.localRotation); } else { computedRotation = rotationHeap.set(this.localRotation); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/PlayerSlotPane.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/PlayerSlotPane.java index 6741788..3529de7 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/PlayerSlotPane.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/PlayerSlotPane.java @@ -182,27 +182,27 @@ public class PlayerSlotPane { public void setTextFromRacePreference(final GameUI rootFrame, final CPlayerJass player) { final MenuFrame menuFrame = (MenuFrame) this.raceMenu.getPopupMenuFrame(); - if (player.isRacePrefSet(CRacePreference.RANDOM)) { + if (player.isRacePrefSet(CRacePreference.RANDOM) && (menuFrame.getMenuItemCount() > 0)) { rootFrame.setText( ((StringFrame) ((GlueTextButtonFrame) this.raceMenu.getPopupTitleFrame()).getButtonText()), menuFrame.getMenuItem(0).getText()); } - else if (player.isRacePrefSet(CRacePreference.HUMAN)) { + else if (player.isRacePrefSet(CRacePreference.HUMAN) && (menuFrame.getMenuItemCount() > 1)) { rootFrame.setText( ((StringFrame) ((GlueTextButtonFrame) this.raceMenu.getPopupTitleFrame()).getButtonText()), menuFrame.getMenuItem(1).getText()); } - else if (player.isRacePrefSet(CRacePreference.ORC)) { + else if (player.isRacePrefSet(CRacePreference.ORC) && (menuFrame.getMenuItemCount() > 2)) { rootFrame.setText( ((StringFrame) ((GlueTextButtonFrame) this.raceMenu.getPopupTitleFrame()).getButtonText()), menuFrame.getMenuItem(2).getText()); } - else if (player.isRacePrefSet(CRacePreference.UNDEAD)) { + else if (player.isRacePrefSet(CRacePreference.UNDEAD) && (menuFrame.getMenuItemCount() > 3)) { rootFrame.setText( ((StringFrame) ((GlueTextButtonFrame) this.raceMenu.getPopupTitleFrame()).getButtonText()), menuFrame.getMenuItem(3).getText()); } - else if (player.isRacePrefSet(CRacePreference.NIGHTELF)) { + else if (player.isRacePrefSet(CRacePreference.NIGHTELF) && (menuFrame.getMenuItemCount() > 4)) { rootFrame.setText( ((StringFrame) ((GlueTextButtonFrame) this.raceMenu.getPopupTitleFrame()).getButtonText()), menuFrame.getMenuItem(4).getText()); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/TeamSetupPane.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/TeamSetupPane.java index 99f0fb2..a54218a 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/TeamSetupPane.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/mapsetup/TeamSetupPane.java @@ -3,6 +3,7 @@ package com.etheller.warsmash.viewer5.handlers.w3x.ui.mapsetup; import java.util.ArrayList; import java.util.List; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.viewport.Viewport; import com.etheller.warsmash.datasources.DataSource; import com.etheller.warsmash.parsers.fdf.GameUI; @@ -40,8 +41,8 @@ public class TeamSetupPane { int forceIndex = 0; for (final Force force : mapInfo.getForces()) { final StringFrame forceLabelString = rootFrame.createStringFrame( - "SmashForce" + forceIndex + "NameLabel", rootFrame, null, TextJustify.LEFT, TextJustify.MIDDLE, - 0.01f); + "SmashForce" + forceIndex + "NameLabel", rootFrame, Color.WHITE, TextJustify.LEFT, + TextJustify.MIDDLE, 0.01f); rootFrame.setText(forceLabelString, rootFrame.getTrigStr(force.getName())); for (int i = 0; (i < WarsmashConstants.MAX_PLAYERS) && (usedSlots < playerCount); i++) { final CBasePlayer player = config.getPlayer(i); diff --git a/desktop/build.gradle b/desktop/build.gradle index 66316d9..b317adf 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -21,6 +21,15 @@ application { applicationDefaultJvmArgs = [] } +task runGame(dependsOn: classes, type: JavaExec) { + main = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + args cmdargs.split() +} + task debug(dependsOn: classes, type: JavaExec) { main = project.mainClassName classpath = sourceSets.main.runtimeClasspath diff --git a/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java b/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java index 81eba5b..a471952 100644 --- a/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java +++ b/desktop/src/com/etheller/warsmash/desktop/DesktopLauncher.java @@ -43,6 +43,7 @@ import com.etheller.warsmash.viewer5.gl.WireframeExtension; public class DesktopLauncher { public static void main(final String[] arg) { + System.out.println("You ran it."); final LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.useGL30 = true; config.gles30ContextMajorVersion = 3; @@ -184,8 +185,8 @@ public class DesktopLauncher { } }; Extensions.audio = new AudioExtension() { - final FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6).clear(); - final FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).clear(); + final FloatBuffer orientation = BufferUtils.createFloatBuffer(6).clear(); + final FloatBuffer position = BufferUtils.createFloatBuffer(3).clear(); @Override public float getDuration(final Sound sound) { diff --git a/jassparser/antlr-src/Jass.g4 b/jassparser/antlr-src/Jass.g4 index c872c3f..5cc619b 100644 --- a/jassparser/antlr-src/Jass.g4 +++ b/jassparser/antlr-src/Jass.g4 @@ -267,12 +267,12 @@ EXITWHEN : 'exitwhen'; DEBUG : 'debug'; fragment ESCAPED_QUOTE : '\\"'; -STRING_LITERAL : '"' ( ESCAPED_QUOTE | ~('\n'|'\r') )*? '"'; +STRING_LITERAL : '"' ( ESCAPED_QUOTE | . )*? '"'; INTEGER : [0]|([1-9][0-9]*) ; - -HEX_CONSTANT : '0x'(([0-9]|[a-f])*) ; + +HEX_CONSTANT : '0x'(([0-9]|[a-f]|[A-F])*) ; DOLLAR_HEX_CONSTANT : '$'(([0-9]|[A-F])*) ; RAWCODE : ('\''.*?'\'');