add filename text scrolling, improved efficiency on text wrapping, add reset button for mappings

This commit is contained in:
dborth 2009-06-27 19:38:39 +00:00
parent 83b4508566
commit 5f3c4ad61d
15 changed files with 268 additions and 80 deletions

View File

@ -680,6 +680,7 @@ void FreeTypeGX::copyTextureToFramebuffer(GXTexObj *texObj, f32 texWidth, f32 te
GX_Color4u8(color.r, color.g, color.b, color.a); GX_Color4u8(color.r, color.g, color.b, color.a);
GX_TexCoord2f32(0.0f, 1.0f); GX_TexCoord2f32(0.0f, 1.0f);
GX_End(); GX_End();
GX_DrawDone();
this->setDefaultMode(); this->setDefaultMode();
} }
@ -713,6 +714,7 @@ void FreeTypeGX::copyFeatureToFramebuffer(f32 featureWidth, f32 featureHeight, i
GX_Position2s16(screenX, featureHeight + screenY); GX_Position2s16(screenX, featureHeight + screenY);
GX_Color4u8(color.r, color.g, color.b, color.a); GX_Color4u8(color.r, color.g, color.b, color.a);
GX_End(); GX_End();
GX_DrawDone();
this->setDefaultMode(); this->setDefaultMode();
} }

View File

@ -467,7 +467,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
else else
{ {
StripExt(tmpname, fname); // hide file extension StripExt(tmpname, fname); // hide file extension
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY); strncpy (browserList[entrycount].displayname, tmpname, MAXJOLIET);
} }
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4); memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);

View File

@ -413,7 +413,7 @@ void StripExt(char* returnstring, char * inputstring)
{ {
char* loc_dot; char* loc_dot;
strncpy (returnstring, inputstring, 255); strncpy (returnstring, inputstring, MAXJOLIET);
if(inputstring == NULL || strlen(inputstring) < 4) if(inputstring == NULL || strlen(inputstring) < 4)
return; return;

View File

@ -18,7 +18,6 @@
#include <gccore.h> #include <gccore.h>
#define MAXJOLIET 255 #define MAXJOLIET 255
#define MAXDISPLAY 40
typedef struct typedef struct
{ {
@ -35,7 +34,7 @@ typedef struct
time_t mtime; // file modified time time_t mtime; // file modified time
char isdir; // 0 - file, 1 - directory char isdir; // 0 - file, 1 - directory
char filename[MAXJOLIET + 1]; // full filename char filename[MAXJOLIET + 1]; // full filename
char displayname[MAXDISPLAY + 1]; // name for browser display char displayname[MAXJOLIET + 1]; // name for browser display
} BROWSERENTRY; } BROWSERENTRY;
extern BROWSERINFO browser; extern BROWSERINFO browser;

View File

@ -98,6 +98,12 @@ extern const u32 button_png_size;
extern const u8 button_over_png[]; extern const u8 button_over_png[];
extern const u32 button_over_png_size; extern const u32 button_over_png_size;
extern const u8 button_short_png[];
extern const u32 button_short_png_size;
extern const u8 button_short_over_png[];
extern const u32 button_short_over_png_size;
extern const u8 button_small_png[]; extern const u8 button_small_png[];
extern const u32 button_small_png_size; extern const u32 button_small_png_size;

View File

@ -325,7 +325,6 @@ ParseDirectory(int method)
DIR_ITER *dir = NULL; DIR_ITER *dir = NULL;
char fulldir[MAXPATHLEN]; char fulldir[MAXPATHLEN];
char filename[MAXPATHLEN]; char filename[MAXPATHLEN];
char tmpname[MAXPATHLEN];
struct stat filestat; struct stat filestat;
char msg[128]; char msg[128];
int retry = 1; int retry = 1;
@ -397,8 +396,7 @@ ParseDirectory(int method)
} }
else else
{ {
StripExt(tmpname, filename); // hide file extension StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
} }
browserList[entryNum].length = filestat.st_size; browserList[entryNum].length = filestat.st_size;

View File

