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

Commit 5965006

Browse files
committed
Fix knob position again
1 parent 3910fa6 commit 5965006

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

GUI/GUISlider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ void GUISlider::OnMouseWheelChange(int x, int y, int modifier, int mouseWheelCha
475475
if (m_Value != m_OldValue) {
476476
const int size = (m_Orientation == Horizontal) ? m_Width : m_Height;
477477
const int posRange = size - m_KnobSize - m_EndThickness;
478-
const float ratio = static_cast<float>(m_Value) / static_cast<float>(m_Maximum - m_Minimum);
479-
m_KnobPosition = m_EndThickness + static_cast<int>(std::round(static_cast<float>(posRange) * ratio));
478+
const float ratio = static_cast<float>(m_Value - m_Minimum) / static_cast<float>(m_Maximum - m_Minimum);
479+
m_KnobPosition = std::max(m_EndThickness, static_cast<int>(std::round(static_cast<float>(posRange) * ratio)));
480480

481481
AddEvent(GUIEvent::Notification, Changed, 0);
482482
}

Menus/MetagameGUI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ int MetagameGUI::Create(Controller *pController)
546546
m_pGoldSlider = dynamic_cast<GUISlider *>(m_pGUIController->GetControl("GoldSlider"));
547547
m_pLengthLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("LengthLabel"));
548548
m_pLengthSlider = dynamic_cast<GUISlider *>(m_pGUIController->GetControl("LengthSlider"));
549+
549550
m_pErrorLabel = dynamic_cast<GUILabel *>(m_pGUIController->GetControl("StartErrorLabel"));
550551
m_apPlayerControlButton[Players::PlayerOne] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("P1ControlButton"));
551552
m_apPlayerControlButton[Players::PlayerTwo] = dynamic_cast<GUIButton *>(m_pGUIController->GetControl("P2ControlButton"));
@@ -1169,7 +1170,7 @@ bool MetagameGUI::StartNewGame()
11691170

11701171
// Set the starting brains for this player
11711172
// Start with the baseline setting
1172-
newPlayer.m_BrainPool = ceilf(BRAINPOOLMAX * ((float)m_pLengthSlider->GetValue() / 100.0));
1173+
newPlayer.m_BrainPool = m_pLengthSlider->GetValue();
11731174
// Baseline can never be 0
11741175
newPlayer.m_BrainPool = MAX(newPlayer.m_BrainPool, 1);
11751176
// Apply the handicap!
@@ -6258,8 +6259,7 @@ void MetagameGUI::UpdateGameSizeLabels()
62586259
m_pGoldLabel->SetText(str);
62596260

62606261
// Set the length label also according to the game length slider
6261-
// TODO: don't hardcode the range of this
6262-
int brainCount = ceilf(BRAINPOOLMAX * ((float)m_pLengthSlider->GetValue() / 100.0));
6262+
int brainCount = m_pLengthSlider->GetValue();
62636263
brainCount = MAX(brainCount, 1);
62646264
sprintf_s(str, sizeof(str), "Game Length: %c%c%d starting brains", -48, -36, brainCount);
62656265
m_pLengthLabel->SetText(str);

0 commit comments

Comments
 (0)