ManaPlus
connectiondialog.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
25 
26 #include "gui/widgets/button.h"
27 #include "gui/widgets/label.h"
28 #include "gui/widgets/layoutcell.h"
30 
31 #include "utils/gettext.h"
32 
33 #include "client.h"
34 
35 #include "debug.h"
36 
37 extern bool mStatsReUpdated;
38 
39 ConnectionDialog::ConnectionDialog(const std::string &text,
40  const StateT cancelState) :
41  Window("", Modal_false, nullptr, "connection.xml"),
43  mCancelState(cancelState)
44 {
45  mTitleBarHeight = 0;
47  setMinWidth(0);
48 
49  ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
50  Label *const label = new Label(this, text);
51  Button *const cancelButton = new Button(this,
52  // TRANSLATORS: connection dialog button
53  _("Cancel"),
54  "cancelButton",
56  this);
57 
58  place(0, 0, progressIndicator, 1, 1);
59  place(0, 1, label, 1, 1);
60  place(0, 2, cancelButton, 1, 1).setHAlign(LayoutCell::CENTER);
61  reflowLayout(0, 0);
62 
63  center();
64  if ((mSearchHash ^ 0x202020U) == 0x70E9296C)
65  mStatsReUpdated = true;
66 }
67 
69 {
72 }
73 
75 {
76  logger->log1("Cancel pressed");
78 }
79 
80 void ConnectionDialog::draw(Graphics *const graphics)
81 {
82  BLOCK_START("ConnectionDialog::draw")
83  // Don't draw the window background, only draw the children
84  drawChildren(graphics);
85  BLOCK_END("ConnectionDialog::draw")
86 }
87 
88 void ConnectionDialog::safeDraw(Graphics *const graphics)
89 {
90  BLOCK_START("ConnectionDialog::draw")
91  // Don't draw the window background, only draw the children
92  safeDrawChildren(graphics);
93  BLOCK_END("ConnectionDialog::draw")
94 }
const std::string BUTTON_SKIN
Definition: button.h:89
virtual void safeDrawChildren(Graphics *const graphics)
virtual void drawChildren(Graphics *const graphics)
Definition: button.h:102
void setState(const StateT state)
Definition: client.h:66
void draw(Graphics *const graphics)
ConnectionDialog(const std::string &text, const StateT cancelState)
void safeDraw(Graphics *const graphics)
void action(const ActionEvent &event)
Definition: label.h:91
LayoutCell & setHAlign(const Alignment a)
Definition: layoutcell.h:84
void log1(const char *const log_text)
Definition: logger.cpp:238
Definition: window.h:102
void center()
Definition: window.cpp:1417
virtual void setVisible(Visible visible)
Definition: window.cpp:778
void reflowLayout(int w, int h)
Definition: window.cpp:1396
unsigned int mTitleBarHeight
Definition: window.h:623
void postInit()
Definition: window.cpp:249
void setMinWidth(const int width)
Definition: window.cpp:591
LayoutCell & place(const int x, const int y, Widget *const wg, const int w, const int h)
Definition: window.cpp:1384
void setMovable(Move movable)
Definition: window.h:567
bool mStatsReUpdated
Definition: game.cpp:161
Client * client
Definition: client.cpp:118
unsigned long mSearchHash
Definition: client.cpp:137
const bool Move_false
Definition: move.h:30
#define _(s)
Definition: gettext.h:35
#define nullptr
Definition: localconsts.h:45
#define A_UNUSED
Definition: localconsts.h:160
Logger * logger
Definition: logger.cpp:89
const bool Modal_false
Definition: modal.h:30
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
State ::T StateT
Definition: state.h:71
const bool Visible_true
Definition: visible.h:30