Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
Add option.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCube committed Jul 16, 2017
1 parent 3d549a0 commit f26f34f
Show file tree
Hide file tree
Showing 2 changed files with 1,082 additions and 291 deletions.
131 changes: 110 additions & 21 deletions ACTWebSocket.Core/ACTWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public class ACTWebSocketMain : UserControl, IActPluginV1, PluginDirectory
private Button buttonRestore;
private Button buttonBackup;
private CheckBox SSLUse;
private Button buttonUpdatePluginAddress;
private CheckBox UpdatePluginAddress;
private CheckBox chatFilter;

public void SetSkinDir(string path)
Expand Down Expand Up @@ -208,6 +210,8 @@ private void InitializeComponent()
this.UPNPUse = new System.Windows.Forms.CheckBox();
this.randomURL = new System.Windows.Forms.CheckBox();
this.startoption = new System.Windows.Forms.GroupBox();
this.buttonUpdatePluginAddress = new System.Windows.Forms.Button();
this.UpdatePluginAddress = new System.Windows.Forms.CheckBox();
this.SSLUse = new System.Windows.Forms.CheckBox();
this.DiscoveryUse = new System.Windows.Forms.CheckBox();
this.skinOnAct = new System.Windows.Forms.CheckBox();
Expand Down Expand Up @@ -374,6 +378,8 @@ private void InitializeComponent()
// startoption
//
this.startoption.BackColor = System.Drawing.Color.Transparent;
this.startoption.Controls.Add(this.buttonUpdatePluginAddress);
this.startoption.Controls.Add(this.UpdatePluginAddress);
this.startoption.Controls.Add(this.SSLUse);
this.startoption.Controls.Add(this.DiscoveryUse);
this.startoption.Controls.Add(this.skinOnAct);
Expand All @@ -384,6 +390,22 @@ private void InitializeComponent()
this.startoption.Name = "startoption";
this.startoption.TabStop = false;
//
// buttonUpdatePluginAddress
//
resources.ApplyResources(this.buttonUpdatePluginAddress, "buttonUpdatePluginAddress");
this.buttonUpdatePluginAddress.Name = "buttonUpdatePluginAddress";
this.buttonUpdatePluginAddress.UseVisualStyleBackColor = true;
this.buttonUpdatePluginAddress.Click += new System.EventHandler(this.buttonUpdatePluginAddress_Click);
//
// UpdatePluginAddress
//
resources.ApplyResources(this.UpdatePluginAddress, "UpdatePluginAddress");
this.UpdatePluginAddress.Checked = true;
this.UpdatePluginAddress.CheckState = System.Windows.Forms.CheckState.Checked;
this.UpdatePluginAddress.Name = "UpdatePluginAddress";
this.UpdatePluginAddress.UseVisualStyleBackColor = true;
this.UpdatePluginAddress.CheckedChanged += new System.EventHandler(this.UpdatePluginAddress_CheckedChanged);
//
// SSLUse
//
resources.ApplyResources(this.SSLUse, "SSLUse");
Expand Down Expand Up @@ -1142,6 +1164,7 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
chatFilter.Checked = ChatFilter;
autostart.Checked = AutoRun;
autostartoverlay.Checked = AutoOverlay;
UpdatePluginAddress.Checked = UpdateAddress;
progressBar.Hide();
progressBar.BringToFront();
StopServer();
Expand Down Expand Up @@ -1433,6 +1456,16 @@ void LoadSettings()
}
buttonRefresh_Click(null, null);
}
if (obj.TryGetValue("UpdateAddress", out token))
{
UpdateAddress = token.ToObject<bool>();
UpdatePluginAddress.Checked = UpdateAddress;
}
else
{
UpdateAddress = true;
UpdatePluginAddress.Checked = true;
}
}
catch (Exception e)
{
Expand Down Expand Up @@ -1476,6 +1509,8 @@ void SaveSettings()
obj.Add("MiniParse", MiniParse);
obj.Add("ChatFilter", ChatFilter);
obj.Add("SkinOnAct", SkinOnAct);
obj.Add("UpdateAddress", UpdateAddress);

JArray skins = new JArray();
foreach (string a in SkinURLList)
{
Expand Down Expand Up @@ -1732,6 +1767,7 @@ public bool RandomURL
public bool AutoRun { get; set; }
public bool AutoOverlay { get; set; }
public bool ChatFilter { get; set; }
public bool UpdateAddress { get; set; }
public List<String> SkinURLList = new List<String>();

//https://github.com/anoyetta/ACT.MPTimer/blob/master/ACT.MPTimer/Utility/ActInvoker.cs
Expand All @@ -1755,6 +1791,45 @@ public static void Invoke(Action action)
}
}
}

