Merge pull request #153 from Cyberboss/WebclientEnabling

Webclient setting
This commit is contained in:
Jordan Brown
2017-09-06 16:35:12 -04:00
committed by GitHub
8 changed files with 169 additions and 53 deletions
+40 -1
View File
@@ -9,7 +9,7 @@ namespace TGCommandLine
public DDCommand()
{
Keyword = "dd";
Children = new Command[] { new DDStartCommand(), new DDStopCommand(), new DDRestartCommand(), new DDStatusCommand(), new DDAutostartCommand(), new DDPortCommand(), new DDSecurityCommand(), new DDWorldAnnounceCommand() };
Children = new Command[] { new DDStartCommand(), new DDStopCommand(), new DDRestartCommand(), new DDStatusCommand(), new DDAutostartCommand(), new DDPortCommand(), new DDSecurityCommand(), new DDWorldAnnounceCommand(), new DDWebclientCommand() };
}
public override string GetHelpText()
{
@@ -191,6 +191,45 @@ namespace TGCommandLine
return "Change or check autostarting of the game server with the service";
}
}
class DDWebclientCommand : Command
{
public DDWebclientCommand()
{
Keyword = "webclient";
RequiredParameters = 1;
}
protected override ExitCode Run(IList<string> parameters)
{
var DD = Server.GetComponent<ITGDreamDaemon>();
switch (parameters[0].ToLower())
{
case "on":
DD.SetWebclient(true);
break;
case "off":
DD.SetWebclient(false);
break;
case "check":
OutputProc("Webclient is: " + (DD.Webclient() ? "Enabled" : "Disabled"));
break;
default:
OutputProc("Invalid parameter: " + parameters[0]);
return ExitCode.BadCommand;
}
return ExitCode.Normal;
}
public override string GetArgumentString()
{
return "<on|off|check>";
}
public override string GetHelpText()
{
return "Change or check if the BYOND webclient is enabled for the game server";
}
}
class DDPortCommand : Command
{
public DDPortCommand()
+67 -50
View File
@@ -71,6 +71,10 @@
this.MajorVersionNumeric = new System.Windows.Forms.NumericUpDown();
this.UpdateProgressBar = new System.Windows.Forms.ProgressBar();
this.ServerPanel = new System.Windows.Forms.TabPage();
this.AutostartCheckbox = new System.Windows.Forms.CheckBox();
this.WebclientCheckBox = new System.Windows.Forms.CheckBox();
this.WorldAnnounceButton = new System.Windows.Forms.Button();
this.WorldAnnounceField = new System.Windows.Forms.TextBox();
this.VisibilityTitle = new System.Windows.Forms.Label();
this.SecuritySelector = new System.Windows.Forms.ComboBox();
this.SecurityTitle = new System.Windows.Forms.Label();
@@ -79,6 +83,7 @@
this.NudgePortLabel = new System.Windows.Forms.Label();
this.ServerPathLabel = new System.Windows.Forms.Label();
this.ServerPathTextbox = new System.Windows.Forms.TextBox();
this.CompileCancelButton = new System.Windows.Forms.Button();
this.ProjectPathLabel = new System.Windows.Forms.Label();
this.projectNameText = new System.Windows.Forms.TextBox();
this.PortLabel = new System.Windows.Forms.Label();
@@ -94,7 +99,6 @@
this.ServerRestartButton = new System.Windows.Forms.Button();
this.ServerStopButton = new System.Windows.Forms.Button();
this.ServerStartButton = new System.Windows.Forms.Button();
this.AutostartCheckbox = new System.Windows.Forms.CheckBox();
this.CompilerStatusLabel = new System.Windows.Forms.Label();
this.CompilerLabel = new System.Windows.Forms.Label();
this.compileButton = new System.Windows.Forms.Button();
@@ -175,9 +179,6 @@
this.WorldStatusTimer = new System.Windows.Forms.Timer(this.components);
this.FullUpdateWorker = new System.ComponentModel.BackgroundWorker();
this.ServerStartBGW = new System.ComponentModel.BackgroundWorker();
this.WorldAnnounceField = new System.Windows.Forms.TextBox();
this.CompileCancelButton = new System.Windows.Forms.Button();
this.WorldAnnounceButton = new System.Windows.Forms.Button();
this.Panels.SuspendLayout();
this.RepoPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.TestmergeSelector)).BeginInit();
@@ -723,6 +724,8 @@
// ServerPanel
//
this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
this.ServerPanel.Controls.Add(this.AutostartCheckbox);
this.ServerPanel.Controls.Add(this.WebclientCheckBox);
this.ServerPanel.Controls.Add(this.WorldAnnounceButton);
this.ServerPanel.Controls.Add(this.WorldAnnounceField);
this.ServerPanel.Controls.Add(this.VisibilityTitle);
@@ -749,7 +752,6 @@
this.ServerPanel.Controls.Add(this.ServerRestartButton);
this.ServerPanel.Controls.Add(this.ServerStopButton);
this.ServerPanel.Controls.Add(this.ServerStartButton);
this.ServerPanel.Controls.Add(this.AutostartCheckbox);
this.ServerPanel.Controls.Add(this.CompilerStatusLabel);
this.ServerPanel.Controls.Add(this.CompilerLabel);
this.ServerPanel.Controls.Add(this.compileButton);
@@ -764,6 +766,53 @@
this.ServerPanel.TabIndex = 2;
this.ServerPanel.Text = "Server";
//
// AutostartCheckbox
//
this.AutostartCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AutostartCheckbox.AutoSize = true;
this.AutostartCheckbox.Font = new System.Drawing.Font("Verdana", 12F);
this.AutostartCheckbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.AutostartCheckbox.Location = new System.Drawing.Point(758, 0);
this.AutostartCheckbox.Name = "AutostartCheckbox";
this.AutostartCheckbox.Size = new System.Drawing.Size(104, 22);
this.AutostartCheckbox.TabIndex = 15;
this.AutostartCheckbox.Text = "Autostart";
this.AutostartCheckbox.UseVisualStyleBackColor = true;
this.AutostartCheckbox.CheckedChanged += new System.EventHandler(this.AutostartCheckbox_CheckedChanged);
//
// WebclientCheckBox
//
this.WebclientCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.WebclientCheckBox.AutoSize = true;
this.WebclientCheckBox.Font = new System.Drawing.Font("Verdana", 12F);
this.WebclientCheckBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.WebclientCheckBox.Location = new System.Drawing.Point(758, 28);
this.WebclientCheckBox.Name = "WebclientCheckBox";
this.WebclientCheckBox.Size = new System.Drawing.Size(108, 22);
this.WebclientCheckBox.TabIndex = 42;
this.WebclientCheckBox.Text = "Webclient";
this.WebclientCheckBox.UseVisualStyleBackColor = true;
this.WebclientCheckBox.CheckedChanged += new System.EventHandler(this.WebclientCheckBox_CheckedChanged);
//
// WorldAnnounceButton
//
this.WorldAnnounceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.WorldAnnounceButton.Location = new System.Drawing.Point(785, 136);
this.WorldAnnounceButton.Name = "WorldAnnounceButton";
this.WorldAnnounceButton.Size = new System.Drawing.Size(77, 20);
this.WorldAnnounceButton.TabIndex = 41;
this.WorldAnnounceButton.Text = "Send";
this.WorldAnnounceButton.UseVisualStyleBackColor = true;
this.WorldAnnounceButton.Click += new System.EventHandler(this.WorldAnnounceButton_Click);
//
// WorldAnnounceField
//
this.WorldAnnounceField.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.WorldAnnounceField.Location = new System.Drawing.Point(566, 136);
this.WorldAnnounceField.Name = "WorldAnnounceField";
this.WorldAnnounceField.Size = new System.Drawing.Size(213, 20);
this.WorldAnnounceField.TabIndex = 40;
//
// VisibilityTitle
//
this.VisibilityTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@@ -871,6 +920,18 @@
this.ServerPathTextbox.Size = new System.Drawing.Size(296, 20);
this.ServerPathTextbox.TabIndex = 32;
//
// CompileCancelButton
//
this.CompileCancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CompileCancelButton.Enabled = false;
this.CompileCancelButton.Location = new System.Drawing.Point(737, 302);
this.CompileCancelButton.Name = "CompileCancelButton";
this.CompileCancelButton.Size = new System.Drawing.Size(69, 31);
this.CompileCancelButton.TabIndex = 31;
this.CompileCancelButton.Text = "Cancel";
this.CompileCancelButton.UseVisualStyleBackColor = true;
this.CompileCancelButton.Click += new System.EventHandler(this.CompileCancelButton_Click);
//
// ProjectPathLabel
//
this.ProjectPathLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -1054,20 +1115,6 @@
this.ServerStartButton.UseVisualStyleBackColor = true;
this.ServerStartButton.Click += new System.EventHandler(this.ServerStartButton_Click);
//
// AutostartCheckbox
//
this.AutostartCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AutostartCheckbox.AutoSize = true;
this.AutostartCheckbox.Font = new System.Drawing.Font("Verdana", 12F);
this.AutostartCheckbox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
this.AutostartCheckbox.Location = new System.Drawing.Point(758, 17);
this.AutostartCheckbox.Name = "AutostartCheckbox";
this.AutostartCheckbox.Size = new System.Drawing.Size(104, 22);
this.AutostartCheckbox.TabIndex = 15;
this.AutostartCheckbox.Text = "Autostart";
this.AutostartCheckbox.UseVisualStyleBackColor = true;
this.AutostartCheckbox.CheckedChanged += new System.EventHandler(this.AutostartCheckbox_CheckedChanged);
//
// CompilerStatusLabel
//
this.CompilerStatusLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
@@ -1961,37 +2008,6 @@
//
this.ServerStartBGW.DoWork += new System.ComponentModel.DoWorkEventHandler(this.ServerStartBGW_DoWork);
//
// WorldAnnounceField
//
this.WorldAnnounceField.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.WorldAnnounceField.Location = new System.Drawing.Point(566, 136);
this.WorldAnnounceField.Name = "WorldAnnounceField";
this.WorldAnnounceField.Size = new System.Drawing.Size(213, 20);
this.WorldAnnounceField.TabIndex = 40;
//
// CompileCancelButton
//
this.CompileCancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.CompileCancelButton.Enabled = false;
this.CompileCancelButton.Location = new System.Drawing.Point(737, 302);
this.CompileCancelButton.Name = "CompileCancelButton";
this.CompileCancelButton.Size = new System.Drawing.Size(69, 31);
this.CompileCancelButton.TabIndex = 31;
this.CompileCancelButton.Text = "Cancel";
this.CompileCancelButton.UseVisualStyleBackColor = true;
this.CompileCancelButton.Click += new System.EventHandler(this.CompileCancelButton_Click);
//
// WorldAnnounceButton
//
this.WorldAnnounceButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.WorldAnnounceButton.Location = new System.Drawing.Point(785, 136);
this.WorldAnnounceButton.Name = "WorldAnnounceButton";
this.WorldAnnounceButton.Size = new System.Drawing.Size(77, 20);
this.WorldAnnounceButton.TabIndex = 41;
this.WorldAnnounceButton.Text = "Send";
this.WorldAnnounceButton.UseVisualStyleBackColor = true;
this.WorldAnnounceButton.Click += new System.EventHandler(this.WorldAnnounceButton_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2181,5 +2197,6 @@
private System.Windows.Forms.Button WorldAnnounceButton;
private System.Windows.Forms.TextBox WorldAnnounceField;
private System.Windows.Forms.Button CompileCancelButton;
private System.Windows.Forms.CheckBox WebclientCheckBox;
}
}
+8
View File
@@ -104,6 +104,7 @@ namespace TGControlPanel
initializeButton.Visible = RepoExists;
NudgePortSelector.Visible = RepoExists;
AutostartCheckbox.Visible = RepoExists;
WebclientCheckBox.Visible = RepoExists;
PortSelector.Visible = RepoExists;
projectNameText.Visible = RepoExists;
compilerProgressBar.Visible = RepoExists;
@@ -157,6 +158,7 @@ namespace TGControlPanel
ServerGStopButton.Enabled = !ShuttingDown;
AutostartCheckbox.Checked = DD.Autostart();
WebclientCheckBox.Checked = DD.Webclient();
if (!PortSelector.Focused)
PortSelector.Value = DD.Port();
if (!projectNameText.Focused)
@@ -485,5 +487,11 @@ namespace TGControlPanel
}
WorldAnnounceField.Text = "";
}
private void WebclientCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (!updatingFields)
Server.GetComponent<ITGDreamDaemon>().SetWebclient(WebclientCheckBox.Checked);
}
}
}
+3
View File
@@ -61,6 +61,9 @@
<setting name="ReattachCommsKey" serializeAs="String">
<value />
</setting>
<setting name="Webclient" serializeAs="String">
<value>False</value>
</setting>
</TGServerService.Properties.Settings>
</userSettings>
</configuration>
+21 -1
View File
@@ -380,7 +380,7 @@ namespace TGServerService
GenCommsKey();
StartingSecurity = (TGDreamDaemonSecurity)Config.ServerSecurity;
Proc.StartInfo.Arguments = String.Format("{0} -port {1} -close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version());
Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient" : "");
InitInterop();
Proc.Start();
@@ -506,5 +506,25 @@ namespace TGServerService
return null;
return res;
}
/// <inheritdoc />
public bool Webclient()
{
return Properties.Settings.Default.Webclient;
}
/// <inheritdoc />
public void SetWebclient(bool on)
{
var Config = Properties.Settings.Default;
lock (watchdogLock) {
var diff = on != Config.Webclient;
if (diff)
{
Config.Webclient = on;
RequestRestart();
}
}
}
}
}
+13 -1
View File
@@ -12,7 +12,7 @@ namespace TGServerService.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -226,5 +226,17 @@ namespace TGServerService.Properties {
this["ReattachCommsKey"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool Webclient {
get {
return ((bool)(this["Webclient"]));
}
set {
this["Webclient"] = value;
}
}
}
}
@@ -53,5 +53,8 @@
<Setting Name="ReattachCommsKey" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Webclient" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
+14
View File
@@ -150,6 +150,20 @@ namespace TGServiceInterface
[OperationContract]
void SetAutostart(bool on);
/// <summary>
/// Check if the byond webclient is currently enabled for the server
/// </summary>
/// <returns>true if the webclient is enabled, false otherwise</returns>
[OperationContract]
bool Webclient();
/// <summary>
/// Set the webclient config. Calls <see cref="RequestRestart"/>
/// </summary>
/// <param name="on">true to enable the byond webclient for the server, false otherwise</param>
[OperationContract]
void SetWebclient(bool on);
/// <summary>
/// Checks if a server stop has bee requested
/// </summary>