Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: show render scale and screen resolution to about window #1006

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ui/xemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ void sdl2_window_resize(struct sdl2_console *scon)
surface_height(scon->surface));
}

void xemu_get_window_size(int *width, int *height)
{
SDL_GetWindowSize(m_window, width, height);
}

static void sdl2_redraw(struct sdl2_console *scon)
{
if (scon->opengl) {
Expand Down
15 changes: 11 additions & 4 deletions ui/xui/main-menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,16 @@ void MainMenuAboutView::Draw()
const char *gl_vendor = (const char*)glGetString(GL_VENDOR);
sys_info_text = g_strdup_printf(
"CPU: %s\nOS Platform: %s\nOS Version: %s\nManufacturer: %s\n"
"GPU Model: %s\nDriver: %s\nShader: %s",
"GPU Model: %s\nDriver: %s\nShader: %s\n",
xemu_get_cpu_info(), xemu_get_os_platform(), xemu_get_os_info(), gl_vendor,
gl_renderer, gl_version, gl_shader_version);
}
int width = 0, height = 0;
xemu_get_window_size(&width, &height);

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

if (m_config_info_text == NULL) {
UpdateConfigInfoText();
Expand All @@ -864,11 +870,12 @@ void MainMenuAboutView::Draw()

SectionTitle("System Information");
ImGui::PushFont(g_font_mgr.m_fixed_width_font);
ImGui::InputTextMultiline("###systeminformation", (char *)sys_info_text,
strlen(sys_info_text),
ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 8),
ImGui::InputTextMultiline("###systeminformation", content,
strlen(content),
ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 11),
ImGuiInputTextFlags_ReadOnly);
ImGui::PopFont();
g_free(content);

SectionTitle("Config Information");
ImGui::PushFont(g_font_mgr.m_fixed_width_font);
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 *g_ui_display_mode_name[];

static inline
bool IsNavInputPressed(ImGuiNavInput i) {
ImGuiIO &io = ImGui::GetIO();
Expand Down
8 changes: 3 additions & 5 deletions ui/xui/popup-menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void PopupMenuItemDelegate::LostFocus() {}
void PopupMenuItemDelegate::PushFocus() {}
void PopupMenuItemDelegate::PopFocus() {}
bool PopupMenuItemDelegate::DidPop() { return false; }
const char *g_ui_display_mode_name[] = {"Center", "Scale", "Scale (Widescreen 16:9)", "Scale (4:3)", "Stretch"};

bool PopupMenuButton(std::string text, std::string icon = "")
{
Expand Down Expand Up @@ -252,16 +253,13 @@ bool PopupMenu::DrawItems(PopupMenuItemDelegate &nav)

class DisplayModePopupMenu : public virtual PopupMenu {
public:

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(g_ui_display_mode_name[i], "", selected))
g_config.display.ui.fit = i;
}

Expand Down
1 change: 1 addition & 0 deletions ui/xui/xemu-hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void xemu_monitor_init(void);
void xemu_toggle_fullscreen(void);
void xemu_eject_disc(void);
void xemu_load_disc(const char *path);
void xemu_get_window_size(int *width, int *height);

// Implemented in xemu_hud.cc
void xemu_hud_init(SDL_Window *window, void *sdl_gl_context);
Expand Down