Skip to content

Commit

Permalink
Adjust bomb defuse alert appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Jan 10, 2025
1 parent 2a628b0 commit ad5aa75
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 16 deletions.
54 changes: 38 additions & 16 deletions Source/Features/Hud/DefusingAlert/DefusingAlertContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "DefusingAlertCondition.h"
#include "DefusingAlertPanel.h"
#include "DefusingAlertPanelParams.h"
#include "DefusingAlertState.h"
#include "DefusingCountdownTextPanel.h"

Expand Down Expand Up @@ -73,18 +74,8 @@ class DefusingAlertContext {
uiEngine().runScript(hudTeamCounter,
R"(
(function() {
var defusingAlertContainer = $.CreatePanel('Panel', $.GetContextPanel().FindChildInLayoutFile('ScoreAndTimeAndBomb'), 'DefusingAlertContainer', {
style: 'y: 100px; width: 100%; height: 35px; border-radius: 3px; world-blur: hudWorldBlur; background-image: url( "s2r://panorama/images/backgrounds/bluedots_large_png.vtex"); background-size: auto 390px; background-img-opacity: 0.04; margin: 0px 2px; background-color: #0000007f;'
});
$.CreatePanel('Image', defusingAlertContainer , '', {
src: "s2r://panorama/images/icons/equipment/defuser.vsvg",
style: "x: 10px; width: 25px; height: 25px; vertical-align: center; wash-color: rgb(119, 221, 255);"
});
$.CreatePanel('Label', defusingAlertContainer , 'DefusingAlertTimer', {
class: 'additive stratum-bold-tf',
style: 'x: 42px; font-size: 22px; vertical-align: center; margin-top: 2px; color: white;',
text: '5.0'
$.CreatePanel('Panel', $.GetContextPanel().FindChildInLayoutFile('ScoreAndTimeAndBomb'), 'DefusingAlertContainer', {
style: 'border-radius: 3px; world-blur: hudWorldBlur; background-image: url( "s2r://panorama/images/backgrounds/bluedots_large_png.vtex"); background-size: auto 390px; background-img-opacity: 0.04; background-color: #0000007f;'
});
})();
)");
Expand All @@ -93,14 +84,45 @@ class DefusingAlertContext {
if (!defusingAlertContainer)
return;

const auto defusingTimer = defusingAlertContainer.findChildInLayoutFile("DefusingAlertTimer");
if (!defusingTimer)
return;

defusingAlertContainer.setVisible(false);
defusingAlertContainer.setFlowChildren(cs2::k_EFlowRight);
defusingAlertContainer.setWidth(cs2::CUILength::percent(100));
defusingAlertContainer.setHeight(cs2::CUILength::pixels(35));
defusingAlertContainer.setPosition(cs2::CUILength::pixels(0), cs2::CUILength::pixels(100));
defusingAlertContainer.setMargin(PanelMarginParams{.marginLeft = cs2::CUILength::pixels(1), .marginRight = cs2::CUILength::pixels(1)});

createIconPanel(defusingAlertContainer);
auto&& defusingTimer = createTimerPanel(defusingAlertContainer);
state().defusingAlertContainerPanelHandle = defusingAlertContainer.getHandle();
state().defusingTimerPanelHandle = defusingTimer.getHandle();
}

decltype(auto) createIconPanel(auto&& containerPanel) const noexcept
{
using namespace defusing_alert_panel_params::defuse_icon_panel_params;

auto&& imagePanel = context.panelFactory().createImagePanel(containerPanel);
imagePanel.setImageSvg(SvgImageParams{.imageUrl = kImageUrl, .textureHeight = kTextureHeight, .fillColor = kColor});

auto&& uiPanel = imagePanel.uiPanel();
uiPanel.setAlign(kAlignment);
uiPanel.setMargin(kMargin);
return utils::lvalue<decltype(uiPanel)>(uiPanel);
}

decltype(auto) createTimerPanel(auto&& containerPanel) const noexcept
{
using namespace defusing_alert_panel_params::timer_text_panel_params;

auto&& panel = context.panelFactory().createLabelPanel(containerPanel).uiPanel();
panel.setWidth(kWidth);
panel.setFont(kFont);
panel.setMixBlendMode(kMixBlendMode);
panel.setColor(kColor);
panel.setAlign(kAlignment);
panel.setTextAlign(kTextAlign);
return utils::lvalue<decltype(panel)>(panel);
}

HookContext& context;
};
29 changes: 29 additions & 0 deletions Source/Features/Hud/DefusingAlert/DefusingAlertPanelParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include <CS2/Panorama/CUILength.h>
#include <CS2/Constants/ColorConstants.h>
#include <CS2/Panorama/StyleEnums.h>
#include <GameClasses/PanelAlignmentParams.h>
#include <GameClasses/PanelFontParams.h>
#include <GameClasses/PanelMarginParams.h>

namespace defusing_alert_panel_params::timer_text_panel_params
{
constexpr auto kWidth = cs2::CUILength::fillParentFlow(1.0f);
constexpr auto kFont = PanelFontParams{
.fontFamily = "Stratum2 Bold TF, 'Arial Unicode MS'",
.fontSize = 24};
constexpr auto kMixBlendMode = cs2::k_EMixBlendModeAdditive;
constexpr auto kColor = cs2::kColorWhite;
constexpr auto kAlignment = PanelAlignmentParams{.verticalAlignment = cs2::k_EVerticalAlignmentCenter};
constexpr auto kTextAlign = cs2::k_ETextAlignCenter;
}

namespace defusing_alert_panel_params::defuse_icon_panel_params
{
constexpr auto kImageUrl = "s2r://panorama/images/icons/equipment/defuser.vsvg";
constexpr auto kTextureHeight = 25;
constexpr auto kAlignment = PanelAlignmentParams{.verticalAlignment = cs2::k_EVerticalAlignmentCenter};
constexpr auto kColor = cs2::kColorDefuseKit;
constexpr auto kMargin = PanelMarginParams{.marginLeft = cs2::CUILength::pixels(5)};
}
1 change: 1 addition & 0 deletions Source/Osiris.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertCondition.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertContext.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertPanel.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertPanelParams.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertState.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertToggle.h" />
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertUnloadHandler.h" />
Expand Down
3 changes: 3 additions & 0 deletions Source/Osiris.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,9 @@
<ClInclude Include="UI\Panorama\SoundTab.h">
<Filter>UI\Panorama</Filter>
</ClInclude>
<ClInclude Include="Features\Hud\DefusingAlert\DefusingAlertPanelParams.h">
<Filter>Features\Hud\DefusingAlert</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="UI\Panorama\CreateGUI.js">
Expand Down

0 comments on commit ad5aa75

Please sign in to comment.