Beispiel #1
0
        public void serializeToJSON(Message message)
        {
            // Look into the message collection for duplicates
            MessageCollection collection = loadFile(_connectionPath);

            // add message to collection or throw error
            switch (message.MessageType)
            {
            case "S":
                if (collection.SMSList.ContainsKey(message.Header))
                {
                    throw new Exception($"{message.Header} message not saved: the database already contains the message.");
                }
                SMS sms = (SMS)message;
                collection.SMSList.Add(message.Header, sms);
                break;

            case "E":
                Email email = (Email)message;
                if (email.EmailType == "SEM")
                {
                    if (collection.SEMList.ContainsKey(message.Header))
                    {
                        throw new Exception($"{message.Header} message not saved: the database already contains the message.");
                    }
                    SEM sem = (SEM)email;
                    collection.SEMList.Add(message.Header, sem);
                }
                else if (email.EmailType == "SIR")
                {
                    if (collection.SIRList.ContainsKey(message.Header))
                    {
                        throw new Exception($"{message.Header} message not saved: the database already contains the message.");
                    }
                    SIR sir = (SIR)email;
                    collection.SIRList.Add(message.Header, sir);
                }
                break;

            case "T":
                if (collection.TweetList.ContainsKey(message.Header))
                {
                    throw new Exception($"{message.Header} message not saved: the database already contains the message.");
                }
                Tweet tweet = (Tweet)message;
                collection.TweetList.Add(message.Header, tweet);
                break;

            default:
                break;
            }

            string jsonString = JsonSerializer.Serialize(collection, new JsonSerializerOptions
            {
                WriteIndented = true,
                Encoder       = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
            });

            File.WriteAllText(ConnectionPath, jsonString);
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void scriptArrayEditor_SelectedObjectChanged(object sender, EventArgs e)
 {
     if (scriptArrayEditor.SelectedObject is SEMScript sound)
     {
         scriptBox.Text = SEM.DecompileSEMScript(sound.CommandData);
     }
 }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        public override void Work(BackgroundWorker w)
        {
            if (!editor.FighterControl.FighterEntries.Contains(fighter))
            {
                w.ReportProgress(100);
                return;
            }

            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var plco = Path.Combine(root, "PlCo.dat");
            var sem  = Path.Combine(root, "audio\\us\\smash2.sem");

            if (!File.Exists(plco))
            {
                throw new FileNotFoundException("PlCo.dat was not found");
            }

            if (!File.Exists(sem))
            {
                throw new FileNotFoundException("smash2.sem was not found");
            }

            ProgressStatus = "Removing Bone Entry";
            w.ReportProgress(0);
            RemoveBoneTableEntry(plco);

            ProgressStatus = "Removing Fighter Entry";
            w.ReportProgress(20);
            editor.FighterControl.RemoveFighterEntry(internalID);

            ProgressStatus = "Removing Items";
            w.ReportProgress(40);
            RemoveMEXItems();

            ProgressStatus = "Removing Fighter Effects";
            w.ReportProgress(50);
            RemoveMEXEffects();

            ProgressStatus = "Removing Sounds";
            w.ReportProgress(60);
            RemoveSounds();

            ProgressStatus = "Removing UI";
            w.ReportProgress(70);
            RemoveUI(fighter, editor, internalID);

            // TODO: remove unused files

            ProgressStatus = "Saving Files";
            w.ReportProgress(90);
            SEM.SaveSEMFile(sem, SemEntries, editor._data);

            foreach (var v in editedFiles)
            {
                v.Item1.Save(v.Item2, v.Item3);
            }

            ProgressStatus = "Done";
            w.ReportProgress(100);
        }
Beispiel #4
0
            /// <summary>
            /// 写入INI
            /// </summary>
            public static void IniW()
            {
                IniW RA2CA = new IniW(AppDomain.CurrentDomain.BaseDirectory + "ra2ca.ini");

                if (IsWindow)
                {
                    RA2CA.IniWriteValue("Video", "Video.Windowed", "1");
                }
                else
                {
                    RA2CA.IniWriteValue("Video", "Video.Windowed", "0");
                }

                if (NoFrame)
                {
                    RA2CA.IniWriteValue("Video", "NoWindowFrame", "1");
                }
                else
                {
                    RA2CA.IniWriteValue("Video", "NoWindowFrame", "0");
                }

                RA2CA.IniWriteValue("Options", "Difficulty", Difficult.ToString());

                RA2CA.IniWriteValue("Audio", "SoundVolume", BGM.ToString());
                RA2CA.IniWriteValue("Audio", "VoiceVolume", VOX.ToString());
                RA2CA.IniWriteValue("Audio", "ScoreVolume", SEM.ToString());

                RA2CA.IniWriteValue("Video", "ScreenWidth", Width.ToString());
                RA2CA.IniWriteValue("Video", "ScreenHeight", Height.ToString());
            }
Beispiel #5
0
        public void SobstituteURL_AddingToURLList_ShouldNotAdd()
        {
            Processor processor        = new Processor();
            SEM       message          = new SEM("E000000000", "*****@*****.**", "Hello World", "Hello");
            Message   processedMessage = processor.ProcessMessage(message);

            Assert.AreEqual(0, processor.QuarantinedLinks.Count);
        }
Beispiel #6
0
        public void GetSetErrorModeTest()
        {
            SEM sem = 0;

            Assert.That(() => sem = GetErrorMode(), Throws.Nothing);
            Assert.That(SetErrorMode(SEM.SEM_FAILCRITICALERRORS), Is.EqualTo(sem));
            SetErrorMode(sem);
        }
Beispiel #7
0
        public void SobstituteURL_AddingToURLList_ShouldPass()
        {
            Processor processor        = new Processor();
            SEM       message          = new SEM("E000000000", "*****@*****.**", "Hello World", "http:\\\\mywebsite.com");
            Message   processedMessage = processor.ProcessMessage(message);

            // Should return 1 as it is the count of the existing key
            Assert.AreEqual(1, processor.QuarantinedLinks["http:\\\\mywebsite.com"]);
        }
Beispiel #8
0
        public void GetSetThreadErrorModeTest()
        {
            SEM sem = 0;

            Assert.That(() => sem = GetThreadErrorMode(), Throws.Nothing);
            Assert.That(SetThreadErrorMode(SEM.SEM_FAILCRITICALERRORS, out var old), Is.True);
            Assert.That(sem, Is.EqualTo(old));
            SetThreadErrorMode(sem, out _);
        }
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSaveScript_Click(object sender, EventArgs e)
 {
     if (scriptArrayEditor.SelectedObject is SEMScript sound)
     {
         byte[] d;
         if (SEM.CompileSEMScript(scriptBox.Text, out d) == -1)
         {
             sound.CommandData = d;
         }
         scriptBox.Text = SEM.DecompileSEMScript(sound.CommandData);
     }
 }
Beispiel #10
0
    // Update is called once per frame
    void Update()
    {
        mouse_wheel();
        float mouse_x_delta = Input.GetAxis("Mouse X");
        float mouse_y_delta = Input.GetAxis("Mouse Y");
        var   pos_center    = new Vector3(GameInfo.field_width / 2, GameInfo.field_width / 2, GameInfo.field_width / 2);

        if (Input.GetMouseButton(0) && (Mathf.Abs(mouse_x_delta) > 0 || Mathf.Abs(mouse_y_delta) > 0))
        {
            Creator.Stage.transform.RotateAround(pos_center, Camera.main.transform.up, mouse_x_delta * 2);
            Creator.Stage.transform.RotateAround(pos_center, Camera.main.transform.right, mouse_y_delta * 2);
            moving = true;
        }


        // 左クリックが0、右クリックが1
        for (var i = 0; i < 2; i++)
        {
            //クリアしている場合は開けさせない 視点移動は許可する
            if (Input.GetMouseButtonUp(i) && GameInfo.game_stop == false)
            {
                //視点移動していたら開けない
                if (moving == true)
                {
                    moving = false;
                    return;
                }
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit = new RaycastHit();
                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.collider.gameObject.tag == "cover")
                    {
                        SEM.se_play((int)SEManager.SENUM.CLICK);
                        if (i == 0)
                        {
                            hit.collider.gameObject.GetComponent <ObjInfo> ().cover_delete();
                        }
                        else
                        {
                            hit.collider.gameObject.GetComponent <ObjInfo> ().banner_up();
                        }
                    }
                }
            }
        }
    }
Beispiel #11
0
    protected void Forgot(object sender, EventArgs e)
    {
        String SaltKey           = Account.Email2Hash(Email.Text);
        String EncryptedPassword = Account.Email2EncryptedPassword(Email.Text);

        if (SaltKey == null || EncryptedPassword == null)
        {
            FailureText.Text = "Email inválido.";
            return;
        }

        String PlainPassword = SEM.Decrypt(EncryptedPassword, SaltKey);

        if (Mailer.SendMail(Mailer.ForgotPassword(Email.Text, PlainPassword)))
        {
            FailureText.Text = "Email enviado com sucesso para " + Email.Text;
        }
    }
    protected void ChangePassword(object sender, EventArgs e)
    {
        WebsiteUser Op = (WebsiteUser)Session["User"];

        if (IsValid)
        {
            if (SEM.Encrypt(CurrentPassword.Text, Account.Email2Hash(Op.Email)) == Account.Email2EncryptedPassword(Op.Email))
            {
                if (SEM.Encrypt(CurrentPassword.Text, Account.Email2Hash(Op.Email)) != SEM.Encrypt(NewPassword.Text, Account.Email2Hash(Op.Email)))
                {
                    Op.EncryptedPassword = SEM.Encrypt(NewPassword.Text, Account.Email2Hash(Op.Email));
                    if (Op.SaveChangesToDatabase())
                    {
                        FailureText.Text     = "Password alterada com sucesso. Por favor volte a fazer login.";
                        ErrorMessage.Visible = true;
                        Session["User"]      = new WebsiteUser(Op.Email, 1);
                        Response.AddHeader("REFRESH", "5;URL=Logout");
                    }
                    else
                    {
                        FailureText.Text     = "Erro desconhecido.";
                        ErrorMessage.Visible = true;
                    }
                }
                else
                {
                    FailureText.Text     = "Password actual nao pode ser igual à nova.";
                    ErrorMessage.Visible = true;
                }
            }
            else
            {
                FailureText.Text     = "Password actual incorrecta.";
                ErrorMessage.Visible = true;
            }
        }
    }