@ -5,7 +5,7 @@
* Michniewski 2008 * Michniewski 2008
* Tantric September 2008 * Tantric September 2008
* *
* unzip.cpp * gcunzip.cpp
* *
* File unzip routines * File unzip routines
***************************************************************************/ ***************************************************************************/
@ -484,9 +484,9 @@ int SzParse(char * filepath, int method)
} }
memset(&(browserList[SzJ]), 0, sizeof(BROWSERENTRY)); // clear the new entry memset(&(browserList[SzJ]), 0, sizeof(BROWSERENTRY)); // clear the new entry
// parse information about this file to the dvd file list structure // parse information about this file to the file list structure
strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...) strncpy(browserList[SzJ].filename, SzF->Name, MAXJOLIET);
strncpy(browserList[SzJ].displayname, SzF->Name, MAXDISPLAY); // crop name for display StripExt(browserList[SzJ].displayname, browserList[SzJ].filename);
browserList[SzJ].length = SzF->Size; // filesize browserList[SzJ].length = SzF->Size; // filesize
browserList[SzJ].offset = SzI; // the extraction function identifies the file with this number browserList[SzJ].offset = SzI; // the extraction function identifies the file with this number
browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags) browserList[SzJ].isdir = 0; // only files will be displayed (-> no flags)

View File

@ -102,6 +102,12 @@ enum
TRIGGER_BUTTON_ONLY_IN_FOCUS TRIGGER_BUTTON_ONLY_IN_FOCUS
}; };
enum
{
SCROLL_NONE,
SCROLL_HORIZONTAL
};
typedef struct _paddata { typedef struct _paddata {
u16 btns_d; u16 btns_d;
u16 btns_u; u16 btns_u;
@ -613,7 +619,9 @@ class GuiText : public GuiElement
//!Sets the maximum width of the drawn texture image //!Sets the maximum width of the drawn texture image
//!If the text exceeds this, it is wrapped to the next line //!If the text exceeds this, it is wrapped to the next line
//!\param w Maximum width //!\param w Maximum width
void SetMaxWidth(int w); void SetMaxWidth(int width);
void SetScroll(int s);
void SetWrap(bool w, int width = 0);
//!Sets the font color //!Sets the font color
//!\param c Font color //!\param c Font color
void SetColor(GXColor c); void SetColor(GXColor c);
@ -627,9 +635,16 @@ class GuiText : public GuiElement
//!Constantly called to draw the text //!Constantly called to draw the text
void Draw(); void Draw();
protected: protected:
char * origText;
wchar_t* text; //!< Unicode text value wchar_t* text; //!< Unicode text value
int size; //!< Font size int size; //!< Font size
int maxWidth; //!< Maximum width of the generated text object (for text wrapping) int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
bool wrap;
wchar_t* textDyn;
int textScroll;
int textScrollPos;
int textScrollInitialDelay;
int textScrollDelay;
u16 style; //!< FreeTypeGX style attributes u16 style; //!< FreeTypeGX style attributes
GXColor color; //!< Font color GXColor color; //!< Font color
}; };

View File

@ -103,6 +103,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
fileListText[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff}); fileListText[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); fileListText[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
fileListText[i]->SetPosition(5,0); fileListText[i]->SetPosition(5,0);
fileListText[i]->SetMaxWidth(380);
fileListBg[i] = new GuiImage(bgGameSelectionEntry); fileListBg[i] = new GuiImage(bgGameSelectionEntry);
fileListFolder[i] = new GuiImage(gameFolder); fileListFolder[i] = new GuiImage(gameFolder);
@ -375,6 +376,11 @@ void GuiFileBrowser::Update(GuiTrigger * t)
selectedItem = i; selectedItem = i;
browser.selIndex = browser.pageIndex + i; browser.selIndex = browser.pageIndex + i;
} }
if(selectedItem == i)
fileListText[i]->SetScroll(SCROLL_HORIZONTAL);
else
fileListText[i]->SetScroll(SCROLL_NONE);
} }
// update the location of the scroll box based on the position in the file list // update the location of the scroll box based on the position in the file list

