mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 14:33:04 +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();
|
||||
// INIT GUI
|
||||
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" );
|
||||
if (runtimeProvider == null) runtimeProvider = new JSRuntimeProvider();
|
||||
}
|
||||
catch( ClassNotFoundException e ) {
|
||||
if (runtimeProvider == null) runtimeProvider = new GuiRuntimeProvider();
|
||||
runtimeProvider = new GuiRuntimeProvider();
|
||||
}
|
||||
runtimeProvider.init(false);
|
||||
runtimeProvider.preLoad();
|
||||
|
|
|
@ -24,6 +24,7 @@ public void loadConfig(String get) {
|
|||
@Override
|
||||
public void run(String[] args) throws NoSuchMethodException, IOException {
|
||||
preLoad();
|
||||
loadConfig("INIT");
|
||||
LogHelper.info("Invoking start() function");
|
||||
Launcher.modulesManager.postInitModules();
|
||||
engine.start((String[]) args);
|
||||
|
@ -33,7 +34,8 @@ public void run(String[] args) throws NoSuchMethodException, IOException {
|
|||
@Override
|
||||
public void preLoad() throws IOException {
|
||||
if (!isPreLoaded) {
|
||||
loadConfig("API");
|
||||
//loadConfig("API");
|
||||
//loadConfig("SETTINGS");
|
||||
loadConfig("CONFIG");
|
||||
isPreLoaded = true;
|
||||
}
|
||||
|
@ -41,6 +43,6 @@ public void preLoad() throws IOException {
|
|||
|
||||
@Override
|
||||
public void init(boolean clientInstance) {
|
||||
loadConfig("INIT");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import pro.gravit.launcher.sgui.Application;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
public class GuiEngine {
|
||||
private Map<String, String> Configs = new HashMap<String, String>();
|
||||
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) {
|
||||
try {
|
||||
System.out.println("Настройка "+config+" Загружена");
|
||||
LogHelper.info("Настройка "+config+" Загружена");
|
||||
Class c = Class.forName("pro.gravit.launcher.sgui.config."+config);
|
||||
Object configclass = c.newInstance();
|
||||
GuiEngineConfig runclass = (GuiEngineConfig) configclass;
|
||||
runclass.main(engine);
|
||||
|
||||
Method runmethod = c.getMethod("main", GuiEngine.class);
|
||||
runmethod.invoke(c.newInstance(), engine);
|
||||
}
|
||||
catch (Exception e){
|
||||
System.out.println("Ошибка при загрузке настройки "+config);
|
||||
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e){
|
||||
LogHelper.info("Ошибка при загрузке настройки "+config);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void configset(String path, String value) {
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
package pro.gravit.launcher.sgui.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class GuiEngineConfig {
|
||||
void main(GuiEngine engine) {}
|
||||
void main(GuiEngine engine) throws IOException{
|
||||
LogHelper.info("Вызов фунции не получился");
|
||||
};
|
||||
}
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
import java.io.IOException;
|
||||
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.GuiEngineConfig;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class CONFIG extends GuiEngineConfig {
|
||||
void main(GuiEngine engine) throws IOException {
|
||||
public void main(GuiEngine engine) throws IOException {
|
||||
engine.configset("dir", "GravitLauncher");
|
||||
engine.configset("title", "GravitLauncher");
|
||||
engine.configset("favicon", "favicon.png");
|
||||
|
@ -28,6 +29,6 @@ void main(GuiEngine engine) throws IOException {
|
|||
if (!IOHelper.isDir(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.sgui.api.GuiEngine;
|
||||
import pro.gravit.launcher.sgui.api.GuiEngineConfig;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class INIT extends GuiEngineConfig {
|
||||
private SettingsManager settingsManager;
|
||||
void main(GuiEngine engine) throws IOException {
|
||||
private SettingsManager settingsManagerClass;
|
||||
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");
|
||||
settingsManager.loadConfig();
|
||||
engine.configset("SettingsManager", settingsManager.settings);
|
||||
engine.configset("SettingsManager", SettingsManager.settings);
|
||||
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