Improve and clean tips of the days:

- Add a "Previous" button, and rename the "more" as "Next"

- Add fake attributions

- Fix the size. I think it look nicer and avoid moving the head of the text

- use a [tip] text=...source=... [/tip] structure, easy to add other keys

- shuffle only when starting the game, and keep the same order for the session

- show the next tip after each refresh
This commit is contained in:
Ali El Gariani 2007-11-17 17:32:03 +00:00
parent 8e54fedc2c
commit bb1118204d
4 changed files with 248 additions and 126 deletions

View file

@ -1,39 +1,151 @@
#textdomain wesnoth
tip_of_day1= _ "Lawful units fight better at day, and chaotic units fight better at night. Neutral units are unaffected by day and night."
tip_of_day2= _ "In a campaign, you can use veteran units from previous scenarios by using the 'recall' option."
tip_of_day3= _ "There are six types of attacks: pierce, blade, impact, fire, cold, and arcane. Different units have weaknesses against different types of attacks. Right-click on a unit, and then select 'Unit Description', and then click 'Resistance' to see how much resistance a unit has against different attack types."
tip_of_day4= _ "The terrain your units are occupying determines the chance your opponents have of hitting them in battle. The defensive rating for the currently selected unit in the currently selected terrain is displayed in the top right corner of the screen."
tip_of_day5= _ "Poisoned units lose 8 hitpoints every turn, but they will not die from poison: poison will never reduce them below 1 hitpoint. Poisoned units can be cured by moving them to a village, or placing them next to a unit with the 'cures' ability."
tip_of_day6= _ "You can use units from a previous scenario by selecting 'Recall' in the game menu. By recalling the same units over and over, you can build up a powerful and experienced army."
tip_of_day7= _ "Units have a Zone of Control in each of the hexes next to them. If a unit moves into an enemy's Zone of Control, it may not move any further that turn. Level 0 units are too frail to control a zone; and skirmisher units are skilled enough to ignore these zones."
tip_of_day8= _ "The chance to hit a unit usually depends on how well that unit can defend itself in the terrain it is standing in, however magical attacks have a 70% chance to hit both when attacking and defending. Marksman attacks have at least 60% chance to hit when attacking."
tip_of_day9= _ "Units stationed in villages heal 8 hitpoints at the beginning of their turn."
tip_of_day10= _ "Units rest if they do not move or attack during their turn. They will recover 2 hitpoints at the beginning of their next turn."
tip_of_day11= _ "Most foot units defend better in villages and castles than in most other terrain, while most mounted units don't get any defensive advantage in villages and castles."
tip_of_day12= _ "Horse based units are generally resistant to attacks with bladed or impact weapons, but are vulnerable to attacks with piercing weapons, including bows and spears."
tip_of_day13= _ "Inflicting the killing blow on an enemy unit is the best way to gain experience. Units killing an enemy will gain 8 experience for every level of the unit they kill."
tip_of_day14= _ "Elvish units move and fight very well in forest. Dwarvish units move and fight very well in hills and mountains."
tip_of_day15= _ "Patience is often key. Rather than attacking in bad conditions, or with few troops, wait for better conditions and then attack."
tip_of_day16= _ "If you are attacked from several directions, it may be a good idea to send expendable units in some directions to delay enemy units."
tip_of_day17= _ "Do not be afraid to retreat and regroup; it is often the key to victory."
tip_of_day18= _ "In most campaigns you will receive a gold bonus for finishing early, depending on the number of villages on the map and the number of turns you finish early. You will always earn more gold this way than through capturing villages and waiting for turns to run out."
tip_of_day19= _ "Your leader can recruit or recall units from any keep inside a castle, not just the keep they start on. You can capture a keep from an enemy and recruit from there. Also, some of your allies may be willing to make room for you on their keep so you can recruit there."
tip_of_day20= _ "Skeletons are resistant to piercing and bladed attacks but vulnerable to impact, fire, and arcane attacks."
tip_of_day21= _ "Units with leadership ability make lower level adjacent units on the same side fight better."
tip_of_day22= _ "Generally avoid moving next to an unoccupied village. An enemy unit may move onto the village and attack you, while enjoying the defense and healing of the village."
tip_of_day23= _ "Holding the mouse cursor on an ability or trait shows a description of that ability or trait."
tip_of_day24= _ "Use lines of units to screen injured units to let them recover."
tip_of_day25= _ "Read the hotkeys list in the preferences menu."
tip_of_day26= _ "If you move a unit, but don't attack or discover any additional information, you can undo your move by pressing 'u'."
tip_of_day27= _ "You can see how far enemy units can move by moving the mouse cursor over them."
tip_of_day28= _ "Use healers to support your attacks - they will win you battles without needing to attack anything themselves."
tip_of_day29= _ "The 'slow' attack ability makes enemy units move slower and halves the damage they do on all attacks until they end a turn."
tip_of_day30= _ "Arcane attacks are very powerful against undead."
tip_of_day31= _ "Units are healed when they advance a level. Used wisely, this can turn a fight."
tip_of_day32= _ "Charging units are best used against enemies they can kill with a single blow."
tip_of_day_33= _ "Units can gain After Maximum Level Advancements (AMLAs), which usually increase the unit's maximum hitpoints by 3. Gaining an AMLA becomes progressively harder for each AMLA the unit receives, however. Thus, it is often more useful to try to advance your lower level units."
tip_of_day_34= _ "On maps where the shroud or fog of war has been enabled, a unit's sight is limited by its maximum movement. Remember this when deciding what unit is best to scout specific types of terrain."
tip_of_day_35= _ "Nearly every icon and word in Wesnoth's playing screen has a tool-tip. Place your mouse pointer over one to get an explanation or description."
tip_of_day_36= _ "You can send the Wesnoth Project an anonymous summary of your progress using the Help Wesnoth button (indicated by the envelope icon near the lower-right-hand corner of the game main screen). This information is vital so we can adjust campaign difficulty."
tip_of_day_37= _ "To advance low-level units quickly, team them with a veteran and use the veteran to damage a joint target heavily enough for the junior partner to get in the killing blow."
tip_of_day_38= _ "You cannot undo a move that reveals any fog or shroud. Toggle the 'Delay Shroud Updates' option on when you need to move units while retaining the ability to undo."
[tip]
text= _ "Lawful units fight better at day, and chaotic units fight better at night. Neutral units are unaffected by day and night."
source= _ "- Royal Compendium of Battle Terminology - Volume II, 212YW"
[/tip]
[tip]
text= _ "In a campaign, you can use veteran units from previous scenarios by using the 'recall' option."
source= _ "- The Wesnoth Tactical Guide"
[tip]
text= _ "There are six types of attacks: pierce, blade, impact, fire, cold, and arcane. Different units have weaknesses against different types of attacks. Right-click on a unit, and then select 'Unit Description', and then click 'Resistance' to see how much resistance a unit has against different attack types."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
text= _ "The terrain your units are occupying determines the chance your opponents have of hitting them in battle. The defensive rating for the currently selected unit in the currently selected terrain is displayed in the top right corner of the screen."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Poisoned units lose 8 hitpoints every turn, but they will not die from poison: poison will never reduce them below 1 hitpoint. Poisoned units can be cured by moving them to a village, or placing them next to a unit with the 'cures' ability."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "You can use units from a previous scenario by selecting 'Recall' in the game menu. By recalling the same units over and over, you can build up a powerful and experienced army."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Units have a Zone of Control in each of the hexes next to them. If a unit moves into an enemy's Zone of Control, it may not move any further that turn. Level 0 units are too frail to control a zone; and skirmisher units are skilled enough to ignore these zones."
source= _ "- Handbook of Tactical Analysis Volume I - Haldric II, 42YW"
[/tip]
[tip]
text= _ "The chance to hit a unit usually depends on how well that unit can defend itself in the terrain it is standing in, however magical attacks have a 70% chance to hit both when attacking and defending. Marksman attacks have at least 60% chance to hit when attacking."
source= _ "- Handbook of Tactical Analysis Volume II - Haldric II, 43YW"
[/tip]
[tip]
text= _ "Units stationed in villages heal 8 hitpoints at the beginning of their turn."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Units rest if they do not move or attack during their turn. They will recover 2 hitpoints at the beginning of their next turn."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Most foot units defend better in villages and castles than in most other terrain, while most mounted units don't get any defensive advantage in villages and castles."
source= _ "- Sir Kaylan, 498YW"
[/tip]
[tip]
text= _ "Horse based units are generally resistant to attacks with bladed or impact weapons, but are vulnerable to attacks with piercing weapons, including bows and spears."
source= _ "- Sir Kaylan, 502YW"
[/tip]
[tip]
text= _ "Inflicting the killing blow on an enemy unit is the best way to gain experience. Units killing an enemy will gain 8 experience for every level of the unit they kill."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Elvish units move and fight very well in forest. Dwarvish units move and fight very well in hills and mountains."
source= _ "- High Lord Kalenz, 470YW"
[/tip]
[tip]
text= _ "Patience is often key. Rather than attacking in bad conditions, or with few troops, wait for better conditions and then attack."
source= _ "- King Konrad, 536YW"
[/tip]
[tip]
text= _ "If you are attacked from several directions, it may be a good idea to send expendable units in some directions to delay enemy units."
source= _ "- King Konrad, 552YW"
[/tip]
[tip]
text= _ "Do not be afraid to retreat and regroup; it is often the key to victory."
source= _ "- Meneldur, 123YW"
[/tip]
[tip]
text= _ "In most campaigns you will receive a gold bonus for finishing early, depending on the number of villages on the map and the number of turns you finish early. You will always earn more gold this way than through capturing villages and waiting for turns to run out."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Your leader can recruit or recall units from any keep inside a castle, not just the keep they start on. You can capture a keep from an enemy and recruit from there. Also, some of your allies may be willing to make room for you on their keep so you can recruit there."
source= _ "- Handbook of Tactical Analysis Volume I - Haldric II, 42YW"
[/tip]
[tip]
text= _ "Skeletons are resistant to piercing and bladed attacks but vulnerable to impact, fire, and arcane attacks."
source= _ "- Memoirs of Gweddry, 627YW"
[/tip]
[tip]
text= _ "Units with leadership ability make lower level adjacent units on the same side fight better."
source= _ "- Handbook of Tactical Analysis Volume I - Haldric II, 42YW"
[/tip]
[tip]
text= _ "Generally avoid moving next to an unoccupied village. An enemy unit may move onto the village and attack you, while enjoying the defense and healing of the village."
source= _ "- Great Mage Delfador, 516YW"
[/tip]
[tip]
text= _ "Holding the mouse cursor on an ability or trait shows a description of that ability or trait."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Use lines of units to screen injured units to let them recover."
source= _ "- Princess Li'sar, 515YW"
[/tip]
[tip]
text= _ "Read the hotkeys list in the preferences menu."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "If you move a unit, but don't attack or discover any additional information, you can undo your move by pressing 'u'."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "You can see how far enemy units can move by moving the mouse cursor over them."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Use healers to support your attacks - they will win you battles without needing to attack anything themselves."
source= _ "- The Scroll of Chantal, 516YW"
[/tip]
[tip]
text= _ "The 'slow' attack ability makes enemy units move slower and halves the damage they do on all attacks until they end a turn."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Arcane attacks are very powerful against undead."
source= _ "- Great Sage Dacyn, 626YW"
[/tip]
[tip]
text= _ "Units are healed when they advance a level. Used wisely, this can turn a fight."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Charging units are best used against enemies they can kill with a single blow."
source= _ "- Sir Kaylan, 498YW"
[/tip]
[tip]
text= _ "Units can gain After Maximum Level Advancements (AMLAs), which usually increase the unit's maximum hitpoints by 3. Gaining an AMLA becomes progressively harder for each AMLA the unit receives, however. Thus, it is often more useful to try to advance your lower level units."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "On maps where the shroud or fog of war has been enabled, a unit's sight is limited by its maximum movement. Remember this when deciding what unit is best to scout specific types of terrain."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "Nearly every icon and word in Wesnoth's playing screen has a tool-tip. Place your mouse pointer over one to get an explanation or description."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "You can send the Wesnoth Project an anonymous summary of your progress using the Help Wesnoth button (indicated by the envelope icon near the lower-right-hand corner of the game main screen). This information is vital so we can adjust campaign difficulty."
source= _ "- The Wesnoth Tactical Guide"
[/tip]
[tip]
text= _ "To advance low-level units quickly, team them with a veteran and use the veteran to damage a joint target heavily enough for the junior partner to get in the killing blow."
source= _ "- Queen Li'sar, 528YW"
[/tip]
[tip]
text= _ "You cannot undo a move that reveals any fog or shroud. Toggle the 'Delay Shroud Updates' option on when you need to move units while retaining the ability to undo."
source= _ "- King Konrad, 536YW"
[/tip]

