/***************************************************************************

	mesbox.c

	Message Box

***************************************************************************/

#include "psp.h"

#define HELP_MES_MAX	13

#define HELP_COLOR_ENABLE	&ui_palette[UI_PAL_SELECT].r, &ui_palette[UI_PAL_SELECT].g, &ui_palette[UI_PAL_SELECT].b
#define HELP_COLOR_DISABLE	&ui_palette[UI_PAL_NORMAL].r, &ui_palette[UI_PAL_NORMAL].g, &ui_palette[UI_PAL_NORMAL].b
#define HELP_COLOR_NORMAL	&ui_palette[UI_PAL_NORMAL].r, &ui_palette[UI_PAL_NORMAL].g, &ui_palette[UI_PAL_NORMAL].b

#define HELP_ENABLE(s1, s2)	{ HELP_COLOR_ENABLE, s1, s2 }
#if JAPANESE_UI
#define HELP_DISABLE(s1)	{ HELP_COLOR_DISABLE, s1, "使用しません" }
#else
#define HELP_DISABLE(s1)	{ HELP_COLOR_DISABLE, s1, "Not use" }
#endif
#define HELP_SKIP			{ HELP_COLOR_NORMAL, "\n", "\0" }
#define HELP_EOM			{ HELP_COLOR_NORMAL, "\0", "\0" }


/***************************************************************************
	Private structures
 ***************************************************************************/

typedef struct message_t
{
	int *r, *g, *b;
	const char *text1;
	const char *text2;
} UI_MESSAGE;

typedef struct help_t
{
	const char *menu_name;
	const UI_MESSAGE mes[HELP_MES_MAX];
} UI_HELP;


const static UI_HELP help_mes[HELP_NUM_MAX] =
{
	// HELP_FILEBROWSER
	{
#if JAPANESE_UI
		"ファイルブラウザ",
#else
		"File browser",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "カーソ\ルを移動"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "カーソ\ルを1ページ分移動"),
			HELP_ENABLE(FONT_CIRCLE, "ゲームを起動"),
			HELP_DISABLE(FONT_CROSS),
			HELP_ENABLE(FONT_SQUARE, "BIOSを起動"),
			HELP_ENABLE(FONT_TRIANGLE, "エミュレータを終了"),
			HELP_ENABLE(FONT_LTRIGGER, "カラー設定メニューを開く"),
			HELP_ENABLE(FONT_RTRIGGER, "このヘルプを開く"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_ENABLE("SELECT", "選択中のディレクトリを起動ディレクトリに設定"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Scroll"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Scroll 1 page"),
			HELP_ENABLE(FONT_CIRCLE, "Launch game"),
			HELP_DISABLE(FONT_CROSS),
			HELP_ENABLE(FONT_SQUARE, "Boot BIOS"),
			HELP_ENABLE(FONT_TRIANGLE, "Exit emulator"),
			HELP_ENABLE(FONT_LTRIGGER, "Open color settings menu"),
			HELP_ENABLE(FONT_RTRIGGER, "Show this help"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_ENABLE("SELECT", "Set selected directory as start up"),
#endif
			HELP_EOM
		}
	},
	// HELP_GAMECONFIG
	{
#if JAPANESE_UI
		"ゲーム設定メニュー",
#else
		"Game configration menu",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "カーソ\ルを移動"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "値を変更"),
			HELP_ENABLE(FONT_CIRCLE, "選択"),
			HELP_ENABLE(FONT_CROSS, "メインメニューに戻る"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "このヘルプを開く"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_DISABLE("SELECT"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Scroll"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Change value"),
			HELP_ENABLE(FONT_CIRCLE, "Select"),
			HELP_ENABLE(FONT_CROSS, "Return to main menu"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "Show this help"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_DISABLE("SELECT"),
#endif
			HELP_EOM
		}
	},
	// HELP_KEYCONFIG
	{
#if JAPANESE_UI
		"入力ボタン設定メニュー",
#else
		"Key configration menu",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "カーソ\ルを移動"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "値を変更"),
			HELP_ENABLE(FONT_CIRCLE, "選択"),
			HELP_ENABLE(FONT_CROSS, "メインメニューに戻る"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "このヘルプを開く"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_DISABLE("SELECT"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Scroll"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Change value"),
			HELP_ENABLE(FONT_CIRCLE, "Select"),
			HELP_ENABLE(FONT_CROSS, "Return to main menu"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "Show this help"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_DISABLE("SELECT"),
#endif
			HELP_EOM
		}
	},
	// HELP_STATE
	{
#if JAPANESE_UI
		"セーブ/ロードステート",
#else
		"Save/Load State",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "カーソ\ルを移動"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "処理を変更"),
			HELP_ENABLE(FONT_CIRCLE, "処理を実行"),
			HELP_DISABLE(FONT_CROSS),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_ENABLE(FONT_LTRIGGER, "メインメニューに戻る"),
			HELP_ENABLE(FONT_RTRIGGER, "このヘルプを開く"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_DISABLE("SELECT"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Scroll"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Change function"),
			HELP_ENABLE(FONT_CIRCLE, "Select"),
			HELP_DISABLE(FONT_CROSS),
			HELP_DISABLE(FONT_SQUARE),
			HELP_DISABLE(FONT_TRIANGLE),
			HELP_ENABLE(FONT_LTRIGGER, "Return to main menu"),
			HELP_ENABLE(FONT_RTRIGGER, "Show this help"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_DISABLE("SELECT"),
#endif
			HELP_EOM
		}
	},
	// HELP_COLORSETTINGS
	{
#if JAPANESE_UI
		"カラー設定メニュー",
#else
		"Color settings menu",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "項目の選択"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "項目の選択/値の変更"),
			HELP_ENABLE(FONT_CIRCLE, "RGBの値を+5"),
			HELP_ENABLE(FONT_CROSS, "ファイルブラウザに戻る"),
			HELP_ENABLE(FONT_SQUARE, "RGBの値を-5"),
			HELP_ENABLE(FONT_TRIANGLE, "全ての値を標準に戻す"),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "このヘルプを開く"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_DISABLE("SELECT"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Select item"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Select item / Change value"),
			HELP_ENABLE(FONT_CIRCLE, "RGB value +5"),
			HELP_ENABLE(FONT_CROSS, "Return to file browser"),
			HELP_ENABLE(FONT_SQUARE, "RGB value -5"),
			HELP_ENABLE(FONT_TRIANGLE, "Restore all values to default"),
			HELP_DISABLE(FONT_LTRIGGER),
			HELP_ENABLE(FONT_RTRIGGER, "Show this help"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_DISABLE("SELECT"),
#endif
			HELP_EOM
		}
	},
	// HELP_COMMANDLIST
	{
#if JAPANESE_UI
		"コマンドリスト",
#else
		"Command list",
#endif
		{
#if JAPANESE_UI
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "スクロール"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW, "1ページ分スクロール"),
			HELP_DISABLE(FONT_CIRCLE),
			HELP_ENABLE(FONT_CROSS, "ゲーム/メインメニューに戻る"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_ENABLE(FONT_TRIANGLE, "このヘルプを開く"),
			HELP_ENABLE(FONT_LTRIGGER, "次の項目を表\示"),
			HELP_ENABLE(FONT_RTRIGGER, "前の項目を表\示"),
			HELP_ENABLE("START", "スクリーンショットを保存"),
			HELP_DISABLE("SELECT"),
#else
			HELP_ENABLE(FONT_UPARROW FONT_DOWNARROW, "Scroll"),
			HELP_ENABLE(FONT_LEFTARROW FONT_RIGHTARROW,"Scroll 1 page"),
			HELP_ENABLE(FONT_CIRCLE, "Select"),
			HELP_ENABLE(FONT_CROSS, "Return to main menu"),
			HELP_DISABLE(FONT_SQUARE),
			HELP_ENABLE(FONT_TRIANGLE, "Show this help"),
			HELP_ENABLE(FONT_LTRIGGER, "Show previous item"),
			HELP_ENABLE(FONT_RTRIGGER, "Show next item"),
			HELP_ENABLE("START", "Save screen shot"),
			HELP_DISABLE("SELECT"),
#endif
			HELP_EOM
		}
	}
};


