Merge remote-tracking branch 'refs/remotes/GarageGames/development' into ColorPickerAdvanced

This commit is contained in:
Anis A. Hireche 2016-02-26 20:15:33 +01:00
commit 2ff18cfc3f
629 changed files with 33887 additions and 3352 deletions

View file

@ -159,6 +159,8 @@ GuiTSCtrl::GuiTSCtrl()
mLastCameraQuery.nearPlane = 0.01f;
mLastCameraQuery.projectionOffset = Point2F::Zero;
mLastCameraQuery.hasFovPort = false;
mLastCameraQuery.hasStereoTargets = false;
mLastCameraQuery.ortho = false;
}
@ -312,6 +314,46 @@ F32 GuiTSCtrl::calculateViewDistance(F32 radius)
//-----------------------------------------------------------------------------
static FovPort CalculateFovPortForCanvas(const RectI viewport, const CameraQuery &cameraQuery)
{
F32 wwidth;
F32 wheight;
F32 renderWidth = viewport.extent.x;
F32 renderHeight = viewport.extent.y;
F32 aspectRatio = renderWidth / renderHeight;
// Use the FOV to calculate the viewport height scale
// then generate the width scale from the aspect ratio.
if(!cameraQuery.ortho)
{
wheight = /*cameraQuery.nearPlane * */ mTan(cameraQuery.fov / 2.0f);
wwidth = aspectRatio * wheight;
}
else
{
wheight = cameraQuery.fov;
wwidth = aspectRatio * wheight;
}
F32 hscale = wwidth * 2.0f / renderWidth;
F32 vscale = wheight * 2.0f / renderHeight;
F32 left = 0.0f * hscale - wwidth;
F32 right = renderWidth * hscale - wwidth;
F32 top = wheight - vscale * 0.0f;
F32 bottom = wheight - vscale * renderHeight;
FovPort fovPort;
fovPort.upTan = top;
fovPort.downTan = -bottom;
fovPort.leftTan = -left;
fovPort.rightTan = right;
return fovPort;
}
//-----------------------------------------------------------------------------
void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
{
// Save the current transforms so we can restore
@ -340,7 +382,25 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
GFX->setCurrentRenderStyle(GFXDevice::RS_StereoSideBySide);
GFX->setCurrentProjectionOffset(mLastCameraQuery.projectionOffset);
GFX->setStereoEyeOffsets(mLastCameraQuery.eyeOffset);
GFX->setFovPort(mLastCameraQuery.fovPort); // NOTE: this specifies fov for BOTH eyes
if (!mLastCameraQuery.hasStereoTargets)
{
// Need to calculate our current viewport here
mLastCameraQuery.stereoViewports[0] = updateRect;
mLastCameraQuery.stereoViewports[0].extent.x /= 2;
mLastCameraQuery.stereoViewports[1] = mLastCameraQuery.stereoViewports[0];
mLastCameraQuery.stereoViewports[1].point.x += mLastCameraQuery.stereoViewports[1].extent.x;
}
if (!mLastCameraQuery.hasFovPort)
{
// Need to make our own fovPort
mLastCameraQuery.fovPort[0] = CalculateFovPortForCanvas(mLastCameraQuery.stereoViewports[0], mLastCameraQuery);
mLastCameraQuery.fovPort[1] = CalculateFovPortForCanvas(mLastCameraQuery.stereoViewports[1], mLastCameraQuery);
}
GFX->setStereoFovPort(mLastCameraQuery.fovPort); // NOTE: this specifies fov for BOTH eyes
GFX->setSteroViewports(mLastCameraQuery.stereoViewports);
GFX->setStereoTargets(mLastCameraQuery.stereoTargets);
@ -402,29 +462,6 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
mLastCameraQuery.cameraMatrix.mul(rotMat);
}
// set up the camera and viewport stuff:
F32 wwidth;
F32 wheight;
F32 renderWidth = F32(renderSize.x);
F32 renderHeight = F32(renderSize.y);
F32 aspectRatio = renderWidth / renderHeight;
// Use the FOV to calculate the viewport height scale
// then generate the width scale from the aspect ratio.
if(!mLastCameraQuery.ortho)
{
wheight = mLastCameraQuery.nearPlane * mTan(mLastCameraQuery.fov / 2.0f);
wwidth = aspectRatio * wheight;
}
else
{
wheight = mLastCameraQuery.fov;
wwidth = aspectRatio * wheight;
}
F32 hscale = wwidth * 2.0f / renderWidth;
F32 vscale = wheight * 2.0f / renderHeight;
Frustum frustum;
if(mRenderStyle == RenderStyleStereoSideBySide)
{
@ -433,6 +470,29 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
}
else
{
// set up the camera and viewport stuff:
F32 wwidth;
F32 wheight;
F32 renderWidth = F32(renderSize.x);
F32 renderHeight = F32(renderSize.y);
F32 aspectRatio = renderWidth / renderHeight;
// Use the FOV to calculate the viewport height scale
// then generate the width scale from the aspect ratio.
if(!mLastCameraQuery.ortho)
{
wheight = mLastCameraQuery.nearPlane * mTan(mLastCameraQuery.fov / 2.0f);
wwidth = aspectRatio * wheight;
}
else
{
wheight = mLastCameraQuery.fov;
wwidth = aspectRatio * wheight;
}
F32 hscale = wwidth * 2.0f / renderWidth;
F32 vscale = wheight * 2.0f / renderHeight;
F32 left = (updateRect.point.x - offset.x) * hscale - wwidth;
F32 right = (updateRect.point.x + updateRect.extent.x - offset.x) * hscale - wwidth;
F32 top = wheight - vscale * (updateRect.point.y - offset.y);
@ -516,16 +576,14 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
Frustum originalFrustum = GFX->getFrustum();
GFXTextureObject *texObject = mStereoGuiTarget->getTexture(0);
const FovPort *currentFovPort = GFX->getSteroFovPort();
const FovPort *currentFovPort = GFX->getStereoFovPort();
const MatrixF *eyeTransforms = GFX->getStereoEyeTransforms();
const MatrixF *worldEyeTransforms = GFX->getInverseStereoEyeTransforms();
const Point3F *eyeOffset = GFX->getStereoEyeOffsets();
Frustum gfxFrustum = originalFrustum;
for (U32 i=0; i<2; i++)
{
GFX->activateStereoTarget(i);
Frustum gfxFrustum = originalFrustum;
const F32 frustumDepth = gfxFrustum.getNearDist();
MathUtils::makeFovPortFrustum(&gfxFrustum, true, gfxFrustum.getNearDist(), gfxFrustum.getFarDist(), currentFovPort[i], eyeTransforms[i]);
GFX->setFrustum(gfxFrustum);
@ -558,11 +616,11 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
F32 screenBottom = rectHeight * 0.5;
const F32 fillConv = 0.0f;
const F32 frustumDepth = gfxFrustum.getNearDist() + 0.012;
verts[0].point.set( screenLeft - fillConv, frustumDepth, screenTop - fillConv );
verts[1].point.set( screenRight - fillConv, frustumDepth, screenTop - fillConv );
verts[2].point.set( screenLeft - fillConv, frustumDepth, screenBottom - fillConv );
verts[3].point.set( screenRight - fillConv, frustumDepth, screenBottom - fillConv );
const F32 frustumDepthAdjusted = gfxFrustum.getNearDist() + 0.012;
verts[0].point.set( screenLeft - fillConv, frustumDepthAdjusted, screenTop - fillConv );
verts[1].point.set( screenRight - fillConv, frustumDepthAdjusted, screenTop - fillConv );
verts[2].point.set( screenLeft - fillConv, frustumDepthAdjusted, screenBottom - fillConv );
verts[3].point.set( screenRight - fillConv, frustumDepthAdjusted, screenBottom - fillConv );
verts[0].color = verts[1].color = verts[2].color = verts[3].color = ColorI(255,255,255,255);

View file

@ -49,6 +49,8 @@ struct CameraQuery
Point3F eyeOffset[2];
MatrixF eyeTransforms[2];
bool ortho;
bool hasFovPort;
bool hasStereoTargets;
MatrixF cameraMatrix;
RectI stereoViewports[2]; // destination viewports
GFXTextureTarget* stereoTargets[2];

View file

@ -128,9 +128,6 @@ bool GuiContainer::reOrder(SimObject* obj, SimObject* target)
bool GuiContainer::resize( const Point2I &newPosition, const Point2I &newExtent )
{
RectI oldBounds = getBounds();
Point2I minExtent = getMinExtent();
if( !Parent::resize( newPosition, newExtent ) )
return false;

View file

@ -91,7 +91,7 @@ class GuiContainer : public GuiControl
inline void setAnchorRight(bool val) { mSizingOptions.mAnchorRight = val; }
ControlSizing getSizingOptions() const { return mSizingOptions; }
void setSizingOptions(ControlSizing val) { mSizingOptions = val; }
void setSizingOptions(const ControlSizing& val) { mSizingOptions = val; }
/// @}

View file

@ -118,6 +118,7 @@ class GuiRolloutCtrl : public GuiTickCtrl
DECLARE_CALLBACK( void, onCollapsed, () );
/// @}
virtual void processTick();
public:
@ -152,7 +153,6 @@ class GuiRolloutCtrl : public GuiTickCtrl
// Sizing Animation Functions
void animateTo( S32 height );
virtual void processTick();
void collapse() { animateTo( mHeader.extent.y ); }
void expand() { animateTo( mExpanded.extent.y ); }

View file

@ -493,6 +493,8 @@ void GuiScrollCtrl::calcThumbs()
void GuiScrollCtrl::scrollDelta(S32 deltaX, S32 deltaY)
{
scrollTo(mChildRelPos.x + deltaX, mChildRelPos.y + deltaY);
onScroll_callback();
}
//-----------------------------------------------------------------------------
@ -1091,8 +1093,9 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
}
// Render Up Arrow.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[upArrowBitmap] );
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[upArrowBitmap]);
// Update Pos.
pos.y += mBitmapBounds[upArrowBitmap].extent.y;
@ -1118,8 +1121,8 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
if ( trackRect.extent.y > 0 )
{
// Render Track.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR( mTextureObject, trackRect, mBitmapBounds[trackBitmap] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(mTextureObject, trackRect, mBitmapBounds[trackBitmap]);
}
// Update Pos.
@ -1137,8 +1140,8 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
}
// Render Down Arrow.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[downArrowBitmap] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[downArrowBitmap]);
// Render the Thumb?
if ( !mVBarEnabled )
@ -1163,8 +1166,8 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
}
// Render Thumb Top.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[thumbBitmapTop] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[thumbBitmapTop]);
// Update Pos.
pos.y += mBitmapBounds[thumbBitmapTop].extent.y;
@ -1179,16 +1182,16 @@ void GuiScrollCtrl::drawVScrollBar(const Point2I &offset)
if ( thumbRect.extent.y > 0 )
{
// Render Track.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR( mTextureObject, thumbRect, mBitmapBounds[thumbBitmapMiddle] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(mTextureObject, thumbRect, mBitmapBounds[thumbBitmapMiddle]);
}
// Update Pos.
pos.y += thumbRect.extent.y;
// Render the Thumb Bottom.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[thumbBitmapBottom] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[thumbBitmapBottom]);
}
//-----------------------------------------------------------------------------
@ -1215,8 +1218,9 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
}
// Render Up Arrow.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[leftArrowBitmap] );
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[leftArrowBitmap]);
// Update Pos.
pos.x += mBitmapBounds[leftArrowBitmap].extent.x;
@ -1242,8 +1246,8 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
if ( trackRect.extent.x > 0 )
{
// Render Track.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR( mTextureObject, trackRect, mBitmapBounds[trackBitmap] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(mTextureObject, trackRect, mBitmapBounds[trackBitmap]);
}
// Update Pos.
@ -1261,8 +1265,8 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
}
// Render Right Arrow.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[rightArrowBitmap] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[rightArrowBitmap]);
// Render the Thumb?
if ( !mHBarEnabled )
@ -1287,8 +1291,8 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
}
// Render Thumb Left.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[thumbBitmapLeft] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[thumbBitmapLeft]);
// Update Pos.
pos.x += mBitmapBounds[thumbBitmapLeft].extent.x;
@ -1303,16 +1307,16 @@ void GuiScrollCtrl::drawHScrollBar(const Point2I &offset)
if ( thumbRect.extent.x > 0 )
{
// Render Track.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR( mTextureObject, thumbRect, mBitmapBounds[thumbBitmapMiddle] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(mTextureObject, thumbRect, mBitmapBounds[thumbBitmapMiddle]);
}
// Update Pos.
pos.x += thumbRect.extent.x;
// Render the Thumb Bottom.
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, pos, mBitmapBounds[thumbBitmapRight] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, pos, mBitmapBounds[thumbBitmapRight]);
}
//-----------------------------------------------------------------------------

View file

@ -444,7 +444,7 @@ bool GuiSplitContainer::layoutControls( RectI &clientRect )
//-----------------------------------------------------------------------------
void GuiSplitContainer::solvePanelConstraints( Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, RectI clientRect )
void GuiSplitContainer::solvePanelConstraints(Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, const RectI& clientRect)
{
if( !firstPanel || !secondPanel )
return;

View file

@ -84,7 +84,7 @@ public:
virtual inline Point2I getSplitPoint() { return mSplitPoint; };
/// The Splitters entire Client Rectangle, this takes into account padding of this control
virtual inline RectI getSplitRect() { return mSplitRect; };
virtual void solvePanelConstraints( Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, RectI clientRect );
virtual void solvePanelConstraints(Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, const RectI& clientRect);
virtual Point2I getMinExtent() const;
protected:

View file

@ -548,7 +548,7 @@ void GuiTabBookCtrl::renderTabs( const Point2I &offset, const RectI &tabRect )
//-----------------------------------------------------------------------------
void GuiTabBookCtrl::renderTab( RectI tabRect, GuiTabPageCtrl *tab )
void GuiTabBookCtrl::renderTab(const RectI& tabRect, GuiTabPageCtrl *tab)
{
StringTableEntry text = tab->getText();
ColorI oldColor;
@ -622,7 +622,7 @@ S32 GuiTabBookCtrl::calculatePageTabWidth( GuiTabPageCtrl *page )
const char* text = page->getText();
if( !text || dStrlen(text) == 0 || mProfile->mFont == NULL )
if( !text || dStrlen(text) == 0 || mProfile == NULL || mProfile->mFont == NULL )
return mMinTabWidth;
GFont *font = mProfile->mFont;

View file

@ -158,7 +158,7 @@ class GuiTabBookCtrl : public GuiContainer
/// Tab rendering subroutine, renders one tab with specified options
/// @param tabRect the rectangle to render the tab into
/// @param tab pointer to the tab page control for which to render the tab
void renderTab( RectI tabRect, GuiTabPageCtrl* tab );
void renderTab(const RectI& tabRect, GuiTabPageCtrl* tab);
/// @}

View file

@ -1212,7 +1212,7 @@ void GuiWindowCtrl::onMouseUp(const GuiEvent &event)
// We're either moving out of a collapse group or moving to another one
// Not valid for windows not previously in a group
if( mCollapseGroup >= 0 &&
( snapType == -1 || ( snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup) ) )
(snapType == -1 || (hitWindow && snapType >= 0 && mCollapseGroup != hitWindow->mCollapseGroup)))
moveFromCollapseGroup();
// No window to connect to
@ -1294,11 +1294,13 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
winRect.extent.x += 1;
GFX->getDrawUtil()->drawRectFill(winRect, mProfile->mFillColor);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset, mBitmapBounds[topBase]);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[topBase+1].extent.x, offset.y),
drawUtil->drawRectFill(winRect, mProfile->mFillColor);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, offset, mBitmapBounds[topBase]);
drawUtil->drawBitmapSR(mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[topBase+1].extent.x, offset.y),
mBitmapBounds[topBase + 1]);
RectI destRect;
@ -1308,7 +1310,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
destRect.extent.y = mBitmapBounds[topBase + 2].extent.y;
RectI stretchRect = mBitmapBounds[topBase + 2];
stretchRect.inset(1,0);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
destRect.point.x = offset.x;
destRect.point.y = offset.y + mBitmapBounds[topBase].extent.y;
@ -1316,7 +1318,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
destRect.extent.y = getHeight() - mBitmapBounds[topBase].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
stretchRect = mBitmapBounds[BorderLeft];
stretchRect.inset(0,1);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
destRect.point.x = offset.x + getWidth() - mBitmapBounds[BorderRight].extent.x;
destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
@ -1325,10 +1327,10 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
stretchRect = mBitmapBounds[BorderRight];
stretchRect.inset(0,1);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset + Point2I(0, getHeight() - mBitmapBounds[BorderBottomLeft].extent.y), mBitmapBounds[BorderBottomLeft]);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset + getExtent() - mBitmapBounds[BorderBottomRight].extent, mBitmapBounds[BorderBottomRight]);
drawUtil->drawBitmapSR(mTextureObject, offset + Point2I(0, getHeight() - mBitmapBounds[BorderBottomLeft].extent.y), mBitmapBounds[BorderBottomLeft]);
drawUtil->drawBitmapSR(mTextureObject, offset + getExtent() - mBitmapBounds[BorderBottomRight].extent, mBitmapBounds[BorderBottomRight]);
destRect.point.x = offset.x + mBitmapBounds[BorderBottomLeft].extent.x;
destRect.extent.x = getWidth() - mBitmapBounds[BorderBottomLeft].extent.x - mBitmapBounds[BorderBottomRight].extent.x;
@ -1338,13 +1340,13 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
stretchRect = mBitmapBounds[BorderBottom];
stretchRect.inset(1,0);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
// Draw the title
// dhc addition: copied/modded from renderJustifiedText, since we enforce a
// different color usage here. NOTE: it currently CAN overdraw the controls
// if mis-positioned or 'scrunched' in a small width.
GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColor);
drawUtil->setBitmapModulation(mProfile->mFontColor);
S32 textWidth = mProfile->mFont->getStrWidth((const UTF8 *)mText);
Point2I start(0,0);
@ -1359,7 +1361,7 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
if( textWidth > winRect.extent.x ) start.set( 0, 0 );
// center the vertical
// start.y = ( winRect.extent.y - ( font->getHeight() - 2 ) ) / 2;
GFX->getDrawUtil()->drawText( mProfile->mFont, start + offset + mProfile->mTextOffset, mText );
drawUtil->drawText( mProfile->mFont, start + offset + mProfile->mTextOffset, mText );
// Deal with rendering the titlebar controls
AssertFatal(root, "Unable to get the root GuiCanvas.");
@ -1378,8 +1380,8 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
bmp += BmpHilite;
}
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset + mCloseButton.point, mBitmapBounds[bmp]);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, offset + mCloseButton.point, mBitmapBounds[bmp]);
}
// Draw the maximize button
@ -1397,8 +1399,8 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
bmp += BmpHilite;
}
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, offset + mMaximizeButton.point, mBitmapBounds[bmp] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR( mTextureObject, offset + mMaximizeButton.point, mBitmapBounds[bmp] );
}
// Draw the minimize button
@ -1416,8 +1418,8 @@ void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
bmp += BmpHilite;
}
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mTextureObject, offset + mMinimizeButton.point, mBitmapBounds[bmp] );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR( mTextureObject, offset + mMinimizeButton.point, mBitmapBounds[bmp] );
}
if( !mMinimized )

View file

@ -136,6 +136,8 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
{
GFX->setClipRect(updateRect);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
//draw the outline
RectI winRect;
winRect.point = offset;
@ -148,11 +150,11 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
winRect.extent.y -= mBitmapBounds[BorderTop].extent.y + mBitmapBounds[BorderBottom].extent.y;
if(mProfile->mOpaque)
GFX->getDrawUtil()->drawRectFill(winRect, mProfile->mFillColor);
drawUtil->drawRectFill(winRect, mProfile->mFillColor);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset, mBitmapBounds[BorderTopLeft]);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[BorderTopRight].extent.x, offset.y),
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR(mTextureObject, offset, mBitmapBounds[BorderTopLeft]);
drawUtil->drawBitmapSR(mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[BorderTopRight].extent.x, offset.y),
mBitmapBounds[BorderTopRight]);
RectI destRect;
@ -162,7 +164,7 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
destRect.extent.y = mBitmapBounds[BorderTop].extent.y;
RectI stretchRect = mBitmapBounds[BorderTop];
stretchRect.inset(1,0);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
destRect.point.x = offset.x;
destRect.point.y = offset.y + mBitmapBounds[BorderTopLeft].extent.y;
@ -170,7 +172,7 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
destRect.extent.y = getHeight() - mBitmapBounds[BorderTopLeft].extent.y - mBitmapBounds[BorderBottomLeft].extent.y;
stretchRect = mBitmapBounds[BorderLeft];
stretchRect.inset(0,1);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
destRect.point.x = offset.x + getWidth() - mBitmapBounds[BorderRight].extent.x;
destRect.extent.x = mBitmapBounds[BorderRight].extent.x;
@ -179,10 +181,10 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
stretchRect = mBitmapBounds[BorderRight];
stretchRect.inset(0,1);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset + Point2I(0, getHeight() - mBitmapBounds[BorderBottomLeft].extent.y), mBitmapBounds[BorderBottomLeft]);
GFX->getDrawUtil()->drawBitmapSR(mTextureObject, offset + getExtent() - mBitmapBounds[BorderBottomRight].extent, mBitmapBounds[BorderBottomRight]);
drawUtil->drawBitmapSR(mTextureObject, offset + Point2I(0, getHeight() - mBitmapBounds[BorderBottomLeft].extent.y), mBitmapBounds[BorderBottomLeft]);
drawUtil->drawBitmapSR(mTextureObject, offset + getExtent() - mBitmapBounds[BorderBottomRight].extent, mBitmapBounds[BorderBottomRight]);
destRect.point.x = offset.x + mBitmapBounds[BorderBottomLeft].extent.x;
destRect.extent.x = getWidth() - mBitmapBounds[BorderBottomLeft].extent.x - mBitmapBounds[BorderBottomRight].extent.x;
@ -192,6 +194,6 @@ void GuiBitmapBorderCtrl::onRender(Point2I offset, const RectI &updateRect)
stretchRect = mBitmapBounds[BorderBottom];
stretchRect.inset(1,0);
GFX->getDrawUtil()->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mTextureObject, destRect, stretchRect);
}
}

View file

@ -113,7 +113,10 @@ void GuiConsoleTextCtrl::onPreRender()
{
if ( mConsoleExpression.isNotEmpty() )
{
mResult = (const char*)Con::evaluatef( "$guiConsoleTextCtrlTemp = %s;", mConsoleExpression.c_str() );
Con::evaluatef( "$guiConsoleTextCtrlTemp = %s;", mConsoleExpression.c_str() );
//Fixes a bug with the above not always grabbing the console text.
mResult = Con::getVariable("$guiConsoleTextCtrlTemp");
// Of the resulting string we will be printing,
// Find the number of lines and length of each.

View file

@ -56,6 +56,8 @@ void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
{
GuiGameListMenuProfile * profile = (GuiGameListMenuProfile *) mProfile;
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
F32 xScale = (float) getWidth() / profile->getRowWidth();
bool profileHasIcons = profile->hasArrows();
@ -121,19 +123,19 @@ void GuiGameListMenuCtrl::onRender(Point2I offset, const RectI &updateRect)
}
// render the row bitmap
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset, rowExtent), profile->getBitmapArrayRect(buttonTextureIndex));
// render the row icon if it has one
if ((iconIndex != NO_ICON) && profileHasIcons && (! profile->getBitmapArrayRect((U32)iconIndex).extent.isZero()))
{
iconIndex += Profile::TEX_FIRST_ICON;
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretchSR(profile->mTextureObject, RectI(currentOffset + iconOffset, iconExtent), profile->getBitmapArrayRect(iconIndex));
}
// render the row text
GFX->getDrawUtil()->setBitmapModulation(fontColor);
drawUtil->setBitmapModulation(fontColor);
renderJustifiedText(currentOffset + textOffset, textExtent, (*row)->mLabel);
}

View file

@ -249,8 +249,9 @@ bool GuiGradientCtrl::onAdd()
{
Parent::onAdd();
S32 l = getBounds().point.x + mSwatchFactor, r = getBounds().point.x + getBounds().extent.x - mSwatchFactor;
S32 t = getBounds().point.y, b = getBounds().point.y + getBounds().extent.y - mSwatchFactor;
RectI bounds = getBounds();
S32 l = bounds.point.x + mSwatchFactor, r = bounds.point.x + bounds.extent.x - mSwatchFactor;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - mSwatchFactor;
mBlendRangeBox = RectI( Point2I(l, t), Point2I(r, b) );
setupDefaultRange();
@ -330,16 +331,18 @@ void GuiGradientCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, Vector<Col
// Update local dimensions
mBlendRangeBox.point = globalToLocalCoord(Point2I(l, t));
mBlendRangeBox.extent = globalToLocalCoord(Point2I(r, b));
ColorRange& firstColorRange = colorRange.first();
if(colorRange.size() == 1) // Only one color to draw
{
PrimBuild::begin( GFXTriangleFan, 4 );
PrimBuild::color( colorRange.first().swatch->getColor() );
PrimBuild::color(firstColorRange.swatch->getColor());
PrimBuild::vertex2i( l, t );
PrimBuild::vertex2i( l, b );
PrimBuild::color( colorRange.first().swatch->getColor() );
PrimBuild::color(firstColorRange.swatch->getColor());
PrimBuild::vertex2i( r, b );
PrimBuild::vertex2i( r, t );
@ -349,13 +352,13 @@ void GuiGradientCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, Vector<Col
{
PrimBuild::begin( GFXTriangleFan, 4 );
PrimBuild::color( colorRange.first().swatch->getColor() );
PrimBuild::color(firstColorRange.swatch->getColor());
PrimBuild::vertex2i( l, t );
PrimBuild::vertex2i( l, b );
PrimBuild::color( colorRange.first().swatch->getColor() );
PrimBuild::vertex2i( l + colorRange.first().swatch->getPosition().x, b );
PrimBuild::vertex2i( l + colorRange.first().swatch->getPosition().x, t );
PrimBuild::color(firstColorRange.swatch->getColor());
PrimBuild::vertex2i(l + firstColorRange.swatch->getPosition().x, b);
PrimBuild::vertex2i(l + firstColorRange.swatch->getPosition().x, t);
PrimBuild::end();
@ -377,13 +380,15 @@ void GuiGradientCtrl::drawBlendRangeBox(RectI &bounds, bool vertical, Vector<Col
PrimBuild::end();
}
ColorRange& lastColorRange = colorRange.last();
PrimBuild::begin( GFXTriangleFan, 4 );
PrimBuild::color( colorRange.last().swatch->getColor() );
PrimBuild::vertex2i( l + colorRange.last().swatch->getPosition().x, t );
PrimBuild::vertex2i( l + colorRange.last().swatch->getPosition().x, b );
PrimBuild::color(lastColorRange.swatch->getColor());
PrimBuild::vertex2i(l + lastColorRange.swatch->getPosition().x, t);
PrimBuild::vertex2i(l + lastColorRange.swatch->getPosition().x, b);
PrimBuild::color( colorRange.last().swatch->getColor() );
PrimBuild::color(lastColorRange.swatch->getColor());
PrimBuild::vertex2i( r, b );
PrimBuild::vertex2i( r, t );
@ -521,7 +526,7 @@ void GuiGradientCtrl::reInitSwatches( GuiGradientCtrl::PickMode )
}
}
void GuiGradientCtrl::addColorRange( Point2I pos, ColorF color )
void GuiGradientCtrl::addColorRange(Point2I pos, const ColorF& color)
{
if( pos.x + mSwatchFactor < mBlendRangeBox.point.x &&
pos.x + mSwatchFactor > mBlendRangeBox.extent.x )

View file

@ -148,7 +148,7 @@ public:
void inspectPreApply();
void inspectPostApply();
void reInitSwatches( GuiGradientCtrl::PickMode );
void addColorRange( Point2I pos, ColorF color );
void addColorRange(Point2I pos, const ColorF& color);
void removeColorRange( GuiGradientSwatchCtrl* swatch );
void sortColorRange();

View file

@ -677,7 +677,7 @@ DefineEngineMethod( GuiListBoxCtrl, setItemColor, void, (S32 index, ColorF color
object->setItemColor( index, color );
}
void GuiListBoxCtrl::setItemColor( S32 index, ColorF color )
void GuiListBoxCtrl::setItemColor(S32 index, const ColorF& color)
{
if ((index >= mItems.size()) || index < 0)
{
@ -748,11 +748,6 @@ S32 GuiListBoxCtrl::insertItem( S32 index, StringTableEntry text, void *itemData
}
LBItem *newItem = new LBItem;
if( !newItem )
{
Con::warnf("GuiListBoxCtrl::insertItem - error allocating item memory!" );
return -1;
}
// Assign item data
newItem->itemText = StringTable->insert(text, true);
@ -792,11 +787,6 @@ S32 GuiListBoxCtrl::insertItemWithColor( S32 index, StringTableEntry text, Color
}
LBItem *newItem = new LBItem;
if( !newItem )
{
Con::warnf("GuiListBoxCtrl::insertItem - error allocating item memory!" );
return -1;
}
// Assign item data
newItem->itemText = StringTable->insert(text, true);
@ -1090,7 +1080,7 @@ void GuiListBoxCtrl::onRender( Point2I offset, const RectI &updateRect )
GFX->setClipRect( oldClipRect );
}
void GuiListBoxCtrl::onRenderItem( RectI itemRect, LBItem *item )
void GuiListBoxCtrl::onRenderItem(const RectI& itemRect, LBItem *item)
{
if( item->isSelected )
GFX->getDrawUtil()->drawRectFill( itemRect, mProfile->mFillColorSEL );

View file

@ -107,7 +107,7 @@ public:
S32 insertItemWithColor( S32 index, StringTableEntry text, ColorF color = ColorF(-1, -1, -1), void *itemData = NULL);
S32 findItemText( StringTableEntry text, bool caseSensitive = false );
void setItemColor(S32 index, ColorF color);
void setItemColor(S32 index, const ColorF& color);
void clearItemColor(S32 index);
void deleteItem( S32 index );
@ -128,7 +128,7 @@ public:
// Rendering
virtual void onRender( Point2I offset, const RectI &updateRect );
virtual void onRenderItem( RectI itemRect, LBItem *item );
virtual void onRenderItem(const RectI& itemRect, LBItem *item);
void drawBox( const Point2I &box, S32 size, ColorI &outlineColor, ColorI &boxColor );
bool renderTooltip( const Point2I &hoverPos, const Point2I& cursorPos, const char* tipText );
void addFilteredItem( String item );

View file

@ -168,7 +168,7 @@ DefineEngineMethod( GuiMLTextCtrl, scrollToTag, void, (S32 tagID),,
object->scrollToTag( tagID );
}
DefineEngineMethod( GuiMLTextCtrl, scrollToTop, void, ( S32 param1, S32 param2),,
DefineEngineMethod( GuiMLTextCtrl, scrollToTop, void, (),,
"@brief Scroll to the top of the text.\n\n"
"@tsexample\n"
"// Inform GuiMLTextCtrl object to scroll to its top\n"
@ -631,7 +631,7 @@ bool GuiMLTextCtrl::setCursorPosition(const S32 newPosition)
mCursorPosition = 0;
return true;
}
else if (newPosition >= mTextBuffer.length())
else if (newPosition >= mTextBuffer.length() - 1)
{
mCursorPosition = mTextBuffer.length();
return true;
@ -669,11 +669,11 @@ void GuiMLTextCtrl::getCursorPositionAndColor(Point2I &cursorTop, Point2I &curso
{
S32 x = 0;
S32 y = 0;
S32 height = mProfile->mFont->getHeight();
S32 height = (mProfile && mProfile->mFont) ? mProfile->mFont->getHeight() : 0;
color = mProfile->mCursorColor;
for(Line *walk = mLineList; walk; walk = walk->next)
{
if ((mCursorPosition <= walk->textStart + walk->len) || (walk->next == NULL))
if ((mCursorPosition < walk->textStart + walk->len) || (walk->next == NULL))
{
// it's in the atoms on this line...
y = walk->y;
@ -768,7 +768,7 @@ void GuiMLTextCtrl::onMouseDown(const GuiEvent& event)
mSelectionAnchorDropped = event.mousePoint;
if (mSelectionAnchor < 0)
mSelectionAnchor = 0;
else if (mSelectionAnchor >= mTextBuffer.length())
else if (mSelectionAnchor >= mTextBuffer.length() - 1)
mSelectionAnchor = mTextBuffer.length();
mVertMoveAnchorValid = false;

View file

@ -852,6 +852,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
if ( mScrollDir != GuiScrollCtrl::None )
autoScroll();
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
RectI r( offset, getExtent() );
if ( mInAction )
{
@ -868,30 +870,30 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
else
{
//renderSlightlyLoweredBox(r, mProfile);
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColor );
drawUtil->drawRectFill( r, mProfile->mFillColor );
}
// Draw a bitmap over the background?
if ( mTextureDepressed )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureDepressed, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureDepressed, rect );
}
else if ( mTextureNormal )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
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 );
}
}
@ -912,24 +914,24 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
}
else
{
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorHL );
drawUtil->drawRectFill( r, mProfile->mFillColorHL );
}
// Draw a bitmap over the background?
if ( mTextureNormal )
{
RectI rect( offset, mBitmapBounds );
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
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 );
}
}
else
@ -942,21 +944,21 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
}
else
{
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorNA );
drawUtil->drawRectFill( r, mProfile->mFillColorNA );
}
// Draw a bitmap over the background?
if ( mTextureNormal )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawRect( r, mProfile->mBorderColorNA );
drawUtil->drawRect( r, mProfile->mBorderColorNA );
}
}
// renderSlightlyRaisedBox(r, mProfile); // Used to be the only 'else' condition to mInAction above.
@ -1027,8 +1029,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
{
Point2I coloredboxsize( 15, 10 );
RectI r( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
GFX->getDrawUtil()->drawRectFill( r, boxColor);
GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));
drawUtil->drawRectFill( r, boxColor);
drawUtil->drawRect( r, ColorI(0,0,0));
localStart.x += coloredboxsize.x + mProfile->mTextOffset.x;
}
@ -1036,7 +1038,7 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Draw the text
Point2I globalStart = localToGlobalCoord( localStart );
ColorI fontColor = mActive ? ( mInAction ? mProfile->mFontColor : mProfile->mFontColorNA ) : mProfile->mFontColorNA;
GFX->getDrawUtil()->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
drawUtil->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
// Get the number of columns in the text
S32 colcount = getColumnCount( mText, "\t" );
@ -1048,7 +1050,7 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// Draw the first column
getColumn( mText, buff, 0, "\t" );
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
// Draw the second column to the right
getColumn( mText, buff, 1, "\t" );
@ -1059,17 +1061,17 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
// right cap of the border.
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - bitmapBounds[2].extent.x, localStart.y ) );
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
} else
{
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - 12, localStart.y ) );
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
}
} else
{
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
}
// If we're rendering a bitmap border, then it will take care of the arrow.

View file

@ -1034,6 +1034,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
if ( mScrollDir != GuiScrollCtrl::None )
autoScroll();
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
RectI r( offset, getExtent() );
if ( mInAction )
{
@ -1050,30 +1052,30 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
else
{
//renderSlightlyLoweredBox(r, mProfile);
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColor );
drawUtil->drawRectFill( r, mProfile->mFillColor );
}
// Draw a bitmap over the background?
if ( mTextureDepressed )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureDepressed, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureDepressed, rect );
}
else if ( mTextureNormal )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
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 );
}
}
@ -1094,24 +1096,24 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
}
else
{
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorHL );
drawUtil->drawRectFill( r, mProfile->mFillColorHL );
}
// Draw a bitmap over the background?
if ( mTextureNormal )
{
RectI rect( offset, mBitmapBounds );
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawLine( l, t, l, b, colorWhite );
GFX->getDrawUtil()->drawLine( l, t, r2, t, colorWhite );
GFX->getDrawUtil()->drawLine( l + 1, b, r2, b, mProfile->mBorderColor );
GFX->getDrawUtil()->drawLine( r2, t + 1, r2, b - 1, mProfile->mBorderColor );
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 );
}
}
else
@ -1124,21 +1126,21 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
}
else
{
GFX->getDrawUtil()->drawRectFill( r, mProfile->mFillColorNA );
drawUtil->drawRectFill( r, mProfile->mFillColorNA );
}
// Draw a bitmap over the background?
if ( mTextureNormal )
{
RectI rect(offset, mBitmapBounds);
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch( mTextureNormal, rect );
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapStretch( mTextureNormal, rect );
}
// Do we render a bitmap border or lines?
if ( !( mProfile->getChildrenProfile() && mProfile->mBitmapArrayRects.size() ) )
{
GFX->getDrawUtil()->drawRect( r, mProfile->mBorderColorNA );
drawUtil->drawRect( r, mProfile->mBorderColorNA );
}
}
// renderSlightlyRaisedBox(r, mProfile); // Used to be the only 'else' condition to mInAction above.
@ -1209,8 +1211,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
Point2I coloredboxsize( 15, 10 );
RectI r( offset.x + mProfile->mTextOffset.x, offset.y + ( (getHeight() - coloredboxsize.y ) / 2 ), coloredboxsize.x, coloredboxsize.y );
GFX->getDrawUtil()->drawRectFill( r, boxColor);
GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));
drawUtil->drawRectFill( r, boxColor);
drawUtil->drawRect( r, ColorI(0,0,0));
localStart.x += coloredboxsize.x + mProfile->mTextOffset.x;
}
@ -1218,7 +1220,7 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
// Draw the text
Point2I globalStart = localToGlobalCoord( localStart );
ColorI fontColor = mActive ? ( mInAction ? mProfile->mFontColor : mProfile->mFontColorNA ) : mProfile->mFontColorNA;
GFX->getDrawUtil()->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
drawUtil->setBitmapModulation( fontColor ); // was: (mProfile->mFontColor);
// Get the number of columns in the text
S32 colcount = getColumnCount( mText, "\t" );
@ -1230,7 +1232,7 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
// Draw the first column
getColumn( mText, buff, 0, "\t" );
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, globalStart, buff, mProfile->mFontColors );
// Draw the second column to the right
getColumn( mText, buff, 1, "\t" );
@ -1241,17 +1243,17 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
// right cap of the border.
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - bitmapBounds[2].extent.x, localStart.y ) );
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
} else
{
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - 12, localStart.y ) );
GFX->getDrawUtil()->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, textpos, buff, mProfile->mFontColors );
}
} else
{
GFX->getDrawUtil()->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
drawUtil->drawText( mProfile->mFont, globalStart, mText, mProfile->mFontColors );
}
// If we're rendering a bitmap border, then it will take care of the arrow.

