Added support for keyboard scrolling

This commit is contained in:
unknown
2010-05-29 00:50:12 +02:00
committed by Chris Forbes
parent b45c74fa0b
commit f2bcf1afae
2 changed files with 370 additions and 321 deletions

View File

@@ -1,41 +1,41 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Server;
using OpenRA.Support;
using OpenRA.Traits;
using OpenRA.Widgets;
using Timer = OpenRA.Support.Timer;
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using OpenRA.FileFormats;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Server;
using OpenRA.Support;
using OpenRA.Traits;
using OpenRA.Widgets;
using Timer = OpenRA.Support.Timer;
using XRandom = OpenRA.Thirdparty.Random;
namespace OpenRA
@@ -64,6 +64,11 @@ namespace OpenRA
static bool mapChangePending;
static Pair<Assembly, string>[] ModAssemblies;
static internal bool scrollUp = false;
static internal bool scrollDown = false;
static internal bool scrollLeft = false;
static internal bool scrollRight = false;
static void LoadModPackages(Manifest manifest)
{
FileSystem.UnmountAll();
@@ -308,6 +313,15 @@ namespace OpenRA
}
}
if (scrollUp == true)
viewport.Scroll(new float2(0, -10));
if (scrollRight == true)
viewport.Scroll(new float2(10, 0));
if (scrollDown == true)
viewport.Scroll(new float2(0, 10));
if (scrollLeft == true)
viewport.Scroll(new float2(-10, 0));
using (new PerfSample("render"))
{
++RenderFrame;
@@ -408,7 +422,7 @@ namespace OpenRA
public static Stance ChooseInitialStance(Player p, Player q)
{
if (p == q) return Stance.Ally;
// Hack: All map players are neutral wrt everyone else
if (p.Index < 0 || q.Index < 0) return Stance.Neutral;
@@ -465,18 +479,18 @@ namespace OpenRA
get { return LobbyInfo.Clients.FirstOrDefault(c => c.Index == orderManager.Connection.LocalClientId); }
}
static Dictionary<char, char> RemapKeys = new Dictionary<char, char>
{
{ '!', '1' },
{ '@', '2' },
{ '#', '3' },
{ '$', '4' },
{ '%', '5' },
{ '^', '6' },
{ '&', '7' },
{ '*', '8' },
{ '(', '9' },
{ ')', '0' },
static Dictionary<char, char> RemapKeys = new Dictionary<char, char>
{
{ '!', '1' },
{ '@', '2' },
{ '#', '3' },
{ '$', '4' },
{ '%', '5' },
{ '^', '6' },
{ '&', '7' },
{ '*', '8' },
{ '(', '9' },
{ ')', '0' },
};
public static void HandleKeyPress(KeyPressEventArgs e, Modifiers modifiers)
@@ -511,6 +525,26 @@ namespace OpenRA
throw new InvalidOperationException("Desync in OnKeyPress");
}
public static void HandleArrowKeyScroll(String k, Boolean pressed)
{
if (k == "up")
{
scrollUp = pressed;
}
if (k == "left")
{
scrollLeft = pressed;
}
if (k == "down")
{
scrollDown = pressed;
}
if (k == "right")
{
scrollRight = pressed;
}
}
public static void HandleModifierKeys(Modifiers mods)
{
controller.SetModifiers(mods);
@@ -604,4 +638,4 @@ namespace OpenRA
Chrome.rootWidget.OpenWindow("MAINMENU_BG");
}
}
}
}