editor/editor_display.cpp

Go to the documentation of this file.
00001 /* $Id: editor_display.cpp 53726 2012-03-31 18:16:27Z fendrin $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Tomasz Sniatowski <kailoran@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #define GETTEXT_DOMAIN "wesnoth-editor"
00016 
00017 #include "editor_display.hpp"
00018 #include "builder.hpp"
00019 
00020 namespace editor {
00021 
00022 editor_display::editor_display(unit_map* units, CVideo& video, const editor_map* map,
00023         const std::vector<team>* t, const config& theme_cfg, const config& level)
00024     : display(units, video, map, t, theme_cfg, level)
00025     , brush_locations_()
00026     , toolbar_hint_()
00027     , palette_report_()
00028 {
00029     clear_screen();
00030 }
00031 
00032 void editor_display::add_brush_loc(const map_location& hex)
00033 {
00034     brush_locations_.insert(hex);
00035     invalidate(hex);
00036 }
00037 
00038 void editor_display::set_brush_locs(const std::set<map_location>& hexes)
00039 {
00040     invalidate(brush_locations_);
00041     brush_locations_ = hexes;
00042     invalidate(brush_locations_);
00043 }
00044 
00045 void editor_display::clear_brush_locs()
00046 {
00047     invalidate(brush_locations_);
00048     brush_locations_.clear();
00049 }
00050 
00051 void editor_display::remove_brush_loc(const map_location& hex)
00052 {
00053     brush_locations_.erase(hex);
00054     invalidate(hex);
00055 }
00056 
00057 void editor_display::rebuild_terrain(const map_location &loc) {
00058     builder_->rebuild_terrain(loc);
00059 }
00060 
00061 void editor_display::pre_draw()
00062 {
00063 }
00064 
00065 image::TYPE editor_display::get_image_type(const map_location& loc)
00066 {
00067     if (map().in_selection(loc)) {
00068         return image::BRIGHTENED;
00069     }
00070     return image::TOD_COLORED;
00071 }
00072 
00073 void editor_display::draw_hex(const map_location& loc)
00074 {
00075     int xpos = get_location_x(loc);
00076     int ypos = get_location_y(loc);
00077     display::draw_hex(loc);
00078     if (map().on_board_with_border(loc)) {
00079         if (map().in_selection(loc)) {
00080             drawing_buffer_add(LAYER_FOG_SHROUD, loc, xpos, ypos,
00081                 image::get_image("editor/selection-overlay.png", image::TOD_COLORED));
00082         }
00083 
00084         if (brush_locations_.find(loc) != brush_locations_.end()) {
00085             static const image::locator brush(game_config::images::editor_brush);
00086             drawing_buffer_add(LAYER_SELECTED_HEX, loc, xpos, ypos,
00087                     image::get_image(brush, image::SCALED_TO_HEX));
00088         }
00089         if (map().on_board(loc) && loc == mouseoverHex_) {
00090             drawing_buffer_add(LAYER_MOUSEOVER_BOTTOM, loc, xpos, ypos,
00091                     image::get_image("misc/hover-hex.png", image::SCALED_TO_HEX));
00092         }
00093     }
00094 }
00095 
00096 const SDL_Rect& editor_display::get_clip_rect()
00097 {
00098     return map_outside_area();
00099 }
00100 
00101 void editor_display::draw_sidebar()
00102 {
00103     config element;
00104     config::attribute_value &text = element.add_child("element")["text"];
00105     // Fill in the terrain report
00106     if (get_map().on_board_with_border(mouseoverHex_)) {
00107         text = get_map().get_terrain_editor_string(mouseoverHex_);
00108         refresh_report("terrain", element);
00109         text = str_cast(mouseoverHex_);
00110         refresh_report("position", element);
00111     }
00112     text = int(get_map().villages().size());
00113     refresh_report("villages", element);
00114     text = toolbar_hint_;
00115     refresh_report("editor_tool_hint", element);
00116 
00117     refresh_report("terrain_image", palette_report_);
00118 }
00119 
00120 } //end namespace editor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:34 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs