Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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 "../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)
tkey r_key (void)
int rp_key (void)
void getkeysyms (tkey *keysym, int *keyprnt)
char skeypress (tkey keynr)
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 244 of file events.cpp.

References ct_invvalue.

Referenced by tdlgengine::addbutton().

int eventthread void *  nothing  ) 
 

Definition at line 538 of file events.cpp.

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

Referenced by initializeEventHandling().

void exit_asc int  returnresult  ) 
 

Definition at line 645 of file events.cpp.

References closeEventThread.

Referenced by main().

void getkeysyms tkey keysym,
int *  keyprnt
 

Definition at line 206 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 690 of file events.cpp.

References eventQueue, and eventQueueMutex.

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

int getTicker  ) 
 

Definition at line 558 of file events.cpp.

Referenced by eventthread().

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

Definition at line 593 of file events.cpp.

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

Referenced by main().

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 684 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 tmousesettings::x, and tmousesettings::y.

int mouseinrect int  x1,
int  y1,
int  x2,
int  y2
 

Definition at line 108 of file events.cpp.

References 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(), tchoosetechnology::run(), ttributepayments::run(), tresearchinfo::run(), tchoosetechlevel::run(), tgiveunitawaydlg::run(), tshownewtanks::run(), tdialogbox::showbutton(), tshowhistoryinit(), and tstringselect::viewtext().

void ndelay int  time  ) 
 

Definition at line 280 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 703 of file events.cpp.

References eventQueue, and eventQueueMutex.

Referenced by EventSupplier::PeepEvent().

int processEvents  ) 
 

Definition at line 325 of file events.cpp.

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

Referenced by eventthread().

bool processGraphicsQueue  ) 
 

Definition at line 511 of file events.cpp.

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

Referenced by eventthread().

void queueOperation GraphicsQueueOperation gqo,
bool  wait,
bool  forceAsync
 

Definition at line 427 of file events.cpp.

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

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

tkey r_key void   ) 
 

Definition at line 158 of file events.cpp.

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

int releasetimeslice void   ) 
 

Definition at line 253 of file events.cpp.

References copy2screen(), and redrawScreen.

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

int rp_key void   ) 
 

Definition at line 182 of file events.cpp.

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

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 666 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 230 of file events.cpp.

Referenced by tviewtextwithscrolling::checkscrolling(), CargoGuiFunctions::Movement::execute(), GuiFunctions::Movement::execute(), GuiFunctions::Ascend::execute(), GuiFunctions::Descend::execute(), and researchinfo().

void starttimer void   ) 
 

Definition at line 293 of file events.cpp.

References ticker, and tticker.

char time_elapsed int  time  ) 
 

Definition at line 298 of file events.cpp.

References ticker, and tticker.

void wait void   ) 
 

Definition at line 239 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 314 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 initializeEventHandling(), and processEvents().

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(), processEvents(), r_key(), and rp_key().

queue<Uint32> keybuffer_prnt
 

Definition at line 43 of file events.cpp.

Referenced by getkeysyms(), processEvents(), r_key(), and rp_key().

queue<tkey> keybuffer_sym
 

Definition at line 42 of file events.cpp.

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

int keyTranslation[keyTranslationNum][2]
 

Initial value:

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

Definition at line 317 of file events.cpp.

Referenced by processEvents().

const int keyTranslationNum = 7
 

Definition at line 316 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(), execuseraction(), giveunitaway(), tdialogbox::intedit(), tdialogbox::knopfdruck(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), tchoice_dlg::run(), tdialogbox::run(), tstringselect::run(), tchoosetechnology::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 425 of file events.cpp.

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

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 589 of file events.cpp.

bool syncGraphics = true
 

Definition at line 422 of file events.cpp.

Referenced by queueOperation().

volatile int ticker = 0
 

Definition at line 278 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(), r_key(), rp_key(), AI::run(), tmessagedlg::run(), PlayerColorPanel::Show(), showAttackAnimation(), starttimer(), and time_elapsed().

const bool trueflag = true
 

Definition at line 65 of file events.cpp.

int tticker = 0
 

Definition at line 291 of file events.cpp.

Referenced by starttimer(), and time_elapsed().


Generated on Tue Jun 24 01:42:49 2008 for Advanced Strategic Command by  doxygen 1.4.2