Search in sources :

Example 1 with PossibleKeybind

use of net.wurstclient.keybinds.PossibleKeybind in project Wurst-MC-1.12 by Wurst-Imperium.

the class SliderSetting method getPossibleKeybinds.

@Override
public final ArrayList<PossibleKeybind> getPossibleKeybinds(String featureName) {
    ArrayList<PossibleKeybind> binds = new ArrayList<>();
    String fullName = featureName + " " + getName();
    String cmd = ".setslider " + featureName.toLowerCase() + " " + getName().toLowerCase().replace(" ", "_") + " ";
    binds.add(new PossibleKeybind(cmd + "more", "Increase " + fullName));
    binds.add(new PossibleKeybind(cmd + "less", "Decrease " + fullName));
    return binds;
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) ArrayList(java.util.ArrayList)

Example 2 with PossibleKeybind

use of net.wurstclient.keybinds.PossibleKeybind in project Wurst-MC-1.12 by Wurst-Imperium.

the class Mod method getPossibleKeybinds.

@Override
public final ArrayList<PossibleKeybind> getPossibleKeybinds() {
    // mod keybinds
    String dotT = ".t " + name.toLowerCase();
    ArrayList<PossibleKeybind> possibleKeybinds = new ArrayList<>(Arrays.asList(new PossibleKeybind(dotT, "Toggle " + name), new PossibleKeybind(dotT + " on", "Enable " + name), new PossibleKeybind(dotT + " off", "Disable " + name)));
    // settings keybinds
    for (Setting setting : getSettings()) possibleKeybinds.addAll(setting.getPossibleKeybinds(name));
    return possibleKeybinds;
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) Setting(net.wurstclient.settings.Setting) ArrayList(java.util.ArrayList)

Example 3 with PossibleKeybind

use of net.wurstclient.keybinds.PossibleKeybind 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));
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) Mod(net.wurstclient.features.Mod) HashMap(java.util.HashMap) Setting(net.wurstclient.settings.Setting) SliderSetting(net.wurstclient.settings.SliderSetting) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Rectangle(java.awt.Rectangle) TreeMap(java.util.TreeMap) NavigatorNewKeybindScreen(net.wurstclient.keybinds.NavigatorNewKeybindScreen) Feature(net.wurstclient.features.Feature) NavigatorRemoveKeybindScreen(net.wurstclient.keybinds.NavigatorRemoveKeybindScreen) GuiButton(net.minecraft.client.gui.GuiButton) Keybind(net.wurstclient.keybinds.KeybindList.Keybind) PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind)

Example 4 with PossibleKeybind

use of net.wurstclient.keybinds.PossibleKeybind in project Wurst-MC-1.12 by Wurst-Imperium.

the class CheckboxSetting method getPossibleKeybinds.

@Override
public final ArrayList<PossibleKeybind> getPossibleKeybinds(String featureName) {
    ArrayList<PossibleKeybind> possibleKeybinds = new ArrayList<>();
    String fullName = featureName + " " + getName();
    String command = ".setcheckbox " + featureName.toLowerCase() + " " + getName().toLowerCase().replace(" ", "_") + " ";
    possibleKeybinds.add(new PossibleKeybind(command + "toggle", "Toggle " + fullName));
    possibleKeybinds.add(new PossibleKeybind(command + "on", "Enable " + fullName));
    possibleKeybinds.add(new PossibleKeybind(command + "off", "Disable " + fullName));
    return possibleKeybinds;
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) ArrayList(java.util.ArrayList)

Example 5 with PossibleKeybind

use of net.wurstclient.keybinds.PossibleKeybind in project Wurst-MC-1.12 by Wurst-Imperium.

the class ModeSetting method getPossibleKeybinds.

@Override
public final ArrayList<PossibleKeybind> getPossibleKeybinds(String featureName) {
    ArrayList<PossibleKeybind> possibleKeybinds = new ArrayList<>();
    String fullName = featureName + " " + getName();
    String command = ".setmode " + featureName.toLowerCase() + " " + getName().toLowerCase().replace(" ", "_") + " ";
    String description = "Set " + fullName + " to ";
    possibleKeybinds.add(new PossibleKeybind(command + "next", "Next " + fullName));
    possibleKeybinds.add(new PossibleKeybind(command + "prev", "Previous " + fullName));
    for (String mode : modes) possibleKeybinds.add(new PossibleKeybind(command + mode.toLowerCase().replace(" ", "_"), description + mode));
    return possibleKeybinds;
}
Also used : PossibleKeybind(net.wurstclient.keybinds.PossibleKeybind) ArrayList(java.util.ArrayList)

Aggregations

PossibleKeybind (net.wurstclient.keybinds.PossibleKeybind)5 ArrayList (java.util.ArrayList)4 Setting (net.wurstclient.settings.Setting)2 Rectangle (java.awt.Rectangle)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 GuiButton (net.minecraft.client.gui.GuiButton)1 Feature (net.wurstclient.features.Feature)1 Mod (net.wurstclient.features.Mod)1 Keybind (net.wurstclient.keybinds.KeybindList.Keybind)1 NavigatorNewKeybindScreen (net.wurstclient.keybinds.NavigatorNewKeybindScreen)1 NavigatorRemoveKeybindScreen (net.wurstclient.keybinds.NavigatorRemoveKeybindScreen)1 CheckboxSetting (net.wurstclient.settings.CheckboxSetting)1 SliderSetting (net.wurstclient.settings.SliderSetting)1