mt-lang 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/docs/index.html +4 -3
  3. data/lib/milk_tea/base.rb +1 -1
  4. data/std/asset_pack.mt +267 -0
  5. data/std/async/libuv_runtime.mt +539 -0
  6. data/std/async/mailbox.mt +191 -0
  7. data/std/async/runtime.mt +87 -0
  8. data/std/async.mt +87 -0
  9. data/std/base64.mt +185 -0
  10. data/std/behavior_tree.mt +396 -0
  11. data/std/binary.mt +314 -0
  12. data/std/binary_heap.mt +157 -0
  13. data/std/bitset.mt +239 -0
  14. data/std/box2d.mt +535 -0
  15. data/std/bytes.mt +46 -0
  16. data/std/c/box2d.mt +1254 -0
  17. data/std/c/cgltf.mt +647 -0
  18. data/std/c/cjson.mt +106 -0
  19. data/std/c/crypto.mt +11 -0
  20. data/std/c/crypto_support.h +51 -0
  21. data/std/c/ctype.mt +19 -0
  22. data/std/c/ctype_bindgen.h +29 -0
  23. data/std/c/curl.mt +1223 -0
  24. data/std/c/enet.mt +473 -0
  25. data/std/c/errno.mt +41 -0
  26. data/std/c/errno_bindgen.h +53 -0
  27. data/std/c/flecs.mt +2945 -0
  28. data/std/c/fs.linux.mt +43 -0
  29. data/std/c/fs.windows.mt +43 -0
  30. data/std/c/fs_support.h +954 -0
  31. data/std/c/gl.mt +2065 -0
  32. data/std/c/gl_registry_helpers.h +10748 -0
  33. data/std/c/glfw.mt +499 -0
  34. data/std/c/libc.mt +167 -0
  35. data/std/c/libuv.mt +1491 -0
  36. data/std/c/math.mt +22 -0
  37. data/std/c/math_bindgen.h +31 -0
  38. data/std/c/miniaudio.mt +3420 -0
  39. data/std/c/pcre2.mt +735 -0
  40. data/std/c/process.mt +58 -0
  41. data/std/c/process_support.h +1147 -0
  42. data/std/c/raygui.mt +1602 -0
  43. data/std/c/raylib.mt +1245 -0
  44. data/std/c/raymath.mt +163 -0
  45. data/std/c/rlgl.mt +434 -0
  46. data/std/c/rpng.mt +60 -0
  47. data/std/c/rres.mt +187 -0
  48. data/std/c/sdl3.mt +4132 -0
  49. data/std/c/sqlite3.mt +951 -0
  50. data/std/c/stb_image.mt +52 -0
  51. data/std/c/stb_image_resize2.mt +128 -0
  52. data/std/c/stb_image_write.mt +19 -0
  53. data/std/c/stb_rect_pack.mt +38 -0
  54. data/std/c/stb_truetype.mt +175 -0
  55. data/std/c/stb_vorbis.mt +31 -0
  56. data/std/c/stdio.mt +90 -0
  57. data/std/c/steamworks.h +5769 -0
  58. data/std/c/steamworks.mt +4771 -0
  59. data/std/c/string.mt +16 -0
  60. data/std/c/string_bindgen.h +36 -0
  61. data/std/c/sync.mt +33 -0
  62. data/std/c/sync_support.h +219 -0
  63. data/std/c/terminal.mt +24 -0
  64. data/std/c/terminal_support.h +408 -0
  65. data/std/c/time.mt +26 -0
  66. data/std/c/tls.mt +24 -0
  67. data/std/c/tls_support.h +626 -0
  68. data/std/c/tracy.mt +53 -0
  69. data/std/c/zlib.mt +20 -0
  70. data/std/c/zlib_support.h +239 -0
  71. data/std/c/zstd.mt +231 -0
  72. data/std/cell.mt +60 -0
  73. data/std/cgltf.mt +115 -0
  74. data/std/cjson.mt +90 -0
  75. data/std/cli.mt +768 -0
  76. data/std/cookie.mt +198 -0
  77. data/std/counter.mt +160 -0
  78. data/std/crypto.mt +74 -0
  79. data/std/cstring.mt +13 -0
  80. data/std/ctype.mt +52 -0
  81. data/std/curl/runtime.mt +261 -0
  82. data/std/curl.mt +38 -0
  83. data/std/deque.mt +348 -0
  84. data/std/encoding.mt +93 -0
  85. data/std/enet.mt +133 -0
  86. data/std/env.mt +41 -0
  87. data/std/errno.mt +47 -0
  88. data/std/flecs.mt +978 -0
  89. data/std/fmt.mt +271 -0
  90. data/std/fs.linux.mt +696 -0
  91. data/std/fs.windows.mt +711 -0
  92. data/std/fsm.mt +267 -0
  93. data/std/gl.mt +2062 -0
  94. data/std/glfw.mt +471 -0
  95. data/std/goap.mt +342 -0
  96. data/std/graph.mt +521 -0
  97. data/std/gzip.mt +77 -0
  98. data/std/hash.mt +429 -0
  99. data/std/http/server.mt +810 -0
  100. data/std/http.mt +1227 -0
  101. data/std/intern.mt +53 -0
  102. data/std/jobs.mt +288 -0
  103. data/std/json.mt +627 -0
  104. data/std/libc.mt +34 -0
  105. data/std/libuv.mt +554 -0
  106. data/std/linear_algebra.mt +243 -0
  107. data/std/linked_map.mt +372 -0
  108. data/std/linked_map_view.mt +49 -0
  109. data/std/linked_set.mt +117 -0
  110. data/std/log.mt +69 -0
  111. data/std/map.mt +418 -0
  112. data/std/math.mt +24 -0
  113. data/std/mem/arena.mt +137 -0
  114. data/std/mem/endian.mt +51 -0
  115. data/std/mem/heap.mt +298 -0
  116. data/std/mem/pool.mt +164 -0
  117. data/std/mem/stack.mt +47 -0
  118. data/std/mem/tracking.mt +119 -0
  119. data/std/miniaudio.mt +1299 -0
  120. data/std/multiset.mt +191 -0
  121. data/std/net/channel.mt +727 -0
  122. data/std/net/clock.mt +237 -0
  123. data/std/net/discovery.mt +277 -0
  124. data/std/net/lobby.mt +813 -0
  125. data/std/net/manager.mt +539 -0
  126. data/std/net/mux.mt +839 -0
  127. data/std/net/nat.mt +122 -0
  128. data/std/net/packet.mt +219 -0
  129. data/std/net/punch.mt +162 -0
  130. data/std/net/rpc.mt +119 -0
  131. data/std/net/session.mt +1157 -0
  132. data/std/net/stun.mt +252 -0
  133. data/std/net/sync.mt +183 -0
  134. data/std/net/turn.mt +459 -0
  135. data/std/net.mt +2944 -0
  136. data/std/oauth2.mt +408 -0
  137. data/std/option.mt +51 -0
  138. data/std/ordered_map.mt +497 -0
  139. data/std/ordered_set.mt +348 -0
  140. data/std/path.mt +368 -0
  141. data/std/pcre2/runtime.mt +35 -0
  142. data/std/pcre2.mt +78 -0
  143. data/std/priority_queue.mt +55 -0
  144. data/std/process.mt +837 -0
  145. data/std/queue.mt +55 -0
  146. data/std/random.mt +146 -0
  147. data/std/raygui.mt +99 -0
  148. data/std/raylib/debug_console.mt +71 -0
  149. data/std/raylib/easing.mt +388 -0
  150. data/std/raylib/packed_assets.mt +255 -0
  151. data/std/raylib/runtime.mt +30 -0
  152. data/std/raylib/tracy_gpu.mt +37 -0
  153. data/std/raylib.mt +1510 -0
  154. data/std/raymath.mt +153 -0
  155. data/std/result.mt +89 -0
  156. data/std/rlgl.mt +268 -0
  157. data/std/rpng.mt +46 -0
  158. data/std/rres.mt +36 -0
  159. data/std/sdl3/runtime.mt +54 -0
  160. data/std/sdl3.mt +1731 -0
  161. data/std/serialize.mt +68 -0
  162. data/std/set.mt +124 -0
  163. data/std/spatial.mt +176 -0
  164. data/std/sqlite3.mt +151 -0
  165. data/std/stack.mt +55 -0
  166. data/std/stb_image.mt +47 -0
  167. data/std/stb_image_resize2.mt +41 -0
  168. data/std/stb_image_write.mt +17 -0
  169. data/std/stb_rect_pack.mt +15 -0
  170. data/std/stb_truetype.mt +77 -0
  171. data/std/stb_vorbis.mt +16 -0
  172. data/std/stdio.mt +88 -0
  173. data/std/steamworks.mt +1542 -0
  174. data/std/str.mt +293 -0
  175. data/std/string.mt +234 -0
  176. data/std/sync.mt +194 -0
  177. data/std/tar.mt +704 -0
  178. data/std/terminal.mt +1002 -0
  179. data/std/testing.mt +266 -0
  180. data/std/thread.mt +120 -0
  181. data/std/time.mt +105 -0
  182. data/std/tls.mt +616 -0
  183. data/std/toml.mt +1310 -0
  184. data/std/tracy.mt +42 -0
  185. data/std/uri.mt +118 -0
  186. data/std/url.mt +372 -0
  187. data/std/vec.mt +433 -0
  188. data/std/zstd.mt +94 -0
  189. metadata +187 -2
data/std/queue.mt ADDED
@@ -0,0 +1,55 @@
1
+ import std.deque as deque
2
+
3
+ public struct Queue[T]:
4
+ values: deque.Deque[T]
5
+
6
+
7
+ extending Queue[T]:
8
+ public static function create() -> Queue[T]:
9
+ return Queue[T](values = deque.Deque[T].create())
10
+
11
+
12
+ public static function with_capacity(capacity: ptr_uint) -> Queue[T]:
13
+ var result = Queue[T].create()
14
+ result.reserve(capacity)
15
+ return result
16
+
17
+
18
+ public function len() -> ptr_uint:
19
+ return this.values.len()
20
+
21
+
22
+ public function capacity() -> ptr_uint:
23
+ return this.values.capacity()
24
+
25
+
26
+ public function is_empty() -> bool:
27
+ return this.values.is_empty()
28
+
29
+
30
+ public function iter() -> deque.Iter[T]:
31
+ return this.values.iter()
32
+
33
+
34
+ public function peek() -> ptr[T]?:
35
+ return this.values.first()
36
+
37
+
38
+ public editable function clear() -> void:
39
+ this.values.clear()
40
+
41
+
42
+ public editable function release() -> void:
43
+ this.values.release()
44
+
45
+
46
+ public editable function reserve(min_capacity: ptr_uint) -> void:
47
+ this.values.reserve(min_capacity)
48
+
49
+
50
+ public editable function enqueue(value: T) -> void:
51
+ this.values.push_back(value)
52
+
53
+
54
+ public editable function dequeue() -> Option[T]:
55
+ return this.values.pop_front()
data/std/random.mt ADDED
@@ -0,0 +1,146 @@
1
+ import std.vec as vec
2
+
3
+ const pcg_multiplier: ulong = 0x5851F42D4C957F2D
4
+
5
+ public struct Rng:
6
+ state: ulong
7
+ increment: ulong
8
+
9
+
10
+ public function from_seed(seed: ulong) -> Rng:
11
+ var rng = Rng(state = 0ul, increment = (seed << 1ul) | 1ul)
12
+ rng.next_u32()
13
+ rng.state = rng.state + seed
14
+ rng.next_u32()
15
+ return rng
16
+
17
+
18
+ public function from_seed_str(seed_str: str) -> Rng:
19
+ var hash: ulong = 5381ul
20
+ var i: ptr_uint = 0
21
+ while i < seed_str.len:
22
+ unsafe:
23
+ let byte_val = ulong<-ubyte<-read(seed_str.data + i)
24
+ hash = ((hash << 5ul) + hash) + byte_val
25
+ i += 1
26
+ return from_seed(hash)
27
+
28
+
29
+ extending Rng:
30
+ public editable function next_u32() -> uint:
31
+ let oldstate = this.state
32
+ this.state = oldstate * pcg_multiplier + this.increment
33
+ let xorshifted = uint<-(((oldstate >> 18ul) ^ oldstate) >> 27ul)
34
+ let rot = uint<-(oldstate >> 59ul)
35
+ return (xorshifted >> rot) | (xorshifted << (32u - rot))
36
+
37
+
38
+ public editable function next_u64() -> ulong:
39
+ let hi = ulong<-this.next_u32()
40
+ let lo = ulong<-this.next_u32()
41
+ return (hi << 32ul) | lo
42
+
43
+
44
+ public editable function next_f64() -> double:
45
+ let val = this.next_u32()
46
+ return double<-val / 4294967296.0
47
+
48
+
49
+ public editable function next_f32() -> float:
50
+ let val = this.next_u32()
51
+ return float<-val / 4294967296.0
52
+
53
+
54
+ public editable function next_ubyte() -> ubyte:
55
+ let val = this.next_u32()
56
+ return ubyte<-(val & 0xFFu)
57
+
58
+
59
+ public editable function next_bool() -> bool:
60
+ let val = this.next_u32()
61
+ return (val & 1u) != 0u
62
+
63
+
64
+ public editable function next_uint() -> uint:
65
+ return this.next_u32()
66
+
67
+
68
+ public editable function next_ulong() -> ulong:
69
+ return this.next_u64()
70
+
71
+
72
+ public editable function next_uint_range(min: uint, max: uint) -> uint:
73
+ if min >= max:
74
+ return min
75
+ let range = max - min
76
+ return min + (this.next_u32() % range)
77
+
78
+
79
+ public editable function next_int_range(min: int, max: int) -> int:
80
+ if min >= max:
81
+ return min
82
+ let range = uint<-(max - min)
83
+ let offset = this.next_u32() % range
84
+ return min + int<-offset
85
+
86
+
87
+ public editable function next_f64_range(min: double, max: double) -> double:
88
+ let t = this.next_f64()
89
+ return min + (max - min) * t
90
+
91
+
92
+ public editable function next_f32_range(min: float, max: float) -> float:
93
+ let t = this.next_f32()
94
+ return min + (max - min) * t
95
+
96
+
97
+ public editable function chance(probability: double) -> bool:
98
+ return this.next_f64() < probability
99
+
100
+
101
+ public editable function pick_ref[T](items: span[T]) -> ptr[T]?:
102
+ let len = items.len
103
+ if len == 0z:
104
+ return null
105
+ let index = ptr_uint<-this.next_uint_range(0u, uint<-len)
106
+ return items.data + index
107
+
108
+
109
+ public editable function pick[T](items: ref[vec.Vec[T]]) -> Option[T]:
110
+ let len = items.len()
111
+ if len == 0z:
112
+ return Option[T].none()
113
+ let index = ptr_uint<-this.next_uint_range(0u, uint<-len)
114
+ let ptr = items.get(index) else:
115
+ return Option[T].none()
116
+ return Option[T].some(value = unsafe: read(ptr))
117
+
118
+
119
+ public editable function shuffle[T](items: ref[vec.Vec[T]]) -> void:
120
+ let n = items.len()
121
+ if n <= 1z:
122
+ return
123
+ var i: ptr_uint = n - 1z
124
+ while i > 0z:
125
+ let j = ptr_uint<-this.next_uint_range(0u, uint<-(i + 1z))
126
+ items.swap(i, j)
127
+ i -= 1
128
+
129
+
130
+ public editable function skip(count: ptr_uint) -> void:
131
+ var i: ptr_uint = 0
132
+ while i < count:
133
+ this.next_u32()
134
+ i += 1
135
+
136
+
137
+ public editable function fork() -> Rng:
138
+ let seed = this.next_u64()
139
+ return from_seed(seed)
140
+
141
+
142
+ public editable function seeds() -> array[ulong, 4]:
143
+ return array[ulong, 4](
144
+ this.next_u64(), this.next_u64(),
145
+ this.next_u64(), this.next_u64()
146
+ )
data/std/raygui.mt ADDED
@@ -0,0 +1,99 @@
1
+ # generated by mtc imported-bindings from std.c.raygui using bindings/imported/raygui.binding.json
2
+
3
+ import std.c.raygui as c
4
+ import std.raylib as rl
5
+
6
+ public type Vector2 = rl.Vector2
7
+ public type Vector3 = rl.Vector3
8
+ public type Color = rl.Color
9
+ public type Rectangle = rl.Rectangle
10
+ public type Font = rl.Font
11
+ public type StyleProp = c.GuiStyleProp
12
+ public type Result_ = c.GuiResult
13
+ public type State = c.GuiState
14
+ public type TextAlignment = c.GuiTextAlignment
15
+ public type TextAlignmentVertical = c.GuiTextAlignmentVertical
16
+ public type TextWrapMode = c.GuiTextWrapMode
17
+ public type Control = c.GuiControl
18
+ public type ControlProperty = c.GuiControlProperty
19
+ public type DefaultProperty = c.GuiDefaultProperty
20
+ public type ToggleProperty = c.GuiToggleProperty
21
+ public type SliderProperty = c.GuiSliderProperty
22
+ public type ProgressBarProperty = c.GuiProgressBarProperty
23
+ public type ScrollBarProperty = c.GuiScrollBarProperty
24
+ public type CheckBoxProperty = c.GuiCheckBoxProperty
25
+ public type ComboBoxProperty = c.GuiComboBoxProperty
26
+ public type DropdownBoxProperty = c.GuiDropdownBoxProperty
27
+ public type TextBoxProperty = c.GuiTextBoxProperty
28
+ public type ValueBoxProperty = c.GuiValueBoxProperty
29
+ public type TabBarProperty = c.GuiTabBarProperty
30
+ public type ListViewProperty = c.GuiListViewProperty
31
+ public type ColorPickerProperty = c.GuiColorPickerProperty
32
+ public type IconName = c.GuiIconName
33
+
34
+ public const RAYGUI_VERSION_MAJOR: int = c.RAYGUI_VERSION_MAJOR
35
+ public const RAYGUI_VERSION_MINOR: int = c.RAYGUI_VERSION_MINOR
36
+ public const RAYGUI_VERSION_PATCH: int = c.RAYGUI_VERSION_PATCH
37
+ public const SCROLLBAR_LEFT_SIDE: int = c.SCROLLBAR_LEFT_SIDE
38
+ public const SCROLLBAR_RIGHT_SIDE: int = c.SCROLLBAR_RIGHT_SIDE
39
+
40
+ public foreign function enable() -> void = c.GuiEnable
41
+ public foreign function disable() -> void = c.GuiDisable
42
+ public foreign function lock() -> void = c.GuiLock
43
+ public foreign function unlock() -> void = c.GuiUnlock
44
+ public foreign function is_locked() -> bool = c.GuiIsLocked
45
+ public foreign function set_alpha(alpha: float) -> void = c.GuiSetAlpha
46
+ public foreign function set_state(state: State) -> void = c.GuiSetState(int<-state)
47
+ public foreign function get_state() -> State = State<-c.GuiGetState()
48
+ public foreign function set_font(font: Font) -> void = c.GuiSetFont
49
+ public foreign function get_font() -> Font = c.GuiGetFont
50
+ public foreign function set_style(control: Control, property: int, value: int) -> void = c.GuiSetStyle(int<-control, property, value)
51
+ public foreign function get_style(control: Control, property: int) -> int = c.GuiGetStyle(int<-control, property)
52
+ public foreign function load_style(file_name: str as cstr) -> void = c.GuiLoadStyle
53
+ public foreign function load_style_from_memory(file_data: const_ptr[ubyte], data_size: int) -> void = c.GuiLoadStyleFromMemory
54
+ public foreign function load_style_default() -> void = c.GuiLoadStyleDefault
55
+ public foreign function enable_tooltip() -> void = c.GuiEnableTooltip
56
+ public foreign function disable_tooltip() -> void = c.GuiDisableTooltip
57
+ public foreign function set_tooltip(tooltip: str as cstr) -> void = c.GuiSetTooltip
58
+ public foreign function icon_text(icon_id: IconName, text: str as cstr) -> cstr = c.GuiIconText(int<-icon_id, text)
59
+ public foreign function set_icon_scale(scale: int) -> void = c.GuiSetIconScale
60
+ public foreign function get_icons() -> span[uint] = span[uint](data = c.GuiGetIcons(), len = 2048)
61
+ public foreign function load_icons_from_memory(file_data: const_ptr[ubyte], data_size: int, load_icons_name: bool) -> ptr[ptr[char]] = c.GuiLoadIconsFromMemory
62
+ public foreign function draw_icon(icon_id: IconName, pos_x: int, pos_y: int, pixel_size: int, color: Color) -> void = c.GuiDrawIcon(int<-icon_id, pos_x, pos_y, pixel_size, color)
63
+ public foreign function get_text_width(text: str as cstr) -> int = c.GuiGetTextWidth
64
+ public foreign function window_box(bounds: Rectangle, title: str as cstr) -> int = c.GuiWindowBox
65
+ public foreign function group_box(bounds: Rectangle, text: str as cstr) -> int = c.GuiGroupBox
66
+ public foreign function line(bounds: Rectangle, text: str as cstr) -> int = c.GuiLine
67
+ public foreign function panel(bounds: Rectangle, text: str as cstr) -> int = c.GuiPanel
68
+ public foreign function scroll_panel(bounds: Rectangle, text: str as cstr, content: Rectangle, inout scroll: Vector2, out view: Rectangle) -> int = c.GuiScrollPanel
69
+ public foreign function label(bounds: Rectangle, text: str as cstr) -> int = c.GuiLabel
70
+ public foreign function button(bounds: Rectangle, text: str as cstr) -> int = c.GuiButton
71
+ public foreign function label_button(bounds: Rectangle, text: str as cstr) -> int = c.GuiLabelButton
72
+ public foreign function toggle(bounds: Rectangle, text: str as cstr, inout active: bool) -> int = c.GuiToggle
73
+ public foreign function toggle_group(bounds: Rectangle, text: str as cstr, inout active: int) -> int = c.GuiToggleGroup
74
+ public foreign function toggle_slider(bounds: Rectangle, text: str as cstr, inout active: int) -> int = c.GuiToggleSlider
75
+ public foreign function check_box(bounds: Rectangle, text: str as cstr, inout checked: bool) -> int = c.GuiCheckBox
76
+ public foreign function combo_box(bounds: Rectangle, text: str as cstr, inout active: int) -> int = c.GuiComboBox
77
+ public foreign function dropdown_box(bounds: Rectangle, text: str as cstr, inout active: int, edit_mode: bool) -> int = c.GuiDropdownBox
78
+ public foreign function spinner(bounds: Rectangle, text: str as cstr, inout value: int, min_value: int, max_value: int, edit_mode: bool) -> int = c.GuiSpinner
79
+ public foreign function value_box(bounds: Rectangle, text: str as cstr, inout value: int, min_value: int, max_value: int, edit_mode: bool) -> int = c.GuiValueBox
80
+ public foreign function value_box_float[N](bounds: Rectangle, text: str as cstr, text_value: str_buffer[N] as ptr[char], inout value: float, edit_mode: bool) -> int = c.GuiValueBoxFloat(bounds, text, text_value, value, edit_mode)
81
+ public foreign function text_box[N](bounds: Rectangle, text: str_buffer[N] as ptr[char], edit_mode: bool) -> int = c.GuiTextBox(bounds, text, int<-(text_public.capacity() + 1), edit_mode)
82
+ public foreign function slider(bounds: Rectangle, text_left: str as cstr, text_right: str as cstr, inout value: float, min_value: float, max_value: float) -> int = c.GuiSlider
83
+ public foreign function slider_bar(bounds: Rectangle, text_left: str as cstr, text_right: str as cstr, inout value: float, min_value: float, max_value: float) -> int = c.GuiSliderBar
84
+ public foreign function progress_bar(bounds: Rectangle, text_left: str as cstr, text_right: str as cstr, inout value: float, min_value: float, max_value: float) -> int = c.GuiProgressBar
85
+ public foreign function status_bar(bounds: Rectangle, text: str as cstr) -> int = c.GuiStatusBar
86
+ public foreign function dummy_rec(bounds: Rectangle, text: str as cstr) -> int = c.GuiDummyRec
87
+ public foreign function grid(bounds: Rectangle, text: str as cstr, spacing: float, subdivs: int, out mouse_cell: Vector2) -> int = c.GuiGrid
88
+ public foreign function list_view(bounds: Rectangle, text: str as cstr, inout scroll_index: int, inout active: int) -> int = c.GuiListView
89
+ public foreign function list_view_ex(bounds: Rectangle, text: span[str] as span[ptr[char]], inout scroll_index: int, inout active: int, inout focus: int) -> int = c.GuiListViewEx(bounds, text.data, int<-text.len, scroll_index, active, focus)
90
+ public foreign function tab_bar(bounds: Rectangle, text: str as cstr, inout hscroll: int, inout active: int) -> int = c.GuiTabBar
91
+ public foreign function tab_bar_ex(bounds: Rectangle, text: span[str] as span[ptr[char]], inout hscroll: int, inout active: int, inout focus: int) -> int = c.GuiTabBarEx(bounds, text.data, int<-text.len, hscroll, active, focus)
92
+ public foreign function message_box(bounds: Rectangle, title: str as cstr, message: str as cstr, buttons: str as cstr, out btn_active: int) -> int = c.GuiMessageBox
93
+ public foreign function text_input_box[N](bounds: Rectangle, title: str as cstr, message: str as cstr, buttons: str as cstr, text: str_buffer[N] as ptr[char], out btn_active: int, inout secret_view_active: bool) -> int = c.GuiTextInputBox(bounds, title, message, buttons, text, int<-(text_public.capacity() + 1), btn_active, secret_view_active)
94
+ public foreign function color_picker(bounds: Rectangle, text: str as cstr, inout color: Color) -> int = c.GuiColorPicker
95
+ public foreign function color_panel(bounds: Rectangle, text: str as cstr, inout color: Color) -> int = c.GuiColorPanel
96
+ public foreign function color_bar_alpha(bounds: Rectangle, text: str as cstr, inout alpha: float) -> int = c.GuiColorBarAlpha
97
+ public foreign function color_bar_hue(bounds: Rectangle, text: str as cstr, inout value: float) -> int = c.GuiColorBarHue
98
+ public foreign function color_picker_hsv(bounds: Rectangle, text: str as cstr, inout color_hsv: Vector3) -> int = c.GuiColorPickerHSV
99
+ public foreign function color_panel_hsv(bounds: Rectangle, text: str as cstr, inout color_hsv: Vector3) -> int = c.GuiColorPanelHSV
@@ -0,0 +1,71 @@
1
+ import std.raylib as rl
2
+
3
+ public struct DebugState:
4
+ enabled: bool
5
+ visible: bool
6
+
7
+
8
+ public function debug_init() -> DebugState:
9
+ return DebugState(
10
+ enabled = true,
11
+ visible = false
12
+ )
13
+
14
+
15
+ public function debug_update(state: ref[DebugState]) -> void:
16
+ let key_f3 = rl.is_key_pressed(rl.KeyboardKey.KEY_F3)
17
+ if key_f3:
18
+ state.visible = not(state.visible)
19
+
20
+
21
+ public function debug_draw(state: const_ptr[DebugState], font_size: int) -> void:
22
+ var visible = false
23
+ unsafe:
24
+ visible = read(state).visible
25
+
26
+ if not visible:
27
+ return
28
+
29
+ let width = rl.get_screen_width()
30
+ let height = rl.get_screen_height()
31
+ let panel_x = width - 290
32
+ let panel_y = 10
33
+ let panel_width = 280
34
+ let panel_height = 160
35
+
36
+ rl.draw_rectangle(
37
+ panel_x,
38
+ panel_y,
39
+ panel_width,
40
+ panel_height,
41
+ rl.Color(r = 0, g = 0, b = 0, a = 200)
42
+ )
43
+
44
+ let fps = rl.get_fps()
45
+ let fps_text = f"FPS: #{fps}"
46
+ rl.draw_text(
47
+ fps_text,
48
+ panel_x + 4,
49
+ panel_y + 4,
50
+ font_size,
51
+ rl.Color(r = 0, g = 255, b = 0, a = 255)
52
+ )
53
+
54
+ let dt = rl.get_frame_time() * 1000.0
55
+ let dt_text = f"Frame: #{dt} ms"
56
+ rl.draw_text(
57
+ dt_text,
58
+ panel_x + 4,
59
+ panel_y + 4 + font_size + 4,
60
+ font_size,
61
+ rl.Color(r = 255, g = 255, b = 0, a = 255)
62
+ )
63
+
64
+ let screen_text = f"#{width}x#{height}"
65
+ rl.draw_text(
66
+ screen_text,
67
+ panel_x + 4,
68
+ panel_y + 4 + (font_size + 4) * 2,
69
+ font_size,
70
+ rl.Color(r = 200, g = 200, b = 200, a = 255)
71
+ )