diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 1d6aa95d2b..0f5f12d537 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -7258,6 +7258,8 @@ (progress-vsync #x120d) (progress-text-language #x120e) (progress-cheats #x120f) + (progress-aspect-ratio-custom-width #x1210) + (progress-aspect-ratio-custom-height #x1211) ) ;; ---text-id-h:text-id diff --git a/game/assets/jak2/text/game_custom_text_en-US.json b/game/assets/jak2/text/game_custom_text_en-US.json index 5db1be3dac..3b431a5f04 100644 --- a/game/assets/jak2/text/game_custom_text_en-US.json +++ b/game/assets/jak2/text/game_custom_text_en-US.json @@ -15,12 +15,14 @@ "1205": "Custom", "1206": "4x3 (PS2)", "1207": "16x9 (PS2)", - "1208": "Select the custom width and height ratio.", + "1208": "Choose width and height ratio", "1209": "Press to confirm and exit.", "120a": "Press to confirm and exit.", - "120b": "Ratio must not be lower than 4x3 (~f).", + "120b": "Ratio must not be lower than 4x3!", "120c": "Current ratio is ~f.", "120d": "V-Sync", "120e": "Text Language", - "120f": "OpenGOAL Secrets" + "120f": "OpenGOAL Secrets", + "1210": "Width", + "1211": "Height" } diff --git a/goal_src/jak2/engine/ui/text-id-h.gc b/goal_src/jak2/engine/ui/text-id-h.gc index 8f4cbb6e0f..74cd1fbcff 100644 --- a/goal_src/jak2/engine/ui/text-id-h.gc +++ b/goal_src/jak2/engine/ui/text-id-h.gc @@ -594,6 +594,8 @@ (progress-vsync #x120d) (progress-text-language #x120e) (progress-cheats #x120f) + (progress-aspect-ratio-custom-width #x1210) + (progress-aspect-ratio-custom-height #x1211) ) ;; ---text-id diff --git a/goal_src/jak2/pc/damage-number.gc b/goal_src/jak2/pc/damage-number.gc index fbc789c0a8..b096052361 100644 --- a/goal_src/jak2/pc/damage-number.gc +++ b/goal_src/jak2/pc/damage-number.gc @@ -351,7 +351,7 @@ ;; position font (set-origin! (-> self font) (+ (/ (-> self trans-2d x) 16) -1792) - (+ (/ (-> self trans-2d y) 16) -1855)) + (+ (/ (-> self trans-2d y) 16) -1855 (the int (-> self height)))) (set-depth! (-> self font) (/ (-> self trans-2d z) 16)) ;; now center (we could do this earlier but it's fine) (-! (-> self font origin x) (/ (-> self width) 2)) diff --git a/goal_src/jak2/pc/pckernel.gc b/goal_src/jak2/pc/pckernel.gc index 608505b9b1..c0a5e626ad 100644 --- a/goal_src/jak2/pc/pckernel.gc +++ b/goal_src/jak2/pc/pckernel.gc @@ -144,12 +144,11 @@ ((and (pc-cheats? (-> *pc-settings* cheats) turbo-board) *target* (focus-test? *target* board) - (case (-> *load-state* vis-nick) - (('ctysluma 'ctyslumb 'ctyslumc - 'ctygena 'ctygenb 'ctygenc - 'ctyport 'ctymarka 'ctymarkb - 'ctypal 'ctyfarma 'ctyfarmb - 'stadium 'ctyinda 'ctyindb) #t) + (case (-> *game-info* current-continue vis-nick) + (('ctysluma 'ctyslumb 'ctyslumc 'ctypal + 'ctygena 'ctygenb 'ctygenc 'ctyport + 'ctymarka 'ctymarkb 'ctyfarma 'ctyfarmb + 'ctyinda 'ctyindb 'stadium) #t) (('forest) #t #|(not (task-node-open? (game-task-node forest-scouts-pegasus)))|#))) (set-setting! 'string-spline-max-move 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 2)) 0) (set-setting! 'string-spline-accel 'abs (* (-> *pc-cheat-state* turbo-board-speed) (meters 0.045)) 0) diff --git a/goal_src/jak2/pc/progress/progress-draw-pc.gc b/goal_src/jak2/pc/progress/progress-draw-pc.gc index 87d2638558..96a70a47b6 100644 --- a/goal_src/jak2/pc/progress/progress-draw-pc.gc +++ b/goal_src/jak2/pc/progress/progress-draw-pc.gc @@ -1757,7 +1757,8 @@ ) (set-scale! arg1 0.45) (print-game-text *temp-string* arg1 #f 44 (bucket-id progress)) - (draw-decoration obj arg1 alpha (text-id progress-root-graphic-options) #f 0.95) + (when-not-drawn-decoration + (draw-decoration obj arg1 alpha (text-id progress-root-graphic-options) #f 0.95)) ) 0 (none) @@ -1881,3 +1882,195 @@ + +(defun draw-decoration-aspect-ratio-custom ((arg0 menu-option) (arg1 font-context) (arg2 float) (arg3 text-id) (arg5 float)) + (let ((gp-0 70) + (s5-0 120) + (sv-48 87) + (s3-0 375) + (s2-0 210) + (sv-64 0) + ) + (case (get-aspect-ratio) + (('aspect4x3) + (set! gp-0 69) + (set! s5-0 129) + (set! sv-48 80) + (set! s3-0 375) + (set! s2-0 210) + ) + (('aspect16x9) + (set! gp-0 79) + (set! s5-0 129) + (set! sv-48 68) + (set! s3-0 356) + (set! s2-0 244) + ) + ) + (when (not (-> *pc-settings* use-vis?)) + (set! gp-0 (the int (adjust-game-x (the float gp-0)))) + (set! s3-0 (the int (* (-> *pc-settings* aspect-ratio-reciprocal) s3-0))) + ) + (set-scale! arg1 arg5) + (set! (-> arg1 origin y) (the float sv-48)) + (set! (-> arg1 height) 50.0) + (set-color! arg1 (font-color progress)) + (set-flags! arg1 (font-flags kerning middle left large)) + (print-game-text (lookup-text! *common-text* arg3 #f) arg1 #f 44 (bucket-id progress)) + (set-vector! (-> arg0 box 0 color) 64 128 128 (the int (* 128.0 arg2))) + (draw-savegame-box arg0 (the float gp-0) (the float (+ gp-0 s3-0)) (the float s5-0) (the float s5-0)) + (with-dma-buffer-add-bucket ((s0-1 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id particles) + ) + (draw-sprite2d-xy + s0-1 + gp-0 + s5-0 + s3-0 + s2-0 + (new 'static 'rgba :r #x40 :g #x40 :b #x40 :a (the int (* 64.0 arg2))) + ) + ) + ) + ) + + +(defun draw-highlight-aspect ((x int) (y int) (w int) (h int) (alpha float)) + "draw the highlight for a number in the aspect ratio screen" + + (with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id progress) + ) + (when (not (-> *pc-settings* use-vis?)) + (set! x (adjust-game-x (the float x))) + (set! w (the int (* (-> *pc-settings* aspect-ratio-reciprocal) w))) + ) + (draw-sprite2d-xy buf x y w h (new 'static 'rgba :r #x40 :g #x80 :b #x80 :a (the int (* 64.0 alpha)))) + ) + ) + + +(defun draw-up-down-aspect ((font font-context) (y-up float) (y-down float)) + (protect ((-> font origin x) (-> font origin y) (-> font scale)) + + (let ((start-y (-> font origin y))) + (set-scale! font 0.5) + (set! (-> font origin y) (- start-y y-up)) + (print-game-text (string-format "~33L~C" 160) font #f 44 (bucket-id progress)) + (set! (-> font origin y) (+ start-y y-down)) + (print-game-text (string-format "~33L~C" 162) font #f 44 (bucket-id progress)) + ) + ) + 0) + +(defmacro swap-confirm? () + "is the confirm button swapped from X?" + `(case (scf-get-territory) + ((2 3) #t) + (else #f))) + + +(defmethod draw-option menu-aspect-ratio-custom-option ((obj menu-aspect-ratio-custom-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) + (let* ((alpha (* 2.0 (- 0.5 (-> arg0 menu-transition)))) + (middle-pad 15.0) + (middle-pad-uncorrected middle-pad) + (numbers-y 206.0) + (numbers-text-y (- numbers-y 44.0)) + (hilite-width 36) + (hilite-height 16) + (hilite-y-ofs 6) + (hilite-height-total (+ hilite-height (* 2 hilite-y-ofs))) + (font-w 100) + (font-w-corrected (if (not (-> *pc-settings* use-vis?)) (the int (* (-> *pc-settings* aspect-ratio-reciprocal) font-w)) + font-w)) + ) + (max! alpha 0.0) + (set! (-> arg1 alpha) alpha) + (set-flags! arg1 (font-flags kerning middle large)) + (set-scale! arg1 0.65) + (set-color! arg1 (font-color progress)) + (set! (-> arg1 origin y) 80.0) + + (if (not (-> *pc-settings* use-vis?)) + (*! middle-pad (-> *pc-settings* aspect-ratio-reciprocal))) + + (protect ((-> arg1 origin x) (-> arg1 width)) + (set-scale! arg1 0.6) + (set-width! arg1 50) + (set! (-> arg1 origin y) numbers-y) + (set! (-> arg1 origin x) (- 256.0 25)) + (print-game-text "x" arg1 #f 44 (bucket-id progress)) + + (set-width! arg1 font-w-corrected) + + (set-scale! arg1 0.6) + (set! (-> arg1 origin y) numbers-y) + (set! (-> arg1 origin x) (- 256.0 middle-pad font-w-corrected)) + (cond + ((= 0 (-> *progress-state-pc* aspect-ratio-ratio-index)) + (draw-highlight-aspect + (- (the int (+ (- 256.0 middle-pad-uncorrected font-w) (/ font-w 2))) (/ hilite-width 2)) + (- (the int (-> arg1 origin y)) hilite-y-ofs) + hilite-width hilite-height-total + alpha) + (set-color! arg1 (progress-selected 0)) + (draw-up-down-aspect arg1 21.0 25.0)) + (else + (set-color! arg1 (font-color progress))) + ) + (print-game-text (string-format "~D" (-> *pc-settings* aspect-custom-x)) arg1 #f 44 (bucket-id progress)) + (set-scale! arg1 0.55) + (set-color! arg1 (font-color progress)) + (set! (-> arg1 origin y) numbers-text-y) + (print-game-text (lookup-text! *common-text* (text-id progress-aspect-ratio-custom-width) #f) arg1 #f 44 (bucket-id progress)) + + (set-scale! arg1 0.6) + (set! (-> arg1 origin y) numbers-y) + (set! (-> arg1 origin x) (+ 256.0 middle-pad)) + (cond + ((= 1 (-> *progress-state-pc* aspect-ratio-ratio-index)) + (draw-highlight-aspect + (- (the int (+ (+ 256.0 middle-pad-uncorrected) (/ font-w 2))) (/ hilite-width 2)) + (- (the int (-> arg1 origin y)) hilite-y-ofs) + hilite-width hilite-height-total + alpha) + (set-color! arg1 (progress-selected 0)) + (draw-up-down-aspect arg1 21.0 25.0)) + (else + (set-color! arg1 (font-color progress))) + ) + (print-game-text (string-format "~D" (-> *pc-settings* aspect-custom-y)) arg1 #f 44 (bucket-id progress)) + (set-scale! arg1 0.55) + (set-color! arg1 (font-color progress)) + (set! (-> arg1 origin y) numbers-text-y) + (print-game-text (lookup-text! *common-text* (text-id progress-aspect-ratio-custom-height) #f) arg1 #f 44 (bucket-id progress)) + ) + + (set! (-> arg1 origin y) 289.0) + (cond + ((< (/ (the float (-> *pc-settings* aspect-custom-x)) (the float (-> *pc-settings* aspect-custom-y))) (/ 4.0 3.0)) + (set-scale! arg1 0.5) + (set-color! arg1 (font-color red)) + (when (and (< (/ (the float (-> *pc-settings* aspect-custom-x)) (the float (-> *pc-settings* aspect-custom-y))) (/ 4.0 3.0)) + (< (mod (-> *display* real-clock frame-counter) (seconds 1.2)) (seconds 1.0))) + (print-game-text (lookup-text! *common-text* (text-id progress-aspect-ratio-custom-warn) #f) arg1 #f 44 (bucket-id progress)) + ) + ) + (else + (set-scale! arg1 0.55) + (set-color! arg1 (font-color progress)) + (print-game-text (lookup-text! *common-text* (if (not (swap-confirm?)) + (text-id progress-aspect-ratio-custom-pad-x) + (text-id progress-aspect-ratio-custom-pad-circle)) #f) arg1 #f 44 (bucket-id progress)) + ) + ) + + (when-not-drawn-decoration + (draw-decoration-aspect-ratio-custom obj arg1 alpha (text-id progress-aspect-ratio-custom-title) 0.55)) + ) + 0 + (none) + ) + + + diff --git a/goal_src/jak2/pc/progress/progress-h-pc.gc b/goal_src/jak2/pc/progress/progress-h-pc.gc index a73221c46d..a5f91e0fc0 100644 --- a/goal_src/jak2/pc/progress/progress-h-pc.gc +++ b/goal_src/jak2/pc/progress/progress-h-pc.gc @@ -9,21 +9,12 @@ |# -(deftype progress-global-state-pc (basic) - ((decoration-draw-time uint64) - - (display-mode-choice-index int8) - - (aspect-ratio-choice-index int8) - ) - ) +(defmacro push-and-set-state (progress state) + `(begin + (push-state ,progress) + (set-next-state ,progress ,state 0))) -(defmacro when-not-drawn-decoration (&rest body) - `(when (> (get-integral-current-time) (-> *progress-state-pc* decoration-draw-time)) - ,@body - (set! (-> *progress-state-pc* decoration-draw-time) (get-integral-current-time)))) - (deftype menu-display-mode-option (menu-option) () @@ -50,7 +41,8 @@ (unlock text-id) (flag pc-cheats) - (avail-after game-task-node) + (avail-after game-task-node) + (avail-after-hero game-task-node) ) ) diff --git a/goal_src/jak2/pc/progress/progress-pc.gc b/goal_src/jak2/pc/progress/progress-pc.gc index 527361583b..c14c758c6b 100644 --- a/goal_src/jak2/pc/progress/progress-pc.gc +++ b/goal_src/jak2/pc/progress/progress-pc.gc @@ -10,9 +10,27 @@ +(deftype progress-global-state-pc (basic) + ((decoration-draw-time uint64) + + (display-mode-choice-index int8) + + (aspect-ratio-choice-index int8) + (aspect-ratio-ratio-index int8) + ) + ) + + (define *progress-state-pc* (new 'static 'progress-global-state-pc)) +(defmacro when-not-drawn-decoration (&rest body) + `(when (> (-> *display* real-clock integral-frame-counter) (-> *progress-state-pc* decoration-draw-time)) + ,@body + (set! (-> *progress-state-pc* decoration-draw-time) (-> *display* real-clock integral-frame-counter)))) + + + (defun set-progress-aspect-ratio-pc-index () "set the progress aspect ratio option index accordingly" (cond @@ -312,6 +330,10 @@ (('unlocked-secrets) (set! (-> obj current-options) *unlocked-secrets*) ) + (('aspect-ratio-custom) + (set! (-> *progress-state-pc* aspect-ratio-ratio-index) 0) + (set! (-> obj current-options) *aspect-ratio-custom-options*) + ) ) (when (= (-> obj current-options) #f) (format #t "Didn't find new menu settings!!~%") @@ -363,7 +385,8 @@ (false! (-> *pc-settings* use-vis?)) ) ((3) - (format #t "nyi custom aspect-ratio~%") + (cpad-clear! 0 confirm) + (push-and-set-state arg0 'aspect-ratio-custom) ) ) ) @@ -384,6 +407,7 @@ 0 ) + (defmethod respond-progress menu-display-mode-option ((obj menu-display-mode-option) (arg0 progress) (arg1 symbol)) "Handle progress menu navigation logic." @@ -414,4 +438,59 @@ ) ) 0 + ) + + +(defmethod respond-progress menu-aspect-ratio-custom-option ((obj menu-aspect-ratio-custom-option) (arg0 progress) (arg1 symbol)) + "Handle progress menu navigation logic." + + (let ((aspect-custom-val-ptr (case (-> *progress-state-pc* aspect-ratio-ratio-index) + ((0) + (&-> *pc-settings* aspect-custom-x)) + ((1) + (&-> *pc-settings* aspect-custom-y)) + (else + (&-> *pc-settings* aspect-custom-x)) + ))) + (cond + ((cpad-pressed? 0 left l-analog-left) + (when (< 0 (-> *progress-state-pc* aspect-ratio-ratio-index)) + (sound-play "roll-over") + (1-! (-> *progress-state-pc* aspect-ratio-ratio-index)) + ) + ) + ((cpad-pressed? 0 right l-analog-right) + (when (> 1 (-> *progress-state-pc* aspect-ratio-ratio-index)) + (sound-play "roll-over") + (1+! (-> *progress-state-pc* aspect-ratio-ratio-index)) + ) + ) + ((cpad-pressed? 0 up l-analog-up) + (when (> 99 (-> aspect-custom-val-ptr)) + (sound-play "roll-over") + (1+! (-> aspect-custom-val-ptr)) + ) + ) + ((cpad-pressed? 0 down l-analog-down) + (when (< 1 (-> aspect-custom-val-ptr)) + (sound-play "roll-over") + (1-! (-> aspect-custom-val-ptr)) + ) + ) + ((cpad-pressed? 0 triangle) + (cpad-clear! 0 triangle) + (sound-play "generic-beep") + (pop-state arg0) + ) + ((cpad-pressed? 0 confirm) + (cpad-clear! 0 confirm) + (when (>= (/ (the float (-> *pc-settings* aspect-custom-x)) (the float (-> *pc-settings* aspect-custom-y))) (/ 4.0 3.0)) + (set! (-> *setting-control* user-default aspect-ratio) 'aspect4x3) + (set-aspect! *pc-settings* (-> *pc-settings* aspect-custom-x) (-> *pc-settings* aspect-custom-y)) + (sound-play "generic-beep") + (pop-state arg0) + ) + ) + )) + 0 ) \ No newline at end of file diff --git a/goal_src/jak2/pc/progress/progress-static-pc.gc b/goal_src/jak2/pc/progress/progress-static-pc.gc index 79ab5b6f43..ea269bda3c 100644 --- a/goal_src/jak2/pc/progress/progress-static-pc.gc +++ b/goal_src/jak2/pc/progress/progress-static-pc.gc @@ -24,4 +24,16 @@ ) +(define *aspect-ratio-custom-options* + (new 'static 'menu-option-list + :y-center 198 + :y-space 34 + :scale 0.82 + :options (new 'static 'boxed-array :type menu-option + (new 'static 'menu-aspect-ratio-custom-option :name (text-id progress-aspect-ratio-custom-title)) + ) + ) + ) + +