diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 9d2f553356..c494c6eab5 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -7416,6 +7416,7 @@ (progress-shadows #x12a0) (progress-shadows-normal #x12a1) (progress-shadows-extended #x12a2) + (progress-error-no-resolutions #x12a3) (progress-input-options-auto-hide-cursor #x1300) (progress-menu-reassign-binds #x1301) (progress-reassign-binds-controller #x1302) 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 7f319ea9d1..13f05034ec 100644 --- a/game/assets/jak2/text/game_custom_text_en-US.json +++ b/game/assets/jak2/text/game_custom_text_en-US.json @@ -143,6 +143,7 @@ "12a0": "Object Shadows", "12a1": "Normal", "12a2": "Extended", + "12a3": "No valid resolutions found.", "1300": "Auto Hide Cursor", "1301": "Reassign Binds", "1302": "Controller Binds", diff --git a/game/system/hid/display_manager.cpp b/game/system/hid/display_manager.cpp index ffd9638e4a..7b12936d93 100644 --- a/game/system/hid/display_manager.cpp +++ b/game/system/hid/display_manager.cpp @@ -338,9 +338,6 @@ void DisplayManager::update_resolutions() { static_cast(curr_mode.w) / static_cast(curr_mode.h)}; m_available_resolutions.push_back(new_res); } - // Add original NTSC/PAL options for weird people that want to act like they are on a PS2? - m_available_resolutions.push_back({512, 448, static_cast(512) / static_cast(448)}); - m_available_resolutions.push_back({512, 224, static_cast(512) / static_cast(224)}); // Sort by area std::sort(m_available_resolutions.begin(), m_available_resolutions.end(), diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 77fade7467..e55c21947b 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -453,6 +453,9 @@ `(debug-font-scale-factor *pc-settings*)) +(defmacro fullscreen? () + `(symbol-member? (-> *pc-settings* display-mode) '(fullscreen borderless))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; cheats diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index 81a779c010..ee4d0ddad2 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -589,18 +589,21 @@ ;; Ignore those that aren't relevant to the current window's aspect ratio ;; we only do this when we aren't in windowed mode, because in windowed mode ;; you are using the resolution menu to change it...so it doesn't make sense to base it on the size - ;; - ;; Additionally, always show the PS2 resolutions or else they are never going to be seen due to the aspect ratio difference (when (or (= (pc-get-display-mode) 'windowed) - (and (= res-width 512) (or (= res-height 448) (= res-height 224))) - (< (fabs (- window-aspect-ratio res-aspect-ratio)) 0.1)) + (< (fabs (- window-aspect-ratio res-aspect-ratio)) 0.05)) (add-resolution-option res-width res-height) (1+! num-resolutions-added))))) - ;; If all we displayed was the 2 PS2 resolutions, inform them they have a weird aspect ratio - (when (< num-resolutions-added 3) - (add-message-option (text-id progress-no-other-resolution-options))) + ;; if we didn't add any options, inform them they have a weird aspect ratio + (cond + ((zero? num-resolutions-added) + (add-message-option (text-id progress-no-other-resolution-options))) + ((fullscreen?) + ;; for the weird people that want a more "PS2-like" experience + (add-resolution-option 512 448) + (add-resolution-option 512 224) + ) ) - (add-back-option)) + (add-back-option))) (defun build-flava-player-options ((mus-idx int)) diff --git a/goal_src/jak2/engine/ui/text-id-h.gc b/goal_src/jak2/engine/ui/text-id-h.gc index 6136e12cfc..385f65d80a 100644 --- a/goal_src/jak2/engine/ui/text-id-h.gc +++ b/goal_src/jak2/engine/ui/text-id-h.gc @@ -731,6 +731,7 @@ (progress-shadows #x12a0) (progress-shadows-normal #x12a1) (progress-shadows-extended #x12a2) + (progress-error-no-resolutions #x12a3) (progress-input-options-auto-hide-cursor #x1300) (progress-menu-reassign-binds #x1301) (progress-reassign-binds-controller #x1302) diff --git a/goal_src/jak2/pc/progress/progress-draw-pc.gc b/goal_src/jak2/pc/progress/progress-draw-pc.gc index dabaed5615..e441a7853b 100644 --- a/goal_src/jak2/pc/progress/progress-draw-pc.gc +++ b/goal_src/jak2/pc/progress/progress-draw-pc.gc @@ -2664,6 +2664,191 @@ +(defun draw-decoration-resolution ((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 70) + (set! s5-0 116) + (set! sv-48 84) + (set! s3-0 375) + (set! s2-0 179) + ) + (('aspect16x9) + (set! gp-0 79) + (set! s5-0 108) + (set! sv-48 58) + (set! s3-0 356) + (set! s2-0 185) + (set! sv-64 20) + ) + ) + (#when PC_PORT + ;; added for better widescreen handling + (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 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)) + (+! (-> arg1 origin y) (the float sv-64)) + (draw-savegame-box + arg0 + (the float gp-0) + (the float (+ gp-0 s3-0)) + (the float (+ s5-0 s2-0)) + (the float (+ s5-0 s2-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 begin-scissor-resolution ((arg0 hud-box)) + (cond + ((= (get-aspect-ratio) 'aspect16x9) + (set! (-> arg0 min x) 79.0) + (set! (-> arg0 min y) 108.0) + (set! (-> arg0 max x) 434.0) + (set! (-> arg0 max y) 293.0) + ) + (else + (set! (-> arg0 min x) 70.0) + (set! (-> arg0 min y) 116.0) + (set! (-> arg0 max x) 444.0) + (set! (-> arg0 max y) 295.0) + ) + ) + (with-dma-buffer-add-bucket ((s4-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id progress) + ) + (setup-scissor arg0 s4-0) + ) + 0 + ) + +(defun end-scissor-resolution ((arg0 hud-box) (arg1 float)) + (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) global-buf)) + (bucket-id progress) + ) + (restore-scissor arg0 s5-0) + ) + 0 + ) + +(defmethod draw-option ((this menu-resolution-option) (the-progress progress) (font font-context) (arg2 int) (arg3 symbol)) + + (let* ((alpha (* 2.0 (- 0.5 (-> the-progress menu-transition)))) + (box (new 'stack 'hud-box)) + (height 22) + (text-pad 1) + (text-height (+ height (* text-pad 2)))) + (max! alpha 0.0) + (set! (-> font alpha) alpha) + + (draw-decoration-resolution this font alpha (if (fullscreen?) (text-id progress-game-res-decoration) (text-id progress-window-size-decoration)) 0.65) + (begin-scissor-resolution box) + + (set-flags! font (font-flags kerning large middle)) + (cond + ((< (-> this selected-index) 0) + ;; not sure. + ) + ((-> this valid?) + (set-scale! font 0.6) + (set-color! font (font-color progress)) + (set! (-> font origin x) (+ (-> box min x) 16)) + (set! (-> font width) (- (-> box max x) (-> box min x) (* 16 2))) + (set-height! font 60) + + ;; draw the highlight first + (draw-highlight 193 (- height 1) alpha) + + ;; now scroll and offset the list + (if (> (abs (- (-> this scroll-index) (the float (-> this selected-index)))) 2.0) + (set! (-> this scroll-index) (the float (-> this selected-index))) + (seek-ease! (-> this scroll-index) (the float (-> this selected-index)) (* 0.15 (-> PP clock time-adjust-ratio)) 0.3 (* 0.0015 (-> PP clock time-adjust-ratio)))) + (set! (-> font origin y) (- 194.0 (* (-> this scroll-index) text-height) (- text-pad))) + + ;; now draw the list! + (let ((valid-index 0)) + (dotimes (i (-> this num-resolutions)) + + ;; count "valid" resolutions + (let ((this-w 0) (this-h 0) (this-aspect 0.0)) + (pc-get-resolution i (& this-w) (& this-h)) + (set! this-aspect (/ (the float this-w) (the float this-h))) + + (when (or (= (pc-get-display-mode) 'windowed) + (< (fabs (- (-> this win-aspect) this-aspect)) 0.05)) + (if (= valid-index (-> this selected-index)) + (set-color! font (progress-selected 0)) + (set-color! font (font-color progress))) + (print-game-text (string-format "~D x ~D" this-w this-h) font #f 44 (bucket-id progress)) + + (+! (-> font origin y) text-height) + (1+! valid-index) + )) + ) + + (when (fullscreen?) + ;; draw extra hardcoded cases + (if (= valid-index (-> this selected-index)) + (set-color! font (progress-selected 0)) + (set-color! font (font-color progress))) + (print-game-text (string-format "~D x ~D" 512 416) font #f 44 (bucket-id progress)) + (+! (-> font origin y) text-height) + (1+! valid-index) + + (if (= valid-index (-> this selected-index)) + (set-color! font (progress-selected 0)) + (set-color! font (font-color progress))) + (print-game-text (string-format "~D x ~D" 512 208) font #f 44 (bucket-id progress)) + (+! (-> font origin y) text-height) + (1+! valid-index) + )) + + ) + (else + ;; wtf?? just print an ominous warning. + (set-scale! font 0.6) + (set-color! font (font-color red)) + + (set! (-> font origin x) (+ (-> box min x) 16)) + (set! (-> font origin y) (+ (-> box min y) 120)) + (set! (-> font width) (- (-> box max x) (-> box min x) (* 16 2))) + (set-height! font 60) + (print-game-text (lookup-text! *common-text* (text-id progress-error-no-resolutions) #f) font #f 44 (bucket-id progress)) + ) + ) + + (end-scissor-resolution box 1.0) + ) + + 0 + (none)) + + + (#when PC_PORT (defun-debug draw-mouse () diff --git a/goal_src/jak2/pc/progress/progress-generic-draw-pc.gc b/goal_src/jak2/pc/progress/progress-generic-draw-pc.gc index d4c8da10ed..e7f6e8613b 100644 --- a/goal_src/jak2/pc/progress/progress-generic-draw-pc.gc +++ b/goal_src/jak2/pc/progress/progress-generic-draw-pc.gc @@ -349,6 +349,12 @@ (draw-generic-simple-string-option obj progress font-ctx option-index (lookup-text! *common-text* (-> obj name) #f)) (none)) +(defmethod draw-option ((obj menu-generic-button-option) (progress progress) (font-ctx font-context) (option-index int) (selected? symbol)) + (when (not (-> obj mounted?)) + (on-mount! obj)) + (draw-generic-simple-string-option obj progress font-ctx option-index (lookup-text! *common-text* (-> obj name) #f)) + (none)) + (defmethod draw-option ((obj menu-generic-confirm-option) (progress progress) (font-ctx font-context) (option-index int) (selected? symbol)) (when (not (-> obj mounted?)) (on-mount! obj)) @@ -613,3 +619,15 @@ (format *progress-generic-temp-string* "~35L~S ~33L~S~1L" (lookup-text! *common-text* (text-id progress-yes) #f) (lookup-text! *common-text* (text-id progress-no) #f))) (print-game-text *progress-generic-temp-string* font-ctx #f 44 (bucket-id progress)))) (none)) + + +(defmethod draw-option ((obj menu-generic-to-resolutions-option) (progress progress) (font-ctx font-context) (option-index int) (selected? symbol)) + ;; change the name depending on whether we're fullscreen or not + (cond + ((and (= (-> obj name) (text-id progress-window-size)) (fullscreen?)) + (set! (-> obj name) (text-id progress-game-res))) + ((and (= (-> obj name) (text-id progress-game-res)) (not (fullscreen?))) + (set! (-> obj name) (text-id progress-window-size))) + ) + (call-parent-method obj progress font-ctx option-index selected?)) + diff --git a/goal_src/jak2/pc/progress/progress-generic-h-pc.gc b/goal_src/jak2/pc/progress/progress-generic-h-pc.gc index fea8f25fe9..6135b10167 100644 --- a/goal_src/jak2/pc/progress/progress-generic-h-pc.gc +++ b/goal_src/jak2/pc/progress/progress-generic-h-pc.gc @@ -46,6 +46,13 @@ (on-mount! "Called when the menu item is first drawn as a means to initialize defaults, etc" (_type_) none) (should-disable? (_type_) symbol))) +(deftype menu-generic-button-option (menu-generic-option) + "A button option that run its action when selected" + (;; props + (on-confirm (function progress none))) + (:methods + (call-on-confirm (_type_ progress) none))) + (deftype menu-generic-scrolling-page (menu-generic-option) "A menu option that holds menu options" (;; props @@ -89,12 +96,12 @@ (item-index int32) ;; lambdas (get-item-index-fn (function int)) - (on-confirm (function int none))) + (on-confirm (function int progress none))) (:methods (num-items (_type_) int) (get-item-label (_type_ int) string) (call-get-item-index-fn (_type_) int) - (call-on-confirm (_type_ int) none))) + (call-on-confirm (_type_ int progress) none))) (deftype menu-generic-confirm-option (menu-generic-option) "A button option that confirms before triggering it's action" @@ -128,6 +135,10 @@ "A generic details list entry" ()) +(deftype menu-generic-to-resolutions-option (menu-generic-button-option) + "Specialization of a generic button option" + ()) + (defenum controller-keybind :type int8 (select 0) @@ -203,6 +214,14 @@ :should-disable? ,should-disable? :target ,target)) +(defmacro progress-new-generic-link-to-page (title &key (should-disable? #f) &rest options) + `(new 'static 'menu-generic-link-option + :name ,title + :should-disable? ,should-disable? + :target (new 'static 'menu-option-list + :options (new 'static 'boxed-array :type menu-option + ,@options)))) + (defmacro progress-new-generic-link-to-scrolling-page (title &key (should-disable? #f) &rest options) `(new 'static 'menu-generic-link-option :name ,title diff --git a/goal_src/jak2/pc/progress/progress-generic-pc.gc b/goal_src/jak2/pc/progress/progress-generic-pc.gc index d293cef07e..d55a388269 100644 --- a/goal_src/jak2/pc/progress/progress-generic-pc.gc +++ b/goal_src/jak2/pc/progress/progress-generic-pc.gc @@ -21,9 +21,14 @@ ((-> this get-item-index-fn)) 0)) -(defmethod call-on-confirm ((this menu-generic-carousel-option) (val int)) - (when (and (nonzero? (-> this on-confirm)) (!= (-> this on-confirm) #f)) - ((-> this on-confirm) val)) +(defmethod call-on-confirm ((this menu-generic-carousel-option) (val int) (the-progress progress)) + (when (and (nonzero? (-> this on-confirm)) (-> this on-confirm)) + ((-> this on-confirm) val the-progress)) + (none)) + +(defmethod call-on-confirm ((this menu-generic-button-option) (the-progress progress)) + (when (and (nonzero? (-> this on-confirm)) (-> this on-confirm)) + ((-> this on-confirm) the-progress)) (none)) (defmethod call-on-confirm ((this menu-generic-confirm-option)) @@ -292,15 +297,15 @@ (let ((menu-option (-> this menu-options (-> *progress-pc-generic-store* current-menu-hover-index)))) ;; if the option is disabled, return early (when (and (type? menu-option menu-generic-option) - (nonzero? (-> (the-as menu-generic-option menu-option) should-disable?)) - (!= (-> (the-as menu-generic-option menu-option) should-disable?) #f) - ((-> (the-as menu-generic-option menu-option) should-disable?))) + (nonzero? (-> (the-as menu-generic-option menu-option) should-disable?)) + (!= (-> (the-as menu-generic-option menu-option) should-disable?) #f) + ((-> (the-as menu-generic-option menu-option) should-disable?))) (sound-play "roll-over") (cpad-clear! 0 confirm) (return 0)) ;; ignore confirm if it's a link (cond - ((type? menu-option menu-generic-link-option) + ((or (type? menu-option menu-generic-link-option) (type? menu-option menu-generic-to-resolutions-option)) (set! selected-item? #t)) (else (set! (-> this selected-option-index) (-> *progress-pc-generic-store* current-menu-hover-index)) @@ -353,7 +358,7 @@ (set! (-> this item-index) 0)) (sound-play "generic-beep")) ((cpad-pressed? 0 confirm) - (call-on-confirm this (-> this item-index)) + (call-on-confirm this (-> this item-index) progress) (sound-play "generic-beep"))) (cond ((cpad-pressed? 0 confirm) @@ -369,6 +374,14 @@ (sound-play "generic-beep")) 0) +(defmethod respond-progress ((this menu-generic-button-option) (progress progress) (selected? symbol)) + (cond + ((cpad-pressed? 0 confirm) + (cpad-clear! 0 confirm) + (call-on-confirm this progress) + (sound-play "generic-beep"))) + 0) + (defmethod respond-progress ((this menu-generic-confirm-option) (progress progress) (selected? symbol)) (if selected? (cond diff --git a/goal_src/jak2/pc/progress/progress-h-pc.gc b/goal_src/jak2/pc/progress/progress-h-pc.gc index 53a0217ebe..d699dd80b3 100644 --- a/goal_src/jak2/pc/progress/progress-h-pc.gc +++ b/goal_src/jak2/pc/progress/progress-h-pc.gc @@ -26,6 +26,20 @@ () ) +(deftype menu-resolution-option (menu-option) + ((last-move time-frame) + (selected-index int16) + (scroll-index float) + (valid? symbol) + + ;; OS state kept for drawing later, avoids desync and duplicate fetching + (num-resolutions int) + (win-aspect float) + (win-w int32) + (win-h int32) + ) + ) + (deftype menu-music-player-option (menu-option) ((last-move time-frame) diff --git a/goal_src/jak2/pc/progress/progress-pc.gc b/goal_src/jak2/pc/progress/progress-pc.gc index ca96943d81..5aad837802 100644 --- a/goal_src/jak2/pc/progress/progress-pc.gc +++ b/goal_src/jak2/pc/progress/progress-pc.gc @@ -343,6 +343,10 @@ (set! (-> (the-as menu-music-player-option (-> *music-player-options* options 0)) excitement) 0) (set! (-> obj current-options) *music-player-options*) ) + (('resolutions) + (set! (-> (the-as menu-resolution-option (-> *resolutions-options* options 0)) selected-index) -1) + (set! (-> obj current-options) *resolutions-options*) + ) (('fps-disclaimer) (set-time! (-> *progress-state-pc* frame-rate-disclaimer-time)) (set! (-> obj current-options) *frame-rate-disclaimer-options*) @@ -660,7 +664,199 @@ ) ) (when scroll-sound? - (sound-play "secrets-scroll")) + (sound-play "roll-over")) + ) + 0 + ) + + + +(defun calculate-current-resolution-index ((want-aspect float) (want-w int) (want-h int)) + (let ((res-w 0) + (res-h 0) + (res-aspect 0.0) + (res-valid 0)) + (dotimes (i (pc-get-num-resolutions)) + (pc-get-resolution i (& res-w) (& res-h)) + (set! res-aspect (/ (the float res-w) (the float res-h))) + (when (or (= (pc-get-display-mode) 'windowed) + (< (fabs (- want-aspect res-aspect)) 0.05)) + (if (and (= res-h want-h) (= res-w want-w)) + (return res-valid)) + (1+! res-valid)) + ) + (cond + ;; 512x416 + ((and (= want-w 512) (= want-h 416)) + res-valid) + ;; 512x208 + ((and (= want-w 512) (= want-h 208)) + (1+ res-valid)) + ;; nothing found + (else + -1) + )) + ) + + +(defglobalconstant DEBUG_RESOLUTION_OPTION #f) +(defmethod respond-progress ((this menu-resolution-option) (arg0 progress) (arg1 symbol)) + "Handle progress menu navigation logic." + + ;; control logic + (let ((scroll-sound? #f) + (resolutions-valid 0) + (resolution-found #f) + (cur-w 0) + (cur-h 0) + (select-w -1) + (select-h -1) + ) + + (set! (-> this num-resolutions) (pc-get-num-resolutions)) + (cond + ;; valid state + ((> (-> this num-resolutions) 0) + (true! (-> this valid?)) + + ;; this code isnt the greatest... + ;; the logic here is that, unlike jak 1, we don't build a list of resolutions and then scroll through that. + ;; we calculate the list every frame, keeping track of the index that is highlighted. + ;; this allows for infinite resolutions and for it to update live according to monitor changes. + + (cond + ((fullscreen?) + ;; grab current window sizes for aspect ratio purposes (only relevant for fullscreen) + (pc-get-window-size (&-> this win-w) (&-> this win-h)) + + (set! cur-w (-> *pc-settings* width)) + (set! cur-h (-> *pc-settings* height)) + (set! (-> this win-aspect) (/ (the float (-> this win-w)) (the float (-> this win-h)))) + (#when DEBUG_RESOLUTION_OPTION (format *stdcon* "fullscreen mode~%")) + ) + (else + (set! cur-w (-> *pc-settings* window-width)) + (set! cur-h (-> *pc-settings* window-height)) + (set! (-> this win-aspect) (/ (the float cur-w) (the float cur-h))) + (#when DEBUG_RESOLUTION_OPTION (format *stdcon* "windowed mode~%")) + ) + ) + + ;; check if we want to automatically pick something already + (when (= -1 (-> this selected-index)) + (set! (-> this selected-index) (calculate-current-resolution-index (-> this win-aspect) cur-w cur-h)) + (#when DEBUG_RESOLUTION_OPTION (format #t "recalc index got ~D~%" (-> this selected-index))) + ;; update if not invalid? + (cond + ((= (-> this selected-index) -1) + (set! (-> this selected-index) 0) ;; give up, just select the first one by default. + ) + (else + (set! select-w cur-w) + (set! select-h cur-h) + (true! resolution-found) + (set! (-> this scroll-index) (the float (-> this selected-index))) + ) + ) + ) + + ;; if we haven't automatically picked a resolution, iterate and find the one highlighted + (when (not resolution-found) + (#when DEBUG_RESOLUTION_OPTION (format *stdcon* "finding resolution ~D~%" (-> this selected-index))) + (dotimes (i (-> this num-resolutions)) + + ;; count "valid" resolutions + (let ((this-w 0) (this-h 0) (this-aspect 0.0)) + (pc-get-resolution i (& this-w) (& this-h)) + (set! this-aspect (/ (the float this-w) (the float this-h))) + + (when (or (= (pc-get-display-mode) 'windowed) + (< (fabs (- (-> this win-aspect) this-aspect)) 0.05)) + ;; this is the highlighted option - save it + (when (= resolutions-valid (-> this selected-index)) + (set! select-w this-w) (set! select-h this-h) + (true! resolution-found) + ;;(set! i (-> this num-resolutions)) ;; abandon loop + ) + (1+! resolutions-valid) + )) + ) + ) + + ;; if still didn't find it, it must be one of the hardcoded cases + (cond + (resolution-found + ;; yay + ) + ;; 512x416 + ((and (fullscreen?) (= resolutions-valid (-> this selected-index))) + (set! select-w 512) + (set! select-h 416) + ) + ;; 512x208 + ((and (fullscreen?) (= (1+ resolutions-valid) (-> this selected-index))) + (set! select-w 512) + (set! select-h 208) + ) + ;; STILL nothing? I don't know how this happens, just don't even try then. + (else + (false! (-> this valid?)) + ) + ) + + ;; hardcoded cases + (when (fullscreen?) + (+! resolutions-valid 2)) + ) + ;; not sure what happened, but there's not even any resolutions + (else + (false! (-> this valid?)) + ) + ) + + (cond + ((-> this valid?) + (#when DEBUG_RESOLUTION_OPTION + (format *stdcon* "selected: ~D (~D x ~D)~%" (-> this selected-index) select-w select-h) + (format *stdcon* "current: ~D x ~D~%" cur-w cur-h) + (format *stdcon* "resolution: ~D valid (out of ~D)~%" resolutions-valid (-> this num-resolutions)) + ) + (cond + ;; navigate up + ((or (cpad-pressed? 0 up l-analog-up) + (and (cpad-hold? 0 up l-analog-up) (time-elapsed? (-> this last-move) (seconds 0.2)))) + (set-time! (-> this last-move)) + (true! scroll-sound?) + (min-max-wrap-around+! (-> this selected-index) -1 0 (1- resolutions-valid)) + ) + ;; navigate down + ((or (cpad-pressed? 0 down l-analog-down) + (and (cpad-hold? 0 down l-analog-down) (time-elapsed? (-> this last-move) (seconds 0.2)))) + (set-time! (-> this last-move)) + (true! scroll-sound?) + (min-max-wrap-around+! (-> this selected-index) 1 0 (1- resolutions-valid)) + ) + ;; select + ((cpad-pressed? 0 confirm) + (cpad-clear! 0 confirm) + (set-size! *pc-settings* select-w select-h #t) + (pop-state arg0)) + ;; exit + ((cpad-pressed? 0 triangle) + (cpad-clear! 0 triangle) + (pop-state arg0)) + ) + ) + (else + ;; just triangle to exit + (when (cpad-pressed? 0 triangle) + (cpad-clear! 0 triangle) + (pop-state arg0)) + ) + ) + + (when scroll-sound? + (sound-play "roll-over")) ) 0 ) diff --git a/goal_src/jak2/pc/progress/progress-static-pc.gc b/goal_src/jak2/pc/progress/progress-static-pc.gc index bd1fd8bd8d..2003a2b24b 100644 --- a/goal_src/jak2/pc/progress/progress-static-pc.gc +++ b/goal_src/jak2/pc/progress/progress-static-pc.gc @@ -6,6 +6,7 @@ Additional PC port specific file for overriding/expanding the progress menu This gives us more freedom to write code how we want. |# +;; temporary (set! (-> *main-options-debug* options 9) (new 'static 'menu-main-menu-option :name (text-id progress-music-player) :scale #t :next-state 'music-player)) ;; in jak 2, the options dont have to be all-caps anymore! @@ -135,7 +136,7 @@ This gives us more freedom to write code how we want. (pc-get-controller-name index *pc-cpp-temp-string*) *pc-cpp-temp-string*) :get-item-index-fn (lambda () (pc-get-controller-index 0)) - :on-confirm (lambda ((index int)) (pc-set-controller! index 0))) + :on-confirm (lambda ((index int) (the-progress progress)) (pc-set-controller! index 0))) (new 'static 'menu-generic-boolean-option :name (text-id progress-vibration) :should-disable? (lambda () (not (pc-current-controller-has-rumble?))) @@ -281,8 +282,8 @@ This gives us more freedom to write code how we want. (text-id language-name-korean) (text-id language-name-english-uk)) :get-item-index-fn (lambda () (-> *setting-control* user-default subtitle-language)) - :on-confirm (lambda ((index int)) (set! (-> *setting-control* user-default subtitle-language) - (the-as language-enum index)))) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *setting-control* user-default subtitle-language) (the-as language-enum index)))) (new 'static 'menu-generic-carousel-option :name (text-id progress-sound-language) :items (new 'static 'boxed-array :type text-id @@ -294,7 +295,8 @@ This gives us more freedom to write code how we want. (text-id language-name-japanese) (text-id language-name-korean)) :get-item-index-fn (lambda () (-> *setting-control* user-default language)) - :on-confirm (lambda ((index int)) (set! (-> *setting-control* user-default language) (the-as language-enum index)))) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *setting-control* user-default language) (the-as language-enum index)))) (new 'static 'menu-generic-carousel-option :name (text-id progress-text-language) :items (new 'static 'boxed-array :type text-id @@ -307,11 +309,11 @@ This gives us more freedom to write code how we want. (text-id language-name-korean) (text-id language-name-english-uk)) :get-item-index-fn (lambda () (-> *pc-settings* text-language)) - :on-confirm (lambda ((index int)) (set! (-> *pc-settings* text-language) - (the-as pc-language index)) - ;; NOTE - this doesn't actually work (naughty dog tried it too in their progress code) - ;; fix it eventually - (load-level-text-files (the-as int (-> *setting-control* user-default language))))) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *pc-settings* text-language) (the-as pc-language index)) + ;; NOTE - this doesn't actually work (naughty dog tried it too in their progress code) + ;; fix it eventually + (load-level-text-files (the-as int (-> *setting-control* user-default language))))) (progress-new-generic-link-to-scrolling-page (text-id progress-misc-game-options) (new 'static 'menu-generic-boolean-option :name (text-id progress-discord-rpc) @@ -331,8 +333,8 @@ This gives us more freedom to write code how we want. ;; store and restore pc-settings cheats ;; TODO - when cheats menus are actually added, update the backup whenever one is changed (if (-> *pc-settings* speedrunner-mode?) - (set! (-> *pc-settings* cheats-backup) (-> *pc-settings* cheats)) - (set! (-> *pc-settings* cheats) (-> *pc-settings* cheats-backup))) + (set! (-> *pc-settings* cheats-backup) (-> *pc-settings* cheats)) + (set! (-> *pc-settings* cheats) (-> *pc-settings* cheats-backup))) (commit-to-file *pc-settings*))) (new 'static 'menu-generic-boolean-option :name (text-id progress-fast-progress) @@ -392,7 +394,7 @@ This gives us more freedom to write code how we want. (pc-get-controller-name index *pc-cpp-temp-string*) *pc-cpp-temp-string*) :get-item-index-fn (lambda () (pc-get-controller-index 0)) - :on-confirm (lambda ((index int)) (pc-set-controller! index 0))) + :on-confirm (lambda ((index int) (the-progress progress)) (pc-set-controller! index 0))) (new 'static 'menu-generic-boolean-option :name (text-id progress-vibration) :should-disable? (lambda () (not (pc-current-controller-has-rumble?))) @@ -538,10 +540,23 @@ This gives us more freedom to write code how we want. (text-id language-name-korean) (text-id language-name-english-uk)) :get-item-index-fn (lambda () (-> *setting-control* user-default subtitle-language)) - :on-confirm (lambda ((index int)) (set! (-> *setting-control* user-default subtitle-language) - (the-as language-enum index)))) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *setting-control* user-default subtitle-language) (the-as language-enum index)))) (new 'static 'menu-generic-carousel-option :name (text-id progress-sound-language) + :items (new 'static 'boxed-array :type text-id + (text-id language-name-english) + (text-id language-name-french) + (text-id language-name-german) + (text-id language-name-spanish) + (text-id language-name-italian) + (text-id language-name-japanese) + (text-id language-name-korean)) + :get-item-index-fn (lambda () (-> *setting-control* user-default language)) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *setting-control* user-default language) (the-as language-enum index)))) + (new 'static 'menu-generic-carousel-option + :name (text-id progress-text-language) :items (new 'static 'boxed-array :type text-id (text-id language-name-english) (text-id language-name-french) @@ -551,11 +566,12 @@ This gives us more freedom to write code how we want. (text-id language-name-japanese) (text-id language-name-korean) (text-id language-name-english-uk)) - :get-item-index-fn (lambda () (-> *setting-control* user-default language)) - :on-confirm (lambda ((index int)) (set! (-> *setting-control* user-default language) (the-as language-enum index)) - ;; NOTE - this doesn't actually work (naughty dog tried it too in their progress code) - ;; fix it eventually - (load-level-text-files (the-as int (-> *setting-control* user-default language))))) + :get-item-index-fn (lambda () (-> *pc-settings* text-language)) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *pc-settings* text-language) (the-as pc-language index)) + ;; NOTE - this doesn't actually work (naughty dog tried it too in their progress code) + ;; fix it eventually + (load-level-text-files (the-as int (-> *setting-control* user-default language))))) (progress-new-generic-link-to-scrolling-page (text-id progress-misc-game-options) (new 'static 'menu-generic-boolean-option :name (text-id progress-discord-rpc) @@ -599,38 +615,16 @@ This gives us more freedom to write code how we want. (commit-to-file *pc-settings*)))))) -;; TODO - migrate this menu as well -;; graphic options -;; resolution - (define *msaa-options* (new 'static 'boxed-array :type int16 1 2 4 8 16)) (define *frame-rate-options* (new 'static 'boxed-array :type int16 60 75 120 144 165 240)) (define *frame-rate-disclaimer-seen?* #f) (define *graphic-options-pc* (progress-new-generic-scrolling-page (text-id progress-root-graphic-options) - (progress-new-generic-link-to-scrolling-page (text-id progress-graphics-ps2) - (new 'static 'menu-generic-boolean-option - :name (text-id progress-lod-bg) - :truthy-text (text-id progress-lod-low) - :falsey-text (text-id progress-lod-high) - :get-value-fn (lambda () (> (-> *pc-settings* lod-force-tfrag) 0)) - :on-confirm (lambda ((val symbol)) - (cond - (val - (set! (-> *pc-settings* lod-force-tfrag) 2) - (set! (-> *pc-settings* lod-force-tie) 2) - ) - (else - (set! (-> *pc-settings* lod-force-tfrag) 0) - (set! (-> *pc-settings* lod-force-tie) 0) - )) - (commit-to-file *pc-settings*))) - (static-progress-generic-pc-settings-lod-default-high-boolean (text-id progress-lod-fg) (-> *pc-settings* ps2-lod-dist?)) - (static-progress-generic-pc-settings-on-off-boolean (text-id progress-ps2-parts) (-> *pc-settings* ps2-parts?)) - (static-progress-generic-pc-settings-shadows-normal-extended-boolean (text-id progress-shadows) (-> *pc-settings* ps2-shadow?)) - (static-progress-generic-pc-settings-on-off-boolean (text-id progress-hires-sky) (-> *pc-settings* hires-clouds?)) - ) + (new 'static 'menu-generic-to-resolutions-option + :name (text-id progress-window-size) + :on-confirm (lambda ((the-progress progress)) + (push-and-set-state the-progress 'resolutions))) (new 'static 'menu-generic-carousel-option :name (text-id progress-graphics-display) :get-item-index-fn (lambda () (-> *pc-settings* monitor)) @@ -638,12 +632,11 @@ This gives us more freedom to write code how we want. :get-item-label-fn (lambda ((index int)) (let ((name (pc-get-display-name index *pc-cpp-temp-string*))) (if name - (string-format "(~D) ~S" index *pc-cpp-temp-string*) - (string-format "Display ~D" index) - ) + (string-format "(~D) ~S" index *pc-cpp-temp-string*) + (string-format "Display ~D" index)) ) ) - :on-confirm (lambda ((index int)) + :on-confirm (lambda ((index int) (the-progress progress)) (set-monitor! *pc-settings* index) (commit-to-file *pc-settings*) ) @@ -663,7 +656,7 @@ This gives us more freedom to write code how we want. (('borderless) 2) ) ) - :on-confirm (lambda ((index int)) + :on-confirm (lambda ((index int) (the-progress progress)) (case index ((0) (set-display-mode! *pc-settings* 'windowed #t)) ((1) (set-display-mode! *pc-settings* 'fullscreen #t)) @@ -693,12 +686,11 @@ This gives us more freedom to write code how we want. ) ) ) - :on-confirm (lambda ((index int)) + :on-confirm (lambda ((index int) (the-progress progress)) (case index ((0) (if (not (-> *pc-settings* use-vis?)) - (false! (-> *setting-control* user-current aspect-ratio)) - ) + (false! (-> *setting-control* user-current aspect-ratio))) (set! (-> *setting-control* user-default aspect-ratio) 'aspect4x3) (true! (-> *pc-settings* use-vis?)) (commit-to-file *pc-settings*) @@ -718,7 +710,7 @@ This gives us more freedom to write code how we want. (commit-to-file *pc-settings*) ) ((3) - (push-and-set-state (-> *progress-process* 0) 'aspect-ratio-custom) + (push-and-set-state the-progress 'aspect-ratio-custom) ) ) ) @@ -737,7 +729,7 @@ This gives us more freedom to write code how we want. ) :get-max-size-fn (lambda () (-> *frame-rate-options* length)) :get-item-label-fn (lambda ((index int)) (string-format "~D" (-> *frame-rate-options* index))) - :on-confirm (lambda ((index int)) + :on-confirm (lambda ((index int) (the-progress progress)) (cond ((or (zero? index) (= (-> *frame-rate-options* index) (-> *pc-settings* target-fps)) *frame-rate-disclaimer-seen?*) (set-frame-rate! *pc-settings* (-> *frame-rate-options* index) #t) @@ -746,7 +738,7 @@ This gives us more freedom to write code how we want. (else (defun-extern set-progress-frame-rate-index int int) (set-progress-frame-rate-index index) - (push-and-set-state (-> *progress-process* 0) 'fps-disclaimer) + (push-and-set-state the-progress 'fps-disclaimer) ) ) ) @@ -776,11 +768,33 @@ This gives us more freedom to write code how we want. (lookup-text! *common-text* (text-id progress-graphics-msaa-off) #f) (string-format (lookup-text! *common-text* (text-id progress-msaa-x) #f) (-> *msaa-options* index))) ) - :on-confirm (lambda ((index int)) - (set! (-> *pc-settings* gfx-msaa) (the int (pow 2.0 (the float index)))) + :on-confirm (lambda ((index int) (the-progress progress)) + (set! (-> *pc-settings* gfx-msaa) (ash 1 index)) (commit-to-file *pc-settings*) ) ) + (progress-new-generic-link-to-scrolling-page (text-id progress-graphics-ps2) + (new 'static 'menu-generic-boolean-option + :name (text-id progress-lod-bg) + :truthy-text (text-id progress-lod-low) + :falsey-text (text-id progress-lod-high) + :get-value-fn (lambda () (> (-> *pc-settings* lod-force-tfrag) 0)) + :on-confirm (lambda ((val symbol)) + (cond + (val + (set! (-> *pc-settings* lod-force-tfrag) 2) + (set! (-> *pc-settings* lod-force-tie) 2) + ) + (else + (set! (-> *pc-settings* lod-force-tfrag) 0) + (set! (-> *pc-settings* lod-force-tie) 0) + )) + (commit-to-file *pc-settings*))) + (static-progress-generic-pc-settings-lod-default-high-boolean (text-id progress-lod-fg) (-> *pc-settings* ps2-lod-dist?)) + (static-progress-generic-pc-settings-on-off-boolean (text-id progress-ps2-parts) (-> *pc-settings* ps2-parts?)) + (static-progress-generic-pc-settings-shadows-normal-extended-boolean (text-id progress-shadows) (-> *pc-settings* ps2-shadow?)) + (static-progress-generic-pc-settings-on-off-boolean (text-id progress-hires-sky) (-> *pc-settings* hires-clouds?)) + ) ) ) @@ -817,3 +831,15 @@ This gives us more freedom to write code how we want. ) +(define *resolutions-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-resolution-option :name (text-id progress-window-size)) + ) + ) + ) + +