Jeck - Updated the WGui/OptionItem classes to all use ReadButton. Also updated daily build.
This commit is contained in:
Binary file not shown.
@@ -29,6 +29,7 @@ public:
|
|||||||
TEXT_BODY,
|
TEXT_BODY,
|
||||||
//Backgrounds only after this
|
//Backgrounds only after this
|
||||||
BACK,
|
BACK,
|
||||||
|
BACK_ALERT,
|
||||||
BACK_HEADER,
|
BACK_HEADER,
|
||||||
BACK_FAIL,
|
BACK_FAIL,
|
||||||
BACK_TAB,
|
BACK_TAB,
|
||||||
@@ -82,6 +83,8 @@ public:
|
|||||||
|
|
||||||
virtual void renderBack(WGuiBase * it);
|
virtual void renderBack(WGuiBase * it);
|
||||||
virtual void subBack(WGuiBase * item) {};
|
virtual void subBack(WGuiBase * item) {};
|
||||||
|
|
||||||
|
virtual bool CheckUserInput(u32 key) {return false;};
|
||||||
};
|
};
|
||||||
|
|
||||||
//This is our base class for concrete items.
|
//This is our base class for concrete items.
|
||||||
@@ -89,7 +92,8 @@ class WGuiItem: public WGuiBase{
|
|||||||
public:
|
public:
|
||||||
virtual void Entering(u32 key);
|
virtual void Entering(u32 key);
|
||||||
virtual bool Leaving(u32 key);
|
virtual bool Leaving(u32 key);
|
||||||
virtual void Update(float dt);
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
virtual void Update(float dt) {};
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
|
|
||||||
WGuiItem(string _display, u8 _mF = 0);
|
WGuiItem(string _display, u8 _mF = 0);
|
||||||
@@ -115,7 +119,6 @@ public:
|
|||||||
virtual void setY(float _y){y = _y;};
|
virtual void setY(float _y){y = _y;};
|
||||||
virtual void setWidth(float _w){width = _w;};
|
virtual void setWidth(float _w){width = _w;};
|
||||||
virtual void setHeight(float _h){height = _h;};
|
virtual void setHeight(float _h){height = _h;};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NO_TRANSLATE = (1<<1),
|
NO_TRANSLATE = (1<<1),
|
||||||
};
|
};
|
||||||
@@ -263,6 +266,7 @@ public:
|
|||||||
virtual void setHeight(float _h) {it->setHeight(_h);};
|
virtual void setHeight(float _h) {it->setHeight(_h);};
|
||||||
virtual void setHidden(bool bHidden) {it->setHidden(bHidden);};
|
virtual void setHidden(bool bHidden) {it->setHidden(bHidden);};
|
||||||
virtual void setVisible(bool bVisisble) {it->setVisible(bVisisble);};
|
virtual void setVisible(bool bVisisble) {it->setVisible(bVisisble);};
|
||||||
|
virtual bool CheckUserInput(u32 key) {return it->CheckUserInput(key);};
|
||||||
protected:
|
protected:
|
||||||
WGuiBase * it;
|
WGuiBase * it;
|
||||||
};
|
};
|
||||||
@@ -306,7 +310,8 @@ public:
|
|||||||
virtual void confirmChange(bool confirmed);
|
virtual void confirmChange(bool confirmed);
|
||||||
|
|
||||||
virtual void Entering(u32 key);
|
virtual void Entering(u32 key);
|
||||||
virtual bool Leaving(u32 key);
|
virtual bool Leaving(u32 key);
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
|
||||||
bool bRight;
|
bool bRight;
|
||||||
float percentRight;
|
float percentRight;
|
||||||
@@ -327,6 +332,7 @@ public:
|
|||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
virtual void Overlay();
|
virtual void Overlay();
|
||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
|
||||||
string confirm;
|
string confirm;
|
||||||
string cancel;
|
string cancel;
|
||||||
@@ -364,7 +370,7 @@ class WGuiButton: public WGuiDeco{
|
|||||||
public:
|
public:
|
||||||
WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
|
WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
|
||||||
virtual void updateValue();
|
virtual void updateValue();
|
||||||
virtual void Update(float dt);
|
virtual bool CheckUserInput(u32 key);
|
||||||
virtual bool Selectable() {return Visible();};
|
virtual bool Selectable() {return Visible();};
|
||||||
virtual PIXEL_TYPE getColor(int type);
|
virtual PIXEL_TYPE getColor(int type);
|
||||||
protected:
|
protected:
|
||||||
@@ -390,6 +396,7 @@ public:
|
|||||||
DS_DEFAULT = (1<<0),
|
DS_DEFAULT = (1<<0),
|
||||||
DS_COLOR_BRIGHT = (1<<1),
|
DS_COLOR_BRIGHT = (1<<1),
|
||||||
DS_COLOR_DARK = (1<<2),
|
DS_COLOR_DARK = (1<<2),
|
||||||
|
DS_STYLE_ALERT = (1<<3),
|
||||||
DS_STYLE_EDGED = (1<<4),
|
DS_STYLE_EDGED = (1<<4),
|
||||||
DS_STYLE_BACKLESS = (1<<5),
|
DS_STYLE_BACKLESS = (1<<5),
|
||||||
};
|
};
|
||||||
@@ -412,11 +419,12 @@ public:
|
|||||||
virtual bool Leaving(u32 key);
|
virtual bool Leaving(u32 key);
|
||||||
virtual void Entering(u32 key);
|
virtual void Entering(u32 key);
|
||||||
virtual void subBack(WGuiBase * item);
|
virtual void subBack(WGuiBase * item);
|
||||||
|
virtual bool CheckUserInput(u32 key);
|
||||||
|
|
||||||
|
|
||||||
WGuiBase * Current();
|
WGuiBase * Current();
|
||||||
virtual void nextItem();
|
virtual bool nextItem();
|
||||||
virtual void prevItem();
|
virtual bool prevItem();
|
||||||
virtual bool isModal();
|
virtual bool isModal();
|
||||||
virtual void setModal(bool val);
|
virtual void setModal(bool val);
|
||||||
|
|
||||||
@@ -441,8 +449,8 @@ class WGuiList: public WGuiMenu{
|
|||||||
virtual void ButtonPressed(int controllerId, int controlId);
|
virtual void ButtonPressed(int controllerId, int controlId);
|
||||||
virtual void setData();
|
virtual void setData();
|
||||||
|
|
||||||
virtual void nextItem();
|
virtual bool nextItem();
|
||||||
virtual void prevItem();
|
virtual bool prevItem();
|
||||||
|
|
||||||
WGuiBase * operator[](int);
|
WGuiBase * operator[](int);
|
||||||
protected:
|
protected:
|
||||||
@@ -548,7 +556,6 @@ class OptionProfile:public OptionDirectory{
|
|||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void confirmChange(bool confirmed);
|
virtual void confirmChange(bool confirmed);
|
||||||
virtual void Update(float dt);
|
|
||||||
virtual void updateValue();
|
virtual void updateValue();
|
||||||
void populate();
|
void populate();
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -706,11 +706,11 @@ bool GameOptionEnum::read(string input){
|
|||||||
//Enum Definitions
|
//Enum Definitions
|
||||||
OptionMaxGrade OptionMaxGrade::mDef;
|
OptionMaxGrade OptionMaxGrade::mDef;
|
||||||
OptionMaxGrade::OptionMaxGrade(){
|
OptionMaxGrade::OptionMaxGrade(){
|
||||||
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_SUPPORTED, "1 - 100% Supported"));
|
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_SUPPORTED, "1: 100% Supported"));
|
||||||
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_BORDERLINE, "2 - Borderline (99% OK)"));
|
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_BORDERLINE, "0: Borderline (99% OK)"));
|
||||||
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_CRAPPY, "3 - Crappy (bugs)"));
|
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_CRAPPY, "-1: Crappy (bugs)"));
|
||||||
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_UNSUPPORTED, "4 - Unsupported"));
|
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_UNSUPPORTED, "-2: Unsupported"));
|
||||||
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_DANGEROUS, "5 - Dangerous (risk of crash)"));
|
mDef.values.push_back(EnumDefinition::assoc(Constants::GRADE_DANGEROUS, "-3: Dangerous (risk of crash)"));
|
||||||
|
|
||||||
};
|
};
|
||||||
OptionClosedHand OptionClosedHand::mDef;
|
OptionClosedHand OptionClosedHand::mDef;
|
||||||
|
|||||||
@@ -156,38 +156,41 @@ void GameStateAwards::Update(float dt)
|
|||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
switch(mState){
|
u32 key;
|
||||||
case STATE_LISTVIEW:
|
while ((key = JGE::GetInstance()->ReadButton())){
|
||||||
if(listview)
|
switch(key){
|
||||||
listview->Update(dt);
|
case PSP_CTRL_START:
|
||||||
break;
|
showMenu = true;
|
||||||
case STATE_DETAILS:
|
|
||||||
if(detailview)
|
|
||||||
detailview->Update(dt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch(mEngine->ReadButton()){
|
|
||||||
case PSP_CTRL_START:
|
|
||||||
showMenu = true;
|
|
||||||
|
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
menu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
|
menu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
|
||||||
if(mState == STATE_DETAILS)
|
if(mState == STATE_DETAILS)
|
||||||
menu->Add(2, "Back to Trophies");
|
menu->Add(2, "Back to Trophies");
|
||||||
menu->Add(1, "Back to Main Menu");
|
menu->Add(1, "Back to Main Menu");
|
||||||
menu->Add(3, "Cancel");
|
menu->Add(3, "Cancel");
|
||||||
break;
|
break;
|
||||||
case PSP_CTRL_LTRIGGER:
|
case PSP_CTRL_LTRIGGER:
|
||||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
|
||||||
break;
|
|
||||||
case PSP_CTRL_CROSS:
|
|
||||||
if(mState == STATE_LISTVIEW)
|
|
||||||
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
else{
|
break;
|
||||||
mState = STATE_LISTVIEW;
|
case PSP_CTRL_CROSS:
|
||||||
SAFE_DELETE(detailview);
|
if(mState == STATE_LISTVIEW)
|
||||||
}
|
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
|
||||||
|
else{
|
||||||
|
mState = STATE_LISTVIEW;
|
||||||
|
SAFE_DELETE(detailview);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if(mState == STATE_LISTVIEW && listview){
|
||||||
|
listview->CheckUserInput(key);
|
||||||
|
listview->Update(dt);
|
||||||
|
}
|
||||||
|
else if(mState == STATE_DETAILS && detailview){
|
||||||
|
detailview->CheckUserInput(key);
|
||||||
|
detailview->Update(dt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void GameStateOptions::Start()
|
|||||||
optionsList = NEW WGuiList("Advanced");
|
optionsList = NEW WGuiList("Advanced");
|
||||||
optionsList->Add(NEW WGuiHeader("Advanced Options"));
|
optionsList->Add(NEW WGuiHeader("Advanced Options"));
|
||||||
WDecoStyled * wAdv = NEW WDecoStyled(NEW WGuiHeader("The following options require a restart."));
|
WDecoStyled * wAdv = NEW WDecoStyled(NEW WGuiHeader("The following options require a restart."));
|
||||||
wAdv->mStyle = WDecoStyled::DS_STYLE_BACKLESS;
|
wAdv->mStyle = WDecoStyled::DS_STYLE_ALERT;
|
||||||
optionsList->Add(wAdv);
|
optionsList->Add(wAdv);
|
||||||
WDecoConfirm * cLang = NEW WDecoConfirm(this,NEW OptionLanguage("Language"));
|
WDecoConfirm * cLang = NEW WDecoConfirm(this,NEW OptionLanguage("Language"));
|
||||||
cLang->confirm = "Use this Language";
|
cLang->confirm = "Use this Language";
|
||||||
@@ -120,11 +120,13 @@ void GameStateOptions::Update(float dt)
|
|||||||
else switch(mState){
|
else switch(mState){
|
||||||
default:
|
default:
|
||||||
case SHOW_OPTIONS:
|
case SHOW_OPTIONS:
|
||||||
optionsTabs->Update(dt);
|
u32 key;
|
||||||
|
|
||||||
if (mEngine->ReadButton() == PSP_CTRL_START){
|
while ((key = JGE::GetInstance()->ReadButton())){
|
||||||
mState = SHOW_OPTIONS_MENU;
|
if(!optionsTabs->CheckUserInput(key) && key == PSP_CTRL_START)
|
||||||
|
mState = SHOW_OPTIONS_MENU;
|
||||||
}
|
}
|
||||||
|
optionsTabs->Update(dt);
|
||||||
break;
|
break;
|
||||||
case SHOW_OPTIONS_MENU:
|
case SHOW_OPTIONS_MENU:
|
||||||
optionsMenu->Update(dt);
|
optionsMenu->Update(dt);
|
||||||
|
|||||||
@@ -84,13 +84,14 @@ string WGuiItem::_(string input){
|
|||||||
return input;
|
return input;
|
||||||
return ::_(input);
|
return ::_(input);
|
||||||
}
|
}
|
||||||
|
bool WGuiItem::CheckUserInput(u32 key){
|
||||||
void WGuiItem::Update(float dt){
|
if(mFocus && key == PSP_CTRL_CIRCLE){
|
||||||
JGE * mEngine = JGE::GetInstance();
|
updateValue();
|
||||||
if (mFocus){
|
return true;
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) updateValue();
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//WDecoStyled
|
//WDecoStyled
|
||||||
void WDecoStyled::subBack(WGuiBase * item){
|
void WDecoStyled::subBack(WGuiBase * item){
|
||||||
if(!item)
|
if(!item)
|
||||||
@@ -107,8 +108,9 @@ void WDecoStyled::subBack(WGuiBase * item){
|
|||||||
if(split->right)
|
if(split->right)
|
||||||
renderer->FillRoundRect(split->right->getX()-2,split->getY()-2,split->right->getWidth(),split->getHeight(),2,split->right->getColor(WGuiColor::BACK));
|
renderer->FillRoundRect(split->right->getX()-2,split->getY()-2,split->right->getWidth(),split->getHeight(),2,split->right->getColor(WGuiColor::BACK));
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
renderer->FillRoundRect(item->getX()-2,item->getY()-2,item->getWidth(),item->getHeight(),2,item->getColor(WGuiColor::BACK));
|
renderer->FillRoundRect(item->getX()-2,item->getY()-2,item->getWidth(),item->getHeight(),2,getColor(WGuiColor::BACK));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -121,6 +123,8 @@ PIXEL_TYPE WDecoStyled::getColor(int type){
|
|||||||
return ARGB(150,35,35,35);
|
return ARGB(150,35,35,35);
|
||||||
else if(mStyle & DS_COLOR_BRIGHT)
|
else if(mStyle & DS_COLOR_BRIGHT)
|
||||||
return ARGB(150,80,80,80);
|
return ARGB(150,80,80,80);
|
||||||
|
else if(mStyle & DS_STYLE_ALERT)
|
||||||
|
return ARGB(150,120,80,80);
|
||||||
else
|
else
|
||||||
return ARGB(150,50,50,50);
|
return ARGB(150,50,50,50);
|
||||||
default:
|
default:
|
||||||
@@ -317,14 +321,6 @@ void OptionProfile::Render(){
|
|||||||
mFont->SetScale(1);
|
mFont->SetScale(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
void OptionProfile::Update(float dt){
|
|
||||||
JGE * mEngine = JGE::GetInstance();
|
|
||||||
|
|
||||||
if (mFocus && mEngine->GetButtonClick(PSP_CTRL_CIRCLE)){
|
|
||||||
updateValue();
|
|
||||||
mEngine->ReadButton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void OptionProfile::Entering(u32 key){
|
void OptionProfile::Entering(u32 key){
|
||||||
mFocus = true;
|
mFocus = true;
|
||||||
initialValue = value;
|
initialValue = value;
|
||||||
@@ -660,15 +656,17 @@ void WGuiList::setData(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiList::nextItem(){
|
bool WGuiList::nextItem(){
|
||||||
WGuiMenu::nextItem();
|
bool rez = WGuiMenu::nextItem();
|
||||||
if(sync)
|
if(sync)
|
||||||
sync->setPos(currentItem);
|
sync->setPos(currentItem);
|
||||||
|
return rez;
|
||||||
}
|
}
|
||||||
void WGuiList::prevItem(){
|
bool WGuiList::prevItem(){
|
||||||
WGuiMenu::prevItem();
|
bool rez = WGuiMenu::prevItem();
|
||||||
if(sync)
|
if(sync)
|
||||||
sync->setPos(currentItem);
|
sync->setPos(currentItem);
|
||||||
|
return rez;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiList::ButtonPressed(int controllerId, int controlId){
|
void WGuiList::ButtonPressed(int controllerId, int controlId){
|
||||||
@@ -885,14 +883,24 @@ bool WDecoConfirm::Leaving(u32 key){
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool WDecoConfirm::CheckUserInput(u32 key){
|
||||||
|
if(hasFocus()){
|
||||||
|
if (mState == OP_CONFIRMED && key == PSP_CTRL_CIRCLE)
|
||||||
|
mState = OP_UNCONFIRMED;
|
||||||
|
|
||||||
|
if (mState != OP_CONFIRMING && it){
|
||||||
|
if(it->CheckUserInput(key))
|
||||||
|
return true;
|
||||||
|
} else if(confirmMenu && confirmMenu->CheckUserInput(key))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WDecoConfirm::Update(float dt){
|
void WDecoConfirm::Update(float dt){
|
||||||
if (hasFocus()){
|
if (hasFocus()){
|
||||||
JGE * mEngine = JGE::GetInstance();
|
if (it && mState != OP_CONFIRMING)
|
||||||
if (mState == OP_CONFIRMED && mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) mState = OP_UNCONFIRMED;
|
|
||||||
|
|
||||||
if (it && mState != OP_CONFIRMING){
|
|
||||||
it->Update(dt);
|
it->Update(dt);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
confirmMenu->Update(dt);
|
confirmMenu->Update(dt);
|
||||||
}
|
}
|
||||||
@@ -937,11 +945,12 @@ void WGuiButton::updateValue(){
|
|||||||
mListener->ButtonPressed(controller, control);
|
mListener->ButtonPressed(controller, control);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiButton::Update(float dt){
|
bool WGuiButton::CheckUserInput(u32 key){
|
||||||
JGE * mEngine = JGE::GetInstance();
|
if (hasFocus() && key == PSP_CTRL_CIRCLE){
|
||||||
if (hasFocus()){
|
updateValue();
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) updateValue();
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PIXEL_TYPE WGuiButton::getColor(int type){
|
PIXEL_TYPE WGuiButton::getColor(int type){
|
||||||
@@ -1021,26 +1030,35 @@ void WGuiSplit::setModal(bool val){
|
|||||||
return left->setModal(val);
|
return left->setModal(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiSplit::Update(float dt){
|
bool WGuiSplit::CheckUserInput(u32 key){
|
||||||
JGE * mEngine = JGE::GetInstance();
|
if(hasFocus()){
|
||||||
|
if (!bRight){
|
||||||
if(hasFocus() && !isModal()){
|
if(key == PSP_CTRL_RIGHT && !isModal()
|
||||||
if (!bRight && mEngine->GetButtonClick(PSP_CTRL_RIGHT) && right->Selectable())
|
&& right->Selectable() && left->Leaving(PSP_CTRL_RIGHT)){
|
||||||
{
|
|
||||||
if(left->Leaving(PSP_CTRL_RIGHT)){
|
|
||||||
bRight = !bRight;
|
bRight = !bRight;
|
||||||
right->Entering(PSP_CTRL_RIGHT);
|
right->Entering(PSP_CTRL_RIGHT);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if(left->CheckUserInput(key))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (bRight && mEngine->GetButtonClick(PSP_CTRL_LEFT) && left->Selectable())
|
else
|
||||||
{
|
{
|
||||||
if(right->Leaving(PSP_CTRL_LEFT)){
|
if (key == PSP_CTRL_LEFT && !isModal()
|
||||||
|
&& left->Selectable() && right->Leaving(PSP_CTRL_LEFT)){
|
||||||
bRight = !bRight;
|
bRight = !bRight;
|
||||||
left->Entering(PSP_CTRL_LEFT);
|
left->Entering(PSP_CTRL_LEFT);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if(right->CheckUserInput(key))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WGuiSplit::Update(float dt){
|
||||||
if(bRight)
|
if(bRight)
|
||||||
right->Update(dt);
|
right->Update(dt);
|
||||||
else
|
else
|
||||||
@@ -1146,41 +1164,56 @@ void WGuiMenu::Add(WGuiBase * it){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool WGuiMenu::CheckUserInput(u32 key){
|
||||||
|
bool kidModal = false;
|
||||||
|
bool handledInput = false;
|
||||||
|
int nbitems = (int) items.size();
|
||||||
|
JGE * mEngine = JGE::GetInstance();
|
||||||
|
|
||||||
|
if(!mEngine->GetButtonState(held)) //Key isn't held down.
|
||||||
|
held = 0;
|
||||||
|
|
||||||
|
if(currentItem >= 0 && currentItem < nbitems)
|
||||||
|
kidModal = items[currentItem]->isModal();
|
||||||
|
|
||||||
|
if(!kidModal && hasFocus()){
|
||||||
|
if (key == buttonPrev){
|
||||||
|
held = buttonPrev;
|
||||||
|
duration = 0;
|
||||||
|
if(prevItem())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(held == buttonPrev && duration > 1){
|
||||||
|
duration = .92;
|
||||||
|
if(prevItem())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (key == buttonNext){
|
||||||
|
held = buttonNext;
|
||||||
|
duration = 0;
|
||||||
|
if(nextItem())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(held == buttonNext && duration > 1){
|
||||||
|
duration = .92;
|
||||||
|
if(nextItem())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(currentItem >= 0 && currentItem < nbitems)
|
||||||
|
return items[currentItem]->CheckUserInput(key);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WGuiMenu::Update(float dt){
|
void WGuiMenu::Update(float dt){
|
||||||
int nbitems = (int) items.size();
|
int nbitems = (int) items.size();
|
||||||
JGE * mEngine = JGE::GetInstance();
|
JGE * mEngine = JGE::GetInstance();
|
||||||
bool kidModal = false;
|
|
||||||
|
|
||||||
if(!mEngine->GetButtonState(held))
|
if(held)
|
||||||
held = 0;
|
|
||||||
else
|
|
||||||
duration += dt;
|
duration += dt;
|
||||||
|
|
||||||
if(currentItem >= 0 && currentItem < nbitems)
|
|
||||||
kidModal = items[currentItem]->isModal();
|
|
||||||
|
|
||||||
if(!kidModal && hasFocus()){
|
|
||||||
if (mEngine->GetButtonClick(buttonPrev)){
|
|
||||||
prevItem();
|
|
||||||
held = buttonPrev;
|
|
||||||
duration = 0;
|
|
||||||
}
|
|
||||||
else if(held == buttonPrev && duration > 1){
|
|
||||||
prevItem();
|
|
||||||
duration = .92;
|
|
||||||
}
|
|
||||||
else if (mEngine->GetButtonClick(buttonNext)){
|
|
||||||
nextItem();
|
|
||||||
held = buttonNext;
|
|
||||||
duration = 0;
|
|
||||||
}
|
|
||||||
else if(held == buttonNext && duration > 1){
|
|
||||||
nextItem();
|
|
||||||
duration = .92;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentItem >= 0 && currentItem < nbitems)
|
if(currentItem >= 0 && currentItem < nbitems)
|
||||||
items[currentItem]->Update(dt);
|
items[currentItem]->Update(dt);
|
||||||
|
|
||||||
@@ -1190,7 +1223,7 @@ void WGuiMenu::Update(float dt){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiMenu::nextItem(){
|
bool WGuiMenu::nextItem(){
|
||||||
int potential = currentItem;
|
int potential = currentItem;
|
||||||
int nbitems = (int) items.size();
|
int nbitems = (int) items.size();
|
||||||
|
|
||||||
@@ -1203,11 +1236,13 @@ void WGuiMenu::nextItem(){
|
|||||||
else if(potential != currentItem && items[currentItem]->Leaving(buttonNext)){
|
else if(potential != currentItem && items[currentItem]->Leaving(buttonNext)){
|
||||||
currentItem = potential;
|
currentItem = potential;
|
||||||
items[currentItem]->Entering(buttonNext);
|
items[currentItem]->Entering(buttonNext);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiMenu::prevItem(){
|
bool WGuiMenu::prevItem(){
|
||||||
int potential = currentItem;
|
int potential = currentItem;
|
||||||
|
|
||||||
if (potential > 0){
|
if (potential > 0){
|
||||||
@@ -1219,8 +1254,10 @@ void WGuiMenu::prevItem(){
|
|||||||
else if(items[currentItem]->Leaving(buttonPrev)){
|
else if(items[currentItem]->Leaving(buttonPrev)){
|
||||||
currentItem = potential;
|
currentItem = potential;
|
||||||
items[currentItem]->Entering(buttonPrev);
|
items[currentItem]->Entering(buttonPrev);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WGuiMenu::setModal(bool val){
|
void WGuiMenu::setModal(bool val){
|
||||||
|
|||||||
Reference in New Issue
Block a user