IaKee / RuneLingual-Plugin

All-in-one translation plugin for OSRS. Powered by RuneLite
BSD 2-Clause "Simplified" License
3 stars 4 forks source link

Add changing text contents within widget #4

Open BopOSRS opened 6 months ago

BopOSRS commented 6 months ago

stole this from meepspeak he's probably fine with it, i've not looked into it much yet and i don't know for sure what this does. but it works for example for NPC names in the collection log so should work elsewhere too might depend on how the text is being displayed in the widget

    private void RemapWidgetText(Widget component, String text, HashMap<String, String> map) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if (text.equalsIgnoreCase(entry.getKey())) {
                component.setText(text.replace(entry.getKey(), entry.getValue()));
                return;
            }
        }
    }

    private void RemapWidgetText(Widget component, String text, ImmutableMap<String, String> map) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            if (text.equalsIgnoreCase(entry.getKey())) {
                component.setText(text.replace(entry.getKey(), entry.getValue()));
                return;
            }
        }
    }
BopOSRS commented 6 months ago

image

This worked just fine. Commited my testing to my main-branch in my fork, it is just a basic replacement of "Rapid" in every widget to the norwegian equivalent as I'm not gonna make a wordlist manually (not right now at least)