View file

@ -363,6 +363,8 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
Point2I ext(getWidth() - mShiftExtent, getHeight());
RectI thumb = mThumb;
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
if( mHasTexture )
{
if(mTicks > 0)
@ -402,12 +404,12 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
S32 index = SliderButtonNormal;
if(mMouseOver)
index = SliderButtonHighlight;
GFX->getDrawUtil()->clearBitmapModulation();
drawUtil->clearBitmapModulation();
//left border
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
drawUtil->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x,offset.y), mBitmapBounds[SliderLineLeft]);
//right border
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
drawUtil->drawBitmapSR(mProfile->mTextureObject, Point2I(offset.x + getWidth() - mBitmapBounds[SliderLineRight].extent.x, offset.y), mBitmapBounds[SliderLineRight]);
//draw our center piece to our slider control's border and stretch it
@ -421,11 +423,11 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
stretchRect = mBitmapBounds[SliderLineCenter];
stretchRect.inset(1,0);
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, destRect, stretchRect);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, destRect, stretchRect);
//draw our control slider button
thumb.point += pos;
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject,Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
drawUtil->drawBitmapSR(mProfile->mTextureObject,Point2I(thumb.point.x,offset.y ),mBitmapBounds[index]);
}
else if (getWidth() >= getHeight())
@ -490,8 +492,8 @@ void GuiSliderCtrl::onRender(Point2I offset, const RectI &updateRect)
else if(textStart.x + txt_w > offset.x+getWidth())
textStart.x -=((textStart.x + txt_w) - (offset.x+getWidth()));
GFX->getDrawUtil()->setBitmapModulation(mProfile->mFontColor);
GFX->getDrawUtil()->drawText(mProfile->mFont, textStart, buf, mProfile->mFontColors);
drawUtil->setBitmapModulation(mProfile->mFontColor);
drawUtil->drawText(mProfile->mFont, textStart, buf, mProfile->mFontColors);
}
renderChildControls(offset, updateRect);
}

View file

