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

+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