Skip to content

Commit

Permalink
feat: emit client events FRAMES_LOADED and SET_GLUE_SCREEN (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
timkurvers authored Apr 13, 2024
1 parent 0e22325 commit 74ca112
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/gfx/Screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class Screen {

this.render = this.render.bind(this);

// TODO: Continuously render screen, not on click
document.addEventListener('click', this.render);

// Required for now to ensure the rendering program is loaded when needed
this.debugLines();
}
Expand Down
21 changes: 18 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Client from './Client';
import EventType from './ui/scripting/EventType';
import { ModelFFX } from './ui/components';
import * as glueScriptFunctions from './ui/scripting/globals/glue';

Expand All @@ -19,11 +20,25 @@ client.ui.factories.register('ModelFFX', ModelFFX);
// await client.ui.load('Interface\\GlueXML\\GlueXML.toc');
// await client.ui.load('Interface\\FrameXML\\FrameXML.toc');

console.timeLog('Client load time', client);
console.timeLog('Client load time');

// TODO: Should be handled by GlueMgr
// client.ui.scripting.execute('SetGlueScreen("login")');
client.ui.scripting.signalEvent(EventType.FRAMES_LOADED);
client.ui.scripting.signalEvent(EventType.SET_GLUE_SCREEN, '%s', 'login');

let last = new Date();
const updateAndRender = () => {
const now = new Date();
const diff = +now - +last;

client.ui.root.onLayerUpdate(diff);
client.screen.render();

last = now;
};

// Postpone rendering to allow resources to load (for now)
setTimeout(client.screen.render, 1000);
setTimeout(updateAndRender, 1000);

document.addEventListener('click', updateAndRender);
})();

0 comments on commit 74ca112

Please sign in to comment.