bugfixes
This commit is contained in:
@@ -21,6 +21,7 @@ menu:
|
|||||||
exit_game: "Eixir del joc"
|
exit_game: "Eixir del joc"
|
||||||
use_new_logo: "Logo nou"
|
use_new_logo: "Logo nou"
|
||||||
show_title_credits: "Crèdits del port"
|
show_title_credits: "Crèdits del port"
|
||||||
|
show_preload: "Barra de precàrrega"
|
||||||
zoom: "Zoom"
|
zoom: "Zoom"
|
||||||
screen: "Pantalla"
|
screen: "Pantalla"
|
||||||
shader: "Shader"
|
shader: "Shader"
|
||||||
|
|||||||
@@ -169,21 +169,19 @@ auto Audio::getRealMusicState() -> MusicState {
|
|||||||
|
|
||||||
// Establece el volumen de los sonidos (float 0.0..1.0)
|
// Establece el volumen de los sonidos (float 0.0..1.0)
|
||||||
void Audio::setSoundVolume(float sound_volume, Group group) const {
|
void Audio::setSoundVolume(float sound_volume, Group group) const {
|
||||||
if (sound_enabled_) {
|
|
||||||
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
||||||
const float CONVERTED_VOLUME = sound_volume * Options::audio.volume;
|
const bool active = enabled_ && sound_enabled_;
|
||||||
|
const float CONVERTED_VOLUME = active ? sound_volume * Options::audio.volume : 0.0F;
|
||||||
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el volumen de la música (float 0.0..1.0)
|
// Establece el volumen de la música (float 0.0..1.0)
|
||||||
void Audio::setMusicVolume(float music_volume) const {
|
void Audio::setMusicVolume(float music_volume) const {
|
||||||
if (music_enabled_) {
|
|
||||||
music_volume = std::clamp(music_volume, MIN_VOLUME, MAX_VOLUME);
|
music_volume = std::clamp(music_volume, MIN_VOLUME, MAX_VOLUME);
|
||||||
const float CONVERTED_VOLUME = music_volume * Options::audio.volume;
|
const bool active = enabled_ && music_enabled_;
|
||||||
|
const float CONVERTED_VOLUME = active ? music_volume * Options::audio.volume : 0.0F;
|
||||||
JA_SetMusicVolume(CONVERTED_VOLUME);
|
JA_SetMusicVolume(CONVERTED_VOLUME);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Aplica la configuración
|
// Aplica la configuración
|
||||||
void Audio::applySettings() {
|
void Audio::applySettings() {
|
||||||
|
|||||||
@@ -70,19 +70,26 @@ void file_setconfigfolder(const char* foldername) {
|
|||||||
if (!homedir) homedir = "/tmp";
|
if (!homedir) homedir = "/tmp";
|
||||||
config_folder = std::string(homedir) + "/Library/Application Support/" + foldername;
|
config_folder = std::string(homedir) + "/Library/Application Support/" + foldername;
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
// Nota emscripten: `__linux__` també està definit, però `getpwuid` no
|
// Nota emscripten: `__linux__` també està definit, però `getpwuid` pot
|
||||||
// troba cap /etc/passwd al MEMFS i retorna nullptr. Amb els fallbacks
|
// retornar nullptr (sense /etc/passwd al MEMFS) o un passwd amb pw_dir
|
||||||
// HOME → /tmp evitem crashejar al primer arranque dins del navegador.
|
// buit. Amb els fallbacks HOME → /tmp evitem crashejar al primer
|
||||||
// La config no persistirà entre recàrregues de la pàgina (MEMFS és
|
// arranque dins del navegador. La config no persistirà entre recàrregues
|
||||||
// volàtil); caldria IDBFS si volguéssem persistència a web.
|
// (MEMFS és volàtil); caldria IDBFS si volguéssem persistència a web.
|
||||||
struct passwd* pw = getpwuid(getuid());
|
struct passwd* pw = getpwuid(getuid());
|
||||||
const char* homedir = (pw && pw->pw_dir) ? pw->pw_dir : nullptr;
|
const char* homedir = (pw && pw->pw_dir && pw->pw_dir[0]) ? pw->pw_dir : nullptr;
|
||||||
if (!homedir) homedir = getenv("HOME");
|
if (!homedir || !homedir[0]) homedir = getenv("HOME");
|
||||||
if (!homedir) homedir = "/tmp";
|
if (!homedir || !homedir[0]) homedir = "/tmp";
|
||||||
config_folder = std::string(homedir) + "/.config/" + foldername;
|
config_folder = std::string(homedir) + "/.config/" + foldername;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::filesystem::create_directories(config_folder);
|
if (config_folder.empty()) {
|
||||||
|
config_folder = "/tmp/jailgames_config";
|
||||||
|
}
|
||||||
|
std::error_code ec;
|
||||||
|
std::filesystem::create_directories(config_folder, ec);
|
||||||
|
// A emscripten/MEMFS create_directories pot fallar (p.ex. parent
|
||||||
|
// read-only o libc++ amb path empty-check estricte). La config és
|
||||||
|
// volàtil al navegador de totes formes: ignorem l'error i continuem.
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* file_getconfigfolder() {
|
const char* file_getconfigfolder() {
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ namespace Menu {
|
|||||||
|
|
||||||
p.items.push_back({Locale::get("menu.items.show_title_credits"), ItemKind::Toggle, [] { return yesNo(Options::game.show_title_credits); }, [](int) { Options::game.show_title_credits = !Options::game.show_title_credits; }, nullptr});
|
p.items.push_back({Locale::get("menu.items.show_title_credits"), ItemKind::Toggle, [] { return yesNo(Options::game.show_title_credits); }, [](int) { Options::game.show_title_credits = !Options::game.show_title_credits; }, nullptr});
|
||||||
|
|
||||||
|
p.items.push_back({Locale::get("menu.items.show_preload"), ItemKind::Toggle, [] { return yesNo(Options::game.show_preload); }, [](int) { Options::game.show_preload = !Options::game.show_preload; }, nullptr});
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,4 +46,5 @@ namespace Defaults::Game {
|
|||||||
constexpr int DINERS_INICIAL = 0;
|
constexpr int DINERS_INICIAL = 0;
|
||||||
constexpr bool USE_NEW_LOGO = true;
|
constexpr bool USE_NEW_LOGO = true;
|
||||||
constexpr bool SHOW_TITLE_CREDITS = true;
|
constexpr bool SHOW_TITLE_CREDITS = true;
|
||||||
|
constexpr bool SHOW_PRELOAD = false;
|
||||||
} // namespace Defaults::Game
|
} // namespace Defaults::Game
|
||||||
|
|||||||
@@ -219,6 +219,8 @@ namespace Options {
|
|||||||
game.use_new_logo = node["use_new_logo"].get_value<bool>();
|
game.use_new_logo = node["use_new_logo"].get_value<bool>();
|
||||||
if (node.contains("show_title_credits"))
|
if (node.contains("show_title_credits"))
|
||||||
game.show_title_credits = node["show_title_credits"].get_value<bool>();
|
game.show_title_credits = node["show_title_credits"].get_value<bool>();
|
||||||
|
if (node.contains("show_preload"))
|
||||||
|
game.show_preload = node["show_preload"].get_value<bool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carrega les opcions des del fitxer configurat
|
// Carrega les opcions des del fitxer configurat
|
||||||
@@ -368,6 +370,7 @@ namespace Options {
|
|||||||
file << "game:\n";
|
file << "game:\n";
|
||||||
file << " use_new_logo: " << (game.use_new_logo ? "true" : "false") << "\n";
|
file << " use_new_logo: " << (game.use_new_logo ? "true" : "false") << "\n";
|
||||||
file << " show_title_credits: " << (game.show_title_credits ? "true" : "false") << "\n";
|
file << " show_title_credits: " << (game.show_title_credits ? "true" : "false") << "\n";
|
||||||
|
file << " show_preload: " << (game.show_preload ? "true" : "false") << "\n";
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
|
||||||
// CONTROLS — només moviment del jugador. Les tecles d'UI viuen a
|
// CONTROLS — només moviment del jugador. Les tecles d'UI viuen a
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ namespace Options {
|
|||||||
int diners_inicial{Defaults::Game::DINERS_INICIAL};
|
int diners_inicial{Defaults::Game::DINERS_INICIAL};
|
||||||
bool use_new_logo{Defaults::Game::USE_NEW_LOGO};
|
bool use_new_logo{Defaults::Game::USE_NEW_LOGO};
|
||||||
bool show_title_credits{Defaults::Game::SHOW_TITLE_CREDITS};
|
bool show_title_credits{Defaults::Game::SHOW_TITLE_CREDITS};
|
||||||
|
bool show_preload{Defaults::Game::SHOW_PRELOAD};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Preset PostFX
|
// Preset PostFX
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ SDL_AppResult SDL_AppInit(void** /*appstate*/, int /*argc*/, char* /*argv*/[]) {
|
|||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
// MEMFS no persistix entre recàrregues: força valors sensats per a web.
|
// MEMFS no persistix entre recàrregues: força valors sensats per a web.
|
||||||
Options::window.fullscreen = false;
|
Options::window.fullscreen = false;
|
||||||
Options::window.zoom = 1;
|
Options::window.zoom = 3;
|
||||||
Options::video.aspect_ratio_4_3 = true;
|
Options::video.aspect_ratio_4_3 = true;
|
||||||
Options::video.scaling_mode = Options::ScalingMode::INTEGER;
|
Options::video.scaling_mode = Options::ScalingMode::INTEGER;
|
||||||
Options::video.texture_filter = Options::TextureFilter::LINEAR;
|
Options::video.texture_filter = Options::TextureFilter::LINEAR;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "core/jail/jdraw8.hpp"
|
#include "core/jail/jdraw8.hpp"
|
||||||
#include "core/resources/resource_cache.hpp"
|
#include "core/resources/resource_cache.hpp"
|
||||||
|
#include "game/options.hpp"
|
||||||
|
|
||||||
namespace scenes {
|
namespace scenes {
|
||||||
|
|
||||||
@@ -37,6 +38,8 @@ namespace scenes {
|
|||||||
void BootLoaderScene::render() const {
|
void BootLoaderScene::render() const {
|
||||||
JD8_ClearScreen(BG_COLOR);
|
JD8_ClearScreen(BG_COLOR);
|
||||||
|
|
||||||
|
if (!Options::game.show_preload) return;
|
||||||
|
|
||||||
const float pct = Resource::Cache::get()->getProgress();
|
const float pct = Resource::Cache::get()->getProgress();
|
||||||
const int filled = static_cast<int>(static_cast<float>(BAR_W) * pct);
|
const int filled = static_cast<int>(static_cast<float>(BAR_W) * pct);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user