Unit training queue display working

This commit is contained in:
Retera 2020-11-15 05:00:11 -05:00
parent f589afdf46
commit 9f80e62ead
16 changed files with 315 additions and 194 deletions

View File

@ -212,9 +212,10 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
final FrameDefinition frameDefinition = this.templates.getFrame(name); final FrameDefinition frameDefinition = this.templates.getFrame(name);
if (frameDefinition.getFrameClass() == FrameClass.Frame) { if (frameDefinition.getFrameClass() == FrameClass.Frame) {
if ("SPRITE".equals(frameDefinition.getFrameType())) { 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) { if (this.autoPosition) {
inflated.positionBounds(this.viewport); inflated.positionBounds(this, this.viewport);
} }
add(inflated); add(inflated);
return 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) { public UIFrame createSimpleFrame(final String name, final UIFrame owner, final int createContext) {
final FrameDefinition frameDefinition = this.templates.getFrame(name); final FrameDefinition frameDefinition = this.templates.getFrame(name);
if (frameDefinition.getFrameClass() == FrameClass.Frame) { if (frameDefinition == null) {
final UIFrame inflated = inflate(frameDefinition, owner, 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) { if (this.autoPosition) {
inflated.positionBounds(this.viewport); inflated.positionBounds(this, this.viewport);
} }
add(inflated); add(inflated);
return inflated; return inflated;
@ -268,7 +274,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
} }
public UIFrame inflate(final FrameDefinition frameDefinition, final UIFrame parent, public UIFrame inflate(final FrameDefinition frameDefinition, final UIFrame parent,
final FrameDefinition parentDefinitionIfAvailable) { final FrameDefinition parentDefinitionIfAvailable, final boolean inDecorateFileNames) {
UIFrame inflatedFrame = null; UIFrame inflatedFrame = null;
BitmapFont frameFont = null; BitmapFont frameFont = null;
Viewport viewport2 = this.viewport; Viewport viewport2 = this.viewport;
@ -281,7 +287,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
// mapping // mapping
this.nameToFrame.put(frameDefinition.getName(), simpleFrame); this.nameToFrame.put(frameDefinition.getName(), simpleFrame);
for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) {
simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition)); simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition,
inDecorateFileNames || childDefinition.has("DecorateFileNames")));
} }
inflatedFrame = simpleFrame; inflatedFrame = simpleFrame;
} }
@ -292,7 +299,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
final SimpleStatusBarFrame simpleStatusBarFrame = new SimpleStatusBarFrame(frameDefinition.getName(), final SimpleStatusBarFrame simpleStatusBarFrame = new SimpleStatusBarFrame(frameDefinition.getName(),
parent, decorateFileNames); parent, decorateFileNames);
for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) {
simpleStatusBarFrame.add(inflate(childDefinition, simpleStatusBarFrame, frameDefinition)); simpleStatusBarFrame.add(inflate(childDefinition, simpleStatusBarFrame, frameDefinition,
inDecorateFileNames || childDefinition.has("DecorateFileNames")));
} }
inflatedFrame = simpleStatusBarFrame; inflatedFrame = simpleStatusBarFrame;
} }
@ -300,8 +308,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
final SpriteFrame spriteFrame = new SpriteFrame(frameDefinition.getName(), parent, this.uiScene, final SpriteFrame spriteFrame = new SpriteFrame(frameDefinition.getName(), parent, this.uiScene,
viewport2); viewport2);
String backgroundArt = frameDefinition.getString("BackgroundArt"); String backgroundArt = frameDefinition.getString("BackgroundArt");
if (frameDefinition.has("DecorateFileNames") || ((parentDefinitionIfAvailable != null) if (frameDefinition.has("DecorateFileNames") || inDecorateFileNames) {
&& parentDefinitionIfAvailable.has("DecorateFileNames"))) {
if (this.skin.hasField(backgroundArt)) { if (this.skin.hasField(backgroundArt)) {
backgroundArt = this.skin.getField(backgroundArt); backgroundArt = this.skin.getField(backgroundArt);
} }
@ -321,7 +328,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
simpleFrame.setSetAllPoints(true); simpleFrame.setSetAllPoints(true);
this.nameToFrame.put(frameDefinition.getName(), simpleFrame); this.nameToFrame.put(frameDefinition.getName(), simpleFrame);
for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) { for (final FrameDefinition childDefinition : frameDefinition.getInnerFrames()) {
simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition)); simpleFrame.add(inflate(childDefinition, simpleFrame, frameDefinition,
inDecorateFileNames || childDefinition.has("DecorateFileNames")));
} }
inflatedFrame = simpleFrame; inflatedFrame = simpleFrame;
break; break;
@ -365,8 +373,7 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
break; break;
case Texture: case Texture:
final String file = frameDefinition.getString("File"); final String file = frameDefinition.getString("File");
final boolean decorateFileNames = frameDefinition.has("DecorateFileNames") final boolean decorateFileNames = frameDefinition.has("DecorateFileNames") || inDecorateFileNames;
|| ((parentDefinitionIfAvailable != null) && parentDefinitionIfAvailable.has("DecorateFileNames"));
final Vector4Definition texCoord = frameDefinition.getVector4("TexCoord"); final Vector4Definition texCoord = frameDefinition.getVector4("TexCoord");
final TextureFrame textureFrame = new TextureFrame(frameDefinition.getName(), parent, decorateFileNames, final TextureFrame textureFrame = new TextureFrame(frameDefinition.getName(), parent, decorateFileNames,
texCoord); 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 // TODO idk what inherits is doing yet, and I didn't implement createContext yet
// even though it looked like just mapping/indexing on int // even though it looked like just mapping/indexing on int
final FrameDefinition frameDefinition = new FrameDefinition(FrameClass.Frame, typeName, name); 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); add(inflatedFrame);
return inflatedFrame; return inflatedFrame;
} }
@ -487,8 +494,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
} }
@Override @Override
public final void positionBounds(final Viewport viewport) { public final void positionBounds(final GameUI gameUI, final Viewport viewport) {
innerPositionBounds(viewport); innerPositionBounds(this, viewport);
} }
@Override @Override

