Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit f7adc0a

Browse files
committed
Change credits scroll mechanism to accomodate the "back to main" button.
Credits scroll duration lowered from 180 seconds to 90 seconds.
1 parent 3fe9948 commit f7adc0a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Menus/MainMenuGUI.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ int MainMenuGUI::Create(Controller *pController)
533533
}
534534

535535
// Read all the credits from the file and set the credits label
536-
GUILabel *pCreditsLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("CreditsLabel"));
536+
m_CreditsLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("CreditsLabel"));
537537
Reader creditsReader("Credits.txt");
538538
string creditsText = creditsReader.ReadTo('#', true);
539539

@@ -548,8 +548,8 @@ int MainMenuGUI::Create(Controller *pController)
548548
if (*sItr == -87)//'©')
549549
(*sItr) = (char)221;
550550
}
551-
pCreditsLabel->SetText(creditsText);
552-
m_pScrollPanel->Resize(m_pScrollPanel->GetWidth(), pCreditsLabel->ResizeHeightToFit());
551+
m_CreditsLabel->SetText(creditsText);
552+
m_CreditsLabel->ResizeHeightToFit();
553553

554554
// Set initial focus, category list, and label settings
555555
m_ScreenChange = true;
@@ -827,21 +827,20 @@ void MainMenuGUI::Update()
827827
m_MainMenuButtons[BACKTOMAIN]->SetVisible(true);
828828
m_apScreenBox[CREDITSSCREEN]->GUIPanel::AddChild(m_MainMenuButtons[BACKTOMAIN]);
829829
m_MainMenuButtons[BACKTOMAIN]->SetPositionRel(240, 298);
830-
// Set the scroll panel to be out of sight at the bottom of the credits screen box
831-
m_pScrollPanel->SetPositionRel(0, m_apScreenBox[CREDITSSCREEN]->GetHeight());
830+
m_pScrollPanel->SetPositionRel(0, 0);
831+
m_CreditsLabel->SetPositionRel(0, m_pScrollPanel->GetHeight());
832832
m_ScrollTimer.Reset();
833833
m_ScreenChange = false;
834834
}
835835

836-
long scrollTime = 180000;
836+
long scrollTime = 90000;
837837
float scrollProgress = (float)m_ScrollTimer.GetElapsedRealTimeMS() / (float)scrollTime;
838-
int scrollDist = -m_apScreenBox[CREDITSSCREEN]->GetHeight() + (-m_pScrollPanel->GetHeight());
839-
// Scroll the scroll panel upwards, GetYPos returns absolute coordinates
840-
m_pScrollPanel->SetPositionRel(0, m_apScreenBox[CREDITSSCREEN]->GetHeight() + (scrollDist * scrollProgress));
838+
int scrollDist = m_pScrollPanel->GetHeight() + m_CreditsLabel->GetHeight();
839+
m_CreditsLabel->SetPositionRel(0, m_pScrollPanel->GetHeight() - static_cast<int>(static_cast<float>(scrollDist) * scrollProgress));
841840
// If we've scrolled through the whole thing, reset to the bottom and restart scroll
842841
if (m_ScrollTimer.IsPastRealMS(scrollTime))
843842
{
844-
m_pScrollPanel->SetPositionRel(0, m_apScreenBox[CREDITSSCREEN]->GetHeight());
843+
m_CreditsLabel->SetPositionRel(0, m_pScrollPanel->GetHeight());
845844
m_ScrollTimer.Reset();
846845
}
847846

Menus/MainMenuGUI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ class MainMenuGUI {
713713
GUICollectionBox *m_pEditorPanel;
714714
// Scrolling panel for the credits
715715
GUICollectionBox *m_pScrollPanel;
716+
GUILabel *m_CreditsLabel; //!< The label containing all the credits text.
716717
// Timer for credits scrolling pacing
717718
Timer m_ScrollTimer;
718719

0 commit comments

Comments
 (0)