private List <CnCNetGame> GetCustomGames(List <CnCNetGame> existingGames) { IniFile iniFile = new IniFile(ProgramConstants.GetBaseResourcePath() + "GameCollectionConfig.ini"); List <CnCNetGame> customGames = new List <CnCNetGame>(); var section = iniFile.GetSection("CustomGames"); if (section == null) { return(customGames); } HashSet <string> customGameIDs = new HashSet <string>(); foreach (var kvp in section.Keys) { if (!iniFile.SectionExists(kvp.Value)) { continue; } string ID = iniFile.GetStringValue(kvp.Value, "InternalName", string.Empty).ToLower(); if (string.IsNullOrEmpty(ID)) { throw new GameCollectionConfigurationException("InternalName for game " + kvp.Value + " is not defined or set to an empty value."); } if (ID.Length > ProgramConstants.GAME_ID_MAX_LENGTH) { throw new GameCollectionConfigurationException("InternalGame for game " + kvp.Value + " is set to a value that exceeds length limit of " + ProgramConstants.GAME_ID_MAX_LENGTH + " characters."); } if (existingGames.Find(g => g.InternalName == ID) != null || customGameIDs.Contains(ID)) { throw new GameCollectionConfigurationException("Game with InternalName " + ID.ToUpper() + " already exists in the game collection."); } string iconFilename = iniFile.GetStringValue(kvp.Value, "IconFilename", ID + "icon.png"); customGames.Add(new CnCNetGame { InternalName = ID, UIName = iniFile.GetStringValue(kvp.Value, "UIName", ID.ToUpper()), ChatChannel = GetIRCChannelNameFromIniFile(iniFile, kvp.Value, "ChatChannel"), GameBroadcastChannel = GetIRCChannelNameFromIniFile(iniFile, kvp.Value, "GameBroadcastChannel"), ClientExecutableName = iniFile.GetStringValue(kvp.Value, "ClientExecutableName", string.Empty), RegistryInstallPath = iniFile.GetStringValue(kvp.Value, "RegistryInstallPath", "HKCU\\Software\\" + ID.ToUpper()), Texture = AssetLoader.AssetExists(iconFilename) ? AssetLoader.LoadTexture(iconFilename) : AssetLoader.TextureFromImage(Resources.unknownicon) }); customGameIDs.Add(ID); } return(customGames); }
public void AddTab(string text, int width) { string tabAssetName = width + "pxtab"; if (AssetLoader.AssetExists(tabAssetName + ".png")) { AddTab(text, AssetLoader.LoadTexture(tabAssetName + ".png"), AssetLoader.LoadTexture(tabAssetName + "_c.png")); } else { AddTab(text, AssetLoader.LoadTexture(width + "pxbtn.png"), AssetLoader.LoadTexture(width + "pxbtn_c.png")); } }
private List <CnCNetGame> GetCustomGames(List <CnCNetGame> existingGames) { IniFile iniFile = new IniFile(ProgramConstants.GetBaseResourcePath() + "GameCollectionConfig.ini"); List <CnCNetGame> customGames = new List <CnCNetGame>(); var section = iniFile.GetSection("CustomGames"); if (section == null) { return(customGames); } HashSet <string> customGameIDs = new HashSet <string>(); foreach (var kvp in section.Keys) { string ID = iniFile.GetStringValue(kvp.Value, "InternalName", string.Empty).ToLower(); if (string.IsNullOrEmpty(ID) || existingGames.Find(g => g.InternalName == ID) != null || customGameIDs.Contains(ID)) { continue; } string iconFilename = iniFile.GetStringValue(kvp.Value, "IconFilename", ID + "icon.png"); customGames.Add(new CnCNetGame { InternalName = ID, UIName = iniFile.GetStringValue(kvp.Value, "UIName", ID.ToUpper()), ChatChannel = iniFile.GetStringValue(kvp.Value, "ChatChannel", string.Empty), GameBroadcastChannel = iniFile.GetStringValue(kvp.Value, "GameBroadcastChannel", string.Empty), ClientExecutableName = iniFile.GetStringValue(kvp.Value, "ClientExecutableName", string.Empty), RegistryInstallPath = iniFile.GetStringValue(kvp.Value, "RegistryInstallPath", "HKCU\\Software\\" + ID.ToUpper()), Texture = AssetLoader.AssetExists(iconFilename) ? AssetLoader.LoadTexture(iconFilename) : AssetLoader.TextureFromImage(Resources.unknownicon) }); customGameIDs.Add(ID); } return(customGames); }