mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] launcher Console
This commit is contained in:
parent
76691da8c9
commit
b432f8f13f
6 changed files with 68 additions and 2 deletions
|
@ -122,6 +122,16 @@ function initConsoleScene() {
|
||||||
pane.lookup("#close").setOnAction(function(){
|
pane.lookup("#close").setOnAction(function(){
|
||||||
consoleStage.hide();
|
consoleStage.hide();
|
||||||
});
|
});
|
||||||
|
var text = consoleMenu.lookup("#textField");
|
||||||
|
var output = consoleMenu.lookup("#output");
|
||||||
|
var appendFunction = function(line) javafx.application.Platform.runLater(function() output.appendText(line));
|
||||||
|
consoleMenu.lookup("#send").setOnAction(function(){
|
||||||
|
execCommand(text.getText());
|
||||||
|
text.setText("");
|
||||||
|
});
|
||||||
|
FunctionalBridge.addPlainOutput(function(string) {
|
||||||
|
appendFunction(string+"\n");
|
||||||
|
})
|
||||||
pane.lookup("#hide").setOnAction(function(event) { consoleStage.setIconified(true) });
|
pane.lookup("#hide").setOnAction(function(event) { consoleStage.setIconified(true) });
|
||||||
|
|
||||||
var pane = consoleMenu.lookup("#consolePane");
|
var pane = consoleMenu.lookup("#consolePane");
|
||||||
|
@ -456,3 +466,4 @@ launcher.loadScript("dialog/overlay/update/update.js");
|
||||||
|
|
||||||
/* ======== Overlays scripts ======== */
|
/* ======== Overlays scripts ======== */
|
||||||
launcher.loadScript("dialog/scenes/options/options.js");
|
launcher.loadScript("dialog/scenes/options/options.js");
|
||||||
|
launcher.loadScript("dialog/scenes/console/console.js");
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<Insets left="10.0" right="10.0" top="10.0" />
|
<Insets left="10.0" right="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</JFXTextArea>
|
</JFXTextArea>
|
||||||
<JFXTextField id="textField" focusColor="#909090" layoutY="395.0" prefHeight="30.0" prefWidth="545.0" promptText="Введите команду..." unFocusColor="#ffffff00">
|
<JFXTextField fx:id="textField" focusColor="#909090" layoutY="395.0" prefHeight="30.0" prefWidth="545.0" promptText="Введите команду..." unFocusColor="#ffffff00">
|
||||||
<opaqueInsets>
|
<opaqueInsets>
|
||||||
<Insets />
|
<Insets />
|
||||||
</opaqueInsets>
|
</opaqueInsets>
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
<Insets left="10.0" />
|
<Insets left="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</JFXTextField>
|
</JFXTextField>
|
||||||
<JFXButton id="send" defaultButton="true" layoutX="542.0" layoutY="395.0" prefHeight="30.0" prefWidth="147.0" text="Отправить" />
|
<JFXButton fx:id="send" defaultButton="true" layoutX="542.0" layoutY="395.0" prefHeight="30.0" prefWidth="147.0" text="Отправить" />
|
||||||
<Line endX="589.0" layoutX="98.0" layoutY="390.0" startX="-100.0" stroke="#5b3636" styleClass="lineHead" />
|
<Line endX="589.0" layoutX="98.0" layoutY="390.0" startX="-100.0" stroke="#5b3636" styleClass="lineHead" />
|
||||||
</children>
|
</children>
|
||||||
<stylesheets>
|
<stylesheets>
|
||||||
|
|
3
Launcher/runtime/dialog/scenes/console/console.js
Normal file
3
Launcher/runtime/dialog/scenes/console/console.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function execCommand(cmd) {
|
||||||
|
FunctionalBridge.evalCommand(cmd);
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
import ru.gravit.launcher.gui.JSRuntimeProvider;
|
import ru.gravit.launcher.gui.JSRuntimeProvider;
|
||||||
import ru.gravit.launcher.gui.RuntimeProvider;
|
import ru.gravit.launcher.gui.RuntimeProvider;
|
||||||
import ru.gravit.launcher.managers.ClientGsonManager;
|
import ru.gravit.launcher.managers.ClientGsonManager;
|
||||||
|
import ru.gravit.launcher.managers.ConsoleManager;
|
||||||
import ru.gravit.launcher.request.Request;
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.websockets.ClientWebSocketService;
|
import ru.gravit.launcher.request.websockets.ClientWebSocketService;
|
||||||
import ru.gravit.launcher.request.websockets.StandartClientWebSocketService;
|
import ru.gravit.launcher.request.websockets.StandartClientWebSocketService;
|
||||||
|
@ -29,6 +30,7 @@ public static void main(String... args) throws Throwable {
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
// Start Launcher
|
// Start Launcher
|
||||||
initGson();
|
initGson();
|
||||||
|
ConsoleManager.initConsole();
|
||||||
LogHelper.setStacktraceEnabled(true);
|
LogHelper.setStacktraceEnabled(true);
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
import ru.gravit.launcher.hasher.FileNameMatcher;
|
import ru.gravit.launcher.hasher.FileNameMatcher;
|
||||||
import ru.gravit.launcher.hasher.HashedDir;
|
import ru.gravit.launcher.hasher.HashedDir;
|
||||||
import ru.gravit.launcher.hwid.OshiHWIDProvider;
|
import ru.gravit.launcher.hwid.OshiHWIDProvider;
|
||||||
|
import ru.gravit.launcher.managers.ConsoleManager;
|
||||||
import ru.gravit.launcher.managers.HasherManager;
|
import ru.gravit.launcher.managers.HasherManager;
|
||||||
import ru.gravit.launcher.managers.HasherStore;
|
import ru.gravit.launcher.managers.HasherStore;
|
||||||
import ru.gravit.launcher.request.Request;
|
import ru.gravit.launcher.request.Request;
|
||||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||||
|
import ru.gravit.utils.helper.CommonHelper;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
@ -104,4 +107,14 @@ public static void setAuthParams(AuthRequestEvent event) {
|
||||||
public interface HashedDirRunnable {
|
public interface HashedDirRunnable {
|
||||||
SignedObjectHolder<HashedDir> run() throws Exception;
|
SignedObjectHolder<HashedDir> run() throws Exception;
|
||||||
}
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static void evalCommand(String cmd)
|
||||||
|
{
|
||||||
|
ConsoleManager.handler.eval(cmd, false);
|
||||||
|
}
|
||||||
|
@LauncherAPI
|
||||||
|
public static void addPlainOutput(LogHelper.Output output)
|
||||||
|
{
|
||||||
|
LogHelper.addOutput(output, LogHelper.OutputTypes.PLAIN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package ru.gravit.launcher.managers;
|
||||||
|
|
||||||
|
import ru.gravit.utils.command.CommandHandler;
|
||||||
|
import ru.gravit.utils.command.JLineCommandHandler;
|
||||||
|
import ru.gravit.utils.command.StdCommandHandler;
|
||||||
|
import ru.gravit.utils.command.basic.HelpCommand;
|
||||||
|
import ru.gravit.utils.helper.CommonHelper;
|
||||||
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ConsoleManager {
|
||||||
|
public static CommandHandler handler;
|
||||||
|
public static Thread thread;
|
||||||
|
public static void initConsole() throws IOException
|
||||||
|
{
|
||||||
|
CommandHandler localCommandHandler;
|
||||||
|
try {
|
||||||
|
Class.forName("jline.Terminal");
|
||||||
|
|
||||||
|
// JLine2 available
|
||||||
|
localCommandHandler = new JLineCommandHandler();
|
||||||
|
LogHelper.info("JLine2 terminal enabled");
|
||||||
|
} catch (ClassNotFoundException ignored) {
|
||||||
|
localCommandHandler = new StdCommandHandler(true);
|
||||||
|
LogHelper.warning("JLine2 isn't in classpath, using std");
|
||||||
|
}
|
||||||
|
handler = localCommandHandler;
|
||||||
|
registerCommands();
|
||||||
|
thread = CommonHelper.newThread("Launcher Console", true, handler);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
public static void registerCommands()
|
||||||
|
{
|
||||||
|
handler.registerCommand("help", new HelpCommand(handler));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue