Skip to content

Commit 882e571

Browse files
committed
New plugin generation updates.
Added used PSDK version to generated source.
1 parent 09552c2 commit 882e571

File tree

2 files changed

+73
-23
lines changed

2 files changed

+73
-23
lines changed

tools/Plugin-SDK_Wizard_Config.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<checkFile>Gameface\Binaries\Win64\LibertyCity.exe</checkFile>
6161
<project>plugin_iii_unreal</project>
6262
<projectOutput>plugin_iii_unreal</projectOutput>
63-
<target>DE-3</target>
63+
<target>GTA3_UNREAL</target>
6464
</component>
6565

6666
<component>
@@ -69,7 +69,7 @@
6969
<checkFile>Gameface\Binaries\Win64\ViceCity.exe</checkFile>
7070
<project>plugin_vc_unreal</project>
7171
<projectOutput>plugin_vc_unreal</projectOutput>
72-
<target>DE-VC</target>
72+
<target>GTAVC_UNREAL</target>
7373
</component>
7474

7575
<component>
@@ -78,7 +78,7 @@
7878
<checkFile>Gameface\Binaries\Win64\SanAndreas.exe</checkFile>
7979
<project>plugin_sa_unreal</project>
8080
<projectOutput>plugin_unreal</projectOutput>
81-
<target>DE-SA</target>
81+
<target>GTASA_UNREAL</target>
8282
</component>
8383

8484
<!-- Extras -->

tools/premake/premake5.lua

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -887,18 +887,63 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga
887887
}
888888
end
889889

890-
function generateNewPluginSource(projectDir, projectName, projectType, game2, game3, gameVc, gameSa, game4, game3Unreal, gameVcUnreal, gameSaUnreal)
891-
isTrilogy = false -- any of classic 3/VC/SA
892-
if game3 or gameVc or gameSa then isTrilogy = true end
893-
isTrilogyOnly = true -- only classic 3/VC/SA
894-
if not isTrilogy or game2 or game4 or game3Unreal or gameVcUnreal or gameSaUnreal then isTrilogyOnly = false end
890+
function getSdkVerInfo()
891+
local verNum = nil
892+
local verNumPrefix = "#define PLUGIN_SDK_VERSION "
893+
894+
local verDate = nil
895+
local verDatePrefix = "#define PLUGIN_SDK_DATE "
895896

