- fix bug in box right drag
- print int vector - duplicate texture resized
This commit is contained in:
parent
f5d03b9be6
commit
2b9dd44ff7
|
@ -114,8 +114,9 @@ void Box::set_right(float right, bool drag)
|
|||
void Box::drag_right(float delta)
|
||||
{
|
||||
float previous_right = get_right();
|
||||
set_right(get_right() + delta);
|
||||
set_w(get_w() + previous_right - get_right());
|
||||
float new_right = get_right() + delta;
|
||||
set_w(get_w() + new_right - previous_right);
|
||||
set_right(new_right);
|
||||
}
|
||||
|
||||
void Box::set_bottom(float bottom)
|
||||
|
|
|
@ -27,7 +27,7 @@ void Sprite::associate(std::string path)
|
|||
std::vector<fs::path> paths;
|
||||
std::copy(directory, fs::directory_iterator(), std::back_inserter(paths));
|
||||
std::sort(paths.begin(), paths.end());
|
||||
for (const fs::path &name : paths)
|
||||
for (const fs::path& name : paths)
|
||||
{
|
||||
frame_paths.push_back(name);
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ void Sprite::add_frame(SDL_Texture* texture)
|
|||
{
|
||||
all_frames_frameset.add_frame_index(ii);
|
||||
}
|
||||
for (auto& member : framesets)
|
||||
for (auto& [name, frameset] : framesets)
|
||||
{
|
||||
member.second.set_size();
|
||||
frameset.set_size();
|
||||
}
|
||||
update_size(preserve_center);
|
||||
}
|
||||
|
@ -109,7 +109,10 @@ Frameset& Sprite::set_frameset(std::string name)
|
|||
{
|
||||
current_frameset_name = name;
|
||||
frame_animation.set_frame_length(get_current_frameset().get_frame_length());
|
||||
update_size(true);
|
||||
if (is_loaded())
|
||||
{
|
||||
update_size(true);
|
||||
}
|
||||
return get_current_frameset();
|
||||
}
|
||||
|
||||
|
@ -557,16 +560,7 @@ void Frameset::step()
|
|||
|
||||
void Frameset::increment_index()
|
||||
{
|
||||
int increment;
|
||||
if (!reversed)
|
||||
{
|
||||
increment = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
increment = -1;
|
||||
}
|
||||
increment_index(increment);
|
||||
increment_index(reversed ? -1 : 1);
|
||||
}
|
||||
|
||||
void Frameset::increment_index(int increment)
|
||||
|
|
|
@ -200,7 +200,13 @@ SDL_Texture* sfw::get_filled_texture(SDL_Renderer* renderer, glm::vec2 size, SDL
|
|||
SDL_Texture* sfw::duplicate_texture(SDL_Renderer* renderer, SDL_Texture* base, Uint32 format)
|
||||
{
|
||||
Box box = get_texture_box(base);
|
||||
SDL_Texture* duplicate = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_TARGET, box.get_w(), box.get_h());
|
||||
return duplicate_texture(renderer, base, box.get_size(), format);
|
||||
}
|
||||
|
||||
SDL_Texture* sfw::duplicate_texture(SDL_Renderer* renderer, SDL_Texture* base, const glm::vec2& size, Uint32 format)
|
||||
{
|
||||
Box box = get_texture_box(base);
|
||||
SDL_Texture* duplicate = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_TARGET, size.x, size.y);
|
||||
if (duplicate == NULL)
|
||||
{
|
||||
print_sdl_error("could not create texture from base");
|
||||
|
@ -492,3 +498,14 @@ std::ostream& operator<<(std::ostream& out, const SDL_Color& color)
|
|||
static_cast<int>(color.b) << ", " << static_cast<int>(color.a) << "}";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const std::vector<int> ints)
|
||||
{
|
||||
out << "{ ";
|
||||
for (int ii : ints)
|
||||
{
|
||||
out << ii << " ";
|
||||
}
|
||||
out << "}";
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace sfw
|
|||
SDL_Texture* get_filled_texture(SDL_Renderer*, glm::vec2, const SDL_Color&, Uint32 = SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Texture* get_filled_texture(SDL_Renderer*, glm::vec2, SDL_Texture*, Uint32 = SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Texture* duplicate_texture(SDL_Renderer*, SDL_Texture*, Uint32 = SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Texture* duplicate_texture(SDL_Renderer*, SDL_Texture*, const glm::vec2&, Uint32 = SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Texture* get_remapped_texture(
|
||||
SDL_Renderer*, SDL_Texture*, const std::map<SDL_Color, SDL_Color>&, Uint32 = SDL_PIXELFORMAT_RGBA32);
|
||||
SDL_Texture* get_remapped_texture(
|
||||
|
@ -120,5 +121,6 @@ std::ostream& operator<<(std::ostream&, const glm::vec2&);
|
|||
bool operator<(const SDL_Color& color_1, const SDL_Color& color_2);
|
||||
bool operator==(const SDL_Color& color_1, const SDL_Color& color_2);
|
||||
std::ostream& operator<<(std::ostream&, const SDL_Color&);
|
||||
std::ostream& operator<<(std::ostream&, const std::vector<int>);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue