Moved tips of the day from english.cfg to their own tips.cfg file.

This commit is contained in:
Cédric Duval 2004-10-31 00:31:59 +00:00
parent 7f4fc5ed32
commit 5e8c0d7ef0
5 changed files with 68 additions and 52 deletions

32
data/tips.cfg Normal file
View file

@ -0,0 +1,32 @@
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 holy. 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 on 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 'cure' ability."
tip_of_day6= _ "You can use units from a previous scenario by selecting 'Recall' by the game menu. By recalling the same units over and over, you can build up a powerful and experienced army."
tip_of_day7= _ "All 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."
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 always have a 70% chance to hit, and marksman attacks have at least 60% chance to hit."
tip_of_day9= _ "Units stationed in villages heal 8 hitpoints at the beginning of their turn."
tip_of_day10= _ "Units that do not move or attack during their turn rest, and 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 holy 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, but it also gives them one less attack than they would normally have. It is thus very effective against units that have a few powerful attacks."
tip_of_day30= _ "Holy 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."

View file

@ -144,37 +144,5 @@ village_name_mountain= _ "$name|ham,$name|bury,$name|ton,$name|mont,$name|mont,$
show_next_tip= _ "Next tip"
tip_of_day= _ "Tip of the Day"
no_tip_of_day= _ "Do not show tips"
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 holy. 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 on 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 'cure' ability."
tip_of_day6= _ "You can use units from a previous scenario by selecting 'Recall' by the game menu. By recalling the same units over and over, you can build up a powerful and experienced army."
tip_of_day7= _ "All 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."
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 always have a 70% chance to hit, and marksman attacks have at least 60% chance to hit."
tip_of_day9= _ "Units stationed in villages heal 8 hitpoints at the beginning of their turn."
tip_of_day10= _ "Units that do not move or attack during their turn rest, and 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 holy 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, but it also gives them one less attack than they would normally have. It is thus very effective against units that have a few powerful attacks."
tip_of_day30= _ "Holy 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."
[/language]

View file

@ -1481,9 +1481,11 @@ int play_game(int argc, char** argv)
gui::TITLE_RESULT res = game.is_loading() ? gui::LOAD_GAME : gui::TITLE_CONTINUE;
int ntip = -1;
config tips_of_day;
while(res == gui::TITLE_CONTINUE) {
res = gui::show_title(game.disp(),&ntip);
res = gui::show_title(game.disp(),tips_of_day,&ntip);
}
tips_of_day.clear();
std::cerr << "title screen returned result\n";
if(res == gui::QUIT_GAME) {

View file

@ -1,3 +1,4 @@
#include "config.hpp"
#include "cursor.hpp"
#include "display.hpp"
#include "events.hpp"
@ -81,49 +82,59 @@ void fade_logo(display& screen, int xpos, int ypos)
faded_in = true;
}
const std::string& get_tip_of_day(int* ntip)
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 = 0;
/*
It is probably the only part of the code where it makes sense for string_table
to send back an empty string. So let's avoid this problem while the "UNTBL" hack
is in effect. -- silene
while(ntips < 1000 && string_table["tip_of_day" + str_cast(ntips+1)] != "") {
*/
while(ntips < 1000 && string_table["tip_of_day" + str_cast(ntips+1)].substr(0, 5) != "UNTLB") {
++ntips;
}
int ntips = tips.values.size();
if(ntips == 0) {
return empty_string;
}
if(ntip != NULL && *ntip > 0) {
if(*ntip > ntips) {
if(*ntip >= ntips) {
*ntip -= ntips;
}
return string_table["tip_of_day" + str_cast(*ntip)];
it = tips.values.begin();
for(int i = 0; i < *ntip; i++,it++);
return it->second;
}
const int tip = (rand()%ntips) + 1;
const int tip = (rand()%ntips);
if(ntip != NULL) {
*ntip = tip;
}
return string_table["tip_of_day" + str_cast(tip)];
it = tips.values.begin();
for(int i = 0; i < tip; i++,it++);
return it->second;
}
const config get_tips_of_day()
{
config cfg;
std::cerr << "Loading tips of day\n";
try {
cfg.read(preprocess_file("data/tips.cfg"));
} catch(config::error& e) {
std::cerr << "Could not read tips.cfg\n";
}
return cfg;
}
} //end anonymous namespace
namespace gui {
TITLE_RESULT show_title(display& screen, int* ntip)
TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip)
{
cursor::set(cursor::NORMAL);
@ -211,7 +222,10 @@ TITLE_RESULT show_title(display& screen, int* ntip)
gui::button next_tip_button(screen,_("More"),button::TYPE_PRESS,"lite_small");
std::string tip_of_day = get_tip_of_day(ntip);
if(tips_of_day.empty()) {
tips_of_day = get_tips_of_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.x())/1024);

View file

@ -8,7 +8,7 @@ namespace gui {
enum TITLE_RESULT { TUTORIAL = 0, NEW_CAMPAIGN, MULTIPLAYER, LOAD_GAME,
CHANGE_LANGUAGE, EDIT_PREFERENCES, SHOW_ABOUT, QUIT_GAME, TITLE_CONTINUE };
TITLE_RESULT show_title(display& screen, int* ntip);
TITLE_RESULT show_title(display& screen, config& tips_of_day, int* ntip);
}