- Stripped out the copying of external files (such as graphics, scenarios, bladbase) into a separate target which the other three are dependent on. - Graphics.exd no longer included by reference; now the individual files are included directly. - Added a recalcRect function to ledGroup, since it's a container. - Added a special case to cLedGroup::setSelected to avoid a crash when no LED is initially selected. - Added a few initializers to constructors. - Changes to cDialog::parse<cPict> which were intended to prevent an access violation; unfortunately it doesn't work yet. - Add cases to cDialog::parse<cPict> to handle PI_TER_MAP and PIC_STATUS. - Fixed a stupid error in all specializations of cDialog::parse which resulted in an infinite loop. - Fixed errors in some specializations of cDialog::parse in which an else statement belonged to a different if than it should have. - Added code to cDialog::loadFromFile to turn the relative path in the argument into an absolute path. - Fixed errors in cDialog::loadFromFile relating to incorrect use of the parser. - Added exit statements to the catch clauses in cDialog::loadFromFile. - Added definition of cDialog::init; - Enclosed the WaitNextEvent call in cDialog::run in an if statement to ignore null events if they occur (I suspect they won't anyway though) - Fixed errors in the Edit Terrain dialog definition which caused an exception to be thrown when parsing it: bold was changed to silom, key= was changed to def-key= - Added status to the list of nullified GWorlPtrs in cPict::init. - Changed the type of cPict::drawPict from map<ePicType,void(*)(short,GWorldPtr,Rect)> to void(*[])(short,GWorldPtr,Rect) - ie, it was changed from a map to an array because the map was causing an error for some reason. - Fixed up the load_strings function, which didn't work at all due to a stupid logic error. git-svn-id: http://openexile.googlecode.com/svn/trunk@96 4ebdad44-0ea0-11de-aab3-ff745001d230
105 lines
2.5 KiB
C++
105 lines
2.5 KiB
C++
/*
|
|
* dialog.h
|
|
* BoE
|
|
*
|
|
* Created by Celtic Minstrel on 11/05/09.
|
|
*
|
|
*/
|
|
|
|
#ifndef DIALOG_H
|
|
#define DIALOG_H
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <exception>
|
|
|
|
#include "ticpp.h"
|
|
|
|
#include "control.h"
|
|
#include "button.h"
|
|
#include "field.h"
|
|
#include "pict.h"
|
|
#include "message.h"
|
|
|
|
class cDialog {
|
|
typedef std::map<std::string,cControl*>::iterator ctrlIter;
|
|
std::map<std::string,cControl*> controls;
|
|
short bg;
|
|
RGBColor defTextClr;
|
|
template<class T> std::pair<std::string,T*> parse(ticpp::Element& who);
|
|
RGBColor parseColor(std::string what);
|
|
cKey parseKey(std::string what);
|
|
WindowRef win;
|
|
cTextField* currentFocus;
|
|
class _init {
|
|
_init();
|
|
~_init();
|
|
friend class cDialog;
|
|
};
|
|
static _init init;
|
|
cDialog* parent;
|
|
void loadFromFile(std::string path);
|
|
public:
|
|
static const short BG_LIGHT, BG_DARK;
|
|
explicit cDialog(cDialog* p = NULL); // dialog with no items
|
|
explicit cDialog(std::string path); // cd_create_dialog
|
|
cDialog(std::string path,cDialog* p); // cd_create_dialog_parent_num
|
|
~cDialog(); // cd_kill_dialog
|
|
bool add(cControl* what, Rect ctrl_frame, std::string key); // returns false if the key is used, true if the control was added
|
|
bool remove(std::string key); // returns true if the key existed and was removed, false if the key did not exist
|
|
void run(); // cd_run_dialog
|
|
template<class type> type& getResult();
|
|
template<class type> void setResult(const type& val);
|
|
void setBg(short n);
|
|
void setDefTextClr(RGBColor clr);
|
|
bool toast();
|
|
cControl& operator[](std::string id);
|
|
void recalcRect();
|
|
private:
|
|
void draw();
|
|
std::string process_keystroke(cKey keyHit);
|
|
std::string process_click(Point where, eKeyMod mods);
|
|
bool dialogNotToast;
|
|
Rect winRect;
|
|
unsigned long long result;
|
|
friend class cControl;
|
|
friend class cButton;
|
|
friend class cLed;
|
|
friend class cLedGroup;
|
|
friend class cPict;
|
|
friend class cTextField;
|
|
friend class cTextMsg;
|
|
friend class _init;
|
|
};
|
|
|
|
class xBadNode : std::exception {
|
|
std::string type;
|
|
const char* msg;
|
|
public:
|
|
xBadNode(std::string t) throw();
|
|
~xBadNode() throw();
|
|
const char* what() throw();
|
|
};
|
|
|
|
class xBadAttr : std::exception {
|
|
std::string type, name;
|
|
const char* msg;
|
|
public:
|
|
xBadAttr(std::string t,std::string n) throw();
|
|
~xBadAttr() throw();
|
|
const char* what() throw();
|
|
};
|
|
|
|
class xBadVal : std::exception {
|
|
std::string type, name, val;
|
|
const char* msg;
|
|
public:
|
|
xBadVal(std::string t,std::string n,std::string v) throw();
|
|
~xBadVal() throw();
|
|
const char* what() throw();
|
|
};
|
|
|
|
#include "dialog.results.h" // public template definitions
|
|
|
|
#endif
|