mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 18:08:34 +00:00
Remove the template code from animated.hpp and put it into animated.cpp.
This code was indirectly included in at least 25 files: the 25 files for which a dependency on string_utils.hpp has been added by a consequence of its removal from animated.hpp. It should induce a small compile time improvement.
This commit is contained in:
parent
3fef2eb121
commit
fa1f3f6444
@ -33,6 +33,7 @@ wesnoth_SOURCES = about.cpp \
|
|||||||
ai.cpp \
|
ai.cpp \
|
||||||
ai_attack.cpp \
|
ai_attack.cpp \
|
||||||
ai_move.cpp \
|
ai_move.cpp \
|
||||||
|
animated.cpp \
|
||||||
astarnode.cpp \
|
astarnode.cpp \
|
||||||
builder.cpp \
|
builder.cpp \
|
||||||
cavegen.cpp \
|
cavegen.cpp \
|
||||||
@ -214,6 +215,7 @@ wesnoth_editor_SOURCES = editor/editor.cpp \
|
|||||||
editor/editor_undo.cpp \
|
editor/editor_undo.cpp \
|
||||||
about.cpp \
|
about.cpp \
|
||||||
actions.cpp \
|
actions.cpp \
|
||||||
|
animated.cpp \
|
||||||
astarnode.cpp \
|
astarnode.cpp \
|
||||||
builder.cpp \
|
builder.cpp \
|
||||||
cavegen.cpp \
|
cavegen.cpp \
|
||||||
@ -289,6 +291,7 @@ wesnoth_editor_SOURCES = editor/editor.cpp \
|
|||||||
ai.hpp \
|
ai.hpp \
|
||||||
ai_attack.hpp \
|
ai_attack.hpp \
|
||||||
ai_move.hpp \
|
ai_move.hpp \
|
||||||
|
animated.hpp \
|
||||||
array.hpp \
|
array.hpp \
|
||||||
astarnode.hpp \
|
astarnode.hpp \
|
||||||
builder.hpp \
|
builder.hpp \
|
||||||
|
262
src/animated.cpp
Normal file
262
src/animated.cpp
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
/*
|
||||||
|
Copyright (C) 2004 by Philippe Plantier <ayin@anathas.org>
|
||||||
|
Copyright (C) 2005 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
|
||||||
|
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.
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY.
|
||||||
|
|
||||||
|
See the COPYING file for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#include <string>
|
||||||
|
//#include <vector>
|
||||||
|
#include "SDL.h"
|
||||||
|
#include "animated.hpp"
|
||||||
|
#include "util.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
const T animated<T,T_void_value>::void_value_ = T_void_value()();
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
animated<T,T_void_value>::animated() :
|
||||||
|
starting_frame_time_(INT_MAX),
|
||||||
|
ending_frame_time_(INT_MIN),
|
||||||
|
started_(false),
|
||||||
|
no_current_frame_(true),
|
||||||
|
does_not_change_(false),
|
||||||
|
real_start_ticks_(0),
|
||||||
|
start_ticks_(0),
|
||||||
|
acceleration_(1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
animated<T,T_void_value>::animated(const std::string &cfg, const string_initializer& init):
|
||||||
|
starting_frame_time_(INT_MAX),
|
||||||
|
started_(false),
|
||||||
|
no_current_frame_(true),
|
||||||
|
does_not_change_(false),
|
||||||
|
real_start_ticks_(0),
|
||||||
|
start_ticks_(0),
|
||||||
|
acceleration_(1)
|
||||||
|
{
|
||||||
|
std::vector<std::string> items = utils::split(cfg);
|
||||||
|
|
||||||
|
int current_time = 0;
|
||||||
|
|
||||||
|
std::vector<std::string>::const_iterator itor = items.begin();
|
||||||
|
for(; itor != items.end(); ++itor) {
|
||||||
|
const std::vector<std::string>& items = utils::split(*itor, ':');
|
||||||
|
std::string str;
|
||||||
|
int time;
|
||||||
|
|
||||||
|
if(items.size() > 1) {
|
||||||
|
str = items.front();
|
||||||
|
time = atoi(items.back().c_str());
|
||||||
|
} else {
|
||||||
|
str = *itor;
|
||||||
|
time = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
frames_.push_back(frame(current_time, init(str)));
|
||||||
|
current_time += time;
|
||||||
|
}
|
||||||
|
|
||||||
|
starting_frame_time_ = 0;
|
||||||
|
ending_frame_time_ = current_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
void animated<T,T_void_value>::add_frame(int start)
|
||||||
|
{
|
||||||
|
frames_.push_back(frame(start));
|
||||||
|
starting_frame_time_ = minimum<int>(starting_frame_time_, start);
|
||||||
|
ending_frame_time_ = maximum<int>(ending_frame_time_, start);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
void animated<T,T_void_value>::add_frame(int start, const T& value)
|
||||||
|
{
|
||||||
|
frames_.push_back(frame(start, value));
|
||||||
|
starting_frame_time_ = minimum<int>(starting_frame_time_, start);
|
||||||
|
ending_frame_time_ = maximum<int>(ending_frame_time_, start);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
void animated<T,T_void_value>::start_animation(int start_frame, int cycles, int acceleration)
|
||||||
|
{
|
||||||
|
started_ = true;
|
||||||
|
start_frame_ = start_frame;
|
||||||
|
start_ticks_ = real_start_ticks_ = current_time_ = SDL_GetTicks() * acceleration;
|
||||||
|
cycles_ = cycles;
|
||||||
|
current_cycle_ = 0;
|
||||||
|
acceleration_ = acceleration;
|
||||||
|
// current_frame_ = frames_.begin();
|
||||||
|
current_frame_ = 0;
|
||||||
|
|
||||||
|
if (ending_frame_time_ >= start_frame_) {
|
||||||
|
duration_ = ending_frame_time_ - start_frame_;
|
||||||
|
} else {
|
||||||
|
duration_ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
void animated<T,T_void_value>::update_current_frame_internal()
|
||||||
|
{
|
||||||
|
// std::cerr << "--- updating frame ---\n";
|
||||||
|
if(does_not_change_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
frame_changed_ = false;
|
||||||
|
// Always update current_time_, for the animation_time functions to work.
|
||||||
|
current_time_ = SDL_GetTicks() * acceleration_;
|
||||||
|
if(!started_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(frames_.empty()) {
|
||||||
|
no_current_frame_ = true;
|
||||||
|
does_not_change_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frames_.size() == 1 && cycles_ == INFINITE_CYCLES) {
|
||||||
|
does_not_change_ = true;
|
||||||
|
frame_changed_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (duration_ > 0) {
|
||||||
|
// Ticks is the actual time since animation started.
|
||||||
|
int ticks = current_time_ - start_ticks_;
|
||||||
|
|
||||||
|
// Handles cycle overflow
|
||||||
|
if(ticks > duration_) {
|
||||||
|
int ncycles = ticks/duration_;
|
||||||
|
current_cycle_ = minimum<int>(cycles_, current_cycle_ + ncycles);
|
||||||
|
start_ticks_ += ncycles * duration_;
|
||||||
|
ticks -= ncycles * duration_;
|
||||||
|
// current_frame_ = frames_.begin();
|
||||||
|
current_frame_ = 0;
|
||||||
|
frame_changed_ = true;
|
||||||
|
}
|
||||||
|
// Checks if the animation is finished
|
||||||
|
if(cycles_ != INFINITE_CYCLES && current_cycle_ >= cycles_) {
|
||||||
|
// If the animation is finished, the current frame is the last
|
||||||
|
// one
|
||||||
|
current_frame_ = frames_.size() - 1;
|
||||||
|
frame_changed_ = true;
|
||||||
|
// std::cerr << "Animation finished\n";
|
||||||
|
no_current_frame_ = false;
|
||||||
|
started_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ticks < (frames_[current_frame_].milliseconds - start_frame_)) {
|
||||||
|
// std::cerr << "Animation not yet started\n";
|
||||||
|
frame_changed_ = true;
|
||||||
|
no_current_frame_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Looks for the current frame
|
||||||
|
typename std::vector<frame>::size_type i = current_frame_ + 1;
|
||||||
|
for(; i != frames_.size(); ++i) {
|
||||||
|
if(ticks < (frames_[i].milliseconds - start_frame_))
|
||||||
|
break;
|
||||||
|
current_frame_ = i;
|
||||||
|
frame_changed_ = true;
|
||||||
|
// std::cerr << "Skipping to next frame\n";
|
||||||
|
}
|
||||||
|
no_current_frame_ = false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// If the duration is void, the animation is automatically finished.
|
||||||
|
// current_cycle_ = cycles_;
|
||||||
|
if(cycles_ != -1)
|
||||||
|
started_ = false;
|
||||||
|
|
||||||
|
does_not_change_ = true;
|
||||||
|
frame_changed_ = false;
|
||||||
|
// current_frame_ = frames_.size() - 1;
|
||||||
|
// frame_changed_ = false;
|
||||||
|
// std::cerr << "Returning last frame\n";
|
||||||
|
no_current_frame_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
bool animated<T,T_void_value>::frame_changed() const
|
||||||
|
{
|
||||||
|
return frame_changed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
bool animated<T,T_void_value>::animation_finished() const
|
||||||
|
{
|
||||||
|
if(!started_)
|
||||||
|
return true;
|
||||||
|
//if(current_cycle_ == cycles_)
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
int animated<T,T_void_value>::get_animation_time() const
|
||||||
|
{
|
||||||
|
if(does_not_change_)
|
||||||
|
return SDL_GetTicks() * acceleration_ - real_start_ticks_ + start_frame_;
|
||||||
|
|
||||||
|
return current_time_ - real_start_ticks_ + start_frame_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
int animated<T,T_void_value>::get_frame_time() const
|
||||||
|
{
|
||||||
|
return current_time_ - start_ticks_ + start_frame_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
const T& animated<T,T_void_value>::get_current_frame() const
|
||||||
|
{
|
||||||
|
if(no_current_frame_ == true)
|
||||||
|
return void_value_;
|
||||||
|
const frame& cur = frames_[current_frame_];
|
||||||
|
if(!cur.has_value)
|
||||||
|
return void_value_;
|
||||||
|
return cur.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
int animated<T,T_void_value>::get_first_frame_time() const
|
||||||
|
{
|
||||||
|
if (starting_frame_time_ != INT_MAX && starting_frame_time_ != INT_MIN)
|
||||||
|
return starting_frame_time_;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, typename T_void_value>
|
||||||
|
int animated<T,T_void_value>::get_last_frame_time() const
|
||||||
|
{
|
||||||
|
if (ending_frame_time_ != INT_MAX && ending_frame_time_ != INT_MIN)
|
||||||
|
return ending_frame_time_;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Force compilation of the following template instantiations
|
||||||
|
|
||||||
|
#include "image.hpp"
|
||||||
|
#include "unit_types.hpp"
|
||||||
|
|
||||||
|
template class animated< image::locator >;
|
||||||
|
template class animated< std::string >;
|
||||||
|
template class animated< unit_animation::frame >;
|
250
src/animated.hpp
250
src/animated.hpp
@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "SDL.h"
|
|
||||||
#include "util.hpp"
|
|
||||||
#include "serialization/string_utils.hpp"
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class void_value
|
class void_value
|
||||||
@ -69,8 +66,7 @@ public:
|
|||||||
bool animation_finished() const;
|
bool animation_finished() const;
|
||||||
int get_animation_time() const;
|
int get_animation_time() const;
|
||||||
int get_frame_time() const;
|
int get_frame_time() const;
|
||||||
inline const T& get_current_frame() const;
|
const T& get_current_frame() const;
|
||||||
const T& get_base_frame() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct frame
|
struct frame
|
||||||
@ -113,249 +109,5 @@ private:
|
|||||||
std::vector<frame> frames_;
|
std::vector<frame> frames_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
const T animated<T,T_void_value>::void_value_ = T_void_value()();
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
animated<T,T_void_value>::animated() :
|
|
||||||
starting_frame_time_(INT_MAX),
|
|
||||||
ending_frame_time_(INT_MIN),
|
|
||||||
started_(false),
|
|
||||||
no_current_frame_(true),
|
|
||||||
does_not_change_(false),
|
|
||||||
real_start_ticks_(0),
|
|
||||||
start_ticks_(0),
|
|
||||||
acceleration_(1)
|
|
||||||
{}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
animated<T,T_void_value>::animated(const std::string &cfg, const string_initializer& init):
|
|
||||||
starting_frame_time_(INT_MAX),
|
|
||||||
started_(false),
|
|
||||||
no_current_frame_(true),
|
|
||||||
does_not_change_(false),
|
|
||||||
real_start_ticks_(0),
|
|
||||||
start_ticks_(0),
|
|
||||||
acceleration_(1)
|
|
||||||
{
|
|
||||||
std::vector<std::string> items = utils::split(cfg);
|
|
||||||
|
|
||||||
int current_time = 0;
|
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator itor = items.begin();
|
|
||||||
for(; itor != items.end(); ++itor) {
|
|
||||||
const std::vector<std::string>& items = utils::split(*itor, ':');
|
|
||||||
std::string str;
|
|
||||||
int time;
|
|
||||||
|
|
||||||
if(items.size() > 1) {
|
|
||||||
str = items.front();
|
|
||||||
time = atoi(items.back().c_str());
|
|
||||||
} else {
|
|
||||||
str = *itor;
|
|
||||||
time = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
frames_.push_back(frame(current_time, init(str)));
|
|
||||||
current_time += time;
|
|
||||||
}
|
|
||||||
|
|
||||||
starting_frame_time_ = 0;
|
|
||||||
ending_frame_time_ = current_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
void animated<T,T_void_value>::add_frame(int start)
|
|
||||||
{
|
|
||||||
frames_.push_back(frame(start));
|
|
||||||
starting_frame_time_ = minimum<int>(starting_frame_time_, start);
|
|
||||||
ending_frame_time_ = maximum<int>(ending_frame_time_, start);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
void animated<T,T_void_value>::add_frame(int start, const T& value)
|
|
||||||
{
|
|
||||||
frames_.push_back(frame(start, value));
|
|
||||||
starting_frame_time_ = minimum<int>(starting_frame_time_, start);
|
|
||||||
ending_frame_time_ = maximum<int>(ending_frame_time_, start);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
void animated<T,T_void_value>::start_animation(int start_frame, int cycles, int acceleration)
|
|
||||||
{
|
|
||||||
started_ = true;
|
|
||||||
start_frame_ = start_frame;
|
|
||||||
start_ticks_ = real_start_ticks_ = current_time_ = SDL_GetTicks() * acceleration;
|
|
||||||
cycles_ = cycles;
|
|
||||||
current_cycle_ = 0;
|
|
||||||
acceleration_ = acceleration;
|
|
||||||
// current_frame_ = frames_.begin();
|
|
||||||
current_frame_ = 0;
|
|
||||||
|
|
||||||
if (ending_frame_time_ >= start_frame_) {
|
|
||||||
duration_ = ending_frame_time_ - start_frame_;
|
|
||||||
} else {
|
|
||||||
duration_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
void animated<T,T_void_value>::update_current_frame_internal()
|
|
||||||
{
|
|
||||||
// std::cerr << "--- updating frame ---\n";
|
|
||||||
if(does_not_change_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
frame_changed_ = false;
|
|
||||||
// Always update current_time_, for the animation_time functions to work.
|
|
||||||
current_time_ = SDL_GetTicks() * acceleration_;
|
|
||||||
if(!started_)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(frames_.empty()) {
|
|
||||||
no_current_frame_ = true;
|
|
||||||
does_not_change_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(frames_.size() == 1 && cycles_ == INFINITE_CYCLES) {
|
|
||||||
does_not_change_ = true;
|
|
||||||
frame_changed_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (duration_ > 0) {
|
|
||||||
// Ticks is the actual time since animation started.
|
|
||||||
int ticks = current_time_ - start_ticks_;
|
|
||||||
|
|
||||||
// Handles cycle overflow
|
|
||||||
if(ticks > duration_) {
|
|
||||||
int ncycles = ticks/duration_;
|
|
||||||
current_cycle_ = minimum<int>(cycles_, current_cycle_ + ncycles);
|
|
||||||
start_ticks_ += ncycles * duration_;
|
|
||||||
ticks -= ncycles * duration_;
|
|
||||||
// current_frame_ = frames_.begin();
|
|
||||||
current_frame_ = 0;
|
|
||||||
frame_changed_ = true;
|
|
||||||
}
|
|
||||||
// Checks if the animation is finished
|
|
||||||
if(cycles_ != INFINITE_CYCLES && current_cycle_ >= cycles_) {
|
|
||||||
// If the animation is finished, the current frame is the last
|
|
||||||
// one
|
|
||||||
current_frame_ = frames_.size() - 1;
|
|
||||||
frame_changed_ = true;
|
|
||||||
// std::cerr << "Animation finished\n";
|
|
||||||
no_current_frame_ = false;
|
|
||||||
started_ = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ticks < (frames_[current_frame_].milliseconds - start_frame_)) {
|
|
||||||
// std::cerr << "Animation not yet started\n";
|
|
||||||
frame_changed_ = true;
|
|
||||||
no_current_frame_ = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Looks for the current frame
|
|
||||||
typename std::vector<frame>::size_type i = current_frame_ + 1;
|
|
||||||
for(; i != frames_.size(); ++i) {
|
|
||||||
if(ticks < (frames_[i].milliseconds - start_frame_))
|
|
||||||
break;
|
|
||||||
current_frame_ = i;
|
|
||||||
frame_changed_ = true;
|
|
||||||
// std::cerr << "Skipping to next frame\n";
|
|
||||||
}
|
|
||||||
no_current_frame_ = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// If the duration is void, the animation is automatically finished.
|
|
||||||
// current_cycle_ = cycles_;
|
|
||||||
if(cycles_ != -1)
|
|
||||||
started_ = false;
|
|
||||||
|
|
||||||
does_not_change_ = true;
|
|
||||||
frame_changed_ = false;
|
|
||||||
// current_frame_ = frames_.size() - 1;
|
|
||||||
// frame_changed_ = false;
|
|
||||||
// std::cerr << "Returning last frame\n";
|
|
||||||
no_current_frame_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
bool animated<T,T_void_value>::frame_changed() const
|
|
||||||
{
|
|
||||||
return frame_changed_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
bool animated<T,T_void_value>::animation_finished() const
|
|
||||||
{
|
|
||||||
if(!started_)
|
|
||||||
return true;
|
|
||||||
//if(current_cycle_ == cycles_)
|
|
||||||
// return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
int animated<T,T_void_value>::get_animation_time() const
|
|
||||||
{
|
|
||||||
if(does_not_change_)
|
|
||||||
return SDL_GetTicks() * acceleration_ - real_start_ticks_ + start_frame_;
|
|
||||||
|
|
||||||
return current_time_ - real_start_ticks_ + start_frame_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
int animated<T,T_void_value>::get_frame_time() const
|
|
||||||
{
|
|
||||||
return current_time_ - start_ticks_ + start_frame_;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
const T& animated<T,T_void_value>::get_current_frame() const
|
|
||||||
{
|
|
||||||
if(no_current_frame_ == true)
|
|
||||||
return void_value_;
|
|
||||||
const frame& cur = frames_[current_frame_];
|
|
||||||
if(!cur.has_value)
|
|
||||||
return void_value_;
|
|
||||||
return cur.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
const T& animated<T,T_void_value>::get_base_frame() const
|
|
||||||
{
|
|
||||||
if(frames_.empty())
|
|
||||||
return void_value_;
|
|
||||||
|
|
||||||
return frames_[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
int animated<T,T_void_value>::get_first_frame_time() const
|
|
||||||
{
|
|
||||||
if (starting_frame_time_ != INT_MAX && starting_frame_time_ != INT_MIN)
|
|
||||||
return starting_frame_time_;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename T_void_value>
|
|
||||||
int animated<T,T_void_value>::get_last_frame_time() const
|
|
||||||
{
|
|
||||||
if (ending_frame_time_ != INT_MAX && ending_frame_time_ != INT_MIN)
|
|
||||||
return ending_frame_time_;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "terrain.hpp"
|
#include "terrain.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#define ERR_NG lg::err(lg::engine)
|
#define ERR_NG lg::err(lg::engine)
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "pathfind.hpp"
|
#include "pathfind.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#define LOG_NG lg::info(lg::engine)
|
#define LOG_NG lg::info(lg::engine)
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "show_dialog.hpp"
|
#include "show_dialog.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
#include "widgets/progressbar.hpp"
|
#include "widgets/progressbar.hpp"
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "../team.hpp"
|
#include "../team.hpp"
|
||||||
#include "../util.hpp"
|
#include "../util.hpp"
|
||||||
#include "../video.hpp"
|
#include "../video.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include "editor.hpp"
|
#include "editor.hpp"
|
||||||
#include "map_manip.hpp"
|
#include "map_manip.hpp"
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "../team.hpp"
|
#include "../team.hpp"
|
||||||
#include "../util.hpp"
|
#include "../util.hpp"
|
||||||
#include "../wesconfig.h"
|
#include "../wesconfig.h"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "team.hpp"
|
#include "team.hpp"
|
||||||
#include "tooltips.hpp"
|
#include "tooltips.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include "unit.hpp"
|
#include "unit.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/button.hpp"
|
#include "widgets/button.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "unit_display.hpp"
|
#include "unit_display.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "preferences.hpp"
|
#include "preferences.hpp"
|
||||||
#include "statistics.hpp"
|
#include "statistics.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "sdl_utils.hpp"
|
#include "sdl_utils.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "unit.hpp"
|
#include "unit.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/button.hpp"
|
#include "widgets/button.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
#include "widgets/scrollbar.hpp"
|
#include "widgets/scrollbar.hpp"
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "leader_list.hpp"
|
#include "leader_list.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
|
|
||||||
leader_list_manager::leader_list_manager(const config::child_list& side_list,
|
leader_list_manager::leader_list_manager(const config::child_list& side_list,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "pathfind.hpp"
|
#include "pathfind.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "race.hpp"
|
#include "race.hpp"
|
||||||
#include "scoped_resource.hpp"
|
#include "scoped_resource.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#define ERR_CF lg::err(lg::config)
|
#define ERR_CF lg::err(lg::config)
|
||||||
#define LOG_NG lg::info(lg::engine)
|
#define LOG_NG lg::info(lg::engine)
|
||||||
|
@ -12,13 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.hpp"
|
#include "global.hpp"
|
||||||
#include "multiplayer_connect.hpp"
|
#include "dialogs.hpp"
|
||||||
#include "font.hpp"
|
#include "font.hpp"
|
||||||
|
#include "game_config.hpp"
|
||||||
|
#include "multiplayer_connect.hpp"
|
||||||
#include "preferences.hpp"
|
#include "preferences.hpp"
|
||||||
#include "show_dialog.hpp"
|
#include "show_dialog.hpp"
|
||||||
#include "dialogs.hpp"
|
|
||||||
#include "game_config.hpp"
|
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#define LOG_NW lg::info(lg::network)
|
#define LOG_NW lg::info(lg::network)
|
||||||
#define ERR_NW lg::err(lg::network)
|
#define ERR_NW lg::err(lg::network)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "replay.hpp"
|
#include "replay.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#define LOG_NW lg::info(lg::network)
|
#define LOG_NW lg::info(lg::network)
|
||||||
#define ERR_NW lg::err(lg::network)
|
#define ERR_NW lg::err(lg::network)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "unit_display.hpp"
|
#include "unit_display.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "show_dialog.hpp"
|
#include "show_dialog.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
#include "widgets/button.hpp"
|
#include "widgets/button.hpp"
|
||||||
#include "widgets/label.hpp"
|
#include "widgets/label.hpp"
|
||||||
#include "widgets/menu.hpp"
|
#include "widgets/menu.hpp"
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "race.hpp"
|
#include "race.hpp"
|
||||||
#include "replay.hpp"
|
#include "replay.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "team.hpp"
|
#include "team.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "theme.hpp"
|
#include "theme.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "unit.hpp"
|
#include "unit.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -20,18 +20,12 @@
|
|||||||
#include "unit_types.hpp"
|
#include "unit_types.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include "wassert.hpp"
|
#include "wassert.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
//these headers are used to check for file existence
|
|
||||||
#ifdef linux
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unit_animation::frame::frame(const config& cfg)
|
unit_animation::frame::frame(const config& cfg)
|
||||||
{
|
{
|
||||||
xoffset = atoi(cfg["xoffset"].c_str());
|
xoffset = atoi(cfg["xoffset"].c_str());
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "../log.hpp"
|
#include "../log.hpp"
|
||||||
#include "../util.hpp"
|
#include "../util.hpp"
|
||||||
#include "../video.hpp"
|
#include "../video.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
namespace gui {
|
namespace gui {
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "../show_dialog.hpp"
|
#include "../show_dialog.hpp"
|
||||||
#include "../util.hpp"
|
#include "../util.hpp"
|
||||||
#include "../video.hpp"
|
#include "../video.hpp"
|
||||||
|
#include "serialization/string_utils.hpp"
|
||||||
|
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user