Working on UI improvement

This commit is contained in:
Vladislav Khorev committed 2026-05-27 17:30:41 +03:00
1 parent 0da1ae124c
commit 80af0e61ae
43 files changed
+889 -64

No files matched your search

+52 -2
View File
@@ -369,6 +369,24 @@ namespace ZL
locations["uni_interior"]->onTeleport = teleportCallback;
locations["location_dorm"]->onTeleport = teleportCallback;
// Wire tutorial advance callbacks for all locations.
// advanceTutorialStep() guards against double-advancing, so sharing is safe.
for (auto& [name, loc] : locations) {
loc->dialogueSystem.setOnDialogueAdvanced([this]() {
menuManager.advanceTutorialStep();
});
loc->onPlayerFloorWalk = [this]() {
if (menuManager.tutorialStep == TutorialStep::Step2) {
menuManager.advanceTutorialStep();
}
};
}
// Wire inventory item-pickup callback for tutorial step4/5 item tracking.
inventory.onItemAdded = [this](const std::string& itemId) {
menuManager.onItemPickedUp(itemId);
};
currentLocation = locations["location_dorm"];
currentLocation->scriptEngine.callLocationEnterCallback();
@@ -552,6 +570,8 @@ namespace ZL
updateDarklandsFlash(delta);
menuManager.uiManager.update(static_cast<float>(delta));
if (currentLocation)
{
currentLocation->update(delta);
@@ -661,6 +681,10 @@ namespace ZL
if (Environment::zoom < zoomstep) {
Environment::zoom = zoomstep;
}
// Tutorial step3 → step4: any mouse-wheel scroll counts as "zoom gesture".
if (menuManager.tutorialStep == TutorialStep::Step3) {
menuManager.advanceTutorialStep();
}
}
if (event.type == SDL_KEYDOWN && event.key.repeat == 0) {
@@ -722,8 +746,10 @@ namespace ZL
break;
case SDLK_l:
x = x - 1;
std::cout << "current x: " << x << std::endl;
//x = x - 1;
//std::cout << "current x: " << x << std::endl;
std::cout << "Azimuth: " << currentLocation->cameraAzimuth << std::endl;
std::cout << "Inclination: " << currentLocation->cameraInclination << std::endl;
break;
case SDLK_c:
@@ -826,6 +852,10 @@ namespace ZL
// movement threshold was crossed.
currentLocation->lastMouseX = eventX;
currentLocation->lastMouseY = eventY;
// Snapshot current angles so we can measure how far the user rotates.
dragStartAzimuth = currentLocation->cameraAzimuth;
dragStartInclination = currentLocation->cameraInclination;
}
}
@@ -881,6 +911,13 @@ namespace ZL
static const float zoomMin = 2.0f;
if (newZoom < zoomMin) newZoom = zoomMin;
Environment::zoom = newZoom;
// Tutorial step3 → step4: detect a significant pinch-zoom (≥ 2 zoom units).
if (menuManager.tutorialStep == TutorialStep::Step3) {
if (std::abs(Environment::zoom - pinchStartZoom) >= 2.0f) {
menuManager.advanceTutorialStep();
}
}
}
void Game::endPinch()
@@ -1004,6 +1041,19 @@ namespace ZL
if (currentLocation) {
// Forwarded for dialogue hover and (when cameraDragging) camera rotation.
currentLocation->handleMotion(fingerId, eventX, eventY, mx, my);
// Tutorial step1 → step2: detect a significant camera rotation on BOTH axes.
// ~0.15 rad (≈8.6°) per axis ensures the user intentionally panned in 2D,
// not just nudged a single axis by accident.
static constexpr float TUTORIAL_ROTATION_THRESHOLD = 0.15f;
if (cameraDragging
&& menuManager.tutorialStep == TutorialStep::Step1) {
float deltaAz = std::abs(currentLocation->cameraAzimuth - dragStartAzimuth);
float deltaInc = std::abs(currentLocation->cameraInclination - dragStartInclination);
if (deltaAz >= TUTORIAL_ROTATION_THRESHOLD && deltaInc >= TUTORIAL_ROTATION_THRESHOLD) {
menuManager.advanceTutorialStep();
}
}
}
}