diff --git a/goal_src/jak2/engine/scene/scene.gc b/goal_src/jak2/engine/scene/scene.gc index fb886eab2..d3037637a 100644 --- a/goal_src/jak2/engine/scene/scene.gc +++ b/goal_src/jak2/engine/scene/scene.gc @@ -921,19 +921,25 @@ ) ) (process-entity-status! self (entity-perm-status no-kill) #t) - (until (not (or (-> *setting-control* user-current talking) - (-> *setting-control* user-current spooling) - (-> *setting-control* user-current hint) - (-> *setting-control* user-current ambient) - ) - ) + ;; og:preserve-this + ;; NOTE - for speedrunner mode, allows the game to continue + ;; even if there is a dialogue in progress + (until (not (or (-> *setting-control* user-current spooling) + (when (not (-> *pc-settings* speedrunner-mode?)) + (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient))))) (set-setting! 'allow-progress #f 0.0 0) (apply-settings *setting-control*) (dotimes (s4-0 2) - (while (or (-> *setting-control* user-current talking) - (-> *setting-control* user-current spooling) - (-> *setting-control* user-current hint) - (-> *setting-control* user-current ambient) + ;; og:preserve-this + ;; NOTE - for speedrunner mode, allows the game to continue + ;; even if there is a dialogue in progress + (while (or (-> *setting-control* user-current spooling) + (when (not (-> *pc-settings* speedrunner-mode?)) + (or (-> *setting-control* user-current talking) + (-> *setting-control* user-current hint) + (-> *setting-control* user-current ambient))) (or (and (-> *setting-control* user-current movie) (!= (-> *setting-control* user-current movie) (process->ppointer self)) ) diff --git a/goal_src/jak2/levels/common/warp-gate.gc b/goal_src/jak2/levels/common/warp-gate.gc index a26c49558..0731f8386 100644 --- a/goal_src/jak2/levels/common/warp-gate.gc +++ b/goal_src/jak2/levels/common/warp-gate.gc @@ -538,11 +538,19 @@ (and (-> self continue) (not (focus-test? *target* in-head edge-grab pole flut tube board pilot mech indax)) (-> *setting-control* user-current airlock) - (not (-> *setting-control* user-current hint)) + ;; og:preserve-this + ;; For speedrunner mode, always allow warp-gates to be used + ;; even when dialogues are playing + (or (-> *pc-settings* speedrunner-mode?) + (not (-> *setting-control* user-current hint))) ) ) (talker-surpress!) - (when (and (can-display-query? self (the-as string #f) -99.0) + ;; og:preserve-this + ;; For speedrunner mode, always allow warp-gates to be used + ;; even when dialogues are playing + (when (and (or (-> *pc-settings* speedrunner-mode?) + (can-display-query? self (the-as string #f) -99.0)) (cond ((and (-> *target* next-state) (let ((v1-30 (-> *target* next-state name))) (or (= v1-30 'target-warp-in) (= v1-30 'target-warp-out)) diff --git a/goal_src/jak2/pc/features/speedruns-h.gc b/goal_src/jak2/pc/features/speedruns-h.gc index 3c14fd218..e980c66f8 100644 --- a/goal_src/jak2/pc/features/speedruns-h.gc +++ b/goal_src/jak2/pc/features/speedruns-h.gc @@ -11,6 +11,8 @@ ;; there's no point in adding categories that just start from a new-game and have later restrictions ;; because we aren't going to modify the code to make that possible ;; ie. removing mars tomb skip if you pick "all missions" + ;; Random one for experimentation + (all-cheats-allowed 999) ) (deftype speedrun-info (structure) diff --git a/goal_src/jak2/pc/features/speedruns.gc b/goal_src/jak2/pc/features/speedruns.gc index 2b88b14ec..f57443c53 100644 --- a/goal_src/jak2/pc/features/speedruns.gc +++ b/goal_src/jak2/pc/features/speedruns.gc @@ -13,14 +13,15 @@ ;; turn on speedrun verification display (set! (-> this display-run-info?) #t) ;; ensure any required settings are enabled - (set! (-> *setting-control* user-default dialog-volume) 0.0) ;; disable dialog volume (enforce-settings! this) ;; finalize any category specific setup code (case (-> this category) (((speedrun-category newgame-normal)) (initialize! *game-info* 'game (the-as game-save #f) "game-start")) (((speedrun-category newgame-heromode)) - (initialize! *game-info* 'game (the-as game-save #f) "game-start-hero"))) + (initialize! *game-info* 'game (the-as game-save #f) "game-start-hero")) + (((speedrun-category all-cheats-allowed)) + (initialize! *game-info* 'game (the-as game-save #f) "game-start"))) (if (!= -1 (-> *game-info* auto-save-which)) (set! (-> *setting-control* user-default auto-save) #t)) @@ -30,7 +31,16 @@ (defmethod enforce-settings! ((this speedrun-info)) (set! (-> *pc-settings* ps2-actor-vis?) #t) ;; force PS2 actor visibility (set-frame-rate! *pc-settings* 60 #t) ;; force FPS to `60` - (set! (-> *pc-settings* cheats) (the-as pc-cheats #x0)) ;; disable any active cheats + ;; For posterity, the main reason why changing the cheats is useful is for two main reasons: + ;; - If you are playing a category that requires cheats (ie. a turbo jetboard one) you'd + ;; probably like the game to automatically set the appropriate ones for you + ;; - If you are playing a category that forbids cheats, you wouldn't want your run invalidated because you forgot + ;; + ;; However, the pc-settings stores a backup of your cheats whenever you manually modify them (NYI - no menus yet) + ;; and when speedrunner mode is first enabled. They are restored when speedrunner mode is disabled. + (when (!= (-> this category) (speedrun-category all-cheats-allowed)) + ;; disable any active cheats + (set! (-> *pc-settings* cheats) (the-as pc-cheats #x0))) (none)) (defmethod hide-run-info! ((this speedrun-info)) @@ -66,7 +76,8 @@ (-> this display-run-info?)) (clear *temp-string*) (clear *pc-encoded-temp-string*) - (format *temp-string* "PC Cheats: ~D~%Frame Rate: ~D~%PS2 Actor Vis?: ~S~%Version: ~S~%" + (format *temp-string* "Category: ~S~%PC Cheats: ~D~%Frame Rate: ~D~%PS2 Actor Vis?: ~S~%Version: ~S~%" + (enum->string speedrun-category (-> this category)) (the-as int (-> *pc-settings* cheats)) (-> *pc-settings* target-fps) (if (-> *pc-settings* ps2-actor-vis?) "true" "false") @@ -76,7 +87,7 @@ ;; reset bucket settings prior to drawing - font won't do this for us, and ;; draw-raw-image can sometimes mess them up. (intro sequence) (dma-buffer-add-gs-set-flusha buf (alpha-1 (new 'static 'gs-alpha :b #x1 :d #x1)) (tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))) - (let ((font-ctx (new 'stack 'font-context *font-default-matrix* 510 375 0.0 (font-color default) (font-flags right shadow kerning large)))) + (let ((font-ctx (new 'stack 'font-context *font-default-matrix* 510 365 0.0 (font-color default) (font-flags right shadow kerning large)))) (set! (-> font-ctx scale) 0.325) (draw-string-adv *pc-encoded-temp-string* buf font-ctx)))) (none)) @@ -87,6 +98,16 @@ (new 'static 'popup-menu :entries (new 'static 'boxed-array :type popup-menu-entry (new 'static 'popup-menu-button :label "Reset" :on-press (lambda () (send-event (ppointer->process *speedrun-menu*) 'invoke (speedrun-menu-command reset)))) + (new 'static 'popup-menu-label :label "Categories") + (new 'static 'popup-menu-flag :label "Normal" + :on-press (lambda () (set-category! *speedrun-info* (speedrun-category newgame-normal))) + :is-toggled? (lambda () (= (-> *speedrun-info* category) (speedrun-category newgame-normal)))) + (new 'static 'popup-menu-flag :label "Hero Mode" + :on-press (lambda () (set-category! *speedrun-info* (speedrun-category newgame-heromode))) + :is-toggled? (lambda () (= (-> *speedrun-info* category) (speedrun-category newgame-heromode)))) + (new 'static 'popup-menu-flag :label "All Cheats Allowed" + :on-press (lambda () (set-category! *speedrun-info* (speedrun-category all-cheats-allowed))) + :is-toggled? (lambda () (= (-> *speedrun-info* category) (speedrun-category all-cheats-allowed)))) (new 'static 'popup-menu-button :label "Exit" :on-press (lambda () (send-event (ppointer->process *speedrun-menu*) 'invoke (speedrun-menu-command exit)))) ) ) @@ -159,7 +180,7 @@ (when (-> this draw-menu?) ;; handle any inputs for within the menu (cond - ((cpad-pressed? 0 triangle select) + ((cpad-pressed? 0 triangle select circle) (set! (-> this draw-menu?) #f)) ((cpad-pressed? 0 up) (move-up! (-> this popup-menu))) diff --git a/goal_src/jak2/pc/pckernel-impl.gc b/goal_src/jak2/pc/pckernel-impl.gc index 58e3464dc..a1800acc9 100644 --- a/goal_src/jak2/pc/pckernel-impl.gc +++ b/goal_src/jak2/pc/pckernel-impl.gc @@ -79,6 +79,7 @@ (cheats pc-cheats) (cheats-revealed pc-cheats) (cheats-purchased pc-cheats) + (cheats-backup pc-cheats) ;; backup for 'cheats', persisted to disk to be restored when disabling speedrunner mode ;; music (music-unlocked bit-array) (flava-unlocked symbol 6) diff --git a/goal_src/jak2/pc/pckernel.gc b/goal_src/jak2/pc/pckernel.gc index a9eee44ec..aeb6c9b68 100644 --- a/goal_src/jak2/pc/pckernel.gc +++ b/goal_src/jak2/pc/pckernel.gc @@ -563,6 +563,7 @@ (("cheats") (set! (-> obj cheats) (the-as pc-cheats (file-stream-read-int file)))) (("cheats-revealed") (set! (-> obj cheats-revealed) (the-as pc-cheats (file-stream-read-int file)))) (("cheats-purchased") (set! (-> obj cheats-purchased) (the-as pc-cheats (file-stream-read-int file)))) + (("cheats-backup") (set! (-> obj cheats-backup) (the-as pc-cheats (file-stream-read-int file)))) (("music-unlocked") (dotimes (i (/ (align64 (-> obj music-unlocked length)) 64)) (bit-array<-int64 (-> obj music-unlocked) (* i 64) (file-stream-read-int file)) @@ -591,6 +592,7 @@ (format file " (cheats #x~x)~%" (-> obj cheats)) (format file " (cheats-revealed #x~x)~%" (-> obj cheats-revealed)) (format file " (cheats-purchased #x~x)~%" (-> obj cheats-purchased)) + (format file " (cheats-backup #x~x)~%" (-> obj cheats-backup)) (format file " (music-unlocked") (dotimes (i (/ (align64 (-> obj music-unlocked length)) 64)) (format file " #x~x" (int64<-bit-array (-> obj music-unlocked) (* i 64))) diff --git a/goal_src/jak2/pc/progress/progress-static-pc.gc b/goal_src/jak2/pc/progress/progress-static-pc.gc index 47b981109..fb847370f 100644 --- a/goal_src/jak2/pc/progress/progress-static-pc.gc +++ b/goal_src/jak2/pc/progress/progress-static-pc.gc @@ -364,6 +364,11 @@ This gives us more freedom to write code how we want. :get-value-fn (lambda () (-> *pc-settings* speedrunner-mode?)) :on-confirm (lambda ((val symbol)) (set! (-> *pc-settings* speedrunner-mode?) val) + ;; 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))) (commit-to-file *pc-settings*))) (new 'static 'menu-generic-boolean-option :name (text-id progress-fast-progress) diff --git a/goal_src/jak2/pc/util/popup-menu-h.gc b/goal_src/jak2/pc/util/popup-menu-h.gc index 23b6d065c..19d086e0b 100644 --- a/goal_src/jak2/pc/util/popup-menu-h.gc +++ b/goal_src/jak2/pc/util/popup-menu-h.gc @@ -12,8 +12,13 @@ (:methods (draw! (_type_ font-context dma-buffer) none))) +(deftype popup-menu-label (popup-menu-entry) ()) + (deftype popup-menu-button (popup-menu-entry) ()) +(deftype popup-menu-flag (popup-menu-entry) + ((is-toggled? (function symbol)))) + (deftype popup-menu (basic) ((entries (array popup-menu-entry)) (curr-entry-index int32)) diff --git a/goal_src/jak2/pc/util/popup-menu.gc b/goal_src/jak2/pc/util/popup-menu.gc index 84fda0d60..c05ff40d5 100644 --- a/goal_src/jak2/pc/util/popup-menu.gc +++ b/goal_src/jak2/pc/util/popup-menu.gc @@ -2,9 +2,6 @@ (in-package goal) (defmethod draw! ((this popup-menu-entry) (font-ctx font-context) (dma-buf dma-buffer)) - (none)) - -(defmethod draw! ((this popup-menu-button) (font-ctx font-context) (dma-buf dma-buffer)) (let ((old-x (-> font-ctx origin x)) (old-y (-> font-ctx origin y))) (pc-encode-utf8-string (-> this label) *pc-encoded-temp-string*) @@ -31,20 +28,37 @@ (new 'static 'rgba :r 0 :g 0 :b 0 :a 255)) ;; menu contents (dotimes (i (-> this entries length)) - (if (= i (-> this curr-entry-index)) - (set! (-> font-ctx color) (font-color cyan)) - (set! (-> font-ctx color) (font-color default))) + (cond + ;; TODO - probably just handle this in the draw methods + ((type? (-> this entries i) popup-menu-label) + (set! (-> font-ctx color) (font-color progress-option-off))) + ((type? (-> this entries i) popup-menu-flag) + (set! (-> font-ctx color) + (if (or ((-> (the-as popup-menu-flag (-> this entries i)) is-toggled?)) + (= i (-> this curr-entry-index))) + (font-color cyan) + (font-color default)))) + (else + (set! (-> font-ctx color) + (if (= i (-> this curr-entry-index)) + (font-color cyan) + (font-color default))))) (draw! (-> this entries i) font-ctx buf) - (set! (-> font-ctx origin y) (+ 15.0 (-> font-ctx origin y))))) - ) + (set! (-> font-ctx origin y) (+ 15.0 (-> font-ctx origin y)))))) (none)) (defmethod move-up! ((this popup-menu)) (set! (-> this curr-entry-index) (max 0 (dec (-> this curr-entry-index)))) + ;; skip labels + (when (type? (-> this entries (-> this curr-entry-index)) popup-menu-label) + (set! (-> this curr-entry-index) (max 0 (dec (-> this curr-entry-index))))) (none)) (defmethod move-down! ((this popup-menu)) (set! (-> this curr-entry-index) (min (dec (-> this entries length)) (inc (-> this curr-entry-index)))) + ;; skip labels + (when (type? (-> this entries (-> this curr-entry-index)) popup-menu-label) + (set! (-> this curr-entry-index) (min (dec (-> this entries length)) (inc (-> this curr-entry-index))))) (none)) (defmethod press! ((this popup-menu))