Search in sources :

Example 1 with Proxy

use of mathax.client.systems.proxies.Proxy in project Client by MatHax.

the class MultiplayerScreenMixin method onRender.

@Inject(method = "render", at = @At("TAIL"))
private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
    float x = 2;
    float y = 2;
    String space = " ";
    int spaceLength = textRenderer.getWidth(space);
    String loggedInAs = "Logged in as";
    int loggedInAsLength = textRenderer.getWidth(loggedInAs);
    String loggedName = Modules.get().get(NameProtect.class).getName(client.getSession().getUsername());
    int loggedNameLength = textRenderer.getWidth(loggedName);
    String loggedOpenDeveloper = "[";
    int loggedOpenDeveloperLength = textRenderer.getWidth(loggedOpenDeveloper);
    String loggedDeveloper = "Developer";
    int loggedDeveloperLength = textRenderer.getWidth(loggedDeveloper);
    String loggedCloseDeveloper = "]";
    // Logged in as
    drawStringWithShadow(matrices, textRenderer, loggedInAs, 2, (int) y, GRAY);
    drawStringWithShadow(matrices, textRenderer, space, loggedInAsLength + 2, (int) y, GRAY);
    drawStringWithShadow(matrices, textRenderer, loggedName, loggedInAsLength + spaceLength + 2, (int) y, WHITE);
    if (Modules.get() != null && !Modules.get().isActive(NameProtect.class) && Utils.isDeveloper(client.getSession().getUuid())) {
        drawStringWithShadow(matrices, textRenderer, space, loggedInAsLength + spaceLength + loggedNameLength + 2, (int) y, GRAY);
        drawStringWithShadow(matrices, textRenderer, loggedOpenDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + 2, (int) y, GRAY);
        drawStringWithShadow(matrices, textRenderer, loggedDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + loggedOpenDeveloperLength + 2, (int) y, MatHax.INSTANCE.MATHAX_COLOR_INT);
        drawStringWithShadow(matrices, textRenderer, loggedCloseDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + loggedOpenDeveloperLength + loggedDeveloperLength + 2, (int) y, GRAY);
    }
    y += textRenderer.fontHeight + 2;
    // Proxy
    Proxy proxy = Proxies.get().getEnabled();
    String proxyLeft = proxy != null ? "Using proxies" + " " : "Not using a proxies";
    String proxyRight = proxy != null ? (proxy.name != null && !proxy.name.isEmpty() ? "(" + proxy.name + ") " : "") + proxy.address + ":" + proxy.port : null;
    drawStringWithShadow(matrices, textRenderer, proxyLeft, (int) x, (int) y, GRAY);
    if (proxyRight != null)
        drawStringWithShadow(matrices, textRenderer, proxyRight, (int) x + textRenderer.getWidth(proxyLeft), (int) y, WHITE);
}
Also used : Proxy(mathax.client.systems.proxies.Proxy) NameProtect(mathax.client.systems.modules.misc.NameProtect) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with Proxy

use of mathax.client.systems.proxies.Proxy in project Client by MatHax.

the class ProxiesScreen method initWidgets.

@Override
public void initWidgets() {
    // Proxies
    WTable table = add(theme.table()).expandX().widget();
    for (Proxy proxy : Proxies.get()) {
        // Enabled
        WCheckbox enabled = table.add(theme.checkbox(proxy.enabled)).widget();
        checkboxes.add(enabled);
        enabled.action = () -> {
            boolean checked = enabled.checked;
            Proxies.get().setEnabled(proxy, checked);
            for (WCheckbox checkbox : checkboxes) checkbox.checked = false;
            enabled.checked = checked;
        };
        // Name
        WLabel name = table.add(theme.label(proxy.name)).widget();
        name.color = theme.textColor();
        // Type
        WLabel type = table.add(theme.label("(" + proxy.type + ")")).widget();
        type.color = theme.textSecondaryColor();
        // IP + Port
        WHorizontalList ipList = table.add(theme.horizontalList()).expandCellX().widget();
        ipList.spacing = 0;
        ipList.add(theme.label(proxy.address));
        ipList.add(theme.label(":")).widget().color = theme.textSecondaryColor();
        ipList.add(theme.label(Integer.toString(proxy.port)));
        // Edit
        WButton edit = table.add(theme.button(GuiRenderer.EDIT)).widget();
        edit.action = () -> openEditProxyScreen(proxy);
        // Remove
        WMinus remove = table.add(theme.minus()).widget();
        remove.action = () -> {
            Proxies.get().remove(proxy);
            reload();
        };
        table.row();
    }
    WHorizontalList l = add(theme.horizontalList()).expandX().widget();
    // New
    WButton newBtn = l.add(theme.button("New")).expandX().widget();
    newBtn.action = () -> openEditProxyScreen(null);
    // Import
    PointerBuffer filters = BufferUtils.createPointerBuffer(1);
    ByteBuffer txtFilter = MemoryUtil.memASCII("*.txt");
    filters.put(txtFilter);
    filters.rewind();
    WButton importBtn = l.add(theme.button("Import")).expandX().widget();
    importBtn.action = () -> {
        String selectedFile = TinyFileDialogs.tinyfd_openFileDialog("Import Proxies", null, filters, null, false);
        if (selectedFile != null) {
            File file = new File(selectedFile);
            mc.setScreen(new ProxiesImportScreen(theme, file));
        }
    };
}
Also used : PointerBuffer(org.lwjgl.PointerBuffer) WButton(mathax.client.gui.widgets.pressable.WButton) WCheckbox(mathax.client.gui.widgets.pressable.WCheckbox) ByteBuffer(java.nio.ByteBuffer) WLabel(mathax.client.gui.widgets.WLabel) Proxy(mathax.client.systems.proxies.Proxy) WTable(mathax.client.gui.widgets.containers.WTable) WMinus(mathax.client.gui.widgets.pressable.WMinus) File(java.io.File) WHorizontalList(mathax.client.gui.widgets.containers.WHorizontalList)

