-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.21.1] More overriders for 3PanelScreen, and Togglable Button (#118)
* Make scrollbar and bottom panel configurable * Add Toggleable Button and Remove Fabric Mixin * Add opinion to change bottom panel height * Set required fabric api version Update to new Fabric do it our mixin removal * Formatting fixes
- Loading branch information
1 parent
7de707d
commit 4a0e323
Showing
8 changed files
with
101 additions
and
38 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
54 changes: 54 additions & 0 deletions
54
common/src/main/java/dev/ftb/mods/ftblibrary/ui/ToggleableButton.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,54 @@ | ||
package dev.ftb.mods.ftblibrary.ui; | ||
|
||
import dev.ftb.mods.ftblibrary.icon.Icon; | ||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public class ToggleableButton extends SimpleButton { | ||
|
||
private Component enabledText; | ||
private Component disabledText; | ||
|
||
private boolean state; | ||
|
||
public ToggleableButton(Panel panel, boolean defaultState, Icon enabled, Icon disabled, ToggleableCallback toggleableCallback) { | ||
super(panel, Component.empty(), defaultState ? enabled : disabled, null); | ||
this.state = defaultState; | ||
this.setConsumer((widget, button) -> { | ||
this.state = !this.state; | ||
widget.setIcon(this.state ? enabled : disabled); | ||
toggleableCallback.onClicked(widget, this.state); | ||
}); | ||
this.enabledText = Component.translatable("ftblibrary.gui.enabled").withStyle(ChatFormatting.GREEN); | ||
this.disabledText = Component.translatable("ftblibrary.gui.disabled").withStyle(ChatFormatting.RED); | ||
updateTitle(); | ||
} | ||
|
||
public Component getEnabledText() { | ||
return enabledText; | ||
} | ||
|
||
public ToggleableButton setEnabledText(Component enabledText) { | ||
this.enabledText = enabledText; | ||
updateTitle(); | ||
return this; | ||
} | ||
|
||
public Component getDisabledText() { | ||
return disabledText; | ||
} | ||
|
||
public ToggleableButton setDisabledText(Component disabledText) { | ||
this.disabledText = disabledText; | ||
updateTitle(); | ||
return this; | ||
} | ||
|
||
private void updateTitle() { | ||
setTitle(state ? enabledText : disabledText); | ||
} | ||
|
||
public interface ToggleableCallback { | ||
void onClicked(SimpleButton widget, boolean newState); | ||
} | ||
} |
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
26 changes: 0 additions & 26 deletions
26
...src/main/java/dev/ftb/mods/ftblibrary/core/mixin/fabric/AbstractContainerScreenMixin.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
"PlayerMixin" | ||
], | ||
"client": [ | ||
"AbstractContainerScreenMixin", | ||
"KeyMappingAccessor" | ||
], | ||
"injectors": { | ||
|
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