Update ui
This commit is contained in:
parent
099fdf1b4b
commit
aee31e8f3a
3 changed files with 94 additions and 61 deletions
27
utils.odin
27
utils.odin
|
|
@ -7,6 +7,9 @@ import "core:fmt"
|
|||
import "core:math/linalg"
|
||||
import "core:mem"
|
||||
|
||||
IS_ENUM :: intrinsics.type_is_enum
|
||||
IS_ENUMERATED_ARRAY :: intrinsics.type_is_enumerated_array
|
||||
|
||||
// Wraps os.read_entire_file and os.write_entire_file, but they also work with emscripten.
|
||||
@(require_results)
|
||||
read_entire_file :: proc(name: string, allocator := context.allocator, loc := #caller_location) -> (data: []byte, success: bool) {
|
||||
|
|
@ -17,7 +20,7 @@ write_entire_file :: proc(name: string, data: []byte, truncate := true) -> (succ
|
|||
return _write_entire_file(name, data, truncate)
|
||||
}
|
||||
|
||||
/// ### RAYLIB SHORTHANDS ### ///
|
||||
/// ### RAYLIB TEXT DRAWING ### ///
|
||||
measure_text :: proc(text: cstring, style: FontStyle) -> v2 {
|
||||
return rl.MeasureTextEx(style.font, text, style.size, style.spacing)
|
||||
}
|
||||
|
|
@ -76,19 +79,33 @@ V2_RIGHT :: v2{1.0, 0.0}
|
|||
V2_UP :: v2{0.0, -1.0}
|
||||
V2_DOWN :: v2{0.0, 1.0}
|
||||
|
||||
/// ### MISCELANIOUS ### ///
|
||||
enum_to_raygui_options_string :: proc($T: typeid, allocator: mem.Allocator) -> cstring where intrinsics.type_is_enum(T) {
|
||||
/// ### ENUM STRINGIFICATION ### ///
|
||||
enum_to_raygui_options_string :: proc($T: typeid, allocator: mem.Allocator) -> cstring where IS_ENUM(T) {
|
||||
b := strings.builder_make(allocator)
|
||||
for element, i in T {
|
||||
option := fmt.aprint(element, allocator = allocator)
|
||||
strings.write_string(&b, strings.to_ada_case(option, allocator))
|
||||
strings.write_rune(&b, ';')
|
||||
fmt.sbprint(&b, strings.to_ada_case(option, allocator), ";", sep = "")
|
||||
}
|
||||
strings.builder_replace_all(&b, "_", " ")
|
||||
b.buf[len(b.buf) - 1] = 0
|
||||
return cstring(raw_data(b.buf[:len(b.buf)]))
|
||||
}
|
||||
|
||||
enum_to_raygui_options_string_hotkey :: proc($T: typeid, hotkeys: ^$N, allocator: mem.Allocator) -> cstring where IS_ENUM(T), IS_ENUMERATED_ARRAY(N) {
|
||||
b := strings.builder_make(allocator)
|
||||
for element, i in T {
|
||||
option := fmt.aprint(element, allocator = allocator)
|
||||
option_ada := strings.to_ada_case(option, allocator)
|
||||
if hotkeys[element] != .KEY_NULL {
|
||||
fmt.sbprint(&b, option_ada, " (", rune(hotkeys[element]), ");", sep = "")
|
||||
} else {
|
||||
fmt.sbprint(&b, option_ada, ";", sep = "")
|
||||
}
|
||||
}
|
||||
strings.builder_replace_all(&b, "_", " ")
|
||||
b.buf[len(b.buf) - 1] = 0
|
||||
return cstring(raw_data(b.buf[:len(b.buf)]))
|
||||
}
|
||||
|
||||
/// ### RECTANGLES ### ///
|
||||
rect2_to_irect2 :: proc "contextless" (rect: rect2) -> irect2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue