mirror of
https://gitlab.com/Nanolx/homebrewfilter.git
synced 2024-11-25 02:26:56 +01:00
92 lines
2.4 KiB
C++
92 lines
2.4 KiB
C++
|
|
#include <unistd.h>
|
|
|
|
#include "libwiigui/gui.h"
|
|
#include "main.h"
|
|
|
|
/*** Extern variables ***/
|
|
extern GuiWindow * mainWindow;
|
|
|
|
/*** Extern functions ***/
|
|
extern void ResumeGui();
|
|
extern void HaltGui();
|
|
|
|
/****************************************************************************
|
|
* OnScreenKeyboard
|
|
*
|
|
* Opens an on-screen keyboard window, with the data entered being stored
|
|
* into the specified variable.
|
|
***************************************************************************/
|
|
void OnScreenCodeboard(char * var, u16 maxlen)
|
|
{
|
|
int save = -1;
|
|
|
|
GuiCodeboard codeboard(var, maxlen);
|
|
|
|
GuiImageData btnOutline(Theme.button_small);
|
|
GuiImageData btnOutlineOver(Theme.button_small_focus);
|
|
GuiTrigger trigA;
|
|
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
|
|
|
GuiText okBtnTxt("OK", 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
|
|
GuiImage okBtnImg(&btnOutline);
|
|
GuiImage okBtnImgOver(&btnOutlineOver);
|
|
GuiButton okBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
|
|
|
okBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
|
|
okBtn.SetPosition(25, -25);
|
|
|
|
okBtn.SetLabel(&okBtnTxt);
|
|
okBtn.SetImage(&okBtnImg);
|
|
okBtn.SetImageOver(&okBtnImgOver);
|
|
okBtn.SetTrigger(&trigA);
|
|
okBtn.SetEffectGrow();
|
|
|
|
GuiText cancelBtnTxt(tr("Stop"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
|
|
GuiImage cancelBtnImg(&btnOutline);
|
|
GuiImage cancelBtnImgOver(&btnOutlineOver);
|
|
GuiButton cancelBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
|
cancelBtn.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
|
|
cancelBtn.SetPosition(-25, -25);
|
|
cancelBtn.SetLabel(&cancelBtnTxt);
|
|
cancelBtn.SetImage(&cancelBtnImg);
|
|
cancelBtn.SetImageOver(&cancelBtnImgOver);
|
|
cancelBtn.SetTrigger(&trigA);
|
|
cancelBtn.SetEffectGrow();
|
|
|
|
codeboard.Append(&okBtn);
|
|
codeboard.Append(&cancelBtn);
|
|
|
|
HaltGui();
|
|
mainWindow->SetState(STATE_DISABLED);
|
|
mainWindow->Append(&codeboard);
|
|
mainWindow->ChangeFocus(&codeboard);
|
|
ResumeGui();
|
|
|
|
while(save == -1)
|
|
{
|
|
usleep(100);
|
|
|
|
if(strlen(codeboard.kbtextstr) == 4)
|
|
okBtn.SetClickable(true);
|
|
else
|
|
okBtn.SetClickable(false);
|
|
|
|
if(okBtn.GetState() == STATE_CLICKED)
|
|
save = 1;
|
|
else if(cancelBtn.GetState() == STATE_CLICKED)
|
|
save = 0;
|
|
}
|
|
|
|
if(save)
|
|
sprintf(var, "%s", codeboard.kbtextstr);
|
|
else
|
|
sprintf(var, "NULL");
|
|
|
|
HaltGui();
|
|
mainWindow->Remove(&codeboard);
|
|
mainWindow->SetState(STATE_DEFAULT);
|
|
ResumeGui();
|
|
}
|
|
|