git repos / blockattack-game

commit 5db03af6

Poul Sander · 2018-11-07 19:39
5db03af627bd5a4456419ebdf5d60f8feab47718 patch · browse files
parent e373cd7533fe6243fe99545e782ce02840c8c189

Started using initializer lists in the menu

Changed files

M source/code/MenuSystem.cpp before
M source/code/MenuSystem.h before
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index bb9bc78..faa623d 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -69,11 +69,14 @@ Button::Button() {
Button::~Button() {
}
-Button::Button(const Button& b) {
- label = b.label;
- marked = b.marked;
- action = b.action;
- popOnRun = false;
+Button::Button(const Button& b) : action{b.action}, label{b.label}, marked{b.marked} {
+}
+
+Button& Button::operator=(const Button& other) {
+ action = other.action;
+ label = other.label;
+ marked = other.marked;
+ return *this;
}
void Button::setLabel(const std::string& text) {
@@ -169,11 +172,10 @@ Menu::Menu(SDL_Renderer* screen,bool submenu) {
}
}
-Menu::Menu(SDL_Renderer* screen, const std::string& title, bool submenu) {
+Menu::Menu(SDL_Renderer* screen, const std::string& title, bool submenu) : title{title} {
this->screen = screen;
buttons = std::vector<Button*>(0);
isSubmenu = submenu;
- this->title = title;
if (isSubmenu) {
exit.setLabel(_("Back") );
}
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h index cf3016f..024bf3a 100644 --- a/source/code/MenuSystem.h +++ b/source/code/MenuSystem.h
@@ -69,6 +69,7 @@ public:
Button();
Button(const Button& b);
+ Button& operator=(const Button& other);
virtual ~Button();