Update with small fixes, data ui load level 1 tooltip, night elf build

This commit is contained in:
Retera 2021-02-15 23:41:36 -05:00
parent 2c5c00d4ea
commit e99b44222c
6 changed files with 109 additions and 96 deletions

View File

@ -46,4 +46,5 @@ Path07="."
//FilePath="V1\Farm.w3x"
//FilePath="PenguinWorld.w3x"
//FilePath="Maps\FrozenThrone\Campaign\UndeadX09.w3x"
FilePath="LavellaLagoon.w3x"
//FilePath="LavellaLagoon.w3x"
FilePath="WiceOrc.w3x"

View File

@ -58,7 +58,7 @@ import com.etheller.warsmash.viewer5.handlers.w3x.ui.command.SettableCommandErro
public class WarsmashGdxMapGame extends ApplicationAdapter implements CanvasProvider, InputProcessor {
private static final boolean ENABLE_AUDIO = true;
private static final boolean ENABLE_MUSIC = true;
private static final boolean ENABLE_MUSIC = false;
private DataSource codebase;
private War3MapViewer viewer;
private final Rectangle tempRect = new Rectangle();

View File

@ -139,9 +139,6 @@ public class DataTable implements ObjectData {
if (currentUnit == null) {
System.out.println("null for " + input);
}
if ("Nofood".equals(fieldName)) {
System.out.println(builder.toString().trim());
}
values.add(builder.toString().trim());
}
currentUnit.setField(fieldName, values);

View File

@ -71,12 +71,12 @@ public class AbilityDataUI {
final String iconResearchPath = gameUI.trySkinField(abilityTypeData.getFieldAsString(ICON_RESEARCH, 0));
final String iconNormalPath = gameUI.trySkinField(abilityTypeData.getFieldAsString(ICON_NORMAL, 0));
final String iconTurnOffPath = gameUI.trySkinField(abilityTypeData.getFieldAsString(ICON_TURN_OFF, 0));
final String iconTip = abilityTypeData.getFieldAsString(ABILITY_TIP, 0);
final String iconUberTip = abilityTypeData.getFieldAsString(ABILITY_UBER_TIP, 0);
final String iconTurnOffTip = abilityTypeData.getFieldAsString(ABILITY_UN_TIP, 0);
final String iconTurnOffUberTip = abilityTypeData.getFieldAsString(ABILITY_UN_UBER_TIP, 0);
final String iconResearchTip = abilityTypeData.getFieldAsString(ABILITY_RESEARCH_TIP, 0);
final String iconResearchUberTip = abilityTypeData.getFieldAsString(ABILITY_RESEARCH_UBER_TIP, 0);
final String iconTip = abilityTypeData.getFieldAsString(ABILITY_TIP, 1);
final String iconUberTip = abilityTypeData.getFieldAsString(ABILITY_UBER_TIP, 1);
final String iconTurnOffTip = abilityTypeData.getFieldAsString(ABILITY_UN_TIP, 1);
final String iconTurnOffUberTip = abilityTypeData.getFieldAsString(ABILITY_UN_UBER_TIP, 1);
final String iconResearchTip = abilityTypeData.getFieldAsString(ABILITY_RESEARCH_TIP, 1);
final String iconResearchUberTip = abilityTypeData.getFieldAsString(ABILITY_RESEARCH_UBER_TIP, 1);
final int iconResearchX = abilityTypeData.getFieldAsInteger(ICON_RESEARCH_X, 0);
final int iconResearchY = abilityTypeData.getFieldAsInteger(ICON_RESEARCH_Y, 0);
final int iconNormalX = abilityTypeData.getFieldAsInteger(ICON_NORMAL_X, 0);

View File

@ -1,57 +1,25 @@
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build;
import java.awt.image.BufferedImage;
import java.util.List;
import com.etheller.warsmash.util.War3ID;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit;
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.CAbilityVisitor;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.targeting.AbilityPointTarget;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build.CBehaviorOrcBuild;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.orders.OrderIds;
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer;
public class CAbilityNightElfBuild extends AbstractCAbilityBuild {
private CBehaviorOrcBuild buildBehavior;
public CAbilityNightElfBuild(final int handleId, final List<War3ID> structuresBuilt) {
super(handleId, structuresBuilt);
// TODO Auto-generated constructor stub
}
@Override
public int getBaseOrderId() {
return OrderIds.nightelfbuild;
}
@Override
public void onAdd(final CSimulation game, final CUnit unit) {
// TODO Auto-generated method stub
}
@Override
public void onRemove(final CSimulation game, final CUnit unit) {
// TODO Auto-generated method stub
}
@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) {
// TODO Auto-generated method stub
return null;
}
@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId,
final AbilityPointTarget point) {
// TODO Auto-generated method stub
return null;
}
@Override
public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) {
// TODO Auto-generated method stub
return null;
}
@Override
@ -60,9 +28,50 @@ public class CAbilityNightElfBuild extends AbstractCAbilityBuild {
}
@Override
public void onCancelFromQueue(final CSimulation game, final CUnit unit, final int orderId) {
// TODO Auto-generated method stub
public void onAdd(final CSimulation game, final CUnit unit) {
this.buildBehavior = new CBehaviorOrcBuild(unit);
}
@Override
public void onRemove(final CSimulation game, final CUnit unit) {
}
@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId, final CWidget target) {
return caster.pollNextOrderBehavior(game);
}
@Override
public CBehavior begin(final CSimulation game, final CUnit caster, final int orderId,
final AbilityPointTarget point) {
final War3ID orderIdAsRawtype = new War3ID(orderId);
final CUnitType unitType = game.getUnitData().getUnitType(orderIdAsRawtype);
final BufferedImage buildingPathingPixelMap = unitType.getBuildingPathingPixelMap();
if (buildingPathingPixelMap != null) {
point.x = (float) Math.floor(point.x / 64f) * 64f;
point.y = (float) Math.floor(point.y / 64f) * 64f;
if (((buildingPathingPixelMap.getWidth() / 2) % 2) == 1) {
point.x += 32f;
}
if (((buildingPathingPixelMap.getHeight() / 2) % 2) == 1) {
point.y += 32f;
}
}
final CPlayer player = game.getPlayer(caster.getPlayerIndex());
player.chargeFor(unitType);
if (unitType.getFoodUsed() != 0) {
player.setFoodUsed(player.getFoodUsed() + unitType.getFoodUsed());
}
return this.buildBehavior.reset(point, orderId, getBaseOrderId());
}
@Override
public CBehavior beginNoTarget(final CSimulation game, final CUnit caster, final int orderId) {
return caster.pollNextOrderBehavior(game);
}
@Override
public int getBaseOrderId() {
return OrderIds.nightelfbuild;
}
}

