Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</details>

<details><summary><b>Changed</b></summary>
Expand Down
8 changes: 8 additions & 0 deletions Source/Lua/LuaBindingsManagers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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, 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, 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, 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, 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, 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, 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, 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)

Expand Down
2 changes: 2 additions & 0 deletions Source/Lua/LuaBindingsPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, TextPrimitive)
LuaBindingRegisterFunctionDefinitionForType(PrimitiveLuaBindings, BitmapPrimitive) {
return luabind::class_<BitmapPrimitive, GraphicalPrimitive>("BitmapPrimitive")

.def(luabind::constructor<int, const Vector&, const MOSprite*, float, unsigned int, float, bool, bool>())
.def(luabind::constructor<int, const Vector&, const std::string&, float, float, bool, bool>())
.def(luabind::constructor<int, const Vector&, const MOSprite*, float, unsigned int, bool, bool>())
.def(luabind::constructor<int, const Vector&, const std::string&, float, bool, bool>());
}
8 changes: 4 additions & 4 deletions Source/Managers/PrimitiveMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ void PrimitiveMan::DrawTextPrimitive(int player, const Vector& start, const std:
SchedulePrimitive(std::make_unique<TextPrimitive>(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<BitmapPrimitive>(player, centerPos, moSprite, rotAngle, frame, hFlipped, 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<BitmapPrimitive>(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<BitmapPrimitive>(player, centerPos, filePath, rotAngle, hFlipped, 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<BitmapPrimitive>(player, centerPos, filePath, rotAngle, scale, hFlipped, vFlipped));
}

void PrimitiveMan::DrawIconPrimitive(int player, const Vector& centerPos, Entity* entity) {
Expand Down
76 changes: 74 additions & 2 deletions Source/Managers/PrimitiveMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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.
/// @param moSprite A MOSprite to draw BITMAP from.
Expand All @@ -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, 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.
/// @param centerPos Position of primitive's center in scene coordinates.
Expand All @@ -328,22 +346,49 @@ 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, 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.
/// @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, 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.
/// @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, float scale, bool hFlipped, bool vFlipped);

/// 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.
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, 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.
/// @param filePath An entity to draw sprite from.
Expand All @@ -352,21 +397,48 @@ 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, 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.
/// @param centerPos Position of primitive's center in scene coordinates.
/// @param filePath Path to the bitmap to draw.
/// @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, 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.
/// @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, 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.
/// @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, 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.
Expand Down
8 changes: 6 additions & 2 deletions Source/System/GraphicalPrimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 == 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);
}

if (m_HFlipped || m_VFlipped) {
BITMAP* flipBitmap = create_bitmap_ex(8, bitmapToDraw->w, bitmapToDraw->h);
Expand Down
Loading