View file

@ -2023,7 +2023,6 @@ static int play_game(int argc, char** argv)
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
#endif
int ntip = -1;
config tips_of_day;
loadscreen::global_loadscreen->set_progress(100, _("Loading title screen."));
@ -2053,10 +2052,10 @@ static int play_game(int argc, char** argv)
recorder.clear();
gui::TITLE_RESULT res = game.is_loading() ? gui::LOAD_GAME : gui::TITLE_CONTINUE;
gui::TITLE_RESULT res = game.is_loading() ? gui::LOAD_GAME : gui::TIP_NEXT;
while(res == gui::TITLE_CONTINUE) {
res = gui::show_title(game.disp(),tips_of_day,&ntip);
while(res == gui::TIP_NEXT) {
res = gui::show_title(game.disp(),tips_of_day);
}
game_controller::RELOAD_GAME_DATA should_reload = game_controller::RELOAD_DATA;
@ -2080,11 +2079,10 @@ static int play_game(int argc, char** argv)
continue;
}
} else if(res == gui::CHANGE_LANGUAGE) {
if(game.change_language() == false) {
if(game.change_language() == true) {
tips_of_day.clear();
continue;
}
tips_of_day.clear();
continue;
} else if(res == gui::EDIT_PREFERENCES) {
game.show_preferences();
continue;
@ -2109,7 +2107,6 @@ static int play_game(int argc, char** argv)
else{
game.play_replay();
}
ntip = -1; // Change tip when a game is played
}
return 0;

View file

@ -41,6 +41,7 @@
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
#include "wesconfig.h"
#include <algorithm>
#include "sdl_ttf/SDL_ttf.h"
@ -123,90 +124,89 @@ static bool fade_logo(game_display& screen, int xpos, int ypos)
return true;
}
//! Return the text for one of the tips-of-the-day.
static const std::string& get_tip_of_day(const config& tips,int* ntip)
{
static const std::string empty_string;
string_map::const_iterator it;
if(preferences::show_tip_of_day() == false) {
return empty_string;
}
int ntips = tips.values.size();
if(ntips == 0) {
return empty_string;
}
if(ntip != NULL && *ntip > 0) {
if(*ntip >= ntips) {
*ntip -= ntips;
}
it = tips.values.begin();
for(int i = 0; i < *ntip; i++,it++);
return it->second;
}
const int tip = (rand()%ntips);
if(ntip != NULL) {
*ntip = tip;
}
it = tips.values.begin();
for(int i = 0; i < tip; i++,it++);
return it->second;
}
//! Read the file with the tips-of-the-day.
static const config get_tips_of_day()
static const void read_tips_of_day(config& tips_of_day)
{
config cfg;
tips_of_day.clear();
LOG_CONFIG << "Loading tips of day\n";
try {
scoped_istream stream = preprocess_file("data/hardwired/tips.cfg");
read(cfg, *stream);
read(tips_of_day, *stream);
} catch(config::error&) {
ERR_CONFIG << "Could not read data/hardwired/tips.cfg\n";
}
return cfg;
//we shuffle the tips after each initial loading
config::child_itors tips = tips_of_day.child_range("tip");
if (tips.first != tips.second) {
std::random_shuffle(tips.first, tips.second);
}
}
//! Return the text for one of the tips-of-the-day.
static const config* get_tip_of_day(config& tips_of_day)
{
if (tips_of_day.empty()) {
read_tips_of_day(tips_of_day);
}
const config::child_list& tips = tips_of_day.get_children("tip");
if (!tips.empty()) {
return tips.front();
}
return NULL;
}
//! Go to the next tips-of-the-day
static const void next_tip_of_day(config& tips_of_day, bool reverse = false)
{
// we just rotate the tip list, to avoid the need to keep track
// of the current one, and keep it valid, cycle it, etc...
config::child_itors tips = tips_of_day.child_range("tip");
if (tips.first != tips.second) {
config::child_iterator direction = reverse ? tips.first+1 : tips.second-1;
std::rotate(tips.first, direction, tips.second);
}
}
//! Show one tip-of-the-day in a frame on the titlescreen.
//! This frame has 2 buttons: Next-Tip, and Show-Help.
static void draw_tip_of_day(game_display& screen,
config& tips_of_day, int* ntip,
config& tips_of_day,
const gui::dialog_frame::style& style,
gui::button* const previous_tip_button,
gui::button* const next_tip_button,
gui::button* const help_tip_button,
const SDL_Rect* const main_dialog_area,
surface_restorer& tip_of_day_restorer)
{
if(preferences::show_tip_of_day() == false) {
return;
}
// Restore the previous tip of day area to its old state (section of the title image).
tip_of_day_restorer.restore();
// Draw tip of the day
std::string tip_of_day = get_tip_of_day(tips_of_day,ntip);
if(tip_of_day.empty() == false) {
tip_of_day = font::word_wrap_text(tip_of_day, font::SIZE_NORMAL,
(game_config::title_tip_width*screen.w())/1024);
const config* tip = get_tip_of_day(tips_of_day);
if(tip != NULL) {
int tip_width = game_config::title_tip_width * screen.w() / 1024;
//const std::string& std::string text = (*tip)["text"];
//const std::string& std::string text = (*tip)["source"];
const std::string& tome = font::word_wrap_text(game_config::tome_title,
font::SIZE_NORMAL,
(game_config::title_tip_width*screen.w())/1024);
const std::string& text = font::word_wrap_text((*tip)["text"], font::SIZE_NORMAL, tip_width);
const std::string& source = font::word_wrap_text((*tip)["source"], font::SIZE_NORMAL, tip_width);
const int pad = game_config::title_tip_padding;
SDL_Rect area = font::text_area(tip_of_day,font::SIZE_NORMAL);
SDL_Rect tome_area = font::text_area(tome,font::SIZE_NORMAL,TTF_STYLE_ITALIC);
area.w = maximum<size_t>(area.w,tome_area.w) + 2*pad;
area.h += tome_area.h + next_tip_button->location().h + 3*pad;
SDL_Rect area = font::text_area(text,font::SIZE_NORMAL);
area.w = tip_width;
SDL_Rect source_area = font::text_area(source, font::SIZE_NORMAL, TTF_STYLE_ITALIC);
area.w = maximum<size_t>(area.w, source_area.w) + 2*pad;
area.h += source_area.h + next_tip_button->location().h + 3*pad;
area.x = main_dialog_area->x - (game_config::title_tip_x*screen.w())/1024 - area.w;
area.x = main_dialog_area->x - (game_config::title_tip_x * screen.w() / 1024) - area.w;
area.y = main_dialog_area->y + main_dialog_area->h - area.h;
// Note: The buttons' locations need to be set before the dialog frame is drawn.
@ -215,22 +215,30 @@ static void draw_tip_of_day(game_display& screen,
// This way, the buttons draw a part of the title image,
// because the call to restore above restored the area
// of the old tip of the day to its initial state (the title image).
next_tip_button->set_location(area.x + area.w - next_tip_button->location().w - pad,
area.y + area.h - pad - next_tip_button->location().h);
int button_x = area.x + area.w - next_tip_button->location().w - pad;
int button_y = area.y + area.h - pad - next_tip_button->location().h;
next_tip_button->set_location(button_x, button_y);
next_tip_button->set_dirty(); //force redraw even if location did not change.
button_x -= previous_tip_button->location().w + pad;
previous_tip_button->set_location(button_x, button_y);
previous_tip_button->set_dirty();
button_x = area.x + pad;
help_tip_button->set_location(button_x, button_y);
help_tip_button->set_dirty();
help_tip_button->set_location(area.x + pad,
area.y + area.h - pad - next_tip_button->location().h);
help_tip_button->set_dirty(); //force redraw even if location did not change.
gui::dialog_frame f(screen.video(), "", style, false);
tip_of_day_restorer = surface_restorer(&screen.video(), f.layout(area).exterior);
f.draw_background();
f.draw_border();
font::draw_text(&screen.video(), area, font::SIZE_NORMAL, font::NORMAL_COLOUR,
tip_of_day, area.x + pad, area.y + pad);
text, area.x + pad, area.y + pad);
// todo
font::draw_text(&screen.video(), area, font::SIZE_NORMAL, font::NORMAL_COLOUR,
tome, area.x + area.w - tome_area.w - pad,
next_tip_button->location().y - tome_area.h - pad,
source, area.x + area.w - source_area.w - pad,
next_tip_button->location().y - source_area.h - pad,
false, TTF_STYLE_ITALIC);
}
@ -252,7 +260,7 @@ namespace gui {
//! @return the value of the menu-item the user has choosen.
//! @retval see @ref TITLE_RESULT for possible values
//!
TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip)
TITLE_RESULT show_title(game_display& screen, config& tips_of_day)
{
cursor::set(cursor::NORMAL);
@ -313,7 +321,8 @@ TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip)
N_("TitleScreen button^Quit"),
// Only the above buttons go into the menu-frame
// Next 2 buttons go into frame for the tip-of-the-day:
N_("TitleScreen button^More"),
N_("TitleScreen button^Previous"),
N_("TitleScreen button^Next"),
N_("TitleScreen button^Help"),
// Next entry is no button, but shown as a mail-icon instead:
N_("TitleScreen button^Help Wesnoth") };
@ -371,26 +380,28 @@ TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip)
if(b == QUIT_GAME) break;
}
b = TITLE_CONTINUE;
b = TIP_PREVIOUS;
gui::button previous_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small");
previous_tip_button.set_help_string( sgettext(button_labels[b] ));
b = TIP_NEXT;
gui::button next_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small");
next_tip_button.set_help_string( sgettext(help_button_labels[b] ));
next_tip_button.set_help_string( sgettext(button_labels[b] ));
b = SHOW_HELP;
gui::button help_tip_button(screen.video(),sgettext(button_labels[b]),button::TYPE_PRESS,"lite_small");
help_tip_button.set_help_string( sgettext(help_button_labels[b] ));
help_tip_button.set_help_string( sgettext(button_labels[b] ));
//! @todo FIXME: Translatable string is here because we WILL put text in before 1.2!
gui::button beg_button(screen.video(),("Help Wesnoth"),button::TYPE_IMAGE,"menu-button",button::MINIMUM_SPACE);
beg_button.set_help_string(_("Help Wesnoth by sending us information"));
if(tips_of_day.empty()) {
tips_of_day = get_tips_of_day();
}
next_tip_of_day(tips_of_day);
surface_restorer tip_of_day_restorer;
draw_tip_of_day(screen, tips_of_day, ntip, gui::dialog_frame::titlescreen_style,
&next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style,
&previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
const int pad = game_config::title_tip_padding;
beg_button.set_location(screen.w() - pad - beg_button.location().w,
@ -414,13 +425,15 @@ TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip)
}
}
if(previous_tip_button.pressed()) {
next_tip_of_day(tips_of_day, true);
draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style,
&previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
}
if(next_tip_button.pressed()) {
if(ntip != NULL) {
*ntip = *ntip + 1;
}
draw_tip_of_day(screen, tips_of_day, ntip, gui::dialog_frame::titlescreen_style,
&next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
next_tip_of_day(tips_of_day, false);
draw_tip_of_day(screen, tips_of_day, gui::dialog_frame::titlescreen_style,
&previous_tip_button, &next_tip_button, &help_tip_button, &main_dialog_area, tip_of_day_restorer);
}
if(help_tip_button.pressed()) {
@ -445,7 +458,7 @@ TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip)
// If the resolution has changed due to the user resizing the screen,
// or from changing between windowed and fullscreen:
if(screen.video().modeChanged()) {
return TITLE_CONTINUE;
return TIP_NEXT;
}
screen.delay(20);

View file

@ -28,14 +28,14 @@ enum TITLE_RESULT { TUTORIAL = 0, //!< Start special campaign 'tutorial'
CHANGE_LANGUAGE, EDIT_PREFERENCES,
SHOW_ABOUT, //!< Show credits
QUIT_GAME,
TITLE_CONTINUE, //!< Show next tip-of-the-day
TIP_PREVIOUS, //!< Show previous tip-of-the-day
TIP_NEXT, //!< Show next tip-of-the-day
SHOW_HELP,
BEG_FOR_UPLOAD //!< Ask user for permission to upload game-stats as feedback
};
//! Show titlepage with logo & background, menu-buttons and tip-of-day.
TITLE_RESULT show_title(game_display& screen, config& tips_of_day, int* ntip);
TITLE_RESULT show_title(game_display& screen, config& tips_of_day);
}
#endif