View File

@ -146,7 +146,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
private static final String BUILDING_PATHING_PREVIEW_KEY = "buildingPathingPreview";
public static final float DEFAULT_COMMAND_CARD_ICON_WIDTH = 0.039f;
public static final float DEFAULT_COMMAND_CARD_ICON_PRESSED_WIDTH = 0.037f;
private static final int COMMAND_CARD_WIDTH = 4;
private static final int COMMAND_CARD_WIDTH = 5;
private static final int COMMAND_CARD_HEIGHT = 3;
private static final Vector2 screenCoordsVector = new Vector2();
@ -1748,6 +1748,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
@Override
public void ordersChanged() {
reloadSelectedUnitUI(this.selectedUnit);
if (this.mouseOverUIFrame instanceof ClickableActionFrame) {
loadTooltip();
}
}
@Override
@ -2094,50 +2097,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
if (mousedUIFrame != this.mouseOverUIFrame) {
if (mousedUIFrame instanceof ClickableActionFrame) {
this.mouseOverUIFrame = (ClickableActionFrame) mousedUIFrame;
final int goldCost = this.mouseOverUIFrame.getToolTipGoldCost();
final int lumberCost = this.mouseOverUIFrame.getToolTipLumberCost();
final int foodCost = this.mouseOverUIFrame.getToolTipFoodCost();
final String toolTip = this.mouseOverUIFrame.getToolTip();
this.rootFrame.setText(this.tooltipUberTipText, this.mouseOverUIFrame.getUberTip());
int resourceIndex = 0;
if (goldCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipGoldIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(goldCost));
resourceIndex++;
}
if (lumberCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipLumberIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(lumberCost));
resourceIndex++;
}
if (foodCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipSupplyIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(foodCost));
resourceIndex++;
}
for (int i = resourceIndex; i < this.tooltipResourceFrames.length; i++) {
this.tooltipResourceFrames[i].setVisible(false);
}
float resourcesHeight;
if (resourceIndex != 0) {
this.tooltipUberTipText.addSetPoint(this.uberTipWithResourcesSetPoint);
resourcesHeight = 0.014f;
}
else {
this.tooltipUberTipText.addSetPoint(this.uberTipNoResourcesSetPoint);
resourcesHeight = 0.004f;
}
this.rootFrame.setText(this.tooltipText, toolTip);
final float predictedViewportHeight = this.tooltipText.getPredictedViewportHeight()
+ GameUI.convertY(this.uiViewport, resourcesHeight)
+ this.tooltipUberTipText.getPredictedViewportHeight()
+ GameUI.convertY(this.uiViewport, 0.003f);
this.tooltipFrame.setHeight(predictedViewportHeight);
this.tooltipFrame.positionBounds(this.rootFrame, this.uiViewport);
this.tooltipFrame.setVisible(true);
loadTooltip();
}
else {
this.mouseOverUIFrame = null;
@ -2147,6 +2107,52 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
return false;
}
private void loadTooltip() {
final int goldCost = this.mouseOverUIFrame.getToolTipGoldCost();
final int lumberCost = this.mouseOverUIFrame.getToolTipLumberCost();
final int foodCost = this.mouseOverUIFrame.getToolTipFoodCost();
final String toolTip = this.mouseOverUIFrame.getToolTip();
this.rootFrame.setText(this.tooltipUberTipText, this.mouseOverUIFrame.getUberTip());
int resourceIndex = 0;
if (goldCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipGoldIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(goldCost));
resourceIndex++;
}
if (lumberCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipLumberIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(lumberCost));
resourceIndex++;
}
if (foodCost != 0) {
this.tooltipResourceFrames[resourceIndex].setVisible(true);
this.tooltipResourceIconFrames[resourceIndex].setTexture("ToolTipSupplyIcon", this.rootFrame);
this.rootFrame.setText(this.tooltipResourceTextFrames[resourceIndex], Integer.toString(foodCost));
resourceIndex++;
}
for (int i = resourceIndex; i < this.tooltipResourceFrames.length; i++) {
this.tooltipResourceFrames[i].setVisible(false);
}
float resourcesHeight;
if (resourceIndex != 0) {
this.tooltipUberTipText.addSetPoint(this.uberTipWithResourcesSetPoint);
resourcesHeight = 0.014f;
}
else {
this.tooltipUberTipText.addSetPoint(this.uberTipNoResourcesSetPoint);
resourcesHeight = 0.004f;
}
this.rootFrame.setText(this.tooltipText, toolTip);
final float predictedViewportHeight = this.tooltipText.getPredictedViewportHeight()
+ GameUI.convertY(this.uiViewport, resourcesHeight)
+ this.tooltipUberTipText.getPredictedViewportHeight() + GameUI.convertY(this.uiViewport, 0.003f);
this.tooltipFrame.setHeight(predictedViewportHeight);
this.tooltipFrame.positionBounds(this.rootFrame, this.uiViewport);
this.tooltipFrame.setVisible(true);
}
public float getHeightRatioCorrection() {
return this.heightRatioCorrection;
}