Some clean up, web version prepare

This commit is contained in:
Vladislav Khorev committed 2026-07-17 21:27:47 +03:00
1 parent e9c888e2bf
commit 0975f3b9cd
104 files changed
+779 -1483

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
#include "render/Renderer.h"
#include "render/TextureManager.h"
namespace ZL
namespace FRG
{
struct MeshGroup
+2 -2
View File
@@ -37,7 +37,7 @@ bool AudioPlayerAsync::init() {
Mix_AllocateChannels(16);
initialized = true;
ZL::logger() << "AudioPlayerAsync initialized with SDL2_mixer" << std::endl;
FRG::logger() << "AudioPlayerAsync initialized with SDL2_mixer" << std::endl;
return true;
}
@@ -61,7 +61,7 @@ void AudioPlayerAsync::shutdown() {
Mix_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
initialized = false;
ZL::logger() << "AudioPlayerAsync shutdown" << std::endl;
FRG::logger() << "AudioPlayerAsync shutdown" << std::endl;
}
void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, int channel) {
+1 -1
View File
@@ -6,7 +6,7 @@
#include <sstream>
#include <cstring>
namespace ZL
namespace FRG
{
#ifdef EMSCRIPTEN
using std::min;
+1 -1
View File
@@ -3,7 +3,7 @@
#include <unordered_map>
namespace ZL
namespace FRG
{
constexpr int MAX_BONE_COUNT = 6;
constexpr int MAX_GPU_BONES = 64;
+3 -3
View File
@@ -10,7 +10,7 @@
#include "utils/Utils.h"
#include "TextModel.h"
namespace ZL {
namespace FRG {
const float ATTACK_COOLDOWN_TIME = 1.6f;
extern float x;
@@ -193,7 +193,7 @@ void Character::forceReplan() {
state.onArrivedCallbackName.clear();
}
void Character::setTexture(std::shared_ptr<ZL::Texture> texture) {
void Character::setTexture(std::shared_ptr<FRG::Texture> texture) {
for (auto& animEntry : animations) {
for (const auto& name : animEntry.second.model.meshNamesOrdered) {
meshTextures[name] = texture;
@@ -1354,4 +1354,4 @@ void Character::drawHealthBar(Renderer& renderer,
renderer.shaderManager.PopShader();
}
} // namespace ZL
} // namespace FRG
+3 -3
View File
@@ -14,7 +14,7 @@
#include "dialogue/TranslationDatabase.h"
#include "AudioPlayerAsync.h"
namespace ZL {
namespace FRG {
class TextRenderer;
@@ -40,7 +40,7 @@ public:
// Assigns a texture to a specific mesh by name.
void setTexture(const std::string& meshName, std::shared_ptr<Texture> texture);
// Assigns one texture to every mesh in every loaded animation. Call AFTER loading animations.
void setTexture(std::shared_ptr<ZL::Texture> texture);
void setTexture(std::shared_ptr<FRG::Texture> texture);
// Creates a fully-loaded Character from a CharacterState (including its creationInfo).
// Loads all animations, textures, and weapon mesh/texture from the paths stored in creationInfo.
@@ -158,4 +158,4 @@ private:
const Eigen::Matrix4f& lightFromCamera, GLuint shadowMapTex, const float* ambientColor, const float* fogColor);
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -1,6 +1,6 @@
#include "CharacterState.h"
namespace ZL {
namespace FRG {
bool CharacterState::isMoving() const {
Eigen::Vector3f toTarget = walkTarget - position;
@@ -92,4 +92,4 @@ void CharacterState::load(const nlohmann::json& in)
onArrivedCallbackName = in.value("onArrivedCallbackName", std::string());
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -8,7 +8,7 @@
#include "external/nlohmann/json.hpp"
#include "ISaveable.h"
namespace ZL {
namespace FRG {
constexpr float VISIBLE_RANGE = 6.f;
@@ -141,4 +141,4 @@ public:
void load(const nlohmann::json& in) override;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -13,7 +13,7 @@
#include <emscripten/html5.h>
#endif
namespace ZL {
namespace FRG {
@@ -92,4 +92,4 @@ void Environment::setFullscreen(bool enable) {
#endif
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -7,7 +7,7 @@
#endif
#include <Eigen/Dense>
namespace ZL {
namespace FRG {
#ifdef EMSCRIPTEN
@@ -64,4 +64,4 @@ public:
static void computeProjectionDimensions();
};
} // namespace ZL
} // namespace FRG
+29 -29
View File
@@ -24,7 +24,7 @@
#include "GameConstants.h"
namespace ZL
namespace FRG
{
static const float zoomMin = 6.0f;
static const float zoomMax = 20.0f;
@@ -85,8 +85,8 @@ namespace ZL
Environment::height = Environment::CONST_DEFAULT_HEIGHT;
Environment::computeProjectionDimensions();
ZL::BindOpenGlFunctions();
ZL::CheckGlError(__FILE__, __LINE__);
FRG::BindOpenGlFunctions();
FRG::CheckGlError(__FILE__, __LINE__);
renderer.InitOpenGL();
#if defined(EMSCRIPTEN)
@@ -152,7 +152,7 @@ namespace ZL
// (e.g. resources/start_dorm.lua) start a dialogue as soon as they're
// loaded, so the language needs to be known before that first load.
loadSteps.push([this]() {
ZL::loadLanguageSetting();
FRG::loadLanguageSetting();
});
loadSteps.push([this]() {
@@ -165,7 +165,7 @@ namespace ZL
renderer.shaderManager.AddShaderFromFiles("spark", "resources/shaders/spark.vertex", "resources/shaders/spark_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("skinning", "resources/shaders/skinning.vertex", "resources/shaders/default_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog", "resources/shaders/fog.vertex", "resources/shaders/fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_skinning", "resources/shaders/fog_skinning.vertex", "resources/shaders/fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_skinning", "resources/shaders/fog_skinning_web.vertex", "resources/shaders/fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("darklands_fog", "resources/shaders/darklands_fog.vertex", "resources/shaders/darklands_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("darklands_fog_skinning", "resources/shaders/darklands_fog_skinning.vertex", "resources/shaders/darklands_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("darklands_flash", "resources/shaders/default.vertex", "resources/shaders/darklands_flash_web.fragment", CONST_ZIP_FILE);
@@ -173,15 +173,15 @@ namespace ZL
renderer.shaderManager.AddShaderFromFiles("cutsceneBlack", "resources/shaders/default.vertex", "resources/shaders/cutscene_black_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("shadow_depth", "resources/shaders/shadow_depth.vertex", "resources/shaders/shadow_depth_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("shadow_depth_skinning", "resources/shaders/shadow_depth_skinning.vertex", "resources/shaders/shadow_depth_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("default_shadow", "resources/shaders/default_shadow.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("skinning_shadow", "resources/shaders/skinning_shadow.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_shadow", "resources/shaders/fog_shadow.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_skinning_shadow", "resources/shaders/fog_skinning_shadow.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog", "resources/shaders/night_fog.vertex", "resources/shaders/night_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_skinning", "resources/shaders/night_fog_skinning.vertex", "resources/shaders/night_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_shadow", "resources/shaders/night_fog_shadow.vertex", "resources/shaders/night_fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_skinning_shadow", "resources/shaders/night_fog_skinning_shadow.vertex", "resources/shaders/night_fog_shadow_web.fragment", CONST_ZIP_FILE);
#elif defined(__linux__)
renderer.shaderManager.AddShaderFromFiles("default_shadow", "resources/shaders/default_shadow_web.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("skinning_shadow", "resources/shaders/skinning_shadow_web.vertex", "resources/shaders/default_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_shadow", "resources/shaders/fog_shadow_web.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("fog_skinning_shadow", "resources/shaders/fog_skinning_shadow_web.vertex", "resources/shaders/fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog", "resources/shaders/night_fog_web.vertex", "resources/shaders/night_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_skinning", "resources/shaders/night_fog_skinning_web.vertex", "resources/shaders/night_fog_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_shadow", "resources/shaders/night_fog_shadow_web.vertex", "resources/shaders/night_fog_shadow_web.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_skinning_shadow", "resources/shaders/night_fog_skinning_shadow_web.vertex", "resources/shaders/night_fog_shadow_web.fragment", CONST_ZIP_FILE);
/*#elif defined(__linux__)
renderer.shaderManager.AddShaderFromFiles("env_sky", "resources/shaders/env_sky.vertex", "resources/shaders/env_sky_desktop.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("defaultAtmosphere", "resources/shaders/defaultAtmosphere.vertex", "resources/shaders/defaultAtmosphere_desktop.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("planetBake", "resources/shaders/planet_bake.vertex", "resources/shaders/planet_bake_desktop.fragment", CONST_ZIP_FILE);
@@ -207,7 +207,7 @@ namespace ZL
renderer.shaderManager.AddShaderFromFiles("night_fog_shadow", "resources/shaders/night_fog_shadow.vertex", "resources/shaders/night_fog_shadow_desktop.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("night_fog_skinning_shadow", "resources/shaders/night_fog_skinning_shadow.vertex", "resources/shaders/night_fog_shadow_desktop.fragment", CONST_ZIP_FILE);
*/
#else
renderer.shaderManager.AddShaderFromFiles("env_sky", "resources/shaders/env_sky.vertex", "resources/shaders/env_sky_desktop.fragment", CONST_ZIP_FILE);
renderer.shaderManager.AddShaderFromFiles("defaultAtmosphere", "resources/shaders/defaultAtmosphere.vertex", "resources/shaders/defaultAtmosphere_desktop.fragment", CONST_ZIP_FILE);
@@ -444,7 +444,7 @@ namespace ZL
void Game::performResetToInitialState() {
const std::string path = "resources/config/start_state.json";
const std::string content = ZL::readTextFile(path);
const std::string content = FRG::readTextFile(path);
if (!content.empty()) {
try {
nlohmann::json root = nlohmann::json::parse(content);
@@ -1013,11 +1013,11 @@ namespace ZL
if (showLoadingProgressBar == false) // Loading language screen
{
if (ZL::g_currentLanguage == ZL::Language::English)
if (FRG::g_currentLanguage == FRG::Language::English)
{
glBindTexture(GL_TEXTURE_2D, menuManager.languageLoadingEn->getTexID());
}
else if (ZL::g_currentLanguage == ZL::Language::Russian)
else if (FRG::g_currentLanguage == FRG::Language::Russian)
{
glBindTexture(GL_TEXTURE_2D, menuManager.languageLoadingRu->getTexID());
}
@@ -1156,7 +1156,7 @@ namespace ZL
}
void Game::render() {
ZL::CheckGlError(__FILE__, __LINE__);
FRG::CheckGlError(__FILE__, __LINE__);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1164,7 +1164,7 @@ namespace ZL
drawScene();
processTickCount();
SDL_GL_SwapWindow(ZL::Environment::window);
SDL_GL_SwapWindow(FRG::Environment::window);
}
void Game::update() {
@@ -1178,7 +1178,7 @@ namespace ZL
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) {
const bool wasPortrait = Environment::width < Environment::height;
//ZL::logger() << "Window resized" << std::endl;
//FRG::logger() << "Window resized" << std::endl;
if (Environment::isHighDPIEnabled) {
// Если High DPI включен, запрашиваем реальное физическое разрешение буфера
int drawW, drawH;
@@ -1188,8 +1188,8 @@ namespace ZL
}
else {
// Если High DPI выключен, используем логические размеры из события
Environment::width = event.window.data1 / ZL::Environment::customDpiScale;
Environment::height = event.window.data2 / ZL::Environment::customDpiScale;
Environment::width = event.window.data1 / FRG::Environment::customDpiScale;
Environment::height = event.window.data2 / FRG::Environment::customDpiScale;
}
Environment::computeProjectionDimensions();
@@ -1260,10 +1260,10 @@ namespace ZL
int my = static_cast<int>((float)eventY / Environment::height * Environment::projectionHeight);
if (event.type == SDL_MOUSEBUTTONDOWN) {
onPointerDown(ZL::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
onPointerDown(FRG::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
}
else {
onPointerUp(ZL::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
onPointerUp(FRG::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
}
}
else if (event.button.button == SDL_BUTTON_RIGHT
@@ -1278,7 +1278,7 @@ namespace ZL
int eventY = event.motion.y;
int mx = static_cast<int>((float)eventX / Environment::width * Environment::projectionWidth);
int my = static_cast<int>((float)eventY / Environment::height * Environment::projectionHeight);
onPointerMotion(ZL::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
onPointerMotion(FRG::UiManager::MOUSE_FINGER_ID, eventX, eventY, mx, my);
}
if (event.type == SDL_MOUSEWHEEL) {
@@ -1851,7 +1851,7 @@ namespace ZL
SaveSlotInfo Game::readSlotInfo(int slot) const
{
std::string path = "save_slot" + std::to_string(slot) + ".json";
std::string content = ZL::readSavedTextFile(path);
std::string content = FRG::readSavedTextFile(path);
if (content.empty()) return {};
try {
nlohmann::json root = nlohmann::json::parse(content);
@@ -1883,7 +1883,7 @@ namespace ZL
void Game::loadGame(int slot)
{
std::string path = "save_slot" + std::to_string(slot) + ".json";
std::string content = ZL::readSavedTextFile(path);
std::string content = FRG::readSavedTextFile(path);
if (content.empty()) {
std::cerr << "[save] Save file not found or empty: " << path << std::endl;
return;
@@ -1915,4 +1915,4 @@ namespace ZL
}
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -22,7 +22,7 @@
#include "Location.h"
#include "AudioPlayerAsync.h"
#include "GameState.h"
namespace ZL {
namespace FRG {
struct SaveSlotInfo {
std::string locationName;
@@ -206,4 +206,4 @@ namespace ZL {
};
} // namespace ZL
} // namespace FRG
+1 -1
View File
@@ -1,6 +1,6 @@
#include "GameConstants.h"
namespace ZL
namespace FRG
{
const std::string defaultShaderName = "default";
const std::string envShaderName = "env";
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "render/Renderer.h"
namespace ZL
namespace FRG
{
extern const std::string defaultShaderName;
extern const std::string envShaderName;
+2 -2
View File
@@ -3,7 +3,7 @@
#include <iomanip>
#include <sstream>
namespace ZL {
namespace FRG {
void GameState::save(nlohmann::json& out) const
{
@@ -158,4 +158,4 @@ void GameState::load(const nlohmann::json& in)
taxiIsCalled = in.value("taxiIsCalled", taxiIsCalled);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -9,7 +9,7 @@
#include <memory>
#include <vector>
namespace ZL {
namespace FRG {
enum class TutorialStep {
Step0, // Dialogue hint: "click to advance"
@@ -75,4 +75,4 @@ struct GameState : public ISaveable {
void load(const nlohmann::json& in) override;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include "external/nlohmann/json.hpp"
namespace ZL {
namespace FRG {
struct ISaveable {
virtual void save(nlohmann::json& out) const = 0;
@@ -9,4 +9,4 @@ struct ISaveable {
virtual ~ISaveable() = default;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -11,7 +11,7 @@
#include <emscripten.h>
#endif
namespace ZL {
namespace FRG {
Language g_currentLanguage = Language::Russian;
@@ -119,4 +119,4 @@ Language detectSystemLanguage() {
return Language::English;
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -1,7 +1,7 @@
#pragma once
#include <string>
namespace ZL {
namespace FRG {
enum class Language {
Russian,
@@ -31,4 +31,4 @@ void loadLanguageSetting();
Language detectSystemLanguage();
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -16,7 +16,7 @@
#include "external/nlohmann/json.hpp"
#include <SDL.h>
namespace ZL
namespace FRG
{
extern const char* CONST_ZIP_FILE;
@@ -2232,4 +2232,4 @@ namespace ZL
}
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -20,7 +20,7 @@
#include <cstdint>
#include <unordered_map>
namespace ZL
namespace FRG
{
struct PointLight
@@ -214,4 +214,4 @@ namespace ZL
std::unordered_map<int, float> npcBumpsPlayerCooldown;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -12,7 +12,7 @@
#include <cmath>
#include <algorithm>
namespace ZL
namespace FRG
{
extern const char* CONST_ZIP_FILE;
@@ -535,4 +535,4 @@ namespace ZL
saveJsonToFile(j, filename);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -7,7 +7,7 @@
#include "items/GameObjectLoader.h"
#include <Eigen/Dense>
namespace ZL {
namespace FRG {
class Location; // forward declaration — LocationEditor.cpp includes Location.h
@@ -67,4 +67,4 @@ private:
Location& loc;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -1,6 +1,6 @@
#include "LocationState.h"
namespace ZL {
namespace FRG {
void LocationState::save(nlohmann::json& out) const
{
@@ -223,4 +223,4 @@ void LocationState::load(const nlohmann::json& in)
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -3,7 +3,7 @@
#include "ISaveable.h"
#include "NpcCar.h"
namespace ZL {
namespace FRG {
struct LocationState : public ISaveable {
// ---- Camera ----
@@ -41,4 +41,4 @@ struct LocationState : public ISaveable {
void load(const nlohmann::json& in) override;
};
} // namespace ZL
} // namespace FRG
+17 -17
View File
@@ -10,7 +10,7 @@
#include <string>
#include <SDL.h>
namespace ZL {
namespace FRG {
// Localization
static const std::string EMPTY_LANGUAGE_RU = u8"(пусто)";
@@ -669,13 +669,13 @@ namespace ZL {
uiManager.setTextButtonCallback("languageRussianButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
ZL::g_currentLanguage = ZL::Language::Russian;
FRG::g_currentLanguage = FRG::Language::Russian;
reloadLocalizedGameContent();
saveSettings();
});
uiManager.setTextButtonCallback("languageEnglishButton", [this](const std::string&) {
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
ZL::g_currentLanguage = ZL::Language::English;
FRG::g_currentLanguage = FRG::Language::English;
reloadLocalizedGameContent();
saveSettings();
});
@@ -748,18 +748,18 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
if (FRG::g_currentLanguage == FRG::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
else if (FRG::g_currentLanguage == FRG::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
: localizedLocationName[info.locationName][FRG::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(kSlotButtons[i], label);
}
uiManager.setTextButtonCallback(kSlotButtons[i], [this, slot](const std::string&) {
@@ -789,18 +789,18 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
if (FRG::g_currentLanguage == FRG::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
else if (FRG::g_currentLanguage == FRG::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
: localizedLocationName[info.locationName][FRG::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
}
uiManager.setTextButtonCallback(buttonName, [this, slot, buttonName](const std::string&) {
@@ -809,18 +809,18 @@ namespace ZL {
SaveSlotInfo info = getSlotInfoFunc(slot);
std::string emptyText;
if (ZL::g_currentLanguage == ZL::Language::Russian)
if (FRG::g_currentLanguage == FRG::Language::Russian)
{
emptyText = EMPTY_LANGUAGE_RU;
}
else if (ZL::g_currentLanguage == ZL::Language::English)
else if (FRG::g_currentLanguage == FRG::Language::English)
{
emptyText = EMPTY_LANGUAGE_EN;
}
std::string label = info.empty
? emptyText
: localizedLocationName[info.locationName][ZL::g_currentLanguage] + " " + info.savedAt;
: localizedLocationName[info.locationName][FRG::g_currentLanguage] + " " + info.savedAt;
uiManager.setTextButtonText(buttonName, label);
audioPlayer_.playSoundAsync("audio/751089__smallconfusion__mechanical-plastic-click-11.ogg");
}
@@ -2271,7 +2271,7 @@ namespace ZL {
root["musicEnabled"] = audioPlayer_.isMusicEnabled();
root["soundEnabled"] = audioPlayer_.isSoundEnabled();
root["fullscreen"] = Environment::isFullscreen;
root["language"] = ZL::languageToCode(ZL::g_currentLanguage);
root["language"] = FRG::languageToCode(FRG::g_currentLanguage);
root["shadow"] = shadowsEnabled;
saveJsonToFile(root, "settings.json");
@@ -2282,12 +2282,12 @@ namespace ZL {
// 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.
// Language is loaded separately, even earlier (see ZL::loadLanguageSetting()
// Language is loaded separately, even earlier (see FRG::loadLanguageSetting()
// callers), because some location scripts start a dialogue as soon as they're
// loaded, before this function ever runs.
ZL::loadLanguageSetting();
FRG::loadLanguageSetting();
const std::string content = ZL::readSavedTextFile("settings.json");
const std::string content = FRG::readSavedTextFile("settings.json");
if (content.empty()) return;
try {
const nlohmann::json root = nlohmann::json::parse(content);
@@ -2427,4 +2427,4 @@ namespace ZL {
uiManager.updateAllLayouts();
}
} // namespace ZL
} // namespace FRG
+3 -3
View File
@@ -13,9 +13,9 @@
#include "render/FrameBuffer.h"
// Forward-declared here to avoid pulling Game.h into MenuManager.h.
namespace ZL { struct SaveSlotInfo; }
namespace FRG { struct SaveSlotInfo; }
namespace ZL {
namespace FRG {
extern const char* CONST_ZIP_FILE;
@@ -343,4 +343,4 @@ namespace ZL {
};
} // namespace ZL
} // namespace FRG
+1 -1
View File
@@ -1,6 +1,6 @@
#include "NpcCar.h"
namespace ZL
namespace FRG
{
const float NpcCar::acceleration = 10.0f;
const float NpcCar::friction = 8.0f;
+1 -1
View File
@@ -2,7 +2,7 @@
#include "render/Renderer.h"
#include "Environment.h"
namespace ZL {
namespace FRG {
struct NpcCar
{
enum class Mode { FOLLOW_WAYPOINTS, NONE };
+2 -2
View File
@@ -10,7 +10,7 @@
#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>
namespace ZL {
namespace FRG {
namespace {
@@ -1159,4 +1159,4 @@ namespace ZL {
outCallback = wrapLuaCallback(fn);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -8,7 +8,7 @@
#include "ISaveable.h"
#include "AudioPlayerAsync.h"
namespace ZL {
namespace FRG {
class Location;
class Inventory;
@@ -79,4 +79,4 @@ private:
std::unique_ptr<Impl> impl;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -10,7 +10,7 @@
#include "utils/Utils.h"
#include "GameConstants.h"
namespace ZL {
namespace FRG {
using json = nlohmann::json;
@@ -669,4 +669,4 @@ namespace ZL {
return true;
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -6,7 +6,7 @@
#include <chrono>
#include <string>
namespace ZL {
namespace FRG {
struct SparkParticle {
Vector3f position;
@@ -126,4 +126,4 @@ namespace ZL {
Vector3f getRandomVelocity(int emitterIndex);
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -2,7 +2,7 @@
#include "render/Renderer.h"
#include "render/TextureManager.h"
namespace ZL {
namespace FRG {
void TeleportZone::initSparks(std::shared_ptr<Texture> activeTex, std::shared_ptr<Texture> inactiveTex)
{
@@ -49,4 +49,4 @@ void TeleportZone::draw(Renderer& renderer, float zoom, int width, int height)
if (sparks) sparks->draw(renderer, zoom, width, height);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -4,7 +4,7 @@
#include <Eigen/Core>
#include "SparkEmitter.h"
namespace ZL {
namespace FRG {
class Renderer;
class Texture;
@@ -33,4 +33,4 @@ struct TeleportZone {
void draw(Renderer& renderer, float zoom, int width, int height);
};
} // namespace ZL
} // namespace FRG
+1 -1
View File
@@ -7,7 +7,7 @@
#ifdef __ANDROID__
#include <android/log.h>
#endif
namespace ZL
namespace FRG
{
static std::unordered_map<std::string, VertexDataStruct> s_meshCache;
+1 -1
View File
@@ -4,7 +4,7 @@
#include <unordered_map>
namespace ZL
namespace FRG
{
VertexDataStruct LoadFromTextFile02(const std::string& fileName, const std::string& ZIPFileName = "");
VertexDataStruct LoadModelFromBinFile(const std::string& fileName, const std::string& ZIPFileName = "");
+2 -2
View File
@@ -7,7 +7,7 @@
#include <sstream>
#include "GameConstants.h"
namespace ZL {
namespace FRG {
using json = nlohmann::json;
@@ -2307,4 +2307,4 @@ namespace ZL {
chatBubbles.clear();
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -13,7 +13,7 @@
#include <variant>
#include <cstdint>
namespace ZL {
namespace FRG {
using json = nlohmann::json;
@@ -565,4 +565,4 @@ namespace ZL {
};
} // namespace ZL
} // namespace FRG
+5 -5
View File
@@ -3,12 +3,12 @@
#include "utils/Utils.h"
#include <iostream>
namespace ZL
namespace FRG
{
extern const char* CONST_ZIP_FILE;
}
namespace ZL::Cutscene {
namespace FRG::Cutscene {
EasingType CutsceneDatabase::parseEasingType(const std::string& value) {
if (value == "EaseInSine") return EasingType::EaseInSine;
@@ -92,11 +92,11 @@ bool CutsceneDatabase::loadFromFile(const std::string& path) {
std::string raw;
try {
if (strlen(ZL::CONST_ZIP_FILE) == 0) {
if (strlen(FRG::CONST_ZIP_FILE) == 0) {
raw = readTextFile(path);
}
else {
auto buf = readFileFromZIP(path, ZL::CONST_ZIP_FILE);
auto buf = readFileFromZIP(path, FRG::CONST_ZIP_FILE);
if (buf.empty()) {
std::cerr << "[cutscene] Failed to read " << path << " from zip\n";
throw std::runtime_error("Failed to load cutscene file: " + path);
@@ -135,4 +135,4 @@ const StaticCutsceneDefinition* CutsceneDatabase::findCutscene(const std::string
return (it != cutscenes.end()) ? &it->second : nullptr;
}
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+2 -2
View File
@@ -5,7 +5,7 @@
#include <string>
#include <unordered_map>
namespace ZL::Cutscene {
namespace FRG::Cutscene {
class CutsceneDatabase {
public:
@@ -26,4 +26,4 @@ private:
static StaticCutsceneDefinition parseCutscene(const json& j);
};
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+12 -12
View File
@@ -6,7 +6,7 @@
#include <algorithm>
#include <cmath>
namespace ZL::Cutscene {
namespace FRG::Cutscene {
bool CutsceneOverlay::init(Renderer& renderer, const std::string& zipFile) {
rendererRef = &renderer;
@@ -26,8 +26,8 @@ bool CutsceneOverlay::init(Renderer& renderer, const std::string& zipFile) {
choiceRenderer->init(renderer, "resources/fonts/DroidSans.ttf", 22, zipFile);
}
void CutsceneOverlay::update(const ZL::Dialogue::PresentationModel& model, int deltaMs) {
if (model.mode != ZL::Dialogue::PresentationMode::Cutscene || !model.cutsceneSkippable) {
void CutsceneOverlay::update(const FRG::Dialogue::PresentationModel& model, int deltaMs) {
if (model.mode != FRG::Dialogue::PresentationMode::Cutscene || !model.cutsceneSkippable) {
cutsceneSkipHintVisible = false;
cutsceneSkipArmed = false;
cutsceneSkipHolding = false;
@@ -106,8 +106,8 @@ void CutsceneOverlay::buildImageUV(
outBR = { (cx + halfW) / safeImgW, (cy - halfH) / safeImgH };
}
void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationModel& model) {
if (model.mode != ZL::Dialogue::PresentationMode::Cutscene) return;
void CutsceneOverlay::draw(Renderer& renderer, const FRG::Dialogue::PresentationModel& model) {
if (model.mode != FRG::Dialogue::PresentationMode::Cutscene) return;
const float W = Environment::projectionWidth;
const float H = Environment::projectionHeight;
@@ -126,7 +126,7 @@ void CutsceneOverlay::draw(Renderer& renderer, const ZL::Dialogue::PresentationM
const UiRect screenRect{ 0.0f, 0.0f, W, H };
for (const ZL::Cutscene::PresentedCutsceneImage& layer : model.cutsceneImages) {
for (const FRG::Cutscene::PresentedCutsceneImage& layer : model.cutsceneImages) {
const auto texture = loadTextureCached(layer.path);
if (!texture) continue;
@@ -224,9 +224,9 @@ bool CutsceneOverlay::consumeSkipRequested() {
return result;
}
void CutsceneOverlay::handlePointerDown(float x, float y, const ZL::Dialogue::PresentationModel& model) {
void CutsceneOverlay::handlePointerDown(float x, float y, const FRG::Dialogue::PresentationModel& model) {
(void)x; (void)y;
if (model.mode != ZL::Dialogue::PresentationMode::Cutscene || !model.cutsceneSkippable) return;
if (model.mode != FRG::Dialogue::PresentationMode::Cutscene || !model.cutsceneSkippable) return;
if (!cutsceneSkipArmed) {
cutsceneSkipHintVisible = true;
@@ -245,11 +245,11 @@ void CutsceneOverlay::handlePointerDown(float x, float y, const ZL::Dialogue::Pr
cutsceneSkipHoldElapsedMs = 0;
}
void CutsceneOverlay::handlePointerMoved(float /*x*/, float /*y*/, const ZL::Dialogue::PresentationModel& /*model*/) {
void CutsceneOverlay::handlePointerMoved(float /*x*/, float /*y*/, const FRG::Dialogue::PresentationModel& /*model*/) {
}
bool CutsceneOverlay::handlePointerReleased(float /*x*/, float /*y*/, const ZL::Dialogue::PresentationModel& model) {
if (model.mode != ZL::Dialogue::PresentationMode::Cutscene) return false;
bool CutsceneOverlay::handlePointerReleased(float /*x*/, float /*y*/, const FRG::Dialogue::PresentationModel& model) {
if (model.mode != FRG::Dialogue::PresentationMode::Cutscene) return false;
if (cutsceneSkipHolding && cutsceneSkipHoldElapsedMs < CutsceneSkipHoldDurationMs) {
cutsceneSkipHolding = false;
cutsceneSkipHoldElapsedMs = 0;
@@ -306,4 +306,4 @@ std::string CutsceneOverlay::wrapTextToWidth(
return output;
}
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+7 -7
View File
@@ -11,17 +11,17 @@
#include <string>
#include <vector>
namespace ZL::Cutscene {
namespace FRG::Cutscene {
class CutsceneOverlay {
public:
bool init(Renderer& renderer, const std::string& zipFile = "");
void update(const ZL::Dialogue::PresentationModel& model, int deltaMs);
void draw(Renderer& renderer, const ZL::Dialogue::PresentationModel& model);
void update(const FRG::Dialogue::PresentationModel& model, int deltaMs);
void draw(Renderer& renderer, const FRG::Dialogue::PresentationModel& model);
void handlePointerDown(float x, float y, const ZL::Dialogue::PresentationModel& model);
void handlePointerMoved(float x, float y, const ZL::Dialogue::PresentationModel& model);
bool handlePointerReleased(float x, float y, const ZL::Dialogue::PresentationModel& model);
void handlePointerDown(float x, float y, const FRG::Dialogue::PresentationModel& model);
void handlePointerMoved(float x, float y, const FRG::Dialogue::PresentationModel& model);
bool handlePointerReleased(float x, float y, const FRG::Dialogue::PresentationModel& model);
bool consumeSkipRequested();
private:
@@ -69,4 +69,4 @@ private:
float maxWidthPx, float scale);
};
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+5 -5
View File
@@ -5,18 +5,18 @@
#include <iostream>
#include "utils/Utils.h"
namespace ZL::Cutscene {
namespace FRG::Cutscene {
void CutsceneRuntime::setDatabase(const CutsceneDatabase* value) {
database = value;
}
void CutsceneRuntime::setTranslationDatabase(const ZL::Dialogue::TranslationDatabase* value) {
void CutsceneRuntime::setTranslationDatabase(const FRG::Dialogue::TranslationDatabase* value) {
translations = value;
}
std::string CutsceneRuntime::tr(const std::string& s) const {
return translations ? translations->translate(s, ZL::g_currentLanguage) : s;
return translations ? translations->translate(s, FRG::g_currentLanguage) : s;
}
void CutsceneRuntime::setOnFinished(std::function<void(const std::string&)> cb) {
@@ -282,7 +282,7 @@ std::vector<PresentedCutsceneImage> CutsceneRuntime::evaluateImages() const {
void CutsceneRuntime::refreshPresentation() {
if (!activeCutscene) return;
presentation.mode = ZL::Dialogue::PresentationMode::Cutscene;
presentation.mode = FRG::Dialogue::PresentationMode::Cutscene;
presentation.cutsceneSkippable = activeCutscene->skippable;
presentation.cutsceneImages = evaluateImages();
@@ -381,4 +381,4 @@ int CutsceneRuntime::computeFallbackDurationMs(const std::string& text) {
return std::max(minDuration, calculated + linger);
}
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+6 -6
View File
@@ -7,12 +7,12 @@
#include <functional>
#include <string>
namespace ZL::Cutscene {
namespace FRG::Cutscene {
class CutsceneRuntime {
public:
void setDatabase(const CutsceneDatabase* value);
void setTranslationDatabase(const ZL::Dialogue::TranslationDatabase* value);
void setTranslationDatabase(const FRG::Dialogue::TranslationDatabase* value);
void setOnFinished(std::function<void(const std::string&)> cb);
void setOnLineStarted(std::function<void(const std::string&)> cb);
@@ -26,11 +26,11 @@ public:
bool canSkip() const;
void skip();
const ZL::Dialogue::PresentationModel& getPresentation() const { return presentation; }
const FRG::Dialogue::PresentationModel& getPresentation() const { return presentation; }
private:
const CutsceneDatabase* database = nullptr;
const ZL::Dialogue::TranslationDatabase* translations = nullptr;
const FRG::Dialogue::TranslationDatabase* translations = nullptr;
const StaticCutsceneDefinition* activeCutscene = nullptr;
std::string activeCutsceneId;
@@ -44,7 +44,7 @@ private:
int cutsceneTotalDurationMs = 0;
int cutsceneContentDurationMs = 0;
ZL::Dialogue::PresentationModel presentation;
FRG::Dialogue::PresentationModel presentation;
std::function<void(const std::string&)> onFinished;
std::function<void(const std::string&)> onLineStarted;
@@ -62,4 +62,4 @@ private:
static int computeFallbackDurationMs(const std::string& text);
};
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+2 -2
View File
@@ -3,7 +3,7 @@
#include <string>
#include <vector>
namespace ZL::Cutscene {
namespace FRG::Cutscene {
enum class EasingType {
Linear,
@@ -75,4 +75,4 @@ struct PresentedCutsceneImage {
int height = 0;
};
} // namespace ZL::Cutscene
} // namespace FRG::Cutscene
+3 -3
View File
@@ -3,12 +3,12 @@
#include "utils/Utils.h"
#include <iostream>
namespace ZL
namespace FRG
{
extern const char* CONST_ZIP_FILE;
}
namespace ZL::Dialogue {
namespace FRG::Dialogue {
NodeType DialogueDatabase::parseNodeType(const std::string& value) {
if (value == "Choice") return NodeType::Choice;
@@ -174,4 +174,4 @@ const DialogueDefinition* DialogueDatabase::findDialogue(const std::string& id)
return (it != dialogues.end()) ? &it->second : nullptr;
}
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -5,7 +5,7 @@
#include <string>
#include <unordered_map>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
class DialogueDatabase {
public:
@@ -29,4 +29,4 @@ private:
static DialogueDefinition parseDialogue(const json& j);
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+3 -3
View File
@@ -6,13 +6,13 @@
#include <algorithm>
#include <array>
namespace ZL
namespace FRG
{
extern float x;
extern float y;
}
namespace ZL::Dialogue {
namespace FRG::Dialogue {
bool DialogueOverlay::init(Renderer& renderer, const std::string& zipFile) {
rendererRef = &renderer;
@@ -447,4 +447,4 @@ bool DialogueOverlay::rectContains(const UiRect& rect, float x, float y) {
return x >= rect.x && x <= rect.x + rect.w && y >= rect.y && y <= rect.y + rect.h;
}
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
class DialogueOverlay {
public:
@@ -62,4 +62,4 @@ private:
void drawPortrait(Renderer& renderer, const PresentationModel& model);
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -3,7 +3,7 @@
#include <algorithm>
#include <iostream>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
static std::pair<std::string, std::string> splitDot(const std::string& s) {
const auto dot = s.find('.');
@@ -414,4 +414,4 @@ void DialogueRuntime::load(const nlohmann::json& in)
revealCharacters = static_cast<float>(presentation.fullText.size());
}
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+3 -3
View File
@@ -11,9 +11,9 @@
#include <unordered_set>
#include <vector>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
class DialogueRuntime : public ZL::ISaveable {
class DialogueRuntime : public FRG::ISaveable {
public:
void setDatabase(const DialogueDatabase* value);
void setTranslationDatabase(const TranslationDatabase* value);
@@ -92,4 +92,4 @@ private:
std::string tr(const std::string& s) const;
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -1,6 +1,6 @@
#include "dialogue/DialogueSystem.h"
namespace ZL::Dialogue {
namespace FRG::Dialogue {
bool DialogueSystem::init(Renderer& renderer, const std::string& zipFile) {
dialogueRuntime.setDatabase(&database);
@@ -221,4 +221,4 @@ void DialogueSystem::setOnDialogueAdvanced(std::function<void()> cb) {
onDialogueAdvancedCallback = std::move(cb);
}
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+6 -6
View File
@@ -12,9 +12,9 @@
#include <functional>
#include <string>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
class DialogueSystem : public ZL::ISaveable {
class DialogueSystem : public FRG::ISaveable {
public:
bool init(Renderer& renderer, const std::string& zipFile = "");
@@ -71,10 +71,10 @@ private:
DialogueRuntime dialogueRuntime;
DialogueOverlay dialogueOverlay;
ZL::Cutscene::CutsceneDatabase cutsceneDatabase;
FRG::Cutscene::CutsceneDatabase cutsceneDatabase;
TranslationDatabase cutsceneTranslationDatabase;
ZL::Cutscene::CutsceneRuntime cutsceneRuntime;
ZL::Cutscene::CutsceneOverlay cutsceneOverlay;
FRG::Cutscene::CutsceneRuntime cutsceneRuntime;
FRG::Cutscene::CutsceneOverlay cutsceneOverlay;
std::function<void()> onDialogueAdvancedCallback;
std::function<void()> onCutsceneStartedCallback;
@@ -87,4 +87,4 @@ private:
void onCutsceneFinishedInternal(const std::string& id);
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+3 -3
View File
@@ -6,7 +6,7 @@
#include <unordered_set>
#include <vector>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
enum class NodeType {
Line,
@@ -121,9 +121,9 @@ struct PresentationModel {
bool showCutsceneSubtitle = false;
bool cutsceneSkippable = false;
std::vector<ZL::Cutscene::PresentedCutsceneImage> cutsceneImages;
std::vector<FRG::Cutscene::PresentedCutsceneImage> cutsceneImages;
float cutsceneGlobalFadeAlpha = 1.0f;
float cutsceneBlackAlpha = 0.0f;
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+3 -3
View File
@@ -3,12 +3,12 @@
#include "utils/Utils.h"
#include <iostream>
namespace ZL
namespace FRG
{
extern const char* CONST_ZIP_FILE;
}
namespace ZL::Dialogue {
namespace FRG::Dialogue {
bool TranslationDatabase::loadFromFile(const std::string& path) {
entries.clear();
@@ -94,4 +94,4 @@ const std::string& TranslationDatabase::translateRef(const std::string& key, Lan
return key;
}
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -5,7 +5,7 @@
#include <string>
#include <unordered_map>
namespace ZL::Dialogue {
namespace FRG::Dialogue {
// Loads a shared translation file mapping dialogue "key" strings (the literal
// speaker/text/choice text found in dialogue config files) to per-language text.
@@ -24,4 +24,4 @@ private:
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> entries;
};
} // namespace ZL::Dialogue
} // namespace FRG::Dialogue
+2 -2
View File
@@ -10,7 +10,7 @@
#include <SDL.h>
namespace ZL {
namespace FRG {
using json = nlohmann::json;
@@ -389,4 +389,4 @@ namespace ZL {
return npcs;
}
} // namespace ZL
} // namespace FRG
+3 -3
View File
@@ -10,7 +10,7 @@
#include "InteractiveObjectState.h"
#include "../CharacterState.h"
namespace ZL {
namespace FRG {
class Character;
@@ -98,7 +98,7 @@ namespace ZL {
const std::string& zipPath = ""
);
static std::vector<std::unique_ptr<ZL::Character>> loadAndCreate_Npcs(
static std::vector<std::unique_ptr<FRG::Character>> loadAndCreate_Npcs(
const std::string& jsonPath,
Renderer& renderer,
const std::string& zipPath = ""
@@ -114,4 +114,4 @@ namespace ZL {
static std::vector<InteractiveObjectData> loadInteractiveFromJson(const std::string& jsonPath, const std::string& zipPath);
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -7,7 +7,7 @@
#include <algorithm>
#include <Eigen/Geometry>
namespace ZL {
namespace FRG {
extern const std::string textureUniformName;
#ifdef EMSCRIPTEN
@@ -300,4 +300,4 @@ namespace ZL {
}
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -8,7 +8,7 @@
#include "render/Renderer.h"
#include "InteractiveObjectState.h"
namespace ZL {
namespace FRG {
class Renderer;
@@ -42,4 +42,4 @@ namespace ZL {
void drawDarklands(Renderer& renderer) const;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -7,7 +7,7 @@
#include "external/nlohmann/json.hpp"
#include "ISaveable.h"
namespace ZL {
namespace FRG {
// Animation task for timed position/rotation/scale/alpha transitions.
// Moved here from InteractiveObject so InteractiveObjectState can own it.
@@ -75,4 +75,4 @@ public:
void load(const nlohmann::json& in) override;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -5,7 +5,7 @@
#include <iostream>
#include "../utils/Utils.h"
namespace ZL {
namespace FRG {
void Inventory::addItem(const std::string& itemId) {
itemIds.push_back(itemId);
@@ -54,4 +54,4 @@ namespace ZL {
}
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -5,7 +5,7 @@
#include <functional>
#include "ISaveable.h"
namespace ZL {
namespace FRG {
struct Item {
std::string id;
@@ -42,4 +42,4 @@ namespace ZL {
std::vector<std::string> itemIds;
};
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -4,7 +4,7 @@
#include "external/nlohmann/json.hpp"
#include <iostream>
namespace ZL {
namespace FRG {
ItemRegistry& ItemRegistry::instance() {
static ItemRegistry reg;
@@ -56,4 +56,4 @@ const Item* ItemRegistry::findById(const std::string& id) const {
return it != items_.end() ? &it->second : nullptr;
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -3,7 +3,7 @@
#include <unordered_map>
#include "Item.h"
namespace ZL {
namespace FRG {
class ItemRegistry {
public:
@@ -20,4 +20,4 @@ private:
std::unordered_map<std::string, Item> items_;
};
} // namespace ZL
} // namespace FRG
+87 -77
View File
@@ -16,20 +16,41 @@
#endif
// Единый указатель на объект игры для всех платформ
FRG::Game* g_game = nullptr;
#if defined(EMSCRIPTEN)
static SDL_GLContext glContext_x;
static bool g_isFsLoaded = false; // Флаг готовности
// Макрос EMSCRIPTEN_KEEPALIVE экспортирует функцию в глобальный объект Module
extern "C" void EMSCRIPTEN_KEEPALIVE onFileSystemLoaded() {
// 1. Файлы загружены. Теперь можно читать настройки и логи
// Если функции readSettings() нет для Emscripten, форсируем логгер:
FRG::Environment::enableLogging = true;
FRG::initLogger();
FRG::logger() << "[boot] File system is ready. Setting up game..." << std::endl;
// 2. Инициализируем игру ТОЛЬКО когда файлы доступны
g_game = new FRG::Game();
g_game->setup();
// 3. Даем отмашку главному циклу
g_isFsLoaded = true;
}
#endif
// Единый указатель на объект игры для всех платформ
ZL::Game* g_game = nullptr;
void MainLoop() {
#if defined(EMSCRIPTEN)
// Крутим цикл вхолостую, пока JS читает IndexedDB
if (!g_isFsLoaded) return;
#endif
g_game->update();
}
#ifdef EMSCRIPTEN
EM_BOOL onWebGLContextLost(int /*eventType*/, const void* /*reserved*/, void* /*userData*/) {
@@ -55,8 +76,8 @@ static void applyResize(int logicalW, int logicalH) {
// Сообщаем SDL о новом размере.
// ВАЖНО: SDL2 в Emscripten ожидает здесь именно физические пиксели
// для корректной работы последующих вызовов glViewport.
if (ZL::Environment::window) {
SDL_SetWindowSize(ZL::Environment::window, physicalW, physicalH);
if (FRG::Environment::window) {
SDL_SetWindowSize(FRG::Environment::window, physicalW, physicalH);
}
// Пушим событие, чтобы движок пересчитал матрицы проекции
@@ -67,7 +88,7 @@ static void applyResize(int logicalW, int logicalH) {
e.window.data2 = physicalH;
SDL_PushEvent(&e);
logger() << "Resized, new size: " << logicalW << "x" << logicalH
FRG::logger() << "Resized, new size: " << logicalW << "x" << logicalH
<< " (physical: " << physicalW << "x" << physicalH
<< ", DPR: " << dpr << ")" << std::endl;
}
@@ -80,7 +101,7 @@ 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;
FRG::Environment::isFullscreen = e->isFullscreen;
// Вместо window.innerWidth, попробуйте запросить размер целевого элемента
// так как после перехода в FS именно он растягивается на весь экран.
@@ -94,43 +115,32 @@ int main(int argc, char* argv[]) {
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); // Для WebGL 2.0
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
ZL::Environment::window = SDL_CreateWindow("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
glContext_x = SDL_GL_CreateContext(ZL::Environment::window);
FRG::Environment::window = SDL_CreateWindow("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
glContext_x = SDL_GL_CreateContext(FRG::Environment::window);
SDL_GL_MakeCurrent(ZL::Environment::window, glContext_x);
g_game = new ZL::Game();
g_game->setup();
SDL_GL_MakeCurrent(FRG::Environment::window, glContext_x);
emscripten_set_webglcontextlost_callback("#canvas", nullptr, EM_TRUE, onWebGLContextLost);
emscripten_set_webglcontextrestored_callback("#canvas", nullptr, EM_TRUE, onWebGLContextRestored);
// Keep Environment::width/height in sync when the canvas is resized.
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, nullptr, EM_FALSE, onWindowResized);
emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, nullptr, EM_FALSE, onFullscreenChanged);
// 2. ИНИЦИАЛИЗАЦИЯ РАЗМЕРОВ:
// Получаем реальные размеры окна браузера на момент запуска
int canvasW = EM_ASM_INT({ return window.innerWidth; });
int canvasH = EM_ASM_INT({ return window.innerHeight; });
// Вызываем вашу функцию — она сама применит DPR, выставит физический размер
// канваса и отправит SDL_WINDOWEVENT_RESIZED для настройки проекции.
applyResize(canvasW, canvasH);
// Prevent mouse clicks from generating fake SDL_FINGERDOWN events (desktop browser)
SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
// Prevent touch events from generating fake SDL_MOUSEBUTTONDOWN events (mobile browser),
// since we now handle SDL_FINGERDOWN directly for multi-touch support.
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
ZL::emscriptenInitFileSystem();
// Запускаем асинхронное монтирование ФС
FRG::emscriptenInitFileSystem();
// Начинаем крутить пустой цикл. Он активируется, когда отработает onFileSystemLoaded
emscripten_set_main_loop(MainLoop, 0, 1);
return 0;
}
@@ -152,11 +162,11 @@ extern "C" int SDL_main(int argc, char* argv[]) {
SDL_Quit();
return 1;
}
ZL::Environment::width = displayMode.w;
ZL::Environment::height = displayMode.h;
FRG::Environment::width = displayMode.w;
FRG::Environment::height = displayMode.h;
__android_log_print(ANDROID_LOG_INFO, "Game", "Display resolution: %dx%d",
ZL::Environment::width, ZL::Environment::height);
FRG::Environment::width, FRG::Environment::height);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
@@ -169,31 +179,31 @@ extern "C" int SDL_main(int argc, char* argv[]) {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
ZL::Environment::window = SDL_CreateWindow(
FRG::Environment::window = SDL_CreateWindow(
"Shadow Over Bishkek",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
ZL::Environment::width, ZL::Environment::height,
FRG::Environment::width, FRG::Environment::height,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN
);
if (!ZL::Environment::window) {
if (!FRG::Environment::window) {
__android_log_print(ANDROID_LOG_ERROR, "Game", "Failed to create window: %s", SDL_GetError());
SDL_Quit();
return 1;
}
SDL_GLContext ctx = SDL_GL_CreateContext(ZL::Environment::window);
SDL_GLContext ctx = SDL_GL_CreateContext(FRG::Environment::window);
if (!ctx) {
__android_log_print(ANDROID_LOG_ERROR, "Game", "SDL_GL_CreateContext failed: %s", SDL_GetError());
SDL_DestroyWindow(ZL::Environment::window);
SDL_DestroyWindow(FRG::Environment::window);
SDL_Quit();
return 1;
}
if (SDL_GL_MakeCurrent(ZL::Environment::window, ctx) != 0) {
if (SDL_GL_MakeCurrent(FRG::Environment::window, ctx) != 0) {
__android_log_print(ANDROID_LOG_ERROR, "Game", "SDL_GL_MakeCurrent failed: %s", SDL_GetError());
SDL_GL_DeleteContext(ctx);
SDL_DestroyWindow(ZL::Environment::window);
SDL_DestroyWindow(FRG::Environment::window);
SDL_Quit();
return 1;
}
@@ -232,20 +242,20 @@ extern "C" int SDL_main(int argc, char* argv[]) {
void readSettings()
{
const std::string settingsContent = ZL::readSavedTextFile("settings.json");
const std::string settingsContent = FRG::readSavedTextFile("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>();
FRG::Environment::isFullscreen = settingsRoot["fullscreen"].get<bool>();
}
if (settingsRoot.contains("isHighDPIEnabled")) {
ZL::Environment::isHighDPIEnabled = settingsRoot["isHighDPIEnabled"].get<bool>();
FRG::Environment::isHighDPIEnabled = settingsRoot["isHighDPIEnabled"].get<bool>();
}
if (settingsRoot.contains("enableLogging")) {
ZL::Environment::enableLogging = settingsRoot["enableLogging"].get<bool>();
FRG::Environment::enableLogging = settingsRoot["enableLogging"].get<bool>();
}
}
@@ -262,12 +272,12 @@ int main(int argc, char* argv[]) {
try
{
readSettings();
if (ZL::Environment::enableLogging)
if (FRG::Environment::enableLogging)
{
ZL::initLogger();
FRG::initLogger();
}
ZL::logger() << "Log started!" << std::endl;
FRG::logger() << "Log started!" << std::endl;
#ifdef STEAMSDK
// Передаем явный App ID демо-версии
@@ -283,11 +293,11 @@ int main(int argc, char* argv[]) {
SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2");
constexpr int CONST_WIDTH = ZL::Environment::CONST_DEFAULT_WIDTH;
constexpr int CONST_HEIGHT = ZL::Environment::CONST_DEFAULT_HEIGHT;
constexpr int CONST_WIDTH = FRG::Environment::CONST_DEFAULT_WIDTH;
constexpr int CONST_HEIGHT = FRG::Environment::CONST_DEFAULT_HEIGHT;
ZL::Environment::width = CONST_WIDTH;
ZL::Environment::height = CONST_HEIGHT;
FRG::Environment::width = CONST_WIDTH;
FRG::Environment::height = CONST_HEIGHT;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
SDL_Log("SDL init failed: %s", SDL_GetError());
return 1;
@@ -298,53 +308,53 @@ int main(int argc, char* argv[]) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE;
if (ZL::Environment::isFullscreen) {
if (FRG::Environment::isFullscreen) {
windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
SDL_DisplayMode dm;
if (SDL_GetCurrentDisplayMode(0, &dm) == 0) {
ZL::logger() << "Desktop resolution: " << dm.w << "x" << dm.h << " @ " << dm.refresh_rate << "Hz\n";
FRG::logger() << "Desktop resolution: " << dm.w << "x" << dm.h << " @ " << dm.refresh_rate << "Hz\n";
}
else {
SDL_Log("SDL_GetCurrentDisplayMode failed: %s", SDL_GetError());
}
int windowWidth = ZL::Environment::width;
int windowHeight = ZL::Environment::height;
int windowWidth = FRG::Environment::width;
int windowHeight = FRG::Environment::height;
if (dm.w <= 1280 && dm.h <= 720) {
windowWidth = round(dm.w / 1.5);
windowHeight = round(dm.h / 1.5);
}
ZL::Environment::window = SDL_CreateWindow(
FRG::Environment::window = SDL_CreateWindow(
"Shadow Over Bishkek Demo",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
windowWidth, windowHeight,
windowFlags
);
ctx = SDL_GL_CreateContext(ZL::Environment::window);
SDL_GL_MakeCurrent(ZL::Environment::window, ctx);
ctx = SDL_GL_CreateContext(FRG::Environment::window);
SDL_GL_MakeCurrent(FRG::Environment::window, ctx);
if (ZL::Environment::isHighDPIEnabled) {
if (FRG::Environment::isHighDPIEnabled) {
int drawW, drawH;
SDL_GL_GetDrawableSize(ZL::Environment::window, &drawW, &drawH);
ZL::Environment::width = drawW;
ZL::Environment::height = drawH;
ZL::logger() << "HiDPI enabled, drawable size: " << drawW << "x" << drawH << std::endl;
SDL_GL_GetDrawableSize(FRG::Environment::window, &drawW, &drawH);
FRG::Environment::width = drawW;
FRG::Environment::height = drawH;
FRG::logger() << "HiDPI enabled, drawable size: " << drawW << "x" << drawH << std::endl;
}
else {
int winW, winH;
SDL_GetWindowSize(ZL::Environment::window, &winW, &winH);
ZL::Environment::width = winW;
ZL::Environment::height = winH;
ZL::logger() << "HiDPI disabled, window size: " << winW << "x" << winH << std::endl;
SDL_GetWindowSize(FRG::Environment::window, &winW, &winH);
FRG::Environment::width = winW;
FRG::Environment::height = winH;
FRG::logger() << "HiDPI disabled, window size: " << winW << "x" << winH << std::endl;
}
// Динамическое создание объекта игры
g_game = new ZL::Game();
g_game = new FRG::Game();
g_game->setup();
while (!g_game->shouldExit()) {
@@ -356,10 +366,10 @@ int main(int argc, char* argv[]) {
#endif
}
//ZL::logger() << "Quitting step 1: " << std::endl;
//FRG::logger() << "Quitting step 1: " << std::endl;
// Явное уничтожение объекта игры ДО завершения работы Steamworks
delete g_game;
//ZL::logger() << "Quitting step 2: " << std::endl;
//FRG::logger() << "Quitting step 2: " << std::endl;
g_game = nullptr;
}
catch (const std::exception& e)
@@ -379,31 +389,31 @@ int main(int argc, char* argv[]) {
}
}
//ZL::logger() << "Quitting step 3: " << std::endl;
//FRG::logger() << "Quitting step 3: " << std::endl;
#ifdef STEAMSDK
// Деинициализация Steamworks происходит только тогда, когда все объекты игры гарантированно уничтожены
SteamAPI_Shutdown();
#endif
//ZL::logger() << "Quitting step 4: " << std::endl;
//FRG::logger() << "Quitting step 4: " << std::endl;
// Очистка ресурсов SDL
if (ctx) {
//ZL::logger() << "Quitting step 5: " << std::endl;
//FRG::logger() << "Quitting step 5: " << std::endl;
SDL_GL_DeleteContext(ctx);
}
//ZL::logger() << "Quitting step 6: " << std::endl;
if (ZL::Environment::window) {
//ZL::logger() << "Quitting step 7: " << std::endl;
SDL_DestroyWindow(ZL::Environment::window);
//FRG::logger() << "Quitting step 6: " << std::endl;
if (FRG::Environment::window) {
//FRG::logger() << "Quitting step 7: " << std::endl;
SDL_DestroyWindow(FRG::Environment::window);
}
//ZL::logger() << "Quitting step 8: " << std::endl;
//FRG::logger() << "Quitting step 8: " << std::endl;
#ifndef EMSCRIPTEN
// In Emscripten, SDL must stay alive across context loss/restore cycles
// so the window remains valid when the game object is re-created.
SDL_Quit();
#endif
//ZL::logger() << "Quitting step 9: " << std::endl;
//FRG::logger() << "Quitting step 9: " << std::endl;
return 0;
}
#endif
+2 -2
View File
@@ -9,7 +9,7 @@
#include <limits>
#include <queue>
namespace ZL {
namespace FRG {
using json = nlohmann::json;
@@ -1075,4 +1075,4 @@ bool PathFinder::pointInPolygon(float x, float z, const std::vector<Eigen::Vecto
return inside;
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -5,7 +5,7 @@
#include <string>
#include <vector>
namespace ZL {
namespace FRG {
class PathFinder {
public:
@@ -111,4 +111,4 @@ private:
const std::vector<unsigned char>& walkableGrid) const;
};
} // namespace ZL
} // namespace FRG
+3 -3
View File
@@ -5,7 +5,7 @@
#include <algorithm>
#include <iostream>
namespace ZL::Quest {
namespace FRG::Quest {
using json = nlohmann::json;
@@ -27,7 +27,7 @@ static QuestStatus parseQuestStatus(const std::string& value) {
}
bool QuestJournal::loadFromFile(const std::string& path, const std::string& zipFile) {
const std::string content = ZL::readLocalizedConfigFile(path, zipFile);
const std::string content = FRG::readLocalizedConfigFile(path, zipFile);
if (content.empty()) {
std::cerr << "[quest] Failed to read " << path << std::endl;
return false;
@@ -260,4 +260,4 @@ void QuestJournal::load(const nlohmann::json& in) {
}
}
} // namespace ZL::Quest
} // namespace FRG::Quest
+3 -3
View File
@@ -8,9 +8,9 @@
#include <vector>
#include <functional>
namespace ZL::Quest {
namespace FRG::Quest {
class QuestJournal : public ZL::ISaveable {
class QuestJournal : public FRG::ISaveable {
public:
bool loadFromFile(const std::string& path, const std::string& zipFile = "");
@@ -49,4 +49,4 @@ private:
bool setStatus(const std::string& questId, QuestStatus status);
};
} // namespace ZL::Quest
} // namespace FRG::Quest
+2 -2
View File
@@ -3,7 +3,7 @@
#include <string>
#include <vector>
namespace ZL::Quest {
namespace FRG::Quest {
enum class QuestStatus {
Hidden,
@@ -37,4 +37,4 @@ struct QuestState {
const char* toString(QuestStatus status);
} // namespace ZL::Quest
} // namespace FRG::Quest
+2 -2
View File
@@ -2,7 +2,7 @@
#include <iostream>
#include "Environment.h"
namespace ZL {
namespace FRG {
FrameBuffer::FrameBuffer(int w, int h, bool useMipmaps)
: width(w), height(h), useMipmaps(useMipmaps) {
@@ -59,4 +59,4 @@ namespace ZL {
glViewport(0, 0, Environment::width, Environment::height);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -2,7 +2,7 @@
#include "render/OpenGlExtensions.h"
#include <memory>
namespace ZL {
namespace FRG {
class FrameBuffer {
private:
@@ -28,4 +28,4 @@ namespace ZL {
int getHeight() const { return height; }
};
} // namespace ZL
} // namespace FRG
+1 -1
View File
@@ -117,7 +117,7 @@ PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArray = NULL;
#endif
namespace ZL {
namespace FRG {
bool BindOpenGlFunctions()
{
+1 -1
View File
@@ -154,7 +154,7 @@ extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArray;
#else
#endif
namespace ZL {
namespace FRG {
+1 -1
View File
@@ -1,7 +1,7 @@
#include "render/Renderer.h"
#include <cmath>
namespace ZL {
namespace FRG {
Matrix4f MakeOrthoMatrix(float width, float height, float zNear, float zFar)
{
+1 -1
View File
@@ -8,7 +8,7 @@
#include "TextureManager.h"
#include <Eigen/Dense>
namespace ZL {
namespace FRG {
using Eigen::Vector2f;
using Eigen::Vector3f;
+1 -1
View File
@@ -6,7 +6,7 @@
#include <android/log.h>
#endif
namespace ZL {
namespace FRG {
ShaderResource::ShaderResource(const std::string &vertexCode, const std::string &fragmentCode) {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "render/OpenGlExtensions.h"
#include "utils/Utils.h"
namespace ZL {
namespace FRG {
constexpr size_t CONST_MAX_SHADER_STACK_SIZE = 16;
+2 -2
View File
@@ -3,7 +3,7 @@
#include <iostream>
#include <cmath>
namespace ZL {
namespace FRG {
// Build a look-at view matrix (column-major, same convention as the engine).
static Eigen::Matrix4f lookAt(const Eigen::Vector3f& eye,
@@ -167,4 +167,4 @@ namespace ZL {
glViewport(0, 0, Environment::width, Environment::height);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -2,7 +2,7 @@
#include "render/OpenGlExtensions.h"
#include <Eigen/Dense>
namespace ZL {
namespace FRG {
class ShadowMap {
private:
@@ -44,4 +44,4 @@ namespace ZL {
const Eigen::Vector3f& getLightDirection() const { return lightDirection; }
};
} // namespace ZL
} // namespace FRG
+5 -5
View File
@@ -10,7 +10,7 @@
#include <cmath>
#include <unordered_set>
namespace ZL {
namespace FRG {
struct GlyphAtlasData {
std::unordered_map<uint32_t, GlyphInfo> glyphs;
@@ -71,13 +71,13 @@ bool TextRenderer::init(Renderer& renderer, const std::string& ttfPath, int pixe
#endif
}
ZL::CheckGlError(__FILE__, __LINE__);
FRG::CheckGlError(__FILE__, __LINE__);
if (!loadGlyphs(ttfPath, pixelSize, zipfilename)) return false;
ZL::CheckGlError(__FILE__, __LINE__);
FRG::CheckGlError(__FILE__, __LINE__);
textMesh.data.PositionData.resize(6, Eigen::Vector3f(0, 0, 0));
textMesh.RefreshVBO();
ZL::CheckGlError(__FILE__, __LINE__);
FRG::CheckGlError(__FILE__, __LINE__);
return true;
}
@@ -515,4 +515,4 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
// Сброс бинда текстуры не обязателен, но можно для чистоты
glBindTexture(GL_TEXTURE_2D, 0);
}
} // namespace ZL
} // namespace FRG
+2 -2
View File
@@ -9,7 +9,7 @@
#include <array>
namespace ZL {
namespace FRG {
struct GlyphInfo {
Eigen::Vector2f uv; // u,v координата левого верхнего угла в атласе (0..1)
@@ -62,4 +62,4 @@ private:
std::unordered_map<std::string, CachedText> cache;
};
} // namespace ZL
} // namespace FRG
+1 -1
View File
@@ -5,7 +5,7 @@
#endif
#include <iostream>
namespace ZL
namespace FRG
{
#ifdef EMSCRIPTEN
using std::min;
+1 -1
View File
@@ -9,7 +9,7 @@
#define PNG_ENABLED
#endif
namespace ZL
namespace FRG
{
struct TextureDataStruct {
+1 -1
View File
@@ -4,7 +4,7 @@
#include "UiManager.h"
#include <Eigen/Core>
namespace ZL
namespace FRG
{
// Axis-aligned textured quad with cached mesh. Rebuild only when rect changes.
struct UiQuad {
+1 -1
View File
@@ -1,7 +1,7 @@
#include "TaskManager.h"
namespace ZL
namespace FRG
{
TaskManager::TaskManager(size_t threadCount) {
+2 -2
View File
@@ -11,7 +11,7 @@
#include <queue>
namespace ZL {
namespace FRG {
class TaskManager {
private:
@@ -53,4 +53,4 @@ namespace ZL {
void processMainThreadTasks();
};
} // namespace ZL
} // namespace FRG
+19 -15
View File
@@ -24,7 +24,7 @@
#include <emscripten.h>
#endif
namespace ZL
namespace FRG
{
std::string readTextFile(const std::string& filename) {
#ifdef __ANDROID__
@@ -326,25 +326,25 @@ namespace ZL
void emscriptenInitFileSystem()
{
#if defined(__EMSCRIPTEN__)
// 1. Создаем точку монтирования в памяти
namespace fs = std::filesystem;
fs::create_directories("/offline");
// 2. Монтируем IDBFS в эту точку
EM_ASM({
FS.mount(IDBFS, {}, '/offline');
// 3. Синхронизируем из IndexedDB в VFS (true = из IDB в память)
// Этот вызов асинхронный. Настройки станут доступны только после его завершения.
FS.syncfs(true, function(err) {
if (err) {
console.error("Error loading filesystem from IndexedDB:", err);
}
FS.syncfs(true, function(err) {
if (err) {
console.error("Error loading filesystem from IndexedDB:", err);
}
else {
console.log("IndexedDB successfully synced to VFS.");
// Здесь при необходимости можно вызвать коллбэк в C++
// для отложенной загрузки файла настроек, если это критично.
}
});
console.log("IndexedDB successfully synced to VFS.");
}
// Вызываем экспортированную C-функцию
if (Module._onFileSystemLoaded) {
Module._onFileSystemLoaded();
}
});
});
#endif
}
@@ -384,12 +384,16 @@ namespace ZL
TeeBuffer(std::streambuf* sb1, std::streambuf* sb2) : out1(sb1), out2(sb2) {}
};
// --- Глобальные переменные логгера ---
namespace {
std::ofstream g_logFile;
std::unique_ptr<TeeBuffer> g_teeBuffer;
std::unique_ptr<std::ostream> g_teeStream;
NullStream g_nullStream;
// Решение проблемы UB: буфер создается ДО потока
NullBuffer g_nullBuffer;
std::ostream g_nullStream(&g_nullBuffer);
}
// --- Инициализация логгера ---
+1 -1
View File
@@ -15,7 +15,7 @@
#include <cstdlib>
#include "external/nlohmann/json.hpp"
namespace ZL
namespace FRG
{
std::string readTextFile(const std::string& filename);