*Made scrolling with D-PAD while pointing at a list browser possible.

*UpdatePath and titles.txt Path are now changable again (forgot to add them before)
*Added forgot UnicodeFix Option
This commit is contained in:
dimok321 2009-06-07 16:16:18 +00:00
parent b758bef4e1
commit 6cf6de3e70
4 changed files with 230 additions and 168 deletions

View File

@ -225,7 +225,7 @@ int MenuSettings()
MainButton4.SetEffectGrow();
MainButton4.SetTrigger(&trigA);
customOptionList options2(9);
customOptionList options2(10);
GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150);
optionBrowser2.SetPosition(0, 90);
optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -298,6 +298,9 @@ int MenuSettings()
/** Disable ability to click through MainButtons */
optionBrowser2.SetClickable(false);
/** Default no scrollbar and reset position **/
optionBrowser2.SetScrollbar(0);
optionBrowser2.SetOffset(0);
MainButton1.StopEffect();
MainButton2.StopEffect();
@ -394,6 +397,9 @@ int MenuSettings()
/** Disable ability to click through MainButtons */
optionBrowser2.SetClickable(false);
/** Default no scrollbar and reset position **/
optionBrowser2.SetScrollbar(0);
optionBrowser2.SetOffset(0);
MainButton1.StopEffect();
MainButton2.StopEffect();
@ -463,8 +469,10 @@ int MenuSettings()
options2.SetName(5, "%s",LANGUAGE.PromptsButtons);
options2.SetName(6, "%s",LANGUAGE.keyboard);
options2.SetName(7, "%s",LANGUAGE.Wiilight);
options2.SetName(8, "%s", LANGUAGE.Rumble);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL);
options2.SetName(8, "%s",LANGUAGE.Rumble);
options2.SetName(9, "%s",LANGUAGE.Unicodefix);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
optionBrowser2.SetScrollbar(1);
w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true);
ResumeGui();
@ -499,6 +507,8 @@ int MenuSettings()
Settings.wiilight = 0;
if(Settings.rumble >= settings_rumble_max)
Settings.rumble = 0; //RUMBLE
if ( Settings.unicodefix > 2 )
Settings.unicodefix = 0;
if(!strcmp("notset", Settings.language_path))
options2.SetValue(0, "%s", LANGUAGE.Default);
@ -538,6 +548,10 @@ int MenuSettings()
if (Settings.rumble == RumbleOn) options2.SetValue(8,"%s",LANGUAGE.ON);
else if (Settings.rumble == RumbleOff) options2.SetValue(8,"%s",LANGUAGE.OFF);
if (Settings.unicodefix == 0) options2.SetValue(9,"%s",LANGUAGE.OFF);
else if (Settings.unicodefix == 1) options2.SetValue(9,"%s",LANGUAGE.TChinese);
else if (Settings.unicodefix == 2) options2.SetValue(9,"%s",LANGUAGE.SChinese);
if(backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
@ -639,6 +653,9 @@ int MenuSettings()
case 8:
Settings.rumble++;
break;
case 9:
Settings.unicodefix++;
break;
}
}
optionBrowser2.SetEffect(EFFECT_FADE, -20);
@ -677,7 +694,8 @@ int MenuSettings()
options2.SetName(6, NULL);
options2.SetName(7, NULL);
options2.SetName(8, NULL);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL);
options2.SetName(9, NULL);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true);
ResumeGui();
@ -822,7 +840,8 @@ int MenuSettings()
options2.SetName(6, NULL);
options2.SetName(7, NULL);
options2.SetName(8, NULL);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL);
options2.SetName(9, NULL);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true);
ResumeGui();
@ -988,7 +1007,8 @@ int MenuSettings()
options2.SetName(6, NULL);
options2.SetName(7, NULL);
options2.SetName(8, NULL);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL);
options2.SetName(9, NULL);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true);
ResumeGui();
@ -1135,7 +1155,8 @@ int MenuSettings()
options2.SetName(6, NULL);
options2.SetName(7, NULL);
options2.SetName(8, NULL);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL);
options2.SetName(9, NULL);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true);
ResumeGui();
@ -1303,6 +1324,58 @@ int MenuSettings()
WindowPrompt(LANGUAGE.Themepathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0);
}
break;
case 3:
if ( Settings.godmode == 1)
{
w.Remove(&optionBrowser2);
w.Remove(&backBtn);
char entered[43] = "";
strncpy(entered, Settings.titlestxt_path, sizeof(entered));
int result = OnScreenKeyboard(entered,43,4);
w.Append(&optionBrowser2);
w.Append(&backBtn);
if ( result == 1 )
{
int len = (strlen(entered)-1);
if(entered[len] !='/')
strncat (entered, "/", 1);
strncpy(Settings.titlestxt_path, entered, sizeof(Settings.titlestxt_path));
WindowPrompt(LANGUAGE.TitlestxtpathChanged,0,LANGUAGE.ok,0,0,0);
if(isSdInserted()) {
cfg_save_global();
CFG_Load();
} else {
WindowPrompt(LANGUAGE.NoSDcardinserted, LANGUAGE.InsertaSDCardtosave, LANGUAGE.ok, 0,0,0);
}
}
}
else
{
WindowPrompt(LANGUAGE.Titlestxtpathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0);
}
break;
case 4:
if ( Settings.godmode == 1)
{
w.Remove(&optionBrowser2);
w.Remove(&backBtn);
char entered[43] = "";
strncpy(entered, Settings.update_path, sizeof(entered));
int result = OnScreenKeyboard(entered,43,4);
w.Append(&optionBrowser2);
w.Append(&backBtn);
if ( result == 1 )
{
int len = (strlen(entered)-1);
if(entered[len] !='/')
strncat (entered, "/", 1);
strncpy(Settings.update_path, entered, sizeof(Settings.update_path));
WindowPrompt(LANGUAGE.Updatepathchanged,0,LANGUAGE.ok,0,0,0);
}
}
else
WindowPrompt(0,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0);
break;
}
}
/** If not godmode don't let him inside **/

