summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-22 00:38:17 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-22 00:38:17 +0200
commit0ff419560d5a567afaa0294968cc1f5b5e6b597b (patch)
tree03edeac0b7850348b9b910e0d39dd88a477afd75
parent15ff1d512b9e103396144bec1cd8004ecf4f7f9c (diff)
downloadcolobot-0ff419560d5a567afaa0294968cc1f5b5e6b597b.tar.gz
colobot-0ff419560d5a567afaa0294968cc1f5b5e6b597b.tar.bz2
colobot-0ff419560d5a567afaa0294968cc1f5b5e6b597b.zip
Event fixes & refactoring
- added new state tracking to Event - removed old fields from Event - fixed some issues with Events and fps counter
-rw-r--r--src/app/app.cpp132
-rw-r--r--src/app/app.h32
-rw-r--r--src/common/event.h118
-rw-r--r--src/common/event_ids.h6
-rw-r--r--src/graphics/engine/camera.cpp26
-rw-r--r--src/graphics/engine/engine.cpp1
-rw-r--r--src/object/brain.cpp2
-rw-r--r--src/object/robotmain.cpp10
-rw-r--r--src/ui/button.cpp8
-rw-r--r--src/ui/check.cpp4
-rw-r--r--src/ui/color.cpp6
-rw-r--r--src/ui/compass.cpp4
-rw-r--r--src/ui/control.cpp12
-rw-r--r--src/ui/displayinfo.cpp6
-rw-r--r--src/ui/edit.cpp48
-rw-r--r--src/ui/editvalue.cpp9
-rw-r--r--src/ui/gauge.cpp2
-rw-r--r--src/ui/interface.cpp2
-rw-r--r--src/ui/key.cpp7
-rw-r--r--src/ui/list.cpp6
-rw-r--r--src/ui/maindialog.cpp32
-rw-r--r--src/ui/map.cpp10
-rw-r--r--src/ui/scroll.cpp20
-rw-r--r--src/ui/shortcut.cpp4
-rw-r--r--src/ui/slider.cpp22
-rw-r--r--src/ui/studio.cpp6
-rw-r--r--src/ui/target.cpp14
-rw-r--r--src/ui/window.cpp16
28 files changed, 272 insertions, 293 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 73f7237..c787927 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -725,7 +725,7 @@ int CApplication::Run()
{
haveEvent = true;
- Event event = ParseEvent();
+ Event event = ProcessSystemEvent();
if (event.type == EVENT_QUIT)
goto end; // exit the loop
@@ -812,21 +812,11 @@ const std::string& CApplication::GetErrorMessage()
return m_errorMessage;
}
-//! Translates SDL press state to PressState
-PressState TranslatePressState(unsigned char state)
-{
- if (state == SDL_PRESSED)
- return STATE_PRESSED;
- else
- return STATE_RELEASED;
-}
-
/** The SDL event parsed is stored internally.
If event is not available or is not understood, returned event is of type EVENT_NULL. */
-Event CApplication::ParseEvent()
+Event CApplication::ProcessSystemEvent()
{
Event event;
-
event.systemEvent = true;
if (m_private->currentEvent.type == SDL_QUIT)
@@ -843,9 +833,10 @@ Event CApplication::ParseEvent()
event.key.virt = false;
event.key.key = m_private->currentEvent.key.keysym.sym;
- event.key.mod = m_private->currentEvent.key.keysym.mod;
- event.key.state = TranslatePressState(m_private->currentEvent.key.state);
event.key.unicode = m_private->currentEvent.key.keysym.unicode;
+
+ // Use the occasion to update kmods
+ m_kmodState = m_private->currentEvent.key.keysym.mod;
}
else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) ||
(m_private->currentEvent.type == SDL_MOUSEBUTTONUP) )
@@ -860,8 +851,6 @@ Event CApplication::ParseEvent()
event.mouseWheel.dir = WHEEL_DOWN;
else
event.mouseWheel.dir = WHEEL_UP;
- event.mouseWheel.pos = m_engine->WindowToInterfaceCoords(
- Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
}
}
else
@@ -871,18 +860,24 @@ Event CApplication::ParseEvent()
else
event.type = EVENT_MOUSE_BUTTON_UP;
- event.mouseButton.button = m_private->currentEvent.button.button;
- event.mouseButton.state = TranslatePressState(m_private->currentEvent.button.state);
- event.mouseButton.pos = m_engine->WindowToInterfaceCoords(
- Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ event.mouseButton.button = static_cast<MouseButton>(1 << m_private->currentEvent.button.button);
+
+ // Use the occasion to update mouse button state
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
+ m_mouseButtonsState |= event.mouseButton.button;
+ else
+ m_mouseButtonsState &= ~event.mouseButton.button;
}
+
+ // Use the occasion to update mouse pos
+ m_mousePos = m_engine->WindowToInterfaceCoords(
+ Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
}
else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
{
event.type = EVENT_MOUSE_MOVE;
- event.mouseMove.state = TranslatePressState(m_private->currentEvent.button.state);
- event.mouseMove.pos = m_engine->WindowToInterfaceCoords(
+ m_mousePos = m_engine->WindowToInterfaceCoords(
Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
}
else if (m_private->currentEvent.type == SDL_JOYAXISMOTION)
@@ -901,7 +896,6 @@ Event CApplication::ParseEvent()
event.type = EVENT_JOY_BUTTON_UP;
event.joyButton.button = m_private->currentEvent.jbutton.button;
- event.joyButton.state = TranslatePressState(m_private->currentEvent.jbutton.state);
}
else if (m_private->currentEvent.type == SDL_ACTIVEEVENT)
{
@@ -917,35 +911,10 @@ Event CApplication::ParseEvent()
event.active.gain = m_private->currentEvent.active.gain == 1;
}
- return event;
-}
-
-/**
- * Processes incoming events. It is the first function called after an event is captured.
- * Event is modified, updating its tracked keys state and mouse position to current values.
- * Function returns \c true if the event is to be passed on to other processing functions
- * or \c false if not. */
-bool CApplication::ProcessEvent(Event &event)
-{
- CLogger *l = GetLogger();
-
- event.trackedKeys = m_trackedKeys;
- event.mousePos = m_mousePos;
- if (event.type == EVENT_ACTIVE)
+ if (event.type == EVENT_KEY_DOWN)
{
- if (m_debugMode)
- l->Info("Focus change: active = %s\n", event.active.gain ? "true" : "false");
- }
- else if (event.type == EVENT_KEY_DOWN)
- {
- m_kmodState = event.key.mod;
-
- if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
- m_trackedKeys |= TRKEY_SHIFT;
- else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
- m_trackedKeys |= TRKEY_CONTROL;
- else if (event.key.key == KEY(KP8))
+ if (event.key.key == KEY(KP8))
m_trackedKeys |= TRKEY_NUM_UP;
else if (event.key.key == KEY(KP2))
m_trackedKeys |= TRKEY_NUM_DOWN;
@@ -964,13 +933,7 @@ bool CApplication::ProcessEvent(Event &event)
}
else if (event.type == EVENT_KEY_UP)
{
- m_kmodState = event.key.mod;
-
- if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
- m_trackedKeys &= ~TRKEY_SHIFT;
- else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
- m_trackedKeys &= ~TRKEY_CONTROL;
- else if (event.key.key == KEY(KP8))
+ if (event.key.key == KEY(KP8))
m_trackedKeys &= ~TRKEY_NUM_UP;
else if (event.key.key == KEY(KP2))
m_trackedKeys &= ~TRKEY_NUM_DOWN;
@@ -987,14 +950,23 @@ bool CApplication::ProcessEvent(Event &event)
else if (event.key.key == KEY(PAGEDOWN))
m_trackedKeys &= ~TRKEY_PAGE_DOWN;
}
- else if (event.type == EVENT_MOUSE_BUTTON_DOWN)
- {
- m_mouseButtonsState |= 1 << event.mouseButton.button;
- }
- else if (event.type == EVENT_MOUSE_BUTTON_UP)
- {
- m_mouseButtonsState &= ~(1 << event.mouseButton.button);
- }
+
+ event.trackedKeysState = m_trackedKeys;
+ event.kmodState = m_kmodState;
+ event.mousePos = m_mousePos;
+ event.mouseButtonsState = m_mouseButtonsState;
+
+ return event;
+}
+
+/**
+ * Processes incoming events. It is the first function called after an event is captured.
+ * Event is modified, updating its tracked keys state and mouse position to current values.
+ * Function returns \c true if the event is to be passed on to other processing functions
+ * or \c false if not. */
+bool CApplication::ProcessEvent(const Event &event)
+{
+ CLogger *l = GetLogger();
// Print the events in debug mode to test the code
if (m_debugMode)
@@ -1005,28 +977,21 @@ bool CApplication::ProcessEvent(Event &event)
case EVENT_KEY_UP:
l->Info("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
l->Info(" virt = %s\n", (event.key.virt) ? "true" : "false");
- l->Info(" key = %4x\n", event.key.key);
- l->Info(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- l->Info(" mod = %4x\n", event.key.mod);
- l->Info(" unicode = %4x\n", event.key.unicode);
+ l->Info(" key = %d\n", event.key.key);
+ l->Info(" unicode = 0x%04x\n", event.key.unicode);
break;
case EVENT_MOUSE_MOVE:
l->Info("EVENT_MOUSE_MOVE:\n");
- l->Info(" state = %s\n", (event.mouseMove.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- l->Info(" pos = (%f, %f)\n", event.mouseMove.pos.x, event.mouseMove.pos.y);
break;
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
l->Info("EVENT_MOUSE_BUTTON_%s:\n", (event.type == EVENT_MOUSE_BUTTON_DOWN) ? "DOWN" : "UP");
l->Info(" button = %d\n", event.mouseButton.button);
- l->Info(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
- l->Info(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
break;
case EVENT_MOUSE_WHEEL:
l->Info("EVENT_MOUSE_WHEEL:\n");
l->Info(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
- l->Info(" pos = (%f, %f)\n", event.mouseWheel.pos.x, event.mouseWheel.pos.y);
- break;
+ break;
case EVENT_JOY_AXIS:
l->Info("EVENT_JOY_AXIS:\n");
l->Info(" axis = %d\n", event.joyAxis.axis);
@@ -1036,7 +1001,6 @@ bool CApplication::ProcessEvent(Event &event)
case EVENT_JOY_BUTTON_UP:
l->Info("EVENT_JOY_BUTTON_%s:\n", (event.type == EVENT_JOY_BUTTON_DOWN) ? "DOWN" : "UP");
l->Info(" button = %d\n", event.joyButton.button);
- l->Info(" state = %s\n", (event.joyButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
break;
case EVENT_ACTIVE:
l->Info("EVENT_ACTIVE:\n");
@@ -1044,8 +1008,16 @@ bool CApplication::ProcessEvent(Event &event)
l->Info(" gain = %s\n", event.active.gain ? "true" : "false");
break;
default:
+ l->Info("Event type = %d:\n", static_cast<int>(event.type));
break;
}
+
+ l->Info(" systemEvent = %s\n", event.systemEvent ? "true" : "false");
+ l->Info(" rTime = %f\n", event.rTime);
+ l->Info(" kmodState = %04x\n", event.kmodState);
+ l->Info(" trackedKeysState = %04x\n", event.trackedKeysState);
+ l->Info(" mousePos = %f, %f\n", event.mousePos.x, event.mousePos.y);
+ l->Info(" mouseButtonsState = %02x\n", event.mouseButtonsState);
}
// By default, pass on all events
@@ -1081,9 +1053,9 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
virtualEvent.type = EVENT_KEY_DOWN;
else
virtualEvent.type = EVENT_KEY_UP;
+
virtualEvent.key.virt = true;
virtualEvent.key.key = VIRTUAL_JOY(sourceEvent.joyButton.button);
- virtualEvent.key.mod = 0;
virtualEvent.key.unicode = 0;
}
else
@@ -1161,6 +1133,11 @@ void CApplication::StepSimulation()
Event frameEvent(EVENT_FRAME);
+ frameEvent.systemEvent = true;
+ frameEvent.trackedKeysState = m_trackedKeys;
+ frameEvent.kmodState = m_kmodState;
+ frameEvent.mousePos = m_mousePos;
+ frameEvent.mouseButtonsState = m_mouseButtonsState;
frameEvent.rTime = m_relTime;
m_eventQueue->AddEvent(frameEvent);
}
@@ -1280,6 +1257,7 @@ bool CApplication::GetMouseButtonState(int index)
void CApplication::ResetKeyStates()
{
+ GetLogger()->Info("Reset key states\n");
m_trackedKeys = 0;
m_kmodState = 0;
m_robotMain->ResetKeyStates();
diff --git a/src/app/app.h b/src/app/app.h
index 06879ae..f5383ce 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -76,20 +76,18 @@ enum VideoQueryResult
/**
* \enum TrackedKeys
- * \brief Keys (or kmods) whose state (pressed/released) is tracked by CApplication
+ * \brief Additional keys whose state (pressed/released) is tracked by CApplication
*/
enum TrackedKey
{
- TRKEY_SHIFT = (1<<0),
- TRKEY_CONTROL = (1<<1),
- TRKEY_NUM_UP = (1<<2),
- TRKEY_NUM_DOWN = (1<<3),
- TRKEY_NUM_LEFT = (1<<4),
- TRKEY_NUM_RIGHT = (1<<5),
- TRKEY_NUM_PLUS = (1<<6),
- TRKEY_NUM_MINUS = (1<<7),
- TRKEY_PAGE_UP = (1<<8),
- TRKEY_PAGE_DOWN = (1<<9)
+ TRKEY_NUM_UP = (1<<0),
+ TRKEY_NUM_DOWN = (1<<1),
+ TRKEY_NUM_LEFT = (1<<2),
+ TRKEY_NUM_RIGHT = (1<<3),
+ TRKEY_NUM_PLUS = (1<<4),
+ TRKEY_NUM_MINUS = (1<<5),
+ TRKEY_PAGE_UP = (1<<6),
+ TRKEY_PAGE_DOWN = (1<<7)
};
/**
@@ -305,11 +303,11 @@ protected:
bool CreateVideoSurface();
//! Processes the captured SDL event to Event struct
- Event ParseEvent();
+ Event ProcessSystemEvent();
//! If applicable, creates a virtual event to match the changed state as of new event
Event CreateVirtualEvent(const Event& sourceEvent);
//! Handles some incoming events
- bool ProcessEvent(Event &event);
+ bool ProcessEvent(const Event& event);
//! Renders the image in window
void Render();
@@ -375,17 +373,17 @@ protected:
bool m_simulationSuspended;
//@}
- //! Current state of key modifiers (mask of SDLMod)
+ //! Current state of key modifiers (bitmask of SDLMod)
unsigned int m_kmodState;
- //! Current state of some tracked keys (mask of TrackedKey)
+ //! Current state of some tracked keys (bitmask of TrackedKey enum values)
unsigned int m_trackedKeys;
- //! Current state of mouse buttons (mask of button indexes)
- unsigned int m_mouseButtonsState;
//! Current mode of mouse
MouseMode m_mouseMode;
//! Current position of mouse cursor
Math::Point m_mousePos;
+ //! Current state of mouse buttons (bitmask of MouseButton enum values)
+ unsigned int m_mouseButtonsState;
//! Info about current joystick device
JoystickDevice m_joystick;
diff --git a/src/common/event.h b/src/common/event.h
index 378960c..dc50ee6 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -31,42 +31,33 @@ class CInstanceManager;
/**
- * \enum PressState
- * \brief State of key/mouse button
- */
-enum PressState
-{
- STATE_PRESSED,
- STATE_RELEASED
-};
-
-
-/**
* \struct KeyEventData
* \brief Additional data for keyboard event
*/
struct KeyEventData
{
- //! STATE_PRESSED or STATE_RELEASED */
- PressState state;
- //! If true, the key is a virtual code generated by key modifier press or joystick button press
+ //! If true, the key is a virtual code generated by certain key modifiers or joystick buttons
bool virt;
//! Key symbol: KEY(...) macro value or virtual key VIRTUAL_... (from common/key.h)
unsigned int key;
- //! Keyboard modifiers: a bitmask made of KEY_MOD(...) macro values (from common/key.h)
- unsigned int mod;
//! Unicode character
+ //! NOTE: applicable only to EVENT_KEY_DOWN events!
unsigned int unicode;
};
-/** \struct MouseMotionEventData
- \brief Additional data for mouse move event */
-struct MouseMoveEventData
+/**
+ * \enum MouseButton
+ * \brief Mouse button
+ *
+ * Values are a bitmask to have a state bitmask
+ */
+enum MouseButton
{
- //! Current button state
- PressState state;
- //! Position of mouse in normalized coordinates (0..1)
- Math::Point pos;
+ MOUSE_BUTTON_LEFT = (1<<1),
+ MOUSE_BUTTON_MIDDLE = (1<<2),
+ MOUSE_BUTTON_RIGHT = (1<<3),
+ //! There may be additional mouse buttons >= this value
+ MOUSE_BUTTON_OTHER = (1<<4)
};
/**
@@ -75,12 +66,8 @@ struct MouseMoveEventData
*/
struct MouseButtonEventData
{
- //! The mouse button index
- unsigned char button;
- //! STATE_PRESSED or STATE_RELEASED
- PressState state;
- //! Position of mouse in normalized coordinates (0..1)
- Math::Point pos;
+ //! The mouse button
+ MouseButton button;
};
/**
@@ -101,8 +88,6 @@ struct MouseWheelEventData
{
//! Wheel direction
WheelDirection dir;
- //! Position of mouse in normalized coordinates (0..1)
- Math::Point pos;
};
/**
@@ -125,8 +110,6 @@ struct JoyButtonEventData
{
//! The joystick button index
unsigned char button;
- //! STATE_PRESSED or STATE_RELEASED
- PressState state;
};
/**
@@ -170,20 +153,48 @@ struct ActiveEventData
**/
struct Event
{
- //! Type of event (EVENT_*)
+ //! Type of event
EventType type;
- //! If true, the event was produced by system (SDL); else, it has come from user interface
+ //! If true, the event was produced by system in CApplication; else, it has come from game engine
bool systemEvent;
+ //! Relative time since last EVENT_FRAME
+ //! Scope: only EVENT_FRAME events
+ // TODO: gradually replace the usage of this with new CApplication's time functions
+ float rTime;
+
+ //! Motion vector set by keyboard or joystick (managed by CRobotMain)
+ //! Scope: all system events
+ Math::Vector motionInput;
+
+ //! Current state of keyboard modifier keys: bitmask made of KEY_MOD(...) macro values (from common/key.h)
+ //! Scope: all system events
+ unsigned int kmodState;
+
+ //! Current state of tracked keys: bitmask of TrackedKey enum values
+ //! Scope: all system events
+ unsigned int trackedKeysState;
+
+ //! Current position of mouse cursor in interface coords
+ //! Scope: all system events
+ Math::Point mousePos;
+
+ //! Current state of mouse buttons: bitmask of MouseButton enum values
+ //! Scope: all system events
+ unsigned int mouseButtonsState;
+
+ //! Custom parameter that may be set for some events
+ //! Scope: some interface events
+ long customParam;
+
+ //! Union with additional data, applicable only to some events
union
{
//! Additional data for EVENT_KEY_DOWN and EVENT_KEY_UP
KeyEventData key;
//! Additional data for EVENT_MOUSE_BUTTON_DOWN and EVENT_MOUSE_BUTTON_UP
MouseButtonEventData mouseButton;
- //! Additional data for EVENT_MOUSE_MOVE
- MouseMoveEventData mouseMove;
//! Additional data for EVENT_MOUSE_WHEEL
MouseWheelEventData mouseWheel;
//! Additional data for EVENT_JOY
@@ -194,35 +205,15 @@ struct Event
ActiveEventData active;
};
- //! State of tracked keys (mask of TrackedKey enum values)
- unsigned int trackedKeys;
-
- //! Mouse position is provided also for other types of events besides mouse events
- Math::Point mousePos;
-
- //! Motion vector set by keyboard or joystick
- Math::Vector motionInput;
-
- // TODO: remove and replace references with trackedKeys
- short keyState;
-
- // TODO: remove and replace references with mousePos
- Math::Point pos;
-
- // TODO: remove
- long param; // parameter
-
- // TODO: remove in longer term (use CApplication's new time functions instead)
- float rTime; // relative time
-
- Event(EventType aType = EVENT_NULL)
+ Event(EventType type = EVENT_NULL)
{
- type = aType;
- systemEvent = false;
- trackedKeys = 0;
+ this->type = type;
- param = 0;
+ systemEvent = false;
rTime = 0.0f;
+ mouseButtonsState = 0;
+ trackedKeysState = 0;
+ customParam = 0;
}
};
@@ -254,6 +245,7 @@ public:
void Flush();
//! Adds an event to the queue
bool AddEvent(const Event &event);
+ //! Removes and returns an event from queue front
bool GetEvent(Event &event);
protected:
diff --git a/src/common/event_ids.h b/src/common/event_ids.h
index 9cbbf94..b6c646c 100644
--- a/src/common/event_ids.h
+++ b/src/common/event_ids.h
@@ -60,10 +60,16 @@ enum EventType
//! Event sent after releasing a joystick button
EVENT_JOY_BUTTON_UP = 14,
+
+ /* Events sent/received in game and user interface */
+
EVENT_UPDINTERFACE = 20,
EVENT_WIN = 30,
EVENT_LOST = 31,
+ //! CEdit focus
+ EVENT_FOCUS = 35,
+
EVENT_BUTTON_OK = 40,
EVENT_BUTTON_CANCEL = 41,
EVENT_BUTTON_NEXT = 42,
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
index 23131ef..d85194e 100644
--- a/src/graphics/engine/camera.cpp
+++ b/src/graphics/engine/camera.cpp
@@ -18,6 +18,8 @@
#include "graphics/engine/camera.h"
+#include "app/app.h"
+
#include "common/iman.h"
#include "graphics/engine/engine.h"
@@ -1022,7 +1024,7 @@ bool CCamera::EventProcess(const Event &event)
bool CCamera::EventMouseMove(const Event &event)
{
- m_mousePos = event.pos;
+ m_mousePos = event.mousePos;
return true;
}
@@ -1193,7 +1195,7 @@ bool CCamera::EventFrameFree(const Event &event)
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.motionInput.y * event.rTime * factor * m_speed);
// Left/Right
- if ( event.keyState & KS_CONTROL )
+ if ( event.kmodState & KEY_MOD(CTRL) )
{
if ( event.motionInput.x < 0.0f )
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.motionInput.x * event.rTime * factor * m_speed);
@@ -1206,12 +1208,12 @@ bool CCamera::EventFrameFree(const Event &event)
}
// PageUp/PageDown
- if ( event.keyState & KS_NUMMINUS )
+ if ( event.trackedKeysState & TRKEY_NUM_MINUS )
{
if (m_heightEye < 500.0f)
m_heightEye += event.rTime * factor * m_speed;
}
- if ( event.keyState & KS_NUMPLUS )
+ if ( event.trackedKeysState & TRKEY_NUM_PLUS )
{
if (m_heightEye > -2.0f)
m_heightEye -= event.rTime * factor * m_speed;
@@ -1299,12 +1301,12 @@ bool CCamera::EventFrameBack(const Event &event)
type = m_cameraObj->GetType();
// +/-.
- if (event.keyState & KS_NUMPLUS)
+ if (event.trackedKeysState & TRKEY_NUM_PLUS)
{
m_backDist -= event.rTime * 30.0f * m_speed;
if (m_backDist < m_backMin) m_backDist = m_backMin;
}
- if (event.keyState & KS_NUMMINUS)
+ if (event.trackedKeysState & TRKEY_NUM_MINUS)
{
m_backDist += event.rTime * 30.0f * m_speed;
if (m_backDist > 200.0f) m_backDist = 200.0f;
@@ -1448,12 +1450,12 @@ bool CCamera::EventFrameBack(const Event &event)
bool CCamera::EventFrameFix(const Event &event)
{
// +/-.
- if (event.keyState & KS_NUMPLUS)
+ if (event.trackedKeysState & TRKEY_NUM_PLUS)
{
m_fixDist -= event.rTime * 30.0f * m_speed;
if (m_fixDist < 10.0f) m_fixDist = 10.0f;
}
- if (event.keyState & KS_NUMMINUS)
+ if (event.trackedKeysState & TRKEY_NUM_MINUS)
{
m_fixDist += event.rTime * 30.0f * m_speed;
if (m_fixDist > 200.0f) m_fixDist = 200.0f;
@@ -1552,24 +1554,24 @@ bool CCamera::EventFrameVisit(const Event &event)
m_visitTime += event.rTime;
// +/-.
- if (event.keyState & KS_NUMPLUS)
+ if (event.trackedKeysState & TRKEY_NUM_PLUS)
{
m_visitDist -= event.rTime * 50.0f * m_speed;
if (m_visitDist < 20.0f) m_visitDist = 20.0f;
}
- if (event.keyState & KS_NUMMINUS)
+ if (event.trackedKeysState & TRKEY_NUM_MINUS)
{
m_visitDist += event.rTime * 50.0f * m_speed;
if (m_visitDist > 200.0f) m_visitDist = 200.0f;
}
// PageUp/Down.
- if (event.keyState & KS_PAGEUP)
+ if (event.trackedKeysState & TRKEY_PAGE_UP)
{
m_visitDirectionV -= event.rTime * 1.0f * m_speed;
if (m_visitDirectionV < -Math::PI * 0.40f) m_visitDirectionV = -Math::PI * 0.40f;
}
- if (event.keyState & KS_PAGEDOWN)
+ if (event.trackedKeysState & TRKEY_PAGE_DOWN)
{
m_visitDirectionV += event.rTime * 1.0f * m_speed;
if (m_visitDirectionV > 0.0f ) m_visitDirectionV = 0.0f;
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 79becea..b737555 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -356,6 +356,7 @@ void CEngine::FrameUpdate()
CopyTimeStamp(m_lastFrameTime, m_currentFrameTime);
m_fps = m_fpsCounter / diff;
+ m_fpsCounter = 0;
if (m_showStats)
{
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 953f878..7b580d7 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -578,7 +578,7 @@ bool CBrain::EventProcess(const Event &event)
}
if ( action == EVENT_OBJECT_TARGET && !m_object->GetTrainer() )
{
- err = StartTaskGunGoal((event.pos.y-0.50f)*1.3f, (event.pos.x-0.50f)*2.0f);
+ err = StartTaskGunGoal((event.mousePos.y-0.50f)*1.3f, (event.mousePos.x-0.50f)*2.0f);
}
if ( action == EVENT_OBJECT_FIREANT )
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 508e692..93e1fda 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -1333,8 +1333,8 @@ bool CRobotMain::EventProcess(Event &event)
{
if (event.type == EVENT_MOUSE_MOVE)
{
- m_lastMousePos = event.pos;
- HiliteObject(event.pos);
+ m_lastMousePos = event.mousePos;
+ HiliteObject(event.mousePos);
}
return false;
}
@@ -1344,8 +1344,8 @@ bool CRobotMain::EventProcess(Event &event)
if (event.type == EVENT_MOUSE_MOVE)
{
- m_lastMousePos = event.pos;
- HiliteObject(event.pos);
+ m_lastMousePos = event.mousePos;
+ HiliteObject(event.mousePos);
}
if (m_displayInfo != nullptr) // current info?
@@ -1514,7 +1514,7 @@ bool CRobotMain::EventProcess(Event &event)
if (event.mouseButton.button != 1) // only left mouse button
break;
- obj = DetectObject(event.pos);
+ obj = DetectObject(event.mousePos);
if (!m_shortCut) obj = nullptr;
if (obj != nullptr && obj->GetType() == OBJECT_TOTO)
{
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index d98e676..e3dbc30 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -101,11 +101,11 @@ bool CButton::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
m_bCapture = true;
m_repeat = DELAY1;
@@ -125,10 +125,10 @@ bool CButton::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
m_bCapture )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
if ( !m_bImmediat && !m_bRepeat )
{
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index 3b0fbc3..bc80b7c 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -73,11 +73,11 @@ bool CCheck::EventProcess(const Event &event)
CControl::EventProcess(event);
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
Event newEvent = event;
newEvent.type = m_eventType;
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 5668519..a727642 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -105,11 +105,11 @@ bool CColor::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
m_repeat = DELAY1;
@@ -120,7 +120,7 @@ bool CColor::EventProcess(const Event &event)
}
}
- if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1)
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
m_repeat = 0.0f;
}
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index c7d0068..1bc0f8c 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -60,9 +60,9 @@ bool CCompass::EventProcess(const Event &event)
CControl::EventProcess(event);
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1)
+ event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
Event newEvent = event;
newEvent.type = m_eventType;
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index fbf7575..16769d1 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -304,9 +304,9 @@ bool CControl::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
- m_glintMouse = event.mouseMove.pos;
+ m_glintMouse = event.mousePos;
- if ( Detect(event.mouseMove.pos) )
+ if ( Detect(event.mousePos) )
{
if ( (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE ) )
@@ -321,9 +321,9 @@ bool CControl::EventProcess(const Event &event)
}
}
- if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1)
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- if ( Detect(event.mouseButton.pos) )
+ if ( Detect(event.mousePos) )
{
m_bCapture = true;
SetState(STATE_PRESS);
@@ -332,7 +332,7 @@ bool CControl::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
- if ( Detect(event.mouseMove.pos) )
+ if ( Detect(event.mousePos) )
{
SetState(STATE_PRESS);
}
@@ -342,7 +342,7 @@ bool CControl::EventProcess(const Event &event)
}
}
- if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == 1)
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
m_bCapture = false;
ClearState(STATE_PRESS);
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 173c100..9b49f68 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -103,7 +103,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 )
{
- toto->SetMousePos(event.mouseMove.pos);
+ toto->SetMousePos(event.mousePos);
}
}
}
@@ -201,8 +201,8 @@ bool CDisplayInfo::EventProcess(const Event &event)
}
}
- if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 )||
- ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 ))
+ if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT )||
+ ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT ))
{
UpdateCopyButton();
}
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index e2baae9..674ed43 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -240,14 +240,14 @@ bool CEdit::EventProcess(const Event &event)
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_UP &&
- Detect(event.pos) )
+ Detect(event.mousePos) )
{
Scroll(m_lineFirst-3, true);
return true;
}
if (event.type == EVENT_KEY_DOWN &&
event.mouseWheel.dir == WHEEL_DOWN &&
- Detect(event.mouseWheel.pos) )
+ Detect(event.mousePos) )
{
Scroll(m_lineFirst+3, true);
return true;
@@ -263,8 +263,8 @@ bool CEdit::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
- if ( Detect(event.mouseMove.pos) &&
- event.mouseMove.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
+ if ( Detect(event.mousePos) &&
+ event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
{
if ( m_bEdit )
{
@@ -272,7 +272,7 @@ bool CEdit::EventProcess(const Event &event)
}
else
{
- if ( IsLinkPos(event.mouseMove.pos) )
+ if ( IsLinkPos(event.mousePos) )
{
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
@@ -297,23 +297,23 @@ bool CEdit::EventProcess(const Event &event)
if ( event.type == EVENT_KEY_DOWN && m_bFocus )
{
- bShift = ( (event.trackedKeys & TRKEY_SHIFT) != 0 );
- bControl = ( (event.trackedKeys & TRKEY_CONTROL) != 0);
+ bShift = ( (event.kmodState & KEY_MOD(SHIFT) ) != 0 );
+ bControl = ( (event.kmodState & KEY_MOD(CTRL) ) != 0);
if ( (event.key.unicode == 'X' && !bShift && bControl) ||
- (event.key.key == KEY(DELETE) && bShift && !bControl) )
+ ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) )
{
Cut();
return true;
}
if ( (event.key.unicode == 'C' && !bShift && bControl) ||
- (event.key.key == KEY(INSERT) && !bShift && bControl) )
+ ((event.kmodState & KEY_MOD(CTRL)) != 0 && !bShift && bControl) )
{
Copy();
return true;
}
if ( (event.key.unicode == 'V' && !bShift && bControl) ||
- (event.param == KEY(INSERT) && bShift && !bControl) )
+ ((event.kmodState & KEY_MOD(CTRL)) != 0 && bShift && !bControl) )
{
Paste();
return true;
@@ -471,9 +471,9 @@ bool CEdit::EventProcess(const Event &event)
}
}
- if ( event.type == EVENT_ACTIVE )
+ if ( event.type == EVENT_FOCUS )
{
- if ( event.param == m_eventType )
+ if ( event.customParam == m_eventType )
{
m_bFocus = true;
}
@@ -484,15 +484,15 @@ bool CEdit::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1)
+ event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- m_mouseFirstPos = event.pos;
- m_mouseLastPos = event.pos;
- if ( Detect(event.pos) )
+ m_mouseFirstPos = event.mousePos;
+ m_mouseLastPos = event.mousePos;
+ if ( Detect(event.mousePos) )
{
- if ( event.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
+ if ( event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
{
- MouseClick(event.pos);
+ MouseClick(event.mousePos);
if ( m_bEdit || m_bHilite ) m_bCapture = true;
}
m_bFocus = true;
@@ -505,8 +505,8 @@ bool CEdit::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
- m_mouseLastPos = event.pos;
- MouseMove(event.pos);
+ m_mouseLastPos = event.mousePos;
+ MouseMove(event.mousePos);
}
if ( event.type == EVENT_FRAME && m_bCapture )
@@ -515,11 +515,11 @@ bool CEdit::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_UP &&
- event.mouseButton.button == 1)
+ event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- if ( Detect(event.pos) )
+ if ( Detect(event.mousePos) )
{
- if ( event.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
+ if ( event.mousePos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
{
MouseRelease(m_mouseFirstPos);
}
@@ -528,7 +528,7 @@ bool CEdit::EventProcess(const Event &event)
{
if ( m_timeLastClick+DELAY_DBCLICK > m_time ) // double-click ?
{
- MouseDoubleClick(event.pos);
+ MouseDoubleClick(event.mousePos);
}
m_timeLastClick = m_time;
m_bCapture = false;
diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp
index 3b819b3..3cc856d 100644
--- a/src/ui/editvalue.cpp
+++ b/src/ui/editvalue.cpp
@@ -191,7 +191,7 @@ bool CEditValue::EventProcess(const Event &event)
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_UP &&
- Detect(event.mouseWheel.pos))
+ Detect(event.mousePos))
{
value = GetValue()+m_stepValue;
if ( value > m_maxValue ) value = m_maxValue;
@@ -200,7 +200,7 @@ bool CEditValue::EventProcess(const Event &event)
}
if ( event.type == EVENT_KEY_DOWN &&
event.mouseWheel.dir == WHEEL_DOWN &&
- Detect(event.mouseWheel.pos))
+ Detect(event.mousePos))
{
value = GetValue()-m_stepValue;
if ( value < m_minValue ) value = m_minValue;
@@ -230,9 +230,8 @@ void CEditValue::HiliteValue(const Event &event)
m_edit->SetFocus(true);
Event newEvent = event;
- newEvent.type = EVENT_ACTIVE;
- newEvent.active.gain = true; // TODO not much pretty sure about it
- newEvent.param = m_edit->GetEventType();
+ newEvent.type = EVENT_FOCUS;
+ newEvent.customParam = m_edit->GetEventType();
m_event->AddEvent(newEvent); // defocus the other objects
}
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index b1ce31d..b1fa057 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -56,7 +56,7 @@ bool CGauge::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_BUTTON_DOWN )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
Event newEvent = event;
newEvent.type = m_eventType;
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 0745c9b..885cef4 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -282,7 +282,7 @@ bool CInterface::EventProcess(const Event &event)
if (m_camera == nullptr) {
m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA));
}
- m_engine->SetMouseType(m_camera->GetMouseDef(event.mouseMove.pos));
+ m_engine->SetMouseType(m_camera->GetMouseDef(event.mousePos));
}
for (int i = MAXCONTROL-1; i >= 0; i--) {
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 2e627bd..26d99ac 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -82,8 +82,8 @@ bool CKey::EventProcess(const Event &event)
CControl::EventProcess(event);
if (event.type == EVENT_MOUSE_BUTTON_DOWN) {
- if (event.mouseButton.button == 1) // left
- m_bCatch = Detect(event.mouseButton.pos);
+ if (event.mouseButton.button == MOUSE_BUTTON_LEFT) // left
+ m_bCatch = Detect(event.mousePos);
}
if (event.type == EVENT_KEY_DOWN && m_bCatch) {
@@ -92,12 +92,13 @@ bool CKey::EventProcess(const Event &event)
if ( TestKey(event.key.key) ) { // impossible ?
m_sound->Play(SOUND_TZOING);
} else {
+ // TODO: test for virtual, joystick, etc.
if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) {
m_key[0] = event.key.key;
m_key[1] = 0;
} else {
m_key[1] = m_key[0];
- m_key[0] = event.param;
+ m_key[0] = event.key.key;
}
m_sound->Play(SOUND_CLICK);
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index f62d0ea..4356ea4 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -257,7 +257,7 @@ bool CList::EventProcess(const Event &event)
if ((m_state & STATE_ENABLE) == 0)
return true;
- if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mouseWheel.pos)) {
+ if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mousePos)) {
if (m_firstLine > 0)
m_firstLine--;
UpdateScroll();
@@ -265,7 +265,7 @@ bool CList::EventProcess(const Event &event)
return true;
}
- if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mouseWheel.pos)) {
+ if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mousePos)) {
if (m_firstLine < m_totalLine - m_displayLine)
m_firstLine++;
UpdateScroll();
@@ -275,7 +275,7 @@ bool CList::EventProcess(const Event &event)
CControl::EventProcess(event);
- if (event.type == EVENT_MOUSE_MOVE && Detect(event.mouseMove.pos)) {
+ if (event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos)) {
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
for (i = 0; i < m_displayLine; i++) {
if (i + m_firstLine >= m_totalLine)
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 4bfce41..5a9e886 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -2096,8 +2096,8 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
- m_glintMouse = event.pos;
- NiceParticle(event.pos, event.trackedKeys & TRKEY_NUM_LEFT);
+ m_glintMouse = event.mousePos;
+ NiceParticle(event.mousePos, event.mouseButtonsState & MOUSE_BUTTON_LEFT);
}
if ( m_bDialog ) // this dialogue?
@@ -2105,7 +2105,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_interface->EventProcess(event);
if ( event.type == EVENT_DIALOG_OK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN) ) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN) ) )
{
StopDialog();
if ( m_phase == PHASE_NAME )
@@ -2131,7 +2131,7 @@ bool CMainDialog::EventProcess(const Event &event)
}
}
if ( event.type == EVENT_DIALOG_CANCEL ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE) ) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE) ) )
{
StopDialog();
}
@@ -2177,7 +2177,7 @@ bool CMainDialog::EventProcess(const Event &event)
switch( event.type )
{
case EVENT_KEY_DOWN:
- if ( event.param == KEY(ESCAPE) )
+ if ( event.key.key == KEY(ESCAPE) )
{
//? StartQuit(); // would you leave?
m_sound->Play(SOUND_TZOING);
@@ -2238,11 +2238,11 @@ bool CMainDialog::EventProcess(const Event &event)
switch( event.type )
{
case EVENT_KEY_DOWN:
- if ( event.param == KEY(RETURN) )
+ if ( event.key.key == KEY(RETURN) )
{
NameSelect();
}
- if ( event.param == KEY(ESCAPE) )
+ if ( event.key.key == KEY(ESCAPE) )
{
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
@@ -2295,11 +2295,11 @@ bool CMainDialog::EventProcess(const Event &event)
switch( event.type )
{
case EVENT_KEY_DOWN:
- if ( event.param == KEY(RETURN) )
+ if ( event.key.key == KEY(RETURN) )
{
m_main->ChangePhase(PHASE_INIT);
}
- if ( event.param == KEY(ESCAPE) )
+ if ( event.key.key == KEY(ESCAPE) )
{
m_main->ChangePhase(PHASE_NAME);
}
@@ -2430,7 +2430,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == pw->GetEventTypeClose() ||
event.type == EVENT_INTERFACE_BACK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
{
m_main->ChangePhase(PHASE_INIT);
return false;
@@ -2502,7 +2502,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == pw->GetEventTypeClose() ||
event.type == EVENT_INTERFACE_BACK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
{
SetupMemorize();
m_engine->ApplyChange();
@@ -2548,7 +2548,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == pw->GetEventTypeClose() ||
event.type == EVENT_INTERFACE_BACK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
{
SetupMemorize();
m_engine->ApplyChange();
@@ -2920,7 +2920,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == pw->GetEventTypeClose() ||
event.type == EVENT_INTERFACE_BACK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
{
ChangePhase(m_phaseTerm);
}
@@ -2953,7 +2953,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == pw->GetEventTypeClose() ||
event.type == EVENT_INTERFACE_BACK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) )
{
m_interface->DeleteControl(EVENT_WINDOW5);
ChangePhase(PHASE_SIMUL);
@@ -3027,7 +3027,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( event.type == EVENT_KEY_DOWN )
{
- if ( event.param == KEY(ESCAPE) )
+ if ( event.key.key == KEY(ESCAPE) )
{
ChangePhase(PHASE_INIT);
}
@@ -4822,6 +4822,8 @@ void CMainDialog::UpdateSceneChap(int &chap)
pl->SetCheck(j, bPassed);
pl->SetEnable(j, true);
+ continue;
+
if ( m_phase == PHASE_MISSION && !m_main->GetShowAll() && !bPassed )
{
j ++;
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index 3a3d30f..43d9b7b 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -187,15 +187,15 @@ bool CMap::EventProcess(const Event &event)
if ( event.type == EVENT_FRAME )
m_time += event.rTime;
- if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) {
+ if ( event.type == EVENT_MOUSE_MOVE && Detect(event.mousePos) ) {
m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
- if ( DetectObject(event.mouseMove.pos, bInMap) != 0 )
+ if ( DetectObject(event.mousePos, bInMap) != 0 )
m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
- if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) {
- if ( CControl::Detect(event.mouseButton.pos) ) {
- SelectObject(event.mouseButton.pos);
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == MOUSE_BUTTON_LEFT ) {
+ if ( CControl::Detect(event.mousePos) ) {
+ SelectObject(event.mousePos);
return false;
}
}
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index d3d0ed2..17f210e 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -234,21 +234,21 @@ bool CScroll::EventProcess(const Event &event)
hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
pos.y = m_pos.y+hButton;
dim.y = m_dim.y-hButton*2.0f;
pos.y += dim.y*(1.0f-m_visibleRatio)*(1.0f-m_visibleValue);
dim.y *= m_visibleRatio;
- if ( event.mouseButton.pos.y < pos.y ||
- event.mouseButton.pos.y > pos.y+dim.y ) // click outside cabin?
+ if ( event.mousePos.y < pos.y ||
+ event.mousePos.y > pos.y+dim.y ) // click outside cabin?
{
h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio);
- value = 1.0f-(event.mouseButton.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h;
+ value = 1.0f-(event.mousePos.y-(m_pos.y+hButton+dim.y*0.5f))/h;
if ( value < 0.0f ) value = 0.0f;
if ( value > 1.0f ) value = 1.0f;
m_visibleValue = value;
@@ -259,7 +259,7 @@ bool CScroll::EventProcess(const Event &event)
m_event->AddEvent(newEvent);
}
m_bCapture = true;
- m_pressPos = event.mouseButton.pos;
+ m_pressPos = event.mousePos;
m_pressValue = m_visibleValue;
}
}
@@ -269,7 +269,7 @@ bool CScroll::EventProcess(const Event &event)
h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio);
if ( h != 0 )
{
- value = m_pressValue - (event.mouseMove.pos.y-m_pressPos.y)/h;
+ value = m_pressValue - (event.mousePos.y-m_pressPos.y)/h;
if ( value < 0.0f ) value = 0.0f;
if ( value > 1.0f ) value = 1.0f;
@@ -286,7 +286,7 @@ bool CScroll::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_UP &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
m_bCapture )
{
m_bCapture = false;
@@ -294,7 +294,7 @@ bool CScroll::EventProcess(const Event &event)
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_UP &&
- Detect(event.mouseWheel.pos) &&
+ Detect(event.mousePos) &&
m_buttonUp != 0)
{
Event newEvent = event;
@@ -303,7 +303,7 @@ bool CScroll::EventProcess(const Event &event)
}
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_DOWN &&
- Detect(event.mouseWheel.pos) &&
+ Detect(event.mousePos) &&
m_buttonDown != 0)
{
Event newEvent = event;
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index c8d3890..18b8f31 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -67,9 +67,9 @@ bool CShortcut::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1)
+ event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
Event newEvent = event;
newEvent.type = m_eventType;
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index 70dd2cc..ca907fe 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -284,24 +284,24 @@ bool CSlider::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- (event.mouseButton.button == 1 ) &&
+ (event.mouseButton.button == MOUSE_BUTTON_LEFT ) &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
if ( m_bHoriz )
{
pos.x = m_pos.x+m_marginButton;
dim.x = m_dim.x-m_marginButton*2.0f;
- value = (event.mouseButton.pos.x-pos.x-CURSOR_WIDTH/2.0f);
+ value = (event.mousePos.x-pos.x-CURSOR_WIDTH/2.0f);
value /= (dim.x-CURSOR_WIDTH);
}
else
{
pos.y = m_pos.y+m_marginButton;
dim.y = m_dim.y-m_marginButton*2.0f;
- value = (event.mouseButton.pos.y-pos.y-CURSOR_WIDTH/2.0f);
+ value = (event.mousePos.y-pos.y-CURSOR_WIDTH/2.0f);
value /= (dim.y-CURSOR_WIDTH);
}
if ( value < 0.0f ) value = 0.0f;
@@ -314,7 +314,7 @@ bool CSlider::EventProcess(const Event &event)
m_event->AddEvent(newEvent);
m_bCapture = true;
- m_pressPos = event.mouseButton.pos;
+ m_pressPos = event.mousePos;
m_pressValue = m_visibleValue;
}
}
@@ -325,14 +325,14 @@ bool CSlider::EventProcess(const Event &event)
{
pos.x = m_pos.x+m_marginButton;
dim.x = m_dim.x-m_marginButton*2.0f;
- value = (event.mouseMove.pos.x-pos.x-CURSOR_WIDTH/2.0f);
+ value = (event.mousePos.x-pos.x-CURSOR_WIDTH/2.0f);
value /= (dim.x-CURSOR_WIDTH);
}
else
{
pos.y = m_pos.y+m_marginButton;
dim.y = m_dim.y-m_marginButton*2.0f;
- value = (event.mouseMove.pos.y-pos.y-CURSOR_WIDTH/2.0f);
+ value = (event.mousePos.y-pos.y-CURSOR_WIDTH/2.0f);
value /= (dim.y-CURSOR_WIDTH);
}
if ( value < 0.0f ) value = 0.0f;
@@ -350,7 +350,7 @@ bool CSlider::EventProcess(const Event &event)
}
if ( ( event.type == EVENT_MOUSE_BUTTON_UP ) &&
- ( event.mouseButton.button == 1 ) &&
+ ( event.mouseButton.button == MOUSE_BUTTON_LEFT ) &&
m_bCapture )
{
m_bCapture = false;
@@ -358,7 +358,7 @@ bool CSlider::EventProcess(const Event &event)
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_UP &&
- Detect(event.mouseWheel.pos) &&
+ Detect(event.mousePos) &&
m_buttonLeft != 0)
{
Event newEvent = event;
@@ -367,8 +367,8 @@ bool CSlider::EventProcess(const Event &event)
}
if (event.type == EVENT_MOUSE_WHEEL &&
- event.mouseButton.button == WHEEL_DOWN &&
- Detect(event.mouseWheel.pos) &&
+ event.mouseWheel.dir == WHEEL_DOWN &&
+ Detect(event.mousePos) &&
m_buttonRight != 0)
{
Event newEvent = event;
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index c546c57..a581baa 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -242,7 +242,7 @@ bool CStudio::EventProcess(const Event &event)
if ( event.type == EVENT_KEY_DOWN )
{
if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).key ||
- event.param == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy )
+ event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy )
{
if ( m_helpFilename.length() > 0 )
{
@@ -1355,7 +1355,7 @@ bool CStudio::EventDialog(const Event &event)
}
if ( event.type == EVENT_DIALOG_OK ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN)) )
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(RETURN)) )
{
if ( m_dialog == SD_OPEN )
{
@@ -1371,7 +1371,7 @@ bool CStudio::EventDialog(const Event &event)
}
if ( event.type == EVENT_DIALOG_CANCEL ||
- (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ||
+ (event.type == EVENT_KEY_DOWN && event.key.key == KEY(ESCAPE)) ||
event.type == pw->GetEventTypeClose() )
{
StopDialog();
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index f398e58..b47ba16 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -59,7 +59,7 @@ bool CTarget::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
Event newEvent = event;
@@ -70,11 +70,11 @@ bool CTarget::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
Event newEvent = event;
newEvent.type = EVENT_OBJECT_FIRE;
@@ -96,9 +96,9 @@ bool CTarget::EventProcess(const Event &event)
{
m_main->SetFriendAim(false);
- if ( CControl::Detect(event.mouseMove.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
- pObj = DetectFriendObject(event.mouseMove.pos);
+ pObj = DetectFriendObject(event.mousePos);
if ( pObj == 0 )
{
m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
@@ -117,11 +117,11 @@ bool CTarget::EventProcess(const Event &event)
}
if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1 &&
+ event.mouseButton.button == MOUSE_BUTTON_LEFT &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.mouseButton.pos) )
+ if ( CControl::Detect(event.mousePos) )
{
if ( !m_main->GetFriendAim() )
{
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 4967795..97daf94 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -949,9 +949,9 @@ bool CWindow::EventProcess(const Event &event)
m_pressMouse = Gfx::ENG_MOUSE_NORM;
if ( m_name.length() > 0 && m_bMovable && // title bar?
- Detect(event.pos) )
+ Detect(event.mousePos) )
{
- flags = BorderDetect(event.pos);
+ flags = BorderDetect(event.mousePos);
if ( flags == -1 )
{
m_pressMouse = Gfx::ENG_MOUSE_MOVE; // +
@@ -1011,17 +1011,17 @@ bool CWindow::EventProcess(const Event &event)
}
if ( m_bTrashEvent && event.type == EVENT_MOUSE_BUTTON_DOWN &&
- event.mouseButton.button == 1)
+ event.mouseButton.button == MOUSE_BUTTON_LEFT)
{
- if ( Detect(event.pos) )
+ if ( Detect(event.mousePos) )
{
if ( m_name.length() > 0 && m_bMovable ) // title bar?
{
- m_pressFlags = BorderDetect(event.pos);
+ m_pressFlags = BorderDetect(event.mousePos);
if ( m_pressFlags != 0 )
{
m_bCapture = true;
- m_pressPos = event.pos;
+ m_pressPos = event.mousePos;
}
}
return false;
@@ -1030,7 +1030,7 @@ bool CWindow::EventProcess(const Event &event)
if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
- pos = event.pos;
+ pos = event.mousePos;
if ( m_pressFlags == -1 ) // all moves?
{
m_pos.x += pos.x-m_pressPos.x;
@@ -1081,7 +1081,7 @@ bool CWindow::EventProcess(const Event &event)
m_event->AddEvent(newEvent);
}
- if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 && m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == MOUSE_BUTTON_LEFT && m_bCapture )
{
m_bCapture = false;
}