Skip to content

Commit

Permalink
Added proxy names
Browse files Browse the repository at this point in the history
  • Loading branch information
sbxte authored Apr 25, 2021
1 parent ed7c516 commit 3e679d5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ private void initWidgets() {
checkboxes.get(index).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();
Expand Down Expand Up @@ -108,6 +112,12 @@ public EditProxyScreen(GuiTheme theme, Proxy p) {
// General
WTable general = add(theme.table()).expandX().widget();

// Name
general.add(theme.label("Proxy Name:"));
WTextBox name = general.add(theme.textBox(proxy.name)).expandX().widget();
name.action = () -> proxy.name = name.get();
general.row();

// Type
general.add(theme.label("Type:"));
WDropdown<ProxyType> type = general.add(theme.dropdown(proxy.type)).widget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta,
Proxy proxy = Proxies.get().getEnabled();

String left = proxy != null ? "Using proxy " : "Not using a proxy";
String right = proxy != null ? proxy.ip + ":" + proxy.port : null;
String right = proxy != null ? "(" + proxy.name + ") " + proxy.ip + ":" + proxy.port : null;

textRenderer.drawWithShadow(matrices, left, x, y, textColor1);
if (right != null) textRenderer.drawWithShadow(matrices, right, x + textRenderer.getWidth(left), y, textColor2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ public class Proxy implements ISerializable<Proxy> {
public String ip = "";
public int port = 0;

public String name = "";
public String username = "";
public String password = "";

public boolean enabled = false;

public boolean isValid() {
return IP_PATTERN.matcher(ip).matches() && port >= 0 && port <= 65535;
return IP_PATTERN.matcher(ip).matches() && port >= 0 && port <= 65535 && !name.isEmpty();
}

@Override
Expand All @@ -34,6 +35,7 @@ public CompoundTag toTag() {
tag.putString("ip", ip);
tag.putInt("port", port);

tag.putString("name", name);
tag.putString("username", username);
tag.putString("password", password);

Expand All @@ -48,6 +50,7 @@ public Proxy fromTag(CompoundTag tag) {
ip = tag.getString("ip");
port = tag.getInt("port");

name = tag.getString("name");
username = tag.getString("username");
password = tag.getString("password");

Expand Down

0 comments on commit 3e679d5

Please sign in to comment.