mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-24 03:29:22 +01:00
optimizations
This commit is contained in:
parent
775ad14651
commit
8e5eb64a5c
@ -223,11 +223,11 @@ class GuiTrigger
|
||||
//!\return true if selection should be moved down, false otherwise
|
||||
bool Down();
|
||||
|
||||
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
|
||||
s32 chan; //!< Trigger controller channel (0-3, -1 for all)
|
||||
WPADData * wpad; //!< Wii controller trigger
|
||||
WPADData wpaddata; //!< Wii controller trigger data
|
||||
PADData pad; //!< GameCube controller trigger data
|
||||
WPADData * wpad; //!< Wii controller trigger
|
||||
s32 chan; //!< Trigger controller channel (0-3, -1 for all)
|
||||
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
|
||||
};
|
||||
|
||||
extern GuiTrigger userInput[4];
|
||||
@ -399,7 +399,9 @@ class GuiElement
|
||||
//!Called constantly to redraw the element
|
||||
virtual void Draw();
|
||||
protected:
|
||||
bool visible; //!< Visibility of the element. If false, Draw() is skipped
|
||||
GuiTrigger * trigger[2]; //!< GuiTriggers (input actions) that this element responds to
|
||||
UpdateCallback updateCB; //!< Callback function to call when this element is updated
|
||||
GuiElement * parentElement; //!< Parent element
|
||||
int focus; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
|
||||
int width; //!< Element width
|
||||
int height; //!< Element height
|
||||
@ -412,10 +414,9 @@ class GuiElement
|
||||
int xoffsetDyn; //!< Element X offset, dynamic (added to xoffset value for animation effects)
|
||||
int yoffsetDyn; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
|
||||
int alpha; //!< Element alpha value (0-255)
|
||||
f32 scale; //!< Element scale (1 = 100%)
|
||||
int alphaDyn; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
|
||||
f32 scale; //!< Element scale (1 = 100%)
|
||||
f32 scaleDyn; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
|
||||
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
|
||||
int effects; //!< Currently enabled effect(s). 0 when no effects are enabled
|
||||
int effectAmount; //!< Effect amount. Used by different effects for different purposes
|
||||
int effectTarget; //!< Effect target amount. Used by different effects for different purposes
|
||||
@ -429,9 +430,8 @@ class GuiElement
|
||||
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
|
||||
bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
|
||||
bool holdable; //!< Whether or not this element is holdable (can change to HELD state)
|
||||
GuiTrigger * trigger[2]; //!< GuiTriggers (input actions) that this element responds to
|
||||
GuiElement * parentElement; //!< Parent element
|
||||
UpdateCallback updateCB; //!< Callback function to call when this element is updated
|
||||
bool visible; //!< Visibility of the element. If false, Draw() is skipped
|
||||
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
|
||||
};
|
||||
|
||||
//!Allows GuiElements to be grouped together into a "window"
|
||||
@ -650,18 +650,18 @@ class GuiText : public GuiElement
|
||||
//!Constantly called to draw the text
|
||||
void Draw();
|
||||
protected:
|
||||
char * origText; //!< Original text data
|
||||
GXColor color; //!< Font color
|
||||
wchar_t* text; //!< Unicode text value
|
||||
wchar_t* textDyn; //!< Wrapped text value
|
||||
char * origText; //!< Original text data
|
||||
int size; //!< Font size
|
||||
int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
|
||||
bool wrap; //!< Wrapping toggle
|
||||
wchar_t* textDyn; //!< Wrapped text value
|
||||
int textScroll; //!< Scrolling toggle
|
||||
int textScrollPos; //!< Current starting index of text string for scrolling
|
||||
int textScrollInitialDelay; //!< Delay to wait before starting to scroll
|
||||
int textScrollDelay; //!< Scrolling speed
|
||||
u16 style; //!< FreeTypeGX style attributes
|
||||
GXColor color; //!< Font color
|
||||
bool wrap; //!< Wrapping toggle
|
||||
};
|
||||
|
||||
//!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)
|
||||
@ -760,7 +760,6 @@ class GuiKeyboard : public GuiWindow
|
||||
char kbtextstr[256];
|
||||
protected:
|
||||
u32 kbtextmaxlen;
|
||||
Key keys[4][11];
|
||||
int shift;
|
||||
int caps;
|
||||
GuiText * kbText;
|
||||
@ -794,6 +793,7 @@ class GuiKeyboard : public GuiWindow
|
||||
GuiSound * keySoundOver;
|
||||
GuiSound * keySoundClick;
|
||||
GuiTrigger * trigA;
|
||||
Key keys[4][11]; // two chars = less space than one pointer
|
||||
};
|
||||
|
||||
typedef struct _optionlist {
|
||||
@ -818,16 +818,15 @@ class GuiOptionBrowser : public GuiElement
|
||||
void Update(GuiTrigger * t);
|
||||
GuiText * optionVal[PAGESIZE];
|
||||
protected:
|
||||
int selectedItem;
|
||||
int listOffset;
|
||||
bool listChanged;
|
||||
|
||||
OptionList * options;
|
||||
int optionIndex[PAGESIZE];
|
||||
GuiButton * optionBtn[PAGESIZE];
|
||||
GuiText * optionTxt[PAGESIZE];
|
||||
GuiImage * optionBg[PAGESIZE];
|
||||
|
||||
int selectedItem;
|
||||
int listOffset;
|
||||
OptionList * options;
|
||||
|
||||
GuiButton * arrowUpBtn;
|
||||
GuiButton * arrowDownBtn;
|
||||
|
||||
@ -849,6 +848,8 @@ class GuiOptionBrowser : public GuiElement
|
||||
GuiSound * btnSoundOver;
|
||||
GuiSound * btnSoundClick;
|
||||
GuiTrigger * trigA;
|
||||
|
||||
bool listChanged;
|
||||
};
|
||||
|
||||
typedef struct _savelist {
|
||||
@ -874,10 +875,8 @@ class GuiSaveBrowser : public GuiElement
|
||||
void Update(GuiTrigger * t);
|
||||
protected:
|
||||
int selectedItem;
|
||||
int listOffset;
|
||||
int action;
|
||||
bool saveBtnLastOver[SAVELISTSIZE];
|
||||
|
||||
int listOffset;
|
||||
SaveList * saves;
|
||||
GuiButton * saveBtn[SAVELISTSIZE];
|
||||
GuiText * saveDate[SAVELISTSIZE];
|
||||
@ -909,6 +908,8 @@ class GuiSaveBrowser : public GuiElement
|
||||
GuiSound * btnSoundOver;
|
||||
GuiSound * btnSoundClick;
|
||||
GuiTrigger * trigA;
|
||||
|
||||
bool saveBtnLastOver[SAVELISTSIZE];
|
||||
};
|
||||
|
||||
//!Display a list of files
|
||||
@ -924,10 +925,6 @@ class GuiFileBrowser : public GuiElement
|
||||
void Update(GuiTrigger * t);
|
||||
GuiButton * fileList[FILE_PAGESIZE];
|
||||
protected:
|
||||
int selectedItem;
|
||||
int numEntries;
|
||||
bool listChanged;
|
||||
|
||||
GuiText * fileListText[FILE_PAGESIZE];
|
||||
GuiImage * fileListBg[FILE_PAGESIZE];
|
||||
GuiImage * fileListIcon[FILE_PAGESIZE];
|
||||
@ -964,6 +961,10 @@ class GuiFileBrowser : public GuiElement
|
||||
GuiSound * btnSoundClick;
|
||||
GuiTrigger * trigA;
|
||||
GuiTrigger * trigHeldA;
|
||||
|
||||
int selectedItem;
|
||||
int numEntries;
|
||||
bool listChanged;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -130,23 +130,48 @@ void GuiButton::Draw()
|
||||
if(!this->IsVisible())
|
||||
return;
|
||||
|
||||
// draw image
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && imageOver)
|
||||
imageOver->Draw();
|
||||
else if(image)
|
||||
image->Draw();
|
||||
// draw icon
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && iconOver)
|
||||
iconOver->Draw();
|
||||
else if(icon)
|
||||
icon->Draw();
|
||||
// draw text
|
||||
for(int i=0; i<3; i++)
|
||||
if(state == STATE_SELECTED || state == STATE_HELD)
|
||||
{
|
||||
if((state == STATE_SELECTED || state == STATE_HELD) && labelOver[i])
|
||||
labelOver[i]->Draw();
|
||||
else if(label[i])
|
||||
label[i]->Draw();
|
||||
if(imageOver)
|
||||
imageOver->Draw();
|
||||
else if(image) // draw image
|
||||
image->Draw();
|
||||
|
||||
if(iconOver)
|
||||
iconOver->Draw();
|
||||
else if(icon) // draw icon
|
||||
icon->Draw();
|
||||
|
||||
// draw text
|
||||
if(labelOver[0])
|
||||
labelOver[0]->Draw();
|
||||
else if(label[0])
|
||||
label[0]->Draw();
|
||||
|
||||
if(labelOver[1])
|
||||
labelOver[1]->Draw();
|
||||
else if(label[1])
|
||||
label[1]->Draw();
|
||||
|
||||
if(labelOver[2])
|
||||
labelOver[2]->Draw();
|
||||
else if(label[2])
|
||||
label[2]->Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(image) // draw image
|
||||
image->Draw();
|
||||
if(icon) // draw icon
|
||||
icon->Draw();
|
||||
|
||||
// draw text
|
||||
if(label[0])
|
||||
label[0]->Draw();
|
||||
if(label[1])
|
||||
label[1]->Draw();
|
||||
if(label[2])
|
||||
label[2]->Draw();
|
||||
}
|
||||
|
||||
this->UpdateEffects();
|
||||
|
@ -91,7 +91,7 @@ int GuiElement::GetLeft()
|
||||
x = pLeft;
|
||||
break;
|
||||
case ALIGN_CENTRE:
|
||||
x = pLeft + (pWidth/2) - (width/2);
|
||||
x = pLeft + (pWidth>>1) - (width>>1);
|
||||
break;
|
||||
case ALIGN_RIGHT:
|
||||
x = pLeft + pWidth - width;
|
||||
@ -121,7 +121,7 @@ int GuiElement::GetTop()
|
||||
y = pTop;
|
||||
break;
|
||||
case ALIGN_MIDDLE:
|
||||
y = pTop + (pHeight/2) - (height/2);
|
||||
y = pTop + (pHeight>>1) - (height>>1);
|
||||
break;
|
||||
case ALIGN_BOTTOM:
|
||||
y = pTop + pHeight - height;
|
||||
@ -204,15 +204,13 @@ void GuiElement::SetAlpha(int a)
|
||||
|
||||
int GuiElement::GetAlpha()
|
||||
{
|
||||
int a;
|
||||
int a = alpha;
|
||||
|
||||
if(alphaDyn >= 0)
|
||||
a = alphaDyn;
|
||||
else
|
||||
a = alpha;
|
||||
|
||||
if(parentElement)
|
||||
a *= parentElement->GetAlpha()/255.0;
|
||||
a *= float(parentElement->GetAlpha())/255.0f;
|
||||
|
||||
return a;
|
||||
}
|
||||
@ -352,12 +350,11 @@ void GuiElement::SetEffect(int eff, int amount, int target)
|
||||
else if(eff & EFFECT_SLIDE_RIGHT)
|
||||
xoffsetDyn = screenwidth;
|
||||
}
|
||||
if(eff & EFFECT_FADE && amount > 0)
|
||||
if(eff & EFFECT_FADE)
|
||||
{
|
||||
if(amount > 0)
|
||||
alphaDyn = 0;
|
||||
}
|
||||
else if(eff & EFFECT_FADE && amount < 0)
|
||||
{
|
||||
else if(amount < 0)
|
||||
alphaDyn = alpha;
|
||||
}
|
||||
|
||||
@ -474,12 +471,13 @@ void GuiElement::UpdateEffects()
|
||||
}
|
||||
if(effects & EFFECT_SCALE)
|
||||
{
|
||||
scaleDyn += effectAmount/100.0;
|
||||
scaleDyn += f32(effectAmount)*0.01f;
|
||||
f32 effTar100 = f32(effectTarget)*0.01f;
|
||||
|
||||
if((effectAmount < 0 && scaleDyn <= effectTarget/100.0)
|
||||
|| (effectAmount > 0 && scaleDyn >= effectTarget/100.0))
|
||||
if((effectAmount < 0 && scaleDyn <= effTar100)
|
||||
|| (effectAmount > 0 && scaleDyn >= effTar100))
|
||||
{
|
||||
scaleDyn = effectTarget/100.0;
|
||||
scaleDyn = effTar100;
|
||||
effects = 0; // shut off effect
|
||||
}
|
||||
}
|
||||
@ -522,8 +520,8 @@ void GuiElement::Draw()
|
||||
|
||||
bool GuiElement::IsInside(int x, int y)
|
||||
{
|
||||
if(x > this->GetLeft() && x < (this->GetLeft()+width)
|
||||
&& y > this->GetTop() && y < (this->GetTop()+height))
|
||||
if(unsigned(x - this->GetLeft()) < unsigned(width)
|
||||
&& unsigned(y - this->GetTop()) < unsigned(height))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
|
||||
scrollbarBoxBtn->SetHoldable(true);
|
||||
scrollbarBoxBtn->SetTrigger(trigHeldA);
|
||||
|
||||
for(int i=0; i<FILE_PAGESIZE; i++)
|
||||
for(int i=0; i<FILE_PAGESIZE; ++i)
|
||||
{
|
||||
fileListText[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
|
||||
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
|
||||
@ -211,7 +211,7 @@ void GuiFileBrowser::Draw()
|
||||
|
||||
bgFileSelectionImg->Draw();
|
||||
|
||||
for(int i=0; i<FILE_PAGESIZE; i++)
|
||||
for(u32 i=0; i<FILE_PAGESIZE; ++i)
|
||||
{
|
||||
fileList[i]->Draw();
|
||||
}
|
||||
@ -251,7 +251,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
else if(positionWiimote > scrollbarBoxBtn->GetMaxY())
|
||||
positionWiimote = scrollbarBoxBtn->GetMaxY();
|
||||
|
||||
browser.pageIndex = (positionWiimote * browser.numEntries)/156.0 - selectedItem;
|
||||
browser.pageIndex = (positionWiimote * browser.numEntries)/156.0f - selectedItem;
|
||||
|
||||
if(browser.pageIndex <= 0)
|
||||
{
|
||||
@ -312,7 +312,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
if(selectedItem == FILE_PAGESIZE-1)
|
||||
{
|
||||
// move list down by 1
|
||||
browser.pageIndex++;
|
||||
++browser.pageIndex;
|
||||
listChanged = true;
|
||||
}
|
||||
else if(fileList[selectedItem+1]->IsVisible())
|
||||
@ -327,7 +327,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
if(selectedItem == 0 && browser.pageIndex + selectedItem > 0)
|
||||
{
|
||||
// move list up by 1
|
||||
browser.pageIndex--;
|
||||
--browser.pageIndex;
|
||||
listChanged = true;
|
||||
}
|
||||
else if(selectedItem > 0)
|
||||
@ -339,7 +339,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
|
||||
endNavigation:
|
||||
|
||||
for(int i=0; i<FILE_PAGESIZE; i++)
|
||||
for(int i=0; i<FILE_PAGESIZE; ++i)
|
||||
{
|
||||
if(listChanged || numEntries != browser.numEntries)
|
||||
{
|
||||
@ -414,20 +414,24 @@ void GuiFileBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
|
||||
// update the location of the scroll box based on the position in the file list
|
||||
if(positionWiimote > 0 || listChanged || numEntries != browser.numEntries)
|
||||
{
|
||||
if(positionWiimote > 0)
|
||||
{
|
||||
position = positionWiimote; // follow wiimote cursor
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
}
|
||||
else if(listChanged || numEntries != browser.numEntries)
|
||||
{
|
||||
if(float((browser.pageIndex<<1))/(float(FILE_PAGESIZE)) < 1.0)
|
||||
{
|
||||
position = 0;
|
||||
}
|
||||
else if(browser.pageIndex+FILE_PAGESIZE >= browser.numEntries)
|
||||
{
|
||||
position = 156;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = 156*(browser.pageIndex + FILE_PAGESIZE/2.0) / (browser.numEntries*1.0);
|
||||
|
||||
if(browser.pageIndex/(FILE_PAGESIZE/2.0) < 1)
|
||||
position = 0;
|
||||
else if((browser.pageIndex+FILE_PAGESIZE)/(FILE_PAGESIZE*1.0) >= (browser.numEntries)/(FILE_PAGESIZE*1.0))
|
||||
position = 156;
|
||||
position = 156* (int((float(browser.pageIndex) + float(FILE_PAGESIZE)*0.5f) / (float(browser.numEntries))));
|
||||
}
|
||||
scrollbarBoxBtn->SetPosition(0,position+36);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ GuiImage::GuiImage(u8 * img, int w, int h)
|
||||
|
||||
GuiImage::GuiImage(int w, int h, GXColor c)
|
||||
{
|
||||
image = (u8 *)memalign (32, w * h * 4);
|
||||
image = (u8 *)memalign (32, w * h << 2);
|
||||
width = w;
|
||||
height = h;
|
||||
imageangle = 0;
|
||||
@ -66,14 +66,14 @@ GuiImage::GuiImage(int w, int h, GXColor c)
|
||||
|
||||
int x, y;
|
||||
|
||||
for(y=0; y < h; y++)
|
||||
for(y=0; y < h; ++y)
|
||||
{
|
||||
for(x=0; x < w; x++)
|
||||
for(x=0; x < w; ++x)
|
||||
{
|
||||
this->SetPixel(x, y, c);
|
||||
}
|
||||
}
|
||||
int len = w*h*4;
|
||||
int len = w * h << 2;
|
||||
if(len%32) len += (32-len%32);
|
||||
DCFlushRange(image, len);
|
||||
}
|
||||
@ -157,21 +157,24 @@ void GuiImage::SetStripe(int s)
|
||||
|
||||
void GuiImage::ColorStripe(int shift)
|
||||
{
|
||||
int x, y;
|
||||
GXColor color;
|
||||
int x, y=0;
|
||||
int alt = 0;
|
||||
|
||||
for(y=0; y < this->GetHeight(); y++)
|
||||
int thisHeight = this->GetHeight();
|
||||
int thisWidth = this->GetWidth();
|
||||
|
||||
for(; y < thisHeight; ++y)
|
||||
{
|
||||
if(y % 3 == 0)
|
||||
alt ^= 1;
|
||||
|
||||
for(x=0; x < this->GetWidth(); x++)
|
||||
if(alt)
|
||||
{
|
||||
for(x=0; x < thisWidth; ++x)
|
||||
{
|
||||
color = GetPixel(x, y);
|
||||
|
||||
if(alt)
|
||||
{
|
||||
if(color.r < 255-shift)
|
||||
color.r += shift;
|
||||
else
|
||||
@ -186,9 +189,15 @@ void GuiImage::ColorStripe(int shift)
|
||||
color.b = 255;
|
||||
|
||||
color.a = 255;
|
||||
SetPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(x=0; x < thisWidth; ++x)
|
||||
{
|
||||
color = GetPixel(x, y);
|
||||
|
||||
if(color.r > shift)
|
||||
color.r -= shift;
|
||||
else
|
||||
@ -203,10 +212,10 @@ void GuiImage::ColorStripe(int shift)
|
||||
color.b = 0;
|
||||
|
||||
color.a = 255;
|
||||
}
|
||||
SetPixel(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,24 +228,31 @@ void GuiImage::Draw()
|
||||
|
||||
float currScale = this->GetScale();
|
||||
int currLeft = this->GetLeft();
|
||||
int thisTop = this->GetTop();
|
||||
|
||||
if(tile > 0)
|
||||
{
|
||||
for(int i=0; i<tile; i++)
|
||||
Menu_DrawImg(currLeft+width*i, this->GetTop(), width, height, image, imageangle, currScale, currScale, this->GetAlpha());
|
||||
int alpha = this->GetAlpha();
|
||||
for(int i=0; i<tile; ++i)
|
||||
{
|
||||
Menu_DrawImg(currLeft+width*i, thisTop, width, height, image, imageangle, currScale, currScale, alpha);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// temporary (maybe), used to correct offset for scaled images
|
||||
if(scale != 1)
|
||||
currLeft = currLeft - width/2 + (width*scale)/2;
|
||||
currLeft += (width*(scale - 1))/2;
|
||||
|
||||
Menu_DrawImg(currLeft, this->GetTop(), width, height, image, imageangle, currScale, currScale, this->GetAlpha());
|
||||
Menu_DrawImg(currLeft, thisTop, width, height, image, imageangle, currScale, currScale, this->GetAlpha());
|
||||
}
|
||||
|
||||
if(stripe > 0)
|
||||
for(int y=0; y < this->GetHeight(); y+=6)
|
||||
Menu_DrawRectangle(currLeft,this->GetTop()+y,this->GetWidth(),3,(GXColor){0, 0, 0, stripe},1);
|
||||
|
||||
{
|
||||
int thisHeight = this->GetHeight();
|
||||
int thisWidth = this->GetWidth();
|
||||
for(int y=0; y < thisHeight; y+=6)
|
||||
Menu_DrawRectangle(currLeft,thisTop+y,thisWidth,3,(GXColor){0, 0, 0, stripe},1);
|
||||
}
|
||||
this->UpdateEffects();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ GuiImageData::GuiImageData(const u8 * i)
|
||||
|
||||
if(res == PNGU_OK)
|
||||
{
|
||||
int len = imgProp.imgWidth * imgProp.imgHeight * 4;
|
||||
int len = (imgProp.imgWidth * imgProp.imgHeight) <<2;
|
||||
if(len%32) len += (32-len%32);
|
||||
data = (u8 *)memalign (32, len);
|
||||
|
||||
|
@ -211,7 +211,7 @@ void GuiOptionBrowser::Draw()
|
||||
|
||||
int next = listOffset;
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
for(int i=0; i<PAGESIZE; ++i)
|
||||
{
|
||||
if(next >= 0)
|
||||
{
|
||||
@ -249,7 +249,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
if(listChanged)
|
||||
{
|
||||
listChanged = false;
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
for(int i=0; i<PAGESIZE; ++i)
|
||||
{
|
||||
if(next >= 0)
|
||||
{
|
||||
@ -272,7 +272,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<PAGESIZE; i++)
|
||||
for(int i=0; i<PAGESIZE; ++i)
|
||||
{
|
||||
if(i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED)
|
||||
optionBtn[i]->ResetState();
|
||||
@ -311,7 +311,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
{
|
||||
optionBtn[selectedItem]->ResetState();
|
||||
optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
|
||||
selectedItem++;
|
||||
++selectedItem;
|
||||
}
|
||||
}
|
||||
arrowDownBtn->ResetState();
|
||||
@ -332,7 +332,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
|
||||
{
|
||||
optionBtn[selectedItem]->ResetState();
|
||||
optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
|
||||
selectedItem--;
|
||||
--selectedItem;
|
||||
}
|
||||
}
|
||||
arrowUpBtn->ResetState();
|
||||
|
@ -107,7 +107,7 @@ GuiSaveBrowser::GuiSaveBrowser(int w, int h, SaveList * s, int a)
|
||||
saveBtn[i]->SetImageOver(saveBgOverImg[i]);
|
||||
saveBtn[i]->SetIcon(savePreviewImg[i]);
|
||||
saveBtn[i]->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
|
||||
saveBtn[i]->SetPosition(257*(i % 2),87*(i/2));
|
||||
saveBtn[i]->SetPosition(257*(i % 2),87*(i>>1));
|
||||
saveBtn[i]->SetTrigger(trigA);
|
||||
saveBtn[i]->SetState(STATE_DISABLED);
|
||||
saveBtn[i]->SetEffectGrow();
|
||||
@ -257,7 +257,7 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
||||
if(selectedItem == 0)
|
||||
{
|
||||
if((listOffset - 2 >= 0 && action == 0) ||
|
||||
(listOffset - 2 >= -2 && action == 1))
|
||||
(listOffset >= 0 && action == 1))
|
||||
{
|
||||
// move list up by 1
|
||||
listOffset -= 2;
|
||||
@ -295,7 +295,7 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
||||
if(selectedItem < 2)
|
||||
{
|
||||
if((listOffset - 2 >= 0 && action == 0) ||
|
||||
(listOffset - 2 >= -2 && action == 1))
|
||||
(listOffset >= 0 && action == 1))
|
||||
{
|
||||
// move list up by 1
|
||||
listOffset -= 2;
|
||||
|
@ -42,7 +42,7 @@ void GuiSound::Play()
|
||||
switch(type)
|
||||
{
|
||||
case SOUND_PCM:
|
||||
vol = 255*(volume/100.0)*(GCSettings.SFXVolume/100.0);
|
||||
vol = 2.55f*(volume*GCSettings.SFXVolume);
|
||||
voice = ASND_GetFirstUnusedVoice();
|
||||
if(voice >= 0)
|
||||
ASND_SetVoice(voice, VOICE_STEREO_16BIT, 48000, 0,
|
||||
@ -55,7 +55,7 @@ void GuiSound::Play()
|
||||
PlayOgg((char *)sound, length, 0, OGG_INFINITE_TIME);
|
||||
else
|
||||
PlayOgg((char *)sound, length, 0, OGG_ONE_TIME);
|
||||
SetVolumeOgg(255*(volume/100.0));
|
||||
SetVolumeOgg(2.55f*(volume));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -134,7 +134,7 @@ void GuiSound::SetVolume(int vol)
|
||||
if(voice < 0)
|
||||
return;
|
||||
|
||||
int newvol = 255*(volume/100.0)*(GCSettings.SFXVolume/100.0);
|
||||
int newvol = 2.55f*(volume*GCSettings.SFXVolume);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
@ -143,7 +143,7 @@ void GuiSound::SetVolume(int vol)
|
||||
break;
|
||||
|
||||
case SOUND_OGG:
|
||||
SetVolumeOgg(255*(volume/100.0));
|
||||
SetVolumeOgg(2.55f*(volume));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -10,13 +10,13 @@
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
static GXColor presetColor = (GXColor){255, 255, 255, 255};
|
||||
static int currentSize = 0;
|
||||
static int presetSize = 0;
|
||||
static int presetMaxWidth = 0;
|
||||
static int presetAlignmentHor = 0;
|
||||
static int presetAlignmentVert = 0;
|
||||
static u16 presetStyle = 0;
|
||||
static GXColor presetColor = (GXColor){255, 255, 255, 255};
|
||||
|
||||
#define TEXT_SCROLL_DELAY 8
|
||||
#define TEXT_SCROLL_INITIAL_DELAY 6
|
||||
@ -230,7 +230,7 @@ void GuiText::Draw()
|
||||
if(maxWidth > 0)
|
||||
{
|
||||
char * tmpText = strdup(origText);
|
||||
u8 maxChar = (maxWidth*2.0) / newSize;
|
||||
u8 maxChar = int((float((maxWidth<<1))) / (float(newSize)));
|
||||
|
||||
if(!textDyn)
|
||||
{
|
||||
@ -247,11 +247,11 @@ void GuiText::Draw()
|
||||
{
|
||||
if(textScrollInitialDelay)
|
||||
{
|
||||
textScrollInitialDelay--;
|
||||
--textScrollInitialDelay;
|
||||
}
|
||||
else
|
||||
{
|
||||
textScrollPos++;
|
||||
++textScrollPos;
|
||||
if(textScrollPos > textlen-1)
|
||||
{
|
||||
textScrollPos = 0;
|
||||
@ -306,12 +306,12 @@ void GuiText::Draw()
|
||||
lastSpace = -1; // we have used this space
|
||||
lastSpaceIndex = -1;
|
||||
}
|
||||
linenum++;
|
||||
++linenum;
|
||||
i = -1;
|
||||
}
|
||||
else if(ch == txtlen-1)
|
||||
{
|
||||
linenum++;
|
||||
++linenum;
|
||||
}
|
||||
}
|
||||
if(text[ch] == ' ' && i >= 0)
|
||||
@ -319,18 +319,21 @@ void GuiText::Draw()
|
||||
lastSpace = ch;
|
||||
lastSpaceIndex = i;
|
||||
}
|
||||
ch++;
|
||||
i++;
|
||||
++ch;
|
||||
++i;
|
||||
}
|
||||
|
||||
int voffset = 0;
|
||||
|
||||
if(alignmentVert == ALIGN_MIDDLE)
|
||||
voffset = -(lineheight*linenum)/2 + lineheight/2;
|
||||
voffset = (lineheight >> 1) * (1-linenum);
|
||||
|
||||
for(i=0; i < linenum; i++)
|
||||
int left = this->GetLeft();
|
||||
int top = this->GetTop() + voffset;
|
||||
|
||||
for(i=0; i < linenum; ++i)
|
||||
{
|
||||
fontSystem[currentSize]->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, textrow[i], c, style);
|
||||
fontSystem[currentSize]->drawText(left, top+i*lineheight, textrow[i], c, style);
|
||||
delete[] textrow[i];
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,8 @@ void GuiWindow::Remove(GuiElement* e)
|
||||
if (e == NULL)
|
||||
return;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
if(e == _elements.at(i))
|
||||
{
|
||||
@ -85,7 +86,8 @@ void GuiWindow::Draw()
|
||||
if(_elements.size() == 0 || !this->IsVisible())
|
||||
return;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try { _elements.at(i)->Draw(); }
|
||||
catch (const std::exception& e) { }
|
||||
@ -102,7 +104,8 @@ void GuiWindow::ResetState()
|
||||
if(state != STATE_DISABLED)
|
||||
state = STATE_DEFAULT;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try { _elements.at(i)->ResetState(); }
|
||||
catch (const std::exception& e) { }
|
||||
@ -113,7 +116,8 @@ void GuiWindow::SetState(int s)
|
||||
{
|
||||
state = s;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try { _elements.at(i)->SetState(s); }
|
||||
catch (const std::exception& e) { }
|
||||
@ -124,7 +128,8 @@ void GuiWindow::SetVisible(bool v)
|
||||
{
|
||||
visible = v;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try { _elements.at(i)->SetVisible(v); }
|
||||
catch (const std::exception& e) { }
|
||||
@ -146,7 +151,8 @@ void GuiWindow::ChangeFocus(GuiElement* e)
|
||||
if(parentElement)
|
||||
return; // this is only intended for the main window
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
if(e == _elements.at(i))
|
||||
_elements.at(i)->SetFocus(1);
|
||||
@ -162,10 +168,12 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
|
||||
int found = -1;
|
||||
int newfocus = -1;
|
||||
u8 i;
|
||||
int i;
|
||||
|
||||
int elemSize = _elements.size();
|
||||
|
||||
// look for currently in focus element
|
||||
for (i = 0; i < _elements.size(); i++)
|
||||
for (i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -181,7 +189,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
// element with focus not found, try to give focus
|
||||
if(found == -1)
|
||||
{
|
||||
for (i = 0; i < _elements.size(); i++)
|
||||
for (i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -198,7 +206,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
else if(t->wpad->btns_d & (WPAD_BUTTON_1 | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)
|
||||
|| t->pad.btns_d & PAD_BUTTON_B)
|
||||
{
|
||||
for (i = found; i < _elements.size(); i++)
|
||||
for (i = found; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -215,7 +223,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
|
||||
|
||||
if(newfocus == -1)
|
||||
{
|
||||
for (i = 0; i < found; i++)
|
||||
for (i = 0; i < found; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -236,13 +244,14 @@ int GuiWindow::GetSelected()
|
||||
{
|
||||
// find selected element
|
||||
int found = -1;
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(_elements.at(i)->GetState() == STATE_SELECTED)
|
||||
{
|
||||
found = i;
|
||||
found = int(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -258,7 +267,8 @@ void GuiWindow::MoveSelectionHor(int dir)
|
||||
int found = -1;
|
||||
u16 left = 0;
|
||||
u16 top = 0;
|
||||
u8 i = 0;
|
||||
u32 i;
|
||||
u32 elemSize = _elements.size();
|
||||
|
||||
int selected = this->GetSelected();
|
||||
|
||||
@ -268,8 +278,9 @@ void GuiWindow::MoveSelectionHor(int dir)
|
||||
top = _elements.at(selected)->GetTop();
|
||||
}
|
||||
|
||||
|
||||
// look for a button on the same row, to the left/right
|
||||
for (i = 0; i < _elements.size(); i++)
|
||||
for (i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -278,9 +289,9 @@ void GuiWindow::MoveSelectionHor(int dir)
|
||||
if(_elements.at(i)->GetLeft()*dir > left*dir && _elements.at(i)->GetTop() == top)
|
||||
{
|
||||
if(found == -1)
|
||||
found = i;
|
||||
found = int(i);
|
||||
else if(_elements.at(i)->GetLeft()*dir < _elements.at(found)->GetLeft()*dir)
|
||||
found = i; // this is a better match
|
||||
found = int(i); // this is a better match
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +301,7 @@ void GuiWindow::MoveSelectionHor(int dir)
|
||||
goto matchfound;
|
||||
|
||||
// match still not found, let's try the first button in the next row
|
||||
for (i = 0; i < _elements.size(); i++)
|
||||
for (i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -327,7 +338,6 @@ void GuiWindow::MoveSelectionVert(int dir)
|
||||
int found = -1;
|
||||
u16 left = 0;
|
||||
u16 top = 0;
|
||||
u8 i = 0;
|
||||
|
||||
int selected = this->GetSelected();
|
||||
|
||||
@ -338,7 +348,8 @@ void GuiWindow::MoveSelectionVert(int dir)
|
||||
}
|
||||
|
||||
// look for a button above/below, with the least horizontal difference
|
||||
for (i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -378,7 +389,8 @@ void GuiWindow::Update(GuiTrigger * t)
|
||||
if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement))
|
||||
return;
|
||||
|
||||
for (u8 i = 0; i < _elements.size(); i++)
|
||||
u32 elemSize = _elements.size();
|
||||
for (u32 i = 0; i < elemSize; ++i)
|
||||
{
|
||||
try { _elements.at(i)->Update(t); }
|
||||
catch (const std::exception& e) { }
|
||||
|
@ -264,19 +264,23 @@ UpdateGUI (void *arg)
|
||||
mainWindow->Draw();
|
||||
|
||||
#ifdef HW_RVL
|
||||
for(i=3; i >= 0; i--) // so that player 1's cursor appears on top!
|
||||
i = 3;
|
||||
do
|
||||
{
|
||||
if(userInput[i].wpad->ir.valid)
|
||||
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
|
||||
96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
|
||||
DoRumble(i);
|
||||
}
|
||||
--i;
|
||||
} while(i>=0);
|
||||
#endif
|
||||
|
||||
Menu_Render();
|
||||
|
||||
for(i=3; i >= 0; i--)
|
||||
mainWindow->Update(&userInput[i]);
|
||||
mainWindow->Update(&userInput[3]);
|
||||
mainWindow->Update(&userInput[2]);
|
||||
mainWindow->Update(&userInput[1]);
|
||||
mainWindow->Update(&userInput[0]);
|
||||
|
||||
#ifdef HW_RVL
|
||||
if(updateFound)
|
||||
@ -416,12 +420,12 @@ ProgressWindow(char *title, char *msg)
|
||||
{
|
||||
if(count % 5 == 0)
|
||||
{
|
||||
angle+=45;
|
||||
if(angle >= 360)
|
||||
angle+=45.0f;
|
||||
if(angle >= 360.0f)
|
||||
angle = 0;
|
||||
throbberImg.SetAngle(angle);
|
||||
}
|
||||
count++;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
@ -844,21 +848,24 @@ static void WindowCredits(void * ptr)
|
||||
bgTopImg->Draw();
|
||||
creditsWindow.Draw();
|
||||
|
||||
for(i=3; i >= 0; i--)
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
i = 3;
|
||||
do {
|
||||
if(userInput[i].wpad->ir.valid)
|
||||
Menu_DrawImg(userInput[i].wpad->ir.x-48, userInput[i].wpad->ir.y-48,
|
||||
96, 96, pointer[i]->GetImage(), userInput[i].wpad->ir.angle, 1, 1, 255);
|
||||
DoRumble(i);
|
||||
--i;
|
||||
} while(i >= 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
Menu_Render();
|
||||
|
||||
for(i=0; i < 4; i++)
|
||||
if((userInput[0].wpad->btns_d || userInput[0].pad.btns_d) ||
|
||||
(userInput[1].wpad->btns_d || userInput[1].pad.btns_d) ||
|
||||
(userInput[2].wpad->btns_d || userInput[2].pad.btns_d) ||
|
||||
(userInput[3].wpad->btns_d || userInput[3].pad.btns_d))
|
||||
{
|
||||
if(userInput[i].wpad->btns_d || userInput[i].pad.btns_d)
|
||||
exit = true;
|
||||
}
|
||||
usleep(THREAD_SLEEP);
|
||||
@ -1362,7 +1369,7 @@ static int MenuGame()
|
||||
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE)
|
||||
{
|
||||
newStatus = true;
|
||||
newLevel = (userInput[i].wpad->battery_level / 100.0) * 4;
|
||||
newLevel = int(userInput[i].wpad->battery_level / 100.0) << 2;
|
||||
if(newLevel > 4) newLevel = 4;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user