-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
325 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
fabric/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/ClockDrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextDrawCall; | ||
import com.lx862.jcm.mod.render.TextOverflowMode; | ||
import com.lx862.jcm.mod.render.text.TextAlignment; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
import org.mtr.mapping.mapper.WorldHelper; | ||
|
||
public class ClockDrawCall extends TextDrawCall { | ||
// TODO: (Maybe next version) Add 12/24h toggle | ||
public ClockDrawCall(String font, int textColor, double x, double y, double width, double height) { | ||
super(font, textColor, x, y, width, height); | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
long timeNow = WorldHelper.getTimeOfDay(world) + 6000; | ||
long hours = timeNow / 1000; | ||
long minutes = Math.round((timeNow - (hours * 1000)) / 16.8); | ||
String timeString = String.format("%02d:%02d", hours % 24, minutes % 60); | ||
drawText(graphicsHolder, TextAlignment.RIGHT, facing, timeString, TextOverflowMode.STRETCH); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
fabric/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/DestinationDrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextDrawCall; | ||
import com.lx862.jcm.mod.render.RenderHelper; | ||
import com.lx862.jcm.mod.render.TextOverflowMode; | ||
import com.lx862.jcm.mod.render.text.TextAlignment; | ||
import com.lx862.jcm.mod.render.text.TextInfo; | ||
import com.lx862.jcm.mod.render.text.TextRenderingManager; | ||
import org.mtr.core.operation.ArrivalResponse; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
|
||
public class DestinationDrawCall extends TextDrawCall { | ||
private final ArrivalResponse arrival; | ||
public DestinationDrawCall(ArrivalResponse arrival, String font, int textColor, double x, double y, double width, double height, double scale) { | ||
super(font, textColor, x, y, width, height, scale); | ||
this.arrival = arrival; | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
String routeNo = arrival.getRouteNumber().isEmpty() ? "" : arrival.getRouteNumber() + " "; | ||
String leftDestination = routeNo + arrival.getDestination(); | ||
TextInfo destinationText = new TextInfo(leftDestination).withColor(textColor).withFont(font); | ||
|
||
int destinationWidth = TextRenderingManager.getTextWidth(destinationText); | ||
|
||
graphicsHolder.push(); | ||
if(destinationWidth > width) { | ||
RenderHelper.scaleToFit(graphicsHolder, destinationWidth, width, false); | ||
// TODO: Make marquee an option in custom PIDS Preset | ||
//drawPIDSScrollingText(graphicsHolder, facing, leftDestination, 0, 0, textColor, (int)destinationMaxWidth - 2); | ||
} | ||
|
||
drawText(graphicsHolder, TextAlignment.LEFT, facing, destinationText, TextOverflowMode.STRETCH); | ||
graphicsHolder.pop(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
fabric/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/ETADrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextDrawCall; | ||
import com.lx862.jcm.mod.render.TextOverflowMode; | ||
import com.lx862.jcm.mod.render.text.TextAlignment; | ||
import com.lx862.jcm.mod.render.text.TextInfo; | ||
import com.lx862.jcm.mod.util.TextUtil; | ||
import org.mtr.core.operation.ArrivalResponse; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.MutableText; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
|
||
public class ETADrawCall extends TextDrawCall { | ||
// TODO: (Maybe next version) Add absolute time? | ||
private final ArrivalResponse arrival; | ||
public ETADrawCall(ArrivalResponse arrival, String font, int textColor, double x, double y, double width, double height, double scale) { | ||
super(font, textColor, x, y, width, height, scale); | ||
this.arrival = arrival; | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
long remTime = arrival.getArrival() - System.currentTimeMillis(); | ||
long remSec = remTime / 1000L; | ||
|
||
if((int)remSec > 0) { | ||
MutableText etaText = remSec > 60 ? TextUtil.translatable("gui.mtr.arrival_min", remSec / 60) : TextUtil.translatable("gui.mtr.arrival_sec", remSec % 60); | ||
drawText(graphicsHolder, TextAlignment.RIGHT, facing, new TextInfo(etaText), TextOverflowMode.STRETCH); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ic/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/PlatformCircleDrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextureDrawCall; | ||
import org.mtr.core.operation.ArrivalResponse; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.Identifier; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
|
||
public class PlatformCircleDrawCall extends TextureDrawCall { | ||
private final ArrivalResponse arrival; | ||
public PlatformCircleDrawCall(ArrivalResponse arrival, Identifier textureId, double x, double y, double width, double height) { | ||
super(textureId, x, y, width, height); | ||
this.arrival = arrival; | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
drawTexture(graphicsHolder, facing, texture, 0, 0, width, height, arrival.getRouteColor() + ARGB_BLACK); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
fabric/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/PlatformDrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextDrawCall; | ||
import com.lx862.jcm.mod.render.RenderHelper; | ||
import com.lx862.jcm.mod.render.TextOverflowMode; | ||
import com.lx862.jcm.mod.render.text.TextAlignment; | ||
import com.lx862.jcm.mod.render.text.TextInfo; | ||
import com.lx862.jcm.mod.render.text.TextRenderingManager; | ||
import org.mtr.core.operation.ArrivalResponse; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
|
||
public class PlatformDrawCall extends TextDrawCall { | ||
private final ArrivalResponse arrival; | ||
public PlatformDrawCall(ArrivalResponse arrival, String font, int textColor, double x, double y, double width, double height) { | ||
super(font, textColor, x, y, width, height, 1); | ||
this.arrival = arrival; | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
graphicsHolder.translate(width / 1.6, 2, 0); | ||
drawText(graphicsHolder, TextAlignment.CENTER, facing, arrival.getPlatformName(), TextOverflowMode.SCALE); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
fabric/src/main/java/com/lx862/jcm/mod/data/pids/preset/drawcalls/WeatherIconDrawCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.lx862.jcm.mod.data.pids.preset.drawcalls; | ||
|
||
import com.lx862.jcm.mod.data.pids.preset.drawcalls.base.TextureDrawCall; | ||
import org.mtr.mapping.holder.Direction; | ||
import org.mtr.mapping.holder.Identifier; | ||
import org.mtr.mapping.holder.World; | ||
import org.mtr.mapping.mapper.GraphicsHolder; | ||
|
||
public class WeatherIconDrawCall extends TextureDrawCall { | ||
private final Identifier iconSunny; | ||
private final Identifier iconThunder; | ||
private final Identifier iconRainy; | ||
public WeatherIconDrawCall(Identifier iconSunny, Identifier iconRainy, Identifier iconThunder, double x, double y, double width, double height) { | ||
super(null, x, y, width, height); | ||
this.iconSunny = iconSunny; | ||
this.iconRainy = iconRainy; | ||
this.iconThunder = iconThunder; | ||
} | ||
|
||
@Override | ||
public void render(GraphicsHolder graphicsHolder, World world, Direction facing) { | ||
Identifier textureId; | ||
if(world.isRaining()) { | ||
textureId = iconRainy; | ||
} else if(world.isThundering()) { | ||
textureId = iconThunder; | ||
} else { | ||
textureId = iconSunny; | ||
} | ||
drawTexture(graphicsHolder, facing, textureId, 0, 0, width, height, ARGB_WHITE); | ||
} | ||
} |
Oops, something went wrong.