Add engine support for mirrored portraits.
This commit is contained in:
parent
ca7736178d
commit
ee140c0587
6 changed files with 21 additions and 9 deletions
|
@ -25,6 +25,7 @@
|
|||
x = 0
|
||||
y = "(height - image_height)"
|
||||
name = "(portrait_image)"
|
||||
vertical_mirror = "(portrait_mirror)"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
|
|
@ -1917,15 +1917,16 @@ namespace {
|
|||
unsigned image_size = 200;
|
||||
unsigned window_height = 400;
|
||||
if(spacer && spacer->get_best_size().x == 500) {
|
||||
image_size = 400;
|
||||
window_height = 600;
|
||||
image_size = 400;
|
||||
window_height = 600;
|
||||
}
|
||||
|
||||
const unit_map::iterator speaker = units->find(event_info.loc1);
|
||||
assert(speaker != units->end());
|
||||
|
||||
const tportrait* portrait = speaker->second.portrait(image_size);
|
||||
const tportrait* portrait = speaker->second.portrait(image_size, tportrait::LEFT);
|
||||
const std::string image = portrait ? portrait->image : "";
|
||||
const bool mirror = portrait ? portrait->mirror : false;
|
||||
|
||||
/**
|
||||
* @todo FIXME these fixed sizes should depend on the map size and maybe
|
||||
|
@ -1936,6 +1937,7 @@ namespace {
|
|||
gui2::settings::screen_width - 140, window_height));
|
||||
|
||||
window.canvas(1).set_variable("portrait_image", variant(image));
|
||||
window.canvas(1).set_variable("portrait_mirror", variant(mirror));
|
||||
|
||||
gui2::tcontrol* label = dynamic_cast<gui2::tcontrol*>(window.find_widget("message", false));
|
||||
assert(label);
|
||||
|
|
|
@ -38,7 +38,8 @@ static tportrait::tside get_side(const std::string& side)
|
|||
tportrait::tportrait(const config& cfg) :
|
||||
image(cfg["image"]),
|
||||
side(get_side(cfg["side"])),
|
||||
size(lexical_cast_default<unsigned>(cfg["size"]))
|
||||
size(lexical_cast_default<unsigned>(cfg["size"])),
|
||||
mirror(utils::string_bool(cfg["mirror"]))
|
||||
{
|
||||
VALIDATE(!image.empty(), missing_mandatory_wml_key("portrait", "image"));
|
||||
VALIDATE(size != 0, missing_mandatory_wml_key("portrait", "size"));
|
||||
|
|
|
@ -35,6 +35,7 @@ struct tportrait {
|
|||
std::string image;
|
||||
tside side;
|
||||
unsigned size;
|
||||
bool mirror;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2924,10 +2924,13 @@ std::string unit::image_mods() const{
|
|||
return modifier.str();
|
||||
}
|
||||
|
||||
const tportrait* unit::portrait(const unsigned size) const
|
||||
const tportrait* unit::portrait(
|
||||
const unsigned size, const tportrait::tside side) const
|
||||
{
|
||||
foreach(const tportrait& portrait, (type()->portraits())) {
|
||||
if(portrait.size == size) {
|
||||
if(portrait.size == size
|
||||
&& (side == portrait.side || portrait.side == tportrait::BOTH)) {
|
||||
|
||||
return &portrait;
|
||||
}
|
||||
}
|
||||
|
|
10
src/unit.hpp
10
src/unit.hpp
|
@ -18,18 +18,18 @@
|
|||
#define UNIT_H_INCLUDED
|
||||
|
||||
#include "config.hpp"
|
||||
#include "formula_callable.hpp"
|
||||
#include "map.hpp"
|
||||
#include "portrait.hpp"
|
||||
#include "race.hpp"
|
||||
#include "team.hpp"
|
||||
#include "unit_types.hpp"
|
||||
#include "unit_map.hpp"
|
||||
#include "formula_callable.hpp"
|
||||
|
||||
class game_display;
|
||||
class gamestatus;
|
||||
class game_state;
|
||||
class config_writer;
|
||||
class tportrait;
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -301,10 +301,14 @@ public:
|
|||
/**
|
||||
* Gets the portrait for a unit.
|
||||
*
|
||||
* @param size The size of the portrait.
|
||||
* @param side The side the portrait is shown on.
|
||||
*
|
||||
* @returns The portrait with the wanted size.
|
||||
* @retval NULL The wanted portrait doesn't exist.
|
||||
*/
|
||||
const tportrait* portrait(const unsigned size) const;
|
||||
const tportrait* portrait(
|
||||
const unsigned size, const tportrait::tside side) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue