/** * Load a scenario in a safe way, and prepare the game. * @param houseID The House which is going to play the game. * @param scenarioID The Scenario to load. */ void Game_LoadScenario(uint8 houseID, uint16 scenarioID) { Audio_PlayVoice(VOICE_STOP); Game_Init(); g_validateStrictIfZero++; g_scenarioID = scenarioID; if (!Scenario_Load(scenarioID, houseID)) { GUI_DisplayModalMessage("No more scenarios!", 0xFFFF); PrepareEnd(); exit(0); } Game_Prepare(); if (scenarioID < 5) { g_hintsShown1 = 0; g_hintsShown2 = 0; } g_validateStrictIfZero--; }
/** * Initialize a game, by setting most variables to zero, cleaning the map, etc * etc. */ void Game_Init() { Unit_Init(); Structure_Init(); UnitAI_ClearSquads(); Team_Init(); House_Init(); Animation_Init(); Explosion_Init(); memset(g_map, 0, 64 * 64 * sizeof(Tile)); Map_ResetFogOfWar(); memset(g_mapSpriteID, 0, 64 * 64 * sizeof(uint16)); memset(g_starportAvailable, 0, sizeof(g_starportAvailable)); Audio_PlayVoice(VOICE_STOP); g_playerCreditsNoSilo = 0; g_houseMissileCountdown = 0; g_selectionState = 0; /* Invalid. */ g_structureActivePosition = 0; g_unitHouseMissile = NULL; g_unitActive = NULL; g_structureActive = NULL; g_activeAction = 0xFFFF; g_structureActiveType = 0xFFFF; GUI_DisplayText(NULL, -1); }
/** * Checks if the level comes to an end. If so, it shows all end-level stuff, * and prepares for the next level. */ static void GameLoop_LevelEnd() { static uint32 levelEndTimer = 0; if (levelEndTimer >= g_timerGame && !s_debugForceWin) return; if (GameLoop_IsLevelFinished()) { Audio_PlayMusic(MUSIC_STOP); Audio_PlayVoice(VOICE_STOP); Video_SetCursor(SHAPE_CURSOR_NORMAL); if (GameLoop_IsLevelWon()) { Audio_PlayVoice(VOICE_YOUR_MISSION_IS_COMPLETE); GUI_DisplayModalMessage(String_Get_ByIndex(STR_MISSION_WON), 0xFFFF); g_gameMode = GM_WIN; } else { Audio_PlayVoice(VOICE_YOU_HAVE_FAILED_YOUR_MISSION); GUI_DisplayModalMessage(String_Get_ByIndex(STR_MISSION_FAILED), 0xFFFF); g_gameMode = GM_LOSE; } GUI_ChangeSelectionType(SELECTIONTYPE_MENTAT); g_playerHouse->flags.doneFullScaleAttack = false; s_debugForceWin = false; return; } levelEndTimer = g_timerGame + 300; }
int main(int argc, char** argv) { UNUSED(argc); UNUSED(argv); FileHash_Init(); Mouse_Init(); if (A5_InitOptions() == false) exit(1); char filename[1024]; snprintf(filename, sizeof(filename), "%s/error.log", g_dune_data_dir); FILE* err = fopen(filename, "w"); snprintf(filename, sizeof(filename), "%s/output.log", g_dune_data_dir); FILE* out = fopen(filename, "w"); _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); if (err != NULL) _dup2(_fileno(err), _fileno(stderr)); if (out != NULL) _dup2(_fileno(out), _fileno(stdout)); FreeConsole(); if (!Unknown_25C4_000E()) exit(1); if (A5_Init() == false) exit(1); Scenario_InitTables(); Input_Init(); Audio_LoadSampleSet(SAMPLESET_INVALID); String_Init(); Sprites_Init(); Sprites_LoadTiles(); VideoA5_InitSprites(); GameLoop_TweakWidgetDimensions(); Audio_PlayVoice(VOICE_STOP); GameLoop_GameIntroAnimationMenu(); printf("%s\n", String_Get_ByIndex(STR_THANK_YOU_FOR_PLAYING_DUNE_II)); PrepareEnd(); exit(0); }
/** * Load a scenario in a safe way, and prepare the game. * @param houseID The House which is going to play the game. * @param scenarioID The Scenario to load. */ bool Game_LoadScenario(const char* scenario) { Audio_PlayVoice(VOICE_STOP); Game_Init(); g_validateStrictIfZero++; g_scenarioID = 0xFFFF; if (!Scenario_Load(scenario, SEARCHDIR_SCENARIO_DIR)) return false; Game_Prepare(); g_hintsShown1 = 0; g_hintsShown2 = 0; g_validateStrictIfZero--; return true; }
bool StrategicMap_TimerLoop(StrategicMapData* map) { const int64_t curr_ticks = Timer_GetTicks(); bool redraw = true; Audio_PlayMusicIfSilent(MUSIC_STRATEGIC_MAP); switch (map->state) { case STRATEGIC_MAP_SHOW_PLANET: if (map->fast_forward || (curr_ticks - map->text_timer >= 120)) { map->region_aux = Video_InitFadeInCPS("DUNEMAP.CPS", 8, 24, 304, 120, true); map->state++; StrategicMap_AdvanceText(map, false); } break; case STRATEGIC_MAP_SHOW_SURFACE: case STRATEGIC_MAP_SHOW_DIVISION: Video_TickFadeIn(map->region_aux); if (map->fast_forward || (curr_ticks - map->text_timer >= 120 + 60)) { if (map->state == STRATEGIC_MAP_SHOW_SURFACE) map->region_aux = Video_InitFadeInCPS("DUNEMAP.CPS", 8, 24, 304, 120, false); else map->region_aux = NULL; map->state++; StrategicMap_AdvanceText(map, false); } break; case STRATEGIC_MAP_SHOW_TEXT: if (map->fast_forward || (curr_ticks - map->text_timer >= 12 * 3)) { const ShapeID shapeID = SHAPE_MAP_PIECE + map->progression[map->curr_progression].region; const HouseType houseID = map->progression[map->curr_progression].houseID; const int region = map->progression[map->curr_progression].region; map->state = STRATEGIC_MAP_SHOW_PROGRESSION; map->region_aux = Video_InitFadeInShape(shapeID, houseID, region_data[region].x, region_data[region].y); } break; case STRATEGIC_MAP_SHOW_PROGRESSION: if (map->fast_forward || Video_TickFadeIn(map->region_aux)) { const int curr = map->curr_progression; map->owner[map->progression[curr].region] = map->progression[curr].houseID; if (StrategicMap_GetNextProgression(map)) { map->state = STRATEGIC_MAP_SHOW_TEXT; map->region_aux = NULL; } else { map->state = STRATEGIC_MAP_SELECT_REGION; map->fast_forward = false; map->region_aux = NULL; map->arrow_frame = 0; map->arrow_timer = curr_ticks; Audio_PlayVoice(VOICE_SELECT_YOUR_NEXT_CONQUEST); } StrategicMap_AdvanceText(map, false); } break; case STRATEGIC_MAP_SELECT_REGION: Audio_Poll(); if (curr_ticks - map->text_timer >= 3 * 12) redraw = false; break; case STRATEGIC_MAP_BLINK_REGION: case STRATEGIC_MAP_BLINK_END: break; } if (curr_ticks - map->arrow_timer >= STRATEGIC_MAP_ARROW_ANIMATION_DELAY) { const int64_t dt = curr_ticks - map->arrow_timer; map->arrow_timer = curr_ticks + dt % STRATEGIC_MAP_ARROW_ANIMATION_DELAY; map->arrow_frame += dt / STRATEGIC_MAP_ARROW_ANIMATION_DELAY; redraw = true; } return redraw; }
void OptionsMenu(float ContentTransp, float *ButtonTransp1, float *LastButtonUpdateTime1, float *ButtonTransp2, float *LastButtonUpdateTime2) { RECT SrcRect, DstRect; SetRect(&SrcRect,0,0,2,2); SetRect(&DstRect,0,0,Setup.iAspectRatioWidth,768); vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/blackpoint.tga"), true, 0.5f*ContentTransp); int CurrentPos = 0; int X1 = Setup.iAspectRatioWidth/2 - 375; int Y1 = 65; int Prir1 = 55; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Music_Volume")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Decrease"), ContentTransp, !Setup.Music_check || Setup.MusicSw==0)) { Setup.MusicSw--; if (Setup.MusicSw<0) Setup.MusicSw = 0; vw_SetMusicMainVolume(Setup.MusicSw/10.0f); } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Increase"), ContentTransp, !Setup.Music_check || Setup.MusicSw==10)) { Setup.MusicSw++; if (Setup.MusicSw>10) Setup.MusicSw = 10; vw_SetMusicMainVolume(Setup.MusicSw/10.0f); } if (!Setup.Music_check) { int SizeI = (170-vw_FontSize(vw_GetText("3_Not_available")))/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,0.5f,0.0f, ContentTransp, vw_GetText("3_Not_available")); } else { for (int i=0; i<10; i++) { SetRect(&SrcRect,0,0,16,32); SetRect(&DstRect,X1+443+16*i,Y1-4,X1+443+16+16*i,Y1+32-4); if (Setup.MusicSw>i) vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc.tga"), true, ContentTransp); else vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc_none.tga"), true, ContentTransp); } } Y1 += Prir1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Voice_Volume")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Decrease"), ContentTransp, !Setup.Sound_check || Setup.VoiceSw==0, false)) { Setup.VoiceSw--; if (Setup.VoiceSw<0) Setup.VoiceSw = 0; Audio_SetVoiceMainVolume(Setup.VoiceSw/10.0f); Audio_PlayVoice(1, 1.0f); } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Increase"), ContentTransp, !Setup.Sound_check || Setup.VoiceSw==10, false)) { Setup.VoiceSw++; if (Setup.VoiceSw>10) Setup.VoiceSw = 10; Audio_SetVoiceMainVolume(Setup.VoiceSw/10.0f); Audio_PlayVoice(1, 1.0f); } if (!Setup.Sound_check) { int SizeI = (170-vw_FontSize(vw_GetText("3_Not_available")))/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,0.5f,0.0f, ContentTransp, vw_GetText("3_Not_available")); } else { for (int i=0; i<10; i++) { SetRect(&SrcRect,0,0,16,32); SetRect(&DstRect,X1+443+16*i,Y1-4,X1+443+16+16*i,Y1+32-4); if (Setup.VoiceSw>i) vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc.tga"), true, ContentTransp); else vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc_none.tga"), true, ContentTransp); } } Y1 += Prir1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Sound_Effects_Volume")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Decrease"), ContentTransp, !Setup.Sound_check || Setup.SoundSw==0)) { Setup.SoundSw--; if (Setup.SoundSw<0) Setup.SoundSw = 0; Audio_SetSound2DMainVolume(Setup.SoundSw/10.0f); } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Increase"), ContentTransp, !Setup.Sound_check || Setup.SoundSw==10)) { Setup.SoundSw++; if (Setup.SoundSw>10) Setup.SoundSw = 10; Audio_SetSound2DMainVolume(Setup.SoundSw/10.0f); } if (!Setup.Sound_check) { int SizeI = (170-vw_FontSize(vw_GetText("3_Not_available")))/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,0.5f,0.0f, ContentTransp, vw_GetText("3_Not_available")); } else { for (int i=0; i<10; i++) { SetRect(&SrcRect,0,0,16,32); SetRect(&DstRect,X1+443+16*i,Y1-4,X1+443+16+16*i,Y1+32-4); if (Setup.SoundSw>i) vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc.tga"), true, ContentTransp); else vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc_none.tga"), true, ContentTransp); } } // проверяем, есть ли вообще полноэкранные разрешения bool CanSwitchToFullScreen = false; for(int i=0; i<VideoModesNum; i++) { if ((VideoModes[i].BPP == 16) | (VideoModes[i].BPP == 24)) { CanSwitchToFullScreen = true; break; } } Y1 += Prir1; if (Options_BPP != 0) CurrentPos = 0; else CurrentPos = 1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Full_Screen")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Prev"), ContentTransp, !CanSwitchToFullScreen) || DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Next"), ContentTransp, !CanSwitchToFullScreen)) { if (Options_BPP != 0) { Options_BPP = 0; } else { Options_BPP = CurrentVideoMode.BPP; // пробуем просто переключить BPP, проверяем есть ли такое разрешение bool NeedDetectResolution = true; for(int i=0; i<VideoModesNum; i++) { if ((VideoModes[i].W == Options_Width) & (VideoModes[i].H == Options_Height) & (VideoModes[i].BPP == Options_BPP)) { NeedDetectResolution = false; break; } } // находим первый полноэкранный режим в списке if (NeedDetectResolution) for(int i=0; i<VideoModesNum; i++) { if ((VideoModes[i].BPP == 16) | (VideoModes[i].BPP == 24)) { Options_Width = VideoModes[i].W; Options_Height = VideoModes[i].H; Options_BPP = VideoModes[i].BPP; break; } } } } int Size = vw_FontSize(Options_BPP ? vw_GetText("1_On") : vw_GetText("1_Off")); int SizeI = (170-Size)/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, Options_BPP ? vw_GetText("1_On") : vw_GetText("1_Off")); // находим текущий номер режима в списке int CurrentListNum = 0; for(int i=0; i<VideoModesNum; i++) { if (VideoModes[i].W == Options_Width && VideoModes[i].H == Options_Height && VideoModes[i].BPP == Options_BPP) { CurrentListNum = i; break; } } Y1 += Prir1; if (Options_BPP != 0) CurrentPos = 0; else CurrentPos = 1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText(ButtonScreenModeTitle[CurrentPos])); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Prev"), ContentTransp, false)) { CurrentListNum--; // ставим правильный bool check_next = true; while (check_next) { // вышли за предел if (CurrentListNum < 0) CurrentListNum = VideoModesNum-1; if ((VideoModes[CurrentListNum].BPP > 0 && Options_BPP > 0) || (VideoModes[CurrentListNum].BPP == 0 && Options_BPP == 0)) { check_next = false; } else { CurrentListNum--; } } Options_Width = VideoModes[CurrentListNum].W; Options_Height = VideoModes[CurrentListNum].H; Options_BPP = VideoModes[CurrentListNum].BPP; if ((Options_Width*1.0f)/(Options_Height*1.0f) < 1.4f) Options_iAspectRatioWidth = 1024; else Options_iAspectRatioWidth = 1228; } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Next"), ContentTransp, false)) { CurrentListNum++; // ставим правильный bool check_next = true; while (check_next) { // вышли за предел if (CurrentListNum >= VideoModesNum) CurrentListNum = 0; if ((VideoModes[CurrentListNum].BPP > 0 && Options_BPP > 0) || (VideoModes[CurrentListNum].BPP == 0 && Options_BPP == 0)) { check_next = false; } else { CurrentListNum++; } } Options_Width = VideoModes[CurrentListNum].W; Options_Height = VideoModes[CurrentListNum].H; Options_BPP = VideoModes[CurrentListNum].BPP; if ((Options_Width*1.0f)/(Options_Height*1.0f) < 1.4f) Options_iAspectRatioWidth = 1024; else Options_iAspectRatioWidth = 1228; } char VideoModeTitle[32]; if (VideoModes[CurrentListNum].BPP != 0) sprintf(VideoModeTitle, "%ix%i %ibit", VideoModes[CurrentListNum].W, VideoModes[CurrentListNum].H, VideoModes[CurrentListNum].BPP); else sprintf(VideoModeTitle, "%ix%i", VideoModes[CurrentListNum].W, VideoModes[CurrentListNum].H); Size = vw_FontSize(VideoModeTitle); SizeI = (170-Size)/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, VideoModeTitle); Y1 += Prir1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Aspect_Ration")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Prev"), ContentTransp, false)) { if (Options_iAspectRatioWidth == 1228) Options_iAspectRatioWidth = 1024; else Options_iAspectRatioWidth = 1228; } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Next"), ContentTransp, false)) { if (Options_iAspectRatioWidth == 1024) Options_iAspectRatioWidth = 1228; else Options_iAspectRatioWidth = 1024; } if (Options_iAspectRatioWidth == 1024) { Size = vw_FontSize(vw_GetText("3_Standard")); SizeI = (170-Size)/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Standard")); } else { Size = vw_FontSize(vw_GetText("3_Widescreen")); SizeI = (170-Size)/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Widescreen")); } Y1 += Prir1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, "VSync (%s)", vw_GetText("3_VSync")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Prev"), ContentTransp, false) || DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Next"), ContentTransp, false)) if (NeedCheck == 0) { if (Options_VSync == 1) Options_VSync = 0; else Options_VSync = 1; } Size = vw_FontSize(Options_VSync ? vw_GetText("1_On") : vw_GetText("1_Off")); SizeI = (170-Size)/2; vw_DrawFont(X1+438+SizeI, Y1, 0, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, Options_VSync ? vw_GetText("1_On") : vw_GetText("1_Off")); Y1 += Prir1; vw_DrawFont(X1, Y1, -280, 0, 1.0f, 1.0f,1.0f,1.0f, ContentTransp, vw_GetText("3_Brightness")); if (DrawButton128_2(X1+300, Y1-6, vw_GetText("1_Decrease"), ContentTransp, Setup.Brightness<=1)) { Setup.Brightness -= 1; if (Setup.Brightness <= 1) Setup.Brightness = 1; } if (DrawButton128_2(X1+616, Y1-6, vw_GetText("1_Increase"), ContentTransp, Setup.Brightness>=10)) { Setup.Brightness += 1; if (Setup.Brightness >= 10) Setup.Brightness = 10; } for (int i=0; i<10; i++) { SetRect(&SrcRect,0,0,16,32); SetRect(&DstRect,X1+443+16*i,Y1-4,X1+443+16+16*i,Y1+32-4); if (Setup.Brightness>i) vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc.tga"), true, ContentTransp); else vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/perc_none.tga"), true, ContentTransp); } int Prir = 100; int X; int Y = 165+Prir*4; X = Setup.iAspectRatioWidth/2 - 366; if (DrawButton200_2(X,Y+28, vw_GetText("1_Advanced"), ContentTransp, false)) { if (GameStatus == GAME) { SetOptionsMenu(OPTIONS_ADVANCED); GameMenuStatus = 3; } else ComBuffer = OPTIONS_ADVANCED; } X = Setup.iAspectRatioWidth/2 - 100; if (DrawButton200_2(X,Y+28, vw_GetText("1_Interface"), ContentTransp, false)) { if (GameStatus == GAME) { SetOptionsMenu(INTERFACE); GameMenuStatus = 4; } else ComBuffer = INTERFACE; } X = Setup.iAspectRatioWidth/2 + 166; if (DrawButton200_2(X,Y+28, vw_GetText("1_Config_Controls"), ContentTransp, false)) { if (GameStatus == GAME) { SetOptionsMenu(CONFCONTROL); GameMenuStatus = 5; } else ComBuffer = CONFCONTROL; } if ((Options_Width == Setup.Width && Options_Height == Setup.Height && Options_BPP == Setup.BPP && Options_VSync == Setup.VSync && Options_iAspectRatioWidth == Setup.iAspectRatioWidth)) { X = (Setup.iAspectRatioWidth - 384)/2; Y = Y+Prir; if (GameStatus == GAME) { if (DrawButton384(X,Y, vw_GetText("1_GAME_MENU"), ContentTransp, ButtonTransp1, LastButtonUpdateTime1)) { GameMenuStatus = 1; } } else { if (DrawButton384(X,Y, vw_GetText("1_MAIN_MENU"), ContentTransp, ButtonTransp1, LastButtonUpdateTime1)) { ComBuffer = MAIN_MENU; } } } else { X = Setup.iAspectRatioWidth/2 - 256 - 38; Y = Y+Prir; if (GameStatus == GAME) { if (DrawButton256(X,Y, vw_GetText("1_GAME_MENU"), ContentTransp, ButtonTransp1, LastButtonUpdateTime1)) { GameMenuStatus = 1; } } else { if (DrawButton256(X,Y, vw_GetText("1_MAIN_MENU"), ContentTransp, ButtonTransp1, LastButtonUpdateTime1)) { ComBuffer = MAIN_MENU; } } X = Setup.iAspectRatioWidth/2 + 38; if (DrawButton256(X,Y, vw_GetText("1_APPLY"), ContentTransp, ButtonTransp2, LastButtonUpdateTime2)) { // проверяем, нужно перегружать или нет if (Options_Width != Setup.Width || Options_Height != Setup.Height || Options_BPP != Setup.BPP || Options_VSync != Setup.VSync || Options_iAspectRatioWidth != Setup.iAspectRatioWidth) { if (GameStatus == GAME) SetCurrentDialogBox(17); else { CanQuit = false; Quit = true; NeedReCreate = true; SaveOptionsMenuTmpData(); } } } } }
/** * Main game loop. */ void GameLoop_Main(bool new_game, const char* scenario) { static int64_t l_timerNext = 0; static int64_t l_timerUnitStatus = 0; static int16 l_selectionState = -2; int frames_skipped = 0; Mouse_TransformFromDiv(SCREENDIV_MENU, &g_mouseX, &g_mouseY); Sprites_UnloadTiles(); Sprites_LoadTiles(); Viewport_Init(); if (new_game) { if (scenario) { if (!Game_LoadScenario(scenario)) goto end; } else Game_LoadScenario(g_playerHouseID, g_scenarioID); GUI_ChangeSelectionType(g_debugScenario ? SELECTIONTYPE_DEBUG : SELECTIONTYPE_STRUCTURE); } GUI_Palette_CreateRemap(g_table_houseInfo[g_playerHouseID].spriteColor); Audio_LoadSampleSet(g_table_houseInfo[g_playerHouseID].sampleSet); Timer_ResetScriptTimers(); Timer_SetTimer(TIMER_GAME, true); /* Note: original game chose only MUSIC_IDLE1 .. MUSIC_IDLE6. */ Audio_PlayMusic(MUSIC_RANDOM_IDLE); l_timerNext = Timer_GetTicks() + 300; g_musicInBattle = 0; g_gameMode = GM_NORMAL; g_gameOverlay = GAMEOVERLAY_NONE; Timer_RegisterSource(); while (g_gameMode == GM_NORMAL) { Timer_WaitForEvent(); const int64_t curr_ticks = Timer_GameTicks(); if (g_gameOverlay == GAMEOVERLAY_NONE) { Input_Tick(false); uint16 key = GUI_Widget_HandleEvents(g_widgetLinkedListHead); GameLoop_ProcessUnhandledInput(key); if (g_mousePanning) Video_WarpCursor(TRUE_DISPLAY_WIDTH / 2, TRUE_DISPLAY_HEIGHT / 2); } else if (g_gameOverlay == GAMEOVERLAY_MENTAT) { Input_Tick(true); MenuBar_TickMentatOverlay(); } else { Input_Tick(true); MenuBar_TickOptionsOverlay(); } if (g_gameOverlay == GAMEOVERLAY_NONE && g_timerGame != curr_ticks) g_timerGame = curr_ticks; else if (g_gameOverlay == GAMEOVERLAY_NONE) continue; if (g_selectionTypeNew != g_selectionType) GUI_ChangeSelectionType(g_selectionTypeNew); GUI_PaletteAnimate(); if (l_selectionState != g_selectionState) { Map_SetSelectionObjectPosition(0xFFFF); Map_SetSelectionObjectPosition(g_selectionRectanglePosition); l_selectionState = g_selectionState; } const bool narrator_speaking = Audio_Poll(); if (!narrator_speaking) { if (!g_enable_audio || !g_enable_music) { g_musicInBattle = 0; } else if (g_musicInBattle > 0) { Audio_PlayMusic(MUSIC_RANDOM_ATTACK); l_timerNext = Timer_GetTicks() + 300; g_musicInBattle = -1; } else { if (Timer_GetTicks() > l_timerNext) { if (!Audio_MusicIsPlaying()) { if (g_gameOverlay == GAMEOVERLAY_MENTAT) Audio_PlayMusic((MusicID)g_table_houseInfo[g_playerHouseID].musicBriefing); else Audio_PlayMusic(MUSIC_RANDOM_IDLE); l_timerNext = Timer_GetTicks() + 300; g_musicInBattle = 0; } } } } GFX_Screen_SetActive(SCREEN_0); if ((g_gameOverlay == GAMEOVERLAY_NONE) && (g_selectionType == SELECTIONTYPE_TARGET || g_selectionType == SELECTIONTYPE_PLACE || g_selectionType == SELECTIONTYPE_UNIT || g_selectionType == SELECTIONTYPE_STRUCTURE)) { if (Unit_AnySelected()) { if (l_timerUnitStatus < g_timerGame) { Unit_DisplayGroupStatusText(); l_timerUnitStatus = g_timerGame + 300; } if (g_selectionType != SELECTIONTYPE_TARGET) { const Unit* u = Unit_FirstSelected(NULL); g_selectionPosition = Tile_PackTile(Tile_Center(u->o.position)); } } UnitAI_SquadLoop(); GameLoop_Team(); GameLoop_Unit(); GameLoop_Structure(); GameLoop_House(); } if (g_running && !g_debugScenario) GameLoop_LevelEnd(); if (!g_running) break; if (frames_skipped > 4 || Timer_QueueIsEmpty()) { frames_skipped = 0; if (g_gameOverlay == GAMEOVERLAY_NONE) GUI_DrawInterfaceAndRadar(); else if (g_gameOverlay == GAMEOVERLAY_MENTAT) MenuBar_DrawMentatOverlay(); else { GUI_DrawInterfaceAndRadar(); MenuBar_DrawOptionsOverlay(); } Video_Tick(); A5_UseTransform(SCREENDIV_MAIN); } else frames_skipped++; } end: Timer_UnregisterSource(); Audio_PlayVoice(VOICE_STOP); Widget_SetCurrentWidget(0); g_selectionPosition = 0xFFFF; Unit_UnselectAll(); if (g_gameOverlay == GAMEOVERLAY_NONE) Mouse_TransformToDiv(SCREENDIV_MENU, &g_mouseX, &g_mouseY); }
//------------------------------------------------------------------------------------ // покупка-установка систем корабля //------------------------------------------------------------------------------------ void Workshop_Workshop() { RECT SrcRect, DstRect; SetRect(&SrcRect,0,0,256,256); SetRect(&DstRect,Setup.iAspectRatioWidth/2-256,0,Setup.iAspectRatioWidth/2-256+512,412); vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/back_spot.tga"), true, 0.35f*MenuContentTransp); vw_End2DMode(); WorkshopDrawShip(WorkshopFighterGame, 1); vw_Start2DMode(-1,1); SetRect(&SrcRect,0,0,210,600); SetRect(&DstRect,Setup.iAspectRatioWidth/2-492,50-10,Setup.iAspectRatioWidth/2-492+210,50+600-10); vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/workshop_panel2.tga"), true, MenuContentTransp); // стрелки SetRect(&SrcRect,0,0,74,120); SetRect(&DstRect,Setup.iAspectRatioWidth/2-461,494,Setup.iAspectRatioWidth/2-461+74,494+120); int MouseX, MouseY; vw_GetMousePos(&MouseX, &MouseY); if (((DstRect.right-8 >= MouseX)& (DstRect.left+8<= MouseX)& (DstRect.bottom-10 >= MouseY)& (DstRect.top+10<= MouseY)) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { Audio_PlaySound2D(2,1.0f); CurrentSystemStockNum = GetPrevSystemStockNum(); } vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/arrows_on.tga"), true, MenuContentTransp); } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/arrows_off.tga"), true, MenuContentTransp); } SetRect(&SrcRect,74,0,148,120); SetRect(&DstRect,Setup.iAspectRatioWidth/2-461+74,494,Setup.iAspectRatioWidth/2-461+148,494+120); if (((DstRect.right-8 >= MouseX)& (DstRect.left+8<= MouseX)& (DstRect.bottom-10 >= MouseY)& (DstRect.top+10<= MouseY)) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { Audio_PlaySound2D(2,1.0f); CurrentSystemStockNum = GetNextSystemStockNum(); } vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/arrows_on.tga"), true, MenuContentTransp); } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/arrows_off.tga"), true, MenuContentTransp); } // выводим иконки систем в магазине, по которым тоже можно кликать SetRect(&SrcRect,0,0,128,128); SetRect(&DstRect,Setup.iAspectRatioWidth/2-436,50+20+5-5,Setup.iAspectRatioWidth/2-338,50+128-20+5+5); if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { CurrentSystemStockNum = GetPrevSystemStockNum(); Audio_PlaySound2D(2,1.0f); } vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(GetPrevSystemStockNum()), true, MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(GetPrevSystemStockNum()))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, 1.0f,1.0f,1.0f, MenuContentTransp, vw_GetText(GetSystemName(GetPrevSystemStockNum()))); } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(GetPrevSystemStockNum()), true, 0.35f*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(GetPrevSystemStockNum()))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, 1.0f,1.0f,1.0f, 0.35f*MenuContentTransp, vw_GetText(GetSystemName(GetPrevSystemStockNum()))); } SetRect(&SrcRect,0,0,128,128); SetRect(&DstRect,Setup.iAspectRatioWidth/2-451,55+128+20,Setup.iAspectRatioWidth/2-451+128,55+128+128+20); vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(CurrentSystemStockNum), true, MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(CurrentSystemStockNum))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, 1.0f,1.0f,1.0f, MenuContentTransp, vw_GetText(GetSystemName(CurrentSystemStockNum))); if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) CurrentCursorStatus = 1; SetRect(&SrcRect,0,0,128,128); SetRect(&DstRect,Setup.iAspectRatioWidth/2-451+20-5,60+20+256+40-5-5,Setup.iAspectRatioWidth/2-451+128-20+5,60-20+128+256+40-5 +5); if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { Audio_PlaySound2D(2,1.0f); CurrentSystemStockNum = GetNextSystemStockNum(); } vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(GetNextSystemStockNum()), true, MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(GetNextSystemStockNum()))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, 1.0f,1.0f,1.0f, MenuContentTransp, vw_GetText(GetSystemName(GetNextSystemStockNum()))); } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(GetNextSystemStockNum()), true, 0.35f*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(GetNextSystemStockNum()))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, 1.0f,1.0f,1.0f, 0.35f*MenuContentTransp, vw_GetText(GetSystemName(GetNextSystemStockNum()))); } vw_DrawFont(Setup.iAspectRatioWidth/2-475, 630, 0, 0, 1.5f, 1.0f,1.0f,1.0f, MenuContentTransp, vw_GetText("7_System_Stock")); SetRect(&SrcRect,0,0,210,600); SetRect(&DstRect,Setup.iAspectRatioWidth/2+282,50-10,Setup.iAspectRatioWidth/2+492,50+600-10); vw_DrawTransparent(&DstRect, &SrcRect, vw_FindTextureByName("DATA/MENU/workshop_panel2+.tga"), true, MenuContentTransp); // проверяем, а все ли нормально с энергией... если не нормально, будем моргать и выведем соотв. надпись bool NeedMoreEnergy = false; if (Setup.Profile[CurrentProfile].PowerSystem != 0) { float Have = GetShipRechargeEnergy(Setup.Profile[CurrentProfile].PowerSystem); float Need = 0.0f; // если это не аркадный режим, нужно учитывать двигатель if (Setup.Profile[CurrentProfile].SpaceShipControlMode != 1) if (Setup.Profile[CurrentProfile].EngineSystem != 0) Need += GetShipEngineSystemEnergyUse(Setup.Profile[CurrentProfile].EngineSystem); // если есть спец система, ее нужно тоже учитывать if (Setup.Profile[CurrentProfile].AdvancedProtectionSystem != 0) Need += GetShipProtectionSystemEnergyUse(Setup.Profile[CurrentProfile].AdvancedProtectionSystem); // слабый реактор if (Need >= Have) NeedMoreEnergy = true; } else { // у нас вообще нет реактора... караул!!! NeedMoreEnergy = true; } // выводим информационную надпись + голосовое сообщение if (NeedMoreEnergy) { // запускаем голос... if (vw_FindSoundByNum(VoiceNeedMoreEnergy) == 0) { // уже не играем, нужно запустить опять VoiceNeedMoreEnergy = Audio_PlayVoice(6, 1.0f); } // вывод текста int SizeI = (Setup.iAspectRatioWidth-vw_FontSize(vw_GetText("9_14Line1")))/2; vw_DrawFont(SizeI, 60, 0, 0, 1.0f, 1.0f,0.0f,0.0f, CurrentAlert3*MenuContentTransp, vw_GetText("9_14Line1")); SizeI = (Setup.iAspectRatioWidth-vw_FontSize(vw_GetText("9_14Line2")))/2; vw_DrawFont(SizeI, 80, 0, 0, 1.0f, 1.0f,0.0f,0.0f, CurrentAlert3*MenuContentTransp, vw_GetText("9_14Line2")); SizeI = (Setup.iAspectRatioWidth-vw_FontSize(vw_GetText("9_14Line3")))/2; vw_DrawFont(SizeI, 100, 0, 0, 1.0f, 1.0f,0.0f,0.0f, CurrentAlert3*MenuContentTransp, vw_GetText("9_14Line3")); } // сбор данных float Current = 0.5f; int Cost = 0; bool CanSell = false; bool CanBuy = true; // Engine SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,70,Setup.iAspectRatioWidth/2+437,70+100); if (CurrentSystemStockNum>=1 && CurrentSystemStockNum<=4) { if (Setup.Profile[CurrentProfile].EngineSystem != 0) { CanSell = true; Cost = GetSystemCost(Setup.Profile[CurrentProfile].EngineSystem); if (Cost + Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } else { if (Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } } // Power SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,180,Setup.iAspectRatioWidth/2+437,180+100); if (CurrentSystemStockNum>=5 && CurrentSystemStockNum<=8) { if (Setup.Profile[CurrentProfile].PowerSystem != 0) { CanSell = true; Cost = GetSystemCost(Setup.Profile[CurrentProfile].PowerSystem+4); if (Cost + Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } else { if (Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } } // Target SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,290,Setup.iAspectRatioWidth/2+437,290+100); if (CurrentSystemStockNum>=9 && CurrentSystemStockNum<=12) { if (Setup.Profile[CurrentProfile].TargetingSystem != 0) { CanSell = true; Cost = GetSystemCost(Setup.Profile[CurrentProfile].TargetingSystem+8); if (Cost + Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } else { if (Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } } // Mech SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,400,Setup.iAspectRatioWidth/2+437,400+100); if (CurrentSystemStockNum>=13 && CurrentSystemStockNum<=16) { if (Setup.Profile[CurrentProfile].TargetingMechanicSystem != 0) { CanSell = true; Cost = GetSystemCost(Setup.Profile[CurrentProfile].TargetingMechanicSystem+12); if (Cost + Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } else { if (Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } } // Protect SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,510,Setup.iAspectRatioWidth/2+437,510+100); if (CurrentSystemStockNum>=17 && CurrentSystemStockNum<=20) { if (Setup.Profile[CurrentProfile].AdvancedProtectionSystem != 0) { CanSell = true; Cost = GetSystemCost(Setup.Profile[CurrentProfile].AdvancedProtectionSystem+16); if (Cost + Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } else { if (Setup.Profile[CurrentProfile].Money < GetSystemCost(CurrentSystemStockNum)) CanBuy = false; } } // прорисовка // Engine SetRect(&SrcRect,0,0,128,128); SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,70,Setup.iAspectRatioWidth/2+437,70+100); Current = 0.5f; float ColorR, ColorG, ColorB; ColorR = ColorG = ColorB = 1.0f; if (NeedMoreEnergy && Setup.Profile[CurrentProfile].EngineSystem != 0 && Setup.Profile[CurrentProfile].SpaceShipControlMode != 1) { ColorR = 1.0f; ColorG = 0.0f; ColorB = 0.0f; } if (CurrentSystemStockNum>=1 && CurrentSystemStockNum<=4) { if (!NeedMoreEnergy || Setup.Profile[CurrentProfile].EngineSystem == 0 || Setup.Profile[CurrentProfile].SpaceShipControlMode == 1) { if (CanBuy) {ColorR = 0.0f; ColorG = 0.8f; ColorB = 0.0f;} else {ColorR = 1.0f; ColorG = 0.5f; ColorB = 0.0f;} } Current = 1.0f; } if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } Current = 1.0f; CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { CurrentSystemStockNum = 1; Audio_PlaySound2D(2,1.0f); } } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } } if (Setup.Profile[CurrentProfile].EngineSystem <= 0) { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(-4), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText("3_empty")); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("3_empty")); Size = vw_FontSize(vw_GetText("4_Spaceship_Engine")); WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("4_Spaceship_Engine")); } else { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(Setup.Profile[CurrentProfile].EngineSystem), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].EngineSystem))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].EngineSystem))); } // Power SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,180,Setup.iAspectRatioWidth/2+437,180+100); ColorR = ColorG = ColorB = 1.0f; if (NeedMoreEnergy) { ColorR = 1.0f; ColorG = 0.0f; ColorB = 0.0f; } Current = 0.5f; if (CurrentSystemStockNum>=5 && CurrentSystemStockNum<=8) { if (!NeedMoreEnergy) { if (CanBuy) {ColorR = 0.0f; ColorG = 0.8f; ColorB = 0.0f;} else {ColorR = 1.0f; ColorG = 0.5f; ColorB = 0.0f;} } Current = 1.0f; } if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } Current = 1.0f; CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { CurrentSystemStockNum = 5; Audio_PlaySound2D(2,1.0f); } } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } } if (Setup.Profile[CurrentProfile].PowerSystem <= 0) { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(-2), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText("3_empty")); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("3_empty")); Size = vw_FontSize(vw_GetText("4_Power_Source")); WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("4_Power_Source")); } else { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(Setup.Profile[CurrentProfile].PowerSystem+4), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].PowerSystem+4))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].PowerSystem+4))); } // Target SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,290,Setup.iAspectRatioWidth/2+437,290+100); ColorR = ColorG = ColorB = 1.0f; Current = 0.5f; if (CurrentSystemStockNum>=9 && CurrentSystemStockNum<=12) { if (CanBuy) {ColorR = 0.0f; ColorG = 0.8f; ColorB = 0.0f;} else {ColorR = 1.0f; ColorG = 0.5f; ColorB = 0.0f;} Current = 1.0f; } if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } Current = 1.0f; CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { CurrentSystemStockNum = 9; Audio_PlaySound2D(2,1.0f); } } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } } if (Setup.Profile[CurrentProfile].TargetingSystem <= 0) { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(-1), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText("3_empty")); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("3_empty")); Size = vw_FontSize(vw_GetText("4_Optical_Computer")); WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("4_Optical_Computer")); } else { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(Setup.Profile[CurrentProfile].TargetingSystem+8), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].TargetingSystem+8))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].TargetingSystem+8))); } // Mech SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,400,Setup.iAspectRatioWidth/2+437,400+100); ColorR = ColorG = ColorB = 1.0f; Current = 0.5f; if (CurrentSystemStockNum>=13 && CurrentSystemStockNum<=16) { if (CanBuy) {ColorR = 0.0f; ColorG = 0.8f; ColorB = 0.0f;} else {ColorR = 1.0f; ColorG = 0.5f; ColorB = 0.0f;} Current = 1.0f; } if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } Current = 1.0f; CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { Audio_PlaySound2D(2,1.0f); CurrentSystemStockNum = 13; } } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } } if (Setup.Profile[CurrentProfile].TargetingMechanicSystem <= 0) { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(-3), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText("3_empty")); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("3_empty")); Size = vw_FontSize(vw_GetText("4_Targeting_System")); WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("4_Targeting_System")); } else { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(Setup.Profile[CurrentProfile].TargetingMechanicSystem+12), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].TargetingMechanicSystem+12))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].TargetingMechanicSystem+12))); } // Protect SetRect(&DstRect,Setup.iAspectRatioWidth/2+337,510,Setup.iAspectRatioWidth/2+437,510+100); ColorR = ColorG = ColorB = 1.0f; if (NeedMoreEnergy && Setup.Profile[CurrentProfile].AdvancedProtectionSystem != 0) { ColorR = 1.0f; ColorG = 0.0f; ColorB = 0.0f; } Current = 0.5f; if (CurrentSystemStockNum>=17 && CurrentSystemStockNum<=20) { if (!NeedMoreEnergy || Setup.Profile[CurrentProfile].AdvancedProtectionSystem == 0) { if (CanBuy) {ColorR = 0.0f; ColorG = 0.8f; ColorB = 0.0f;} else {ColorR = 1.0f; ColorG = 0.5f; ColorB = 0.0f;} } Current = 1.0f; } if (vw_OnRect(&DstRect) && !isDialogBoxDrawing()) { if (NeedPlayWorkshopOnButtonSoundX != DstRect.left || NeedPlayWorkshopOnButtonSoundY != DstRect.top) { Audio_PlaySound2D(1,1.0f); NeedPlayWorkshopOnButtonSoundX = DstRect.left; NeedPlayWorkshopOnButtonSoundY = DstRect.top; } Current = 1.0f; CurrentCursorStatus = 1; if (vw_GetWindowLBMouse(true)) { Audio_PlaySound2D(2,1.0f); CurrentSystemStockNum = 17; } } else { if (NeedPlayWorkshopOnButtonSoundX == DstRect.left && NeedPlayWorkshopOnButtonSoundY == DstRect.top) { NeedPlayWorkshopOnButtonSoundX = 0; NeedPlayWorkshopOnButtonSoundY = 0; } } if (Setup.Profile[CurrentProfile].AdvancedProtectionSystem <= 0) { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(0), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText("3_empty")); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.top-4, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("3_empty")); Size = vw_FontSize(vw_GetText("4_Advanced_System")); WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-20, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText("4_Advanced_System")); } else { vw_DrawTransparent(&DstRect, &SrcRect, GetSystemIcon(Setup.Profile[CurrentProfile].AdvancedProtectionSystem+16), true, Current*MenuContentTransp); int Size = vw_FontSize(vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].AdvancedProtectionSystem+16))); float WScale = 0; if (Size > 128) { Size = 128; WScale = -128; } vw_DrawFont(DstRect.left+(DstRect.right-DstRect.left-Size)/2, DstRect.bottom-70, WScale, 0, 1.0f, ColorR,ColorG,ColorB, Current*MenuContentTransp, vw_GetText(GetSystemName(Setup.Profile[CurrentProfile].AdvancedProtectionSystem+16))); } vw_DrawFont(Setup.iAspectRatioWidth/2+475-vw_FontSize(vw_GetText("7_Installed_Systems"))*1.5f, 630, 0, 0, 1.5f, 1.0f,1.0f,1.0f, MenuContentTransp, vw_GetText("7_Installed_Systems")); // текущая система vw_DrawFont(Setup.iAspectRatioWidth/2-250, 430, 0, 0, 1.0f, 1.0f,1.0f,0.0f, MenuContentTransp, vw_GetText("7_Selected_System")); vw_DrawFont(Setup.iAspectRatioWidth/2+250-vw_FontSize(vw_GetText("7_Installed_System")), 430, 0, 0, 1.0f, 1.0f,1.0f,0.0f, MenuContentTransp, vw_GetText("7_Installed_System")); if (CanBuy) vw_DrawFont(Setup.iAspectRatioWidth/2-250, 485, 0, 0, 1.0f, 1.0f,1.0f,1.0f, MenuContentTransp, "%s: %i", vw_GetText("7_Cost"), GetSystemCost(CurrentSystemStockNum)); else vw_DrawFont(Setup.iAspectRatioWidth/2-250, 485, 0, 0, 1.0f, 1.0f,0.5f,0.0f, CurrentAlert3*MenuContentTransp, "%s: %i", vw_GetText("7_Cost"), GetSystemCost(CurrentSystemStockNum)); vw_DrawFont(Setup.iAspectRatioWidth/2+250-vw_FontSize("%s: %i", vw_GetText("7_Cost"), Cost), 485, 0, 0, 1.0f, 1.0f,1.0f,1.0f, MenuContentTransp, "%s: %i", vw_GetText("7_Cost"), Cost); if (DrawButton128_2(Setup.iAspectRatioWidth/2-250,580-55, vw_GetText("1_Info"), MenuContentTransp, false)) { SetCurrentDialogBox(8); DialogSystem = CurrentSystemStockNum; } if (DrawButton128_2(Setup.iAspectRatioWidth/2+250-128,580-55, vw_GetText("1_Info"), MenuContentTransp, !CanSell)) { SetCurrentDialogBox(8); NeedMoreEnergyDialog = NeedMoreEnergy; if (CurrentSystemStockNum>=1 && CurrentSystemStockNum<=4) DialogSystem = Setup.Profile[CurrentProfile].EngineSystem; if (CurrentSystemStockNum>=5 && CurrentSystemStockNum<=8) DialogSystem = Setup.Profile[CurrentProfile].PowerSystem+4; if (CurrentSystemStockNum>=9 && CurrentSystemStockNum<=12) DialogSystem = Setup.Profile[CurrentProfile].TargetingSystem+8; if (CurrentSystemStockNum>=13 && CurrentSystemStockNum<=16) DialogSystem = Setup.Profile[CurrentProfile].TargetingMechanicSystem+12; if (CurrentSystemStockNum>=17 && CurrentSystemStockNum<=20) DialogSystem = Setup.Profile[CurrentProfile].AdvancedProtectionSystem+16; } if (DrawButton128_2(Setup.iAspectRatioWidth/2-250,50+580-55, vw_GetText("1_Buy"), MenuContentTransp, !CanBuy)) { BuyCurrentSystem(); } // покупка, если 2 раза кликнули на иконку текущей системы SetRect(&DstRect,Setup.iAspectRatioWidth/2-451,55+128+20,Setup.iAspectRatioWidth/2-451+128,55+128+128+20); if (vw_OnRect(&DstRect) && !isDialogBoxDrawing() && CanBuy) if (vw_GetWindowLBDoubleMouse(true)) BuyCurrentSystem(); if (DrawButton128_2(Setup.iAspectRatioWidth/2+250-128,50+580-55, vw_GetText("1_Sell"), MenuContentTransp, !CanSell)) { SellCurrentSystem(); } // вывод информации int SizeI = (Setup.iAspectRatioWidth-vw_FontSize("%s: %i", vw_GetText("3_Money"), Setup.Profile[CurrentProfile].Money)*1.25f)/2; if (CanBuy) vw_DrawFont(SizeI, 630, 0, 0, 1.25f, 1.0f,1.0f,0.0f, MenuContentTransp, "%s: %i", vw_GetText("3_Money"), Setup.Profile[CurrentProfile].Money); else vw_DrawFont(SizeI, 630, 0, 0, 1.25f, 1.0f,0.5f,0.0f, CurrentAlert3*MenuContentTransp, "%s: %i", vw_GetText("3_Money"), Setup.Profile[CurrentProfile].Money); }