Configuration for dark themed GUI.

This commit is contained in:
MobiusDevelopment
2021-05-02 15:02:44 +00:00
parent 04042485eb
commit 8de4d585c3
320 changed files with 7672 additions and 4868 deletions

View File

@@ -32,4 +32,21 @@ MaximumOnlineUsers=2000
AutoCreateAccounts=true
# Enable unknown packet logging.
LogUnknownPackets=false
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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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();
}
}
}