Skip to content

Commit 0cdeaf5

Browse files
committed
add sound preview button to alarm
1 parent 3002d2f commit 0cdeaf5

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/main/java/gregtech/common/metatileentities/electric/MetaTileEntityAlarm.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.cleanroommc.modularui.api.widget.IWidget;
3131
import com.cleanroommc.modularui.screen.ModularPanel;
3232
import com.cleanroommc.modularui.screen.UISettings;
33+
import com.cleanroommc.modularui.utils.Alignment;
3334
import com.cleanroommc.modularui.value.sync.IntSyncValue;
3435
import com.cleanroommc.modularui.value.sync.PanelSyncHandler;
3536
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
@@ -92,30 +93,38 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation,
9293
createSoundsPopup(soundEventSyncHandler));
9394

9495
// TODO: Change the position of the name when it's standardized.
95-
return GTGuis.createPanel(this, 200, 56)
96+
return GTGuis.createPanel(this, 200, 58)
9697
.child(Flow.column()
97-
.marginLeft(5)
98-
.marginRight(5)
99-
.top(5)
98+
.margin(5)
10099
.coverChildrenHeight()
100+
.crossAxisAlignment(Alignment.CrossAxis.START)
101101
.child(IKey.lang("gregtech.gui.alarm.radius")
102-
.asWidget()
103-
.alignX(0.0f))
102+
.asWidget())
104103
.child(new TextFieldWidget()
105104
.widthRel(1.0f)
106-
.marginTop(1)
105+
.margin(0, 2)
107106
.height(16)
108107
.setMaxLength(10)
109108
.setNumbers(0, 128)
110109
.value(radiusSync)
111110
.background(GTGuiTextures.DISPLAY))
112111
.child(Flow.row()
113112
.widthRel(1.0f)
114-
.marginTop(1)
115113
.coverChildrenHeight()
114+
.mainAxisAlignment(Alignment.MainAxis.START)
115+
.childPadding(2)
116116
.child(new ButtonWidget<>()
117-
.marginRight(4)
118-
.size(16)
117+
.size(18)
118+
.onMousePressed(mouse -> {
119+
guiData.getPlayer().playSound(selectedSound, 1.0f, 1.0f);
120+
// returns false so the default click sound isn't played
121+
return false;
122+
})
123+
.overlay(GTGuiTextures.SPEAKER_ICON.asIcon()
124+
.size(18))
125+
.addTooltipLine(IKey.lang("gregtech.gui.alarm.sounds_preview_button")))
126+
.child(new ButtonWidget<>()
127+
.size(18)
119128
.onMousePressed(mouse -> {
120129
if (soundSelector.isPanelOpen()) {
121130
soundSelector.closePanel();
@@ -125,8 +134,8 @@ public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation,
125134

126135
return true;
127136
})
128-
.overlay(GTGuiTextures.SPEAKER_ICON.asIcon()
129-
.size(18))
137+
.overlay(GTGuiTextures.FILTER_SETTINGS_OVERLAY.asIcon()
138+
.size(16))
130139
.addTooltipLine(IKey.lang("gregtech.gui.alarm.sounds_popup_button")))
131140
.child(IKey.dynamic(() -> getSoundName(selectedSound))
132141
.asWidget()
@@ -152,7 +161,6 @@ protected PanelSyncHandler.IPanelBuilder createSoundsPopup(@NotNull MetaTileEnti
152161
syncHandler.closePanel();
153162
return true;
154163
})
155-
.addTooltipLine(IKey.lang("gregtech.gui.alarm.set_sound"))
156164
.overlay(IKey.str(name.toString()))));
157165
}
158166

src/main/resources/assets/gregtech/lang/en_us.lang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5697,7 +5697,7 @@ gregtech.gui.me_bus.extra_slot=Extra Slot/n§7Put extra items for recipes here,
56975697
gregtech.gui.me_bus.auto_pull_button=Click to toggle automatic item pulling from ME
56985698
gregtech.gui.alarm.radius=Alarm Radius:
56995699
gregtech.gui.alarm.sounds_popup_button=Select sound to play
5700-
gregtech.gui.alarm.set_sound=Set sound
5700+
gregtech.gui.alarm.sounds_preview_button=Click to preview selected sound
57015701
gregtech.gui.alarm.sounds=Sounds
57025702
gregtech.gui.alarm.selected_sound=Selected sound
57035703
gregtech.gui.item_passthrough.enabled=Item Passthough Enabled

0 commit comments

Comments
 (0)