00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EDITOR_PALETTES_H_INCLUDED
00019 #define EDITOR_PALETTES_H_INCLUDED
00020
00021 #include "global.hpp"
00022
00023 #include "SDL.h"
00024
00025 #include "../sdl_utils.hpp"
00026 #include "../display.hpp"
00027 #include "../map.hpp"
00028 #include "../widgets/widget.hpp"
00029 #include "editor_layout.hpp"
00030
00031 #include <vector>
00032
00033 class config;
00034
00035 namespace map_editor {
00036
00037
00038
00039 struct terrain_group
00040 {
00041 terrain_group(const config& cfg, display& gui);
00042
00043 std::string id;
00044 t_string name;
00045 gui::button button;
00046 };
00047
00048
00049 class terrain_palette : public gui::widget {
00050 public:
00051 terrain_palette(display &gui, const size_specs &sizes,
00052 const gamemap &map, const config& cfg);
00053
00054
00055 void scroll_up();
00056
00057
00058 void scroll_down();
00059
00060
00061 void scroll_top();
00062
00063
00064 void scroll_bottom();
00065
00066
00067
00068
00069 void set_group(const std::string& id);
00070
00071
00072 t_translation::t_terrain selected_fg_terrain() const;
00073
00074 t_translation::t_terrain selected_bg_terrain() const;
00075
00076
00077 void select_fg_terrain(t_translation::t_terrain);
00078 void select_bg_terrain(t_translation::t_terrain);
00079
00080
00081 void update_selected_terrains(void);
00082
00083
00084
00085
00086 void draw(bool force=false);
00087 virtual void draw();
00088 virtual void handle_event(const SDL_Event& event);
00089 void set_dirty(bool dirty=true);
00090
00091
00092 size_t num_terrains() const;
00093
00094
00095
00096 void adjust_size();
00097
00098
00099 void load_tooltips();
00100
00101 private:
00102 void draw_old(bool);
00103
00104
00105
00106 void left_mouse_click(const int mousex, const int mousey);
00107 void right_mouse_click(const int mousex, const int mousey);
00108
00109
00110
00111 int tile_selected(const int x, const int y) const;
00112
00113
00114 std::string get_terrain_string(const t_translation::t_terrain);
00115
00116
00117 void update_report();
00118
00119 const size_specs &size_specs_;
00120 display &gui_;
00121 unsigned int tstart_;
00122
00123
00124
00125
00126
00127 std::map<std::string, t_translation::t_list> terrain_map_;
00128
00129
00130 t_translation::t_list terrains_;
00131
00132
00133
00134
00135 std::vector<terrain_group> terrain_groups_;
00136
00137
00138
00139
00140 gui::button *checked_group_btn_;
00141
00142 t_translation::t_terrain selected_fg_terrain_, selected_bg_terrain_;
00143 const gamemap &map_;
00144 gui::button top_button_, bot_button_;
00145 size_t button_x_, top_button_y_, bot_button_y_;
00146 size_t nterrains_, terrain_start_;
00147 };
00148
00149
00150 class brush_bar : public gui::widget {
00151 public:
00152 brush_bar(display &gui, const size_specs &sizes);
00153
00154
00155 unsigned int selected_brush_size();
00156
00157
00158 void select_brush_size(int new_size);
00159
00160
00161
00162 void draw(bool force=false);
00163 virtual void draw();
00164 virtual void handle_event(const SDL_Event& event);
00165
00166
00167
00168 void adjust_size();
00169
00170 private:
00171
00172
00173
00174 void left_mouse_click(const int mousex, const int mousey);
00175
00176
00177 int selected_index(const int x, const int y) const;
00178
00179 const size_specs &size_specs_;
00180 display &gui_;
00181 unsigned int selected_;
00182 const int total_brush_;
00183 const size_t size_;
00184 };
00185
00186
00187 }
00188 #endif // EDITOR_PALETTES_H_INCLUDED
00189