Files
oboe/osx/dialogxml/pict.h
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

171 lines
7.3 KiB
C++

/*
* pict.h
* BoE
*
* Created by Celtic Minstrel on 11/05/09.
*
*/
#ifndef PICT_H
#define PICT_H
#include <SFML/Graphics.hpp>
#include <vector>
#include <map>
#include "graphtool.h" // for pic_num_t
#include "control.h"
enum ePicType {
PIC_TER = 1, // 28x36 terrain graphic from the preset sheets
PIC_TER_ANIM = 2, // 28x36 terrain graphic from the preset animated terrain sheet
PIC_MONST = 3, // 28x36 monster graphic from the preset sheets
PIC_DLOG = 4, // 36x36 dialog graphic from the preset sheet
PIC_TALK = 5, // 32x32 talking portrait from the preset sheet
PIC_SCEN = 6, // 32x32 scenario graphic from the scenario sheet
PIC_ITEM = 7, // 28x36 item graphic from the large item sheet, or 18x18 item graphic from the small sheet centred in a 28x36 space
PIC_PC = 8, // 28x36 pc graphic from the player sheet
PIC_FIELD = 9, // 28x36 field graphic from the fields sheet
PIC_BOOM = 10, // 28x36 boom graphic from the booms sheet
PIC_FULL = 11, // entire sheet graphic; number is the resource ID
PIC_MISSILE = 12, // 18x18 missile graphic from the missiles sheet
PIC_DLOG_LG = 13, // 72x72 dialog graphic from the dialog sheet
PIC_SCEN_LG = 14, // 64x64 scenario graphic (currently each is on its own sheet)
PIC_TER_MAP = 15, // 12x12 map graphic... or should it be 6x6?
PIC_STATUS = 16, // 12x12 status icon
PIC_MONST_WIDE = 23, // 56x36 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space
PIC_MONST_TALL = 43, // 28x72 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space
PIC_MONST_LG = 63, // 56x72 monster graphic from the preset sheets, resized to fit in a 28x36 space
PIC_CUSTOM_TER = 101, // 28x36 custom graphic from the custom sheets
PIC_CUSTOM_TER_ANIM = 102,
PIC_CUSTOM_MONST = 103,
PIC_CUSTOM_DLOG = 104, // 36x36 dialog graphic drawn from two 18x26 halves in the custom sheets
PIC_CUSTOM_TALK = 105, // 32x32 talking portrait drawn from two 16x32 halves in the custom sheets
PIC_CUSTOM_SCEN = 106, // 32x32 scenario portrait loading from scenname.exr/scenario.png
PIC_CUSTOM_ITEM = 107,
PIC_CUSTOM_FULL = 111, // entire sheet graphic, drawn from scenname.exr/sheetxxx.png where xxx is the number
PIC_CUSTOM_MISSILE = 112, // 18x18 missile graphic drawn from the the custom sheets
PIC_CUSTOM_DLOG_LG = 113, // 72x72 dialog graphic from the custom sheet, taken from 8 successive slots
PIC_CUSTOM_TER_MAP = 115, // 12x12 map graphic (should it be 6x6?) taken from the custom sheet
PIC_CUSTOM_MONST_WIDE = 123, // 56x36 monster graphic from the custom sheets, resized to fit and centred in a 28x36 space
PIC_CUSTOM_MONST_TALL = 143, // 28x72 monster graphic from the custom sheets, resized to fit and centred in a 28x36 space
PIC_CUSTOM_MONST_LG = 163, // 56x72 monster graphic from the custom sheets, resized to fit in a 28x36 space
PIC_PARTY_MONST = 203, // 28x36 graphic drawn from the savegame sheet
PIC_PARTY_SCEN = 206, // 32x32 graphic drawn from the scenario headers sheet
PIC_PARTY_ITEM = 207,
PIC_PARTY_PC = 208,
PIC_PARTY_MONST_WIDE = 223, // 56x36 monster graphic from the savegame sheet, resized to fit and centred in a 28x36 space
PIC_PARTY_MONST_TALL = 243, // 28x72 monster graphic from the savegame sheet, resized to fit and centred in a 28x36 space
PIC_PARTY_MONST_LG = 263, // 56x72 monster graphic from the savegame sheet, resized to fit in a 28x36 space
NUM_PIC_TYPES
};
enum ePicTypeMod {
// Can be added to or subtracted from ePicType enums, returning an ePicType.
PIC_PRESET = 0, // just for good measure
PIC_WIDE = 20, // if applied to any derivative of PIC_MONST, makes the x-dimension 2 instead of 1
PIC_TALL = 40, // if applied to any derivative of PIC_MONST, makes the y-dimension 2 instead of 1
PIC_CUSTOM = 100, // if applied to any customizable graphic, makes it custom instead of preset
PIC_PARTY = 200, // similar to above
};
enum eSheetType {
SHEET_TER,
SHEET_TER_ANIM,
SHEET_MONST,
SHEET_DLOG,
SHEET_TALK,
SHEET_SCEN,
SHEET_SCEN_LG,
SHEET_ITEM,
SHEET_TINY_ITEM,
SHEET_PC,
SHEET_FIELD,
SHEET_BOOM,
SHEET_MISSILE,
SHEET_PARTY,
SHEET_HEADER,
SHEET_TER_MAP,
SHEET_FULL,
SHEET_STATUS,
SHEET_CUSTOM,
NUM_SHEET_TYPES
};
class cPict : public cControl {
public:
static void init();
void attachClickHandler(click_callback_t f) throw();
void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported);
bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, location where);
void setFormat(eFormat prop, short val) throw(xUnsupportedProp);
short getFormat(eFormat prop) throw(xUnsupportedProp);
void setColour(sf::Color clr) throw(xUnsupportedProp);
sf::Color getColour() throw(xUnsupportedProp);
void setPict(pic_num_t num, ePicType type);
void setPict(pic_num_t num);
pic_num_t getPicNum();
ePicType getPicType();
explicit cPict(cDialog& parent);
explicit cPict(sf::RenderWindow& parent);
bool isClickable();
static void advanceAnim();
virtual ~cPict();
void draw();
private:
static std::shared_ptr<sf::Texture> getSheet(eSheetType type, size_t n = 0);
static short animFrame;
short picNum;
ePicType picType;
bool clickable, drawFramed;
void drawPresetTer(short num, RECT to_rect);
void drawPresetTerAnim(short num, RECT to_rect);
void drawPresetMonstSm(short num, RECT to_rect);
void drawPresetMonstWide(short num, RECT to_rect);
void drawPresetMonstTall(short num, RECT to_rect);
void drawPresetMonstLg(short num, RECT to_rect);
void drawPresetDlog(short num, RECT to_rect);
void drawPresetDlogLg(short num, RECT to_rect);
void drawPresetTalk(short num, RECT to_rect);
void drawPresetScen(short num, RECT to_rect);
void drawPresetScenLg(short num, RECT to_rect);
void drawPresetItem(short num, RECT to_rect);
void drawPresetPc(short num, RECT to_rect);
void drawPresetField(short num, RECT to_rect);
void drawPresetBoom(short num, RECT to_rect);
void drawPresetMissile(short num, RECT to_rect);
void drawPresetTerMap(short num, RECT to_rect);
void drawStatusIcon(short num, RECT to_rect);
void drawFullSheet(short num, RECT to_rect);
void drawCustomTer(short num, RECT to_rect);
void drawCustomTerAnim(short num, RECT to_rect);
void drawCustomMonstSm(short num, RECT to_rect);
void drawCustomMonstWide(short num, RECT to_rect);
void drawCustomMonstTall(short num, RECT to_rect);
void drawCustomMonstLg(short num, RECT to_rect);
void drawCustomDlog(short num, RECT to_rect);
void drawCustomDlogLg(short num, RECT to_rect);
void drawCustomTalk(short num, RECT to_rect);
void drawCustomItem(short num, RECT to_rect);
void drawCustomMissile(short num, RECT to_rect);
void drawCustomTerMap(short num, RECT to_rect);
void drawPartyMonstSm(short num, RECT to_rect);
void drawPartyMonstWide(short num, RECT to_rect);
void drawPartyMonstTall(short num, RECT to_rect);
void drawPartyMonstLg(short num, RECT to_rect);
void drawPartyScen(short num, RECT to_rect);
void drawPartyItem(short num, RECT to_rect);
void drawPartyPc(short num, RECT to_rect);
static std::map<ePicType,void(cPict::*)(short,RECT)>& drawPict();
click_callback_t onClick;
};
ePicType operator + (ePicType lhs, ePicTypeMod rhs);
ePicType operator - (ePicType lhs, ePicTypeMod rhs);
ePicType operator + (ePicTypeMod lhs, ePicType rhs);
ePicType operator - (ePicTypeMod lhs, ePicType rhs);
ePicType&operator +=(ePicType&lhs, ePicTypeMod rhs);
ePicType&operator -=(ePicType&lhs, ePicTypeMod rhs);
#endif