Skip to content

Commit e1e83d9

Browse files
Merge PanoramaImagePanelContext with PanoramaImagePanel
1 parent 07b7e01 commit e1e83d9

File tree

4 files changed

+13
-51
lines changed

4 files changed

+13
-51
lines changed

Source/GameClient/Panorama/PanoramaImagePanel.h

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,36 @@
1010
#include <CS2/Panorama/CImagePanel.h>
1111
#include <MemoryPatterns/PatternTypes/PanoramaImagePanelPatternTypes.h>
1212

13-
#include "PanoramaImagePanelContext.h"
14-
1513
struct SvgImageParams {
1614
const char* imageUrl;
1715
int textureHeight{-1};
1816
std::optional<cs2::Color> fillColor{};
1917
};
2018

21-
template <typename HookContext, typename Context = PanoramaImagePanelContext<HookContext>>
19+
template <typename HookContext>
2220
struct PanoramaImagePanel {
2321
using RawType = cs2::CImagePanel;
2422

25-
template <typename... Args>
26-
requires std::is_constructible_v<Context, Args...>
27-
PanoramaImagePanel(Args&&... args) noexcept
28-
: context{std::forward<Args>(args)...}
23+
PanoramaImagePanel(HookContext& hookContext, cs2::CImagePanel* panel) noexcept
24+
: hookContext{hookContext}
25+
, panel{panel}
2926
{
3027
}
3128

3229
[[nodiscard]] decltype(auto) uiPanel() const noexcept
3330
{
34-
return context.uiPanel();
31+
return hookContext.uiPanel(panel ? panel->uiPanel : nullptr);
3532
}
3633

3734
[[nodiscard]] cs2::ImageProperties* getImageProperties() const noexcept
3835
{
39-
return context.hookContext.patternSearchResults().template get<ImagePropertiesOffset>().of(context.panel).get();
36+
return hookContext.patternSearchResults().template get<ImagePropertiesOffset>().of(panel).get();
4037
}
4138

4239
[[nodiscard]] std::string_view getImagePath() const noexcept
4340
{
44-
if (auto&& imagePath = context.getImagePath())
45-
return imagePath;
41+
if (auto&& imagePath = hookContext.patternSearchResults().template get<OffsetToImagePath>().of(panel).get(); imagePath && imagePath->m_pString)
42+
return imagePath->m_pString;
4643
return {};
4744
}
4845

@@ -53,9 +50,6 @@ struct PanoramaImagePanel {
5350

5451
void setImageSvg(const SvgImageParams& params) const noexcept
5552
{
56-
if (context.panel == nullptr)
57-
return;
58-
5953
const auto properties{getImageProperties()};
6054
if (!properties)
6155
return;
@@ -68,17 +62,18 @@ struct PanoramaImagePanel {
6862
properties->presentSvgAttributes |= 1 << static_cast<std::size_t>(cs2::SvgAttributeType::FillColor);
6963
}
7064

71-
if (context.hookContext.patternSearchResults().template get<SetImageFunctionPointer>())
72-
context.hookContext.patternSearchResults().template get<SetImageFunctionPointer>()(context.panel, params.imageUrl, nullptr, properties);
65+
if (hookContext.patternSearchResults().template get<SetImageFunctionPointer>())
66+
hookContext.patternSearchResults().template get<SetImageFunctionPointer>()(panel, params.imageUrl, nullptr, properties);
7367
}
7468

7569
private:
7670
[[nodiscard]] decltype(auto) uiScaleFactor() const
7771
{
78-
const auto scale = context.uiPanel().getUiScaleFactor().valueOr(1.0f);
72+
const auto scale = uiPanel().getUiScaleFactor().valueOr(1.0f);
7973
assert(scale >= 0.1f && scale <= 10.0f && "Invalid UI scale factor");
8074
return scale;
8175
}
8276

83-
Context context;
77+
HookContext& hookContext;
78+
cs2::CImagePanel* panel;
8479
};

Source/GameClient/Panorama/PanoramaImagePanelContext.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

Source/Osiris.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@
321321
<ClInclude Include="GameClient\Panorama\PanelStylePropertyFactory.h" />
322322
<ClInclude Include="GameClient\Panorama\PanoramaDropDown.h" />
323323
<ClInclude Include="GameClient\Panorama\PanoramaImagePanel.h" />
324-
<ClInclude Include="GameClient\Panorama\PanoramaImagePanelContext.h" />
325324
<ClInclude Include="GameClient\Panorama\PanoramaLabel.h" />
326325
<ClInclude Include="GameClient\Panorama\PanoramaSymbols.h" />
327326
<ClInclude Include="GameClient\Panorama\PanoramaTransformations.h" />

Source/Osiris.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,9 +1571,6 @@
15711571
<ClInclude Include="GameClient\Panorama\PanoramaImagePanel.h">
15721572
<Filter>GameClient\Panorama</Filter>
15731573
</ClInclude>
1574-
<ClInclude Include="GameClient\Panorama\PanoramaImagePanelContext.h">
1575-
<Filter>GameClient\Panorama</Filter>
1576-
</ClInclude>
15771574
<ClInclude Include="GameClient\Panorama\PanoramaLabel.h">
15781575
<Filter>GameClient\Panorama</Filter>
15791576
</ClInclude>

0 commit comments

Comments
 (0)