| 30 | } |
| 31 | |
| 32 | void AutoMenuManager::reloadConfig() |
| 33 | { |
| 34 | InitPrimaryConfig(); |
| 35 | |
| 36 | // Reset menu activation variables |
| 37 | this->actRaceSel = false; |
| 38 | this->actStartedGame = false; |
| 39 | this->autoMapTryCount = 0; |
| 40 | |
| 41 | //this function is called when starcraft loads and at the end of each match. |
| 42 | //the function loads the parameters for the auto-menu feature such as auto_menu, map, race, enemy_race, enemy_count, and game_type |
| 43 | this->autoMenuMode = LoadConfigStringUCase("auto_menu", "auto_menu", "OFF"); |
| 44 | #ifdef _DEBUG |
| 45 | this->autoMenuPause = LoadConfigStringUCase("auto_menu", "pause_dbg", "OFF"); |
| 46 | #endif |
| 47 | this->autoMenuRestartGame = LoadConfigStringUCase("auto_menu", "auto_restart", "OFF"); |
| 48 | this->autoMenuGameName = LoadConfigString("auto_menu", "game"); |
| 49 | this->autoMenuCharacterName = LoadConfigString("auto_menu", "character_name", "FIRST").substr(0, 24); |
| 50 | |
| 51 | // Load map string |
| 52 | std::string cfgMap = LoadConfigString("auto_menu", "map", ""); |
| 53 | std::replace(cfgMap.begin(), cfgMap.end(), '/', '\\'); |
| 54 | |
| 55 | // Used to check if map string was changed. |
| 56 | static std::string lastAutoMapString; |
| 57 | bool mapChanged = false; |
| 58 | |
| 59 | // If the auto-menu map field was changed |
| 60 | |
| 61 | if (lastAutoMapString != cfgMap) |
| 62 | { |
| 63 | lastAutoMapString = cfgMap; |
| 64 | this->lastAutoMapEntry = 0; |
| 65 | this->lastMapGen.clear(); |
| 66 | this->autoMapPool.clear(); |
| 67 | |
| 68 | // Get just the directory |
| 69 | this->autoMenuMapPath.clear(); |
| 70 | size_t tmp = cfgMap.find_last_of("\\/\n"); |
| 71 | if (tmp != std::string::npos) |
| 72 | this->autoMenuMapPath = cfgMap.substr(0, tmp); |
| 73 | this->autoMenuMapPath += "\\"; |
| 74 | |
| 75 | // Iterate files in directory |
| 76 | WIN32_FIND_DATAA finder = { 0 }; |
| 77 | HANDLE hFind = FindFirstFileA(cfgMap.c_str(), &finder); |
| 78 | |
| 79 | if (hFind != INVALID_HANDLE_VALUE) |
| 80 | { |
| 81 | do |
| 82 | { |
| 83 | if (!(finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // Check if found is not a directory |
| 84 | { |
| 85 | // Convert to string and add to autoMapPool if the type is valid |
| 86 | std::string finderStr = std::string(finder.cFileName); |
| 87 | if (getFileType(this->autoMenuMapPath + finderStr)) |
| 88 | { |
| 89 | this->autoMapPool.push_back(finderStr); |
no test coverage detected