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