Пример #1
0
        private void FormActMain_UpdateCheckClicked()
        {
            const int pluginId = 71;

            try
            {
                var localDate  = ActGlobals.oFormActMain.PluginGetSelfDateUtc(this);
                var remoteDate = ActGlobals.oFormActMain.PluginGetRemoteDateUtc(pluginId);
                if (localDate.AddHours(2) >= remoteDate)
                {
                    return;
                }

                var result = MessageBox.Show(Localization.GetText("ui-update-available-message"), Localization.GetText("ui-update-available-title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                var updatedFile = ActGlobals.oFormActMain.PluginDownload(pluginId);
                var pluginData  = ActGlobals.oFormActMain.PluginGetSelfData(this);
                if (pluginData.pluginFile.Directory != null)
                {
                    ActGlobals.oFormActMain.UnZip(updatedFile.FullName, pluginData.pluginFile.Directory.FullName);
                }

                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
                Application.DoEvents();
                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
            }
            catch (Exception ex)
            {
                ActGlobals.oFormActMain.WriteExceptionLog(ex, "Plugin Update Check");
            }
        }
Пример #2
0
 void oFormActMain_UpdateCheckClicked()
 {
     try
     {
         string   fileURL    = @"http://www.vxyz.me/files/PSO2ACT/PSO2ACT.dll";
         DateTime localDate  = ActGlobals.oFormActMain.PluginGetSelfDateUtc(this);
         DateTime remoteDate = GetRemoteLastUpdated(fileURL);
         if (localDate < remoteDate)
         {
             DialogResult result = MessageBox.Show("There is an updated version of the PSO2 Parsing Plugin.  Update it now?\n\n(If there is an update to ACT, you should click No and update ACT first.)", "New Version", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);
                 WebClient     w          = new WebClient();
                 w.DownloadFile(fileURL, pluginData.pluginFile.FullName + ".tmp");
                 pluginData.pluginFile.Delete();
                 File.Move(pluginData.pluginFile.FullName + ".tmp", pluginData.pluginFile.FullName);
                 ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
                 Application.DoEvents();
                 ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Plugin Update Failed: " + ex.Message);
         ActGlobals.oFormActMain.WriteExceptionLog(ex, "Plugin Update Failed");
     }
     Config.refreshFlag = true;
     return;
 }
Пример #3
0
 internal static void logOut(string text)
 {
     if (richTextBox1 != null)
     {
         ThreadInvokes.RichTextBoxAppendText(ActGlobals.oFormActMain, richTextBox1, DateTime.Now.ToString("O") + "|" + text + "\n");
     }
     //ActGlobals.oFormActMain.ParseRawLogLine(false, DateTime.Now, "00|" + DateTime.Now.ToString("O") + "|0048|F|" + text + "|");
 }
Пример #4
0
        private void DoUpdate()
        {
            ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);

            pluginData.pluginFile.Refresh();
            ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
            Application.DoEvents();
            ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
            say("Updated");
        }
Пример #5
0
        private void FormActMain_UpdateCheckClicked()
        {
            const int pluginId = 71;
            var       _logger  = Locator.Current.GetService <IActLogger>();

            try
            {
                var pluginData    = Locator.Current.GetService <ActPluginData>();
                var localVersion  = typeof(ACTPluginUpdateHelper).Assembly.GetName().Version;
                var remoteVersion = ActGlobals.oFormActMain.PluginGetRemoteVersion(pluginId);
                _logger.Write($"{localVersion} vs {remoteVersion}", LogLevel.Warn);

                if (localVersion >= Version.Parse(remoteVersion))
                {
                    return;
                }

                var result = MessageBox.Show(_localizationRepository.GetText("ui-update-available-message"), _localizationRepository.GetText("ui-update-available-title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                var updatedFile = ActGlobals.oFormActMain.PluginDownload(pluginId);
                if (pluginData.pluginFile.Directory != null)
                {
                    ActGlobals.oFormActMain.UnZip(updatedFile.FullName, pluginData.pluginFile.Directory.FullName);
                }

                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
                Application.DoEvents();
                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);

                MessageBox.Show(_localizationRepository.GetText("ui-update-restart-message"), _localizationRepository.GetText("ui-update-restart-title"), MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            catch (Exception ex)
            {
                ActGlobals.oFormActMain.WriteExceptionLog(ex, "Plugin Update Check");
            }
        }
Пример #6
0
        private void OFormActMain_UpdateCheckClicked()
        {
            try
            {
                using (HttpClient httpClient = new HttpClient(new HttpClientHandler
                {
                    AllowAutoRedirect = true
                }))
                {
                    string versionNumber = httpClient.GetStringAsync("https://porier-land.tk/api/act_plugin/version").Result;

                    if (versionNumber != VERSION_NUMBER)
                    {
                        if (MessageBox.Show(
                                string.Format(Language.Resource.GetString("UPDATE_QUESTION"), VERSION_NUMBER, versionNumber),
                                Language.Resource.GetString("UPDATE_TITLE"),
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string latestUrl = httpClient.GetStringAsync("https://porier-land.tk/api/act_plugin/latest").Result;
                            //string latestUrl = httpClient.GetStringAsync("https://porier-land.tk/api/act_plugin/latest_portable").Result;

                            byte[] latestBinary = httpClient.GetByteArrayAsync(latestUrl).Result;

                            ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);
                            pluginData.pluginFile.Delete();
                            File.WriteAllBytes(pluginData.pluginFile.FullName, latestBinary);
                            ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
                            Application.DoEvents();
                            ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(Language.Resource.GetString("UPDATE_EXCEPTION"));
            }
        }
 private void ControllerOnLogMessageAppend(bool fromView, string log)
 {
     ThreadInvokes.RichTextBoxAppendDateTimeLine(ActGlobals.oFormActMain, richTextBoxLog, log);
 }
 void Log(string LogText)
 {
     ThreadInvokes.RichTextBoxAppendDateTimeLine(ActGlobals.oFormActMain, rtbLog, LogText);
 }
Пример #9
0
        /* ---------- Trigger Setup ---------- */

        private void InitTriggers()
        {
            /*triggers.Add(new Trigger("02:Changed primary player to ([\\w' ]+)",
             *      delegate(Match match)
             *      {
             *              playerName = match.Groups[1].ToString();
             *      }));*/

            triggers.Add(new Trigger("SymsFrigde.eXXMG86jeDLPmjo27rQi",
                                     delegate(Match match)
            {
                ActPluginData pluginData = ActGlobals.oFormActMain.PluginGetSelfData(this);
                pluginData.pluginFile.Refresh();
                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, false);
                Application.DoEvents();
                ThreadInvokes.CheckboxSetChecked(ActGlobals.oFormActMain, pluginData.cbEnabled, true);
                say("Updated");
            }));

            //WT Automation

            triggers.Add(new Trigger("WT_MODE:ON",
                                     delegate(Match match)
            {
                wt_mode = true;
                say("Wondrous Tales mode On");
                if (wt_lists == null)
                {
                    wt_lists = new List <string[]>();
                }
                else
                {
                    wt_lists.Clear();
                }
            }));
            triggers.Add(new Trigger("WT_MODE:OFF",
                                     delegate(Match match)
            {
                wt_mode = false;
                say("Wondrous Tales mode Off");
            }));
            triggers.Add(new Trigger("WT:([a-zA-Z0-9 '\\-\\(\\);]+)",
                                     delegate(Match match)
            {
                if (wt_mode)
                {
                    wt_lists.Add(match.Groups[1].ToString().Split(';'));
                }
            }));
            triggers.Add(new Trigger("WT_FUNC:CALC",
                                     delegate(Match match)
            {
                if (wt_mode)
                {
                    tBox.Clear();
                    if (wt_list_dictionary == null)
                    {
                        wt_list_dictionary = new Dictionary <string, int>();
                    }
                    else
                    {
                        wt_list_dictionary.Clear();
                    }

                    foreach (string[] sA in wt_lists)
                    {
                        foreach (string s in sA)
                        {
                            string sL = s.ToLower().Trim();
                            if (wt_list_dictionary.ContainsKey(sL))
                            {
                                wt_list_dictionary[sL]++;
                            }
                            else
                            {
                                wt_list_dictionary.Add(sL, 1);
                            }
                        }
                    }

                    List <KeyValuePair <string, int> > wt_sorted = new List <KeyValuePair <string, int> >();
                    foreach (KeyValuePair <string, int> kv in wt_list_dictionary)
                    {
                        wt_sorted.Add(kv);
                    }
                    wt_sorted.Sort((a, b) => b.Value.CompareTo(a.Value));
                    foreach (KeyValuePair <string, int> kv in wt_sorted)
                    {
                        tBox.AppendText(kv.Key + ": " + kv.Value + Environment.NewLine);
                    }
                }
            }));


            // Midgardsormr
            triggers.Add(midgardsormr = new Trigger(
                             "Midgardsormr:(31AD|31AC|31B0|31AE)",
                             delegate(Match match)
            {
                string value = match.Value;

                if (value == "Midgardsormr:31AD")
                {
                    midgard_prev_state = 1; say("Cardinal Corner"); return;
                }                                                                                                                     // flip
                if (value == "Midgardsormr:31AC")
                {
                    midgard_prev_state = 2; say("In Out"); return;
                }                                                    // spin

                if (midgard_prev_state == 1)                         // flip
                {
                    if (value == "Midgardsormr:31AE")
                    {
                        say("Cardinal");                                                           //spin
                    }
                    if (value == "Midgardsormr:31B0")
                    {
                        say("Corner");                                                            //flip
                    }
                    midgard_prev_state = 0;
                }
                else if (midgard_prev_state == 2)                         // spin
                {
                    if (value == "Midgardsormr:31AE")
                    {
                        say("Out");                                                            //spin
                    }
                    if (value == "Midgardsormr:31B0")
                    {
                        say("In");                                                            //flip
                    }
                    midgard_prev_state = 0;
                }
            }
                             ));

            //Archive Peripheral
            triggers.Add(archivePeripheral = new Trigger(
                             "1B:.{8}:Right Arm Unit:.{4}:.{4}:009(\\w):",
                             delegate(Match match)
            {
                //Should be a single character D or C.
                // D = Blue, C = Orange
                string colorChar = match.Groups[1].ToString();
                // If assuming order will be static fails, can switch to checking what appears to be the UnitID of each hand
                // 0 = Unset, 1 = blue, 2 = orange
                if (archive_peripheral.Length < 2)
                {
                    archive_peripheral += colorChar; // This character should either be D or C, if it's not then something was incorrectly captured
                }
                else                                 //The final set has been reached
                {
                    archive_peripheral += colorChar; // Adding the final character

                    switch (archive_peripheral)
                    {
                    case "DDD":
                        say("West");
                        break;

                    case "CDD":
                        say("North West");
                        break;

                    case "CCD":
                        say("North East");
                        break;

                    case "CCC":
                        say("East");
                        break;

                    case "DCC":
                        say("South East");
                        break;

                    case "DDC":
                        say("South West");
                        break;

                    default:
                        say("I broke it");
                        break;
                    }
                    archive_peripheral = "";
                }
            }
                             ));

            if (playerName != "")
            {
                //Nael Fireballs A, player name filled in
                triggers.Add(naelFireballs = new Trigger(
                                 "23:.{8}:.*:.{8}:([\\s\\w']*):.{4}:.{4}:0005",
                                 delegate(Match match)
                {
                    string name = match.Groups[1].ToString();
                    switch (fireball_count)
                    {
                    case 0:                                     // First Fire
                        if (Regex.Match(name, playerName).Success)
                        {
                            say("Fire in");
                        }
                        break;

                    case 1:                                     // Second Fire
                        if (Regex.Match(name, playerName).Success)
                        {
                            had_second_fireball = true;
                            say("Fire out");
                        }
                        break;

                    case 2:                                     // Third Fire
                        if (had_second_fireball)
                        {
                            say("Avoid fireball");
                        }
                        else if (Regex.Match(name, playerName).Success)
                        {
                            say("Fire in");
                        }
                        break;

                    case 3:                                     // Fourth fire
                        if (Regex.Match(name, playerName).Success)
                        {
                            say("Fire in");
                        }
                        had_second_fireball = false;
                        break;
                    }

                    fireball_count = fireball_count == 3 ? 0 : fireball_count + 1;
                }));
            }
            else
            {
                //Nael Fireballs B, player name NOT filled in
                triggers.Add(naelFireballs = new Trigger(
                                 "23:.{8}:.*:.{8}:([\\s\\w']*):.{4}:.{4}:0005",
                                 delegate(Match match)
                {
                    string firstName = match.Groups[1].ToString().Split(' ')[0];
                    //addLine(firstName);
                    switch (fireball_count)
                    {
                    case 0:                                     // First Fire
                        say(firstName + " in");
                        break;

                    case 1:                                     // Second Fire
                        second_fireball_name = firstName;
                        say(firstName + " out");
                        break;

                    case 2:                                     // Third Fire
                        say(firstName + " in. " + second_fireball_name + " out");
                        second_fireball_name = "";
                        break;

                    case 3:                                     // Fourth fire
                        say(firstName + " in");
                        had_second_fireball = false;
                        break;
                    }
                    fireball_count = fireball_count == 3 ? 0 : fireball_count + 1;
                }));
            }

            triggers.Add(autoEnd = new Trigger("(wipeout|0038:end|21:([0-9,a-f,A-F]{8}):40000010)",
                                               delegate(Match match)
            {
                ActGlobals.oFormActMain.EndCombat(true);
            }
                                               ));

            //Paisley Park load preset

            /*triggers.Add(new Trigger("^\\[\\d\\d:\\d\\d:\\d\\d\\.\\d{3}] 00:0038:PPLP:(.*)",
             *      delegate (Match match)
             *      {
             *              say(match.Groups[1].ToString());
             *              loadPreset(match.Groups[1].ToString());
             *      }
             * ));*/

            /*triggers.Add(new Trigger("^\\[\\d\\d:\\d\\d:\\d\\d\\.\\d{3}] 00:0038:PPPM:(.*)",
             *      delegate (Match match)
             *      {*/
            //{"One":{"X":108.0,"Y":0.0,"Z":100.0,"ID":1,"Active":true}}

            /*
             * {"One" :
             *	{"X":108.0,"Y":0.0,"Z":100.0,"ID":1,"Active":true}
             * }
             * A;X;Y;Z
             */
            /*	string[] split = match.Groups[1].ToString().Split(';');
             *      //say("Placing " + split[0] + " at X " + split[1] + " Y " + split[2] + " Z " + split[3]);
             *      string output = "{\"" + split[0] + "\":{\"X\":" + split[1] + ",\"Y\":" + split[2] + ",\"Z\":" + split[3] + ",\"Active\":true}}";
             *
             *
             *      placeMarker(output);
             * }
             * ));*/
            //The Epic of Alexander (Ultimate) has begun.

            /*triggers.Add(new Trigger("The Epic of Alexander (Ultimate) has begun.",
             *      async delegate (Match match)
             *      {
             *              await Task.Delay(2000);
             *              loadPreset("TEA");
             *      }
             * ));*/
        }