Jelajahi Sumber

widgets: Cleanup musicButton specific hacks

Sandy Carter 10 tahun lalu
induk
melakukan
236492ed39
2 mengubah file dengan 3 tambahan dan 29 penghapusan
  1. 2 24
      client/widgets/Buttons.cpp
  2. 1 5
      client/widgets/Buttons.h

+ 2 - 24
client/widgets/Buttons.cpp

@@ -419,8 +419,8 @@ void CToggleGroup::addToggle(int identifier, CToggleBase* bt)
 	buttons[identifier] = bt;
 }
 
-CToggleGroup::CToggleGroup(const CFunctionList<void(int)> &OnChange, bool musicLikeButtons)
-: onChange(OnChange), selectedID(-2), musicLike(musicLikeButtons)
+CToggleGroup::CToggleGroup(const CFunctionList<void(int)> &OnChange)
+: onChange(OnChange), selectedID(-2)
 {}
 
 void CToggleGroup::setSelected(int id)
@@ -447,28 +447,6 @@ void CToggleGroup::selectionChanged(int to)
 		parent->redraw();
 }
 
-void CToggleGroup::show(SDL_Surface * to)
-{
-	if (musicLike)
-	{
-		if (auto intObj = dynamic_cast<CIntObject*>(buttons[selectedID])) // hack-ish workagound to avoid diamond problem with inheritance
-			intObj->show(to);
-	}
-	else
-		CIntObject::show(to);
-}
-
-void CToggleGroup::showAll(SDL_Surface * to)
-{
-	if (musicLike)
-	{
-		if (auto intObj = dynamic_cast<CIntObject*>(buttons[selectedID])) // hack-ish workagound to avoid diamond problem with inheritance
-			intObj->showAll(to);
-	}
-	else
-		CIntObject::showAll(to);
-}
-
 CVolumeSlider::CVolumeSlider(const Point &position, const std::string &defName, const int value,
                              const std::pair<std::string, std::string> * const help) :
 	value(value),

+ 1 - 5
client/widgets/Buttons.h

@@ -178,12 +178,11 @@ class CToggleGroup : public CIntObject
 	CFunctionList<void(int)> onChange; //called when changing selected button with new button's id
 
 	int selectedID;
-	bool musicLike; //determines the behaviour of this group
 	void selectionChanged(int to);
 public:
 	std::map<int, CToggleBase*> buttons;
 
-	CToggleGroup(const CFunctionList<void(int)> & OnChange, bool musicLikeButtons = false);
+	CToggleGroup(const CFunctionList<void(int)> & OnChange);
 
 	void addCallback(std::function<void(int)> callback);
 
@@ -191,9 +190,6 @@ public:
 	void addToggle(int index, CToggleBase * button);
 	/// Changes selection to specific value. Will select toggle with this ID, if present
 	void setSelected(int id);
-
-	void show(SDL_Surface * to);
-	void showAll(SDL_Surface * to);
 };
 
 /// A typical slider for volume with an animated indicator