use of net.wurstclient.keybinds.NavigatorNewKeybindScreen in project Wurst-MC-1.12 by Wurst-Imperium.
the class NavigatorFeatureScreen method onResize.
@Override
protected void onResize() {
buttonDatas.clear();
// primary button
String primaryAction = feature.getPrimaryAction();
boolean hasPrimaryAction = !primaryAction.isEmpty();
boolean hasHelp = !feature.getHelpPage().isEmpty();
if (hasPrimaryAction) {
primaryButton = new GuiButton(0, width / 2 - 151, height - 65, hasHelp ? 149 : 302, 18, primaryAction);
buttonList.add(primaryButton);
}
// help button
if (hasHelp)
buttonList.add(new GuiButton(1, width / 2 + (hasPrimaryAction ? 2 : -151), height - 65, hasPrimaryAction ? 149 : 302, 20, "Help"));
// type
text = "Type: " + feature.getType();
// category
if (feature.getCategory() != null)
text += ", Category: " + feature.getCategory().getName();
// description
String description = feature.getDescription();
if (!description.isEmpty())
text += "\n\nDescription:\n" + description;
// area
Rectangle area = new Rectangle(middleX - 154, 60, 308, height - 103);
// settings
ArrayList<Setting> settings = feature.getSettings();
if (!settings.isEmpty()) {
text += "\n\nSettings:";
window.setY(Fonts.segoe15.getStringHeight(text) + 2);
sliders.clear();
checkboxes.clear();
for (int i = 0; i < Math.ceil(window.getInnerHeight() / 9.0); i++) text += "\n";
for (Setting setting : settings) if (setting.getComponent() == null)
setting.addToFeatureScreen(this);
}
// keybinds
ArrayList<PossibleKeybind> possibleKeybinds = feature.getPossibleKeybinds();
if (!possibleKeybinds.isEmpty()) {
// heading
text += "\n\nKeybinds:";
// add keybind button
ButtonData addKeybindButton = new ButtonData(area.x + area.width - 16, area.y + Fonts.segoe15.getStringHeight(text) - 7, 12, 8, "+", 0x00ff00) {
@Override
public void press() {
// add keybind
mc.displayGuiScreen(new NavigatorNewKeybindScreen(possibleKeybinds, NavigatorFeatureScreen.this));
}
};
buttonDatas.add(addKeybindButton);
// keybind list
HashMap<String, String> possibleKeybindsMap = new HashMap<>();
for (PossibleKeybind possibleKeybind : possibleKeybinds) possibleKeybindsMap.put(possibleKeybind.getCommand(), possibleKeybind.getDescription());
TreeMap<String, PossibleKeybind> existingKeybinds = new TreeMap<>();
boolean noKeybindsSet = true;
for (int i = 0; i < WurstClient.INSTANCE.getKeybinds().size(); i++) {
Keybind keybind = WurstClient.INSTANCE.getKeybinds().get(i);
String commands = keybind.getCommands();
commands = commands.replace(";", "�").replace("��", ";");
for (String command : commands.split("�")) {
command = command.trim();
String keybindDescription = possibleKeybindsMap.get(command);
if (keybindDescription != null) {
if (noKeybindsSet)
noKeybindsSet = false;
text += "\n" + keybind.getKey() + ": " + keybindDescription;
existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, keybindDescription));
} else if (feature instanceof Mod && command.equalsIgnoreCase(feature.getName())) {
if (noKeybindsSet)
noKeybindsSet = false;
text += "\n" + keybind.getKey() + ": " + "Toggle " + feature.getName();
existingKeybinds.put(keybind.getKey(), new PossibleKeybind(command, "Toggle " + feature.getName()));
}
}
}
if (noKeybindsSet)
text += "\nNone";
else {
// remove keybind button
buttonDatas.add(new ButtonData(addKeybindButton.x, addKeybindButton.y, addKeybindButton.width, addKeybindButton.height, "-", 0xff0000) {
@Override
public void press() {
// remove keybind
mc.displayGuiScreen(new NavigatorRemoveKeybindScreen(existingKeybinds, NavigatorFeatureScreen.this));
}
});
addKeybindButton.x -= 16;
}
}
// see also
Feature[] seeAlso = feature.getSeeAlso();
if (seeAlso.length != 0) {
text += "\n\nSee also:";
for (Feature seeAlsoFeature : seeAlso) {
int y = 60 + getTextHeight() + 2;
String name = seeAlsoFeature.getName();
text += "\n- " + name;
buttonDatas.add(new ButtonData(middleX - 148, y, Fonts.segoe15.getStringWidth(name) + 1, 8, "", 0x404040) {
@Override
public void press() {
mc.displayGuiScreen(new NavigatorFeatureScreen(seeAlsoFeature, parent));
}
});
}
}
// text height
setContentHeight(Fonts.segoe15.getStringHeight(text));
}
Aggregations