events.cpp File Reference

#include <queue>
#include <SDL.h>
#include <SDL_thread.h>
#include "ctype.h"
#include "../events.h"
#include "../stack.h"
#include "../basegfx.h"
#include "../global.h"
#include "../errors.h"
#include "../util/messaginghub.h"
#include "graphicsqueue.h"
#include <iostream>

Include dependency graph for events.cpp:

Go to the source code of this file.

Functions

void setMouseUpdateFlag (const bool *flag)
 passes a references which' value determines if the mouse cursor is hidden on screen updates
void mousevisible (int an)
int getmousestatus ()
int mouseTranslate (int m)
void setmouseposition (int x, int y)
void setnewmousepointer (void *picture, int hotspotx, int hotspoty)
int mouseinrect (int x1, int y1, int x2, int y2)
int mouseinrect (const tmouserect *rect)
int keypress (void)
void getkeysyms (tkey *keysym, int *keyprnt)
char skeypress (tkey keynr)
bool isKeyPressed (SDLKey key)
void wait (void)
tkey char2key (int c)
int releasetimeslice (void)
void ndelay (int time)
void starttimer (void)
char time_elapsed (int time)
int processEvents ()
void queueOperation (GraphicsQueueOperation *gqo, bool wait, bool forceAsync)
bool processGraphicsQueue ()
int eventthread (void *nothing)
int getTicker ()
int initializeEventHandling (int(*gamethread)(void *), void *data)
void exit_asc (int returnresult)
bool setEventRouting (bool queue, bool legacy)
 Defines what happens with the SDL events.
bool legacyEventSystemActive ()
bool getQueuedEvent (SDL_Event &event)
 if the events are being queue, get one.
bool peekEvent (SDL_Event &event)
 gets the next event without removing it from the queue.

Variables

volatile tmousesettings mouseparams
SDL_mutex * keyboardmutex = NULL
SDL_mutex * eventHandlingMutex = NULL
SDL_mutex * eventQueueMutex = NULL
SDL_mutex * graphicsQueueMutex = NULL
queue< tkeykeybuffer_sym
queue< Uint32 > keybuffer_prnt
queue< SDL_Event > eventQueue
bool _queueEvents = true
bool _fillLegacyEventStructures = false
volatile bool eventThreadRunning = false
std::list< GraphicsQueueOperation * > graphicsQueue
int exitprogram = 0
bool redrawScreen = false
const bool trueflag = true
const bool * mouseUpdateFlag = &trueflag
volatile int ticker = 0
int tticker = 0
volatile int closeEventThread = 0
const int keyTranslationNum = 7
int keyTranslation [keyTranslationNum][2]
bool syncGraphics = true
SigC::Signal1< void, const
SDL_Surface * > 
postScreenUpdate
SDL_Thread * secondThreadHandle = NULL
 The handle for the second thread; depending on platform this could be the event handling thread or the game thread.


Function Documentation

tkey char2key ( int  c  ) 

Definition at line 200 of file events.cpp.

References ct_invvalue.

Referenced by tdlgengine::addbutton().

int eventthread ( void *  nothing  ) 

Definition at line 505 of file events.cpp.

References closeEventThread, eventThreadRunning, getTicker(), processEvents(), processGraphicsQueue(), and ticker.

Referenced by initializeEventHandling().

void exit_asc ( int  returnresult  ) 

Definition at line 612 of file events.cpp.

References closeEventThread.

Referenced by main().

void getkeysyms ( tkey keysym,
int *  keyprnt 
)

Definition at line 157 of file events.cpp.

References keyboardmutex, keybuffer_prnt, keybuffer_sym, releasetimeslice(), and ticker.

Referenced by tdialogbox::intedit(), tdialogbox::run(), and tdialogbox::stredit().

int getmousestatus (  ) 

Definition at line 79 of file events.cpp.

Referenced by tdialogbox::buildgraphics(), tdlgengine::buttonpressed(), tdialogbox::copyvirtualframebuf(), tdialogbox::done(), tdialogbox::execbutton(), tdialogbox::run(), tstringselect::run(), and tdialogbox::showbutton().

