Toggle confirmation on exit (#3834)

Adds configurable option for when warning on exit will show

Closes #910 and closes #1594
This commit is contained in:
Matthew Smith
2018-06-17 12:58:36 +01:00
committed by Tomas Slusny
parent b6056e4f0e
commit 020c03682c
3 changed files with 74 additions and 1 deletions

View File

@@ -112,6 +112,17 @@ public interface RuneLiteConfig extends Config
return false;
}
@ConfigItem(
keyName = "warningOnExit",
name = "Display warning on exit",
description = "Toggles a warning popup when trying to exit the client",
position = 17
)
default WarningOnExit warningOnExit()
{
return WarningOnExit.LOGGED_IN;
}
@ConfigItem(
keyName = "notificationTray",
name = "Enable tray notifications",

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2018, Matt <https://github.com/ms813>
* 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.config;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@Getter
@RequiredArgsConstructor
public enum WarningOnExit
{
ALWAYS("Always"),
LOGGED_IN("Logged in"),
NEVER("Never");
private final String type;
@Override
public String toString()
{
return type;
}
}

View File

@@ -64,6 +64,7 @@ import net.runelite.client.RuneLiteProperties;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.ExpandResizeType;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.config.WarningOnExit;
import net.runelite.client.events.ClientUILoaded;
import net.runelite.client.events.PluginToolbarButtonAdded;
import net.runelite.client.events.PluginToolbarButtonRemoved;
@@ -372,7 +373,8 @@ public class ClientUI
},
() -> client != null
&& client instanceof Client
&& ((Client) client).getGameState() != GameState.LOGIN_SCREEN);
&& showWarningOnExit()
);
container = new JPanel();
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
@@ -399,6 +401,21 @@ public class ClientUI
});
}
private boolean showWarningOnExit()
{
if (config.warningOnExit() == WarningOnExit.ALWAYS)
{
return true;
}
if (config.warningOnExit() == WarningOnExit.LOGGED_IN)
{
return ((Client) client).getGameState() != GameState.LOGIN_SCREEN;
}
return false;
}
/**
* Show client UI after everything else is done.
*