Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Dec 21, 2023
1 parent 86cb6e7 commit ecb2231
Show file tree
Hide file tree
Showing 46 changed files with 494 additions and 267 deletions.
10 changes: 5 additions & 5 deletions Sources/Jazz2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,11 @@
<ClInclude Include="Jazz2\UI\Menu\PlayCustomSection.h">
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
<ClInclude Include="Jazz2\Multiplayer\MultiplayerGameMode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Jazz2\UI\Menu\MultiplayerGameModeSelectSection.h">
<Filter>Header Files</Filter>
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
<ClInclude Include="Jazz2\Multiplayer\MultiplayerGameMode.h">
<Filter>Header Files\Jazz2\Multiplayer</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -2424,7 +2424,7 @@
<Filter>Source Files\Jazz2\UI\Menu</Filter>
</ClCompile>
<ClCompile Include="Jazz2\UI\Menu\MultiplayerGameModeSelectSection.cpp">
<Filter>Source Files</Filter>
<Filter>Source Files\Jazz2\UI\Menu</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Sources/Jazz2/Actors/ActorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ namespace Jazz2::Actors
return 1.0f;
}

std::shared_ptr<AudioBufferPlayer> ActorBase::PlaySfx(const StringView& identifier, float gain, float pitch)
std::shared_ptr<AudioBufferPlayer> ActorBase::PlaySfx(const StringView identifier, float gain, float pitch)
{
auto it = _metadata->Sounds.find(String::nullTerminatedView(identifier));
if (it != _metadata->Sounds.end()) {
Expand Down Expand Up @@ -1054,18 +1054,18 @@ namespace Jazz2::Actors
}
}

void ActorBase::PreloadMetadataAsync(const StringView& path)
void ActorBase::PreloadMetadataAsync(const StringView path)
{
ContentResolver::Get().PreloadMetadataAsync(path);
}

void ActorBase::RequestMetadata(const StringView& path)
void ActorBase::RequestMetadata(const StringView path)
{
_metadata = ContentResolver::Get().RequestMetadata(path);
}

#if !defined(WITH_COROUTINES)
void ActorBase::RequestMetadataAsync(const StringView& path)
void ActorBase::RequestMetadataAsync(const StringView path)
{
_metadata = ContentResolver::Get().RequestMetadata(path);
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/Jazz2/Actors/ActorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace Jazz2::Actors
void CreateSpriteDebris(AnimState state, int count);
virtual float GetIceShrapnelScale() const;

std::shared_ptr<AudioBufferPlayer> PlaySfx(const StringView& identifier, float gain = 1.0f, float pitch = 1.0f);
std::shared_ptr<AudioBufferPlayer> PlaySfx(const StringView identifier, float gain = 1.0f, float pitch = 1.0f);
bool SetAnimation(AnimState state, bool skipAnimation = false);
bool SetTransition(AnimState state, bool cancellable, const std::function<void()>& callback = nullptr);
bool SetTransition(AnimState state, bool cancellable, std::function<void()>&& callback);
Expand All @@ -298,11 +298,11 @@ namespace Jazz2::Actors
virtual void OnAnimationStarted();
virtual void OnAnimationFinished();

static void PreloadMetadataAsync(const StringView& path);
void RequestMetadata(const StringView& path);
static void PreloadMetadataAsync(const StringView path);
void RequestMetadata(const StringView path);

#if defined(WITH_COROUTINES)
auto RequestMetadataAsync(const StringView& path)
auto RequestMetadataAsync(const StringView path)
{
struct awaitable {
ActorBase* actor;
Expand All @@ -322,7 +322,7 @@ namespace Jazz2::Actors
return awaitable{this, path};
}
#else
void RequestMetadataAsync(const StringView& path);
void RequestMetadataAsync(const StringView path);
#endif

constexpr void SetState(ActorState flags) noexcept
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/Actors/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2253,7 +2253,7 @@ namespace Jazz2::Actors
}
}

