Converts all game, gui editor, and system classes to utilize assets

Processed core, tools and default modules to utilize assets
Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption
Removed unneeded MainEditor mockup module
Removed some unused/duplicate image assets from the tools
This commit is contained in:
Areloch 2021-07-19 01:07:08 -05:00
parent 83b0432283
commit 5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions

View file

@ -65,11 +65,12 @@ ConsoleDocClass( GuiChunkedBitmapCtrl,
void GuiChunkedBitmapCtrl::initPersistFields()
{
addGroup("GuiChunkedBitmapCtrl");
addField( "bitmap", TypeFilename, Offset( mBitmapName, GuiChunkedBitmapCtrl ), "This is the bitmap to render to the control." );
addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file "
"or a bitmap stored in \"variable\"");
addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use");
addGroup("GuiChunkedBitmapCtrl");
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiChunkedBitmapCtrl, "This is the bitmap to render to the control.");
addField( "useVariable", TypeBool, Offset( mUseVariable, GuiChunkedBitmapCtrl ), "This decides whether to use the \"bitmap\" file "
"or a bitmap stored in \"variable\"");
addField( "tile", TypeBool, Offset( mTile, GuiChunkedBitmapCtrl ), "This is no longer in use", AbstractClassRep::FIELD_HideInInspectors);
endGroup("GuiChunkedBitmapCtrl");
Parent::initPersistFields();
}
@ -86,7 +87,8 @@ DefineEngineMethod( GuiChunkedBitmapCtrl, setBitmap, void, (const char* filename
GuiChunkedBitmapCtrl::GuiChunkedBitmapCtrl()
{
mBitmapName = StringTable->EmptyString();
INIT_IMAGEASSET(Bitmap);
mUseVariable = false;
mTile = false;
}
@ -97,7 +99,8 @@ void GuiChunkedBitmapCtrl::setBitmap(const char *name)
if(awake)
onSleep();
mBitmapName = StringTable->insert(name);
_setBitmap(StringTable->insert(name));
if(awake)
onWake();
setUpdate();
@ -108,14 +111,14 @@ bool GuiChunkedBitmapCtrl::onWake()
if(!Parent::onWake())
return false;
if( !mTexHandle
if( !mBitmap
&& ( ( mBitmapName && mBitmapName[ 0 ] )
|| ( mUseVariable && mConsoleVariable && mConsoleVariable[ 0 ] ) ) )
{
if ( mUseVariable )
mTexHandle.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
mBitmap.set( Con::getVariable( mConsoleVariable ), &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
else
mTexHandle.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
mBitmap.set( mBitmapName, &GFXDefaultGUIProfile, avar("%s() - mTexHandle (line %d)", __FUNCTION__, __LINE__) );
}
return true;
@ -123,7 +126,6 @@ bool GuiChunkedBitmapCtrl::onWake()
void GuiChunkedBitmapCtrl::onSleep()
{
mTexHandle = NULL;
Parent::onSleep();
}
@ -164,10 +166,10 @@ void GuiChunkedBitmapCtrl::renderRegion(const Point2I &offset, const Point2I &ex
void GuiChunkedBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
{
if( mTexHandle )
if( mBitmap )
{
RectI boundsRect( offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch( mTexHandle, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, boundsRect, GFXBitmapFlip_None, GFXTextureFilterLinear );
}
renderChildControls(offset, updateRect);

View file

@ -7,6 +7,8 @@
#include "gfx/gfxDrawUtil.h"
#include "console/engineAPI.h"
#include "T3D/assets/ImageAsset.h"
class GuiChunkedBitmapCtrl : public GuiControl
{
private:
@ -14,8 +16,10 @@ private:
void renderRegion(const Point2I &offset, const Point2I &extent);
protected:
StringTableEntry mBitmapName;
GFXTexHandle mTexHandle;
DECLARE_IMAGEASSET(GuiChunkedBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
DECLARE_IMAGEASSET_SETGET(GuiChunkedBitmapCtrl, Bitmap);
bool mUseVariable;
bool mTile;
@ -34,4 +38,6 @@ public:
void setBitmap(const char *name);
void onRender(Point2I offset, const RectI &updateRect);
};
void onImageChanged() {}
};

View file

@ -114,14 +114,14 @@ public:
}
ColorI color(255,255,255,alpha);
if (mTextureObject)
if (mBitmap)
{
GFX->getDrawUtil()->setBitmapModulation(color);
if(mWrap)
{
GFXTextureObject* texture = mTextureObject;
GFXTextureObject* texture = mBitmap;
RectI srcRegion;
RectI dstRegion;
F32 xdone = ((F32)getExtent().x/(F32)texture->mBitmapSize.x)+1;
@ -144,11 +144,11 @@ public:
else
{
RectI rect(offset, getExtent());
GFX->getDrawUtil()->drawBitmapStretch(mTextureObject, rect);
GFX->getDrawUtil()->drawBitmapStretch(mBitmap, rect);
}
}
if (mProfile->mBorder || !mTextureObject)
if (mProfile->mBorder || !mBitmap)
{
RectI rect(offset.x, offset.y, getExtent().x, getExtent().y);
ColorI borderCol(mProfile->mBorderColor);

View file

@ -119,24 +119,21 @@ ConsoleDocClass( GuiProgressBitmapCtrl,
GuiProgressBitmapCtrl::GuiProgressBitmapCtrl()
: mProgress( 0.f ),
mBitmapName( StringTable->EmptyString() ),
mUseVariable( false ),
mTile( false ),
mNumberOfBitmaps(0),
mDim(0)
{
INIT_IMAGEASSET(Bitmap);
}
//-----------------------------------------------------------------------------
void GuiProgressBitmapCtrl::initPersistFields()
{
addProtectedField( "bitmap", TypeFilename, Offset( mBitmapName, GuiProgressBitmapCtrl ),
_setBitmap, defaultProtectedGetFn,
"~Path to the bitmap file to use for rendering the progress bar.\n\n"
INITPERSISTFIELD_IMAGEASSET(Bitmap, GuiProgressBitmapCtrl, "Bitmap file to use for rendering the progress bar.\n\n"
"If the profile assigned to the control already has a bitmap assigned, this property need not be "
"set in which case the bitmap from the profile is used."
);
"set in which case the bitmap from the profile is used.");
Parent::initPersistFields();
}
@ -149,7 +146,8 @@ void GuiProgressBitmapCtrl::setBitmap( const char* name )
if( awake )
onSleep();
mBitmapName = StringTable->insert( name );
_setBitmap(StringTable->insert(name));
if( awake )
onWake();
@ -222,14 +220,14 @@ void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
//drawing stretch bitmap
RectI progressRect = ctrlRect;
progressRect.extent.x = width;
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[0]);
}
}
else if(mNumberOfBitmaps >= 3)
{
//drawing left-end bitmap
RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectLeft, mProfile->mBitmapArrayRects[0]);
//draw the progress with image
S32 width = (S32)((F32)(getWidth()) * mProgress);
@ -241,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;
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRect, mProfile->mBitmapArrayRects[1]);
//drawing right-end bitmap
RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
drawUtil->drawBitmapStretchSR(mProfile->getBitmapResource(), progressRectRight, mProfile->mBitmapArrayRects[2]);
}
}
else

View file

@ -31,6 +31,7 @@
#include "gui/controls/guiTextCtrl.h"
#endif
#include "T3D/assets/ImageAsset.h"
//FIXME: WTH is this derived from GuiTextCtrl?? should be a GuiControl
@ -45,7 +46,10 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
protected:
F32 mProgress;
StringTableEntry mBitmapName;
DECLARE_IMAGEASSET(GuiProgressBitmapCtrl, Bitmap, onImageChanged, GFXDefaultGUIProfile);
DECLARE_IMAGEASSET_SETGET(GuiProgressBitmapCtrl, Bitmap);
bool mUseVariable;
bool mTile;
S32 mNumberOfBitmaps;
@ -57,6 +61,8 @@ class GuiProgressBitmapCtrl : public GuiTextCtrl
return false;
}
void onImageChanged() {}
public:
GuiProgressBitmapCtrl();