Mana
Loading...
Searching...
No Matches
updaterwindow.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "gui/widgets/window.h"
25
26#include "net/download.h"
27
28#include <guichan/actionlistener.hpp>
29#include <guichan/keylistener.hpp>
30
31#include <memory>
32#include <string>
33#include <vector>
34
35class LinkHandler;
36class BrowserBox;
37class Button;
38class ProgressBar;
39class ScrollArea;
40
42{
43 std::string name;
44 std::string hash;
45 std::string type;
47 std::string desc;
48};
49
55class UpdaterWindow : public Window, public gcn::ActionListener,
56 public gcn::KeyListener
57{
58 public:
68 UpdaterWindow(const std::string &updateHost,
69 const std::string &updatesDir,
70 bool applyUpdates);
71
72 ~UpdaterWindow() override;
73
74 void action(const gcn::ActionEvent &event) override;
75
76 void keyPressed(gcn::KeyEvent &keyEvent) override;
77
78 void logic() override;
79
80private:
81 bool cancel();
82 void play();
83
84 void setLabel(const std::string &);
85 void enablePlay();
86
87 void startDownload(const std::string &fileName,
88 bool storeInMemory,
89 std::optional<unsigned long> adler32 = {});
90 void downloadCompleted();
91
96 void loadNews();
97
101 void loadUpdates();
102
103 enum class DialogState
104 {
108 Done,
109 };
110
113
115 std::string mUpdateHost;
116
118 std::string mUpdatesDir;
119
121 std::string mCurrentFile;
122
124 std::unique_ptr<Net::Download> mDownload;
125
127 std::vector<UpdateFile> mUpdateFiles;
128
130 unsigned int mUpdateIndex = 0;
131
134
135 gcn::Label *mLabel;
141 std::unique_ptr<LinkHandler> mLinkHandler;
142};
A simple browser box able to handle links and forward events to the parent conteiner.
Definition browserbox.h:74
Button widget.
Definition button.h:38
A simple interface to windows that need to handle links from BrowserBox widget.
Definition linkhandler.h:31
A progress bar.
Definition progressbar.h:34
A scroll area.
Definition scrollarea.h:38
Update progress window GUI.
unsigned int mUpdateIndex
Index of the file to be downloaded.
Button * mPlayButton
Button to start playing.
std::string mUpdatesDir
Place where the updates are stored (absolute path).
std::unique_ptr< LinkHandler > mLinkHandler
std::vector< UpdateFile > mUpdateFiles
List of files to download.
BrowserBox * mBrowserBox
Box to display news.
std::unique_ptr< Net::Download > mDownload
Download handle.
std::string mCurrentFile
The file currently downloading.
void loadNews()
Loads and display news.
std::string mUpdateHost
Host where we get the updated files.
DialogState mDialogState
Status of the current download.
ScrollArea * mScrollArea
Used to scroll news box.
void startDownload(const std::string &fileName, bool storeInMemory, std::optional< unsigned long > adler32={})
ProgressBar * mProgressBar
Update progress bar.
~UpdaterWindow() override
void loadUpdates()
Loads the updates this window has gotten into the resource manager.
Button * mCancelButton
Button to stop the update process.
void action(const gcn::ActionEvent &event) override
void setLabel(const std::string &)
void keyPressed(gcn::KeyEvent &keyEvent) override
bool mLoadUpdates
Tells ~UpdaterWindow() if it should load updates.
gcn::Label * mLabel
Progress bar caption.
void logic() override
A window.
Definition window.h:59
std::string type
std::string hash
std::string name
std::string desc