mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
added multiple state support
svn-id: r23006
This commit is contained in:
parent
fd672ef2e1
commit
3b4416bb37
@ -25,9 +25,7 @@
|
||||
|
||||
namespace CEGUI {
|
||||
|
||||
ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item) :
|
||||
PanelItem(referenceTrue) {
|
||||
_item = item;
|
||||
void ItemSwitch::init(WORD referenceTrue, WORD referenceFalse) {
|
||||
_backgroundTrue = _background;
|
||||
_backgroundFalse = new SDL_ImageResource();
|
||||
if (!_backgroundFalse->load(referenceFalse)) {
|
||||
@ -36,10 +34,25 @@ namespace CEGUI {
|
||||
_background = NULL;
|
||||
_backgroundFalse = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item) :
|
||||
PanelItem(referenceTrue) {
|
||||
init(referenceTrue, referenceFalse);
|
||||
_item = item;
|
||||
_itemmax = -1;
|
||||
if (!*_item)
|
||||
_background = _backgroundFalse;
|
||||
}
|
||||
|
||||
ItemSwitch::ItemSwitch(WORD referenceTrue, WORD referenceFalse, int *item, int max) :
|
||||
PanelItem(referenceTrue) {
|
||||
init(referenceTrue, referenceFalse);
|
||||
_itemmultiple = item;
|
||||
_itemmax = max;
|
||||
if (!*item)
|
||||
_background = _backgroundFalse;
|
||||
}
|
||||
|
||||
ItemSwitch::~ItemSwitch() {
|
||||
if (_backgroundFalse)
|
||||
@ -49,18 +62,32 @@ namespace CEGUI {
|
||||
bool ItemSwitch::action(int x, int y, bool pushed) {
|
||||
|
||||
if (checkInside(x, y) && _visible && pushed) {
|
||||
*_item = !*_item;
|
||||
if (*_item)
|
||||
_background = _backgroundTrue;
|
||||
else
|
||||
_background = _backgroundFalse;
|
||||
if (_itemmax <= 0) {
|
||||
*_item = !*_item;
|
||||
if (*_item)
|
||||
_background = _backgroundTrue;
|
||||
else
|
||||
_background = _backgroundFalse;
|
||||
|
||||
if (_panel)
|
||||
_panel->forceRedraw();
|
||||
if (_panel)
|
||||
_panel->forceRedraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
} else {
|
||||
*_itemmultiple = *_itemmultiple + 1;
|
||||
if (*_itemmultiple > _itemmax)
|
||||
*_itemmultiple = 0;
|
||||
if (*_itemmultiple)
|
||||
_background = _backgroundTrue;
|
||||
else
|
||||
_background = _backgroundFalse;
|
||||
|
||||
if (_panel)
|
||||
_panel->forceRedraw();
|
||||
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,14 @@ namespace CEGUI {
|
||||
class ItemSwitch : public PanelItem {
|
||||
public:
|
||||
ItemSwitch(WORD referenceTrue, WORD referenceFalse, bool *item);
|
||||
ItemSwitch(WORD referenceTrue, WORD referenceFalse, int *item, int max);
|
||||
virtual ~ItemSwitch();
|
||||
virtual bool action(int x, int y, bool pushed);
|
||||
private:
|
||||
void init(WORD referenceTrue, WORD referenceFalse);
|
||||
bool *_item;
|
||||
static bool _itemdummy;
|
||||
int *_itemmultiple, _itemmax;
|
||||
SDL_ImageResource *_backgroundTrue;
|
||||
SDL_ImageResource *_backgroundFalse;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user