Skip to content

Commit

Permalink
Merge pull request #3 from harliq/AddWebWcidLookups
Browse files Browse the repository at this point in the history
Added Yotes WCID Lookup Button
  • Loading branch information
harliq authored Feb 6, 2020
2 parents 4c406af + bc69afb commit 549ec3c
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 64 deletions.
129 changes: 93 additions & 36 deletions AceCreator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -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; }
Expand All @@ -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; }
Expand Down Expand Up @@ -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"];
Expand All @@ -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);

Expand All @@ -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();
Expand All @@ -157,7 +176,6 @@ public void LoadWindow()

ButtonTest = view != null ? (HudButton)view["ButtonTest"] : new HudButton();
ButtonTest.Hit += new EventHandler(ButtonTest_Click);

}

[BaseEvent("LoginComplete", "CharacterFilter")]
Expand Down Expand Up @@ -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
Expand All @@ -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)
{
Expand All @@ -234,23 +263,22 @@ 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);
FileInfo[] files = d.GetFiles("*.json");

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();
Expand All @@ -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);

}
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -330,23 +352,18 @@ 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
{
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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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); }
Expand Down Expand Up @@ -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); }
Expand All @@ -430,15 +439,14 @@ 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); }

}
public void ButtonGetInfo_Click(object sender, EventArgs e)
{
Globals.ButtonCommand = "GetInfo";
try
{
WO = CoreManager.Current.WorldFilter[CoreManager.Current.Actions.CurrentSelection];
Expand All @@ -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;
}
Expand All @@ -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); }
}
}
}
1 change: 0 additions & 1 deletion AceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ class AceItem
public int id;
public string name;
}

}
Loading

0 comments on commit 549ec3c

Please sign in to comment.