Skip to content

Commit

Permalink
Reworked menu layout, improved Discord integration, replaced `Interlo…
Browse files Browse the repository at this point in the history
…cked` with `std::atomic`
  • Loading branch information
deathkiller committed Nov 30, 2024
1 parent c131fca commit 4584bdc
Show file tree
Hide file tree
Showing 33 changed files with 230 additions and 1,147 deletions.
Binary file modified Content/Translations/cs.mo
Binary file not shown.
8 changes: 4 additions & 4 deletions Content/Translations/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: jazz2-resurrection\n"
"POT-Creation-Date: 2024-11-30 15:44+0100\n"
"PO-Revision-Date: 2024-11-30 15:46+0100\n"
"PO-Revision-Date: 2024-11-30 23:12+0100\n"
"Last-Translator: \n"
"Language-Team: Dan R.\n"
"Language: cs\n"
Expand Down Expand Up @@ -1737,7 +1737,7 @@ msgstr "Přepisovat dokončení epizody"
#. TRANSLATORS: Menu item in Options > Gameplay section
#: Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp:57
msgid "Discord Integration"
msgstr "Integrace Discordu"
msgstr "Integrace aplikace Discord"

#. TRANSLATORS: Menu item in Options > Gameplay section
#: Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp:61
Expand Down Expand Up @@ -1902,7 +1902,7 @@ msgstr "Týmová bitva"
#. TRANSLATORS: Menu item in Select Game Mode section
#: Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp:22
msgid "Capture The Flag"
msgstr ""
msgstr "Boj o vlajku"

#. TRANSLATORS: Menu item in Select Game Mode section
#: Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp:24
Expand All @@ -1917,7 +1917,7 @@ msgstr "Týmový závod"
#. TRANSLATORS: Menu item in Select Game Mode section
#: Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp:28
msgid "Treasure Hunt"
msgstr ""
msgstr "Lovci pokladů"

#. TRANSLATORS: Menu item in Select Game Mode section
#: Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp:30
Expand Down
3 changes: 0 additions & 3 deletions Sources/Jazz2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,6 @@
<ClInclude Include="nCine\Primitives\Vector4.h" />
<ClInclude Include="nCine\Backends\Qt5Widget.h" />
<ClInclude Include="nCine\ServiceLocator.h" />
<ClInclude Include="nCine\Threading\Atomic.h" />
<ClInclude Include="nCine\Threading\IThreadCommand.h" />
<ClInclude Include="nCine\Threading\IThreadPool.h" />
<ClInclude Include="nCine\Threading\Thread.h" />
Expand Down Expand Up @@ -702,7 +701,6 @@
<ClInclude Include="$(ExtensionLibraryPath)\Containers\StaticArray.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\Tags.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\DateTime.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Threading\Interlocked.h" />
<ClInclude Include="$(ExtensionLibraryPath)\IO\DeflateStream.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\SequenceHelpers.h" />
<ClInclude Include="$(ExtensionLibraryPath)\Containers\StringUtils.h" />
Expand Down Expand Up @@ -1011,7 +1009,6 @@
<ClCompile Include="nCine\Threading\PosixThread.cpp" />
<ClCompile Include="nCine\Threading\PosixThreadSync.cpp" />
<ClCompile Include="nCine\Threading\ThreadPool.cpp" />
<ClCompile Include="nCine\Threading\WindowsAtomic.cpp" />
<ClCompile Include="nCine\Threading\WindowsThread.cpp" />
<ClCompile Include="nCine\Threading\WindowsThreadSync.cpp" />
<ClCompile Include="Jazz2\Actors\Collectibles\AmmoCollectible.cpp" />
Expand Down
3 changes: 0 additions & 3 deletions Sources/Jazz2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1356,9 +1356,6 @@
<ClInclude Include="Jazz2\Tiles\ITileMapOwner.h">
<Filter>Header Files\Jazz2\Tiles</Filter>
</ClInclude>
<ClInclude Include="$(ExtensionLibraryPath)\Threading\Interlocked.h">
<Filter>Header Files\Shared\Threading</Filter>
</ClInclude>
<ClInclude Include="Jazz2\UI\Menu\LoadingSection.h">
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
Expand Down
3 changes: 3 additions & 0 deletions Sources/Jazz2/IStateHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "../Common.h"
#include "../nCine/Input/InputEvents.h"
#include "../nCine/Primitives/Vector2.h"

namespace Jazz2
{
Expand All @@ -14,6 +15,8 @@ namespace Jazz2
IStateHandler(const IStateHandler&) = delete;
IStateHandler& operator=(const IStateHandler&) = delete;

virtual nCine::Vector2i GetViewSize() const { return {}; }

virtual void OnBeginFrame() {}
virtual void OnEndFrame() {}
virtual void OnInitializeViewport(std::int32_t width, std::int32_t height) {}
Expand Down
17 changes: 7 additions & 10 deletions Sources/Jazz2/LevelHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#include "LevelHandler.h"
#include "PlayerViewport.h"
#include "PreferencesCache.h"
#include "UI/DiscordRpcClient.h"
#include "UI/HUD.h"
#include "../Common.h"

#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
# include "UI/DiscordRpcClient.h"
#endif

#if defined(WITH_ANGELSCRIPT)
# include "Scripting/LevelScriptLoader.h"
#endif
Expand Down Expand Up @@ -452,6 +449,11 @@ namespace Jazz2
}
}

Vector2i LevelHandler::GetViewSize() const
{
return _viewSize;
}

void LevelHandler::OnBeginFrame()
{
ZoneScopedC(0x4876AF);
Expand Down Expand Up @@ -1446,11 +1448,6 @@ namespace Jazz2
}
}

Vector2i LevelHandler::GetViewSize() const
{
return _viewSize;
}

void LevelHandler::BeforeActorDestroyed(Actors::ActorBase* actor)
{
// Nothing to do here
Expand Down Expand Up @@ -2021,7 +2018,7 @@ namespace Jazz2

void LevelHandler::UpdateRichPresence()
{
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
if (!PreferencesCache::EnableDiscordIntegration || !UI::DiscordRpcClient::Get().IsSupported()) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/LevelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ namespace Jazz2
float GetAmbientLight(Actors::Player* player) const override;
void SetAmbientLight(Actors::Player* player, float value) override;

Vector2i GetViewSize() const override;

void OnBeginFrame() override;
void OnEndFrame() override;
void OnInitializeViewport(std::int32_t width, std::int32_t height) override;
Expand Down Expand Up @@ -157,8 +159,6 @@ namespace Jazz2
void OnAdvanceDestructibleTileAnimation(std::int32_t tx, std::int32_t ty, std::int32_t amount) override { }
void OnTileFrozen(std::int32_t x, std::int32_t y) override;

Vector2i GetViewSize() const;

virtual void AttachComponents(LevelDescriptor&& descriptor);
virtual void SpawnPlayers(const LevelInitialization& levelInit);

Expand Down
10 changes: 5 additions & 5 deletions Sources/Jazz2/Multiplayer/NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
#undef far
*/

#include <atomic>

#include <Containers/String.h>
#include <Threading/Interlocked.h>

using namespace Death;
using namespace Death::Threading;

namespace Jazz2::Multiplayer
{
std::int32_t NetworkManager::_initializeCount = 0;
static std::atomic_int32_t _initializeCount{0};

NetworkManager::NetworkManager()
: _host(nullptr), _state(NetworkState::None), _handler(nullptr)
Expand Down Expand Up @@ -190,15 +190,15 @@ namespace Jazz2::Multiplayer

void NetworkManager::InitializeBackend()
{
if (Interlocked::Increment(&_initializeCount) == 1) {
if (++_initializeCount == 1) {
std::int32_t error = enet_initialize();
RETURN_ASSERT_MSG(error == 0, "enet_initialize() failed with error %i", error);
}
}

void NetworkManager::ReleaseBackend()
{
if (Interlocked::Decrement(&_initializeCount) == 0) {
if (--_initializeCount == 0) {
enet_deinitialize();
}
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/Jazz2/Multiplayer/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ namespace Jazz2::Multiplayer
Mutex _lock;
std::unique_ptr<ServerDiscovery> _discovery;

static std::int32_t _initializeCount;

static void InitializeBackend();
static void ReleaseBackend();

Expand Down
5 changes: 5 additions & 0 deletions Sources/Jazz2/UI/Cinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace Jazz2::UI
_canvas->setParent(nullptr);
}

Vector2i Cinematics::GetViewSize() const
{
return _upscalePass.GetViewSize();
}

void Cinematics::OnBeginFrame()
{
float timeMult = theApplication().GetTimeMult();
Expand Down
2 changes: 2 additions & 0 deletions Sources/Jazz2/UI/Cinematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace Jazz2::UI
Cinematics(IRootController* root, const StringView path, Function<bool(IRootController*, bool)>&& callback);
~Cinematics() override;

Vector2i GetViewSize() const override;

void OnBeginFrame() override;
void OnInitializeViewport(std::int32_t width, std::int32_t height) override;

Expand Down
Loading

0 comments on commit 4584bdc

Please sign in to comment.