コード例 #1
0
ファイル: widget_click.c プロジェクト: Haozerk/OpenDUNE
static bool GUI_YesNo(uint16 stringID)
{
	WindowDesc *desc = &g_yesNoWindowDesc;
	bool loop;
	bool ret = false;

	desc->stringID = stringID;

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	for (loop = true; loop; sleepIdle()) {
		uint16 key = GUI_Widget_HandleEvents(g_widgetLinkedListTail);

		if ((key & 0x8000) != 0) {
			switch (key & 0x7FFF) {
				case 0x1E: ret = true; break;
				case 0x1F: ret = false; break;
				default: break;
			}
			loop = false;
		}

		GUI_PaletteAnimate();
	}

	GUI_Window_RestoreScreen(desc);

	return ret;
}
コード例 #2
0
/**
 * Handles Click event for "Game controls" button.
 *
 * @param w The widget.
 */
static void GUI_Widget_GameControls_Click(Widget *w)
{
	WindowDesc *desc = &g_gameControlWindowDesc;
	bool loop;

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	loop = true;
	while (loop) {
		Widget *w2 = g_widgetLinkedListTail;
		uint16 key = GUI_Widget_HandleEvents(w2);

		if ((key & 0x8000) != 0) {
			w = GUI_Widget_Get_ByIndex(w2, key & 0x7FFF);

			switch ((key & 0x7FFF) - 0x1E) {
				case 0:
					g_gameConfig.music ^= 0x1;
					if (g_gameConfig.music == 0) Driver_Music_Stop();
					break;

				case 1:
					g_gameConfig.sounds ^= 0x1;
					if (g_gameConfig.sounds == 0) Driver_Sound_Stop();
					break;

				case 2:
					if (++g_gameConfig.gameSpeed >= 5) g_gameConfig.gameSpeed = 0;
					break;

				case 3:
					g_gameConfig.hints ^= 0x1;
					break;

				case 4:
					g_gameConfig.autoScroll ^= 0x1;
					break;

				case 5:
					loop = false;
					break;

				default: break;
			}

			GUI_Widget_MakeNormal(w, false);

			GUI_Widget_Draw(w);
		}

		GUI_PaletteAnimate();
		sleepIdle();
	}

	GUI_Window_RestoreScreen(desc);
}
コード例 #3
0
ファイル: Display.c プロジェクト: xsantinos/STGAA-RTOS
/**
 * @brief 		ACQ_Acquiring thread
 * @param[in] 	CANx point to LPC_CAN_TypeDef object, should be:
 * 				- LPC_CAN1: CAN1 peripheral
 * 				- LPC_CAN2: CAN2 peripheral
 * @param[in]	baudrate: is the baud rate value will be set
 * @see publicVar()
 * @return 		None
 */