std::shared_ptr<AudioBufferPlayer> Player::PlayPlayerSfx(const StringView& identifier, float gain, float pitch)
std::shared_ptr<AudioBufferPlayer> Player::PlayPlayerSfx(const StringView identifier, float gain, float pitch)
{
auto it = _metadata->Sounds.find(String::nullTerminatedView(identifier));
if (it != _metadata->Sounds.end()) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/Actors/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ namespace Jazz2::Actors
virtual void OnHitSpring(const Vector2f& pos, const Vector2f& force, bool keepSpeedX, bool keepSpeedY, bool& removeSpecialMove);
virtual void OnWaterSplash(const Vector2f& pos, bool inwards);

std::shared_ptr<AudioBufferPlayer> PlayPlayerSfx(const StringView& identifier, float gain = 1.0f, float pitch = 1.0f);
std::shared_ptr<AudioBufferPlayer> PlayPlayerSfx(const StringView identifier, float gain = 1.0f, float pitch = 1.0f);
bool SetPlayerTransition(AnimState state, bool cancellable, bool removeControl, SpecialMoveType specialMove, const std::function<void()>& callback = nullptr);
bool SetPlayerTransition(AnimState state, bool cancellable, bool removeControl, SpecialMoveType specialMove, std::function<void()>&& callback);
bool CanFreefall();
Expand Down
22 changes: 11 additions & 11 deletions Sources/Jazz2/ContentResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,13 @@ namespace Jazz2
_isLoading = false;
}

void ContentResolver::PreloadMetadataAsync(const StringView& path)
void ContentResolver::PreloadMetadataAsync(const StringView path)
{
// TODO: reimplement async preloading
RequestMetadata(path);
}

Metadata* ContentResolver::RequestMetadata(const StringView& path)
Metadata* ContentResolver::RequestMetadata(const StringView path)
{
String pathNormalized = fs::ToNativeSeparators(path);
auto it = _cachedMetadata.find(pathNormalized);
Expand Down Expand Up @@ -566,7 +566,7 @@ namespace Jazz2
return _cachedMetadata.emplace(metadata->Path, std::move(metadata)).first->second.get();
}

GenericGraphicResource* ContentResolver::RequestGraphics(const StringView& path, uint16_t paletteOffset)
GenericGraphicResource* ContentResolver::RequestGraphics(const StringView path, uint16_t paletteOffset)
{
// First resources are requested, reset _isLoading flag, because palette should be already applied
_isLoading = false;
Expand Down Expand Up @@ -687,7 +687,7 @@ namespace Jazz2
return nullptr;
}

GenericGraphicResource* ContentResolver::RequestGraphicsAura(const StringView& path, uint16_t paletteOffset)
GenericGraphicResource* ContentResolver::RequestGraphicsAura(const StringView path, uint16_t paletteOffset)
{
// Try "Content" directory first, then "Cache" directory
String fullPath = fs::CombinePath({ GetContentPath(), "Animations"_s, path });
Expand Down Expand Up @@ -871,7 +871,7 @@ namespace Jazz2
}
}

std::unique_ptr<Tiles::TileSet> ContentResolver::RequestTileSet(const StringView& path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping)
std::unique_ptr<Tiles::TileSet> ContentResolver::RequestTileSet(const StringView path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping)
{
// Try "Content" directory first, then "Cache" directory
String fullPath = fs::CombinePath({ GetContentPath(), "Tilesets"_s, path + ".j2t"_s });
Expand Down Expand Up @@ -1063,14 +1063,14 @@ namespace Jazz2
return std::make_unique<Tiles::TileSet>(tileCount, std::move(textureDiffuse), std::move(mask), maskSize * 8, std::move(captionTile));
}

