Update some frame orderings and FDF processing

This commit is contained in:
Retera 2021-12-09 17:25:56 -05:00
parent 50164d8ef7
commit 2649a50f84
13 changed files with 105 additions and 22 deletions

View File

@ -194,6 +194,7 @@ public class WarsmashGdxMapScreen implements InputProcessor, Screen {
this.viewer.getCommandErrorListener().setDelegate(this.meleeUI);
final ModelInstance libgdxContentInstance = new LibGDXContentLayerModel(null, this.viewer, "",
this.viewer.mapPathSolver, "").addInstance();
libgdxContentInstance.setLocation(0f, 0f, 0.5f);
libgdxContentInstance.setScene(this.uiScene);
this.meleeUI.main();

View File

@ -232,7 +232,7 @@ public class WarsmashGdxMenuScreen implements InputProcessor, Screen, SingleMode
final ModelInstance libgdxContentInstance = new LibGDXContentLayerModel(null, this.viewer, "",
PathSolver.DEFAULT, "").addInstance();
libgdxContentInstance.setLocation(0f, 0f, -0.5f);
libgdxContentInstance.setLocation(0f, 0f, 0.5f);
libgdxContentInstance.setScene(this.uiScene);
this.menuUI.main();

View File

@ -78,13 +78,13 @@ public class BackdropFrame extends AbstractUIFrame {
batch.draw(this.background, backgroundX + (i * this.backgroundSize),
backgroundY + (backgroundVerticalFloorRepeatCount * this.backgroundSize),
this.backgroundSize, backgroundHeightRemainder, 0, 1.0f, 1.0f,
backgroundHeightRemainderRatio);
1.0f - backgroundHeightRemainderRatio);
}
batch.draw(this.background,
backgroundX + ((backgroundHorizontalFloorRepeatCount) * this.backgroundSize),
backgroundY + (backgroundVerticalFloorRepeatCount * this.backgroundSize),
backgroundWidthRemainder, backgroundHeightRemainder, 0, 1.0f, backgroundWidthRemainderRatio,
backgroundHeightRemainderRatio);
1.0f - backgroundHeightRemainderRatio);
}
else {
if (this.mirrored) {

View File

@ -20,7 +20,7 @@ public class StringFrame extends AbstractRenderableFrame {
private Color color;
private String text = "Default string";
private final TextJustify justifyH;
private final TextJustify justifyV;
private TextJustify justifyV;
private final BitmapFont frameFont;
private Color fontShadowColor;
private float fontShadowOffsetX;
@ -50,6 +50,10 @@ public class StringFrame extends AbstractRenderableFrame {
this.internalFramesContainer = new SimpleFrame(null, this);
}
public void setJustifyV(final TextJustify justifyV) {
this.justifyV = justifyV;
}
public String getText() {
return this.text;
}
@ -132,6 +136,9 @@ public class StringFrame extends AbstractRenderableFrame {
if (this.renderBounds.height == 0) {
this.renderBounds.height = getPredictedViewportHeight();
}
if (this.renderBounds.width == 0) {
this.renderBounds.width = getPredictedViewportWidth();
}
super.positionBounds(gameUI, viewport);
}
@ -152,7 +159,7 @@ public class StringFrame extends AbstractRenderableFrame {
final float usedWidth = 0;
float usedHeight = 0;
float usedWidthMax = 0;
final float startingBoundsWidth = this.renderBounds.width;
final float startingBoundsWidth = getAssignedWidth();
final boolean firstInLine = false;
Color currentColor = this.color;
for (int i = 0; i < this.text.length(); i++) {

View File

@ -3300,7 +3300,8 @@ public class Jass2 {
if (whichTrigger == null) {
return BooleanJassValue.FALSE;
}
return BooleanJassValue.of(whichTrigger.evaluate(globalScope, triggerScope));
return BooleanJassValue.of(whichTrigger.evaluate(globalScope,
new CommonTriggerExecutionScope(whichTrigger, triggerScope)));
}
});
jassProgramVisitor.getJassNativeManager().createNative("TriggerExecute", new JassFunction() {
@ -3308,7 +3309,7 @@ public class Jass2 {
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
final TriggerExecutionScope triggerScope) {
final Trigger whichTrigger = arguments.get(0).visit(ObjectJassValueVisitor.getInstance());
whichTrigger.execute(globalScope, triggerScope);
whichTrigger.execute(globalScope, new CommonTriggerExecutionScope(whichTrigger, triggerScope));
return null;
}
});
@ -3622,7 +3623,7 @@ public class Jass2 {
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
final TriggerExecutionScope triggerScope) {
final double time = arguments.get(0).visit(RealJassValueVisitor.getInstance());
throw new IllegalStateException("Needs to sleep " + time);
throw new JassException(globalScope, "Needs to sleep " + time, null);
}
});
jassProgramVisitor.getJassNativeManager().createNative("GetPlayerNeutralAggressive", new JassFunction() {

View File

@ -318,7 +318,7 @@ public abstract class Scene {
private static final class InstanceDepthComparator implements Comparator<ModelInstance> {
@Override
public int compare(final ModelInstance o1, final ModelInstance o2) {
return -Float.compare(o2.depth, o1.depth);
return Float.compare(o2.depth, o1.depth);
}
}

View File

@ -536,8 +536,10 @@ public class MdxComplexInstance extends ModelInstance {
}
final MdxModel model = (MdxModel) this.model;
for (final GenericGroup group : model.opaqueGroups) {
group.render(this, this.scene.camera.viewProjectionMatrix);
if (this.additiveOverrideMeshMode) {
for (final GenericGroup group : model.opaqueGroups) {
group.render(this, this.scene.camera.viewProjectionMatrix);
}
}
for (final GenericGroup group : model.translucentGroups) {
group.render(this, this.scene.camera.viewProjectionMatrix);

View File

@ -33,6 +33,7 @@ public class ParticleEmitter2Object extends GenericObject implements EmitterObje
public float[][] intervals;
public int blendSrc;
public int blendDst;
public int filterModeForSort;
public int priorityPlane;
public ParticleEmitter2Object(final MdxModel model, final MdlxParticleEmitter2 emitter, final int index) {
@ -102,6 +103,7 @@ public class ParticleEmitter2Object extends GenericObject implements EmitterObje
final int[] blendModes = FilterMode.emitterFilterMode(emitter.getFilterMode());
this.filterModeForSort = emitter.getFilterMode().ordinal() + 2;
this.blendSrc = blendModes[0];
this.blendDst = blendModes[1];

View File

@ -35,6 +35,33 @@ public class SetupGroups {
}
}
public static int getBackupPrio(final Batch object) {
return object.layer.filterMode;
}
public static int getBackupPrio(final ParticleEmitter2Object object) {
return object.filterModeForSort;
}
public static int getBackupPrio(final RibbonEmitterObject object) {
return object.layer.filterMode;
}
public static int getBackupPrio(final Object object) {
if (object instanceof Batch) {
return getBackupPrio((Batch) object);
}
else if (object instanceof RibbonEmitterObject) {
return getBackupPrio((RibbonEmitterObject) object);
}
else if (object instanceof ParticleEmitter2Object) {
return getBackupPrio((ParticleEmitter2Object) object);
}
else {
throw new IllegalArgumentException(object.getClass().getName());
}
}
public static boolean matchingGroup(final Object group, final Object object) {
if (group instanceof BatchGroup) {
return (object instanceof Batch) && (((Batch) object).isExtended == ((BatchGroup) group).isExtended);
@ -95,7 +122,11 @@ public class SetupGroups {
Collections.sort(sorted, new Comparator<Object>() {
@Override
public int compare(final Object o1, final Object o2) {
return getPrio(o1) - getPrio(o2);
final int priorityDifference = getPrio(o1) - getPrio(o2);
if (priorityDifference == 0) {
return getBackupPrio(o1) - getBackupPrio(o2);
}
return priorityDifference;
}
});

View File

@ -1079,7 +1079,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
"", 0);
this.rootFrame.setSpriteFrameModel(this.cursorFrame, this.rootFrame.getSkinField("Cursor"));
this.cursorFrame.setSequence("Normal");
this.cursorFrame.setZDepth(-1.0f);
this.cursorFrame.setZDepth(1.0f);
if (WarsmashConstants.CATCH_CURSOR) {
Gdx.input.setCursorCatched(true);
}

View File

@ -25,6 +25,7 @@ import com.etheller.warsmash.networking.WarsmashClientSendingOrderListener;
import com.etheller.warsmash.networking.WarsmashClientWriter;
import com.etheller.warsmash.parsers.fdf.GameUI;
import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint;
import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify;
import com.etheller.warsmash.parsers.fdf.frames.EditBoxFrame;
import com.etheller.warsmash.parsers.fdf.frames.GlueButtonFrame;
import com.etheller.warsmash.parsers.fdf.frames.GlueTextButtonFrame;
@ -53,6 +54,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayerUnit
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CRace;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.command.ClickableFrame;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.command.FocusableFrame;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.mapinfo.MapInfoPane;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.menu.CampaignMenuData;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.menu.CampaignMenuUI;
import com.etheller.warsmash.viewer5.handlers.w3x.ui.menu.CampaignMission;
@ -103,7 +105,13 @@ public class MenuUI {
private UIFrame singlePlayerMenu;
private UIFrame singlePlayerMainPanel;
// single player skirmish menu ("Custom Game")
private UIFrame skirmish;
private UIFrame mapInfoPanel;
private UIFrame advancedOptionsPanel;
private GlueTextButtonFrame mapInfoButton;
private GlueTextButtonFrame advancedOptionsButton;
private UIFrame skirmishAdvancedOptionsPane;
private UIFrame profilePanel;
private EditBoxFrame newProfileEditBox;
@ -159,6 +167,7 @@ public class MenuUI {
private LoadingMap loadingMap;
private SpriteFrame loadingBackground;
private boolean unifiedCampaignInfo = false;
private MapInfoPane skirmishMapInfoPane;
public MenuUI(final DataSource dataSource, final Viewport uiViewport, final Scene uiScene, final MdxViewer viewer,
final WarsmashGdxMultiScreenGame screenManager, final SingleModelScreen menuScreen,
@ -259,7 +268,7 @@ public class MenuUI {
"", 0);
this.rootFrame.setSpriteFrameModel(this.cursorFrame, this.rootFrame.getSkinField("Cursor"));
this.cursorFrame.setSequence("Normal");
this.cursorFrame.setZDepth(-1.0f);
this.cursorFrame.setZDepth(1.0f);
if (WarsmashConstants.CATCH_CURSOR) {
Gdx.input.setCursorCatched(true);
}
@ -475,6 +484,18 @@ public class MenuUI {
// Create skirmish UI
this.skirmish = this.rootFrame.createFrame("Skirmish", this.rootFrame, 0, 0);
this.skirmish.setVisible(false);
this.mapInfoButton = (GlueTextButtonFrame) this.rootFrame.getFrameByName("MapInfoButton", 0);
this.advancedOptionsButton = (GlueTextButtonFrame) this.rootFrame.getFrameByName("AdvancedOptionsButton", 0);
this.mapInfoPanel = this.rootFrame.getFrameByName("MapInfoPanel", 0);
this.advancedOptionsPanel = this.rootFrame.getFrameByName("AdvancedOptionsPanel", 0);
final SimpleFrame mapInfoPaneContainer = (SimpleFrame) this.rootFrame.getFrameByName("MapInfoPaneContainer", 0);
final SimpleFrame advancedOptionsPaneContainer = (SimpleFrame) this.rootFrame
.getFrameByName("AdvancedOptionsPaneContainer", 0);
this.skirmishAdvancedOptionsPane = this.rootFrame.createFrame("AdvancedOptionsPane",
advancedOptionsPaneContainer, 0, 0);
this.skirmishAdvancedOptionsPane.setSetAllPoints(true);
advancedOptionsPaneContainer.add(this.skirmishAdvancedOptionsPane);
this.skirmishMapInfoPane = new MapInfoPane(this.rootFrame, mapInfoPaneContainer);
this.skirmishCancelButton = (GlueTextButtonFrame) this.rootFrame.getFrameByName("CancelButton", 0);
this.skirmishCancelButton.setOnClick(new Runnable() {
@ -522,11 +543,10 @@ public class MenuUI {
this.campaignBackButton.setOnClick(new Runnable() {
@Override
public void run() {
if (MenuUI.this.currentMissionSelectMenuUI != null) {
if (MenuUI.this.menuState == MenuState.MISSION_SELECT) {
MenuUI.this.currentMissionSelectMenuUI.setVisible(false);
MenuUI.this.missionSelectFrame.setVisible(false);
MenuUI.this.menuState = MenuState.CAMPAIGN;
MenuUI.this.currentMissionSelectMenuUI = null;
}
else {
MenuUI.this.campaignMenu.setVisible(false);
@ -684,9 +704,10 @@ public class MenuUI {
this.rootFrame.setSpriteFrameModel(this.loadingBar, this.rootFrame.getSkinField("LoadingProgressBar"));
this.loadingBar.setSequence(0);
this.loadingBar.setFrameByRatio(0.5f);
this.loadingBar.setZDepth(1.0f);
this.loadingBar.setZDepth(0.25f);
this.rootFrame.setText(this.loadingTitleText, getStringWithWTS(wts, mapInfo.getLoadingScreenTitle()));
this.rootFrame.setText(this.loadingSubtitleText, getStringWithWTS(wts, mapInfo.getLoadingScreenSubtitle()));
this.loadingText.setJustifyV(TextJustify.TOP);
this.rootFrame.setText(this.loadingText, getStringWithWTS(wts, mapInfo.getLoadingScreenText()));
this.loadingMap = new LoadingMap(viewer, map, mapInfo);
@ -881,6 +902,8 @@ public class MenuUI {
break;
case SINGLE_PLAYER_SKIRMISH:
this.skirmish.setVisible(true);
this.mapInfoPanel.setVisible(true);
this.advancedOptionsPanel.setVisible(false);
this.glueSpriteLayerTopLeft.setSequence("SinglePlayerSkirmish Stand");
this.glueSpriteLayerTopRight.setSequence("SinglePlayerSkirmish Stand");
break;
@ -901,7 +924,7 @@ public class MenuUI {
this.glueScreenLoop = this.uiSounds.getSound(currentCampaignAmbientSound);
this.glueScreenLoop.play(this.uiScene.audioContext, 0f, 0f, 0f);
final DataTable skinData = this.rootFrame.getSkinData();
final String cursorSkin = CRace.VALUES[this.currentCampaign.getCursor()].name();
final String cursorSkin = getRaceNameByCursorID(this.currentCampaign.getCursor());
this.rootFrame.setSpriteFrameModel(this.cursorFrame, skinData.get(cursorSkin).getField("Cursor"));
this.campaignFade.setSequence("Death");
@ -924,7 +947,7 @@ public class MenuUI {
this.glueScreenLoop = this.uiSounds.getSound(currentCampaignAmbientSound);
this.glueScreenLoop.play(this.uiScene.audioContext, 0f, 0f, 0f);
final DataTable skinData = this.rootFrame.getSkinData();
final String cursorSkin = CRace.VALUES[this.currentCampaign.getCursor()].name();
final String cursorSkin = getRaceNameByCursorID(this.currentCampaign.getCursor());
this.rootFrame.setSpriteFrameModel(this.cursorFrame, skinData.get(cursorSkin).getField("Cursor"));
this.campaignFade.setSequence("Death");
@ -1143,7 +1166,7 @@ public class MenuUI {
this.glueScreenLoop = this.uiSounds.getSound(currentCampaignAmbientSound);
this.glueScreenLoop.play(this.uiScene.audioContext, 0f, 0f, 0f);
final DataTable skinData = this.rootFrame.getSkinData();
final String cursorSkin = CRace.VALUES[this.currentCampaign.getCursor()].name();
final String cursorSkin = getRaceNameByCursorID(this.currentCampaign.getCursor());
this.rootFrame.setSpriteFrameModel(this.cursorFrame, skinData.get(cursorSkin).getField("Cursor"));
break;
}
@ -1152,6 +1175,19 @@ public class MenuUI {
// this.menuState = MenuState.MISSION_SELECT;
}
private String getRaceNameByCursorID(final int cursorId) {
return getRaceByCursorID(cursorId).name();
}
private CRace getRaceByCursorID(final int cursorId) {
final CRace race;
final int raceId = cursorId + 1;
if ((raceId >= CRace.VALUES.length) || ((race = CRace.VALUES[raceId]) == null)) {
return CRace.HUMAN; // when in doubt, default to human
}
return race;
}
private String getCurrentBackgroundModel() {
final String background = this.currentCampaign.getBackground();
final String versionedBackground = background + "_V" + WarsmashConstants.GAME_VERSION;

View File

@ -34,6 +34,7 @@ public final class GlobalScope {
private final Map<String, JassType> types = new HashMap<>();
private final HandleTypeSuperTypeLoadingVisitor handleTypeSuperTypeLoadingVisitor = new HandleTypeSuperTypeLoadingVisitor();
private final ArrayDeque<QueuedCallback> triggerQueue = new ArrayDeque<>();
private final ArrayDeque<QueuedCallback> runningTriggerQueue = new ArrayDeque<>();
public final HandleJassType handleType;
@ -229,7 +230,9 @@ public final class GlobalScope {
}
public void replayQueuedTriggers() {
for (final QueuedCallback trigger : this.triggerQueue) {
this.runningTriggerQueue.clear();
this.runningTriggerQueue.addAll(this.triggerQueue);
for (final QueuedCallback trigger : this.runningTriggerQueue) {
trigger.fire(this);
}
this.triggerQueue.clear();

View File

@ -49,7 +49,7 @@ Frame "SIMPLEFRAME" "SmashToolTipIconResource" {
// --- icon -------------------------------------------------------------
Texture "SmashToolTipIconResourceBackdrop" {
Anchor LEFT, 0.0, 0.0
Anchor LEFT, 0.0, 0.0,
Width 0.008,
Height 0.008,
File "ToolTipStonesIcon",