Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
formatting and removed ifdef around setting declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRGriswold committed Jul 17, 2024
1 parent 33265a7 commit 4e5ba66
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 55 deletions.
1 change: 0 additions & 1 deletion src/android/app/src/main/jni/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ void Config::ReadValues() {
ReadSetting("Layout", Settings::values.custom_portrait_bottom_bottom);
#endif


// Utility
ReadSetting("Utility", Settings::values.dump_textures);
ReadSetting("Utility", Settings::values.custom_textures);
Expand Down
29 changes: 13 additions & 16 deletions src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class Setting {
explicit Setting(const Type& default_val, const Type& min_val, const Type& max_val,
const std::string& name)
requires(ranged)
: value{default_val},
default_value{default_val}, maximum{max_val}, minimum{min_val}, label{name} {}
: value{default_val}, default_value{default_val}, maximum{max_val}, minimum{min_val},
label{name} {}

/**
* Returns a reference to the setting's value.
Expand Down Expand Up @@ -450,7 +450,7 @@ struct Values {
Setting<bool> allow_plugin_loader{true, "allow_plugin_loader"};

// Renderer
SwitchableSetting<GraphicsAPI, true> graphics_api {
SwitchableSetting<GraphicsAPI, true> graphics_api{
#if defined(ENABLE_OPENGL)
GraphicsAPI::OpenGL,
#elif defined(ENABLE_VULKAN)
Expand All @@ -461,8 +461,7 @@ struct Values {
// TODO: Add a null renderer backend for this, perhaps.
#error "At least one renderer must be enabled."
#endif
GraphicsAPI::Software, GraphicsAPI::Vulkan, "graphics_api"
};
GraphicsAPI::Software, GraphicsAPI::Vulkan, "graphics_api"};
SwitchableSetting<u32> physical_device{0, "physical_device"};
Setting<bool> use_gles{false, "use_gles"};
Setting<bool> renderer_debug{false, "renderer_debug"};
Expand Down Expand Up @@ -499,17 +498,15 @@ struct Values {
Setting<u16> custom_bottom_bottom{480, "custom_bottom_bottom"};
Setting<u16> custom_second_layer_opacity{100, "custom_second_layer_opacity"};

#ifdef ANDROID
Setting<bool> custom_portrait_layout{false, "custom_portrait_layout"};
Setting<u16> custom_portrait_top_left{0, "custom_portrait_top_left"};
Setting<u16> custom_portrait_top_top{0, "custom_portrait_top_top"};
Setting<u16> custom_portrait_top_right{400, "custom_portrait_top_right"};
Setting<u16> custom_portrait_top_bottom{240, "custom_portrait_top_bottom"};
Setting<u16> custom_portrait_bottom_left{40, "custom_portrait_bottom_left"};
Setting<u16> custom_portrait_bottom_top{240, "custom_portrait_bottom_top"};
Setting<u16> custom_portrait_bottom_right{360, "custom_portrait_bottom_right"};
Setting<u16> custom_portrait_bottom_bottom{480, "custom_portrait_bottom_bottom"};
#endif
Setting<bool> custom_portrait_layout{false, "custom_portrait_layout"};
Setting<u16> custom_portrait_top_left{0, "custom_portrait_top_left"};
Setting<u16> custom_portrait_top_top{0, "custom_portrait_top_top"};
Setting<u16> custom_portrait_top_right{400, "custom_portrait_top_right"};
Setting<u16> custom_portrait_top_bottom{240, "custom_portrait_top_bottom"};
Setting<u16> custom_portrait_bottom_left{40, "custom_portrait_bottom_left"};
Setting<u16> custom_portrait_bottom_top{240, "custom_portrait_bottom_top"};
Setting<u16> custom_portrait_bottom_right{360, "custom_portrait_bottom_right"};
Setting<u16> custom_portrait_bottom_bottom{480, "custom_portrait_bottom_bottom"};

SwitchableSetting<float> bg_red{0.f, "bg_red"};
SwitchableSetting<float> bg_green{0.f, "bg_green"};
Expand Down
4 changes: 2 additions & 2 deletions src/core/frontend/emu_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
const auto min_size =
Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen.GetValue());

if ((Settings::values.custom_layout.GetValue() == true && ! is_portrait_mode) ||
(Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode)) {
if ((Settings::values.custom_layout.GetValue() == true && !is_portrait_mode) ||
(Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode)) {
layout = Layout::CustomFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
is_portrait_mode);
} else {
Expand Down
61 changes: 26 additions & 35 deletions src/core/frontend/framebuffer_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,30 +376,22 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool
ASSERT(height > 0);

FramebufferLayout res{width, height, true, true, {}, {}, !Settings::values.upright_screen};
u16 top_left = is_portrait_mode ?
Settings::values.custom_portrait_top_left.GetValue() :
Settings::values.custom_top_left.GetValue();
u16 top_right = is_portrait_mode ?
Settings::values.custom_portrait_top_right.GetValue() :
Settings::values.custom_top_right.GetValue();
u16 top_top = is_portrait_mode ?
Settings::values.custom_portrait_top_top.GetValue() :
Settings::values.custom_top_top.GetValue();
u16 top_bottom = is_portrait_mode ?
Settings::values.custom_portrait_top_bottom.GetValue() :
Settings::values.custom_top_bottom.GetValue();
u16 bottom_left = is_portrait_mode ?
Settings::values.custom_portrait_bottom_left.GetValue() :
Settings::values.custom_bottom_left.GetValue();
u16 bottom_right = is_portrait_mode ?
Settings::values.custom_portrait_bottom_right.GetValue() :
Settings::values.custom_bottom_right.GetValue();
u16 bottom_top = is_portrait_mode ?
Settings::values.custom_portrait_bottom_top.GetValue() :
Settings::values.custom_bottom_top.GetValue();
u16 bottom_bottom = is_portrait_mode ?
Settings::values.custom_portrait_bottom_bottom.GetValue() :
Settings::values.custom_bottom_bottom.GetValue();
u16 top_left = is_portrait_mode ? Settings::values.custom_portrait_top_left.GetValue()
: Settings::values.custom_top_left.GetValue();
u16 top_right = is_portrait_mode ? Settings::values.custom_portrait_top_right.GetValue()
: Settings::values.custom_top_right.GetValue();
u16 top_top = is_portrait_mode ? Settings::values.custom_portrait_top_top.GetValue()
: Settings::values.custom_top_top.GetValue();
u16 top_bottom = is_portrait_mode ? Settings::values.custom_portrait_top_bottom.GetValue()
: Settings::values.custom_top_bottom.GetValue();
u16 bottom_left = is_portrait_mode ? Settings::values.custom_portrait_bottom_left.GetValue()
: Settings::values.custom_bottom_left.GetValue();
u16 bottom_right = is_portrait_mode ? Settings::values.custom_portrait_bottom_right.GetValue()
: Settings::values.custom_bottom_right.GetValue();
u16 bottom_top = is_portrait_mode ? Settings::values.custom_portrait_bottom_top.GetValue()
: Settings::values.custom_bottom_top.GetValue();
u16 bottom_bottom = is_portrait_mode ? Settings::values.custom_portrait_bottom_bottom.GetValue()
: Settings::values.custom_bottom_bottom.GetValue();

Common::Rectangle<u32> top_screen{top_left, top_top, top_right, top_bottom};
Common::Rectangle<u32> bot_screen{bottom_left, bottom_top, bottom_right, bottom_bottom};
Expand All @@ -416,21 +408,20 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool

FramebufferLayout FrameLayoutFromResolutionScale(u32 res_scale, bool is_secondary) {
bool is_portrait_mode =
Settings::values.layout_option.GetValue() == Settings::LayoutOption::MobilePortrait;
if (Settings::values.custom_layout.GetValue() == true && ! is_portrait_mode) {
Settings::values.layout_option.GetValue() == Settings::LayoutOption::MobilePortrait;
if (Settings::values.custom_layout.GetValue() == true && !is_portrait_mode) {
return CustomFrameLayout(std::max(Settings::values.custom_top_right.GetValue(),
Settings::values.custom_bottom_right.GetValue()),
std::max(Settings::values.custom_top_bottom.GetValue(),
Settings::values.custom_bottom_bottom.GetValue()),
Settings::values.swap_screen.GetValue(),
is_portrait_mode);
}else if (Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode) {
return CustomFrameLayout(std::max(Settings::values.custom_portrait_top_right.GetValue(),
Settings::values.custom_portrait_bottom_right.GetValue()),
std::max(Settings::values.custom_portrait_top_bottom.GetValue(),
Settings::values.custom_portrait_bottom_bottom.GetValue()),
Settings::values.swap_screen.GetValue(),
is_portrait_mode);
Settings::values.swap_screen.GetValue(), is_portrait_mode);
} else if (Settings::values.custom_portrait_layout.GetValue() == true && is_portrait_mode) {
return CustomFrameLayout(
std::max(Settings::values.custom_portrait_top_right.GetValue(),
Settings::values.custom_portrait_bottom_right.GetValue()),
std::max(Settings::values.custom_portrait_top_bottom.GetValue(),
Settings::values.custom_portrait_bottom_bottom.GetValue()),
Settings::values.swap_screen.GetValue(), is_portrait_mode);
}

int width, height;
Expand Down
3 changes: 2 additions & 1 deletion src/core/frontend/framebuffer_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ FramebufferLayout SeparateWindowsLayout(u32 width, u32 height, bool is_secondary
* @param height Window framebuffer height in pixels
* @return Newly created FramebufferLayout object with default screen regions initialized
*/
FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool is_portrait_mode = false);
FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped,
bool is_portrait_mode = false);

/**
* Convenience method to get frame layout by resolution scale
Expand Down

0 comments on commit 4e5ba66

Please sign in to comment.