Skip to content

Commit a6db42e

Browse files
authored
Merge pull request #53 from Kotatsu-RTM/issue/39
マーカーのGUIにレールの高さの入力を追加
2 parents 0a20ae4 + e90dedc commit a6db42e

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

src/main/rtm-patches/jp/ngt/rtm/gui/GuiRailMarker.java.patch

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
--- a/jp/ngt/rtm/gui/GuiRailMarker.java
22
+++ b/jp/ngt/rtm/gui/GuiRailMarker.java
3-
@@ -48,18 +48,18 @@
3+
@@ -25,10 +25,11 @@
4+
private GuiTextFieldCustom fieldAncH;
5+
private GuiTextFieldCustom fieldAncV;
6+
private GuiTextFieldCustom fieldCantCenter;
7+
private GuiTextFieldCustom fieldCantEdge;
8+
private GuiTextFieldCustom fieldCantRandom;
9+
+ private GuiTextFieldCustom fieldHeight;
10+
private GuiButton buttonScript;
11+
private GuiTextFieldCustom fieldArgs;
12+
13+
public GuiRailMarker(TileEntityMarker par1) {
14+
this.marker = par1;
15+
@@ -48,18 +49,19 @@
416
this.buttonList.add(new GuiButton(0, this.width / 2 - 105, this.height - 28, 100, 20, I18n.format("gui.done", new Object[0])));
517
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 100, 20, I18n.format("gui.cancel", new Object[0])));
618
this.buttonScript = new GuiButton(100, this.width - 140, 140, 110, 20, s);
@@ -21,13 +33,26 @@
2133
+ this.fieldCantCenter = this.setFloatField(this.width - 70, 20, 60, 20, String.valueOf(this.currentRP.cantCenter));
2234
+ this.fieldCantEdge = this.setFloatField(this.width - 70, 50, 60, 20, String.valueOf(this.currentRP.cantEdge));
2335
+ this.fieldCantRandom = this.setFloatField(this.width - 70, 80, 60, 20, String.valueOf(this.currentRP.cantRandom));
36+
+ this.fieldHeight = this.setIntegerField(this.width - 70, 110, 60, 20, String.valueOf(this.currentRP.height));
2437
+ this.fieldArgs = this.setFloatField(this.width - 140, 170, 130, 20, s1);
2538
if (this.marker.getBlockType() == RTMBlock.markerSwitch) {
2639
this.fieldAncPitch.setEnabled(false);
2740
this.fieldAncV.setEnabled(false);
2841
this.fieldCantCenter.setEnabled(false);
2942
this.fieldCantEdge.setEnabled(false);
30-
@@ -105,24 +105,10 @@
43+
@@ -79,10 +81,11 @@
44+
this.drawCenteredString(this.fontRenderer, "Anchor Length H", this.width - 110, 70, 16777215);
45+
this.drawCenteredString(this.fontRenderer, "Anchor Length V", this.width - 110, 100, 16777215);
46+
this.drawCenteredString(this.fontRenderer, "Cant Center", this.width - 40, 10, 16777215);
47+
this.drawCenteredString(this.fontRenderer, "Cant Edge", this.width - 40, 40, 16777215);
48+
this.drawCenteredString(this.fontRenderer, "Cant Random", this.width - 40, 70, 16777215);
49+
+ this.drawCenteredString(this.fontRenderer, "Height", this.width - 40, 100, 0xFFFFFF);
50+
this.drawCenteredString(this.fontRenderer, "Line Script", this.width - 75, 130, 16777215);
51+
this.drawCenteredString(this.fontRenderer, "Line Script Args", this.width - 75, 160, 16777215);
52+
}
53+
54+
private void renderLineAndAnchor() {
55+
@@ -105,32 +108,19 @@
3156
}
3257

3358
super.actionPerformed(button);
@@ -52,3 +77,32 @@
5277
this.currentRP.anchorPitch = this.getFieldValue(this.fieldAncPitch, this.currentRP.anchorPitch);
5378
this.currentRP.anchorLengthHorizontal = this.getFieldValue(this.fieldAncH, this.currentRP.anchorLengthHorizontal);
5479
this.currentRP.anchorLengthVertical = this.getFieldValue(this.fieldAncV, this.currentRP.anchorLengthVertical);
80+
this.currentRP.cantCenter = this.getFieldValue(this.fieldCantCenter, this.currentRP.cantCenter);
81+
this.currentRP.cantEdge = this.getFieldValue(this.fieldCantEdge, this.currentRP.cantEdge);
82+
this.currentRP.cantRandom = this.getFieldValue(this.fieldCantRandom, this.currentRP.cantRandom);
83+
+ currentRP.setHeight(getHeight());
84+
this.currentRP.scriptName = this.buttonScript.displayString;
85+
this.currentRP.scriptArgs = this.fieldArgs.getText();
86+
}
87+
88+
private float getFieldValue(GuiTextFieldCustom field, float defaultVal) {
89+
@@ -139,10 +129,19 @@
90+
} catch (NumberFormatException numberformatexception) {
91+
return defaultVal;
92+
}
93+
}
94+
95+
+ private byte getHeight() {
96+
+ try {
97+
+ byte value = Byte.parseByte(fieldHeight.getText());
98+
+ return kotlin.ranges.RangesKt.coerceIn(value, (byte) 0, (byte) 15);
99+
+ } catch (NumberFormatException exception) {
100+
+ return currentRP.height;
101+
+ }
102+
+ }
103+
+
104+
private void sendPacket() {
105+
this.updateValues();
106+
RTMCore.NETWORK_WRAPPER.sendToServer(new PacketMarkerRPClient(this.marker));
107+
}
108+
}

0 commit comments

Comments
 (0)