From 75aae4fd28bbd9062398649a5ee52156b8929648 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Thu, 29 Jun 2023 20:31:14 +0200 Subject: [PATCH] Battle: Do not adjust src_rect anymore when the sprite is flipped Broke the rendering as the same happens now in the sprite class for use by pictures. --- src/battle_animation.cpp | 3 +-- src/sprite_actor.cpp | 5 ++--- src/sprite_weapon.cpp | 8 +++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/battle_animation.cpp b/src/battle_animation.cpp index 12a97c8ab2..9acd30943c 100644 --- a/src/battle_animation.cpp +++ b/src/battle_animation.cpp @@ -107,10 +107,9 @@ void BattleAnimation::DrawAt(Bitmap& dst, int x, int y) { continue; } - SetX(invert ? x - cell.x : cell.x + x); + SetX(cell.x + x); SetY(cell.y + y); int sx = cell.cell_id % 5; - if (invert) sx = 4 - sx; int sy = cell.cell_id / 5; int size = animation.large ? 128 : 96; SetSrcRect(Rect(sx * size, sy * size, size, size)); diff --git a/src/sprite_actor.cpp b/src/sprite_actor.cpp index fda747fb2d..93d95da4b4 100644 --- a/src/sprite_actor.cpp +++ b/src/sprite_actor.cpp @@ -126,8 +126,7 @@ void Sprite_Actor::Update() { animation->SetVisible(IsVisible()); } - const bool flip = battler->IsDirectionFlipped(); - SetFlipX(flip); + SetFlipX(battler->IsDirectionFlipped()); } void Sprite_Actor::SetAnimationState(int state, LoopState loop, int animation_id) { @@ -268,7 +267,7 @@ void Sprite_Actor::DoIdleAnimation() { void Sprite_Actor::OnBattlercharsetReady(FileRequestResult* result, int32_t battler_index) { SetBitmap(Cache::Battlecharset(result->file)); - SetSrcRect(Rect((battler->IsDirectionFlipped() ? 96 : 0), battler_index * 48, 48, 48)); + SetSrcRect(Rect(0, battler_index * 48, 48, 48)); } void Sprite_Actor::Draw(Bitmap& dst) { diff --git a/src/sprite_weapon.cpp b/src/sprite_weapon.cpp index 372d3dff4b..e29fb5f72e 100644 --- a/src/sprite_weapon.cpp +++ b/src/sprite_weapon.cpp @@ -64,8 +64,7 @@ void Sprite_Weapon::Update() { SetSrcRect(Rect(frame * 64, battler_animation_weapon->weapon_index * 64, 64, 64)); - const bool flip = battler->IsDirectionFlipped(); - SetFlipX(flip); + SetFlipX(battler->IsDirectionFlipped()); } void Sprite_Weapon::SetWeaponAnimation(int nweapon_animation_id) { @@ -125,9 +124,8 @@ void Sprite_Weapon::CreateSprite() { void Sprite_Weapon::OnBattleWeaponReady(FileRequestResult* result, int32_t weapon_index) { SetBitmap(Cache::Battleweapon(result->file)); - const bool flip = battler->IsDirectionFlipped(); - SetFlipX(flip); - SetSrcRect(Rect((flip ? 128 : 0), weapon_index * 64, 64, 64)); + SetFlipX(battler->IsDirectionFlipped()); + SetSrcRect(Rect(0, weapon_index * 64, 64, 64)); } void Sprite_Weapon::Draw(Bitmap& dst) {