diff --git a/src/client/DCSInsight/Misc/Constants.cs b/src/client/DCSInsight/Misc/Constants.cs index 55fce67..88b8415 100644 --- a/src/client/DCSInsight/Misc/Constants.cs +++ b/src/client/DCSInsight/Misc/Constants.cs @@ -3,6 +3,6 @@ internal static class Constants { internal const string ListEnvironmentSnippet = "local keys = {}\r\nfor k, v in pairs(_G) do\r\n\tkeys[#keys+1] = k \r\nend\r\nreturn keys"; - internal const string LuaConsole = "Lua Console"; + internal const int LuaConsole = 1; } } diff --git a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs index 989f6c5..ef8a012 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPIBase.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPIBase.cs @@ -26,7 +26,7 @@ public abstract partial class UserControlAPIBase : UserControl, IDisposable, IAs protected bool IsConnected; private readonly Timer _pollingTimer; protected bool CanSend; - private bool KeepResults; + private bool _keepResults; protected Button ButtonSend; protected Label LabelKeepResults; protected CheckBox CheckBoxKeepResults; @@ -46,7 +46,7 @@ public abstract partial class UserControlAPIBase : UserControl, IDisposable, IAs protected UserControlAPIBase(DCSAPI dcsAPI, bool isConnected) { DCSAPI = dcsAPI; - IsLuaConsole = DCSAPI.Syntax == Constants.LuaConsole; + IsLuaConsole = DCSAPI.Id == Constants.LuaConsole; Id = DCSAPI.Id; IsConnected = isConnected; _pollingTimer = new Timer(PollingTimerCallback); @@ -129,7 +129,7 @@ internal void SetResult(DCSAPI dcsApi) DCSAPI.Result = result; - if (KeepResults) + if (_keepResults) { Dispatcher?.BeginInvoke((Action)(() => TextBoxResultBase.Text = TextBoxResultBase.Text.Insert(0, result + "\n"))); return; @@ -291,7 +291,7 @@ protected void CheckBoxKeepResults_OnUnchecked(object sender, RoutedEventArgs e) { try { - KeepResults = false; + _keepResults = false; SetFormState(); } catch (Exception ex) @@ -304,7 +304,7 @@ protected void CheckBoxKeepResults_OnChecked(object sender, RoutedEventArgs e) { try { - KeepResults = true; + _keepResults = true; SetFormState(); } catch (Exception ex) diff --git a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs index b9efeac..6a87b83 100644 --- a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs +++ b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs @@ -41,7 +41,7 @@ public WindowRangeTest(List dcsAPIList) { InitializeComponent(); _dcsAPIList = dcsAPIList; - _dcsAPIList.RemoveAll(o => o.Syntax == Constants.LuaConsole); + _dcsAPIList.RemoveAll(o => o.Id == Constants.LuaConsole); ICEventHandler.AttachErrorListener(this); ICEventHandler.AttachConnectionListener(this); ICEventHandler.AttachDataListener(this); diff --git a/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua b/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua new file mode 100644 index 0000000..64e0356 --- /dev/null +++ b/src/server/Scripts/DCS-INSIGHT/_ServerSettingsDevelopment.lua @@ -0,0 +1,19 @@ +module("ServerSettingsDevelopment", package.seeall) + +--- @class ServerSettingsDevelopment : APIBase +--- @field TCP_address string +--- @field TCP_port integer +local ServerSettingsDevelopment = {} + +ServerSettingsDevelopment.TCP_address = "*" +ServerSettingsDevelopment.TCP_port = 7790 + +-- Log incoming and outgoing JSON +ServerSettingsDevelopment.Log_JSON = false + +-- WARNING! This function enables arbitrary lua code to be +-- executed on your computer, including calls to package os (Operating System). +-- Do NOT enable unless your are firewalled. +ServerSettingsDevelopment.EnableLuaConsole = true + +return ServerSettingsDevelopment diff --git a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua index f9ece78..a29f1d1 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua @@ -95,6 +95,8 @@ function APIHandler:addLuaConsole() if ServerSettings.EnableLuaConsole then self.commandsTable[#self.commandsTable + 1] = LoadStringAPI:new(nil, counter()) self.apiTable[#self.apiTable + 1] = self.commandsTable[#self.commandsTable].apiInfo + else + counter() -- increase counter as 1 is reserved for lua console end end