- Added some of the most basic dialogs - Changed C-style <xxx.h> headers to C++-style <cxxx> headers - Switched graphics to load from the PNG files in graphics.exd rather than from Blades of Exile Graphics (NOTE: Some graphics still don't work, probably because of incorrect source rects) - Switched cursors to load from GIF files in graphics.exd rather than from Blades of Exile Graphics - Moved Niemand's tileImage functions from boe.graphics.cpp to graphtool.cpp, so they can be used by all three programs. - Added some string lists in .txt files - Made cursors into an enum - Rewrote the code for displaying the Edit Terrain dialog to use the new engine (not tested yet) - Fixed some __attribute__((deprecated)) stuff - Most graphics are now loaded just after the custom graphics. This means they will be overridden by a file of the same name in the scenario's .exr folder. - Altered modes a little so that when at the startup screen you are in MODE_STARTUP rather than MODE_OUTDOORS. - Switched from function pointers to boost::function – the Boost libraries are now required. - Finished off the new dialog engine and made gess necessary - Added status icons as another type that can be drawn in dialogs - C Wrappers for Cocoa cursors based on an Apple example. This is tested, and works perfectly. - Added a switch in the program for using Windows graphics; however, there is no way as yet to set this flag, and in fact there aren't even any Windows graphics to use. - Added include guards to graphtool.h - Made separate mac and win directories within sounds.exa, since the Mac and Windows sounds are mostly subtly different (with two completely different!) git-svn-id: http://openexile.googlecode.com/svn/trunk@90 4ebdad44-0ea0-11de-aab3-ff745001d230
143 lines
3.9 KiB
C++
143 lines
3.9 KiB
C++
/*
|
|
* control.h
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minstrel on 11/05/09.
|
|
*
|
|
*/
|
|
|
|
#ifndef CONTROL_H
|
|
#define CONTROL_H
|
|
|
|
#include <string>
|
|
#include <exception>
|
|
#include <boost/function.hpp>
|
|
|
|
//struct cPict {
|
|
// short pict;
|
|
// short type;
|
|
//};
|
|
enum eKeyMod {
|
|
mod_none = 0,
|
|
mod_alt = 1, mod_shift = 2, mod_ctrl = 4,
|
|
mod_altshift = mod_alt + mod_shift,
|
|
mod_altctrl = mod_alt + mod_ctrl,
|
|
mod_shiftctrl = mod_shift + mod_ctrl,
|
|
mod_all = mod_alt + mod_shift + mod_ctrl,
|
|
};
|
|
|
|
enum eSpecKey {
|
|
key_left, key_right, key_up, key_down,
|
|
key_esc, key_enter, key_tab, key_help, // key_help should bind to the help key on Mac and the F1 key on Windows
|
|
key_bsp, key_del, key_home, key_end, key_pgup, key_pgdn, // TODO: Implement these
|
|
// On Mac, command-left should trigger key_home; command-right should trigger key_end;
|
|
// command-up should trigger key_pgup; and command-down should trigger key_pgdn.
|
|
// This is in addition to the home, end, pgup, pgdn keys triggering these.
|
|
};
|
|
|
|
struct cKey {
|
|
bool spec;
|
|
union {
|
|
unsigned char c;
|
|
eSpecKey k;
|
|
};
|
|
eKeyMod mod;
|
|
};
|
|
|
|
bool operator== (cKey& a, cKey& b);
|
|
|
|
enum eFormat {
|
|
TXT_COLOR,
|
|
TXT_FRAME,
|
|
TXT_FONT,
|
|
TXT_SIZE,
|
|
TXT_WRAP,
|
|
};
|
|
|
|
enum eControlType {
|
|
CTRL_UNKNOWN,
|
|
CTRL_BTN, // An ordinary push button
|
|
CTRL_LED, // An LED (checkbox/radiobutton)
|
|
CTRL_PICT, // A picture
|
|
CTRL_FIELD, // An edit text field
|
|
CTRL_TEXT, // A static text object
|
|
CTRL_GROUP, // A LED radiobutton-like group
|
|
CTRL_STACK, // A group of controls that display pages (not implemented yet)
|
|
};
|
|
|
|
enum eTextFont {DUNGEON, GENEVA, SILOM, MAIDENWORD};
|
|
|
|
class cDialog;
|
|
//typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/);
|
|
//typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus.
|
|
typedef boost::function<bool(cDialog&,std::string,eKeyMod)> click_callback_t;
|
|
typedef boost::function<bool(cDialog&,std::string,bool)> focus_callback_t;
|
|
|
|
class xHandlerNotSupported : std::exception {
|
|
static const char* focusMsg;
|
|
static const char* clickMsg;
|
|
bool isFocus;
|
|
public:
|
|
xHandlerNotSupported(bool isFocus);
|
|
const char* what();
|
|
};
|
|
|
|
class xUnsupportedProp : std::exception {
|
|
eFormat whichProp;
|
|
char* msg;
|
|
public:
|
|
xUnsupportedProp(eFormat prop) throw();
|
|
~xUnsupportedProp() throw();
|
|
const char* what() throw();
|
|
};
|
|
|
|
class cControl {
|
|
public:
|
|
static void init();
|
|
void attachKey(cKey key);
|
|
void detachKey();
|
|
void setTextToKey();
|
|
bool hasKey();
|
|
virtual void attachClickHandler(click_callback_t f) throw(xHandlerNotSupported) = 0;
|
|
virtual void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported) = 0;
|
|
virtual bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where);
|
|
virtual bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus);
|
|
//virtual void setPict(short pict, short type) = 0;
|
|
virtual void show(); // cd_activate_item true
|
|
virtual void hide(); // cd_activate_item false
|
|
bool isVisible(); // cd_get_active
|
|
eControlType getType();
|
|
virtual void setText(std::string l);
|
|
virtual std::string getText();
|
|
long getTextAsNum();
|
|
void setTextToNum(long what);
|
|
virtual void setFormat(eFormat prop, short val) throw(xUnsupportedProp) = 0;
|
|
virtual short getFormat(eFormat prop) throw(xUnsupportedProp) = 0;
|
|
virtual bool isClickable() = 0;
|
|
bool handleClick();
|
|
cControl(cDialog* p,eControlType t);
|
|
virtual ~cControl();
|
|
protected:
|
|
cDialog* parent;
|
|
std::string lbl;
|
|
bool visible, depressed; // depressed is only applicable for clickable controls
|
|
Rect frame;
|
|
cKey key;
|
|
friend class cDialog;
|
|
friend class cLedGroup;
|
|
//friend class cStack;
|
|
virtual void draw() = 0;
|
|
static bool foundSilom();
|
|
static short font_nums[4];
|
|
void drawFrame(short amt, short med_or_lt);
|
|
private:
|
|
eControlType type;
|
|
static bool found_silom;
|
|
};
|
|
|
|
eKeyMod operator + (eKeyMod lhs, eKeyMod rhs);
|
|
eKeyMod operator - (eKeyMod lhs, eKeyMod rhs);
|
|
eKeyMod&operator += (eKeyMod&lhs, eKeyMod rhs);
|
|
eKeyMod&operator -= (eKeyMod&lhs, eKeyMod rhs);
|
|
#endif
|