Add all new AFX files

This commit is contained in:
Marc Chapman 2017-07-26 09:35:44 +01:00
parent f2b86b7df3
commit ace877b409
218 changed files with 54970 additions and 0 deletions

View file

@ -0,0 +1,147 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "gui/3d/guiTSControl.h"
class afxEventCatchAll : public GuiControl
{
typedef GuiControl Parent;
public:
/* C */ afxEventCatchAll() { }
virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
virtual void onMouseUp(const GuiEvent&);
virtual void onMouseDown(const GuiEvent&);
virtual void onMouseMove(const GuiEvent&);
virtual void onMouseDragged(const GuiEvent&);
virtual void onMouseEnter(const GuiEvent&);
virtual void onMouseLeave(const GuiEvent&);
virtual bool onMouseWheelUp(const GuiEvent&);
virtual bool onMouseWheelDown(const GuiEvent&);
virtual void onRightMouseDown(const GuiEvent&);
virtual void onRightMouseUp(const GuiEvent&);
virtual void onRightMouseDragged(const GuiEvent&);
DECLARE_CONOBJECT(afxEventCatchAll);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
IMPLEMENT_CONOBJECT(afxEventCatchAll);
ConsoleDocClass( afxEventCatchAll,
"@brief A simple but useful GUI control that propagates all events to its parent "
"control.\n\n"
"afxEventCatchAll is useful when you want certain events to be handled by its parent "
"afxTSCtrl and not get consumed by certain non-interactive controls like a text "
"HUD.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
void afxEventCatchAll::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->getCursor(cursor, showCursor, lastGuiEvent);
}
void afxEventCatchAll::onMouseUp(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseUp(evt);
}
void afxEventCatchAll::onMouseDown(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseDown(evt);
}
void afxEventCatchAll::onMouseMove(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseMove(evt);
}
void afxEventCatchAll::onMouseDragged(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseDragged(evt);
}
void afxEventCatchAll::onMouseEnter(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseEnter(evt);
}
void afxEventCatchAll::onMouseLeave(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onMouseLeave(evt);
}
bool afxEventCatchAll::onMouseWheelUp(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
return (parent) ? parent->onMouseWheelUp(evt) : false;
}
bool afxEventCatchAll::onMouseWheelDown(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
return (parent) ? parent->onMouseWheelDown(evt) : false;
}
void afxEventCatchAll::onRightMouseDown(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onRightMouseDown(evt);
}
void afxEventCatchAll::onRightMouseUp(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onRightMouseUp(evt);
}
void afxEventCatchAll::onRightMouseDragged(const GuiEvent& evt)
{
GuiTSCtrl* parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (parent) parent->onRightMouseDragged(evt);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,205 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "gui/editor/inspector/customField.h"
#include "gui/editor/guiInspector.h"
#include "afx/ui/afxGuiSubstitutionField.h"
IMPLEMENT_CONOBJECT( afxGuiSubstitutionField );
ConsoleDocClass( afxGuiSubstitutionField,
"@brief A customized variation of GuiInspectorField.\n\n"
"A customized variation of GuiInspectorField.\n"
"@ingroup AFX\n"
);
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
afxGuiSubstitutionField::afxGuiSubstitutionField( GuiInspector* inspector,
GuiInspectorGroup* parent,
SimFieldDictionary::Entry* field)
{
mInspector = inspector;
mParent = parent;
setBounds(0,0,100,20);
subs_string = StringTable->insert("");
}
afxGuiSubstitutionField::afxGuiSubstitutionField()
{
mInspector = NULL;
mParent = NULL;
subs_string = StringTable->insert("");
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
void afxGuiSubstitutionField::setData( const char* data, bool callbacks )
{
if ( mField == NULL)
return;
const U32 numTargets = mInspector->getNumInspectObjects();
//if( callbacks && numTargets > 1 )
// Con::executef( mInspector, "beginCompoundUndo" );
if (data[0] != '$' && data[1] != '$')
{
data = StringTable->insert(avar("$$ %s", data), true);
}
else
{
data = StringTable->insert(data, true);
}
for( U32 i = 0; i < numTargets; ++ i )
{
SimObject* target = mInspector->getInspectObject( i );
SimDataBlock* datablock = dynamic_cast<SimDataBlock*>(target);
if (datablock)
datablock->addSubstitution(mField->pFieldname, 0, data);
}
//if( callbacks && numTargets > 1 )
// Con::executef( mInspector, "endCompoundUndo" );
// Force our edit to update
updateValue();
}
const char* afxGuiSubstitutionField::getData( U32 inspectObjectIndex )
{
if( mField == NULL)
return "";
SimObject* target = mInspector->getInspectObject(inspectObjectIndex);
SimDataBlock* datablock = dynamic_cast<SimDataBlock*>(target);
if (datablock)
{
const char* current_subs = datablock->getSubstitution(mField->pFieldname, 0);
if (current_subs)
return StringTable->insert(avar("$$ %s", current_subs));
}
return StringTable->insert( "" );
}
/// Update this controls value to reflect that of the inspected field.
void afxGuiSubstitutionField::updateValue()
{
if( mInspector->getNumInspectObjects() > 1 )
{
// ??
return;
}
SimObject* target = mInspector->getInspectObject(0);
SimDataBlock* datablock = dynamic_cast<SimDataBlock*>(target);
if (datablock)
{
const char* current_subs = datablock->getSubstitution(mField->pFieldname, 0);
if (current_subs)
{
setValue(StringTable->insert(avar("$$ %s", current_subs)));
return;
}
}
setValue(StringTable->insert("$$ -- undefined --"));
}
void afxGuiSubstitutionField::setToolTip( StringTableEntry data )
{
mEdit->setDataField( StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile" );
mEdit->setDataField( StringTable->insert("hovertime"), NULL, "1000" );
mEdit->setDataField( StringTable->insert("tooltip"), NULL, data );
}
bool afxGuiSubstitutionField::onAdd()
{
if( !Parent::onAdd() )
return false;
return true;
}
GuiControl* afxGuiSubstitutionField::constructEditControl()
{
if (mField->doNotSubstitute)
{
GuiTextEditCtrl* retCtrl = new GuiTextEditCtrl();
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile" );
// Register the object
retCtrl->registerObject();
retCtrl->setText( StringTable->insert("n/a") );
retCtrl->setActive(false);
return retCtrl;
}
GuiControl* retCtrl = new GuiTextEditCtrl();
retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiInspectorTextEditProfile" );
// Register the object
retCtrl->registerObject();
char szBuffer[512];
dSprintf( szBuffer, 512, "%d.apply(%d.getText());",getId(), retCtrl->getId() );
retCtrl->setField("AltCommand", szBuffer );
retCtrl->setField("Validate", szBuffer );
return retCtrl;
}
void afxGuiSubstitutionField::setValue( const char* newValue )
{
if (!mField->doNotSubstitute)
{
GuiTextEditCtrl *ctrl = dynamic_cast<GuiTextEditCtrl*>( mEdit );
if ( ctrl != NULL )
ctrl->setText( newValue );
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// protected:
void afxGuiSubstitutionField::_executeSelectedCallback()
{
Con::executef( mInspector, "onFieldSelected", mCaption, ConsoleBaseType::getType(mField->type)->getTypeName(), "Substitution Statement" );
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,66 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_GUI_SUBSTITUTION_FIELD_H_
#define _AFX_GUI_SUBSTITUTION_FIELD_H_
#include "console/simFieldDictionary.h"
#include "gui/editor/inspector/field.h"
class afxGuiSubstitutionField : public GuiInspectorField
{
typedef GuiInspectorField Parent;
public:
afxGuiSubstitutionField(GuiInspector *inspector, GuiInspectorGroup* parent, SimFieldDictionary::Entry* field);
afxGuiSubstitutionField();
~afxGuiSubstitutionField() {};
DECLARE_CONOBJECT(afxGuiSubstitutionField);
DECLARE_CATEGORY("AFX");
virtual void setData( const char* data, bool callbacks = true );
virtual const char* getData( U32 inspectObjectIndex = 0 );
virtual void updateValue();
virtual void setToolTip( StringTableEntry data );
virtual bool onAdd();
virtual GuiControl* constructEditControl();
virtual void setValue( const char* newValue );
protected:
virtual void _executeSelectedCallback();
protected:
String subs_string;
};
#endif // _AFX_SUBSTITUTION_FIELD_H_

View file

@ -0,0 +1,328 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "gui/3d/guiTSControl.h"
#include "gfx/gfxDrawUtil.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/shapeBase.h"
#include "afx/ui/afxGuiTextHud.h"
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
Vector<afxGuiTextHud::HudTextSpec> afxGuiTextHud::text_items;
IMPLEMENT_CONOBJECT(afxGuiTextHud);
ConsoleDocClass( afxGuiTextHud,
"@brief Similar to GuiShapeNameHud, afxGuiTextHud displays ShapeBase object names but "
"also allows Gui Text effects.\n\n"
"@ingroup GuiGame\n"
);
afxGuiTextHud::afxGuiTextHud()
{
mFillColor.set( 0.25f, 0.25f, 0.25f, 0.25f );
mFrameColor.set( 0, 0, 0, 1 );
mTextColor.set( 0, 1, 0, 1 );
mShowFill = false;
mShowFrame = true;
mVerticalOffset = 0.5f;
mDistanceFade = 0.1f;
mLabelAllShapes = false;
mEnableControlObjectOcclusion = false;
}
void afxGuiTextHud::initPersistFields()
{
addGroup("Colors");
addField( "fillColor", TypeColorF, Offset( mFillColor, afxGuiTextHud ),
"...");
addField( "frameColor", TypeColorF, Offset( mFrameColor, afxGuiTextHud ),
"...");
addField( "textColor", TypeColorF, Offset( mTextColor, afxGuiTextHud ),
"...");
endGroup("Colors");
addGroup("Misc");
addField( "showFill", TypeBool, Offset( mShowFill, afxGuiTextHud ),
"...");
addField( "showFrame", TypeBool, Offset( mShowFrame, afxGuiTextHud ),
"...");
addField( "verticalOffset", TypeF32, Offset( mVerticalOffset, afxGuiTextHud ),
"...");
addField( "distanceFade", TypeF32, Offset( mDistanceFade, afxGuiTextHud ),
"...");
addField( "labelAllShapes", TypeBool, Offset( mLabelAllShapes, afxGuiTextHud ),
"...");
addField( "enableControlObjectOcclusion", TypeBool, Offset( mEnableControlObjectOcclusion, afxGuiTextHud ),
"...");
endGroup("Misc");
Parent::initPersistFields();
}
//----------------------------------------------------------------------------
/// Core rendering method for this control.
///
/// This method scans through all the current client ShapeBase objects.
/// If one is named, it displays the name and damage information for it.
///
/// Information is offset from the center of the object's bounding box,
/// unless the object is a PlayerObjectType, in which case the eye point
/// is used.
///
/// @param updateRect Extents of control.
void afxGuiTextHud::onRender( Point2I, const RectI &updateRect)
{
// Background fill first
if (mShowFill)
GFX->getDrawUtil()->drawRectFill(updateRect, mFillColor.toColorI());
// Must be in a TS Control
GuiTSCtrl *parent = dynamic_cast<GuiTSCtrl*>(getParent());
if (!parent) return;
// Must have a connection and control object
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn)
return;
GameBase * control = dynamic_cast<GameBase*>(conn->getControlObject());
if (!control)
return;
// Get control camera info
MatrixF cam;
Point3F camPos;
VectorF camDir;
conn->getControlCameraTransform(0,&cam);
cam.getColumn(3, &camPos);
cam.getColumn(1, &camDir);
F32 camFovCos;
conn->getControlCameraFov(&camFovCos);
camFovCos = mCos(mDegToRad(camFovCos) / 2);
// Visible distance info & name fading
F32 visDistance = gClientSceneGraph->getVisibleDistance();
F32 visDistanceSqr = visDistance * visDistance;
F32 fadeDistance = visDistance * mDistanceFade;
// Collision info. We're going to be running LOS tests and we
// don't want to collide with the control object.
static U32 losMask = TerrainObjectType | TerrainLikeObjectType | ShapeBaseObjectType;
if (!mEnableControlObjectOcclusion)
control->disableCollision();
if (mLabelAllShapes)
{
// This section works just like GuiShapeNameHud and renders labels for
// all the shapes.
// All ghosted objects are added to the server connection group,
// so we can find all the shape base objects by iterating through
// our current connection.
for (SimSetIterator itr(conn); *itr; ++itr)
{
///if ((*itr)->getTypeMask() & ShapeBaseObjectType)
///{
ShapeBase* shape = dynamic_cast<ShapeBase*>(*itr);
if ( shape ) {
if (shape != control && shape->getShapeName())
{
// Target pos to test, if it's a player run the LOS to his eye
// point, otherwise we'll grab the generic box center.
Point3F shapePos;
if (shape->getTypeMask() & PlayerObjectType)
{
MatrixF eye;
// Use the render eye transform, otherwise we'll see jittering
shape->getRenderEyeTransform(&eye);
eye.getColumn(3, &shapePos);
}
else
{
// Use the render transform instead of the box center
// otherwise it'll jitter.
MatrixF srtMat = shape->getRenderTransform();
srtMat.getColumn(3, &shapePos);
}
VectorF shapeDir = shapePos - camPos;
// Test to see if it's in range
F32 shapeDist = shapeDir.lenSquared();
if (shapeDist == 0 || shapeDist > visDistanceSqr)
continue;
shapeDist = mSqrt(shapeDist);
// Test to see if it's within our viewcone, this test doesn't
// actually match the viewport very well, should consider
// projection and box test.
shapeDir.normalize();
F32 dot = mDot(shapeDir, camDir);
if (dot < camFovCos)
continue;
// Test to see if it's behind something, and we want to
// ignore anything it's mounted on when we run the LOS.
RayInfo info;
shape->disableCollision();
SceneObject *mount = shape->getObjectMount();
if (mount)
mount->disableCollision();
bool los = !gClientContainer.castRay(camPos, shapePos,losMask, &info);
shape->enableCollision();
if (mount)
mount->enableCollision();
if (!los)
continue;
// Project the shape pos into screen space and calculate
// the distance opacity used to fade the labels into the
// distance.
Point3F projPnt;
shapePos.z += mVerticalOffset;
if (!parent->project(shapePos, &projPnt))
continue;
F32 opacity = (shapeDist < fadeDistance)? 1.0:
1.0 - (shapeDist - fadeDistance) / (visDistance - fadeDistance);
// Render the shape's name
drawName(Point2I((S32)projPnt.x, (S32)projPnt.y),shape->getShapeName(),opacity);
}
}
}
}
// This section renders all text added by afxGuiText effects.
for (S32 i = 0; i < text_items.size(); i++)
{
HudTextSpec* spec = &text_items[i];
if (spec->text && spec->text[0] != '\0')
{
VectorF shapeDir = spec->pos - camPos;
// do range test
F32 shapeDist = shapeDir.lenSquared();
if (shapeDist == 0 || shapeDist > visDistanceSqr)
continue;
shapeDist = mSqrt(shapeDist);
// Test to see if it's within our viewcone, this test doesn't
// actually match the viewport very well, should consider
// projection and box test.
shapeDir.normalize();
F32 dot = mDot(shapeDir, camDir);
if (dot < camFovCos)
continue;
// Test to see if it's behind something, and we want to
// ignore anything it's mounted on when we run the LOS.
RayInfo info;
if (spec->obj)
spec->obj->disableCollision();
bool los = !gClientContainer.castRay(camPos, spec->pos, losMask, &info);
if (spec->obj)
spec->obj->enableCollision();
if (!los)
continue;
// Project the shape pos into screen space.
Point3F projPnt;
if (!parent->project(spec->pos, &projPnt))
continue;
// Calculate the distance opacity used to fade text into the distance.
F32 opacity = (shapeDist < fadeDistance)? 1.0 : 1.0 - (shapeDist - fadeDistance) / (25.0f);
if (opacity > 0.01f)
drawName(Point2I((S32)projPnt.x, (S32)projPnt.y), spec->text, opacity, &spec->text_clr);
}
}
// Restore control object collision
if (!mEnableControlObjectOcclusion)
control->enableCollision();
// Border last
if (mShowFrame)
GFX->getDrawUtil()->drawRect(updateRect, mFrameColor.toColorI());
reset();
}
//----------------------------------------------------------------------------
/// Render object names.
///
/// Helper function for GuiShapeNameHud::onRender
///
/// @param offset Screen coordinates to render name label. (Text is centered
/// horizontally about this location, with bottom of text at
/// specified y position.)
/// @param name String name to display.
/// @param opacity Opacity of name (a fraction).
void afxGuiTextHud::drawName(Point2I offset, const char *name, F32 opacity, LinearColorF* color)
{
// Center the name
offset.x -= mProfile->mFont->getStrWidth((const UTF8 *)name) / 2;
offset.y -= mProfile->mFont->getHeight();
// Deal with opacity and draw.
LinearColorF draw_color = (color) ? *color : mTextColor;
draw_color.alpha *= opacity;
GFX->getDrawUtil()->setBitmapModulation(draw_color.toColorI());
GFX->getDrawUtil()->drawText(mProfile->mFont, offset, name);
GFX->getDrawUtil()->clearBitmapModulation();
}
void afxGuiTextHud::addTextItem(const Point3F& pos, const char* text, LinearColorF& color, SceneObject* obj)
{
if (!text || text[0] == '\0')
return;
HudTextSpec spec;
spec.pos = pos;
spec.text = text;
spec.text_clr = color;
spec.obj = obj;
text_items.push_back(spec);
}
void afxGuiTextHud::reset()
{
text_items.clear();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,87 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_GUI_TEXT_HUD_H_
#define _AFX_GUI_TEXT_HUD_H_
#include "gui/core/guiControl.h"
//----------------------------------------------------------------------------
/// Displays name & damage above shape objects.
///
/// This control displays the name and damage value of all named
/// ShapeBase objects on the client. The name and damage of objects
/// within the control's display area are overlayed above the object.
///
/// This GUI control must be a child of a TSControl, and a server connection
/// and control object must be present.
///
/// This is a stand-alone control and relies only on the standard base GuiControl.
class afxGuiTextHud : public GuiControl
{
typedef GuiControl Parent;
struct HudTextSpec
{
Point3F pos;
const char* text;
LinearColorF text_clr;
SceneObject* obj;
};
static Vector<HudTextSpec> text_items;
// field data
LinearColorF mFillColor;
LinearColorF mFrameColor;
LinearColorF mTextColor;
F32 mVerticalOffset;
F32 mDistanceFade;
bool mShowFrame;
bool mShowFill;
bool mLabelAllShapes;
bool mEnableControlObjectOcclusion;
protected:
void drawName( Point2I offset, const char *buf, F32 opacity, LinearColorF* color=0);
public:
afxGuiTextHud();
// GuiControl
virtual void onRender(Point2I offset, const RectI &updateRect);
static void initPersistFields();
static void addTextItem(const Point3F& pos, const char* text, LinearColorF& color, SceneObject* obj=0);
static void reset();
DECLARE_CONOBJECT( afxGuiTextHud );
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif //_AFX_GUI_TEXT_HUD_H_

View file

@ -0,0 +1,37 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_PROGRESS_BASE_H_
#define _AFX_PROGRESS_BASE_H_
class afxProgressBase
{
public:
virtual void setProgress(F32 value)=0;
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif //_AFX_PROGRESS_BASE_H_

View file

@ -0,0 +1,393 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
//-------------------------------------
//
// Bitmap Button Contrl
// Set 'bitmap' comsole field to base name of bitmaps to use. This control will
// append '_n' for normal
// append '_h' for hilighted
// append '_d' for depressed
//
// if bitmap cannot be found it will use the default bitmap to render.
//
// if the extent is set to (0,0) in the gui editor and appy hit, this control will
// set it's extent to be exactly the size of the normal bitmap (if present)
//
#include "afx/arcaneFX.h"
#include "console/engineAPI.h"
#include "gfx/gfxDrawUtil.h"
#include "afx/ui/afxSpellButton.h"
#include "afx/afxSpellBook.h"
#include "afx/afxMagicSpell.h"
#include "afx/rpg/afxRPGMagicSpell.h"
IMPLEMENT_CONOBJECT(afxSpellButton);
ConsoleDocClass( afxSpellButton,
"@brief A GUI button with some special features that are useful for casting AFX spells.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
#define COOLDOWN_PROFILE &GFXDefaultGUIProfile, avar("%s() - Cooldown Texture (line %d)", __FUNCTION__, __LINE__)
StringTableEntry afxSpellButton::sUnknownSpellBitmap = "";
StringTableEntry afxSpellButton::sSpellCooldownBitmaps = "";
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
afxSpellButton::afxSpellButton()
{
if (sUnknownSpellBitmap == NULL)
sUnknownSpellBitmap = ST_NULLSTRING;
if (sSpellCooldownBitmaps == NULL)
sSpellCooldownBitmaps = ST_NULLSTRING;
mBitmapName = ST_NULLSTRING;
setExtent(140, 30);
spellbook = NULL;
book_slot.set(0, 0);
}
afxSpellButton::~afxSpellButton()
{
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
void afxSpellButton::initPersistFields()
{
addField("bitmap", TypeFilename, Offset(mBitmapName, afxSpellButton),
"...");
addField("book_slot", TypePoint2I, Offset(book_slot, afxSpellButton),
"...");
Parent::initPersistFields();
Con::addVariable("pref::afxSpellButton::unknownSpellBitmap", TypeFilename, &sUnknownSpellBitmap);
Con::addVariable("pref::afxSpellButton::spellCooldownBitmaps", TypeFilename, &sSpellCooldownBitmaps);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
bool afxSpellButton::onAdd()
{
if (!Parent::onAdd())
return false;
if (sSpellCooldownBitmaps != NULL)
{
char buffer[256];
for (int i = 0; i < NUM_COOLDOWN_FRAMES; i++)
{
dSprintf(buffer, 256, "%s_%.2d", sSpellCooldownBitmaps, i);
cooldown_txrs[i].set(buffer, COOLDOWN_PROFILE);
}
}
return true;
}
bool afxSpellButton::onWake()
{
if (! Parent::onWake())
return false;
setActive(true);
update_bitmap();
return true;
}
void afxSpellButton::onSleep()
{
mTextureNormal = NULL;
mTextureHilight = NULL;
mTextureDepressed = NULL;
Parent::onSleep();
}
void afxSpellButton::onMouseEnter(const GuiEvent &event)
{
Parent::onMouseEnter(event);
Con::executef(this, "onMouseEnter");
}
void afxSpellButton::onMouseLeave(const GuiEvent &event)
{
Parent::onMouseLeave(event);
Con::executef(this, "onMouseLeave");
}
void afxSpellButton::inspectPostApply()
{
// if the extent is set to (0,0) in the gui editor and apply hit, this control will
// set it's extent to be exactly the size of the normal bitmap (if present)
Parent::inspectPostApply();
if ((getWidth() == 0) && (getHeight() == 0) && mTextureNormal)
{
setExtent(mTextureNormal->getWidth(), mTextureNormal->getHeight());
}
}
void afxSpellButton::setBitmap(const char *name, bool placeholder)
{
mBitmapName = (name) ? StringTable->insert(name) : ST_NULLSTRING;
if (!isAwake())
return;
if (mBitmapName != ST_NULLSTRING)
{
char buffer[1024];
char *p;
if (placeholder)
{
dStrcpy(buffer, name);
p = buffer + dStrlen(buffer);
dStrcpy(p, "_i");
mTextureInactive.set(buffer, COOLDOWN_PROFILE);
mTextureNormal = mTextureInactive;
mTextureHilight = mTextureInactive;
mTextureDepressed = mTextureInactive;
setActive(false);
}
else
{
dStrcpy(buffer, name);
p = buffer + dStrlen(buffer);
dStrcpy(p, "_n");
mTextureNormal.set(buffer, COOLDOWN_PROFILE);
dStrcpy(p, "_h");
mTextureHilight.set(buffer, COOLDOWN_PROFILE);
if (!mTextureHilight)
mTextureHilight = mTextureNormal;
dStrcpy(p, "_d");
mTextureDepressed.set(buffer, COOLDOWN_PROFILE);
if (!mTextureDepressed)
mTextureDepressed = mTextureHilight;
dStrcpy(p, "_i");
mTextureInactive.set(buffer, COOLDOWN_PROFILE);
if (!mTextureInactive)
mTextureInactive = mTextureNormal;
setActive(true);
}
}
else
{
mTextureNormal = NULL;
mTextureHilight = NULL;
mTextureDepressed = NULL;
mTextureInactive = NULL;
}
setUpdate();
}
void afxSpellButton::onRender(Point2I offset, const RectI& updateRect)
{
enum { NORMAL, HILIGHT, DEPRESSED, INACTIVE } state = NORMAL;
if (mActive)
{
if (mMouseOver) state = HILIGHT;
if (mDepressed || mStateOn) state = DEPRESSED;
}
else
state = INACTIVE;
switch (state)
{
case NORMAL: renderButton(mTextureNormal, offset, updateRect); break;
case HILIGHT: renderButton(mTextureHilight ? mTextureHilight : mTextureNormal, offset, updateRect); break;
case DEPRESSED: renderButton(mTextureDepressed, offset, updateRect); break;
case INACTIVE: renderButton(mTextureInactive ? mTextureInactive : mTextureNormal, offset, updateRect); break;
}
}
void afxSpellButton::onDeleteNotify(SimObject* obj)
{
// Handle Shape Deletion
afxSpellBook* book = dynamic_cast<afxSpellBook*>(obj);
if (book != NULL)
{
if (book == spellbook)
{
spellbook = NULL;
setBitmap("");
setVisible(false);
return;
}
}
Parent::onDeleteNotify(obj);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// protected:
void afxSpellButton::renderButton(GFXTexHandle &texture, Point2I &offset,
const RectI& updateRect)
{
if (texture)
{
RectI rect(offset, getExtent());
GFX->getDrawUtil()->clearBitmapModulation();
GFX->getDrawUtil()->drawBitmapStretch(texture, rect);
if (spellbook)
{
F32 cooldown = spellbook->getCooldownFactor(book_slot.x, book_slot.y);
if (cooldown < 1.0f)
{
if (cooldown_txrs[(int)(36.0f*cooldown)])
GFX->getDrawUtil()->drawBitmapStretch(cooldown_txrs[(int)(36.0f*cooldown)], rect);
}
}
renderChildControls( offset, updateRect);
}
else
Parent::onRender(offset, updateRect);
}
void afxSpellButton::update_bitmap()
{
const char* icon_name = 0;
bool is_placeholder = false;
if (spellbook)
{
icon_name = spellbook->getSpellIcon(book_slot.x, book_slot.y);
is_placeholder = spellbook->isPlaceholder(book_slot.x, book_slot.y);
if (icon_name && icon_name[0] == '\0')
icon_name = sUnknownSpellBitmap;
}
if (icon_name)
{
setBitmap(icon_name, is_placeholder);
setVisible(true);
}
else
{
setBitmap("");
setVisible(false);
}
}
void afxSpellButton::setSpellBook(afxSpellBook* book, U8 page)
{
book_slot.x = page;
if (spellbook)
clearNotify(spellbook);
spellbook = book;
update_bitmap();
if (spellbook)
deleteNotify(spellbook);
}
void afxSpellButton::setPage(U8 page)
{
book_slot.x = page;
update_bitmap();
}
char* afxSpellButton::formatDesc(char* buffer, int len) const
{
return (spellbook) ? spellbook->formatDesc(buffer, len, book_slot.x, book_slot.y) : (char*)"";
}
afxMagicSpellData* afxSpellButton::getSpellDataBlock() const
{
return (spellbook) ? spellbook->getSpellData(book_slot.x, book_slot.y) : 0;
}
afxRPGMagicSpellData* afxSpellButton::getSpellRPGDataBlock() const
{
return (spellbook) ? spellbook->getSpellRPGData(book_slot.x, book_slot.y) : 0;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
DefineEngineMethod( afxSpellButton, onSpellbookChange, void, ( afxSpellBook* spellbook, unsigned int page ),,
"Notify an afxSpellButton when its associated spellbook has changed.\n" )
{
object->setSpellBook(spellbook, (U8)page);
}
DefineEngineMethod( afxSpellButton, onTurnPage, void, ( unsigned int page ),,
"Notify an afxSpellButton when the spellbook turns to a new page.\n" )
{
object->setPage((U8)page);
}
DefineEngineMethod( afxSpellButton, getSpellDescription, const char*, (),,
"Get the text description of a spell.\n" )
{
char buf[1024];
return object->formatDesc(buf, 1024);
}
DefineEngineMethod( afxSpellButton, getSpellDataBlock, S32, (),,
"Get the spell's datablock.\n" )
{
afxMagicSpellData* spell_data = object->getSpellDataBlock();
return (spell_data) ? spell_data->getId() : -1;
}
DefineEngineMethod( afxSpellButton, getSpellRPGDataBlock, S32, (),,
"Get the spell's RPG datablock.\n" )
{
afxRPGMagicSpellData* spell_rpg_data = object->getSpellRPGDataBlock();
return (spell_rpg_data) ? spell_rpg_data->getId() : -1;
}
DefineEngineMethod( afxSpellButton, useFreeTargeting, bool, (),,
"Test if spell uses free targeting.\n" )
{
afxRPGMagicSpellData* spell_rpg_data = object->getSpellRPGDataBlock();
return (spell_rpg_data) ? (spell_rpg_data->spell_target == afxRPGMagicSpellData::TARGET_FREE) : false;
}
DefineEngineMethod( afxSpellButton, getFreeTargetStyle, S32, (),,
"Get the free targeting style used by the spell.\n" )
{
afxRPGMagicSpellData* spell_rpg_data = object->getSpellRPGDataBlock();
return (spell_rpg_data) ? spell_rpg_data->free_target_style : 0;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,103 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_SPELL_BUTTON_H_
#define _AFX_SPELL_BUTTON_H_
#include "gui/buttons/guiButtonCtrl.h"
///-------------------------------------
/// Bitmap Button Contrl
/// Set 'bitmap' comsole field to base name of bitmaps to use. This control will
/// append '_n' for normal
/// append '_h' for hilighted
/// append '_d' for depressed
///
/// if bitmap cannot be found it will use the default bitmap to render.
///
/// if the extent is set to (0,0) in the gui editor and appy hit, this control will
/// set it's extent to be exactly the size of the normal bitmap (if present)
///
class afxSpellBook;
class afxMagicSpellData;
class afxRPGMagicSpellData;
class afxSpellButton : public GuiButtonCtrl
{
private:
typedef GuiButtonCtrl Parent;
enum { NUM_COOLDOWN_FRAMES = 36 };
protected:
static StringTableEntry sUnknownSpellBitmap;
static StringTableEntry sSpellCooldownBitmaps;
StringTableEntry mBitmapName;
GFXTexHandle mTextureNormal;
GFXTexHandle mTextureHilight;
GFXTexHandle mTextureDepressed;
GFXTexHandle mTextureInactive;
afxSpellBook* spellbook;
Point2I book_slot;
GFXTexHandle cooldown_txrs[NUM_COOLDOWN_FRAMES];
void update_bitmap();
void renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect);
public:
/*C*/ afxSpellButton();
/*D*/ ~afxSpellButton();
void setBitmap(const char *name, bool placholder=false);
void setSpellBook(afxSpellBook*, U8 page);
void setPage(U8 page);
char* formatDesc(char* buffer, int len) const;
afxMagicSpellData* getSpellDataBlock() const;
afxRPGMagicSpellData* getSpellRPGDataBlock() const;
virtual bool onAdd();
virtual bool onWake();
virtual void onSleep();
virtual void inspectPostApply();
virtual void onMouseEnter(const GuiEvent &event);
virtual void onMouseLeave(const GuiEvent &event);
virtual void onRender(Point2I offset, const RectI &updateRect);
virtual void onDeleteNotify(SimObject*);
static void initPersistFields();
DECLARE_CONOBJECT(afxSpellButton);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif //_GUI_BITMAP_BUTTON_CTRL_H

View file

@ -0,0 +1,162 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "console/engineAPI.h"
#include "gui/core/guiControl.h"
#include "gfx/gfxDrawUtil.h"
#include "afx/ui/afxProgressBase.h"
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
class afxSpellCastBar : public GuiControl, public afxProgressBase
{
typedef GuiControl Parent;
bool want_border;
bool want_background;
bool use_alt_final_color;
LinearColorF rgba_background;
LinearColorF rgba_border;
LinearColorF rgba_fill;
LinearColorF rgba_fill_final;
F32 fraction;
public:
/*C*/ afxSpellCastBar();
virtual void onRender(Point2I, const RectI&);
void setFraction(F32 frac);
F32 getFraction() const { return fraction; }
virtual void setProgress(F32 value) { setFraction(value); }
virtual void onStaticModified(const char* slotName, const char* newValue = NULL);
static void initPersistFields();
DECLARE_CONOBJECT(afxSpellCastBar);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
IMPLEMENT_CONOBJECT(afxSpellCastBar);
ConsoleDocClass( afxSpellCastBar,
"@brief A GUI progress bar useful as a spell casting bar.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
afxSpellCastBar::afxSpellCastBar()
{
want_border = true;
want_background = true;
use_alt_final_color = false;
rgba_background.set(0.0f, 0.0f, 0.0f, 0.5f);
rgba_border.set(0.5f, 0.5f, 0.5f, 1.0f);
rgba_fill.set(0.0f, 1.0f, 1.0f, 1.0f);
rgba_fill_final.set(0.0f, 1.0f, 1.0f, 1.0f);
fraction = 0.5f;
}
void afxSpellCastBar::setFraction(F32 frac)
{
fraction = mClampF(frac, 0.0f, 1.0f);
}
void afxSpellCastBar::onStaticModified(const char* slotName, const char* newValue)
{
Parent::onStaticModified(slotName, newValue);
if (dStricmp(slotName, "fillColorFinal") == 0)
use_alt_final_color = true;
}
// STATIC
void afxSpellCastBar::initPersistFields()
{
addGroup("Colors");
addField( "backgroundColor", TypeColorF, Offset(rgba_background, afxSpellCastBar),
"...");
addField( "borderColor", TypeColorF, Offset(rgba_border, afxSpellCastBar),
"...");
addField( "fillColor", TypeColorF, Offset(rgba_fill, afxSpellCastBar),
"...");
addField( "fillColorFinal", TypeColorF, Offset(rgba_fill_final, afxSpellCastBar),
"...");
endGroup("Colors");
Parent::initPersistFields();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
void afxSpellCastBar::onRender(Point2I offset, const RectI &updateRect)
{
LinearColorF color;
// draw the background
if (want_background)
{
color.set(rgba_background.red, rgba_background.green, rgba_background.blue, rgba_background.alpha*fade_amt);
GFX->getDrawUtil()->drawRectFill(updateRect, color.toColorI());
}
// calculate the rectangle dimensions
RectI rect(updateRect);
rect.extent.x = (S32)(rect.extent.x * fraction);
// draw the filled part of bar
if (fraction >= 1.0f && use_alt_final_color)
color.set(rgba_fill_final.red, rgba_fill_final.green, rgba_fill_final.blue, rgba_fill_final.alpha*fade_amt);
else
color.set(rgba_fill.red, rgba_fill.green, rgba_fill.blue, rgba_fill.alpha*fade_amt);
GFX->getDrawUtil()->drawRectFill(rect, color.toColorI());
// draw the border
if (want_border)
{
color.set(rgba_border.red, rgba_border.green, rgba_border.blue, rgba_border.alpha*fade_amt);
GFX->getDrawUtil()->drawRect(updateRect, color.toColorI());
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
DefineEngineMethod(afxSpellCastBar, setProgress, void, (float percentDone),,
"Set the progress percentage on the progress-bar.\n\n"
"@ingroup AFX")
{
object->setFraction(percentDone);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,24 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,202 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "console/engineAPI.h"
#include "gui/core/guiControl.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/shapeBase.h"
#include "gfx/gfxDrawUtil.h"
#include "afx/ui/afxProgressBase.h"
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
class afxStatusBar : public GuiControl, public afxProgressBase
{
typedef GuiControl Parent;
LinearColorF rgba_fill;
F32 fraction;
ShapeBase* shape;
bool show_energy;
bool monitor_player;
public:
/*C*/ afxStatusBar();
virtual void onRender(Point2I, const RectI&);
void setFraction(F32 frac);
F32 getFraction() const { return fraction; }
virtual void setProgress(F32 value) { setFraction(value); }
void setShape(ShapeBase* s);
void clearShape() { setShape(NULL); }
virtual bool onWake();
virtual void onSleep();
virtual void onMouseDown(const GuiEvent &event);
virtual void onDeleteNotify(SimObject*);
static void initPersistFields();
DECLARE_CONOBJECT(afxStatusBar);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
IMPLEMENT_CONOBJECT(afxStatusBar);
ConsoleDocClass( afxStatusBar,
"@brief A GUI status bar for tracking and displaying health and energy of ShapeBase "
"objects.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
afxStatusBar::afxStatusBar()
{
rgba_fill.set(0.0f, 1.0f, 1.0f, 1.0f);
fraction = 1.0f;
shape = 0;
show_energy = false;
monitor_player = false;
}
void afxStatusBar::setFraction(F32 frac)
{
fraction = mClampF(frac, 0.0f, 1.0f);
}
void afxStatusBar::setShape(ShapeBase* s)
{
if (shape)
clearNotify(shape);
shape = s;
if (shape)
deleteNotify(shape);
}
void afxStatusBar::onDeleteNotify(SimObject* obj)
{
if (shape == (ShapeBase*)obj)
{
shape = NULL;
return;
}
Parent::onDeleteNotify(obj);
}
bool afxStatusBar::onWake()
{
if (!Parent::onWake())
return false;
return true;
}
void afxStatusBar::onSleep()
{
//clearShape();
Parent::onSleep();
}
// STATIC
void afxStatusBar::initPersistFields()
{
addField("fillColor", TypeColorF, Offset(rgba_fill, afxStatusBar),
"...");
addField("displayEnergy", TypeBool, Offset(show_energy, afxStatusBar),
"...");
addField("monitorPlayer", TypeBool, Offset(monitor_player, afxStatusBar),
"...");
Parent::initPersistFields();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//
void afxStatusBar::onRender(Point2I offset, const RectI &updateRect)
{
if (!shape)
return;
if (shape->getDamageState() != ShapeBase::Enabled)
fraction = 0.0f;
else
fraction = (show_energy) ? shape->getEnergyValue() : (1.0f - shape->getDamageValue());
// set alpha value for the fill area
rgba_fill.alpha = 1.0f;
// calculate the rectangle dimensions
RectI rect(updateRect);
rect.extent.x = (S32)(rect.extent.x*fraction);
// draw the filled part of bar
GFX->getDrawUtil()->drawRectFill(rect, rgba_fill.toColorI());
}
void afxStatusBar::onMouseDown(const GuiEvent &event)
{
GuiControl *parent = getParent();
if (parent)
parent->onMouseDown(event);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
DefineEngineMethod(afxStatusBar, setProgress, void, (float percentDone),,
"Set the progress percentage on the status-bar.\n\n"
"@ingroup AFX")
{
object->setFraction(percentDone);
}
DefineEngineMethod(afxStatusBar, setShape, void, (ShapeBase* shape),,
"Associate a ShapeBase-derived object with the status-bar.\n\n"
"@ingroup AFX")
{
object->setShape(shape);
}
DefineEngineMethod(afxStatusBar, clearShape, void, (),,
"Clear out any ShapeBase-derived object associated with the status-bar.\n\n"
"@ingroup AFX")
{
object->clearShape();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,24 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,52 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/ui/afxStatusBox.h"
IMPLEMENT_CONOBJECT(afxStatusBox);
ConsoleDocClass( afxStatusBox,
"@brief A simple GUI control used to contain player status bars and a label.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
afxStatusBox::afxStatusBox()
{
}
void afxStatusBox::onMouseDown(const GuiEvent &event)
{
Parent::onMouseDown(event);
Con::executef(this, "onMouseDown");
}
void afxStatusBox::onSleep()
{
Parent::onSleep();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,50 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_STATUS_BOX_H_
#define _AFX_STATUS_BOX_H_
#include "afx/arcaneFX.h"
#include "gui/controls/guiBitmapCtrl.h"
class afxStatusBox : public GuiBitmapCtrl
{
private:
typedef GuiBitmapCtrl Parent;
public:
/*C*/ afxStatusBox();
virtual void onMouseDown(const GuiEvent &event);
virtual void onSleep();
DECLARE_CONOBJECT(afxStatusBox);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif //_AFX_STATUS_BOX_H_

View file

@ -0,0 +1,49 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/ui/afxStatusLabel.h"
IMPLEMENT_CONOBJECT(afxStatusLabel);
ConsoleDocClass( afxStatusLabel,
"@brief A simple GUI control used for a player status label.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
afxStatusLabel::afxStatusLabel()
{
}
void afxStatusLabel::onMouseDown(const GuiEvent &event)
{
GuiControl *parent = getParent();
if (parent)
parent->onMouseDown(event);
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,49 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_STATUS_LABEL_H_
#define _AFX_STATUS_LABEL_H_
#include "afx/arcaneFX.h"
#include "gui/controls/guiMLTextCtrl.h"
class afxStatusLabel : public GuiMLTextCtrl
{
private:
typedef GuiMLTextCtrl Parent;
public:
/*C*/ afxStatusLabel();
virtual void onMouseDown(const GuiEvent &event);
DECLARE_CONOBJECT(afxStatusLabel);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif //_AFX_STATUS_LABEL_H_

View file

@ -0,0 +1,367 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Some of the object selection code in this file is based on functionality described
// in the following resource:
//
// Object Selection in Torque by Dave Myers
// http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#include "afx/arcaneFX.h"
#include "console/engineAPI.h"
#include "gui/core/guiCanvas.h"
#include "T3D/gameBase/gameConnection.h"
#include "T3D/gameFunctions.h"
#include "afx/ui/afxTSCtrl.h"
#include "afx/afxSpellBook.h"
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
IMPLEMENT_CONOBJECT(afxTSCtrl);
ConsoleDocClass( afxTSCtrl,
"@brief A customized variation of GameTSCtrl.\n\n"
"@ingroup afxGUI\n"
"@ingroup AFX\n"
);
afxTSCtrl::afxTSCtrl()
{
mMouse3DVec.zero();
mMouse3DPos.zero();
mouse_dn_timestamp = 0;
spellbook = NULL;
clearTargetingMode();
}
bool afxTSCtrl::processCameraQuery(CameraQuery *camq)
{
GameUpdateCameraFov();
return GameProcessCameraQuery(camq);
}
void afxTSCtrl::renderWorld(const RectI &updateRect)
{
GameRenderWorld();
}
void afxTSCtrl::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent)
{
Parent::getCursor(cursor, showCursor, lastGuiEvent);
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn || !conn->getRolloverObj())
return;
GuiCanvas *pRoot = getRoot();
if( !pRoot )
return;
PlatformWindow* pWindow = pRoot->getPlatformWindow();
AssertFatal(pWindow != NULL, "GuiControl without owning platform window! This should not be possible.");
PlatformCursorController* pController = pWindow->getCursorController();
AssertFatal(pController != NULL, "PlatformWindow without an owned CursorController!");
if(pRoot->mCursorChanged != PlatformCursorController::curHand)
{
// We've already changed the cursor, so set it back before we change it again.
if(pRoot->mCursorChanged != -1)
pController->popCursor();
// Now change the cursor shape
pController->pushCursor(PlatformCursorController::curHand);
pRoot->mCursorChanged = PlatformCursorController::curHand;
}
else if(pRoot->mCursorChanged != -1)
{
// Restore the cursor we changed
pController->popCursor();
pRoot->mCursorChanged = -1;
}
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
void afxTSCtrl::onMouseDown(const GuiEvent &evt)
{
//Con::printf("#### afxTSCtrl::onLeftMouseDown() ####");
// save a timestamp so we can measure how long the button is down
mouse_dn_timestamp = Platform::getRealMilliseconds();
GuiCanvas* Canvas = getRoot();
// clear button down status because the ActionMap is going to capture
// the mouse and the button up will never happen
Canvas->clearMouseButtonDown();
// indicate that processing of event should continue (pass down to ActionMap)
Canvas->setConsumeLastInputEvent(false);
}
void afxTSCtrl::onRightMouseDown(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onRightMouseDown() ####");
GuiCanvas* Canvas = getRoot();
// clear right button down status because the ActionMap is going to capture
// the mouse and the right button up will never happen
Canvas->clearMouseRightButtonDown();
// indicate that processing of event should continue (pass down to ActionMap)
Canvas->setConsumeLastInputEvent(false);
}
void afxTSCtrl::onMouseMove(const GuiEvent& evt)
{
AssertFatal(!targeting_mode.empty(), "Error, undefined targeting mode.");
Targeting targeting = targeting_mode.last();
if (targeting.mode == arcaneFX::TARGETING_OFF || targeting.check != arcaneFX::TARGET_CHECK_ON_MOUSE_MOVE)
return;
performTargeting(evt.mousePoint, targeting.mode);
}
void afxTSCtrl::onRender(Point2I offset, const RectI &updateRect)
{
GameConnection* con = GameConnection::getConnectionToServer();
#if defined(BROKEN_DAMAGEFLASH_WHITEOUT_BLACKOUT)
bool skipRender = (!con);
#else
bool skipRender = (!con ||
(con->getWhiteOut() >= 1.f) ||
(con->getDamageFlash() >= 1.f) ||
(con->getBlackOut() >= 1.f));
#endif
if (!skipRender)
Parent::onRender(offset, updateRect);
GFX->setViewport(updateRect);
}
void afxTSCtrl::advanceTime(F32 dt)
{
AssertFatal(!targeting_mode.empty(), "Error, undefined targeting mode.");
Targeting targeting = targeting_mode.last();
if (targeting.mode == arcaneFX::TARGETING_OFF || targeting.check != arcaneFX::TARGET_CHECK_POLL)
return;
GuiCanvas* Canvas = getRoot();
Point2I cursor_pos;
if (Canvas && Canvas->getLastCursorPoint(cursor_pos))
{
performTargeting(cursor_pos, targeting.mode);
}
};
void afxTSCtrl::performTargeting(const Point2I& mousePoint, U8 mode)
{
GuiCanvas* Canvas = getRoot();
if (mode != arcaneFX::TARGETING_FREE && !Canvas->isCursorON())
return;
MatrixF cam_xfm;
Point3F dummy_pt;
if (GameGetCameraTransform(&cam_xfm, &dummy_pt))
{
// get cam pos
Point3F cameraPoint; cam_xfm.getColumn(3,&cameraPoint);
// construct 3D screen point from mouse coords
Point3F screen_pt((F32)mousePoint.x, (F32)mousePoint.y, 1.0f);
// convert screen point to world point
bool bad_cam = mIsZero(mLastCameraQuery.farPlane);
Point3F world_pt;
if (!bad_cam && unproject(screen_pt, &world_pt))
{
Point3F mouseVec = world_pt - cameraPoint;
mouseVec.normalizeSafe();
mMouse3DPos = cameraPoint;
mMouse3DVec = mouseVec;
F32 selectRange = arcaneFX::sTargetSelectionRange;
Point3F mouseScaled = mouseVec*selectRange;
Point3F rangeEnd = cameraPoint + mouseScaled;
if (mode == arcaneFX::TARGETING_STANDARD)
arcaneFX::rolloverRayCast(cameraPoint, rangeEnd, arcaneFX::sTargetSelectionMask);
else if (mode == arcaneFX::TARGETING_FREE)
arcaneFX::freeTargetingRayCast(cameraPoint, rangeEnd, arcaneFX::sFreeTargetSelectionMask);
}
}
}
void afxTSCtrl::onMouseEnter(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onMouseEnter() ####");
}
void afxTSCtrl::onMouseDragged(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onMouseDragged() ####");
}
void afxTSCtrl::onMouseLeave(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onMouseLeave() ####");
}
bool afxTSCtrl::onMouseWheelUp(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onMouseWheelUp() ####");
Con::executef(this, "onMouseWheelUp");
return true;
}
bool afxTSCtrl::onMouseWheelDown(const GuiEvent& evt)
{
//Con::printf("#### afxTSCtrl::onMouseWheelDown() ####");
Con::executef(this, "onMouseWheelDown");
return true;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
void afxTSCtrl::setSpellBook(afxSpellBook* book)
{
if (book != spellbook)
{
spellbook = book;
Con::executef(this, "onSpellbookChange", (spellbook) ? spellbook->getIdString() : "");
}
}
void afxTSCtrl::clearTargetingMode()
{
targeting_mode.clear();
pushTargetingMode(arcaneFX::TARGETING_OFF, arcaneFX::TARGET_CHECK_POLL);
}
void afxTSCtrl::pushTargetingMode(U8 mode, U8 check)
{
switch (mode)
{
case arcaneFX::TARGETING_OFF:
case arcaneFX::TARGETING_STANDARD:
case arcaneFX::TARGETING_FREE:
break;
default:
Con::errorf("afxTSCtrl::setTargetingMode() -- unknown targeting mode [%d].", mode);
return;
}
switch (check)
{
case arcaneFX::TARGET_CHECK_POLL:
case arcaneFX::TARGET_CHECK_ON_MOUSE_MOVE:
break;
default:
Con::errorf("afxTSCtrl::setTargetingMode() -- unknown targeting check method [%d].", check);
return;
}
Targeting targeting = { mode, check };
targeting_mode.push_back(targeting);
}
void afxTSCtrl::popTargetingMode()
{
if (targeting_mode.size() <= 1)
return ;
targeting_mode.pop_back();
}
U8 afxTSCtrl::getTargetingMode()
{
return (targeting_mode.size() > 0) ? targeting_mode.last().mode : arcaneFX::TARGETING_OFF;
}
U8 afxTSCtrl::getTargetingCheckMethod()
{
return (targeting_mode.size() > 0) ? targeting_mode.last().check : arcaneFX::TARGET_CHECK_POLL;
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
DefineEngineMethod(afxTSCtrl, setSpellBook, void, (afxSpellBook* spellbook),,
"Associate a spellbook with an afxTSCtrl.\n\n"
"@ingroup AFX")
{
object->setSpellBook(spellbook);
}
DefineEngineMethod(afxTSCtrl, pushTargetingMode, void, (unsigned int mode, unsigned int checkMethod), ((U32)arcaneFX::TARGETING_OFF, (U32)arcaneFX::TARGET_CHECK_POLL),
"Push a new targeting-mode onto a statck of modes.\n\n"
"@ingroup AFX")
{
object->pushTargetingMode((U8)mode, (U8)checkMethod);
}
DefineEngineMethod(afxTSCtrl, popTargetingMode, void, (),,
"Pop the targeting-mode off a statck of modes.\n\n"
"@ingroup AFX")
{
object->popTargetingMode();
}
DefineEngineMethod(afxTSCtrl, getTargetingMode, S32, (),,
"Get the current targeting-mode.\n\n"
"@ingroup AFX")
{
return object->getTargetingMode();
}
DefineEngineMethod(afxTSCtrl, getMouse3DVec, Point3F, (),,
"Get the 3D direction vector for the mouse cursor.\n\n"
"@ingroup AFX")
{
return object->getMouse3DVec();
}
DefineEngineMethod(afxTSCtrl, getMouse3DPos, Point3F, (),,
"Get the 3D position of the mouse cursor.\n\n"
"@ingroup AFX")
{
return object->getMouse3DPos();
}
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//

View file

@ -0,0 +1,96 @@
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
// Copyright (C) 2015 Faust Logic, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#ifndef _AFX_TS_CTRL_H_
#define _AFX_TS_CTRL_H_
#include "app/game.h"
#include "gui/3d/guiTSControl.h"
#include "core/iTickable.h"
class GameBase;
class afxSpellBook;
//----------------------------------------------------------------------------
class afxTSCtrl : public GuiTSCtrl, public virtual ITickable
{
private:
struct Targeting
{
U8 mode;
U8 check;
};
typedef GuiTSCtrl Parent;
Point3F mMouse3DVec;
Point3F mMouse3DPos;
U32 mouse_dn_timestamp;
afxSpellBook* spellbook;
Vector<Targeting> targeting_mode;
public:
/*C*/ afxTSCtrl();
virtual bool processCameraQuery(CameraQuery *query);
virtual void renderWorld(const RectI &updateRect);
virtual void onRender(Point2I offset, const RectI &updateRect);
virtual void getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent);
virtual void onMouseDown(const GuiEvent&);
virtual void onMouseMove(const GuiEvent&);
virtual void onMouseDragged(const GuiEvent&);
virtual void onMouseEnter(const GuiEvent&);
virtual void onMouseLeave(const GuiEvent&);
virtual bool onMouseWheelUp(const GuiEvent&);
virtual bool onMouseWheelDown(const GuiEvent&);
virtual void onRightMouseDown(const GuiEvent&);
Point3F getMouse3DVec() {return mMouse3DVec;};
Point3F getMouse3DPos() {return mMouse3DPos;};
void setSpellBook(afxSpellBook* book);
void clearTargetingMode();
void pushTargetingMode(U8 mode, U8 check);
void popTargetingMode();
U8 getTargetingMode();
U8 getTargetingCheckMethod();
void performTargeting(const Point2I& mousePoint, U8 mode);
virtual void interpolateTick( F32 delta ) {};
virtual void processTick() {};
virtual void advanceTime( F32 timeDelta );
DECLARE_CONOBJECT(afxTSCtrl);
DECLARE_CATEGORY("AFX");
};
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
#endif // _AFX_TS_CTRL_H_