[Jak 2 and Jak 3]: Fixing menu text boundaries and drawing alignments for Automatic and Custom aspect ratios (#4380)

This PR fixes the alignment of text and other elements in several menus
of Jak 3 (as well as some of Jak 2) when using Automatic or Custom
aspect ratios. It also cleans up some of the relevant functions which
are used to draw these menus (although I'm still learning how to clean
goal code).

I mostly used french text for testing (since the french text seems to
push the font boundaries to their limits a bit more).
I used Automatic 16:9 and Custom 4:1 aspect ratios for testing to see if
my changes scale to other aspect ratios properly, comparing with PS2 4:3
for reference.



### Jak 3

### Image Color Scale

Before:
- The black/white color scale would get stretched (beyond the limits of
the menu in 4x1)
<img width="1280" height="758" alt="color-scale-16x9-broken"
src="https://github.com/user-attachments/assets/4b3b897e-1417-42da-86a1-dd78926ccb73"
/>
<img width="1283" height="747" alt="color-scale-4x1-broken"
src="https://github.com/user-attachments/assets/44d192ba-5afe-43ae-9419-021123478a31"
/>

Reference (PS2 4:3 in OpenGoal):
<img width="1278" height="773" alt="color-scale-reference"
src="https://github.com/user-attachments/assets/d9bd8f4e-8f69-49a9-8a99-3fcd3d7a4097"
/>

After fixes:

<img width="1283" height="765" alt="color-scale-16x9-fixed"
src="https://github.com/user-attachments/assets/99422d7f-d688-4d91-8ce0-6ad0b7cb10df"
/>
<img width="1282" height="762" alt="color-scale-4x1-fixed"
src="https://github.com/user-attachments/assets/6011f30a-0c31-4ea9-afe1-735ec36f3d32"
/>




### Secrets menu

Before:
- The secret titles touch their costs (#4233).
- The alignment of the top line showing orbs available/cost and total
orbs collected is broken (more noticeable in 4:1)
- The alignment of the titles for groups of secrets is broken (more
noticeable in 4:1)
- The indentation for secret titles relative to the group of secrets is
also broken (again, more noticeable in 4:1)
<img width="1286" height="758" alt="secrets-broken-16x9"
src="https://github.com/user-attachments/assets/bd6c7dab-ce95-4349-bf1d-2a09f82fcbfe"
/>
<img width="1287" height="751" alt="secrets-broken-4x1"
src="https://github.com/user-attachments/assets/3e1ce842-19ba-49b3-92f9-52034ae1982f"
/>

Reference (PS2 4:3 in OpenGoal):

<img width="1280" height="761" alt="Screenshot from 2026-08-16 22-58-22"
src="https://github.com/user-attachments/assets/7326a1c7-b479-4fb7-9450-377a05ab7963"
/>

After fixes:
<img width="1280" height="722" alt="secrets-fixed-16x9"
src="https://github.com/user-attachments/assets/0a66d45f-3aa3-4cc8-ac88-c6aef20f1319"
/>
<img width="1286" height="713" alt="secrets-fixed-4x1"
src="https://github.com/user-attachments/assets/e8740739-42ac-4a12-aad1-e6620dfc73ed"
/>



### Secrets purchase menu

Before: 

- The text for the secret you're purchasing can get cut off if too big.
- As before, the top line showing orb cost/orbs collected is misaligned.
<img width="1288" height="754" alt="secrets-purchase-broken-16x9"
src="https://github.com/user-attachments/assets/49b709e3-c015-42ba-b0aa-034769286d77"
/>
<img width="1281" height="756" alt="secrets-purchase-broken-4x1"
src="https://github.com/user-attachments/assets/0c3c5e02-048a-4188-ada7-2413c384224b"
/>

Reference (PS2 4:3 in OpenGoal):

<img width="1286" height="753" alt="secrets-purchase-reference"
src="https://github.com/user-attachments/assets/bb0b1d1a-87f6-4343-8a82-2e1f968943cd"
/>

After fixes:
<img width="1286" height="759" alt="secrets-purchase-fixed-16x9"
src="https://github.com/user-attachments/assets/1d73593f-1d58-407e-9ce6-2da5bf0fd84b"
/>
<img width="1283" height="750" alt="secrets-purchase-fixed-4x1"
src="https://github.com/user-attachments/assets/85c7e14d-c6b2-4b21-83e5-173af5cba185"
/>


### Save/Load/Create Hero Mode Save menu

Here I show the load game screen only but the bugs were the same among
all 3 as the code is shared. The fixes apply to all 3 as well 😃

Before:

- The header text is cut off in french. 
- There is a faint red rectangle to the right of the menu (look closely!
It's a bit clearer and goes beyond the menu in 4x1).
- The left yellow boxes around the save-games that are not selected do
not scale properly (more noticeable in 4x1).

<img width="1284" height="749" alt="load-broken-Automatic"
src="https://github.com/user-attachments/assets/2ae3bd8b-42ec-49bc-9851-cbaace4ce64b"
/>
<img width="1285" height="751" alt="load-broken-4x1"
src="https://github.com/user-attachments/assets/655de844-748c-43f9-a2e8-d779fe3a8e19"
/>

Reference (PS2 4:3 in OpenGoal):
<img width="1281" height="762" alt="load-screen-4x3"
src="https://github.com/user-attachments/assets/e4e320c9-999a-44a7-8b3e-34cfdbeef5a1"
/>



After Fixes:

- Now headers that exceed the width of the menu screen will be shrunken
down to fit. This will hopefully work for any other menus that need it
as well 😃
- No more red rectangle on the right, and the yellow box to the left
around the save games scales properly.

<img width="1286" height="754" alt="load-fixed-automatic"
src="https://github.com/user-attachments/assets/1a48d811-5684-4f7e-a12a-19e896e30b48"
/>
<img width="1288" height="749" alt="load-fixed-4x1"
src="https://github.com/user-attachments/assets/f5a68cb1-576a-4927-977b-b3419aaf7c23"
/>


### Missions menu 

Before:

- Mission text is sometimes cut off on the right
- Mission text is shifted to the right (more noticeable in 4x1)

<img width="1286" height="753" alt="missions-alignment-broken-16x9"
src="https://github.com/user-attachments/assets/37175eb7-e191-4c09-bb72-b40819acd99b"
/>
<img width="1281" height="750" alt="missions-alignment-broken-16x9-2"
src="https://github.com/user-attachments/assets/482f351a-7386-4211-8434-cf60c0691fdb"
/>
<img width="1286" height="756" alt="missions-broken-4x1"
src="https://github.com/user-attachments/assets/4cbfa4d0-999b-4265-bed0-957958663037"
/>
<img width="1290" height="750" alt="missions-broken-4x1-2"
src="https://github.com/user-attachments/assets/4889b498-d6aa-4e6c-87fc-4dfadeac5827"
/>

Reference (PS2 4:3 in OpenGoal):
<img width="1284" height="768" alt="missions-reference-1"
src="https://github.com/user-attachments/assets/91a526c8-08c2-4a62-8219-09e967fab9c2"
/>
<img width="1276" height="755" alt="missions-reference-2"
src="https://github.com/user-attachments/assets/65c4e944-5b1f-479a-bf7c-eca19c81f5d6"
/>


After:
<img width="1281" height="760" alt="missions-fixed-16x9"
src="https://github.com/user-attachments/assets/a972daf0-1872-46f0-a829-cd8d292df1d6"
/>
<img width="1282" height="750" alt="missions-fixed-16x9-2"
src="https://github.com/user-attachments/assets/973611d6-a72c-43f8-b2f3-034e83f6c416"
/>
<img width="1289" height="760" alt="missions-alignment-fixed-4x1"
src="https://github.com/user-attachments/assets/699c5dbc-8c39-468d-9e14-94007a789e48"
/>
<img width="1281" height="755" alt="missions-alignment-fixed-4x1-2"
src="https://github.com/user-attachments/assets/89216187-d453-4d3e-8e8b-5ae365e7227d"
/>


### Jak 2 

### Secrets menu orb icon
Position was wrong in Automatic and some (but strangely, not all) Custom
Aspect ratios. A correction for the aspect ratio was also being applied
in the setter.

Before:
<img width="1284" height="755" alt="image"
src="https://github.com/user-attachments/assets/0a15e238-1d98-4ba7-86ce-b295e8d78d7a"
/>

After:
<img width="1283" height="755" alt="image"
src="https://github.com/user-attachments/assets/bd97de44-ef41-426c-a76f-d4fe99a35285"
/>

### Missions menu
- Indentation was not working, even in 4:3, due to a typo.
- Width was broken in Automatic and Custom

Before:
<img width="1281" height="753" alt="Screenshot from 2026-08-19 01-05-54"
src="https://github.com/user-attachments/assets/6f5e3cc4-3522-45a5-a45b-34a46a7db544"
/>

After:
<img width="1287" height="761" alt="image"
src="https://github.com/user-attachments/assets/cae5498b-6ca4-40ab-a31c-feb8899bc1e7"
/>
This commit is contained in:
Jordan
2026-08-28 16:42:47 +02:00
committed by GitHub
parent bebfb0cec8
commit 427c952558
9 changed files with 812 additions and 405 deletions
+2 -2
View File
@@ -8831,7 +8831,7 @@
(progress-subtitles #x006e)
(progress-restart-mission #x006f)
(text-0072 #x0072)
(text-0073 #x0073)
(progress-saved-game #x0073)
(progress-qr #x0074)
(text-0075 #x0075)
(text-0076 #x0076)
@@ -28091,7 +28091,7 @@
(draw-bg-box-outline (_type_ progress-box float) object) ;; 41
(draw-bg-box-alpha-2 (_type_ progress-box float) object) ;; 42
(draw-bg-box-alpha-1 (_type_ progress-box float) object) ;; 43
(progress-method-44 (_type_ font-context string) object) ;; 44
(draw-button-text (_type_ font-context string) object) ;; 44
(progress-method-45 (_type_ font-context float float string float float int) float) ;; 45
(draw-header (_type_ font-context float text-id) object) ;; 46
(progress-method-47 (_type_ font-context symbol symbol) object) ;; 47
+13 -14
View File
@@ -9,6 +9,11 @@
|#
(defmacro adjust-x-if-needed (x)
"adjust an x screen coord if ps2 vis is disabled"
`(if (not (-> *pc-settings* use-vis?)) (adjust-game-x (the float ,x)) ,x))
(defun draw-previous-next ((arg0 menu-highscores-option) (arg1 font-context) (arg2 symbol))
(local-vars (sv-16 string) (sv-32 int))
@@ -993,20 +998,16 @@
)
(let ((page-idx (-> obj page-index)))
(cond
((zero? page-idx)
((or (zero? page-idx) (= page-idx 1))
(draw-missions-decoration obj font-ctx font-alpha (text-id progress-root-missions))
)
((= page-idx 1)
(draw-missions-decoration obj font-ctx font-alpha (text-id progress-root-missions))
)
)
)
)
(begin-scissor-missions hud-bounds)
(set-flags! font-ctx (font-flags kerning large))
(if (-> *pc-settings* use-vis?)
(+! (-> font-ctx origin x) 20.0)
(+! (-> font-ctx origin x) (* (-> *pc-settings* aspect-ratio-reciprocal) 20.0)))
(+! (-> font-ctx origin x) 20.0)
(case (get-aspect-ratio)
(('aspect16x9)
(set! (-> font-ctx origin y) 80.0)
@@ -1026,6 +1027,9 @@
(set! (-> font-ctx origin y) (the float (+ y-offset (the int line-height))))
)
(set! (-> font-ctx width) 340.0)
(when (not (-> *pc-settings* use-vis?))
(set! (-> font-ctx width) (- (* (-> font-ctx width) (-> *pc-settings* aspect-ratio-reciprocal) ) 8.0))
)
(set! (-> font-ctx height) 44.0)
(when (!= line-height 0.0)
(set! (-> *progress-state* missions-total-spacing) 0.0)
@@ -1473,9 +1477,9 @@
)
(set! (-> this sprites 0 pos z) #xffffff)
(set! (-> this sprites 0 pos w) 0)
(if (not (-> *pc-settings* use-vis?))
(set-hud-piece-position! (-> this sprites 0) (adjust-game-x 100.0) 128)
(set-hud-piece-position! (-> this sprites 0) 100 128))
;; Fixes orb position in Automatic and other aspect ratios
(set! (-> this sprites 0 pos x) (adjust-x-if-needed 100))
(set! (-> this sprites 0 pos y) 128)
(with-dma-buffer-add-bucket ((s3-0 (-> *display* frames (-> *display* on-screen) global-buf))
(bucket-id progress)
)
@@ -1700,11 +1704,6 @@
)
(defmacro adjust-x-if-needed (x)
"adjust an x screen coord if ps2 vis is disabled"
`(if (not (-> *pc-settings* use-vis?)) (adjust-game-x (the float ,x)) ,x))
(defmethod draw-option ((obj menu-memcard-slot-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol))
(local-vars
(sv-16 float)
@@ -175,7 +175,7 @@
)
;; WARN: Return type mismatch int vs object.
(defmethod progress-method-44 ((this progress) (arg0 font-context) (arg1 string))
(defmethod draw-button-text ((this progress) (arg0 font-context) (arg1 string))
(let ((f0-1 (- 1.0 (-> this menu-transition))))
(set-scale! arg0 0.5)
(set! (-> arg0 alpha) f0-1)
@@ -625,7 +625,7 @@
)
)
)
(progress-method-44 this arg0 sv-20)
(draw-button-text this arg0 sv-20)
(+! (-> arg0 origin y) f30-0)
)
)
@@ -2459,7 +2459,11 @@
(cond
((= (-> s2-0 file arg2 present) 1)
(let ((sv-48 print-game-text))
(format (clear *temp-string*) "~S ~D" (lookup-text! *common-text* (text-id text-0073) #f) (+ arg2 1))
(string-format
"~S ~D"
(lookup-text! *common-text* (text-id progress-saved-game) #f)
(+ arg2 1)
)
(sv-48 *temp-string* arg1 #f 44 (bucket-id hud-draw-hud-alpha))
)
)
@@ -256,7 +256,7 @@
(draw-bg-box-outline (_type_ progress-box float) object)
(draw-bg-box-alpha-2 (_type_ progress-box float) object)
(draw-bg-box-alpha-1 (_type_ progress-box float) object)
(progress-method-44 (_type_ font-context string) object)
(draw-button-text (_type_ font-context string) object)
(progress-method-45 (_type_ font-context float float string float float int) float)
(draw-header (_type_ font-context float text-id) object)
(progress-method-47 (_type_ font-context symbol symbol) object)
+1 -1
View File
@@ -112,7 +112,7 @@
(progress-subtitles #x006e)
(progress-restart-mission #x006f)
(text-0072 #x0072)
(text-0073 #x0073)
(progress-saved-game #x0073)
(progress-qr #x0074)
(text-0075 #x0075)
(text-0076 #x0076)
+193 -161
View File
@@ -411,193 +411,225 @@
(none)
)
(defun print-game-text ((arg0 string) (arg1 font-context) (arg2 symbol) (arg3 int) (arg4 bucket-id))
;; display-text : text to print
;; font-ctx : the font to draw the text with
;; invisible : will actually print the text if true, otherwise will not print
;; arg3: height of text if text is supposed to be large
;; bucket-id: buffer used to draw?
;; Returns the height of the printed text.
(defun print-game-text ((display-text string) (font-ctx font-context) (invisible symbol) (large-font-size int) (bucket-id bucket-id))
(local-vars
(sv-16 float)
(sv-20 float)
(sv-24 font-flags)
(sv-28 font-color)
(sv-32 (pointer uint8))
(sv-36 float)
(sv-40 float)
(sv-44 float)
(sv-48 float)
(sv-52 float)
(sv-56 float)
(sv-64 int)
(sv-72 uint)
(sv-80 int)
(sv-88 int)
(sv-96 int)
(sv-104 uint)
(sv-108 symbol)
(sv-112 int)
(sv-120 int)
(font-origin-x float) ;; Initial x and y position of font context
(font-origin-y float)
(font-flags font-flags)
(font-color font-color)
(cur-ch-ptr (pointer uint8)) ;; Char pointer used to traverse chars of display-text
(font-cur-position float)
(font-origin-x-copy float)
(right-side float) ;; Right boundary of where there is to draw
(bottom-side float) ;; Bottom boundary of where there is to draw
(whitespace-width float) ;; The width of a whitespace char using font-ctx
(line-height float) ;; The height of a line printed with font-ctx
(non-empty-lines int) ;; The number of lines printed so far
(cur-ch uint) ;; Current character inside display-text
(game-word-len int) ;;The current length of game-text-word
(game-line-len int) ;;The current length of game-text-line
(num-lines int)
(next-ch uint) ;;The next character inside display-text
(word-break symbol) ;; True if and only if game-text-word is complete and should be put in game-text-line
(num-lines-to-print int) ;;The number of outstanding lines that still need to be printed.
(game-text-word-width int)
)
(cond
((< 0.1 (-> arg1 scale))
(set! sv-16 (-> arg1 origin x))
(set! sv-20 (-> arg1 origin y))
(set! sv-24 (-> arg1 flags))
(set! sv-28 (-> arg1 color))
(set-context! *font-work* arg1)
(set! (-> arg1 max-x) sv-16)
(when (logtest? (-> arg1 flags) (font-flags middle-vert))
(logclear! (-> arg1 flags) (font-flags middle-vert))
(+! (-> arg1 origin y)
(the float
(the int (* 0.5 (- (-> arg1 height) (print-game-text arg0 arg1 #t 44 (bucket-id hud-draw-hud-alpha)))))
)
)
)
(set! sv-32 (-> arg0 data))
(set! sv-36 (-> arg1 origin x))
(set! sv-40 (-> arg1 origin x))
(set! sv-44 (+ (-> arg1 origin x) (-> arg1 width)))
(set! sv-48 (+ (-> arg1 origin y) (-> arg1 height)))
(set! sv-52 (-> (get-string-length " " arg1) length))
(set! sv-56 (* (if (logtest? (-> arg1 flags) (font-flags large))
(the float arg3)
28.0
)
(-> arg1 scale)
)
)
(set! sv-64 0)
(if (logtest? (-> arg1 flags) (font-flags middle))
(+! (-> arg1 origin x) (/ (-> arg1 width) 2))
)
(set! sv-72 (-> sv-32 0))
(set! sv-80 0)
(set! sv-88 0)
(set! sv-96 0)
(set! sv-104 (-> sv-32 1))
(set! sv-108 (the-as symbol #f))
(set! sv-112 0)
(set! sv-120 0)
(set! (-> *game-text-line* data 0) (the-as uint 0))
(while (and (not (and (zero? sv-72) (zero? sv-80) (zero? sv-88))) (>= sv-48 (-> arg1 origin y)))
(set! sv-120 0)
(set! sv-32 (&-> sv-32 1))
(set! sv-104 (-> sv-32 0))
(set! sv-32 (&-> sv-32 -1))
((< 0.1 (-> font-ctx scale)) ;; Only print if font's scale is greater than 0.1
;;Storing font-ctx properties to restore them later.
(set! font-origin-x (-> font-ctx origin x))
(set! font-origin-y (-> font-ctx origin y))
(set! font-flags (-> font-ctx flags))
(set! font-color (-> font-ctx color))
(set-context! *font-work* font-ctx)
(set! (-> font-ctx max-x) (-> font-ctx origin x))
(when (logtest? (-> font-ctx flags) (font-flags middle-vert)) ;; If middle-vert flag is set,
(logclear! (-> font-ctx flags) (font-flags middle-vert)) ;; Clear the flag
(+! (-> font-ctx origin y) ;; font's y-origin += 0.5 * (font-height - height needed to print display-text)
(the float
(the int (* 0.5 (- (-> font-ctx height) (print-game-text display-text font-ctx #t 44 (bucket-id hud-draw-hud-alpha)))))
)
)
)
(set! cur-ch-ptr (-> display-text data))
(set! font-cur-position (-> font-ctx origin x))
(set! font-origin-x-copy (-> font-ctx origin x))
(set! right-side (+ (-> font-ctx origin x) (-> font-ctx width)))
(set! bottom-side (+ (-> font-ctx origin y) (-> font-ctx height)))
(set! whitespace-width (-> (get-string-length " " font-ctx) length))
;;line-height is set to font-ctx scale * (large-font-size if font-ctx has its large flat set or 28.0)
(set! line-height (* (-> font-ctx scale)
(if (logtest? (-> font-ctx flags) (font-flags large))
(the float large-font-size)
28.0
)
)
)
(set! non-empty-lines 0)
(if (logtest? (-> font-ctx flags) (font-flags middle))
(+! (-> font-ctx origin x) (/ (-> font-ctx width) 2))
)
(set! cur-ch (-> cur-ch-ptr 0))
(set! game-word-len 0)
(set! game-line-len 0)
(set! num-lines 0)
(set! next-ch (-> cur-ch-ptr 1)) ;;Following character in display-text
(set! word-break (the-as symbol #f)) ;;Set to false
(set! num-lines-to-print 0)
(set! game-text-word-width 0)
(set! (-> *game-text-line* data 0) (the-as uint 0)) ;;zero
;; While there are more characters to read from display-text (cur-ch is not \0) into game-text-word,
;; game-text-word hasn't been written to game-text-line or game-text-line hasn't been printed
;; and the font context's vertical position isn't below the bottom of the drawing context.
(while (and (not (and (zero? cur-ch) (zero? game-word-len) (zero? game-line-len))) (>= bottom-side (-> font-ctx origin y)))
(set! game-text-word-width 0)
;; (set! cur-ch-ptr (&-> cur-ch-ptr 1))
;; (set! next-ch (-> cur-ch-ptr 0))
;; (set! cur-ch-ptr (&-> cur-ch-ptr -1))
(set! next-ch (-> cur-ch-ptr 1))
(cond
((and (> sv-72 0) (< sv-72 (the-as uint 4)))
(set! (-> *game-text-word* data sv-80) sv-72)
(set! sv-80 (+ sv-80 1))
(set! (-> *game-text-word* data sv-80) sv-104)
(set! sv-80 (+ sv-80 1))
(set! sv-32 (&-> sv-32 1))
;; 0 < current character < 4
((and (> cur-ch 0) (< cur-ch (the-as uint 4)))
;; Copy current and next character from display text into game-text-word
(set! (-> *game-text-word* data game-word-len) cur-ch)
(set! game-word-len (+ game-word-len 1))
(set! (-> *game-text-word* data game-word-len) next-ch)
(set! game-word-len (+ game-word-len 1))
(set! cur-ch-ptr (&-> cur-ch-ptr 1)) ;; Increment pointer within display-text
)
((or (= sv-72 32) (= sv-72 47) (and (= sv-72 45) (!= (-> sv-32 -1) 126)))
(set! (-> *game-text-word* data sv-80) sv-72)
(set! sv-80 (+ sv-80 1))
(set! sv-108 #t)
;; Current character is a space or forward slash, or it's a minus and previous was a tilde.
;; Might need to check that cur-ch-ptr - 1 is not out of bounds?
((or (= cur-ch #\\s) (= cur-ch #\/) (and (= cur-ch #\-) (!= (-> cur-ch-ptr -1) #\~)))
(set! (-> *game-text-word* data game-word-len) cur-ch) ;;Write the character into the word
(set! game-word-len (+ game-word-len 1))
(set! word-break #t) ;; Should copy current game-text-word into game-text-line
)
((zero? sv-72)
(if (nonzero? sv-80)
(set! sv-108 #t)
)
(set! sv-112 (+ sv-112 1))
;; Current character is 0
((zero? cur-ch)
(if (nonzero? game-word-len) ;;If game-text-word not empty
(set! word-break #t) ;; Should copy current game-text-word into game-text-line
)
(set! num-lines-to-print (+ num-lines-to-print 1))
)
((and (= sv-72 92) (= sv-104 92))
(set! sv-32 (&-> sv-32 1))
(if (nonzero? sv-80)
(set! sv-108 #t)
)
(set! sv-112 (+ sv-112 1))
;; Both current character and next are backslashes
((and (= cur-ch #\\) (= next-ch #\\))
(set! cur-ch-ptr (&-> cur-ch-ptr 1)) ;; Increment pointer within display-text
(if (nonzero? game-word-len)
(set! word-break #t) ;; Should copy current game-text-word into game-text-line
)
(set! num-lines-to-print (+ num-lines-to-print 1))
)
((and (= sv-72 95) (= sv-104 95))
(set! sv-32 (&-> sv-32 1))
(set! (-> *game-text-word* data sv-80) (the-as uint 32))
(set! sv-80 (+ sv-80 1))
;; Current character and next are underscores
((and (= cur-ch #\_) (= next-ch #\_))
(set! cur-ch-ptr (&-> cur-ch-ptr 1)) ;; Increment pointer within display-text
(set! (-> *game-text-word* data game-word-len) #\\s) ;;Write a space into the word
(set! game-word-len (+ game-word-len 1))
)
(else ;;Write character into word and increment word length
(set! (-> *game-text-word* data game-word-len) cur-ch)
(set! game-word-len (+ game-word-len 1))
)
(else
(set! (-> *game-text-word* data sv-80) sv-72)
(set! sv-80 (+ sv-80 1))
)
)
(when sv-108
(set! (-> *game-text-word* data sv-80) (the-as uint 0))
(let ((f30-1 sv-36))
(set! sv-120 (the int (-> (get-string-length *game-text-word* arg1) length)))
(let ((f0-27 (+ f30-1 (the float sv-120))))
(if (= (-> *game-text-word* data (+ sv-80 -1)) 32)
(set! f0-27 (- f0-27 sv-52))
(when word-break
(set! (-> *game-text-word* data game-word-len) (the-as uint 0)) ;;Null terminate word
(let ((word-start font-cur-position))
;;Set game-text-word-width to the length of game-text-word using font-ctx
(set! game-text-word-width (the int (-> (get-string-length *game-text-word* font-ctx) length)))
(let ((word-end (+ word-start (the float game-text-word-width))))
(if (= (-> *game-text-word* data (+ game-word-len -1)) #\\s) ;; If last character is a space
(set! word-end (- word-end whitespace-width))
)
(cond
((< sv-44 f0-27)
(set! (-> arg1 max-x) (fmax (-> arg1 max-x) sv-36))
(set! sv-112 (+ sv-112 1))
((< right-side word-end) ;; If word would exceed right side of screen,
(set! (-> font-ctx max-x) (fmax (-> font-ctx max-x) font-cur-position))
(set! num-lines-to-print (+ num-lines-to-print 1))
)
(else
;;Append game-word to the end of game-line
(copy-charp<-charp (&-> *game-text-line* data game-line-len) (-> *game-text-word* data))
(set! game-line-len (+ game-line-len game-word-len))
(set! game-word-len 0)
(set! font-cur-position (+ font-cur-position (the float game-text-word-width))) ;; Add the word width to font-cur-position
(set! (-> font-ctx max-x) (fmax (-> font-ctx max-x) font-cur-position))
(set! word-break (the-as symbol #f))
)
(else
(copy-charp<-charp (&-> *game-text-line* data sv-88) (-> *game-text-word* data))
(set! sv-88 (+ sv-88 sv-80))
(set! sv-80 0)
(set! sv-36 (+ sv-36 (the float sv-120)))
(set! (-> arg1 max-x) (fmax (-> arg1 max-x) sv-36))
(set! sv-108 (the-as symbol #f))
)
)
)
)
)
(while (> sv-112 0)
(let ((f30-2 (+ (-> arg1 origin y) sv-56)))
(when (and (>= sv-96 (the-as int (-> arg1 start-line))) #t)
(when (= (-> *game-text-line* data (+ sv-88 -1)) 32)
(set! (-> *game-text-line* data (+ sv-88 -1)) (the-as uint 0))
(while (> num-lines-to-print 0)
;; Store the position of the current line + line-height
(let ((next-line-origin-y (+ (-> font-ctx origin y) line-height)))
;;Note: for now it seems like font-ctx start-line is always 0.
(when (>= num-lines (the-as int (-> font-ctx start-line)))
;; If game-text-line ends in a space, replace the space with 0
;; (should probably decrement length too??)
(when (= (-> *game-text-line* data (+ game-line-len -1)) #\\s)
(set! (-> *game-text-line* data (+ game-line-len -1)) (the-as uint 0))
0
)
(if (nonzero? (-> *game-text-line* data 0))
(set! sv-64 (+ sv-64 1))
)
(when (not arg2)
(with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf))
arg4
)
;;Actually print the text onscreen if the text is not meant to be invisible.
(when (not invisible)
(with-dma-buffer-add-bucket ((s2-1 (-> *display* frames (-> *display* on-screen) global-buf))
bucket-id
)
(draw-string *game-text-line* s2-1 arg1)
(draw-string *game-text-line* s2-1 font-ctx)
)
)
(set! (-> arg1 origin y) f30-2)
)
)
(set! sv-96 (+ sv-96 1))
(set! (-> *game-text-line* data 0) (the-as uint 0))
(set! sv-88 0)
(set! sv-112 (+ sv-112 -1))
(set! sv-36 sv-40)
(when sv-108
(copy-charp<-charp (&-> *game-text-line* data sv-88) (-> *game-text-word* data))
(set! sv-88 (+ sv-88 sv-80))
(set! sv-80 0)
(set! sv-108 (the-as symbol #f))
(set! sv-36 (+ sv-36 (the float sv-120)))
)
)
(when (nonzero? sv-72)
(set! sv-32 (&-> sv-32 1))
(set! sv-72 (-> sv-32 0))
)
)
(set! (-> arg1 origin x) sv-16)
(set! (-> arg1 origin y) sv-20)
(set! (-> arg1 flags) sv-24)
(set! (-> arg1 color) sv-28)
)
(if (nonzero? (-> *game-text-line* data 0))
(set! non-empty-lines (+ non-empty-lines 1)) ;; Increment non-empty lines "printed"
)
;; Update the font-context to be positioned after the previous line
(set! (-> font-ctx origin y) next-line-origin-y)
)
)
(set! num-lines (+ num-lines 1))
(set! (-> *game-text-line* data 0) (the-as uint 0))
(set! game-line-len 0)
(set! num-lines-to-print (+ num-lines-to-print -1))
(set! font-cur-position font-origin-x-copy)
(when word-break
;;Copy game-text-word to the end of game-text-line
(copy-charp<-charp (&-> *game-text-line* data game-line-len) (-> *game-text-word* data))
(set! game-line-len (+ game-line-len game-word-len))
(set! game-word-len 0)
(set! word-break (the-as symbol #f)) ;; Reset
(set! font-cur-position (+ font-cur-position (the float game-text-word-width))) ;; Add word width to current position
)
)
(when (nonzero? cur-ch)
(set! cur-ch-ptr (&-> cur-ch-ptr 1))
(set! cur-ch (-> cur-ch-ptr 0))
)
)
;; Restore font-ctx properties.
(set! (-> font-ctx origin x) font-origin-x)
(set! (-> font-ctx origin y) font-origin-y)
(set! (-> font-ctx flags) font-flags)
(set! (-> font-ctx color) font-color)
;; og:preserve-this
(#when PC_PORT
(if (and *debug-segment* *display-text-box*)
(draw-debug-text-box arg1)))
(if (> sv-64 0)
(* sv-56 (the float sv-64))
0.0
)
)
(else
0.0
(draw-debug-text-box font-ctx)))
;;
(if (> non-empty-lines 0)
(* line-height (the float non-empty-lines))
0.0
)
)
(else
0.0
)
)
)
(defun disable-level-text-file-loading ()
(set! *level-text-file-load-flag* #f)
File diff suppressed because it is too large Load Diff
+8 -3
View File
@@ -176,7 +176,7 @@
;; definition for method 44 of type progress
;; WARN: Return type mismatch int vs object.
(defmethod progress-method-44 ((this progress) (arg0 font-context) (arg1 string))
(defmethod draw-button-text ((this progress) (arg0 font-context) (arg1 string))
(let ((f0-1 (- 1.0 (-> this menu-transition))))
(set-scale! arg0 0.5)
(set! (-> arg0 alpha) f0-1)
@@ -637,7 +637,7 @@
)
)
)
(progress-method-44 this arg0 sv-20)
(draw-button-text this arg0 sv-20)
(+! (-> arg0 origin y) f30-0)
)
)
@@ -2565,7 +2565,12 @@
(cond
((= (-> s2-0 file arg2 present) 1)
(let ((sv-48 print-game-text))
(format (clear *temp-string*) "~S ~D" (lookup-text! *common-text* (text-id text-0073) #f) (+ arg2 1))
(format
(clear *temp-string*)
"~S ~D"
(lookup-text! *common-text* (text-id progress-saved-game) #f)
(+ arg2 1)
)
(sv-48 *temp-string* arg1 #f 44 (bucket-id hud-draw-hud-alpha))
)
)
+1 -1
View File
@@ -149,7 +149,7 @@
(draw-bg-box-outline (_type_ progress-box float) object)
(draw-bg-box-alpha-2 (_type_ progress-box float) object)
(draw-bg-box-alpha-1 (_type_ progress-box float) object)
(progress-method-44 (_type_ font-context string) object)
(draw-button-text (_type_ font-context string) object)
(progress-method-45 (_type_ font-context float float string float float int) float)
(draw-header (_type_ font-context float text-id) object)
(progress-method-47 (_type_ font-context symbol symbol) object)