Merge pull request #1172 from Areloch/BaseUIUpdate_Wipwork

BaseUI Update
This commit is contained in:
Brian Roberts 2024-01-05 14:30:00 -06:00 committed by GitHub
commit cf7e9f7a00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 5091 additions and 6538 deletions

View file

@ -478,7 +478,7 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
setProtocolVersion(currentProtocol < CurrentProtocolVersion ? currentProtocol : CurrentProtocolVersion);
const char *serverPassword = Con::getVariable("pref::Server::Password");
if(serverPassword[0])
if(serverPassword[0] && !isLocalConnection())
{
if(String::compare(joinPassword, serverPassword))
{

View file

@ -210,7 +210,7 @@ bool AssetManager::addModuleDeclaredAssets( ModuleDefinition* pModuleDefinition
dSprintf(extensionBuffer, sizeof(extensionBuffer), "*.%s", pDeclaredAssets->getExtension());
// Scan declared assets at location.
if ( !scanDeclaredAssets( filePathBuffer, extensionBuffer, pDeclaredAssets->getRecurse(), pModuleDefinition ) )
if ( !scanDeclaredAssets( filePathBuffer, extensionBuffer, pDeclaredAssets->getRecurse(), pModuleDefinition ) && mEchoInfo)
{
// Warn.
Con::warnf( "AssetManager::addModuleDeclaredAssets() - No assets found at location '%s' with extension '%s'.", filePathBuffer, pDeclaredAssets->getExtension() );

View file

@ -31,14 +31,14 @@
#include "sfx/sfxTrack.h"
IMPLEMENT_CONOBJECT( GuiButtonBaseCtrl );
IMPLEMENT_CONOBJECT(GuiButtonBaseCtrl);
ConsoleDocClass( GuiButtonBaseCtrl,
ConsoleDocClass(GuiButtonBaseCtrl,
"@brief The base class for the various button controls.\n\n"
"This is the base class for the various types of button controls. If no more specific functionality is required than "
"offered by this class, then it can be instantiated and used directly. Otherwise, its subclasses should be used:\n"
"- GuiRadioCtrl (radio buttons)\n"
"- GuiCheckBoxCtrl (checkboxes)\n"
"- GuiButtonCtrl (push buttons with text labels)\n"
@ -47,49 +47,54 @@ ConsoleDocClass( GuiButtonBaseCtrl,
"- GuiToggleButtonCtrl (toggle buttons, i.e. push buttons with \"sticky\" behavior)\n"
"- GuiSwatchButtonCtrl (color swatch buttons)\n"
"- GuiBorderButtonCtrl (push buttons for surrounding child controls)\n\n"
"@ingroup GuiButtons"
);
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseDown, void, (), (),
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseDown, void, (), (),
"If #useMouseEvents is true, this is called when the left mouse button is pressed on an (active) "
"button." );
"button.");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseUp, void, (), (),
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseUp, void, (), (),
"If #useMouseEvents is true, this is called when the left mouse button is release over an (active) "
"button.\n\n"
"@note To trigger actions, better use onClick() since onMouseUp() will also be called when the mouse was "
"not originally pressed on the button." );
"not originally pressed on the button.");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onClick, void, (), (),
"Called when the primary action of the button is triggered (e.g. by a left mouse click)." );
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onClick, void, (), (),
"Called when the primary action of the button is triggered (e.g. by a left mouse click).");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onDoubleClick, void, (), (),
"Called when the left mouse button is double-clicked on the button." );
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onDoubleClick, void, (), (),
"Called when the left mouse button is double-clicked on the button.");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onRightClick, void, (), (),
"Called when the right mouse button is clicked on the button." );
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onRightClick, void, (), (),
"Called when the right mouse button is clicked on the button.");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseEnter, void, (), (),
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseEnter, void, (), (),
"If #useMouseEvents is true, this is called when the mouse cursor moves over the button (only if the button "
"is the front-most visible control, though)." );
"is the front-most visible control, though).");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseLeave, void, (), (),
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseLeave, void, (), (),
"If #useMouseEvents is true, this is called when the mouse cursor moves off the button (only if the button "
"had previously received an onMouseEvent() event)." );
"had previously received an onMouseEvent() event).");
IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseDragged, void, (), (),
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseDragged, void, (), (),
"If #useMouseEvents is true, this is called when a left mouse button drag is detected, i.e. when the user "
"pressed the left mouse button on the control and then moves the mouse over a certain distance threshold with "
"the mouse button still pressed." );
"the mouse button still pressed.");
IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onHighlighted, void, (bool highlighted), (highlighted),
"This is called when the highlighted state of the button is changed.");
ImplementEnumType( GuiButtonType,
ImplementEnumType(GuiButtonType,
"Type of button control.\n\n"
"@ingroup GuiButtons" )
{ GuiButtonBaseCtrl::ButtonTypePush, "PushButton", "A button that triggers an action when clicked." },
{ GuiButtonBaseCtrl::ButtonTypeCheck, "ToggleButton", "A button that is toggled between on and off state." },
{ GuiButtonBaseCtrl::ButtonTypeRadio, "RadioButton", "A button placed in groups for presenting choices." },
"@ingroup GuiButtons")
{
GuiButtonBaseCtrl::ButtonTypePush, "PushButton", "A button that triggers an action when clicked."
},
{ GuiButtonBaseCtrl::ButtonTypeCheck, "ToggleButton", "A button that is toggled between on and off state." },
{ GuiButtonBaseCtrl::ButtonTypeRadio, "RadioButton", "A button placed in groups for presenting choices." },
EndImplementEnumType;
@ -100,7 +105,7 @@ GuiButtonBaseCtrl::GuiButtonBaseCtrl()
mDepressed = false;
mHighlighted = false;
mActive = true;
static StringTableEntry sButton = StringTable->insert( "Button" );
static StringTableEntry sButton = StringTable->insert("Button");
mButtonText = sButton;
mButtonTextID = StringTable->EmptyString();
mStateOn = false;
@ -115,27 +120,27 @@ GuiButtonBaseCtrl::GuiButtonBaseCtrl()
void GuiButtonBaseCtrl::initPersistFields()
{
docsURL;
addGroup( "Button" );
addField( "text", TypeCaseString, Offset(mButtonText, GuiButtonBaseCtrl),
"Text label to display on button (if button class supports text labels)." );
addField( "textID", TypeString, Offset(mButtonTextID, GuiButtonBaseCtrl),
"ID of string in string table to use for text label on button.\n\n"
"@see setTextID\n"
"@see GuiControl::langTableMod\n"
"@see LangTable\n\n" );
addField( "groupNum", TypeS32, Offset(mRadioGroup, GuiButtonBaseCtrl),
"Radio button toggle group number. All radio buttons that are assigned the same #groupNum and that "
"are parented to the same control will synchronize their toggle state, i.e. if one radio button is toggled on "
"all other radio buttons in its group will be toggled off.\n\n"
"The default group is -1." );
addField( "buttonType", TYPEID< ButtonType >(), Offset(mButtonType, GuiButtonBaseCtrl),
"Button behavior type.\n" );
addField( "useMouseEvents", TypeBool, Offset(mUseMouseEvents, GuiButtonBaseCtrl),
"If true, mouse events will be passed on to script. Default is false.\n" );
endGroup( "Button" );
addGroup("Button");
addField("text", TypeCaseString, Offset(mButtonText, GuiButtonBaseCtrl),
"Text label to display on button (if button class supports text labels).");
addField("textID", TypeString, Offset(mButtonTextID, GuiButtonBaseCtrl),
"ID of string in string table to use for text label on button.\n\n"
"@see setTextID\n"
"@see GuiControl::langTableMod\n"
"@see LangTable\n\n");
addField("groupNum", TypeS32, Offset(mRadioGroup, GuiButtonBaseCtrl),
"Radio button toggle group number. All radio buttons that are assigned the same #groupNum and that "
"are parented to the same control will synchronize their toggle state, i.e. if one radio button is toggled on "
"all other radio buttons in its group will be toggled off.\n\n"
"The default group is -1.");
addField("buttonType", TYPEID< ButtonType >(), Offset(mButtonType, GuiButtonBaseCtrl),
"Button behavior type.\n");
addField("useMouseEvents", TypeBool, Offset(mUseMouseEvents, GuiButtonBaseCtrl),
"If true, mouse events will be passed on to script. Default is false.\n");
endGroup("Button");
Parent::initPersistFields();
}
@ -143,70 +148,70 @@ void GuiButtonBaseCtrl::initPersistFields()
bool GuiButtonBaseCtrl::onWake()
{
if(!Parent::onWake())
if (!Parent::onWake())
return false;
// is we have a script variable, make sure we're in sync
if ( mConsoleVariable[0] )
mStateOn = Con::getBoolVariable( mConsoleVariable );
if(mButtonTextID && *mButtonTextID != 0)
setTextID(mButtonTextID);
if (mConsoleVariable[0])
mStateOn = Con::getBoolVariable(mConsoleVariable);
if (mButtonTextID && *mButtonTextID != 0)
setTextID(mButtonTextID);
return true;
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::setText( const char* text )
void GuiButtonBaseCtrl::setText(const char* text)
{
mButtonText = StringTable->insert(text, true);
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::setTextID(const char *id)
void GuiButtonBaseCtrl::setTextID(const char* id)
{
S32 n = Con::getIntVariable(id, -1);
if(n != -1)
{
mButtonTextID = StringTable->insert(id);
setTextID(n);
}
S32 n = Con::getIntVariable(id, -1);
if (n != -1)
{
mButtonTextID = StringTable->insert(id);
setTextID(n);
}
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::setTextID(S32 id)
{
const UTF8 *str = getGUIString(id);
if(str)
setText((const char*)str);
//mButtonTextID = id;
const UTF8* str = getGUIString(id);
if (str)
setText((const char*)str);
//mButtonTextID = id;
}
//-----------------------------------------------------------------------------
const char *GuiButtonBaseCtrl::getText()
const char* GuiButtonBaseCtrl::getText()
{
return mButtonText;
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::setStateOn( bool bStateOn )
void GuiButtonBaseCtrl::setStateOn(bool bStateOn)
{
if(!mActive)
if (!mActive)
return;
if(mButtonType == ButtonTypeCheck)
if (mButtonType == ButtonTypeCheck)
{
mStateOn = bStateOn;
}
else if(mButtonType == ButtonTypeRadio)
else if (mButtonType == ButtonTypeRadio)
{
messageSiblings(mRadioGroup);
mStateOn = bStateOn;
}
}
setUpdate();
}
@ -214,7 +219,7 @@ void GuiButtonBaseCtrl::setStateOn( bool bStateOn )
void GuiButtonBaseCtrl::acceleratorKeyPress(U32)
{
if( !mActive )
if (!mActive)
return;
//set the bool
@ -228,7 +233,7 @@ void GuiButtonBaseCtrl::acceleratorKeyPress(U32)
void GuiButtonBaseCtrl::acceleratorKeyRelease(U32)
{
if (! mActive)
if (!mActive)
return;
if (mDepressed)
@ -245,9 +250,9 @@ void GuiButtonBaseCtrl::acceleratorKeyRelease(U32)
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event)
void GuiButtonBaseCtrl::onMouseDown(const GuiEvent& event)
{
if (! mActive)
if (!mActive)
return;
if (mProfile->mCanKeyFocus)
@ -255,19 +260,19 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event)
if (mProfile->isSoundButtonDownValid())
SFX->playOnce(mProfile->getSoundButtonDownProfile());
mMouseDownPoint = event.mousePoint;
mMouseDragged = false;
if( mUseMouseEvents )
onMouseDown_callback();
if (mUseMouseEvents)
onMouseDown_callback();
//lock the mouse
mouseLock();
mDepressed = true;
// If we have a double click then execute the alt command.
if ( event.mouseClickCount == 2 )
if (event.mouseClickCount == 2)
{
onDoubleClick_callback();
execAltConsoleCallback();
@ -279,17 +284,18 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event)
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event)
void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent& event)
{
setUpdate();
if( mUseMouseEvents )
if (mUseMouseEvents)
onMouseEnter_callback();
if(isMouseLocked())
if (isMouseLocked())
{
mDepressed = true;
mHighlighted = true;
onHighlighted_callback(mHighlighted);
}
else
{
@ -297,38 +303,42 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event)
SFX->playOnce(mProfile->getSoundButtonOverProfile());
mHighlighted = true;
messageSiblings(mRadioGroup);
onHighlighted_callback(mHighlighted);
}
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMouseLeave(const GuiEvent &)
void GuiButtonBaseCtrl::onMouseLeave(const GuiEvent&)
{
setUpdate();
if( mUseMouseEvents )
if (mUseMouseEvents)
onMouseLeave_callback();
if( isMouseLocked() )
if (isMouseLocked())
mDepressed = false;
mHighlighted = false;
onHighlighted_callback(mHighlighted);
messageSiblings(mRadioGroup);
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMouseUp(const GuiEvent &event)
void GuiButtonBaseCtrl::onMouseUp(const GuiEvent& event)
{
mouseUnlock();
if( !mActive )
if (!mActive)
return;
setUpdate();
if( mUseMouseEvents )
if (mUseMouseEvents)
onMouseUp_callback();
//if we released the mouse within this control, perform the action
if( mDepressed )
if (mDepressed)
onAction();
mDepressed = false;
@ -337,38 +347,38 @@ void GuiButtonBaseCtrl::onMouseUp(const GuiEvent &event)
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onRightMouseUp(const GuiEvent &event)
void GuiButtonBaseCtrl::onRightMouseUp(const GuiEvent& event)
{
onRightClick_callback();
Parent::onRightMouseUp( event );
Parent::onRightMouseUp(event);
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMouseDragged( const GuiEvent& event )
void GuiButtonBaseCtrl::onMouseDragged(const GuiEvent& event)
{
if( mUseMouseEvents )
if (mUseMouseEvents)
{
// If we haven't started a drag yet, find whether we have moved past
// the tolerance value.
if( !mMouseDragged )
if (!mMouseDragged)
{
Point2I delta = mMouseDownPoint - event.mousePoint;
if( mAbs( delta.x ) > 2 || mAbs( delta.y ) > 2 )
if (mAbs(delta.x) > 2 || mAbs(delta.y) > 2)
mMouseDragged = true;
}
if( mMouseDragged )
if (mMouseDragged)
onMouseDragged_callback();
}
Parent::onMouseDragged( event );
Parent::onMouseDragged(event);
}
//-----------------------------------------------------------------------------
bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event)
bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent& event)
{
//if the control is a dead end, kill the event
if (!mActive)
@ -376,7 +386,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event)
//see if the key down is a return or space or not
if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE)
&& event.modifier == 0)
&& event.modifier == 0)
{
if (mProfile->isSoundButtonDownValid())
SFX->playOnce(mProfile->getSoundButtonDownProfile());
@ -389,7 +399,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event)
//-----------------------------------------------------------------------------
bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent &event)
bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent& event)
{
//if the control is a dead end, kill the event
if (!mActive)
@ -410,64 +420,83 @@ bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent &event)
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::setScriptValue(const char *value)
void GuiButtonBaseCtrl::setScriptValue(const char* value)
{
mStateOn = dAtob(value);
mStateOn = dAtob(value);
// Update the console variable:
if ( mConsoleVariable[0] )
Con::setBoolVariable( mConsoleVariable, mStateOn );
// Update the console variable:
if (mConsoleVariable[0])
Con::setBoolVariable(mConsoleVariable, mStateOn);
setUpdate();
}
//-----------------------------------------------------------------------------
const char *GuiButtonBaseCtrl::getScriptValue()
const char* GuiButtonBaseCtrl::getScriptValue()
{
return mStateOn ? "1" : "0";
return mStateOn ? "1" : "0";
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onAction()
{
if(!mActive)
return;
if (!mActive)
return;
if(mButtonType == ButtonTypeCheck)
{
mStateOn = mStateOn ? false : true;
if (mButtonType == ButtonTypeCheck)
{
mStateOn = mStateOn ? false : true;
}
else if(mButtonType == ButtonTypeRadio)
{
mStateOn = true;
messageSiblings(mRadioGroup);
}
setUpdate();
else if (mButtonType == ButtonTypeRadio)
{
mStateOn = true;
messageSiblings(mRadioGroup);
}
setUpdate();
// Update the console variable:
if ( mConsoleVariable[0] )
Con::setBoolVariable( mConsoleVariable, mStateOn );
if (mConsoleVariable[0])
Con::setBoolVariable(mConsoleVariable, mStateOn);
onClick_callback();
Parent::onAction();
onClick_callback();
Parent::onAction();
}
//-----------------------------------------------------------------------------
void GuiButtonBaseCtrl::onMessage( GuiControl *sender, S32 msg )
void GuiButtonBaseCtrl::onMessage(GuiControl* sender, S32 msg)
{
Parent::onMessage(sender, msg);
if( mRadioGroup == msg && mButtonType == ButtonTypeRadio )
{
setUpdate();
mStateOn = ( sender == this );
Parent::onMessage(sender, msg);
if (mRadioGroup == msg)
{
if (mButtonType == ButtonTypeRadio)
{
setUpdate();
mStateOn = (sender == this);
// Update the console variable:
if ( mConsoleVariable[0] )
Con::setBoolVariable( mConsoleVariable, mStateOn );
}
// Update the console variable:
if (mConsoleVariable[0])
Con::setBoolVariable(mConsoleVariable, mStateOn);
}
else if (mButtonType == ButtonTypePush)
{
mHighlighted = (sender == this);
onHighlighted_callback(mHighlighted);
}
}
}
void GuiButtonBaseCtrl::setHighlighted(bool highlighted)
{
mHighlighted = highlighted;
onHighlighted_callback(mHighlighted);
if (mRadioGroup != -1)
{
messageSiblings(mRadioGroup);
}
}
//=============================================================================
@ -477,69 +506,69 @@ void GuiButtonBaseCtrl::onMessage( GuiControl *sender, S32 msg )
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, performClick, void, (),,
DefineEngineMethod(GuiButtonBaseCtrl, performClick, void, (), ,
"Simulate a click on the button.\n"
"This method will trigger the button's action just as if the button had been pressed by the "
"user.\n\n" )
"user.\n\n")
{
object->onAction();
}
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, setText, void, ( const char* text ),,
DefineEngineMethod(GuiButtonBaseCtrl, setText, void, (const char* text), ,
"Set the text displayed on the button's label.\n"
"@param text The text to display as the button's text label.\n"
"@note Not all buttons render text labels.\n\n"
"@see getText\n"
"@see setTextID\n" )
"@see setTextID\n")
{
object->setText( text );
object->setText(text);
}
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, setTextID, void, ( const char* id ),,
DefineEngineMethod(GuiButtonBaseCtrl, setTextID, void, (const char* id), ,
"Set the text displayed on the button's label using a string from the string table "
"assigned to the control.\n\n"
"@param id Name of the variable that contains the integer string ID. Used to look up "
"string in table.\n\n"
"string in table.\n\n"
"@note Not all buttons render text labels.\n\n"
"@see setText\n"
"@see getText\n"
"@see GuiControl::langTableMod\n"
"@see LangTable\n\n"
"@ref Gui_i18n" )
"@ref Gui_i18n")
{
object->setTextID( id );
object->setTextID(id);
}
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, getText, const char*, (),,
DefineEngineMethod(GuiButtonBaseCtrl, getText, const char*, (), ,
"Get the text display on the button's label (if any).\n\n"
"@return The button's label." )
"@return The button's label.")
{
return object->getText( );
return object->getText();
}
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, setStateOn, void, ( bool isOn ), ( true ),
DefineEngineMethod(GuiButtonBaseCtrl, setStateOn, void, (bool isOn), (true),
"For toggle or radio buttons, set whether the button is currently activated or not. For radio buttons, "
"toggling a button on will toggle all other radio buttons in its group to off.\n\n"
"@param isOn If true, the button will be toggled on (if not already); if false, it will be toggled off.\n\n"
"@note Toggling the state of a button with this method will <em>not</em> not trigger the action associated with the "
"button. To do that, use performClick()." )
"button. To do that, use performClick().")
{
object->setStateOn( isOn );
object->setStateOn(isOn);
}
//-----------------------------------------------------------------------------
DefineEngineMethod( GuiButtonBaseCtrl, resetState, void, (),,
DefineEngineMethod(GuiButtonBaseCtrl, resetState, void, (), ,
"Reset the mousing state of the button.\n\n"
"This method should not generally be called." )
"This method should not generally be called.")
{
object->resetState();
}
@ -551,7 +580,7 @@ DefineEngineMethod(GuiButtonBaseCtrl, setHighlighted, void, (bool highlighted),
object->setHighlighted(highlighted);
}
DefineEngineMethod(GuiButtonBaseCtrl, isHighlighted, bool, (),,
DefineEngineMethod(GuiButtonBaseCtrl, isHighlighted, bool, (), ,
"Reset the mousing state of the button.\n\n"
"This method should not generally be called.")
{

View file

@ -24,7 +24,7 @@
#define _GUIBUTTONBASECTRL_H_
#ifndef _GUICONTROL_H_
#include "gui/core/guiControl.h"
#include "gui/core/guiControl.h"
#endif
@ -33,98 +33,99 @@
///
class GuiButtonBaseCtrl : public GuiControl
{
public:
typedef GuiControl Parent;
public:
enum ButtonType
{
ButtonTypePush,
ButtonTypeCheck,
ButtonTypeRadio,
};
typedef GuiControl Parent;
protected:
StringTableEntry mButtonText;
StringTableEntry mButtonTextID;
bool mDepressed;
bool mHighlighted;
bool mStateOn;
S32 mButtonType;
S32 mRadioGroup;
bool mUseMouseEvents;
/// Point where left mouse button was pressed down. Used to find when to start
/// a mouse drag.
Point2I mMouseDownPoint;
///
bool mMouseDragged;
/// @name Callbacks
/// @{
enum ButtonType
{
ButtonTypePush,
ButtonTypeCheck,
ButtonTypeRadio,
};
DECLARE_CALLBACK( void, onMouseDown, () );
DECLARE_CALLBACK( void, onMouseUp, () );
DECLARE_CALLBACK( void, onClick, () );
DECLARE_CALLBACK( void, onRightClick, () );
DECLARE_CALLBACK( void, onDoubleClick, () );
DECLARE_CALLBACK( void, onMouseEnter, () );
DECLARE_CALLBACK( void, onMouseLeave, () );
DECLARE_CALLBACK( void, onMouseDragged, () );
protected:
/// @}
StringTableEntry mButtonText;
StringTableEntry mButtonTextID;
bool mDepressed;
bool mHighlighted;
bool mStateOn;
S32 mButtonType;
S32 mRadioGroup;
bool mUseMouseEvents;
public:
/// Point where left mouse button was pressed down. Used to find when to start
/// a mouse drag.
Point2I mMouseDownPoint;
GuiButtonBaseCtrl();
bool onWake();
///
bool mMouseDragged;
DECLARE_CONOBJECT( GuiButtonBaseCtrl );
DECLARE_CATEGORY( "Gui Buttons" );
DECLARE_DESCRIPTION( "A basic button control." );
static void initPersistFields();
/// @name Callbacks
/// @{
void setText(const char *text);
void setTextID(S32 id);
void setTextID(const char *id);
const char *getText();
void setStateOn( bool bStateOn );
bool getStateOn() const { return mStateOn; }
DECLARE_CALLBACK(void, onMouseDown, ());
DECLARE_CALLBACK(void, onMouseUp, ());
DECLARE_CALLBACK(void, onClick, ());
DECLARE_CALLBACK(void, onRightClick, ());
DECLARE_CALLBACK(void, onDoubleClick, ());
DECLARE_CALLBACK(void, onMouseEnter, ());
DECLARE_CALLBACK(void, onMouseLeave, ());
DECLARE_CALLBACK(void, onMouseDragged, ());
DECLARE_CALLBACK(void, onHighlighted, (bool));
void setDepressed( bool depressed ) { mDepressed = depressed; }
void resetState() {mDepressed = false; mHighlighted = false;}
/// @}
void setHighlighted(bool highlighted) { mHighlighted = highlighted; }
bool isHighlighted() { return mHighlighted; }
public:
void acceleratorKeyPress(U32 index);
void acceleratorKeyRelease(U32 index);
GuiButtonBaseCtrl();
bool onWake();
void onMouseDown(const GuiEvent &);
void onMouseUp(const GuiEvent &);
void onMouseDragged( const GuiEvent& event );
void onRightMouseUp(const GuiEvent &);
DECLARE_CONOBJECT(GuiButtonBaseCtrl);
DECLARE_CATEGORY("Gui Buttons");
DECLARE_DESCRIPTION("A basic button control.");
void onMouseEnter(const GuiEvent &);
void onMouseLeave(const GuiEvent &);
static void initPersistFields();
bool onKeyDown(const GuiEvent &event);
bool onKeyUp(const GuiEvent &event);
void setText(const char* text);
void setTextID(S32 id);
void setTextID(const char* id);
const char* getText();
void setStateOn(bool bStateOn);
bool getStateOn() const { return mStateOn; }
void setScriptValue(const char *value);
const char *getScriptValue();
void setDepressed(bool depressed) { mDepressed = depressed; }
void resetState() { mDepressed = false; mHighlighted = false; }
void onMessage(GuiControl *,S32 msg);
void onAction();
bool usesMouseEvents() const { return mUseMouseEvents; }
void setUseMouseEvents( bool val ) { mUseMouseEvents = val; }
void setHighlighted(bool highlighted);
bool isHighlighted() { return mHighlighted; }
void acceleratorKeyPress(U32 index);
void acceleratorKeyRelease(U32 index);
void onMouseDown(const GuiEvent&);
void onMouseUp(const GuiEvent&);
void onMouseDragged(const GuiEvent& event);
void onRightMouseUp(const GuiEvent&);
void onMouseEnter(const GuiEvent&);
void onMouseLeave(const GuiEvent&);
bool onKeyDown(const GuiEvent& event);
bool onKeyUp(const GuiEvent& event);
void setScriptValue(const char* value);
const char* getScriptValue();
void onMessage(GuiControl*, S32 msg);
void onAction();
bool usesMouseEvents() const { return mUseMouseEvents; }
void setUseMouseEvents(bool val) { mUseMouseEvents = val; }
};
typedef GuiButtonBaseCtrl::ButtonType GuiButtonType;
DefineEnumType( GuiButtonType );
DefineEnumType(GuiButtonType);
#endif

View file

@ -253,7 +253,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
if (mProfile->mBorder != 0)
renderFilledBorder(boundsRect, borderColor, fillColor, mProfile->mBorderThickness);
else
GFX->getDrawUtil()->drawRectFill(boundsRect, mProfile->mFillColor);
GFX->getDrawUtil()->drawRectFill(boundsRect, fillColor);
}
}
else if(mHighlighted && mActive)
@ -269,7 +269,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
if (mProfile->mBorder != 0)
renderFilledBorder(boundsRect, borderColor, fillColor, mProfile->mBorderThickness);
else
GFX->getDrawUtil()->drawRectFill(boundsRect, mProfile->mFillColor);
GFX->getDrawUtil()->drawRectFill(boundsRect, fillColor);
}
}
else
@ -388,6 +388,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
start.x = iconRect.extent.x + mButtonMargin.x + mTextMargin;
}
drawer->setBitmapModulation(fontColor);
drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors );
}
@ -395,6 +396,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
{
Point2I start( mTextMargin, ( getHeight() - mProfile->mFont->getHeight() ) / 2 );
drawer->setBitmapModulation(fontColor);
drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors );
}
@ -408,6 +410,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect )
}
else
start.set( ( getWidth() - textWidth ) / 2, ( getHeight() - mProfile->mFont->getHeight() ) / 2 );
drawer->setBitmapModulation( fontColor );
drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors );
}

View file

@ -218,7 +218,8 @@ GuiControl::GuiControl() : mAddGroup( NULL ),
mLangTable(NULL),
mFirstResponder(NULL),
mHorizSizing(horizResizeRight),
mVertSizing(vertResizeBottom)
mVertSizing(vertResizeBottom),
mCategory(StringTable->EmptyString())
{
mConsoleVariable = StringTable->EmptyString();
mAcceleratorKey = StringTable->EmptyString();
@ -294,6 +295,10 @@ void GuiControl::initPersistFields()
addField("accelerator", TypeString, Offset(mAcceleratorKey, GuiControl),
"Key combination that triggers the control's primary action when the control is on the canvas." );
addField("category", TypeString, Offset(mCategory, GuiControl),
"Name of the category this gui control should be grouped into for organizational purposes. Primarily for tooling.");
endGroup( "Control" );
addGroup( "ToolTip" );
@ -2942,3 +2947,19 @@ DefineEngineMethod( GuiControl, getAspect, F32, (),,
const Point2I &ext = object->getExtent();
return (F32)ext.x / (F32)ext.y;
}
//-----------------------------------------------------------------------------
DefineEngineMethod(GuiControl, execCommand, const char*, (), ,
"Forcefully executes the command field value(if any) on this guiControl.\n"
"@return The results of the evaluation of the command.")
{
return object->execConsoleCallback();
}
DefineEngineMethod(GuiControl, execAltCommand, const char*, (), ,
"Forcefully executes the altCommand field value(if any) on this guiControl.\n"
"@return The results of the evaluation of the altCommand.")
{
return object->execAltConsoleCallback();
}

View file

@ -218,6 +218,8 @@ class GuiControl : public SimGroup
String mAltConsoleCommand;
String mTooltip;
StringTableEntry mCategory;
/// @}

View file

@ -40,6 +40,7 @@
#include "gui/editor/editorFunctions.h"
#include "math/mEase.h"
#include "math/mathTypes.h"
#include "sim/actionMap.h"
//-----------------------------------------------------------------------------
@ -60,7 +61,7 @@ GuiControl* GuiInspectorTypeMenuBase::constructEditControl()
GuiPopUpMenuCtrl *menu = dynamic_cast<GuiPopUpMenuCtrl*>(retCtrl);
// Let's make it look pretty.
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiPopUpMenuProfile" );
retCtrl->setDataField( StringTable->insert("profile"), NULL, "ToolsGuiPopupMenuProfile" );
_registerEditControl( retCtrl );
// Configure it to update our value when the popup is closed
@ -387,6 +388,44 @@ void GuiInspectorTypeGuiProfile::consoleInit()
ConsoleBaseType::getType( TYPEID< GuiControlProfile >() )->setInspectorFieldType("GuiInspectorTypeGuiProfile");
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeActionMap
//-----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiInspectorTypeActionMap);
ConsoleDocClass(GuiInspectorTypeActionMap,
"@brief Inspector field type for ActionMap\n\n"
"Editor use only.\n\n"
"@internal"
);
void GuiInspectorTypeActionMap::_populateMenu(GuiPopUpMenuCtrl* menu)
{
// Add the action maps to the menu.
//First add a blank entry so you can clear the action map
menu->addEntry("", 0);
SimGroup* grp = Sim::getRootGroup();
SimSetIterator iter(grp);
for (; *iter; ++iter)
{
ActionMap* actionMap = dynamic_cast<ActionMap*>(*iter);
if (!actionMap)
continue;
menu->addEntry(actionMap->getName(), actionMap->getId());
}
menu->sort();
}
void GuiInspectorTypeActionMap::consoleInit()
{
Parent::consoleInit();
ConsoleBaseType::getType(TYPEID< ActionMap >())->setInspectorFieldType("GuiInspectorTypeActionMap");
}
//-----------------------------------------------------------------------------
// GuiInspectorTypeCheckBox
//-----------------------------------------------------------------------------

View file

@ -186,6 +186,20 @@ public:
virtual void _populateMenu( GuiPopUpMenuCtrl *menu );
};
//-----------------------------------------------------------------------------
// GuiInspectorTypeActionMap Class
//-----------------------------------------------------------------------------
class GuiInspectorTypeActionMap : public GuiInspectorTypeMenuBase
{
private:
typedef GuiInspectorTypeMenuBase Parent;
public:
DECLARE_CONOBJECT(GuiInspectorTypeActionMap);
static void consoleInit();
virtual void _populateMenu(GuiPopUpMenuCtrl* menu);
};
//-----------------------------------------------------------------------------
// GuiInspectorTypeCheckBox Class
//-----------------------------------------------------------------------------

View file

@ -64,6 +64,7 @@ GuiInputCtrl::GuiInputCtrl()
mSendModifierEvents(false),
mIgnoreMouseEvents(false)
{
mActionmap = nullptr;
}
//------------------------------------------------------------------------------
@ -80,6 +81,7 @@ void GuiInputCtrl::initPersistFields()
"If true, Make events will be sent for modifier keys (Default false).");
addField("ignoreMouseEvents", TypeBool, Offset(mIgnoreMouseEvents, GuiInputCtrl),
"If true, any events from mouse devices will be passed through.");
addField("actionMap", TYPEID<ActionMap>(), Offset(mActionmap, GuiInputCtrl), "The name of an action map to push/pop on the input stack alongside the wake/sleep of this control.");
endGroup("GuiInputCtrl");
Parent::initPersistFields();
@ -103,6 +105,12 @@ bool GuiInputCtrl::onWake()
if( !smDesignTime && !mIgnoreMouseEvents)
mouseLock();
if(mActionmap != nullptr)
{
SimSet* actionMapSet = Sim::getActiveActionMapSet();
actionMapSet->pushObject(mActionmap);
}
setFirstResponder();
@ -115,6 +123,13 @@ void GuiInputCtrl::onSleep()
{
Parent::onSleep();
mouseUnlock();
if (mActionmap != nullptr)
{
SimSet* actionMapSet = Sim::getActiveActionMapSet();
actionMapSet->removeObject(mActionmap);
}
clearFirstResponder();
}
@ -158,6 +173,9 @@ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event )
if (mIgnoreMouseEvents && event.deviceType == MouseDeviceType)
return false;
if (mActionmap != nullptr)
return false;
char deviceString[32];
if ( event.action == SI_MAKE )
{

View file

@ -26,6 +26,7 @@
#ifndef _GUIMOUSEEVENTCTRL_H_
#include "gui/utility/guiMouseEventCtrl.h"
#endif
#include "sim/actionMap.h"
/// A control that locks the mouse and reports all keyboard input events
@ -38,6 +39,8 @@ protected:
bool mSendModifierEvents;
bool mIgnoreMouseEvents;
ActionMap* mActionmap;
public:
typedef GuiMouseEventCtrl Parent;

View file

@ -729,7 +729,8 @@ bool ActionMap::nextBoundNode( const char* function, U32 &devMapIndex, U32 &node
for ( U32 j = nodeIndex; j < dvcMap->nodeMap.size(); j++ )
{
const Node* node = &dvcMap->nodeMap[j];
if ( !( node->flags & Node::BindCmd ) && ( dStricmp( function, node->consoleFunction ) == 0 ) )
if ( ( (node->flags & Node::BindCmd) && (dStricmp(function, node->makeConsoleCommand) == 0 || dStricmp(function, node->breakConsoleCommand) == 0) )
|| (!(node->flags & Node::BindCmd) && dStricmp( function, node->consoleFunction ) == 0 ) )
{
devMapIndex = i;
nodeIndex = j;
@ -1805,6 +1806,7 @@ bool ActionMap::handleEvent(const InputEventInfo* pEvent)
for (SimSet::iterator itr = pActionMapSet->end() - 1;
itr > pActionMapSet->begin(); itr--) {
ActionMap* pMap = static_cast<ActionMap*>(*itr);
if (pMap->processAction(pEvent) == true)
return true;
}