From 03717e11d489d4abbd3da6252eaa29511d1bf292 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sat, 11 Jul 2015 23:53:25 +0200 Subject: [PATCH] Added aspect ratio in resolution list (#501) --- src/ui/maindialog.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index ec866b4d..665197e4 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -4545,6 +4545,15 @@ void CMainDialog::UpdateSceneResume(int rank) // Updates the list of modes. +int GCD(int a, int b) { + return (b == 0) ? a : GCD(b, a%b); +} +Math::IntPoint AspectRatio(Math::IntPoint resolution) +{ + int gcd = GCD(resolution.x, resolution.y); + return Math::IntPoint(static_cast(resolution.x) / gcd, static_cast(resolution.y) / gcd); +} + void CMainDialog::UpdateDisplayMode() { CWindow* pw; @@ -4563,7 +4572,8 @@ void CMainDialog::UpdateDisplayMode() for (Math::IntPoint mode : modes) { mode_text.str(""); - mode_text << mode.x << "x" << mode.y; + Math::IntPoint aspect = AspectRatio(mode); + mode_text << mode.x << "x" << mode.y << " [" << aspect.x << ":" << aspect.y << "]"; pl->SetItemName(i++, mode_text.str().c_str()); }