Skip to content

Commit

Permalink
Merge pull request #1 from Deseteral/feature/imgui
Browse files Browse the repository at this point in the history
ImGui
  • Loading branch information
Deseteral authored Sep 27, 2023
2 parents 42deac1 + 3864e5c commit 21ee4c0
Show file tree
Hide file tree
Showing 11 changed files with 2,573 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
imgui-js/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "imgui-js"]
path = imgui-js
url = https://github.com/flyover/imgui-js.git
30 changes: 30 additions & 0 deletions examples/src/scenes/imgui-test-scene.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Screen } from 'ponczek/gfx/screen';
import { Scene } from 'ponczek/core/scene';
import { ENDESGA16PaletteIdx } from 'ponczek/palettes/endesga16-palette';
import { Input, SceneManager } from 'ponczek/core';
import { withTransition } from 'examples/utils/with-transition';

export class ImGuiTestScene extends Scene {
private counter: number = 0;

update(): void {
ImGui.Begin('Hello');
ImGui.Text('Hello world from ImGui!');
ImGui.Text(`Counter value: ${this.counter}`);

if (ImGui.Button('Bump value')) {
this.counter += 1;
}

ImGui.End();

if (Input.getButtonDown('b')) withTransition(() => SceneManager.popScene());
}

render(scr: Screen): void {
scr.clearScreen(ENDESGA16PaletteIdx[6]);

scr.color(ENDESGA16PaletteIdx[14]);
scr.fillRect(10, 25, 128, 256);
}
}
2 changes: 2 additions & 0 deletions examples/src/scenes/main-menu-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { SceneStackTestScene } from 'examples/scenes/scene-stack-test-scene';
import { SimplexNoiseTestScene } from 'examples/scenes/simplex-noise-test-scene';
import { TilemapTestScene } from 'examples/scenes/tilemap-test-scene';
import { withTransition } from 'examples/utils/with-transition';
import { ImGuiTestScene } from 'examples/scenes/imgui-test-scene';

interface Item {
text: string,
Expand Down Expand Up @@ -58,6 +59,7 @@ export class MainMenuScene extends Scene {
[{ text: 'Scene stack', scene: () => new SceneStackTestScene() }],
[{ text: 'Simplex noise', scene: () => new SimplexNoiseTestScene() }],
[{ text: 'Tilemap', scene: () => new TilemapTestScene() }],
[{ text: 'ImGui', scene: () => new ImGuiTestScene() }],
];

this.frameTexture = Texture.copy(Assets.texture('frame'));
Expand Down
9 changes: 9 additions & 0 deletions examples/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ body {
canvas {
image-rendering: pixelated;
}

#imgui-canvas {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
pointer-events: none;
}
1 change: 1 addition & 0 deletions imgui-js
Submodule imgui-js added at a66f2a
6 changes: 6 additions & 0 deletions scripts/generate-index-files.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import fs from 'fs';
import path from 'path';

const ignoredModules = [
'imgui',
];

function writeIndexForFiles(files: string[], indexFilePath: string): void {
const exportList = [
...files.map((fileName) => `export * from './${fileName}';`),
Expand All @@ -14,6 +18,7 @@ const rootFolderContent = fs.readdirSync('./src', { withFileTypes: true });
// Create modules index files
rootFolderContent
.filter((entry) => entry.isDirectory())
.filter((entry) => !ignoredModules.includes(entry.name))
.map((entry) => path.resolve('.', 'src', entry.name))
.forEach((modulePath) => {
const indexFilePath = path.resolve(modulePath, 'index.ts');
Expand All @@ -28,6 +33,7 @@ rootFolderContent
const rootIndexPath = path.resolve('.', 'src', 'index.ts');
const rootModules = rootFolderContent
.filter((entry) => (entry.isDirectory() || path.extname(entry.name) === '.ts'))
.filter((entry) => !ignoredModules.includes(entry.name))
.map((entry) => entry.name)
.map((filePath) => path.basename(filePath, path.extname(filePath)))
.filter((name) => name !== 'index');
Expand Down
2 changes: 2 additions & 0 deletions src/imgui/imgui-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference path="./imgui.d.ts" />
import '../../imgui-js/dist/imgui.umd.js'; // eslint-disable-line
Loading

0 comments on commit 21ee4c0

Please sign in to comment.