From bc69afbfda019b598bf4819c7f669e6a959a7953 Mon Sep 17 00:00:00 2001 From: harliq <30803300+harliq@users.noreply.github.com> Date: Wed, 5 Feb 2020 22:38:51 -0500 Subject: [PATCH] Added Yotes WCID Lookup Button Added Edit JSON Button Added Edit SQL Button Lists now Refresh correctly when exporting a JSON or SQL File --- AceCreator.cs | 129 ++++++++++++++++++++++++++----------- AceItem.cs | 1 - ChatMessages.cs | 30 ++++++--- Globals.cs | 2 + Properties/AssemblyInfo.cs | 4 +- Util.cs | 15 ----- mainView.xml | 4 ++ 7 files changed, 121 insertions(+), 64 deletions(-) diff --git a/AceCreator.cs b/AceCreator.cs index 0ae7868..d879647 100644 --- a/AceCreator.cs +++ b/AceCreator.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Reflection; using System.Text.RegularExpressions; @@ -29,7 +30,11 @@ public class AceCreator : PluginBase public HudCombo ChoiceJSON { get; set; } public HudCombo ChoiceSQL { get; set; } public HudButton CommandConvertSQL { get; set; } + public HudButton ButtonOpenSQL { get; set; } + public HudButton CommandConvertJSON { get; set; } + public HudButton ButtonOpenJSON { get; set; } + public HudButton CommandRefreshFilesList { get; set; } public HudTextBox TextboxCreateWCID { get; set; } public HudButton ButtonCreateWCID { get; set; } @@ -40,8 +45,9 @@ public class AceCreator : PluginBase public HudButton ButtonExportJSON { get; set; } public HudTextBox TextboxExportSQLWCID { get; set; } public HudButton ButtonExportSQL { get; set; } + public HudButton ButtonYotesWCIDLookUp { get; set; } + public HudButton ButtonDeleteItem { get; set; } - public HudStaticText LabelGetInfo { get; set; } public HudButton ButtonGetInfo { get; set; } @@ -102,7 +108,12 @@ public void LoadWindow() VirindiViewService.XMLParsers.Decal3XMLParser parser = new VirindiViewService.XMLParsers.Decal3XMLParser(); parser.ParseFromResource("AceCreator.mainView.xml", out properties, out controls); view = new VirindiViewService.HudView(properties, controls); - view.Title = "ACE Content Creator - Version " + typeof(AceCreator).Assembly.GetName().Version; + // view.Title = "ACE Content Creator - Version " + typeof(AceCreator).Assembly.GetName().Version; + // Get the file version for the notepad. + string assemblyFolder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo( assemblyFolder+ @"\AceCreator.dll"); + //view.Title = "ACE Content Creator - Version " + typeof(AceCreator).Assembly.GetName().Version; + view.Title = "ACE Content Creator - Version " + myFileVersionInfo.FileVersion; // Content Tab ChoiceJSON = (HudCombo)view["ChoiceJSON"]; @@ -113,9 +124,15 @@ public void LoadWindow() CommandConvertSQL = view != null ? (HudButton)view["CommandConvertSQL"] : new HudButton(); CommandConvertSQL.Hit += new EventHandler(ButtonConvertSQL_Click); + ButtonOpenSQL = view != null ? (HudButton)view["ButtonOpenSQL"] : new HudButton(); + ButtonOpenSQL.Hit += new EventHandler(ButtonOpenSQL_Click); + CommandConvertJSON = view != null ? (HudButton)view["CommandConvertJSON"] : new HudButton(); CommandConvertJSON.Hit += new EventHandler(ButtonConvertJSON_Click); + ButtonOpenJSON = view != null ? (HudButton)view["ButtonOpenJSON"] : new HudButton(); + ButtonOpenJSON.Hit += new EventHandler(ButtonOpenJSON_Click); + CommandRefreshFilesList = view != null ? (HudButton)view["CommandRefreshFilesList"] : new HudButton(); CommandRefreshFilesList.Hit += new EventHandler(ButtonRefreshFilesList_Click); @@ -142,7 +159,9 @@ public void LoadWindow() ButtonDeleteItem = view != null ? (HudButton)view["ButtonDeleteItem"] : new HudButton(); ButtonDeleteItem.Hit += new EventHandler(ButtonDeleteItem_Click); - + + ButtonYotesWCIDLookUp = view != null ? (HudButton)view["ButtonYotesWCIDLookUp"] : new HudButton(); + ButtonYotesWCIDLookUp.Hit += new EventHandler(ButtonYotesWCIDLookUp_Click); LabelGetInfo = (HudStaticText)view["LabelGetInfo"]; ButtonGetInfo = view != null ? (HudButton)view["ButtonGetInfo"] : new HudButton(); @@ -157,7 +176,6 @@ public void LoadWindow() ButtonTest = view != null ? (HudButton)view["ButtonTest"] : new HudButton(); ButtonTest.Hit += new EventHandler(ButtonTest_Click); - } [BaseEvent("LoginComplete", "CharacterFilter")] @@ -207,7 +225,6 @@ public void WorldFilter_ChangeObject(object sender, ChangeObjectEventArgs e) catch (Exception ex) { Util.LogError(ex); } } - private void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e) { try @@ -222,9 +239,21 @@ private void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e) LabelGetInfo.Text = e.Text; TextboxExportJsonWCID.Text = wcid; TextboxExportSQLWCID.Text = wcid; + Globals.YotesWCID = wcid; + if (Globals.ButtonCommand == "YotesLookup") + { + Util.WriteToChat("Opening Browser"); + Globals.ButtonCommand = ""; + System.Diagnostics.Process.Start("http://ac.yotesfan.com/weenies/items/" + wcid); + } // Util.WriteToChat(e.Text); } - + if (ChatMessages.FileExport(e.Text)) + { + JsonChoiceList(); + SqlChoiceList(); + Util.WriteToChat("ListRefresh"); + } } catch (Exception ex) { @@ -234,7 +263,7 @@ private void Current_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e) private void JsonChoiceList() { ChoiceJSON = (HudCombo)view["ChoiceJSON"]; - //Util.WriteToChat(Globals.PathJSON); + // Util.WriteToChat(Globals.PathJSON); ChoiceJSON.Clear(); string filespath = Globals.PathJSON; DirectoryInfo d = new DirectoryInfo(filespath); @@ -242,15 +271,14 @@ private void JsonChoiceList() foreach (var file in files) { - //Util.WriteToChat(file.Name); + // Util.WriteToChat(file.Name); ChoiceJSON.AddItem(file.Name, file); } } - private void SqlChoiceList() { - //Util.WriteToChat(Globals.PathSQL); + // Util.WriteToChat(Globals.PathSQL); ChoiceSQL = (HudCombo)view["ChoiceSQL"]; // ICombo addfile = JSONFileList.Add(File.AppendAllText) ChoiceSQL.Clear(); @@ -260,7 +288,7 @@ private void SqlChoiceList() foreach (var file in files) { - //Util.WriteToChat(file.Name); + // Util.WriteToChat(file.Name); ChoiceSQL.AddItem(file.Name, file.Name); } @@ -275,24 +303,20 @@ private void LoadPathSettings() { TextBoxPathJSON.Text = pathsettings["jsonpath"]; Globals.PathJSON = pathsettings["jsonpath"]; - //Util.WriteToChat(pathsettings["jsonpath"]); + // Util.WriteToChat(pathsettings["jsonpath"]); } if (pathsettings.ContainsKey("sqlpath")) // && pathsettings["sqlpath"] != "") { TextBoxPathSQL.Text = pathsettings["sqlpath"]; Globals.PathSQL = pathsettings["sqlpath"]; - //Util.WriteToChat(pathsettings["sqlpath"]); + // Util.WriteToChat(pathsettings["sqlpath"]); } - } private void SavePathSettings(object sender, EventArgs e) { - //EmailSender = new Email(email.Text, host.Text, int.Parse(port.Text), ss1.Checked, pass.Text); - //DiscordSender = new Discord(discordurl.Text); Util.SaveIni(TextBoxPathJSON.Text, TextBoxPathSQL.Text); } - // ComboBox Change public void ChoiceJSON_Change(object sender, EventArgs e) { @@ -303,7 +327,6 @@ public void ChoiceJSON_Change(object sender, EventArgs e) TextboxCreateWCID.Text = tsplit.Split(' ')[0]; } catch (Exception ex) { Util.LogError(ex); } - } public void ChoiceSQL_Change(object sender, EventArgs e) { @@ -316,7 +339,6 @@ public void ChoiceSQL_Change(object sender, EventArgs e) catch (Exception ex) { Util.LogError(ex); } } - // Buttons public void ButtonConvertSQL_Click(object sender, EventArgs e) { @@ -330,9 +352,7 @@ public void ButtonConvertSQL_Click(object sender, EventArgs e) TextboxCreateWCID.Text = tsplit.Split(' ')[0]; } catch (Exception ex) { Util.LogError(ex); } - } - public void ButtonConvertJSON_Click(object sender, EventArgs e) { try @@ -340,13 +360,10 @@ public void ButtonConvertJSON_Click(object sender, EventArgs e) TextboxCreateWCID = (HudTextBox)view["TextboxCreateWCID"]; Util.SendChatCommand(@"/import-json " + ((HudStaticText)ChoiceJSON[ChoiceJSON.Current]).Text); Util.WriteToChat("Imported JSON= " + ((HudStaticText)ChoiceJSON[ChoiceJSON.Current]).Text); - string tsplit = ((HudStaticText)ChoiceJSON[ChoiceJSON.Current]).Text; TextboxCreateWCID.Text = tsplit.Split(' ')[0]; - } catch (Exception ex) { Util.LogError(ex); } - } public void ButtonRefreshFilesList_Click(object sender, EventArgs e) { @@ -356,11 +373,9 @@ public void ButtonRefreshFilesList_Click(object sender, EventArgs e) JsonChoiceList(); SqlChoiceList(); - - //Util.WriteToChat("Text= " + ((HudStaticText)ChoiceSQL[ChoiceSQL.Current]).Text); + // Util.WriteToChat("Text= " + ((HudStaticText)ChoiceSQL[ChoiceSQL.Current]).Text); } catch (Exception ex) { Util.LogError(ex); } - } public void ButtonSavePaths_Click(object sender, EventArgs e) { @@ -370,7 +385,6 @@ public void ButtonSavePaths_Click(object sender, EventArgs e) Util.SaveIni(TextBoxPathJSON.Text, TextBoxPathSQL.Text); } catch (Exception ex) { Util.LogError(ex); } - } public void ButtonTest_Click(object sender, EventArgs e) { @@ -379,13 +393,11 @@ public void ButtonTest_Click(object sender, EventArgs e) LoadPathSettings(); } catch (Exception ex) { Util.LogError(ex); } - } public void ButtonCreateWCID_Click(object sender, EventArgs e) { try { - Util.SendChatCommand(@"/create " + TextboxCreateWCID.Text); } catch (Exception ex) { Util.LogError(ex); } @@ -415,10 +427,7 @@ public void ButtonExportJSON_Click(object sender, EventArgs e) { try { - Util.SendChatCommand(@"/export-json " + TextboxExportJsonWCID.Text); - // Add look at chat so when exported it will refresh list - JsonChoiceList(); } catch (Exception ex) { Util.LogError(ex); } @@ -430,8 +439,6 @@ public void ButtonExportSQL_Click(object sender, EventArgs e) { Util.SendChatCommand(@"/export-sql " + TextboxExportSQLWCID.Text); - // Add look at chat so when exported it will refresh list - SqlChoiceList(); } catch (Exception ex) { Util.LogError(ex); } @@ -439,6 +446,7 @@ public void ButtonExportSQL_Click(object sender, EventArgs e) } public void ButtonGetInfo_Click(object sender, EventArgs e) { + Globals.ButtonCommand = "GetInfo"; try { WO = CoreManager.Current.WorldFilter[CoreManager.Current.Actions.CurrentSelection]; @@ -465,12 +473,51 @@ public void ButtonDeleteItem_Click(object sender, EventArgs e) catch (Exception ex) { Util.LogError(ex); } } + public void ButtonYotesWCIDLookUp_Click(object sender, EventArgs e) + { + Globals.ButtonCommand = "YotesLookup"; + try + { + WO = CoreManager.Current.WorldFilter[CoreManager.Current.Actions.CurrentSelection]; + aceItem.name = WO.Name; + aceItem.id = WO.Id; + + Globals.Host.Actions.RequestId(Globals.Host.Actions.CurrentSelection); + CoreManager.Current.WorldFilter.ChangeObject += GetInfoWaitForItemUpdate; + Util.WriteToChat(Globals.YotesWCID); + + } + catch (Exception ex) { Util.LogError(ex); } + + } + public void ButtonOpenJSON_Click(object sender, EventArgs e) + { + + try + { + System.Diagnostics.Process.Start(Globals.PathJSON + @"\" + ((HudStaticText)ChoiceJSON[ChoiceJSON.Current]).Text); + } + catch (Exception ex) { Util.LogError(ex); } + + } + public void ButtonOpenSQL_Click(object sender, EventArgs e) + { + + try + { + System.Diagnostics.Process.Start(Globals.PathSQL + @"\" + ((HudStaticText)ChoiceSQL[ChoiceSQL.Current]).Text); + } + catch (Exception ex) { Util.LogError(ex); } + + } + // Methods private void GetInfoWaitForItemUpdate(object sender, ChangeObjectEventArgs e) { try { if (e.Changed.Id == aceItem.id) { + Util.SendChatCommand("/getinfo"); CoreManager.Current.WorldFilter.ChangeObject -= GetInfoWaitForItemUpdate; } @@ -489,6 +536,16 @@ private void DeleteItemWaitForItemUpdate(object sender, ChangeObjectEventArgs e) } catch (Exception ex) { Util.LogError(ex); } } - + private void LookupYotesWaitForItemUpdate(object sender, ChangeObjectEventArgs e) + { + try + { + if (e.Changed.Id == aceItem.id) + { + CoreManager.Current.WorldFilter.ChangeObject -= LookupYotesWaitForItemUpdate; + } + } + catch (Exception ex) { Util.LogError(ex); } + } } } diff --git a/AceItem.cs b/AceItem.cs index 4a7402e..1957e73 100644 --- a/AceItem.cs +++ b/AceItem.cs @@ -9,5 +9,4 @@ class AceItem public int id; public string name; } - } diff --git a/ChatMessages.cs b/ChatMessages.cs index 5391e31..bdee0a7 100644 --- a/ChatMessages.cs +++ b/ChatMessages.cs @@ -8,15 +8,14 @@ namespace AceCreator { public class ChatMessages { - public static Collection WeenieGetInfo = new Collection(); + public static Collection ExportFiles = new Collection(); + public ChatMessages() { // Weenie WCID WeenieGetInfo.Add(new Regex("^WeenieClassId:.*")); - - // Weenie Class Name - // WeenieGetInfo.Add(new Regex("^WeenieClassName: (?.+)$")); + ExportFiles.Add(new Regex("^Exported.*")); } public static bool GetWeenieInfo(string text, out string wcid) { @@ -26,9 +25,9 @@ public static bool GetWeenieInfo(string text, out string wcid) { // Util.WriteToChat("CapGroup1= " + RegExGroup(@"WeenieClassId: (.*)", text)); + wcid = RegExGroup(@"WeenieClassId: (.*)", text); return true; - } } @@ -38,14 +37,25 @@ public static bool GetWeenieInfo(string text, out string wcid) public static string RegExGroup(string pattern, string text) { - Regex r = new Regex(pattern, RegexOptions.IgnoreCase); + Regex r = new Regex(pattern, RegexOptions.IgnoreCase); - // match the regex pattern against string - Match m = r.Match(text); - Group g = m.Groups[1]; - string mystring = g.Value; + // match the regex pattern against string + Match m = r.Match(text); + Group g = m.Groups[1]; + string mystring = g.Value; return mystring; } + public static bool FileExport(string text) + { + foreach (Regex regex in ExportFiles) + { + if (regex.IsMatch(text)) + { + return true; + } + } + return false; + } } } \ No newline at end of file diff --git a/Globals.cs b/Globals.cs index 06a068d..387deab 100644 --- a/Globals.cs +++ b/Globals.cs @@ -24,5 +24,7 @@ public static void Init(string pluginName, PluginHost host, CoreManager core) public static string PathJSON; public static string PathSQL; + public static string YotesWCID; + public static string ButtonCommand; } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 941c498..717a840 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.2.6")] -[assembly: AssemblyFileVersion("1.0.2.6")] +[assembly: AssemblyVersion("1.0.3.4")] +[assembly: AssemblyFileVersion("1.0.4.0")] diff --git a/Util.cs b/Util.cs index 31f5e56..51e7ae0 100644 --- a/Util.cs +++ b/Util.cs @@ -104,24 +104,9 @@ internal static Dictionary LoadSetttings() { WriteToChat(line); string[] templineinfo = line.Split('='); - //if (templineinfo.Length > 2) - // temp.Add(templineinfo[0], templineinfo[1] + ":" + templineinfo[2]); - //else temp.Add(templineinfo[0], templineinfo[1]); - //if (templineinfo[0] == "jsonpath") - //{ - // Globals.PathJSON = templineinfo[1]; - //} - //if (templineinfo[0] == "sqlpath") - //{ - // Globals.PathJSON = templineinfo[1]; - //} } - return temp; } - - - } } diff --git a/mainView.xml b/mainView.xml index 0ed68df..9163ef8 100644 --- a/mainView.xml +++ b/mainView.xml @@ -6,9 +6,11 @@ + + @@ -28,6 +30,8 @@ + +