Git didn't properly actually commit new files.
1121
Engine/source/gui/controls/guiGameSettingsCtrl.cpp
Normal file
313
Engine/source/gui/controls/guiGameSettingsCtrl.h
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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 _GuiGameSettingsCtrl_H_
|
||||
#define _GuiGameSettingsCtrl_H_
|
||||
|
||||
#include "gui/buttons/guiButtonCtrl.h"
|
||||
#include "T3D/assets/ImageAsset.h"
|
||||
|
||||
/// \class GuiGameSettingsCtrl
|
||||
/// A base class for cross platform menu controls that are gamepad friendly.
|
||||
class GuiGameSettingsCtrl : public GuiButtonCtrl
|
||||
{
|
||||
public:
|
||||
typedef GuiButtonCtrl Parent;
|
||||
|
||||
enum Mode
|
||||
{
|
||||
Default = 0,
|
||||
OptionList,
|
||||
Slider,
|
||||
Keybind,
|
||||
Text
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
/// \struct OptionEntry
|
||||
/// Display text and ID key for each entry in an option.
|
||||
struct OptionEntry
|
||||
{
|
||||
StringTableEntry mDisplayText; ///< The text that is displayed for the option
|
||||
StringTableEntry mKeyString; ///< Key value that is associated with this option
|
||||
OptionEntry() : mDisplayText(StringTable->EmptyString()), mKeyString(StringTable->EmptyString()) {}
|
||||
virtual ~OptionEntry() {}
|
||||
};
|
||||
|
||||
|
||||
StringTableEntry mLabel; ///< Text to display in the control as a label
|
||||
StringTableEntry mScriptCallback; ///< Script callback when control is activated
|
||||
StringTableEntry mTooltip; ///< A descriptive tooltip message for what the control is
|
||||
|
||||
Mode mMode;
|
||||
|
||||
//List options
|
||||
Vector<OptionEntry> mOptions; ///< Collection of options available to display
|
||||
S32 mSelectedOption; ///< Index into mOptions pointing at the selected option
|
||||
bool mWrapOptions; ///< Determines if options should "wrap around" at the ends
|
||||
|
||||
//Slider option
|
||||
F32 mValue; ///< When working as a slider, this contains the value
|
||||
F32 mStepSize; ///< When working as a slider, this is the increment levels in the range
|
||||
Point2F mRange; ///< When working as a slider, this sets our min/max range
|
||||
|
||||
//Keybind option
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, KeybindBitmap, changeBitmap, GFXDefaultGUIProfile);
|
||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, KeybindBitmap);
|
||||
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, PreviousBitmap, changeBitmap, GFXDefaultGUIProfile);
|
||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, PreviousBitmap);
|
||||
|
||||
DECLARE_IMAGEASSET(GuiGameSettingsCtrl, NextBitmap, changeBitmap, GFXDefaultGUIProfile);
|
||||
DECLARE_ASSET_SETGET(GuiGameSettingsCtrl, NextBitmap);
|
||||
|
||||
S32 mArrowSize;
|
||||
S32 mColumnSplit; //Padding between the leftmost edge of the control, and the left side of the 'option'.
|
||||
S32 mRightPad;
|
||||
|
||||
bool mEnabled;
|
||||
bool mSelected;
|
||||
|
||||
public:
|
||||
void changeBitmap() {}
|
||||
|
||||
/// Sets the control as selected . Only controls that are enabled can be selected.
|
||||
virtual void setSelected();
|
||||
|
||||
/// Determines if the specified control is enabled or disabled.
|
||||
///
|
||||
/// \return True if the specified control is enabled. False if the control is not
|
||||
/// enabled
|
||||
virtual bool isEnabled() const;
|
||||
|
||||
/// Sets a control's enabled status according to the given parameters.
|
||||
///
|
||||
/// \param enabled Indicate true to enable the control or false to disable it.
|
||||
virtual void setEnabled(bool enabled);
|
||||
|
||||
/// Gets the label displayed on the control.
|
||||
///
|
||||
/// \return The label for the control.
|
||||
virtual StringTableEntry getLabel() const;
|
||||
|
||||
/// Sets the label on the control.
|
||||
///
|
||||
/// \param label Text to set as the label.
|
||||
virtual void setLabel(const char * label);
|
||||
|
||||
/// Sets the control to a List setting.
|
||||
///
|
||||
/// \param label The text to display on the control as a label.
|
||||
/// \param optionsList A tab separated list of options for the control.
|
||||
/// \param wrapOptions Specify true to allow options to wrap at the ends or
|
||||
/// false to prevent wrapping.
|
||||
/// \param callback [optional] Name of a script function to use as a callback
|
||||
/// when this control is activated. Default NULL means no callback.
|
||||
/// \param enabled [optional] If this control is initially enabled. Default true.
|
||||
void setListSetting(const char* label, const char* optionsList, bool wrapOptions, const char* callback,bool enabled, const char* tooltip = "", const char* defaultValue = "");
|
||||
|
||||
/// Sets the control to a Slider setting
|
||||
///
|
||||
/// \param label The text to display on the control as a label.
|
||||
/// \param defaultValue A float indicating the slider's default value
|
||||
/// \param increments A float indicating the incremental values the slider snaps along between it's range
|
||||
/// \param range A Point2F that indicates the minimum and maximum value range
|
||||
/// \param callback [optional] Name of a script function to use as a callback
|
||||
/// when this control is activated. Default NULL means no callback.
|
||||
/// \param enabled [optional] If this control is initially enabled. Default true.
|
||||
void setSliderSetting(const char* label, F32 defaultValue, F32 increments, Point2F range, const char* callback, bool enabled, const char* tooltip = "");
|
||||
|
||||
/// Sets the control to a Keybind setting
|
||||
///
|
||||
/// \param label The text to display on the control as a label.
|
||||
/// \param bitmapAssetId The assetId for the button display image
|
||||
/// \param range A Point2F that indicates the minimum and maximum value range
|
||||
/// \param callback [optional] Name of a script function to use as a callback
|
||||
/// when this control is activated. Default NULL means no callback.
|
||||
/// \param enabled [optional] If this control is initially enabled. Default true.
|
||||
void setKeybindSetting(const char* label, const char* bitmapAssetId, const char* callback, bool enabled, const char* tooltip);
|
||||
|
||||
/// Gets the text for the currently selected option of the control.
|
||||
///
|
||||
/// \return A string representing the text currently displayed as the selected
|
||||
/// option on the control. If there is no such displayed text then the empty
|
||||
/// string is returned.
|
||||
StringTableEntry getCurrentOption() const;
|
||||
|
||||
/// Gets the key string for the currently selected option of the control
|
||||
///
|
||||
/// \return The key (or id) that was assigned to the selected option on the
|
||||
/// control. If there is no selected option then the empty string is returned.
|
||||
StringTableEntry getCurrentOptionKey() const;
|
||||
|
||||
/// Gets the index into the option list for the currently selected option of the control.
|
||||
///
|
||||
/// \return The index of the selected option on the control. If there is no
|
||||
/// selected option then -1 is returned.
|
||||
S32 getCurrentOptionIndex() const;
|
||||
|
||||
/// Attempts to set the control to the specified selected option. The option
|
||||
/// will only be set if the option exists in the control.
|
||||
///
|
||||
/// \param option The option to be made active.
|
||||
/// \return True if the control contained the option and was set, false otherwise.
|
||||
bool selectOption(const char* option);
|
||||
|
||||
/// Attempts to set the control to the option with the specified key. The
|
||||
/// option will only be set if the key exists in the control.
|
||||
///
|
||||
/// \param optionKey The key string that was assigned to the option to be made active.
|
||||
/// \return True if the control contained the key and the option and was set, false otherwise.
|
||||
bool selectOptionByKey(const char* optionKey);
|
||||
|
||||
/// Attempts to set the control to the option at the specified index. The option
|
||||
/// will only be set if the index is valid.
|
||||
///
|
||||
/// \param optionIndex The index of the option to be made active.
|
||||
/// \return True if the index was valid and the option and was set, false otherwise.
|
||||
bool selectOptionByIndex(S32 optionIndex);
|
||||
|
||||
/// Sets the list of options on the control.
|
||||
///
|
||||
/// \param optionsList A tab separated list of options for the control.
|
||||
void setOptions(const char* optionsList);
|
||||
|
||||
/// Adds an option to the list of options on the control.
|
||||
///
|
||||
/// \param displayText The text to display for this option.
|
||||
/// \param keyText The id string to associate with this value. If NULL the
|
||||
/// id will be the same as the display text.
|
||||
void addOption(const char* displayText, const char* keyText);
|
||||
|
||||
/// Activates the control. The script callback of the control will
|
||||
/// be called (if it has one).
|
||||
virtual void activate();
|
||||
|
||||
/// Gets the value
|
||||
///
|
||||
F32 getValue();
|
||||
|
||||
/// Sets the value
|
||||
///
|
||||
/// \param value The new value to be set.
|
||||
void setValue(F32 value);
|
||||
|
||||
Mode getMode() { return mMode; }
|
||||
|
||||
/// Gets the tooltip
|
||||
const char* getTooltip();
|
||||
|
||||
GuiGameSettingsCtrl();
|
||||
~GuiGameSettingsCtrl();
|
||||
|
||||
void onRender(Point2I offset, const RectI &updateRect);
|
||||
|
||||
void onRenderListOption(Point2I currentOffset);
|
||||
void onRenderSliderOption(Point2I currentOffset);
|
||||
|
||||
void onRenderKeybindOption(Point2I currentOffset);
|
||||
|
||||
/// Callback when the object is registered with the sim.
|
||||
///
|
||||
/// \return True if the profile was successfully added, false otherwise.
|
||||
bool onAdd();
|
||||
|
||||
/// Callback when the control wakes up.
|
||||
bool onWake();
|
||||
|
||||
void clear();
|
||||
|
||||
virtual void onMouseMove(const GuiEvent& event);
|
||||
virtual void onMouseUp(const GuiEvent& event);
|
||||
|
||||
DECLARE_CONOBJECT(GuiGameSettingsCtrl);
|
||||
DECLARE_CATEGORY( "Gui Game" );
|
||||
DECLARE_DESCRIPTION( "Base class for cross platform menu controls that are gamepad friendly." );
|
||||
|
||||
/// Initializes fields accessible through the console.
|
||||
static void initPersistFields();
|
||||
|
||||
static const S32 NO_OPTION = -1; ///< Indicates there is no option
|
||||
|
||||
protected:
|
||||
/// Sets up the option
|
||||
///
|
||||
/// \param label The text to display on the control as a label.
|
||||
/// \param callback Name of a script function to use as a callback when this
|
||||
/// control is activated.
|
||||
/// \param enabled [optional] If this control is initially enabled. Default true.
|
||||
virtual void set(const char* label, const char* callback, bool useHighlightIcon = true, bool enabled = true, S32 mode = 0, const char* tooltip = "");
|
||||
|
||||
/// Sets the script variable $ThisControl to reflect this control.
|
||||
virtual void setThisControl();
|
||||
|
||||
/// @name Callbacks
|
||||
/// @{
|
||||
DECLARE_CALLBACK( void, onChange, () );
|
||||
|
||||
DECLARE_CALLBACK(void, onInputEvent, (const char* device, const char* action, bool state));
|
||||
|
||||
DECLARE_CALLBACK(void, onAxisEvent, (const char* device, const char* action, F32 axisValue));
|
||||
/// @}
|
||||
|
||||
/// Evaluates some script. If the command is empty then nothing is evaluated.
|
||||
///
|
||||
/// \param command The script to evaluate.
|
||||
void doScriptCommand(StringTableEntry command);
|
||||
|
||||
StringTableEntry mCallbackOnA; ///< Script callback when the 'A' button is pressed
|
||||
StringTableEntry mCallbackOnB; ///< Script callback when the 'B' button is pressed
|
||||
StringTableEntry mCallbackOnX; ///< Script callback when the 'X' button is pressed
|
||||
StringTableEntry mCallbackOnY; ///< Script callback when the 'Y' button is pressed
|
||||
|
||||
private:
|
||||
/// Performs a click on the current option. The x position is used to
|
||||
/// determine if the left or right arrow were clicked. If one was clicked, the
|
||||
/// option will be changed. If neither was clicked, the option is unaffected.
|
||||
/// This method should only be called when there is an actively selected control.
|
||||
///
|
||||
/// \param xPos The x position of the the click, relative to the control.
|
||||
void clickOption(S32 xPos);
|
||||
|
||||
/// Changes the option on the currently selected control.
|
||||
///
|
||||
/// \param delta The amount to change the option selection by. Typically this
|
||||
/// will be 1 or -1.
|
||||
void changeOption(S32 delta);
|
||||
|
||||
/// Performs a click on the current slider control. The x position is used to
|
||||
/// determine if the left or right arrow were clicked, or if it landed somewhere on the sliderbar.
|
||||
/// If one was clicked, the option will be changed. If neither was clicked, the option is unaffected.
|
||||
/// This method should only be called when there is an actively selected control.
|
||||
///
|
||||
/// \param xPos The x position of the the click, relative to the control.
|
||||
void clickSlider(S32 xPos);
|
||||
|
||||
void clickKeybind(S32 xPos);
|
||||
|
||||
private:
|
||||
bool mCallbackOnInputs;
|
||||
bool mConsumeKeyInputEvents;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<GUIAsset
|
||||
AssetName="NetGraphGui"
|
||||
GUIFile="@assetFile=netGraphGui.gui"
|
||||
VersionId="1"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/Torque_3D_logo.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
Templates/BaseGame/game/data/UI/images/Torque_3D_logo_alt.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 10 KiB |
BIN
Templates/BaseGame/game/data/UI/images/Torque_3D_logo_w.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
Templates/BaseGame/game/data/UI/images/backgrounddark.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="backgrounddark_image"
|
||||
imageFile="@assetFile=backgrounddark.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/clearbtn_d.png
Normal file
|
After Width: | Height: | Size: 593 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="clearbtn_d_image"
|
||||
imageFile="@assetFile=clearbtn_d.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/clearbtn_h.png
Normal file
|
After Width: | Height: | Size: 595 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="clearbtn_h_image"
|
||||
imageFile="@assetFile=clearbtn_h.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/clearbtn_n.png
Normal file
|
After Width: | Height: | Size: 377 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="clearbtn_n_image"
|
||||
imageFile="@assetFile=clearbtn_n.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/collapsetoolbar_d.png
Normal file
|
After Width: | Height: | Size: 280 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="collapsetoolbar_d_image"
|
||||
imageFile="@assetFile=collapsetoolbar_d.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/collapsetoolbar_h.png
Normal file
|
After Width: | Height: | Size: 468 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="collapsetoolbar_h_image"
|
||||
imageFile="@assetFile=collapsetoolbar_h.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/collapsetoolbar_n.png
Normal file
|
After Width: | Height: | Size: 439 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="collapsetoolbar_n_image"
|
||||
imageFile="@assetFile=collapsetoolbar_n.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/dropdownbuttonarrow.png
Normal file
|
After Width: | Height: | Size: 132 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="dropdownbuttonarrow_image"
|
||||
imageFile="@assetFile=dropdownbuttonarrow.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/dropdowntextEdit.png
Normal file
|
After Width: | Height: | Size: 390 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="dropdowntextEdit_image"
|
||||
imageFile="@assetFile=dropdowntextEdit.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/expandtoolbar_d.png
Normal file
|
After Width: | Height: | Size: 278 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="expandtoolbar_d_image"
|
||||
imageFile="@assetFile=expandtoolbar_d.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/expandtoolbar_h.png
Normal file
|
After Width: | Height: | Size: 468 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="expandtoolbar_h_image"
|
||||
imageFile="@assetFile=expandtoolbar_h.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/expandtoolbar_n.png
Normal file
|
After Width: | Height: | Size: 437 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="expandtoolbar_n_image"
|
||||
imageFile="@assetFile=expandtoolbar_n.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/groupborder.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="groupborder_image"
|
||||
imageFile="@assetFile=groupborder.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/inactiveoverlay.png
Normal file
|
After Width: | Height: | Size: 131 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="inactiveoverlay_image"
|
||||
imageFile="@assetFile=inactiveoverlay.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/menubutton.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="menubutton_image"
|
||||
imageFile="@assetFile=menubutton.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/nextOption_n.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
<ImageAsset
|
||||
canSave="true"
|
||||
canSaveDynamicFields="true"
|
||||
AssetName="nextOption_n_image"
|
||||
imageFile="@assetFile=nextOption_n.png"
|
||||
UseMips="true"
|
||||
isHDRImage="false"
|
||||
imageType="GUI" />
|
||||
BIN
Templates/BaseGame/game/data/UI/images/nextbutton_d.png
Normal file
|
After Width: | Height: | Size: 279 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="nextbutton_d_image"
|
||||
imageFile="@assetFile=nextbutton_d.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/nextbutton_h.png
Normal file
|
After Width: | Height: | Size: 549 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="nextbutton_h_image"
|
||||
imageFile="@assetFile=nextbutton_h.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/nextbutton_n.png
Normal file
|
After Width: | Height: | Size: 484 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="nextbutton_n_image"
|
||||
imageFile="@assetFile=nextbutton_n.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/nopreview.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="nopreview_image"
|
||||
imageFile="@assetFile=nopreview.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/previousOption_n.png
Normal file
|
After Width: | Height: | Size: 8 KiB |
|
|
@ -0,0 +1,8 @@
|
|||
<ImageAsset
|
||||
canSave="true"
|
||||
canSaveDynamicFields="true"
|
||||
AssetName="previousOption_n_image"
|
||||
imageFile="@assetFile=previousOption_n.png"
|
||||
UseMips="true"
|
||||
isHDRImage="false"
|
||||
imageType="GUI" />
|
||||
BIN
Templates/BaseGame/game/data/UI/images/previousbutton_d.png
Normal file
|
After Width: | Height: | Size: 290 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="previousbutton_d_image"
|
||||
imageFile="@assetFile=previousbutton_d.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/previousbutton_h.png
Normal file
|
After Width: | Height: | Size: 561 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="previousbutton_h_image"
|
||||
imageFile="@assetFile=previousbutton_h.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/previousbutton_n.png
Normal file
|
After Width: | Height: | Size: 494 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="previousbutton_n_image"
|
||||
imageFile="@assetFile=previousbutton_n.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/selectorbutton.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="selectorbutton_image"
|
||||
imageFile="@assetFile=selectorbutton.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/selectorbuttonblank.png
Normal file
|
After Width: | Height: | Size: 744 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="selectorbuttonblank_image"
|
||||
imageFile="@assetFile=selectorbuttonblank.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/selectorbuttondark.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="selectorbuttondark_image"
|
||||
imageFile="@assetFile=selectorbuttondark.png"/>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="selectorbuttonhighlightonly_image"
|
||||
imageFile="@assetFile=selectorbuttonhighlightonly.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/separatorh.png
Normal file
|
After Width: | Height: | Size: 117 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="separatorh_image"
|
||||
imageFile="@assetFile=separatorh.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/separatorv.png
Normal file
|
After Width: | Height: | Size: 118 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="separatorv_image"
|
||||
imageFile="@assetFile=separatorv.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/sliderwbox.png
Normal file
|
After Width: | Height: | Size: 982 B |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="sliderwbox_image"
|
||||
imageFile="@assetFile=sliderwbox.png"/>
|
||||
BIN
Templates/BaseGame/game/data/UI/images/tabborder.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -0,0 +1,3 @@
|
|||
<ImageAsset
|
||||
AssetName="tabborder_image"
|
||||
imageFile="@assetFile=tabborder.png"/>
|
||||
|
|
@ -0,0 +1,510 @@
|
|||
//==============================================================================
|
||||
// Menu Input Buttons
|
||||
// This file manages the Menu Input Buttons stuff
|
||||
// Any time you have a GUI button that should be clickable AND map to a key input
|
||||
// such as a gamepad button, or enter, etc, this stuff can be used
|
||||
//==============================================================================
|
||||
/*
|
||||
Gamepad input reference for 360 controller
|
||||
btn_a = A
|
||||
btn_b = B
|
||||
btn_x = X
|
||||
btn_y = Y
|
||||
btn_r = Right Bumper
|
||||
btn_l = Right Bumper
|
||||
upov = Dpad Up
|
||||
dpov = Dpad Down
|
||||
lpov = Dpad Left
|
||||
rpov = Dpad Right
|
||||
xaxis = Left Stick | + values = up, - values = down
|
||||
yaxis = Left Stick | + values = up, - values = down
|
||||
rxaxis = Right Stick | + values = up, - values = down
|
||||
ryaxis = Right Stick | + values = up, - values = down
|
||||
zaxis = Left Trigger
|
||||
rzaxis = Right Trigger
|
||||
btn_start = Start
|
||||
btn_back = Back/Select
|
||||
*/
|
||||
|
||||
/// This is used with the main UI menu lists, when a non-axis input event is called
|
||||
/// such as pressing a button
|
||||
/// It is called from the engine
|
||||
function UIMenuButtonList::onInputEvent(%this, %device, %action, %state)
|
||||
{
|
||||
if(%state)
|
||||
$activeMenuButtonContainer.processInputs(%device, %action);
|
||||
}
|
||||
|
||||
/// This is used with the main UI menu lists, when an axis input event is called
|
||||
/// such as moving a joystick
|
||||
/// It is called from the engine
|
||||
function UIMenuButtonList::onAxisEvent(%this, %device, %action, %axisVal)
|
||||
{
|
||||
//Skip out of the value is too low as it could just be noise or miscalibrated defaults
|
||||
if(%axisVal < 0.02)
|
||||
return;
|
||||
|
||||
$activeMenuButtonContainer.processAxisEvent(%device, %action);
|
||||
}
|
||||
|
||||
/// Sets the command and text for the specified button. If %text and %command
|
||||
/// are left empty, the button will be disabled and hidden.
|
||||
///
|
||||
/// \param %gamepadButton (string) The button to set for when using gamepad input. See the input map reference comment at the top of the file
|
||||
/// \param %keyboardButton (string) The button to set for when using keyboard/mouse input.
|
||||
/// \param %text (string) The text to display next to the A button graphic.
|
||||
/// \param %command (string) The command executed when the A button is pressed.
|
||||
/// \param %gamepadOnly (bool) If true, will only show the button when working in the gamepad input mode
|
||||
function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %command, %gamepadOnly)
|
||||
{
|
||||
%set = (! ((%text $= "") && (%command $= "")));
|
||||
%this.setText(%text);
|
||||
%this.setActive(%set);
|
||||
%this.setVisible(%set);
|
||||
|
||||
%this.gamepadButton = %gamepadButton;
|
||||
%this.keyboardButton = %keyboardButton;
|
||||
|
||||
if(%gamepadOnly $= "")
|
||||
%gamepadOnly = false;
|
||||
|
||||
%this.gamepadOnly = %gamepadOnly;
|
||||
|
||||
%this.Command = %command;
|
||||
}
|
||||
|
||||
/// Refreshes the specific button, updating it's visbility status and the displayed input image
|
||||
function MenuInputButton::refresh(%this)
|
||||
{
|
||||
%set = (! ((%this.text $= "") && (%this.command $= "")));
|
||||
|
||||
//Special-case of where we're in keyboard+mouse mode, but the menubutton is gamepad only mode, so we early out
|
||||
if(%this.gamepadOnly && $activeControllerType !$= "gamepad")
|
||||
%set = false;
|
||||
|
||||
%this.setActive(%set);
|
||||
%this.setVisible(%set);
|
||||
|
||||
if(!%this.isActive())
|
||||
return;
|
||||
|
||||
if($activeControllerType $= "gamepad")
|
||||
{
|
||||
if(%this.gamepadButton !$= "")
|
||||
{
|
||||
%assetId = "";
|
||||
if($activeControllerName $= "PS4 Controller")
|
||||
{
|
||||
%assetId = "UI:PS4_";
|
||||
|
||||
if(%this.gamepadButton $= "btn_a")
|
||||
%assetId = %assetId @ "Cross";
|
||||
else if(%this.gamepadButton $= "btn_b")
|
||||
%assetId = %assetId @ "Circle";
|
||||
else if(%this.gamepadButton $= "btn_x")
|
||||
%assetId = %assetId @ "Square";
|
||||
else if(%this.gamepadButton $= "btn_y")
|
||||
%assetId = %assetId @ "Triangle";
|
||||
else if(%this.gamepadButton $= "btn_l")
|
||||
%assetId = %assetId @ "L1";
|
||||
else if(%this.gamepadButton $= "zaxis")
|
||||
%assetId = %assetId @ "L2";
|
||||
else if(%this.gamepadButton $= "btn_r")
|
||||
%assetId = %assetId @ "R1";
|
||||
else if(%this.gamepadButton $= "rzaxis")
|
||||
%assetId = %assetId @ "R2";
|
||||
else if(%this.gamepadButton $= "btn_start")
|
||||
%assetId = %assetId @ "Options";
|
||||
else if(%this.gamepadButton $= "btn_back")
|
||||
%assetId = %assetId @ "Share";
|
||||
}
|
||||
else if($activeControllerName $= "Nintendo Switch Pro Controller")
|
||||
{
|
||||
%assetId = "UI:Switch_";
|
||||
|
||||
if(%this.gamepadButton $= "btn_a")
|
||||
%assetId = %assetId @ "B";
|
||||
else if(%this.gamepadButton $= "btn_b")
|
||||
%assetId = %assetId @ "A";
|
||||
else if(%this.gamepadButton $= "btn_x")
|
||||
%assetId = %assetId @ "Y";
|
||||
else if(%this.gamepadButton $= "btn_y")
|
||||
%assetId = %assetId @ "X";
|
||||
else if(%this.gamepadButton $= "btn_l")
|
||||
%assetId = %assetId @ "LB";
|
||||
else if(%this.gamepadButton $= "zaxis")
|
||||
%assetId = %assetId @ "LT";
|
||||
else if(%this.gamepadButton $= "btn_r")
|
||||
%assetId = %assetId @ "RB";
|
||||
else if(%this.gamepadButton $= "rzaxis")
|
||||
%assetId = %assetId @ "RT";
|
||||
else if(%this.gamepadButton $= "btn_start")
|
||||
%assetId = %assetId @ "Plus";
|
||||
else if(%this.gamepadButton $= "btn_back")
|
||||
%assetId = %assetId @ "Minus";
|
||||
}
|
||||
else if($activeControllerName !$= "")
|
||||
{
|
||||
%assetId = "UI:Xbox_";
|
||||
|
||||
if(%this.gamepadButton $= "btn_a")
|
||||
%assetId = %assetId @ "A";
|
||||
else if(%this.gamepadButton $= "btn_b")
|
||||
%assetId = %assetId @ "B";
|
||||
else if(%this.gamepadButton $= "btn_x")
|
||||
%assetId = %assetId @ "X";
|
||||
else if(%this.gamepadButton $= "btn_y")
|
||||
%assetId = %assetId @ "Y";
|
||||
else if(%this.gamepadButton $= "btn_l")
|
||||
%assetId = %assetId @ "LB";
|
||||
else if(%this.gamepadButton $= "zaxis")
|
||||
%assetId = %assetId @ "LT";
|
||||
else if(%this.gamepadButton $= "btn_r")
|
||||
%assetId = %assetId @ "RB";
|
||||
else if(%this.gamepadButton $= "rzaxis")
|
||||
%assetId = %assetId @ "RT";
|
||||
else if(%this.gamepadButton $= "btn_start")
|
||||
%assetId = %assetId @ "Menu";
|
||||
else if(%this.gamepadButton $= "btn_back")
|
||||
%assetId = %assetId @ "Windows";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%this.keyboardButton !$= "")
|
||||
{
|
||||
%assetId = "UI:Keyboard_Black_" @ %this.keyboardButton;
|
||||
}
|
||||
}
|
||||
|
||||
%this.setBitmap(%assetId @ "_image");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Refreshes a menu input container, updating the buttons inside it
|
||||
function MenuInputButtonContainer::refresh(%this)
|
||||
{
|
||||
%count = %this.getCount();
|
||||
for(%i=0; %i < %count; %i++)
|
||||
{
|
||||
%btn = %this.getObject(%i);
|
||||
|
||||
%btn.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the given MenuInputButtonContainer as the active one. This directs input events
|
||||
/// to it's buttons, ensures it's visible, and auto-hides the old active container if it was set
|
||||
function MenuInputButtonContainer::setActive(%this)
|
||||
{
|
||||
if(isObject($activeMenuButtonContainer))
|
||||
$activeMenuButtonContainer.hidden = true;
|
||||
|
||||
$activeMenuButtonContainer = %this;
|
||||
$activeMenuButtonContainer.hidden = false;
|
||||
$activeMenuButtonContainer.refresh();
|
||||
}
|
||||
|
||||
/// Checks the input manager for if we have a gamepad active and gets it's name
|
||||
/// If we have one, also sets the active input type to gamepad
|
||||
function MenuInputButtonContainer::checkGamepad(%this)
|
||||
{
|
||||
%controllerName = SDLInputManager::JoystickNameForIndex(0);
|
||||
|
||||
$activeControllerName = %controllerName;
|
||||
|
||||
if($activeControllerName $= "")
|
||||
$activeControllerType = "K&M";
|
||||
else
|
||||
$activeControllerType = "gamepad";
|
||||
}
|
||||
|
||||
/// This is called by the earlier inputs callback that comes from the menu list
|
||||
/// this allows us to first check what the input type is, and if the device is different
|
||||
/// (such as going from keyboard and mouse to gamepad) we can refresh the buttons to update
|
||||
/// the display
|
||||
/// Then we process the input to see if it matches to any of the button maps for our
|
||||
/// MenuInputButtons. If we have a match, we execute it's command.
|
||||
function MenuInputButtonContainer::processInputs(%this, %device, %action)
|
||||
{
|
||||
//check to see if our status has changed
|
||||
%changed = false;
|
||||
|
||||
%oldDevice = $activeControllerName;
|
||||
|
||||
%deviceName = stripTrailingNumber(%device);
|
||||
|
||||
if(%deviceName $= "keyboard" || %deviceName $= "mouse")
|
||||
{
|
||||
if($activeControllerName !$= "K&M")
|
||||
%changed = true;
|
||||
|
||||
$activeControllerName = "K&M";
|
||||
$activeControllerType = "K&M";
|
||||
Canvas.showCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%this.checkGamepad())
|
||||
{
|
||||
Canvas.hideCursor();
|
||||
}
|
||||
|
||||
if($activeControllerType !$= %oldDevice)
|
||||
%changed = true;
|
||||
}
|
||||
|
||||
if(%changed)
|
||||
%this.refresh();
|
||||
|
||||
//Now process the input for the button accelerator, if applicable
|
||||
//Set up our basic buttons
|
||||
for(%i=0; %i < %this.getCount(); %i++)
|
||||
{
|
||||
%btn = %this.getObject(%i);
|
||||
|
||||
if(!%btn.isActive())
|
||||
continue;
|
||||
|
||||
if($activeControllerType !$= "K&M")
|
||||
{
|
||||
if(%btn.gamepadButton $= %action)
|
||||
{
|
||||
eval(%btn.command);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%btn.keyboardButton $= %action)
|
||||
{
|
||||
eval(%btn.command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This is called by the earlier inputs callback that comes from the menu list
|
||||
/// this allows us to first check what the input type is, and if the device is different
|
||||
/// (such as going from keyboard and mouse to gamepad) we can refresh the buttons to update
|
||||
/// the display
|
||||
function MenuInputButtonContainer::processAxisEvent(%this, %device, %action, %axisVal)
|
||||
{
|
||||
//check to see if our status has changed
|
||||
%changed = false;
|
||||
|
||||
%oldDevice = $activeControllerName;
|
||||
|
||||
%deviceName = stripTrailingNumber(%device);
|
||||
|
||||
if(%deviceName $= "mouse")
|
||||
{
|
||||
if($activeControllerName !$= "K&M")
|
||||
%changed = true;
|
||||
|
||||
$activeControllerName = "K&M";
|
||||
$activeControllerType = "K&M";
|
||||
Canvas.showCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(%this.checkGamepad())
|
||||
{
|
||||
Canvas.hideCursor();
|
||||
}
|
||||
|
||||
if($activeControllerType !$= %oldDevice)
|
||||
%changed = true;
|
||||
}
|
||||
|
||||
if(%changed)
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
function onSDLDeviceConnected(%sdlIndex, %deviceName, %deviceType)
|
||||
{
|
||||
/*if(GamepadButtonsGui.checkGamepad())
|
||||
{
|
||||
GamepadButtonsGui.hidden = false;
|
||||
}*/
|
||||
}
|
||||
|
||||
function onSDLDeviceDisconnected(%sdlIndex)
|
||||
{
|
||||
/*if(!GamepadButtonsGui.checkGamepad())
|
||||
{
|
||||
GamepadButtonsGui.hidden = true;
|
||||
}*/
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Menu Input processing
|
||||
// These functions manage the Menu input processing in general
|
||||
// Whenever a MenuInputHandler consumes an input event, it'll process them here
|
||||
// This'll let the active menu list be navigated, as well as buttons be processed
|
||||
// and ultimately handled by the Input Buttons above
|
||||
//==============================================================================
|
||||
function MenuInputHandler::onAxisEvent(%this, %device, %action, %value)
|
||||
{
|
||||
//this is to force a refresh of the menu
|
||||
if(%value == 1 || %value == -1)
|
||||
$activeMenuButtonContainer.processInputs(%device, %action);
|
||||
|
||||
if(startsWith(%device, "mouse"))
|
||||
return;
|
||||
|
||||
if((%action $= "upov" && %value > 0) || (%action $= "yaxis" && %value == -1))
|
||||
{
|
||||
$activeMenuList.navigateUp();
|
||||
}
|
||||
|
||||
if((%action $= "dpov" && %value > 0) || (%action $= "yaxis" && %value == 1))
|
||||
{
|
||||
$activeMenuList.navigateDown();
|
||||
}
|
||||
|
||||
//How we deal with the left and right navigation is dependant on the mode of the
|
||||
//menu list
|
||||
if($activeMenuListMode $= "Settings")
|
||||
{
|
||||
if((%action $= "lpov" && %value > 0) || (%action $= "xaxis" && %value == -1))
|
||||
{
|
||||
echo("Options menu nudged left!");
|
||||
//$activeMenuList.navigateLeft();
|
||||
}
|
||||
|
||||
if((%action $= "rpov" && %value > 0) || (%action $= "xaxis" && %value == -1))
|
||||
{
|
||||
echo("Options menu nudged right!");
|
||||
//$activeMenuList.navigateRight();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((%action $= "lpov" && %value > 0) || (%action $= "xaxis" && %value == -1))
|
||||
{
|
||||
$activeMenuList.navigateLeft();
|
||||
}
|
||||
|
||||
if((%action $= "rpov" && %value > 0) || (%action $= "xaxis" && %value == -1))
|
||||
{
|
||||
$activeMenuList.navigateRight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function MenuInputHandler::onInputEvent(%this, %device, %action, %state)
|
||||
{
|
||||
if(%action $= "upov" || %action $= "dpov" || %action $= "lpov" || %action $= "rpov")
|
||||
{
|
||||
%this.onAxisEvent(%device, %action, %state);
|
||||
return;
|
||||
}
|
||||
|
||||
if(%state)
|
||||
$activeMenuButtonContainer.processInputs(%device, %action);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Menu List processing
|
||||
// These functions manage the navigation and activation of the Menu Lists
|
||||
//==============================================================================
|
||||
|
||||
function MenuList::setAsActiveMenuList(%this, %startPosition, %menuMode)
|
||||
{
|
||||
if(%startPosition $= "")
|
||||
%startPosition = "0 0";
|
||||
|
||||
if(%menuMode $= "")
|
||||
%menuMode = "Menu";
|
||||
|
||||
$activeMenuList = %this;
|
||||
$activeMenuList.hidden = false;
|
||||
$activeMenuListPosition = %startPosition;
|
||||
$activeMenuListMode = %menuMode;
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
|
||||
function MenuList::activate(%this)
|
||||
{
|
||||
//check for a highlighted element
|
||||
if($activeMenuListPosition.y > -1 && $activeMenuListPosition < $activeMenuList.getCount())
|
||||
{
|
||||
%btn = $activeMenuList.getObject($activeMenuListPosition.y);
|
||||
%btn.performClick();
|
||||
}
|
||||
}
|
||||
|
||||
function MenuList::refresh(%this)
|
||||
{
|
||||
%selectedObject = 0;
|
||||
for(%i=0; %i < $activeMenuList.getCount(); %i++)
|
||||
{
|
||||
%btn = $activeMenuList.getObject(%i);
|
||||
|
||||
%isSelected = %i == $activeMenuListPosition.y;
|
||||
|
||||
%btn.setHighlighted(%isSelected);
|
||||
|
||||
if(%isSelected)
|
||||
%selectedObject = %i;
|
||||
}
|
||||
|
||||
if($activeMenuList.isMethod("onNavigate"))
|
||||
$activeMenuList.onNavigate($activeMenuListPosition.y);
|
||||
|
||||
%parent = $activeMenuList.getParent();
|
||||
if(%parent.getClassName() $= "GuiScrollCtrl")
|
||||
{
|
||||
%parent.scrollToObject(%selectedObject);
|
||||
}
|
||||
}
|
||||
|
||||
function MenuList::navigateUp(%this)
|
||||
{
|
||||
$activeMenuListPosition.y -= 1;
|
||||
if($activeMenuListPosition.y < 0)
|
||||
$activeMenuListPosition.y = 0;
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function MenuList::navigateDown(%this)
|
||||
{
|
||||
$activeMenuListPosition.y += 1;
|
||||
if($activeMenuListPosition.y >= $activeMenuList.getCount())
|
||||
$activeMenuListPosition.y = $activeMenuList.getCount()-1;
|
||||
|
||||
%this.refresh();
|
||||
}
|
||||
|
||||
function MenuList::navigateLeft()
|
||||
{
|
||||
echo("Menu list navigated left!");
|
||||
|
||||
//Atm, we're only handling specific control types, namely options entries, but
|
||||
//this could readily be expanded upon to handle grids like for inventory screens
|
||||
//or the like
|
||||
|
||||
%btn = $activeMenuList.getObject($activeMenuListPosition.y);
|
||||
if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled())
|
||||
{
|
||||
warnf("MenuList::navigateLeft() - actioned the option" @ %btn @ " to the left");
|
||||
}
|
||||
}
|
||||
|
||||
function MenuList::navigateRight()
|
||||
{
|
||||
echo("Menu list navigated right!");
|
||||
|
||||
%btn = $activeMenuList.getObject($activeMenuListPosition.y);
|
||||
if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled())
|
||||
{
|
||||
warnf("MenuList::navigateLeft() - actioned the option" @ %btn @ " to the left");
|
||||
}
|
||||
}
|
||||