Advanced Strategic Command
|
#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>
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 More... | |
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) |
bool | 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. More... | |
bool | legacyEventSystemActive () |
bool | getQueuedEvent (SDL_Event &event) |
if the events are being queue, get one. More... | |
bool | peekEvent (SDL_Event &event) |
gets the next event without removing it from the queue. More... | |
Variables | |
volatile tmousesettings | mouseparams |
SDL_mutex * | keyboardmutex = NULL |
SDL_mutex * | eventHandlingMutex = NULL |
SDL_mutex * | eventQueueMutex = NULL |
SDL_mutex * | graphicsQueueMutex = NULL |
queue< tkey > | keybuffer_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::signal< 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. More... | |
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 | ) |
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.
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, tmousesettings::xsize, and tmousesettings::ysize.
Referenced by main().
bool isKeyPressed | ( | SDLKey | key | ) |
Definition at line 187 of file events.cpp.
Referenced by GuiFunctions::MovementBase::execute(), and CargoGuiFunctions::Movement::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 | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Definition at line 108 of file events.cpp.
References tmousesettings::x, and tmousesettings::y.
Referenced by tdialogbox::execbutton(), tdialogbox::intedit(), tgiveunitawaydlg::run(), and tdialogbox::stredit().
int mouseinrect | ( | const tmouserect * | rect | ) |
Definition at line 116 of file events.cpp.
References tmousesettings::x, tmouserect::x1, tmouserect::x2, tmousesettings::y, tmouserect::y1, and tmouserect::y2.
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(), tmapgenerator::init(), tplayerchange::init(), tstringselect::init(), tplayerselall::init(), tchoice_dlg::init(), BuildingValues::init(), EditAiParam::init(), tres::init(), tminestrength::init(), tgetid::init(), StringEdit::init(), tdialogbox::knopfdruck(), mapeditorMainThread(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), tputresourcesdlg::run(), tviewanytext::run(), ttributepayments::run(), tdialogbox::run(), MultilineEdit::run(), tresearchinfo::run(), tchoosetechlevel::run(), tgiveunitawaydlg::run(), tchoice_dlg::run(), tbi3preferences::run(), ResizeMap::run(), tchoosezoomlevel::run(), tdisplaymessage::run(), MirrorMap::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.
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, 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(), trunreplay::run(), tdialogbox::run(), tgiveunitawaydlg::run(), tchoice_dlg::run(), showAttackAnimation(), tdialogbox::stredit(), trunreplay::wait(), EventSupplier::WaitEvent(), and waitWithUpdate().
bool setEventRouting | ( | bool | queue, |
bool | legacy | ||
) |
Defines what happens with the SDL events.
queue | Events are queued to be extracted with getQueuedEvent |
legacy | Events are evaluated and the global legacy structures updated |
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.
bool time_elapsed | ( | int | time | ) |
Definition at line 254 of file events.cpp.
void wait | ( | void | ) |
Definition at line 195 of file events.cpp.
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] |
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(), tdialogbox::intedit(), tdialogbox::knopfdruck(), tdialogbox::newknopfdruck(), tdialogbox::newknopfdruck2(), ttributepayments::run(), tdialogbox::run(), tstringselect::run(), tgiveunitawaydlg::run(), tchoice_dlg::run(), and tdialogbox::stredit().
const bool* mouseUpdateFlag = &trueflag |
Definition at line 67 of file events.cpp.
Referenced by UpdateRectOp::execute(), UpdateRectsOp::execute(), InitScreenOp::execute(), and setMouseUpdateFlag().
sigc::signal<void,const SDL_Surface*> postScreenUpdate |
Definition at line 392 of file events.cpp.
Referenced by UpdateRectOp::execute(), UpdateRectsOp::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(), MainScreenWidget::idleHandler(), OverviewMapHolder::idleHandler(), PlayerColorPanel::idler(), infomessage(), MainScreenWidget::mouseScrollChecker(), ndelay(), tmessagedlg::run(), AI::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().