|
|
@ -22,15 +22,9 @@ |
|
|
|
(unsigned char) "data/Fonts/UbuntuMono-R.ttf") |
|
|
|
|
|
|
|
(define-keybind s-quit-keybind (array SDL_SCANCODE_Q keybind-modifier-flags-ctrl)) |
|
|
|
(define-keybind s-next-slide-keybind (array SDL_SCANCODE_RIGHT) |
|
|
|
(array SDL_SCANCODE_DOWN) |
|
|
|
(array SDL_SCANCODE_SPACE) |
|
|
|
(array SDL_SCANCODE_RETURN) |
|
|
|
(array SDL_SCANCODE_PAGEDOWN)) |
|
|
|
(define-keybind s-previous-slide-keybind (array SDL_SCANCODE_LEFT) |
|
|
|
(array SDL_SCANCODE_UP) |
|
|
|
(array SDL_SCANCODE_BACKSPACE) |
|
|
|
(array SDL_SCANCODE_PAGEUP)) |
|
|
|
(define-keybind s-view-selection-keybind (array SDL_SCANCODE_F1)) |
|
|
|
(define-keybind s-view-atlas-keybind (array SDL_SCANCODE_F2)) |
|
|
|
(define-keybind s-view-svg-keybind (array SDL_SCANCODE_F3)) |
|
|
|
|
|
|
|
(define-keybind s-toggle-fullscreen-keybind (array SDL_SCANCODE_F11)) |
|
|
|
|
|
|
@ -159,7 +153,7 @@ |
|
|
|
(var puppet-atlas-width int 0) |
|
|
|
(var puppet-atlas-height int 0) |
|
|
|
(scope |
|
|
|
(var filename (addr (const char)) "data/TestPuppet.svg") |
|
|
|
(var filename (addr (const char)) "data/DoNotCheckIn.svg") |
|
|
|
(set puppet-image (nsvgParseFromFile filename "px" 96.0f)) |
|
|
|
(unless puppet-image |
|
|
|
(vpslog "Failed to load SVG %s\n" filename) |
|
|
@ -173,15 +167,15 @@ |
|
|
|
(malloc (* (path puppet-image > width) (path puppet-image > height) 4))) |
|
|
|
(defer (free image-buffer)) |
|
|
|
|
|
|
|
(each-shape-in-svg-image puppet-image shape |
|
|
|
;; (when (= 0 (strncmp (path shape > id) "Head" (sizeof (path shape > id)))) |
|
|
|
;; (set (path shape > flags) |
|
|
|
;; (bit-xor (path shape > flags) NSVG_FLAGS_VISIBLE))) |
|
|
|
(vpslog "Shape %s\n\tBounds: %.2f %.2f -> %.2f %.2f\n" (path shape > id) |
|
|
|
(at 0 (path shape > bounds)) |
|
|
|
(at 1 (path shape > bounds)) |
|
|
|
(at 2 (path shape > bounds)) |
|
|
|
(at 3 (path shape > bounds)))) |
|
|
|
;; (each-shape-in-svg-image puppet-image shape |
|
|
|
;; ;; (when (= 0 (strncmp (path shape > id) "Head" (sizeof (path shape > id)))) |
|
|
|
;; ;; (set (path shape > flags) |
|
|
|
;; ;; (bit-xor (path shape > flags) NSVG_FLAGS_VISIBLE))) |
|
|
|
;; (vpslog "Shape %s\n\tBounds: %.2f %.2f -> %.2f %.2f\n" (path shape > id) |
|
|
|
;; (at 0 (path shape > bounds)) |
|
|
|
;; (at 1 (path shape > bounds)) |
|
|
|
;; (at 2 (path shape > bounds)) |
|
|
|
;; (at 3 (path shape > bounds)))) |
|
|
|
|
|
|
|
(var puppet-atlas-buffer (addr (unsigned char)) null) |
|
|
|
(defer (when puppet-atlas-buffer (free puppet-atlas-buffer))) |
|
|
@ -240,6 +234,9 @@ |
|
|
|
(defer (dynarray-free (field s-key-states last-frame-states))) |
|
|
|
|
|
|
|
(var enable-fullscreen bool false) |
|
|
|
(var view-selection bool false) |
|
|
|
(var view-atlas bool false) |
|
|
|
(var view-svg bool true) |
|
|
|
|
|
|
|
(var exit-reason (addr (const char)) null) |
|
|
|
(while true |
|
|
@ -259,6 +256,13 @@ |
|
|
|
(SDL_SetWindowFullscreen window SDL_WINDOW_FULLSCREEN_DESKTOP) |
|
|
|
(SDL_SetWindowFullscreen window 0))) |
|
|
|
|
|
|
|
(when (keybind-tapped (addr s-view-selection-keybind) (addr s-key-states)) |
|
|
|
(set view-selection (not view-selection))) |
|
|
|
(when (keybind-tapped (addr s-view-atlas-keybind) (addr s-key-states)) |
|
|
|
(set view-atlas (not view-atlas))) |
|
|
|
(when (keybind-tapped (addr s-view-svg-keybind) (addr s-key-states)) |
|
|
|
(set view-svg (not view-svg))) |
|
|
|
|
|
|
|
(var true-window-width int 0) |
|
|
|
(var true-window-height int 0) |
|
|
|
(SDL_GetWindowSize window (addr true-window-width) (addr true-window-height)) |
|
|
@ -290,26 +294,26 @@ |
|
|
|
(SDL_SetRenderDrawColor renderer 11 11 11 255) |
|
|
|
(SDL_RenderClear renderer) |
|
|
|
|
|
|
|
;; (scope ;; Draw entire SVG |
|
|
|
;; (var source-rectangle SDL_Rect |
|
|
|
;; (array 0 |
|
|
|
;; 0 |
|
|
|
;; svg-image-width |
|
|
|
;; svg-image-height)) |
|
|
|
;; (var destination-rectangle SDL_Rect |
|
|
|
;; (array |
|
|
|
;; 0 |
|
|
|
;; 0 |
|
|
|
;; svg-image-width |
|
|
|
;; svg-image-height)) |
|
|
|
;; (SDL_RenderCopy renderer svg-image-texture |
|
|
|
;; (addr source-rectangle) (addr destination-rectangle))) |
|
|
|
(when view-svg ;; Draw entire SVG |
|
|
|
(var source-rectangle SDL_Rect |
|
|
|
(array 0 |
|
|
|
0 |
|
|
|
svg-image-width |
|
|
|
svg-image-height)) |
|
|
|
(var destination-rectangle SDL_Rect |
|
|
|
(array |
|
|
|
0 |
|
|
|
0 |
|
|
|
svg-image-width |
|
|
|
svg-image-height)) |
|
|
|
(SDL_RenderCopy renderer svg-image-texture |
|
|
|
(addr source-rectangle) (addr destination-rectangle))) |
|
|
|
|
|
|
|
(var mouse-x int 0) |
|
|
|
(var mouse-y int 0) |
|
|
|
(SDL_GetMouseState (addr mouse-x) (addr mouse-y)) |
|
|
|
|
|
|
|
(when puppet-atlas-texture |
|
|
|
(when (and view-atlas puppet-atlas-texture) |
|
|
|
(var atlas-rectangle SDL_Rect |
|
|
|
(array 0 |
|
|
|
0 |
|
|
@ -319,7 +323,7 @@ |
|
|
|
(sdl-print-error) |
|
|
|
(set exit-reason "Failed to render atlas texture"))) |
|
|
|
|
|
|
|
(scope ;; Shape selection and debug viewing |
|
|
|
(when view-selection ;; Shape selection and debug viewing |
|
|
|
(var hovered-shape-id-buffer (array 1024 char) (array 0)) |
|
|
|
(var hovered-write-head (addr char) hovered-shape-id-buffer) |
|
|
|
(each-shape-in-svg-image puppet-image shape |
|
|
@ -392,7 +396,7 @@ |
|
|
|
(/ true-window-width 9) (- true-window-height 10) |
|
|
|
hovered-shape-id-buffer)) |
|
|
|
|
|
|
|
(when packed-rectangles |
|
|
|
(when (and view-atlas packed-rectangles) |
|
|
|
(var current-rectangle (addr stbrp_rect) packed-rectangles) |
|
|
|
(each-shape-in-svg-image puppet-image shape |
|
|
|
(unless (bit-and (path shape > flags) NSVG_FLAGS_VISIBLE) |
|
|
|