static Status  DSP_CreateGUI(void){
	// Window "H&T"

	GUI_Window_Create ("Login", "NONE", WHITE, "LOGIN", NULL, NULL, NULL);
	GUI_Picture_Create("Login","Login_icons",  5,23, 48, 40,InicioBitmaps,BLACK,NULL);
	GUI_Text_Create   ("Login", "row1", 60, 14, WHITE, "", BLACK, "RECETA  : ....");
	GUI_Text_Create   ("Login", "row2", 60, 22, WHITE, "", BLACK, "PRODUCTO: ....");
	GUI_Text_Create   ("Login", "row3", 60, 30, WHITE, "", BLACK, "DOSIS   : ....");
	GUI_Text_Create   ("Login", "row4", 60, 38, WHITE, "", BLACK, "VOLUMEN : ....");
	GUI_Text_Create   ("Login", "row5", 60, 46, WHITE, "", BLACK, "REGENTE : ....");
	GUI_Text_Create   ("Login", "row6", 60, 54, WHITE, "", BLACK, "OPERARIO: ....");

	GUI_Window_Create ("Confirm", "Login", WHITE, "LOGIN", NULL, NULL, NULL);
	GUI_Text_Create   ("Confirm", "Agree", 50, 25, WHITE, "", BLACK, "¿CONFIRMAR RECETA?");

	GUI_Window_Create( "Home", "NONE", WHITE, "STGAA v3.0", NULL, NULL, NULL );
	GUI_Picture_Create("Home","Signal_icons",  111, 0, 8,8,NULL,WHITE,NULL);
	GUI_Picture_Create("Home","SD_icons",  120, 0, 8,8,NULL,WHITE,NULL);

	GUI_Picture_Create("Home","GPS_icons",  3, 18, 12, 16,GpsBitmaps,BLACK,NULL);
    GUI_Text_Create   ("Home", "Latitude",  20, 16, WHITE, "", BLACK, "31*49'56.4\"S");
    GUI_Text_Create   ("Home", "Longitude",  20, 24, WHITE, "", BLACK, "60*31'20.2\"E");

    GUI_Picture_Create("Home","ANE_icons",  3, 47, 12,16,WindsBitmaps,BLACK,NULL);
    GUI_Text_Create   ("Home", "WindSpeed",  20, 40, WHITE, "", BLACK, "9.1 Km/h ");
    GUI_Text_Create   ("Home", "WindDirection",  20, 48, WHITE, "", BLACK, "NNE");

    GUI_Picture_Create("Home","CAU_icons", 77, 18, 12,16,FlowBitmaps,BLACK,NULL);
    GUI_Text_Create   ("Home", "PumpState",  90, 16, WHITE, "", BLACK, "ON");
    GUI_Text_Create   ("Home", "Flow",  90, 24, WHITE, "", BLACK, "140 L/m");

    GUI_Picture_Create("Home","TYH_icons", 77, 47, 12,16,TyhBitmaps,BLACK,NULL);
    GUI_Text_Create   ("Home", "Temperature",  90, 40, WHITE, "", BLACK, "24.5*C ");
    GUI_Text_Create   ("Home", "Humidity",  90, 48, WHITE, "", BLACK, "72 %HR ");

    GUI_Window_Draw ("Home");

	return SUCCESS;
}
コード例 #4
0
ファイル: widget_click.c プロジェクト: Haozerk/OpenDUNE
/**
 * Handles Click event for "Save Game" or "Load Game" button.
 *
 * @param save Wether to save or load.
 * @return True if a game has been saved or loaded, False otherwise.
 */
bool GUI_Widget_SaveLoad_Click(bool save)
{
	WindowDesc *desc = &g_saveLoadWindowDesc;
	bool loop;

	s_savegameCountOnDisk = GetSavegameCount();

	s_savegameIndexBase = max(0, s_savegameCountOnDisk - (save ? 0 : 1));

	FillSavegameDesc(save);

	desc->stringID = save ? STR_SELECT_A_POSITION_TO_SAVE_TO : STR_SELECT_A_SAVED_GAME_TO_LOAD;

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	UpdateArrows(save, true);

	for (loop = true; loop; sleepIdle()) {
		Widget *w = g_widgetLinkedListTail;
		uint16 key = GUI_Widget_HandleEvents(w);

		UpdateArrows(save, false);

		if ((key & 0x8000) != 0) {
			Widget *w2;

			key &= 0x7FFF;
			w2 = GUI_Widget_Get_ByIndex(w, key);

			switch (key) {
				case 0x25:
					s_savegameIndexBase = min(s_savegameCountOnDisk - (save ? 0 : 1), s_savegameIndexBase + 1);

					FillSavegameDesc(save);

					GUI_Widget_DrawAll(w);
					break;

				case 0x26:
					s_savegameIndexBase = max(0, s_savegameIndexBase - 1);

					FillSavegameDesc(save);

					GUI_Widget_DrawAll(w);
					break;

				case 0x23:
					loop = false;
					break;

				default: {
					GUI_Window_RestoreScreen(desc);

					key -= 0x1E;

					if (!save) {
						LoadFile(GenerateSavegameFilename(s_savegameIndexBase - key));
						return true;
					}

					if (GUI_Widget_Savegame_Click(key)) return true;

					GUI_Window_BackupScreen(desc);

					UpdateArrows(save, true);

					GUI_Window_Create(desc);

					UpdateArrows(save, true);
				} break;
			}

			GUI_Widget_MakeNormal(w2, false);
		}

		GUI_PaletteAnimate();
	}

	GUI_Window_RestoreScreen(desc);

	return false;
}
コード例 #5
0
ファイル: widget_click.c プロジェクト: Haozerk/OpenDUNE
/**
 * Handles Click event for savegame button.
 *
 * @param key The index of the clicked button.
 * @return True if a game has been saved, False otherwise.
 */
