Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: redesign output filter buttons and add custom resolution to game view

esenginea57433f59035
diff --git a/editor/src/panels/OutputPanel.ts b/editor/src/panels/OutputPanel.ts
index 55cdb5949..f7ba60718 100644
--- a/editor/src/panels/OutputPanel.ts
+++ b/editor/src/panels/OutputPanel.ts
@@ -182,7 +182,7 @@ export class OutputPanel implements PanelInstance {
const filtersEl = this.container_.querySelector('.es-output-filters')!;
for (const type of Object.keys(TYPE_LABELS) as OutputType[]) {
const btn = document.createElement('button');
- btn.className = `es-btn es-btn-icon es-output-filter-btn es-active es-output-filter-${type}`;
+ btn.className = `es-output-filter-btn es-active es-output-filter-${type}`;
btn.title = `Toggle ${type}`;
btn.innerHTML = `${TYPE_LABELS[type]} <span class="es-output-filter-count">0</span>`;
btn.addEventListener('click', () => this.toggleFilter(type));
diff --git a/editor/src/panels/game-view/GameViewToolbar.ts b/editor/src/panels/game-view/GameViewToolbar.ts
index 773330b5e..bddc77dbc 100644
--- a/editor/src/panels/game-view/GameViewToolbar.ts
+++ b/editor/src/panels/game-view/GameViewToolbar.ts
@@ -28,6 +28,9 @@ export class GameViewToolbar {
private stopBtn_: HTMLButtonElement | null = null;
private fpsDisplay_: HTMLSpanElement | null = null;
private resolutionSelect_: HTMLSelectElement | null = null;
+ private customSizeEl_: HTMLElement | null = null;
+ private customWidthInput_: HTMLInputElement | null = null;
+ private customHeightInput_: HTMLInputElement | null = null;
private currentPreset_: ResolutionPreset = RESOLUTION_PRESETS[0];
constructor(container: HTMLElement, callbacks: GameViewToolbarCallbacks) {
@@ -47,7 +50,12 @@ export class GameViewToolbar {
<button class="es-btn es-btn-icon es-gameview-stop" title="Stop" disabled>${icons.stop(14)}</button>
</div>
<div class="es-toolbar-divider"></div>
- <select class="es-gameview-resolution">${options}</select>
+ <select class="es-gameview-resolution">${options}<option value="custom">Custom</option></select>
+ <div class="es-gameview-custom-size" style="display:none">
+ <input type="number" class="es-gameview-custom-w" placeholder="W" min="1" max="7680" />
+ <span class="es-gameview-custom-x">&times;</span>
+ <input type="number" class="es-gameview-custom-h" placeholder="H" min="1" max="4320" />
+ </div>
<span class="es-gameview-fps"></span>
</div>
`;
@@ -58,15 +66,35 @@ export class GameViewToolbar {
this.stopBtn_ = this.container_.querySelector('.es-gameview-stop');
this.fpsDisplay_ = this.container_.querySelector('.es-gameview-fps');
this.resolutionSelect_ = this.container_.querySelector('.es-gameview-resolution');
+ this.customSizeEl_ = this.container_.querySelector('.es-gameview-custom-size');
+ this.customWidthInput_ = this.container_.querySelector('.es-gameview-custom-w');
+ this.customHeightInput_ = this.container_.querySelector('.es-gameview-custom-h');
this.playBtn_?.addEventListener('click', () => this.callbacks_.onPlay());
this.stopBtn_?.addEventListener('click', () => this.callbacks_.onStop());
this.resolutionSelect_?.addEventListener('change', () => {
- const idx = parseInt(this.resolutionSelect_!.value, 10);
- this.currentPreset_ = RESOLUTION_PRESETS[idx];
- this.callbacks_.onResolutionChange(this.currentPreset_);
+ const val = this.resolutionSelect_!.value;
+ if (val === 'custom') {
+ this.customSizeEl_!.style.display = 'flex';
+ this.applyCustomResolution();
+ } else {
+ this.customSizeEl_!.style.display = 'none';
+ const idx = parseInt(val, 10);
+ this.currentPreset_ = RESOLUTION_PRESETS[idx];
+ this.callbacks_.onResolutionChange(this.currentPreset_);
+ }
});
+
+ this.customWidthInput_?.addEventListener('change', () => this.applyCustomResolution());
+ this.customHeightInput_?.addEventListener('change', () => this.applyCustomResolution());
+ }
+
+ private applyCustomResolution(): void {
+ const w = parseInt(this.customWidthInput_?.value ?? '0', 10) || 0;
+ const h = parseInt(this.customHeightInput_?.value ?? '0', 10) || 0;
+ this.currentPreset_ = { label: 'Custom', width: w, height: h };
+ this.callbacks_.onResolutionChange(this.currentPreset_);
}
updateState(state: GameState): void {
@@ -95,5 +123,8 @@ export class GameViewToolbar {
this.stopBtn_ = null;
this.fpsDisplay_ = null;
this.resolutionSelect_ = null;
+ this.customSizeEl_ = null;
+ this.customWidthInput_ = null;
+ this.customHeightInput_ = null;
}
}
diff --git a/editor/src/styles/game-view.css b/editor/src/styles/game-view.css
index b8a0cdb48..ae7e33cf4 100644
--- a/editor/src/styles/game-view.css
+++ b/editor/src/styles/game-view.css
@@ -52,6 +52,45 @@
border-color: var(--es-accent);
}
+.es-gameview-custom-size {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.es-gameview-custom-w,
+.es-gameview-custom-h {
+ width: 56px;
+ height: 22px;
+ padding: 2px 4px;
+ background: var(--es-input-bg);
+ color: var(--es-text-primary);
+ border: 1px solid var(--es-border);
+ border-radius: 3px;
+ font-size: 11px;
+ outline: none;
+ -moz-appearance: textfield;
+}
+
+.es-gameview-custom-w::-webkit-outer-spin-button,
+.es-gameview-custom-w::-webkit-inner-spin-button,
+.es-gameview-custom-h::-webkit-outer-spin-button,
+.es-gameview-custom-h::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+.es-gameview-custom-w:focus,
+.es-gameview-custom-h:focus {
+ border-color: var(--es-accent);
+}
+
+.es-gameview-custom-x {
+ font-size: 11px;
+ color: var(--es-text-secondary);
+ user-select: none;
+}
+
.es-gameview-fps {
font-size: 11px;
color: var(--es-text-secondary);
diff --git a/editor/src/styles/output.css b/editor/src/styles/output.css
index f607ed387..77ca82ae9 100644
--- a/editor/src/styles/output.css
+++ b/editor/src/styles/output.css
@@ -41,23 +41,51 @@
display: inline-flex;
align-items: center;
gap: 3px;
- padding: 2px 6px;
+ padding: 2px 8px;
font-size: 11px;
border-radius: 3px;
- color: var(--es-text-secondary);
- opacity: 0.5;
+ border: none;
+ background: transparent;
+ color: var(--es-text-disabled);
cursor: pointer;
+ transition: color 0.15s, background 0.15s;
+ line-height: 1.4;
+}
+
+.es-output-filter-btn:hover {
+ color: var(--es-text-secondary);
+ background: var(--es-bg-hover);
}
.es-output-filter-btn.es-active {
- opacity: 1;
color: var(--es-text-primary);
+ background: rgba(204, 204, 204, 0.08);
+}
+
+.es-output-filter-command.es-active {
+ color: #4da6ff;
+ background: rgba(0, 120, 212, 0.15);
+}
+
+.es-output-filter-stdout.es-active {
+ color: var(--es-text-primary);
+ background: rgba(204, 204, 204, 0.08);
+}
+
+.es-output-filter-stderr.es-active {
+ color: #e5c07b;
+ background: rgba(229, 192, 123, 0.12);
+}
+
+.es-output-filter-error.es-active {
+ color: #f44336;
+ background: rgba(244, 67, 54, 0.12);
}
-.es-output-filter-command.es-active { color: var(--es-accent); }
-.es-output-filter-stderr.es-active { color: #e5c07b; }
-.es-output-filter-error.es-active { color: var(--es-danger); }
-.es-output-filter-success.es-active { color: var(--es-success); }
+.es-output-filter-success.es-active {
+ color: #4caf50;
+ background: rgba(76, 175, 80, 0.12);
+}
.es-output-filter-count {
font-size: 10px;