public static string interpretString(string thestring, GameObject gameobj, GameTypeSettingsObj gamesetobj) { ///$gamename ///$plrnumber ///$password ///$turnnumber ///$savepath ///$modpath string fmt = "000#"; thestring = thestring.Replace("$gamename", gameobj.GameName); thestring = thestring.Replace("$plrnumber", gameobj.GamePlrNumber.ToString(fmt)); thestring = thestring.Replace("$password", gameobj.GamePlrEmpPassword); thestring = thestring.Replace("$turnnumber", gameobj.GameTurnNum.ToString()); thestring = thestring.Replace("$savepath", gamesetobj.GameMods[gameobj.GameMod].ModSavePath); thestring = thestring.Replace("$modpath", gamesetobj.GameMods[gameobj.GameMod].ModPath); return thestring; }
public static Dictionary<string, GameTypeSettingsObj> GetGameSettings(string filename) { XDocument doc = LoadFile(filename); Dictionary<string, GameTypeSettingsObj> dicofgamesettings = new Dictionary<string, GameTypeSettingsObj>(); XContainer thisContainerRoot = doc.Root; foreach (var xnode in thisContainerRoot.Elements()) { string gametypeName = xnode.Name.ToString(); GameTypeSettingsObj thisgamesettingobj = new GameTypeSettingsObj(); dicofgamesettings.Add(gametypeName, thisgamesettingobj); thisgamesettingobj.GameTypeName = gametypeName; foreach (var gameElement in xnode.Elements()) { string gameNodeName = gameElement.Name.ToString(); if (gameNodeName == "gameExe") { thisgamesettingobj.GameExe = gameElement.Value.Trim(); } else if (gameNodeName == "workingDirectory") { thisgamesettingobj.WorkingDirectory = gameElement.Value.Trim(); } else if (gameNodeName == "gameArgs") { thisgamesettingobj.GameArguments = gameElement.Value.Trim(); } else if (gameNodeName == "preScriptPath") { thisgamesettingobj.GamePreScript = gameElement.Value.Trim(); } else if (gameNodeName == "postScriptPath") { thisgamesettingobj.GamePostScript = gameElement.Value.Trim(); } else if (gameNodeName == "uploadFileMask") { thisgamesettingobj.GameUploadFileMask = gameElement.Value.Trim(); } else if (gameNodeName == "MODS" || gameNodeName == "mods") { foreach (var modElement in gameElement.Elements()) { string modNodeName = modElement.Name.ToString(); ModSettingsObj thismodsettingobj = new ModSettingsObj(); thismodsettingobj.ModName = modNodeName; foreach (var moddataelemnt in modElement.Elements()) { string moddataNodeName = moddataelemnt.Name.ToString(); if (moddataNodeName == "modPath") { thismodsettingobj.ModPath = moddataelemnt.Value.Trim(); } if (moddataNodeName == "savePath") { thismodsettingobj.ModSavePath = moddataelemnt.Value.Trim(); } } thisgamesettingobj.GameMods.Add(modNodeName, thismodsettingobj); } } } } return dicofgamesettings; }