From 616d9742123d00ff3ea2e05f4d47b6982f870e75 Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 6 Dec 2023 19:50:51 -0600 Subject: [PATCH 01/19] Wipwork for updating the BaseUI Adds ability to select an actionmap for a GuiInputCtrl which will push it onto the stack, so menus can enact an action map Update of the MainMenuGUI to fit new style and have the logic needed for KBM and gamepad navigation Very early wipwork of OptionsMenu overhaul for new standard --- .../source/gui/editor/guiInspectorTypes.cpp | 39 ++ Engine/source/gui/editor/guiInspectorTypes.h | 14 + Engine/source/gui/utility/guiInputCtrl.cpp | 18 + Engine/source/gui/utility/guiInputCtrl.h | 3 + .../rendering/scripts/graphicsOptions.tscript | 318 ++++++++------- Templates/BaseGame/game/data/UI/UI.tscript | 6 +- .../game/data/UI/guis/MainMenuButtons.tscript | 11 +- .../BaseGame/game/data/UI/guis/mainMenu.gui | 188 +++++---- .../game/data/UI/guis/mainMenu.tscript | 122 ++++-- .../game/data/UI/guis/optionsMenu.gui | 379 +++++++++--------- .../game/data/UI/guis/optionsMenu.tscript | 110 +++++ .../game/data/UI/scripts/profiles.tscript | 30 +- 12 files changed, 746 insertions(+), 492 deletions(-) diff --git a/Engine/source/gui/editor/guiInspectorTypes.cpp b/Engine/source/gui/editor/guiInspectorTypes.cpp index 8da27c273..7cb489163 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.cpp +++ b/Engine/source/gui/editor/guiInspectorTypes.cpp @@ -40,6 +40,7 @@ #include "gui/editor/editorFunctions.h" #include "math/mEase.h" #include "math/mathTypes.h" +#include "sim/actionMap.h" //----------------------------------------------------------------------------- @@ -387,6 +388,44 @@ void GuiInspectorTypeGuiProfile::consoleInit() ConsoleBaseType::getType( TYPEID< GuiControlProfile >() )->setInspectorFieldType("GuiInspectorTypeGuiProfile"); } +//----------------------------------------------------------------------------- +// GuiInspectorTypeActionMap +//----------------------------------------------------------------------------- +IMPLEMENT_CONOBJECT(GuiInspectorTypeActionMap); + +ConsoleDocClass(GuiInspectorTypeActionMap, + "@brief Inspector field type for ActionMap\n\n" + "Editor use only.\n\n" + "@internal" +); + +void GuiInspectorTypeActionMap::_populateMenu(GuiPopUpMenuCtrl* menu) +{ + // Add the action maps to the menu. + //First add a blank entry so you can clear the action map + menu->addEntry("", 0); + + SimGroup* grp = Sim::getRootGroup(); + SimSetIterator iter(grp); + for (; *iter; ++iter) + { + ActionMap* actionMap = dynamic_cast(*iter); + if (!actionMap) + continue; + + menu->addEntry(actionMap->getName(), actionMap->getId()); + } + + menu->sort(); +} + +void GuiInspectorTypeActionMap::consoleInit() +{ + Parent::consoleInit(); + + ConsoleBaseType::getType(TYPEID< ActionMap >())->setInspectorFieldType("GuiInspectorTypeActionMap"); +} + //----------------------------------------------------------------------------- // GuiInspectorTypeCheckBox //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/editor/guiInspectorTypes.h b/Engine/source/gui/editor/guiInspectorTypes.h index 31b21a186..d5cb90f93 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.h +++ b/Engine/source/gui/editor/guiInspectorTypes.h @@ -186,6 +186,20 @@ public: virtual void _populateMenu( GuiPopUpMenuCtrl *menu ); }; +//----------------------------------------------------------------------------- +// GuiInspectorTypeActionMap Class +//----------------------------------------------------------------------------- +class GuiInspectorTypeActionMap : public GuiInspectorTypeMenuBase +{ +private: + typedef GuiInspectorTypeMenuBase Parent; +public: + DECLARE_CONOBJECT(GuiInspectorTypeActionMap); + static void consoleInit(); + + virtual void _populateMenu(GuiPopUpMenuCtrl* menu); +}; + //----------------------------------------------------------------------------- // GuiInspectorTypeCheckBox Class //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/utility/guiInputCtrl.cpp b/Engine/source/gui/utility/guiInputCtrl.cpp index f5f41b486..31d2a2e86 100644 --- a/Engine/source/gui/utility/guiInputCtrl.cpp +++ b/Engine/source/gui/utility/guiInputCtrl.cpp @@ -64,6 +64,7 @@ GuiInputCtrl::GuiInputCtrl() mSendModifierEvents(false), mIgnoreMouseEvents(false) { + mActionmap = nullptr; } //------------------------------------------------------------------------------ @@ -80,6 +81,7 @@ void GuiInputCtrl::initPersistFields() "If true, Make events will be sent for modifier keys (Default false)."); addField("ignoreMouseEvents", TypeBool, Offset(mIgnoreMouseEvents, GuiInputCtrl), "If true, any events from mouse devices will be passed through."); + addField("actionMap", TYPEID(), Offset(mActionmap, GuiInputCtrl), "The name of an action map to push/pop on the input stack alongside the wake/sleep of this control."); endGroup("GuiInputCtrl"); Parent::initPersistFields(); @@ -103,6 +105,12 @@ bool GuiInputCtrl::onWake() if( !smDesignTime && !mIgnoreMouseEvents) mouseLock(); + + if(mActionmap != nullptr) + { + SimSet* actionMapSet = Sim::getActiveActionMapSet(); + actionMapSet->pushObject(mActionmap); + } setFirstResponder(); @@ -115,6 +123,13 @@ void GuiInputCtrl::onSleep() { Parent::onSleep(); mouseUnlock(); + + if (mActionmap != nullptr) + { + SimSet* actionMapSet = Sim::getActiveActionMapSet(); + actionMapSet->removeObject(mActionmap); + } + clearFirstResponder(); } @@ -158,6 +173,9 @@ bool GuiInputCtrl::onInputEvent( const InputEventInfo &event ) if (mIgnoreMouseEvents && event.deviceType == MouseDeviceType) return false; + if (mActionmap != nullptr) + return false; + char deviceString[32]; if ( event.action == SI_MAKE ) { diff --git a/Engine/source/gui/utility/guiInputCtrl.h b/Engine/source/gui/utility/guiInputCtrl.h index 269569693..5b87cc53f 100644 --- a/Engine/source/gui/utility/guiInputCtrl.h +++ b/Engine/source/gui/utility/guiInputCtrl.h @@ -26,6 +26,7 @@ #ifndef _GUIMOUSEEVENTCTRL_H_ #include "gui/utility/guiMouseEventCtrl.h" #endif +#include "sim/actionMap.h" /// A control that locks the mouse and reports all keyboard input events @@ -38,6 +39,8 @@ protected: bool mSendModifierEvents; bool mIgnoreMouseEvents; + ActionMap* mActionmap; + public: typedef GuiMouseEventCtrl Parent; diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript index 19b7f50cd..681873a01 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript @@ -54,153 +54,199 @@ function GraphicsOptionsMenuGroup::applySetting(%this, %settingName) } } -new SimGroup( MeshQualityGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; +//Primary Group(Video, Audio, Controls) +//Sub Grouping(Basic, Advanced, or Display, Graphics) - key["$pref::TS::detailAdjust"] = 1.5; - key["$pref::TS::skipRenderDLs"] = 0; - }; - new ArrayObject( ) - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::TS::detailAdjust"] = 1.0; - key["$pref::TS::skipRenderDLs"] = 0; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::TS::detailAdjust"] = 0.75; - key["$pref::TS::skipRenderDLs"] = 0; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::TS::detailAdjust"] = 0.5; - key["$pref::TS::skipRenderDLs"] = 1; - }; -}; - -new SimGroup( MeshDrawDistQualityGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::useStaticObjectFade"] = false; - key["$pref::staticObjectFadeStart"] = 75; - key["$pref::staticObjectFadeEnd"] = 100; - key["$pref::staticObjectUnfadeableSize"] = 75; - - }; - new ArrayObject( ) - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 75; - key["$pref::staticObjectFadeEnd"] = 100; - key["$pref::staticObjectUnfadeableSize"] = 75; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 50; - key["$pref::staticObjectFadeEnd"] = 75; - key["$pref::staticObjectUnfadeableSize"] = 100; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 25; - key["$pref::staticObjectFadeEnd"] = 50; - key["$pref::staticObjectUnfadeableSize"] = 200; - }; -}; - -new SimGroup( TextureQualityGroup ) +new SimGroup(VideoSettingsGroup) { - class = "GraphicsOptionsMenuGroup"; + class = "PrimaryOptionsGroup"; + displayName = "Video"; - new ArrayObject() + new SimGroup(BasicVideoSettingsGroup) { - class = "GraphicsQualityLevel"; - caseSensitive = true; + class = "SubOptionsGroup"; + displayName = "Basic"; - displayName = "High"; - - key["$pref::Video::textureReductionLevel"] = 0; - key["$pref::Reflect::refractTexScale"] = 1.25; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::Video::textureReductionLevel"] = 0; - key["$pref::Reflect::refractTexScale"] = 1; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; + new SimGroup() + { + class = "OptionsSettings"; + + OptionName = "Graphical Quality"; + Description = "Controls the general graphical quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; - key["$pref::Video::textureReductionLevel"] = 1; - key["$pref::Reflect::refractTexScale"] = 0.75; + displayName = "High"; + + key["$pref::TS::detailAdjust"] = 1.5; + key["$pref::TS::skipRenderDLs"] = 0; + key["$pref::useStaticObjectFade"] = false; + key["$pref::staticObjectFadeStart"] = 75; + key["$pref::staticObjectFadeEnd"] = 100; + key["$pref::staticObjectUnfadeableSize"] = 75; + }; + }; }; - new ArrayObject() + + /*new SimGroup(AdvancedVideoSettingsGroup) { - class = "GraphicsQualityLevel"; - caseSensitive = true; + groupName = "Advanced"; - displayName = "Lowest"; - - key["$pref::Video::textureReductionLevel"] = 2; - key["$pref::Reflect::refractTexScale"] = 0.5; - }; + new SimGroup( MeshQualityGroup ) + { + class = "GraphicsOptionsMenuGroup"; + + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::TS::detailAdjust"] = 1.5; + key["$pref::TS::skipRenderDLs"] = 0; + }; + new ArrayObject( ) + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::TS::detailAdjust"] = 1.0; + key["$pref::TS::skipRenderDLs"] = 0; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::TS::detailAdjust"] = 0.75; + key["$pref::TS::skipRenderDLs"] = 0; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Lowest"; + + key["$pref::TS::detailAdjust"] = 0.5; + key["$pref::TS::skipRenderDLs"] = 1; + }; + }; + + new SimGroup( MeshDrawDistQualityGroup ) + { + class = "GraphicsOptionsMenuGroup"; + + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::useStaticObjectFade"] = false; + key["$pref::staticObjectFadeStart"] = 75; + key["$pref::staticObjectFadeEnd"] = 100; + key["$pref::staticObjectUnfadeableSize"] = 75; + + }; + new ArrayObject( ) + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 75; + key["$pref::staticObjectFadeEnd"] = 100; + key["$pref::staticObjectUnfadeableSize"] = 75; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 50; + key["$pref::staticObjectFadeEnd"] = 75; + key["$pref::staticObjectUnfadeableSize"] = 100; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Lowest"; + + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 25; + key["$pref::staticObjectFadeEnd"] = 50; + key["$pref::staticObjectUnfadeableSize"] = 200; + }; + }; + + new SimGroup( TextureQualityGroup ) + { + class = "GraphicsOptionsMenuGroup"; + + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Video::textureReductionLevel"] = 0; + key["$pref::Reflect::refractTexScale"] = 1.25; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::Video::textureReductionLevel"] = 0; + key["$pref::Reflect::refractTexScale"] = 1; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Video::textureReductionLevel"] = 1; + key["$pref::Reflect::refractTexScale"] = 0.75; + }; + new ArrayObject() + { + class = "GraphicsQualityLevel"; + caseSensitive = true; + + displayName = "Lowest"; + + key["$pref::Video::textureReductionLevel"] = 2; + key["$pref::Reflect::refractTexScale"] = 0.5; + }; + }; + + };*/ }; +//Fields have display name, populated by group. Direct name association to the fieldset + new SimGroup( GroundCoverDensityGroup ) { class = "GraphicsOptionsMenuGroup"; diff --git a/Templates/BaseGame/game/data/UI/UI.tscript b/Templates/BaseGame/game/data/UI/UI.tscript index 3baad2bd5..455067910 100644 --- a/Templates/BaseGame/game/data/UI/UI.tscript +++ b/Templates/BaseGame/game/data/UI/UI.tscript @@ -41,7 +41,7 @@ function UI::initClient(%this) %this.queueExec("./scripts/profiles"); //Navigation Utility Scripts - %this.queueExec("./scripts/menuNavigation"); + //%this.queueExec("./scripts/menuNavigation"); //Now gui files %this.queueExec("./scripts/menuInputHandling"); @@ -49,8 +49,8 @@ function UI::initClient(%this) %this.queueExec("./guis/mainMenu"); %this.queueExec("./guis/mainMenu.gui"); - %this.queueExec("./guis/mainMenuButtons"); - %this.queueExec("./guis/mainMenuButtons.gui"); + //%this.queueExec("./guis/mainMenuButtons"); + //%this.queueExec("./guis/mainMenuButtons.gui"); %this.queueExec("./guis/chooseLevelDlg"); %this.queueExec("./guis/chooseLevelDlg.gui"); diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript index be79f9dd3..1a79ff5fb 100644 --- a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript +++ b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript @@ -94,16 +94,7 @@ function openJoinServerMenu() MainMenuGui.pushPage(JoinServerMenu); } -function openOptionsMenu() -{ - //Here, like the other commands, we add a new page onto the stack - //In this case, we'll push the OptionsMenu control onto the stack. This will - //invoke the canClose() and then onClose() functions for MainMenuButtonList - //before calling the onOpen() for OptionsMenu then displaying. - //The options menu additionally has an example of why we may want to capitalize on the - //canClose() call. - MainMenuGui.pushPage(OptionsMenu); -} + function openWorldEditorBtn() { diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index 69ceaf317..7d6374594 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -1,40 +1,41 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { BitmapAsset = "UI:backgrounddark_image"; - extent = "1024 768"; + extent = "1280 720"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; - superClass = "UINavigation"; - canSaveDynamicFields = "0"; - + canSaveDynamicFields = "1"; + + new GuiInputCtrl(MainMenuInputHandler) { + sendAxisEvents = "0"; + sendBreakEvents = "0"; + ignoreMouseEvents = "1"; + position = "-50 0"; + extent = "2186 851"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + //class = "MenuInputHandler"; + actionMap = MainMenuActionMap; + }; new GuiBitmapCtrl(SideBackgroundImage) { - bitmapAsset = "UI:menu_side_background_image"; - color = "255 255 255 255"; - wrap = "0"; - position = "0 0"; + BitmapAsset = "UI:menu_side_background_image"; + position = "0 -48"; extent = "900 600"; - minExtent = "8 2"; - horizSizing = "right"; vertSizing = "top"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; - new GuiBitmapCtrl(MainMenuAppLogo) { BitmapAsset = "UI:Torque_3D_logo_image"; - position = "550 30"; + position = "462 30"; extent = "360 100"; - horizSizing = "left"; + horizSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; canSaveDynamicFields = "1"; @@ -46,98 +47,95 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { useModifiers = "0"; useStates = "1"; }; - new GuiControl(MainMenuButtonHolder) { - position = "143 711"; - extent = "736 40"; - horizSizing = "center"; + new GuiPanel(MainMenuButtonPanel) { + position = "0 683"; + extent = "1281 40"; + horizSizing = "width"; vertSizing = "top"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiIconButtonCtrl(MainMenuGoButton) { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Go"; + position = "1115 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "activateSelected();"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiStackControl(MainMenuButtonList) { + padding = "5"; + dynamicSize = "0"; + position = "440 185"; + extent = "400 322"; + horizSizing = "center"; + vertSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - class = "MenuInputButtonContainer"; + superClass = "MenuList"; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Go"; - position = "11 0"; - extent = "140 40"; + new GuiButtonCtrl(MainMenuSinglePlayerBtn) { + text = "Single Player"; + extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "MainMenuButtonList.activate();"; + command = "openSinglePlayerMenu();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button1"; - class = "MenuInputButton"; }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Go"; - position = "155 0"; - extent = "140 40"; + new GuiButtonCtrl(MainMenuCreateSrvrBtn) { + text = "Create Server"; + position = "0 45"; + extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "MainMenuButtonList.activate();"; + command = "openMultiPlayerMenu();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button2"; - class = "MenuInputButton"; }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Go"; - position = "299 0"; - extent = "140 40"; + new GuiButtonCtrl(MainMenuJoinSrvrBtn) { + text = "Join Server"; + position = "0 90"; + extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "MainMenuButtonList.activate();"; + command = "openJoinServerMenu();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button3"; - class = "MenuInputButton"; }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Go"; - position = "443 0"; - extent = "140 40"; + new GuiButtonCtrl(MainMenuOptionBtn) { + text = "Options"; + position = "0 135"; + extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "MainMenuButtonList.activate();"; + command = "Canvas.pushDialog(OptionsMenu);"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuWorldEditBtn) { + text = "Open World Editor (F11)"; + position = "0 180"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "openWorldEditorBtn();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuGuiEditBtn) { + text = "Open GUI Editor (F10)"; + position = "0 225"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "openGUIEditorBtn();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl(MainMenuExitBtn) { + text = "Exit"; + position = "0 270"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "quit();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; - class = "MenuInputButton"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - text = "Go"; - position = "587 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - command = "MainMenuButtonList.activate();"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button5"; - class = "MenuInputButton"; }; - }; - new GuiInputCtrl(MainMenuInputHandler) { - sendAxisEvents = "1"; - sendBreakEvents = "1"; - ignoreMouseEvents = "1"; - position = "-50 0"; - extent = "10 10"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiInputCtrlProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputHandler"; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index ec4fa44f7..9ec352dc1 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -1,52 +1,90 @@ function MainMenuGui::onAdd(%this) { - $activeControllerName = "K&M"; //default input type } function MainMenuGui::onWake(%this) { - //In the BaseUI example case, the MainMenuGUI acts as our background - //So it's a logical control to set as our UINavigation as well. So we - //set the MainMenuGUI's superClass to UINavigation to integrate it into - //that namespace to open up page navigation - - //At the same time, the MainMenuGUI control has the button holder, set to - //the MenuInputButtonContainer class, allowing us to set it as the active button - //holder here, prepping it for catching any button inputs to active commands - //Specifically, it sets the $activeMenuButtonContainer to be this, which allows - //other controls to manage what the behavior of the buttons is consistently - //without needing to worry about hardcoded names - MainMenuButtonHolder.setActive(); - - //We also have the MainMenuInputHandler, a GuiInputCtrl with the MenuInputHandler class - //This allows us to catch any input/axis event and pass it along to the active menuList - //or button containers to navigate the menus - //We set up this catch by making said control our first responder, here - MainMenuInputHandler.setFirstResponder(); - - //We also go ahead and mark for any future pages being added to the UINavigation's page stack - //to be prompted to resize when added. This isn't required, but helps keep pages formated to - //the current size of the UINavigation, which is useful when dealing with aspect ratio or resolution - //changes. - %this.resizePages = true; - //Lastly, we go ahead and display some actual navigable content up on our main menu here - //In this case, we set the MainMenuButtons as our root page, so we always come back - //to having the main menu buttons on screen if every other page is closed. - //This will ultimately call MainMenuButtons::onOpen(), so to see where the navigation - //chain continues, see that function. - %this.setRootPage(MainMenuButtons); - - %this.refreshPage(); + MainMenuButtonList.listPosition = 0; } -function MainMenuButtonHolder::onWake(%this) +if(!isObject( MainMenuActionMap ) ) { - //Because the blan slate MainMenuGUI doesn't have anything we need to bother with inputs on - //we just go ahead and disable all the buttons in our MainMenuButtonHolder to have - // a clean slate - %this-->button1.disable(); - %this-->button2.disable(); - %this-->button3.disable(); - %this-->button4.disable(); - %this-->button5.disable(); + new ActionMap(MainMenuActionMap){}; + + MainMenuActionMap.bind( keyboard, w, mainMenuNavigateUp ); + MainMenuActionMap.bind( keyboard, s, mainMenuNavigateDown ); + MainMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", mainMenuStickNavigate ); + MainMenuActionMap.bind( gamepad, upov, mainMenuNavigateUp ); + MainMenuActionMap.bind( gamepad, dpov, mainMenuNavigateDown ); + + MainMenuActionMap.bind( keyboard, Enter, activateSelected ); + MainMenuActionMap.bind( gamepad, btn_a, activateSelected ); +} + +function mainMenuNavigateUp(%val) +{ + if(%val) + { + MainMenuButtonList.listPosition -= 1; + if(MainMenuButtonList.listPosition < 0) + MainMenuButtonList.listPosition = 0; + + MainMenuGUI.syncGUI(); + } +} + +function mainMenuNavigateDown(%val) +{ + if(%val) + { + MainMenuButtonList.listPosition += 1; + if(MainMenuButtonList.listPosition >= MainMenuButtonList.getCount()) + MainMenuButtonList.listPosition = MainMenuButtonList.getCount()-1; + + MainMenuGUI.syncGUI(); + } +} + +function mainMenuStickNavigate(%val) +{ + if(%val == -1) + mainMenuNavigateUp(1); + else if(%val == 1) + mainMenuNavigateDown(1); +} + +function MainMenuGUI::syncGUI(%this) +{ + MainMenuButtonList.callOnChildren("setHighlighted", false); + + %btn = MainMenuButtonList.getObject(MainMenuButtonList.listPosition); + %btn.setHighlighted(true); + + // + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + %binding = MainMenuActionMap.getBinding("activateSelected"); + + %bindingCount = getFieldCount(%binding); + for(%i=0; %i < %bindingCount; %i+=2) + { + %mapDevice = stripTrailingNumber(getField(%binding, %i)); + if(%mapDevice $= %device) + { + %button = getField(%binding, %i+1); + break; + } + } + + %assetId = getButtonBitmap(%device, %button); + MainMenuGoButton.setBitmap(%assetId); +} + +function activateSelected() +{ + %btn = MainMenuButtonList.getObject(MainMenuButtonList.listPosition); + %btn.performClick(); } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 8a85fd848..33eae9db5 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -1,226 +1,211 @@ //--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(OptionsMenu) { - extent = "1024 768"; - profile = "GuiNonModalDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; +$guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { + BitmapAsset = "UI:backgrounddark_image"; + extent = "1280 720"; + minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; - canSaveDynamicFields = "0"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; + currentCategory = "Graphics"; + optionsCategories = "17233"; + unappliedChanges = "17234"; new GuiControl(OptionsMenuContainer) { - position = "48 56"; - extent = "928 655"; + position = "208 32"; + extent = "870 655"; horizSizing = "aspectCenter"; vertSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; + }; + new GuiInputCtrl(MainMenuInputHandler) { + ignoreMouseEvents = "1"; + ActionMap = "MainMenuActionMap"; + position = "-49 0"; + extent = "2186 851"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiStackControl(OptionsMenuCategoryList) { + stackingType = "Horizontal"; + padding = "10"; + dynamicSize = "0"; + position = "398 80"; + extent = "471 40"; + horizSizing = "center"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_low_image"; - position = "0 40"; - extent = "927 618"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; + new GuiButtonCtrl() { + text = "Video"; + extent = "100 40"; + profile = "GuiMenuButtonProfile"; + command = "populateDisplaySettingsList();"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_image"; - extent = "927 40"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; + new GuiButtonCtrl() { + text = "Audio"; + position = "110 0"; + extent = "100 40"; + profile = "GuiMenuButtonProfile"; + command = "populateAudioSettingsList();"; tooltipProfile = "GuiToolTipProfile"; }; + new GuiButtonCtrl() { + text = "Keyboard & Mouse"; + position = "220 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "populateKeyboardMouseSettingsList();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Gamepad"; + position = "370 0"; + extent = "100 40"; + profile = "GuiMenuButtonProfile"; + command = "populateGamepadSettingsList();"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiScrollCtrl(OptionsMenuSettingsScroll) { + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + position = "331 128"; + extent = "618 555"; + horizSizing = "center"; + vertSizing = "height"; + profile = "GuiMenuScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiStackControl(VideoSettingsList) { + padding = "5"; + changeChildSizeToFit = "0"; + position = "1 1"; + extent = "603 245"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + visible = true; + }; + new GuiStackControl(AudioSettingsList) { + padding = "5"; + changeChildSizeToFit = "0"; + position = "1 1"; + extent = "603 245"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + visible = false; + }; + new GuiStackControl(ControlSettingsList) { + padding = "5"; + changeChildSizeToFit = "0"; + position = "1 1"; + extent = "603 245"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + visible = false; + }; + }; + new GuiPanel(OptionMenuTitlePanel) { + extent = "1281 80"; + horizSizing = "width"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + new GuiTextCtrl() { text = "OPTIONS"; - position = "22 7"; + position = "22 23"; extent = "220 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextCtrl(OptionName) { - position = "3 606"; - extent = "293 17"; - horizSizing = "width"; - profile = "MenuSubHeaderText"; + }; + new GuiPanel(MainMenuButtonPanel) { + position = "0 683"; + extent = "1281 40"; + horizSizing = "width"; + vertSizing = "top"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Apply"; + position = "1115 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuSelectButton(1);"; tooltipProfile = "GuiToolTipProfile"; + internalName = "button4"; + class = "MenuInputButton"; }; - new GuiMLTextCtrl(OptionDescription) { - text = "This is a placeholder text for an option."; - position = "3 625"; - extent = "293 14"; - horizSizing = "width"; - profile = "GuiMLTextProfile"; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Back"; + position = "16 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuSelectButton(1);"; tooltipProfile = "GuiToolTipProfile"; - }; - new GuiSplitContainer() { - splitPoint = "250 100"; - fixedPanel = "FirstPanel"; - fixedSize = "250"; - position = "0 48"; - extent = "928 555"; - horizSizing = "width"; - profile = "GuiMenuScrollProfile"; - tooltipProfile = "GuiToolTipProfile"; - - new GuiPanel() { - docking = "Client"; - extent = "248 555"; - profile = "GuiOverlayProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "Panel1"; - - new GuiStackControl(OptionsMenuCategoryList) { - padding = "10"; - dynamicSize = "0"; - extent = "248 555"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - - new GuiButtonCtrl() { - text = "Display"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "populateDisplaySettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Graphics"; - position = "0 45"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "populateGraphicsSettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Audio"; - position = "0 90"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "populateAudioSettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Keyboard & Mouse"; - position = "0 135"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "populateKeyboardMouseSettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Gamepad"; - position = "0 180"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "populateGamepadSettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Example Options"; - position = "0 225"; - extent = "248 35"; - profile = "GuiMenuButtonProfile"; - command = "testExampleOptions();"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; - }; - new GuiPanel() { - docking = "Client"; - position = "252 0"; - extent = "676 555"; - profile = "GuiOverlayProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "panel2"; - - new GuiScrollCtrl(OptionsMenuSettingsScroll) { - hScrollBar = "alwaysOff"; - vScrollBar = "dynamic"; - extent = "676 554"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiMenuScrollProfile"; - tooltipProfile = "GuiToolTipProfile"; - - new GuiStackControl(OptionsMenuSettingsList) { - padding = "5"; - changeChildSizeToFit = "0"; - position = "1 1"; - extent = "661 170"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - new GuiGameSettingsCtrl() { - PreviousBitmapAsset = "UI:previousOption_n_image"; - NextBitmapAsset = "UI:nextOption_n_image"; - columnSplit = "198"; - useMouseEvents = "1"; - extent = "661 30"; - horizSizing = "width"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuOptionsButton"; - }; - new GuiGameSettingsCtrl() { - PreviousBitmapAsset = "UI:previousOption_n_image"; - NextBitmapAsset = "UI:nextOption_n_image"; - columnSplit = "198"; - useMouseEvents = "1"; - position = "0 35"; - extent = "661 30"; - horizSizing = "width"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuOptionsButton"; - }; - new GuiGameSettingsCtrl() { - PreviousBitmapAsset = "UI:previousOption_n_image"; - NextBitmapAsset = "UI:nextOption_n_image"; - columnSplit = "198"; - useMouseEvents = "1"; - position = "0 70"; - extent = "661 30"; - horizSizing = "width"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuOptionsButton"; - }; - new GuiGameSettingsCtrl() { - PreviousBitmapAsset = "UI:previousOption_n_image"; - NextBitmapAsset = "UI:nextOption_n_image"; - columnSplit = "198"; - useMouseEvents = "1"; - position = "0 105"; - extent = "661 30"; - horizSizing = "width"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuOptionsButton"; - }; - new GuiGameSettingsCtrl() { - PreviousBitmapAsset = "UI:previousOption_n_image"; - NextBitmapAsset = "UI:nextOption_n_image"; - columnSplit = "198"; - useMouseEvents = "1"; - position = "0 140"; - extent = "661 30"; - horizSizing = "width"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuOptionsButton"; - }; - }; - }; + internalName = "button4"; + class = "MenuInputButton"; }; }; - + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_E_image"; + iconLocation = "Center"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + position = "899 80"; + extent = "50 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuSelectButton(1);"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button4"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl() { + BitmapAsset = "UI:Keyboard_Black_Q_image"; + iconLocation = "Center"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + position = "331 80"; + extent = "50 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "MainMenuSelectButton(1);"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "button4"; + class = "MenuInputButton"; }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index a8db2ba83..5bdc09e92 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -72,6 +72,49 @@ function OptionsMenu::onAdd(%this) callOnModules("populateOptionsMenuCategories", "Game"); } +function OptionsMenu::onWake(%this) +{ + VideoSettingsList.clear(); + + for(%i=0; %i < VideoSettingsGroup.getCount(); %i++) + { + %setting = VideoSettingsGroup.getObject(%i); + + echo(" OptionsMenu::onWake() - video: " @ %setting.class); + if(%setting.class $= "SubOptionsGroup") + { + %entry = addOptionGroup(); + %entry.text = %setting.displayName; + + if(isObject(%entry)) + VideoSettingsList.add(%entry); + + for(%s=0; %s < %setting.getCount(); %s++) + { + %option = %setting.getObject(%s); + + %optionsEntry = addOptionEntry(); + %optionsEntry-->optionName.text = %option.OptionName; + %optionsEntry-->optionDescription.text = %option.Description; + %optionsEntry-->optionValue.text = %option.getObject(0).displayName; + + if(isObject(%optionsEntry)) + VideoSettingsList.add(%optionsEntry); + } + } + else if(%setting.class $= "OptionsSettings") + { + %entry = addOptionEntry(); + %entry-->optionName.text = %setting.displayName; + %entry-->optionDescription.text = %setting.description; + %entry-->optionValue.text = %setting.getObject(0).displayName; + + if(isObject(%entry)) + VideoSettingsList.add(%entry); + } + } +} + function OptionsMenu::onOpen(%this) { OptionsMenuCategoryList.clear(); @@ -1179,3 +1222,70 @@ function addKeybindOption(%label, %description, %bitmapName, %callback, %enabled OptionsMenuSettingsList.addSliderRow(%label, %bitmapName, %callback, %enabled, %description); } + + +// +// +// +function addOptionGroup() +{ + %group = new GuiTextCtrl() { + text = "Graphics"; + position = "0 0"; + extent = "500 30"; + profile = "MenuHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + + return %group; + +} + +function addOptionEntry() +{ + %entry = new GuiContainer() { + position = "0 0"; + extent = "500 40"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = ""; + position = "1 -1"; + extent = "250 20"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionName"; + }; + new GuiTextCtrl() { + text = "Sets the resolution and detail of shadows"; + position = "1 17"; + extent = "250 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionDescription"; + }; + + new GuiContainer() { + position = "250 0"; + extent = "250 40"; + profile = GuiModelessDialogProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "left"; + vertSizing = "height"; + + new GuiTextCtrl() { + text = "< High >"; + position = "180 0"; + extent = "70 40"; + profile = "GuiMenuTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "left"; + vertSizing = "center"; + internalName = "optionValue"; + }; + }; + }; + + return %entry; +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index 16d2caa45..8a3e1fa9e 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -87,27 +87,32 @@ if( !isObject( GuiMenuButtonProfile ) ) new GuiControlProfile( GuiMenuButtonProfile ) { opaque = true; - border = true; + border = false; fontSize = 18; fontType = "Arial Bold"; - fontColor = $TextMediumEmphasisColor; - fontColorHL = $TextMediumEmphasisColor; - fontColorNA = $TextDisabledColor; - fontColorSEL = $TextMediumEmphasisColor; - fillColor = "40 40 40"; - fillColorHL = "49 34 37"; + fontColor = "200 200 200 255"; + fontColorHL = "0 0 0 255"; + fontColorNA = "108 108 108 255"; + fontColorSEL = "200 200 200 255"; + fillColor = "0 0 0 0"; + fillColorHL = "255 255 255 255"; fillColorNA = "40 40 40"; borderColor = "87 87 87"; borderColorNA = "0 0 0"; borderColorHL = "194 64 64"; - fixedExtent = false; + fixedExtent = 0; justify = "center"; canKeyFocus = false; //bitmapAsset = "UI:menu_button_image"; hasBitmapArray = false; soundButtonDown = "UI:buttonClick"; soundButtonOver = "UI:buttonHover"; - category = "Core"; + category = "BaseUI"; + fontColors[0] = "200 200 200 255"; + fontColors[2] = "108 108 108 255"; + fontColors[3] = "200 200 200 255"; + fontColors[5] = "Magenta"; + fontColorLinkHL = "Magenta"; }; if( !isObject( GuiHighlightMenuButtonProfile ) ) @@ -555,3 +560,10 @@ singleton GuiControlProfile(SliderBitmapGUIProfile) opaque = false; borderColor = "0 0 0 255"; }; + +singleton GuiControlProfile(GuiMenuPanelProfile) +{ + category = "BaseUI"; + opaque = true; + fillcolor = "15 15 15 255"; +}; From ce4c8dabc90b2fa1a8e76989ca7e87dba8f0d37b Mon Sep 17 00:00:00 2001 From: Areloch Date: Sat, 16 Dec 2023 23:18:33 -0600 Subject: [PATCH 02/19] Ongoing wipwork of the BaseUI update. Some bugfixes pending --- .../source/gui/buttons/guiButtonBaseCtrl.cpp | 5 + Engine/source/gui/buttons/guiButtonBaseCtrl.h | 14 +- .../source/gui/buttons/guiIconButtonCtrl.cpp | 7 +- Engine/source/gui/core/guiControl.cpp | 7 +- Engine/source/gui/core/guiControl.h | 2 + Engine/source/sim/actionMap.cpp | 4 +- .../game/core/gui/scripts/profiles.tscript | 24 +- .../rendering/scripts/graphicsOptions.tscript | 63 ++ Templates/BaseGame/game/data/UI/UI.tscript | 35 +- .../data/UI/guis/ChooseLevelDlg.asset.taml | 5 - .../data/UI/guis/ChooseLevelMenu.asset.taml | 5 + .../game/data/UI/guis/ChooseLevelMenu.gui | 97 +++ .../game/data/UI/guis/ChooseLevelMenu.tscript | 211 +++++ .../game/data/UI/guis/GameMenu.asset.taml | 5 + .../BaseGame/game/data/UI/guis/GameMenu.gui | 97 +++ .../game/data/UI/guis/GameMenu.tscript | 186 +++++ .../data/UI/guis/GuiMusicPlayer.asset.taml | 5 - .../data/UI/guis/IODropdownDlg.asset.taml | 4 - .../game/data/UI/guis/IODropdownDlg.ed.gui | 159 ---- .../data/UI/guis/MainMenuButtons.asset.taml | 5 - .../game/data/UI/guis/MainMenuButtons.gui | 84 -- .../game/data/UI/guis/MainMenuButtons.tscript | 107 --- .../game/data/UI/guis/PauseMenu.asset.taml | 5 - .../game/data/UI/guis/RecordingsDlg.gui | 230 ------ .../game/data/UI/guis/SystemMenu.asset.taml | 5 + .../BaseGame/game/data/UI/guis/SystemMenu.gui | 53 ++ .../game/data/UI/guis/SystemMenu.tscript | 37 + .../game/data/UI/guis/chooseLevelDlg.gui | 106 --- .../game/data/UI/guis/chooseLevelDlg.tscript | 210 ----- .../game/data/UI/guis/guiMusicPlayer.gui | 192 ----- .../game/data/UI/guis/guiMusicPlayer.tscript | 236 ------ .../game/data/UI/guis/joinServerMenu.gui | 262 +++---- .../game/data/UI/guis/joinServerMenu.tscript | 146 +++- .../BaseGame/game/data/UI/guis/mainMenu.gui | 20 +- .../game/data/UI/guis/mainMenu.tscript | 102 +-- .../game/data/UI/guis/messageBoxDlg.gui | 340 +------- .../game/data/UI/guis/messageBoxDlg.tscript | 218 ++++++ .../game/data/UI/guis/optionsMenu.gui | 391 +++++++--- .../game/data/UI/guis/optionsMenu.tscript | 225 +++++- .../BaseGame/game/data/UI/guis/pauseMenu.gui | 163 ---- .../game/data/UI/guis/pauseMenu.tscript | 93 --- .../data/UI/guis/recordingsDlg.asset.taml | 4 - .../BaseGame/game/data/UI/images/backdrop.png | Bin 0 -> 5290 bytes .../data/UI/images/backdrop_image.asset.taml | 3 + .../UI/images/textEditFrame_image.asset.taml | 3 + .../data/UI/scripts/guiTreeViewCtrl.tscript | 50 -- .../game/data/UI/scripts/help.tscript | 90 --- .../data/UI/scripts/menuInputHandling.tscript | 729 ------------------ .../data/UI/scripts/menuNavigation.tscript | 308 -------- .../game/data/UI/scripts/messageBoxes.tscript | 341 -------- .../game/data/UI/scripts/profiles.tscript | 201 ++--- .../game/data/UI/scripts/utility.tscript | 22 + Templates/BaseGame/game/tools/settings.xml | 9 +- 53 files changed, 2033 insertions(+), 3892 deletions(-) delete mode 100644 Templates/BaseGame/game/data/UI/guis/ChooseLevelDlg.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui create mode 100644 Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript create mode 100644 Templates/BaseGame/game/data/UI/guis/GameMenu.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/guis/GameMenu.gui create mode 100644 Templates/BaseGame/game/data/UI/guis/GameMenu.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/GuiMusicPlayer.asset.taml delete mode 100644 Templates/BaseGame/game/data/UI/guis/IODropdownDlg.asset.taml delete mode 100644 Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui delete mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml delete mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui delete mode 100644 Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/PauseMenu.asset.taml delete mode 100644 Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui create mode 100644 Templates/BaseGame/game/data/UI/guis/SystemMenu.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/guis/SystemMenu.gui create mode 100644 Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui delete mode 100644 Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui delete mode 100644 Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.tscript create mode 100644 Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/pauseMenu.gui delete mode 100644 Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript delete mode 100644 Templates/BaseGame/game/data/UI/guis/recordingsDlg.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/images/backdrop.png create mode 100644 Templates/BaseGame/game/data/UI/images/backdrop_image.asset.taml create mode 100644 Templates/BaseGame/game/data/UI/images/textEditFrame_image.asset.taml delete mode 100644 Templates/BaseGame/game/data/UI/scripts/guiTreeViewCtrl.tscript delete mode 100644 Templates/BaseGame/game/data/UI/scripts/help.tscript delete mode 100644 Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript delete mode 100644 Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript delete mode 100644 Templates/BaseGame/game/data/UI/scripts/messageBoxes.tscript diff --git a/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp b/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp index e5efe0279..6477fde03 100644 --- a/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp +++ b/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp @@ -83,6 +83,8 @@ IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseDragged, void, (), (), "pressed the left mouse button on the control and then moves the mouse over a certain distance threshold with " "the mouse button still pressed." ); +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onHighlighted, void, (bool highlighted), (highlighted), + "Called when the status of the button being highlighted changes."); ImplementEnumType( GuiButtonType, "Type of button control.\n\n" @@ -290,6 +292,7 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event) { mDepressed = true; mHighlighted = true; + onHighlighted_callback(true); } else { @@ -297,6 +300,7 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event) SFX->playOnce(mProfile->getSoundButtonOverProfile()); mHighlighted = true; + onHighlighted_callback(true); } } @@ -311,6 +315,7 @@ void GuiButtonBaseCtrl::onMouseLeave(const GuiEvent &) if( isMouseLocked() ) mDepressed = false; mHighlighted = false; + onHighlighted_callback(false); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/buttons/guiButtonBaseCtrl.h b/Engine/source/gui/buttons/guiButtonBaseCtrl.h index 60f76ea4a..e20ebb00f 100644 --- a/Engine/source/gui/buttons/guiButtonBaseCtrl.h +++ b/Engine/source/gui/buttons/guiButtonBaseCtrl.h @@ -73,6 +73,7 @@ class GuiButtonBaseCtrl : public GuiControl DECLARE_CALLBACK( void, onMouseEnter, () ); DECLARE_CALLBACK( void, onMouseLeave, () ); DECLARE_CALLBACK( void, onMouseDragged, () ); + DECLARE_CALLBACK( void, onHighlighted, (bool)); /// @} @@ -95,9 +96,18 @@ class GuiButtonBaseCtrl : public GuiControl bool getStateOn() const { return mStateOn; } void setDepressed( bool depressed ) { mDepressed = depressed; } - void resetState() {mDepressed = false; mHighlighted = false;} + void resetState() + { + mDepressed = false; + mHighlighted = false; + onHighlighted_callback(false); + } - void setHighlighted(bool highlighted) { mHighlighted = highlighted; } + void setHighlighted(bool highlighted) + { + mHighlighted = highlighted; + onHighlighted_callback(highlighted); + } bool isHighlighted() { return mHighlighted; } void acceleratorKeyPress(U32 index); diff --git a/Engine/source/gui/buttons/guiIconButtonCtrl.cpp b/Engine/source/gui/buttons/guiIconButtonCtrl.cpp index 8196d59b0..b9288ec7e 100644 --- a/Engine/source/gui/buttons/guiIconButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiIconButtonCtrl.cpp @@ -253,7 +253,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect ) if (mProfile->mBorder != 0) renderFilledBorder(boundsRect, borderColor, fillColor, mProfile->mBorderThickness); else - GFX->getDrawUtil()->drawRectFill(boundsRect, mProfile->mFillColor); + GFX->getDrawUtil()->drawRectFill(boundsRect, fillColor); } } else if(mHighlighted && mActive) @@ -269,7 +269,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect ) if (mProfile->mBorder != 0) renderFilledBorder(boundsRect, borderColor, fillColor, mProfile->mBorderThickness); else - GFX->getDrawUtil()->drawRectFill(boundsRect, mProfile->mFillColor); + GFX->getDrawUtil()->drawRectFill(boundsRect, fillColor); } } else @@ -388,6 +388,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect ) start.x = iconRect.extent.x + mButtonMargin.x + mTextMargin; } + drawer->setBitmapModulation(fontColor); drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors ); } @@ -395,6 +396,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect ) { Point2I start( mTextMargin, ( getHeight() - mProfile->mFont->getHeight() ) / 2 ); + drawer->setBitmapModulation(fontColor); drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors ); } @@ -408,6 +410,7 @@ void GuiIconButtonCtrl::renderButton( Point2I &offset, const RectI& updateRect ) } else start.set( ( getWidth() - textWidth ) / 2, ( getHeight() - mProfile->mFont->getHeight() ) / 2 ); + drawer->setBitmapModulation( fontColor ); drawer->drawText( mProfile->mFont, start + offset, text, mProfile->mFontColors ); } diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index 37102adf2..a5e21a984 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -218,7 +218,8 @@ GuiControl::GuiControl() : mAddGroup( NULL ), mLangTable(NULL), mFirstResponder(NULL), mHorizSizing(horizResizeRight), - mVertSizing(vertResizeBottom) + mVertSizing(vertResizeBottom), + mCategory(StringTable->EmptyString()) { mConsoleVariable = StringTable->EmptyString(); mAcceleratorKey = StringTable->EmptyString(); @@ -294,6 +295,10 @@ void GuiControl::initPersistFields() addField("accelerator", TypeString, Offset(mAcceleratorKey, GuiControl), "Key combination that triggers the control's primary action when the control is on the canvas." ); + addField("category", TypeString, Offset(mCategory, GuiControl), + "Name of the category this gui control should be grouped into for organizational purposes. Primarily for tooling."); + + endGroup( "Control" ); addGroup( "ToolTip" ); diff --git a/Engine/source/gui/core/guiControl.h b/Engine/source/gui/core/guiControl.h index e0b3c0a76..fdd987468 100644 --- a/Engine/source/gui/core/guiControl.h +++ b/Engine/source/gui/core/guiControl.h @@ -218,6 +218,8 @@ class GuiControl : public SimGroup String mAltConsoleCommand; String mTooltip; + + StringTableEntry mCategory; /// @} diff --git a/Engine/source/sim/actionMap.cpp b/Engine/source/sim/actionMap.cpp index 19e56315d..2e9c3b0e7 100644 --- a/Engine/source/sim/actionMap.cpp +++ b/Engine/source/sim/actionMap.cpp @@ -729,7 +729,8 @@ bool ActionMap::nextBoundNode( const char* function, U32 &devMapIndex, U32 &node for ( U32 j = nodeIndex; j < dvcMap->nodeMap.size(); j++ ) { const Node* node = &dvcMap->nodeMap[j]; - if ( !( node->flags & Node::BindCmd ) && ( dStricmp( function, node->consoleFunction ) == 0 ) ) + if ( ( (node->flags & Node::BindCmd) && (dStricmp(function, node->makeConsoleCommand) == 0 || dStricmp(function, node->breakConsoleCommand) == 0) ) + || (!(node->flags & Node::BindCmd) && dStricmp( function, node->consoleFunction ) == 0 ) ) { devMapIndex = i; nodeIndex = j; @@ -1805,6 +1806,7 @@ bool ActionMap::handleEvent(const InputEventInfo* pEvent) for (SimSet::iterator itr = pActionMapSet->end() - 1; itr > pActionMapSet->begin(); itr--) { ActionMap* pMap = static_cast(*itr); + if (pMap->processAction(pEvent) == true) return true; } diff --git a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript index 199d943eb..bd3d55604 100644 --- a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript +++ b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript @@ -147,25 +147,31 @@ new GuiControlProfile(GuiTextEditProfile) category = "Core"; }; -if(!isObject(GuiMenuScrollProfile)) -new GuiControlProfile(GuiMenuScrollProfile) +if(!isObject(GuiScrollProfile)) +new GuiControlProfile(GuiScrollProfile) { - opaque = true; - fontColor = $TextMediumEmphasisColor; - fontColorHL = $TextMediumEmphasisColor; - fontColorNA = $TextDisabledColor; - fontColorSEL = $TextMediumEmphasisColor; - fillColor = "40 40 40"; + opaque = "0"; + fontColor = "200 200 200 255"; + fontColorHL = "200 200 200 255"; + fontColorNA = "108 108 108 255"; + fontColorSEL = "200 200 200 255"; + fillColor = "0 0 0 0"; fillColorHL = "56 56 56"; fillColorNA = "40 40 40"; borderColor = "87 87 87"; borderColorNA = "0 0 0"; borderColorHL = "255 255 255"; - border = true; + border = "0"; bitmapAsset = "Core_GUI:scrollBar_image"; hasBitmapArray = true; category = "Core"; fontSize = 15; + fontColors[0] = "200 200 200 255"; + fontColors[1] = "200 200 200 255"; + fontColors[2] = "108 108 108 255"; + fontColors[3] = "200 200 200 255"; + fontColors[8] = "Fuchsia"; + fontColors[9] = "255 0 255 255"; }; if(!isObject(GuiOverlayProfile)) diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript index 681873a01..10d883bea 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript @@ -74,6 +74,21 @@ new SimGroup(VideoSettingsGroup) OptionName = "Graphical Quality"; Description = "Controls the general graphical quality"; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::TS::detailAdjust"] = 1.0; + key["$pref::TS::skipRenderDLs"] = 0; + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 75; + key["$pref::staticObjectFadeEnd"] = 100; + key["$pref::staticObjectUnfadeableSize"] = 75; + }; + new ArrayObject() { class = "OptionsQualityLevel"; @@ -89,6 +104,54 @@ new SimGroup(VideoSettingsGroup) key["$pref::staticObjectUnfadeableSize"] = 75; }; }; + + new SimGroup() + { + class = "OptionsSettings"; + + OptionName = "Lighting Quality"; + Description = "Controls the lighting and shadows quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::lightManager"] = "Advanced Lighting"; + key["$pref::Shadows::disable"] = false; + key["$pref::Shadows::textureScalar"] = 1.0; + key["$pref::PSSM::detailAdjustScale"] = 1.0; + key["$pref::allowLocalLightShadows"] = true; + }; + }; + }; + + new SimGroup(AdvancedVideoSettingsGroup) + { + class = "SubOptionsGroup"; + displayName = "Advanced"; + + new SimGroup() + { + class = "OptionsSettings"; + + OptionName = "Mesh Detail"; + Description = "Controls the max quality of mesh objects"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::TS::detailAdjust"] = 1.5; + key["$pref::TS::skipRenderDLs"] = 0; + }; + + }; }; /*new SimGroup(AdvancedVideoSettingsGroup) diff --git a/Templates/BaseGame/game/data/UI/UI.tscript b/Templates/BaseGame/game/data/UI/UI.tscript index 455067910..9652b97d7 100644 --- a/Templates/BaseGame/game/data/UI/UI.tscript +++ b/Templates/BaseGame/game/data/UI/UI.tscript @@ -39,21 +39,12 @@ function UI::initClient(%this) //Load UI stuff //Profiles %this.queueExec("./scripts/profiles"); - - //Navigation Utility Scripts - //%this.queueExec("./scripts/menuNavigation"); - - //Now gui files - %this.queueExec("./scripts/menuInputHandling"); - + %this.queueExec("./guis/mainMenu"); %this.queueExec("./guis/mainMenu.gui"); - //%this.queueExec("./guis/mainMenuButtons"); - //%this.queueExec("./guis/mainMenuButtons.gui"); - - %this.queueExec("./guis/chooseLevelDlg"); - %this.queueExec("./guis/chooseLevelDlg.gui"); + %this.queueExec("./guis/ChooseLevelMenu"); + %this.queueExec("./guis/ChooseLevelMenu.gui"); %this.queueExec("./guis/joinServerMenu"); %this.queueExec("./guis/joinServerMenu.gui"); @@ -63,8 +54,8 @@ function UI::initClient(%this) %this.queueExec("./guis/optionsMenu"); %this.queueExec("./guis/optionsMenu.gui"); - %this.queueExec("./guis/pauseMenu"); - %this.queueExec("./guis/pauseMenu.gui"); + %this.queueExec("./guis/GameMenu"); + %this.queueExec("./guis/GameMenu.gui"); %this.queueExec("./guis/remapDlg.gui"); %this.queueExec("./guis/remapConfirmDlg.gui"); @@ -73,21 +64,18 @@ function UI::initClient(%this) %this.queueExec("./guis/profiler.gui"); %this.queueExec("./guis/netGraphGui.gui"); - %this.queueExec("./guis/RecordingsDlg.gui"); - - %this.queueExec("./guis/guiMusicPlayer"); - %this.queueExec("./guis/guiMusicPlayer.gui"); %this.queueExec("./guis/startupGui"); %this.queueExec("./guis/startupGui.gui"); - // Load Editor Dialogs + %this.queueExec("./guis/messageBoxDlg"); %this.queueExec("./guis/messageBoxDlg.gui"); + %this.queueExec("./guis/SystemMenu"); + %this.queueExec("./guis/SystemMenu.gui"); + //Load scripts %this.queueExec("./scripts/controlsMenu"); - %this.queueExec("./scripts/messageBoxes"); - %this.queueExec("./scripts/help"); %this.queueExec("./scripts/cursors"); if(isToolBuild()) @@ -97,3 +85,8 @@ function UI::initClient(%this) function UI::onCreateClientConnection(%this){} function UI::onDestroyClientConnection(%this){} + +function UI::registerGameMenus(%this, %menusArrayObj) +{ + %menusArrayObj.add("System", SystemMenu); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelDlg.asset.taml b/Templates/BaseGame/game/data/UI/guis/ChooseLevelDlg.asset.taml deleted file mode 100644 index 9090ea1af..000000000 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelDlg.asset.taml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.asset.taml b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.asset.taml new file mode 100644 index 000000000..7b612550f --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.asset.taml @@ -0,0 +1,5 @@ + diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui new file mode 100644 index 000000000..5fe626a07 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -0,0 +1,97 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiChunkedBitmapCtrl(ChooseLevelMenu) { + BitmapAsset = "UI:backgrounddark_image"; + extent = "1280 720"; + minExtent = "8 8"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiNonModalDefaultProfile"; + category = "BaseUI"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; + launchInEditor = "0"; + + new GuiInputCtrl(ChooseLevelInputHandler) { + ignoreMouseEvents = "1"; + ActionMap = "ChooseLevelActionMap"; + position = "-50 0"; + extent = "2186 851"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + + new GuiPanel(ChooseLevelTitlePanel) { + extent = "1281 80"; + horizSizing = "width"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl(ChooseLevelTitleText) { + text = "SINGLE PLAYER"; + position = "22 23"; + extent = "220 28"; + profile = "MenuHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiPanel(ChooseLevelButtonPanel) { + position = "0 683"; + extent = "1281 40"; + horizSizing = "width"; + vertSizing = "top"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiIconButtonCtrl(ChooseLevelStartBtn) { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Start"; + position = "1115 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "OptionsMenu.applySettings();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiIconButtonCtrl(ChooseLevelBackBtn) { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Back"; + position = "16 0"; + extent = "140 40"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.popDialog();"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiScrollCtrl(LevelPreviewScroll) { + hScrollBar = "dynamic"; + vScrollBar = "alwaysOff"; + position = "0 118"; + extent = "1283 500"; + horizSizing = "width"; + vertSizing = "center"; + profile = "GuiMenuScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiStackControl(LevelPreviewArray) { + position = "1 1"; + extent = "1280 480"; + vertSizing = "center"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + padding = "5"; + stackingType = "Horizontal"; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript new file mode 100644 index 000000000..39ecf2ef5 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -0,0 +1,211 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +//---------------------------------------- +function ChooseLevelMenu::onAdd( %this ) +{ + if(!isObject(ChooseLevelAssetQuery)) + new AssetQuery(ChooseLevelAssetQuery); +} + +function ChooseLevelMenu::onWake(%this) +{ + LevelPreviewArray.clear(); + + ChooseLevelAssetQuery.clear(); + AssetDatabase.findAssetType(ChooseLevelAssetQuery, "LevelAsset"); + + %count = ChooseLevelAssetQuery.getCount(); + + if(%count == 0 && !IsDirectory("tools")) + { + //We have no levels found. Prompt the user to open the editor to the default level if the tools are present + MessageBoxOK("Error", "No levels were found in any modules. Please ensure you have modules loaded that contain gameplay code and level files.", + "Canvas.popDialog(ChooseLevelMenu); if(isObject(ChooseLevelMenu.returnGui) && ChooseLevelMenu.returnGui.isMethod(\"onReturnTo\")) ChooseLevelMenu.returnGui.onReturnTo();"); + + ChooseLevelAssetQuery.delete(); + return; + } + + for(%i=0; %i < %count; %i++) + { + %assetId = ChooseLevelAssetQuery.getAsset(%i); + + if(AssetDatabase.getAssetModule(%assetId).ModuleId $= "ToolsModule") + continue; + + %levelAsset = AssetDatabase.acquireAsset(%assetId); + + %file = %levelAsset.getLevelPath(); + + if ( !isFile(%file) ) + continue; + + %levelPreviewImg = %levelAsset.getPreviewImagePath(); + + if (!isFile(%levelPreviewImg)) + %levelPreviewImg = "UI:no_preview_image"; + + %preview = new GuiContainer() { + extent = "480 480"; + levelAssetId = %assetId; + + new GuiButtonCtrl() { + position = "0 0"; + extent = "480 480"; + buttonType = "ToggleButton"; + profile = LevelPreviewButtonProfile; + horizSizing = "width"; + vertSizing = "height"; + internalName = "button"; + class = "LevelPreviewButton"; + command = "$selectedLevelAsset = " @ %assetId @ ";"; + altCommand = "ChooseLevelBegin(1);"; //allow doubleclick to quick action it + }; + + new GuiBitmapCtrl() { + position = "20 0"; + extent = "440 440"; + BitmapAsset = %levelPreviewImg; + horizSizing = "width"; + vertSizing = "bottom"; + profile = GuiNonModalDefaultProfile; + }; + + new GuiTextCtrl() { + position = "20 445"; + extent = "440 15"; + text = %levelAsset.levelName; + profile = MenuSubHeaderText; + internalName = "levelNameTxt"; + }; + + new GuiMLTextCtrl() { + position = "20 465"; + extent = "440 15"; + text = %levelAsset.levelDescription; + profile = GuiMLTextProfile; + internalName = "levelDescTxt"; + }; + }; + + LevelPreviewArray.add(%preview); + } + + // Also add the new level mission as defined in the world editor settings + // if we are choosing a level to launch in the editor. + if ( %this.launchInEditor ) + { + %this.addMissionFile( "tools/levels/DefaultEditorLevel.mis" ); + } + + //LevelList.setSelected(0); + + if(!$pref::HostMultiPlayer) + ChooseLevelTitleText.setText("SINGLE PLAYER"); + else + ChooseLevelTitleText.setText("CREATE SERVER"); + + $MenuList = LevelPreviewArray; + $MenuList.listPosition = 0; + $MenuList.syncGui(); +} + +if(!isObject( ChooseLevelActionMap ) ) +{ + new ActionMap(ChooseLevelActionMap){}; + + //Null the up/down nav so we can swap in left/right nav + ChooseLevelActionMap.bindCmd( keyboard, w, "" ); + ChooseLevelActionMap.bindCmd( keyboard, s, "" ); + ChooseLevelActionMap.bindCmd( gamepad, yaxis, "" ); + ChooseLevelActionMap.bindCmd( gamepad, upov, "" ); + ChooseLevelActionMap.bindCmd( gamepad, dpov, "" ); + + ChooseLevelActionMap.bind( keyboard, a, BaseUINavigatePrev ); + ChooseLevelActionMap.bind( keyboard, d, BaseUINavigateNext ); + ChooseLevelActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", BaseUIStickNavigate ); + ChooseLevelActionMap.bind( gamepad, lpov, BaseUINavigatePrev ); + ChooseLevelActionMap.bind( gamepad, rpov, BaseUINavigateNext ); + + ChooseLevelActionMap.bind( keyboard, Enter, ChooseLevelBegin ); + ChooseLevelActionMap.bind( gamepad, btn_a, ChooseLevelBegin ); +} + +function LevelPreviewArray::syncGUI(%this) +{ + %this.callOnChildren("setHighlighted", false); + + %btn = %this.getObject(%this.listPosition); + %btn-->button.setHighlighted(true); + + $selectedLevelAsset = %btn.levelAssetId; +} + +function ChooseLevelBegin(%val) +{ + if(%val) + { + // So we can't fire the button when loading is in progress. + if ( isObject( ServerGroup ) ) + return; + + Canvas.popDialog(); + + %entry = LevelPreviewArray.getObject(LevelPreviewArray.listPosition); + + if(!AssetDatabase.isDeclaredAsset(%entry.levelAssetId)) + { + MessageBoxOK("Error", "Selected level preview does not have a valid level asset!"); + return; + } + + // Launch the chosen level with the editor open? + if ( ChooseLevelMenu.launchInEditor ) + { + activatePackage( "BootEditor" ); + ChooseLevelMenu.launchInEditor = false; + StartGame(%entry.levelAssetId, "SinglePlayer"); + } + else + { + StartGame(%entry.levelAssetId); + } + } +} + +function ChooseLevelMenu::onSleep( %this ) +{ + // This is set from the outside, only stays true for a single wake/sleep + // cycle. + %this.launchInEditor = false; +} + +function LevelPreviewButton::onHighlighted(%this, %highlighted) +{ + %container = %this.getParent(); + + %container-->levelNameTxt.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText; + %container-->levelDescTxt.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile; + + LevelPreviewScroll.scrollToObject(%this); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.asset.taml b/Templates/BaseGame/game/data/UI/guis/GameMenu.asset.taml new file mode 100644 index 000000000..2b9ed760a --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.asset.taml @@ -0,0 +1,5 @@ + diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.gui b/Templates/BaseGame/game/data/UI/guis/GameMenu.gui new file mode 100644 index 000000000..559f8c59c --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.gui @@ -0,0 +1,97 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiControl(GameMenu) { + extent = "1280 720"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + superClass = "UINavigation"; + canSaveDynamicFields = "1"; + currentMenu = "SystemMenu"; + gameMenusArray = "17288"; + resizePages = "1"; + + new GuiInputCtrl(GameMenuInputHandler) { + ignoreMouseEvents = "1"; + ActionMap = "GameMenuActionMap"; + position = "-50 0"; + extent = "50 50"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiChunkedBitmapCtrl(GameMenuBG) { + BitmapAsset = "UI:hudfill_image"; + extent = "1280 720"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; + + new GuiPanel(GameMenuTitlePanel) { + extent = "1281 60"; + horizSizing = "width"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiStackControl(GameMenuButtonList){ + position = "40 0"; + extent = "1240 60"; + profile = GuiDefaultProfile; + stackingType = "Horizontal"; + padding = "10"; + horizSizing = "center"; + vertSizing = "center"; + }; + + new GuiControl(GameMenuNavButtonOverlay) { + extent = "1281 60"; + horizSizing = "width"; + vertSizing = "height"; + profile = GuiNonModalDefaultProfile; + + new GuiBitmapCtrl(GameMenuPrevNavIcon) { + BitmapAsset = "UI:Keyboard_Black_Q_image"; + position = "0 24"; + extent = "40 40"; + profile = GuiNonModalDefaultProfile; + vertSizing = "top"; + }; + + new GuiBitmapCtrl(GameMenuNextNavIcon) { + BitmapAsset = "UI:Keyboard_Black_E_image"; + position = "0 24"; + extent = "40 40"; + profile = GuiNonModalDefaultProfile; + vertSizing = "top"; + }; + }; + }; + }; + new GuiPanel(GameMenuButtonPanel) { + position = "0 683"; + extent = "1281 40"; + horizSizing = "width"; + vertSizing = "top"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiIconButtonCtrl(GameMenuBackBtn) { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Back"; + position = "16 0"; + extent = "140 40"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.popDialog(GameMenu);"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript new file mode 100644 index 000000000..0b6177604 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript @@ -0,0 +1,186 @@ +function GameMenu::onAdd(%this) +{ + %this.gameMenusArray = new ArrayObject(){}; +} + +function GameMenu::onWake(%this) +{ + if($Server::ServerType $= "SinglePlayer") + { + $timescale = 0; + + sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ 0 ] ); + } + + callOnModules("registerGameMenus", "", %this.gameMenusArray); + + //Remove duplicates as needed + %this.gameMenusArray.uniqueKey(); + + GameMenuButtonList.clear(); + + %stackWidth = 0; + //process the entries and give 'em buttons on the button array + for(%i=0; %i < %this.gameMenusArray.count(); %i++) + { + %buttonText = %this.gameMenusArray.getKey(%i); + + %textWidth = GuiMenuButtonProfile.getStringWidth(%buttonText); + + %btn = new GuiButtonCtrl() { + extent = %textWidth + 80 SPC 40; + profile = GuiMenuButtonProfile; + text = %buttonText; + class = "GameMenuButton"; + command = "GameMenu.openGameMenu(\"" @ %buttonText @ "\");"; + }; + + %stackWidth += %textWidth + 40; + + GameMenuButtonList.add(%btn); + } + + GameMenuButtonList.resize(GameMenuTitlePanel.extent.x/2 - %stackWidth/2, 0, %stackWidth, GameMenuTitlePanel.extent.y); + + %this.openGameMenu("System"); + + //give a slight delay for the canvas to be fully refreshed before we sync things + %this.schedule(500, "syncGUI"); +} + +function GameMenu::onSleep(%this) +{ + if($Server::ServerType $= "SinglePlayer") + { + $timescale = 1; + sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); + } + + if(isObject(%this.currentMenu)) + { + Canvas.popDialog(%this.currentMenu); + } +} + +if(!isObject( GameMenuActionMap ) ) +{ + new ActionMap(GameMenuActionMap){}; + + //We'll just use the existing BaseUI nav functions because it'd be the same logic anyways + GameMenuActionMap.bind( keyboard, w, BaseUINavigatePrev ); + GameMenuActionMap.bind( keyboard, s, BaseUINavigateNext ); + GameMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", BaseUIStickNavigate ); + GameMenuActionMap.bind( gamepad, upov, BaseUINavigatePrev ); + GameMenuActionMap.bind( gamepad, dpov, BaseUINavigateNext ); + + GameMenuActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); + GameMenuActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); + + GameMenuActionMap.bindCmd( keyboard, Escape, "Canvas.popDialog(GameMenu);", "" ); + GameMenuActionMap.bindCmd( gamepad, btn_b, "Canvas.popDialog(GameMenu);", "" ); + GameMenuActionMap.bindCmd( gamepad, btn_start, "Canvas.popDialog(GameMenu);", "" ); + + GameMenuActionMap.bind( keyboard, q, GameMenuPrevMenu ); + GameMenuActionMap.bind( gamepad, btn_l, GameMenuPrevMenu ); + + GameMenuActionMap.bind( keyboard, e, GameMenuNextMenu ); + GameMenuActionMap.bind( gamepad, btn_r, GameMenuNextMenu ); +} + +function GameMenu::openGameMenu(%this, %menuName) +{ + %menuIdx = %this.gameMenusArray.getIndexFromKey(%menuName); + if(%menuIdx != -1) + { + %newMenu = %this.gameMenusArray.getValue(%menuIdx); + + if(isObject(%this.currentMenu)) + Canvas.popDialog(%this.currentMenu); + + Canvas.pushDialog(%newMenu); + %this.currentMenu = %newMenu; + %this.currentMenuIdx = %menuIdx; + } + + %this.syncGui(); +} + +function openPauseMenuOptions() +{ + GameMenu.pushPage(OptionsMenu); +} + +function pauseMenuExitToMenu() +{ + MessageBoxOKCancel("Exit?", "Do you wish to exit to the Main Menu?", "escapeFromGame();", ""); +} + +function pauseMenuExitToDesktop() +{ + MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", ""); +} + +function GameMenuPrevMenu(%val) +{ + if(%val) + { + %currentIdx = GameMenu.currentMenuIdx; + GameMenu.currentMenuIdx -= 1; + if(GameMenu.currentMenuIdx < 0) + GameMenu.currentMenuIdx = 0; + + if(%currentIdx == GameMenu.currentMenuIdx) + return; + + %menuName = GameMenu.gameMenusArray.getKey(GameMenu.currentMenuIdx); + + GameMenu.openGameMenu(%menuName); + } +} + +function GameMenuNextMenu(%val) +{ + if(%val) + { + %currentIdx = GameMenu.currentMenuIdx; + GameMenu.currentMenuIdx += 1; + if(GameMenu.currentMenuIdx >= GameMenu.gameMenusArray.count()) + GameMenu.currentMenuIdx = GameMenu.gameMenusArray.count()-1; + + if(%currentIdx == GameMenu.currentMenuIdx) + return; + + %menuName = GameMenu.gameMenusArray.getKey(GameMenu.currentMenuIdx); + + GameMenu.openGameMenu(%menuName); + } +} + +function GameMenu::syncGui(%this) +{ + GameMenuButtonList.callOnChildren("setHighlighted", false); + + %btn = GameMenuButtonList.getObject(%this.currentMenuIdx); + %btn.setHighlighted(true); + + %buttonPosX = %btn.position.x + GameMenuButtonList.position.x; + + GameMenuPrevNavIcon.position.x = %buttonPosX; + GameMenuNextNavIcon.position.x = %buttonPosX + %btn.extent.x - 40; + + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + GameMenuBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut")); + + GameMenuPrevNavIcon.setBitmap(GameMenuActionMap.getCommandButtonBitmap(%device, "GameMenuPrevMenu")); + GameMenuNextNavIcon.setBitmap(GameMenuActionMap.getCommandButtonBitmap(%device, "GameMenuNextMenu")); + + %this.schedule(500, "syncGUI"); +} + +/* + +*/ \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/GuiMusicPlayer.asset.taml b/Templates/BaseGame/game/data/UI/guis/GuiMusicPlayer.asset.taml deleted file mode 100644 index 94601d7a3..000000000 --- a/Templates/BaseGame/game/data/UI/guis/GuiMusicPlayer.asset.taml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.asset.taml b/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.asset.taml deleted file mode 100644 index d1d0c8c8e..000000000 --- a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.asset.taml +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui b/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui deleted file mode 100644 index 6a98fe6d7..000000000 --- a/Templates/BaseGame/game/data/UI/guis/IODropdownDlg.ed.gui +++ /dev/null @@ -1,159 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(IODropdownDlg) { - profile = "GuiDefaultProfile"; - horizSizing = "width"; - vertSizing = "height"; - position = "0 0"; - extent = "640 480"; - minExtent = "8 8"; - visible = "1"; - helpTag = "0"; - new GuiWindowCtrl(IODropdownFrame) { - canSaveDynamicFields = "0"; - Profile = "GuiWindowProfile"; - horizSizing = "center"; - vertSizing = "center"; - position = "272 77"; - extent = "256 117"; - minExtent = "256 8"; - canSave = "1"; - Visible = "1"; - hovertime = "1000"; - maxLength = "255"; - resizeWidth = "1"; - resizeHeight = "1"; - canMove = "1"; - canClose = "1"; - canMinimize = "0"; - canMaximize = "0"; - minSize = "50 50"; - text = ""; - closeCommand="IOCallback(IODropdownDlg,IODropdownDlg.cancelCallback);"; - - new GuiMLTextCtrl(IODropdownText) { - text = ""; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - isContainer = "0"; - profile = "GuiMLTextProfile"; - horizSizing = "center"; - vertSizing = "bottom"; - position = "9 26"; - extent = "237 16"; - minExtent = "8 8"; - canSave = "1"; - visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiBitmapBorderCtrl() { - isContainer = "0"; - profile = "GuiGroupBorderProfile"; - horizSizing = "width"; - vertSizing = "bottom"; - position = "7 51"; - extent = "243 28"; - minExtent = "0 0"; - canSave = "1"; - visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - - new GuiTextCtrl(IOInputText) { - text = "Decal Datablock"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - isContainer = "0"; - profile = "GuiTextRightProfile"; - horizSizing = "right"; - vertSizing = "bottom"; - position = "5 5"; - extent = "105 18"; - minExtent = "8 2"; - canSave = "1"; - visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiPopUpMenuCtrl(IODropdownMenu) { - maxPopupHeight = "200"; - sbUsesNAColor = "0"; - reverseTextList = "0"; - bitmapBounds = "16 16"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - isContainer = "0"; - profile = "GuiPopUpMenuProfile"; - horizSizing = "width"; - vertSizing = "bottom"; - position = "115 5"; - extent = "122 18"; - minExtent = "8 2"; - canSave = "1"; - visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - }; - new GuiButtonCtrl() { - text = "OK"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - isContainer = "0"; - profile = "GuiButtonProfile"; - horizSizing = "width"; - vertSizing = "top"; - position = "7 85"; - extent = "156 24"; - minExtent = "8 8"; - canSave = "1"; - visible = "1"; - accelerator = "return"; - command = "IOCallback(IODropdownDlg,IODropdownDlg.callback);"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl() { - text = "Cancel"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - isContainer = "0"; - profile = "GuiButtonProfile"; - horizSizing = "left"; - vertSizing = "top"; - position = "170 85"; - extent = "80 24"; - minExtent = "8 8"; - canSave = "1"; - visible = "1"; - accelerator = "escape"; - command = "IOCallback(IODropdownDlg,IODropdownDlg.cancelCallback);"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - }; -}; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml deleted file mode 100644 index 2ab6cfeef..000000000 --- a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.asset.taml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui deleted file mode 100644 index de086ec19..000000000 --- a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.gui +++ /dev/null @@ -1,84 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(MainMenuButtons) { - extent = "1024 768"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiNonModalDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - canSaveDynamicFields = "1"; - originalAssetName = "MainMenuButtons"; - - new GuiStackControl(MainMenuButtonList) { - padding = "15"; - dynamicSize = "0"; - position = "312 145"; - extent = "400 477"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - - new GuiButtonCtrl(MainMenuSinglePlayerBtn) { - text = "Single Player"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openSinglePlayerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl(MainMenuCreateSrvrBtn) { - text = "Create Server"; - position = "0 70"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openMultiPlayerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl(MainMenuJoinSrvrBtn) { - text = "Join Server"; - position = "0 140"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openJoinServerMenu();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl(MainMenuOptionBtn) { - text = "Options"; - position = "0 210"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openOptionsMenu();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl(MainMenuWorldEditBtn) { - text = "Open World Editor (F11)"; - position = "0 280"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openWorldEditorBtn();"; - tooltipProfile = "GuiToolTipProfile"; - enabled = (ModuleDatabase.findModule("ToolsModule") !$= ""); - visible = (ModuleDatabase.findModule("ToolsModule") !$= ""); - }; - new GuiButtonCtrl(MainMenuGuiEditBtn) { - text = "Open GUI Editor (F10)"; - position = "0 350"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "openGUIEditorBtn();"; - tooltipProfile = "GuiToolTipProfile"; - enabled = (ModuleDatabase.findModule("ToolsModule") !$= ""); - visible = (ModuleDatabase.findModule("ToolsModule") !$= ""); - }; - new GuiButtonCtrl(MainMenuExitBtn) { - text = "Exit"; - position = "0 420"; - extent = "400 55"; - profile = "GuiMenuButtonProfile"; - command = "quit();"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; -}; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript b/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript deleted file mode 100644 index 1a79ff5fb..000000000 --- a/Templates/BaseGame/game/data/UI/guis/MainMenuButtons.tscript +++ /dev/null @@ -1,107 +0,0 @@ -function MainMenuButtons::onWake(%this) -{ -} - -function MainMenuButtons::onSleep(%this) -{ -} - -//============================================================================== -// This gets called by the MainMenuGUI beacuse it, being a UINavigation classed control -// set MainMenuButtonList as it's root page. -// This is an optional function, but is called as part of the validation that the page -// CAN be opened, so it's shown here as an example -function MainMenuButtons::canOpen(%this) -{ - return true; -} - -//============================================================================== -// This gets called by the MainMenuGUI beacuse it, being a UINavigation classed control -// set MainMenuButtonList as it's root page. -// Once the page is added to the MainMenuGUI's UINavigation page stack, onOpen here is called -// Which allows us to actually do the work we need to do for display -function MainMenuButtons::onOpen(%this) -{ - //Here, we set the MainMenuButtonList - a GuiStackControl with the MenuList class - // to be the active menu list. - // This means that when the MainMenuGUI's MainMenuInputHandler receives an input - // or we have one of the buttons in the MainMenuButtonHolder be actioned, we know - // we're working/navigating this list of buttons specifically - // In practice, it sets the $activeMenuList global variable so the various menu class code - // can reference it consistently - MainMenuButtonList.setAsActiveMenuList(); - - //Because MainMenuGUI set it's MainMenuButtonHolder as the active button container, we can reference it - //by $activeMenuButtonContainer and set the menu button/accelerator prompts we need for the MainMenuButtonList - //specifically. - //In particular, being a simple list of buttons, the only one we NEED is a simple activate, so we'll - //disable all the other ones to keep them clear in case they were set by other pages at some point - $activeMenuButtonContainer-->button1.disable(); - $activeMenuButtonContainer-->button2.disable(); - $activeMenuButtonContainer-->button3.disable(); - - //Here we set the 4th button in the container - //All the buttons have the MenuInputButton class, which, like the other classes - //help keep things accessible and consistent. Here we use that class's set function to - //configure the accelerator behavior - //The first parameter sets the gamepad button to the 'A' button - //The second sets the keyboard button to Enter or Return - //Third is what the displayed text will be - //And finally we set the command when the button is clicked, or either key inputs are caught by - //our MenuInputHandler - //The menu buttons automatically detect which input device you're using and swap the display between - //gamepad or keyboard for consistent behavior - $activeMenuButtonContainer-->button4.set("btn_a", "Return", "Go", "MainMenuButtonList.activate();"); - $activeMenuButtonContainer-->button5.disable(); -} - -//Optional, as the check defaults to true, but here as an example case -function MainMenuButtons::canClose(%this) -{ - return true; -} - - -function MainMenuButtons::onClose(%this) -{ -} - -//Our actual commands when we activate the buttons -function openSinglePlayerMenu() -{ - $pref::HostMultiPlayer=false; - MainMenuGui.pushPage(ChooseLevelDlg); -} - -function openMultiPlayerMenu() -{ - $pref::HostMultiPlayer=true; - - //Here, like the other commands, we add a new page onto the stack - //In this case, we'll push the ChooseLevelDlg control onto the stack. This will - //invoke the canClose() and then onClose() functions for MainMenuButtonList - //before calling the onOpen() for ChooseLevelDlg then displaying. - MainMenuGui.pushPage(ChooseLevelDlg); -} - -function openJoinServerMenu() -{ - //Here, like the other commands, we add a new page onto the stack - //In this case, we'll push the JoinServerMenu control onto the stack. This will - //invoke the canClose() and then onClose() functions for MainMenuButtonList - //before calling the onOpen() for JoinServerMenu then displaying. - MainMenuGui.pushPage(JoinServerMenu); -} - - - -function openWorldEditorBtn() -{ - fastLoadWorldEdit(1); -} - -function openGUIEditorBtn() -{ - fastLoadGUIEdit(1); -} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/PauseMenu.asset.taml b/Templates/BaseGame/game/data/UI/guis/PauseMenu.asset.taml deleted file mode 100644 index 08a16f03d..000000000 --- a/Templates/BaseGame/game/data/UI/guis/PauseMenu.asset.taml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui b/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui deleted file mode 100644 index c13008f11..000000000 --- a/Templates/BaseGame/game/data/UI/guis/RecordingsDlg.gui +++ /dev/null @@ -1,230 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(recordingsDlg) { - position = "0 0"; - extent = "1024 768"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "1"; - helpTag = "0"; - - new GuiWindowCtrl() { - text = "Demo Recordings"; - resizeWidth = "0"; - resizeHeight = "0"; - canMove = "1"; - canClose = "1"; - canMinimize = "0"; - canMaximize = "0"; - canCollapse = "0"; - closeCommand = "Canvas.popDialog(recordingsDlg);"; - edgeSnap = "1"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - position = "247 215"; - extent = "530 338"; - minExtent = "48 92"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiWindowProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiScrollCtrl() { - willFirstRespond = "1"; - hScrollBar = "dynamic"; - vScrollBar = "alwaysOn"; - lockHorizScroll = "0"; - lockVertScroll = "0"; - constantThumbHeight = "0"; - childMargin = "0 0"; - mouseWheelScrollSpeed = "-1"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - position = "23 60"; - extent = "484 237"; - minExtent = "32 32"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiScrollProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiTextListCtrl(RecordingsDlgList) { - columns = "0"; - fitParentWidth = "1"; - clipColumnText = "0"; - position = "1 1"; - extent = "469 32"; - minExtent = "8 20"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiTextArrayProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; - new GuiButtonCtrl(DR_CancelBtn) { - text = "Cancel"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "396 306"; - extent = "110 20"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "top"; - profile = "GuiButtonProfile"; - visible = "1"; - active = "1"; - command = "Canvas.popDialog(recordingsDlg);"; - accelerator = "escape"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(DR_StartDemoBtn) { - text = "Play"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "25 305"; - extent = "110 20"; - minExtent = "8 8"; - horizSizing = "right"; - vertSizing = "top"; - profile = "GuiButtonProfile"; - visible = "1"; - active = "1"; - command = "StartSelectedDemo();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiTextCtrl() { - text = "During gameplay press the following keys:"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - position = "23 30"; - extent = "206 18"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiTextProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiTextCtrl() { - text = "Start = F3"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - position = "253 32"; - extent = "50 15"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiTextProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiTextCtrl() { - text = "Stop = F4"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; - position = "320 32"; - extent = "49 13"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiTextProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(DR_DelDemoBtn) { - text = "Delete"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "210 305"; - extent = "110 20"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiButtonProfile"; - visible = "1"; - active = "1"; - command = "deleteDemoRecord();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; -}; -//--- OBJECT WRITE END --- - diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.asset.taml b/Templates/BaseGame/game/data/UI/guis/SystemMenu.asset.taml new file mode 100644 index 000000000..e5e752734 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.asset.taml @@ -0,0 +1,5 @@ + diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui new file mode 100644 index 000000000..d2a12bed3 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui @@ -0,0 +1,53 @@ +//--- OBJECT WRITE BEGIN --- +$guiContent = new GuiControl(SystemMenu) { + extent = "1280 720"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + canSaveDynamicFields = "1"; + + new GuiStackControl(SystemMenuButtonList) { + padding = "5"; + dynamicSize = "0"; + position = "440 263"; + extent = "400 189"; + horizSizing = "center"; + vertSizing = "center"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + + new GuiButtonCtrl() { + text = "Return to Game"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.popDialog(GameMenu);"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Options"; + position = "0 45"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.pushDialog(OptionsMenu);"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Exit to Menu"; + position = "0 90"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "systemMenuExitToMenu();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Exit to Desktop"; + position = "0 135"; + extent = "400 40"; + profile = "GuiMenuButtonProfile"; + command = "systemMenuExitToDesktop();"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; +}; +//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript b/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript new file mode 100644 index 000000000..2b6b8ed27 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript @@ -0,0 +1,37 @@ +function SystemMenu::onWake(%this) +{ + $MenuList = SystemMenuButtonList; + $MenuList.listPosition = 0; +} + +function SystemMenu::onSleep(%this) +{ + +} + +function systemMenuExitToMenu() +{ + MessageBoxOKCancel("Exit?", "Do you wish to exit to the Main Menu?", "escapeFromGame();", ""); +} + +function systemMenuExitToDesktop() +{ + MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", ""); +} + +function SystemMenuButtonList::syncGUI(%this) +{ + %this.callOnChildren("setHighlighted", false); + + %btn = %this.getObject(%this.listPosition); + %btn.setHighlighted(true); + + // + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + //We'll call back to the GameMenu parent just to be sure everything's on the same page + GameMenu.syncGui(); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui deleted file mode 100644 index 414f1ccb3..000000000 --- a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.gui +++ /dev/null @@ -1,106 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(ChooseLevelDlg) { - extent = "1024 768"; - minExtent = "8 8"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiNonModalDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - canSaveDynamicFields = "1"; - Enabled = "1"; - launchInEditor = "0"; - returnGui = "MainMenuGui"; - - new GuiControl(ChooseLevelWindow) { - position = "48 56"; - extent = "928 655"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_image"; - extent = "927 40"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl(LevelSelectTitle) { - text = "SINGLE PLAYER"; - position = "22 10"; - extent = "307 28"; - profile = "MenuHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_low_image"; - position = "0 40"; - extent = "927 618"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiBitmapCtrl() { - BitmapAsset = "Core_Rendering:missingTexture_image"; - position = "513 71"; - extent = "400 300"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "CurrentPreview"; - canSaveDynamicFields = "1"; - Enabled = "1"; - }; - new GuiTextCtrl() { - text = "Example Level"; - maxLength = "255"; - position = "514 375"; - extent = "398 27"; - minExtent = "8 8"; - profile = "MenuHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - internalName = "LevelName"; - }; - new GuiTextCtrl() { - text = "Description:"; - maxLength = "255"; - position = "522 410"; - extent = "91 18"; - minExtent = "8 8"; - profile = "MenuSubHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - internalName = "LevelDescriptionLabel"; - }; - new GuiMLTextCtrl() { - text = "This is placeholder text"; - position = "522 436"; - extent = "391 14"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "LevelDescription"; - }; - new GuiScrollCtrl() { - hScrollBar = "dynamic"; - vScrollBar = "dynamic"; - position = "0 40"; - extent = "450 580"; - profile = "GuiMenuScrollProfile"; - tooltipProfile = "GuiToolTipProfile"; - - new GuiGameListMenuCtrl(LevelList) { - callbackOnInputs = "1"; - position = "1 1"; - extent = "450 90"; - profile = "DefaultListMenuProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "UIMenuButtonList"; - }; - }; - }; -}; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript b/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript deleted file mode 100644 index b39db49d1..000000000 --- a/Templates/BaseGame/game/data/UI/guis/chooseLevelDlg.tscript +++ /dev/null @@ -1,210 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -//---------------------------------------- -function ChooseLevelDlg::onWake( %this ) -{ - if(!isObject(LevelListEntries)) - new ArrayObject(LevelListEntries){}; - - if(!isObject(ChooseLevelAssetQuery)) - new AssetQuery(ChooseLevelAssetQuery); -} - -function ChooseLevelDlg::onOpen(%this) -{ - LevelList.clearRows(); - LevelListEntries.empty(); - - ChooseLevelWindow->CurrentPreview.setBitmap("UI:no_preview_image"); - ChooseLevelWindow->LevelDescriptionLabel.visible = false; - ChooseLevelWindow->LevelDescription.visible = false; - - ChooseLevelAssetQuery.clear(); - AssetDatabase.findAssetType(ChooseLevelAssetQuery, "LevelAsset"); - - %count = ChooseLevelAssetQuery.getCount(); - - if(%count == 0 && !IsDirectory("tools")) - { - //We have no levels found. Prompt the user to open the editor to the default level if the tools are present - MessageBoxOK("Error", "No levels were found in any modules. Please ensure you have modules loaded that contain gameplay code and level files.", - "Canvas.popDialog(ChooseLevelDlg); if(isObject(ChooseLevelDlg.returnGui) && ChooseLevelDlg.returnGui.isMethod(\"onReturnTo\")) ChooseLevelDlg.returnGui.onReturnTo();"); - - ChooseLevelAssetQuery.delete(); - return; - } - - for(%i=0; %i < %count; %i++) - { - %assetId = ChooseLevelAssetQuery.getAsset(%i); - - if(AssetDatabase.getAssetModule(%assetId).ModuleId $= "ToolsModule") - continue; - - %levelAsset = AssetDatabase.acquireAsset(%assetId); - - %file = %levelAsset.getLevelPath(); - - if ( !isFile(%file @ ".mis") && !isFile(%file @ ".mis.dso") &&!isFile(%file) ) - continue; - - // Skip our new level/mission if we arent choosing a level - // to launch in the editor. - if ( !%this.launchInEditor ) - { - %fileName = fileName(%file); - if (strstr(%fileName, "newMission.mis") > -1 || strstr(%fileName, "newLevel.mis") > -1) - continue; - } - - %this.addLevelAsset( %levelAsset ); - } - - // Also add the new level mission as defined in the world editor settings - // if we are choosing a level to launch in the editor. - if ( %this.launchInEditor ) - { - %this.addMissionFile( "tools/levels/DefaultEditorLevel.mis" ); - } - - for(%i=0; %i < LevelListEntries.count(); %i++) - { - %levelAsset = LevelListEntries.getKey(%i); - - LevelList.addRow(%levelAsset.LevelName, "", -1, -30); - } - - LevelList.setSelected(0); - LevelList.onChange(); - - if(!$pref::HostMultiPlayer) - LevelSelectTitle.setText("SINGLE PLAYER"); - else - LevelSelectTitle.setText("CREATE SERVER"); - - $activeMenuButtonContainer-->button1.disable(); - $activeMenuButtonContainer-->button2.disable(); - $activeMenuButtonContainer-->button3.disable(); - $activeMenuButtonContainer-->button4.set("btn_a", "Return", "Start Level", "ChooseLevelDlg.beginLevel();"); - $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", %this @ ".navigation.popPage();"); -} - -function ChooseLevelDlg::onSleep( %this ) -{ - // This is set from the outside, only stays true for a single wake/sleep - // cycle. - %this.launchInEditor = false; -} - -function ChooseLevelDlg::addMissionFile( %this, %file ) -{ - %levelName = fileBase(%file); - %levelDesc = "A Torque level"; - - %LevelInfoObject = getLevelInfo(%file); - - if (%LevelInfoObject != 0) - { - if(%LevelInfoObject.levelName !$= "") - %levelName = %LevelInfoObject.levelName; - else if(%LevelInfoObject.name !$= "") - %levelName = %LevelInfoObject.name; - - if (%LevelInfoObject.desc0 !$= "") - %levelDesc = %LevelInfoObject.desc0; - - if (%LevelInfoObject.preview !$= "") - %levelPreview = %LevelInfoObject.preview; - - %LevelInfoObject.delete(); - } - - LevelListEntries.add( %levelName TAB %file TAB %levelDesc TAB %levelPreview ); -} - -function ChooseLevelDlg::addLevelAsset( %this, %levelAsset ) -{ - LevelListEntries.add( %levelAsset ); -} - -function LevelList::onChange(%this) -{ - %index = %this.getSelectedRow(); - - %levelAsset = LevelListEntries.getKey(%index); - - // Get the name - ChooseLevelWindow->LevelName.text = %levelAsset.LevelName; - - // Get the level id - $selectedLevelAsset = %levelAsset.getAssetId(); - - // Find the preview image - %levelPreview = %levelAsset.getPreviewImagePath(); - - // Test against all of the different image formats - // This should probably be moved into an engine function - if (isFile(%levelPreview)) - ChooseLevelWindow->CurrentPreview.setBitmap(%levelPreview); - else - ChooseLevelWindow->CurrentPreview.setBitmap("UI:no_preview_image"); - - // Get the description - %levelDesc = %levelAsset.description; - - if(%levelDesc !$= "") - { - ChooseLevelWindow->LevelDescriptionLabel.setVisible(true); - ChooseLevelWindow->LevelDescription.setVisible(true); - ChooseLevelWindow->LevelDescription.setText(%levelDesc); - } - else - { - ChooseLevelWindow->LevelDescriptionLabel.setVisible(false); - ChooseLevelWindow->LevelDescription.setVisible(false); - } - -} - -// Do this onMouseUp not via Command which occurs onMouseDown so we do -// not have a lingering mouseUp event lingering in the ether. -function ChooseLevelDlg::beginLevel(%this) -{ - // So we can't fire the button when loading is in progress. - if ( isObject( ServerGroup ) ) - return; - - %this.navigation.popPage(); - - // Launch the chosen level with the editor open? - if ( ChooseLevelDlg.launchInEditor ) - { - activatePackage( "BootEditor" ); - ChooseLevelDlg.launchInEditor = false; - StartGame("", "SinglePlayer"); - } - else - { - StartGame(); - } -} diff --git a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui b/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui deleted file mode 100644 index cfd2c3e96..000000000 --- a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.gui +++ /dev/null @@ -1,192 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(GuiMusicPlayer) { - isContainer = "1"; - Profile = "GuiWindowProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "0 0"; - Extent = "1024 768"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "1"; - superClass = "GuiMusicPlayerClass"; - - new GuiWindowCtrl() { - resizeWidth = "0"; - resizeHeight = "0"; - canMove = "1"; - canClose = "1"; - canMinimize = "1"; - canMaximize = "1"; - minSize = "50 50"; - EdgeSnap = "1"; - text = "Torque Music Player"; - Margin = "0 0 0 0"; - Padding = "0 0 0 0"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - isContainer = "1"; - Profile = "GuiWindowProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "29 35"; - Extent = "518 377"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - closeCommand = "toggleMusicPlayer();"; - - new GuiCheckBoxCtrl(GuiMusicPlayerFadeCheckBox) { - useInactiveState = "0"; - text = "Fade"; - groupNum = "-1"; - buttonType = "ToggleButton"; - useMouseEvents = "0"; - isContainer = "0"; - Profile = "GuiCheckBoxProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "457 347"; - Extent = "53 30"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiCheckBoxCtrl(GuiMusicPlayerLoopCheckBox) { - useInactiveState = "0"; - text = "Loop"; - groupNum = "-1"; - buttonType = "ToggleButton"; - useMouseEvents = "0"; - isContainer = "0"; - Profile = "GuiCheckBoxProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "457 330"; - Extent = "44 30"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiScrollCtrl() { - willFirstRespond = "1"; - hScrollBar = "dynamic"; - vScrollBar = "alwaysOn"; - lockHorizScroll = "0"; - lockVertScroll = "0"; - constantThumbHeight = "0"; - childMargin = "0 0"; - mouseWheelScrollSpeed = "-1"; - Margin = "0 0 0 0"; - Padding = "0 0 0 0"; - AnchorTop = "1"; - AnchorBottom = "0"; - AnchorLeft = "1"; - AnchorRight = "0"; - isContainer = "1"; - Profile = "GuiScrollProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "9 31"; - Extent = "500 298"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - - new GuiListBoxCtrl(GuiMusicPlayerMusicList) { - AllowMultipleSelections = "1"; - fitParentWidth = "1"; - isContainer = "0"; - Profile = "GuiListBoxProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "1 1"; - Extent = "485 2"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - superClass = "GuiMusicPlayerMusicListClass"; - }; - }; - new GuiSliderCtrl(GuiMusicPlayerScrubber) { - range = "0 1"; - ticks = "10"; - value = "0"; - snap = "false"; - isContainer = "0"; - Profile = "GuiSliderProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "114 343"; - Extent = "331 23"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "$thisControl.onDragComplete();"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - class = "GuiMusicPlayerScrubberClass"; - className = "GuiMusicPlayerScrubberClass"; - }; - new GuiButtonCtrl(GuiMusicPlayerStopButton) { - text = "Stop"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - isContainer = "0"; - Profile = "GuiButtonProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "57 338"; - Extent = "40 30"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "GuiMusicPlayer.stop();"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - new GuiButtonCtrl(GuiMusicPlayerPlayButton) { - text = "Play"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - isContainer = "0"; - Profile = "GuiButtonProfile"; - HorizSizing = "right"; - VertSizing = "bottom"; - position = "13 338"; - Extent = "40 30"; - MinExtent = "8 2"; - canSave = "1"; - Visible = "1"; - Command = "GuiMusicPlayer.play();"; - tooltipprofile = "GuiToolTipProfile"; - hovertime = "1000"; - canSaveDynamicFields = "0"; - }; - }; -}; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.tscript b/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.tscript deleted file mode 100644 index 2a302e635..000000000 --- a/Templates/BaseGame/game/data/UI/guis/guiMusicPlayer.tscript +++ /dev/null @@ -1,236 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -// A very simple music player. -//--------------------------------------------------------------------------------------------- -// Preferences. - -$pref::GuiMusicPlayer::filePattern = "*.ogg\t*.wav"; -$pref::GuiMusicPlayer::fadeTime = "3.0"; - -//--------------------------------------------------------------------------------------------- -// Datablocks. - -singleton SFXDescription( GuiMusicPlayerStream : AudioMusic2D ) -{ - volume = 1.0; - isLooping = false; - isStreaming = true; - is3D = false; -}; -singleton SFXDescription( GuiMusicPlayerLoopingStream : AudioMusic2D ) -{ - volume = 1.0; - isLooping = true; - isStreaming = true; - is3D = false; -}; - -//--------------------------------------------------------------------------------------------- -// Functions. - -function toggleMusicPlayer() -{ - if( !GuiMusicPlayer.isAwake() ) - { - GuiMusicPlayer.setExtent( Canvas.getExtent() ); - GuiMusicPlayer.setPosition( 0, 0 ); - - Canvas.pushDialog( GuiMusicPlayer ); - } - else - Canvas.popDialog( GuiMusicPlayer ); -} - -//--------------------------------------------------------------------------------------------- -// Methods. - -function GuiMusicPlayer_onSFXSourceStatusChange( %id, %status ) -{ - if( %status $= "Stopped" ) - GuiMusicPlayer.onStop(); -} - -function GuiMusicPlayerClass::play( %this ) -{ - if( %this.status $= "Stopped" - || %this.status $= "Paused" - || %this.status $= "" ) - { - %isPlaying = true; - if( %this.status $= "Paused" && isObject( %this.sfxSource ) ) - %this.sfxSource.play(); - else - { - %sel = GuiMusicPlayerMusicList.getSelectedItem(); - if( %sel == -1 ) - %isPlaying = false; - else - { - %desc = GuiMusicPlayerStream; - if( GuiMusicPlayerLoopCheckBox.getValue() ) - %desc = GuiMusicPlayerLoopingStream; - - if( GuiMusicPlayerFadeCheckBox.getValue() ) - { - %desc.fadeInTime = $pref::GuiMusicPlayer::fadeTime; - %desc.fadeOutTime = $pref::GuiMusicPlayer::fadeTime; - } - else - { - %desc.fadeInTime = 0; - %desc.fadeOutTime = 0; - } - - %file = GuiMusicPlayerMusicList.getItemText( %sel ); - %this.sfxSource = sfxPlayOnce( %desc, %file ); - if( !%this.sfxSource ) - %isPlaying = false; - else - { - %this.sfxSource.statusCallback = "GuiMusicPlayer_onSFXSourceStatusChange"; - GuiMusicPlayer.status = "Playing"; - - GuiMusicPlayerScrubber.setActive( true ); - GuiMusicPlayerScrubber.setup( %this.sfxSource.getDuration() ); - } - } - } - - if( %isPlaying ) - { - GuiMusicPlayerPlayButton.setText( "Pause" ); - GuiMusicPlayerPlayButton.command = "GuiMusicPlayer.pause();"; - GuiMusicPlayerLoopCheckBox.setActive( false ); - GuiMusicPlayerFadeCheckBox.setActive( false ); - %this.status = "Playing"; - } - } -} - -function GuiMusicPlayerClass::stop( %this ) -{ - if( %this.status $= "Playing" - || %this.status $= "Paused" ) - { - if( isObject( %this.sfxSource ) ) - %this.sfxSource.stop( 0 ); // Stop immediately. - } -} - -function GuiMusicPlayerClass::onStop( %this ) -{ - %this.sfxSource = 0; - - GuiMusicPlayerLoopCheckBox.setActive( true ); - GuiMusicPlayerFadeCheckBox.setActive( true ); - GuiMusicPlayerScrubber.setActive( false ); - GuiMusicPlayerPlayButton.setText( "Play" ); - GuiMusicPlayerPlayButton.Command = "GuiMusicPlayer.play();"; - %this.status = "Stopped"; - - GuiMusicPlayerScrubber.setValue( 0 ); -} - -function GuiMusicPlayerClass::pause( %this ) -{ - if( %this.status $= "Playing" ) - { - if( isObject( %this.sfxSource ) ) - %this.sfxSource.pause( 0 ); - - GuiMusicPlayerPlayButton.setText( "Play" ); - GuiMusicPlayerPlayButton.command = "GuiMusicPlayer.play();"; - %this.status = "Paused"; - } -} - -function GuiMusicPlayerClass::seek( %this, %playtime ) -{ - if( ( %this.status $= "Playing" - || %this.status $= "Paused" ) - && isObject( %this.sfxSource ) ) - %this.sfxSource.setPosition( %playtime ); -} - -function GuiMusicPlayer::onWake( %this ) -{ - GuiMusicPlayerMusicList.load(); -} - -function GuiMusicPlayerMusicListClass::load( %this ) -{ - // Remove all the files currently in the list. - - %this.clearItems(); - - // Find the file matching pattern we should use. - - %filePattern = $pref::GuiMusicPlayer::filePattern; - %sfxProvider = getWord( sfxGetDeviceInfo(), 0 ); - %filePatternVarName = "$pref::GuiMusicPlayer::filePattern" @ %sfxProvider; - if( isDefined( %filePatternVarName ) ) - eval( "%filePattern = " @ %filePatternVarName @ ";" ); - - // Find all files matching the pattern. - - for( %file = findFirstFileMultiExpr( %filePattern ); - %file !$= ""; - %file = findNextFileMultiExpr( %filePattern ) ) - %this.addItem( makeRelativePath( %file, getMainDotCsDir() ) ); -} - -function GuiMusicPlayerMusicList::onDoubleClick( %this ) -{ - GuiMusicPlayer.stop(); - GuiMusicPlayer.play(); -} - -function GuiMusicPlayerScrubber::onMouseDragged( %this ) -{ - %this.isBeingDragged = true; -} - -function GuiMusicPlayerScrubberClass::setup( %this, %totalPlaytime ) -{ - %this.range = "0 " @ %totalPlaytime; - %this.ticks = %totalPlaytime / 5; // One tick per five seconds. - - %this.update(); -} - -function GuiMusicPlayerScrubberClass::update( %this ) -{ - if( GuiMusicPlayer.status $= "Playing" - && !%this.isBeingDragged ) - %this.setValue( GuiMusicPlayer.sfxSource.getPosition() ); - - if( GuiMusicPlayer.status $= "Playing" - || GuiMusicPlayer.status $= "Paused" ) - %this.schedule( 5, "update" ); -} - -function GuiMusicPlayerScrubberClass::onDragComplete( %this ) -{ - GuiMusicPlayer.seek( %this.getValue() ); - %this.isBeingDragged = false; -} diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index 758d1bf32..d7d787c89 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -1,159 +1,161 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(JoinServerMenu) { - extent = "1024 768"; - profile = "GuiNonModalDefaultProfile"; + extent = "1280 720"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuBackgroundProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; + canSaveDynamicFields = "1"; + + new GuiInputCtrl(JoinServerInputHandler) { + ignoreMouseEvents = "1"; + ActionMap = "JoinServerActionMap"; + position = "-50 0"; + extent = "50 50"; horizSizing = "width"; vertSizing = "height"; - canSaveDynamicFields = "0"; - - new GuiControl(JoinServerWindow) { - position = "48 56"; - extent = "928 655"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + + new GuiPanel(JoinServerTitlePanel) { + extent = "1281 80"; + horizSizing = "width"; + profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_image"; - extent = "927 40"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; new GuiTextCtrl() { text = "JOIN SERVER"; - position = "22 10"; - extent = "207 28"; + position = "22 23"; + extent = "220 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_low_image"; - position = "0 40"; - extent = "927 618"; - horizSizing = "width"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl(JS_status) { - text = "No servers found."; - maxLength = "255"; - position = "392 47"; - extent = "148 18"; - minExtent = "8 8"; + }; + new GuiContainer() { + position = "203 81"; + extent = "900 30"; + profile = GuiMenuPanelProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "center"; + vertSizing = "bottom"; + + new GuiTextCtrl() { + text = "Server Details"; + position = "0 0"; + extent = "730 30"; + horizSizing = "right"; + vertSizing = "center"; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextCtrl() { - text = "Players"; - maxLength = "255"; - position = "269 67"; - extent = "36 18"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - }; - new GuiTextCtrl() { - text = "Version"; - maxLength = "255"; - position = "335 67"; - extent = "38 18"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - }; - new GuiTextCtrl() { - text = "Game"; - maxLength = "255"; - position = "412 67"; - extent = "28 18"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - }; + new GuiTextCtrl() { text = "Ping"; - maxLength = "255"; - position = "212 67"; - extent = "20 18"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; + position = "730 0"; + extent = "50 30"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; }; + new GuiTextCtrl() { - text = "Server Name"; - maxLength = "255"; - position = "12 67"; - extent = "63 18"; - minExtent = "8 8"; - profile = "GuiMLWhiteTextProfile"; + text = "Player Count"; + position = "780 0"; + extent = "120 30"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; }; - new GuiScrollCtrl() { - hScrollBar = "dynamic"; - vScrollBar = "dynamic"; - position = "19 98"; - extent = "890 501"; - minExtent = "8 8"; - profile = "GuiMenuScrollProfile"; - tooltipProfile = "GuiToolTipProfile"; + }; + new GuiScrollCtrl() { + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + position = "203 111"; + extent = "900 601"; + minExtent = "8 8"; + horizSizing = "center"; + vertSizing = "height"; + profile = "GuiMenuScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; - new GuiStackControl(JoinServerList) { - padding = "10"; - changeChildSizeToFit = "0"; - position = "1 1"; - extent = "888 16"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - }; + new GuiStackControl(JoinServerList) { + padding = "10"; + changeChildSizeToFit = "0"; + position = "1 1"; + extent = "888 16"; + horizSizing = "center"; + vertSizing = "center"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; }; - new GuiControl(JS_queryStatus) { - position = "16 615"; - extent = "900 35"; - profile = "GuiDefaultProfile"; - visible = "0"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - hidden = "1"; - - new GuiProgressCtrl(JS_statusBar) { - position = "84 0"; - extent = "695 35"; - minExtent = "8 8"; - profile = "GuiProgressProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; - }; - new GuiButtonCtrl(JS_cancelQuery) { - text = "Cancel!"; - extent = "84 35"; - minExtent = "8 8"; - profile = "GuiMenuButtonProfile"; - command = "JoinServerDlg.cancel();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl(JS_statusText) { - text = "Querying master server"; - maxLength = "255"; - position = "84 0"; - extent = "695 35"; - minExtent = "8 8"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "0"; }; + new GuiPanel(JoinServerButtonPanel) { + position = "0 683"; + extent = "1281 40"; + horizSizing = "width"; + vertSizing = "top"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiIconButtonCtrl(JoinServerJoinBtn) { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Join"; + position = "1115 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "JoinServerMenu.query();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiIconButtonCtrl(JoinServerQLanBtn) { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Query Lan"; + position = "965 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "JoinServerMenu.queryLan();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiIconButtonCtrl(JoinServerQServerBtn) { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Query Server"; + position = "817 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "JoinServerMenu.join();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiIconButtonCtrl(JoinServerBackBtn) { + BitmapAsset = "UI:Keyboard_Black_Escape_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Back"; + position = "16 0"; + extent = "140 40"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.popDialog();"; + tooltipProfile = "GuiToolTipProfile"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index c4d9fff24..d829be8ce 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -1,17 +1,19 @@ function JoinServerMenu::onWake(%this) { + $MenuList = JoinServerList; + JoinServerList.listPosition = 0; } -function JoinServerMenu::onOpen(%this) +if(!isObject( JoinServerActionMap ) ) { - JoinServerList.setAsActiveMenuList(); - - $activeMenuButtonContainer-->button1.set("btn_y", "R", "Refresh", "JoinServerMenu.refresh();"); - $activeMenuButtonContainer-->button2.set("btn_a", "Q", "Query LAN", "JoinServerMenu.queryLan();"); - $activeMenuButtonContainer-->button3.set("btn_x", "E", "Query Online", "JoinServerMenu.query();"); - $activeMenuButtonContainer-->button4.set("btn_start", "Return", "Join", "JoinServerMenu.join();"); - $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", "cancelServerQuery(); " @ %this @ ".navigation.popPage();"); + new ActionMap(JoinServerActionMap){}; + + JoinServerActionMap.bindCmd( keyboard, q, "JoinServerMenu.query();" ); + JoinServerActionMap.bindCmd( gamepad, btn_x, "JoinServerMenu.query();" ); + + JoinServerActionMap.bindCmd( keyboard, e, "JoinServerMenu.queryLan();" ); + JoinServerActionMap.bindCmd( gamepad, btn_y, "JoinServerMenu.queryLan();" ); } //---------------------------------------- @@ -93,19 +95,17 @@ function JoinServerMenu::update(%this) %sc = getServerCount(); for( %i = 0; %i < %sc; %i ++ ) { setServerInfo(%i); - %serverBtn = new GuiButtonCtrl(){ - text = $ServerInfo::Name TAB - $ServerInfo::Ping TAB - $ServerInfo::PlayerCount @ "/" @ $ServerInfo::MaxPlayers TAB - $ServerInfo::Version TAB - $ServerInfo::MissionName; - profile = GuiJoinServerButtonProfile; - extent = JoinServerList.extent.x SPC 30; - }; - JoinServerList.add(%serverBtn); + + %serverEntry = %this.addServerEntry(); + %serverEntry-->serverNameTxt.text = $ServerInfo::Name; + %serverEntry-->serverDetailsTxt.text = $ServerInfo::Version @ " | " @ $ServerInfo::MissionName @ " | " @ $ServerInfo::MissionType; + %serverEntry-->pingTxt.text = $ServerInfo::Ping @ " ms"; + %serverEntry-->playerCountTxt.text = $ServerInfo::PlayerCount @ "|" @ $ServerInfo::MaxPlayers; + + %serverEntry.resize(0, 0, JoinServerList.extent.x, %serverEntry.extent.y); + + JoinServerList.add(%serverEntry); } - - $activeMenuButtonContainer-->button4.setActive(JoinServerList.getCount() > 0); } //---------------------------------------- @@ -138,3 +138,109 @@ function onServerQueryStatus(%status, %msg, %value) JoinServerMenu.update(); } } + +function JoinServerMenu::addServerEntry(%this) +{ + %entry = new GuiContainer() { + position = "0 0"; + extent = "900 40"; + profile = GuiMenuDefaultProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "width"; + vertSizing = "bottom"; + class = "JoinServerServerEntry"; + + new GuiButtonCtrl() { + profile = GuiMenuButtonProfile; + position = "0 0"; + extent = "900 40"; + horizSizing = "width"; + vertSizing = "height"; + internalName = "button"; + }; + + new GuiTextCtrl() { + position = "0 0"; + extent = "730 20"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "serverNameTxt"; + }; + new GuiTextCtrl() { + position = $optionsEntryPad SPC 17; + extent = "730 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "serverDetailsTxt"; + }; + + new GuiTextCtrl() { + position = "730 0"; + extent = "50 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "pingTxt"; + }; + + new GuiTextCtrl() { + position = "780 0"; + extent = "120 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "playerCountTxt"; + }; + }; + + return %entry; +} + +function JoinServerMenu::addStatusEntry(%this) +{ + %entry = new GuiContainer() { + position = "0 0"; + extent = "900 40"; + profile = GuiMenuDefaultProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "width"; + vertSizing = "bottom"; + class = "JoinServerStatusEntry"; + + new GuiTextCtrl() { + position = "0 0"; + extent = "730 20"; + profile = "MenuSubHeaderCenteredText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "statusTxt"; + }; + }; + + return %entry; +} + +function JoinServerList::syncGui(%this) +{ + %this.callOnChildren("setHighlighted", false); + + if(%this.listPosition < %this.getCount()) + { + %btn = %this.getObject(%this.listPosition); + %btn-->button.setHighlighted(true); + } + + // + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + JoinServerBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut")); + JoinServerJoinBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected")); + JoinServerQLanBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.queryLan();")); + JoinServerQServerBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.query();")); + + //JoinServerJoinBtn.setActive($selectedLevelAsset !$= ""); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index 7d6374594..6ccf77732 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -6,22 +6,20 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; + category = "BaseUI"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; canSaveDynamicFields = "1"; new GuiInputCtrl(MainMenuInputHandler) { - sendAxisEvents = "0"; - sendBreakEvents = "0"; ignoreMouseEvents = "1"; + ActionMap = "BaseUIActionMap"; position = "-50 0"; extent = "2186 851"; horizSizing = "width"; vertSizing = "height"; profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; - //class = "MenuInputHandler"; - actionMap = MainMenuActionMap; }; new GuiBitmapCtrl(SideBackgroundImage) { BitmapAsset = "UI:menu_side_background_image"; @@ -33,7 +31,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { }; new GuiBitmapCtrl(MainMenuAppLogo) { BitmapAsset = "UI:Torque_3D_logo_image"; - position = "462 30"; + position = "460 78"; extent = "360 100"; horizSizing = "center"; profile = "GuiDefaultProfile"; @@ -73,7 +71,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { new GuiStackControl(MainMenuButtonList) { padding = "5"; dynamicSize = "0"; - position = "440 185"; + position = "440 199"; extent = "400 322"; horizSizing = "center"; vertSizing = "center"; @@ -85,7 +83,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { text = "Single Player"; extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "openSinglePlayerMenu();"; + command = "$pref::HostMultiPlayer=false;\nCanvas.pushDialog(ChooseLevelMenu);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl(MainMenuCreateSrvrBtn) { @@ -93,7 +91,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { position = "0 45"; extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "openMultiPlayerMenu();"; + command = "$pref::HostMultiPlayer=true;Canvas.pushDialog(ChooseLevelMenu);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl(MainMenuJoinSrvrBtn) { @@ -101,7 +99,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { position = "0 90"; extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "openJoinServerMenu();"; + command = "Canvas.pushDialog(JoinServerMenu);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl(MainMenuOptionBtn) { @@ -117,7 +115,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { position = "0 180"; extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "openWorldEditorBtn();"; + command = "fastLoadWorldEdit(1);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl(MainMenuGuiEditBtn) { @@ -125,7 +123,7 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { position = "0 225"; extent = "400 40"; profile = "GuiMenuButtonProfile"; - command = "openGUIEditorBtn();"; + command = "fastLoadGUIEdit(1);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl(MainMenuExitBtn) { diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index 9ec352dc1..b334aeca8 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -4,60 +4,84 @@ function MainMenuGui::onAdd(%this) function MainMenuGui::onWake(%this) { - MainMenuButtonList.listPosition = 0; + $MenuList = MainMenuButtonList; + $MenuList.listPosition = 0; } -if(!isObject( MainMenuActionMap ) ) +function MainMenuGui::onSleep(%this) { - new ActionMap(MainMenuActionMap){}; - - MainMenuActionMap.bind( keyboard, w, mainMenuNavigateUp ); - MainMenuActionMap.bind( keyboard, s, mainMenuNavigateDown ); - MainMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", mainMenuStickNavigate ); - MainMenuActionMap.bind( gamepad, upov, mainMenuNavigateUp ); - MainMenuActionMap.bind( gamepad, dpov, mainMenuNavigateDown ); - - MainMenuActionMap.bind( keyboard, Enter, activateSelected ); - MainMenuActionMap.bind( gamepad, btn_a, activateSelected ); } -function mainMenuNavigateUp(%val) +if(!isObject( BaseUIActionMap ) ) +{ + new ActionMap(BaseUIActionMap){}; + + BaseUIActionMap.bind( keyboard, w, BaseUINavigatePrev ); + BaseUIActionMap.bind( keyboard, s, BaseUINavigateNext ); + BaseUIActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", BaseUIStickNavigate ); + BaseUIActionMap.bind( gamepad, upov, BaseUINavigatePrev ); + BaseUIActionMap.bind( gamepad, dpov, BaseUINavigateNext ); + + BaseUIActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); + BaseUIActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); + + BaseUIActionMap.bind( keyboard, Escape, BaseUIBackOut ); + BaseUIActionMap.bind( gamepad, btn_b, BaseUIBackOut ); +} + +function BaseUINavigatePrev(%val) { if(%val) { - MainMenuButtonList.listPosition -= 1; - if(MainMenuButtonList.listPosition < 0) - MainMenuButtonList.listPosition = 0; + $MenuList.listPosition -= 1; + if($MenuList.listPosition < 0) + $MenuList.listPosition = 0; - MainMenuGUI.syncGUI(); + $MenuList.syncGUI(); } } -function mainMenuNavigateDown(%val) +function BaseUINavigateNext(%val) { if(%val) { - MainMenuButtonList.listPosition += 1; - if(MainMenuButtonList.listPosition >= MainMenuButtonList.getCount()) - MainMenuButtonList.listPosition = MainMenuButtonList.getCount()-1; + $MenuList.listPosition += 1; + if($MenuList.listPosition >= $MenuList.getCount()) + $MenuList.listPosition = $MenuList.getCount()-1; - MainMenuGUI.syncGUI(); + $MenuList.syncGUI(); } } -function mainMenuStickNavigate(%val) +function BaseUIStickNavigate(%val) { if(%val == -1) - mainMenuNavigateUp(1); + BaseUINavigateNext(1); else if(%val == 1) mainMenuNavigateDown(1); } -function MainMenuGUI::syncGUI(%this) +function BaseUIBackOut(%val) { - MainMenuButtonList.callOnChildren("setHighlighted", false); + //we can't navigate further back than the MainMenuGui + if(%val && Canvas.getObject(Canvas.getCount()-1) != MainMenuGui) + { + Canvas.popDialog(); + %topMenu = Canvas.getObject(Canvas.getCount()-1); + if(isObject(%topMenu)) + { + //re-kick the on-wake so we can be fully up to date and relevently + //contexted + %topMenu.onWake(); + } + } +} + +function MainMenuButtonList::syncGUI(%this) +{ + %this.callOnChildren("setHighlighted", false); - %btn = MainMenuButtonList.getObject(MainMenuButtonList.listPosition); + %btn = %this.getObject(%this.listPosition); %btn.setHighlighted(true); // @@ -66,25 +90,13 @@ function MainMenuGUI::syncGUI(%this) if(%device $= "mouse") %device = "keyboard"; - %binding = MainMenuActionMap.getBinding("activateSelected"); - - %bindingCount = getFieldCount(%binding); - for(%i=0; %i < %bindingCount; %i+=2) - { - %mapDevice = stripTrailingNumber(getField(%binding, %i)); - if(%mapDevice $= %device) - { - %button = getField(%binding, %i+1); - break; - } - } - - %assetId = getButtonBitmap(%device, %button); - MainMenuGoButton.setBitmap(%assetId); + MainMenuGoButton.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected")); } -function activateSelected() +function BaseUIActivateSelected() { - %btn = MainMenuButtonList.getObject(MainMenuButtonList.listPosition); - %btn.performClick(); + %btn = $MenuList.getObject($MenuList.listPosition); + + if(%btn.isMethod("performClick")) + %btn.performClick(); } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui index 91207adff..1923c3a11 100644 --- a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.gui @@ -1,347 +1,75 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(MessageBoxDlg) { - position = "0 0"; - extent = "1024 768"; + extent = "1280 720"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; profile = "GuiOverlayProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; canSaveDynamicFields = "1"; helpTag = "0"; - new GuiControl(MessageBoxCtrl) { - position = "192 197"; - extent = "641 381"; - minExtent = "8 2"; + new GuiInputCtrl(MessageBoxInputHandler) { + ignoreMouseEvents = "1"; + ActionMap = "MessageBoxActionMap"; + position = "-50 0"; + extent = "2186 851"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiInputCtrlProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + + new GuiBitmapCtrl() { + BitmapAsset = "UI:backdrop_image"; + position = "272 128"; + extent = "735 463"; + horizSizing = "center"; + vertSizing = "center"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiControl(MessageBoxCtrl) { + position = "319 169"; + extent = "641 381"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; - bitmapAsset = "UI:panel_image"; - color = "255 255 255 255"; - position = "0 0"; - extent = "641 40"; - minExtent = "8 2"; + new GuiPanel() { + extent = "641 381"; horizSizing = "width"; - vertSizing = "bottom"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; + vertSizing = "height"; + profile = "GuiMenuBasePanelProfile"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiTextCtrl(MessageBoxTitleText) { - text = "OPTIONS"; - maxLength = "1024"; - margin = "0 0 0 0"; - padding = "0 0 0 0"; - anchorTop = "1"; - anchorBottom = "0"; - anchorLeft = "1"; - anchorRight = "0"; position = "32 7"; extent = "577 28"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "MenuHeaderText"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiBitmapBarCtrl() { - percent = "100"; - vertical = "0"; - flipClip = "0"; - bitmapAsset = "UI:panel_low_image"; - color = "255 255 255 255"; - position = "0 40"; - extent = "641 341"; - minExtent = "8 2"; horizSizing = "width"; - vertSizing = "bottom"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; + profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; new GuiMLTextCtrl(MessageBoxText) { - lineSpacing = "2"; - allowColorChars = "0"; - maxChars = "-1"; - useURLMouseCursor = "0"; position = "81 83"; extent = "481 19"; minExtent = "8 8"; horizSizing = "center"; vertSizing = "center"; profile = "MenuMLSubHeaderText"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; }; - new GuiControl(MessageBoxOKButtonHolder) { - position = "0 285"; - extent = "642 40"; - minExtent = "8 2"; - horizSizing = "center"; + new GuiStackControl(MessageBoxButtonHolder) { + stackingType = "Horizontal"; + position = "250 285"; + extent = "140 40"; + horizSizing = "width"; vertSizing = "top"; profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "251 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "OKButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; - new GuiControl(MessageBoxOCButtonHolder) { - position = "0 285"; - extent = "642 40"; - minExtent = "8 2"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "171 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "OKButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "323 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "CancelButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - }; - new GuiControl(MessageBoxYNCButtonHolder) { - position = "0 285"; - extent = "642 40"; - minExtent = "8 2"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - visible = "1"; - active = "1"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - canSave = "1"; - canSaveDynamicFields = "0"; - - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "99 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "yesButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "251 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "noButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - new GuiIconButtonCtrl() { - buttonMargin = "4 4"; - iconBitmap = "data/ui/images/Inputs/Keyboard & Mouse/Keyboard_Black_Enter"; - iconLocation = "Left"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - textMargin = "4"; - autoSize = "0"; - text = "Go"; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "403 0"; - extent = "140 40"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = "MainMenuButtonList.activateRow();"; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - internalName = "CancelButton"; - class = "MenuInputButton"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript new file mode 100644 index 000000000..7ef43ba05 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript @@ -0,0 +1,218 @@ +//----------------------------------------------------------------------------- +// 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. +//----------------------------------------------------------------------------- + +// -------------------------------------------------------------------- +// Message Sound +// -------------------------------------------------------------------- +/*new SFXDescription(MessageBoxAudioDescription) +{ + volume = 1.0; + isLooping = false; + is3D = false; + channel = $GuiAudioType; +}; + +new SFXProfile(messageBoxBeep) +{ + filename = "./messageBoxSound"; + description = MessageBoxAudioDescription; + preload = true; +};*/ + +//--------------------------------------------------------------------------------------------- +// messageCallback +// Calls a callback passed to a message box. +//--------------------------------------------------------------------------------------------- +function messageCallback(%dlg, %callback) +{ + Canvas.popDialog(%dlg); + eval(%callback); +} + +//--------------------------------------------------------------------------------------------- +// MBSetText +// Sets the text of a message box and resizes it to accomodate the new string. +//--------------------------------------------------------------------------------------------- +function MBSetText(%text, %frame, %msg) +{ + // Get the extent of the text box. + %ext = %text.getExtent(); + // Set the text in the center of the text box. + %text.setText("" @ %msg); + // Force the textbox to resize itself vertically. + %text.forceReflow(); + // Grab the new extent of the text box. + %newExtent = %text.getExtent(); + + // Get the vertical change in extent. + %deltaY = getWord(%newExtent, 1) - getWord(%ext, 1); + + // Resize the window housing the text box. + %windowPos = %frame.getPosition(); + %windowExt = %frame.getExtent(); + %frame.resize(getWord(%windowPos, 0), getWord(%windowPos, 1) - (%deltaY / 2), + getWord(%windowExt, 0), getWord(%windowExt, 1) + %deltaY); + + %frame.canMove = "0"; + //%frame.canClose = "0"; + %frame.resizeWidth = "0"; + %frame.resizeHeight = "0"; + %frame.canMinimize = "0"; + %frame.canMaximize = "0"; + + //sfxPlayOnce( messageBoxBeep ); +} + +function MessageBoxCtrl::onWake(%this) +{ + %this.callback = ""; + %this.cancelCallback = ""; +} + +//--------------------------------------------------------------------------------------------- +// Various message box display functions. Each one takes a window title, a message, and a +// callback for each button. +//--------------------------------------------------------------------------------------------- +function MessageBoxCtrl::createButton(%this, %text, %command, %bitmap) +{ + %btn = new GuiIconButtonCtrl() { + BitmapAsset = %bitmap; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + iconLocation = "Left"; + text = %text; + position = "251 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = %command; + tooltipProfile = "GuiToolTipProfile"; + }; + + MessageBoxButtonHolder.add(%btn); + + //update positioning of the holder to be centered + MessageBoxButtonHolder.position.x = MessageBoxCtrl.extent.x/2 - MessageBoxButtonHolder.extent.x/2; + + return %btn; +} + +function MessageBoxDlg::onWake(%this) +{ + +} + +if(!isObject( MessageBoxActionMap ) ) +{ + new ActionMap(MessageBoxActionMap){}; + + MessageBoxActionMap.bind( keyboard, Enter, messageBoxYesClicked ); + MessageBoxActionMap.bind( gamepad, btn_a, messageBoxYesClicked ); + + MessageBoxActionMap.bind( keyboard, Escape, messageBoxNoClicked ); + MessageBoxActionMap.bind( gamepad, btn_b, messageBoxNoClicked ); +} + +function MessageBoxCtrl::syncGui(%this) +{ + +} + +function messageBoxYesClicked(%this) +{ + MessageCallback(MessageBoxDlg, MessageBoxDlg.callback); +} + +function messageBoxNoClicked(%this) +{ + MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback); +} + +//MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\""); +function MessageBoxOK(%title, %message, %callback) +{ + MessageBoxButtonHolder.clear(); + + Canvas.pushDialog(MessageBoxDlg); + MessageBoxTitleText.text = %title; + + %okButton = MessageBoxCtrl.createButton("OK", "messageBoxYesClicked();"); + %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxYesClicked"); + %okButton.setBitmap(%bitmapAssetId); + + MBSetText(MessageBoxText, MessageBoxCtrl, %message); + MessageBoxDlg.callback = %callback; +} + +function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback, %okLabelOverride, %cancelLabelOverride) +{ + MessageBoxButtonHolder.clear(); + + Canvas.pushDialog(MessageBoxDlg); + MessageBoxTitleText.text = %title; + + if(%okLabelOverride $= "") + %okLabel = "OK"; + else + %okLabel = %okLabelOverride; + + if(%cancelLabelOverride $= "") + %cancelLabel = "Cancel"; + else + %cancelLabel = %cancelLabelOverride; + + %okButton = MessageBoxCtrl.createButton(%okLabel, "messageBoxYesClicked();"); + %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxYesClicked"); + %okButton.setBitmap(%bitmapAssetId); + + %cancelButton = MessageBoxCtrl.createButton(%cancelLabel, "messageBoxNoClicked();"); + %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxNoClicked"); + %cancelButton.setBitmap(%bitmapAssetId); + + MBSetText(MessageBoxText, MessageBoxCtrl, %message); + MessageBoxDlg.callback = %callback; + MessageBoxDlg.cancelCallback = %cancelCallback; +} + +function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback) +{ + MessageBoxOKCancel(%title, %message, %yesCallback, %noCallback, "Yes", "No"); +} + +//--------------------------------------------------------------------------------------------- +// MessagePopup +// Displays a message box with no buttons. Disappears after %delay milliseconds. +//--------------------------------------------------------------------------------------------- +function MessagePopup(%title, %message, %delay) +{ + Canvas.pushDialog(MessageBoxDlg); + MessageBoxTitleText.text = %title; + MBSetText(MessageBoxText, MessageBoxCtrl, %message); + + if (%delay !$= "") + schedule(%delay, 0, CloseMessagePopup); +} + +function CloseMessagePopup() +{ + Canvas.popDialog(MessageBoxDlg); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 33eae9db5..522e7044a 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -6,73 +6,94 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; + category = "BaseUI"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; canSaveDynamicFields = "1"; - currentCategory = "Graphics"; - optionsCategories = "17233"; - unappliedChanges = "17234"; + optionsCategories = "17237"; + unappliedChanges = "17238"; - new GuiControl(OptionsMenuContainer) { - position = "208 32"; - extent = "870 655"; - horizSizing = "aspectCenter"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - }; - new GuiInputCtrl(MainMenuInputHandler) { + new GuiInputCtrl(OptionsMenuInputHandler) { ignoreMouseEvents = "1"; - ActionMap = "MainMenuActionMap"; - position = "-49 0"; + ActionMap = "OptionsMenuActionMap"; + position = "-50 0"; extent = "2186 851"; horizSizing = "width"; vertSizing = "height"; profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiStackControl(OptionsMenuCategoryList) { - stackingType = "Horizontal"; - padding = "10"; - dynamicSize = "0"; - position = "398 80"; - extent = "471 40"; + new GuiControl(OptionsMenuCategoryContainer) { + position = "332 80"; + extent = "617 49"; horizSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; + isContainer = "1"; - new GuiButtonCtrl() { - text = "Video"; - extent = "100 40"; + new GuiIconButtonCtrl(OptionsMenuCatPrevBtn) { + BitmapAsset = "UI:Keyboard_Black_Q_image"; + iconLocation = "Center"; + makeIconSquare = "1"; + textLocation = "Center"; + bitmapMargin = "30"; + position = "1 4"; + extent = "50 40"; + vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "populateDisplaySettingsList();"; + command = "OptionsMenuCategoryPrev();"; tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; }; - new GuiButtonCtrl() { - text = "Audio"; - position = "110 0"; - extent = "100 40"; + new GuiIconButtonCtrl(OptionsMenuCatNextBtn) { + BitmapAsset = "UI:Keyboard_Black_E_image"; + iconLocation = "Center"; + makeIconSquare = "1"; + bitmapMargin = "30"; + position = "568 4"; + extent = "50 40"; + horizSizing = "left"; + vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "populateAudioSettingsList();"; + command = "OptionsMenuCategoryNext();"; tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; }; - new GuiButtonCtrl() { - text = "Keyboard & Mouse"; - position = "220 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - command = "populateKeyboardMouseSettingsList();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Gamepad"; - position = "370 0"; - extent = "100 40"; - profile = "GuiMenuButtonProfile"; - command = "populateGamepadSettingsList();"; + new GuiStackControl(OptionsMenuCategoryList) { + stackingType = "Horizontal"; + padding = "10"; + dynamicSize = "0"; + position = "137 3"; + extent = "358 40"; + horizSizing = "center"; + vertSizing = "center"; + profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; + superClass = "MenuList"; + + new GuiButtonCtrl() { + text = "Video"; + extent = "100 40"; + profile = "GuiMenuButtonProfile"; + command = "populateDisplaySettingsList();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Audio"; + position = "110 0"; + extent = "100 40"; + profile = "GuiMenuButtonProfile"; + command = "populateAudioSettingsList();"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Controls"; + position = "220 0"; + extent = "140 40"; + profile = "GuiMenuButtonProfile"; + command = "populateKeyboardMouseSettingsList();"; + tooltipProfile = "GuiToolTipProfile"; + }; }; }; new GuiScrollCtrl(OptionsMenuSettingsScroll) { @@ -89,13 +110,227 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { padding = "5"; changeChildSizeToFit = "0"; position = "1 1"; - extent = "603 245"; + extent = "603 200"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; superClass = "MenuList"; - visible = true; + + new GuiTextCtrl() { + text = "Basic"; + extent = "500 30"; + profile = "MenuHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiContainer() { + position = "0 35"; + extent = "603 40"; + horizSizing = "width"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "OptionsListEntry"; + + new GuiButtonCtrl() { + extent = "603 40"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "Button"; + class = "optionsMenuButton"; + }; + new GuiTextCtrl() { + text = "Graphical Quality"; + position = "10 -1"; + extent = "250 20"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionName"; + }; + new GuiTextCtrl() { + text = "Controls the general graphical quality"; + position = "10 17"; + extent = "178 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionDescription"; + }; + new GuiContainer() { + position = "353 0"; + extent = "250 40"; + horizSizing = "left"; + vertSizing = "height"; + profile = "GuiModelessDialogProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "valuesContainer"; + + new GuiButtonCtrl() { + text = "<"; + position = "160 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextCtrl() { + text = "High"; + position = "180 0"; + extent = "50 40"; + vertSizing = "center"; + profile = "GuiMenuTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionValue"; + }; + new GuiButtonCtrl() { + text = ">"; + position = "230 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + }; + new GuiContainer() { + position = "0 80"; + extent = "603 40"; + horizSizing = "width"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "OptionsListEntry"; + + new GuiButtonCtrl() { + extent = "603 40"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "Button"; + class = "optionsMenuButton"; + }; + new GuiTextCtrl() { + text = "Lighting Quality"; + position = "10 -1"; + extent = "250 20"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionName"; + }; + new GuiTextCtrl() { + text = "Controls the lighting and shadows quality"; + position = "10 17"; + extent = "198 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionDescription"; + }; + new GuiContainer() { + position = "353 0"; + extent = "250 40"; + horizSizing = "left"; + vertSizing = "height"; + profile = "GuiModelessDialogProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "valuesContainer"; + + new GuiButtonCtrl() { + text = "<"; + position = "160 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextCtrl() { + text = "High"; + position = "180 0"; + extent = "50 40"; + vertSizing = "center"; + profile = "GuiMenuTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionValue"; + }; + new GuiButtonCtrl() { + text = ">"; + position = "230 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + }; + new GuiTextCtrl() { + text = "Advanced"; + position = "0 125"; + extent = "500 30"; + profile = "MenuHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiContainer() { + position = "0 160"; + extent = "603 40"; + horizSizing = "width"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + class = "OptionsListEntry"; + + new GuiButtonCtrl() { + extent = "603 40"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "Button"; + class = "optionsMenuButton"; + }; + new GuiTextCtrl() { + text = "Mesh Detail"; + position = "10 -1"; + extent = "250 20"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionName"; + }; + new GuiTextCtrl() { + text = "Controls the max quality of mesh objects"; + position = "10 17"; + extent = "195 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "OptionDescription"; + }; + new GuiContainer() { + position = "353 0"; + extent = "250 40"; + horizSizing = "left"; + vertSizing = "height"; + profile = "GuiModelessDialogProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "valuesContainer"; + + new GuiButtonCtrl() { + text = "<"; + position = "160 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextCtrl() { + text = "High"; + position = "180 0"; + extent = "50 40"; + vertSizing = "center"; + profile = "GuiMenuTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionValue"; + }; + new GuiButtonCtrl() { + text = ">"; + position = "230 0"; + extent = "20 40"; + profile = "GuiMenuButtonProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + }; }; new GuiStackControl(AudioSettingsList) { padding = "5"; @@ -105,9 +340,10 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; + visible = "0"; tooltipProfile = "GuiToolTipProfile"; superClass = "MenuList"; - visible = false; + hidden = "1"; }; new GuiStackControl(ControlSettingsList) { padding = "5"; @@ -117,9 +353,10 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; + visible = "0"; tooltipProfile = "GuiToolTipProfile"; superClass = "MenuList"; - visible = false; + hidden = "1"; }; }; new GuiPanel(OptionMenuTitlePanel) { @@ -136,7 +373,7 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; }; }; - new GuiPanel(MainMenuButtonPanel) { + new GuiPanel(OptionsMenuButtonPanel) { position = "0 683"; extent = "1281 40"; horizSizing = "width"; @@ -144,7 +381,7 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; - new GuiIconButtonCtrl() { + new GuiIconButtonCtrl(OptionsMenuApplyBtn) { BitmapAsset = "UI:Keyboard_Black_Return_image"; sizeIconToButton = "1"; makeIconSquare = "1"; @@ -155,12 +392,11 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "MainMenuSelectButton(1);"; + command = "OptionsMenu.applySettings();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; class = "MenuInputButton"; }; - new GuiIconButtonCtrl() { + new GuiIconButtonCtrl(OptionsMenuBackBtn) { BitmapAsset = "UI:Keyboard_Black_Escape_image"; sizeIconToButton = "1"; makeIconSquare = "1"; @@ -168,44 +404,27 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { text = "Back"; position = "16 0"; extent = "140 40"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "Canvas.popDialog();"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl(OptionsMenuResetBtn) { + BitmapAsset = "UI:Keyboard_Black_Return_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Reset"; + position = "947 0"; + extent = "140 40"; horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "MainMenuSelectButton(1);"; + command = "OptionsMenu.resetSettings();"; tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; class = "MenuInputButton"; }; }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_E_image"; - iconLocation = "Center"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - position = "899 80"; - extent = "50 40"; - horizSizing = "left"; - vertSizing = "center"; - profile = "GuiMenuButtonProfile"; - command = "MainMenuSelectButton(1);"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; - class = "MenuInputButton"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Q_image"; - iconLocation = "Center"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - position = "331 80"; - extent = "50 40"; - horizSizing = "left"; - vertSizing = "center"; - profile = "GuiMenuButtonProfile"; - command = "MainMenuSelectButton(1);"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; - class = "MenuInputButton"; - }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 5bdc09e92..9e52e4154 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -48,6 +48,7 @@ $yesNoList = "No\tYes"; $onOffList = "Off\tOn"; +$optionsEntryPad = 10; function OptionsMenu::onAdd(%this) { @@ -63,12 +64,6 @@ function OptionsMenu::onAdd(%this) %this.currentCategory = ""; - addOptionsMenuCategory("Display", "populateDisplaySettingsList();"); - addOptionsMenuCategory("Graphics", "populateGraphicsSettingsList();"); - addOptionsMenuCategory("Audio", "populateAudioSettingsList();"); - addOptionsMenuCategory("Keyboard & Mouse", "populateKeyboardMouseSettingsList();"); - addOptionsMenuCategory("Gamepad", "populateGamepadSettingsList();"); - callOnModules("populateOptionsMenuCategories", "Game"); } @@ -93,28 +88,147 @@ function OptionsMenu::onWake(%this) { %option = %setting.getObject(%s); - %optionsEntry = addOptionEntry(); - %optionsEntry-->optionName.text = %option.OptionName; - %optionsEntry-->optionDescription.text = %option.Description; - %optionsEntry-->optionValue.text = %option.getObject(0).displayName; - + %optionsEntry = addOptionEntry(%option); + if(isObject(%optionsEntry)) + { + %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y); + VideoSettingsList.add(%optionsEntry); + } } } else if(%setting.class $= "OptionsSettings") { - %entry = addOptionEntry(); - %entry-->optionName.text = %setting.displayName; - %entry-->optionDescription.text = %setting.description; - %entry-->optionValue.text = %setting.getObject(0).displayName; - - if(isObject(%entry)) - VideoSettingsList.add(%entry); + %optionsEntry = addOptionEntry(%option); + + if(isObject(%optionsEntry)) + { + %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y); + + VideoSettingsList.add(%optionsEntry); + } } } + + $MenuList = VideoSettingsList; + + //Find our first non-group entry + while($MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry && $MenuList.listPosition < $MenuList.getCount()) + { + $MenuList.listPosition += 1; + } } +if(!isObject( OptionsMenuActionMap ) ) +{ + new ActionMap(OptionsMenuActionMap){}; + + OptionsMenuActionMap.bind( keyboard, w, OptionMenuNavigatePrev ); + OptionsMenuActionMap.bind( keyboard, s, OptionMenuNavigateNext ); + OptionsMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", OptionMenuStickNavigate ); + OptionsMenuActionMap.bind( gamepad, upov, OptionMenuNavigatePrev ); + OptionsMenuActionMap.bind( gamepad, dpov, OptionMenuNavigateNext ); + + OptionsMenuActionMap.bind( keyboard, a, OptionMenuPrevSetting ); + OptionsMenuActionMap.bind( keyboard, d, OptionMenuNextSetting ); + OptionsMenuActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", OptionMenuStickChangeSetting ); + OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting ); + OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuNextSetting ); + + //OptionsMenuActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); + //OptionsMenuActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); +} + +function VideoSettingsList::syncGui(%this) +{ + %this.callOnChildren("setHighlighted", false); + + %btn = %this.getObject(%this.listPosition); + if(%btn.class $= "OptionsListEntry") + %btn-->button.setHighlighted(true); +} + +// +function OptionMenuNavigatePrev(%val) +{ + if(%val) + { + $MenuList.listPosition -= 1; + while( $MenuList.listPosition >= 0 && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry) + { + $MenuList.listPosition -= 1; + } + + if($MenuList.listPosition < 0) + $MenuList.listPosition = 0; + + $MenuList.syncGUI(); + } +} + +function OptionMenuNavigateNext(%val) +{ + if(%val) + { + $MenuList.listPosition += 1; + while($MenuList.listPosition < $MenuList.getCount() && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry) + { + $MenuList.listPosition += 1; + } + + if($MenuList.listPosition >= $MenuList.getCount()) + $MenuList.listPosition = $MenuList.getCount()-1; + + $MenuList.syncGUI(); + } +} + +function OptionMenuStickNavigate(%val) +{ + if(%val == -1) + BaseUINavigateNext(1); + else if(%val == 1) + mainMenuNavigateDown(1); +} + +function OptionMenuPrevSetting(%val) +{ + %option = $MenuList.getObject($MenuList.listPosition); + echo("Option: " @ %option.className); + %optionObject = %option.optionsObject; + %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName); + /*$MenuList.listPosition -= 1; + + if($MenuList.listPosition < 0) + $MenuList.listPosition = 0;*/ + + $MenuList.syncGUI(); +} + +function OptionMenuNextSetting(%val) +{ + %option = $MenuList.getObject($MenuList.listPosition); + %optionObject = %option.optionsObject; + %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName); + + /*$MenuList.listPosition += 1; + + if($MenuList.listPosition >= $MenuList.getCount()) + $MenuList.listPosition = $MenuList.getCount()-1;*/ + + $MenuList.syncGUI(); +} + +function OptionMenuStickChangeSetting(%val) +{ + +} +// function OptionsMenu::onOpen(%this) { OptionsMenuCategoryList.clear(); @@ -173,7 +287,7 @@ function OptionsMenu::canClose(%this) //UINavigation to not close the page if(OptionsMenuSettingsList.isActiveMenuList()) { - OptionsMenuCategoryList.setAsActiveMenuList(); + OptionsMenuCategoryList.setAsActiveMenuList(); return false; } else @@ -1238,28 +1352,66 @@ function addOptionGroup() }; return %group; - } -function addOptionEntry() +function optionsMenuButton::onHighlighted(%this, %highlighted) { + %container = %this.getParent(); + + %container-->optionName.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText; + %container-->optionDescription.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile; + + %valuesContainer = %container-->valuesContainer; + %valuesContainer-->optionValue.profile = %highlighted ? GuiMenuTextProfileHighlighted : GuiMenuTextProfile; +} + +function optionsMenuButton::onMouseDown(%this) +{ + //check if we're clicking on the left or right of the value and adjust it accordingly +} + +function addOptionEntry(%optionObj) +{ + if(!isObject(%optionObj) || %optionObj.class !$= "OptionsSettings") + { + error("addOptionsEntry() - attempting to create a new options entry, but was provided an invalid options object"); + return 0; + } + + %qualityLevel = %optionObj.getObject(0); + %entry = new GuiContainer() { position = "0 0"; extent = "500 40"; - profile = "GuiMenuPanelProfile"; + profile = GuiMenuDefaultProfile; tooltipProfile = "GuiToolTipProfile"; + horizSizing = "width"; + vertSizing = "bottom"; + class = "OptionsListEntry"; + optionsObject = %optionObj; + currentOptionIndex = 0; + + new GuiButtonCtrl() { + profile = GuiMenuButtonProfile; + position = "0 0"; + extent = "500 40"; + horizSizing = "width"; + vertSizing = "height"; + internalName = "button"; + class = "optionsMenuButton"; + }; new GuiTextCtrl() { - text = ""; - position = "1 -1"; + text = %optionObj.OptionName; + position = $optionsEntryPad SPC -1; extent = "250 20"; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; internalName = "optionName"; }; new GuiTextCtrl() { - text = "Sets the resolution and detail of shadows"; - position = "1 17"; + text = %optionObj.Description; + position = $optionsEntryPad SPC 17; extent = "250 18"; profile = "GuiMLTextProfile"; tooltipProfile = "GuiToolTipProfile"; @@ -1273,17 +1425,32 @@ function addOptionEntry() tooltipProfile = "GuiToolTipProfile"; horizSizing = "left"; vertSizing = "height"; + internalName = "valuesContainer"; + + new GuiButtonCtrl() { + position = "160 0"; + extent = "20 40"; + text = "<"; + profile = GuiMenuButtonProfile; + }; new GuiTextCtrl() { - text = "< High >"; + text = %qualityLevel.displayName; position = "180 0"; - extent = "70 40"; + extent = "50 40"; profile = "GuiMenuTextProfile"; tooltipProfile = "GuiToolTipProfile"; - horizSizing = "left"; + horizSizing = "right"; vertSizing = "center"; internalName = "optionValue"; }; + + new GuiButtonCtrl() { + position = "230 0"; + extent = "20 40"; + text = ">"; + profile = GuiMenuButtonProfile; + }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui b/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui deleted file mode 100644 index 59d498e28..000000000 --- a/Templates/BaseGame/game/data/UI/guis/pauseMenu.gui +++ /dev/null @@ -1,163 +0,0 @@ -//--- OBJECT WRITE BEGIN --- -$guiContent = new GuiControl(PauseMenu) { - extent = "1024 768"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - superClass = "UINavigation"; - canSaveDynamicFields = "1"; - - new GuiChunkedBitmapCtrl(PauseMenuBG) { - BitmapAsset = "UI:hudfill_image"; - extent = "1024 768"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - canSaveDynamicFields = "1"; - }; - new GuiInputCtrl(PauseMenuInputHandler) { - sendAxisEvents = "1"; - sendBreakEvents = "1"; - ignoreMouseEvents = "1"; - position = "-50 0"; - extent = "10 10"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiInputCtrlProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputHandler"; - }; - new GuiControl(PauseMenuButtons) { - position = "162 125"; - extent = "700 518"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - - new GuiStackControl(PauseMenuList) { - padding = "15"; - dynamicSize = "0"; - extent = "700 320"; - horizSizing = "center"; - vertSizing = "center"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - - new GuiButtonCtrl() { - text = "Options"; - extent = "700 55"; - profile = "GuiMenuButtonProfile"; - command = "openPauseMenuOptions();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Exit to Menu"; - position = "0 70"; - extent = "700 55"; - profile = "GuiMenuButtonProfile"; - command = "pauseMenuExitToMenu();"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiButtonCtrl() { - text = "Exit to Desktop"; - position = "0 140"; - extent = "700 55"; - profile = "GuiMenuButtonProfile"; - command = "pauseMenuExitToDesktop();"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; - }; - new GuiControl(PauseButtonHolder) { - position = "144 711"; - extent = "736 40"; - horizSizing = "center"; - vertSizing = "top"; - profile = "GuiDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - isContainer = "1"; - class = "MenuInputButtonContainer"; - - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - position = "11 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - visible = "0"; - active = "0"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button1"; - class = "MenuInputButton"; - hidden = "1"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - position = "155 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - visible = "0"; - active = "0"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button2"; - class = "MenuInputButton"; - hidden = "1"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - position = "299 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - visible = "0"; - active = "0"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button3"; - class = "MenuInputButton"; - hidden = "1"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - position = "443 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - visible = "0"; - active = "0"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button4"; - class = "MenuInputButton"; - hidden = "1"; - }; - new GuiIconButtonCtrl() { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Right"; - position = "587 0"; - extent = "140 40"; - profile = "GuiMenuButtonProfile"; - visible = "0"; - active = "0"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "button5"; - class = "MenuInputButton"; - hidden = "1"; - }; - }; -}; -//--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript b/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript deleted file mode 100644 index 0c55e625f..000000000 --- a/Templates/BaseGame/game/data/UI/guis/pauseMenu.tscript +++ /dev/null @@ -1,93 +0,0 @@ -function PauseMenu::onWake(%this) -{ - if($Server::ServerType $= "SinglePlayer") - { - $timescale = 0; - - sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ 0 ] ); - } - - PauseButtonHolder.setActive(); - PauseMenuInputHandler.setFirstResponder(); - - %this.resizePages = true; - - %this.setRootPage(PauseMenuButtons); -} - -function PauseMenuButtons::onOpen(%this) -{ - PauseMenuList.clear(); - - if($Tools::loaded && EditorIsActive()) - { - %this.addPauseMenuButton("Exit Editor", "fastLoadWorldEdit();"); - } - - %this.addPauseMenuButton("Options", "openPauseMenuOptions();"); - %this.addPauseMenuButton("Exit to Menu", "pauseMenuExitToMenu();"); - %this.addPauseMenuButton("Exit to Desktop", "pauseMenuExitToDesktop();"); - - PauseMenuList.setAsActiveMenuList(); - - $activeMenuButtonContainer-->button1.disable(); - $activeMenuButtonContainer-->button2.disable(); - $activeMenuButtonContainer-->button3.disable(); - $activeMenuButtonContainer-->button4.set("btn_a", "", "OK", "PauseMenuList.activate();"); - $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", "Canvas.popDialog();"); -} - -function PauseMenuButtons::addPauseMenuButton(%this, %buttonText, %buttonCallback) -{ - %newButton = new GuiButtonCtrl() { - text = %buttonText; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 0"; - extent = "400 55"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = %buttonCallback; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - - PauseMenuList.add(%newButton); -} -function PauseMenu::onSleep(%this) -{ - if($Server::ServerType $= "SinglePlayer") - { - $timescale = 1; - sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); - } -} - -function openPauseMenuOptions() -{ - PauseMenu.pushPage(OptionsMenu); -} - -function pauseMenuExitToMenu() -{ - MessageBoxOKCancel("Exit?", "Do you wish to exit to the Main Menu?", "escapeFromGame();", ""); -} - -function pauseMenuExitToDesktop() -{ - MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", ""); -} - -function PauseButtonHolder::onWake(%this) -{ - - -} diff --git a/Templates/BaseGame/game/data/UI/guis/recordingsDlg.asset.taml b/Templates/BaseGame/game/data/UI/guis/recordingsDlg.asset.taml deleted file mode 100644 index 2b0c337b5..000000000 --- a/Templates/BaseGame/game/data/UI/guis/recordingsDlg.asset.taml +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/Templates/BaseGame/game/data/UI/images/backdrop.png b/Templates/BaseGame/game/data/UI/images/backdrop.png new file mode 100644 index 0000000000000000000000000000000000000000..e645dfe0da2394b880a35cdf432e9fa5a5954fb1 GIT binary patch literal 5290 zcmV;b6jkeqP)EX>4Tx04R}tkv&MmKpe$iQ>9WW4t5Z6$WR5rf~bh2v|S}bq^n3@1i`*``n+SUn!Uj@QK9pOgAjz4dU5N zOXs{#9A;%nAwDObFzABBk6f2se&bwnSm2pqBb$yBhl#~f7t3AD%7#ijLmW|5jq-(@ z%L?Z$&T6&J+V|uy3>CDM4A*InAb}+$k%9;rbyQG=g($5WDJIgiAM@}JJN^{8WO7x& z$gzMLR7j2={11M2YZj-c+@w$p=zX#6k5M473$z-x{e5iPtrNii3|wg)f2|43eUjej zXptjeU>mr&?r8EJaJd5vJ?WAmIg+2IP%HxPXY@^ZVDJ_QuDQLn_i_3FWT~s=8{ps& z7%Nfsy2rcwx_kTgOuN4yhM97&>RPEW00006VoOIv0RI600RN!9r;`8x010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=L`x1I4-2ugOUIM02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{01|>pL_t(|+U;H0j^sEFWF!*Xz5oBQQ?(c%_M!8TWu7{m zHP}sHrn)L^SqB*mQWP!n|Ih#Q2alh3=X)xDh6rih<9%6s&a&%EgM0ksp60iVXY~HR zp9}x%@n74}^WQk%XFiJ}0_yh}ZJFcfuUGCj$IatHzOFm8$EZK==JmeY)1DY>>EpK7 zbc6o79X?;J0EmeEe*D)r)N2LK6MXoaw{U@Aupd@15Jv4key1l;ROa%}Pj++AUrmYH zh18UR3Ib_@{6t#edGRe}VRP?)MC7}Neke%r=jZePM~$$cQ@Tmx<2QH{|M){QXfmN| z8e&;jD~o-Y6ipb8V{I-42=eq4r9Y-cw1m(3HxFavd6u0qyb$o~vH0u-fC>^Ezo9h- z-vnh06jz#e4qaG)PZmfH)o~4u^4%Cm#w*_s0eF4xh6ewBAb|!&&0~qTIW-`S0_wAo zFas{6vLT!>&DI-%A}xy`+Cqm6l%tuWCr=W`{CLkza5S~Ar^RmtK(lVY9)iH6z(N;! z0|MX1MI25MO?Xe_&i0rkdra4y*^A+s!RY!7pEB(Gizj*W#K+=)Lk`O5x_{5lzeMEU zbFfA0&rWmj?9B#Gctf*GdxxX_55eK^`RhUYT8{M+mb>$0Jf8eS0O2Jf!IW#vyq)f-~hpVQmCx^ly&nG-bvW*1K~2RF+H14>zQ}6Lq~?&n}aNIq7hg* z*|Nq|`>xqr8^knE^ldczr&tVHYuO(s6Q)4|J07^+r&x(Kr(YuS6#?AcAwf7RKqL4leW2P0c7DDlLMP|(u1q=qEFtpj0+ve>w(xWd3Vgye=pR~ykwZ`v3;6k$-y%79PMqzarWE#%< z;Lho~x3p(>6{&W^fTbfOpZ7Rc5EOJ2Gzt_+Yx5Zg=0xWJe`Fqw7k%KF28^^W;x8u( z6@@Ats0JHN3O7sMePlM`ClYT0DK6{l2{;h2*R1i~|38S1P|^B6GVHUMgfDg{yFd`x za7z#*oxKLlcK#N@eGtnX9RFN|j+yW1c;%wR-qyw^|CVM~&u9XM8F~Hvc9KF8JPRjd zIJfZ-i6M?{ZvBKXt)xfnHdMBZ#$|AA{)y+^d|2WF8;3#TkFl8>o_Cb*JS)mzHW{Zt z%GM-bL!l!;JR=BDQT=Lk6A7i6t1T&qSAi7w+h=rou=fbGy=yZoS0XX3<_uFlAl_KiGg8VKimAV$PK?0i7&<{l>=&tX(90# z(vSL3=k7UK#yf1+5Ijcaz#)MxiX!3H=cS~y)+4LovRHT8EVPH3Rx(* z2^^JSgc!-Byl@y!x`*R@$xY49V|D zc{dad0T}l-0g43*KDdIb4)5(?gUk9p-+L*_I!2lx^PY-jGtnPr`96K-C4WgtKEnCl( z#4$^bnRU*0j1kEp)7V%oDZyTOS&TFlT;?PgF=CWz-~&n^ zsON$RSmvZ2MNcSbjXa!0i?|bMXo2<7XrdZrWzde(XJ3vN+Ny( zIUb`|FTLq^Qk@6sPt;uko4m9&JIKU>RN*Q_U?R%$%wdHnTmGsEV4PCi3&W+zh>1DF z4slzq3d0;A;%X)WFd%>1GJ#B)gtAbJi>(lipcfdIV zXr7V0RqVx~0oa?`oYlq!kbAu!U)&@O%cdDhs}s&BgPRJ>nj|o)QuXJg7=^P7hvjTP z?$SPIjvGXskv)aO(;?~GkJgsDM!}56N8Jbc?wn}otKE;D(BLw;Nq32fdr?6 zBU0FDKDYCJ4mEK>OnxCqU_7S6B(|6&umVQbnSsx%i%jmL%{~Nkj~zH16_vL0%J=mo zFcr}D0|3iyWc^$gHz_RK8JQ6(q`nFE#elr>Y9z2D2=MKGTqaF|H{9ga6ct=5r(xz7 zX`i&)Ih_L;<oVhpTl`GcgFlaY$174JGxT;>jjojmUEBaFP)s-d zEEmcvk;6#}&5gsM-2>%-EQgl-obocc!nv9SST1_ZbH>8~5h^CYW0f?3y_!4t^N<1KW`oXQVeQ~3aTA&^=%~65Zk18p`9uoHq_qJs`J3i z=?ODHbW8Tu$pIeNB0gloaG`YV1Lt`OiZ%_(=%wdrAidvoiUYv)uxQ#5TLQ6JseX7s zrzT501vLu527`r$yC=5;OT>`q+C%$Ct!{qluv3<3L4KMVwvrTX-QOI(W|8y26W~91 zX>&`*p8!8F`813uhFdHehW`&99gYo^Lh#Ae3PAxjowOjiq@nfQ#`E>k$LX z%}*gA>!NB2#(HJ9?9+7u^Wx0Cb6cZPIUf>pqV-eEltuO!5c{(i0Nt*)t{;D%v1j_L zY-MYt>^>HYZA~zv)G+bSA)ko8S19uEVnk*4X{tiVmI9sTq~#8%jNr(a?5dKwR}`Kg@hOG_zHQO-Rl)fh!2 z8ce6h0gi!%-tXCXW||9>kHeBxFH}=M47A}jxCq_8V-%2nLI{MktfEEJS4ij_92Ir?OIB3sJ)3w<%kBt0((+Aa4Ehh#;=Ed|za3yp*yNHE^*cvD&GA`#0RaKjs5aHMK{b3r#VKQ^vWu zFP*pGPr-#%`W;64qIJ0$K!k$Cxs$YP%7%Bmy*4ntV!6l*c8OD=sEGC+GP_hPlYs`7 z#N`SrS1Q=Yxl^0SmH_5F8jKZAKPa_!aP*dJaKN8~>x0T~qjKowdtgSnETdhdSWKE3PSm2sx&kQssz+VL-HlrAI z*>~(Fjlb|~@C6k^C(@Qxo<=8jR(hEF$eY32jCTkj6C0RcWvtVcv2rHGAq`b@SXOyD zLj=`qpd$zHJqo`#xdT^q%(!{giBdBc`y-OGL%bO}Jk;nSkas!CERvi2Tdm)|5@pSo9`>dExS^ z@No?#2(n%WLRnPe0B?7q-wGylSmDBHEKdx#0|A#@ws&*t^$2SND1AKK5@RSG&;bH=rEm8<)?3Ou!wEpw?Ryiy*#w}QOj+j~il_2$rIt~uSe7LKXE z@+!RHlc`uJI1~E{*s<9F zg^h*%v(s`>!y4}mVrr#O^>rM2h4hSieCyQ6m;Yi%Cd#_NqnX2{K_PWWO z;iI2#5q6%S6EB)bZB6dV^U;mfd(Sq6@+BhQfg-u}Y903y;Gdttz1l<|q1j&lDn0- zt^c0To`1)Sm>~)Kmf38%1Eb9;9nsndLZry>;$|HgpuwJv7&H(0*3m(Zex z_SG1K!UZyJ-hq7b{G2G}Apv)a%*|LZn`aJSY4+EP?MF*qE6O<+pVL8opnNUVaHmK< zIh1t|CvlPXukxTm9&!&tyc*j_0RNFYXt_m^tJI%#rL#^}`-(PEGdXXs0_wS^Hm=Tq zqqMaZ7(@{pVPZ>CbuMtUXx{w6YT&N8de7ej~W`P7s5Gsyb$V!wgDwVFoF3m~_ zc3YF^PUl1CqC_zIbJV*nInP6<>0-CYUt zWTD=hXvhYW!L_EyTQqEFTbY+pTgPmF-!3js5zj;3>)nG|BNA3M-oeHPlr3>M0mFPJ wl3Q!hSM}9e!(~o(*s*omwdey>&6j`w7d=J+E`W$^lmGw#07*qoM6N<$f^ diff --git a/Templates/BaseGame/game/data/UI/images/textEditFrame_image.asset.taml b/Templates/BaseGame/game/data/UI/images/textEditFrame_image.asset.taml new file mode 100644 index 000000000..86a29b170 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/images/textEditFrame_image.asset.taml @@ -0,0 +1,3 @@ + diff --git a/Templates/BaseGame/game/data/UI/scripts/guiTreeViewCtrl.tscript b/Templates/BaseGame/game/data/UI/scripts/guiTreeViewCtrl.tscript deleted file mode 100644 index bc952dbca..000000000 --- a/Templates/BaseGame/game/data/UI/scripts/guiTreeViewCtrl.tscript +++ /dev/null @@ -1,50 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -function GuiTreeViewCtrl::onDefineIcons( %this ) -{ - %icons = "core/art/gui/images/treeview/default:" @ - "core/art/gui/images/treeview/simgroup:" @ - "core/art/gui/images/treeview/simgroup_closed:" @ - "core/art/gui/images/treeview/simgroup_selected:" @ - "core/art/gui/images/treeview/simgroup_selected_closed:" @ - "core/art/gui/images/treeview/hidden:" @ - "core/art/gui/images/treeview/shll_icon_passworded_hi:" @ - "core/art/gui/images/treeview/shll_icon_passworded:" @ - "core/art/gui/images/treeview/default"; - - %this.buildIconTable(%icons); -} - -function GuiTreeViewCtrl::handleRenameObject( %this, %name, %obj ) -{ - %inspector = GuiInspector::findByObject( %obj ); - - if( isObject( %inspector ) ) - { - %field = ( %this.renameInternal ) ? "internalName" : "name"; - %inspector.setObjectField( %field, %name ); - return true; - } - - return false; -} diff --git a/Templates/BaseGame/game/data/UI/scripts/help.tscript b/Templates/BaseGame/game/data/UI/scripts/help.tscript deleted file mode 100644 index a305671af..000000000 --- a/Templates/BaseGame/game/data/UI/scripts/help.tscript +++ /dev/null @@ -1,90 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -function HelpDlg::onWake(%this) -{ - HelpFileList.entryCount = 0; - HelpFileList.clear(); - for(%file = findFirstFile("*.hfl"); %file !$= ""; %file = findNextFile("*.hfl")) - { - HelpFileList.fileName[HelpFileList.entryCount] = %file; - HelpFileList.addRow(HelpFileList.entryCount, fileBase(%file)); - HelpFileList.entryCount++; - } - HelpFileList.sortNumerical(0); - for(%i = 0; %i < HelpFileList.entryCount; %i++) - { - %rowId = HelpFileList.getRowId(%i); - %text = HelpFileList.getRowTextById(%rowId); - %text = %i + 1 @ ". " @ restWords(%text); - HelpFileList.setRowById(%rowId, %text); - } - HelpFileList.setSelectedRow(0); -} - -function HelpFileList::onSelect(%this, %row) -{ - %fo = new FileObject(); - %fo.openForRead(%this.fileName[%row]); - %text = ""; - while(!%fo.isEOF()) - %text = %text @ %fo.readLine() @ "\n"; - - %fo.delete(); - HelpText.setText(%text); -} - -function getHelp(%helpName) -{ - Canvas.pushDialog(HelpDlg); - if(%helpName !$= "") - { - %index = HelpFileList.findTextIndex(%helpName); - HelpFileList.setSelectedRow(%index); - } -} - -function contextHelp() -{ - for(%i = 0; %i < Canvas.getCount(); %i++) - { - if(Canvas.getObject(%i).getName() $= HelpDlg) - { - Canvas.popDialog(HelpDlg); - return; - } - } - %content = Canvas.getContent(); - %helpPage = %content.getHelpPage(); - getHelp(%helpPage); -} - -function GuiControl::getHelpPage(%this) -{ - return %this.helpPage; -} - -function GuiMLTextCtrl::onURL(%this, %url) -{ - gotoWebPage( %url ); -} - diff --git a/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript b/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript deleted file mode 100644 index 36f96568f..000000000 --- a/Templates/BaseGame/game/data/UI/scripts/menuInputHandling.tscript +++ /dev/null @@ -1,729 +0,0 @@ -//============================================================================== -// 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 -*/ - -//============================================================================== -/// Summary: -/// 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 -/// -/// \param %device (string) The name of the device the input event is coming fromt -/// \param %action (string) The specific key/input action -/// \param %state (bool) The down/up state of the event sent -function UIMenuButtonList::onInputEvent(%this, %device, %action, %state) -{ - if(%state) - $activeMenuButtonContainer.processInputs(%device, %action); -} - -//============================================================================== -/// Summary: -/// 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 -/// -/// \param %device (string) The name of the device the input event is coming fromt -/// \param %action (string) The specific key/input action -/// \param %axisVal (float) The float value of the axis event -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); -} - -//============================================================================== -/// Summary: -/// 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. -function MenuInputButton::set(%this, %gamepadButton, %keyboardButton, %text, %command) -{ - %this.setHidden(false); - - %set = (! ((%text $= "") && (%command $= ""))); - - %this.gamepadButton = %gamepadButton; - %this.keyboardButton = %keyboardButton; - - if(%gamepadButton $= "") - %this.gamepadValid = false; - else - %this.gamepadValid = true; - - if(%keyboardButton $= "") - %this.kbmValid = false; - else - %this.kbmValid = true; - - if((!%this.kbmValid && $activeControllerType !$= "gamepad") || - (!%this.gamepadValid && $activeControllerType $= "gamepad")) - %set = false; - - %this.setText(%text); - %this.Command = %command; - - %this.refresh(); -} - -//============================================================================== -/// Summary: -/// Disables the MenuInputButton, marking it as not to consume inputs or display -function MenuInputButton::disable(%this) -{ - %this.setText(""); - %this.Command = ""; - %this.setActive(false); - %this.setVisible(false); -} - -//============================================================================== -/// Summary: -/// Refreshes the specific button, updating it's visbility status and the displayed input image -function MenuInputButton::refresh(%this) -{ - %set = (! ((%this.text $= "") && (%this.command $= ""))); - - //Do a check so if a MenuInput is selectively bound and we're not using the - //matched input type, then we skip - if((!%this.kbmValid && $activeControllerType !$= "gamepad") || - (!%this.gamepadValid && $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; -} - -//============================================================================== -/// Summary: -/// 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(); - } -} - -//============================================================================== -/// Summary: -/// 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(); -} - -//============================================================================== -/// Summary: -/// 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"; -} - - //============================================================================== -/// Summary: -/// 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. -/// -/// \param %device (string) The device that is causing the input event -/// \param %action (string) The name of the input action -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); - } - } - } -} - -//============================================================================== -/// Summary: -/// 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 -/// -/// \param %device (string) The name of the device the input event is coming fromt -/// \param %action (string) The specific key/input action -/// \param %axisVal (float) The float value of the axis event -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 -//============================================================================== -//============================================================================== -/// Summary: -/// 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 -/// -/// \param %device (string) The name of the device the input event is coming fromt -/// \param %action (string) The specific key/input action -/// \param %axisVal (float) The float value of the axis event -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(); - } - } -} - -//============================================================================== -/// Summary: -/// 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 -/// -/// \param %device (string) The name of the device the input event is coming fromt -/// \param %action (string) The specific key/input action -/// \param %state (bool) The down/up state of the event sent -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 -//============================================================================== -//============================================================================== -/// Summary: -/// Is the GUIContainer with this MenuList namespace the 'active' menulist as far -/// as UI interfaces is concerned? -function MenuList::isActiveMenuList(%this) -{ - if($activeMenuList == %this) - return true; - - return false; -} - -//============================================================================== -/// Summary: -/// Sets the GUIContainer with this MenuList namespace as the active menulist. -/// This means that any input events caught in MenuInputHandlers is directed at -/// this menu list to navigate it -/// -/// \param %startPosition (Point2F) The X and Y starting positions of the selection for this menuList -/// \param %menuMode (string) Indicates the mode/type of menuList, allowing for special behaviors depending on type -function MenuList::setAsActiveMenuList(%this, %startPosition, %menuMode) -{ - if(%startPosition $= "") - %startPosition = "0 0"; - - if(%menuMode $= "") - %menuMode = "Menu"; - - $activeMenuList = %this; - $activeMenuList.hidden = false; - $activeMenuList.ListPosition = %startPosition; - $activeMenuListMode = %menuMode; - - %this.refresh(); -} - -//============================================================================== -/// Summary: -/// Activates the currently highlighted child object -function MenuList::activate(%this) -{ - //check for a highlighted element - if($activeMenuList.ListPosition.y > -1 && $activeMenuList.ListPosition < $activeMenuList.getCount()) - { - %btn = $activeMenuList.getObject($activeMenuList.ListPosition.y); - %btn.performClick(); - } -} - -//============================================================================== -/// Summary: -/// refreshes the menuList, updating children highlight status and if there is -/// a button pointer control defined on our list, we update it's position as -/// needed -function MenuList::refresh(%this) -{ - %selectedObject = -1; - for(%i=0; %i < $activeMenuList.getCount(); %i++) - { - %btn = $activeMenuList.getObject(%i); - - %isSelected = %i == $activeMenuList.ListPosition.y; - - %btn.setHighlighted(%isSelected); - - if(%isSelected) - %selectedObject = %i; - } - - if(isObject(%this.buttonPointerCtrl)) - { - if(%selectedObject != -1) - { - %this.buttonPointerCtrl.setHidden(false); - - %buttonCenter = $activeMenuList.getObject(%selectedObject).getGlobalCenter(); - - if(%this.centerButtonPointerCtrl) - { - %this.buttonPointerCtrl.setCenter(%buttonCenter.x, %buttonCenter.y); - } - else - { - //if we're not centering, then left-justify - %this.buttonPointerCtrl.setCenter(%buttonCenter.x - $activeMenuList.getObject(%selectedObject).extent.x / 2, %buttonCenter.y); - } - } - else - { - %this.buttonPointerCtrl.setHidden(true); - } - } - - if($activeMenuList.isMethod("onNavigate")) - $activeMenuList.onNavigate($activeMenuList.ListPosition.y); - - %parent = $activeMenuList.getParent(); - if(%parent.getClassName() $= "GuiScrollCtrl") - { - %parent.scrollToObject(%selectedObject); - } -} - -//============================================================================== -/// Summary: -/// Selects the next 'up' child item in the menuList. If the current is the topmost -/// then nothing happens -function MenuList::navigateUp(%this) -{ - $activeMenuList.ListPosition.y -= 1; - if($activeMenuList.ListPosition.y < 0) - $activeMenuList.ListPosition.y = 0; - - %this.refresh(); -} - -//============================================================================== -/// Summary: -/// Selects the next 'down' child item in the menuList. If the current is the bottommost -/// then nothing happens -function MenuList::navigateDown(%this) -{ - $activeMenuList.ListPosition.y += 1; - if($activeMenuList.ListPosition.y >= $activeMenuList.getCount()) - $activeMenuList.ListPosition.y = $activeMenuList.getCount()-1; - - %this.refresh(); -} - -//============================================================================== -/// Summary: -/// Selects the next 'left' child item in the menuList. If the current item is the leftmost -/// then nothing happens -function MenuList::navigateLeft() -{ - //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($activeMenuList.ListPosition.y); - if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled()) - { - %mode = %btn.getMode(); - if(%mode == 0) //options list - { - %optionId = %btn.getCurrentOptionIndex() - 1; - %btn.selectOptionByIndex(%optionId); - %btn.onChange(); - } - else if(%mode == 1) //slider - { - %value = %btn.getValue(); - %adjustedValue = %value - %btn.getIncrement(); - %minValue = %btn.getRange().x; - if(%adjustedValue < %minValue) - %adjustedValue = %minValue; - - %btn.setValue(%adjustedValue); - %btn.onChange(); - } - } -} - -//============================================================================== -/// Summary: -/// Selects the next 'right' child item in the menuList. If the current item is the rightmost -/// then nothing happens -function MenuList::navigateRight() -{ - %btn = $activeMenuList.getObject($activeMenuList.ListPosition.y); - if(%btn.getClassName() $= "GuiGameSettingsCtrl" && %btn.isEnabled()) - { - %mode = %btn.getMode(); - if(%mode == 0) //options list - { - %optionId = %btn.getCurrentOptionIndex() + 1; - %btn.selectOptionByIndex(%optionId); - %btn.onChange(); - } - else if(%mode == 1) //slider - { - %value = %btn.getValue(); - %adjustedValue = %value + %btn.getIncrement(); - %maxValue = %btn.getRange().y; - if(%adjustedValue > %maxValue) - %adjustedValue = %maxValue; - - %btn.setValue(%adjustedValue); - %btn.onChange(); - } - } -} - -//============================================================================== -/// Summary: -/// Gets the current vertical positionally selected child object -function MenuList::getActiveRow(%this) -{ - return $activeMenuList.ListPosition.y; -} - -//============================================================================== -/// Summary: -/// Called from the engine when a GUIButtonBase-derived class with MenuListButton namespace class -/// has its highlighting status changed. Allows us to react to this change of state and trigger refreshse -/// or other events to keep the navigation tracking up to date -/// -/// \param %state (bool) The on/off state of the button being highlighted -function MenuListButton::onHighlighted(%this, %state) -{ - echo("MenuListButton::onHighlighted() - " @ %this.internalName @ " was " @ %state @ " highlighted"); - %parentContainer = %this.getParent(); - if(%parentContainer.class $= "MenuList" || %parentContainer.superClass $= "MenuList") - { - if(isObject(%parentContainer.buttonPointerCtrl)) - { - if(%state) - { - %parentContainer.buttonPointerCtrl.setHidden(false); - - %buttonCenter = %this.getGlobalCenter(); - echo(" - button center:" @ %buttonCenter); - - if(%parentContainer.centerButtonPointerCtrl) - { - %parentContainer.buttonPointerCtrl.setGlobalCenter(%buttonCenter.x, %buttonCenter.y); - } - else - { - //if we're not centering, then left-justify - %parentContainer.buttonPointerCtrl.setGlobalCenter(%buttonCenter.x - %this.extent.x / 2, %buttonCenter.y); - } - echo(" - pointer position:" @ %parentContainer.buttonPointerCtrl.getPosition()); - } - /*else - { - %parentContainer.buttonPointerCtrl.setHidden(true); - }*/ - } - } -} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript b/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript deleted file mode 100644 index 20ff05ff7..000000000 --- a/Templates/BaseGame/game/data/UI/scripts/menuNavigation.tscript +++ /dev/null @@ -1,308 +0,0 @@ -//============================================================================== -/// Summary: -/// This function sets the root page for the navigation stack. The root page is 'below' -/// all other normal pages and cannot be popped like a normal page. -/// When we set a new root page, we first check if we have an existing root page. -/// If we do, we run the usual canClose() then onClose() function pair, then we -/// set it and call the onOpen() for the new root page. -/// -/// \param %rootPage (guiControl) The new guiControl that is being set as the root page of the navigation stack -function UINavigation::setRootPage(%this, %rootPage) -{ - if(!isObject(%this.pageStack)) - { - %this.pageStack = new ArrayObject(); - } - - if(%this.rootPage $= %rootPage) - return; - - if(isObject(%this.rootPage)) - { - %canClose = true; - if(%this.rootPage.isMethod("canClose")) - %canClose = %this.rootPage.call("canClose"); - - if(!%canClose) - return; //if we're not allowed to close, just bail out wholesale because clearly - //something is blocking changes to pages - - %this.remove(%this.rootPage); - if(%this.rootPage.isMethod("onClose")) - %this.rootPage.call("onClose"); - - %this.rootPage.navigation = ""; - } - - %this.rootPage = %rootPage; - - %this.add(%rootPage); - if(%this.resizePages) - { - %rootPage.resize(%this.position.x, %this.position.y, - %this.extent.x, %this.extent.y); - } - %rootPage.navigation = %this; - - if(%rootPage.isMethod("onOpen")) - %rootPage.call("onOpen"); -} - -//============================================================================== -/// Summary: -/// This function pushes a page onto the given UINavigation-classed GUIContainer's stack -/// The order of operations is thus: -/// 1) check to see if the new page being pushed says it can open via the canOpen() function. -/// If this method is not defined, it defaults to true, as there's no impediment to continuing -/// If this check returns false, the pushPage event cancels. -/// 2) check to see if the current page on the stack says it can close. Similar to -/// the canOpen() check on the new page, we default to true -/// If this check returns false, the pushPage event cancels. -/// 3) Call - if defined - onClose() on the current top page of the stack -/// 4) Add the new page onto the stack -/// 5) Call - if defined - onOpen() on the new page -/// 6) Finally, if we defined a callback, call that. -/// With this all run, the previous top page has done any cleanup work it needed to -/// and the new top page has been opened successfully. -/// -/// \param %newPage (guiControl) The new guiControl that is being added onto the page stack -/// \param %callback[optional]: (Evaluable string) A evalable statement to invoke when the push has been completed -function UINavigation::pushPage(%this, %newPage, %callback) -{ - if(!isObject(%this.pageStack)) - { - %this.pageStack = new ArrayObject(); - } - - //don't re-add pages - if(%this.getPageCount() != 0 && - %this.pageStack.getIndexFromKey(%newPage) != -1) - return; - - %canChange = true; - if(%newPage.isMethod("canOpen")) - %canChange = %newPage.call("canOpen"); - - if(!%canChange) - return; - - %currentPage = %this.getCurrentPage(); - if(isObject(%currentPage)) - { - if(%currentPage.isMethod("canClose")) - %canChange = %currentPage.call("canClose"); - - if(!%canChange) - return; - - if(%currentPage.isMethod("onClose")) - %currentPage.call("onClose"); - } - - %this.pageStack.push_back(%newPage); - %this.add(%newPage); - if(%this.resizePages) - { - %newPage.resize(%this.position.x, %this.position.y, - %this.extent.x, %this.extent.y); - } - - if(%newPage.isMethod("onOpen")) - %newPage.call("onOpen"); - - %newPage.navigation = %this; - - if(%callback !$= "") - eval(%callback); -} - -//============================================================================== -/// Summary: -/// This function pops the topmost page off the given UINavigation-classed GUIContainer's stack -/// The order of operations is thus: -/// 1) check to see if the top page being popped says it can close via the canClose() function. -/// If this method is not defined, it defaults to true, as there's no impediment to continuing -/// If this check returns false, the popPage event cancels. -/// 2) check to see if the previous page on the stack says it can open. Similar to -/// the canClose() check on the new page, we default to true -/// If this check returns false, the popPage event cancels. -/// 3) Call - if defined - onClose() on the current top page of the stack -/// 4) Remove the top page -/// 5) Call - if defined - onOpen() on the now topmost page -/// 6) Finally, if we defined a callback, call that. -/// With this all run, the previous top page has done any cleanup work it needed to -/// and the new top page has been opened successfully. -/// -/// \param %callback[optional] (Evaluable string) A evalable statement to invoke when the pop has been completed -function UINavigation::popPage(%this, %callback) -{ - if(%this.pageStack.count() == 0) - return; - - %currentPage = %this.getCurrentPage(); - if(isObject(%currentPage)) - { - %canChange = true; - if(%currentPage.isMethod("canClose")) - %canChange = %currentPage.call("canClose"); - - if(!%canChange) - return; - } - - %prevPage = %this.getPreviousPage(); - if(isObject(%prevPage)) - { - %canChange = true; - if(%prevPage.isMethod("canOpen")) - %canChange = %prevPage.call("canOpen"); - - if(!%canChange) - return; - } - - if(isObject(%currentPage)) - { - if(%currentPage.isMethod("onClose")) - { - %currentPage.call("onClose"); - } - - %this.pageStack.pop_back(); - %this.remove(%currentPage); - - %currentPage.navigation = ""; - } - - %newTopPage = %this.getCurrentPage(); - if(isObject(%newTopPage)) - { - if(%newTopPage.isMethod("onOpen")) - %newTopPage.call("onOpen"); - } - - if(%callback !$= "") - eval(%callback); -} - -//============================================================================== -/// Summary: -/// In order tops the topmost page in a loop until it has closed the entire stack, -/// leaving only the root page -/// -/// \param %callback[optional] (Evaluable String) A evalable statement to invoke when the pop has been completed -function UINavigation::popToRoot(%this, %callback) -{ - %pageChanged = false; - while(%this.getPageCount() != 0) - { - %currentPage = %this.getCurrentPage(); - if(isObject(%currentPage)) - { - if(%currentPage.isMethod("canClose")) - %canChange = %currentPage.call("canClose"); - - if(!%canChange) - return; - } - - %prevPage = %this.getPreviousPage(); - if(isObject(%prevPage)) - { - if(%prevPage.isMethod("canOpen")) - %canChange = %prevPage.call("canOpen"); - - if(!%canChange) - return; - } - - if(isObject(%currentPage)) - { - if(%currentPage.isMethod("onClose")) - { - %currentPage.call("onClose"); - } - - %this.pageStack.pop_back(); - %this.remove(%currentPage); - - %currentPage.navigation = ""; - } - - %newTopPage = %this.getCurrentPage(); - if(%newTopPage.isMethod("onOpen")) - %newTopPage.call("onOpen"); - - %pageChanged = true; - } - - if(%pageChanged && %callback !$= "") - eval(%callback); -} - -//============================================================================== -/// Summary: -/// Gets the current, topmost page on the stack. If no non-root pages are on the stack -/// the root page is returned -function UINavigation::getCurrentPage(%this) -{ - if(isObject(%this.pageStack) && %this.pageStack.count() != 0) - { - return %this.pageStack.getKey(%this.pageStack.count()-1); - } - else - { - if(isObject(%this.rootPage)) - return %this.rootPage; - } - - return 0; -} - -//============================================================================== -/// Summary: -/// Gets the page just under the topmost page in the stack. If there is no previous page -/// then the root page is returned -function UINavigation::getPreviousPage(%this) -{ - if(isObject(%this.pageStack) && %this.pageStack.count() > 1) - { - return %this.pageStack.getKey(%this.pageStack.count()-2); - } - else - { - if(isObject(%this.rootPage)) - return %this.rootPage; - } - - return 0; -} - -//============================================================================== -/// Summary: -/// Gets the number of pages on the stack. -function UINavigation::getPageCount(%this) -{ - %count = 0; - if(isObject(%this.pageStack)) - %count = %this.pageStack.count(); - - if(isObject(%this.rootPage)) - %count++; - - return %count; -} - -//============================================================================== -/// Summary: -/// Force the page to reprocess to ensure it's status is up to date -function UINavigation::refreshPage(%this) -{ - %page = %this.getCurrentPage(); - if(!isObject(%page)) - return; - - if(%page.isMethod("onOpen")) - %page.call("onOpen"); -} - diff --git a/Templates/BaseGame/game/data/UI/scripts/messageBoxes.tscript b/Templates/BaseGame/game/data/UI/scripts/messageBoxes.tscript deleted file mode 100644 index f1c3db40e..000000000 --- a/Templates/BaseGame/game/data/UI/scripts/messageBoxes.tscript +++ /dev/null @@ -1,341 +0,0 @@ -//----------------------------------------------------------------------------- -// 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. -//----------------------------------------------------------------------------- - -// -------------------------------------------------------------------- -// Message Sound -// -------------------------------------------------------------------- -/*new SFXDescription(MessageBoxAudioDescription) -{ - volume = 1.0; - isLooping = false; - is3D = false; - channel = $GuiAudioType; -}; - -new SFXProfile(messageBoxBeep) -{ - filename = "./messageBoxSound"; - description = MessageBoxAudioDescription; - preload = true; -};*/ - -//--------------------------------------------------------------------------------------------- -// messageCallback -// Calls a callback passed to a message box. -//--------------------------------------------------------------------------------------------- -function messageCallback(%dlg, %callback) -{ - Canvas.popDialog(%dlg); - eval(%callback); -} - -//--------------------------------------------------------------------------------------------- -// MBSetText -// Sets the text of a message box and resizes it to accomodate the new string. -//--------------------------------------------------------------------------------------------- -function MBSetText(%text, %frame, %msg) -{ - // Get the extent of the text box. - %ext = %text.getExtent(); - // Set the text in the center of the text box. - %text.setText("" @ %msg); - // Force the textbox to resize itself vertically. - %text.forceReflow(); - // Grab the new extent of the text box. - %newExtent = %text.getExtent(); - - // Get the vertical change in extent. - %deltaY = getWord(%newExtent, 1) - getWord(%ext, 1); - - // Resize the window housing the text box. - %windowPos = %frame.getPosition(); - %windowExt = %frame.getExtent(); - %frame.resize(getWord(%windowPos, 0), getWord(%windowPos, 1) - (%deltaY / 2), - getWord(%windowExt, 0), getWord(%windowExt, 1) + %deltaY); - - %frame.canMove = "0"; - //%frame.canClose = "0"; - %frame.resizeWidth = "0"; - %frame.resizeHeight = "0"; - %frame.canMinimize = "0"; - %frame.canMaximize = "0"; - - //sfxPlayOnce( messageBoxBeep ); -} - -function MessageBoxCtrl::onWake(%this) -{ -} - -//--------------------------------------------------------------------------------------------- -// Various message box display functions. Each one takes a window title, a message, and a -// callback for each button. -//--------------------------------------------------------------------------------------------- - -//MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\""); -function MessageBoxOK(%title, %message, %callback) -{ - Canvas.pushDialog(MessageBoxDlg); - MessageBoxTitleText.text = %title; - - MessageBoxOCButtonHolder.hidden = true; - MessageBoxYNCButtonHolder.hidden = true; - MessageBoxOKButtonHolder.hidden = false; - - MessageBoxOKButtonHolder-->OKButton.set("btn_a", "Return", "OK", "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);"); - - MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer; - MessageBoxOKButtonHolder.setActive(); - - MBSetText(MessageBoxText, MessageBoxCtrl, %message); - MessageBoxDlg.callback = %callback; -} - -function MessageBoxOKDlg::onSleep( %this ) -{ - %this.callback = ""; - MessageBoxCtrl.originalMenuInputContainer.setActive(); -} - -function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback, %okLabelOverride, %cancelLabelOverride) -{ - Canvas.pushDialog(MessageBoxDlg); - MessageBoxTitleText.text = %title; - - MessageBoxOCButtonHolder.hidden = false; - MessageBoxYNCButtonHolder.hidden = true; - MessageBoxOKButtonHolder.hidden = true; - - if(%okLabelOverride $= "") - %okLabel = "OK"; - else - %okLabel = %okLabelOverride; - - if(%cancelLabelOverride $= "") - %cancelLabel = "Cancel"; - else - %cancelLabel = %cancelLabelOverride; - - MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", %okLabel, "MessageCallback(MessageBoxDlg,MessageBoxDlg.callback);"); - MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", %cancelLabel, "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);"); - - MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer; - MessageBoxOCButtonHolder.setActive(); - - MBSetText(MessageBoxText, MessageBoxCtrl, %message); - MessageBoxDlg.callback = %callback; - MessageBoxDlg.cancelCallback = %cancelCallback; -} - -function MessageBoxOKCancelDlg::onSleep( %this ) -{ - %this.callback = ""; - MessageBoxCtrl.originalMenuInputContainer.setActive(); -} - -function MessageBoxOKCancelDetails(%title, %message, %details, %callback, %cancelCallback) -{ - if(%details $= "") - { - MBOKCancelDetailsButton.setVisible(false); - } - - MBOKCancelDetailsScroll.setVisible(false); - - MBOKCancelDetailsFrame.setText( %title ); - - Canvas.pushDialog(MessageBoxOKCancelDetailsDlg); - MBSetText(MBOKCancelDetailsText, MBOKCancelDetailsFrame, %message); - MBOKCancelDetailsInfoText.setText(%details); - - %textExtent = MBOKCancelDetailsText.getExtent(); - %textExtentY = getWord(%textExtent, 1); - %textPos = MBOKCancelDetailsText.getPosition(); - %textPosY = getWord(%textPos, 1); - - %extentY = %textPosY + %textExtentY + 65; - - MBOKCancelDetailsInfoText.setExtent(285, 128); - - MBOKCancelDetailsFrame.setExtent(300, %extentY); - - MessageBoxOKCancelDetailsDlg.callback = %callback; - MessageBoxOKCancelDetailsDlg.cancelCallback = %cancelCallback; - - MBOKCancelDetailsFrame.defaultExtent = MBOKCancelDetailsFrame.getExtent(); -} - -function MBOKCancelDetailsToggleInfoFrame() -{ - if(!MBOKCancelDetailsScroll.isVisible()) - { - MBOKCancelDetailsScroll.setVisible(true); - MBOKCancelDetailsText.forceReflow(); - %textExtent = MBOKCancelDetailsText.getExtent(); - %textExtentY = getWord(%textExtent, 1); - %textPos = MBOKCancelDetailsText.getPosition(); - %textPosY = getWord(%textPos, 1); - - %verticalStretch = %textExtentY; - - if((%verticalStretch > 260) || (%verticalStretch < 0)) - %verticalStretch = 260; - - %extent = MBOKCancelDetailsFrame.defaultExtent; - %height = getWord(%extent, 1); - - %posY = %textPosY + %textExtentY + 10; - %posX = getWord(MBOKCancelDetailsScroll.getPosition(), 0); - MBOKCancelDetailsScroll.setPosition(%posX, %posY); - MBOKCancelDetailsScroll.setExtent(getWord(MBOKCancelDetailsScroll.getExtent(), 0), %verticalStretch); - MBOKCancelDetailsFrame.setExtent(300, %height + %verticalStretch + 10); - } else - { - %extent = MBOKCancelDetailsFrame.defaultExtent; - %width = getWord(%extent, 0); - %height = getWord(%extent, 1); - MBOKCancelDetailsFrame.setExtent(%width, %height); - MBOKCancelDetailsScroll.setVisible(false); - } -} - -function MessageBoxOKCancelDetailsDlg::onSleep( %this ) -{ - %this.callback = ""; - MessageBoxCtrl.originalMenuInputContainer.setActive(); -} - -function MessageBoxYesNo(%title, %message, %yesCallback, %noCallback) -{ - Canvas.pushDialog(MessageBoxDlg); - MessageBoxTitleText.text = %title; - - MessageBoxOCButtonHolder.hidden = false; - MessageBoxYNCButtonHolder.hidden = true; - MessageBoxOKButtonHolder.hidden = true; - - MessageBoxOCButtonHolder-->OKButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);"); - MessageBoxOCButtonHolder-->CancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);"); - - MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer; - MessageBoxOCButtonHolder.setActive(); - - MBSetText(MessageBoxText, MessageBoxCtrl, %message); - MessageBoxDlg.yesCallBack = %yesCallback; - MessageBoxDlg.noCallback = %noCallback; -} - -function MessageBoxYesNoCancel(%title, %message, %yesCallback, %noCallback, %cancelCallback) -{ - Canvas.pushDialog(MessageBoxDlg); - MessageBoxTitleText.text = %title; - - MessageBoxOCButtonHolder.hidden = true; - MessageBoxYNCButtonHolder.hidden = false; - MessageBoxOKButtonHolder.hidden = true; - - MessageBoxYNCButtonHolder-->yesButton.set("btn_a", "Return", "Yes", "MessageCallback(MessageBoxDlg,MessageBoxDlg.yesCallBack);"); - MessageBoxYNCButtonHolder-->noButton.set("btn_x", "backspace", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.noCallback);"); - MessageBoxYNCButtonHolder-->cancelButton.set("btn_b", "Escape", "No", "MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback);"); - - MessageBoxCtrl.originalMenuInputContainer = $activeMenuButtonContainer; - MessageBoxYNCButtonHolder.setActive(); - - MBSetText(MessageBoxText, MessageBoxCtrl, %message); - MessageBoxDlg.yesCallBack = %yesCallback; - MessageBoxDlg.noCallback = %noCallback; - MessageBoxDlg.cancelCallback = %cancelCallback; -} - -function MessageBoxDlg::onSleep( %this ) -{ - %this.callback = ""; - %this.cancelCallback = ""; - %this.yesCallback = ""; - %this.noCallback = ""; - %this.cancelCallback = ""; - MessageBoxCtrl.originalMenuInputContainer.setActive(); -} - -//--------------------------------------------------------------------------------------------- -// MessagePopup -// Displays a message box with no buttons. Disappears after %delay milliseconds. -//--------------------------------------------------------------------------------------------- -function MessagePopup(%title, %message, %delay) -{ - Canvas.pushDialog(MessageBoxDlg); - MessageBoxTitleText.text = %title; - MBSetText(MessageBoxText, MessageBoxCtrl, %message); - - if (%delay !$= "") - schedule(%delay, 0, CloseMessagePopup); -} - -function CloseMessagePopup() -{ - Canvas.popDialog(MessageBoxDlg); -} - -//--------------------------------------------------------------------------------------------- -// IODropdown -// By passing in a simgroup or simset, the user will be able to choose a child of that group -// through a guiPopupMenuCtrl -//--------------------------------------------------------------------------------------------- - -function IODropdown(%title, %message, %simgroup, %callback, %cancelCallback) -{ - IODropdownFrame.text = %title; - Canvas.pushDialog(IODropdownDlg); - MBSetText(IODropdownText, IODropdownFrame, %message); - - if(isObject(%simgroup)) - { - for(%i = 0; %i < %simgroup.getCount(); %i++) - IODropdownMenu.add(%simgroup.getObject(%i).getName()); - - } - - IODropdownMenu.sort(); - IODropdownMenu.setFirstSelected(0); - - IODropdownDlg.callback = %callback; - IODropdownDlg.cancelCallback = %cancelCallback; -} - -function IODropdownDlg::onSleep( %this ) -{ - %this.callback = ""; - %this.cancelCallback = ""; - IODropdownMenu.clear(); -} - -//The # in the function passed replaced with the output -//of the preset menu. -function IOCallback(%dlg, %callback) -{ - %id = IODropdownMenu.getSelected(); - %text = IODropdownMenu.getTextById(%id); - %callback = strreplace(%callback, "#", %text); - eval(%callback); - - Canvas.popDialog(%dlg); -} diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index 8a3e1fa9e..d8d2304d3 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -1,8 +1,10 @@ $TextMediumEmphasisColor = "200 200 200"; +$TextMediumEmphasisColorHL = "0 0 0"; $TextHighEmphasisColor = "224 224 224"; +$TextHighEmphasisColorHL = "0 0 0"; $TextDisabledColor = "108 108 108"; -new GuiGameListMenuProfile(DefaultListMenuProfile) +singleton GuiGameListMenuProfile(DefaultListMenuProfile) { fontType = "Arial Bold"; fontSize = 20; @@ -26,12 +28,12 @@ new GuiGameListMenuProfile(DefaultListMenuProfile) canKeyFocus = true; }; -new GuiControlProfile(GamepadDefaultProfile) +singleton GuiControlProfile(GamepadDefaultProfile) { border = 0; }; -new GuiControlProfile(GamepadButtonTextLeft) +singleton GuiControlProfile(GamepadButtonTextLeft) { fontType = "Arial Bold"; fontSize = 20; @@ -39,20 +41,26 @@ new GuiControlProfile(GamepadButtonTextLeft) justify = "left"; }; -new GuiControlProfile(GamepadButtonTextRight : GamepadButtonTextLeft) +singleton GuiControlProfile(GamepadButtonTextRight : GamepadButtonTextLeft) { justify = "right"; }; -new GuiControlProfile(MenuHeaderText) +singleton GuiControlProfile(MenuHeaderText) { fontType = "Arial Bold"; fontSize = 30; fontColor = $TextHighEmphasisColor; justify = "left"; + modal = false; }; -new GuiControlProfile(MenuHeaderTextCenter) +singleton GuiControlProfile(MenuHeaderTextHighlighted : MenuHeaderText) +{ + fontColor = $TextHighEmphasisColorHL; +}; + +singleton GuiControlProfile(MenuHeaderTextCenter) { fontType = "Arial Bold"; fontSize = 30; @@ -60,15 +68,26 @@ new GuiControlProfile(MenuHeaderTextCenter) justify = "center"; }; -new GuiControlProfile(MenuSubHeaderText) +singleton GuiControlProfile(MenuSubHeaderText) { fontType = "Arial Bold"; fontSize = 20; fontColor = $TextMediumEmphasisColor; justify = "left"; + modal = false; }; -new GuiControlProfile(MenuMLSubHeaderText) +singleton GuiControlProfile(MenuSubHeaderTextHighlighted : MenuSubHeaderText) +{ + fontColor = $TextMediumEmphasisColorHL; +}; + +singleton GuiControlProfile(MenuSubHeaderCenteredText : MenuSubHeaderText) +{ + justify = "center"; +}; + +singleton GuiControlProfile(MenuMLSubHeaderText) { fontType = "Arial Bold"; fontSize = 20; @@ -76,15 +95,21 @@ new GuiControlProfile(MenuMLSubHeaderText) justify = "left"; autoSizeWidth = true; autoSizeHeight = true; + modal = false; }; -new GuiControlProfile(MenuMLSubHeaderTextCenter : MenuMLSubHeaderText) +singleton GuiControlProfile(MenuMLSubHeaderTextCenter : MenuMLSubHeaderText) { justify = "center"; }; -if( !isObject( GuiMenuButtonProfile ) ) -new GuiControlProfile( GuiMenuButtonProfile ) +singleton GuiControlProfile( GuiMenuDefaultProfile ) +{ + opaque = false; + fillColor = "0 0 0 0"; +}; + +singleton GuiControlProfile( GuiMenuButtonProfile ) { opaque = true; border = false; @@ -115,8 +140,13 @@ new GuiControlProfile( GuiMenuButtonProfile ) fontColorLinkHL = "Magenta"; }; -if( !isObject( GuiHighlightMenuButtonProfile ) ) -new GuiControlProfile( GuiHighlightMenuButtonProfile ) +singleton GuiControlProfile( LevelPreviewButtonProfile : GuiMenuButtonProfile ) +{ + fontSize = 22; + justify = "Left"; +}; + +singleton GuiControlProfile( GuiHighlightMenuButtonProfile ) { opaque = true; border = false; @@ -134,8 +164,7 @@ new GuiControlProfile( GuiHighlightMenuButtonProfile ) category = "Core"; }; -if( !isObject( GuiBlankMenuButtonProfile ) ) -new GuiControlProfile( GuiBlankMenuButtonProfile ) +singleton GuiControlProfile( GuiBlankMenuButtonProfile ) { opaque = true; border = false; @@ -155,14 +184,12 @@ new GuiControlProfile( GuiBlankMenuButtonProfile ) category = "Core"; }; -if( !isObject( GuiJoinServerButtonProfile ) ) -new GuiControlProfile( GuiJoinServerButtonProfile : GuiMenuButtonProfile ) +singleton GuiControlProfile( GuiJoinServerButtonProfile : GuiMenuButtonProfile ) { justify = "left"; }; -if( !isObject( GuiMenuTextProfile ) ) -new GuiControlProfile( GuiMenuTextProfile ) +singleton GuiControlProfile( GuiMenuTextProfile ) { opaque = true; border = false; @@ -173,27 +200,30 @@ new GuiControlProfile( GuiMenuTextProfile ) fontColorNA = "125 125 125"; fixedExtent = false; justify = "center"; - category = "Core"; + category = "BaseUI"; + modal = false; }; -if( !isObject( GuiSolidDefaultProfile ) ) -new GuiControlProfile (GuiSolidDefaultProfile) +singleton GuiControlProfile( GuiMenuTextProfileHighlighted : GuiMenuTextProfile ) +{ + fontColor = "0 0 0"; +}; + +singleton GuiControlProfile (GuiSolidDefaultProfile) { opaque = true; border = true; category = "Core"; }; -if( !isObject( GuiTransparentProfile ) ) -new GuiControlProfile (GuiTransparentProfile) +singleton GuiControlProfile (GuiTransparentProfile) { opaque = false; border = false; category = "Core"; }; -if( !isObject( GuiGroupBorderProfile ) ) -new GuiControlProfile( GuiGroupBorderProfile ) +singleton GuiControlProfile( GuiGroupBorderProfile ) { border = false; opaque = false; @@ -202,8 +232,7 @@ new GuiControlProfile( GuiGroupBorderProfile ) category = "Core"; }; -if( !isObject( GuiTabBorderProfile ) ) -new GuiControlProfile( GuiTabBorderProfile ) +singleton GuiControlProfile( GuiTabBorderProfile ) { border = false; opaque = false; @@ -212,15 +241,13 @@ new GuiControlProfile( GuiTabBorderProfile ) category = "Core"; }; -if( !isObject( GuiModelessDialogProfile ) ) -new GuiControlProfile( GuiModelessDialogProfile ) +singleton GuiControlProfile( GuiModelessDialogProfile ) { modal = false; category = "Core"; }; -if( !isObject( GuiFrameSetProfile ) ) -new GuiControlProfile (GuiFrameSetProfile) +singleton GuiControlProfile (GuiFrameSetProfile) { fillcolor = "255 255 255"; borderColor = "246 245 244"; @@ -230,31 +257,27 @@ new GuiControlProfile (GuiFrameSetProfile) category = "Core"; }; -if( !isObject( GuiInputCtrlProfile ) ) -new GuiControlProfile( GuiInputCtrlProfile ) +singleton GuiControlProfile( GuiInputCtrlProfile ) { tab = true; canKeyFocus = true; category = "Core"; }; -if( !isObject( GuiTextProfile ) ) -new GuiControlProfile (GuiTextProfile) +singleton GuiControlProfile (GuiTextProfile) { justify = "left"; fontColor = "20 20 20"; category = "Core"; }; -if( !isObject( GuiTextRightProfile ) ) -new GuiControlProfile (GuiTextRightProfile : GuiTextProfile) +singleton GuiControlProfile (GuiTextRightProfile : GuiTextProfile) { justify = "right"; category = "Core"; }; -if( !isObject( GuiAutoSizeTextProfile ) ) -new GuiControlProfile (GuiAutoSizeTextProfile) +singleton GuiControlProfile (GuiAutoSizeTextProfile) { fontColor = "0 0 0"; autoSizeWidth = true; @@ -262,22 +285,19 @@ new GuiControlProfile (GuiAutoSizeTextProfile) category = "Core"; }; -if( !isObject( GuiMediumTextProfile ) ) -new GuiControlProfile( GuiMediumTextProfile : GuiTextProfile ) +singleton GuiControlProfile( GuiMediumTextProfile : GuiTextProfile ) { fontSize = 24; category = "Core"; }; -if( !isObject( GuiBigTextProfile ) ) -new GuiControlProfile( GuiBigTextProfile : GuiTextProfile ) +singleton GuiControlProfile( GuiBigTextProfile : GuiTextProfile ) { fontSize = 36; category = "Core"; }; -if( !isObject( GuiMLTextProfile ) ) -new GuiControlProfile( GuiMLTextProfile ) +singleton GuiControlProfile( GuiMLTextProfile ) { fontColor = $TextMediumEmphasisColor; fontColorHL = $TextMediumEmphasisColor; @@ -289,11 +309,16 @@ new GuiControlProfile( GuiMLTextProfile ) autoSizeWidth = true; autoSizeHeight = true; border = false; - category = "Core"; + modal = false; + category = "BaseUI"; }; -if( !isObject( GuiMLWhiteTextProfile ) ) -new GuiControlProfile( GuiMLWhiteTextProfile ) +singleton GuiControlProfile( GuiMLTextProfileHighlighted : GuiMLTextProfile ) +{ + fontColor = $TextMediumEmphasisColorHL; +}; + +singleton GuiControlProfile( GuiMLWhiteTextProfile ) { fontColor = "220 220 220"; fontColorHL = $TextMediumEmphasisColor; @@ -303,8 +328,7 @@ new GuiControlProfile( GuiMLWhiteTextProfile ) category = "Core"; }; -if( !isObject( GuiTextArrayProfile ) ) -new GuiControlProfile( GuiTextArrayProfile : GuiTextProfile ) +singleton GuiControlProfile( GuiTextArrayProfile : GuiTextProfile ) { fontColor = $TextMediumEmphasisColor; fontColorHL = $TextMediumEmphasisColor; @@ -324,8 +348,7 @@ new GuiControlProfile( GuiTextArrayProfile : GuiTextProfile ) canKeyFocus = true; }; -if( !isObject( GuiMenuTextEditProfile ) ) -new GuiControlProfile( GuiMenuTextEditProfile : GuiTextEditProfile ) +singleton GuiControlProfile( GuiMenuTextEditProfile : GuiTextEditProfile ) { fontColor = $TextMediumEmphasisColor; fontColorHL = $TextMediumEmphasisColor; @@ -347,8 +370,7 @@ new GuiControlProfile( GuiMenuTextEditProfile : GuiTextEditProfile ) // TODO: Revisit Popupmenu // ---------------------------------------------------------------------------- -if( !isObject( GuiPopupMenuItemBorder ) ) -new GuiControlProfile( GuiPopupMenuItemBorder : GuiButtonProfile ) +singleton GuiControlProfile( GuiPopupMenuItemBorder : GuiButtonProfile ) { opaque = true; border = true; @@ -362,8 +384,7 @@ new GuiControlProfile( GuiPopupMenuItemBorder : GuiButtonProfile ) category = "Core"; }; -if( !isObject( GuiPopUpMenuDefault ) ) -new GuiControlProfile( GuiPopUpMenuDefault : GuiDefaultProfile ) +singleton GuiControlProfile( GuiPopUpMenuDefault : GuiDefaultProfile ) { opaque = true; mouseOverSelected = true; @@ -385,8 +406,7 @@ new GuiControlProfile( GuiPopUpMenuDefault : GuiDefaultProfile ) category = "Core"; }; -if( !isObject( GuiPopUpMenuProfile ) ) -new GuiControlProfile( GuiPopUpMenuProfile : GuiPopUpMenuDefault ) +singleton GuiControlProfile( GuiPopUpMenuProfile : GuiPopUpMenuDefault ) { textOffset = "6 4"; bitmapAsset = "UI:dropDown_image"; @@ -396,8 +416,7 @@ new GuiControlProfile( GuiPopUpMenuProfile : GuiPopUpMenuDefault ) category = "Core"; }; -if( !isObject( GuiTabBookProfile ) ) -new GuiControlProfile( GuiTabBookProfile ) +singleton GuiControlProfile( GuiTabBookProfile ) { fillColorHL = "100 100 100"; fillColorNA = "150 150 150"; @@ -418,8 +437,7 @@ new GuiControlProfile( GuiTabBookProfile ) category = "Core"; }; -if( !isObject( GuiTabPageProfile ) ) -new GuiControlProfile( GuiTabPageProfile : GuiDefaultProfile ) +singleton GuiControlProfile( GuiTabPageProfile : GuiDefaultProfile ) { fontType = "Arial"; fontSize = 10; @@ -430,8 +448,7 @@ new GuiControlProfile( GuiTabPageProfile : GuiDefaultProfile ) category = "Core"; }; -if( !isObject( GuiConsoleProfile ) ) -new GuiControlProfile( GuiConsoleProfile ) +singleton GuiControlProfile( GuiConsoleProfile ) { fontType = ($platform $= "macos") ? "Monaco" : "Lucida Console"; fontSize = ($platform $= "macos") ? 13 : 12; @@ -445,8 +462,7 @@ new GuiControlProfile( GuiConsoleProfile ) category = "Core"; }; -if( !isObject( GuiConsoleTextProfile ) ) -new GuiControlProfile( GuiConsoleTextProfile ) +singleton GuiControlProfile( GuiConsoleTextProfile ) { fontColor = "0 0 0"; autoSizeWidth = true; @@ -462,8 +478,7 @@ new GuiControlProfile( GuiConsoleTextProfile ) $ConsoleDefaultFillColor = "0 0 0 175"; -if( !isObject( ConsoleScrollProfile ) ) -new GuiControlProfile( ConsoleScrollProfile : GuiScrollProfile ) +singleton GuiControlProfile( ConsoleScrollProfile : GuiScrollProfile ) { opaque = true; fillColor = $ConsoleDefaultFillColor; @@ -473,8 +488,7 @@ new GuiControlProfile( ConsoleScrollProfile : GuiScrollProfile ) category = "Core"; }; -if( !isObject( ConsoleTextEditProfile ) ) -new GuiControlProfile( ConsoleTextEditProfile : GuiTextEditProfile ) +singleton GuiControlProfile( ConsoleTextEditProfile : GuiTextEditProfile ) { fillColor = "242 241 240 255"; fillColorHL = "255 255 255"; @@ -485,8 +499,7 @@ new GuiControlProfile( ConsoleTextEditProfile : GuiTextEditProfile ) // Center and bottom print //----------------------------------------------------------------------------- -if( !isObject( CenterPrintProfile ) ) -new GuiControlProfile ( CenterPrintProfile ) +singleton GuiControlProfile ( CenterPrintProfile ) { opaque = false; fillColor = "128 128 128"; @@ -496,8 +509,7 @@ new GuiControlProfile ( CenterPrintProfile ) category = "Core"; }; -if( !isObject( CenterPrintTextProfile ) ) -new GuiControlProfile ( CenterPrintTextProfile ) +singleton GuiControlProfile ( CenterPrintTextProfile ) { opaque = false; fontType = "Arial"; @@ -509,9 +521,7 @@ new GuiControlProfile ( CenterPrintTextProfile ) // ---------------------------------------------------------------------------- // Radio button control // ---------------------------------------------------------------------------- - -if( !isObject( GuiRadioProfile ) ) -new GuiControlProfile( GuiRadioProfile ) +singleton GuiControlProfile( GuiRadioProfile ) { fontSize = 14; fillColor = "232 232 232"; @@ -526,31 +536,16 @@ new GuiControlProfile( GuiRadioProfile ) // // Scroll Profile // -if(!isObject(GuiMenuScrollProfile)) -new GuiControlProfile(GuiMenuScrollProfile) +singleton GuiControlProfile(GuiMenuScrollProfile) { opaque = false; - fillcolor = "22 22 22"; + fillcolor = "0 0 0 0"; fontColor = "200 200 200"; fontColorHL = "250 250 250"; border = false; bitmapAsset = "UI:scrollBar_image"; hasBitmapArray = true; - category = "Core"; -}; - -// Scroll -if(!isObject(GuiMenuScrollProfile)) -new GuiControlProfile(GuiMenuScrollProfile) -{ - opaque = true; - fillcolor = "128 128 128"; - fontColor = "0 0 0"; - fontColorHL = "150 150 150"; - border = true; - bitmapAsset = "UI:scrollBar_image"; - hasBitmapArray = true; - category = "Core"; + category = "BaseUI"; }; singleton GuiControlProfile(SliderBitmapGUIProfile) @@ -561,9 +556,23 @@ singleton GuiControlProfile(SliderBitmapGUIProfile) borderColor = "0 0 0 255"; }; +singleton GuiControlProfile(GuiMenuBackgroundProfile) +{ + category = "BaseUI"; + opaque = true; + fillcolor = "34 34 34 255"; +}; + singleton GuiControlProfile(GuiMenuPanelProfile) { category = "BaseUI"; opaque = true; fillcolor = "15 15 15 255"; }; + +singleton GuiControlProfile(GuiMenuBasePanelProfile) +{ + category = "BaseUI"; + opaque = true; + fillcolor = "40 40 40 255"; +}; \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/utility.tscript b/Templates/BaseGame/game/data/UI/scripts/utility.tscript index 4245651f0..a0870f54d 100644 --- a/Templates/BaseGame/game/data/UI/scripts/utility.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/utility.tscript @@ -1,3 +1,25 @@ +function ActionMap::getCommandButtonBitmap(%this, %device, %command) +{ + %binding = %this.getBinding(%command); + + if(%device $= "mouse" || %device $= "") + %device = "keyboard"; + + %bindingCount = getFieldCount(%binding); + for(%i=0; %i < %bindingCount; %i+=2) + { + %mapDevice = stripTrailingNumber(getField(%binding, %i)); + if(%mapDevice $= %device) + { + %button = getField(%binding, %i+1); + break; + } + } + + %assetId = getButtonBitmap(%device, %button); + return %assetId; +} + function getButtonBitmap(%device, %button) { if(%device $= "gamepad") diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index 3d22b0ffd..ede1a4e14 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -41,7 +41,7 @@ Edit Asset 0 1047 2200 360 + name="LastPosExt">0 976 2016 360 1 tools/RPGDialogEditor/gui 1024 768 + name="previewResolution">1280 720 https://docs.torque3d.org - - Categorized - Date: Sun, 17 Dec 2023 03:27:30 -0600 Subject: [PATCH 03/19] Standardized titlebar formatting Cleaned up some unneeded fields in the gui files Fixed up querying presentation for joinServerMenu Removed usages of background image in favor of guiProfiles for various menus Implemented optionsMenu traversing options categories along with required keybinds Adjusted some guiProfiles' font sizes to improve legibility on smaller displays --- .../game/data/UI/guis/ChooseLevelMenu.gui | 7 +- .../BaseGame/game/data/UI/guis/GameMenu.gui | 4 - .../BaseGame/game/data/UI/guis/SystemMenu.gui | 1 - .../game/data/UI/guis/joinServerMenu.gui | 29 +- .../game/data/UI/guis/joinServerMenu.tscript | 76 ++-- .../BaseGame/game/data/UI/guis/mainMenu.gui | 6 +- .../game/data/UI/guis/optionsMenu.gui | 336 +++--------------- .../game/data/UI/guis/optionsMenu.tscript | 213 +++++++---- .../game/data/UI/scripts/profiles.tscript | 14 +- 9 files changed, 267 insertions(+), 419 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index 5fe626a07..7fb06379a 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -1,11 +1,10 @@ //--- OBJECT WRITE BEGIN --- -$guiContent = new GuiChunkedBitmapCtrl(ChooseLevelMenu) { - BitmapAsset = "UI:backgrounddark_image"; +$guiContent = new GuiControl(ChooseLevelMenu) { extent = "1280 720"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiNonModalDefaultProfile"; + profile = "GuiMenuBackgroundProfile"; category = "BaseUI"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; @@ -24,7 +23,7 @@ $guiContent = new GuiChunkedBitmapCtrl(ChooseLevelMenu) { }; new GuiPanel(ChooseLevelTitlePanel) { - extent = "1281 80"; + extent = "1281 60"; horizSizing = "width"; profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.gui b/Templates/BaseGame/game/data/UI/guis/GameMenu.gui index 559f8c59c..09cdf31e1 100644 --- a/Templates/BaseGame/game/data/UI/guis/GameMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.gui @@ -4,11 +4,7 @@ $guiContent = new GuiControl(GameMenu) { profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; - superClass = "UINavigation"; canSaveDynamicFields = "1"; - currentMenu = "SystemMenu"; - gameMenusArray = "17288"; - resizePages = "1"; new GuiInputCtrl(GameMenuInputHandler) { ignoreMouseEvents = "1"; diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui index d2a12bed3..381762506 100644 --- a/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui @@ -15,7 +15,6 @@ $guiContent = new GuiControl(SystemMenu) { vertSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; new GuiButtonCtrl() { text = "Return to Game"; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index d7d787c89..fe2575ca2 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -20,7 +20,7 @@ $guiContent = new GuiControl(JoinServerMenu) { }; new GuiPanel(JoinServerTitlePanel) { - extent = "1281 80"; + extent = "1281 60"; horizSizing = "width"; profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; @@ -34,7 +34,7 @@ $guiContent = new GuiControl(JoinServerMenu) { }; }; new GuiContainer() { - position = "203 81"; + position = "203 61"; extent = "900 30"; profile = GuiMenuPanelProfile; tooltipProfile = "GuiToolTipProfile"; @@ -44,7 +44,7 @@ $guiContent = new GuiControl(JoinServerMenu) { new GuiTextCtrl() { text = "Server Details"; position = "0 0"; - extent = "730 30"; + extent = "700 30"; horizSizing = "right"; vertSizing = "center"; profile = "MenuSubHeaderText"; @@ -53,29 +53,29 @@ $guiContent = new GuiControl(JoinServerMenu) { new GuiTextCtrl() { text = "Ping"; - position = "730 0"; - extent = "50 30"; + position = "700 0"; + extent = "70 30"; horizSizing = "left"; vertSizing = "center"; - profile = "MenuSubHeaderText"; + profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { text = "Player Count"; - position = "780 0"; - extent = "120 30"; + position = "770 0"; + extent = "130 30"; horizSizing = "left"; vertSizing = "center"; - profile = "MenuSubHeaderText"; + profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; }; }; new GuiScrollCtrl() { hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; - position = "203 111"; - extent = "900 601"; + position = "203 91"; + extent = "900 621"; minExtent = "8 8"; horizSizing = "center"; vertSizing = "height"; @@ -91,7 +91,6 @@ $guiContent = new GuiControl(JoinServerMenu) { vertSizing = "center"; profile = "GuiMenuDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; }; }; new GuiPanel(JoinServerButtonPanel) { @@ -113,7 +112,7 @@ $guiContent = new GuiControl(JoinServerMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "JoinServerMenu.query();"; + command = "JoinServerMenu.join();"; tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(JoinServerQLanBtn) { @@ -136,8 +135,8 @@ $guiContent = new GuiControl(JoinServerMenu) { makeIconSquare = "1"; textLocation = "Center"; text = "Query Server"; - position = "817 0"; - extent = "140 40"; + position = "800 0"; + extent = "160 40"; horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index d829be8ce..f612a3117 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -3,6 +3,8 @@ function JoinServerMenu::onWake(%this) { $MenuList = JoinServerList; JoinServerList.listPosition = 0; + + JoinServerList.syncGui(); } if(!isObject( JoinServerActionMap ) ) @@ -14,11 +16,17 @@ if(!isObject( JoinServerActionMap ) ) JoinServerActionMap.bindCmd( keyboard, e, "JoinServerMenu.queryLan();" ); JoinServerActionMap.bindCmd( gamepad, btn_y, "JoinServerMenu.queryLan();" ); + + JoinServerActionMap.bindCmd( keyboard, Enter, "JoinServerMenu::join();" ); + JoinServerActionMap.bindCmd( gamepad, btn_a, "JoinServerMenu::join();" ); } //---------------------------------------- function JoinServerMenu::query(%this) { + //Nuke the current list and indicate we're working on a query... + JoinServerList.clear(); + queryMasterServer( 0, // Query flags $Client::GameTypeQuery, // gameTypes @@ -36,6 +44,9 @@ function JoinServerMenu::query(%this) //---------------------------------------- function JoinServerMenu::queryLan(%this) { + //Nuke the current list and indicate we're working on a query... + JoinServerList.clear(); + queryLANServers( $pref::Net::Port, // lanPort for local queries 0, // Query flags @@ -63,16 +74,14 @@ function JoinServerMenu::cancel(%this) function JoinServerMenu::join(%this) { cancelServerQuery(); - %index = JS_serverList.getSelectedId(); - - JoinGame(%index); + JoinGame(JoinServerList.listPosition); } //---------------------------------------- function JoinServerMenu::refresh(%this) { cancelServerQuery(); - %index= JoinServerList.getActiveRow(); + %index = JoinServerList.listPosition; // The server info index is stored in the row along with the // rest of displayed info. @@ -98,7 +107,7 @@ function JoinServerMenu::update(%this) %serverEntry = %this.addServerEntry(); %serverEntry-->serverNameTxt.text = $ServerInfo::Name; - %serverEntry-->serverDetailsTxt.text = $ServerInfo::Version @ " | " @ $ServerInfo::MissionName @ " | " @ $ServerInfo::MissionType; + %serverEntry-->serverDetailsTxt.text = $ServerInfo::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $ServerInfo::MissionType; %serverEntry-->pingTxt.text = $ServerInfo::Ping @ " ms"; %serverEntry-->playerCountTxt.text = $ServerInfo::PlayerCount @ "|" @ $ServerInfo::MaxPlayers; @@ -106,6 +115,8 @@ function JoinServerMenu::update(%this) JoinServerList.add(%serverEntry); } + + JoinServerList.syncGui(); } //---------------------------------------- @@ -115,26 +126,22 @@ function onServerQueryStatus(%status, %msg, %value) // Update query status // States: start, update, ping, query, done // value = % (0-1) done for ping and query states - if (!JS_queryStatus.isVisible()) - JS_queryStatus.setVisible(true); + //if (!JS_queryStatus.isVisible()) + // JS_queryStatus.setVisible(true); switch$ (%status) { case "start": - JS_statusText.setText(%msg); - JS_statusBar.setValue(0); + MessagePopup("", %msg, 5000); JoinServerList.clear(); case "ping": - JS_statusText.setText("Ping Servers"); - JS_statusBar.setValue(%value); + MessagePopup("", "Pinging Servers", 5000); case "query": - JS_statusText.setText("Query Servers"); - JS_statusBar.setValue(%value); + MessagePopup("", "Querying Servers", 5000); case "done": - JS_queryStatus.setVisible(false); - JS_status.setText(%msg); + MessagePopup("", %msg, 1000); JoinServerMenu.update(); } } @@ -157,39 +164,40 @@ function JoinServerMenu::addServerEntry(%this) horizSizing = "width"; vertSizing = "height"; internalName = "button"; + class = "JoinServerEntryButton"; }; new GuiTextCtrl() { position = "0 0"; - extent = "730 20"; + extent = "700 20"; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; internalName = "serverNameTxt"; }; new GuiTextCtrl() { position = $optionsEntryPad SPC 17; - extent = "730 18"; + extent = "700 18"; profile = "GuiMLTextProfile"; tooltipProfile = "GuiToolTipProfile"; internalName = "serverDetailsTxt"; }; new GuiTextCtrl() { - position = "730 0"; - extent = "50 40"; + position = "700 0"; + extent = "70 40"; horizSizing = "left"; vertSizing = "center"; - profile = "MenuSubHeaderText"; + profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; internalName = "pingTxt"; }; new GuiTextCtrl() { - position = "780 0"; - extent = "120 40"; + position = "770 0"; + extent = "130 40"; horizSizing = "left"; vertSizing = "center"; - profile = "MenuSubHeaderText"; + profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; internalName = "playerCountTxt"; }; @@ -198,6 +206,16 @@ function JoinServerMenu::addServerEntry(%this) return %entry; } +function JoinServerEntryButton::onHighlighted(%this, %highlighted) +{ + %container = %this.getParent(); + + %container-->serverNameTxt.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText; + %container-->serverDetailsTxt.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile; + %container-->pingTxt.profile = %highlighted ? MenuSubHeaderCenteredTextHighlighted : MenuSubHeaderCenteredText; + %container-->playerCountTxt.profile = %highlighted ? MenuSubHeaderCenteredTextHighlighted : MenuSubHeaderCenteredText; +} + function JoinServerMenu::addStatusEntry(%this) { %entry = new GuiContainer() { @@ -221,6 +239,13 @@ function JoinServerMenu::addStatusEntry(%this) return %entry; } +function JoinServerStatusEntry::updateProgress(%this) +{ + %this-->statusText.text = %this-->statusText.text @ "."; //ellipses....... + + %this.schedule(500, "updateProgress"); +} + function JoinServerList::syncGui(%this) { %this.callOnChildren("setHighlighted", false); @@ -238,9 +263,10 @@ function JoinServerList::syncGui(%this) %device = "keyboard"; JoinServerBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut")); - JoinServerJoinBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected")); + JoinServerJoinBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu::join();")); JoinServerQLanBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.queryLan();")); JoinServerQServerBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.query();")); - //JoinServerJoinBtn.setActive($selectedLevelAsset !$= ""); + + JoinServerJoinBtn.setActive(JoinServerList.getCount() > 0); } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index 6ccf77732..3fc39662b 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -1,11 +1,10 @@ //--- OBJECT WRITE BEGIN --- -$guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { - BitmapAsset = "UI:backgrounddark_image"; +$guiContent = new GuiControl(MainMenuGui) { extent = "1280 720"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiDefaultProfile"; + profile = "GuiMenuBackgroundProfile"; category = "BaseUI"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; @@ -77,7 +76,6 @@ $guiContent = new GuiChunkedBitmapCtrl(MainMenuGui) { vertSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; new GuiButtonCtrl(MainMenuSinglePlayerBtn) { text = "Single Player"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 522e7044a..f7a6daa70 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -1,17 +1,14 @@ //--- OBJECT WRITE BEGIN --- -$guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { - BitmapAsset = "UI:backgrounddark_image"; +$guiContent = new GuiControl(OptionsMenu) { extent = "1280 720"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiDefaultProfile"; + profile = "GuiMenuBackgroundProfile"; category = "BaseUI"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; - canSaveDynamicFields = "1"; - optionsCategories = "17237"; - unappliedChanges = "17238"; + canSaveDynamicFields = "0"; new GuiInputCtrl(OptionsMenuInputHandler) { ignoreMouseEvents = "1"; @@ -24,83 +21,77 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiControl(OptionsMenuCategoryContainer) { - position = "332 80"; - extent = "617 49"; + position = "0 60"; + extent = "1280 49"; horizSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; - new GuiIconButtonCtrl(OptionsMenuCatPrevBtn) { - BitmapAsset = "UI:Keyboard_Black_Q_image"; - iconLocation = "Center"; - makeIconSquare = "1"; - textLocation = "Center"; - bitmapMargin = "30"; - position = "1 4"; - extent = "50 40"; - vertSizing = "center"; - profile = "GuiMenuButtonProfile"; - command = "OptionsMenuCategoryPrev();"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputButton"; - }; - new GuiIconButtonCtrl(OptionsMenuCatNextBtn) { - BitmapAsset = "UI:Keyboard_Black_E_image"; - iconLocation = "Center"; - makeIconSquare = "1"; - bitmapMargin = "30"; - position = "568 4"; - extent = "50 40"; - horizSizing = "left"; - vertSizing = "center"; - profile = "GuiMenuButtonProfile"; - command = "OptionsMenuCategoryNext();"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputButton"; - }; new GuiStackControl(OptionsMenuCategoryList) { stackingType = "Horizontal"; padding = "10"; dynamicSize = "0"; - position = "137 3"; - extent = "358 40"; + position = "430 0"; + extent = "420 40"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; new GuiButtonCtrl() { text = "Video"; - extent = "100 40"; + extent = "120 40"; profile = "GuiMenuButtonProfile"; - command = "populateDisplaySettingsList();"; + command = "OptionsMenu.openOptionsCategory(\"Video\");"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl() { text = "Audio"; - position = "110 0"; - extent = "100 40"; + position = "130 0"; + extent = "120 40"; profile = "GuiMenuButtonProfile"; - command = "populateAudioSettingsList();"; + command = "OptionsMenu.openOptionsCategory(\"Audio\");"; tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl() { text = "Controls"; - position = "220 0"; - extent = "140 40"; + position = "260 0"; + extent = "160 40"; profile = "GuiMenuButtonProfile"; - command = "populateKeyboardMouseSettingsList();"; + command = "OptionsMenu.openOptionsCategory(\"Controls\");"; tooltipProfile = "GuiToolTipProfile"; }; }; + + new GuiControl(OptionsMenuNavButtonOverlay) { + extent = "1281 40"; + horizSizing = "width"; + vertSizing = "height"; + profile = GuiNonModalDefaultProfile; + + new GuiBitmapCtrl(OptionsMenuPrevNavIcon) { + BitmapAsset = "UI:Keyboard_Black_Q_image"; + position = "0 10"; + extent = "40 40"; + profile = GuiNonModalDefaultProfile; + vertSizing = "top"; + }; + + new GuiBitmapCtrl(OptionsMenuNextNavIcon) { + BitmapAsset = "UI:Keyboard_Black_E_image"; + position = "0 10"; + extent = "40 40"; + profile = GuiNonModalDefaultProfile; + vertSizing = "top"; + }; + }; }; new GuiScrollCtrl(OptionsMenuSettingsScroll) { hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; - position = "331 128"; - extent = "618 555"; + position = "240 110"; + extent = "800 573"; horizSizing = "center"; vertSizing = "height"; profile = "GuiMenuScrollProfile"; @@ -109,258 +100,40 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { new GuiStackControl(VideoSettingsList) { padding = "5"; changeChildSizeToFit = "0"; - position = "1 1"; - extent = "603 200"; + position = "0 1"; + extent = "800 200"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; - - new GuiTextCtrl() { - text = "Basic"; - extent = "500 30"; - profile = "MenuHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiContainer() { - position = "0 35"; - extent = "603 40"; - horizSizing = "width"; - profile = "GuiMenuDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "OptionsListEntry"; - - new GuiButtonCtrl() { - extent = "603 40"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "Button"; - class = "optionsMenuButton"; - }; - new GuiTextCtrl() { - text = "Graphical Quality"; - position = "10 -1"; - extent = "250 20"; - profile = "MenuSubHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionName"; - }; - new GuiTextCtrl() { - text = "Controls the general graphical quality"; - position = "10 17"; - extent = "178 18"; - profile = "GuiMLTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionDescription"; - }; - new GuiContainer() { - position = "353 0"; - extent = "250 40"; - horizSizing = "left"; - vertSizing = "height"; - profile = "GuiModelessDialogProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "valuesContainer"; - - new GuiButtonCtrl() { - text = "<"; - position = "160 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl() { - text = "High"; - position = "180 0"; - extent = "50 40"; - vertSizing = "center"; - profile = "GuiMenuTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "optionValue"; - }; - new GuiButtonCtrl() { - text = ">"; - position = "230 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; - }; - new GuiContainer() { - position = "0 80"; - extent = "603 40"; - horizSizing = "width"; - profile = "GuiMenuDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "OptionsListEntry"; - - new GuiButtonCtrl() { - extent = "603 40"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "Button"; - class = "optionsMenuButton"; - }; - new GuiTextCtrl() { - text = "Lighting Quality"; - position = "10 -1"; - extent = "250 20"; - profile = "MenuSubHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionName"; - }; - new GuiTextCtrl() { - text = "Controls the lighting and shadows quality"; - position = "10 17"; - extent = "198 18"; - profile = "GuiMLTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionDescription"; - }; - new GuiContainer() { - position = "353 0"; - extent = "250 40"; - horizSizing = "left"; - vertSizing = "height"; - profile = "GuiModelessDialogProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "valuesContainer"; - - new GuiButtonCtrl() { - text = "<"; - position = "160 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl() { - text = "High"; - position = "180 0"; - extent = "50 40"; - vertSizing = "center"; - profile = "GuiMenuTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "optionValue"; - }; - new GuiButtonCtrl() { - text = ">"; - position = "230 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; - }; - new GuiTextCtrl() { - text = "Advanced"; - position = "0 125"; - extent = "500 30"; - profile = "MenuHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiContainer() { - position = "0 160"; - extent = "603 40"; - horizSizing = "width"; - profile = "GuiMenuDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - class = "OptionsListEntry"; - - new GuiButtonCtrl() { - extent = "603 40"; - horizSizing = "width"; - vertSizing = "height"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "Button"; - class = "optionsMenuButton"; - }; - new GuiTextCtrl() { - text = "Mesh Detail"; - position = "10 -1"; - extent = "250 20"; - profile = "MenuSubHeaderText"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionName"; - }; - new GuiTextCtrl() { - text = "Controls the max quality of mesh objects"; - position = "10 17"; - extent = "195 18"; - profile = "GuiMLTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "OptionDescription"; - }; - new GuiContainer() { - position = "353 0"; - extent = "250 40"; - horizSizing = "left"; - vertSizing = "height"; - profile = "GuiModelessDialogProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "valuesContainer"; - - new GuiButtonCtrl() { - text = "<"; - position = "160 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - new GuiTextCtrl() { - text = "High"; - position = "180 0"; - extent = "50 40"; - vertSizing = "center"; - profile = "GuiMenuTextProfile"; - tooltipProfile = "GuiToolTipProfile"; - internalName = "optionValue"; - }; - new GuiButtonCtrl() { - text = ">"; - position = "230 0"; - extent = "20 40"; - profile = "GuiMenuButtonProfile"; - tooltipProfile = "GuiToolTipProfile"; - }; - }; - }; }; new GuiStackControl(AudioSettingsList) { padding = "5"; changeChildSizeToFit = "0"; - position = "1 1"; - extent = "603 245"; + position = "0 1"; + extent = "800 200"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; visible = "0"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; hidden = "1"; }; new GuiStackControl(ControlSettingsList) { padding = "5"; changeChildSizeToFit = "0"; - position = "1 1"; - extent = "603 245"; + position = "0 1"; + extent = "800 200"; horizSizing = "width"; vertSizing = "height"; profile = "GuiDefaultProfile"; visible = "0"; tooltipProfile = "GuiToolTipProfile"; - superClass = "MenuList"; hidden = "1"; }; }; new GuiPanel(OptionMenuTitlePanel) { - extent = "1281 80"; + extent = "1281 60"; horizSizing = "width"; profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; @@ -381,21 +154,6 @@ $guiContent = new GuiChunkedBitmapCtrl(OptionsMenu) { profile = "GuiMenuPanelProfile"; tooltipProfile = "GuiToolTipProfile"; - new GuiIconButtonCtrl(OptionsMenuApplyBtn) { - BitmapAsset = "UI:Keyboard_Black_Return_image"; - sizeIconToButton = "1"; - makeIconSquare = "1"; - textLocation = "Center"; - text = "Apply"; - position = "1115 0"; - extent = "140 40"; - horizSizing = "left"; - vertSizing = "center"; - profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.applySettings();"; - tooltipProfile = "GuiToolTipProfile"; - class = "MenuInputButton"; - }; new GuiIconButtonCtrl(OptionsMenuBackBtn) { BitmapAsset = "UI:Keyboard_Black_Escape_image"; sizeIconToButton = "1"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 9e52e4154..d2c3fbb8c 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -50,6 +50,10 @@ $yesNoList = "No\tYes"; $onOffList = "Off\tOn"; $optionsEntryPad = 10; +$OptionsMenuCategories[0] = "Video"; +$OptionsMenuCategories[1] = "Audio"; +$OptionsMenuCategories[2] = "Controls"; + function OptionsMenu::onAdd(%this) { if(!isObject(%this.optionsCategories)) @@ -69,6 +73,8 @@ function OptionsMenu::onAdd(%this) function OptionsMenu::onWake(%this) { + %this.unappliedChanges.empty(); + VideoSettingsList.clear(); for(%i=0; %i < VideoSettingsGroup.getCount(); %i++) @@ -111,13 +117,9 @@ function OptionsMenu::onWake(%this) } } - $MenuList = VideoSettingsList; + //establish the cached prefs values here - //Find our first non-group entry - while($MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry && $MenuList.listPosition < $MenuList.getCount()) - { - $MenuList.listPosition += 1; - } + %this.openOptionsCategory("Video"); } if(!isObject( OptionsMenuActionMap ) ) @@ -136,8 +138,14 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting ); OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuNextSetting ); - //OptionsMenuActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); - //OptionsMenuActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); + OptionsMenuActionMap.bind( keyboard, q, OptionsMenuPrevCategory ); + OptionsMenuActionMap.bind( gamepad, btn_l, OptionsMenuPrevCategory ); + + OptionsMenuActionMap.bind( keyboard, e, OptionsMenuNextCategory ); + OptionsMenuActionMap.bind( gamepad, btn_r, OptionsMenuNextCategory ); + + OptionsMenuActionMap.bind( keyboard, R, OptionsMenuReset ); + OptionsMenuActionMap.bind( gamepad, btn_x, OptionsMenuReset ); } function VideoSettingsList::syncGui(%this) @@ -149,6 +157,108 @@ function VideoSettingsList::syncGui(%this) %btn-->button.setHighlighted(true); } +function AudioSettingsList::syncGui(%this) +{ + +} + +function ControlSettingsList::syncGui(%this) +{ + +} + +function OptionsMenu::openOptionsCategory(%this, %categoryName) +{ + VideoSettingsList.setVisible(%categoryName $= "Video"); + AudioSettingsList.setVisible(%categoryName $= "Audio"); + ControlSettingsList.setVisible(%categoryName $= "Controls"); + + if(%categoryName $= "Video") + { + $MenuList = VideoSettingsList; + //Find our first non-group entry + while($MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry && $MenuList.listPosition < $MenuList.getCount()) + { + $MenuList.listPosition += 1; + } + + %this.currentCatgeoryIdx = 0; + } + else if(%categoryName $= "Audio") + { + $MenuList = AudioSettingsList; + + %this.currentCatgeoryIdx = 1; + } + else if(%categoryName $= "Controls") + { + $MenuList = ControlSettingsList; + + %this.currentCatgeoryIdx = 2; + } + + $MenuList.syncGui(); + %this.syncGui(); +} + +function OptionsMenu::syncGui(%this) +{ + OptionsMenuCategoryList.callOnChildren("setHighlighted", false); + + %btn = OptionsMenuCategoryList.getObject(%this.currentCatgeoryIdx); + %btn.setHighlighted(true); + + %buttonPosX = %btn.position.x + OptionsMenuCategoryList.position.x; + + OptionsMenuPrevNavIcon.position.x = %buttonPosX - 5; + OptionsMenuNextNavIcon.position.x = %buttonPosX + %btn.extent.x - 35; + + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + OptionsMenuBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut")); + OptionsMenuResetBtn.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuReset")); + + OptionsMenuPrevNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuPrevCategory")); + OptionsMenuNextNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuNextCategory")); +} + +function OptionsMenuPrevCategory(%val) +{ + if(%val) + { + %currentIdx = OptionsMenu.currentMenuIdx; + OptionsMenu.currentMenuIdx -= 1; + + OptionsMenu.currentMenuIdx = mClamp(OptionsMenu.currentMenuIdx, 0, 3); + + if(%currentIdx == OptionsMenu.currentMenuIdx) + return; + + %newCategory = $OptionsMenuCategories[OptionsMenu.currentMenuIdx]; + OptionsMenu.openOptionsCategory(%newCategory); + } +} + +function OptionsMenuNextCategory(%val) +{ + if(%val) + { + %currentIdx = OptionsMenu.currentMenuIdx; + OptionsMenu.currentMenuIdx += 1; + + OptionsMenu.currentMenuIdx = mClamp(OptionsMenu.currentMenuIdx, 0, 3); + + if(%currentIdx == OptionsMenu.currentMenuIdx) + return; + + %newCategory = $OptionsMenuCategories[OptionsMenu.currentMenuIdx]; + OptionsMenu.openOptionsCategory(%newCategory); + } +} + // function OptionMenuNavigatePrev(%val) { @@ -199,11 +309,11 @@ function OptionMenuPrevSetting(%val) %optionObject = %option.optionsObject; %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName); - /*$MenuList.listPosition -= 1; - - if($MenuList.listPosition < 0) - $MenuList.listPosition = 0;*/ + %option.currentOptionIndex = mClamp(%option.currentOptionIndex-1, 0, %optionObject.getCount()-1); + + %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); $MenuList.syncGUI(); } @@ -211,15 +321,15 @@ function OptionMenuPrevSetting(%val) function OptionMenuNextSetting(%val) { %option = $MenuList.getObject($MenuList.listPosition); + echo("Option: " @ %option.className); %optionObject = %option.optionsObject; %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - echo("Changed option: " @ %optionObject.optionName @ " to level: " @ %currentOptionLevel.displayName); + %option.currentOptionIndex = mClamp(%option.currentOptionIndex+1, 0, %optionObject.getCount()-1); - /*$MenuList.listPosition += 1; - - if($MenuList.listPosition >= $MenuList.getCount()) - $MenuList.listPosition = $MenuList.getCount()-1;*/ + %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); $MenuList.syncGUI(); } @@ -228,52 +338,7 @@ function OptionMenuStickChangeSetting(%val) { } -// -function OptionsMenu::onOpen(%this) -{ - OptionsMenuCategoryList.clear(); - - for(%i=0; %i < %this.optionsCategories.count(); %i++) - { - %catName = %this.optionsCategories.getKey(%i); - %callback = %this.optionsCategories.getValue(%i); - - %newCatButton = new GuiButtonCtrl() { - text = %catName; - groupNum = "-1"; - buttonType = "PushButton"; - useMouseEvents = "0"; - position = "0 180"; - extent = "248 35"; - minExtent = "8 2"; - horizSizing = "right"; - vertSizing = "bottom"; - profile = "GuiMenuButtonProfile"; - visible = "1"; - active = "1"; - command = %callback; - tooltipProfile = "GuiToolTipProfile"; - hovertime = "1000"; - isContainer = "0"; - canSave = "1"; - canSaveDynamicFields = "0"; - }; - - OptionsMenuCategoryList.add(%newCatButton); - } - - %this.unappliedChanges.empty(); - $pref::Video::displayDeviceId = ""; - - OptionsMenuCategoryList.setAsActiveMenuList(); - - $activeMenuButtonContainer-->button1.set("btn_back", "R", "Reset", "OptionsMenu.resetToDefaults();"); - $activeMenuButtonContainer-->button2.disable(); - $activeMenuButtonContainer-->button3.set("", "Space", "Apply", "OptionsMenu.apply();"); - $activeMenuButtonContainer-->button4.set("btn_a", "", "Select", "OptionsMenu.select();"); - $activeMenuButtonContainer-->button5.set("btn_b", "Escape", "Back", %this @ ".navigation.popPage();"); -} - + //We capitalize on the canClose test here, because we want to prompt for unapplied options changes before //backing out. So when the UINavigation test canClose, we can see if we have unapplied settings and prompt //that via the message box and return false. @@ -1382,7 +1447,7 @@ function addOptionEntry(%optionObj) %entry = new GuiContainer() { position = "0 0"; - extent = "500 40"; + extent = "800 40"; profile = GuiMenuDefaultProfile; tooltipProfile = "GuiToolTipProfile"; horizSizing = "width"; @@ -1394,7 +1459,7 @@ function addOptionEntry(%optionObj) new GuiButtonCtrl() { profile = GuiMenuButtonProfile; position = "0 0"; - extent = "500 40"; + extent = "800 40"; horizSizing = "width"; vertSizing = "height"; internalName = "button"; @@ -1404,7 +1469,7 @@ function addOptionEntry(%optionObj) new GuiTextCtrl() { text = %optionObj.OptionName; position = $optionsEntryPad SPC -1; - extent = "250 20"; + extent = "400 20"; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; internalName = "optionName"; @@ -1412,15 +1477,15 @@ function addOptionEntry(%optionObj) new GuiTextCtrl() { text = %optionObj.Description; position = $optionsEntryPad SPC 17; - extent = "250 18"; + extent = "400 18"; profile = "GuiMLTextProfile"; tooltipProfile = "GuiToolTipProfile"; internalName = "optionDescription"; }; new GuiContainer() { - position = "250 0"; - extent = "250 40"; + position = "400 0"; + extent = "400 40"; profile = GuiModelessDialogProfile; tooltipProfile = "GuiToolTipProfile"; horizSizing = "left"; @@ -1428,15 +1493,16 @@ function addOptionEntry(%optionObj) internalName = "valuesContainer"; new GuiButtonCtrl() { - position = "160 0"; + position = "310 0"; extent = "20 40"; text = "<"; profile = GuiMenuButtonProfile; + internalName = "prevValButton"; }; new GuiTextCtrl() { text = %qualityLevel.displayName; - position = "180 0"; + position = "330 0"; extent = "50 40"; profile = "GuiMenuTextProfile"; tooltipProfile = "GuiToolTipProfile"; @@ -1446,10 +1512,11 @@ function addOptionEntry(%optionObj) }; new GuiButtonCtrl() { - position = "230 0"; + position = "380 0"; extent = "20 40"; text = ">"; profile = GuiMenuButtonProfile; + internalName = "nextValButton"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index d8d2304d3..93e65e7dd 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -49,7 +49,7 @@ singleton GuiControlProfile(GamepadButtonTextRight : GamepadButtonTextLeft) singleton GuiControlProfile(MenuHeaderText) { fontType = "Arial Bold"; - fontSize = 30; + fontSize = 36; fontColor = $TextHighEmphasisColor; justify = "left"; modal = false; @@ -63,7 +63,7 @@ singleton GuiControlProfile(MenuHeaderTextHighlighted : MenuHeaderText) singleton GuiControlProfile(MenuHeaderTextCenter) { fontType = "Arial Bold"; - fontSize = 30; + fontSize = 32; fontColor = $TextHighEmphasisColor; justify = "center"; }; @@ -71,7 +71,7 @@ singleton GuiControlProfile(MenuHeaderTextCenter) singleton GuiControlProfile(MenuSubHeaderText) { fontType = "Arial Bold"; - fontSize = 20; + fontSize = 24; fontColor = $TextMediumEmphasisColor; justify = "left"; modal = false; @@ -87,6 +87,11 @@ singleton GuiControlProfile(MenuSubHeaderCenteredText : MenuSubHeaderText) justify = "center"; }; +singleton GuiControlProfile(MenuSubHeaderCenteredTextHighlighted : MenuSubHeaderCenteredText) +{ + fontColor = $TextMediumEmphasisColorHL; +}; + singleton GuiControlProfile(MenuMLSubHeaderText) { fontType = "Arial Bold"; @@ -113,7 +118,7 @@ singleton GuiControlProfile( GuiMenuButtonProfile ) { opaque = true; border = false; - fontSize = 18; + fontSize = 24; fontType = "Arial Bold"; fontColor = "200 200 200 255"; fontColorHL = "0 0 0 255"; @@ -304,6 +309,7 @@ singleton GuiControlProfile( GuiMLTextProfile ) fontColorSEL = $TextMediumEmphasisColor; fontColorNA = $TextDisabledColor; + fontSize = 20; fontColorLink = "100 100 100"; fontColorLinkHL = $TextMediumEmphasisColor; autoSizeWidth = true; From 55697cffdbb9ad3ceaa4e3810f4474ef94b5007a Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 18 Dec 2023 23:49:13 -0600 Subject: [PATCH 04/19] Streamlined baseUI profiles Implemented audioOptions file with structure to comply to BaseUI options menu Implemented majority of keybind remapping logic for options menu --- Engine/source/assets/assetManager.cpp | 2 +- .../core/console/scripts/profiles.tscript | 2 +- .../game/core/gui/scripts/profiles.tscript | 21 + .../rendering/scripts/graphicsOptions.tscript | 1426 ++++++++++------- .../BaseGame/game/core/sfx/Core_SFX.tscript | 2 +- .../core/sfx/scripts/audioOptions.tscript | 82 + .../scripts/client/defaultKeybinds.tscript | 9 +- .../game/data/UI/guis/ChooseLevelMenu.tscript | 2 +- .../game/data/UI/guis/optionsMenu.gui | 36 +- .../game/data/UI/guis/optionsMenu.tscript | 1051 ++++++------ .../game/data/UI/scripts/profiles.tscript | 506 +----- .../tools/VPathEditor/GUI/VPathEditor.gui | 4 +- .../VPathEditor/GUI/VPathEditorToolbar.gui | 4 +- .../tools/VerveEditor/GUI/GuiProfiles.tscript | 4 +- .../assetBrowser/scripts/assetBrowser.tscript | 2 +- .../gui/messageBoxes/IODropdownDlg.ed.gui | 2 +- .../tools/gui/renderTargetVisualizer.ed.gui | 4 +- .../levels/DefaultEditorLevel.asset.taml | 6 +- .../gui/guiMaterialPropertiesWindow.ed.gui | 14 +- .../game/tools/navEditor/NavEditorGui.gui | 2 +- .../tools/navEditor/NavEditorSettingsTab.gui | 2 +- Templates/BaseGame/game/tools/settings.xml | 2 +- .../game/tools/worldEditor/gui/shadowViz.gui | 2 +- 23 files changed, 1605 insertions(+), 1582 deletions(-) create mode 100644 Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript diff --git a/Engine/source/assets/assetManager.cpp b/Engine/source/assets/assetManager.cpp index 9d925d873..30efc47db 100644 --- a/Engine/source/assets/assetManager.cpp +++ b/Engine/source/assets/assetManager.cpp @@ -210,7 +210,7 @@ bool AssetManager::addModuleDeclaredAssets( ModuleDefinition* pModuleDefinition dSprintf(extensionBuffer, sizeof(extensionBuffer), "*.%s", pDeclaredAssets->getExtension()); // Scan declared assets at location. - if ( !scanDeclaredAssets( filePathBuffer, extensionBuffer, pDeclaredAssets->getRecurse(), pModuleDefinition ) ) + if ( !scanDeclaredAssets( filePathBuffer, extensionBuffer, pDeclaredAssets->getRecurse(), pModuleDefinition ) && mEchoInfo) { // Warn. Con::warnf( "AssetManager::addModuleDeclaredAssets() - No assets found at location '%s' with extension '%s'.", filePathBuffer, pDeclaredAssets->getExtension() ); diff --git a/Templates/BaseGame/game/core/console/scripts/profiles.tscript b/Templates/BaseGame/game/core/console/scripts/profiles.tscript index 097ae7da6..98a407643 100644 --- a/Templates/BaseGame/game/core/console/scripts/profiles.tscript +++ b/Templates/BaseGame/game/core/console/scripts/profiles.tscript @@ -52,7 +52,7 @@ new GuiControlProfile(GuiConsoleTextProfile) category = "Core"; }; -$ConsoleDefaultFillColor = "12 14 19 175"; +$ConsoleDefaultFillColor = "0 0 0 175"; if(!isObject(ConsoleScrollProfile)) new GuiControlProfile(ConsoleScrollProfile : GuiScrollProfile) diff --git a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript index bd3d55604..fe02febfa 100644 --- a/Templates/BaseGame/game/core/gui/scripts/profiles.tscript +++ b/Templates/BaseGame/game/core/gui/scripts/profiles.tscript @@ -267,3 +267,24 @@ new GuiControlProfile(GuiScrollProfile) bitmapAsset = "Core_GUI:scrollBar_image"; category = "Core"; }; + +// --------------------------------------------------------------------------- +singleton GuiControlProfile( GuiInputCtrlProfile ) +{ + tab = true; + canKeyFocus = true; + category = "Core"; +}; + +singleton GuiControlProfile (GuiTextProfile) +{ + justify = "left"; + fontColor = "20 20 20"; + category = "Core"; +}; + +singleton GuiControlProfile (GuiTextRightProfile : GuiTextProfile) +{ + justify = "right"; + category = "Core"; +}; \ No newline at end of file diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript index 10d883bea..f48023dd2 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript @@ -1,4 +1,4 @@ -function GraphicsQualityLevel::isCurrent( %this ) +function OptionsQualityLevel::isCurrent( %this ) { // Test each pref to see if the current value // equals our stored value. @@ -15,7 +15,7 @@ function GraphicsQualityLevel::isCurrent( %this ) return true; } -function GraphicsQualityLevel::apply( %this ) +function OptionsQualityLevel::apply( %this ) { for ( %i=0; %i < %this.count(); %i++ ) { @@ -36,7 +36,7 @@ function GraphicsQualityLevel::apply( %this ) } } -function GraphicsOptionsMenuGroup::applySetting(%this, %settingName) +function OptionsSettings::applySetting(%this, %settingName) { for(%i=0; %i < %this.getCount(); %i++) { @@ -62,78 +62,92 @@ new SimGroup(VideoSettingsGroup) class = "PrimaryOptionsGroup"; displayName = "Video"; - new SimGroup(BasicVideoSettingsGroup) + new SimGroup(VideoDisplaySettingsGroup) { class = "SubOptionsGroup"; - displayName = "Basic"; + displayName = "Display Settings"; - new SimGroup() - { + new SimGroup( VideoAPISettingsGroup ) + { class = "OptionsSettings"; - - OptionName = "Graphical Quality"; - Description = "Controls the general graphical quality"; - - new ArrayObject() - { - class = "OptionsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::TS::detailAdjust"] = 1.0; - key["$pref::TS::skipRenderDLs"] = 0; - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 75; - key["$pref::staticObjectFadeEnd"] = 100; - key["$pref::staticObjectUnfadeableSize"] = 75; - }; - - new ArrayObject() - { - class = "OptionsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::TS::detailAdjust"] = 1.5; - key["$pref::TS::skipRenderDLs"] = 0; - key["$pref::useStaticObjectFade"] = false; - key["$pref::staticObjectFadeStart"] = 75; - key["$pref::staticObjectFadeEnd"] = 100; - key["$pref::staticObjectUnfadeableSize"] = 75; - }; + OptionName = "Display API"; }; - new SimGroup() - { + new SimGroup( DisplayDevicesGroup ) + { class = "OptionsSettings"; - - OptionName = "Lighting Quality"; - Description = "Controls the lighting and shadows quality"; + OptionName = "Display Devices"; + }; + + new SimGroup( DisplayModeGroup ) + { + class = "OptionsSettings"; + OptionName = "Display Mode"; new ArrayObject() { class = "OptionsQualityLevel"; - caseSensitive = true; - - displayName = "High"; + displayName = "Windowed"; - key["$pref::lightManager"] = "Advanced Lighting"; - key["$pref::Shadows::disable"] = false; - key["$pref::Shadows::textureScalar"] = 1.0; - key["$pref::PSSM::detailAdjustScale"] = 1.0; - key["$pref::allowLocalLightShadows"] = true; - }; + key["$pref::Video::deviceMode"] = 0; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Borderless"; + + key["$pref::Video::deviceMode"] = 1; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Fullscreen"; + + key["$pref::Video::deviceMode"] = 2; + }; + }; + + new SimGroup ( DisplayResSettingsGroup ) + { + class = "OptionsSettings"; + OptionName = "Display Resolution"; + }; + + new SimGroup ( VSyncSettingsGroup ) + { + class = "OptionsSettings"; + OptionName = "VSync"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::Video::enableVerticalSync"] = 0; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::Video::enableVerticalSync"] = 1; + }; + }; + + new SimGroup ( DisplayRefreshSettingsGroup ) + { + class = "OptionsSettings"; + OptionName = "Refresh Rate"; }; }; - new SimGroup(AdvancedVideoSettingsGroup) + //General quality settings + new SimGroup() { class = "SubOptionsGroup"; - displayName = "Advanced"; - - new SimGroup() + displayName = "Object Quality"; + + new SimGroup( MeshDetailSettingsGroup ) { class = "OptionsSettings"; @@ -145,36 +159,24 @@ new SimGroup(VideoSettingsGroup) class = "OptionsQualityLevel"; caseSensitive = true; - displayName = "High"; - - key["$pref::TS::detailAdjust"] = 1.5; - key["$pref::TS::skipRenderDLs"] = 0; - }; - - }; - }; - - /*new SimGroup(AdvancedVideoSettingsGroup) - { - groupName = "Advanced"; - - new SimGroup( MeshQualityGroup ) - { - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() + displayName = "Lowest"; + + key["$pref::TS::detailAdjust"] = 0.5; + key["$pref::TS::skipRenderDLs"] = 1; + }; + new ArrayObject() { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; - displayName = "High"; - - key["$pref::TS::detailAdjust"] = 1.5; + displayName = "Low"; + + key["$pref::TS::detailAdjust"] = 0.75; key["$pref::TS::skipRenderDLs"] = 0; - }; + }; new ArrayObject( ) { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "Medium"; @@ -184,46 +186,48 @@ new SimGroup(VideoSettingsGroup) }; new ArrayObject() { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::TS::detailAdjust"] = 0.75; - key["$pref::TS::skipRenderDLs"] = 0; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::TS::detailAdjust"] = 0.5; - key["$pref::TS::skipRenderDLs"] = 1; - }; - }; - - new SimGroup( MeshDrawDistQualityGroup ) - { - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "High"; - key["$pref::useStaticObjectFade"] = false; - key["$pref::staticObjectFadeStart"] = 75; - key["$pref::staticObjectFadeEnd"] = 100; - key["$pref::staticObjectUnfadeableSize"] = 75; - - }; + key["$pref::TS::detailAdjust"] = 1.5; + key["$pref::TS::skipRenderDLs"] = 0; + }; + }; + + new SimGroup( MeshDrawDistQualityGroup ) + { + class = "OptionsSettings"; + OptionName = "Mesh Draw Distance"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Lowest"; + + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 25; + key["$pref::staticObjectFadeEnd"] = 50; + key["$pref::staticObjectUnfadeableSize"] = 200; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::useStaticObjectFade"] = true; + key["$pref::staticObjectFadeStart"] = 50; + key["$pref::staticObjectFadeEnd"] = 75; + key["$pref::staticObjectUnfadeableSize"] = 100; + }; new ArrayObject( ) { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "Medium"; @@ -235,57 +239,37 @@ new SimGroup(VideoSettingsGroup) }; new ArrayObject() { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 50; - key["$pref::staticObjectFadeEnd"] = 75; - key["$pref::staticObjectUnfadeableSize"] = 100; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::useStaticObjectFade"] = true; - key["$pref::staticObjectFadeStart"] = 25; - key["$pref::staticObjectFadeEnd"] = 50; - key["$pref::staticObjectUnfadeableSize"] = 200; - }; - }; - - new SimGroup( TextureQualityGroup ) - { - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "High"; - key["$pref::Video::textureReductionLevel"] = 0; - key["$pref::Reflect::refractTexScale"] = 1.25; - }; + key["$pref::useStaticObjectFade"] = false; + key["$pref::staticObjectFadeStart"] = 75; + key["$pref::staticObjectFadeEnd"] = 100; + key["$pref::staticObjectUnfadeableSize"] = 75; + + }; + }; + + new SimGroup( TextureQualityGroup ) + { + class = "OptionsSettings"; + OptionName = "Texture Quality"; + new ArrayObject() { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; - displayName = "Medium"; - - key["$pref::Video::textureReductionLevel"] = 0; - key["$pref::Reflect::refractTexScale"] = 1; + displayName = "Lowest"; + + key["$pref::Video::textureReductionLevel"] = 2; + key["$pref::Reflect::refractTexScale"] = 0.5; }; new ArrayObject() { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "Low"; @@ -295,441 +279,742 @@ new SimGroup(VideoSettingsGroup) }; new ArrayObject() { - class = "GraphicsQualityLevel"; + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::Video::textureReductionLevel"] = 0; + key["$pref::Reflect::refractTexScale"] = 1; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Video::textureReductionLevel"] = 0; + key["$pref::Reflect::refractTexScale"] = 1.25; + }; + }; + + new SimGroup( GroundCoverDensityGroup ) + { + class = "OptionsSettings"; + OptionName = "Ground Cover Density"; + Description = "Density of ground cover items, such as grass"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Lowest"; + + key["$pref::GroundCover::densityScale"] = 0.25; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Low"; + + key["$pref::GroundCover::densityScale"] = 0.5; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Medium"; + + key["$pref::GroundCover::densityScale"] = 0.75; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "High"; + + key["$pref::GroundCover::densityScale"] = 1.0; + }; + }; + + new SimGroup( DecalLifetimeGroup ) + { + class = "OptionsSettings"; + OptionName = "Decal Life Time"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "None"; + + key["$pref::decalMgr::enabled"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::decalMgr::enabled"] = true; + key["$pref::Decals::lifeTimeScale"] = 0.25; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::decalMgr::enabled"] = true; + key["$pref::Decals::lifeTimeScale"] = 0.5; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::decalMgr::enabled"] = true; + key["$pref::Decals::lifeTimeScale"] = 1; + }; + }; + + new SimGroup( TerrainQualityGroup ) + { + class = "OptionsSettings"; + OptionName = "Terrain Quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; caseSensitive = true; displayName = "Lowest"; - key["$pref::Video::textureReductionLevel"] = 2; - key["$pref::Reflect::refractTexScale"] = 0.5; + key["$pref::Terrain::lodScale"] = 2.0; + key["$pref::Terrain::detailScale"] = 0.5; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Terrain::lodScale"] = 1.5; + key["$pref::Terrain::detailScale"] = 0.75; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::Terrain::lodScale"] = 1.0; + key["$pref::Terrain::detailScale"] = 1.0; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Terrain::lodScale"] = 0.75; + key["$pref::Terrain::detailScale"] = 1.5; + }; + }; + }; + + //Shadows and Lighting + new SimGroup() + { + class = "SubOptionsGroup"; + displayName = "Lighting Quality"; + + new SimGroup( ShadowQualityList ) + { + class = "OptionsSettings"; + OptionName = "Shadow Quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "None"; + + key["$pref::lightManager"] = "Advanced Lighting"; + key["$pref::Shadows::disable"] = true; + key["$pref::Shadows::textureScalar"] = 0.5; + key["$pref::allowLocalLightShadows"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::lightManager"] = "Advanced Lighting"; + key["$pref::Shadows::disable"] = false; + key["$pref::Shadows::textureScalar"] = 0.25; + key["$pref::PSSM::detailAdjustScale"] = 0.25; + key["$pref::allowLocalLightShadows"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::lightManager"] = "Advanced Lighting"; + key["$pref::Shadows::disable"] = false; + key["$pref::Shadows::textureScalar"] = 0.5; + key["$pref::PSSM::detailAdjustScale"] = 0.5; + key["$pref::allowLocalLightShadows"] = true; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::lightManager"] = "Advanced Lighting"; + key["$pref::Shadows::disable"] = false; + key["$pref::Shadows::textureScalar"] = 1.0; + key["$pref::PSSM::detailAdjustScale"] = 1.0; + key["$pref::allowLocalLightShadows"] = true; }; }; - };*/ -}; - -//Fields have display name, populated by group. Direct name association to the fieldset - -new SimGroup( GroundCoverDensityGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::GroundCover::densityScale"] = 1.0; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::GroundCover::densityScale"] = 0.75; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; + new SimGroup( ShadowDistanceList ) + { + class = "OptionsSettings"; + OptionName = "Shadow Distance"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; - key["$pref::GroundCover::densityScale"] = 0.5; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::GroundCover::densityScale"] = 0.25; - }; -}; - -new SimGroup( DecalLifetimeGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::decalMgr::enabled"] = true; - key["$pref::Decals::lifeTimeScale"] = 1; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::decalMgr::enabled"] = true; - key["$pref::Decals::lifeTimeScale"] = 0.5; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::decalMgr::enabled"] = true; - key["$pref::Decals::lifeTimeScale"] = 0.25; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "None"; - - key["$pref::decalMgr::enabled"] = false; - }; -}; - -new SimGroup( TerrainQualityGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::Terrain::lodScale"] = 0.75; - key["$pref::Terrain::detailScale"] = 1.5; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::Terrain::lodScale"] = 1.0; - key["$pref::Terrain::detailScale"] = 1.0; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; + displayName = "Lowest"; - key["$pref::Terrain::lodScale"] = 1.5; - key["$pref::Terrain::detailScale"] = 0.75; + key["$pref::Shadows::drawDistance"] = 0.1; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Shadows::drawDistance"] = 0.25; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::Shadows::drawDistance"] = 0.5; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Shadows::drawDistance"] = 0.75; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Highest"; + + key["$pref::Shadows::drawDistance"] = 1; + }; + }; + + new SimGroup( LightingQualityList ) + { + class = "OptionsSettings"; + OptionName = "Lighting Quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::maximumNumOfLights"] = 5; + key["$pref::useLightFade"] = true; + key["$pref::lightFadeStart"] = 10; + key["$pref::lightFadeEnd"] = 25; + + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::maximumNumOfLights"] = 10; + key["$pref::useLightFade"] = true; + key["$pref::lightFadeStart"] = 25; + key["$pref::lightFadeEnd"] = 50; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::maximumNumOfLights"] = 15; + key["$pref::useLightFade"] = true; + key["$pref::lightFadeStart"] = 50; + key["$pref::lightFadeEnd"] = 75; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Highest"; + + key["$pref::maximumNumOfLights"] = -1; + key["$pref::useLightFade"] = false; + key["$pref::lightFadeStart"] = 50; + key["$pref::lightFadeEnd"] = 75; + }; + }; + + new SimGroup( SoftShadowList ) + { + class = "OptionsSettings"; + OptionName = "Soft Shadowing"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Off"; + + key["$pref::Shadows::filterMode"] = "None"; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Shadows::filterMode"] = "SoftShadow"; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Shadows::filterMode"] = "SoftShadowHighQuality"; + }; + }; + + new SimGroup( LightDistanceList ) + { + class = "OptionsSettings"; + OptionName = "Lights Draw Distance"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Lowest"; + + key["$pref::Lights::drawDistance"] = 0.25; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Lights::drawDistance"] = 0.25; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Medium"; + + key["$pref::Lights::drawDistance"] = 0.5; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Lights::drawDistance"] = 0.75; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Highest"; + + key["$pref::Lights::drawDistance"] = 1; + }; + }; }; - new ArrayObject() + + new SimGroup() { - class = "GraphicsQualityLevel"; - caseSensitive = true; + class = "SubOptionsGroup"; + displayName = "Effects"; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Shader Quality"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "Low"; + + key["$pref::Video::disablePixSpecular"] = true; + key["$pref::Video::disableNormalmapping"] = true; + key["$pref::PostFX::EnableHDRBloom"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + caseSensitive = true; + + displayName = "High"; + + key["$pref::Video::disablePixSpecular"] = false; + key["$pref::Video::disableNormalmapping"] = false; + key["$pref::PostFX::EnableHDRBloom"] = true; + }; + + }; - displayName = "Lowest"; + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Anisotropic Filtering"; + Description = "Amount of Anisotropic Filtering on textures, which dictates their sharpness at a distance"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::Video::defaultAnisotropy"] = 0; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "4x"; + + key["$pref::Video::defaultAnisotropy"] = 4; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "8x"; + + key["$pref::Video::defaultAnisotropy"] = 8; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "16x"; + + key["$pref::Video::defaultAnisotropy"] =16; + }; + }; - key["$pref::Terrain::lodScale"] = 2.0; - key["$pref::Terrain::detailScale"] = 0.5; - }; + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Anti-Aliasing"; + Description = "The Anti-Aliasing Method applied to rendering"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "None"; + + key["$pref::Video::AAMode"] = "None"; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "FXAA"; + + key["$pref::Video::AAMode"] = "FXAA"; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "SMAA"; + + key["$pref::Video::AAMode"] = "SMAA"; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "SMAA High"; + + key["$pref::Video::AAMode"] ="SMAA High"; + }; + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Parallax"; + Description = "Whether the surface parallax shader effect is enabled"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::Video::enableParallaxMapping"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::Video::enableParallaxMapping"] = true; + }; + + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "True Water Reflections"; + Description = "Whether realtime water reflections are enabled"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::Water::enableTrueReflections"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::Water::enableTrueReflections"] = true; + }; + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "SSAO"; + Description = "Whether Screen-Space Ambient Occlusion is enabled"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::PostFX::EnableSSAO"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::PostFX::EnableSSAO"] = true; + }; + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Depth of Field"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::PostFX::EnableDOF"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::PostFX::EnableDOF"] = true; + }; + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Vignette"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::PostFX::EnableVignette"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::PostFX::EnableVignette"] = true; + }; + }; + + new SimGroup() + { + class = "OptionsSettings"; + OptionName = "Light Rays"; + + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "Off"; + + key["$pref::PostFX::EnableLightRays"] = false; + }; + new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = "On"; + + key["$pref::PostFX::EnableLightRays"] = true; + }; + }; + }; }; -//Shadows and Lighting -new SimGroup( ShadowQualityList ) +function VideoSettingsGroup::populateDisplaySettings(%this) { - class = "GraphicsOptionsMenuGroup"; + VideoAPISettingsGroup.clear(); + DisplayDevicesGroup.clear(); + DisplayResSettingsGroup.clear(); + DisplayRefreshSettingsGroup.clear(); - new ArrayObject() + %apiList = ""; + %apiCount = GFXInit::getAdapterCount(); + for(%i=0; %i < %apiCount; %i++) { - class = "GraphicsQualityLevel"; - caseSensitive = true; + %api = GFXInit::getAdapterType(%i); - displayName = "High"; - - key["$pref::lightManager"] = "Advanced Lighting"; - key["$pref::Shadows::disable"] = false; - key["$pref::Shadows::textureScalar"] = 1.0; - key["$pref::PSSM::detailAdjustScale"] = 1.0; - key["$pref::allowLocalLightShadows"] = true; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::lightManager"] = "Advanced Lighting"; - key["$pref::Shadows::disable"] = false; - key["$pref::Shadows::textureScalar"] = 0.5; - key["$pref::PSSM::detailAdjustScale"] = 0.5; - key["$pref::allowLocalLightShadows"] = true; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::lightManager"] = "Advanced Lighting"; - key["$pref::Shadows::disable"] = false; - key["$pref::Shadows::textureScalar"] = 0.25; - key["$pref::PSSM::detailAdjustScale"] = 0.25; - key["$pref::allowLocalLightShadows"] = false; - - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "None"; - - key["$pref::lightManager"] = "Advanced Lighting"; - key["$pref::Shadows::disable"] = true; - key["$pref::Shadows::textureScalar"] = 0.5; - key["$pref::allowLocalLightShadows"] = false; - }; -}; - -new SimGroup( ShadowDistanceList ) -{ - class = "GraphicsOptionsMenuGroup"; + if(%api !$= "NullDevice") + { + %entry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %api; + key["$pref::Video::displayDevice"] = %api; + }; + + VideoAPISettingsGroup.add(%entry); + } + } - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Highest"; - - key["$pref::Shadows::drawDistance"] = 1; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::Shadows::drawDistance"] = 0.75; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::Shadows::drawDistance"] = 0.5; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::Shadows::drawDistance"] = 0.25; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::Shadows::drawDistance"] = 0.1; - }; -}; - -new SimGroup( LightingQualityList ) -{ - class = "GraphicsOptionsMenuGroup"; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Highest"; - - key["$pref::maximumNumOfLights"] = -1; - key["$pref::useLightFade"] = false; - key["$pref::lightFadeStart"] = 50; - key["$pref::lightFadeEnd"] = 75; - }; + %numDevices = Canvas.getMonitorCount(); + + %devicesList = getDisplayDeviceList(); - new ArrayObject() + for(%i=0; %i < getFieldCount(%devicesList); %i++) { - class = "GraphicsQualityLevel"; - caseSensitive = true; + %device = getField(%devicesList, %i); - displayName = "High"; + %entry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %device; + key["$pref::Video::displayDeviceId"] = %device; + }; - key["$pref::maximumNumOfLights"] = 15; - key["$pref::useLightFade"] = true; - key["$pref::lightFadeStart"] = 50; - key["$pref::lightFadeEnd"] = 75; - }; + DisplayDevicesGroup.add(%entry); + } + + %mode = getField($Video::ModeTags, $pref::Video::deviceMode); - new ArrayObject() + if(%mode !$= "Borderless") { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::maximumNumOfLights"] = 10; - key["$pref::useLightFade"] = true; - key["$pref::lightFadeStart"] = 25; - key["$pref::lightFadeEnd"] = 50; - }; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::maximumNumOfLights"] = 5; - key["$pref::useLightFade"] = true; - key["$pref::lightFadeStart"] = 10; - key["$pref::lightFadeEnd"] = 25; + %resolutionList = getScreenResolutionList($pref::Video::deviceId, $Video::Mode[%mode]); + for(%i=0; %i < getFieldCount(%resolutionList); %i++) + { + %rawResolution = getField(%resolutionList, %i); + %prettyResolution = _makePrettyResString(%rawResolution); + + %entry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %prettyResolution; + key["$pref::Video::Resolution"] = %rawResolution; + }; + + DisplayResSettingsGroup.add(%entry); + } + } - }; -}; + %refreshList = getScreenRefreshList($pref::Video::mode); + for(%i=0; %i < getFieldCount(%refreshList); %i++) + { + %refreshRate = getField(%refreshList, %i); -new SimGroup( SoftShadowList ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; + %entry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %refreshRate; + key["$pref::Video::RefreshRate"] = %refreshRate; + }; - displayName = "High"; - - key["$pref::Shadows::filterMode"] = "SoftShadowHighQuality"; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::Shadows::filterMode"] = "SoftShadow"; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Off"; - - key["$pref::Shadows::filterMode"] = "None"; - }; -}; - -new SimGroup( LightDistanceList ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Highest"; - - key["$pref::Lights::drawDistance"] = 1; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::Lights::drawDistance"] = 0.75; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Medium"; - - key["$pref::Lights::drawDistance"] = 0.5; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::Lights::drawDistance"] = 0.25; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Lowest"; - - key["$pref::Lights::drawDistance"] = 0.25; - }; -}; - -new SimGroup( ShaderQualityGroup ) -{ - class = "GraphicsOptionsMenuGroup"; - - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "High"; - - key["$pref::Video::disablePixSpecular"] = false; - key["$pref::Video::disableNormalmapping"] = false; - key["$pref::PostFX::EnableHDRBloom"] = true; - }; - new ArrayObject() - { - class = "GraphicsQualityLevel"; - caseSensitive = true; - - displayName = "Low"; - - key["$pref::Video::disablePixSpecular"] = true; - key["$pref::Video::disableNormalmapping"] = true; - key["$pref::PostFX::EnableHDRBloom"] = false; - }; -}; - + DisplayRefreshSettingsGroup.add(%entry); + } +} function getCurrentQualityLevel(%qualityGroup) { for ( %i=0; %i < %qualityGroup.getCount(); %i++ ) { %level = %qualityGroup.getObject( %i ); if ( %level.isCurrent() ) - return %level.displayName; + return %level; } return "Custom"; @@ -1036,4 +1321,35 @@ function getScreenRefreshList(%resolution) %rateArray.delete(); return %returnsList; +} + +function getDisplayDeviceList() +{ + %numDevices = Canvas.getMonitorCount(); + %devicesList = ""; + for(%i = 0; %i < %numDevices; %i++) + { + %device = (%i+1) @ " - " @ Canvas.getMonitorName(%i); + if(%i==0) + %devicesList = %device; + else + %devicesList = %devicesList @ "\t" @ %device; + } + + return %devicesList; +} + +function getDisplayDeviceId(%displayDeviceName) +{ + %deviceList = getDisplayDeviceList(); + + %deviceCount = getFieldCount(%deviceList); + for(%d = 0; %d < %deviceCount; %d++) + { + %deviceName = getField(%deviceList, %d); + if(%deviceName $= %displayDeviceName) + return %d; + } + + return -1; } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/sfx/Core_SFX.tscript b/Templates/BaseGame/game/core/sfx/Core_SFX.tscript index f0babb90f..771048b32 100644 --- a/Templates/BaseGame/game/core/sfx/Core_SFX.tscript +++ b/Templates/BaseGame/game/core/sfx/Core_SFX.tscript @@ -7,7 +7,7 @@ function Core_SFX::onCreate(%this) exec("./scripts/audioDescriptions." @ $TorqueScriptFileExtension); exec("./scripts/audioEnvironments." @ $TorqueScriptFileExtension); exec("./scripts/audioStates." @ $TorqueScriptFileExtension); - + exec("./scripts/audioOptions." @ $TorqueScriptFileExtension); } function Core_SFX::onDestroy(%this) diff --git a/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript b/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript new file mode 100644 index 000000000..19417c2e4 --- /dev/null +++ b/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript @@ -0,0 +1,82 @@ +new SimGroup(AudioSettingsGroup) +{ + class = "PrimaryOptionsGroup"; + displayName = "Audio"; + + new SimGroup() + { + class = "SubOptionsGroup"; + displayName = "Audio Devices"; + + new SimGroup(AudioSettingsProviderGroup) + { + class = "AudioOptionsSettings"; + + OptionName = "Audio Provider"; + Description = ""; + }; + + new SimGroup(AudioSettingsDeviceGroup) + { + class = "AudioOptionsSettings"; + + OptionName = "Audio Device"; + Description = ""; + }; + }; +}; + +function AudioSettingsGroup::populateSettings(%this) +{ + AudioSettingsProviderGroup.clear(); + AudioSettingsDeviceGroup.clear(); + + %buffer = sfxGetAvailableDevices(); + %count = getRecordCount( %buffer ); + + for(%i = 0; %i < %count; %i++) + { + %record = getRecord(%buffer, %i); + %provider = getField(%record, 0); + %device = getField(%record, 1); + + //When the client is actually running, we don't care about null audo devices + if(%provider $= "null") + continue; + + //We can't have duplicate providers, so double check for uniqueness + %foundProvider = false; + foreach(%registeredProviders in AudioSettingsProviderGroup) + { + if(%registeredProviders.displayName $= %provider) + { + %foundProvider = true; + break; + } + } + + if(!%foundProvider) + { + //Provider entry + %providerEntry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %provider; + key["$pref::SFX::provider"] = %provider; + }; + + AudioSettingsProviderGroup.add(%providerEntry); + } + + //Device Entry + %deviceEntry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %device; + provider = %provider; //this is for filtering later, if we need to + key["$pref::SFX::device"] = %device; + }; + + AudioSettingsDeviceGroup.add(%deviceEntry); + } +} diff --git a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript index cb4f84431..913b088fc 100644 --- a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript @@ -17,13 +17,20 @@ addKeyRemap("Ascend", "ExampleMoveMap", "keyboard", "moveup", "Makes the camera addKeyRemap("Descend", "ExampleMoveMap", "keyboard", "movedown", "Makes the camera descend"); addKeyRemap("Jump", "ExampleMoveMap", "keyboard", "jump", "Jump"); +addKeyRemap("Forward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Forward Movement"); +addKeyRemap("Backward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Backward Movement"); +addKeyRemap("Strafe Left", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Left Strafing Movement"); +addKeyRemap("Strafe Right", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Right Strafing Movement"); +addKeyRemap("Jump", "ExampleMoveMap", "gamepad", "jump", "Jump"); + //------------------------------------------------------------------------------ // Non-remapable binds //------------------------------------------------------------------------------ ExampleMoveMap.bind( keyboard, F2, showPlayerList ); ExampleMoveMap.bind(keyboard, "ctrl h", hideHUDs); ExampleMoveMap.bind(keyboard, "alt p", doScreenShotHudless); -ExampleMoveMap.bindCmd(keyboard, "escape", "", "Canvas.pushDialog(PauseMenu);"); +ExampleMoveMap.bindCmd(keyboard, "escape", "", "Canvas.pushDialog(GameMenu);"); +ExampleMoveMap.bindCmd(gamepad, btn_start, "Canvas.pushDialog(GameMenu);", "" ); //------------------------------------------------------------------------------ // Movement Keys diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index 39ecf2ef5..646a55101 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -73,7 +73,7 @@ function ChooseLevelMenu::onWake(%this) position = "0 0"; extent = "480 480"; buttonType = "ToggleButton"; - profile = LevelPreviewButtonProfile; + profile = GuiMenuButtonLeftJustProfile; horizSizing = "width"; vertSizing = "height"; internalName = "button"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index f7a6daa70..6fb19d7e1 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -32,8 +32,8 @@ $guiContent = new GuiControl(OptionsMenu) { stackingType = "Horizontal"; padding = "10"; dynamicSize = "0"; - position = "430 0"; - extent = "420 40"; + position = "330 0"; + extent = "650 40"; horizSizing = "center"; vertSizing = "center"; profile = "GuiDefaultProfile"; @@ -55,11 +55,19 @@ $guiContent = new GuiControl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiButtonCtrl() { - text = "Controls"; + text = "Keyboard/Mouse"; position = "260 0"; + extent = "220 40"; + profile = "GuiMenuButtonProfile"; + command = "OptionsMenu.openOptionsCategory(\"KBM\");"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiButtonCtrl() { + text = "Controller"; + position = "480 0"; extent = "160 40"; profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.openOptionsCategory(\"Controls\");"; + command = "OptionsMenu.openOptionsCategory(\"Controller\");"; tooltipProfile = "GuiToolTipProfile"; }; }; @@ -98,6 +106,7 @@ $guiContent = new GuiControl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; new GuiStackControl(VideoSettingsList) { + class = "OptionsMenuList"; padding = "5"; changeChildSizeToFit = "0"; position = "0 1"; @@ -108,6 +117,7 @@ $guiContent = new GuiControl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiStackControl(AudioSettingsList) { + class = "OptionsMenuList"; padding = "5"; changeChildSizeToFit = "0"; position = "0 1"; @@ -119,7 +129,21 @@ $guiContent = new GuiControl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; hidden = "1"; }; - new GuiStackControl(ControlSettingsList) { + new GuiStackControl(KBMControlsList) { + class = "OptionsMenuList"; + padding = "5"; + changeChildSizeToFit = "0"; + position = "0 1"; + extent = "800 200"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiDefaultProfile"; + visible = "0"; + tooltipProfile = "GuiToolTipProfile"; + hidden = "1"; + }; + new GuiStackControl(GamepadControlsList) { + class = "OptionsMenuList"; padding = "5"; changeChildSizeToFit = "0"; position = "0 1"; @@ -174,7 +198,7 @@ $guiContent = new GuiControl(OptionsMenu) { makeIconSquare = "1"; textLocation = "Center"; text = "Reset"; - position = "947 0"; + position = "1135 0"; extent = "140 40"; horizSizing = "left"; vertSizing = "center"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index d2c3fbb8c..9437a6b57 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -52,7 +52,8 @@ $optionsEntryPad = 10; $OptionsMenuCategories[0] = "Video"; $OptionsMenuCategories[1] = "Audio"; -$OptionsMenuCategories[2] = "Controls"; +$OptionsMenuCategories[2] = "KBM"; +$OptionsMenuCategories[3] = "Controller"; function OptionsMenu::onAdd(%this) { @@ -75,48 +76,13 @@ function OptionsMenu::onWake(%this) { %this.unappliedChanges.empty(); - VideoSettingsList.clear(); + %this.populateVideoSettings(); - for(%i=0; %i < VideoSettingsGroup.getCount(); %i++) - { - %setting = VideoSettingsGroup.getObject(%i); - - echo(" OptionsMenu::onWake() - video: " @ %setting.class); - if(%setting.class $= "SubOptionsGroup") - { - %entry = addOptionGroup(); - %entry.text = %setting.displayName; - - if(isObject(%entry)) - VideoSettingsList.add(%entry); - - for(%s=0; %s < %setting.getCount(); %s++) - { - %option = %setting.getObject(%s); - - %optionsEntry = addOptionEntry(%option); - - if(isObject(%optionsEntry)) - { - %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y); - - VideoSettingsList.add(%optionsEntry); - } - } - } - else if(%setting.class $= "OptionsSettings") - { - %optionsEntry = addOptionEntry(%option); - - if(isObject(%optionsEntry)) - { - %optionsEntry.resize(0, 0, VideoSettingsList.extent.x, %optionsEntry.extent.y); - - VideoSettingsList.add(%optionsEntry); - } - } - } + %this.populateAudioSettings(); + %this.populateKBMControls(); + + %this.populateGamepadControls(); //establish the cached prefs values here %this.openOptionsCategory("Video"); @@ -148,30 +114,73 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( gamepad, btn_x, OptionsMenuReset ); } -function VideoSettingsList::syncGui(%this) +function OptionsMenuList::syncGui(%this) { %this.callOnChildren("setHighlighted", false); %btn = %this.getObject(%this.listPosition); - if(%btn.class $= "OptionsListEntry") + if(%btn.class $= "OptionsListEntry" || + %btn.class $= "OptionsListSliderEntry" || + %btn.class $= "OptionsKeybindEntry") %btn-->button.setHighlighted(true); -} + + //iterate over the items and ensure that they are formatted well based on the settings selected + foreach(%option in %this) + { + %container = %option-->valuesContainer; + + if(%option.class $= "OptionsListEntry") + { + %hasLevels = %option.optionsObject.getCount() <= 1; + + %optionObject = %option.optionsObject; + + //If it's out of range of the options, it's probably a custom value + if(%option.currentOptionIndex < %optionObject.getCount() && %option.currentOptionIndex >= 0) + { + %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + %currentOptionLevelTxt = %currentOptionLevel.displayName; + } + else + { + %currentOptionLevelTxt = "Custom"; + } + + %optionValTextWidth = %option-->optionValue.profile.getStringWidth(%currentOptionLevelTxt); + + %option-->optionValue.resize(%container.extent.x - %container-->prevValButton.extent.x - %optionValTextWidth - 20, 0, + %optionValTextWidth + 20, %container.extent.y); + + %option-->optionValue.text = %currentOptionLevelTxt; + + %container-->prevValButton.position.x = %option-->optionValue.position.x - 20; + %container-->nextValButton.position.x = %container.extent.x - %container-->prevValButton.extent.x; -function AudioSettingsList::syncGui(%this) -{ - -} - -function ControlSettingsList::syncGui(%this) -{ - + //if there's no alternatives, disable the left/right buttons + %container-->prevValButton.setHidden(%hasLevels); + %container-->nextValButton.setHidden(%hasLevels); + } + else if(%option.class $= "OptionsListSliderEntry") + { + } + else if(%option.class $= "OptionsKeybindEntry") + { + %bindImgAsset = getButtonBitmap(%option.device, getField(%option.keymap, 1)); + + if(%bindImgAsset $= "UI:Keyboard_Black_Blank_image") + %bindImgAsset = ""; + + %container-->bindButton.setBitmap(%bindImgAsset); + } + } } function OptionsMenu::openOptionsCategory(%this, %categoryName) { VideoSettingsList.setVisible(%categoryName $= "Video"); AudioSettingsList.setVisible(%categoryName $= "Audio"); - ControlSettingsList.setVisible(%categoryName $= "Controls"); + KBMControlsList.setVisible(%categoryName $= "KBM"); + GamepadControlsList.setVisible(%categoryName $= "Controller"); if(%categoryName $= "Video") { @@ -190,12 +199,18 @@ function OptionsMenu::openOptionsCategory(%this, %categoryName) %this.currentCatgeoryIdx = 1; } - else if(%categoryName $= "Controls") + else if(%categoryName $= "KBM") { - $MenuList = ControlSettingsList; + $MenuList = KBMControlsList; %this.currentCatgeoryIdx = 2; } + else if(%categoryName $= "Controller") + { + $MenuList = GamepadControlsList; + + %this.currentCatgeoryIdx = 3; + } $MenuList.syncGui(); %this.syncGui(); @@ -265,7 +280,9 @@ function OptionMenuNavigatePrev(%val) if(%val) { $MenuList.listPosition -= 1; - while( $MenuList.listPosition >= 0 && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry) + while( $MenuList.listPosition >= 0 && ($MenuList.getObject($MenuList.listPosition).class !$= "OptionsListEntry" && + $MenuList.getObject($MenuList.listPosition).class !$= "OptionsListSliderEntry" && + $MenuList.getObject($MenuList.listPosition).class !$= "OptionsKeybindEntry")) { $MenuList.listPosition -= 1; } @@ -282,7 +299,9 @@ function OptionMenuNavigateNext(%val) if(%val) { $MenuList.listPosition += 1; - while($MenuList.listPosition < $MenuList.getCount() && $MenuList.getObject($MenuList.listPosition).class !$= OptionsListEntry) + while($MenuList.listPosition < $MenuList.getCount() && ($MenuList.getObject($MenuList.listPosition).class !$= "OptionsListEntry" && + $MenuList.getObject($MenuList.listPosition).class !$= "OptionsListSliderEntry" && + $MenuList.getObject($MenuList.listPosition).class !$= "OptionsKeybindEntry")) { $MenuList.listPosition += 1; } @@ -304,32 +323,50 @@ function OptionMenuStickNavigate(%val) function OptionMenuPrevSetting(%val) { + if(!%val) + return; + %option = $MenuList.getObject($MenuList.listPosition); - echo("Option: " @ %option.className); - %optionObject = %option.optionsObject; - %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - %option.currentOptionIndex = mClamp(%option.currentOptionIndex-1, 0, %optionObject.getCount()-1); - - %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - - echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + if(!isObject(%option)) + return; + + if(%option.class !$= "OptionsListEntry") + { + %optionObject = %option.optionsObject; + %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + %option.currentOptionIndex = mClamp(%option.currentOptionIndex-1, 0, %optionObject.getCount()-1); + + %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + } $MenuList.syncGUI(); } function OptionMenuNextSetting(%val) { + if(!%val) + return; + %option = $MenuList.getObject($MenuList.listPosition); - echo("Option: " @ %option.className); - %optionObject = %option.optionsObject; - %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - %option.currentOptionIndex = mClamp(%option.currentOptionIndex+1, 0, %optionObject.getCount()-1); - - %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - - echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + if(!isObject(%option) ) + return; + + if(%option.class !$= "OptionsListEntry") + { + %optionObject = %option.optionsObject; + %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + %option.currentOptionIndex = mClamp(%option.currentOptionIndex+1, 0, %optionObject.getCount()-1); + + %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); + + echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + } $MenuList.syncGUI(); } @@ -339,6 +376,208 @@ function OptionMenuStickChangeSetting(%val) } +// +// +// +function OptionsMenu::populateVideoSettings(%this) +{ + VideoSettingsList.clear(); + + VideoSettingsGroup::populateDisplaySettings(); + + for(%i=0; %i < VideoSettingsGroup.getCount(); %i++) + { + %setting = VideoSettingsGroup.getObject(%i); + + if(%setting.class $= "SubOptionsGroup") + { + %entry = addOptionGroup(%setting.displayName); + + if(isObject(%entry)) + VideoSettingsList.add(%entry); + + for(%s=0; %s < %setting.getCount(); %s++) + { + %option = %setting.getObject(%s); + + %optionsEntry = addOptionEntry(%option); + + if(isObject(%optionsEntry)) + VideoSettingsList.add(%optionsEntry); + } + } + else if(%setting.class $= "OptionsSettings") + { + %optionsEntry = addOptionEntry(%setting); + + if(isObject(%optionsEntry)) + VideoSettingsList.add(%optionsEntry); + } + } + + //Ensure our newly templated options listings are sized right + for(%i=0; %i < VideoSettingsList.getCount(); %i++) + { + %entry = VideoSettingsList.getObject(%i); + %entry.resize(0, 0, VideoSettingsList.extent.x - 15, %entry.extent.y); //-10 for the scroll wheel pad + } +} + +function OptionsMenu::populateAudioSettings(%this) +{ + AudioSettingsList.clear(); + AudioSettingsGroup.populateSettings(); + + //Process the lists + for(%i=0; %i < AudioSettingsGroup.getCount(); %i++) + { + %setting = AudioSettingsGroup.getObject(%i); + + if(%setting.class $= "SubOptionsGroup") + { + %entry = addOptionGroup(%setting.displayName); + + if(isObject(%entry)) + AudioSettingsList.add(%entry); + + for(%s=0; %s < %setting.getCount(); %s++) + { + %option = %setting.getObject(%s); + + %optionsEntry = addOptionEntry(%option); + + if(isObject(%optionsEntry)) + AudioSettingsList.add(%optionsEntry); + } + } + else if(%setting.class $= "AudioOptionsSettings") + { + %optionsEntry = addOptionEntry(%setting); + + if(isObject(%optionsEntry)) + AudioSettingsList.add(%optionsEntry); + } + } + + AudioSettingsList.add(addOptionGroup("Channel Volume")); + + AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 0.1)); + AudioSettingsList.add(addOptionSlider("GUI Volume", "", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0, 1, 0.1)); + AudioSettingsList.add(addOptionSlider("Effects Volume", "", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0, 1, 0.1)); + AudioSettingsList.add(addOptionSlider("Music Volume", "", "$pref::SFX::channelVolume[" @ $MusicAudioType @ "]", 0, 1, 0.1)); + + //Ensure our newly templated options listings are sized right + for(%i=0; %i < AudioSettingsList.getCount(); %i++) + { + %entry = AudioSettingsList.getObject(%i); + %entry.resize(0, 0, AudioSettingsList.extent.x - 15, %entry.extent.y); //-10 for the scroll wheel pad + } +} + +function OptionsMenu::populateKBMControls(%this) +{ + //$remapListDevice = "keyboard"; + %this.populateKeybinds("keyboard", KBMControlsList); + + %this.syncGui(); +} + +function OptionsMenu::populateGamepadControls(%this) +{ + //$remapListDevice = ; + %this.populateKeybinds("gamepad", GamepadControlsList); + + %this.syncGui(); +} + +function OptionsMenu::populateKeybinds(%this, %device, %controlsList) +{ + //%device = $remapListDevice; + + %controlsList.clear(); + + //build out our list of action maps + %actionMapCount = ActionMapGroup.getCount(); + + %actionMapList = ""; + for(%i=0; %i < %actionMapCount; %i++) + { + %actionMap = ActionMapGroup.getObject(%i); + + if(%actionMap == GlobalActionMap.getId()) + continue; + + %actionMapName = %actionMap.humanReadableName $= "" ? %actionMap.getName() : %actionMap.humanReadableName; + + //see if we have any actual listed remappable keys for this movemap. if so, drop it from the listing + %hasRemaps = false; + for ( %r = 0; %r < $RemapCount; %r++ ) + { + %testMapName = $RemapActionMap[%r].humanReadableName $= "" ? $RemapActionMap[%r].getName() : $RemapActionMap[%r].humanReadableName; + + if(%actionMapName $= %testMapName) + { + //got a match to at least one, so we're ok to continue + %hasRemaps = true; + break; + } + } + + if(!%hasRemaps) + continue; + + if(%actionMapList $= "") + %actionMapList = %actionMapName; + else + %actionMapList = %actionMapList TAB %actionMapName; + } + + //If we didn't find any valid actionMaps, then just exit out + if(%actionMapList $= "") + return; + + if($activeRemapControlSet $= "") + $activeRemapControlSet = getField(%actionMapList, 0); + + if(getFieldCount(%actionMapList) > 1) + { + for(%am = 0; %am < getFieldCount(%actionMapList); %am++) + { + %currentActionMap = getField(%actionMapList, %am); + + %actionMapGroupEntry = addOptionGroup(%currentActionMap); + %controlsList.add(%actionMapGroupEntry); + + for ( %i = 0; %i < $RemapCount; %i++ ) + { + if(%device !$= "" && %device !$= $RemapDevice[%i]) + continue; + + %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; + + if(%currentActionMap !$= %actionMapName) + continue; + + %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device ); + + %description = $RemapDescription[%i]; + + %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %description); + %controlsList.add(%remapEntry); + } + } + } + + //Ensure our newly templated options listings are sized right + for(%i=0; %i < %controlsList.getCount(); %i++) + { + %entry = %controlsList.getObject(%i); + %entry.resize(0, 0, %controlsList.extent.x - 15, %entry.extent.y); //-10 for the scroll wheel pad + } +} +// +// old +// //We capitalize on the canClose test here, because we want to prompt for unapplied options changes before //backing out. So when the UINavigation test canClose, we can see if we have unapplied settings and prompt //that via the message box and return false. @@ -377,22 +616,6 @@ function OptionsMenu::onClose(%this) } -function OptionsMenuSettingsList::onAdd(%this) -{ -} - -function OptionsMenuSettingsList::getOptionsList(%this, %index) -{ -} - -function OptionsMenu::select(%this) -{ - if(OptionsMenuCategoryList.isActiveMenuList()) - { - OptionsMenuSettingsList.setAsActiveMenuList(); - } -} - function OptionsMenu::apply(%this) { //Now we run through our list of unapplied changes and... apply them. @@ -537,67 +760,8 @@ function OptionsMenu::resetToDefaults(%this) MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", ""); } -function OptionsMenu::refresh(%this) -{ - //cache our scroll position so we can ensure we end up back at it after the refresh - %lastScrollPos = OptionsMenuSettingsScroll.getScrollPosition(); - - %cat = %this.currentCategory; - if(%this.currentCategory !$= "") - { - if(!isInt(%this.currentCategory)) - { - %this.currentCategory = getOptionsCategoryIndexByName(%this.currentCategory); - } - - if(%this.currentCategory == -1) - return; - - %category = %this.optionsCategories.getKey(%this.currentCategory); - %command = %this.optionsCategories.getValue(%this.currentCategory); - eval(%command); - } - - //now, because we reconstruct the displayed set, we'll force the mouse(if we're using it as our input) - //to be poked so we can re-track to whatever control, if any, we're over - if($activeControllerType !$= "gamepad") - { - Canvas.setCursorPos(Canvas.getCursorPos()); - } - - //restore scroll position - OptionsMenuSettingsScroll.setScrollPosition(%lastScrollPos.x, %lastScrollPos.y); -} - -function OptionsMenu::getOptionVariableValue(%this, %variableName) -{ - %unappliedPrefIndex = %this.unappliedChanges.getIndexFromKey(%variableName); - if(%unappliedPrefIndex != -1) - { - %value = %this.unappliedChanges.getValue(%unappliedPrefIndex); - return strreplace(%value, "\"", ""); - } - - %sanitizedVar = strReplace(%variableName, "[", ""); - %sanitizedVar = strReplace(%sanitizedVar, "]", ""); - %sanitizedVar = strReplace(%sanitizedVar, ",", "_"); - return getVariable(%sanitizedVar); -} - -function OptionsMenuSelectButton::onVisible(%this, %state) -{ - //We're sorta cheating here. - //This button should only be displayed when we're in the categories list - //so whenever the status changes, such as automatically refreshing due to - //navigation events, we'll just do a quick check to ensure we're - //in the right visibility mode - if(%state && OptionsMenuSettingsList.isActiveMenuList()) - { - %this.setHidden(true); - } -} -// // +// old ones // function populateDisplaySettingsList() { @@ -686,7 +850,7 @@ function populateDisplaySettingsList() } // -// +// // function populateGraphicsSettingsList() { @@ -775,7 +939,7 @@ function updateGraphicsSettings() } } -function updateDisplaySettings() +/*function updateDisplaySettings() { //Update the display settings now %deviceName = getDisplayDeviceName(); @@ -851,7 +1015,7 @@ function updateDisplaySettings() $pref::Video::AA = %newAA; configureCanvas(); } -} +}*/ function updatePostFXSettings() { @@ -959,328 +1123,6 @@ function updateAudioSettings() // // // -function populateKeyboardMouseSettingsList() -{ - OptionsMenuSettingsList.clear(); - - OptionsMenu.currentCategory = "Keyboard & Mouse"; - - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); - - $remapListDevice = "keyboard"; - fillRemapList(); - - //OptionsMenuSettingsList.refresh(); -} - -function populateGamepadSettingsList() -{ - OptionsMenuSettingsList.clear(); - - OptionsMenu.currentCategory = "Gamepad"; - - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); - - $remapListDevice = "gamepad"; - fillRemapList(); - - OptionsMenuSettingsList.updateStack(); -} - -// -// -// -function getDisplayDeviceList() -{ - %numDevices = Canvas.getMonitorCount(); - %devicesList = ""; - for(%i = 0; %i < %numDevices; %i++) - { - %device = (%i+1) @ " - " @ Canvas.getMonitorName(%i); - if(%i==0) - %devicesList = %device; - else - %devicesList = %devicesList @ "\t" @ %device; - } - - return %devicesList; -} - -function getDisplayDeviceId(%displayDeviceName) -{ - %deviceList = getDisplayDeviceList(); - - %deviceCount = getFieldCount(%deviceList); - for(%d = 0; %d < %deviceCount; %d++) - { - %deviceName = getField(%deviceList, %d); - if(%deviceName $= %displayDeviceName) - return %d; - } - - return -1; -} -// -// -// -function OptionsMenuList::activateRow(%this) -{ - //OptionsMenuSettingsList.setFirstResponder(); - OptionsMenuSettingsList.setAsActiveMenuList(); -} - -function OptionsMenuSettingsList::setRowEnabled(%this, %row, %status) -{ - %option = %this.getObject(%row); - if(isObject(%option)) - { - %option.setEnabled(%status); - } -} - -function OptionsMenuSettingsList::addOptionRow(%this, %label, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled, %description, %defaultValue) -{ - if(%enabled $= "") - %enabled = true; - - %optionsRowSize = 30; - %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text? - - %option = new GuiGameSettingsCtrl() { - class = "MenuOptionsButton"; - profile = "GuiMenuButtonProfile"; - horizSizing = "width"; - vertSizing = "bottom"; - position = "0 0"; - extent = %this.extent.x SPC %optionsRowSize; - columnSplit = %optionColumnWidth; - useMouseEvents = true; - previousBitmapAsset = "UI:previousOption_n_image"; - nextBitmapAsset = "UI:nextOption_n_image"; - }; - - %option.targetPrefVar = %targetPrefVar; //create a var-option association - - if(%defaultValue $= "") - { - %unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetPrefVar); - if(%unappliedPrefIndex != -1) - { - %value = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex); - %defaultValue = strreplace(%value, "\"", ""); - } - - if(%defaultValue $= "") - { - %sanitizedVar = strReplace(%targetPrefVar, "[", ""); - %sanitizedVar = strReplace(%sanitizedVar, "]", ""); - %sanitizedVar = strReplace(%sanitizedVar, ",", "_"); - %defaultValue = getVariable(%sanitizedVar); - } - } - - /*if(%defaultValue $= "Off" || %defaultValue $= "No") - %defaultValue = "0"; - if(%defaultValue $= "On" || %defaultValue $= "Yes") - %defaultValue = "1";*/ - - %option.setListSetting(%label, %optionsList, %wrapOptions, %callback, %enabled, %description, %defaultValue); - - %this.add(%option); -} - -function OptionsMenuSettingsList::addOptionQualityLevelRow(%this, %label, %targetPrefVar, %qualityLevelList, %wrapOptions, %callback, %enabled, %description, %defaultValue) -{ - if(%defaultValue $= "") - { - %unappliedPrefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetPrefVar); - if(%unappliedPrefIndex != -1) - { - %value = OptionsMenu.unappliedChanges.getValue(%unappliedPrefIndex); - %defaultValue = strreplace(%value, "\"", ""); - } - - if(%defaultValue $= "") - { - %sanitizedVar = strReplace(%targetPrefVar, "[", ""); - %sanitizedVar = strReplace(%sanitizedVar, "]", ""); - %sanitizedVar = strReplace(%sanitizedVar, ",", "_"); - %defaultValue = getVariable(%sanitizedVar); - } - - if(%defaultValue $= "") - %defaultValue = getCurrentQualityLevel(%qualityLevelList); - } - - return %this.addOptionRow(%label, %targetPrefVar, getQualityLevels(%qualityLevelList), - %wrapOptions, %callback, %enabled, %description, %defaultValue); -} - -function OptionsMenuSettingsList::addOptionBoolRow(%this, %label, %targetPrefVar, %qualityLevelList, %wrapOptions, %callback, %enabled, %description, %defaultValue, %inverted) -{ - if(%defaultValue $= "") - %defaultValue = OptionsMenu.getOptionVariableValue(%targetPrefVar); - - if(%inverted $= "") - %inverted = false; - - //Lame and hacky, but some variables are 'disabled' and some are 'enabled' - if(isInt(%defaultValue) && %inverted) - { - if(%defaultValue == 0) - %defaultValue = 1; - else - %defaultValue = 0; - } - - if(%qualityLevelList $= $yesNoList && isInt(%defaultValue)) - { - %defaultValue = convertBoolToYesNo(%defaultValue); - } - else if(%qualityLevelList $= $onOffList && isInt(%defaultValue)) - { - %defaultValue = convertBoolToOnOff(%defaultValue); - } - - return %this.addOptionRow(%label, %targetPrefVar, %qualityLevelList, - %wrapOptions, %callback, %enabled, %description, %defaultValue); -} - -function OptionsMenuSettingsList::addSliderRow(%this, %label, %targetPrefVar, %increment, %range, %callback, %enabled, %description, %defaultValue) -{ - if(%enabled $= "") - %enabled = true; - - %optionsRowSize = 30; - %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text? - - %option = new GuiGameSettingsCtrl() { - class = "MenuOptionsButton"; - profile = "GuiMenuButtonProfile"; - horizSizing = "width"; - vertSizing = "bottom"; - position = "0 0"; - extent = %this.extent.x SPC %optionsRowSize; - columnSplit = %optionColumnWidth; - useMouseEvents = true; - }; - - %option.targetPrefVar = %targetPrefVar; //create a var-option association - - if(%defaultValue $= "") - %defaultValue = OptionsMenu.getOptionVariableValue(%targetPrefVar); - - %option.setSliderSetting(%label, %defaultValue, %increment, %range, %callback, %enabled, %description); - - %this.add(%option); -} - -function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %callback, %enabled, %description, %remapIndex) -{ - if(%enabled $= "") - %enabled = true; - - %optionsRowSize = 40; - %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text? - - %option = new GuiGameSettingsCtrl() { - class = "MenuOptionsButton"; - profile = "GuiMenuButtonProfile"; - horizSizing = "width"; - vertSizing = "bottom"; - position = "0 0"; - extent = %this.extent.x SPC %optionsRowSize; - columnSplit = %optionColumnWidth; - useMouseEvents = true; - }; - - %option.remapIndex = %remapIndex; - - %option.setKeybindSetting(%label, %bitmapName, %callback, %enabled, %description); - - %this.add(%option); -} - -// -function OptionsMenuCategoryList::onNavigate(%this, %index) -{ - OptionsMenu.currentCategory = %index; - %this.getObject(%index).performClick(); -} - -function convertOptionToBool(%val) -{ - if(%val $= "yes" || %val $= "on") - return 1; - else - return 0; -} - -function convertBoolToYesNo(%val) -{ - if(%val == 1) - return "Yes"; - else if(%val == 0) - return "No"; - - return %val; -} - -function convertBoolToOnOff(%val) -{ - if(%val == 1) - return "On"; - else if(%val == 0) - return "Off"; - - return %val; -} - -function getDisplayDeviceName() -{ - %numDevices = Canvas.getMonitorCount(); - %devicesList = ""; - for(%i = 0; %i < %numDevices; %i++) - { - %device = (%i+1) @ " - " @ Canvas.getMonitorName(%i); - if(%i==0) - %devicesList = %device; - else - %devicesList = %devicesList @ "\t" @ %device; - } - - return getField(%devicesList, $pref::Video::deviceId); -} -// -// -// -function MenuOptionsButton::onMouseEnter(%this) -{ - if(isObject(OptionName)) - OptionName.setText(%this.getLabel()); - if(isObject(OptionDescription)) - OptionDescription.setText(%this.getToolTip()); -} - -function MenuOptionsButton::onMouseLeave(%this) -{ - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); -} - -function MenuOptionsButton::onHighlighted(%this, %state) -{ - MenuListButton::onHighlighted(%this, %state); -} - function MenuOptionsButton::onChange(%this) { %optionMode = %this.getMode(); @@ -1347,71 +1189,14 @@ function OptionsMenu::onKeybindChanged(%this, %actionMap, %keybind) } // -// Indicates what category the options item should be added into +// new // -function addOptionsMenuCategory(%categoryName, %selectCallback) -{ - //Don't add duplicates! - %index = OptionsMenu.optionsCategories.getIndexFromKey(%categoryName); - if(%index == -1) - OptionsMenu.optionsCategories.add(%categoryName, %selectCallback); -} - -function removeOptionsMenuCategory(%categoryName) -{ - %index = OptionsMenu.optionsCategories.getIndexFromKey(%categoryName); - if(%index != -1) - OptionsMenu.optionsCategories.erase(%index); -} - -function getOptionsCategoryIndexByName(%categoryName) -{ - for(%i=0; %i < OptionsMenu.optionsCategories.count(); %i++) - { - if(OptionsMenu.optionsCategories.getKey(%i) $= %categoryName) - return %i; - } - - return -1; -} - -function addListOption(%label, %description, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled) -{ - if(%wrapOptions $= "") - %wrapOptions = false; - - if(%enabled $= "") - %enabled = true; - - OptionsMenuSettingsList.addOptionRow(%label, %targetPrefVar, %optionsList, %wrapOptions, %callback, %enabled, %description, %targetPrefVar); -} - -function addSliderOption(%label, %description, %targetPrefVar, %defaultValue, %increment, %range, %callback, %enabled) -{ - if(%enabled $= "") - %enabled = true; - - OptionsMenuSettingsList.addSliderRow(%label, %targetPrefVar, %defaultValue, %increment, %range, %callback, %enabled, %description); -} - -function addKeybindOption(%label, %description, %bitmapName, %callback, %enabled) -{ - if(%enabled $= "") - %enabled = true; - - OptionsMenuSettingsList.addSliderRow(%label, %bitmapName, %callback, %enabled, %description); -} - - -// -// -// -function addOptionGroup() +function addOptionGroup(%displayName) { %group = new GuiTextCtrl() { - text = "Graphics"; + text = %displayName; position = "0 0"; - extent = "500 30"; + extent = "500 45"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; @@ -1427,23 +1212,35 @@ function optionsMenuButton::onHighlighted(%this, %highlighted) %container-->optionDescription.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile; %valuesContainer = %container-->valuesContainer; - %valuesContainer-->optionValue.profile = %highlighted ? GuiMenuTextProfileHighlighted : GuiMenuTextProfile; -} - -function optionsMenuButton::onMouseDown(%this) -{ - //check if we're clicking on the left or right of the value and adjust it accordingly + %valuesContainer-->optionValue.profile = %highlighted ? GuiMenuTextProfileHL : GuiMenuTextProfile; + + OptionsMenuSettingsScroll.scrollToObject(%container); } function addOptionEntry(%optionObj) { - if(!isObject(%optionObj) || %optionObj.class !$= "OptionsSettings") + if(!isObject(%optionObj) || (%optionObj.class !$= "OptionsSettings" && %optionObj.class !$= "AudioOptionsSettings")) { error("addOptionsEntry() - attempting to create a new options entry, but was provided an invalid options object"); return 0; } - %qualityLevel = %optionObj.getObject(0); + %qualityLevel = getCurrentQualityLevel(%optionObj); + + if(isObject(%qualityLevel)) + { + %qualityLevelText = %qualityLevel.displayName; + %qualityLevelIndex = %optionObj.getObjectIndex(%qualityLevel); + } + else + { + %qualityLevelText = %qualityLevel; + %qualityLevelIndex = %optionObj.getCount(); + } + + %optionNameHeight = 20; + if(%optionObj.Description $= "") + %optionNameHeight = 40; %entry = new GuiContainer() { position = "0 0"; @@ -1454,7 +1251,8 @@ function addOptionEntry(%optionObj) vertSizing = "bottom"; class = "OptionsListEntry"; optionsObject = %optionObj; - currentOptionIndex = 0; + currentOptionIndex = %qualityLevelIndex; + canSave = "0"; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -1469,7 +1267,7 @@ function addOptionEntry(%optionObj) new GuiTextCtrl() { text = %optionObj.OptionName; position = $optionsEntryPad SPC -1; - extent = "400 20"; + extent = 400 SPC %optionNameHeight; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; internalName = "optionName"; @@ -1501,7 +1299,7 @@ function addOptionEntry(%optionObj) }; new GuiTextCtrl() { - text = %qualityLevel.displayName; + text = %qualityLevelText; position = "330 0"; extent = "50 40"; profile = "GuiMenuTextProfile"; @@ -1521,5 +1319,166 @@ function addOptionEntry(%optionObj) }; }; + return %entry; +} + +function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %sliderMax, %sliderTicks) +{ + %currentVal = getVariable(%prefName); + + if(%currentVal $= "") + %currentVal = %sliderMin; + + %optionNameHeight = 20; + if(%optionDesc $= "") + %optionNameHeight = 40; + + %entry = new GuiContainer() { + position = "0 0"; + extent = "800 40"; + profile = GuiMenuDefaultProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "width"; + vertSizing = "bottom"; + class = "OptionsListSliderEntry"; + canSave = "0"; + + new GuiButtonCtrl() { + profile = GuiMenuButtonProfile; + position = "0 0"; + extent = "800 40"; + horizSizing = "width"; + vertSizing = "height"; + internalName = "button"; + class = "optionsMenuButton"; + }; + + new GuiTextCtrl() { + text = %optionName; + position = $optionsEntryPad SPC -1; + extent = 400 SPC %optionNameHeight; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionName"; + }; + + new GuiTextCtrl() { + text = %optionDesc; + position = $optionsEntryPad SPC 17; + extent = "400 18"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "optionDescription"; + }; + + new GuiContainer() { + position = "400 0"; + extent = "400 40"; + profile = GuiModelessDialogProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "left"; + vertSizing = "height"; + internalName = "valuesContainer"; + + new GuiSliderCtrl() { + range = %sliderMin SPC %sliderMax; + ticks = %sliderTicks; + snap = "1"; + value = %currentVal; + useFillBar = "1"; + fillBarColor = $TextMediumEmphasisColor; + renderTicks = "0"; + position = "0 10"; + extent = "300 20"; + minExtent = "8 2"; + horizSizing = "right"; + vertSizing = "center"; + profile = GuiMenuButtonProfile; + visible = "1"; + active = "1"; + command = "$thisControl.updateSliderValue();"; + tooltipProfile = "GuiToolTipProfile"; + hovertime = "1000"; + isContainer = "0"; + canSave = "1"; + canSaveDynamicFields = "0"; + class = "OptionsSliderEntrySlider"; + }; + }; + }; + + return %entry; +} + +function OptionsSliderEntrySlider::updateSliderValue(%this) +{ + //update settings value here +} + +function OptionsMenuActionMapButton::onHighlighted(%this, %highlighted) +{ + %container = %this.getParent(); + %container-->actionName.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText; + + OptionsMenuSettingsScroll.scrollToObject(%container); +} + +function addActionMapEntry(%actionMap, %device, %keyMap, %description) +{ + %entry = new GuiContainer() { + position = "0 0"; + extent = "800 40"; + profile = GuiMenuDefaultProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "width"; + vertSizing = "bottom"; + class = "OptionsKeybindEntry"; + canSave = "0"; + actionMap = %actionMap; + device = %device; + keymap = %keyMap; + + new GuiButtonCtrl() { + profile = GuiMenuButtonProfile; + position = "0 0"; + extent = "800 40"; + horizSizing = "width"; + vertSizing = "height"; + internalName = "button"; + class = "OptionsMenuActionMapButton"; + }; + + new GuiTextCtrl() { + text = getField(%keyMap, 0); + position = $optionsEntryPad SPC -1; + extent = "400 40"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "actionName"; + }; + + new GuiContainer() { + position = "400 3"; + extent = "400 34"; + profile = GuiModelessDialogProfile; + tooltipProfile = "GuiToolTipProfile"; + horizSizing = "left"; + vertSizing = "height"; + internalName = "valuesContainer"; + + new GuiIconButtonCtrl() { + position = "300 -10"; + extent = "98 45"; + BitmapAsset = ""; + profile = GuiRemapActionMapButtonProfile; + sizeIconToButton = true; + makeIconSquare = true; + iconLocation = "center"; + internalName = "bindButton"; + active = false; + }; + }; + }; + return %entry; } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index 93e65e7dd..c6c34cb9c 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -4,48 +4,45 @@ $TextHighEmphasisColor = "224 224 224"; $TextHighEmphasisColorHL = "0 0 0"; $TextDisabledColor = "108 108 108"; -singleton GuiGameListMenuProfile(DefaultListMenuProfile) +// --------------------------------------------------------------------------- +// Defaults +// --------------------------------------------------------------------------- +singleton GuiControlProfile( GuiMenuDefaultProfile ) { - fontType = "Arial Bold"; - fontSize = 20; - fontColor = $TextMediumEmphasisColor; - fontColorSEL = $TextMediumEmphasisColor; - fontColorNA = $TextDisabledColor; - fontColorHL = $TextMediumEmphasisColor; - - fillColor = "108 108 108"; - fillColorHL = "140 140 140"; - fillColorSEL = "180 180 180"; - - HitAreaUpperLeft = "16 20"; - HitAreaLowerRight = "503 74"; - IconOffset = "40 0"; - TextOffset = "100 0"; - RowSize = "500 90"; - ColumnSplit = "250"; - RightPad = "20"; - bitmap = "UI:listMenuArray_image"; - canKeyFocus = true; + opaque = false; + fillColor = "0 0 0 0"; + category = "BaseUI"; }; -singleton GuiControlProfile(GamepadDefaultProfile) +singleton GuiControlProfile( GuiModelessDialogProfile : GuiMenuDefaultProfile ) { - border = 0; + modal = false; }; -singleton GuiControlProfile(GamepadButtonTextLeft) +singleton GuiControlProfile(GuiMenuBackgroundProfile) { - fontType = "Arial Bold"; - fontSize = 20; - fontColor = "255 255 255"; - justify = "left"; + category = "BaseUI"; + opaque = true; + fillcolor = "34 34 34 255"; }; -singleton GuiControlProfile(GamepadButtonTextRight : GamepadButtonTextLeft) +singleton GuiControlProfile(GuiMenuPanelProfile) { - justify = "right"; + category = "BaseUI"; + opaque = true; + fillcolor = "15 15 15 255"; }; +singleton GuiControlProfile(GuiMenuBasePanelProfile) +{ + category = "BaseUI"; + opaque = true; + fillcolor = "40 40 40 255"; +}; + +// --------------------------------------------------------------------------- +// Text +// --------------------------------------------------------------------------- singleton GuiControlProfile(MenuHeaderText) { fontType = "Arial Bold"; @@ -53,6 +50,7 @@ singleton GuiControlProfile(MenuHeaderText) fontColor = $TextHighEmphasisColor; justify = "left"; modal = false; + category = "BaseUI"; }; singleton GuiControlProfile(MenuHeaderTextHighlighted : MenuHeaderText) @@ -60,11 +58,8 @@ singleton GuiControlProfile(MenuHeaderTextHighlighted : MenuHeaderText) fontColor = $TextHighEmphasisColorHL; }; -singleton GuiControlProfile(MenuHeaderTextCenter) +singleton GuiControlProfile(MenuHeaderTextCenter : MenuHeaderText) { - fontType = "Arial Bold"; - fontSize = 32; - fontColor = $TextHighEmphasisColor; justify = "center"; }; @@ -75,6 +70,7 @@ singleton GuiControlProfile(MenuSubHeaderText) fontColor = $TextMediumEmphasisColor; justify = "left"; modal = false; + category = "BaseUI"; }; singleton GuiControlProfile(MenuSubHeaderTextHighlighted : MenuSubHeaderText) @@ -101,6 +97,7 @@ singleton GuiControlProfile(MenuMLSubHeaderText) autoSizeWidth = true; autoSizeHeight = true; modal = false; + category = "BaseUI"; }; singleton GuiControlProfile(MenuMLSubHeaderTextCenter : MenuMLSubHeaderText) @@ -108,92 +105,6 @@ singleton GuiControlProfile(MenuMLSubHeaderTextCenter : MenuMLSubHeaderText) justify = "center"; }; -singleton GuiControlProfile( GuiMenuDefaultProfile ) -{ - opaque = false; - fillColor = "0 0 0 0"; -}; - -singleton GuiControlProfile( GuiMenuButtonProfile ) -{ - opaque = true; - border = false; - fontSize = 24; - fontType = "Arial Bold"; - fontColor = "200 200 200 255"; - fontColorHL = "0 0 0 255"; - fontColorNA = "108 108 108 255"; - fontColorSEL = "200 200 200 255"; - fillColor = "0 0 0 0"; - fillColorHL = "255 255 255 255"; - fillColorNA = "40 40 40"; - borderColor = "87 87 87"; - borderColorNA = "0 0 0"; - borderColorHL = "194 64 64"; - fixedExtent = 0; - justify = "center"; - canKeyFocus = false; - //bitmapAsset = "UI:menu_button_image"; - hasBitmapArray = false; - soundButtonDown = "UI:buttonClick"; - soundButtonOver = "UI:buttonHover"; - category = "BaseUI"; - fontColors[0] = "200 200 200 255"; - fontColors[2] = "108 108 108 255"; - fontColors[3] = "200 200 200 255"; - fontColors[5] = "Magenta"; - fontColorLinkHL = "Magenta"; -}; - -singleton GuiControlProfile( LevelPreviewButtonProfile : GuiMenuButtonProfile ) -{ - fontSize = 22; - justify = "Left"; -}; - -singleton GuiControlProfile( GuiHighlightMenuButtonProfile ) -{ - opaque = true; - border = false; - fontSize = 18; - fontType = "Arial Bold"; - fontColor = "240 240 240"; - fontColorHL = "0 0 0"; - fontColorNA = "125 125 125"; - //fontColorSEL ="0 0 0"; - fixedExtent = false; - justify = "center"; - canKeyFocus = false; - bitmapAsset = "UI:selector_button_highlight_only_image"; - hasBitmapArray = false; - category = "Core"; -}; - -singleton GuiControlProfile( GuiBlankMenuButtonProfile ) -{ - opaque = true; - border = false; - fontSize = 18; - fontType = "Arial Bold"; - fontColor = "220 220 220"; - fontColorHL = "255 255 255"; - fontColorNA = "200 200 200"; - //fontColorSEL ="0 0 0"; - fixedExtent = false; - justify = "center"; - canKeyFocus = false; - bitmapAsset = "UI:selector_button_blank_image"; - hasBitmapArray = false; - soundButtonDown = menuButtonPressed; - soundButtonOver = menuButtonHover; - category = "Core"; -}; - -singleton GuiControlProfile( GuiJoinServerButtonProfile : GuiMenuButtonProfile ) -{ - justify = "left"; -}; - singleton GuiControlProfile( GuiMenuTextProfile ) { opaque = true; @@ -209,99 +120,11 @@ singleton GuiControlProfile( GuiMenuTextProfile ) modal = false; }; -singleton GuiControlProfile( GuiMenuTextProfileHighlighted : GuiMenuTextProfile ) +singleton GuiControlProfile( GuiMenuTextProfileHL : GuiMenuTextProfile ) { fontColor = "0 0 0"; }; -singleton GuiControlProfile (GuiSolidDefaultProfile) -{ - opaque = true; - border = true; - category = "Core"; -}; - -singleton GuiControlProfile (GuiTransparentProfile) -{ - opaque = false; - border = false; - category = "Core"; -}; - -singleton GuiControlProfile( GuiGroupBorderProfile ) -{ - border = false; - opaque = false; - hasBitmapArray = true; - bitmapAsset = "UI:group_border_image"; - category = "Core"; -}; - -singleton GuiControlProfile( GuiTabBorderProfile ) -{ - border = false; - opaque = false; - hasBitmapArray = true; - bitmapAsset = "UI:tab_border_image"; - category = "Core"; -}; - -singleton GuiControlProfile( GuiModelessDialogProfile ) -{ - modal = false; - category = "Core"; -}; - -singleton GuiControlProfile (GuiFrameSetProfile) -{ - fillcolor = "255 255 255"; - borderColor = "246 245 244"; - border = 1; - opaque = true; - border = true; - category = "Core"; -}; - -singleton GuiControlProfile( GuiInputCtrlProfile ) -{ - tab = true; - canKeyFocus = true; - category = "Core"; -}; - -singleton GuiControlProfile (GuiTextProfile) -{ - justify = "left"; - fontColor = "20 20 20"; - category = "Core"; -}; - -singleton GuiControlProfile (GuiTextRightProfile : GuiTextProfile) -{ - justify = "right"; - category = "Core"; -}; - -singleton GuiControlProfile (GuiAutoSizeTextProfile) -{ - fontColor = "0 0 0"; - autoSizeWidth = true; - autoSizeHeight = true; - category = "Core"; -}; - -singleton GuiControlProfile( GuiMediumTextProfile : GuiTextProfile ) -{ - fontSize = 24; - category = "Core"; -}; - -singleton GuiControlProfile( GuiBigTextProfile : GuiTextProfile ) -{ - fontSize = 36; - category = "Core"; -}; - singleton GuiControlProfile( GuiMLTextProfile ) { fontColor = $TextMediumEmphasisColor; @@ -324,224 +147,48 @@ singleton GuiControlProfile( GuiMLTextProfileHighlighted : GuiMLTextProfile ) fontColor = $TextMediumEmphasisColorHL; }; -singleton GuiControlProfile( GuiMLWhiteTextProfile ) -{ - fontColor = "220 220 220"; - fontColorHL = $TextMediumEmphasisColor; - autoSizeWidth = true; - autoSizeHeight = true; - border = false; - category = "Core"; -}; - -singleton GuiControlProfile( GuiTextArrayProfile : GuiTextProfile ) -{ - fontColor = $TextMediumEmphasisColor; - fontColorHL = $TextMediumEmphasisColor; - fontColorSEL = $TextMediumEmphasisColor; - fontColorNA = $TextDisabledColor; - - fillColor = "22 22 22 255"; - fillColorHL = "22 22 22 255"; - fillColorSEL = "56 56 56 255"; - - border = true; - borderColor ="87 87 87"; - borderColorHL = "87 87 87"; - borderColorSEL = "255 255 255"; - - category = "Core"; - canKeyFocus = true; -}; - -singleton GuiControlProfile( GuiMenuTextEditProfile : GuiTextEditProfile ) -{ - fontColor = $TextMediumEmphasisColor; - fontColorHL = $TextMediumEmphasisColor; - fontColorSEL = $TextMediumEmphasisColor; - fontColorNA = $TextDisabledColor; - - fillColor = "22 22 22 255"; - fillColorHL = "22 22 22 255"; - - border = true; - borderColor ="87 87 87"; - borderColorHL = "87 87 87"; - borderColorSEL = "255 255 255"; - - category = "Core"; -}; - -// ---------------------------------------------------------------------------- -// TODO: Revisit Popupmenu -// ---------------------------------------------------------------------------- - -singleton GuiControlProfile( GuiPopupMenuItemBorder : GuiButtonProfile ) +// --------------------------------------------------------------------------- +// Interactive Controls +// --------------------------------------------------------------------------- +singleton GuiControlProfile( GuiMenuButtonProfile ) { opaque = true; - border = true; - fontColor = "0 0 0"; - fontColorHL = "0 0 0"; - fontColorNA = "255 255 255"; - fixedExtent = false; + border = false; + fontSize = 24; + fontType = "Arial Bold"; + fontColor = "200 200 200 255"; + fontColorHL = "0 0 0 255"; + fontColorNA = "108 108 108 255"; + fontColorSEL = "200 200 200 255"; + fillColor = "0 0 0 0"; + fillColorHL = "255 255 255 255"; + fillColorNA = "40 40 40"; + borderColor = "87 87 87"; + borderColorNA = "0 0 0"; + borderColorHL = "194 64 64"; + fixedExtent = 0; justify = "center"; canKeyFocus = false; - bitmapAsset = "UI:menubutton_image"; - category = "Core"; + hasBitmapArray = false; + soundButtonDown = "UI:buttonClick"; + soundButtonOver = "UI:buttonHover"; + category = "BaseUI"; + fontColors[0] = "200 200 200 255"; + fontColors[2] = "108 108 108 255"; + fontColors[3] = "200 200 200 255"; }; -singleton GuiControlProfile( GuiPopUpMenuDefault : GuiDefaultProfile ) +singleton GuiControlProfile( GuiMenuButtonLeftJustProfile : GuiMenuButtonProfile ) { - opaque = true; - mouseOverSelected = true; - textOffset = "3 3"; - border = 0; - borderThickness = 0; - fixedExtent = true; - hasBitmapArray = true; - - fillColor = EditorSettings.value("Theme/fieldBGColor");//"255 255 255";//100 - fillColorHL = EditorSettings.value("Theme/fieldBGHLColor");//"91 101 116"; - fillColorSEL = EditorSettings.value("Theme/fieldBGSELColor");//"91 101 116"; - fontColor = EditorSettings.value("Theme/fieldTextColor");//"215 215 215"; - fontColorHL = EditorSettings.value("Theme/fieldTextHLColor");//"215 215 215"; - fontColorSEL = EditorSettings.value("Theme/fieldTextSELColor");//"215 215 215"; - fontColorNA = EditorSettings.value("Theme/fieldTextColor");//"215 215 215"; - borderColor = EditorSettings.value("Theme/dividerDarkColor"); - profileForChildren = GuiPopupMenuItemBorder; - category = "Core"; + justify = "Left"; }; -singleton GuiControlProfile( GuiPopUpMenuProfile : GuiPopUpMenuDefault ) +singleton GuiControlProfile( GuiRemapActionMapButtonProfile : GuiMenuButtonProfile ) { - textOffset = "6 4"; - bitmapAsset = "UI:dropDown_image"; - hasBitmapArray = true; - border = 1; - profileForChildren = GuiPopUpMenuDefault; - category = "Core"; + fillColor = "18 18 18 255"; + fillColorHL = "0 0 0 255"; }; -singleton GuiControlProfile( GuiTabBookProfile ) -{ - fillColorHL = "100 100 100"; - fillColorNA = "150 150 150"; - fontColor = "30 30 30"; - fontColorHL = "0 0 0"; - fontColorNA = "50 50 50"; - fontType = "Arial"; - fontSize = 14; - justify = "center"; - bitmapAsset = "UI:tab_image"; - tabWidth = 64; - tabHeight = 24; - tabPosition = "Top"; - tabRotation = "Horizontal"; - textOffset = "0 -3"; - tab = true; - cankeyfocus = true; - category = "Core"; -}; - -singleton GuiControlProfile( GuiTabPageProfile : GuiDefaultProfile ) -{ - fontType = "Arial"; - fontSize = 10; - justify = "center"; - bitmapAsset = "UI:tab_image"; - opaque = false; - fillColor = "240 239 238"; - category = "Core"; -}; - -singleton GuiControlProfile( GuiConsoleProfile ) -{ - fontType = ($platform $= "macos") ? "Monaco" : "Lucida Console"; - fontSize = ($platform $= "macos") ? 13 : 12; - fontColor = "255 255 255"; - fontColorHL = "0 255 255"; - fontColorNA = "255 0 0"; - fontColors[6] = "100 100 100"; - fontColors[7] = "100 100 0"; - fontColors[8] = "0 0 100"; - fontColors[9] = "0 100 0"; - category = "Core"; -}; - -singleton GuiControlProfile( GuiConsoleTextProfile ) -{ - fontColor = "0 0 0"; - autoSizeWidth = true; - autoSizeHeight = true; - textOffset = "2 2"; - opaque = true; - fillColor = "255 255 255"; - border = true; - borderThickness = 1; - borderColor = "0 0 0"; - category = "Core"; -}; - -$ConsoleDefaultFillColor = "0 0 0 175"; - -singleton GuiControlProfile( ConsoleScrollProfile : GuiScrollProfile ) -{ - opaque = true; - fillColor = $ConsoleDefaultFillColor; - border = 1; - //borderThickness = 0; - borderColor = "0 0 0"; - category = "Core"; -}; - -singleton GuiControlProfile( ConsoleTextEditProfile : GuiTextEditProfile ) -{ - fillColor = "242 241 240 255"; - fillColorHL = "255 255 255"; - category = "Core"; -}; - -//----------------------------------------------------------------------------- -// Center and bottom print -//----------------------------------------------------------------------------- - -singleton GuiControlProfile ( CenterPrintProfile ) -{ - opaque = false; - fillColor = "128 128 128"; - fontColor = "0 255 0"; - border = true; - borderColor = "0 255 0"; - category = "Core"; -}; - -singleton GuiControlProfile ( CenterPrintTextProfile ) -{ - opaque = false; - fontType = "Arial"; - fontSize = 12; - fontColor = "0 255 0"; - category = "Core"; -}; - -// ---------------------------------------------------------------------------- -// Radio button control -// ---------------------------------------------------------------------------- -singleton GuiControlProfile( GuiRadioProfile ) -{ - fontSize = 14; - fillColor = "232 232 232"; - fontColor = "20 20 20"; - fontColorHL = "80 80 80"; - fixedExtent = true; - bitmapAsset = "UI:radioButton_image"; - hasBitmapArray = true; - category = "Core"; -}; - -// -// Scroll Profile -// singleton GuiControlProfile(GuiMenuScrollProfile) { opaque = false; @@ -552,33 +199,4 @@ singleton GuiControlProfile(GuiMenuScrollProfile) bitmapAsset = "UI:scrollBar_image"; hasBitmapArray = true; category = "BaseUI"; -}; - -singleton GuiControlProfile(SliderBitmapGUIProfile) -{ - bitmapAsset = "UI:optionsMenuSliderBitmapArray_image"; - hasBitmapArray = true; - opaque = false; - borderColor = "0 0 0 255"; -}; - -singleton GuiControlProfile(GuiMenuBackgroundProfile) -{ - category = "BaseUI"; - opaque = true; - fillcolor = "34 34 34 255"; -}; - -singleton GuiControlProfile(GuiMenuPanelProfile) -{ - category = "BaseUI"; - opaque = true; - fillcolor = "15 15 15 255"; -}; - -singleton GuiControlProfile(GuiMenuBasePanelProfile) -{ - category = "BaseUI"; - opaque = true; - fillcolor = "40 40 40 255"; }; \ No newline at end of file diff --git a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditor.gui b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditor.gui index b6315df53..e48614c5a 100644 --- a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditor.gui +++ b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditor.gui @@ -302,7 +302,7 @@ new VPathEditor(EVPathEditor) { }; new GuiPopUpMenuCtrl(EPathEditorNodeOrientationMode){ internalName = "weight"; - Profile = "GuiPopUpMenuProfile"; + Profile = "ToolsGuiPopUpMenuProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = "57 84"; @@ -385,7 +385,7 @@ new VPathEditor(EVPathEditor) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; - Profile = "GuiTransparentProfile"; + Profile = "ToolsGuiTransparentProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = "1 1"; diff --git a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui index 57651df52..5a1f0a808 100644 --- a/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui +++ b/Templates/BaseGame/game/tools/VPathEditor/GUI/VPathEditorToolbar.gui @@ -30,7 +30,7 @@ $guiContent = new GuiControl(VPathEditorToolbar) new GuiTextCtrl() { internalName = "ToolbarLabel"; - profile = "GuiTextProfile"; + profile = "ToolsGuiTextProfile"; horizSizing = "right"; vertSizing = "bottom"; position = "2 7"; @@ -48,7 +48,7 @@ $guiContent = new GuiControl(VPathEditorToolbar) internalName = "PathTypeMenu"; Enabled = "1"; isContainer = "0"; - Profile = "GuiPopUpMenuProfile"; + Profile = "ToolsGuiPopUpMenuProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = "85 7"; diff --git a/Templates/BaseGame/game/tools/VerveEditor/GUI/GuiProfiles.tscript b/Templates/BaseGame/game/tools/VerveEditor/GUI/GuiProfiles.tscript index ada3b1a08..457e0fae2 100644 --- a/Templates/BaseGame/game/tools/VerveEditor/GUI/GuiProfiles.tscript +++ b/Templates/BaseGame/game/tools/VerveEditor/GUI/GuiProfiles.tscript @@ -79,7 +79,7 @@ singleton GuiControlProfile( VEditorTextEditProfile : VEditorDefaultProfile ) canKeyFocus = true; }; -singleton GuiControlProfile( VEditorPopupMenuProfile : GuiPopUpMenuProfile ) +singleton GuiControlProfile( VEditorPopupMenuProfile : ToolsGuiPopUpMenuProfile ) { FillColorHL = "90 90 90"; FillColorSEL = "0 0 0"; @@ -204,7 +204,7 @@ singleton GuiControlProfile( VEditorPropertyLabelProfile : VEditorTextProfile ) //----------------------------------------------------------------------------- -singleton GuiControlProfile( VEditorPreferenceLabelProfile : GuiTextProfile ) +singleton GuiControlProfile( VEditorPreferenceLabelProfile : ToolsGuiTextProfile ) { opaque = true; fillColor = "242 241 240"; diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript index 1216eaab6..a63aef2c9 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetBrowser.tscript @@ -2420,7 +2420,7 @@ function AssetBrowserPreviewButton::onMouseDragged(%this) %ctrl = new GuiDragAndDropControl() { canSaveDynamicFields = "0"; - Profile = "GuiSolidDefaultProfile"; + Profile = "ToolsGuiSolidDefaultProfile"; HorizSizing = "right"; VertSizing = "bottom"; Position = %xPos SPC %yPos; diff --git a/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui b/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui index e62771773..dda5498a0 100644 --- a/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui +++ b/Templates/BaseGame/game/tools/gui/messageBoxes/IODropdownDlg.ed.gui @@ -54,7 +54,7 @@ $guiContent = new GuiControl(IODropdownDlg) { }; new GuiBitmapBorderCtrl() { isContainer = "0"; - profile = "GuiGroupBorderProfile"; + profile = "ToolsGuiGroupBorderProfile"; horizSizing = "width"; vertSizing = "bottom"; position = "7 51"; diff --git a/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui b/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui index 79007fda4..9c6b5fa15 100644 --- a/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui +++ b/Templates/BaseGame/game/tools/gui/renderTargetVisualizer.ed.gui @@ -5,7 +5,7 @@ $guiContent = new GuiControl(RenderTargetVisualizer) { minExtent = "8 2"; horizSizing = "right"; vertSizing = "bottom"; - profile = "GuiModelessDialogProfile"; + profile = "ToolsGuiModelessDialogProfile"; visible = "1"; active = "1"; tooltipProfile = "GuiToolTipProfile"; @@ -79,7 +79,7 @@ $guiContent = new GuiControl(RenderTargetVisualizer) { minExtent = "8 2"; horizSizing = "width"; vertSizing = "bottom"; - profile = "GuiPopUpMenuProfile"; + profile = "ToolsGuiPopUpMenuProfile"; visible = "1"; active = "1"; command = "RenderTargetsList.updateTarget();"; diff --git a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml index 5fdb84bfc..9b3fe43b3 100644 --- a/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml +++ b/Templates/BaseGame/game/tools/levels/DefaultEditorLevel.asset.taml @@ -1,10 +1,7 @@ + VersionId="1"/> diff --git a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui index 39c431697..6f7640ea1 100644 --- a/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui +++ b/Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui @@ -2619,7 +2619,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { hovertime = "1000"; new GuiContainer(){ // enable/disable - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -2652,7 +2652,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; new GuiContainer(){ // scale - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -2735,7 +2735,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; new GuiContainer(){ // direction - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -2817,7 +2817,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; }; new GuiContainer(){ // strength - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -2899,7 +2899,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; }; new GuiContainer(){ // coverage - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -2981,7 +2981,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; }; new GuiContainer(){ // specular - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 24"; @@ -3063,7 +3063,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) { }; }; new GuiContainer(){ // empty space - profile="GuiTransparentProfile"; + profile="ToolsGuiTransparentProfile"; isContainer = "1"; position = "0 0"; Extent = "300 10"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui index cb0b0f098..a512eb327 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorGui.gui @@ -549,7 +549,7 @@ $guiContent = new GuiNavEditorCtrl(NavEditorGui, EditorGuiGroup) { canSaveDynamicFields = "0"; Enabled = "1"; isContainer = "1"; - Profile = "GuiTransparentProfile"; + Profile = "ToolsGuiTransparentProfile"; HorizSizing = "width"; VertSizing = "height"; Position = "1 1"; diff --git a/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui b/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui index 9aafcd0b9..6cc6cbb71 100644 --- a/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui +++ b/Templates/BaseGame/game/tools/navEditor/NavEditorSettingsTab.gui @@ -14,7 +14,7 @@ $guiContent = new GuiTabPageCtrl(ENavEditorSettingsPage) { minExtent = "8 2"; horizSizing = "width"; vertSizing = "height"; - profile = "GuiSolidDefaultProfile"; + profile = "ToolsGuiSolidDefaultProfile"; visible = "1"; active = "1"; tooltipProfile = "GuiToolTipProfile"; diff --git a/Templates/BaseGame/game/tools/settings.xml b/Templates/BaseGame/game/tools/settings.xml index ede1a4e14..4960ec633 100644 --- a/Templates/BaseGame/game/tools/settings.xml +++ b/Templates/BaseGame/game/tools/settings.xml @@ -41,7 +41,7 @@ Edit Asset 0 976 2016 360 + name="LastPosExt">0 976 2200 360 1 Date: Tue, 19 Dec 2023 02:36:43 -0600 Subject: [PATCH 05/19] Most of the keybind/remap stuff finished Fixed up most of the options apply logic --- Templates/BaseGame/game/data/UI/UI.tscript | 1 + .../game/data/UI/guis/optionsMenu.gui | 2 +- .../game/data/UI/guis/optionsMenu.tscript | 154 ++++++++++++++---- .../BaseGame/game/data/UI/guis/remapDlg.gui | 32 ++-- .../game/data/UI/guis/remapDlg.tscript | 77 +++++++++ .../game/data/UI/scripts/controlsMenu.tscript | 98 ----------- 6 files changed, 217 insertions(+), 147 deletions(-) create mode 100644 Templates/BaseGame/game/data/UI/guis/remapDlg.tscript diff --git a/Templates/BaseGame/game/data/UI/UI.tscript b/Templates/BaseGame/game/data/UI/UI.tscript index 9652b97d7..027451977 100644 --- a/Templates/BaseGame/game/data/UI/UI.tscript +++ b/Templates/BaseGame/game/data/UI/UI.tscript @@ -57,6 +57,7 @@ function UI::initClient(%this) %this.queueExec("./guis/GameMenu"); %this.queueExec("./guis/GameMenu.gui"); + %this.queueExec("./guis/remapDlg"); %this.queueExec("./guis/remapDlg.gui"); %this.queueExec("./guis/remapConfirmDlg.gui"); diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 6fb19d7e1..a6906986f 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -188,7 +188,7 @@ $guiContent = new GuiControl(OptionsMenu) { extent = "140 40"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "Canvas.popDialog();"; + command = "tryCloseOptionsMenu();"; tooltipProfile = "GuiToolTipProfile"; class = "MenuInputButton"; }; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 9437a6b57..0f3fe9f24 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -92,6 +92,9 @@ if(!isObject( OptionsMenuActionMap ) ) { new ActionMap(OptionsMenuActionMap){}; + OptionsMenuActionMap.bind( keyboard, Escape, tryCloseOptionsMenu); + OptionsMenuActionMap.bind( gamepad, btn_b, tryCloseOptionsMenu); + OptionsMenuActionMap.bind( keyboard, w, OptionMenuNavigatePrev ); OptionsMenuActionMap.bind( keyboard, s, OptionMenuNavigateNext ); OptionsMenuActionMap.bind( gamepad, yaxis, "D", "-0.23 0.23", OptionMenuStickNavigate ); @@ -331,7 +334,7 @@ function OptionMenuPrevSetting(%val) if(!isObject(%option)) return; - if(%option.class !$= "OptionsListEntry") + if(%option.class $= "OptionsListEntry") { %optionObject = %option.optionsObject; %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); @@ -356,7 +359,7 @@ function OptionMenuNextSetting(%val) if(!isObject(%option) ) return; - if(%option.class !$= "OptionsListEntry") + if(%option.class $= "OptionsListEntry") { %optionObject = %option.optionsObject; %currentOptionLevel = %optionObject.getObject(%option.currentOptionIndex); @@ -562,7 +565,7 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList) %description = $RemapDescription[%i]; - %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %description); + %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %i, %description); %controlsList.add(%remapEntry); } } @@ -575,45 +578,128 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList) %entry.resize(0, 0, %controlsList.extent.x - 15, %entry.extent.y); //-10 for the scroll wheel pad } } -// -// old -// -//We capitalize on the canClose test here, because we want to prompt for unapplied options changes before -//backing out. So when the UINavigation test canClose, we can see if we have unapplied settings and prompt -//that via the message box and return false. -//This gives the user a chance to choose how they wish to proceed before we allow the -//UINavigation to move away from the options menu -function OptionsMenu::canClose(%this) + +function tryCloseOptionsMenu(%val) { - //Another special case is us catching the 'back/pop' action by just shifting from one - //menu list to another. In this case, we check if we were on the settings list as our active MenuList - //if so, then the back/pop just moves us to the Category list as our active and we inform the - //UINavigation to not close the page - if(OptionsMenuSettingsList.isActiveMenuList()) + if(!%val) + return; + + //scan through all our options and see if any are any unapplied changes. If + //so we need to prompt to apply or discard them + %unappliedChanges = false; + + foreach(%option in VideoSettingsList) { - OptionsMenuCategoryList.setAsActiveMenuList(); - return false; - } - else - { - //Here, we're on the category list as our active, so we're actually trying to leae the page - //If we have unapplied changes, we want to prompt about them before closing the page and navigating away - //If we don't, then we can process the popPage as normal and let the OptionsMenu close - if(%this.unappliedChanges.count() != 0) + if(%option.class $= "OptionsListEntry") { - MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", - "OptionsMenu.apply(); MainMenuGUI.popPage();", "" @ %this @ ".unappliedChanges.empty(); " @ %this @ ".navigation.popPage();", - "Apply", "Discard"); - return false; + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + echo("tryCloseOptionsMenu() - testing option: " @ %option.optionsObject.optionName @ " target level of: " @ %targetOptionLevel.displayName); + + if(!%targetOptionLevel.isCurrent()) + { + %unappliedChanges = true; + break; + } + } } } - return true; + //check if we already have unapplied changes, so we can skip further iterating + if(!%unappliedChanges) + { + foreach(%option in AudioSettingsList) + { + if(%option.class $= "OptionsListEntry") + { + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + echo("tryCloseOptionsMenu() - testing option: " @ %option.optionsObject.optionName @ " target level of: " @ %targetOptionLevel.displayName); + + if(!%targetOptionLevel.isCurrent()) + { + %unappliedChanges = true; + break; + } + } + } + } + } + + if(%unappliedChanges) + { + MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", + "OptionsMenu.applyChangedOptions();", "Canvas.popDialog(OptionsMenu);", + "Apply", "Discard"); + } + else + { + Canvas.popDialog(OptionsMenu); + } } -function OptionsMenu::onClose(%this) +function OptionsMenu::applyChangedOptions(%this) { + foreach(%option in VideoSettingsList) + { + if(%option.class $= "OptionsListEntry") + { + //If it's custom or nonsensical index, there's some kind of external factor going on, so we're + //just going to skip applying it because we don't know what we'd be applying + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + if(!%targetOptionLevel.isCurrent()) + { + echo("Applying setting of " @ %option.optionsObject.optionName); + %targetOptionLevel.apply(); + } + } + } + } + foreach(%option in AudioSettingsList) + { + if(%option.class $= "OptionsListEntry") + { + //If it's custom or nonsensical index, there's some kind of external factor going on, so we're + //just going to skip applying it because we don't know what we'd be applying + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + if(!%targetOptionLevel.isCurrent()) + { + echo("Applying setting of " @ %option.optionsObject.optionName); + %targetOptionLevel.apply(); + } + } + } + } + + //Finally, write our prefs to file + %prefPath = getPrefpath(); + export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); + + Canvas.popDialog(OptionsMenu); +} + +function doKeyRemap( %optionEntry ) +{ + //%rowIndex = %row.remapIndex; + //%name = $RemapName[%rowIndex]; + + %name = getField(%optionEntry.keymap,0); + + RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ; + OptRemapInputCtrl.index = %optionEntry.remapIndex; + + Canvas.pushDialog( RemapDlg ); } function OptionsMenu::apply(%this) @@ -1423,7 +1509,7 @@ function OptionsMenuActionMapButton::onHighlighted(%this, %highlighted) OptionsMenuSettingsScroll.scrollToObject(%container); } -function addActionMapEntry(%actionMap, %device, %keyMap, %description) +function addActionMapEntry(%actionMap, %device, %keyMap, %index, %description) { %entry = new GuiContainer() { position = "0 0"; @@ -1437,6 +1523,7 @@ function addActionMapEntry(%actionMap, %device, %keyMap, %description) actionMap = %actionMap; device = %device; keymap = %keyMap; + remapIndex = %index; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -1446,6 +1533,7 @@ function addActionMapEntry(%actionMap, %device, %keyMap, %description) vertSizing = "height"; internalName = "button"; class = "OptionsMenuActionMapButton"; + altCommand = "doKeyRemap($thisControl.getParent());"; }; new GuiTextCtrl() { diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui index feef7d938..ccc678df6 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui @@ -1,6 +1,6 @@ //--- OBJECT WRITE BEGIN --- $guiContent = new GuiControl(RemapDlg) { - extent = "1024 768"; + extent = "1280 720"; minExtent = "8 8"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; @@ -9,7 +9,7 @@ $guiContent = new GuiControl(RemapDlg) { helpTag = "0"; new GuiContainer(RemapPanel) { - position = "162 332"; + position = "290 308"; extent = "700 104"; horizSizing = "center"; vertSizing = "center"; @@ -34,26 +34,28 @@ $guiContent = new GuiControl(RemapDlg) { tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_image"; - extent = "701 40"; + new GuiBitmapCtrl() { + BitmapAsset = "UI:backdrop_image"; + position = "1 1"; + extent = "701 100"; horizSizing = "width"; + vertSizing = "height"; profile = "GuiDefaultProfile"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiBitmapBarCtrl() { - BitmapAsset = "UI:panel_low_image"; - position = "0 40"; - extent = "701 341"; + new GuiPanel() { + position = "38 12"; + extent = "625 80"; horizSizing = "width"; - profile = "GuiDefaultProfile"; + vertSizing = "height"; + profile = "GuiMenuBasePanelProfile"; tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { - text = "Press escape to cancel"; + text = "Press escape or start to cancel"; maxLength = "255"; - position = "260 67"; - extent = "181 23"; + position = "252 51"; + extent = "245 23"; minExtent = "8 8"; horizSizing = "width"; vertSizing = "height"; @@ -61,9 +63,9 @@ $guiContent = new GuiControl(RemapDlg) { tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl() { - text = "Re-bind \"Forward\" to..."; + text = "Re-bind \"\" to..."; maxLength = "255"; - position = "259 40"; + position = "251 24"; extent = "184 23"; minExtent = "8 8"; horizSizing = "center"; diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript b/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript new file mode 100644 index 000000000..107251735 --- /dev/null +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript @@ -0,0 +1,77 @@ +function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) +{ + Canvas.popDialog( RemapDlg ); + + if ( %device $= "keyboard" && %action $= "escape" ) + return; + else if( %device $= "gamepad" && %action $= "btn_start" ) + return; + + %cmd = $RemapCmd[%this.index]; + %name = $RemapName[%this.index]; + %actionMap = $RemapActionMap[%this.index]; + + echo("OptRemapInputCtrl::onInputEvent() - remapping details: " @ %cmd @ ", " @ %name @ ", " @ %actionMap @ " remapped to: " @ %device @ ", " @ %action); + + // Grab the friendly display name for this action + // which we'll use when prompting the user below. + %mapName = getMapDisplayName( %device, %action ); + + // Get the current command this action is mapped to. + %prevMap = %actionMap.getCommand( %device, %action ); + + //TODO: clear all existant keybinds to a command and then bind it so we only have a single one at all times + unbindExtraActions( %cmd, %actionMap, 0 ); + unbindExtraActions( %cmd, %actionMap, 1 ); + + // If nothing was mapped to the previous command + // mapping then it's easy... just bind it. + if ( %prevMap $= "" ) + { + //unbindExtraActions( %cmd, %actionMap, 1 ); + %actionMap.bind( %device, %action, %cmd ); + + OptionsMenu.syncGui(); + return; + } + + // If the previous command is the same as the + // current then they hit the same input as what + // was already assigned. + if ( %prevMap $= %cmd ) + { + //unbindExtraActions( %cmd, %actionMap, 0 ); + %actionMap.bind( %device, %action, %cmd ); + + OptionsMenu.syncGui(); + return; + } + + // Look for the index of the previous mapping. + %prevMapIndex = findRemapCmdIndex( %prevMap ); + + // If we get a negative index then the previous + // mapping was to an item that isn't included in + // the mapping list... so we cannot unmap it. + if ( %prevMapIndex == -1 ) + { + MessageBoxOK( "Remap Failed", "\"" @ %mapName @ "\" is already bound to a non-remappable command!" ); + return; + } + + // Setup the forced remapping callback command. + %callback = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @ + %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");"; + + // Warn that we're about to remove the old mapping and + // replace it with another. + %prevCmdName = $RemapName[%prevMapIndex]; + //Canvas.pushDialog( RemapConfirmDlg ); + + %remapWarnText = "\"" @ %mapName @ "\" is already bound to \"" @ %prevCmdName @ "\"! Do you wish to replace this mapping?"; + %doRemapCommand = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @ + %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");"; + %cancelCommand = ""; + + MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand ); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript index 95df2cebf..ef2c85df0 100644 --- a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript @@ -205,21 +205,6 @@ function controlSetChanged() fillRemapList(); } -function doKeyRemap( %row ) -{ - %rowIndex = %row.remapIndex; - %name = $RemapName[%rowIndex]; - - RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ; - OptRemapInputCtrl.index = %rowIndex; - Canvas.pushDialog( RemapDlg ); - - //Let the options menu know - %actionMap = $RemapActionMap[%rowIndex]; - - OptionsMenu.onKeybindChanged(%actionMap, %name); -} - function ControlsMenuRebindButton::onClick(%this) { %name = $RemapName[%this.keybindIndex]; @@ -230,89 +215,6 @@ function ControlsMenuRebindButton::onClick(%this) Canvas.pushDialog( RemapDlg ); } -function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) -{ - //error( "** onInputEvent called - device = " @ %device @ ", action = " @ %action @ " **" ); - Canvas.popDialog( RemapDlg ); - - // Test for the reserved keystrokes: - if ( %device $= "keyboard" ) - { - // Cancel... - if ( %action $= "escape" ) - { - // Do nothing... - return; - } - } - - %cmd = $RemapCmd[%this.index]; - %name = $RemapName[%this.index]; - %actionMap = $RemapActionMap[%this.index]; - - // Grab the friendly display name for this action - // which we'll use when prompting the user below. - %mapName = getMapDisplayName( %device, %action ); - - // Get the current command this action is mapped to. - %prevMap = %actionMap.getCommand( %device, %action ); - - //TODO: clear all existant keybinds to a command and then bind it so we only have a single one at all times - unbindExtraActions( %cmd, %actionMap, 0 ); - unbindExtraActions( %cmd, %actionMap, 1 ); - - // If nothing was mapped to the previous command - // mapping then it's easy... just bind it. - if ( %prevMap $= "" ) - { - //unbindExtraActions( %cmd, %actionMap, 1 ); - %actionMap.bind( %device, %action, %cmd ); - - fillRemapList(); - return; - } - - // If the previous command is the same as the - // current then they hit the same input as what - // was already assigned. - if ( %prevMap $= %cmd ) - { - //unbindExtraActions( %cmd, %actionMap, 0 ); - %actionMap.bind( %device, %action, %cmd ); - - fillRemapList(); - return; - } - - // Look for the index of the previous mapping. - %prevMapIndex = findRemapCmdIndex( %prevMap ); - - // If we get a negative index then the previous - // mapping was to an item that isn't included in - // the mapping list... so we cannot unmap it. - if ( %prevMapIndex == -1 ) - { - MessageBoxOK( "Remap Failed", "\"" @ %mapName @ "\" is already bound to a non-remappable command!" ); - return; - } - - // Setup the forced remapping callback command. - %callback = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @ - %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");"; - - // Warn that we're about to remove the old mapping and - // replace it with another. - %prevCmdName = $RemapName[%prevMapIndex]; - Canvas.pushDialog( RemapConfirmDlg ); - - %remapWarnText = "\"" @ %mapName @ "\" is already bound to \"" @ %prevCmdName @ "\"! Do you wish to replace this mapping?"; - %doRemapCommand = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @ - %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ "); Canvas.popDialog();"; - %cancelCommand = "Canvas.popDialog();"; - - MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand ); -} - function findRemapCmdIndex( %command ) { for ( %i = 0; %i < $RemapCount; %i++ ) From df005435025f1483da07b3070502d01fcb8a4a79 Mon Sep 17 00:00:00 2001 From: Areloch Date: Tue, 19 Dec 2023 16:37:23 -0600 Subject: [PATCH 06/19] Implemented apply changes logic Updated autodetect graphics to complete to new apply changes rules Made it so gamepad can activate key rebinds --- .../rendering/scripts/graphicsOptions.tscript | 270 +++++--- .../core/sfx/scripts/audioOptions.tscript | 21 + .../game/data/UI/guis/optionsMenu.tscript | 597 +++--------------- 3 files changed, 292 insertions(+), 596 deletions(-) diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript index f48023dd2..42d6bef5f 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript @@ -71,6 +71,7 @@ new SimGroup(VideoSettingsGroup) { class = "OptionsSettings"; OptionName = "Display API"; + requiresRestart = true; }; new SimGroup( DisplayDevicesGroup ) @@ -693,7 +694,7 @@ new SimGroup(VideoSettingsGroup) class = "SubOptionsGroup"; displayName = "Effects"; - new SimGroup() + new SimGroup(ShaderQualityOptionsGroup) { class = "OptionsSettings"; OptionName = "Shader Quality"; @@ -723,7 +724,7 @@ new SimGroup(VideoSettingsGroup) }; - new SimGroup() + new SimGroup(AnisotropicFilterOptionsGroup) { class = "OptionsSettings"; OptionName = "Anisotropic Filtering"; @@ -759,7 +760,7 @@ new SimGroup(VideoSettingsGroup) }; }; - new SimGroup() + new SimGroup(AntiAliasingOptionsGroup) { class = "OptionsSettings"; OptionName = "Anti-Aliasing"; @@ -771,6 +772,7 @@ new SimGroup(VideoSettingsGroup) displayName = "None"; key["$pref::Video::AAMode"] = "None"; + key["$pref::Video::AA"] = 0; }; new ArrayObject() { @@ -778,6 +780,7 @@ new SimGroup(VideoSettingsGroup) displayName = "FXAA"; key["$pref::Video::AAMode"] = "FXAA"; + key["$pref::Video::AA"] = 0; }; new ArrayObject() { @@ -785,6 +788,7 @@ new SimGroup(VideoSettingsGroup) displayName = "SMAA"; key["$pref::Video::AAMode"] = "SMAA"; + key["$pref::Video::AA"] = 4; }; new ArrayObject() { @@ -792,10 +796,11 @@ new SimGroup(VideoSettingsGroup) displayName = "SMAA High"; key["$pref::Video::AAMode"] ="SMAA High"; + key["$pref::Video::AA"] = 4; }; }; - new SimGroup() + new SimGroup(ParallaxOptionsGroup) { class = "OptionsSettings"; OptionName = "Parallax"; @@ -818,7 +823,7 @@ new SimGroup(VideoSettingsGroup) }; - new SimGroup() + new SimGroup(TrueWaterReflectionsOptionsGroup) { class = "OptionsSettings"; OptionName = "True Water Reflections"; @@ -840,7 +845,7 @@ new SimGroup(VideoSettingsGroup) }; }; - new SimGroup() + new SimGroup(PostFXSSAOOptionsGroup) { class = "OptionsSettings"; OptionName = "SSAO"; @@ -862,7 +867,7 @@ new SimGroup(VideoSettingsGroup) }; }; - new SimGroup() + new SimGroup(PostFXDOFOptionsGroup) { class = "OptionsSettings"; OptionName = "Depth of Field"; @@ -883,7 +888,7 @@ new SimGroup(VideoSettingsGroup) }; }; - new SimGroup() + new SimGroup(PostFXVignetteOptionsGroup) { class = "OptionsSettings"; OptionName = "Vignette"; @@ -904,7 +909,7 @@ new SimGroup(VideoSettingsGroup) }; }; - new SimGroup() + new SimGroup(PostFXLightRayOptionsGroup) { class = "OptionsSettings"; OptionName = "Light Rays"; @@ -1008,6 +1013,126 @@ function VideoSettingsGroup::populateDisplaySettings(%this) DisplayRefreshSettingsGroup.add(%entry); } } + +function DisplayDevicesGroup::onApply(%this) +{ + updateDisplayOptionsSettings(); +} + +function DisplayModeGroup::onApply(%this) +{ + updateDisplayOptionsSettings(); +} + +function DisplayResSettingsGroup::onApply(%this) +{ + updateDisplayOptionsSettings(); +} + +function VSyncSettingsGroup::onApply(%this) +{ + updateDisplayOptionsSettings(); +} + +function DisplayRefreshSettingsGroup::onApply(%this) +{ + updateDisplayOptionsSettings(); +} + +function updateDisplayOptionsSettings() +{ + //Update the display settings now + %deviceName = getDisplayDeviceName(); + %newDeviceID = getWord(%deviceName, 0) - 1; + + %deviceModeName = getField($Video::ModeTags, $pref::Video::deviceMode); + %newDeviceMode = 0; + foreach$(%modeName in $Video::ModeTags) + { + if (%deviceModeName $= %modeName) + break; + else + %newDeviceMode++; + } + + if($pref::Video::deviceMode == $Video::ModeBorderless) + { + //if we're changing to borderless, we swap to the full resolution of the desktop + $pref::Video::mode = Canvas.getBestCanvasRes($pref::Video::deviceId, $pref::Video::deviceMode); + + $pref::Video::Resolution = $pref::Video::mode.x SPC $pref::Video::mode.y; + } + + %newRes = $pref::Video::Resolution; + %newBpp = 32; // ... its not 1997 anymore. + %newFullScreen = %deviceModeName $= "Fullscreen" ? true : false; + %newRefresh = $pref::Video::RefreshRate; + %newVsync = $pref::Video::enableVerticalSync; + %newAA = $pref::Video::AA; + + // Build the final mode string. + %newMode = $pref::Video::Resolution SPC %newFullScreen SPC %newBpp SPC %newRefresh SPC %newAA; + + // Change the video mode. + if ( %newMode !$= $pref::Video::mode || %newDeviceID != $pref::Video::deviceId || + %newVsync != $pref::Video::enableVerticalSync || %newDeviceMode != $pref::Video::deviceMode) + { + //****Edge Case Hack + // If we're in fullscreen mode and switching to a different monitor at the + // same resolution and maintaining fullscreen, GFX...WindowTarget::resetMode() + // will early-out because there is no "mode change" and the monitor change + // will not get applied. Instead of modifying platform code, we're going to + // move onto the new monitor in borderless and immediately switch to FS. + if (%newFullScreen && $pref::Video::FullScreen && + ($pref::Video::Resolution $= %newRes) && ($pref::Video::deviceId != %newDeviceID)) + { + $pref::Video::deviceId = %newDeviceID; + $pref::Video::deviceMode = $Video::ModeBorderless; + %tmpModeStr = Canvas.getMonitorMode(%newDeviceID, 0); + Canvas.setVideoMode(%tmpModeStr.x, %tmpModeStr.y, false, 32, getWord(%tmpModeStr, $WORD::REFRESH), %newAA); + } + + $pref::Video::mode = %newMode; + $pref::Video::enableVerticalSync = %newVsync; + $pref::Video::deviceId = %newDeviceID; + $pref::Video::deviceMode = %newDeviceMode; + $pref::Video::Resolution = %newRes; + $pref::Video::FullScreen = %newFullScreen; + $pref::Video::RefreshRate = %newRefresh; + $pref::Video::AA = %newAA; + configureCanvas(); + } +} + +function TextureQualityGroup::onApply(%this) +{ + reloadTextures(); +} + +function PostFXSSAOOptionsGroup::onApply(%this) +{ + %currentLevel = %this.getCurrentQualityLevel(); + PostFXManager.settingsEffectSetEnabled(SSAOPostFx, %currentLevel.getKey(0)); +} + +function PostFXDOFOptionsGroup::onApply(%this) +{ + %currentLevel = %this.getCurrentQualityLevel(); + PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, %currentLevel.getKey(0)); +} + +function PostFXVignetteOptionsGroup::onApply(%this) +{ + %currentLevel = %this.getCurrentQualityLevel(); + PostFXManager.settingsEffectSetEnabled(vignettePostFX, %currentLevel.getKey(0)); +} + +function PostFXLightRayOptionsGroup::onApply(%this) +{ + %currentLevel = %this.getCurrentQualityLevel(); + PostFXManager.settingsEffectSetEnabled(LightRayPostFX, %currentLevel.getKey(0)); +} + function getCurrentQualityLevel(%qualityGroup) { for ( %i=0; %i < %qualityGroup.getCount(); %i++ ) @@ -1046,11 +1171,6 @@ function AutodetectGraphics() %intel = ( strstr( strupr( getDisplayDeviceInformation() ), "INTEL" ) != -1 ) ? true : false; %videoMem = GFXCardProfilerAPI::getVideoMemoryMB(); - return AutodetectGraphics_Apply( %shaderVer, %intel, %videoMem ); -} - -function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) -{ if ( %shaderVer < 2.0 ) { echo("Your video card does not meet the minimum requirment of shader model 2.0."); @@ -1074,17 +1194,14 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) $pref::Shadows::useShadowCaching = true; - $pref::Water::enableTrueReflections = false; - $pref::Video::enableParallaxMapping = false; - $pref::PostFX::EnableSSAO = false; - $pref::PostFX::EnableHDR = false; - $pref::PostFX::EnableDOF = false; - $pref::PostFX::EnableLightRays = false; - $pref::PostFX::EnableVignette = false; - - $pref::Video::AAMode = "None"; - $pref::Video::AA = 0; - $pref::Video::defaultAnisotropy = 0; + AnisotropicFilterOptionsGroup.applySetting("None"); + AntiAliasingOptionsGroup.applySetting("Off"); + ParallaxOptionsGroup.applySetting("Off"); + TrueWaterReflectionsOptionsGroup.applySetting("Off"); + PostFXSSAOOptionsGroup.applySetting("Off"); + PostFXDOFOptionsGroup.applySetting("Off"); + PostFXVignetteOptionsGroup.applySetting("Off"); + PostFXLightRayOptionsGroup.applySetting("Off"); } else { @@ -1101,17 +1218,14 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) $pref::Shadows::useShadowCaching = true; - $pref::Water::enableTrueReflections = false; - $pref::Video::enableParallaxMapping = false; - $pref::PostFX::EnableSSAO = false; - $pref::PostFX::EnableHDR = false; - $pref::PostFX::EnableDOF = false; - $pref::PostFX::EnableLightRays = false; - $pref::PostFX::EnableVignette = false; - - $pref::Video::AAMode = "None"; - $pref::Video::AA = 0; - $pref::Video::defaultAnisotropy = 0; + AnisotropicFilterOptionsGroup.applySetting("None"); + AntiAliasingOptionsGroup.applySetting("Off"); + ParallaxOptionsGroup.applySetting("Off"); + TrueWaterReflectionsOptionsGroup.applySetting("Off"); + PostFXSSAOOptionsGroup.applySetting("Off"); + PostFXDOFOptionsGroup.applySetting("Off"); + PostFXVignetteOptionsGroup.applySetting("Off"); + PostFXLightRayOptionsGroup.applySetting("Off"); } } else @@ -1132,17 +1246,14 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) //Should this default to on in ultra settings? $pref::Shadows::useShadowCaching = true; - $pref::Water::enableTrueReflections = true; - $pref::Video::enableParallaxMapping = true; - $pref::PostFX::EnableSSAO = true; - $pref::PostFX::EnableHDR = true; - $pref::PostFX::EnableDOF = true; - $pref::PostFX::EnableLightRays = true; - $pref::PostFX::EnableVignette = true; - - $pref::Video::AAMode = "SMAA High"; - $pref::Video::AA = 4; - $pref::Video::defaultAnisotropy = 16; + AnisotropicFilterOptionsGroup.applySetting("16x"); + AntiAliasingOptionsGroup.applySetting("SMAA High"); + ParallaxOptionsGroup.applySetting("On"); + TrueWaterReflectionsOptionsGroup.applySetting("On"); + PostFXSSAOOptionsGroup.applySetting("On"); + PostFXDOFOptionsGroup.applySetting("On"); + PostFXVignetteOptionsGroup.applySetting("On"); + PostFXLightRayOptionsGroup.applySetting("On"); } else if ( %videoMem > 400 || %videoMem == 0 ) { @@ -1159,17 +1270,14 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) $pref::Shadows::useShadowCaching = true; - $pref::Water::enableTrueReflections = true; - $pref::Video::enableParallaxMapping = true; - $pref::PostFX::EnableSSAO = false; - $pref::PostFX::EnableHDR = true; - $pref::PostFX::EnableDOF = true; - $pref::PostFX::EnableLightRays = true; - $pref::PostFX::EnableVignette = true; - - $pref::Video::AAMode = "SMAA"; - $pref::Video::AA = 4; - $pref::Video::defaultAnisotropy = 4; + AnisotropicFilterOptionsGroup.applySetting("4x"); + AntiAliasingOptionsGroup.applySetting("SMAA"); + ParallaxOptionsGroup.applySetting("On"); + TrueWaterReflectionsOptionsGroup.applySetting("On"); + PostFXSSAOOptionsGroup.applySetting("Off"); + PostFXDOFOptionsGroup.applySetting("On"); + PostFXVignetteOptionsGroup.applySetting("On"); + PostFXLightRayOptionsGroup.applySetting("On"); if ( %videoMem == 0 ) echo("Torque was unable to detect available video memory. Applying 'Medium' quality."); @@ -1189,31 +1297,17 @@ function AutodetectGraphics_Apply(%shaderVer, %intel, %videoMem ) $pref::Shadows::useShadowCaching = true; - $pref::Water::enableTrueReflections = true; - $pref::Video::enableParallaxMapping = true; - $pref::PostFX::EnableSSAO = false; - $pref::PostFX::EnableHDR = false; - $pref::PostFX::EnableDOF = false; - $pref::PostFX::EnableLightRays = false; - $pref::PostFX::EnableVignette = false; - - $pref::Video::AAMode = "FXAA"; - $pref::Video::AA = 0; - $pref::Video::defaultAnisotropy = 0; + AnisotropicFilterOptionsGroup.applySetting("None"); + AntiAliasingOptionsGroup.applySetting("FXAA"); + ParallaxOptionsGroup.applySetting("On"); + TrueWaterReflectionsOptionsGroup.applySetting("On"); + PostFXSSAOOptionsGroup.applySetting("Off"); + PostFXDOFOptionsGroup.applySetting("Off"); + PostFXVignetteOptionsGroup.applySetting("Off"); + PostFXLightRayOptionsGroup.applySetting("Off"); } } - //%this.refresh(); - - //%this.apply(); - - //force postFX updates - PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO); - PostFXManager.settingsEffectSetEnabled(HDRPostFX, $pref::PostFX::EnableHDR); - PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, $pref::PostFX::EnableDOF); - PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays); - PostFXManager.settingsEffectSetEnabled(VignettePostFX, $pref::PostFX::EnableVignette); - echo("Graphics quality settings have been auto detected."); } @@ -1352,4 +1446,20 @@ function getDisplayDeviceId(%displayDeviceName) } return -1; +} + +function getDisplayDeviceName() +{ + %numDevices = Canvas.getMonitorCount(); + %devicesList = ""; + for(%i = 0; %i < %numDevices; %i++) + { + %device = (%i+1) @ " - " @ Canvas.getMonitorName(%i); + if(%i==0) + %devicesList = %device; + else + %devicesList = %devicesList @ "\t" @ %device; + } + + return getField(%devicesList, $pref::Video::deviceId); } \ No newline at end of file diff --git a/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript b/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript index 19417c2e4..eb72c3f86 100644 --- a/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript +++ b/Templates/BaseGame/game/core/sfx/scripts/audioOptions.tscript @@ -80,3 +80,24 @@ function AudioSettingsGroup::populateSettings(%this) AudioSettingsDeviceGroup.add(%deviceEntry); } } + +function AudioSettingsProviderGroup::onApply(%this) +{ + updateAudioOptionsSettings(); +} + +function AudioSettingsDeviceGroup::onApply(%this) +{ + updateAudioOptionsSettings(); +} + +function updateAudioOptionsSettings() +{ + if ( !sfxCreateDevice( $pref::SFX::provider, + $pref::SFX::device, + $pref::SFX::useHardware, + -1 ) ) + error( "Unable to create SFX device: " @ $pref::SFX::provider + SPC $pref::SFX::device + SPC $pref::SFX::useHardware ); +} \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 0f3fe9f24..a4a14d996 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -115,6 +115,9 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( keyboard, R, OptionsMenuReset ); OptionsMenuActionMap.bind( gamepad, btn_x, OptionsMenuReset ); + + OptionsMenuActionMap.bind( keyboard, Enter, OptionsMenuActivateOption ); + OptionsMenuActionMap.bind( gamepad, btn_a, OptionsMenuActivateOption ); } function OptionsMenuList::syncGui(%this) @@ -178,6 +181,49 @@ function OptionsMenuList::syncGui(%this) } } +function OptionsMenuList::checkForUnappliedChanges(%this) +{ + %unappliedChanges = false; + + foreach(%option in %this) + { + if(%option.class $= "OptionsListEntry") + { + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + if(!%targetOptionLevel.isCurrent()) + %unappliedChanges = true; + + if(%option.optionsObject.requiresRestart) + $optionsChangeRequiresRestart = true; + } + } + } + + return %unappliedChanges; +} + +function OptionsMenuList::applyChanges(%this) +{ + foreach(%option in %this) + { + if(%option.class $= "OptionsListEntry") + { + //If it's custom or nonsensical index, there's some kind of external factor going on, so we're + //just going to skip applying it because we don't know what we'd be applying + if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) + { + %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); + + if(!%targetOptionLevel.isCurrent()) + %targetOptionLevel.apply(); + } + } + } +} + function OptionsMenu::openOptionsCategory(%this, %categoryName) { VideoSettingsList.setVisible(%categoryName $= "Video"); @@ -343,7 +389,7 @@ function OptionMenuPrevSetting(%val) %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + //echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); } $MenuList.syncGUI(); @@ -368,7 +414,7 @@ function OptionMenuNextSetting(%val) %newOptionLevel = %optionObject.getObject(%option.currentOptionIndex); - echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); + //echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); } $MenuList.syncGUI(); @@ -379,6 +425,23 @@ function OptionMenuStickChangeSetting(%val) } +function OptionsMenuActivateOption(%val) +{ + if(!%val) + return; + + %option = $MenuList.getObject($MenuList.listPosition); + + if(!isObject(%option)) + return; + + echo(%option.class); + + if(%option.class $= "OptionsKeybindEntry") + { + eval(%option-->button.altCommand); + } +} // // // @@ -584,53 +647,12 @@ function tryCloseOptionsMenu(%val) if(!%val) return; - //scan through all our options and see if any are any unapplied changes. If - //so we need to prompt to apply or discard them - %unappliedChanges = false; + $optionsChangeRequiresRestart = false; - foreach(%option in VideoSettingsList) - { - if(%option.class $= "OptionsListEntry") - { - if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) - { - %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); - - echo("tryCloseOptionsMenu() - testing option: " @ %option.optionsObject.optionName @ " target level of: " @ %targetOptionLevel.displayName); - - if(!%targetOptionLevel.isCurrent()) - { - %unappliedChanges = true; - break; - } - } - } - } + %unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges(); + %unappliedAudioChanges = AudioSettingsList.checkForUnappliedChanges(); - //check if we already have unapplied changes, so we can skip further iterating - if(!%unappliedChanges) - { - foreach(%option in AudioSettingsList) - { - if(%option.class $= "OptionsListEntry") - { - if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) - { - %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); - - echo("tryCloseOptionsMenu() - testing option: " @ %option.optionsObject.optionName @ " target level of: " @ %targetOptionLevel.displayName); - - if(!%targetOptionLevel.isCurrent()) - { - %unappliedChanges = true; - break; - } - } - } - } - } - - if(%unappliedChanges) + if(%unappliedVideoChanges || %unappliedAudioChanges) { MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", "OptionsMenu.applyChangedOptions();", "Canvas.popDialog(OptionsMenu);", @@ -640,53 +662,27 @@ function tryCloseOptionsMenu(%val) { Canvas.popDialog(OptionsMenu); } -} +} function OptionsMenu::applyChangedOptions(%this) { - foreach(%option in VideoSettingsList) - { - if(%option.class $= "OptionsListEntry") - { - //If it's custom or nonsensical index, there's some kind of external factor going on, so we're - //just going to skip applying it because we don't know what we'd be applying - if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) - { - %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); - - if(!%targetOptionLevel.isCurrent()) - { - echo("Applying setting of " @ %option.optionsObject.optionName); - %targetOptionLevel.apply(); - } - } - } - } + VideoSettingsList.applyChanges(); + AudioSettingsList.applyChanges(); - foreach(%option in AudioSettingsList) - { - if(%option.class $= "OptionsListEntry") - { - //If it's custom or nonsensical index, there's some kind of external factor going on, so we're - //just going to skip applying it because we don't know what we'd be applying - if(%option.currentOptionIndex >= 0 && %option.currentOptionIndex < %option.optionsObject.getCount()) - { - %targetOptionLevel = %option.optionsObject.getObject(%option.currentOptionIndex); - - if(!%targetOptionLevel.isCurrent()) - { - echo("Applying setting of " @ %option.optionsObject.optionName); - %targetOptionLevel.apply(); - } - } - } - } + //$pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2); + sfxSetMasterVolume( $pref::SFX::masterVolume ); + sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] ); + sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); + sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] ); //Finally, write our prefs to file %prefPath = getPrefpath(); export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); Canvas.popDialog(OptionsMenu); + + if($optionsChangeRequiresRestart) + MessageBoxOK("Restart Required", "Some of your changes require the game to be restarted."); } function doKeyRemap( %optionEntry ) @@ -841,442 +837,11 @@ function OptionsMenu::apply(%this) OptionsMenu.unappliedChanges.empty(); } -function OptionsMenu::resetToDefaults(%this) +function OptionsMenu::resetSettings(%this) { MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", ""); } -// -// old ones -// -function populateDisplaySettingsList() -{ - OptionsMenuSettingsList.clear(); - - OptionsMenu.currentCategory = "Display"; - - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); - - %apiList = ""; - %apiCount = GFXInit::getAdapterCount(); - %apiIdx = 0; - for(%i=0; %i < %apiCount; %i++) - { - %api = GFXInit::getAdapterType(%i); - - if(%api !$= "NullDevice") - { - if(%apiIdx==0) - %apiList = %api; - else - %apiList = %apiList TAB %api; - - %apiIdx++; - } - } - - trim(%apiList); - - %displayDevice = OptionsMenu.getOptionVariableValue("$pref::Video::displayDevice"); - if(%displayDevice $= "") - %displayDevice = getDisplayDeviceType(); - - OptionsMenuSettingsList.addOptionRow("Display API", "$pref::Video::displayDevice", %apiList, false, "", true, "The display API used for rendering.", %displayDevice); - - %numDevices = Canvas.getMonitorCount(); - - %devicesList = getDisplayDeviceList(); - - if($pref::Video::displayDeviceId $= "") - $pref::Video::displayDeviceId = getField(%devicesList, $pref::Video::deviceId); - - OptionsMenuSettingsList.addOptionRow("Display Device", "$pref::Video::displayDeviceId", %devicesList, false, "", true, "The display devices the window should be on."); - - if (%numDevices > 1) - OptionsMenuSettingsList.setRowEnabled(1, true); - else - OptionsMenuSettingsList.setRowEnabled(1, false); - - %mode = OptionsMenu.getOptionVariableValue("$pref::Video::deviceMode"); - if(isInt(%mode)) - %mode = getField($Video::ModeTags, $pref::Video::deviceMode); - OptionsMenuSettingsList.addOptionRow("Window Mode", "$pref::Video::deviceMode", $Video::ModeTags, false, "", true, "", %mode); - - if(%mode !$= "Borderless") - { - %resolutionList = getScreenResolutionList($pref::Video::deviceId, $Video::Mode[%mode]); - %resolution = OptionsMenu.getOptionVariableValue("$pref::Video::Resolution"); - if(%resolution $= "") - %resolution = $pref::Video::mode; - - %resolution = _makePrettyResString(%resolution); - - OptionsMenuSettingsList.addOptionRow("Resolution", "$pref::Video::Resolution", %resolutionList, false, "", true, "Resolution of the game window", %resolution); - - // If the requested resolution could not be set, mark the control and pref as changed. - %resControl = OptionsMenuSettingsList.getObject(OptionsMenuSettingsList.getCount()-1); - if (%resControl.getCurrentOption() !$= %resolution) - %resControl.onChange(); - } - - OptionsMenuSettingsList.addOptionBoolRow("VSync", "$pref::Video::enableVerticalSync", $YesNoList, false, "", true, "", ""); - - - %refreshList = getScreenRefreshList($pref::Video::mode); - OptionsMenuSettingsList.addOptionRow("Refresh Rate", "$pref::Video::RefreshRate", %refreshList, false, "", true, "", OptionsMenu.getOptionVariableValue("$pref::Video::RefreshRate")); - - //move to gameplay tab - //OptionsMenuSettingsList.addSliderRow("Field of View", "", 75, 5, "65 100", ""); - - //OptionsMenuSettingsList.addSliderRow("Brightness", "", 0.5, 0.1, "0 1", ""); - //OptionsMenuSettingsList.addSliderRow("Contrast", "", 0.5, 0.1, "0 1", ""); -} - -// -// -// -function populateGraphicsSettingsList() -{ - OptionsMenuSettingsList.clear(); - - OptionsMenu.currentCategory = "Graphics"; - - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); - - %yesNoList = "No\tYes"; - %onOffList = "Off\tOn"; - %anisoFilter = "Off\t4\t8\t16"; - %aaTypeFilter = "None\tFXAA\tSMAA\tSMAA High"; - OptionsMenuSettingsList.addOptionQualityLevelRow("Lighting Quality", "$pref::Graphics::LightingQuality", - LightingQualityList, false, "", true, "Amount and drawdistance of local lights"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Shadow Quality", "$pref::Graphics::ShadowQuality", - ShadowQualityList, false, "", true, "Shadow revolution quality"); - - %shadowQuality = OptionsMenu.getOptionVariableValue("$pref::Graphics::ShadowQuality"); - if(%shadowQuality !$= "None") - { - OptionsMenuSettingsList.addOptionQualityLevelRow("Soft Shadow Quality", "$pref::Graphics::SoftShadowQuality", - SoftShadowList, false, "", true, "Amount of softening applied to shadowmaps"); - } - - OptionsMenuSettingsList.addOptionQualityLevelRow("Mesh Quality", "$pref::Graphics::MeshQuality", - MeshQualityGroup, false, "", true, "Fidelity of rendering of mesh objects"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Object Draw Distance", "$pref::Graphics::ObjectDrawDistance", - MeshDrawDistQualityGroup, false, "", true, "Dictates if and when static objects fade out in the distance"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Texture Quality", "$pref::Graphics::TextureQuality", - TextureQualityGroup, false, "", true, "Fidelity of textures"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Terrain Quality", "$pref::Graphics::TerrainQuality", - TerrainQualityGroup, false, "", true, "Quality level of terrain objects"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Decal Lifetime", "$pref::Graphics::DecalLifetime", - DecalLifetimeGroup, false, "", true, "How long decals are rendered"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Ground Cover Density", "$pref::Graphics::GroundCoverDensity", - GroundCoverDensityGroup, false, "", true, "Density of ground cover items, such as grass"); - OptionsMenuSettingsList.addOptionQualityLevelRow("Shader Quality", "$pref::Graphics::ShaderQuality", - ShaderQualityGroup, false, "", true, "Dictates the overall shader quality level, adjusting what features are enabled."); - OptionsMenuSettingsList.addOptionRow("Anisotropic Filtering", "$pref::Video::defaultAnisotropy", %anisoFilter, false, "", true, "Amount of Anisotropic Filtering on textures, which dictates their sharpness at a distance"); - - OptionsMenuSettingsList.addOptionRow("Anti-Aliasing Type", "$pref::Video::AAMode", %aaTypeFilter, false, "", true, "The Anti-Aliasing Method applied to rendering"); - - OptionsMenuSettingsList.addOptionBoolRow("Parallax", "$pref::Video::enableParallaxMapping", %onOffList, false, "", true, "Whether the surface parallax shader effect is enabled", ""); - OptionsMenuSettingsList.addOptionBoolRow("Water Reflections", "$pref::Water::enableTrueReflections", %onOffList, false, "", true, "Whether water reflections are enabled", ""); - - OptionsMenuSettingsList.addOptionBoolRow("SSAO", "$pref::PostFX::EnableSSAO", %onOffList, false, "", true, "Whether Screen-Space Ambient Occlusion is enabled"); - OptionsMenuSettingsList.addOptionBoolRow("Depth of Field", "$pref::PostFX::EnableDOF", %onOffList, false, "", true, "Whether the Depth of Field effect is enabled"); - OptionsMenuSettingsList.addOptionBoolRow("Vignette", "$pref::PostFX::EnableVignette", %onOffList, false, "", true, "Whether the vignette effect is enabled"); - OptionsMenuSettingsList.addOptionBoolRow("Light Rays", "$pref::PostFX::EnableLightRays", %onOffList, false, "", true, "Whether the light rays effect is enabled"); -} - -function updateGraphicsSettings() -{ - if($pref::Graphics::LightingQuality !$= getCurrentQualityLevel(LightingQualityList)) - LightingQualityList.applySetting($pref::Graphics::LightingQuality); - if($pref::Graphics::ShadowQuality !$= getCurrentQualityLevel(ShadowQualityList)) - ShadowQualityList.applySetting($pref::Graphics::ShadowQuality); - if($pref::Graphics::SoftShadowQuality !$= getCurrentQualityLevel(SoftShadowList)) - SoftShadowList.applySetting($pref::Graphics::SoftShadowQuality); - - if($pref::Graphics::MeshQuality !$= getCurrentQualityLevel(MeshQualityGroup)) - MeshQualityGroup.applySetting($pref::Graphics::MeshQuality); - if($pref::Graphics::ObjectDrawDistance !$= getCurrentQualityLevel(MeshDrawDistQualityGroup)) - MeshDrawDistQualityGroup.applySetting($pref::Graphics::ObjectDrawDistance); - if($pref::Graphics::TextureQuality !$= getCurrentQualityLevel(TextureQualityGroup)) - { - TextureQualityGroup.applySetting($pref::Graphics::TextureQuality); - - reloadTextures(); - } - if($pref::Graphics::TerrainQuality !$= getCurrentQualityLevel(TerrainQualityGroup)) - TerrainQualityGroup.applySetting($pref::Graphics::TerrainQuality); - if($pref::Graphics::DecalLifetime !$= getCurrentQualityLevel(DecalLifetimeGroup)) - DecalLifetimeGroup.applySetting($pref::Graphics::DecalLifetime); - if($pref::Graphics::GroundCoverDensity !$= getCurrentQualityLevel(GroundCoverDensityGroup)) - GroundCoverDensityGroup.applySetting($pref::Graphics::GroundCoverDensity); - if($pref::Graphics::ShaderQuality !$= getCurrentQualityLevel(ShaderQualityGroup)) - { - ShaderQualityGroup.applySetting($pref::Graphics::ShaderQuality); - //this has ties into postFX behaviors, so we'll force an update to it here - updatePostFXSettings(); - } -} - -/*function updateDisplaySettings() -{ - //Update the display settings now - %deviceName = getDisplayDeviceName(); - %newDeviceID = getWord(%deviceName, 0) - 1; - - if(!isInt($pref::Video::deviceMode)) - { - //probably saved out as the mode name, so just translate it back - for(%i=0; %i < getFieldCount($Video::ModeTags); %i++) - { - if(getField($Video::ModeTags, %i) $= $pref::Video::deviceMode) - { - $pref::Video::deviceMode = %i; - break; - } - } - } - - %deviceModeName = getField($Video::ModeTags, $pref::Video::deviceMode); - %newDeviceMode = 0; - foreach$(%modeName in $Video::ModeTags) - { - if (%deviceModeName $= %modeName) - break; - else - %newDeviceMode++; - } - - if($pref::Video::deviceMode == $Video::ModeBorderless) - { - //if we're changing to borderless, we swap to the full resolution of the desktop - $pref::Video::mode = Canvas.getBestCanvasRes($pref::Video::deviceId, $pref::Video::deviceMode); - - $pref::Video::Resolution = $pref::Video::mode.x SPC $pref::Video::mode.y; - } - - %newRes = $pref::Video::Resolution; - %newBpp = 32; // ... its not 1997 anymore. - %newFullScreen = %deviceModeName $= "Fullscreen" ? true : false; - %newRefresh = $pref::Video::RefreshRate; - %newVsync = $pref::Video::enableVerticalSync; - %newAA = $pref::Video::AA; - - // Build the final mode string. - %newMode = $pref::Video::Resolution SPC %newFullScreen SPC %newBpp SPC %newRefresh SPC %newAA; - - // Change the video mode. - if ( %newMode !$= $pref::Video::mode || %newDeviceID != $pref::Video::deviceId || - %newVsync != $pref::Video::enableVerticalSync || %newDeviceMode != $pref::Video::deviceMode) - { - //****Edge Case Hack - // If we're in fullscreen mode and switching to a different monitor at the - // same resolution and maintaining fullscreen, GFX...WindowTarget::resetMode() - // will early-out because there is no "mode change" and the monitor change - // will not get applied. Instead of modifying platform code, we're going to - // move onto the new monitor in borderless and immediately switch to FS. - if (%newFullScreen && $pref::Video::FullScreen && - ($pref::Video::Resolution $= %newRes) && ($pref::Video::deviceId != %newDeviceID)) - { - $pref::Video::deviceId = %newDeviceID; - $pref::Video::deviceMode = $Video::ModeBorderless; - %tmpModeStr = Canvas.getMonitorMode(%newDeviceID, 0); - Canvas.setVideoMode(%tmpModeStr.x, %tmpModeStr.y, false, 32, getWord(%tmpModeStr, $WORD::REFRESH), %newAA); - } - - $pref::Video::mode = %newMode; - $pref::Video::enableVerticalSync = %newVsync; - $pref::Video::deviceId = %newDeviceID; - $pref::Video::deviceMode = %newDeviceMode; - $pref::Video::Resolution = %newRes; - $pref::Video::FullScreen = %newFullScreen; - $pref::Video::RefreshRate = %newRefresh; - $pref::Video::AA = %newAA; - configureCanvas(); - } -}*/ - -function updatePostFXSettings() -{ - PostFXManager.settingsEffectSetEnabled(SSAOPostFx, $pref::PostFX::EnableSSAO); - PostFXManager.settingsEffectSetEnabled(DepthOfFieldPostFX, $pref::PostFX::EnableDOF); - PostFXManager.settingsEffectSetEnabled(LightRayPostFX, $pref::PostFX::EnableLightRays); - PostFXManager.settingsEffectSetEnabled(vignettePostFX, $pref::PostFX::EnableVignette); -} - -// -// -// -function populateAudioSettingsList() -{ - OptionsMenuSettingsList.clear(); - - OptionsMenu.currentCategory = "Audio"; - - if(isObject(OptionName)) - OptionName.setText(""); - if(isObject(OptionDescription)) - OptionDescription.setText(""); - - %buffer = sfxGetAvailableDevices(); - %count = getRecordCount( %buffer ); - %audioDriverList = ""; - %audioProviderList = ""; - %audioDeviceList = ""; - - $currentAudioProvider = $currentAudioProvider $= "" ? $pref::SFX::provider : $currentAudioProvider; - - for(%i = 0; %i < %count; %i++) - { - %record = getRecord(%buffer, %i); - %provider = getField(%record, 0); - %device = getField(%record, 1); - - //When the client is actually running, we don't care about null audo devices - if(%provider $= "null") - continue; - - if(%audioProviderList $= "") - %audioProviderList = %provider; - else - %audioProviderList = %audioProviderList @ "\t" @ %provider; - - if(%provider $= $currentAudioProvider) - { - if(%audioDeviceList $= "") - %audioDeviceList = %device; - else - %audioDeviceList = %audioDeviceList @ "\t" @ %device; - } - } - - OptionsMenuSettingsList.addOptionRow("Audio Provider", "$pref::SFX::provider", %audioProviderList, false, "audioProviderChanged", true, ""); - OptionsMenuSettingsList.addOptionRow("Audio Device", "$pref::SFX::device", %audioDeviceList, false, "", true); - - OptionsMenuSettingsList.addSliderRow("Master Volume", "$pref::SFX::masterVolume", 0.1, "0 1", ""); - OptionsMenuSettingsList.addSliderRow("GUI Volume", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0.1, "0 1", ""); - OptionsMenuSettingsList.addSliderRow("Effects Volume", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0.1, "0 1", ""); - OptionsMenuSettingsList.addSliderRow("Music Volume", "$pref::SFX::channelVolume[" @ $MusicAudioType @ "]", 0.1, "0 1", ""); -} - -function audioProviderChanged() -{ - //Get the option we have set for the provider - %provider = OptionsMenuSettingsList.getCurrentOption(0); - $currentAudioProvider = %provider; - - //And now refresh the list to get the correct devices - populateAudioSettingsList(); -} - -function updateAudioSettings() -{ - //$pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2); - sfxSetMasterVolume( $pref::SFX::masterVolume ); - - //$pref::SFX::channelVolume[ $GuiAudioType ] = OptionsMenuSettingsList.getValue(3); - //$pref::SFX::channelVolume[ $SimAudioType ] = OptionsMenuSettingsList.getValue(4); - //$pref::SFX::channelVolume[ $MusicAudioType ] = OptionsMenuSettingsList.getValue(5); - - sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] ); - sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); - sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] ); - - //$pref::SFX::provider = OptionsMenuSettingsList.getCurrentOption(0); - //$pref::SFX::device = OptionsMenuSettingsList.getCurrentOption(1); - - if ( !sfxCreateDevice( $pref::SFX::provider, - $pref::SFX::device, - $pref::SFX::useHardware, - -1 ) ) - error( "Unable to create SFX device: " @ $pref::SFX::provider - SPC $pref::SFX::device - SPC $pref::SFX::useHardware ); - - if( !isObject( $AudioTestHandle ) ) - { - sfxPlay(menuButtonPressed); - } -} - -// -// -// -function MenuOptionsButton::onChange(%this) -{ - %optionMode = %this.getMode(); - %optionName = %this.getLabel(); - %tooltipText = %this.getTooltip(); - - %targetVar = %this.targetPrefVar; - - OptionName.setText(%optionName); - OptionDescription.setText(%tooltipText); - - if(%optionMode == 0) - { - %currentValue = %this.getCurrentOption(); - if(%currentValue !$= "") - { - if(%currentValue $= "yes" || %currentValue $= "on") - %saveReadyValue = 1; - else if(%currentValue $= "no" || %currentValue $= "off") - %saveReadyValue = 0; - else - %saveReadyValue = %currentValue; - - %prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar); - if(%prefIndex == -1) - { - echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %saveReadyValue); - OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %saveReadyValue @ "\"" ); - } - else - { - echo("Setting UnappliedChanges via modify: key:" @ %targetVar @", value: " @ %saveReadyValue); - OptionsMenu.unappliedChanges.setValue("\"" @ %saveReadyValue @ "\"", %prefIndex); - } - } - } - else if(%optionMode == 1) - { - %currentValue = %this.getValue(); - - %prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%targetVar); - if(%prefIndex == -1) - { - echo("Setting UnappliedChanges via add: key:" @ %targetVar @", value: " @ %currentValue); - OptionsMenu.unappliedChanges.add(%targetVar, "\"" @ %currentValue @ "\"" ); - } - else - { - OptionsMenu.unappliedChanges.setValue("\"" @ %currentValue @ "\"", %prefIndex); - } - } - - //Update the UI in case there's responsive logic - OptionsMenu.schedule(32, "refresh"); -} - -function OptionsMenu::onKeybindChanged(%this, %actionMap, %keybind) -{ - %prefIndex = OptionsMenu.unappliedChanges.getIndexFromKey(%actionMap); - if(%prefIndex == -1) - OptionsMenu.unappliedChanges.add(%actionMap, %keybind); - else - OptionsMenu.unappliedChanges.setValue(%keybind, %prefIndex); -} - -// -// new -// function addOptionGroup(%displayName) { %group = new GuiTextCtrl() { From 4ed617f7dfab2914d1df9dcb58eb6f5805fd5c88 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Wed, 20 Dec 2023 18:51:12 -0600 Subject: [PATCH 07/19] fix type list popup display --- Engine/source/gui/editor/guiInspectorTypes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/gui/editor/guiInspectorTypes.cpp b/Engine/source/gui/editor/guiInspectorTypes.cpp index 7cb489163..49d693523 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.cpp +++ b/Engine/source/gui/editor/guiInspectorTypes.cpp @@ -61,7 +61,7 @@ GuiControl* GuiInspectorTypeMenuBase::constructEditControl() GuiPopUpMenuCtrl *menu = dynamic_cast(retCtrl); // Let's make it look pretty. - retCtrl->setDataField( StringTable->insert("profile"), NULL, "GuiPopUpMenuProfile" ); + retCtrl->setDataField( StringTable->insert("profile"), NULL, "ToolsGuiPopupMenuProfile" ); _registerEditControl( retCtrl ); // Configure it to update our value when the popup is closed From 5d2d04791dad1e0302de6e7506187907e0ee2153 Mon Sep 17 00:00:00 2001 From: Areloch Date: Thu, 21 Dec 2023 23:59:19 -0600 Subject: [PATCH 08/19] Cleaned up old, deprecated apply function causing confusion Cleaned up old refs to previous unapplied changes system Added comments to some critical functions to better explain their behavior and purpose, as well as referencing the source files for the graphic and audio options groups --- .../game/data/UI/guis/optionsMenu.tscript | 226 ++---------------- 1 file changed, 26 insertions(+), 200 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index a4a14d996..93762fb81 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -1,53 +1,3 @@ -//options settings - -//Screen and Display menu -//Renderer Mode -//Screen resolution -//Windowed/fullscreen(borderless?) -//VSync - -//Screen brightness -//screen brightness -//screen gamma - -//Lighting Menu -//Shadow Distance(Distance shadows are drawn to. Also affects shadowmap slices) -//Shadow Quality(Resolution of shadows rendered, setting to none disables dynamic shadows) -//Soft Shadows(Whether shadow softening is used) -//Shadow caching(If the lights enable it, shadow caching is activated) -//Light Draw Distance(How far away lights are still drawn. Doesn't impact vector lights like the sun) - -//Mesh and Textures Menu -//Draw distance(Overall draw distance) -slider -//Object draw distance(Draw distance from small/unimportant objects) -slider -//Mesh quality -//Texture quality -//Foliage draw distance -//Terrain Quality -//Decal Quality - -//Effects Menu -//Parallax -//HDR -//Light shafts -//Motion Blur -//Depth of Field -//SSAO -//AA(ModelXAmount)[defualt is FXAA] -//Anisotropic filtering - -//Keybinds - -//Camera -//horizontal mouse sensitivity -//vert mouse sensitivity -//invert vertical -//zoom mouse sensitivities(both horz/vert) -//headbob -//FOV - -$yesNoList = "No\tYes"; -$onOffList = "Off\tOn"; $optionsEntryPad = 10; $OptionsMenuCategories[0] = "Video"; @@ -62,11 +12,6 @@ function OptionsMenu::onAdd(%this) %this.optionsCategories = new ArrayObject(); } - if(!isObject(%this.unappliedChanges)) - { - %this.unappliedChanges = new ArrayObject(OptionsMenuUnappliedChanges); - } - %this.currentCategory = ""; callOnModules("populateOptionsMenuCategories", "Game"); @@ -74,8 +19,6 @@ function OptionsMenu::onAdd(%this) function OptionsMenu::onWake(%this) { - %this.unappliedChanges.empty(); - %this.populateVideoSettings(); %this.populateAudioSettings(); @@ -120,6 +63,9 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( gamepad, btn_a, OptionsMenuActivateOption ); } +//============================================================================== +// This function updates all the elements in the actual lists to ensure they're +// sized, stylized and formatted correctly, as well as up to date values function OptionsMenuList::syncGui(%this) { %this.callOnChildren("setHighlighted", false); @@ -265,6 +211,10 @@ function OptionsMenu::openOptionsCategory(%this, %categoryName) %this.syncGui(); } +//============================================================================== +// This function updates the non-list items of the menu to be up to date and stylistically +// complaint. This ensures keybind hint buttons are presented correctly based on the current input +// device function OptionsMenu::syncGui(%this) { OptionsMenuCategoryList.callOnChildren("setHighlighted", false); @@ -289,6 +239,9 @@ function OptionsMenu::syncGui(%this) OptionsMenuNextNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuNextCategory")); } +//============================================================================== +// Menu navigation functions +// Primarily used by keybinds function OptionsMenuPrevCategory(%val) { if(%val) @@ -323,7 +276,6 @@ function OptionsMenuNextCategory(%val) } } -// function OptionMenuNavigatePrev(%val) { if(%val) @@ -442,9 +394,14 @@ function OptionsMenuActivateOption(%val) eval(%option-->button.altCommand); } } -// -// -// + +//============================================================================== +// This function utilizes the VideoSettingsGroup SimGroup to populate options. +// The object is defined in core/rendering/scripts/graphicsOptions.tscript +// A majority of the options are statically defined, but some are dynamically populated +// on refresh, like the display device or available resolution options. +// Once populated, we loop over the simgroup structure to populate our option entry +// rows in the options menu itself. function OptionsMenu::populateVideoSettings(%this) { VideoSettingsList.clear(); @@ -489,6 +446,11 @@ function OptionsMenu::populateVideoSettings(%this) } } +//============================================================================== +// This function utilizes the AudioSettingsGroup SimGroup to populate options. +// The object is defined in core/sfx/scripts/audioOptions.tscript +// Similar to the video options, it can be a mix of static and dynamically populated +// option entries, which we then iterate over and populate the entry rows for the menu function OptionsMenu::populateAudioSettings(%this) { AudioSettingsList.clear(); @@ -642,6 +604,7 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList) } } +//============================================================================== function tryCloseOptionsMenu(%val) { if(!%val) @@ -698,150 +661,13 @@ function doKeyRemap( %optionEntry ) Canvas.pushDialog( RemapDlg ); } -function OptionsMenu::apply(%this) -{ - //Now we run through our list of unapplied changes and... apply them. - %hasKeybindChanges = false; - %hasVideoChanges = false; - %hasPostFXChanges = false; - %hasAudioChanges = false; - %hasGraphicsChanges = false; - for(%i=0; %i < %this.unappliedChanges.count(); %i++) - { - %targetVar = %this.unappliedChanges.getKey(%i); - %newValue = strReplace(%this.unappliedChanges.getValue(%i), "\"", ""); - - //First, lets just check through our action map names, see if any match - %wasKeybind = false; - for(%am=0; %am < ActionMapGroup.getCount(); %am++) - { - %actionMap = ActionMapGroup.getObject(%am); - - if(%actionMap == GlobalActionMap.getId()) - continue; - - %actionMapName = %actionMap.getName(); - if(%actionMapName $= %targetVar) - { - %hasKeybindChanges = true; - %wasKeybind = true; - break; - } - } - - if(!%wasKeybind) - { - %sanitizedVar = strReplace(%targetVar, "[", ""); - %sanitizedVar = strReplace(%sanitizedVar, "]", ""); - %sanitizedVar = strReplace(%sanitizedVar, ",", "_"); - %currentValue = getVariable(%sanitizedVar); - if(%currentValue !$= %newValue) - { - setVariable(%targetVar, %newValue); - - //now, lets check for special cases that need additional handling - //for updates - if ( %targetVar $= "$pref::Video::displayDevice" ) - { - schedule(32, 0, "MessageBoxOK", "Change requires restart", "Please restart the game for a display device change to take effect."); - } - else if(startsWith(%targetVar, "$pref::PostFX::")) - { - %hasPostFXChanges = true; - } - else if(startsWith(%targetVar, "$pref::Video::")) - { - %hasVideoChanges = true; - - //if it's the resolution, it's possible we got the human-friendly - //version stored off. if so, reprocess into the usable state - if(%targetVar $= "$pref::Video::Resolution") - { - if(strpos(%newValue, " x ") != -1) - { - %newValue = strreplace(%newValue, " x ", " "); - setVariable(%targetVar, %newValue); - } - } - //This is a bit of hackery to have an intermediate variable because we display in text - //but save by index, so we take the applied name and get the index of the deviceId - else if(%targetVar $= "$pref::Video::displayDeviceId") - { - %deviceId = getDisplayDeviceId($pref::Video::displayDeviceId); - if(%deviceId == -1) - %deviceId = 0; - - $pref::Video::deviceId = %deviceId; - $pref::Video::displayDeviceId = ""; - } - } - else if(startsWith(%targetVar, "$pref::SFX::")) - { - %hasAudioChanges = true; - } - else if(startsWith(%targetVar, "$pref::Graphics::")) - { - %hasGraphicsChanges = true; - } - } - } - } - - //If we had keybind changes, go ahead and save those out - if(%hasKeybindChanges) - { - %prefPath = getPrefpath(); - - %actionMapCount = ActionMapGroup.getCount(); - - %actionMapList = ""; - %append = false; - for(%i=0; %i < %actionMapCount; %i++) - { - %actionMap = ActionMapGroup.getObject(%i); - - if(%actionMap == GlobalActionMap.getId()) - continue; - - %actionMap.save( %prefPath @ "/keybinds." @ $TorqueScriptFileExtension, %append ); - - if(%append != true) - %append = true; - } - } - - if(%hasPostFXChanges) - { - updatePostFXSettings(); - } - - if(%hasVideoChanges) - { - updateDisplaySettings(); - } - - if(%hasAudioChanges) - { - updateAudioSettings(); - } - - if(%hasGraphicsChanges) - { - updateGraphicsSettings(); - } - - //Finally, write our prefs to file - %prefPath = getPrefpath(); - export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); - - OptionsMenu.unappliedChanges.empty(); -} - function OptionsMenu::resetSettings(%this) { MessageBoxOKCancel("", "This will set the graphical settings back to the auto-detected defaults. Do you wish to continue?", "AutodetectGraphics();", ""); } +//============================================================================== +// Option types function addOptionGroup(%displayName) { %group = new GuiTextCtrl() { From 36d00e09d3565f0f91df5cfe111f18ac97ba807c Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 27 Dec 2023 01:36:58 -0600 Subject: [PATCH 09/19] - Fixed Back on-screen menu button for OptionsMenu wasn't working - Fixed MainMenu buttonlist not navigating with keybinds after going to optionsMenu and going back - Fixed menu title text clipping - Fixed keybind preview images on keybind lists in OptionsMenu being modal - Fixed btn_l and btn_r bitmap button binding not working - Fixed a/b and x/y button bitmaps on xbox controllers being flipped --- .../game/data/UI/guis/ChooseLevelMenu.gui | 2 +- .../game/data/UI/guis/joinServerMenu.gui | 2 +- .../game/data/UI/guis/mainMenu.tscript | 2 +- .../game/data/UI/guis/optionsMenu.gui | 4 +-- .../game/data/UI/guis/optionsMenu.tscript | 4 +-- .../game/data/UI/scripts/profiles.tscript | 1 + .../game/data/UI/scripts/utility.tscript | 32 ++++++++++++------- 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index 7fb06379a..6739e8bc9 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -31,7 +31,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { new GuiTextCtrl(ChooseLevelTitleText) { text = "SINGLE PLAYER"; position = "22 23"; - extent = "220 28"; + extent = "1281 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index fe2575ca2..30b6a8d04 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -28,7 +28,7 @@ $guiContent = new GuiControl(JoinServerMenu) { new GuiTextCtrl() { text = "JOIN SERVER"; position = "22 23"; - extent = "220 28"; + extent = "1281 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index b334aeca8..0989607ce 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -64,7 +64,7 @@ function BaseUIStickNavigate(%val) function BaseUIBackOut(%val) { //we can't navigate further back than the MainMenuGui - if(%val && Canvas.getObject(Canvas.getCount()-1) != MainMenuGui) + if(%val && Canvas.getObject(Canvas.getCount()-1).getId() != MainMenuGui.getId()) { Canvas.popDialog(); %topMenu = Canvas.getObject(Canvas.getCount()-1); diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index a6906986f..9ef81c263 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -165,7 +165,7 @@ $guiContent = new GuiControl(OptionsMenu) { new GuiTextCtrl() { text = "OPTIONS"; position = "22 23"; - extent = "220 28"; + extent = "1281 28"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; @@ -188,7 +188,7 @@ $guiContent = new GuiControl(OptionsMenu) { extent = "140 40"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "tryCloseOptionsMenu();"; + command = "tryCloseOptionsMenu(1);"; tooltipProfile = "GuiToolTipProfile"; class = "MenuInputButton"; }; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 93762fb81..ba6f1e9b4 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -623,7 +623,7 @@ function tryCloseOptionsMenu(%val) } else { - Canvas.popDialog(OptionsMenu); + BaseUIBackOut(1); } } @@ -642,7 +642,7 @@ function OptionsMenu::applyChangedOptions(%this) %prefPath = getPrefpath(); export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); - Canvas.popDialog(OptionsMenu); + BaseUIBackOut(1); if($optionsChangeRequiresRestart) MessageBoxOK("Restart Required", "Some of your changes require the game to be restarted."); diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index c6c34cb9c..60c7f4bf7 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -187,6 +187,7 @@ singleton GuiControlProfile( GuiRemapActionMapButtonProfile : GuiMenuButtonProfi { fillColor = "18 18 18 255"; fillColorHL = "0 0 0 255"; + modal = false; }; singleton GuiControlProfile(GuiMenuScrollProfile) diff --git a/Templates/BaseGame/game/data/UI/scripts/utility.tscript b/Templates/BaseGame/game/data/UI/scripts/utility.tscript index a0870f54d..a3d596088 100644 --- a/Templates/BaseGame/game/data/UI/scripts/utility.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/utility.tscript @@ -45,13 +45,13 @@ function getButtonBitmap(%device, %button) %assetId = %assetId @ "Square"; else if(%button $= "Y" || %button $= "btn_y") %assetId = %assetId @ "Triangle"; - else if(%button $= "LB") + else if(%button $= "LB" || %button $= "btn_l") %assetId = %assetId @ "L1"; - else if(%button $= "LT") + else if(%button $= "LT" || %button $= "btn_lt") %assetId = %assetId @ "L2"; - else if(%button $= "RB") + else if(%button $= "RB" || %button $= "btn_r") %assetId = %assetId @ "R1"; - else if(%button $= "RT") + else if(%button $= "RT" || %button $= "btn_rt") %assetId = %assetId @ "R2"; else if(%button $= "thumbrx" || %button $= "thumbry") %assetId = %assetId @ "Right_Stick"; @@ -84,13 +84,13 @@ function getButtonBitmap(%device, %button) %assetId = %assetId @ "Y"; else if(%button $= "Y" || %button $= "btn_y") %assetId = %assetId @ "X"; - else if(%button $= "LB") + else if(%button $= "LB" || %button $= "btn_l") %assetId = %assetId @ "LB"; - else if(%button $= "LT") + else if(%button $= "LT" || %button $= "btn_lt") %assetId = %assetId @ "LT"; - else if(%button $= "RB") + else if(%button $= "RB" || %button $= "btn_r") %assetId = %assetId @ "RB"; - else if(%button $= "RT") + else if(%button $= "RT" || %button $= "btn_rt") %assetId = %assetId @ "RT"; else if(%button $= "thumbrx" || %button $= "thumbry") %assetId = %assetId @ "Right_Stick"; @@ -120,13 +120,21 @@ function getButtonBitmap(%device, %button) %assetId = "UI:Xbox_"; if(%button $= "btn_a") - %assetId = %assetId @ "B"; - else if(%button $= "btn_b") %assetId = %assetId @ "A"; + else if(%button $= "btn_b") + %assetId = %assetId @ "B"; else if(%button $= "btn_x") - %assetId = %assetId @ "Y"; - else if(%button $= "btn_y") %assetId = %assetId @ "X"; + else if(%button $= "btn_y") + %assetId = %assetId @ "Y"; + else if(%button $= "LB" || %button $= "btn_l") + %assetId = %assetId @ "LB"; + else if(%button $= "LT" || %button $= "btn_lt") + %assetId = %assetId @ "LT"; + else if(%button $= "RB" || %button $= "btn_r") + %assetId = %assetId @ "RB"; + else if(%button $= "RT" || %button $= "btn_rt") + %assetId = %assetId @ "RT"; else if(%button $= "thumbrx" || %button $= "thumbry") %assetId = %assetId @ "Right_Stick"; else if(%button $= "thumblx" || %button $= "thumbly") From f5ab97242f5e75f2aca892a3df145fbffa77f362 Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 27 Dec 2023 11:42:43 -0600 Subject: [PATCH 10/19] - Added logic to guiButtonBaseCtrl so if highlighted and is part of a group, will signal the siblings in the group as well - Standardizes highlighting behavior between keybind and mouse highlighting of buttons - Standardized onHighlighted callback for buttonBase - Fixed handling of up/down nav with gamepad stick - Added logic to make holding down nav keybinds iterate over buttons in menu lists --- .../source/gui/buttons/guiButtonBaseCtrl.cpp | 340 ++++++++++-------- Engine/source/gui/buttons/guiButtonBaseCtrl.h | 161 ++++----- .../BaseGame/game/data/UI/guis/mainMenu.gui | 14 + .../game/data/UI/guis/mainMenu.tscript | 33 +- 4 files changed, 301 insertions(+), 247 deletions(-) diff --git a/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp b/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp index 6477fde03..2a545ffe1 100644 --- a/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp +++ b/Engine/source/gui/buttons/guiButtonBaseCtrl.cpp @@ -31,14 +31,14 @@ #include "sfx/sfxTrack.h" -IMPLEMENT_CONOBJECT( GuiButtonBaseCtrl ); +IMPLEMENT_CONOBJECT(GuiButtonBaseCtrl); -ConsoleDocClass( GuiButtonBaseCtrl, +ConsoleDocClass(GuiButtonBaseCtrl, "@brief The base class for the various button controls.\n\n" - + "This is the base class for the various types of button controls. If no more specific functionality is required than " "offered by this class, then it can be instantiated and used directly. Otherwise, its subclasses should be used:\n" - + "- GuiRadioCtrl (radio buttons)\n" "- GuiCheckBoxCtrl (checkboxes)\n" "- GuiButtonCtrl (push buttons with text labels)\n" @@ -47,51 +47,54 @@ ConsoleDocClass( GuiButtonBaseCtrl, "- GuiToggleButtonCtrl (toggle buttons, i.e. push buttons with \"sticky\" behavior)\n" "- GuiSwatchButtonCtrl (color swatch buttons)\n" "- GuiBorderButtonCtrl (push buttons for surrounding child controls)\n\n" - + "@ingroup GuiButtons" ); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseDown, void, (), (), +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseDown, void, (), (), "If #useMouseEvents is true, this is called when the left mouse button is pressed on an (active) " - "button." ); + "button."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseUp, void, (), (), +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseUp, void, (), (), "If #useMouseEvents is true, this is called when the left mouse button is release over an (active) " "button.\n\n" "@note To trigger actions, better use onClick() since onMouseUp() will also be called when the mouse was " - "not originally pressed on the button." ); + "not originally pressed on the button."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onClick, void, (), (), - "Called when the primary action of the button is triggered (e.g. by a left mouse click)." ); +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onClick, void, (), (), + "Called when the primary action of the button is triggered (e.g. by a left mouse click)."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onDoubleClick, void, (), (), - "Called when the left mouse button is double-clicked on the button." ); +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onDoubleClick, void, (), (), + "Called when the left mouse button is double-clicked on the button."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onRightClick, void, (), (), - "Called when the right mouse button is clicked on the button." ); +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onRightClick, void, (), (), + "Called when the right mouse button is clicked on the button."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseEnter, void, (), (), +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseEnter, void, (), (), "If #useMouseEvents is true, this is called when the mouse cursor moves over the button (only if the button " - "is the front-most visible control, though)." ); + "is the front-most visible control, though)."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseLeave, void, (), (), +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseLeave, void, (), (), "If #useMouseEvents is true, this is called when the mouse cursor moves off the button (only if the button " - "had previously received an onMouseEvent() event)." ); + "had previously received an onMouseEvent() event)."); -IMPLEMENT_CALLBACK( GuiButtonBaseCtrl, onMouseDragged, void, (), (), +IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onMouseDragged, void, (), (), "If #useMouseEvents is true, this is called when a left mouse button drag is detected, i.e. when the user " "pressed the left mouse button on the control and then moves the mouse over a certain distance threshold with " - "the mouse button still pressed." ); + "the mouse button still pressed."); IMPLEMENT_CALLBACK(GuiButtonBaseCtrl, onHighlighted, void, (bool highlighted), (highlighted), - "Called when the status of the button being highlighted changes."); + "This is called when the highlighted state of the button is changed."); -ImplementEnumType( GuiButtonType, + +ImplementEnumType(GuiButtonType, "Type of button control.\n\n" - "@ingroup GuiButtons" ) - { GuiButtonBaseCtrl::ButtonTypePush, "PushButton", "A button that triggers an action when clicked." }, - { GuiButtonBaseCtrl::ButtonTypeCheck, "ToggleButton", "A button that is toggled between on and off state." }, - { GuiButtonBaseCtrl::ButtonTypeRadio, "RadioButton", "A button placed in groups for presenting choices." }, + "@ingroup GuiButtons") +{ + GuiButtonBaseCtrl::ButtonTypePush, "PushButton", "A button that triggers an action when clicked." +}, +{ GuiButtonBaseCtrl::ButtonTypeCheck, "ToggleButton", "A button that is toggled between on and off state." }, +{ GuiButtonBaseCtrl::ButtonTypeRadio, "RadioButton", "A button placed in groups for presenting choices." }, EndImplementEnumType; @@ -102,7 +105,7 @@ GuiButtonBaseCtrl::GuiButtonBaseCtrl() mDepressed = false; mHighlighted = false; mActive = true; - static StringTableEntry sButton = StringTable->insert( "Button" ); + static StringTableEntry sButton = StringTable->insert("Button"); mButtonText = sButton; mButtonTextID = StringTable->EmptyString(); mStateOn = false; @@ -117,27 +120,27 @@ GuiButtonBaseCtrl::GuiButtonBaseCtrl() void GuiButtonBaseCtrl::initPersistFields() { docsURL; - addGroup( "Button" ); - - addField( "text", TypeCaseString, Offset(mButtonText, GuiButtonBaseCtrl), - "Text label to display on button (if button class supports text labels)." ); - addField( "textID", TypeString, Offset(mButtonTextID, GuiButtonBaseCtrl), - "ID of string in string table to use for text label on button.\n\n" - "@see setTextID\n" - "@see GuiControl::langTableMod\n" - "@see LangTable\n\n" ); - addField( "groupNum", TypeS32, Offset(mRadioGroup, GuiButtonBaseCtrl), - "Radio button toggle group number. All radio buttons that are assigned the same #groupNum and that " - "are parented to the same control will synchronize their toggle state, i.e. if one radio button is toggled on " - "all other radio buttons in its group will be toggled off.\n\n" - "The default group is -1." ); - addField( "buttonType", TYPEID< ButtonType >(), Offset(mButtonType, GuiButtonBaseCtrl), - "Button behavior type.\n" ); - addField( "useMouseEvents", TypeBool, Offset(mUseMouseEvents, GuiButtonBaseCtrl), - "If true, mouse events will be passed on to script. Default is false.\n" ); - - endGroup( "Button" ); - + addGroup("Button"); + + addField("text", TypeCaseString, Offset(mButtonText, GuiButtonBaseCtrl), + "Text label to display on button (if button class supports text labels)."); + addField("textID", TypeString, Offset(mButtonTextID, GuiButtonBaseCtrl), + "ID of string in string table to use for text label on button.\n\n" + "@see setTextID\n" + "@see GuiControl::langTableMod\n" + "@see LangTable\n\n"); + addField("groupNum", TypeS32, Offset(mRadioGroup, GuiButtonBaseCtrl), + "Radio button toggle group number. All radio buttons that are assigned the same #groupNum and that " + "are parented to the same control will synchronize their toggle state, i.e. if one radio button is toggled on " + "all other radio buttons in its group will be toggled off.\n\n" + "The default group is -1."); + addField("buttonType", TYPEID< ButtonType >(), Offset(mButtonType, GuiButtonBaseCtrl), + "Button behavior type.\n"); + addField("useMouseEvents", TypeBool, Offset(mUseMouseEvents, GuiButtonBaseCtrl), + "If true, mouse events will be passed on to script. Default is false.\n"); + + endGroup("Button"); + Parent::initPersistFields(); } @@ -145,70 +148,70 @@ void GuiButtonBaseCtrl::initPersistFields() bool GuiButtonBaseCtrl::onWake() { - if(!Parent::onWake()) + if (!Parent::onWake()) return false; // is we have a script variable, make sure we're in sync - if ( mConsoleVariable[0] ) - mStateOn = Con::getBoolVariable( mConsoleVariable ); - if(mButtonTextID && *mButtonTextID != 0) - setTextID(mButtonTextID); + if (mConsoleVariable[0]) + mStateOn = Con::getBoolVariable(mConsoleVariable); + if (mButtonTextID && *mButtonTextID != 0) + setTextID(mButtonTextID); return true; } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::setText( const char* text ) +void GuiButtonBaseCtrl::setText(const char* text) { mButtonText = StringTable->insert(text, true); } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::setTextID(const char *id) +void GuiButtonBaseCtrl::setTextID(const char* id) { - S32 n = Con::getIntVariable(id, -1); - if(n != -1) - { - mButtonTextID = StringTable->insert(id); - setTextID(n); - } + S32 n = Con::getIntVariable(id, -1); + if (n != -1) + { + mButtonTextID = StringTable->insert(id); + setTextID(n); + } } //----------------------------------------------------------------------------- void GuiButtonBaseCtrl::setTextID(S32 id) { - const UTF8 *str = getGUIString(id); - if(str) - setText((const char*)str); - //mButtonTextID = id; + const UTF8* str = getGUIString(id); + if (str) + setText((const char*)str); + //mButtonTextID = id; } //----------------------------------------------------------------------------- -const char *GuiButtonBaseCtrl::getText() +const char* GuiButtonBaseCtrl::getText() { return mButtonText; } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::setStateOn( bool bStateOn ) +void GuiButtonBaseCtrl::setStateOn(bool bStateOn) { - if(!mActive) + if (!mActive) return; - if(mButtonType == ButtonTypeCheck) + if (mButtonType == ButtonTypeCheck) { mStateOn = bStateOn; } - else if(mButtonType == ButtonTypeRadio) + else if (mButtonType == ButtonTypeRadio) { messageSiblings(mRadioGroup); mStateOn = bStateOn; - } + } setUpdate(); } @@ -216,7 +219,7 @@ void GuiButtonBaseCtrl::setStateOn( bool bStateOn ) void GuiButtonBaseCtrl::acceleratorKeyPress(U32) { - if( !mActive ) + if (!mActive) return; //set the bool @@ -230,7 +233,7 @@ void GuiButtonBaseCtrl::acceleratorKeyPress(U32) void GuiButtonBaseCtrl::acceleratorKeyRelease(U32) { - if (! mActive) + if (!mActive) return; if (mDepressed) @@ -247,9 +250,9 @@ void GuiButtonBaseCtrl::acceleratorKeyRelease(U32) //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event) +void GuiButtonBaseCtrl::onMouseDown(const GuiEvent& event) { - if (! mActive) + if (!mActive) return; if (mProfile->mCanKeyFocus) @@ -257,19 +260,19 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event) if (mProfile->isSoundButtonDownValid()) SFX->playOnce(mProfile->getSoundButtonDownProfile()); - + mMouseDownPoint = event.mousePoint; mMouseDragged = false; - if( mUseMouseEvents ) - onMouseDown_callback(); + if (mUseMouseEvents) + onMouseDown_callback(); //lock the mouse mouseLock(); mDepressed = true; // If we have a double click then execute the alt command. - if ( event.mouseClickCount == 2 ) + if (event.mouseClickCount == 2) { onDoubleClick_callback(); execAltConsoleCallback(); @@ -281,18 +284,18 @@ void GuiButtonBaseCtrl::onMouseDown(const GuiEvent &event) //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event) +void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent& event) { setUpdate(); - if( mUseMouseEvents ) + if (mUseMouseEvents) onMouseEnter_callback(); - if(isMouseLocked()) + if (isMouseLocked()) { mDepressed = true; mHighlighted = true; - onHighlighted_callback(true); + onHighlighted_callback(mHighlighted); } else { @@ -300,40 +303,42 @@ void GuiButtonBaseCtrl::onMouseEnter(const GuiEvent &event) SFX->playOnce(mProfile->getSoundButtonOverProfile()); mHighlighted = true; - onHighlighted_callback(true); + messageSiblings(mRadioGroup); + onHighlighted_callback(mHighlighted); } } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMouseLeave(const GuiEvent &) +void GuiButtonBaseCtrl::onMouseLeave(const GuiEvent&) { setUpdate(); - if( mUseMouseEvents ) + if (mUseMouseEvents) onMouseLeave_callback(); - if( isMouseLocked() ) + if (isMouseLocked()) mDepressed = false; mHighlighted = false; - onHighlighted_callback(false); + onHighlighted_callback(mHighlighted); + messageSiblings(mRadioGroup); } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMouseUp(const GuiEvent &event) +void GuiButtonBaseCtrl::onMouseUp(const GuiEvent& event) { mouseUnlock(); - if( !mActive ) + if (!mActive) return; - + setUpdate(); - if( mUseMouseEvents ) + if (mUseMouseEvents) onMouseUp_callback(); //if we released the mouse within this control, perform the action - if( mDepressed ) + if (mDepressed) onAction(); mDepressed = false; @@ -342,38 +347,38 @@ void GuiButtonBaseCtrl::onMouseUp(const GuiEvent &event) //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onRightMouseUp(const GuiEvent &event) +void GuiButtonBaseCtrl::onRightMouseUp(const GuiEvent& event) { onRightClick_callback(); - Parent::onRightMouseUp( event ); + Parent::onRightMouseUp(event); } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMouseDragged( const GuiEvent& event ) +void GuiButtonBaseCtrl::onMouseDragged(const GuiEvent& event) { - if( mUseMouseEvents ) + if (mUseMouseEvents) { // If we haven't started a drag yet, find whether we have moved past // the tolerance value. - - if( !mMouseDragged ) + + if (!mMouseDragged) { Point2I delta = mMouseDownPoint - event.mousePoint; - if( mAbs( delta.x ) > 2 || mAbs( delta.y ) > 2 ) + if (mAbs(delta.x) > 2 || mAbs(delta.y) > 2) mMouseDragged = true; } - - if( mMouseDragged ) + + if (mMouseDragged) onMouseDragged_callback(); } - - Parent::onMouseDragged( event ); + + Parent::onMouseDragged(event); } //----------------------------------------------------------------------------- -bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event) +bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent& event) { //if the control is a dead end, kill the event if (!mActive) @@ -381,7 +386,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event) //see if the key down is a return or space or not if ((event.keyCode == KEY_RETURN || event.keyCode == KEY_SPACE) - && event.modifier == 0) + && event.modifier == 0) { if (mProfile->isSoundButtonDownValid()) SFX->playOnce(mProfile->getSoundButtonDownProfile()); @@ -394,7 +399,7 @@ bool GuiButtonBaseCtrl::onKeyDown(const GuiEvent &event) //----------------------------------------------------------------------------- -bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent &event) +bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent& event) { //if the control is a dead end, kill the event if (!mActive) @@ -415,64 +420,83 @@ bool GuiButtonBaseCtrl::onKeyUp(const GuiEvent &event) //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::setScriptValue(const char *value) +void GuiButtonBaseCtrl::setScriptValue(const char* value) { - mStateOn = dAtob(value); + mStateOn = dAtob(value); - // Update the console variable: - if ( mConsoleVariable[0] ) - Con::setBoolVariable( mConsoleVariable, mStateOn ); + // Update the console variable: + if (mConsoleVariable[0]) + Con::setBoolVariable(mConsoleVariable, mStateOn); setUpdate(); } //----------------------------------------------------------------------------- -const char *GuiButtonBaseCtrl::getScriptValue() +const char* GuiButtonBaseCtrl::getScriptValue() { - return mStateOn ? "1" : "0"; + return mStateOn ? "1" : "0"; } //----------------------------------------------------------------------------- void GuiButtonBaseCtrl::onAction() { - if(!mActive) - return; + if (!mActive) + return; - if(mButtonType == ButtonTypeCheck) - { - mStateOn = mStateOn ? false : true; + if (mButtonType == ButtonTypeCheck) + { + mStateOn = mStateOn ? false : true; } - else if(mButtonType == ButtonTypeRadio) - { - mStateOn = true; - messageSiblings(mRadioGroup); - } - setUpdate(); + else if (mButtonType == ButtonTypeRadio) + { + mStateOn = true; + messageSiblings(mRadioGroup); + } + setUpdate(); // Update the console variable: - if ( mConsoleVariable[0] ) - Con::setBoolVariable( mConsoleVariable, mStateOn ); + if (mConsoleVariable[0]) + Con::setBoolVariable(mConsoleVariable, mStateOn); - onClick_callback(); - Parent::onAction(); + onClick_callback(); + Parent::onAction(); } //----------------------------------------------------------------------------- -void GuiButtonBaseCtrl::onMessage( GuiControl *sender, S32 msg ) +void GuiButtonBaseCtrl::onMessage(GuiControl* sender, S32 msg) { - Parent::onMessage(sender, msg); - if( mRadioGroup == msg && mButtonType == ButtonTypeRadio ) - { - setUpdate(); - mStateOn = ( sender == this ); + Parent::onMessage(sender, msg); + if (mRadioGroup == msg) + { + if (mButtonType == ButtonTypeRadio) + { + setUpdate(); + mStateOn = (sender == this); - // Update the console variable: - if ( mConsoleVariable[0] ) - Con::setBoolVariable( mConsoleVariable, mStateOn ); - } + // Update the console variable: + if (mConsoleVariable[0]) + Con::setBoolVariable(mConsoleVariable, mStateOn); + } + else if (mButtonType == ButtonTypePush) + { + mHighlighted = (sender == this); + onHighlighted_callback(mHighlighted); + } + } +} + +void GuiButtonBaseCtrl::setHighlighted(bool highlighted) +{ + mHighlighted = highlighted; + onHighlighted_callback(mHighlighted); + + if (mRadioGroup != -1) + { + messageSiblings(mRadioGroup); + } } //============================================================================= @@ -482,69 +506,69 @@ void GuiButtonBaseCtrl::onMessage( GuiControl *sender, S32 msg ) //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, performClick, void, (),, +DefineEngineMethod(GuiButtonBaseCtrl, performClick, void, (), , "Simulate a click on the button.\n" "This method will trigger the button's action just as if the button had been pressed by the " - "user.\n\n" ) + "user.\n\n") { object->onAction(); } //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, setText, void, ( const char* text ),, +DefineEngineMethod(GuiButtonBaseCtrl, setText, void, (const char* text), , "Set the text displayed on the button's label.\n" "@param text The text to display as the button's text label.\n" "@note Not all buttons render text labels.\n\n" "@see getText\n" - "@see setTextID\n" ) + "@see setTextID\n") { - object->setText( text ); + object->setText(text); } //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, setTextID, void, ( const char* id ),, +DefineEngineMethod(GuiButtonBaseCtrl, setTextID, void, (const char* id), , "Set the text displayed on the button's label using a string from the string table " "assigned to the control.\n\n" "@param id Name of the variable that contains the integer string ID. Used to look up " - "string in table.\n\n" + "string in table.\n\n" "@note Not all buttons render text labels.\n\n" "@see setText\n" "@see getText\n" "@see GuiControl::langTableMod\n" "@see LangTable\n\n" - "@ref Gui_i18n" ) + "@ref Gui_i18n") { - object->setTextID( id ); + object->setTextID(id); } //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, getText, const char*, (),, +DefineEngineMethod(GuiButtonBaseCtrl, getText, const char*, (), , "Get the text display on the button's label (if any).\n\n" - "@return The button's label." ) + "@return The button's label.") { - return object->getText( ); + return object->getText(); } //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, setStateOn, void, ( bool isOn ), ( true ), +DefineEngineMethod(GuiButtonBaseCtrl, setStateOn, void, (bool isOn), (true), "For toggle or radio buttons, set whether the button is currently activated or not. For radio buttons, " "toggling a button on will toggle all other radio buttons in its group to off.\n\n" "@param isOn If true, the button will be toggled on (if not already); if false, it will be toggled off.\n\n" "@note Toggling the state of a button with this method will not not trigger the action associated with the " - "button. To do that, use performClick()." ) + "button. To do that, use performClick().") { - object->setStateOn( isOn ); + object->setStateOn(isOn); } //----------------------------------------------------------------------------- -DefineEngineMethod( GuiButtonBaseCtrl, resetState, void, (),, +DefineEngineMethod(GuiButtonBaseCtrl, resetState, void, (), , "Reset the mousing state of the button.\n\n" - "This method should not generally be called." ) + "This method should not generally be called.") { object->resetState(); } @@ -556,7 +580,7 @@ DefineEngineMethod(GuiButtonBaseCtrl, setHighlighted, void, (bool highlighted), object->setHighlighted(highlighted); } -DefineEngineMethod(GuiButtonBaseCtrl, isHighlighted, bool, (),, +DefineEngineMethod(GuiButtonBaseCtrl, isHighlighted, bool, (), , "Reset the mousing state of the button.\n\n" "This method should not generally be called.") { diff --git a/Engine/source/gui/buttons/guiButtonBaseCtrl.h b/Engine/source/gui/buttons/guiButtonBaseCtrl.h index e20ebb00f..f6f5dddc7 100644 --- a/Engine/source/gui/buttons/guiButtonBaseCtrl.h +++ b/Engine/source/gui/buttons/guiButtonBaseCtrl.h @@ -24,7 +24,7 @@ #define _GUIBUTTONBASECTRL_H_ #ifndef _GUICONTROL_H_ - #include "gui/core/guiControl.h" +#include "gui/core/guiControl.h" #endif @@ -33,108 +33,99 @@ /// class GuiButtonBaseCtrl : public GuiControl { - public: - - typedef GuiControl Parent; +public: - enum ButtonType - { - ButtonTypePush, - ButtonTypeCheck, - ButtonTypeRadio, - }; + typedef GuiControl Parent; - protected: - - StringTableEntry mButtonText; - StringTableEntry mButtonTextID; - bool mDepressed; - bool mHighlighted; - bool mStateOn; - S32 mButtonType; - S32 mRadioGroup; - bool mUseMouseEvents; - - /// Point where left mouse button was pressed down. Used to find when to start - /// a mouse drag. - Point2I mMouseDownPoint; - - /// - bool mMouseDragged; - - /// @name Callbacks - /// @{ + enum ButtonType + { + ButtonTypePush, + ButtonTypeCheck, + ButtonTypeRadio, + }; - DECLARE_CALLBACK( void, onMouseDown, () ); - DECLARE_CALLBACK( void, onMouseUp, () ); - DECLARE_CALLBACK( void, onClick, () ); - DECLARE_CALLBACK( void, onRightClick, () ); - DECLARE_CALLBACK( void, onDoubleClick, () ); - DECLARE_CALLBACK( void, onMouseEnter, () ); - DECLARE_CALLBACK( void, onMouseLeave, () ); - DECLARE_CALLBACK( void, onMouseDragged, () ); - DECLARE_CALLBACK( void, onHighlighted, (bool)); +protected: - /// @} + StringTableEntry mButtonText; + StringTableEntry mButtonTextID; + bool mDepressed; + bool mHighlighted; + bool mStateOn; + S32 mButtonType; + S32 mRadioGroup; + bool mUseMouseEvents; - public: + /// Point where left mouse button was pressed down. Used to find when to start + /// a mouse drag. + Point2I mMouseDownPoint; - GuiButtonBaseCtrl(); - bool onWake(); + /// + bool mMouseDragged; - DECLARE_CONOBJECT( GuiButtonBaseCtrl ); - DECLARE_CATEGORY( "Gui Buttons" ); - DECLARE_DESCRIPTION( "A basic button control." ); - - static void initPersistFields(); + /// @name Callbacks + /// @{ - void setText(const char *text); - void setTextID(S32 id); - void setTextID(const char *id); - const char *getText(); - void setStateOn( bool bStateOn ); - bool getStateOn() const { return mStateOn; } + DECLARE_CALLBACK(void, onMouseDown, ()); + DECLARE_CALLBACK(void, onMouseUp, ()); + DECLARE_CALLBACK(void, onClick, ()); + DECLARE_CALLBACK(void, onRightClick, ()); + DECLARE_CALLBACK(void, onDoubleClick, ()); + DECLARE_CALLBACK(void, onMouseEnter, ()); + DECLARE_CALLBACK(void, onMouseLeave, ()); + DECLARE_CALLBACK(void, onMouseDragged, ()); + DECLARE_CALLBACK(void, onHighlighted, (bool)); - void setDepressed( bool depressed ) { mDepressed = depressed; } - void resetState() - { - mDepressed = false; - mHighlighted = false; - onHighlighted_callback(false); - } + /// @} - void setHighlighted(bool highlighted) - { - mHighlighted = highlighted; - onHighlighted_callback(highlighted); - } - bool isHighlighted() { return mHighlighted; } +public: - void acceleratorKeyPress(U32 index); - void acceleratorKeyRelease(U32 index); + GuiButtonBaseCtrl(); + bool onWake(); - void onMouseDown(const GuiEvent &); - void onMouseUp(const GuiEvent &); - void onMouseDragged( const GuiEvent& event ); - void onRightMouseUp(const GuiEvent &); + DECLARE_CONOBJECT(GuiButtonBaseCtrl); + DECLARE_CATEGORY("Gui Buttons"); + DECLARE_DESCRIPTION("A basic button control."); - void onMouseEnter(const GuiEvent &); - void onMouseLeave(const GuiEvent &); + static void initPersistFields(); - bool onKeyDown(const GuiEvent &event); - bool onKeyUp(const GuiEvent &event); + void setText(const char* text); + void setTextID(S32 id); + void setTextID(const char* id); + const char* getText(); + void setStateOn(bool bStateOn); + bool getStateOn() const { return mStateOn; } - void setScriptValue(const char *value); - const char *getScriptValue(); + void setDepressed(bool depressed) { mDepressed = depressed; } + void resetState() { mDepressed = false; mHighlighted = false; } - void onMessage(GuiControl *,S32 msg); - void onAction(); - - bool usesMouseEvents() const { return mUseMouseEvents; } - void setUseMouseEvents( bool val ) { mUseMouseEvents = val; } + void setHighlighted(bool highlighted); + bool isHighlighted() { return mHighlighted; } + + void acceleratorKeyPress(U32 index); + void acceleratorKeyRelease(U32 index); + + void onMouseDown(const GuiEvent&); + void onMouseUp(const GuiEvent&); + void onMouseDragged(const GuiEvent& event); + void onRightMouseUp(const GuiEvent&); + + void onMouseEnter(const GuiEvent&); + void onMouseLeave(const GuiEvent&); + + bool onKeyDown(const GuiEvent& event); + bool onKeyUp(const GuiEvent& event); + + void setScriptValue(const char* value); + const char* getScriptValue(); + + void onMessage(GuiControl*, S32 msg); + void onAction(); + + bool usesMouseEvents() const { return mUseMouseEvents; } + void setUseMouseEvents(bool val) { mUseMouseEvents = val; } }; typedef GuiButtonBaseCtrl::ButtonType GuiButtonType; -DefineEnumType( GuiButtonType ); +DefineEnumType(GuiButtonType); #endif diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui index 3fc39662b..ce1ab06a5 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.gui @@ -83,6 +83,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "$pref::HostMultiPlayer=false;\nCanvas.pushDialog(ChooseLevelMenu);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuCreateSrvrBtn) { text = "Create Server"; @@ -91,6 +93,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "$pref::HostMultiPlayer=true;Canvas.pushDialog(ChooseLevelMenu);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuJoinSrvrBtn) { text = "Join Server"; @@ -99,6 +103,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "Canvas.pushDialog(JoinServerMenu);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuOptionBtn) { text = "Options"; @@ -107,6 +113,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "Canvas.pushDialog(OptionsMenu);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuWorldEditBtn) { text = "Open World Editor (F11)"; @@ -115,6 +123,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "fastLoadWorldEdit(1);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuGuiEditBtn) { text = "Open GUI Editor (F10)"; @@ -123,6 +133,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "fastLoadGUIEdit(1);"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; new GuiButtonCtrl(MainMenuExitBtn) { text = "Exit"; @@ -131,6 +143,8 @@ $guiContent = new GuiControl(MainMenuGui) { profile = "GuiMenuButtonProfile"; command = "quit();"; tooltipProfile = "GuiToolTipProfile"; + class="MainMenuButton"; + groupNum = 1; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index 0989607ce..fda741b68 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -1,3 +1,6 @@ +$BaseUI::scrollSpeedTimeMs = 250; +$BaseUI::scrollSchedule = 0; + function MainMenuGui::onAdd(%this) { } @@ -38,6 +41,12 @@ function BaseUINavigatePrev(%val) $MenuList.listPosition = 0; $MenuList.syncGUI(); + + $BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "BaseUINavigatePrev", 1); + } + else + { + cancel($BaseUI::scrollSchedule); } } @@ -50,15 +59,25 @@ function BaseUINavigateNext(%val) $MenuList.listPosition = $MenuList.getCount()-1; $MenuList.syncGUI(); + + $BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "BaseUINavigateNext", 1); + } + else + { + cancel($BaseUI::scrollSchedule); } } function BaseUIStickNavigate(%val) { - if(%val == -1) + if(%val == 1) BaseUINavigateNext(1); - else if(%val == 1) - mainMenuNavigateDown(1); + else if(%val == -1) + BaseUINavigatePrev(1); + else + { + cancel($BaseUI::scrollSchedule); + } } function BaseUIBackOut(%val) @@ -79,7 +98,7 @@ function BaseUIBackOut(%val) function MainMenuButtonList::syncGUI(%this) { - %this.callOnChildren("setHighlighted", false); + //%this.callOnChildren("setHighlighted", false); %btn = %this.getObject(%this.listPosition); %btn.setHighlighted(true); @@ -93,6 +112,12 @@ function MainMenuButtonList::syncGUI(%this) MainMenuGoButton.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected")); } +function MainMenuButton::onHighlighted(%this, %highlighted) +{ + if(%highlighted) + $MenuList.listPosition = MainMenuButtonList.getObjectIndex(%this); +} + function BaseUIActivateSelected() { %btn = $MenuList.getObject($MenuList.listPosition); From 67ac556ecd4dc339fbf1fbc15f0148f0112d1f93 Mon Sep 17 00:00:00 2001 From: Areloch Date: Sun, 31 Dec 2023 12:46:48 -0600 Subject: [PATCH 11/19] - Added ability to explicitly execute a guiControl's console and altConsole command - Fixed formatting of resolution strings for the internal values, allowing them to be properly parsed and applied by the options menu/canvas - Fixed display of Display Device on option's menu - Fixed Issue of it not displaying any keybinds in keyboard/gamepad options if there's only a single actionmap - Added 'hold to scroll' action to optionsMenu - Added apply button to options menu - Added remap button to options menu when on keyboard/gamepad keybinds categories - Fixed up the remap logic so remapping a key only unbinds the matched device being bound, so binds for different devices are untouched - Made keybinds options properly refresh when keybinds are changed - Shifted keyboard "go" keybind for menu nav from Enter to Space for easier use - Removed stick keybinds from gamepad --- Engine/source/gui/core/guiControl.cpp | 16 +++ .../game/core/gui/scripts/canvas.tscript | 2 +- .../rendering/scripts/graphicsOptions.tscript | 38 +++++- .../scripts/client/defaultKeybinds.tscript | 8 +- .../game/data/UI/guis/ChooseLevelMenu.tscript | 2 +- .../game/data/UI/guis/GameMenu.tscript | 2 +- .../game/data/UI/guis/joinServerMenu.tscript | 2 +- .../game/data/UI/guis/mainMenu.tscript | 6 +- .../game/data/UI/guis/messageBoxDlg.tscript | 2 +- .../game/data/UI/guis/optionsMenu.gui | 32 ++++- .../game/data/UI/guis/optionsMenu.tscript | 109 ++++++++++++------ .../BaseGame/game/data/UI/guis/remapDlg.gui | 1 + .../game/data/UI/guis/remapDlg.tscript | 81 +++++++++---- .../game/data/UI/scripts/controlsMenu.tscript | 17 --- 14 files changed, 223 insertions(+), 95 deletions(-) diff --git a/Engine/source/gui/core/guiControl.cpp b/Engine/source/gui/core/guiControl.cpp index a5e21a984..6a888485d 100644 --- a/Engine/source/gui/core/guiControl.cpp +++ b/Engine/source/gui/core/guiControl.cpp @@ -2947,3 +2947,19 @@ DefineEngineMethod( GuiControl, getAspect, F32, (),, const Point2I &ext = object->getExtent(); return (F32)ext.x / (F32)ext.y; } + +//----------------------------------------------------------------------------- + +DefineEngineMethod(GuiControl, execCommand, const char*, (), , + "Forcefully executes the command field value(if any) on this guiControl.\n" + "@return The results of the evaluation of the command.") +{ + return object->execConsoleCallback(); +} + +DefineEngineMethod(GuiControl, execAltCommand, const char*, (), , + "Forcefully executes the altCommand field value(if any) on this guiControl.\n" + "@return The results of the evaluation of the altCommand.") +{ + return object->execAltConsoleCallback(); +} diff --git a/Templates/BaseGame/game/core/gui/scripts/canvas.tscript b/Templates/BaseGame/game/core/gui/scripts/canvas.tscript index 79988556d..8d6a0d98b 100644 --- a/Templates/BaseGame/game/core/gui/scripts/canvas.tscript +++ b/Templates/BaseGame/game/core/gui/scripts/canvas.tscript @@ -94,7 +94,7 @@ function configureCanvas() if ($pref::Video::deviceMode != $Video::ModeFullscreen) $pref::Video::FullScreen = false; %modeStr = Canvas.prefsToModeStr(); - + echo("--------------"); echo("Attempting to set resolution to \"" @ %modeStr @ "\""); diff --git a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript index 42d6bef5f..450be2512 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/graphicsOptions.tscript @@ -9,9 +9,10 @@ function OptionsQualityLevel::isCurrent( %this ) %value = %this.getValue( %i ); if ( getVariable( %pref ) !$= %value ) + { return false; + } } - return true; } @@ -971,7 +972,7 @@ function VideoSettingsGroup::populateDisplaySettings(%this) { class = "OptionsQualityLevel"; displayName = %device; - key["$pref::Video::displayDeviceId"] = %device; + key["$pref::Video::deviceId"] = %i; }; DisplayDevicesGroup.add(%entry); @@ -985,8 +986,9 @@ function VideoSettingsGroup::populateDisplaySettings(%this) for(%i=0; %i < getFieldCount(%resolutionList); %i++) { %rawResolution = getField(%resolutionList, %i); - %prettyResolution = _makePrettyResString(%rawResolution); + %prettyResolution = _makePrettyResString(%rawResolution); + %entry = new ArrayObject() { class = "OptionsQualityLevel"; @@ -997,6 +999,26 @@ function VideoSettingsGroup::populateDisplaySettings(%this) DisplayResSettingsGroup.add(%entry); } } + else + { + if($platform !$= "windows") + %monitorRect = Canvas.getMonitorUsableRect($pref::Video::deviceId); + else + %monitorRect = Canvas.getMonitorRect($pref::Video::deviceId); + + %rawResolution = getWords(%monitorRect, 2); + + %prettyResolution = _makePrettyResString(%rawResolution); + + %entry = new ArrayObject() + { + class = "OptionsQualityLevel"; + displayName = %prettyResolution; + key["$pref::Video::Resolution"] = %rawResolution; + }; + + DisplayResSettingsGroup.add(%entry); + } %refreshList = getScreenRefreshList($pref::Video::mode); for(%i=0; %i < getFieldCount(%refreshList); %i++) @@ -1100,6 +1122,7 @@ function updateDisplayOptionsSettings() $pref::Video::FullScreen = %newFullScreen; $pref::Video::RefreshRate = %newRefresh; $pref::Video::AA = %newAA; + configureCanvas(); } } @@ -1135,6 +1158,11 @@ function PostFXLightRayOptionsGroup::onApply(%this) function getCurrentQualityLevel(%qualityGroup) { + /*if(%qualityGroup.getId() == DisplayResSettingsGroup.getId()) + { + echo("Checking current quality level of Display Resolution"); + }*/ + for ( %i=0; %i < %qualityGroup.getCount(); %i++ ) { %level = %qualityGroup.getObject( %i ); @@ -1349,7 +1377,7 @@ function getScreenResolutionList(%deviceID, %deviceMode) if ((%deviceMode == $Video::ModeBorderless) && ($platform !$= "windows")) { %borderlessRes = getWords(Canvas.getMonitorUsableRect(%deviceID), 2); - return _makePrettyResString(%borderlessRes); + return %borderlessRes; } %resCount = Canvas.getModeCount(); @@ -1361,7 +1389,7 @@ function getScreenResolutionList(%deviceID, %deviceMode) if (!Canvas.checkCanvasRes(%testResString, %deviceID, %deviceMode, false)) continue; - %testRes = _makePrettyResString( %testResString ); + %testRes = getWords(%testResString, 0, 1); //sanitize %found = false; diff --git a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript index 913b088fc..9a9a3ddd5 100644 --- a/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript +++ b/Templates/BaseGame/game/data/ExampleModule/scripts/client/defaultKeybinds.tscript @@ -17,10 +17,10 @@ addKeyRemap("Ascend", "ExampleMoveMap", "keyboard", "moveup", "Makes the camera addKeyRemap("Descend", "ExampleMoveMap", "keyboard", "movedown", "Makes the camera descend"); addKeyRemap("Jump", "ExampleMoveMap", "keyboard", "jump", "Jump"); -addKeyRemap("Forward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Forward Movement"); -addKeyRemap("Backward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Backward Movement"); -addKeyRemap("Strafe Left", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Left Strafing Movement"); -addKeyRemap("Strafe Right", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Right Strafing Movement"); +//addKeyRemap("Forward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Forward Movement"); +//addKeyRemap("Backward", "ExampleMoveMap", "gamepad", "gamePadMoveY", "Backward Movement"); +//addKeyRemap("Strafe Left", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Left Strafing Movement"); +//addKeyRemap("Strafe Right", "ExampleMoveMap", "gamepad", "gamePadMoveX", "Right Strafing Movement"); addKeyRemap("Jump", "ExampleMoveMap", "gamepad", "jump", "Jump"); //------------------------------------------------------------------------------ diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index 646a55101..df9f1f372 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -147,7 +147,7 @@ if(!isObject( ChooseLevelActionMap ) ) ChooseLevelActionMap.bind( gamepad, lpov, BaseUINavigatePrev ); ChooseLevelActionMap.bind( gamepad, rpov, BaseUINavigateNext ); - ChooseLevelActionMap.bind( keyboard, Enter, ChooseLevelBegin ); + ChooseLevelActionMap.bind( keyboard, Space, ChooseLevelBegin ); ChooseLevelActionMap.bind( gamepad, btn_a, ChooseLevelBegin ); } diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript index 0b6177604..23a86e491 100644 --- a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript @@ -73,7 +73,7 @@ if(!isObject( GameMenuActionMap ) ) GameMenuActionMap.bind( gamepad, upov, BaseUINavigatePrev ); GameMenuActionMap.bind( gamepad, dpov, BaseUINavigateNext ); - GameMenuActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); + GameMenuActionMap.bind( keyboard, Space, BaseUIActivateSelected ); GameMenuActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); GameMenuActionMap.bindCmd( keyboard, Escape, "Canvas.popDialog(GameMenu);", "" ); diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index f612a3117..15b8580f1 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -17,7 +17,7 @@ if(!isObject( JoinServerActionMap ) ) JoinServerActionMap.bindCmd( keyboard, e, "JoinServerMenu.queryLan();" ); JoinServerActionMap.bindCmd( gamepad, btn_y, "JoinServerMenu.queryLan();" ); - JoinServerActionMap.bindCmd( keyboard, Enter, "JoinServerMenu::join();" ); + JoinServerActionMap.bindCmd( keyboard, Space, "JoinServerMenu::join();" ); JoinServerActionMap.bindCmd( gamepad, btn_a, "JoinServerMenu::join();" ); } diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index fda741b68..770857ec8 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -9,6 +9,8 @@ function MainMenuGui::onWake(%this) { $MenuList = MainMenuButtonList; $MenuList.listPosition = 0; + + $MenuList.syncGui(); } function MainMenuGui::onSleep(%this) @@ -25,7 +27,7 @@ if(!isObject( BaseUIActionMap ) ) BaseUIActionMap.bind( gamepad, upov, BaseUINavigatePrev ); BaseUIActionMap.bind( gamepad, dpov, BaseUINavigateNext ); - BaseUIActionMap.bind( keyboard, Enter, BaseUIActivateSelected ); + BaseUIActionMap.bind( keyboard, Space, BaseUIActivateSelected ); BaseUIActionMap.bind( gamepad, btn_a, BaseUIActivateSelected ); BaseUIActionMap.bind( keyboard, Escape, BaseUIBackOut ); @@ -75,9 +77,7 @@ function BaseUIStickNavigate(%val) else if(%val == -1) BaseUINavigatePrev(1); else - { cancel($BaseUI::scrollSchedule); - } } function BaseUIBackOut(%val) diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript index 7ef43ba05..71dc9bbea 100644 --- a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript @@ -125,7 +125,7 @@ if(!isObject( MessageBoxActionMap ) ) { new ActionMap(MessageBoxActionMap){}; - MessageBoxActionMap.bind( keyboard, Enter, messageBoxYesClicked ); + MessageBoxActionMap.bind( keyboard, Space, messageBoxYesClicked ); MessageBoxActionMap.bind( gamepad, btn_a, messageBoxYesClicked ); MessageBoxActionMap.bind( keyboard, Escape, messageBoxNoClicked ); diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui index 9ef81c263..08e312d52 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.gui @@ -192,11 +192,41 @@ $guiContent = new GuiControl(OptionsMenu) { tooltipProfile = "GuiToolTipProfile"; class = "MenuInputButton"; }; - new GuiIconButtonCtrl(OptionsMenuResetBtn) { + new GuiIconButtonCtrl(OptionsMenuRemapBtn) { + BitmapAsset = "UI:Keyboard_Black_Space_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; + text = "Remap"; + position = "850 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "OptionsMenuActivateOption(1)"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl(OptionsMenuApplyBtn) { BitmapAsset = "UI:Keyboard_Black_Return_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Center"; + text = "Apply"; + position = "990 0"; + extent = "140 40"; + horizSizing = "left"; + vertSizing = "center"; + profile = "GuiMenuButtonProfile"; + command = "OptionsMenu.applyChangedOptions();"; + tooltipProfile = "GuiToolTipProfile"; + class = "MenuInputButton"; + }; + new GuiIconButtonCtrl(OptionsMenuResetBtn) { + BitmapAsset = "UI:Keyboard_Black_R_image"; + sizeIconToButton = "1"; + makeIconSquare = "1"; + textLocation = "Center"; text = "Reset"; position = "1135 0"; extent = "140 40"; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index ba6f1e9b4..81303f4ac 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -59,8 +59,11 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( keyboard, R, OptionsMenuReset ); OptionsMenuActionMap.bind( gamepad, btn_x, OptionsMenuReset ); - OptionsMenuActionMap.bind( keyboard, Enter, OptionsMenuActivateOption ); + OptionsMenuActionMap.bind( keyboard, Space, OptionsMenuActivateOption ); OptionsMenuActionMap.bind( gamepad, btn_a, OptionsMenuActivateOption ); + + OptionsMenuActionMap.bind( keyboard, Enter, tryApplyOptions); + OptionsMenuActionMap.bind( gamepad, btn_start, tryApplyOptions); } //============================================================================== @@ -237,6 +240,11 @@ function OptionsMenu::syncGui(%this) OptionsMenuPrevNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuPrevCategory")); OptionsMenuNextNavIcon.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuNextCategory")); + + OptionsMenuApplyBtn.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "tryApplyOptions")); + + OptionsMenuRemapBtn.visible = KBMControlsList.visible || GamepadControlsList.visible; + OptionsMenuRemapBtn.setBitmap(OptionsMenuActionMap.getCommandButtonBitmap(%device, "OptionsMenuActivateOption")); } //============================================================================== @@ -292,6 +300,12 @@ function OptionMenuNavigatePrev(%val) $MenuList.listPosition = 0; $MenuList.syncGUI(); + + $BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "OptionMenuNavigatePrev", 1); + } + else + { + cancel($BaseUI::scrollSchedule); } } @@ -311,15 +325,23 @@ function OptionMenuNavigateNext(%val) $MenuList.listPosition = $MenuList.getCount()-1; $MenuList.syncGUI(); + + $BaseUI::scrollSchedule = schedule($BaseUI::scrollSpeedTimeMs, 0, "OptionMenuNavigateNext", 1); + } + else + { + cancel($BaseUI::scrollSchedule); } } function OptionMenuStickNavigate(%val) { - if(%val == -1) - BaseUINavigateNext(1); - else if(%val == 1) - mainMenuNavigateDown(1); + if(%val == 1) + OptionMenuNavigateNext(1); + else if(%val == -1) + OptionMenuNavigatePrev(1); + else + cancel($BaseUI::scrollSchedule); } function OptionMenuPrevSetting(%val) @@ -387,11 +409,9 @@ function OptionsMenuActivateOption(%val) if(!isObject(%option)) return; - echo(%option.class); - if(%option.class $= "OptionsKeybindEntry") { - eval(%option-->button.altCommand); + %option-->button.execAltCommand(); } } @@ -504,29 +524,29 @@ function OptionsMenu::populateAudioSettings(%this) function OptionsMenu::populateKBMControls(%this) { - //$remapListDevice = "keyboard"; %this.populateKeybinds("keyboard", KBMControlsList); %this.syncGui(); + + KBMControlsList.syncGui(); } function OptionsMenu::populateGamepadControls(%this) { - //$remapListDevice = ; %this.populateKeybinds("gamepad", GamepadControlsList); %this.syncGui(); + + GamepadControlsList.syncGui(); } function OptionsMenu::populateKeybinds(%this, %device, %controlsList) { - //%device = $remapListDevice; - %controlsList.clear(); //build out our list of action maps %actionMapCount = ActionMapGroup.getCount(); - + %actionMapList = ""; for(%i=0; %i < %actionMapCount; %i++) { @@ -567,32 +587,34 @@ function OptionsMenu::populateKeybinds(%this, %device, %controlsList) if($activeRemapControlSet $= "") $activeRemapControlSet = getField(%actionMapList, 0); - if(getFieldCount(%actionMapList) > 1) + for(%am = 0; %am < getFieldCount(%actionMapList); %am++) { - for(%am = 0; %am < getFieldCount(%actionMapList); %am++) + %currentActionMap = getField(%actionMapList, %am); + + //only add the group if we've got more than one group, otherwise it's obviously + //part of the single grouping + if(getFieldCount(%actionMapList) > 1) { - %currentActionMap = getField(%actionMapList, %am); - %actionMapGroupEntry = addOptionGroup(%currentActionMap); %controlsList.add(%actionMapGroupEntry); + } + + for ( %i = 0; %i < $RemapCount; %i++ ) + { + if(%device !$= "" && %device !$= $RemapDevice[%i]) + continue; + + %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; + + if(%currentActionMap !$= %actionMapName) + continue; + + %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device ); + + %description = $RemapDescription[%i]; - for ( %i = 0; %i < $RemapCount; %i++ ) - { - if(%device !$= "" && %device !$= $RemapDevice[%i]) - continue; - - %actionMapName = $RemapActionMap[%i].humanReadableName $= "" ? $RemapActionMap[%i].getName() : $RemapActionMap[%i].humanReadableName; - - if(%currentActionMap !$= %actionMapName) - continue; - - %keyMap = buildFullMapString( %i, $RemapActionMap[%i], %device ); - - %description = $RemapDescription[%i]; - - %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %i, %description); - %controlsList.add(%remapEntry); - } + %remapEntry = addActionMapEntry(%actionMapName, %device, %keyMap, %i, %description); + %controlsList.add(%remapEntry); } } @@ -627,6 +649,20 @@ function tryCloseOptionsMenu(%val) } } +function tryApplyOptions(%val) +{ + if(!%val) + return; + + $optionsChangeRequiresRestart = false; + + %unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges(); + %unappliedAudioChanges = AudioSettingsList.checkForUnappliedChanges(); + + if(%unappliedVideoChanges || %unappliedAudioChanges) + OptionsMenu.applyChangedOptions(); +} + function OptionsMenu::applyChangedOptions(%this) { VideoSettingsList.applyChanges(); @@ -650,14 +686,13 @@ function OptionsMenu::applyChangedOptions(%this) function doKeyRemap( %optionEntry ) { - //%rowIndex = %row.remapIndex; - //%name = $RemapName[%rowIndex]; - %name = getField(%optionEntry.keymap,0); RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ; OptRemapInputCtrl.index = %optionEntry.remapIndex; + $remapListDevice = %optionEntry.device; + Canvas.pushDialog( RemapDlg ); } diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui index ccc678df6..756eb7de5 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui @@ -24,6 +24,7 @@ $guiContent = new GuiControl(RemapDlg) { vertSizing = "height"; profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; + sendAxisEvents = "1"; }; new GuiControl(RemapBoxCtrl) { position = "-1 1"; diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript b/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript index 107251735..7e4b55906 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.tscript @@ -1,12 +1,36 @@ +function OptRemapInputCtrl::onAxisEvent( %this, %device, %action, %axisVal) +{ + if(%device $= "mouse") + return; + if(!startsWith(%device,$remapListDevice)) + return; + if(%axisVal != 1 && %axisVal != -1) //we want full presses on sticks to be sure + return; + + Canvas.popDialog( RemapDlg ); + + %this.doRemap(%device, %action, %axisVal); +} + function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) { - Canvas.popDialog( RemapDlg ); - - if ( %device $= "keyboard" && %action $= "escape" ) - return; - else if( %device $= "gamepad" && %action $= "btn_start" ) + if(!startsWith(%device,$remapListDevice) && %action !$= "escape" && %action !$= "btn_start") + { + return; + } + else + { + Canvas.popDialog( RemapDlg ); + + if(%action $= "escape" || %action $= "btn_start") return; + + %this.doRemap(%device, %action, 0); + } +} +function OptRemapInputCtrl::doRemap(%this, %device, %action, %axisVal) +{ %cmd = $RemapCmd[%this.index]; %name = $RemapName[%this.index]; %actionMap = $RemapActionMap[%this.index]; @@ -21,32 +45,24 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) %prevMap = %actionMap.getCommand( %device, %action ); //TODO: clear all existant keybinds to a command and then bind it so we only have a single one at all times - unbindExtraActions( %cmd, %actionMap, 0 ); - unbindExtraActions( %cmd, %actionMap, 1 ); + unbindExtraActions( %cmd, %actionMap, %device, 0 ); + unbindExtraActions( %cmd, %actionMap, %device, 1 ); // If nothing was mapped to the previous command // mapping then it's easy... just bind it. - if ( %prevMap $= "" ) + // If the previous command is the same as the + // current then they hit the same input as what + // was already assigned. + if ( %prevMap $= "" || %prevMap $= %cmd ) { //unbindExtraActions( %cmd, %actionMap, 1 ); %actionMap.bind( %device, %action, %cmd ); - OptionsMenu.syncGui(); + OptionsMenu.populateKBMControls(); + OptionsMenu.populateGamepadControls(); return; } - // If the previous command is the same as the - // current then they hit the same input as what - // was already assigned. - if ( %prevMap $= %cmd ) - { - //unbindExtraActions( %cmd, %actionMap, 0 ); - %actionMap.bind( %device, %action, %cmd ); - - OptionsMenu.syncGui(); - return; - } - // Look for the index of the previous mapping. %prevMapIndex = findRemapCmdIndex( %prevMap ); @@ -73,5 +89,24 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action ) %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ ");"; %cancelCommand = ""; - MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand ); -} \ No newline at end of file + MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand ); +} + +/// This unbinds actions beyond %count associated to the +/// particular actionMap %commmand. +function unbindExtraActions( %command, %actionMap, %device, %count ) +{ + %temp = %actionMap.getBinding( %command ); + if ( %temp $= "" ) + return; + + %count = getFieldCount( %temp ) - ( %count * 2 ); + for ( %i = 0; %i < %count; %i += 2 ) + { + %amDevice = getField( %temp, %i + 0 ); + %action = getField( %temp, %i + 1 ); + + if(%device !$= "" || %device $= %amDevice) + %actionMap.unbind( %device, %action ); + } +} diff --git a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript index ef2c85df0..dcf198969 100644 --- a/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/controlsMenu.tscript @@ -225,23 +225,6 @@ function findRemapCmdIndex( %command ) return( -1 ); } -/// This unbinds actions beyond %count associated to the -/// particular actionMap %commmand. -function unbindExtraActions( %command, %actionMap, %count ) -{ - %temp = %actionMap.getBinding( %command ); - if ( %temp $= "" ) - return; - - %count = getFieldCount( %temp ) - ( %count * 2 ); - for ( %i = 0; %i < %count; %i += 2 ) - { - %device = getField( %temp, %i + 0 ); - %action = getField( %temp, %i + 1 ); - - %actionMap.unbind( %device, %action ); - } -} function redoMapping( %device, %actionMap, %action, %cmd, %oldIndex, %newIndex ) { From e71880b898ab5a2bccfcd4024f57b2c3f814cbad Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 1 Jan 2024 01:42:53 -0600 Subject: [PATCH 12/19] - Added a companion global var array for $AudioChannelsName[x] as well as utilizing $AudioChannelCount for keeping better tabs on the active defined audio channels. This allows modules to establish new channels more easily - Updated the handling of the option slider entries to utilize temp vars and properly complied the audio channel options to the new setup - Fixed issue where behavior of slider was erratic because of improperly defined tick count - Added logic to check if audio sliders were changed for the 'check unchanged settings' logic - Made the keybind remap inputCtrl ignore axis events - Made the MessageBoxDlg input commands properly check for key makes, to prevent messages boxes from catching key breaks and blowing past follow-up messageboxes accidentally - Fixed forward/backward iteration of options entries, especially on dpad, and added handling for gamepad stick to do the same - Added logic so option sliders can also be manipulated by the forward/backward to make it standard for all - Fixed erroneous marking of "restart required" message as true if any settings change, and not just settings expressly flagged as requiring a restart --- .../game/core/sfx/scripts/audio.tscript | 11 ++- .../game/data/UI/guis/messageBoxDlg.tscript | 10 ++- .../game/data/UI/guis/optionsMenu.tscript | 86 ++++++++++++++++--- .../BaseGame/game/data/UI/guis/remapDlg.gui | 2 +- 4 files changed, 90 insertions(+), 19 deletions(-) diff --git a/Templates/BaseGame/game/core/sfx/scripts/audio.tscript b/Templates/BaseGame/game/core/sfx/scripts/audio.tscript index abc6cb6a8..2d8726afc 100644 --- a/Templates/BaseGame/game/core/sfx/scripts/audio.tscript +++ b/Templates/BaseGame/game/core/sfx/scripts/audio.tscript @@ -309,17 +309,26 @@ function sfxAutodetect() //----------------------------------------------------------------------------- // Volume channel IDs for backwards-compatibility. - +$AudioChannelCount = 5; $GuiAudioType = 1; // Interface. $SimAudioType = 2; // Game. $MessageAudioType = 3; // Notifications. $MusicAudioType = 4; // Music. $AudioChannels[ 0 ] = AudioChannelDefault; +$AudioChannelsName[ 0 ] = "Master"; + $AudioChannels[ $GuiAudioType ] = AudioChannelGui; +$AudioChannelsName[ $GuiAudioType ] = "Gui"; + $AudioChannels[ $SimAudioType ] = AudioChannelEffects; +$AudioChannelsName[ $SimAudioType ] = "Effects"; + $AudioChannels[ $MessageAudioType ] = AudioChannelMessages; +$AudioChannelsName[ $MessageAudioType ] = "Messages"; + $AudioChannels[ $MusicAudioType ] = AudioChannelMusic; +$AudioChannelsName[ $MusicAudioType ] = "Music"; function sfxOldChannelToGroup( %channel ) { diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript index 71dc9bbea..53133de0e 100644 --- a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript @@ -137,14 +137,16 @@ function MessageBoxCtrl::syncGui(%this) } -function messageBoxYesClicked(%this) +function messageBoxYesClicked(%val) { - MessageCallback(MessageBoxDlg, MessageBoxDlg.callback); + if(%val) + MessageCallback(MessageBoxDlg, MessageBoxDlg.callback); } -function messageBoxNoClicked(%this) +function messageBoxNoClicked(%val) { - MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback); + if(%val) + MessageCallback(MessageBoxDlg,MessageBoxDlg.cancelCallback); } //MessageBoxOK("Test", "This is a test message box", "echo(\"Uhhhhhawhat?\""); diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 81303f4ac..ffbfcaf1f 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -19,6 +19,8 @@ function OptionsMenu::onAdd(%this) function OptionsMenu::onWake(%this) { + $optionsChangeRequiresRestart = false; + %this.populateVideoSettings(); %this.populateAudioSettings(); @@ -48,7 +50,7 @@ if(!isObject( OptionsMenuActionMap ) ) OptionsMenuActionMap.bind( keyboard, d, OptionMenuNextSetting ); OptionsMenuActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", OptionMenuStickChangeSetting ); OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuPrevSetting ); - OptionsMenuActionMap.bind( gamepad, lpov, OptionMenuNextSetting ); + OptionsMenuActionMap.bind( gamepad, rpov, OptionMenuNextSetting ); OptionsMenuActionMap.bind( keyboard, q, OptionsMenuPrevCategory ); OptionsMenuActionMap.bind( gamepad, btn_l, OptionsMenuPrevCategory ); @@ -145,7 +147,7 @@ function OptionsMenuList::checkForUnappliedChanges(%this) if(!%targetOptionLevel.isCurrent()) %unappliedChanges = true; - if(%option.optionsObject.requiresRestart) + if(%unappliedChanges && %option.optionsObject.requiresRestart) $optionsChangeRequiresRestart = true; } } @@ -365,6 +367,17 @@ function OptionMenuPrevSetting(%val) //echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); } + else if(%option.class $= "OptionsListSliderEntry") + { + %sliderCtrl = %option-->valuesContainer-->slider; + %minValue = %sliderCtrl.range.x; + %maxValue = %sliderCtrl.range.y; + %ticks = %sliderCtrl.ticks; + + %tickIncrementVal = (%maxValue - %minValue) / %ticks; + + %sliderCtrl.value -= %tickIncrementVal; + } $MenuList.syncGUI(); } @@ -390,13 +403,27 @@ function OptionMenuNextSetting(%val) //echo("Changed option: " @ %optionObject.optionName @ " from level: " @ %currentOptionLevel.displayName @ " to level: " @ %newOptionLevel.displayName); } + else if(%option.class $= "OptionsListSliderEntry") + { + %sliderCtrl = %option-->valuesContainer-->slider; + %minValue = %sliderCtrl.range.x; + %maxValue = %sliderCtrl.range.y; + %ticks = %sliderCtrl.ticks; + + %tickIncrementVal = (%maxValue - %minValue) / %ticks; + + %sliderCtrl.value += %tickIncrementVal; + } $MenuList.syncGUI(); } function OptionMenuStickChangeSetting(%val) { - + if(%val == 1) + OptionMenuNextSetting(1); + else if(%val == -1) + OptionMenuPrevSetting(1); } function OptionsMenuActivateOption(%val) @@ -509,10 +536,19 @@ function OptionsMenu::populateAudioSettings(%this) AudioSettingsList.add(addOptionGroup("Channel Volume")); - AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 0.1)); - AudioSettingsList.add(addOptionSlider("GUI Volume", "", "$pref::SFX::channelVolume[" @ $GuiAudioType @ "]", 0, 1, 0.1)); - AudioSettingsList.add(addOptionSlider("Effects Volume", "", "$pref::SFX::channelVolume[" @ $SimAudioType @ "]", 0, 1, 0.1)); - AudioSettingsList.add(addOptionSlider("Music Volume", "", "$pref::SFX::channelVolume[" @ $MusicAudioType @ "]", 0, 1, 0.1)); + //Now we'll populate the sliders for the audio channels. + //The defaults of these are defined in core/sfx/scripts/audio.tscript + //These define the MasterVolume channel, as well as several other common defualt ones + //Because it's a variable list, this can be expanded by modules by just upping $AudioChannelCount + //and then defining the $AudioChannelName[x] with the displayed name and + //and the $AudioChannels[x] variable with the SFXSource object defined to it for the given channel + AudioSettingsList.add(addOptionSlider("Master Volume", "", "$pref::SFX::masterVolume", 0, 1, 10)); + + //We init to 1, because 0 is the reserved for the masterVolume in practice + for(%i=1; %i < $AudioChannelCount; %i++) + { + AudioSettingsList.add(addOptionSlider($AudioChannelsName[%i] @ " Volume", "", "$pref::SFX::channelVolume" @ %i, 0, 1, 10)); + } //Ensure our newly templated options listings are sized right for(%i=0; %i < AudioSettingsList.getCount(); %i++) @@ -637,6 +673,17 @@ function tryCloseOptionsMenu(%val) %unappliedVideoChanges = VideoSettingsList.checkForUnappliedChanges(); %unappliedAudioChanges = AudioSettingsList.checkForUnappliedChanges(); + //validate audio prefs + if($pref::SFX::masterVolume_tempVar !$= "" && $pref::SFX::masterVolume_tempVar != $pref::SFX::masterVolume) + %unappliedAudioChanges = true; + + for(%i=1; %i < $AudioChannelCount; %i++) + { + %tempVolume = getVariable("$pref::SFX::channelVolume" @ %i @ "_tempVar"); + if(%tempVolume !$= "" && $pref::SFX::channelVolume[ %i ] != %tempVolume) + %unappliedAudioChanges = true; + } + if(%unappliedVideoChanges || %unappliedAudioChanges) { MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", @@ -668,12 +715,19 @@ function OptionsMenu::applyChangedOptions(%this) VideoSettingsList.applyChanges(); AudioSettingsList.applyChanges(); - //$pref::SFX::masterVolume = OptionsMenuSettingsList.getValue(2); + //Process the audio channel tempvars to get their values + //and then apply them to the actual pref variable, as well as the SFXChannelVolume + $pref::SFX::masterVolume = $pref::SFX::masterVolume_tempVar; sfxSetMasterVolume( $pref::SFX::masterVolume ); - sfxSetChannelVolume( $GuiAudioType, $pref::SFX::channelVolume[ $GuiAudioType ] ); - sfxSetChannelVolume( $SimAudioType, $pref::SFX::channelVolume[ $SimAudioType ] ); - sfxSetChannelVolume( $MusicAudioType, $pref::SFX::channelVolume[ $MusicAudioType ] ); + //0 is always master anyways + for(%i=1; %i < $AudioChannelCount; %i++) + { + %volume = getVariable("$pref::SFX::channelVolume" @ %i @ "_tempVar"); + sfxSetChannelVolume( %i, %volume ); + $pref::SFX::channelVolume[ %i ] = %volume; + } + //Finally, write our prefs to file %prefPath = getPrefpath(); export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); @@ -838,13 +892,17 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide { %currentVal = getVariable(%prefName); + %tempVarName = %prefName @ "_tempVar"; + if(%currentVal $= "") %currentVal = %sliderMin; + setVariable(%tempVarName, %currentVal); + %optionNameHeight = 20; if(%optionDesc $= "") %optionNameHeight = 40; - + %entry = new GuiContainer() { position = "0 0"; extent = "800 40"; @@ -897,11 +955,12 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide ticks = %sliderTicks; snap = "1"; value = %currentVal; + variable = %tempVarName; useFillBar = "1"; fillBarColor = $TextMediumEmphasisColor; renderTicks = "0"; position = "0 10"; - extent = "300 20"; + extent = "400 20"; minExtent = "8 2"; horizSizing = "right"; vertSizing = "center"; @@ -915,6 +974,7 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide canSave = "1"; canSaveDynamicFields = "0"; class = "OptionsSliderEntrySlider"; + internalName = "slider"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui index 756eb7de5..2ebf9b150 100644 --- a/Templates/BaseGame/game/data/UI/guis/remapDlg.gui +++ b/Templates/BaseGame/game/data/UI/guis/remapDlg.gui @@ -24,7 +24,7 @@ $guiContent = new GuiControl(RemapDlg) { vertSizing = "height"; profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; - sendAxisEvents = "1"; + sendAxisEvents = "0"; }; new GuiControl(RemapBoxCtrl) { position = "-1 1"; From 150684a47de60d746cbf9d50b57fe6150b55b6e8 Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 1 Jan 2024 14:11:43 -0600 Subject: [PATCH 13/19] - Complied the SystemMenu buttons to the groupNum highlighting implementation as they're simple buttons - Fixed issue of Query Server on-screen button tripping a join action - Added playername textEdit field to Join Server menu - Fixed issue of messageBox on-screen buttons not making the input events properly after adding the make/break check from prior commit - Added MenuTextEditProfile for editable text fields in menu - Fixed issue of not getting the correct shift key bitmap if the button name was l/rshift --- .../BaseGame/game/data/UI/guis/SystemMenu.gui | 8 +++ .../game/data/UI/guis/SystemMenu.tscript | 10 +++- .../game/data/UI/guis/joinServerMenu.gui | 55 +++++++++++++------ .../game/data/UI/guis/messageBoxDlg.tscript | 6 +- .../game/data/UI/scripts/profiles.tscript | 28 +++++++++- .../game/data/UI/scripts/utility.tscript | 3 + 6 files changed, 87 insertions(+), 23 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui index 381762506..18605ba85 100644 --- a/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.gui @@ -22,6 +22,8 @@ $guiContent = new GuiControl(SystemMenu) { profile = "GuiMenuButtonProfile"; command = "Canvas.popDialog(GameMenu);"; tooltipProfile = "GuiToolTipProfile"; + groupNum = "1"; + class = "SystemMenuButton"; }; new GuiButtonCtrl() { text = "Options"; @@ -30,6 +32,8 @@ $guiContent = new GuiControl(SystemMenu) { profile = "GuiMenuButtonProfile"; command = "Canvas.pushDialog(OptionsMenu);"; tooltipProfile = "GuiToolTipProfile"; + groupNum = "1"; + class = "SystemMenuButton"; }; new GuiButtonCtrl() { text = "Exit to Menu"; @@ -38,6 +42,8 @@ $guiContent = new GuiControl(SystemMenu) { profile = "GuiMenuButtonProfile"; command = "systemMenuExitToMenu();"; tooltipProfile = "GuiToolTipProfile"; + groupNum = "1"; + class = "SystemMenuButton"; }; new GuiButtonCtrl() { text = "Exit to Desktop"; @@ -46,6 +52,8 @@ $guiContent = new GuiControl(SystemMenu) { profile = "GuiMenuButtonProfile"; command = "systemMenuExitToDesktop();"; tooltipProfile = "GuiToolTipProfile"; + groupNum = "1"; + class = "SystemMenuButton"; }; }; }; diff --git a/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript b/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript index 2b6b8ed27..1974b2d0f 100644 --- a/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/SystemMenu.tscript @@ -2,6 +2,8 @@ function SystemMenu::onWake(%this) { $MenuList = SystemMenuButtonList; $MenuList.listPosition = 0; + + $MenuList.syncGui(); } function SystemMenu::onSleep(%this) @@ -19,10 +21,14 @@ function systemMenuExitToDesktop() MessageBoxOKCancel("Exit?", "Do you wish to exit to the desktop?", "quit();", ""); } +function SystemMenuButton::onHighlighted(%this, %highlighted) +{ + if(%highlighted) + $MenuList.listPosition = $MenuList.getObjectIndex(%this); +} + function SystemMenuButtonList::syncGUI(%this) { - %this.callOnChildren("setHighlighted", false); - %btn = %this.getObject(%this.listPosition); %btn.setHighlighted(true); diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index 30b6a8d04..f307a6e93 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -7,7 +7,7 @@ $guiContent = new GuiControl(JoinServerMenu) { tooltipProfile = "GuiToolTipProfile"; isContainer = "1"; canSaveDynamicFields = "1"; - + new GuiInputCtrl(JoinServerInputHandler) { ignoreMouseEvents = "1"; ActionMap = "JoinServerActionMap"; @@ -18,7 +18,6 @@ $guiContent = new GuiControl(JoinServerMenu) { profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiPanel(JoinServerTitlePanel) { extent = "1281 60"; horizSizing = "width"; @@ -34,23 +33,45 @@ $guiContent = new GuiControl(JoinServerMenu) { }; }; new GuiContainer() { - position = "203 61"; + position = "190 61"; extent = "900 30"; - profile = GuiMenuPanelProfile; - tooltipProfile = "GuiToolTipProfile"; horizSizing = "center"; - vertSizing = "bottom"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Player Name"; + position = "0 5"; + extent = "98 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl(JoinServerPlayerNameTxt) { + text = "Visitor"; + position = "606 7"; + extent = "295 18"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$pref::Player::Name"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "190 97"; + extent = "900 30"; + horizSizing = "center"; + profile = "GuiMenuPanelProfile"; + tooltipProfile = "GuiToolTipProfile"; new GuiTextCtrl() { text = "Server Details"; - position = "0 0"; extent = "700 30"; - horizSizing = "right"; vertSizing = "center"; profile = "MenuSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextCtrl() { text = "Ping"; position = "700 0"; @@ -60,7 +81,6 @@ $guiContent = new GuiControl(JoinServerMenu) { profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextCtrl() { text = "Player Count"; position = "770 0"; @@ -70,12 +90,12 @@ $guiContent = new GuiControl(JoinServerMenu) { profile = "MenuSubHeaderCenteredText"; tooltipProfile = "GuiToolTipProfile"; }; - }; + }; new GuiScrollCtrl() { hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; - position = "203 91"; - extent = "900 621"; + position = "190 127"; + extent = "900 551"; minExtent = "8 8"; horizSizing = "center"; vertSizing = "height"; @@ -102,7 +122,7 @@ $guiContent = new GuiControl(JoinServerMenu) { tooltipProfile = "GuiToolTipProfile"; new GuiIconButtonCtrl(JoinServerJoinBtn) { - BitmapAsset = "UI:Keyboard_Black_Return_image"; + BitmapAsset = "UI:Keyboard_Black_Space_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Center"; @@ -112,11 +132,12 @@ $guiContent = new GuiControl(JoinServerMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; + active = "0"; command = "JoinServerMenu.join();"; tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(JoinServerQLanBtn) { - BitmapAsset = "UI:Keyboard_Black_Escape_image"; + BitmapAsset = "UI:Keyboard_Black_E_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Center"; @@ -130,7 +151,7 @@ $guiContent = new GuiControl(JoinServerMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(JoinServerQServerBtn) { - BitmapAsset = "UI:Keyboard_Black_Escape_image"; + BitmapAsset = "UI:Keyboard_Black_Q_image"; sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Center"; @@ -140,7 +161,7 @@ $guiContent = new GuiControl(JoinServerMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "JoinServerMenu.join();"; + command = "JoinServerMenu.query();"; tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(JoinServerBackBtn) { diff --git a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript index 53133de0e..322b81082 100644 --- a/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript +++ b/Templates/BaseGame/game/data/UI/guis/messageBoxDlg.tscript @@ -157,7 +157,7 @@ function MessageBoxOK(%title, %message, %callback) Canvas.pushDialog(MessageBoxDlg); MessageBoxTitleText.text = %title; - %okButton = MessageBoxCtrl.createButton("OK", "messageBoxYesClicked();"); + %okButton = MessageBoxCtrl.createButton("OK", "messageBoxYesClicked(1);"); %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxYesClicked"); %okButton.setBitmap(%bitmapAssetId); @@ -182,11 +182,11 @@ function MessageBoxOKCancel(%title, %message, %callback, %cancelCallback, %okLab else %cancelLabel = %cancelLabelOverride; - %okButton = MessageBoxCtrl.createButton(%okLabel, "messageBoxYesClicked();"); + %okButton = MessageBoxCtrl.createButton(%okLabel, "messageBoxYesClicked(1);"); %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxYesClicked"); %okButton.setBitmap(%bitmapAssetId); - %cancelButton = MessageBoxCtrl.createButton(%cancelLabel, "messageBoxNoClicked();"); + %cancelButton = MessageBoxCtrl.createButton(%cancelLabel, "messageBoxNoClicked(1);"); %bitmapAssetId = MessageBoxActionMap.getCommandButtonBitmap(Canvas.getLastInputDevice(), "messageBoxNoClicked"); %cancelButton.setBitmap(%bitmapAssetId); diff --git a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript index 60c7f4bf7..9b9b1490c 100644 --- a/Templates/BaseGame/game/data/UI/scripts/profiles.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/profiles.tscript @@ -200,4 +200,30 @@ singleton GuiControlProfile(GuiMenuScrollProfile) bitmapAsset = "UI:scrollBar_image"; hasBitmapArray = true; category = "BaseUI"; -}; \ No newline at end of file +}; + +new GuiControlProfile(MenuTextEditprofile) +{ + opaque = true; + fillColor = "10 10 10 255"; + fillColorHL = "10 10 10 255"; + fontColor = "240 240 240"; + fontColorHL = "10 10 10 255"; + fontColorSEL = "255 255 255 255"; + fontColorNA = "200 200 200"; + textOffset = "4 2"; + autoSizeWidth = false; + autoSizeHeight = true; + justify = "left"; + tab = true; + canKeyFocus = true; + category = "BaseUI"; + borderColorSEL = "0 0 0 0"; + fontColors[0] = "240 240 240 255"; + fontColors[1] = "10 10 10 255"; + fontColors[2] = "200 200 200 255"; + fontColors[3] = "255 255 255 255"; + fillColorSEL = "10 10 10 255"; + fontSize = "18"; + cursorColor = "255 255 255 255"; +}; diff --git a/Templates/BaseGame/game/data/UI/scripts/utility.tscript b/Templates/BaseGame/game/data/UI/scripts/utility.tscript index a3d596088..e5eeac2de 100644 --- a/Templates/BaseGame/game/data/UI/scripts/utility.tscript +++ b/Templates/BaseGame/game/data/UI/scripts/utility.tscript @@ -113,6 +113,9 @@ function getButtonBitmap(%device, %button) } else if(%device $= "Keyboard" || %device $= "Mouse") { + if(%button $= "lshift" || %button $= "rshift") + %button = "shift"; + %assetId = "UI:Keyboard_Black_" @ %button @ "_image"; } else if(%device !$= "") From c809dbb4be964ceb738f4ebed708b179a2960c5e Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 3 Jan 2024 23:45:36 -0600 Subject: [PATCH 14/19] - Ensures if there is a $pref::server::password set and you're creating a localConnection game, you can connect even if you don't have a client password set - Changed ChooseLevelMenu layout to have a vertical list for levels with a static preview set, as well as a separate tab for server configs if trying to create a server - Added field to set password for connecting to passworded servers on the JoinServerMenu - Added sanity check so you can't try and activate a menuList that has no children(caused error spam) --- Engine/source/T3D/gameBase/gameConnection.cpp | 2 +- .../game/data/UI/guis/ChooseLevelMenu.gui | 299 ++++++++++++++++-- .../game/data/UI/guis/ChooseLevelMenu.tscript | 197 ++++++++---- .../game/data/UI/guis/joinServerMenu.gui | 34 +- .../game/data/UI/guis/joinServerMenu.tscript | 9 + .../game/data/UI/guis/mainMenu.tscript | 3 + 6 files changed, 446 insertions(+), 98 deletions(-) diff --git a/Engine/source/T3D/gameBase/gameConnection.cpp b/Engine/source/T3D/gameBase/gameConnection.cpp index b88bde05e..6b19b40b5 100644 --- a/Engine/source/T3D/gameBase/gameConnection.cpp +++ b/Engine/source/T3D/gameBase/gameConnection.cpp @@ -478,7 +478,7 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr setProtocolVersion(currentProtocol < CurrentProtocolVersion ? currentProtocol : CurrentProtocolVersion); const char *serverPassword = Con::getVariable("pref::Server::Password"); - if(serverPassword[0]) + if(serverPassword[0] && !isLocalConnection()) { if(String::compare(joinPassword, serverPassword)) { diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index 6739e8bc9..3b43eb163 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -10,7 +10,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) { isContainer = "1"; canSaveDynamicFields = "1"; launchInEditor = "0"; - + previewButtonSize = "445 120"; + new GuiInputCtrl(ChooseLevelInputHandler) { ignoreMouseEvents = "1"; ActionMap = "ChooseLevelActionMap"; @@ -21,7 +22,6 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "GuiInputCtrlProfile"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiPanel(ChooseLevelTitlePanel) { extent = "1281 60"; horizSizing = "width"; @@ -36,6 +36,275 @@ $guiContent = new GuiControl(ChooseLevelMenu) { tooltipProfile = "GuiToolTipProfile"; }; }; + new GuiStackControl(ChooseLevelMenuTabList) { + stackingType = "Horizontal"; + padding = "10"; + position = "485 61"; + extent = "310 41"; + horizSizing = "center"; + profile = "GuiDefaultProfile"; + visible = "0"; + tooltipProfile = "GuiToolTipProfile"; + hidden = "1"; + + new GuiButtonCtrl() { + text = "Level"; + groupNum = "1"; + extent = "150 41"; + profile = "GuiMenuButtonProfile"; + command = "ChooseLevelMenu.openMenu(0);"; + tooltipProfile = "GuiToolTipProfile"; + class = "ChooseLevelMenuButton"; + }; + new GuiButtonCtrl() { + text = "Server Config"; + groupNum = "1"; + position = "160 0"; + extent = "150 41"; + profile = "GuiMenuButtonProfile"; + command = "ChooseLevelMenu.openMenu(1);"; + tooltipProfile = "GuiToolTipProfile"; + class = "ChooseLevelMenuButton"; + }; + }; + new GuiControl(ChooseLevelMenuNavButtonOverlay) { + position = "0 61"; + extent = "1281 60"; + horizSizing = "width"; + profile = "GuiNonModalDefaultProfile"; + visible = "0"; + tooltipProfile = "GuiToolTipProfile"; + isContainer = "1"; + hidden = "1"; + + new GuiBitmapCtrl(ChooseLevelMenuPrevNavIcon) { + BitmapAsset = "UI:Keyboard_Black_Q_image"; + position = "485 24"; + extent = "40 40"; + vertSizing = "top"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiBitmapCtrl(ChooseLevelMenuNextNavIcon) { + BitmapAsset = "UI:Keyboard_Black_E_image"; + position = "595 24"; + extent = "40 40"; + vertSizing = "top"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer(LevelSelectContainer) { + position = "196 119"; + extent = "888 566"; + horizSizing = "center"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiScrollCtrl(LevelPreviewScroll) { + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + extent = "445 562"; + vertSizing = "height"; + profile = "GuiMenuScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiStackControl(LevelPreviewArray) { + padding = "5"; + position = "0 1"; + extent = "445 120"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiBitmapCtrl(LevelPreviewBitmap) { + BitmapAsset = "testMaps:EmptyLevel_preview_image"; + position = "448 0"; + extent = "440 440"; + horizSizing = "left"; + profile = "GuiNonModalDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextCtrl(LevelNameText) { + text = "EmptyLevel"; + position = "448 445"; + extent = "440 20"; + horizSizing = "left"; + profile = "MenuSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "levelNameTxt"; + }; + new GuiMLTextCtrl(LevelDescriptionText) { + position = "448 473"; + extent = "440 19"; + horizSizing = "left"; + profile = "GuiMLTextProfile"; + tooltipProfile = "GuiToolTipProfile"; + internalName = "levelDescTxt"; + }; + }; + new GuiContainer(ServerConfigContainer) { + position = "196 119"; + extent = "888 566"; + horizSizing = "center"; + profile = "GuiNonModalDefaultProfile"; + visible = "0"; + tooltipProfile = "GuiToolTipProfile"; + hidden = "1"; + + new GuiScrollCtrl(ServerConfigScroll) { + hScrollBar = "alwaysOff"; + vScrollBar = "dynamic"; + extent = "888 566"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuScrollProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiStackControl(ServerConfigList) { + padding = "5"; + changeChildSizeToFit = "0"; + position = "1 1"; + extent = "900 170"; + horizSizing = "width"; + vertSizing = "height"; + profile = "GuiMenuDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiContainer() { + extent = "900 30"; + horizSizing = "width"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Host Player Name"; + position = "0 3"; + extent = "140 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl() { + text = "Visitor"; + position = "606 4"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$pref::Player::Name"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "0 35"; + extent = "900 30"; + horizSizing = "width"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Server Name"; + position = "0 3"; + extent = "101 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl() { + text = "Torque 3D Server"; + position = "606 4"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$Pref::Server::Name"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "0 70"; + extent = "900 30"; + horizSizing = "width"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Server Password"; + position = "0 3"; + extent = "135 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl() { + text = "Torque 3D Server"; + position = "606 4"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$Pref::Server::Password"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "0 105"; + extent = "900 30"; + horizSizing = "width"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Server Description"; + position = "0 3"; + extent = "147 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl() { + text = "This is a Torque 3D server."; + position = "606 4"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$Pref::Server::Info"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "0 140"; + extent = "900 30"; + horizSizing = "width"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Max Players"; + position = "0 3"; + extent = "94 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl(JoinServerPlayerNameTxt) { + text = "64"; + position = "606 4"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$Pref::Server::MaxPlayers"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + }; + }; + }; new GuiPanel(ChooseLevelButtonPanel) { position = "0 683"; extent = "1281 40"; @@ -49,9 +318,9 @@ $guiContent = new GuiControl(ChooseLevelMenu) { sizeIconToButton = "1"; makeIconSquare = "1"; textLocation = "Center"; - text = "Start"; - position = "1115 0"; - extent = "140 40"; + text = "Start Game"; + position = "1092 0"; + extent = "163 40"; horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; @@ -72,25 +341,5 @@ $guiContent = new GuiControl(ChooseLevelMenu) { tooltipProfile = "GuiToolTipProfile"; }; }; - new GuiScrollCtrl(LevelPreviewScroll) { - hScrollBar = "dynamic"; - vScrollBar = "alwaysOff"; - position = "0 118"; - extent = "1283 500"; - horizSizing = "width"; - vertSizing = "center"; - profile = "GuiMenuScrollProfile"; - tooltipProfile = "GuiToolTipProfile"; - - new GuiStackControl(LevelPreviewArray) { - position = "1 1"; - extent = "1280 480"; - vertSizing = "center"; - profile = "GuiMenuDefaultProfile"; - tooltipProfile = "GuiToolTipProfile"; - padding = "5"; - stackingType = "Horizontal"; - }; - }; }; //--- OBJECT WRITE END --- diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index df9f1f372..bf871146a 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -19,12 +19,13 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. //----------------------------------------------------------------------------- - //---------------------------------------- function ChooseLevelMenu::onAdd( %this ) { if(!isObject(ChooseLevelAssetQuery)) new AssetQuery(ChooseLevelAssetQuery); + + %this.previewButtonSize = "445 120"; } function ChooseLevelMenu::onWake(%this) @@ -42,7 +43,7 @@ function ChooseLevelMenu::onWake(%this) MessageBoxOK("Error", "No levels were found in any modules. Please ensure you have modules loaded that contain gameplay code and level files.", "Canvas.popDialog(ChooseLevelMenu); if(isObject(ChooseLevelMenu.returnGui) && ChooseLevelMenu.returnGui.isMethod(\"onReturnTo\")) ChooseLevelMenu.returnGui.onReturnTo();"); - ChooseLevelAssetQuery.delete(); + ChooseLevelAssetQuery.clear(); return; } @@ -65,47 +66,27 @@ function ChooseLevelMenu::onWake(%this) if (!isFile(%levelPreviewImg)) %levelPreviewImg = "UI:no_preview_image"; - %preview = new GuiContainer() { - extent = "480 480"; + %preview = new GuiIconButtonCtrl() { + position = "0 0"; + extent = %this.previewButtonSize; + buttonType = "PushButton"; + profile = GuiMenuButtonLeftJustProfile; + horizSizing = "right"; + vertSizing = "bottom"; + internalName = "button"; + class = "LevelPreviewButton"; + //command = "$selectedLevelAsset = " @ %assetId @ ";"; + altCommand = "ChooseLevelBegin(1);"; //allow doubleclick to quick action it + text = %levelAsset.levelName; + bitmapAsset = %levelPreviewImg; + levelAsset = %levelAsset; levelAssetId = %assetId; - - new GuiButtonCtrl() { - position = "0 0"; - extent = "480 480"; - buttonType = "ToggleButton"; - profile = GuiMenuButtonLeftJustProfile; - horizSizing = "width"; - vertSizing = "height"; - internalName = "button"; - class = "LevelPreviewButton"; - command = "$selectedLevelAsset = " @ %assetId @ ";"; - altCommand = "ChooseLevelBegin(1);"; //allow doubleclick to quick action it - }; - - new GuiBitmapCtrl() { - position = "20 0"; - extent = "440 440"; - BitmapAsset = %levelPreviewImg; - horizSizing = "width"; - vertSizing = "bottom"; - profile = GuiNonModalDefaultProfile; - }; - - new GuiTextCtrl() { - position = "20 445"; - extent = "440 15"; - text = %levelAsset.levelName; - profile = MenuSubHeaderText; - internalName = "levelNameTxt"; - }; - - new GuiMLTextCtrl() { - position = "20 465"; - extent = "440 15"; - text = %levelAsset.levelDescription; - profile = GuiMLTextProfile; - internalName = "levelDescTxt"; - }; + iconLocation = "left"; + sizeIconToButton = true; + makeIconSquare = true; + textLocation = "left"; + textMargin = 120; + groupNum = 2; }; LevelPreviewArray.add(%preview); @@ -117,50 +98,115 @@ function ChooseLevelMenu::onWake(%this) { %this.addMissionFile( "tools/levels/DefaultEditorLevel.mis" ); } - - //LevelList.setSelected(0); - + if(!$pref::HostMultiPlayer) ChooseLevelTitleText.setText("SINGLE PLAYER"); else ChooseLevelTitleText.setText("CREATE SERVER"); - $MenuList = LevelPreviewArray; - $MenuList.listPosition = 0; - $MenuList.syncGui(); + %this.openMenu(0); } if(!isObject( ChooseLevelActionMap ) ) { new ActionMap(ChooseLevelActionMap){}; - //Null the up/down nav so we can swap in left/right nav - ChooseLevelActionMap.bindCmd( keyboard, w, "" ); - ChooseLevelActionMap.bindCmd( keyboard, s, "" ); - ChooseLevelActionMap.bindCmd( gamepad, yaxis, "" ); - ChooseLevelActionMap.bindCmd( gamepad, upov, "" ); - ChooseLevelActionMap.bindCmd( gamepad, dpov, "" ); + ChooseLevelActionMap.bind( keyboard, q, ChooseLevelMenuPrevMenu); + ChooseLevelActionMap.bind( gamepad, btn_l, ChooseLevelMenuPrevMenu); - ChooseLevelActionMap.bind( keyboard, a, BaseUINavigatePrev ); - ChooseLevelActionMap.bind( keyboard, d, BaseUINavigateNext ); - ChooseLevelActionMap.bind( gamepad, xaxis, "D", "-0.23 0.23", BaseUIStickNavigate ); - ChooseLevelActionMap.bind( gamepad, lpov, BaseUINavigatePrev ); - ChooseLevelActionMap.bind( gamepad, rpov, BaseUINavigateNext ); + ChooseLevelActionMap.bind( keyboard, e, ChooseLevelMenuNextMenu); + ChooseLevelActionMap.bind( gamepad, btn_r, ChooseLevelMenuNextMenu); ChooseLevelActionMap.bind( keyboard, Space, ChooseLevelBegin ); ChooseLevelActionMap.bind( gamepad, btn_a, ChooseLevelBegin ); } +function ChooseLevelMenu::syncGUI(%this) +{ + //Update the button imagery to comply to the last input device we'd used + %device = Canvas.getLastInputDevice(); + if(%device $= "mouse") + %device = "keyboard"; + + //Category handling + %btn = ChooseLevelMenuTabList.getObject(%this.currentMenuIdx); + %btn.setHighlighted(true); + + %buttonPosX = %btn.position.x + ChooseLevelMenuTabList.position.x; + + ChooseLevelMenuPrevNavIcon.position.x = %buttonPosX; + ChooseLevelMenuNextNavIcon.position.x = %buttonPosX + %btn.extent.x - 40; + + ChooseLevelBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut")); + + ChooseLevelStartBtn.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelBegin")); + + ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu")); + ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu")); + + ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer; + ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer; +} + function LevelPreviewArray::syncGUI(%this) { - %this.callOnChildren("setHighlighted", false); - %btn = %this.getObject(%this.listPosition); - %btn-->button.setHighlighted(true); + %btn.setHighlighted(true); $selectedLevelAsset = %btn.levelAssetId; } +function ChooseLevelMenuPrevMenu(%val) +{ + if(%val) + { + %currentIdx = ChooseLevelMenu.currentMenuIdx; + ChooseLevelMenu.currentMenuIdx -= 1; + + ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, 1); + + if(%currentIdx == ChooseLevelMenu.currentMenuIdx) + return; + + ChooseLevelMenu.openMenu(ChooseLevelMenu.currentMenuIdx); + } +} + +function ChooseLevelMenuNextMenu(%val) +{ + if(%val) + { + %currentIdx = ChooseLevelMenu.currentMenuIdx; + ChooseLevelMenu.currentMenuIdx += 1; + + ChooseLevelMenu.currentMenuIdx = mClamp(ChooseLevelMenu.currentMenuIdx, 0, 1); + + if(%currentIdx == ChooseLevelMenu.currentMenuIdx) + return; + + ChooseLevelMenu.openMenu(ChooseLevelMenu.currentMenuIdx); + } +} + + +function ChooseLevelMenu::openMenu(%this, %menuIdx) +{ + LevelSelectContainer.setVisible(%menuIdx == 0); + ServerConfigContainer.setVisible(%menuIdx == 1); + + if(%menuIdx == 0) + $MenuList = LevelPreviewArray; + else if(%menuIdx == 1) + $MenuList = ServerConfigList; + + %this.currentMenuIdx = %menuIdx; + + if($MenuList.isMethod("syncGui")) + $MenuList.syncGui(); + + %this.syncGui(); +} + function ChooseLevelBegin(%val) { if(%val) @@ -178,6 +224,8 @@ function ChooseLevelBegin(%val) MessageBoxOK("Error", "Selected level preview does not have a valid level asset!"); return; } + + $selectedLevelAsset = %entry.levelAssetId; // Launch the chosen level with the editor open? if ( ChooseLevelMenu.launchInEditor ) @@ -198,14 +246,27 @@ function ChooseLevelMenu::onSleep( %this ) // This is set from the outside, only stays true for a single wake/sleep // cycle. %this.launchInEditor = false; + + //Ensure any changes we made to our server configs is saved out + if($pref::HostMultiPlayer) + { + echo("Exporting server prefs"); + %prefPath = getPrefpath(); + export("$Pref::Server::*", %prefPath @ "/serverPrefs." @ $TorqueScriptFileExtension, false); + BanList::Export(%prefPath @ "/banlist." @ $TorqueScriptFileExtension); + } } function LevelPreviewButton::onHighlighted(%this, %highlighted) { - %container = %this.getParent(); - - %container-->levelNameTxt.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText; - %container-->levelDescTxt.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile; - - LevelPreviewScroll.scrollToObject(%this); + if(%highlighted) + { + $MenuList.listPosition = $MenuList.getObjectIndex(%this); + + LevelPreviewBitmap.bitmapAsset = %this.bitmapAsset; + LevelNameText.text = %this.levelAsset.levelName; + LevelDescriptionText.setText(%this.levelAsset.levelDescription); + + LevelPreviewScroll.scrollToObject(%this); + } } \ No newline at end of file diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui index f307a6e93..9394ca35f 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.gui @@ -50,7 +50,7 @@ $guiContent = new GuiControl(JoinServerMenu) { new GuiTextEditCtrl(JoinServerPlayerNameTxt) { text = "Visitor"; position = "606 7"; - extent = "295 18"; + extent = "295 22"; horizSizing = "left"; vertSizing = "center"; profile = "MenuTextEditprofile"; @@ -59,7 +59,33 @@ $guiContent = new GuiControl(JoinServerMenu) { }; }; new GuiContainer() { - position = "190 97"; + position = "190 87"; + extent = "900 30"; + horizSizing = "center"; + profile = "GuiDefaultProfile"; + tooltipProfile = "GuiToolTipProfile"; + + new GuiTextCtrl() { + text = "Password"; + position = "0 5"; + extent = "78 23"; + vertSizing = "center"; + profile = "MenuMLSubHeaderText"; + tooltipProfile = "GuiToolTipProfile"; + }; + new GuiTextEditCtrl(JoinServerPasswordTxt) { + text = "Visitor"; + position = "606 7"; + extent = "295 22"; + horizSizing = "left"; + vertSizing = "center"; + profile = "MenuTextEditprofile"; + variable = "$Client::Password"; + tooltipProfile = "GuiToolTipProfile"; + }; + }; + new GuiContainer() { + position = "190 121"; extent = "900 30"; horizSizing = "center"; profile = "GuiMenuPanelProfile"; @@ -94,8 +120,8 @@ $guiContent = new GuiControl(JoinServerMenu) { new GuiScrollCtrl() { hScrollBar = "alwaysOff"; vScrollBar = "dynamic"; - position = "190 127"; - extent = "900 551"; + position = "190 151"; + extent = "900 532"; minExtent = "8 8"; horizSizing = "center"; vertSizing = "height"; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index 15b8580f1..a0f5f38a9 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -2,11 +2,20 @@ function JoinServerMenu::onWake(%this) { $MenuList = JoinServerList; + $MenuList.clear(); + $Client::Password = ""; JoinServerList.listPosition = 0; JoinServerList.syncGui(); } +function JoinServerMenu::onSleep(%this) +{ + echo("Exporting client prefs"); + %prefPath = getPrefpath(); + export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); +} + if(!isObject( JoinServerActionMap ) ) { new ActionMap(JoinServerActionMap){}; diff --git a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript index 770857ec8..b8f86c3cf 100644 --- a/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/mainMenu.tscript @@ -120,6 +120,9 @@ function MainMenuButton::onHighlighted(%this, %highlighted) function BaseUIActivateSelected() { + if($MenuList.getCount() == 0 || $MenuList.listPosition >= $MenuList.getCount() || $MenuList.listPosition < 0) + return; + %btn = $MenuList.getObject($MenuList.listPosition); if(%btn.isMethod("performClick")) From 5e334eb19682fdd8c79fd7375a186b1aa3fc5f9a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 4 Jan 2024 11:54:28 -0600 Subject: [PATCH 15/19] don't save map population elements when editing track addOption entry/slider/group position in the overall list, and use that found key to hook in the "<" and ">" subelements for selection purposes --- .../BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript | 1 + Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index bf871146a..c64222332 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -87,6 +87,7 @@ function ChooseLevelMenu::onWake(%this) textLocation = "left"; textMargin = 120; groupNum = 2; + cansave = false; }; LevelPreviewArray.add(%preview); diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index ffbfcaf1f..f297b1159 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -19,6 +19,7 @@ function OptionsMenu::onAdd(%this) function OptionsMenu::onWake(%this) { + %this.optsListCount = -1; $optionsChangeRequiresRestart = false; %this.populateVideoSettings(); @@ -759,6 +760,7 @@ function OptionsMenu::resetSettings(%this) // Option types function addOptionGroup(%displayName) { + OptionsMenu.optsListCount++; %group = new GuiTextCtrl() { text = %displayName; position = "0 0"; @@ -785,6 +787,7 @@ function optionsMenuButton::onHighlighted(%this, %highlighted) function addOptionEntry(%optionObj) { + OptionsMenu.optsListCount++; if(!isObject(%optionObj) || (%optionObj.class !$= "OptionsSettings" && %optionObj.class !$= "AudioOptionsSettings")) { error("addOptionsEntry() - attempting to create a new options entry, but was provided an invalid options object"); @@ -818,6 +821,7 @@ function addOptionEntry(%optionObj) class = "OptionsListEntry"; optionsObject = %optionObj; currentOptionIndex = %qualityLevelIndex; + selectionID = OptionsMenu.optsListCount; canSave = "0"; new GuiButtonCtrl() { @@ -862,6 +866,7 @@ function addOptionEntry(%optionObj) text = "<"; profile = GuiMenuButtonProfile; internalName = "prevValButton"; + command = "$MenuList.listPosition = $thisControl.getParent().getParent().selectionID; OptionMenuPrevSetting(1);"; }; new GuiTextCtrl() { @@ -881,6 +886,7 @@ function addOptionEntry(%optionObj) text = ">"; profile = GuiMenuButtonProfile; internalName = "nextValButton"; + command = "$MenuList.listPosition = $thisControl.getParent().getParent().selectionID; OptionMenuNextSetting(1);"; }; }; }; @@ -890,6 +896,7 @@ function addOptionEntry(%optionObj) function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %sliderMax, %sliderTicks) { + OptionsMenu.optsListCount++; %currentVal = getVariable(%prefName); %tempVarName = %prefName @ "_tempVar"; From 2fee2902f62b41b9135217e5cbaadc82c08c5b3a Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 4 Jan 2024 12:07:57 -0600 Subject: [PATCH 16/19] don't automatically set the server password --- Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index 3b43eb163..89648cacf 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -240,7 +240,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiTextEditCtrl() { - text = "Torque 3D Server"; + text = ""; position = "606 4"; extent = "295 22"; horizSizing = "left"; From e4342079f14339e1ccc7cb3933e06c6c611d0260 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 4 Jan 2024 12:55:07 -0600 Subject: [PATCH 17/19] function ChooseLevelMenu::fillPrefEntries( %this ) utility method to set gui elements to prefs --- .../BaseGame/game/data/UI/guis/ChooseLevelMenu.gui | 12 ++++++------ .../game/data/UI/guis/ChooseLevelMenu.tscript | 10 ++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index 89648cacf..fb98ec6e9 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -187,7 +187,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "MenuMLSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextEditCtrl() { + new GuiTextEditCtrl(playerNameCTRL) { text = "Visitor"; position = "606 4"; extent = "295 22"; @@ -213,8 +213,8 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "MenuMLSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextEditCtrl() { - text = "Torque 3D Server"; + new GuiTextEditCtrl(serverNameCTRL) { + text = ""; position = "606 4"; extent = "295 22"; horizSizing = "left"; @@ -239,7 +239,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "MenuMLSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextEditCtrl() { + new GuiTextEditCtrl(serverPassCTRL) { text = ""; position = "606 4"; extent = "295 22"; @@ -265,7 +265,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "MenuMLSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextEditCtrl() { + new GuiTextEditCtrl(serverInfoCTRL) { text = "This is a Torque 3D server."; position = "606 4"; extent = "295 22"; @@ -291,7 +291,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { profile = "MenuMLSubHeaderText"; tooltipProfile = "GuiToolTipProfile"; }; - new GuiTextEditCtrl(JoinServerPlayerNameTxt) { + new GuiTextEditCtrl(serverMaxPlayersCTRL) { text = "64"; position = "606 4"; extent = "295 22"; diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index c64222332..b11a3a062 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -26,6 +26,16 @@ function ChooseLevelMenu::onAdd( %this ) new AssetQuery(ChooseLevelAssetQuery); %this.previewButtonSize = "445 120"; + %this.fillPrefEntries(); +} + +function ChooseLevelMenu::fillPrefEntries( %this ) +{ + serverNameCTRL.setText($Pref::Player::Name); + serverNameCTRL.setText($Pref::Server::Name); + serverPassCTRL.setText($Pref::Server::Password); + serverInfoCTRL.setText($Pref::Server::Info); + serverMaxPlayersCTRL.setText($Pref::Server::MaxPlayers); } function ChooseLevelMenu::onWake(%this) From f4491f82021215170b9234ad251b772e5d4da3ab Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 4 Jan 2024 13:10:17 -0600 Subject: [PATCH 18/19] typofix. also, repopulate pref GuiTextEditCtrl each onWake just to be sure --- Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index b11a3a062..6d22b40d4 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -26,12 +26,11 @@ function ChooseLevelMenu::onAdd( %this ) new AssetQuery(ChooseLevelAssetQuery); %this.previewButtonSize = "445 120"; - %this.fillPrefEntries(); } function ChooseLevelMenu::fillPrefEntries( %this ) { - serverNameCTRL.setText($Pref::Player::Name); + playerNameCTRL.setText($Pref::Player::Name); serverNameCTRL.setText($Pref::Server::Name); serverPassCTRL.setText($Pref::Server::Password); serverInfoCTRL.setText($Pref::Server::Info); @@ -40,6 +39,7 @@ function ChooseLevelMenu::fillPrefEntries( %this ) function ChooseLevelMenu::onWake(%this) { + %this.fillPrefEntries(); LevelPreviewArray.clear(); ChooseLevelAssetQuery.clear(); From 833d17ccfcf1d75c61425609c7c5e00b67412d81 Mon Sep 17 00:00:00 2001 From: Areloch Date: Thu, 4 Jan 2024 20:30:11 -0600 Subject: [PATCH 19/19] - Cleaned up elements in ChooseLevelMenu and ensured onscreen button had correct command - Ensured there's always a level selected by default on the chooseLevelMenu - Added a small delay to try and ensure the level/server config tab key hints align properly - Added logic so you can't swap to server config page on chooseLevelMenu if in single player mode - Added server description to server details line on JoinServerMenu - Ensured programmatically added elements aren't saved out if GUIs are edited - Fixed back-out prompt in OptionsMenu properly backs out so it doesn't break menu nav --- .../game/data/UI/guis/ChooseLevelMenu.gui | 6 +++--- .../game/data/UI/guis/ChooseLevelMenu.tscript | 16 +++++++++------- .../BaseGame/game/data/UI/guis/GameMenu.tscript | 1 + .../game/data/UI/guis/joinServerMenu.tscript | 3 ++- .../game/data/UI/guis/optionsMenu.tscript | 13 ++++++------- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui index fb98ec6e9..15ad905d0 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.gui @@ -120,7 +120,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { }; }; new GuiBitmapCtrl(LevelPreviewBitmap) { - BitmapAsset = "testMaps:EmptyLevel_preview_image"; + BitmapAsset = ""; position = "448 0"; extent = "440 440"; horizSizing = "left"; @@ -128,7 +128,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { tooltipProfile = "GuiToolTipProfile"; }; new GuiTextCtrl(LevelNameText) { - text = "EmptyLevel"; + text = ""; position = "448 445"; extent = "440 20"; horizSizing = "left"; @@ -324,7 +324,7 @@ $guiContent = new GuiControl(ChooseLevelMenu) { horizSizing = "left"; vertSizing = "center"; profile = "GuiMenuButtonProfile"; - command = "OptionsMenu.applySettings();"; + command = "ChooseLevelBegin(1);"; tooltipProfile = "GuiToolTipProfile"; }; new GuiIconButtonCtrl(ChooseLevelBackBtn) { diff --git a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript index 6d22b40d4..970ff0f87 100644 --- a/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/ChooseLevelMenu.tscript @@ -103,6 +103,8 @@ function ChooseLevelMenu::onWake(%this) LevelPreviewArray.add(%preview); } + LevelPreviewArray.listPosition = 0; + // Also add the new level mission as defined in the world editor settings // if we are choosing a level to launch in the editor. if ( %this.launchInEditor ) @@ -115,7 +117,10 @@ function ChooseLevelMenu::onWake(%this) else ChooseLevelTitleText.setText("CREATE SERVER"); - %this.openMenu(0); + ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer; + ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer; + + %this.schedule(32, openMenu, 0); } if(!isObject( ChooseLevelActionMap ) ) @@ -144,7 +149,7 @@ function ChooseLevelMenu::syncGUI(%this) %btn.setHighlighted(true); %buttonPosX = %btn.position.x + ChooseLevelMenuTabList.position.x; - + ChooseLevelMenuPrevNavIcon.position.x = %buttonPosX; ChooseLevelMenuNextNavIcon.position.x = %buttonPosX + %btn.extent.x - 40; @@ -154,9 +159,6 @@ function ChooseLevelMenu::syncGUI(%this) ChooseLevelMenuPrevNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuPrevMenu")); ChooseLevelMenuNextNavIcon.setBitmap(ChooseLevelActionMap.getCommandButtonBitmap(%device, "ChooseLevelMenuNextMenu")); - - ChooseLevelMenuTabList.visible = $pref::HostMultiPlayer; - ChooseLevelMenuNavButtonOverlay.visible = $pref::HostMultiPlayer; } function LevelPreviewArray::syncGUI(%this) @@ -169,7 +171,7 @@ function LevelPreviewArray::syncGUI(%this) function ChooseLevelMenuPrevMenu(%val) { - if(%val) + if(%val && $pref::HostMultiPlayer) { %currentIdx = ChooseLevelMenu.currentMenuIdx; ChooseLevelMenu.currentMenuIdx -= 1; @@ -185,7 +187,7 @@ function ChooseLevelMenuPrevMenu(%val) function ChooseLevelMenuNextMenu(%val) { - if(%val) + if(%val && $pref::HostMultiPlayer) { %currentIdx = ChooseLevelMenu.currentMenuIdx; ChooseLevelMenu.currentMenuIdx += 1; diff --git a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript index 23a86e491..58f9fd145 100644 --- a/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/GameMenu.tscript @@ -33,6 +33,7 @@ function GameMenu::onWake(%this) text = %buttonText; class = "GameMenuButton"; command = "GameMenu.openGameMenu(\"" @ %buttonText @ "\");"; + canSave = false; }; %stackWidth += %textWidth + 40; diff --git a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript index a0f5f38a9..24aad2152 100644 --- a/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/joinServerMenu.tscript @@ -116,7 +116,7 @@ function JoinServerMenu::update(%this) %serverEntry = %this.addServerEntry(); %serverEntry-->serverNameTxt.text = $ServerInfo::Name; - %serverEntry-->serverDetailsTxt.text = $ServerInfo::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $ServerInfo::MissionType; + %serverEntry-->serverDetailsTxt.text = $ServerInfo::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $ServerInfo::MissionType @ " | " @ $ServerInfo::Info; %serverEntry-->pingTxt.text = $ServerInfo::Ping @ " ms"; %serverEntry-->playerCountTxt.text = $ServerInfo::PlayerCount @ "|" @ $ServerInfo::MaxPlayers; @@ -165,6 +165,7 @@ function JoinServerMenu::addServerEntry(%this) horizSizing = "width"; vertSizing = "bottom"; class = "JoinServerServerEntry"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index f297b1159..44321630a 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -688,7 +688,7 @@ function tryCloseOptionsMenu(%val) if(%unappliedVideoChanges || %unappliedAudioChanges) { MessageBoxOKCancel("Discard Changes?", "You have unapplied changes to your settings, do you wish to apply or discard them?", - "OptionsMenu.applyChangedOptions();", "Canvas.popDialog(OptionsMenu);", + "OptionsMenu.applyChangedOptions(); BaseUIBackOut(1);", "BaseUIBackOut(1);", "Apply", "Discard"); } else @@ -732,9 +732,7 @@ function OptionsMenu::applyChangedOptions(%this) //Finally, write our prefs to file %prefPath = getPrefpath(); export("$pref::*", %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension, false); - - BaseUIBackOut(1); - + if($optionsChangeRequiresRestart) MessageBoxOK("Restart Required", "Some of your changes require the game to be restarted."); } @@ -767,6 +765,7 @@ function addOptionGroup(%displayName) extent = "500 45"; profile = "MenuHeaderText"; tooltipProfile = "GuiToolTipProfile"; + canSave = false; }; return %group; @@ -822,7 +821,7 @@ function addOptionEntry(%optionObj) optionsObject = %optionObj; currentOptionIndex = %qualityLevelIndex; selectionID = OptionsMenu.optsListCount; - canSave = "0"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -918,7 +917,7 @@ function addOptionSlider(%optionName, %optionDesc, %prefName, %sliderMin, %slide horizSizing = "width"; vertSizing = "bottom"; class = "OptionsListSliderEntry"; - canSave = "0"; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile; @@ -1012,11 +1011,11 @@ function addActionMapEntry(%actionMap, %device, %keyMap, %index, %description) horizSizing = "width"; vertSizing = "bottom"; class = "OptionsKeybindEntry"; - canSave = "0"; actionMap = %actionMap; device = %device; keymap = %keyMap; remapIndex = %index; + canSave = false; new GuiButtonCtrl() { profile = GuiMenuButtonProfile;