The palette is now a part of theme WML...
...instead of being placed at hardcoded coordinates. Windows and Mac build systems still have to be adjusted.
This commit is contained in:
parent
58d28e3f09
commit
a68f0ca12b
17 changed files with 46 additions and 193 deletions
|
@ -649,7 +649,6 @@ set(wesnoth-main_SRC
|
|||
editor/toolkit/brush.cpp
|
||||
editor/toolkit/brush_bar.cpp
|
||||
editor/palette/editor_palettes.cpp
|
||||
editor/palette/palette_layout.cpp
|
||||
editor/palette/terrain_palettes.cpp
|
||||
editor/palette/unit_palette.cpp
|
||||
editor/editor_controller.cpp
|
||||
|
|
|
@ -229,7 +229,6 @@ wesnoth_sources = Split("""
|
|||
editor/palette/editor_palettes.cpp
|
||||
editor/palette/terrain_palettes.cpp
|
||||
editor/palette/unit_palette.cpp
|
||||
editor/palette/palette_layout.cpp
|
||||
editor/palette/palette_manager.cpp
|
||||
editor/toolkit/brush.cpp
|
||||
editor/toolkit/brush_bar.cpp
|
||||
|
|
|
@ -166,6 +166,8 @@ public:
|
|||
int h() const { return screen_.gety(); } /**< height */
|
||||
const SDL_Rect& minimap_area() const
|
||||
{ return theme_.mini_map_location(screen_area()); }
|
||||
const SDL_Rect& palette_area() const
|
||||
{ return theme_.palette_location(screen_area()); }
|
||||
const SDL_Rect& unit_image_area() const
|
||||
{ return theme_.unit_image_location(screen_area()); }
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
#define COMMON_PALETTES_H_INCLUDED
|
||||
|
||||
#include "config.hpp"
|
||||
#include "palette_layout.hpp"
|
||||
|
||||
class SDL_Rect;
|
||||
|
||||
namespace editor {
|
||||
|
||||
|
@ -54,7 +55,7 @@ public:
|
|||
virtual bool scroll_down() = 0;
|
||||
|
||||
//drawing
|
||||
virtual void adjust_size(const size_specs& size) = 0;
|
||||
virtual void adjust_size(const SDL_Rect& target) = 0;
|
||||
virtual void draw(bool) = 0;
|
||||
|
||||
//group
|
||||
|
|
|
@ -192,19 +192,19 @@ template const config editor_palette<unit_type>::active_group_report();
|
|||
//template const config editor_palette<void*>::active_group_report();
|
||||
|
||||
template<class Item>
|
||||
void editor_palette<Item>::adjust_size(const size_specs& size)
|
||||
void editor_palette<Item>::adjust_size(const SDL_Rect& target)
|
||||
{
|
||||
palette_x_ = size.palette_x;
|
||||
palette_y_ = size.palette_y;
|
||||
const size_t space_for_items = size.palette_h;
|
||||
palette_x_ = target.x;
|
||||
palette_y_ = target.y;
|
||||
const size_t space_for_items = target.h;
|
||||
const unsigned items_fitting =
|
||||
static_cast<unsigned> (space_for_items / item_space_) *
|
||||
item_width_;
|
||||
nitems_ = std::min<int>(items_fitting, nmax_items_);
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::adjust_size(const size_specs& size);
|
||||
template void editor_palette<unit_type>::adjust_size(const size_specs& size);
|
||||
//template void editor_palette<void*>::adjust_size(const size_specs& size);
|
||||
template void editor_palette<t_translation::t_terrain>::adjust_size(const SDL_Rect& target);
|
||||
template void editor_palette<unit_type>::adjust_size(const SDL_Rect& target);
|
||||
//template void editor_palette<void*>::adjust_size(const SDL_Rect& target);
|
||||
|
||||
template<class Item>
|
||||
void editor_palette<Item>::select_fg_item(std::string item_id)
|
||||
|
@ -319,7 +319,7 @@ template<class Item>
|
|||
int editor_palette<Item>::tile_selected(const int x, const int y) const
|
||||
{
|
||||
for(unsigned int i = 0; i != nitems_; i++) {
|
||||
const int px = size_specs_.palette_x + (i % item_width_) * item_space_;
|
||||
const int px = palette_x_ + (i % item_width_) * item_space_;
|
||||
const int py = palette_y_ + (i / item_width_) * item_space_;
|
||||
const int pw = item_space_;
|
||||
const int ph = item_space_;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define EDITOR_PALETTES_H_INCLUDED
|
||||
|
||||
#include "../editor_display.hpp"
|
||||
#include "palette_layout.hpp"
|
||||
#include "common_palette.hpp"
|
||||
|
||||
namespace editor {
|
||||
|
@ -27,16 +26,15 @@ class editor_palette : public common_palette {
|
|||
|
||||
public:
|
||||
|
||||
editor_palette(editor_display &gui, const size_specs &sizes, const config& /*cfg*/
|
||||
editor_palette(editor_display &gui, const config& /*cfg*/
|
||||
, size_t item_size, size_t item_width, mouse_action** active_mouse_action)
|
||||
: groups_()
|
||||
, gui_(gui)
|
||||
, size_specs_(sizes)
|
||||
, item_size_(item_size)
|
||||
, item_width_(item_width)
|
||||
, item_space_(item_size + 3)
|
||||
, palette_y_(sizes.palette_y)
|
||||
, palette_x_(sizes.palette_x)
|
||||
, palette_y_(0)
|
||||
, palette_x_(0)
|
||||
, group_map_()
|
||||
, item_map_()
|
||||
, nitems_(0)
|
||||
|
@ -78,7 +76,7 @@ public:
|
|||
*
|
||||
* Use if the size_specs have changed.
|
||||
*/
|
||||
void adjust_size(const size_specs& size);
|
||||
void adjust_size(const SDL_Rect& target);
|
||||
|
||||
virtual bool scroll_up();
|
||||
virtual bool scroll_down();
|
||||
|
@ -142,7 +140,6 @@ protected:
|
|||
std::vector<item_group> groups_;
|
||||
|
||||
editor_display &gui_;
|
||||
const size_specs &size_specs_;
|
||||
|
||||
int item_size_;
|
||||
int item_width_;
|
||||
|
|
|
@ -29,9 +29,9 @@ namespace editor {
|
|||
class empty_palette : public editor_palette<unit_type> {
|
||||
public:
|
||||
|
||||
empty_palette(editor_display &gui, const size_specs &sizes, const config& cfg,
|
||||
empty_palette(editor_display &gui, const config& cfg,
|
||||
mouse_action** active_mouse_action)
|
||||
: editor_palette<unit_type>(gui, sizes, cfg, 0, 0, active_mouse_action) {};
|
||||
: editor_palette<unit_type>(gui, cfg, 0, 0, active_mouse_action) {};
|
||||
|
||||
// think about removing it
|
||||
virtual void setup(const config& /*cfg*/) {};
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-editor"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Set various sizes for the screen-layout of the map editor.
|
||||
*/
|
||||
|
||||
#include "palette_layout.hpp"
|
||||
|
||||
#include "display.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
const size_t default_terrain_size = 36;
|
||||
const size_t default_terrain_width = 4;
|
||||
const size_t default_brush_width = 4;
|
||||
}
|
||||
|
||||
namespace editor {
|
||||
|
||||
size_specs::size_specs()
|
||||
: palette_x(0)
|
||||
, palette_y(0)
|
||||
, palette_h(20)
|
||||
, palette_w(10)
|
||||
, brush_x(0)
|
||||
, brush_y(0)
|
||||
, brush_padding(1)
|
||||
, brush_width(default_brush_width)
|
||||
{
|
||||
}
|
||||
|
||||
void adjust_sizes(const display &disp, size_specs &sizes) {
|
||||
/** @todo Hardcoded coordinates for brush selection, make them themeable. */
|
||||
sizes.brush_x = disp.map_outside_area().w + 12;
|
||||
sizes.brush_y = (disp.h() >= 768) ? 340 : 270;
|
||||
/** @todo Hardcoded coordinates for terrain palette, make them themeable. */
|
||||
sizes.palette_x = disp.map_outside_area().w + 12;
|
||||
sizes.palette_y = sizes.brush_y + 33;
|
||||
sizes.palette_w = 174; // sizes.terrain_space * sizes.terrain_width;
|
||||
sizes.palette_h = disp.h() - sizes.palette_y;
|
||||
}
|
||||
|
||||
} // end namespace editor
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2003 - 2012 by David White <dave@whitevine.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifndef EDITOR_LAYOUT_H_INCLUDED
|
||||
#define EDITOR_LAYOUT_H_INCLUDED
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
class display;
|
||||
|
||||
namespace editor {
|
||||
|
||||
/** Size specifications for the map editor. */
|
||||
struct size_specs {
|
||||
/**
|
||||
* Initialize the values to dummy-values that will avoid floating point
|
||||
* errors if calculations are made before the sizes are adjusted through
|
||||
* adjust_sizes().
|
||||
*/
|
||||
size_specs();
|
||||
size_t palette_x;
|
||||
size_t palette_y;
|
||||
size_t palette_h;
|
||||
size_t palette_w;
|
||||
size_t brush_x;
|
||||
size_t brush_y;
|
||||
size_t brush_padding;
|
||||
size_t brush_width;
|
||||
};
|
||||
|
||||
/** Adjust the internal size specifications to fit the display. */
|
||||
void adjust_sizes(const display &disp, size_specs &sizes);//, size_t item_size, size_t item_width);
|
||||
|
||||
}
|
||||
|
||||
#endif // EDITOR_LAYOUT_H_INCLUDED
|
|
@ -23,16 +23,15 @@
|
|||
|
||||
namespace editor {
|
||||
|
||||
palette_manager::palette_manager(editor_display& gui, const size_specs &sizes, const config& cfg
|
||||
palette_manager::palette_manager(editor_display& gui, const config& cfg
|
||||
, mouse_action** active_mouse_action)
|
||||
: gui::widget(gui.video()),
|
||||
gui_(gui),
|
||||
size_specs_(sizes),
|
||||
palette_start_(sizes.palette_y),
|
||||
palette_start_(0),
|
||||
mouse_action_(active_mouse_action),
|
||||
terrain_palette_(new terrain_palette(gui, sizes, cfg, active_mouse_action)),
|
||||
unit_palette_(new unit_palette(gui,sizes,cfg,active_mouse_action)),
|
||||
empty_palette_(new empty_palette(gui,sizes,cfg,active_mouse_action))
|
||||
terrain_palette_(new terrain_palette(gui, cfg, active_mouse_action)),
|
||||
unit_palette_(new unit_palette(gui, cfg, active_mouse_action)),
|
||||
empty_palette_(new empty_palette(gui, cfg, active_mouse_action))
|
||||
{
|
||||
unit_palette_->setup(cfg);
|
||||
terrain_palette_->setup(cfg);
|
||||
|
@ -47,17 +46,11 @@ void palette_manager::set_group(size_t index)
|
|||
void palette_manager::adjust_size()
|
||||
{
|
||||
scroll_top();
|
||||
|
||||
SDL_Rect rect = create_rect(size_specs_.palette_x
|
||||
, size_specs_.palette_y
|
||||
, size_specs_.palette_w
|
||||
, size_specs_.palette_h);
|
||||
|
||||
const SDL_Rect& rect = gui_.palette_area();
|
||||
set_location(rect);
|
||||
palette_start_ = size_specs_.palette_y;
|
||||
|
||||
palette_start_ = rect.y;
|
||||
bg_register(rect);
|
||||
active_palette().adjust_size(size_specs_);
|
||||
active_palette().adjust_size(rect);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
|
@ -67,11 +60,7 @@ void palette_manager::scroll_down()
|
|||
|
||||
if (scrolled) {
|
||||
|
||||
SDL_Rect rect = create_rect(size_specs_.palette_x
|
||||
, size_specs_.palette_y
|
||||
, size_specs_.palette_w
|
||||
, size_specs_.palette_h);
|
||||
|
||||
const SDL_Rect& rect = gui_.palette_area();
|
||||
bg_restore(rect);
|
||||
set_dirty();
|
||||
}
|
||||
|
@ -81,12 +70,7 @@ void palette_manager::scroll_up()
|
|||
{
|
||||
bool scrolled_up = active_palette().scroll_up();
|
||||
if(scrolled_up) {
|
||||
|
||||
SDL_Rect rect = create_rect(size_specs_.palette_x
|
||||
, size_specs_.palette_y
|
||||
, size_specs_.palette_w
|
||||
, size_specs_.palette_h);
|
||||
|
||||
const SDL_Rect rect = gui_.palette_area();
|
||||
bg_restore(rect);
|
||||
set_dirty();
|
||||
}
|
||||
|
@ -94,11 +78,7 @@ void palette_manager::scroll_up()
|
|||
|
||||
void palette_manager::scroll_top()
|
||||
{
|
||||
SDL_Rect rect = create_rect(size_specs_.palette_x
|
||||
, size_specs_.palette_y
|
||||
, size_specs_.palette_w
|
||||
, size_specs_.palette_h);
|
||||
|
||||
const SDL_Rect rect = gui_.palette_area();
|
||||
active_palette().set_start_item(0);
|
||||
bg_restore(rect);
|
||||
set_dirty();
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
//palette_manager();
|
||||
|
||||
palette_manager(editor_display &gui, const size_specs &sizes, const config& cfg
|
||||
palette_manager(editor_display &gui, const config& cfg
|
||||
, mouse_action** active_mouse_action);
|
||||
|
||||
void set_group(size_t index);
|
||||
|
@ -80,12 +80,14 @@ public:
|
|||
void right_mouse_click(const int mousex, const int mousey);
|
||||
|
||||
/** Return the number of the tile that is at coordinates (x, y) in the panel. */
|
||||
//TODO
|
||||
// int tile_selected(const int x, const int y) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
common_palette& active_palette(); //{ return (*mouse_action_)->get_palette(); };
|
||||
common_palette& active_palette();
|
||||
//TODO { return (*mouse_action_)->get_palette(); };
|
||||
|
||||
//TODO
|
||||
// terrain_palette* terrain_palette() { return terrain_palette_; };
|
||||
|
@ -95,7 +97,6 @@ public:
|
|||
private:
|
||||
|
||||
editor_display& gui_;
|
||||
const size_specs &size_specs_;
|
||||
int palette_start_;
|
||||
|
||||
mouse_action** mouse_action_;
|
||||
|
|
|
@ -205,11 +205,10 @@ void terrain_palette::draw_item(SDL_Rect& dstrect, const t_translation::t_terrai
|
|||
}
|
||||
}
|
||||
|
||||
terrain_palette::terrain_palette(editor_display &gui, const size_specs &sizes,
|
||||
const config& cfg,
|
||||
terrain_palette::terrain_palette(editor_display &gui, const config& cfg,
|
||||
mouse_action** active_mouse_action)
|
||||
//TODO avoid magic numbers
|
||||
: editor_palette<t_translation::t_terrain>(gui, sizes, cfg, 36, 4, active_mouse_action)
|
||||
: editor_palette<t_translation::t_terrain>(gui, cfg, 36, 4, active_mouse_action)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,9 +38,8 @@ void set_selected_bg_terrain(t_translation::t_terrain terrain);
|
|||
/** Palette where the terrain to be drawn can be selected. */
|
||||
class terrain_palette : public editor_palette<t_translation::t_terrain> {
|
||||
public:
|
||||
terrain_palette(editor_display &gui, const size_specs &sizes,
|
||||
const config& cfg,
|
||||
mouse_action** active_mouse_action);
|
||||
terrain_palette(editor_display &gui, const config& cfg,
|
||||
mouse_action** active_mouse_action);
|
||||
|
||||
const gamemap& map() const { return gui_.get_map(); }
|
||||
|
||||
|
|
|
@ -119,11 +119,10 @@ void unit_palette::draw_item(SDL_Rect& dstrect, const unit_type& u, std::strings
|
|||
tooltip_text << u.type_name();
|
||||
}
|
||||
|
||||
unit_palette::unit_palette(editor_display &gui, const size_specs &sizes,
|
||||
const config& cfg,
|
||||
unit_palette::unit_palette(editor_display &gui, const config& cfg,
|
||||
mouse_action** active_mouse_action)
|
||||
//TODO avoid magic numbers
|
||||
: editor_palette<unit_type>(gui, sizes, cfg, 72, 2, active_mouse_action)
|
||||
: editor_palette<unit_type>(gui, cfg, 72, 2, active_mouse_action)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -30,11 +30,9 @@ namespace editor {
|
|||
class unit_palette : public editor_palette<unit_type> {
|
||||
public:
|
||||
|
||||
unit_palette(editor_display &gui, const size_specs &sizes,
|
||||
const config& cfg,
|
||||
mouse_action** active_mouse_action);
|
||||
// unit_type& fore,
|
||||
// unit_type& back);
|
||||
unit_palette(editor_display &gui,
|
||||
const config& cfg,
|
||||
mouse_action** active_mouse_action);
|
||||
|
||||
virtual void setup(const config& cfg);
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ editor_toolkit::editor_toolkit(editor_display& gui, const CKey& key, const confi
|
|||
: gui_(gui)
|
||||
, key_(key)
|
||||
, palette_manager_()
|
||||
, size_specs_()
|
||||
, toolbar_dirty_(true)
|
||||
, mouse_action_(NULL)
|
||||
, mouse_actions_()
|
||||
|
@ -68,10 +67,8 @@ void editor_toolkit::init_brushes(const config& game_config)
|
|||
|
||||
void editor_toolkit::init_sidebar(const config& game_config)
|
||||
{
|
||||
size_specs_.reset(new size_specs());
|
||||
adjust_sizes(gui_, *size_specs_);
|
||||
brush_bar_.reset(new brush_bar(gui_, brushes_, &brush_));
|
||||
palette_manager_.reset(new palette_manager(gui_, *size_specs_, game_config, &mouse_action_));
|
||||
palette_manager_.reset(new palette_manager(gui_, game_config, &mouse_action_));
|
||||
}
|
||||
|
||||
void editor_toolkit::init_mouse_actions(const config& game_config)
|
||||
|
@ -90,8 +87,8 @@ void editor_toolkit::init_mouse_actions(const config& game_config)
|
|||
new mouse_action_unit(key_, *palette_manager_->unit_palette_.get())));
|
||||
|
||||
//TODO
|
||||
// mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_PASTE,
|
||||
// new mouse_action_paste(clipboard_, key_, *palette_manager_->empty_palette_.get())));
|
||||
// mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_PASTE,
|
||||
// new mouse_action_paste(clipboard_, key_, *palette_manager_->empty_palette_.get())));
|
||||
|
||||
BOOST_FOREACH(const theme::menu& menu, gui_.get_theme().menus()) {
|
||||
if (menu.items().size() == 1) {
|
||||
|
@ -174,8 +171,6 @@ void editor_toolkit::cycle_brush()
|
|||
|
||||
void editor_toolkit::adjust_size()
|
||||
{
|
||||
adjust_sizes(gui_, *size_specs_);
|
||||
|
||||
palette_manager_->adjust_size();
|
||||
palette_manager_->draw(true);
|
||||
|
||||
|
|
|
@ -86,10 +86,6 @@ private:
|
|||
/** TODO */
|
||||
boost::scoped_ptr<palette_manager> palette_manager_;
|
||||
|
||||
private:
|
||||
/** Legacy object required by the legacy terrain palette and brush bar */
|
||||
boost::scoped_ptr<size_specs> size_specs_;
|
||||
|
||||
//Toolbar
|
||||
|
||||
/** Toolbar-requires-redraw flag */
|
||||
|
|
Loading…
Add table
Reference in a new issue