private void UpdatePluginAddress_CheckedChanged(object sender, EventArgs e)
{
UpdateAddress = UpdatePluginAddress.Checked;
}

private void buttonUpdatePluginAddress_Click(object sender, EventArgs e)
{
// Set Local IP
Task task = new Task(() =>
{
try
{
foreach (var x in ActGlobals.oFormActMain.ActPlugins)
{
if (x.pluginFile.Name.ToUpper() == "FFXIV_ACT_Plugin.dll".ToUpper() && x.cbEnabled.Checked)
{
IActPluginV1 o = x.pluginObj;
if (o != null)
{
try
{
SetLocalIP(o);
}
catch (Exception)
{

}
}
}
}
}
catch (Exception)
{
}
});
task.Start();
}

private static void SetLocalIP(object plugin)
{
var connections = SocketConnection.GetAllTcpConnections();
Expand Down Expand Up @@ -1790,11 +1865,21 @@ private static void SetLocalIP(object plugin)
{
try
{
combo.Text = local.ToString();///*combo.Items[combo.Items.IndexOf(local.ToString())]*/;
int index = combo.Items.IndexOf(local.ToString());
if (index > 0)
{
combo.SelectedIndex = index;
}
else
{
combo.SelectedIndex = 0;
//combo.Text = local.ToString();///*combo.Items[combo.Items.IndexOf(local.ToString())]*/;
}
}
catch (Exception e)
{
combo.Text = "All (Default)";
combo.SelectedIndex = 0;
//combo.Text = "All (Default)";
}
});
}
Expand All @@ -1816,35 +1901,38 @@ public void StartServer()
core.Filters["/OnLogLineRead"] = true;
core.Filters["/MiniParse"] = true;

// Set Local IP
Task task = new Task(() =>
if(UpdateAddress)
{
try
// Set Local IP
Task task = new Task(() =>
{
foreach (var x in ActGlobals.oFormActMain.ActPlugins)
try
{
if (x.pluginFile.Name.ToUpper() == "FFXIV_ACT_Plugin.dll".ToUpper() && x.cbEnabled.Checked)
foreach (var x in ActGlobals.oFormActMain.ActPlugins)
{
IActPluginV1 o = x.pluginObj;
if (o != null)
if (x.pluginFile.Name.ToUpper() == "FFXIV_ACT_Plugin.dll".ToUpper() && x.cbEnabled.Checked)
{
try
{
SetLocalIP(o);
}
catch (Exception)
IActPluginV1 o = x.pluginObj;
if (o != null)
{
try
{
SetLocalIP(o);
}
catch (Exception)
{

}
}
}
}
}
}
catch (Exception)
{
}
});
task.Start();
catch (Exception)
{
}
});
task.Start();
}

if (UseUPnP)
{
Expand Down Expand Up @@ -1912,6 +2000,7 @@ public void StartServer()
uPnPPort.Enabled = false;
hostnames.Enabled = false;
buttonOff.Enabled = true;
//UpdatePluginAddress.Enabled = false;


if(UseDiscovery)
Expand Down Expand Up @@ -1979,6 +2068,7 @@ public void StopServer()
uPnPPort.Enabled = false;
hostnames.Enabled = true;
buttonOff.Enabled = false;
//UpdatePluginAddress.Enabled = true;
}

public void consolelog(object s)
Expand Down Expand Up @@ -3707,6 +3797,5 @@ void OverlayVersionCheck(String filepath = null)
}
});
}

}
}
Loading

0 comments on commit f26f34f

Please sign in to comment.