diff --git a/src/main/java/cam72cam/immersiverailroading/ConfigGraphics.java b/src/main/java/cam72cam/immersiverailroading/ConfigGraphics.java index d2da9781f..85e984b14 100644 --- a/src/main/java/cam72cam/immersiverailroading/ConfigGraphics.java +++ b/src/main/java/cam72cam/immersiverailroading/ConfigGraphics.java @@ -1,22 +1,22 @@ package cam72cam.immersiverailroading; +import cam72cam.immersiverailroading.library.PressureDisplayType; import cam72cam.immersiverailroading.library.SpeedDisplayType; +import cam72cam.immersiverailroading.library.TemperatureDisplayType; +import cam72cam.immersiverailroading.library.ValveGearConfig; import cam72cam.mod.config.ConfigFile.Comment; import cam72cam.mod.config.ConfigFile.Name; import cam72cam.mod.render.OptiFine; +import java.util.HashMap; +import java.util.Map; + import static cam72cam.mod.config.ConfigFile.*; @Comment("Configuration File") @Name("general") @File("immersiverailroading_graphics.cfg") public class ConfigGraphics { - @Comment( "Place to draw the Train GUI as a % from the left of the screen" ) - public static int GUIPositionHorizontal = 2; - - @Comment( "Place to draw the Train GUI as a % from the top of the screen" ) - public static int GUIPositionVertical = 95; - @Comment("Enable Particles") public static boolean particlesEnabled = true; @@ -26,6 +26,12 @@ public class ConfigGraphics { @Comment( "What unit to use for speedometer. (kmh, mph or ms)" ) public static SpeedDisplayType speedUnit = SpeedDisplayType.kmh; + @Comment("What units to display pressure in (psi, bar)") + public static PressureDisplayType pressureUnit = PressureDisplayType.psi; + + @Comment("What units to display pressure in (psi, bar)") + public static TemperatureDisplayType temperatureUnit = TemperatureDisplayType.celcius; + @Comment( "How long to keep textures in memory after they have left the screen (higher numbers = smoother game play, lower numbers = less GPU memory used)") @Range(min = 0, max = 100) public static int textureCacheSeconds = 30; @@ -52,4 +58,7 @@ public class ConfigGraphics { @Comment("How likely a piece of stock is to sway (1 == always, 10 == infrequent)") @Range(min = 0, max = 10) public static int StockSwayChance = 1; + + @Comment("Settings used in the stock user interfaces") + public static Map settings = new HashMap<>(); } diff --git a/src/main/java/cam72cam/immersiverailroading/ImmersiveRailroading.java b/src/main/java/cam72cam/immersiverailroading/ImmersiveRailroading.java index 474f361ee..746e43acc 100644 --- a/src/main/java/cam72cam/immersiverailroading/ImmersiveRailroading.java +++ b/src/main/java/cam72cam/immersiverailroading/ImmersiveRailroading.java @@ -217,6 +217,8 @@ public void postRender(EntityMoveableRollingStock entity, RenderState state, flo return true; }); + ClientEvents.TICK.subscribe(GuiBuilder::onClientTick); + Particles.SMOKE = Particle.register(SmokeParticle::new, SmokeParticle::renderAll); ClientPartDragging.register(); diff --git a/src/main/java/cam72cam/immersiverailroading/entity/EntityRollingStock.java b/src/main/java/cam72cam/immersiverailroading/entity/EntityRollingStock.java index 617896852..ccc3fe6a6 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/EntityRollingStock.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/EntityRollingStock.java @@ -138,7 +138,9 @@ public ClickResult onClick(Player player, Player.Hand hand) { } public void setTexture(String variant) { - this.texture = variant; + if (getDefinition().textureNames.containsKey(variant)) { + this.texture = variant; + } } @Override diff --git a/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java b/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java index 2a4a8af4d..45b3e69cb 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/Locomotive.java @@ -48,10 +48,12 @@ public abstract class Locomotive extends FreightTank { @TagField("HORN") protected int hornTime = 0; - public static final UUID AUTOMATED_PLAYER = new UUID(0, 0); @TagSync @TagField(value = "HORN_PLAYER", mapper = StrictTagMapper.class) protected UUID hornPlayer = null; + @TagSync + @TagField(value = "HORN_PULL") + public float hornPull; @TagSync @TagField("BELL") @@ -325,6 +327,7 @@ public void onTick() { if (getWorld().isServer) { sync.setInterval(5); for (Control control : getDefinition().getModel().getControls()) { + // Logic duplicated in Readouts#setValue if (!getDefinition().isLinearBrakeControl() && control.part.type == ModelComponentType.TRAIN_BRAKE_X) { setTrainBrake(Math.max(0, Math.min(1, getTrainBrake() + (getControlPosition(control) - 0.5f) / 8))); } @@ -349,6 +352,9 @@ public void onTick() { } else if (hornPlayer != null) { hornPlayer = null; } + if (hornTime == 0) { + hornPull = 0; + } OptionalDouble control = this.getDefinition().getModel().getControls().stream() .filter(x -> x.part.type == ModelComponentType.BELL_CONTROL_X) .mapToDouble(this::getControlPosition) @@ -504,6 +510,11 @@ private void setRealReverser(float newReverser){ } public void setHorn(int val, UUID uuid) { + if (uuid == null) { + // Legacy API + hornPull = 1; + } + if (hornPlayer == null && uuid != null) { hornPlayer = uuid; } @@ -512,6 +523,11 @@ public void setHorn(int val, UUID uuid) { } } + public void setHorn(int time, float value) { + hornTime = time; + hornPull = value; + } + public int getHornTime() { return hornTime; } @@ -525,8 +541,16 @@ public Entity getHornPlayer() { return null; } - public boolean isAutomatedHorn() { - return AUTOMATED_PLAYER.equals(hornPlayer); + public float getHornPull() { + if (getHornPlayer() != null) { + return (getHornPlayer().getRotationPitch() + 90) / 180; + } + double control = this.getDefinition().getModel().getControls().stream() + .filter(x -> x.part.type == ModelComponentType.WHISTLE_CONTROL_X) + .mapToDouble(this::getControlPosition) + .max().orElse(0); + + return Math.max((float)control, hornPull); } @Deprecated diff --git a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java index 0e692669e..00060f10a 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/LocomotiveSteam.java @@ -102,7 +102,7 @@ public double getAppliedTractiveEffort(Speed speed) { // Cap the max "effective" reverser. At high speeds having a fully open reverser just damages equipment double reverser = getReverser(); - double reverserCap = 0.5; + double reverserCap = 0.25; double maxReverser = 1 - Math.abs(getCurrentSpeed().metric()) / getDefinition().getMaxSpeed(gauge).metric() * reverserCap; // This should probably be tuned... diff --git a/src/main/java/cam72cam/immersiverailroading/entity/physics/SimulationState.java b/src/main/java/cam72cam/immersiverailroading/entity/physics/SimulationState.java index 316771b8d..d5e0fe1ba 100644 --- a/src/main/java/cam72cam/immersiverailroading/entity/physics/SimulationState.java +++ b/src/main/java/cam72cam/immersiverailroading/entity/physics/SimulationState.java @@ -162,7 +162,7 @@ public boolean equals(Object o) { couplerEngagedRear == other.couplerEngagedRear && Math.abs(tractiveEffortFactors - other.tractiveEffortFactors) < 0.01 && Math.abs(massKg - other.massKg)/massKg < 0.01 && - (desiredBrakePressure == null || Math.abs(desiredBrakePressure - other.desiredBrakePressure) < 0.1) && + (desiredBrakePressure == null || Math.abs(desiredBrakePressure - other.desiredBrakePressure) < 0.001) && Math.abs(independentBrakePosition - other.independentBrakePosition) < 0.01; } return false; diff --git a/src/main/java/cam72cam/immersiverailroading/gui/overlay/GuiBuilder.java b/src/main/java/cam72cam/immersiverailroading/gui/overlay/GuiBuilder.java index 180da9e97..3fe64cd3f 100644 --- a/src/main/java/cam72cam/immersiverailroading/gui/overlay/GuiBuilder.java +++ b/src/main/java/cam72cam/immersiverailroading/gui/overlay/GuiBuilder.java @@ -1,9 +1,15 @@ package cam72cam.immersiverailroading.gui.overlay; +import cam72cam.immersiverailroading.ConfigGraphics; import cam72cam.immersiverailroading.entity.EntityCoupleableRollingStock; import cam72cam.immersiverailroading.entity.EntityRollingStock; import cam72cam.immersiverailroading.library.GuiText; +import cam72cam.immersiverailroading.registry.EntityRollingStockDefinition; import cam72cam.immersiverailroading.util.DataBlock; +import cam72cam.immersiverailroading.util.MergedBlocks; +import cam72cam.mod.MinecraftClient; +import cam72cam.mod.config.ConfigFile; +import cam72cam.mod.entity.Entity; import cam72cam.mod.event.ClientEvents; import cam72cam.mod.gui.helpers.GUIHelpers; import cam72cam.mod.math.Vec3d; @@ -17,15 +23,17 @@ import util.Matrix4; import javax.imageio.ImageIO; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.*; +import java.util.List; public class GuiBuilder { private final float x; private final float y; - private final boolean centerx; - private final boolean centery; + private final Horizontal screen_x; + private final Vertical screen_y; private final Identifier image; private final int imageWidth; @@ -36,9 +44,13 @@ public class GuiBuilder { private final Readouts readout; private final String control; + private final String setting; + private final String texture_variant; + private final Float setting_default; private final boolean global; private final boolean invert; - private final boolean hide; + private final boolean translucent; + private final boolean toggle; private final float tlx; private final float tly; private final float rotx; @@ -49,20 +61,59 @@ public class GuiBuilder { private final Float scaley; private final Map colors = new HashMap<>(); + private final EntityRollingStockDefinition.ControlSoundsDefinition sound; private final List elements; + private float temporary_value = 0.5f; + + private enum Horizontal { + LEFT, + RIGHT, + MIDDLE, + ; + + public static Horizontal from(String pos_x) { + return pos_x == null ? LEFT : valueOf(pos_x.toUpperCase(Locale.ROOT)); + } + } + private enum Vertical { + TOP, + MIDDLE, + BOTTOM, + ; + public static Vertical from(String pos_y) { + return pos_y == null ? TOP : valueOf(pos_y.toUpperCase(Locale.ROOT)); + } + } + + private static DataBlock processImports(DataBlock data) throws IOException { + // This is kinda weird as it appends the import to the current block instead of inserting it in the current + // element list. It's definitely a bit of a footgun. The "correct" way to do this would be to make import part + // of parsing in CAML, which is it's own sort of weirdness due to JSON interop. + List direct = data.getValues("import"); + if (direct != null) { + for (DataBlock.Value imp : direct) { + data = new MergedBlocks(data, processImports(DataBlock.load(imp.asIdentifier()))); + } + } + List imports = data.getBlocks("import"); + if (imports != null) { + for (DataBlock imp : imports) { + data = new MergedBlocks(data, processImports(DataBlock.load(imp.getValue("source").asIdentifier(), imp.getBlock("replace")))); + } + } + return data; + } + protected GuiBuilder(DataBlock data) throws IOException { + data = processImports(data); + // common stuff this.x = data.getValue("x").asFloat(0f); this.y = data.getValue("y").asFloat(0f); - DataBlock centered = data.getBlock("centered"); - if (centered != null) { - this.centerx = centered.getValue("x").asBoolean(false); - this.centery = centered.getValue("y").asBoolean(false); - } else { - this.centerx = this.centery = false; - } + this.screen_x = Horizontal.from(data.getValue("screen_x").asString()); + this.screen_y = Vertical.from(data.getValue("screen_y").asString()); // Image stuff this.image = data.getValue("image").asIdentifier(null); @@ -89,9 +140,15 @@ protected GuiBuilder(DataBlock data) throws IOException { String readout = data.getValue("readout").asString(); this.readout = readout != null ? Readouts.valueOf(readout.toUpperCase(Locale.ROOT)) : null; this.control = data.getValue("control").asString(); + this.setting = data.getValue("setting").asString(); + this.setting_default = data.getValue("setting_default").asFloat(); + this.texture_variant = data.getValue("texture_variant").asString(); + DataBlock soundBlock = data.getBlock("sound"); + this.sound = soundBlock != null ? new EntityRollingStockDefinition.ControlSoundsDefinition(soundBlock) : null; this.global = data.getValue("global").asBoolean(false); this.invert = data.getValue("invert").asBoolean(false); - this.hide = data.getValue("hide").asBoolean(false); + this.translucent = data.getValue("translucent").asBoolean(data.getValue("hide").asBoolean(false)); + this.toggle = data.getValue("toggle").asBoolean(false); DataBlock tl = data.getBlock("translate"); if (tl != null) { @@ -147,12 +204,6 @@ protected GuiBuilder(DataBlock data) throws IOException { elements.add(new GuiBuilder(element)); } } - List imports = data.getValues("import"); - if (imports != null) { - for (DataBlock.Value imp : imports) { - elements.add(parse(imp.asIdentifier())); - } - } } public static GuiBuilder parse(Identifier overlay) throws IOException { @@ -161,28 +212,45 @@ public static GuiBuilder parse(Identifier overlay) throws IOException { private void applyPosition(Matrix4 matrix, int maxx, int maxy) { matrix.translate(this.x, this.y, 0); - if (centerx) { - matrix.translate(maxx/2f, 0, 0); - } - if (centery) { - matrix.translate(0, maxy/2f, 0); - } - Vec3d offset = matrix.apply(Vec3d.ZERO); - if (offset.x < 0) { - matrix.translate(maxx, 0, 0); + switch (screen_x) { + case LEFT: + // NOP + break; + case MIDDLE: + matrix.translate(maxx/2f, 0, 0); + break; + case RIGHT: + matrix.translate(maxx, 0, 0); + break; } - if (offset.y < 0) { - matrix.translate(0, maxy, 0); + switch (screen_y) { + case TOP: + // NOP + break; + case MIDDLE: + matrix.translate(0, maxy/2f, 0); + break; + case BOTTOM: + matrix.translate(0, maxy, 0); + break; } } private float getValue(EntityRollingStock stock) { float value = 0; if (readout != null) { - value = readout.getValue(stock); + value = readout.getValue(stock, temporary_value); } else if (control != null) { value = stock.getControlPosition(control); + } else if (setting != null) { + if (!ConfigGraphics.settings.containsKey(setting) && setting_default != null) { + ConfigGraphics.settings.put(setting, setting_default); + } + + value = ConfigGraphics.settings.getOrDefault(setting, 0f); + } else if (texture_variant != null) { + value = texture_variant.equals(stock.getTexture()) ? 1 : 0; } if (invert) { @@ -192,7 +260,7 @@ private float getValue(EntityRollingStock stock) { return value; } - private void applyValue(Matrix4 matrix, float value, int maxx, int maxy) { + private void applyValue(Matrix4 matrix, float value) { if (tlx != 0 || tly != 0) { matrix.translate(tlx * value, tly * value, 0); } @@ -204,29 +272,25 @@ private void applyValue(Matrix4 matrix, float value, int maxx, int maxy) { if (scalex != null || scaley != null) { matrix.scale(scalex != null ? scalex * value : 1, scaley != null ? scaley * value : 1, 1); } - - Vec3d offset = matrix.apply(Vec3d.ZERO); - if (offset.x < 0) { - matrix.translate(maxx, 0, 0); - } - if (offset.y < 0) { - matrix.translate(0, maxy, 0); - } } public void render(RenderState state, EntityRollingStock stock) { - render(stock, state.clone().color(1, 1, 1, 1), GUIHelpers.getScreenWidth(), GUIHelpers.getScreenHeight()); + render(stock, state.clone().color(1, 1, 1, 1), GUIHelpers.getScreenWidth(), GUIHelpers.getScreenHeight(), 0xFFFFFFFF); } - private void render(EntityRollingStock stock, RenderState state, int maxx, int maxy) { + private void render(EntityRollingStock stock, RenderState state, int maxx, int maxy, int baseColor) { float value = getValue(stock); - if (hide && value != 1) { - return; + if (translucent) { + if (value == 0) { + return; + } + float alpha = (baseColor >> 24 & 255) / 255f * value; + baseColor = baseColor & 0x00FFFFFF | ((int)(alpha * 255f) << 24); } state = state.clone(); // TODO mem opt? applyPosition(state.model_view(), maxx, maxy); - applyValue(state.model_view(), value, maxx, maxy); + applyValue(state.model_view(), value); Float colorKey = null; for (float key : colors.keySet()) { @@ -235,9 +299,16 @@ private void render(EntityRollingStock stock, RenderState state, int maxx, int m } } - int col = colors.getOrDefault(colorKey, 0xFFFFFFFF); - if (colorKey != null) { - state.color((col >> 16 & 255) / 255.0f, (col >> 8 & 255) / 255.0f, (col & 255) / 255.0f, (col >> 24 & 255) / 255.0f); + if (colorKey != null && colors.containsKey(colorKey)) { + float oldAlpha = (baseColor >> 24 & 255) / 255f; + + int newColor = colors.get(colorKey); + float newAlpha = (newColor >> 24 & 255) / 255f; + baseColor = newColor & 0x00FFFFFF | ((int)(newAlpha * oldAlpha * 255f) << 24); + } + + if (colorKey != null || translucent) { + state.color((baseColor >> 16 & 255) / 255.0f, (baseColor >> 8 & 255) / 255.0f, (baseColor & 255) / 255.0f, (baseColor >> 24 & 255) / 255.0f); } if (image != null) { @@ -266,21 +337,21 @@ private void render(EntityRollingStock stock, RenderState state, int maxx, int m float scale = textHeight / 8f; Matrix4 mat = state.model_view().copy(); mat.scale(scale, scale, scale); - GUIHelpers.drawCenteredString(out, 0, 0, col, mat); + GUIHelpers.drawCenteredString(out, 0, 0, baseColor, mat); } for (GuiBuilder element : elements) { - element.render(stock, state, maxx, maxy); + element.render(stock, state, maxx, maxy, baseColor); } } private GuiBuilder find(EntityRollingStock stock, Matrix4 matrix, int maxx, int maxy, int x, int y) { float value = getValue(stock); - if (hide && value != 1) { + if (translucent && value == 0) { return null; } matrix = matrix.copy(); // TODO mem opt? applyPosition(matrix, maxx, maxy); - applyValue(matrix, value, maxx, maxy); + applyValue(matrix, value); for (GuiBuilder element : elements) { GuiBuilder found = element.find(stock, matrix, maxx, maxy, x, y); if (found != null) { @@ -288,8 +359,8 @@ private GuiBuilder find(EntityRollingStock stock, Matrix4 matrix, int maxx, int } } - if (image != null) { - if (control == null) { + if (image != null && interactable()) { + if (control == null && setting == null && texture_variant == null) { if (readout == null) { return null; } @@ -297,6 +368,7 @@ private GuiBuilder find(EntityRollingStock stock, Matrix4 matrix, int maxx, int case THROTTLE: case REVERSER: case TRAIN_BRAKE: + case TRAIN_BRAKE_LEVER: case INDEPENDENT_BRAKE: case COUPLER_FRONT: case COUPLER_REAR: @@ -311,18 +383,30 @@ private GuiBuilder find(EntityRollingStock stock, Matrix4 matrix, int maxx, int } int border = 2; Vec3d cornerA = matrix.apply(new Vec3d(-border, -border, 0)); - Vec3d cornerB = matrix.apply(new Vec3d(imageWidth + border, imageHeight + border, 0)); - if (x >= cornerA.x && x <= cornerB.x || x >= cornerB.x && x <= cornerA.x) { - if (y >= cornerA.y && y <= cornerB.y || y >= cornerB.y && y <= cornerA.y) { - return this; - } + Vec3d cornerB = matrix.apply(new Vec3d(-border, imageHeight + border, 0)); + Vec3d cornerC = matrix.apply(new Vec3d(imageWidth + border, -border, 0)); + Vec3d cornerD = matrix.apply(new Vec3d(imageWidth + border, imageHeight + border, 0)); + + Polygon poly = new Polygon( + new int[]{(int) cornerA.x, (int) cornerB.x, (int) cornerC.x, (int) cornerD.x}, + new int[]{(int) cornerA.y, (int) cornerB.y, (int) cornerC.y, (int) cornerD.y}, + 4 + ); + if (poly.getBounds2D().contains(x, y)) { + return this; } } return null; } - private boolean hasMovement() { - return tlx != 0 || tly != 0 || rotdeg != 0 || scalex != null || scaley != null; + private boolean interactable() { + return tlx != 0 || tly != 0 || rotdeg != 0 || scalex != null || scaley != null || toggle; + } + + private void onMouseClick(EntityRollingStock stock) { + if (sound != null) { + sound.effects(stock, true, getValue(stock), MinecraftClient.getPlayer().getPosition()); + } } private void onMouseMove(EntityRollingStock stock, Matrix4 matrix, GuiBuilder target, int maxx, int maxy, int x, int y) { @@ -330,7 +414,7 @@ private void onMouseMove(EntityRollingStock stock, Matrix4 matrix, GuiBuilder ta matrix = matrix.copy(); // TODO mem opt? applyPosition(matrix, maxx, maxy); Matrix4 preApply = matrix.copy(); - applyValue(matrix, value, maxx, maxy); + applyValue(matrix, value); if (target == this) { // 0 0 imageHeight imageWidth @@ -352,7 +436,7 @@ private void onMouseMove(EntityRollingStock stock, Matrix4 matrix, GuiBuilder ta temp.scale(scalex != null ? scalex * checkValue : 1, scaley != null ? scaley * checkValue : 1, 1); } - Vec3d checkMiddle = temp.apply(new Vec3d(1, 1, 0)); + Vec3d checkMiddle = temp.apply(new Vec3d(imageWidth/2f, imageHeight/2f, 0)); double delta = checkMiddle.distanceTo(new Vec3d(x, y, 0)); if (delta < closestDelta) { closestDelta = delta; @@ -361,7 +445,20 @@ private void onMouseMove(EntityRollingStock stock, Matrix4 matrix, GuiBuilder ta } if (closestValue != value) { - new ControlChangePacket(stock, readout, control, global, closestValue).sendToServer(); + float val = invert ? 1 - closestValue : closestValue; + temporary_value = val; + if (setting != null) { + ConfigGraphics.settings.put(setting, val); + ConfigFile.write(ConfigGraphics.class); + } else { + if (readout != Readouts.TRAIN_BRAKE_LEVER) { + new ControlChangePacket(stock, readout, control, global, texture_variant, val).sendToServer(); + } + } + } + + if (target.sound != null) { + target.sound.effects(stock, true, target.getValue(stock), MinecraftClient.getPlayer().getPosition()); } } else { for (GuiBuilder element : elements) { @@ -370,24 +467,51 @@ private void onMouseMove(EntityRollingStock stock, Matrix4 matrix, GuiBuilder ta } } + public void onMouseRelease(EntityRollingStock stock) { + float value = getValue(stock); + + if (sound != null) { + sound.effects(stock, false, value, MinecraftClient.getPlayer().getPosition()); + } + + if (toggle) { + value = 1 - value; + } + + if (readout == Readouts.HORN || readout == Readouts.WHISTLE) { + value = 0; + } + + if (setting != null) { + ConfigGraphics.settings.put(setting, value); + ConfigFile.write(ConfigGraphics.class); + } else { + new ControlChangePacket(stock, readout, control, global, texture_variant, value).sendToServer(); + } + + temporary_value = 0.5f; + } + private static GuiBuilder target = null; + public boolean click(ClientEvents.MouseGuiEvent event, EntityRollingStock stock) { switch (event.action) { case CLICK: target = find(stock, new Matrix4(), GUIHelpers.getScreenWidth(), GUIHelpers.getScreenHeight(), event.x, event.y); + if (target != null) { + target.onMouseClick(stock); + } return target == null; case RELEASE: if (target != null) { - if (!target.hasMovement()) { - new ControlChangePacket(stock, target.readout, target.control, target.global, target.invert ? target.getValue(stock) : 1 - target.getValue(stock)).sendToServer(); - } + target.onMouseRelease(stock); target = null; return false; } break; case MOVE: - if (target != null && target.hasMovement()) { - onMouseMove(stock, new Matrix4(), target, GUIHelpers.getScreenWidth(), GUIHelpers.getScreenHeight(), event.x, event.y); + if (target != null) { + this.onMouseMove(stock, new Matrix4(), target, GUIHelpers.getScreenWidth(), GUIHelpers.getScreenHeight(), event.x, event.y); return false; } break; @@ -395,6 +519,21 @@ public boolean click(ClientEvents.MouseGuiEvent event, EntityRollingStock stock) return true; } + public static void onClientTick() { + if (target != null && (target.readout == Readouts.TRAIN_BRAKE_LEVER)) { + if (!MinecraftClient.isReady()) { + return ; + } + Entity riding = MinecraftClient.getPlayer().getRiding(); + if (!(riding instanceof EntityRollingStock)) { + return ; + } + EntityRollingStock stock = (EntityRollingStock) riding; + float value = target.invert ? target.getValue(stock) : 1 - target.getValue(stock); + new ControlChangePacket(stock, target.readout, target.control, target.global, target.texture_variant, value).sendToServer(); + } + } + public static class ControlChangePacket extends Packet { @TagField private UUID stockUUID; @@ -407,58 +546,69 @@ public static class ControlChangePacket extends Packet { @TagField private float value; + @TagField + private String texture_variant; public ControlChangePacket() { super(); // Reflection } - public ControlChangePacket(EntityRollingStock stock, Readouts readout, String controlGroup, boolean global, float value) { + public ControlChangePacket(EntityRollingStock stock, Readouts readout, String controlGroup, boolean global, String texture_variant, float value) { this.stockUUID = stock.getUUID(); this.readout = readout; this.controlGroup = controlGroup; this.global = global; + this.texture_variant = texture_variant; this.value = value; + // Update the UI, server will resync once the update actually happens + update(stock); } @Override protected void handle() { EntityRollingStock stock = getWorld().getEntity(stockUUID, EntityRollingStock.class); if (stock != null) { - // TODO permissions! - if (controlGroup != null) { - switch (controlGroup) { - case "REVERSERFORWARD": - readout = Readouts.REVERSER; - value = 1; - break; - case "REVERSERNEUTRAL": - readout = Readouts.REVERSER; - value = 0.5f; - break; - case "REVERSERBACKWARD": - readout = Readouts.REVERSER; - value = 0; - break; - default: - if (global) { - ((EntityCoupleableRollingStock)stock).mapTrain((EntityCoupleableRollingStock) stock, false, target -> { - target.setControlPosition(controlGroup, value); - }); - } else { - stock.setControlPosition(controlGroup, value); - } - return; - } + update(stock); + } + } + public void update(EntityRollingStock stock) { + // TODO permissions! + if (controlGroup != null) { + switch (controlGroup) { + case "REVERSERFORWARD": + readout = Readouts.REVERSER; + value = 1; + break; + case "REVERSERNEUTRAL": + readout = Readouts.REVERSER; + value = 0.5f; + break; + case "REVERSERBACKWARD": + readout = Readouts.REVERSER; + value = 0; + break; + default: + if (global) { + ((EntityCoupleableRollingStock)stock).mapTrain((EntityCoupleableRollingStock) stock, false, target -> { + target.setControlPosition(controlGroup, value); + }); + } else { + stock.setControlPosition(controlGroup, value); + } + return; } - if (readout != null) { - if (global) { - ((EntityCoupleableRollingStock)stock).mapTrain((EntityCoupleableRollingStock) stock, false, target -> { - readout.setValue(target, value); - }); - } else { - readout.setValue(stock, value); - } + } + if (readout != null) { + if (global) { + ((EntityCoupleableRollingStock)stock).mapTrain((EntityCoupleableRollingStock) stock, false, target -> { + readout.setValue(target, value); + }); + } else { + readout.setValue(stock, value); } } + if (texture_variant != null && value == 1) { + stock.setTexture(texture_variant); + } } } } diff --git a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java index d7899468f..48a2f8c6a 100644 --- a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java +++ b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Readouts.java @@ -13,6 +13,7 @@ public enum Readouts { THROTTLE, REVERSER, TRAIN_BRAKE, + TRAIN_BRAKE_LEVER, INDEPENDENT_BRAKE, BRAKE_PRESSURE, COUPLER_FRONT, @@ -31,13 +32,16 @@ public enum Readouts { ; public float getValue(EntityRollingStock stock) { + return getValue(stock, 0); + } + + public float getValue(EntityRollingStock stock, float lever) { switch (this) { case LIQUID: return stock instanceof FreightTank ? ((FreightTank) stock).getPercentLiquidFull() / 100f : 0; case SPEED: - return stock instanceof Locomotive ? (float) ( - Math.abs(((Locomotive) stock).getCurrentSpeed().metric()) / - ((Locomotive) stock).getDefinition().getMaxSpeed(stock.gauge).metric()) : 0; + return (float)Math.abs(((EntityMoveableRollingStock)stock).getCurrentSpeed().metric() / + (stock instanceof Locomotive ? ((Locomotive) stock).getDefinition().getMaxSpeed(stock.gauge).metric() : 200)); case TEMPERATURE: if (stock instanceof LocomotiveSteam) { return ((LocomotiveSteam) stock).getBoilerTemperature() / 100f; @@ -55,6 +59,8 @@ public float getValue(EntityRollingStock stock) { return stock instanceof Locomotive ? (((Locomotive) stock).getReverser() + 1) / 2 : 0; case TRAIN_BRAKE: return stock instanceof Locomotive ? ((Locomotive) stock).getTrainBrake() : 0; + case TRAIN_BRAKE_LEVER: + return stock.getDefinition().isLinearBrakeControl() ? TRAIN_BRAKE.getValue(stock) : lever; case INDEPENDENT_BRAKE: return stock instanceof EntityMoveableRollingStock ? ((EntityMoveableRollingStock) stock).getIndependentBrake() : 0; case BRAKE_PRESSURE: @@ -71,7 +77,7 @@ public float getValue(EntityRollingStock stock) { return stock instanceof Locomotive ? ((Locomotive) stock).getBell() > 0 ? 1 : 0 : 0; case WHISTLE: case HORN: - return stock instanceof Locomotive ? ((Locomotive) stock).getHornTime() > 0 ? 1 : 0 : 0; + return stock instanceof Locomotive ? ((Locomotive) stock).hornPull : 0; case ENGINE: return stock instanceof LocomotiveDiesel ? ((LocomotiveDiesel) stock).isTurnedOn() ? 1 : 0 : 0; case FRONT_BOGEY_ANGLE: @@ -119,6 +125,16 @@ public void setValue(EntityRollingStock stock, float value) { ((Locomotive) stock).setTrainBrake(value); } break; + case TRAIN_BRAKE_LEVER: + if (stock.getDefinition().isLinearBrakeControl()) { + TRAIN_BRAKE.setValue(stock, value); + } else { + if (stock instanceof Locomotive) { + // Logic duplicated in Locomotive#onTick + ((Locomotive) stock).setTrainBrake(Math.max(0, Math.min(1, ((Locomotive) stock).getTrainBrake() + (value - 0.5f) / 80))); + } + } + break; case INDEPENDENT_BRAKE: if (stock instanceof EntityMoveableRollingStock) { ((Locomotive) stock).setIndependentBrake(value); @@ -136,13 +152,17 @@ public void setValue(EntityRollingStock stock, float value) { break; case BELL: if (stock instanceof Locomotive) { - ((Locomotive) stock).setBell(10); + ((Locomotive) stock).setBell((int) (value * 10)); } break; case WHISTLE: case HORN: if (stock instanceof Locomotive) { - ((Locomotive) stock).setHorn(40, Locomotive.AUTOMATED_PLAYER); + if (value != 0) { + ((Locomotive) stock).setHorn(10000, value); + } else { + ((Locomotive) stock).setHorn(10, value); + } } break; case ENGINE: diff --git a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Stat.java b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Stat.java index f47981a1d..cac3a7d0b 100644 --- a/src/main/java/cam72cam/immersiverailroading/gui/overlay/Stat.java +++ b/src/main/java/cam72cam/immersiverailroading/gui/overlay/Stat.java @@ -9,65 +9,106 @@ public enum Stat { SPEED, + MAX_SPEED, + UNITS_SPEED, LIQUID, MAX_LIQUID, - BOILER_PSI, - MAX_BOILER_PSI, + UNITS_LIQUID, + BOILER_PRESSURE, + MAX_BOILER_PRESSURE, + UNITS_BOILER_PRESSURE, TEMPERATURE, MAX_TEMPERATURE, + UNITS_TEMPERATURE, + BRAKE_PRESSURE, + MAX_BRAKE_PRESSURE, + UNITS_BRAKE_PRESSURE, ; + public String getValue(EntityRollingStock stock) { + Float temp = null; + switch (this) { case SPEED: if (stock instanceof EntityMoveableRollingStock) { Speed speed = ((EntityMoveableRollingStock) stock).getCurrentSpeed(); switch (ConfigGraphics.speedUnit) { case mph: - return String.format("%.2f mph", Math.abs(speed.imperial())); + return String.format("%.2f", Math.abs(speed.imperial())); case ms: - return String.format("%.2f m/s", Math.abs(speed.metric()) / 3.6); + return String.format("%.2f", Math.abs(speed.metersPerSecond())); case kmh: - default: - return String.format("%.2f km/h", Math.abs(speed.metric())); + return String.format("%.2f", Math.abs(speed.metric())); } } return ""; + case MAX_SPEED: + if (stock instanceof Locomotive) { + Speed speed = ((Locomotive)stock).getDefinition().getMaxSpeed(stock.gauge); + switch (ConfigGraphics.speedUnit) { + case mph: + return String.format("%.0f", Math.abs(speed.imperial())); + case ms: + return String.format("%.0f", Math.abs(speed.metersPerSecond())); + case kmh: + return String.format("%.0f", Math.abs(speed.metric())); + } + } + return ""; + case UNITS_SPEED: + return ConfigGraphics.speedUnit.toUnitString(); case LIQUID: return stock instanceof FreightTank ? - String.format("%.1fB", + String.format("%.1f", ((FreightTank) stock).getLiquidAmount() / (float)Fluid.BUCKET_VOLUME) : ""; case MAX_LIQUID: return stock instanceof FreightTank ? - String.format("%.1fB", + String.format("%.1f", ((FreightTank)stock).getTankCapacity().MilliBuckets() / (float)Fluid.BUCKET_VOLUME) : ""; - case BOILER_PSI: + case UNITS_LIQUID: + return "B"; + + case BOILER_PRESSURE: return stock instanceof LocomotiveSteam ? - String.format("%.1fPSI", ((LocomotiveSteam) stock).getBoilerPressure()) : ""; - case MAX_BOILER_PSI: + String.format("%.1f", ConfigGraphics.pressureUnit.convertFromPSI(((LocomotiveSteam) stock).getBoilerPressure())) : ""; + case MAX_BOILER_PRESSURE: return stock instanceof LocomotiveSteam ? - String.format("%.1fPSI", (float)((LocomotiveSteam) stock).getDefinition().getMaxPSI(stock.gauge)) + String.format("%.1f", ConfigGraphics.pressureUnit.convertFromPSI((float)((LocomotiveSteam) stock).getDefinition().getMaxPSI(stock.gauge))) : ""; + case UNITS_BOILER_PRESSURE: + return ConfigGraphics.pressureUnit.toUnitString(); + case TEMPERATURE: if (stock instanceof LocomotiveSteam) { - return String.format("%.1fC", ((LocomotiveSteam) stock).getBoilerTemperature()); + temp = ((LocomotiveSteam) stock).getBoilerTemperature(); } if (stock instanceof LocomotiveDiesel) { - return String.format("%.1fC", ((LocomotiveDiesel) stock).getEngineTemperature()); + temp = ((LocomotiveDiesel) stock).getEngineTemperature(); } - return ""; + return temp != null ? String.format("%.1f", ConfigGraphics.temperatureUnit.convertFromCelcius(temp)) : ""; case MAX_TEMPERATURE: if (stock instanceof LocomotiveSteam) { - return String.format("%.1fC", 100f); + temp = 100f; } if (stock instanceof LocomotiveDiesel) { - return String.format("%.1fC", 150f); + temp = 150f; + } + return temp != null ? String.format("%.1f", ConfigGraphics.temperatureUnit.convertFromCelcius(temp)) : ""; + case UNITS_TEMPERATURE: + return ConfigGraphics.temperatureUnit.toUnitString(); + case BRAKE_PRESSURE: + if (stock instanceof EntityMoveableRollingStock) { + return String.format("%s", (int)(((EntityMoveableRollingStock) stock).getBrakePressure() * 100)); } return ""; - default: - return ""; + case MAX_BRAKE_PRESSURE: + return "100"; + case UNITS_BRAKE_PRESSURE: + return "%"; } + return ""; } @Override public String toString() { diff --git a/src/main/java/cam72cam/immersiverailroading/library/PressureDisplayType.java b/src/main/java/cam72cam/immersiverailroading/library/PressureDisplayType.java new file mode 100644 index 000000000..8fd4be128 --- /dev/null +++ b/src/main/java/cam72cam/immersiverailroading/library/PressureDisplayType.java @@ -0,0 +1,16 @@ +package cam72cam.immersiverailroading.library; + +import java.util.Locale; + +public enum PressureDisplayType { + psi, + bar; + + public float convertFromPSI(float value) { + return this == psi ? value : value * 0.0689476f; + } + + public String toUnitString() { + return toString().toUpperCase(Locale.ROOT); + } +} diff --git a/src/main/java/cam72cam/immersiverailroading/library/SpeedDisplayType.java b/src/main/java/cam72cam/immersiverailroading/library/SpeedDisplayType.java index 1220dd534..e5ebb348a 100644 --- a/src/main/java/cam72cam/immersiverailroading/library/SpeedDisplayType.java +++ b/src/main/java/cam72cam/immersiverailroading/library/SpeedDisplayType.java @@ -3,5 +3,17 @@ public enum SpeedDisplayType { kmh, mph, - ms, + ms; + + public String toUnitString() { + switch (this) { + default: + case kmh: + return "km/h"; + case mph: + return "mph"; + case ms: + return "m/s"; + } + } } diff --git a/src/main/java/cam72cam/immersiverailroading/library/TemperatureDisplayType.java b/src/main/java/cam72cam/immersiverailroading/library/TemperatureDisplayType.java new file mode 100644 index 000000000..090646425 --- /dev/null +++ b/src/main/java/cam72cam/immersiverailroading/library/TemperatureDisplayType.java @@ -0,0 +1,31 @@ +package cam72cam.immersiverailroading.library; + +public enum TemperatureDisplayType { + celcius, + farenheit, + kelvin,; + + public float convertFromCelcius(float value) { + switch (this) { + default: + case celcius: + return value; + case farenheit: + return (value * 9f/5f) + 32f; + case kelvin: + return value + 270f; + } + } + + public String toUnitString() { + switch (this) { + default: + case celcius: + return "C"; + case farenheit: + return "F"; + case kelvin: + return "K"; + } + } +} diff --git a/src/main/java/cam72cam/immersiverailroading/model/SteamLocomotiveModel.java b/src/main/java/cam72cam/immersiverailroading/model/SteamLocomotiveModel.java index f9c9c4792..e5ff02342 100644 --- a/src/main/java/cam72cam/immersiverailroading/model/SteamLocomotiveModel.java +++ b/src/main/java/cam72cam/immersiverailroading/model/SteamLocomotiveModel.java @@ -92,7 +92,7 @@ protected void effects(LocomotiveSteam stock) { } pressureValve.effects(stock, stock.isOverpressure() && Config.isFuelRequired(stock.gauge)); idleSounds.effects(stock, stock.getBoilerTemperature() > stock.ambientTemperature() + 5 ? 0.1f : 0); - whistle.effects(stock, stock.getBoilerPressure() > 0 || !Config.isFuelRequired(stock.gauge) ? stock.getHornTime() : 0, stock.isAutomatedHorn(), stock.getHornPlayer()); + whistle.effects(stock, stock.getBoilerPressure() > 0 || !Config.isFuelRequired(stock.gauge) ? stock.getHornTime() : 0, stock.getHornPull()); } @Override diff --git a/src/main/java/cam72cam/immersiverailroading/model/StockModel.java b/src/main/java/cam72cam/immersiverailroading/model/StockModel.java index 3b17726b7..32b0e0384 100644 --- a/src/main/java/cam72cam/immersiverailroading/model/StockModel.java +++ b/src/main/java/cam72cam/immersiverailroading/model/StockModel.java @@ -247,6 +247,9 @@ public final void onClientRemoved(EntityMoveableRollingStock stock) { protected void removed(ENTITY stock) { headlights.forEach(x -> x.removed(stock)); + controls.forEach(c -> c.removed(stock)); + doors.forEach(c -> c.removed(stock)); + gauges.forEach(c -> c.removed(stock)); animations.forEach(c -> c.removed(stock)); wheel_sound.removed(stock); diff --git a/src/main/java/cam72cam/immersiverailroading/model/part/Control.java b/src/main/java/cam72cam/immersiverailroading/model/part/Control.java index 687bdd521..e65e4a0a4 100644 --- a/src/main/java/cam72cam/immersiverailroading/model/part/Control.java +++ b/src/main/java/cam72cam/immersiverailroading/model/part/Control.java @@ -18,8 +18,6 @@ import cam72cam.mod.model.obj.OBJGroup; import cam72cam.mod.render.GlobalRender; import cam72cam.mod.render.opengl.RenderState; -import cam72cam.mod.resource.Identifier; -import cam72cam.mod.sound.ISound; import cam72cam.mod.util.Axis; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.text.WordUtils; @@ -48,9 +46,6 @@ public class Control extends Interactable< private final Map translations = new HashMap<>(); private final Map scales = new HashMap<>(); private final Map scaleRot = new HashMap<>(); - private final Map lastMoveSoundValue = new HashMap<>(); - private final Map wasSoundPressed = new HashMap<>(); - private final Map> sounds = new HashMap<>(); public static List> get(ComponentProvider provider, ModelState state, ModelComponentType type, ModelPosition pos) { return provider.parseAll(type, pos).stream().map(part1 -> new Control(part1, state, provider.internal_model_scale)).collect(Collectors.toList()); @@ -380,65 +375,16 @@ public void stopClientDragging() { lastClientLook = null; } - public ControlSoundsDefinition getSounds(T stock) { - return stock.getDefinition().getControlSound(part.type.name().replace("_X", "_" + part.id)); - } - - private void createSound(T stock, Identifier sound, boolean repeats) { - if (sound == null) { - return; + public void effects(T stock) { + ControlSoundsDefinition sounds = stock.getDefinition().getControlSound(part.type.name().replace("_X", "_" + part.id)); + if (sounds != null) { + sounds.effects(stock, stock.getControlPressed(this), stock.getControlPosition(this), center(stock)); } - ISound snd = stock.createSound(sound, repeats, 10, ConfigSound.SoundCategories::controls); - snd.setVelocity(stock.getVelocity()); - snd.setVolume(1); - snd.setPitch(1f); - snd.play(center(stock)); - sounds.computeIfAbsent(stock.getUUID(), k -> new ArrayList<>()).add(snd); } - - public void effects(T stock) { - ControlSoundsDefinition sounds = getSounds(stock); + public void removed(T stock) { + ControlSoundsDefinition sounds = stock.getDefinition().getControlSound(part.type.name().replace("_X", "_" + part.id)); if (sounds != null) { - if (this.sounds.containsKey(stock.getUUID())) { - for (ISound snd : new ArrayList<>(this.sounds.get(stock.getUUID()))) { - if (snd.isPlaying()) { - snd.setVelocity(stock.getVelocity()); - snd.setPosition(center(stock)); - } else { - this.sounds.get(stock.getUUID()).remove(snd); - } - } - } - - boolean isPressed = stock.getControlPressed(this); - Boolean wasPressed = wasSoundPressed.getOrDefault(stock.getUUID(), isPressed); - wasSoundPressed.put(stock.getUUID(), isPressed); - - float value = stock.getControlPosition(this); - float lastValue = lastMoveSoundValue.computeIfAbsent(stock.getUUID(), k -> value); - - if (!wasPressed && isPressed) { - // Start - createSound(stock, sounds.engage, false); - if (sounds.move != null && sounds.movePercent == null) { - // Start move repeat - createSound(stock, sounds.move, true); - } - } else if (wasPressed && !isPressed) { - // Release - if (this.sounds.containsKey(stock.getUUID())) { - for (ISound snd : this.sounds.get(stock.getUUID())) { - snd.stop(); - } - } - createSound(stock, sounds.disengage, false); - } else if (sounds.move != null && sounds.movePercent != null){ - // Move - if (Math.abs(lastValue - value) > sounds.movePercent) { - createSound(stock, sounds.move, false); - lastMoveSoundValue.put(stock.getUUID(), value); - } - } + sounds.removed(stock); } } } diff --git a/src/main/java/cam72cam/immersiverailroading/model/part/Whistle.java b/src/main/java/cam72cam/immersiverailroading/model/part/Whistle.java index b55255164..3642a5473 100644 --- a/src/main/java/cam72cam/immersiverailroading/model/part/Whistle.java +++ b/src/main/java/cam72cam/immersiverailroading/model/part/Whistle.java @@ -12,13 +12,11 @@ import cam72cam.immersiverailroading.render.ExpireableMap; import cam72cam.immersiverailroading.render.SmokeParticle; import cam72cam.immersiverailroading.util.VecUtil; -import cam72cam.mod.entity.Entity; import cam72cam.mod.math.Vec3d; import cam72cam.mod.sound.ISound; import java.util.ArrayList; import java.util.List; -import java.util.OptionalDouble; import java.util.UUID; public class Whistle { @@ -49,7 +47,7 @@ private SoundEffects(EntityMoveableRollingStock stock) { } } - public void update(EntityMoveableRollingStock stock, int hornTime, boolean isAutomatedHorn, Entity hornPlayer) { + public void update(EntityMoveableRollingStock stock, int hornTime, float hornPull) { if (hornTime < 1) { pullString = 0; soundDampener = 0; @@ -68,20 +66,7 @@ public void update(EntityMoveableRollingStock stock, int hornTime, boolean isAut if (soundDampener < 1) { soundDampener += 0.1; } - if (hornPlayer != null) { - float newString = (hornPlayer.getRotationPitch() + 90) / 180; - delta = newString - pullString; - } else { - OptionalDouble control = stock.getDefinition().getModel().getControls().stream() - .filter(x -> x.part.type == ModelComponentType.WHISTLE_CONTROL_X) - .mapToDouble(stock::getControlPosition) - .max(); - if (control.isPresent() && !isAutomatedHorn) { - delta = (float) control.getAsDouble() - pullString; - } else { - delta = (float) quilling.maxPull - pullString; - } - } + delta = hornPull - pullString; } else { if (soundDampener > 0) { soundDampener -= 0.07; @@ -145,7 +130,7 @@ public void onRemove(UUID key, SoundEffects value) { } }; - public void effects(EntityMoveableRollingStock stock, int hornTime, boolean isAutomatedHorn, Entity hornPlayer) { + public void effects(EntityMoveableRollingStock stock, int hornTime, float hornPull) { // Particles and Sound if (quilling != null) { @@ -156,7 +141,7 @@ public void effects(EntityMoveableRollingStock stock, int hornTime, boolean isAu sounds.put(stock.getUUID(), sound); } - sound.update(stock, hornTime, isAutomatedHorn, hornPlayer); + sound.update(stock, hornTime, hornPull); } else { whistle.effects(stock, hornTime > 0); } diff --git a/src/main/java/cam72cam/immersiverailroading/registry/EntityRollingStockDefinition.java b/src/main/java/cam72cam/immersiverailroading/registry/EntityRollingStockDefinition.java index 6cb227dd6..2f32ae8c8 100644 --- a/src/main/java/cam72cam/immersiverailroading/registry/EntityRollingStockDefinition.java +++ b/src/main/java/cam72cam/immersiverailroading/registry/EntityRollingStockDefinition.java @@ -5,21 +5,25 @@ import cam72cam.immersiverailroading.ImmersiveRailroading; import cam72cam.immersiverailroading.entity.EntityBuildableRollingStock; import cam72cam.immersiverailroading.entity.EntityCoupleableRollingStock.CouplerType; +import cam72cam.immersiverailroading.entity.EntityMoveableRollingStock; import cam72cam.immersiverailroading.entity.EntityRollingStock; -import cam72cam.immersiverailroading.util.*; import cam72cam.immersiverailroading.gui.overlay.GuiBuilder; import cam72cam.immersiverailroading.gui.overlay.Readouts; import cam72cam.immersiverailroading.library.*; import cam72cam.immersiverailroading.model.StockModel; import cam72cam.immersiverailroading.model.components.ModelComponent; -import cam72cam.mod.ModCore; +import cam72cam.immersiverailroading.util.*; import cam72cam.mod.entity.EntityRegistry; import cam72cam.mod.math.Vec3d; import cam72cam.mod.model.obj.OBJGroup; import cam72cam.mod.model.obj.VertexBuffer; import cam72cam.mod.resource.Identifier; -import cam72cam.mod.serialization.*; +import cam72cam.mod.serialization.ResourceCache; import cam72cam.mod.serialization.ResourceCache.GenericByteBuffer; +import cam72cam.mod.serialization.TagCompound; +import cam72cam.mod.serialization.TagField; +import cam72cam.mod.serialization.TagMapped; +import cam72cam.mod.sound.ISound; import cam72cam.mod.text.TextUtil; import cam72cam.mod.world.World; @@ -27,7 +31,6 @@ import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Files; import java.util.*; import java.util.function.Function; import java.util.function.Supplier; @@ -206,19 +209,85 @@ public static class ControlSoundsDefinition { public final Float movePercent; public final Identifier disengage; - protected ControlSoundsDefinition(Identifier engage, Identifier move, Float movePercent, Identifier disengage) { + private final Map> sounds = new HashMap<>(); + private final Map lastMoveSoundValue = new HashMap<>(); + private final Map wasSoundPressed = new HashMap<>(); + + public ControlSoundsDefinition(Identifier engage, Identifier move, Float movePercent, Identifier disengage) { this.engage = engage; this.move = move; this.movePercent = movePercent; this.disengage = disengage; } - private ControlSoundsDefinition(DataBlock data) { + public ControlSoundsDefinition(DataBlock data) { engage = data.getValue("engage").asIdentifier(); move = data.getValue("move").asIdentifier(); movePercent = data.getValue("movePercent").asFloat(); disengage = data.getValue("disengage").asIdentifier(); } + + private void createSound(EntityRollingStock stock, Identifier sound, Vec3d pos, boolean repeats) { + if (sound == null) { + return; + } + ISound snd = stock.createSound(sound, repeats, 10, ConfigSound.SoundCategories::controls); + snd.setVelocity(stock.getVelocity()); + snd.setVolume(1); + snd.setPitch(1f); + snd.play(pos); + sounds.computeIfAbsent(stock.getUUID(), k -> new ArrayList<>()).add(snd); + } + + public void effects(EntityRollingStock stock, boolean isPressed, float value, Vec3d pos) { + if (this.sounds.containsKey(stock.getUUID())) { + for (ISound snd : new ArrayList<>(this.sounds.get(stock.getUUID()))) { + if (snd.isPlaying()) { + snd.setVelocity(stock.getVelocity()); + snd.setPosition(pos); + } else { + this.sounds.get(stock.getUUID()).remove(snd); + } + } + } + + Boolean wasPressed = wasSoundPressed.getOrDefault(stock.getUUID(), isPressed); + wasSoundPressed.put(stock.getUUID(), isPressed); + + float lastValue = lastMoveSoundValue.computeIfAbsent(stock.getUUID(), k -> value); + + if (!wasPressed && isPressed) { + // Start + createSound(stock, engage, pos, false); + if (move != null && movePercent == null) { + // Start move repeat + createSound(stock, move, pos, true); + } + } else if (wasPressed && !isPressed) { + // Release + if (this.sounds.containsKey(stock.getUUID())) { + for (ISound snd : this.sounds.get(stock.getUUID())) { + snd.stop(); + } + } + createSound(stock, disengage, pos, false); + } else if (move != null && movePercent != null){ + // Move + if (Math.abs(lastValue - value) > movePercent) { + createSound(stock, move, pos, false); + lastMoveSoundValue.put(stock.getUUID(), value); + } + } + } + + public void removed(T stock) { + List removed = this.sounds.remove(stock.getUUID()); + if (removed != null) { + for (ISound sound : removed) { + sound.stop(); + } + } + } } public EntityRollingStockDefinition(Class type, String defID, DataBlock data) throws Exception { diff --git a/src/main/java/cam72cam/immersiverailroading/tile/TileRailBase.java b/src/main/java/cam72cam/immersiverailroading/tile/TileRailBase.java index 31c94f13b..3e6e30082 100644 --- a/src/main/java/cam72cam/immersiverailroading/tile/TileRailBase.java +++ b/src/main/java/cam72cam/immersiverailroading/tile/TileRailBase.java @@ -37,8 +37,6 @@ import java.util.*; -import static cam72cam.immersiverailroading.entity.Locomotive.AUTOMATED_PLAYER; - public class TileRailBase extends BlockEntityTrackTickable implements IRedstoneProvider { @TagField("parent") private Vec3i parent; @@ -668,7 +666,7 @@ public void update() { loco.setTrainBrake(power / 15f); break; case HORN: - loco.setHorn(40, AUTOMATED_PLAYER); + loco.setHorn(40, power/15f); break; case BELL: loco.setBell(10 * power); diff --git a/src/main/java/cam72cam/immersiverailroading/util/DataBlock.java b/src/main/java/cam72cam/immersiverailroading/util/DataBlock.java index 9e4e17bbc..0ec051a9a 100644 --- a/src/main/java/cam72cam/immersiverailroading/util/DataBlock.java +++ b/src/main/java/cam72cam/immersiverailroading/util/DataBlock.java @@ -2,9 +2,12 @@ import cam72cam.immersiverailroading.ImmersiveRailroading; import cam72cam.mod.resource.Identifier; +import org.apache.commons.io.IOUtils; import java.io.IOException; import java.io.InputStream; +import java.io.StringReader; +import java.nio.charset.Charset; import java.util.List; import java.util.Locale; import java.util.Map; @@ -99,11 +102,25 @@ public String asString() { static DataBlock load(Identifier ident) throws IOException { - return load(ident, false); + return load(ident, false, null); } - static DataBlock load(Identifier ident, boolean last) throws IOException { + static DataBlock load(Identifier ident, DataBlock parameters) throws IOException { + return load(ident, false, parameters); + } + + static DataBlock load(Identifier ident, boolean last, DataBlock parameters) throws IOException { InputStream stream = last ? ident.getLastResourceStream() : ident.getResourceStream(); + + if (parameters != null) { + String input = IOUtils.toString(stream, Charset.defaultCharset()); + for (String key : parameters.getValueMap().keySet()) { + input = input.replace(key, parameters.getValue(key).asString()); + } + stream = IOUtils.toInputStream(input, Charset.defaultCharset()); + } + + if (ident.getPath().toLowerCase(Locale.ROOT).endsWith(".caml")) { return CAML.parse(stream); } diff --git a/src/main/java/cam72cam/immersiverailroading/util/MergedBlocks.java b/src/main/java/cam72cam/immersiverailroading/util/MergedBlocks.java index af63ce10e..901e605fe 100644 --- a/src/main/java/cam72cam/immersiverailroading/util/MergedBlocks.java +++ b/src/main/java/cam72cam/immersiverailroading/util/MergedBlocks.java @@ -21,8 +21,9 @@ public MergedBlocks(DataBlock base, DataBlock override) { override.getValuesMap().forEach((key, values) -> { if (primitiveSets.containsKey(key)) { // Merge into new list - values = new ArrayList<>(values); - values.addAll(primitiveSets.get(key)); + List tmp = new ArrayList<>(primitiveSets.get(key)); + tmp.addAll(values); + values = tmp; } primitiveSets.put(key, values); }); @@ -34,8 +35,9 @@ public MergedBlocks(DataBlock base, DataBlock override) { }); override.getBlocksMap().forEach((key, blocks) -> { if (blockSets.containsKey(key)) { - blocks = new ArrayList<>(blocks); - blocks.addAll(blockSets.get(key)); + List tmp = new ArrayList<>(blockSets.get(key)); + tmp.addAll(blocks); + blocks = tmp; } blockSets.put(key, blocks); }); diff --git a/src/main/java/cam72cam/immersiverailroading/util/Speed.java b/src/main/java/cam72cam/immersiverailroading/util/Speed.java index 5b846b401..1fada9ad4 100644 --- a/src/main/java/cam72cam/immersiverailroading/util/Speed.java +++ b/src/main/java/cam72cam/immersiverailroading/util/Speed.java @@ -31,6 +31,9 @@ public double minecraft() { public double metric() { return internalSpeed * speedRatio; } + public double metersPerSecond() { + return internalSpeed * speedRatio / 3.6; + } public double imperial() { return metric() * 0.621371; diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/gear.png b/src/main/resources/assets/immersiverailroading/gui/default/common/gear.png new file mode 100644 index 000000000..c3257a800 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/common/gear.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/opacity.caml b/src/main/resources/assets/immersiverailroading/gui/default/common/opacity.caml new file mode 100644 index 000000000..4b0ba303c --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/common/opacity.caml @@ -0,0 +1,3 @@ +setting = "GUI_OPACITY" +setting_default = 1 +translucent = true diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/scale.caml b/src/main/resources/assets/immersiverailroading/gui/default/common/scale.caml new file mode 100644 index 000000000..50cc17e94 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/common/scale.caml @@ -0,0 +1,5 @@ +setting = "GUI_SCALE" +setting_default = 0.25 +scale = + x = 4 + y = 4 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/settings.caml b/src/main/resources/assets/immersiverailroading/gui/default/common/settings.caml new file mode 100644 index 000000000..298912a50 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/common/settings.caml @@ -0,0 +1,74 @@ +element: + screen_x = LEFT + screen_y = TOP + x = 4 + y = 4 + image = "immersiverailroading:gui/default/common/gear.png" + toggle = true + + setting = "IR_SETTINGS_PANEL" + setting_default = 1 + +element: + screen_x = MIDDLE + screen_y = MIDDLE + setting = "IR_SETTINGS_PANEL" + x = -125 + y = -50 + invert = true + hide = true + + image = "immersiverailroading:gui/default/common/settings_panel.png" + + element: + x = 125 + y = 10 + text = + value = "Immersive Railroading Interface Settings" + height = 8 + + element: + x = 17 + y = 40 + text = + value = "Scale:" + height = 6 + + element: + x = 35 + y = 40 + image = "immersiverailroading:gui/default/common/settings_slider.png" + + element: + x = 0 + y = -8 + image = "immersiverailroading:gui/default/common/settings_bar.png" + + setting = "GUI_SCALE" + setting_default = 0.25 + + translate = + x = 200 + + element: + x = 17 + y = 70 + text = + value = "Opacity:" + height = 6 + + element: + x = 35 + y = 70 + image = "immersiverailroading:gui/default/common/settings_slider.png" + + element: + x = 0 + y = -8 + image = "immersiverailroading:gui/default/common/settings_bar.png" + + setting = "GUI_OPACITY" + setting_default = 1 + + translate = + x = 200 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/settings_bar.png b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_bar.png new file mode 100644 index 000000000..5dc99772d Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_bar.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/settings_panel.png b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_panel.png new file mode 100644 index 000000000..0bba550be Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_panel.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/common/settings_slider.png b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_slider.png new file mode 100644 index 000000000..41e520615 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/common/settings_slider.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel.caml b/src/main/resources/assets/immersiverailroading/gui/default/diesel.caml index f0631bbd0..9ef8cc910 100644 --- a/src/main/resources/assets/immersiverailroading/gui/default/diesel.caml +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel.caml @@ -1,135 +1,149 @@ element: - # left panel - x = 10 - y = -95 - image = "immersiverailroading:gui/overlay_diesel.png" - element: - # fuel level - x = 5 - y = 75 - image = "immersiverailroading:gui/fluid.png" - readout = "LIQUID" - translate = - x = 0 - y = -50 - scale = - y = 1 - color = - 0 = "0xAA79650c" - element: - # engine temp - x = 25 - y = 75 - image = "immersiverailroading:gui/fluid.png" - readout = "TEMPERATURE" - translate = - x = 0 - y = -50 - scale = - y = 1 - color = - 0 = "0x992a81af" - 0.5 = "0x992a933a" - 0.6666 = "0x99d16c15" - 0.9333 = "0x99a21010" - element: - # brake pressure - x = 41 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "BRAKE_PRESSURE" - translate = - x = 0 - y = -50 - color = - 0.0 = "0xDDa22020" - element: - # train brake - x = 41 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "TRAIN_BRAKE" - translate = - x = 0 - y = -50 - element: - # ind brake - x = 47 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "INDEPENDENT_BRAKE" - translate = - x = 0 - y = -50 - element: - # throttle - x = 61 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "THROTTLE" - translate = - x = 0 - y = -50 - element: - # reverser - x = 67 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "REVERSER" - translate = - x = 0 - y = -50 - element: - # speed readout - text = - value = "stat.speed" - height = 6 - x = 38 - y = 8 + import: "immersiverailroading:gui/default/common/settings.caml" + +element: + screen_x = RIGHT + screen_y = BOTTOM + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # top labels - y = 19 + image = "immersiverailroading:gui/default/diesel/diesel_base.png" + x = -120 + y = -190 + + element: + x = 55 element: - x = 10 - text = - value = "stat.liquid" - height = 4 + y = 2.5 + image = "immersiverailroading:gui/default/diesel/dial.png" + import: "immersiverailroading:gui/default/diesel/gauge_speed_face.caml" + element: - x = 30 - text = - value = "stat.temperature" - height = 4 + y = 65 + image = "immersiverailroading:gui/default/diesel/dial.png" + import: "immersiverailroading:gui/default/diesel/gauge_brake_face.caml" + element: - x = 48 - text = - value = "label.brake" - height = 4 + y = 127.5 + image = "immersiverailroading:gui/default/diesel/dial.png" + import: "immersiverailroading:gui/default/diesel/gauge_temperature_face.caml" + + + element: element: - x = 69 - text = - value = "label.throttle" - height = 4 - element: - # bottom labels - y = 78 + x = 5 + y = 80 + image = "immersiverailroading:gui/default/diesel/horn.png" + + readout = HORN + + rotate = + x = 0 + y = 10 + degrees = 10 + element: - x = 10 - text = - value = "stat.max_liquid" - height = 4 + x = 5 + y = 95 + image = "immersiverailroading:gui/default/diesel/button.png" + + readout = ENGINE + toggle = true + color = + 0.0 = 0xFF006000 + 1.0 = 0xFF008000 + + element: + x = 35 + y = 95 + image = "immersiverailroading:gui/default/diesel/button.png" + + readout = BELL + toggle = true + color = + 0.0 = 0xFFAAAA00 + 1.0 = 0xFFCCCC00 + element: - x = 30 - y = 0 - text = - value = "stat.max_temperature" - height = 4 + x = 5 + y = 115 + image = "immersiverailroading:gui/default/diesel/throttle_base.png" + + element: + x = 11.5 + y = 13 + image = "immersiverailroading:gui/default/diesel/throttle_lever.png" + readout = "THROTTLE" + rotate = + x = 1.5 + y = -13 + degrees = -90 + offset = 45 + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + element: - x = 48 - text = - value = "" - height = 4 + x = 34 + y = 115 + image = "immersiverailroading:gui/default/diesel/reverser_base.png" + + element: + x = 9 + y = 10 + image = "immersiverailroading:gui/default/diesel/reverser_lever.png" + readout = "REVERSER" + rotate = + x = 1 + y = -10 + degrees = -90 + offset = 45 + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + element: - x = 69 - text = - value = "label.reverser" - height = 4 + x = 12 + y = 145 + image = "immersiverailroading:gui/default/diesel/brake_stand.png" + + element: + x = 10 + y = 2.5 + image = "immersiverailroading:gui/default/diesel/brake_lever.png" + readout = "TRAIN_BRAKE_LEVER" + rotate = + x = -5 + y = 2.5 + degrees = 30 + offset = -15 + color = + 0.0 = 0xFF806600 + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + move = "immersiverailroading:sounds/default/pressure.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + + element: + x = 12 + y = 165 + image = "immersiverailroading:gui/default/diesel/brake_stand.png" + element: + x = 10 + y = 2.5 + image = "immersiverailroading:gui/default/diesel/brake_lever.png" + readout = "INDEPENDENT_BRAKE" + rotate = + x = -5 + y = 2.5 + degrees = -15 + offset = 0 + color = + 0.0 = 0xFF800000 + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel.json b/src/main/resources/assets/immersiverailroading/gui/default/diesel.json index 2c7fcbf97..a44242760 100644 --- a/src/main/resources/assets/immersiverailroading/gui/default/diesel.json +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel.json @@ -1,185 +1,3 @@ { - "elements": [ - { - "comment": "left panel", - "x": 10, - "y": -95, - "image": "immersiverailroading:gui/overlay_diesel.png", - "elements": [ - { - "comment": "fuel level", - "x": 5, - "y": 75, - "image": "immersiverailroading:gui/fluid.png", - "readout": "LIQUID", - "translate": { - "x": 0, - "y": -50 - }, - "scale": { - "y": 1 - }, - "color": { - "0": "0xAA79650c" - } - }, - { - "comment": "engine temp", - "x": 25, - "y": 75, - "image": "immersiverailroading:gui/fluid.png", - "readout": "TEMPERATURE", - "translate": { - "x": 0, - "y": -50 - }, - "scale": { - "y": 1 - }, - "color": { - "0": "0x992a81af", - "0.5": "0x992a933a", - "0.6666": "0x99d16c15", - "0.9333": "0x99a21010" - } - }, - { - "comment": "brake pressure", - "x": 41, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "BRAKE_PRESSURE", - "translate": { - "x": 0, - "y": -50 - }, - "color": { - "0.0": "0xDDa22020" - } - }, - { - "comment": "train brake", - "x": 41, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "TRAIN_BRAKE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "ind brake", - "x": 47, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "INDEPENDENT_BRAKE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "throttle", - "x": 61, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "THROTTLE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "reverser", - "x": 67, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "REVERSER", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "speed readout", - "text": { - "value": "stat.speed", - "height": 6 - }, - "x": 38, - "y": 8 - }, - { - "comment": "top labels", - "y": 19, - "elements": [ - { - "x": 10, - "text": { - "value": "stat.liquid", - "height": 4 - } - }, - { - "x": 30, - "text": { - "value": "stat.temperature", - "height": 4 - } - }, - { - "x": 48, - "text": { - "value": "label.brake", - "height": 4 - } - }, - { - "x": 69, - "text": { - "value": "label.throttle", - "height": 4 - } - } - ] - }, - { - "comment": "bottom labels", - "y": 78, - "elements": [ - { - "x": 10, - "text": { - "value": "stat.max_liquid", - "height": 4 - } - }, - { - "x": 30, - "y": 0, - "text": { - "value": "stat.max_temperature", - "height": 4 - } - }, - { - "x": 48, - "text": { - "value": "", - "height": 4 - } - }, - { - "x": 69, - "text": { - "value": "label.reverser", - "height": 4 - } - } - ] - } - ] - } - ] + "import": "immersiverailroading:gui/diesel.caml" } \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_lever.png new file mode 100644 index 000000000..9704fb7d7 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_stand.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_stand.png new file mode 100644 index 000000000..2ed5cf310 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/brake_stand.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/button.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/button.png new file mode 100644 index 000000000..ecc3861a4 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/button.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial.png new file mode 100644 index 000000000..b95a7e379 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial_ticks_x10.caml b/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial_ticks_x10.caml new file mode 100644 index 000000000..453e7a013 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel/dial_ticks_x10.caml @@ -0,0 +1,60 @@ +# Ticks +element: + x = 29.5 # 60/2 - rotate.x + y = 7 # 60/2 - rotate.y + color = + 0.0 = "0xAA282828" + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -100 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -75 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -50 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -25 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 0 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 25 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 50 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 75 + element: + image = "immersiverailroading:gui/default/diesel/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 100 \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_base.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_base.png new file mode 100644 index 000000000..c627a1cc4 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_base.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_dial.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_dial.png new file mode 100644 index 000000000..babb3673d Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/diesel_dial.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_brake_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_brake_face.caml new file mode 100644 index 000000000..1ce64d069 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_brake_face.caml @@ -0,0 +1,62 @@ +element: + x = 30 + y = 19 + text = + value = "BRAKE" + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 30 + y = 47 + text = + value = stat.brake_pressure stat.units_brake_pressure + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 14 + y = 40 + text = + value = "0" + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 44 + y = 40 + text = + value = stat.max_brake_pressure + height = 4 + color = + 0.0 = "0xFF000000" + + +element: + image = "immersiverailroading:gui/default/diesel/diesel_dial.png" + x = 27.5 # 60/2 - rotate.x + y = 16 # 60/2 - rotate.y + readout = TRAIN_BRAKE + rotate = + x = 2.5 # indicator width/2 + y = 14 # indicator height/2 + degrees = 250 + offset = -125 + +element: + image = "immersiverailroading:gui/default/diesel/diesel_dial.png" + x = 27.5 # 60/2 - rotate.x + y = 16 # 60/2 - rotate.y + readout = BRAKE_PRESSURE + color = + 0 = "0xFFFF1010" + rotate = + x = 2.5 # indicator width/2 + y = 14 # indicator height/2 + degrees = 250 + offset = -125 + +import: "immersiverailroading:gui/default/diesel/dial_ticks_x10.caml" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_speed_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_speed_face.caml new file mode 100644 index 000000000..2eaaf4859 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_speed_face.caml @@ -0,0 +1,49 @@ +element: + x = 30 + y = 19 + text = + value = "SPEED" + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 30 + y = 47 + text = + value = stat.speed stat.units_speed + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 14 + y = 40 + text = + value = "0" + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 44 + y = 40 + text = + value = stat.max_speed + height = 4 + color = + 0.0 = "0xFF000000" + + +element: + image = "immersiverailroading:gui/default/diesel/diesel_dial.png" + x = 27.5 # 60/2 - rotate.x + y = 16 # 60/2 - rotate.y + readout = SPEED + rotate = + x = 2.5 # indicator width/2 + y = 14 # indicator height/2 + degrees = 250 + offset = -125 + +import: "immersiverailroading:gui/default/diesel/dial_ticks_x10.caml" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_temperature_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_temperature_face.caml new file mode 100644 index 000000000..b3de1083d --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/diesel/gauge_temperature_face.caml @@ -0,0 +1,49 @@ +element: + x = 30 + y = 19 + text = + value = "TEMP." + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 30 + y = 47 + text = + value = stat.temperature stat.units_temperature + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 14 + y = 40 + text = + value = "0" + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 44 + y = 40 + text = + value = stat.max_temperature + height = 4 + color = + 0.0 = "0xFF000000" + + +element: + image = "immersiverailroading:gui/default/diesel/diesel_dial.png" + x = 27.5 # 60/2 - rotate.x + y = 16 # 60/2 - rotate.y + readout = TEMPERATURE + rotate = + x = 2.5 # indicator width/2 + y = 14 # indicator height/2 + degrees = 250 + offset = -125 + +import: "immersiverailroading:gui/default/diesel/dial_ticks_x10.caml" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/horn.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/horn.png new file mode 100644 index 000000000..cebd7956d Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/horn.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_base.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_base.png new file mode 100644 index 000000000..db3473607 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_base.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_lever.png new file mode 100644 index 000000000..608b3cc06 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/reverser_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_base.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_base.png new file mode 100644 index 000000000..23779d8da Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_base.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_lever.png new file mode 100644 index 000000000..8ae8e7260 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/throttle_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/diesel/tickmark.png b/src/main/resources/assets/immersiverailroading/gui/default/diesel/tickmark.png new file mode 100644 index 000000000..014434c39 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/diesel/tickmark.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam.caml index db5298cee..0f7ae1f54 100644 --- a/src/main/resources/assets/immersiverailroading/gui/default/steam.caml +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam.caml @@ -1,157 +1,154 @@ element: - # left panel - x = 10 - y = -95 - image = "immersiverailroading:gui/overlay_steam.png" + import: "immersiverailroading:gui/default/common/settings.caml" + +element: + screen_x = RIGHT + screen_y = BOTTOM + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # water level - x = 5 - y = 75 - image = "immersiverailroading:gui/fluid.png" - readout = "LIQUID" - translate = - x = 0 - y = -50 - scale = - y = 1 - color = - 0 = "0xAA0F0FFF" + y = -60 + element: + import: "immersiverailroading:gui/default/steam/dial_right.caml" + import: "immersiverailroading:gui/default/steam/gauge_speed_face.caml" + element: - # steam level - x = 25 - y = 75 - image = "immersiverailroading:gui/fluid.png" - readout = "BOILER_PRESSURE" - translate = - x = 0 - y = -50 - scale = - y = 1 - color = - 0 = "0x99DDDDDD" + y = -120 + element: + import: "immersiverailroading:gui/default/steam/dial_right.caml" + import: "immersiverailroading:gui/default/steam/gauge_brake_face.caml" + +element: + screen_x = RIGHT + screen_y = TOP + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # boiler temp - x = 45 - y = 75 - image = "immersiverailroading:gui/fluid.png" - readout = "TEMPERATURE" - translate = - x = 0 - y = -40 - scale = - y = 0.8 - color = - 0 = "0x99d1c715" - 0.95 = "0x99d16c15" - 1.05 = "0x99a21010" + x = -6 + y = -30 + image = "immersiverailroading:gui/default/steam/whistle_cord.png" element: - # brake pressure - x = 61 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "BRAKE_PRESSURE" - translate = - x = 0 - y = -50 - color = - 0.0 = "0xDDa22020" + x = -6 + y = 52 + image = "immersiverailroading:gui/default/steam/whistle.png" + readout = "WHISTLE" + translate = + y = 12 + + +element: + screen_x = RIGHT + screen_y = BOTTOM + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # train brake - x = 61 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "TRAIN_BRAKE" - translate = - x = 0 - y = -50 + x = -70 + element: + x = -25 + y = -70 + + image = "immersiverailroading:gui/default/steam/reverser_harp_lever.png" + readout = "REVERSER" + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + move = "immersiverailroading:sounds/default/lever_move.ogg" + movePercent = 0.1 + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + rotate = + x = 2 + y = 70 + degrees = 60 + offset = -30 + element: + x = -45 + y = -36 + image = "immersiverailroading:gui/default/steam/reverser_harp_stand.png" + element: - # ind brake - x = 67 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "INDEPENDENT_BRAKE" - translate = - x = 0 - y = -50 + y = -65 + element: + x = -8 + y = -4 + image = "immersiverailroading:gui/default/steam/brake_stand.png" + element: + x = -22.5 + y = -1.5 + image = "immersiverailroading:gui/default/steam/brake_lever.png" + readout = "TRAIN_BRAKE_LEVER" + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + move = "immersiverailroading:sounds/default/pressure.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + rotate = + x = 18.5 + y = 1.5 + degrees = -30 + element: - # throttle - x = 81 - y = 74 - image = "immersiverailroading:gui/indicator.png" + y = -150 + element: + x = -10 + y = -5 + image = "immersiverailroading:gui/default/steam/throttle_backing.png" + element: + x = -80 + y = -4 + image = "immersiverailroading:gui/default/steam/throttle.png" readout = "THROTTLE" - translate = - x = 0 - y = -50 - element: - # reverser - x = 87 - y = 74 - image = "immersiverailroading:gui/indicator.png" - readout = "REVERSER" - translate = - x = 0 - y = -50 - element: - # speed readout - text = - value = "stat.speed" - height = 6 - x = 50 - y = 8 + sound = + engage = "immersiverailroading:sounds/default/lever_engage.ogg" + disengage = "immersiverailroading:sounds/default/lever_disengage.ogg" + rotate = + x = 75 + y = 4 + degrees = -30 + + +element: + #left panel + screen_x = LEFT + screen_y = MIDDLE + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # top labels - y = 19 - element: - x = 10 - text = - value = "stat.liquid" - height = 4 - element: - x = 30 - text = - value = "stat.boiler_psi" - height = 4 - element: - x = 50 - text = - value = "stat.temperature" - height = 4 - element: - x = 68 - text = - value = "label.brake" - height = 4 - element: - x = 89 - text = - value = "label.throttle" - height = 4 + y = -50 + x = -90 + import: "immersiverailroading:gui/default/steam/gauge_water_left.caml" + +element: + screen_x = LEFT + screen_y = TOP + + import: "immersiverailroading:gui/default/common/opacity.caml" + + element: + import: "immersiverailroading:gui/default/common/scale.caml" + element: - # bottom labels - y = 78 - element: - x = 10 - text = - value = "stat.max_liquid" - height = 4 - element: - x = 30 - text = - value = "stat.max_boiler_psi" - height = 4 - element: - x = 50 - y = 0 - text = - value = "stat.max_temperature" - height = 4 + element: + x = 0 element: - x = 68 - text = - value = "" - height = 4 + import: "immersiverailroading:gui/default/steam/dial_up.caml" + import: "immersiverailroading:gui/default/steam/gauge_boiler_face.caml" + + element: + x = 60 element: - x = 89 - text = - value = "label.reverser" - height = 4 + import: "immersiverailroading:gui/default/steam/dial_up.caml" + import: "immersiverailroading:gui/default/steam/gauge_temperature_face.caml" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam.json b/src/main/resources/assets/immersiverailroading/gui/default/steam.json index 4ecfdca58..84971d9ea 100644 --- a/src/main/resources/assets/immersiverailroading/gui/default/steam.json +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam.json @@ -1,215 +1,4 @@ { - "elements": [ - { - "comment": "left panel", - "x": 10, - "y": -95, - "image": "immersiverailroading:gui/overlay_steam.png", - "elements": [ - { - "comment": "water level", - "x": 5, - "y": 75, - "image": "immersiverailroading:gui/fluid.png", - "readout": "LIQUID", - "translate": { - "x": 0, - "y": -50 - }, - "scale": { - "y": 1 - }, - "color": { - "0": "0xAA0F0FFF" - } - }, - { - "comment": "steam level", - "x": 25, - "y": 75, - "image": "immersiverailroading:gui/fluid.png", - "readout": "BOILER_PRESSURE", - "translate": { - "x": 0, - "y": -50 - }, - "scale": { - "y": 1 - }, - "color": { - "0": "0x99DDDDDD" - } - }, - { - "comment": "boiler temp", - "x": 45, - "y": 75, - "image": "immersiverailroading:gui/fluid.png", - "readout": "TEMPERATURE", - "translate": { - "x": 0, - "y": -40 - }, - "scale": { - "y": 0.8 - }, - "color": { - "0": "0x99d1c715", - "0.95": "0x99d16c15", - "1.05": "0x99a21010" - } - }, - { - "comment": "brake pressure", - "x": 61, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "BRAKE_PRESSURE", - "translate": { - "x": 0, - "y": -50 - }, - "color": { - "0.0": "0xDDa22020" - } - }, - { - "comment": "train brake", - "x": 61, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "TRAIN_BRAKE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "ind brake", - "x": 67, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "INDEPENDENT_BRAKE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "throttle", - "x": 81, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "THROTTLE", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "reverser", - "x": 87, - "y": 74, - "image": "immersiverailroading:gui/indicator.png", - "readout": "REVERSER", - "translate": { - "x": 0, - "y": -50 - } - }, - { - "comment": "speed readout", - "text": { - "value": "stat.speed", - "height": 6 - }, - "x": 50, - "y": 8 - }, - { - "comment": "top labels", - "y": 19, - "elements": [ - { - "x": 10, - "text": { - "value": "stat.liquid", - "height": 4 - } - }, - { - "x": 30, - "text": { - "value": "stat.boiler_psi", - "height": 4 - } - }, - { - "x": 50, - "text": { - "value": "stat.temperature", - "height": 4 - } - }, - { - "x": 68, - "text": { - "value": "label.brake", - "height": 4 - } - }, - { - "x": 89, - "text": { - "value": "label.throttle", - "height": 4 - } - } - ] - }, - { - "comment": "bottom labels", - "y": 78, - "elements": [ - { - "x": 10, - "text": { - "value": "stat.max_liquid", - "height": 4 - } - }, - { - "x": 30, - "text": { - "value": "stat.max_boiler_psi", - "height": 4 - } - }, - { - "x": 50, - "y": 0, - "text": { - "value": "stat.max_temperature", - "height": 4 - } - }, - { - "x": 68, - "text": { - "value": "", - "height": 4 - } - }, - { - "x": 89, - "text": { - "value": "label.reverser", - "height": 4 - } - } - ] - } - ] - } - ] + "comment": "Legacy JSON wrapper", + "import": "immersiverailroading:gui/steam.caml" } \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_lever.png new file mode 100644 index 000000000..f041ba143 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_stand.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_stand.png new file mode 100644 index 000000000..dfab2c474 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/brake_stand.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_down.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_down.caml new file mode 100644 index 000000000..5a329711b --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_down.caml @@ -0,0 +1,2 @@ +element: + image = "immersiverailroading:gui/default/steam/dial_steam.png" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left.caml new file mode 100644 index 000000000..fcddeba89 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left.caml @@ -0,0 +1,7 @@ +element: + x = 60 # 68 + element: + image = "immersiverailroading:gui/default/steam/dial_steam.png" + rotate = + offset = 90 +x = 8 \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left_down.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left_down.caml new file mode 100644 index 000000000..4e81d390a --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_left_down.caml @@ -0,0 +1,7 @@ +element: + image = "immersiverailroading:gui/default/steam/dial_steam_right_base.png" + rotate = + offset = 180 + + x = 137 + y = 82 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_right.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_right.caml new file mode 100644 index 000000000..cf9d0a281 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_right.caml @@ -0,0 +1,8 @@ +element: + y = 60 + element: + image = "immersiverailroading:gui/default/steam/dial_steam.png" + rotate = + offset = -90 + +x = -68 \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_steam.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_steam.png new file mode 100644 index 000000000..3e56743ce Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_steam.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_ticks_x10.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_ticks_x10.caml new file mode 100644 index 000000000..457260e0d --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_ticks_x10.caml @@ -0,0 +1,60 @@ +# Ticks +element: + x = 29.5 # 60/2 - rotate.x + y = 7 # 60/2 - rotate.y + color = + 0.0 = "0xAA282828" + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -100 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -75 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -50 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = -25 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 0 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 25 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 50 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 75 + element: + image = "immersiverailroading:gui/default/steam/tickmark.png" + rotate = + x = 0.5 + y = 23 + offset = 100 \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_up.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_up.caml new file mode 100644 index 000000000..5d3712a61 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/dial_up.caml @@ -0,0 +1,8 @@ +element: + x = 60 + y = 60 # 8 + element: + image = "immersiverailroading:gui/default/steam/dial_steam.png" + rotate = + offset = 180 +y = 8 \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_boiler_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_boiler_face.caml new file mode 100644 index 000000000..a026eb109 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_boiler_face.caml @@ -0,0 +1,12 @@ +import: + source = immersiverailroading:gui/default/steam/gauge_common_face.caml + replace = + TITLE = BOILER + MIN = 0 + CURRENT = stat.boiler_pressure stat.units_boiler_pressure + MAX = stat.max_boiler_pressure + +import: + source = immersiverailroading:gui/default/steam/gauge_dial.caml + replace = + READOUT = BOILER_PRESSURE \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_brake_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_brake_face.caml new file mode 100644 index 000000000..c1ba76d00 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_brake_face.caml @@ -0,0 +1,20 @@ +import: + source = immersiverailroading:gui/default/steam/gauge_common_face.caml + replace = + TITLE = BRAKE + MIN = 0 + CURRENT = stat.brake_pressure stat.units_brake_pressure + MAX = stat.max_brake_pressure + +import: + source = immersiverailroading:gui/default/steam/gauge_dial.caml + replace = + READOUT = TRAIN_BRAKE + +element: + color = + 0 = "0xFFFF1010" + import: + source = immersiverailroading:gui/default/steam/gauge_dial.caml + replace = + READOUT = BRAKE_PRESSURE \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_common_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_common_face.caml new file mode 100644 index 000000000..744967b53 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_common_face.caml @@ -0,0 +1,37 @@ +element: + x = 30 + y = 19 + text = + value = TITLE + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 30 + y = 47 + text = + value = CURRENT + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 14 + y = 40 + text = + value = MIN + height = 4 + color = + 0.0 = "0xFF000000" + +element: + x = 44 + y = 40 + text = + value = MAX + height = 4 + color = + 0.0 = "0xFF000000" + +import: "immersiverailroading:gui/default/steam/dial_ticks_x10.caml" \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_dial.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_dial.caml new file mode 100644 index 000000000..5e5428c23 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_dial.caml @@ -0,0 +1,10 @@ +element: + image = "immersiverailroading:gui/default/steam/steam_dial.png" + x = 27.5 # 60/2 - rotate.x + y = 16 # 60/2 - rotate.y + readout = READOUT + rotate = + x = 2.5 # indicator width/2 + y = 14 # indicator height/2 + degrees = 250 + offset = -125 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_speed_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_speed_face.caml new file mode 100644 index 000000000..1b7c6d844 --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_speed_face.caml @@ -0,0 +1,12 @@ +import: + source = immersiverailroading:gui/default/steam/gauge_common_face.caml + replace = + TITLE = SPEED + MIN = 0 + CURRENT = stat.speed stat.units_speed + MAX = stat.max_speed + +import: + source = immersiverailroading:gui/default/steam/gauge_dial.caml + replace = + READOUT = SPEED \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_temperature_face.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_temperature_face.caml new file mode 100644 index 000000000..2fc5d819f --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_temperature_face.caml @@ -0,0 +1,12 @@ +import: + source = immersiverailroading:gui/default/steam/gauge_common_face.caml + replace = + TITLE = TEMPERATURE + MIN = 0 + CURRENT = stat.temperature stat.units_temperature + MAX = stat.max_temperature + +import: + source = immersiverailroading:gui/default/steam/gauge_dial.caml + replace = + READOUT = TEMPERATURE \ No newline at end of file diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_left.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_left.caml new file mode 100644 index 000000000..ce8ac6d9d --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_left.caml @@ -0,0 +1,14 @@ +element: + image = "immersiverailroading:gui/default/steam/water_glass_left.png" + + element: + x = 104 + y = 87 + image = "immersiverailroading:gui/default/steam/water_glass_fill.png" + + readout = "LIQUID" + translate = + x = 0 + y = -69 + scale = + y = 1 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_right.caml b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_right.caml new file mode 100644 index 000000000..f37663b6a --- /dev/null +++ b/src/main/resources/assets/immersiverailroading/gui/default/steam/gauge_water_right.caml @@ -0,0 +1,15 @@ +element: + image = "immersiverailroading:gui/default/steam/water_glass_right.png" + x = -105 # base width from image + + element: + x = 6 + y = 87 + image = "immersiverailroading:gui/default/steam/water_glass_fill.png" + + readout = "LIQUID" + translate = + x = 0 + y = -69 + scale = + y = 1 diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_base.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_base.png new file mode 100644 index 000000000..885427cd2 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_base.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_lever.png new file mode 100644 index 000000000..4fbadbc38 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_stand.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_stand.png new file mode 100644 index 000000000..774419ec9 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_harp_stand.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_lever.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_lever.png new file mode 100644 index 000000000..e38830003 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/reverser_lever.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/steam_dial.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/steam_dial.png new file mode 100644 index 000000000..babb3673d Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/steam_dial.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle.png new file mode 100644 index 000000000..4fa93d3a5 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle_backing.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle_backing.png new file mode 100644 index 000000000..38279e53a Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/throttle_backing.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/tickmark.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/tickmark.png new file mode 100644 index 000000000..014434c39 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/tickmark.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_fill.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_fill.png new file mode 100644 index 000000000..2bd3b9757 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_fill.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_left.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_left.png new file mode 100644 index 000000000..c77ad1b08 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_left.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_right.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_right.png new file mode 100644 index 000000000..6ced25b01 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/water_glass_right.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle.png new file mode 100644 index 000000000..a1d74208f Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle.png differ diff --git a/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle_cord.png b/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle_cord.png new file mode 100644 index 000000000..90be1df41 Binary files /dev/null and b/src/main/resources/assets/immersiverailroading/gui/default/steam/whistle_cord.png differ