*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.SetEffectGrow();
MainButton4.SetTrigger(&trigA); 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); GuiCustomOptionBrowser optionBrowser2(396, 280, &options2, CFG.theme_path, "bg_options_settings.png", bg_options_settings_png, 0, 150);
optionBrowser2.SetPosition(0, 90); optionBrowser2.SetPosition(0, 90);
optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); optionBrowser2.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -298,6 +298,9 @@ int MenuSettings()
/** Disable ability to click through MainButtons */ /** Disable ability to click through MainButtons */
optionBrowser2.SetClickable(false); optionBrowser2.SetClickable(false);
/** Default no scrollbar and reset position **/
optionBrowser2.SetScrollbar(0);
optionBrowser2.SetOffset(0);
MainButton1.StopEffect(); MainButton1.StopEffect();
MainButton2.StopEffect(); MainButton2.StopEffect();
@ -394,6 +397,9 @@ int MenuSettings()
/** Disable ability to click through MainButtons */ /** Disable ability to click through MainButtons */
optionBrowser2.SetClickable(false); optionBrowser2.SetClickable(false);
/** Default no scrollbar and reset position **/
optionBrowser2.SetScrollbar(0);
optionBrowser2.SetOffset(0);
MainButton1.StopEffect(); MainButton1.StopEffect();
MainButton2.StopEffect(); MainButton2.StopEffect();
@ -464,7 +470,9 @@ int MenuSettings()
options2.SetName(6, "%s",LANGUAGE.keyboard); options2.SetName(6, "%s",LANGUAGE.keyboard);
options2.SetName(7, "%s",LANGUAGE.Wiilight); options2.SetName(7, "%s",LANGUAGE.Wiilight);
options2.SetName(8, "%s",LANGUAGE.Rumble); options2.SetName(8, "%s",LANGUAGE.Rumble);
for(int i = 0; i < 9; i++) options2.SetValue(i, NULL); options2.SetName(9, "%s",LANGUAGE.Unicodefix);
for(int i = 0; i < 10; i++) options2.SetValue(i, NULL);
optionBrowser2.SetScrollbar(1);
w.Append(&optionBrowser2); w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true); optionBrowser2.SetClickable(true);
ResumeGui(); ResumeGui();
@ -499,6 +507,8 @@ int MenuSettings()
Settings.wiilight = 0; Settings.wiilight = 0;
if(Settings.rumble >= settings_rumble_max) if(Settings.rumble >= settings_rumble_max)
Settings.rumble = 0; //RUMBLE Settings.rumble = 0; //RUMBLE
if ( Settings.unicodefix > 2 )
Settings.unicodefix = 0;
if(!strcmp("notset", Settings.language_path)) if(!strcmp("notset", Settings.language_path))
options2.SetValue(0, "%s", LANGUAGE.Default); options2.SetValue(0, "%s", LANGUAGE.Default);
@ -538,6 +548,10 @@ int MenuSettings()
if (Settings.rumble == RumbleOn) options2.SetValue(8,"%s",LANGUAGE.ON); if (Settings.rumble == RumbleOn) options2.SetValue(8,"%s",LANGUAGE.ON);
else if (Settings.rumble == RumbleOff) options2.SetValue(8,"%s",LANGUAGE.OFF); 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) if(backBtn.GetState() == STATE_CLICKED)
{ {
backBtn.ResetState(); backBtn.ResetState();
@ -639,6 +653,9 @@ int MenuSettings()
case 8: case 8:
Settings.rumble++; Settings.rumble++;
break; break;
case 9:
Settings.unicodefix++;
break;
} }
} }
optionBrowser2.SetEffect(EFFECT_FADE, -20); optionBrowser2.SetEffect(EFFECT_FADE, -20);
@ -677,7 +694,8 @@ int MenuSettings()
options2.SetName(6, NULL); options2.SetName(6, NULL);
options2.SetName(7, NULL); options2.SetName(7, NULL);
options2.SetName(8, 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); w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true); optionBrowser2.SetClickable(true);
ResumeGui(); ResumeGui();
@ -822,7 +840,8 @@ int MenuSettings()
options2.SetName(6, NULL); options2.SetName(6, NULL);
options2.SetName(7, NULL); options2.SetName(7, NULL);
options2.SetName(8, 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); w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true); optionBrowser2.SetClickable(true);
ResumeGui(); ResumeGui();
@ -988,7 +1007,8 @@ int MenuSettings()
options2.SetName(6, NULL); options2.SetName(6, NULL);
options2.SetName(7, NULL); options2.SetName(7, NULL);
options2.SetName(8, 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); w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true); optionBrowser2.SetClickable(true);
ResumeGui(); ResumeGui();
@ -1135,7 +1155,8 @@ int MenuSettings()
options2.SetName(6, NULL); options2.SetName(6, NULL);
options2.SetName(7, NULL); options2.SetName(7, NULL);
options2.SetName(8, 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); w.Append(&optionBrowser2);
optionBrowser2.SetClickable(true); optionBrowser2.SetClickable(true);
ResumeGui(); ResumeGui();
@ -1303,6 +1324,58 @@ int MenuSettings()
WindowPrompt(LANGUAGE.Themepathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0); WindowPrompt(LANGUAGE.Themepathchange,LANGUAGE.Consoleshouldbeunlockedtomodifyit,LANGUAGE.ok,0,0,0);
} }
break; 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 **/ /** If not godmode don't let him inside **/

