Skip to content

Commit 5af9525

Browse files
committed
Initial commit
0 parents  commit 5af9525

File tree

12 files changed

+4008
-0
lines changed

12 files changed

+4008
-0
lines changed

LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2023 Karim Rizk
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
--DATIS OPTIONS PAGE
2+
3+
local leftMargin = 56
4+
local width = 850
5+
6+
-- Skins
7+
8+
local EditBoxSkin = {
9+
["params"] = {
10+
["name"] = "editBoxSkin_login",
11+
}
12+
}
13+
14+
local CheckBoxSkin = {
15+
["params"] = {
16+
["name"] = "checkBoxSkin_options",
17+
}
18+
}
19+
20+
local TitleSkin = {
21+
["params"] = {
22+
["name"] = "staticOptionsTitleSkin",
23+
},
24+
["states"] = {
25+
["released"] = {
26+
[1] = {
27+
["text"] = {
28+
["horzAlign"] = {
29+
["type"] = "min"
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
37+
local LabelSkin = {
38+
["params"] = {
39+
["name"] = "staticOptionsCaptionSkin",
40+
}
41+
}
42+
43+
local HelpSkin = {
44+
["params"] = {
45+
["name"] = "staticSkin2",
46+
},
47+
["states"] = {
48+
["released"] = {
49+
[1] = {
50+
["text"] = {
51+
["fontSize"] = 10,
52+
["horzAlign"] = {
53+
["type"] = "min"
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
61+
local ComboListSkin = {
62+
["params"] = {
63+
["name"] = "comboListSkin_options",
64+
}
65+
}
66+
67+
-- Content
68+
69+
dialog = {
70+
["children"] = {
71+
["containerPlugin"] = {
72+
["children"] = {
73+
74+
----------------------------------------
75+
-- Title
76+
----------------------------------------
77+
["VSCDTitleLabel"] = {
78+
["params"] = {
79+
["enabled"] = true,
80+
["bounds"] = {
81+
["x"] = leftMargin,
82+
["y"] = 30,
83+
["w"] = width,
84+
["h"] = 24,
85+
},
86+
["visible"] = true,
87+
["tooltip"] = "",
88+
["zindex"] = 0,
89+
["text"] = "$VSCD_DEBUG_TITLE",
90+
},
91+
["skin"] = TitleSkin,
92+
["type"] = "Static",
93+
},
94+
95+
-----------------------------------------------
96+
-- VSCD Enabled
97+
-----------------------------------------------
98+
99+
["VSCDEnabledCheckbox"] = {
100+
["params"] = {
101+
["bounds"] = {
102+
["x"] = leftMargin,
103+
["y"] = 90,
104+
["w"] = width,
105+
["h"] = 20,
106+
},
107+
["enabled"] = true,
108+
["state"] = false,
109+
["text"] = "$VSCD_DEBUG_ENABLED",
110+
["tooltip"] = "",
111+
["visible"] = true,
112+
["zindex"] = 0,
113+
["tabOrder"] = 0,
114+
},
115+
["skin"] = CheckBoxSkin,
116+
["type"] = "CheckBox",
117+
},
118+
119+
["VSCDEnabledEnabledHelpLabel"] = {
120+
["params"] = {
121+
["bounds"] = {
122+
["x"] = leftMargin,
123+
["y"] = 110,
124+
["w"] = width,
125+
["h"] = 40,
126+
},
127+
["enabled"] = true,
128+
["text"] = "$VSCD_DEBUG_ENABLED_TOOLTIP",
129+
["tooltip"] = "",
130+
["visible"] = true,
131+
["zindex"] = 0,
132+
},
133+
["skin"] = HelpSkin,
134+
["type"] = "Static",
135+
},
136+
137+
138+
-----------------------------------------------
139+
140+
},
141+
["type"] = "Panel",
142+
["skin"] = {
143+
["params"] = {
144+
["name"] = "panelSkin",
145+
},
146+
},
147+
["params"] = {
148+
["enabled"] = true,
149+
["bounds"] = {
150+
["x"] = 0,
151+
["y"] = 0,
152+
["w"] = 974,
153+
["h"] = 600,
154+
},
155+
["visible"] = true,
156+
["tooltip"] = "",
157+
["zindex"] = 2,
158+
["text"] = "",
159+
},
160+
},
161+
},
162+
["type"] = "Window",
163+
["skin"] = {
164+
["params"] = {
165+
["name"] = "windowSkin",
166+
},
167+
},
168+
["params"] = {
169+
["bounds"] = {
170+
["h"] = 851,
171+
["w"] = 1135,
172+
["x"] = 0,
173+
["y"] = 0,
174+
},
175+
["draggable"] = true,
176+
["enabled"] = true,
177+
["hasCursor"] = true,
178+
["lockFlow"] = false,
179+
["modal"] = false,
180+
["text"] = "dialog",
181+
["zOrder"] = 1,
182+
},
183+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--package.cpath = package.cpath..";"..lfs.writedir().."Mods\\tech\\DCS-SRS\\bin\\?.dll;"
2+
3+
cdata = {
4+
VSCD_DEBUG_TITLE = _("VSCode Lua Debugger"),
5+
VSCD_DEBUG_ENABLED = _("Enabled"),
6+
VSCD_DEBUG_ENABLED_TOOLTIP = _("Requires `DebugVSCode` flag set to true in your mission. Case sensitive."),
7+
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
local DbOption = require("Options.DbOption")
2+
3+
return {
4+
VSCDEnabled = DbOption.new():setValue(true):checkbox(),
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package.path = package.path..";.\\LuaSocket\\?.lua;"..'.\\Scripts\\?.lua;'
2+
package.path = package.path..lfs.writedir()..'Mods\\Services\\VSCodeDcsDebugger\\Scripts\\?.lua;'
3+
4+
local VLog = require('VSCDD-log')
5+
local LuaPanda = require("VSCDD-LuaPanda")
6+
7+
-- local enabled = OptionsData.getPlugin("DCS-SRS","srsAutoLaunchEnabled")
8+
9+
-- @TODO: Disable the debugger when running multiplayer or as a server
10+
-- @TODO: Disable when disabled from the in-game options
11+
local connResult = LuaPanda.start("127.0.0.1", 8818)
12+
if connResult then
13+
VLog.Info("Debug client successfully connected to VSCode.")
14+
else
15+
VLog.Error("Debug client failed to connect.")
16+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
local function readFile(path)
4+
local file = io.open(path, "r")
5+
6+
if not file then return nil end
7+
8+
local content = file:read("*all")
9+
file:close()
10+
return content
11+
end
12+
13+
package.path = package.path..';.\\LuaSocket\\?.lua;'..'.\\Scripts\\?.lua;'
14+
package.path = package.path..lfs.writedir()..'Mods\\Services\\VSCodeDcsDebugger\\Scripts\\?.lua;'
15+
16+
local VLog = require('VSCDD-log')
17+
local lfs = require('lfs')
18+
19+
VLog.Info('Injecting debugger....')
20+
local bootstrapper = readFile(lfs.writedir()..[[Mods\Services\VSCodeDcsDebugger\Scripts\VSCDD-Bootstrapper.lua]])
21+
22+
local script = 'a_do_script([['..bootstrapper..']])'
23+
24+
VLog.Info(net.dostring_in('mission', script))
25+
VLog.Info('Debugger injection finished.')
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
--------------------------
3+
-- This file is currently not in use, onMissionLoadProgress does not work, and neither of the other two are convenient.
4+
-- onMissionLoadBegin: Runs before the mission lua runtime is ready
5+
-- onMissionLoadEnd: Runs after sanitization
6+
7+
-- @TODO: Figure out a way to properly inject the debugger - perhaps if we get LoadProgress to work, we could
8+
-- inject the code at a step we know works.
9+
-- Currently we're just using a hack to modify MissionScripting.lua to include our code.
10+
11+
-- @TODO: Figure out if we can use this to set enable/disable status for the mission environment side of the script.
12+
--------------------------
13+
14+
local DCS = require('DCS')
15+
local VLog = require('VSCDD-log')
16+
local lfs = require('lfs')
17+
18+
local VSCDDEventHandler = {}
19+
20+
function VSCDDEventHandler.onMissionLoadBegin()
21+
dofile(lfs.writedir()..[[Mods\Services\VSCodeDcsDebugger\Scripts\VSCDD-Injector.lua]])
22+
end
23+
24+
function VSCDDEventHandler.onMissionLoadEnd()
25+
--dofile(lfs.writedir()..[[Mods\Services\VSCodeDcsDebugger\Scripts\VSCDD-Injector.lua]])
26+
end
27+
28+
function VSCDDEventHandler.onMissionLoadProgress(progress, message)
29+
log.write(progress, log.INFO, progress)
30+
log.write(message, log.INFO, message)
31+
end
32+
33+
-- checkBootstrapperContent()
34+
-- DCS.setUserCallbacks(VSCDDEventHandler)

0 commit comments

Comments
 (0)