Skip to content

Commit

Permalink
Expose enums to ogmo editor
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Aug 19, 2024
1 parent d67a11a commit bb89912
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/igua/ogmo/external-provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { SceneLibrary } from "../core/scene/scene-library";
import { NpcLooks } from "../iguana/npc-looks";

const enums: OgmoExternalProvider.Enum[] = [
{
name: 'Scene',
values: SceneLibrary.getNames(),
},
{
name: 'NpcLook',
values: Object.keys(NpcLooks),
}
];

const data: OgmoExternalProvider.Data = {
enums,
}

namespace OgmoExternalProvider {
export interface Enum {
name: string;
values: string[];
}

export interface Data {
enums: Enum[];
}
}

export function provide() {
window.parent.postMessage(data, '*');
const preEl = document.createElement('pre');
preEl.textContent = JSON.stringify(data, undefined, 2);
document.body.prepend(preEl);
}
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ async function initialize() {
integralUpscaleCanvas(addGameCanvasToDocument(renderer.view));

require("./igua/launch/prepare-game-engine").prepareGameEngine(renderer);

if (Environment.isOgmoExternalProvider) {
require("./igua/ogmo/external-provider").provide();
return;
}

require("./igua/launch/install-dev-tools").installDevTools();
require("./igua/launch/start-game").startGame();
}
Expand Down
4 changes: 4 additions & 0 deletions src/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ export const Environment = {
},
get requiresUserGestureForSound() {
return Environment.isProduction && !Environment.isElectron;
},
get isOgmoExternalProvider() {
const params = new URLSearchParams(window.location.search);
return params.has('ogmoExternalProvider');
}
};

0 comments on commit bb89912

Please sign in to comment.