Exemplo n.º 1
0
        private static void Save()
        {
            PrintLine("Atempting Save of leaderboards");
            FileStream fs = UFile.Create(_savePath);

            CustomXmlWriter cxw = CustomXmlWriter.Create(fs);

            cxw.WriteStartDocument();
            cxw.WriteStartElement("LocalScores");
            foreach (QueuededScore qs in _scoresToSend)
            {
                cxw.WriteStartElement("ScoresToSend");

                cxw.WriteAttributeString("Leaderboard", qs.Leaderboard);
                cxw.WriteAttributeULong("Id", qs.Score.Principal_ID);
                cxw.WriteAttributeULong("Nex_Id", qs.Score.Nex_Unique_ID);
                cxw.WriteAttributeULong("Misc", qs.Score.Misc);
                cxw.WriteAttributeUInt("Score", qs.Score.Score);
                cxw.WriteAttributeArray <byte>("Cud", qs.Score.CommonDataBinary);
                cxw.WriteAttributeString("UserName", qs.Score.CommonDataUserName);
                cxw.WriteAttributeInt("Type", (int)qs.Type);
                cxw.WriteEndElement();
            }

            foreach (KeyValuePair <string, List <HighScore> > kvp in _localLeaderboards)
            {
                cxw.WriteStartElement("Leaderboard");
                cxw.WriteAttributeString("Name", kvp.Key);

                foreach (HighScore hs in kvp.Value)
                {
                    cxw.WriteStartElement("Score");
                    cxw.WriteAttributeULong("Id", hs.Principal_ID);
                    cxw.WriteAttributeULong("Nex_Id", hs.Nex_Unique_ID);
                    cxw.WriteAttributeUInt("Score", hs.Score);
                    cxw.WriteAttributeULong("Misc", hs.Misc);
                    cxw.WriteAttributeString("UserName", hs.CommonDataUserName);
                    cxw.WriteAttributeArray <byte>("Cud", hs.CommonDataBinary);
                    cxw.WriteEndElement();
                }
                cxw.WriteEndElement();
            }
            cxw.WriteEndElement();

            cxw.WriteEndDocument();
            cxw.Close();
            fs.Close();
            UFile.Commit();
            PrintLine("Save Compleate");
        }
Exemplo n.º 2
0
 public void EndDebugLog()
 {
     try
     {
         if (mLogXmlWriter != null)
         {
             // Closes the file handles too
             mLogXmlWriter.WriteEndDocument();
             mLogXmlWriter = null;
         }
     }
     catch (Exception ex)
     {
     }
 }
 public void EndDebugLog()
 {
     try
     {
         if (mLogXmlWriter != null)
         {
             // Closes the file handles too
             mLogXmlWriter.WriteEndDocument();
             mLogXmlWriter = null;
         }
     }
     catch (Exception ex)
     {
         Message.Sender.ShowError(this, "Cannot stop debugging", false, ex);
     }
 }
        public void Debug(object sender, string msg)
        {
            string finalMsg = sender.GetType().ToString() + " - " + msg;
            StyledNotification.Format format = new StyledNotification.Format(finalMsg, StyledNotification.NotificationStyle.kSystemMessage);
            StyledNotification.Show(format);

            bool result;
            try
            {
                if (addHeader)
                {
                    Common.sLogEnumerator++;
                    string[] array = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[]
            {
                '\n'
            });
                    string[] array2 = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[]
            {
                '\n'
            });
                    string text2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Common.NewLine;
                    string text3 = text2;
                    text2 = string.Concat(new string[]
            {
                text3,
                "<",
                VersionStamp.sNamespace,
                ">",
                Common.NewLine
            });
                    object obj = text2;
                    text2 = string.Concat(new object[]
            {
                obj,
                "<ModVersion value=\"",
                VersionStamp.sVersion,
                "\"/>",
                Common.NewLine
            });
                    int num = (array.Length > array2.Length) ? array2.Length : array.Length;
                    for (int i = 0; i < num; i++)
                    {
                        string text4 = array[i].Replace(":", "").Replace(" ", "");
                        string a;
                        if ((a = text4) != null && (a == "GameVersion" || a == "BuildVersion"))
                        {
                            string text5 = text2;
                            text2 = string.Concat(new string[]
                    {
                        text5,
                        "<",
                        text4,
                        " value=\"",
                        array2[i],
                        "\"/>",
                        Common.NewLine
                    });
                        }
                    }
                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        object obj2 = text2;
                        text2 = string.Concat(new object[]
                {
                    obj2,
                    "<Installed=\"",
                    productFlags,
                    "\"/>",
                    Common.NewLine
                });
                    }
                    object obj3 = text2;
                    text2 = string.Concat(new object[]
            {
                obj3,
                "<Enumerator value=\"",
                Common.sLogEnumerator,
                "\"/>",
                Common.NewLine
            });
                    text2 = text2 + "<Content>" + Common.NewLine;
                    text = text2 + text.Replace("&", "&amp;");
                    text = text + Common.NewLine + "</Content>";
                    string text6 = text;
                    text = string.Concat(new string[]
            {
                text6,
                Common.NewLine,
                "</",
                VersionStamp.sNamespace,
                ">"
            });
                }
                uint num2 = 0u;
                Simulator.CreateScriptErrorFile(ref num2);
                if (num2 != 0u)
                {
                    CustomXmlWriter customXmlWriter = new CustomXmlWriter(num2);
                    customXmlWriter.WriteToBuffer(text);
                    customXmlWriter.WriteEndDocument();
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return result;
        }
