Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul XP Bar system; adds right click menu & new logic #60

Merged
merged 13 commits into from
Dec 30, 2020
Merged
54 changes: 53 additions & 1 deletion src/Client/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import Game.KeyboardHandler;
import Game.Renderer;
import Game.Replay;
import Game.XPBar;
import java.awt.Cursor;
import java.awt.Point;
import java.awt.image.BufferedImage;
Expand All @@ -44,7 +45,7 @@ public class Settings {
public static boolean fovUpdateRequired;
public static boolean versionCheckRequired = true;
public static int javaVersion = 0;
public static final double VERSION_NUMBER = 20201202.021116;
public static final double VERSION_NUMBER = 20201211.234544;
/**
* A time stamp corresponding to the current version of this source code. Used as a sophisticated
* versioning system.
Expand Down Expand Up @@ -1361,6 +1362,29 @@ public static void initSettings() {
kbs.modifier = getKeyModifierFromString(keybindCombo);
kbs.key = Integer.parseInt(keybindCombo.substring(2));
}

// XP
int numberOfGoalers = getPropInt(props, "numberOfGoalers", 0);
String[] goalerUsernames = new String[numberOfGoalers];
for (int usernameID = 0; usernameID < numberOfGoalers; usernameID++) {
goalerUsernames[usernameID] = getPropString(props, "username" + usernameID, "");
Client.xpGoals.put(goalerUsernames[usernameID], new Integer[Client.NUM_SKILLS]);
Client.lvlGoals.put(goalerUsernames[usernameID], new Float[Client.NUM_SKILLS]);
for (int skill = 0; skill < Client.NUM_SKILLS; skill++) {
Client.xpGoals.get(goalerUsernames[usernameID])[skill] =
getPropInt(props, String.format("xpGoal%02d%03d", skill, usernameID), 0);
try {
Client.lvlGoals.get(goalerUsernames[usernameID])[skill] =
Float.parseFloat(getPropString(props, String.format("lvlGoal%02d%03d", skill, usernameID), "0"));
} catch (Exception e1) {
Client.lvlGoals.get(goalerUsernames[usernameID])[skill] = new Float(0);
Logger.Warn("Couldn't parse settings key " + String.format("lvlGoal%02d%03d", skill, usernameID));
}
}
}
XPBar.pinnedBar = getPropBoolean(props,"pinXPBar", false);
XPBar.pinnedSkill = getPropInt(props, "pinnedSkill", -1);

} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -1687,10 +1711,38 @@ public static void save(String preset) {
Integer.toString(getPropIntForKeyModifier(kbs)) + "*" + kbs.key);
}

// XP Goals
int usernameID = 0;
for (String username : Client.xpGoals.keySet()) {
for (int skill = 0; skill < Client.NUM_SKILLS; skill++) {
int skillgoal = 0;
try {
skillgoal = Client.xpGoals.get(username)[skill];
} catch (Exception noGoal) {}

float lvlgoal = (float)0;
try {
lvlgoal = Client.lvlGoals.get(username)[skill];
} catch (Exception noGoal) {}

props.setProperty(String.format("xpGoal%02d%03d", skill, usernameID),
Integer.toString(skillgoal));
props.setProperty(String.format("lvlGoal%02d%03d", skill, usernameID),
Float.toString(lvlgoal));
}
props.setProperty(String.format("username%d", usernameID), username);
usernameID++;
}
props.setProperty("numberOfGoalers", String.format("%d", usernameID));

props.setProperty("pinXPBar", Boolean.toString(XPBar.pinnedBar));
props.setProperty("pinnedSkill", String.format("%d", XPBar.pinnedSkill));

FileOutputStream out = new FileOutputStream(Dir.JAR + "/config.ini");
props.store(out, "---rscplus config---");
out.close();
} catch (Exception e) {
e.printStackTrace();
Logger.Error("Unable to save settings");
}
}
Expand Down
51 changes: 50 additions & 1 deletion src/Game/AccountManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public static void draw_change_pass_hook(int mouseX, int mouseY, int mouseButton
panelPasswordChangeMode = 3;
return;
}
} else {
} else if (panelPasswordChangeMode < 8){
if (panelPasswordChangeMode == 3) {
Renderer.drawStringCenter("Passwords do not match!", Renderer.width / 2, yPos, 4, 0xFFFFFF);
yPos += 25;
Expand Down Expand Up @@ -1068,6 +1068,55 @@ public static void draw_change_pass_hook(int mouseX, int mouseY, int mouseButton
"the same as your username", Renderer.width / 2, yPos, 4, 0xFFFFFF);
return;
}
} else {
// TODO: this is bad practice, but I'm putting XPBar code in this file
// so that I don't have to reimplement this input box.
// If we're going to do this, this entire method should be put in some other file, possibly its own class
if (panelPasswordChangeMode == 8) {
Hubcapp marked this conversation as resolved.
Show resolved Hide resolved
Renderer.drawStringCenter(
"Please enter your XP or level goal", Renderer.width / 2, yPos, 4, 0xFFFFFF);
yPos += 25;

Renderer.drawStringCenter(Client.modal_enteredText + "*", Renderer.width / 2, yPos, 4, 0xFFFFFF);
if (Client.modal_text.length() > 0) {
int goal = -1;
try {
goal = Integer.parseInt(Client.modal_text);
} catch (NumberFormatException e ) {
panelPasswordChangeMode = 9;
return;
}

Client.xpbar.setXpGoal(goal);
Client.modal_enteredText = "";
Client.modal_text = "";
panelPasswordChangeMode = 0;
return;
}

} else if (panelPasswordChangeMode == 9) {
Renderer.drawStringCenter(
"Numbers only, please", Renderer.width / 2, yPos, 4, 0xFFFFFF);
yPos += 25;

Renderer.drawStringCenter(Client.modal_enteredText + "*", Renderer.width / 2, yPos, 4, 0xFFFFFF);
if (Client.modal_text.length() > 0) {
int goal = -1;
try {
goal = Integer.parseInt(Client.modal_text);
} catch (NumberFormatException e ) {
panelPasswordChangeMode = 9;
return;
}

Client.xpbar.setXpGoal(goal);
Client.modal_enteredText = "";
Client.modal_text = "";
panelPasswordChangeMode = 0;
return;
}

}
}
}

Expand Down
Loading