From 65af2ece16408761cafe8d6f095325b81457c05f Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Thu, 6 Mar 2025 01:43:35 +0200 Subject: [PATCH 1/6] Add scaling to bitmap primitives may be obsoleted by upcoming renderer overhaul, also may lack some safety cause I can't into cpp. --- Source/Lua/LuaBindingsManagers.cpp | 8 +++ Source/Lua/LuaBindingsPrimitives.cpp | 2 + Source/Managers/PrimitiveMan.cpp | 8 +-- Source/Managers/PrimitiveMan.h | 76 +++++++++++++++++++++++++++- Source/System/GraphicalPrimitive.cpp | 8 ++- Source/System/GraphicalPrimitive.h | 43 ++++++++++++++-- 6 files changed, 134 insertions(+), 11 deletions(-) diff --git a/Source/Lua/LuaBindingsManagers.cpp b/Source/Lua/LuaBindingsManagers.cpp index 24470d05ca..db70412553 100644 --- a/Source/Lua/LuaBindingsManagers.cpp +++ b/Source/Lua/LuaBindingsManagers.cpp @@ -262,13 +262,21 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PrimitiveMan) { .def("DrawTextPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& text, bool isSmall, int alignment)) & PrimitiveMan::DrawTextPrimitive) .def("DrawTextPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle)) & PrimitiveMan::DrawTextPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawIconPrimitive", (void(PrimitiveMan::*)(const Vector& start, Entity* entity)) & PrimitiveMan::DrawIconPrimitive) .def("DrawIconPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, Entity* entity)) & PrimitiveMan::DrawIconPrimitive) diff --git a/Source/Lua/LuaBindingsPrimitives.cpp b/Source/Lua/LuaBindingsPrimitives.cpp index 65d932888b..9352f0c2b0 100644 --- a/Source/Lua/LuaBindingsPrimitives.cpp +++ b/Source/Lua/LuaBindingsPrimitives.cpp @@ -95,6 +95,8 @@ LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TextPrimitive) LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BitmapPrimitive) { return luabind::class_("BitmapPrimitive") + .def(luabind::constructor()) + .def(luabind::constructor()) .def(luabind::constructor()) .def(luabind::constructor()); } diff --git a/Source/Managers/PrimitiveMan.cpp b/Source/Managers/PrimitiveMan.cpp index 8e007a6517..6d66c30da8 100644 --- a/Source/Managers/PrimitiveMan.cpp +++ b/Source/Managers/PrimitiveMan.cpp @@ -217,12 +217,12 @@ void PrimitiveMan::DrawTextPrimitive(int player, const Vector& start, const std: SchedulePrimitive(std::make_unique(player, start, text, isSmall, alignment, rotAngle)); } -void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) { - SchedulePrimitive(std::make_unique(player, centerPos, moSprite, rotAngle, frame, hFlipped, vFlipped)); +void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) { + SchedulePrimitive(std::make_unique(player, centerPos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped)); } -void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { - SchedulePrimitive(std::make_unique(player, centerPos, filePath, rotAngle, hFlipped, vFlipped)); +void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) { + SchedulePrimitive(std::make_unique(player, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped)); } void PrimitiveMan::DrawIconPrimitive(int player, const Vector& centerPos, Entity* entity) { diff --git a/Source/Managers/PrimitiveMan.h b/Source/Managers/PrimitiveMan.h index e920a091bf..19aa1a579e 100644 --- a/Source/Managers/PrimitiveMan.h +++ b/Source/Managers/PrimitiveMan.h @@ -311,6 +311,14 @@ namespace RTE { /// @param frame Frame to draw. void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, false, false); } + /// Schedule to draw a bitmap primitive. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param scale Drawing scale. + void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, scale, frame, false, false); } + /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. /// @param centerPos Position of primitive's center in scene coordinates. /// @param moSprite A MOSprite to draw BITMAP from. @@ -320,6 +328,16 @@ namespace RTE { /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, hFlipped, vFlipped); } + /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param scale Drawing scale. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. + void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped); } + /// Schedule to draw a bitmap primitive visible only to a specified player. /// @param player Player screen to draw primitive on. /// @param centerPos Position of primitive's center in scene coordinates. @@ -328,15 +346,35 @@ namespace RTE { /// @param frame Frame to draw. void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, false, false); } + /// Schedule to draw a bitmap primitive visible only to a specified player. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param scale Drawing scale. + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, scale, false, false); } + + /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param moSprite A MOSprite to draw BITMAP from. + /// @param rotAngle Rotation angle in radians. + /// @param frame Frame to draw. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1u, false, false); } + /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. /// @param centerPos Position of primitive's center in scene coordinates. /// @param moSprite A MOSprite to draw BITMAP from. /// @param rotAngle Rotation angle in radians. /// @param frame Frame to draw. + /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped); + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped); /// Schedule to draw a bitmap primitive. /// @param centerPos Position of primitive's center in scene coordinates. @@ -344,6 +382,13 @@ namespace RTE { /// @param rotAngle Rotation angle in radians. void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, false, false); } + /// Schedule to draw a bitmap primitive. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. + /// @param scale Drawing scale. + void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, false, false); } + /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. /// @param centerPos Position of primitive's center in scene coordinates. /// @param filePath An entity to draw sprite from. @@ -352,6 +397,15 @@ namespace RTE { /// @param vFlipped Whether to flip the sprite vertically. void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, hFlipped, vFlipped); } + /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath An entity to draw sprite from. + /// @param rotAngle Rotation angle in radians. + /// @param scale Drawing scale. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. + void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped); } + /// Schedule to draw a bitmap primitive visible only to a specified player. /// @param player Player screen to draw primitive on. /// @param centerPos Position of primitive's center in scene coordinates. @@ -359,14 +413,32 @@ namespace RTE { /// @param rotAngle Rotation angle in radians. void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, false, false); } + /// Schedule to draw a bitmap primitive visible only to a specified player. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. + /// @param scale Drawing scale. + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, scale, false, false); } + + /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. + /// @param player Player screen to draw primitive on. + /// @param centerPos Position of primitive's center in scene coordinates. + /// @param filePath Path to the bitmap to draw. + /// @param rotAngle Rotation angle in radians. + /// @param hFlipped Whether to flip the sprite horizontally. + /// @param vFlipped Whether to flip the sprite vertically. + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, 1u, false, false); } + /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. /// @param centerPos Position of primitive's center in scene coordinates. /// @param filePath Path to the bitmap to draw. /// @param rotAngle Rotation angle in radians. + /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped); + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped); /// Schedule to draw the GUI icon of an object. /// @param centerPos Position of primitive's center in scene coordinates. diff --git a/Source/System/GraphicalPrimitive.cpp b/Source/System/GraphicalPrimitive.cpp index 7cb922151b..2846b3bf24 100644 --- a/Source/System/GraphicalPrimitive.cpp +++ b/Source/System/GraphicalPrimitive.cpp @@ -504,9 +504,13 @@ void BitmapPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { return; } - BITMAP* bitmapToDraw = create_bitmap_ex(8, m_Bitmap->w, m_Bitmap->h); + BITMAP* bitmapToDraw = create_bitmap_ex(8, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); clear_to_color(bitmapToDraw, ColorKeys::g_MaskColor); - draw_sprite(bitmapToDraw, m_Bitmap, 0, 0); + if (m_Scale == 1u) { + draw_sprite(bitmapToDraw, m_Bitmap, 0, 0); + } else { + stretch_sprite(bitmapToDraw, m_Bitmap, 0, 0, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); + } if (m_HFlipped || m_VFlipped) { BITMAP* flipBitmap = create_bitmap_ex(8, bitmapToDraw->w, bitmapToDraw->h); diff --git a/Source/System/GraphicalPrimitive.h b/Source/System/GraphicalPrimitive.h index f074a86a10..cfd49285b2 100644 --- a/Source/System/GraphicalPrimitive.h +++ b/Source/System/GraphicalPrimitive.h @@ -537,49 +537,86 @@ namespace RTE { float m_RotAngle = 0; //!< Angle to rotate bitmap in radians. bool m_HFlipped = false; //!< Whether the Bitmap to draw should be horizontally flipped. bool m_VFlipped = false; //!< Whether the Bitmap to draw should be vertically flipped. + unsigned int m_Scale = 1u; /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. /// @param centerPos Position of this primitive's center. /// @param bitmap BITMAP to draw. /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) : m_Bitmap(bitmap), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; m_Player = player; + m_Scale = scale; } + /// Constructor method for BitmapPrimitive object. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param bitmap BITMAP to draw. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. + BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, bool hFlipped, bool vFlipped) : + BitmapPrimitive(player, centerPos, bitmap, rotAngle, 1u, hFlipped, vFlipped) {} + /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. /// @param centerPos Position of this primitive's center. /// @param moSprite The MOSprite to get the BITMAP to draw from. /// @param rotAngle Angle to rotate BITMAP in radians. /// @param frame Frame number of the MOSprite that will be drawn. + /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) : m_Bitmap(moSprite->GetSpriteFrame(frame)), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; m_Player = player; + m_Scale = scale; } + /// Constructor method for BitmapPrimitive object. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param moSprite The MOSprite to get the BITMAP to draw from. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param frame Frame number of the MOSprite that will be drawn. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. + BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) : + BitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1u, hFlipped, vFlipped) {} + /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. /// @param centerPos Position of this primitive's center. /// @param filePath The path to get the BITMAP to draw from. /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) : m_Bitmap(ContentFile(filePath.c_str()).GetAsBitmap()), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; m_Player = player; + m_Scale = scale; } + /// Constructor method for BitmapPrimitive object. + /// @param player Player screen to draw this primitive on. + /// @param centerPos Position of this primitive's center. + /// @param filePath The path to get the BITMAP to draw from. + /// @param rotAngle Angle to rotate BITMAP in radians. + /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. + /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. + BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) : + BitmapPrimitive(player, centerPos, filePath, rotAngle, 1u, hFlipped, vFlipped) {} private: static const PrimitiveType c_PrimitiveType; //!< Type identifier of this primitive. From dec5091cde28f36a4f9ed72a7a31b806948ec16f Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Wed, 12 Mar 2025 21:48:56 +0200 Subject: [PATCH 2/6] float the uints --- Source/Lua/LuaBindingsManagers.cpp | 16 ++++++++-------- Source/Managers/PrimitiveMan.cpp | 4 ++-- Source/Managers/PrimitiveMan.h | 20 ++++++++++---------- Source/System/GraphicalPrimitive.cpp | 6 +++--- Source/System/GraphicalPrimitive.h | 14 +++++++------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Source/Lua/LuaBindingsManagers.cpp b/Source/Lua/LuaBindingsManagers.cpp index db70412553..37be7b48a6 100644 --- a/Source/Lua/LuaBindingsManagers.cpp +++ b/Source/Lua/LuaBindingsManagers.cpp @@ -262,21 +262,21 @@ LuaBindingRegisterFunctionDefinitionForType(ManagerLuaBindings, PrimitiveMan) { .def("DrawTextPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& text, bool isSmall, int alignment)) & PrimitiveMan::DrawTextPrimitive) .def("DrawTextPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& text, bool isSmall, int alignment, float rotAngle)) & PrimitiveMan::DrawTextPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, float scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(const Vector& start, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, float scale)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) - .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) + .def("DrawBitmapPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped)) & PrimitiveMan::DrawBitmapPrimitive) .def("DrawIconPrimitive", (void(PrimitiveMan::*)(const Vector& start, Entity* entity)) & PrimitiveMan::DrawIconPrimitive) .def("DrawIconPrimitive", (void(PrimitiveMan::*)(int player, const Vector& start, Entity* entity)) & PrimitiveMan::DrawIconPrimitive) diff --git a/Source/Managers/PrimitiveMan.cpp b/Source/Managers/PrimitiveMan.cpp index 6d66c30da8..7b3df14769 100644 --- a/Source/Managers/PrimitiveMan.cpp +++ b/Source/Managers/PrimitiveMan.cpp @@ -217,11 +217,11 @@ void PrimitiveMan::DrawTextPrimitive(int player, const Vector& start, const std: SchedulePrimitive(std::make_unique(player, start, text, isSmall, alignment, rotAngle)); } -void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) { +void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped) { SchedulePrimitive(std::make_unique(player, centerPos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped)); } -void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) { +void PrimitiveMan::DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped) { SchedulePrimitive(std::make_unique(player, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped)); } diff --git a/Source/Managers/PrimitiveMan.h b/Source/Managers/PrimitiveMan.h index 19aa1a579e..3bfa9dc48d 100644 --- a/Source/Managers/PrimitiveMan.h +++ b/Source/Managers/PrimitiveMan.h @@ -317,7 +317,7 @@ namespace RTE { /// @param rotAngle Rotation angle in radians. /// @param frame Frame to draw. /// @param scale Drawing scale. - void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, scale, frame, false, false); } + void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, scale, frame, false, false); } /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. /// @param centerPos Position of primitive's center in scene coordinates. @@ -336,7 +336,7 @@ namespace RTE { /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped); } + void DrawBitmapPrimitive(const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped); } /// Schedule to draw a bitmap primitive visible only to a specified player. /// @param player Player screen to draw primitive on. @@ -353,7 +353,7 @@ namespace RTE { /// @param rotAngle Rotation angle in radians. /// @param frame Frame to draw. /// @param scale Drawing scale. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, scale, false, false); } + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, scale, false, false); } /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. @@ -363,7 +363,7 @@ namespace RTE { /// @param frame Frame to draw. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1u, false, false); } + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1.0f, false, false); } /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. @@ -374,7 +374,7 @@ namespace RTE { /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped); + void DrawBitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped); /// Schedule to draw a bitmap primitive. /// @param centerPos Position of primitive's center in scene coordinates. @@ -387,7 +387,7 @@ namespace RTE { /// @param filePath Path to the bitmap to draw. /// @param rotAngle Rotation angle in radians. /// @param scale Drawing scale. - void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, false, false); } + void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, float scale) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, false, false); } /// Schedule to draw a bitmap primitive with the option to flip the primitive horizontally and vertically. /// @param centerPos Position of primitive's center in scene coordinates. @@ -404,7 +404,7 @@ namespace RTE { /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped); } + void DrawBitmapPrimitive(const Vector& centerPos, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(-1, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped); } /// Schedule to draw a bitmap primitive visible only to a specified player. /// @param player Player screen to draw primitive on. @@ -419,7 +419,7 @@ namespace RTE { /// @param filePath Path to the bitmap to draw. /// @param rotAngle Rotation angle in radians. /// @param scale Drawing scale. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, scale, false, false); } + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, float scale) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, scale, false, false); } /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. @@ -428,7 +428,7 @@ namespace RTE { /// @param rotAngle Rotation angle in radians. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, 1u, false, false); } + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) { DrawBitmapPrimitive(player, centerPos, filePath, rotAngle, 1.0f, false, false); } /// Schedule to draw a bitmap primitive visible only to a specified player with the option to flip the primitive horizontally or vertically. /// @param player Player screen to draw primitive on. @@ -438,7 +438,7 @@ namespace RTE { /// @param scale Drawing scale. /// @param hFlipped Whether to flip the sprite horizontally. /// @param vFlipped Whether to flip the sprite vertically. - void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped); + void DrawBitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped); /// Schedule to draw the GUI icon of an object. /// @param centerPos Position of primitive's center in scene coordinates. diff --git a/Source/System/GraphicalPrimitive.cpp b/Source/System/GraphicalPrimitive.cpp index 2846b3bf24..27002d3bda 100644 --- a/Source/System/GraphicalPrimitive.cpp +++ b/Source/System/GraphicalPrimitive.cpp @@ -504,12 +504,12 @@ void BitmapPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { return; } - BITMAP* bitmapToDraw = create_bitmap_ex(8, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); + BITMAP* bitmapToDraw = create_bitmap_ex(8, (int)(m_Bitmap->w * m_Scale), (int)(m_Bitmap->h * m_Scale)); clear_to_color(bitmapToDraw, ColorKeys::g_MaskColor); - if (m_Scale == 1u) { + if (m_Scale == 1.0f) { draw_sprite(bitmapToDraw, m_Bitmap, 0, 0); } else { - stretch_sprite(bitmapToDraw, m_Bitmap, 0, 0, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); + stretch_sprite(bitmapToDraw, m_Bitmap, 0, 0, (int)(m_Bitmap->w * m_Scale), (int)(m_Bitmap->h * m_Scale)); } if (m_HFlipped || m_VFlipped) { diff --git a/Source/System/GraphicalPrimitive.h b/Source/System/GraphicalPrimitive.h index cfd49285b2..7c33858b5e 100644 --- a/Source/System/GraphicalPrimitive.h +++ b/Source/System/GraphicalPrimitive.h @@ -537,7 +537,7 @@ namespace RTE { float m_RotAngle = 0; //!< Angle to rotate bitmap in radians. bool m_HFlipped = false; //!< Whether the Bitmap to draw should be horizontally flipped. bool m_VFlipped = false; //!< Whether the Bitmap to draw should be vertically flipped. - unsigned int m_Scale = 1u; + float m_Scale = 1.0; /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. @@ -547,7 +547,7 @@ namespace RTE { /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, float scale, bool hFlipped, bool vFlipped) : m_Bitmap(bitmap), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; @@ -563,7 +563,7 @@ namespace RTE { /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, BITMAP* bitmap, float rotAngle, bool hFlipped, bool vFlipped) : - BitmapPrimitive(player, centerPos, bitmap, rotAngle, 1u, hFlipped, vFlipped) {} + BitmapPrimitive(player, centerPos, bitmap, rotAngle, 1.0f, hFlipped, vFlipped) {} /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. @@ -574,7 +574,7 @@ namespace RTE { /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, unsigned int scale, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, float scale, bool hFlipped, bool vFlipped) : m_Bitmap(moSprite->GetSpriteFrame(frame)), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; @@ -591,7 +591,7 @@ namespace RTE { /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, const MOSprite* moSprite, float rotAngle, unsigned int frame, bool hFlipped, bool vFlipped) : - BitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1u, hFlipped, vFlipped) {} + BitmapPrimitive(player, centerPos, moSprite, rotAngle, frame, 1.0f, hFlipped, vFlipped) {} /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. @@ -601,7 +601,7 @@ namespace RTE { /// @param scale BITMAP scale. /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. - BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, unsigned int scale, bool hFlipped, bool vFlipped) : + BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, float scale, bool hFlipped, bool vFlipped) : m_Bitmap(ContentFile(filePath.c_str()).GetAsBitmap()), m_RotAngle(rotAngle), m_HFlipped(hFlipped), m_VFlipped(vFlipped) { m_StartPos = centerPos; @@ -616,7 +616,7 @@ namespace RTE { /// @param hFlipped Whether the BITMAP to draw should be horizontally flipped. /// @param vFlipped Whether the BITMAP to draw should be vertically flipped. BitmapPrimitive(int player, const Vector& centerPos, const std::string& filePath, float rotAngle, bool hFlipped, bool vFlipped) : - BitmapPrimitive(player, centerPos, filePath, rotAngle, 1u, hFlipped, vFlipped) {} + BitmapPrimitive(player, centerPos, filePath, rotAngle, 1.0f, hFlipped, vFlipped) {} private: static const PrimitiveType c_PrimitiveType; //!< Type identifier of this primitive. From 26d71251d5f1ec5a32e538074d013d6f3497d765 Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Wed, 12 Mar 2025 21:52:41 +0200 Subject: [PATCH 3/6] there's always a typo --- Source/System/GraphicalPrimitive.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/System/GraphicalPrimitive.h b/Source/System/GraphicalPrimitive.h index 7c33858b5e..93c40ae08c 100644 --- a/Source/System/GraphicalPrimitive.h +++ b/Source/System/GraphicalPrimitive.h @@ -537,7 +537,7 @@ namespace RTE { float m_RotAngle = 0; //!< Angle to rotate bitmap in radians. bool m_HFlipped = false; //!< Whether the Bitmap to draw should be horizontally flipped. bool m_VFlipped = false; //!< Whether the Bitmap to draw should be vertically flipped. - float m_Scale = 1.0; + float m_Scale = 1.0f; /// Constructor method for BitmapPrimitive object. /// @param player Player screen to draw this primitive on. From f2327400fb2475aa746dfcf03bcf2a8c41200639 Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Wed, 12 Mar 2025 23:09:39 +0200 Subject: [PATCH 4/6] Update Source/System/GraphicalPrimitive.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit implicit cast Co-authored-by: Leo Göttlicher <8429918+HeliumAnt@users.noreply.github.com> --- Source/System/GraphicalPrimitive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/System/GraphicalPrimitive.cpp b/Source/System/GraphicalPrimitive.cpp index 27002d3bda..29f7fb667d 100644 --- a/Source/System/GraphicalPrimitive.cpp +++ b/Source/System/GraphicalPrimitive.cpp @@ -509,7 +509,7 @@ void BitmapPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { if (m_Scale == 1.0f) { draw_sprite(bitmapToDraw, m_Bitmap, 0, 0); } else { - stretch_sprite(bitmapToDraw, m_Bitmap, 0, 0, (int)(m_Bitmap->w * m_Scale), (int)(m_Bitmap->h * m_Scale)); + stretch_sprite(bitmapToDraw, m_Bitmap, 0, 0, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); } if (m_HFlipped || m_VFlipped) { From 182247185e414289558d3235a5f9ec6f67c7f765 Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Wed, 12 Mar 2025 23:09:53 +0200 Subject: [PATCH 5/6] Update Source/System/GraphicalPrimitive.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit implicit cast 2 Co-authored-by: Leo Göttlicher <8429918+HeliumAnt@users.noreply.github.com> --- Source/System/GraphicalPrimitive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/System/GraphicalPrimitive.cpp b/Source/System/GraphicalPrimitive.cpp index 29f7fb667d..6f19674485 100644 --- a/Source/System/GraphicalPrimitive.cpp +++ b/Source/System/GraphicalPrimitive.cpp @@ -504,7 +504,7 @@ void BitmapPrimitive::Draw(BITMAP* drawScreen, const Vector& targetPos) { return; } - BITMAP* bitmapToDraw = create_bitmap_ex(8, (int)(m_Bitmap->w * m_Scale), (int)(m_Bitmap->h * m_Scale)); + BITMAP* bitmapToDraw = create_bitmap_ex(8, m_Bitmap->w * m_Scale, m_Bitmap->h * m_Scale); clear_to_color(bitmapToDraw, ColorKeys::g_MaskColor); if (m_Scale == 1.0f) { draw_sprite(bitmapToDraw, m_Bitmap, 0, 0); From 6ebee1ab4c6ef0c9af16e8d03595b9669950f48f Mon Sep 17 00:00:00 2001 From: zomgtehderpy Date: Wed, 12 Mar 2025 23:55:09 +0200 Subject: [PATCH 6/6] one last bug fixed and changelog updated --- CHANGELOG.md | 19 +++++++++++++++++++ Source/Lua/LuaBindingsPrimitives.cpp | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 641471455f..ded0dd9ba7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - New `SceneMan` function `CastAllMOsRay(startVector, rayVector, table ignoreMOIDs, ignoreTeam, ignoreMaterial, bool ignoreAllTerrain, int skip)` which returns an iterator with pointers to all the non-ignored MOs met along the ray. +- Added scaling capability to Bitmap primitives. + New draw bindings with argument for scale are: + ``` + PrimitiveMan:DrawBitmapPrimitive(pos, moSprite, rotAngle, frame, scale) + PrimitiveMan:DrawBitmapPrimitive(pos, moSprite, rotAngle, frame, scale, bool hFlipped, bool vFlipped) + PrimitiveMan:DrawBitmapPrimitive(player, pos, moSprite, rotAngle, frame, scale) + PrimitiveMan:DrawBitmapPrimitive(player, pos, moSprite, rotAngle, frame, scale, bool hFlipped, bool vFlipped) + PrimitiveMan:DrawBitmapPrimitive(pos, filePath, rotAngle, scale) + PrimitiveMan:DrawBitmapPrimitive(pos, filePath, rotAngle, scale, bool hFlipped, bool vFlipped) + PrimitiveMan:DrawBitmapPrimitive(player, pos, filePath, rotAngle, scale) + PrimitiveMan:DrawBitmapPrimitive(player, pos, filePath, rotAngle, scale, bool hFlipped, bool vFlipped) + ``` + As well as constructors: + ``` + BitmapPrimitive(player, pos, moSprite, rotAngle, frame, scale, hFlipped, vFlipped) + BitmapPrimitive(player, pos, filePath, rotAngle, scale, hFlipped, vFlipped) + ``` + Original bindings with no scale argument are untouched and can be called as they were. +
Changed diff --git a/Source/Lua/LuaBindingsPrimitives.cpp b/Source/Lua/LuaBindingsPrimitives.cpp index 9352f0c2b0..3122129a26 100644 --- a/Source/Lua/LuaBindingsPrimitives.cpp +++ b/Source/Lua/LuaBindingsPrimitives.cpp @@ -95,8 +95,8 @@ LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TextPrimitive) LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BitmapPrimitive) { return luabind::class_("BitmapPrimitive") - .def(luabind::constructor()) - .def(luabind::constructor()) + .def(luabind::constructor()) + .def(luabind::constructor()) .def(luabind::constructor()) .def(luabind::constructor()); }