Difference between revisions of "Callback: Additional text in purchase screen"

From GRFSpecs
Jump to navigationJump to search
(six registers instead of four)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Additional text in purchase screen (23) ==
 
== Additional text in purchase screen (23) ==
   
This callback is called when TTDPatch displays the vehicle stats of any vehicle in its purchase screen. The return value is the "xx" of a D0xx text ID to be shown below all other stats. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it. As of r1908, text IDs D100..D3FF may also be returned.
+
This callback can be used to append text below the vehicle information in the purchase screen. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.
   
  +
{|
How many lines are available depends on the type of vehicle and its other properties, for instance the presence or absence of a "refittable to" line or powered wagons etc. Lines are wrapped automatically, or may be broken explicitly using the newline character 0D.
 
  +
|-
  +
!Return value!!Version!!Meaning
  +
|-
  +
|0000..03FF|| ||D0xx text to display. {{ttdp|}} Before r1908 only text IDs D000..D0FF were supported.
  +
|-
  +
|0400||{{grfFrom|8}}||Display no text (same as callback failure).
  +
|-
  +
|040F||{{ottdp|15|no}}||Display text using text ID from register 0x100 (not limited to D0xx texts). The text stack starts at register 0x101.
  +
|}
  +
 
{{ottdp|1.2-14|no|ottdrev=r23045}} Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.
  +
  +
{{ottdp|15|no}} The contents of registers 100h..10Fh are copied onto the text reference stack.
  +
 
Lines are wrapped automatically, or may be broken explicitly using the newline character 0D. How many lines are available depends on the type of vehicle and its other properties, for instance the presence or absence of a "refittable to" line or powered wagons etc.
   
 
If cargo FF (buy menu sprite) is handled explicitly for a vehicle, then the varaction 2 handling [[Callbacks#Additional text in purchase screen (23) |callback 23]] must be in the buy menu varaction 2 chain.
 
If cargo FF (buy menu sprite) is handled explicitly for a vehicle, then the varaction 2 handling [[Callbacks#Additional text in purchase screen (23) |callback 23]] must be in the buy menu varaction 2 chain.
   
  +
{{ottdp|1.2|no|ottdrev=r23045}} Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.
 
  +
Example for setting additional text for a road vehicle:
  +
  +
// Define string with ID D001 for featur 01. Bit 7 of the language byte must be set to 1, because the string ID is a word.
  +
4 * 32 04 01 83 01 \wxD001 "Hint: This is a " 0D "new line." 00
  +
// The callback
  +
5 * 14 02 01 10 85 0C 00 \wxFFFF 01 \wx8001 \wx23 \wx23 02 00
   
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 14:12, 13 May 2025

Additional text in purchase screen (23)

This callback can be used to append text below the vehicle information in the purchase screen. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.

Return value Version Meaning
0000..03FF D0xx text to display. Supported by TTDPatch Before r1908 only text IDs D000..D0FF were supported.
0400 GRFv≥8 Display no text (same as callback failure).
040F Supported by OpenTTD 1515 Not supported by TTDPatch Display text using text ID from register 0x100 (not limited to D0xx texts). The text stack starts at register 0x101.

Supported by OpenTTD 1.2-14 (r23045)1.2-14 Not supported by TTDPatch Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.

Supported by OpenTTD 1515 Not supported by TTDPatch The contents of registers 100h..10Fh are copied onto the text reference stack.

Lines are wrapped automatically, or may be broken explicitly using the newline character 0D. How many lines are available depends on the type of vehicle and its other properties, for instance the presence or absence of a "refittable to" line or powered wagons etc.

If cargo FF (buy menu sprite) is handled explicitly for a vehicle, then the varaction 2 handling callback 23 must be in the buy menu varaction 2 chain.


Example for setting additional text for a road vehicle:

// Define string with ID D001 for featur 01. Bit 7 of the language byte must be set to 1, because the string ID is a word.
4 * 32 04 01 83 01 \wxD001 "Hint: This is a " 0D "new line." 00
// The callback
5 * 14 02 01 10 85 0C 00 \wxFFFF 01 \wx8001 \wx23 \wx23 02 00