diff --git a/assets/lang/lang_en.properties b/assets/lang/lang_en.properties index 700c38a..9ea3730 100644 --- a/assets/lang/lang_en.properties +++ b/assets/lang/lang_en.properties @@ -204,6 +204,7 @@ error.flamingo_offline="Could not connect to Flamingo.\nSome launcher functional error.no_compatible_jvm="No compatible Java VM to start the editor with." error.folders_within_mods_folder="There are folders within the mods folder.\nYou do not need to extract the .zip files, simply drag and drop the .zip files inside the mods folder." error.unsupported_64bit="Your system does not support a 64-bit Java VM." +error.not_supported="Not supported." # Discord RPC strings presence.using="Using Knight Launcher" diff --git a/src/main/java/com/luuqui/launcher/LauncherEventHandler.java b/src/main/java/com/luuqui/launcher/LauncherEventHandler.java index 1bfc3d2..3d4a276 100644 --- a/src/main/java/com/luuqui/launcher/LauncherEventHandler.java +++ b/src/main/java/com/luuqui/launcher/LauncherEventHandler.java @@ -314,8 +314,6 @@ public static void selectedServerChanged(ActionEvent event) { LauncherGUI.playerCountTooltipButton.setVisible(true); LauncherGUI.serverInfoButton.setEnabled(false); LauncherGUI.serverInfoButton.setVisible(false); - LauncherGUI.editorsButton.setEnabled(true); - LauncherGUI.editorsButton.setVisible(true); } else { LauncherGUI.launchButton.setEnabled(selectedServer.enabled == 1); if(!selectedServer.isInstalled()) { @@ -335,10 +333,6 @@ public static void selectedServerChanged(ActionEvent event) { // TODO: Fetch player count. LauncherGUI.playerCountLabel.setVisible(false); - - // TODO: Editors support for third party servers. - LauncherGUI.editorsButton.setEnabled(false); - LauncherGUI.editorsButton.setVisible(false); } LauncherApp.selectedServer = selectedServer; diff --git a/src/main/java/com/luuqui/launcher/editor/EditorsEventHandler.java b/src/main/java/com/luuqui/launcher/editor/EditorsEventHandler.java index ed6b4f8..8b263e6 100644 --- a/src/main/java/com/luuqui/launcher/editor/EditorsEventHandler.java +++ b/src/main/java/com/luuqui/launcher/editor/EditorsEventHandler.java @@ -1,6 +1,7 @@ package com.luuqui.launcher.editor; import com.luuqui.dialog.Dialog; +import com.luuqui.launcher.LauncherApp; import com.luuqui.launcher.LauncherGlobals; import com.luuqui.launcher.Locale; import com.luuqui.launcher.ModuleLoader; @@ -10,6 +11,8 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.io.File; +import java.util.ArrayList; +import java.util.List; import static com.luuqui.launcher.editor.Log.log; @@ -18,7 +21,7 @@ public class EditorsEventHandler { public static boolean isBooting = false; public static boolean spiralviewExtracted = false; - private static void startEditor(String editor, String arg) { + private static void startEditor(String editor, String arg, boolean thirdparty) { if(!spiralviewExtracted) { ModuleLoader.loadSpiralview(); spiralviewExtracted = true; @@ -41,45 +44,72 @@ private static void startEditor(String editor, String arg) { Dialog.push(Locale.getValue("error.no_compatible_jvm"), Locale.getValue("b.editors"), JOptionPane.ERROR_MESSAGE); } - String[] editorCmdLine = new String[] { - javaVMPath, - "-classpath", - LauncherGlobals.USER_DIR + File.separator + "./KnightLauncher/modules/spiralview/spiralview.jar" + libSeparator + - LauncherGlobals.USER_DIR + File.separator + "./code/projectx-config.jar" + libSeparator + - LauncherGlobals.USER_DIR + File.separator + "./code/projectx-pcode.jar" + libSeparator + - LauncherGlobals.USER_DIR + File.separator + "./code/lwjgl_util.jar" + libSeparator + - LauncherGlobals.USER_DIR + File.separator + "./code/lwjgl.jar", - "-Xms2G", - "-Xmx2G", - "-Dappdir=" + LauncherGlobals.USER_DIR + File.separator + "./", - "-Dresource_dir=" + LauncherGlobals.USER_DIR + File.separator + "./rsrc", - "-Djava.library.path=" + LauncherGlobals.USER_DIR + File.separator + "./native", - editor, - arg - }; - - ProcessUtil.runFromDirectory(editorCmdLine, LauncherGlobals.USER_DIR, true); + String classpath = ""; + String rootDir = LauncherApp.selectedServer.getRootDirectory(); + if(!thirdparty) classpath += rootDir + File.separator + "./KnightLauncher/modules/spiralview/spiralview.jar" + libSeparator; + if(thirdparty) classpath += LauncherGlobals.USER_DIR + File.separator + "./KnightLauncher.jar" + libSeparator; + classpath += rootDir + File.separator + "./code/projectx-config.jar" + libSeparator; + classpath += rootDir + File.separator + "./code/projectx-pcode.jar" + libSeparator; + classpath += rootDir + File.separator + "./code/lwjgl_util.jar" + libSeparator; + classpath += rootDir + File.separator + "./code/lwjgl.jar"; + + List editorCmdLine = new ArrayList<>(); + editorCmdLine.add(javaVMPath); + editorCmdLine.add("-classpath"); + editorCmdLine.add(classpath); + editorCmdLine.add("-Xms2G"); + editorCmdLine.add("-Xmx2G"); + if(thirdparty) { + editorCmdLine.add("-Dcom.threerings.getdown=false"); + editorCmdLine.add("-XX:SoftRefLRUPolicyMSPerMB=10"); + editorCmdLine.add("-Dorg.lwjgl.util.NoChecks=true"); + editorCmdLine.add("-Dsun.java2d.d3d=false"); + editorCmdLine.add("-XX:+AggressiveOpts"); + } + editorCmdLine.add("-Dappdir=" + rootDir + File.separator + "./"); + editorCmdLine.add("-Dresource_dir=" + rootDir + File.separator + "./rsrc"); + editorCmdLine.add("-Djava.library.path=" + rootDir + File.separator + "./native"); + editorCmdLine.add(editor); + editorCmdLine.add(arg); + + ProcessUtil.runFromDirectory(editorCmdLine.toArray(new String[editorCmdLine.size()]), rootDir, true); } } public static void startModelViewer(ActionEvent actionEvent) { EditorsGUI.editorLaunchFakeProgressBar.setMaximum(150); - startEditor("com.luuqui.spiralview.ModelViewerHook", "rsrc/character/pc/model.dat"); + if(LauncherApp.selectedServer.isOfficial()) { + startEditor("com.luuqui.spiralview.ModelViewerHook", "rsrc/character/pc/model.dat", false); + } else { + startEditor("com.threerings.opengl.model.tools.ModelViewer", LauncherApp.selectedServer.getRootDirectory() + "rsrc/character/pc/model.dat", true); + } } public static void startSceneEditor(ActionEvent actionEvent) { EditorsGUI.editorLaunchFakeProgressBar.setMaximum(155); - startEditor("com.luuqui.spiralview.SceneEditorHook", ""); + if(LauncherApp.selectedServer.isOfficial()) { + startEditor("com.luuqui.spiralview.SceneEditorHook", "", false); + } else { + startEditor("com.threerings.tudey.tools.SceneEditor", "", true); + } } public static void startInterfaceTester(ActionEvent actionEvent) { EditorsGUI.editorLaunchFakeProgressBar.setMaximum(110); - startEditor("com.luuqui.spiralview.InterfaceTesterHook", ""); + if(LauncherApp.selectedServer.isOfficial()) { + startEditor("com.luuqui.spiralview.InterfaceTesterHook", "", false); + } else { + Dialog.push(Locale.getValue("error.not_supported"), Locale.getValue("t.error"), JOptionPane.ERROR_MESSAGE); + } } public static void startParticleEditor(ActionEvent actionEvent) { EditorsGUI.editorLaunchFakeProgressBar.setMaximum(125); - startEditor("com.luuqui.spiralview.ParticleEditorHook", ""); + if(LauncherApp.selectedServer.isOfficial()) { + startEditor("com.luuqui.spiralview.ParticleEditorHook", "", false); + } else { + startEditor("com.threerings.opengl.effect.tools.ParticleEditor", "", true); + } } protected static void startedBooting() {