View File

@ -1,27 +1,35 @@
package com.etheller.warsmash.parsers.fdf.frames; package com.etheller.warsmash.parsers.fdf.frames;
import java.util.ArrayList; import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.viewport.Viewport; 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.AnchorDefinition;
import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint;
public abstract class AbstractRenderableFrame implements UIFrame { 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; private static final boolean DEBUG_LOG = true;
protected String name; protected String name;
protected UIFrame parent; protected UIFrame parent;
protected boolean visible = true; protected boolean visible = true;
protected int level; protected int level;
protected final Rectangle renderBounds = new Rectangle(0, 0, 0, 0); // in libgdx rendering space protected final Rectangle renderBounds = new Rectangle(0, 0, 0, 0); // in libgdx rendering space
protected List<AnchorDefinition> anchors = new ArrayList<>(); private final EnumMap<FramePoint, FramePointAssignment> framePointToAssignment = new EnumMap<>(FramePoint.class);
protected List<SetPoint> setPoints = new ArrayList<>();
private boolean setAllPoints;
public AbstractRenderableFrame(final String name, final UIFrame parent) { public AbstractRenderableFrame(final String name, final UIFrame parent) {
this.name = name; this.name = name;
@ -30,7 +38,11 @@ public abstract class AbstractRenderableFrame implements UIFrame {
@Override @Override
public void setSetAllPoints(final boolean setAllPoints) { 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 @Override
@ -43,88 +55,38 @@ public abstract class AbstractRenderableFrame implements UIFrame {
this.renderBounds.height = height; this.renderBounds.height = height;
} }
private boolean hasLeftAnchor() { private FramePointAssignment getByPriority(final FramePoint[] priorities) {
for (final AnchorDefinition anchor : this.anchors) { for (final FramePoint priorityFramePoint : priorities) {
switch (anchor.getMyPoint()) { final FramePointAssignment framePointAssignment = this.framePointToAssignment.get(priorityFramePoint);
case CENTER: if (framePointAssignment != null) {
case BOTTOM: return framePointAssignment;
case TOP:
case BOTTOMRIGHT:
case RIGHT:
case TOPRIGHT:
break;
case BOTTOMLEFT:
case LEFT:
case TOPLEFT:
return true;
default:
break;
} }
} }
return false; return null;
} }
private boolean hasRightAnchor() { private FramePointAssignment getLeftAnchor() {
for (final AnchorDefinition anchor : this.anchors) { return getByPriority(LEFT_ANCHOR_PRIORITY);
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 boolean hasTopAnchor() { private FramePointAssignment getRightAnchor() {
for (final AnchorDefinition anchor : this.anchors) { return getByPriority(RIGHT_ANCHOR_PRIORITY);
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 boolean hasBottomAnchor() { private FramePointAssignment getTopAnchor() {
for (final AnchorDefinition anchor : this.anchors) { return getByPriority(TOP_ANCHOR_PRIORITY);
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;
} }
private FramePointAssignment getBottomAnchor() {
return getByPriority(BOTTOM_ANCHOR_PRIORITY);
} }
return false;
private FramePointAssignment getCenterHorizontalAnchor() {
return getByPriority(CENTER_HORIZ_ANCHOR_PRIORITY);
}
private FramePointAssignment getCenterVerticalAnchor() {
return getByPriority(CENTER_VERT_ANCHOR_PRIORITY);
} }
@Override @Override
@ -162,7 +124,7 @@ public abstract class AbstractRenderableFrame implements UIFrame {
case BOTTOMLEFT: case BOTTOMLEFT:
case LEFT: case LEFT:
case TOPLEFT: case TOPLEFT:
if (hasRightAnchor()) { if (getRightAnchor() != null) {
final float oldRightX = this.renderBounds.x + this.renderBounds.width; final float oldRightX = this.renderBounds.x + this.renderBounds.width;
this.renderBounds.x = x; this.renderBounds.x = x;
this.renderBounds.width = oldRightX - x; this.renderBounds.width = oldRightX - x;
@ -175,7 +137,7 @@ public abstract class AbstractRenderableFrame implements UIFrame {
case BOTTOMRIGHT: case BOTTOMRIGHT:
case RIGHT: case RIGHT:
case TOPRIGHT: case TOPRIGHT:
if (hasLeftAnchor()) { if (getLeftAnchor() != null) {
this.renderBounds.width = x - this.renderBounds.x; this.renderBounds.width = x - this.renderBounds.x;
} }
else { else {
@ -222,7 +184,7 @@ public abstract class AbstractRenderableFrame implements UIFrame {
case TOPLEFT: case TOPLEFT:
case TOP: case TOP:
case TOPRIGHT: case TOPRIGHT:
if (hasBottomAnchor()) { if (getBottomAnchor() != null) {
this.renderBounds.height = y - this.renderBounds.y; this.renderBounds.height = y - this.renderBounds.y;
} }
else { else {
@ -232,7 +194,7 @@ public abstract class AbstractRenderableFrame implements UIFrame {
case BOTTOMLEFT: case BOTTOMLEFT:
case BOTTOM: case BOTTOM:
case BOTTOMRIGHT: case BOTTOMRIGHT:
if (hasTopAnchor()) { if (getTopAnchor() != null) {
final float oldBottomY = this.renderBounds.y + this.renderBounds.height; final float oldBottomY = this.renderBounds.y + this.renderBounds.height;
this.renderBounds.y = y; this.renderBounds.y = y;
this.renderBounds.height = oldBottomY - y; this.renderBounds.height = oldBottomY - y;
@ -248,72 +210,83 @@ public abstract class AbstractRenderableFrame implements UIFrame {
@Override @Override
public void addAnchor(final AnchorDefinition anchorDefinition) { 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 @Override
public void addSetPoint(final SetPoint setPointDefinition) { public void addSetPoint(final SetPoint setPointDefinition) {
// TODO this is O(N) in the number of SetPoints, and that this.framePointToAssignment.put(setPointDefinition.getMyPoint(), setPointDefinition);
// is not good performance.
final Iterator<SetPoint> iterator = this.setPoints.iterator();
while (iterator.hasNext()) {
final SetPoint setPoint = iterator.next();
if (setPoint.getMyPoint() == setPointDefinition.getMyPoint()) {
iterator.remove();
}
}
this.setPoints.add(setPointDefinition);
} }
@Override @Override
public void positionBounds(final Viewport viewport) { public void positionBounds(final GameUI gameUI, final Viewport viewport) {
if (this.parent == null) { if (this.parent == null) {
// TODO this is a bit of a hack, remove later // TODO this is a bit of a hack, remove later
return; return;
} }
if (this.anchors.isEmpty() && this.setPoints.isEmpty()) { if (this.framePointToAssignment.isEmpty()) {
this.renderBounds.x = this.parent.getFramePointX(FramePoint.LEFT); this.renderBounds.x = this.parent.getFramePointX(FramePoint.LEFT);
this.renderBounds.y = this.parent.getFramePointY(FramePoint.BOTTOM); this.renderBounds.y = this.parent.getFramePointY(FramePoint.BOTTOM);
} }
else { else {
for (final AnchorDefinition anchor : this.anchors) { final FramePointAssignment leftAnchor = getLeftAnchor();
final float parentPointX = this.parent.getFramePointX(anchor.getMyPoint()); final FramePointAssignment rightAnchor = getRightAnchor();
final float parentPointY = this.parent.getFramePointY(anchor.getMyPoint()); final FramePointAssignment topAnchor = getTopAnchor();
setFramePointX(anchor.getMyPoint(), parentPointX + anchor.getX()); final FramePointAssignment bottomAnchor = getBottomAnchor();
setFramePointY(anchor.getMyPoint(), parentPointY + anchor.getY()); final FramePointAssignment centerHorizontalAnchor = getCenterHorizontalAnchor();
if (DEBUG_LOG) { final FramePointAssignment centerVerticalAnchor = getCenterVerticalAnchor();
System.out.println(getClass().getSimpleName() + ":" + this.name + " anchoring to: " + anchor); if (leftAnchor != null) {
} this.renderBounds.x = leftAnchor.getX(gameUI, viewport);
}
for (final SetPoint setPoint : this.setPoints) {
final UIFrame other = setPoint.getOther();
if (other == null) {
continue;
}
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) { if (this.renderBounds.width == 0) {
this.renderBounds.width = this.parent.getFramePointX(FramePoint.RIGHT) if (rightAnchor != null) {
- this.parent.getFramePointX(FramePoint.LEFT); 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;
}
}
}
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;
}
}
else if (centerHorizontalAnchor != null) {
this.renderBounds.x = centerHorizontalAnchor.getX(gameUI, viewport) - (this.renderBounds.width / 2);
}
if (bottomAnchor != null) {
this.renderBounds.y = bottomAnchor.getY(gameUI, viewport);
if (this.renderBounds.height == 0) { if (this.renderBounds.height == 0) {
this.renderBounds.height = this.parent.getFramePointY(FramePoint.TOP) if (topAnchor != null) {
- this.parent.getFramePointY(FramePoint.BOTTOM); 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) { if (DEBUG_LOG) {
System.out.println(getClass().getSimpleName() + ":" + this.name + ":" + hashCode() System.out.println(getClass().getSimpleName() + ":" + this.name + ":" + hashCode()
+ " finishing position bounds: " + this.renderBounds); + " 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() { public boolean isVisible() {
return this.visible; return this.visible;

View File

@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.Viewport; import com.badlogic.gdx.utils.viewport.Viewport;
import com.etheller.warsmash.parsers.fdf.GameUI;
public abstract class AbstractUIFrame extends AbstractRenderableFrame implements UIFrame { public abstract class AbstractUIFrame extends AbstractRenderableFrame implements UIFrame {
private final List<UIFrame> childFrames = new ArrayList<>(); private final List<UIFrame> childFrames = new ArrayList<>();
@ -30,9 +31,9 @@ public abstract class AbstractUIFrame extends AbstractRenderableFrame implements
} }
@Override @Override
protected void innerPositionBounds(final Viewport viewport) { protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) {
for (final UIFrame childFrame : this.childFrames) { for (final UIFrame childFrame : this.childFrames) {
childFrame.positionBounds(viewport); childFrame.positionBounds(gameUI, viewport);
} }
} }

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -1,8 +1,10 @@
package com.etheller.warsmash.parsers.fdf.frames; 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; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint;
public class SetPoint { public class SetPoint implements FramePointAssignment {
private final FramePoint myPoint; private final FramePoint myPoint;
private final UIFrame other; private final UIFrame other;
private final FramePoint otherPoint; private final FramePoint otherPoint;
@ -37,4 +39,14 @@ public class SetPoint {
public float getY() { public float getY() {
return this.y; 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;
}
} }

View File

@ -70,7 +70,7 @@ public class SpriteFrame extends AbstractRenderableFrame {
} }
@Override @Override
protected void innerPositionBounds(final Viewport viewport) { protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) {
updateInstanceLocation(viewport); updateInstanceLocation(viewport);
} }

View File

@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.Viewport; import com.badlogic.gdx.utils.viewport.Viewport;
import com.etheller.warsmash.parsers.fdf.GameUI;
import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify; import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify;
public class StringFrame extends AbstractRenderableFrame { public class StringFrame extends AbstractRenderableFrame {
@ -69,7 +70,7 @@ public class StringFrame extends AbstractRenderableFrame {
} }
@Override @Override
protected void innerPositionBounds(final Viewport viewport) { protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) {
} }
} }

View File

@ -31,7 +31,7 @@ public class TextureFrame extends AbstractRenderableFrame {
} }
@Override @Override
protected void innerPositionBounds(final Viewport viewport) { protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) {
} }
public void setTexture(String file, final GameUI gameUI) { public void setTexture(String file, final GameUI gameUI) {

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.Viewport; 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.AnchorDefinition;
import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint;
@ -18,7 +19,7 @@ public interface UIFrame {
void setFramePointY(final FramePoint framePoint, final float y); 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); void addAnchor(final AnchorDefinition anchorDefinition);

View File

@ -284,7 +284,7 @@ public class Jass2 {
public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope, public JassValue call(final List<JassValue> arguments, final GlobalScope globalScope,
final TriggerExecutionScope triggerScope) { final TriggerExecutionScope triggerScope) {
final UIFrame frame = arguments.get(0).visit(ObjectJassValueVisitor.<UIFrame>getInstance()); final UIFrame frame = arguments.get(0).visit(ObjectJassValueVisitor.<UIFrame>getInstance());
frame.positionBounds(uiViewport); frame.positionBounds(JUIEnvironment.this.gameUI, uiViewport);
return null; return null;
} }
}); });

View File

@ -36,7 +36,7 @@ public class SplatModel {
this.color = new float[] { 1, 1, 1, 1 }; this.color = new float[] { 1, 1, 1, 1 };
this.locations = locations; this.locations = locations;
if ((unitMapping != null) && (unitMapping.size() > 0)) { if (unitMapping != null) {
this.splatInstances = new ArrayList<>(); this.splatInstances = new ArrayList<>();
for (int i = 0; i < unitMapping.size(); i++) { for (int i = 0; i < unitMapping.size(); i++) {
this.splatInstances.add(new SplatMover(this)); this.splatInstances.add(new SplatMover(this));
@ -46,7 +46,7 @@ public class SplatModel {
this.splatInstances = null; this.splatInstances = null;
} }
loadBatches(gl, centerOffset); loadBatches(gl, centerOffset);
if ((unitMapping != null) && (unitMapping.size() > 0)) { if (unitMapping != null) {
if (this.splatInstances.size() != unitMapping.size()) { if (this.splatInstances.size() != unitMapping.size()) {
throw new IllegalStateException(); throw new IllegalStateException();
} }

View File

@ -1383,7 +1383,7 @@ public class Terrain {
final SplatModel splatModel = new SplatModel(Gdx.gl30, final SplatModel splatModel = new SplatModel(Gdx.gl30,
(Texture) this.viewer.load(path, PathSolver.DEFAULT, null), splat.locations, this.centerOffset, (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; splatModel.color[3] = splat.opacity;
this.uberSplatModels.put(path, splatModel); this.uberSplatModels.put(path, splatModel);
} }
@ -1401,7 +1401,7 @@ public class Terrain {
SplatModel splatModel = this.uberSplatModels.get(path); SplatModel splatModel = this.uberSplatModels.get(path);
if (splatModel == null) { if (splatModel == null) {
splatModel = new SplatModel(Gdx.gl30, (Texture) this.viewer.load(path, PathSolver.DEFAULT, 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); this.uberSplatModels.put(path, splatModel);
} }
return splatModel.add(x - scale, y - scale, x + scale, y + scale, z, this.centerOffset); 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); SplatModel splatModel = this.uberSplatModels.get(texture);
if (splatModel == null) { if (splatModel == null) {
splatModel = new SplatModel(Gdx.gl30, (Texture) this.viewer.load(texture, PathSolver.DEFAULT, 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; splatModel.color[3] = opacity;
this.uberSplatModels.put(texture, splatModel); this.uberSplatModels.put(texture, splatModel);
} }

View File

@ -270,7 +270,10 @@ public class CUnitData {
final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK1_DMG_UPGRADE_AMT, 0); final int damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK1_DMG_UPGRADE_AMT, 0);
final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK1_TARGET_COUNT, 0); final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK1_TARGET_COUNT, 0);
final float projectileArc = unitType.getFieldAsFloat(ATTACK1_PROJECTILE_ARC, 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 final boolean projectileHomingEnabled = unitType
.getFieldAsBoolean(ATTACK1_PROJECTILE_HOMING_ENABLED, 0); .getFieldAsBoolean(ATTACK1_PROJECTILE_HOMING_ENABLED, 0);
final int projectileSpeed = unitType.getFieldAsInteger(ATTACK1_PROJECTILE_SPEED, 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 damageUpgradeAmount = unitType.getFieldAsInteger(ATTACK2_DMG_UPGRADE_AMT, 0);
final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK2_TARGET_COUNT, 0); final int maximumNumberOfTargets = unitType.getFieldAsInteger(ATTACK2_TARGET_COUNT, 0);
final float projectileArc = unitType.getFieldAsFloat(ATTACK2_PROJECTILE_ARC, 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 final boolean projectileHomingEnabled = unitType
.getFieldAsBoolean(ATTACK2_PROJECTILE_HOMING_ENABLED, 0); .getFieldAsBoolean(ATTACK2_PROJECTILE_HOMING_ENABLED, 0);
final int projectileSpeed = unitType.getFieldAsInteger(ATTACK2_PROJECTILE_SPEED, 0); final int projectileSpeed = unitType.getFieldAsInteger(ATTACK2_PROJECTILE_SPEED, 0);

View File

@ -98,11 +98,11 @@ public class CommandCardIcon extends AbstractRenderableFrame {
} }
@Override @Override
protected void innerPositionBounds(final Viewport viewport) { protected void innerPositionBounds(final GameUI gameUI, final Viewport viewport) {
this.iconFrame.positionBounds(viewport); this.iconFrame.positionBounds(gameUI, viewport);
this.activeHighlightFrame.positionBounds(viewport); this.activeHighlightFrame.positionBounds(gameUI, viewport);
this.cooldownFrame.positionBounds(viewport); this.cooldownFrame.positionBounds(gameUI, viewport);
this.autocastFrame.positionBounds(viewport); this.autocastFrame.positionBounds(gameUI, viewport);
} }
@Override @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.setWidth(GameUI.convertX(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_PRESSED_WIDTH));
this.iconFrame.setHeight(GameUI.convertY(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.setWidth(GameUI.convertX(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_WIDTH));
this.iconFrame.setHeight(GameUI.convertY(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_WIDTH)); this.iconFrame.setHeight(GameUI.convertY(uiViewport, MeleeUI.DEFAULT_COMMAND_CARD_ICON_WIDTH));
positionBounds(uiViewport); positionBounds(gameUI, uiViewport);
} }
} }

View File

@ -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.AnchorDefinition;
import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint; import com.etheller.warsmash.parsers.fdf.datamodel.FramePoint;
import com.etheller.warsmash.parsers.fdf.datamodel.TextJustify; 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.SetPoint;
import com.etheller.warsmash.parsers.fdf.frames.SimpleFrame;
import com.etheller.warsmash.parsers.fdf.frames.SimpleStatusBarFrame; import com.etheller.warsmash.parsers.fdf.frames.SimpleStatusBarFrame;
import com.etheller.warsmash.parsers.fdf.frames.SpriteFrame; import com.etheller.warsmash.parsers.fdf.frames.SpriteFrame;
import com.etheller.warsmash.parsers.fdf.frames.StringFrame; import com.etheller.warsmash.parsers.fdf.frames.StringFrame;
@ -124,6 +126,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
private StringFrame simpleBuildingDescriptionValue; private StringFrame simpleBuildingDescriptionValue;
private StringFrame simpleBuildingBuildingActionLabel; private StringFrame simpleBuildingBuildingActionLabel;
private SimpleStatusBarFrame simpleBuildingBuildTimeIndicator; private SimpleStatusBarFrame simpleBuildingBuildTimeIndicator;
private final TextureFrame[] queueIconFrames = new TextureFrame[WarsmashConstants.BUILD_QUEUE_SIZE];
private UIFrame attack1Icon; private UIFrame attack1Icon;
private TextureFrame attack1IconBackdrop; private TextureFrame attack1IconBackdrop;
@ -167,6 +170,10 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
private final float widthRatioCorrection; private final float widthRatioCorrection;
private final float heightRatioCorrection; private final float heightRatioCorrection;
private CommandCardIcon mouseDownUIFrame; private CommandCardIcon mouseDownUIFrame;
private UIFrame smashSimpleInfoPanel;
private SimpleFrame smashAttack1IconWrapper;
private SimpleFrame smashAttack2IconWrapper;
private SimpleFrame smashArmorIconWrapper;
public MeleeUI(final DataSource dataSource, final ExtendViewport uiViewport, public MeleeUI(final DataSource dataSource, final ExtendViewport uiViewport,
final FreeTypeFontGenerator fontGenerator, final Scene uiScene, final Scene portraitScene, 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.unitLifeText = (StringFrame) this.rootFrame.getFrameByName("UnitPortraitHitPointText", 0);
this.unitManaText = (StringFrame) this.rootFrame.getFrameByName("UnitPortraitManaPointText", 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); final float infoPanelUnitDetailWidth = GameUI.convertY(this.uiViewport, 0.180f);
this.simpleInfoPanelUnitDetail.setWidth(infoPanelUnitDetailWidth);
final float infoPanelUnitDetailHeight = GameUI.convertY(this.uiViewport, 0.105f); 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.simpleNameValue = (StringFrame) this.rootFrame.getFrameByName("SimpleNameValue", 0);
this.simpleClassValue = (StringFrame) this.rootFrame.getFrameByName("SimpleClassValue", 0); this.simpleClassValue = (StringFrame) this.rootFrame.getFrameByName("SimpleClassValue", 0);
this.simpleBuildingActionLabel = (StringFrame) this.rootFrame.getFrameByName("SimpleBuildingActionLabel", 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 // Create Simple Info Panel Building Detail
this.simpleInfoPanelBuildingDetail = this.rootFrame.createSimpleFrame("SimpleInfoPanelBuildingDetail", this.simpleInfoPanelBuildingDetail = this.rootFrame.createSimpleFrame("SimpleInfoPanelBuildingDetail",
this.consoleUI, 0); this.smashSimpleInfoPanel, 0);
this.simpleInfoPanelBuildingDetail
.addAnchor(new AnchorDefinition(FramePoint.BOTTOM, 0, GameUI.convertY(this.uiViewport, 0.0f)));
this.simpleInfoPanelBuildingDetail.setWidth(infoPanelUnitDetailWidth);
this.simpleInfoPanelBuildingDetail.setHeight(infoPanelUnitDetailHeight);
this.simpleBuildingNameValue = (StringFrame) this.rootFrame.getFrameByName("SimpleBuildingNameValue", 0); this.simpleBuildingNameValue = (StringFrame) this.rootFrame.getFrameByName("SimpleBuildingNameValue", 0);
this.simpleBuildingDescriptionValue = (StringFrame) this.rootFrame this.simpleBuildingDescriptionValue = (StringFrame) this.rootFrame
.getFrameByName("SimpleBuildingDescriptionValue", 0); .getFrameByName("SimpleBuildingDescriptionValue", 0);
@ -336,28 +341,59 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.simpleBuildingBuildTimeIndicator.setWidth(buildTimeIndicatorWidth); this.simpleBuildingBuildTimeIndicator.setWidth(buildTimeIndicatorWidth);
this.simpleBuildingBuildTimeIndicator.setHeight(buildTimeIndicatorHeight); this.simpleBuildingBuildTimeIndicator.setHeight(buildTimeIndicatorHeight);
this.simpleInfoPanelBuildingDetail.setVisible(false); 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, this.queueIconFrames[0] = this.rootFrame.createTextureFrame("SmashBuildQueueIcon0", this.smashSimpleInfoPanel,
0); false, new Vector4Definition(0, 1, 0, 1));
this.attack1Icon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, 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))); 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.attack1IconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 0);
this.attack1InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0); this.attack1InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0);
this.attack1InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 0); this.attack1InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 0);
this.attack2Icon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconDamage", this.simpleInfoPanelUnitDetail, this.smashAttack2IconWrapper = (SimpleFrame) this.rootFrame.createSimpleFrame("SmashSimpleInfoPanelIconDamage",
1); this.simpleInfoPanelUnitDetail, 0);
this.attack2Icon this.smashAttack2IconWrapper
.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, .addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT,
GameUI.convertX(this.uiViewport, 0.1f), GameUI.convertY(this.uiViewport, -0.030125f))); 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.attack2IconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 1);
this.attack2InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 1); this.attack2InfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 1);
this.attack2InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 1); this.attack2InfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 1);
this.armorIcon = this.rootFrame.createSimpleFrame("SimpleInfoPanelIconArmor", this.simpleInfoPanelUnitDetail, this.smashArmorIconWrapper = (SimpleFrame) this.rootFrame.createSimpleFrame("SmashSimpleInfoPanelIconArmor",
1); this.simpleInfoPanelUnitDetail, 0);
this.armorIcon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, this.smashArmorIconWrapper.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail,
GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.06025f))); 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.armorIconBackdrop = (TextureFrame) this.rootFrame.getFrameByName("InfoPanelIconBackdrop", 0);
this.armorInfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0); this.armorInfoPanelIconValue = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconValue", 0);
this.armorInfoPanelIconLevel = (StringFrame) this.rootFrame.getFrameByName("InfoPanelIconLevel", 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.meleeUIMinimap = createMinimap(this.war3MapViewer);
this.rootFrame.positionBounds(this.uiViewport); this.rootFrame.positionBounds(this.rootFrame, this.uiViewport);
selectUnit(null); selectUnit(null);
} }
@ -720,10 +756,17 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.attack2Icon.setVisible(false); this.attack2Icon.setVisible(false);
this.attack1InfoPanelIconLevel.setText(""); this.attack1InfoPanelIconLevel.setText("");
this.attack2InfoPanelIconLevel.setText(""); this.attack2InfoPanelIconLevel.setText("");
this.simpleBuildingActionLabel.setText(""); this.simpleBuildingBuildingActionLabel.setText("");
this.simpleBuildingNameValue.setText("");
this.armorIcon.setVisible(false); this.armorIcon.setVisible(false);
this.armorInfoPanelIconLevel.setText(""); this.armorInfoPanelIconLevel.setText("");
this.simpleBuildTimeIndicator.setVisible(false); 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 { else {
unit.getSimulationUnit().addStateListener(this); unit.getSimulationUnit().addStateListener(this);
@ -744,6 +787,28 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.unitManaText.setText(""); this.unitManaText.setText("");
} }
if (simulationUnit.getBuildQueue()[0] != null) { 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.simpleInfoPanelBuildingDetail.setVisible(true);
this.simpleInfoPanelUnitDetail.setVisible(false); this.simpleInfoPanelUnitDetail.setVisible(false);
this.simpleBuildingNameValue.setText(simulationUnit.getUnitType().getName()); this.simpleBuildingNameValue.setText(simulationUnit.getUnitType().getName());
@ -764,6 +829,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.armorIcon.setVisible(false); this.armorIcon.setVisible(false);
} }
else { else {
for (final TextureFrame queueIconFrame : this.queueIconFrames) {
queueIconFrame.setVisible(false);
}
this.simpleInfoPanelBuildingDetail.setVisible(false); this.simpleInfoPanelBuildingDetail.setVisible(false);
this.simpleInfoPanelUnitDetail.setVisible(true); this.simpleInfoPanelUnitDetail.setVisible(true);
this.simpleNameValue.setText(simulationUnit.getUnitType().getName()); this.simpleNameValue.setText(simulationUnit.getUnitType().getName());
@ -804,18 +872,21 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.attack2Icon.setVisible(false); this.attack2Icon.setVisible(false);
} }
this.armorIcon.addSetPoint( this.smashArmorIconWrapper.addSetPoint(
new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT, new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT,
GameUI.convertX(this.uiViewport, 0f), GameUI.convertY(this.uiViewport, -0.06025f))); 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 { else {
this.attack1Icon.setVisible(false); this.attack1Icon.setVisible(false);
this.attack2Icon.setVisible(false); this.attack2Icon.setVisible(false);
this.armorIcon.addSetPoint(new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, this.smashArmorIconWrapper.addSetPoint(
FramePoint.TOPLEFT, 0, GameUI.convertY(this.uiViewport, -0.030125f))); new SetPoint(FramePoint.TOPLEFT, this.simpleInfoPanelUnitDetail, FramePoint.TOPLEFT,
this.armorIcon.positionBounds(this.uiViewport); 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); localArmorIcon.setVisible(!constructing);
@ -824,6 +895,9 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
if (constructing) { if (constructing) {
this.simpleBuildingActionLabel this.simpleBuildingActionLabel
.setText(this.rootFrame.getTemplates().getDecoratedString("CONSTRUCTING")); .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 { else {
this.simpleBuildingActionLabel.setText(""); this.simpleBuildingActionLabel.setText("");
@ -1204,7 +1278,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
else { else {
if (clickedUIFrame instanceof CommandCardIcon) { if (clickedUIFrame instanceof CommandCardIcon) {
this.mouseDownUIFrame = (CommandCardIcon) clickedUIFrame; this.mouseDownUIFrame = (CommandCardIcon) clickedUIFrame;
this.mouseDownUIFrame.mouseDown(this.uiViewport); this.mouseDownUIFrame.mouseDown(this.rootFrame, this.uiViewport);
} }
} }
return false; return false;
@ -1219,7 +1293,7 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
this.mouseDownUIFrame.onClick(button); this.mouseDownUIFrame.onClick(button);
this.war3MapViewer.getUiSounds().getSound("InterfaceClick").play(this.uiScene.audioContext, 0, 0); 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; this.mouseDownUIFrame = null;
return false; return false;