use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class WAccount method init.
@Override
public void init() {
// Head
add(theme.texture(32, 32, account.getCache().shouldRotateHeadTexture() ? 90 : 0, account.getCache().getHeadTexture()));
// Name
WLabel name = add(theme.label(account.getUsername())).widget();
if (mc.getSession().getUsername().equalsIgnoreCase(account.getUsername()))
name.color = loggedInColor();
// Type
WLabel label = add(theme.label("(" + account.getType() + ")")).expandCellX().right().widget();
label.color = accountTypeColor();
// Login
WButton login = add(theme.button("Login")).widget();
login.action = () -> {
login.minWidth = login.width;
login.set("...");
screen.locked = true;
MatHaxExecutor.execute(() -> {
if (account.login()) {
name.set(account.getUsername());
Accounts.get().save();
screen.taskAfterRender = refreshScreenAction;
}
login.minWidth = 0;
login.set("Login");
screen.locked = false;
});
};
// Remove
WMinus remove = add(theme.minus()).widget();
remove.action = () -> {
Accounts.get().remove(account);
if (refreshScreenAction != null)
refreshScreenAction.run();
};
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class Notebot method getWidget.
// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
WTable table = theme.table();
// Label
status = table.add(theme.label(getStatus())).expandCellX().widget();
// Pause
WButton pauseBtn = table.add(theme.button(isPlaying ? "Pause" : "Resume")).right().widget();
pauseBtn.action = () -> {
pause();
pauseBtn.set(isPlaying ? "Pause" : "Resume");
status.set(getStatus());
};
// Stop
WButton stop = table.add(theme.button("Stop")).right().widget();
stop.action = this::stop;
table.row();
noSongsFound = true;
try {
Files.list(MatHax.FOLDER.toPath().resolve("Notebot")).forEach(path -> {
if (isValidFile(path)) {
noSongsFound = false;
table.add(theme.label(getFileLabel(path))).expandCellX();
WButton load = table.add(theme.button("Load")).right().widget();
load.action = () -> {
loadSong(path.toFile());
status.set(getStatus());
};
WButton preview = table.add(theme.button("Preview")).right().widget();
preview.action = () -> {
previewSong(path.toFile());
status.set(getStatus());
};
table.row();
}
});
} catch (IOException e) {
table.add(theme.label("Missing \"Notebot\" folder.")).expandCellX();
table.row();
}
if (noSongsFound) {
table.add(theme.label("No songs found.")).expandCellX();
table.row();
WButton guide = table.add(theme.button("Guide")).expandX().widget();
guide.action = () -> Util.getOperatingSystem().open("https://mathaxclient.xyz/Notebot-Guide");
}
return table;
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class BookBot method getWidget.
// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
WHorizontalList list = theme.horizontalList();
WButton selectFile = list.add(theme.button("Select File")).widget();
WLabel fileName = list.add(theme.label((file != null && file.exists()) ? file.getName() : "No file selected.")).widget();
selectFile.action = () -> {
String path = TinyFileDialogs.tinyfd_openFileDialog("Select File", new File(MatHax.FOLDER, "bookbot.txt").getAbsolutePath(), filters, null, false);
if (path != null) {
file = new File(path);
fileName.set(file.getName());
}
};
return list;
}
use of mathax.client.gui.widgets.pressable.WButton in project Client by MatHax.
the class Swarm method getWidget.
// Buttons
@Override
public WWidget getWidget(GuiTheme theme) {
WVerticalList list = theme.verticalList();
WHorizontalList b = list.add(theme.horizontalList()).expandX().widget();
WButton start = b.add(theme.button("Start")).expandX().widget();
start.action = () -> {
if (!isActive())
return;
close();
if (mode.get() == Mode.Host)
host = new SwarmHost(serverPort.get());
else
worker = new SwarmWorker(ipAddress.get(), serverPort.get());
};
WButton stop = b.add(theme.button("Stop")).expandX().widget();
stop.action = this::close;
WButton guide = list.add(theme.button("Guide")).expandX().widget();
guide.action = () -> Util.getOperatingSystem().open("https://mathaxclient.xyz/Swarm-Guide");
return list;
}
Aggregations