@ -215,7 +215,7 @@ void GuiTextEditCtrl::execConsoleCallback()
// Update the console variable:
if ( mConsoleVariable[0] )
Con::setVariable( mConsoleVariable, mTextBuffer.getPtr8() );
Con::setVariable(mConsoleVariable, mTextBuffer.getPtr8());
}
void GuiTextEditCtrl::updateHistory( StringBuffer *inTxt, bool moveIndex )
@ -376,6 +376,8 @@ S32 GuiTextEditCtrl::calculateCursorPos( const Point2I &globalPos )
void GuiTextEditCtrl::onMouseDown( const GuiEvent &event )
{
if(!isActive())
return;
mDragHit = false;
// If we have a double click, select all text. Otherwise

View file

@ -4641,6 +4641,8 @@ S32 GuiTreeViewCtrl::findItemByValue(const char *name)
{
for (S32 i = 0; i < mItems.size(); i++)
{
if (!mItems[i])
continue;
if( mItems[i]->mState.test( Item::InspectorData ) )
continue;
if (mItems[i] && dStrcmp(mItems[i]->getValue(),name) == 0)

View file

@ -144,23 +144,12 @@ GuiCanvas::GuiCanvas(): GuiControl(),
#else
mNumFences = 0;
#endif
#ifdef TORQUE_DEMO_PURCHASE
mPurchaseScreen = NULL;
#endif
}
GuiCanvas::~GuiCanvas()
{
SAFE_DELETE(mPlatformWindow);
SAFE_DELETE_ARRAY( mFences );
#ifdef TORQUE_DEMO_PURCHASE
// if (mPurchaseScreen)
// {
// SAFE_DELETE(mPurchaseScreen);
// }
#endif
}
//------------------------------------------------------------------------------
@ -282,13 +271,6 @@ bool GuiCanvas::onAdd()
// Define the menu bar for this canvas (if any)
Con::executef(this, "onCreateMenu");
#ifdef TORQUE_DEMO_PURCHASE
mPurchaseScreen = new PurchaseScreen;
mPurchaseScreen->init();
mLastPurchaseHideTime = 0;
#endif
Sim::findObject("PlatformGenericMenubar", mMenuBarCtrl);
return parentRet;
@ -296,11 +278,6 @@ bool GuiCanvas::onAdd()
void GuiCanvas::onRemove()
{
#ifdef TORQUE_DEMO_PURCHASE
if (mPurchaseScreen && mPurchaseScreen->isAwake())
removeObject(mPurchaseScreen);
#endif
// And the process list
Process::remove(this, &GuiCanvas::paint);
@ -344,8 +321,11 @@ void GuiCanvas::setWindowTitle(const char *newTitle)
mPlatformWindow->setCaption(newTitle);
}
CanvasSizeChangeSignal GuiCanvas::smCanvasSizeChangeSignal;
void GuiCanvas::handleResize( WindowId did, S32 width, S32 height )
{
getCanvasSizeChangeSignal().trigger(this);
if (Journal::IsPlaying() && mPlatformWindow)
{
mPlatformWindow->lockSize(false);
@ -1362,11 +1342,6 @@ bool GuiCanvas::rootMouseWheelDown(const GuiEvent &event)
void GuiCanvas::setContentControl(GuiControl *gui)
{
#ifdef TORQUE_DEMO_PURCHASE
if (mPurchaseScreen->isForceExit())
return;
#endif
// Skip out if we got passed NULL (why would that happen?)
if(!gui)
return;
@ -1435,11 +1410,6 @@ GuiControl *GuiCanvas::getContentControl()
void GuiCanvas::pushDialogControl(GuiControl *gui, S32 layer, bool center)
{
#ifdef TORQUE_DEMO_PURCHASE
if (mPurchaseScreen->isForceExit())
return;
#endif
if( center )
gui->setPosition( getExtent().x / 2 - gui->getExtent().x / 2,
getExtent().y / 2 - gui->getExtent().y / 2 );
@ -1956,10 +1926,6 @@ void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */)
// this situation is necessary because it needs to take the screenshot
// before the buffers swap
#ifdef TORQUE_DEMO_TIMEOUT
checkTimeOut();
#endif
PROFILE_END();
// Fence logic here, because this is where endScene is called.

View file

@ -33,16 +33,14 @@
#include "platform/platformInput.h"
#endif
#ifndef _SIGNAL_H_
#include "core/util/tSignal.h"
#endif
#include "component/interfaces/IProcessInput.h"
#include "windowManager/platformWindowMgr.h"
#include "gfx/gfxFence.h"
#ifdef TORQUE_DEMO_PURCHASE
#ifndef _PURCHASESCREEN_H_
#include "demo/purchase/purchaseScreen.h"
#endif
#endif
/// A canvas on which rendering occurs.
///
///
@ -80,6 +78,8 @@
/// screen will be painted normally. If you are making an animated GuiControl
/// you need to add your control to the dirty areas of the canvas.
///
class guiCanvas;
typedef Signal<void(GuiCanvas* canvas)> CanvasSizeChangeSignal;
class GuiCanvas : public GuiControl, public IProcessInput
{
@ -189,6 +189,8 @@ protected:
virtual void setupFences();
void checkLockMouseMove( const GuiEvent& event );
//Signal used to let others know this canvas has changed size.
static CanvasSizeChangeSignal smCanvasSizeChangeSignal;
GuiControl *mMenuBarCtrl;
@ -206,6 +208,8 @@ public:
static void initPersistFields();
static CanvasSizeChangeSignal& getCanvasSizeChangeSignal() { return smCanvasSizeChangeSignal; }
/// @name Rendering methods
///
/// @{
@ -442,21 +446,6 @@ public:
private:
static const U32 MAX_GAMEPADS = 4; ///< The maximum number of supported gamepads
#ifdef TORQUE_DEMO_PURCHASE
private:
PurchaseScreen* mPurchaseScreen;
U32 mLastPurchaseHideTime;
public:
void showPurchaseScreen(bool show, bool startBlocker, const char* location, bool doExit);
void updatePurchaseScreen(const char* value);
#endif
#ifdef TORQUE_DEMO_TIMEOUT
private:
void checkTimeOut();
#endif
};
#endif

View file

@ -270,11 +270,11 @@ void GuiControl::initPersistFields()
addField("variable", TypeString, Offset(mConsoleVariable, GuiControl),
"Name of the variable to which the value of this control will be synchronized." );
addField("command", TypeRealString, Offset(mConsoleCommand, GuiControl),
addField("command", TypeCommand, Offset(mConsoleCommand, GuiControl),
"Command to execute on the primary action of the control.\n\n"
"@note Within this script snippet, the control on which the #command is being executed is bound to "
"the global variable $ThisControl." );
addField("altCommand", TypeRealString, Offset(mAltConsoleCommand, GuiControl),
addField("altCommand", TypeCommand, Offset(mAltConsoleCommand, GuiControl),
"Command to execute on the secondary action of the control.\n\n"
"@note Within this script snippet, the control on which the #altCommand is being executed is bound to "
"the global variable $ThisControl." );
@ -465,6 +465,8 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
GFont *font = mTooltipProfile->mFont;
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// Support for multi-line tooltip text...
Vector<U32> startLineOffsets, lineLengths;
@ -521,12 +523,12 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
GFX->setClipRect( rect );
// Draw Filler bit, then border on top of that
GFX->getDrawUtil()->drawRectFill( rect, mTooltipProfile->mFillColor );
GFX->getDrawUtil()->drawRect( rect, mTooltipProfile->mBorderColor );
drawUtil->drawRectFill( rect, mTooltipProfile->mFillColor );
drawUtil->drawRect( rect, mTooltipProfile->mBorderColor );
// Draw the text centered in the tool tip box...
GFX->getDrawUtil()->setBitmapModulation( mTooltipProfile->mFontColor );
drawUtil->setBitmapModulation( mTooltipProfile->mFontColor );
for ( U32 i = 0; i < lineLengths.size(); i++ )
{
@ -534,7 +536,7 @@ bool GuiControl::defaultTooltipRender( const Point2I &hoverPos, const Point2I &c
const UTF8 *line = renderTip.c_str() + startLineOffsets[i];
U32 lineLen = lineLengths[i];
GFX->getDrawUtil()->drawTextN( font, start + offset, line, lineLen, mProfile->mFontColors );
drawUtil->drawTextN( font, start + offset, line, lineLen, mProfile->mFontColors );
}
GFX->setClipRect( oldClip );
@ -602,6 +604,8 @@ void GuiControl::setUpdate()
void GuiControl::renderJustifiedText(Point2I offset, Point2I extent, const char *text)
{
GFont *font = mProfile->mFont;
if(!font)
return;
S32 textWidth = font->getStrWidthPrecise((const UTF8*)text);
U32 textHeight = font->getHeight();
@ -1753,41 +1757,48 @@ void GuiControl::write(Stream &stream, U32 tabStop, U32 flags)
{
//note: this will return false if either we, or any of our parents, are non-save controls
bool bCanSave = ( flags & IgnoreCanSave ) || ( flags & NoCheckParentCanSave && getCanSave() ) || getCanSaveParent();
StringTableEntry steName = mAddGroup->getInternalName();
if(bCanSave && mAddGroup && (steName != NULL) && (steName != StringTable->insert("null")) && getName() )
if (bCanSave && mAddGroup)
{
MutexHandle handle;
handle.lock(mMutex);
StringTableEntry steName = mAddGroup->getInternalName();
// export selected only?
if((flags & SelectedOnly) && !isSelected())
if ((steName != NULL) && (steName != StringTable->insert("null")) && getName())
{
for(U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop, flags);
MutexHandle handle;
handle.lock(mMutex);
// export selected only?
if ((flags & SelectedOnly) && !isSelected())
{
for (U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop, flags);
return;
}
stream.writeTabs(tabStop);
char buffer[1024];
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
stream.write(dStrlen(buffer), buffer);
writeFields(stream, tabStop + 1);
if (size())
{
stream.write(2, "\r\n");
for (U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop + 1, flags);
}
stream.writeTabs(tabStop);
stream.write(4, "};\r\n");
return;
}
stream.writeTabs(tabStop);
char buffer[1024];
dSprintf(buffer, sizeof(buffer), "new %s(%s,%s) {\r\n", getClassName(), getName() ? getName() : "", mAddGroup->getInternalName());
stream.write(dStrlen(buffer), buffer);
writeFields(stream, tabStop + 1);
if(size())
{
stream.write(2, "\r\n");
for(U32 i = 0; i < size(); i++)
(*this)[i]->write(stream, tabStop + 1, flags);
}
stream.writeTabs(tabStop);
stream.write(4, "};\r\n");
}
else if (bCanSave)
if (bCanSave)
Parent::write( stream, tabStop, flags );
}
//=============================================================================
@ -2820,9 +2831,9 @@ DefineConsoleMethod( GuiControl, setExtent, void, ( const char* extOrX, const ch
"@hide" )
{
Point2I extent;
if(!dStrIsEmpty(extOrX) && dStrIsEmpty(y))
if(!String::isEmpty(extOrX) && String::isEmpty(y))
dSscanf(extOrX, "%d %d", &extent.x, &extent.y);
else if(!dStrIsEmpty(extOrX) && !dStrIsEmpty(y))
else if(!String::isEmpty(extOrX) && !String::isEmpty(y))
{
extent.x = dAtoi(extOrX);
extent.y = dAtoi(y);

View file

@ -41,15 +41,17 @@ void renderRaisedBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, t, l, b - 1, colorWhite);
GFX->getDrawUtil()->drawLine(l, t, r - 1, t, colorWhite);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->drawLine(l, b, r, b, colorBlack);
GFX->getDrawUtil()->drawLine(r, b - 1, r, t, colorBlack);
drawUtil->drawRectFill( bounds, profile->mFillColor);
drawUtil->drawLine(l, t, l, b - 1, colorWhite);
drawUtil->drawLine(l, t, r - 1, t, colorWhite);
GFX->getDrawUtil()->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor);
drawUtil->drawLine(l, b, r, b, colorBlack);
drawUtil->drawLine(r, b - 1, r, t, colorBlack);
drawUtil->drawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
drawUtil->drawLine(r - 1, b - 2, r - 1, t + 1, profile->mBorderColor);
}
void renderSlightlyRaisedBox( const RectI &bounds, GuiControlProfile *profile )
@ -70,16 +72,18 @@ void renderLoweredBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->drawLine(l, b, r, b, colorWhite);
GFX->getDrawUtil()->drawLine(r, b - 1, r, t, colorWhite);
drawUtil->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, t, r - 1, t, colorBlack);
GFX->getDrawUtil()->drawLine(l, t + 1, l, b - 1, colorBlack);
drawUtil->drawLine(l, b, r, b, colorWhite);
drawUtil->drawLine(r, b - 1, r, t, colorWhite);
GFX->getDrawUtil()->drawLine(l + 1, t + 1, r - 2, t + 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l + 1, t + 2, l + 1, b - 2, profile->mBorderColor);
drawUtil->drawLine(l, t, r - 1, t, colorBlack);
drawUtil->drawLine(l, t + 1, l, b - 1, colorBlack);
drawUtil->drawLine(l + 1, t + 1, r - 2, t + 1, profile->mBorderColor);
drawUtil->drawLine(l + 1, t + 2, l + 1, b - 2, profile->mBorderColor);
}
void renderSlightlyLoweredBox( const RectI &bounds, GuiControlProfile *profile )
@ -87,11 +91,13 @@ void renderSlightlyLoweredBox( const RectI &bounds, GuiControlProfile *profile )
S32 l = bounds.point.x + 1, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y + 1, b = bounds.point.y + bounds.extent.y - 1;
GFX->getDrawUtil()->drawRectFill( bounds, profile->mFillColor);
GFX->getDrawUtil()->drawLine(l, b, r, b, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(r, t, r, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l, t, l, b - 1, profile->mBorderColor);
GFX->getDrawUtil()->drawLine(l + 1, t, r - 1, t, profile->mBorderColor);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->drawRectFill( bounds, profile->mFillColor);
drawUtil->drawLine(l, b, r, b, profile->mBorderColor);
drawUtil->drawLine(r, t, r, b - 1, profile->mBorderColor);
drawUtil->drawLine(l, t, l, b - 1, profile->mBorderColor);
drawUtil->drawLine(l + 1, t, r - 1, t, profile->mBorderColor);
}
void renderBorder( const RectI &bounds, GuiControlProfile *profile )

View file

@ -717,7 +717,7 @@ IMPLEMENT_STRUCT( RectSpacingI,
END_IMPLEMENT_STRUCT;
ConsoleType( RectSpacingI, TypeRectSpacingI, RectSpacingI )
ConsoleType(RectSpacingI, TypeRectSpacingI, RectSpacingI, "")
ImplementConsoleTypeCasters( TypeRectSpacingI, RectSpacingI )
ConsoleGetType( TypeRectSpacingI )

View file

@ -47,8 +47,6 @@ U32 GuiImageList::Insert( const char* texturePath, GFXTextureProfile *Type )
{
TextureEntry *t = new TextureEntry;
if ( ! t ) return -1;
t->TexturePath = StringTable->insert(texturePath);
if ( *t->TexturePath )
{

View file

@ -564,31 +564,25 @@ void GuiInspector::refresh()
ungroup = new GuiInspectorGroup( "Ungrouped", this );
ungroup->setHeaderHidden( true );
ungroup->setCanCollapse( false );
if( ungroup != NULL )
{
ungroup->registerObject();
mGroups.push_back( ungroup );
addObject( ungroup );
}
ungroup->registerObject();
mGroups.push_back( ungroup );
addObject( ungroup );
}
// Put the 'transform' group first
GuiInspectorGroup *transform = new GuiInspectorGroup( "Transform", this );
if( transform != NULL )
{
transform->registerObject();
mGroups.push_back( transform );
addObject( transform );
}
transform->registerObject();
mGroups.push_back(transform);
addObject(transform);
// Always create the 'general' group (for fields without a group)
GuiInspectorGroup *general = new GuiInspectorGroup( "General", this );
if( general != NULL )
{
general->registerObject();
mGroups.push_back( general );
addObject( general );
}
general->registerObject();
mGroups.push_back(general);
addObject(general);
// Create the inspector groups for static fields.
@ -606,25 +600,23 @@ void GuiInspector::refresh()
if( !group && !isGroupFiltered( itr->pGroupname ) )
{
GuiInspectorGroup *group = new GuiInspectorGroup( itr->pGroupname, this );
if( group != NULL )
group->registerObject();
if( !group->getNumFields() )
{
group->registerObject();
if( !group->getNumFields() )
{
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[GuiInspector] Removing empty group '%s'",
group->getCaption().c_str() );
#endif
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[GuiInspector] Removing empty group '%s'",
group->getCaption().c_str() );
#endif
// The group ended up having no fields. Remove it.
group->deleteObject();
}
else
{
mGroups.push_back( group );
addObject( group );
}
}
// The group ended up having no fields. Remove it.
group->deleteObject();
}
else
{
mGroups.push_back( group );
addObject( group );
}
}
}
}
@ -634,12 +626,10 @@ void GuiInspector::refresh()
if ( !isGroupFiltered( "Dynamic Fields" ) )
{
GuiInspectorGroup *dynGroup = new GuiInspectorDynamicGroup( "Dynamic Fields", this);
if( dynGroup != NULL )
{
dynGroup->registerObject();
mGroups.push_back( dynGroup );
addObject( dynGroup );
}
dynGroup->registerObject();
mGroups.push_back( dynGroup );
addObject( dynGroup );
}
if( mShowCustomFields && mTargets.size() == 1 )

View file

@ -57,10 +57,6 @@ GuiControl* GuiInspectorTypeMenuBase::constructEditControl()
{
GuiControl* retCtrl = new GuiPopUpMenuCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
GuiPopUpMenuCtrl *menu = dynamic_cast<GuiPopUpMenuCtrl*>(retCtrl);
// Let's make it look pretty.
@ -218,25 +214,21 @@ GuiControl* GuiInspectorTypeMaterialName::construct(const char* command)
//return retCtrl;
mBrowseButton = new GuiBitmapButtonCtrl();
if ( mBrowseButton != NULL )
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
char szBuffer[512];
dSprintf( szBuffer, 512, command, getId());
mBrowseButton->setField( "Command", szBuffer );
dSprintf( szBuffer, 512, command, getId());
mBrowseButton->setField( "Command", szBuffer );
//temporary static button name
char bitmapName[512] = "tools/materialEditor/gui/change-material-btn";
mBrowseButton->setBitmap( bitmapName );
//temporary static button name
char bitmapName[512] = "tools/materialEditor/gui/change-material-btn";
mBrowseButton->setBitmap( bitmapName );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
}
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
return retCtrl;
}
@ -328,25 +320,21 @@ GuiControl* GuiInspectorTypeTerrainMaterialName::construct(const char* command)
//return retCtrl;
mBrowseButton = new GuiBitmapButtonCtrl();
if ( mBrowseButton != NULL )
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
char szBuffer[512];
dSprintf( szBuffer, 512, command, getId());
mBrowseButton->setField( "Command", szBuffer );
dSprintf( szBuffer, 512, command, getId());
mBrowseButton->setField( "Command", szBuffer );
//temporary static button name
char bitmapName[512] = "tools/gui/images/layers-btn";
mBrowseButton->setBitmap( bitmapName );
//temporary static button name
char bitmapName[512] = "tools/gui/images/layers-btn";
mBrowseButton->setBitmap( bitmapName );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
}
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
return retCtrl;
}
@ -414,10 +402,6 @@ GuiControl* GuiInspectorTypeCheckBox::constructEditControl()
{
GuiControl* retCtrl = new GuiCheckBoxCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
GuiCheckBoxCtrl *check = dynamic_cast<GuiCheckBoxCtrl*>(retCtrl);
// Let's make it look pretty.
@ -485,10 +469,6 @@ GuiControl* GuiInspectorTypeFileName::constructEditControl()
{
GuiControl* retCtrl = new GuiTextEditCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
// Let's make it look pretty.
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditRightProfile" );
retCtrl->setDataField( StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile" );
@ -504,20 +484,17 @@ GuiControl* GuiInspectorTypeFileName::constructEditControl()
mBrowseButton = new GuiButtonCtrl();
if( mBrowseButton != NULL )
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
char szBuffer[512];
dSprintf( szBuffer, 512, "getLoadFilename(\"*.*|*.*\", \"%d.apply\", %d.getData());", getId(), getId() );
mBrowseButton->setField( "Command", szBuffer );
mBrowseButton->setField( "text", "..." );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
}
dSprintf( szBuffer, 512, "getLoadFilename(\"*.*|*.*\", \"%d.apply\", %d.getData());", getId(), getId() );
mBrowseButton->setField( "Command", szBuffer );
mBrowseButton->setField( "text", "..." );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
return retCtrl;
}
@ -769,23 +746,20 @@ GuiControl* GuiInspectorTypeShapeFilename::constructEditControl()
// Create "Open in ShapeEditor" button
mShapeEdButton = new GuiBitmapButtonCtrl();
if ( mShapeEdButton != NULL )
{
char szBuffer[512];
dSprintf( szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.open(%d.getText());", retCtrl->getId() );
mShapeEdButton->setField( "Command", szBuffer );
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
mShapeEdButton->setBitmap( bitmapName );
dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.open(%d.getText());", retCtrl->getId());
mShapeEdButton->setField("Command", szBuffer);
mShapeEdButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mShapeEdButton->setDataField( StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile" );
mShapeEdButton->setDataField( StringTable->insert("hovertime"), NULL, "1000" );
mShapeEdButton->setDataField( StringTable->insert("tooltip"), NULL, "Open this file in the Shape Editor" );
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
mShapeEdButton->setBitmap(bitmapName);
mShapeEdButton->registerObject();
addObject( mShapeEdButton );
}
mShapeEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
mShapeEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
mShapeEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
mShapeEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Shape Editor");
mShapeEdButton->registerObject();
addObject(mShapeEdButton);
return retCtrl;
}
@ -842,10 +816,6 @@ GuiControl* GuiInspectorTypeCommand::constructEditControl()
{
GuiButtonCtrl* retCtrl = new GuiButtonCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
// Let's make it look pretty.
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile" );
@ -926,25 +896,21 @@ GuiControl* GuiInspectorTypeRectUV::constructEditControl()
//return retCtrl;
mBrowseButton = new GuiBitmapButtonCtrl();
if ( mBrowseButton != NULL )
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
char szBuffer[512];
dSprintf( szBuffer, 512, "uvEditor.showDialog(\"%d.apply\", %d, %d.getText());", getId(), mInspector->getInspectObject()->getId(), retCtrl->getId());
mBrowseButton->setField( "Command", szBuffer );
dSprintf( szBuffer, 512, "uvEditor.showDialog(\"%d.apply\", %d, %d.getText());", getId(), mInspector->getInspectObject()->getId(), retCtrl->getId());
mBrowseButton->setField( "Command", szBuffer );
//temporary static button name
char bitmapName[512] = "tools/gui/images/uv-editor-btn";
mBrowseButton->setBitmap( bitmapName );
//temporary static button name
char bitmapName[512] = "tools/gui/images/uv-editor-btn";
mBrowseButton->setBitmap( bitmapName );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
}
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
return retCtrl;
}
@ -1084,10 +1050,6 @@ GuiControl* GuiInspectorTypeColor::constructEditControl()
{
GuiControl* retCtrl = new GuiTextEditCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
// Let's make it look pretty.
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile" );
@ -1101,46 +1063,42 @@ GuiControl* GuiInspectorTypeColor::constructEditControl()
mBrowseButton = new GuiSwatchButtonCtrl();
if ( mBrowseButton != NULL )
{
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorSwatchButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
RectI browseRect( Point2I( ( getLeft() + getWidth()) - 26, getTop() + 2), Point2I(20, getHeight() - 4) );
mBrowseButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorSwatchButtonProfile" );
mBrowseButton->registerObject();
addObject( mBrowseButton );
char szColor[512];
if( _getColorConversionFunction() )
dSprintf( szColor, 512, "%s( %d.color )", _getColorConversionFunction(), mBrowseButton->getId() );
else
dSprintf( szColor, 512, "%d.color", mBrowseButton->getId() );
char szColor[2048];
if( _getColorConversionFunction() )
dSprintf( szColor, 512, "%s( %d.color )", _getColorConversionFunction(), mBrowseButton->getId() );
else
dSprintf( szColor, 512, "%d.color", mBrowseButton->getId() );
// If the inspector supports the alternate undo recording path,
// use this here.
// If the inspector supports the alternate undo recording path,
// use this here.
char szBuffer[2048];
GuiInspector* inspector = getInspector();
if( inspector->isMethod( "onInspectorPreFieldModification" ) )
{
dSprintf( szBuffer, sizeof( szBuffer ),
"%d.onInspectorPreFieldModification(\"%s\",\"%s\"); %s(%s, \"%d.onInspectorPostFieldModification(); %d.applyWithoutUndo\", %d.getRoot(), \"%d.applyWithoutUndo\", \"%d.onInspectorDiscardFieldModification(); %%unused=\");",
inspector->getId(), getRawFieldName(), getArrayIndex(),
mColorFunction, szColor, inspector->getId(), getId(),
getId(),
getId(),
inspector->getId()
);
}
else
dSprintf( szBuffer, sizeof( szBuffer ),
"%s(%s, \"%d.apply\", %d.getRoot());",
mColorFunction, szColor, getId(), getId() );
mBrowseButton->setConsoleCommand( szBuffer );
mBrowseButton->setUseMouseEvents( true ); // Allow drag&drop.
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
GuiInspector* inspector = getInspector();
if( inspector->isMethod( "onInspectorPreFieldModification" ) )
{
dSprintf( szBuffer, sizeof( szBuffer ),
"%d.onInspectorPreFieldModification(\"%s\",\"%s\"); %s(%s, \"%d.onInspectorPostFieldModification(); %d.applyWithoutUndo\", %d.getRoot(), \"%d.applyWithoutUndo\", \"%d.onInspectorDiscardFieldModification(); %%unused=\");",
inspector->getId(), getRawFieldName(), getArrayIndex(),
mColorFunction, szColor, inspector->getId(), getId(),
getId(),
getId(),
inspector->getId()
);
}
else
dSprintf( szBuffer, sizeof( szBuffer ),
"%s(%s, \"%d.apply\", %d.getRoot());",
mColorFunction, szColor, getId(), getId() );
mBrowseButton->setConsoleCommand( szBuffer );
mBrowseButton->setUseMouseEvents( true ); // Allow drag&drop.
// Position
mBrowseButton->resize( browseRect.point, browseRect.extent );
return retCtrl;
}
@ -1277,10 +1235,6 @@ GuiControl* GuiInspectorTypeS32::constructEditControl()
{
GuiControl* retCtrl = new GuiTextEditSliderCtrl();
// If we couldn't construct the control, bail!
if( retCtrl == NULL )
return retCtrl;
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile" );
// Don't forget to register ourselves

View file

@ -159,7 +159,7 @@ IMPLEMENT_CALLBACK( GuiMenuBar, onSubmenuSelect, void, ( S32 submenuId, const ch
// console methods
//------------------------------------------------------------------------------
DefineEngineMethod( GuiMenuBar, clearMenus, void, ( S32 param1, S32 param2),,
DefineEngineMethod( GuiMenuBar, clearMenus, void, (),,
"@brief Clears all the menus from the menu bar.\n\n"
"@tsexample\n"
"// Inform the GuiMenuBar control to clear all menus from itself.\n"
@ -795,14 +795,14 @@ GuiMenuBar::Menu* GuiMenuBar::sCreateMenu(const char *menuText, U32 menuId)
return newMenu;
}
void GuiMenuBar::addMenu(GuiMenuBar::Menu *newMenu)
void GuiMenuBar::addMenu(GuiMenuBar::Menu *newMenu, S32 pos)
{
// add it to the menu list
menuBarDirty = true;
Menu **walk;
for(walk = &menuList; *walk; walk = &(*walk)->nextMenu)
;
*walk = newMenu;
if (pos == -1)
mMenuList.push_back(newMenu);
else
mMenuList.insert(pos, newMenu);
}
void GuiMenuBar::addMenu(const char *menuText, U32 menuId)
@ -817,16 +817,16 @@ GuiMenuBar::Menu *GuiMenuBar::findMenu(const char *menu)
if(dIsdigit(menu[0]))
{
U32 id = dAtoi(menu);
for(Menu *walk = menuList; walk; walk = walk->nextMenu)
if(id == walk->id)
return walk;
for (U32 i = 0; i < mMenuList.size(); ++i)
if (id == mMenuList[i]->id)
return mMenuList[i];
return NULL;
}
else
{
for(Menu *walk = menuList; walk; walk = walk->nextMenu)
if(!dStricmp(menu, walk->text))
return walk;
for (U32 i = 0; i < mMenuList.size(); ++i)
if (!dStricmp(menu, mMenuList[i]->text))
return mMenuList[i];
return NULL;
}
}
@ -854,16 +854,15 @@ void GuiMenuBar::removeMenu(Menu *menu)
{
menuBarDirty = true;
clearMenuItems(menu);
for(Menu **walk = &menuList; *walk; walk = &(*walk)->nextMenu)
for (U32 i = 0; i < mMenuList.size(); ++i)
{
if(*walk == menu)
if (mMenuList[i] == menu)
{
*walk = menu->nextMenu;
mMenuList.erase(i);
break;
}
}
dFree(menu->text);
delete menu;
}
void GuiMenuBar::removeMenuItem(Menu *menu, MenuItem *menuItem)
@ -945,8 +944,26 @@ void GuiMenuBar::clearMenuItems(Menu *menu)
void GuiMenuBar::clearMenus()
{
while(menuList)
removeMenu(menuList);
mMenuList.clear();
}
void GuiMenuBar::attachToMenuBar(Menu* menu, S32 pos)
{
addMenu(menu, pos);
}
void GuiMenuBar::removeFromMenuBar(Menu* menu)
{
menuBarDirty = true;
for (U32 i = 0; i < mMenuList.size(); ++i)
{
if (mMenuList[i] == menu)
{
mMenuList.erase(i);
break;
}
}
}
//------------------------------------------------------------------------------
@ -1018,7 +1035,7 @@ void GuiMenuBar::addSubmenuItem(Menu *menu, MenuItem *submenu, const char *text,
newMenuItem->checkGroup = checkGroup;
newMenuItem->nextMenuItem = NULL;
newMenuItem->acceleratorIndex = 0;
newMenuItem->enabled = text[0] != '-';
newMenuItem->enabled = (dStrlen(text) > 1 || text[0] != '-');
newMenuItem->visible = true;
newMenuItem->bitmapIndex = -1;
@ -1083,7 +1100,7 @@ void GuiMenuBar::clearSubmenuItems(MenuItem *menuitem)
GuiMenuBar::GuiMenuBar()
{
menuList = NULL;
mMenuList.clear();
menuBarDirty = true;
mouseDownMenu = NULL;
mouseOverMenu = NULL;
@ -1140,9 +1157,9 @@ GuiMenuBar::Menu *GuiMenuBar::findHitMenu(Point2I mousePoint)
{
Point2I pos = globalToLocalCoord(mousePoint);
for(Menu *walk = menuList; walk; walk = walk->nextMenu)
if(walk->visible && walk->bounds.pointInRect(pos))
return walk;
for (U32 i = 0; i < mMenuList.size(); ++i)
if (mMenuList[i]->visible && mMenuList[i]->bounds.pointInRect(pos))
return mMenuList[i];
return NULL;
}
@ -1153,35 +1170,35 @@ void GuiMenuBar::onPreRender()
{
menuBarDirty = false;
U32 curX = mPadding;
for(Menu *walk = menuList; walk; walk = walk->nextMenu)
for (U32 i = 0; i < mMenuList.size(); ++i)
{
if(!walk->visible)
if (!mMenuList[i]->visible)
continue;
// Bounds depends on if there is a bitmap to be drawn or not
if(walk->bitmapIndex == -1)
if (mMenuList[i]->bitmapIndex == -1)
{
// Text only
walk->bounds.set(curX, 0, mProfile->mFont->getStrWidth(walk->text) + (mHorizontalMargin * 2), getHeight() - (mVerticalMargin * 2));
mMenuList[i]->bounds.set(curX, 0, mProfile->mFont->getStrWidth(mMenuList[i]->text) + (mHorizontalMargin * 2), getHeight() - (mVerticalMargin * 2));
} else
{
// Will the bitmap and text be draw?
if(!walk->drawBitmapOnly)
if (!mMenuList[i]->drawBitmapOnly)
{
// Draw the bitmap and the text
RectI *bitmapBounds = mProfile->mBitmapArrayRects.address();
walk->bounds.set(curX, 0, bitmapBounds[walk->bitmapIndex].extent.x + mProfile->mFont->getStrWidth(walk->text) + (mHorizontalMargin * 2), getHeight() + (mVerticalMargin * 2));
mMenuList[i]->bounds.set(curX, 0, bitmapBounds[mMenuList[i]->bitmapIndex].extent.x + mProfile->mFont->getStrWidth(mMenuList[i]->text) + (mHorizontalMargin * 2), getHeight() + (mVerticalMargin * 2));
} else
{
// Only the bitmap will be drawn
RectI *bitmapBounds = mProfile->mBitmapArrayRects.address();
walk->bounds.set(curX, 0, bitmapBounds[walk->bitmapIndex].extent.x + mBitmapMargin + (mHorizontalMargin * 2), getHeight() + (mVerticalMargin * 2));
mMenuList[i]->bounds.set(curX, 0, bitmapBounds[mMenuList[i]->bitmapIndex].extent.x + mBitmapMargin + (mHorizontalMargin * 2), getHeight() + (mVerticalMargin * 2));
}
}
curX += walk->bounds.extent.x;
curX += mMenuList[i]->bounds.extent.x;
}
mouseOverMenu = NULL;
mouseDownMenu = NULL;
@ -1278,69 +1295,70 @@ void GuiMenuBar::onMouseUp(const GuiEvent &event)
void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
{
RectI ctrlRect(offset, getExtent());
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
//if opaque, fill the update rect with the fill color
if (mProfile->mOpaque)
GFX->getDrawUtil()->drawRectFill(RectI(offset, getExtent()), mProfile->mFillColor);
drawUtil->drawRectFill(RectI(offset, getExtent()), mProfile->mFillColor);
//if there's a border, draw the border
if (mProfile->mBorder)
renderBorder(ctrlRect, mProfile);
for(Menu *walk = menuList; walk; walk = walk->nextMenu)
for (U32 i = 0; i < mMenuList.size(); ++i)
{
if(!walk->visible)
if (!mMenuList[i]->visible)
continue;
ColorI fontColor = mProfile->mFontColor;
RectI bounds = walk->bounds;
RectI bounds = mMenuList[i]->bounds;
bounds.point += offset;
Point2I start;
start.x = walk->bounds.point.x + mHorizontalMargin;
start.y = walk->bounds.point.y + ( walk->bounds.extent.y - mProfile->mFont->getHeight() ) / 2;
start.x = mMenuList[i]->bounds.point.x + mHorizontalMargin;
start.y = mMenuList[i]->bounds.point.y + (mMenuList[i]->bounds.extent.y - mProfile->mFont->getHeight()) / 2;
// Draw the border
if(walk->drawBorder)
if (mMenuList[i]->drawBorder)
{
RectI highlightBounds = bounds;
highlightBounds.inset(1,1);
if(walk == mouseDownMenu)
if (mMenuList[i] == mouseDownMenu)
renderFilledBorder(highlightBounds, mProfile->mBorderColorHL, mProfile->mFillColorHL );
else if(walk == mouseOverMenu && mouseDownMenu == NULL)
renderFilledBorder(highlightBounds, mProfile->mBorderColor, mProfile->mFillColor );
else if (mMenuList[i] == mouseOverMenu && mouseDownMenu == NULL)
renderFilledBorder(highlightBounds, mProfile->mBorderColorHL, mProfile->mFillColorHL);
}
// Do we draw a bitmap?
if(walk->bitmapIndex != -1)
if (mMenuList[i]->bitmapIndex != -1)
{
S32 index = walk->bitmapIndex * 3;
if(walk == mouseDownMenu)
S32 index = mMenuList[i]->bitmapIndex * 3;
if (mMenuList[i] == mouseDownMenu)
++index;
else if(walk == mouseOverMenu && mouseDownMenu == NULL)
else if (mMenuList[i] == mouseOverMenu && mouseDownMenu == NULL)
index += 2;
RectI rect = mProfile->mBitmapArrayRects[index];
Point2I bitmapstart(start);
bitmapstart.y = walk->bounds.point.y + ( walk->bounds.extent.y - rect.extent.y ) / 2;
bitmapstart.y = mMenuList[i]->bounds.point.y + (mMenuList[i]->bounds.extent.y - rect.extent.y) / 2;
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapSR( mProfile->mTextureObject, offset + bitmapstart, rect);
drawUtil->clearBitmapModulation();
drawUtil->drawBitmapSR( mProfile->mTextureObject, offset + bitmapstart, rect);
// Should we also draw the text?
if(!walk->drawBitmapOnly)
if (!mMenuList[i]->drawBitmapOnly)
{
start.x += mBitmapMargin;
GFX->getDrawUtil()->setBitmapModulation( fontColor );
GFX->getDrawUtil()->drawText( mProfile->mFont, start + offset, walk->text, mProfile->mFontColors );
drawUtil->setBitmapModulation( fontColor );
drawUtil->drawText(mProfile->mFont, start + offset, mMenuList[i]->text, mProfile->mFontColors);
}
} else
{
GFX->getDrawUtil()->setBitmapModulation( fontColor );
GFX->getDrawUtil()->drawText( mProfile->mFont, start + offset, walk->text, mProfile->mFontColors );
drawUtil->setBitmapModulation( fontColor );
drawUtil->drawText(mProfile->mFont, start + offset, mMenuList[i]->text, mProfile->mFontColors);
}
}
@ -1353,9 +1371,9 @@ void GuiMenuBar::buildWindowAcceleratorMap( WindowInputGenerator &inputGenerator
// add all our keys:
mCurAcceleratorIndex = 1;
for(Menu *menu = menuList; menu; menu = menu->nextMenu)
for (U32 i = 0; i < mMenuList.size(); ++i)
{
for(MenuItem *item = menu->firstMenuItem; item; item = item->nextMenuItem)
for (MenuItem *item = mMenuList[i]->firstMenuItem; item; item = item->nextMenuItem)
{
if(!item->accelerator)
{
@ -1383,20 +1401,20 @@ void GuiMenuBar::acceleratorKeyPress(U32 index)
{
// loop through all the menus
// and find the item that corresponds to the accelerator index
for(Menu *menu = menuList; menu; menu = menu->nextMenu)
for (U32 i = 0; i < mMenuList.size(); ++i)
{
if(!menu->visible)
if (!mMenuList[i]->visible)
continue;
for(MenuItem *item = menu->firstMenuItem; item; item = item->nextMenuItem)
for (MenuItem *item = mMenuList[i]->firstMenuItem; item; item = item->nextMenuItem)
{
if(item->acceleratorIndex == index)
{
// first, call the script callback for menu selection:
onMenuSelect_callback(menu->id, menu->text);
onMenuSelect_callback(mMenuList[i]->id, mMenuList[i]->text);
if(item->visible)
menuItemSelected(menu, item);
menuItemSelected(mMenuList[i], item);
return;
}
}
@ -1623,7 +1641,7 @@ void GuiMenuBar::closeMenu()
}
// Called when a menu item is highlighted by the mouse
void GuiMenuBar::highlightedMenuItem(S32 selectionIndex, RectI bounds, Point2I cellSize)
void GuiMenuBar::highlightedMenuItem(S32 selectionIndex, const RectI& bounds, Point2I cellSize)
{
S32 selstore = selectionIndex;
@ -1777,7 +1795,7 @@ void GuiMenuBar::onAction()
//------------------------------------------------------------------------------
// Performs an action when a menu item that is a submenu is selected/highlighted
void GuiMenuBar::onSubmenuAction(S32 selectionIndex, RectI bounds, Point2I cellSize)
void GuiMenuBar::onSubmenuAction(S32 selectionIndex, const RectI& bounds, Point2I cellSize)
{
if(!mouseOverSubmenu)
return;

View file

@ -133,7 +133,7 @@ public:
GuiSubmenuBackgroundCtrl *mSubmenuBackground; // Background for a submenu
GuiMenuTextListCtrl *mSubmenuTextList; // Text list for a submenu
Menu *menuList;
Vector<Menu*> mMenuList;
Menu *mouseDownMenu;
Menu *mouseOverMenu;
@ -164,7 +164,7 @@ public:
// 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);
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
@ -175,6 +175,9 @@ public:
static void clearMenuItems(Menu *menu);
void clearMenus();
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);
@ -182,12 +185,12 @@ public:
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, RectI bounds, Point2I cellSize);
void onSubmenuAction(S32 selectionIndex, const RectI& bounds, Point2I cellSize);
void closeSubmenu();
void checkSubmenuMouseMove(const GuiEvent &event);
MenuItem *findHitMenuItem(Point2I mousePoint);
void highlightedMenuItem(S32 selectionIndex, RectI bounds, Point2I cellSize); // Called whenever a menu item is highlighted by the mouse
void highlightedMenuItem(S32 selectionIndex, const RectI& bounds, Point2I cellSize); // Called whenever a menu item is highlighted by the mouse
// display/mouse functions

View file

@ -287,33 +287,35 @@ void GuiRectHandles::onRender(Point2I offset, const RectI &updateRect)
Point2I size(extent.x*mHandleRect.extent.x, extent.y*mHandleRect.extent.y);
RectI box(offset+pos, size);
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
// Draw border
GFX->getDrawUtil()->drawRect(box, handleColor);
drawUtil->drawRect(box, handleColor);
// Draw each handle
Point2I handleSize(mHandleSize, mHandleSize);
RectI handleRect(box.point, handleSize);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper left
drawUtil->drawRectFill(handleRect, handleColor); // Upper left
handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper right
drawUtil->drawRectFill(handleRect, handleColor); // Upper right
handleRect.point = Point2I(box.point.x, box.point.y+size.y-handleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower left
drawUtil->drawRectFill(handleRect, handleColor); // Lower left
handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+size.y-handleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower right
drawUtil->drawRectFill(handleRect, handleColor); // Lower right
Point2I halfSize = size / 2;
Point2I halfHandleSize = handleSize / 2;
handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Upper middle
drawUtil->drawRectFill(handleRect, handleColor); // Upper middle
handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+size.y-handleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Lower middle
drawUtil->drawRectFill(handleRect, handleColor); // Lower middle
handleRect.point = Point2I(box.point.x, box.point.y+halfSize.y-halfHandleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Left middle
drawUtil->drawRectFill(handleRect, handleColor); // Left middle
handleRect.point = Point2I(box.point.x+size.x-handleSize.x, box.point.y+halfSize.y-halfHandleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Right middle
drawUtil->drawRectFill(handleRect, handleColor); // Right middle
handleRect.point = Point2I(box.point.x+halfSize.x-halfHandleSize.x, box.point.y+halfSize.y-halfHandleSize.y);
GFX->getDrawUtil()->drawRectFill(handleRect, handleColor); // Middle
drawUtil->drawRectFill(handleRect, handleColor); // Middle
renderChildControls(offset, updateRect);
}

View file

@ -330,10 +330,11 @@ void GuiShapeEdPreview::setCurrentDetail(S32 dl)
{
if ( mModel )
{
S32 smallest = mModel->getShape()->mSmallestVisibleDL;
mModel->getShape()->mSmallestVisibleDL = mModel->getShape()->details.size()-1;
TSShape* shape = mModel->getShape();
S32 smallest = shape->mSmallestVisibleDL;
shape->mSmallestVisibleDL = shape->details.size() - 1;
mModel->setCurrentDetail( dl );
mModel->getShape()->mSmallestVisibleDL = smallest;
shape->mSmallestVisibleDL = smallest;
// Match the camera distance to this detail if necessary
//@todo if ( !gui->mFixedDetail )
@ -359,19 +360,21 @@ bool GuiShapeEdPreview::setObjectModel(const char* modelName)
mModel = new TSShapeInstance( model, true );
AssertFatal( mModel, avar("GuiShapeEdPreview: Failed to load model %s. Please check your model name and load a valid model.", modelName ));
TSShape* shape = mModel->getShape();
// Initialize camera values:
mOrbitPos = mModel->getShape()->center;
mOrbitPos = shape->center;
// Set camera move and zoom speed according to model size
mMoveSpeed = mModel->getShape()->radius / sMoveScaler;
mZoomSpeed = mModel->getShape()->radius / sZoomScaler;
mMoveSpeed = shape->radius / sMoveScaler;
mZoomSpeed = shape->radius / sZoomScaler;
// Reset node selection
mHoverNode = -1;
mSelectedNode = -1;
mSelectedObject = -1;
mSelectedObjDetail = 0;
mProjectedNodes.setSize( mModel->getShape()->nodes.size() );
mProjectedNodes.setSize( shape->nodes.size() );
// Reset detail stats
mCurrentDL = 0;
@ -511,8 +514,6 @@ bool GuiShapeEdPreview::mountShape(const char* modelName, const char* nodeName,
return false;
TSShapeInstance* tsi = new TSShapeInstance( model, true );
if ( !tsi )
return false;
if ( slot == -1 )
{
@ -683,9 +684,11 @@ void GuiShapeEdPreview::refreshShape()
mModel->initNodeTransforms();
mModel->initMeshObjects();
mProjectedNodes.setSize( mModel->getShape()->nodes.size() );
TSShape* shape = mModel->getShape();
if ( mSelectedObject >= mModel->getShape()->objects.size() )
mProjectedNodes.setSize( shape->nodes.size() );
if ( mSelectedObject >= shape->objects.size() )
{
mSelectedObject = -1;
mSelectedObjDetail = 0;
@ -694,22 +697,22 @@ void GuiShapeEdPreview::refreshShape()
// Re-compute the collision mesh stats
mColMeshes = 0;
mColPolys = 0;
for ( S32 i = 0; i < mModel->getShape()->details.size(); i++ )
for ( S32 i = 0; i < shape->details.size(); i++ )
{
const TSShape::Detail& det = mModel->getShape()->details[i];
const String& detName = mModel->getShape()->getName( det.nameIndex );
const TSShape::Detail& det = shape->details[i];
const String& detName = shape->getName( det.nameIndex );
if ( ( det.subShapeNum < 0 ) || !detName.startsWith( "collision-" ) )
continue;
mColPolys += det.polyCount;
S32 od = det.objectDetailNum;
S32 start = mModel->getShape()->subShapeFirstObject[det.subShapeNum];
S32 end = start + mModel->getShape()->subShapeNumObjects[det.subShapeNum];
S32 start = shape->subShapeFirstObject[det.subShapeNum];
S32 end = start + shape->subShapeNumObjects[det.subShapeNum];
for ( S32 j = start; j < end; j++ )
{
const TSShape::Object &obj = mModel->getShape()->objects[j];
const TSMesh* mesh = ( od < obj.numMeshes ) ? mModel->getShape()->meshes[obj.startMeshIndex + od] : NULL;
const TSShape::Object &obj = shape->objects[j];
const TSMesh* mesh = ( od < obj.numMeshes ) ? shape->meshes[obj.startMeshIndex + od] : NULL;
if ( mesh )
mColMeshes++;
}
@ -1542,10 +1545,12 @@ void GuiShapeEdPreview::renderSunDirection() const
GFXStateBlockDesc desc;
desc.setZReadWrite( true, true );
GFX->getDrawUtil()->drawArrow( desc, start, end, color );
GFX->getDrawUtil()->drawArrow( desc, start + up, end + up, color );
GFX->getDrawUtil()->drawArrow( desc, start + right, end + right, color );
GFX->getDrawUtil()->drawArrow( desc, start + up + right, end + up + right, color );
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
drawUtil->drawArrow( desc, start, end, color );
drawUtil->drawArrow( desc, start + up, end + up, color );
drawUtil->drawArrow( desc, start + right, end + right, color );
drawUtil->drawArrow( desc, start + up + right, end + up + right, color );
}
}
@ -1603,6 +1608,8 @@ void GuiShapeEdPreview::renderNodes() const
void GuiShapeEdPreview::renderNodeAxes(S32 index, const ColorF& nodeColor) const
{
if(mModel->mNodeTransforms.size() <= index || index < 0)
return;
const Point3F xAxis( 1.0f, 0.15f, 0.15f );
const Point3F yAxis( 0.15f, 1.0f, 0.15f );
const Point3F zAxis( 0.15f, 0.15f, 1.0f );
@ -1626,6 +1633,8 @@ void GuiShapeEdPreview::renderNodeAxes(S32 index, const ColorF& nodeColor) const
void GuiShapeEdPreview::renderNodeName(S32 index, const ColorF& textColor) const
{
if(index < 0 || index >= mModel->getShape()->nodes.size() || index >= mProjectedNodes.size())
return;
const TSShape::Node& node = mModel->getShape()->nodes[index];
const String& nodeName = mModel->getShape()->getName( node.nameIndex );

View file

@ -167,12 +167,10 @@ GuiInspectorField* GuiInspectorGroup::constructField( S32 fieldType )
GuiInspectorDatablockField *dbFieldClass = new GuiInspectorDatablockField( typeClassName );
if( dbFieldClass != NULL )
{
// return our new datablock field with correct datablock type enumeration info
return dbFieldClass;
}
}
// return our new datablock field with correct datablock type enumeration info
return dbFieldClass;
}
// Nope, not a datablock. So maybe it has a valid inspector field override we can use?
if(!cbt->getInspectorFieldType())

View file

@ -52,13 +52,10 @@ void GuiVariableInspector::loadVars( String searchStr )
group->setCaption( "Global Variables" );
group->mSearchString = searchStr;
if( group != NULL )
{
group->registerObject();
mGroups.push_back( group );
addObject( group );
}
group->registerObject();
mGroups.push_back( group );
addObject( group );
//group->inspectGroup();
}

View file

@ -206,8 +206,10 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
mDim = getHeight();
else
mDim = getWidth();
GFXDrawUtil* drawUtil = GFX->getDrawUtil();
GFX->getDrawUtil()->clearBitmapModulation();
drawUtil->clearBitmapModulation();
if(mNumberOfBitmaps == 1)
{
@ -218,14 +220,14 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
//drawing stretch bitmap
RectI progressRect = ctrlRect;
progressRect.extent.x = width;
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
}
}
else if(mNumberOfBitmaps >= 3)
{
//drawing left-end bitmap
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);
//draw the progress with image
S32 width = (S32)((F32)(getWidth()) * mProgress);
@ -237,11 +239,11 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
progressRect.extent.x = (width - mDim - mDim);
if (progressRect.extent.x < 0)
progressRect.extent.x = 0;
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
//drawing right-end bitmap
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
GFX->getDrawUtil()->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
}
}
else
@ -249,7 +251,7 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
//if there's a border, draw it
if (mProfile->mBorder)
GFX->getDrawUtil()->drawRect(ctrlRect, mProfile->mBorderColor);
drawUtil->drawRect(ctrlRect, mProfile->mBorderColor);
Parent::onRender( offset, updateRect );

View file

@ -46,7 +46,7 @@ ConsoleDocClass( GuiMouseEventCtrl,
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDown, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDown, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse is pressed down while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -70,7 +70,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDown, void, ( U8 modifier, Point2I
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseUp, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseUp, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse is released while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -94,7 +94,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseUp, void, ( U8 modifier, Point2I m
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseMove, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseMove, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse is moved (without dragging) while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -118,7 +118,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseMove, void, ( U8 modifier, Point2I
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDragged, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDragged, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse is dragged while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -142,7 +142,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseDragged, void, ( U8 modifier, Poi
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseEnter, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseEnter, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse enters this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -166,7 +166,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseEnter, void, ( U8 modifier, Point
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseLeave, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseLeave, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse leaves this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -190,7 +190,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onMouseLeave, void, ( U8 modifier, Point
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseDown, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseDown, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the right mouse button is pressed while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -214,7 +214,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseDown, void, ( U8 modifier, P
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseUp, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseUp, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the right mouse button is released while in this control.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -238,7 +238,7 @@ IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseUp, void, ( U8 modifier, Poi
"@see GuiControl\n\n"
);
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseDragged, void, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ),
IMPLEMENT_CALLBACK( GuiMouseEventCtrl, onRightMouseDragged, void, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ),
( modifier, mousePoint, mouseClickCount ),
"@brief Callback that occurs whenever the mouse is dragged in this control while the right mouse button is pressed.\n\n"
"@param modifier Key that was pressed during this callback. Values are:\n\n"
@ -270,11 +270,6 @@ GuiMouseEventCtrl::GuiMouseEventCtrl()
//------------------------------------------------------------------------------
void GuiMouseEventCtrl::sendMouseEvent(const char * name, const GuiEvent & event)
{
char buf[3][32];
dSprintf(buf[0], 32, "%d", event.modifier);
dSprintf(buf[1], 32, "%d %d", event.mousePoint.x, event.mousePoint.y);
dSprintf(buf[2], 32, "%d", event.mouseClickCount);
if(dStricmp(name,"onMouseDown") == 0)
onMouseDown_callback(event.modifier, event.mousePoint, event.mouseClickCount);
else if(dStricmp(name,"onMouseUp") == 0)

View file

@ -41,15 +41,15 @@ class GuiMouseEventCtrl : public GuiControl
GuiMouseEventCtrl();
DECLARE_CALLBACK( void, onMouseDown, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseUp, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseMove, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseDragged, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseEnter, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseLeave, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseDown, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseUp, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseDragged, ( U8 modifier, Point2I mousePoint,U8 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseDown, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseUp, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseMove, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseDragged, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseEnter, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onMouseLeave, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseDown, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseUp, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
DECLARE_CALLBACK( void, onRightMouseDragged, ( S32 modifier, Point2I mousePoint, S32 mouseClickCount ));
// GuiControl
void onMouseDown(const GuiEvent & event);

View file

@ -575,12 +575,13 @@ void MessageVector::registerSpectator(SpectatorCallback callBack, void *spectato
}
mSpectators.increment();
mSpectators.last().callback = callBack;
mSpectators.last().key = spectatorKey;
SpectatorRef& lastSpectatorRef = mSpectators.last();
lastSpectatorRef.callback = callBack;
lastSpectatorRef.key = spectatorKey;
// Need to message this spectator of all the lines currently inserted...
for (i = 0; i < mMessageLines.size(); i++) {
(*mSpectators.last().callback)(mSpectators.last().key,
(*lastSpectatorRef.callback)(lastSpectatorRef.key,
LineInserted, i);
}
}

View file

@ -918,7 +918,7 @@ void DICreateUndoAction::initPersistFields()
Parent::initPersistFields();
}
void DICreateUndoAction::addDecal( DecalInstance decal )
void DICreateUndoAction::addDecal(const DecalInstance& decal)
{
mDecalInstance = decal;
mDatablockId = decal.mDataBlock->getId();
@ -1006,7 +1006,7 @@ void DIDeleteUndoAction::initPersistFields()
Parent::initPersistFields();
}
void DIDeleteUndoAction::deleteDecal( DecalInstance decal )
void DIDeleteUndoAction::deleteDecal(const DecalInstance& decal)
{
mDecalInstance = decal;
mDatablockId = decal.mDataBlock->getId();
@ -1094,7 +1094,7 @@ void DBDeleteUndoAction::initPersistFields()
Parent::initPersistFields();
}
void DBDeleteUndoAction::deleteDecal( DecalInstance decal )
void DBDeleteUndoAction::deleteDecal(const DecalInstance& decal)
{
mDecalInstanceVec.increment();
mDecalInstanceVec.last() = decal;

View file

@ -129,7 +129,7 @@ public:
DICreateUndoAction( const UTF8* actionName = "Create Decal " );
virtual ~DICreateUndoAction();
void addDecal( DecalInstance decal );
void addDecal(const DecalInstance& decal);
// UndoAction
virtual void undo();
@ -159,7 +159,7 @@ public:
virtual ~DIDeleteUndoAction();
///
void deleteDecal( DecalInstance decal );
void deleteDecal(const DecalInstance& decal);
// UndoAction
virtual void undo();
@ -188,7 +188,7 @@ public:
DBDeleteUndoAction( const UTF8* actionName = "Delete Decal Datablock" );
virtual ~DBDeleteUndoAction();
void deleteDecal( DecalInstance decal );
void deleteDecal(const DecalInstance& decal);
// UndoAction
virtual void undo();

View file

@ -357,9 +357,6 @@ GBitmap * GuiMissionAreaCtrl::createTerrainBitmap()
GBitmap * bitmap = new GBitmap(mTerrainBlock->getBlockSize(), mTerrainBlock->getBlockSize(), false, GFXFormatR8G8B8 );
if(!bitmap)
return NULL;
// get the min/max
F32 min, max;
mTerrainBlock->getMinMaxHeight(&min, &max);

View file

@ -66,7 +66,7 @@ template<class T> inline void Selection<T>::offset( const Point3F &delta )
{
typename Selection<T>::iterator itr = this->begin();
for ( ; itr != this->end(); itr++ )
for (; itr != this->end(); ++itr)
offsetObject( *itr, delta );
}
@ -75,7 +75,7 @@ template<class T> inline void Selection<T>::rotate( const EulerF &delta )
typename Selection<T>::iterator itr = this->begin();
Point3F origin = getOrigin();
for ( ; itr != this->end(); itr++ )
for (; itr != this->end(); ++itr)
rotateObject( *itr, delta, origin );
}

View file

@ -1449,14 +1449,15 @@ void TerrainEditor::renderSelection( const Selection & sel, const ColorF & inCol
// walk the points in the selection
for(U32 i = 0; i < sel.size(); i++)
{
Point2I gPos = sel[i].mGridPoint.gridPos;
GridPoint selectedGridPoint = sel[i].mGridPoint;
Point2I gPos = selectedGridPoint.gridPos;
GFXVertexPC *verts = &(vertexBuffer[i * 5]);
bool center = gridToWorld(sel[i].mGridPoint, verts[0].point);
gridToWorld(Point2I(gPos.x + 1, gPos.y), verts[1].point, sel[i].mGridPoint.terrainBlock);
gridToWorld(Point2I(gPos.x + 1, gPos.y + 1), verts[2].point, sel[i].mGridPoint.terrainBlock);
gridToWorld(Point2I(gPos.x, gPos.y + 1), verts[3].point, sel[i].mGridPoint.terrainBlock);
bool center = gridToWorld(selectedGridPoint, verts[0].point);
gridToWorld(Point2I(gPos.x + 1, gPos.y), verts[1].point, selectedGridPoint.terrainBlock);
gridToWorld(Point2I(gPos.x + 1, gPos.y + 1), verts[2].point, selectedGridPoint.terrainBlock);
gridToWorld(Point2I(gPos.x, gPos.y + 1), verts[3].point, selectedGridPoint.terrainBlock);
verts[4].point = verts[0].point;
F32 weight = sel[i].mWeight;
@ -2762,9 +2763,9 @@ DefineConsoleMethod(TerrainEditor, getTerrainUnderWorldPoint, S32, (const char *
if(tEditor == NULL)
return 0;
Point3F pos;
if(!dStrIsEmpty(ptOrX) && dStrIsEmpty(Y) && dStrIsEmpty(Z))
if(!String::isEmpty(ptOrX) && String::isEmpty(Y) && String::isEmpty(Z))
dSscanf(ptOrX, "%f %f %f", &pos.x, &pos.y, &pos.z);
else if(!dStrIsEmpty(ptOrX) && !dStrIsEmpty(Y) && !dStrIsEmpty(Z))
else if(!String::isEmpty(ptOrX) && !String::isEmpty(Y) && !String::isEmpty(Z))
{
pos.x = dAtof(ptOrX);
pos.y = dAtof(Y);

View file

@ -30,7 +30,9 @@
#include "console/simObjectMemento.h"
#endif
class GuiInspectorField;
// Need full definition visible for SimObjectPtr<GuiInspectorField>
#include "gui/editor/inspector/field.h"
class GuiInspector;
class MECreateUndoAction : public UndoAction

View file

@ -1631,10 +1631,11 @@ void WorldEditor::renderScreenObj( SceneObject *obj, const Point3F& projPos, con
// Save an IconObject for performing icon-click testing later.
mIcons.increment();
mIcons.last().object = obj;
mIcons.last().rect = renderRect;
mIcons.last().dist = projPos.z;
mIcons.last().alpha = iconAlpha;
IconObject& lastIcon = mIcons.last();
lastIcon.object = obj;
lastIcon.rect = renderRect;
lastIcon.dist = projPos.z;
lastIcon.alpha = iconAlpha;
}
//
@ -2654,7 +2655,7 @@ void WorldEditor::renderScene( const RectI &updateRect )
// Probably should test the entire icon screen-rect instead of just the centerpoint
// but would need to move some code from renderScreenObj to here.
if ( mDragSelect )
if (mDragSelect && selection)
if ( mDragRect.pointInRect(sPosI) && !selection->objInSet(obj) )
mDragSelected->addObject(obj);
@ -2809,7 +2810,7 @@ void WorldEditor::clearSelection()
void WorldEditor::selectObject( SimObject *obj )
{
if ( mSelectionLocked || !mSelected )
if ( mSelectionLocked || !mSelected || !obj )
return;
// Don't check isSelectionEnabled of SceneObjects here as we
@ -2832,7 +2833,7 @@ void WorldEditor::selectObject( const char* obj )
void WorldEditor::unselectObject( SimObject *obj )
{
if ( mSelectionLocked || !mSelected )
if ( mSelectionLocked || !mSelected || !obj )
return;
if ( !objClassIgnored( obj ) && mSelected->objInSet( obj ) )