Example 3 with Proxy

use of mathax.client.systems.proxies.Proxy in project Client by MatHax.

the class TitleScreenMixin method onRender.

@Inject(method = "render", at = @At("TAIL"))
private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo info) {
    float y = 2;
    float y2 = y + textRenderer.fontHeight + y;
    String space = " ";
    int spaceLength = textRenderer.getWidth(space);
    String loggedInAs = "Logged in as";
    int loggedInAsLength = textRenderer.getWidth(loggedInAs);
    String loggedName = Modules.get().get(NameProtect.class).getName(client.getSession().getUsername());
    int loggedNameLength = textRenderer.getWidth(loggedName);
    String loggedOpenDeveloper = "[";
    int loggedOpenDeveloperLength = textRenderer.getWidth(loggedOpenDeveloper);
    String loggedDeveloper = "Developer";
    int loggedDeveloperLength = textRenderer.getWidth(loggedDeveloper);
    String loggedCloseDeveloper = "]";
    Proxy proxy = Proxies.get().getEnabled();
    String proxyUsing = proxy != null ? "Using proxy" + " " : "Not using a proxy";
    int proxyUsingLength = textRenderer.getWidth(proxyUsing);
    String proxyDetails = proxy != null ? "(" + proxy.name + ") " + proxy.address + ":" + proxy.port : null;
    String watermarkName = "MatHax";
    int watermarkNameLength = textRenderer.getWidth(watermarkName);
    String watermarkVersion = Version.getStylized();
    int watermarkVersionLength = textRenderer.getWidth(watermarkVersion);
    int watermarkFullLength = watermarkNameLength + spaceLength + watermarkVersionLength;
    String authorBy = "By";
    int authorByLength = textRenderer.getWidth(authorBy);
    String authorName = "Matejko06";
    int authorNameLength = textRenderer.getWidth(authorName);
    int authorFullLength = authorByLength + spaceLength + authorNameLength;
    drawStringWithShadow(matrices, textRenderer, loggedInAs, 2, (int) y, GRAY);
    drawStringWithShadow(matrices, textRenderer, space, loggedInAsLength + 2, (int) y, GRAY);
    drawStringWithShadow(matrices, textRenderer, loggedName, loggedInAsLength + spaceLength + 2, (int) y, WHITE);
    if (Modules.get() != null && !Modules.get().isActive(NameProtect.class) && Utils.isDeveloper(client.getSession().getUuid())) {
        drawStringWithShadow(matrices, textRenderer, space, loggedInAsLength + spaceLength + loggedNameLength + 2, (int) y, GRAY);
        drawStringWithShadow(matrices, textRenderer, loggedOpenDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + 2, (int) y, GRAY);
        drawStringWithShadow(matrices, textRenderer, loggedDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + loggedOpenDeveloperLength + 2, (int) y, MatHax.INSTANCE.MATHAX_COLOR_INT);
        drawStringWithShadow(matrices, textRenderer, loggedCloseDeveloper, loggedInAsLength + spaceLength + loggedNameLength + spaceLength + loggedOpenDeveloperLength + loggedDeveloperLength + 2, (int) y, GRAY);
    }
    int watermarkPreviousWidth = 0;
    drawStringWithShadow(matrices, textRenderer, watermarkName, width - watermarkFullLength - 2, (int) y, MatHax.INSTANCE.MATHAX_COLOR_INT);
    watermarkPreviousWidth += watermarkNameLength;
    drawStringWithShadow(matrices, textRenderer, space, width - watermarkFullLength + watermarkPreviousWidth - 2, (int) y, WHITE);
    watermarkPreviousWidth += spaceLength;
    drawStringWithShadow(matrices, textRenderer, watermarkVersion, width - watermarkFullLength + watermarkPreviousWidth - 2, (int) y, GRAY);
    int authorPreviousWidth = 0;
    drawStringWithShadow(matrices, textRenderer, authorBy, width - authorFullLength - 2, (int) y2, GRAY);
    authorPreviousWidth += authorByLength;
    drawStringWithShadow(matrices, textRenderer, space, width - authorFullLength + authorPreviousWidth - 2, (int) y2, GRAY);
    authorPreviousWidth += spaceLength;
    drawStringWithShadow(matrices, textRenderer, authorName, width - authorFullLength + authorPreviousWidth - 2, (int) y2, WHITE);
    drawStringWithShadow(matrices, textRenderer, proxyUsing, 2, (int) y2, GRAY);
    if (proxyDetails != null)
        drawStringWithShadow(matrices, textRenderer, proxyDetails, 2 + proxyUsingLength, (int) y2, WHITE);
}
Also used : Proxy(mathax.client.systems.proxies.Proxy) NameProtect(mathax.client.systems.modules.misc.NameProtect) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

Proxy (mathax.client.systems.proxies.Proxy)3 NameProtect (mathax.client.systems.modules.misc.NameProtect)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 File (java.io.File)1 ByteBuffer (java.nio.ByteBuffer)1 WLabel (mathax.client.gui.widgets.WLabel)1 WHorizontalList (mathax.client.gui.widgets.containers.WHorizontalList)1 WTable (mathax.client.gui.widgets.containers.WTable)1 WButton (mathax.client.gui.widgets.pressable.WButton)1 WCheckbox (mathax.client.gui.widgets.pressable.WCheckbox)1 WMinus (mathax.client.gui.widgets.pressable.WMinus)1 PointerBuffer (org.lwjgl.PointerBuffer)1