Support placefile icon modulate with "scwx-ModulateIcon:" statement

This commit is contained in:
Dan Paulat 2023-09-09 16:00:19 -05:00
parent 1a9e87ba07
commit 2f41993d7b
3 changed files with 34 additions and 17 deletions

View file

@ -488,11 +488,11 @@ void PlacefileIcons::Impl::UpdateBuffers()
units::angle::degrees<float> angle = di->angle_;
const float a = angle.value();
// Fixed modulate color
const float mc0 = 1.0f;
const float mc1 = 1.0f;
const float mc2 = 1.0f;
const float mc3 = 1.0f;
// Modulate color
const float mc0 = di->modulate_[0] / 255.0f;
const float mc1 = di->modulate_[1] / 255.0f;
const float mc2 = di->modulate_[2] / 255.0f;
const float mc3 = di->modulate_[3] / 255.0f;
newIconBuffer_.insert(newIconBuffer_.end(),
{

View file

@ -81,14 +81,15 @@ public:
{
IconDrawItem() { itemType_ = ItemType::Icon; }
double latitude_ {};
double longitude_ {};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::size_t fileNumber_ {0u};
std::size_t iconNumber_ {0u};
std::string hoverText_ {};
boost::gil::rgba8_pixel_t modulate_ {};
double latitude_ {};
double longitude_ {};
double x_ {};
double y_ {};
units::degrees<double> angle_ {};
std::size_t fileNumber_ {0u};
std::size_t iconNumber_ {0u};
std::string hoverText_ {};
};
struct TextDrawItem : DrawItem

View file

@ -68,9 +68,10 @@ public:
std::chrono::seconds refresh_ {-1};
// Parsing state
units::length::nautical_miles<double> threshold_ {999.0_nmi};
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
ColorMode colorMode_ {ColorMode::RGBA};
units::length::nautical_miles<double> threshold_ {999.0_nmi};
boost::gil::rgba8_pixel_t color_ {255, 255, 255, 255};
boost::gil::rgba8_pixel_t iconModulate_ {255, 255, 255, 255};
ColorMode colorMode_ {ColorMode::RGBA};
std::chrono::sys_time<std::chrono::seconds> startTime_ {};
std::chrono::sys_time<std::chrono::seconds> endTime_ {};
@ -242,6 +243,8 @@ void Placefile::Impl::ProcessLine(const std::string& line)
static const std::string imageKey_ {"Image:"};
static const std::string polygonKey_ {"Polygon:"};
static const std::string scwxModulateIconKey_ {"scwx-ModulateIcon:"};
currentStatement_ = DrawingStatement::Standard;
// When tokenizing, add one additional delimiter to discard unexpected
@ -338,6 +341,18 @@ void Placefile::Impl::ProcessLine(const std::string& line)
color_ = ParseColor(tokenList, 0, colorMode_);
}
}
else if (boost::istarts_with(line, scwxModulateIconKey_))
{
// Supercell Wx Extension
// scwx-ModulateIcon: red green blue [alpha]
std::vector<std::string> tokenList = util::ParseTokens(
line, {" ", " ", " ", " "}, scwxModulateIconKey_.size());
if (tokenList.size() >= 3)
{
iconModulate_ = ParseColor(tokenList, 0, colorMode_);
}
}
else if (boost::istarts_with(line, refreshKey_))
{
// Refresh: minutes
@ -433,6 +448,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
di->threshold_ = threshold_;
di->startTime_ = startTime_;
di->endTime_ = endTime_;
di->modulate_ = iconModulate_;
ParseLocation(tokenList[0],
tokenList[1],
@ -686,7 +702,7 @@ void Placefile::Impl::ProcessLine(const std::string& line)
}
else
{
logger_->warn("Unknown statement: {}", line);
logger_->trace("Unknown statement: {}", line);
}
}