widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #06790
[Merge] lp:~widelands-dev/widelands/bug-1395278-network-io-wui into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1395278-network-io-wui into lp:widelands.
Commit message:
Refactored remaining member variables.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1395278 in widelands: "Consolidate naming of member variables"
https://bugs.launchpad.net/widelands/+bug/1395278
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1395278-network-io-wui/+merge/289557
That's all, folks! :)
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1395278-network-io-wui into lp:widelands.
=== modified file 'src/io/filesystem/layered_filesystem.cc'
--- src/io/filesystem/layered_filesystem.cc 2016-02-18 18:27:52 +0000
+++ src/io/filesystem/layered_filesystem.cc 2016-03-19 10:27:47 +0000
@@ -29,7 +29,7 @@
LayeredFileSystem * g_fs;
-LayeredFileSystem::LayeredFileSystem(): m_home(nullptr) {}
+LayeredFileSystem::LayeredFileSystem(): home_(nullptr) {}
/**
* Free all sub-filesystems
@@ -47,12 +47,12 @@
}
void LayeredFileSystem::add_file_system(FileSystem* fs) {
- m_filesystems.emplace_back(fs);
+ filesystems_.emplace_back(fs);
}
void LayeredFileSystem::set_home_file_system(FileSystem * fs)
{
- m_home.reset(fs);
+ home_.reset(fs);
}
/**
@@ -61,11 +61,11 @@
*/
void LayeredFileSystem::remove_file_system(const FileSystem & fs)
{
- if (m_filesystems.back().get() != &fs)
+ if (filesystems_.back().get() != &fs)
throw std::logic_error
("LayeredFileSystem::remove_file_system: interspersed add/remove "
"detected!");
- m_filesystems.pop_back();
+ filesystems_.pop_back();
}
/**
@@ -80,8 +80,8 @@
std::set<std::string> results;
FilenameSet files;
// Check home system first
- if (m_home) {
- files = m_home->list_directory(path);
+ if (home_) {
+ files = home_->list_directory(path);
for
(FilenameSet::iterator fnit = files.begin();
fnit != files.end();
@@ -89,7 +89,7 @@
results.insert(*fnit);
}
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) {
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it) {
files = (*it)->list_directory(path);
for (FilenameSet::iterator fnit = files.begin(); fnit != files.end(); ++fnit)
@@ -102,9 +102,9 @@
* Returns true if the file can be found in at least one of the sub-filesystems
*/
bool LayeredFileSystem::file_exists(const std::string & path) {
- if (m_home && m_home->file_exists(path))
+ if (home_ && home_->file_exists(path))
return true;
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->file_exists(path))
return true;
@@ -116,10 +116,10 @@
*/
// TODO(unknown): What if it's a file in some and a dir in others?????
bool LayeredFileSystem::is_directory(const std::string & path) {
- if (m_home && m_home->is_directory(path))
+ if (home_ && home_->is_directory(path))
return true;
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_directory(path))
return true;
@@ -135,10 +135,10 @@
* Let's just avoid any possible hassles with that.
*/
void * LayeredFileSystem::load(const std::string & fname, size_t & length) {
- if (m_home && m_home->file_exists(fname))
- return m_home->load(fname, length);
+ if (home_ && home_->file_exists(fname))
+ return home_->load(fname, length);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->file_exists(fname))
return (*it)->load(fname, length);
@@ -152,10 +152,10 @@
void LayeredFileSystem::write
(const std::string & fname, void const * const data, int32_t const length)
{
- if (m_home && m_home->is_writable())
- return m_home->write(fname, data, length);
+ if (home_ && home_->is_writable())
+ return home_->write(fname, data, length);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable())
return (*it)->write(fname, data, length);
@@ -168,10 +168,10 @@
* it exists.
*/
StreamRead * LayeredFileSystem::open_stream_read (const std::string & fname) {
- if (m_home && m_home->file_exists(fname))
- return m_home->open_stream_read(fname);
+ if (home_ && home_->file_exists(fname))
+ return home_->open_stream_read(fname);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->file_exists(fname))
return (*it)->open_stream_read(fname);
@@ -183,10 +183,10 @@
* Analogously to Write, create the file in the first writable sub-FS.
*/
StreamWrite * LayeredFileSystem::open_stream_write(const std::string & fname) {
- if (m_home && m_home->is_writable())
- return m_home->open_stream_write(fname);
+ if (home_ && home_->is_writable())
+ return home_->open_stream_write(fname);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable())
return (*it)->open_stream_write(fname);
@@ -197,10 +197,10 @@
* MakeDir in first writable directory
*/
void LayeredFileSystem::make_directory(const std::string & dirname) {
- if (m_home && m_home->is_writable())
- return m_home->make_directory(dirname);
+ if (home_ && home_->is_writable())
+ return home_->make_directory(dirname);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable())
return (*it)->make_directory(dirname);
@@ -211,10 +211,10 @@
* ensure_directory_exists in first writable directory
*/
void LayeredFileSystem::ensure_directory_exists(const std::string & dirname) {
- if (m_home && m_home->is_writable())
- return m_home->ensure_directory_exists(dirname);
+ if (home_ && home_->is_writable())
+ return home_->ensure_directory_exists(dirname);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable())
return (*it)->ensure_directory_exists(dirname);
@@ -226,10 +226,10 @@
*/
FileSystem * LayeredFileSystem::make_sub_file_system(const std::string & dirname)
{
- if (m_home && m_home->is_writable() && m_home->file_exists(dirname))
- return m_home->make_sub_file_system(dirname);
+ if (home_ && home_->is_writable() && home_->file_exists(dirname))
+ return home_->make_sub_file_system(dirname);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable() && (*it)->file_exists(dirname))
return (*it)->make_sub_file_system(dirname);
@@ -242,10 +242,10 @@
*/
FileSystem * LayeredFileSystem::create_sub_file_system(const std::string & dirname, Type const type)
{
- if (m_home && m_home->is_writable() && !m_home->file_exists(dirname))
- return m_home->create_sub_file_system(dirname, type);
+ if (home_ && home_->is_writable() && !home_->file_exists(dirname))
+ return home_->create_sub_file_system(dirname, type);
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable() && !(*it)->file_exists(dirname))
return (*it)->create_sub_file_system(dirname, type);
@@ -260,12 +260,12 @@
if (!file_exists(file))
return;
- if (m_home && m_home->is_writable() && m_home->file_exists(file)) {
- m_home->fs_unlink(file);
+ if (home_ && home_->is_writable() && home_->file_exists(file)) {
+ home_->fs_unlink(file);
return;
}
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable() && (*it)->file_exists(file)) {
(*it)->fs_unlink(file);
return;
@@ -277,11 +277,11 @@
{
if (!file_exists(old_name))
return;
- if (m_home && m_home->is_writable() && m_home->file_exists(old_name)) {
- m_home->fs_rename(old_name, new_name);
+ if (home_ && home_->is_writable() && home_->file_exists(old_name)) {
+ home_->fs_rename(old_name, new_name);
return;
}
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if ((*it)->is_writable() && (*it)->file_exists(old_name)) {
(*it)->fs_rename(old_name, new_name);
return;
@@ -293,10 +293,10 @@
// This heuristic is justified by the fact that ths is
// where we will create new files.
unsigned long long LayeredFileSystem::disk_space() {
- if (m_home) {
- return m_home->disk_space();
+ if (home_) {
+ return home_->disk_space();
}
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it)
if (*it)
return (*it)->disk_space();
return 0;
@@ -306,11 +306,11 @@
std::string message = filename + "\nI have tried the following path(s):";
- if (m_home) {
- message += "\n " + m_home->get_basename() + FileSystem::file_separator() + filename;
+ if (home_) {
+ message += "\n " + home_->get_basename() + FileSystem::file_separator() + filename;
}
- for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) {
+ for (auto it = filesystems_.rbegin(); it != filesystems_.rend(); ++it) {
message += "\n " + (*it)->get_basename() + FileSystem::file_separator() + filename;
}
return message;
=== modified file 'src/io/filesystem/layered_filesystem.h'
--- src/io/filesystem/layered_filesystem.h 2016-02-09 07:51:23 +0000
+++ src/io/filesystem/layered_filesystem.h 2016-03-19 10:27:47 +0000
@@ -85,8 +85,8 @@
/// This is used to assemble an error message for exceptions that includes all file paths
std::string paths_error_message(const std::string& filename) const;
- std::vector<std::unique_ptr<FileSystem>> m_filesystems;
- std::unique_ptr<FileSystem> m_home;
+ std::vector<std::unique_ptr<FileSystem>> filesystems_;
+ std::unique_ptr<FileSystem> home_;
};
/// Access all game data files etc. through this FileSystem
=== modified file 'src/io/filesystem/zip_exceptions.h'
--- src/io/filesystem/zip_exceptions.h 2014-09-27 18:52:14 +0000
+++ src/io/filesystem/zip_exceptions.h 2016-03-19 10:27:47 +0000
@@ -28,7 +28,7 @@
* Problems with the zipfile itself or normal file operations should throw
* FileError or one of it's descendants with an appropriate message. E.g.:
* throw FileNotFoundError("ZipFilesystem::load", fname,
- * "couldn't open file (from zipfile "+m_zipfilename+")");
+ * "couldn't open file (from zipfile "+zipfilename_+")");
*/
struct ZipOperationError : public std::logic_error {
ZipOperationError
@@ -40,12 +40,12 @@
std::logic_error
(thrower + ": " + message + " (working on '" + filename +
"' in zipfile '" + zipfilename + "')"),
- m_thrower(thrower), m_filename(filename), m_zipfilename(zipfilename)
+ thrower_(thrower), filename_(filename), zipfilename_(zipfilename)
{}
- std::string m_thrower;
- std::string m_filename;
- std::string m_zipfilename;
+ std::string thrower_;
+ std::string filename_;
+ std::string zipfilename_;
};
#endif // end of include guard: WL_IO_FILESYSTEM_ZIP_EXCEPTIONS_H
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2016-03-08 15:21:41 +0000
+++ src/network/nethost.cc 2016-03-19 10:27:47 +0000
@@ -66,12 +66,12 @@
struct HostGameSettingsProvider : public GameSettingsProvider {
- HostGameSettingsProvider(NetHost * const init_host) : h(init_host), m_cur_wincondition(0) {}
+ HostGameSettingsProvider(NetHost * const init_host) : host_(init_host), current_wincondition_(0) {}
~HostGameSettingsProvider() {}
- void set_scenario(bool is_scenario) override {h->set_scenario(is_scenario);}
+ void set_scenario(bool is_scenario) override {host_->set_scenario(is_scenario);}
- const GameSettings & settings() override {return h->settings();}
+ const GameSettings & settings() override {return host_->settings();}
bool can_change_map() override {return true;}
bool can_change_player_state(uint8_t const number) override {
@@ -107,7 +107,7 @@
settings().players.at(number).state == PlayerSettings::stateComputer;
}
- bool can_launch() override {return h->can_launch();}
+ bool can_launch() override {return host_->can_launch();}
virtual void set_map
(const std::string & mapname,
@@ -115,7 +115,7 @@
uint32_t const maxplayers,
bool const savegame = false) override
{
- h->set_map(mapname, mapfilename, maxplayers, savegame);
+ host_->set_map(mapname, mapfilename, maxplayers, savegame);
}
void set_player_state
(uint8_t number, PlayerSettings::State const state) override
@@ -123,23 +123,23 @@
if (number >= settings().players.size())
return;
- h->set_player_state(number, state);
+ host_->set_player_state(number, state);
}
void next_player_state(uint8_t const number) override {
if (number > settings().players.size())
return;
PlayerSettings::State newstate = PlayerSettings::stateClosed;
- switch (h->settings().players.at(number).state) {
+ switch (host_->settings().players.at(number).state) {
case PlayerSettings::stateClosed:
// In savegames : closed players can not be changed.
- assert(!h->settings().savegame);
+ assert(!host_->settings().savegame);
newstate = PlayerSettings::stateOpen;
break;
case PlayerSettings::stateOpen:
case PlayerSettings::stateHuman:
- if (h->settings().scenario) {
- assert(h->settings().players.at(number).closeable);
+ if (host_->settings().scenario) {
+ assert(host_->settings().players.at(number).closeable);
newstate = PlayerSettings::stateClosed;
break;
} // else fall through
@@ -150,21 +150,21 @@
ComputerPlayer::get_implementations();
ComputerPlayer::ImplementationVector::const_iterator it =
impls.begin();
- if (h->settings().players.at(number).ai.empty()) {
+ if (host_->settings().players.at(number).ai.empty()) {
set_player_ai(number, (*it)->name);
newstate = PlayerSettings::stateComputer;
break;
}
do {
++it;
- if ((*(it - 1))->name == h->settings().players.at(number).ai)
+ if ((*(it - 1))->name == host_->settings().players.at(number).ai)
break;
} while (it != impls.end());
if (settings().players.at(number).random_ai) {
set_player_ai(number, std::string());
set_player_name(number, std::string());
// Do not share a player in savegames or scenarios
- if (h->settings().scenario || h->settings().savegame)
+ if (host_->settings().scenario || host_->settings().savegame)
newstate = PlayerSettings::stateOpen;
else {
uint8_t shared = 0;
@@ -198,7 +198,7 @@
case PlayerSettings::stateShared:
{
// Do not close a player in savegames or scenarios
- if (h->settings().scenario || h->settings().savegame)
+ if (host_->settings().scenario || host_->settings().savegame)
newstate = PlayerSettings::stateOpen;
else
newstate = PlayerSettings::stateClosed;
@@ -206,13 +206,13 @@
}
}
- h->set_player_state(number, newstate, true);
+ host_->set_player_state(number, newstate, true);
}
void set_player_tribe
(uint8_t number, const std::string& tribe, bool const random_tribe) override
{
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
if
@@ -223,87 +223,87 @@
settings().players.at(number).state == PlayerSettings::stateShared
||
settings().players.at(number).state == PlayerSettings::stateOpen) // For savegame loading
- h->set_player_tribe(number, tribe, random_tribe);
+ host_->set_player_tribe(number, tribe, random_tribe);
}
void set_player_team(uint8_t number, Widelands::TeamNumber team) override
{
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
if
(number == settings().playernum ||
settings().players.at(number).state == PlayerSettings::stateComputer)
- h->set_player_team(number, team);
+ host_->set_player_team(number, team);
}
void set_player_closeable(uint8_t number, bool closeable) override {
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
- h->set_player_closeable(number, closeable);
+ host_->set_player_closeable(number, closeable);
}
void set_player_shared(uint8_t number, uint8_t shared) override {
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
- h->set_player_shared(number, shared);
+ host_->set_player_shared(number, shared);
}
void set_player_init(uint8_t const number, uint8_t const index) override {
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
- h->set_player_init(number, index);
+ host_->set_player_init(number, index);
}
void set_player_ai(uint8_t number, const std::string & name, bool const random_ai = false) override {
- h->set_player_ai(number, name, random_ai);
+ host_->set_player_ai(number, name, random_ai);
}
void set_player_name(uint8_t const number, const std::string & name) override {
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
- h->set_player_name(number, name);
+ host_->set_player_name(number, name);
}
void set_player(uint8_t const number, PlayerSettings const ps) override {
- if (number >= h->settings().players.size())
+ if (number >= host_->settings().players.size())
return;
- h->set_player(number, ps);
+ host_->set_player(number, ps);
}
void set_player_number(uint8_t const number) override {
if
(number == UserSettings::none() ||
- number < h->settings().players.size())
- h->set_player_number(number);
+ number < host_->settings().players.size())
+ host_->set_player_number(number);
}
std::string get_win_condition_script() override {
- return h->settings().win_condition_script;
+ return host_->settings().win_condition_script;
}
void set_win_condition_script(std::string wc) override {
- h->set_win_condition_script(wc);
+ host_->set_win_condition_script(wc);
}
void next_win_condition() override {
- if (m_win_condition_scripts.empty()) {
- m_win_condition_scripts = h->settings().win_condition_scripts;
- m_cur_wincondition = -1;
+ if (wincondition_scripts_.empty()) {
+ wincondition_scripts_ = host_->settings().win_condition_scripts;
+ current_wincondition_ = -1;
}
if (can_change_map()) {
- m_cur_wincondition++;
- m_cur_wincondition %= m_win_condition_scripts.size();
- set_win_condition_script(m_win_condition_scripts[m_cur_wincondition]);
+ current_wincondition_++;
+ current_wincondition_ %= wincondition_scripts_.size();
+ set_win_condition_script(wincondition_scripts_[current_wincondition_]);
}
}
private:
- NetHost * h;
- int16_t m_cur_wincondition;
- std::vector<std::string> m_win_condition_scripts;
+ NetHost * host_;
+ int16_t current_wincondition_;
+ std::vector<std::string> wincondition_scripts_;
};
struct HostChatProvider : public ChatProvider {
=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc 2016-02-09 21:14:53 +0000
+++ src/wui/actionconfirm.cc 2016-03-19 10:27:47 +0000
@@ -54,7 +54,7 @@
virtual void ok() = 0;
protected:
- Widelands::ObjectPointer m_object;
+ Widelands::ObjectPointer object_;
};
/**
@@ -81,7 +81,7 @@
void ok() override;
private:
- Widelands::ObjectPointer m_todestroy;
+ Widelands::ObjectPointer todestroy_;
};
/**
@@ -110,7 +110,7 @@
private:
// Do not make this a reference - it is a stack variable in the caller
- const Widelands::DescriptionIndex m_id;
+ const Widelands::DescriptionIndex id_;
};
@@ -143,7 +143,7 @@
:
UI::Window
(&parent, "building_action_confirm", 0, 0, 200, 120, windowtitle),
- m_object (&building)
+ object_ (&building)
{
new UI::MultilineTextarea
(this,
@@ -179,7 +179,7 @@
Widelands::Ship & ship)
:
UI::Window(&parent, "ship_action_confirm", 0, 0, 200, 120, windowtitle),
- m_object (&ship)
+ object_ (&ship)
{
new UI::MultilineTextarea
(this,
@@ -223,7 +223,7 @@
_("Destroy building?"),
_("Do you really want to destroy this %s?"),
building),
- m_todestroy(todestroy ? todestroy : &building)
+ todestroy_(todestroy ? todestroy : &building)
{
// Nothing special to do
}
@@ -237,8 +237,8 @@
void BulldozeConfirm::think()
{
const Widelands::EditorGameBase & egbase = iaplayer().egbase();
- upcast(Widelands::Building, building, m_object .get(egbase));
- upcast(Widelands::PlayerImmovable, todestroy, m_todestroy.get(egbase));
+ upcast(Widelands::Building, building, object_ .get(egbase));
+ upcast(Widelands::PlayerImmovable, todestroy, todestroy_.get(egbase));
if
(!todestroy ||
@@ -256,8 +256,8 @@
void BulldozeConfirm::ok()
{
Widelands::Game & game = iaplayer().game();
- upcast(Widelands::Building, building, m_object.get(game));
- upcast(Widelands::PlayerImmovable, todestroy, m_todestroy.get(game));
+ upcast(Widelands::Building, building, object_.get(game));
+ upcast(Widelands::PlayerImmovable, todestroy, todestroy_.get(game));
if
(todestroy &&
@@ -300,7 +300,7 @@
void DismantleConfirm::think()
{
const Widelands::EditorGameBase & egbase = iaplayer().egbase();
- upcast(Widelands::Building, building, m_object.get(egbase));
+ upcast(Widelands::Building, building, object_.get(egbase));
if
(!building ||
@@ -317,8 +317,8 @@
void DismantleConfirm::ok()
{
Widelands::Game & game = iaplayer().game();
- upcast(Widelands::Building, building, m_object.get(game));
- upcast(Widelands::PlayerImmovable, todismantle, m_object.get(game));
+ upcast(Widelands::Building, building, object_.get(game));
+ upcast(Widelands::PlayerImmovable, todismantle, object_.get(game));
if
(building &&
@@ -347,7 +347,7 @@
_("Enhance building?"),
_("Do you really want to enhance this %s?"),
building),
- m_id(id)
+ id_(id)
{
// Nothing special to do
}
@@ -361,7 +361,7 @@
void EnhanceConfirm::think()
{
const Widelands::EditorGameBase & egbase = iaplayer().egbase();
- upcast(Widelands::Building, building, m_object.get(egbase));
+ upcast(Widelands::Building, building, object_.get(egbase));
if
(!building ||
@@ -378,14 +378,14 @@
void EnhanceConfirm::ok()
{
Widelands::Game & game = iaplayer().game();
- upcast(Widelands::Building, building, m_object.get(game));
+ upcast(Widelands::Building, building, object_.get(game));
if
(building &&
iaplayer().can_act(building->owner().player_number()) &&
(building->get_playercaps() & Widelands::Building::PCap_Enhancable))
{
- game.send_player_enhance_building(*building, m_id);
+ game.send_player_enhance_building(*building, id_);
}
die();
@@ -408,7 +408,7 @@
void ShipSinkConfirm::think()
{
const Widelands::EditorGameBase & egbase = iaplayer().egbase();
- upcast(Widelands::Ship, ship, m_object.get(egbase));
+ upcast(Widelands::Ship, ship, object_.get(egbase));
if (!ship || !iaplayer().can_act(ship->get_owner()->player_number()))
die();
@@ -421,7 +421,7 @@
void ShipSinkConfirm::ok()
{
Widelands::Game & game = iaplayer().game();
- upcast(Widelands::Ship, ship, m_object.get(game));
+ upcast(Widelands::Ship, ship, object_.get(game));
if (ship && iaplayer().can_act(ship->get_owner()->player_number())) {
game.send_player_sink_ship(*ship);
@@ -447,7 +447,7 @@
*/
void ShipCancelExpeditionConfirm::think() {
const Widelands::EditorGameBase& egbase = iaplayer().egbase();
- upcast(Widelands::Ship, ship, m_object.get(egbase));
+ upcast(Widelands::Ship, ship, object_.get(egbase));
if (!ship || !iaplayer().can_act(ship->get_owner()->player_number()) ||
!ship->state_is_expedition()) {
@@ -461,7 +461,7 @@
void ShipCancelExpeditionConfirm::ok()
{
Widelands::Game & game = iaplayer().game();
- upcast(Widelands::Ship, ship, m_object.get(game));
+ upcast(Widelands::Ship, ship, object_.get(game));
if
(ship
=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc 2016-01-29 08:37:22 +0000
+++ src/wui/constructionsitewindow.cc 2016-03-19 10:27:47 +0000
@@ -41,7 +41,7 @@
void think() override;
private:
- UI::ProgressBar * m_progress;
+ UI::ProgressBar * progress_;
};
@@ -54,14 +54,14 @@
UI::Box & box = *new UI::Box(get_tabs(), 0, 0, UI::Box::Vertical);
// Add the progress bar
- m_progress =
+ progress_ =
new UI::ProgressBar
(&box,
0, 0,
UI::ProgressBar::DefaultWidth, UI::ProgressBar::DefaultHeight,
UI::ProgressBar::Horizontal);
- m_progress->set_total(1 << 16);
- box.add(m_progress, UI::Align::kHCenter);
+ progress_->set_total(1 << 16);
+ box.add(progress_, UI::Align::kHCenter);
box.add_space(8);
@@ -88,7 +88,7 @@
const Widelands::ConstructionSite & cs =
dynamic_cast<Widelands::ConstructionSite&>(building());
- m_progress->set_state(cs.get_built_per64k());
+ progress_->set_state(cs.get_built_per64k());
}
=== modified file 'src/wui/dismantlesitewindow.cc'
--- src/wui/dismantlesitewindow.cc 2016-01-29 08:37:22 +0000
+++ src/wui/dismantlesitewindow.cc 2016-03-19 10:27:47 +0000
@@ -38,7 +38,7 @@
void think() override;
private:
- UI::ProgressBar * m_progress;
+ UI::ProgressBar * progress_;
};
@@ -51,14 +51,14 @@
UI::Box & box = *new UI::Box(get_tabs(), 0, 0, UI::Box::Vertical);
// Add the progress bar
- m_progress =
+ progress_ =
new UI::ProgressBar
(&box,
0, 0,
UI::ProgressBar::DefaultWidth, UI::ProgressBar::DefaultHeight,
UI::ProgressBar::Horizontal);
- m_progress->set_total(1 << 16);
- box.add(m_progress, UI::Align::kHCenter);
+ progress_->set_total(1 << 16);
+ box.add(progress_, UI::Align::kHCenter);
box.add_space(8);
@@ -82,7 +82,7 @@
const Widelands::DismantleSite & ds =
dynamic_cast<Widelands::DismantleSite&>(building());
- m_progress->set_state(ds.get_built_per64k());
+ progress_->set_state(ds.get_built_per64k());
}
=== modified file 'src/wui/fieldaction.cc'
--- src/wui/fieldaction.cc 2016-03-18 08:22:55 +0000
+++ src/wui/fieldaction.cc 2016-03-19 10:27:47 +0000
@@ -212,19 +212,19 @@
bool repeating = false);
void okdialog();
- Widelands::Player * m_plr;
- Widelands::Map * m_map;
- FieldOverlayManager & m_field_overlay_manager;
-
- Widelands::FCoords m_node;
-
- UI::TabPanel m_tabpanel;
- bool m_fastclick; // if true, put the mouse over first button in first tab
- uint32_t m_best_tab;
- FieldOverlayManager::OverlayId m_workarea_preview_overlay_id;
+ Widelands::Player* player_;
+ Widelands::Map* map_;
+ FieldOverlayManager& field_overlay_manager_;
+
+ Widelands::FCoords node_;
+
+ UI::TabPanel tabpanel_;
+ bool fastclick_; // if true, put the mouse over first button in first tab
+ uint32_t best_tab_;
+ FieldOverlayManager::OverlayId workarea_preview_overlay_id_;
/// Variables to use with attack dialog.
- AttackBox * m_attack_box;
+ AttackBox * attack_box_;
};
static const char * const pic_tab_buildroad = "images/wui/fieldaction/menu_tab_buildroad.png";
@@ -272,36 +272,36 @@
UI::UniqueWindow::Registry * const registry)
:
UI::UniqueWindow(ib, "field_action", registry, 68, 34, _("Action")),
- m_plr(plr),
- m_map(&ib->egbase().map()),
- m_field_overlay_manager(*ib->mutable_field_overlay_manager()),
- m_node(ib->get_sel_pos().node, &(*m_map)[ib->get_sel_pos().node]),
- m_tabpanel(this, 0, 0, g_gr->images().get("images/ui_basic/but1.png")),
- m_fastclick(true),
- m_best_tab(0),
- m_workarea_preview_overlay_id(0),
- m_attack_box(nullptr)
+ player_(plr),
+ map_(&ib->egbase().map()),
+ field_overlay_manager_(*ib->mutable_field_overlay_manager()),
+ node_(ib->get_sel_pos().node, &(*map_)[ib->get_sel_pos().node]),
+ tabpanel_(this, 0, 0, g_gr->images().get("images/ui_basic/but1.png")),
+ fastclick_(true),
+ best_tab_(0),
+ workarea_preview_overlay_id_(0),
+ attack_box_(nullptr)
{
ib->set_sel_freeze(true);
- set_center_panel(&m_tabpanel);
+ set_center_panel(&tabpanel_);
}
FieldActionWindow::~FieldActionWindow()
{
- if (m_workarea_preview_overlay_id)
- m_field_overlay_manager.remove_overlay(m_workarea_preview_overlay_id);
+ if (workarea_preview_overlay_id_)
+ field_overlay_manager_.remove_overlay(workarea_preview_overlay_id_);
ibase().set_sel_freeze(false);
- delete m_attack_box;
+ delete attack_box_;
}
void FieldActionWindow::think() {
if
- (m_plr && m_plr->vision(m_node.field - &ibase().egbase().map()[0]) <= 1
- && !m_plr->see_all())
+ (player_ && player_->vision(node_.field - &ibase().egbase().map()[0]) <= 1
+ && !player_->see_all())
die();
}
@@ -319,7 +319,7 @@
// Now force the mouse onto the first button
set_mouse_pos
- (Point(17 + kBuildGridCellSize * m_best_tab, m_fastclick ? 51 : 17));
+ (Point(17 + kBuildGridCellSize * best_tab_, fastclick_ ? 51 : 17));
// Will only do something if we explicitly set another fast click panel
// than the first button
@@ -335,19 +335,19 @@
void FieldActionWindow::add_buttons_auto()
{
UI::Box * buildbox = nullptr;
- UI::Box & watchbox = *new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal);
+ UI::Box & watchbox = *new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal);
// Add road-building actions
upcast(InteractiveGameBase, igbase, &ibase());
- const Widelands::PlayerNumber owner = m_node.field->get_owned_by();
+ const Widelands::PlayerNumber owner = node_.field->get_owned_by();
if (!igbase || igbase->can_see(owner)) {
- Widelands::BaseImmovable * const imm = m_map->get_immovable(m_node);
+ Widelands::BaseImmovable * const imm = map_->get_immovable(node_);
const bool can_act = igbase ? igbase->can_act(owner) : true;
// The box with road-building buttons
- buildbox = new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal);
+ buildbox = new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal);
if (upcast(Widelands::Flag, flag, imm)) {
// Add flag actions
@@ -385,7 +385,7 @@
_("Send geologist to explore site"));
}
} else {
- const int32_t buildcaps = m_plr ? m_plr->get_buildcaps(m_node) : 0;
+ const int32_t buildcaps = player_ ? player_->get_buildcaps(node_) : 0;
// Add house building
if ((buildcaps & Widelands::BUILDCAPS_SIZEMASK) ||
@@ -395,7 +395,7 @@
}
// Add build actions
- if ((m_fastclick = buildcaps & Widelands::BUILDCAPS_FLAG))
+ if ((fastclick_ = buildcaps & Widelands::BUILDCAPS_FLAG))
add_button
(buildbox, "build_flag",
pic_buildflag,
@@ -410,12 +410,12 @@
_("Destroy a road"));
}
} else if
- (m_plr &&
+ (player_ &&
1
<
- m_plr->vision
+ player_->vision
(Widelands::Map::get_index
- (m_node, ibase().egbase().map().get_width())))
+ (node_, ibase().egbase().map().get_width())))
add_buttons_attack ();
// Watch actions, only when game (no use in editor) same for statistics.
@@ -455,18 +455,18 @@
void FieldActionWindow::add_buttons_attack ()
{
- UI::Box & a_box = *new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal);
+ UI::Box & a_box = *new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal);
if
(upcast
- (Widelands::Attackable, attackable, m_map->get_immovable(m_node)))
+ (Widelands::Attackable, attackable, map_->get_immovable(node_)))
{
if
- (m_plr && m_plr->is_hostile(attackable->owner()) &&
+ (player_ && player_->is_hostile(attackable->owner()) &&
attackable->can_attack())
{
- m_attack_box = new AttackBox(&a_box, m_plr, &m_node, 0, 0);
- a_box.add(m_attack_box, UI::Align::kTop);
+ attack_box_ = new AttackBox(&a_box, player_, &node_, 0, 0);
+ a_box.add(attack_box_, UI::Align::kTop);
set_fastclick_panel
(&add_button
@@ -489,14 +489,14 @@
*/
void FieldActionWindow::add_buttons_build(int32_t buildcaps)
{
- if (!m_plr)
+ if (!player_)
return;
BuildGrid * bbg_house[4] = {nullptr, nullptr, nullptr, nullptr};
BuildGrid * bbg_mine = nullptr;
- const Widelands::TribeDescr & tribe = m_plr->tribe();
+ const Widelands::TribeDescr & tribe = player_->tribe();
- m_fastclick = false;
+ fastclick_ = false;
for (const Widelands::DescriptionIndex& building_index : tribe.buildings()) {
const Widelands::BuildingDescr* building_descr = tribe.get_building_descr(building_index);
@@ -505,7 +505,7 @@
// Some building types cannot be built (i.e. construction site) and not
// allowed buildings.
if (dynamic_cast<const Game *>(&ibase().egbase())) {
- if (!building_descr->is_buildable() || !m_plr->is_building_type_allowed(building_index))
+ if (!building_descr->is_buildable() || !player_->is_building_type_allowed(building_index))
continue;
if (building_descr->needs_seafaring() && ibase().egbase().map().get_port_spaces().size() < 2)
continue;
@@ -534,7 +534,7 @@
// Allocate the tab's grid if necessary
if (!*ppgrid) {
- *ppgrid = new BuildGrid(&m_tabpanel, m_plr, 0, 0, 5);
+ *ppgrid = new BuildGrid(&tabpanel_, player_, 0, 0, 5);
(*ppgrid)->buildclicked.connect(boost::bind(&FieldActionWindow::act_build, this, _1));
(*ppgrid)->buildmouseout.connect
(boost::bind(&FieldActionWindow::building_icon_mouse_out, this, _1));
@@ -550,15 +550,15 @@
// Add all necessary tabs
for (int32_t i = 0; i < 4; ++i)
if (bbg_house[i])
- m_tabpanel.activate
- (m_best_tab = add_tab
+ tabpanel_.activate
+ (best_tab_ = add_tab
(name_tab_build[i], pic_tab_buildhouse[i],
bbg_house[i],
i18n::translate(tooltip_tab_build[i])));
if (bbg_mine)
- m_tabpanel.activate
- (m_best_tab = add_tab
+ tabpanel_.activate
+ (best_tab_ = add_tab
("mines", pic_tab_buildmine, bbg_mine, _("Build mines")));
}
@@ -570,7 +570,7 @@
*/
void FieldActionWindow::add_buttons_road(bool flag)
{
- UI::Box & buildbox = *new UI::Box(&m_tabpanel, 0, 0, UI::Box::Horizontal);
+ UI::Box & buildbox = *new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal);
if (flag)
add_button
@@ -596,7 +596,7 @@
UI::Panel * panel, const std::string & tooltip_text)
{
return
- m_tabpanel.add
+ tabpanel_.add
(name, g_gr->images().get(picname), panel, tooltip_text);
}
@@ -632,7 +632,7 @@
*/
void FieldActionWindow::okdialog()
{
- ibase().warp_mouse_to_node(m_node);
+ ibase().warp_mouse_to_node(node_);
die();
}
@@ -644,7 +644,7 @@
void FieldActionWindow::act_watch()
{
upcast(InteractiveGameBase, igbase, &ibase());
- show_watch_window(*igbase, m_node);
+ show_watch_window(*igbase, node_);
okdialog();
}
@@ -678,7 +678,7 @@
*/
void FieldActionWindow::act_debug()
{
- show_field_debug(ibase(), m_node);
+ show_field_debug(ibase(), node_);
}
@@ -691,15 +691,15 @@
{
upcast(Game, game, &ibase().egbase());
if (game)
- game->send_player_build_flag(m_plr->player_number(), m_node);
+ game->send_player_build_flag(player_->player_number(), node_);
else
- m_plr->build_flag(m_node);
+ player_->build_flag(node_);
if (ibase().is_building_road())
ibase().finish_build_road();
else if (game) {
upcast(InteractivePlayer, iaplayer, &ibase());
- iaplayer->set_flag_to_connect(m_node);
+ iaplayer->set_flag_to_connect(node_);
}
okdialog();
@@ -708,7 +708,7 @@
void FieldActionWindow::act_configure_economy()
{
- if (upcast(const Widelands::Flag, flag, m_node.field->get_immovable()))
+ if (upcast(const Widelands::Flag, flag, node_.field->get_immovable()))
flag->get_economy()->show_options_window();
}
@@ -725,7 +725,7 @@
upcast(Game, game, &egbase);
upcast(InteractivePlayer, iaplayer, &ibase());
- if (upcast(Widelands::Flag, flag, m_node.field->get_immovable())) {
+ if (upcast(Widelands::Flag, flag, node_.field->get_immovable())) {
if (Building * const building = flag->get_building()) {
if (building->get_playercaps() & Building::PCap_Bulldoze) {
if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
@@ -753,7 +753,7 @@
{
// If we area already building a road just ignore this
if (!ibase().is_building_road()) {
- ibase().start_build_road(m_node, m_plr->player_number());
+ ibase().start_build_road(node_, player_->player_number());
okdialog();
}
}
@@ -780,7 +780,7 @@
void FieldActionWindow::act_removeroad()
{
Widelands::EditorGameBase & egbase = ibase().egbase();
- if (upcast(Widelands::Road, road, egbase.map().get_immovable(m_node))) {
+ if (upcast(Widelands::Road, road, egbase.map().get_immovable(node_))) {
upcast(Game, game, &ibase().egbase());
game->send_player_bulldoze
(*road, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL));
@@ -799,9 +799,9 @@
upcast(Game, game, &ibase().egbase());
upcast(InteractivePlayer, iaplayer, &ibase());
- game->send_player_build(iaplayer->player_number(), m_node, Widelands::DescriptionIndex(idx));
- ibase().reference_player_tribe(m_plr->player_number(), &m_plr->tribe());
- iaplayer->set_flag_to_connect(game->map().br_n(m_node));
+ game->send_player_build(iaplayer->player_number(), node_, Widelands::DescriptionIndex(idx));
+ ibase().reference_player_tribe(player_->player_number(), &player_->tribe());
+ iaplayer->set_flag_to_connect(game->map().br_n(node_));
okdialog();
}
@@ -809,9 +809,9 @@
void FieldActionWindow::building_icon_mouse_out
(Widelands::DescriptionIndex)
{
- if (m_workarea_preview_overlay_id) {
- m_field_overlay_manager.remove_overlay(m_workarea_preview_overlay_id);
- m_workarea_preview_overlay_id = 0;
+ if (workarea_preview_overlay_id_) {
+ field_overlay_manager_.remove_overlay(workarea_preview_overlay_id_);
+ workarea_preview_overlay_id_ = 0;
}
}
@@ -819,10 +819,10 @@
void FieldActionWindow::building_icon_mouse_in
(const Widelands::DescriptionIndex idx)
{
- if (ibase().show_workarea_preview_ && !m_workarea_preview_overlay_id) {
+ if (ibase().show_workarea_preview_ && !workarea_preview_overlay_id_) {
const WorkareaInfo& workarea_info =
- m_plr->tribe().get_building_descr(Widelands::DescriptionIndex(idx))->workarea_info_;
- m_workarea_preview_overlay_id = ibase().show_work_area(workarea_info, m_node);
+ player_->tribe().get_building_descr(Widelands::DescriptionIndex(idx))->workarea_info_;
+ workarea_preview_overlay_id_ = ibase().show_work_area(workarea_info, node_);
}
}
@@ -835,7 +835,7 @@
void FieldActionWindow::act_geologist()
{
upcast(Game, game, &ibase().egbase());
- if (upcast(Widelands::Flag, flag, game->map().get_immovable(m_node))) {
+ if (upcast(Widelands::Flag, flag, game->map().get_immovable(node_))) {
game->send_player_flagaction (*flag);
}
okdialog();
@@ -849,15 +849,15 @@
*/
void FieldActionWindow::act_attack ()
{
- assert(m_attack_box);
+ assert(attack_box_);
upcast(Game, game, &ibase().egbase());
- if (upcast(Building, building, game->map().get_immovable(m_node)))
- if (m_attack_box->soldiers() > 0) {
+ if (upcast(Building, building, game->map().get_immovable(node_)))
+ if (attack_box_->soldiers() > 0) {
upcast(InteractivePlayer const, iaplayer, &ibase());
game->send_player_enemyflagaction(
building->base_flag(),
iaplayer->player_number(),
- m_attack_box->soldiers() /* number of soldiers */);
+ attack_box_->soldiers() /* number of soldiers */);
}
okdialog();
}
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc 2016-03-17 07:09:14 +0000
+++ src/wui/game_debug_ui.cc 2016-03-19 10:27:47 +0000
@@ -55,10 +55,10 @@
void log(std::string str) override;
private:
- const Widelands::EditorGameBase & m_egbase;
- Widelands::ObjectPointer m_object;
+ const Widelands::EditorGameBase& egbase_;
+ Widelands::ObjectPointer object_;
- UI::MultilineTextarea m_log;
+ UI::MultilineTextarea log_;
};
@@ -68,9 +68,9 @@
Widelands::MapObject & obj)
:
UI::Panel(&parent, 0, 0, 350, 200),
-m_egbase (egbase),
-m_object (&obj),
-m_log (this, 0, 0, 350, 200, "", UI::Align::kLeft, UI::MultilineTextarea::ScrollMode::kScrollLog)
+egbase_ (egbase),
+object_ (&obj),
+log_ (this, 0, 0, 350, 200, "", UI::Align::kLeft, UI::MultilineTextarea::ScrollMode::kScrollLog)
{
obj.set_logsink(this);
}
@@ -78,7 +78,7 @@
MapObjectDebugPanel::~MapObjectDebugPanel()
{
- if (Widelands::MapObject * const obj = m_object.get(m_egbase))
+ if (Widelands::MapObject * const obj = object_.get(egbase_))
if (obj->get_logsink() == this)
obj->set_logsink(nullptr);
}
@@ -91,7 +91,7 @@
*/
void MapObjectDebugPanel::log(std::string str)
{
- m_log.set_text((m_log.get_text() + str).c_str());
+ log_.set_text((log_.get_text() + str).c_str());
}
@@ -138,10 +138,10 @@
void think() override;
private:
- bool m_log_general_info;
- Widelands::ObjectPointer m_object;
- uint32_t m_serial;
- UI::TabPanel m_tabs;
+ bool log_general_info_;
+ Widelands::ObjectPointer object_;
+ uint32_t serial_;
+ UI::TabPanel tabs_;
};
@@ -149,18 +149,18 @@
(InteractiveBase & parent, Widelands::MapObject & obj)
:
UI::Window (&parent, "map_object_debug", 0, 0, 100, 100, ""),
- m_log_general_info(true),
- m_object (&obj),
- m_tabs
+ log_general_info_(true),
+ object_ (&obj),
+ tabs_
(this, 0, 0,
g_gr->images().get("images/ui_basic/but4.png"))
{
- m_serial = obj.serial();
- set_title(std::to_string(m_serial));
-
- obj.create_debug_panels(parent.egbase(), m_tabs);
-
- set_center_panel(&m_tabs);
+ serial_ = obj.serial();
+ set_title(std::to_string(serial_));
+
+ obj.create_debug_panels(parent.egbase(), tabs_);
+
+ set_center_panel(&tabs_);
}
@@ -172,14 +172,14 @@
void MapObjectDebugWindow::think()
{
Widelands::EditorGameBase & egbase = ibase().egbase();
- if (Widelands::MapObject * const obj = m_object.get(egbase)) {
- if (m_log_general_info) {
+ if (Widelands::MapObject * const obj = object_.get(egbase)) {
+ if (log_general_info_) {
obj->log_general_info(egbase);
- m_log_general_info = false;
+ log_general_info_ = false;
}
UI::Window::think();
} else {
- set_title((boost::format("DEAD: %u") % m_serial).str());
+ set_title((boost::format("DEAD: %u") % serial_).str());
}
}
@@ -220,12 +220,12 @@
void open_bob(uint32_t);
private:
- Widelands::Map & m_map;
- Widelands::FCoords const m_coords;
+ Widelands::Map& map_;
+ Widelands::FCoords const coords_;
- UI::MultilineTextarea m_ui_field;
- UI::Button m_ui_immovable;
- UI::Listselect<intptr_t> m_ui_bobs;
+ UI::MultilineTextarea ui_field_;
+ UI::Button ui_immovable_;
+ UI::Listselect<intptr_t> ui_bobs_;
};
@@ -233,29 +233,29 @@
(InteractiveBase & parent, Widelands::Coords const coords)
:
UI::Window(&parent, "field_debug", 0, 60, 300, 400, _("Debug Field")),
- m_map (parent.egbase().map()),
- m_coords (m_map.get_fcoords(coords)),
+ map_ (parent.egbase().map()),
+ coords_ (map_.get_fcoords(coords)),
// setup child panels
- m_ui_field(this, 0, 0, 300, 280, ""),
+ ui_field_(this, 0, 0, 300, 280, ""),
- m_ui_immovable
+ ui_immovable_
(this, "immovable",
0, 280, 300, 24,
g_gr->images().get("images/ui_basic/but4.png"),
""),
- m_ui_bobs(this, 0, 304, 300, 96)
+ ui_bobs_(this, 0, 304, 300, 96)
{
- m_ui_immovable.sigclicked.connect(boost::bind(&FieldDebugWindow::open_immovable, this));
+ ui_immovable_.sigclicked.connect(boost::bind(&FieldDebugWindow::open_immovable, this));
- assert(0 <= m_coords.x);
- assert(m_coords.x < m_map.get_width());
- assert(0 <= m_coords.y);
- assert(m_coords.y < m_map.get_height());
- assert(&m_map[0] <= m_coords.field);
- assert (m_coords.field < &m_map[0] + m_map.max_index());
- m_ui_bobs.selected.connect(boost::bind(&FieldDebugWindow::open_bob, this, _1));
+ assert(0 <= coords_.x);
+ assert(coords_.x < map_.get_width());
+ assert(0 <= coords_.y);
+ assert(coords_.y < map_.get_height());
+ assert(&map_[0] <= coords_.field);
+ assert (coords_.field < &map_[0] + map_.max_index());
+ ui_bobs_.selected.connect(boost::bind(&FieldDebugWindow::open_bob, this, _1));
}
@@ -276,15 +276,15 @@
dynamic_cast<const InteractiveBase&>(*get_parent())
.egbase();
{
- Widelands::PlayerNumber const owner = m_coords.field->get_owned_by();
+ Widelands::PlayerNumber const owner = coords_.field->get_owned_by();
str += (boost::format("(%i, %i)\nheight: %u\nowner: %u\n")
- % m_coords.x % m_coords.y
- % static_cast<unsigned int>(m_coords.field->get_height())
+ % coords_.x % coords_.y
+ % static_cast<unsigned int>(coords_.field->get_height())
% static_cast<unsigned int>(owner)).str();
if (owner) {
Widelands::NodeCaps const buildcaps =
- egbase.player(owner).get_buildcaps(m_coords);
+ egbase.player(owner).get_buildcaps(coords_);
if (buildcaps & Widelands::BUILDCAPS_BIG)
str += " can build big building\n";
else if (buildcaps & Widelands::BUILDCAPS_MEDIUM)
@@ -299,12 +299,12 @@
str += " can build port\n";
}
}
- if (m_coords.field->nodecaps() & Widelands::MOVECAPS_WALK)
+ if (coords_.field->nodecaps() & Widelands::MOVECAPS_WALK)
str += "is walkable\n";
- if (m_coords.field->nodecaps() & Widelands::MOVECAPS_SWIM)
+ if (coords_.field->nodecaps() & Widelands::MOVECAPS_SWIM)
str += "is swimable\n";
- Widelands::MapIndex const i = m_coords.field - &m_map[0];
- Widelands::PlayerNumber const nr_players = m_map.get_nrplayers();
+ Widelands::MapIndex const i = coords_.field - &map_[0];
+ Widelands::PlayerNumber const nr_players = map_.get_nrplayers();
iterate_players_existing_const(plnum, nr_players, egbase, player) {
const Widelands::Player::Field & player_field = player->fields()[i];
str += (boost::format("Player %u:\n") % static_cast<unsigned int>(plnum)).str();
@@ -357,13 +357,13 @@
}
}
{
- const Widelands::DescriptionIndex ridx = m_coords.field->get_resources();
+ const Widelands::DescriptionIndex ridx = coords_.field->get_resources();
if (ridx == Widelands::kNoResource) {
str += "Resource: None\n";
} else {
- const int ramount = m_coords.field->get_resources_amount();
- const int initial_amount = m_coords.field->get_initial_res_amount();
+ const int ramount = coords_.field->get_resources_amount();
+ const int initial_amount = coords_.field->get_initial_res_amount();
str += (boost::format("Resource: %s\n")
% ibase().egbase().world().get_resource(ridx)->name().c_str()).str();
@@ -372,28 +372,28 @@
}
}
- m_ui_field.set_text(str.c_str());
+ ui_field_.set_text(str.c_str());
// Immovable information
- if (Widelands::BaseImmovable * const imm = m_coords.field->get_immovable())
+ if (Widelands::BaseImmovable * const imm = coords_.field->get_immovable())
{
- m_ui_immovable.set_title((boost::format("%s (%u)")
+ ui_immovable_.set_title((boost::format("%s (%u)")
% imm->descr().name().c_str()
% imm->serial()).str());
- m_ui_immovable.set_enabled(true);
+ ui_immovable_.set_enabled(true);
} else {
- m_ui_immovable.set_title("no immovable");
- m_ui_immovable.set_enabled(false);
+ ui_immovable_.set_title("no immovable");
+ ui_immovable_.set_enabled(false);
}
// Bobs information
std::vector<Widelands::Bob *> bobs;
- m_map.find_bobs(Widelands::Area<Widelands::FCoords>(m_coords, 0), &bobs);
+ map_.find_bobs(Widelands::Area<Widelands::FCoords>(coords_, 0), &bobs);
// Do not clear the list. Instead parse all bobs and sync lists
- for (uint32_t idx = 0; idx < m_ui_bobs.size(); idx++) {
+ for (uint32_t idx = 0; idx < ui_bobs_.size(); idx++) {
Widelands::MapObject* mo =
- ibase().egbase().objects().get_object(m_ui_bobs[idx]);
+ ibase().egbase().objects().get_object(ui_bobs_[idx]);
bool toremove = false;
std::vector<Widelands::Bob *>::iterator removeIt;
// Nested loop :(
@@ -416,12 +416,12 @@
}
// Remove from our list if its not in the bobs
// list, or if it doesn't seem to exist anymore
- m_ui_bobs.remove(idx);
+ ui_bobs_.remove(idx);
idx--; // reiter the same index
}
// Add remaining
for (const Widelands::Bob * temp_bob : bobs) {
- m_ui_bobs.add(
+ ui_bobs_.add(
(boost::format("%s (%u)")
% temp_bob->descr().name()
% temp_bob->serial()).str(),
@@ -437,7 +437,7 @@
*/
void FieldDebugWindow::open_immovable()
{
- if (Widelands::BaseImmovable * const imm = m_coords.field->get_immovable())
+ if (Widelands::BaseImmovable * const imm = coords_.field->get_immovable())
show_mapobject_debug(ibase(), *imm);
}
@@ -451,7 +451,7 @@
if (index != UI::Listselect<intptr_t>::no_selection_index())
if
(Widelands::MapObject * const object =
- ibase().egbase().objects().get_object(m_ui_bobs.get_selected()))
+ ibase().egbase().objects().get_object(ui_bobs_.get_selected()))
show_mapobject_debug(ibase(), *object);
}
=== modified file 'src/wui/portdockwaresdisplay.cc'
--- src/wui/portdockwaresdisplay.cc 2016-01-28 21:27:04 +0000
+++ src/wui/portdockwaresdisplay.cc 2016-03-19 10:27:47 +0000
@@ -42,20 +42,20 @@
std::string info_for_ware(Widelands::DescriptionIndex ware) override;
private:
- PortDock & m_portdock;
+ PortDock & portdock_;
};
PortDockWaresDisplay::PortDockWaresDisplay
(Panel * parent, uint32_t width, PortDock & pd, Widelands::WareWorker type) :
AbstractWaresDisplay(parent, 0, 0, pd.owner().tribe(), type, false),
- m_portdock(pd)
+ portdock_(pd)
{
set_inner_size(width, 0);
}
std::string PortDockWaresDisplay::info_for_ware(Widelands::DescriptionIndex ware)
{
- uint32_t count = m_portdock.count_waiting(get_type(), ware);
+ uint32_t count = portdock_.count_waiting(get_type(), ware);
return boost::lexical_cast<std::string>(count);
}
=== modified file 'src/wui/shipwindow.cc'
--- src/wui/shipwindow.cc 2016-03-15 20:56:49 +0000
+++ src/wui/shipwindow.cc 2016-03-19 10:27:47 +0000
@@ -76,38 +76,38 @@
void act_explore_island(IslandExploreDirection);
private:
- InteractiveGameBase & m_igbase;
- Ship & m_ship;
+ InteractiveGameBase & igbase_;
+ Ship & ship_;
- UI::Button * m_btn_goto;
- UI::Button * m_btn_destination;
- UI::Button * m_btn_sink;
- UI::Button * m_btn_debug;
- UI::Button * m_btn_cancel_expedition;
- UI::Button * m_btn_explore_island_cw;
- UI::Button * m_btn_explore_island_ccw;
- UI::Button * m_btn_scout[LAST_DIRECTION]; // format: DIRECTION - 1, as 0 is normally the current location.
- UI::Button * m_btn_construct_port;
- ItemWaresDisplay * m_display;
+ UI::Button * btn_goto_;
+ UI::Button * btn_destination_;
+ UI::Button * btn_sink_;
+ UI::Button * btn_debug_;
+ UI::Button * btn_cancel_expedition_;
+ UI::Button * btn_explore_island_cw_;
+ UI::Button * btn_explore_island_ccw_;
+ UI::Button * btn_scout_[LAST_DIRECTION]; // format: DIRECTION - 1, as 0 is normally the current location.
+ UI::Button * btn_construct_port_;
+ ItemWaresDisplay * display_;
};
ShipWindow::ShipWindow(InteractiveGameBase & igb, Ship & ship, const std::string & title) :
Window(&igb, "shipwindow", 0, 0, 0, 0, title),
- m_igbase(igb),
- m_ship(ship)
+ igbase_(igb),
+ ship_(ship)
{
- assert(!m_ship.window_);
- assert(m_ship.get_owner());
- m_ship.window_ = this;
+ assert(!ship_.window_);
+ assert(ship_.get_owner());
+ ship_.window_ = this;
UI::Box * vbox = new UI::Box(this, 0, 0, UI::Box::Vertical);
- m_display = new ItemWaresDisplay(vbox, *ship.get_owner());
- m_display->set_capacity(ship.descr().get_capacity());
- vbox->add(m_display, UI::Align::kHCenter, false);
+ display_ = new ItemWaresDisplay(vbox, *ship.get_owner());
+ display_->set_capacity(ship.descr().get_capacity());
+ vbox->add(display_, UI::Align::kHCenter, false);
// Expedition buttons
- if (m_ship.state_is_expedition()) {
+ if (ship_.state_is_expedition()) {
UI::Box * exp_top = new UI::Box(vbox, 0, 0, UI::Box::Horizontal);
vbox->add(exp_top, UI::Align::kHCenter, false);
UI::Box * exp_mid = new UI::Box(vbox, 0, 0, UI::Box::Horizontal);
@@ -115,59 +115,59 @@
UI::Box * exp_bot = new UI::Box(vbox, 0, 0, UI::Box::Horizontal);
vbox->add(exp_bot, UI::Align::kHCenter, false);
- m_btn_scout[WALK_NW - 1] =
+ btn_scout_[WALK_NW - 1] =
make_button
(exp_top, "scnw", _("Scout towards the north west"), pic_scout_nw,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_NW));
- exp_top->add(m_btn_scout[WALK_NW - 1], UI::Align::kLeft, false);
+ exp_top->add(btn_scout_[WALK_NW - 1], UI::Align::kLeft, false);
- m_btn_explore_island_cw =
+ btn_explore_island_cw_ =
make_button
(exp_top, "expcw", _("Explore the island’s coast clockwise"), pic_explore_cw,
boost::bind(&ShipWindow::act_explore_island, this, IslandExploreDirection::kClockwise));
- exp_top->add(m_btn_explore_island_cw, UI::Align::kLeft, false);
+ exp_top->add(btn_explore_island_cw_, UI::Align::kLeft, false);
- m_btn_scout[WALK_NE - 1] =
+ btn_scout_[WALK_NE - 1] =
make_button
(exp_top, "scne", _("Scout towards the north east"), pic_scout_ne,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_NE));
- exp_top->add(m_btn_scout[WALK_NE - 1], UI::Align::kLeft, false);
+ exp_top->add(btn_scout_[WALK_NE - 1], UI::Align::kLeft, false);
- m_btn_scout[WALK_W - 1] =
+ btn_scout_[WALK_W - 1] =
make_button
(exp_mid, "scw", _("Scout towards the west"), pic_scout_w,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_W));
- exp_mid->add(m_btn_scout[WALK_W - 1], UI::Align::kLeft, false);
+ exp_mid->add(btn_scout_[WALK_W - 1], UI::Align::kLeft, false);
- m_btn_construct_port =
+ btn_construct_port_ =
make_button
(exp_mid, "buildport", _("Construct a port at the current location"), pic_construct_port,
boost::bind(&ShipWindow::act_construct_port, this));
- exp_mid->add(m_btn_construct_port, UI::Align::kLeft, false);
+ exp_mid->add(btn_construct_port_, UI::Align::kLeft, false);
- m_btn_scout[WALK_E - 1] =
+ btn_scout_[WALK_E - 1] =
make_button
(exp_mid, "sce", _("Scout towards the east"), pic_scout_e,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_E));
- exp_mid->add(m_btn_scout[WALK_E - 1], UI::Align::kLeft, false);
+ exp_mid->add(btn_scout_[WALK_E - 1], UI::Align::kLeft, false);
- m_btn_scout[WALK_SW - 1] =
+ btn_scout_[WALK_SW - 1] =
make_button
(exp_bot, "scsw", _("Scout towards the south west"), pic_scout_sw,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_SW));
- exp_bot->add(m_btn_scout[WALK_SW - 1], UI::Align::kLeft, false);
+ exp_bot->add(btn_scout_[WALK_SW - 1], UI::Align::kLeft, false);
- m_btn_explore_island_ccw =
+ btn_explore_island_ccw_ =
make_button
(exp_bot, "expccw", _("Explore the island’s coast counter clockwise"), pic_explore_ccw,
boost::bind(&ShipWindow::act_explore_island, this, IslandExploreDirection::kCounterClockwise));
- exp_bot->add(m_btn_explore_island_ccw, UI::Align::kLeft, false);
+ exp_bot->add(btn_explore_island_ccw_, UI::Align::kLeft, false);
- m_btn_scout[WALK_SE - 1] =
+ btn_scout_[WALK_SE - 1] =
make_button
(exp_bot, "scse", _("Scout towards the south east"), pic_scout_se,
boost::bind(&ShipWindow::act_scout_towards, this, WALK_SE));
- exp_bot->add(m_btn_scout[WALK_SE - 1], UI::Align::kLeft, false);
+ exp_bot->add(btn_scout_[WALK_SE - 1], UI::Align::kLeft, false);
}
@@ -175,83 +175,83 @@
UI::Box * buttons = new UI::Box(vbox, 0, 0, UI::Box::Horizontal);
vbox->add(buttons, UI::Align::kLeft, false);
- m_btn_goto =
+ btn_goto_ =
make_button
(buttons, "goto", _("Go to ship"), pic_goto,
boost::bind(&ShipWindow::act_goto, this));
- buttons->add(m_btn_goto, UI::Align::kLeft, false);
- m_btn_destination =
+ buttons->add(btn_goto_, UI::Align::kLeft, false);
+ btn_destination_ =
make_button
(buttons, "destination", _("Go to destination"), pic_destination,
boost::bind(&ShipWindow::act_destination, this));
- m_btn_destination->set_enabled(false);
- buttons->add(m_btn_destination, UI::Align::kLeft, false);
+ btn_destination_->set_enabled(false);
+ buttons->add(btn_destination_, UI::Align::kLeft, false);
- m_btn_sink =
+ btn_sink_ =
make_button
(buttons, "sink", _("Sink the ship"), pic_sink, boost::bind(&ShipWindow::act_sink, this));
- buttons->add(m_btn_sink, UI::Align::kLeft, false);
+ buttons->add(btn_sink_, UI::Align::kLeft, false);
- if (m_ship.state_is_expedition()) {
- m_btn_cancel_expedition =
+ if (ship_.state_is_expedition()) {
+ btn_cancel_expedition_ =
make_button
(buttons, "cancel_expedition", _("Cancel the Expedition"), pic_cancel_expedition,
boost::bind(&ShipWindow::act_cancel_expedition, this));
- buttons->add(m_btn_cancel_expedition, UI::Align::kLeft, false);
+ buttons->add(btn_cancel_expedition_, UI::Align::kLeft, false);
}
- if (m_igbase.get_display_flag(InteractiveBase::dfDebug)) {
- m_btn_debug =
+ if (igbase_.get_display_flag(InteractiveBase::dfDebug)) {
+ btn_debug_ =
make_button
(buttons, "debug", _("Show Debug Window"), pic_debug,
boost::bind(&ShipWindow::act_debug, this));
- m_btn_debug->set_enabled(true);
+ btn_debug_->set_enabled(true);
buttons->add
- (m_btn_debug, UI::Align::kLeft, false);
+ (btn_debug_, UI::Align::kLeft, false);
}
set_center_panel(vbox);
set_thinks(true);
center_to_parent();
move_out_of_the_way();
- set_fastclick_panel(m_btn_goto);
+ set_fastclick_panel(btn_goto_);
}
ShipWindow::~ShipWindow()
{
- assert(m_ship.window_ == this);
- m_ship.window_ = nullptr;
+ assert(ship_.window_ == this);
+ ship_.window_ = nullptr;
}
void ShipWindow::think()
{
UI::Window::think();
- InteractiveBase * ib = m_ship.get_owner()->egbase().get_ibase();
+ InteractiveBase * ib = ship_.get_owner()->egbase().get_ibase();
bool can_act = false;
if (upcast(InteractiveGameBase, igb, ib))
- can_act = igb->can_act(m_ship.get_owner()->player_number());
-
- m_btn_destination->set_enabled(m_ship.get_destination(m_igbase.egbase()));
- m_btn_sink->set_enabled(can_act);
-
- m_display->clear();
- for (uint32_t idx = 0; idx < m_ship.get_nritems(); ++idx) {
- Widelands::ShippingItem item = m_ship.get_item(idx);
+ can_act = igb->can_act(ship_.get_owner()->player_number());
+
+ btn_destination_->set_enabled(ship_.get_destination(igbase_.egbase()));
+ btn_sink_->set_enabled(can_act);
+
+ display_->clear();
+ for (uint32_t idx = 0; idx < ship_.get_nritems(); ++idx) {
+ Widelands::ShippingItem item = ship_.get_item(idx);
Widelands::WareInstance * ware;
Widelands::Worker * worker;
- item.get(m_igbase.egbase(), &ware, &worker);
+ item.get(igbase_.egbase(), &ware, &worker);
if (ware) {
- m_display->add(false, ware->descr_index());
+ display_->add(false, ware->descr_index());
}
if (worker) {
- m_display->add(true, worker->descr().worker_index());
+ display_->add(true, worker->descr().worker_index());
}
}
// Expedition specific buttons
- uint8_t state = m_ship.get_ship_state();
- if (m_ship.state_is_expedition()) {
+ uint8_t state = ship_.get_ship_state();
+ if (ship_.state_is_expedition()) {
/* The following rules apply:
* - The "construct port" button is only active, if the ship is waiting for commands and found a port
* buildspace
@@ -260,18 +260,18 @@
* - The "explore island's coast" buttons are only active, if a coast is in vision range (no matter if
* in waiting or already expedition/scouting mode)
*/
- m_btn_construct_port->set_enabled(can_act && (state == Ship::EXP_FOUNDPORTSPACE));
+ btn_construct_port_->set_enabled(can_act && (state == Ship::EXP_FOUNDPORTSPACE));
bool coast_nearby = false;
for (Direction dir = 1; dir <= LAST_DIRECTION; ++dir) {
// NOTE buttons are saved in the format DIRECTION - 1
- m_btn_scout[dir - 1]->set_enabled
- (can_act && m_ship.exp_dir_swimable(dir) && (state != Ship::EXP_COLONIZING));
- coast_nearby |= !m_ship.exp_dir_swimable(dir);
+ btn_scout_[dir - 1]->set_enabled
+ (can_act && ship_.exp_dir_swimable(dir) && (state != Ship::EXP_COLONIZING));
+ coast_nearby |= !ship_.exp_dir_swimable(dir);
}
- m_btn_explore_island_cw ->set_enabled(can_act && coast_nearby && (state != Ship::EXP_COLONIZING));
- m_btn_explore_island_ccw->set_enabled(can_act && coast_nearby && (state != Ship::EXP_COLONIZING));
- m_btn_sink ->set_enabled(can_act && (state != Ship::EXP_COLONIZING));
- m_btn_cancel_expedition ->set_enabled(can_act && (state != Ship::EXP_COLONIZING));
+ btn_explore_island_cw_ ->set_enabled(can_act && coast_nearby && (state != Ship::EXP_COLONIZING));
+ btn_explore_island_ccw_->set_enabled(can_act && coast_nearby && (state != Ship::EXP_COLONIZING));
+ btn_sink_ ->set_enabled(can_act && (state != Ship::EXP_COLONIZING));
+ btn_cancel_expedition_ ->set_enabled(can_act && (state != Ship::EXP_COLONIZING));
}
}
@@ -292,14 +292,14 @@
/// Move the main view towards the current ship location
void ShipWindow::act_goto()
{
- m_igbase.move_view_to(m_ship.get_position());
+ igbase_.move_view_to(ship_.get_position());
}
/// Move the main view towards the current destination of the ship
void ShipWindow::act_destination()
{
- if (PortDock * destination = m_ship.get_destination(m_igbase.egbase())) {
- m_igbase.move_view_to(destination->get_warehouse()->get_position());
+ if (PortDock * destination = ship_.get_destination(igbase_.egbase())) {
+ igbase_.move_view_to(destination->get_warehouse()->get_position());
}
}
@@ -307,44 +307,44 @@
void ShipWindow::act_sink()
{
if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
- m_igbase.game().send_player_sink_ship(m_ship);
+ igbase_.game().send_player_sink_ship(ship_);
}
else {
- show_ship_sink_confirm(dynamic_cast<InteractivePlayer&>(m_igbase), m_ship);
+ show_ship_sink_confirm(dynamic_cast<InteractivePlayer&>(igbase_), ship_);
}
}
/// Show debug info
void ShipWindow::act_debug()
{
- show_mapobject_debug(m_igbase, m_ship);
+ show_mapobject_debug(igbase_, ship_);
}
/// Cancel expedition if confirmed
void ShipWindow::act_cancel_expedition()
{
if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) {
- m_igbase.game().send_player_cancel_expedition_ship(m_ship);
+ igbase_.game().send_player_cancel_expedition_ship(ship_);
}
else {
show_ship_cancel_expedition_confirm
- (dynamic_cast<InteractivePlayer&>(m_igbase), m_ship);
+ (dynamic_cast<InteractivePlayer&>(igbase_), ship_);
}
}
/// Sends a player command to the ship to scout towards a specific direction
void ShipWindow::act_scout_towards(WalkingDir direction) {
// ignore request if the direction is not swimable at all
- if (!m_ship.exp_dir_swimable(static_cast<Direction>(direction)))
+ if (!ship_.exp_dir_swimable(static_cast<Direction>(direction)))
return;
- m_igbase.game().send_player_ship_scouting_direction(m_ship, direction);
+ igbase_.game().send_player_ship_scouting_direction(ship_, direction);
}
/// Constructs a port at the port build space in vision range
void ShipWindow::act_construct_port() {
- if (m_ship.exp_port_spaces().empty())
+ if (ship_.exp_port_spaces().empty())
return;
- m_igbase.game().send_player_ship_construct_port(m_ship, m_ship.exp_port_spaces().front());
+ igbase_.game().send_player_ship_construct_port(ship_, ship_.exp_port_spaces().front());
}
/// Explores the island cw or ccw
@@ -352,14 +352,14 @@
bool coast_nearby = false;
bool moveable = false;
for (Direction dir = 1; (dir <= LAST_DIRECTION) && (!coast_nearby || !moveable); ++dir) {
- if (!m_ship.exp_dir_swimable(dir))
+ if (!ship_.exp_dir_swimable(dir))
coast_nearby = true;
else
moveable = true;
}
if (!coast_nearby || !moveable)
return;
- m_igbase.game().send_player_ship_explore_island(m_ship, direction);
+ igbase_.game().send_player_ship_explore_island(ship_, direction);
}
=== modified file 'src/wui/soldiercapacitycontrol.cc'
--- src/wui/soldiercapacitycontrol.cc 2016-02-13 12:15:29 +0000
+++ src/wui/soldiercapacitycontrol.cc 2016-03-19 10:27:47 +0000
@@ -45,12 +45,12 @@
void click_decrease();
void click_increase();
- InteractiveGameBase & m_igb;
+ InteractiveGameBase & igbase_;
Widelands::Building & building_;
- UI::Button m_decrease;
- UI::Button m_increase;
- UI::Textarea m_value;
+ UI::Button decrease_;
+ UI::Button increase_;
+ UI::Textarea value_;
};
SoldierCapacityControl::SoldierCapacityControl
@@ -58,28 +58,28 @@
Widelands::Building & building)
:
Box(parent, 0, 0, Horizontal),
-m_igb(igb),
+igbase_(igb),
building_(building),
-m_decrease
+decrease_
(this, "decrease", 0, 0, 32, 32,
g_gr->images().get("images/ui_basic/but4.png"),
g_gr->images().get("images/wui/buildings/menu_down_train.png"), _("Decrease capacity")),
-m_increase
+increase_
(this, "increase", 0, 0, 32, 32,
g_gr->images().get("images/ui_basic/but4.png"),
g_gr->images().get("images/wui/buildings/menu_up_train.png"), _("Increase capacity")),
-m_value(this, "199", UI::Align::kCenter)
+value_(this, "199", UI::Align::kCenter)
{
- m_decrease.sigclicked.connect(boost::bind(&SoldierCapacityControl::click_decrease, boost::ref(*this)));
- m_increase.sigclicked.connect(boost::bind(&SoldierCapacityControl::click_increase, boost::ref(*this)));
+ decrease_.sigclicked.connect(boost::bind(&SoldierCapacityControl::click_decrease, boost::ref(*this)));
+ increase_.sigclicked.connect(boost::bind(&SoldierCapacityControl::click_increase, boost::ref(*this)));
add(new UI::Textarea(this, _("Capacity")), UI::Align::kHCenter);
- add(&m_decrease, UI::Align::kHCenter);
- add(&m_value, UI::Align::kHCenter);
- add(&m_increase, UI::Align::kHCenter);
+ add(&decrease_, UI::Align::kHCenter);
+ add(&value_, UI::Align::kHCenter);
+ add(&increase_, UI::Align::kHCenter);
- m_decrease.set_repeating(true);
- m_increase.set_repeating(true);
+ decrease_.set_repeating(true);
+ increase_.set_repeating(true);
set_thinks(true);
}
@@ -91,16 +91,16 @@
char buffer[sizeof("4294967295")];
sprintf(buffer, "%2u", capacity);
- m_value.set_text(buffer);
+ value_.set_text(buffer);
- bool const can_act = m_igb.can_act(building_.owner().player_number());
- m_decrease.set_enabled(can_act && soldiers->min_soldier_capacity() < capacity);
- m_increase.set_enabled(can_act && soldiers->max_soldier_capacity() > capacity);
+ bool const can_act = igbase_.can_act(building_.owner().player_number());
+ decrease_.set_enabled(can_act && soldiers->min_soldier_capacity() < capacity);
+ increase_.set_enabled(can_act && soldiers->max_soldier_capacity() > capacity);
}
void SoldierCapacityControl::change_soldier_capacity(int delta)
{
- m_igb.game().send_player_change_soldier_capacity(building_, delta);
+ igbase_.game().send_player_change_soldier_capacity(building_, delta);
}
void SoldierCapacityControl::click_decrease()
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2016-02-17 22:13:21 +0000
+++ src/wui/soldierlist.cc 2016-03-19 10:27:47 +0000
@@ -40,6 +40,14 @@
using Widelands::Soldier;
using Widelands::SoldierControl;
+namespace {
+
+constexpr uint32_t kMaxColumns = 6;
+constexpr uint32_t kAnimateSpeed = 300; ///< in pixels per second
+constexpr uint32_t kIconBorder = 2;
+
+} // namespace
+
/**
* Iconic representation of soldiers, including their levels and current health.
*/
@@ -48,7 +56,7 @@
SoldierPanel(UI::Panel & parent, Widelands::EditorGameBase & egbase, Widelands::Building & building);
- Widelands::EditorGameBase & egbase() const {return m_egbase;}
+ Widelands::EditorGameBase & egbase() const {return egbase_;}
void think() override;
void draw(RenderTarget &) override;
@@ -81,25 +89,21 @@
/*@}*/
};
- Widelands::EditorGameBase & m_egbase;
- SoldierControl & m_soldiers;
-
- SoldierFn m_mouseover_fn;
- SoldierFn m_click_fn;
-
- std::vector<Icon> m_icons;
-
- uint32_t m_rows;
- uint32_t m_cols;
-
- uint32_t m_icon_width;
- uint32_t m_icon_height;
-
- int32_t m_last_animate_time;
-
- static const uint32_t MaxColumns = 6;
- static const uint32_t AnimateSpeed = 300; ///< in pixels per second
- static const uint32_t IconBorder = 2;
+ Widelands::EditorGameBase & egbase_;
+ SoldierControl& soldiers_;
+
+ SoldierFn mouseover_fn_;
+ SoldierFn click_fn_;
+
+ std::vector<Icon> icons_;
+
+ uint32_t rows_;
+ uint32_t cols_;
+
+ uint32_t icon_width_;
+ uint32_t icon_height_;
+
+ int32_t last_animate_time_;
};
SoldierPanel::SoldierPanel
@@ -108,39 +112,39 @@
Widelands::Building & building)
:
Panel(&parent, 0, 0, 0, 0),
-m_egbase(gegbase),
-m_soldiers(*dynamic_cast<SoldierControl *>(&building)),
-m_last_animate_time(0)
+egbase_(gegbase),
+soldiers_(*dynamic_cast<SoldierControl *>(&building)),
+last_animate_time_(0)
{
- Soldier::calc_info_icon_size(building.owner().tribe(), m_icon_width, m_icon_height);
- m_icon_width += 2 * IconBorder;
- m_icon_height += 2 * IconBorder;
+ Soldier::calc_info_icon_size(building.owner().tribe(), icon_width_, icon_height_);
+ icon_width_ += 2 * kIconBorder;
+ icon_height_ += 2 * kIconBorder;
- uint32_t maxcapacity = m_soldiers.max_soldier_capacity();
- if (maxcapacity <= MaxColumns) {
- m_cols = maxcapacity;
- m_rows = 1;
+ uint32_t maxcapacity = soldiers_.max_soldier_capacity();
+ if (maxcapacity <= kMaxColumns) {
+ cols_ = maxcapacity;
+ rows_ = 1;
} else {
- m_cols = MaxColumns;
- m_rows = (maxcapacity + m_cols - 1) / m_cols;
+ cols_ = kMaxColumns;
+ rows_ = (maxcapacity + cols_ - 1) / cols_;
}
- set_size(m_cols * m_icon_width, m_rows * m_icon_height);
- set_desired_size(m_cols * m_icon_width, m_rows * m_icon_height);
+ set_size(cols_ * icon_width_, rows_ * icon_height_);
+ set_desired_size(cols_ * icon_width_, rows_ * icon_height_);
set_thinks(true);
// Initialize the icons
uint32_t row = 0;
uint32_t col = 0;
- for (Soldier * soldier : m_soldiers.present_soldiers()) {
+ for (Soldier * soldier : soldiers_.present_soldiers()) {
Icon icon;
icon.soldier = soldier;
icon.row = row;
icon.col = col;
icon.pos = calc_pos(row, col);
- m_icons.push_back(icon);
+ icons_.push_back(icon);
- if (++col >= m_cols) {
+ if (++col >= cols_) {
col = 0;
row++;
}
@@ -152,7 +156,7 @@
*/
void SoldierPanel::set_mouseover(const SoldierPanel::SoldierFn & fn)
{
- m_mouseover_fn = fn;
+ mouseover_fn_ = fn;
}
/**
@@ -160,22 +164,22 @@
*/
void SoldierPanel::set_click(const SoldierPanel::SoldierFn & fn)
{
- m_click_fn = fn;
+ click_fn_ = fn;
}
void SoldierPanel::think()
{
bool changes = false;
- uint32_t capacity = m_soldiers.soldier_capacity();
+ uint32_t capacity = soldiers_.soldier_capacity();
// Update soldier list and target row/col:
- std::vector<Soldier *> soldierlist = m_soldiers.present_soldiers();
+ std::vector<Soldier *> soldierlist = soldiers_.present_soldiers();
std::vector<uint32_t> row_occupancy;
- row_occupancy.resize(m_rows);
+ row_occupancy.resize(rows_);
// First pass: check whether existing icons are still valid, and compact them
- for (uint32_t idx = 0; idx < m_icons.size(); ++idx) {
- Icon & icon = m_icons[idx];
+ for (uint32_t idx = 0; idx < icons_.size(); ++idx) {
+ Icon & icon = icons_[idx];
Soldier * soldier = icon.soldier.get(egbase());
if (soldier) {
std::vector<Soldier *>::iterator it = std::find(soldierlist.begin(), soldierlist.end(), soldier);
@@ -186,7 +190,7 @@
}
if (!soldier) {
- m_icons.erase(m_icons.begin() + idx);
+ icons_.erase(icons_.begin() + idx);
idx--;
changes = true;
continue;
@@ -194,8 +198,8 @@
while
(icon.row &&
- (row_occupancy[icon.row] >= MaxColumns ||
- icon.row * MaxColumns + row_occupancy[icon.row] >= capacity))
+ (row_occupancy[icon.row] >= kMaxColumns ||
+ icon.row * kMaxColumns + row_occupancy[icon.row] >= capacity))
icon.row--;
icon.col = row_occupancy[icon.row]++;
@@ -207,7 +211,7 @@
icon.soldier = soldierlist.back();
soldierlist.pop_back();
icon.row = 0;
- while (row_occupancy[icon.row] >= MaxColumns)
+ while (row_occupancy[icon.row] >= kMaxColumns)
icon.row++;
icon.col = row_occupancy[icon.row]++;
icon.pos = calc_pos(icon.row, icon.col);
@@ -215,32 +219,32 @@
// Let soldiers slide in from the right border
icon.pos.x = get_w();
- std::vector<Icon>::iterator insertpos = m_icons.begin();
+ std::vector<Icon>::iterator insertpos = icons_.begin();
- for (std::vector<Icon>::iterator icon_iter = m_icons.begin();
- icon_iter != m_icons.end();
+ for (std::vector<Icon>::iterator icon_iter = icons_.begin();
+ icon_iter != icons_.end();
++icon_iter) {
if (icon_iter->row <= icon.row)
insertpos = icon_iter + 1;
- icon.pos.x = std::max<int32_t>(icon.pos.x, icon_iter->pos.x + m_icon_width);
+ icon.pos.x = std::max<int32_t>(icon.pos.x, icon_iter->pos.x + icon_width_);
}
icon.cache_health = 0;
icon.cache_level = 0;
- m_icons.insert(insertpos, icon);
+ icons_.insert(insertpos, icon);
changes = true;
}
// Third pass: animate icons
int32_t curtime = SDL_GetTicks();
- int32_t dt = std::min(std::max(curtime - m_last_animate_time, 0), 1000);
- int32_t maxdist = dt * AnimateSpeed / 1000;
- m_last_animate_time = curtime;
+ int32_t dt = std::min(std::max(curtime - last_animate_time_, 0), 1000);
+ int32_t maxdist = dt * kAnimateSpeed / 1000;
+ last_animate_time_ = curtime;
- for (Icon& icon : m_icons) {
+ for (Icon& icon : icons_) {
Point goal = calc_pos(icon.row, icon.col);
Point dp = goal - icon.pos;
@@ -270,41 +274,41 @@
if (changes) {
Point mousepos = get_mouse_position();
- m_mouseover_fn(find_soldier(mousepos.x, mousepos.y));
+ mouseover_fn_(find_soldier(mousepos.x, mousepos.y));
}
}
void SoldierPanel::draw(RenderTarget & dst)
{
// Fill a region matching the current site capacity with black
- uint32_t capacity = m_soldiers.soldier_capacity();
- uint32_t fullrows = capacity / MaxColumns;
+ uint32_t capacity = soldiers_.soldier_capacity();
+ uint32_t fullrows = capacity / kMaxColumns;
if (fullrows)
dst.fill_rect
- (Rect(Point(0, 0), get_w(), m_icon_height * fullrows),
+ (Rect(Point(0, 0), get_w(), icon_height_ * fullrows),
RGBAColor(0, 0, 0, 0));
- if (capacity % MaxColumns)
+ if (capacity % kMaxColumns)
dst.fill_rect
(Rect
- (Point(0, m_icon_height * fullrows),
- m_icon_width * (capacity % MaxColumns),
- m_icon_height),
+ (Point(0, icon_height_ * fullrows),
+ icon_width_ * (capacity % kMaxColumns),
+ icon_height_),
RGBAColor(0, 0, 0, 0));
// Draw icons
- for (const Icon& icon : m_icons) {
+ for (const Icon& icon : icons_) {
const Soldier * soldier = icon.soldier.get(egbase());
if (!soldier)
continue;
- soldier->draw_info_icon(dst, icon.pos + Point(IconBorder, IconBorder), false);
+ soldier->draw_info_icon(dst, icon.pos + Point(kIconBorder, kIconBorder), false);
}
}
Point SoldierPanel::calc_pos(uint32_t row, uint32_t col) const
{
- return Point(col * m_icon_width, row * m_icon_height);
+ return Point(col * icon_width_, row * icon_height_);
}
/**
@@ -312,8 +316,8 @@
*/
const Soldier * SoldierPanel::find_soldier(int32_t x, int32_t y) const
{
- for (const Icon& icon : m_icons) {
- Rect r(icon.pos, m_icon_width, m_icon_height);
+ for (const Icon& icon : icons_) {
+ Rect r(icon.pos, icon_width_, icon_height_);
if (r.contains(Point(x, y))) {
return icon.soldier.get(egbase());
}
@@ -324,8 +328,8 @@
void SoldierPanel::handle_mousein(bool inside)
{
- if (!inside && m_mouseover_fn)
- m_mouseover_fn(nullptr);
+ if (!inside && mouseover_fn_)
+ mouseover_fn_(nullptr);
}
bool SoldierPanel::handle_mousemove
@@ -335,17 +339,17 @@
int32_t /* xdiff */,
int32_t /* ydiff */)
{
- if (m_mouseover_fn)
- m_mouseover_fn(find_soldier(x, y));
+ if (mouseover_fn_)
+ mouseover_fn_(find_soldier(x, y));
return true;
}
bool SoldierPanel::handle_mousepress(uint8_t btn, int32_t x, int32_t y)
{
if (btn == SDL_BUTTON_LEFT) {
- if (m_click_fn) {
+ if (click_fn_) {
if (const Soldier * soldier = find_soldier(x, y))
- m_click_fn(soldier);
+ click_fn_(soldier);
}
return true;
}
@@ -370,11 +374,11 @@
void set_soldier_preference(int32_t changed_to);
void think() override;
- InteractiveGameBase & m_igb;
- Widelands::Building & building_;
- SoldierPanel m_soldierpanel;
- UI::Radiogroup m_soldier_preference;
- UI::Textarea m_infotext;
+ InteractiveGameBase& igbase_;
+ Widelands::Building& building_;
+ SoldierPanel soldierpanel_;
+ UI::Radiogroup soldier_preference_;
+ UI::Textarea infotext_;
};
SoldierList::SoldierList
@@ -384,19 +388,19 @@
:
UI::Box(&parent, 0, 0, UI::Box::Vertical),
-m_igb(igb),
+igbase_(igb),
building_(building),
-m_soldierpanel(*this, igb.egbase(), building),
-m_infotext(this, _("Click soldier to send away"))
+soldierpanel_(*this, igb.egbase(), building),
+infotext_(this, _("Click soldier to send away"))
{
- add(&m_soldierpanel, UI::Align::kHCenter);
+ add(&soldierpanel_, UI::Align::kHCenter);
add_space(2);
- add(&m_infotext, UI::Align::kHCenter);
+ add(&infotext_, UI::Align::kHCenter);
- m_soldierpanel.set_mouseover(boost::bind(&SoldierList::mouseover, this, _1));
- m_soldierpanel.set_click(boost::bind(&SoldierList::eject, this, _1));
+ soldierpanel_.set_mouseover(boost::bind(&SoldierList::mouseover, this, _1));
+ soldierpanel_.set_click(boost::bind(&SoldierList::eject, this, _1));
// We don't want translators to translate this twice, so it's a bit involved.
int w = UI::g_fh1->render(
@@ -413,31 +417,31 @@
UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
- bool can_act = m_igb.can_act(building_.owner().player_number());
+ bool can_act = igbase_.can_act(building_.owner().player_number());
if (upcast(Widelands::MilitarySite, ms, &building)) {
- m_soldier_preference.add_button
+ soldier_preference_.add_button
(buttons, Point(0, 0),
g_gr->images().get("images/wui/buildings/prefer_rookies.png"),
_("Prefer Rookies"));
- m_soldier_preference.add_button
+ soldier_preference_.add_button
(buttons, Point(32, 0),
g_gr->images().get("images/wui/buildings/prefer_heroes.png"),
_("Prefer Heroes"));
- UI::Radiobutton* button = m_soldier_preference.get_first_button();
+ UI::Radiobutton* button = soldier_preference_.get_first_button();
while (button) {
buttons->add(button, UI::Align::kLeft);
button = button->next_button();
}
- m_soldier_preference.set_state(0);
+ soldier_preference_.set_state(0);
if (ms->get_soldier_preference() == Widelands::MilitarySite::kPrefersHeroes) {
- m_soldier_preference.set_state(1);
+ soldier_preference_.set_state(1);
}
if (can_act) {
- m_soldier_preference.changedto.connect
+ soldier_preference_.changedto.connect
(boost::bind(&SoldierList::set_soldier_preference, this, _1));
} else {
- m_soldier_preference.set_enabled(false);
+ soldier_preference_.set_enabled(false);
}
}
buttons->add_inf_space();
@@ -456,19 +460,19 @@
void SoldierList::think()
{
// Only update the soldiers pref radio if player is spectator
- if (m_igb.can_act(building_.owner().player_number())) {
+ if (igbase_.can_act(building_.owner().player_number())) {
return;
}
if (upcast(Widelands::MilitarySite, ms, &building_)) {
switch (ms->get_soldier_preference()) {
case Widelands::MilitarySite::kPrefersRookies:
- m_soldier_preference.set_state(0);
+ soldier_preference_.set_state(0);
break;
case Widelands::MilitarySite::kPrefersHeroes:
- m_soldier_preference.set_state(1);
+ soldier_preference_.set_state(1);
break;
case Widelands::MilitarySite::kNoPreference:
- m_soldier_preference.set_state(-1);
+ soldier_preference_.set_state(-1);
break;
}
}
@@ -478,11 +482,11 @@
void SoldierList::mouseover(const Soldier * soldier)
{
if (!soldier) {
- m_infotext.set_text(_("Click soldier to send away"));
+ infotext_.set_text(_("Click soldier to send away"));
return;
}
- m_infotext.set_text(
+ infotext_.set_text(
(boost::format(_("HP: %1$u/%2$u AT: %3$u/%4$u DE: %5$u/%6$u EV: %7$u/%8$u"))
% soldier->get_health_level() % soldier->descr().get_max_health_level()
% soldier->get_attack_level() % soldier->descr().get_max_attack_level()
@@ -495,11 +499,11 @@
void SoldierList::eject(const Soldier * soldier)
{
uint32_t const capacity_min = soldiers().min_soldier_capacity();
- bool can_act = m_igb.can_act(building_.owner().player_number());
+ bool can_act = igbase_.can_act(building_.owner().player_number());
bool over_min = capacity_min < soldiers().present_soldiers().size();
if (can_act && over_min)
- m_igb.game().send_player_drop_soldier(building_, soldier->serial());
+ igbase_.game().send_player_drop_soldier(building_, soldier->serial());
}
void SoldierList::set_soldier_preference(int32_t changed_to) {
@@ -507,7 +511,7 @@
upcast(Widelands::MilitarySite, ms, &building_);
assert(ms);
#endif
- m_igb.game().send_player_militarysite_set_soldier_preference
+ igbase_.game().send_player_militarysite_set_soldier_preference
(building_, changed_to == 0 ?
Widelands::MilitarySite::kPrefersRookies:
Widelands::MilitarySite::kPrefersHeroes);
=== modified file 'src/wui/story_message_box.cc'
--- src/wui/story_message_box.cc 2015-10-04 19:26:02 +0000
+++ src/wui/story_message_box.cc 2016-03-19 10:27:47 +0000
@@ -36,7 +36,7 @@
uint32_t const w, uint32_t const h)
: UI::Window(parent, "story_message_box", 0, 0, 600, 400, title.c_str())
{
- UI::MultilineTextarea * m_text = nullptr;
+ UI::MultilineTextarea * message_text = nullptr;
int32_t const spacing = 5;
int32_t offsy = 5;
int32_t offsx = spacing;
@@ -44,15 +44,15 @@
int32_t posy = offsy;
set_inner_size(w, h);
- m_text =
+ message_text =
new UI::MultilineTextarea
(this,
posx, posy,
get_inner_w() - posx - spacing,
get_inner_h() - posy - 2 * spacing - 50);
- if (m_text)
- m_text->set_text(body);
+ if (message_text)
+ message_text->set_text(body);
int32_t const but_width = 120;
int32_t space = get_inner_w() - 2 * spacing;
Follow ups