Skip to content

Commit

Permalink
Merge pull request #121 from caiiiycuk/html5
Browse files Browse the repository at this point in the history
Gpx Patch
  • Loading branch information
IonAgorria authored Feb 19, 2024
2 parents 1e11d31 + 35a342c commit 5343bd2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
39 changes: 31 additions & 8 deletions Source/Game/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ int terScreenIndex = 0;
#ifdef GPX
constexpr int terFullScreen = 0;
constexpr int terResizableWindow = 0;
bool isRuntimePaused = false;
#else
int terFullScreen = 0;
int terResizableWindow = 1;
Expand Down Expand Up @@ -577,10 +578,14 @@ cInterfaceRenderDevice* SetGraph()
terBitPerPixel = 32;
terScreenSizeX = gpx()->sys()->getWidth();
terScreenSizeY = gpx()->sys()->getHeight();
if (terScreenSizeY < 720) {
terScreenSizeY = 720;
terScreenSizeX = 720.0f * gpx()->sys()->getWidth() / gpx()->sys()->getHeight();
SDL_DisplayMode dm;
SDL_GetCurrentDisplayMode(0, &dm);
auto minHeight = min(dm.h, 960);
if (terScreenSizeY < minHeight) {
terScreenSizeY = minHeight;
terScreenSizeX = (float) minHeight * gpx()->sys()->getWidth() / gpx()->sys()->getHeight();
}
printf("Display size: %dx%d, screen height %d, min height %d\n", terScreenSizeX, terScreenSizeY, dm.h, minHeight);
int ModeRender = RENDERDEVICE_MODE_RGB32 | RENDERDEVICE_MODE_WINDOW;
#else
int ModeRender=0;
Expand Down Expand Up @@ -912,6 +917,15 @@ char* alloc_exec_arg_string(std::string arg, bool wrap_spaces) {
strcpy(str, arg.c_str());
return str;
}
#ifdef GPX
void pauseRuntime() {
isRuntimePaused = true;
}

void resumeRuntime() {
isRuntimePaused = false;
}
#endif

int SDL_main(int argc, char *argv[])
{
Expand Down Expand Up @@ -995,6 +1009,15 @@ int SDL_main(int argc, char *argv[])

bool run = true;
while (run) {
#ifdef GPX
if (isRuntimePaused) {
#ifdef EMSCRIPTEN
emscripten_sleep(0);
continue;
#endif
}
#endif

app_event_poll();

//NetworkPause handler
Expand Down Expand Up @@ -1025,14 +1048,14 @@ int SDL_main(int argc, char *argv[])
#ifdef GPX
static bool gpx_ready = false;
if (!gpx_ready) {
gpx_ready = false;
gpx_ready = true;
#ifdef EMSCRIPTEN
EM_ASM(({
if (!document.pointerLockElement) {
Module["canvas"].addEventListener("pointerdown", () => {
Module["canvas"].addEventListener("pointerdown", () => {
if (!document.pointerLockElement) {
Module["canvas"].requestPointerLock().catch((e) => console.error("Can't lock mouse", e));
});
}
}
});
}));
#endif
gpx()->sys()->mainReady(true);
Expand Down
3 changes: 2 additions & 1 deletion Source/Game/Texts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gamepix.com&FFFFFF
&CCCCFFВеб версия&FFFFFF
Александр "caiiiycuk" Гурьянов
Станислав "sta3ik" Павлов
&66CCFFК-Д ЛАБ
Expand All @@ -37,7 +38,7 @@ gamepix.com&FFFFFF
&CCCCFFWeb Version&FFFFFF
Alexander "caiiiycuk" Guryanov
Stanislav "sta3ik" Pavlov
&66CCFFK-D LAB
kdlab.com&FFFFFF
Expand Down
7 changes: 7 additions & 0 deletions Source/UserInterface/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,14 @@ int SwitchMenuBGQuant2( float, float ) {
switch (_id_on) {
case SQSH_MM_START_SCR:
//Only enable if user didn't choose a specific content
#ifdef GPX
_shellIconManager.GetWnd(SQSH_MM_QUIT_BTN)->Enable(false);
_shellIconManager.GetWnd(SQSH_MM_LANG_BTN)->Enable(false);
_shellIconManager.GetWnd(SQSH_MM_CONTENT_CHOOSER_BTN)->Enable(false);
_shellIconManager.GetWnd(SQSH_MM_MULTIPLAYER_BTN)->Enable(false);
#else
_shellIconManager.GetWnd(SQSH_MM_MULTIPLAYER_BTN)->Enable(terGameContentAvailable == terGameContentSelect);
#endif
break;
case SQSH_MM_SINGLE_SCR:
//Only enable if user didn't choose a specific content
Expand Down
9 changes: 8 additions & 1 deletion Source/UserInterface/ReelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ void ReelManager::showModal(const char* videoFileName, const char* soundFileName
}
}

#ifdef GPX
while (!player->IsEnd()) {
player->Update();
}
#else

Vect2i picSize;
Vect2i showPos;
switch (sizeType) {
Expand Down Expand Up @@ -122,7 +128,7 @@ void ReelManager::showModal(const char* videoFileName, const char* soundFileName
terRenderDevice->BeginScene();
terRenderDevice->EndScene();
terRenderDevice->Flush();

#endif
delete player;
player = NULL;
RELEASE(bgTexture);
Expand Down Expand Up @@ -195,4 +201,5 @@ void ReelManager::showPictureModal(const char* pictureFileName, int stableTime)
// RELEASE(bgTexture);

hide();

}
2 changes: 1 addition & 1 deletion Source/UserInterface/UserSingleProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void UserSingleProfile::addProfile(const std::string& name) {
bool UserSingleProfile::removeDir(const std::string& dir) {
std::error_code error;
std::string allSaves = getAllSavesDirectory();
std::filesystem::path target_path = std::filesystem::u8path(allSaves + PATH_SEP + dir);
std::filesystem::path target_path = std::filesystem::u8path(allSaves + dir);
std::filesystem::remove_all(target_path, error);
if( error ) {
ErrH.Abort("Can't remove profile directory: ", XERR_USER, error.value(), error.message().c_str());
Expand Down

0 comments on commit 5343bd2

Please sign in to comment.