Merge pull request #938 from Areloch/OptionsAndRemappingFixes

Misc fixes for options and key remapping
This commit is contained in:
Brian Roberts 2022-12-16 01:26:12 -06:00 committed by GitHub
commit 7d02eea6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 114 deletions

View file

@ -817,16 +817,9 @@ void GuiGameSettingsCtrl::clickKeybind(S32 xPos)
S32 columnSplit = mColumnSplit; S32 columnSplit = mColumnSplit;
S32 height = getHeight(); S32 height = getHeight();
S32 width = getWidth();
Point2I button; RectI rect(Point2I::Zero, Point2I(width, height));
button.x = columnSplit + (columnSplit / 2.5)/* + (optionWidth / 2)*/;
button.y = 0;
Point2I buttonSize;
buttonSize.x = height;
buttonSize.y = height;
RectI rect(button, buttonSize);
onChange_callback(); onChange_callback();

View file

@ -828,7 +828,7 @@ function OptionsMenuSettingsList::addOptionRow(%this, %label, %targetPrefVar, %o
%enabled = true; %enabled = true;
%optionsRowSize = 30; %optionsRowSize = 30;
%optionColumnWidth = %this.extent.x * 0.3;//todo, calculate off longest option text? %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text?
%option = new GuiGameSettingsCtrl() { %option = new GuiGameSettingsCtrl() {
class = "MenuOptionsButton"; class = "MenuOptionsButton";
@ -936,7 +936,7 @@ function OptionsMenuSettingsList::addSliderRow(%this, %label, %targetPrefVar, %i
%enabled = true; %enabled = true;
%optionsRowSize = 30; %optionsRowSize = 30;
%optionColumnWidth = %this.extent.x - 450;//todo, calculate off longest option text? %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text?
%option = new GuiGameSettingsCtrl() { %option = new GuiGameSettingsCtrl() {
class = "MenuOptionsButton"; class = "MenuOptionsButton";
@ -965,7 +965,7 @@ function OptionsMenuSettingsList::addKeybindRow(%this, %label, %bitmapName, %cal
%enabled = true; %enabled = true;
%optionsRowSize = 40; %optionsRowSize = 40;
%optionColumnWidth = %this.extent.x - 450; %optionColumnWidth = %this.extent.x * 0.5;//todo, calculate off longest option text?
%option = new GuiGameSettingsCtrl() { %option = new GuiGameSettingsCtrl() {
class = "MenuOptionsButton"; class = "MenuOptionsButton";

View file

@ -1,121 +1,77 @@
//--- OBJECT WRITE BEGIN --- //--- OBJECT WRITE BEGIN ---
$guiContent = new GuiControl(RemapDlg) { $guiContent = new GuiControl(RemapDlg) {
position = "0 0";
extent = "1024 768"; extent = "1024 768";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile"; profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1"; isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1"; canSaveDynamicFields = "1";
helpTag = "0"; helpTag = "0";
new GuiContainer(RemapPanel) { new GuiContainer(RemapPanel) {
margin = "0 0 0 0"; position = "162 332";
padding = "0 0 0 0"; extent = "700 104";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "162 352";
extent = "700 64";
minExtent = "8 2";
horizSizing = "center"; horizSizing = "center";
vertSizing = "center"; vertSizing = "center";
profile = "GuiDefaultProfile"; profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
new GuiInputCtrl(OptRemapInputCtrl) { new GuiInputCtrl(OptRemapInputCtrl) {
lockMouse = "0";
position = "480 0"; position = "480 0";
extent = "64 64"; extent = "64 104";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "width"; horizSizing = "width";
vertSizing = "height"; vertSizing = "height";
profile = "GuiInputCtrlProfile"; profile = "GuiInputCtrlProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
}; };
new GuiChunkedBitmapCtrl() { new GuiControl(RemapBoxCtrl) {
bitmapAsset = "UI:hudfill_image"; position = "-1 1";
useVariable = "0"; extent = "701 102";
tile = "0"; horizSizing = "center";
position = "0 0"; vertSizing = "center";
extent = "700 64"; profile = "GuiDefaultProfile";
minExtent = "8 2"; tooltipProfile = "GuiToolTipProfile";
horizSizing = "right"; isContainer = "1";
vertSizing = "bottom";
new GuiBitmapBarCtrl() {
BitmapAsset = "UI:panel_image";
extent = "701 40";
horizSizing = "width";
profile = "GuiDefaultProfile";
tooltipProfile = "GuiToolTipProfile";
};
new GuiBitmapBarCtrl() {
BitmapAsset = "UI:panel_low_image";
position = "0 40";
extent = "701 341";
horizSizing = "width";
profile = "GuiDefaultProfile"; profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "0";
canSave = "1";
canSaveDynamicFields = "0";
}; };
new GuiTextCtrl() { new GuiTextCtrl() {
text = "Press escape to cancel"; text = "Press escape to cancel";
maxLength = "255"; maxLength = "255";
margin = "0 0 0 0"; position = "260 67";
padding = "0 0 0 0"; extent = "181 23";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "247 34";
extent = "242 20";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "width"; horizSizing = "width";
vertSizing = "height"; vertSizing = "height";
profile = "GuiMenuButtonProfile"; profile = "MenuMLSubHeaderTextCenter";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
}; };
new GuiTextCtrl() { new GuiTextCtrl() {
text = "Re-bind \"\" to..."; text = "Re-bind \"Forward\" to...";
maxLength = "255"; maxLength = "255";
margin = "0 0 0 0"; position = "259 40";
padding = "0 0 0 0"; extent = "184 23";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "177 8";
extent = "384 20";
minExtent = "8 8"; minExtent = "8 8";
horizSizing = "width"; horizSizing = "center";
vertSizing = "height"; vertSizing = "height";
profile = "GuiMenuButtonProfile"; profile = "MenuMLSubHeaderTextCenter";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile"; tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
internalName = "OptRemapText"; internalName = "OptRemapText";
canSave = "1"; };
canSaveDynamicFields = "0";
}; };
}; };
}; };

View file

@ -205,12 +205,13 @@ function controlSetChanged()
fillRemapList(); fillRemapList();
} }
function doKeyRemap( %rowIndex ) function doKeyRemap( %row )
{ {
%rowIndex = %row.getParent().getObjectIndex(%row);
%rowIndex--; //Offset the rowIndex to account for controlset option %rowIndex--; //Offset the rowIndex to account for controlset option
%name = $RemapName[%rowIndex]; %name = $RemapName[%rowIndex];
RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ;
OptRemapInputCtrl.index = %rowIndex; OptRemapInputCtrl.index = %rowIndex;
Canvas.pushDialog( RemapDlg ); Canvas.pushDialog( RemapDlg );
@ -223,7 +224,7 @@ function doKeyRemap( %rowIndex )
function ControlsMenuRebindButton::onClick(%this) function ControlsMenuRebindButton::onClick(%this)
{ {
%name = $RemapName[%this.keybindIndex]; %name = $RemapName[%this.keybindIndex];
RemapDlg-->OptRemapText.setValue( "Re-bind \"" @ %name @ "\" to..." ); RemapDlg-->OptRemapText.text = "Re-bind \"" @ %name @ "\" to..." ;
OptRemapInputCtrl.index = %this.keybindIndex; OptRemapInputCtrl.index = %this.keybindIndex;
OptRemapInputCtrl.optionIndex = %this.optionIndex; OptRemapInputCtrl.optionIndex = %this.optionIndex;
@ -305,16 +306,12 @@ function OptRemapInputCtrl::onInputEvent( %this, %device, %action )
%prevCmdName = $RemapName[%prevMapIndex]; %prevCmdName = $RemapName[%prevMapIndex];
Canvas.pushDialog( RemapConfirmDlg ); Canvas.pushDialog( RemapConfirmDlg );
RemapConfirmationText.setText("\"" @ %mapName @ "\" is already bound to \"" %remapWarnText = "\"" @ %mapName @ "\" is already bound to \"" @ %prevCmdName @ "\"! Do you wish to replace this mapping?";
@ %prevCmdName @ "\"! Do you wish to replace this mapping?"); %doRemapCommand = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
RemapConfirmationYesButton.command = "redoMapping(" @ %device @ ", " @ %actionMap @ ", \"" @ %action @ "\", \"" @
%cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ "); Canvas.popDialog();"; %cmd @ "\", " @ %prevMapIndex @ ", " @ %this.index @ "); Canvas.popDialog();";
RemapConfirmationNoButton.command = "Canvas.popDialog();"; %cancelCommand = "Canvas.popDialog();";
/*MessageBoxYesNo( "Warning", MessageBoxYesNo( "Key already in use", %remapWarnText, %doRemapCommand, %cancelCommand );
"\"" @ %mapName @ "\" is already bound to \""
@ %prevCmdName @ "\"!\nDo you wish to replace this mapping?",
%callback, "" );*/
} }
function findRemapCmdIndex( %command ) function findRemapCmdIndex( %command )

View file

@ -78,6 +78,11 @@ new GuiControlProfile(MenuMLSubHeaderText)
autoSizeHeight = true; autoSizeHeight = true;
}; };
new GuiControlProfile(MenuMLSubHeaderTextCenter : MenuMLSubHeaderText)
{
justify = "center";
};
if( !isObject( GuiMenuButtonProfile ) ) if( !isObject( GuiMenuButtonProfile ) )
new GuiControlProfile( GuiMenuButtonProfile ) new GuiControlProfile( GuiMenuButtonProfile )
{ {