From 5356d03950aefaebaeeb1e2f4794a248c34bcb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ma=C5=A1karinec?= Date: Sun, 10 Mar 2024 13:17:53 +0100 Subject: [PATCH] Bump submodules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Maškarinec --- examples/flappy/main.um | 6 +- examples/platformer/game/env.um | 2 +- examples/platformer/game/game.um | 2 +- examples/platformer/game/player.um | 6 +- examples/pomodoro/main.um | 8 +- examples/space-shooter/hud.um | 2 +- examples/space-shooter/menu.um | 2 +- examples/tetris/falling_piece.um | 20 +- examples/tetris/gameplay.um | 2 +- lib/sokol | 2 +- lib/umka | 2 +- main.um | 10 +- src/staembed.c | 863 +++++++++++++++-------------- tests/allt.um | 5 +- tests/canvast.um | 8 +- tests/cursort.um | 10 +- tests/dpit.um | 6 +- tests/fontt.um | 2 +- tests/fullscreent.um | 4 +- tests/inputt.um | 10 +- tests/navt.um | 4 +- tests/rayt.um | 6 +- tests/signalt.um | 2 +- tests/uit.um | 18 +- umka/audio.um | 15 +- umka/font.um | 12 +- umka/input.um | 288 +++++----- umka/th.um | 15 +- umka/ui.um | 107 ++-- umka/window.um | 34 +- 30 files changed, 737 insertions(+), 736 deletions(-) diff --git a/examples/flappy/main.um b/examples/flappy/main.um index d266305e..b8ab4780 100644 --- a/examples/flappy/main.um +++ b/examples/flappy/main.um @@ -147,8 +147,8 @@ fn drawCenteredText(t: str, y: th.fu, c: uint32, s: th.fu): th.fu { fn menu() { // check all the known keys for a press - for i:=0; i <= input.key_menu; i++ { - if input.isJustPressed(i) { + for i:=0; i <= int(input.Key.menu); i++ { + if input.isJustPressed(input.Key(i)) { play() } } @@ -196,7 +196,7 @@ fn game() { } // jumping means setting the y motion to the jumpForce - if input.isJustPressedc(' ') || input.isJustPressed(input.mouse1) { + if input.isJustPressedc(' ') || input.isJustPressed(input.Key.mouse1) { motion.y = jumpForce jumpSound.play() } diff --git a/examples/platformer/game/env.um b/examples/platformer/game/env.um index 87c97f13..d4b23f92 100644 --- a/examples/platformer/game/env.um +++ b/examples/platformer/game/env.um @@ -127,7 +127,7 @@ fn reset*() { } fn handle*() { - if input.isJustPressed(input.key_enter) { + if input.isJustPressed(input.Key.enter) { reset() start = th.time } diff --git a/examples/platformer/game/game.um b/examples/platformer/game/game.um index 414eee2b..32f189db 100644 --- a/examples/platformer/game/game.um +++ b/examples/platformer/game/game.um @@ -54,7 +54,7 @@ fn handle*() { bees.handle() player.handle() case stateFinished: - if input.isJustPressed(input.key_enter) { + if input.isJustPressed(input.Key.enter) { state = stateGame reset() } diff --git a/examples/platformer/game/player.um b/examples/platformer/game/player.um index 335c5ec1..00d0c532 100644 --- a/examples/platformer/game/player.um +++ b/examples/platformer/game/player.um @@ -57,11 +57,11 @@ fn move() { canJump = false } - if input.isPressed(input.key_left) { + if input.isPressed(input.Key.left) { mot.x = -1 } - if input.isPressed(input.key_right) { + if input.isPressed(input.Key.right) { mot.x = 1 } @@ -150,7 +150,7 @@ fn handle*() { die() } - if input.isJustPressed(input.key_escape) { + if input.isJustPressed(input.Key.escape) { body.t.p = env.spawn } diff --git a/examples/pomodoro/main.um b/examples/pomodoro/main.um index 5546bb9e..94c9c4cc 100644 --- a/examples/pomodoro/main.um +++ b/examples/pomodoro/main.um @@ -95,7 +95,7 @@ fn guiGetButtonState(gui: ^Gui): ButtonState { lastRect := guiGetLastRect(gui).rect state := ButtonState{} state.hovered = rectVsPoint(lastRect, th_input.getMousePos()) - state.pressed = state.hovered && th_input.isJustPressed(th_input.mouse1) + state.pressed = state.hovered && th_input.isJustPressed(th_input.Key.mouse1) return state } @@ -401,7 +401,7 @@ const onFrame = fn(args: []any) { v_colorscheme = c_colorschemeLight } - if th_input.isJustPressed(th_input.key_escape) { + if th_input.isJustPressed(th_input.Key.escape) { debug = !debug } @@ -490,8 +490,8 @@ fn init*() { v_lastTime = th.time th_window.setup("Pomodoro", trunc(screen.w), trunc(screen.h)) th_window.setViewport(th.Vf2{screen.w, screen.h}) - v_mainFont = th_font.load("Font.ttf", 32, 1) - v_mainFontSmall = th_font.load("Font.ttf", 20, 1) + v_mainFont = th_font.load("Font.ttf", 32) + v_mainFontSmall = th_font.load("Font.ttf", 20) v_countdown = getCountdown(0) v_alarm = th_audio.load("Alarm.wav") v_rectBase = th_image.load("rectbase.png") diff --git a/examples/space-shooter/hud.um b/examples/space-shooter/hud.um index 81572b95..7b7044a4 100644 --- a/examples/space-shooter/hud.um +++ b/examples/space-shooter/hud.um @@ -15,7 +15,7 @@ var ( fn init*() { hearth = image.load("gfx/hearth.png") - mainFont = font.load("gfx/marediv-regular.ttf", 64, font.filterNearest) + mainFont = font.load("gfx/marediv-regular.ttf", 64, font.Filter.nearest) } fn handle*() { } diff --git a/examples/space-shooter/menu.um b/examples/space-shooter/menu.um index 125faa3c..755e8f9b 100644 --- a/examples/space-shooter/menu.um +++ b/examples/space-shooter/menu.um @@ -48,7 +48,7 @@ fn handle*() { gui.box({ dimension: 10, padding: 2, - dir: ui.BoxDirectionUp }) + dir: ui.BoxDir.up }) if gui.qbutton("EXIT") { global.scene = global.NONE diff --git a/examples/tetris/falling_piece.um b/examples/tetris/falling_piece.um index 4e334ff3..a58aec10 100644 --- a/examples/tetris/falling_piece.um +++ b/examples/tetris/falling_piece.um @@ -51,13 +51,13 @@ fn getKicks(from, to: int): [4]presets.Kick { if clockwise { return presets.ClockwiseI[from] } else { - return presets.CounterclockwiseI[from] + return presets.CounterclockwiseI[from] } } if clockwise { return presets.ClockwiseNI[from] } - return presets.CounterclockwiseNI[from] + return presets.CounterclockwiseNI[from] } fn checkTSpinCorners() { @@ -88,14 +88,14 @@ fn runKickTable(table: [4]presets.Kick): bool { if !invalid() { if kind == presets.pieceTypeT { isTspin = true - } + } return true } x = original_x y = original_y } return false -} +} fn rotate180() { from := rotation @@ -180,18 +180,18 @@ fn update*(speed: real) { placeTimer = 0 } - - if (leftBtnLatch.pass(input.isPressed(input.key_left))) { + + if (leftBtnLatch.pass(input.isPressed(input.Key.left))) { placeTimer = 0 movePiece(-1, 0) } - if (rightBtnLatch.pass(input.isPressed(input.key_right))) { + if (rightBtnLatch.pass(input.isPressed(input.Key.right))) { placeTimer = 0 movePiece(1, 0) } - if (input.isPressed(input.key_down)) { + if (input.isPressed(input.Key.down)) { placeTimer += th.delta/1000.0 prev := y y += 0.01*th.delta*speed; @@ -200,7 +200,7 @@ fn update*(speed: real) { } } - if (input.isJustPressedc('X') || input.isJustPressed(input.key_up)) { + if (input.isJustPressedc('X') || input.isJustPressed(input.Key.up)) { global.playSound(&global.audioRotate) placeTimer = 0 rotateClockwise() @@ -215,7 +215,7 @@ fn update*(speed: real) { } if (input.isJustPressedc(' ')) { global.playSound(&global.audioPush) - push() + push() } } diff --git a/examples/tetris/gameplay.um b/examples/tetris/gameplay.um index f25fae47..75f5d298 100644 --- a/examples/tetris/gameplay.um +++ b/examples/tetris/gameplay.um @@ -111,7 +111,7 @@ fn update*() { field.init() field.lost = false } - if input.isJustPressed(input.key_shift) { + if input.isJustPressed(input.Key.shift) { stashPiece() } if falling_piece.placeTimer > 0.5 || falling_piece.groundTouchTimer > 5 { diff --git a/lib/sokol b/lib/sokol index 55dff3d0..db32cf40 160000 --- a/lib/sokol +++ b/lib/sokol @@ -1 +1 @@ -Subproject commit 55dff3d0b9f67145582e13d3b184138260cbcc98 +Subproject commit db32cf409a9eb984e1ababa96e243f141c7f40ed diff --git a/lib/umka b/lib/umka index 3b1411d8..0a6d90a6 160000 --- a/lib/umka +++ b/lib/umka @@ -1 +1 @@ -Subproject commit 3b1411d812b038b8ef878e65cf958823b8eb3991 +Subproject commit 0a6d90a6c41ab42a12fd946debe4e65dcb9d4bf1 diff --git a/main.um b/main.um index e6948eb4..2b27f101 100644 --- a/main.um +++ b/main.um @@ -23,7 +23,7 @@ fn onFrame(args: []any) { p := th.Vf2{ 0, 1 } - if !input.isPressed(input.key_left_alt) { + if !input.isPressed(input.Key.leftAlt) { for i in lines { s := 1 if i == 1 { @@ -56,10 +56,10 @@ fn onFrame(args: []any) { } - if input.isJustPressed(input.key_enter) { - if th.platform == th.PlatformWindows { + if input.isJustPressed(input.Key.enter) { + if th.platform == th.Platform.windows { std.system("explorer \"https://tophat2d.dev/\"") - } else if th.platform == th.PlatformLinux { + } else if th.platform == th.Platform.linux { std.system("xdg-open https://tophat2d.dev/") } } @@ -74,7 +74,7 @@ fn init*() { window.setup("Hello world", 600, 600) window.setViewport(th.Vf2{ 100, 100 }) - loadedFont = font.load("etc/roboto.ttf", 16, 2) + loadedFont = font.load("etc/roboto.ttf", 16) if !loadedFont.validate() { exit(1, "could not load font") } diff --git a/src/staembed.c b/src/staembed.c index f2debde1..393328fb 100644 --- a/src/staembed.c +++ b/src/staembed.c @@ -1,4 +1,4 @@ -#include "tophat.h" +#include "tophat.h" const char *th_em_modulesrc[] = { "\n" "import (\n" @@ -84,20 +84,21 @@ const char *th_em_modulesrc[] = { "\n" "var pool: []^Sound\n" "\n" -"type LoadFlag = uint32\n" -"const (\n" +"//~~enum LoadFlag\n" +"type LoadFlag* = enum {\n" "\t// Streams the audio, only saving 2 seconds into memory.\n" -"\tLoadFlagStream* = LoadFlag(1)\n" +"\tstream = 1\n" "\t// Loads the sound in async. Use `audio.waitForLoad` to wait for the\n" "\t// sounds to load.\n" -"\tLoadFlagAsync* = LoadFlag(4)\n" -")\n" +"\tasync = 4\n" +"}\n" +"//~~\n" "\n" -"fn umth_sound_load(path: str, flags: uint32): ^struct{}\n" +"fn umth_sound_load(path: str, flags: LoadFlag): ^struct{}\n" "//~~fn load\n" "// Loads a sounds at path, if there is an error, the underlying pointer\n" "// will be `NULL` and `validate` will return false.\n" -"fn load*(path: str, flags: LoadFlag = 0): Sound {\n" +"fn load*(path: str, flags: LoadFlag = LoadFlag.stream): Sound {\n" "//~~\n" "\treturn Sound{umth_sound_load(path, flags)}\n" "}\n" @@ -534,7 +535,9 @@ const char *th_em_modulesrc[] = { "\n" "fn umth_image_render_target_to_image(ret: ^Image, rt: RenderTarget)\n" "//~~fn RenderTarget.toImage\n" -"// Returns the image of the render target.\n" +"// Returns the image of the render target. The resulting image has the same\n" +"// lifetime as the base RenderTarget. If you need to use it past the lifetime\n" +"// of the RenderTarget, use the copy method.\n" "// Do not call `setfilter` on the resulting image.\n" "fn (rt: ^RenderTarget) toImage*(): Image {\n" "//~~\n" @@ -803,137 +806,137 @@ const char *th_em_modulesrc[] = { ")\n" "\n" "//~~Keycode constants\n" -"const (\n" -"\tmouse1* = 1 // NOTE: mouse 2 and 3 key codes are swapped\n" -"\tmouse2* = 3 // because sokol uses 3 for middle mouse\n" -"\tmouse3* = 2 // button.\n" -"\n" -"\tkey_ctrl* = 16\n" -"\tkey_shift* = 17\n" -"\tkey_alt* = 18\n" -"\n" -"\tkey_space* = 32\n" -"\tkey_apostrophe* = 39 /* \' */\n" -"\tkey_comma* = 44 /* , */\n" -"\tkey_minus* = 45 /* - */\n" -"\tkey_dot* = 46 /* . */\n" -"\tkey_slash* = 47 /* / */\n" -"\tkey_0* = 48\n" -"\tkey_1* = 49\n" -"\tkey_2* = 50\n" -"\tkey_3* = 51\n" -"\tkey_4* = 52\n" -"\tkey_5* = 53\n" -"\tkey_6* = 54\n" -"\tkey_7* = 55\n" -"\tkey_8* = 56\n" -"\tkey_9* = 57\n" -"\tkey_semicolon* = 59 /* ; */\n" -"\tkey_equal* = 61 /* = */\n" -"\tkey_a* = 65\n" -"\tkey_b* = 66\n" -"\tkey_c* = 67\n" -"\tkey_d* = 68\n" -"\tkey_e* = 69\n" -"\tkey_f* = 70\n" -"\tkey_g* = 71\n" -"\tkey_h* = 72\n" -"\tkey_i* = 73\n" -"\tkey_j* = 74\n" -"\tkey_k* = 75\n" -"\tkey_l* = 76\n" -"\tkey_m* = 77\n" -"\tkey_n* = 78\n" -"\tkey_o* = 79\n" -"\tkey_p* = 80\n" -"\tkey_q* = 81\n" -"\tkey_r* = 82\n" -"\tkey_s* = 83\n" -"\tkey_t* = 84\n" -"\tkey_u* = 85\n" -"\tkey_v* = 86\n" -"\tkey_w* = 87\n" -"\tkey_x* = 88\n" -"\tkey_y* = 89\n" -"\tkey_z* = 90\n" -"\tkey_left_bracket* = 91 /* [ */\n" -"\tkey_backslash* = 92 /* \\ */\n" -"\tkey_right_bracket* = 93 /* ] */\n" -"\tkey_grave_accent* = 96 /* ` */\n" -"\tkey_world_1* = 161 /* non-US #1 */\n" -"\tkey_world_2* = 162 /* non-US #2 */\n" -"\tkey_escape* = 256\n" -"\tkey_enter* = 257\n" -"\tkey_tab* = 258\n" -"\tkey_backspace* = 259\n" -"\tkey_insert* = 260\n" -"\tkey_delete* = 261\n" -"\tkey_right* = 262\n" -"\tkey_left* = 263\n" -"\tkey_down* = 264\n" -"\tkey_up* = 265\n" -"\tkey_page_up* = 266\n" -"\tkey_page_down* = 267\n" -"\tkey_home* = 268\n" -"\tkey_end* = 269\n" -"\tkey_caps_lock* = 280\n" -"\tkey_scroll_lock* = 281\n" -"\tkey_num_lock* = 282\n" -"\tkey_print_screen* = 283\n" -"\tkey_pause* = 284\n" -"\tkey_fn* = 289\n" -"\tkey_fn1* = 290\n" -"\tkey_fn2* = 291\n" -"\tkey_fn3* = 292\n" -"\tkey_fn4* = 293\n" -"\tkey_fn5* = 294\n" -"\tkey_fn6* = 295\n" -"\tkey_fn7* = 296\n" -"\tkey_fn8* = 297\n" -"\tkey_fn9* = 298\n" -"\tkey_fn10* = 299\n" -"\tkey_fn11* = 300\n" -"\tkey_fn12* = 301\n" -"\tkey_fn13* = 302\n" -"\tkey_fn14* = 303\n" -"\tkey_fn15* = 304\n" -"\tkey_fn16* = 305\n" -"\tkey_fn17* = 306\n" -"\tkey_fn18* = 307\n" -"\tkey_fn19* = 308\n" -"\tkey_fn20* = 309\n" -"\tkey_fn21* = 310\n" -"\tkey_fn22* = 311\n" -"\tkey_fn23* = 312\n" -"\tkey_fn24* = 313\n" -"\tkey_fn25* = 314\n" -"\tkey_kp_0* = 320\n" -"\tkey_kp_1* = 321\n" -"\tkey_kp_2* = 322\n" -"\tkey_kp_3* = 323\n" -"\tkey_kp_4* = 324\n" -"\tkey_kp_5* = 325\n" -"\tkey_kp_6* = 326\n" -"\tkey_kp_7* = 327\n" -"\tkey_kp_8* = 328\n" -"\tkey_kp_9* = 329\n" -"\tkey_kp_decimal* = 330\n" -"\tkey_kp_divide* = 331\n" -"\tkey_kp_multiply* = 332\n" -"\tkey_kp_subtract* = 333\n" -"\tkey_kp_add* = 334\n" -"\tkey_kp_enter* = 335\n" -"\tkey_kp_equal* = 336\n" -"\tkey_left_shift* = 340\n" -"\tkey_left_control* = 341\n" -"\tkey_left_alt* = 342\n" -"\tkey_left_super* = 343\n" -"\tkey_right_shift* = 344\n" -"\tkey_right_control* = 345\n" -"\tkey_right_alt* = 346\n" -"\tkey_right_super* = 347\n" -"\tkey_menu* = 348\n" -")\n" +"type Key* = enum {\n" +"\tmouse1 = 1 // NOTE: mouse 2 and 3 key codes are swapped\n" +"\tmouse2 = 3 // because sokol uses 3 for middle mouse\n" +"\tmouse3 = 2 // button.\n" +"\n" +"\tctrl = 16\n" +"\tshift = 17\n" +"\talt = 18\n" +"\n" +"\tspace = 32\n" +"\tapostrophe = 39 /* \' */\n" +"\tcomma = 44 /* , */\n" +"\tminus = 45 /* - */\n" +"\tdot = 46 /* . */\n" +"\tslash = 47 /* / */\n" +"\tnum0 = 48\n" +"\tnum1 = 49\n" +"\tnum2 = 50\n" +"\tnum3 = 51\n" +"\tnum4 = 52\n" +"\tnum5 = 53\n" +"\tnum6 = 54\n" +"\tnum7 = 55\n" +"\tnum8 = 56\n" +"\tnum9 = 57\n" +"\tsemicolon = 59 /* ; */\n" +"\tequal = 61 /* = */\n" +"\ta = 65\n" +"\tb = 66\n" +"\tc = 67\n" +"\td = 68\n" +"\te = 69\n" +"\tf = 70\n" +"\tg = 71\n" +"\th = 72\n" +"\ti = 73\n" +"\tj = 74\n" +"\tk = 75\n" +"\tl = 76\n" +"\tm = 77\n" +"\tn = 78\n" +"\to = 79\n" +"\tp = 80\n" +"\tq = 81\n" +"\tr = 82\n" +"\ts = 83\n" +"\tt = 84\n" +"\tu = 85\n" +"\tv = 86\n" +"\tw = 87\n" +"\tx = 88\n" +"\ty = 89\n" +"\tz = 90\n" +"\tleftBracket = 91 /* [ */\n" +"\tbackslash = 92 /* \\ */\n" +"\trightBracket = 93 /* ] */\n" +"\tgraveAccent = 96 /* ` */\n" +"\tworld1 = 161 /* non-US #1 */\n" +"\tworld2 = 162 /* non-US #2 */\n" +"\tescape = 256\n" +"\tenter = 257\n" +"\ttab = 258\n" +"\tbackspace = 259\n" +"\tinsert = 260\n" +"\tdelete = 261\n" +"\tright = 262\n" +"\tleft = 263\n" +"\tdown = 264\n" +"\tup = 265\n" +"\tpageUp = 266\n" +"\tpageDown = 267\n" +"\thome = 268\n" +"\tend = 269\n" +"\tcapsLock = 280\n" +"\tscrollLock = 281\n" +"\tnumLock = 282\n" +"\tprintScreen = 283\n" +"\tpause = 284\n" +"\tfn0 = 289\n" +"\tfn1 = 290\n" +"\tfn2 = 291\n" +"\tfn3 = 292\n" +"\tfn4 = 293\n" +"\tfn5 = 294\n" +"\tfn6 = 295\n" +"\tfn7 = 296\n" +"\tfn8 = 297\n" +"\tfn9 = 298\n" +"\tfn10 = 299\n" +"\tfn11 = 300\n" +"\tfn12 = 301\n" +"\tfn13 = 302\n" +"\tfn14 = 303\n" +"\tfn15 = 304\n" +"\tfn16 = 305\n" +"\tfn17 = 306\n" +"\tfn18 = 307\n" +"\tfn19 = 308\n" +"\tfn20 = 309\n" +"\tfn21 = 310\n" +"\tfn22 = 311\n" +"\tfn23 = 312\n" +"\tfn24 = 313\n" +"\tfn25 = 314\n" +"\tkp0 = 320\n" +"\tkp1 = 321\n" +"\tkp2 = 322\n" +"\tkp3 = 323\n" +"\tkp4 = 324\n" +"\tkp5 = 325\n" +"\tkp6 = 326\n" +"\tkp7 = 327\n" +"\tkp8 = 328\n" +"\tkp9 = 329\n" +"\tkpDecimal = 330\n" +"\tkpDivide = 331\n" +"\tkpMultiply = 332\n" +"\tkpSubtract = 333\n" +"\tkpAdd = 334\n" +"\tkpEnter = 335\n" +"\tkpEqual = 336\n" +"\tleftShift = 340\n" +"\tleftControl = 341\n" +"\tleftAlt = 342\n" +"\tleftSuper = 343\n" +"\trightShift = 344\n" +"\trightControl = 345\n" +"\trightAlt = 346\n" +"\trightSuper = 347\n" +"\tmenu = 348\n" +"}\n" "//~~\n" "\n" "\n" @@ -961,11 +964,11 @@ const char *th_em_modulesrc[] = { "\treturn getMousePos().add(window.getViewportOffset())\n" "}\n" "\n" -"fn umth_input_is_pressed(keycode: int32): int32\n" +"fn umth_input_is_pressed(keycode: Key): int32\n" "//~~fn isPressed\n" "// Returns true if key is pressed. Either use codes defined in the file above,\n" "// or pass lower case char/number.\n" -"fn isPressed*(code: int): bool {\n" +"fn isPressed*(code: Key): bool {\n" "\t//~~\n" "\tval := bool(umth_input_is_pressed(code))\n" "\treturn val\n" @@ -975,13 +978,13 @@ const char *th_em_modulesrc[] = { "// Like `isPressed`, but you can pass char as the code.\n" "fn isPressedc*(code: char): bool {\n" "\t//~~\n" -"\treturn isPressed(toupper(code))\n" +"\treturn isPressed(Key(toupper(code)))\n" "}\n" "\n" -"fn umth_input_is_just_pressed(key: int32): int32\n" +"fn umth_input_is_just_pressed(key: Key): int32\n" "//~~fn isJustPressed\n" "// Returns, whether code was just pressed this loop.\n" -"fn isJustPressed*(code: int): bool {\n" +"fn isJustPressed*(code: Key): bool {\n" "\t//~~\n" "\treturn bool(umth_input_is_just_pressed(code))\n" "}\n" @@ -990,13 +993,13 @@ const char *th_em_modulesrc[] = { "// Like `isJustPressed`, but you can pass char as the code.\n" "fn isJustPressedc*(code: char): bool {\n" "\t//~~\n" -"\treturn isJustPressed(toupper(code))\n" +"\treturn isJustPressed(Key(toupper(code)))\n" "}\n" "\n" -"fn umth_input_is_pressed_repeat(key: int32): int32\n" +"fn umth_input_is_pressed_repeat(key: Key): int32\n" "//~~fn isPressedRepeat\n" "// Returns, whether code was just pressed this loop, with key repeat.\n" -"fn isPressedRepeat*(code: int): bool {\n" +"fn isPressedRepeat*(code: Key): bool {\n" "\t//~~\n" "\treturn bool(umth_input_is_pressed_repeat(code))\n" "}\n" @@ -1005,14 +1008,14 @@ const char *th_em_modulesrc[] = { "// Like `isPressedRepeat`, but you can pass char as the code.\n" "fn isPressedRepeatc*(code: char): bool {\n" "\t//~~\n" -"\treturn isPressedRepeat(toupper(code))\n" +"\treturn isPressedRepeat(Key(toupper(code)))\n" "}\n" "\n" "\n" -"fn umth_input_is_just_released(key: int32): int32\n" +"fn umth_input_is_just_released(key: Key): int32\n" "//~~fn isJustReleased\n" "// Returns true if a key was just released.\n" -"fn isJustReleased*(code: int): bool {\n" +"fn isJustReleased*(code: Key): bool {\n" "\t//~~\n" "\treturn bool(umth_input_is_just_released(code))\n" "}\n" @@ -1020,13 +1023,13 @@ const char *th_em_modulesrc[] = { "// Like `isJustReleased`, but you can pass char as the code.\n" "fn isJustReleasedc*(code: char): bool {\n" "\t//~~\n" -"\treturn isJustReleased(toupper(code))\n" +"\treturn isJustReleased(Key(toupper(code)))\n" "}\n" "\n" -"fn umth_input_clear*(code: int)\n" +"fn umth_input_clear*(code: Key)\n" "//~~fn clear\n" "// Clears both the pressed and justPressed state of a code.\n" -"fn clear*(code: int) {\n" +"fn clear*(code: Key) {\n" "\t//~~\n" "\tumth_input_clear(code)\n" "}\n" @@ -1035,7 +1038,7 @@ const char *th_em_modulesrc[] = { "// Like `clear`, but you can pass char as the code.\n" "fn clearc*(code: char) {\n" "\t//~~\n" -"\tumth_input_clear(toupper(code))\n" +"\tumth_input_clear(Key(toupper(code)))\n" "}\n" "\n" "fn umth_input_get_str(): str\n" @@ -1549,20 +1552,20 @@ const char *th_em_modulesrc[] = { ")\n" "\n" "//~~Cursor types\n" -"const (\n" -"\tcursorDefault* = 0\t\t// Default system cursor\n" -"\tcursorArrow*\t\t\t// Normal cursor; Arrow cursor\n" -"\tcursorIBeam*\t\t\t// \'I\' text cursor; I-Beam\n" -"\tcursorCrosshair*\t\t// \'+\' cursor; Select region cursor\n" -"\tcursorFinger*\t\t\t// Index finger pointing cursor; Click cursor\n" -"\tcursorSizeEW*\t\t\t// \'<->\' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor\n" -"\tcursorSizeNS*\t\t\t// Resize height cursor; Resize vertically cursor; North-South resize cursor\n" -"\tcursorSizeNWSE*\t\t\t// Resize width and height from the right side cursor; Northwest-Southeast resize cursor\n" -"\tcursorSizeSWNE*\t\t\t// Resize width and height from the left side cursor; Southwest-Northeast resize cursor\n" -"\tcursorSizeAll*\t\t\t// Resize all cursor; Move cursor\n" -"\tcursorNo*\t\t\t// \'(/)\' cursor; Disabled cursor; Disallowed cursor\n" -"\tcursorCount_*\n" -")\n" +"type Cursor* = enum {\n" +"\tsystem = 0\t\t// Default system cursor\n" +"\tarrow\t\t\t// Normal cursor; Arrow cursor\n" +"\tiBeam\t\t\t// \'I\' text cursor; I-Beam\n" +"\tcrosshair\t\t// \'+\' cursor; Select region cursor\n" +"\tfinger\t\t\t// Index finger pointing cursor; Click cursor\n" +"\tsizeEW\t\t\t// \'<->\' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor\n" +"\tsizeNS\t\t\t// Resize height cursor; Resize vertically cursor; North-South resize cursor\n" +"\tsizeNWSE\t\t\t// Resize width and height from the right side cursor; Northwest-Southeast resize cursor\n" +"\tsizeSWNE\t\t\t// Resize width and height from the left side cursor; Southwest-Northeast resize cursor\n" +"\tsizeAll\t\t\t// Resize all cursor; Move cursor\n" +"\tno\t\t\t// \'(/)\' cursor; Disabled cursor; Disallowed cursor\n" +"\tcount_\n" +"}\n" "//~~\n" "\n" "//~~Window dimensions\n" @@ -1633,7 +1636,7 @@ const char *th_em_modulesrc[] = { "\tw, h = width, height\n" "\tumth_window_setup(title, width, height)\n" "\n" -"\tth.platform = umth_window_get_platform_id()\n" +"\tth.platform = th.Platform(umth_window_get_platform_id())\n" "\n" "\taudio.__setup()\n" "\tplaceholders.__setup()\n" @@ -1769,10 +1772,10 @@ const char *th_em_modulesrc[] = { "\tumth_window_freeze_cursor(freeze)\n" "}\n" "\n" -"fn umth_window_set_cursor(cursor: int)\n" +"fn umth_window_set_cursor(cursor: Cursor)\n" "//~~fn setCursor\n" "// Allows you to set the displaying cursor. Refer to the cursors section for available cursors.\n" -"fn setCursor*(cursor: int) {\n" +"fn setCursor*(cursor: Cursor) {\n" "//~~\n" "\tumth_window_set_cursor(cursor);\n" "}\n" @@ -1995,19 +1998,19 @@ const char *th_em_modulesrc[] = { ")\n" "\n" "//~~Filtering constants\n" -"const (\n" -"\tfilterNearest* = 0\n" -"\tfilterLinear* = 1\n" -")\n" +"type Filter* = enum {\n" +"\tnearest = 0\n" +"\tlinear = 1\n" +"}\n" "//~~\n" "\n" "//~~opaque Font\n" "type Font* = struct { _: ^struct{} }\n" "//~~\n" "\n" -"fn umth_font_load(path: str, size: th.fu, filter: uint32): ^struct{}\n" +"fn umth_font_load(path: str, size: th.fu, filter: Filter): ^struct{}\n" "//~~fn load\n" -"fn load*(path: str, size: th.fu, filter: uint32 = filterLinear): Font {\n" +"fn load*(path: str, size: th.fu, filter: Filter = Filter.linear): Font {\n" "//~~\n" "\treturn Font{umth_font_load(path, size, filter)}\n" "}\n" @@ -2369,14 +2372,13 @@ const char *th_em_modulesrc[] = { "//~~\n" "\n" "//~~enum Platform\n" -"type Platform* = int\n" -"const (\n" -"\tPlatformUnknown* = 0\n" -"\tPlatformLinux*\n" -"\tPlatformWindows*\n" -"\tPlatformMacOs*\n" -"\tPlatformWeb*\n" -")\n" +"type Platform* = enum {\n" +"\tunknown\n" +"\tlinux\n" +"\twindows\n" +"\tmacOs\n" +"\tweb\n" +"}\n" "//~~\n" "\n" "//~~Misc variables\n" @@ -3133,21 +3135,21 @@ const char *th_em_modulesrc[] = { "// Runs the evaluation phase on `layout`.\n" "fn (this: ^Gui) eval*(layout: LayoutFn) {\n" "//~~\n" -"\tif input.isJustPressed(input.mouse1) { this.m1Pressed = true }\n" -"\tif input.isJustReleased(input.mouse1) { this.m1Pressed = false }\n" -"\tif input.isJustPressed(input.mouse2) { this.m2Pressed = true }\n" -"\tif input.isJustReleased(input.mouse2) { this.m2Pressed = false }\n" -"\tif input.isJustPressed(input.mouse3) { this.m3Pressed = true }\n" -"\tif input.isJustReleased(input.mouse3) { this.m3Pressed = false }\n" +"\tif input.isJustPressed(input.Key.mouse1) { this.m1Pressed = true }\n" +"\tif input.isJustReleased(input.Key.mouse1) { this.m1Pressed = false }\n" +"\tif input.isJustPressed(input.Key.mouse2) { this.m2Pressed = true }\n" +"\tif input.isJustReleased(input.Key.mouse2) { this.m2Pressed = false }\n" +"\tif input.isJustPressed(input.Key.mouse3) { this.m3Pressed = true }\n" +"\tif input.isJustReleased(input.Key.mouse3) { this.m3Pressed = false }\n" "\n" "\tthis.idx = 0\n" "\tthis.isEval = true\n" "\tlayout(this)\n" "\n" "\tif this.hover(this.container[0].getDims()) {\n" -"\t\t\tinput.clear(input.mouse1)\n" -"\t\t\tinput.clear(input.mouse2)\n" -"\t\t\tinput.clear(input.mouse3)\n" +"\t\t\tinput.clear(input.Key.mouse1)\n" +"\t\t\tinput.clear(input.Key.mouse2)\n" +"\t\t\tinput.clear(input.Key.mouse3)\n" "\t}\n" "}\n" "\n" @@ -3162,27 +3164,22 @@ const char *th_em_modulesrc[] = { "\n" "//~~enum BoxGrow\n" "// The different types of \"growing\" the box can do.\n" -"type BoxGrow* = uint\n" -"const (\n" -"\t// Increments by an amount set by the user.\n" -"\tBoxGrowDimension* = BoxGrow(0)\n" -"\t// Divides the container into `n` equal parts.\n" -"\tBoxGrowSubdivision* = BoxGrow(1)\n" -"\t// Grows the box based on values in the span array.\n" -"\tBoxGrowSpan* = BoxGrow(2)\n" -"\tBoxGrowPxSpan* = BoxGrow(3)\n" -")\n" +"type BoxGrow* = enum {\n" +"\tdimension\n" +"\tsubdiv\n" +"\tspan\n" +"\tpxSpan\n" +"}\n" "//~~\n" "\n" "//~~enum BoxDirection\n" "// Direction in which the box will grow.\n" -"type BoxDirection* = uint\n" -"const (\n" -"\tBoxDirectionDown* = BoxDirection(0)\n" -"\tBoxDirectionRight* = BoxDirection(1)\n" -"\tBoxDirectionUp* = BoxDirection(2)\n" -"\tBoxDirectionLeft* = BoxDirection(3)\n" -")\n" +"type BoxDir* = enum {\n" +"\tdown\n" +"\tright\n" +"\tup\n" +"\tleft\n" +"}\n" "//~~\n" "\n" "//~~struct BoxConfig\n" @@ -3195,7 +3192,7 @@ const char *th_em_modulesrc[] = { "\t// the grow type\n" "\tgrowType: BoxGrow\n" "\t// the grow direction\n" -"\tdir: BoxDirection\n" +"\tdir: BoxDir\n" "\t// Specifies the values used with BoxGrowSpan nad BoxGrowPxSpan.\n" "\t// If BoxGrowSpan is used, 1 equals the size of the box divided by the sum\n" "\t// of all spans.\n" @@ -3225,16 +3222,16 @@ const char *th_em_modulesrc[] = { "fn (this: ^Box) getGrow(): th.fu {\n" "\tswitch this.cfg.growType {\n" "\t// These values are constant and can therefore be only calculated once.\n" -"\tcase BoxGrowDimension:\n" +"\tcase BoxGrow.dimension:\n" "\t\treturn this.grow\n" -"\tcase BoxGrowSubdivision:\n" +"\tcase BoxGrow.subdiv:\n" "\t\treturn this.grow\n" -"\tcase BoxGrowSpan:\n" +"\tcase BoxGrow.span:\n" "\t\t// We store the amount of pixels per a span in the grow array.\n" "\t\tsp := this.cfg.span[this.spanCursor]\n" "\t\tthis.spanCursor = (this.spanCursor + 1) % len(this.cfg.span)\n" "\t\treturn sp * this.grow\n" -"\tcase BoxGrowPxSpan:\n" +"\tcase BoxGrow.pxSpan:\n" "\t\tsp := this.cfg.span[this.spanCursor]\n" "\t\tthis.spanCursor = (this.spanCursor + 1) % len(this.cfg.span)\n" "\t\treturn sp\n" @@ -3245,7 +3242,7 @@ const char *th_em_modulesrc[] = { "\n" "fn (this: ^Box) pushRect(r: rect.Rect): rect.Rect {\n" "\tswitch this.cfg.dir {\n" -"\tcase BoxDirectionDown:\n" +"\tcase BoxDir.down:\n" "\t\tr.x = this.dm.x\n" "\t\tr.y = this.dm.y\n" "\n" @@ -3258,7 +3255,7 @@ const char *th_em_modulesrc[] = { "\t\t}\n" "\n" "\t\tthis.dm.y += r.h + this.cfg.padding\n" -"\tcase BoxDirectionRight:\n" +"\tcase BoxDir.right:\n" "\t\tr.x = this.dm.x\n" "\t\tr.y = this.dm.y\n" "\n" @@ -3271,7 +3268,7 @@ const char *th_em_modulesrc[] = { "\t\t}\n" "\n" "\t\tthis.dm.x += r.w + this.cfg.padding\n" -"\tcase BoxDirectionUp:\n" +"\tcase BoxDir.up:\n" "\t\tif r.h == 0 {\n" "\t\t\tr.h = this.getGrow()\n" "\t\t}\n" @@ -3283,7 +3280,7 @@ const char *th_em_modulesrc[] = { "\t\tthis.dm.h -= r.h + this.cfg.padding\n" "\t\tr.x = this.dm.x\n" "\t\tr.y = this.dm.y + this.dm.h\n" -"\tcase BoxDirectionLeft:\n" +"\tcase BoxDir.left:\n" "\t\tif r.h == 0 {\n" "\t\t\tr.h = this.dm.h\n" "\t\t}\n" @@ -3308,8 +3305,8 @@ const char *th_em_modulesrc[] = { "// Adds the `Box` container to the gui.\n" "fn (gui: ^Gui) box*(cfg: BoxConfig = {\n" "\tdimension: 30,\n" -"\tgrowType: BoxGrowDimension,\n" -"\tdir: BoxDirectionDown }) {\n" +"\tgrowType: BoxGrow.dimension,\n" +"\tdir: BoxDir.down }) {\n" "//~~\n" "\n" "\tb := Box{}\n" @@ -3317,21 +3314,21 @@ const char *th_em_modulesrc[] = { "\tb.cfg = cfg\n" "\n" "\tdm := b.dm.h\n" -"\tif cfg.dir == BoxDirectionRight || cfg.dir == BoxDirectionLeft {\n" +"\tif cfg.dir == BoxDir.right || cfg.dir == BoxDir.left {\n" "\t\tdm = b.dm.w\n" "\t}\n" "\tdm += b.cfg.padding\n" "\n" "\tswitch cfg.growType {\n" -"\tcase BoxGrowDimension:\n" +"\tcase BoxGrow.dimension:\n" "\t\tb.grow = cfg.dimension\n" -"\tcase BoxGrowSubdivision:\n" +"\tcase BoxGrow.subdiv:\n" "\t\tif cfg.subdivisions == 0 {\n" "\t\t\tth.__error(\"Invalid subdivision count\")\n" "\t\t}\n" "\n" "\t\tb.grow = dm / cfg.subdivisions\n" -"\tcase BoxGrowSpan:\n" +"\tcase BoxGrow.span:\n" "\t\ts := th.fu(0)\n" "\t\tfor _,v in b.cfg.span {\n" "\t\t\ts += v\n" @@ -3489,7 +3486,7 @@ const char *th_em_modulesrc[] = { "\tr := gui.getContainer().getDims()\n" "\n" "\tif gui.isEval {\n" -"\t\tif gui.hover(r) && input.isJustReleased(input.mouse1) {\n" +"\t\tif gui.hover(r) && input.isJustReleased(input.Key.mouse1) {\n" "\t\t\treturn true\n" "\t\t}\n" "\t\treturn false\n" @@ -3623,16 +3620,16 @@ const char *th_em_modulesrc[] = { "\thover := gui.hover(r)\n" "\n" "\tif gui.isEval {\n" -"\t\tif input.isJustPressed(input.mouse1) && hover {\n" +"\t\tif input.isJustPressed(input.Key.mouse1) && hover {\n" "\t\t\tgui.selection = gui.idx\n" "\t\t}\n" "\n" -"\t\tif input.isJustPressed(input.mouse1) && !hover &&\n" +"\t\tif input.isJustPressed(input.Key.mouse1) && !hover &&\n" "\t\t\tgui.selection == gui.idx {\n" "\t\t\t\tgui.selection = 0\n" "\t\t}\n" "\n" -"\t\tif input.isJustPressed(input.key_escape) && gui.selection == gui.idx {\n" +"\t\tif input.isJustPressed(input.Key.escape) && gui.selection == gui.idx {\n" "\t\t\tgui.selection = 0\n" "\t\t}\n" "\n" @@ -3640,7 +3637,7 @@ const char *th_em_modulesrc[] = { "\t\t\treturn\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_backspace) {\n" +"\t\tif input.isPressedRepeat(input.Key.backspace) {\n" "\n" "\t\t\tif tb.cursor > 0 {\n" "\t\t\t\ttb.buffer = append(slice(tb.buffer, 0, tb.cursor - 1), slice(tb.buffer, tb.cursor))\n" @@ -3648,24 +3645,24 @@ const char *th_em_modulesrc[] = { "\t\t\t}\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_delete) {\n" +"\t\tif input.isPressedRepeat(input.Key.delete) {\n" "\n" "\t\t\tif tb.cursor >= 0 && tb.cursor < len(tb.buffer) {\n" "\t\t\t\ttb.buffer = append(slice(tb.buffer, 0, tb.cursor), slice(tb.buffer, tb.cursor+1))\n" "\t\t\t}\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_home) {\n" +"\t\tif input.isPressedRepeat(input.Key.home) {\n" "\t\t\ttb.cursor = 0\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_end) {\n" +"\t\tif input.isPressedRepeat(input.Key.end) {\n" "\t\t\ttb.cursor = len(tb.buffer)\n" "\t\t}\n" "\n" "\t\tv := true\n" "\n" -"\t\tif input.isPressed(input.key_ctrl) && input.isJustPressedc(\'v\') {\n" +"\t\tif input.isPressed(input.Key.ctrl) && input.isJustPressedc(\'v\') {\n" "\t\t\ttoInsert := utf8.decode(window.getClipboard())\n" "\n" "\t\t\ttb.buffer = append(append(slice(tb.buffer, 0, tb.cursor), toInsert), slice(tb.buffer, tb.cursor))\n" @@ -3673,12 +3670,12 @@ const char *th_em_modulesrc[] = { "\t\t\tv = false\n" "\t\t}\n" "\n" -"\t\tif input.isPressed(input.key_ctrl) && input.isJustPressedc(\'c\') {\n" +"\t\tif input.isPressed(input.Key.ctrl) && input.isJustPressedc(\'c\') {\n" "\t\t\twindow.setClipboard(utf8.encode(tb.buffer))\n" "\t\t\tv = false\n" "\t\t}\n" "\n" -"\t\tif input.isPressed(input.key_ctrl) && input.isJustPressedc(\'u\') {\n" +"\t\tif input.isPressed(input.Key.ctrl) && input.isJustPressedc(\'u\') {\n" "\t\t\ttb.clear()\n" "\t\t\tv = false\n" "\t\t}\n" @@ -3687,7 +3684,7 @@ const char *th_em_modulesrc[] = { "\t\t\treturn r == utf8.Rune(\' \') || r == utf8.Rune(\'\\t\') || r == utf8.Rune(\'\\n\')\n" "\t\t}\n" "\n" -"\t\tif input.isPressed(input.key_ctrl) && input.isPressedRepeat(input.key_left) {\n" +"\t\tif input.isPressed(input.Key.ctrl) && input.isPressedRepeat(input.Key.left) {\n" "\t\t\t// skip spaces\n" "\t\t\tfor tb.cursor > 0 && isRuneSpace(tb.buffer[tb.cursor-1]) {\n" "\t\t\t\ttb.cursor--\n" @@ -3699,7 +3696,7 @@ const char *th_em_modulesrc[] = { "\t\t\tv = false\n" "\t\t}\n" "\n" -"\t\tif input.isPressed(input.key_ctrl) && input.isPressedRepeat(input.key_right) {\n" +"\t\tif input.isPressed(input.Key.ctrl) && input.isPressedRepeat(input.Key.right) {\n" "\t\t\t// skip spaces\n" "\t\t\tfor tb.cursor < len(tb.buffer) && isRuneSpace(tb.buffer[tb.cursor]) {\n" "\t\t\t\ttb.cursor++\n" @@ -3711,11 +3708,11 @@ const char *th_em_modulesrc[] = { "\t\t\tv = false\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_left) && v {\n" +"\t\tif input.isPressedRepeat(input.Key.left) && v {\n" "\t\t\tif tb.cursor > 0 { tb.cursor-- }\n" "\t\t}\n" "\n" -"\t\tif input.isPressedRepeat(input.key_right) && v {\n" +"\t\tif input.isPressedRepeat(input.Key.right) && v {\n" "\t\t\tif tb.cursor < len(tb.buffer) { tb.cursor++ }\n" "\t\t}\n" "\n" @@ -3947,10 +3944,24 @@ const char *th_em_moduledocs[] = { "Represents an instance of a playable sound. It is an opaque structure.\n" "\n" "\n" +"## enum LoadFlag\n" +"\n" +"```\n" +"type LoadFlag* = enum {\n" +"\t// Streams the audio, only saving 2 seconds into memory.\n" +"\tstream = 1\n" +"\t// Loads the sound in async. Use `audio.waitForLoad` to wait for the\n" +"\t// sounds to load.\n" +"\tasync = 4\n" +"}\n" +"```\n" +"\n" +"\n" +"\n" "## fn load\n" "\n" "```\n" -"fn load*(path: str, flags: LoadFlag = 0): Sound {\n" +"fn load*(path: str, flags: LoadFlag = LoadFlag.stream): Sound {\n" "```\n" "\n" "Loads a sounds at path, if there is an error, the underlying pointer\n" @@ -4251,7 +4262,9 @@ const char *th_em_moduledocs[] = { "fn (rt: ^RenderTarget) toImage*(): Image {\n" "```\n" "\n" -"Returns the image of the render target.\n" +"Returns the image of the render target. The resulting image has the same\n" +"lifetime as the base RenderTarget. If you need to use it past the lifetime\n" +"of the RenderTarget, use the copy method.\n" "Do not call `setfilter` on the resulting image.\n" "\n" "\n" @@ -4445,137 +4458,137 @@ const char *th_em_moduledocs[] = { "## Keycode constants\n" "\n" "```\n" -"const (\n" -"\tmouse1* = 1 // NOTE: mouse 2 and 3 key codes are swapped\n" -"\tmouse2* = 3 // because sokol uses 3 for middle mouse\n" -"\tmouse3* = 2 // button.\n" -"\n" -"\tkey_ctrl* = 16\n" -"\tkey_shift* = 17\n" -"\tkey_alt* = 18\n" -"\n" -"\tkey_space* = 32\n" -"\tkey_apostrophe* = 39 /* \' */\n" -"\tkey_comma* = 44 /* , */\n" -"\tkey_minus* = 45 /* - */\n" -"\tkey_dot* = 46 /* . */\n" -"\tkey_slash* = 47 /* / */\n" -"\tkey_0* = 48\n" -"\tkey_1* = 49\n" -"\tkey_2* = 50\n" -"\tkey_3* = 51\n" -"\tkey_4* = 52\n" -"\tkey_5* = 53\n" -"\tkey_6* = 54\n" -"\tkey_7* = 55\n" -"\tkey_8* = 56\n" -"\tkey_9* = 57\n" -"\tkey_semicolon* = 59 /* ; */\n" -"\tkey_equal* = 61 /* = */\n" -"\tkey_a* = 65\n" -"\tkey_b* = 66\n" -"\tkey_c* = 67\n" -"\tkey_d* = 68\n" -"\tkey_e* = 69\n" -"\tkey_f* = 70\n" -"\tkey_g* = 71\n" -"\tkey_h* = 72\n" -"\tkey_i* = 73\n" -"\tkey_j* = 74\n" -"\tkey_k* = 75\n" -"\tkey_l* = 76\n" -"\tkey_m* = 77\n" -"\tkey_n* = 78\n" -"\tkey_o* = 79\n" -"\tkey_p* = 80\n" -"\tkey_q* = 81\n" -"\tkey_r* = 82\n" -"\tkey_s* = 83\n" -"\tkey_t* = 84\n" -"\tkey_u* = 85\n" -"\tkey_v* = 86\n" -"\tkey_w* = 87\n" -"\tkey_x* = 88\n" -"\tkey_y* = 89\n" -"\tkey_z* = 90\n" -"\tkey_left_bracket* = 91 /* [ */\n" -"\tkey_backslash* = 92 /* \\ */\n" -"\tkey_right_bracket* = 93 /* ] */\n" -"\tkey_grave_accent* = 96 /* ` */\n" -"\tkey_world_1* = 161 /* non-US #1 */\n" -"\tkey_world_2* = 162 /* non-US #2 */\n" -"\tkey_escape* = 256\n" -"\tkey_enter* = 257\n" -"\tkey_tab* = 258\n" -"\tkey_backspace* = 259\n" -"\tkey_insert* = 260\n" -"\tkey_delete* = 261\n" -"\tkey_right* = 262\n" -"\tkey_left* = 263\n" -"\tkey_down* = 264\n" -"\tkey_up* = 265\n" -"\tkey_page_up* = 266\n" -"\tkey_page_down* = 267\n" -"\tkey_home* = 268\n" -"\tkey_end* = 269\n" -"\tkey_caps_lock* = 280\n" -"\tkey_scroll_lock* = 281\n" -"\tkey_num_lock* = 282\n" -"\tkey_print_screen* = 283\n" -"\tkey_pause* = 284\n" -"\tkey_fn* = 289\n" -"\tkey_fn1* = 290\n" -"\tkey_fn2* = 291\n" -"\tkey_fn3* = 292\n" -"\tkey_fn4* = 293\n" -"\tkey_fn5* = 294\n" -"\tkey_fn6* = 295\n" -"\tkey_fn7* = 296\n" -"\tkey_fn8* = 297\n" -"\tkey_fn9* = 298\n" -"\tkey_fn10* = 299\n" -"\tkey_fn11* = 300\n" -"\tkey_fn12* = 301\n" -"\tkey_fn13* = 302\n" -"\tkey_fn14* = 303\n" -"\tkey_fn15* = 304\n" -"\tkey_fn16* = 305\n" -"\tkey_fn17* = 306\n" -"\tkey_fn18* = 307\n" -"\tkey_fn19* = 308\n" -"\tkey_fn20* = 309\n" -"\tkey_fn21* = 310\n" -"\tkey_fn22* = 311\n" -"\tkey_fn23* = 312\n" -"\tkey_fn24* = 313\n" -"\tkey_fn25* = 314\n" -"\tkey_kp_0* = 320\n" -"\tkey_kp_1* = 321\n" -"\tkey_kp_2* = 322\n" -"\tkey_kp_3* = 323\n" -"\tkey_kp_4* = 324\n" -"\tkey_kp_5* = 325\n" -"\tkey_kp_6* = 326\n" -"\tkey_kp_7* = 327\n" -"\tkey_kp_8* = 328\n" -"\tkey_kp_9* = 329\n" -"\tkey_kp_decimal* = 330\n" -"\tkey_kp_divide* = 331\n" -"\tkey_kp_multiply* = 332\n" -"\tkey_kp_subtract* = 333\n" -"\tkey_kp_add* = 334\n" -"\tkey_kp_enter* = 335\n" -"\tkey_kp_equal* = 336\n" -"\tkey_left_shift* = 340\n" -"\tkey_left_control* = 341\n" -"\tkey_left_alt* = 342\n" -"\tkey_left_super* = 343\n" -"\tkey_right_shift* = 344\n" -"\tkey_right_control* = 345\n" -"\tkey_right_alt* = 346\n" -"\tkey_right_super* = 347\n" -"\tkey_menu* = 348\n" -")\n" +"type Key* = enum {\n" +"\tmouse1 = 1 // NOTE: mouse 2 and 3 key codes are swapped\n" +"\tmouse2 = 3 // because sokol uses 3 for middle mouse\n" +"\tmouse3 = 2 // button.\n" +"\n" +"\tctrl = 16\n" +"\tshift = 17\n" +"\talt = 18\n" +"\n" +"\tspace = 32\n" +"\tapostrophe = 39 /* \' */\n" +"\tcomma = 44 /* , */\n" +"\tminus = 45 /* - */\n" +"\tdot = 46 /* . */\n" +"\tslash = 47 /* / */\n" +"\tnum0 = 48\n" +"\tnum1 = 49\n" +"\tnum2 = 50\n" +"\tnum3 = 51\n" +"\tnum4 = 52\n" +"\tnum5 = 53\n" +"\tnum6 = 54\n" +"\tnum7 = 55\n" +"\tnum8 = 56\n" +"\tnum9 = 57\n" +"\tsemicolon = 59 /* ; */\n" +"\tequal = 61 /* = */\n" +"\ta = 65\n" +"\tb = 66\n" +"\tc = 67\n" +"\td = 68\n" +"\te = 69\n" +"\tf = 70\n" +"\tg = 71\n" +"\th = 72\n" +"\ti = 73\n" +"\tj = 74\n" +"\tk = 75\n" +"\tl = 76\n" +"\tm = 77\n" +"\tn = 78\n" +"\to = 79\n" +"\tp = 80\n" +"\tq = 81\n" +"\tr = 82\n" +"\ts = 83\n" +"\tt = 84\n" +"\tu = 85\n" +"\tv = 86\n" +"\tw = 87\n" +"\tx = 88\n" +"\ty = 89\n" +"\tz = 90\n" +"\tleftBracket = 91 /* [ */\n" +"\tbackslash = 92 /* \\ */\n" +"\trightBracket = 93 /* ] */\n" +"\tgraveAccent = 96 /* ` */\n" +"\tworld1 = 161 /* non-US #1 */\n" +"\tworld2 = 162 /* non-US #2 */\n" +"\tescape = 256\n" +"\tenter = 257\n" +"\ttab = 258\n" +"\tbackspace = 259\n" +"\tinsert = 260\n" +"\tdelete = 261\n" +"\tright = 262\n" +"\tleft = 263\n" +"\tdown = 264\n" +"\tup = 265\n" +"\tpageUp = 266\n" +"\tpageDown = 267\n" +"\thome = 268\n" +"\tend = 269\n" +"\tcapsLock = 280\n" +"\tscrollLock = 281\n" +"\tnumLock = 282\n" +"\tprintScreen = 283\n" +"\tpause = 284\n" +"\tfn0 = 289\n" +"\tfn1 = 290\n" +"\tfn2 = 291\n" +"\tfn3 = 292\n" +"\tfn4 = 293\n" +"\tfn5 = 294\n" +"\tfn6 = 295\n" +"\tfn7 = 296\n" +"\tfn8 = 297\n" +"\tfn9 = 298\n" +"\tfn10 = 299\n" +"\tfn11 = 300\n" +"\tfn12 = 301\n" +"\tfn13 = 302\n" +"\tfn14 = 303\n" +"\tfn15 = 304\n" +"\tfn16 = 305\n" +"\tfn17 = 306\n" +"\tfn18 = 307\n" +"\tfn19 = 308\n" +"\tfn20 = 309\n" +"\tfn21 = 310\n" +"\tfn22 = 311\n" +"\tfn23 = 312\n" +"\tfn24 = 313\n" +"\tfn25 = 314\n" +"\tkp0 = 320\n" +"\tkp1 = 321\n" +"\tkp2 = 322\n" +"\tkp3 = 323\n" +"\tkp4 = 324\n" +"\tkp5 = 325\n" +"\tkp6 = 326\n" +"\tkp7 = 327\n" +"\tkp8 = 328\n" +"\tkp9 = 329\n" +"\tkpDecimal = 330\n" +"\tkpDivide = 331\n" +"\tkpMultiply = 332\n" +"\tkpSubtract = 333\n" +"\tkpAdd = 334\n" +"\tkpEnter = 335\n" +"\tkpEqual = 336\n" +"\tleftShift = 340\n" +"\tleftControl = 341\n" +"\tleftAlt = 342\n" +"\tleftSuper = 343\n" +"\trightShift = 344\n" +"\trightControl = 345\n" +"\trightAlt = 346\n" +"\trightSuper = 347\n" +"\tmenu = 348\n" +"}\n" "```\n" "\n" "\n" @@ -4601,7 +4614,7 @@ const char *th_em_moduledocs[] = { "## fn isPressed\n" "\n" "```\n" -"fn isPressed*(code: int): bool {\n" +"fn isPressed*(code: Key): bool {\n" "```\n" "\n" "Returns true if key is pressed. Either use codes defined in the file above,\n" @@ -4620,7 +4633,7 @@ const char *th_em_moduledocs[] = { "## fn isJustPressed\n" "\n" "```\n" -"fn isJustPressed*(code: int): bool {\n" +"fn isJustPressed*(code: Key): bool {\n" "```\n" "\n" "Returns, whether code was just pressed this loop.\n" @@ -4638,7 +4651,7 @@ const char *th_em_moduledocs[] = { "## fn isPressedRepeat\n" "\n" "```\n" -"fn isPressedRepeat*(code: int): bool {\n" +"fn isPressedRepeat*(code: Key): bool {\n" "```\n" "\n" "Returns, whether code was just pressed this loop, with key repeat.\n" @@ -4656,7 +4669,7 @@ const char *th_em_moduledocs[] = { "## fn isJustReleased\n" "\n" "```\n" -"fn isJustReleased*(code: int): bool {\n" +"fn isJustReleased*(code: Key): bool {\n" "```\n" "\n" "Returns true if a key was just released.\n" @@ -4674,7 +4687,7 @@ const char *th_em_moduledocs[] = { "## fn clear\n" "\n" "```\n" -"fn clear*(code: int) {\n" +"fn clear*(code: Key) {\n" "```\n" "\n" "Clears both the pressed and justPressed state of a code.\n" @@ -5113,20 +5126,20 @@ const char *th_em_moduledocs[] = { "## Cursor types\n" "\n" "```\n" -"const (\n" -"\tcursorDefault* = 0\t\t// Default system cursor\n" -"\tcursorArrow*\t\t\t// Normal cursor; Arrow cursor\n" -"\tcursorIBeam*\t\t\t// \'I\' text cursor; I-Beam\n" -"\tcursorCrosshair*\t\t// \'+\' cursor; Select region cursor\n" -"\tcursorFinger*\t\t\t// Index finger pointing cursor; Click cursor\n" -"\tcursorSizeEW*\t\t\t// \'<->\' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor\n" -"\tcursorSizeNS*\t\t\t// Resize height cursor; Resize vertically cursor; North-South resize cursor\n" -"\tcursorSizeNWSE*\t\t\t// Resize width and height from the right side cursor; Northwest-Southeast resize cursor\n" -"\tcursorSizeSWNE*\t\t\t// Resize width and height from the left side cursor; Southwest-Northeast resize cursor\n" -"\tcursorSizeAll*\t\t\t// Resize all cursor; Move cursor\n" -"\tcursorNo*\t\t\t// \'(/)\' cursor; Disabled cursor; Disallowed cursor\n" -"\tcursorCount_*\n" -")\n" +"type Cursor* = enum {\n" +"\tsystem = 0\t\t// Default system cursor\n" +"\tarrow\t\t\t// Normal cursor; Arrow cursor\n" +"\tiBeam\t\t\t// \'I\' text cursor; I-Beam\n" +"\tcrosshair\t\t// \'+\' cursor; Select region cursor\n" +"\tfinger\t\t\t// Index finger pointing cursor; Click cursor\n" +"\tsizeEW\t\t\t// \'<->\' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor\n" +"\tsizeNS\t\t\t// Resize height cursor; Resize vertically cursor; North-South resize cursor\n" +"\tsizeNWSE\t\t\t// Resize width and height from the right side cursor; Northwest-Southeast resize cursor\n" +"\tsizeSWNE\t\t\t// Resize width and height from the left side cursor; Southwest-Northeast resize cursor\n" +"\tsizeAll\t\t\t// Resize all cursor; Move cursor\n" +"\tno\t\t\t// \'(/)\' cursor; Disabled cursor; Disallowed cursor\n" +"\tcount_\n" +"}\n" "```\n" "\n" "\n" @@ -5299,7 +5312,7 @@ const char *th_em_moduledocs[] = { "## fn setCursor\n" "\n" "```\n" -"fn setCursor*(cursor: int) {\n" +"fn setCursor*(cursor: Cursor) {\n" "```\n" "\n" "Allows you to set the displaying cursor. Refer to the cursors section for available cursors.\n" @@ -5447,10 +5460,10 @@ const char *th_em_moduledocs[] = { "## Filtering constants\n" "\n" "```\n" -"const (\n" -"\tfilterNearest* = 0\n" -"\tfilterLinear* = 1\n" -")\n" +"type Filter* = enum {\n" +"\tnearest = 0\n" +"\tlinear = 1\n" +"}\n" "```\n" "\n" "\n" @@ -5466,7 +5479,7 @@ const char *th_em_moduledocs[] = { "## fn load\n" "\n" "```\n" -"fn load*(path: str, size: th.fu, filter: uint32 = filterLinear): Font {\n" +"fn load*(path: str, size: th.fu, filter: Filter = Filter.linear): Font {\n" "```\n" "\n" "\n" @@ -5850,14 +5863,13 @@ const char *th_em_moduledocs[] = { "## enum Platform\n" "\n" "```\n" -"type Platform* = int\n" -"const (\n" -"\tPlatformUnknown* = 0\n" -"\tPlatformLinux*\n" -"\tPlatformWindows*\n" -"\tPlatformMacOs*\n" -"\tPlatformWeb*\n" -")\n" +"type Platform* = enum {\n" +"\tunknown\n" +"\tlinux\n" +"\twindows\n" +"\tmacOs\n" +"\tweb\n" +"}\n" "```\n" "\n" "\n" @@ -6618,16 +6630,12 @@ const char *th_em_moduledocs[] = { "## enum BoxGrow\n" "\n" "```\n" -"type BoxGrow* = uint\n" -"const (\n" -"\t// Increments by an amount set by the user.\n" -"\tBoxGrowDimension* = BoxGrow(0)\n" -"\t// Divides the container into `n` equal parts.\n" -"\tBoxGrowSubdivision* = BoxGrow(1)\n" -"\t// Grows the box based on values in the span array.\n" -"\tBoxGrowSpan* = BoxGrow(2)\n" -"\tBoxGrowPxSpan* = BoxGrow(3)\n" -")\n" +"type BoxGrow* = enum {\n" +"\tdimension\n" +"\tsubdiv\n" +"\tspan\n" +"\tpxSpan\n" +"}\n" "```\n" "\n" "The different types of \"growing\" the box can do.\n" @@ -6636,13 +6644,12 @@ const char *th_em_moduledocs[] = { "## enum BoxDirection\n" "\n" "```\n" -"type BoxDirection* = uint\n" -"const (\n" -"\tBoxDirectionDown* = BoxDirection(0)\n" -"\tBoxDirectionRight* = BoxDirection(1)\n" -"\tBoxDirectionUp* = BoxDirection(2)\n" -"\tBoxDirectionLeft* = BoxDirection(3)\n" -")\n" +"type BoxDir* = enum {\n" +"\tdown\n" +"\tright\n" +"\tup\n" +"\tleft\n" +"}\n" "```\n" "\n" "Direction in which the box will grow.\n" @@ -6659,7 +6666,7 @@ const char *th_em_moduledocs[] = { "\t// the grow type\n" "\tgrowType: BoxGrow\n" "\t// the grow direction\n" -"\tdir: BoxDirection\n" +"\tdir: BoxDir\n" "\t// Specifies the values used with BoxGrowSpan nad BoxGrowPxSpan.\n" "\t// If BoxGrowSpan is used, 1 equals the size of the box divided by the sum\n" "\t// of all spans.\n" @@ -6698,8 +6705,8 @@ const char *th_em_moduledocs[] = { "```\n" "fn (gui: ^Gui) box*(cfg: BoxConfig = {\n" "\tdimension: 30,\n" -"\tgrowType: BoxGrowDimension,\n" -"\tdir: BoxDirectionDown }) {\n" +"\tgrowType: BoxGrow.dimension,\n" +"\tdir: BoxDir.down }) {\n" "```\n" "\n" "Adds the `Box` container to the gui.\n" diff --git a/tests/allt.um b/tests/allt.um index 83584920..6e871337 100644 --- a/tests/allt.um +++ b/tests/allt.um @@ -1,5 +1,5 @@ // Test for import warnings and errors. -// Autogenerated by `cmd/buildallt.sh` +// Autogenerated by `cmd/buildallt.sh` import ( "anim.um" "atlas.um" @@ -26,5 +26,4 @@ import ( "window.um" ) -fn init*() { -} +fn init*() { } diff --git a/tests/canvast.um b/tests/canvast.um index 9fe0f22c..3fda5c35 100644 --- a/tests/canvast.um +++ b/tests/canvast.um @@ -29,22 +29,22 @@ fn init*() { img.draw(th.Transform{p: th.Vf2{10, 40}, s: th.Vf2{1, 1}}, th.white) - if input.isPressed(input.key_right) { + if input.isPressed(input.Key.right) { window.setViewportOffset( window.getViewportOffset().add({ th.delta * 0.2, 0 })) } - if input.isPressed(input.key_left) { + if input.isPressed(input.Key.left) { window.setViewportOffset( window.getViewportOffset().sub({ th.delta * 0.2, 0 })) } - if input.isPressed(input.key_down) { + if input.isPressed(input.Key.down) { window.setViewportOffset( window.getViewportOffset().add({ 0, th.delta * 0.2 })) } - if input.isPressed(input.key_up) { + if input.isPressed(input.Key.up) { window.setViewportOffset( window.getViewportOffset().sub({ 0, th.delta * 0.2 })) } diff --git a/tests/cursort.um b/tests/cursort.um index 4d3cd2d3..25f15c10 100644 --- a/tests/cursort.um +++ b/tests/cursort.um @@ -9,15 +9,15 @@ import ( fn init*() { window.setup("Cursor test", 400, 400) - cursor := new(int) - cursor ^= 0 - + cursor := new(int) + cursor ^= 0 + window.onFrame.register(|cursor| { cursor ^+= trunc(input.getMouseScroll().y) > 0 ? 1 : 0 cursor ^+= trunc(input.getMouseScroll().y) < 0 ? -1 : 0 - cursor ^%= window.cursorCount_ + cursor ^%= int(window.Cursor.count_) cursor ^= cursor^ < 0 ? 0 : cursor^ - window.setCursor(cursor^) + window.setCursor(window.Cursor(cursor^)) canvas.drawText(sprintf("Select cursor with\nscrollwheel: %d", cursor^), {10, 10}, th.red, 3) }) } diff --git a/tests/dpit.um b/tests/dpit.um index 44bf43b0..7e93e68c 100644 --- a/tests/dpit.um +++ b/tests/dpit.um @@ -14,7 +14,7 @@ dpiEnabled := false fn init*() { window.setup("DPI Awareness Test", trunc(400*window.getDpiScaleFactor()), trunc(400*window.getDpiScaleFactor())) window.setViewport(window.getDims()) - f = font.load("etc/roboto.ttf", 64, 1) + f = font.load("etc/roboto.ttf", 64) if f.validate() == false { exit(1, "Invalid font."); } @@ -23,8 +23,8 @@ fn init*() { window.onFrame.register(signal.Callback{ dpiStr := "DPI Awareness Test\n" - dpiStr += sprintf("Scale: %g\n", window.getDpiScaleFactor()) - dpiStr += sprintf("DPI Enabled: %v\n", dpiEnabled) + dpiStr += sprintf("Scale: %g\n", window.getDpiScaleFactor()) + dpiStr += sprintf("DPI Enabled: %v\n", dpiEnabled) f.draw(dpiStr, th.Vf2{0, 0}, 0x000000FF, window.getDpiScaleFactor()*0.5) }) } diff --git a/tests/fontt.um b/tests/fontt.um index 5fcd1303..2ce87f55 100644 --- a/tests/fontt.um +++ b/tests/fontt.um @@ -18,7 +18,7 @@ fn drawTextRect(text: str, pos: th.Vf2, scale: real = 1.0) { fn init*() { window.setup("my title", 400, 400) window.setViewport(th.Vf2{400, 400}) - f = font.load("etc/roboto.ttf", 16, 0) + f = font.load("etc/roboto.ttf", 16, font.Filter.nearest) if f.validate() == false { exit(1, "Invalid font."); } diff --git a/tests/fullscreent.um b/tests/fullscreent.um index 62956d0d..0690f57a 100644 --- a/tests/fullscreent.um +++ b/tests/fullscreent.um @@ -21,11 +21,11 @@ fn init*() { canvas.drawText("FULLSCREEN OFF", th.Vf2{0, 33}, th.red, 4) } - if input.isPressed(input.key_alt) && input.isJustPressed(input.key_enter) { + if input.isPressed(input.Key.alt) && input.isJustPressed(input.Key.enter) { window.setFullscreen(true) } - if input.isJustPressed(input.key_escape) { + if input.isJustPressed(input.Key.escape) { window.setFullscreen(false) } }) diff --git a/tests/inputt.um b/tests/inputt.um index 32b5977f..64afcd92 100644 --- a/tests/inputt.um +++ b/tests/inputt.um @@ -24,11 +24,11 @@ fn init*() { }*/ printf("lshift: %v %v %v\n", - input.isPressed(input.key_left_shift), - input.isJustPressed(input.key_left_shift), - input.isJustReleased(input.key_left_shift)) + input.isPressed(input.Key.leftShift), + input.isJustPressed(input.Key.leftShift), + input.isJustReleased(input.Key.leftShift)) - if input.isJustPressed(input.key_backspace) { + if input.isJustPressed(input.Key.backspace) { text = "" } @@ -36,7 +36,7 @@ fn init*() { printf("' was just pressed\n") } - if input.isJustPressed(input.key_escape) { + if input.isJustPressed(input.Key.escape) { printf("escape was just pressed\n") } diff --git a/tests/navt.um b/tests/navt.um index 227af7e8..cdbda377 100644 --- a/tests/navt.um +++ b/tests/navt.um @@ -52,12 +52,12 @@ fn init*() { p = m.nav(s, e) window.onFrame.register(signal.Callback{ - if input.isJustPressed(input.mouse1) { + if input.isJustPressed(input.Key.mouse1) { s = input.getMousePos() p = update(&m, s, e) } - if input.isJustPressed(input.mouse3) { + if input.isJustPressed(input.Key.mouse3) { e = input.getMousePos() p = update(&m, s, e) } diff --git a/tests/rayt.um b/tests/rayt.um index cb964b40..effb5cdf 100644 --- a/tests/rayt.um +++ b/tests/rayt.um @@ -21,16 +21,16 @@ fn init*() { window.setup("raycast test", 400, 400) r = ray.mk(th.Vf2{}, 60, 0) - e = ent.mk(image.load("etc/test.png"), th.Transform{s: th.Vf2{4, 4}}) + e = ent.mk(image.load("etc/test.png"), {p: { 100, 100 }, s: { 4, 4 }}) window.onFrame.register(signal.Callback{ r.pos = input.getGlobalMousePos() - if input.isPressed(input.mouse1) { + if input.isPressed(input.Key.mouse1) { r.r -= 0.1 * th.delta } - if input.isPressed(input.mouse3) { + if input.isPressed(input.Key.mouse3) { r.r += 0.1 * th.delta } diff --git a/tests/signalt.um b/tests/signalt.um index 80efe2bc..621121c8 100644 --- a/tests/signalt.um +++ b/tests/signalt.um @@ -17,7 +17,7 @@ fn init*() { }) window.onFrame.register({ - if input.isPressed(input.key_space) { + if input.isPressed(input.Key.space) { signal.emit("spacePress", th.time) } }) diff --git a/tests/uit.um b/tests/uit.um index 6b02ce20..4b6ad049 100644 --- a/tests/uit.um +++ b/tests/uit.um @@ -15,7 +15,7 @@ fn init*() { window.setup("gui test", 600, 600) window.setViewport(th.Vf2{ 200, 200 }) - ft := font.load("etc/roboto.ttf", 32, font.filterLinear) + ft := font.load("etc/roboto.ttf", 32, font.Filter.linear) gui = ui.mk(rect.mk(0, 0, 200, 200), ui.getDefaultStyle()) gui.getStyle().ft = ft @@ -28,14 +28,14 @@ fn init*() { layout := ui.LayoutFn{ gui.box(ui.BoxConfig{ dimension: 30, - growType: ui.BoxGrowDimension, - dir: ui.BoxDirectionUp, + growType: ui.BoxGrow.dimension, + dir: ui.BoxDir.up, padding: 5 }) { gui.box(ui.BoxConfig{ span: { 1.5, 1, 1.5 }, - growType: ui.BoxGrowSpan, - dir: ui.BoxDirectionRight }) + growType: ui.BoxGrow.span, + dir: ui.BoxDir.right }) { for i := 0; i < 3; i++ { if gui.qbutton(sprintf("Button %d", i+1)) { @@ -47,8 +47,8 @@ fn init*() { gui.box(ui.BoxConfig{ subdivisions: 3, - growType: ui.BoxGrowSubdivision, - dir: ui.BoxDirectionRight }) + growType: ui.BoxGrow.subdiv, + dir: ui.BoxDir.right }) { for i := 0; i < 3; i++ { if gui.qbutton(sprintf("Button %d", i+1)) { @@ -74,8 +74,8 @@ fn init*() { gui.stack({ padding: 3 }) gui.box(ui.BoxConfig{ subdivisions: 2, - growType: ui.BoxGrowSubdivision, - dir: ui.BoxDirectionDown }) + growType: ui.BoxGrow.subdiv, + dir: ui.BoxDir.down}) { gui.label("I'm a window\n", ui.LabelConfig{ centerX: true, centerY: true }) diff --git a/umka/audio.um b/umka/audio.um index d49c47eb..8568ea59 100644 --- a/umka/audio.um +++ b/umka/audio.um @@ -13,20 +13,21 @@ type Sound* = struct { _: ^struct{} } var pool: []^Sound -type LoadFlag = uint32 -const ( +//~~enum LoadFlag +type LoadFlag* = enum { // Streams the audio, only saving 2 seconds into memory. - LoadFlagStream* = LoadFlag(1) + stream = 1 // Loads the sound in async. Use `audio.waitForLoad` to wait for the // sounds to load. - LoadFlagAsync* = LoadFlag(4) -) + async = 4 +} +//~~ -fn umth_sound_load(path: str, flags: uint32): ^struct{} +fn umth_sound_load(path: str, flags: LoadFlag): ^struct{} //~~fn load // Loads a sounds at path, if there is an error, the underlying pointer // will be `NULL` and `validate` will return false. -fn load*(path: str, flags: LoadFlag = 0): Sound { +fn load*(path: str, flags: LoadFlag = LoadFlag.stream): Sound { //~~ return Sound{umth_sound_load(path, flags)} } diff --git a/umka/font.um b/umka/font.um index 32600007..dd055178 100644 --- a/umka/font.um +++ b/umka/font.um @@ -7,19 +7,19 @@ import ( ) //~~Filtering constants -const ( - filterNearest* = 0 - filterLinear* = 1 -) +type Filter* = enum { + nearest = 0 + linear = 1 +} //~~ //~~opaque Font type Font* = struct { _: ^struct{} } //~~ -fn umth_font_load(path: str, size: th.fu, filter: uint32): ^struct{} +fn umth_font_load(path: str, size: th.fu, filter: Filter): ^struct{} //~~fn load -fn load*(path: str, size: th.fu, filter: uint32 = filterLinear): Font { +fn load*(path: str, size: th.fu, filter: Filter = Filter.linear): Font { //~~ return Font{umth_font_load(path, size, filter)} } diff --git a/umka/input.um b/umka/input.um index dbb25d1d..473960b1 100644 --- a/umka/input.um +++ b/umka/input.um @@ -10,137 +10,137 @@ import ( ) //~~Keycode constants -const ( - mouse1* = 1 // NOTE: mouse 2 and 3 key codes are swapped - mouse2* = 3 // because sokol uses 3 for middle mouse - mouse3* = 2 // button. +type Key* = enum { + mouse1 = 1 // NOTE: mouse 2 and 3 key codes are swapped + mouse2 = 3 // because sokol uses 3 for middle mouse + mouse3 = 2 // button. - key_ctrl* = 16 - key_shift* = 17 - key_alt* = 18 + ctrl = 16 + shift = 17 + alt = 18 - key_space* = 32 - key_apostrophe* = 39 /* ' */ - key_comma* = 44 /* , */ - key_minus* = 45 /* - */ - key_dot* = 46 /* . */ - key_slash* = 47 /* / */ - key_0* = 48 - key_1* = 49 - key_2* = 50 - key_3* = 51 - key_4* = 52 - key_5* = 53 - key_6* = 54 - key_7* = 55 - key_8* = 56 - key_9* = 57 - key_semicolon* = 59 /* ; */ - key_equal* = 61 /* = */ - key_a* = 65 - key_b* = 66 - key_c* = 67 - key_d* = 68 - key_e* = 69 - key_f* = 70 - key_g* = 71 - key_h* = 72 - key_i* = 73 - key_j* = 74 - key_k* = 75 - key_l* = 76 - key_m* = 77 - key_n* = 78 - key_o* = 79 - key_p* = 80 - key_q* = 81 - key_r* = 82 - key_s* = 83 - key_t* = 84 - key_u* = 85 - key_v* = 86 - key_w* = 87 - key_x* = 88 - key_y* = 89 - key_z* = 90 - key_left_bracket* = 91 /* [ */ - key_backslash* = 92 /* \ */ - key_right_bracket* = 93 /* ] */ - key_grave_accent* = 96 /* ` */ - key_world_1* = 161 /* non-US #1 */ - key_world_2* = 162 /* non-US #2 */ - key_escape* = 256 - key_enter* = 257 - key_tab* = 258 - key_backspace* = 259 - key_insert* = 260 - key_delete* = 261 - key_right* = 262 - key_left* = 263 - key_down* = 264 - key_up* = 265 - key_page_up* = 266 - key_page_down* = 267 - key_home* = 268 - key_end* = 269 - key_caps_lock* = 280 - key_scroll_lock* = 281 - key_num_lock* = 282 - key_print_screen* = 283 - key_pause* = 284 - key_fn* = 289 - key_fn1* = 290 - key_fn2* = 291 - key_fn3* = 292 - key_fn4* = 293 - key_fn5* = 294 - key_fn6* = 295 - key_fn7* = 296 - key_fn8* = 297 - key_fn9* = 298 - key_fn10* = 299 - key_fn11* = 300 - key_fn12* = 301 - key_fn13* = 302 - key_fn14* = 303 - key_fn15* = 304 - key_fn16* = 305 - key_fn17* = 306 - key_fn18* = 307 - key_fn19* = 308 - key_fn20* = 309 - key_fn21* = 310 - key_fn22* = 311 - key_fn23* = 312 - key_fn24* = 313 - key_fn25* = 314 - key_kp_0* = 320 - key_kp_1* = 321 - key_kp_2* = 322 - key_kp_3* = 323 - key_kp_4* = 324 - key_kp_5* = 325 - key_kp_6* = 326 - key_kp_7* = 327 - key_kp_8* = 328 - key_kp_9* = 329 - key_kp_decimal* = 330 - key_kp_divide* = 331 - key_kp_multiply* = 332 - key_kp_subtract* = 333 - key_kp_add* = 334 - key_kp_enter* = 335 - key_kp_equal* = 336 - key_left_shift* = 340 - key_left_control* = 341 - key_left_alt* = 342 - key_left_super* = 343 - key_right_shift* = 344 - key_right_control* = 345 - key_right_alt* = 346 - key_right_super* = 347 - key_menu* = 348 -) + space = 32 + apostrophe = 39 /* ' */ + comma = 44 /* , */ + minus = 45 /* - */ + dot = 46 /* . */ + slash = 47 /* / */ + num0 = 48 + num1 = 49 + num2 = 50 + num3 = 51 + num4 = 52 + num5 = 53 + num6 = 54 + num7 = 55 + num8 = 56 + num9 = 57 + semicolon = 59 /* ; */ + equal = 61 /* = */ + a = 65 + b = 66 + c = 67 + d = 68 + e = 69 + f = 70 + g = 71 + h = 72 + i = 73 + j = 74 + k = 75 + l = 76 + m = 77 + n = 78 + o = 79 + p = 80 + q = 81 + r = 82 + s = 83 + t = 84 + u = 85 + v = 86 + w = 87 + x = 88 + y = 89 + z = 90 + leftBracket = 91 /* [ */ + backslash = 92 /* \ */ + rightBracket = 93 /* ] */ + graveAccent = 96 /* ` */ + world1 = 161 /* non-US #1 */ + world2 = 162 /* non-US #2 */ + escape = 256 + enter = 257 + tab = 258 + backspace = 259 + insert = 260 + delete = 261 + right = 262 + left = 263 + down = 264 + up = 265 + pageUp = 266 + pageDown = 267 + home = 268 + end = 269 + capsLock = 280 + scrollLock = 281 + numLock = 282 + printScreen = 283 + pause = 284 + fn0 = 289 + fn1 = 290 + fn2 = 291 + fn3 = 292 + fn4 = 293 + fn5 = 294 + fn6 = 295 + fn7 = 296 + fn8 = 297 + fn9 = 298 + fn10 = 299 + fn11 = 300 + fn12 = 301 + fn13 = 302 + fn14 = 303 + fn15 = 304 + fn16 = 305 + fn17 = 306 + fn18 = 307 + fn19 = 308 + fn20 = 309 + fn21 = 310 + fn22 = 311 + fn23 = 312 + fn24 = 313 + fn25 = 314 + kp0 = 320 + kp1 = 321 + kp2 = 322 + kp3 = 323 + kp4 = 324 + kp5 = 325 + kp6 = 326 + kp7 = 327 + kp8 = 328 + kp9 = 329 + kpDecimal = 330 + kpDivide = 331 + kpMultiply = 332 + kpSubtract = 333 + kpAdd = 334 + kpEnter = 335 + kpEqual = 336 + leftShift = 340 + leftControl = 341 + leftAlt = 342 + leftSuper = 343 + rightShift = 344 + rightControl = 345 + rightAlt = 346 + rightSuper = 347 + menu = 348 +} //~~ @@ -168,11 +168,11 @@ fn getGlobalMousePos*(): th.Vf2 { return getMousePos().add(window.getViewportOffset()) } -fn umth_input_is_pressed(keycode: int32): int32 +fn umth_input_is_pressed(keycode: Key): int32 //~~fn isPressed // Returns true if key is pressed. Either use codes defined in the file above, // or pass lower case char/number. -fn isPressed*(code: int): bool { +fn isPressed*(code: Key): bool { //~~ val := bool(umth_input_is_pressed(code)) return val @@ -182,13 +182,13 @@ fn isPressed*(code: int): bool { // Like `isPressed`, but you can pass char as the code. fn isPressedc*(code: char): bool { //~~ - return isPressed(toupper(code)) + return isPressed(Key(toupper(code))) } -fn umth_input_is_just_pressed(key: int32): int32 +fn umth_input_is_just_pressed(key: Key): int32 //~~fn isJustPressed // Returns, whether code was just pressed this loop. -fn isJustPressed*(code: int): bool { +fn isJustPressed*(code: Key): bool { //~~ return bool(umth_input_is_just_pressed(code)) } @@ -197,13 +197,13 @@ fn isJustPressed*(code: int): bool { // Like `isJustPressed`, but you can pass char as the code. fn isJustPressedc*(code: char): bool { //~~ - return isJustPressed(toupper(code)) + return isJustPressed(Key(toupper(code))) } -fn umth_input_is_pressed_repeat(key: int32): int32 +fn umth_input_is_pressed_repeat(key: Key): int32 //~~fn isPressedRepeat // Returns, whether code was just pressed this loop, with key repeat. -fn isPressedRepeat*(code: int): bool { +fn isPressedRepeat*(code: Key): bool { //~~ return bool(umth_input_is_pressed_repeat(code)) } @@ -212,14 +212,14 @@ fn isPressedRepeat*(code: int): bool { // Like `isPressedRepeat`, but you can pass char as the code. fn isPressedRepeatc*(code: char): bool { //~~ - return isPressedRepeat(toupper(code)) + return isPressedRepeat(Key(toupper(code))) } -fn umth_input_is_just_released(key: int32): int32 +fn umth_input_is_just_released(key: Key): int32 //~~fn isJustReleased // Returns true if a key was just released. -fn isJustReleased*(code: int): bool { +fn isJustReleased*(code: Key): bool { //~~ return bool(umth_input_is_just_released(code)) } @@ -227,13 +227,13 @@ fn isJustReleased*(code: int): bool { // Like `isJustReleased`, but you can pass char as the code. fn isJustReleasedc*(code: char): bool { //~~ - return isJustReleased(toupper(code)) + return isJustReleased(Key(toupper(code))) } -fn umth_input_clear*(code: int) +fn umth_input_clear*(code: Key) //~~fn clear // Clears both the pressed and justPressed state of a code. -fn clear*(code: int) { +fn clear*(code: Key) { //~~ umth_input_clear(code) } @@ -242,7 +242,7 @@ fn clear*(code: int) { // Like `clear`, but you can pass char as the code. fn clearc*(code: char) { //~~ - umth_input_clear(toupper(code)) + umth_input_clear(Key(toupper(code))) } fn umth_input_get_str(): str diff --git a/umka/th.um b/umka/th.um index 53f32907..8d93b75b 100644 --- a/umka/th.um +++ b/umka/th.um @@ -325,14 +325,13 @@ const ( //~~ //~~enum Platform -type Platform* = int -const ( - PlatformUnknown* = 0 - PlatformLinux* - PlatformWindows* - PlatformMacOs* - PlatformWeb* -) +type Platform* = enum { + unknown + linux + windows + macOs + web +} //~~ //~~Misc variables diff --git a/umka/ui.um b/umka/ui.um index 1586b66a..73052425 100644 --- a/umka/ui.um +++ b/umka/ui.um @@ -203,21 +203,21 @@ fn (this: ^Gui) hover(r: rect.Rect): bool { // Runs the evaluation phase on `layout`. fn (this: ^Gui) eval*(layout: LayoutFn) { //~~ - if input.isJustPressed(input.mouse1) { this.m1Pressed = true } - if input.isJustReleased(input.mouse1) { this.m1Pressed = false } - if input.isJustPressed(input.mouse2) { this.m2Pressed = true } - if input.isJustReleased(input.mouse2) { this.m2Pressed = false } - if input.isJustPressed(input.mouse3) { this.m3Pressed = true } - if input.isJustReleased(input.mouse3) { this.m3Pressed = false } + if input.isJustPressed(input.Key.mouse1) { this.m1Pressed = true } + if input.isJustReleased(input.Key.mouse1) { this.m1Pressed = false } + if input.isJustPressed(input.Key.mouse2) { this.m2Pressed = true } + if input.isJustReleased(input.Key.mouse2) { this.m2Pressed = false } + if input.isJustPressed(input.Key.mouse3) { this.m3Pressed = true } + if input.isJustReleased(input.Key.mouse3) { this.m3Pressed = false } this.idx = 0 this.isEval = true layout(this) if this.hover(this.container[0].getDims()) { - input.clear(input.mouse1) - input.clear(input.mouse2) - input.clear(input.mouse3) + input.clear(input.Key.mouse1) + input.clear(input.Key.mouse2) + input.clear(input.Key.mouse3) } } @@ -232,27 +232,22 @@ fn (this: ^Gui) draw*(layout: LayoutFn) { //~~enum BoxGrow // The different types of "growing" the box can do. -type BoxGrow* = uint -const ( - // Increments by an amount set by the user. - BoxGrowDimension* = BoxGrow(0) - // Divides the container into `n` equal parts. - BoxGrowSubdivision* = BoxGrow(1) - // Grows the box based on values in the span array. - BoxGrowSpan* = BoxGrow(2) - BoxGrowPxSpan* = BoxGrow(3) -) +type BoxGrow* = enum { + dimension + subdiv + span + pxSpan +} //~~ //~~enum BoxDirection // Direction in which the box will grow. -type BoxDirection* = uint -const ( - BoxDirectionDown* = BoxDirection(0) - BoxDirectionRight* = BoxDirection(1) - BoxDirectionUp* = BoxDirection(2) - BoxDirectionLeft* = BoxDirection(3) -) +type BoxDir* = enum { + down + right + up + left +} //~~ //~~struct BoxConfig @@ -265,7 +260,7 @@ type BoxConfig* = struct { // the grow type growType: BoxGrow // the grow direction - dir: BoxDirection + dir: BoxDir // Specifies the values used with BoxGrowSpan nad BoxGrowPxSpan. // If BoxGrowSpan is used, 1 equals the size of the box divided by the sum // of all spans. @@ -295,16 +290,16 @@ type Box* = struct { fn (this: ^Box) getGrow(): th.fu { switch this.cfg.growType { // These values are constant and can therefore be only calculated once. - case BoxGrowDimension: + case BoxGrow.dimension: return this.grow - case BoxGrowSubdivision: + case BoxGrow.subdiv: return this.grow - case BoxGrowSpan: + case BoxGrow.span: // We store the amount of pixels per a span in the grow array. sp := this.cfg.span[this.spanCursor] this.spanCursor = (this.spanCursor + 1) % len(this.cfg.span) return sp * this.grow - case BoxGrowPxSpan: + case BoxGrow.pxSpan: sp := this.cfg.span[this.spanCursor] this.spanCursor = (this.spanCursor + 1) % len(this.cfg.span) return sp @@ -315,7 +310,7 @@ fn (this: ^Box) getGrow(): th.fu { fn (this: ^Box) pushRect(r: rect.Rect): rect.Rect { switch this.cfg.dir { - case BoxDirectionDown: + case BoxDir.down: r.x = this.dm.x r.y = this.dm.y @@ -328,7 +323,7 @@ fn (this: ^Box) pushRect(r: rect.Rect): rect.Rect { } this.dm.y += r.h + this.cfg.padding - case BoxDirectionRight: + case BoxDir.right: r.x = this.dm.x r.y = this.dm.y @@ -341,7 +336,7 @@ fn (this: ^Box) pushRect(r: rect.Rect): rect.Rect { } this.dm.x += r.w + this.cfg.padding - case BoxDirectionUp: + case BoxDir.up: if r.h == 0 { r.h = this.getGrow() } @@ -353,7 +348,7 @@ fn (this: ^Box) pushRect(r: rect.Rect): rect.Rect { this.dm.h -= r.h + this.cfg.padding r.x = this.dm.x r.y = this.dm.y + this.dm.h - case BoxDirectionLeft: + case BoxDir.left: if r.h == 0 { r.h = this.dm.h } @@ -378,8 +373,8 @@ fn (this: ^Box) getDims(): rect.Rect { // Adds the `Box` container to the gui. fn (gui: ^Gui) box*(cfg: BoxConfig = { dimension: 30, - growType: BoxGrowDimension, - dir: BoxDirectionDown }) { + growType: BoxGrow.dimension, + dir: BoxDir.down }) { //~~ b := Box{} @@ -387,21 +382,21 @@ fn (gui: ^Gui) box*(cfg: BoxConfig = { b.cfg = cfg dm := b.dm.h - if cfg.dir == BoxDirectionRight || cfg.dir == BoxDirectionLeft { + if cfg.dir == BoxDir.right || cfg.dir == BoxDir.left { dm = b.dm.w } dm += b.cfg.padding switch cfg.growType { - case BoxGrowDimension: + case BoxGrow.dimension: b.grow = cfg.dimension - case BoxGrowSubdivision: + case BoxGrow.subdiv: if cfg.subdivisions == 0 { th.__error("Invalid subdivision count") } b.grow = dm / cfg.subdivisions - case BoxGrowSpan: + case BoxGrow.span: s := th.fu(0) for _,v in b.cfg.span { s += v @@ -559,7 +554,7 @@ fn (gui: ^Gui) button*(cfg: ButtonConfig = {}): bool { r := gui.getContainer().getDims() if gui.isEval { - if gui.hover(r) && input.isJustReleased(input.mouse1) { + if gui.hover(r) && input.isJustReleased(input.Key.mouse1) { return true } return false @@ -693,16 +688,16 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { hover := gui.hover(r) if gui.isEval { - if input.isJustPressed(input.mouse1) && hover { + if input.isJustPressed(input.Key.mouse1) && hover { gui.selection = gui.idx } - if input.isJustPressed(input.mouse1) && !hover && + if input.isJustPressed(input.Key.mouse1) && !hover && gui.selection == gui.idx { gui.selection = 0 } - if input.isJustPressed(input.key_escape) && gui.selection == gui.idx { + if input.isJustPressed(input.Key.escape) && gui.selection == gui.idx { gui.selection = 0 } @@ -710,7 +705,7 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { return } - if input.isPressedRepeat(input.key_backspace) { + if input.isPressedRepeat(input.Key.backspace) { if tb.cursor > 0 { tb.buffer = append(slice(tb.buffer, 0, tb.cursor - 1), slice(tb.buffer, tb.cursor)) @@ -718,24 +713,24 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { } } - if input.isPressedRepeat(input.key_delete) { + if input.isPressedRepeat(input.Key.delete) { if tb.cursor >= 0 && tb.cursor < len(tb.buffer) { tb.buffer = append(slice(tb.buffer, 0, tb.cursor), slice(tb.buffer, tb.cursor+1)) } } - if input.isPressedRepeat(input.key_home) { + if input.isPressedRepeat(input.Key.home) { tb.cursor = 0 } - if input.isPressedRepeat(input.key_end) { + if input.isPressedRepeat(input.Key.end) { tb.cursor = len(tb.buffer) } v := true - if input.isPressed(input.key_ctrl) && input.isJustPressedc('v') { + if input.isPressed(input.Key.ctrl) && input.isJustPressedc('v') { toInsert := utf8.decode(window.getClipboard()) tb.buffer = append(append(slice(tb.buffer, 0, tb.cursor), toInsert), slice(tb.buffer, tb.cursor)) @@ -743,12 +738,12 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { v = false } - if input.isPressed(input.key_ctrl) && input.isJustPressedc('c') { + if input.isPressed(input.Key.ctrl) && input.isJustPressedc('c') { window.setClipboard(utf8.encode(tb.buffer)) v = false } - if input.isPressed(input.key_ctrl) && input.isJustPressedc('u') { + if input.isPressed(input.Key.ctrl) && input.isJustPressedc('u') { tb.clear() v = false } @@ -757,7 +752,7 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { return r == utf8.Rune(' ') || r == utf8.Rune('\t') || r == utf8.Rune('\n') } - if input.isPressed(input.key_ctrl) && input.isPressedRepeat(input.key_left) { + if input.isPressed(input.Key.ctrl) && input.isPressedRepeat(input.Key.left) { // skip spaces for tb.cursor > 0 && isRuneSpace(tb.buffer[tb.cursor-1]) { tb.cursor-- @@ -769,7 +764,7 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { v = false } - if input.isPressed(input.key_ctrl) && input.isPressedRepeat(input.key_right) { + if input.isPressed(input.Key.ctrl) && input.isPressedRepeat(input.Key.right) { // skip spaces for tb.cursor < len(tb.buffer) && isRuneSpace(tb.buffer[tb.cursor]) { tb.cursor++ @@ -781,11 +776,11 @@ fn (gui: ^Gui) textBox*(tb: ^TextBox, cfg: TextBoxConfig = {}) { v = false } - if input.isPressedRepeat(input.key_left) && v { + if input.isPressedRepeat(input.Key.left) && v { if tb.cursor > 0 { tb.cursor-- } } - if input.isPressedRepeat(input.key_right) && v { + if input.isPressedRepeat(input.Key.right) && v { if tb.cursor < len(tb.buffer) { tb.cursor++ } } diff --git a/umka/window.um b/umka/window.um index de3baf77..0a68ab93 100644 --- a/umka/window.um +++ b/umka/window.um @@ -16,20 +16,20 @@ var ( ) //~~Cursor types -const ( - cursorDefault* = 0 // Default system cursor - cursorArrow* // Normal cursor; Arrow cursor - cursorIBeam* // 'I' text cursor; I-Beam - cursorCrosshair* // '+' cursor; Select region cursor - cursorFinger* // Index finger pointing cursor; Click cursor - cursorSizeEW* // '<->' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor - cursorSizeNS* // Resize height cursor; Resize vertically cursor; North-South resize cursor - cursorSizeNWSE* // Resize width and height from the right side cursor; Northwest-Southeast resize cursor - cursorSizeSWNE* // Resize width and height from the left side cursor; Southwest-Northeast resize cursor - cursorSizeAll* // Resize all cursor; Move cursor - cursorNo* // '(/)' cursor; Disabled cursor; Disallowed cursor - cursorCount_* -) +type Cursor* = enum { + system = 0 // Default system cursor + arrow // Normal cursor; Arrow cursor + iBeam // 'I' text cursor; I-Beam + crosshair // '+' cursor; Select region cursor + finger // Index finger pointing cursor; Click cursor + sizeEW // '<->' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor + sizeNS // Resize height cursor; Resize vertically cursor; North-South resize cursor + sizeNWSE // Resize width and height from the right side cursor; Northwest-Southeast resize cursor + sizeSWNE // Resize width and height from the left side cursor; Southwest-Northeast resize cursor + sizeAll // Resize all cursor; Move cursor + no // '(/)' cursor; Disabled cursor; Disallowed cursor + count_ +} //~~ //~~Window dimensions @@ -100,7 +100,7 @@ fn setup*(title: str = "tophat game", width: int = 400, height: int32 = 400) { w, h = width, height umth_window_setup(title, width, height) - th.platform = umth_window_get_platform_id() + th.platform = th.Platform(umth_window_get_platform_id()) audio.__setup() placeholders.__setup() @@ -236,10 +236,10 @@ fn freezeCursor*(freeze: bool) { umth_window_freeze_cursor(freeze) } -fn umth_window_set_cursor(cursor: int) +fn umth_window_set_cursor(cursor: Cursor) //~~fn setCursor // Allows you to set the displaying cursor. Refer to the cursors section for available cursors. -fn setCursor*(cursor: int) { +fn setCursor*(cursor: Cursor) { //~~ umth_window_set_cursor(cursor); }