Fixing localization bugs, working with graphics settings
This commit is contained in:
1 parent
d4365728fe
commit
9d03b52c2a
14 files changed
+354
-44
No files matched your search
+62
-4
@@ -292,6 +292,19 @@ namespace ZL
|
||||
menuManager.onLoadGame = [this](int slot) { loadGame(slot); };
|
||||
menuManager.getSlotInfoFunc = [this](int slot) { return readSlotInfo(slot); };
|
||||
|
||||
menuManager.shadowMapSettingsChangedFunc = [this](bool newValue) {
|
||||
if (newValue)
|
||||
{
|
||||
createShadowMapAndProparateToLocations();
|
||||
menuManager.shadowsEnabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
destroyShadowMapAndProparateToLocations();
|
||||
menuManager.shadowsEnabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Lets MenuManager run a heavy operation (e.g. reloadLocalizedGameContent())
|
||||
// as a chunked sequence instead of one blocking call: the closures are
|
||||
// drained one per frame by update(), with the loading screen shown for
|
||||
@@ -322,6 +335,14 @@ namespace ZL
|
||||
audioPlayer->crossFadeMusicAsync("audio/main menu final.ogg");
|
||||
});
|
||||
|
||||
|
||||
/*loadSteps.push([this]() {
|
||||
if (menshadowsEnabled)
|
||||
{
|
||||
createShadowMapAndProparateToLocations();
|
||||
}
|
||||
});*/
|
||||
|
||||
loadSteps.push([this]() {
|
||||
loadingCompleted = true;
|
||||
});
|
||||
@@ -730,6 +751,30 @@ namespace ZL
|
||||
}
|
||||
}
|
||||
|
||||
void Game::createShadowMapAndProparateToLocations()
|
||||
{
|
||||
if (shadowMap) {
|
||||
std::cout << "Shadow map already exists, skipping creation" << std::endl;
|
||||
return;
|
||||
}
|
||||
shadowMap = std::make_shared<ShadowMap>(2048, 40.0f, 0.1f, 100.0f);
|
||||
shadowMap->setLightDirection(Eigen::Vector3f(-0.5f, -1.0f, -0.3f));
|
||||
std::cout << "Shadow map initialized" << std::endl;
|
||||
|
||||
for (auto& [name, loc] : gameState.locations) {
|
||||
loc->shadowMap = shadowMap;
|
||||
}
|
||||
|
||||
}
|
||||
void Game::destroyShadowMapAndProparateToLocations()
|
||||
{
|
||||
shadowMap.reset();
|
||||
for (auto& [name, loc] : gameState.locations) {
|
||||
loc->shadowMap.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Game::drawUI()
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
@@ -991,19 +1036,32 @@ namespace ZL
|
||||
|
||||
|
||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
// Обновляем размеры и сбрасываем кеш текстов, т.к. меши хранятся в пикселях
|
||||
const bool wasPortrait = Environment::width < Environment::height;
|
||||
Environment::width = event.window.data1;
|
||||
Environment::height = event.window.data2;
|
||||
|
||||
if (Environment::isHighDPIEnabled) {
|
||||
// Если High DPI включен, запрашиваем реальное физическое разрешение буфера
|
||||
int drawW, drawH;
|
||||
SDL_GL_GetDrawableSize(Environment::window, &drawW, &drawH);
|
||||
Environment::width = drawW;
|
||||
Environment::height = drawH;
|
||||
}
|
||||
else {
|
||||
// Если High DPI выключен, используем логические размеры из события
|
||||
Environment::width = event.window.data1 / ZL::Environment::customDpiScale;
|
||||
Environment::height = event.window.data2 / ZL::Environment::customDpiScale;
|
||||
}
|
||||
|
||||
Environment::computeProjectionDimensions();
|
||||
|
||||
const bool isPortrait = Environment::width < Environment::height;
|
||||
menuManager.uiManager.updateAllLayouts();
|
||||
menuManager.topUiManager.updateAllLayouts();
|
||||
|
||||
if (wasPortrait != isPortrait) {
|
||||
menuManager.onOrientationChanged();
|
||||
}
|
||||
std::cout << "Window resized: " << Environment::width << "x" << Environment::height << std::endl;
|
||||
|
||||
std::cout << "Window resized (Render Size): " << Environment::width << "x" << Environment::height << std::endl;
|
||||
//space.clearTextRendererCache();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user