Added option for turn on/off smooth scroll
This commit is contained in:
@ -61,6 +61,10 @@ void OptionsState::handleEvent(const SDL_Event& e) {
|
||||
toggleSoundFx();
|
||||
return;
|
||||
}
|
||||
if (m_selectedField == Field::SmoothScroll) {
|
||||
toggleSmoothScroll();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -151,7 +155,7 @@ void OptionsState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
||||
SDL_SetRenderDrawColor(renderer, 40, 80, 140, 240);
|
||||
SDL_RenderRect(renderer, &inner);
|
||||
|
||||
constexpr int rowCount = 4;
|
||||
constexpr int rowCount = 5;
|
||||
const float rowHeight = 60.0f;
|
||||
const float spacing = std::max(0.0f, (inner.h - rowHeight * rowCount) / (rowCount + 1));
|
||||
|
||||
@ -180,7 +184,7 @@ void OptionsState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
||||
int valueW = 0, valueH = 0;
|
||||
float valueScale = (field == Field::Back) ? 1.3f : 1.5f;
|
||||
retroFont->measure(value, valueScale, valueW, valueH);
|
||||
bool rightAlign = (field == Field::Fullscreen || field == Field::Music || field == Field::SoundFx);
|
||||
bool rightAlign = (field == Field::Fullscreen || field == Field::Music || field == Field::SoundFx || field == Field::SmoothScroll);
|
||||
float valX = rightAlign
|
||||
? (row.x + row.w - static_cast<float>(valueW) - 16.0f)
|
||||
: (row.x + (row.w - static_cast<float>(valueW)) * 0.5f);
|
||||
@ -197,6 +201,8 @@ void OptionsState::render(SDL_Renderer* renderer, float logicalScale, SDL_Rect l
|
||||
rowY += rowHeight + spacing;
|
||||
drawField(Field::SoundFx, rowY, "SOUND FX", isSoundFxEnabled() ? "ON" : "OFF");
|
||||
rowY += rowHeight + spacing;
|
||||
drawField(Field::SmoothScroll, rowY, "SMOOTH SCROLL", isSmoothScrollEnabled() ? "ON" : "OFF");
|
||||
rowY += rowHeight + spacing;
|
||||
drawField(Field::Back, rowY, "", "RETURN TO MENU");
|
||||
|
||||
(void)retroFont; // footer removed for cleaner layout
|
||||
@ -220,6 +226,9 @@ void OptionsState::activateSelection() {
|
||||
case Field::SoundFx:
|
||||
toggleSoundFx();
|
||||
break;
|
||||
case Field::SmoothScroll:
|
||||
toggleSmoothScroll();
|
||||
break;
|
||||
case Field::Back:
|
||||
exitToMenu();
|
||||
break;
|
||||
@ -266,6 +275,12 @@ void OptionsState::toggleSoundFx() {
|
||||
Settings::instance().save();
|
||||
}
|
||||
|
||||
void OptionsState::toggleSmoothScroll() {
|
||||
bool next = !Settings::instance().isSmoothScrollEnabled();
|
||||
Settings::instance().setSmoothScrollEnabled(next);
|
||||
Settings::instance().save();
|
||||
}
|
||||
|
||||
void OptionsState::exitToMenu() {
|
||||
if (ctx.requestFadeTransition) {
|
||||
ctx.requestFadeTransition(AppState::Menu);
|
||||
@ -291,3 +306,7 @@ bool OptionsState::isMusicEnabled() const {
|
||||
bool OptionsState::isSoundFxEnabled() const {
|
||||
return SoundEffectManager::instance().isEnabled();
|
||||
}
|
||||
|
||||
bool OptionsState::isSmoothScrollEnabled() const {
|
||||
return Settings::instance().isSmoothScrollEnabled();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user