html-button direct eval
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-16 13:01:40 -04:00
parent dfd5932675
commit 84e5d33173
6 changed files with 30 additions and 6 deletions

View File

@ -16,5 +16,5 @@ mainPanel {
<button onclick="hook('ROOM_TOOL_TOGGLE')">Show Rooms</button>
<button onclick="hook('ROOM_TOOL_TOGGLE')">Select Furniture Spots</button>
<button onclick="hook('ROOM_TOOL_TOGGLE')">Show Furniture Spots</button>
<button onclick="hook('ROOM_TOOL_TOGGLE')">Detect Room</button>
<button onclick="console.log(Object.keys(engine))">Detect Room</button>
</div>

View File

@ -69,15 +69,17 @@ export const clientHooks: Hook[] = [
{
signal: "ROOM_TOOL_TOGGLE",
callback: (engine: Engine) => {
engine.singletons.loggerScripts.WARNING('asdf')
engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
// engine.singletons.loggerScripts.WARNING('asdf')
// engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
}
},
{
signal: "ROOM_TOOL_MENU",
callback: (engine: Engine) => {
engine.singletons.loggerScripts.WARNING('asdf')
engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
console.log(JSON.stringify({}))
console.log(Object.keys(globalThis))
// engine.singletons.loggerScripts.WARNING('asdf')
// engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
engine.classes.menuUtils.static.openDialog('Data/menu/room/roomToolConfig.html')
}
},

View File

@ -1844,6 +1844,7 @@ Out-of-context typescript compilation that falls back to in-context compilation
Fix opengl bug
Fix typescript out-of-context compilation caching
Script recompilation work
HTML-defined buttons now directly eval in the js context instead of going through hook manager

View File

@ -20,5 +20,17 @@ public class ClientScriptUtils {
}
});
}
/**
* Evaluates a string
* @param evalCode The string to evaluate
*/
public static void eval(String evalCode){
Globals.engineState.scriptEngine.getScriptContext().executeSynchronously(() -> {
if(Globals.engineState.scriptEngine != null && Globals.engineState.scriptEngine.isInitialized()){
Globals.engineState.scriptEngine.getScriptContext().eval(evalCode);
}
});
}
}

View File

@ -80,7 +80,7 @@ public class HtmlParser {
callback = () -> {};
} else {
callback = () -> {
ClientScriptUtils.fireSignal("uiButton", onClick);
ClientScriptUtils.eval(onClick);
};
}
rVal = Button.createEmptyButton(callback);

View File

@ -517,4 +517,13 @@ public class ScriptContext {
fireSignal.execute(sceneInstanceId,signal,args);
}
/**
* Evaluates a string
* @param evalString The string
*/
public void eval(String evalString){
Source source = Source.create("js",evalString);
context.eval(source);
}
}