From 8de4d585c37b88374806b084ab577e2eff49491e Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 2 May 2021 15:02:44 +0000 Subject: [PATCH] Configuration for dark themed GUI. --- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../LimitLinesDocumentListener.java | 2 +- .../l2jmobius/commons/ui}/SplashScreen.java | 2 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui}/LimitLinesDocumentListener.java | 2 +- .../l2jmobius/commons/ui}/SplashScreen.java | 2 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui}/LimitLinesDocumentListener.java | 2 +- .../l2jmobius/commons/ui}/SplashScreen.java | 2 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../LimitLinesDocumentListener.java | 2 +- .../l2jmobius/commons/ui}/SplashScreen.java | 2 +- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/config/server.ini | 19 +- .../java/org/l2jmobius/Config.java | 5 +- .../java/org/l2jmobius/Server.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 8 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../java/org/l2jmobius/util/DarkTheme.java | 57 ++++++ .../dist/game/config/main/Server.ini | 17 ++ .../dist/login/config/main/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 12 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/main/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- .../dist/game/config/Server.ini | 17 ++ .../dist/login/config/LoginServer.ini | 17 ++ .../java/org/l2jmobius/Config.java | 6 +- .../org/l2jmobius/commons/ui/DarkTheme.java | 57 ++++++ .../ui/LimitLinesDocumentListener.java | 163 ++++++++++++++++++ .../l2jmobius/commons/ui/SplashScreen.java | 78 +++++++++ .../util/LimitLinesDocumentListener.java | 163 ------------------ .../l2jmobius/commons/util/SplashScreen.java | 78 --------- .../org/l2jmobius/gameserver/GameServer.java | 6 +- .../java/org/l2jmobius/gameserver/ui/Gui.java | 12 +- .../l2jmobius/gameserver/ui/SystemPanel.java | 6 +- .../l2jmobius/loginserver/LoginServer.java | 6 +- .../org/l2jmobius/loginserver/ui/Gui.java | 13 +- .../tools/dbinstaller/gui/DBConfigGUI.java | 2 +- 320 files changed, 7672 insertions(+), 4868 deletions(-) create mode 100644 L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/DarkTheme.java rename L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/{util => ui}/LimitLinesDocumentListener.java (95%) rename {L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util => L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui}/SplashScreen.java (94%) create mode 100644 L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/DarkTheme.java rename {L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util => L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui}/LimitLinesDocumentListener.java (95%) rename {L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util => L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui}/SplashScreen.java (94%) create mode 100644 L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/DarkTheme.java rename {L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util => L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui}/LimitLinesDocumentListener.java (95%) rename {L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util => L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui}/SplashScreen.java (94%) create mode 100644 L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/DarkTheme.java rename L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/{util => ui}/LimitLinesDocumentListener.java (95%) rename {L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util => L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui}/SplashScreen.java (94%) create mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/util/DarkTheme.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/SplashScreen.java create mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/DarkTheme.java create mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java create mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/SplashScreen.java delete mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java delete mode 100644 L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/SplashScreen.java diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini index b174b854e7..b1c2fcf580 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_1.0_Ertheia/dist/login/config/LoginServer.ini b/L2J_Mobius_1.0_Ertheia/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_1.0_Ertheia/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java index b8540bc8f3..e6bf619d07 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/Config.java @@ -96,11 +96,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -444,6 +444,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java similarity index 95% rename from L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java rename to L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java index 7b9f2eb217..0185c2a02a 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/SplashScreen.java similarity index 94% rename from L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/SplashScreen.java rename to L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/SplashScreen.java index 7b492e9a52..7902b3d9dd 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/SplashScreen.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import java.awt.Color; import java.awt.Frame; diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java index 1286683d01..9069a6128f 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -181,8 +182,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini index 81047aa753..5c581aff36 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini +++ b/L2J_Mobius_2.5_Underground/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_2.5_Underground/dist/login/config/LoginServer.ini b/L2J_Mobius_2.5_Underground/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_2.5_Underground/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_2.5_Underground/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java index 794dc56608..f6072013b6 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -451,6 +451,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java similarity index 95% rename from L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java rename to L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java index 7b9f2eb217..0185c2a02a 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/SplashScreen.java similarity index 94% rename from L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/SplashScreen.java rename to L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/SplashScreen.java index 7b492e9a52..7902b3d9dd 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/commons/util/SplashScreen.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import java.awt.Color; import java.awt.Frame; diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java index 3fbe72d0ba..c4fd6601eb 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -185,8 +186,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini index f5c23c6087..45325696e8 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini +++ b/L2J_Mobius_3.0_Helios/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_3.0_Helios/dist/login/config/LoginServer.ini b/L2J_Mobius_3.0_Helios/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_3.0_Helios/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_3.0_Helios/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java index e107c72ac1..f0318e9f68 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -451,6 +451,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java similarity index 95% rename from L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java rename to L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java index 7b9f2eb217..0185c2a02a 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/SplashScreen.java similarity index 94% rename from L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/SplashScreen.java rename to L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/SplashScreen.java index 7b492e9a52..7902b3d9dd 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/SplashScreen.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import java.awt.Color; import java.awt.Frame; diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java index 3fbe72d0ba..c4fd6601eb 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -185,8 +186,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini index bab2b45d5b..788a02b559 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/login/config/LoginServer.ini b/L2J_Mobius_4.0_GrandCrusade/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_4.0_GrandCrusade/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java index 7700553d55..e150274253 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -445,6 +445,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java similarity index 95% rename from L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java rename to L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java index 7b9f2eb217..0185c2a02a 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import javax.swing.SwingUtilities; import javax.swing.event.DocumentEvent; diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/SplashScreen.java similarity index 94% rename from L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/SplashScreen.java rename to L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/SplashScreen.java index 7b492e9a52..7902b3d9dd 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/commons/util/SplashScreen.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.l2jmobius.commons.util; +package org.l2jmobius.commons.ui; import java.awt.Color; import java.awt.Frame; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java index 1d95113991..36acbe8fa5 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -185,8 +186,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini index d923afe204..c5d2227463 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini +++ b/L2J_Mobius_5.0_Salvation/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_5.0_Salvation/dist/login/config/LoginServer.ini b/L2J_Mobius_5.0_Salvation/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_5.0_Salvation/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_5.0_Salvation/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java index ff1dc10fa3..b0cd0c3fe5 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -440,6 +440,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java index 3b8d267c1e..1e2987690d 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -187,8 +188,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini index 343dd520b1..2ff3e3ef36 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_5.5_EtinasFate/dist/login/config/LoginServer.ini b/L2J_Mobius_5.5_EtinasFate/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_5.5_EtinasFate/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java index 99082967f3..6779fb8b89 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -440,6 +440,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java index 3b8d267c1e..1e2987690d 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -187,8 +188,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini index 4e21050262..ea6528aaf1 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_6.0_Fafurion/dist/login/config/LoginServer.ini b/L2J_Mobius_6.0_Fafurion/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_6.0_Fafurion/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java index b0bf7da550..651be3dc35 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -441,6 +441,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java index 9f6d2fc00f..341aa3d4ec 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -188,8 +189,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini index b739db22c0..4bdc6d633b 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_7.0_PreludeOfWar/dist/login/config/LoginServer.ini b/L2J_Mobius_7.0_PreludeOfWar/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_7.0_PreludeOfWar/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java index d314f72d80..90b60a4b82 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -440,6 +440,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java index 1b7c71a955..a4da6f9025 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -191,8 +192,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_8.0_Homunculus/dist/game/config/Server.ini b/L2J_Mobius_8.0_Homunculus/dist/game/config/Server.ini index d564479ff8..85353a2ae2 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/game/config/Server.ini +++ b/L2J_Mobius_8.0_Homunculus/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_8.0_Homunculus/dist/login/config/LoginServer.ini b/L2J_Mobius_8.0_Homunculus/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_8.0_Homunculus/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_8.0_Homunculus/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java index 58d8bbe7a6..19da2ca7ba 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -440,6 +440,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java index dfcf1d9df9..487185a8f7 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -190,8 +191,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/Server.ini b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/Server.ini index da30ee05e1..0e649c20ea 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/Server.ini +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/login/config/LoginServer.ini b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/login/config/LoginServer.ini index 4841207266..2359b2b2b3 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java index 58d8bbe7a6..19da2ca7ba 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -440,6 +440,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java index dfcf1d9df9..487185a8f7 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -190,8 +191,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_9.0_ReturnOfTheQueenAnt/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_C1_HarbingersOfWar/dist/config/server.ini b/L2J_Mobius_C1_HarbingersOfWar/dist/config/server.ini index ca2083039f..fb149dd915 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/dist/config/server.ini +++ b/L2J_Mobius_C1_HarbingersOfWar/dist/config/server.ini @@ -32,4 +32,21 @@ MaximumOnlineUsers=2000 AutoCreateAccounts=true # Enable unknown packet logging. -LogUnknownPackets=false \ No newline at end of file +LogUnknownPackets=false + + +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java index c67072a797..bc22cd3959 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Config.java @@ -36,7 +36,7 @@ public class Config // -------------------------------------------------- // Config File Definitions // -------------------------------------------------- - private static final String SERVER_CONFIG_FILE = "config/server.ini"; + public static final String SERVER_CONFIG_FILE = "config/server.ini"; private static final String RATES_CONFIG_FILE = "config/rates.ini"; private static final String KARMA_CONFIG_FILE = "config/karma.ini"; private static final String THREADPOOL_CONFIG_FILE = "config/threadpool.ini"; @@ -54,6 +54,9 @@ public class Config public static boolean AUTO_CREATE_ACCOUNTS; // Other public static boolean LOG_UNKNOWN_PACKETS; + // GUI + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; // Rates public static float RATE_XP; public static float RATE_SP; diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Server.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Server.java index f0156ffda0..90bdc32a36 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Server.java +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/Server.java @@ -26,6 +26,7 @@ import java.util.logging.LogManager; import org.l2jmobius.gameserver.GameServer; import org.l2jmobius.gameserver.ui.Gui; import org.l2jmobius.loginserver.LoginServer; +import org.l2jmobius.util.PropertiesParser; public class Server { @@ -45,8 +46,11 @@ public class Server Config.load(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("Server: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/Gui.java index d7edc0aebd..003cc779c4 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/Gui.java @@ -47,6 +47,7 @@ import javax.swing.WindowConstants; import org.l2jmobius.Config; import org.l2jmobius.gameserver.AdminCommands; +import org.l2jmobius.util.DarkTheme; import org.l2jmobius.util.LimitLinesDocumentListener; import org.l2jmobius.util.SplashScreen; import org.l2jmobius.util.Util; @@ -81,6 +82,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -225,7 +231,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java index 9314d572f3..63d0726f3d 100644 --- a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -48,7 +48,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 121); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/util/DarkTheme.java b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/util/DarkTheme.java new file mode 100644 index 0000000000..0f79df19be --- /dev/null +++ b/L2J_Mobius_C1_HarbingersOfWar/java/org/l2jmobius/util/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.util; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/Server.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/Server.ini index 01c5d54dfd..06fdfb4bc8 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/Server.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/game/config/main/Server.ini @@ -134,6 +134,23 @@ InstantThreadPoolCount = 120 UrgentPacketThreadCoreSize = 40 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Misc Player Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini b/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini index 237bafbfb0..c9ff70e345 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini +++ b/L2J_Mobius_C4_ScionsOfDestiny/dist/login/config/main/LoginServer.ini @@ -60,6 +60,23 @@ Password = MaximumDbConnections = 10 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java index 39c5ab92de..cbb6f9e65d 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/Config.java @@ -74,7 +74,7 @@ public class Config private static final String PVP_CONFIG_FILE = "./config/main/PvP.ini"; private static final String RAIDBOSS_CONFIG_FILE = "./config/main/RaidBoss.ini"; private static final String RATES_CONFIG_FILE = "./config/main/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/main/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/main/Server.ini"; private static final String SEVENSIGNS_CONFIG_FILE = "./config/main/SevenSigns.ini"; public static final String SIEGE_CONFIG_FILE = "./config/main/Siege.ini"; // protected @@ -102,7 +102,7 @@ public class Config private static final String EVENT_REBIRTH_CONFIG_FILE = "./config/custom/Rebirth.ini"; private static final String EVENT_WEDDING_CONFIG_FILE = "./config/custom/Wedding.ini"; // login - private static final String LOGIN_CONFIG_FILE = "./config/main/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/main/LoginServer.ini"; // others private static final String BANNED_IP_FILE = "./config/others/banned_ip.cfg"; public static final String SERVER_NAME_FILE = "./config/others/servername.xml"; @@ -1128,6 +1128,8 @@ public class Config public static int SCHEDULED_THREAD_POOL_COUNT; public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static String CNAME_TEMPLATE; public static String PET_NAME_TEMPLATE; public static String CLAN_NAME_TEMPLATE; diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java index 54a4eb39ad..460275cac5 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/GameServer.java @@ -31,6 +31,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadlockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.commons.util.Util; import org.l2jmobius.gameserver.cache.CrestCache; import org.l2jmobius.gameserver.cache.HtmCache; @@ -147,8 +148,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/Gui.java index 6753ba533e..3d120c9192 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.MultisellData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -301,7 +307,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/SystemPanel.java index c72c87653e..577f4885c9 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java index 5e4a35d6d3..16b3f125c5 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/LoginServer.java @@ -38,6 +38,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.loginserver.network.AbstractClientPacket; import org.l2jmobius.loginserver.network.LoginClient; import org.l2jmobius.loginserver.ui.Gui; @@ -62,8 +63,11 @@ public class LoginServer extends FloodProtectedListener public static void main(String[] args) { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/ui/Gui.java index 8002a7be63..1a7c8a0f0f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/loginserver/ui/Gui.java @@ -44,8 +44,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServer; import org.l2jmobius.loginserver.LoginController; @@ -76,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -247,7 +253,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_C6_Interlude/dist/game/config/main/Server.ini b/L2J_Mobius_C6_Interlude/dist/game/config/main/Server.ini index 48509a7f02..4dc22ce89b 100644 --- a/L2J_Mobius_C6_Interlude/dist/game/config/main/Server.ini +++ b/L2J_Mobius_C6_Interlude/dist/game/config/main/Server.ini @@ -130,6 +130,23 @@ InstantThreadPoolCount = 120 UrgentPacketThreadCoreSize = 40 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Misc Player Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_C6_Interlude/dist/login/config/LoginServer.ini b/L2J_Mobius_C6_Interlude/dist/login/config/LoginServer.ini index eddcfed49a..5f9cf9997e 100644 --- a/L2J_Mobius_C6_Interlude/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_C6_Interlude/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java index f5e1c4f291..c58976b5e8 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/Config.java @@ -85,7 +85,7 @@ public class Config private static final String PVP_CONFIG_FILE = "./config/main/PvP.ini"; private static final String RAIDBOSS_CONFIG_FILE = "./config/main/RaidBoss.ini"; private static final String RATES_CONFIG_FILE = "./config/main/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/main/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/main/Server.ini"; private static final String SEVENSIGNS_CONFIG_FILE = "./config/main/SevenSigns.ini"; public static final String SIEGE_CONFIG_FILE = "./config/main/Siege.ini"; // protected @@ -113,7 +113,7 @@ public class Config private static final String EVENT_REBIRTH_CONFIG_FILE = "./config/custom/Rebirth.ini"; private static final String EVENT_WEDDING_CONFIG_FILE = "./config/custom/Wedding.ini"; // login - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; // -------------------------------------------------- // Variable Definitions @@ -1167,6 +1167,8 @@ public class Config public static int SCHEDULED_THREAD_POOL_COUNT; public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static String CNAME_TEMPLATE; public static String PET_NAME_TEMPLATE; public static String CLAN_NAME_TEMPLATE; diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java index 9639d41fd4..de3541b023 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/GameServer.java @@ -31,6 +31,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadlockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.commons.util.Util; import org.l2jmobius.gameserver.cache.CrestCache; import org.l2jmobius.gameserver.cache.HtmCache; @@ -151,8 +152,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java index 6753ba533e..3d120c9192 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.MultisellData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -301,7 +307,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java index c72c87653e..577f4885c9 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java index 591e958bea..60d7b20534 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini index 28f5b33d5f..81f18c7d54 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_CT_2.4_Epilogue/dist/login/config/LoginServer.ini b/L2J_Mobius_CT_2.4_Epilogue/dist/login/config/LoginServer.ini index 43cdcdc509..9ad5239b10 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_CT_2.4_Epilogue/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java index c5458f04ee..968462fd26 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/Config.java @@ -95,11 +95,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; private static final String HEXID_FILE = "./config/hexid.txt"; @@ -506,6 +506,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java index 0ac23b6eeb..ff343ae6c1 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.AugmentationData; import org.l2jmobius.gameserver.data.BotReportTable; @@ -181,8 +182,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/SystemPanel.java index ba4c0427f7..8627f6b73b 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini index 5f4e106e11..cbf4449941 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/login/config/LoginServer.ini b/L2J_Mobius_CT_2.6_HighFive/dist/login/config/LoginServer.ini index 65b4c65afa..d1cdd87b50 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_CT_2.6_HighFive/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java index 0de24c6906..e86d8ae8fb 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java @@ -95,11 +95,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; private static final String HEXID_FILE = "./config/hexid.txt"; @@ -511,6 +511,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java index 60f12f2847..53aa1d969f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.AugmentationData; import org.l2jmobius.gameserver.data.BotReportTable; @@ -182,8 +183,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/SystemPanel.java index ba4c0427f7..8627f6b73b 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini index 39b5db82f8..87fda974c6 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_2.0_Saviors/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java index 42a6513a0a..30c323a046 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java index a806a7a2cf..e5baab79ce 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -184,8 +185,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini index f31dd638ff..97976a0f0e 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_2.1_Zaken/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java index 5ad193bde5..7826924295 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java index a806a7a2cf..e5baab79ce 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -184,8 +185,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini index fd19902600..6d08ed56ac 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_2.2_Antharas/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java index 5ad193bde5..7826924295 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java index 40ffe207c0..224916a41e 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -185,8 +186,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini index a07c6414bb..d4484f6fb0 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_2.3_SevenSigns/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java index 7524966270..87122f6345 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java index 62b725f796..90d8c9fb4e 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -186,8 +187,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini index 29958b5736..3ca98d49f8 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java index b79e592c45..f78b02bed2 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java index f608f8cdeb..2d0d739f2c 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -187,8 +188,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini index 4ce8c2859d..c2891468fd 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_3.0_TheKamael/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_3.0_TheKamael/dist/login/config/LoginServer.ini index 7ce0641617..5dc32c62d9 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_3.0_TheKamael/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java index ad3825e01c..0ec617ba55 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -465,6 +465,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java index 85caf8a9e3..8ad135a147 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -190,8 +191,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini index 3253273fed..51cddc17f5 100644 --- a/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini +++ b/L2J_Mobius_Classic_Interlude/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_Interlude/dist/login/config/LoginServer.ini b/L2J_Mobius_Classic_Interlude/dist/login/config/LoginServer.ini index a1627e5d7d..6c1e444403 100644 --- a/L2J_Mobius_Classic_Interlude/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Classic_Interlude/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java index 51e71ade13..df7b54965a 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/Config.java @@ -98,11 +98,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -466,6 +466,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java index e7c3991df1..991eb093ee 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -182,8 +183,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java index 29db364957..eefe142e0a 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -85,6 +86,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -323,7 +329,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java index a19a873bfe..d7c147f4be 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/Server.ini b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/Server.ini index c520efa6c4..f45328337e 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/Server.ini +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/login/config/LoginServer.ini b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/login/config/LoginServer.ini index 0b1653ba1a..cb96e9368f 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java index 20e99e426a..63d4e21e0e 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -467,6 +467,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java index f36c6b92b3..c15c91445e 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -194,8 +195,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/SystemPanel.java index 0e0e24b7da..21e417bf00 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities; diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/Server.ini b/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/Server.ini index 4c0973b3b9..98b8d62253 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/Server.ini +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/game/config/Server.ini @@ -142,6 +142,23 @@ UrgentPacketThreadCoreSize = 40 ThreadsForLoading = False +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Dead Lock Detector (separate thread for detecting deadlocks) # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Essence_5.0_Sylph/dist/login/config/LoginServer.ini b/L2J_Mobius_Essence_5.0_Sylph/dist/login/config/LoginServer.ini index 0b1653ba1a..cb96e9368f 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/dist/login/config/LoginServer.ini +++ b/L2J_Mobius_Essence_5.0_Sylph/dist/login/config/LoginServer.ini @@ -54,6 +54,23 @@ Password = MaximumDbConnections = 5 +# --------------------------------------------------------------------------- +# Look and feel +# --------------------------------------------------------------------------- + +# Enable L2jMobius GUI when OS supports it. +# Provides access to admin commands without the need to be online. +# Warning! Do not disable if you use Gameserver.exe +# because server will run in the background! +# Default: True +EnableGUI = True + +# Dark theme. +# Use a dark version of the Nimbus theme. +# Default: True +DarkTheme = True + + # --------------------------------------------------------------------------- # Automatic Database Backup Settings # --------------------------------------------------------------------------- diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java index 548d226ecf..1e10d28647 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/Config.java @@ -97,11 +97,11 @@ public class Config private static final String GENERAL_CONFIG_FILE = "./config/General.ini"; private static final String GRACIASEEDS_CONFIG_FILE = "./config/GraciaSeeds.ini"; private static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini"; - private static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; + public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini"; private static final String NPC_CONFIG_FILE = "./config/NPC.ini"; private static final String PVP_CONFIG_FILE = "./config/PVP.ini"; private static final String RATES_CONFIG_FILE = "./config/Rates.ini"; - private static final String SERVER_CONFIG_FILE = "./config/Server.ini"; + public static final String SERVER_CONFIG_FILE = "./config/Server.ini"; private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini"; private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini"; private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt"; @@ -467,6 +467,8 @@ public class Config public static int INSTANT_THREAD_POOL_COUNT; public static int IO_PACKET_THREAD_CORE_SIZE; public static boolean THREADS_FOR_LOADING; + public static boolean ENABLE_GUI; + public static boolean DARK_THEME; public static boolean DEADLOCK_DETECTOR; public static int DEADLOCK_CHECK_INTERVAL; public static boolean RESTART_ON_DEADLOCK; diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/DarkTheme.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/DarkTheme.java new file mode 100644 index 0000000000..0545c2dc6a --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/DarkTheme.java @@ -0,0 +1,57 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; + +import javax.swing.UIManager; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; + +/** + * @author Mobius + */ +public class DarkTheme +{ + public static void activate() + { + // Modify existing white Nimbus look and feel to dark. + UIManager.put("control", new Color(128, 128, 128)); + UIManager.put("info", new Color(128, 128, 128)); + UIManager.put("nimbusBase", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusAlertYellow", new Color(248, 187, 0)); + UIManager.put("nimbusDisabledText", new Color(128, 128, 128)); + UIManager.put("nimbusFocus", Color.DARK_GRAY); // new Color(115, 164, 209) + UIManager.put("nimbusGreen", new Color(176, 179, 50)); + UIManager.put("nimbusInfoBlue", Color.DARK_GRAY); // new Color(66, 139, 221) + UIManager.put("nimbusLightBackground", Color.DARK_GRAY); // new Color(18, 30, 49) + UIManager.put("nimbusOrange", new Color(191, 98, 4)); + UIManager.put("nimbusRed", new Color(169, 46, 34)); + UIManager.put("nimbusSelectedText", new Color(255, 255, 255)); + UIManager.put("nimbusSelectionBackground", new Color(104, 93, 156)); + UIManager.put("text", new Color(230, 230, 230)); + + // Set look and feel. + try + { + UIManager.setLookAndFeel(new NimbusLookAndFeel()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java new file mode 100644 index 0000000000..0185c2a02a --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/LimitLinesDocumentListener.java @@ -0,0 +1,163 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.Element; + +/* + * A class to control the maximum number of lines to be stored in a Document + * + * Excess lines can be removed from the start or end of the Document + * depending on your requirement. + * + * a) if you append text to the Document, then you would want to remove lines + * from the start. + * b) if you insert text at the beginning of the Document, then you would + * want to remove lines from the end. + */ +public class LimitLinesDocumentListener implements DocumentListener +{ + private int _maximumLines; + private final boolean _isRemoveFromStart; + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. + */ + public LimitLinesDocumentListener(int maximumLines) + { + this(maximumLines, true); + } + + /* + * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. + */ + public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) + { + setLimitLines(maximumLines); + _isRemoveFromStart = isRemoveFromStart; + } + + /* + * Return the maximum number of lines to be stored in the Document. + */ + public int getLimitLines() + { + return _maximumLines; + } + + /* + * Set the maximum number of lines to be stored in the Document. + */ + public void setLimitLines(int maximumLines) + { + if (maximumLines < 1) + { + final String message = "Maximum lines must be greater than 0"; + throw new IllegalArgumentException(message); + } + + _maximumLines = maximumLines; + } + + /* + * Handle insertion of new text into the Document. + */ + @Override + public void insertUpdate(DocumentEvent e) + { + // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. + SwingUtilities.invokeLater(() -> removeLines(e)); + } + + @Override + public void removeUpdate(DocumentEvent e) + { + // Ignore. + } + + @Override + public void changedUpdate(DocumentEvent e) + { + // Ignore. + } + + /* + * Remove lines from the Document when necessary. + */ + private void removeLines(DocumentEvent e) + { + // The root Element of the Document will tell us the total number of line in the Document. + final Document document = e.getDocument(); + final Element root = document.getDefaultRootElement(); + + while (root.getElementCount() > _maximumLines) + { + if (_isRemoveFromStart) + { + removeFromStart(document, root); + } + else + { + removeFromEnd(document, root); + } + } + } + + /* + * Remove lines from the start of the Document + */ + private void removeFromStart(Document document, Element root) + { + final Element line = root.getElement(0); + final int end = line.getEndOffset(); + + try + { + document.remove(0, end); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } + + /* + * Remove lines from the end of the Document + */ + private void removeFromEnd(Document document, Element root) + { + // We use start minus 1 to make sure we remove the newline character of the previous line. + + final Element line = root.getElement(root.getElementCount() - 1); + final int start = line.getStartOffset(); + final int end = line.getEndOffset(); + + try + { + document.remove(start - 1, end - start); + } + catch (BadLocationException ble) + { + System.out.println(ble); + } + } +} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/SplashScreen.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/SplashScreen.java new file mode 100644 index 0000000000..7902b3d9dd --- /dev/null +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/ui/SplashScreen.java @@ -0,0 +1,78 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.l2jmobius.commons.ui; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Toolkit; +import java.util.Timer; +import java.util.TimerTask; + +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JWindow; + +/** + * @author Mobius + */ +public class SplashScreen extends JWindow +{ + Image image; + + /** + * @param path of image file + * @param time in milliseconds + * @param parent frame to set visible after time ends + */ + public SplashScreen(String path, long time, JFrame parent) + { + setBackground(new Color(0, 255, 0, 0)); // Transparency. + image = Toolkit.getDefaultToolkit().getImage(path); + final ImageIcon imageIcon = new ImageIcon(image); + setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + new Timer().schedule(new TimerTask() + { + @Override + public void run() + { + setVisible(false); + if (parent != null) + { + // Make parent visible. + parent.setVisible(true); + // Focus parent window. + parent.toFront(); + parent.setState(Frame.ICONIFIED); + parent.setState(Frame.NORMAL); + } + dispose(); + } + }, imageIcon.getIconWidth() > 0 ? time : 100); + } + + @Override + public void paint(Graphics g) + { + g.drawImage(image, 0, 0, null); + } +} diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java deleted file mode 100644 index 7b9f2eb217..0000000000 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/LimitLinesDocumentListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Element; - -/* - * A class to control the maximum number of lines to be stored in a Document - * - * Excess lines can be removed from the start or end of the Document - * depending on your requirement. - * - * a) if you append text to the Document, then you would want to remove lines - * from the start. - * b) if you insert text at the beginning of the Document, then you would - * want to remove lines from the end. - */ -public class LimitLinesDocumentListener implements DocumentListener -{ - private int _maximumLines; - private final boolean _isRemoveFromStart; - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of the Document. - */ - public LimitLinesDocumentListener(int maximumLines) - { - this(maximumLines, true); - } - - /* - * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or end of the Document, depending on the boolean value specified. - */ - public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) - { - setLimitLines(maximumLines); - _isRemoveFromStart = isRemoveFromStart; - } - - /* - * Return the maximum number of lines to be stored in the Document. - */ - public int getLimitLines() - { - return _maximumLines; - } - - /* - * Set the maximum number of lines to be stored in the Document. - */ - public void setLimitLines(int maximumLines) - { - if (maximumLines < 1) - { - final String message = "Maximum lines must be greater than 0"; - throw new IllegalArgumentException(message); - } - - _maximumLines = maximumLines; - } - - /* - * Handle insertion of new text into the Document. - */ - @Override - public void insertUpdate(DocumentEvent e) - { - // Changes to the Document can not be done within the listener so we need to add the processing to the end of the EDT. - SwingUtilities.invokeLater(() -> removeLines(e)); - } - - @Override - public void removeUpdate(DocumentEvent e) - { - // Ignore. - } - - @Override - public void changedUpdate(DocumentEvent e) - { - // Ignore. - } - - /* - * Remove lines from the Document when necessary. - */ - private void removeLines(DocumentEvent e) - { - // The root Element of the Document will tell us the total number of line in the Document. - final Document document = e.getDocument(); - final Element root = document.getDefaultRootElement(); - - while (root.getElementCount() > _maximumLines) - { - if (_isRemoveFromStart) - { - removeFromStart(document, root); - } - else - { - removeFromEnd(document, root); - } - } - } - - /* - * Remove lines from the start of the Document - */ - private void removeFromStart(Document document, Element root) - { - final Element line = root.getElement(0); - final int end = line.getEndOffset(); - - try - { - document.remove(0, end); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } - - /* - * Remove lines from the end of the Document - */ - private void removeFromEnd(Document document, Element root) - { - // We use start minus 1 to make sure we remove the newline character of the previous line. - - final Element line = root.getElement(root.getElementCount() - 1); - final int start = line.getStartOffset(); - final int end = line.getEndOffset(); - - try - { - document.remove(start - 1, end - start); - } - catch (BadLocationException ble) - { - System.out.println(ble); - } - } -} \ No newline at end of file diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/SplashScreen.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/SplashScreen.java deleted file mode 100644 index 7b492e9a52..0000000000 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/commons/util/SplashScreen.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.l2jmobius.commons.util; - -import java.awt.Color; -import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Toolkit; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JWindow; - -/** - * @author Mobius - */ -public class SplashScreen extends JWindow -{ - Image image; - - /** - * @param path of image file - * @param time in milliseconds - * @param parent frame to set visible after time ends - */ - public SplashScreen(String path, long time, JFrame parent) - { - setBackground(new Color(0, 255, 0, 0)); // Transparency. - image = Toolkit.getDefaultToolkit().getImage(path); - final ImageIcon imageIcon = new ImageIcon(image); - setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight()); - setLocationRelativeTo(null); - setAlwaysOnTop(true); - setVisible(true); - - new Timer().schedule(new TimerTask() - { - @Override - public void run() - { - setVisible(false); - if (parent != null) - { - // Make parent visible. - parent.setVisible(true); - // Focus parent window. - parent.toFront(); - parent.setState(Frame.ICONIFIED); - parent.setState(Frame.NORMAL); - } - dispose(); - } - }, imageIcon.getIconWidth() > 0 ? time : 100); - } - - @Override - public void paint(Graphics g) - { - g.drawImage(image, 0, 0, null); - } -} diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java index 845c89f1b8..8d969bf373 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/GameServer.java @@ -34,6 +34,7 @@ import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.DeadLockDetector; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.BotReportTable; import org.l2jmobius.gameserver.data.EventDroplist; @@ -195,8 +196,11 @@ public class GameServer final long serverLoadStart = Chronos.currentTimeMillis(); // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.SERVER_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("GameServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/Gui.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/Gui.java index 160240551e..c43452db68 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/Gui.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/Gui.java @@ -45,8 +45,9 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.l2jmobius.Config; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.gameserver.Shutdown; import org.l2jmobius.gameserver.cache.HtmCache; import org.l2jmobius.gameserver.data.xml.AdminData; @@ -86,6 +87,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -335,7 +341,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(layeredPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/SystemPanel.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/SystemPanel.java index 0e0e24b7da..21e417bf00 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/SystemPanel.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/gameserver/ui/SystemPanel.java @@ -47,7 +47,11 @@ public class SystemPanel extends JPanel public SystemPanel() { - setBackground(Color.WHITE); + if (!Config.DARK_THEME) + { + setBackground(Color.WHITE); + } + setBounds(500, 20, 284, 140); setBorder(new LineBorder(new Color(0, 0, 0), 1, false)); setOpaque(true); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/LoginServer.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/LoginServer.java index e3bca876b1..04aa4c55ee 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/LoginServer.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/LoginServer.java @@ -33,6 +33,7 @@ import org.l2jmobius.Config; import org.l2jmobius.commons.database.DatabaseBackup; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.enums.ServerMode; +import org.l2jmobius.commons.util.PropertiesParser; import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus; import org.l2jmobius.loginserver.network.ClientNetworkManager; import org.l2jmobius.loginserver.ui.Gui; @@ -63,8 +64,11 @@ public class LoginServer private LoginServer() throws Exception { // GUI - if (!GraphicsEnvironment.isHeadless()) + final PropertiesParser serverSettings = new PropertiesParser(Config.LOGIN_CONFIG_FILE); + Config.ENABLE_GUI = serverSettings.getBoolean("EnableGUI", true); + if (Config.ENABLE_GUI && !GraphicsEnvironment.isHeadless()) { + Config.DARK_THEME = serverSettings.getBoolean("DarkTheme", true); System.out.println("LoginServer: Running in GUI mode."); new Gui(); } diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/ui/Gui.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/ui/Gui.java index bc4249e20f..872cb12329 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/ui/Gui.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/loginserver/ui/Gui.java @@ -43,8 +43,10 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.LimitLinesDocumentListener; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.Config; +import org.l2jmobius.commons.ui.DarkTheme; +import org.l2jmobius.commons.ui.LimitLinesDocumentListener; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.loginserver.GameServerTable; import org.l2jmobius.loginserver.GameServerTable.GameServerInfo; import org.l2jmobius.loginserver.LoginController; @@ -75,6 +77,11 @@ public class Gui public Gui() { + if (Config.DARK_THEME) + { + DarkTheme.activate(); + } + // Initialize console. txtrConsole = new JTextArea(); txtrConsole.setEditable(false); @@ -243,7 +250,7 @@ public class Gui frame.setJMenuBar(menuBar); frame.setIconImages(icons); frame.add(scrollPanel, BorderLayout.CENTER); - frame.getContentPane().setPreferredSize(new Dimension(800, 550)); + frame.getContentPane().setPreferredSize(new Dimension(Config.DARK_THEME ? 815 : 800, 550)); frame.pack(); frame.setLocationRelativeTo(null); diff --git a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java index 7ab1875acd..e75091c54f 100644 --- a/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java +++ b/L2J_Mobius_Essence_5.0_Sylph/java/org/l2jmobius/tools/dbinstaller/gui/DBConfigGUI.java @@ -36,7 +36,7 @@ import javax.swing.SpringLayout; import javax.swing.SwingConstants; import javax.swing.WindowConstants; -import org.l2jmobius.commons.util.SplashScreen; +import org.l2jmobius.commons.ui.SplashScreen; import org.l2jmobius.tools.dbinstaller.RunTasks; import org.l2jmobius.tools.dbinstaller.util.mysql.MySqlConnect; import org.l2jmobius.tools.dbinstaller.util.swing.SpringUtilities;