Merge branch 'development' into ConvexProxies

This commit is contained in:
Areloch 2018-12-09 15:34:12 -06:00 committed by GitHub
commit bb30de04f7
2803 changed files with 195958 additions and 224299 deletions

View file

@ -432,8 +432,6 @@ void GuiTSCtrl::_internalRender(RectI guiViewport, RectI renderViewport, Frustum
if (mRenderStyle == RenderStyleStereoSideBySide && debugDraw->willDraw())
{
// For SBS we need to render over each viewport
Frustum frustum;
GFX->setViewport(mLastCameraQuery.stereoViewports[0]);
MathUtils::makeFovPortFrustum(&frustum, mLastCameraQuery.ortho, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane, mLastCameraQuery.fovPort[0]);
GFX->setFrustum(frustum);
@ -543,7 +541,6 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
GFX->setStereoTargets(mLastCameraQuery.stereoTargets);
MatrixF myTransforms[2];
Frustum frustum;
if (smUseLatestDisplayTransform)
{

View file

@ -307,22 +307,22 @@ void GuiBitmapButtonCtrl::setBitmap( const String& name )
if( mUseModifiers )
baseName += modifiers[ i ];
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
if( mUseStates )
{
if( !mTextures[ i ].mTextureNormal )
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXDefaultGUIProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureHilight )
mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureDepressed )
mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXDefaultGUIProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
if( !mTextures[ i ].mTextureInactive )
mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
}

View file

@ -92,17 +92,17 @@ void GuiToolboxButtonCtrl::onSleep()
//-------------------------------------
DefineConsoleMethod( GuiToolboxButtonCtrl, setNormalBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is active")
DefineEngineMethod( GuiToolboxButtonCtrl, setNormalBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is active")
{
object->setNormalBitmap(name);
}
DefineConsoleMethod( GuiToolboxButtonCtrl, setLoweredBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
DefineEngineMethod( GuiToolboxButtonCtrl, setLoweredBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
{
object->setLoweredBitmap(name);
}
DefineConsoleMethod( GuiToolboxButtonCtrl, setHoverBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
DefineEngineMethod( GuiToolboxButtonCtrl, setHoverBitmap, void, ( const char * name ), , "( filepath name ) sets the bitmap that shows when the button is disabled")
{
object->setHoverBitmap(name);
}

View file

@ -152,14 +152,24 @@ ConsoleDocClass( GuiDragAndDropControl,
"@ingroup GuiUtil"
);
IMPLEMENT_CALLBACK(GuiDragAndDropControl, onControlDragCancelled, void, (), (),
"Called when the we cancel out of the drag and drop action.\n"
"@see GuiDragAndDropControl::onControlDragCancelled");
//-----------------------------------------------------------------------------
GuiDragAndDropControl::GuiDragAndDropControl() : mDeleteOnMouseUp(true), mUseWholeCanvas(false)
{
}
void GuiDragAndDropControl::initPersistFields()
{
addField( "deleteOnMouseUp", TypeBool, Offset( mDeleteOnMouseUp, GuiDragAndDropControl ),
"If true, the control deletes itself when the left mouse button is released.\n\n"
"If at this point, the drag&drop control still contains its payload, it will be deleted along with the control." );
addField("useWholeCanvas", TypeBool, Offset(mUseWholeCanvas, GuiDragAndDropControl),
"If true, the control can be tested against ANY control active on the canvas instead of just the direct parent.\n\n");
Parent::initPersistFields();
}
@ -226,8 +236,10 @@ void GuiDragAndDropControl::onMouseUp(const GuiEvent& event)
mouseUnlock();
GuiControl* target = findDragTarget( event.mousePoint, "onControlDropped" );
if( target )
target->onControlDropped_callback( dynamic_cast< GuiControl* >( at( 0 ) ), getDropPoint() );
if (target)
target->onControlDropped_callback(dynamic_cast<GuiControl*>(at(0)), getDropPoint());
else
onControlDragCancelled_callback();
if( mDeleteOnMouseUp )
deleteObject();
@ -239,6 +251,13 @@ GuiControl* GuiDragAndDropControl::findDragTarget( Point2I mousePoint, const cha
{
// If there are any children and we have a parent.
GuiControl* parent = getParent();
if (mUseWholeCanvas)
{
parent->setVisible(false);
parent = getRoot();
}
if (size() && parent)
{
mVisible = false;
@ -252,6 +271,10 @@ GuiControl* GuiDragAndDropControl::findDragTarget( Point2I mousePoint, const cha
dropControl = dropControl->getParent();
}
}
if(mUseWholeCanvas)
parent->setVisible(true);
return NULL;
}

View file

@ -53,6 +53,8 @@ class GuiDragAndDropControl : public GuiControl
/// If true, the control deletes itself when the left mouse button is released.
bool mDeleteOnMouseUp;
bool mUseWholeCanvas;
/// Controls may want to react when they are dragged over, entered or exited.
SimObjectPtr<GuiControl> mLastTarget;
@ -65,7 +67,7 @@ class GuiDragAndDropControl : public GuiControl
public:
GuiDragAndDropControl() {}
GuiDragAndDropControl();
void startDragging(Point2I offset = Point2I(0, 0));
@ -81,6 +83,8 @@ class GuiDragAndDropControl : public GuiControl
DECLARE_DESCRIPTION( "A special control that implements drag&drop behavior.\n"
"The control will notify other controls as it moves across the canvas.\n"
"Content can be attached through dynamic fields or child objects." );
DECLARE_CALLBACK(void, onControlDragCancelled, ());
};
#endif

View file

@ -218,9 +218,9 @@ bool GuiFormCtrl::resize(const Point2I &newPosition, const Point2I &newExtent)
S32 strlen = dStrlen((const char*)mCaption);
for(S32 i=strlen; i>=0; --i)
{
dStrcpy(buf, "");
dStrncat(buf, (const char*)mCaption, i);
dStrcat(buf, "...");
dStrcpy(buf, "", i);
dStrcat(buf, (const char*)mCaption, i);
dStrcat(buf, "...", i);
textWidth = mProfile->mFont->getStrWidth(buf);

View file

@ -357,7 +357,7 @@ void GuiWindowCtrl::moveToCollapseGroup(GuiWindowCtrl* hitWindow, bool orientati
}
else
{
S32 groupVec = hitWindow->mCollapseGroup;
groupVec = hitWindow->mCollapseGroup;
if(orientation == 0)
parent->mCollapseGroupVec[groupVec].push_front(this);

View file

@ -167,8 +167,9 @@ bool guiAnimBitmapCtrl::ptSetFrameRanges(void *object, const char *index, const
pData->mCurFrameIndex = pData->mNumFrames;
return true;
}
char* tokCopy = new char[dStrlen(data) + 1];
dStrcpy(tokCopy, data);
dsize_t tokLen = dStrlen(data) + 1;
char* tokCopy = new char[tokLen];
dStrcpy(tokCopy, data, tokLen);
char* currTok = dStrtok(tokCopy, " \t");
while (currTok != NULL)
@ -291,4 +292,4 @@ void guiAnimBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
}
renderChildControls(offset, updateRect);
}
}

View file

@ -261,7 +261,7 @@ static ConsoleDocFragment _sGuiBitmapCtrlSetBitmap2(
//"Set the bitmap displayed in the control. Note that it is limited in size, to 256x256."
DefineConsoleMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bool resize), ( false),
DefineEngineMethod( GuiBitmapCtrl, setBitmap, void, ( const char * fileRoot, bool resize), ( false),
"( String filename | String filename, bool resize ) Assign an image to the control.\n\n"
"@hide" )
{

View file

@ -658,17 +658,17 @@ void GuiColorPickerCtrl::setScriptValue(const char *value)
setValue(newValue);
}
DefineConsoleMethod(GuiColorPickerCtrl, getSelectorPos, Point2I, (), , "Gets the current position of the selector")
DefineEngineMethod(GuiColorPickerCtrl, getSelectorPos, Point2I, (), , "Gets the current position of the selector")
{
return object->getSelectorPos();
}
DefineConsoleMethod(GuiColorPickerCtrl, setSelectorPos, void, (Point2I newPos), , "Sets the current position of the selector")
DefineEngineMethod(GuiColorPickerCtrl, setSelectorPos, void, (Point2I newPos), , "Sets the current position of the selector")
{
object->setSelectorPos(newPos);
}
DefineConsoleMethod(GuiColorPickerCtrl, updateColor, void, (), , "Forces update of pick color")
DefineEngineMethod(GuiColorPickerCtrl, updateColor, void, (), , "Forces update of pick color")
{
object->updateColor();
}

View file

@ -50,6 +50,12 @@ IMPLEMENT_CALLBACK( GuiConsole, onMessageSelected, void, ( ConsoleLogEntry::Leve
"@param level Diagnostic level of the message.\n"
"@param message Message text.\n" );
IMPLEMENT_CALLBACK(GuiConsole, onNewMessage, void, (U32 errorCount, U32 warnCount, U32 normalCount), (errorCount, warnCount, normalCount),
"Called when a new message is logged.\n\n"
"@param errorCount The number of error messages logged.\n"
"@param warnCount The number of warning messages logged.\n"
"@param normalCount The number of normal messages logged.\n");
//-----------------------------------------------------------------------------
@ -58,6 +64,11 @@ GuiConsole::GuiConsole()
setExtent(64, 64);
mCellSize.set(1, 1);
mSize.set(1, 0);
mDisplayErrors = true;
mDisplayWarnings = true;
mDisplayNormalMessages = true;
mFiltersDirty = true;
}
//-----------------------------------------------------------------------------
@ -81,56 +92,98 @@ S32 GuiConsole::getMaxWidth(S32 startIndex, S32 endIndex)
U32 size;
ConsoleLogEntry *log;
Con::getLockLog(log, size);
if(startIndex < 0 || (U32)endIndex >= size || startIndex > endIndex)
if (startIndex < 0 || (U32)endIndex >= mFilteredLog.size() || startIndex > endIndex)
return 0;
S32 result = 0;
for(S32 i = startIndex; i <= endIndex; i++)
result = getMax(result, (S32)(mFont->getStrWidth((const UTF8 *)log[i].mString)));
Con::unlockLog();
result = getMax(result, (S32)(mFont->getStrWidth((const UTF8 *)mFilteredLog[i].mString)));
return(result + 6);
}
void GuiConsole::refreshLogText()
{
U32 size;
ConsoleLogEntry *log;
Con::getLockLog(log, size);
if (mFilteredLog.size() != size || mFiltersDirty)
{
mFilteredLog.clear();
U32 errorCount = 0;
U32 warnCount = 0;
U32 normalCount = 0;
//Filter the log if needed
for (U32 i = 0; i < size; ++i)
{
ConsoleLogEntry &entry = log[i];
if (entry.mLevel == ConsoleLogEntry::Error)
{
errorCount++;
if (mDisplayErrors)
{
mFilteredLog.push_back(entry);
}
}
else if (entry.mLevel == ConsoleLogEntry::Warning)
{
warnCount++;
if (mDisplayWarnings)
{
mFilteredLog.push_back(entry);
}
}
else if (entry.mLevel == ConsoleLogEntry::Normal)
{
normalCount++;
if (mDisplayNormalMessages)
{
mFilteredLog.push_back(entry);
}
}
}
onNewMessage_callback(errorCount, warnCount, normalCount);
}
Con::unlockLog();
}
//-----------------------------------------------------------------------------
void GuiConsole::onPreRender()
{
//see if the size has changed
U32 prevSize = getHeight() / mCellSize.y;
U32 size;
ConsoleLogEntry *log;
Con::getLockLog(log, size);
Con::unlockLog(); // we unlock immediately because we only use size here, not log.
refreshLogText();
if(size != prevSize)
{
//first, find out if the console was scrolled up
bool scrolled = false;
GuiScrollCtrl *parent = dynamic_cast<GuiScrollCtrl*>(getParent());
//first, find out if the console was scrolled up
bool scrolled = false;
GuiScrollCtrl *parent = dynamic_cast<GuiScrollCtrl*>(getParent());
if(parent)
scrolled = parent->isScrolledToBottom();
if(parent)
scrolled = parent->isScrolledToBottom();
//find the max cell width for the new entries
S32 newMax = getMaxWidth(prevSize, size - 1);
if(newMax > mCellSize.x)
mCellSize.set(newMax, mFont->getHeight());
//find the max cell width for the new entries
S32 newMax = getMaxWidth(prevSize, mFilteredLog.size() - 1);
if(newMax > mCellSize.x)
mCellSize.set(newMax, mFont->getHeight());
//set the array size
mSize.set(1, size);
//set the array size
mSize.set(1, mFilteredLog.size());
//resize the control
setExtent( Point2I(mCellSize.x, mCellSize.y * size));
//resize the control
setExtent(Point2I(mCellSize.x, mCellSize.y * mFilteredLog.size()));
//if the console was not scrolled, make the last entry visible
if (scrolled)
scrollCellVisible(Point2I(0,mSize.y - 1));
}
//if the console was not scrolled, make the last entry visible
if (scrolled)
scrollCellVisible(Point2I(0,mSize.y - 1));
}
//-----------------------------------------------------------------------------
@ -139,10 +192,8 @@ void GuiConsole::onRenderCell(Point2I offset, Point2I cell, bool /*selected*/, b
{
U32 size;
ConsoleLogEntry *log;
Con::getLockLog(log, size);
ConsoleLogEntry &entry = log[cell.y];
ConsoleLogEntry &entry = mFilteredLog[cell.y];
switch (entry.mLevel)
{
case ConsoleLogEntry::Normal: GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColor); break;
@ -151,8 +202,6 @@ void GuiConsole::onRenderCell(Point2I offset, Point2I cell, bool /*selected*/, b
default: AssertFatal(false, "GuiConsole::onRenderCell - Unrecognized ConsoleLogEntry type, update this.");
}
GFX->getDrawUtil()->drawText(mFont, Point2I(offset.x + 3, offset.y), entry.mString, mProfile->mFontColors);
Con::unlockLog();
}
//-----------------------------------------------------------------------------
@ -164,10 +213,81 @@ void GuiConsole::onCellSelected( Point2I cell )
U32 size;
ConsoleLogEntry* log;
Con::getLockLog(log, size);
ConsoleLogEntry& entry = log[ cell.y ];
ConsoleLogEntry& entry = mFilteredLog[cell.y];
onMessageSelected_callback( entry.mLevel, entry.mString );
Con::unlockLog();
}
void GuiConsole::setDisplayFilters(bool errors, bool warns, bool normal)
{
mDisplayErrors = errors;
mDisplayWarnings = warns;
mDisplayNormalMessages = normal;
mFiltersDirty = true;
refreshLogText();
//find the max cell width for the new entries
S32 newMax = getMaxWidth(0, mFilteredLog.size() - 1);
mCellSize.set(newMax, mFont->getHeight());
//set the array size
mSize.set(1, mFilteredLog.size());
//resize the control
setExtent(Point2I(mCellSize.x, mCellSize.y * mFilteredLog.size()));
scrollCellVisible(Point2I(0, mSize.y - 1));
mFiltersDirty = false;
}
DefineEngineMethod(GuiConsole, setDisplayFilters, void, (bool errors, bool warns, bool normal), (true, true, true),
"Sets the current display filters for the console gui. Allows you to indicate if it should display errors, warns and/or normal messages.\n\n"
"@param errors If true, the console gui will display any error messages that were emitted.\n\n"
"@param warns If true, the console gui will display any warning messages that were emitted.\n\n"
"@param normal If true, the console gui will display any regular messages that were emitted.\n\n")
{
object->setDisplayFilters(errors, warns, normal);
}
DefineEngineMethod(GuiConsole, getErrorFilter, bool, (), ,
"Returns if the error filter is on or not.")
{
return object->getErrorFilter();
}
DefineEngineMethod(GuiConsole, getWarnFilter, bool, (), ,
"Returns if the warning filter is on or not.")
{
return object->getWarnFilter();
}
DefineEngineMethod(GuiConsole, getNormalFilter, bool, (), ,
"Returns if the normal message filter is on or not.")
{
return object->getNormalFilter();
}
DefineEngineMethod(GuiConsole, toggleErrorFilter, void, (), ,
"Toggles the error filter.")
{
object->toggleErrorFilter();
}
DefineEngineMethod(GuiConsole, toggleWarnFilter, void, (), ,
"Toggles the warning filter.")
{
object->toggleWarnFilter();
}
DefineEngineMethod(GuiConsole, toggleNormalFilter, void, (), ,
"Toggles the normal messages filter.")
{
object->toggleNormalFilter();
}
DefineEngineMethod(GuiConsole, refresh, void, (), ,
"Refreshes the displayed messages.")
{
object->refresh();
}

View file

@ -39,14 +39,22 @@ class GuiConsole : public GuiArrayCtrl
Resource<GFont> mFont;
bool mDisplayErrors;
bool mDisplayWarnings;
bool mDisplayNormalMessages;
bool mFiltersDirty;
S32 getMaxWidth(S32 startIndex, S32 endIndex);
Vector<ConsoleLogEntry> mFilteredLog;
protected:
/// @name Callbacks
/// @{
DECLARE_CALLBACK( void, onMessageSelected, ( ConsoleLogEntry::Level level, const char* message ) );
DECLARE_CALLBACK(void, onNewMessage, (U32 errorCount, U32 warnCount, U32 normalCount));
/// @}
@ -63,6 +71,30 @@ class GuiConsole : public GuiArrayCtrl
virtual bool onWake();
virtual void onPreRender();
virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
void setDisplayFilters(bool errors, bool warns, bool normal);
bool getErrorFilter() { return mDisplayErrors; }
bool getWarnFilter() { return mDisplayWarnings; }
bool getNormalFilter() { return mDisplayNormalMessages; }
void toggleErrorFilter()
{
setDisplayFilters(!mDisplayErrors, mDisplayWarnings, mDisplayNormalMessages);
}
void toggleWarnFilter()
{
setDisplayFilters(mDisplayErrors, !mDisplayWarnings, mDisplayNormalMessages);
}
void toggleNormalFilter()
{
setDisplayFilters(mDisplayErrors, mDisplayWarnings, !mDisplayNormalMessages);
}
void refresh()
{
setDisplayFilters(mDisplayErrors, mDisplayWarnings, mDisplayNormalMessages);
}
void refreshLogText();
};
#endif

View file

@ -142,7 +142,6 @@ void GuiDecoyCtrl::onMouseMove(const GuiEvent &event)
if(mIsDecoy == true)
{
mVisible = false;
GuiControl *parent = getParent();
GuiControl *tempControl = parent->findHitControl(localPoint);
//the decoy control has the responsibility of keeping track of the decoyed controls status

View file

@ -189,13 +189,13 @@ DefineEngineMethod( GuiDirectoryFileListCtrl, getSelectedFiles, const char*, (),
// Fetch the remaining entries
for( S32 i = 1; i < ItemVector.size(); i++ )
{
StringTableEntry itemText = object->getItemText( ItemVector[i] );
itemText = object->getItemText( ItemVector[i] );
if( !itemText )
continue;
dMemset( itemBuffer, 0, itemBufSize );
dSprintf( itemBuffer, itemBufSize, " %s", itemText );
dStrcat( returnBuffer, itemBuffer );
dStrcat( returnBuffer, itemBuffer, itemBufSize );
}
return returnBuffer;

View file

@ -276,7 +276,7 @@ void GuiFileTreeCtrl::recurseInsert( Item* parent, StringTableEntry path )
char szPathCopy [ 1024 ];
dMemset( szPathCopy, 0, 1024 );
dStrcpy( szPathCopy, path );
dStrcpy( szPathCopy, path, 1024 );
// Jump over the first character if it's a root /
char *curPos = szPathCopy;
@ -379,18 +379,18 @@ void GuiFileTreeCtrl::recurseInsert( Item* parent, StringTableEntry path )
}
DefineConsoleMethod( GuiFileTreeCtrl, getSelectedPath, const char*, (), , "getSelectedPath() - returns the currently selected path in the tree")
DefineEngineMethod( GuiFileTreeCtrl, getSelectedPath, const char*, (), , "getSelectedPath() - returns the currently selected path in the tree")
{
const String& path = object->getSelectedPath();
return Con::getStringArg( path );
}
DefineConsoleMethod( GuiFileTreeCtrl, setSelectedPath, bool, (const char * path), , "setSelectedPath(path) - expands the tree to the specified path")
DefineEngineMethod( GuiFileTreeCtrl, setSelectedPath, bool, (const char * path), , "setSelectedPath(path) - expands the tree to the specified path")
{
return object->setSelectedPath( path );
}
DefineConsoleMethod( GuiFileTreeCtrl, reload, void, (), , "() - Reread the directory tree hierarchy." )
DefineEngineMethod( GuiFileTreeCtrl, reload, void, (), , "() - Reread the directory tree hierarchy." )
{
object->updateTree();
}

View file

@ -601,7 +601,7 @@ void GuiGradientCtrl::sortColorRange()
dQsort( mAlphaRange.address(), mAlphaRange.size(), sizeof(ColorRange), _numIncreasing);
}
DefineConsoleMethod(GuiGradientCtrl, getColorCount, S32, (), , "Get color count")
DefineEngineMethod(GuiGradientCtrl, getColorCount, S32, (), , "Get color count")
{
if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange )
return object->mColorRange.size();
@ -611,7 +611,7 @@ DefineConsoleMethod(GuiGradientCtrl, getColorCount, S32, (), , "Get color count"
return 0;
}
DefineConsoleMethod(GuiGradientCtrl, getColor, LinearColorF, (S32 idx), , "Get color value")
DefineEngineMethod(GuiGradientCtrl, getColor, LinearColorF, (S32 idx), , "Get color value")
{
if( object->getDisplayMode() == GuiGradientCtrl::pHorizColorRange )

View file

@ -458,7 +458,7 @@ DefineEngineMethod( GuiListBoxCtrl, getSelectedItems, const char*, (),,
{
UTF8 retFormat[12];
dSprintf( retFormat, 12, "%d ", (*i) );
dStrcat( retBuffer, retFormat );
dStrcat( retBuffer, retFormat, 12 );
}
return retBuffer;

View file

@ -167,7 +167,7 @@ void GuiMaterialCtrl::onRender( Point2I offset, const RectI &updateRect )
GFX->setTexture( 0, NULL );
}
DefineConsoleMethod( GuiMaterialCtrl, setMaterial, bool, ( const char * materialName ), , "( string materialName )"
DefineEngineMethod( GuiMaterialCtrl, setMaterial, bool, ( const char * materialName ), , "( string materialName )"
"Set the material to be displayed in the control." )
{
return object->setMaterial( materialName );

View file

@ -190,9 +190,9 @@ void GuiPopupTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selec
if(drawbox)
{
Point2I coloredboxsize(15,10);
RectI r(offset.x + mProfile->mTextOffset.x, offset.y+2, coloredboxsize.x, coloredboxsize.y);
GFX->getDrawUtil()->drawRectFill( r, boxColor);
GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));
RectI boxBounds(offset.x + mProfile->mTextOffset.x, offset.y+2, coloredboxsize.x, coloredboxsize.y);
GFX->getDrawUtil()->drawRectFill(boxBounds, boxColor);
GFX->getDrawUtil()->drawRect(boxBounds, ColorI(0,0,0));
textXOffset += coloredboxsize.x + mProfile->mTextOffset.x;
}
@ -300,82 +300,82 @@ void GuiPopUpMenuCtrl::initPersistFields(void)
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
DefineEngineMethod( GuiPopUpMenuCtrl, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
{
object->addEntry(name, idNum, scheme);
}
DefineConsoleMethod( GuiPopUpMenuCtrl, addScheme, void, (U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL), ,
DefineEngineMethod( GuiPopUpMenuCtrl, addScheme, void, (U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL), ,
"(int id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL)")
{
object->addScheme( id, fontColor, fontColorHL, fontColorSEL );
}
DefineConsoleMethod( GuiPopUpMenuCtrl, getText, const char*, (), , "")
DefineEngineMethod( GuiPopUpMenuCtrl, getText, const char*, (), , "")
{
return object->getText();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, clear, void, (), , "Clear the popup list.")
DefineEngineMethod( GuiPopUpMenuCtrl, clear, void, (), , "Clear the popup list.")
{
object->clear();
}
//FIXME: clashes with SimSet.sort
DefineConsoleMethod(GuiPopUpMenuCtrl, sort, void, (), , "Sort the list alphabetically.")
DefineEngineMethod(GuiPopUpMenuCtrl, sort, void, (), , "Sort the list alphabetically.")
{
object->sort();
}
// Added to sort the entries by ID
DefineConsoleMethod(GuiPopUpMenuCtrl, sortID, void, (), , "Sort the list by ID.")
DefineEngineMethod(GuiPopUpMenuCtrl, sortID, void, (), , "Sort the list by ID.")
{
object->sortID();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, forceOnAction, void, (), , "")
DefineEngineMethod( GuiPopUpMenuCtrl, forceOnAction, void, (), , "")
{
object->onAction();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, forceClose, void, (), , "")
DefineEngineMethod( GuiPopUpMenuCtrl, forceClose, void, (), , "")
{
object->closePopUp();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, getSelected, S32, (), , "Gets the selected index")
DefineEngineMethod( GuiPopUpMenuCtrl, getSelected, S32, (), , "Gets the selected index")
{
return object->getSelected();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])")
DefineEngineMethod( GuiPopUpMenuCtrl, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])")
{
object->setSelected( id, scriptCallback );
}
DefineConsoleMethod( GuiPopUpMenuCtrl, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])")
DefineEngineMethod( GuiPopUpMenuCtrl, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])")
{
object->setFirstSelected( scriptCallback );
}
DefineConsoleMethod( GuiPopUpMenuCtrl, setNoneSelected, void, (), , "")
DefineEngineMethod( GuiPopUpMenuCtrl, setNoneSelected, void, (), , "")
{
object->setNoneSelected();
}
DefineConsoleMethod( GuiPopUpMenuCtrl, getTextById, const char*, (S32 id), , "(int id)")
DefineEngineMethod( GuiPopUpMenuCtrl, getTextById, const char*, (S32 id), , "(int id)")
{
return(object->getTextById(id));
}
DefineConsoleMethod( GuiPopUpMenuCtrl, changeTextById, void, ( S32 id, const char * text ), , "( int id, string text )" )
DefineEngineMethod( GuiPopUpMenuCtrl, changeTextById, void, ( S32 id, const char * text ), , "( int id, string text )" )
{
object->setEntryText( id, text );
}
DefineConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, (const char * className, const char * enumName), , "(string class, string enum)"
DefineEngineMethod( GuiPopUpMenuCtrl, setEnumContent, void, (const char * className, const char * enumName), , "(string class, string enum)"
"This fills the popup with a classrep's field enumeration type info.\n\n"
"More of a helper function than anything. If console access to the field list is added, "
"at least for the enumerated types, then this should go away..")
@ -429,20 +429,20 @@ DefineConsoleMethod( GuiPopUpMenuCtrl, setEnumContent, void, (const char * class
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, findText, S32, (const char * text), , "(string text)"
DefineEngineMethod( GuiPopUpMenuCtrl, findText, S32, (const char * text), , "(string text)"
"Returns the position of the first entry containing the specified text or -1 if not found.")
{
return( object->findText( text ) );
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, size, S32, (), , "Get the size of the menu - the number of entries in it.")
DefineEngineMethod( GuiPopUpMenuCtrl, size, S32, (), , "Get the size of the menu - the number of entries in it.")
{
return( object->getNumEntries() );
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, replaceText, void, (bool doReplaceText), , "(bool doReplaceText)")
DefineEngineMethod( GuiPopUpMenuCtrl, replaceText, void, (bool doReplaceText), , "(bool doReplaceText)")
{
object->replaceText(S32(doReplaceText));
}
@ -532,7 +532,7 @@ void GuiPopUpMenuCtrl::clearEntry( S32 entry )
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrl, clearEntry, void, (S32 entry), , "(S32 entry)")
DefineEngineMethod( GuiPopUpMenuCtrl, clearEntry, void, (S32 entry), , "(S32 entry)")
{
object->clearEntry(entry);
}
@ -566,13 +566,14 @@ void GuiPopUpMenuCtrl::setBitmap( const char *name )
{
char buffer[1024];
char *p;
dStrcpy(buffer, name);
dStrcpy(buffer, name, 1024);
p = buffer + dStrlen(buffer);
S32 pLen = 1024 - dStrlen(buffer);
dStrcpy(p, "_n");
dStrcpy(p, "_n", pLen);
mTextureNormal = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
dStrcpy(p, "_d");
dStrcpy(p, "_d", pLen);
mTextureDepressed = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__) );
if ( !mTextureDepressed )
mTextureDepressed = mTextureNormal;
@ -637,7 +638,7 @@ void GuiPopUpMenuCtrl::addEntry( const char *buf, S32 id, U32 scheme )
mIdMax = id;
Entry e;
dStrcpy( e.buf, buf );
dStrcpy( e.buf, buf, 256 );
e.id = id;
e.scheme = scheme;
@ -854,23 +855,23 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
RectI r( offset, getExtent() );
RectI baseRect( offset, getExtent() );
if ( mInAction )
{
S32 l = r.point.x, r2 = r.point.x + r.extent.x - 1;
S32 t = r.point.y, b = r.point.y + r.extent.y - 1;
S32 left = baseRect.point.x, right = baseRect.point.x + baseRect.extent.x - 1;
S32 top = baseRect.point.y, bottom = baseRect.point.y + baseRect.extent.y - 1;
// Do we render a bitmap border or lines?
if ( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() )
{
// Render the fixed, filled in border
renderFixedBitmapBordersFilled(r, 3, mProfile );
renderFixedBitmapBordersFilled(baseRect, 3, mProfile );
}
else
{
//renderSlightlyLoweredBox(r, mProfile);
drawUtil->drawRectFill( r, mProfile->mFillColor );
drawUtil->drawRectFill(baseRect, mProfile->mFillColor );
}
// Draw a bitmap over the background?
@ -890,10 +891,10 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
drawUtil->drawLine( l, t, l, b, colorWhite );
drawUtil->drawLine( l, t, r2, t, colorWhite );
drawUtil->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
drawUtil->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
drawUtil->drawLine(left, top, left, bottom, colorWhite );
drawUtil->drawLine(left, top, right, top, colorWhite );
drawUtil->drawLine(left + 1, bottom, right, bottom, mProfile->mBorderColor );
drawUtil->drawLine(right, top + 1, right, bottom - 1, mProfile->mBorderColor );
}
}
@ -902,19 +903,19 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// TODO: Add onMouseEnter() and onMouseLeave() and a definition of mMouseOver (see guiButtonBaseCtrl) for this to work.
if ( mMouseOver )
{
S32 l = r.point.x, r2 = r.point.x + r.extent.x - 1;
S32 t = r.point.y, b = r.point.y + r.extent.y - 1;
S32 left = baseRect.point.x, right = baseRect.point.x + baseRect.extent.x - 1;
S32 top = baseRect.point.y, bottom = baseRect.point.y + baseRect.extent.y - 1;
// Do we render a bitmap border or lines?
if ( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() )
{
// Render the fixed, filled in border
renderFixedBitmapBordersFilled( r, 2, mProfile );
renderFixedBitmapBordersFilled(baseRect, 2, mProfile );
}
else
{
drawUtil->drawRectFill( r, mProfile->mFillColorHL );
drawUtil->drawRectFill(baseRect, mProfile->mFillColorHL );
}
// Draw a bitmap over the background?
@ -928,10 +929,10 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
drawUtil->drawLine( l, t, l, b, colorWhite );
drawUtil->drawLine( l, t, r2, t, colorWhite );
drawUtil->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
drawUtil->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
drawUtil->drawLine(left, top, left, bottom, colorWhite);
drawUtil->drawLine(left, top, right, top, colorWhite);
drawUtil->drawLine(left + 1, bottom, right, bottom, mProfile->mBorderColor);
drawUtil->drawLine(right, top + 1, right, bottom - 1, mProfile->mBorderColor);
}
}
else
@ -940,11 +941,11 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
if ( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() )
{
// Render the fixed, filled in border
renderFixedBitmapBordersFilled( r, 1, mProfile );
renderFixedBitmapBordersFilled(baseRect, 1, mProfile );
}
else
{
drawUtil->drawRectFill( r, mProfile->mFillColorNA );
drawUtil->drawRectFill(baseRect, mProfile->mFillColorNA );
}
// Draw a bitmap over the background?
@ -958,7 +959,7 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
drawUtil->drawRect( r, mProfile->mBorderColorNA );
drawUtil->drawRect( baseRect, mProfile->mBorderColorNA );
}
}
// renderSlightlyRaisedBox(r, mProfile); // Used to be the only 'else' condition to mInAction above.
@ -1028,9 +1029,9 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
if ( drawbox )
{
Point2I coloredboxsize( 15, 10 );
RectI r( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
drawUtil->drawRectFill( r, boxColor);
drawUtil->drawRect( r, ColorI(0,0,0));
RectI boxBounds( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
drawUtil->drawRectFill(boxBounds, boxColor);
drawUtil->drawRect(boxBounds, ColorI(0,0,0));
localStart.x += coloredboxsize.x + mProfile->mTextOffset.x;
}
@ -1054,18 +1055,18 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Draw the second column to the right
getColumn( mText, buff, 1, "\t" );
S32 txt_w = mProfile->mFont->getStrWidth( buff );
S32 colTxt_w = mProfile->mFont->getStrWidth( buff );
if ( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - bitmapBounds[2].extent.x, localStart.y ) );
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - colTxt_w - bitmapBounds[2].extent.x, localStart.y ) );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
} else
{
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - 12, localStart.y ) );
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - colTxt_w - 12, localStart.y ) );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
}
@ -1078,10 +1079,10 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
if ( !(mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size()) )
{
// Draw a triangle (down arrow)
S32 left = r.point.x + r.extent.x - 12;
S32 left = baseRect.point.x + baseRect.extent.x - 12;
S32 right = left + 8;
S32 middle = left + 4;
S32 top = r.extent.y / 2 + r.point.y - 4;
S32 top = baseRect.extent.y / 2 + baseRect.point.y - 4;
S32 bottom = top + 8;
PrimBuild::color( mProfile->mFontColor );

View file

@ -364,7 +364,7 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExAdd(
"void add(string name, S32 idNum, S32 scheme=0);"
);
DefineConsoleMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
DefineEngineMethod( GuiPopUpMenuCtrlEx, add, void, (const char * name, S32 idNum, U32 scheme), ("", -1, 0), "(string name, int idNum, int scheme=0)")
{
object->addEntry(name, idNum, scheme);
}
@ -390,7 +390,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
U32 r, g, b;
char buf[64];
dStrcpy( buf, argv[3] );
dStrcpy( buf, argv[3], 64 );
char* temp = dStrtok( buf, " \0" );
r = temp ? dAtoi( temp ) : 0;
temp = dStrtok( NULL, " \0" );
@ -399,7 +399,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
b = temp ? dAtoi( temp ) : 0;
fontColor.set( r, g, b );
dStrcpy( buf, argv[4] );
dStrcpy( buf, argv[4], 64 );
temp = dStrtok( buf, " \0" );
r = temp ? dAtoi( temp ) : 0;
temp = dStrtok( NULL, " \0" );
@ -408,7 +408,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
b = temp ? dAtoi( temp ) : 0;
fontColorHL.set( r, g, b );
dStrcpy( buf, argv[5] );
dStrcpy( buf, argv[5], 64 );
temp = dStrtok( buf, " \0" );
r = temp ? dAtoi( temp ) : 0;
temp = dStrtok( NULL, " \0" );
@ -426,7 +426,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
// U32 r, g, b;
// char buf[64];
//
// dStrcpy( buf, argv[3] );
// dStrcpy( buf, argv[3], 64 );
// char* temp = dStrtok( buf, " \0" );
// r = temp ? dAtoi( temp ) : 0;
// temp = dStrtok( NULL, " \0" );
@ -435,7 +435,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
// b = temp ? dAtoi( temp ) : 0;
// fontColor.set( r, g, b );
//
// dStrcpy( buf, argv[4] );
// dStrcpy( buf, argv[4], 64 );
// temp = dStrtok( buf, " \0" );
// r = temp ? dAtoi( temp ) : 0;
// temp = dStrtok( NULL, " \0" );
@ -444,7 +444,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, addScheme, void, (S32 id, ColorI fontCol
// b = temp ? dAtoi( temp ) : 0;
// fontColorHL.set( r, g, b );
//
// dStrcpy( buf, argv[5] );
// dStrcpy( buf, argv[5], 64 );
// temp = dStrtok( buf, " \0" );
// r = temp ? dAtoi( temp ) : 0;
// temp = dStrtok( NULL, " \0" );
@ -525,7 +525,7 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExsetSelected(
"setSelected(int id, bool scriptCallback=true);"
);
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])"
DefineEngineMethod( GuiPopUpMenuCtrlEx, setSelected, void, (S32 id, bool scriptCallback), (true), "(int id, [scriptCallback=true])"
"@hide")
{
object->setSelected( id, scriptCallback );
@ -539,7 +539,7 @@ ConsoleDocFragment _GuiPopUpMenuCtrlExsetFirstSelected(
);
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])"
DefineEngineMethod( GuiPopUpMenuCtrlEx, setFirstSelected, void, (bool scriptCallback), (true), "([scriptCallback=true])"
"@hide")
{
object->setFirstSelected( scriptCallback );
@ -561,7 +561,7 @@ DefineEngineMethod( GuiPopUpMenuCtrlEx, getTextById, const char*, (S32 id),,
}
DefineConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), ,
DefineEngineMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), ,
"@brief Get color of an entry's box\n\n"
"@param id ID number of entry to query\n\n"
"@return ColorI in the format of \"Red Green Blue Alpha\", each of with is a value between 0 - 255")
@ -572,7 +572,7 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, ColorI, (S32 id), ,
}
DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * className, const char * enumName ), ,
DefineEngineMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * className, const char * enumName ), ,
"@brief This fills the popup with a classrep's field enumeration type info.\n\n"
"More of a helper function than anything. If console access to the field list is added, "
"at least for the enumerated types, then this should go away.\n\n"
@ -628,7 +628,7 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, setEnumContent, void, ( const char * cl
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "(string text)"
DefineEngineMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "(string text)"
"Returns the id of the first entry containing the specified text or -1 if not found."
"@param text String value used for the query\n\n"
"@return Numerical ID of entry containing the text.")
@ -637,7 +637,7 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, findText, S32, (const char * text), , "
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, (), ,
DefineEngineMethod( GuiPopUpMenuCtrlEx, size, S32, (), ,
"@brief Get the size of the menu\n\n"
"@return Number of entries in the menu\n")
{
@ -645,7 +645,7 @@ DefineConsoleMethod( GuiPopUpMenuCtrlEx, size, S32, (), ,
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, replaceText, void, (S32 boolVal), ,
DefineEngineMethod( GuiPopUpMenuCtrlEx, replaceText, void, (S32 boolVal), ,
"@brief Flag that causes each new text addition to replace the current entry\n\n"
"@param True to turn on replacing, false to disable it")
{
@ -737,7 +737,7 @@ void GuiPopUpMenuCtrlEx::clearEntry( S32 entry )
}
//------------------------------------------------------------------------------
DefineConsoleMethod( GuiPopUpMenuCtrlEx, clearEntry, void, (S32 entry), , "(S32 entry)")
DefineEngineMethod( GuiPopUpMenuCtrlEx, clearEntry, void, (S32 entry), , "(S32 entry)")
{
object->clearEntry(entry);
}
@ -771,13 +771,14 @@ void GuiPopUpMenuCtrlEx::setBitmap(const char *name)
{
char buffer[1024];
char *p;
dStrcpy(buffer, name);
dStrcpy(buffer, name, 1024);
p = buffer + dStrlen(buffer);
S32 pLen = 1024 - dStrlen(buffer);
dStrcpy(p, "_n");
dStrcpy(p, "_n", pLen);
mTextureNormal = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
dStrcpy(p, "_d");
dStrcpy(p, "_d", pLen);
mTextureDepressed = GFXTexHandle( (StringTableEntry)buffer, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__) );
if ( !mTextureDepressed )
mTextureDepressed = mTextureNormal;
@ -840,7 +841,7 @@ void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme)
mIdMax = id;
Entry e;
dStrcpy( e.buf, buf );
dStrcpy( e.buf, buf, 256 );
e.id = id;
e.scheme = scheme;
@ -1210,9 +1211,9 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
if ( drawbox )
{
Point2I coloredboxsize( 15, 10 );
RectI r( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
drawUtil->drawRectFill( r, boxColor);
drawUtil->drawRect( r, ColorI(0,0,0));
RectI boxBounds( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
drawUtil->drawRectFill(boxBounds, boxColor);
drawUtil->drawRect(boxBounds, ColorI(0,0,0));
localStart.x += coloredboxsize.x + mProfile->mTextOffset.x;
}
@ -1236,18 +1237,18 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
// Draw the second column to the right
getColumn( mText, buff, 1, "\t" );
S32 txt_w = mProfile->mFont->getStrWidth( buff );
S32 colTxt_w = mProfile->mFont->getStrWidth( buff );
if ( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - bitmapBounds[2].extent.x, localStart.y ) );
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - colTxt_w - bitmapBounds[2].extent.x, localStart.y ) );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
} else
{
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - 12, localStart.y ) );
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - colTxt_w - 12, localStart.y ) );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
}

