Editor: The name of the currently selected terrain is now displayed.
This commit is contained in:
parent
936a4eb18c
commit
451757d32e
5 changed files with 73 additions and 5 deletions
|
@ -219,6 +219,13 @@ height=600
|
|||
xanchor=proportional
|
||||
yanchor=fixed
|
||||
[/position]
|
||||
|
||||
[selected_terrain]
|
||||
font_size=12
|
||||
rect=900,736,1024,20
|
||||
xanchor=right
|
||||
yanchor=bottom
|
||||
[/selected_terrain]
|
||||
[/status]
|
||||
|
||||
[/resolution]
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace {
|
|||
const double dist = std::sqrt(xdiff * xdiff + ydiff * ydiff);
|
||||
return dist;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace map_editor {
|
||||
|
@ -91,6 +92,10 @@ map_editor::map_editor(display &gui, gamemap &map, config &theme, config &game_c
|
|||
hotkey::get_hotkeys().clear();
|
||||
hotkey::add_hotkeys(theme_, true);
|
||||
recalculate_starting_pos_labels();
|
||||
|
||||
reports::set_report_content(reports::SELECTED_TERRAIN,
|
||||
get_terrain_string(palette_.selected_terrain()));
|
||||
gui_.invalidate_all();
|
||||
}
|
||||
|
||||
void map_editor::handle_event(const SDL_Event &event) {
|
||||
|
@ -118,6 +123,26 @@ void map_editor::handle_keyboard_event(const SDL_KeyboardEvent &event,
|
|||
}
|
||||
}
|
||||
|
||||
std::string map_editor::get_terrain_string(const gamemap::TERRAIN t) {
|
||||
std::stringstream str;
|
||||
const std::string& name = map_.terrain_name(t);
|
||||
const std::vector<std::string>& underlying_names =
|
||||
map_.underlying_terrain_name(t);
|
||||
str << translate_string(name);
|
||||
if(underlying_names.size() != 1 || underlying_names.front() != name) {
|
||||
str << " (";
|
||||
for(std::vector<std::string>::const_iterator i = underlying_names.begin();
|
||||
i != underlying_names.end(); ++i) {
|
||||
str << translate_string(*i);
|
||||
if(i+1 != underlying_names.end()) {
|
||||
str << ",";
|
||||
}
|
||||
}
|
||||
str << ")";
|
||||
}
|
||||
return str.str();
|
||||
}
|
||||
|
||||
void map_editor::handle_mouse_button_event(const SDL_MouseButtonEvent &event,
|
||||
const int mousex, const int mousey) {
|
||||
if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||
|
@ -161,7 +186,13 @@ void map_editor::handle_mouse_button_event(const SDL_MouseButtonEvent &event,
|
|||
}
|
||||
}
|
||||
else {
|
||||
const gamemap::TERRAIN old_tr = palette_.selected_terrain();
|
||||
palette_.left_mouse_click(mousex, mousey);
|
||||
if (palette_.selected_terrain() != old_tr) {
|
||||
reports::set_report_content(reports::SELECTED_TERRAIN,
|
||||
get_terrain_string(palette_.selected_terrain()));
|
||||
gui_.invalidate_game_status();
|
||||
}
|
||||
brush_.left_mouse_click(mousex, mousey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
|
||||
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
||||
// Exception thrown when new map is to be loaded.
|
||||
/// Exception thrown when new map is to be loaded.
|
||||
struct new_map_exception {
|
||||
new_map_exception(const std::string &map, const std::string filename="")
|
||||
: new_map(map), new_filename(filename) {}
|
||||
|
@ -218,6 +218,13 @@ private:
|
|||
/// Commit the movement of a selection.
|
||||
void perform_selection_move();
|
||||
|
||||
/// Return a string represeting the terrain and the underlying ones.
|
||||
std::string get_terrain_string(const gamemap::TERRAIN);
|
||||
|
||||
/// An item in the clipboard. Consists of the copied terrain and an
|
||||
/// offset. When pasting stuff, the offset is used to calculate
|
||||
/// where to put the pasted hex when calculating from the one
|
||||
/// selected when the paste takes place.
|
||||
struct clipboard_item {
|
||||
clipboard_item(int xo, int yo, gamemap::TERRAIN t) :
|
||||
x_offset(xo), y_offset(yo), terrain(t) {}
|
||||
|
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
namespace {
|
||||
const std::string report_names[] = { "unit_description", "unit_type", "unit_level",
|
||||
"unit_traits","unit_status","unit_alignment","unit_abilities","unit_hp","unit_xp",
|
||||
"unit_moves","unit_weapons","unit_image","unit_profile","time_of_day",
|
||||
"turn","gold","villages","num_units","upkeep", "expenses",
|
||||
"income", "terrain", "position", "side_playing", "observers" };
|
||||
"income", "terrain", "position", "side_playing", "observers", "selected_terrain"};
|
||||
std::map<reports::TYPE, std::string> report_contents;
|
||||
}
|
||||
|
||||
namespace reports {
|
||||
|
@ -323,10 +325,25 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
|||
|
||||
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 {
|
||||
return report();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return report(str.str());
|
||||
}
|
||||
|
||||
|
||||
void set_report_content(const TYPE which_report, const std::string &content) {
|
||||
report_contents[which_report] = content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace reports {
|
|||
UNIT_ALIGNMENT, UNIT_ABILITIES, UNIT_HP, UNIT_XP, UNIT_MOVES, UNIT_WEAPONS,
|
||||
UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
|
||||
TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES, INCOME, TERRAIN, POSITION,
|
||||
SIDE_PLAYING, OBSERVERS, NUM_REPORTS};
|
||||
SIDE_PLAYING, OBSERVERS, SELECTED_TERRAIN, NUM_REPORTS};
|
||||
|
||||
enum { UNIT_REPORTS_BEGIN=UNIT_DESCRIPTION, UNIT_REPORTS_END=UNIT_PROFILE+1 };
|
||||
enum { STATUS_REPORTS_BEGIN=TIME_OF_DAY, STATUS_REPORTS_END=NUM_REPORTS};
|
||||
|
@ -64,6 +64,12 @@ namespace reports {
|
|||
const gamemap::location& loc, const gamemap::location& mouseover,
|
||||
const gamestatus& status, const std::set<std::string>& observers,
|
||||
const std::string* format_string=NULL);
|
||||
// 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
|
||||
void set_report_content(const TYPE which_report, const std::string &content);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue