Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mmsystem.h>
- void CApplication::Level_Set(u32 L) {
- Log("--Level_Set1");
- if (L >= Levels.size())
- return;
- Level_Current = L;
- char* LNameString = Levels[L].folder;
- FS.get_path("$level$")->_set(LNameString);
- LNameString[strlen(LNameString) - 1] = 0; //Убираем слеш в конце имени уровня
- string_path temp = { 0 };
- string_path temp2 = { 0 };
- strconcat(sizeof(temp), temp, "intro\\intro_", LNameString);
- Log("--Level_Set2");
- u32 PicturesCount = READ_IF_EXISTS(pSettings, r_u32, "load_screen", "intro_picrures_count", 0); //может вообще лучше читать это из конфигов уровней именно?
- if (PicturesCount > 0) {
- Log("--Level_Set3");
- if (IntroThread) //Поток уже создан? Дальше делать нечего.
- return;
- Log("--CreatingIntroThread!");
- IntroThread = new std::thread([=] { //Возможно, будет правильнее делать не захват, а передавать аргументами. и получать соотв.
- Log("--IntroThreadStarted!");
- u32 current_picture = 1;
- u32 max_picture = PicturesCount;
- u32 PicturesTimeout = READ_IF_EXISTS(pSettings, r_u32, "load_screen", "intro_picrures_timeout", 5000); //По дефолту 5 секунд сделать.
- while (true) {
- if (IntroThreadDestroying)
- break;
- static DWORD dwLastFrameTime = 0;
- DWORD dwCurrentTime = timeGetTime();
- if (dwCurrentTime - dwLastFrameTime < PicturesTimeout)
- continue;
- dwLastFrameTime = dwCurrentTime;
- hLevelLogo.destroy();
- Msg("~~Max_picture is [%u]", max_picture);
- current_picture = ::Random.randI(1, max_picture);
- Msg("~~Current_picture is [%u]", current_picture);
- string_path temp = { 0 };
- string_path temp2 = { 0 };
- strconcat(sizeof(temp), temp, "intro\\intro_", LNameString, "_", std::to_string(current_picture).c_str());
- if (FS.exist(temp2, "$game_textures$", temp, ".dds")) { //Тут ассерт сделать?
- Msg("~~Creating level_logo: [%s]", temp2);
- hLevelLogo.create("font", temp);
- }
- else
- Msg("!!Not found texture [%s]", temp);
- load_draw_internal();
- }
- });
- }
- else if (FS.exist(temp2, "$game_textures$", temp, ".dds")) {
- hLevelLogo.create("font", temp);
- }
- else {
- hLevelLogo.create("font", "intro\\intro_no_start_picture");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement