diff --git a/Source/UI/UIBarGraph.cpp b/Source/UI/UIBarGraph.cpp index 121d8816..07a36f21 100644 --- a/Source/UI/UIBarGraph.cpp +++ b/Source/UI/UIBarGraph.cpp @@ -1,4 +1,12 @@ #include "UI/UIBarGraph.h" +#include "Resource/Bitmap/BitmapResource.h" +#include "Resource/ResourceMgr.h" +#include "Resource/SkinPalette.h" +#include "Resource/TextureNames.h" +#include "Utility/Text/FormatString.h" + +#include +#include // OFFSET: 0x0086C310 // FUNCTION: fn_11024 @@ -18,6 +26,147 @@ UIBarGraph3::~UIBarGraph3() = default; // FUNCTION: fn_11098 UIBarGraphPlayer::~UIBarGraphPlayer() = default; +// OFFSET: 0x00887600 +// FUNCTION: fn_11338 +void UIBarGraph4::Paint() { + if (!this->m_current || !this->m_maximum || *this->m_maximum < *this->m_current) { + return; + } + + unsigned red, green, blue; + SkinPaletteChannels(ResourceMgr::Instance(), 26, 2, red, green, blue); + this->ClearSurface(RGB(red, green, green)); + SkinPaletteChannels(ResourceMgr::Instance(), 30, 2, red, green, blue); + this->FillRegion(1, 1, this->geometry.width - 2, this->geometry.height - 2, RGB(red, green, blue)); + + if (*this->m_maximum == 0) { + return; + } + + const float ratio = static_cast(*this->m_current) / static_cast(*this->m_maximum); + if (ratio == 0.0f) { + return; + } + + SkinPaletteChannels(ResourceMgr::Instance(), 2, 6, red, green, blue); + if (!this->m_plainColor && ratio * 100.0f < 25.0f) { + red = 255; + green = 0; + blue = 0; + } + this->FillRegion(1, 1, static_cast(static_cast(this->geometry.width - 2) * ratio), this->geometry.height - 2, RGB(red, green, blue)); +} + +// OFFSET: 0x00887790 +// FUNCTION: fn_11339 +void UIBarGraph::Paint() { + this->DrawBitmap(0, 0, &static_cast(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\basic_interface\\gze_bg.bmp")))->image, false); + if (this->m_value == 0.0f) { + return; + } + + const std::string color = this->m_value >= 25.0f ? "blue" : "red"; + const int fill = (this->geometry.width - 8) * static_cast(this->m_value) / 100; + + const auto* left = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_left.bmp").c_str()))); + this->DrawBitmap(0, 0, &left->image, true); + + const auto* middle = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_mid.bmp").c_str()))); + for (int x = 0; x < fill; ++x) { + this->DrawBitmap(x + 4, 0, &middle->image, true); + } + + const auto* right = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_right.bmp").c_str()))); + this->DrawBitmap(fill + 4, 0, &right->image, true); +} + +// OFFSET: 0x00887CB0 +// FUNCTION: fn_11340 +void UIBarGraphHomun::Paint() { + if (!this->m_current || !this->m_maximum) { + return; + } + + const std::int64_t current = this->m_current(); + const std::int64_t maximum = this->m_maximum(); + if (current > maximum) { + return; + } + + this->ClearSurface(0xFFFF00FF); + const auto* backLeft = static_cast(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\basic_interface\\gze_bg_left.bmp"))); + const auto* backMiddle = static_cast(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\basic_interface\\gze_bg_mid.bmp"))); + const auto* backRight = static_cast(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\basic_interface\\gze_bg_right.bmp"))); + if (backLeft && backMiddle && backRight) { + this->DrawBitmap(0, 0, &backLeft->image, false); + for (std::int64_t x = 0; x < this->geometry.width - backLeft->image.width - backRight->image.width; ++x) { + this->DrawBitmap(static_cast(x) + backLeft->image.width, 0, &backMiddle->image, false); + } + this->DrawBitmap(this->geometry.width - backRight->image.width, 0, &backRight->image, false); + } + + if (maximum == 0) { + return; + } + + const double ratio = static_cast(current) / static_cast(maximum); + if (ratio == 0.0) { + return; + } + + const std::string color = ratio < 0.25 ? "red" : "blue"; + const int fill = static_cast(static_cast(this->geometry.width - 8) * ratio); + + const auto* left = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_left.bmp").c_str()))); + this->DrawBitmap(0, 0, &left->image, true); + + const auto* middle = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_mid.bmp").c_str()))); + for (int x = 0; x < fill; ++x) { + this->DrawBitmap(x + 4, 0, &middle->image, true); + } + + const auto* right = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_right.bmp").c_str()))); + this->DrawBitmap(fill + 4, 0, &right->image, true); + + this->DrawCenteredText(0, -2, FormatOwnedString("%3I64d / %3I64d", current, maximum).c_str(), this->geometry.width, 1, 13, 0, 0); +} + +// OFFSET: 0x008882C0 +// FUNCTION: fn_11341 +void UIBarGraphPlayer::Paint() { + if (!this->m_current || !this->m_maximum) { + return; + } + + const std::int64_t current = this->m_current(); + const std::int64_t maximum = this->m_maximum(); + if (current > maximum) { + return; + } + + this->DrawBitmap(0, 0, &static_cast(ResourceMgr::Instance().Load(Resolve("유저인터페이스\\basic_interface\\gze_bg1.bmp")))->image, false); + if (maximum == 0) { + return; + } + + const double ratio = static_cast(current) / static_cast(maximum); + const std::string color = ratio < 0.25 ? "red" : "blue"; + const int fill = static_cast(static_cast(this->geometry.width - 8) * ratio); + + const auto* left = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_left.bmp").c_str()))); + this->DrawBitmap(0, 0, &left->image, true); + + const auto* middle = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_mid.bmp").c_str()))); + for (int x = 0; x < fill; ++x) { + this->DrawBitmap(x + 4, 0, &middle->image, true); + } + + const auto* right = static_cast(ResourceMgr::Instance().Load(Resolve(("유저인터페이스\\basic_interface\\gze" + color + "_right.bmp").c_str()))); + this->DrawBitmap(fill + 4, 0, &right->image, true); + + this->DrawCenteredText(0, -2, FormatOwnedString("%3I64d / %3I64d", current, maximum).c_str(), this->geometry.width, 1, 13, 0, 0); +} + // OFFSET: 0x0089CDB0 // FUNCTION: fn_11593 void UIBarGraphHomun::SetValues(std::function current, std::function maximum) { diff --git a/Source/UI/UIBarGraph.h b/Source/UI/UIBarGraph.h index ee5b9fea..44529552 100644 --- a/Source/UI/UIBarGraph.h +++ b/Source/UI/UIBarGraph.h @@ -10,6 +10,8 @@ struct UIButtonContext; class UIBarGraph : public UIWindow { public: + void Paint() override; + void SetValue(float value); /* 007C */ float m_value; @@ -22,6 +24,7 @@ public: class UIBarGraph4 : public UIBarGraph3 { public: + void Paint() override; void Slot28(int x, int y) override; void SetValues(const int* current, const int* maximum); @@ -29,6 +32,7 @@ public: protected: /* 007C */ const int* m_current; /* 0080 */ const int* m_maximum; + /* 0084 */ bool m_plainColor; UIButtonContext* m_controls; }; @@ -58,6 +62,8 @@ class UIBarGraphHomun : public UIWindow { public: explicit UIBarGraphHomun(UIWindowContext& context); + void Paint() override; + void SetValues(std::function current, std::function maximum); protected: @@ -70,6 +76,8 @@ public: explicit UIBarGraphPlayer(UIWindowContext& context); ~UIBarGraphPlayer() override; + void Paint() override; + void SetValues(std::function current, std::function maximum); protected: