# HG changeset patch # User Sam # Date 1696216509 -25200 # Node ID 8a2fae96570c584637273dfe0bdb690b5aecb041 # Parent 995e273157cd6d223d942bf02d7d8911f12921a6 add anykey-pressed api, extend default charset when loading fonts diff -r 995e273157cd -r 8a2fae96570c src/semicongine/engine.nim --- a/src/semicongine/engine.nim Sun Oct 01 20:53:35 2023 +0700 +++ b/src/semicongine/engine.nim Mon Oct 02 10:15:09 2023 +0700 @@ -189,6 +189,7 @@ # wrappers for internal things func keyIsDown*(engine: Engine, key: Key): auto = key in engine.input.keyIsDown func keyWasPressed*(engine: Engine, key: Key): auto = key in engine.input.keyWasPressed +func keyWasPressed*(engine: Engine): auto = engine.input.keyWasPressed.len > 0 func keyWasReleased*(engine: Engine, key: Key): auto = key in engine.input.keyWasReleased func mouseIsDown*(engine: Engine, button: MouseButton): auto = button in engine.input.mouseIsDown func mouseWasPressed*(engine: Engine, button: MouseButton): auto = button in engine.input.mouseWasPressed diff -r 995e273157cd -r 8a2fae96570c src/semicongine/resources.nim --- a/src/semicongine/resources.nim Sun Oct 01 20:53:35 2023 +0700 +++ b/src/semicongine/resources.nim Mon Oct 02 10:15:09 2023 +0700 @@ -130,7 +130,7 @@ var thename = name if thename == "": thename = path.splitFile().name - let defaultCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=+[{]};:,<.>/? ".toRunes() + let defaultCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=+[{]};:,<.>/? $!@#%^&*()\"'".toRunes() loadResource_intern(path).readTrueType(name, defaultCharset, color, resolution) proc loadMeshes*(path: string): seq[MeshTree] = diff -r 995e273157cd -r 8a2fae96570c src/semicongine/text.nim --- a/src/semicongine/text.nim Sun Oct 01 20:53:35 2023 +0700 +++ b/src/semicongine/text.nim Mon Oct 02 10:15:09 2023 +0700 @@ -7,6 +7,8 @@ import ./vulkan/shader const SHADER_ATTRIB_PREFIX = "semicon_text_" +var instanceCounter = 0 + type TextAlignment = enum Left @@ -16,7 +18,7 @@ maxLen*: int text: seq[Rune] dirty: bool - alignment*: TextAlignment + alignment*: TextAlignment = Center font*: Font mesh*: Mesh @@ -103,7 +105,8 @@ ] result = Textbox(maxLen: maxLen, text: text, font: font, dirty: true) - result.mesh = newMesh(positions = positions, indices = indices, uvs = uvs) + result.mesh = newMesh(positions = positions, indices = indices, uvs = uvs, name = &"textbox-{instanceCounter}") + inc instanceCounter result.mesh[].renameAttribute("position", POSITION_ATTRIB) result.mesh[].renameAttribute("uv", UV_ATTRIB) result.mesh.materials = @[Material(