Merge branch 'master' into console-func-refactor

Conflicts:
	Engine/source/app/net/net.cpp
	Engine/source/console/astNodes.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/console/console.h
	Engine/source/console/consoleInternal.h
	Engine/source/console/engineAPI.h
This commit is contained in:
Daniel Buckmaster 2014-10-14 14:40:17 +11:00
commit b507dc9555
6487 changed files with 315149 additions and 609761 deletions

View file

@ -53,6 +53,13 @@ ConsoleDocClass( GuiTSCtrl,
U32 GuiTSCtrl::smFrameCount = 0;
Vector<GuiTSCtrl*> GuiTSCtrl::smAwakeTSCtrls;
ImplementEnumType( GuiTSRenderStyles,
"Style of rendering for a GuiTSCtrl.\n\n"
"@ingroup Gui3D" )
{ GuiTSCtrl::RenderStyleStandard, "standard" },
{ GuiTSCtrl::RenderStyleStereoSideBySide, "stereo side by side" },
EndImplementEnumType;
//-----------------------------------------------------------------------------
@ -131,6 +138,8 @@ GuiTSCtrl::GuiTSCtrl()
mForceFOV = 0;
mReflectPriority = 1.0f;
mRenderStyle = RenderStyleStandard;
mSaveModelview.identity();
mSaveProjection.identity();
mSaveViewport.set( 0, 0, 10, 10 );
@ -142,6 +151,9 @@ GuiTSCtrl::GuiTSCtrl()
mLastCameraQuery.farPlane = 10.0f;
mLastCameraQuery.nearPlane = 0.01f;
mLastCameraQuery.projectionOffset = Point2F::Zero;
mLastCameraQuery.eyeOffset = Point3F::Zero;
mLastCameraQuery.ortho = false;
}
@ -165,6 +177,9 @@ void GuiTSCtrl::initPersistFields()
"The reflect update priorities of all visible GuiTSCtrls are added together and each control is assigned "
"a share of the per-frame reflection update time according to its percentage of the total priority value." );
addField("renderStyle", TYPEID< RenderStyles >(), Offset(mRenderStyle, GuiTSCtrl),
"Indicates how this control should render its contents." );
endGroup( "Rendering" );
Parent::initPersistFields();
@ -256,7 +271,9 @@ F32 GuiTSCtrl::calculateViewDistance(F32 radius)
F32 fov = mLastCameraQuery.fov;
F32 wwidth;
F32 wheight;
F32 aspectRatio = F32(getWidth()) / F32(getHeight());
F32 renderWidth = (mRenderStyle == RenderStyleStereoSideBySide) ? F32(getWidth())*0.5f : F32(getWidth());
F32 renderHeight = F32(getHeight());
F32 aspectRatio = renderWidth / renderHeight;
// Use the FOV to calculate the viewport height scale
// then generate the width scale from the aspect ratio.
@ -299,6 +316,21 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
return;
}
// Set up the appropriate render style
U32 prevRenderStyle = GFX->getCurrentRenderStyle();
Point2F prevProjectionOffset = GFX->getCurrentProjectionOffset();
Point3F prevEyeOffset = GFX->getStereoEyeOffset();
if(mRenderStyle == RenderStyleStereoSideBySide)
{
GFX->setCurrentRenderStyle(GFXDevice::RS_StereoSideBySide);
GFX->setCurrentProjectionOffset(mLastCameraQuery.projectionOffset);
GFX->setStereoEyeOffset(mLastCameraQuery.eyeOffset);
}
else
{
GFX->setCurrentRenderStyle(GFXDevice::RS_Standard);
}
if ( mReflectPriority > 0 )
{
// Get the total reflection priority.
@ -324,7 +356,9 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
// set up the camera and viewport stuff:
F32 wwidth;
F32 wheight;
F32 aspectRatio = F32(getWidth()) / F32(getHeight());
F32 renderWidth = (mRenderStyle == RenderStyleStereoSideBySide) ? F32(getWidth())*0.5f : F32(getWidth());
F32 renderHeight = F32(getHeight());
F32 aspectRatio = renderWidth / renderHeight;
// Use the FOV to calculate the viewport height scale
// then generate the width scale from the aspect ratio.
@ -339,16 +373,28 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
wwidth = aspectRatio * wheight;
}
F32 hscale = wwidth * 2.0f / F32(getWidth());
F32 vscale = wheight * 2.0f / F32(getHeight());
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);
F32 bottom = wheight - vscale * (updateRect.point.y + updateRect.extent.y - offset.y);
F32 hscale = wwidth * 2.0f / renderWidth;
F32 vscale = wheight * 2.0f / renderHeight;
Frustum frustum;
frustum.set( mLastCameraQuery.ortho, left, right, top, bottom, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane );
if(mRenderStyle == RenderStyleStereoSideBySide)
{
F32 left = 0.0f * hscale - wwidth;
F32 right = renderWidth * hscale - wwidth;
F32 top = wheight - vscale * 0.0f;
F32 bottom = wheight - vscale * renderHeight;
frustum.set( mLastCameraQuery.ortho, left, right, top, bottom, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane );
}
else
{
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);
F32 bottom = wheight - vscale * (updateRect.point.y + updateRect.extent.y - offset.y);
frustum.set( mLastCameraQuery.ortho, left, right, top, bottom, mLastCameraQuery.nearPlane, mLastCameraQuery.farPlane );
}
// Manipulate the frustum for tiled screenshots
const bool screenShotMode = gScreenShot && gScreenShot->isPending();
@ -412,6 +458,11 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
// we begin rendering the child controls.
saver.restore();
// Restore the render style and any stereo parameters
GFX->setCurrentRenderStyle(prevRenderStyle);
GFX->setCurrentProjectionOffset(prevProjectionOffset);
GFX->setStereoEyeOffset(prevEyeOffset);
// Allow subclasses to render 2D elements.
GFX->setClipRect(updateRect);
renderGui( offset, updateRect );
@ -488,7 +539,7 @@ DefineEngineMethod( GuiTSCtrl, getWorldToScreenScale, Point2F, (),,
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiTSCtrl, calculateViewDistance, float, ( float radius ),,
DefineEngineMethod( GuiTSCtrl, calculateViewDistance, F32, ( F32 radius ),,
"Given the camera's current FOV, get the distance from the camera's viewpoint at which the given radius will fit in the render area.\n"
"@param radius Radius in world-space units which should fit in the view.\n"
"@return The distance from the viewpoint at which the given radius would be fully visible." )

View file

@ -36,6 +36,8 @@ struct CameraQuery
F32 nearPlane;
F32 farPlane;
F32 fov;
Point2F projectionOffset;
Point3F eyeOffset;
bool ortho;
MatrixF cameraMatrix;
};
@ -45,12 +47,17 @@ class GuiTSCtrl : public GuiContainer
{
typedef GuiContainer Parent;
public:
enum RenderStyles {
RenderStyleStandard = 0,
RenderStyleStereoSideBySide = (1<<0),
};
protected:
static U32 smFrameCount;
F32 mCameraZRot;
F32 mForceFOV;
protected:
/// A list of GuiTSCtrl which are awake and
/// most likely rendering.
static Vector<GuiTSCtrl*> smAwakeTSCtrls;
@ -59,8 +66,11 @@ protected:
/// update timeslice for this viewport to get.
F32 mReflectPriority;
F32 mOrthoWidth;
F32 mOrthoHeight;
/// The current render type
U32 mRenderStyle;
F32 mOrthoWidth;
F32 mOrthoHeight;
MatrixF mSaveModelview;
MatrixF mSaveProjection;
@ -150,4 +160,8 @@ public:
DECLARE_DESCRIPTION( "Abstract base class for controls that render a 3D viewport." );
};
typedef GuiTSCtrl::RenderStyles GuiTSRenderStyles;
DefineEnumType( GuiTSRenderStyles );
#endif // _GUITSCONTROL_H_

View file

@ -29,6 +29,7 @@
#include "gui/core/guiCanvas.h"
#include "gui/core/guiDefaultControlRender.h"
#include "gfx/gfxDrawUtil.h"
#include "gfx/gfxTextureManager.h"
ImplementEnumType( GuiBitmapMode,
@ -327,7 +328,7 @@ void GuiBitmapButtonCtrl::setBitmap( const String& name )
if( i == 0 && mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull() )
{
Con::warnf( "GuiBitmapButtonCtrl::setBitmap - Unable to load texture: %s", mBitmapName.c_str() );
this->setBitmap( "core/art/unavailable" );
this->setBitmap( GFXTextureManager::getUnavailableTexturePath() );
return;
}
}
@ -372,7 +373,7 @@ void GuiBitmapButtonCtrl::setBitmapHandles(GFXTexHandle normal, GFXTexHandle hig
if (mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull())
{
Con::warnf("GuiBitmapButtonCtrl::setBitmapHandles() - Invalid texture handles");
setBitmap("core/art/unavailable");
setBitmap( GFXTextureManager::getUnavailableTexturePath() );
return;
}

View file

@ -230,7 +230,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
bool highlight = mMouseOver;
bool depressed = mDepressed;
ColorI fontColor = mActive ? (highlight ? mProfile->mFontColor : mProfile->mFontColor) : mProfile->mFontColorNA;
ColorI fontColor = mActive ? (highlight ? mProfile->mFontColorHL : mProfile->mFontColor) : mProfile->mFontColorNA;
RectI boundsRect(offset, getExtent());
@ -436,4 +436,4 @@ DefineEngineMethod( GuiIconButtonCtrl, setBitmap, void, (const char* buttonFilen
char* argBuffer = Con::getArgBuffer( 512 );
Platform::makeFullPathName( buttonFilename, argBuffer, 512 );
object->setBitmap( argBuffer );
}
}

View file

@ -39,9 +39,9 @@ ConsoleDocClass( GuiSwatchButtonCtrl,
"A swatch button is a push button that uses its color field to designate the color drawn over an image, on top of a button.\n\n"
"The color itself is a float value stored inside the GuiSwatchButtonCtrl::color field. The texture path that represents\n"
"the image underlying the color is stored inside the GuiSwatchButtonCtrl::bitmap field.\n"
"the image underlying the color is stored inside the GuiSwatchButtonCtrl::gridBitmap field.\n"
"The default value assigned toGuiSwatchButtonCtrl::color is \"1 1 1 1\"( White ). The default/fallback image assigned to \n"
"GuiSwatchButtonCtrl::bitmap is \"core/art/gui/images/transp_grid\".\n\n"
"GuiSwatchButtonCtrl::gridBitmap is \"tools/gui/images/transp_grid\".\n\n"
"@tsexample\n"
"// Create a GuiSwatchButtonCtrl that calls randomFunction with its current color when clicked\n"
@ -65,11 +65,15 @@ GuiSwatchButtonCtrl::GuiSwatchButtonCtrl()
static StringTableEntry sProfile = StringTable->insert( "profile" );
setDataField( sProfile, NULL, "GuiInspectorSwatchButtonProfile" );
mGridBitmap = "tools/gui/images/transp_grid";
}
void GuiSwatchButtonCtrl::initPersistFields()
{
addField( "color", TypeColorF, Offset( mSwatchColor, GuiSwatchButtonCtrl ), "The foreground color of GuiSwatchButtonCtrl" );
addField( "gridBitmap", TypeString, Offset( mGridBitmap, GuiSwatchButtonCtrl ), "The bitmap used for the transparent grid" );
Parent::initPersistFields();
}
@ -80,7 +84,7 @@ bool GuiSwatchButtonCtrl::onWake()
return false;
if ( mGrid.isNull() )
mGrid.set( "core/art/gui/images/transp_grid", &GFXDefaultGUIProfile, avar("%s() - mGrid (line %d)", __FUNCTION__, __LINE__) );
mGrid.set( mGridBitmap, &GFXDefaultGUIProfile, avar("%s() - mGrid (line %d)", __FUNCTION__, __LINE__) );
return true;
}

View file

@ -41,6 +41,9 @@ class GuiSwatchButtonCtrl : public GuiButtonBaseCtrl
/// The color to display on the button.
ColorF mSwatchColor;
/// Bitmap used for mGrid
String mGridBitmap;
/// Background texture that will show through with transparent colors.
GFXTexHandle mGrid;

View file

@ -26,7 +26,6 @@
#include "console/engineAPI.h"
#include "console/console.h"
#include "gfx/bitmap/gBitmap.h"
#include "platform/event.h"
#include "gui/core/guiDefaultControlRender.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"

View file

