Skip to content

Commit

Permalink
Add array in misc.hh to avoid double translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabxx committed Jun 20, 2022
1 parent a612e02 commit 8042e0a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/xui/main-menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void MainMenuAboutView::Draw()

char *content = g_strdup_printf("%sScaling: %dx\nResolution: %dx%d\nDisplay Mode: %s",
sys_info_text, nv2a_get_surface_scale_factor(),
width, height, GetDisplayMode());
width, height, display_modes[g_config.display.ui.fit]);

static uint32_t time_start = 0;
if (ImGui::IsWindowAppearing()) {
Expand Down
2 changes: 2 additions & 0 deletions ui/xui/misc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern "C" {
#include <noc_file_dialog.h>
}

extern const char **display_modes;

This comment has been minimized.

Copy link
@abaire

abaire Jun 20, 2022

Contributor

You should decorate this name somehow "display_modes" is very generic and you're putting this into the default C namespace so there's a high chance that there will be a conflict. Call it something more verbose like "g_ui_display_mode_name" or "g_ui_display_mode_translation_table"


static inline
bool IsNavInputPressed(ImGuiNavInput i) {
ImGuiIO &io = ImGui::GetIO();
Expand Down
14 changes: 2 additions & 12 deletions ui/xui/popup-menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,13 @@ bool PopupMenu::DrawItems(PopupMenuItemDelegate &nav)

class DisplayModePopupMenu : public virtual PopupMenu {
public:
const char *GetDisplayMode()
{
const char *values[] = {
"Center", "Scale", "Scale (Widescreen 16:9)", "Scale (4:3)", "Stretch"
};
return values[g_config.display.ui.fit];
}

bool DrawItems(PopupMenuItemDelegate &nav) override
{
const char *values[] = {
"Center", "Scale", "Scale (Widescreen 16:9)", "Scale (4:3)", "Stretch"
};

for (int i = 0; i < CONFIG_DISPLAY_UI_FIT__COUNT; i++) {
bool selected = g_config.display.ui.fit == i;
if (m_focus && selected) ImGui::SetKeyboardFocusHere();
if (PopupMenuCheck(values[i], "", selected))
if (PopupMenuCheck(display_modes[i], "", selected))
g_config.display.ui.fit = i;
}

Expand Down

0 comments on commit 8042e0a

Please sign in to comment.