mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Merge branch 'Preview4_0' of https://github.com/TorqueGameEngines/Torque3D into SoundAssetImplements
This commit is contained in:
commit
b83babe175
26 changed files with 355 additions and 114 deletions
|
|
@ -1551,13 +1551,10 @@ void ParticleEmitter::updateBBox()
|
||||||
|
|
||||||
for (Particle* part = part_list_head.next; part != NULL; part = part->next)
|
for (Particle* part = part_list_head.next; part != NULL; part = part->next)
|
||||||
{
|
{
|
||||||
for (Particle* part = part_list_head.next; part != NULL; part = part->next)
|
Point3F particleSize(part->size * 0.5f);
|
||||||
{
|
F32 motion = getMax((part->vel.len() * part->totalLifetime / 1000.0f), 1.0f);
|
||||||
Point3F particleSize(part->size * 0.5f);
|
minPt.setMin(part->pos - particleSize - Point3F(motion));
|
||||||
F32 motion = getMax((part->vel.len() * part->totalLifetime / 1000.0f), 1.0f);
|
maxPt.setMax(part->pos + particleSize + Point3F(motion));
|
||||||
minPt.setMin(part->pos - particleSize - Point3F(motion));
|
|
||||||
maxPt.setMax(part->pos + particleSize + Point3F(motion));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mObjBox = Box3F(minPt, maxPt);
|
mObjBox = Box3F(minPt, maxPt);
|
||||||
|
|
@ -1675,8 +1672,8 @@ void ParticleEmitter::addParticle(const Point3F& pos, const Point3F& axis, const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
U32 dBlockIndex = gRandGen.randI() % mDataBlock->particleDataBlocks.size();
|
dBlockIndex = gRandGen.randI() % mDataBlock->particleDataBlocks.size();
|
||||||
mDataBlock->particleDataBlocks[dBlockIndex]->initializeParticle(pNew, vel);
|
mDataBlock->particleDataBlocks[dBlockIndex]->initializeParticle(pNew, vel);
|
||||||
}
|
}
|
||||||
updateKeyData( pNew );
|
updateKeyData( pNew );
|
||||||
|
|
||||||
|
|
@ -2220,7 +2217,7 @@ void ParticleEmitter::setupOriented( Particle *part,
|
||||||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||||
const ColorI color = partCol.toColorI();
|
const ColorI color = partCol.toColorI();
|
||||||
// Here we deal with UVs for animated particle (oriented)
|
// Here we deal with UVs for animated particle (oriented)
|
||||||
if (part->dataBlock->animateTexture)
|
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||||
{
|
{
|
||||||
// Let particle compute the UV indices for current frame
|
// Let particle compute the UV indices for current frame
|
||||||
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
||||||
|
|
@ -2331,7 +2328,7 @@ void ParticleEmitter::setupAligned( const Particle *part,
|
||||||
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
LinearColorF partCol = mLerp( part->color, ( part->color * ambientColor ), ambientLerp );
|
||||||
const ColorI color = partCol.toColorI();
|
const ColorI color = partCol.toColorI();
|
||||||
// Here we deal with UVs for animated particle
|
// Here we deal with UVs for animated particle
|
||||||
if (part->dataBlock->animateTexture)
|
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||||
{
|
{
|
||||||
// Let particle compute the UV indices for current frame
|
// Let particle compute the UV indices for current frame
|
||||||
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
S32 fm = (S32)(part->currentAge*(1.0f/1000.0f)*part->dataBlock->framesPerSec);
|
||||||
|
|
@ -2520,7 +2517,7 @@ void ParticleEmitter::setupRibbon(Particle *part,
|
||||||
ColorI pCol = partCol.toColorI();
|
ColorI pCol = partCol.toColorI();
|
||||||
|
|
||||||
// Here we deal with UVs for animated particle (oriented)
|
// Here we deal with UVs for animated particle (oriented)
|
||||||
if (part->dataBlock->animateTexture)
|
if (part->dataBlock->animateTexture && !part->dataBlock->animTexFrames.empty())
|
||||||
{
|
{
|
||||||
// Let particle compute the UV indices for current frame
|
// Let particle compute the UV indices for current frame
|
||||||
S32 fm = (S32)(part->currentAge*(1.0f / 1000.0f)*part->dataBlock->framesPerSec);
|
S32 fm = (S32)(part->currentAge*(1.0f / 1000.0f)*part->dataBlock->framesPerSec);
|
||||||
|
|
|
||||||
|
|
@ -783,6 +783,8 @@ bool Projectile::onAdd()
|
||||||
// If we're on the server, we need to inherit some of our parent's velocity
|
// If we're on the server, we need to inherit some of our parent's velocity
|
||||||
//
|
//
|
||||||
mCurrTick = 0;
|
mCurrTick = 0;
|
||||||
|
|
||||||
|
scriptOnAdd();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -250,8 +250,9 @@ namespace VPersistence
|
||||||
if ( object->isMethod( "onAdd" ) )
|
if ( object->isMethod( "onAdd" ) )
|
||||||
{
|
{
|
||||||
// Callback.
|
// Callback.
|
||||||
const char *retValue = Con::executef( object, "onAdd" );
|
ConsoleValue cValue = Con::executef( object, "onAdd" );
|
||||||
if ( !dAtob( retValue ) )
|
|
||||||
|
if ( !cValue.getBool() )
|
||||||
{
|
{
|
||||||
// Delete.
|
// Delete.
|
||||||
object->deleteObject();
|
object->deleteObject();
|
||||||
|
|
|
||||||
|
|
@ -989,9 +989,10 @@ afxEffectron::start_effect(afxEffectronData* datablock, SimObject* extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CALL SCRIPT afxEffectronData::onPreactivate(%params, %extra)
|
// CALL SCRIPT afxEffectronData::onPreactivate(%params, %extra)
|
||||||
const char* result = Con::executef(datablock, "onPreactivate",
|
ConsoleValue cValue = Con::executef(datablock, "onPreactivate",
|
||||||
Con::getIntArg(param_holder->getId()),
|
Con::getIntArg(param_holder->getId()),
|
||||||
(extra) ? Con::getIntArg(extra->getId()) : "");
|
(extra) ? Con::getIntArg(extra->getId()) : "");
|
||||||
|
const char* result = cValue.getString();
|
||||||
if (result && result[0] != '\0' && !dAtob(result))
|
if (result && result[0] != '\0' && !dAtob(result))
|
||||||
{
|
{
|
||||||
#if defined(TORQUE_DEBUG)
|
#if defined(TORQUE_DEBUG)
|
||||||
|
|
|
||||||
|
|
@ -1068,9 +1068,11 @@ afxSelectron::start_selectron(SceneObject* picked, U8 subcode, SimObject* extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CALL SCRIPT afxSelectronData::onPreactivate(%params, %extra)
|
// CALL SCRIPT afxSelectronData::onPreactivate(%params, %extra)
|
||||||
const char* result = Con::executef(datablock, "onPreactivate",
|
ConsoleValue cValue = Con::executef(datablock, "onPreactivate",
|
||||||
Con::getIntArg(param_holder->getId()),
|
Con::getIntArg(param_holder->getId()),
|
||||||
(extra) ? Con::getIntArg(extra->getId()) : "").getString();
|
(extra) ? Con::getIntArg(extra->getId()) : "");
|
||||||
|
|
||||||
|
const char* result = cValue.getString();
|
||||||
if (result && result[0] != '\0' && !dAtob(result))
|
if (result && result[0] != '\0' && !dAtob(result))
|
||||||
{
|
{
|
||||||
#if defined(TORQUE_DEBUG)
|
#if defined(TORQUE_DEBUG)
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ S32 QSORT_CALLBACK ArrayObject::_keyFunctionCompare( const void* a, const void*
|
||||||
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
||||||
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
||||||
|
|
||||||
S32 result = dAtoi(Con::executef((const char*)smCompareFunction, ea->key, eb->key));
|
ConsoleValue cValue = Con::executef((const char*)smCompareFunction, ea->key, eb->key);
|
||||||
|
S32 result = cValue.getInt();
|
||||||
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
||||||
return ( smDecreasing ? -res : res );
|
return ( smDecreasing ? -res : res );
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +114,8 @@ S32 QSORT_CALLBACK ArrayObject::_valueFunctionCompare( const void* a, const void
|
||||||
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
ArrayObject::Element* ea = ( ArrayObject::Element* )( a );
|
||||||
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
ArrayObject::Element* eb = ( ArrayObject::Element* )( b );
|
||||||
|
|
||||||
S32 result = dAtoi( Con::executef( (const char*)smCompareFunction, ea->value, eb->value ) );
|
ConsoleValue cValue = Con::executef( (const char*)smCompareFunction, ea->value, eb->value );
|
||||||
|
S32 result = cValue.getInt();
|
||||||
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
S32 res = result < 0 ? -1 : ( result > 0 ? 1 : 0 );
|
||||||
return ( smDecreasing ? -res : res );
|
return ( smDecreasing ? -res : res );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,57 +56,7 @@ namespace Compiler
|
||||||
|
|
||||||
using namespace Compiler;
|
using namespace Compiler;
|
||||||
|
|
||||||
class FuncVars
|
FuncVars gEvalFuncVars;
|
||||||
{
|
|
||||||
struct Var
|
|
||||||
{
|
|
||||||
S32 reg;
|
|
||||||
TypeReq currentType;
|
|
||||||
StringTableEntry name;
|
|
||||||
bool isConstant;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false)
|
|
||||||
{
|
|
||||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
|
||||||
if (found != vars.end())
|
|
||||||
{
|
|
||||||
AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
|
||||||
return found->second.reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
S32 id = counter++;
|
|
||||||
vars[var] = { id, currentType, var, isConstant };
|
|
||||||
variableNameMap[id] = var;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
S32 lookup(StringTableEntry var, S32 lineNumber)
|
|
||||||
{
|
|
||||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
|
||||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
|
||||||
return found->second.reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeReq lookupType(StringTableEntry var, S32 lineNumber)
|
|
||||||
{
|
|
||||||
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
|
||||||
|
|
||||||
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
|
||||||
return found->second.currentType;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline S32 count() { return counter; }
|
|
||||||
|
|
||||||
std::unordered_map<S32, StringTableEntry> variableNameMap;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_map<StringTableEntry, Var> vars;
|
|
||||||
S32 counter = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
FuncVars* gFuncVars = NULL;
|
FuncVars* gFuncVars = NULL;
|
||||||
|
|
||||||
inline FuncVars* getFuncVars(S32 lineNumber)
|
inline FuncVars* getFuncVars(S32 lineNumber)
|
||||||
|
|
@ -1602,7 +1552,8 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
|
||||||
tbl->add(fnName, nameSpace, varName);
|
tbl->add(fnName, nameSpace, varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
gFuncVars = NULL;
|
// In eval mode, global func vars are allowed.
|
||||||
|
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
|
||||||
|
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ CodeBlock * CodeBlock::smCodeBlockList = NULL;
|
||||||
CodeBlock * CodeBlock::smCurrentCodeBlock = NULL;
|
CodeBlock * CodeBlock::smCurrentCodeBlock = NULL;
|
||||||
ConsoleParser *CodeBlock::smCurrentParser = NULL;
|
ConsoleParser *CodeBlock::smCurrentParser = NULL;
|
||||||
|
|
||||||
|
extern FuncVars gEvalFuncVars;
|
||||||
|
extern FuncVars* gFuncVars;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
CodeBlock::CodeBlock()
|
CodeBlock::CodeBlock()
|
||||||
|
|
@ -491,6 +494,8 @@ bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, con
|
||||||
chompUTF8BOM(inScript, &script);
|
chompUTF8BOM(inScript, &script);
|
||||||
|
|
||||||
gSyntaxError = false;
|
gSyntaxError = false;
|
||||||
|
gIsEvalCompile = false;
|
||||||
|
gFuncVars = NULL;
|
||||||
|
|
||||||
consoleAllocReset();
|
consoleAllocReset();
|
||||||
|
|
||||||
|
|
@ -629,6 +634,11 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
||||||
addToCodeList();
|
addToCodeList();
|
||||||
|
|
||||||
gStatementList = NULL;
|
gStatementList = NULL;
|
||||||
|
|
||||||
|
// we are an eval compile if we don't have a file name associated (no exec)
|
||||||
|
gIsEvalCompile = fileName == NULL;
|
||||||
|
// In eval mode, global func vars are allowed.
|
||||||
|
gFuncVars = gIsEvalCompile ? &gEvalFuncVars : NULL;
|
||||||
|
|
||||||
// Set up the parser.
|
// Set up the parser.
|
||||||
smCurrentParser = getParserForFile(fileName);
|
smCurrentParser = getParserForFile(fileName);
|
||||||
|
|
@ -667,6 +677,8 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
||||||
|
|
||||||
codeStream.emit(OP_RETURN_VOID);
|
codeStream.emit(OP_RETURN_VOID);
|
||||||
codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
|
codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
|
||||||
|
|
||||||
|
S32 localRegisterCount = gIsEvalCompile ? gEvalFuncVars.count() : 0;
|
||||||
|
|
||||||
consoleAllocReset();
|
consoleAllocReset();
|
||||||
|
|
||||||
|
|
@ -683,7 +695,8 @@ ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inStr
|
||||||
if (lastIp + 1 != codeSize)
|
if (lastIp + 1 != codeSize)
|
||||||
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
|
||||||
|
|
||||||
return std::move(exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame));
|
// repurpose argc as local register counter for global state
|
||||||
|
return std::move(exec(0, fileName, NULL, localRegisterCount, 0, noCalls, NULL, setFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -693,7 +693,8 @@ ConsoleValue CodeBlock::exec(U32 ip, const char* functionName, Namespace* thisNa
|
||||||
// Do we want this code to execute using a new stack frame?
|
// Do we want this code to execute using a new stack frame?
|
||||||
if (setFrame < 0)
|
if (setFrame < 0)
|
||||||
{
|
{
|
||||||
gEvalState.pushFrame(NULL, NULL, 0);
|
// argc is the local count for eval
|
||||||
|
gEvalState.pushFrame(NULL, NULL, argc);
|
||||||
gCallStack.pushFrame(0);
|
gCallStack.pushFrame(0);
|
||||||
popFrame = true;
|
popFrame = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@
|
||||||
|
|
||||||
#include "console/simBase.h"
|
#include "console/simBase.h"
|
||||||
|
|
||||||
|
extern FuncVars gEvalFuncVars;
|
||||||
|
|
||||||
namespace Compiler
|
namespace Compiler
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -86,6 +88,7 @@ namespace Compiler
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
bool gSyntaxError = false;
|
bool gSyntaxError = false;
|
||||||
|
bool gIsEvalCompile = false;
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -121,6 +124,7 @@ namespace Compiler
|
||||||
getFunctionStringTable().reset();
|
getFunctionStringTable().reset();
|
||||||
getIdentTable().reset();
|
getIdentTable().reset();
|
||||||
getFunctionVariableMappingTable().reset();
|
getFunctionVariableMappingTable().reset();
|
||||||
|
gEvalFuncVars.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
|
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
|
||||||
|
|
@ -132,6 +136,44 @@ namespace Compiler
|
||||||
|
|
||||||
using namespace Compiler;
|
using namespace Compiler;
|
||||||
|
|
||||||
|
S32 FuncVars::assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant)
|
||||||
|
{
|
||||||
|
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||||
|
if (found != vars.end())
|
||||||
|
{
|
||||||
|
AssertISV(!found->second.isConstant, avar("Reassigning variable %s when it is a constant. File: %s Line : %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||||
|
return found->second.reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
S32 id = counter++;
|
||||||
|
vars[var] = { id, currentType, var, isConstant };
|
||||||
|
variableNameMap[id] = var;
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
S32 FuncVars::lookup(StringTableEntry var, S32 lineNumber)
|
||||||
|
{
|
||||||
|
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||||
|
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||||
|
return found->second.reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeReq FuncVars::lookupType(StringTableEntry var, S32 lineNumber)
|
||||||
|
{
|
||||||
|
std::unordered_map<StringTableEntry, Var>::iterator found = vars.find(var);
|
||||||
|
|
||||||
|
AssertISV(found != vars.end(), avar("Variable %s referenced before used when compiling script. File: %s Line: %d", var, CodeBlock::smCurrentParser->getCurrentFile(), lineNumber));
|
||||||
|
return found->second.currentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FuncVars::clear()
|
||||||
|
{
|
||||||
|
vars.clear();
|
||||||
|
variableNameMap.clear();
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,35 @@ namespace Compiler
|
||||||
void consoleAllocReset();
|
void consoleAllocReset();
|
||||||
|
|
||||||
extern bool gSyntaxError;
|
extern bool gSyntaxError;
|
||||||
|
extern bool gIsEvalCompile;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FuncVars
|
||||||
|
{
|
||||||
|
struct Var
|
||||||
|
{
|
||||||
|
S32 reg;
|
||||||
|
TypeReq currentType;
|
||||||
|
StringTableEntry name;
|
||||||
|
bool isConstant;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
S32 assign(StringTableEntry var, TypeReq currentType, S32 lineNumber, bool isConstant = false);
|
||||||
|
|
||||||
|
S32 lookup(StringTableEntry var, S32 lineNumber);
|
||||||
|
|
||||||
|
TypeReq lookupType(StringTableEntry var, S32 lineNumber);
|
||||||
|
|
||||||
|
inline S32 count() { return counter; }
|
||||||
|
|
||||||
|
std::unordered_map<S32, StringTableEntry> variableNameMap;
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<StringTableEntry, Var> vars;
|
||||||
|
S32 counter = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Utility class to emit and patch bytecode
|
/// Utility class to emit and patch bytecode
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,8 @@ S32 QSORT_CALLBACK SimObjectList::_callbackSort( const void *a, const void *b )
|
||||||
static char idB[64];
|
static char idB[64];
|
||||||
dSprintf( idB, sizeof( idB ), "%d", objB->getId() );
|
dSprintf( idB, sizeof( idB ), "%d", objB->getId() );
|
||||||
|
|
||||||
return dAtoi( Con::executef( (const char*)smSortScriptCallbackFn, idA, idB ) );
|
ConsoleValue cValue = Con::executef( (const char*)smSortScriptCallbackFn, idA, idB );
|
||||||
|
return cValue.getInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimObjectList::scriptSort( const String &scriptCallback )
|
void SimObjectList::scriptSort( const String &scriptCallback )
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,8 @@ void GuiRiverEditorCtrl::_process3DMouseDown( const Gui3DMouseEvent& event )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *res = Con::executef( this, "createRiver" );
|
ConsoleValue cValue = Con::executef( this, "createRiver" );
|
||||||
|
const char* res = cValue.getString();
|
||||||
|
|
||||||
River *newRiver;
|
River *newRiver;
|
||||||
if ( !Sim::findObject( res, newRiver ) )
|
if ( !Sim::findObject( res, newRiver ) )
|
||||||
|
|
|
||||||
|
|
@ -588,7 +588,8 @@ void ForestBrushTool::_collectElements()
|
||||||
if ( !Sim::findObject( "ForestEditBrushTree", brushTree ) )
|
if ( !Sim::findObject( "ForestEditBrushTree", brushTree ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char* objectIdList = Con::executef( brushTree, "getSelectedObjectList" );
|
ConsoleValue cValue = Con::executef( brushTree, "getSelectedObjectList" );
|
||||||
|
const char* objectIdList = cValue.getString();
|
||||||
|
|
||||||
// Collect those objects in a vector and mark them as selected.
|
// Collect those objects in a vector and mark them as selected.
|
||||||
|
|
||||||
|
|
@ -685,4 +686,4 @@ bool ForestBrushTool::getGroundAt( const Point3F &worldPt, F32 *zValueOut, Vecto
|
||||||
DefineEngineMethod( ForestBrushTool, collectElements, void, (), , "" )
|
DefineEngineMethod( ForestBrushTool, collectElements, void, (), , "" )
|
||||||
{
|
{
|
||||||
object->collectElements();
|
object->collectElements();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ void GuiGameListMenuCtrl::onRenderListOption(Row* row, Point2I currentOffset)
|
||||||
|
|
||||||
// calculate text to be at the center between the arrows
|
// calculate text to be at the center between the arrows
|
||||||
GFont* font = profile->mFont;
|
GFont* font = profile->mFont;
|
||||||
StringTableEntry text = row->mOptions[row->mSelectedOption];
|
StringTableEntry text = row->mOptions[row->mSelectedOption].mDisplayText;
|
||||||
S32 textWidth = font->getStrWidth(text);
|
S32 textWidth = font->getStrWidth(text);
|
||||||
S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
|
S32 columnWidth = profile->mHitAreaLowerRight.x * xScale - profile->mRightPad - columnSplit;
|
||||||
S32 columnCenter = columnSplit + (columnWidth >> 1);
|
S32 columnCenter = columnSplit + (columnWidth >> 1);
|
||||||
|
|
@ -489,15 +489,18 @@ void GuiGameListMenuCtrl::addRow(const char* label, const char* optionsList, boo
|
||||||
{
|
{
|
||||||
static StringTableEntry DELIM = StringTable->insert("\t", true);
|
static StringTableEntry DELIM = StringTable->insert("\t", true);
|
||||||
Row* row = new Row();
|
Row* row = new Row();
|
||||||
Vector<StringTableEntry> options(__FILE__, __LINE__);
|
Vector<OptionEntry> options(__FILE__, __LINE__);
|
||||||
|
|
||||||
S32 defaultOption = 0;
|
S32 defaultOption = 0;
|
||||||
|
|
||||||
S32 count = StringUnit::getUnitCount(optionsList, DELIM);
|
S32 count = StringUnit::getUnitCount(optionsList, DELIM);
|
||||||
for (S32 i = 0; i < count; ++i)
|
for (S32 i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
|
OptionEntry e;
|
||||||
const char* option = StringUnit::getUnit(optionsList, i, DELIM);
|
const char* option = StringUnit::getUnit(optionsList, i, DELIM);
|
||||||
options.push_back(StringTable->insert(option, true));
|
e.mDisplayText = StringTable->insert(option, true);
|
||||||
|
e.mKeyString = e.mDisplayText;
|
||||||
|
options.push_back(e);
|
||||||
|
|
||||||
if (String::compare(option, defaultValue) == 0)
|
if (String::compare(option, defaultValue) == 0)
|
||||||
defaultOption = options.size() - 1;
|
defaultOption = options.size() - 1;
|
||||||
|
|
@ -1075,12 +1078,38 @@ StringTableEntry GuiGameListMenuCtrl::getCurrentOption(S32 rowIndex) const
|
||||||
Row* row = (Row*)mRows[rowIndex];
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
if (row->mSelectedOption != NO_OPTION)
|
if (row->mSelectedOption != NO_OPTION)
|
||||||
{
|
{
|
||||||
return row->mOptions[row->mSelectedOption];
|
return row->mOptions[row->mSelectedOption].mDisplayText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringTable->insert("", false);
|
return StringTable->insert("", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringTableEntry GuiGameListMenuCtrl::getCurrentOptionKey(S32 rowIndex) const
|
||||||
|
{
|
||||||
|
if (isValidRowIndex(rowIndex))
|
||||||
|
{
|
||||||
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
if (row->mSelectedOption != NO_OPTION)
|
||||||
|
{
|
||||||
|
return row->mOptions[row->mSelectedOption].mKeyString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringTable->insert("", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
S32 GuiGameListMenuCtrl::getCurrentOptionIndex(S32 rowIndex) const
|
||||||
|
{
|
||||||
|
if (isValidRowIndex(rowIndex))
|
||||||
|
{
|
||||||
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
if (row->mSelectedOption != NO_OPTION)
|
||||||
|
{
|
||||||
|
return row->mSelectedOption;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return S32(-1);
|
||||||
|
}
|
||||||
|
|
||||||
bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
|
bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
|
||||||
{
|
{
|
||||||
if (!isValidRowIndex(rowIndex))
|
if (!isValidRowIndex(rowIndex))
|
||||||
|
|
@ -1090,9 +1119,9 @@ bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
|
||||||
|
|
||||||
Row* row = (Row*)mRows[rowIndex];
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
|
||||||
for (Vector<StringTableEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
|
for (Vector<OptionEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
|
||||||
{
|
{
|
||||||
if (String::compare(*anOption, theOption) == 0)
|
if (String::compare((*anOption).mDisplayText, theOption) == 0)
|
||||||
{
|
{
|
||||||
S32 newIndex = anOption - row->mOptions.begin();
|
S32 newIndex = anOption - row->mOptions.begin();
|
||||||
row->mSelectedOption = newIndex;
|
row->mSelectedOption = newIndex;
|
||||||
|
|
@ -1103,6 +1132,45 @@ bool GuiGameListMenuCtrl::selectOption(S32 rowIndex, const char* theOption)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GuiGameListMenuCtrl::selectOptionByKey(S32 rowIndex, const char* optionKey)
|
||||||
|
{
|
||||||
|
if (!isValidRowIndex(rowIndex))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
|
||||||
|
for (Vector<OptionEntry>::iterator anOption = row->mOptions.begin(); anOption < row->mOptions.end(); ++anOption)
|
||||||
|
{
|
||||||
|
if (String::compare((*anOption).mKeyString, optionKey) == 0)
|
||||||
|
{
|
||||||
|
S32 newIndex = anOption - row->mOptions.begin();
|
||||||
|
row->mSelectedOption = newIndex;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GuiGameListMenuCtrl::selectOptionByIndex(S32 rowIndex, S32 optionIndex)
|
||||||
|
{
|
||||||
|
if (!isValidRowIndex(rowIndex) || (optionIndex < 0))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
if (optionIndex < row->mOptions.size())
|
||||||
|
{
|
||||||
|
row->mSelectedOption = optionIndex;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
|
void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
|
||||||
{
|
{
|
||||||
static StringTableEntry DELIM = StringTable->insert("\t", true);
|
static StringTableEntry DELIM = StringTable->insert("\t", true);
|
||||||
|
|
@ -1119,7 +1187,10 @@ void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
|
||||||
for (S32 i = 0; i < count; ++i)
|
for (S32 i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const char* option = StringUnit::getUnit(optionsList, i, DELIM);
|
const char* option = StringUnit::getUnit(optionsList, i, DELIM);
|
||||||
row->mOptions[i] = StringTable->insert(option, true);
|
OptionEntry e;
|
||||||
|
e.mDisplayText = StringTable->insert(option, true);
|
||||||
|
e.mKeyString = e.mDisplayText;
|
||||||
|
row->mOptions[i] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row->mSelectedOption >= row->mOptions.size())
|
if (row->mSelectedOption >= row->mOptions.size())
|
||||||
|
|
@ -1128,6 +1199,21 @@ void GuiGameListMenuCtrl::setOptions(S32 rowIndex, const char* optionsList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiGameListMenuCtrl::addOption(S32 rowIndex, const char* displayText, const char* keyText)
|
||||||
|
{
|
||||||
|
if (!isValidRowIndex(rowIndex))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionEntry e;
|
||||||
|
e.mDisplayText = StringTable->insert(displayText, true);
|
||||||
|
e.mKeyString = (keyText[0] == '\0') ? e.mDisplayText : StringTable->insert(keyText, true);
|
||||||
|
|
||||||
|
Row* row = (Row*)mRows[rowIndex];
|
||||||
|
row->mOptions.push_back(e);
|
||||||
|
}
|
||||||
|
|
||||||
void GuiGameListMenuCtrl::clickOption(Row* row, S32 xPos)
|
void GuiGameListMenuCtrl::clickOption(Row* row, S32 xPos)
|
||||||
{
|
{
|
||||||
GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
|
GuiGameListMenuProfile* profile = (GuiGameListMenuProfile*)mProfile;
|
||||||
|
|
@ -1566,6 +1652,22 @@ DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOption, const char*, (S32 row)
|
||||||
return object->getCurrentOption(row);
|
return object->getCurrentOption(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOptionKey, const char*, (S32 row), ,
|
||||||
|
"Gets the key string for the currently selected option of the given row.\n\n"
|
||||||
|
"@param row Index of the row to get the option from.\n"
|
||||||
|
"@return The key (or id) that was assigned to the selected option on the given row. If there is no selected option then the empty string is returned.")
|
||||||
|
{
|
||||||
|
return object->getCurrentOptionKey(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiGameListMenuCtrl, getCurrentOptionIndex, S32, (S32 row), ,
|
||||||
|
"Gets the index into the option list for the currently selected option of the given row.\n\n"
|
||||||
|
"@param row Index of the row to get the option from.\n"
|
||||||
|
"@return The index of the selected option on the given row. If there is no selected option then -1 is returned.")
|
||||||
|
{
|
||||||
|
return object->getCurrentOptionIndex(row);
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char* option), ,
|
DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char* option), ,
|
||||||
"Set the row's current option to the one specified\n\n"
|
"Set the row's current option to the one specified\n\n"
|
||||||
"@param row Index of the row to set an option on.\n"
|
"@param row Index of the row to set an option on.\n"
|
||||||
|
|
@ -1575,6 +1677,24 @@ DefineEngineMethod(GuiGameListMenuCtrl, selectOption, bool, (S32 row, const char
|
||||||
return object->selectOption(row, option);
|
return object->selectOption(row, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiGameListMenuCtrl, selectOptionByKey, bool, (S32 row, const char* optionKey), ,
|
||||||
|
"Set the row's current option to the one with the specified key.\n\n"
|
||||||
|
"@param row Index of the row to set an option on.\n"
|
||||||
|
"@param optionKey The key string that was assigned to the option to be made active.\n"
|
||||||
|
"@return True if the row contained the key and the option and was set, false otherwise.")
|
||||||
|
{
|
||||||
|
return object->selectOptionByKey(row, optionKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiGameListMenuCtrl, selectOptionByIndex, bool, (S32 row, S32 optionIndex), ,
|
||||||
|
"Set the row's current option to the one at the specified index.\n\n"
|
||||||
|
"@param row Index of the row to set an option on.\n"
|
||||||
|
"@param optionIndex The index of the option to be made active.\n"
|
||||||
|
"@return True if the index was valid and the option and was set, false otherwise.")
|
||||||
|
{
|
||||||
|
return object->selectOptionByIndex(row, optionIndex);
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char* optionsList), ,
|
DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char* optionsList), ,
|
||||||
"Sets the list of options on the given row.\n\n"
|
"Sets the list of options on the given row.\n\n"
|
||||||
"@param row Index of the row to set options on."
|
"@param row Index of the row to set options on."
|
||||||
|
|
@ -1583,6 +1703,16 @@ DefineEngineMethod(GuiGameListMenuCtrl, setOptions, void, (S32 row, const char*
|
||||||
object->setOptions(row, optionsList);
|
object->setOptions(row, optionsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GuiGameListMenuCtrl, addOption, void, (S32 row, const char* displayText, const char* keyText), (""),
|
||||||
|
"Adds an option to the list of options on the given row.\n\n"
|
||||||
|
"@param row Index of the row to add the option on.\n"
|
||||||
|
"@param displayText The text to display for this option.\n"
|
||||||
|
"@param keyText [Optional] The id string to associate with this value. "
|
||||||
|
"If unset, the id will be the same as the display text.\n")
|
||||||
|
{
|
||||||
|
object->addOption(row, displayText, keyText);
|
||||||
|
}
|
||||||
|
|
||||||
DefineEngineMethod(GuiGameListMenuCtrl, getValue, F32, (S32 row), ,
|
DefineEngineMethod(GuiGameListMenuCtrl, getValue, F32, (S32 row), ,
|
||||||
"Sets the list of options on the given row.\n\n"
|
"Sets the list of options on the given row.\n\n"
|
||||||
"@param row Index of the row to set options on."
|
"@param row Index of the row to set options on."
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,18 @@ public:
|
||||||
typedef GuiGameListMenuProfile Profile;
|
typedef GuiGameListMenuProfile Profile;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// \struct OptionEntry
|
||||||
|
/// Display text and ID key for each entry in an option row.
|
||||||
|
struct OptionEntry
|
||||||
|
{
|
||||||
|
StringTableEntry mDisplayText; ///< The text that is displayed for the option
|
||||||
|
StringTableEntry mKeyString; ///< Key value that is associated with this option
|
||||||
|
OptionEntry() : mDisplayText(StringTable->EmptyString()), mKeyString(StringTable->EmptyString()) {}
|
||||||
|
virtual ~OptionEntry() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \struct Row
|
/// \struct Row
|
||||||
/// Internal data representation of a single row in the control.
|
/// Internal data representation of a single row in the control.
|
||||||
struct Row
|
struct Row
|
||||||
|
|
@ -60,7 +72,7 @@ protected:
|
||||||
Mode mMode;
|
Mode mMode;
|
||||||
|
|
||||||
//List options
|
//List options
|
||||||
Vector<StringTableEntry> mOptions; ///< Collection of options available to display
|
Vector<OptionEntry> mOptions; ///< Collection of options available to display
|
||||||
S32 mSelectedOption; ///< Index into mOptions pointing at the selected option
|
S32 mSelectedOption; ///< Index into mOptions pointing at the selected option
|
||||||
bool mWrapOptions; ///< Determines if options should "wrap around" at the ends
|
bool mWrapOptions; ///< Determines if options should "wrap around" at the ends
|
||||||
|
|
||||||
|
|
@ -174,13 +186,43 @@ public:
|
||||||
/// string is returned.
|
/// string is returned.
|
||||||
StringTableEntry getCurrentOption(S32 rowIndex) const;
|
StringTableEntry getCurrentOption(S32 rowIndex) const;
|
||||||
|
|
||||||
|
/// Gets the key string for the currently selected option of the given row
|
||||||
|
///
|
||||||
|
/// \param rowIndex Index of the row to get the option from.
|
||||||
|
/// \return The key (or id) that was assigned to the selected option on the
|
||||||
|
/// given row. If there is no selected option then the empty string is returned.
|
||||||
|
StringTableEntry getCurrentOptionKey(S32 rowIndex) const;
|
||||||
|
|
||||||
|
/// Gets the index into the option list for the currently selected option of the given row.
|
||||||
|
///
|
||||||
|
/// \param rowIndex Index of the row to get the option from.
|
||||||
|
/// \return The index of the selected option on the given row. If there is no
|
||||||
|
/// selected option then -1 is returned.
|
||||||
|
S32 getCurrentOptionIndex(S32 rowIndex) const;
|
||||||
|
|
||||||
/// Attempts to set the given row to the specified selected option. The option
|
/// Attempts to set the given row to the specified selected option. The option
|
||||||
/// will only be set if the option exists in the control.
|
/// will only be set if the option exists in the control.
|
||||||
///
|
///
|
||||||
/// \param rowIndex Index of the row to set an option on.
|
/// \param rowIndex Index of the row to set an option on.
|
||||||
/// \param option The option to be made active.
|
/// \param option The option to be made active.
|
||||||
/// \return True if the row contained the option and was set, false otherwise.
|
/// \return True if the row contained the option and was set, false otherwise.
|
||||||
bool selectOption(S32 rowIndex, StringTableEntry option);
|
bool selectOption(S32 rowIndex, const char* option);
|
||||||
|
|
||||||
|
/// Attempts to set the given row to the option with the specified key. The
|
||||||
|
/// option will only be set if the key exists in the control.
|
||||||
|
///
|
||||||
|
/// \param rowIndex Index of the row to set an option on.
|
||||||
|
/// \param optionKey The key string that was assigned to the option to be made active.
|
||||||
|
/// \return True if the row contained the key and the option and was set, false otherwise.
|
||||||
|
bool selectOptionByKey(S32 rowIndex, const char* optionKey);
|
||||||
|
|
||||||
|
/// Attempts to set the given row to the option at the specified index. The option
|
||||||
|
/// will only be set if the index is valid.
|
||||||
|
///
|
||||||
|
/// \param rowIndex Index of the row to set an option on.
|
||||||
|
/// \param optionIndex The index of the option to be made active.
|
||||||
|
/// \return True if the index was valid and the option and was set, false otherwise.
|
||||||
|
bool selectOptionByIndex(S32 rowIndex, S32 optionIndex);
|
||||||
|
|
||||||
/// Sets the list of options on the given row.
|
/// Sets the list of options on the given row.
|
||||||
///
|
///
|
||||||
|
|
@ -188,6 +230,14 @@ public:
|
||||||
/// \param optionsList A tab separated list of options for the control.
|
/// \param optionsList A tab separated list of options for the control.
|
||||||
void setOptions(S32 rowIndex, const char* optionsList);
|
void setOptions(S32 rowIndex, const char* optionsList);
|
||||||
|
|
||||||
|
/// Adds an option to the list of options on the given row.
|
||||||
|
///
|
||||||
|
/// \param rowIndex Index of the row to set options on.
|
||||||
|
/// \param displayText The text to display for this option.
|
||||||
|
/// \param keyText The id string to associate with this value. If NULL the
|
||||||
|
/// id will be the same as the display text.
|
||||||
|
void addOption(S32 rowIndex, const char* displayText, const char* keyText);
|
||||||
|
|
||||||
/// Activates the current row. The script callback of the current row will
|
/// Activates the current row. The script callback of the current row will
|
||||||
/// be called (if it has one).
|
/// be called (if it has one).
|
||||||
virtual void activateRow();
|
virtual void activateRow();
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,9 @@ void GuiTreeViewCtrl::Item::getTooltipText(U32 bufLen, char *buf)
|
||||||
method += pClassName;
|
method += pClassName;
|
||||||
if(mParentControl->isMethod(method.c_str()))
|
if(mParentControl->isMethod(method.c_str()))
|
||||||
{
|
{
|
||||||
const char* tooltip = Con::executef( mParentControl, method.c_str(), pObject->getIdString() );
|
ConsoleValue cValue = Con::executef( mParentControl, method.c_str(), pObject->getIdString() );
|
||||||
|
const char* tooltip = cValue.getString();
|
||||||
|
|
||||||
dsize_t len = dStrlen(buf);
|
dsize_t len = dStrlen(buf);
|
||||||
S32 newBufLen = bufLen-len;
|
S32 newBufLen = bufLen-len;
|
||||||
if(dStrlen(tooltip) > 0 && newBufLen > 0)
|
if(dStrlen(tooltip) > 0 && newBufLen > 0)
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,9 @@ void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
if (item->mEnabled)
|
if (item->mEnabled)
|
||||||
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : ""));
|
{
|
||||||
|
Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,8 @@ bool PopupMenu::canHandleID(U32 id)
|
||||||
|
|
||||||
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
|
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
|
||||||
{
|
{
|
||||||
return dAtob(Con::executef(this, "onSelectItem", Con::getIntArg(command), text ? text : ""));
|
ConsoleValue cValue = Con::executef(this, "onSelectItem", Con::getIntArg(command), text ? text : "");
|
||||||
|
return cValue.getBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,9 @@ bool WorldEditor::pasteSelection( bool dropSel )
|
||||||
SimGroup *targetGroup = NULL;
|
SimGroup *targetGroup = NULL;
|
||||||
if( isMethod( "getNewObjectGroup" ) )
|
if( isMethod( "getNewObjectGroup" ) )
|
||||||
{
|
{
|
||||||
const char* targetGroupName = Con::executef( this, "getNewObjectGroup" );
|
ConsoleValue cValue = Con::executef( this, "getNewObjectGroup" );
|
||||||
|
const char* targetGroupName = cValue.getString();
|
||||||
|
|
||||||
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
|
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
|
||||||
Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
|
Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
|
||||||
}
|
}
|
||||||
|
|
@ -1993,12 +1995,12 @@ void WorldEditor::on3DMouseMove(const Gui3DMouseEvent & event)
|
||||||
if ( !mHitObject )
|
if ( !mHitObject )
|
||||||
{
|
{
|
||||||
SceneObject *hitObj = NULL;
|
SceneObject *hitObj = NULL;
|
||||||
if ( collide(event, &hitObj) && hitObj->isSelectionEnabled() && !objClassIgnored(hitObj) )
|
if ( collide(event, &hitObj) && !hitObj->isDeleted() && hitObj->isSelectionEnabled() && !objClassIgnored(hitObj) )
|
||||||
{
|
{
|
||||||
mHitObject = hitObj;
|
mHitObject = hitObj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastMouseEvent = event;
|
mLastMouseEvent = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -397,7 +397,8 @@ bool ModuleManager::loadModuleGroup( const char* pModuleGroup )
|
||||||
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
|
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
|
||||||
{
|
{
|
||||||
// Yes, so execute the script file.
|
// Yes, so execute the script file.
|
||||||
const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) );
|
ConsoleValue cValue = Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath());
|
||||||
|
const bool scriptFileExecuted = cValue.getBool();
|
||||||
|
|
||||||
// Did we execute the script file?
|
// Did we execute the script file?
|
||||||
if ( scriptFileExecuted )
|
if ( scriptFileExecuted )
|
||||||
|
|
@ -784,7 +785,8 @@ bool ModuleManager::loadModuleExplicit( const char* pModuleId, const U32 version
|
||||||
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
|
if ( pLoadReadyModuleDefinition->getModuleScriptFilePath() != StringTable->EmptyString() )
|
||||||
{
|
{
|
||||||
// Yes, so execute the script file.
|
// Yes, so execute the script file.
|
||||||
const bool scriptFileExecuted = dAtob( Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath() ) );
|
ConsoleValue cValue = Con::executef("exec", pLoadReadyModuleDefinition->getModuleScriptFilePath());
|
||||||
|
const bool scriptFileExecuted = cValue.getBool();
|
||||||
|
|
||||||
// Did we execute the script file?
|
// Did we execute the script file?
|
||||||
if ( !scriptFileExecuted )
|
if ( !scriptFileExecuted )
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,10 @@ StdConsole *stdConsole = NULL;
|
||||||
DefineEngineFunction(enableWinConsole, void, (bool _enable),, "enableWinConsole(bool);")
|
DefineEngineFunction(enableWinConsole, void, (bool _enable),, "enableWinConsole(bool);")
|
||||||
{
|
{
|
||||||
if (stdConsole)
|
if (stdConsole)
|
||||||
stdConsole->enable(_enable);
|
{
|
||||||
|
stdConsole->enable(_enable);
|
||||||
|
stdConsole->enableInput(_enable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdConsole::create()
|
void StdConsole::create()
|
||||||
|
|
@ -141,6 +144,9 @@ StdConsole::StdConsole()
|
||||||
stdIn = dup(0);
|
stdIn = dup(0);
|
||||||
stdErr = dup(2);
|
stdErr = dup(2);
|
||||||
|
|
||||||
|
// Ensure in buffer is null terminated after allocation
|
||||||
|
inbuf[0] = 0x00;
|
||||||
|
|
||||||
iCmdIndex = 0;
|
iCmdIndex = 0;
|
||||||
stdConsoleEnabled = false;
|
stdConsoleEnabled = false;
|
||||||
stdConsoleInputEnabled = false;
|
stdConsoleInputEnabled = false;
|
||||||
|
|
@ -195,11 +201,14 @@ void StdConsole::processConsoleLine(const char *consoleLine)
|
||||||
{
|
{
|
||||||
if(stdConsoleEnabled)
|
if(stdConsoleEnabled)
|
||||||
{
|
{
|
||||||
inbuf[inpos] = 0;
|
|
||||||
if(lineOutput)
|
if(lineOutput)
|
||||||
printf("%s\n", consoleLine);
|
printf("%s\n", consoleLine);
|
||||||
else
|
else
|
||||||
printf("%c%s\n%s%s", '\r', consoleLine, Con::getVariable("Con::Prompt"), inbuf);
|
{
|
||||||
|
// Clear current line before outputting the console line. This prevents prompt text from overflowing onto normal output.
|
||||||
|
printf("%c[2K", 27);
|
||||||
|
printf("%c%s\n%s%s", '\r', consoleLine, Con::getVariable("Con::Prompt"), inbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -323,6 +332,7 @@ void StdConsole::process()
|
||||||
|
|
||||||
printf("%s", Con::getVariable("Con::Prompt"));
|
printf("%s", Con::getVariable("Con::Prompt"));
|
||||||
inpos = outpos = 0;
|
inpos = outpos = 0;
|
||||||
|
inbuf[0] = 0x00; // Ensure inbuf is NULL terminated after sending out command
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
// JMQTODO: are these magic numbers keyboard map specific?
|
// JMQTODO: are these magic numbers keyboard map specific?
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageReceived, bool, ( const char* qu
|
||||||
bool ScriptMsgListener::onMessageReceived(StringTableEntry queue, const char* event, const char* data)
|
bool ScriptMsgListener::onMessageReceived(StringTableEntry queue, const char* event, const char* data)
|
||||||
{
|
{
|
||||||
return onMessageReceived_callback(queue, event, data);
|
return onMessageReceived_callback(queue, event, data);
|
||||||
//return dAtob(Con::executef(this, "onMessageReceived", queue, event, data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const char* queue, Message *msg ), ( queue, msg ),
|
IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const char* queue, Message *msg ), ( queue, msg ),
|
||||||
|
|
@ -135,7 +134,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onMessageObjectReceived, bool, ( const ch
|
||||||
bool ScriptMsgListener::onMessageObjectReceived(StringTableEntry queue, Message *msg)
|
bool ScriptMsgListener::onMessageObjectReceived(StringTableEntry queue, Message *msg)
|
||||||
{
|
{
|
||||||
return onMessageObjectReceived_callback(queue, msg);
|
return onMessageObjectReceived_callback(queue, msg);
|
||||||
//return dAtob(Con::executef(this, "onMessageObjectReceived", queue, Con::getIntArg(msg->getId())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -150,7 +148,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onAddToQueue, void, ( const char* queue),
|
||||||
|
|
||||||
void ScriptMsgListener::onAddToQueue(StringTableEntry queue)
|
void ScriptMsgListener::onAddToQueue(StringTableEntry queue)
|
||||||
{
|
{
|
||||||
//Con::executef(this, "onAddToQueue", queue);
|
|
||||||
onAddToQueue_callback(queue);
|
onAddToQueue_callback(queue);
|
||||||
IMLParent::onAddToQueue(queue);
|
IMLParent::onAddToQueue(queue);
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +173,6 @@ IMPLEMENT_CALLBACK( ScriptMsgListener, onRemoveFromQueue, void, ( const char* qu
|
||||||
|
|
||||||
void ScriptMsgListener::onRemoveFromQueue(StringTableEntry queue)
|
void ScriptMsgListener::onRemoveFromQueue(StringTableEntry queue)
|
||||||
{
|
{
|
||||||
//Con::executef(this, "onRemoveFromQueue", queue);
|
|
||||||
onRemoveFromQueue_callback(queue);
|
onRemoveFromQueue_callback(queue);
|
||||||
IMLParent::onRemoveFromQueue(queue);
|
IMLParent::onRemoveFromQueue(queue);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,14 @@ ModuleDatabase.LoadExplicit( "CoreModule" );
|
||||||
// Display a splash window immediately to improve app responsiveness before
|
// Display a splash window immediately to improve app responsiveness before
|
||||||
// engine is initialized and main window created.
|
// engine is initialized and main window created.
|
||||||
if ($Server::Dedicated == false)
|
if ($Server::Dedicated == false)
|
||||||
displaySplashWindow($Core::splashWindowImage);
|
{
|
||||||
|
if ($platform $= "windows")
|
||||||
|
displaySplashWindow($Core::splashWindowImage);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
$Video::forceDisplayAdapter = -1;
|
$Video::forceDisplayAdapter = -1;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Load any gameplay modules
|
// Load any gameplay modules
|
||||||
|
|
@ -45,7 +50,7 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Server::Dedicated == false)
|
if ( ($Server::Dedicated == false) && ($platform $= "windows") )
|
||||||
closeSplashWindow();
|
closeSplashWindow();
|
||||||
|
|
||||||
echo("Engine initialized...");
|
echo("Engine initialized...");
|
||||||
|
|
@ -1097,9 +1097,6 @@ function MaterialEditorGui::updateActiveMaterial(%this, %propertyField, %value,
|
||||||
{
|
{
|
||||||
MaterialEditorGui.setMaterialDirty();
|
MaterialEditorGui.setMaterialDirty();
|
||||||
|
|
||||||
if(%value $= "")
|
|
||||||
%value = "\"\"";
|
|
||||||
|
|
||||||
// Here is where we handle undo actions with slider controls. We want to be able to
|
// Here is where we handle undo actions with slider controls. We want to be able to
|
||||||
// undo every onMouseUp; so we overrite the same undo action when necessary in order
|
// undo every onMouseUp; so we overrite the same undo action when necessary in order
|
||||||
// to achieve this desired effect.
|
// to achieve this desired effect.
|
||||||
|
|
@ -1130,7 +1127,7 @@ function MaterialEditorGui::updateActiveMaterial(%this, %propertyField, %value,
|
||||||
|
|
||||||
if (MaterialEditorGui.livePreview == true)
|
if (MaterialEditorGui.livePreview == true)
|
||||||
{
|
{
|
||||||
MaterialEditorGui.setFieldValue(%propertyField, %value);
|
MaterialEditorGui.currentMaterial.setFieldValue(%propertyField, %value);
|
||||||
MaterialEditorGui.currentMaterial.flush();
|
MaterialEditorGui.currentMaterial.flush();
|
||||||
MaterialEditorGui.currentMaterial.reload();
|
MaterialEditorGui.currentMaterial.reload();
|
||||||
}
|
}
|
||||||
|
|
@ -1263,8 +1260,8 @@ function MaterialEditorGui::doUpdateTextureMap( %this, %assetId )
|
||||||
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
|
%bitmap = strreplace(%bitmap,"tools/materialEditor/scripts/","");
|
||||||
%bitmapCtrl.setBitmap(%bitmap);
|
%bitmapCtrl.setBitmap(%bitmap);
|
||||||
%textCtrl.setText(%assetId);
|
%textCtrl.setText(%assetId);
|
||||||
MaterialEditorGui.updateActiveMaterial(%type @ "Map[" @ %layer @ "]","\"\"");
|
MaterialEditorGui.updateActiveMaterial(%type @ "Map[" @ %layer @ "]","");
|
||||||
MaterialEditorGui.updateActiveMaterial(%type @ "MapAsset[" @ %layer @ "]","\"" @ %assetId @ "\"");
|
MaterialEditorGui.updateActiveMaterial(%type @ "MapAsset[" @ %layer @ "]", %assetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1276,7 +1273,7 @@ function MaterialEditorGui::updateDetailScale(%this,%newScale)
|
||||||
{
|
{
|
||||||
%layer = MaterialEditorGui.currentLayer;
|
%layer = MaterialEditorGui.currentLayer;
|
||||||
|
|
||||||
%detailScale = "\"" @ %newScale SPC %newScale @ "\"";
|
%detailScale = %newScale SPC %newScale;
|
||||||
MaterialEditorGui.updateActiveMaterial("detailScale[" @ %layer @ "]", %detailScale);
|
MaterialEditorGui.updateActiveMaterial("detailScale[" @ %layer @ "]", %detailScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1284,7 +1281,7 @@ function MaterialEditorGui::updateDetailNormalStrength(%this,%newStrength)
|
||||||
{
|
{
|
||||||
%layer = MaterialEditorGui.currentLayer;
|
%layer = MaterialEditorGui.currentLayer;
|
||||||
|
|
||||||
%detailStrength = "\"" @ %newStrength @ "\"";
|
%detailStrength = %newStrength;
|
||||||
MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength);
|
MaterialEditorGui.updateActiveMaterial("detailNormalMapStrength[" @ %layer @ "]", %detailStrength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1295,7 +1292,7 @@ function MaterialEditorGui::updateRotationOffset(%this, %isSlider, %onMouseUp)
|
||||||
%Y = MaterialEditorPropertiesWindow-->RotationTextEditV.getText();
|
%Y = MaterialEditorPropertiesWindow-->RotationTextEditV.getText();
|
||||||
MaterialEditorPropertiesWindow-->RotationCrosshair.setPosition(45*mAbs(%X)-2, 45*mAbs(%Y)-2);
|
MaterialEditorPropertiesWindow-->RotationCrosshair.setPosition(45*mAbs(%X)-2, 45*mAbs(%Y)-2);
|
||||||
|
|
||||||
MaterialEditorGui.updateActiveMaterial("rotPivotOffset[" @ %layer @ "]","\"" @ %X SPC %Y @ "\"",%isSlider,%onMouseUp);
|
MaterialEditorGui.updateActiveMaterial("rotPivotOffset[" @ %layer @ "]", %X SPC %Y,%isSlider,%onMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
function MaterialEditorGui::updateRotationSpeed(%this, %isSlider, %onMouseUp)
|
function MaterialEditorGui::updateRotationSpeed(%this, %isSlider, %onMouseUp)
|
||||||
|
|
@ -1457,7 +1454,7 @@ function MaterialEditorGui::syncGuiColor(%this, %guiCtrl, %propname, %color)
|
||||||
%a = getWord(%color,3);
|
%a = getWord(%color,3);
|
||||||
|
|
||||||
%colorSwatch = (%r SPC %g SPC %b SPC %a);
|
%colorSwatch = (%r SPC %g SPC %b SPC %a);
|
||||||
%color = "\"" @ %r SPC %g SPC %b SPC %a @ "\"";
|
%color = %r SPC %g SPC %b SPC %a;
|
||||||
|
|
||||||
%guiCtrl.color = %colorSwatch;
|
%guiCtrl.color = %colorSwatch;
|
||||||
MaterialEditorGui.updateActiveMaterial(%propName, %color);
|
MaterialEditorGui.updateActiveMaterial(%propName, %color);
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ function EWCreatorWindow::createObject( %this, %cmd )
|
||||||
%this.setNewObjectGroup( getScene(0) );
|
%this.setNewObjectGroup( getScene(0) );
|
||||||
|
|
||||||
pushInstantGroup();
|
pushInstantGroup();
|
||||||
%objId = eval(%cmd);
|
%objId = eval("return " @ %cmd);
|
||||||
popInstantGroup();
|
popInstantGroup();
|
||||||
|
|
||||||
if( isObject( %objId ) )
|
if( isObject( %objId ) )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue