mirror of https://github.com/OpenTTD/OpenTTD
(svn r2074) MouseLoop -> InputLoop(), factor out a real mouse-specific MouseLoop from the new InitLoop() (more in the spirit of HandleKeypress()).
parent
d4b3469e2f
commit
f89984642e
2
ttd.c
2
ttd.c
|
@ -1163,7 +1163,7 @@ void GameLoop(void)
|
||||||
if (!_pause || _cheats.build_in_pause.value)
|
if (!_pause || _cheats.build_in_pause.value)
|
||||||
MoveAllTextEffects();
|
MoveAllTextEffects();
|
||||||
|
|
||||||
MouseLoop();
|
InputLoop();
|
||||||
|
|
||||||
if (_game_mode != GM_MENU)
|
if (_game_mode != GM_MENU)
|
||||||
MusicLoop();
|
MusicLoop();
|
||||||
|
|
61
window.c
61
window.c
|
@ -1284,37 +1284,11 @@ static void HandleKeypress(uint32 key)
|
||||||
extern void UpdateTileSelection(void);
|
extern void UpdateTileSelection(void);
|
||||||
extern bool VpHandlePlaceSizingDrag(void);
|
extern bool VpHandlePlaceSizingDrag(void);
|
||||||
|
|
||||||
void MouseLoop(void)
|
static void MouseLoop(int click, int mousewheel)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
Window *w;
|
Window *w;
|
||||||
ViewPort *vp;
|
ViewPort *vp;
|
||||||
int click;
|
|
||||||
int mousewheel;
|
|
||||||
|
|
||||||
_current_player = _local_player;
|
|
||||||
|
|
||||||
// Handle pressed keys
|
|
||||||
if (_pressed_key) {
|
|
||||||
uint32 key = _pressed_key; _pressed_key = 0;
|
|
||||||
HandleKeypress(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mouse event?
|
|
||||||
click = 0;
|
|
||||||
if (_left_button_down && !_left_button_clicked) {
|
|
||||||
_left_button_clicked = true;
|
|
||||||
click = 1;
|
|
||||||
} else if (_right_button_clicked) {
|
|
||||||
_right_button_clicked = false;
|
|
||||||
click = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
mousewheel = 0;
|
|
||||||
if (_cursor.wheel) {
|
|
||||||
mousewheel = _cursor.wheel;
|
|
||||||
_cursor.wheel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DecreaseWindowCounters();
|
DecreaseWindowCounters();
|
||||||
HandlePlacePresize();
|
HandlePlacePresize();
|
||||||
|
@ -1410,6 +1384,39 @@ void MouseLoop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputLoop(void)
|
||||||
|
{
|
||||||
|
int click;
|
||||||
|
int mousewheel;
|
||||||
|
|
||||||
|
_current_player = _local_player;
|
||||||
|
|
||||||
|
// Handle pressed keys
|
||||||
|
if (_pressed_key) {
|
||||||
|
uint32 key = _pressed_key; _pressed_key = 0;
|
||||||
|
HandleKeypress(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mouse event?
|
||||||
|
click = 0;
|
||||||
|
if (_left_button_down && !_left_button_clicked) {
|
||||||
|
_left_button_clicked = true;
|
||||||
|
click = 1;
|
||||||
|
} else if (_right_button_clicked) {
|
||||||
|
_right_button_clicked = false;
|
||||||
|
click = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
mousewheel = 0;
|
||||||
|
if (_cursor.wheel) {
|
||||||
|
mousewheel = _cursor.wheel;
|
||||||
|
_cursor.wheel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseLoop(click, mousewheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _we4_timer;
|
static int _we4_timer;
|
||||||
|
|
||||||
extern uint32 _pixels_redrawn;
|
extern uint32 _pixels_redrawn;
|
||||||
|
|
2
window.h
2
window.h
|
@ -566,7 +566,7 @@ void InitWindowSystem(void);
|
||||||
void UnInitWindowSystem(void);
|
void UnInitWindowSystem(void);
|
||||||
void ResetWindowSystem(void);
|
void ResetWindowSystem(void);
|
||||||
int GetMenuItemIndex(Window *w, int x, int y);
|
int GetMenuItemIndex(Window *w, int x, int y);
|
||||||
void MouseLoop(void);
|
void InputLoop(void);
|
||||||
void UpdateWindows(void);
|
void UpdateWindows(void);
|
||||||
void InvalidateWidget(Window *w, byte widget_index);
|
void InvalidateWidget(Window *w, byte widget_index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue