EgtExecutor 2.1g4 :
- aggiunte funzioni lua EgtSetVal e EgtGetVal (imposto e leggo su stringa Key=Val) - aggiunta funzione lua EgtSimulate (simulazione in cieco per verifica collisioni e corse) - aggiunte funzioni ExeSetEnableUI e ExeGetEnableUI per disabilitare e riabilitare aggiornamenti interfaccia utente.
This commit is contained in:
+141
-13
@@ -20,9 +20,11 @@
|
||||
#include "resource.h"
|
||||
#include "/EgtDev/Include/ExeExecutor.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileCompare.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
@@ -87,14 +89,16 @@ LuaPause( lua_State* L)
|
||||
int nTime ;
|
||||
LuaCheckParam( L, 1, nTime)
|
||||
LuaClearStack( L) ;
|
||||
// controllo la durata della pausa e la eseguo
|
||||
const int MIN_TIME = 0 ;
|
||||
const int MAX_TIME = 10000 ;
|
||||
if ( nTime < MIN_TIME)
|
||||
nTime = MIN_TIME ;
|
||||
else if ( nTime > MAX_TIME)
|
||||
nTime = MAX_TIME ;
|
||||
Sleep( nTime) ;
|
||||
// se abilitata UI, controllo la durata della pausa e la eseguo
|
||||
if ( ExeGetEnableUI()) {
|
||||
const int MIN_TIME = 0 ;
|
||||
const int MAX_TIME = 10000 ;
|
||||
if ( nTime < MIN_TIME)
|
||||
nTime = MIN_TIME ;
|
||||
else if ( nTime > MAX_TIME)
|
||||
nTime = MAX_TIME ;
|
||||
Sleep( nTime) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, true) ;
|
||||
return 1 ;
|
||||
@@ -188,6 +192,131 @@ LuaSplitStringPlus( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetVal( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Key, bVal|nVal|dVal|sVal|vtVal|ptVal|b3Val|frVal
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
bool bOk = false ;
|
||||
string sNotes = "" ;
|
||||
switch ( lua_type( L, 3)) {
|
||||
case LUA_TBOOLEAN :
|
||||
{ bool bVal ;
|
||||
LuaGetParam( L, 3, bVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, bVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TNUMBER :
|
||||
{ double dVal ;
|
||||
LuaGetParam( L, 3, dVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, dVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TSTRING :
|
||||
{ string sVal ;
|
||||
LuaGetParam( L, 3, sVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, (const string&) sVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TTABLE :
|
||||
{ Frame3d frVal ;
|
||||
BBox3d b3Val ;
|
||||
Vector3d vtVal ; // va bene anche per Point3d
|
||||
if ( LuaGetParam( L, 3, frVal)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, frVal, sNotes) ;
|
||||
}
|
||||
else if ( LuaGetParam( L, 3, b3Val)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, b3Val, sNotes) ;
|
||||
}
|
||||
else if ( LuaGetParam( L, 3, vtVal)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, vtVal, sNotes) ;
|
||||
}
|
||||
} break ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, sNotes) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetVal( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : String, Key, sType
|
||||
string sVal ;
|
||||
LuaCheckParam( L, 1, sVal)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
string sType = "s" ;
|
||||
LuaGetParam( L, 3, sType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'info
|
||||
if ( sType == "b" || sType == "B") {
|
||||
bool bVal ;
|
||||
if ( GetVal( sVal, sKey, bVal))
|
||||
LuaSetParam( L, bVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "i" || sType == "I") {
|
||||
int nVal ;
|
||||
if ( GetVal( sVal, sKey, nVal))
|
||||
LuaSetParam( L, nVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "d" || sType == "D") {
|
||||
double dVal ;
|
||||
if ( GetVal( sVal, sKey, dVal))
|
||||
LuaSetParam( L, dVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "v" || sType == "V") {
|
||||
Vector3d vtVal ;
|
||||
if ( GetVal( sVal, sKey, vtVal))
|
||||
LuaSetParam( L, vtVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "p" || sType == "P") {
|
||||
Point3d ptVal ;
|
||||
if ( GetVal( sVal, sKey, ptVal))
|
||||
LuaSetParam( L, ptVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "x" || sType == "X") {
|
||||
BBox3d b3Val ;
|
||||
if ( GetVal( sVal, sKey, b3Val))
|
||||
LuaSetParam( L, b3Val) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "f" || sType == "F") {
|
||||
Frame3d frVal ;
|
||||
if ( GetVal( sVal, sKey, frVal))
|
||||
LuaSetParam( L, frVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else { // "s" "S"
|
||||
string sInfo ;
|
||||
if ( GetVal( sVal, sKey, sInfo))
|
||||
LuaSetParam( L, sInfo) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExecTsc( lua_State* L)
|
||||
@@ -270,17 +399,14 @@ LuaGetDebugLevel( lua_State* L)
|
||||
static int
|
||||
LuaOutLog( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : stringa da emettere [, DebugLevel]
|
||||
// 1 o 2 parametri : stringa da emettere [, DebugLevel = 0]
|
||||
string sOut ;
|
||||
LuaCheckParam( L, 1, sOut)
|
||||
int nDbgLev = 0 ;
|
||||
LuaGetParam( L, 2, nDbgLev) ;
|
||||
LuaClearStack( L) ;
|
||||
// accodo il messaggio nel file di log
|
||||
if ( nDbgLev == 0)
|
||||
LOG_INFO( GetLogger(), sOut.c_str())
|
||||
else if ( ExeGetDebugLevel() >= nDbgLev)
|
||||
LOG_DBG_INFO( GetLogger(), sOut.c_str())
|
||||
ExeOutLog( sOut, nDbgLev) ;
|
||||
// non c'è risultato
|
||||
return 0 ;
|
||||
}
|
||||
@@ -791,6 +917,8 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtNumToString", LuaNumToString) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitString", LuaSplitString) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitStringPlus", LuaSplitStringPlus) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetVal", LuaSetVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetVal", LuaGetVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExecTsc", LuaExecTsc) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExecTscLine", LuaExecTscLine) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetTscVar", LuaSetTscVar) ;
|
||||
|
||||
Reference in New Issue
Block a user