mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 01:54:38 +02:00
#15 exit game from menu
This commit is contained in:
@@ -246,6 +246,7 @@ namespace Core {
|
||||
} settings;
|
||||
|
||||
bool resetState;
|
||||
bool isQuit;
|
||||
|
||||
int getTime() {
|
||||
return osGetTime();
|
||||
@@ -255,6 +256,10 @@ namespace Core {
|
||||
lastTime = getTime();
|
||||
resetState = true;
|
||||
}
|
||||
|
||||
void quit() {
|
||||
isQuit = true;
|
||||
}
|
||||
}
|
||||
|
||||
#include "input.h"
|
||||
@@ -550,6 +555,8 @@ namespace Core {
|
||||
tinf_init();
|
||||
#endif
|
||||
|
||||
isQuit = false;
|
||||
|
||||
Input::init();
|
||||
#ifdef ANDROID
|
||||
void *libGL = dlopen("libGLESv2.so", RTLD_LAZY);
|
||||
|
@@ -514,7 +514,12 @@ struct Inventory {
|
||||
switch (item->value) {
|
||||
case 0 : nextLevel = passportSlots[slot]; break;
|
||||
case 1 : nextLevel = level->isTitle() ? level->getStartId() : id; break;
|
||||
case 2 : nextLevel = level->isTitle() ? TR::LVL_MAX : level->getTitleId(); break;
|
||||
case 2 :
|
||||
if (!level->isTitle())
|
||||
nextLevel = level->getTitleId();
|
||||
else
|
||||
Core::quit(); // exit game
|
||||
break;
|
||||
}
|
||||
|
||||
if (nextLevel != TR::LVL_MAX) {
|
||||
|
@@ -214,12 +214,12 @@ int main(int argc, char **argv) {
|
||||
sndInit();
|
||||
Game::init(argc > 1 ? argv[1] : NULL);
|
||||
|
||||
while (1) {
|
||||
while (!Core::isQuit) {
|
||||
if (XPending(dpy)) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
if (event.type == ClientMessage && *event.xclient.data.l == WM_DELETE_WINDOW)
|
||||
break;
|
||||
Core::quit();
|
||||
WndProc(event,dpy,wnd);
|
||||
} else {
|
||||
pthread_mutex_lock(&sndMutex);
|
||||
|
@@ -1,6 +1,5 @@
|
||||
#include "game.h"
|
||||
|
||||
bool isQuit = false;
|
||||
WindowRef window;
|
||||
AGLContext context;
|
||||
|
||||
@@ -71,7 +70,7 @@ OSStatus eventHandler(EventHandlerCallRef handler, EventRef event, void* userDat
|
||||
case kEventClassWindow :
|
||||
switch (eventKind) {
|
||||
case kEventWindowClosed :
|
||||
isQuit = true;
|
||||
Core::quit();
|
||||
break;
|
||||
case kEventWindowBoundsChanged : {
|
||||
aglUpdateContext(context);
|
||||
@@ -202,7 +201,7 @@ int main() {
|
||||
ShowWindow(window);
|
||||
|
||||
EventRecord event;
|
||||
while (!isQuit)
|
||||
while (!Core::isQuit)
|
||||
if (!GetNextEvent(0xffff, &event) && Game::update()) {
|
||||
Game::render();
|
||||
aglSwapBuffers(context);
|
||||
|
@@ -468,13 +468,12 @@ int main(int argc, char **argv) {
|
||||
sndInit();
|
||||
|
||||
char *lvlName = argc > 1 ? argv[1] : NULL;
|
||||
char *sndName = argc > 2 ? argv[2] : NULL;
|
||||
|
||||
Game::init(lvlName, sndName);
|
||||
Game::init(lvlName);
|
||||
|
||||
inputInit(); // initialize and grab input devices
|
||||
|
||||
while (!Input::down[ikEscape]) {
|
||||
while (!Core::isQuit) {
|
||||
inputUpdate();
|
||||
|
||||
pthread_mutex_lock(&sndMutex);
|
||||
|
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "game.h"
|
||||
|
||||
int osStartTime = 0;
|
||||
|
||||
int osGetTime() {
|
||||
#ifdef DEBUG
|
||||
LARGE_INTEGER Freq, Count;
|
||||
@@ -24,7 +26,7 @@ int osGetTime() {
|
||||
return int(Count.QuadPart * 1000L / Freq.QuadPart);
|
||||
#else
|
||||
timeBeginPeriod(0);
|
||||
return int(timeGetTime());
|
||||
return int(timeGetTime()) - osStartTime;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -357,6 +359,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
Sound::channelsCount = 0;
|
||||
|
||||
osStartTime = osGetTime();
|
||||
|
||||
touchInit(hWnd);
|
||||
joyInit();
|
||||
sndInit(hWnd);
|
||||
@@ -371,10 +375,12 @@ int main(int argc, char** argv) {
|
||||
|
||||
MSG msg;
|
||||
|
||||
do {
|
||||
while (!Core::isQuit) {
|
||||
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
if (msg.message == WM_QUIT)
|
||||
Core::quit();
|
||||
} else {
|
||||
joyUpdate();
|
||||
if (Game::update()) {
|
||||
@@ -385,7 +391,7 @@ int main(int argc, char** argv) {
|
||||
Sleep(20);
|
||||
#endif
|
||||
}
|
||||
} while (msg.message != WM_QUIT);
|
||||
};
|
||||
|
||||
sndFree();
|
||||
Game::deinit();
|
||||
|
Reference in New Issue
Block a user