Advertisement
vladislavbelov

Credits/Text scroll top

Dec 10th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.11 KB | None | 0 0
  1. Index: binaries/data/mods/mod/gui/gui.rnc
  2. ===================================================================
  3. --- binaries/data/mods/mod/gui/gui.rnc  (revision 19029)
  4. +++ binaries/data/mods/mod/gui/gui.rnc  (working copy)
  5. @@ -71,6 +71,7 @@
  6.    attribute scrollbar { bool }?&
  7.    attribute scrollbar_style { text }?&
  8.    attribute scroll_bottom { bool }?&
  9. +  attribute scroll_top { bool }?&
  10.    attribute selected_column { text }?&
  11.    attribute selected_column_order { text }?&
  12.    attribute sortable { bool }?&
  13. Index: binaries/data/mods/mod/gui/gui.rng
  14. ===================================================================
  15. --- binaries/data/mods/mod/gui/gui.rng  (revision 19029)
  16. +++ binaries/data/mods/mod/gui/gui.rng  (working copy)
  17. @@ -290,6 +290,11 @@
  18.          </attribute>
  19.        </optional>
  20.        <optional>
  21. +        <attribute name="scroll_top">
  22. +          <ref name="bool"/>
  23. +        </attribute>
  24. +      </optional>
  25. +      <optional>
  26.          <attribute name="selected_column"/>
  27.        </optional>
  28.        <optional>
  29. Index: binaries/data/mods/public/gui/credits/credits.xml
  30. ===================================================================
  31. --- binaries/data/mods/public/gui/credits/credits.xml   (revision 19029)
  32. +++ binaries/data/mods/public/gui/credits/credits.xml   (working copy)
  33. @@ -28,7 +28,7 @@
  34.         </object>
  35.  
  36.         <object type="image" sprite="ModernFade" size="220 30 100%-20 100%-54">
  37. -           <object name="creditsText" type="text" style="textPanel"/>
  38. +           <object name="creditsText" type="text" style="textPanel" scroll_top="true" />
  39.         </object>
  40.  
  41.         <!-- Close dialog -->
  42. Index: source/gui/CText.cpp
  43. ===================================================================
  44. --- source/gui/CText.cpp    (revision 19029)
  45. +++ source/gui/CText.cpp    (working copy)
  46. @@ -34,6 +34,7 @@
  47.     AddSetting(GUIST_bool,                  "scrollbar");
  48.     AddSetting(GUIST_CStr,                  "scrollbar_style");
  49.     AddSetting(GUIST_bool,                  "scroll_bottom");
  50. +   AddSetting(GUIST_bool,                  "scroll_top");
  51.     AddSetting(GUIST_CGUISpriteInstance,    "sprite");
  52.     AddSetting(GUIST_EAlign,                "text_align");
  53.     AddSetting(GUIST_EVAlign,               "text_valign");
  54. @@ -97,8 +98,9 @@
  55.     // Setup scrollbar
  56.     if (scrollbar)
  57.     {
  58. -       bool scrollbottom = false;
  59. -       GUI<bool>::GetSetting(this, "scroll_bottom", scrollbottom);
  60. +       bool scroll_top = false, scroll_bottom = false;
  61. +       GUI<bool>::GetSetting(this, "scroll_bottom", scroll_bottom);
  62. +       GUI<bool>::GetSetting(this, "scroll_top", scroll_top);
  63.  
  64.         // If we are currently scrolled to the bottom of the text,
  65.         // then add more lines of text, update the scrollbar so we
  66. @@ -105,7 +107,7 @@
  67.         // stick to the bottom.
  68.         // (Use 1.5px delta so this triggers the first time caption is set)
  69.         bool bottom = false;
  70. -       if (scrollbottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f)
  71. +       if (scroll_bottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f)
  72.             bottom = true;
  73.  
  74.         GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0]->m_Size.cy);
  75. @@ -118,6 +120,8 @@
  76.  
  77.         if (bottom)
  78.             GetScrollBar(0).SetPos(GetScrollBar(0).GetMaxPos());
  79. +       if (scroll_top)
  80. +           GetScrollBar(0).SetPos(0.0f);
  81.     }
  82.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement