mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 01:49:40 +00:00
Added DataScript global definitions i.e. npc, world, event to syntax highlighter as global vars
This commit is contained in:
1 parent
df0d46e63d
commit
aae2fdb23a
5 files changed
+155
-24
No files matched your search
@@ -16,6 +16,8 @@ import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextArea;
|
||||
import noppes.npcs.client.gui.util.GuiScriptTextArea;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.ScriptTextContainer;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -160,6 +162,10 @@ public class GuiScript extends GuiScriptInterface {
|
||||
|
||||
activeArea.setLanguage(script.getLanguage());
|
||||
activeArea.setScriptContext(getScriptContext());
|
||||
|
||||
// Set editor globals based on the active NPC hook
|
||||
String hookName = EnumScriptType.values()[activeTab].function;
|
||||
applyEditorGlobals(activeArea, hookName);
|
||||
|
||||
// Setup fullscreen key binding
|
||||
GuiScriptTextArea.KEYS.FULLSCREEN.setTask(e -> {
|
||||
@@ -225,6 +231,19 @@ public class GuiScript extends GuiScriptInterface {
|
||||
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
|
||||
}
|
||||
|
||||
// Apply editor globals for the active NPC hook.
|
||||
private void applyEditorGlobals(GuiScriptTextArea activeArea, String hookName) {
|
||||
if (activeArea == null)
|
||||
return;
|
||||
|
||||
ScriptTextContainer textContainer = activeArea.getContainer();
|
||||
if (textContainer == null)
|
||||
return;
|
||||
|
||||
if (script != null)
|
||||
textContainer.setEditorGlobalsMap(script.getEditorGlobals(hookName));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getConsoleText() {
|
||||
Map<Long, String> map = this.script.getOldConsoleText();
|
||||
@@ -371,4 +390,3 @@ public class GuiScript extends GuiScriptInterface {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user