Add non default forecolor flag if forecolor is not white

This commit is contained in:
Jan 2021-12-29 18:08:38 +01:00
parent f628d33a95
commit 8e4b2bb057
4 changed files with 24 additions and 7 deletions

View File

@ -1421,8 +1421,8 @@ namespace IW4
WINDOW_FLAG_FADING_OUT = 0x10, WINDOW_FLAG_FADING_OUT = 0x10,
WINDOW_FLAG_FADING_IN = 0x20, WINDOW_FLAG_FADING_IN = 0x20,
WINDOW_FLAG_80 = 0x80, WINDOW_FLAG_80 = 0x80,
WINDOW_FLAG_SCRIPT_BACKCOLOR = 0x8000, WINDOW_FLAG_NON_DEFAULT_BACKCOLOR = 0x8000,
WINDOW_FLAG_SCRIPT_FORECOLOR = 0x10000 WINDOW_FLAG_NON_DEFAULT_FORECOLOR = 0x10000
}; };
struct windowDef_t struct windowDef_t

View File

@ -486,10 +486,10 @@ namespace IW4
if (expression == nullptr) if (expression == nullptr)
return nullptr; return nullptr;
if(expression->IsStatic()) if (expression->IsStatic())
{ {
const auto staticValue = expression->Evaluate(); const auto staticValue = expression->Evaluate();
if(staticValue.IsTruthy()) if (staticValue.IsTruthy())
item->window.dynamicFlags[0] |= WINDOW_FLAG_VISIBLE; item->window.dynamicFlags[0] |= WINDOW_FLAG_VISIBLE;
return nullptr; return nullptr;
} }
@ -852,13 +852,13 @@ namespace IW4
multiValue->count = static_cast<int>(std::min(std::extent_v<decltype(multiDef_s::dvarList)>, commonMultiValue->m_step_names.size())); multiValue->count = static_cast<int>(std::min(std::extent_v<decltype(multiDef_s::dvarList)>, commonMultiValue->m_step_names.size()));
multiValue->strDef = !commonMultiValue->m_string_values.empty() ? 1 : 0; multiValue->strDef = !commonMultiValue->m_string_values.empty() ? 1 : 0;
for(auto i = 0; i < multiValue->count; i++) for (auto i = 0; i < multiValue->count; i++)
{ {
multiValue->dvarList[i] = ConvertString(commonMultiValue->m_step_names[i]); multiValue->dvarList[i] = ConvertString(commonMultiValue->m_step_names[i]);
if(multiValue->strDef) if (multiValue->strDef)
{ {
if(commonMultiValue->m_string_values.size() > static_cast<unsigned>(i)) if (commonMultiValue->m_string_values.size() > static_cast<unsigned>(i))
multiValue->dvarStr[i] = ConvertString(commonMultiValue->m_string_values[i]); multiValue->dvarStr[i] = ConvertString(commonMultiValue->m_string_values[i]);
} }
else else
@ -917,7 +917,11 @@ namespace IW4
item->textStyle = commonItem.m_text_style; item->textStyle = commonItem.m_text_style;
item->fontEnum = ConvertTextFont(commonItem.m_text_font); item->fontEnum = ConvertTextFont(commonItem.m_text_font);
ConvertColor(item->window.backColor, commonItem.m_back_color); ConvertColor(item->window.backColor, commonItem.m_back_color);
ConvertColor(item->window.foreColor, commonItem.m_fore_color); ConvertColor(item->window.foreColor, commonItem.m_fore_color);
if (!commonItem.m_fore_color.Equals(CommonColor(1.0, 1.0, 1.0, 1.0)))
item->window.dynamicFlags[0] |= WINDOW_FLAG_NON_DEFAULT_FORECOLOR;
ConvertColor(item->window.borderColor, commonItem.m_border_color); ConvertColor(item->window.borderColor, commonItem.m_border_color);
ConvertColor(item->window.outlineColor, commonItem.m_outline_color); ConvertColor(item->window.outlineColor, commonItem.m_outline_color);
ConvertColor(item->window.disableColor, commonItem.m_disable_color); ConvertColor(item->window.disableColor, commonItem.m_disable_color);

View File

@ -1,5 +1,8 @@
#include "CommonMenuTypes.h" #include "CommonMenuTypes.h"
#include <limits>
#include <cmath>
using namespace menu; using namespace menu;
CommonColor::CommonColor() CommonColor::CommonColor()
@ -20,6 +23,14 @@ CommonColor::CommonColor(const double r, const double g, const double b, const d
this->a = a; this->a = a;
} }
bool CommonColor::Equals(const CommonColor& other) const
{
return std::fabs(this->r - other.r) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->g - other.g) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->b - other.b) < std::numeric_limits<double>::epsilon()
&& std::fabs(this->a - other.a) < std::numeric_limits<double>::epsilon();
}
CommonRect::CommonRect() CommonRect::CommonRect()
: CommonRect(0, 0, 0, 0) : CommonRect(0, 0, 0, 0)
{ {

View File

@ -15,6 +15,8 @@ namespace menu
CommonColor(); CommonColor();
CommonColor(double r, double g, double b, double a); CommonColor(double r, double g, double b, double a);
bool Equals(const CommonColor& other) const;
}; };
struct CommonRect struct CommonRect