Work on FDF

This commit is contained in:
Retera 2020-05-20 01:32:52 -04:00
parent 155c0cffa8
commit 57e7538ec8
51 changed files with 791 additions and 8 deletions

View File

@ -504,6 +504,25 @@ public class War3MapViewer extends ModelViewer {
path = path.substring(0, path.length() - 4);
}
final String unitShadow = "Shadow";
if ((unitShadow != null) && !"_".equals(unitShadow)) {
final String texture = "ReplaceableTextures\\Shadows\\" + unitShadow + ".blp";
final float shadowX = 50;
final float shadowY = 50;
final float shadowWidth = 128;
final float shadowHeight = 128;
if (!this.terrain.splats.containsKey(texture)) {
final Splat splat = new Splat();
splat.opacity = 0.5f;
this.terrain.splats.put(texture, splat);
}
final float x = unit.getLocation()[0] - shadowX;
final float y = unit.getLocation()[1] - shadowY;
this.terrain.splats.get(texture).locations
.add(new float[] { x, y, x + shadowWidth, y + shadowHeight, 3 });
unitShadowSplat = this.terrain.splats.get(texture);
}
path += ".mdx";
}
}
@ -608,6 +627,14 @@ public class War3MapViewer extends ModelViewer {
else {
this.items.add(new RenderItem(this, model, row, unit, soundset, portraitModel)); // TODO store
// somewhere
if (unitShadowSplat != null) {
unitShadowSplat.unitMapping.add(new Consumer<SplatModel.SplatMover>() {
@Override
public void accept(final SplatMover t) {
}
});
}
}
}
else {

View File

@ -6,7 +6,7 @@ import org.antlr.v4.runtime.tree.TerminalNode;
import com.etheller.warsmash.fdfparser.FDFParser.IncludeStatementContext;
import com.etheller.warsmash.fdfparser.FDFParser.StringListStatementContext;
import com.etheller.warsmash.parsers.fdf.templates.FrameTemplateEnvironment;
import com.etheller.warsmash.parsers.fdf.datamodel.FrameTemplateEnvironment;
public class FrameDefinitionVisitor extends FDFBaseVisitor<Void> {
private final FrameTemplateEnvironment templates;

View File

@ -4,7 +4,7 @@ import org.antlr.v4.runtime.BaseErrorListener;
import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Recognizer;
import com.etheller.warsmash.parsers.fdf.templates.FrameTemplateEnvironment;
import com.etheller.warsmash.parsers.fdf.datamodel.FrameTemplateEnvironment;
public class Main {
public static final boolean REPORT_SYNTAX_ERRORS = true;

View File

@ -1,6 +1,6 @@
package com.etheller.warsmash.parsers.fdf;
import com.etheller.warsmash.parsers.fdf.templates.FrameTemplateEnvironment;
import com.etheller.warsmash.parsers.fdf.datamodel.FrameTemplateEnvironment;
public interface FDFStatement {
void loadTemplate(FrameTemplateEnvironment frameDef);

View File

@ -2,7 +2,7 @@ package com.etheller.warsmash.parsers.fdf;
import java.util.List;
import com.etheller.warsmash.parsers.fdf.templates.FrameTemplateEnvironment;
import com.etheller.warsmash.parsers.fdf.datamodel.FrameTemplateEnvironment;
public class FDFStringListStatement implements FDFStatement {
private final List<FDFNamedString> namedStrings;

View File

@ -0,0 +1,25 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class AnchorDefinition {
private final FramePoint myPoint;
private final float x;
private final float y;
public AnchorDefinition(final FramePoint myPoint, final float x, final float y) {
this.myPoint = myPoint;
this.x = x;
this.y = y;
}
public FramePoint getMyPoint() {
return this.myPoint;
}
public float getX() {
return this.x;
}
public float getY() {
return this.y;
}
}

View File

@ -0,0 +1,12 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum BackdropCornerFlags {
UL,
UR,
BL,
BR,
T,
L,
B,
R;
}

View File

@ -0,0 +1,28 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class ColorDefinition {
private final float red, green, blue, alpha;
public ColorDefinition(final float red, final float green, final float blue, final float alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
public float getRed() {
return this.red;
}
public float getGreen() {
return this.green;
}
public float getBlue() {
return this.blue;
}
public float getAlpha() {
return this.alpha;
}
}

View File

@ -0,0 +1,7 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum ControlStyle {
AUTOTRACK,
HIGHLIGHTONFOCUS,
HIGHLIGHTONMOUSEOVER;
}

View File

@ -0,0 +1,25 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class FontDefinition {
private final String fontName;
private final float fontSize;
private final String extra;
public FontDefinition(final String fontName, final float fontSize, final String extra) {
this.fontName = fontName;
this.fontSize = fontSize;
this.extra = extra;
}
public String getFontName() {
return this.fontName;
}
public float getFontSize() {
return this.fontSize;
}
public String getExtra() {
return this.extra;
}
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum FontFlags {
FIXEDSIZE;
}

View File

@ -0,0 +1,45 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.etheller.warsmash.parsers.fdf.datamodel.fields.FrameDefinitionField;
/**
* Pretty sure this is probably not how it works in-game but this silly
* everything class might help get a prototype running fast until I have a
* better understanding of how I want these classes designed.
*/
public class FrameDefintion {
private String frameType;
private String name;
private final List<FrameDefintion> innerFrames = new ArrayList<>();
private final Set<String> flags = new HashSet<>();
private final Map<String, FrameDefinitionField> nameToField = new HashMap<>();
private final List<SetPointDefinition> setPoints = new ArrayList<>();
private final List<AnchorDefinition> anchors = new ArrayList<>();
public void inheritFrom(final FrameDefintion other, final boolean withChildren) {
this.flags.addAll(other.flags);
this.nameToField.putAll(other.nameToField);
if (withChildren) {
this.innerFrames.addAll(other.innerFrames);
}
}
public void set(final String fieldName, final FrameDefinitionField value) {
this.nameToField.put(fieldName, value);
}
public void add(final SetPointDefinition setPointDefinition) {
this.setPoints.add(setPointDefinition);
}
public void add(final AnchorDefinition anchorDefinition) {
this.anchors.add(anchorDefinition);
}
}

View File

@ -0,0 +1,68 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
/**
* Pretty sure this is probably not how it works in-game but this silly
* everything class might help get a prototype running fast until I have a
* better understanding of how I want these classes designed.
*/
public class FrameDefintionOld {
private String frameType;
private String name;
// everything
private float width;
private float height;
private boolean decorateFileNames;
private boolean setAllPoints;
private final List<FrameDefintionOld> innerFrames = new ArrayList<>();
// "BACKDROP"
private boolean backdropTileBackground;
private boolean backdropHalfSides;
private boolean backdropBlendAll;
private String backdropBackground;
private EnumSet<BackdropCornerFlags> backdropCornerFlags;
private float backdropCornerSize;
private float backdropBackgroundSize;
private Insets backdropBackgroundInsets;
private String backdropCornerFile;
private String backdropLeftFile;
private String backdropRightFile;
private String backdropTopFile;
private String backdropBottomFile;
private String backdropEdgeFile;
// "HIGHLIGHT"
private HighlightType highlightType;
private String highlightAlphaFile;
private HighlightAlphaMode highlightAlphaMode;
// "TEXTBUTTON" or "GLUEBUTTON"
private EnumSet<ControlStyle> controlStyle;
private Offset buttonPushedTextOffset;
private String controlBackdrop;
private String controlPushedBackdrop;
private String controlDisabledBackdrop;
private String controlFocusHighlight;
private String controlMouseOverHighlight;
// "TEXT"
private FontDefinition frameFont;
private TextJustify fontJustificationH;
private TextJustify fontJustificationV;
private EnumSet<FontFlags> fontFlags;
private ColorDefinition fontColor;
private ColorDefinition fontHighlightColor;
private ColorDefinition fontDisabledColor;
private ColorDefinition fontShadowColor;
private Offset fontShadowOffset;
// "SLIDER"
private boolean sliderLayoutHorizontal;
// "SCROLLBAR"
private boolean sliderLayoutVertical;
private String scrollBarIncButtonFrame;
private String scrollBarDecButtonFrame;
private String scrollBarThumbButtonFrame;
// "LISTBOX"
private float listBoxBorder;
// "EDITBOX"
}

View File

@ -1,4 +1,4 @@
package com.etheller.warsmash.parsers.fdf.templates;
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum FrameEvent {
CONTROL_CLICK,

View File

@ -1,4 +1,4 @@
package com.etheller.warsmash.parsers.fdf.templates;
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum FramePoint {
TOPLEFT,

View File

@ -1,4 +1,4 @@
package com.etheller.warsmash.parsers.fdf.templates;
package com.etheller.warsmash.parsers.fdf.datamodel;
import java.util.HashMap;
import java.util.Map;

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum HighlightAlphaMode {
ADD;
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum HighlightType {
FILETEXTURE;
}

View File

@ -0,0 +1,41 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class Insets {
private float top;
private float left;
private float bottom;
private float right;
public float getTop() {
return this.top;
}
public float getLeft() {
return this.left;
}
public float getBottom() {
return this.bottom;
}
public float getRight() {
return this.right;
}
public void setTop(final float top) {
this.top = top;
}
public void setLeft(final float left) {
this.left = left;
}
public void setBottom(final float bottom) {
this.bottom = bottom;
}
public void setRight(final float right) {
this.right = right;
}
}

View File

@ -0,0 +1,23 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class Offset {
private float x;
private float y;
public float getX() {
return this.x;
}
public float getY() {
return this.y;
}
public void setX(final float x) {
this.x = x;
}
public void setY(final float y) {
this.y = y;
}
}

View File

@ -0,0 +1,38 @@
package com.etheller.warsmash.parsers.fdf.datamodel;
public class SetPointDefinition {
private final FramePoint myPoint;
private final String other;
private final FramePoint otherPoint;
private final float x;
private final float y;
public SetPointDefinition(final FramePoint myPoint, final String other, final FramePoint otherPoint, final float x,
final float y) {
this.myPoint = myPoint;
this.other = other;
this.otherPoint = otherPoint;
this.x = x;
this.y = y;
}
public FramePoint getMyPoint() {
return this.myPoint;
}
public String getOther() {
return this.other;
}
public FramePoint getOtherPoint() {
return this.otherPoint;
}
public float getX() {
return this.x;
}
public float getY() {
return this.y;
}
}

View File

@ -1,4 +1,4 @@
package com.etheller.warsmash.parsers.fdf.templates;
package com.etheller.warsmash.parsers.fdf.datamodel;
public enum TextJustify {
TOP,

View File

@ -0,0 +1,21 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
import com.etheller.warsmash.parsers.fdf.datamodel.ColorDefinition;
public class ColorFrameDefinitionField implements FrameDefinitionField {
private final ColorDefinition value;
public ColorFrameDefinitionField(final ColorDefinition value) {
this.value = value;
}
public ColorDefinition getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,18 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
public class FloatFrameDefinitionField implements FrameDefinitionField {
private final float value;
public FloatFrameDefinitionField(final float value) {
this.value = value;
}
public float getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,21 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
import com.etheller.warsmash.parsers.fdf.datamodel.FontDefinition;
public class FontFrameDefinitionField implements FrameDefinitionField {
private final FontDefinition value;
public FontFrameDefinitionField(final FontDefinition value) {
this.value = value;
}
public FontDefinition getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
public interface FrameDefinitionField {
<TYPE> TYPE visit(FrameDefinitionFieldVisitor<TYPE> visitor);
}

View File

@ -0,0 +1,15 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
public interface FrameDefinitionFieldVisitor<TYPE> {
TYPE accept(StringFrameDefinitionField field);
TYPE accept(FloatFrameDefinitionField field);
TYPE accept(ColorFrameDefinitionField field);
TYPE accept(InsetsFrameDefinitionField field);
TYPE accept(OffsetFrameDefinitionField field);
TYPE accept(FontFrameDefinitionField field);
}

View File

@ -0,0 +1,20 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
import com.etheller.warsmash.parsers.fdf.datamodel.Insets;
public class InsetsFrameDefinitionField implements FrameDefinitionField {
private final Insets value;
public InsetsFrameDefinitionField(final Insets value) {
this.value = value;
}
public Insets getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,20 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
import com.etheller.warsmash.parsers.fdf.datamodel.Offset;
public class OffsetFrameDefinitionField implements FrameDefinitionField {
private final Offset value;
public OffsetFrameDefinitionField(final Offset value) {
this.value = value;
}
public Offset getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,18 @@
package com.etheller.warsmash.parsers.fdf.datamodel.fields;
public class StringFrameDefinitionField implements FrameDefinitionField {
private final String value;
public StringFrameDefinitionField(final String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
@Override
public <TYPE> TYPE visit(final FrameDefinitionFieldVisitor<TYPE> visitor) {
return visitor.accept(this);
}
}

View File

@ -0,0 +1,113 @@
package com.etheller.warsmash.parsers.fdf.frames;
import java.util.EnumSet;
import com.etheller.warsmash.parsers.fdf.datamodel.BackdropCornerFlags;
import com.etheller.warsmash.parsers.fdf.datamodel.Insets;
import com.etheller.warsmash.parsers.fdf.frames.base.Frame;
public class FrameBackdrop extends Frame {
private boolean tileBackground;
private boolean halfSides;
private boolean blendAll;
private String background;
private EnumSet<BackdropCornerFlags> cornerFlags;
private float cornerSize;
private float backgroundSize;
private Insets backgroundInsets;
private String cornerFile;
private String leftFile;
private String rightFile;
private String topFile;
private String bottomFile;
private String edgeFile;
public boolean isTileBackground() {
return this.tileBackground;
}
public boolean isHalfSides() {
return this.halfSides;
}
public boolean isBlendAll() {
return this.blendAll;
}
public String getBackground() {
return this.background;
}
public EnumSet<BackdropCornerFlags> getCornerFlags() {
return this.cornerFlags;
}
public float getCornerSize() {
return this.cornerSize;
}
public String getCornerFile() {
return this.cornerFile;
}
public String getLeftFile() {
return this.leftFile;
}
public String getRightFile() {
return this.rightFile;
}
public String getTopFile() {
return this.topFile;
}
public String getBottomFile() {
return this.bottomFile;
}
public void setTileBackground(final boolean tileBackground) {
this.tileBackground = tileBackground;
}
public void setHalfSides(final boolean halfSides) {
this.halfSides = halfSides;
}
public void setBlendAll(final boolean blendAll) {
this.blendAll = blendAll;
}
public void setBackground(final String background) {
this.background = background;
}
public void setCornerFlags(final EnumSet<BackdropCornerFlags> cornerFlags) {
this.cornerFlags = cornerFlags;
}
public void setCornerSize(final float cornerSize) {
this.cornerSize = cornerSize;
}
public void setCornerFile(final String cornerFile) {
this.cornerFile = cornerFile;
}
public void setLeftFile(final String leftFile) {
this.leftFile = leftFile;
}
public void setRightFile(final String rightFile) {
this.rightFile = rightFile;
}
public void setTopFile(final String topFile) {
this.topFile = topFile;
}
public void setBottomFile(final String bottomFile) {
this.bottomFile = bottomFile;
}
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameButton {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameChatDisplay {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameCheckBox {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameDialog {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameEditBox {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameFrame {
}

View File

@ -0,0 +1,35 @@
package com.etheller.warsmash.parsers.fdf.frames;
import com.etheller.warsmash.parsers.fdf.datamodel.HighlightAlphaMode;
import com.etheller.warsmash.parsers.fdf.datamodel.HighlightType;
import com.etheller.warsmash.parsers.fdf.frames.base.Frame;
public class FrameHighlight extends Frame {
private HighlightType type;
private String alphaFile;
private HighlightAlphaMode alphaMode;
public HighlightType getType() {
return this.type;
}
public String getAlphaFile() {
return this.alphaFile;
}
public HighlightAlphaMode getAlphaMode() {
return this.alphaMode;
}
public void setType(final HighlightType type) {
this.type = type;
}
public void setAlphaFile(final String alphaFile) {
this.alphaFile = alphaFile;
}
public void setAlphaMode(final HighlightAlphaMode alphaMode) {
this.alphaMode = alphaMode;
}
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameListBox {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameMenu {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FramePopupMenu {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameScrollbar {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameSlider {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameText {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames;
public class FrameTextArea {
}

View File

@ -0,0 +1,19 @@
package com.etheller.warsmash.parsers.fdf.frames;
import java.util.EnumSet;
import com.etheller.warsmash.parsers.fdf.datamodel.ControlStyle;
import com.etheller.warsmash.parsers.fdf.datamodel.Offset;
import com.etheller.warsmash.parsers.fdf.frames.base.Frame;
public class FrameTextButton extends Frame {
private EnumSet<ControlStyle> controlStyle;
private Offset buttonPushedTextOffset;
private String controlBackdrop;
private String controlPushedBackdrop;
private String controlDisabledBackdrop;
private String controlFocusHighlight;
private String controlMouseOverHighlight;
}

View File

@ -0,0 +1,39 @@
package com.etheller.warsmash.parsers.fdf.frames.base;
import java.util.ArrayList;
import java.util.List;
public class Frame {
private String name;
private float width;
private float height;
private final List<Frame> innerFrames = new ArrayList<>();
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
public float getWidth() {
return this.width;
}
public float getHeight() {
return this.height;
}
public void setWidth(final float width) {
this.width = width;
}
public void setHeight(final float height) {
this.height = height;
}
public List<Frame> getInnerFrames() {
return this.innerFrames;
}
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames.simple;
public class FrameSimpleButton {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames.simple;
public class FrameSimpleCheckBox {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames.simple;
public class FrameSimpleFrame {
}

View File

@ -0,0 +1,5 @@
package com.etheller.warsmash.parsers.fdf.frames.simple;
public class FrameSimpleStatusBar {
}