proof of concept of ui button calling engine code

This commit is contained in:
austin 2025-05-16 13:10:44 -04:00
parent 84e5d33173
commit 4b1e93067f
7 changed files with 25 additions and 51 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="console.log(Object.keys(engine))">Detect Room</button>
<button onclick="engine.playerState.controlState.roomTool.updateState('Detect Room')">Detect Room</button>
</div>

View File

@ -66,20 +66,9 @@ export const clientHooks: Hook[] = [
engine.classes.areaUtils.static.selectAreaRectangular()
}
},
{
signal: "ROOM_TOOL_TOGGLE",
callback: (engine: Engine) => {
// engine.singletons.loggerScripts.WARNING('asdf')
// engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
}
},
{
signal: "ROOM_TOOL_MENU",
callback: (engine: Engine) => {
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

@ -3,21 +3,30 @@
/**
* Overall state of the player's controls
*/
export interface PlayerControlState {
export class PlayerControlState {
/**
* State of the room tool
*/
roomTool: RoomToolState,
roomTool: RoomToolState = new RoomToolState()
}
/**
* State for the room tool
*/
export interface RoomToolState {
export class RoomToolState {
/**
* The currently selected functionality of the room tool
*/
currentState: number,
currentState: number = 0
/**
* Updates the state of the room tool
* @param value The new value
*/
updateState(value: string){
console.log(value)
}
}
/**
@ -34,9 +43,5 @@ export interface ClientPlayer {
* Actual player control state
*/
export const defaultPlayerState: ClientPlayer = {
controlState: {
roomTool: {
currentState: 0
}
}
controlState: new PlayerControlState()
}

View File

@ -1,30 +0,0 @@
/**
* Overall state of the player's controls
*/
interface PlayerControlState {
/**
* State of the room tool
*/
roomTool: RoomToolState,
}
/**
* State for the room tool
*/
interface RoomToolState {
/**
* The currently selected functionality of the room tool
*/
currentState: number,
}
/**
* Actual player control state
*/
export let playerControlState: PlayerControlState = {
roomTool: {
currentState: 0
}
}

View File

@ -1845,6 +1845,8 @@ 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
Fix caching with deleted source files
Proof of concept of ui button calling engine code

View File

@ -339,6 +339,11 @@ public class ScriptContext {
long lastModified = 0;
try {
File correspondingSourceFile = new File(pathRaw.replace(".cache\\tscache\\src\\", "./assets/").replace(".js",".ts"));
if(!correspondingSourceFile.exists()){
checksumMap.getFileLastModifyMap().remove(cacheKey);
//skip non-existant file
return;
}
FileTime time = Files.getLastModifiedTime(correspondingSourceFile.toPath());
lastModified = time.toMillis();
} catch (IOException e) {

View File

@ -323,6 +323,9 @@ public class ScriptEngine extends SignalServiceImpl {
timeMatch = fileLastModifyMap.get(normalizedPath).contains(lastModified + "");
}
LoggerInterface.loggerScripts.DEBUG("Skipping Preload: " + normalizedPath + " " + inMap + " " + timeMatch + " " + correspondingSourceFile.exists() + " " + lastModified + " " + correspondingSourceFile.toString());
if(!inMap){
continue;
}
rVal = false;
}
} catch (IOException e) {