The HeroEngine Icon system is designed to provide users with an extensible design for displaying nodes (spells, skills, items, etc) through a graphical interface. The system consists of two classes which interact and depend on each other. These are icons ( _GUIIcon ) and their containers ( _GUIIconContainer ).
There are two types of supported drag concepts:
1. Pushing and holding a mouse button down in order to drag a control. C++ provides callbacks for this mechanic.
- Called on the GUIMovePanel that is trying to be dragged, if allowMove is true.
- Called on the GUIMovePanel that was being dragged, if OnDragDrop() is not handled.
- Called on a GUIControl when a dragged GUIMovePanel enters its screen space.
- Called on a GUIControl when a dragged GUIMovePanel leaves its screen space.
- Called on a GUIControl when a dragged GUIMovePanel is dropped while over its screen space.
- Called on a GUIControl when a dragged GUIMovePanel changes location within its screen space.
2. Releasing the mouse button and performing a swap of icons. This is handled entirely in HSL using an OnFrameUpdate callback (see the client script DragNDrop).
The icon system works with two tightly coupled base classes, _GUIIcon and _GUIIconContainer.
The basic _GUIIcon is simply GUI control that has the ability to display a node graphically. It has several fields which control the behavior for the concept of "Drag and Drop."
- Determines if the control can be dragged at all by the C++ Drag mechanics.
- Inert controls will have a proxy created that can be dragged away, while the original stays in place.
- Sticky Icons will not move until a small distance is covered by the cursor while the mouse is down.
A _GUIIconContainer is a basic control that knows how to display and interact with icons. Any control that wishes to be placed into a _GUIIconContainer must have a base class of _GUIIcon.
The two methods that perform the majority of the logic are OnDragStart and OnDragDrop. This section may contain information which is Hero's Journey specific.
Extending the system
//// // Called by C++ when a GUIMovePanel is dropped onto this _GUIIcon // Default: Ask the Container what to do. If no container, destroy icon //// method OnDragDrop(icon as NodeRef of Class GUIControl) as Boolean //// // Called by C++ when a GUIMovePanel is dragged on to this GUIControl's screen space // Default: Ask the container (if any) what to do //// method OnDragEnter(icon as NodeRef of Class GUIControl) //// // Called by C++ when a GUIMovePanel is dragged off of this GUIControl's screen space // Default: Ask the container (if any) what to do //// method OnDragLeave(icon as NodeRef of Class GUIControl) //// // Called by C++ when a GUIMovePanel is clicked and drag is attempted // Return true to prevent dragging, false to allow // Default: Asks _IsDraggable() //// method onDragStart() as Boolean //// // Called by C++ when OnDragDrop is not handled by the control that was dropped on // Default: Notifies the last Container (if any) and if not handled, Destroy ME //// method OnDragStop() //// // Returns whether or not the icon should be allowed to be dragged. // Both subject and container must allow drag // Default is false //// method _IsDraggable() as Boolean //// // Sticky icons require a distance to be travelled before being allowed to drag /// method _isIconSticky() as Boolean //// // Sets the _isIconSticky value for this icon. Sticky icons require a distance to be travelled // before being allowed to drag //// method _setIconSticky(sticky as Boolean) //// // Resets the layer field which will remove it from any children list //// method _DetachIcon() //// // Called when dragging of the icon has started. // Determines if the icon is inert or sticky and takes appropriate action // Notifies the subject and container of _OnIconDraggedAway() // Detaches the icon from its container //// method _OnIconDragStarted() //// // Called when the icon is dropped onto a _GUIIconContainer // Default: Set IgnoreMouseEvents to false //// method _OnIconDragDropped() //// // Called after the _IconSubject has created the icon // Default: Sets _IconSubject and calls _SetupIcon() //// method _OnIconCreate(subj as NodeRef of Class _IconSubjectInterface) //// // Called after icon is created // Default: Sets Texture values of the icon //// method _SetupIcon() //// // Inert icons will have a proxy created in their place when they are dragged from a container //// method _isIconInert() as Boolean //// // Sets inert value on the icon // Inert icons will have a proxy created in their place when they are dragged from a container //// method _SetIconInert(inert as Boolean) //// // Sets the iconID of the icon. // Icon ID is the texture map coordinate for the desired icon art //// method _SetIconID(icon as Integer) //// // Returns the iconID of the icon //// method _GetIconID() as Integer //// // Returns the _iconSubject // The instantiated node that this _GUIIcon represents //// method _GetIconSubject() as NodeRef //// // Sets the _iconSubject // The instantiated node that this _GUIIcon represents //// method _SetIconSubject(subj as NodeRef) //// // Returns the control that will be used to display the icon art // Default: Return ME //// method _GetIconImage() as NodeRef of Class GUIControl //// // Override with the list of texture FQN // Example: "\GUI\awesomeTexture.dds" // Default: Return empty list of string //// method _GetIconTextures() as List of String //// // Override with the size of the icon // Default: 0,0 //// method _GetIconGridInfo() as Class xy //// // With the given texture list, icon size, and icon id. Sets the defaultStatePresentation of the control // provided by _GetIconImage() //// method _SetIconTexture(textures as List of String, iconSize as Class xy, theIconID copies Integer) as Boolean //// // Called by C++ when a requested FQN resource is available //// method OnResourceAvailable(fqn as String, success as Boolean) as Boolean //// // Called if the container requests a ghost icon be put in place when dragged // Default: Do nothing //// method _SetIconAppearanceToGhost() //// // Called if the container does not handle the appearance settings // Default: Do nothing //// method _SetIconAppearanceToDefault() //// // Called when the icon is being dragged out of a container // Default: Do Nothing //// method _SetIconAppearanceToDragging() //// // Determines if the _GUIIcon requires server coordination before dropping into a container // Default: false //// method AsyncIconDrop() as Boolean //// // Sets the last container that the icon was in // Used to provide callbacks for events //// method _SetIconLastContainer(ctnr as NodeRef) //// // Returns the last container the icon was in //// method _GetIconlastContainer() as NodeRef of Class GUIControl //// // Iterates through all parent controls and returns the first _GUIIconContainer //// method _GetIconContainer() as NodeRef of Class _GUIIconContainer //// // Provides last minute cleanup before both icon and subject are destroyed\ // Default: Do Nothing //// method _OnIconSubjectDestroy()