use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class WKeyBind method init.
@Override
public void init() {
label = add(theme.label("")).widget();
WButton set = add(theme.button("Set")).widget();
set.action = () -> {
listening = true;
label.set(appendBindText("..."));
if (actionOnSet != null)
actionOnSet.run();
};
WButton reset = add(theme.button(GuiRenderer.RESET)).expandCellX().right().widget();
reset.action = this::resetBind;
refreshLabel();
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class WPlaybackControls method add.
@Override
public void add(WTable parent, MusicTab.MusicScreen screen, GuiTheme theme) {
WHorizontalList list = parent.add(theme.horizontalList()).widget();
WButton pauseButton = list.add(theme.button(Music.player.isPaused() ? "Resume" : "Pause")).widget();
pauseButton.action = () -> {
if (Music.player.isPaused()) {
Music.trackScheduler.setPaused(false);
pauseButton.set("Pause");
} else {
Music.trackScheduler.setPaused(true);
pauseButton.set("Resume");
}
};
if (Music.trackScheduler.hasNext()) {
list.add(theme.button("Shuffle")).widget().action = () -> {
Collections.shuffle(Music.trackScheduler.tracks);
screen.construct();
};
list.add(theme.button("Clear")).widget().action = () -> {
Music.trackScheduler.tracks.clear();
screen.construct();
};
}
list.add(theme.button("Playlists")).widget().action = () -> {
mc.setScreen(new PlaylistsScreen(theme, screen));
};
String duration;
AudioTrack current = Music.player.getPlayingTrack();
if (current == null)
duration = "Not playing";
else
duration = Music.getTime();
list.add(theme.label("Duration: " + duration)).right();
parent.row();
super.add(parent, screen, theme);
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class StringListSetting method fillTable.
public static void fillTable(GuiTheme theme, WTable table, StringListSetting setting) {
setting.get().removeIf(String::isEmpty);
ArrayList<String> strings = new ArrayList<>(setting.get());
for (int i = 0; i < setting.get().size(); i++) {
int msgI = i;
String message = setting.get().get(i);
WTextBox textBox = table.add(theme.textBox(message)).expandX().widget();
textBox.action = () -> strings.set(msgI, textBox.get());
textBox.actionOnUnfocused = () -> setting.set(strings);
WMinus delete = table.add(theme.minus()).widget();
delete.action = () -> {
strings.remove(msgI);
setting.set(strings);
table.clear();
fillTable(theme, table, setting);
};
table.row();
}
WTextBox textBox = table.add(theme.textBox(setting.newText)).minWidth(300).expandX().widget();
textBox.action = () -> setting.newText = textBox.get();
WPlus add = table.add(theme.plus()).widget();
add.action = () -> {
strings.add(setting.newText);
setting.set(strings);
setting.newText = "";
table.clear();
fillTable(theme, table, setting);
};
// Reset
table.row();
WButton reset = table.add(theme.button("Reset")).widget();
reset.action = () -> {
setting.reset();
table.clear();
fillTable(theme, table, setting);
};
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class DefaultSettingsWidgetFactory method colorW.
private void colorW(WTable table, ColorSetting setting) {
WHorizontalList list = table.add(theme.horizontalList()).expandX().widget();
WQuad quad = list.add(theme.quad(setting.get())).widget();
WButton edit = list.add(theme.button(GuiRenderer.EDIT)).widget();
edit.action = () -> mc.setScreen(new ColorSettingScreen(theme, setting));
reset(table, setting, () -> quad.color = setting.get());
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class DefaultSettingsWidgetFactory method genericW.
private void genericW(WTable table, GenericSetting<?> setting) {
WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
edit.action = () -> mc.setScreen(setting.get().createScreen(theme));
reset(table, setting, null);
}
Aggregations