Advertisement
Guest User

Untitled

a guest
Sep 14th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.38 KB | None | 0 0
  1. #include <mmsystem.h>
  2. void CApplication::Level_Set(u32 L) {
  3.     Log("--Level_Set1");
  4.     if (L >= Levels.size())
  5.         return;
  6.  
  7.     Level_Current = L;
  8.     char* LNameString = Levels[L].folder;
  9.     FS.get_path("$level$")->_set(LNameString);
  10.  
  11.     LNameString[strlen(LNameString) - 1] = 0; //Убираем слеш в конце имени уровня
  12.  
  13.     string_path temp = { 0 };
  14.     string_path temp2 = { 0 };
  15.     strconcat(sizeof(temp), temp, "intro\\intro_", LNameString);
  16.     Log("--Level_Set2");
  17.     u32 PicturesCount = READ_IF_EXISTS(pSettings, r_u32, "load_screen", "intro_picrures_count", 0); //может вообще лучше читать это из конфигов уровней именно?
  18.     if (PicturesCount > 0) {
  19.         Log("--Level_Set3");
  20.         if (IntroThread) //Поток уже создан? Дальше делать нечего.
  21.             return;
  22.         Log("--CreatingIntroThread!");
  23.         IntroThread = new std::thread([=] { //Возможно, будет правильнее делать не захват, а передавать аргументами. и получать соотв.
  24.             Log("--IntroThreadStarted!");
  25.             u32 current_picture = 1;
  26.             u32 max_picture = PicturesCount;
  27.             u32 PicturesTimeout = READ_IF_EXISTS(pSettings, r_u32, "load_screen", "intro_picrures_timeout", 5000); //По дефолту 5 секунд сделать.
  28.             while (true) {
  29.                 if (IntroThreadDestroying)
  30.                     break;
  31.                 static DWORD dwLastFrameTime = 0;
  32.                 DWORD dwCurrentTime = timeGetTime();
  33.                 if (dwCurrentTime - dwLastFrameTime < PicturesTimeout)
  34.                     continue;
  35.                 dwLastFrameTime = dwCurrentTime;
  36.                 hLevelLogo.destroy();
  37.                 Msg("~~Max_picture is [%u]", max_picture);
  38.                 current_picture = ::Random.randI(1, max_picture);
  39.                 Msg("~~Current_picture is [%u]", current_picture);
  40.                 string_path temp = { 0 };
  41.                 string_path temp2 = { 0 };
  42.                 strconcat(sizeof(temp), temp, "intro\\intro_", LNameString, "_", std::to_string(current_picture).c_str());
  43.                 if (FS.exist(temp2, "$game_textures$", temp, ".dds")) { //Тут ассерт сделать?
  44.                     Msg("~~Creating level_logo: [%s]", temp2);
  45.                     hLevelLogo.create("font", temp);
  46.                 }
  47.                 else
  48.                     Msg("!!Not found texture [%s]", temp);
  49.                 load_draw_internal();
  50.             }
  51.         });
  52.     }
  53.     else if (FS.exist(temp2, "$game_textures$", temp, ".dds")) {
  54.         hLevelLogo.create("font", temp);
  55.     }
  56.     else {
  57.         hLevelLogo.create("font", "intro\\intro_no_start_picture");
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement