From 92fba32c5ef55afc21f10b039eb1f85a527b2c2c Mon Sep 17 00:00:00 2001 From: JoshuaJB Date: Sun, 29 Dec 2013 20:46:02 +0000 Subject: [PATCH] Some more C++ GUI cleanup. This was SVN commit r14436. --- source/gui/CCheckBox.cpp | 5 +++-- source/gui/IGUIButtonBehavior.cpp | 17 ++++------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/source/gui/CCheckBox.cpp b/source/gui/CCheckBox.cpp index 9f3fc8e004..ff4f41464b 100644 --- a/source/gui/CCheckBox.cpp +++ b/source/gui/CCheckBox.cpp @@ -103,11 +103,12 @@ void CCheckBox::HandleMessage(SGUIMessage &Message) { bool checked; + // Switch to opposite. GUI::GetSetting(this, "checked", checked); checked = !checked; GUI::SetSetting(this, "checked", checked); - - } break; + break; + } default: break; diff --git a/source/gui/IGUIButtonBehavior.cpp b/source/gui/IGUIButtonBehavior.cpp index 973395b43c..93b8f785d7 100644 --- a/source/gui/IGUIButtonBehavior.cpp +++ b/source/gui/IGUIButtonBehavior.cpp @@ -40,6 +40,7 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) { bool enabled; GUI::GetSetting(this, "enabled", enabled); + CStrW soundPath; // TODO Gee: easier access functions switch (Message.type) { @@ -48,7 +49,6 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) if (!enabled) break; - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_enter", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } @@ -59,7 +59,6 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) if (!enabled) break; - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_leave", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } @@ -70,13 +69,11 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) { if (!enabled) { - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_pressed", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); @@ -99,13 +96,11 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) { if (!enabled) { - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_disabled", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); break; } - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_pressed", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); @@ -131,7 +126,6 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) if (m_PressedRight) { m_PressedRight = false; - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_released", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } @@ -146,7 +140,6 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message) if (m_Pressed) { m_Pressed = false; - CStrW soundPath; if (g_SoundManager && GUI::GetSetting(this, "sound_released", soundPath) == PSRETURN_OK && !soundPath.empty()) g_SoundManager->PlayAsUI(soundPath.c_str(), false); } @@ -204,17 +197,15 @@ void IGUIButtonBehavior::DrawButton(const CRect &rect, GUI::GetSetting(this, "enabled", enabled); if (!enabled) - { GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_disabled, sprite), cell_id, z, rect); - } - else - if (m_MouseHovering) + else if (m_MouseHovering) { if (m_Pressed) GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_pressed, sprite), cell_id, z, rect); else GetGUI()->DrawSprite(GUI<>::FallBackSprite(sprite_over, sprite), cell_id, z, rect); } - else GetGUI()->DrawSprite(sprite, cell_id, z, rect); + else + GetGUI()->DrawSprite(sprite, cell_id, z, rect); } }