bool getQueuedEvent ( SDL_Event &  event  ) 

if the events are being queue, get one.

Returns:
false if no event available

Definition at line 657 of file events.cpp.

References eventQueue, and eventQueueMutex.

Referenced by EventSupplier::PollEvent(), and EventSupplier::WaitEvent().

int getTicker (  ) 

Definition at line 525 of file events.cpp.

Referenced by eventthread().

int initializeEventHandling ( int(*)(void *)  gamethread,
void *  data 
)

Definition at line 560 of file events.cpp.

References closeEventThread, eventHandlingMutex, eventQueueMutex, eventthread(), gamethread(), graphicsQueueMutex, keyboardmutex, mouseparams, tmousesettings::xsize, and tmousesettings::ysize.

Referenced by main().

bool isKeyPressed ( SDLKey  key  ) 

Definition at line 187 of file events.cpp.

Referenced by CargoGuiFunctions::Movement::execute(), and GuiFunctions::MovementBase::execute().

int keypress ( void   ) 

Definition at line 146 of file events.cpp.

References keyboardmutex, and keybuffer_sym.

Referenced by tdialogbox::intedit(), tdialogbox::run(), tdialogbox::stredit(), and trunreplay::wait().

bool legacyEventSystemActive (  ) 

Definition at line 651 of file events.cpp.

References _fillLegacyEventStructures.

Referenced by choice_dlg(), chooseString(), displaymessage(), viewmessage(), and viewtextquery().

int mouseinrect ( const tmouserect rect  ) 

Definition at line 116 of file events.cpp.

References mouseparams, tmousesettings::x, tmouserect::x1, tmouserect::x2, tmousesettings::y, tmouserect::y1, and tmouserect::y2.

int mouseinrect ( int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 108 of file events.cpp.

References mouseparams, tmousesettings::x, and tmousesettings::y.

int mouseTranslate ( int  m  ) 

Definition at line 84 of file events.cpp.

Referenced by processEvents().

void mousevisible ( int  an  ) 

Definition at line 75 of file events.cpp.

Referenced by tplayerchange::anzeige(), tplayerselall::anzeige(), tdialogbox::buildgraphics(), thelpsystem::buildgraphics(), tdlgengine::buttonpressed(), tdialogbox::copyvirtualframebuf(), tdialogbox::done(), tdialogbox::execbutton(), tchoice_dlg::init(), tstringselect::init(), tgetid::init(), StringEdit::init(), tmapgenerator::init(), tplayerchange::init(), BuildingValues::init(), EditAiParam::init(), UnitPropertyEditor::init(), tres::init(), tminestrength::init(), tplayerselall::init(), tdialogbox::knopfdruck(), mapeditorMainThread(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), tchoice_dlg::run(), tviewanytext::run(), tbi3preferences::run(), ResizeMap::run(), tchoosezoomlevel::run(), MultilineEdit::run(), tdialogbox::run(), tdisplaymessage::run(), tputresourcesdlg::run(), MirrorMap::run(), ttributepayments::run(), tresearchinfo::run(), tchoosetechlevel::run(), tgiveunitawaydlg::run(), tdialogbox::showbutton(), tshowhistoryinit(), and tstringselect::viewtext().

void ndelay ( int  time  ) 

Definition at line 236 of file events.cpp.

References releasetimeslice(), and ticker.

bool peekEvent ( SDL_Event &  event  ) 

gets the next event without removing it from the queue.

Returns:
false if no event available

Definition at line 670 of file events.cpp.

References eventQueue, and eventQueueMutex.

Referenced by EventSupplier::PeepEvent().

int processEvents (  ) 

Definition at line 293 of file events.cpp.

References _fillLegacyEventStructures, _queueEvents, ct_altp, ct_shp, ct_stp, eventQueue, eventQueueMutex, exitprogram, keyboardmutex, keybuffer_prnt, keybuffer_sym, keyTranslation, keyTranslationNum, mouseparams, mouseTranslate(), queueOperation(), redrawScreen, GameMap::state, tmousesettings::taste, tmousesettings::x, tmousesettings::x1, tmousesettings::y, and tmousesettings::y1.

Referenced by eventthread().

bool processGraphicsQueue (  ) 

Definition at line 478 of file events.cpp.

References GraphicsQueueOperation::execute(), graphicsQueue, and graphicsQueueMutex.

Referenced by eventthread().

void queueOperation ( GraphicsQueueOperation gqo,
bool  wait,
bool  forceAsync 
)

Definition at line 394 of file events.cpp.

References eventThreadRunning, GraphicsQueueOperation::execute(), graphicsQueue, graphicsQueueMutex, and syncGraphics.

Referenced by processEvents(), ASC_PG_App::toggleFullscreen(), ASC_PG_ScreenUpdater::UpdateRect(), and ASC_PG_ScreenUpdater::UpdateRects().

int releasetimeslice ( void   ) 

Definition at line 209 of file events.cpp.

References copy2screen(), and redrawScreen.

Referenced by tsearchreactionfireingunits::attack(), tstringselect::done(), execaction(), tdialogbox::execbutton(), executeUserAction(), getkeysyms(), giveunitaway(), tdialogbox::intedit(), tdialogbox::knopfdruck(), ndelay(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), tchoice_dlg::run(), tdialogbox::run(), tgiveunitawaydlg::run(), trunreplay::run(), showAttackAnimation(), tdialogbox::stredit(), trunreplay::wait(), EventSupplier::WaitEvent(), and waitWithUpdate().

bool setEventRouting ( bool  queue,
bool  legacy 
)

Defines what happens with the SDL events.

Parameters:
queue Events are queued to be extracted with getQueuedEvent
legacy Events are evaluated and the global legacy structures updated
Returns:
the previous state of the event queing

Definition at line 633 of file events.cpp.

References _fillLegacyEventStructures, _queueEvents, eventQueue, and eventQueueMutex.

Referenced by ASC_PG_App::enableLegacyEventHandling(), tdialogbox::tdialogbox(), and tdialogbox::~tdialogbox().

void setmouseposition ( int  x,
int  y 
)

Definition at line 99 of file events.cpp.

void setMouseUpdateFlag ( const bool *  flag  ) 

passes a references which' value determines if the mouse cursor is hidden on screen updates

Definition at line 69 of file events.cpp.

References mouseUpdateFlag.

Referenced by ASC_PG_App::ASC_PG_App().

void setnewmousepointer ( void *  picture,
int  hotspotx,
int  hotspoty 
)

Definition at line 104 of file events.cpp.

char skeypress ( tkey  keynr  ) 

Definition at line 181 of file events.cpp.

Referenced by tviewtextwithscrolling::checkscrolling(), and researchinfo().

void starttimer ( void   ) 

Definition at line 249 of file events.cpp.

References ticker, and tticker.

char time_elapsed ( int  time  ) 

Definition at line 254 of file events.cpp.

References ticker, and tticker.

void wait ( void   ) 

Definition at line 195 of file events.cpp.


Variable Documentation

bool _fillLegacyEventStructures = false

Definition at line 46 of file events.cpp.

Referenced by legacyEventSystemActive(), processEvents(), and setEventRouting().

bool _queueEvents = true

Definition at line 45 of file events.cpp.

Referenced by processEvents(), and setEventRouting().

volatile int closeEventThread = 0

Definition at line 270 of file events.cpp.

Referenced by eventthread(), exit_asc(), and initializeEventHandling().

SDL_mutex* eventHandlingMutex = NULL

Definition at line 38 of file events.cpp.

Referenced by EventHandlingMutex::EventHandlingMutex(), initializeEventHandling(), and EventHandlingMutex::~EventHandlingMutex().

queue<SDL_Event> eventQueue

Definition at line 44 of file events.cpp.

Referenced by getQueuedEvent(), peekEvent(), processEvents(), and setEventRouting().

SDL_mutex* eventQueueMutex = NULL

Definition at line 39 of file events.cpp.

Referenced by getQueuedEvent(), initializeEventHandling(), peekEvent(), processEvents(), and setEventRouting().

volatile bool eventThreadRunning = false

Definition at line 48 of file events.cpp.

Referenced by eventthread(), and queueOperation().

int exitprogram = 0

Definition at line 53 of file events.cpp.

Referenced by processEvents().

std::list<GraphicsQueueOperation*> graphicsQueue

Definition at line 51 of file events.cpp.

Referenced by processGraphicsQueue(), and queueOperation().

SDL_mutex* graphicsQueueMutex = NULL

Definition at line 40 of file events.cpp.

Referenced by initializeEventHandling(), processGraphicsQueue(), and queueOperation().

SDL_mutex* keyboardmutex = NULL

Definition at line 37 of file events.cpp.

Referenced by getkeysyms(), initializeEventHandling(), keypress(), and processEvents().

queue<Uint32> keybuffer_prnt

Definition at line 43 of file events.cpp.

Referenced by getkeysyms(), and processEvents().

queue<tkey> keybuffer_sym

Definition at line 42 of file events.cpp.

Referenced by getkeysyms(), keypress(), and processEvents().

int keyTranslation[keyTranslationNum][2]

Initial value:

 { { 228, 132 }, 
                                             { 246, 148 }, 
                                             { 252, 129 }, 
                                             { 196, 142 }, 
                                             { 214, 153 }, 
                                             { 220, 154 }, 
                                             { 223, 225 } }

Definition at line 273 of file events.cpp.

Referenced by processEvents().

const int keyTranslationNum = 7

Definition at line 272 of file events.cpp.

Referenced by processEvents().

volatile tmousesettings mouseparams

Definition at line 35 of file events.cpp.

Referenced by tstringselect::done(), execaction(), tdialogbox::execbutton(), executeUserAction(), giveunitaway(), initializeEventHandling(), tdialogbox::intedit(), tdialogbox::knopfdruck(), mouseinrect(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), processEvents(), tchoice_dlg::run(), tdialogbox::run(), tstringselect::run(), ttributepayments::run(), tgiveunitawaydlg::run(), and tdialogbox::stredit().

const bool* mouseUpdateFlag = &trueflag

Definition at line 67 of file events.cpp.

Referenced by InitScreenOp::execute(), UpdateRectsOp::execute(), UpdateRectOp::execute(), and setMouseUpdateFlag().

SigC::Signal1<void,const SDL_Surface*> postScreenUpdate

Definition at line 392 of file events.cpp.

Referenced by UpdateRectsOp::execute(), UpdateRectOp::execute(), ReplayRecorder::start(), ASC_PG_ScreenUpdater::UpdateRect(), ASC_PG_ScreenUpdater::UpdateRects(), and waitWithUpdate().

bool redrawScreen = false

Definition at line 63 of file events.cpp.

Referenced by ASC_PG_App::eventIdle(), processEvents(), and releasetimeslice().

SDL_Thread* secondThreadHandle = NULL

The handle for the second thread; depending on platform this could be the event handling thread or the game thread.

Definition at line 556 of file events.cpp.

bool syncGraphics = true

Definition at line 389 of file events.cpp.

Referenced by queueOperation().

volatile int ticker = 0

Definition at line 234 of file events.cpp.

Referenced by tsearchreactionfireingunits::attack(), AutoProgressBar::AutoProgressBar(), benchgame(), tdlgengine::buttonpressed(), tviewtextwithscrolling::checkscrolling(), MainScreenWidget::displayMessage(), MapDisplayPG::displayUnitMovement(), eventthread(), tdialogbox::execbutton(), trunreplay::execnextreplaymove(), getkeysyms(), OverviewMapHolder::idleHandler(), MainScreenWidget::idleHandler(), PlayerColorPanel::idler(), infomessage(), MainScreenWidget::mouseScrollChecker(), ndelay(), AI::run(), tmessagedlg::run(), PlayerColorPanel::Show(), showAttackAnimation(), starttimer(), time_elapsed(), trunreplay::wait(), and waitWithUpdate().

const bool trueflag = true

Definition at line 65 of file events.cpp.

int tticker = 0

Definition at line 247 of file events.cpp.

Referenced by starttimer(), and time_elapsed().


Generated on Mon May 21 01:34:49 2012 for Advanced Strategic Command by  doxygen 1.5.1