diff --git a/enu.nimble b/enu.nimble index 969ee2c8..333e10b7 100644 --- a/enu.nimble +++ b/enu.nimble @@ -33,9 +33,8 @@ bin = @["enu" & lib_ext] requires "nim >= 2.0.2", "https://github.com/dsrw/Nim#44959b7", - "https://github.com/arnetheduck/nim-results#f3c666a", "https://github.com/dsrw/godot-nim#43addc1", - "https://github.com/dsrw/model_citizen 0.19.2", + "https://github.com/dsrw/model_citizen 0.19.3", "https://github.com/dsrw/nanoid.nim 0.2.1", "cligen 1.6.17", "https://github.com/treeform/pretty", "chroma", "markdown", "chronicles", "dotenv", "nimibook", "metrics#51f1227", "zippy" diff --git a/src/config.nims b/src/config.nims index 86419ab8..378c9757 100644 --- a/src/config.nims +++ b/src/config.nims @@ -22,8 +22,6 @@ if host_os == "windows": --experimental: "dynamic_bind_sym" ---experimental: - "overloadable_enums" --define: "vm_exec_hooks" @@ -48,17 +46,21 @@ if defined(release): --define: "zen_lax_free" -# --passC:"-I/opt/homebrew/include" - if project_name() == "enu": if host_os == "ios": - --define:use_pcre_header - --define:"chronicles_colors=None" - --passC:"-Ivendor/pcre -miphoneos-version-min=12.0 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -mcpu=apple-a10" - --passL:"-target aarch64-ios --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" - --app:staticlib + --define: + use_pcre_header + --define: + "chronicles_colors=None" + --passC: + "-Ivendor/pcre -miphoneos-version-min=12.0 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -mcpu=apple-a10" + --passL: + "-target aarch64-ios --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" + --app: + staticlib else: - --app:lib + --app: + lib --no_main else: --define: diff --git a/src/models/bots.nim b/src/models/bots.nim index c79e3ed5..a96055a0 100644 --- a/src/models/bots.nim +++ b/src/models/bots.nim @@ -82,7 +82,7 @@ proc init*( animation_value: ~"auto", speed: 1.0, clone_of: clone_of, - start_color: action_colors[black], + start_color: action_colors[Black], parent: parent, ) diff --git a/src/models/builds.nim b/src/models/builds.nim index 311fc3f6..d11893fe 100644 --- a/src/models/builds.nim +++ b/src/models/builds.nim @@ -9,7 +9,7 @@ const ChunkSize = vec3(16, 16, 16) include "build_code_template.nim.nimf" -const default_color = action_colors[blue] +const default_color = action_colors[Blue] var current_build* {.threadvar.}: Build @@ -55,7 +55,7 @@ proc find_first*(units: ZenSeq[Unit], positions: open_array[Vector3]): Build = var loc = position - offset if loc in unit: var info = unit.chunks[loc.buffer][loc] - if info.kind != Hole and info.color != action_colors[eraser]: + if info.kind != Hole and info.color != action_colors[Eraser]: return unit let first = unit.units.find_first(positions) if ?first: @@ -214,11 +214,11 @@ proc remove(self: Build) = skip_point = vec3() last_point = self.target_point - self.draw(point, (Hole, action_colors[eraser])) + self.draw(point, (Hole, action_colors[Eraser])) if self.units.len == 0 and not self.chunks.any_it( - it.value.any_it(it.value.color != action_colors[eraser]) + it.value.any_it(it.value.color != action_colors[Eraser]) ): if self.parent.is_nil: state.units -= self @@ -374,11 +374,11 @@ method ensure_visible*(self: Build) = # single block. if self.units.len == 0 and not self.chunks.any_it( - it.value.any_it(it.value.color != action_colors[eraser]) + it.value.any_it(it.value.color != action_colors[Eraser]) ): let color = - if self.start_color == action_colors[eraser]: - action_colors[blue] + if self.start_color == action_colors[Eraser]: + action_colors[Blue] else: self.start_color self.draw(vec3(), (Computed, color)) diff --git a/src/models/colors.nim b/src/models/colors.nim index 28931b87..c1e31c7f 100644 --- a/src/models/colors.nim +++ b/src/models/colors.nim @@ -14,51 +14,51 @@ proc col*(hex: string): chroma.Color = type Colors* = enum - eraser - blue - red - green - black - white - brown + Eraser + Blue + Red + Green + Black + White + Brown Theme* = enum - normal - comment - entity - keyword - operator - class - storage - constant - text - number - variable - invalid + Normal + Comment + Entity + Keyword + Operator + Class + Storage + Constant + Text + Number + Variable + Invalid const ir_black* = [ - normal: col"F6F3E8", - comment: col"7C7C7C", - entity: col"FFD2A7", - keyword: col"96CBFE", - operator: col"EDEDED", - class: col"FFFFB6", - storage: col"CFCB90", - constant: col"99CC99", - text: col"A8FF60", - number: col"FF73FD", - variable: col"C6C5FE", - invalid: col"FD5FF1" + Normal: col"F6F3E8", + Comment: col"7C7C7C", + Entity: col"FFD2A7", + Keyword: col"96CBFE", + Operator: col"EDEDED", + Class: col"FFFFB6", + Storage: col"CFCB90", + Constant: col"99CC99", + Text: col"A8FF60", + Number: col"FF73FD", + Variable: col"C6C5FE", + Invalid: col"FD5FF1" ] const action_colors* = [ - eraser: chroma.Color(), - blue: col"0067ff", - red: col"fc0e0b", - green: col"14f707", - black: col"000000", - white: col"d9eed8", - brown: col"3f302b" + Eraser: chroma.Color(), + Blue: col"0067ff", + Red: col"fc0e0b", + Green: col"14f707", + Black: col"000000", + White: col"d9eed8", + Brown: col"3f302b" ] proc action_index*(self: Color): Colors = diff --git a/src/models/serializers.nim b/src/models/serializers.nim index 432d5714..35b4cd17 100644 --- a/src/models/serializers.nim +++ b/src/models/serializers.nim @@ -11,7 +11,7 @@ type LevelInfo = object proc to_json_hook(self: Color): JsonNode = result = - if self == action_colors[eraser]: + if self == action_colors[Eraser]: %"" else: for i, color in Colors.enum_fields: @@ -22,10 +22,10 @@ proc to_json_hook(self: Color): JsonNode = proc from_json_hook(self: var Color, json: JsonNode) = let hex = json.get_str if hex == "": - self = action_colors[eraser] + self = action_colors[Eraser] else: for i, color in Colors.enum_fields: - if color == hex: + if color.to_lower == hex.to_lower: self = action_colors[Colors(i)] return self = hex.parse_html_hex diff --git a/src/models/signs.nim b/src/models/signs.nim index cb797d2e..a6f6fc5d 100644 --- a/src/models/signs.nim +++ b/src/models/signs.nim @@ -22,7 +22,7 @@ proc init*( size_value: ~size, billboard_value: ~billboard, frame_created: state.frame_count, - start_color: action_colors[black], + start_color: action_colors[Black], start_transform: transform, owner_value: ~owner, text_only: text_only, diff --git a/src/models/units.nim b/src/models/units.nim index 36c133fb..1226c3f7 100644 --- a/src/models/units.nim +++ b/src/models/units.nim @@ -114,11 +114,11 @@ method collect_garbage*(self: Unit) {.base, gcsafe.} = for id, chunk in self.shared.edits.value: var cleaned_chunk = chunk for loc, voxel in chunk.value: - if voxel.kind == Hole and voxel.color == action_colors[eraser]: + if voxel.kind == Hole and voxel.color == action_colors[Eraser]: cleaned_chunk.del(loc) elif voxel.kind == Hole: var voxel = voxel - voxel.color = action_colors[eraser] + voxel.color = action_colors[Eraser] cleaned_chunk[loc] = voxel self.shared.edits[id] = cleaned_chunk diff --git a/src/nodes/bot_node.nim b/src/nodes/bot_node.nim index 82163461..e690386e 100644 --- a/src/nodes/bot_node.nim +++ b/src/nodes/bot_node.nim @@ -41,16 +41,16 @@ gdobj BotNode of KinematicBody: proc set_color(color: chroma.Color) = var adjusted: chroma.Color - if color == action_colors[green]: + if color == action_colors[Green]: adjusted = color adjusted.a = 0.015 - elif color == action_colors[white]: + elif color == action_colors[White]: adjusted = color adjusted.a = 0.1 else: - var dist = (color.distance(action_colors[brown]) + 10).cbrt / 7.5 + var dist = (color.distance(action_colors[Brown]) + 10).cbrt / 7.5 adjusted = color.saturate(0.2).darken(dist - 0.15) - adjusted.a = 0.95 - color.distance(action_colors[black]) / 100 + adjusted.a = 0.95 - color.distance(action_colors[Black]) / 100 debug "setting bot color", color, adjusted SpatialMaterial(self.material).albedo_color = adjusted diff --git a/src/nodes/build_node.nim b/src/nodes/build_node.nim index dfe6979c..daa501a0 100644 --- a/src/nodes/build_node.nim +++ b/src/nodes/build_node.nim @@ -72,7 +72,7 @@ gdobj BuildNode of VoxelTerrain: let m = self.get_material(i).as(ShaderMaterial) if not m.is_nil: if self.error_highlight_on: - m.set_shader_param("emission", action_colors[red].to_variant) + m.set_shader_param("emission", action_colors[Red].to_variant) else: m.set_shader_param( "emission", self.model.shared.emission_colors[i].to_variant @@ -94,7 +94,7 @@ gdobj BuildNode of VoxelTerrain: # `and not modified` isn't required, but the block will be # replaced on the next iteration anyway. if removed and not modified: - self.draw(change.item.key, action_colors[eraser]) + self.draw(change.item.key, action_colors[Eraser]) elif added: self.draw(change.item.key, change.item.value.color) self.draw_block(self.model.chunks[chunk_id]) diff --git a/src/types.nim b/src/types.nim index 1b50ab28..b9301b56 100644 --- a/src/types.nim +++ b/src/types.nim @@ -11,6 +11,7 @@ from pkg/godot import NimGodotObject export Vector3, Transform, vector3, basis, AABB, aabb export godotbase except print export Interpreter +export lineinfos.`==` type EnuError* = object of CatchableError diff --git a/src/ui/editor.nim b/src/ui/editor.nim index 9dac345b..bc1a534c 100644 --- a/src/ui/editor.nim +++ b/src/ui/editor.nim @@ -21,12 +21,12 @@ const clear = init_color(0.0, 0.0, 0.0, 0.0) proc configure_highlighting*(self: TextEdit) = # strings - self.add_color_region("\"", "\"", ir_black[text], false) - self.add_color_region("\"\"\"", "\"\"\"", ir_black[text], false) + self.add_color_region("\"", "\"", ir_black[Text], false) + self.add_color_region("\"\"\"", "\"\"\"", ir_black[Text], false) # block comments - self.add_color_region("#[", "]#", ir_black[comment], false) + self.add_color_region("#[", "]#", ir_black[Comment], false) # line comments - self.add_color_region("#", "\n", ir_black[comment], true) + self.add_color_region("#", "\n", ir_black[Comment], true) gdobj Editor of MarginContainer: var diff --git a/src/ui/gui.nim b/src/ui/gui.nim index e4f0b3b7..ab8f4c37 100644 --- a/src/ui/gui.nim +++ b/src/ui/gui.nim @@ -25,6 +25,10 @@ gdobj GUI of Control: method on_focus_exited() = state.pop_flag ViewportFocused + method gui_input(event: InputEvent) = + (state.nodes.player as PlayerNode).viewport_input(event) + self.accept_event() + method input(event: InputEvent) = if event of InputEventScreenTouch: let event = event as InputEventScreenTouch diff --git a/src/ui/markdown_label.nim b/src/ui/markdown_label.nim index b9acda92..3aae28c0 100644 --- a/src/ui/markdown_label.nim +++ b/src/ui/markdown_label.nim @@ -143,7 +143,7 @@ gdobj MarkdownLabel of ScrollContainer: if t of Heading: label.with( - push_font self.local_header_font, push_color ir_black[keyword] + push_font self.local_header_font, push_color ir_black[Keyword] ) self.render_markdown t label.with(pop, pop, newline) @@ -159,7 +159,7 @@ gdobj MarkdownLabel of ScrollContainer: elif t of CodeSpan: label.with( push_font self.local_mono_font, - push_color ir_black[number], + push_color ir_black[Number], add_text t.doc, ) self.render_markdown t @@ -194,7 +194,7 @@ gdobj MarkdownLabel of ScrollContainer: label.with(pop, pop, newline) elif t of Link: let t = Link(t) - label.push_color(ir_black[variable]) + label.push_color(ir_black[Variable]) label.push_font self.local_bold_font label.push_meta(t.url.to_variant) label.add_text t.title diff --git a/src/ui/settings.nim b/src/ui/settings.nim index 1e5f5404..735ca72d 100644 --- a/src/ui/settings.nim +++ b/src/ui/settings.nim @@ -44,10 +44,10 @@ gdobj Settings of PanelContainer: self.environments.select(state.config.environment) let level_label = find("LevelLabel", Label) if ?state.config.connect_address: - level_label.add_color_override("font_color", ir_black[comment]) + level_label.add_color_override("font_color", ir_black[Comment]) self.levels.disabled = true else: - level_label.add_color_override("font_color", ir_black[normal]) + level_label.add_color_override("font_color", ir_black[Normal]) self.levels.disabled = false self.levels.select(state.config.level) @@ -109,7 +109,7 @@ gdobj Settings of PanelContainer: var add_hex = true for color in Colors: - if color != eraser: + if color != Eraser: self.colors.add_item($color) if state.config.player_color == action_colors[color]: add_hex = false diff --git a/src/ui/virtual_joystick.nim b/src/ui/virtual_joystick.nim index 1c498e44..4932e221 100644 --- a/src/ui/virtual_joystick.nim +++ b/src/ui/virtual_joystick.nim @@ -19,7 +19,7 @@ type gdobj VirtualJoystick of Control: var - pressed_color {.gdexport.} = godot.Color(ir_black[number]) + pressed_color {.gdexport.} = godot.Color(ir_black[Number]) deadzone_size {.gdexport, hint: Range, hint_str = "0,200,1".} = 10.0 clampzone_size {.gdexport, hint: Range, hint_str = "0,500,1".} = 75.0 joystick_mode {.gdexport.} = FIXED