Beispiel #13
0
        public Message ProcessMessage(Message message)
        {
            switch (message.MessageType)
            {
            case "S":
                SMS sms = new SMS(message.Header, message.Sender, message.Text);
                sms = ProcessSMS(sms);
                return(sms);

            case "E":
                Email email = (Email)message;
                if (email.EmailType == "SEM")
                {
                    SEM sem = (SEM)email;
                    sem = ProcessSEM(sem);
                    return(sem);
                }
                else if (email.EmailType == "SIR")
                {
                    SIR sir = (SIR)email;
                    sir = ProcessSIR(sir);
                    return(sir);
                }
                else
                {
                    throw new Exception("Email type not recognized, please make sure you have a valid email type.");
                }

            case "T":
                Tweet tweet = new Tweet(message.Header, message.Sender, message.Text);
                tweet = ProcessTweet(tweet);
                return(tweet);

            default:
                throw new Exception("Incorrect message type");
            }
        }
Beispiel #14
0
 private SEM ProcessSEM(SEM message)
 {
     message.Text = SobstituteURL(message.Text);
     return(message);
 }
 public static extern SEM SetErrorMode(SEM uMode);
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fighter"></param>
        /// <param name="editor"></param>
        private void RemoveSounds()
        {
            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var sem  = Path.Combine(root, "audio\\us\\smash2.sem");

            if (!File.Exists(sem))
            {
                return;
            }

            // Load SEM File
            SemEntries = SEM.ReadSEMFile(sem, true, editor._data);

            // remove narrator call
            var inUse = editor.FighterControl.FighterEntries.Any(e => e.AnnouncerCall == fighter.AnnouncerCall);

            if (!inUse)
            {
                var nameBank = SemEntries.Find(e => e.SoundBank?.Name == "nr_name.ssm");
                //nameBank.RemoveSoundAt(fighter.AnnouncerCall % 10000);
                // TODO: remove narrator name call

                foreach (var v in editor.FighterControl.FighterEntries)
                {
                    if (v.AnnouncerCall > fighter.AnnouncerCall)
                    {
                        v.AnnouncerCall -= 1;
                    }
                }
            }

            // remove ssm
            var ssminUse = editor.FighterControl.FighterEntries.Any(e => e.SSMIndex == fighter.SSMIndex);

            if (!ssminUse)
            {
                SemEntries.RemoveAt(fighter.SSMIndex);

                foreach (var v in editor.FighterControl.FighterEntries)
                {
                    if (v.SSMIndex > fighter.SSMIndex)
                    {
                        v.SSMIndex -= 1;
                    }
                }
            }

            // remove victory theme
            var vicinUse = editor.FighterControl.FighterEntries.Any(e => e.VictoryThemeID == fighter.VictoryThemeID);

            if (!vicinUse)
            {
                editor.MusicControl.RemoveMusicAt(fighter.VictoryThemeID);

                foreach (var v in editor.FighterControl.FighterEntries)
                {
                    if (v.VictoryThemeID > fighter.VictoryThemeID)
                    {
                        v.VictoryThemeID -= 1;
                    }
                }
            }
        }
Beispiel #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="packagePath"></param>
        public override void Work(BackgroundWorker w)
        {
            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);
            var plco = Path.Combine(root, "PlCo.dat");
            var sem  = Path.Combine(root, "audio\\us\\smash2.sem");

            if (!File.Exists(plco))
            {
                throw new FileNotFoundException("PlCo.dat was not found");
            }

            if (!File.Exists(sem))
            {
                throw new FileNotFoundException("smash2.sem was not found");
            }

            using (ZipFile pack = new ZipFile(packagePath))
            {
                string fighterYAMLPath = null;

                foreach (var e in pack)
                {
                    Console.WriteLine(e.FileName);
                    if (Path.GetFileName(e.FileName).ToLower() == "fighter.yaml")
                    {
                        fighterYAMLPath = e.FileName;
                    }
                }

                if (string.IsNullOrEmpty(fighterYAMLPath))
                {
                    return;
                }

                MEXFighterEntry mexEntry = null;

                using (MemoryStream zos = new MemoryStream())
                {
                    pack[fighterYAMLPath].Extract(zos);
                    zos.Position = 0;
                    //using (StreamReader r = new StreamReader(zos))
                    //    mexEntry = MEXFighterEntry.Deserialize(r.ReadToEnd());
                }

                if (mexEntry == null)
                {
                    return;
                }

                ProgressStatus = $"Importing  {mexEntry.NameText}...";
                w.ReportProgress(0);

                var internalID = editor.FighterControl.AddEntry(mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(10);
                ImportItemData(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(20);
                GenerateEffectFile(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(30);
                ImportSoundData(pack, mexEntry, sem);

                ProgressStatus = "Installing UI"; w.ReportProgress(50);
                InstallUI(pack, mexEntry);

                ProgressStatus = "Installing Item Data"; w.ReportProgress(60);
                InjectBoneTable(pack, plco, internalID);

                //...
                ProgressStatus = "Extracting Files";
                w.ReportProgress(70);
                ExtractFiles(pack, mexEntry, editor);

                ProgressStatus = "Building new SEM";
                w.ReportProgress(80);
                if (SemEntries.Count != 0)
                {
                    SEM.SaveSEMFile(sem, SemEntries, editor._data);
                }

                ProgressStatus = "Saving Files";
                w.ReportProgress(90);
                foreach (var d in editedFiles)
                {
                    d.Item1.Save(d.Item2, d.Item3);
                }

                ProgressStatus = "Done";
                w.ReportProgress(100);
                // done
                Console.WriteLine($"Done!");
            }
        }
Beispiel #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pack"></param>
        /// <param name="fighter"></param>
        /// <param name="editor"></param>
        /// <returns>Dictionary to maps old sound id values to new values</returns>
        private void ImportSoundData(ZipFile pack, MEXFighterEntry fighter, string semFile)
        {
            Console.WriteLine($"Importing Sound Data...");

            var root = Path.GetDirectoryName(MainForm.Instance.FilePath);

            // Load SEM File
            SemEntries = SEM.ReadSEMFile(semFile, true, editor._data);

            // narrator call-----------------------------------------------
            var narratorScript = @".SFXID : (id)
.REVERB : 48
.PRIORITY : 15
.UNKNOWN06 : 229
.END : 0";
            var narr           = pack["Sound/narrator.dsp"];

            var nameBank = SemEntries.Find(e => e.SoundBank?.Name == "nr_name.ssm");

            if (narr != null && nameBank != null)
            {
                var narsound = new DSP();
                narsound.FromFormat(GetBytes(narr), "dsp");
                var index = nameBank.SoundBank.Sounds.Length;
                nameBank.SoundBank.AddSound(narsound);

                var script = new SEMScript();
                SEM.CompileSEMScript(narratorScript.Replace("(id)", index.ToString()), out script.CommandData);
                var scriptIndex = nameBank.Scripts.Length;
                nameBank.AddScript(script);

                fighter.AnnouncerCall = scriptIndex + SemEntries.IndexOf(nameBank) * 10000;

                Console.WriteLine("Imported Announcer Call");
            }

            // Create and import SSM-----------------------------------------------

            var semYAML = pack["Sound/sem.yaml"];
            var ssmFile = pack["Sound/sound.ssm"];

            if (semYAML != null)
            {
                using (MemoryStream zos = new MemoryStream())
                {
                    semYAML.Extract(zos);
                    zos.Position = 0;
                    using (StreamReader r = new StreamReader(zos))
                    {
                        var semEntry = SEMEntry.Deserialize(r.ReadToEnd());

                        if (ssmFile != null)
                        {
                            var ssmName = fighter.NameText.ToLower() + ".ssm";
                            semEntry.SoundBank = new SSM();
                            using (MemoryStream ssmStream = new MemoryStream())
                            {
                                ssmFile.Extract(ssmStream);
                                ssmStream.Position = 0;
                                semEntry.SoundBank.Open(ssmName, ssmStream);
                            }
                            var ssmFilePath = Path.Combine(root, "audio\\us\\" + ssmName);
                            File.WriteAllBytes(ssmFilePath, GetBytes(ssmFile));
                        }

                        fighter.SSMIndex = SemEntries.Count;
                        SemEntries.Add(semEntry);
                    }
                }
            }


            // Import Victory Theme
            var victory = pack["Sound/victory.hps"];

            if (victory != null)
            {
                var ffname = $"ff_{fighter.NameText.ToLower()}.hps";
                fighter.VictoryThemeID = editor.MusicControl.AddMusic(new HSD_String()
                {
                    Value = ffname
                });

                var fffilePath = Path.Combine(root, "audio\\" + ffname);
                File.WriteAllBytes(fffilePath, GetBytes(victory));
            }
        }
Beispiel #19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="path"></param>
 public void SaveSEMFile(string path, MEX_Data mex = null)
 {
     SEM.SaveSEMFile(path, Entries.ToList(), mex);
 }
Beispiel #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="path"></param>
        public void OpenSEMFile(string path, MEX_Data mex = null)
        {
            Entries = SEM.ReadSEMFile(path, true, mex).ToArray();

            entryList.SetArrayFromProperty(this, "Entries");
        }