Files
oboe/osx/dialogxml/dialog-converting.txt
Celtic Minstrel c413d292a9 Tear out most of the legacy code in the game - see below for details
(PC Editor and Scenario Editor are unaffected by this commit.)

Things removed:
- All references to Carbon and QuickDraw are gone.
- No more Resource Manager; the game no longer relies on old resource files at all
- The old dialog framework (from dlogtool.c, functions usually prefixed with cd_) is no longer used.
- Files that weren't being compiled
- Boost libraries that are now in the C++ library (function, shared_ptr)
- Obsolete build settings

Replacement dependencies:
- Boost Filesystem replaces references to things like FSSpec
- SFML replaces all the QuickDraw code and most window management
- Cocoa replaces AppleEvent management, menu management, and some window management
- I wrote a resource manager interface to mimick the important aspects of the behaviour of the Mac Resource Manager
- I had to rewrite some functions that QuickDraw provided natively, such as clipping regions; not all of these are tested

Things added:
- Every referenced dialog has been converted from a DITL resource into the new XML-based dialog format.
- All referenced STR# resources have been extracted into simple text files
- Now compiles against Mac OSX 10.7 SDK and libc++
- The first item in the Help menu opens the docs on Sylae's website
- It seems all the constants for soundtool vanished somewhere, so I added them back from the original Mac source