@ -1478,7 +1478,7 @@ void GuiWindowCtrl::positionButtons(void)
// Until a pref, if alignment is LEFT, put buttons RIGHT justified.
// ELSE, put buttons LEFT justified.
int closeLeft = mainOff.x, closeTop = mainOff.y, closeOff = buttonWidth + 2;
S32 closeLeft = mainOff.x, closeTop = mainOff.y, closeOff = buttonWidth + 2;
if ( mProfile->mAlignment == GuiControlProfile::LeftJustify )
{
closeOff = -closeOff;

View file

@ -178,13 +178,13 @@ void GuiBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
GFXTextureObject* texture = mTextureObject;
RectI srcRegion;
RectI dstRegion;
float xdone = ((float)getExtent().x/(float)texture->mBitmapSize.x)+1;
float ydone = ((float)getExtent().y/(float)texture->mBitmapSize.y)+1;
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
F32 ydone = ((F32)getExtent().y/(F32)texture->mBitmapSize.y)+1;
int xshift = mStartPoint.x%texture->mBitmapSize.x;
int yshift = mStartPoint.y%texture->mBitmapSize.y;
for(int y = 0; y < ydone; ++y)
for(int x = 0; x < xdone; ++x)
S32 xshift = mStartPoint.x%texture->mBitmapSize.x;
S32 yshift = mStartPoint.y%texture->mBitmapSize.y;
for(S32 y = 0; y < ydone; ++y)
for(S32 x = 0; x < xdone; ++x)
{
srcRegion.set(0,0,texture->mBitmapSize.x,texture->mBitmapSize.y);
dstRegion.set( ((texture->mBitmapSize.x*x)+offset.x)-xshift,

View file

@ -528,10 +528,11 @@ void GuiColorPickerCtrl::setScriptValue(const char *value)
ConsoleMethod(GuiColorPickerCtrl, getSelectorPos, const char*, 2, 2, "Gets the current position of the selector")
{
char *temp = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char *temp = Con::getReturnBuffer(bufSize);
Point2I pos;
pos = object->getSelectorPos();
dSprintf(temp,256,"%d %d",pos.x, pos.y);
dSprintf(temp,bufSize,"%d %d",pos.x, pos.y);
return temp;
}

View file

@ -169,17 +169,18 @@ DefineEngineMethod( GuiDirectoryFileListCtrl, getSelectedFiles, const char*, (),
return StringTable->insert( "" );
// Get an adequate buffer
char itemBuffer[256];
dMemset( itemBuffer, 0, 256 );
static const U32 itemBufSize = 256;
char itemBuffer[itemBufSize];
char* returnBuffer = Con::getReturnBuffer( ItemVector.size() * 64 );
dMemset( returnBuffer, 0, ItemVector.size() * 64 );
static const U32 bufSize = ItemVector.size() * 64;
char* returnBuffer = Con::getReturnBuffer( bufSize );
dMemset( returnBuffer, 0, bufSize );
// Fetch the first entry
StringTableEntry itemText = object->getItemText( ItemVector[0] );
if( !itemText )
return StringTable->lookup("");
dSprintf( returnBuffer, ItemVector.size() * 64, "%s", itemText );
dSprintf( returnBuffer, bufSize, "%s", itemText );
// If only one entry, return it.
if( ItemVector.size() == 1 )
@ -192,8 +193,8 @@ DefineEngineMethod( GuiDirectoryFileListCtrl, getSelectedFiles, const char*, (),
if( !itemText )
continue;
dMemset( itemBuffer, 0, 256 );
dSprintf( itemBuffer, 256, " %s", itemText );
dMemset( itemBuffer, 0, itemBufSize );
dSprintf( itemBuffer, itemBufSize, " %s", itemText );
dStrcat( returnBuffer, itemBuffer );
}

View file

@ -260,7 +260,7 @@ bool GuiFileTreeCtrl::matchesFilters(const char* filename)
if( !mFilters.size() )
return true;
for(int i = 0; i < mFilters.size(); i++)
for(S32 i = 0; i < mFilters.size(); i++)
{
if(FindMatch::isMatch( mFilters[i], filename))
return true;

View file

@ -736,7 +736,7 @@ bool GuiGameListMenuProfile::onAdd()
// We can't call enforceConstraints() here because incRefCount initializes
// some of the things to enforce. Do a basic sanity check here instead.
if( !dStrlen(mBitmapName) )
if( !mBitmapName || !dStrlen(mBitmapName) )
{
Con::errorf( "GuiGameListMenuProfile: %s can't be created without a bitmap. Please add a 'Bitmap' property to the object definition.", getName() );
return false;

View file

@ -213,7 +213,7 @@ void GuiGameListOptionsCtrl::addRow(const char* label, const char* optionsList,
Row * row = new Row();
Vector<StringTableEntry> options( __FILE__, __LINE__ );
S32 count = StringUnit::getUnitCount(optionsList, DELIM);
for (int i = 0; i < count; ++i)
for (S32 i = 0; i < count; ++i)
{
const char * option = StringUnit::getUnit(optionsList, i, DELIM);
options.push_back(StringTable->insert(option, true));
@ -238,7 +238,7 @@ void GuiGameListOptionsCtrl::setOptions(S32 rowIndex, const char * optionsList)
S32 count = StringUnit::getUnitCount(optionsList, DELIM);
row->mOptions.setSize(count);
for (int i = 0; i < count; ++i)
for (S32 i = 0; i < count; ++i)
{
const char * option = StringUnit::getUnit(optionsList, i, DELIM);
row->mOptions[i] = StringTable->insert(option, true);

View file

@ -89,11 +89,9 @@ bool GuiGradientSwatchCtrl::onWake()
if ( !Parent::onWake() )
return false;
if ( mPointer.isNull() )
mPointer.set( "core/art/gui/images/arrowbtn_d", &GFXDefaultGUIProfile, avar("%s() - mGrid (line %d)", __FUNCTION__, __LINE__) );
char* altCommand = Con::getReturnBuffer(512);
dSprintf( altCommand, 512, "%s(%i.color, \"%i.setColor\");", mColorFunction, getId(), getId() );
static const U32 bufSize = 512;
char* altCommand = Con::getReturnBuffer(bufSize);
dSprintf( altCommand, bufSize, "%s(%i.color, \"%i.setColor\");", mColorFunction, getId(), getId() );
setField( "altCommand", altCommand );
return true;
@ -619,10 +617,11 @@ ConsoleMethod(GuiGradientCtrl, getColor, const char*, 3, 3, "Get color value")
{
if ( idx >= 0 && idx < object->mColorRange.size() )
{
char* rColor = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* rColor = Con::getReturnBuffer(bufSize);
rColor[0] = 0;
dSprintf(rColor, 256, "%f %f %f %f",
dSprintf(rColor, bufSize, "%f %f %f %f",
object->mColorRange[idx].swatch->getColor().red,
object->mColorRange[idx].swatch->getColor().green,
object->mColorRange[idx].swatch->getColor().blue,
@ -635,10 +634,11 @@ ConsoleMethod(GuiGradientCtrl, getColor, const char*, 3, 3, "Get color value")
{
if ( idx >= 0 && idx < object->mAlphaRange.size() )
{
char* rColor = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* rColor = Con::getReturnBuffer(bufSize);
rColor[0] = 0;
dSprintf(rColor, 256, "%f %f %f %f",
dSprintf(rColor, bufSize, "%f %f %f %f",
object->mAlphaRange[idx].swatch->getColor().red,
object->mAlphaRange[idx].swatch->getColor().green,
object->mAlphaRange[idx].swatch->getColor().blue,

View file

@ -48,7 +48,6 @@ public:
void onRender(Point2I offset, const RectI &updateRect);
bool onWake();
protected:
GFXTexHandle mPointer;
StringTableEntry mColorFunction;
};
//----------------------------

View file

@ -450,8 +450,9 @@ DefineEngineMethod( GuiListBoxCtrl, getSelectedItems, const char*, (),,
if( selItems.empty() )
return StringTable->lookup("-1");
UTF8 *retBuffer = Con::getReturnBuffer( selItems.size() * 4 );
dMemset( retBuffer, 0, selItems.size() * 4 );
static const U32 bufSize = selItems.size() * 4;
UTF8 *retBuffer = Con::getReturnBuffer( bufSize );
dMemset( retBuffer, 0, bufSize );
Vector<S32>::iterator i = selItems.begin();
for( ; i != selItems.end(); i++ )
{

View file

@ -91,7 +91,7 @@ GFX_ImplementTextureProfile(GFXMLTextureProfile,
GFXTextureProfile::DiffuseMap,
GFXTextureProfile::PreserveSize |
GFXTextureProfile::Static,
GFXTextureProfile::None);
GFXTextureProfile::NONE);
const U32 GuiMLTextCtrl::csmTextBufferGrowthSize = 1024;
@ -121,10 +121,10 @@ DefineEngineMethod( GuiMLTextCtrl, getText, const char*, (),,
return( object->getTextContent() );
}
DefineEngineMethod( GuiMLTextCtrl, addText, void, ( const char* text, bool reformat),,
DefineEngineMethod( GuiMLTextCtrl, addText, void, ( const char* text, bool reformat), (true),
"@brief Appends the text in the control with additional text. Also .\n\n"
"@param text New text to append to the existing text.\n"
"@param reformat If true, the control will also be visually reset.\n"
"@param reformat If true, the control will also be visually reset (defaults to true).\n"
"@tsexample\n"
"// Define new text to add\n"
"%text = \"New Text to Add\";\n\n"
@ -138,7 +138,7 @@ DefineEngineMethod( GuiMLTextCtrl, addText, void, ( const char* text, bool refor
object->addText(text, dStrlen(text), reformat);
}
DefineEngineMethod( GuiMLTextCtrl, setCursorPosition, bool, (int newPos),,
DefineEngineMethod( GuiMLTextCtrl, setCursorPosition, bool, (S32 newPos),,
"@brief Change the text cursor's position to a new defined offset within the text in the control.\n\n"
"@param newPos Offset to place cursor.\n"
"@tsexample\n"
@ -153,7 +153,7 @@ DefineEngineMethod( GuiMLTextCtrl, setCursorPosition, bool, (int newPos),,
return object->setCursorPosition(newPos);
}
DefineEngineMethod( GuiMLTextCtrl, scrollToTag, void, (int tagID),,
DefineEngineMethod( GuiMLTextCtrl, scrollToTag, void, (S32 tagID),,
"@brief Scroll down to a specified tag.\n\n"
"Detailed description\n\n"
"@param tagID TagID to scroll the control to\n"

View file

@ -24,7 +24,6 @@
#include "gui/containers/guiScrollCtrl.h"
#include "gui/core/guiCanvas.h"
#include "console/consoleTypes.h"
#include "platform/event.h"
#include "core/frameAllocator.h"
#include "core/stringBuffer.h"
#include "gfx/gfxDrawUtil.h"

View file

@ -1011,8 +1011,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - mBitmapBounds[2].extent.x - txt_w;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - bitmapBounds[2].extent.x - txt_w;
}
else
{
@ -1024,8 +1024,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = (getWidth() - mBitmapBounds[2].extent.x - txt_w) / 2;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = (getWidth() - bitmapBounds[2].extent.x - txt_w) / 2;
} else
{
@ -1043,8 +1043,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - mBitmapBounds[2].extent.x - txt_w;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - bitmapBounds[2].extent.x - txt_w;
}
else
{
@ -1095,8 +1095,8 @@ void GuiPopUpMenuCtrl::onRender( Point2I offset, const RectI &updateRect )
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - mBitmapBounds[2].extent.x, localStart.y ) );
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 );
} else

View file

@ -579,8 +579,9 @@ ConsoleMethod( GuiPopUpMenuCtrlEx, getColorById, const char*, 3, 3,
ColorI color;
object->getColoredBox(color, dAtoi(argv[2]));
char *strBuffer = Con::getReturnBuffer(512);
dSprintf(strBuffer, 512, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
static const U32 bufSize = 512;
char *strBuffer = Con::getReturnBuffer(bufSize);
dSprintf(strBuffer, bufSize, "%d %d %d %d", color.red, color.green, color.blue, color.alpha);
return strBuffer;
}
@ -1167,8 +1168,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - mBitmapBounds[2].extent.x - txt_w;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - bitmapBounds[2].extent.x - txt_w;
}
else
{
@ -1180,8 +1181,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = (getWidth() - mBitmapBounds[2].extent.x - txt_w) / 2;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = (getWidth() - bitmapBounds[2].extent.x - txt_w) / 2;
} else
{
@ -1199,8 +1200,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - mBitmapBounds[2].extent.x - txt_w;
RectI* bitmapBounds = mProfile->mBitmapArrayRects.address();
localStart.x = getWidth() - bitmapBounds[2].extent.x - txt_w;
}
else
{
@ -1251,8 +1252,8 @@ void GuiPopUpMenuCtrlEx::onRender(Point2I offset, const RectI &updateRect)
{
// We're making use of a bitmap border, so take into account the
// right cap of the border.
RectI* mBitmapBounds = mProfile->mBitmapArrayRects.address();
Point2I textpos = localToGlobalCoord( Point2I( getWidth() - txt_w - mBitmapBounds[2].extent.x, localStart.y ) );
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 );
} else

View file

@ -26,7 +26,6 @@
#include "gfx/gfxTextureManager.h"
#include "gui/controls/guiSliderCtrl.h"
#include "gui/core/guiDefaultControlRender.h"
#include "platform/event.h"
#include "gfx/primBuilder.h"
#include "gfx/gfxDrawUtil.h"
#include "sfx/sfxSystem.h"

View file

@ -1688,7 +1688,7 @@ DefineEngineMethod( GuiTextEditCtrl, getCursorPos, S32, (),,
return( object->getCursorPos() );
}
DefineEngineMethod( GuiTextEditCtrl, setCursorPos, void, (int position),,
DefineEngineMethod( GuiTextEditCtrl, setCursorPos, void, (S32 position),,
"@brief Sets the text cursor at the defined position within the control.\n\n"
"@param position Text position to set the text cursor.\n"
"@tsexample\n"

View file

@ -79,12 +79,12 @@ IMPLEMENT_CALLBACK( GuiTextListCtrl, onDeleteKey, void, ( const char* id ),( id
"@see GuiControl\n\n"
);
static int sortColumn;
static S32 sortColumn;
static bool sIncreasing;
static const char *getColumn(const char *text)
{
int ct = sortColumn;
S32 ct = sortColumn;
while(ct--)
{
text = dStrchr(text, '\t');
@ -530,7 +530,7 @@ DefineEngineMethod( GuiTextListCtrl, getSelectedId, S32, (),,
return object->getSelectedId();
}
DefineEngineMethod( GuiTextListCtrl, setSelectedById, void, (int id),,
DefineEngineMethod( GuiTextListCtrl, setSelectedById, void, (S32 id),,
"@brief Finds the specified entry by id, then marks its row as selected.\n\n"
"@param id Entry within the text list to make selected.\n"
"@tsexample\n"
@ -548,7 +548,7 @@ DefineEngineMethod( GuiTextListCtrl, setSelectedById, void, (int id),,
object->setSelectedCell(Point2I(0, index));
}
DefineEngineMethod( GuiTextListCtrl, setSelectedRow, void, (int rowNum),,
DefineEngineMethod( GuiTextListCtrl, setSelectedRow, void, (S32 rowNum),,
"@briefSelects the specified row.\n\n"
"@param rowNum Row number to set selected.\n"
"@tsexample\n"
@ -584,7 +584,7 @@ DefineEngineMethod( GuiTextListCtrl, clearSelection, void, (),,
object->setSelectedCell(Point2I(-1, -1));
}
DefineEngineMethod( GuiTextListCtrl, addRow, S32, (int id, const char* text, int index),(0,"",-1),
DefineEngineMethod( GuiTextListCtrl, addRow, S32, (S32 id, const char* text, S32 index),(0,"",-1),
"@brief Adds a new row at end of the list with the defined id and text.\n"
"If index is used, then the new row is inserted at the row location of 'index'.\n\n"
"@param id Id of the new row.\n"
@ -612,7 +612,7 @@ DefineEngineMethod( GuiTextListCtrl, addRow, S32, (int id, const char* text, int
return ret;
}
DefineEngineMethod( GuiTextListCtrl, setRowById, void, (int id, const char* text),,
DefineEngineMethod( GuiTextListCtrl, setRowById, void, (S32 id, const char* text),,
"@brief Sets the text at the defined id.\n\n"
"@param id Id to change.\n"
"@param text Text to use at the Id.\n"
@ -629,7 +629,7 @@ DefineEngineMethod( GuiTextListCtrl, setRowById, void, (int id, const char* text
object->setEntry(id, text);
}
DefineEngineMethod( GuiTextListCtrl, sort, void, ( int columnId, bool increasing ), ( true ),
DefineEngineMethod( GuiTextListCtrl, sort, void, ( S32 columnId, bool increasing ), ( true ),
"@brief Performs a standard (alphabetical) sort on the values in the specified column.\n\n"
"@param columnId Column ID to perform the sort on.\n"
"@param increasing If false, sort will be performed in reverse.\n"
@ -646,7 +646,7 @@ DefineEngineMethod( GuiTextListCtrl, sort, void, ( int columnId, bool increasing
object->sort( columnId, increasing );
}
DefineEngineMethod( GuiTextListCtrl, sortNumerical, void, (int columnID, bool increasing), ( true ),
DefineEngineMethod( GuiTextListCtrl, sortNumerical, void, (S32 columnID, bool increasing), ( true ),
"@brief Perform a numerical sort on the values in the specified column.\n\n"
"Detailed description\n\n"
"@param columnId Column ID to perform the sort on.\n"
@ -687,7 +687,7 @@ DefineEngineMethod( GuiTextListCtrl, rowCount, S32, (),,
return object->getNumEntries();
}
DefineEngineMethod( GuiTextListCtrl, getRowId, S32, (int index),,
DefineEngineMethod( GuiTextListCtrl, getRowId, S32, (S32 index),,
"@brief Get the row ID for an index.\n\n"
"@param index Index to get the RowID at\n"
"@tsexample\n"
@ -705,7 +705,7 @@ DefineEngineMethod( GuiTextListCtrl, getRowId, S32, (int index),,
return object->mList[index].id;
}
DefineEngineMethod( GuiTextListCtrl, getRowTextById, const char*, (int id),,
DefineEngineMethod( GuiTextListCtrl, getRowTextById, const char*, (S32 id),,
"@brief Get the text of a row with the specified id.\n\n"
"@tsexample\n"
"// Define the id\n"
@ -722,7 +722,7 @@ DefineEngineMethod( GuiTextListCtrl, getRowTextById, const char*, (int id),,
return object->mList[index].text;
}
DefineEngineMethod( GuiTextListCtrl, getRowNumById, S32, (int id),,
DefineEngineMethod( GuiTextListCtrl, getRowNumById, S32, (S32 id),,
"@brief Get the row number for a specified id.\n\n"
"@param id Id to get the row number at\n"
"@tsexample\n"
@ -739,7 +739,7 @@ DefineEngineMethod( GuiTextListCtrl, getRowNumById, S32, (int id),,
return index;
}
DefineEngineMethod( GuiTextListCtrl, getRowText, const char*, (int index),,
DefineEngineMethod( GuiTextListCtrl, getRowText, const char*, (S32 index),,
"@brief Get the text of the row with the specified index.\n\n"
"@param index Row index to acquire the text at.\n"
"@tsexample\n"
@ -756,7 +756,7 @@ DefineEngineMethod( GuiTextListCtrl, getRowText, const char*, (int index),,
return object->mList[index].text;
}
DefineEngineMethod( GuiTextListCtrl, removeRowById, void, (int id),,
DefineEngineMethod( GuiTextListCtrl, removeRowById, void, (S32 id),,
"@brief Remove row with the specified id.\n\n"
"@param id Id to remove the row entry at\n"
"@tsexample\n"
@ -770,7 +770,7 @@ DefineEngineMethod( GuiTextListCtrl, removeRowById, void, (int id),,
object->removeEntry(id);
}
DefineEngineMethod( GuiTextListCtrl, removeRow, void, (int index),,
DefineEngineMethod( GuiTextListCtrl, removeRow, void, (S32 index),,
"@brief Remove a row from the table, based on its index.\n\n"
"@param index Row index to remove from the list.\n"
"@tsexample\n"
@ -784,7 +784,7 @@ DefineEngineMethod( GuiTextListCtrl, removeRow, void, (int index),,
object->removeEntryByIndex(index);
}
DefineEngineMethod( GuiTextListCtrl, scrollVisible, void, (int rowNum),,
DefineEngineMethod( GuiTextListCtrl, scrollVisible, void, (S32 rowNum),,
"@brief Scroll so the specified row is visible\n\n"
"@param rowNum Row number to make visible\n"
"@tsexample\n"
@ -813,7 +813,7 @@ DefineEngineMethod( GuiTextListCtrl, findTextIndex, S32, (const char* needle),,
return( object->findEntryByText(needle) );
}
DefineEngineMethod( GuiTextListCtrl, setRowActive, void, (int rowNum, bool active),,
DefineEngineMethod( GuiTextListCtrl, setRowActive, void, (S32 rowNum, bool active),,
"@brief Mark a specified row as active/not.\n\n"
"@param rowNum Row number to change the active state.\n"
"@param active Boolean active state to set the row number.\n"
@ -830,7 +830,7 @@ DefineEngineMethod( GuiTextListCtrl, setRowActive, void, (int rowNum, bool activ
object->setEntryActive( U32( rowNum ), active );
}
DefineEngineMethod( GuiTextListCtrl, isRowActive, bool, (int rowNum),,
DefineEngineMethod( GuiTextListCtrl, isRowActive, bool, (S32 rowNum),,
"@brief Check if the specified row is currently active or not.\n\n"
"@param rowNum Row number to check the active state.\n"
"@tsexample\n"

View file

@ -30,7 +30,6 @@
#include "console/consoleTypes.h"
#include "console/console.h"
#include "gui/core/guiTypes.h"
#include "platform/event.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/controls/guiTextEditCtrl.h"
#ifdef TORQUE_TOOLS
@ -3438,6 +3437,8 @@ void GuiTreeViewCtrl::onMouseUp(const GuiEvent &event)
scrollVisible(newItem);
onDragDropped_callback();
buildVisibleTree(false);
}
mDragMidPoint = NomDragMidPoint;
@ -3582,7 +3583,7 @@ void GuiTreeViewCtrl::onMiddleMouseDown(const GuiEvent & event)
for (S32 j = 0; j < mSelected.size(); j++) {
Con::printf("%d", mSelected[j]);
}
S32 mCurrentDragCell = mMouseOverCell.y;
mCurrentDragCell = mMouseOverCell.y;
S32 midpCell = (mCurrentDragCell) * mItemHeight + (mItemHeight/2);
S32 currentY = pt.y;
S32 yDiff = currentY-midpCell;
@ -3647,7 +3648,7 @@ void GuiTreeViewCtrl::onMouseDown(const GuiEvent & event)
break;
}
}
S32 mCurrentDragCell = mMouseOverCell.y;
mCurrentDragCell = mMouseOverCell.y;
if (mVisibleItems[firstSelectedIndex] != firstItem )
{
/*
@ -4919,7 +4920,7 @@ ConsoleMethod( GuiTreeViewCtrl, open, void, 3, 4, "(SimSet obj, bool okToEdit=tr
ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string text ) - Set the tooltip to show for the given item." )
{
int id = dAtoi( argv[ 2 ] );
S32 id = dAtoi( argv[ 2 ] );
GuiTreeViewCtrl::Item* item = object->getItem( id );
if( !item )
@ -4933,7 +4934,7 @@ ConsoleMethod( GuiTreeViewCtrl, setItemTooltip, void, 4, 4, "( int id, string te
ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normalImage, int expandedImage ) - Sets the normal and expanded images to show for the given item." )
{
int id = dAtoi( argv[ 2 ] );
S32 id = dAtoi( argv[ 2 ] );
GuiTreeViewCtrl::Item* item = object->getItem( id );
if( !item )
@ -4948,7 +4949,7 @@ ConsoleMethod( GuiTreeViewCtrl, setItemImages, void, 5, 5, "( int id, int normal
ConsoleMethod( GuiTreeViewCtrl, isParentItem, bool, 3, 3, "( int id ) - Returns true if the given item contains child items." )
{
int id = dAtoi( argv[ 2 ] );
S32 id = dAtoi( argv[ 2 ] );
if( !id && object->getItemCount() )
return true;
@ -5060,11 +5061,12 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObject, S32, 2, 3, "( int index=0 ) -
ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2,
"Returns a space sperated list of all selected object ids.")
{
char* buff = Con::getReturnBuffer(1024);
dSprintf(buff,1024,"");
static const U32 bufSize = 1024;
char* buff = Con::getReturnBuffer(bufSize);
dSprintf(buff,bufSize,"");
const Vector< GuiTreeViewCtrl::Item* > selectedItems = object->getSelectedItems();
for(int i = 0; i < selectedItems.size(); i++)
for(S32 i = 0; i < selectedItems.size(); i++)
{
GuiTreeViewCtrl::Item *item = selectedItems[i];
@ -5076,7 +5078,7 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedObjectList, const char*, 2, 2,
//the start of the buffer where we want to write
char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = 1024-len-1;
S32 size = bufSize-len-1;
//write it:
if(size < 1)
{
@ -5125,11 +5127,12 @@ ConsoleMethod(GuiTreeViewCtrl, getTextToRoot, const char*,4,4,"(TreeItemId item,
ConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, 2,2,"returns a space seperated list of mulitple item ids")
{
char* buff = Con::getReturnBuffer(1024);
dSprintf(buff,1024,"");
static const U32 bufSize = 1024;
char* buff = Con::getReturnBuffer(bufSize);
dSprintf(buff,bufSize,"");
const Vector< S32 >& selected = object->getSelected();
for(int i = 0; i < selected.size(); i++)
for(S32 i = 0; i < selected.size(); i++)
{
S32 id = selected[i];
//get the current length of the buffer
@ -5137,7 +5140,7 @@ ConsoleMethod(GuiTreeViewCtrl, getSelectedItemList,const char*, 2,2,"returns a s
//the start of the buffer where we want to write
char* buffPart = buff+len;
//the size of the remaining buffer (-1 cause dStrlen doesn't count the \0)
S32 size = 1024-len-1;
S32 size = bufSize-len-1;
//write it:
if(size < 1)
{

View file

@ -25,7 +25,6 @@
#include "console/console.h"
#include "console/engineAPI.h"
#include "platform/event.h"
#include "gui/containers/guiScrollCtrl.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiDefaultControlRender.h"

View file

@ -26,7 +26,6 @@
#include "console/console.h"
#include "console/engineAPI.h"
#include "platform/profiler.h"
#include "platform/event.h"
#include "gfx/gfxDevice.h"
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiTypes.h"
@ -122,7 +121,8 @@ GuiCanvas::GuiCanvas(): GuiControl(),
mMiddleMouseLast(false),
mRightMouseLast(false),
mPlatformWindow(NULL),
mLastRenderMs(0)
mLastRenderMs(0),
mDisplayWindow(true)
{
setBounds(0, 0, 640, 480);
mAwake = true;
@ -177,6 +177,8 @@ void GuiCanvas::initPersistFields()
addGroup("Canvas Rendering");
addProtectedField( "numFences", TypeS32, Offset( mNumFences, GuiCanvas ), &setProtectedNumFences, &defaultProtectedGetFn, "The number of GFX fences to use." );
addField("displayWindow", TypeBool, Offset(mDisplayWindow, GuiCanvas), "Controls if the canvas window is rendered or not." );
endGroup("Canvas Rendering");
Parent::initPersistFields();
@ -253,6 +255,19 @@ bool GuiCanvas::onAdd()
// Make sure we're able to render.
newDevice->setAllowRender( true );
if(mDisplayWindow)
{
getPlatformWindow()->show();
WindowManager->setDisplayWindow(true);
getPlatformWindow()->setDisplayWindow(true);
}
else
{
getPlatformWindow()->hide();
WindowManager->setDisplayWindow(false);
getPlatformWindow()->setDisplayWindow(false);
}
// Propagate add to parents.
// CodeReview - if GuiCanvas fails to add for whatever reason, what happens to
// all the event registration above?
@ -1562,7 +1577,7 @@ void GuiCanvas::setupFences()
mFences = new GFXFence*[mNumFences];
// Allocate the new fences
for( int i = 0; i < mNumFences; i++ )
for( S32 i = 0; i < mNumFences; i++ )
mFences[i] = GFX->createFence();
}
@ -2315,6 +2330,40 @@ DefineEngineMethod( GuiCanvas, setWindowTitle, void, ( const char* newTitle),,
}
DefineEngineMethod( GuiCanvas, findFirstMatchingMonitor, S32, (const char* name),,
"@brief Find the first monitor index that matches the given name.\n\n"
"The actual match algorithm depends on the implementation.\n"
"@param name The name to search for.\n\n"
"@return The number of monitors attached to the system, including the default monoitor.")
{
return PlatformWindowManager::get()->findFirstMatchingMonitor(name);
}
DefineEngineMethod( GuiCanvas, getMonitorCount, S32, (),,
"@brief Gets the number of monitors attached to the system.\n\n"
"@return The number of monitors attached to the system, including the default monoitor.")
{
return PlatformWindowManager::get()->getMonitorCount();
}
DefineEngineMethod( GuiCanvas, getMonitorName, const char*, (S32 index),,
"@brief Gets the name of the requested monitor.\n\n"
"@param index The monitor index.\n\n"
"@return The name of the requested monitor.")
{
return PlatformWindowManager::get()->getMonitorName(index);
}
DefineEngineMethod( GuiCanvas, getMonitorRect, RectI, (S32 index),,
"@brief Gets the region of the requested monitor.\n\n"
"@param index The monitor index.\n\n"
"@return The rectangular region of the requested monitor.")
{
return PlatformWindowManager::get()->getMonitorRect(index);
}
DefineEngineMethod( GuiCanvas, getVideoMode, const char*, (),,
"@brief Gets the current screen mode as a string.\n\n"
@ -2650,3 +2699,23 @@ ConsoleMethod( GuiCanvas, setVideoMode, void, 5, 8,
// Store the new mode into a pref.
Con::setVariable( "$pref::Video::mode", vm.toString() );
}
ConsoleMethod( GuiCanvas, showWindow, void, 2, 2, "" )
{
if (!object->getPlatformWindow())
return;
object->getPlatformWindow()->show();
WindowManager->setDisplayWindow(true);
object->getPlatformWindow()->setDisplayWindow(true);
}
ConsoleMethod( GuiCanvas, hideWindow, void, 2, 2, "" )
{
if (!object->getPlatformWindow())
return;
object->getPlatformWindow()->hide();
WindowManager->setDisplayWindow(false);
object->getPlatformWindow()->setDisplayWindow(false);
}

View file

@ -26,9 +26,6 @@
#ifndef _SIMBASE_H_
#include "console/simBase.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _GUICONTROL_H_
#include "gui/core/guiControl.h"
#endif
@ -111,6 +108,8 @@ protected:
bool mClampTorqueCursor;
bool mAlwaysHandleMouseButtons;
bool mDisplayWindow;
/// @}
/// @name Mouse Input

View file

@ -28,7 +28,6 @@
#include "console/consoleInternal.h"
#include "console/engineAPI.h"
#include "console/codeBlock.h"
#include "platform/event.h"
#include "gfx/bitmap/gBitmap.h"
#include "sim/actionMap.h"
#include "gui/core/guiCanvas.h"

View file

@ -38,9 +38,6 @@
#ifndef _GUITYPES_H_
#include "gui/core/guiTypes.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#ifndef _UTIL_DELEGATE_H_
#include "core/util/delegate.h"
#endif

View file

@ -63,13 +63,13 @@ GFX_ImplementTextureProfile(GFXGuiCursorProfile,
GFXTextureProfile::DiffuseMap,
GFXTextureProfile::PreserveSize |
GFXTextureProfile::Static,
GFXTextureProfile::None);
GFXTextureProfile::NONE);
GFX_ImplementTextureProfile(GFXDefaultGUIProfile,
GFXTextureProfile::DiffuseMap,
GFXTextureProfile::PreserveSize |
GFXTextureProfile::Static |
GFXTextureProfile::NoPadding,
GFXTextureProfile::None);
GFXTextureProfile::NONE);
GuiCursor::GuiCursor()
@ -719,8 +719,9 @@ ImplementConsoleTypeCasters( TypeRectSpacingI, RectSpacingI )
ConsoleGetType( TypeRectSpacingI )
{
RectSpacingI *rect = (RectSpacingI *) dptr;
char* returnBuffer = Con::getReturnBuffer(256);
dSprintf(returnBuffer, 256, "%d %d %d %d", rect->top, rect->bottom,
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
dSprintf(returnBuffer, bufSize, "%d %d %d %d", rect->top, rect->bottom,
rect->left, rect->right);
return returnBuffer;
}

View file

@ -38,7 +38,7 @@
#include "gfx/gfxDevice.h"
#include "platform/event.h"
#include "platform/input/event.h"
class GBitmap;
class SFXTrack;

View file

@ -78,8 +78,9 @@ ConsoleMethod(DbgFileView, getCurrentLine, const char *, 2, 2, "()"
{
S32 lineNum;
const char *file = object->getCurrentLine(lineNum);
char* ret = Con::getReturnBuffer(256);
dSprintf(ret, sizeof(ret), "%s\t%d", file, lineNum);
static const U32 bufSize = 256;
char* ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%s\t%d", file, lineNum);
return ret;
}

View file

@ -97,7 +97,7 @@ void GuiEaseViewCtrl::onRender(Point2I offset, const RectI &updateRect)
// Draw curve.
for( int i = 1; i <= numPoints; ++ i )
for( S32 i = 1; i <= numPoints; ++ i )
{
F32 x = ( F32 ) i / ( F32 ) numPoints;
F32 y = mEase.getValue( x, 0, 1, 1 );

View file

@ -274,7 +274,7 @@ void GuiGraphCtrl::addDatum(S32 plotID, F32 v)
//-----------------------------------------------------------------------------
float GuiGraphCtrl::getDatum( int plotID, int sample)
F32 GuiGraphCtrl::getDatum( S32 plotID, S32 sample)
{
AssertFatal(plotID > -1 && plotID < MaxPlots, "Invalid plot specified!");
AssertFatal(sample > -1 && sample < MaxDataPoints, "Invalid sample specified!");

View file

@ -182,7 +182,7 @@ DefineEngineMethod( GuiImageList, count, S32, (),,
return object->Count();
}
DefineEngineMethod( GuiImageList, remove, bool, (int index),,
DefineEngineMethod( GuiImageList, remove, bool, (S32 index),,
"@brief Removes an image from the list by index.\n\n"
"@param index Image index to remove.\n"
"@tsexample\n"

View file

@ -764,8 +764,7 @@ GuiControl* GuiInspectorTypeShapeFilename::constructEditControl()
// Change filespec
char szBuffer[512];
dSprintf( szBuffer, sizeof(szBuffer), "getLoadFilename(\"%s\", \"%d.apply\", %d.getData());",
"DTS Files (*.dts)|*.dts|COLLADA Files (*.dae)|*.dae|(All Files (*.*)|*.*|", getId(), getId() );
dSprintf( szBuffer, sizeof(szBuffer), "getLoadFormatFilename(\"%d.apply\", %d.getData());", getId(), getId() );
mBrowseButton->setField( "Command", szBuffer );
// Create "Open in ShapeEditor" button
@ -1538,7 +1537,7 @@ GuiControl* GuiInspectorTypeBitMask32Helper::constructEditControl()
mButton->setField( "Command", szBuffer );
mButton->setField( "buttonType", "ToggleButton" );
mButton->setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorButtonProfile" );
mButton->setBitmap( "core/art/gui/images/arrowBtn" );
mButton->setBitmap( "tools/gui/images/arrowBtn" );
mButton->setStateOn( true );
mButton->setExtent( 16, 16 );
mButton->registerObject();

View file

@ -193,7 +193,7 @@ DefineEngineMethod( GuiMenuBar, setMenuMargins, void, (S32 horizontalMargin, S32
object->mBitmapMargin = bitmapToTextSpacing;
}
DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, int menuId),,
DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, S32 menuId),,
"@brief Adds a new menu to the menu bar.\n\n"
"@param menuText Text to display for the new menu item.\n"
"@param menuId ID for the new menu item.\n"
@ -215,7 +215,7 @@ DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, int menuId)
object->addMenu(menuText, menuId);
}
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, int menuItemId, const char* accelerator, int checkGroup),
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup),
("","",0,NULL,-1),
"@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n"
"@param menu Menu name or menu Id to add the new item to.\n"
@ -496,7 +496,7 @@ DefineEngineMethod(GuiMenuBar, setMenuItemVisible, void, (const char* menuTarget
menuItem->visible = isVisible;
}
DefineEngineMethod(GuiMenuBar, setMenuItemBitmap, void, (const char* menuTarget, const char* menuItemTarget, int bitmapIndex),,
DefineEngineMethod(GuiMenuBar, setMenuItemBitmap, void, (const char* menuTarget, const char* menuItemTarget, S32 bitmapIndex),,
"@brief Sets the specified menu item bitmap index in the bitmap array. Setting the item's index to -1 will remove any bitmap.\n\n"
"@param menuTarget Menu to affect the menuItem in\n"
"@param menuItem Menu item to affect\n"

View file

@ -40,7 +40,7 @@ ConsoleDocClass( GuiParticleGraphCtrl,
GuiParticleGraphCtrl::GuiParticleGraphCtrl()
{
for(int i = 0; i < MaxPlots; i++)
for(S32 i = 0; i < MaxPlots; i++)
{
mPlots[i].mGraphColor = ColorF(1.0, 1.0, 1.0);
VECTOR_SET_ASSOCIATION(mPlots[i].mGraphData);
@ -140,7 +140,7 @@ void GuiParticleGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
ColorF color(1.0f, 1.0f, 1.0f, 0.5f);
pDrawUtil->drawRectFill(updateRect, color);
for (int k = 0; k < MaxPlots; k++)
for (S32 k = 0; k < MaxPlots; k++)
{
// Nothing to graph
if ((mPlots[k].mGraphData.size() == 0) || (mPlots[k].mHidden == true))
@ -1060,12 +1060,13 @@ ConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, const char*, 5, 6, "(int plotI
{
S32 plotID = dAtoi(argv[2]);
S32 pointAdded = 0;
char *retBuffer = Con::getReturnBuffer(32);
static const U32 bufSize = 32;
char *retBuffer = Con::getReturnBuffer(bufSize);
if(plotID > object->MaxPlots)
{
Con::errorf("Invalid plotID.");
dSprintf(retBuffer, 32, "%d", -2);
dSprintf(retBuffer, bufSize, "%d", -2);
return retBuffer;
}
@ -1078,7 +1079,7 @@ ConsoleMethod(GuiParticleGraphCtrl, addPlotPoint, const char*, 5, 6, "(int plotI
}
dSprintf(retBuffer, 32, "%d", pointAdded);
dSprintf(retBuffer, bufSize, "%d", pointAdded);
return retBuffer;
}
@ -1107,19 +1108,20 @@ ConsoleMethod(GuiParticleGraphCtrl, changePlotPoint, const char*, 6, 6, "(int pl
"@return No return value.")
{
S32 plotID = dAtoi(argv[2]);
static const U32 bufSize = 64;
if(plotID > object->MaxPlots)
{
Con::errorf("Invalid plotID.");
char *retBuffer = Con::getReturnBuffer(64);
char *retBuffer = Con::getReturnBuffer(bufSize);
const S32 index = -1;
dSprintf(retBuffer, 64, "%d", index);
dSprintf(retBuffer, bufSize, "%d", index);
return retBuffer;
}
char *retBuffer = Con::getReturnBuffer(64);
char *retBuffer = Con::getReturnBuffer(bufSize);
const S32 index = object->changePlotPoint( plotID, dAtoi(argv[3]), Point2F(dAtof(argv[4]), dAtof(argv[5])));
dSprintf(retBuffer, 64, "%d", index);
dSprintf(retBuffer, bufSize, "%d", index);
return retBuffer;
}
@ -1127,9 +1129,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getSelectedPlot, const char*, 2, 2, "() "
"Gets the selected Plot (a.k.a. graph).\n"
"@return The plot's ID.")
{
char *retBuffer = Con::getReturnBuffer(32);
static const U32 bufSize = 32;
char *retBuffer = Con::getReturnBuffer(bufSize);
const S32 plot = object->getSelectedPlot();
dSprintf(retBuffer, 32, "%d", plot);
dSprintf(retBuffer, bufSize, "%d", plot);
return retBuffer;
}
@ -1137,9 +1140,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getSelectedPoint, const char*, 2, 2, "()"
"Gets the selected Point on the Plot (a.k.a. graph)."
"@return The last selected point ID")
{
char *retBuffer = Con::getReturnBuffer(32);
static const U32 bufSize = 32;
char *retBuffer = Con::getReturnBuffer(bufSize);
const S32 point = object->getSelectedPoint();
dSprintf(retBuffer, 32, "%d", point);
dSprintf(retBuffer, bufSize, "%d", point);
return retBuffer;
}
@ -1158,9 +1162,10 @@ ConsoleMethod(GuiParticleGraphCtrl, isExistingPoint, const char*, 4, 4, "(int pl
Con::errorf("Invalid sample.");
}
char *retBuffer = Con::getReturnBuffer(32);
static const U32 bufSize = 32;
char *retBuffer = Con::getReturnBuffer(bufSize);
const bool isPoint = object->isExistingPoint(plotID, samples);
dSprintf(retBuffer, 32, "%d", isPoint);
dSprintf(retBuffer, bufSize, "%d", isPoint);
return retBuffer;
}
@ -1180,9 +1185,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getPlotPoint, const char*, 4, 4, "(int plotI
Con::errorf("Invalid sample.");
}
char *retBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char *retBuffer = Con::getReturnBuffer(bufSize);
const Point2F &pos = object->getPlotPoint(plotID, samples);
dSprintf(retBuffer, 64, "%f %f", pos.x, pos.y);
dSprintf(retBuffer, bufSize, "%f %f", pos.x, pos.y);
return retBuffer;
}
@ -1201,9 +1207,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getPlotIndex, const char*, 5, 5, "(int plotI
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(32);
static const U32 bufSize = 32;
char *retBuffer = Con::getReturnBuffer(bufSize);
const S32 &index = object->getPlotIndex(plotID, x, y);
dSprintf(retBuffer, 32, "%d", index);
dSprintf(retBuffer, bufSize, "%d", index);
return retBuffer;
}
@ -1218,9 +1225,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getGraphColor, const char*, 3, 3, "(int plot
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char *retBuffer = Con::getReturnBuffer(bufSize);
const ColorF &color = object->getGraphColor(plotID);
dSprintf(retBuffer, 64, "%f %f %f", color.red, color.green, color.blue);
dSprintf(retBuffer, bufSize, "%f %f %f", color.red, color.green, color.blue);
return retBuffer;
}
@ -1235,9 +1243,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getGraphMin, const char*, 3, 3, "(int plotID
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char *retBuffer = Con::getReturnBuffer(bufSize);
const Point2F graphMin = object->getGraphMin(plotID);
dSprintf(retBuffer, 64, "%f %f", graphMin.x, graphMin.y);
dSprintf(retBuffer, bufSize, "%f %f", graphMin.x, graphMin.y);
return retBuffer;
}
@ -1252,9 +1261,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getGraphMax, const char*, 3, 3, "(int plotID
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char *retBuffer = Con::getReturnBuffer(bufSize);
const Point2F graphMax = object->getGraphMax(plotID);
dSprintf(retBuffer, 64, "%f %f", graphMax.x, graphMax.y);
dSprintf(retBuffer, bufSize, "%f %f", graphMax.x, graphMax.y);
return retBuffer;
}
@ -1269,9 +1279,10 @@ ConsoleMethod(GuiParticleGraphCtrl, getGraphName, const char*, 3, 3, "(int plotI
Con::errorf("Invalid plotID.");
}
char *retBuffer = Con::getReturnBuffer(64);
static const U32 bufSize = 64;
char *retBuffer = Con::getReturnBuffer(bufSize);
const StringTableEntry graphName = object->getGraphName(plotID);
dSprintf(retBuffer, 64, "%s", graphName);
dSprintf(retBuffer, bufSize, "%s", graphName);
return retBuffer;
}

View file

@ -42,7 +42,7 @@
static const F32 sMoveScaler = 50.0f;
static const F32 sZoomScaler = 200.0f;
static const int sNodeRectSize = 16;
static const S32 sNodeRectSize = 16;
IMPLEMENT_CONOBJECT( GuiShapeEdPreview );

View file

@ -98,6 +98,9 @@ static S32 QSORT_CALLBACK compareEntries(const void* a,const void* b)
//-----------------------------------------------------------------------------
bool GuiInspectorDynamicGroup::inspectGroup()
{
if( !mParent )
return false;
// clear the first responder if it's set
mStack->clearFirstResponder();

View file

@ -58,7 +58,7 @@ GuiInspectorField::GuiInspectorField( GuiInspector* inspector,
setCanSave( false );
setBounds(0,0,100,18);
if( field )
if( field != NULL )
_setFieldDocs( field->pFieldDocs );
}
@ -378,8 +378,9 @@ void GuiInspectorField::setInspectorField( AbstractClassRep::Field *field, Strin
mCaption = getFieldName();
else
mCaption = caption;
_setFieldDocs( mField->pFieldDocs );
if ( mField != NULL )
_setFieldDocs( mField->pFieldDocs );
}
//-----------------------------------------------------------------------------
@ -454,7 +455,7 @@ void GuiInspectorField::setInspectorProfile()
{
GuiControlProfile *profile = NULL;
if( mInspector->getNumInspectObjects() > 1 )
if( mInspector && (mInspector->getNumInspectObjects() > 1) )
{
if( !hasSameValueInAllObjects() )
Sim::findObject( "GuiInspectorMultiFieldDifferentProfile", profile );

View file

@ -230,7 +230,7 @@ void GuiInspectorGroup::clearFields()
bool GuiInspectorGroup::inspectGroup()
{
// We can't inspect a group without a target!
if( !mParent->getNumInspectObjects() )
if( !mParent || !mParent->getNumInspectObjects() )
return false;
// to prevent crazy resizing, we'll just freeze our stack for a sec..

View file

@ -50,6 +50,12 @@ GuiInspectorVariableField::~GuiInspectorVariableField()
bool GuiInspectorVariableField::onAdd()
{
if( !mInspector )
{
Con::errorf("GuiInspectorVariableField::onAdd - Fail - No inspector");
return false;
}
setInspectorProfile();
// Hack: skip our immediate parent

View file

@ -123,13 +123,13 @@ public:
GFXTextureObject* texture = mTextureObject;
RectI srcRegion;
RectI dstRegion;
float xdone = ((float)getExtent().x/(float)texture->mBitmapSize.x)+1;
float ydone = ((float)getExtent().y/(float)texture->mBitmapSize.y)+1;
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
F32 ydone = ((F32)getExtent().y/(F32)texture->mBitmapSize.y)+1;
int xshift = mStartPoint.x%texture->mBitmapSize.x;
int yshift = mStartPoint.y%texture->mBitmapSize.y;
for(int y = 0; y < ydone; ++y)
for(int x = 0; x < xdone; ++x)
S32 xshift = mStartPoint.x%texture->mBitmapSize.x;
S32 yshift = mStartPoint.y%texture->mBitmapSize.y;
for(S32 y = 0; y < ydone; ++y)
for(S32 x = 0; x < xdone; ++x)
{
srcRegion.set(0,0,texture->mBitmapSize.x,texture->mBitmapSize.y);
dstRegion.set( ((texture->mBitmapSize.x*x)+offset.x)-xshift,

View file

@ -158,8 +158,9 @@ void GuiProgressBitmapCtrl::setBitmap( const char* name )
const char* GuiProgressBitmapCtrl::getScriptValue()
{
char * ret = Con::getReturnBuffer(64);
dSprintf(ret, 64, "%g", mProgress);
static const U32 bufSize = 64;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%g", mProgress);
return ret;
}

View file

@ -59,8 +59,9 @@ GuiProgressCtrl::GuiProgressCtrl()
const char* GuiProgressCtrl::getScriptValue()
{
char * ret = Con::getReturnBuffer(64);
dSprintf(ret, 64, "%g", mProgress);
static const U32 bufSize = 64;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%g", mProgress);
return ret;
}

View file

@ -26,9 +26,6 @@
#ifndef _GUIMOUSEEVENTCTRL_H_
#include "gui/utility/guiMouseEventCtrl.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
/// A control that locks the mouse and reports all keyboard input events

View file

@ -26,9 +26,6 @@
#ifndef _GUICONTROL_H_
#include "gui/core/guiControl.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
class GuiMouseEventCtrl : public GuiControl

View file

@ -1298,7 +1298,7 @@ DefineEngineMethod( EditTSCtrl, renderCircle, void, ( Point3F pos, Point3F norma
PrimBuild::begin( GFXLineStrip, points.size() + 1 );
for( int i = 0; i < points.size(); i++ )
for( S32 i = 0; i < points.size(); i++ )
PrimBuild::vertex3fv( points[i] );
// GFX does not have a LineLoop primitive, so connect the last line
@ -1321,7 +1321,7 @@ DefineEngineMethod( EditTSCtrl, renderCircle, void, ( Point3F pos, Point3F norma
PrimBuild::vertex3fv( pos );
// Edge verts
for( int i = 0; i < points.size(); i++ )
for( S32 i = 0; i < points.size(); i++ )
PrimBuild::vertex3fv( points[i] );
PrimBuild::vertex3fv( points[0] );

View file

@ -821,12 +821,13 @@ ConsoleMethod( GuiDecalEditorCtrl, getDecalTransform, const char*, 3, 3, "getDec
if( decalInstance == NULL )
return "";
char* returnBuffer = Con::getReturnBuffer(256);
static const U32 bufSize = 256;
char* returnBuffer = Con::getReturnBuffer(bufSize);
returnBuffer[0] = 0;
if ( decalInstance )
{
dSprintf(returnBuffer, 256, "%f %f %f %f %f %f %f",
dSprintf(returnBuffer, bufSize, "%f %f %f %f %f %f %f",
decalInstance->mPosition.x, decalInstance->mPosition.y, decalInstance->mPosition.z,
decalInstance->mTangent.x, decalInstance->mTangent.y, decalInstance->mTangent.z,
decalInstance->mSize);

View file

@ -631,6 +631,52 @@ void SmoothHeightAction::process(Selection * sel, const Gui3DMouseEvent &, bool
}
}
void SmoothSlopeAction::process(Selection * sel, const Gui3DMouseEvent &, bool selChanged, Type)
{
if(!sel->size())
return;
if(selChanged)
{
// Perform simple 2d linear regression on x&z and y&z:
// b = (Avg(xz) - Avg(x)Avg(z))/(Avg(x^2) - Avg(x)^2)
Point2F prod(0.f, 0.f); // mean of product for covar
Point2F avgSqr(0.f, 0.f); // mean sqr of x, y for var
Point2F avgPos(0.f, 0.f);
F32 avgHeight = 0.f;
F32 z;
Point2F pos;
for(U32 k = 0; k < sel->size(); k++)
{
mTerrainEditor->getUndoSel()->add((*sel)[k]);
pos = Point2F((*sel)[k].mGridPoint.gridPos.x, (*sel)[k].mGridPoint.gridPos.y);
z = (*sel)[k].mHeight;
prod += pos * z;
avgSqr += pos * pos;
avgPos += pos;
avgHeight += z;
}
prod /= sel->size();
avgSqr /= sel->size();
avgPos /= sel->size();
avgHeight /= sel->size();
Point2F avgSlope = (prod - avgPos*avgHeight)/(avgSqr - avgPos*avgPos);
F32 goalHeight;
for(U32 i = 0; i < sel->size(); i++)
{
goalHeight = avgHeight + ((*sel)[i].mGridPoint.gridPos.x - avgPos.x)*avgSlope.x +
((*sel)[i].mGridPoint.gridPos.y - avgPos.y)*avgSlope.y;
(*sel)[i].mHeight += (goalHeight - (*sel)[i].mHeight) * (*sel)[i].mWeight;
mTerrainEditor->setGridInfo((*sel)[i]);
}
mTerrainEditor->scheduleGridUpdate();
}
}
void PaintNoiseAction::process(Selection * sel, const Gui3DMouseEvent &, bool selChanged, Type type)
{
// If this is the ending

View file

@ -258,6 +258,15 @@ class SmoothHeightAction : public TerrainAction
void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type);
};
class SmoothSlopeAction : public TerrainAction
{
public:
SmoothSlopeAction(TerrainEditor * editor) : TerrainAction(editor){}
StringTableEntry getName(){return("smoothSlope");}
void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type);
};
class PaintNoiseAction : public TerrainAction
{
public:

View file

@ -33,7 +33,6 @@
#include "gfx/gfxDrawUtil.h"
#include "gui/core/guiCanvas.h"
#include "gui/worldEditor/terrainActions.h"
#include "interior/interiorInstance.h"
#include "terrain/terrMaterial.h"
@ -671,7 +670,7 @@ TerrainEditor::TerrainEditor() :
mUndoSel(0),
mGridUpdateMin( S32_MAX, S32_MAX ),
mGridUpdateMax( 0, 0 ),
mMaxBrushSize(48,48),
mMaxBrushSize(256,256),
mNeedsGridUpdate( false ),
mNeedsMaterialUpdate( false ),
mMouseDown( false )
@ -710,6 +709,7 @@ TerrainEditor::TerrainEditor() :
mActions.push_back(new AdjustHeightAction(this));
mActions.push_back(new FlattenHeightAction(this));
mActions.push_back(new SmoothHeightAction(this));
mActions.push_back(new SmoothSlopeAction(this));
mActions.push_back(new PaintNoiseAction(this));
//mActions.push_back(new ThermalErosionAction(this));
@ -2111,8 +2111,9 @@ const char* TerrainEditor::getBrushPos()
AssertFatal(mMouseBrush!=NULL, "TerrainEditor::getBrushPos: no mouse brush!");
Point2I pos = mMouseBrush->getPosition();
char * ret = Con::getReturnBuffer(32);
dSprintf(ret, 32, "%d %d", pos.x, pos.y);
static const U32 bufSize = 32;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%d %d", pos.x, pos.y);
return(ret);
}
@ -2244,73 +2245,6 @@ void TerrainEditor::markEmptySquares()
{
if(!checkTerrainBlock(this, "markEmptySquares"))
return;
// TODO!
/*
// build a list of all the marked interiors
Vector<InteriorInstance*> interiors;
U32 mask = InteriorObjectType;
gServerContainer.findObjects(mask, findObjectsCallback, &interiors);
// walk the terrains and empty any grid which clips to an interior
for (U32 i = 0; i < mTerrainBlocks.size(); i++)
{
for(U32 x = 0; x < TerrainBlock::BlockSize; x++)
{
for(U32 y = 0; y < TerrainBlock::BlockSize; y++)
{
TerrainBlock::Material * material = mTerrainBlocks[i]->getMaterial(x,y);
material->flags |= ~(TerrainBlock::Material::Empty);
Point3F a, b;
gridToWorld(Point2I(x,y), a, mTerrainBlocks[i]);
gridToWorld(Point2I(x+1,y+1), b, mTerrainBlocks[i]);
Box3F box;
box.minExtents = a;
box.maxExtents = b;
box.minExtents.setMin(b);
box.maxExtents.setMax(a);
const MatrixF & terrOMat = mTerrainBlocks[i]->getTransform();
const MatrixF & terrWMat = mTerrainBlocks[i]->getWorldTransform();
terrWMat.mulP(box.minExtents);
terrWMat.mulP(box.maxExtents);
for(U32 i = 0; i < interiors.size(); i++)
{
MatrixF mat = interiors[i]->getWorldTransform();
mat.scale(interiors[i]->getScale());
mat.mul(terrOMat);
U32 waterMark = FrameAllocator::getWaterMark();
U16* zoneVector = (U16*)FrameAllocator::alloc(interiors[i]->getDetailLevel(0)->getNumZones());
U32 numZones = 0;
interiors[i]->getDetailLevel(0)->scanZones(box, mat,
zoneVector, &numZones);
if (numZones != 0)
{
Con::printf("%d %d", x, y);
material->flags |= TerrainBlock::Material::Empty;
FrameAllocator::setWaterMark(waterMark);
break;
}
FrameAllocator::setWaterMark(waterMark);
}
}
}
}
// rebuild stuff..
for (U32 i = 0; i < mTerrainBlocks.size(); i++)
{
mTerrainBlocks[i]->buildGridMap();
mTerrainBlocks[i]->rebuildEmptyFlags();
mTerrainBlocks[i]->packEmptySquares();
}
*/
}
void TerrainEditor::mirrorTerrain(S32 mirrorIndex)
@ -2588,8 +2522,9 @@ ConsoleMethod( TerrainEditor, getBrushSize, const char*, 2, 2, "()")
{
Point2I size = object->getBrushSize();
char * ret = Con::getReturnBuffer(32);
dSprintf(ret, 32, "%d %d", size.x, size.y);
static const U32 bufSize = 32;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%d %d", size.x, size.y);
return ret;
}
@ -2933,3 +2868,77 @@ ConsoleMethod( TerrainEditor, setSlopeLimitMaxAngle, F32, 3, 3, 0)
object->mSlopeMaxAngle = angle;
return angle;
}
//------------------------------------------------------------------------------
void TerrainEditor::autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage )
{
if (!mActiveTerrain)
return;
S32 mat = getPaintMaterialIndex();
if (mat == -1)
return;
mUndoSel = new Selection;
U32 terrBlocks = mActiveTerrain->getBlockSize();
for (U32 y = 0; y < terrBlocks; y++)
{
for (U32 x = 0; x < terrBlocks; x++)
{
// get info
GridPoint gp;
gp.terrainBlock = mActiveTerrain;
gp.gridPos.set(x, y);
GridInfo gi;
getGridInfo(gp, gi);
if (gi.mMaterial == mat)
continue;
if (mRandI(0, 100) > mCoverage)
continue;
Point3F wp;
gridToWorld(gp, wp);
if (!(wp.z >= mMinHeight && wp.z <= mMaxHeight))
continue;
// transform wp to object space
Point3F op;
mActiveTerrain->getWorldTransform().mulP(wp, &op);
Point3F norm;
mActiveTerrain->getNormal(Point2F(op.x, op.y), &norm, true);
if (mMinSlope > 0)
if (norm.z > mSin(mDegToRad(90.0f - mMinSlope)))
continue;
if (mMaxSlope < 90)
if (norm.z < mSin(mDegToRad(90.0f - mMaxSlope)))
continue;
gi.mMaterialChanged = true;
mUndoSel->add(gi);
gi.mMaterial = mat;
setGridInfo(gi);
}
}
if(mUndoSel->size())
submitUndo( mUndoSel );
else
delete mUndoSel;
mUndoSel = 0;
scheduleMaterialUpdate();
}
ConsoleMethod( TerrainEditor, autoMaterialLayer, void, 7, 7, "(float minHeight, float maxHeight, float minSlope, float maxSlope, float coverage)")
{
object->autoMaterialLayer( dAtof(argv[2]), dAtof(argv[3]), dAtof(argv[4]), dAtof(argv[5]), dAtof(argv[6]));
}

View file

@ -112,7 +112,7 @@ protected:
public:
enum { MaxBrushDim = 40 };
enum { MaxBrushDim = 256 };
Brush(TerrainEditor * editor);
virtual ~Brush(){};
@ -230,6 +230,8 @@ class TerrainEditor : public EditTSCtrl
void submitMaterialUndo( String actionName );
void onMaterialUndo( TerrainBlock *terr );
void autoMaterialLayer( F32 mMinHeight, F32 mMaxHeight, F32 mMinSlope, F32 mMaxSlope, F32 mCoverage );
private:
typedef EditTSCtrl Parent;

View file

@ -1505,7 +1505,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
GFXVertexBufferHandle<GFXVertexPC> vb;
vb.set(GFX, 3*batchSize, GFXBufferTypeVolatile);
vb.lock();
void *lockPtr = vb.lock();
if(!lockPtr) return;
U32 vIdx=0;
@ -1542,7 +1543,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
// Reset for next pass...
vIdx = 0;
vb.lock();
void *lockPtr = vb.lock();
if(!lockPtr) return;
}
}
@ -2880,8 +2882,9 @@ const Point3F& WorldEditor::getSelectionCentroid()
const char* WorldEditor::getSelectionCentroidText()
{
const Point3F & centroid = getSelectionCentroid();
char * ret = Con::getReturnBuffer(100);
dSprintf(ret, 100, "%g %g %g", centroid.x, centroid.y, centroid.z);
static const U32 bufSize = 100;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z);
return ret;
}
@ -3261,8 +3264,9 @@ ConsoleMethod( WorldEditor, getSelectionCentroid, const char *, 2, 2, "")
ConsoleMethod( WorldEditor, getSelectionExtent, const char *, 2, 2, "")
{
Point3F bounds = object->getSelectionExtent();
char * ret = Con::getReturnBuffer(100);
dSprintf(ret, 100, "%g %g %g", bounds.x, bounds.y, bounds.z);
static const U32 bufSize = 100;
char * ret = Con::getReturnBuffer(bufSize);
dSprintf(ret, bufSize, "%g %g %g", bounds.x, bounds.y, bounds.z);
return ret;
}

View file

@ -642,10 +642,11 @@ ConsoleMethod( WorldEditorSelection, containsGlobalBounds, bool, 2, 2, "() - Tru
ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Return the median of all object positions in the selection." )
{
char* buffer = Con::getReturnBuffer( 256 );
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& centroid = object->getCentroid();
dSprintf( buffer, 256, "%g %g %g", centroid.x, centroid.y, centroid.z );
dSprintf( buffer, bufSize, "%g %g %g", centroid.x, centroid.y, centroid.z );
return buffer;
}
@ -653,10 +654,11 @@ ConsoleMethod( WorldEditorSelection, getCentroid, const char*, 2, 2, "() - Retur
ConsoleMethod( WorldEditorSelection, getBoxCentroid, const char*, 2, 2, "() - Return the center of the bounding box around the selection." )
{
char* buffer = Con::getReturnBuffer( 256 );
static const U32 bufSize = 256;
char* buffer = Con::getReturnBuffer( bufSize );
const Point3F& boxCentroid = object->getBoxCentroid();
dSprintf( buffer, 256, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
dSprintf( buffer, bufSize, "%g %g %g", boxCentroid.x, boxCentroid.y, boxCentroid.z );
return buffer;
}