Skip to content

Commit 2288295

Browse files
committed
Label fixes
1 parent f50dc82 commit 2288295

File tree

9 files changed

+77
-67
lines changed

9 files changed

+77
-67
lines changed

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/common/gui/CwgGuiFactory.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -108,46 +108,46 @@ public static GuiTextField doubleTextField(double defaultValue) {
108108
return field;
109109
}
110110

111-
public static CwgGuiLabel label() {
112-
return CwgGuiLabel.create(0, 0, 10, 10, 0xFFFFFFFF);
111+
public static CwgGuiLabel label(CwgGuiLabel.Type type) {
112+
return CwgGuiLabel.create(type, 0, 0, 10, 10, 0xFFFFFFFF);
113113
}
114114

115-
public static CwgGuiLabel label(String formatString) {
116-
return label(formatString, 0xFFFFFFFF, 0, 0);
115+
public static CwgGuiLabel label(CwgGuiLabel.Type type, String formatString) {
116+
return label(type, formatString, 0xFFFFFFFF, 0, 0);
117117
}
118118

119-
public static CwgGuiLabel label(String formatString, int color) {
120-
return label(str(formatString), color, 0, 0);
119+
public static CwgGuiLabel label(CwgGuiLabel.Type type, String formatString, int color) {
120+
return label(type, str(formatString), color, 0, 0);
121121
}
122122

123-
public static CwgGuiLabel label(String formatString, int x, int y) {
124-
return label(formatString, 0xFFFFFFFF, x, y);
123+
public static CwgGuiLabel label(CwgGuiLabel.Type type, String formatString, int x, int y) {
124+
return label(type, formatString, 0xFFFFFFFF, x, y);
125125
}
126126

127-
public static CwgGuiLabel label(String formatString, int color, int x, int y) {
128-
return CwgGuiLabel.create(str(formatString), x, y, 10, 10, color);
127+
public static CwgGuiLabel label(CwgGuiLabel.Type type, String formatString, int color, int x, int y) {
128+
return CwgGuiLabel.create(str(formatString), type, x, y, 10, 10, color);
129129
}
130130

131-
public static CwgGuiLabel labelUnloc(String... lines) {
132-
CwgGuiLabel label = label();
131+
public static CwgGuiLabel labelUnloc(CwgGuiLabel.Type type, String... lines) {
132+
CwgGuiLabel label = label(type);
133133
label.setLines(lines);
134134
return label;
135135
}
136136

137-
public static CwgGuiLabel labelUnloc(String text) {
138-
return labelUnloc(text, 0xFFFFFFFF, 0, 0);
137+
public static CwgGuiLabel labelUnloc(CwgGuiLabel.Type type, String text) {
138+
return labelUnloc(type, text, 0xFFFFFFFF, 0, 0);
139139
}
140140

141-
public static CwgGuiLabel labelUnloc(String text, int color) {
142-
return labelUnloc(str(text), color, 0, 0);
141+
public static CwgGuiLabel labelUnloc(CwgGuiLabel.Type type, String text, int color) {
142+
return labelUnloc(type, str(text), color, 0, 0);
143143
}
144144

145-
public static CwgGuiLabel labelUnloc(String text, int x, int y) {
146-
return labelUnloc(text, 0xFFFFFFFF, x, y);
145+
public static CwgGuiLabel labelUnloc(CwgGuiLabel.Type type, String text, int x, int y) {
146+
return labelUnloc(type, text, 0xFFFFFFFF, x, y);
147147
}
148148

149-
public static CwgGuiLabel labelUnloc(String text, int color, int x, int y) {
150-
return CwgGuiLabel.createUnlocalized(text, x, y, 10, 10, color);
149+
public static CwgGuiLabel labelUnloc(CwgGuiLabel.Type type, String text, int color, int x, int y) {
150+
return CwgGuiLabel.createUnlocalized(text, type, x, y, 10, 10, color);
151151
}
152152

153153
public static CwgGuiButton button(String formatString) {

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/common/gui/FlatCubicGui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.label;
2727
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.wrap;
2828
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.vanillaText;
29+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.CENTERED;
2930

3031
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiButton;
3132
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel;
@@ -101,8 +102,7 @@ private UITabbedContainer makeTabContainer() {
101102
CwgGuiButton done = CwgGuiFactory.button( "done", btn -> FlatCubicGui.this.done());
102103
done.setWidth(BTN_WIDTH);
103104

104-
CwgGuiLabel label = label();
105-
label.setCentered();
105+
CwgGuiLabel label = label(CENTERED);
106106

107107
UIBorderLayout upperLayout = new UIBorderLayout(this)
108108
.setSize(xSize, ySize)

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/common/gui/component/CwgGuiLabel.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,30 @@
3434

3535
public class CwgGuiLabel extends GuiLabel {
3636

37-
public static CwgGuiLabel create(String formatString, int x, int y, int width, int height, int color) {
37+
public static CwgGuiLabel create(String formatString,Type type, int x, int y, int width, int height, int color) {
3838
CwgGuiLabel label = new CwgGuiLabel(x, y, width, height, color);
39+
if (type == Type.CENTERED) {
40+
label.setCentered();
41+
}
3942
label.setTranslationKey(formatString);
4043
return label;
4144
}
4245

43-
public static CwgGuiLabel createUnlocalized(String text, int x, int y, int width, int height, int color) {
46+
public static CwgGuiLabel createUnlocalized(String text, Type type, int x, int y, int width, int height, int color) {
4447
CwgGuiLabel label = new CwgGuiLabel(x, y, width, height, color);
48+
if (type == Type.CENTERED) {
49+
label.setCentered();
50+
}
4551
label.setUnlocalizedText(text);
4652
return label;
4753
}
4854

49-
public static CwgGuiLabel create(int x, int y, int width, int height, int color) {
50-
return new CwgGuiLabel(x, y, width, height, color);
55+
public static CwgGuiLabel create(Type type, int x, int y, int width, int height, int color) {
56+
CwgGuiLabel label = new CwgGuiLabel(x, y, width, height, color);
57+
if (type == Type.CENTERED) {
58+
label.setCentered();
59+
}
60+
return label;
5161
}
5262

5363
private CwgGuiLabel(int x, int y, int width, int height, int color) {
@@ -78,4 +88,8 @@ public void setLines(String... text) {
7888
Collections.addAll(labels, text);
7989
this.height = text.length * 10;
8090
}
91+
92+
public enum Type {
93+
LEFT_ALIGN, CENTERED
94+
}
8195
}

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/common/gui/component/UIFlatTerrainLayer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.wrap;
3636
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.FlatLayersTab.HORIZONTAL_INSETS;
3737
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.FlatLayersTab.VERTICAL_INSETS;
38+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.LEFT_ALIGN;
3839

3940
import io.github.opencubicchunks.cubicchunks.cubicgen.preset.FlatLayer;
4041
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.FlatCubicGui;
@@ -70,7 +71,7 @@ public UIFlatTerrainLayer(FlatCubicGui guiFor, FlatLayersTab flatLayersTabFor, F
7071
updateLabels();
7172
}).display());
7273

73-
this.blockInfo = label();
74+
this.blockInfo = label(LEFT_ALIGN);
7475
updateLabels();
7576

7677
addLayer = button("add_layer");
@@ -80,8 +81,8 @@ public UIFlatTerrainLayer(FlatCubicGui guiFor, FlatLayersTab flatLayersTabFor, F
8081
removeLayer.y = 20;
8182
removeLayer.onClick(btn -> removeLayer());
8283

83-
from = label("from");
84-
to = label("to_exclusively");
84+
from = label(LEFT_ALIGN, "from");
85+
to = label(LEFT_ALIGN, "to_exclusively");
8586

8687
fromField = intTextField(layer.fromY);
8788
toField = intTextField(layer.toY);

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/customcubic/gui/AdvancedTerrainShapeTab.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.wrap;
3333
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.makeUISelect;
3434
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.malisisText;
35+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.CENTERED;
36+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.LEFT_ALIGN;
3537
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.HORIZONTAL_INSETS;
3638
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.HORIZONTAL_PADDING;
3739
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.VERTICAL_INSETS;
@@ -122,7 +124,7 @@ class AdvancedTerrainShapeTab {
122124
.setRightPadding(6)
123125

124126
//expected heights
125-
.add(wrap(gui, CwgGuiFactory.label("expected_heights_group")),
127+
.add(wrap(gui, label(CENTERED, "expected_heights_group")),
126128
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, gridY += 2, WIDTH_1_COL))
127129
.add(wrap(gui, this.lockExpectedHeights = checkBox("lock_expected_heights", true)),
128130
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 0, ++gridY, WIDTH_2_COL))
@@ -135,7 +137,7 @@ class AdvancedTerrainShapeTab {
135137
this.expectedHeightVariation = doubleTextField(conf.getDouble("expectedHeightVariation"))),
136138
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 1, gridY, WIDTH_2_COL))
137139
// height variation
138-
.add(wrap(gui, CwgGuiFactory.label("height_variation_group")),
140+
.add(wrap(gui, label(CENTERED, "height_variation_group")),
139141
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
140142
.add(wrap(gui, this.heightVariationFactor = positiveExponentialSlider(
141143
0, 20, conf.getDouble("heightVariationFactor"), "height_variation_factor_slider")),
@@ -149,7 +151,7 @@ class AdvancedTerrainShapeTab {
149151
new UIVerticalTableLayout.GridLocation(WIDTH_3_COL * 2, gridY, WIDTH_3_COL))
150152

151153
// height
152-
.add(wrap(gui, CwgGuiFactory.label("height_group")),
154+
.add(wrap(gui, label(CENTERED, "height_group")),
153155
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
154156
.add(wrap(gui, this.heightFactor = symmetricExponentialSlider(
155157
1, 20, conf.getDouble("heightFactor"), "height_factor")),
@@ -159,7 +161,7 @@ class AdvancedTerrainShapeTab {
159161
new UIVerticalTableLayout.GridLocation(WIDTH_2_COL * 1, gridY, WIDTH_2_COL))
160162

161163
// depth noise
162-
.add(wrap(gui, CwgGuiFactory.label("depth_noise_group")),
164+
.add(wrap(gui, label(CENTERED, "depth_noise_group")),
163165
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
164166
.add(wrap(gui, this.depthNoisePeriodX = CwgGuiFactory.invertedPositiveExponentialSlider(
165167
-8, MAX_NOISE_FREQ_POWER, 1.0 / conf.getDouble("depthNoiseFrequencyX"), "depth_noise_period_x")),
@@ -179,7 +181,7 @@ class AdvancedTerrainShapeTab {
179181
new UIVerticalTableLayout.GridLocation(WIDTH_3_COL * 2, gridY, WIDTH_3_COL))
180182

181183
// selector noise
182-
.add(wrap(gui, CwgGuiFactory.label("selector_noise_group")),
184+
.add(wrap(gui, label(CENTERED, "selector_noise_group")),
183185
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
184186
.add(wrap(gui, this.selectorNoisePeriodX = CwgGuiFactory.invertedPositiveExponentialSlider(
185187
-8, MAX_NOISE_FREQ_POWER, 1.0 / conf.getDouble("selectorNoiseFrequencyX"), "selector_noise_period_x")),
@@ -203,7 +205,7 @@ class AdvancedTerrainShapeTab {
203205

204206

205207
// low noise
206-
.add(wrap(gui, CwgGuiFactory.label("low_noise_group")),
208+
.add(wrap(gui, label(CENTERED, "low_noise_group")),
207209
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
208210
.add(wrap(gui, this.lowNoisePeriodX = CwgGuiFactory.invertedPositiveExponentialSlider(
209211
-8, MAX_NOISE_FREQ_POWER, 1.0 / conf.getDouble("lowNoiseFrequencyX"), "low_noise_period_x")),
@@ -226,7 +228,7 @@ class AdvancedTerrainShapeTab {
226228
new UIVerticalTableLayout.GridLocation(WIDTH_3_COL * 2, gridY, WIDTH_3_COL))
227229

228230
// high noise
229-
.add(wrap(gui, CwgGuiFactory.label("high_noise_group")),
231+
.add(wrap(gui, label(CENTERED, "high_noise_group")),
230232
new UIVerticalTableLayout.GridLocation(WIDTH_1_COL * 0, ++gridY, WIDTH_1_COL))
231233
.add(wrap(gui, this.highNoisePeriodX = CwgGuiFactory.invertedPositiveExponentialSlider(
232234
-8, MAX_NOISE_FREQ_POWER, 1.0 / conf.getDouble("highNoiseFrequencyX"), "high_noise_period_x")),
@@ -359,7 +361,7 @@ public void onUpdate(ComponentEvent.ValueChange<UISelect<EnumFacing.Axis>, EnumF
359361
}
360362

361363
private static UIComponent<?> doubleInput(ExtraGui gui, String labelText, GuiTextField field) {
362-
UISplitLayout<?> split = new UISplitLayout<>(gui, UISplitLayout.Type.SIDE_BY_SIDE, wrap(gui, label(labelText)), wrap(gui, field));
364+
UISplitLayout<?> split = new UISplitLayout<>(gui, UISplitLayout.Type.SIDE_BY_SIDE, wrap(gui, label(LEFT_ALIGN, labelText)), wrap(gui, field));
363365
split.setSizeOf(UISplitLayout.Pos.SECOND, 40);
364366
split.autoFitToContent(true);
365367
return split;

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/customcubic/gui/CaveSettingsTab.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.slider;
3030
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.wrap;
3131
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.*;
32+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.LEFT_ALIGN;
3233
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.HORIZONTAL_PADDING;
3334
import static io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.gui.CustomCubicGui.VERTICAL_INSETS;
3435

@@ -227,7 +228,7 @@ private class UICaveOptionEntry extends UIVerticalTableLayout<UICaveOptionEntry>
227228
updateCaveLabel();
228229
}).display();
229230
});
230-
this.caveBlockLabel = label();
231+
this.caveBlockLabel = label(LEFT_ALIGN);
231232
updateCaveLabel();
232233

233234
this.caveRarity = intSlider(1, 128, conf.getInt("caveRarity"), "cave_rarity");

src/main/java/io/github/opencubicchunks/cubicchunks/cubicgen/customcubic/gui/CustomCubicGui.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,20 @@
2727
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.label;
2828
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory.wrap;
2929
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.MalisisGuiUtils.vanillaText;
30+
import static io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel.Type.CENTERED;
3031

3132
import blue.endless.jankson.JsonGrammar;
3233
import blue.endless.jankson.JsonObject;
3334
import blue.endless.jankson.api.DeserializationException;
3435
import com.google.common.eventbus.Subscribe;
3536
import io.github.opencubicchunks.cubicchunks.cubicgen.CustomCubicMod;
36-
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.CwgGuiFactory;
3737
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.ExtraGui;
3838
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.GuiOverlay;
3939
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiButton;
4040
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.CwgGuiLabel;
4141
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.NoTranslationFont;
4242
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UIBorderLayout;
4343
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UIColoredPanel;
44-
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UIMultilineLabel;
4544
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UISplitLayout;
4645
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UITabbedContainer;
4746
import io.github.opencubicchunks.cubicchunks.cubicgen.common.gui.component.UITextFieldFixed;
@@ -56,7 +55,6 @@
5655
import net.malisis.core.client.gui.component.container.UIContainer;
5756
import net.malisis.core.client.gui.component.interaction.UITextField;
5857
import net.malisis.core.client.gui.event.ComponentEvent;
59-
import net.malisis.core.renderer.font.FontOptions;
6058
import net.minecraft.client.gui.GuiCreateWorld;
6159
import net.minecraft.client.resources.I18n;
6260

@@ -151,12 +149,12 @@ private UITabbedContainer makeTabContainer() {
151149
final int xSize = UIComponent.INHERITED - HORIZONTAL_PADDING * 2 - HORIZONTAL_INSETS * 2;
152150
final int ySize = VERTICAL_PADDING;
153151
final int xPos = HORIZONTAL_PADDING + HORIZONTAL_INSETS;
154-
CwgGuiButton prev = CwgGuiFactory.button( "previous_page");
155-
CwgGuiButton next = CwgGuiFactory.button( "next_page");
152+
CwgGuiButton prev = button( "previous_page");
153+
CwgGuiButton next = button( "next_page");
156154
prev.setWidth(BTN_WIDTH);
157155
next.setWidth(BTN_WIDTH);
158156

159-
CwgGuiLabel label = label();
157+
CwgGuiLabel label = label(CENTERED);
160158

161159
UIBorderLayout upperLayout = new UIBorderLayout(this)
162160
.setSize(xSize, ySize)
@@ -170,7 +168,7 @@ private UITabbedContainer makeTabContainer() {
170168
done.x = 0;
171169
done.y = 0;
172170

173-
CwgGuiButton sharePreset = CwgGuiFactory.button("presets");
171+
CwgGuiButton sharePreset = button("presets");
174172
sharePreset.setWidth(BTN_WIDTH);
175173
sharePreset.x = BTN_WIDTH + 10;
176174

@@ -187,8 +185,8 @@ private UITabbedContainer makeTabContainer() {
187185
UISplitLayout<?> presetsButtonsSplit = new UISplitLayout<>(gui, UISplitLayout.Type.STACKED,
188186
presetsSplit,
189187
new UISplitLayout<>(gui, UISplitLayout.Type.SIDE_BY_SIDE,
190-
wrap(gui, doneShare = CwgGuiFactory.button("presets.done")),
191-
wrap(gui, cancelShare = CwgGuiFactory.button("presets.cancel"))
188+
wrap(gui, doneShare = button("presets.done")),
189+
wrap(gui, cancelShare = button("presets.cancel"))
192190
).setPadding(0, 3)
193191
).setSizeOf(UISplitLayout.Pos.SECOND, 26).setPadding(HORIZONTAL_PADDING, 0);
194192

0 commit comments

Comments
 (0)