;;-*-Lisp-*- (in-package goal) ;; name: hud.gc ;; name in dgo: hud ;; dgos: GAME, ENGINE ;; DECOMP BEGINS (defmethod relocate ((this hud) (arg0 int)) (dotimes (v1-0 (-> this nb-of-particles)) (if (nonzero? (-> this particles v1-0 part)) (&+! (-> this particles v1-0 part) arg0) ) ) (the-as hud ((method-of-type process relocate) this arg0)) ) (defmethod deactivate ((this hud)) (dotimes (v1-0 9) (if (and (-> *hud-parts* parts v1-0) (= (ppointer->process (-> *hud-parts* parts v1-0)) this)) (set! (-> *hud-parts* parts v1-0) (the-as (pointer hud) #f)) ) ) (dotimes (s5-0 (-> this nb-of-particles)) (kill-and-free-particles (-> this particles s5-0 part)) (set! (-> this particles s5-0 part matrix) -1) ) ((method-of-type process deactivate) this) (none) ) (defmethod draw-hud ((this hud)) (when (and (not (hidden? this)) (not (paused?))) (dotimes (s5-0 (-> this nb-of-particles)) (when (!= s5-0 (-> this skip-particle)) (if (or (!= (-> this particles 0 pos x) 0.0) (!= (-> this particles 0 pos y) 0.0)) (spawn (-> this particles s5-0 part) *null-vector*) ) ) ) ) 0 (none) ) (defmethod tally-value ((this hud) (arg0 int) (arg1 int)) (if (= arg0 (-> this target-value)) (set-time! (-> this last-target-equal-time)) ) (when (and (not *progress-process*) (and (!= (-> this last-hide-time) (current-time)) (not (movie?)) (time-elapsed? (-> *game-info* letterbox-time) (seconds 0.1)) (time-elapsed? (-> *game-info* blackout-time) (seconds 0.1)) (not (and *target* (logtest? (-> *target* state-flags) (state-flags grabbed)))) ) ) (when (or (!= (-> this value) arg0) (!= (-> this value2) arg1) (-> this force-on-screen) (or (and (cpad-hold? 0 l2) (not (-> this disable))) (and (not *cheat-mode*) (cpad-hold? 0 r2)) (-> this first-init) ) ) ;; modified for pc port (cond ((cpad-hold? 0 up) (set! *hud-collectable-view* (hud-collectable-view game-totals)) ) ((cpad-hold? 0 down) (set! *hud-collectable-view* (hud-collectable-view level-totals)) ) ((or (cpad-hold? 0 left) (cpad-hold? 0 right)) (set! *hud-collectable-view* (hud-collectable-view original)) ) ) (cond ((and (-> this increment-on-event) (< (-> this value) arg0) (not (-> this first-init)) (not (time-elapsed? (-> this last-target-equal-time) (seconds 1.5))) ) (when (and (!= (-> this value) (-> this target-value)) (time-elapsed? (-> this last-increment-time) (seconds 0.1))) (sound-play "cursor-options") (+! (-> this value) 1) (set-time! (-> this last-increment-time)) ) ) (else (if (not (and (not (-> this first-init)) (time-elapsed? (-> this last-target-equal-time) (seconds 1.5)))) (set! (-> this value) arg0) ) (set! (-> this target-value) arg0) (set-time! (-> this last-target-equal-time)) ) ) (set! (-> this value2) arg1) (when (and (not (movie?)) (= *master-mode* 'game) (not (-> this first-init)) (not (-> this disable))) (if (>= (-> this friend) 0) (send-event (ppointer->process (-> *hud-parts* parts (-> this friend))) 'show) ) (go hud-arriving) ) (set-time! (-> this trigger-time)) (set! (-> this first-init) #f) ) ) 0 (none) ) (defmethod draw-icons ((this hud)) (dotimes (v1-0 (-> this nb-of-icons)) (set-vector! (-> this icons v1-0 icon 0 root scale) (* (-> this icons v1-0 scale-x) (-> *video-parms* relative-x-scale)) (* (-> this icons v1-0 scale-y) (-> *video-parms* relative-y-scale)) (* (-> this icons v1-0 scale-x) (-> *video-parms* relative-x-scale)) 1.0 ) (set! (-> this icons v1-0 icon 0 root trans x) (the float (+ (-> this icons v1-0 icon-x) -256 (* (-> this x-sgn) (-> this offset)))) ) (set! (-> this icons v1-0 icon 0 root trans y) (- (+ (the float (-> this icons v1-0 icon-y)) (* (the float (-> this y-sgn)) (the float (-> this offset)) (-> *video-parms* relative-y-scale) (-> *video-parms* relative-y-scale) ) (* (the float (-> this y-offset)) (-> *video-parms* relative-x-scale-reciprical)) ) (the float (-> *video-parms* screen-sy)) ) ) ) 0 (none) ) (defmethod draw-particles ((this hud)) (dotimes (s5-0 (-> this nb-of-particles)) (when (!= (-> this skip-particle) -2) (set! (-> this particles s5-0 pos x) (+ -256.0 (the float (* (-> this x-sgn) (-> this offset))) (-> this particles s5-0 init-pos x)) ) (set! (-> this particles s5-0 pos y) (* 0.5 (- (* (-> *video-parms* relative-y-scale) (+ (-> this particles s5-0 init-pos y) (the float (* (-> this y-sgn) (-> this offset))) ;; og:preserve-this (#if PC_PORT (if (not (-> *pc-settings* use-vis?)) (* (the float (-> this y-offset)) (-> *video-parms* relative-y-scale)) (* (the float (-> this y-offset)) (-> *video-parms* relative-x-scale-reciprical)) ) (* (the float (-> this y-offset)) (-> *video-parms* relative-x-scale-reciprical)) ) ) ) (the float (-> *video-parms* screen-sy)) ) ) ) (set! (-> this particles s5-0 pos z) (-> this particles s5-0 init-pos z)) ) (if (> (-> this particles s5-0 part matrix) 0) (set-vector! (sprite-get-user-hvdf (-> this particles s5-0 part matrix)) (the float (+ (the int (-> this particles s5-0 pos x)) 2048)) (the float (+ (the int (-> this particles s5-0 pos y)) 2048)) (- (-> *math-camera* hvdf-off z) (* 1024.0 (-> this particles s5-0 pos z))) (-> *math-camera* hvdf-off w) ) ) ) 0 (none) ) (defmethod hud-update ((this hud)) 0 (none) ) (defmethod init-particles! ((this hud) (arg0 int)) 0 (none) ) (defmethod get-icon-pos-x ((this hud)) 0 ) (defmethod get-icon-pos-y ((this hud)) 0 ) (defmethod get-icon-scale-x ((this hud)) 0.0 ) (defmethod get-icon-scale-y ((this hud)) 0.0 ) (defmethod set-pos-and-scale ((this hud) (arg0 symbol) (arg1 symbol)) 0 (none) ) (defmethod hidden? ((this hud)) (= (-> this next-state name) 'hud-hidden) ) (defstate hud-hidden (hud) :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) (local-vars (v0-0 object)) (case message (('show) (if (and (not *progress-process*) (!= (-> self last-hide-time) (current-time))) (go hud-arriving) ) ) (('hide) (set! v0-0 (current-time)) (set! (-> self last-hide-time) (the-as time-frame v0-0)) v0-0 ) (('hide-quick) (set! v0-0 (current-time)) (set! (-> self last-hide-time) (the-as time-frame 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) (draw-icons self) (draw-particles 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) ) ) :exit (behavior () (set! (-> self y-offset) (-> self next-y-offset)) ) :code (behavior () (logior! (-> self mask) (process-mask sleep-code)) (loop (suspend) ) ) :post (behavior () (if (-> self deactivate-when-hidden) (deactivate self) ) (hud-update self) ) ) (defstate hud-arriving (hud) :event (behavior ((proc process) (argc int) (message symbol) (block event-message-block)) (local-vars (v0-3 object)) (case message (('hide-quick) (set-time! (-> self last-hide-time)) (set! (-> self force-on-screen) #f) (set! (-> self offset) 128) (draw-particles self) (draw-icons self) (hud-update self) (go hud-hidden) ) (('hide) (set-time! (-> self last-hide-time)) (set! (-> self force-on-screen) #f) (go hud-leaving 10) ) (('show) (if (and (not *progress-process*) (!= (-> self last-hide-time) (current-time))) (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)) ) ) ) :code (behavior () (loop (if (not (paused?)) (seekl! (-> self offset) 0 (the int (* 15.0 (-> *display* time-adjust-ratio)))) ) (draw-icons self) (if (<= (-> self offset) 0) (go hud-in) ) (when (movie?) (set-time! (-> self last-hide-time)) (set! (-> self force-on-screen) #f) (set! (-> self offset) 128) (draw-particles self) (draw-icons self) (hud-update self) (go hud-hidden) ) (suspend) ) ) :post (behavior () (hud-update self) (draw-particles self) (draw-hud self) ) ) (defstate hud-in (hud) :event (-> hud-arriving event) :code (behavior () (set-time! (-> self trigger-time)) (while (and (not (time-elapsed? (-> self trigger-time) (seconds 2))) (not (movie?))) (set! (-> self offset) 0) (draw-icons self) (suspend) ) (when (movie?) (set-time! (-> self last-hide-time)) (set! (-> self force-on-screen) #f) (set! (-> self offset) 128) (draw-particles self) (draw-icons self) (hud-update self) (go hud-hidden) ) (go hud-leaving 5) ) :post (-> hud-arriving post) ) (defstate hud-leaving (hud) :event (-> hud-arriving event) :code (behavior ((arg0 int)) (loop (if (not (paused?)) (seekl! (-> self offset) 128 (the int (* (the float arg0) (-> *display* time-adjust-ratio)))) ) (draw-icons self) (when (movie?) (set-time! (-> self last-hide-time)) (set! (-> self force-on-screen) #f) (set! (-> self offset) 128) (draw-particles self) (draw-icons self) (hud-update self) (go hud-hidden) ) (if (>= (-> self offset) 128) (go hud-hidden) ) (suspend) ) ) :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-time! (-> self last-increment-time)) (set-time! (-> self last-target-equal-time)) (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-time! (-> self last-hide-time)) (logior! (-> self mask) (process-mask menu)) (logclear! (-> self mask) (process-mask pause progress)) (init-particles! self arg0) (draw-icons self) (draw-particles self) (go hud-hidden) (none) ) (defun send-hud-increment-event ((arg0 hud)) (if (-> arg0 increment-on-event) (send-event arg0 'increment) ) ) (defstate hud-collecting (process-drawable) :trans (behavior () (case (-> self type) ((fuel-cell) (fuel-cell-animate) ) ) ) :code (behavior ((arg0 handle)) (let ((s5-0 (new 'stack-no-clear 'vector))) (let ((s4-0 (handle->process arg0))) (set! (-> s5-0 x) (- (the float (+ (get-icon-pos-x (the-as hud s4-0)) -256)) (-> self root trans x))) (set! (-> s5-0 y) (- (the float (- (get-icon-pos-y (the-as hud s4-0)) (-> *video-parms* screen-sy))) (-> self root trans y)) ) ) (let ((f30-0 4.0) (f26-0 0.0) (f28-0 (-> self root scale x)) (f24-0 (-> self root scale y)) (f22-0 (-> self root scale z)) ) (loop (let ((f0-7 (* f30-0 (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 trans x) (* f0-7 (-> s5-0 x))) (+! (-> self root trans y) (* f0-7 (-> s5-0 y))) ) (set-vector! (-> self root 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))) (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) ) ) ) ) ) :post ja-post )