Simplified code.
Fixed internationalization of selected terrain report.
This commit is contained in:
parent
3895801f1a
commit
02c47fc5b1
7 changed files with 29 additions and 48 deletions
|
@ -102,7 +102,6 @@ display::display(CVideo& video, const gamemap* map, const config& theme_cfg, con
|
|||
map_labels_(new map_labels(*this, 0)),
|
||||
scroll_event_("scrolled"),
|
||||
nextDraw_(0),
|
||||
report_(),
|
||||
buttons_(),
|
||||
invalidated_(),
|
||||
previous_invalidated_(),
|
||||
|
@ -2128,10 +2127,6 @@ void display::draw_image_for_report(surface& img, SDL_Rect& rect)
|
|||
}
|
||||
}
|
||||
|
||||
void display:: set_report_content(const reports::TYPE which_report, const std::string &content) {
|
||||
report_[which_report] = content;
|
||||
}
|
||||
|
||||
void display::refresh_report(reports::TYPE report_num, reports::report report)
|
||||
{
|
||||
const theme::status_item* const item = theme_.get_status_item(reports::report_name(report_num));
|
||||
|
|
|
@ -468,16 +468,6 @@ public:
|
|||
*/
|
||||
void redraw_minimap() { redrawMinimap_ = true; }
|
||||
|
||||
/**
|
||||
* Set what will be shown for the report with type which_report.
|
||||
* Note that this only works for some reports,
|
||||
* i.e. reports that can not be deducted
|
||||
* from the supplied arguments to generate_report,
|
||||
* currently: SELECTED_TERRAIN, EDIT_LEFT_BUTTON_FUNCTION
|
||||
*/
|
||||
void set_report_content(const reports::TYPE which_report, const std::string &content);
|
||||
std::map<reports::TYPE, std::string> get_report_contents() const {return report_;};
|
||||
|
||||
virtual const time_of_day get_time_of_day(const map_location& /*loc*/) const {return time_of_day();}
|
||||
|
||||
protected:
|
||||
|
@ -594,7 +584,6 @@ protected:
|
|||
SDL_Rect reportRects_[reports::NUM_REPORTS];
|
||||
surface reportSurfaces_[reports::NUM_REPORTS];
|
||||
reports::report reports_[reports::NUM_REPORTS];
|
||||
std::map<reports::TYPE, std::string> report_;
|
||||
std::vector<gui::button> buttons_;
|
||||
std::set<map_location> invalidated_;
|
||||
std::set<map_location> previous_invalidated_;
|
||||
|
|
|
@ -1184,6 +1184,8 @@ void editor_controller::fill_selection()
|
|||
perform_refresh(editor_action_paint_area(get_map().selection(), foreground_terrain_));
|
||||
}
|
||||
|
||||
std::string left_button_function;
|
||||
|
||||
void editor_controller::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
|
||||
{
|
||||
std::map<hotkey::HOTKEY_COMMAND, mouse_action*>::iterator i = mouse_actions_.find(command);
|
||||
|
@ -1191,8 +1193,7 @@ void editor_controller::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
|
|||
mouse_action_ = i->second;
|
||||
set_mouseover_overlay();
|
||||
redraw_toolbar();
|
||||
gui().set_report_content(reports::EDIT_LEFT_BUTTON_FUNCTION,
|
||||
hotkey::get_hotkey(command).get_description());
|
||||
left_button_function = hotkey::get_hotkey(command).get_description();
|
||||
gui().invalidate_game_status();
|
||||
} else {
|
||||
ERR_ED << "Invalid hotkey command ("
|
||||
|
|
|
@ -532,12 +532,14 @@ int terrain_palette::tile_selected(const int x, const int y) const {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void terrain_palette::update_report() {
|
||||
const std::string msg = std::string(_("FG")) + ": "
|
||||
+ get_terrain_string(selected_fg_terrain()) + "\n"
|
||||
+ std::string(_("BG")) +
|
||||
": " + get_terrain_string(selected_bg_terrain());
|
||||
gui_.set_report_content(reports::SELECTED_TERRAIN, msg);
|
||||
std::string selected_terrain;
|
||||
|
||||
void terrain_palette::update_report()
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << _("FG: ") << get_terrain_string(selected_fg_terrain())
|
||||
<< '\n' << _("BG: ") << get_terrain_string(selected_bg_terrain());
|
||||
selected_terrain = msg.str();
|
||||
}
|
||||
|
||||
void terrain_palette::load_tooltips()
|
||||
|
|
|
@ -420,10 +420,9 @@ void game_display::draw_report(reports::TYPE report_num)
|
|||
return;
|
||||
}
|
||||
|
||||
reports::report report = reports::generate_report(report_num, report_,
|
||||
teams_[viewing_team()],
|
||||
size_t(currentTeam_+1),size_t(activeTeam_+1),
|
||||
selectedHex_, mouseoverHex_, displayedUnitHex_,
|
||||
reports::report report = reports::generate_report(report_num,
|
||||
teams_[viewing_team()], currentTeam_ + 1, activeTeam_ + 1,
|
||||
selectedHex_, mouseoverHex_, displayedUnitHex_,
|
||||
observers_, level_, !viewpoint_);
|
||||
|
||||
refresh_report(report_num, report);
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
namespace editor {
|
||||
extern std::string selected_terrain, left_button_function;
|
||||
}
|
||||
|
||||
namespace reports {
|
||||
|
||||
static void add_status(report &r,
|
||||
|
@ -56,7 +60,6 @@ static std::string flush(std::ostringstream &s)
|
|||
static char const *naps = "</span>";
|
||||
|
||||
report generate_report(TYPE type,
|
||||
const std::map<reports::TYPE, std::string> &report_contents,
|
||||
const team ¤t_team, int current_side, int playing_side,
|
||||
const map_location& loc, const map_location& mouseover, const map_location& displayed_unit_hex,
|
||||
const std::set<std::string> &observers,
|
||||
|
@ -688,25 +691,17 @@ report generate_report(TYPE type,
|
|||
|
||||
return report("",game_config::observer_image,str.str());
|
||||
}
|
||||
case SELECTED_TERRAIN: {
|
||||
std::map<TYPE, std::string>::const_iterator it =
|
||||
report_contents.find(SELECTED_TERRAIN);
|
||||
if (it != report_contents.end()) {
|
||||
return report(it->second);
|
||||
}
|
||||
else {
|
||||
case EDITOR_SELECTED_TERRAIN: {
|
||||
if (editor::selected_terrain.empty())
|
||||
return report();
|
||||
}
|
||||
else
|
||||
return report(editor::selected_terrain);
|
||||
}
|
||||
case EDIT_LEFT_BUTTON_FUNCTION: {
|
||||
std::map<TYPE, std::string>::const_iterator it =
|
||||
report_contents.find(EDIT_LEFT_BUTTON_FUNCTION);
|
||||
if (it != report_contents.end()) {
|
||||
return report(it->second);
|
||||
}
|
||||
else {
|
||||
case EDITOR_LEFT_BUTTON_FUNCTION: {
|
||||
if (editor::left_button_function.empty())
|
||||
return report();
|
||||
}
|
||||
else
|
||||
return report(editor::left_button_function);
|
||||
}
|
||||
case REPORT_COUNTDOWN: {
|
||||
int min;
|
||||
|
|
|
@ -33,8 +33,9 @@ namespace reports {
|
|||
UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
|
||||
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES,
|
||||
INCOME, TERRAIN, POSITION, SIDE_PLAYING, OBSERVERS,
|
||||
REPORT_COUNTDOWN, REPORT_CLOCK, SELECTED_TERRAIN,
|
||||
EDIT_LEFT_BUTTON_FUNCTION, EDITOR_TOOL_HINT, NUM_REPORTS};
|
||||
REPORT_COUNTDOWN, REPORT_CLOCK, EDITOR_SELECTED_TERRAIN,
|
||||
EDITOR_LEFT_BUTTON_FUNCTION, EDITOR_TOOL_HINT, NUM_REPORTS
|
||||
};
|
||||
|
||||
enum { UNIT_REPORTS_BEGIN=UNIT_NAME, UNIT_REPORTS_END=UNIT_PROFILE+1 };
|
||||
enum { STATUS_REPORTS_BEGIN=TIME_OF_DAY, STATUS_REPORTS_END=EDITOR_TOOL_HINT };
|
||||
|
@ -94,7 +95,6 @@ namespace reports {
|
|||
};
|
||||
|
||||
report generate_report(TYPE type,
|
||||
const std::map<reports::TYPE, std::string> &report_contents,
|
||||
const team ¤t_team,
|
||||
int current_side, int active_side,
|
||||
const map_location& loc, const map_location& mouseover, const map_location& displayed_unit_hex,
|
||||
|
|
Loading…
Add table
Reference in a new issue