[+] Added function for key scroll speed
This commit is contained in:
parent
dbf38df98d
commit
56092051f2
6 changed files with 46 additions and 17 deletions
|
@ -65,7 +65,7 @@
|
|||
#include "widgets.h"
|
||||
|
||||
|
||||
extern void DoScrollArea(int state, bool fast);
|
||||
extern void DoScrollArea(int state, bool fast, bool isKeyboard);
|
||||
extern void DrawGuichanWidgets();
|
||||
extern void CleanGame();
|
||||
|
||||
|
@ -1985,10 +1985,10 @@ void EditorMainLoop()
|
|||
// Map scrolling
|
||||
//
|
||||
if (UI.MouseScroll) {
|
||||
DoScrollArea(MouseScrollState, 0);
|
||||
DoScrollArea(MouseScrollState, 0, MouseScrollState == 0 && KeyScrollState > 0);
|
||||
}
|
||||
if (UI.KeyScroll) {
|
||||
DoScrollArea(KeyScrollState, (KeyModifiers & ModifierControl) != 0);
|
||||
DoScrollArea(KeyScrollState, (KeyModifiers & ModifierControl) != 0, MouseScrollState == 0 && KeyScrollState > 0);
|
||||
if (CursorOn == CursorOnMap && (MouseButtons & LeftButton) &&
|
||||
(Editor.State == EditorEditTile ||
|
||||
Editor.State == EditorEditUnit)) {
|
||||
|
|
|
@ -380,6 +380,8 @@ public:
|
|||
|
||||
bool MouseScroll; /// Enable mouse scrolling
|
||||
bool KeyScroll; /// Enable keyboard scrolling
|
||||
/// Key Scroll Speed
|
||||
int KeyScrollSpeed;
|
||||
/// Mouse Scroll Speed (screenpixels per mousepixel)
|
||||
int MouseScrollSpeed;
|
||||
/// Middle-Mouse Scroll Speed (screenpixels per mousepixel)
|
||||
|
|
|
@ -777,12 +777,12 @@ static void NetworkParseInGameEvent(const unsigned char *buf, int len, const CHo
|
|||
int player = packet.Header.OrigPlayer;
|
||||
if (player == 255) {
|
||||
const int index = FindHostIndexBy(host);
|
||||
if (index == -1 || PlayerQuit[Hosts[index].PlyNr]) {
|
||||
#ifdef DEBUG
|
||||
const std::string hostStr = host.toString();
|
||||
DebugPrint("Not a host in play: %s\n" _C_ hostStr.c_str());
|
||||
#endif
|
||||
return;
|
||||
if (index == -1 || PlayerQuit[Hosts[index].PlyNr]) {
|
||||
#ifdef DEBUG
|
||||
const std::string hostStr = host.toString();
|
||||
DebugPrint("Not a host in play: %s\n" _C_ hostStr.c_str());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
player = Hosts[index].PlyNr;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ EventCallback EditorCallbacks; /// Editor callbacks
|
|||
** @todo Support dynamic acceleration of scroll speed.
|
||||
** @todo If the scroll key is longer pressed the area is scrolled faster.
|
||||
*/
|
||||
void DoScrollArea(int state, bool fast)
|
||||
void DoScrollArea(int state, bool fast, bool isKeyboard)
|
||||
{
|
||||
CViewport *vp;
|
||||
int stepx;
|
||||
|
@ -87,6 +87,8 @@ void DoScrollArea(int state, bool fast)
|
|||
static int remx = 0; // FIXME: docu
|
||||
static int remy = 0; // FIXME: docu
|
||||
|
||||
int speed = isKeyboard ? UI.KeyScrollSpeed : UI.MouseScrollSpeed;
|
||||
|
||||
if (state == ScrollNone) {
|
||||
return;
|
||||
}
|
||||
|
@ -94,12 +96,12 @@ void DoScrollArea(int state, bool fast)
|
|||
vp = UI.SelectedViewport;
|
||||
|
||||
if (fast) {
|
||||
stepx = (int)(UI.MouseScrollSpeed * vp->MapWidth / 2 * PixelTileSize.x * FRAMES_PER_SECOND / 4);
|
||||
stepy = (int)(UI.MouseScrollSpeed * vp->MapHeight / 2 * PixelTileSize.y * FRAMES_PER_SECOND / 4);
|
||||
stepx = (int)(speed * vp->MapWidth / 2 * PixelTileSize.x * FRAMES_PER_SECOND / 4);
|
||||
stepy = (int)(speed * vp->MapHeight / 2 * PixelTileSize.y * FRAMES_PER_SECOND / 4);
|
||||
} else {// dynamic: let these variables increase up to fast..
|
||||
// FIXME: pixels per second should be configurable
|
||||
stepx = (int)(UI.MouseScrollSpeed * PixelTileSize.x * FRAMES_PER_SECOND / 4);
|
||||
stepy = (int)(UI.MouseScrollSpeed * PixelTileSize.y * FRAMES_PER_SECOND / 4);
|
||||
stepx = (int)(speed * PixelTileSize.x * FRAMES_PER_SECOND / 4);
|
||||
stepy = (int)(speed * PixelTileSize.y * FRAMES_PER_SECOND / 4);
|
||||
}
|
||||
if ((state & (ScrollLeft | ScrollRight)) && (state & (ScrollLeft | ScrollRight)) != (ScrollLeft | ScrollRight)) {
|
||||
stepx = stepx * 100 * 100 / VideoSyncSpeed / FRAMES_PER_SECOND / (SkipFrames + 1);
|
||||
|
@ -341,7 +343,7 @@ static void DisplayLoop()
|
|||
//
|
||||
// Map scrolling
|
||||
//
|
||||
DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0);
|
||||
DoScrollArea(MouseScrollState | KeyScrollState, (KeyModifiers & ModifierControl) != 0, MouseScrollState == 0 && KeyScrollState > 0);
|
||||
|
||||
ColorCycle();
|
||||
|
||||
|
|
|
@ -68,6 +68,29 @@ CPreference Preference;
|
|||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Set speed of key scroll
|
||||
**
|
||||
** @param l Lua state.
|
||||
*/
|
||||
static int CclSetKeyScrollSpeed(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 1);
|
||||
UI.KeyScrollSpeed = LuaToNumber(l, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Get speed of key scroll
|
||||
**
|
||||
** @param l Lua state.
|
||||
*/
|
||||
static int CclGetKeyScrollSpeed(lua_State *l)
|
||||
{
|
||||
LuaCheckArgs(l, 0);
|
||||
lua_pushnumber(l, UI.KeyScrollSpeed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Set speed of mouse scroll
|
||||
|
@ -1170,6 +1193,8 @@ void UserInterfaceCclRegister()
|
|||
CursorCclRegister();
|
||||
lua_register(Lua, "AddMessage", CclAddMessage);
|
||||
|
||||
lua_register(Lua, "SetKeyScrollSpeed", CclSetKeyScrollSpeed);
|
||||
lua_register(Lua, "GetKeyScrollSpeed", CclGetKeyScrollSpeed);
|
||||
lua_register(Lua, "SetMouseScrollSpeed", CclSetMouseScrollSpeed);
|
||||
lua_register(Lua, "GetMouseScrollSpeed", CclGetMouseScrollSpeed);
|
||||
lua_register(Lua, "SetMouseScrollSpeedDefault", CclSetMouseScrollSpeedDefault);
|
||||
|
|
|
@ -112,8 +112,8 @@ CUnitInfoPanel::~CUnitInfoPanel()
|
|||
|
||||
|
||||
CUserInterface::CUserInterface() :
|
||||
MouseScroll(false), KeyScroll(false), MouseScrollSpeed(1),
|
||||
MouseScrollSpeedDefault(0), MouseScrollSpeedControl(0),
|
||||
MouseScroll(false), KeyScroll(false), KeyScrollSpeed(1),
|
||||
MouseScrollSpeed(1), MouseScrollSpeedDefault(0), MouseScrollSpeedControl(0),
|
||||
NormalFontColor("yellow"), ReverseFontColor("white"),
|
||||
SingleSelectedButton(NULL),
|
||||
MaxSelectedFont(NULL), MaxSelectedTextX(0), MaxSelectedTextY(0),
|
||||
|
|
Loading…
Reference in a new issue