Skip to content

Commit

Permalink
Autogenerated "Time of Day Schedule" help browser section.
Browse files Browse the repository at this point in the history
  • Loading branch information
fendrin committed Oct 19, 2014
1 parent 22b6687 commit f8887a5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
8 changes: 5 additions & 3 deletions changelog
Expand Up @@ -78,6 +78,8 @@ Version 1.13.0-dev:
* Disabled the tod schedule and playlist menues in pure map mode.
* Support for displaying the saved status of the selected area.
* Fixed error messages about missing UI elements.
* Help Browser:
* Autogenerated Time of Day Schedule section
* Language and i18n:
* Updated translations: Czech, French, German, Greek, Hungarian, Italian,
Lithuanian, Scottish Gaelic, Slovak, Vietnamese
Expand Down Expand Up @@ -855,10 +857,10 @@ Version 1.11.7:
have also been made:
* S3: scenario now ends after dwarf leader is killed (no need to continue
to the signpost any more)
* S3: add possibility to give Grüü instructions
* S3: add possibility to give Gr���� instructions
* S6: new Lua AI code for the transports with somewhat different behavior
* S14: Kapou'e cannot recruit troll whelps any more (this scenario only)
* S14: "It is now Grüü's turn" displayed correctly on Side 4 turn
* S14: "It is now Gr����'s turn" displayed correctly on Side 4 turn
* S16: fix recalling of alternative units if Jetto/Inarix have been killed
* S18: Howgarth's death now results in defeat, as stated in objectives
* S18: Shan Taum death dialog shown correctly if Kapou'e kills him himself
Expand Down Expand Up @@ -10552,7 +10554,7 @@ Version 0.8.2:
* fixed problems with cache invalidation
* fixed file descriptor leak
* fixed 'gender' not working with move_unit_fake
* fixed grüü losing experience when joining
* fixed gr�������� losing experience when joining
* fixed units moving through water not being submerged while moving
* terrains tiles are now cut according to the hexagonal shape, to avoid some graphical glitches
* workaround a SDL_TTF bug that makes it crash when presented an invalid UTF-8 string
Expand Down
9 changes: 8 additions & 1 deletion data/core/help.cfg
@@ -1,10 +1,17 @@
#textdomain wesnoth-help
[help]
[toplevel]
sections=introduction,gameplay,units,abilities_section,traits_section,weapon_specials,eras_section,terrains_section,addons,editor,commands,encyclopedia
sections=introduction,gameplay,units,abilities_section,traits_section,weapon_specials,eras_section,terrains_section,schedule,addons,editor,commands,encyclopedia
topics=about,license
[/toplevel]

[section]
id=schedule
title= _ "Time of Day Schedule"
generator=time_of_days
sort_topics=generated
[/section]

[section]
id=introduction
title= _ "Introduction"
Expand Down
3 changes: 3 additions & 0 deletions players_changelog
Expand Up @@ -30,6 +30,9 @@ Version 1.13.0-dev:
* Graphics:
* Smooth unit movement over terrain with elevation (e.g. keeps/bridges)

* Help Browser:
* Autogenerated Time of Day Schedule section

* Language and i18n:
* Updated translations: Czech, French, German, Greek, Hungarian, Italian,
Lithuanian, Scottish Gaelic, Slovak, Vietnamese.
Expand Down
37 changes: 37 additions & 0 deletions src/help.cpp
Expand Up @@ -40,6 +40,8 @@
#include "unit_helper.hpp"
#include "wml_separators.hpp"
#include "serialization/parser.hpp"
#include "time_of_day.hpp"
#include "tod_manager.hpp"

#include <boost/foreach.hpp>

Expand Down Expand Up @@ -578,6 +580,7 @@ enum UNIT_DESCRIPTION_TYPE {FULL_DESCRIPTION, NO_DESCRIPTION, NON_REVEALING_DESC
/// encountered.
static UNIT_DESCRIPTION_TYPE description_type(const unit_type &type);
static std::vector<topic> generate_ability_topics(const bool);
static std::vector<topic> generate_time_of_day_topics(const bool);
static std::vector<topic> generate_weapon_special_topics(const bool);

static void generate_era_sections(const config *help_cfg, section &sec, int level);
Expand Down Expand Up @@ -1071,6 +1074,8 @@ std::vector<topic> generate_topics(const bool sort_generated,const std::string &
res = generate_ability_topics(sort_generated);
} else if (generator == "weapon_specials") {
res = generate_weapon_special_topics(sort_generated);
} else if (generator == "time_of_days") {
res = generate_time_of_day_topics(sort_generated);
} else {
std::vector<std::string> parts = utils::split(generator, ':', utils::STRIP_SPACES);
if (parts[0] == "units" && parts.size()>1) {
Expand Down Expand Up @@ -1155,6 +1160,38 @@ const std::vector<std::string>& topic_text::parsed_text() const
return parsed_text_;
}

std::vector<topic> generate_time_of_day_topics(const bool /*sort_generated*/)
{
std::vector<topic> topics;
std::stringstream toplevel;

if (! resources::tod_manager) {
toplevel << N_("Only available during a scenario.");
topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
return topics;
}
const std::vector<time_of_day>& times = resources::tod_manager->times();
BOOST_FOREACH(const time_of_day& time, times)
{
const std::string id = "time_of_day_" + time.id;
const std::string image = "<img>src='" + time.image + "'</img>";
std::stringstream text;

toplevel << make_link(time.name.str(), id) << jump_to(160) <<
image << jump(30) << time.lawful_bonus << '\n';

text << image << '\n' <<
time.description.str() << '\n' <<
"Lawful Bonus: " << time.lawful_bonus << '\n' <<
'\n' << make_link(N_("Schedule"), "..schedule");

topics.push_back( topic(time.name.str(), id, text.str()) );
}

topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
return topics;
}

std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
{
std::vector<topic> topics;
Expand Down
4 changes: 2 additions & 2 deletions src/reports.cpp
Expand Up @@ -1099,7 +1099,7 @@ REPORT_GENERATOR(tod_stats, rc)
int times = schedule.size();
text << current + 1 << "/" << times;

return text_report(text.str(), tooltip.str());
return text_report(text.str(), tooltip.str(), "..schedule");
}

static config time_of_day_at(reports::context & rc, const map_location& mouseover_hex)
Expand Down Expand Up @@ -1142,7 +1142,7 @@ static config time_of_day_at(reports::context & rc, const map_location& mouseove
else if (tod.bonus_modified < 0) tod_image += "~DARKEN()";
if (preferences::flip_time()) tod_image += "~FL(horiz)";

return image_report(tod_image, tooltip.str(), "time_of_day");
return image_report(tod_image, tooltip.str(), "time_of_day_" + tod.id);
}
REPORT_GENERATOR(time_of_day, rc)
{
Expand Down

0 comments on commit f8887a5

Please sign in to comment.