Browse Source

Rename global, fix array parsing

* Add g- for global
* Decrease frequency of checking for wallpaper changes
* Don't require space after array keyword in Introspection
master
Macoy Madson 3 months ago
parent
commit
7b1e76303b
  1. 12
      src/ImGuiAutoColor.cake
  2. 4
      src/Introspection.cake

12
src/ImGuiAutoColor.cake

@ -28,7 +28,8 @@
(array 0x7a 0x74 0x71)))
;; Colors are in range 0 to 1.f
(var-global current-interpolate-base16-colors ([] 16 ([] 3 float)) (array 0))
(var-global g-current-interpolate-base16-colors ([] 16 ([] 3 float)) (array 0))
(var check-for-background-change-rate (const float) 5.f)
(var target-set-time float 0.f)
@ -101,7 +102,7 @@
(defun imgui-auto-color-initialize ()
(each-in-array current-base16-colors i
(each-in-range 3 component
(set (at i component current-interpolate-base16-colors)
(set (at i component g-current-interpolate-base16-colors)
(/ (type-cast (at i component current-base16-colors) float) 255.f))))
(memcpy target-base16-colors current-base16-colors (sizeof target-base16-colors))
(set-imgui-colors-from-base16 current-base16-colors))
@ -121,7 +122,6 @@
;; Automatically update the theme on background change
(var current-time float (get-time-since-startup))
(var-static last-background-changed-check float current-time)
(var check-for-background-change-rate (const float) 1.f)
(when (> (- current-time last-background-changed-check)
check-for-background-change-rate)
(set last-background-changed-check current-time)
@ -150,15 +150,15 @@
(each-in-array target-base16-colors i
(each-in-range 3 component
(var current-value float (at i component current-interpolate-base16-colors))
(var current-value float (at i component g-current-interpolate-base16-colors))
(var-cast-to target-value float (at i component target-base16-colors))
(set target-value (/ target-value 255.f))
(set (at i component current-interpolate-base16-colors)
(set (at i component g-current-interpolate-base16-colors)
(+ current-value
(* (- target-value current-value)
transition-speed)))
(set (at i component current-base16-colors)
(type-cast (round (* 255.f (at i component current-interpolate-base16-colors)))
(type-cast (round (* 255.f (at i component g-current-interpolate-base16-colors)))
(unsigned char)))))
(unless (= 0 (memcmp before-update-values current-base16-colors (sizeof before-update-values)))

4
src/Introspection.cake

@ -1149,8 +1149,8 @@
(var value-argument-start (* (const char)) argument-start)
(var value-argument-end (* (const char)) argument-end)
(when (path current-field > count) ;; Handle (array)
(var array-keyword-length int 6) ;; Length of "array "
(when (!= 0 (strncmp (+ 1 argument-start) "array " array-keyword-length))
(var array-keyword-length int 5) ;; Length of "array "
(when (!= 0 (strncmp (+ 1 argument-start) "array" array-keyword-length))
(fprintf stderr "error: expected (array) for field %s, got "
(path current-field > name))
(print-string-range argument-start argument-end true)

Loading…
Cancel
Save