diff --git a/core/src/com/etheller/warsmash/parsers/fdf/GameUI.java b/core/src/com/etheller/warsmash/parsers/fdf/GameUI.java index fd56287..63b2fe8 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/GameUI.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/GameUI.java @@ -212,9 +212,10 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { final FrameDefinition frameDefinition = this.templates.getFrame(name); if (frameDefinition.getFrameClass() == FrameClass.Frame) { if ("SPRITE".equals(frameDefinition.getFrameType())) { - final UIFrame inflated = inflate(frameDefinition, owner, null); + final UIFrame inflated = inflate(frameDefinition, owner, null, + frameDefinition.has("DecorateFileNames")); if (this.autoPosition) { - inflated.positionBounds(this.viewport); + inflated.positionBounds(this, this.viewport); } add(inflated); return inflated; @@ -225,10 +226,15 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { public UIFrame createSimpleFrame(final String name, final UIFrame owner, final int createContext) { final FrameDefinition frameDefinition = this.templates.getFrame(name); - if (frameDefinition.getFrameClass() == FrameClass.Frame) { - final UIFrame inflated = inflate(frameDefinition, owner, null); + if (frameDefinition == null) { + final SimpleFrame simpleFrame = new SimpleFrame(name, owner); + add(simpleFrame); + return simpleFrame; + } + else if (frameDefinition.getFrameClass() == FrameClass.Frame) { + final UIFrame inflated = inflate(frameDefinition, owner, null, frameDefinition.has("DecorateFileNames")); if (this.autoPosition) { - inflated.positionBounds(this.viewport); + inflated.positionBounds(this, this.viewport); } add(inflated); return inflated; @@ -268,7 +274,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { } public UIFrame inflate(final FrameDefinition frameDefinition, final UIFrame parent, - final FrameDefinition parentDefinitionIfAvailable) { + final FrameDefinition parentDefinitionIfAvailable, final boolean inDecorateFileNames) { UIFrame inflatedFrame = null; BitmapFont frameFont = null; Viewport viewport2 = this.viewport; @@ -281,7 +287,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { // mapping this.nameToFrame.put(frameDefinition.getName(), simpleFrame); for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { - simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition)); + simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition, + inDecorateFileNames || childDefinition.has("DecorateFileNames"))); } inflatedFrame = simpleFrame; } @@ -292,7 +299,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { final SimpleStatusBarFrame simpleStatusBarFrame = new SimpleStatusBarFrame(frameDefinition.getName(), parent, decorateFileNames); for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { - simpleStatusBarFrame.add(inflate(childDefinition, simpleStatusBarFrame, frameDefinition)); + simpleStatusBarFrame.add(inflate(childDefinition, simpleStatusBarFrame, frameDefinition, + inDecorateFileNames || childDefinition.has("DecorateFileNames"))); } inflatedFrame = simpleStatusBarFrame; } @@ -300,8 +308,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { final SpriteFrame spriteFrame = new SpriteFrame(frameDefinition.getName(), parent, this.uiScene, viewport2); String backgroundArt = frameDefinition.getString("BackgroundArt"); - if (frameDefinition.has("DecorateFileNames") || ((parentDefinitionIfAvailable != null) - && parentDefinitionIfAvailable.has("DecorateFileNames"))) { + if (frameDefinition.has("DecorateFileNames") || inDecorateFileNames) { if (this.skin.hasField(backgroundArt)) { backgroundArt = this.skin.getField(backgroundArt); } @@ -321,7 +328,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { simpleFrame.setSetAllPoints(true); this.nameToFrame.put(frameDefinition.getName(), simpleFrame); for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { - simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition)); + simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition, + inDecorateFileNames || childDefinition.has("DecorateFileNames"))); } inflatedFrame = simpleFrame; break; @@ -365,8 +373,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { break; case Texture: final String file = frameDefinition.getString("File"); - final boolean decorateFileNames = frameDefinition.has("DecorateFileNames") - || ((parentDefinitionIfAvailable != null) && parentDefinitionIfAvailable.has("DecorateFileNames")); + final boolean decorateFileNames = frameDefinition.has("DecorateFileNames") || inDecorateFileNames; final Vector4Definition texCoord = frameDefinition.getVector4("TexCoord"); final TextureFrame textureFrame = new TextureFrame(frameDefinition.getName(), parent, decorateFileNames, texCoord); @@ -432,7 +439,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { // TODO idk what inherits is doing yet, and I didn't implement createContext yet // even though it looked like just mapping/indexing on int final FrameDefinition frameDefinition = new FrameDefinition(FrameClass.Frame, typeName, name); - final UIFrame inflatedFrame = inflate(frameDefinition, owner, null); + final UIFrame inflatedFrame = inflate(frameDefinition, owner, null, frameDefinition.has("DecorateFileNames")); add(inflatedFrame); return inflatedFrame; } @@ -487,8 +494,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame { } @Override - public final void positionBounds(final Viewport viewport) { - innerPositionBounds(viewport); + public final void positionBounds(final GameUI gameUI, final Viewport viewport) { + innerPositionBounds(this, viewport); } @Override diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractRenderableFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractRenderableFrame.java index ace3f36..e1ebe94 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractRenderableFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractRenderableFrame.java @@ -1,27 +1,35 @@ package com.etheller.warsmash.parsers.fdf.frames; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; +import java.util.EnumMap; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.parsers.fdf.datamodel.AnchorDefinition; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; public abstract class AbstractRenderableFrame implements UIFrame { + private static final FramePoint[] LEFT_ANCHOR_PRIORITY = { FramePoint.LEFT, FramePoint.TOPLEFT, + FramePoint.BOTTOMLEFT }; + private static final FramePoint[] RIGHT_ANCHOR_PRIORITY = { FramePoint.RIGHT, FramePoint.TOPRIGHT, + FramePoint.BOTTOMRIGHT }; + private static final FramePoint[] CENTER_HORIZ_ANCHOR_PRIORITY = { FramePoint.CENTER, FramePoint.TOP, + FramePoint.BOTTOM }; + private static final FramePoint[] CENTER_VERT_ANCHOR_PRIORITY = { FramePoint.CENTER, FramePoint.LEFT, + FramePoint.RIGHT }; + private static final FramePoint[] TOP_ANCHOR_PRIORITY = { FramePoint.TOP, FramePoint.TOPLEFT, FramePoint.TOPRIGHT }; + private static final FramePoint[] BOTTOM_ANCHOR_PRIORITY = { FramePoint.BOTTOM, FramePoint.BOTTOMLEFT, + FramePoint.BOTTOMRIGHT }; private static final boolean DEBUG_LOG = true; protected String name; protected UIFrame parent; protected boolean visible = true; protected int level; protected final Rectangle renderBounds = new Rectangle(0, 0, 0, 0); // in libgdx rendering space - protected List anchors = new ArrayList<>(); - protected List setPoints = new ArrayList<>(); - private boolean setAllPoints; + private final EnumMap framePointToAssignment = new EnumMap<>(FramePoint.class); public AbstractRenderableFrame(final String name, final UIFrame parent) { this.name = name; @@ -30,7 +38,11 @@ public abstract class AbstractRenderableFrame implements UIFrame { @Override public void setSetAllPoints(final boolean setAllPoints) { - this.setAllPoints = setAllPoints; + for (final FramePoint framePoint : FramePoint.values()) { + if (!this.framePointToAssignment.containsKey(framePoint)) { + this.framePointToAssignment.put(framePoint, new SetPoint(framePoint, this.parent, framePoint, 0, 0)); + } + } } @Override @@ -43,88 +55,38 @@ public abstract class AbstractRenderableFrame implements UIFrame { this.renderBounds.height = height; } - private boolean hasLeftAnchor() { - for (final AnchorDefinition anchor : this.anchors) { - switch (anchor.getMyPoint()) { - case CENTER: - case BOTTOM: - case TOP: - case BOTTOMRIGHT: - case RIGHT: - case TOPRIGHT: - break; - case BOTTOMLEFT: - case LEFT: - case TOPLEFT: - return true; - default: - break; + private FramePointAssignment getByPriority(final FramePoint[] priorities) { + for (final FramePoint priorityFramePoint : priorities) { + final FramePointAssignment framePointAssignment = this.framePointToAssignment.get(priorityFramePoint); + if (framePointAssignment != null) { + return framePointAssignment; } } - return false; + return null; } - private boolean hasRightAnchor() { - for (final AnchorDefinition anchor : this.anchors) { - switch (anchor.getMyPoint()) { - case CENTER: - case BOTTOM: - case TOP: - case BOTTOMLEFT: - case LEFT: - case TOPLEFT: - break; - case BOTTOMRIGHT: - case RIGHT: - case TOPRIGHT: - return true; - default: - break; - } - } - return false; + private FramePointAssignment getLeftAnchor() { + return getByPriority(LEFT_ANCHOR_PRIORITY); } - private boolean hasTopAnchor() { - for (final AnchorDefinition anchor : this.anchors) { - switch (anchor.getMyPoint()) { - case CENTER: - case BOTTOM: - case BOTTOMLEFT: - case LEFT: - case BOTTOMRIGHT: - case RIGHT: - break; - case TOP: - case TOPLEFT: - case TOPRIGHT: - return true; - default: - break; - } - } - return false; + private FramePointAssignment getRightAnchor() { + return getByPriority(RIGHT_ANCHOR_PRIORITY); } - private boolean hasBottomAnchor() { - for (final AnchorDefinition anchor : this.anchors) { - switch (anchor.getMyPoint()) { - case CENTER: - case LEFT: - case RIGHT: - case TOP: - case TOPLEFT: - case TOPRIGHT: - break; - case BOTTOM: - case BOTTOMLEFT: - case BOTTOMRIGHT: - return true; - default: - break; - } - } - return false; + private FramePointAssignment getTopAnchor() { + return getByPriority(TOP_ANCHOR_PRIORITY); + } + + private FramePointAssignment getBottomAnchor() { + return getByPriority(BOTTOM_ANCHOR_PRIORITY); + } + + private FramePointAssignment getCenterHorizontalAnchor() { + return getByPriority(CENTER_HORIZ_ANCHOR_PRIORITY); + } + + private FramePointAssignment getCenterVerticalAnchor() { + return getByPriority(CENTER_VERT_ANCHOR_PRIORITY); } @Override @@ -162,7 +124,7 @@ public abstract class AbstractRenderableFrame implements UIFrame { case BOTTOMLEFT: case LEFT: case TOPLEFT: - if (hasRightAnchor()) { + if (getRightAnchor() != null) { final float oldRightX = this.renderBounds.x + this.renderBounds.width; this.renderBounds.x = x; this.renderBounds.width = oldRightX - x; @@ -175,7 +137,7 @@ public abstract class AbstractRenderableFrame implements UIFrame { case BOTTOMRIGHT: case RIGHT: case TOPRIGHT: - if (hasLeftAnchor()) { + if (getLeftAnchor() != null) { this.renderBounds.width = x - this.renderBounds.x; } else { @@ -222,7 +184,7 @@ public abstract class AbstractRenderableFrame implements UIFrame { case TOPLEFT: case TOP: case TOPRIGHT: - if (hasBottomAnchor()) { + if (getBottomAnchor() != null) { this.renderBounds.height = y - this.renderBounds.y; } else { @@ -232,7 +194,7 @@ public abstract class AbstractRenderableFrame implements UIFrame { case BOTTOMLEFT: case BOTTOM: case BOTTOMRIGHT: - if (hasTopAnchor()) { + if (getTopAnchor() != null) { final float oldBottomY = this.renderBounds.y + this.renderBounds.height; this.renderBounds.y = y; this.renderBounds.height = oldBottomY - y; @@ -248,72 +210,83 @@ public abstract class AbstractRenderableFrame implements UIFrame { @Override public void addAnchor(final AnchorDefinition anchorDefinition) { - this.anchors.add(anchorDefinition); + this.framePointToAssignment.put(anchorDefinition.getMyPoint(), new SetPoint(anchorDefinition.getMyPoint(), + this.parent, anchorDefinition.getMyPoint(), anchorDefinition.getX(), anchorDefinition.getY())); } @Override public void addSetPoint(final SetPoint setPointDefinition) { - // TODO this is O(N) in the number of SetPoints, and that - // is not good performance. - final Iterator iterator = this.setPoints.iterator(); - while (iterator.hasNext()) { - final SetPoint setPoint = iterator.next(); - if (setPoint.getMyPoint() == setPointDefinition.getMyPoint()) { - iterator.remove(); - } - } - this.setPoints.add(setPointDefinition); + this.framePointToAssignment.put(setPointDefinition.getMyPoint(), setPointDefinition); } @Override - public void positionBounds(final Viewport viewport) { + public void positionBounds(final GameUI gameUI, final Viewport viewport) { if (this.parent == null) { // TODO this is a bit of a hack, remove later return; } - if (this.anchors.isEmpty() && this.setPoints.isEmpty()) { + if (this.framePointToAssignment.isEmpty()) { this.renderBounds.x = this.parent.getFramePointX(FramePoint.LEFT); this.renderBounds.y = this.parent.getFramePointY(FramePoint.BOTTOM); } else { - for (final AnchorDefinition anchor : this.anchors) { - final float parentPointX = this.parent.getFramePointX(anchor.getMyPoint()); - final float parentPointY = this.parent.getFramePointY(anchor.getMyPoint()); - setFramePointX(anchor.getMyPoint(), parentPointX + anchor.getX()); - setFramePointY(anchor.getMyPoint(), parentPointY + anchor.getY()); - if (DEBUG_LOG) { - System.out.println(getClass().getSimpleName() + ":" + this.name + " anchoring to: " + anchor); + final FramePointAssignment leftAnchor = getLeftAnchor(); + final FramePointAssignment rightAnchor = getRightAnchor(); + final FramePointAssignment topAnchor = getTopAnchor(); + final FramePointAssignment bottomAnchor = getBottomAnchor(); + final FramePointAssignment centerHorizontalAnchor = getCenterHorizontalAnchor(); + final FramePointAssignment centerVerticalAnchor = getCenterVerticalAnchor(); + if (leftAnchor != null) { + this.renderBounds.x = leftAnchor.getX(gameUI, viewport); + if (this.renderBounds.width == 0) { + if (rightAnchor != null) { + this.renderBounds.width = rightAnchor.getX(gameUI, viewport) - this.renderBounds.x; + } + else if (centerHorizontalAnchor != null) { + this.renderBounds.width = (centerHorizontalAnchor.getX(gameUI, viewport) - this.renderBounds.x) + * 2; + } } } - for (final SetPoint setPoint : this.setPoints) { - final UIFrame other = setPoint.getOther(); - if (other == null) { - continue; + else if (rightAnchor != null) { + this.renderBounds.x = rightAnchor.getX(gameUI, viewport) - this.renderBounds.width; + if (centerHorizontalAnchor != null) { + this.renderBounds.width = (this.renderBounds.x - centerHorizontalAnchor.getX(gameUI, viewport)) * 2; } - final float parentPointX = other.getFramePointX(setPoint.getOtherPoint()); - final float parentPointY = other.getFramePointY(setPoint.getOtherPoint()); - setFramePointX(setPoint.getMyPoint(), parentPointX + setPoint.getX()); - setFramePointY(setPoint.getMyPoint(), parentPointY + setPoint.getY()); } - } - if (this.setAllPoints) { - if (this.renderBounds.width == 0) { - this.renderBounds.width = this.parent.getFramePointX(FramePoint.RIGHT) - - this.parent.getFramePointX(FramePoint.LEFT); + else if (centerHorizontalAnchor != null) { + this.renderBounds.x = centerHorizontalAnchor.getX(gameUI, viewport) - (this.renderBounds.width / 2); } - if (this.renderBounds.height == 0) { - this.renderBounds.height = this.parent.getFramePointY(FramePoint.TOP) - - this.parent.getFramePointY(FramePoint.BOTTOM); + if (bottomAnchor != null) { + this.renderBounds.y = bottomAnchor.getY(gameUI, viewport); + if (this.renderBounds.height == 0) { + if (topAnchor != null) { + this.renderBounds.height = topAnchor.getY(gameUI, viewport) - this.renderBounds.y; + } + else if (centerVerticalAnchor != null) { + this.renderBounds.height = (centerVerticalAnchor.getY(gameUI, viewport) - this.renderBounds.y) + * 2; + } + } + } + else if (topAnchor != null) { + this.renderBounds.y = topAnchor.getY(gameUI, viewport) - this.renderBounds.height; + if (centerVerticalAnchor != null) { + this.renderBounds.height = (this.renderBounds.y - centerVerticalAnchor.getY(gameUI, viewport)) * 2; + } + } + else if (centerVerticalAnchor != null) { + this.renderBounds.y = centerVerticalAnchor.getY(gameUI, viewport) - (this.renderBounds.height / 2); } } if (DEBUG_LOG) { System.out.println(getClass().getSimpleName() + ":" + this.name + ":" + hashCode() + " finishing position bounds: " + this.renderBounds); } - innerPositionBounds(viewport); + innerPositionBounds(gameUI, viewport); } - protected abstract void innerPositionBounds(final Viewport viewport); + protected abstract void innerPositionBounds(GameUI gameUI, final Viewport viewport); public boolean isVisible() { return this.visible; diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractUIFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractUIFrame.java index 91e12d0..0f69ecd 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractUIFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/AbstractUIFrame.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; public abstract class AbstractUIFrame extends AbstractRenderableFrame implements UIFrame { private final List childFrames = new ArrayList<>(); @@ -30,9 +31,9 @@ public abstract class AbstractUIFrame extends AbstractRenderableFrame implements } @Override - protected void innerPositionBounds(final Viewport viewport) { + protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) { for (final UIFrame childFrame : this.childFrames) { - childFrame.positionBounds(viewport); + childFrame.positionBounds(gameUI, viewport); } } diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/AnchorPoint.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/AnchorPoint.java new file mode 100644 index 0000000..01566c9 --- /dev/null +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/AnchorPoint.java @@ -0,0 +1,36 @@ +package com.etheller.warsmash.parsers.fdf.frames; + +import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; +import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; + +public class AnchorPoint implements FramePointAssignment { + private final FramePoint framePoint; + private final float x; + private final float y; + + public AnchorPoint(final FramePoint framePoint, final float x, final float y) { + this.framePoint = framePoint; + this.x = x; + this.y = y; + } + + public float getX() { + return this.x; + } + + public float getY() { + return this.y; + } + + @Override + public float getX(final GameUI gameUI, final Viewport uiViewport) { + return gameUI.getFramePointX(this.framePoint) + this.x; + } + + @Override + public float getY(final GameUI gameUI, final Viewport uiViewport) { + return gameUI.getFramePointY(this.framePoint) + this.y; + } + +} diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/FramePointAssignment.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/FramePointAssignment.java new file mode 100644 index 0000000..66706a7 --- /dev/null +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/FramePointAssignment.java @@ -0,0 +1,10 @@ +package com.etheller.warsmash.parsers.fdf.frames; + +import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; + +public interface FramePointAssignment { + float getX(GameUI gameUI, Viewport uiViewport); + + float getY(GameUI gameUI, Viewport uiViewport); +} diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/SetPoint.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/SetPoint.java index 0c54c20..015fdb0 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/SetPoint.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/SetPoint.java @@ -1,8 +1,10 @@ package com.etheller.warsmash.parsers.fdf.frames; +import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; -public class SetPoint { +public class SetPoint implements FramePointAssignment { private final FramePoint myPoint; private final UIFrame other; private final FramePoint otherPoint; @@ -37,4 +39,14 @@ public class SetPoint { public float getY() { return this.y; } + + @Override + public float getX(final GameUI gameUI, final Viewport uiViewport) { + return this.other.getFramePointX(this.otherPoint) + this.x; + } + + @Override + public float getY(final GameUI gameUI, final Viewport uiViewport) { + return this.other.getFramePointY(this.otherPoint) + this.y; + } } diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/SpriteFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/SpriteFrame.java index f569e66..e05bb64 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/SpriteFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/SpriteFrame.java @@ -70,7 +70,7 @@ public class SpriteFrame extends AbstractRenderableFrame { } @Override - protected void innerPositionBounds(final Viewport viewport) { + protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) { updateInstanceLocation(viewport); } diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/StringFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/StringFrame.java index 9f7c888..b33fcc7 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/StringFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/StringFrame.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify; public class StringFrame extends AbstractRenderableFrame { @@ -69,7 +70,7 @@ public class StringFrame extends AbstractRenderableFrame { } @Override - protected void innerPositionBounds(final Viewport viewport) { + protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) { } } diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java index 86c5e39..c8f1412 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/TextureFrame.java @@ -31,7 +31,7 @@ public class TextureFrame extends AbstractRenderableFrame { } @Override - protected void innerPositionBounds(final Viewport viewport) { + protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) { } public void setTexture(String file, final GameUI gameUI) { diff --git a/core/src/com/etheller/warsmash/parsers/fdf/frames/UIFrame.java b/core/src/com/etheller/warsmash/parsers/fdf/frames/UIFrame.java index cb819c0..151cfe5 100644 --- a/core/src/com/etheller/warsmash/parsers/fdf/frames/UIFrame.java +++ b/core/src/com/etheller/warsmash/parsers/fdf/frames/UIFrame.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.utils.viewport.Viewport; +import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.parsers.fdf.datamodel.AnchorDefinition; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; @@ -18,7 +19,7 @@ public interface UIFrame { void setFramePointY(final FramePoint framePoint, final float y); - void positionBounds(final Viewport viewport); + void positionBounds(GameUI gameUI, final Viewport viewport); void addAnchor(final AnchorDefinition anchorDefinition); diff --git a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java index e19a5a0..38f8540 100644 --- a/core/src/com/etheller/warsmash/parsers/jass/Jass2.java +++ b/core/src/com/etheller/warsmash/parsers/jass/Jass2.java @@ -284,7 +284,7 @@ public class Jass2 { public JassValue call(final List arguments, final GlobalScope globalScope, final TriggerExecutionScope triggerScope) { final UIFrame frame = arguments.get(0).visit(ObjectJassValueVisitor.getInstance()); - frame.positionBounds(uiViewport); + frame.positionBounds(JUIEnvironment.this.gameUI, uiViewport); return null; } }); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/SplatModel.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/SplatModel.java index eb93ebe..cd9c872 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/SplatModel.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/SplatModel.java @@ -36,7 +36,7 @@ public class SplatModel { this.color = new float[] { 1, 1, 1, 1 }; this.locations = locations; - if ((unitMapping != null) && (unitMapping.size() > 0)) { + if (unitMapping != null) { this.splatInstances = new ArrayList<>(); for (int i = 0; i < unitMapping.size(); i++) { this.splatInstances.add(new SplatMover(this)); @@ -46,7 +46,7 @@ public class SplatModel { this.splatInstances = null; } loadBatches(gl, centerOffset); - if ((unitMapping != null) && (unitMapping.size() > 0)) { + if (unitMapping != null) { if (this.splatInstances.size() != unitMapping.size()) { throw new IllegalStateException(); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java index 930f5ee..bdeff04 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/environment/Terrain.java @@ -1383,7 +1383,7 @@ public class Terrain { final SplatModel splatModel = new SplatModel(Gdx.gl30, (Texture) this.viewer.load(path, PathSolver.DEFAULT, null), splat.locations, this.centerOffset, - splat.unitMapping, false); + splat.unitMapping.isEmpty() ? null : splat.unitMapping, false); splatModel.color[3] = splat.opacity; this.uberSplatModels.put(path, splatModel); } @@ -1401,7 +1401,7 @@ public class Terrain { SplatModel splatModel = this.uberSplatModels.get(path); if (splatModel == null) { splatModel = new SplatModel(Gdx.gl30, (Texture) this.viewer.load(path, PathSolver.DEFAULT, null), - new ArrayList<>(), this.centerOffset, null, false); + new ArrayList<>(), this.centerOffset, new ArrayList<>(), false); this.uberSplatModels.put(path, splatModel); } return splatModel.add(x - scale, y - scale, x + scale, y + scale, z, this.centerOffset); @@ -1412,7 +1412,7 @@ public class Terrain { SplatModel splatModel = this.uberSplatModels.get(texture); if (splatModel == null) { splatModel = new SplatModel(Gdx.gl30, (Texture) this.viewer.load(texture, PathSolver.DEFAULT, null), - new ArrayList<>(), this.centerOffset, null, false); + new ArrayList<>(), this.centerOffset, new ArrayList<>(), false); splatModel.color[3] = opacity; this.uberSplatModels.put(texture, splatModel); } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java index 510371a..4869d37 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/data/CUnitData.java @@ -270,7 +270,10 @@ public class CUnitData { final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK1_DMG_UPGRADE_AMT, 0); final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK1_TARGET_COUNT, 0); final float projectileArc = unitType.getFieldAsFloat(ATTACK1_PROJECTILE_ARC, 0); - final String projectileArt = unitType.getFieldAsString(ATTACK1_MISSILE_ART, 0); + String projectileArt = unitType.getFieldAsString(ATTACK1_MISSILE_ART, 0); + if ("_".equals(projectileArt) || projectileArt.isEmpty()) { + projectileArt = unitType.getFieldAsString(ATTACK2_MISSILE_ART, 0); + } final boolean projectileHomingEnabled = unitType .getFieldAsBoolean(ATTACK1_PROJECTILE_HOMING_ENABLED, 0); final int projectileSpeed = unitType.getFieldAsInteger(ATTACK1_PROJECTILE_SPEED, 0); @@ -319,7 +322,10 @@ public class CUnitData { final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK2_DMG_UPGRADE_AMT, 0); final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK2_TARGET_COUNT, 0); final float projectileArc = unitType.getFieldAsFloat(ATTACK2_PROJECTILE_ARC, 0); - final String projectileArt = unitType.getFieldAsString(ATTACK2_MISSILE_ART, 0); + String projectileArt = unitType.getFieldAsString(ATTACK2_MISSILE_ART, 0); + if ("_".equals(projectileArt) || projectileArt.isEmpty()) { + projectileArt = unitType.getFieldAsString(ATTACK1_MISSILE_ART, 0); + } final boolean projectileHomingEnabled = unitType .getFieldAsBoolean(ATTACK2_PROJECTILE_HOMING_ENABLED, 0); final int projectileSpeed = unitType.getFieldAsInteger(ATTACK2_PROJECTILE_SPEED, 0); diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/CommandCardIcon.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/CommandCardIcon.java index 034e7fd..f981edf 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/CommandCardIcon.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/CommandCardIcon.java @@ -98,11 +98,11 @@ public class CommandCardIcon extends AbstractRenderableFrame { } @Override - protected void innerPositionBounds(final Viewport viewport) { - this.iconFrame.positionBounds(viewport); - this.activeHighlightFrame.positionBounds(viewport); - this.cooldownFrame.positionBounds(viewport); - this.autocastFrame.positionBounds(viewport); + protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) { + this.iconFrame.positionBounds(gameUI, viewport); + this.activeHighlightFrame.positionBounds(gameUI, viewport); + this.cooldownFrame.positionBounds(gameUI, viewport); + this.autocastFrame.positionBounds(gameUI, viewport); } @Override @@ -147,15 +147,15 @@ public class CommandCardIcon extends AbstractRenderableFrame { } } - public void mouseDown(final Viewport uiViewport) { + public void mouseDown(final GameUI gameUI, final Viewport uiViewport) { this.iconFrame.setWidth(GameUI.convertX(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_PRESSED_WIDTH)); this.iconFrame.setHeight(GameUI.convertY(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_PRESSED_WIDTH)); - positionBounds(uiViewport); + positionBounds(gameUI, uiViewport); } - public void mouseUp(final Viewport uiViewport) { + public void mouseUp(final GameUI gameUI, final Viewport uiViewport) { this.iconFrame.setWidth(GameUI.convertX(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_WIDTH)); this.iconFrame.setHeight(GameUI.convertY(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_WIDTH)); - positionBounds(uiViewport); + positionBounds(gameUI, uiViewport); } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java index 03499c6..0d0358c 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/ui/MeleeUI.java @@ -24,7 +24,9 @@ import com.etheller.warsmash.parsers.fdf.GameUI; import com.etheller.warsmash.parsers.fdf.datamodel.AnchorDefinition; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify; +import com.etheller.warsmash.parsers.fdf.datamodel.Vector4Definition; import com.etheller.warsmash.parsers.fdf.frames.SetPoint; +import com.etheller.warsmash.parsers.fdf.frames.SimpleFrame; import com.etheller.warsmash.parsers.fdf.frames.SimpleStatusBarFrame; import com.etheller.warsmash.parsers.fdf.frames.SpriteFrame; import com.etheller.warsmash.parsers.fdf.frames.StringFrame; @@ -124,6 +126,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma private StringFrame simpleBuildingDescriptionValue; private StringFrame simpleBuildingBuildingActionLabel; private SimpleStatusBarFrame simpleBuildingBuildTimeIndicator; + private final TextureFrame[] queueIconFrames = new TextureFrame[WarsmashConstants.BUILD_QUEUE_SIZE]; private UIFrame attack1Icon; private TextureFrame attack1IconBackdrop; @@ -167,6 +170,10 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma private final float widthRatioCorrection; private final float heightRatioCorrection; private CommandCardIcon mouseDownUIFrame; + private UIFrame smashSimpleInfoPanel; + private SimpleFrame smashAttack1IconWrapper; + private SimpleFrame smashAttack2IconWrapper; + private SimpleFrame smashArmorIconWrapper; public MeleeUI(final DataSource dataSource, final ExtendViewport uiViewport, final FreeTypeFontGenerator fontGenerator, final Scene uiScene, final Scene portraitScene, @@ -291,15 +298,17 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.unitLifeText = (StringFrame) this.rootFrame.getFrameByName("UnitPortraitHitPointText", 0); this.unitManaText = (StringFrame) this.rootFrame.getFrameByName("UnitPortraitManaPointText", 0); - // Create Simple Info Unit Detail - this.simpleInfoPanelUnitDetail = this.rootFrame.createSimpleFrame("SimpleInfoPanelUnitDetail", this.consoleUI, - 0); - this.simpleInfoPanelUnitDetail - .addAnchor(new AnchorDefinition(FramePoint.BOTTOM, 0, GameUI.convertY(this.uiViewport, 0.0f))); final float infoPanelUnitDetailWidth = GameUI.convertY(this.uiViewport, 0.180f); - this.simpleInfoPanelUnitDetail.setWidth(infoPanelUnitDetailWidth); final float infoPanelUnitDetailHeight = GameUI.convertY(this.uiViewport, 0.105f); - this.simpleInfoPanelUnitDetail.setHeight(infoPanelUnitDetailHeight); + this.smashSimpleInfoPanel = this.rootFrame.createSimpleFrame("SmashSimpleInfoPanel", this.rootFrame, 0); + this.smashSimpleInfoPanel + .addAnchor(new AnchorDefinition(FramePoint.BOTTOM, 0, GameUI.convertY(this.uiViewport, 0.0f))); + this.smashSimpleInfoPanel.setWidth(infoPanelUnitDetailWidth); + this.smashSimpleInfoPanel.setHeight(infoPanelUnitDetailHeight); + + // Create Simple Info Unit Detail + this.simpleInfoPanelUnitDetail = this.rootFrame.createSimpleFrame("SimpleInfoPanelUnitDetail", + this.smashSimpleInfoPanel, 0); this.simpleNameValue = (StringFrame) this.rootFrame.getFrameByName("SimpleNameValue", 0); this.simpleClassValue = (StringFrame) this.rootFrame.getFrameByName("SimpleClassValue", 0); this.simpleBuildingActionLabel = (StringFrame) this.rootFrame.getFrameByName("SimpleBuildingActionLabel", 0); @@ -316,11 +325,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma // Create Simple Info Panel Building Detail this.simpleInfoPanelBuildingDetail = this.rootFrame.createSimpleFrame("SimpleInfoPanelBuildingDetail", - this.consoleUI, 0); - this.simpleInfoPanelBuildingDetail - .addAnchor(new AnchorDefinition(FramePoint.BOTTOM, 0, GameUI.convertY(this.uiViewport, 0.0f))); - this.simpleInfoPanelBuildingDetail.setWidth(infoPanelUnitDetailWidth); - this.simpleInfoPanelBuildingDetail.setHeight(infoPanelUnitDetailHeight); + this.smashSimpleInfoPanel, 0); this.simpleBuildingNameValue = (StringFrame) this.rootFrame.getFrameByName("SimpleBuildingNameValue", 0); this.simpleBuildingDescriptionValue = (StringFrame) this.rootFrame .getFrameByName("SimpleBuildingDescriptionValue", 0); @@ -336,28 +341,59 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.simpleBuildingBuildTimeIndicator.setWidth(buildTimeIndicatorWidth); this.simpleBuildingBuildTimeIndicator.setHeight(buildTimeIndicatorHeight); this.simpleInfoPanelBuildingDetail.setVisible(false); + final TextureFrame simpleBuildQueueBackdrop = (TextureFrame) this.rootFrame + .getFrameByName("SimpleBuildQueueBackdrop", 0); + simpleBuildQueueBackdrop.setWidth(infoPanelUnitDetailWidth); + simpleBuildQueueBackdrop.setHeight(infoPanelUnitDetailWidth * 0.5f); - this.attack1Icon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconDamage", this.simpleInfoPanelUnitDetail, - 0); - this.attack1Icon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, + this.queueIconFrames[0] = this.rootFrame.createTextureFrame("SmashBuildQueueIcon0", this.smashSimpleInfoPanel, + false, new Vector4Definition(0, 1, 0, 1)); + this.queueIconFrames[0].addAnchor(new AnchorDefinition(FramePoint.BOTTOMLEFT, + (infoPanelUnitDetailWidth * 15) / 256, (infoPanelUnitDetailWidth * 66) / 256)); + this.queueIconFrames[0].setWidth((infoPanelUnitDetailWidth * 38) / 256); + this.queueIconFrames[0].setHeight((infoPanelUnitDetailWidth * 38) / 256); + + for (int i = 1; i < this.queueIconFrames.length; i++) { + this.queueIconFrames[i] = this.rootFrame.createTextureFrame("SmashBuildQueueIcon" + i, + this.smashSimpleInfoPanel, false, new Vector4Definition(0, 1, 0, 1)); + this.queueIconFrames[i].addAnchor(new AnchorDefinition(FramePoint.BOTTOMLEFT, + (infoPanelUnitDetailWidth * (13 + (40 * (i - 1)))) / 256, (infoPanelUnitDetailWidth * 24) / 256)); + this.queueIconFrames[i].setWidth((infoPanelUnitDetailWidth * 29) / 256); + this.queueIconFrames[i].setHeight((infoPanelUnitDetailWidth * 29) / 256); + } + + this.smashAttack1IconWrapper = (SimpleFrame) this.rootFrame.createSimpleFrame("SmashSimpleInfoPanelIconDamage", + this.simpleInfoPanelUnitDetail, 0); + this.smashAttack1IconWrapper.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, 0, GameUI.convertY(this.uiViewport, -0.030125f))); + this.smashAttack1IconWrapper.setWidth(GameUI.convertX(this.uiViewport, 0.1f)); + this.smashAttack1IconWrapper.setHeight(GameUI.convertY(this.uiViewport, 0.030125f)); + this.attack1Icon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconDamage", this.smashAttack1IconWrapper, + 0); this.attack1IconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 0); this.attack1InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0); this.attack1InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 0); - this.attack2Icon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconDamage", this.simpleInfoPanelUnitDetail, - 1); - this.attack2Icon + this.smashAttack2IconWrapper = (SimpleFrame) this.rootFrame.createSimpleFrame("SmashSimpleInfoPanelIconDamage", + this.simpleInfoPanelUnitDetail, 0); + this.smashAttack2IconWrapper .addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, GameUI.convertX(this.uiViewport, 0.1f), GameUI.convertY(this.uiViewport, -0.030125f))); + this.smashAttack2IconWrapper.setWidth(GameUI.convertX(this.uiViewport, 0.1f)); + this.smashAttack2IconWrapper.setHeight(GameUI.convertY(this.uiViewport, 0.030125f)); + this.attack2Icon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconDamage", this.smashAttack2IconWrapper, + 1); this.attack2IconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 1); this.attack2InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 1); this.attack2InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 1); - this.armorIcon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconArmor", this.simpleInfoPanelUnitDetail, - 1); - this.armorIcon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, - GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.06025f))); + this.smashArmorIconWrapper = (SimpleFrame) this.rootFrame.createSimpleFrame("SmashSimpleInfoPanelIconArmor", + this.simpleInfoPanelUnitDetail, 0); + this.smashArmorIconWrapper.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, + FramePoint.TOPLEFT, GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.06025f))); + this.smashArmorIconWrapper.setWidth(GameUI.convertX(this.uiViewport, 0.1f)); + this.smashArmorIconWrapper.setHeight(GameUI.convertY(this.uiViewport, 0.030125f)); + this.armorIcon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconArmor", this.smashArmorIconWrapper, 0); this.armorIconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 0); this.armorInfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0); this.armorInfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 0); @@ -423,7 +459,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.meleeUIMinimap = createMinimap(this.war3MapViewer); - this.rootFrame.positionBounds(this.uiViewport); + this.rootFrame.positionBounds(this.rootFrame, this.uiViewport); selectUnit(null); } @@ -720,10 +756,17 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.attack2Icon.setVisible(false); this.attack1InfoPanelIconLevel.setText(""); this.attack2InfoPanelIconLevel.setText(""); - this.simpleBuildingActionLabel.setText(""); + this.simpleBuildingBuildingActionLabel.setText(""); + this.simpleBuildingNameValue.setText(""); this.armorIcon.setVisible(false); this.armorInfoPanelIconLevel.setText(""); this.simpleBuildTimeIndicator.setVisible(false); + this.simpleBuildingBuildTimeIndicator.setVisible(false); + this.simpleInfoPanelBuildingDetail.setVisible(false); + this.simpleInfoPanelUnitDetail.setVisible(false); + for (final TextureFrame queueIconFrame : this.queueIconFrames) { + queueIconFrame.setVisible(false); + } } else { unit.getSimulationUnit().addStateListener(this); @@ -744,6 +787,28 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.unitManaText.setText(""); } if (simulationUnit.getBuildQueue()[0] != null) { + for (int i = 0; i < this.queueIconFrames.length; i++) { + final QueueItemType queueItemType = simulationUnit.getBuildQueueTypes()[i]; + if (queueItemType == null) { + this.queueIconFrames[i].setVisible(false); + } + else { + this.queueIconFrames[i].setVisible(true); + switch (queueItemType) { + case RESEARCH: + final IconUI upgradeUI = this.war3MapViewer.getAbilityDataUI() + .getUpgradeUI(simulationUnit.getBuildQueue()[i], 0); + this.queueIconFrames[i].setTexture(upgradeUI.getIcon()); + break; + case UNIT: + default: + final IconUI unitUI = this.war3MapViewer.getAbilityDataUI() + .getUnitUI(simulationUnit.getBuildQueue()[i]); + this.queueIconFrames[i].setTexture(unitUI.getIcon()); + break; + } + } + } this.simpleInfoPanelBuildingDetail.setVisible(true); this.simpleInfoPanelUnitDetail.setVisible(false); this.simpleBuildingNameValue.setText(simulationUnit.getUnitType().getName()); @@ -764,6 +829,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.armorIcon.setVisible(false); } else { + for (final TextureFrame queueIconFrame : this.queueIconFrames) { + queueIconFrame.setVisible(false); + } this.simpleInfoPanelBuildingDetail.setVisible(false); this.simpleInfoPanelUnitDetail.setVisible(true); this.simpleNameValue.setText(simulationUnit.getUnitType().getName()); @@ -804,18 +872,21 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.attack2Icon.setVisible(false); } - this.armorIcon.addSetPoint( + this.smashArmorIconWrapper.addSetPoint( new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.06025f))); - this.armorIcon.positionBounds(this.uiViewport); + this.smashArmorIconWrapper.positionBounds(this.rootFrame, this.uiViewport); + this.armorIcon.positionBounds(this.rootFrame, this.uiViewport); } else { this.attack1Icon.setVisible(false); this.attack2Icon.setVisible(false); - this.armorIcon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, - FramePoint.TOPLEFT, 0, GameUI.convertY(this.uiViewport, -0.030125f))); - this.armorIcon.positionBounds(this.uiViewport); + this.smashArmorIconWrapper.addSetPoint( + new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, + GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.030125f))); + this.smashArmorIconWrapper.positionBounds(this.rootFrame, this.uiViewport); + this.armorIcon.positionBounds(this.rootFrame, this.uiViewport); } localArmorIcon.setVisible(!constructing); @@ -824,6 +895,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma if (constructing) { this.simpleBuildingActionLabel .setText(this.rootFrame.getTemplates().getDecoratedString("CONSTRUCTING")); + this.queueIconFrames[0].setVisible(true); + this.queueIconFrames[0].setTexture(this.war3MapViewer.getAbilityDataUI() + .getUnitUI(this.selectedUnit.getSimulationUnit().getTypeId()).getIcon()); } else { this.simpleBuildingActionLabel.setText(""); @@ -1204,7 +1278,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma else { if (clickedUIFrame instanceof CommandCardIcon) { this.mouseDownUIFrame = (CommandCardIcon) clickedUIFrame; - this.mouseDownUIFrame.mouseDown(this.uiViewport); + this.mouseDownUIFrame.mouseDown(this.rootFrame, this.uiViewport); } } return false; @@ -1219,7 +1293,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma this.mouseDownUIFrame.onClick(button); this.war3MapViewer.getUiSounds().getSound("InterfaceClick").play(this.uiScene.audioContext, 0, 0); } - this.mouseDownUIFrame.mouseUp(this.uiViewport); + this.mouseDownUIFrame.mouseUp(this.rootFrame, this.uiViewport); } this.mouseDownUIFrame = null; return false;