View File

@ -18,23 +18,36 @@ static int presetAlignmentVert = 0;
static u16 presetStyle = 0; static u16 presetStyle = 0;
static GXColor presetColor = (GXColor){255, 255, 255, 255}; static GXColor presetColor = (GXColor){255, 255, 255, 255};
#define TEXT_SCROLL_DELAY 8
#define TEXT_SCROLL_INITIAL_DELAY 6
/** /**
* Constructor for the GuiText class. * Constructor for the GuiText class.
*/ */
GuiText::GuiText(const char * t, int s, GXColor c) GuiText::GuiText(const char * t, int s, GXColor c)
{ {
origText = NULL;
text = NULL; text = NULL;
size = s; size = s;
color = c; color = c;
alpha = c.a; alpha = c.a;
style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE; style = FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE;
maxWidth = 0; maxWidth = 0;
wrap = false;
textDyn = NULL;
textScroll = SCROLL_NONE;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
alignmentHor = ALIGN_CENTRE; alignmentHor = ALIGN_CENTRE;
alignmentVert = ALIGN_MIDDLE; alignmentVert = ALIGN_MIDDLE;
if(t) if(t)
{
origText = strdup(t);
text = fontSystem->charToWideChar((char *)t); text = fontSystem->charToWideChar((char *)t);
}
} }
/** /**
@ -42,18 +55,28 @@ GuiText::GuiText(const char * t, int s, GXColor c)
*/ */
GuiText::GuiText(const char * t) GuiText::GuiText(const char * t)
{ {
origText = NULL;
text = NULL; text = NULL;
size = presetSize; size = presetSize;
color = presetColor; color = presetColor;
alpha = presetColor.a; alpha = presetColor.a;
style = presetStyle; style = presetStyle;
maxWidth = presetMaxWidth; maxWidth = presetMaxWidth;
wrap = false;
textDyn = NULL;
textScroll = SCROLL_NONE;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
alignmentHor = presetAlignmentHor; alignmentHor = presetAlignmentHor;
alignmentVert = presetAlignmentVert; alignmentVert = presetAlignmentVert;
if(t) if(t)
{
origText = strdup(t);
text = fontSystem->charToWideChar((char *)t); text = fontSystem->charToWideChar((char *)t);
}
} }
/** /**
@ -61,22 +84,34 @@ GuiText::GuiText(const char * t)
*/ */
GuiText::~GuiText() GuiText::~GuiText()
{ {
if(origText)
free(origText);
if(text) if(text)
{
delete text; delete text;
text = NULL; if(textDyn)
} delete textDyn;
} }
void GuiText::SetText(const char * t) void GuiText::SetText(const char * t)
{ {
if(origText)
free(origText);
if(text) if(text)
delete text; delete text;
if(textDyn)
delete textDyn;
origText = NULL;
text = NULL; text = NULL;
textDyn = NULL;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
if(t) if(t)
{
origText = strdup(t);
text = fontSystem->charToWideChar((char *)t); text = fontSystem->charToWideChar((char *)t);
}
} }
void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v) void GuiText::SetPresets(int sz, GXColor c, int w, u16 s, int h, int v)
@ -94,9 +129,31 @@ void GuiText::SetFontSize(int s)
size = s; size = s;
} }
void GuiText::SetMaxWidth(int w) void GuiText::SetMaxWidth(int width)
{ {
maxWidth = w; maxWidth = width;
}
void GuiText::SetWrap(bool w, int width)
{
wrap = w;
maxWidth = width;
}
void GuiText::SetScroll(int s)
{
if(textScroll == s)
return;
if(textDyn)
{
delete(textDyn);
textDyn = NULL;
}
textScroll = s;
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
textScrollDelay = TEXT_SCROLL_DELAY;
} }
void GuiText::SetColor(GXColor c) void GuiText::SetColor(GXColor c)
@ -170,32 +227,81 @@ void GuiText::Draw()
if(alignmentVert == ALIGN_MIDDLE) if(alignmentVert == ALIGN_MIDDLE)
voffset = -newSize/2 + 2; voffset = -newSize/2 + 2;
if(maxWidth > 0) // text wrapping if(maxWidth > 0)
{
char * tmpText = strdup(origText);
u8 maxChar = (maxWidth*2.0) / newSize;
if(!textDyn)
{
if(strlen(tmpText) > maxChar)
tmpText[maxChar] = 0;
textDyn = fontSystem->charToWideChar(tmpText);
}
if(textScroll == SCROLL_HORIZONTAL)
{
int textlen = strlen(origText);
if(textlen > maxChar && (FrameTimer % textScrollDelay == 0))
{
if(textScrollInitialDelay)
{
textScrollInitialDelay--;
}
else
{
textScrollPos++;
if(textScrollPos > textlen-1)
{
textScrollPos = 0;
textScrollInitialDelay = TEXT_SCROLL_INITIAL_DELAY;
}
strncpy(tmpText, &origText[textScrollPos], maxChar-1);
tmpText[maxChar-1] = 0;
int dynlen = strlen(tmpText);
if(dynlen+2 < maxChar)
{
tmpText[dynlen] = ' ';
tmpText[dynlen+1] = ' ';
strncat(&tmpText[dynlen+2], origText, maxChar - dynlen - 2);
}
if(textDyn) delete textDyn;
textDyn = fontSystem->charToWideChar(tmpText);
}
}
if(textDyn)
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, textDyn, c, style);
}
else if(wrap)
{ {
int lineheight = newSize + 6; int lineheight = newSize + 6;
int strlen = wcslen(text); int txtlen = wcslen(text);
int i = 0; int i = 0;
int ch = 0; int ch = 0;
int linenum = 0; int linenum = 0;
int lastSpace = -1; int lastSpace = -1;
int lastSpaceIndex = -1; int lastSpaceIndex = -1;
wchar_t * tmptext[20]; wchar_t * textrow[20];
while(ch < strlen) while(ch < txtlen)
{ {
if(i == 0) if(i == 0)
tmptext[linenum] = new wchar_t[strlen + 1]; textrow[linenum] = new wchar_t[txtlen + 1];
tmptext[linenum][i] = text[ch]; textrow[linenum][i] = text[ch];
tmptext[linenum][i+1] = 0; textrow[linenum][i+1] = 0;
if(text[ch] == ' ' || ch == strlen-1) if(text[ch] == ' ' || ch == txtlen-1)
{ {
if(fontSystem->getWidth(tmptext[linenum]) >= maxWidth) if(wcslen(textrow[linenum]) >= maxChar)
{ {
if(lastSpace >= 0) if(lastSpace >= 0)
{ {
tmptext[linenum][lastSpaceIndex] = 0; // discard space, and everything after textrow[linenum][lastSpaceIndex] = 0; // discard space, and everything after
ch = lastSpace; // go backwards to the last space ch = lastSpace; // go backwards to the last space
lastSpace = -1; // we have used this space lastSpace = -1; // we have used this space
lastSpaceIndex = -1; lastSpaceIndex = -1;
@ -203,7 +309,7 @@ void GuiText::Draw()
linenum++; linenum++;
i = -1; i = -1;
} }
else if(ch == strlen-1) else if(ch == txtlen-1)
{ {
linenum++; linenum++;
} }
@ -222,11 +328,17 @@ void GuiText::Draw()
for(i=0; i < linenum; i++) for(i=0; i < linenum; i++)
{ {
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, tmptext[i], c, style); fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset+i*lineheight, textrow[i], c, style);
delete tmptext[i]; delete textrow[i];
} }
} }
else else
{
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, textDyn, c, style);
}
free(tmpText);
}
else
{ {
fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style); fontSystem->drawText(this->GetLeft(), this->GetTop()+voffset, text, c, style);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -101,7 +101,6 @@ ParseMCDirectory (int slot)
card_dir CardDir; card_dir CardDir;
int CardError; int CardError;
int entryNum = 0; int entryNum = 0;
char tmpname[MAXPATHLEN];
// Try to mount the card // Try to mount the card
CardError = MountMC(slot, NOTSILENT); CardError = MountMC(slot, NOTSILENT);
@ -127,8 +126,7 @@ ParseMCDirectory (int slot)
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET); strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
StripExt(tmpname, (char *)CardDir.filename); // hide file extension StripExt(browserList[entryNum].displayname, browserList[entryNum].filename); // hide file extension
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
browserList[entryNum].length = CardDir.filelen; browserList[entryNum].length = CardDir.filelen;
entryNum++; entryNum++;

View File

@ -158,7 +158,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label, const ch
GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255}); GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msgTxt.SetPosition(0,-20); msgTxt.SetPosition(0,-20);
msgTxt.SetMaxWidth(430); msgTxt.SetWrap(true, 430);
GuiText btn1Txt(btn1Label, 24, (GXColor){0, 0, 0, 255}); GuiText btn1Txt(btn1Label, 24, (GXColor){0, 0, 0, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
@ -1213,7 +1213,7 @@ static int MenuGame()
resetBtn.SetEffectGrow(); resetBtn.SetEffectGrow();
GuiText gameSettingsBtnTxt("Game Settings", 24, (GXColor){0, 0, 0, 255}); GuiText gameSettingsBtnTxt("Game Settings", 24, (GXColor){0, 0, 0, 255});
gameSettingsBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); gameSettingsBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage gameSettingsBtnImg(&btnLargeOutline); GuiImage gameSettingsBtnImg(&btnLargeOutline);
GuiImage gameSettingsBtnImgOver(&btnLargeOutlineOver); GuiImage gameSettingsBtnImgOver(&btnLargeOutlineOver);
GuiImage gameSettingsBtnIcon(&iconGameSettings); GuiImage gameSettingsBtnIcon(&iconGameSettings);
@ -1788,7 +1788,7 @@ static int MenuGameSettings()
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
GuiText mappingBtnTxt("Button Mappings", 24, (GXColor){0, 0, 0, 255}); GuiText mappingBtnTxt("Button Mappings", 24, (GXColor){0, 0, 0, 255});
mappingBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage mappingBtnImg(&btnLargeOutline); GuiImage mappingBtnImg(&btnLargeOutline);
GuiImage mappingBtnImgOver(&btnLargeOutlineOver); GuiImage mappingBtnImgOver(&btnLargeOutlineOver);
GuiImage mappingBtnIcon(&iconMappings); GuiImage mappingBtnIcon(&iconMappings);
@ -1805,7 +1805,7 @@ static int MenuGameSettings()
mappingBtn.SetEffectGrow(); mappingBtn.SetEffectGrow();
GuiText videoBtnTxt("Video", 24, (GXColor){0, 0, 0, 255}); GuiText videoBtnTxt("Video", 24, (GXColor){0, 0, 0, 255});
videoBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); videoBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage videoBtnImg(&btnLargeOutline); GuiImage videoBtnImg(&btnLargeOutline);
GuiImage videoBtnImgOver(&btnLargeOutlineOver); GuiImage videoBtnImgOver(&btnLargeOutlineOver);
GuiImage videoBtnIcon(&iconVideo); GuiImage videoBtnIcon(&iconVideo);
@ -1969,6 +1969,9 @@ static int MenuGameCheats()
options.length = i; options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Game Settings - Cheats", 28, (GXColor){255, 255, 255, 255}); GuiText titleTxt("Game Settings - Cheats", 28, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50); titleTxt.SetPosition(50,50);
@ -2065,7 +2068,7 @@ static int MenuSettingsMappings()
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiText snesBtnTxt("SNES Controller", 24, (GXColor){0, 0, 0, 255}); GuiText snesBtnTxt("SNES Controller", 24, (GXColor){0, 0, 0, 255});
snesBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); snesBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage snesBtnImg(&btnLargeOutline); GuiImage snesBtnImg(&btnLargeOutline);
GuiImage snesBtnImgOver(&btnLargeOutlineOver); GuiImage snesBtnImgOver(&btnLargeOutlineOver);
GuiImage snesBtnIcon(&iconSNESController); GuiImage snesBtnIcon(&iconSNESController);
@ -2082,7 +2085,7 @@ static int MenuSettingsMappings()
snesBtn.SetEffectGrow(); snesBtn.SetEffectGrow();
GuiText superscopeBtnTxt("Super Scope", 24, (GXColor){0, 0, 0, 255}); GuiText superscopeBtnTxt("Super Scope", 24, (GXColor){0, 0, 0, 255});
superscopeBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); superscopeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage superscopeBtnImg(&btnLargeOutline); GuiImage superscopeBtnImg(&btnLargeOutline);
GuiImage superscopeBtnImgOver(&btnLargeOutlineOver); GuiImage superscopeBtnImgOver(&btnLargeOutlineOver);
GuiImage superscopeBtnIcon(&iconSuperscope); GuiImage superscopeBtnIcon(&iconSuperscope);
@ -2099,7 +2102,7 @@ static int MenuSettingsMappings()
superscopeBtn.SetEffectGrow(); superscopeBtn.SetEffectGrow();
GuiText mouseBtnTxt("SNES Mouse", 24, (GXColor){0, 0, 0, 255}); GuiText mouseBtnTxt("SNES Mouse", 24, (GXColor){0, 0, 0, 255});
mouseBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); mouseBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage mouseBtnImg(&btnLargeOutline); GuiImage mouseBtnImg(&btnLargeOutline);
GuiImage mouseBtnImgOver(&btnLargeOutlineOver); GuiImage mouseBtnImgOver(&btnLargeOutlineOver);
GuiImage mouseBtnIcon(&iconMouse); GuiImage mouseBtnIcon(&iconMouse);
@ -2227,7 +2230,7 @@ static int MenuSettingsMappingsController()
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiText gamecubeBtnTxt("GameCube Controller", 24, (GXColor){0, 0, 0, 255}); GuiText gamecubeBtnTxt("GameCube Controller", 24, (GXColor){0, 0, 0, 255});
gamecubeBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage gamecubeBtnImg(&btnLargeOutline); GuiImage gamecubeBtnImg(&btnLargeOutline);
GuiImage gamecubeBtnImgOver(&btnLargeOutlineOver); GuiImage gamecubeBtnImgOver(&btnLargeOutlineOver);
GuiImage gamecubeBtnIcon(&iconGamecube); GuiImage gamecubeBtnIcon(&iconGamecube);
@ -2260,7 +2263,7 @@ static int MenuSettingsMappingsController()
wiimoteBtn.SetEffectGrow(); wiimoteBtn.SetEffectGrow();
GuiText classicBtnTxt("Classic Controller", 24, (GXColor){0, 0, 0, 255}); GuiText classicBtnTxt("Classic Controller", 24, (GXColor){0, 0, 0, 255});
classicBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); classicBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage classicBtnImg(&btnLargeOutline); GuiImage classicBtnImg(&btnLargeOutline);
GuiImage classicBtnImgOver(&btnLargeOutlineOver); GuiImage classicBtnImgOver(&btnLargeOutlineOver);
GuiImage classicBtnIcon(&iconClassic); GuiImage classicBtnIcon(&iconClassic);
@ -2419,7 +2422,7 @@ ButtonMappingWindow()
GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255}); GuiText msgTxt(msg, 26, (GXColor){0, 0, 0, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msgTxt.SetPosition(0,-20); msgTxt.SetPosition(0,-20);
msgTxt.SetMaxWidth(430); msgTxt.SetWrap(true, 430);
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&titleTxt); promptWindow.Append(&titleTxt);
@ -2516,6 +2519,8 @@ static int MenuSettingsMappingsMap()
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM); GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
GuiImageData btnOutline(button_png); GuiImageData btnOutline(button_png);
GuiImageData btnOutlineOver(button_over_png); GuiImageData btnOutlineOver(button_over_png);
GuiImageData btnShortOutline(button_short_png);
GuiImageData btnShortOutlineOver(button_short_over_png);
GuiTrigger trigA; GuiTrigger trigA;
if(GCSettings.WiimoteOrientation) if(GCSettings.WiimoteOrientation)
@ -2537,6 +2542,20 @@ static int MenuSettingsMappingsMap()
backBtn.SetTrigger(&trigA); backBtn.SetTrigger(&trigA);
backBtn.SetEffectGrow(); backBtn.SetEffectGrow();
GuiText resetBtnTxt("Reset", 24, (GXColor){0, 0, 0, 255});
GuiImage resetBtnImg(&btnShortOutline);
GuiImage resetBtnImgOver(&btnShortOutlineOver);
GuiButton resetBtn(btnShortOutline.GetWidth(), btnShortOutline.GetHeight());
resetBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
resetBtn.SetPosition(260, -35);
resetBtn.SetLabel(&resetBtnTxt);
resetBtn.SetImage(&resetBtnImg);
resetBtn.SetImageOver(&resetBtnImgOver);
resetBtn.SetSoundOver(&btnSoundOver);
resetBtn.SetSoundClick(&btnSoundClick);
resetBtn.SetTrigger(&trigA);
resetBtn.SetEffectGrow();
i=0; i=0;
switch(mapMenuCtrlSNES) switch(mapMenuCtrlSNES)
@ -2578,6 +2597,9 @@ static int MenuSettingsMappingsMap()
break; break;
}; };
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiOptionBrowser optionBrowser(552, 248, &options); GuiOptionBrowser optionBrowser(552, 248, &options);
optionBrowser.SetPosition(0, 108); optionBrowser.SetPosition(0, 108);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
@ -2586,6 +2608,7 @@ static int MenuSettingsMappingsMap()
HaltGui(); HaltGui();
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
w.Append(&backBtn); w.Append(&backBtn);
w.Append(&resetBtn);
mainWindow->Append(&optionBrowser); mainWindow->Append(&optionBrowser);
mainWindow->Append(&w); mainWindow->Append(&w);
mainWindow->Append(&titleTxt); mainWindow->Append(&titleTxt);
@ -2598,13 +2621,16 @@ static int MenuSettingsMappingsMap()
for(i=0; i < options.length; i++) for(i=0; i < options.length; i++)
{ {
options.value[i][0] = 0;
for(j=0; j < ctrlr_def[mapMenuCtrl].num_btns; j++) for(j=0; j < ctrlr_def[mapMenuCtrl].num_btns; j++)
{ {
if(btnmap[mapMenuCtrlSNES][mapMenuCtrl][i] == if(btnmap[mapMenuCtrlSNES][mapMenuCtrl][i] == 0)
{
options.value[i][0] = 0;
}
else if(btnmap[mapMenuCtrlSNES][mapMenuCtrl][i] ==
ctrlr_def[mapMenuCtrl].map[j].btn) ctrlr_def[mapMenuCtrl].map[j].btn)
{ {
if(strcmp(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name) != 0)
sprintf(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name); sprintf(options.value[i], ctrlr_def[mapMenuCtrl].map[j].name);
break; break;
} }
@ -2615,13 +2641,27 @@ static int MenuSettingsMappingsMap()
if(ret >= 0) if(ret >= 0)
{ {
btnmap[mapMenuCtrlSNES][mapMenuCtrl][ret] = ButtonMappingWindow(); // get a button selection from user // get a button selection from user
btnmap[mapMenuCtrlSNES][mapMenuCtrl][ret] = ButtonMappingWindow();
} }
if(backBtn.GetState() == STATE_CLICKED) if(backBtn.GetState() == STATE_CLICKED)
{ {
menu = MENU_GAMESETTINGS_MAPPINGS_CTRL; menu = MENU_GAMESETTINGS_MAPPINGS_CTRL;
} }
else if(resetBtn.GetState() == STATE_CLICKED)
{
resetBtn.ResetState();
int choice = WindowPrompt(
"Reset Mappings",
"Are you sure that you want to reset your mappings?",
"Yes",
"No");
if(choice == 1)
ResetControls(mapMenuCtrlSNES, mapMenuCtrl);
}
} }
HaltGui(); HaltGui();
mainWindow->Remove(&optionBrowser); mainWindow->Remove(&optionBrowser);
@ -2853,6 +2893,9 @@ static int MenuSettingsVideo()
sprintf(options.name[i++], "Video Mode"); sprintf(options.name[i++], "Video Mode");
options.length = i; options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255}); GuiText titleTxt("Game Settings - Video", 28, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50); titleTxt.SetPosition(50,50);
@ -3031,7 +3074,7 @@ static int MenuSettings()
savingBtn.SetEffectGrow(); savingBtn.SetEffectGrow();
GuiText menuBtnTxt("Menu", 24, (GXColor){0, 0, 0, 255}); GuiText menuBtnTxt("Menu", 24, (GXColor){0, 0, 0, 255});
menuBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); menuBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage menuBtnImg(&btnLargeOutline); GuiImage menuBtnImg(&btnLargeOutline);
GuiImage menuBtnImgOver(&btnLargeOutlineOver); GuiImage menuBtnImgOver(&btnLargeOutlineOver);
GuiImage menuBtnIcon(&iconMenu); GuiImage menuBtnIcon(&iconMenu);
@ -3048,7 +3091,7 @@ static int MenuSettings()
menuBtn.SetEffectGrow(); menuBtn.SetEffectGrow();
GuiText networkBtnTxt("Network", 24, (GXColor){0, 0, 0, 255}); GuiText networkBtnTxt("Network", 24, (GXColor){0, 0, 0, 255});
networkBtnTxt.SetMaxWidth(btnLargeOutline.GetWidth()-30); networkBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30);
GuiImage networkBtnImg(&btnLargeOutline); GuiImage networkBtnImg(&btnLargeOutline);
GuiImage networkBtnImgOver(&btnLargeOutlineOver); GuiImage networkBtnImgOver(&btnLargeOutlineOver);
GuiImage networkBtnIcon(&iconNetwork); GuiImage networkBtnIcon(&iconNetwork);
@ -3172,6 +3215,9 @@ static int MenuSettingsFile()
sprintf(options.name[i++], "Verify MC Saves"); sprintf(options.name[i++], "Verify MC Saves");
options.length = i; options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Settings - Saving & Loading", 28, (GXColor){255, 255, 255, 255}); GuiText titleTxt("Settings - Saving & Loading", 28, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50); titleTxt.SetPosition(50,50);
@ -3355,6 +3401,9 @@ static int MenuSettingsMenu()
sprintf(options.name[i++], "Rumble"); sprintf(options.name[i++], "Rumble");
options.length = i; options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Settings - Menu", 28, (GXColor){255, 255, 255, 255}); GuiText titleTxt("Settings - Menu", 28, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50); titleTxt.SetPosition(50,50);
@ -3500,6 +3549,9 @@ static int MenuSettingsNetwork()
sprintf(options.name[i++], "SMB Share Password"); sprintf(options.name[i++], "SMB Share Password");
options.length = i; options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Settings - Network", 28, (GXColor){255, 255, 255, 255}); GuiText titleTxt("Settings - Network", 28, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,50); titleTxt.SetPosition(50,50);

View File

@ -1025,8 +1025,6 @@ ResetVideo_Menu ()
***************************************************************************/ ***************************************************************************/
void Menu_Render() void Menu_Render()
{ {
GX_DrawDone ();
whichfb ^= 1; // flip framebuffer whichfb ^= 1; // flip framebuffer
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE); GX_SetColorUpdate(GX_TRUE);
@ -1086,6 +1084,7 @@ void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[],
GX_Color4u8(0xFF,0xFF,0xFF,alpha); GX_Color4u8(0xFF,0xFF,0xFF,alpha);
GX_TexCoord2f32(0, 1); GX_TexCoord2f32(0, 1);
GX_End(); GX_End();
GX_DrawDone();
GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0); GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
@ -1124,4 +1123,5 @@ void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 f
GX_Color4u8(color.r, color.g, color.b, color.a); GX_Color4u8(color.r, color.g, color.b, color.a);
} }
GX_End(); GX_End();
GX_DrawDone();
} }