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

From GRFSpecs
Jump to navigationJump to search
(use new grf templates)
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.
   
  +
A text string for feature 48 in the D0XX range must be defined before using this callback. Line breaks (0D) and colors are supported. The return value of this callback is the XX of a D0XX string ID.
{{grfFrom|8}} For GRF version 8 and above you can return 400 to display no text (instead of failing the callback).
 
   
  +
As of r1908, text IDs D100..D3FF may also be returned.
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.
 
  +
 
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.
  +
  +
  +
Example for setting additional text for a road vehicle:
  +
  +
// Define string with ID D001. Bit 7 of the language byte must be set to 1, because the string ID is a word.
  +
4 * 32 04 48 83 01 01 D0 "Hint: This is a " 0D "new line." 00
  +
// The callback
  +
5 * 14 02 01 10 81 0C 00 FF 01 01 80 23 23 02 00
  +
 
{{grfFrom|8}} Since GRF version 8 the value 400 can be returned to display no text. In older versions it is necessary to fail the callback.
   
 
{{ottdp|1.2|no|ottdrev=r23045}} Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.
 
{{ottdp|1.2|no|ottdrev=r23045}} Since OpenTTD r23045 the contents of registers 100h..105h are copied onto the text reference stack.

Revision as of 18:03, 16 October 2013

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.

A text string for feature 48 in the D0XX range must be defined before using this callback. Line breaks (0D) and colors are supported. The return value of this callback is the XX of a D0XX string ID.

As of r1908, text IDs D100..D3FF may also be returned.

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. Bit 7 of the language byte must be set to 1, because the string ID is a word.
4 * 32 04 48 83 01 01 D0 "Hint: This is a " 0D "new line." 00
// The callback
5 * 14 02 01 10 81 0C 00 FF 01 01 80 23 23 02 00

GRFv≥8 Since GRF version 8 the value 400 can be returned to display no text. In older versions it is necessary to fail the callback.

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