mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Merge pull request #1009 from Azaezel/alpha41/moduleFileReload
adds a reloadModuleFiles(%moduleGroup); command
This commit is contained in:
commit
c08fa359d2
1 changed files with 71 additions and 1 deletions
|
|
@ -4,8 +4,78 @@ $reportModuleFileConflicts=true;
|
||||||
if (!isObject(ExecFilesList))
|
if (!isObject(ExecFilesList))
|
||||||
new ArrayObject(ExecFilesList);
|
new ArrayObject(ExecFilesList);
|
||||||
|
|
||||||
|
function reformatModTime(%modTime)
|
||||||
|
{
|
||||||
|
%date = getword(%modTime,0);
|
||||||
|
%date = strreplace(%modTime,"/"," ");
|
||||||
|
%date = getword(%date,2) SPC getword(%date,0) SPC getword(%date,1);
|
||||||
|
%hourMinSec = getword(%modTime,1);
|
||||||
|
%hourMinSec = strreplace(%hourMinSec,":"," ");
|
||||||
|
%retTime = %date SPC %hourMinSec;
|
||||||
|
for (%i=0;%i<6;%i++)
|
||||||
|
{
|
||||||
|
%nTry = getWord(%retTime,%i);
|
||||||
|
if (%nTry<10)
|
||||||
|
setWord(%retTime,%i,"0" SPC %nTry);
|
||||||
|
}
|
||||||
|
return %retTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//example usage: reloadModuleFiles("game");
|
||||||
|
function reloadModuleFiles(%moduleGroup)
|
||||||
|
{
|
||||||
|
//Get our modules so we can exec any specific client-side loading/handling
|
||||||
|
%modulesList = ModuleDatabase.findModules();
|
||||||
|
for(%i=0; %i < getWordCount(%modulesList); %i++)
|
||||||
|
{
|
||||||
|
%module = getWord(%modulesList, %i);
|
||||||
|
if(%moduleGroup !$= "")
|
||||||
|
{
|
||||||
|
if(%module.group !$= %moduleGroup)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(isFile(%module.ModuleScriptFilePath))
|
||||||
|
{
|
||||||
|
%modTime = fileModifiedTime(%module.ModuleScriptFilePath);
|
||||||
|
if (getWordCount(%modTime)>0)
|
||||||
|
{
|
||||||
|
%doExec = false;
|
||||||
|
if ($lastReExecution $="")
|
||||||
|
{
|
||||||
|
%doExec = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
%modTime = reformatModTime(%modTime);
|
||||||
|
if (strcmp(%modTime,$lastReExecution)>0)
|
||||||
|
{
|
||||||
|
//error("moded:"@ %modTime);
|
||||||
|
//warn("execd:"@ $lastReExecution);
|
||||||
|
%doExec = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (%doExec)
|
||||||
|
{
|
||||||
|
exec(%module.ModuleScriptFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lastReExecution = getTimeStamp();
|
||||||
|
//erase time seperators
|
||||||
|
$lastReExecution = strreplace($lastReExecution,"_"," ");
|
||||||
|
$lastReExecution = strreplace($lastReExecution,"-"," ");
|
||||||
|
for (%i=0;%i<6;%i++)
|
||||||
|
{
|
||||||
|
%nTry = getWord($lastReExecution,%i);
|
||||||
|
if (%nTry<10)
|
||||||
|
setWord($lastReExecution,%i,"0" SPC %nTry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function moduleExec(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
|
function moduleExec(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
|
||||||
{
|
{
|
||||||
|
reloadModuleFiles(%moduleGroup);
|
||||||
//clear per module group file execution chain
|
//clear per module group file execution chain
|
||||||
%execArray = new ArrayObject("callOn" @ %functionName @ "_" @ %moduleGroup);
|
%execArray = new ArrayObject("callOn" @ %functionName @ "_" @ %moduleGroup);
|
||||||
ExecFilesList.push_back(%execArray);
|
ExecFilesList.push_back(%execArray);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue