2012-09-19 15:15:01 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// Copyright (c) 2012 GarageGames, LLC
|
|
|
|
|
//
|
|
|
|
|
// 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 _GUIBITMAPBUTTON_H_
|
|
|
|
|
#define _GUIBITMAPBUTTON_H_
|
|
|
|
|
|
|
|
|
|
#ifndef _GUIBUTTONCTRL_H_
|
|
|
|
|
#include "gui/buttons/guiButtonCtrl.h"
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef _GFXTEXTUREMANAGER_H_
|
|
|
|
|
#include "gfx/gfxTextureManager.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// A button control that uses bitmaps as its different button states.
|
|
|
|
|
///
|
|
|
|
|
/// Set 'bitmap' console field to base name of bitmaps to use. This control will
|
|
|
|
|
///
|
|
|
|
|
/// append '_n' for normal
|
|
|
|
|
/// append '_h' for highlighted
|
|
|
|
|
/// append '_d' for depressed
|
|
|
|
|
/// append '_i' for inactive
|
|
|
|
|
///
|
|
|
|
|
/// If a bitmap cannot be found it will use the default bitmap to render.
|
|
|
|
|
///
|
|
|
|
|
/// Additionally, a bitmap button can be made to react to keyboard modifiers. These can be
|
|
|
|
|
/// either CTRL/CMD, ALT, or SHIFT (but no combination of them.) To assign a different bitmap
|
|
|
|
|
/// for a modifier state, prepend "_ctrl", _"alt", or "_shift" to the state postfix.
|
|
|
|
|
///
|
|
|
|
|
/// To implement different handlers for the modifier states, use the "onDefaultClick",
|
|
|
|
|
/// "onCtrlClick", "onAltClick", and "onShiftClick" methods.
|
|
|
|
|
///
|
|
|
|
|
class GuiBitmapButtonCtrl : public GuiButtonCtrl
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
typedef GuiButtonCtrl Parent;
|
|
|
|
|
|
|
|
|
|
enum BitmapMode
|
|
|
|
|
{
|
|
|
|
|
BitmapStretched,
|
|
|
|
|
BitmapCentered,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
enum Modifier
|
|
|
|
|
{
|
|
|
|
|
ModifierNone,
|
|
|
|
|
ModifierCtrl,
|
|
|
|
|
ModifierAlt,
|
|
|
|
|
ModifierShift,
|
|
|
|
|
|
|
|
|
|
NumModifiers
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum State
|
|
|
|
|
{
|
|
|
|
|
NORMAL,
|
|
|
|
|
HILIGHT,
|
|
|
|
|
DEPRESSED,
|
|
|
|
|
INACTIVE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Textures
|
|
|
|
|
{
|
|
|
|
|
/// Texture for normal state.
|
2021-08-02 09:20:27 +00:00
|
|
|
StringTableEntry mTextureNormalAssetId;
|
|
|
|
|
AssetPtr<ImageAsset> mTextureNormalAsset;
|
2012-09-19 15:15:01 +00:00
|
|
|
GFXTexHandle mTextureNormal;
|
|
|
|
|
|
|
|
|
|
/// Texture for highlight state.
|
2021-08-02 09:20:27 +00:00
|
|
|
StringTableEntry mTextureHilightAssetId;
|
|
|
|
|
AssetPtr<ImageAsset> mTextureHilightAsset;
|
2012-09-19 15:15:01 +00:00
|
|
|
GFXTexHandle mTextureHilight;
|
|
|
|
|
|
|
|
|
|
/// Texture for depressed state.
|
2021-08-02 09:20:27 +00:00
|
|
|
StringTableEntry mTextureDepressedAssetId;
|
|
|
|
|
AssetPtr<ImageAsset> mTextureDepressedAsset;
|
2012-09-19 15:15:01 +00:00
|
|
|
GFXTexHandle mTextureDepressed;
|
|
|
|
|
|
|
|
|
|
/// Texture for inactive state.
|
2021-08-02 09:20:27 +00:00
|
|
|
StringTableEntry mTextureInactiveAssetId;
|
|
|
|
|
AssetPtr<ImageAsset> mTextureInactiveAsset;
|
2012-09-19 15:15:01 +00:00
|
|
|
GFXTexHandle mTextureInactive;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Make control extents equal to bitmap size.
|
|
|
|
|
bool mAutoFitExtents;
|
|
|
|
|
|
|
|
|
|
/// Allow switching out images according to modifier presses.
|
|
|
|
|
bool mUseModifiers;
|
|
|
|
|
|
|
|
|
|
/// Allow switching images according to mouse states. On by default.
|
|
|
|
|
/// Switch off when not needed as it otherwise results in a lot of costly
|
|
|
|
|
/// texture loads.
|
|
|
|
|
bool mUseStates;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
BitmapMode mBitmapMode;
|
|
|
|
|
|
2021-08-02 09:20:27 +00:00
|
|
|
DECLARE_IMAGEASSET(GuiBitmapButtonCtrl, Bitmap, onBitmapChange, GFXDefaultGUIProfile);
|
2021-10-03 07:56:26 +00:00
|
|
|
DECLARE_ASSET_SETGET(GuiBitmapButtonCtrl, Bitmap);
|
2012-09-19 15:15:01 +00:00
|
|
|
|
2016-03-10 02:02:39 +00:00
|
|
|
/// alpha masking
|
|
|
|
|
bool mMasked;
|
|
|
|
|
|
2012-09-19 15:15:01 +00:00
|
|
|
///
|
|
|
|
|
Textures mTextures[ NumModifiers ];
|
2021-11-27 02:13:59 +00:00
|
|
|
ColorI mColor;
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
virtual void renderButton( GFXTexHandle &texture, const Point2I& offset, const RectI& updateRect );
|
|
|
|
|
|
|
|
|
|
static bool _setAutoFitExtents( void *object, const char *index, const char *data );
|
2021-08-02 09:20:27 +00:00
|
|
|
//static bool _setBitmap( void *object, const char *index, const char *data );
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
State getState() const
|
|
|
|
|
{
|
|
|
|
|
if( mActive )
|
|
|
|
|
{
|
|
|
|
|
if( mDepressed || mStateOn ) return DEPRESSED;
|
2022-02-18 00:04:31 +00:00
|
|
|
if( mHighlighted ) return HILIGHT;
|
2012-09-19 15:15:01 +00:00
|
|
|
return NORMAL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return INACTIVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Modifier getCurrentModifier();
|
|
|
|
|
GFXTexHandle& getTextureForCurrentState();
|
|
|
|
|
|
|
|
|
|
/// @name Callbacks
|
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
|
|
DECLARE_CALLBACK( void, onDefaultClick, () );
|
|
|
|
|
DECLARE_CALLBACK( void, onCtrlClick, () );
|
|
|
|
|
DECLARE_CALLBACK( void, onAltClick, () );
|
|
|
|
|
DECLARE_CALLBACK( void, onShiftClick, () );
|
|
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
|
Adjusted callback handling of asset inspector fields when invoking AB to select asset for more consistent behavior and better handling of updating the objects and inspector
Added logic to forcefully acquire newly imported asset definition to better try and ensure it's loaded immediately after import
Added logic to asset importer so if a file is not found for an importing material asset, if populate maps is on, then it will try and find a matching image asset in the destination module
Added logic to tsStatic to better handle fields being updated via the editor, forcing updates and refreshes of the shape and materialSlots
Fixed handling of guiBitmapButtonCtrl so it will update the bitmap used when edited via the Gui Editor
Updated image ref to the hudFill image asset for the console GUI
Cleaned up names for the default camera model/material
Defaulted import config to utilize the Prune action instead of rename for more predictable default behavior
Added icons next to AB's preview slider bar for additional visual feedback of slider intent
Added missing checkbox to asset import window and cleaned up scaling behavior
Fixed handling of drag-n-drop behavior in GUI editor so it doesn't block further interaction
Added logic for drag-n-drop of image assets to GUI Editor so it will create a GuiBitmapCtrl with the image
Added handling for drag-n-drop import of folders of assets to AB/Asset Import
Added missing asset import config option to indicate if config supported import of sound assets
Added logic when opening asset import config editor, where if there is a default import config set in the settings, it will open that one by default
Hid the collision section of the import config editor, as those options are currently unutilized
Improved behavior for Create New Folder window in the AB, now always pushing to the front, and also selecting the text by default, so the user can just start typing the new name
Also added return and escape key accelerators to Create New Folder window for better UX
Fixed display of editor windows, adding a distinct blue color to highlighted windows' title bar and fixing display of minimize/maximize/window/close buttons
Moved GUIEditor's onControlDropped function to the AB script to match placement of sibling world editor function
Fixed issue with material editor where the ORM Config map slot was getting the normal map instead of the correct ORM map
2021-11-26 22:40:15 +00:00
|
|
|
void onBitmapChange()
|
|
|
|
|
{
|
|
|
|
|
setBitmap(getBitmap());
|
|
|
|
|
}
|
2021-08-02 09:20:27 +00:00
|
|
|
|
2012-09-19 15:15:01 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
GuiBitmapButtonCtrl();
|
|
|
|
|
|
|
|
|
|
void setAutoFitExtents( bool state );
|
2021-07-19 06:07:08 +00:00
|
|
|
void setBitmap( StringTableEntry name );
|
2012-09-19 15:15:01 +00:00
|
|
|
void setBitmapHandles( GFXTexHandle normal, GFXTexHandle highlighted, GFXTexHandle depressed, GFXTexHandle inactive );
|
|
|
|
|
|
|
|
|
|
//Parent methods
|
|
|
|
|
virtual bool onWake();
|
|
|
|
|
virtual void onSleep();
|
|
|
|
|
virtual void onAction();
|
|
|
|
|
virtual void inspectPostApply();
|
|
|
|
|
|
|
|
|
|
virtual void onRender(Point2I offset, const RectI &updateRect);
|
|
|
|
|
|
|
|
|
|
static void initPersistFields();
|
2016-03-10 02:02:39 +00:00
|
|
|
bool pointInControl(const Point2I& parentCoordPoint);
|
2012-09-19 15:15:01 +00:00
|
|
|
|
|
|
|
|
DECLARE_CONOBJECT(GuiBitmapButtonCtrl);
|
|
|
|
|
DECLARE_DESCRIPTION( "A button control rendered entirely from bitmaps.\n"
|
|
|
|
|
"The individual button states are represented with separate bitmaps." );
|
Adjusted handling for the bitmap and bitmapAsset fields for guiBitmapButtonCtrl to forcefully update the button states when changed, ensuring that the bitmaps refresh when changed via the field
Added callback for onResize to guiWindowCtrl so controls - such as the EditorTree - can be properly resized in certain circumstances when the window is changed
Added getIncrement() and getRange() to GuiGameSettingsCtrl to better facilitate options manipulation on the script side
Corrected some of the console method documentation strings in GuiGameSettingsCtrl
Removed some unneeded, extraneous files and their asset definitions that came from odd import conversions. Where applicable, created cleaned up versions to make naming conventions and references stable
Fixed canvas mode update text typo: FSAA -> FXAA
Added logic to DOF, Light Rays, SSAO and Vignette postFX's to check both the preset setting AND the user preference before enabling.
Shifted initialization order so PostFX's are loaded before we configure the canvas, to ensure stuff like the FXAAPostFX exists and can be toggled on on load
Fixed multiple issues with options menu:
When using gamepad, unable to navigate from categories to options. Fixed so can now traverse as normal
Input limitations on gamepad necessitated changing of how setting applying happens, is now done as a 'apply or discard' prompt when leaving the options menu
Added proper handling for adjusting settings with gamepad with left/right inputs
Fixed issue where the unapplied change for an option was sometimes being processed as an object name rather than an implicit string. Now made to be explicit strings to avoid issue.
Made the menu button input for "Select" to go from categories to options gamepad only, and hidden when in the options list
Fixed issue where changing window mode didn't correctly affect resolution option. Now set up so changing this field correctly refreshes the resolution option. Specifically, when on borderless, the resolution field does not show, preventing confusion as it is always full resolution
Generally have the options list refresh when changes happen to allow any and all fields to be able to dynamically respond to other options having changed improving flexibility.
Cleaned up old, unused, commented out functions
Added ability on OKCancel message boxes to override the button text if needed
Fixed issue with AssetBrowser where the shrink/grow icons next to the preview size slider were not anchored correctly.
Adjusted callback logic so if preview slider is clicked on, rather than dragged, it will correctly update the zoom values
Added sorting to Modules List dropdown for the AssetBrowser
Improved standardization of double-clicking in AssetBrowser. Now defaults to editing action if regularly browsing and selecting if in select mode. Still allows regular per-type overrides as normal
Moved definition of GuiDisabledTextEditProfile to gui profiles.ed.tscript file, removed duplicates to stop error spam
Adjusted default settings value for double-click action in AB to be edit to prevent unstable behavior
Removed old file refs from Load Recent list in the default settings
2022-03-27 03:36:37 +00:00
|
|
|
|
|
|
|
|
//Basically a wrapper function to do our special state handling setup when the fields change
|
|
|
|
|
static bool _setBitmapFieldData(void* obj, const char* index, const char* data)
|
|
|
|
|
{
|
|
|
|
|
GuiBitmapButtonCtrl* object = static_cast<GuiBitmapButtonCtrl*>(obj);
|
|
|
|
|
object->setBitmap(StringTable->insert(data));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-09-19 15:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef GuiBitmapButtonCtrl::BitmapMode GuiBitmapMode;
|
|
|
|
|
DefineEnumType( GuiBitmapMode );
|
|
|
|
|
|
|
|
|
|
/// Extension of GuiBitmapButtonCtrl that also display a text label on the button.
|
|
|
|
|
class GuiBitmapButtonTextCtrl : public GuiBitmapButtonCtrl
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
typedef GuiBitmapButtonCtrl Parent;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
virtual void renderButton( GFXTexHandle &texture, const Point2I& offset, const RectI& updateRect );
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
DECLARE_CONOBJECT( GuiBitmapButtonTextCtrl );
|
|
|
|
|
DECLARE_DESCRIPTION( "An extension of GuiBitmapButtonCtrl that also renders a text\n"
|
|
|
|
|
"label on the button." );
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //_GUI_BITMAP_BUTTON_CTRL_H
|