ctr_Repair/trunk/CardSaveData/Mover/body/source/screen/screen.cpp

869 lines
26 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <wchar.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <nn.h>
#include <stdio.h>
#include "screen.h"
#include "../../../../common/my_defs.h"
#include "../../ver.h"
Gui gui;
u8 scr_evnt;
enum{
//PANEL_END,
PANEL_ERROR,
PANEL_SUCCESS,
PANEL_TOPMENU,
PANEL_TITLE,
PANEL_QUIT,
PANEL_READ,
PANEL_WRITE,
PANEL_YES,
PANEL_NO,
PANEL_CONFIRM,
PANEL_DELCONF,
PANEL_MENU,
PANEL_BKUP,
PANEL_INSEXIT,
PANEL_DBGLOG
};
enum{
MESSAGE_VERSION,
MESSAGE_PRODUCT,
MESSAGE_PRODUCT2,
MESSAGE_ERROR_TITLE,
MESSAGE_ERROR_INFO,
MESSAGE_ERROR_INFO2,
MESSAGE_ERROR_INFO3,
MESSAGE_SUCCESS_TITLE,
MESSAGE_SUCCESS_INFO,
MESSAGE_SUCCESS_INFO2,
MESSAGE_CONFIRM_TITLE,
MESSAGE_CONFIRM_MSG,
MESSAGE_DELCONF_TITLE,
MESSAGE_DELCONF_MSG,
MESSAGE_DELCONF_MSG2,
MESSAGE_DELCONF_MSG3,
//MESSAGE_TOPMENU_HELP_TITLE,
MESSAGE_TOPMENU_HELP_READ,
MESSAGE_TOPMENU_HELP_WRITE,
MESSAGE_TOPMENU_HELP_END,
MESSAGE_TOPMENU_HELP_OPERATE,
MESSAGE_TITLE,
MESSAGE_MENU_READ,
MESSAGE_MENU_WRITE,
//MESSAGE_MENU_END,
MESSAGE_MENU_OPERATE,
MESSAGE_MENU_CAUTION,
MESSAGE_MENU_ERROR,
MESSAGE_MENU_DEBUG,
MESSAGE_INSEXT_1,
MESSAGE_INSEXT_2,
MESSAGE_INSEXT_3,
MESSAGE_OPERATE,
MESSAGE_RESULT,
MESSAGE_QUIT_OPERATE,
MESSAGE_CONF,
MESSAGE_COUNT,
MESSAGE_COUNT2,
MESSAGE_STATUS
};
enum{
MEMO_DBGLOG
};
//画面消去、コンポーネントをディセーブル
void ScrClr()
{
gui.ButtonMask(0);
gui.DisableAll();
gui.Draw();
}
nn::os::Tick holdTck;
u32 holdVal;
//---------------------------------イベントコールバック
//----------------PADボタン
void pushButton(u32 sts)
{
//NN_LOG("button > %4x\n",button);
u32 trg = sts & 0x0ffff;
u32 hld = sts >> 16;
if( holdVal )//押し続け判定
{
if (hld != holdVal)
{
holdVal = 0;
}else
if (nn::fnd::TimeSpan::FromMilliSeconds(4000) < (nn::os::Tick::GetSystemCurrent()-holdTck))
{
holdVal = 0;
scr_evnt = EVNT_PUSH_LEFT_X;
}
}else if (hld == ( nn::hid::BUTTON_LEFT | nn::hid::BUTTON_X ))
{
holdVal = hld;
holdTck = nn::os::Tick::GetSystemCurrent();
}
else if (trg & nn::hid::BUTTON_B)scr_evnt = EVNT_PUSH_B;
}
//-----------------パネルをタッチ
// ---- Top Menu :READ
void touchRead(u32 pos NN_IS_UNUSED_VAR)
{
scr_evnt = EVNT_SEL_READ;
}
// ---- Top Menu :WRITE
void touchWrite(u32 pos NN_IS_UNUSED_VAR)
{
scr_evnt = EVNT_SEL_WRITE;
}
//---- Top Menu :END
//void touchEnd(u32 pos NN_IS_UNUSED_VAR)
//{
// scr_evnt = EVNT_SEL_END;
//}
//---- YES
void touchYes(u32 pos NN_IS_UNUSED_VAR)
{
scr_evnt = EVNT_YES;
}
//---- NO
void touchNo(u32 pos NN_IS_UNUSED_VAR)
{
scr_evnt = EVNT_NO;
}
void touchQuit(u32 pos NN_IS_UNUSED_VAR)
{
scr_evnt = EVNT_QUIT;
}
#define NULL_PTR 0
#define NULL_STR 0
#define SCREEN_UPPER 0
#define SCREEN_LOWER 1
#define LOC_CONF_X 60
#define LOC_CONF_Y 20
#define LOC_CONF_W (400 - LOC_CONF_X*2)
#define LOC_CONF_H 70
#define LOC_LOG_X 50
#define LOC_LOG_W (400 - LOC_LOG_X*2)
#define LOC_LOG_Y (LOC_CONF_Y + LOC_CONF_H + 10)
#define LOC_LOG_H (240 - LOC_LOG_Y - 10)
#define LOG_MAX 10
// -------------------------------------------------- コンポーネント設計
//下画面
#ifdef USE_WCHAR
/*
tChar* S_Backup = L"読込";
tChar* S_Restore = L"書込";
tChar* S_Yes = L"はい";
tChar* S_No = L"いいえ";
tChar* S_Quit = L"戻る";
tChar* S_Space = L" ";
tChar* S_Execute = L"実行しますか?";
tChar* S_HelpBackup = L"[読込] カードから読む";
tChar* S_HelpRestore = L"[書込] カードに書く";
tChar* S_Touch = L"タッチで実行します";
tChar* S_Version = L"";
tChar* S_QuitB = L"タッチかBボタンで戻ります";
tChar* S_Insexit = L"デバイスの挿抜を検知しました";
tChar* S_RetTop = L"開始画面に戻ります";
tChar* S_Del = L" ** 削除 ** ";
tChar* S_Del2 = L"    注意";
tChar* S_Del3 = L"読出したデータを削除します";
tChar* S_Title = L" <カードセーブ移行>";
tChar* S_InsertCard = L"カードを挿入して下さい";
tChar* S_TitleBkup = L" -- カードから読込 --";
tChar* S_TitleRestore = L" -- カードへ書込 --";
*/
tChar* S_Backup = L"Backup";
tChar* S_Restore = L"Restore";
tChar* S_Yes = L"YES";
tChar* S_No = L"NO";
tChar* S_Quit = L"Quit";
tChar* S_Space = L" ";
tChar* S_Execute = L"Do you execute?";
tChar* S_HelpBackup = L"[Backup] read from Card";
tChar* S_HelpRestore = L"[Restore] write to Card";
tChar* S_Touch = L"Touch below";
tChar* S_Version = L"version";
tChar* S_QuitB = L"touch [Quit] or push B";
tChar* S_Insexit = L"device insert or pull out is detected";
tChar* S_RetTop = L"return to top menu";
tChar* S_Del = L" *** DELETE *** ";
tChar* S_Del2 = L" caution!";
tChar* S_Del3 = L"this is delete backup";
tChar* S_Title = L" < CTR Card Savedata Mover >";
tChar* S_InsertCard = L"Please Insert Card";
tChar* S_TitleBkup = L" --- Backup Card Savedata ---";
tChar* S_TitleRestore = L"--- Restore Card Savedata ---";
#else
tChar* S_Backup = "Backup";
tChar* S_Restore = "Restore";
tChar* S_Yes = "YES";
tChar* S_No = "NO";
tChar* S_Quit = "Quit";
tChar* S_Space = " ";
tChar* S_Execute = "Do you execute?";
tChar* S_HelpBackup = "[Backup] read from Card";
tChar* S_HelpRestore = "[Restore] write to Card";
tChar* S_Touch = "Touch below";
tChar* S_Version = "version";
tChar* S_QuitB = "touch [Quit] or push B";
tChar* S_Insexit = "device insert or pull out is detected";
tChar* S_RetTop = "return to top menu";
tChar* S_Del = " *** DELETE *** ";
tChar* S_Del2 = " caution!";
tChar* S_Del3 = "this is delete backup";
tChar* S_Title = " < CTR Card Savedata Mover >";
tChar* S_InsertCard = "Please Insert Card";
tChar* S_TitleBkup = " --- Backup Card Savedata ---";
tChar* S_TitleRestore = "--- Restore Card Savedata ---";
#endif
//Top Menu
const tPanel panel_Read = {(uptr)touchRead,S_Backup,80+20,30,160,80,PANEL_READ,SCREEN_LOWER};
const tPanel panel_Write = {(uptr)touchWrite,S_Restore,80+20,130,160,80,PANEL_WRITE,SCREEN_LOWER};
//const tPanel panel_End = {(uptr)touchEnd,"End",80,180,160,30,PANEL_END,SCREEN_LOWER};
//Yes No
const tPanel panel_Yes = {(uptr)touchYes,S_Yes,40+10,60,80,120,PANEL_YES,SCREEN_LOWER};
const tPanel panel_No = {(uptr)touchNo,S_No,200+30,60,80,120,PANEL_NO,SCREEN_LOWER};
//Quit
const tPanel panel_Quit = {(uptr)touchQuit,S_Quit,80+20,60,160,120,PANEL_QUIT,SCREEN_LOWER};
//上画面
/*
//デバグ用
//エラー表示
const tPanel panel_Error = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_ERROR,SCREEN_UPPER};
const tMessage mess_Title_Err = {S_Space,10,10,COLOR_RED,8,MESSAGE_ERROR_TITLE,PANEL_ERROR};
const tMessage mess_Info_Err = {S_Space,10,22,COLOR_RED,8,MESSAGE_ERROR_INFO,PANEL_ERROR};
const tMessage mess_Info2_Err = {S_Space,10,40,COLOR_RED,8,MESSAGE_ERROR_INFO2,PANEL_ERROR};
const tMessage mess_Info3_Err = {S_Space,10,50,COLOR_RED,8,MESSAGE_ERROR_INFO3,PANEL_ERROR};
//成功
const tPanel panel_Success = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_SUCCESS,SCREEN_UPPER};
const tMessage mess_Title_Suc = {S_Space,10,10,COLOR_GREEN,8,MESSAGE_SUCCESS_TITLE,PANEL_SUCCESS};
const tMessage mess_Info_Suc = {S_Space,10,40,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO,PANEL_SUCCESS};
const tMessage mess_Info2_Suc = {S_Space,10,50,COLOR_WHITE,8,MESSAGE_SUCCESS_INFO2,PANEL_SUCCESS};
//実行確認
const tPanel panel_Confirm = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_CONFIRM,SCREEN_UPPER};
const tMessage mess_conf_Title = {S_Space,10,10,COLOR_YELLO,8,MESSAGE_CONFIRM_TITLE,PANEL_CONFIRM};
const tMessage mess_conf_Msg = {S_Execute,10,40,COLOR_WHITE,8,MESSAGE_CONFIRM_MSG,PANEL_CONFIRM};
//トップメニュー
//const tPanel panel_topmenu_help = {NULL_PTR,NULL_STR,LOC_CONF_X,LOC_CONF_Y,LOC_CONF_W,LOC_CONF_H,PANEL_TOPMENU,SCREEN_UPPER};
//const tMessage mess_topmenu_help_read = {S_HelpBackup,10,4,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_READ,PANEL_TOPMENU};
//const tMessage mess_topmenu_help_write = {S_HelpRestore,10,16,COLOR_WHITE,8,MESSAGE_TOPMENU_HELP_WRITE,PANEL_TOPMENU};
//const tMessage mess_topmenu_help_operate = {S_Touch,10,48,COLOR_GREEN,8,MESSAGE_TOPMENU_HELP_OPERATE,PANEL_TOPMENU};
//ログ表示
const tPanel panel_dbglog = {NULL_PTR,NULL_STR,LOC_LOG_X,LOC_LOG_Y,LOC_LOG_W,LOC_LOG_H,PANEL_DBGLOG,SCREEN_UPPER};
const tMemo memo_dbglog = {LOG_MAX,10,10,COLOR_WHITE,8,MEMO_DBGLOG,PANEL_DBGLOG};
*/
//通常時
//タイトル
#define FONT_SIZE_TITLE 12
#define LOC_TITL_X (40-FONT_SIZE_TITLE*2)
#define LOC_TITL_Y 20
#define LOC_TITL_W (400 - LOC_CONF_X*2)
#define LOC_TITL_H 50
#define FONT_SIZE_PRODUCT 10
const tPanel panel_title = {NULL_PTR,NULL_STR,LOC_TITL_X,LOC_TITL_Y,LOC_TITL_W,LOC_TITL_H,PANEL_TITLE,SCREEN_UPPER};
const tMessage mess_title = {S_Space,0,0,COLOR_WHITE,FONT_SIZE_TITLE,MESSAGE_TITLE,PANEL_TITLE};
const tMessage mess_product = {S_Space,0,LOC_TITL_H - 22,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT,PANEL_TITLE};
const tMessage mess_product2 = {S_Space,0,LOC_TITL_H - 10,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_PRODUCT2,PANEL_TITLE};
const tMessage mess_version = {S_Version,LOC_TITL_W-FONT_SIZE_PRODUCT*6,FONT_SIZE_TITLE+2,COLOR_WHITE,FONT_SIZE_PRODUCT,MESSAGE_VERSION,PANEL_TITLE};
#define LOC_MESS_X 20
#define LOC_MESS_W (400 - LOC_MESS_X*2)
#define LOC_MESS_Y (LOC_TITL_Y + LOC_TITL_H + 10)
#define LOC_MESS_H (240 - LOC_MESS_Y - 10)
//TOPメニュー
#define FONT_SIZE 10
#define STR_LINE(ln) (FONT_SIZE + 2)*ln
const tPanel panel_menu = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_MENU,SCREEN_UPPER};
const tMessage mess_menu_read = {S_HelpBackup,10,STR_LINE(1),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_READ,PANEL_MENU};
const tMessage mess_menu_write = {S_HelpRestore,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_MENU_WRITE,PANEL_MENU};
const tMessage mess_menu_operate = {S_Touch,10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_MENU_OPERATE,PANEL_MENU};
const tMessage mess_bkuperr = {S_Space,10,STR_LINE(6),COLOR_RED,FONT_SIZE,MESSAGE_MENU_ERROR,PANEL_MENU};
const tMessage mess_carderr = {S_Space,10,STR_LINE(7),COLOR_YELLO,FONT_SIZE,MESSAGE_MENU_CAUTION,PANEL_MENU};
//Backup
const tPanel panel_bkup = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_BKUP,SCREEN_UPPER};
const tMessage mess_quit_operate = {S_QuitB,10,STR_LINE(4),COLOR_SKY,FONT_SIZE,MESSAGE_QUIT_OPERATE,PANEL_BKUP};
const tMessage mess_conf = {S_Execute,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_CONF,PANEL_BKUP};
const tMessage mess_result = {S_Space,10,STR_LINE(2),COLOR_WHITE,FONT_SIZE,MESSAGE_RESULT,PANEL_BKUP};
const tMessage mess_operate = {S_Touch,10,STR_LINE(4),COLOR_GREEN,FONT_SIZE,MESSAGE_OPERATE,PANEL_BKUP};
const tMessage mess_status = {S_Space,10,STR_LINE(7),COLOR_WHITE,FONT_SIZE,MESSAGE_STATUS,PANEL_BKUP};
const tMessage mess_count = {S_Space,10,STR_LINE(8),COLOR_WHITE,FONT_SIZE,MESSAGE_COUNT,PANEL_BKUP};
const tMessage mess_count2 = {S_Space,10,STR_LINE(9),COLOR_GREEN,FONT_SIZE,MESSAGE_COUNT2,PANEL_BKUP};
//挿抜発生時
const tPanel panel_insexit = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y,LOC_MESS_W,LOC_MESS_H,PANEL_INSEXIT,SCREEN_UPPER};
const tMessage mess_insexit = {S_Insexit,10,STR_LINE(3),COLOR_RED,8,MESSAGE_INSEXT_1,PANEL_INSEXIT};
const tMessage mess_insexit2 = {S_RetTop,10,STR_LINE(5),COLOR_WHITE,8,MESSAGE_INSEXT_2,PANEL_INSEXIT};
const tMessage mess_insexit3 = {S_QuitB,10,STR_LINE(6),COLOR_WHITE,8,MESSAGE_INSEXT_3,PANEL_INSEXIT};
//削除確認
const tPanel panel_delconf = {NULL_PTR,NULL_STR,LOC_MESS_X,LOC_MESS_Y-36,LOC_MESS_W,LOC_MESS_H,PANEL_DELCONF,SCREEN_UPPER};
const tMessage mess_delconf_Title = {S_Del,10,10,COLOR_YELLO,16,MESSAGE_DELCONF_TITLE,PANEL_DELCONF};
const tMessage mess_delconf_Msg = {S_Del2,10,50,COLOR_YELLO,12,MESSAGE_DELCONF_MSG,PANEL_DELCONF};
const tMessage mess_delconf_Msg2 = {S_Del3,10,70,COLOR_YELLO,12,MESSAGE_DELCONF_MSG2,PANEL_DELCONF};
const tMessage mess_delconf_Msg3 = {S_Execute,10,90,COLOR_YELLO,12,MESSAGE_DELCONF_MSG3,PANEL_DELCONF};
nn::os::LightEvent stopEvnt(true);
tChar scr_ver[16];
tChar scr_err[32];
tChar scr_debug[32];
//menu
bool ScrInitialize(uptr heap,u32 size,bool jp,bool deb)
{
scr_evnt = EVNT_NONE;
holdVal = 0;
holdTck = nn::fnd::TimeSpan(0);
if (gui.Initialize(heap,size,&stopEvnt)==false)return false;
gui.ButtonCallback((uptr)pushButton);
//コンポーネント登録
gui.PanelSet(&panel_Read);
gui.PanelSet(&panel_Write);
// gui.PanelSet(&panel_End);
gui.PanelSet(&panel_Yes);
gui.PanelSet(&panel_No);
gui.PanelSet(&panel_Quit);
// gui.PanelSet(&panel_Error);
// gui.PanelSet(&panel_Success);
// gui.PanelSet(&panel_Confirm);
gui.PanelSet(&panel_delconf);
// gui.PanelSet(&panel_topmenu_help);
gui.PanelSet(&panel_title);
gui.PanelSet(&panel_menu);
gui.PanelSet(&panel_bkup);
// gui.PanelSet(&panel_dbglog);
gui.PanelSet(&panel_insexit);
gui.PanelLineStyle(PANEL_TITLE,COLOR_BLACK);
// gui.MessSet(&mess_Title_Err);
// gui.MessSet(&mess_Info_Err);
// gui.MessSet(&mess_Info2_Err);
// gui.MessSet(&mess_Info3_Err);
// gui.MessSet(&mess_Title_Suc);
// gui.MessSet(&mess_Info_Suc);
// gui.MessSet(&mess_Info2_Suc);
// gui.MessSet(&mess_conf_Title);
// gui.MessSet(&mess_conf_Msg);
gui.MessSet(&mess_delconf_Title);
gui.MessSet(&mess_delconf_Msg);
gui.MessSet(&mess_delconf_Msg2);
gui.MessSet(&mess_delconf_Msg3);
// gui.MessSet(&mess_topmenu_help_read);
// gui.MessSet(&mess_topmenu_help_write);
// gui.MessSet(&mess_topmenu_help_end);
// gui.MessSet(&mess_topmenu_help_operate);
gui.MessSet(&mess_title);
gui.MessSet(&mess_version);
gui.MessSet(&mess_product);
gui.MessSet(&mess_product2);
gui.MessSet(&mess_menu_read);
gui.MessSet(&mess_menu_write);
// gui.MessSet(&mess_menu_end);
gui.MessSet(&mess_menu_operate);
gui.MessSet(&mess_quit_operate);
gui.MessSet(&mess_conf);
gui.MessSet(&mess_operate);
gui.MessSet(&mess_bkuperr);
gui.MessSet(&mess_carderr);
// gui.MessSet(&mess_debug);
gui.MessSet(&mess_result);
gui.MessSet(&mess_status);
gui.MessSet(&mess_count);
gui.MessSet(&mess_count2);
gui.MessSet(&mess_insexit);
gui.MessSet(&mess_insexit2);
gui.MessSet(&mess_insexit3);
// gui.MemoSet(&memo_dbglog);
// gui.MemoEffective(MESSAGE_PRODUCT);
gui.MessEffective(MESSAGE_ERROR_TITLE);
gui.MessEffective(MESSAGE_ERROR_INFO);
gui.MessEffective(MESSAGE_ERROR_INFO2);
gui.MessEffective(MESSAGE_ERROR_INFO3);
gui.MessEffective(MESSAGE_SUCCESS_TITLE);
gui.MessEffective(MESSAGE_SUCCESS_INFO);
gui.MessEffective(MESSAGE_SUCCESS_INFO2);
gui.MessEffective(MESSAGE_CONFIRM_TITLE);
gui.MessEffective(MESSAGE_CONFIRM_MSG);
gui.MessEffective(MESSAGE_DELCONF_TITLE);
gui.MessEffective(MESSAGE_DELCONF_MSG);
gui.MessEffective(MESSAGE_DELCONF_MSG2);
gui.MessEffective(MESSAGE_DELCONF_MSG3);
gui.MessEffective(MESSAGE_TOPMENU_HELP_READ);
gui.MessEffective(MESSAGE_TOPMENU_HELP_WRITE);
gui.MessEffective(MESSAGE_TOPMENU_HELP_END);
gui.MessEffective(MESSAGE_TOPMENU_HELP_OPERATE);
gui.MessEffective(MESSAGE_MENU_READ);
gui.MessEffective(MESSAGE_MENU_WRITE);
// gui.MessEffective(MESSAGE_MENU_END);
gui.MessEffective(MESSAGE_MENU_OPERATE);
gui.MessEffective(MESSAGE_INSEXT_1);
gui.MessEffective(MESSAGE_INSEXT_2);
gui.MessEffective(MESSAGE_INSEXT_3);
gui.MessEffective(MESSAGE_TITLE);
gui.MessEffective(MESSAGE_VERSION);
// gui.MemoEffective(MEMO_DBGLOG);
gui.PanelLineStyle(PANEL_DELCONF,COLOR_YELLO);
#ifdef USE_WCHAR
if (VERSION != 0.0){
swprintf(scr_ver,10,L"ver %.2f",VERSION);
if (deb)wcscat(scr_ver,L" DEBUG");
}else wcscpy(scr_ver,VERSION_TXT_W);
#else
if (VERSION != 0.0){
sprintf(scr_ver,"ver %.2f",VERSION);
if (deb)strcat(scr_ver," DEBUG");
}else strcpy(scr_ver,VERSION_TXT);
#endif
gui.MessStr(MESSAGE_VERSION,scr_ver);
gui.MessStr(MESSAGE_MENU_CAUTION,scr_err);
gui.MessStr(MESSAGE_MENU_ERROR,scr_err);
// gui.MessStr(MESSAGE_MENU_DEBUG,scr_debug);
return true;
}
void ScrFinalize()
{
stopEvnt.Signal();
while(stopEvnt.TryWait()){
nn::os::Thread::Yield();
};
gui.Finalize();
}
//YES-NO ボタン
void YesNo()
{
gui.ButtonMask(nn::hid::BUTTON_A | nn::hid::BUTTON_B);
gui.PanelEffective(PANEL_YES);
gui.PanelEffective(PANEL_NO);
gui.Draw();
}
void Quit()
{
gui.ButtonMask(nn::hid::BUTTON_A | nn::hid::BUTTON_B);
gui.PanelEffective(PANEL_QUIT);
gui.Draw();
}
/*
//トップメニュー画面
//引数:カード状態
void scr_TopMenuDbg(bool formatted,bool insertted)//デバッグ用
{
scr_evnt = EVNT_NONE;
gui.ButtonMask(nn::hid::BUTTON_A | nn::hid::BUTTON_R | nn::hid::BUTTON_L);
if (formatted)
{//リード可能
gui.MessSet(&mess_topmenu_help_read);
gui.PanelEffective(PANEL_READ);
}else{//リード不可
gui.MessSet(&mess_topmenu_help_notread);
gui.PanelEffective(PANEL_READ,false);
}
if (insertted)
{//書き込み可
gui.MessSet(&mess_topmenu_help_write);
gui.PanelEffective(PANEL_WRITE);
}else{//書き込み不可
gui.MessSet(&mess_topmenu_help_notwrite);
gui.PanelEffective(PANEL_WRITE,false);
}
gui.MessEffective(MESSAGE_TOPMENU_HELP_READ);
gui.MessEffective(MESSAGE_TOPMENU_HELP_WRITE);
// gui.PanelEffective(PANEL_END);
gui.PanelEffective(PANEL_TOPMENU);
gui.Draw();
}
*/
//通常時
//プロダクトコード
//引数:カード、拡張セーブに記録されたもの
tChar scr_pcode[32];
tChar scr_pcode2[32];
#ifdef USE_WCHAR
void scr_PrdCode(char *s)
{
wcscpy(scr_pcode,L"CARD : ");
if (s[0]==0) wcscat(scr_pcode,L"----");
else mbstowcs(&scr_pcode[7],s,30);
gui.MessStr(MESSAGE_PRODUCT,scr_pcode);
}
void scr_PrdCodeEx(char *s)
{
wcscpy(scr_pcode2,L"BKUP : ");
if (s[0]==0) wcscat(scr_pcode2,L"----");
else mbstowcs(&scr_pcode2[7],s,30);
gui.MessStr(MESSAGE_PRODUCT2,scr_pcode2);
}
#else
void scr_PrdCode(char *s)
{
strcpy(scr_pcode,"CARD : ");
if (s[0]==0) strcat(scr_pcode,"----");
else strcat(scr_pcode,s);
gui.MessStr(MESSAGE_PRODUCT,scr_pcode);
}
void scr_PrdCodeEx(char *s)
{
strcpy(scr_pcode2,"BKUP : ");
if (s[0]==0) strcat(scr_pcode2,"----");
else strcat(scr_pcode2,s);
gui.MessStr(MESSAGE_PRODUCT2,scr_pcode2);
}
#endif
//削除の実行確認
void scr_DelConf()
{
scr_evnt = EVNT_NONE;
gui.PanelEffective(PANEL_DELCONF);
YesNo();
}
//エラー表示
#ifdef USE_WCHAR
inline void set_err(int i)
{
swprintf(scr_err,16,L"ERROR %d",i);
}
inline void set_err(wchar_t* s)
{
wcscpy(scr_err,s);
}
#else
inline void set_err(int i)
{
sprintf(scr_err,"ERROR %d",i);
}
inline void set_err(char* s)
{
strcpy(scr_err,s);
}
#endif
//Top menu
//引数:デバイス状態
//arg : プロダクトコード一致
void scr_TopMenu(bool formatted,bool inserted,bool exfm,bool bkupins,int err)
{
int i;
scr_evnt = EVNT_NONE;
u32 mask = 0;
mask |= (nn::hid::BUTTON_LEFT | nn::hid::BUTTON_X);//LEFT+X = Delete 有効
gui.MessStr(MESSAGE_TITLE,S_Title);
gui.MessEffective(MESSAGE_MENU_ERROR,false,false);
gui.MessEffective(MESSAGE_MENU_CAUTION,false,false);
gui.MessEffective(MESSAGE_MENU_OPERATE,false,false);
//片方のみ有効
if (formatted && bkupins && (exfm == false))
{//バックアップ
gui.MessEffective(MESSAGE_MENU_OPERATE);
gui.PanelEffective(PANEL_READ);
gui.PanelEffective(PANEL_WRITE,false,false);
}else if (exfm && inserted)
{//リストア
mask |= (nn::hid::BUTTON_LEFT | nn::hid::BUTTON_X);//LEFT+X = Delete 有効
gui.PanelEffective(PANEL_READ,false,false);
i =0;
if (err & SDATA_ERRPUT_PCODE) i = TGT_CARD + ERC_PRODCODE;//プロダクトコード不一致
//else
//if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + TGT_CARD;//バックアップなし
if (i !=0 )
{
gui.PanelEffective(PANEL_WRITE,false,false);
set_err(i);
gui.MessEffective(MESSAGE_MENU_ERROR);
}
else{
gui.MessEffective(MESSAGE_MENU_OPERATE);
gui.PanelEffective(PANEL_WRITE);
}
}else{//なし
gui.PanelEffective(PANEL_WRITE,false,false);
gui.PanelEffective(PANEL_READ,false,false);
if (inserted == false)
{
set_err(S_InsertCard);
gui.MessEffective(MESSAGE_MENU_CAUTION);
}else{
if (err & SDATA_ERRPUT_MEDIA) i = ERC_MEDIA + TGT_CARD;//セーブデータがマウントできない
else if (bkupins == false) i = ERC_DEVICE + TGT_SD;//書出し先デバイスが無い(SDのみ発生)
else i = ERC_EXEC;//実行エラー、フラグ設定ミス?
set_err(i);
gui.MessEffective(MESSAGE_MENU_ERROR);
}
}
gui.ButtonMask(mask);
gui.MessEffective(MESSAGE_PRODUCT);
gui.MessEffective(MESSAGE_PRODUCT2);
gui.PanelEffective(PANEL_TITLE);
gui.PanelEffective(PANEL_MENU);
gui.Draw();
}
//デバッグ用、ボタン待ち
void ScrStep()
{
scr_evnt = EVNT_NONE;
gui.ButtonMask(nn::hid::BUTTON_B);
}
void ClearBkupMess()
{
gui.MessEffective(MESSAGE_CONF,false,false);
gui.MessEffective(MESSAGE_RESULT,false,false);
gui.MessEffective(MESSAGE_OPERATE,false,false);
gui.MessEffective(MESSAGE_QUIT_OPERATE,false,false);
gui.MessEffective(MESSAGE_STATUS,false,false);
gui.MessEffective(MESSAGE_COUNT,false,false);
gui.MessEffective(MESSAGE_COUNT2,false,false);
gui.PanelEffective(PANEL_BKUP);
}
//Backup
void scr_Backup()
{
scr_evnt = EVNT_NONE;
gui.PanelLineStyle(PANEL_BKUP,COLOR_SKY);
gui.MessStr(MESSAGE_TITLE,S_TitleBkup);
gui.PanelEffective(PANEL_TITLE);
ClearBkupMess();
gui.Draw();
}
void scr_BackupYesNo()
{
scr_Backup();
gui.MessEffective(MESSAGE_CONF);
gui.MessEffective(MESSAGE_OPERATE);
YesNo();
}
//restore
void scr_Restore()
{
scr_evnt = EVNT_NONE;
gui.PanelLineStyle(PANEL_BKUP,COLOR_PARPL);
gui.MessStr(MESSAGE_TITLE,S_TitleRestore);
gui.PanelEffective(PANEL_TITLE);
ClearBkupMess();//backupと同じパネルを使う
gui.Draw();
}
void scr_RestoreYesNo()
{
scr_Restore();
gui.MessEffective(MESSAGE_CONF);
gui.MessEffective(MESSAGE_OPERATE);
YesNo();
}
void scr_Status(tChar *s,eColor col)
{
gui.MessCol(MESSAGE_STATUS,col);
gui.MessStr(MESSAGE_STATUS,s);
gui.MessEffective(MESSAGE_STATUS);
gui.Draw();
}
void scr_ResultQuit(tChar *s,eColor col)
{
gui.MessCol(MESSAGE_RESULT,col);
gui.MessStr(MESSAGE_RESULT,s);
gui.MessEffective(MESSAGE_RESULT);
gui.MessEffective(MESSAGE_QUIT_OPERATE);
Quit();
}
void scr_InsExitQuit()
{
ClearBkupMess();
gui.PanelLineStyle(PANEL_INSEXIT,COLOR_RED);
gui.PanelEffective(PANEL_INSEXIT);
Quit();
}
// カウント/MAX 表示
tChar str_Counter[32];
tChar str_Counter2[32];
void scr_CountPerMax(int ct,int max)
{
#ifdef USE_WCHAR
swprintf(str_Counter,30,L"%d / %d",ct,max);
#else
sprintf(str_Counter,"%d / %d",ct,max);
#endif
gui.MessStr(MESSAGE_COUNT,str_Counter);
gui.MessEffective(MESSAGE_COUNT);
gui.Draw();
}
//ゲージtotal
void scr_CountPerMax2(int ct,int max,int total)
{
int i,lv;
if (total == -1) str_Counter2[0]=0;
else if (total != 0){
// gui.MessCol(MESSAGE_COUNT2,COLOR_WHITE);
#ifdef USE_WCHAR
swprintf(str_Counter2,30,L"total size %d",total);
}else{
// gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO);
lv = ct/(max/25);
for (i =0;i<lv;i++)str_Counter2[i] = L'>';
while ( i < 25 )str_Counter2[i++] = L'|';
str_Counter2[i] = 0;
}
#else
sprintf(str_Counter2,"total size %d",total);
}else{
// gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO);
lv = ct/(max/25);
for (i =0;i<lv;i++)str_Counter2[i] = '>';
while ( i < 25 )str_Counter2[i++] = '|';
str_Counter2[i] = 0;
}
#endif
//sprintf(str_Counter2,"%d / %d",ct,max);
gui.MessStr(MESSAGE_COUNT2,str_Counter2);
gui.MessEffective(MESSAGE_COUNT2);
gui.Draw();
}
void scr_MessOnCount2(tChar *str)
{
// gui.MessCol(MESSAGE_COUNT2,COLOR_YELLO);
gui.MessStr(MESSAGE_COUNT2,str);
gui.MessEffective(MESSAGE_COUNT2);
gui.Draw();
}
//実行確認
void scr_ConfirmDbg(tChar *str)
{
scr_evnt = EVNT_NONE;
gui.MessStr(MESSAGE_CONFIRM_TITLE,str);
gui.PanelEffective(PANEL_CONFIRM);
YesNo();
}
//エラー表示とQuitボタン
void scr_ErrorQuitDbg(tColStr **s)
{
scr_evnt = EVNT_NONE;
gui.MessStr(MESSAGE_ERROR_TITLE,s[0]->str);
gui.MessCol(MESSAGE_ERROR_TITLE,s[0]->color);
gui.MessStr(MESSAGE_ERROR_INFO,s[1]->str);
gui.MessCol(MESSAGE_ERROR_INFO,s[1]->color);
gui.MessStr(MESSAGE_ERROR_INFO2,s[2]->str);
gui.MessCol(MESSAGE_ERROR_INFO2,s[2]->color);
gui.MessStr(MESSAGE_ERROR_INFO3,s[3]->str);
gui.MessCol(MESSAGE_ERROR_INFO3,s[3]->color);
gui.PanelEffective(PANEL_ERROR);
Quit();
}
//成功表示とQuitボタン
void scr_SuccessQuitDbg(tColStr **s)
{
scr_evnt = EVNT_NONE;
gui.MessStr(MESSAGE_SUCCESS_TITLE,s[0]->str);
gui.MessCol(MESSAGE_SUCCESS_TITLE,s[0]->color);
gui.MessStr(MESSAGE_SUCCESS_INFO,s[1]->str);
gui.MessCol(MESSAGE_SUCCESS_INFO,s[1]->color);
gui.MessStr(MESSAGE_SUCCESS_INFO2,s[2]->str);
gui.MessCol(MESSAGE_SUCCESS_INFO2,s[2]->color);
gui.PanelEffective(PANEL_SUCCESS);
Quit();
}
void scr_Draw()
{
gui.Draw();
}
void scr_GetEvnt()
{
// gui.thUpdate();
}