Other changes:
- Updated to XCode 4(?) project format
- Added the xcschemes created by XCode 4; I'm not sure how important these are, but they seem like they might be important
- Added document on converting dialogs to the XML format.
- Make string formatting mismatches into errors instead of warnings
- Disable error limit
- Graphics sheets that previously used masking now have alpha transparency
- Converted all graphics sheets to 8-bit PNG
- Trimmed white border from intro image
- Converted dialogs in the resource file have their resource name set to the name of the XML file of the converted version
- Referenced string resources in the resource file have their resource name set to the name of the text file of the extracted version
- Add the black-and-white patterns from the PAT resources to the pixpats.png; at least one of them is used somewhere in the game
- Recreated the menu.xib as a Cocoa xib file instead of a Carbon xib file
- Disable GNU C++ extensions; maybe this'll make it easier to compile with cl.exe later
- Add marks to the enormous handle_action function to make it easier to navigate\
- A build step to validate the XML dialogs using xmllint (doesn't quite work properly yet but does at least catch dialogs that are not well-formed)- Fix a lot of warnings about assigning string constants to non-const char pointers
- Fixed the file and application icons (which had somehow become corrupted at some point)
- Lots of additional functions in the custom location and rectangle classes, including implicit conversion to and from SFML rects and vectors; also they now store coordinates as int instead of char
- A new enum for encounter note types
- Much tweaking of the encounter note recording mechanisms
- To ease porting, I added a simple function that converts from classic Mac ticks (about 1/60 of a second) to the SFML time type
- Python script to convert STR# resources to txt files, replacing newlines with vertical bars
- Extracted the Mac font (Dungeon Bold) from the resource file and also added the Windows font (MaidenWord)

XML Dialog Framework changes:
- Remove the static initialization object in favour of manually calling cDialog::init()
- {set,get}Format() no longer used for colour; there's a dedicated {set,get}Colour() instead
- draw() methods unprotected in the control classes so that controls can be drawn in the main window
- There's no longer a friend relationship between the dialogs and the controls
- Fixed buttons duplicating the "depressed" boolean
- Buttons now properly offset the label for tiny and push buttons, and for LEDs
- Buttons no longer assume that either none or both of "width" and "height" are given in the XML
- Add {get,set}BtnType() to cButton
- cLedGroup now overrides handleClick(), which has also been made virtual; this was necessary for LEDs within a group to properly hilite while being clicked
- Add addChoice() to cLedGroup to insert additional LED choices
- Moved the key enums and cKey to a separate file
- Add a method to get a control's attached key
- Add methods to get and set a control's rect and position
- Controls can now directly take a window as a parent rather than a dialog
- Add addLabelFor() method to cDialog which adds a static text control as a label for another control
- Remove hack for storing a dialog result of arbitrary type in favour of boost::any
- Add method to get default text colour for a dialog
- Add method to get a dialog's rect
- Add method to add the same event handler to multiple controls in a dialog
- Add concept of default button to dialogs
- Add enum for text field type (currently either number or text)
- Implement the text field without use of native controls, including somewhat decent text input and a flashing insertion point
- cPict no longer stores references to every sheet; it fetches them as needed from the resource manager
- The many draw functions in cPict are no longer static, since they need to access the window containing the pict (before they could only be static due to QuickDraw's global state)
- Add setPict() without a type argument to change the graphic without changing the type, which is a common operation
- Add a scrollbar control; the specifics aren't implemented yet
- Change signature of the record callback for cStrDlog; it will no longer be passed the strings
- Publicize the no-button constructor of cChoiceDlog; it'll assume "okay" is the only button
- Add operator-> to cPictChoice for accessing the underlying dialog
- Add constructor to cPictChoice that takes a starting and ending pic num
- Remove err parameter from giveError
- Many more keys handled, plus support for catching copy, paste, cut, and select all keyboard shortcuts
- Text input fields take priority, overriding any other keyboard shortcuts in the dialog, but they never catch help (F1), escape, or enter
- Some changes to the format itself:
-> keys go in the "def-key" attribute, but modifiers go in "key-mod"
-> "clickable" is no longer a recognized attribute
-> "title" is now a recognized text size (18pt, even larger than "large" at 12pt)
-> "defbtn" attribute on the root element
2014-04-14 13:52:01 -04:00

100 lines
4.6 KiB
Plaintext

The old dialogs are represented as DITL resource (technically a DLOG resource, but the DITL contains all the important stuff). All items in the DITL resource are either static text or editable text fields.
The static text entries have magic characters in them to specify their purpose. An empty static text is equivalent to one consisting solely of the character "+".
Actual text entries are anything that doesn't begin with a digit. (The original code actually requires them to begin with [A-z"] or a formatting character.) They may begin with any of the following characters to represent formatting:
type flag meaning
+ 3 1 white Geneva bold 10pt framed
* 3 0 white Geneva bold 10pt
~ 7 0 white Geneva bold 12pt
! 4 0 white Geneva plain 10pt
= 9 1 same as 3,1, but text wraps
9 0 same as 3,0, but text wraps
^ 10 1 or 2 -- note, this type would never be reached by the original code
& 11 1 or 2
For ^ or &, flag=2 if string_length > 55. I think string_length is pixel length, not character length. These are buttons, not text, so the upshot is that longer text is automatically put on a larger button.
All other entries are of the form %d_%d, ie two numbers separated by an underscore. The first number is the type, and the second is the flag.
Item types 0, 1, 10, 11 are buttons. I think 10 and 11 are buttons with arbitrary text, while 0 and 1 are predefined buttons. The flag is the button style. There seems to be no difference whatsoever between 0 and 1 or between 10 and 11, but I think the intention was that 1 and 11 function as the "default button", meaning pressing enter selects them. The button styles are:
0 = small
1 = regular
2 = large
3 = white help button with ? on it
4 = left arrow
5 = right arrow
6 = up arrow
7 = down arrow
8 = LED indicator (probably unused?)
9 = LED on (probably unused?)
10 = LED off (probably unused?)
11 = Done
12 = tall
13 = Race Good/Bad Traits
14 = Round red push button (unused?)
If a button has a flag of 143, no button graphic is drawn, but the label is, so this would make clickable text (ie hyperlinks).
Item type 2 is an LED button. The flag specifies its state:
0 = black (off)
1 = red
2 = green
for. If the flag is 0 it uses button type 10 (BTN_TALL), while if the flag is 1 or 2 it uses button type 9 (BTN_DONE). It looks like flag 1 always uses the pressed state. (Oh, maybe this is an LED?)
Item types 3, 4, 7, 8, and 9 are text. They are formatted as follows:
3 = Geneva bold 10pt, line height 12
4 = Geneva plain 10pt, line height 12
7 = Geneva bold 12pt, line height 14
8 = Dungeon plain 18pt, line height 12? (only used for one dialog)
9 = Geneva bold 10pt, line height 12
(Note, I have substituted Silom for Geneva bold.)
The flag is interpreted as follows:
0 = White, no frame
1 = White, framed
10 = Red, no frame
11 = Red, framed
However, type 8 is never red; it appears to be clickable, and can even have a key equivalent. Also notice that 9 and 3 are in fact identical.
Item type 6 is processed when creating a new window and then never again touched. I think it might be a clickable area.
Item type 5 is a graphic. The flag specifies which graphic to draw, according to the following table:
-1 solid black
0 + x number of terrain graphic
300 + x animated terrain graphic (grabs the first frame only)
400 + x monster graphic num
700 + x dlog graphic (large dlog graphics were done by using four of these arranged in the correct way)
800 + x pc graphic
900 + x B&W graphic - the PICT resource for this does not exist
950 null item
1000 + x Talking face
1100 item info help
1200 pc screen help
1300 combat ap
1400-1402 button help
1410-1412 large scen graphics
1500 stat symbols help
1600 + x scen graphics
1700 + x anim graphic -- drawn from fields_gworld, so a boom or barrier icon?
1800 + x items
2000 + x custom graphics up to 2399
2400 + x custom graphics up to 2799, BUT it's a split graphic ...
it looks at the size of rect, and places a 32 x 32 or 36 x 36 graphic drawn
from the custom gworld, depending on the size of rect. half of graphic is
drawn from one custom slot, and half is drawn from next one.
+3000 suppress drawing a frame around the graphic
Item types 12+ are unused.
Dialog ID 1098 has some special stuff done by draw_pc_effects for item_nums 18...23. It looks like this is status effects in the spellcasting window.
Hotkeys can be attached to buttons (types 0, 1, 2) and, for some reason, to type 8.
Label flags for cd_add_label are of the form xyzz, where:
- x is 0 for Geneva plain, 1 for bold
- y is 0 for left, 1 for above, 2 for right, 3 for below
- zz specifies the distance of the label from its control, in multiples of 2 pixels