896-
isUnreal = false -- any of Definitive Edition
897-
if game3Unreal or gameVcUnreal or gameSaUnreal then isUnreal = true end
898-
isUnrealOnly = true -- only classic 3/VC/SA
899-
if not isUnreal or game2 or game3 or gameVc or gameSa or game4 then isUnrealOnly = false end
897+
local file = io.open(path.join(sdkdir, "shared\\plugin.h"), "r")
898+
if file then
899+
for line in file:lines() do
900+
if line:sub(1, #verNumPrefix) == verNumPrefix then
901+
verNum = line:sub(#verNumPrefix + 1)
902+
end
903+
904+
if line:sub(1, #verDatePrefix) == verDatePrefix then
905+
verDate = line:sub(#verDatePrefix + 1)
906+
end
907+
end
908+
909+
file:close()
910+
end
911+
912+
local verTxt = nil
913+
914+
if verNum ~= nil then
915+
verTxt = "version " .. verNum
916+
end
917+
918+
if verDate ~= nil then
919+
if verTxt ~= nil then
920+
verTxt = verTxt .. " "
921+
end
922+
923+
verTxt = verTxt .. "from " .. verDate
924+
end
925+
926+
return verTxt
927+
end
900928

901-
platformCount = 0
929+
function generateNewPluginSource(projectDir, projectName, projectType, game2, game3, gameVc, gameSa, game4, game3Unreal, gameVcUnreal, gameSaUnreal)
930+
-- classis trilogy helper variables
931+
local trilogyDefs = {}
932+
if game3 then table.insert(trilogyDefs, "GTA3") end
933+
if gameVc then table.insert(trilogyDefs, "GTAVC") end
934+
if gameSa then table.insert(trilogyDefs, "GTASA") end
935+
local isTrilogy = (#trilogyDefs > 0) -- any of classic 3/VC/SA
936+
local isTrilogyOnly = isTrilogy and not (game2 or game4 or game3Unreal or gameVcUnreal or gameSaUnreal) -- only classic 3/VC/SA
937+
938+
-- Unreal trilogy helper variables
939+
local unrealDefs = {}
940+
if game3Unreal then table.insert(unrealDefs, "GTA3_UNREAL") end
941+
if gameVcUnreal then table.insert(unrealDefs, "GTAVC_UNREAL") end
942+
if gameSaUnreal then table.insert(unrealDefs, "GTASA_UNREAL") end
943+
local isUnreal = (#unrealDefs > 0) -- any of Unreal 3/VC/SA
944+
local isUnrealOnly = isUnreal and not (game2 or game3 or gameVc or gameSa or game4) -- only Unreal 3/VC/SA
945+
946+
local platformCount = 0
902947
if game2 then platformCount = platformCount + 1 end
903948
if game3 or gameVc then platformCount = platformCount + 1 end -- 3 and VC are almost identical
904949
if gameSa then platformCount = platformCount + 1 end
@@ -907,23 +952,28 @@ function generateNewPluginSource(projectDir, projectName, projectType, game2, ga
907952
if gameVcUnreal then platformCount = platformCount + 1 end
908953
if gameSaUnreal then platformCount = platformCount + 1 end
909954

910-
projectDir = path.normalize(projectDir)
911-
sourceDir = path.join(projectDir, "source")
955+
local projectDir = path.normalize(projectDir)
956+
local sourceDir = path.join(projectDir, "source")
912957
os.execute('if not exist "' .. sourceDir .. '" (mkdir "' .. sourceDir .. '")')
913958

914959
-- generate Main.cpp
915-
main = io.open(path.join(sourceDir, "Main.cpp"), 'w')
960+
local main = io.open(path.join(sourceDir, "Main.cpp"), 'w')
916961

917962
-- includes
918-
main:write([[#include <plugin.h>]], '\n')
963+
main:write([[#include <plugin.h>]])
964+
local verStr = getSdkVerInfo()
965+
if verStr ~= nil then
966+
main:write(' // Plugin-SDK ', verStr)
967+
end
968+
main:write('\n')
919969

920970
if game2 then
921971
if platformCount > 1 then main:write([[#if defined GTA2]], '\n') end
922972
main:write([[#include <CHud.h>]], '\n')
923973
if platformCount > 1 then main:write([[#endif]], '\n') end
924974
end
925975
if isTrilogy then
926-
if not isTrilogyOnly then main:write([[#if defined GTA3 || defined GTAVC || defined GTASA ]], '\n') end
976+
if not isTrilogyOnly then main:write([[#if defined ]], table.concat(trilogyDefs, " || defined "), '\n') end
927977
main:write([[#include <CMessages.h>]], '\n')
928978
if not isTrilogyOnly then main:write([[#endif]], '\n') end
929979
end
@@ -933,7 +983,7 @@ function generateNewPluginSource(projectDir, projectName, projectType, game2, ga
933983
if platformCount > 1 then main:write([[#endif]], '\n') end
934984
end
935985
if isUnreal then
936-
if not isUnrealOnly then main:write([[#if defined GTA3_UNREAL || defined GTAVC_UNREAL || defined GTASA_UNREAL ]], '\n') end
986+
if not isUnrealOnly then main:write([[#if defined ]], table.concat(unrealDefs, " || defined "), '\n') end
937987
--main:write([[#include <CHud.h>]], '\n') -- TODO: DE trilogy include
938988
if not isUnrealOnly then main:write([[#endif]], '\n') end
939989
end
@@ -956,8 +1006,8 @@ struct Main
9561006
{
9571007
m_frame++;
9581008
959-
static wchar_t msg[255];
960-
swprintf_s(msg, L"Hello world! Frame %d", m_frame);
1009+
static char msg[255];
1010+
sprintf_s(msg, "Hello world! Frame %d", m_frame);
9611011
9621012
]])
9631013

@@ -970,7 +1020,7 @@ struct Main
9701020

9711021
-- message printing classic trilogy
9721022
if isTrilogy then
973-
if not isTrilogyOnly then main:write([[ #if defined GTA3 or defined GTAVC or defined GTASA]], '\n') end
1023+
if not isTrilogyOnly then main:write([[ #if defined ]], table.concat(trilogyDefs, " || defined "), '\n') end
9741024
main:write([[ CMessages::AddMessageJumpQ(msg, 500, 0);]], '\n')
9751025
if not isTrilogyOnly then main:write([[ #endif]], '\n') end
9761026
end
@@ -984,7 +1034,7 @@ struct Main
9841034

9851035
-- message printing Definitive Edition trilogy
9861036
if isUnreal then
987-
if not isUnrealOnly then main:write([[ #if defined GTA3_UNREAL or defined GTAVC_UNREAL or defined GTASA_UNREAL]], '\n') end
1037+
if not isUnrealOnly then main:write([[ #if defined ]], table.concat(unrealDefs, " || defined "), '\n') end
9881038
--main:write([[ CMessages::AddMessageJumpQ(msg, 500, 0);]], '\n') TODO: DE trilogy message printing
9891039
if not isUnrealOnly then main:write([[ #endif]], '\n') end
9901040
end

0 commit comments

Comments
 (0)