Skip to content

Commit

Permalink
Restore loadscreen translatable stage messages
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Apr 1, 2016
1 parent 1c5f602 commit a5cd2c7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
47 changes: 42 additions & 5 deletions src/gui/dialogs/loadscreen.cpp
Expand Up @@ -11,6 +11,11 @@
See the COPYING file for more details.
*/

/**
* @file
* Screen with logo and loading status info during program-startup.
*/

#define GETTEXT_DOMAIN "wesnoth-lib"

#include "cursor.hpp"
Expand All @@ -22,9 +27,37 @@

#include "video.hpp"
#include "cursor.hpp"
#include "gettext.hpp"
#include "log.hpp"
#include <boost/bind.hpp>
#include <boost/thread.hpp>

static lg::log_domain log_loadscreen("loadscreen");
#define ERR_LS LOG_STREAM(err, log_loadscreen)
#define WRN_LS LOG_STREAM(warn, log_loadscreen)
#define LOG_LS LOG_STREAM(info, log_loadscreen)
#define DBG_LS LOG_STREAM(debug, log_loadscreen)

static const std::map<std::string, std::string> stages =
{
{ "build terrain", N_("Building terrain rules") },
{ "create cache", N_("Reading files and creating cache") },
{ "init display", N_("Initializing display") },
{ "init fonts", N_("Reinitialize fonts for the current language") },
{ "init teams", N_("Initializing teams") },
{ "init theme", N_("Initializing display") },
{ "load config", N_("Loading game configuration") },
{ "load data", N_("Loading data files") },
{ "load level", N_("Loading level") },
{ "init lua", N_("Initializing scripting engine") },
{ "init whiteboard", N_("Initializing planning mode") },
{ "load unit types", N_("Reading unit files") },
{ "load units", N_("Loading units") },
{ "refresh addons", N_("Searching for installed add-ons") },
{ "start game", N_("Starting game") },
{ "verify cache", N_("Verifying cache") },
};

namespace gui2
{

Expand All @@ -37,8 +70,8 @@ tloadscreen::tloadscreen(boost::function<void()> f)
, work_(f)
, worker_()
, cursor_setter_()
, current_stage_(nullptr)
, current_visible_stage_(nullptr)
, current_stage_()
, current_visible_stage_()
{
current_load = this;
}
Expand Down Expand Up @@ -79,9 +112,13 @@ void tloadscreen::progress(const char* stage)
if(!current_load) {
return;
}
// Currently this is a no-op stub
if(stage) {
current_load->current_stage_ = stage;
auto iter = stages.find(stage);
if(iter == stages.end()) {
WRN_LS << "Stage ID '" << stage << "' missing description." << std::endl;
return;
}
current_load->current_stage_ = iter;
}
}

Expand All @@ -95,7 +132,7 @@ void tloadscreen::timer_callback(twindow& window)
if (current_stage_ != current_visible_stage_)
{
current_visible_stage_ = current_stage_;
progress_stage_label_->set_label(current_visible_stage_);
progress_stage_label_->set_label(t_string(current_stage_->second, "wesnoth-lib") + "...");
}
++animation_counter_;
if (animation_counter_ % 2 == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/gui/dialogs/loadscreen.hpp
Expand Up @@ -18,6 +18,7 @@

#include <boost/function.hpp>
#include <boost/scoped_ptr.hpp>
#include <map>

class CVideo;
namespace boost
Expand Down Expand Up @@ -77,9 +78,8 @@ class tloadscreen : public tdialog
tlabel* animation_label_;
static tloadscreen* current_load;

//Note we cannot use std::strings here unless we we explicitly use mutexes.
const char* current_stage_;
const char* current_visible_stage_;
std::map<std::string,std::string>::const_iterator current_stage_;
std::map<std::string,std::string>::const_iterator current_visible_stage_;
};

} // namespace gui2
2 changes: 1 addition & 1 deletion src/play_controller.cpp
Expand Up @@ -243,6 +243,7 @@ void play_controller::init(CVideo& video, const config& level)
resources::tunnels = gamestate().pathfind_manager_.get();

LOG_NG << "initializing whiteboard..." << (SDL_GetTicks() - ticks()) << std::endl;
gui2::tloadscreen::progress("init whiteboard");
whiteboard_manager_.reset(new wb::manager());
resources::whiteboard = whiteboard_manager_;

Expand Down Expand Up @@ -272,7 +273,6 @@ void play_controller::init(CVideo& video, const config& level)
LOG_NG << "done initializing display... " << (SDL_GetTicks() - ticks()) << std::endl;

LOG_NG << "building gamestate to gui and whiteboard... " << (SDL_GetTicks() - ticks()) << std::endl;
gui2::tloadscreen::progress("init whiteboard");
// This *needs* to be created before the show_intro and show_map_scene
// as that functions use the manager state_of_game
// Has to be done before registering any events!
Expand Down
14 changes: 7 additions & 7 deletions src/wesnoth.cpp
Expand Up @@ -636,38 +636,38 @@ static int do_gameloop(const std::vector<std::string>& args)
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
#endif

gui2::tloadscreen::progress("init gui"); // Does nothing since there's no loadscreen yet
gui2::init();
const gui2::event::tmanager gui_event_manager;


game_config_manager config_manager(cmdline_opts, game->video(),
game->jump_to_editor());

gui2::tloadscreen::display(game->video(), [&res, &config_manager]() {
gui2::tloadscreen::progress("load config");
res = config_manager.init_game_config(game_config_manager::NO_FORCE_RELOAD);
});

if(res == false) {
std::cerr << "could not initialize game config\n";
return 1;
return;
}
gui2::tloadscreen::progress("init fonts");

res = font::load_font_config();
if(res == false) {
std::cerr << "could not re-initialize fonts for the current language\n";
return 1;
return;
}

gui2::tloadscreen::progress("refresh addons");
refresh_addon_version_info_cache();
});

if(res == false) {
return 1;
}

config tips_of_day;

gui2::tloadscreen::progress("titlescreen");

LOG_CONFIG << "time elapsed: "<< (SDL_GetTicks() - start_ticks) << " ms\n";

plugins_manager plugins_man(new application_lua_kernel(&game->video()));
Expand Down

0 comments on commit a5cd2c7

Please sign in to comment.