Is my usage of VLF correct (i.e. correct cancellation of dialogs, callback usage etc?)
Code: Select all
void OnOffFadeOut(void * ptr)
{
//asm("break\n");
vlfGuiRemoveText(relayname);
vlfGuiCancelCentralMenu();
vlfGuiCancelBottomDialog();
MainMenu(g_relaySel);
}
int BackToMainMenuFromOnOffMenu(int enter)
{
if (enter)
{
if (bConnected)
{
unsigned char msg;
switch (vlfGuiCentralMenuSelection())
{
case 0:
msg = 'A' + (unsigned char)g_relaySel;
sceNetInetSend(g_sock, &msg, 1, 0);
break;
case 1:
msg = 'a' + (unsigned char)g_relaySel;
sceNetInetSend(g_sock, &msg, 1, 0);
break;
}
vlfGuiSetRectangleFade(0, 56, 350, 272 - 56, VLF_FADE_MODE_OUT, VLF_FADE_SPEED_SUPER_FAST, 0, OnOffFadeOut, NULL, 0);
return VLF_EV_RET_REMOVE_HANDLERS;
}
vlfGuiMessageDialog("No connection to Home Automation Server.", VLF_MD_TYPE_ERROR);
return VLF_EV_RET_NOTHING;
}
vlfGuiSetRectangleFade(0, 56, 350, 272 - 56, VLF_FADE_MODE_OUT, VLF_FADE_SPEED_SUPER_FAST, 0, OnOffFadeOut, NULL, 0);
return VLF_EV_RET_REMOVE_HANDLERS;
}
void OnOffMenu(int sel)
{
char *items[] =
{
"On",
"Off"
};
relayname = vlfGuiAddText(240, 90, names[g_relaySel]);
vlfGuiSetTextAlignment(relayname, VLF_ALIGNMENT_CENTER);
vlfGuiCentralMenu(2, items, sel, NULL, 0, 0);
vlfGuiBottomDialog(VLF_DI_ENTER, VLF_DI_CANCEL, 0, 1, VLF_DEFAULT, BackToMainMenuFromOnOffMenu);
vlfGuiSetRectangleFade(0, 56, 350, 272 - 56, VLF_FADE_MODE_IN, VLF_FADE_SPEED_SUPER_FAST, 0, NULL, NULL, 0);
}
void MainMenuFadeOut(void * ptr)
{
vlfGuiCancelCentralMenu();
vlfGuiCancelBottomDialog();
OnOffMenu(g_relayStatus[g_relaySel]?0:1);
}
int MainMenuSelect(int sel)
{
g_relaySel = sel;
vlfGuiSetRectangleFade(0, 56, 480, 272 - 56, VLF_FADE_MODE_OUT, VLF_FADE_SPEED_SUPER_FAST, 0, MainMenuFadeOut, NULL, 0);
return VLF_EV_RET_REMOVE_HANDLERS;
}
void MainMenu(int sel)
{
char *items[] =
{
&names[0][0],
&names[1][0],
&names[2][0],
&names[3][0],
&names[4][0],
&names[5][0],
&names[6][0],
&names[7][0]
};
vlfGuiCentralMenu(8, items, sel, MainMenuSelect, 0, 5);
vlfGuiBottomDialog(VLF_DI_ENTER, VLF_DI_CANCEL, 0, 1, VLF_DEFAULT, NULL);
vlfGuiSetRectangleFade(0, 56, 480, 272 - 56, VLF_FADE_MODE_IN, VLF_FADE_SPEED_SUPER_FAST, 0, NULL, NULL, 0);
}