Skip to content

Commit

Permalink
Wilderness combat level range display (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
conker-rsc authored Nov 5, 2023
1 parent 47211c1 commit 401b65f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
19 changes: 17 additions & 2 deletions src/Client/ConfigWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public class ConfigWindow {
private JCheckBox overlayPanelBuffsCheckbox;
private JCheckBox overlayPanelKeptItemsCheckbox;
private JCheckBox overlayPanelKeptItemsWildCheckbox;
private JCheckBox overlayPanelWildLevelRangeCheckbox;
private JCheckBox overlayPanelLastMenuActionCheckbox;
private JCheckBox overlayPanelMouseTooltipCheckbox;
private JCheckBox overlayPanelExtendedTooltipCheckbox;
Expand Down Expand Up @@ -2387,6 +2388,12 @@ public void actionPerformed(ActionEvent e) {
overlayPanelKeptItemsWildCheckbox.setToolTipText(
"Only displays the \"kept items\" skull when you are in the wilderness");

overlayPanelWildLevelRangeCheckbox =
addCheckbox("Show attackable level range while in the wilderness", overlayPanel);
overlayPanelWildLevelRangeCheckbox.setToolTipText(
"Displays the attackable combat level range above the wilderness level display");
SearchUtils.addSearchMetadata(overlayPanelWildLevelRangeCheckbox, CommonMetadata.PVP.getText());

overlayPanelLastMenuActionCheckbox = addCheckbox("Show last menu action display", overlayPanel);
overlayPanelLastMenuActionCheckbox.setToolTipText("Toggle last menu action used display");

Expand Down Expand Up @@ -2592,7 +2599,10 @@ public void actionPerformed(ActionEvent e) {
"Show attackable players' names in a separate colour", overlayPanelPvpNamesPanel);
overlayPanelPvpNamesCheckbox.setToolTipText(
"Changes the colour of players' names when they are within attacking range in the wilderness");
SearchUtils.addSearchMetadata(overlayPanelPvpNamesCheckbox, CommonMetadata.COLOUR.getText());
SearchUtils.addSearchMetadata(
overlayPanelPvpNamesCheckbox,
CommonMetadata.COLOUR.getText(),
CommonMetadata.PVP.getText());

overlayPanelPvpNamesColourSubpanel = new JPanel();
overlayPanelPvpNamesPanel.add(overlayPanelPvpNamesColourSubpanel);
Expand Down Expand Up @@ -5008,7 +5018,8 @@ private enum CommonMetadata {
SFX("sfx", "sound effects"),
FPS("fps", "frames per second"),
COLOUR("colour", "color"),
COLOURS("colours", "colors");
COLOURS("colours", "colors"),
PVP("pvp", "pk");

public final String text;

Expand Down Expand Up @@ -6042,6 +6053,8 @@ private void executeSynchronizeGuiValues() {
overlayPanelKeptItemsCheckbox.setSelected(Settings.DEATH_ITEMS.get(Settings.currentProfile));
overlayPanelKeptItemsWildCheckbox.setSelected(
Settings.DEATH_ITEMS_WILD.get(Settings.currentProfile));
overlayPanelWildLevelRangeCheckbox.setSelected(
Settings.SHOW_WILD_RANGE.get(Settings.currentProfile));
overlayPanelLastMenuActionCheckbox.setSelected(
Settings.SHOW_LAST_MENU_ACTION.get(Settings.currentProfile));
overlayPanelMouseTooltipCheckbox.setSelected(
Expand Down Expand Up @@ -6515,6 +6528,8 @@ private void saveSettings() {
Settings.DEATH_ITEMS.put(Settings.currentProfile, overlayPanelKeptItemsCheckbox.isSelected());
Settings.DEATH_ITEMS_WILD.put(
Settings.currentProfile, overlayPanelKeptItemsWildCheckbox.isSelected());
Settings.SHOW_WILD_RANGE.put(
Settings.currentProfile, overlayPanelWildLevelRangeCheckbox.isSelected());
Settings.SHOW_LAST_MENU_ACTION.put(
Settings.currentProfile, overlayPanelLastMenuActionCheckbox.isSelected());
Settings.SHOW_MOUSE_TOOLTIP.put(
Expand Down
12 changes: 11 additions & 1 deletion src/Client/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Properties;
Expand Down Expand Up @@ -226,6 +225,7 @@ public class Settings {
public static HashMap<String, Boolean> SHOW_BUFFS = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> DEATH_ITEMS = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> DEATH_ITEMS_WILD = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> SHOW_WILD_RANGE = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> SHOW_LAST_MENU_ACTION = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> SHOW_INVCOUNT = new HashMap<String, Boolean>();
public static HashMap<String, Boolean> SHOW_INVCOUNT_COLOURS = new HashMap<String, Boolean>();
Expand Down Expand Up @@ -1579,6 +1579,15 @@ public static void definePresets(Properties props) {
DEATH_ITEMS_WILD.put(
"custom", getPropBoolean(props, "death_items_wild", DEATH_ITEMS_WILD.get("default")));

SHOW_WILD_RANGE.put("vanilla", false);
SHOW_WILD_RANGE.put("vanilla_resizable", false);
SHOW_WILD_RANGE.put("lite", false);
SHOW_WILD_RANGE.put("default", false);
SHOW_WILD_RANGE.put("heavy", true);
SHOW_WILD_RANGE.put("all", true);
SHOW_WILD_RANGE.put(
"custom", getPropBoolean(props, "show_wild_range", SHOW_WILD_RANGE.get("default")));

SHOW_LAST_MENU_ACTION.put("vanilla", false);
SHOW_LAST_MENU_ACTION.put("vanilla_resizable", false);
SHOW_LAST_MENU_ACTION.put("lite", false);
Expand Down Expand Up @@ -3362,6 +3371,7 @@ public static void save(String preset) {
props.setProperty("show_buffs", Boolean.toString(SHOW_BUFFS.get(preset)));
props.setProperty("death_items", Boolean.toString(DEATH_ITEMS.get(preset)));
props.setProperty("death_items_wild", Boolean.toString(DEATH_ITEMS_WILD.get(preset)));
props.setProperty("show_wild_range", Boolean.toString(SHOW_WILD_RANGE.get(preset)));
props.setProperty(
"show_last_menu_action", Boolean.toString(SHOW_LAST_MENU_ACTION.get(preset)));
props.setProperty("show_mouse_tooltip", Boolean.toString(SHOW_MOUSE_TOOLTIP.get(preset)));
Expand Down
12 changes: 11 additions & 1 deletion src/Game/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -2571,9 +2571,19 @@ public static void checkForUpdate(boolean announceIfUpToDate) {
}
}

// hook to display retro fps on the client, early 2001 style
// hook to draw native text on every frame tick
public static void drawNativeTextHook(Object surfaceInstance) {
if (surfaceInstance != null) {
if (Settings.SHOW_WILD_RANGE.get(Settings.currentProfile) && Client.is_in_wild) {
int lowRange = Math.max((Client.getPlayerLevel() - Client.wild_level), 3);
int highRange = Math.min(Client.wild_level + Client.getPlayerLevel(), 123);
String wildernessRange = "(" + lowRange + " - " + highRange + ")";

Renderer.drawStringCenter(
wildernessRange, Renderer.width - 47, Renderer.height_client - 60, 1, 0xffff00);
}

// display retro fps on the client, early 2001 style
if (Settings.SHOW_RETRO_FPS.get(Settings.currentProfile)) {
int offset = 0;
if (Client.is_in_wild) offset = 70;
Expand Down
5 changes: 3 additions & 2 deletions src/Game/SpecialStar.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static void initializeSpecialStars() throws IOException {
g.dispose();

starGlimmerMask = new short[12][11];
try (InputStream inputStream = Launcher.getResource("/assets/starGlimmerMask.dat").openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
try (InputStream inputStream =
Launcher.getResource("/assets/starGlimmerMask.dat").openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) {
String line;
int row = 0;
while ((line = br.readLine()) != null) {
Expand Down

0 comments on commit 401b65f

Please sign in to comment.