mirror of
https://github.com/rosebudai/OpenRCT2-Web.git
synced 2026-12-05 12:45:14 +01:00
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
/*****************************************************************************
|
|
* Copyright (c) 2014-2025 OpenRCT2 developers
|
|
*
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
|
*
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
*****************************************************************************/
|
|
|
|
#include "ColourWithFlags.h"
|
|
|
|
namespace OpenRCT2
|
|
{
|
|
static constexpr uint8_t kLegacyColourMaskBase = 0x1F;
|
|
static constexpr uint8_t kLegacyColourFlagOutline = (1 << 5);
|
|
static constexpr uint8_t kLegacyColourFlagInset = (1 << 6);
|
|
|
|
ColourWithFlags ColourWithFlags::withFlag(ColourFlag flag, bool on) const
|
|
{
|
|
struct ColourWithFlags result = *this;
|
|
result.flags.set(flag, on);
|
|
return result;
|
|
}
|
|
|
|
ColourWithFlags ColourWithFlags::fromLegacy(uint8_t legacy)
|
|
{
|
|
ColourWithFlags result{};
|
|
result.colour = legacy & kLegacyColourMaskBase;
|
|
if (legacy & kLegacyColourFlagTranslucent)
|
|
result.flags.set(ColourFlag::translucent);
|
|
if (legacy & kLegacyColourFlagInset)
|
|
result.flags.set(ColourFlag::inset);
|
|
if (legacy & kLegacyColourFlagOutline)
|
|
result.flags.set(ColourFlag::withOutline);
|
|
|
|
return result;
|
|
}
|
|
|
|
ColourWithFlags& ColourWithFlags::operator=(colour_t rhs)
|
|
{
|
|
colour = rhs;
|
|
flags = {};
|
|
return *this;
|
|
}
|
|
} // namespace OpenRCT2
|