static bool GUI_Widget_Savegame_Click(uint16 key)
{
	WindowDesc *desc = &g_savegameNameWindowDesc;
	bool loop;
	char *saveDesc = g_savegameDesc[key];
	uint16 loc08;
	uint16 loc0A;
	bool ret;

	if (*saveDesc == '[') *saveDesc = 0;

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	ret = false;
	loc08 = 1;

	if (*saveDesc == '[') key = s_savegameCountOnDisk;

	GFX_Screen_SetActive(SCREEN_0);

	Widget_SetCurrentWidget(15);

	GUI_Mouse_Hide_Safe();
	GUI_DrawBorder((g_curWidgetXBase << 3) - 1, g_curWidgetYBase - 1, (g_curWidgetWidth << 3) + 2, g_curWidgetHeight + 2, 4, false);
	GUI_Mouse_Show_Safe();

	for (loop = true; loop; sleepIdle()) {
		Widget *w = g_widgetLinkedListTail;

		GUI_DrawText_Wrapper(NULL, 0, 0, 232, 235, 0x22);

		loc0A = GUI_EditBox(saveDesc, 50, 15, g_widgetLinkedListTail, NULL, loc08);
		loc08 = 2;

		if ((loc0A & 0x8000) == 0) continue;

		GUI_Widget_MakeNormal(GUI_Widget_Get_ByIndex(w, loc0A & 0x7FFF), false);

		switch (loc0A & 0x7FFF) {
			case 0x1E:
				if (*saveDesc == 0) break;

				SaveFile(GenerateSavegameFilename(s_savegameIndexBase - key), saveDesc);
				loop = false;
				ret = true;
				break;

			case 0x1F:
				loop = false;
				ret = false;
				FillSavegameDesc(true);
				break;

			default: break;
		}
	}

	GUI_Window_RestoreScreen(desc);

	return ret;
}
コード例 #6
0
ファイル: widget_click.c プロジェクト: Haozerk/OpenDUNE
/**
 * Handles Click event for "Options" button.
 *
 * @param w The widget.
 * @return False, always.
 */
