/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_2561
 *  net.minecraft.class_332
 *  net.minecraft.class_364
 *  net.minecraft.class_4185
 *  net.minecraft.class_4185$class_7840
 *  net.minecraft.class_437
 *  net.minecraft.class_500
 *  org.spongepowered.asm.mixin.Mixin
 *  org.spongepowered.asm.mixin.Unique
 *  org.spongepowered.asm.mixin.injection.At
 *  org.spongepowered.asm.mixin.injection.Inject
 *  org.spongepowered.asm.mixin.injection.callback.CallbackInfo
 */
package meteordevelopment.meteorclient.mixin;

import java.util.Objects;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.player.NameProtect;
import meteordevelopment.meteorclient.systems.proxies.Proxies;
import meteordevelopment.meteorclient.systems.proxies.Proxy;
import meteordevelopment.meteorclient.utils.render.color.Color;
import net.minecraft.class_2561;
import net.minecraft.class_332;
import net.minecraft.class_364;
import net.minecraft.class_4185;
import net.minecraft.class_437;
import net.minecraft.class_500;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value={class_500.class})
public abstract class MultiplayerScreenMixin
extends class_437 {
    @Unique
    private int textColor1;
    @Unique
    private int textColor2;
    @Unique
    private String loggedInAs;
    @Unique
    private int loggedInAsLength;
    @Unique
    private class_4185 accounts;
    @Unique
    private class_4185 proxies;

    public MultiplayerScreenMixin(class_2561 title) {
        super(title);
    }

    @Inject(method={"method_48640"}, at={@At(value="TAIL")})
    private void onInit(CallbackInfo info) {
        this.textColor1 = Color.fromRGBA(255, 255, 255, 255);
        this.textColor2 = Color.fromRGBA(175, 175, 175, 255);
        this.loggedInAs = "Logged in as ";
        this.loggedInAsLength = this.field_22793.method_1727(this.loggedInAs);
        if (this.accounts == null) {
            this.accounts = (class_4185)this.method_37063((class_364)new class_4185.class_7840((class_2561)class_2561.method_43470((String)"Accounts"), button -> this.field_22787.method_1507((class_437)GuiThemes.get().accountsScreen())).method_46437(75, 20).method_46431());
        }
        this.accounts.method_48229(this.field_22789 - 75 - 3, 3);
        if (this.proxies == null) {
            this.proxies = (class_4185)this.method_37063((class_364)new class_4185.class_7840((class_2561)class_2561.method_43470((String)"Proxies"), button -> this.field_22787.method_1507((class_437)GuiThemes.get().proxiesScreen())).method_46437(75, 20).method_46431());
        }
        this.proxies.method_48229(this.field_22789 - 75 - 3 - 75 - 2, 3);
    }

    public void method_25394(class_332 context, int mouseX, int mouseY, float deltaTicks) {
        String left;
        super.method_25394(context, mouseX, mouseY, deltaTicks);
        int x = 3;
        int y = 3;
        context.method_25303(MeteorClient.mc.field_1772, this.loggedInAs, x, y, this.textColor1);
        context.method_25303(MeteorClient.mc.field_1772, Modules.get().get(NameProtect.class).getName(this.field_22787.method_1548().method_1676()), x + this.loggedInAsLength, y, this.textColor2);
        Objects.requireNonNull(this.field_22793);
        Proxy proxy = Proxies.get().getEnabled();
        String string = left = proxy != null ? "Using proxy " : "Not using a proxy";
        String right = proxy != null ? (String)(proxy.name.get() != null && !proxy.name.get().isEmpty() ? "(" + proxy.name.get() + ") " : "") + proxy.address.get() + ":" + String.valueOf(proxy.port.get()) : null;
        context.method_25303(MeteorClient.mc.field_1772, left, x, y += 9 + 2, this.textColor1);
        if (right != null) {
            context.method_25303(MeteorClient.mc.field_1772, right, x + this.field_22793.method_1727(left), y, this.textColor2);
        }
    }
}

