diff --git a/runelite-api/src/main/java/net/runelite/api/Client.java b/runelite-api/src/main/java/net/runelite/api/Client.java index c96a8d360e..699ae802c8 100644 --- a/runelite-api/src/main/java/net/runelite/api/Client.java +++ b/runelite-api/src/main/java/net/runelite/api/Client.java @@ -239,4 +239,11 @@ public interface Client extends GameEngine int getMouseIdleTicks(); int getKeyboardIdleTicks(); -} + + /** + * Changes how game behaves based on memory mode. Low memory mode skips drawing of all floors and renders ground + * textures in low quality. + * @param lowMemory if we are running in low memory mode or not + */ + void changeMemoryMode(boolean lowMemory); +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryConfig.java new file mode 100644 index 0000000000..d3e6fd3d3f --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.lowmemory; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "lowmemory", + name = "Low Memory Mode", + description = "Configuration for the plugin for enabling and disabling RuneScape low memory mode" +) +public interface LowMemoryConfig extends Config +{ + @ConfigItem( + keyName = "enabled", + name = "Enabled", + description = "Configures whether or not low memory mode is enabled" + ) + default boolean enabled() + { + return false; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java new file mode 100644 index 0000000000..95709b5cd9 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018, Tomas Slusny + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package net.runelite.client.plugins.lowmemory; + +import com.google.common.eventbus.Subscribe; +import com.google.inject.Provides; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.events.ConfigChanged; +import net.runelite.api.events.GameStateChanged; +import net.runelite.api.events.SessionClose; +import net.runelite.api.events.SessionOpen; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; + +@PluginDescriptor(name = "Low memory plugin") +public class LowMemoryPlugin extends Plugin +{ + @Inject + Client client; + + @Inject + LowMemoryConfig config; + + @Provides + LowMemoryConfig provideConfig(ConfigManager configManager) + { + return configManager.getConfig(LowMemoryConfig.class); + } + + @Override + protected void startUp() throws Exception + { + client.changeMemoryMode(config.enabled()); + } + + @Override + protected void shutDown() throws Exception + { + client.changeMemoryMode(false); + } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("lowmemory")) + { + client.changeMemoryMode(config.enabled()); + } + } + + @Subscribe + private void onSessionOpen(SessionOpen event) + { + client.changeMemoryMode(config.enabled()); + } + + @Subscribe + private void onSessionClose(SessionClose event) + { + client.changeMemoryMode(config.enabled()); + } + + @Subscribe + private void onGameStateChanged(GameStateChanged event) + { + if (event.getGameState() == GameState.LOGIN_SCREEN) + { + client.changeMemoryMode(config.enabled()); + } + } +} \ No newline at end of file diff --git a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java index bc0b642336..7ecf4e9e67 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -396,6 +396,16 @@ public abstract class RSClientMixin implements RSClient } } + @Inject + @Override + public void changeMemoryMode(boolean lowMemory) + { + setLowMemory(lowMemory); + setRegionLowMemory(lowMemory); + setHighMemory(!lowMemory); + setOcLowDetail(lowMemory); + } + @FieldHook("skillExperiences") @Inject public static void experiencedChanged(int idx) diff --git a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java index bf3f5d04fa..7fce392ead 100644 --- a/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java +++ b/runescape-api/src/main/java/net/runelite/rs/api/RSClient.java @@ -420,4 +420,16 @@ public interface RSClient extends RSGameEngine, Client @Import("keyboardIdleTicks") @Override int getKeyboardIdleTicks(); -} + + @Import("lowMemory") + void setLowMemory(boolean lowMemory); + + @Import("regionLowMemory") + void setRegionLowMemory(boolean lowMemory); + + @Import("highMemory") + void setHighMemory(boolean highMemory); + + @Import("ocLowDetail") + void setOcLowDetail(boolean lowDetail); +} \ No newline at end of file