bool GUI_Widget_Options_Click(Widget *w)
{
	WindowDesc *desc = &g_optionsWindowDesc;
	uint16 cursor = g_cursorSpriteID;
	bool loop;

	g_cursorSpriteID = 0;

	Sprites_SetMouseSprite(0, 0, g_sprites[0]);

	Sprites_UnloadTiles();

	memmove(g_palette_998A, g_paletteActive, 256 * 3);

	Driver_Voice_Play(NULL, 0xFF);

	Timer_SetTimer(TIMER_GAME, false);

	GUI_DrawText_Wrapper(NULL, 0, 0, 0, 0, 0x22);

	ShadeScreen();

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	for (loop = true; loop; sleepIdle()) {
		Widget *w2 = g_widgetLinkedListTail;
		uint16 key = GUI_Widget_HandleEvents(w2);

		if ((key & 0x8000) != 0) {
			w = GUI_Widget_Get_ByIndex(w2, key);

			GUI_Window_RestoreScreen(desc);

			switch ((key & 0x7FFF) - 0x1E) {
				case 0:
					if (GUI_Widget_SaveLoad_Click(false)) loop = false;
					break;

				case 1:
					if (GUI_Widget_SaveLoad_Click(true)) loop = false;
					break;

				case 2:
					GUI_Widget_GameControls_Click(w);
					break;

				case 3:
					/* "Are you sure you wish to restart?" */
					if (!GUI_YesNo(0x76)) break;

					loop = false;
					g_gameMode = GM_RESTART;
					break;

				case 4:
					/* "Are you sure you wish to pick a new house?" */
					if (!GUI_YesNo(0x77)) break;

					loop = false;
					Driver_Music_FadeOut();
					g_gameMode = GM_PICKHOUSE;
					break;

				case 5:
					loop = false;
					break;

				case 6:
					/* "Are you sure you want to quit playing?" */
					loop = !GUI_YesNo(0x65);
					g_running = loop;

					Sound_Output_Feedback(0xFFFE);

					while (Driver_Voice_IsPlaying()) sleepIdle();
					break;

				default: break;
			}

			if (g_running && loop) {
				GUI_Window_BackupScreen(desc);

				GUI_Window_Create(desc);
			}
		}

		GUI_PaletteAnimate();
	}

	g_textDisplayNeedsUpdate = true;

	Sprites_LoadTiles();
	GUI_DrawInterfaceAndRadar(SCREEN_0);

	UnshadeScreen();

	GUI_Widget_MakeSelected(w, false);

	Timer_SetTimer(TIMER_GAME, true);

	GameOptions_Save();

	Structure_Recount();
	Unit_Recount();

	g_cursorSpriteID = cursor;

	Sprites_SetMouseSprite(0, 0, g_sprites[cursor]);

	return false;
}
コード例 #7
0
/**
 * Handles Click event for savegame button.
 *
 * @param index The index of the clicked button.
 * @return True if a game has been saved, False otherwise.
 */
static bool GUI_Widget_Savegame_Click(uint16 index)
{
	WindowDesc *desc = &g_savegameNameWindowDesc;
	bool loop;
	char *saveDesc = g_savegameDesc[index];
	bool widgetPaint;
	bool ret;

	if (*saveDesc == '[') *saveDesc = 0;

	GUI_Window_BackupScreen(desc);

	GUI_Window_Create(desc);

	ret = false;
	widgetPaint = true;

	if (*saveDesc == '[') index = s_savegameCountOnDisk;

	GFX_Screen_SetActive(SCREEN_0);

	Widget_SetCurrentWidget(15);

	GUI_Mouse_Hide_Safe();
	GUI_DrawBorder((g_curWidgetXBase << 3) - 1, g_curWidgetYBase - 1, (g_curWidgetWidth << 3) + 2, g_curWidgetHeight + 2, 4, false);
	GUI_Mouse_Show_Safe();

	for (loop = true; loop; sleepIdle()) {
		uint16 eventKey;
		Widget *w = g_widgetLinkedListTail;

		GUI_DrawText_Wrapper(NULL, 0, 0, 232, 235, 0x22);

		eventKey = GUI_EditBox(saveDesc, 50, 15, g_widgetLinkedListTail, NULL, widgetPaint);
		widgetPaint = false;

		if ((eventKey & 0x8000) == 0) continue;

		GUI_Widget_MakeNormal(GUI_Widget_Get_ByIndex(w, eventKey & 0x7FFF), false);

		switch (eventKey & 0x7FFF) {
			case 0x1E:	/* RETURN / Save Button */
				if (*saveDesc == 0) break;

				SaveGame_SaveFile(GenerateSavegameFilename(s_savegameIndexBase - index), saveDesc);
				loop = false;
				ret = true;
				break;

			case 0x1F:	/* ESCAPE / Cancel Button */
				loop = false;
				ret = false;
				FillSavegameDesc(true);
				break;

			default: break;
		}
	}

	GUI_Window_RestoreScreen(desc);

	return ret;
}