Exemplo n.º 5
0
        public static bool WriteLog(string text, bool addHeader, bool scripterror, bool printmessage)
        {
            try
            {
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }



                if (addHeader)
                {
                    sLogEnumerator++;

                    try
                    {
                        if (printmessage)
                        {
                            PrintMessage("Write Log is Created");
                        }
                        else if (scripterror)
                        {
                            PrintMessage("NiecMod " + NewLine + "Script Error is Found No: " + sLogEnumerator);
                        }
                    }
                    catch (Exception)
                    { }

                    string[] labels = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[] { '\n' });
                    string[] data   = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[] { '\n' });

                    string header = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + NewLine;
                    header += "<" + "NiecMod" + ">" + NewLine;
                    try
                    {
                        header += "<ModVersion value=\"" + "1.0" + "\"/>" + NewLine;
                    }
                    catch (Exception)
                    {
                        header += "<ModVersion value=\"" + "1.0" + "\"/>" + NewLine;
                    }


                    int num2 = (labels.Length > data.Length) ? data.Length : labels.Length;
                    for (int j = 0x0; j < num2; j++)
                    {
                        string label = labels[j].Replace(":", "").Replace(" ", "");

                        switch (label)
                        {
                        //case "GameVersion":
                        case "BuildVersion":
                            header += "<" + label + " value=\"" + data[j] + "\"/>" + NewLine;
                            break;
                        }
                    }

                    IGameUtils utils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (utils != null)
                    {
                        ProductVersion version = (ProductVersion)utils.GetProductFlags();

                        header += "<Installed value=\"" + version + "\"/>" + NewLine;
                    }

                    header += "<Enumerator value=\"" + sLogEnumerator + "\"/>" + NewLine;
                    header += "<Content>" + NewLine;
                    if (scripterror)
                    {
                        header += ScriptError() + NewLine;
                    }
                    text = header + text.Replace("&", "&amp;");//.Replace(NewLine, "  <br />" + NewLine);

                    text += NewLine + "</Content>";
                    text += NewLine + "</" + "NiecMod" + ">";
                }

                uint   fileHandle = 0x0;
                string str        = Simulator.CreateScriptErrorFile(ref fileHandle);
                if (fileHandle != 0x0)
                {
                    CustomXmlWriter xmlWriter = new CustomXmlWriter(fileHandle);

                    xmlWriter.WriteToBuffer(text);

                    xmlWriter.WriteEndDocument();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public void Debug(object sender, string msg)
        {
            string finalMsg = sender.GetType().ToString() + " - " + msg;

            StyledNotification.Format format = new StyledNotification.Format(finalMsg, StyledNotification.NotificationStyle.kSystemMessage);
            StyledNotification.Show(format);


            bool result;

            try
            {
                if (addHeader)
                {
                    Common.sLogEnumerator++;
                    string[] array = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[]
                    {
                        '\n'
                    });
                    string[] array2 = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[]
                    {
                        '\n'
                    });
                    string text2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Common.NewLine;
                    string text3 = text2;
                    text2 = string.Concat(new string[]
                    {
                        text3,
                        "<",
                        VersionStamp.sNamespace,
                        ">",
                        Common.NewLine
                    });
                    object obj = text2;
                    text2 = string.Concat(new object[]
                    {
                        obj,
                        "<ModVersion value=\"",
                        VersionStamp.sVersion,
                        "\"/>",
                        Common.NewLine
                    });
                    int num = (array.Length > array2.Length) ? array2.Length : array.Length;
                    for (int i = 0; i < num; i++)
                    {
                        string text4 = array[i].Replace(":", "").Replace(" ", "");
                        string a;
                        if ((a = text4) != null && (a == "GameVersion" || a == "BuildVersion"))
                        {
                            string text5 = text2;
                            text2 = string.Concat(new string[]
                            {
                                text5,
                                "<",
                                text4,
                                " value=\"",
                                array2[i],
                                "\"/>",
                                Common.NewLine
                            });
                        }
                    }
                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        object         obj2         = text2;
                        text2 = string.Concat(new object[]
                        {
                            obj2,
                            "<Installed=\"",
                            productFlags,
                            "\"/>",
                            Common.NewLine
                        });
                    }
                    object obj3 = text2;
                    text2 = string.Concat(new object[]
                    {
                        obj3,
                        "<Enumerator value=\"",
                        Common.sLogEnumerator,
                        "\"/>",
                        Common.NewLine
                    });
                    text2 = text2 + "<Content>" + Common.NewLine;
                    text  = text2 + text.Replace("&", "&amp;");
                    text  = text + Common.NewLine + "</Content>";
                    string text6 = text;
                    text = string.Concat(new string[]
                    {
                        text6,
                        Common.NewLine,
                        "</",
                        VersionStamp.sNamespace,
                        ">"
                    });
                }
                uint num2 = 0u;
                Simulator.CreateScriptErrorFile(ref num2);
                if (num2 != 0u)
                {
                    CustomXmlWriter customXmlWriter = new CustomXmlWriter(num2);
                    customXmlWriter.WriteToBuffer(text);
                    customXmlWriter.WriteEndDocument();
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }