From 507ecff2ed1685b68eac6b661153882ded5b798a Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 11 Dec 2016 21:15:50 +0000 Subject: [PATCH] Scroll to the top when switching between tabs in the credits. Patch by vladislavbelov This was SVN commit r19036. --- binaries/data/mods/mod/gui/gui.rnc | 1 + binaries/data/mods/mod/gui/gui.rng | 5 +++++ binaries/data/mods/public/gui/credits/credits.xml | 2 +- source/gui/CText.cpp | 10 +++++++--- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/mod/gui/gui.rnc b/binaries/data/mods/mod/gui/gui.rnc index 034078d700..4e3f42b59b 100644 --- a/binaries/data/mods/mod/gui/gui.rnc +++ b/binaries/data/mods/mod/gui/gui.rnc @@ -71,6 +71,7 @@ ex_settings = attribute scrollbar { bool }?& attribute scrollbar_style { text }?& attribute scroll_bottom { bool }?& + attribute scroll_top { bool }?& attribute selected_column { text }?& attribute selected_column_order { text }?& attribute sortable { bool }?& diff --git a/binaries/data/mods/mod/gui/gui.rng b/binaries/data/mods/mod/gui/gui.rng index fde243b43d..758418ddc4 100644 --- a/binaries/data/mods/mod/gui/gui.rng +++ b/binaries/data/mods/mod/gui/gui.rng @@ -289,6 +289,11 @@ + + + + + diff --git a/binaries/data/mods/public/gui/credits/credits.xml b/binaries/data/mods/public/gui/credits/credits.xml index d780226f77..8875a02165 100644 --- a/binaries/data/mods/public/gui/credits/credits.xml +++ b/binaries/data/mods/public/gui/credits/credits.xml @@ -28,7 +28,7 @@ - + diff --git a/source/gui/CText.cpp b/source/gui/CText.cpp index 34c11cfa30..5a2d6be813 100644 --- a/source/gui/CText.cpp +++ b/source/gui/CText.cpp @@ -34,6 +34,7 @@ CText::CText() AddSetting(GUIST_bool, "scrollbar"); AddSetting(GUIST_CStr, "scrollbar_style"); AddSetting(GUIST_bool, "scroll_bottom"); + AddSetting(GUIST_bool, "scroll_top"); AddSetting(GUIST_CGUISpriteInstance, "sprite"); AddSetting(GUIST_EAlign, "text_align"); AddSetting(GUIST_EVAlign, "text_valign"); @@ -97,15 +98,16 @@ void CText::SetupText() // Setup scrollbar if (scrollbar) { - bool scrollbottom = false; - GUI::GetSetting(this, "scroll_bottom", scrollbottom); + bool scroll_top = false, scroll_bottom = false; + GUI::GetSetting(this, "scroll_bottom", scroll_bottom); + GUI::GetSetting(this, "scroll_top", scroll_top); // If we are currently scrolled to the bottom of the text, // then add more lines of text, update the scrollbar so we // stick to the bottom. // (Use 1.5px delta so this triggers the first time caption is set) bool bottom = false; - if (scrollbottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f) + if (scroll_bottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f) bottom = true; GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0]->m_Size.cy); @@ -118,6 +120,8 @@ void CText::SetupText() if (bottom) GetScrollBar(0).SetPos(GetScrollBar(0).GetMaxPos()); + if (scroll_top) + GetScrollBar(0).SetPos(0.0f); } }