Skip to content

Commit 71f5a70

Browse files
authored
Merge pull request #707 from JerwuQu/jwq_bugfix-bonanza
Issue squashing
2 parents f86cdac + 4fd7205 commit 71f5a70

File tree

8 files changed

+28
-18
lines changed

8 files changed

+28
-18
lines changed

cli/cli.js

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const langOption = new Option("--lang <lang>", "Use the given language")
1010
.choices(LANGS);
1111

1212
function requireLang (opts) {
13+
if (opts.lang) {
14+
return opts.lang;
15+
}
1316
if (opts.surpriseMe) {
1417
return LANGS[(Math.random()*LANGS.length) >>> 0];
1518
}

runtimes/web/src/constants.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// If you update this definition, make sure to also update the definition
2-
// in vite.config.ts to match.
3-
export const GAMEDEV_MODE: boolean = import.meta.env.VITE_WASM4_GAMEDEV_MODE !== "false";
4-
1+
export const GAMEDEV_MODE = WASM4_GAMEDEV_MODE;
52
export const WIDTH = 160;
63
export const HEIGHT = 160;
74

runtimes/web/src/ui/menu-overlay.ts

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ export class MenuOverlay extends LitElement {
6565
background: rgba(0, 0, 0, 0.85);
6666
}
6767
68+
.version {
69+
color: #fff;
70+
padding-bottom: 1em;
71+
}
72+
6873
.menu {
6974
border: 2px solid #f0f0f0;
7075
padding: 0 1em 0 1em;
@@ -244,6 +249,9 @@ export class MenuOverlay extends LitElement {
244249

245250
render () {
246251
return html`
252+
<div class="version">
253+
WASM-4 v${WASM4_VERSION}
254+
</div>
247255
<div class="menu">
248256
<ul style="display:${this.optionContext === optionContext.DEFAULT? "inherit": "none"}">
249257
${map(options[optionContext.DEFAULT], (option, idx) =>

runtimes/web/src/vite-env.d.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Include the types for Vite's special import.meta.env object.
22
/// <reference types="vite/client" />
33

4-
interface ImportMetaEnv {
5-
readonly VITE_WASM4_GAMEDEV_MODE: string
6-
}
4+
declare const WASM4_VERSION: string
5+
declare const WASM4_GAMEDEV_MODE: boolean

runtimes/web/vite.config.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { UserConfig, defineConfig } from 'vite';
22
import minifyHTML from 'rollup-plugin-minify-html-literals-v3';
3-
4-
function isGamedevBuild(): boolean {
5-
// If you update this definition, make sure to also update the definition
6-
// in src/constants.ts to match.
7-
return process.env.VITE_WASM4_GAMEDEV_MODE !== "false";
8-
}
3+
import cliPackageJSON from '../../cli/package.json';
94

105
// https://vitejs.dev/config/
116
export default defineConfig(({ mode }) => {
12-
const gamedev_build = isGamedevBuild();
7+
const gamedev_build = process.env.VITE_WASM4_GAMEDEV_MODE !== "false";
138

149
let user_config: UserConfig = {
1510
server: {
@@ -46,6 +41,10 @@ export default defineConfig(({ mode }) => {
4641
plugins: [
4742
minifyHTML(),
4843
],
44+
define: {
45+
WASM4_GAMEDEV_MODE: gamedev_build,
46+
WASM4_VERSION: JSON.stringify(cliPackageJSON.version),
47+
},
4948
};
5049

5150
return user_config;

site/docs/guides/user-input.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ export fn update() void {
404404

405405
## Mouse
406406

407-
Mouse (or touchscreen) input is supported. See the [Memory Map](/docs/reference/memory)
408-
reference for more details on `MOUSE_X`, `MOUSE_Y`, and `MOUSE_BUTTONS`.
407+
Mouse (or touchscreen) input is supported and will work for positions even outside of the game window on supported platforms.
408+
See the [Memory Map](/docs/reference/memory) reference for more details on `MOUSE_X`, `MOUSE_Y`, and `MOUSE_BUTTONS`.
409409

410410
On the example below, we can make a rectangle follow the mouse position and expand when clicked:
411411

site/docs/reference/functions.md

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ By default, `str` is expected to be a `\0` terminated ASCII string.
9191
This means bytes `0x80-0xFF` are treated as individual characters, even in programming languages where strings are normally UTF-8 encoded.
9292
No terminating `\0` is needed in those languages.
9393
In languages where all strings are UTF-16, `str` must only contain characters up to U+00FF and no `\0` is needed.
94+
95+
The text drawing functions in WASM-4's internals and bindings are called `textUtf8` and `textUtf16` for UTF-8 and UTF-16 respectively,
96+
but these names are misnomers and don't actually use UTF-8 or UTF-16 encodings.
97+
If you encounter these functions, instead treat them according to the explanation above.
9498
:::
9599

96100
## Sound

site/docs/reference/memory.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ Example:
8282

8383
### MOUSE_X
8484

85-
Signed 16 bit integer containing the X position of the mouse.
85+
Signed 16 bit integer containing the X position of the mouse. Can contain positions outside of the game window.
8686

8787
### MOUSE_Y
8888

89-
Signed 16 bit integer containing the Y position of the mouse.
89+
Signed 16 bit integer containing the Y position of the mouse. Can contain positions outside of the game window.
9090

9191
### MOUSE_BUTTONS
9292

0 commit comments

Comments
 (0)