Files
jak-project/goal_src/jak2/pc/pckernel.gc
T
ManDude 18ddd1613c Jak 2 pc subtitle support (#2672)
Adds support for adding custom subtitles to Jak 2 audio. Comes with a
new editor for the new system and format. Compared to the Jak 1 system,
this is much simpler to make an editor for.

Comes with a few subtitles already made as an example.
Cutscenes are not officially supported but you can technically subtitle
those with editor, so please don't right now.

This new system supports multiple subtitles playing at once (even from a
single source!) and will smartly push the subtitles up if there's a
message already playing:

![image](https://github.com/open-goal/jak-project/assets/7569514/033e6374-a05a-4c31-b029-51868153a932)

![image](https://github.com/open-goal/jak-project/assets/7569514/5298aa6d-a183-446e-bdb6-61c4682df917)

Unlike in Jak 1, it will not hide the bottom HUD when subtitles are
active:

![image](https://github.com/open-goal/jak-project/assets/7569514/d466bfc0-55d0-4689-a6e1-b7784b9fff59)

Sadly this leaves us with not much space for the subtitle region (and
the subtitles are shrunk when the minimap is enabled) but when you have
guards and citizens talking all the time, hiding the HUD every time
anyone spoke would get really frustrating.

The subtitle speaker is also color-coded now, because I thought that
would be fun to do.

TODO:
- [x] proper cutscene support.
- [x] merge mode for cutscenes so we don't have to rewrite the script?

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2023-06-08 01:04:16 +01:00

165 lines
5.6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
#|
This file runs the game-specific version of the pckernel.
See pckernel-common.gc for the bulk of the pckernel.
|#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; methods
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod set-game-setting! pc-settings-jak2 ((obj pc-settings-jak2) (setting symbol) (value symbol))
(case setting
(('video-mode)
(set! (-> *setting-control* user-current video-mode) #f)
(set! (-> *setting-control* user-default video-mode) value)
)
(('aspect-ratio)
(set! (-> *setting-control* user-default aspect-ratio) value)
)
(else
(format #t "unknown setting ~A (~A) to set-game-setting!" setting value))
)
)
(defmethod get-game-setting pc-settings-jak2 ((obj pc-settings-jak2) (setting symbol))
(case setting
(('video-mode)
(-> *setting-control* user-default video-mode)
)
(('aspect-ratio)
(-> *setting-control* user-default aspect-ratio)
)
(else
(format #t "unknown setting ~A to get-game-setting" setting)
#f)
)
)
(defmethod set-game-language! pc-settings-jak2 ((obj pc-settings-jak2) (lang language-enum))
(set! (-> *setting-control* user-default language) lang)
)
(defmethod get-game-language pc-settings-jak2 ((obj pc-settings-jak2))
(get-current-language)
)
(defmethod update pc-settings-jak2 ((obj pc-settings-jak2))
"handle the text parsing input for the 'settings' group"
((method-of-type pc-settings update) obj)
(set! (-> obj movie?) (and (!= #f *scene-player*) (movie?)))
(none))
(defmethod update-discord-rpc pc-settings-jak2 ((obj pc-settings-jak2))
"update discord rpc module"
(let ((info (new 'stack 'discord-info)))
(set! (-> info orb-count) (&-> *game-info* skill-total))
(set! (-> info gem-count) (&-> *game-info* gem-total))
(set! (-> info death-count) (&-> *game-info* total-deaths))
(set! (-> info status) "Playing Jak II™")
;; grab the name of the level we're in
(if (and *level* (level-get-target-inside *level*))
(set! (-> info level) (symbol->string (-> (level-get-target-inside *level*) name)))
(set! (-> info level) "unknown"))
(set! (-> info cutscene?) #f) ;; TODO - cutscenes don't work yet
(set! (-> info time-of-day) (&-> *time-of-day-context* time))
(set! (-> info percent-complete) (calculate-percentage *game-info*))
;; TODO - wrapping in `with-profiler` causes an error, fix it
(pc-discord-rpc-update info))
(none))
(defmethod update-speedrun pc-settings-jak2 ((obj pc-settings-jak2))
"update speedrun module"
(when (-> *pc-settings* speedrunner-mode?)
(speedrun-mode-update))
(none))
(defmethod update-video-hacks pc-settings-jak2 ((obj pc-settings-jak2))
"update the graphics hacks used for the progress menu. ugh."
(set! (-> (get-video-params) relative-x-scale) (-> obj aspect-ratio-reciprocal))
(set! (-> (get-video-params) relative-x-scale-reciprical) (-> obj aspect-ratio-scale))
)
(defmethod eligible-for-fast-elevator? pc-settings-jak2 ((obj pc-settings-jak2) (proc process))
"is this a valid process for a fast elevator?"
(and (-> obj fast-elevator?) (not (or (string= (-> proc name) "drill-lift-1")
(string= (-> proc name )"drill-lift-2"))))
)
(define *airlock-speed* 1.5)
(defmethod get-airlock-speed pc-settings-jak2 ((obj pc-settings-jak2))
"return the current speed modifier for airlocks"
(if (-> obj fast-airlock?)
*airlock-speed*
1.0)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; file I/O
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod handle-input-settings pc-settings-jak2 ((obj pc-settings-jak2) (file file-stream))
"handle the text parsing input for the 'settings' group"
((method-of-type pc-settings handle-input-settings) obj file)
(case-str *pc-temp-string*
(("jetboard-trick-text?") (set! (-> obj jetboard-trick-text?) (file-stream-read-symbol file)))
(("fast-airlock?") (set! (-> obj fast-airlock?) (file-stream-read-symbol file)))
(("fast-elevator?") (set! (-> obj fast-elevator?) (file-stream-read-symbol file)))
(("text-language") (set! (-> obj text-language) (the-as pc-language (file-stream-read-int file))))
)
0)
(defmethod handle-output-settings pc-settings-jak2 ((obj pc-settings-jak2) (file file-stream))
"handle the text writing output for the 'settings' group"
((method-of-type pc-settings handle-output-settings) obj file)
(format file " (jetboard-trick-text? ~A)~%" (-> obj jetboard-trick-text?))
(format file " (fast-airlock? ~A)~%" (-> obj fast-airlock?))
(format file " (fast-elevator? ~A)~%" (-> obj fast-elevator?))
(format file " (text-language ~D)~%" (-> obj text-language))
0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; PC settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-once *pc-settings* (new 'global 'pc-settings-jak2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; other
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun draw-build-revision ()
(with-dma-buffer-add-bucket ((buf (-> (current-frame) global-buf))
(bucket-id debug-no-zbuf1))
(draw-string-xy *pc-settings-built-sha*
buf
0 10
(font-color flat-yellow)
(font-flags shadow kerning))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; process pools
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; the actor pool for PC processes! it has space for 4 processes, with 16K of space.
(define *pc-dead-pool* (new 'global 'dead-pool 4 (* 16 1024) "*pc-dead-pool*"))