diff --git a/.gitignore b/.gitignore index 3f52fae8..692cffec 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ core.user core.vcxproj.user .vscode *.user +Output diff --git a/installer/DCSOlympus.iss b/installer/DCSOlympus.iss new file mode 100644 index 00000000..922a605d --- /dev/null +++ b/installer/DCSOlympus.iss @@ -0,0 +1,23 @@ +[Setup] +AppName=DCS Olympus +AppVerName=DCS Olympus Alpha v0.0.1 +DefaultDirName={usersavedgames}\DCS.openbeta +DefaultGroupName=DCSOlympus +OutputBaseFilename=DCSOlympus + +[Tasks] +; NOTE: The following entry contains English phrases ("Create a desktop icon" and "Additional icons"). You are free to translate them into another language if required. + +[Files] +; NOTE: Don't use "Flags: ignoreversion" on any shared system files +Source: "..\scripts\OlympusExport.lua"; DestDir: "{app}\Scripts"; Flags: ignoreversion +Source: "..\scripts\OlympusHook.lua"; DestDir: "{app}\Scripts\Hooks"; Flags: ignoreversion +Source: "..\scripts\OlympusCommand.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion +Source: "..\scripts\OlympusMission.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion +Source: "..\bin\x64\Release\*.dll"; DestDir: "{app}\Mods\Services\Olympus\bin"; Flags: ignoreversion; + +[Code] +procedure AppendExportString(); +begin + SaveStringToFile(ExpandConstant('{app}\Scripts\Export.lua'), #13#10 + 'local Olympuslfs=require(''lfs'');dofile(Olympuslfs.writedir()..''Scripts/OlympusExport.lua'')' + #13#10, True); +end; \ No newline at end of file diff --git a/scripts/Export.lua b/scripts/Export.lua new file mode 100644 index 00000000..f60c236d --- /dev/null +++ b/scripts/Export.lua @@ -0,0 +1 @@ +local Olympuslfs=require('lfs');dofile(Olympuslfs.writedir()..'Scripts/OlympusExport.lua') diff --git a/scripts/OlympusExport.lua b/scripts/OlympusExport.lua new file mode 100644 index 00000000..91561122 --- /dev/null +++ b/scripts/OlympusExport.lua @@ -0,0 +1,44 @@ +Olympus = {} +Olympus.OlympusDLL = nil +Olympus.cppRESTDLL = nil +Olympus.DLLsloaded = false +Olympus.debug = true +if Olympus.debug then + Olympus.OlympusModPath = "C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Debug\\" +else + Olympus.OlympusModPath = "C:\\Users\\dpass\\Doczuments\\Olympus\\bin\\x64\\Release\\" +end + +log.write('Olympus.EXPORT.LUA', log.INFO,'Executing OlympusExport.lua') + +function Olympus.loadDLLs() + -- Add the .dll paths + package.cpath = package.cpath..';'..Olympus.OlympusModPath..'?.dll;' + + if Olympus.debug then + log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading cpprest_2_10d.dll from ['..Olympus.OlympusModPath..']') + pcall(require, 'cpprest_2_10d') + else + log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']') + pcall(require, 'cpprest_2_10') + end + + log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading Olympus.dll from ['..Olympus.OlympusModPath..']') + local status + status, Olympus.OlympusDLL = pcall(require, 'Olympus') + if not status then + return false + end + return true +end + +do + if isOlympusModuleInitialized~=true then + local OlympusName = 'Olympus 0.0.1 C++ module' + isOlympusModuleInitialized=true; + Olympus.loadDLLs() + log.write('Olympus.EXPORT.LUA', log.INFO, OlympusName..' successfully loaded.') + else + log.write('Olympus.EXPORT.LUA', log.INFO, 'Olympus.dll already initialized') + end +end \ No newline at end of file diff --git a/scripts/OlympusHook.lua b/scripts/OlympusHook.lua new file mode 100644 index 00000000..2e3cb554 --- /dev/null +++ b/scripts/OlympusHook.lua @@ -0,0 +1,70 @@ +Olympus = {} +Olympus.OlympusDLL = nil +Olympus.cppRESTDLL = nil +Olympus.DLLsloaded = false +Olympus.debug = true +if Olympus.debug then + Olympus.OlympusModPath = "C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Debug\\" +else + Olympus.OlympusModPath = "C:\\Users\\dpass\\Doczuments\\Olympus\\bin\\x64\\Release\\" +end + +log.write('Olympus.HOOKS.LUA', log.INFO,'Executing OlympusHook.lua') + +function loadDLLs() + -- Add the .dll paths + package.cpath = package.cpath..';'..Olympus.OlympusModPath..'?.dll;' + + if Olympus.debug then + log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading cpprest_2_10d.dll from ['..Olympus.OlympusModPath..']') + pcall(require, 'cpprest_2_10d') + else + log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']') + pcall(require, 'cpprest_2_10') + end + + log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading Olympus.dll from ['..Olympus.OlympusModPath..']') + local status + status, Olympus.OlympusDLL = pcall(require, 'Olympus') + if not status then + return false + end + return true +end + +do + if isOlympusModuleInitialized~=true then + local OlympusName = 'Olympus 0.0.1 C++ module'; + + -- Register callbacks + local OlympusCallbacks = {} + function OlympusCallbacks.onSimulationStart() + log.write('Olympus.HOOKS.LUA', log.INFO,OlympusName..' onSimulationStart') + if DCS.isServer() then + Olympus.DLLsloaded = loadDLLs() + if Olympus.DLLsloaded then + Olympus.OlympusDLL.onSimulationStart() + log.write('Olympus.HOOKS.LUA', log.INFO, OlympusName..' successfully loaded.') + else + log.write('Olympus.HOOKS.LUA', log.ERROR, 'Failed to load '..OlympusName..'.') + end + end + end + + function OlympusCallbacks.onSimulationFrame() + if DCS.isServer() and Olympus.DLLsloaded then + Olympus.OlympusDLL.onSimulationFrame() + end + end + + function OlympusCallbacks.onSimulationStop() + if DCS.isServer() and Olympus.DLLsloaded then + Olympus.OlympusDLL.onSimulationStop() + end + end + DCS.setUserCallbacks(OlympusCallbacks) + log.write('Olympus.HOOKS.LUA', log.INFO, OlympusName..' callbacks registered correctly.') + + isOlympusModuleInitialized=true; + end +end \ No newline at end of file