View File

@ -12,7 +12,6 @@
#include "../cfg.h" #include "../cfg.h"
#include "gui_customoptionbrowser.h" #include "gui_customoptionbrowser.h"
#include <unistd.h> #include <unistd.h>
@ -110,7 +109,7 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath); snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath);
bgOptionsEntry = new GuiImageData(imgPath, bg_options_entry_png); bgOptionsEntry = new GuiImageData(imgPath, bg_options_entry_png);
if (scrollbaron == 1) {
snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath); snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath);
scrollbar = new GuiImageData(imgPath, scrollbar_png); scrollbar = new GuiImageData(imgPath, scrollbar_png);
scrollbarImg = new GuiImage(scrollbar); scrollbarImg = new GuiImage(scrollbar);
@ -170,7 +169,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
scrollbarBoxBtn->SetMaxY(height-30); scrollbarBoxBtn->SetMaxY(height-30);
scrollbarBoxBtn->SetHoldable(true); scrollbarBoxBtn->SetHoldable(true);
scrollbarBoxBtn->SetTrigger(trigHeldA); scrollbarBoxBtn->SetTrigger(trigHeldA);
}
optionIndex = new int[size]; optionIndex = new int[size];
optionVal = new GuiText * [size]; optionVal = new GuiText * [size];
@ -213,7 +211,6 @@ GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList *
*/ */
GuiCustomOptionBrowser::~GuiCustomOptionBrowser() GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
{ {
if (scrollbaron == 1) {
delete arrowUpBtn; delete arrowUpBtn;
delete arrowDownBtn; delete arrowDownBtn;
delete scrollbarBoxBtn; delete scrollbarBoxBtn;
@ -231,7 +228,7 @@ GuiCustomOptionBrowser::~GuiCustomOptionBrowser()
delete arrowUpOver; delete arrowUpOver;
delete scrollbarBox; delete scrollbarBox;
delete scrollbarBoxOver; delete scrollbarBoxOver;
}
delete bgOptionsImg; delete bgOptionsImg;
delete bgOptions; delete bgOptions;
delete bgOptionsEntry; 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 * FindMenuItem
* *
@ -371,6 +379,7 @@ void GuiCustomOptionBrowser::Draw()
} }
this->UpdateEffects(); this->UpdateEffects();
} }
void GuiCustomOptionBrowser::UpdateListEntries() void GuiCustomOptionBrowser::UpdateListEntries()
{ {
if(listOffset<0) listOffset = this->FindMenuItem(-1, 1); if(listOffset<0) listOffset = this->FindMenuItem(-1, 1);
@ -416,6 +425,7 @@ void GuiCustomOptionBrowser::UpdateListEntries()
} }
} }
} }
void GuiCustomOptionBrowser::Update(GuiTrigger * t) void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{ {
LOCK(this); LOCK(this);
@ -430,11 +440,6 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
} }
int old_listOffset = listOffset; int old_listOffset = listOffset;
// scrolldelay affects how fast the list scrolls
// when the arrows are clicked
float scrolldelay = 3.5;
if (scrollbaron == 1) if (scrollbaron == 1)
{ {
// update the location of the scroll box based on the position in the option list // update the location of the scroll box based on the position in the option list
@ -445,6 +450,9 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
next = listOffset; next = listOffset;
u32 buttonshold = ButtonsHold();
if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) {
for(int i=0; i < size; i++) for(int i=0; i < size; i++)
{ {
if(next >= 0) if(next >= 0)
@ -459,135 +467,20 @@ void GuiCustomOptionBrowser::Update(GuiTrigger * t)
} }
} }
optionBtn[i]->Update(t); optionBtn[i]->Update(t);
if(optionBtn[i]->GetState() == STATE_SELECTED) if(optionBtn[i]->GetState() == STATE_SELECTED)
{ {
selectedItem = i; selectedItem = i;
} }
}
} }
// pad/joystick navigation // pad/joystick navigation
if(!focus) if(!focus)
return; // skip navigation 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); 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) if(old_listOffset != listOffset)
UpdateListEntries(); UpdateListEntries();

View File

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

View File

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