Add Edge Scroll setting
This commit is contained in:
@@ -19,6 +19,9 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
public class UserSettings
|
public class UserSettings
|
||||||
{
|
{
|
||||||
|
// Behaviour settings
|
||||||
|
public bool ViewportEdgeScroll = true;
|
||||||
|
|
||||||
// Debug settings
|
// Debug settings
|
||||||
public bool PerfDebug = false;
|
public bool PerfDebug = false;
|
||||||
public bool RecordSyncReports = true;
|
public bool RecordSyncReports = true;
|
||||||
|
|||||||
@@ -46,6 +46,14 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
};
|
};
|
||||||
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
name.OnEnterKey = () => { name.LoseFocus(); return true; };
|
||||||
|
|
||||||
|
var edgeScroll = general.GetWidget<CheckboxWidget>("EDGE_SCROLL");
|
||||||
|
edgeScroll.Checked = () => Game.Settings.ViewportEdgeScroll;
|
||||||
|
edgeScroll.OnMouseDown = mi =>
|
||||||
|
{
|
||||||
|
Game.Settings.ViewportEdgeScroll ^= true;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
var audio = bg.GetWidget("AUDIO_PANE");
|
var audio = bg.GetWidget("AUDIO_PANE");
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,11 @@ namespace OpenRA.Widgets
|
|||||||
Down = 4,
|
Down = 4,
|
||||||
Right = 8
|
Right = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewportScrollControllerWidget : Widget
|
class ViewportScrollControllerWidget : Widget
|
||||||
{
|
{
|
||||||
public int EdgeScrollThreshold = 15;
|
public int EdgeScrollThreshold = 15;
|
||||||
public bool EdgeScroll = true;
|
|
||||||
public bool KeyboardScroll = true;
|
|
||||||
public bool MouseScroll = true;
|
|
||||||
|
|
||||||
ScrollDirection Keyboard;
|
ScrollDirection Keyboard;
|
||||||
ScrollDirection Edge;
|
ScrollDirection Edge;
|
||||||
|
|
||||||
@@ -43,10 +40,7 @@ namespace OpenRA.Widgets
|
|||||||
public override void DrawInner( World world ) {}
|
public override void DrawInner( World world ) {}
|
||||||
|
|
||||||
public override bool HandleInputInner(MouseInput mi)
|
public override bool HandleInputInner(MouseInput mi)
|
||||||
{
|
{
|
||||||
if (!MouseScroll)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mi.Event == MouseInputEvent.Move &&
|
if (mi.Event == MouseInputEvent.Move &&
|
||||||
(mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right)))
|
(mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right)))
|
||||||
{
|
{
|
||||||
@@ -58,7 +52,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
if (!EdgeScroll)
|
if (!Game.Settings.ViewportEdgeScroll)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left))
|
if (Edge.Includes(ScrollDirection.Up) && Edge.Includes(ScrollDirection.Left))
|
||||||
@@ -89,10 +83,7 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandleKeyPressInner(KeyInput e)
|
public override bool HandleKeyPressInner(KeyInput e)
|
||||||
{
|
{
|
||||||
if (!KeyboardScroll)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
switch (e.KeyName)
|
switch (e.KeyName)
|
||||||
{
|
{
|
||||||
case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true;
|
case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true;
|
||||||
@@ -106,7 +97,7 @@ namespace OpenRA.Widgets
|
|||||||
public override void Tick(World world)
|
public override void Tick(World world)
|
||||||
{
|
{
|
||||||
Edge = ScrollDirection.None;
|
Edge = ScrollDirection.None;
|
||||||
if (EdgeScroll)
|
if (Game.Settings.ViewportEdgeScroll)
|
||||||
{
|
{
|
||||||
// Check for edge-scroll
|
// Check for edge-scroll
|
||||||
if (Widget.LastMousePos.X < EdgeScrollThreshold)
|
if (Widget.LastMousePos.X < EdgeScrollThreshold)
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ Container@ROOT:
|
|||||||
X:90
|
X:90
|
||||||
Y:0
|
Y:0
|
||||||
MaxLength:16
|
MaxLength:16
|
||||||
|
Checkbox@EDGE_SCROLL:
|
||||||
|
Id:EDGE_SCROLL
|
||||||
|
X:0
|
||||||
|
Y:30
|
||||||
|
Width:200
|
||||||
|
Height:20
|
||||||
|
Text: Enable Edge Scrolling
|
||||||
Container@AUDIO_PANE:
|
Container@AUDIO_PANE:
|
||||||
Id:AUDIO_PANE
|
Id:AUDIO_PANE
|
||||||
X:37
|
X:37
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ Container@ROOT:
|
|||||||
X:90
|
X:90
|
||||||
Y:0
|
Y:0
|
||||||
MaxLength:16
|
MaxLength:16
|
||||||
|
Checkbox@EDGE_SCROLL:
|
||||||
|
Id:EDGE_SCROLL
|
||||||
|
X:0
|
||||||
|
Y:30
|
||||||
|
Width:200
|
||||||
|
Height:20
|
||||||
|
Text: Enable Edge Scrolling
|
||||||
Container@AUDIO_PANE:
|
Container@AUDIO_PANE:
|
||||||
Id:AUDIO_PANE
|
Id:AUDIO_PANE
|
||||||
X:37
|
X:37
|
||||||
|
|||||||
Reference in New Issue
Block a user