Browse Source

Fix assert when minimizing window

The table wasn't being created when window is not visible.

* Move save/load config variables to top of file for easier setting
filter-focus
Macoy Madson 1 year ago
parent
commit
46d3c045af
  1. 27
      src/FileHelper.cake

27
src/FileHelper.cake

@ -32,12 +32,18 @@
(import "ProfilerNull.cake")))
;;
;; Types and stuff
;; Types, config, and stuff
;;
(var-global g-is-first-time-run bool true) ;; Pops Help window on first run
(var c-check-save-userdata-interval-seconds (const float) 5.f)
;; (var g-should-save-load-imgui-config bool true)
(var g-should-save-load-imgui-config bool false)
(var g-should-save-load-user-config bool true)
;; (var g-should-save-load-user-config bool false)
(var g-treemap-multithreaded-state (* treemap-file-system-multithreaded-state) null)
(var g-treemap-request-refresh-time Uint64 0)
(defun-local treemap-request-refresh ()
@ -846,7 +852,10 @@
;; Use a child window so that the filter is still visible even after scrolling entries
(imgui-call BeginChild "Directory Listing Child")
(imgui-call BeginTable "Directory Listing" 5 ImGuiTableFlags_SizingStretchProp)
(unless (imgui-call BeginTable "Directory Listing" 5 ImGuiTableFlags_SizingStretchProp)
(imgui-call EndChild)
(imgui-call End)
(return))
(imgui-call TableSetupColumn "Name" ImGuiTableColumnFlags_WidthStretch)
(imgui-call TableSetupColumn "Size" ImGuiTableColumnFlags_WidthFixed)
(imgui-call TableSetupColumn "Type" ImGuiTableColumnFlags_WidthFixed)
@ -1245,18 +1254,12 @@
(SDL_free pref-path)
(SDL_Log "Userdata directory: %s\n" g-userdata-output-dir)
(var should-save-load-imgui-config bool true)
;; (var should-save-load-imgui-config bool false)
(var should-save-load-user-config bool true)
;; (var should-save-load-user-config bool false)
;; Make sure imgui saves preferences to pref dir as well. The first load happens in the main loop
(scope
(var imgui-io (& ImGuiIO) (imgui-call GetIO))
(snprintf g-imgui-output-file (sizeof g-imgui-output-file) "%simgui.ini"
g-userdata-output-dir)
(if should-save-load-imgui-config
(if g-should-save-load-imgui-config
(scope (SDL_Log "Imgui output to: %s\n" g-imgui-output-file)
(set (field imgui-io IniFilename) g-imgui-output-file))
;; Temporarily disable save/load
@ -1280,7 +1283,7 @@
;; (strdict-use-key-arena g-userdata-dict)
(strdict-use-key-strdup g-userdata-dict)
(if should-save-load-user-config
(if g-should-save-load-user-config
(unless (load-state-s-expr)
(SDL_Log "Did not load UserData\n"))
(load-state-default))
@ -1362,7 +1365,7 @@
(profiler-mark-frame)
(time-this-scope scope-6 "User Frame")
(when (and should-save-load-user-config
(when (and g-should-save-load-user-config
(> (/ (- (SDL_GetPerformanceCounter) last-time-saved)
(type-cast (SDL_GetPerformanceFrequency) float))
c-check-save-userdata-interval-seconds))
@ -1657,7 +1660,7 @@ Depending on the error, open the UserData.cakedata file in a text editor and see
(body ;; Shut down
(time-this-scope scope-7 "User shut down")
(when should-save-load-user-config
(when g-should-save-load-user-config
(unless (save-state-s-expr)
(SDL_Log "error: failed to save state")))
(load-save-shutdown)

Loading…
Cancel
Save