Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eventmanager.cpp File Reference
#include "vegastrike.h"
#include "eventmanager.h"
#include <algorithm>
#include "cmd/base.h"
#include "gldrv/winsys.h"

Go to the source code of this file.

Functions

void ModifyMouseSensitivity (int &x, int &y)
 
EventManagerglobalEventManager (void)
 
bool hasGlobalEventManager (void)
 
static void clearDeleteQueue ()
 
void InitCallbacks (void)
 
static float MouseXTo2dX (int x)
 
static float MouseYTo2dY (int y)
 

Variables

static EventManagerglobalEventManagerPtr = NULL
 
static std::vector
< EventResponder * > 
deleteQueue
 

Function Documentation

static void clearDeleteQueue ( )
static

Definition at line 82 of file eventmanager.cpp.

References deleteQueue, and i.

Referenced by EventManager::ProcessMouseActive(), EventManager::ProcessMouseClick(), and EventManager::ProcessMousePassive().

83 {
84  while ( deleteQueue.size() ) {
85  std::vector< EventResponder* >queue( deleteQueue );
86  deleteQueue.clear();
87  for (size_t i = 0; i < queue.size(); i++)
88  delete queue[i];
89  }
90 }
bool hasGlobalEventManager ( void  )

Definition at line 48 of file eventmanager.cpp.

Referenced by EventResponder::~EventResponder().

49 {
50  return globalEventManagerPtr != NULL;
51 }
void InitCallbacks ( void  )
static float MouseXTo2dX ( int  x)
static

Definition at line 218 of file eventmanager.cpp.

References g_game, and game_data_t::x_resolution.

Referenced by EventManager::ProcessMouseActive(), EventManager::ProcessMouseClick(), and EventManager::ProcessMousePassive().

219 {
220  //2*(coord+.5)/res + 1.
221  //Puts origin in the middle of the screen, going -1 -> 1 left to right.
222  //Add .5 to put mouse in middle of pixel, rather than left side.
223  //Multiply by 2 first to reduce division error in the multiply.
224  //Do everything in double to minimize calc error and because it's faster.
225  //Result in float to round-off at the end. Gets prettier numbers. :-)
226  return ( 2.0*( (double) x+0.5 ) )/g_game.x_resolution-1.0;
227 }
static float MouseYTo2dY ( int  y)
static

Definition at line 229 of file eventmanager.cpp.

References g_game, and game_data_t::y_resolution.

Referenced by EventManager::ProcessMouseActive(), EventManager::ProcessMouseClick(), and EventManager::ProcessMousePassive().

230 {
231  //See explanation of x.
232  //This is a bit different from x because the mouse coords increase top-
233  //to-bottom, and the drawing surface y increases bottom-to-top.
234  //So we need to reflect the mouse coords around the y origin.
235  return 1.0-( 2.0*( (double) y+0.5 ) )/g_game.y_resolution;
236 }

Variable Documentation

std::vector< EventResponder* > deleteQueue
static

Definition at line 62 of file eventmanager.cpp.

Referenced by EventManager::addToDeleteQueue(), and clearDeleteQueue().

EventManager* globalEventManagerPtr = NULL
static