From a72b865dc99367100a755a28596ccd917214ee73 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 24 May 2024 22:06:48 -0500 Subject: [PATCH] [studio/modlib] Add function for exporting selection color --- .../core/include/nostalgia/core/color.hpp | 3 ++- .../studio/tilesheeteditor/tilesheetpixels.cpp | 5 +---- .../studio/modlib/include/studio/color.hpp | 17 +++++++++++++++++ .../studio/modlib/include/studio/studio.hpp | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/olympic/studio/modlib/include/studio/color.hpp diff --git a/src/nostalgia/modules/core/include/nostalgia/core/color.hpp b/src/nostalgia/modules/core/include/nostalgia/core/color.hpp index b780672f..b86c4f67 100644 --- a/src/nostalgia/modules/core/include/nostalgia/core/color.hpp +++ b/src/nostalgia/modules/core/include/nostalgia/core/color.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include namespace nostalgia::core { @@ -135,7 +136,7 @@ constexpr Color16 color16(int r, int g, int b, int a = 0) noexcept { return static_cast(ox::min(static_cast(r), 31)) | static_cast(ox::min(static_cast(g), 31) << 5) | static_cast(ox::min(static_cast(b), 31) << 10) - | static_cast(a << 15); + | static_cast(a << 15); } [[nodiscard]] diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp index 1185f2f0..3fe6e0af 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheetpixels.cpp @@ -139,10 +139,7 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept { return; } if (m_model.pixelSelected(i)) { - auto const r = red16(color) / 2; - auto const g = (green16(color) + 20) / 2; - auto const b = (blue16(color) + 31) / 2; - color = color16(r, g, b); + color = studio::applySelectionColor(color); } setPixelBufferObject(paneSize, static_cast(i * VertexVboRows), fx, fy, color, vbo, ebo); }); diff --git a/src/olympic/studio/modlib/include/studio/color.hpp b/src/olympic/studio/modlib/include/studio/color.hpp new file mode 100644 index 00000000..2e117eaa --- /dev/null +++ b/src/olympic/studio/modlib/include/studio/color.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +namespace studio { + +[[nodiscard]] +constexpr nostalgia::core::Color16 applySelectionColor( + nostalgia::core::Color16 const color) noexcept { + namespace core = nostalgia::core; + auto const r = core::red16(color) / 2; + auto const g = (core::green16(color) + 20) / 2; + auto const b = (core::blue16(color) + 31) / 2; + return core::color16(r, g, b); +} + +} \ No newline at end of file diff --git a/src/olympic/studio/modlib/include/studio/studio.hpp b/src/olympic/studio/modlib/include/studio/studio.hpp index 9e47156a..fd9c0ea5 100644 --- a/src/olympic/studio/modlib/include/studio/studio.hpp +++ b/src/olympic/studio/modlib/include/studio/studio.hpp @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include