summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Romeo <vittorio.romeo@outlook.com>2021-10-31 18:05:38 +0000
committerVittorio Romeo <vittorio.romeo@outlook.com>2021-10-31 18:05:38 +0000
commit883128647504d4fe2bbd837fa82960c7d36131a6 (patch)
treef30411bade5345c3d4dc4a1a009b334a9c94620f
parentc2462c5d53f7f6a691192b6ee093b9598db15ab6 (diff)
Flash effect color can now be changed
-rw-r--r--src/SSVOpenHexagon/Core/HGGraphics.cpp19
-rw-r--r--src/SSVOpenHexagon/Core/HGScripting.cpp8
2 files changed, 19 insertions, 8 deletions
diff --git a/src/SSVOpenHexagon/Core/HGGraphics.cpp b/src/SSVOpenHexagon/Core/HGGraphics.cpp
index 7a085104..95abd3a2 100644
--- a/src/SSVOpenHexagon/Core/HGGraphics.cpp
+++ b/src/SSVOpenHexagon/Core/HGGraphics.cpp
@@ -11,6 +11,7 @@
#include "SSVOpenHexagon/Components/CWall.hpp"
#include "SSVStart/Utils/SFML.hpp"
+#include <SFML/Config.hpp>
#include <imgui.h>
#include <imgui-SFML.h>
@@ -288,22 +289,24 @@ void HexagonGame::drawImguiLuaConsole()
ImGui::SFML::Render(*window);
}
-void HexagonGame::initFlashEffect()
+void HexagonGame::initFlashEffect(int r, int g, int b)
{
flashPolygon.clear();
- flashPolygon.emplace_back(
- sf::Vector2f{-100.f, -100.f}, sf::Color{255, 255, 255, 0});
+ const sf::Color color{static_cast<sf::Uint8>(r), static_cast<sf::Uint8>(g),
+ static_cast<sf::Uint8>(b), 0};
+
+ flashPolygon.emplace_back(sf::Vector2f{-100.f, -100.f}, color);
- flashPolygon.emplace_back(sf::Vector2f{Config::getWidth() + 100.f, -100.f},
- sf::Color{255, 255, 255, 0});
+ flashPolygon.emplace_back(
+ sf::Vector2f{Config::getWidth() + 100.f, -100.f}, color);
flashPolygon.emplace_back(
sf::Vector2f{Config::getWidth() + 100.f, Config::getHeight() + 100.f},
- sf::Color{255, 255, 255, 0});
+ color);
- flashPolygon.emplace_back(sf::Vector2f{-100.f, Config::getHeight() + 100.f},
- sf::Color{255, 255, 255, 0});
+ flashPolygon.emplace_back(
+ sf::Vector2f{-100.f, Config::getHeight() + 100.f}, color);
}
void HexagonGame::drawKeyIcons()
diff --git a/src/SSVOpenHexagon/Core/HGScripting.cpp b/src/SSVOpenHexagon/Core/HGScripting.cpp
index 4268294e..10715391 100644
--- a/src/SSVOpenHexagon/Core/HGScripting.cpp
+++ b/src/SSVOpenHexagon/Core/HGScripting.cpp
@@ -61,6 +61,14 @@ void HexagonGame::initLua_Utils()
.arg("value")
.doc("Flash the screen with `$0` intensity (from 0 to 255).");
+ addLuaFn(lua, "u_setFlashColor", //
+ [this](int r, int g, int b) { initFlashEffect(r, g, b); })
+ .arg("r")
+ .arg("g")
+ .arg("b")
+ .doc("Set the color of the flash effect to `{$0, $1, $2}`.");
+ // ------------------------------------------------------------------------
+
addLuaFn(lua, "u_log", //
[this](const std::string& mLog)
{