mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-20 06:53:02 +03:00
Добавлены настройки по умолчанию
This commit is contained in:
parent
8696906017
commit
637ab55d5d
7 changed files with 74 additions and 18 deletions
|
@ -74,12 +74,20 @@ public void start(String... args) throws Throwable {
|
||||||
Launcher.modulesManager.preInitModules();
|
Launcher.modulesManager.preInitModules();
|
||||||
// INIT GUI
|
// INIT GUI
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
Class.forName( "com.jfoenixparts.controls.JFXPButton" );
|
||||||
|
if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider();
|
||||||
|
}
|
||||||
|
catch( ClassNotFoundException e ) {
|
||||||
|
runtimeProvider = new GuiRuntimeProvider();
|
||||||
|
}
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Class.forName( "javafx.application.Application" );
|
Class.forName( "javafx.application.Application" );
|
||||||
if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider();
|
if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider();
|
||||||
}
|
}
|
||||||
catch( ClassNotFoundException e ) {
|
catch( ClassNotFoundException e ) {
|
||||||
if (runtimeProvider == null) runtimeProvider = new GuiRuntimeProvider();
|
runtimeProvider = new GuiRuntimeProvider();
|
||||||
}
|
}
|
||||||
runtimeProvider.init(false);
|
runtimeProvider.init(false);
|
||||||
runtimeProvider.preLoad();
|
runtimeProvider.preLoad();
|
||||||
|
|
|
@ -24,6 +24,7 @@ public void loadConfig(String get) {
|
||||||
@Override
|
@Override
|
||||||
public void run(String[] args) throws NoSuchMethodException, IOException {
|
public void run(String[] args) throws NoSuchMethodException, IOException {
|
||||||
preLoad();
|
preLoad();
|
||||||
|
loadConfig("INIT");
|
||||||
LogHelper.info("Invoking start() function");
|
LogHelper.info("Invoking start() function");
|
||||||
Launcher.modulesManager.postInitModules();
|
Launcher.modulesManager.postInitModules();
|
||||||
engine.start((String[]) args);
|
engine.start((String[]) args);
|
||||||
|
@ -33,7 +34,8 @@ public void run(String[] args) throws NoSuchMethodException, IOException {
|
||||||
@Override
|
@Override
|
||||||
public void preLoad() throws IOException {
|
public void preLoad() throws IOException {
|
||||||
if (!isPreLoaded) {
|
if (!isPreLoaded) {
|
||||||
loadConfig("API");
|
//loadConfig("API");
|
||||||
|
//loadConfig("SETTINGS");
|
||||||
loadConfig("CONFIG");
|
loadConfig("CONFIG");
|
||||||
isPreLoaded = true;
|
isPreLoaded = true;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +43,6 @@ public void preLoad() throws IOException {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(boolean clientInstance) {
|
public void init(boolean clientInstance) {
|
||||||
loadConfig("INIT");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import pro.gravit.launcher.sgui.Application;
|
import pro.gravit.launcher.sgui.Application;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
public class GuiEngine {
|
public class GuiEngine {
|
||||||
private Map<String, String> Configs = new HashMap<String, String>();
|
private Map<String, String> Configs = new HashMap<String, String>();
|
||||||
private Map<String, Object> Settings = new HashMap<String, Object>();
|
private Map<String, Object> Settings = new HashMap<String, Object>();
|
||||||
|
@ -11,15 +14,14 @@ public void start(String[] args) {
|
||||||
}
|
}
|
||||||
public void config(GuiEngine engine,String config) {
|
public void config(GuiEngine engine,String config) {
|
||||||
try {
|
try {
|
||||||
System.out.println("Настройка "+config+" Загружена");
|
LogHelper.info("Настройка "+config+" Загружена");
|
||||||
Class c = Class.forName("pro.gravit.launcher.sgui.config."+config);
|
Class c = Class.forName("pro.gravit.launcher.sgui.config."+config);
|
||||||
Object configclass = c.newInstance();
|
Method runmethod = c.getMethod("main", GuiEngine.class);
|
||||||
GuiEngineConfig runclass = (GuiEngineConfig) configclass;
|
runmethod.invoke(c.newInstance(), engine);
|
||||||
runclass.main(engine);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e){
|
||||||
System.out.println("Ошибка при загрузке настройки "+config);
|
LogHelper.info("Ошибка при загрузке настройки "+config);
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void configset(String path, String value) {
|
public void configset(String path, String value) {
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
package pro.gravit.launcher.sgui.api;
|
package pro.gravit.launcher.sgui.api;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class GuiEngineConfig {
|
public class GuiEngineConfig {
|
||||||
void main(GuiEngine engine) {}
|
void main(GuiEngine engine) throws IOException{
|
||||||
|
LogHelper.info("Вызов фунции не получился");
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -2,12 +2,13 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import pro.gravit.launcher.client.DirBridge;
|
import pro.gravit.launcher.client.DirBridge;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
|
||||||
import pro.gravit.launcher.sgui.api.GuiEngine;
|
import pro.gravit.launcher.sgui.api.GuiEngine;
|
||||||
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
||||||
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class CONFIG extends GuiEngineConfig {
|
public class CONFIG extends GuiEngineConfig {
|
||||||
void main(GuiEngine engine) throws IOException {
|
public void main(GuiEngine engine) throws IOException {
|
||||||
engine.configset("dir", "GravitLauncher");
|
engine.configset("dir", "GravitLauncher");
|
||||||
engine.configset("title", "GravitLauncher");
|
engine.configset("title", "GravitLauncher");
|
||||||
engine.configset("favicon", "favicon.png");
|
engine.configset("favicon", "favicon.png");
|
||||||
|
@ -28,6 +29,6 @@ void main(GuiEngine engine) throws IOException {
|
||||||
if (!IOHelper.isDir(DirBridge.defaultUpdatesDir)) {
|
if (!IOHelper.isDir(DirBridge.defaultUpdatesDir)) {
|
||||||
java.nio.file.Files.createDirectory(DirBridge.defaultUpdatesDir);
|
java.nio.file.Files.createDirectory(DirBridge.defaultUpdatesDir);
|
||||||
}
|
}
|
||||||
System.out.println("Настройка...");
|
LogHelper.info("Настройка...");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,14 +4,17 @@
|
||||||
import pro.gravit.launcher.managers.SettingsManager;
|
import pro.gravit.launcher.managers.SettingsManager;
|
||||||
import pro.gravit.launcher.sgui.api.GuiEngine;
|
import pro.gravit.launcher.sgui.api.GuiEngine;
|
||||||
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class INIT extends GuiEngineConfig {
|
public class INIT extends GuiEngineConfig {
|
||||||
private SettingsManager settingsManager;
|
private SettingsManager settingsManagerClass;
|
||||||
void main(GuiEngine engine) throws IOException {
|
public void main(GuiEngine engine) throws IOException {
|
||||||
|
engine.config(engine, "SETTINGS");
|
||||||
|
SettingsManager settingsManager = (SettingsManager) engine.configget("SettingsManagerClass",true);
|
||||||
engine.configset("version-gui","0.0.1");
|
engine.configset("version-gui","0.0.1");
|
||||||
settingsManager.loadConfig();
|
settingsManager.loadConfig();
|
||||||
engine.configset("SettingsManager", settingsManager.settings);
|
engine.configset("SettingsManager", SettingsManager.settings);
|
||||||
settingsManager.loadHDirStore();
|
settingsManager.loadHDirStore();
|
||||||
System.out.println("Инициализация...");
|
LogHelper.info("Инициализация...");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package pro.gravit.launcher.sgui.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import pro.gravit.launcher.client.DirBridge;
|
||||||
|
import pro.gravit.launcher.NewLauncherSettings;
|
||||||
|
import pro.gravit.launcher.managers.SettingsManager;
|
||||||
|
import pro.gravit.launcher.sgui.api.GuiEngine;
|
||||||
|
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
public class SETTINGS extends GuiEngineConfig {
|
||||||
|
public void main(GuiEngine engine) throws IOException {
|
||||||
|
class settingsManagerClass extends SettingsManager {
|
||||||
|
public NewLauncherSettings getDefaultConfig() {
|
||||||
|
NewLauncherSettings new_settings = new NewLauncherSettings();
|
||||||
|
new_settings.login = null;
|
||||||
|
new_settings.rsaPassword = null;
|
||||||
|
new_settings.profile = 0;
|
||||||
|
|
||||||
|
new_settings.updatesDir = DirBridge.defaultUpdatesDir;
|
||||||
|
new_settings.autoEnter = (boolean) engine.configget("autoEnterDefault", true);
|
||||||
|
new_settings.fullScreen = (boolean) engine.configget("fullScreenDefault", true);
|
||||||
|
new_settings.ram = (int) engine.configget("ramDefault", true);
|
||||||
|
new_settings.lastDigest = null;
|
||||||
|
new_settings.lastProfiles.clear();
|
||||||
|
new_settings.lastHDirs.clear();
|
||||||
|
return new_settings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settingsManagerClass settingsManager = new settingsManagerClass();
|
||||||
|
engine.configset("SettingsManager", settingsManager.settings);
|
||||||
|
engine.configset("SettingsManagerClass", settingsManager);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue