jak-project/goal_src/engine/ui/hud.gc

537 lines
16 KiB
Common Lisp
Raw Normal View History

;;-*-Lisp-*-
2020-09-04 14:44:23 -04:00
(in-package goal)
;; name: hud.gc
;; name in dgo: hud
;; dgos: GAME, ENGINE
;; TODO - for hud-classes
(define-extern hud-init-by-other (function int none :behavior hud))
;; DECOMP BEGINS
(defmethod relocate hud ((obj hud) (arg0 int))
(dotimes (v1-0 (-> obj nb-of-particles))
(if (nonzero? (-> obj particles v1-0 part))
(&+! (-> obj particles v1-0 part) arg0)
)
)
(the-as hud ((method-of-type process relocate) obj arg0))
)
(defmethod deactivate hud ((obj hud))
(dotimes (v1-0 9)
(if (and (-> *hud-parts* parts v1-0) (= (ppointer->process (-> *hud-parts* parts v1-0)) obj))
(set! (-> *hud-parts* parts v1-0) (the-as (pointer process) #f))
)
)
(dotimes (s5-0 (-> obj nb-of-particles))
(kill-and-free-particles (-> obj particles s5-0 part))
(set! (-> obj particles s5-0 part matrix) -1)
)
((method-of-type process deactivate) obj)
(none)
)
(defmethod dummy-15 hud ((obj hud))
(when (and (not (dummy-14 obj)) (not (paused?)))
(dotimes (s5-0 (-> obj nb-of-particles))
(when (!= s5-0 (-> obj skip-particle))
(if (or (!= (-> obj particles 0 pos x) 0.0) (!= (-> obj particles 0 pos y) 0.0))
(spawn (-> obj particles s5-0 part) *null-vector*)
)
)
)
)
0
(none)
)
(defmethod TODO-RENAME-16 hud ((obj hud) (arg0 int) (arg1 int))
(if (= arg0 (-> obj target-value))
(set! (-> obj last-target-equal-time) (the-as uint (-> *display* base-frame-counter)))
)
(when (and (not *progress-process*) (and
(!= (-> obj last-hide-time) (-> *display* base-frame-counter))
(not (movie?))
(>= (- (-> *display* base-frame-counter) (-> *game-info* letterbox-time)) 30)
(>= (- (-> *display* base-frame-counter) (-> *game-info* blackout-time)) 30)
(not (and *target* (logtest? (-> *target* state-flags) 256)))
)
)
(when (or
(!= (-> obj value) arg0)
(!= (-> obj value2) arg1)
(-> obj force-on-screen)
(or
(and (cpad-hold? 0 l2) (not (-> obj disable)))
(and (not *cheat-mode*) (cpad-hold? 0 r2))
(-> obj first-init)
)
)
(cond
((and
(-> obj increment-on-event)
(< (-> obj value) arg0)
(not (-> obj first-init))
(< (- (-> *display* base-frame-counter) (the-as int (-> obj last-target-equal-time))) 450)
)
(when (and
(!= (-> obj value) (-> obj target-value))
(>= (- (-> *display* base-frame-counter) (the-as int (-> obj last-increment-time))) 30)
)
(sound-play-by-name (static-sound-name "cursor-options") (new-sound-id) 1024 0 0 1 #t)
(+! (-> obj value) 1)
(set! (-> obj last-increment-time) (the-as uint (-> *display* base-frame-counter)))
)
)
(else
(if (not (and
(not (-> obj first-init))
(>= (- (-> *display* base-frame-counter) (the-as int (-> obj last-target-equal-time))) 450)
)
)
(set! (-> obj value) arg0)
)
(set! (-> obj target-value) arg0)
(set! (-> obj last-target-equal-time) (the-as uint (-> *display* base-frame-counter)))
)
)
(set! (-> obj value2) arg1)
(when (and (not (movie?)) (= *master-mode* 'game) (not (-> obj first-init)) (not (-> obj disable)))
(if (>= (-> obj friend) 0)
(send-event (ppointer->process (-> *hud-parts* parts (-> obj friend))) 'show)
)
(go hud-arriving)
)
(set! (-> obj trigger-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> obj first-init) #f)
)
)
0
(none)
)
(defmethod dummy-17 hud ((obj hud))
(dotimes (v1-0 (-> obj nb-of-icons))
(set-vector!
(-> obj icons v1-0 icon 0 root scale)
(* (-> obj icons v1-0 scale-x) (-> *video-parms* relative-x-scale))
(* (-> obj icons v1-0 scale-y) (-> *video-parms* relative-y-scale))
(* (-> obj icons v1-0 scale-x) (-> *video-parms* relative-x-scale))
1.0
)
(set! (-> obj icons v1-0 icon 0 root trans x)
(the float (+ (-> obj icons v1-0 icon-x) -256 (* (-> obj x-sgn) (-> obj offset))))
)
(set! (-> obj icons v1-0 icon 0 root trans y)
(- (+ (the float (-> obj icons v1-0 icon-y))
(* (the float (-> obj y-sgn))
(the float (-> obj offset))
(-> *video-parms* relative-y-scale)
(-> *video-parms* relative-y-scale)
)
(* (the float (-> obj y-offset)) (-> *video-parms* relative-x-scale-reciprical))
)
(the float (-> *video-parms* screen-sy))
)
)
)
0
(none)
)
(defmethod dummy-18 hud ((obj hud))
(dotimes (s5-0 (-> obj nb-of-particles))
(when (!= (-> obj skip-particle) -2)
(set! (-> obj particles s5-0 pos x)
(+ -256.0 (the float (* (-> obj x-sgn) (-> obj offset))) (-> obj particles s5-0 init-pos x))
)
(set! (-> obj particles s5-0 pos y)
(* 0.5 (- (* (-> *video-parms* relative-y-scale)
(+ (-> obj particles s5-0 init-pos y)
(the float (* (-> obj y-sgn) (-> obj offset)))
(* (the float (-> obj y-offset)) (-> *video-parms* relative-x-scale-reciprical))
)
)
(the float (-> *video-parms* screen-sy))
)
)
)
(set! (-> obj particles s5-0 pos z) (-> obj particles s5-0 init-pos z))
)
(if (> (-> obj particles s5-0 part matrix) 0)
(set-vector!
(sprite-get-user-hvdf (-> obj particles s5-0 part matrix))
(the float (+ (the int (-> obj particles s5-0 pos x)) 2048))
(the float (+ (the int (-> obj particles s5-0 pos y)) 2048))
(- (-> *math-camera* hvdf-off z) (* 1024.0 (-> obj particles s5-0 pos z)))
(-> *math-camera* hvdf-off w)
)
)
)
0
(none)
)
(defmethod TODO-RENAME-19 hud ((obj hud))
0
(none)
)
(defmethod init-particles! hud ((obj hud) (arg0 int))
0
(none)
)
(defmethod first-icon-x hud ((obj hud))
0
)
(defmethod first-icon-y hud ((obj hud))
0
)
(defmethod inc-value hud ((obj hud))
0.0
)
(defmethod dec-value hud ((obj hud))
0.0
)
(defmethod animate! hud ((obj hud) (arg0 symbol) (arg1 symbol))
0
(none)
)
(defmethod dummy-14 hud ((obj hud))
(= (-> obj next-state name) 'hud-hidden)
(none)
)
(defstate hud-hidden (hud)
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(local-vars (v0-0 object))
(case arg2
(('show)
(if (and (not *progress-process*) (!= (-> self last-hide-time) (-> *display* base-frame-counter)))
(go hud-arriving)
)
)
(('hide)
(set! v0-0 (-> *display* base-frame-counter))
(set! (-> self last-hide-time) (the-as uint v0-0))
v0-0
)
(('hide-quick)
(set! v0-0 (-> *display* base-frame-counter))
(set! (-> self last-hide-time) (the-as uint v0-0))
v0-0
)
(('increment)
(set! v0-0 (+ (-> self target-value) 1))
(set! (-> self target-value) (the-as int v0-0))
v0-0
)
(('sync)
(set! v0-0 #t)
(set! (-> self first-init) (the-as symbol v0-0))
v0-0
)
(('disable)
(set! v0-0 #t)
(set! (-> self disable) (the-as symbol v0-0))
v0-0
)
(('enable)
(set! (-> self disable) #f)
#f
)
)
)
:enter
(behavior ()
(set! (-> self offset) 128)
(dummy-17 self)
(dummy-18 self)
(let ((gp-0 (-> self child)))
(while gp-0
(send-event (ppointer->process gp-0) 'draw #f)
(set! gp-0 (-> gp-0 0 brother))
)
)
(dotimes (gp-1 (-> self nb-of-particles))
(kill-and-free-particles (-> self particles gp-1 part))
(set! (-> self particles gp-1 part matrix) -1)
)
(none)
)
:exit
(behavior () (set! (-> self y-offset) (-> self next-y-offset)) (none))
:code
(behavior ()
(logior! (-> self mask) (process-mask sleep-code))
(while #t
(suspend)
)
(none)
)
:post
(behavior ()
(if (-> self deactivate-when-hidden)
(deactivate self)
)
(TODO-RENAME-19 self)
(none)
)
)
(defstate hud-arriving (hud)
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(local-vars (v0-3 object))
(case arg2
(('hide-quick)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self force-on-screen) #f)
(set! (-> self offset) 128)
(dummy-18 self)
(dummy-17 self)
(TODO-RENAME-19 self)
(go hud-hidden)
)
(('hide)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self force-on-screen) #f)
(go hud-leaving 10)
)
(('show)
(if (and (not *progress-process*) (!= (-> self last-hide-time) (-> *display* base-frame-counter)))
(go hud-arriving)
)
)
(('increment)
(set! v0-3 (+ (-> self target-value) 1))
(set! (-> self target-value) (the-as int v0-3))
v0-3
)
(('sync)
(set! v0-3 #t)
(set! (-> self first-init) (the-as symbol v0-3))
v0-3
)
(('disable)
(set! v0-3 #t)
(set! (-> self disable) (the-as symbol v0-3))
v0-3
)
(('enable)
(set! (-> self disable) #f)
#f
)
)
)
:enter
(behavior ()
(let ((gp-0 (-> self child)))
(while gp-0
(send-event (ppointer->process gp-0) 'draw #t)
(set! gp-0 (-> gp-0 0 brother))
)
)
(dotimes (gp-1 (-> self nb-of-particles))
(if (= (-> self particles gp-1 part matrix) -1)
(set! (-> self particles gp-1 part matrix) (sprite-allocate-user-hvdf))
)
)
(none)
)
:code
(behavior ()
(while #t
(if (not (paused?))
(set! (-> self offset) (seekl (-> self offset) 0 (the int (* 15.0 (-> *display* time-adjust-ratio)))))
)
(dummy-17 self)
(if (<= (-> self offset) 0)
(go hud-in)
)
(when (movie?)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self force-on-screen) #f)
(set! (-> self offset) 128)
(dummy-18 self)
(dummy-17 self)
(TODO-RENAME-19 self)
(go hud-hidden)
)
(suspend)
)
(none)
)
:post
(behavior () (TODO-RENAME-19 self) (dummy-18 self) (dummy-15 self) (none))
)
(defstate hud-in (hud)
:event
(-> hud-arriving event)
:code
(behavior ()
(set! (-> self trigger-time) (the-as uint (-> *display* base-frame-counter)))
(while (and (< (- (-> *display* base-frame-counter) (the-as int (-> self trigger-time))) 600) (not (movie?)))
(set! (-> self offset) 0)
(dummy-17 self)
(suspend)
)
(when (movie?)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self force-on-screen) #f)
(set! (-> self offset) 128)
(dummy-18 self)
(dummy-17 self)
(TODO-RENAME-19 self)
(go hud-hidden)
)
(go hud-leaving 5)
(none)
)
:post
(-> hud-arriving post)
)
(defstate hud-leaving (hud)
:event
(-> hud-arriving event)
:code
(behavior ((arg0 int))
(while #t
(if (not (paused?))
(set! (-> self offset)
(seekl (-> self offset) 128 (the int (* (the float arg0) (-> *display* time-adjust-ratio))))
)
)
(dummy-17 self)
(when (movie?)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self force-on-screen) #f)
(set! (-> self offset) 128)
(dummy-18 self)
(dummy-17 self)
(TODO-RENAME-19 self)
(go hud-hidden)
)
(if (>= (-> self offset) 128)
(go hud-hidden)
)
(suspend)
)
(none)
)
:post
(-> hud-arriving post)
)
(defbehavior hud-init-by-other hud ((arg0 int))
(set! (-> self nb-of-icons) 0)
(set! (-> self nb-of-particles) 0)
(set! (-> self max-nb-of-particles) 7)
(set! (-> self first-init) #t)
(set! (-> self friend) -1)
(set! (-> self last-increment-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self last-target-equal-time) (the-as uint (-> *display* base-frame-counter)))
(set! (-> self increment-on-event) #f)
(set! (-> self skip-particle) -1)
(set! (-> self disable) #f)
(set! (-> self force-on-screen) #f)
(set! (-> self deactivate-when-hidden) #f)
(set! (-> self y-offset) 0)
(set! (-> self next-y-offset) 0)
(set! (-> self last-hide-time) (the-as uint (-> *display* base-frame-counter)))
(logior! (-> self mask) (process-mask menu))
(logclear! (-> self mask) (process-mask pause progress))
(init-particles! self arg0)
(dummy-17 self)
(dummy-18 self)
(go hud-hidden)
(none)
)
(defun send-hud-increment-event ((arg0 hud))
(if (-> arg0 increment-on-event)
(send-event arg0 'increment)
)
)
(defstate hud-collecting (collectable)
:trans
(behavior ()
(case (-> self type)
((fuel-cell)
(fuel-cell-animate)
)
)
(none)
)
:code
(behavior ((arg0 handle))
(let ((s5-0 (new 'stack-no-clear 'vector)))
(let ((s4-0 (handle->process arg0)))
(set! (-> s5-0 x) (- (the float (+ (first-icon-x (the-as hud s4-0)) -256)) (-> self root-override trans x)))
(set! (-> s5-0 y) (- (the float (- (first-icon-y (the-as hud s4-0)) (-> *video-parms* screen-sy)))
(-> self root-override trans y)
)
)
)
(let ((f30-0 4.0)
(f26-0 0.0)
(f28-0 (-> self root-override scale x))
(f24-0 (-> self root-override scale y))
(f22-0 (-> self root-override scale z))
)
(while #t
(let ((f0-7 (* f30-0 (-> *display* seconds-per-frame))))
(+! f26-0 f0-7)
(when (< 1.0 f26-0)
(let ((f0-8 (- f26-0 f0-7)))
(set! f0-7 (- 1.0 f0-8))
)
(set! f26-0 1.0)
)
(+! (-> self root-override trans x) (* f0-7 (-> s5-0 x)))
(+! (-> self root-override trans y) (* f0-7 (-> s5-0 y)))
)
(set-vector!
(-> self root-override scale)
(* f28-0 (-> *video-parms* relative-x-scale))
(* f24-0 (-> *video-parms* relative-y-scale) (-> *video-parms* relative-y-scale))
(* f22-0 (-> *video-parms* relative-x-scale))
1.0
)
(let ((a0-12 (-> self root-override)))
(set-yaw-angle-clear-roll-pitch!
a0-12
(- (y-angle a0-12) (* 182.04445 (* 8.0 (-> *display* time-adjust-ratio))))
)
)
(suspend)
(when (>= f26-0 1.0)
(send-hud-increment-event (the-as hud (handle->process arg0)))
(deactivate self)
)
)
)
)
(none)
)
:post
(the-as (function none :behavior collectable) ja-post)
)