From d7b0770b7162fec4a33c7c0b1dd63fff7ecbbe59 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sat, 17 Dec 2022 20:50:33 +0400 Subject: [PATCH] Remove excessive code --- client/lobby/RandomMapTab.cpp | 6 +----- client/widgets/Buttons.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index de7e29006..9bf461bcb 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -544,7 +544,7 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab): } else { - button->addOverlay(buildWidget(variables["unchecked"])); + button->addOverlay(nullptr); } } })); @@ -554,11 +554,7 @@ TeamAlignmentsWidget::TeamAlignmentsWidget(RandomMapTab & randomMapTab): { variables["point"]["x"].Integer() = variables["cellOffset"]["x"].Integer() + plId * variables["cellMargin"]["x"].Integer(); variables["point"]["y"].Integer() = variables["cellOffset"]["y"].Integer() + teamId * variables["cellMargin"]["y"].Integer(); - //Point p(40 + plId * 32, 20 + teamId * 32); - placeholders.push_back(buildWidget(variables["placeholder"])); auto button = buildWidget(variables["button"]); - button->pos.w = variables["cellMargin"]["x"].Integer(); - button->pos.h = variables["cellMargin"]["y"].Integer(); players.back()->addToggle(teamId, std::dynamic_pointer_cast(button)); } diff --git a/client/widgets/Buttons.cpp b/client/widgets/Buttons.cpp index 592eecdc0..98bb638d7 100644 --- a/client/widgets/Buttons.cpp +++ b/client/widgets/Buttons.cpp @@ -84,8 +84,11 @@ void CButton::addTextOverlay(const std::string & Text, EFonts font, SDL_Color co void CButton::addOverlay(std::shared_ptr newOverlay) { overlay = newOverlay; - addChild(newOverlay.get()); - overlay->moveTo(overlay->pos.centerIn(pos).topLeft()); + if(overlay) + { + addChild(newOverlay.get()); + overlay->moveTo(overlay->pos.centerIn(pos).topLeft()); + } update(); }