View file

@ -50,7 +50,7 @@ GuiTabPageCtrl::GuiTabPageCtrl(void)
{
setExtent(Point2I(100, 200));
mFitBook = false;
dStrcpy(mText,(UTF8*)"TabPage");
dStrcpy(mText,(UTF8*)"TabPage", MAX_STRING_LENGTH);
mActive = true;
mIsContainer = true;
}

View file

@ -36,9 +36,7 @@
#include "gui/editor/editorFunctions.h"
#endif
#include "console/engineAPI.h"
#ifdef TORQUE_EXPERIMENTAL_EC
#include "T3D/entity.h"
#endif
IMPLEMENT_CONOBJECT(GuiTreeViewCtrl);
@ -647,20 +645,6 @@ void GuiTreeViewCtrl::Item::getTooltipText(U32 bufLen, char *buf)
bool GuiTreeViewCtrl::Item::isParent() const
{
#ifdef TORQUE_EXPERIMENTAL_EC
//We might have a special case with entities
//So if our entity either has children, or has some component with the EditorInspect interface, we return true
if (mInspectorInfo.mObject)
{
Entity* e = dynamic_cast<Entity*>(mInspectorInfo.mObject.getObject());
if (e)
{
if (e->size() > 0 || e->getComponentCount() != 0)
return true;
}
}
#endif
if(mState.test(VirtualParent))
{
if( !isInspectorData() )
@ -2517,6 +2501,19 @@ const char * GuiTreeViewCtrl::getItemValue(S32 itemId)
//-----------------------------------------------------------------------------
S32 GuiTreeViewCtrl::getItemAtPosition(Point2I position)
{
BitSet32 hitFlags = 0;
Item* item;
if (_hitTest(position, item, hitFlags))
return item->mId;
else
return -1;
}
//-----------------------------------------------------------------------------
bool GuiTreeViewCtrl::editItem( S32 itemId, const char* newText, const char* newValue )
{
Item* item = getItem( itemId );
@ -3007,10 +3004,10 @@ void GuiTreeViewCtrl::onMouseUp(const GuiEvent &event)
{
if( !mActive || !mAwake || !mVisible )
return;
BitSet32 hitFlags = 0;
if( isMethod("onMouseUp") )
{
BitSet32 hitFlags = 0;
Item* item;
S32 hitItemId = -1;
@ -3028,26 +3025,26 @@ void GuiTreeViewCtrl::onMouseUp(const GuiEvent &event)
return;
}
BitSet32 hitFlags = 0;
Item *item;
bool hitCheck = _hitTest( event.mousePoint, item, hitFlags );
hitFlags = 0;
Item *hitItem;
bool hitCheck = _hitTest( event.mousePoint, hitItem, hitFlags );
mRenamingItem = NULL;
if( hitCheck )
{
if ( event.mouseClickCount == 1 && !mMouseDragged && mPossibleRenameItem != NULL )
{
if ( item == mPossibleRenameItem )
showItemRenameCtrl( item );
if (hitItem == mPossibleRenameItem )
showItemRenameCtrl(hitItem);
}
else // If mouseUp occurs on the same item as mouse down
{
bool wasSelected = isSelected( item );
bool wasSelected = isSelected(hitItem);
bool multiSelect = getSelectedItemsCount() > 1;
if( wasSelected && multiSelect && item == mTempItem )
if( wasSelected && multiSelect && hitItem == mTempItem )
{
clearSelection();
addSelection( item->mId );
addSelection( hitItem->mId );
}
}
}
@ -3064,7 +3061,7 @@ void GuiTreeViewCtrl::onMouseUp(const GuiEvent &event)
{
Parent::onMouseMove( event );
BitSet32 hitFlags = 0;
hitFlags = 0;
if( !_hitTest( event.mousePoint, newItem2, hitFlags ) )
{
if( !mShowRoot )
@ -3790,7 +3787,6 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
if( !item->isInspectorData() && item->mState.test(Item::VirtualParent) )
onVirtualParentExpand(item);
#ifdef TORQUE_EXPERIMENTAL_EC
//Slightly hacky, but I'm not sure of a better setup until we get major update to the editors
//We check if our object is an entity, and if it is, we call a 'onInspect' function.
//This function is pretty much a special notifier to the entity so if it has any behaviors that do special
@ -3798,19 +3794,14 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
if (item->isInspectorData())
{
Entity* e = dynamic_cast<Entity*>(item->getObject());
//if (item->mScriptInfo.mText != StringTable->insert("Components"))
{
Entity* e = dynamic_cast<Entity*>(item->getObject());
if (e)
{
if (item->isExpanded())
e->onInspect();
else
e->onEndInspect();
}
if (e)
{
if (item->isExpanded())
e->onInspect();
else
e->onEndInspect();
}
}
#endif
mFlags.set( RebuildVisible );
scrollVisible(item);
@ -4558,12 +4549,10 @@ bool GuiTreeViewCtrl::objectSearch( const SimObject *object, Item **item )
if ( !pItem )
continue;
#ifdef TORQUE_EXPERIMENTAL_EC
//A bit hackish, but we make a special exception here for items that are named 'Components', as they're merely
//virtual parents to act as a container to an Entity's components
if (pItem->mScriptInfo.mText == StringTable->insert("Components"))
continue;
#endif
SimObject *pObj = pItem->getObject();
@ -4628,11 +4617,10 @@ bool GuiTreeViewCtrl::onVirtualParentBuild(Item *item, bool bForceFullUpdate)
// Go through our items and purge those that have disappeared from
// the set.
#ifdef TORQUE_EXPERIMENTAL_EC
//Entities will be a special case here, if we're an entity, skip this step
if (dynamic_cast<Entity*>(srcObj))
return true;
#endif
for( Item* ptr = item->mChild; ptr != NULL; )
{
@ -4762,15 +4750,15 @@ StringTableEntry GuiTreeViewCtrl::getTextToRoot( S32 itemId, const char * delimi
dMemset( bufferOne, 0, sizeof(bufferOne) );
dMemset( bufferTwo, 0, sizeof(bufferTwo) );
dStrcpy( bufferOne, item->getText() );
dStrcpy( bufferOne, item->getText(), 1024 );
Item *prevNode = item->mParent;
while ( prevNode )
{
dMemset( bufferNodeText, 0, sizeof(bufferNodeText) );
dStrcpy( bufferNodeText, prevNode->getText() );
dStrcpy( bufferNodeText, prevNode->getText(), 128 );
dSprintf( bufferTwo, 1024, "%s%s%s",bufferNodeText, delimiter, bufferOne );
dStrcpy( bufferOne, bufferTwo );
dStrcpy( bufferOne, bufferTwo, 1024 );
dMemset( bufferTwo, 0, sizeof(bufferTwo) );
prevNode = prevNode->mParent;
}
@ -5571,3 +5559,11 @@ DefineEngineMethod( GuiTreeViewCtrl, clearFilterText, void, (),,
{
object->clearFilterText();
}
DefineEngineMethod(GuiTreeViewCtrl, getItemAtPosition, S32, (Point2I position), (Point2I::Zero),
"Get the tree item at the passed in position.\n\n"
"@param position The position to check for what item is below it.\n"
"@return The id of the item under the position.")
{
return object->getItemAtPosition(position);
}

View file

@ -513,6 +513,8 @@ class GuiTreeViewCtrl : public GuiArrayCtrl
bool editItem( S32 itemId, const char* newText, const char* newValue );
bool markItem( S32 itemId, bool mark );
S32 getItemAtPosition(Point2I position);
bool isItemSelected( S32 itemId );

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "platform/platform.h"
#include "gui/core/guiCanvas.h"
@ -128,7 +133,8 @@ GuiCanvas::GuiCanvas(): GuiControl(),
mLastRenderMs(0),
mPlatformWindow(NULL),
mDisplayWindow(true),
mMenuBarCtrl(NULL)
mMenuBarCtrl(nullptr),
mMenuBackground(nullptr)
{
setBounds(0, 0, 640, 480);
mAwake = true;
@ -271,8 +277,6 @@ bool GuiCanvas::onAdd()
// Define the menu bar for this canvas (if any)
Con::executef(this, "onCreateMenu");
Sim::findObject("PlatformGenericMenubar", mMenuBarCtrl);
return parentRet;
}
@ -293,25 +297,49 @@ void GuiCanvas::setMenuBar(SimObject *obj)
mMenuBarCtrl = dynamic_cast<GuiControl*>(obj);
//remove old menubar
if( oldMenuBar )
Parent::removeObject( oldMenuBar );
if (oldMenuBar)
{
Parent::removeObject(oldMenuBar);
Parent::removeObject(mMenuBackground); //also remove the modeless wrapper
}
// set new menubar
if( mMenuBarCtrl )
Parent::addObject(mMenuBarCtrl);
if (mMenuBarCtrl)
{
//Add a wrapper control so that the menubar sizes correctly
GuiControlProfile* profile;
Sim::findObject("GuiModelessDialogProfile", profile);
if (!profile)
{
Con::errorf("GuiCanvas::setMenuBar: Unable to find the GuiModelessDialogProfile profile!");
return;
}
if (mMenuBackground == nullptr)
{
mMenuBackground = new GuiControl();
mMenuBackground->registerObject();
mMenuBackground->setControlProfile(profile);
}
mMenuBackground->addObject(mMenuBarCtrl);
Parent::addObject(mMenuBackground);
}
// update window accelerator keys
if( oldMenuBar != mMenuBarCtrl )
{
StringTableEntry ste = StringTable->insert("menubar");
GuiMenuBar* menu = NULL;
menu = !oldMenuBar ? NULL : dynamic_cast<GuiMenuBar*>(oldMenuBar->findObjectByInternalName( ste, true));
if( menu )
menu->removeWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
GuiMenuBar* oldMenu = dynamic_cast<GuiMenuBar*>(oldMenuBar);
GuiMenuBar* newMenu = dynamic_cast<GuiMenuBar*>(mMenuBarCtrl);
menu = !mMenuBarCtrl ? NULL : dynamic_cast<GuiMenuBar*>(mMenuBarCtrl->findObjectByInternalName( ste, true));
if( menu )
menu->buildWindowAcceleratorMap( *getPlatformWindow()->getInputGenerator() );
if(oldMenu)
oldMenu->removeWindowAcceleratorMap(*getPlatformWindow()->getInputGenerator());
if(newMenu)
newMenu->buildWindowAcceleratorMap(*getPlatformWindow()->getInputGenerator());
}
}
@ -605,10 +633,11 @@ bool GuiCanvas::tabPrev(void)
bool GuiCanvas::processInputEvent(InputEventInfo &inputEvent)
{
mConsumeLastInputEvent = true;
// First call the general input handler (on the extremely off-chance that it will be handled):
if (mFirstResponder && mFirstResponder->onInputEvent(inputEvent))
{
return(true);
return mConsumeLastInputEvent;
}
switch (inputEvent.deviceType)
@ -664,7 +693,7 @@ bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent)
if (mFirstResponder)
{
if(mFirstResponder->onKeyDown(mLastEvent))
return true;
return mConsumeLastInputEvent;
}
//see if we should tab next/prev
@ -675,12 +704,12 @@ bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent)
if (inputEvent.modifier & SI_SHIFT)
{
if(tabPrev())
return true;
return mConsumeLastInputEvent;
}
else if (inputEvent.modifier == 0)
{
if(tabNext())
return true;
return mConsumeLastInputEvent;
}
}
}
@ -691,14 +720,14 @@ bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent)
if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier)
{
mAcceleratorMap[i].ctrl->acceleratorKeyPress(mAcceleratorMap[i].index);
return true;
return mConsumeLastInputEvent;
}
}
}
else if(inputEvent.action == SI_BREAK)
{
if(mFirstResponder && mFirstResponder->onKeyUp(mLastEvent))
return true;
return mConsumeLastInputEvent;
//see if there's an accelerator
for (U32 i = 0; i < mAcceleratorMap.size(); i++)
@ -706,7 +735,7 @@ bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent)
if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier)
{
mAcceleratorMap[i].ctrl->acceleratorKeyRelease(mAcceleratorMap[i].index);
return true;
return mConsumeLastInputEvent;
}
}
}
@ -718,13 +747,14 @@ bool GuiCanvas::processKeyboardEvent(InputEventInfo &inputEvent)
if ((U32)mAcceleratorMap[i].keyCode == (U32)inputEvent.objInst && (U32)mAcceleratorMap[i].modifier == eventModifier)
{
mAcceleratorMap[i].ctrl->acceleratorKeyPress(mAcceleratorMap[i].index);
return true;
return mConsumeLastInputEvent;
}
}
if(mFirstResponder)
{
return mFirstResponder->onKeyRepeat(mLastEvent);
bool ret = mFirstResponder->onKeyRepeat(mLastEvent);
return ret && mConsumeLastInputEvent;
}
}
return false;
@ -801,7 +831,7 @@ bool GuiCanvas::processMouseEvent(InputEventInfo &inputEvent)
rootMiddleMouseDragged(mLastEvent);
else
rootMouseMove(mLastEvent);
return true;
return mConsumeLastInputEvent;
}
else if ( inputEvent.objInst == SI_ZAXIS
|| inputEvent.objInst == SI_RZAXIS )
@ -860,7 +890,7 @@ bool GuiCanvas::processMouseEvent(InputEventInfo &inputEvent)
rootMouseUp(mLastEvent);
}
return true;
return mConsumeLastInputEvent;
}
else if(inputEvent.objInst == KEY_BUTTON1) // right button
{
@ -891,7 +921,7 @@ bool GuiCanvas::processMouseEvent(InputEventInfo &inputEvent)
else // it was a mouse up
rootRightMouseUp(mLastEvent);
return true;
return mConsumeLastInputEvent;
}
else if(inputEvent.objInst == KEY_BUTTON2) // middle button
{
@ -922,7 +952,7 @@ bool GuiCanvas::processMouseEvent(InputEventInfo &inputEvent)
else // it was a mouse up
rootMiddleMouseUp(mLastEvent);
return true;
return mConsumeLastInputEvent;
}
}
return false;
@ -1500,9 +1530,9 @@ void GuiCanvas::popDialogControl(GuiControl *gui)
if (size() > 0)
{
GuiControl *ctrl = static_cast<GuiControl *>(last());
if( ctrl->getFirstResponder() )
ctrl->getFirstResponder()->setFirstResponder();
GuiControl *lastCtrl = static_cast<GuiControl *>(last());
if(lastCtrl->getFirstResponder() )
lastCtrl->getFirstResponder()->setFirstResponder();
}
else
{
@ -1517,8 +1547,8 @@ void GuiCanvas::popDialogControl(GuiControl *gui)
if (size() > 0)
{
GuiControl *ctrl = static_cast<GuiControl*>(last());
ctrl->buildAcceleratorMap();
GuiControl *lastCtrl = static_cast<GuiControl*>(last());
lastCtrl->buildAcceleratorMap();
}
refreshMouseControl();
}
@ -1626,27 +1656,26 @@ void GuiCanvas::maintainSizing()
Point2I newPos = screenRect.point;
// if menubar is active displace content gui control
if( mMenuBarCtrl && (ctrl == getContentControl()) )
{
const SimObject *menu = mMenuBarCtrl->findObjectByInternalName( StringTable->insert("menubar"), true);
if (mMenuBarCtrl && (ctrl == getContentControl()))
{
/*const SimObject *menu = mMenuBarCtrl->findObjectByInternalName( StringTable->insert("menubar"), true);
if( !menu )
continue;
if( !menu )
continue;
AssertFatal( dynamic_cast<const GuiControl*>(menu), "");
AssertFatal( dynamic_cast<const GuiControl*>(menu), "");*/
const U32 yOffset = static_cast<const GuiControl*>(menu)->getExtent().y;
newPos.y += yOffset;
newExt.y -= yOffset;
const U32 yOffset = static_cast<const GuiMenuBar*>(mMenuBarCtrl)->mMenubarHeight;
newPos.y += yOffset;
newExt.y -= yOffset;
}
if(pos != newPos || ext != newExt)
if (pos != newPos || ext != newExt)
{
ctrl->resize(newPos, newExt);
resetUpdateRegions();
}
}
}
void GuiCanvas::setupFences()
@ -1801,7 +1830,7 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
if (GuiOffscreenCanvas::sList.size() != 0)
{
// Reset the entire state since oculus shit will have barfed it.
GFX->disableShaders(true);
//GFX->disableShaders(true);
GFX->updateStates(true);
for (Vector<GuiOffscreenCanvas*>::iterator itr = GuiOffscreenCanvas::sList.begin(); itr != GuiOffscreenCanvas::sList.end(); itr++)
@ -2110,7 +2139,7 @@ ConsoleDocFragment _pushDialog(
"void pushDialog( GuiControl ctrl, int layer=0, bool center=false);"
);
DefineConsoleMethod( GuiCanvas, pushDialog, void, (const char * ctrlName, S32 layer, bool center), ( 0, false), "(GuiControl ctrl, int layer=0, bool center=false)"
DefineEngineMethod( GuiCanvas, pushDialog, void, (const char * ctrlName, S32 layer, bool center), ( 0, false), "(GuiControl ctrl, int layer=0, bool center=false)"
"@hide")
{
GuiControl *gui;
@ -2147,7 +2176,7 @@ ConsoleDocFragment _popDialog2(
"void popDialog();"
);
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (nullAsType<GuiControl*>()), "(GuiControl ctrl=NULL)"
DefineEngineMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (nullAsType<GuiControl*>()), "(GuiControl ctrl=NULL)"
"@hide")
{
if (gui)
@ -2175,7 +2204,7 @@ ConsoleDocFragment _popLayer2(
"void popLayer(S32 layer);"
);
DefineConsoleMethod( GuiCanvas, popLayer, void, (S32 layer), (0), "(int layer)"
DefineEngineMethod( GuiCanvas, popLayer, void, (S32 layer), (0), "(int layer)"
"@hide")
{
@ -2333,7 +2362,7 @@ ConsoleDocFragment _setCursorPos2(
"bool setCursorPos( F32 posX, F32 posY);"
);
DefineConsoleMethod( GuiCanvas, setCursorPos, void, (Point2I pos), , "(Point2I pos)"
DefineEngineMethod( GuiCanvas, setCursorPos, void, (Point2I pos), , "(Point2I pos)"
"@hide")
{
@ -2618,7 +2647,7 @@ DefineEngineMethod( GuiCanvas, setWindowPosition, void, ( Point2I position ),,
object->getPlatformWindow()->setPosition( position );
}
DefineConsoleMethod( GuiCanvas, isFullscreen, bool, (), , "() - Is this canvas currently fullscreen?" )
DefineEngineMethod( GuiCanvas, isFullscreen, bool, (), , "() - Is this canvas currently fullscreen?" )
{
if (Platform::getWebDeployment())
return false;
@ -2629,14 +2658,14 @@ DefineConsoleMethod( GuiCanvas, isFullscreen, bool, (), , "() - Is this canvas c
return object->getPlatformWindow()->getVideoMode().fullScreen;
}
DefineConsoleMethod( GuiCanvas, minimizeWindow, void, (), , "() - minimize this canvas' window." )
DefineEngineMethod( GuiCanvas, minimizeWindow, void, (), , "() - minimize this canvas' window." )
{
PlatformWindow* window = object->getPlatformWindow();
if ( window )
window->minimize();
}
DefineConsoleMethod( GuiCanvas, isMinimized, bool, (), , "()" )
DefineEngineMethod( GuiCanvas, isMinimized, bool, (), , "()" )
{
PlatformWindow* window = object->getPlatformWindow();
if ( window )
@ -2645,7 +2674,7 @@ DefineConsoleMethod( GuiCanvas, isMinimized, bool, (), , "()" )
return false;
}
DefineConsoleMethod( GuiCanvas, isMaximized, bool, (), , "()" )
DefineEngineMethod( GuiCanvas, isMaximized, bool, (), , "()" )
{
PlatformWindow* window = object->getPlatformWindow();
if ( window )
@ -2654,21 +2683,21 @@ DefineConsoleMethod( GuiCanvas, isMaximized, bool, (), , "()" )
return false;
}
DefineConsoleMethod( GuiCanvas, maximizeWindow, void, (), , "() - maximize this canvas' window." )
DefineEngineMethod( GuiCanvas, maximizeWindow, void, (), , "() - maximize this canvas' window." )
{
PlatformWindow* window = object->getPlatformWindow();
if ( window )
window->maximize();
}
DefineConsoleMethod( GuiCanvas, restoreWindow, void, (), , "() - restore this canvas' window." )
DefineEngineMethod( GuiCanvas, restoreWindow, void, (), , "() - restore this canvas' window." )
{
PlatformWindow* window = object->getPlatformWindow();
if( window )
window->restore();
}
DefineConsoleMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus for this canvas' window.")
DefineEngineMethod( GuiCanvas, setFocus, void, (), , "() - Claim OS input focus for this canvas' window.")
{
PlatformWindow* window = object->getPlatformWindow();
if( window )
@ -2683,7 +2712,7 @@ DefineEngineMethod( GuiCanvas, setMenuBar, void, ( GuiControl* menu ),,
return object->setMenuBar( menu );
}
DefineConsoleMethod( GuiCanvas, setVideoMode, void,
DefineEngineMethod( GuiCanvas, setVideoMode, void,
(U32 width, U32 height, bool fullscreen, U32 bitDepth, U32 refreshRate, U32 antialiasLevel),
( false, 0, 0, 0),
"(int width, int height, bool fullscreen, [int bitDepth], [int refreshRate], [int antialiasLevel] )\n"
@ -2783,7 +2812,7 @@ DefineConsoleMethod( GuiCanvas, setVideoMode, void,
Con::setVariable( "$pref::Video::mode", vm.toString() );
}
ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
DefineEngineMethod(GuiCanvas, showWindow, void, (),, "")
{
if (!object->getPlatformWindow())
return;
@ -2793,7 +2822,7 @@ ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
object->getPlatformWindow()->setDisplayWindow(true);
}
ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
DefineEngineMethod(GuiCanvas, hideWindow, void, (),, "")
{
if (!object->getPlatformWindow())
return;
@ -2803,15 +2832,34 @@ ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
object->getPlatformWindow()->setDisplayWindow(false);
}
ConsoleMethod( GuiCanvas, cursorClick, void, 4, 4, "button, isDown" )
DefineEngineMethod(GuiCanvas, cursorClick, void, (S32 buttonId, bool isDown), , "")
{
const S32 buttonId = dAtoi(argv[2]);
const bool isDown = dAtob(argv[3]);
object->cursorClick(buttonId, isDown);
}
ConsoleMethod( GuiCanvas, cursorNudge, void, 4, 4, "x, y" )
DefineEngineMethod(GuiCanvas, cursorNudge, void, (F32 x, F32 y), , "")
{
object->cursorNudge(dAtof(argv[2]), dAtof(argv[3]));
object->cursorNudge(x, y);
}
// This function allows resetting of the video-mode from script. It was motivated by
// the need to temporarily disable vsync during datablock cache load to avoid a
// significant slowdown.
bool AFX_forceVideoReset = false;
DefineEngineMethod(GuiCanvas, resetVideoMode, void, (), , "")
{
PlatformWindow* window = object->getPlatformWindow();
if (window)
{
GFXWindowTarget* gfx_target = window->getGFXTarget();
if (gfx_target)
{
AFX_forceVideoReset = true;
gfx_target->resetMode();
AFX_forceVideoReset = false;
}
}
}

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _GUICANVAS_H_
#define _GUICANVAS_H_
@ -193,6 +198,7 @@ protected:
static CanvasSizeChangeSignal smCanvasSizeChangeSignal;
GuiControl *mMenuBarCtrl;
GuiControl* mMenuBackground;
public:
DECLARE_CONOBJECT(GuiCanvas);
@ -205,6 +211,7 @@ public:
virtual void onRemove();
void setMenuBar(SimObject *obj);
SimObject* getMenuBar() { return mMenuBarCtrl; }
static void initPersistFields();
@ -329,6 +336,9 @@ public:
/// Returns the point, in screenspace, at which the cursor is located.
virtual Point2I getCursorPos();
/// Returns the point, in local coordinates, at which the cursor is located
virtual Point2I getCursorPosLocal() { return Point2I(S32(mCursorPt.x), S32(mCursorPt.y)); }
/// Enable/disable rendering of the cursor.
/// @param state True if we should render cursor
virtual void showCursor(bool state);
@ -446,6 +456,13 @@ public:
private:
static const U32 MAX_GAMEPADS = 4; ///< The maximum number of supported gamepads
protected:
bool mConsumeLastInputEvent;
public:
void clearMouseRightButtonDown(void) { mMouseRightButtonDown = false; }
void clearMouseButtonDown(void) { mMouseButtonDown = false; }
void setConsumeLastInputEvent(bool flag) { mConsumeLastInputEvent = flag; }
bool getLastCursorPoint(Point2I& pt) const { pt = mLastCursorPt; return mLastCursorEnabled; }
};
#endif

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "platform/platform.h"
#include "gui/core/guiControl.h"
@ -224,6 +229,7 @@ GuiControl::GuiControl() : mAddGroup( NULL ),
mCanSaveFieldDictionary = false;
mNotifyChildrenResized = true;
fade_amt = 1.0f;
}
//-----------------------------------------------------------------------------
@ -2564,7 +2570,7 @@ DefineEngineMethod( GuiControl, findHitControls, const char*, ( S32 x, S32 y, S3
return "";
char* buffer = Con::getReturnBuffer( s.size() );
dStrcpy( buffer, s.c_str() );
dStrcpy( buffer, s.c_str(), s.size() );
return buffer;
}
@ -2892,7 +2898,7 @@ static ConsoleDocFragment _sGuiControlSetExtent2(
"GuiControl", // The class to place the method in; use NULL for functions.
"void setExtent( Point2I p );" ); // The definition string.
DefineConsoleMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), (""),
DefineEngineMethod( GuiControl, setExtent, void, ( const char* extOrX, const char* y ), (""),
"( Point2I p | int x, int y ) Set the width and height of the control.\n\n"
"@hide" )
{

View file

@ -20,6 +20,11 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _GUICONTROL_H_
#define _GUICONTROL_H_
@ -822,6 +827,10 @@ class GuiControl : public SimGroup
void inspectPostApply();
void inspectPreApply();
protected:
F32 fade_amt;
public:
void setFadeAmount(F32 amt) { fade_amt = amt; }
};
typedef GuiControl::horizSizingOptions GuiHorizontalSizing;

View file

@ -66,13 +66,13 @@ DbgFileView::DbgFileView()
mSize.set(1, 0);
}
DefineConsoleMethod(DbgFileView, setCurrentLine, void, (S32 line, bool selected), , "(int line, bool selected)"
DefineEngineMethod(DbgFileView, setCurrentLine, void, (S32 line, bool selected), , "(int line, bool selected)"
"Set the current highlighted line.")
{
object->setCurrentLine(line, selected);
}
DefineConsoleMethod(DbgFileView, getCurrentLine, const char *, (), , "()"
DefineEngineMethod(DbgFileView, getCurrentLine, const char *, (), , "()"
"Get the currently executing file and line, if any.\n\n"
"@returns A string containing the file, a tab, and then the line number."
" Use getField() with this.")
@ -84,38 +84,38 @@ DefineConsoleMethod(DbgFileView, getCurrentLine, const char *, (), , "()"
return ret;
}
DefineConsoleMethod(DbgFileView, open, bool, (const char * filename), , "(string filename)"
DefineEngineMethod(DbgFileView, open, bool, (const char * filename), , "(string filename)"
"Open a file for viewing.\n\n"
"@note This loads the file from the local system.")
{
return object->openFile(filename);
}
DefineConsoleMethod(DbgFileView, clearBreakPositions, void, (), , "()"
DefineEngineMethod(DbgFileView, clearBreakPositions, void, (), , "()"
"Clear all break points in the current file.")
{
object->clearBreakPositions();
}
DefineConsoleMethod(DbgFileView, setBreakPosition, void, (U32 line), , "(int line)"
DefineEngineMethod(DbgFileView, setBreakPosition, void, (U32 line), , "(int line)"
"Set a breakpoint at the specified line.")
{
object->setBreakPosition(line);
}
DefineConsoleMethod(DbgFileView, setBreak, void, (U32 line), , "(int line)"
DefineEngineMethod(DbgFileView, setBreak, void, (U32 line), , "(int line)"
"Set a breakpoint at the specified line.")
{
object->setBreakPointStatus(line, true);
}
DefineConsoleMethod(DbgFileView, removeBreak, void, (U32 line), , "(int line)"
DefineEngineMethod(DbgFileView, removeBreak, void, (U32 line), , "(int line)"
"Remove a breakpoint from the specified line.")
{
object->setBreakPointStatus(line, false);
}
DefineConsoleMethod(DbgFileView, findString, bool, (const char * findThis), , "(string findThis)"
DefineEngineMethod(DbgFileView, findString, bool, (const char * findThis), , "(string findThis)"
"Find the specified string in the currently viewed file and "
"scroll it into view.")
{
@ -431,7 +431,7 @@ bool DbgFileView::findMouseOverVariable()
{
S32 stringPosition = pt.x - gFileXOffset;
char tempBuf[256], *varNamePtr = &tempBuf[1];
dStrcpy(tempBuf, mFileView[cell.y].text);
dStrcpy(tempBuf, mFileView[cell.y].text, 256);
//find the current mouse over char
S32 charNum = findMouseOverChar(mFileView[cell.y].text, stringPosition);
@ -526,7 +526,7 @@ void DbgFileView::onPreRender()
{
setUpdate();
char oldVar[256];
dStrcpy(oldVar, mMouseOverVariable);
dStrcpy(oldVar, mMouseOverVariable, 256);
bool found = findMouseOverVariable();
if (found && mPCCurrentLine >= 0)
{
@ -685,7 +685,7 @@ void DbgFileView::onRenderCell(Point2I offset, Point2I cell, bool selected, bool
{
S32 startPos, endPos;
char tempBuf[256];
dStrcpy(tempBuf, mFileView[cell.y].text);
dStrcpy(tempBuf, mFileView[cell.y].text, 256);
//get the end coord
tempBuf[mBlockEnd] = '\0';

View file

@ -542,10 +542,10 @@ void GuiEditCtrl::onMouseDragged( const GuiEvent &event )
// Snap the mouse cursor to grid if active. Do this on the mouse cursor so that we handle
// incremental drags correctly.
Point2I mousePoint = event.mousePoint;
snapToGrid( mousePoint );
Point2I dragPoint = event.mousePoint;
snapToGrid(dragPoint);
Point2I delta = mousePoint - mLastDragPos;
Point2I delta = dragPoint - mLastDragPos;
// If CTRL is down, apply smart snapping.
@ -584,7 +584,7 @@ void GuiEditCtrl::onMouseDragged( const GuiEvent &event )
// Remember drag point.
mLastDragPos = mousePoint;
mLastDragPos = dragPoint;
}
else if (mMouseDownMode == MovingSelection && mSelectedControls.size())
{
@ -770,7 +770,7 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
( mMouseDownMode == MovingSelection || mMouseDownMode == SizingSelection ) &&
( mGridSnap.x || mGridSnap.y ) )
{
Point2I cext = getContentControl()->getExtent();
cext = getContentControl()->getExtent();
Point2I coff = getContentControl()->localToGlobalCoord(Point2I(0,0));
// create point-dots
@ -847,8 +847,8 @@ void GuiEditCtrl::onRender(Point2I offset, const RectI &updateRect)
if( mSnapTargets[ axis ] )
{
RectI bounds = mSnapTargets[ axis ]->getGlobalBounds();
drawer->drawRect( bounds, ColorI( 128, 128, 128, 128 ) );
RectI snapBounds = mSnapTargets[ axis ]->getGlobalBounds();
drawer->drawRect(snapBounds, ColorI( 128, 128, 128, 128 ) );
}
}
}
@ -1015,7 +1015,7 @@ void GuiEditCtrl::removeSelection( GuiControl* ctrl )
{
if( selectionContains( ctrl ) )
{
Vector< GuiControl* >::iterator i = ::find( mSelectedControls.begin(), mSelectedControls.end(), ctrl );
Vector< GuiControl* >::iterator i = T3D::find( mSelectedControls.begin(), mSelectedControls.end(), ctrl );
if ( i != mSelectedControls.end() )
mSelectedControls.erase( i );
@ -2468,7 +2468,7 @@ void GuiEditCtrl::startMouseGuideDrag( guideAxis axis, U32 guideIndex, bool lock
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, getContentControl, S32, (), , "() - Return the toplevel control edited inside the GUI editor." )
DefineEngineMethod( GuiEditCtrl, getContentControl, S32, (), , "() - Return the toplevel control edited inside the GUI editor." )
{
GuiControl* ctrl = object->getContentControl();
if( ctrl )
@ -2479,7 +2479,7 @@ DefineConsoleMethod( GuiEditCtrl, getContentControl, S32, (), , "() - Return the
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, setContentControl, void, (GuiControl *ctrl ), , "( GuiControl ctrl ) - Set the toplevel control to edit in the GUI editor." )
DefineEngineMethod( GuiEditCtrl, setContentControl, void, (GuiControl *ctrl ), , "( GuiControl ctrl ) - Set the toplevel control to edit in the GUI editor." )
{
if (ctrl)
object->setContentControl(ctrl);
@ -2487,7 +2487,7 @@ DefineConsoleMethod( GuiEditCtrl, setContentControl, void, (GuiControl *ctrl ),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, addNewCtrl, void, (GuiControl *ctrl), , "(GuiControl ctrl)")
DefineEngineMethod( GuiEditCtrl, addNewCtrl, void, (GuiControl *ctrl), , "(GuiControl ctrl)")
{
if (ctrl)
object->addNewControl(ctrl);
@ -2495,28 +2495,28 @@ DefineConsoleMethod( GuiEditCtrl, addNewCtrl, void, (GuiControl *ctrl), , "(GuiC
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, addSelection, void, (S32 id), , "selects a control.")
DefineEngineMethod( GuiEditCtrl, addSelection, void, (S32 id), , "selects a control.")
{
object->addSelection(id);
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, removeSelection, void, (S32 id), , "deselects a control.")
DefineEngineMethod( GuiEditCtrl, removeSelection, void, (S32 id), , "deselects a control.")
{
object->removeSelection(id);
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, clearSelection, void, (), , "Clear selected controls list.")
DefineEngineMethod( GuiEditCtrl, clearSelection, void, (), , "Clear selected controls list.")
{
object->clearSelection();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, select, void, (GuiControl *ctrl), , "(GuiControl ctrl)")
DefineEngineMethod( GuiEditCtrl, select, void, (GuiControl *ctrl), , "(GuiControl ctrl)")
{
if (ctrl)
object->setSelection(ctrl, false);
@ -2524,7 +2524,7 @@ DefineConsoleMethod( GuiEditCtrl, select, void, (GuiControl *ctrl), , "(GuiContr
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, (GuiControl *addSet), , "(GuiControl ctrl)")
DefineEngineMethod( GuiEditCtrl, setCurrentAddSet, void, (GuiControl *addSet), , "(GuiControl ctrl)")
{
if (addSet)
object->setCurrentAddSet(addSet);
@ -2532,7 +2532,7 @@ DefineConsoleMethod( GuiEditCtrl, setCurrentAddSet, void, (GuiControl *addSet),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, getCurrentAddSet, S32, (), , "Returns the set to which new controls will be added")
DefineEngineMethod( GuiEditCtrl, getCurrentAddSet, S32, (), , "Returns the set to which new controls will be added")
{
const GuiControl* add = object->getCurrentAddSet();
return add ? add->getId() : 0;
@ -2540,49 +2540,49 @@ DefineConsoleMethod( GuiEditCtrl, getCurrentAddSet, S32, (), , "Returns the set
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, toggle, void, (), , "Toggle activation.")
DefineEngineMethod( GuiEditCtrl, toggle, void, (), , "Toggle activation.")
{
object->setEditMode( !object->isActive() );
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, justify, void, (U32 mode), , "(int mode)" )
DefineEngineMethod( GuiEditCtrl, justify, void, (U32 mode), , "(int mode)" )
{
object->justifySelection( (GuiEditCtrl::Justification)mode );
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, bringToFront, void, (), , "")
DefineEngineMethod( GuiEditCtrl, bringToFront, void, (), , "")
{
object->bringToFront();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, pushToBack, void, (), , "")
DefineEngineMethod( GuiEditCtrl, pushToBack, void, (), , "")
{
object->pushToBack();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, deleteSelection, void, (), , "() - Delete the selected controls.")
DefineEngineMethod( GuiEditCtrl, deleteSelection, void, (), , "() - Delete the selected controls.")
{
object->deleteSelection();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, moveSelection, void, (S32 dx, S32 dy), , "Move all controls in the selection by (dx,dy) pixels.")
DefineEngineMethod( GuiEditCtrl, moveSelection, void, (S32 dx, S32 dy), , "Move all controls in the selection by (dx,dy) pixels.")
{
object->moveAndSnapSelection(Point2I(dx, dy));
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Save selection to file or clipboard.")
DefineEngineMethod( GuiEditCtrl, saveSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Save selection to file or clipboard.")
{
object->saveSelection( filename );
@ -2590,7 +2590,7 @@ DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, loadSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Load selection from file or clipboard.")
DefineEngineMethod( GuiEditCtrl, loadSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Load selection from file or clipboard.")
{
object->loadSelection( filename );
@ -2598,7 +2598,7 @@ DefineConsoleMethod( GuiEditCtrl, loadSelection, void, (const char * filename),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, selectAll, void, (), , "()")
DefineEngineMethod( GuiEditCtrl, selectAll, void, (), , "()")
{
object->selectAll();
}
@ -2613,27 +2613,27 @@ DefineEngineMethod( GuiEditCtrl, getSelection, SimSet*, (),,
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, getNumSelected, S32, (), , "() - Return the number of controls currently selected." )
DefineEngineMethod( GuiEditCtrl, getNumSelected, S32, (), , "() - Return the number of controls currently selected." )
{
return object->getNumSelected();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, (), , "() - Returns global bounds of current selection as vector 'x y width height'." )
DefineEngineMethod( GuiEditCtrl, getSelectionGlobalBounds, const char*, (), , "() - Returns global bounds of current selection as vector 'x y width height'." )
{
RectI bounds = object->getSelectionGlobalBounds();
String str = String::ToString( "%i %i %i %i", bounds.point.x, bounds.point.y, bounds.extent.x, bounds.extent.y );
char* buffer = Con::getReturnBuffer( str.length() );
dStrcpy( buffer, str.c_str() );
char* buffer = Con::getReturnBuffer( str.size() );
dStrcpy( buffer, str.c_str(), str.size() );
return buffer;
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, selectParents, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select parents of currently selected controls." )
DefineEngineMethod( GuiEditCtrl, selectParents, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select parents of currently selected controls." )
{
object->selectParents( addToSelection );
@ -2641,7 +2641,7 @@ DefineConsoleMethod( GuiEditCtrl, selectParents, void, ( bool addToSelection ),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, selectChildren, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select children of currently selected controls." )
DefineEngineMethod( GuiEditCtrl, selectChildren, void, ( bool addToSelection ), (false), "( bool addToSelection=false ) - Select children of currently selected controls." )
{
object->selectChildren( addToSelection );
@ -2657,14 +2657,14 @@ DefineEngineMethod( GuiEditCtrl, getTrash, SimGroup*, (),,
//-----------------------------------------------------------------------------
DefineConsoleMethod(GuiEditCtrl, setSnapToGrid, void, (U32 gridsize), , "GuiEditCtrl.setSnapToGrid(gridsize)")
DefineEngineMethod(GuiEditCtrl, setSnapToGrid, void, (U32 gridsize), , "GuiEditCtrl.setSnapToGrid(gridsize)")
{
object->setSnapToGrid(gridsize);
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, readGuides, void, ( GuiControl* ctrl, S32 axis ), (-1), "( GuiControl ctrl [, int axis ] ) - Read the guides from the given control." )
DefineEngineMethod( GuiEditCtrl, readGuides, void, ( GuiControl* ctrl, S32 axis ), (-1), "( GuiControl ctrl [, int axis ] ) - Read the guides from the given control." )
{
// Find the control.
@ -2694,7 +2694,7 @@ DefineConsoleMethod( GuiEditCtrl, readGuides, void, ( GuiControl* ctrl, S32 axis
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, writeGuides, void, ( GuiControl* ctrl, S32 axis ), ( -1), "( GuiControl ctrl [, int axis ] ) - Write the guides to the given control." )
DefineEngineMethod( GuiEditCtrl, writeGuides, void, ( GuiControl* ctrl, S32 axis ), ( -1), "( GuiControl ctrl [, int axis ] ) - Write the guides to the given control." )
{
// Find the control.
@ -2724,7 +2724,7 @@ DefineConsoleMethod( GuiEditCtrl, writeGuides, void, ( GuiControl* ctrl, S32 axi
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, clearGuides, void, ( S32 axis ), (-1), "( [ int axis ] ) - Clear all currently set guide lines." )
DefineEngineMethod( GuiEditCtrl, clearGuides, void, ( S32 axis ), (-1), "( [ int axis ] ) - Clear all currently set guide lines." )
{
if( axis != -1 )
{
@ -2745,7 +2745,7 @@ DefineConsoleMethod( GuiEditCtrl, clearGuides, void, ( S32 axis ), (-1), "( [ in
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, fitIntoParents, void, (bool width, bool height), (true, true), "( bool width=true, bool height=true ) - Fit selected controls into their parents." )
DefineEngineMethod( GuiEditCtrl, fitIntoParents, void, (bool width, bool height), (true, true), "( bool width=true, bool height=true ) - Fit selected controls into their parents." )
{
object->fitIntoParents( width, height );
@ -2753,7 +2753,7 @@ DefineConsoleMethod( GuiEditCtrl, fitIntoParents, void, (bool width, bool height
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, getMouseMode, const char*, (), , "() - Return the current mouse mode." )
DefineEngineMethod( GuiEditCtrl, getMouseMode, const char*, (), , "() - Return the current mouse mode." )
{
switch( object->getMouseMode() )
{

View file

@ -60,7 +60,7 @@ void GuiFilterCtrl::initPersistFields()
Parent::initPersistFields();
}
DefineConsoleMethod( GuiFilterCtrl, getValue, const char*, (), , "Return a tuple containing all the values in the filter."
DefineEngineMethod( GuiFilterCtrl, getValue, const char*, (), , "Return a tuple containing all the values in the filter."
"@internal")
{
static char buffer[512];
@ -70,14 +70,14 @@ DefineConsoleMethod( GuiFilterCtrl, getValue, const char*, (), , "Return a tuple
for (U32 i=0; i < filter->size(); i++)
{
char value[32];
dSprintf(value, 31, "%1.5f ", *(filter->begin()+i) );
dStrcat(buffer, value);
dSprintf(value, 32, "%1.5f ", *(filter->begin()+i) );
dStrcat(buffer, value, 32);
}
return buffer;
}
ConsoleMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, f2, ...)"
DefineEngineStringlyVariadicMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, f2, ...)"
"Reset the filter to use the specified points, spread equidistantly across the domain."
"@internal")
{
@ -89,7 +89,7 @@ ConsoleMethod( GuiFilterCtrl, setValue, void, 3, 20, "(f1, f2, ...)"
object->set(filter);
}
DefineConsoleMethod( GuiFilterCtrl, identity, void, (), , "Reset the filtering."
DefineEngineMethod( GuiFilterCtrl, identity, void, (), , "Reset the filtering."
"@internal")
{
object->identity();
@ -177,9 +177,9 @@ void GuiFilterCtrl::onRender(Point2I offset, const RectI &updateRect)
Point2I pos = offset;
Point2I ext = getExtent();
RectI r(pos, ext);
GFX->getDrawUtil()->drawRectFill(r, ColorI(255,255,255));
GFX->getDrawUtil()->drawRect(r, ColorI(0,0,0));
RectI bgRect(pos, ext);
GFX->getDrawUtil()->drawRectFill(bgRect, ColorI(255,255,255));
GFX->getDrawUtil()->drawRect(bgRect, ColorI(0,0,0));
// shrink by 2 pixels
pos.x += 2;
@ -218,13 +218,13 @@ void GuiFilterCtrl::onRender(Point2I offset, const RectI &updateRect)
// draw the knots
for (U32 k=0; k < mFilter.size(); k++)
{
RectI r;
r.point.x = (S32)(((F32)ext.x/(F32)(mFilter.size()-1)*(F32)k));
r.point.y = (S32)(ext.y - ((F32)ext.y * mFilter[k]));
r.point += pos + Point2I(-2,-2);
r.extent = Point2I(5,5);
RectI knotRect;
knotRect.point.x = (S32)(((F32)ext.x/(F32)(mFilter.size()-1)*(F32)k));
knotRect.point.y = (S32)(ext.y - ((F32)ext.y * mFilter[k]));
knotRect.point += pos + Point2I(-2,-2);
knotRect.extent = Point2I(5,5);
GFX->getDrawUtil()->drawRectFill(r, ColorI(255,0,0));
GFX->getDrawUtil()->drawRectFill(knotRect, ColorI(255,0,0));
}
renderChildControls(offset, updateRect);
@ -239,7 +239,7 @@ void Filter::set(S32 argc, const char *argv[])
if (argc == 1)
{ // in the form of one string "1.0 1.0 1.0"
char list[1024];
dStrcpy(list, *argv); // strtok modifies the string so we need to copy it
dStrcpy(list, *argv, 1024); // strtok modifies the string so we need to copy it
char *value = dStrtok(list, " ");
while (value)
{

View file

@ -168,7 +168,7 @@ void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
F32 Scale = F32( getExtent().y ) / F32( mGraphMax[ k ] * 1.05 );
const S32 numSamples = mGraphData[ k ].size();
F32 graphOffset;
switch( mGraphType[ k ] )
{
case Bar:
@ -180,21 +180,21 @@ void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
PrimBuild::begin( GFXTriangleStrip, 4 );
PrimBuild::color( mGraphColor[ k ] );
F32 offset = F32( getExtent().x ) / F32( MaxDataPoints ) * F32( sample + 1 );
graphOffset = F32( getExtent().x ) / F32( MaxDataPoints ) * F32( sample + 1 );
PrimBuild::vertex2f( globalPos.x + prevOffset,
midPointY - ( getDatum( k, sample ) * Scale ) );
PrimBuild::vertex2f( globalPos.x + offset,
PrimBuild::vertex2f( globalPos.x + graphOffset,
midPointY - ( getDatum( k, sample ) * Scale ) );
PrimBuild::vertex2f( globalPos.x + offset,
PrimBuild::vertex2f( globalPos.x + graphOffset,
midPointY );
PrimBuild::vertex2f( globalPos.x + prevOffset,
midPointY );
prevOffset = offset;
prevOffset = graphOffset;
PrimBuild::end();
}
@ -209,12 +209,12 @@ void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
for( S32 sample = 0; sample < numSamples; ++ sample )
{
F32 offset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );
graphOffset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );
PrimBuild::vertex2f( globalPos.x + offset,
PrimBuild::vertex2f( globalPos.x + graphOffset,
midPointY );
PrimBuild::vertex2f( globalPos.x + offset,
PrimBuild::vertex2f( globalPos.x + graphOffset,
midPointY - ( getDatum( k, sample ) * Scale ) );
}
@ -234,9 +234,9 @@ void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
for( S32 sample = 0; sample < numSamples; ++ sample )
{
F32 offset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );
graphOffset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );
PrimBuild::vertex2f( globalPos.x + offset,
PrimBuild::vertex2f( globalPos.x + graphOffset,
midPointY - ( getDatum( k, sample ) * Scale ) );
}
@ -407,7 +407,7 @@ DefineEngineMethod( GuiGraphCtrl, setGraphType, void, ( S32 plotId, GuiGraphType
//-----------------------------------------------------------------------------
ConsoleMethod( GuiGraphCtrl, matchScale, void, 3, GuiGraphCtrl::MaxPlots + 2, "( int plotID1, int plotID2, ... ) "
DefineEngineStringlyVariadicMethod( GuiGraphCtrl, matchScale, void, 3, GuiGraphCtrl::MaxPlots + 2, "( int plotID1, int plotID2, ... ) "
"Set the scale of all specified plots to the maximum scale among them.\n\n"
"@param plotID1 Index of plotting curve.\n"
"@param plotID2 Index of plotting curve." )

View file

@ -29,11 +29,10 @@
#include "gui/containers/guiScrollCtrl.h"
#include "gui/editor/inspector/customField.h"
#ifdef TORQUE_EXPERIMENTAL_EC
#include "gui/editor/inspector/entityGroup.h"
#include "gui/editor/inspector/mountingGroup.h"
#include "gui/editor/inspector/componentGroup.h"
#endif
#include "T3D/components/component.h"
IMPLEMENT_CONOBJECT(GuiInspector);
@ -55,7 +54,8 @@ GuiInspector::GuiInspector()
mOverDivider( false ),
mMovingDivider( false ),
mHLField( NULL ),
mShowCustomFields( true )
mShowCustomFields( true ),
mComponentGroupTargetId(-1)
{
mPadding = 1;
}
@ -589,10 +589,16 @@ void GuiInspector::refresh()
mGroups.push_back(general);
addObject(general);
#ifdef TORQUE_EXPERIMENTAL_EC
//Entity inspector group
if (mTargets.first()->getClassRep()->isSubclassOf("Entity"))
{
//Put the GameObject group before everything that'd be gameobject-effecting, for orginazational purposes
GuiInspectorGroup *gameObject = new GuiInspectorGroup("GameObject", this);
gameObject->registerObject();
mGroups.push_back(gameObject);
addObject(gameObject);
GuiInspectorEntityGroup *components = new GuiInspectorEntityGroup("Components", this);
if (components != NULL)
{
@ -601,6 +607,32 @@ void GuiInspector::refresh()
addObject(components);
}
Entity* selectedEntity = dynamic_cast<Entity*>(mTargets.first().getObject());
U32 compCount = selectedEntity->getComponentCount();
//Now, add the component groups
for (U32 c = 0; c < compCount; ++c)
{
Component* comp = selectedEntity->getComponent(c);
String compName;
if (comp->getFriendlyName() != StringTable->EmptyString())
compName = comp->getFriendlyName();
else
compName = comp->getComponentName();
StringBuilder captionString;
captionString.format("%s [%i]", compName.c_str(), comp->getId());
GuiInspectorGroup *compGroup = new GuiInspectorComponentGroup(captionString.data(), this, comp);
if (compGroup != NULL)
{
compGroup->registerObject();
mGroups.push_back(compGroup);
addObject(compGroup);
}
}
//Mounting group override
GuiInspectorGroup *mounting = new GuiInspectorMountingGroup("Mounting", this);
if (mounting != NULL)
@ -611,21 +643,6 @@ void GuiInspector::refresh()
}
}
if (mTargets.first()->getClassRep()->isSubclassOf("Component"))
{
//Build the component field groups as the component describes it
Component* comp = dynamic_cast<Component*>(mTargets.first().getPointer());
if (comp->getComponentFieldCount() > 0)
{
GuiInspectorComponentGroup *compGroup = new GuiInspectorComponentGroup("Component Fields", this);
compGroup->registerObject();
mGroups.push_back(compGroup);
addObject(compGroup);
}
}
#endif
// Create the inspector groups for static fields.
for( TargetVector::iterator iter = mTargets.begin(); iter != mTargets.end(); ++ iter )
@ -641,23 +658,23 @@ void GuiInspector::refresh()
if( !group && !isGroupFiltered( itr->pGroupname ) )
{
GuiInspectorGroup *group = new GuiInspectorGroup( itr->pGroupname, this );
GuiInspectorGroup *newGroup = new GuiInspectorGroup( itr->pGroupname, this );
group->registerObject();
if( !group->getNumFields() )
newGroup->registerObject();
if( !newGroup->getNumFields() )
{
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[GuiInspector] Removing empty group '%s'",
group->getCaption().c_str() );
newGroup->getCaption().c_str() );
#endif
// The group ended up having no fields. Remove it.
group->deleteObject();
newGroup->deleteObject();
}
else
{
mGroups.push_back( group );
addObject( group );
mGroups.push_back(newGroup);
addObject(newGroup);
}
}
}

View file

@ -89,6 +89,9 @@ public:
else
return nullptr;
}
S32 getComponentGroupTargetId() { return mComponentGroupTargetId; }
void setComponentGroupTargetId(S32 compId) { mComponentGroupTargetId = compId; }
/// Return the number of objects being inspected by this GuiInspector.
U32 getNumInspectObjects() const { return mTargets.size(); }
@ -146,6 +149,8 @@ protected:
/// Objects being inspected by this GuiInspector.
TargetVector mTargets;
S32 mComponentGroupTargetId;
F32 mDividerPos;
S32 mDividerMargin;

View file

@ -601,13 +601,12 @@ void GuiInspectorTypeFileName::updateValue()
}
}
ConsoleMethod( GuiInspectorTypeFileName, apply, void, 3,3, "apply(newValue);" )
DefineEngineMethod(GuiInspectorTypeFileName, apply, void, (String path), , "")
{
String path( (const char*)argv[2] );
if ( path.isNotEmpty() )
path = Platform::makeRelativePathName( path, Platform::getMainDotCsDir() );
object->setData( path.c_str() );
if (path.isNotEmpty())
path = Platform::makeRelativePathName(path, Platform::getMainDotCsDir());
object->setData(path.c_str());
}
@ -1035,7 +1034,6 @@ GuiControl* GuiInspectorTypeEaseF::constructEditControl()
mBrowseButton = new GuiButtonCtrl();
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
char szBuffer[512];
dSprintf( szBuffer, sizeof( szBuffer ), "GetEaseF(%d.getText(), \"%d.apply\", %d.getRoot());", retCtrl->getId(), getId(), getId() );
mBrowseButton->setField( "Command", szBuffer );
mBrowseButton->setField( "text", "E" );
@ -1502,7 +1500,7 @@ void GuiInspectorTypeBitMask32::updateData()
setData( data );
}
ConsoleMethod( GuiInspectorTypeBitMask32, applyBit, void, 2,2, "apply();" )
DefineEngineMethod( GuiInspectorTypeBitMask32, applyBit, void, (),, "" )
{
object->updateData();
}

File diff suppressed because it is too large Load diff

View file

@ -23,119 +23,43 @@
#ifndef _GUIMENUBAR_H_
#define _GUIMENUBAR_H_
#ifndef _GUITEXTLISTCTRL_H_
#include "gui/controls/guiTextListCtrl.h"
#endif
#ifndef _GUITICKCTRL_H_
#include "gui/shiny/guiTickCtrl.h"
#endif
#ifndef _POPUPMENU_H_
#include "gui/editor/popupMenu.h"
#endif
class GuiMenuBar;
class GuiMenuTextListCtrl;
class WindowInputGenerator;
class GuiMenuBackgroundCtrl : public GuiControl
{
typedef GuiControl Parent;
protected:
GuiMenuBar *mMenuBarCtrl;
GuiMenuTextListCtrl *mTextList;
public:
GuiMenuBackgroundCtrl(GuiMenuBar *ctrl, GuiMenuTextListCtrl* textList);
void onMouseDown(const GuiEvent &event);
void onMouseMove(const GuiEvent &event);
void onMouseDragged(const GuiEvent &event);
};
class GuiSubmenuBackgroundCtrl : public GuiMenuBackgroundCtrl
{
typedef GuiMenuBackgroundCtrl Parent;
public:
GuiSubmenuBackgroundCtrl(GuiMenuBar *ctrl, GuiMenuTextListCtrl* textList);
bool pointInControl(const Point2I & parentCoordPoint);
void onMouseDown(const GuiEvent &event);
};
//------------------------------------------------------------------------------
class GuiMenuTextListCtrl : public GuiTextListCtrl
{
private:
typedef GuiTextListCtrl Parent;
protected:
GuiMenuBar *mMenuBarCtrl;
public:
bool isSubMenu; // Indicates that this text list is in a submenu
GuiMenuTextListCtrl(); // for inheritance
GuiMenuTextListCtrl(GuiMenuBar *ctrl);
// GuiControl overloads:
bool onKeyDown(const GuiEvent &event);
void onMouseDown(const GuiEvent &event);
void onMouseUp(const GuiEvent &event);
void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver);
virtual void onCellHighlighted(Point2I cell); // Added
};
//------------------------------------------------------------------------------
class GuiMenuBar : public GuiTickCtrl // Was: GuiControl
{
typedef GuiTickCtrl Parent; // Was: GuiControl Parent;
public:
struct Menu;
struct MenuEntry
{
U32 pos;
RectI bounds;
struct MenuItem // an individual item in a pull-down menu
{
char *text; // the text of the menu item
U32 id; // a script-assigned identifier
char *accelerator; // the keyboard accelerator shortcut for the menu item
U32 acceleratorIndex; // index of this accelerator
bool enabled; // true if the menu item is selectable
bool visible; // true if the menu item is visible
S32 bitmapIndex; // index of the bitmap in the bitmap array
S32 checkGroup; // the group index of the item visa vi check marks -
// only one item in the group can be checked.
MenuItem *nextMenuItem; // next menu item in the linked list
bool isSubmenu; // This menu item has a submenu that will be displayed
Menu* submenuParentMenu; // For a submenu, this is the parent menu
Menu* submenu;
String cmd;
};
struct Menu
{
char *text;
U32 id;
RectI bounds;
bool visible;
S32 bitmapIndex; // Index of the bitmap in the bitmap array (-1 = no bitmap)
bool drawBitmapOnly; // Draw only the bitmap and not the text
bool drawBorder; // Should a border be drawn around this menu (usually if we only have a bitmap, we don't want a border)
S32 bitmapIndex;
bool drawBitmapOnly;
Menu *nextMenu;
MenuItem *firstMenuItem;
};
GuiMenuBackgroundCtrl *mBackground;
GuiMenuTextListCtrl *mTextList;
GuiSubmenuBackgroundCtrl *mSubmenuBackground; // Background for a submenu
GuiMenuTextListCtrl *mSubmenuTextList; // Text list for a submenu
bool drawBorder;
Vector<Menu*> mMenuList;
Menu *mouseDownMenu;
Menu *mouseOverMenu;
StringTableEntry text;
PopupMenu* popupMenu;
};
Vector<MenuEntry> mMenuList;
MenuEntry *mouseDownMenu;
MenuEntry *mouseOverMenu;
MenuItem* mouseDownSubmenu; // Stores the menu item that is a submenu that has been selected
MenuItem* mouseOverSubmenu; // Stores the menu item that is a submenu that has been highlighted
@ -151,59 +75,26 @@ public:
S32 mVerticalMargin; // Top and bottom margin around the text of each menu
S32 mBitmapMargin; // Margin between a menu's bitmap and text
// Used to keep track of the amount of ticks that the mouse is hovering
// over a menu.
S32 mMouseOverCounter;
bool mCountMouseOver;
S32 mMouseHoverAmount;
U32 mMenubarHeight;
bool mMouseInMenu;
GuiMenuBar();
void onRemove();
bool onWake();
void onSleep();
// internal menu handling functions
// these are used by the script manipulation functions to add/remove/change menu items
static Menu* sCreateMenu(const char *menuText, U32 menuId);
void addMenu(Menu *menu, S32 pos = -1);
void addMenu(const char *menuText, U32 menuId);
Menu *findMenu(const char *menu); // takes either a menu text or a string id
static MenuItem *findMenuItem(Menu *menu, const char *menuItem); // takes either a menu text or a string id
void removeMenu(Menu *menu);
static void removeMenuItem(Menu *menu, MenuItem *menuItem);
static MenuItem* addMenuItem(Menu *menu, const char *text, U32 id, const char *accelerator, S32 checkGroup, const char *cmd);
static MenuItem* addMenuItem(Menu *menu, MenuItem *menuItem);
static void clearMenuItems(Menu *menu);
void clearMenus();
virtual void addObject(SimObject* object);
void attachToMenuBar(Menu* menu, S32 pos = -1);
void removeFromMenuBar(Menu* menu);
// Methods to deal with submenus
static MenuItem* findSubmenuItem(Menu *menu, const char *menuItem, const char *submenuItem);
static MenuItem* findSubmenuItem(MenuItem *menuItem, const char *submenuItem);
static void addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text, U32 id, const char *accelerator, S32 checkGroup);
static void addSubmenuItem(Menu *menu, MenuItem *submenu, MenuItem *newMenuItem );
static void removeSubmenuItem(MenuItem *menuItem, MenuItem *submenuItem);
static void clearSubmenuItems(MenuItem *menuitem);
void onSubmenuAction(S32 selectionIndex, const RectI& bounds, Point2I cellSize);
void closeSubmenu();
void checkSubmenuMouseMove(const GuiEvent &event);
MenuItem *findHitMenuItem(Point2I mousePoint);
void highlightedMenuItem(S32 selectionIndex, const RectI& bounds, Point2I cellSize); // Called whenever a menu item is highlighted by the mouse
// display/mouse functions
Menu *findHitMenu(Point2I mousePoint);
// Called when the GUI theme changes and a bitmap arrary may need updating
// void onThemeChange();
MenuEntry *findHitMenu(Point2I mousePoint);
void onPreRender();
void onRender(Point2I offset, const RectI &updateRect);
void checkMenuMouseMove(const GuiEvent &event);
void onMouseMove(const GuiEvent &event);
void onMouseEnter(const GuiEvent &event);
void onMouseLeave(const GuiEvent &event);
void onMouseDown(const GuiEvent &event);
void onMouseDragged(const GuiEvent &event);
@ -215,18 +106,22 @@ public:
void removeWindowAcceleratorMap( WindowInputGenerator &inputGenerator );
void acceleratorKeyPress(U32 index);
virtual void menuItemSelected(Menu *menu, MenuItem *item);
// Added to support 'ticks'
void processTick();
void insert(SimObject* pObject, S32 pos);
static void initPersistFields();
U32 getMenuListCount() { return mMenuList.size(); }
PopupMenu* getMenu(U32 index);
PopupMenu* findMenu(StringTableEntry barTitle);
DECLARE_CONOBJECT(GuiMenuBar);
DECLARE_CALLBACK( void, onMouseInMenu, ( bool hasLeftMenu ));
DECLARE_CALLBACK( void, onMenuSelect, ( S32 menuId, const char* menuText ));
DECLARE_CALLBACK( void, onMenuItemSelect, ( S32 menuId, const char* menuText, S32 menuItemId, const char* menuItemText ));
DECLARE_CALLBACK( void, onSubmenuSelect, ( S32 submenuId, const char* submenuText ));
};
#endif

View file

@ -1004,7 +1004,7 @@ bool GuiParticleGraphCtrl::renderGraphTooltip(Point2I cursorPos, StringTableEntr
return true;
}
DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPoint, void, (S32 point), , "(int point)"
DefineEngineMethod(GuiParticleGraphCtrl, setSelectedPoint, void, (S32 point), , "(int point)"
"Set the selected point on the graph.\n"
"@return No return value")
{
@ -1016,7 +1016,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPoint, void, (S32 point), ,
object->setSelectedPoint( point );
}
DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPlot, void, (S32 plotID), , "(int plotID)"
DefineEngineMethod(GuiParticleGraphCtrl, setSelectedPlot, void, (S32 plotID), , "(int plotID)"
"Set the selected plot (a.k.a. graph)."
"@return No return value" )
{
@ -1028,7 +1028,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setSelectedPlot, void, (S32 plotID), ,
object->setSelectedPlot( plotID );
}
DefineConsoleMethod(GuiParticleGraphCtrl, clearGraph, void, (S32 plotID), , "(int plotID)"
DefineEngineMethod(GuiParticleGraphCtrl, clearGraph, void, (S32 plotID), , "(int plotID)"
"Clear the graph of the given plot."
"@return No return value")
{
@ -1040,14 +1040,14 @@ DefineConsoleMethod(GuiParticleGraphCtrl, clearGraph, void, (S32 plotID), , "(in
object->clearGraph( plotID );
}
DefineConsoleMethod(GuiParticleGraphCtrl, clearAllGraphs, void, (), , "()"
DefineEngineMethod(GuiParticleGraphCtrl, clearAllGraphs, void, (), , "()"
"Clear all of the graphs."
"@return No return value")
{
object->clearAllGraphs();
}
DefineConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x, F32 y, bool setAdded), (true), "(int plotID, float x, float y, bool setAdded = true;)"
DefineEngineMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x, F32 y, bool setAdded), (true), "(int plotID, float x, float y, bool setAdded = true;)"
"Add a data point to the given plot."
"@return")
{
@ -1060,7 +1060,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, S32, (S32 plotID, F32 x,
return object->addPlotPoint( plotID, Point2F(x, y), setAdded);
}
DefineConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)\n"
DefineEngineMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)\n"
"Insert a data point to the given plot and plot position.\n"
"@param plotID The plot you want to access\n"
"@param i The data point.\n"
@ -1075,7 +1075,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, insertPlotPoint, void, (S32 plotID, S3
object->insertPlotPoint( plotID, i, Point2F(x, y));
}
DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)"
DefineEngineMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32 i, F32 x, F32 y), , "(int plotID, int i, float x, float y)"
"Change a data point to the given plot and plot position.\n"
"@param plotID The plot you want to access\n"
"@param i The data point.\n"
@ -1090,21 +1090,21 @@ DefineConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, S32, (S32 plotID, S32
return object->changePlotPoint( plotID, i, Point2F(x, y));
}
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, S32, (), , "() "
DefineEngineMethod(GuiParticleGraphCtrl, getSelectedPlot, S32, (), , "() "
"Gets the selected Plot (a.k.a. graph).\n"
"@return The plot's ID.")
{
return object->getSelectedPlot();
}
DefineConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, S32, (), , "()"
DefineEngineMethod(GuiParticleGraphCtrl, getSelectedPoint, S32, (), , "()"
"Gets the selected Point on the Plot (a.k.a. graph)."
"@return The last selected point ID")
{
return object->getSelectedPoint();
}
DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S32 samples), , "(int plotID, int samples)"
DefineEngineMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S32 samples), , "(int plotID, int samples)"
"@return Returns true or false whether or not the point in the plot passed is an existing point.")
{
@ -1119,7 +1119,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, bool, (S32 plotID, S3
return object->isExistingPoint(plotID, samples);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S32 samples), , "(int plotID, int samples)"
DefineEngineMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S32 samples), , "(int plotID, int samples)"
"Get a data point from the plot specified, samples from the start of the graph."
"@return The data point ID")
{
@ -1137,7 +1137,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, Point2F, (S32 plotID, S3
return object->getPlotPoint(plotID, samples);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x, F32 y), , "(int plotID, float x, float y)\n"
DefineEngineMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x, F32 y), , "(int plotID, float x, float y)\n"
"Gets the index of the point passed on the plotID passed (graph ID).\n"
"@param plotID The plot you wish to check.\n"
"@param x,y The coordinates of the point to get.\n"
@ -1151,7 +1151,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, S32, (S32 plotID, F32 x,
return object->getPlotIndex(plotID, x, y);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, LinearColorF, (S32 plotID), , "(int plotID)"
DefineEngineMethod(GuiParticleGraphCtrl, getGraphColor, LinearColorF, (S32 plotID), , "(int plotID)"
"Get the color of the graph passed."
"@return Returns the color of the graph as a string of RGB values formatted as \"R G B\"")
{
@ -1165,7 +1165,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphColor, LinearColorF, (S32 plot
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), , "(int plotID) "
DefineEngineMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), , "(int plotID) "
"Get the minimum values of the graph ranges.\n"
"@return Returns the minimum of the range formatted as \"x-min y-min\"")
{
@ -1177,7 +1177,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMin, Point2F, (S32 plotID), ,
return object->getGraphMin(plotID);
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), , "(int plotID) "
DefineEngineMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), , "(int plotID) "
"Get the maximum values of the graph ranges.\n"
"@return Returns the maximum of the range formatted as \"x-max y-max\"")
{
@ -1190,7 +1190,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphMax, Point2F, (S32 plotID), ,
}
DefineConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID), , "(int plotID) "
DefineEngineMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID), , "(int plotID) "
"Get the name of the graph passed.\n"
"@return Returns the name of the plot")
{
@ -1207,7 +1207,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, (S32 plotID
return retBuffer;
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMin, void, (S32 plotID, F32 minX, F32 minY), , "(int plotID, float minX, float minY) "
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMin, void, (S32 plotID, F32 minX, F32 minY), , "(int plotID, float minX, float minY) "
"Set the min values of the graph of plotID.\n"
"@param plotID The plot to modify\n"
"@param minX,minY The minimum bound of the value range.\n"
@ -1223,7 +1223,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMin, void, (S32 plotID, F32 mi
object->setGraphMin(plotID, Point2F(minX, minY));
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinX, void, (S32 plotID, F32 minX), , "(int plotID, float minX) "
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMinX, void, (S32 plotID, F32 minX), , "(int plotID, float minX) "
"Set the min X value of the graph of plotID.\n"
"@param plotID The plot to modify.\n"
"@param minX The minimum x value.\n"
@ -1239,7 +1239,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinX, void, (S32 plotID, F32 m
object->setGraphMinX(plotID, minX);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinY, void, (S32 plotID, F32 minX), , "(int plotID, float minY) "
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMinY, void, (S32 plotID, F32 minX), , "(int plotID, float minY) "
"Set the min Y value of the graph of plotID."
"@param plotID The plot to modify.\n"
"@param minY The minimum y value.\n"
@ -1255,7 +1255,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMinY, void, (S32 plotID, F32 m
object->setGraphMinY(plotID, minX);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMax, void, (S32 plotID, F32 maxX, F32 maxY), , "(int plotID, float maxX, float maxY) "
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMax, void, (S32 plotID, F32 maxX, F32 maxY), , "(int plotID, float maxX, float maxY) "
"Set the max values of the graph of plotID."
"@param plotID The plot to modify\n"
"@param maxX,maxY The maximum bound of the value range.\n"
@ -1271,7 +1271,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMax, void, (S32 plotID, F32 ma
object->setGraphMax(plotID, Point2F(maxX, maxY));
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxX, void, (S32 plotID, F32 maxX), , "(int plotID, float maxX)"
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMaxX, void, (S32 plotID, F32 maxX), , "(int plotID, float maxX)"
"Set the max X value of the graph of plotID."
"@param plotID The plot to modify.\n"
"@param maxX The maximum x value.\n"
@ -1287,7 +1287,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxX, void, (S32 plotID, F32 m
object->setGraphMaxX(plotID, maxX);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxY, void, (S32 plotID, F32 maxX), , "(int plotID, float maxY)"
DefineEngineMethod(GuiParticleGraphCtrl, setGraphMaxY, void, (S32 plotID, F32 maxX), , "(int plotID, float maxY)"
"Set the max Y value of the graph of plotID."
"@param plotID The plot to modify.\n"
"@param maxY The maximum y value.\n"
@ -1303,7 +1303,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphMaxY, void, (S32 plotID, F32 m
object->setGraphMaxY(plotID, maxX);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphHidden, void, (S32 plotID, bool isHidden), , "(int plotID, bool isHidden)"
DefineEngineMethod(GuiParticleGraphCtrl, setGraphHidden, void, (S32 plotID, bool isHidden), , "(int plotID, bool isHidden)"
"Set whether the graph number passed is hidden or not."
"@return No return value.")
{
@ -1317,7 +1317,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphHidden, void, (S32 plotID, boo
object->setGraphHidden(plotID, isHidden);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setAutoGraphMax, void, (bool autoMax), , "(bool autoMax) "
DefineEngineMethod(GuiParticleGraphCtrl, setAutoGraphMax, void, (bool autoMax), , "(bool autoMax) "
"Set whether the max will automatically be set when adding points "
"(ie if you add a value over the current max, the max is increased to that value).\n"
"@return No return value.")
@ -1325,35 +1325,35 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setAutoGraphMax, void, (bool autoMax),
object->setAutoGraphMax(autoMax);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setAutoRemove, void, (bool autoRemove), , "(bool autoRemove) "
DefineEngineMethod(GuiParticleGraphCtrl, setAutoRemove, void, (bool autoRemove), , "(bool autoRemove) "
"Set whether or not a point should be deleted when you drag another one over it."
"@return No return value.")
{
object->setAutoRemove(autoRemove);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setRenderAll, void, (bool autoRemove), , "(bool renderAll)"
DefineEngineMethod(GuiParticleGraphCtrl, setRenderAll, void, (bool autoRemove), , "(bool renderAll)"
"Set whether or not a position should be rendered on every point or just the last selected."
"@return No return value.")
{
object->setRenderAll(autoRemove);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setPointXMovementClamped, void, (bool autoRemove), , "(bool clamped)"
DefineEngineMethod(GuiParticleGraphCtrl, setPointXMovementClamped, void, (bool autoRemove), , "(bool clamped)"
"Set whether the x position of the selected graph point should be clamped"
"@return No return value.")
{
object->setPointXMovementClamped(autoRemove);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setRenderGraphTooltip, void, (bool autoRemove), , "(bool renderGraphTooltip)"
DefineEngineMethod(GuiParticleGraphCtrl, setRenderGraphTooltip, void, (bool autoRemove), , "(bool renderGraphTooltip)"
"Set whether or not to render the graph tooltip."
"@return No return value.")
{
object->setRenderGraphTooltip(autoRemove);
}
DefineConsoleMethod(GuiParticleGraphCtrl, setGraphName, void, (S32 plotID, const char * graphName), , "(int plotID, string graphName) "
DefineEngineMethod(GuiParticleGraphCtrl, setGraphName, void, (S32 plotID, const char * graphName), , "(int plotID, string graphName) "
"Set the name of the given plot.\n"
"@param plotID The plot to modify.\n"
"@param graphName The name to set on the plot.\n"
@ -1369,7 +1369,7 @@ DefineConsoleMethod(GuiParticleGraphCtrl, setGraphName, void, (S32 plotID, const
object->setGraphName(plotID, graphName);
}
DefineConsoleMethod(GuiParticleGraphCtrl, resetSelectedPoint, void, (), , "()"
DefineEngineMethod(GuiParticleGraphCtrl, resetSelectedPoint, void, (), , "()"
"This will reset the currently selected point to nothing."
"@return No return value.")
{

View file

@ -25,20 +25,32 @@
#include "gfx/primBuilder.h"
#include "gui/core/guiCanvas.h"
GuiPopupMenuBackgroundCtrl::GuiPopupMenuBackgroundCtrl(GuiPopupMenuTextListCtrl *textList)
GuiPopupMenuBackgroundCtrl::GuiPopupMenuBackgroundCtrl()
{
mTextList = textList;
mTextList->mBackground = this;
mMenuBarCtrl = nullptr;
}
void GuiPopupMenuBackgroundCtrl::onMouseDown(const GuiEvent &event)
{
mTextList->setSelectedCell(Point2I(-1, -1));
}
void GuiPopupMenuBackgroundCtrl::onMouseUp(const GuiEvent &event)
{
clearPopups();
//Pass along the event just in case we clicked over a menu item. We don't want to eat the input for it.
if (mMenuBarCtrl)
mMenuBarCtrl->onMouseUp(event);
close();
}
void GuiPopupMenuBackgroundCtrl::onMouseMove(const GuiEvent &event)
{
//It's possible we're trying to pan through a menubar while a popup is displayed. Pass along our event to the menubar for good measure
if (mMenuBarCtrl)
mMenuBarCtrl->onMouseMove(event);
}
void GuiPopupMenuBackgroundCtrl::onMouseDragged(const GuiEvent &event)
@ -47,27 +59,66 @@ void GuiPopupMenuBackgroundCtrl::onMouseDragged(const GuiEvent &event)
void GuiPopupMenuBackgroundCtrl::close()
{
getRoot()->removeObject(this);
if(getRoot())
getRoot()->removeObject(this);
mMenuBarCtrl = nullptr;
}
S32 GuiPopupMenuBackgroundCtrl::findPopupMenu(PopupMenu* menu)
{
S32 menuId = -1;
for (U32 i = 0; i < mPopups.size(); i++)
{
if (mPopups[i]->getId() == menu->getId())
return i;
}
return menuId;
}
void GuiPopupMenuBackgroundCtrl::clearPopups()
{
for (U32 i = 0; i < mPopups.size(); i++)
{
mPopups[i]->mTextList->setSelectedCell(Point2I(-1, -1));
mPopups[i]->mTextList->mPopup->hidePopup();
}
}
GuiPopupMenuTextListCtrl::GuiPopupMenuTextListCtrl()
{
isSubMenu = false; // Added
mMenu = NULL;
mMenuBar = NULL;
mPopup = NULL;
mMenuBar = nullptr;
mPopup = nullptr;
mLastHighlightedMenuIdx = -1;
}
void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
if (dStrcmp(mList[cell.y].text + 3, "-\t")) // Was: dStrcmp(mList[cell.y].text + 2, "-\t")) but has been changed to take into account the submenu flag
Parent::onRenderCell(offset, cell, selected, mouseOver);
else
//check if we're a real entry, or if it's a divider
if (mPopup->mMenuItems[cell.y].mIsSpacer)
{
S32 yp = offset.y + mCellSize.y / 2;
GFX->getDrawUtil()->drawLine(offset.x, yp, offset.x + mCellSize.x, yp, ColorI(128, 128, 128));
GFX->getDrawUtil()->drawLine(offset.x, yp + 1, offset.x + mCellSize.x, yp + 1, ColorI(255, 255, 255));
GFX->getDrawUtil()->drawLine(offset.x + 5, yp, offset.x + mCellSize.x - 5, yp, ColorI(128, 128, 128));
}
else
{
if (dStrcmp(mList[cell.y].text + 3, "-\t")) // Was: dStrcmp(mList[cell.y].text + 2, "-\t")) but has been changed to take into account the submenu flag
{
Parent::onRenderCell(offset, cell, selected, mouseOver);
}
else
{
S32 yp = offset.y + mCellSize.y / 2;
GFX->getDrawUtil()->drawLine(offset.x, yp, offset.x + mCellSize.x, yp, ColorI(128, 128, 128));
GFX->getDrawUtil()->drawLine(offset.x, yp + 1, offset.x + mCellSize.x, yp + 1, ColorI(255, 255, 255));
}
}
// now see if there's a bitmap...
U8 idx = mList[cell.y].text[0];
if (idx != 1)
@ -101,16 +152,22 @@ void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool s
S32 bottom = top + 8;
S32 middle = top + 4;
PrimBuild::begin(GFXTriangleList, 3);
if (selected || mouseOver)
PrimBuild::color(mProfile->mFontColorHL);
else
PrimBuild::color(mProfile->mFontColor);
//PrimBuild::begin(GFXTriangleList, 3);
PrimBuild::vertex2i(left, top);
ColorI color = ColorI::BLACK;
if (selected || mouseOver)
color = mProfile->mFontColorHL;
else
color = mProfile->mFontColor;
GFX->getDrawUtil()->drawLine(Point2I(left, top), Point2I(right, middle), color);
GFX->getDrawUtil()->drawLine(Point2I(right, middle), Point2I(left, bottom), color);
GFX->getDrawUtil()->drawLine(Point2I(left, bottom), Point2I(left, top), color);
/*PrimBuild::vertex2i(left, top);
PrimBuild::vertex2i(right, middle);
PrimBuild::vertex2i(left, bottom);
PrimBuild::end();
PrimBuild::end();*/
}
}
@ -153,17 +210,12 @@ void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
if (selectionIndex != -1)
{
GuiMenuBar::MenuItem *list = mMenu->firstMenuItem;
MenuItem *item = &mPopup->mMenuItems[selectionIndex];
while (selectionIndex && list)
if (item)
{
list = list->nextMenuItem;
selectionIndex--;
}
if (list)
{
if (list->enabled)
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), list->text ? list->text : ""));
if (item->mEnabled)
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : ""));
}
}
@ -181,4 +233,23 @@ void GuiPopupMenuTextListCtrl::onCellHighlighted(Point2I cell)
Point2I globalpoint = localToGlobalCoord(globalbounds.point);
globalbounds.point = globalpoint;
}
S32 selectionIndex = cell.y;
if (selectionIndex != -1 && mLastHighlightedMenuIdx != selectionIndex)
{
mLastHighlightedMenuIdx = selectionIndex;
mPopup->hidePopupSubmenus();
}
if (selectionIndex != -1)
{
MenuItem *list = &mPopup->mMenuItems[selectionIndex];
if (list->mIsSubmenu && list->mSubMenu != nullptr)
{
list->mSubMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y));
}
}
}

View file

@ -42,6 +42,7 @@ class GuiPopupMenuBackgroundCtrl;
class GuiPopupMenuTextListCtrl : public GuiTextListCtrl
{
friend class GuiPopupMenuBackgroundCtrl;
friend class PopupMenu;
private:
typedef GuiTextListCtrl Parent;
@ -51,10 +52,12 @@ private:
public:
bool isSubMenu; // Indicates that this text list is in a submenu
Point2I maxBitmapSize;
GuiMenuBar::Menu* mMenu;
GuiMenuBar* mMenuBar;
PopupMenu* mPopup;
S32 mLastHighlightedMenuIdx;
GuiPopupMenuTextListCtrl();
// GuiControl overloads:
@ -70,16 +73,21 @@ class GuiPopupMenuBackgroundCtrl : public GuiControl
{
typedef GuiControl Parent;
protected:
GuiPopupMenuTextListCtrl *mTextList;
public:
GuiPopupMenuBackgroundCtrl(GuiPopupMenuTextListCtrl* textList);
GuiPopupMenuBackgroundCtrl();
void onMouseDown(const GuiEvent &event);
void onMouseUp(const GuiEvent &event);
void onMouseMove(const GuiEvent &event);
void onMouseDragged(const GuiEvent &event);
void close();
void clearPopups();
S32 findPopupMenu(PopupMenu* menu);
Vector<PopupMenu*> mPopups;
GuiMenuBar* mMenuBarCtrl;
};
#endif

View file

@ -366,8 +366,8 @@ bool GuiShapeEdPreview::setObjectModel(const char* modelName)
mOrbitPos = shape->center;
// Set camera move and zoom speed according to model size
mMoveSpeed = shape->radius / sMoveScaler;
mZoomSpeed = shape->radius / sZoomScaler;
mMoveSpeed = shape->mRadius / sMoveScaler;
mZoomSpeed = shape->mRadius / sZoomScaler;
// Reset node selection
mHoverNode = -1;
@ -853,7 +853,7 @@ void GuiShapeEdPreview::exportToCollada( const String& path )
if ( mModel )
{
MatrixF orientation( true );
orientation.setPosition( mModel->getShape()->bounds.getCenter() );
orientation.setPosition( mModel->getShape()->mBounds.getCenter() );
orientation.inverse();
OptimizedPolyList polyList;
@ -926,8 +926,8 @@ void GuiShapeEdPreview::handleMouseDown(const GuiEvent& event, GizmoMode mode)
}
}
if ( mode == RotateMode )
mRenderCameraAxes = true;
//if ( mode == RotateMode )
// mRenderCameraAxes = true;
}
void GuiShapeEdPreview::handleMouseUp(const GuiEvent& event, GizmoMode mode)
@ -941,8 +941,8 @@ void GuiShapeEdPreview::handleMouseUp(const GuiEvent& event, GizmoMode mode)
mGizmo->on3DMouseUp( mLastEvent );
}
if ( mode == RotateMode )
mRenderCameraAxes = false;
//if ( mode == RotateMode )
// mRenderCameraAxes = false;
}
void GuiShapeEdPreview::handleMouseMove(const GuiEvent& event, GizmoMode mode)
@ -1138,8 +1138,8 @@ bool GuiShapeEdPreview::getCameraTransform(MatrixF* cameraMatrix)
cameraMatrix->identity();
if ( mModel )
{
Point3F camPos = mModel->getShape()->bounds.getCenter();
F32 offset = mModel->getShape()->bounds.len();
Point3F camPos = mModel->getShape()->mBounds.getCenter();
F32 offset = mModel->getShape()->mBounds.len();
switch (mDisplayType)
{
@ -1164,6 +1164,19 @@ void GuiShapeEdPreview::computeSceneBounds(Box3F& bounds)
{
if ( mModel )
mModel->computeBounds( mCurrentDL, bounds );
if (bounds.getExtents().x < POINT_EPSILON || bounds.getExtents().y < POINT_EPSILON || bounds.getExtents().z < POINT_EPSILON)
{
bounds.set(Point3F::Zero);
//We probably don't have any actual meshes in this model, so compute using the bones if we have them
for (S32 i = 0; i < mModel->getShape()->nodes.size(); i++)
{
Point3F nodePos = mModel->mNodeTransforms[i].getPosition();
bounds.extend(nodePos);
}
}
}
void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
@ -1231,9 +1244,9 @@ void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
continue;
// Count the number of draw calls and materials
mNumDrawCalls += mesh->primitives.size();
for ( S32 iPrim = 0; iPrim < mesh->primitives.size(); iPrim++ )
usedMaterials.push_back_unique( mesh->primitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask );
mNumDrawCalls += mesh->mPrimitives.size();
for ( S32 iPrim = 0; iPrim < mesh->mPrimitives.size(); iPrim++ )
usedMaterials.push_back_unique( mesh->mPrimitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask );
// For skinned meshes, count the number of bones and weights
if ( mesh->getMeshType() == TSMesh::SkinMeshType )
@ -1429,7 +1442,7 @@ void GuiShapeEdPreview::renderWorld(const RectI &updateRect)
// Render the shape bounding box
if ( mRenderBounds )
{
Point3F boxSize = mModel->getShape()->bounds.maxExtents - mModel->getShape()->bounds.minExtents;
Point3F boxSize = mModel->getShape()->mBounds.maxExtents - mModel->getShape()->mBounds.minExtents;
GFXStateBlockDesc desc;
desc.fillMode = GFXFillWireframe;
@ -1531,7 +1544,7 @@ void GuiShapeEdPreview::renderSunDirection() const
{
// Render four arrows aiming in the direction of the sun's light
ColorI color = LinearColorF( mFakeSun->getColor()).toColorI();
F32 length = mModel->getShape()->bounds.len() * 0.8f;
F32 length = mModel->getShape()->mBounds.len() * 0.8f;
// Get the sun's vectors
Point3F fwd = mFakeSun->getTransform().getForwardVector();

View file

@ -38,10 +38,11 @@ ConsoleDocClass(GuiInspectorComponentGroup,
"@internal"
);
GuiInspectorComponentGroup::GuiInspectorComponentGroup(StringTableEntry groupName, SimObjectPtr<GuiInspector> parent)
GuiInspectorComponentGroup::GuiInspectorComponentGroup(StringTableEntry groupName, SimObjectPtr<GuiInspector> parent, Component* targetComponent)
: GuiInspectorGroup(groupName, parent)
{
/*mNeedScroll=false;*/
mTargetComponent = targetComponent;
};
bool GuiInspectorComponentGroup::onAdd()
@ -89,15 +90,277 @@ bool GuiInspectorComponentGroup::inspectGroup()
GuiRolloutCtrl *pArrayRollout = NULL;
bool bGrabItems = false;
Component* comp = dynamic_cast<Component*>(getInspector()->getInspectObject(0));
//if this isn't a component, what are we even doing here?
if (!comp)
if (!mTargetComponent)
return false;
for (U32 i = 0; i < comp->getComponentFieldCount(); i++)
mParent->setComponentGroupTargetId(mTargetComponent->getId());
//first, relevent static fields
AbstractClassRep::FieldList& fieldList = mTargetComponent->getClassRep()->mFieldList;
for (AbstractClassRep::FieldList::iterator itr = fieldList.begin();
itr != fieldList.end(); ++itr)
{
ComponentField* field = comp->getComponentField(i);
AbstractClassRep::Field* field = &(*itr);
if (field->type == AbstractClassRep::StartGroupFieldType)
{
// If we're dealing with general fields, always set grabItems to true (to skip them)
if (bNoGroup == true)
bGrabItems = true;
else if (dStricmp(field->pGroupname, mCaption) == 0)
bGrabItems = true;
continue;
}
else if (field->type == AbstractClassRep::EndGroupFieldType)
{
// If we're dealing with general fields, always set grabItems to false (to grab them)
if (bNoGroup == true)
bGrabItems = false;
else if (dStricmp(field->pGroupname, mCaption) == 0)
bGrabItems = false;
continue;
}
// Skip field if it has the HideInInspectors flag set.
if (field->flag.test(AbstractClassRep::FIELD_HideInInspectors))
continue;
if (field->pFieldname == StringTable->insert("locked") || field->pFieldname == StringTable->insert("class")
|| field->pFieldname == StringTable->insert("internalName"))
continue;
if (/*(bGrabItems == true || (bNoGroup == true && bGrabItems == false)) &&*/ itr->type != AbstractClassRep::DeprecatedFieldType)
{
if (bNoGroup == true && bGrabItems == true)
continue;
if (field->type == AbstractClassRep::StartArrayFieldType)
{
#ifdef DEBUG_SPEW
Platform::outputDebugString("[GuiInspectorGroup] Beginning array '%s'",
field->pFieldname);
#endif
// Starting an array...
// Create a rollout for the Array, give it the array's name.
GuiRolloutCtrl *arrayRollout = new GuiRolloutCtrl();
GuiControlProfile *arrayRolloutProfile = dynamic_cast<GuiControlProfile*>(Sim::findObject("GuiInspectorRolloutProfile0"));
arrayRollout->setControlProfile(arrayRolloutProfile);
//arrayRollout->mCaption = StringTable->insert( String::ToString( "%s (%i)", field->pGroupname, field->elementCount ) );
arrayRollout->setCaption(field->pGroupname);
//arrayRollout->setMargin( 14, 0, 0, 0 );
arrayRollout->registerObject();
GuiStackControl *arrayStack = new GuiStackControl();
arrayStack->registerObject();
arrayStack->freeze(true);
arrayRollout->addObject(arrayStack);
// Allocate a rollout for each element-count in the array
// Give it the element count name.
for (U32 i = 0; i < field->elementCount; i++)
{
GuiRolloutCtrl *elementRollout = new GuiRolloutCtrl();
GuiControlProfile *elementRolloutProfile = dynamic_cast<GuiControlProfile*>(Sim::findObject("GuiInspectorRolloutProfile0"));
char buf[256];
dSprintf(buf, 256, " [%i]", i);
elementRollout->setControlProfile(elementRolloutProfile);
elementRollout->setCaption(buf);
//elementRollout->setMargin( 14, 0, 0, 0 );
elementRollout->registerObject();
GuiStackControl *elementStack = new GuiStackControl();
elementStack->registerObject();
elementRollout->addObject(elementStack);
elementRollout->instantCollapse();
arrayStack->addObject(elementRollout);
}
pArrayRollout = arrayRollout;
pArrayStack = arrayStack;
arrayStack->freeze(false);
pArrayRollout->instantCollapse();
mStack->addObject(arrayRollout);
bMakingArray = true;
continue;
}
else if (field->type == AbstractClassRep::EndArrayFieldType)
{
#ifdef DEBUG_SPEW
Platform::outputDebugString("[GuiInspectorGroup] Ending array '%s'",
field->pFieldname);
#endif
bMakingArray = false;
continue;
}
if (bMakingArray)
{
// Add a GuiInspectorField for this field,
// for every element in the array...
for (U32 i = 0; i < pArrayStack->size(); i++)
{
FrameTemp<char> intToStr(64);
dSprintf(intToStr, 64, "%d", i);
// The array stack should have a rollout for each element
// as children...
GuiRolloutCtrl *pRollout = dynamic_cast<GuiRolloutCtrl*>(pArrayStack->at(i));
// And the each of those rollouts should have a stack for
// fields...
GuiStackControl *pStack = dynamic_cast<GuiStackControl*>(pRollout->at(0));
// And we add a new GuiInspectorField to each of those stacks...
GuiInspectorField *fieldGui = constructField(field->type);
if (fieldGui == NULL)
fieldGui = new GuiInspectorField();
fieldGui->init(mParent, this);
StringTableEntry caption = field->pFieldname;
fieldGui->setInspectorField(field, caption, intToStr);
if (fieldGui->registerObject())
{
#ifdef DEBUG_SPEW
Platform::outputDebugString("[GuiInspectorGroup] Adding array element '%s[%i]'",
field->pFieldname, i);
#endif
mChildren.push_back(fieldGui);
pStack->addObject(fieldGui);
}
else
delete fieldGui;
}
continue;
}
// This is weird, but it should work for now. - JDD
// We are going to check to see if this item is an array
// if so, we're going to construct a field for each array element
if (field->elementCount > 1)
{
// Make a rollout control for this array
//
GuiRolloutCtrl *rollout = new GuiRolloutCtrl();
rollout->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorRolloutProfile0");
rollout->setCaption(String::ToString("%s (%i)", field->pFieldname, field->elementCount));
rollout->setMargin(14, 0, 0, 0);
rollout->registerObject();
mArrayCtrls.push_back(rollout);
// Put a stack control within the rollout
//
GuiStackControl *stack = new GuiStackControl();
stack->setDataField(StringTable->insert("profile"), NULL, "GuiInspectorStackProfile");
stack->registerObject();
stack->freeze(true);
rollout->addObject(stack);
mStack->addObject(rollout);
// Create each field and add it to the stack.
//
for (S32 nI = 0; nI < field->elementCount; nI++)
{
FrameTemp<char> intToStr(64);
dSprintf(intToStr, 64, "%d", nI);
// Construct proper ValueName[nI] format which is "ValueName0" for index 0, etc.
String fieldName = String::ToString("%s%d", field->pFieldname, nI);
// If the field already exists, just update it
GuiInspectorField *fieldGui = findField(fieldName);
if (fieldGui != NULL)
{
fieldGui->updateValue();
continue;
}
bNewItems = true;
fieldGui = constructField(field->type);
if (fieldGui == NULL)
fieldGui = new GuiInspectorField();
fieldGui->init(mParent, this);
StringTableEntry caption = StringTable->insert(String::ToString(" [%i]", nI));
fieldGui->setInspectorField(field, caption, intToStr);
fieldGui->setTargetObject(mTargetComponent);
if (fieldGui->registerObject())
{
mChildren.push_back(fieldGui);
stack->addObject(fieldGui);
}
else
delete fieldGui;
}
stack->freeze(false);
stack->updatePanes();
rollout->instantCollapse();
}
else
{
// If the field already exists, just update it
GuiInspectorField *fieldGui = findField(field->pFieldname);
if (fieldGui != NULL)
{
fieldGui->updateValue();
continue;
}
bNewItems = true;
fieldGui = constructField(field->type);
if (fieldGui == NULL)
fieldGui = new GuiInspectorField();
fieldGui->init(mParent, this);
fieldGui->setInspectorField(field);
fieldGui->setTargetObject(mTargetComponent);
if (fieldGui->registerObject())
{
#ifdef DEBUG_SPEW
Platform::outputDebugString("[GuiInspectorGroup] Adding field '%s'",
field->pFieldname);
#endif
fieldGui->setValue(mTargetComponent->getDataField(field->pFieldname, NULL));
mChildren.push_back(fieldGui);
mStack->addObject(fieldGui);
}
else
{
SAFE_DELETE(fieldGui);
}
}
}
}
for (U32 i = 0; i < mTargetComponent->getComponentFieldCount(); i++)
{
ComponentField* field = mTargetComponent->getComponentField(i);
//first and foremost, nab the field type and check if it's a custom field or not.
//If it's not a custom field, proceed below, if it is, hand it off to script to be handled by the component
if (field->mFieldType == -1)
{
Con::executef(this, "onConstructComponentField", mTargetComponent, field->mFieldName);
continue;
}
bNewItems = true;
@ -107,10 +370,12 @@ bool GuiInspectorComponentGroup::inspectGroup()
fieldGui->init(mParent, this);
AbstractClassRep::Field *refField;
fieldGui->setTargetObject(mTargetComponent);
AbstractClassRep::Field *refField = NULL;
//check dynamics
SimFieldDictionary* fieldDictionary = comp->getFieldDictionary();
SimFieldDictionary* fieldDictionary = mTargetComponent->getFieldDictionary();
SimFieldDictionaryIterator itr(fieldDictionary);
while (*itr)
@ -196,7 +461,15 @@ void GuiInspectorComponentGroup::onMouseMove(const GuiEvent &event)
{
//mParent->mOverDivider = false;
}
ConsoleMethod(GuiInspectorComponentGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
void GuiInspectorComponentGroup::onRightMouseUp(const GuiEvent &event)
{
//mParent->mOverDivider = false;
if (isMethod("onRightMouseUp"))
Con::executef(this, "onRightMouseUp", event.mousePoint);
}
DefineEngineMethod(GuiInspectorComponentGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -242,11 +515,17 @@ AbstractClassRep::Field* GuiInspectorComponentGroup::findObjectBehaviorField(Com
}
return NULL;
}
ConsoleMethod(GuiInspectorComponentGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();")
DefineEngineMethod(GuiInspectorComponentGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod(GuiInspectorComponentGroup, removeDynamicField, void, 3, 3, "")
DefineEngineMethod(GuiInspectorComponentGroup, removeDynamicField, void, (), , "")
{
}
DefineEngineMethod(GuiInspectorComponentGroup, getComponent, S32, (), , "")
{
return object->getComponent()->getId();
}

View file

@ -34,12 +34,14 @@ private:
typedef GuiInspectorGroup Parent;
GuiControl* mAddCtrl;
Component* mTargetComponent;
Vector<AbstractClassRep::Field> tempFields;
public:
DECLARE_CONOBJECT(GuiInspectorComponentGroup);
GuiInspectorComponentGroup() { /*mNeedScroll=false;*/ };
GuiInspectorComponentGroup(StringTableEntry groupName, SimObjectPtr<GuiInspector> parent);
GuiInspectorComponentGroup(StringTableEntry groupName, SimObjectPtr<GuiInspector> parent, Component* targetComponent);
//-----------------------------------------------------------------------------
// inspectGroup is overridden in GuiInspectorComponentGroup to inspect an
@ -50,6 +52,7 @@ public:
virtual void updateAllFields();
void onMouseMove(const GuiEvent &event);
virtual void onRightMouseUp(const GuiEvent &event);
// For scriptable dynamic field additions
void addDynamicField();
@ -61,6 +64,9 @@ public:
virtual SimFieldDictionary::Entry* findDynamicFieldInDictionary(StringTableEntry fieldName);
AbstractClassRep::Field* findObjectBehaviorField(Component* target, String fieldName);
Component* getComponent() { return mTargetComponent; }
protected:
// create our inner controls when we add
virtual bool createContent();

View file

@ -316,7 +316,7 @@ void GuiInspectorDynamicField::_executeSelectedCallback()
Con::executef( mInspector, "onFieldSelected", mDynField->slotName, "TypeDynamicField" );
}
DefineConsoleMethod( GuiInspectorDynamicField, renameField, void, (const char* newDynamicFieldName),, "field.renameField(newDynamicFieldName);" )
DefineEngineMethod( GuiInspectorDynamicField, renameField, void, (const char* newDynamicFieldName),, "field.renameField(newDynamicFieldName);" )
{
object->renameField( newDynamicFieldName );
}

View file

@ -26,9 +26,7 @@
#include "gui/editor/inspector/dynamicField.h"
#include "console/engineAPI.h"
#ifdef TORQUE_EXPERIMENTAL_EC
#include "T3D/components/component.h"
#endif
IMPLEMENT_CONOBJECT(GuiInspectorDynamicGroup);
@ -126,7 +124,6 @@ bool GuiInspectorDynamicGroup::inspectGroup()
SimFieldDictionary * fieldDictionary = target->getFieldDictionary();
for(SimFieldDictionaryIterator ditr(fieldDictionary); *ditr; ++ditr)
{
#ifdef TORQUE_EXPERIMENTAL_EC
if (target->getClassRep()->isSubclassOf("Component"))
{
Component* compTarget = dynamic_cast<Component*>(target);
@ -135,7 +132,7 @@ bool GuiInspectorDynamicGroup::inspectGroup()
if (compField)
continue;
}
#endif
if( i == 0 )
{
flist.increment();
@ -191,7 +188,7 @@ void GuiInspectorDynamicGroup::updateAllFields()
inspectGroup();
}
DefineConsoleMethod(GuiInspectorDynamicGroup, inspectGroup, bool, (), , "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorDynamicGroup, inspectGroup, bool, (), , "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -266,11 +263,11 @@ void GuiInspectorDynamicGroup::addDynamicField()
instantExpand();
}
DefineConsoleMethod( GuiInspectorDynamicGroup, addDynamicField, void, (), , "obj.addDynamicField();" )
DefineEngineMethod( GuiInspectorDynamicGroup, addDynamicField, void, (), , "obj.addDynamicField();" )
{
object->addDynamicField();
}
DefineConsoleMethod( GuiInspectorDynamicGroup, removeDynamicField, void, (), , "" )
DefineEngineMethod( GuiInspectorDynamicGroup, removeDynamicField, void, (), , "" )
{
}

View file

@ -70,7 +70,8 @@ bool GuiInspectorEntityGroup::inspectGroup()
{
Entity* target = dynamic_cast<Entity*>(mParent->getInspectObject(0));
Con::executef(this, "inspectObject", target->getIdString());
if(target)
Con::executef(this, "inspectObject", target->getIdString());
}
return true;
@ -86,7 +87,8 @@ void GuiInspectorEntityGroup::onMouseMove(const GuiEvent &event)
{
//mParent->mOverDivider = false;
}
ConsoleMethod(GuiInspectorEntityGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorEntityGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -127,11 +129,12 @@ AbstractClassRep::Field* GuiInspectorEntityGroup::findObjectBehaviorField(Compon
}
return NULL;
}
ConsoleMethod(GuiInspectorEntityGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();")
DefineEngineMethod(GuiInspectorEntityGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod(GuiInspectorEntityGroup, removeDynamicField, void, 3, 3, "")
DefineEngineMethod(GuiInspectorEntityGroup, removeDynamicField, void, (), , "")
{
}

View file

@ -688,59 +688,59 @@ void GuiInspectorField::_setFieldDocs( StringTableEntry docs )
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, getInspector, S32, (), , "() - Return the GuiInspector to which this field belongs." )
DefineEngineMethod( GuiInspectorField, getInspector, S32, (), , "() - Return the GuiInspector to which this field belongs." )
{
return object->getInspector()->getId();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, getInspectedFieldName, const char*, (), , "() - Return the name of the field edited by this inspector field." )
DefineEngineMethod( GuiInspectorField, getInspectedFieldName, const char*, (), , "() - Return the name of the field edited by this inspector field." )
{
return object->getFieldName();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, getInspectedFieldType, const char*, (), , "() - Return the type of the field edited by this inspector field." )
DefineEngineMethod( GuiInspectorField, getInspectedFieldType, const char*, (), , "() - Return the type of the field edited by this inspector field." )
{
return object->getFieldType();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, apply, void, ( const char * newValue, bool callbacks ), (true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." )
DefineEngineMethod( GuiInspectorField, apply, void, ( const char * newValue, bool callbacks ), (true), "( string newValue, bool callbacks=true ) - Set the field's value. Suppress callbacks for undo if callbacks=false." )
{
object->setData( newValue, callbacks );
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, applyWithoutUndo, void, (const char * data), , "() - Set field value without recording undo (same as 'apply( value, false )')." )
DefineEngineMethod( GuiInspectorField, applyWithoutUndo, void, (const char * data), , "() - Set field value without recording undo (same as 'apply( value, false )')." )
{
object->setData( data, false );
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, getData, const char*, (), , "() - Return the value currently displayed on the field." )
DefineEngineMethod( GuiInspectorField, getData, const char*, (), , "() - Return the value currently displayed on the field." )
{
return object->getData();
}
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiInspectorField, reset, void, (), , "() - Reset to default value." )
DefineEngineMethod( GuiInspectorField, reset, void, (), , "() - Reset to default value." )
{
object->resetData();
}
DefineConsoleMethod(GuiInspectorField, setCaption, void, (String newCaption),, "() - Reset to default value.")
DefineEngineMethod(GuiInspectorField, setCaption, void, (String newCaption),, "() - Reset to default value.")
{
object->setCaption(StringTable->insert(newCaption.c_str()));
}
DefineConsoleMethod(GuiInspectorField, setEditControl, void, (GuiControl* editCtrl), (nullAsType<GuiControl*>()), "() - Reset to default value.")
DefineEngineMethod(GuiInspectorField, setEditControl, void, (GuiControl* editCtrl), (nullAsType<GuiControl*>()), "() - Reset to default value.")
{
object->setEditControl(editCtrl);
}

View file

@ -242,7 +242,8 @@ void GuiInspectorMountingGroup::onMouseMove(const GuiEvent &event)
//mParent->mOverDivider = false;
bool test = false;
}
ConsoleMethod(GuiInspectorMountingGroup, inspectGroup, bool, 2, 2, "Refreshes the dynamic fields in the inspector.")
DefineEngineMethod(GuiInspectorMountingGroup, inspectGroup, bool, (),, "Refreshes the dynamic fields in the inspector.")
{
return object->inspectGroup();
}
@ -319,12 +320,13 @@ AbstractClassRep::Field* GuiInspectorMountingGroup::findObjectComponentField(Com
}
return NULL;
}
ConsoleMethod( GuiInspectorMountingGroup, addDynamicField, void, 2, 2, "obj.addDynamicField();" )
DefineEngineMethod(GuiInspectorMountingGroup, addDynamicField, void, (), , "obj.addDynamicField();")
{
object->addDynamicField();
}
ConsoleMethod( GuiInspectorMountingGroup, removeDynamicField, void, 3, 3, "" )
DefineEngineMethod(GuiInspectorMountingGroup, removeDynamicField, void, (), , "")
{
}

View file

@ -57,6 +57,7 @@ public:
protected:
StringTableEntry mVariableName;
StringTableEntry mSetCallbackName;
SimObject* mOwnerObject;
};

View file

@ -151,6 +151,9 @@ bool GuiInspectorVariableGroup::inspectGroup()
fieldGui->setInspectorField(NULL, mFields[i]->mFieldLabel);
fieldGui->setDocs(mFields[i]->mFieldDescription);
if(mFields[i]->mSetCallbackName != StringTable->EmptyString())
fieldGui->setSpecialEditCallbackName(mFields[i]->mSetCallbackName);
/*if (mFields[i]->mSetCallbackName != StringTable->EmptyString())
{
fieldGui->on.notify()
@ -247,12 +250,12 @@ GuiInspectorField* GuiInspectorVariableGroup::createInspectorField()
return NULL;
}
DefineConsoleMethod(GuiInspectorVariableGroup, createInspectorField, GuiInspectorField*, (),, "createInspectorField()")
DefineEngineMethod(GuiInspectorVariableGroup, createInspectorField, GuiInspectorField*, (),, "createInspectorField()")
{
return object->createInspectorField();
}
DefineConsoleMethod(GuiInspectorVariableGroup, addInspectorField, void, (GuiInspectorField* field), (nullAsType<GuiInspectorField*>()), "addInspectorField( GuiInspectorFieldObject )")
DefineEngineMethod(GuiInspectorVariableGroup, addInspectorField, void, (GuiInspectorField* field), (nullAsType<GuiInspectorField*>()), "addInspectorField( GuiInspectorFieldObject )")
{
object->addInspectorField(field);
}

View file

@ -167,6 +167,10 @@ void GuiVariableInspector::addField(const char* name, const char* label, const c
fieldTypeMask = TypeColorF;
else if (newField.mFieldTypeName == StringTable->insert("ease"))
fieldTypeMask = TypeEaseF;
else if (newField.mFieldTypeName == StringTable->insert("command"))
fieldTypeMask = TypeCommand;
else if (newField.mFieldTypeName == StringTable->insert("filename"))
fieldTypeMask = TypeStringFilename;
else
fieldTypeMask = -1;
@ -191,7 +195,10 @@ void GuiVariableInspector::addCallbackField(const char* name, const char* label,
void GuiVariableInspector::clearFields()
{
mGroups.clear();
mFields.clear();
clear();
update();
}
@ -209,17 +216,17 @@ void GuiVariableInspector::setFieldEnabled(const char* name, bool enabled)
}
}
DefineConsoleMethod(GuiVariableInspector, startGroup, void, (const char* name),, "startGroup( groupName )")
DefineEngineMethod(GuiVariableInspector, startGroup, void, (const char* name),, "startGroup( groupName )")
{
object->startGroup(name);
}
DefineConsoleMethod(GuiVariableInspector, endGroup, void, (),, "endGroup()")
DefineEngineMethod(GuiVariableInspector, endGroup, void, (),, "endGroup()")
{
object->endGroup();
}
DefineConsoleMethod(GuiVariableInspector, addField, void, (const char* name, const char* label, const char* typeName,
DefineEngineMethod(GuiVariableInspector, addField, void, (const char* name, const char* label, const char* typeName,
const char* description, const char* defaultValue, const char* dataValues, SimObject* ownerObj),
("","","","","", "", nullAsType<SimObject*>()), "addField( fieldName/varName, fieldLabel, fieldTypeName, description, defaultValue, defaultValues, ownerObject )")
{
@ -229,7 +236,7 @@ DefineConsoleMethod(GuiVariableInspector, addField, void, (const char* name, con
object->addField(name, label, typeName, description, defaultValue, dataValues, ownerObj);
}
DefineConsoleMethod(GuiVariableInspector, addCallbackField, void, (const char* name, const char* label, const char* typeName,
DefineEngineMethod(GuiVariableInspector, addCallbackField, void, (const char* name, const char* label, const char* typeName,
const char* description, const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj),
("", "", "", "", "", "", nullAsType<SimObject*>()), "addField( fieldName/varName, fieldLabel, fieldTypeName, description, defaultValue, defaultValues, callbackName, ownerObject )")
{
@ -239,22 +246,22 @@ DefineConsoleMethod(GuiVariableInspector, addCallbackField, void, (const char* n
object->addCallbackField(name, label, typeName, description, defaultValue, dataValues, callbackName, ownerObj);
}
DefineConsoleMethod(GuiVariableInspector, update, void, (), , "update()")
DefineEngineMethod(GuiVariableInspector, update, void, (), , "update()")
{
object->update();
}
DefineConsoleMethod(GuiVariableInspector, clearFields, void, (), , "clearFields()")
DefineEngineMethod(GuiVariableInspector, clearFields, void, (), , "clearFields()")
{
object->clearFields();
}
DefineConsoleMethod(GuiVariableInspector, setFieldEnabled, void, (const char* fieldName, bool isEnabled), (true), "setFieldEnabled( fieldName, isEnabled )")
DefineEngineMethod(GuiVariableInspector, setFieldEnabled, void, (const char* fieldName, bool isEnabled), (true), "setFieldEnabled( fieldName, isEnabled )")
{
object->setFieldEnabled(fieldName, isEnabled);
}
DefineConsoleMethod( GuiVariableInspector, loadVars, void, ( const char * searchString ), , "loadVars( searchString )" )
DefineEngineMethod( GuiVariableInspector, loadVars, void, ( const char * searchString ), , "loadVars( searchString )" )
{
object->loadVars( searchString );
}

View file

@ -0,0 +1,522 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "gui/editor/popupMenu.h"
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "gui/core/guiCanvas.h"
#include "core/util/safeDelete.h"
#include "gui/editor/guiPopupMenuCtrl.h"
#include "gui/editor/guiMenuBar.h"
static U32 sMaxPopupGUID = 0;
PopupMenuEvent PopupMenu::smPopupMenuEvent;
bool PopupMenu::smSelectionEventHandled = false;
/// Event class used to remove popup menus from the event notification in a safe way
class PopUpNotifyRemoveEvent : public SimEvent
{
public:
void process(SimObject *object)
{
PopupMenu::smPopupMenuEvent.remove((PopupMenu *)object, &PopupMenu::handleSelectEvent);
}
};
//-----------------------------------------------------------------------------
// Constructor/Destructor
//-----------------------------------------------------------------------------
PopupMenu::PopupMenu()
{
mMenuItems = NULL;
mMenuBarCtrl = nullptr;
mBarTitle = StringTable->EmptyString();
mBounds = RectI(0, 0, 64, 64);
mVisible = true;
mBitmapIndex = -1;
mDrawBitmapOnly = false;
mDrawBorder = false;
mTextList = nullptr;
mIsSubmenu = false;
}
PopupMenu::~PopupMenu()
{
PopupMenu::smPopupMenuEvent.remove(this, &PopupMenu::handleSelectEvent);
}
IMPLEMENT_CONOBJECT(PopupMenu);
ConsoleDocClass( PopupMenu,
"@brief PopupMenu represents a system menu.\n\n"
"You can add menu items to the menu, but there is no torque object associated "
"with these menu items, they exist only in a platform specific manner.\n\n"
"@note Internal use only\n\n"
"@internal"
);
//-----------------------------------------------------------------------------
void PopupMenu::initPersistFields()
{
Parent::initPersistFields();
addField("barTitle", TypeCaseString, Offset(mBarTitle, PopupMenu), "");
}
//-----------------------------------------------------------------------------
bool PopupMenu::onAdd()
{
if(! Parent::onAdd())
return false;
Con::executef(this, "onAdd");
return true;
}
void PopupMenu::onRemove()
{
Con::executef(this, "onRemove");
Parent::onRemove();
}
//-----------------------------------------------------------------------------
void PopupMenu::onMenuSelect()
{
Con::executef(this, "onMenuSelect");
}
//-----------------------------------------------------------------------------
void PopupMenu::handleSelectEvent(U32 popID, U32 command)
{
}
//-----------------------------------------------------------------------------
bool PopupMenu::onMessageReceived(StringTableEntry queue, const char* event, const char* data)
{
return Con::executef(this, "onMessageReceived", queue, event, data);
}
bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg )
{
return Con::executef(this, "onMessageReceived", queue, Con::getIntArg(msg->getId()));
}
//////////////////////////////////////////////////////////////////////////
// Platform Menu Data
//////////////////////////////////////////////////////////////////////////
GuiMenuBar* PopupMenu::getMenuBarCtrl()
{
return mMenuBarCtrl;
}
//////////////////////////////////////////////////////////////////////////
// Public Methods
//////////////////////////////////////////////////////////////////////////
S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd)
{
String titleString = title;
MenuItem newItem;
newItem.mID = pos;
newItem.mText = titleString;
newItem.mCMD = cmd;
if (titleString.isEmpty() || titleString == String("-"))
newItem.mIsSpacer = true;
else
newItem.mIsSpacer = false;
if (accelerator[0])
newItem.mAccelerator = dStrdup(accelerator);
else
newItem.mAccelerator = NULL;
newItem.mVisible = true;
newItem.mIsChecked = false;
newItem.mAcceleratorIndex = 0;
newItem.mEnabled = !newItem.mIsSpacer;
newItem.mIsSubmenu = false;
newItem.mSubMenu = nullptr;
newItem.mSubMenuParentMenu = nullptr;
mMenuItems.push_back(newItem);
return pos;
}
S32 PopupMenu::insertSubMenu(S32 pos, const char *title, PopupMenu *submenu)
{
S32 itemPos = insertItem(pos, title, "", "");
mMenuItems[itemPos].mIsSubmenu = true;
mMenuItems[itemPos].mSubMenu = submenu;
mMenuItems[itemPos].mSubMenuParentMenu = this;
submenu->mIsSubmenu = true;
return itemPos;
}
bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, const char* cmd)
{
String titleString = title;
for (U32 i = 0; i < mMenuItems.size(); i++)
{
if (mMenuItems[i].mText == titleString)
{
mMenuItems[i].mID = pos;
mMenuItems[i].mCMD = cmd;
if (accelerator && accelerator[0])
mMenuItems[i].mAccelerator = dStrdup(accelerator);
else
mMenuItems[i].mAccelerator = NULL;
return true;
}
}
return false;
}
void PopupMenu::removeItem(S32 itemPos)
{
if (mMenuItems.empty() || mMenuItems.size() < itemPos || itemPos < 0)
return;
mMenuItems.erase(itemPos);
}
//////////////////////////////////////////////////////////////////////////
void PopupMenu::enableItem(S32 pos, bool enable)
{
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
return;
mMenuItems[pos].mEnabled = enable;
}
void PopupMenu::checkItem(S32 pos, bool checked)
{
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
return;
if (checked && mMenuItems[pos].mCheckGroup != -1)
{
// first, uncheck everything in the group:
for (U32 i = 0; i < mMenuItems.size(); i++)
if (mMenuItems[i].mCheckGroup == mMenuItems[pos].mCheckGroup && mMenuItems[i].mIsChecked)
mMenuItems[i].mIsChecked = false;
}
mMenuItems[pos].mIsChecked = checked;
}
void PopupMenu::checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos)
{
for (U32 i = 0; i < mMenuItems.size(); i++)
{
if (mMenuItems[i].mID >= firstPos && mMenuItems[i].mID <= lastPos)
{
mMenuItems[i].mIsChecked = false;
}
}
}
bool PopupMenu::isItemChecked(S32 pos)
{
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
return false;
return mMenuItems[pos].mIsChecked;
}
U32 PopupMenu::getItemCount()
{
return mMenuItems.size();
}
void PopupMenu::clearItems()
{
mMenuItems.clear();
}
//////////////////////////////////////////////////////////////////////////
bool PopupMenu::canHandleID(U32 id)
{
return true;
}
bool PopupMenu::handleSelect(U32 command, const char *text /* = NULL */)
{
return dAtob(Con::executef(this, "onSelectItem", Con::getIntArg(command), text ? text : ""));
}
//////////////////////////////////////////////////////////////////////////
void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
{
if (owner == NULL)
return;
GuiControl* editorGui;
Sim::findObject("EditorGui", editorGui);
if (editorGui)
{
GuiPopupMenuBackgroundCtrl* backgroundCtrl;
Sim::findObject("PopUpMenuControl", backgroundCtrl);
GuiControlProfile* profile;
Sim::findObject("GuiMenubarProfile", profile);
if (!profile)
return;
if (mTextList == nullptr)
{
mTextList = new GuiPopupMenuTextListCtrl();
mTextList->registerObject();
mTextList->setControlProfile(profile);
mTextList->mPopup = this;
mTextList->mMenuBar = getMenuBarCtrl();
}
if (!backgroundCtrl)
{
backgroundCtrl = new GuiPopupMenuBackgroundCtrl();
backgroundCtrl->registerObject("PopUpMenuControl");
}
if (!backgroundCtrl || !mTextList)
return;
if (!mIsSubmenu)
{
//if we're a 'parent' menu, then tell the background to clear out all existing other popups
backgroundCtrl->clearPopups();
}
//find out if we're doing a first-time add
S32 popupIndex = backgroundCtrl->findPopupMenu(this);
if (popupIndex == -1)
{
backgroundCtrl->addObject(mTextList);
backgroundCtrl->mPopups.push_back(this);
}
mTextList->mBackground = backgroundCtrl;
owner->pushDialogControl(backgroundCtrl, 10);
//Set the background control's menubar, if any, and if it's not already set
if(backgroundCtrl->mMenuBarCtrl == nullptr)
backgroundCtrl->mMenuBarCtrl = getMenuBarCtrl();
backgroundCtrl->setExtent(editorGui->getExtent());
mTextList->clear();
S32 textWidth = 0, width = 0;
S32 acceleratorWidth = 0;
GFont *font = profile->mFont;
Point2I maxBitmapSize = Point2I(0, 0);
S32 numBitmaps = profile->mBitmapArrayRects.size();
if (numBitmaps)
{
RectI *bitmapBounds = profile->mBitmapArrayRects.address();
for (S32 i = 0; i < numBitmaps; i++)
{
if (bitmapBounds[i].extent.x > maxBitmapSize.x)
maxBitmapSize.x = bitmapBounds[i].extent.x;
if (bitmapBounds[i].extent.y > maxBitmapSize.y)
maxBitmapSize.y = bitmapBounds[i].extent.y;
}
}
for (U32 i = 0; i < mMenuItems.size(); i++)
{
if (!mMenuItems[i].mVisible)
continue;
S32 iTextWidth = font->getStrWidth(mMenuItems[i].mText.c_str());
S32 iAcceleratorWidth = mMenuItems[i].mAccelerator ? font->getStrWidth(mMenuItems[i].mAccelerator) : 0;
if (iTextWidth > textWidth)
textWidth = iTextWidth;
if (iAcceleratorWidth > acceleratorWidth)
acceleratorWidth = iAcceleratorWidth;
}
width = textWidth + acceleratorWidth + maxBitmapSize.x * 2 + 2 + 4;
mTextList->setCellSize(Point2I(width, font->getHeight() + 2));
mTextList->clearColumnOffsets();
mTextList->addColumnOffset(-1); // add an empty column in for the bitmap index.
mTextList->addColumnOffset(maxBitmapSize.x + 1);
mTextList->addColumnOffset(maxBitmapSize.x + 1 + textWidth + 4);
U32 entryCount = 0;
for (U32 i = 0; i < mMenuItems.size(); i++)
{
if (!mMenuItems[i].mVisible)
continue;
char buf[512];
// If this menu item is a submenu, then set the isSubmenu to 2 to indicate
// an arrow should be drawn. Otherwise set the isSubmenu normally.
char isSubmenu = 1;
if (mMenuItems[i].mIsSubmenu)
isSubmenu = 2;
char bitmapIndex = 1;
if (mMenuItems[i].mBitmapIndex >= 0 && (mMenuItems[i].mBitmapIndex * 3 <= profile->mBitmapArrayRects.size()))
bitmapIndex = mMenuItems[i].mBitmapIndex + 2;
dSprintf(buf, sizeof(buf), "%c%c\t%s\t%s", bitmapIndex, isSubmenu, mMenuItems[i].mText.c_str(), mMenuItems[i].mAccelerator ? mMenuItems[i].mAccelerator : "");
mTextList->addEntry(entryCount, buf);
if (!mMenuItems[i].mEnabled)
mTextList->setEntryActive(entryCount, false);
entryCount++;
}
Point2I pos = Point2I::Zero;
if (x == -1 && y == -1)
pos = owner->getCursorPos();
else
pos = Point2I(x, y);
mTextList->setPosition(pos);
//nudge in if we'd overshoot the screen
S32 widthDiff = (mTextList->getPosition().x + mTextList->getExtent().x) - backgroundCtrl->getWidth();
if (widthDiff > 0)
{
Point2I popupPos = mTextList->getPosition();
mTextList->setPosition(popupPos.x - widthDiff, popupPos.y);
}
mTextList->setHidden(false);
}
}
void PopupMenu::hidePopup()
{
if (mTextList)
{
mTextList->setHidden(true);
}
hidePopupSubmenus();
}
void PopupMenu::hidePopupSubmenus()
{
for (U32 i = 0; i < mMenuItems.size(); i++)
{
if (mMenuItems[i].mSubMenu != nullptr)
mMenuItems[i].mSubMenu->hidePopup();
}
}
//-----------------------------------------------------------------------------
// Console Methods
//-----------------------------------------------------------------------------
DefineEngineMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd), ("", "", ""), "(pos[, title][, accelerator][, cmd])")
{
return object->insertItem(pos, title, accelerator, cmd);
}
DefineEngineMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
{
object->removeItem(pos);
}
DefineEngineMethod(PopupMenu, insertSubMenu, S32, (S32 pos, String title, String subMenu), , "(pos, title, subMenu)")
{
PopupMenu *mnu = dynamic_cast<PopupMenu *>(Sim::findObject(subMenu));
if(mnu == NULL)
{
Con::errorf("PopupMenu::insertSubMenu - Invalid PopupMenu object specified for submenu");
return -1;
}
return object->insertSubMenu(pos, title, mnu);
}
DefineEngineMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator, const char *cmd), (""), "(pos, title[, accelerator][, cmd])")
{
return object->setItem(pos, title, accelerator, cmd);
}
//-----------------------------------------------------------------------------
DefineEngineMethod(PopupMenu, enableItem, void, (S32 pos, bool enabled), , "(pos, enabled)")
{
object->enableItem(pos, enabled);
}
DefineEngineMethod(PopupMenu, checkItem, void, (S32 pos, bool checked), , "(pos, checked)")
{
object->checkItem(pos, checked);
}
DefineEngineMethod(PopupMenu, checkRadioItem, void, (S32 firstPos, S32 lastPos, S32 checkPos), , "(firstPos, lastPos, checkPos)")
{
object->checkRadioItem(firstPos, lastPos, checkPos);
}
DefineEngineMethod(PopupMenu, isItemChecked, bool, (S32 pos), , "(pos)")
{
return object->isItemChecked(pos);
}
DefineEngineMethod(PopupMenu, getItemCount, S32, (), , "()")
{
return object->getItemCount();
}
DefineConsoleMethod(PopupMenu, clearItems, void, (), , "()")
{
return object->clearItems();
}
//-----------------------------------------------------------------------------
DefineEngineMethod(PopupMenu, showPopup, void, (const char * canvasName, S32 x, S32 y), ( -1, -1), "(Canvas,[x, y])")
{
GuiCanvas *pCanvas = dynamic_cast<GuiCanvas*>(Sim::findObject(canvasName));
object->showPopup(pCanvas, x, y);
}

View file

@ -0,0 +1,187 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _POPUPMENU_H_
#define _POPUPMENU_H_
#include "console/simBase.h"
#include "core/util/tVector.h"
#include "util/messaging/dispatcher.h"
#include "gui/core/guiCanvas.h"
class PopupMenu;
class GuiMenuBar;
class GuiPopupMenuTextListCtrl;
class GuiPopupMenuBackgroundCtrl;
struct MenuItem // an individual item in a pull-down menu
{
String mText; // the text of the menu item
U32 mID; // a script-assigned identifier
char *mAccelerator; // the keyboard accelerator shortcut for the menu item
U32 mAcceleratorIndex; // index of this accelerator
bool mEnabled; // true if the menu item is selectable
bool mVisible; // true if the menu item is visible
S32 mBitmapIndex; // index of the bitmap in the bitmap array
S32 mCheckGroup; // the group index of the item visa vi check marks -
// only one item in the group can be checked.
bool mIsSubmenu; // This menu item has a submenu that will be displayed
bool mIsChecked;
bool mIsSpacer;
bool mIsMenubarEntry;
PopupMenu* mSubMenuParentMenu; // For a submenu, this is the parent menu
PopupMenu* mSubMenu;
String mCMD;
};
// PopupMenu represents a menu.
// You can add menu items to the menu, but there is no torque object associated
// with these menu items, they exist only in a platform specific manner.
class PopupMenu : public SimObject, public virtual Dispatcher::IMessageListener
{
typedef SimObject Parent;
friend class GuiMenuBar;
friend class GuiPopupMenuTextListCtrl;
friend class GuiPopupMenuBackgroundCtrl;
protected:
Vector<MenuItem> mMenuItems;
GuiMenuBar* mMenuBarCtrl;
StringTableEntry mBarTitle;
RectI mBounds;
bool mVisible;
S32 mBitmapIndex; // Index of the bitmap in the bitmap array (-1 = no bitmap)
bool mDrawBitmapOnly; // Draw only the bitmap and not the text
bool mDrawBorder; // Should a border be drawn around this menu (usually if we only have a bitmap, we don't want a border)
bool mIsSubmenu;
//This is the gui control that renders our popup
GuiPopupMenuTextListCtrl *mTextList;
public:
PopupMenu();
virtual ~PopupMenu();
DECLARE_CONOBJECT(PopupMenu);
static void initPersistFields();
virtual bool onAdd();
virtual void onRemove();
static PopupMenuEvent smPopupMenuEvent;
static bool smSelectionEventHandled; /// Set to true if any menu or submenu handles a selection event
/// pass NULL for @p title to insert a separator
/// returns the menu item's ID, or -1 on failure.
/// implementd on a per-platform basis.
/// TODO: factor out common code
S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// Sets the name title and accelerator for
/// an existing item.
bool setItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// pass NULL for @p title to insert a separator
/// returns the menu item's ID, or -1 on failure.
/// adds the submenu to the mSubmenus vector.
/// implemented on a per-platform basis.
/// TODO: factor out common code
S32 insertSubMenu(S32 pos, const char *title, PopupMenu *submenu);
/// remove the menu item at @p itemPos
/// if the item has a submenu, it is removed from the mSubmenus list.
/// implemented on a per-platform basis.
/// TODO: factor out common code
void removeItem(S32 itemPos);
/// implemented on a per-platform basis.
void enableItem(S32 pos, bool enable);
/// implemented on a per-platform basis.
void checkItem(S32 pos, bool checked);
/// All items at positions firstPos through lastPos are unchecked, and the
/// item at checkPos is checked.
/// implemented on a per-platform basis.
void checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos);
bool isItemChecked(S32 pos);
/// Returns the number of items in the menu.
U32 getItemCount();
///Clears all items
void clearItems();
//-----------------------------------------------------------------------------
/// Displays this menu as a popup menu and blocks until the user has selected
/// an item.
/// @param canvas the owner to show this popup associated with
/// @param x window local x coordinate at which to display the popup menu
/// @param y window local y coordinate at which to display the popup menu
/// implemented on a per-platform basis.
void showPopup(GuiCanvas *owner, S32 x = -1, S32 y = -1);
void hidePopup();
void hidePopupSubmenus();
/// Returns true iff this menu contains an item that matches @p iD.
/// implemented on a per-platform basis.
/// TODO: factor out common code
bool canHandleID(U32 iD);
/// A menu item in this menu has been selected by id.
/// Submenus are given a chance to respond to the command first.
/// If no submenu can handle the command id, this menu handles it.
/// The script callback this::onSelectItem( position, text) is called.
/// If @p text is null, then the text arg passed to script is the text of
/// the selected menu item.
/// implemented on a per-platform basis.
/// TODO: factor out common code
bool handleSelect(U32 command, const char *text = NULL);
void onMenuSelect();
/// Helper function to allow menu selections from signal events.
/// Wraps canHandleID() and handleSelect() in one function
/// without changing their internal functionality, so
/// it should work regardless of platform.
void handleSelectEvent(U32 popID, U32 command);
virtual bool onMessageReceived(StringTableEntry queue, const char* event, const char* data );
virtual bool onMessageObjectReceived(StringTableEntry queue, Message *msg );
bool isVisible() { return mVisible; }
void setVisible(bool isVis) { mVisible = isVis; }
GuiMenuBar* getMenuBarCtrl();
};
#endif // _POPUPMENU_H_

View file

@ -177,13 +177,13 @@ ConsoleDocClass( GuiIdleCamFadeBitmapCtrl,
"This is going to be deprecated, and any useful code ported to FadeinBitmap\n\n"
"@internal");
DefineConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeIn, void, (), , "()"
DefineEngineMethod(GuiIdleCamFadeBitmapCtrl, fadeIn, void, (), , "()"
"@internal")
{
object->fadeIn();
}
DefineConsoleMethod(GuiIdleCamFadeBitmapCtrl, fadeOut, void, (), , "()"
DefineEngineMethod(GuiIdleCamFadeBitmapCtrl, fadeOut, void, (), , "()"
"@internal")
{
object->fadeOut();

View file

@ -59,7 +59,7 @@ static ConsoleDocFragment _setProcessTicks(
"void setProcessTicks( bool tick )"
);
DefineConsoleMethod( GuiTickCtrl, setProcessTicks, void, (bool tick), (true), "( [tick = true] ) - This will set this object to either be processing ticks or not" )
DefineEngineMethod( GuiTickCtrl, setProcessTicks, void, (bool tick), (true), "( [tick = true] ) - This will set this object to either be processing ticks or not" )
{
object->setProcessTicks(tick);
}

View file

@ -258,7 +258,7 @@ static ConsoleDocFragment _MessageVectordump2(
"MessageVector",
"void dump( string filename, string header);");
DefineConsoleMethod( MessageVector, dump, void, (const char * filename, const char * header), (""), "(string filename, string header=NULL)"
DefineEngineMethod( MessageVector, dump, void, (const char * filename, const char * header), (""), "(string filename, string header=NULL)"
"Dump the message vector to a file, optionally prefixing a header."
"@hide")
{
@ -500,7 +500,7 @@ void MessageVector::insertLine(const U32 position,
U32 len = dStrlen(newMessage) + 1;
char* copy = new char[len];
dStrcpy(copy, newMessage);
dStrcpy(copy, newMessage, len);
mMessageLines.insert(position);
mMessageLines[position].message = copy;

View file

@ -219,7 +219,7 @@ void CreatorTree::sort()
}
//------------------------------------------------------------------------------
DefineConsoleMethod( CreatorTree, addGroup, S32, (S32 group, const char * name, const char * value), , "(string group, string name, string value)")
DefineEngineMethod( CreatorTree, addGroup, S32, (S32 group, const char * name, const char * value), , "(string group, string name, string value)")
{
CreatorTree::Node * grp = object->findNode(group);
@ -236,7 +236,7 @@ DefineConsoleMethod( CreatorTree, addGroup, S32, (S32 group, const char * name,
return(node ? node->getId() : -1);
}
DefineConsoleMethod( CreatorTree, addItem, S32, (S32 group, const char * name, const char * value), , "(Node group, string name, string value)")
DefineEngineMethod( CreatorTree, addItem, S32, (S32 group, const char * name, const char * value), , "(Node group, string name, string value)")
{
CreatorTree::Node * grp = object->findNode(group);
@ -249,7 +249,7 @@ DefineConsoleMethod( CreatorTree, addItem, S32, (S32 group, const char * name, c
}
//------------------------------------------------------------------------------
DefineConsoleMethod( CreatorTree, fileNameMatch, bool, (const char * world, const char * type, const char * filename), , "(string world, string type, string filename)")
DefineEngineMethod( CreatorTree, fileNameMatch, bool, (const char * world, const char * type, const char * filename), , "(string world, string type, string filename)")
{
// argv[2] - world short
// argv[3] - type short
@ -269,12 +269,12 @@ DefineConsoleMethod( CreatorTree, fileNameMatch, bool, (const char * world, cons
return(!dStrnicmp(filename+1, type, typeLen));
}
DefineConsoleMethod( CreatorTree, getSelected, S32, (), , "Return a handle to the currently selected item.")
DefineEngineMethod( CreatorTree, getSelected, S32, (), , "Return a handle to the currently selected item.")
{
return(object->getSelected());
}
DefineConsoleMethod( CreatorTree, isGroup, bool, (const char * group), , "(Group g)")
DefineEngineMethod( CreatorTree, isGroup, bool, (const char * group), , "(Group g)")
{
CreatorTree::Node * node = object->findNode(dAtoi(group));
if(node && node->isGroup())
@ -282,24 +282,24 @@ DefineConsoleMethod( CreatorTree, isGroup, bool, (const char * group), , "(Group
return(false);
}
DefineConsoleMethod( CreatorTree, getName, const char*, (const char * item), , "(Node item)")
DefineEngineMethod( CreatorTree, getName, const char*, (const char * item), , "(Node item)")
{
CreatorTree::Node * node = object->findNode(dAtoi(item));
return(node ? node->mName : 0);
}
DefineConsoleMethod( CreatorTree, getValue, const char*, (S32 nodeValue), , "(Node n)")
DefineEngineMethod( CreatorTree, getValue, const char*, (S32 nodeValue), , "(Node n)")
{
CreatorTree::Node * node = object->findNode(nodeValue);
return(node ? node->mValue : 0);
}
DefineConsoleMethod( CreatorTree, clear, void, (), , "Clear the tree.")
DefineEngineMethod( CreatorTree, clear, void, (), , "Clear the tree.")
{
object->clear();
}
DefineConsoleMethod( CreatorTree, getParent, S32, (S32 nodeValue), , "(Node n)")
DefineEngineMethod( CreatorTree, getParent, S32, (S32 nodeValue), , "(Node n)")
{
CreatorTree::Node * node = object->findNode(nodeValue);
if(node && node->mParent)

View file

@ -128,7 +128,7 @@ static GameBase * getControlObj()
return(control);
}
DefineConsoleMethod( EditManager, setBookmark, void, (S32 val), , "(int slot)")
DefineEngineMethod( EditManager, setBookmark, void, (S32 val), , "(int slot)")
{
if(val < 0 || val > 9)
return;
@ -138,7 +138,7 @@ DefineConsoleMethod( EditManager, setBookmark, void, (S32 val), , "(int slot)")
object->mBookmarks[val] = control->getTransform();
}
DefineConsoleMethod( EditManager, gotoBookmark, void, (S32 val), , "(int slot)")
DefineEngineMethod( EditManager, gotoBookmark, void, (S32 val), , "(int slot)")
{
if(val < 0 || val > 9)
return;
@ -148,17 +148,17 @@ DefineConsoleMethod( EditManager, gotoBookmark, void, (S32 val), , "(int slot)")
control->setTransform(object->mBookmarks[val]);
}
DefineConsoleMethod( EditManager, editorEnabled, void, (), , "Perform the onEditorEnabled callback on all SimObjects and set gEditingMission true" )
DefineEngineMethod( EditManager, editorEnabled, void, (), , "Perform the onEditorEnabled callback on all SimObjects and set gEditingMission true" )
{
object->editorEnabled();
}
DefineConsoleMethod( EditManager, editorDisabled, void, (), , "Perform the onEditorDisabled callback on all SimObjects and set gEditingMission false" )
DefineEngineMethod( EditManager, editorDisabled, void, (), , "Perform the onEditorDisabled callback on all SimObjects and set gEditingMission false" )
{
object->editorDisabled();
}
DefineConsoleMethod( EditManager, isEditorEnabled, bool, (), , "Return the value of gEditingMission." )
DefineEngineMethod( EditManager, isEditorEnabled, bool, (), , "Return the value of gEditingMission." )
{
return gEditingMission;
}

View file

@ -23,7 +23,7 @@
#include "platform/platform.h"
#include "gui/worldEditor/editorIconRegistry.h"
#include "console/console.h"
#include "console/engineAPI.h"
#include "console/simBase.h"
@ -36,6 +36,8 @@ ConsoleDoc(
"@internal"
);
IMPLEMENT_STATIC_CLASS(EditorIconRegistry,, "");
EditorIconRegistry::EditorIconRegistry()
{
}
@ -168,51 +170,42 @@ void EditorIconRegistry::clear()
mDefaultIcon.free();
}
ConsoleStaticMethod( EditorIconRegistry, add, void, 3, 4, "( String className, String imageFile [, bool overwrite = true] )"
DefineEngineStaticMethod( EditorIconRegistry, add, void, (String className, String imageFile, bool overwrite), (true),
"@internal")
{
bool overwrite = true;
if ( argc > 3 )
overwrite = dAtob( argv[3] );
gEditorIcons.add( argv[1], argv[2], overwrite );
gEditorIcons.add( className, imageFile, overwrite );
}
ConsoleStaticMethod( EditorIconRegistry, loadFromPath, void, 2, 3, "( String imagePath [, bool overwrite = true] )"
DefineEngineStaticMethod( EditorIconRegistry, loadFromPath, void, (String imagePath, bool overwrite), (true),
"@internal")
{
bool overwrite = true;
if ( argc > 2 )
overwrite = dAtob( argv[2] );
gEditorIcons.loadFromPath( argv[1], overwrite );
gEditorIcons.loadFromPath( imagePath, overwrite );
}
ConsoleStaticMethod( EditorIconRegistry, clear, void, 1, 1, ""
DefineEngineStaticMethod( EditorIconRegistry, clear, void, (),,
"@internal")
{
gEditorIcons.clear();
}
ConsoleStaticMethod( EditorIconRegistry, findIconByClassName, const char*, 2, 2, "( String className )\n"
"Returns the file path to the icon file if found."
DefineEngineStaticMethod( EditorIconRegistry, findIconByClassName, const char*, (String className),,
"@brief Returns the file path to the icon file if found."
"@internal")
{
GFXTexHandle icon = gEditorIcons.findIcon( argv[1] );
GFXTexHandle icon = gEditorIcons.findIcon( className );
if ( icon.isNull() )
return NULL;
return icon->mPath;
}
ConsoleStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, 2, 2, "( SimObject )\n"
DefineEngineStaticMethod( EditorIconRegistry, findIconBySimObject, const char*, (SimObject* obj),,
"Returns the file path to the icon file if found."
"@internal")
{
SimObject *obj = NULL;
if ( !Sim::findObject( argv[1], obj ) )
if ( !obj )
{
Con::warnf( "EditorIconRegistry::findIcon, parameter %d was not a SimObject!", (const char*)argv[1] );
Con::warnf( "EditorIconRegistry::findIcon, parameter was not a SimObject!");
return NULL;
}

View file

@ -30,6 +30,8 @@
#include "core/util/tDictionary.h"
#endif
#include "console/engineAPI.h"
class SimObject;
class AbstractClassRep;
@ -40,6 +42,7 @@ class AbstractClassRep;
class EditorIconRegistry
{
public:
DECLARE_STATIC_CLASS(EditorIconRegistry);
EditorIconRegistry();
~EditorIconRegistry();

View file

@ -612,12 +612,12 @@ bool Gizmo::collideAxisGizmo( const Gui3DMouseEvent & event )
Point3F(mOrigin + (p1 + p2) * scale)
};
Point3F end = camPos + event.vec * smProjectDistance;
F32 t = plane.intersect(camPos, end);
Point3F endProj = camPos + event.vec * smProjectDistance;
F32 t = plane.intersect(camPos, endProj);
if ( t >= 0 && t <= 1 )
{
Point3F pos;
pos.interpolate(camPos, end, t);
pos.interpolate(camPos, endProj, t);
// check if inside our 'poly' of this axisIdx vector...
bool inside = true;

View file

@ -2474,43 +2474,43 @@ ConvexShape* GuiConvexEditorCtrl::createConvexShapeFrom(SceneObject* polyObject)
return shape;
}
DefineConsoleMethod( GuiConvexEditorCtrl, hollowSelection, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, hollowSelection, void, (), , "" )
{
object->hollowSelection();
}
DefineConsoleMethod( GuiConvexEditorCtrl, recenterSelection, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, recenterSelection, void, (), , "" )
{
object->recenterSelection();
}
DefineConsoleMethod( GuiConvexEditorCtrl, hasSelection, S32, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, hasSelection, S32, (), , "" )
{
return object->hasSelection();
}
DefineConsoleMethod( GuiConvexEditorCtrl, handleDelete, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, handleDelete, void, (), , "" )
{
object->handleDelete();
}
DefineConsoleMethod( GuiConvexEditorCtrl, handleDeselect, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, handleDeselect, void, (), , "" )
{
object->handleDeselect();
}
DefineConsoleMethod( GuiConvexEditorCtrl, dropSelectionAtScreenCenter, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, dropSelectionAtScreenCenter, void, (), , "" )
{
object->dropSelectionAtScreenCenter();
}
DefineConsoleMethod( GuiConvexEditorCtrl, selectConvex, void, (ConvexShape *convex), , "( ConvexShape )" )
DefineEngineMethod( GuiConvexEditorCtrl, selectConvex, void, (ConvexShape *convex), , "( ConvexShape )" )
{
if (convex)
object->setSelection( convex, -1 );
}
DefineConsoleMethod( GuiConvexEditorCtrl, splitSelectedFace, void, (), , "" )
DefineEngineMethod( GuiConvexEditorCtrl, splitSelectedFace, void, (), , "" )
{
object->splitSelectedFace();
}

View file

@ -784,12 +784,12 @@ void GuiDecalEditorCtrl::setMode( String mode, bool sourceShortcut = false )
Con::executef( this, "paletteSync", mMode );
}
DefineConsoleMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, (), , "deleteSelectedDecal()" )
DefineEngineMethod( GuiDecalEditorCtrl, deleteSelectedDecal, void, (), , "deleteSelectedDecal()" )
{
object->deleteSelectedDecal();
}
DefineConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, ( const char * datablock ), , "deleteSelectedDecalDatablock( String datablock )" )
DefineEngineMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, ( const char * datablock ), , "deleteSelectedDecalDatablock( String datablock )" )
{
String lookupName( datablock );
if( lookupName == String::EmptyString )
@ -798,22 +798,22 @@ DefineConsoleMethod( GuiDecalEditorCtrl, deleteDecalDatablock, void, ( const cha
object->deleteDecalDatablock( lookupName );
}
DefineConsoleMethod( GuiDecalEditorCtrl, setMode, void, ( String newMode ), , "setMode( String mode )()" )
DefineEngineMethod( GuiDecalEditorCtrl, setMode, void, ( String newMode ), , "setMode( String mode )()" )
{
object->setMode( newMode );
}
DefineConsoleMethod( GuiDecalEditorCtrl, getMode, const char*, (), , "getMode()" )
DefineEngineMethod( GuiDecalEditorCtrl, getMode, const char*, (), , "getMode()" )
{
return object->mMode;
}
DefineConsoleMethod( GuiDecalEditorCtrl, getDecalCount, S32, (), , "getDecalCount()" )
DefineEngineMethod( GuiDecalEditorCtrl, getDecalCount, S32, (), , "getDecalCount()" )
{
return gDecalManager->mDecalInstanceVec.size();
}
DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" )
DefineEngineMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 id ), , "getDecalTransform()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
@ -835,7 +835,7 @@ DefineConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, ( U32 i
return returnBuffer;
}
DefineConsoleMethod( GuiDecalEditorCtrl, getDecalLookupName, const char*, ( U32 id ), , "getDecalLookupName( S32 )()" )
DefineEngineMethod( GuiDecalEditorCtrl, getDecalLookupName, const char*, ( U32 id ), , "getDecalLookupName( S32 )()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
if( decalInstance == NULL )
@ -844,7 +844,7 @@ DefineConsoleMethod( GuiDecalEditorCtrl, getDecalLookupName, const char*, ( U32
return decalInstance->mDataBlock->lookupName;
}
DefineConsoleMethod( GuiDecalEditorCtrl, selectDecal, void, ( U32 id ), , "selectDecal( S32 )()" )
DefineEngineMethod( GuiDecalEditorCtrl, selectDecal, void, ( U32 id ), , "selectDecal( S32 )()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
if( decalInstance == NULL )
@ -853,7 +853,7 @@ DefineConsoleMethod( GuiDecalEditorCtrl, selectDecal, void, ( U32 id ), , "selec
object->selectDecal( decalInstance );
}
DefineConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3F pos, Point3F tan,F32 size ), , "editDecalDetails( S32 )()" )
DefineEngineMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point3F pos, Point3F tan,F32 size ), , "editDecalDetails( S32 )()" )
{
DecalInstance *decalInstance = gDecalManager->mDecalInstanceVec[id];
if( decalInstance == NULL )
@ -872,14 +872,14 @@ DefineConsoleMethod( GuiDecalEditorCtrl, editDecalDetails, void, ( U32 id, Point
gDecalManager->notifyDecalModified( decalInstance );
}
DefineConsoleMethod( GuiDecalEditorCtrl, getSelectionCount, S32, (), , "" )
DefineEngineMethod( GuiDecalEditorCtrl, getSelectionCount, S32, (), , "" )
{
if ( object->mSELDecal != NULL )
return 1;
return 0;
}
DefineConsoleMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, ( const char * dbFrom, const char * dbTo ), , "" )
DefineEngineMethod( GuiDecalEditorCtrl, retargetDecalDatablock, void, ( const char * dbFrom, const char * dbTo ), , "" )
{
if( dStrcmp( dbFrom, "" ) != 0 && dStrcmp( dbTo, "" ) != 0 )
object->retargetDecalDatablock( dbFrom, dbTo );

View file

@ -95,7 +95,7 @@ void GuiMissionAreaEditorCtrl::setSelectedMissionArea( MissionArea *missionArea
Con::executef( this, "onMissionAreaSelected" );
}
DefineConsoleMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" )
DefineEngineMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (const char * missionAreaName), (""), "" )
{
if ( dStrcmp( missionAreaName, "" )==0 )
object->setSelectedMissionArea(NULL);
@ -107,7 +107,7 @@ DefineConsoleMethod( GuiMissionAreaEditorCtrl, setSelectedMissionArea, void, (co
}
}
DefineConsoleMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, (), , "" )
DefineEngineMethod( GuiMissionAreaEditorCtrl, getSelectedMissionArea, const char*, (), , "" )
{
MissionArea *missionArea = object->getSelectedMissionArea();
if ( !missionArea )

View file

@ -88,35 +88,35 @@ void GuiTerrPreviewCtrl::initPersistFields()
}
DefineConsoleMethod( GuiTerrPreviewCtrl, reset, void, (), , "Reset the view of the terrain.")
DefineEngineMethod( GuiTerrPreviewCtrl, reset, void, (), , "Reset the view of the terrain.")
{
object->reset();
}
DefineConsoleMethod( GuiTerrPreviewCtrl, setRoot, void, (), , "Add the origin to the root and reset the origin.")
DefineEngineMethod( GuiTerrPreviewCtrl, setRoot, void, (), , "Add the origin to the root and reset the origin.")
{
object->setRoot();
}
DefineConsoleMethod( GuiTerrPreviewCtrl, getRoot, Point2F, (), , "Return a Point2F representing the position of the root.")
DefineEngineMethod( GuiTerrPreviewCtrl, getRoot, Point2F, (), , "Return a Point2F representing the position of the root.")
{
return object->getRoot();
}
DefineConsoleMethod( GuiTerrPreviewCtrl, setOrigin, void, (Point2F pos), , "(float x, float y)"
DefineEngineMethod( GuiTerrPreviewCtrl, setOrigin, void, (Point2F pos), , "(float x, float y)"
"Set the origin of the view.")
{
object->setOrigin( pos );
}
DefineConsoleMethod( GuiTerrPreviewCtrl, getOrigin, Point2F, (), , "Return a Point2F containing the position of the origin.")
DefineEngineMethod( GuiTerrPreviewCtrl, getOrigin, Point2F, (), , "Return a Point2F containing the position of the origin.")
{
return object->getOrigin();
}
DefineConsoleMethod( GuiTerrPreviewCtrl, getValue, const char*, (), , "Returns a 4-tuple containing: root_x root_y origin_x origin_y")
DefineEngineMethod( GuiTerrPreviewCtrl, getValue, const char*, (), , "Returns a 4-tuple containing: root_x root_y origin_x origin_y")
{
Point2F r = object->getRoot();
Point2F o = object->getOrigin();
@ -126,7 +126,7 @@ DefineConsoleMethod( GuiTerrPreviewCtrl, getValue, const char*, (), , "Returns a
return valuebuf;
}
DefineConsoleMethod( GuiTerrPreviewCtrl, setValue, void, (const char * tuple), , "Accepts a 4-tuple in the same form as getValue returns.\n\n"
DefineEngineMethod( GuiTerrPreviewCtrl, setValue, void, (const char * tuple), , "Accepts a 4-tuple in the same form as getValue returns.\n\n"
"@see GuiTerrPreviewCtrl::getValue()")
{
Point2F r,o;

View file

@ -795,7 +795,7 @@ void TerrainSmoothAction::smooth( TerrainBlock *terrain, F32 factor, U32 steps )
redo();
}
DefineConsoleMethod( TerrainSmoothAction, smooth, void, ( TerrainBlock *terrain, F32 factor, U32 steps ), , "( TerrainBlock obj, F32 factor, U32 steps )")
DefineEngineMethod( TerrainSmoothAction, smooth, void, ( TerrainBlock *terrain, F32 factor, U32 steps ), , "( TerrainBlock obj, F32 factor, U32 steps )")
{
if (terrain)
object->smooth( terrain, factor, mClamp( steps, 1, 13 ) );

View file

@ -2403,7 +2403,7 @@ void TerrainEditor::reorderMaterial( S32 index, S32 orderPos )
//------------------------------------------------------------------------------
DefineConsoleMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)")
DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)")
{
SimSet * missionGroup = dynamic_cast<SimSet*>(Sim::findObject("MissionGroup"));
if (!missionGroup)
@ -2459,12 +2459,12 @@ DefineConsoleMethod( TerrainEditor, attachTerrain, void, (const char * terrain),
}
}
DefineConsoleMethod( TerrainEditor, getTerrainBlockCount, S32, (), , "()")
DefineEngineMethod( TerrainEditor, getTerrainBlockCount, S32, (), , "()")
{
return object->getTerrainBlockCount();
}
DefineConsoleMethod( TerrainEditor, getTerrainBlock, S32, (S32 index), , "(S32 index)")
DefineEngineMethod( TerrainEditor, getTerrainBlock, S32, (S32 index), , "(S32 index)")
{
TerrainBlock* tb = object->getTerrainBlock(index);
if(!tb)
@ -2473,7 +2473,7 @@ DefineConsoleMethod( TerrainEditor, getTerrainBlock, S32, (S32 index), , "(S32 i
return tb->getId();
}
DefineConsoleMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, (), , "() gets the list of current terrain materials for all terrain blocks.")
DefineEngineMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, (), , "() gets the list of current terrain materials for all terrain blocks.")
{
Vector<StringTableEntry> list;
object->getTerrainBlocksMaterialList(list);
@ -2495,30 +2495,30 @@ DefineConsoleMethod(TerrainEditor, getTerrainBlocksMaterialList, const char *, (
ret[0] = 0;
for(U32 i = 0; i < list.size(); ++i)
{
dStrcat( ret, list[i] );
dStrcat( ret, "\n" );
dStrcat( ret, list[i], size );
dStrcat( ret, "\n", size );
}
return ret;
}
DefineConsoleMethod( TerrainEditor, setBrushType, void, (String type), , "(string type)"
DefineEngineMethod( TerrainEditor, setBrushType, void, (String type), , "(string type)"
"One of box, ellipse, selection.")
{
object->setBrushType(type);
}
DefineConsoleMethod( TerrainEditor, getBrushType, const char*, (), , "()")
DefineEngineMethod( TerrainEditor, getBrushType, const char*, (), , "()")
{
return object->getBrushType();
}
DefineConsoleMethod( TerrainEditor, setBrushSize, void, ( S32 w, S32 h), (0), "(int w [, int h])")
DefineEngineMethod( TerrainEditor, setBrushSize, void, ( S32 w, S32 h), (0), "(int w [, int h])")
{
object->setBrushSize( w, h==0?w:h );
}
DefineConsoleMethod( TerrainEditor, getBrushSize, const char*, (), , "()")
DefineEngineMethod( TerrainEditor, getBrushSize, const char*, (), , "()")
{
Point2I size = object->getBrushSize();
@ -2528,74 +2528,74 @@ DefineConsoleMethod( TerrainEditor, getBrushSize, const char*, (), , "()")
return ret;
}
DefineConsoleMethod( TerrainEditor, setBrushPressure, void, (F32 pressure), , "(float pressure)")
DefineEngineMethod( TerrainEditor, setBrushPressure, void, (F32 pressure), , "(float pressure)")
{
object->setBrushPressure( pressure );
}
DefineConsoleMethod( TerrainEditor, getBrushPressure, F32, (), , "()")
DefineEngineMethod( TerrainEditor, getBrushPressure, F32, (), , "()")
{
return object->getBrushPressure();
}
DefineConsoleMethod( TerrainEditor, setBrushSoftness, void, (F32 softness), , "(float softness)")
DefineEngineMethod( TerrainEditor, setBrushSoftness, void, (F32 softness), , "(float softness)")
{
object->setBrushSoftness( softness );
}
DefineConsoleMethod( TerrainEditor, getBrushSoftness, F32, (), , "()")
DefineEngineMethod( TerrainEditor, getBrushSoftness, F32, (), , "()")
{
return object->getBrushSoftness();
}
DefineConsoleMethod( TerrainEditor, getBrushPos, const char*, (), , "Returns a Point2I.")
DefineEngineMethod( TerrainEditor, getBrushPos, const char*, (), , "Returns a Point2I.")
{
return object->getBrushPos();
}
DefineConsoleMethod( TerrainEditor, setBrushPos, void, (Point2I pos), , "Location")
DefineEngineMethod( TerrainEditor, setBrushPos, void, (Point2I pos), , "Location")
{
object->setBrushPos(pos);
}
DefineConsoleMethod( TerrainEditor, setAction, void, (const char * action_name), , "(string action_name)")
DefineEngineMethod( TerrainEditor, setAction, void, (const char * action_name), , "(string action_name)")
{
object->setAction(action_name);
}
DefineConsoleMethod( TerrainEditor, getActionName, const char*, (U32 index), , "(int num)")
DefineEngineMethod( TerrainEditor, getActionName, const char*, (U32 index), , "(int num)")
{
return (object->getActionName(index));
}
DefineConsoleMethod( TerrainEditor, getNumActions, S32, (), , "")
DefineEngineMethod( TerrainEditor, getNumActions, S32, (), , "")
{
return(object->getNumActions());
}
DefineConsoleMethod( TerrainEditor, getCurrentAction, const char*, (), , "")
DefineEngineMethod( TerrainEditor, getCurrentAction, const char*, (), , "")
{
return object->getCurrentAction();
}
DefineConsoleMethod( TerrainEditor, resetSelWeights, void, (bool clear), , "(bool clear)")
DefineEngineMethod( TerrainEditor, resetSelWeights, void, (bool clear), , "(bool clear)")
{
object->resetSelWeights(clear);
}
DefineConsoleMethod( TerrainEditor, clearSelection, void, (), , "")
DefineEngineMethod( TerrainEditor, clearSelection, void, (), , "")
{
object->clearSelection();
}
DefineConsoleMethod( TerrainEditor, processAction, void, (String action), (""), "(string action=NULL)")
DefineEngineMethod( TerrainEditor, processAction, void, (String action), (""), "(string action=NULL)")
{
object->processAction(action);
}
DefineConsoleMethod( TerrainEditor, getActiveTerrain, S32, (), , "")
DefineEngineMethod( TerrainEditor, getActiveTerrain, S32, (), , "")
{
S32 ret = 0;
@ -2607,27 +2607,27 @@ DefineConsoleMethod( TerrainEditor, getActiveTerrain, S32, (), , "")
return ret;
}
DefineConsoleMethod( TerrainEditor, getNumTextures, S32, (), , "")
DefineEngineMethod( TerrainEditor, getNumTextures, S32, (), , "")
{
return object->getNumTextures();
}
DefineConsoleMethod( TerrainEditor, markEmptySquares, void, (), , "")
DefineEngineMethod( TerrainEditor, markEmptySquares, void, (), , "")
{
object->markEmptySquares();
}
DefineConsoleMethod( TerrainEditor, mirrorTerrain, void, (S32 mirrorIndex), , "")
DefineEngineMethod( TerrainEditor, mirrorTerrain, void, (S32 mirrorIndex), , "")
{
object->mirrorTerrain(mirrorIndex);
}
DefineConsoleMethod(TerrainEditor, setTerraformOverlay, void, (bool overlayEnable), , "(bool overlayEnable) - sets the terraformer current heightmap to draw as an overlay over the current terrain.")
DefineEngineMethod(TerrainEditor, setTerraformOverlay, void, (bool overlayEnable), , "(bool overlayEnable) - sets the terraformer current heightmap to draw as an overlay over the current terrain.")
{
// XA: This one needs to be implemented :)
}
DefineConsoleMethod(TerrainEditor, updateMaterial, bool, ( U32 index, String matName ), ,
DefineEngineMethod(TerrainEditor, updateMaterial, bool, ( U32 index, String matName ), ,
"( int index, string matName )\n"
"Changes the material name at the index." )
{
@ -2645,7 +2645,7 @@ DefineConsoleMethod(TerrainEditor, updateMaterial, bool, ( U32 index, String mat
return true;
}
DefineConsoleMethod(TerrainEditor, addMaterial, S32, ( String matName ), ,
DefineEngineMethod(TerrainEditor, addMaterial, S32, ( String matName ), ,
"( string matName )\n"
"Adds a new material." )
{
@ -2660,7 +2660,7 @@ DefineConsoleMethod(TerrainEditor, addMaterial, S32, ( String matName ), ,
return true;
}
DefineConsoleMethod( TerrainEditor, removeMaterial, void, ( S32 index ), , "( int index ) - Remove the material at the given index." )
DefineEngineMethod( TerrainEditor, removeMaterial, void, ( S32 index ), , "( int index ) - Remove the material at the given index." )
{
TerrainBlock *terr = object->getClientTerrain();
if ( !terr )
@ -2689,7 +2689,7 @@ DefineConsoleMethod( TerrainEditor, removeMaterial, void, ( S32 index ), , "( in
object->setGridUpdateMinMax();
}
DefineConsoleMethod(TerrainEditor, getMaterialCount, S32, (), ,
DefineEngineMethod(TerrainEditor, getMaterialCount, S32, (), ,
"Returns the current material count." )
{
TerrainBlock *terr = object->getClientTerrain();
@ -2699,7 +2699,7 @@ DefineConsoleMethod(TerrainEditor, getMaterialCount, S32, (), ,
return 0;
}
DefineConsoleMethod(TerrainEditor, getMaterials, const char *, (), , "() gets the list of current terrain materials.")
DefineEngineMethod(TerrainEditor, getMaterials, const char *, (), , "() gets the list of current terrain materials.")
{
TerrainBlock *terr = object->getClientTerrain();
if ( !terr )
@ -2709,14 +2709,14 @@ DefineConsoleMethod(TerrainEditor, getMaterials, const char *, (), , "() gets th
ret[0] = 0;
for(U32 i = 0; i < terr->getMaterialCount(); i++)
{
dStrcat( ret, terr->getMaterialName(i) );
dStrcat( ret, "\n" );
dStrcat( ret, terr->getMaterialName(i), 4096 );
dStrcat( ret, "\n", 4096 );
}
return ret;
}
DefineConsoleMethod( TerrainEditor, getMaterialName, const char*, (S32 index), , "( int index ) - Returns the name of the material at the given index." )
DefineEngineMethod( TerrainEditor, getMaterialName, const char*, (S32 index), , "( int index ) - Returns the name of the material at the given index." )
{
TerrainBlock *terr = object->getClientTerrain();
if ( !terr )
@ -2732,7 +2732,7 @@ DefineConsoleMethod( TerrainEditor, getMaterialName, const char*, (S32 index), ,
return Con::getReturnBuffer( name );
}
DefineConsoleMethod( TerrainEditor, getMaterialIndex, S32, ( String name ), , "( string name ) - Returns the index of the material with the given name or -1." )
DefineEngineMethod( TerrainEditor, getMaterialIndex, S32, ( String name ), , "( string name ) - Returns the index of the material with the given name or -1." )
{
TerrainBlock *terr = object->getClientTerrain();
if ( !terr )
@ -2747,13 +2747,13 @@ DefineConsoleMethod( TerrainEditor, getMaterialIndex, S32, ( String name ), , "(
return -1;
}
DefineConsoleMethod( TerrainEditor, reorderMaterial, void, ( S32 index, S32 orderPos ), , "( int index, int order ) "
DefineEngineMethod( TerrainEditor, reorderMaterial, void, ( S32 index, S32 orderPos ), , "( int index, int order ) "
"- Reorder material at the given index to the new position, changing the order in which it is rendered / blended." )
{
object->reorderMaterial( index, orderPos );
}
DefineConsoleMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, (const char * ptOrX, const char * Y, const char * Z), ("", "", ""),
DefineEngineMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, (const char * ptOrX, const char * Y, const char * Z), ("", "", ""),
"(x/y/z) Gets the terrain block that is located under the given world point.\n"
"@param x/y/z The world coordinates (floating point values) you wish to query at. "
"These can be formatted as either a string (\"x y z\") or separately as (x, y, z)\n"
@ -2822,12 +2822,12 @@ void TerrainEditor::initPersistFields()
Parent::initPersistFields();
}
DefineConsoleMethod( TerrainEditor, getSlopeLimitMinAngle, F32, (), , "")
DefineEngineMethod( TerrainEditor, getSlopeLimitMinAngle, F32, (), , "")
{
return object->mSlopeMinAngle;
}
DefineConsoleMethod( TerrainEditor, setSlopeLimitMinAngle, F32, (F32 angle), , "")
DefineEngineMethod( TerrainEditor, setSlopeLimitMinAngle, F32, (F32 angle), , "")
{
if ( angle < 0.0f )
angle = 0.0f;
@ -2838,12 +2838,12 @@ DefineConsoleMethod( TerrainEditor, setSlopeLimitMinAngle, F32, (F32 angle), , "
return angle;
}
DefineConsoleMethod( TerrainEditor, getSlopeLimitMaxAngle, F32, (), , "")
DefineEngineMethod( TerrainEditor, getSlopeLimitMaxAngle, F32, (), , "")
{
return object->mSlopeMaxAngle;
}
DefineConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, (F32 angle), , "")
DefineEngineMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, (F32 angle), , "")
{
if ( angle > 90.0f )
angle = 90.0f;
@ -2857,14 +2857,21 @@ DefineConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, (F32 angle), , "
//------------------------------------------------------------------------------
void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage )
{
if (!mActiveTerrain)
#define AUTOPAINT_UNDO
if (!mActiveTerrain)
return;
S32 mat = getPaintMaterialIndex();
if (mat == -1)
return;
mUndoSel = new Selection;
#ifndef AUTOPAINT_UNDO
mUndoSel = new Selection;
#endif
U32 terrBlocks = mActiveTerrain->getBlockSize();
for (U32 y = 0; y < terrBlocks; y++)
@ -2906,19 +2913,23 @@ void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinS
if (norm.z < mSin(mDegToRad(90.0f - mMaxSlope)))
continue;
gi.mMaterialChanged = true;
mUndoSel->add(gi);
gi.mMaterialChanged = true;
#ifndef AUTOPAINT_UNDO
mUndoSel->add(gi);
#endif
gi.mMaterial = mat;
setGridInfo(gi);
}
}
#ifndef AUTOPAINT_UNDO
if(mUndoSel->size())
submitUndo( mUndoSel );
else
delete mUndoSel;
mUndoSel = 0;
#endif
scheduleMaterialUpdate();
}

View file

@ -0,0 +1,136 @@
#include "editorTool.h"
IMPLEMENT_CONOBJECT(EditorTool);
EditorTool::EditorTool()
{
mWorldEditor = NULL;
mUseMouseDown = true;
mUseMouseUp = true;
mUseMouseMove = true;
mUseRightMouseDown = false;
mUseRightMouseUp = false;
mUseRightMouseMove = false;
mUseMiddleMouseDown = true;
mUseMiddleMouseUp = true;
mUseMiddleMouseMove = true;
mUseKeyInput = true;
}
bool EditorTool::onAdd()
{
return Parent::onAdd();
}
void EditorTool::onRemove()
{
Parent::onRemove();
}
//Called when the tool is activated on the World Editor
void EditorTool::onActivated(WorldEditor* editor)
{
mWorldEditor = editor;
Con::executef(this, "onActivated");
}
//Called when the tool is deactivated on the World Editor
void EditorTool::onDeactivated()
{
mWorldEditor = NULL;
Con::executef(this, "onDeactivated");
}
//
bool EditorTool::onMouseMove(const Gui3DMouseEvent &e)
{
if (!mUseMouseDown)
return false;
Con::executef(this, "onMouseMove", e.mousePoint);
return true;
}
bool EditorTool::onMouseDown(const Gui3DMouseEvent &e)
{
if (!mUseMouseDown)
return false;
Con::executef(this, "onMouseDown", e.mousePoint);
return true;
}
bool EditorTool::onMouseDragged(const Gui3DMouseEvent &e)
{
Con::executef(this, "onMouseDragged", e.mousePoint);
return true;
}
bool EditorTool::onMouseUp(const Gui3DMouseEvent &e)
{
if (!mUseMouseDown)
return false;
Con::executef(this, "onMouseUp", e.mousePoint);
return true;
}
//
bool EditorTool::onRightMouseDown(const Gui3DMouseEvent &e)
{
if (!mUseRightMouseDown)
return false;
Con::executef(this, "onRightMouseDown", e.mousePoint);
return true;
}
bool EditorTool::onRightMouseDragged(const Gui3DMouseEvent &e)
{
Con::executef(this, "onRightMouseDragged", e.mousePoint);
return true;
}
bool EditorTool::onRightMouseUp(const Gui3DMouseEvent &e)
{
if (!mUseRightMouseDown)
return false;
Con::executef(this, "onRightMouseUp", e.mousePoint);
return true;
}
//
bool EditorTool::onMiddleMouseDown(const Gui3DMouseEvent &e)
{
if (!mUseMiddleMouseDown)
return false;
Con::executef(this, "onMiddleMouseDown", e.mousePoint);
return true;
}
bool EditorTool::onMiddleMouseDragged(const Gui3DMouseEvent &e)
{
Con::executef(this, "onMiddleMouseDragged", e.mousePoint);
return true;
}
bool EditorTool::onMiddleMouseUp(const Gui3DMouseEvent &e)
{
if (!mUseMiddleMouseDown)
return false;
Con::executef(this, "onMiddleMouseUp", e.mousePoint);
return true;
}
//
bool EditorTool::onInputEvent(const InputEventInfo &e)
{
if (!mUseKeyInput)
return false;
Con::executef(this, "onKeyPress", e.ascii, e.modifier);
return true;
}
//
void render(SceneRenderState *);

View file

@ -0,0 +1,88 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _EDITOR_TOOL_
#define _EDITOR_TOOL_
#ifndef _WORLDEDITOR_H_
#include "gui/worldEditor/worldEditor.h"
#endif
class EditorTool : public SimObject
{
typedef SimObject Parent;
protected:
WorldEditor* mWorldEditor;
bool mUseMouseDown;
bool mUseMouseUp;
bool mUseMouseMove;
bool mUseRightMouseDown;
bool mUseRightMouseUp;
bool mUseRightMouseMove;
bool mUseMiddleMouseDown;
bool mUseMiddleMouseUp;
bool mUseMiddleMouseMove;
bool mUseKeyInput;
public:
EditorTool();
~EditorTool(){}
DECLARE_CONOBJECT(EditorTool);
bool onAdd();
void onRemove();
//Called when the tool is activated on the World Editor
virtual void onActivated(WorldEditor*);
//Called when the tool is deactivated on the World Editor
virtual void onDeactivated();
//
virtual bool onMouseMove(const Gui3DMouseEvent &);
virtual bool onMouseDown(const Gui3DMouseEvent &);
virtual bool onMouseDragged(const Gui3DMouseEvent &);
virtual bool onMouseUp(const Gui3DMouseEvent &);
//
virtual bool onRightMouseDown(const Gui3DMouseEvent &);
virtual bool onRightMouseDragged(const Gui3DMouseEvent &);
virtual bool onRightMouseUp(const Gui3DMouseEvent &);
//
virtual bool onMiddleMouseDown(const Gui3DMouseEvent &);
virtual bool onMiddleMouseDragged(const Gui3DMouseEvent &);
virtual bool onMiddleMouseUp(const Gui3DMouseEvent &);
//
virtual bool onInputEvent(const InputEventInfo &);
//
virtual void render(){}
};
#endif

View file

@ -49,6 +49,7 @@
#include "math/mEase.h"
#include "T3D/tsStatic.h"
#include "tools/editorTool.h"
IMPLEMENT_CONOBJECT( WorldEditor );
@ -1453,16 +1454,16 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
}
CameraSpline::Knot::Path path;
CameraSpline::Knot::Path tPath;
switch (pathmarker->mSmoothingType)
{
case Marker::SmoothingTypeLinear: path = CameraSpline::Knot::LINEAR; break;
case Marker::SmoothingTypeLinear: tPath = CameraSpline::Knot::LINEAR; break;
case Marker::SmoothingTypeSpline:
default: path = CameraSpline::Knot::SPLINE; break;
default: tPath = CameraSpline::Knot::SPLINE; break;
}
spline.push_back(new CameraSpline::Knot(pos, rot, 1.0f, type, path));
spline.push_back(new CameraSpline::Knot(pos, rot, 1.0f, type, tPath));
}
F32 t = 0.0f;
@ -1558,8 +1559,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
// Reset for next pass...
vIdx = 0;
void *lockPtr = vb.lock();
if(!lockPtr) return;
void *nextlockPtr = vb.lock();
if(!nextlockPtr) return;
}
}
@ -1823,6 +1824,8 @@ WorldEditor::WorldEditor()
mUseGroupCenter = true;
mFadeIcons = true;
mFadeIconsDist = 8.f;
mActiveEditorTool = nullptr;
}
WorldEditor::~WorldEditor()
@ -1915,6 +1918,10 @@ void WorldEditor::on3DMouseMove(const Gui3DMouseEvent & event)
setCursor(PlatformCursorController::curArrow);
mHitObject = NULL;
//If we have an active tool and it's intercepted our input, bail out
if (mActiveEditorTool != nullptr && mActiveEditorTool->onMouseMove(event))
return;
//
mUsingAxisGizmo = false;
@ -1943,6 +1950,10 @@ void WorldEditor::on3DMouseMove(const Gui3DMouseEvent & event)
void WorldEditor::on3DMouseDown(const Gui3DMouseEvent & event)
{
//If we have an active tool and it's intercepted our input, bail out
if (mActiveEditorTool != nullptr && mActiveEditorTool->onMouseDown(event))
return;
mMouseDown = true;
mMouseDragged = false;
mPerformedDragCopy = false;
@ -2010,6 +2021,10 @@ void WorldEditor::on3DMouseDown(const Gui3DMouseEvent & event)
void WorldEditor::on3DMouseUp( const Gui3DMouseEvent &event )
{
//If we have an active tool and it's intercepted our input, bail out
if (mActiveEditorTool != nullptr && mActiveEditorTool->onMouseUp(event))
return;
const bool wasUsingAxisGizmo = mUsingAxisGizmo;
mMouseDown = false;
@ -2165,6 +2180,10 @@ void WorldEditor::on3DMouseUp( const Gui3DMouseEvent &event )
void WorldEditor::on3DMouseDragged(const Gui3DMouseEvent & event)
{
//If we have an active tool and it's intercepted our input, bail out
if (mActiveEditorTool != nullptr && mActiveEditorTool->onMouseDragged(event))
return;
if ( !mMouseDown )
return;
@ -2400,6 +2419,9 @@ void WorldEditor::renderScene( const RectI &updateRect )
GFXDEBUGEVENT_SCOPE( Editor_renderScene, ColorI::RED );
smRenderSceneSignal.trigger(this);
if (mActiveEditorTool != nullptr)
mActiveEditorTool->render();
// Grab this before anything here changes it.
Frustum frustum;
@ -3014,25 +3036,25 @@ bool WorldEditor::alignByAxis( S32 axis )
if(mSelected->size() < 2)
return true;
SceneObject* object = dynamic_cast< SceneObject* >( ( *mSelected )[ 0 ] );
if( !object )
SceneObject* primaryObj = dynamic_cast< SceneObject* >( ( *mSelected )[ 0 ] );
if( !primaryObj)
return false;
submitUndo( mSelected, "Align By Axis" );
// All objects will be repositioned to line up with the
// first selected object
Point3F pos = object->getPosition();
Point3F pos = primaryObj->getPosition();
for(S32 i=0; i<mSelected->size(); ++i)
{
SceneObject* object = dynamic_cast< SceneObject* >( ( *mSelected )[ i ] );
if( !object )
SceneObject* additionalObj = dynamic_cast< SceneObject* >( ( *mSelected )[ i ] );
if( !additionalObj)
continue;
Point3F objPos = object->getPosition();
Point3F objPos = additionalObj->getPosition();
objPos[axis] = pos[axis];
object->setPosition(objPos);
additionalObj->setPosition(objPos);
}
return true;
@ -3190,7 +3212,20 @@ void WorldEditor::resetSelectedScale()
//------------------------------------------------------------------------------
ConsoleMethod( WorldEditor, ignoreObjClass, void, 3, 0, "(string class_name, ...)")
void WorldEditor::setEditorTool(EditorTool* newTool)
{
if (mActiveEditorTool)
mActiveEditorTool->onDeactivated();
mActiveEditorTool = newTool;
if (mActiveEditorTool)
mActiveEditorTool->onActivated(this);
}
//------------------------------------------------------------------------------
DefineEngineStringlyVariadicMethod( WorldEditor, ignoreObjClass, void, 3, 0, "(string class_name, ...)")
{
object->ignoreObjClass(argc, argv);
}
@ -3217,7 +3252,7 @@ DefineEngineMethod( WorldEditor, getActiveSelection, S32, (),,
return object->getActiveSelectionSet()->getId();
}
DefineConsoleMethod( WorldEditor, setActiveSelection, void, ( WorldEditorSelection* selection), ,
DefineEngineMethod( WorldEditor, setActiveSelection, void, ( WorldEditorSelection* selection), ,
"Set the currently active WorldEditorSelection object.\n"
"@param selection A WorldEditorSelectionSet object to use for the selection container.")
{
@ -3892,15 +3927,38 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
OptimizedPolyList polyList;
polyList.setBaseTransform(orientation);
ColladaUtils::ExportData exportData;
for (S32 i = 0; i < objectList.size(); i++)
{
SceneObject *pObj = objectList[i];
if (!pObj->buildPolyList(PLC_Export, &polyList, pObj->getWorldBox(), pObj->getWorldSphere()))
if (!pObj->buildExportPolyList(&exportData, pObj->getWorldBox(), pObj->getWorldSphere()))
Con::warnf("colladaExportObjectList() - object %i returned no geometry.", pObj->getId());
}
//Now that we have all of our mesh data, process it so we can correctly collapse everything.
exportData.processData();
//recenter generated visual mesh results
for (U32 dl = 0; dl < exportData.colMeshes.size(); dl++)
{
for (U32 pnt = 0; pnt < exportData.colMeshes[dl].mesh.mPoints.size(); pnt++)
{
exportData.colMeshes[dl].mesh.mPoints[pnt] -= centroid;
}
}
//recenter generated collision mesh results
for (U32 dl = 0; dl < exportData.detailLevels.size(); dl++)
{
for (U32 pnt = 0; pnt < exportData.detailLevels[dl].mesh.mPoints.size(); pnt++)
{
exportData.detailLevels[dl].mesh.mPoints[pnt] -= centroid;
}
}
// Use a ColladaUtils function to do the actual export to a Collada file
ColladaUtils::exportToCollada(filename, polyList);
ColladaUtils::exportToCollada(filename, exportData);
//
// Allocate TSStatic object and add to level.
@ -4015,8 +4073,8 @@ DefineEngineMethod( WorldEditor, createPolyhedralObject, SceneObject*, ( const c
// Create the object.
SceneObject* object = dynamic_cast< SceneObject* >( classRep->create() );
if( !Object )
SceneObject* polyObj = dynamic_cast< SceneObject* >( classRep->create() );
if( !polyObj)
{
Con::errorf( "WorldEditor::createPolyhedralObject - Could not create SceneObject with class '%s'", className );
return NULL;
@ -4034,7 +4092,7 @@ DefineEngineMethod( WorldEditor, createPolyhedralObject, SceneObject*, ( const c
for( U32 i = 0; i < numPoints; ++ i )
{
static StringTableEntry sPoint = StringTable->insert( "point" );
object->setDataField( sPoint, NULL, EngineMarshallData( points[ i ] ) );
polyObj->setDataField( sPoint, NULL, EngineMarshallData( points[ i ] ) );
}
// Add the plane data.
@ -4050,7 +4108,7 @@ DefineEngineMethod( WorldEditor, createPolyhedralObject, SceneObject*, ( const c
char buffer[ 1024 ];
dSprintf( buffer, sizeof( buffer ), "%g %g %g %g", plane.x, plane.y, plane.z, plane.d );
object->setDataField( sPlane, NULL, buffer );
polyObj->setDataField( sPlane, NULL, buffer );
}
// Add the edge data.
@ -4069,24 +4127,24 @@ DefineEngineMethod( WorldEditor, createPolyhedralObject, SceneObject*, ( const c
edge.vertex[ 0 ], edge.vertex[ 1 ]
);
object->setDataField( sEdge, NULL, buffer );
polyObj->setDataField( sEdge, NULL, buffer );
}
// Set the transform.
object->setTransform( savedTransform );
object->setScale( savedScale );
polyObj->setTransform( savedTransform );
polyObj->setScale( savedScale );
// Register and return the object.
if( !object->registerObject() )
if( !polyObj->registerObject() )
{
Con::errorf( "WorldEditor::createPolyhedralObject - Failed to register object!" );
delete object;
delete polyObj;
return NULL;
}
return object;
return polyObj;
}
//-----------------------------------------------------------------------------
@ -4175,3 +4233,15 @@ DefineEngineMethod( WorldEditor, createConvexShapeFrom, ConvexShape*, ( SceneObj
return shape;
}
DefineEngineMethod(WorldEditor, setEditorTool, void, (EditorTool* newEditorTool), (nullAsType<EditorTool*>()),
"Sets the active Editor Tool for the world editor.")
{
object->setEditorTool(newEditorTool);
}
DefineEngineMethod(WorldEditor, getActiveEditorTool, EditorTool*, (),,
"Gets the active Editor Tool for the world editor.")
{
return object->getActiveEditorTool();
}

View file

@ -58,7 +58,7 @@
class SceneObject;
class WorldEditorSelection;
class EditorTool;
///
class WorldEditor : public EditTSCtrl
@ -285,6 +285,9 @@ class WorldEditor : public EditTSCtrl
ClassInfo::Entry * getClassEntry(const SimObject * obj);
bool addClassEntry(ClassInfo::Entry * entry);
EditorTool* mActiveEditorTool;
// persist field data
public:
@ -411,6 +414,9 @@ class WorldEditor : public EditTSCtrl
DECLARE_CONOBJECT(WorldEditor);
static Signal<void(WorldEditor*)> smRenderSceneSignal;
void setEditorTool(EditorTool*);
EditorTool* getActiveEditorTool() { return mActiveEditorTool; }
};
typedef WorldEditor::DropType WorldEditorDropType;

View file

@ -23,7 +23,7 @@
#include "gui/worldEditor/worldEditorSelection.h"
#include "gui/worldEditor/worldEditor.h"
#include "scene/sceneObject.h"
#include "T3D/entity.h"
IMPLEMENT_CONOBJECT( WorldEditorSelection );
@ -410,26 +410,34 @@ void WorldEditorSelection::rotate(const EulerF & rot, const Point3F & center)
// single selections will rotate around own axis, multiple about world
if(size() == 1)
{
SceneObject* object = dynamic_cast< SceneObject* >( at( 0 ) );
if( object )
Entity* eO = dynamic_cast< Entity* >(at(0));
if (eO)
{
MatrixF mat = object->getTransform();
eO->setTransform(eO->getPosition(), eO->getRotation() + RotationF(rot));
}
else
{
SceneObject* object = dynamic_cast<SceneObject*>(at(0));
if (object)
{
MatrixF mat = object->getTransform();
Point3F pos;
mat.getColumn(3, &pos);
Point3F pos;
mat.getColumn(3, &pos);
// get offset in obj space
Point3F offset = pos - center;
MatrixF wMat = object->getWorldTransform();
wMat.mulV(offset);
// get offset in obj space
Point3F offset = pos - center;
MatrixF wMat = object->getWorldTransform();
wMat.mulV(offset);
//
MatrixF transform(EulerF(0,0,0), -offset);
transform.mul(MatrixF(rot));
transform.mul(MatrixF(EulerF(0,0,0), offset));
mat.mul(transform);
//
MatrixF transform(EulerF(0, 0, 0), -offset);
transform.mul(MatrixF(rot));
transform.mul(MatrixF(EulerF(0, 0, 0), offset));
mat.mul(transform);
object->setTransform(mat);
object->setTransform(mat);
}
}
}
else
@ -649,58 +657,42 @@ void WorldEditorSelection::setSize(const VectorF & newsize)
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, containsGlobalBounds, bool, 2, 2, "() - True if an object with global bounds is contained in the selection." )
DefineEngineMethod( WorldEditorSelection, containsGlobalBounds, bool, (),, "True if an object with global bounds is contained in the selection." )
{
return object->containsGlobalBounds();
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Return the median of all object positions in the selection." )
DefineEngineMethod( WorldEditorSelection, getCentroid, Point3F, (),, "Return the median of all object positions in the selection." )
{
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& centroid = object->getCentroid();
dSprintf( buffer, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z );
return buffer;
return centroid;
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, getBoxCentroid, const char*, 2, 2, "() - Return the center of the bounding box around the selection." )
DefineEngineMethod( WorldEditorSelection, getBoxCentroid, Point3F, (),, "Return the center of the bounding box around the selection." )
{
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& boxCentroid = object->getBoxCentroid();
dSprintf( buffer, bufSize, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
return buffer;
return boxCentroid;
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, offset, void, 3, 4, "( vector delta, float gridSnap=0 ) - Move all objects in the selection by the given delta." )
{
F32 x, y, z;
dSscanf( argv[ 3 ], "%g %g %g", &x, &y, &z );
F32 gridSnap = 0.f;
if( argc > 3 )
gridSnap = dAtof( argv[ 3 ] );
object->offset( Point3F( x, y, z ), gridSnap );
DefineEngineMethod(WorldEditorSelection, offset, void, (Point3F delta, F32 gridSnap), (0.0f), "Move all objects in the selection by the given delta.")
{
object->offset( delta, gridSnap );
WorldEditor::updateClientTransforms( object );
}
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add all objects in the given set to this selection." )
DefineEngineMethod( WorldEditorSelection, union, void, (SimSet* selection),, "Add all objects in the given set to this selection." )
{
SimSet* selection;
if( !Sim::findObject( argv[ 2 ], selection ) )
if( !selection)
{
Con::errorf( "WorldEditorSelection::union - no SimSet '%s'", (const char*)argv[ 2 ] );
Con::errorf( "WorldEditorSelection::union - no SimSet");
return;
}
@ -711,12 +703,11 @@ ConsoleMethod( WorldEditorSelection, union, void, 3, 3, "( SimSet set ) - Add al
//-----------------------------------------------------------------------------
ConsoleMethod( WorldEditorSelection, subtract, void, 3, 3, "( SimSet ) - Remove all objects in the given set from this selection." )
DefineEngineMethod( WorldEditorSelection, subtract, void, (SimSet* selection),, "Remove all objects in the given set from this selection." )
{
SimSet* selection;
if( !Sim::findObject( argv[ 2 ], selection ) )
if( !selection )
{
Con::errorf( "WorldEditorSelection::subtract - no SimSet '%s'", (const char*)argv[ 2 ] );
Con::errorf( "WorldEditorSelection::subtract - no SimSet" );
return;
}