diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 3c82f48..4aec5dd 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -44,21 +44,27 @@ GameLoop::GameLoop(SDL_Surface *surf, GLuint *gameTextures, uint startLevel, uin nextLevelMenu.Add(new GenericMenuItem(_("Next level"), nextLevelMenuNextLevelHandler, this)); nextLevelMenu.Add(new GenericMenuItem(_("End game"), pauseMenuEndGameHandler, this)); nextLevelMenu.Add(new GenericMenuItem(_("View replay"), nextLevelMenuViewReplayHandler, this)); +#ifndef __EMSCRIPTEN__ nextLevelMenu.Add(new GenericMenuItem(_("Export video"), nextLevelMenuExportVideoHandler, this)); +#endif nextLevelMenu.SetDimensions(30, 40, 40); gameOverMenu.Add(new GenericMenuItem(_("Back to main menu"), gameOverMenuEndGameHandler, this)); gameOverMenu.Add(new GenericMenuItem(_("Restart game"), gameOverMenuRestartHandler, this)); gameOverMenu.Add(new GenericMenuItem(_("View replay"), nextLevelMenuViewReplayHandler, this)); +#ifndef __EMSCRIPTEN__ gameOverMenu.Add(new GenericMenuItem(_("Export video"), nextLevelMenuExportVideoHandler, this)); +#endif gameOverMenu.SetDimensions(30, 40, 40); lifeLostMenu.Add(new GenericMenuItem(_("Retry level"), lifeLostMenuRetryLevelHandler, this)); lifeLostMenu.Add(new GenericMenuItem(_("End game"), lifeLostMenuEndGameHandler, this)); lifeLostMenu.Add(new GenericMenuItem(_("View replay"), nextLevelMenuViewReplayHandler, this)); +#ifndef __EMSCRIPTEN__ lifeLostMenu.Add(new GenericMenuItem(_("Export video"), nextLevelMenuExportVideoHandler, this)); +#endif lifeLostMenu.SetDimensions(30, 40, 40); diff --git a/src/main.cpp b/src/main.cpp index c6f1803..bc02ec9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,6 +48,17 @@ bool resReset; bool audioHardwareInitialized; SDL_Rect **screenModes = NULL; GLuint pointer = 0; + +#ifdef __EMSCRIPTEN__ +#include +/* fredygames.com browser build: the page calls this when the tab is hidden or closed, because the + * game only writes its settings when it quits (profiles it writes along the way) */ +extern "C" EMSCRIPTEN_KEEPALIVE void fredygames_save(void) +{ + settings.Save(); + profile.Save(); +} +#endif int pointerFrame = 0; double pointerRot = 0.0; @@ -154,7 +165,12 @@ int main (int argc, char *argv[]) if (!screenModes) screenModes=SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN|SDL_HWSURFACE); +#ifdef __EMSCRIPTEN__ + /* fredygames.com browser build: one fixed size, which the page scales to the player */ + string res = "1024x768"; +#else string res = settings.get("resolution", "640x480"); +#endif int vmx = atoi(res.c_str()); int vmy = atoi(res.substr(res.find_first_of("x") + 1).c_str()); diff --git a/src/mainmenu.cpp b/src/mainmenu.cpp index 2a73d6e..5878917 100644 --- a/src/mainmenu.cpp +++ b/src/mainmenu.cpp @@ -191,7 +191,11 @@ void MainMenu::CreateOptionsMenu() resolutions.push_back(tempRes[m]); } +#ifdef __EMSCRIPTEN__ + int y = 7; /* Cancel and Apply, two items earlier without Resolution and Fullscreen (below) */ +#else int y = 9; +#endif #ifdef ENABLE_NLS y++; @@ -208,8 +212,11 @@ void MainMenu::CreateOptionsMenu() optionsMenu.Add(new OptionMenuItem(_("Language"), languages, "language", &settings, descriptions)); #endif +#ifndef __EMSCRIPTEN__ + /* fredygames.com browser build: the size is fixed and the page has its own fullscreen button */ optionsMenu.Add(new OptionMenuItem(_("Resolution"), resolutions, "resolution", &settings)); optionsMenu.Add(new BooleanMenuItem(_("Fullscreen"), &settings, "fullscreen")); +#endif optionsMenu.Add(new BooleanMenuItem(_("Show FPS"), &settings, "showFps")); optionsMenu.Add(new BooleanMenuItem(_("Colour hints"), &settings, "colourHints")); optionsMenu.Add(new BooleanMenuItem(_("Disable speed-up"), &settings, "disableSpeedup")); @@ -437,7 +444,11 @@ void optionsMenuCancelHandler(void *ptr) menuBackHandler (ptr); +#ifdef __EMSCRIPTEN__ + int y = 7; /* see MainMenu::CreateOptionsMenu */ +#else int y = 9; +#endif #ifdef ENABLE_NLS y++; diff --git a/src/mixer.cpp b/src/mixer.cpp index b6af4d6..acb8c21 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -23,7 +23,7 @@ namespace Scenes { -Mixer::Mixer(MixerMode mmode = Realtime) +Mixer::Mixer(MixerMode mmode) : mode(mmode), isPlaying(false) { mut_disposeList = SDL_CreateMutex(); diff --git a/src/ogvexport.h b/src/ogvexport.h index 72c3573..45d18fc 100644 --- a/src/ogvexport.h +++ b/src/ogvexport.h @@ -24,6 +24,22 @@ #include #include + +#ifdef __EMSCRIPTEN__ +/* fredygames.com browser build: no video export (it needs libtheora and writes an .ogv file the page + * could not offer anyway); the class stays so the replay code compiles, and does nothing */ +#include +using namespace std; +namespace Scenes +{ +class OgvExport +{ +public: + OgvExport(string, int, int, int, int = 63, int = 0, int = 192000) {} + void FeedFrame(void *, void *, bool = false) {} +}; +} +#else #include #include #include @@ -77,4 +93,5 @@ public: }; } +#endif //__EMSCRIPTEN__ #endif //__OGVEXPORT_H__ diff --git a/src/scene.cpp b/src/scene.cpp index 24cf781..8152aae 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -326,7 +326,12 @@ FrameEvents Scene::CreateFrameEvents() case SDL_KEYDOWN: ev.keyDown.push_back(event.key.keysym.sym); ev.empty = false; +#ifdef __EMSCRIPTEN__ + /* fredygames.com browser build: SDL2 has no keysym.unicode (see zazsdl12.c) */ + ev.unicode.push_back(zaz_keysym_unicode(&event.key.keysym)); +#else ev.unicode.push_back(event.key.keysym.unicode); +#endif break; case SDL_KEYUP: ev.keyUp.push_back(event.key.keysym.sym);