bool ContentResolver::LevelExists(const StringView& episodeName, const StringView& levelName)
bool ContentResolver::LevelExists(const StringView episodeName, const StringView levelName)
{
// Try "Content" directory first, then "Cache" directory
return (fs::IsReadableFile(fs::CombinePath({ GetContentPath(), "Episodes"_s, episodeName, levelName + ".j2l"_s })) ||
fs::IsReadableFile(fs::CombinePath({ GetCachePath(), "Episodes"_s, episodeName, levelName + ".j2l"_s })));
}

bool ContentResolver::TryLoadLevel(const StringView& path, GameDifficulty difficulty, LevelDescriptor& descriptor)
bool ContentResolver::TryLoadLevel(const StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor)
{
// Try "Content" directory first, then "Cache" directory
auto pathNormalized = fs::ToNativeSeparators(path);
Expand Down Expand Up @@ -1234,7 +1234,7 @@ namespace Jazz2
}
}

std::optional<Episode> ContentResolver::GetEpisode(const StringView& name, bool withImages)
std::optional<Episode> ContentResolver::GetEpisode(const StringView name, bool withImages)
{
String fullPath = fs::CombinePath({ GetContentPath(), "Episodes"_s, name + ".j2e"_s });
if (!fs::IsReadableFile(fullPath)) {
Expand All @@ -1243,7 +1243,7 @@ namespace Jazz2
return GetEpisodeByPath(fullPath, withImages);
}

std::optional<Episode> ContentResolver::GetEpisodeByPath(const StringView& path, bool withImages)
std::optional<Episode> ContentResolver::GetEpisodeByPath(const StringView path, bool withImages)
{
auto s = fs::Open(path, FileAccessMode::Read);
if (s->GetSize() < 16) {
Expand Down Expand Up @@ -1308,7 +1308,7 @@ namespace Jazz2
return episode;
}

std::unique_ptr<AudioStreamPlayer> ContentResolver::GetMusic(const StringView& path)
std::unique_ptr<AudioStreamPlayer> ContentResolver::GetMusic(const StringView path)
{
// Don't load sounds in headless mode
if (_isHeadless) {
Expand Down Expand Up @@ -1587,7 +1587,7 @@ namespace Jazz2
}

#if defined(DEATH_DEBUG)
void ContentResolver::MigrateGraphics(const StringView& path)
void ContentResolver::MigrateGraphics(const StringView path)
{
String auraPath = fs::CombinePath({ GetContentPath(), "Animations"_s, path.exceptSuffix(4) + ".aura"_s });
if (fs::FileExists(auraPath)) {
Expand Down
22 changes: 11 additions & 11 deletions Sources/Jazz2/ContentResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ namespace Jazz2
void BeginLoading();
void EndLoading();

void PreloadMetadataAsync(const StringView& path);
Metadata* RequestMetadata(const StringView& path);
GenericGraphicResource* RequestGraphics(const StringView& path, uint16_t paletteOffset);
void PreloadMetadataAsync(const StringView path);
Metadata* RequestMetadata(const StringView path);
GenericGraphicResource* RequestGraphics(const StringView path, uint16_t paletteOffset);

std::unique_ptr<Tiles::TileSet> RequestTileSet(const StringView& path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping = nullptr);
bool LevelExists(const StringView& episodeName, const StringView& levelName);
bool TryLoadLevel(const StringView& path, GameDifficulty difficulty, LevelDescriptor& descriptor);
std::unique_ptr<Tiles::TileSet> RequestTileSet(const StringView path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping = nullptr);
bool LevelExists(const StringView episodeName, const StringView levelName);
bool TryLoadLevel(const StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor);
void ApplyDefaultPalette();

std::optional<Episode> GetEpisode(const StringView& name, bool withImages = false);
std::optional<Episode> GetEpisodeByPath(const StringView& path, bool withImages = false);
std::unique_ptr<AudioStreamPlayer> GetMusic(const StringView& path);
std::optional<Episode> GetEpisode(const StringView name, bool withImages = false);
std::optional<Episode> GetEpisodeByPath(const StringView path, bool withImages = false);
std::unique_ptr<AudioStreamPlayer> GetMusic(const StringView path);
UI::Font* GetFont(FontType fontType);
Shader* GetShader(PrecompiledShader shader);
void CompileShaders();
Expand All @@ -100,15 +100,15 @@ namespace Jazz2

void InitializePaths();

GenericGraphicResource* RequestGraphicsAura(const StringView& path, uint16_t paletteOffset);
GenericGraphicResource* RequestGraphicsAura(const StringView path, uint16_t paletteOffset);
static void ReadImageFromFile(std::unique_ptr<Stream>& s, uint8_t* data, int32_t width, int32_t height, int32_t channelCount);

std::unique_ptr<Shader> CompileShader(const char* shaderName, Shader::DefaultVertex vertex, const char* fragment, Shader::Introspection introspection = Shader::Introspection::Enabled);
std::unique_ptr<Shader> CompileShader(const char* shaderName, const char* vertex, const char* fragment, Shader::Introspection introspection = Shader::Introspection::Enabled);

void RecreateGemPalettes();
#if defined(DEATH_DEBUG)
void MigrateGraphics(const StringView& path);
void MigrateGraphics(const StringView path);
#endif

bool _isHeadless;
Expand Down
12 changes: 6 additions & 6 deletions Sources/Jazz2/ILevelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ namespace Jazz2

virtual void AddActor(std::shared_ptr<Actors::ActorBase> actor) = 0;

virtual std::shared_ptr<AudioBufferPlayer> PlaySfx(Actors::ActorBase* self, const StringView& identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain = 1.0f, float pitch = 1.0f) = 0;
virtual std::shared_ptr<AudioBufferPlayer> PlayCommonSfx(const StringView& identifier, const Vector3f& pos, float gain = 1.0f, float pitch = 1.0f) = 0;
virtual std::shared_ptr<AudioBufferPlayer> PlaySfx(Actors::ActorBase* self, const StringView identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain = 1.0f, float pitch = 1.0f) = 0;
virtual std::shared_ptr<AudioBufferPlayer> PlayCommonSfx(const StringView identifier, const Vector3f& pos, float gain = 1.0f, float pitch = 1.0f) = 0;
virtual void WarpCameraToTarget(Actors::ActorBase* actor, bool fast = false) = 0;
virtual bool IsPositionEmpty(Actors::ActorBase* self, const AABBf& aabb, Tiles::TileCollisionParams& params, Actors::ActorBase** collider) = 0;

Expand All @@ -84,24 +84,24 @@ namespace Jazz2
virtual void GetCollidingPlayers(const AABBf& aabb, const std::function<bool(Actors::ActorBase*)> callback) = 0;

virtual void BroadcastTriggeredEvent(Actors::ActorBase* initiator, EventType eventType, std::uint8_t* eventParams) = 0;
virtual void BeginLevelChange(ExitType exitType, const StringView& nextLevel) = 0;
virtual void BeginLevelChange(ExitType exitType, const StringView nextLevel) = 0;
virtual void HandleGameOver(Actors::Player* player) = 0;
virtual bool HandlePlayerDied(Actors::Player* player) = 0;
virtual void HandlePlayerWarped(Actors::Player* player, const Vector2f& prevPos, bool fast) = 0;
virtual void SetCheckpoint(Actors::Player* player, const Vector2f& pos) = 0;
virtual void RollbackToCheckpoint(Actors::Player* player) = 0;
virtual void ActivateSugarRush(Actors::Player* player) = 0;
virtual void ShowLevelText(const StringView& text) = 0;
virtual void ShowLevelText(const StringView text) = 0;
virtual void ShowCoins(Actors::Player* player, std::int32_t count) = 0;
virtual void ShowGems(Actors::Player* player, std::int32_t count) = 0;
virtual StringView GetLevelText(std::uint32_t textId, std::int32_t index = -1, std::uint32_t delimiter = 0) = 0;
virtual void OverrideLevelText(std::uint32_t textId, const StringView& value) = 0;
virtual void OverrideLevelText(std::uint32_t textId, const StringView value) = 0;
virtual void LimitCameraView(int left, int width) = 0;
virtual void ShakeCameraView(float duration) = 0;
virtual bool GetTrigger(std::uint8_t triggerId) = 0;
virtual void SetTrigger(std::uint8_t triggerId, bool newState) = 0;
virtual void SetWeather(WeatherType type, std::uint8_t intensity) = 0;
virtual bool BeginPlayMusic(const StringView& path, bool setDefault = false, bool forceReload = false) = 0;
virtual bool BeginPlayMusic(const StringView path, bool setDefault = false, bool forceReload = false) = 0;

virtual bool PlayerActionPressed(std::int32_t index, PlayerActions action, bool includeGamepads = true) = 0;
virtual bool PlayerActionPressed(std::int32_t index, PlayerActions action, bool includeGamepads, bool& isGamepad) = 0;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/IRootController.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Jazz2
virtual bool SaveCurrentStateIfAny() = 0;

#if defined(WITH_MULTIPLAYER)
virtual bool ConnectToServer(const StringView& address, std::uint16_t port) = 0;
virtual bool ConnectToServer(const StringView address, std::uint16_t port) = 0;
virtual bool CreateServer(LevelInitialization&& levelInit, std::uint16_t port) = 0;
#endif

Expand Down
12 changes: 6 additions & 6 deletions Sources/Jazz2/LevelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ namespace Jazz2
_actors.emplace_back(actor);
}

std::shared_ptr<AudioBufferPlayer> LevelHandler::PlaySfx(Actors::ActorBase* self, const StringView& identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain, float pitch)
std::shared_ptr<AudioBufferPlayer> LevelHandler::PlaySfx(Actors::ActorBase* self, const StringView identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain, float pitch)
{
auto& player = _playingSounds.emplace_back(std::make_shared<AudioBufferPlayer>(buffer));
player->setPosition(Vector3f(pos.X, pos.Y, 100.0f));
Expand All @@ -762,7 +762,7 @@ namespace Jazz2
return player;
}

std::shared_ptr<AudioBufferPlayer> LevelHandler::PlayCommonSfx(const StringView& identifier, const Vector3f& pos, float gain, float pitch)
std::shared_ptr<AudioBufferPlayer> LevelHandler::PlayCommonSfx(const StringView identifier, const Vector3f& pos, float gain, float pitch)
{
auto it = _commonResources->Sounds.find(String::nullTerminatedView(identifier));
if (it != _commonResources->Sounds.end()) {
Expand Down Expand Up @@ -994,7 +994,7 @@ namespace Jazz2
}
}

void LevelHandler::BeginLevelChange(ExitType exitType, const StringView& nextLevel)
void LevelHandler::BeginLevelChange(ExitType exitType, const StringView nextLevel)
{
if (_nextLevelType != ExitType::None) {
return;
Expand Down Expand Up @@ -1137,7 +1137,7 @@ namespace Jazz2
#endif
}

void LevelHandler::ShowLevelText(const StringView& text)
void LevelHandler::ShowLevelText(const StringView text)
{
_hud->ShowLevelText(text);
}
Expand Down Expand Up @@ -1192,7 +1192,7 @@ namespace Jazz2
return text;
}

void LevelHandler::OverrideLevelText(uint32_t textId, const StringView& value)
void LevelHandler::OverrideLevelText(uint32_t textId, const StringView value)
{
if (textId >= _levelTexts.size()) {
if (value.empty()) {
Expand Down Expand Up @@ -1659,7 +1659,7 @@ namespace Jazz2
_weatherIntensity = intensity;
}

bool LevelHandler::BeginPlayMusic(const StringView& path, bool setDefault, bool forceReload)
bool LevelHandler::BeginPlayMusic(const StringView path, bool setDefault, bool forceReload)
{
bool result = false;

Expand Down
Loading

0 comments on commit ecb2231

Please sign in to comment.