Working on minor stuff, arts, settings, cutscenes

This commit is contained in:
Vladislav Khorev committed 2026-07-04 17:33:01 +03:00
1 parent 5516d02e2c
commit f7e63f933b
31 files changed
+237 -1881

No files matched your search

+33 -1
View File
@@ -8,9 +8,14 @@
#else
#include <GL/gl.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten/html5.h>
#endif
namespace ZL {
int Environment::windowHeaderHeight = 0;
int Environment::width = CONST_DEFAULT_WIDTH;
@@ -20,6 +25,12 @@ float Environment::zoom = DEFAULT_ZOOM;
SDL_Window* Environment::window = nullptr;
#ifdef EMSCRIPTEN
bool Environment::isFullscreen = false;
#else
bool Environment::isFullscreen = true;
#endif
bool Environment::showMouse = false;
bool Environment::exitGameLoop = false;
@@ -55,4 +66,25 @@ void Environment::computeProjectionDimensions()
}
}
void Environment::setFullscreen(bool enable) {
#ifdef EMSCRIPTEN
if (enable) {
EmscriptenFullscreenStrategy strategy{};
strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
emscripten_request_fullscreen_strategy("#canvas", EM_TRUE, &strategy);
} else {
emscripten_exit_fullscreen();
}
// isFullscreen is updated by onFullscreenChanged once the browser confirms —
// the request above is deferred/async and can fail silently (e.g. denied).
#else
if (window) {
SDL_SetWindowFullscreen(window, enable ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
}
isFullscreen = enable;
#endif
}
} // namespace ZL
+3
View File
@@ -30,6 +30,9 @@ public:
static SDL_Window* window;
static bool isFullscreen;
static void setFullscreen(bool enable);
static bool showMouse;
static bool exitGameLoop;
+31 -1
View File
@@ -15,7 +15,6 @@
#include <android/log.h>
#endif
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif
@@ -1508,12 +1507,24 @@ namespace ZL
currentLocation()->state.isNight = gameState.isNight;
currentLocation()->scriptEngine.callTriggerNightEnterCallback();
}
audioPlayer->crossFadeMusicAsync("audio/bishkek night.ogg");
} else {
gameState.isDarklands = !gameState.isDarklands;
// Change HUD
menuManager.setDarklandsMode(gameState.isDarklands);
if (gameState.isDarklands)
{
audioPlayer->crossFadeMusicAsync("audio/bishkek fight calm.ogg");
}
else
{
audioPlayer->crossFadeMusicAsync("audio/bishkek night.ogg");
}
if (currentLocation()) {
currentLocation()->state.isDarklands = gameState.isDarklands;
if (gameState.isDarklands)
@@ -1622,6 +1633,25 @@ namespace ZL
} catch (const std::exception& e) {
std::cerr << "[save] Failed to parse save file " << path << ": " << e.what() << std::endl;
}
if (gameState.isDarklands)
{
audioPlayer->crossFadeMusicAsync("audio/bishkek fight calm.ogg");
}
else if (gameState.isNight)
{
audioPlayer->crossFadeMusicAsync("audio/bishkek night.ogg");
}
else
{
if (gameState.currentLocationName == "location_dorm") {
audioPlayer->crossFadeMusicAsync("audio/obshaga.ogg");
}
else
{
audioPlayer->crossFadeMusicAsync("audio/bishkek univer day.ogg");
}
}
}
} // namespace ZL
+2 -1
View File
@@ -93,7 +93,8 @@ namespace ZL
interactiveObjects = GameObjectLoader::loadAndCreateInteractiveObjects(params.interactiveObjectsJsonPath, renderer, CONST_ZIP_FILE);
//auto playerTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/gg/IMG_20260413_182354_992.png", CONST_ZIP_FILE));
auto playerTexture = renderer.textureManager.LoadFromPng("resources/w/gg/UniV_Grid_2K_Base_color.png", CONST_ZIP_FILE);
//auto playerTexture = renderer.textureManager.LoadFromPng("resources/w/gg/UniV_Grid_2K_Base_color.png", CONST_ZIP_FILE);
auto playerTexture = renderer.textureManager.LoadFromPng("resources/w/gg/UniV_Grid_2K_Base_color001.png", CONST_ZIP_FILE);
auto sparkTexture = renderer.textureManager.LoadFromPng("resources/w/spark.png", CONST_ZIP_FILE);
+22
View File
@@ -360,9 +360,17 @@ namespace ZL {
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
};
auto refreshFullscreenToggle = [this]() {
const bool on = Environment::isFullscreen;
uiManager.setTextButtonText("fullScreenToggleButton", on ? "Full Screen: ON" : "Full Screen: OFF");
uiManager.setTextButtonColor("fullScreenToggleButton", on
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
};
refreshMusicToggle();
refreshSoundToggle();
refreshFullscreenToggle();
uiManager.setTextButtonCallback("musicToggleButton", [this](const std::string&) {
audioPlayer_.setMusicEnabled(!audioPlayer_.isMusicEnabled());
@@ -380,6 +388,10 @@ namespace ZL {
? std::array<float, 4>{ 0.2f, 0.9f, 0.2f, 1.0f }
: std::array<float, 4>{ 0.9f, 0.2f, 0.2f, 1.0f });
});
uiManager.setTextButtonCallback("fullScreenToggleButton", [this, refreshFullscreenToggle](const std::string&) {
Environment::setFullscreen(!Environment::isFullscreen);
refreshFullscreenToggle();
});
}
void MenuManager::showLoadGameScreen()
@@ -1783,6 +1795,7 @@ namespace ZL {
root["soundVolume"] = audioPlayer_.getSoundVolume();
root["musicEnabled"] = audioPlayer_.isMusicEnabled();
root["soundEnabled"] = audioPlayer_.isSoundEnabled();
root["fullscreen"] = Environment::isFullscreen;
std::ofstream file("settings.json");
if (file.is_open()) {
@@ -1793,6 +1806,10 @@ namespace ZL {
}
void MenuManager::loadSettings() {
// Note: on desktop, main() already reads settings.json and creates the window
// directly in the right fullscreen state (see WIN32 main() in main.cpp) to avoid
// a windowed -> fullscreen flash. The block below just keeps Environment::isFullscreen
// in sync in case this is ever called from a path that didn't pre-apply it.
const std::string content = ZL::readTextFile("settings.json");
if (content.empty()) return;
try {
@@ -1805,6 +1822,11 @@ namespace ZL {
audioPlayer_.setMusicEnabled(root["musicEnabled"].get<bool>());
if (root.contains("soundEnabled"))
audioPlayer_.setSoundEnabled(root["soundEnabled"].get<bool>());
if (root.contains("fullscreen")) {
#ifndef EMSCRIPTEN
Environment::setFullscreen(root["fullscreen"].get<bool>());
#endif
}
} catch (const std::exception& e) {
std::cerr << "[settings] Failed to parse settings.json: " << e.what() << std::endl;
}
+24 -5
View File
@@ -1,5 +1,6 @@
#include "Game.h"
#include "Environment.h"
#include "utils/Utils.h"
#include <iostream>
#ifdef __ANDROID__
#include <android/log.h>
@@ -85,6 +86,8 @@ EM_BOOL onWindowResized(int /*eventType*/, const EmscriptenUiEvent* e, void* /*u
}
EM_BOOL onFullscreenChanged(int /*eventType*/, const EmscriptenFullscreenChangeEvent* e, void* /*userData*/) {
ZL::Environment::isFullscreen = e->isFullscreen;
// Вместо window.innerWidth, попробуйте запросить размер целевого элемента
// так как после перехода в FS именно он растягивается на весь экран.
double clientW, clientH;
@@ -245,11 +248,27 @@ int main(int argc, char *argv[]) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#ifdef FULLSCREEN
const Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
const Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE;
#endif
// Read the persisted fullscreen preference (if any) before creating the
// window, so it opens directly in the right mode instead of flashing
// windowed -> fullscreen once settings are loaded later during setupPart2().
{
const std::string settingsContent = ZL::readTextFile("settings.json");
if (!settingsContent.empty()) {
try {
const nlohmann::json settingsRoot = nlohmann::json::parse(settingsContent);
if (settingsRoot.contains("fullscreen")) {
ZL::Environment::isFullscreen = settingsRoot["fullscreen"].get<bool>();
}
} catch (const std::exception& e) {
std::cerr << "[settings] Failed to parse settings.json: " << e.what() << std::endl;
}
}
}
Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE;
if (ZL::Environment::isFullscreen) {
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
ZL::Environment::window = SDL_CreateWindow(
"Shadow Over Bishkek",