Removed hard coded directory paths

- Removed references to core directory.
- Switch some references to tools directory
- Added preferences variables where appropriate
This commit is contained in:
DavidWyand-GG 2013-03-07 18:56:53 -05:00
parent 853b70255b
commit 4b1334db9f
25 changed files with 75 additions and 18 deletions

View file

@ -330,7 +330,12 @@ void Forest::createNewFile()
// We need to construct a default file name
String missionName( Con::getVariable( "$Client::MissionFile" ) );
missionName.replace( "tools/levels", "levels" );
String levelDirectory( Con::getVariable( "$pref::Directories::Level" ) );
if ( levelDirectory.isEmpty() )
{
levelDirectory = "levels";
}
missionName.replace( "tools/levels", levelDirectory );
missionName = Platform::makeRelativePathName(missionName, Platform::getMainDotCsDir());
Torque::Path basePath( missionName );

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

@ -89,9 +89,6 @@ 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() );
setField( "altCommand", altCommand );

View file

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

View file

@ -1538,7 +1538,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

@ -127,7 +127,7 @@ void PostEffectVis::open( PostEffect *pfx )
bmpCtrl->setSizing( GuiControl::horizResizeWidth, GuiControl::vertResizeHeight );
bmpCtrl->setExtent( 341, 181 );
bmpCtrl->setDataField( StringTable->insert( "wrap" ), NULL, "1" );
bmpCtrl->setBitmap( "core/art/gui/images/transp_grid" );
bmpCtrl->setBitmap( "tools/gui/images/transp_grid" );
bmpCtrl->registerObject();
winCtrl->addObject( bmpCtrl );

View file

@ -864,8 +864,13 @@ bool TerrainBlock::onAdd()
if ( mTerrFileName.isEmpty() )
{
mTerrFileName = Con::getVariable( "$Client::MissionFile" );
mTerrFileName.replace("tools/levels/", "art/terrains/");
mTerrFileName.replace("levels/", "art/terrains/");
String terrainDirectory( Con::getVariable( "$pref::Directories::Terrain" ) );
if ( terrainDirectory.isEmpty() )
{
terrainDirectory = "art/terrains/";
}
mTerrFileName.replace("tools/levels/", terrainDirectory);
mTerrFileName.replace("levels/", terrainDirectory);
Vector<String> materials;
materials.push_back( "warning_material" );

View file

@ -744,7 +744,12 @@ void TerrainFile::create( String *inOutFilename,
if ( !basePath.getExtension().equal("mis") )
{
// Use the default path and filename
basePath.setPath( "art/terrains" );
String terrainDirectory( Con::getVariable( "$pref::Directories::Terrain" ) );
if ( terrainDirectory.isEmpty() )
{
terrainDirectory = "art/terrains";
}
basePath.setPath( terrainDirectory );
basePath.setFileName( "terrain" );
}

View file

@ -50,8 +50,13 @@ ConsoleStaticMethod( TerrainBlock, createNew, S32, 5, 5,
// rename it themselves in their file browser. The main reason for this is so we can easily increment for ourselves;
// and because its too easy to rename the terrain object and forget to take care of the terrain filename afterwards.
FileName terrFileName( Con::getVariable("$Client::MissionFile") );
terrFileName.replace("tools/levels/", "art/terrains/");
terrFileName.replace("levels/", "art/terrains/");
String terrainDirectory( Con::getVariable( "$pref::Directories::Terrain" ) );
if ( terrainDirectory.isEmpty() )
{
terrainDirectory = "art/terrains/";
}
terrFileName.replace("tools/levels/", terrainDirectory);
terrFileName.replace("levels/", terrainDirectory);
TerrainFile::create( &terrFileName, resolution, materials );

View file

@ -402,7 +402,7 @@ F32 MeshFit::maxDot( const VectorF& v ) const
// Best-fit oriented bounding box
void MeshFit::addBox( const Point3F& sides, const MatrixF& mat )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_cube.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getCubeShapePath() );
if ( !mesh )
return;
@ -431,7 +431,7 @@ void MeshFit::fitOBB()
// Best-fit sphere
void MeshFit::addSphere( F32 radius, const Point3F& center )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_sphere.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getSphereShapePath() );
if ( !mesh )
return;
@ -460,7 +460,7 @@ void MeshFit::fitSphere()
// Best-fit capsule
void MeshFit::addCapsule( F32 radius, F32 height, const MatrixF& mat )
{
TSMesh* mesh = initMeshFromFile( "core/art/shapes/unit_capsule.dts" );
TSMesh* mesh = initMeshFromFile( TSShapeConstructor::getCapsuleShapePath() );
if ( !mesh )
return;

View file

@ -74,6 +74,10 @@ EndImplementEnumType;
//-----------------------------------------------------------------------------
String TSShapeConstructor::smCapsuleShapePath("core/art/shapes/unit_capsule.dts");
String TSShapeConstructor::smCubeShapePath("core/art/shapes/unit_cube.dts");
String TSShapeConstructor::smSphereShapePath("core/art/shapes/unit_sphere.dts");
ResourceRegisterPostLoadSignal< TSShape > TSShapeConstructor::_smAutoLoad( &TSShapeConstructor::_onTSShapeLoaded );
ResourceRegisterUnloadSignal< TSShape > TSShapeConstructor::_smAutoUnload( &TSShapeConstructor::_onTSShapeUnloaded );
@ -280,6 +284,23 @@ void TSShapeConstructor::initPersistFields()
Parent::initPersistFields();
}
void TSShapeConstructor::consoleInit()
{
Parent::consoleInit();
Con::addVariable( "$pref::TSShapeConstructor::CapsuleShapePath", TypeString, &TSShapeConstructor::smCapsuleShapePath,
"The file path to the capsule shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
Con::addVariable( "$pref::TSShapeConstructor::CubeShapePath", TypeString, &TSShapeConstructor::smCubeShapePath,
"The file path to the cube shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
Con::addVariable( "$pref::TSShapeConstructor::SphereShapePath", TypeString, &TSShapeConstructor::smSphereShapePath,
"The file path to the sphere shape used by tsMeshFit.\n\n"
"@ingroup MeshFit\n" );
}
TSShapeConstructor* TSShapeConstructor::findShapeConstructor(const FileName& path)
{
SimGroup *group;

View file

@ -220,6 +220,11 @@ protected:
Vector<FileName> mSequences;
ChangeSet mChangeSet;
// Paths to shapes used by MeshFit
static String smCapsuleShapePath;
static String smCubeShapePath;
static String smSphereShapePath;
static bool addSequenceFromField( void *obj, const char *index, const char *data );
static void _onTSShapeLoaded( Resource< TSShape >& shape );
@ -250,6 +255,7 @@ public:
DECLARE_CONOBJECT(TSShapeConstructor);
static void initPersistFields();
static void consoleInit();
static TSShapeConstructor* findShapeConstructor(const FileName& path);
bool onAdd();
@ -261,6 +267,13 @@ public:
void notifyShapeChanged();
/// @name Shape paths for MeshFit
///@{
static const String& getCapsuleShapePath() { return smCapsuleShapePath; }
static const String& getCubeShapePath() { return smCubeShapePath; }
static const String& getSphereShapePath() { return smSphereShapePath; }
///@}
TSShape* getShape() const { return mShape; }
const String& getShapePath() const { return mShapePath; }

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B