Initial settings menu copied from the old impl.
This commit is contained in:
@@ -84,6 +84,7 @@
|
||||
<Compile Include="CncColorPickerPaletteModifier.cs" />
|
||||
<Compile Include="Widgets\CncModBrowserLogic.cs" />
|
||||
<Compile Include="Widgets\CncPerfDebugLogic.cs" />
|
||||
<Compile Include="Widgets\CncSettingsLogic.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
var doNothing = (Action)(() => {});
|
||||
|
||||
menu.GetWidget<CncMenuButtonWidget>("QUIT_BUTTON").OnClick = () =>
|
||||
PromptConfirmAction("Exit Game", "Are you sure you want to leave the game?", onQuit, doNothing);
|
||||
PromptConfirmAction("Quit", "Are you sure you want to quit?", onQuit, doNothing);
|
||||
|
||||
var onSurrender = (Action)(() => world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false)));
|
||||
var surrenderButton = menu.GetWidget<CncMenuButtonWidget>("SURRENDER_BUTTON");
|
||||
@@ -120,7 +120,14 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
});
|
||||
};
|
||||
|
||||
menu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").IsDisabled = () => true;
|
||||
menu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () =>
|
||||
{
|
||||
hideButtons = true;
|
||||
Widget.OpenWindow("SETTINGS_PANEL", new Dictionary<string, object>()
|
||||
{
|
||||
{ "onExit", new Action(() => hideButtons = false) },
|
||||
});
|
||||
};
|
||||
|
||||
menu.GetWidget<CncMenuButtonWidget>("RESUME_BUTTON").OnClick = () =>
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
@@ -117,7 +118,14 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
});
|
||||
};
|
||||
|
||||
settingsMenu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").IsDisabled = () => true;
|
||||
settingsMenu.GetWidget<CncMenuButtonWidget>("PREFERENCES_BUTTON").OnClick = () =>
|
||||
{
|
||||
Menu = MenuType.None;
|
||||
Widget.OpenWindow("SETTINGS_PANEL", new Dictionary<string, object>()
|
||||
{
|
||||
{ "onExit", new Action(() => ReturnToMenu(MenuType.Settings)) },
|
||||
});
|
||||
};
|
||||
settingsMenu.GetWidget<CncMenuButtonWidget>("BACK_BUTTON").OnClick = () => Menu = MenuType.Main;
|
||||
}
|
||||
|
||||
|
||||
149
OpenRA.Mods.Cnc/Widgets/CncSettingsLogic.cs
Executable file
149
OpenRA.Mods.Cnc/Widgets/CncSettingsLogic.cs
Executable file
@@ -0,0 +1,149 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public class CncSettingsLogic : IWidgetDelegate
|
||||
{
|
||||
Widget bg;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public CncSettingsLogic([ObjectCreator.Param] Widget widget,
|
||||
[ObjectCreator.Param] Action onExit)
|
||||
{
|
||||
bg = widget.GetWidget("SETTINGS_PANEL");
|
||||
var tabs = bg.GetWidget<ContainerWidget>("TAB_CONTAINER");
|
||||
|
||||
//Tabs
|
||||
tabs.GetWidget<ButtonWidget>("GENERAL").OnMouseUp = mi => FlipToTab("GENERAL_PANE");
|
||||
tabs.GetWidget<ButtonWidget>("AUDIO").OnMouseUp = mi => FlipToTab("AUDIO_PANE");
|
||||
tabs.GetWidget<ButtonWidget>("DISPLAY").OnMouseUp = mi => FlipToTab("DISPLAY_PANE");
|
||||
tabs.GetWidget<ButtonWidget>("DEBUG").OnMouseUp = mi => FlipToTab("DEBUG_PANE");
|
||||
FlipToTab("GENERAL_PANE");
|
||||
|
||||
//General
|
||||
var general = bg.GetWidget("GENERAL_PANE");
|
||||
|
||||
var name = general.GetWidget<TextFieldWidget>("NAME");
|
||||
name.Text = Game.Settings.Player.Name;
|
||||
name.OnLoseFocus = () =>
|
||||
{
|
||||
name.Text = name.Text.Trim();
|
||||
|
||||
if (name.Text.Length == 0)
|
||||
name.Text = Game.Settings.Player.Name;
|
||||
else
|
||||
Game.Settings.Player.Name = name.Text;
|
||||
};
|
||||
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
||||
|
||||
general.GetWidget<CheckboxWidget>("EDGE_SCROLL").Bind(Game.Settings.Game, "ViewportEdgeScroll");
|
||||
|
||||
// Added scroll sensitivity - Gecko
|
||||
var edgeScrollSlider = general.GetWidget<SliderWidget>("EDGE_SCROLL_AMOUNT");
|
||||
if (edgeScrollSlider != null) // Backwards compatible - Gecko
|
||||
{
|
||||
edgeScrollSlider.SetOffset(Game.Settings.Game.ViewportEdgeScrollStep);
|
||||
edgeScrollSlider.OnChange += _ => { Game.Settings.Game.ViewportEdgeScrollStep = edgeScrollSlider.GetOffset(); };
|
||||
Game.Settings.Game.ViewportEdgeScrollStep = edgeScrollSlider.GetOffset();
|
||||
}
|
||||
|
||||
general.GetWidget<CheckboxWidget>("INVERSE_SCROLL").Bind(Game.Settings.Game, "InverseDragScroll");
|
||||
general.GetWidget<CheckboxWidget>("TEAMCHAT_TOGGLE").Bind(Game.Settings.Game, "TeamChatToggle");
|
||||
|
||||
|
||||
// Audio
|
||||
var audio = bg.GetWidget("AUDIO_PANE");
|
||||
|
||||
var soundslider = audio.GetWidget<SliderWidget>("SOUND_VOLUME");
|
||||
soundslider.OnChange += x => { Sound.SoundVolume = x; };
|
||||
soundslider.GetOffset = () => { return Sound.SoundVolume; };
|
||||
soundslider.SetOffset(Sound.SoundVolume);
|
||||
|
||||
var musicslider = audio.GetWidget<SliderWidget>("MUSIC_VOLUME");
|
||||
musicslider.OnChange += x => { Sound.MusicVolume = x; };
|
||||
musicslider.GetOffset = () => { return Sound.MusicVolume; };
|
||||
musicslider.SetOffset(Sound.MusicVolume);
|
||||
|
||||
|
||||
// Display
|
||||
var display = bg.GetWidget("DISPLAY_PANE");
|
||||
display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX").Bind(Game.Settings.Game, "TeamChatToggle");
|
||||
|
||||
var fullscreen = display.GetWidget<CheckboxWidget>("FULLSCREEN_CHECKBOX");
|
||||
fullscreen.IsChecked = () => Game.Settings.Graphics.Mode != WindowMode.Windowed;
|
||||
fullscreen.OnChange += c => Game.Settings.Graphics.Mode = (Game.Settings.Graphics.Mode == WindowMode.Windowed) ? WindowMode.PseudoFullscreen : WindowMode.Windowed;
|
||||
|
||||
var width = display.GetWidget<TextFieldWidget>("SCREEN_WIDTH");
|
||||
Game.Settings.Graphics.WindowedSize.X = (Game.Settings.Graphics.WindowedSize.X < Game.Settings.Graphics.MinResolution.X)?
|
||||
Game.Settings.Graphics.MinResolution.X : Game.Settings.Graphics.WindowedSize.X;
|
||||
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||
width.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var w = int.Parse(width.Text);
|
||||
if (w > Game.Settings.Graphics.MinResolution.X)
|
||||
Game.Settings.Graphics.WindowedSize = new int2(w, Game.Settings.Graphics.WindowedSize.Y);
|
||||
}
|
||||
catch (FormatException) {
|
||||
width.Text = Game.Settings.Graphics.WindowedSize.X.ToString();
|
||||
}
|
||||
};
|
||||
width.OnEnterKey = () => { width.LoseFocus(); return true; };
|
||||
|
||||
var height = display.GetWidget<TextFieldWidget>("SCREEN_HEIGHT");
|
||||
Game.Settings.Graphics.WindowedSize.Y = (Game.Settings.Graphics.WindowedSize.Y < Game.Settings.Graphics.MinResolution.Y)?
|
||||
Game.Settings.Graphics.MinResolution.Y : Game.Settings.Graphics.WindowedSize.Y;
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
height.OnLoseFocus = () =>
|
||||
{
|
||||
try {
|
||||
var h = int.Parse(height.Text);
|
||||
if (h > Game.Settings.Graphics.MinResolution.Y)
|
||||
Game.Settings.Graphics.WindowedSize = new int2(Game.Settings.Graphics.WindowedSize.X, h);
|
||||
else
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
}
|
||||
catch (FormatException) {
|
||||
height.Text = Game.Settings.Graphics.WindowedSize.Y.ToString();
|
||||
}
|
||||
};
|
||||
height.OnEnterKey = () => { height.LoseFocus(); return true; };
|
||||
|
||||
// Debug
|
||||
var debug = bg.GetWidget("DEBUG_PANE");
|
||||
debug.GetWidget<CheckboxWidget>("PERFDEBUG_CHECKBOX").Bind(Game.Settings.Debug, "PerfGraph");
|
||||
debug.GetWidget<CheckboxWidget>("GAMETIME_CHECKBOX").Bind(Game.Settings.Game, "MatchTimer");
|
||||
debug.GetWidget<CheckboxWidget>("CHECKUNSYNCED_CHECKBOX").Bind(Game.Settings.Debug, "SanityCheckUnsyncedCode");
|
||||
|
||||
bg.GetWidget<CncMenuButtonWidget>("BUTTON_CLOSE").OnClick = () => {
|
||||
Game.Settings.Save();
|
||||
Widget.CloseWindow();
|
||||
onExit();
|
||||
};
|
||||
}
|
||||
|
||||
string open = null;
|
||||
bool FlipToTab(string id)
|
||||
{
|
||||
if (open != null)
|
||||
bg.GetWidget(open).Visible = false;
|
||||
|
||||
open = id;
|
||||
bg.GetWidget(open).Visible = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ Container@INGAME_MENU:
|
||||
Y:0
|
||||
Width:140
|
||||
Height:35
|
||||
Text:Exit Game
|
||||
Text:Quit
|
||||
CncMenuButton@SURRENDER_BUTTON:
|
||||
Id:SURRENDER_BUTTON
|
||||
X:150
|
||||
|
||||
226
mods/cnc/chrome/preferences.yaml
Normal file
226
mods/cnc/chrome/preferences.yaml
Normal file
@@ -0,0 +1,226 @@
|
||||
Background@SETTINGS_PANEL:
|
||||
Id:SETTINGS_PANEL
|
||||
Delegate:CncSettingsLogic
|
||||
X:(WINDOW_RIGHT - WIDTH)/2
|
||||
Y:(WINDOW_BOTTOM- HEIGHT)/2
|
||||
Width: 450
|
||||
Height: 350
|
||||
Children:
|
||||
Label@SETTINGS_LABEL_TITLE:
|
||||
Id:SETTINGS_LABEL_TITLE
|
||||
X:0
|
||||
Y:20
|
||||
Width:450
|
||||
Height:25
|
||||
Text:Settings
|
||||
Align:Center
|
||||
Bold:True
|
||||
CncMenuButton@BUTTON_CLOSE:
|
||||
Id:BUTTON_CLOSE
|
||||
X:PARENT_RIGHT - 180
|
||||
Y:PARENT_BOTTOM - 45
|
||||
Width:160
|
||||
Height:25
|
||||
Text:Close
|
||||
Bold:True
|
||||
Container@TAB_CONTAINER:
|
||||
Id:TAB_CONTAINER
|
||||
X:0
|
||||
Y:50
|
||||
Width:PARENT_RIGHT
|
||||
Height:25
|
||||
Children:
|
||||
Button@GENERAL:
|
||||
Id:GENERAL
|
||||
X:45
|
||||
Y:0
|
||||
Width:90
|
||||
Height:25
|
||||
Text:General
|
||||
Bold:True
|
||||
Button@AUDIO:
|
||||
Id:AUDIO
|
||||
X:135
|
||||
Y:0
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Audio
|
||||
Bold:True
|
||||
Button@DISPLAY:
|
||||
Id:DISPLAY
|
||||
X:225
|
||||
Y:0
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Display
|
||||
Bold:True
|
||||
Button@DEBUG:
|
||||
Id:DEBUG
|
||||
X:315
|
||||
Y:0
|
||||
Width:90
|
||||
Height:25
|
||||
Text:Debug
|
||||
Bold:True
|
||||
Container@GENERAL_PANE:
|
||||
Id:GENERAL_PANE
|
||||
X:37
|
||||
Y:100
|
||||
Width:PARENT_RIGHT - 37
|
||||
Height:PARENT_BOTTOM - 100
|
||||
Visible: true
|
||||
Children:
|
||||
Label@SETTINGS_PLAYER_NAME:
|
||||
Id:SETTINGS_PLAYER_NAME
|
||||
X:0
|
||||
Y:10
|
||||
Text: Player Name:
|
||||
TextField@NAME:
|
||||
Id:NAME
|
||||
Text:Name
|
||||
Width:139
|
||||
Height:25
|
||||
X:90
|
||||
Y:0
|
||||
MaxLength:16
|
||||
Checkbox@EDGE_SCROLL:
|
||||
Id:EDGE_SCROLL
|
||||
X:0
|
||||
Y:30
|
||||
Width:200
|
||||
Height:20
|
||||
Text: Enable Edge Scrolling
|
||||
Label@EDGE_SCROLL_AMOUNT_LABEL:
|
||||
Id:EDGE_SCROLL_AMOUNT_LABEL
|
||||
X:0
|
||||
Y:70
|
||||
Text: Scroll Speed
|
||||
Slider@EDGE_SCROLL_AMOUNT:
|
||||
Id:EDGE_SCROLL_AMOUNT
|
||||
X:130
|
||||
Y:60
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Range:10,50
|
||||
Checkbox@INVERSE_SCROLL:
|
||||
Id:INVERSE_SCROLL
|
||||
X:0
|
||||
Y:90
|
||||
Width:200
|
||||
Height:20
|
||||
Text: Invert Mouse Drag Scrolling
|
||||
Checkbox@TEAMCHAT_TOGGLE:
|
||||
Id:TEAMCHAT_TOGGLE
|
||||
X:0
|
||||
Y:120
|
||||
Width:200
|
||||
Height:20
|
||||
Text: Shift-Enter Toggles Team Chat
|
||||
Container@AUDIO_PANE:
|
||||
Id:AUDIO_PANE
|
||||
X:37
|
||||
Y:100
|
||||
Width:PARENT_RIGHT - 37
|
||||
Height:PARENT_BOTTOM - 100
|
||||
Visible: false
|
||||
Children:
|
||||
Label@SOUND_VOLUME_LABEL:
|
||||
Id:SOUND_VOLUME_LABEL
|
||||
X:0
|
||||
Y:10
|
||||
Text: Sound Volume
|
||||
Slider@SOUND_VOLUME:
|
||||
Id:SOUND_VOLUME
|
||||
X:100
|
||||
Y:0
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Label@MUSIC_VOLUME_LABEL:
|
||||
Id:MUSIC_VOLUME_LABEL
|
||||
X:0
|
||||
Y:40
|
||||
Text: Music Volume
|
||||
Slider@MUSIC_VOLUME:
|
||||
Id:MUSIC_VOLUME
|
||||
X:100
|
||||
Y:30
|
||||
Width:250
|
||||
Height:20
|
||||
Ticks:5
|
||||
Container@DISPLAY_PANE:
|
||||
Id:DISPLAY_PANE
|
||||
X:37
|
||||
Y:100
|
||||
Width:PARENT_RIGHT - 37
|
||||
Height:PARENT_BOTTOM - 100
|
||||
Visible: false
|
||||
Children:
|
||||
Checkbox@FULLSCREEN_CHECKBOX:
|
||||
Id:FULLSCREEN_CHECKBOX
|
||||
X:0
|
||||
Y:0
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Fullscreen
|
||||
Label@RESOLUTION_LABEL:
|
||||
Id:RESOLUTION_LABEL
|
||||
X:0
|
||||
Y:50
|
||||
Text: Window Resolution:
|
||||
TextField@SCREEN_WIDTH:
|
||||
Id:SCREEN_WIDTH
|
||||
Text:Width
|
||||
Width:50
|
||||
Height:25
|
||||
X:130
|
||||
Y:40
|
||||
MaxLength:5
|
||||
Label@X:
|
||||
Id:X
|
||||
Text:x
|
||||
X:185
|
||||
Y:50
|
||||
TextField@SCREEN_HEIGHT:
|
||||
Id:SCREEN_HEIGHT
|
||||
Text:Height
|
||||
Width:50
|
||||
Height:25
|
||||
X:195
|
||||
Y:40
|
||||
MaxLength:5
|
||||
Label@RESTART:
|
||||
Id:RESTART
|
||||
Text: Restart Game To Apply Changes
|
||||
X:0
|
||||
Y:PARENT_BOTTOM - 30
|
||||
Container@DEBUG_PANE:
|
||||
Id:DEBUG_PANE
|
||||
X:37
|
||||
Y:100
|
||||
Width:PARENT_RIGHT - 37
|
||||
Height:PARENT_BOTTOM - 100
|
||||
Visible: false
|
||||
Children:
|
||||
Checkbox@PERFDEBUG_CHECKBOX:
|
||||
Id:PERFDEBUG_CHECKBOX
|
||||
X:0
|
||||
Y:0
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Performance Information
|
||||
Checkbox@GAMETIME_CHECKBOX:
|
||||
Id:GAMETIME_CHECKBOX
|
||||
X:0
|
||||
Y:30
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Show Game Time Counter
|
||||
Checkbox@CHECKUNSYNCED_CHECKBOX:
|
||||
Id:CHECKUNSYNCED_CHECKBOX
|
||||
X:0
|
||||
Y:60
|
||||
Width:300
|
||||
Height:20
|
||||
Text:Check Sync around Unsynced Code
|
||||
@@ -74,6 +74,7 @@ ChromeLayout:
|
||||
mods/cnc/chrome/ingamemenu.yaml
|
||||
mods/cnc/chrome/music.yaml
|
||||
mods/cnc/chrome/modchooser.yaml
|
||||
mods/cnc/chrome/preferences.yaml
|
||||
|
||||
Weapons:
|
||||
mods/cnc/weapons.yaml
|
||||
|
||||
Reference in New Issue
Block a user