View File

@ -12,7 +12,6 @@
#include "../cfg.h"
#include "gui_customoptionbrowser.h"
#include <unistd.h>
@ -110,7 +109,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath);
bgOptionsEntry = new GuiImageData(imgPath, bg_options_entry_png);
if (scrollbaron == 1) {
snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath);
scrollbar = new GuiImageData(imgPath, scrollbar_png);
scrollbarImg = new GuiImage(scrollbar);
@ -170,7 +169,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
scrollbarBoxBtn->SetMaxY(height-30);
scrollbarBoxBtn->SetHoldable(true);
scrollbarBoxBtn->SetTrigger(trigHeldA);
}
optionIndex = new int[size];
optionVal = new GuiText * [size];
@ -213,7 +211,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
*/
GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
{
if (scrollbaron == 1) {
delete arrowUpBtn;
delete arrowDownBtn;
delete scrollbarBoxBtn;
@ -231,7 +228,7 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
delete arrowUpOver;
delete scrollbarBox;
delete scrollbarBoxOver;
}
delete bgOptionsImg;
delete bgOptions;
delete bgOptionsEntry;
@ -320,6 +317,17 @@ void GuiCustomOptionBrowser::SetClickable(bool enable)
}
}
void GuiCustomOptionBrowser::SetScrollbar(int enable)
{
scrollbaron = enable;
}
void GuiCustomOptionBrowser::SetOffset(int optionnumber)
{
listOffset = optionnumber;
selectedItem = optionnumber;
}
/****************************************************************************
* FindMenuItem
*
@ -371,6 +379,7 @@ void GuiCustomOptionBrowser::Draw()
}
this->UpdateEffects();
}
void GuiCustomOptionBrowser::UpdateListEntries()
{
if(listOffset<0) listOffset = this->FindMenuItem(-1, 1);
@ -416,6 +425,7 @@ void GuiCustomOptionBrowser::UpdateListEntries()
}
}
}
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
LOCK(this);
@ -430,11 +440,6 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
int old_listOffset = listOffset;
// scrolldelay affects how fast the list scrolls
// when the arrows are clicked
float scrolldelay = 3.5;
if (scrollbaron == 1)
{
// update the location of the scroll box based on the position in the option list
@ -445,8 +450,11 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
next = listOffset;
for(int i=0; i < size; i++)
{
u32 buttonshold = ButtonsHold();
if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) {
for(int i=0; i < size; i++)
{
if(next >= 0)
next = this->FindMenuItem(next, 1);
@ -459,136 +467,21 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
}
optionBtn[i]->Update(t);
if(optionBtn[i]->GetState() == STATE_SELECTED)
{
selectedItem = i;
}
}
}
// pad/joystick navigation
if(!focus)
return; // skip navigation
if (scrollbaron == 1)
{
if (t->Down() ||
arrowDownBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////down
arrowDownBtn->GetState() == STATE_HELD)
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if(next >= 0)
{
if(selectedItem == size-1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
else if(optionBtn[selectedItem+1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}
if (ButtonsHold() == WPAD_BUTTON_A)
{
}
else
{
arrowDownBtn->ResetState();
}
}
else if(t->Up() ||
arrowUpBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////up
arrowUpBtn->GetState() == STATE_HELD)
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if(prev >= 0)
{
if(selectedItem == 0)
{
// move list up by 1
listOffset = prev;
}
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}
if (ButtonsHold() == WPAD_BUTTON_A)
{
}
else
{
arrowUpBtn->ResetState();
}
}
if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && options->GetLength() > size)
{
scrollbarBoxBtn->SetPosition(width/2-18+7,0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
listOffset = (position * lang)/180 - selectedItem;
if(listOffset <= 0)
{
listOffset = 0;
selectedItem = 0;
}
else if(listOffset+size >= lang)
{
listOffset = lang-size;
selectedItem = size-1;
}
}
int positionbar = 237*(listOffset + selectedItem) / lang;
if(positionbar > 216)
positionbar = 216;
scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);
if(t->Right())
{
if(listOffset < lang && lang > size)
{
listOffset =listOffset+ size;
if(listOffset+size >= lang)
listOffset = lang-size;
}
}
else if(t->Left())
{
if(listOffset > 0)
{
listOffset =listOffset- size;
if(listOffset < 0)
listOffset = 0;
}
}
}
else
{
if(t->Down())
if(t->Down())
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
@ -626,7 +519,105 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
}
}
}
if (scrollbaron == 1)
{
if (arrowDownBtn->GetState() == STATE_CLICKED ||
arrowDownBtn->GetState() == STATE_HELD)
{
next = this->FindMenuItem(optionIndex[selectedItem], 1);
if(next >= 0)
{
if(selectedItem == size-1)
{
// move list down by 1
listOffset = this->FindMenuItem(listOffset, 1);
}
else if(optionBtn[selectedItem+1]->IsVisible())
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++;
}
scrollbarBoxBtn->Draw();
usleep(35000);
}
if (buttonshold != WPAD_BUTTON_A) {
arrowDownBtn->ResetState();
}
}
else if(arrowUpBtn->GetState() == STATE_CLICKED ||
arrowUpBtn->GetState() == STATE_HELD)
{
prev = this->FindMenuItem(optionIndex[selectedItem], -1);
if(prev >= 0)
{
if(selectedItem == 0)
{
// move list up by 1
listOffset = prev;
}
else
{
optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--;
}
scrollbarBoxBtn->Draw();
usleep(35000);
}
if (buttonshold != WPAD_BUTTON_A) {
arrowUpBtn->ResetState();
}
}
if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid && options->GetLength() > size)
{
scrollbarBoxBtn->SetPosition(width/2-18+7,0);
int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();
listOffset = (position * lang)/180 - selectedItem;
if(listOffset <= 0) {
listOffset = 0;
selectedItem = 0;
} else if(listOffset+size >= lang) {
listOffset = lang-size;
selectedItem = size-1;
}
}
int positionbar = 237*(listOffset + selectedItem) / lang;
if(positionbar > 216)
positionbar = 216;
scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);
if(t->Right())
{
if(listOffset < lang && lang > size)
{
listOffset =listOffset+ size;
if(listOffset+size >= lang)
listOffset = lang-size;
}
}
else if(t->Left())
{
if(listOffset > 0)
{
listOffset =listOffset- size;
if(listOffset < 0)
listOffset = 0;
}
}
}
if(old_listOffset != listOffset)
UpdateListEntries();

View File

@ -39,6 +39,8 @@ class GuiCustomOptionBrowser : public GuiElement
int GetClickedOption();
int GetSelectedOption();
void SetClickable(bool enable);
void SetScrollbar(int enable);
void SetOffset(int optionnumber);
void ResetState();
void SetFocus(int f);
void Draw();

View File

@ -358,26 +358,31 @@ void GuiGameBrowser::Update(GuiTrigger * t)
next = listOffset;
for(int i=0; i<pagesize; i++)
{
if(next >= 0)
next = this->FindMenuItem(next, 1);
u32 buttonshold = ButtonsHold();
if(focus)
{
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
game[i]->ResetState();
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
}
if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) {
game[i]->Update(t);
for(int i=0; i<pagesize; i++)
{
if(next >= 0)
next = this->FindMenuItem(next, 1);
if(game[i]->GetState() == STATE_SELECTED)
{
selectedItem = i;
}
}
if(focus)
{
if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
game[i]->ResetState();
else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
game[selectedItem]->SetState(STATE_SELECTED, t->chan);
}
game[i]->Update(t);
if(game[i]->GetState() == STATE_SELECTED)
{
selectedItem = i;
}
}
}
// pad/joystick navigation
if(!focus)
@ -387,11 +392,10 @@ void GuiGameBrowser::Update(GuiTrigger * t)
{
if (t->Down() ||
arrowDownBtn->GetState() == STATE_CLICKED || ////////////////////////////////////////////down
arrowDownBtn->GetState() == STATE_CLICKED ||
arrowDownBtn->GetState() == STATE_HELD)
{
next = this->FindMenuItem(gameIndex[selectedItem], 1);
if(next >= 0)
@ -411,11 +415,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}
if (ButtonsHold() == WPAD_BUTTON_A)
{
}
else
{
if (buttonshold != WPAD_BUTTON_A){
arrowDownBtn->ResetState();
}
}
@ -441,11 +441,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
scrollbarBoxBtn->Draw();
usleep(10000 * scrolldelay);
}
if (ButtonsHold() == WPAD_BUTTON_A)
{
}
else
{
if (buttonshold != WPAD_BUTTON_A){
arrowUpBtn->ResetState();
}
}
@ -459,7 +455,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
position2 = position1;
}
if (ButtonsHold() == WPAD_BUTTON_B && position1 > 0)
if (buttonshold == WPAD_BUTTON_B && position1 > 0)
{
scrollbarBoxBtn->ScrollIsOn(1);
if (position2 > position1)
@ -509,7 +505,7 @@ void GuiGameBrowser::Update(GuiTrigger * t)
}
}
else if(ButtonsHold() != WPAD_BUTTON_B)
else if(buttonshold != WPAD_BUTTON_B)
{
scrollbarBoxBtn->ScrollIsOn(0);
position2 = 0;