mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-02 03:53:50 +00:00
Merge branch 'development' into EngineAPI-Refactor
This commit is contained in:
commit
3a71c75596
1937 changed files with 102332 additions and 70549 deletions
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -658,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1034,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" );
|
||||
|
|
|
|||
|
|
@ -1369,19 +1369,19 @@ void GuiMenuBar::buildWindowAcceleratorMap(WindowInputGenerator &inputGenerator)
|
|||
{
|
||||
for (U32 item = 0; item < mMenuList[i].popupMenu->mMenuItems.size(); item++)
|
||||
{
|
||||
if (!mMenuList[i].popupMenu->mMenuItems[item].accelerator)
|
||||
if (!mMenuList[i].popupMenu->mMenuItems[item].mAccelerator)
|
||||
{
|
||||
mMenuList[i].popupMenu->mMenuItems[item].accelerator = 0;
|
||||
mMenuList[i].popupMenu->mMenuItems[item].mAccelerator = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
EventDescriptor accelEvent;
|
||||
ActionMap::createEventDescriptor(mMenuList[i].popupMenu->mMenuItems[item].accelerator, &accelEvent);
|
||||
ActionMap::createEventDescriptor(mMenuList[i].popupMenu->mMenuItems[item].mAccelerator, &accelEvent);
|
||||
|
||||
//now we have a modifier, and a key, add them to the canvas
|
||||
inputGenerator.addAcceleratorKey(this, mMenuList[i].popupMenu->mMenuItems[item].cmd, accelEvent.eventCode, accelEvent.flags);
|
||||
inputGenerator.addAcceleratorKey(this, mMenuList[i].popupMenu->mMenuItems[item].mCMD, accelEvent.eventCode, accelEvent.flags);
|
||||
|
||||
mMenuList[i].popupMenu->mMenuItems[item].acceleratorIndex = mCurAcceleratorIndex;
|
||||
mMenuList[i].popupMenu->mMenuItems[item].mAcceleratorIndex = mCurAcceleratorIndex;
|
||||
mCurAcceleratorIndex++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1403,7 +1403,7 @@ void GuiMenuBar::acceleratorKeyPress(U32 index)
|
|||
|
||||
for(U32 item = 0; item < mMenuList[i].popupMenu->mMenuItems.size(); item++)
|
||||
{
|
||||
if(mMenuList[i].popupMenu->mMenuItems[item].acceleratorIndex == index)
|
||||
if(mMenuList[i].popupMenu->mMenuItems[item].mAcceleratorIndex == index)
|
||||
{
|
||||
// first, call the script callback for menu selection:
|
||||
onMenuSelect_callback(mMenuList[i].popupMenu->getId(), mMenuList[i].text);
|
||||
|
|
@ -1454,7 +1454,7 @@ void GuiMenuBar::insert(SimObject* pObject, S32 pos)
|
|||
newMenu.drawBitmapOnly = false;
|
||||
newMenu.drawBorder = true;
|
||||
newMenu.bitmapIndex = -1;
|
||||
newMenu.text = menu->barTitle;
|
||||
newMenu.text = menu->mBarTitle;
|
||||
newMenu.visible = true;
|
||||
newMenu.popupMenu = menu;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ GuiPopupMenuTextListCtrl::GuiPopupMenuTextListCtrl()
|
|||
void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
|
||||
{
|
||||
//check if we're a real entry, or if it's a divider
|
||||
if (mPopup->mMenuItems[cell.y].isSpacer)
|
||||
if (mPopup->mMenuItems[cell.y].mIsSpacer)
|
||||
{
|
||||
S32 yp = offset.y + mCellSize.y / 2;
|
||||
GFX->getDrawUtil()->drawLine(offset.x + 5, yp, offset.x + mCellSize.x - 5, yp, ColorI(128, 128, 128));
|
||||
|
|
@ -214,8 +214,8 @@ void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
|
|||
|
||||
if (item)
|
||||
{
|
||||
if (item->enabled)
|
||||
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->text.isNotEmpty() ? item->text : ""));
|
||||
if (item->mEnabled)
|
||||
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +247,9 @@ void GuiPopupMenuTextListCtrl::onCellHighlighted(Point2I cell)
|
|||
{
|
||||
MenuItem *list = &mPopup->mMenuItems[selectionIndex];
|
||||
|
||||
if (list->isSubmenu && list->subMenu != nullptr)
|
||||
if (list->mIsSubmenu && list->mSubMenu != nullptr)
|
||||
{
|
||||
list->subMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y));
|
||||
list->mSubMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
@ -1244,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 )
|
||||
|
|
@ -1442,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;
|
||||
|
|
@ -1544,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();
|
||||
|
|
|
|||
|
|
@ -46,14 +46,20 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
PopupMenu::PopupMenu()
|
||||
{
|
||||
bitmapIndex = -1;
|
||||
mMenuItems = NULL;
|
||||
mMenuBarCtrl = nullptr;
|
||||
|
||||
barTitle = StringTable->EmptyString();
|
||||
mBarTitle = StringTable->EmptyString();
|
||||
mBounds = RectI(0, 0, 64, 64);
|
||||
mVisible = true;
|
||||
|
||||
mMenuBarCtrl = nullptr;
|
||||
mTextList = nullptr;
|
||||
mBitmapIndex = -1;
|
||||
mDrawBitmapOnly = false;
|
||||
mDrawBorder = false;
|
||||
|
||||
isSubmenu = false;
|
||||
mTextList = nullptr;
|
||||
|
||||
mIsSubmenu = false;
|
||||
}
|
||||
|
||||
PopupMenu::~PopupMenu()
|
||||
|
|
@ -76,7 +82,7 @@ void PopupMenu::initPersistFields()
|
|||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("barTitle", TypeCaseString, Offset(barTitle, PopupMenu), "");
|
||||
addField("barTitle", TypeCaseString, Offset(mBarTitle, PopupMenu), "");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -134,28 +140,28 @@ S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, c
|
|||
String titleString = title;
|
||||
|
||||
MenuItem newItem;
|
||||
newItem.id = pos;
|
||||
newItem.text = titleString;
|
||||
newItem.cmd = cmd;
|
||||
newItem.mID = pos;
|
||||
newItem.mText = titleString;
|
||||
newItem.mCMD = cmd;
|
||||
|
||||
if (titleString.isEmpty() || titleString == String("-"))
|
||||
newItem.isSpacer = true;
|
||||
newItem.mIsSpacer = true;
|
||||
else
|
||||
newItem.isSpacer = false;
|
||||
newItem.mIsSpacer = false;
|
||||
|
||||
if (accelerator[0])
|
||||
newItem.accelerator = dStrdup(accelerator);
|
||||
newItem.mAccelerator = dStrdup(accelerator);
|
||||
else
|
||||
newItem.accelerator = NULL;
|
||||
newItem.mAccelerator = NULL;
|
||||
|
||||
newItem.visible = true;
|
||||
newItem.isChecked = false;
|
||||
newItem.acceleratorIndex = 0;
|
||||
newItem.enabled = !newItem.isSpacer;
|
||||
newItem.mVisible = true;
|
||||
newItem.mIsChecked = false;
|
||||
newItem.mAcceleratorIndex = 0;
|
||||
newItem.mEnabled = !newItem.mIsSpacer;
|
||||
|
||||
newItem.isSubmenu = false;
|
||||
newItem.subMenu = nullptr;
|
||||
newItem.subMenuParentMenu = nullptr;
|
||||
newItem.mIsSubmenu = false;
|
||||
newItem.mSubMenu = nullptr;
|
||||
newItem.mSubMenuParentMenu = nullptr;
|
||||
|
||||
mMenuItems.push_back(newItem);
|
||||
|
||||
|
|
@ -166,11 +172,11 @@ S32 PopupMenu::insertSubMenu(S32 pos, const char *title, PopupMenu *submenu)
|
|||
{
|
||||
S32 itemPos = insertItem(pos, title, "", "");
|
||||
|
||||
mMenuItems[itemPos].isSubmenu = true;
|
||||
mMenuItems[itemPos].subMenu = submenu;
|
||||
mMenuItems[itemPos].subMenuParentMenu = this;
|
||||
mMenuItems[itemPos].mIsSubmenu = true;
|
||||
mMenuItems[itemPos].mSubMenu = submenu;
|
||||
mMenuItems[itemPos].mSubMenuParentMenu = this;
|
||||
|
||||
submenu->isSubmenu = true;
|
||||
submenu->mIsSubmenu = true;
|
||||
|
||||
return itemPos;
|
||||
}
|
||||
|
|
@ -181,15 +187,15 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].text == titleString)
|
||||
if (mMenuItems[i].mText == titleString)
|
||||
{
|
||||
mMenuItems[i].id = pos;
|
||||
mMenuItems[i].cmd = cmd;
|
||||
mMenuItems[i].mID = pos;
|
||||
mMenuItems[i].mCMD = cmd;
|
||||
|
||||
if (accelerator && accelerator[0])
|
||||
mMenuItems[i].accelerator = dStrdup(accelerator);
|
||||
mMenuItems[i].mAccelerator = dStrdup(accelerator);
|
||||
else
|
||||
mMenuItems[i].accelerator = NULL;
|
||||
mMenuItems[i].mAccelerator = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -199,7 +205,7 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
|
|||
|
||||
void PopupMenu::removeItem(S32 itemPos)
|
||||
{
|
||||
if (mMenuItems.size() < itemPos || itemPos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < itemPos || itemPos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems.erase(itemPos);
|
||||
|
|
@ -208,45 +214,45 @@ void PopupMenu::removeItem(S32 itemPos)
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
void PopupMenu::enableItem(S32 pos, bool enable)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems[pos].enabled = enable;
|
||||
mMenuItems[pos].mEnabled = enable;
|
||||
}
|
||||
|
||||
void PopupMenu::checkItem(S32 pos, bool checked)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
if (checked && mMenuItems[pos].checkGroup != -1)
|
||||
if (checked && mMenuItems[pos].mCheckGroup != -1)
|
||||
{
|
||||
// first, uncheck everything in the group:
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
if (mMenuItems[i].checkGroup == mMenuItems[pos].checkGroup && mMenuItems[i].isChecked)
|
||||
mMenuItems[i].isChecked = false;
|
||||
if (mMenuItems[i].mCheckGroup == mMenuItems[pos].mCheckGroup && mMenuItems[i].mIsChecked)
|
||||
mMenuItems[i].mIsChecked = false;
|
||||
}
|
||||
|
||||
mMenuItems[pos].isChecked;
|
||||
mMenuItems[pos].mIsChecked = checked;
|
||||
}
|
||||
|
||||
void PopupMenu::checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos)
|
||||
{
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].id >= firstPos && mMenuItems[i].id <= lastPos)
|
||||
if (mMenuItems[i].mID >= firstPos && mMenuItems[i].mID <= lastPos)
|
||||
{
|
||||
mMenuItems[i].isChecked = false;
|
||||
mMenuItems[i].mIsChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupMenu::isItemChecked(S32 pos)
|
||||
{
|
||||
if (mMenuItems.size() < pos || pos < 0)
|
||||
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||
return false;
|
||||
|
||||
return mMenuItems[pos].isChecked;
|
||||
return mMenuItems[pos].mIsChecked;
|
||||
}
|
||||
|
||||
U32 PopupMenu::getItemCount()
|
||||
|
|
@ -254,6 +260,11 @@ U32 PopupMenu::getItemCount()
|
|||
return mMenuItems.size();
|
||||
}
|
||||
|
||||
void PopupMenu::clearItems()
|
||||
{
|
||||
mMenuItems.clear();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool PopupMenu::canHandleID(U32 id)
|
||||
{
|
||||
|
|
@ -305,7 +316,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
if (!backgroundCtrl || !mTextList)
|
||||
return;
|
||||
|
||||
if (!isSubmenu)
|
||||
if (!mIsSubmenu)
|
||||
{
|
||||
//if we're a 'parent' menu, then tell the background to clear out all existing other popups
|
||||
|
||||
|
|
@ -354,11 +365,11 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (!mMenuItems[i].visible)
|
||||
if (!mMenuItems[i].mVisible)
|
||||
continue;
|
||||
|
||||
S32 iTextWidth = font->getStrWidth(mMenuItems[i].text.c_str());
|
||||
S32 iAcceleratorWidth = mMenuItems[i].accelerator ? font->getStrWidth(mMenuItems[i].accelerator) : 0;
|
||||
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;
|
||||
|
|
@ -378,7 +389,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (!mMenuItems[i].visible)
|
||||
if (!mMenuItems[i].mVisible)
|
||||
continue;
|
||||
|
||||
char buf[512];
|
||||
|
|
@ -386,17 +397,17 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
// 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].isSubmenu)
|
||||
if (mMenuItems[i].mIsSubmenu)
|
||||
isSubmenu = 2;
|
||||
|
||||
char bitmapIndex = 1;
|
||||
if (mMenuItems[i].bitmapIndex >= 0 && (mMenuItems[i].bitmapIndex * 3 <= profile->mBitmapArrayRects.size()))
|
||||
bitmapIndex = mMenuItems[i].bitmapIndex + 2;
|
||||
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].text.c_str(), mMenuItems[i].accelerator ? mMenuItems[i].accelerator : "");
|
||||
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].enabled)
|
||||
if (!mMenuItems[i].mEnabled)
|
||||
mTextList->setEntryActive(entryCount, false);
|
||||
|
||||
entryCount++;
|
||||
|
|
@ -437,8 +448,8 @@ void PopupMenu::hidePopupSubmenus()
|
|||
{
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].subMenu != nullptr)
|
||||
mMenuItems[i].subMenu->hidePopup();
|
||||
if (mMenuItems[i].mSubMenu != nullptr)
|
||||
mMenuItems[i].mSubMenu->hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -498,6 +509,11 @@ 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])")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,27 +34,27 @@ class GuiPopupMenuBackgroundCtrl;
|
|||
|
||||
struct MenuItem // an individual item in a pull-down menu
|
||||
{
|
||||
String 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 -
|
||||
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 isSubmenu; // This menu item has a submenu that will be displayed
|
||||
bool mIsSubmenu; // This menu item has a submenu that will be displayed
|
||||
|
||||
bool isChecked;
|
||||
bool mIsChecked;
|
||||
|
||||
bool isSpacer;
|
||||
bool mIsSpacer;
|
||||
|
||||
bool isMenubarEntry;
|
||||
bool mIsMenubarEntry;
|
||||
|
||||
PopupMenu* subMenuParentMenu; // For a submenu, this is the parent menu
|
||||
PopupMenu* subMenu;
|
||||
String cmd;
|
||||
PopupMenu* mSubMenuParentMenu; // For a submenu, this is the parent menu
|
||||
PopupMenu* mSubMenu;
|
||||
String mCMD;
|
||||
};
|
||||
|
||||
// PopupMenu represents a menu.
|
||||
|
|
@ -72,16 +72,16 @@ protected:
|
|||
|
||||
GuiMenuBar* mMenuBarCtrl;
|
||||
|
||||
StringTableEntry barTitle;
|
||||
StringTableEntry mBarTitle;
|
||||
|
||||
RectI bounds;
|
||||
bool visible;
|
||||
RectI mBounds;
|
||||
bool mVisible;
|
||||
|
||||
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 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 isSubmenu;
|
||||
bool mIsSubmenu;
|
||||
|
||||
//This is the gui control that renders our popup
|
||||
GuiPopupMenuTextListCtrl *mTextList;
|
||||
|
|
@ -137,6 +137,9 @@ public:
|
|||
/// 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.
|
||||
|
|
@ -175,8 +178,8 @@ public:
|
|||
virtual bool onMessageReceived(StringTableEntry queue, const char* event, const char* data );
|
||||
virtual bool onMessageObjectReceived(StringTableEntry queue, Message *msg );
|
||||
|
||||
bool isVisible() { return visible; }
|
||||
void setVisible(bool isVis) { visible = isVis; }
|
||||
bool isVisible() { return mVisible; }
|
||||
void setVisible(bool isVis) { mVisible = isVis; }
|
||||
|
||||
GuiMenuBar* getMenuBarCtrl();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue