Merge pull request #421 from deathbeam/low-memory

Add low memory mode flag
This commit is contained in:
Adam
2018-01-24 13:32:42 -05:00
committed by GitHub
5 changed files with 174 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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;
}
}

View File

@@ -0,0 +1,96 @@
/*
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
* 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());
}
}
}

View File

@@ -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)

View File

@@ -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);
}