/*--------------------------------------------------------
	ヘルプ表示
 -------------------------------------------------------*/

int help(int no)
{
	int i;
	char title[256];

	if (no > HELP_NUM_MAX) return 0;

	video_copy_rect32(show_frame, draw_frame, &full_rect, &full_rect);

	boxfill_alpha(0, 0, SCR_WIDTH - 1, SCR_HEIGHT - 1, COLOR_BLACK, 8);
	draw_dialog(59, 34, 419, 264);

#if JAPANESE_UI
	sprintf(title, "ヘルプ - %s", help_mes[no].menu_name);
#else
	sprintf(title, "Help - %s", help_mes[no].menu_name);
#endif
	uifont_print_shadow_center(43, UI_COLOR(UI_PAL_INFO), title);

	for (i = 0; help_mes[no].mes[i].text1[0]; i++)
	{
		int r = *help_mes[no].mes[i].r;
		int g = *help_mes[no].mes[i].g;
		int b = *help_mes[no].mes[i].b;

		uifont_print(73, 70 + (i << 4), r, g, b, help_mes[no].mes[i].text1);
		uifont_print(143, 70 + (i << 4), r, g, b, help_mes[no].mes[i].text2);
	}

#if JAPANESE_UI
	uifont_print_shadow_center(240, UI_COLOR(UI_PAL_SELECT), "何かボタンを押すとメニューに戻ります");
#else
	uifont_print_shadow_center(240, UI_COLOR(UI_PAL_SELECT), "Press any button to return to menu.");
#endif

	video_flip_screen(1);
	pad_wait_clear();
	pad_wait_press(-1);
	pad_wait_clear();
	video_flip_screen(1);

	return 0;
}
