Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/flarialmc/dll
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvin1663 committed Aug 4, 2024
2 parents c8e2f10 + 1408194 commit 37a7a05
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
16 changes: 14 additions & 2 deletions src/Client/GUI/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ std::unordered_map<std::string, ID2D1Image *> FlarialGUI::cachedBitmaps;
LRUCache<uint64_t, winrt::com_ptr<IDWriteTextLayout>> FlarialGUI::textLayoutCache(4000);
LRUCache<UINT32, winrt::com_ptr<IDWriteTextFormat>> FlarialGUI::textFormatCache(300);

LRUCache<std::wstring, std::string> FlarialGUI::fromWideCache(4000);
LRUCache<std::string, std::wstring> FlarialGUI::toWideCache(4000);

std::unordered_map<int, float> FlarialGUI::additionalY;
//std::unordered_map<std::string, winrt::com_ptr<ID2D1GradientStopCollection>> FlarialGUI::gradientStopCache;
LRUCache<uint64_t, winrt::com_ptr<ID2D1LinearGradientBrush>> FlarialGUI::gradientBrushCache(300);
Expand Down Expand Up @@ -296,13 +299,17 @@ uint64_t generateUniqueLinearGradientBrushKey(float x, float hexPreviewSize, flo
return combinedHash;
}

std::string FlarialGUI::WideToNarrow(const std::wstring& wideStr) {
std::string WideToNarrow_creator(const std::wstring& wideStr) {
int narrowStrLen = WideCharToMultiByte(CP_UTF8, 0, wideStr.c_str(), -1, nullptr, 0, nullptr, nullptr);
std::vector<char> narrowStr(narrowStrLen);
WideCharToMultiByte(CP_UTF8, 0, wideStr.c_str(), -1, narrowStr.data(), narrowStrLen, nullptr, nullptr);
return std::string(narrowStr.data());
}

std::string FlarialGUI::WideToNarrow(const std::wstring& wideStr) {
return fromWideCache.getOrInsert(WideToNarrow_creator, wideStr, wideStr);
}

bool FlarialGUI::CursorInRect(float rectX, float rectY, float width, float height) {
if (MC::mousePos.x >= rectX && MC::mousePos.x <= rectX + width && MC::mousePos.y >= rectY &&
MC::mousePos.y <= rectY + height) {
Expand Down Expand Up @@ -1501,14 +1508,19 @@ void FlarialGUI::CopyBitmap(ID2D1Bitmap1 *from, ID2D1Bitmap **to) {
(*to)->CopyFromBitmap(&destPoint, from, &rect);
}

std::wstring FlarialGUI::to_wide(const std::string &str) {
std::wstring to_wide_creator(const std::string &str) {

int wchars_num = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, nullptr, 0);
std::wstring wide;
wide.resize(wchars_num);
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, &wide[0], wchars_num);
return wide;
}

std::wstring FlarialGUI::to_wide(const std::string &str) {
return toWideCache.getOrInsert(to_wide_creator, str, str);
}

template<typename T>
void FlarialGUI::lerp(T &a, const T &b, float t) {
if (!Client::settings.getSettingByName<bool>("disableanims")->value) {
Expand Down
2 changes: 2 additions & 0 deletions src/Client/GUI/Engine/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ namespace FlarialGUI {
extern LRUCache<UINT32, winrt::com_ptr<ID2D1SolidColorBrush>> brushCache;
extern LRUCache<uint64_t, winrt::com_ptr<IDWriteTextLayout>> textLayoutCache;
extern LRUCache<UINT32, winrt::com_ptr<IDWriteTextFormat>> textFormatCache;
extern LRUCache<std::wstring, std::string> fromWideCache;
extern LRUCache<std::string, std::wstring> toWideCache;
//extern std::unordered_map<std::string, winrt::com_ptr<ID2D1GradientStopCollection>> gradientStopCache;
extern LRUCache<uint64_t, winrt::com_ptr<ID2D1LinearGradientBrush>> gradientBrushCache;

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Module/Modules/ClickGUI/ClickGUIRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ClickGUIRenderer : public Listener {

}

//Blur::RenderBlur(event.RTV, 3, realBlurAmount/4);
Blur::RenderBlur(event.RTV, 3, realBlurAmount/4);

float baseHeight = Constraints::RelativeConstraint(baseHeightReal);

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Module/Modules/ComboCounter/ComboCounter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ComboCounter : public Module {
FlarialGUI::ScrollBar(toggleX, toggleY, 140, Constraints::SpacingConstraint(5.5, scrollviewWidth), 2);
FlarialGUI::SetScrollView(toggleX, Constraints::PercentageConstraint(0.00, "top"),
Constraints::RelativeConstraint(1.0, "width"),
Constraints::RelativeConstraint(1.0f, "height"));
Constraints::RelativeConstraint(0.88f, "height"));

this->addHeader("Module UI");
this->addSlider("UI Scale", "", this->settings.getSettingByName<float>("uiscale")->value, 2.f);
Expand Down

0 comments on commit 37a7a05

Please sign in to comment.