-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement weapon reload sound visualization
- Loading branch information
1 parent
5d37b05
commit 0faa727
Showing
8 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ enum class HudInWorldPanelZOrder { | |
Footstep, | ||
BombBeep, | ||
WeaponScope, | ||
WeaponReload, | ||
BombPlant, | ||
BombDefuse | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include <algorithm> | ||
#include <cassert> | ||
#include <string_view> | ||
|
||
#include <CS2/Constants/SoundNames.h> | ||
|
||
struct WeaponReloadSound { | ||
static constexpr auto kFadeAwayStart = 1.8f; | ||
static constexpr auto kFadeAwayDuration = 0.8f; | ||
static constexpr auto kMinScale = 0.5f; | ||
|
||
[[nodiscard]] static constexpr bool isSound(std::string_view soundName) noexcept | ||
{ | ||
return soundName.starts_with(cs2::kWeaponSoundsPath) && (soundName.ends_with(cs2::kClipOutSoundSuffix) || soundName.ends_with(cs2::kCoverUpSoundSuffix)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#pragma once | ||
|
||
#include <CS2/Classes/Panorama.h> | ||
#include <FeatureHelpers/HudInWorldPanelFactory.h> | ||
#include <FeatureHelpers/HudInWorldPanelZOrder.h> | ||
#include <FeatureHelpers/Sound/WeaponReloadSound.h> | ||
#include <FeatureHelpers/Sound/SoundVisualizationFeature.h> | ||
#include <GameClasses/PanoramaUiEngine.h> | ||
|
||
struct WeaponReloadPanels { | ||
[[nodiscard]] static cs2::CPanel2D* createContainerPanel(const HudInWorldPanelFactory& inWorldFactory) noexcept | ||
{ | ||
return inWorldFactory.createPanel("WeaponReloadContainer", HudInWorldPanelZOrder::WeaponReload); | ||
} | ||
|
||
static void createContentPanels(cs2::CUIPanel& containerPanel) noexcept | ||
{ | ||
for (std::size_t i = 0; i < kMaxNumberOfPanels; ++i) { | ||
PanoramaUiEngine::runScript(&containerPanel, | ||
R"( | ||
(function() { | ||
var weaponReloadPanel = $.CreatePanel('Panel', $.GetContextPanel().FindChildInLayoutFile("WeaponReloadContainer"), '', { | ||
style: 'width: 100px; height: 100px; x: -50px; y: -50px;' | ||
}); | ||
$.CreatePanel('Image', weaponReloadPanel, '', { | ||
src: "s2r://panorama/images/icons/ui/switch_teams_dead.svg", | ||
style: "horizontal-align: center; vertical-align: center; img-shadow: 0px 0px 1px 3 #000000;" | ||
}); | ||
})();)", "", 0); | ||
} | ||
} | ||
|
||
static constexpr auto kMaxNumberOfPanels = 10; | ||
}; | ||
|
||
using WeaponReloadVisualizer = SoundVisualizationFeature<WeaponReloadPanels, WeaponReloadSound>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters