|
7 | 7 | import gregtech.api.items.metaitem.stats.IMouseEventHandler; |
8 | 8 | import gregtech.api.mui.GTGuiTextures; |
9 | 9 | import gregtech.api.mui.GTGuis; |
| 10 | +import gregtech.api.mui.drawable.DynamicColorRectangle; |
10 | 11 | import gregtech.api.mui.factory.MetaItemGuiFactory; |
11 | 12 | import gregtech.api.mui.sync.PagedWidgetSyncHandler; |
12 | 13 | import gregtech.api.util.GTUtility; |
@@ -144,66 +145,43 @@ public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager |
144 | 145 | .addPage(Flow.column() |
145 | 146 | .widthRel(1.0f) |
146 | 147 | .heightRel(1.0f) |
147 | | - .child(Flow.row() |
148 | | - .widthRel(1.0f) |
149 | | - .coverChildrenHeight() |
150 | | - .child(new TextFieldWidget() |
151 | | - .width(30) |
152 | | - .setNumbers(0, 255) |
153 | | - .value(createRGBIntValue(ARGBHelper.RED, rgbColorSync, |
154 | | - usesRGBSync::getBoolValue))) |
155 | | - .child(new SliderWidget() |
156 | | - .width(132) |
157 | | - .bounds(0.0D, 255.0d) |
158 | | - .value(createRGBDoubleValue(ARGBHelper.RED, rgbColorSync, |
159 | | - usesRGBSync::getBoolValue)))) |
160 | | - .child(Flow.row() |
161 | | - .widthRel(1.0f) |
162 | | - .coverChildrenHeight() |
163 | | - .child(new TextFieldWidget() |
164 | | - .width(30) |
165 | | - .setNumbers(0, 255) |
166 | | - .value(createRGBIntValue(ARGBHelper.GREEN, rgbColorSync, |
167 | | - usesRGBSync::getBoolValue))) |
168 | | - .child(new SliderWidget() |
169 | | - .width(132) |
170 | | - .bounds(0.0D, 255.0d) |
171 | | - .value(createRGBDoubleValue(ARGBHelper.GREEN, rgbColorSync, |
172 | | - usesRGBSync::getBoolValue)))) |
173 | | - .child(Flow.row() |
174 | | - .widthRel(1.0f) |
175 | | - .coverChildrenHeight() |
176 | | - .child(new TextFieldWidget() |
177 | | - .width(30) |
178 | | - .setNumbers(0, 255) |
179 | | - .value(createRGBIntValue(ARGBHelper.BLUE, rgbColorSync, |
180 | | - usesRGBSync::getBoolValue))) |
181 | | - .child(new SliderWidget() |
182 | | - .width(132) |
183 | | - .bounds(0.0D, 255.0d) |
184 | | - .value(createRGBDoubleValue(ARGBHelper.BLUE, rgbColorSync, |
185 | | - usesRGBSync::getBoolValue)))))); |
| 148 | + .child(createColorRow(ARGBHelper.RED, rgbColorSync, usesRGBSync::getBoolValue)) |
| 149 | + .child(createColorRow(ARGBHelper.GREEN, rgbColorSync, usesRGBSync::getBoolValue)) |
| 150 | + .child(createColorRow(ARGBHelper.BLUE, rgbColorSync, usesRGBSync::getBoolValue)))); |
186 | 151 | } |
187 | 152 |
|
188 | | - private static IntValue.Dynamic createRGBIntValue(@NotNull ARGBHelper helper, @NotNull IntSyncValue argbSync, |
189 | | - @NotNull BooleanSupplier allowSetting) { |
190 | | - return new IntValue.Dynamic(() -> helper.getFromInt(argbSync.getIntValue()), |
191 | | - newSingleColor -> { |
192 | | - if (allowSetting.getAsBoolean()) { |
193 | | - argbSync.setIntValue(helper.setInInt(argbSync.getIntValue(), newSingleColor)); |
194 | | - } |
195 | | - }); |
196 | | - } |
197 | | - |
198 | | - private static DoubleValue.Dynamic createRGBDoubleValue(@NotNull ARGBHelper helper, |
199 | | - @NotNull IntSyncValue argbSync, |
200 | | - @NotNull BooleanSupplier allowSetting) { |
201 | | - return new DoubleValue.Dynamic(() -> helper.getFromInt(argbSync.getIntValue()), |
202 | | - newSingleColor -> { |
203 | | - if (allowSetting.getAsBoolean()) { |
204 | | - argbSync.setIntValue(helper.setInInt(argbSync.getIntValue(), (int) newSingleColor)); |
205 | | - } |
206 | | - }); |
| 153 | + private static Flow createColorRow(@NotNull ARGBHelper helper, @NotNull IntSyncValue rgbColorSync, |
| 154 | + @NotNull BooleanSupplier allowSetting) { |
| 155 | + return Flow.row() |
| 156 | + .widthRel(1.0f) |
| 157 | + .coverChildrenHeight() |
| 158 | + .child(new TextFieldWidget() |
| 159 | + .width(30) |
| 160 | + .setNumbers(0, 255) |
| 161 | + .value(new IntValue.Dynamic(() -> helper.isolateAndShift(rgbColorSync.getIntValue()), |
| 162 | + colorDigit -> { |
| 163 | + if (allowSetting.getAsBoolean()) { |
| 164 | + int newColor = helper.replace(rgbColorSync.getIntValue(), colorDigit); |
| 165 | + rgbColorSync.setIntValue(newColor); |
| 166 | + } |
| 167 | + }))) |
| 168 | + .child(new SliderWidget() |
| 169 | + .width(132) |
| 170 | + .bounds(0.0D, 255.0d) |
| 171 | + .value(new DoubleValue.Dynamic( |
| 172 | + () -> (double) helper.isolateAndShift(rgbColorSync.getIntValue()), |
| 173 | + colorDigit -> { |
| 174 | + if (allowSetting.getAsBoolean()) { |
| 175 | + int newColor = helper.replace(rgbColorSync.getIntValue(), (int) colorDigit); |
| 176 | + rgbColorSync.setIntValue(newColor); |
| 177 | + } |
| 178 | + })) |
| 179 | + .background( |
| 180 | + new DynamicColorRectangle(() -> helper.isolateWithFullAlpha(rgbColorSync.getIntValue())) |
| 181 | + .asIcon() |
| 182 | + .margin(4, 0) |
| 183 | + .height(8)) |
| 184 | + .addTooltipLine(IKey.lang("metaitem.spray.creative.tip." + helper.toString().toLowerCase()))); |
207 | 185 | } |
208 | 186 |
|
209 | 187 | @Override |
|
0 commit comments