mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-05-31 08:51:35 -04:00
Hook up cutscene aspect ratio setting (#43)
This commit is contained in:
@@ -24,6 +24,10 @@ namespace banjo {
|
||||
namespace sound {
|
||||
inline const std::string bgm_volume = "bgm_volume";
|
||||
}
|
||||
|
||||
namespace graphics {
|
||||
inline const std::string cutscene_aspect_ratio_mode = "cutscene_aspect_ratio_mode";
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Move loading configs to the runtime once we have a way to allow per-project customization.
|
||||
@@ -70,6 +74,15 @@ namespace banjo {
|
||||
|
||||
NoteSavingMode get_note_saving_mode();
|
||||
|
||||
enum class CutsceneAspectRatioMode {
|
||||
Original,
|
||||
Clamp16x9,
|
||||
Full,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
CutsceneAspectRatioMode get_cutscene_aspect_ratio_mode();
|
||||
|
||||
void open_quit_game_prompt();
|
||||
};
|
||||
|
||||
|
||||
@@ -117,6 +117,11 @@ banjo::AnalogCamMode banjo::get_analog_cam_mode() {
|
||||
return get_general_config_enum_value<banjo::AnalogCamMode>(banjo::configkeys::general::analog_cam_mode);
|
||||
}
|
||||
|
||||
template <typename T = uint32_t>
|
||||
T get_graphics_config_enum_value(const std::string& option_id) {
|
||||
return static_cast<T>(std::get<uint32_t>(recompui::config::get_graphics_config().get_option_value(option_id)));
|
||||
}
|
||||
|
||||
static void add_sound_options(recomp::config::Config &config) {
|
||||
config.add_percent_number_option(
|
||||
banjo::configkeys::sound::bgm_volume,
|
||||
@@ -134,6 +139,26 @@ int banjo::get_bgm_volume() {
|
||||
return get_sound_config_number_value<int>(banjo::configkeys::sound::bgm_volume);
|
||||
}
|
||||
|
||||
static void add_graphics_options(recomp::config::Config &config) {
|
||||
using EnumOptionVector = const std::vector<recomp::config::ConfigOptionEnumOption>;
|
||||
static EnumOptionVector cutscene_aspect_ratio_mode_options = {
|
||||
{banjo::CutsceneAspectRatioMode::Original, "Original", "Original"},
|
||||
{banjo::CutsceneAspectRatioMode::Clamp16x9, "Clamp16x9", "16:9"},
|
||||
{banjo::CutsceneAspectRatioMode::Full, "Expand", "Expand"},
|
||||
};
|
||||
config.add_enum_option(
|
||||
banjo::configkeys::graphics::cutscene_aspect_ratio_mode,
|
||||
"Cutscene Aspect Ratio",
|
||||
"Sets the aspect ratio limit for cutscenes. Cutscenes have been adjusted to work in <recomp-color primary>16:9</recomp-color>, which is the default option. Wider aspect ratios may show details that weren't meant to be on-screen.",
|
||||
cutscene_aspect_ratio_mode_options,
|
||||
banjo::CutsceneAspectRatioMode::Clamp16x9
|
||||
);
|
||||
}
|
||||
|
||||
banjo::CutsceneAspectRatioMode banjo::get_cutscene_aspect_ratio_mode() {
|
||||
return get_graphics_config_enum_value<banjo::CutsceneAspectRatioMode>(banjo::configkeys::graphics::cutscene_aspect_ratio_mode);
|
||||
}
|
||||
|
||||
void banjo::init_config() {
|
||||
std::filesystem::path recomp_dir = recompui::file::get_app_folder_path();
|
||||
|
||||
@@ -150,6 +175,7 @@ void banjo::init_config() {
|
||||
add_general_options(general_config);
|
||||
|
||||
auto &graphics_config = recompui::config::create_graphics_tab();
|
||||
add_graphics_options(graphics_config);
|
||||
|
||||
recompui::config::create_controls_tab();
|
||||
|
||||
|
||||
+16
-2
@@ -104,8 +104,22 @@ extern "C" void recomp_get_target_aspect_ratio(uint8_t* rdram, recomp_context* c
|
||||
}
|
||||
|
||||
extern "C" void recomp_get_cutscene_aspect_ratio(uint8_t *rdram, recomp_context *ctx) {
|
||||
float ar = 16.0f / 9.0f;
|
||||
_return(ctx, ar);
|
||||
float original = _arg<0, float>(rdram, ctx);
|
||||
int width, height;
|
||||
recompui::get_window_size(width, height);
|
||||
|
||||
switch (banjo::get_cutscene_aspect_ratio_mode()) {
|
||||
case banjo::CutsceneAspectRatioMode::Original:
|
||||
_return(ctx, original);
|
||||
return;
|
||||
case banjo::CutsceneAspectRatioMode::Clamp16x9:
|
||||
default:
|
||||
_return(ctx, 16.0f / 9.0f);
|
||||
return;
|
||||
case banjo::CutsceneAspectRatioMode::Full:
|
||||
_return(ctx, std::max(static_cast<float>(width) / height, original));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void recomp_get_bgm_volume(uint8_t* rdram, recomp_context* ctx) {
|
||||
|
||||
Reference in New Issue
Block a user