Browse Source

Fix ImGuiAutoColor and tests

* Only count functions which start with "test--" rather than taking
anything with "test--" anywhere in the string
* Fix DataBundle looking for the wrong string
* Make unique font data names for each imgui application
master
Macoy Madson 9 months ago
parent
commit
71dc5b80fd
  1. 2
      src/AutoTest.cake
  2. 3
      src/DataBundle.cake
  3. 19
      src/ImGui.cake

2
src/AutoTest.cake

@ -14,7 +14,7 @@
(defun-comptime find-add-tests (environment (& EvaluatorEnvironment) &return bool)
(var functions-to-test (<> std::vector (<> std::pair std::string (* (const Token)))))
(for-in definition-pair (& ObjectDefinitionPair) (field environment definitions)
(unless (!= (in std string npos) (call-on find (field definition-pair first) "test--"))
(unless (= 0 (call-on find (field definition-pair first) "test--"))
(continue))
(call-on push_back functions-to-test (call (in std make_pair)
(field definition-pair first)

3
src/DataBundle.cake

@ -25,8 +25,7 @@
(var filename (* (const char)) (call-on c_str (path filename-token > contents)))
(get-or-create-comptime-var files-to-bundle (<> (in std vector) (in std string)))
(when (= (call-on-ptr end files-to-bundle)
(FindInContainer (deref files-to-bundle)
(call-on c_str (path start-var-name > contents))))
(FindInContainer (deref files-to-bundle) filename))
(call-on-ptr push_back files-to-bundle filename))
(comptime-cond

19
src/ImGui.cake

@ -1,4 +1,4 @@
(import "Dependencies.cake" "CHelpers.cake")
(import "Dependencies.cake" "CHelpers.cake" "ComptimeHelpers.cake")
(c-import "imgui.h")
@ -25,9 +25,20 @@
initialization array
once-per-frame array
shutdown array)
;; This is somewhat unusual. Make unique font data variable names due to "var" always being a
;; global declaration to Cakelisp. The data will still only be bundled once.
;; TODO think of a way to clean this up. DataBundle should handle this better for us.
(var start-font-data-name Token (deref entry-point-name))
(token-contents-snprintf start-font-data-name "start-font-data-%s"
(call-on c_str (field start-font-data-name contents)))
(var end-font-data-name Token (deref entry-point-name))
(token-contents-snprintf end-font-data-name "end-font-data-%s"
(call-on c_str (field end-font-data-name contents)))
(tokenize-push output
(import "DataBundle.cake")
(bundle-file start-font-data end-font-data (unsigned char) "data/Fonts/Ubuntu-R.ttf")
(bundle-file (token-splice-addr start-font-data-name) (token-splice-addr end-font-data-name)
(unsigned char) "data/Fonts/Ubuntu-R.ttf")
(defun (token-splice entry-point-name) (&return int)
(comptime-cond
@ -101,7 +112,9 @@
(set (field font-config FontDataOwnedByAtlas) false)
(var ubuntu-mono-font (* ImFont)
(call-on-ptr AddFontFromMemoryTTF (field imgui-io Fonts)
start-font-data (- end-font-data start-font-data)
(token-splice-addr start-font-data-name)
(- (token-splice-addr end-font-data-name)
(token-splice-addr start-font-data-name))
(* g-font-size-pixels g-dpi-scale)
(addr font-config)))
;; imgui-io.Fonts->GetTexDataAsRGBA32();

Loading…
Cancel
Save