mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
Console Refactor
This commit is contained in:
parent
626de074cc
commit
89b0c7f73b
89 changed files with 1883 additions and 1553 deletions
|
|
@ -22,6 +22,7 @@
|
|||
#include "gui/controls/guiListBoxCtrl.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "console/script.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiListBoxCtrl);
|
||||
|
||||
|
|
@ -165,7 +166,7 @@ GuiListBoxCtrl::GuiListBoxCtrl()
|
|||
mColorBullet = true;
|
||||
mItemSize = Point2I(10,20);
|
||||
mLastClickItem = NULL;
|
||||
|
||||
|
||||
mRenderTooltipDelegate.bind( this, &GuiListBoxCtrl::renderTooltip );
|
||||
}
|
||||
|
||||
|
|
@ -469,11 +470,11 @@ void GuiListBoxCtrl::getSelectedItems( Vector<S32> &Items )
|
|||
{
|
||||
// Clear our return vector
|
||||
Items.clear();
|
||||
|
||||
|
||||
// If there are no selected items, return an empty vector
|
||||
if( mSelectedItems.empty() )
|
||||
return;
|
||||
|
||||
|
||||
for( S32 i = 0; i < mItems.size(); i++ )
|
||||
if( mItems[i]->isSelected )
|
||||
Items.push_back( i );
|
||||
|
|
@ -882,8 +883,8 @@ StringTableEntry GuiListBoxCtrl::getItemText( S32 index )
|
|||
Con::warnf( "GuiListBoxCtrl::getItemText - index out of range!" );
|
||||
return StringTable->lookup("");
|
||||
}
|
||||
|
||||
return mItems[ index ]->itemText;
|
||||
|
||||
return mItems[ index ]->itemText;
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiListBoxCtrl, getItemObject, const char*, (S32 index),,
|
||||
|
|
@ -917,7 +918,7 @@ SimObject* GuiListBoxCtrl::getItemObject( S32 index )
|
|||
SimObject *outObj;
|
||||
Sim::findObject( (SimObjectId)(uintptr_t)(mItems[ index ]->itemData), outObj );
|
||||
|
||||
return outObj;
|
||||
return outObj;
|
||||
}
|
||||
|
||||
DefineEngineMethod( GuiListBoxCtrl, setItemText, void, (S32 index, const char* newtext),,
|
||||
|
|
@ -974,7 +975,7 @@ DefineEngineMethod( GuiListBoxCtrl, setItemTooltip, void, (S32 index, const char
|
|||
Con::errorf( "GuiListBoxCtrl::setItemTooltip - index '%i' out of range", index );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
object->mItems[ index ]->itemTooltip = text;
|
||||
}
|
||||
|
||||
|
|
@ -1104,7 +1105,7 @@ bool GuiListBoxCtrl::renderTooltip( const Point2I &hoverPos, const Point2I& curs
|
|||
S32 hitItemIndex;
|
||||
if( hitTest( hoverPos, hitItemIndex ) )
|
||||
tipText = mItems[ hitItemIndex ]->itemTooltip;
|
||||
|
||||
|
||||
return defaultTooltipRender( hoverPos, cursorPos, tipText );
|
||||
}
|
||||
|
||||
|
|
@ -1115,7 +1116,7 @@ bool GuiListBoxCtrl::renderTooltip( const Point2I &hoverPos, const Point2I& curs
|
|||
bool GuiListBoxCtrl::hitTest( const Point2I& point, S32& outItem )
|
||||
{
|
||||
Point2I localPoint = globalToLocalCoord( point );
|
||||
|
||||
|
||||
S32 itemHit = ( localPoint.y < 0 ) ? -1 : (S32)mFloor( (F32)localPoint.y / (F32)mItemSize.y );
|
||||
if ( itemHit >= mItems.size() || itemHit == -1 )
|
||||
return false;
|
||||
|
|
@ -1123,7 +1124,7 @@ bool GuiListBoxCtrl::hitTest( const Point2I& point, S32& outItem )
|
|||
LBItem *hitItem = mItems[ itemHit ];
|
||||
if ( hitItem == NULL )
|
||||
return false;
|
||||
|
||||
|
||||
outItem = itemHit;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1144,7 +1145,7 @@ void GuiListBoxCtrl::onMouseDown( const GuiEvent &event )
|
|||
S32 itemHit;
|
||||
if( !hitTest( event.mousePoint, itemHit ) )
|
||||
return;
|
||||
|
||||
|
||||
LBItem* hitItem = mItems[ itemHit ];
|
||||
|
||||
// If we're not a multiple selection listbox, we simply select/unselect an item
|
||||
|
|
@ -1172,7 +1173,7 @@ void GuiListBoxCtrl::onMouseDown( const GuiEvent &event )
|
|||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Deal with multiple selections
|
||||
if( event.modifier & SI_MULTISELECT)
|
||||
{
|
||||
|
|
@ -1219,7 +1220,7 @@ void GuiListBoxCtrl::onMouseUp( const GuiEvent& event )
|
|||
|
||||
// Execute console command
|
||||
execConsoleCallback();
|
||||
|
||||
|
||||
Parent::onMouseUp( event );
|
||||
}
|
||||
|
||||
|
|
@ -1268,7 +1269,7 @@ U32 GuiListBoxCtrl::getStringElementCount( const char* inString )
|
|||
// Yes...
|
||||
search = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Found a seperator?
|
||||
|
|
@ -1300,7 +1301,7 @@ U32 GuiListBoxCtrl::getStringElementCount( const char* inString )
|
|||
// Yes...
|
||||
search = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Found Seperator?
|
||||
|
|
@ -1357,7 +1358,7 @@ const char* GuiListBoxCtrl::getStringElement( const char* inString, const U32 in
|
|||
// Yes...
|
||||
search = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Found a seperator?
|
||||
|
|
@ -1396,7 +1397,7 @@ const char* GuiListBoxCtrl::getStringElement( const char* inString, const U32 in
|
|||
// Yes...
|
||||
search = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Found Seperator?
|
||||
|
|
@ -1446,19 +1447,19 @@ void GuiListBoxCtrl::_mirror()
|
|||
|
||||
// Allow script to filter out objects if desired.
|
||||
|
||||
Vector<SimObjectId> workingSet;
|
||||
Vector<SimObjectId> workingSet;
|
||||
|
||||
// If the method is not defined we assume user wants us to add
|
||||
// all objects.
|
||||
bool isObjMirroredDefined = isMethod( "isObjectMirrored" );
|
||||
|
||||
|
||||
for ( S32 i = 0; i < mirrorSet->size(); i++ )
|
||||
{
|
||||
bool addObj = true;
|
||||
|
||||
|
||||
if ( isObjMirroredDefined )
|
||||
addObj = isObjectMirrored_callback(mirrorSet->at(i)->getIdString());
|
||||
|
||||
addObj = isObjectMirrored_callback(mirrorSet->at(i)->getIdString());
|
||||
|
||||
if ( addObj )
|
||||
workingSet.push_back( mirrorSet->at(i)->getId() );
|
||||
}
|
||||
|
|
@ -1481,8 +1482,8 @@ void GuiListBoxCtrl::_mirror()
|
|||
if ( curObj )
|
||||
{
|
||||
if ( workingSet.contains( curId ) )
|
||||
{
|
||||
mItems[i]->itemText = _makeMirrorItemName( curObj );
|
||||
{
|
||||
mItems[i]->itemText = _makeMirrorItemName( curObj );
|
||||
keep = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1492,7 +1493,7 @@ void GuiListBoxCtrl::_mirror()
|
|||
deleteItem( i );
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add items that are in the SimSet but not yet in the list.
|
||||
|
|
@ -1512,7 +1513,7 @@ void GuiListBoxCtrl::_mirror()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ( U32 j = 0; j < mFilteredItems.size(); j++ )
|
||||
{
|
||||
if ( (SimObjectId)(uintptr_t)(mFilteredItems[j]->itemData) == curId )
|
||||
|
|
@ -1523,8 +1524,8 @@ void GuiListBoxCtrl::_mirror()
|
|||
}
|
||||
|
||||
if ( !found )
|
||||
{
|
||||
addItem( _makeMirrorItemName( curObj ), (void*)(uintptr_t)curId );
|
||||
{
|
||||
addItem( _makeMirrorItemName( curObj ), (void*)(uintptr_t)curId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1537,12 +1538,12 @@ StringTableEntry GuiListBoxCtrl::_makeMirrorItemName( SimObject *inObj )
|
|||
{
|
||||
Con::setIntVariable( "$ThisControl", getId() );
|
||||
Con::setIntVariable( "$ThisObject", inObj->getId() );
|
||||
|
||||
outName = StringTable->insert( Con::evaluate( mMakeNameCallback ), true );
|
||||
|
||||
outName = StringTable->insert( Con::evaluate( mMakeNameCallback ).value, true );
|
||||
}
|
||||
else if ( inObj->getName() )
|
||||
outName = StringTable->insert( inObj->getName() );
|
||||
|
||||
|
||||
if ( !outName || !outName[0] )
|
||||
outName = StringTable->insert( "(no name)" );
|
||||
|
||||
|
|
@ -1582,22 +1583,22 @@ DefineEngineMethod( GuiListBoxCtrl, addFilteredItem, void, (const char* newItem)
|
|||
void GuiListBoxCtrl::addFilteredItem( String item )
|
||||
{
|
||||
// Delete from selected items list
|
||||
for ( S32 i = 0; i < mSelectedItems.size(); i++ )
|
||||
for ( S32 i = 0; i < mSelectedItems.size(); i++ )
|
||||
{
|
||||
String itemText = mSelectedItems[i]->itemText;
|
||||
if ( String::compare( itemText.c_str(), item.c_str() ) == 0 )
|
||||
if ( String::compare( itemText.c_str(), item.c_str() ) == 0 )
|
||||
{
|
||||
mSelectedItems.erase_fast( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for ( S32 i = 0; i < mItems.size(); i++ )
|
||||
for ( S32 i = 0; i < mItems.size(); i++ )
|
||||
{
|
||||
String itemText = mItems[i]->itemText;
|
||||
if( String::compare( itemText.c_str(), item.c_str() ) == 0 )
|
||||
{
|
||||
mItems[i]->isSelected = false;
|
||||
{
|
||||
mItems[i]->isSelected = false;
|
||||
mFilteredItems.push_front( mItems[i] );
|
||||
mItems.erase( &mItems[i] );
|
||||
break;
|
||||
|
|
@ -1625,11 +1626,11 @@ DefineEngineMethod( GuiListBoxCtrl, removeFilteredItem, void, ( const char* item
|
|||
|
||||
void GuiListBoxCtrl::removeFilteredItem( String item )
|
||||
{
|
||||
for ( S32 i = 0; i < mFilteredItems.size(); i++ )
|
||||
for ( S32 i = 0; i < mFilteredItems.size(); i++ )
|
||||
{
|
||||
String itemText = mFilteredItems[i]->itemText;
|
||||
if( String::compare( itemText.c_str(), item.c_str() ) == 0 )
|
||||
{
|
||||
{
|
||||
mItems.push_front( mFilteredItems[i] );
|
||||
mFilteredItems.erase( &mFilteredItems[i] );
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue