/** * Loads the ESC Platform Launcher's .plist via the plugin and * parses it as XML. The resulting Dictionary is then passed to * the Docent application. */ public void ReadGamesPlist() { Dictionary <string, string> newGamesList = new Dictionary <string, string>(); string appPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); appPath = appPath.Replace("/Documents", ""); string plistPath = appPath + "/esclauncher/Info.plist"; StringBuilder contents = new StringBuilder(16384); if (0 == GameInterface.getLauncherInfoPlist(plistPath, contents, (uint)contents.Capacity)) { // load external content string contentsString = contents.ToString(); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(contentsString); } catch (XmlException e) { Debug.LogWarning("Failed to load Info.plist: " + e.Message); return; } // parse loaded XML XmlNodeList dictList = xmlDoc.GetElementsByTagName("dict"); XmlNode xmlNode = dictList.Item(1); for (int i = 0; i < xmlNode.ChildNodes.Count; i += 2) { XmlNode keyNode = xmlNode.ChildNodes.Item(i); XmlNode valNode = xmlNode.ChildNodes.Item(i + 1); newGamesList.Add(keyNode.InnerText, valNode.InnerText); } // Compare new plist to existing plist for equality and send a new message to docent if they are not equal bool gameListsAreEqual = (gamesList.Count == newGamesList.Count); if (gameListsAreEqual) { foreach (var pair in gamesList) // If count is same, compare the key / values { string value; if (newGamesList.TryGetValue(pair.Key, out value)) // Requires value to be equal { if (value != pair.Value) { gameListsAreEqual = false; break; } } else // Requires key to be present { gameListsAreEqual = false; break; } } } if (!gameListsAreEqual) { gamesList = newGamesList; UpdateDocentGamesList(); } } else { Debug.LogWarning("Could not load Info.plist"); } }