From 21545e1a2444baa35ecf4f4c1b8b8f336e659731 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 12 Jul 2015 20:25:46 +0200 Subject: [PATCH] Show refresh rate in resolution selector --- Aquaria/AquariaComboBox.cpp | 10 +++++++--- Aquaria/AquariaMenuItem.h | 5 +++-- Aquaria/Game.cpp | 4 +++- BBGE/Core.cpp | 2 +- BBGE/Core.h | 6 +++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Aquaria/AquariaComboBox.cpp b/Aquaria/AquariaComboBox.cpp index ace3175..84cd7b5 100644 --- a/Aquaria/AquariaComboBox.cpp +++ b/Aquaria/AquariaComboBox.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SCROLL_DELAY 0.1f #define SCROLL_DELAY_FIRST 0.4f -AquariaComboBox::AquariaComboBox() : RenderObject() +AquariaComboBox::AquariaComboBox(Vector textscale) : RenderObject() { //Quad *bar, *window, *scrollBtnUp, *scrollBtnDown, *scrollBar; bar = new Quad("gui/combo-drop", Vector(0,0)); @@ -47,6 +47,7 @@ AquariaComboBox::AquariaComboBox() : RenderObject() selectedItemLabel->setFontSize(8); selectedItemLabel->offset.y = -10; selectedItemLabel->position.x = -50; + selectedItemLabel->scale = textscale; addChild(selectedItemLabel, PM_POINTER); numDrops = 8; @@ -62,6 +63,8 @@ AquariaComboBox::AquariaComboBox() : RenderObject() scrollDelay = 0; firstScroll = 0; + + this->textscale = textscale; } void AquariaComboBox::destroy() @@ -230,7 +233,7 @@ void AquariaComboBox::open(float t) { if (i < items.size()) { - AquariaComboBoxItem *a = new AquariaComboBoxItem(items[i], i, this); + AquariaComboBoxItem *a = new AquariaComboBoxItem(items[i], i, this, textscale); a->alpha = 0; a->alpha.interpolateTo(1, t); a->position.y = (a->getHeight()+2) * ((i-scroll)+1); @@ -335,7 +338,7 @@ int AquariaComboBox::addItem(const std::string &n) Vector unselectedColor(0.7, 0.7, 0.7); Vector selectedColor(1,1,1); -AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo) : Quad() +AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo, Vector textscale) : Quad() { this->combo = combo; index = idx; @@ -348,6 +351,7 @@ AquariaComboBoxItem::AquariaComboBoxItem(const std::string &str, int idx, Aquari label->setText(str); label->offset.y = -10; label->position.x = -50; + label->scale = textscale; addChild(label, PM_POINTER); color = unselectedColor; diff --git a/Aquaria/AquariaMenuItem.h b/Aquaria/AquariaMenuItem.h index 842ca39..ee7a85a 100644 --- a/Aquaria/AquariaMenuItem.h +++ b/Aquaria/AquariaMenuItem.h @@ -195,7 +195,7 @@ class AquariaComboBox; class AquariaComboBoxItem : public Quad { public: - AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo); + AquariaComboBoxItem(const std::string &str, int idx, AquariaComboBox *combo, Vector textscale); protected: void onUpdate(float dt); @@ -210,7 +210,7 @@ protected: class AquariaComboBox : public RenderObject { public: - AquariaComboBox(); + AquariaComboBox(Vector textscale = Vector(1, 1)); void destroy(); @@ -242,6 +242,7 @@ protected: int selectedItem; float scrollDelay; bool firstScroll; + Vector textscale; std::vector shownItems; }; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 159bb4c..824e8d2 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -3382,12 +3382,14 @@ void Game::createInGameMenu() resolutionLabel->position = Vector(160, 260); options->addChild(resolutionLabel, PM_POINTER); - resBox = new AquariaComboBox(); + resBox = new AquariaComboBox(Vector(0.7f, 1.0f)); resBox->position = Vector(196, 285); for (i = 0; i < core->screenModes.size(); i++) { std::ostringstream os; os << core->screenModes[i].x << "x" << core->screenModes[i].y; + if(core->screenModes[i].hz) + os << " (" << core->screenModes[i].hz << "hz)"; resBox->addItem(os.str()); if (core->screenModes[i].x == dsq->user.video.resx && core->screenModes[i].y == dsq->user.video.resy) { diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index eb78600..9d61c1a 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -2138,7 +2138,7 @@ void Core::enumerateScreenModes() SDL_GetDisplayMode(0, i, &mode); if (mode.w && mode.h && (mode.w > mode.h)) { - screenModes.push_back(ScreenMode(i, mode.w, mode.h)); + screenModes.push_back(ScreenMode(i, mode.w, mode.h, mode.refresh_rate)); } } diff --git a/BBGE/Core.h b/BBGE/Core.h index fda19c9..34799d8 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -70,10 +70,10 @@ enum TimeUpdateType struct ScreenMode { - ScreenMode() { idx = x = y = 0; } - ScreenMode(int i, int x, int y) : idx(i), x(x), y(y) {} + ScreenMode() { idx = x = y = hz = 0; } + ScreenMode(int i, int x, int y, int hz) : idx(i), x(x), y(y), hz(hz) {} - int idx, x, y; + int idx, x, y, hz; }; struct CoreSettings