From 1fa0d753290dc4afdc509e6c2be0d2889d65e7e0 Mon Sep 17 00:00:00 2001 From: Death Killer <884052+deathkiller@users.noreply.github.com> Date: Sat, 6 Jul 2024 00:24:15 +0200 Subject: [PATCH] Fixed build, refactoring --- Sources/Jazz2/ContentResolver.cpp | 120 +++++++++--------- Sources/Jazz2/ContentResolver.h | 10 +- Sources/Jazz2/PreferencesCache.cpp | 100 +++++++-------- Sources/Jazz2/PreferencesCache.h | 14 +- Sources/Jazz2/UI/Canvas.cpp | 4 +- Sources/Jazz2/UI/Canvas.h | 6 +- Sources/Jazz2/UI/Cinematics.cpp | 30 ++--- Sources/Jazz2/UI/Cinematics.h | 26 ++-- Sources/Jazz2/UI/ControlScheme.cpp | 12 +- Sources/Jazz2/UI/Font.cpp | 62 ++++----- Sources/Jazz2/UI/Font.h | 6 +- Sources/Jazz2/UI/HUD.cpp | 108 ++++++++-------- Sources/Jazz2/UI/HUD.h | 52 ++++---- Sources/Jazz2/UI/LoadingHandler.cpp | 6 +- Sources/Jazz2/UI/LoadingHandler.h | 6 +- Sources/Jazz2/UI/Menu/BeginSection.cpp | 18 +-- Sources/Jazz2/UI/Menu/BeginSection.h | 6 +- .../Jazz2/UI/Menu/ControlsOptionsSection.cpp | 2 +- .../Jazz2/UI/Menu/ControlsOptionsSection.h | 2 +- .../UI/Menu/CreateServerOptionsSection.cpp | 18 +-- .../UI/Menu/CreateServerOptionsSection.h | 16 +-- .../UI/Menu/CustomLevelSelectSection.cpp | 24 ++-- .../Jazz2/UI/Menu/CustomLevelSelectSection.h | 4 +- .../Jazz2/UI/Menu/EpisodeSelectSection.cpp | 12 +- Sources/Jazz2/UI/Menu/EpisodeSelectSection.h | 10 +- Sources/Jazz2/UI/Menu/FirstRunSection.cpp | 4 +- Sources/Jazz2/UI/Menu/FirstRunSection.h | 2 +- .../UI/Menu/GameplayEnhancementsSection.cpp | 4 +- .../UI/Menu/GameplayEnhancementsSection.h | 2 +- .../Jazz2/UI/Menu/GameplayOptionsSection.cpp | 4 +- .../Jazz2/UI/Menu/GameplayOptionsSection.h | 2 +- .../Jazz2/UI/Menu/GraphicsOptionsSection.cpp | 4 +- .../Jazz2/UI/Menu/GraphicsOptionsSection.h | 2 +- Sources/Jazz2/UI/Menu/IMenuContainer.h | 20 +-- Sources/Jazz2/UI/Menu/ImportSection.cpp | 16 +-- Sources/Jazz2/UI/Menu/ImportSection.h | 8 +- Sources/Jazz2/UI/Menu/InGameMenu.cpp | 30 ++--- Sources/Jazz2/UI/Menu/InGameMenu.h | 18 +-- .../Jazz2/UI/Menu/InputDiagnosticsSection.cpp | 28 ++-- .../Jazz2/UI/Menu/InputDiagnosticsSection.h | 4 +- .../Jazz2/UI/Menu/LanguageSelectSection.cpp | 7 +- Sources/Jazz2/UI/Menu/LanguageSelectSection.h | 2 +- Sources/Jazz2/UI/Menu/MainMenu.cpp | 100 +++++++-------- Sources/Jazz2/UI/Menu/MainMenu.h | 14 +- .../Menu/MultiplayerGameModeSelectSection.cpp | 4 +- .../Menu/MultiplayerGameModeSelectSection.h | 2 +- Sources/Jazz2/UI/Menu/OptionsSection.cpp | 2 +- Sources/Jazz2/UI/Menu/OptionsSection.h | 2 +- Sources/Jazz2/UI/Menu/PauseSection.cpp | 12 +- Sources/Jazz2/UI/Menu/PauseSection.h | 4 +- Sources/Jazz2/UI/Menu/PlayCustomSection.cpp | 2 +- Sources/Jazz2/UI/Menu/PlayCustomSection.h | 2 +- Sources/Jazz2/UI/Menu/RefreshCacheSection.cpp | 2 +- .../Jazz2/UI/Menu/RemapControlsSection.cpp | 12 +- Sources/Jazz2/UI/Menu/RemapControlsSection.h | 8 +- Sources/Jazz2/UI/Menu/RescaleModeSection.cpp | 8 +- Sources/Jazz2/UI/Menu/RescaleModeSection.h | 2 +- Sources/Jazz2/UI/Menu/ServerSelectSection.cpp | 14 +- Sources/Jazz2/UI/Menu/ServerSelectSection.h | 4 +- .../Jazz2/UI/Menu/SoundsOptionsSection.cpp | 38 +++--- Sources/Jazz2/UI/Menu/SoundsOptionsSection.h | 8 +- .../Jazz2/UI/Menu/StartGameOptionsSection.cpp | 32 ++--- .../UI/Menu/TouchControlsOptionsSection.cpp | 10 +- .../UI/Menu/TouchControlsOptionsSection.h | 6 +- Sources/Jazz2/UI/RgbLights.h | 4 +- Sources/Jazz2/UI/UpscaleRenderPass.cpp | 8 +- Sources/Jazz2/UI/UpscaleRenderPass.h | 4 +- Sources/nCine/IO/EmscriptenLocalFile.cpp | 26 ++-- Sources/nCine/IO/EmscriptenLocalFile.h | 13 +- 69 files changed, 585 insertions(+), 589 deletions(-) diff --git a/Sources/Jazz2/ContentResolver.cpp b/Sources/Jazz2/ContentResolver.cpp index 9eb79687..07211011 100644 --- a/Sources/Jazz2/ContentResolver.cpp +++ b/Sources/Jazz2/ContentResolver.cpp @@ -79,11 +79,11 @@ namespace Jazz2 _cachedSounds.clear(); #endif - for (int32_t i = 0; i < (int32_t)FontType::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)FontType::Count; i++) { _fonts[i] = nullptr; } - for (int32_t i = 0; i < (int32_t)PrecompiledShader::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)PrecompiledShader::Count; i++) { _precompiledShaders[i] = nullptr; } } @@ -495,7 +495,7 @@ namespace Jazz2 ondemand::object animations; if (doc["Animations"].get(animations) == SUCCESS) { - size_t count; + std::size_t count; if (animations.count_fields().get(count) == SUCCESS) { metadata->Animations.reserve(count); } @@ -600,7 +600,7 @@ namespace Jazz2 // Don't load sounds in headless mode ondemand::object sounds; if (doc["Sounds"].get(sounds) == SUCCESS) { - size_t count; + std::size_t count; if (sounds.count_fields().get(count) == SUCCESS) { metadata->Sounds.reserve(count); } @@ -689,14 +689,14 @@ namespace Jazz2 return nullptr; } - int32_t w = texLoader->width(); - int32_t h = texLoader->height(); - uint32_t* pixels = (uint32_t*)texLoader->pixels(); - const uint32_t* palette = _palettes + paletteOffset; + std::int32_t w = texLoader->width(); + std::int32_t h = texLoader->height(); + std::uint32_t* pixels = (std::uint32_t*)texLoader->pixels(); + const std::uint32_t* palette = _palettes + paletteOffset; bool linearSampling = false; bool needsMask = true; - uint64_t flags; + std::uint64_t flags; if (doc["Flags"].get(flags) == SUCCESS) { // Palette already applied, keep as is if ((flags & 0x01) != 0x01) { @@ -712,19 +712,19 @@ namespace Jazz2 } if (needsMask) { - graphics->Mask = std::make_unique(w * h); + graphics->Mask = std::make_unique(w * h); - for (int32_t i = 0; i < w * h; i++) { + for (std::int32_t i = 0; i < w * h; i++) { // Save original alpha value for collision checking graphics->Mask[i] = ((pixels[i] >> 24) & 0xff); if (palette != nullptr) { - uint32_t color = palette[pixels[i] & 0xff]; + std::uint32_t color = palette[pixels[i] & 0xff]; pixels[i] = (color & 0xffffff) | ((((color >> 24) & 0xff) * ((pixels[i] >> 24) & 0xff) / 255) << 24); } } } else if (palette != nullptr) { - for (int32_t i = 0; i < w * h; i++) { - uint32_t color = palette[pixels[i] & 0xff]; + for (std::int32_t i = 0; i < w * h; i++) { + std::uint32_t color = palette[pixels[i] & 0xff]; pixels[i] = (color & 0xffffff) | ((((color >> 24) & 0xff) * ((pixels[i] >> 24) & 0xff) / 255) << 24); } } @@ -743,11 +743,11 @@ namespace Jazz2 } graphics->AnimDuration = (float)animDuration; - int64_t frameCount; + std::int64_t frameCount; if (doc["FrameCount"].get(frameCount) != SUCCESS) { frameCount = 0; } - graphics->FrameCount = (int32_t)frameCount; + graphics->FrameCount = (std::int32_t)frameCount; graphics->FrameDimensions = GetVector2iFromJson(doc["FrameSize"]); graphics->FrameConfiguration = GetVector2iFromJson(doc["FrameConfiguration"]); @@ -766,7 +766,7 @@ namespace Jazz2 return nullptr; } - GenericGraphicResource* ContentResolver::RequestGraphicsAura(const StringView path, uint16_t paletteOffset) + GenericGraphicResource* ContentResolver::RequestGraphicsAura(const StringView path, std::uint16_t paletteOffset) { auto s = OpenContentFile(fs::CombinePath("Animations"_s, path)); @@ -776,44 +776,44 @@ namespace Jazz2 return nullptr; } - uint64_t signature1 = s->ReadValue(); - uint32_t signature2 = s->ReadValue(); - uint8_t version = s->ReadValue(); - uint8_t flags = s->ReadValue(); + std::uint64_t signature1 = s->ReadValue(); + std::uint32_t signature2 = s->ReadValue(); + std::uint8_t version = s->ReadValue(); + std::uint8_t flags = s->ReadValue(); if (signature1 != 0xB8EF8498E2BFBBEF || signature2 != 0x208F || version != 2 || (flags & 0x80) != 0x80) { return nullptr; } - uint8_t channelCount = s->ReadValue(); - uint32_t frameDimensionsX = s->ReadValue(); - uint32_t frameDimensionsY = s->ReadValue(); + std::uint8_t channelCount = s->ReadValue(); + std::uint32_t frameDimensionsX = s->ReadValue(); + std::uint32_t frameDimensionsY = s->ReadValue(); - uint8_t frameConfigurationX = s->ReadValue(); - uint8_t frameConfigurationY = s->ReadValue(); - uint16_t frameCount = s->ReadValue(); - uint16_t animDuration = s->ReadValue(); + std::uint8_t frameConfigurationX = s->ReadValue(); + std::uint8_t frameConfigurationY = s->ReadValue(); + std::uint16_t frameCount = s->ReadValue(); + std::uint16_t animDuration = s->ReadValue(); - uint16_t hotspotX = s->ReadValue(); - uint16_t hotspotY = s->ReadValue(); + std::uint16_t hotspotX = s->ReadValue(); + std::uint16_t hotspotY = s->ReadValue(); - uint16_t coldspotX = s->ReadValue(); - uint16_t coldspotY = s->ReadValue(); + std::uint16_t coldspotX = s->ReadValue(); + std::uint16_t coldspotY = s->ReadValue(); - uint16_t gunspotX = s->ReadValue(); - uint16_t gunspotY = s->ReadValue(); + std::uint16_t gunspotX = s->ReadValue(); + std::uint16_t gunspotY = s->ReadValue(); - uint32_t width = frameDimensionsX * frameConfigurationX; - uint32_t height = frameDimensionsY * frameConfigurationY; + std::uint32_t width = frameDimensionsX * frameConfigurationX; + std::uint32_t height = frameDimensionsY * frameConfigurationY; - std::unique_ptr pixels = std::make_unique(width * height); + std::unique_ptr pixels = std::make_unique(width * height); - ReadImageFromFile(s, (uint8_t*)pixels.get(), width, height, channelCount); + ReadImageFromFile(s, (std::uint8_t*)pixels.get(), width, height, channelCount); std::unique_ptr graphics = std::make_unique(); graphics->Flags |= GenericGraphicResourceFlags::Referenced; - const uint32_t* palette = _palettes + paletteOffset; + const std::uint32_t* palette = _palettes + paletteOffset; bool linearSampling = false; bool needsMask = true; if ((flags & 0x01) == 0x01) { @@ -825,19 +825,19 @@ namespace Jazz2 } if (needsMask) { - graphics->Mask = std::make_unique(width * height); + graphics->Mask = std::make_unique(width * height); - for (uint32_t i = 0; i < width * height; i++) { + for (std::uint32_t i = 0; i < width * height; i++) { // Save original alpha value for collision checking graphics->Mask[i] = ((pixels[i] >> 24) & 0xff); if (palette != nullptr) { - uint32_t color = palette[pixels[i] & 0xff]; + std::uint32_t color = palette[pixels[i] & 0xff]; pixels[i] = (color & 0xffffff) | ((((color >> 24) & 0xff) * ((pixels[i] >> 24) & 0xff) / 255) << 24); } } } else if (palette != nullptr) { - for (uint32_t i = 0; i < width * height; i++) { - uint32_t color = palette[pixels[i] & 0xff]; + for (std::uint32_t i = 0; i < width * height; i++) { + std::uint32_t color = palette[pixels[i] & 0xff]; pixels[i] = (color & 0xffffff) | ((((color >> 24) & 0xff) * ((pixels[i] >> 24) & 0xff) / 255) << 24); } } @@ -877,7 +877,7 @@ namespace Jazz2 return _cachedGraphics.emplace(Pair(String(path), paletteOffset), std::move(graphics)).first->second.get(); } - void ContentResolver::ReadImageFromFile(std::unique_ptr& s, uint8_t* data, int32_t width, int32_t height, int32_t channelCount) + void ContentResolver::ReadImageFromFile(std::unique_ptr& s, std::uint8_t* data, std::int32_t width, std::int32_t height, std::int32_t channelCount) { typedef union { struct { @@ -899,29 +899,29 @@ namespace Jazz2 rgba_t index[64] { }; rgba_t px; - int32_t run = 0; - int32_t px_len = width * height * channelCount; + std::int32_t run = 0; + std::int32_t px_len = width * height * channelCount; px.rgba.r = 0; px.rgba.g = 0; px.rgba.b = 0; px.rgba.a = 255; - for (int32_t px_pos = 0; px_pos < px_len; px_pos += channelCount) { + for (std::int32_t px_pos = 0; px_pos < px_len; px_pos += channelCount) { if (run > 0) { run--; } else { - int32_t b1 = s->ReadValue(); + std::int32_t b1 = s->ReadValue(); if (b1 == QOI_OP_RGB) { - px.rgba.r = s->ReadValue(); - px.rgba.g = s->ReadValue(); - px.rgba.b = s->ReadValue(); + px.rgba.r = s->ReadValue(); + px.rgba.g = s->ReadValue(); + px.rgba.b = s->ReadValue(); } else if (b1 == QOI_OP_RGBA) { - px.rgba.r = s->ReadValue(); - px.rgba.g = s->ReadValue(); - px.rgba.b = s->ReadValue(); - px.rgba.a = s->ReadValue(); + px.rgba.r = s->ReadValue(); + px.rgba.g = s->ReadValue(); + px.rgba.b = s->ReadValue(); + px.rgba.a = s->ReadValue(); } else if ((b1 & QOI_MASK_2) == QOI_OP_INDEX) { px = index[b1]; } else if ((b1 & QOI_MASK_2) == QOI_OP_DIFF) { @@ -929,8 +929,8 @@ namespace Jazz2 px.rgba.g += ((b1 >> 2) & 0x03) - 2; px.rgba.b += (b1 & 0x03) - 2; } else if ((b1 & QOI_MASK_2) == QOI_OP_LUMA) { - int32_t b2 = s->ReadValue(); - int32_t vg = (b1 & 0x3f) - 32; + std::int32_t b2 = s->ReadValue(); + std::int32_t vg = (b1 & 0x3f) - 32; px.rgba.r += vg - 8 + ((b2 >> 4) & 0x0f); px.rgba.g += vg; px.rgba.b += vg - 8 + (b2 & 0x0f); @@ -945,7 +945,7 @@ namespace Jazz2 } } - std::unique_ptr ContentResolver::RequestTileSet(const StringView path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping) + std::unique_ptr ContentResolver::RequestTileSet(const StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping) { // Try "Content" directory first, then "Cache" directory String fullPath = fs::CombinePath({ GetContentPath(), "Tilesets"_s, String(path + ".j2t"_s) }); @@ -1566,7 +1566,7 @@ namespace Jazz2 // If the UBO is smaller than 64kb and fixed batch size is disabled, batched shaders need to be compiled twice to determine safe `BATCH_SIZE` define value const bool compileTwice = (maxUniformBlockSize < 64 * 1024 && appCfg.fixedBatchSize <= 0 && introspection == Shader::Introspection::NoUniformsInBlocks); - int32_t batchSize; + std::int32_t batchSize; if (appCfg.fixedBatchSize > 0 && introspection == Shader::Introspection::NoUniformsInBlocks) { batchSize = appCfg.fixedBatchSize; } else if (compileTwice) { diff --git a/Sources/Jazz2/ContentResolver.h b/Sources/Jazz2/ContentResolver.h index 9925bc06..38d17a23 100644 --- a/Sources/Jazz2/ContentResolver.h +++ b/Sources/Jazz2/ContentResolver.h @@ -73,9 +73,9 @@ namespace Jazz2 void PreloadMetadataAsync(const StringView path); Metadata* RequestMetadata(const StringView path); - GenericGraphicResource* RequestGraphics(const StringView path, uint16_t paletteOffset); + GenericGraphicResource* RequestGraphics(const StringView path, std::uint16_t paletteOffset); - std::unique_ptr RequestTileSet(const StringView path, uint16_t captionTileId, bool applyPalette, const uint8_t* paletteRemapping = nullptr); + std::unique_ptr RequestTileSet(const StringView path, std::uint16_t captionTileId, bool applyPalette, const std::uint8_t* paletteRemapping = nullptr); bool LevelExists(const StringView episodeName, const StringView levelName); bool TryLoadLevel(const StringView path, GameDifficulty difficulty, LevelDescriptor& descriptor); void ApplyDefaultPalette(); @@ -107,8 +107,8 @@ namespace Jazz2 void InitializePaths(); - GenericGraphicResource* RequestGraphicsAura(const StringView path, uint16_t paletteOffset); - static void ReadImageFromFile(std::unique_ptr& s, uint8_t* data, int32_t width, int32_t height, int32_t channelCount); + GenericGraphicResource* RequestGraphicsAura(const StringView path, std::uint16_t paletteOffset); + static void ReadImageFromFile(std::unique_ptr& s, std::uint8_t* data, std::int32_t width, std::int32_t height, std::int32_t channelCount); std::unique_ptr CompileShader(const char* shaderName, Shader::DefaultVertex vertex, const char* fragment, Shader::Introspection introspection = Shader::Introspection::Enabled); std::unique_ptr CompileShader(const char* shaderName, const char* vertex, const char* fragment, Shader::Introspection introspection = Shader::Introspection::Enabled); @@ -120,7 +120,7 @@ namespace Jazz2 bool _isHeadless; bool _isLoading; - uint32_t _palettes[PaletteCount * ColorsPerPalette]; + std::uint32_t _palettes[PaletteCount * ColorsPerPalette]; HashMap, std::unique_ptr, FNV1aHashFunc, StringRefEqualTo> _cachedMetadata; HashMap, std::unique_ptr> _cachedGraphics; #if defined(WITH_AUDIO) diff --git a/Sources/Jazz2/PreferencesCache.cpp b/Sources/Jazz2/PreferencesCache.cpp index 1abfb27d..63e3e212 100644 --- a/Sources/Jazz2/PreferencesCache.cpp +++ b/Sources/Jazz2/PreferencesCache.cpp @@ -165,19 +165,19 @@ namespace Jazz2 if (!resetConfig) { auto s = fs::Open(_configPath, FileAccess::Read); if (s->GetSize() > 18) { - uint64_t signature = s->ReadValue(); - uint8_t fileType = s->ReadValue(); - uint8_t version = s->ReadValue(); + std::uint64_t signature = s->ReadValue(); + std::uint8_t fileType = s->ReadValue(); + std::uint8_t version = s->ReadValue(); if (signature == 0x2095A59FF0BFBBEF && fileType == ContentResolver::ConfigFile && version <= FileVersion) { if (version == 1) { // Version 1 included compressedSize and decompressedSize, it's not needed anymore - /*int32_t compressedSize =*/ s->ReadValue(); - /*int32_t uncompressedSize =*/ s->ReadValue(); + /*std::int32_t compressedSize =*/ s->ReadValue(); + /*std::int32_t uncompressedSize =*/ s->ReadValue(); } DeflateStream uc(*s); - BoolOptions boolOptions = (BoolOptions)uc.ReadValue(); + BoolOptions boolOptions = (BoolOptions)uc.ReadValue(); #if !defined(DEATH_TARGET_EMSCRIPTEN) EnableFullscreen = ((boolOptions & BoolOptions::EnableFullscreen) == BoolOptions::EnableFullscreen); @@ -218,21 +218,21 @@ namespace Jazz2 } // Bitmask of unlocked episodes, used only if compiled with SHAREWARE_DEMO_ONLY - UnlockedEpisodes = (UnlockableEpisodes)uc.ReadValue(); + UnlockedEpisodes = (UnlockableEpisodes)uc.ReadValue(); - ActiveRescaleMode = (RescaleMode)uc.ReadValue(); + ActiveRescaleMode = (RescaleMode)uc.ReadValue(); - MasterVolume = uc.ReadValue() / 255.0f; - SfxVolume = uc.ReadValue() / 255.0f; - MusicVolume = uc.ReadValue() / 255.0f; + MasterVolume = uc.ReadValue() / 255.0f; + SfxVolume = uc.ReadValue() / 255.0f; + MusicVolume = uc.ReadValue() / 255.0f; - TouchLeftPadding.X = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); - TouchLeftPadding.Y = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); - TouchRightPadding.X = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); - TouchRightPadding.Y = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); + TouchLeftPadding.X = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); + TouchLeftPadding.Y = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); + TouchRightPadding.X = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); + TouchRightPadding.Y = std::round(uc.ReadValue() / (TouchPaddingMultiplier * INT8_MAX)); if (version >= 5) { - GamepadButtonLabels = (GamepadType)uc.ReadValue(); + GamepadButtonLabels = (GamepadType)uc.ReadValue(); } // Controls @@ -265,16 +265,16 @@ namespace Jazz2 } } else { // Skip old control mapping definitions - uint8_t controlMappingCount = uc.ReadValue(); + std::uint8_t controlMappingCount = uc.ReadValue(); uc.Seek(controlMappingCount * sizeof(std::uint32_t), SeekOrigin::Current); } // Episode End - uint16_t episodeEndSize = uc.ReadValue(); - uint16_t episodeEndCount = uc.ReadValue(); + std::uint16_t episodeEndSize = uc.ReadValue(); + std::uint16_t episodeEndCount = uc.ReadValue(); - for (uint32_t i = 0; i < episodeEndCount; i++) { - uint8_t nameLength = uc.ReadValue(); + for (std::uint32_t i = 0; i < episodeEndCount; i++) { + std::uint8_t nameLength = uc.ReadValue(); String episodeName = String(NoInit, nameLength); uc.Read(episodeName.data(), nameLength); @@ -291,17 +291,17 @@ namespace Jazz2 } // Episode Continue - uint16_t episodeContinueSize = uc.ReadValue(); - uint16_t episodeContinueCount = uc.ReadValue(); + std::uint16_t episodeContinueSize = uc.ReadValue(); + std::uint16_t episodeContinueCount = uc.ReadValue(); - for (uint32_t i = 0; i < episodeContinueCount; i++) { - uint8_t nameLength = uc.ReadValue(); + for (std::uint32_t i = 0; i < episodeContinueCount; i++) { + std::uint8_t nameLength = uc.ReadValue(); String episodeName = String(NoInit, nameLength); uc.Read(episodeName.data(), nameLength); if (episodeContinueSize == sizeof(EpisodeContinuationState)) { EpisodeContinuationStateWithLevel stateWithLevel = { }; - nameLength = uc.ReadValue(); + nameLength = uc.ReadValue(); stateWithLevel.LevelName = String(NoInit, nameLength); uc.Read(stateWithLevel.LevelName.data(), nameLength); @@ -309,7 +309,7 @@ namespace Jazz2 _episodeContinue.emplace(std::move(episodeName), std::move(stateWithLevel)); } else { // Struct has different size, so it's better to skip it - nameLength = uc.ReadValue(); + nameLength = uc.ReadValue(); uc.Seek(nameLength + episodeContinueSize, SeekOrigin::Current); } } @@ -386,9 +386,9 @@ namespace Jazz2 return; } - so->WriteValue(0x2095A59FF0BFBBEF); - so->WriteValue(ContentResolver::ConfigFile); - so->WriteValue(FileVersion); + so->WriteValue(0x2095A59FF0BFBBEF); + so->WriteValue(ContentResolver::ConfigFile); + so->WriteValue(FileVersion); DeflateWriter co(*so); @@ -413,27 +413,27 @@ namespace Jazz2 if (ResumeOnStart) boolOptions |= BoolOptions::ResumeOnStart; if (EnableReforgedHUD) boolOptions |= BoolOptions::EnableReforgedHUD; if (EnableReforgedMainMenu) boolOptions |= BoolOptions::EnableReforgedMainMenu; - co.WriteValue((uint64_t)boolOptions); + co.WriteValue((std::uint64_t)boolOptions); if (Language[0] != '\0') { co.Write(Language, sizeof(Language)); } // Bitmask of unlocked episodes, used only if compiled with SHAREWARE_DEMO_ONLY - co.WriteValue((uint32_t)UnlockedEpisodes); + co.WriteValue((std::uint32_t)UnlockedEpisodes); - co.WriteValue((uint8_t)ActiveRescaleMode); + co.WriteValue((std::uint8_t)ActiveRescaleMode); - co.WriteValue((uint8_t)(MasterVolume * 255.0f)); - co.WriteValue((uint8_t)(SfxVolume * 255.0f)); - co.WriteValue((uint8_t)(MusicVolume * 255.0f)); + co.WriteValue((std::uint8_t)(MasterVolume * 255.0f)); + co.WriteValue((std::uint8_t)(SfxVolume * 255.0f)); + co.WriteValue((std::uint8_t)(MusicVolume * 255.0f)); - co.WriteValue((int8_t)(TouchLeftPadding.X * INT8_MAX * TouchPaddingMultiplier)); - co.WriteValue((int8_t)(TouchLeftPadding.Y * INT8_MAX * TouchPaddingMultiplier)); - co.WriteValue((int8_t)(TouchRightPadding.X * INT8_MAX * TouchPaddingMultiplier)); - co.WriteValue((int8_t)(TouchRightPadding.Y * INT8_MAX * TouchPaddingMultiplier)); + co.WriteValue((std::int8_t)(TouchLeftPadding.X * INT8_MAX * TouchPaddingMultiplier)); + co.WriteValue((std::int8_t)(TouchLeftPadding.Y * INT8_MAX * TouchPaddingMultiplier)); + co.WriteValue((std::int8_t)(TouchRightPadding.X * INT8_MAX * TouchPaddingMultiplier)); + co.WriteValue((std::int8_t)(TouchRightPadding.Y * INT8_MAX * TouchPaddingMultiplier)); - co.WriteValue((uint8_t)GamepadButtonLabels); + co.WriteValue((std::uint8_t)GamepadButtonLabels); // Controls auto mappings = UI::ControlScheme::GetMappings(); @@ -450,26 +450,26 @@ namespace Jazz2 } // Episode End - co.WriteValue((uint16_t)sizeof(EpisodeContinuationState)); - co.WriteValue((uint16_t)_episodeEnd.size()); + co.WriteValue((std::uint16_t)sizeof(EpisodeContinuationState)); + co.WriteValue((std::uint16_t)_episodeEnd.size()); for (auto& pair : _episodeEnd) { - co.WriteValue((uint8_t)pair.first.size()); + co.WriteValue((std::uint8_t)pair.first.size()); co.Write(pair.first.data(), (uint32_t)pair.first.size()); co.Write(&pair.second, sizeof(EpisodeContinuationState)); } // Episode Continue - co.WriteValue((uint16_t)sizeof(EpisodeContinuationState)); - co.WriteValue((uint16_t)_episodeContinue.size()); + co.WriteValue((std::uint16_t)sizeof(EpisodeContinuationState)); + co.WriteValue((std::uint16_t)_episodeContinue.size()); for (auto& pair : _episodeContinue) { - co.WriteValue((uint8_t)pair.first.size()); - co.Write(pair.first.data(), (uint32_t)pair.first.size()); + co.WriteValue((std::uint8_t)pair.first.size()); + co.Write(pair.first.data(), (std::uint32_t)pair.first.size()); - co.WriteValue((uint8_t)pair.second.LevelName.size()); - co.Write(pair.second.LevelName.data(), (uint32_t)pair.second.LevelName.size()); + co.WriteValue((std::uint8_t)pair.second.LevelName.size()); + co.Write(pair.second.LevelName.data(), (std::uint32_t)pair.second.LevelName.size()); co.Write(&pair.second.State, sizeof(EpisodeContinuationState)); } diff --git a/Sources/Jazz2/PreferencesCache.h b/Sources/Jazz2/PreferencesCache.h index 5e539baf..84209824 100644 --- a/Sources/Jazz2/PreferencesCache.h +++ b/Sources/Jazz2/PreferencesCache.h @@ -63,13 +63,13 @@ namespace Jazz2 // These structures are aligned manually, because they are serialized and it should work cross-platform struct EpisodeContinuationState { EpisodeContinuationFlags Flags; - uint8_t DifficultyAndPlayerType; - uint8_t Lives; - uint8_t Unused1; - int32_t Score; - uint16_t Unused2; - uint16_t Ammo[(int32_t)WeaponType::Count]; - uint8_t WeaponUpgrades[(int32_t)WeaponType::Count]; + std::uint8_t DifficultyAndPlayerType; + std::uint8_t Lives; + std::uint8_t Unused1; + std::int32_t Score; + std::uint16_t Unused2; + std::uint16_t Ammo[(std::int32_t)WeaponType::Count]; + std::uint8_t WeaponUpgrades[(std::int32_t)WeaponType::Count]; }; struct EpisodeContinuationStateWithLevel { diff --git a/Sources/Jazz2/UI/Canvas.cpp b/Sources/Jazz2/UI/Canvas.cpp index 9fe40150..429c8bad 100644 --- a/Sources/Jazz2/UI/Canvas.cpp +++ b/Sources/Jazz2/UI/Canvas.cpp @@ -33,7 +33,7 @@ namespace Jazz2::UI _currentRenderQueue->addCommand(command); } - void Canvas::DrawTexture(const Texture& texture, const Vector2f& pos, uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending, float angle) + void Canvas::DrawTexture(const Texture& texture, const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending, float angle) { auto command = RentRenderCommand(); if (command->material().setShaderProgramType(Material::ShaderProgramType::Sprite)) { @@ -72,7 +72,7 @@ namespace Jazz2::UI _currentRenderQueue->addCommand(command); } - void Canvas::DrawSolid(const Vector2f& pos, uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending) + void Canvas::DrawSolid(const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending) { auto command = RentRenderCommand(); if (command->material().setShaderProgramType(Material::ShaderProgramType::SpriteNoTexture)) { diff --git a/Sources/Jazz2/UI/Canvas.h b/Sources/Jazz2/UI/Canvas.h index 59a5eacc..d2a0d4b6 100644 --- a/Sources/Jazz2/UI/Canvas.h +++ b/Sources/Jazz2/UI/Canvas.h @@ -21,8 +21,8 @@ namespace Jazz2::UI void OnUpdate(float timeMult) override; bool OnDraw(RenderQueue& renderQueue) override; - void DrawTexture(const Texture& texture, const Vector2f& pos, uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f); - void DrawSolid(const Vector2f& pos, uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending = false); + void DrawTexture(const Texture& texture, const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Vector4f& texCoords, const Colorf& color, bool additiveBlending = false, float angle = 0.0f); + void DrawSolid(const Vector2f& pos, std::uint16_t z, const Vector2f& size, const Colorf& color, bool additiveBlending = false); static Vector2f ApplyAlignment(Alignment align, const Vector2f& vec, const Vector2f& size); RenderCommand* RentRenderCommand(); @@ -30,7 +30,7 @@ namespace Jazz2::UI private: SmallVector, 0> _renderCommands; - int32_t _renderCommandsCount; + std::int32_t _renderCommandsCount; RenderQueue* _currentRenderQueue; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Cinematics.cpp b/Sources/Jazz2/UI/Cinematics.cpp index 9d3216f0..a1790b87 100644 --- a/Sources/Jazz2/UI/Cinematics.cpp +++ b/Sources/Jazz2/UI/Cinematics.cpp @@ -56,7 +56,7 @@ namespace Jazz2::UI UpdatePressedActions(); - if ((_pressedActions & ((1 << (int32_t)PlayerActions::Fire) | (1 << (16 + (int32_t)PlayerActions::Fire)))) == (1 << (int32_t)PlayerActions::Fire)) { + if ((_pressedActions & ((1 << (std::int32_t)PlayerActions::Fire) | (1 << (16 + (std::int32_t)PlayerActions::Fire)))) == (1 << (std::int32_t)PlayerActions::Fire)) { if (_callback != nullptr && _callback(_root, false)) { _callback = nullptr; _framesLeft = 0; @@ -64,18 +64,18 @@ namespace Jazz2::UI } } - void Cinematics::OnInitializeViewport(int32_t width, int32_t height) + void Cinematics::OnInitializeViewport(std::int32_t width, std::int32_t height) { constexpr float defaultRatio = (float)DefaultWidth / DefaultHeight; float currentRatio = (float)width / height; - int32_t w, h; + std::int32_t w, h; if (currentRatio > defaultRatio) { w = std::min(DefaultWidth, width); - h = (int32_t)(w / currentRatio); + h = (std::int32_t)(w / currentRatio); } else if (currentRatio < defaultRatio) { h = std::min(DefaultHeight, height); - w = (int32_t)(h * currentRatio); + w = (std::int32_t)(h * currentRatio); } else { w = std::min(DefaultWidth, width); h = std::min(DefaultHeight, height); @@ -132,7 +132,7 @@ namespace Jazz2::UI #endif // Mark Fire button as already pressed to avoid some issues - _pressedActions = (1 << (int32_t)PlayerActions::Fire) | (1 << ((int32_t)PlayerActions::Fire + 16)); + _pressedActions = (1 << (std::int32_t)PlayerActions::Fire) | (1 << ((std::int32_t)PlayerActions::Fire + 16)); } bool Cinematics::LoadCinematicsFromFile(const StringView path) @@ -156,24 +156,24 @@ namespace Jazz2::UI RETURNF_ASSERT_MSG(strncmp((const char*)internalBuffer, "CineFeed", sizeof("CineFeed") - 1) == 0, "Cannot load \"%s.j2v\" - invalid signature", path.data()); - _width = s->ReadValue(); - _height = s->ReadValue(); + _width = s->ReadValue(); + _height = s->ReadValue(); s->Seek(2, SeekOrigin::Current); // Bits per pixel - _frameDelay = s->ReadValue() / (FrameTimer::SecondsPerFrame * 1000); // Delay in milliseconds - _framesLeft = s->ReadValue(); + _frameDelay = s->ReadValue() / (FrameTimer::SecondsPerFrame * 1000); // Delay in milliseconds + _framesLeft = s->ReadValue(); s->Seek(20, SeekOrigin::Current); _texture = std::make_unique("Cinematics", Texture::Format::RGBA8, _width, _height); - _buffer = std::make_unique(_width * _height); - _lastBuffer = std::make_unique(_width * _height); - _currentFrame = std::make_unique(_width * _height); + _buffer = std::make_unique(_width * _height); + _lastBuffer = std::make_unique(_width * _height); + _currentFrame = std::make_unique(_width * _height); // Read all 4 compressed streams std::uint32_t totalOffset = s->GetPosition(); while (totalOffset < s->GetSize()) { for (std::int32_t i = 0; i < static_cast(arraySize(_decompressedStreams)); i++) { - std::int32_t bytesLeft = s->ReadValue(); + std::int32_t bytesLeft = s->ReadValue(); totalOffset += 4 + bytesLeft; _compressedStreams[i].FetchFromStream(*s, bytesLeft); } @@ -315,7 +315,7 @@ namespace Jazz2::UI _frameIndex++; } - void Cinematics::Read(int streamIndex, void* buffer, std::uint32_t bytes) + void Cinematics::Read(std::int32_t streamIndex, void* buffer, std::uint32_t bytes) { _decompressedStreams[streamIndex].Read(buffer, bytes); } diff --git a/Sources/Jazz2/UI/Cinematics.h b/Sources/Jazz2/UI/Cinematics.h index 6734d79b..30054ef5 100644 --- a/Sources/Jazz2/UI/Cinematics.h +++ b/Sources/Jazz2/UI/Cinematics.h @@ -24,8 +24,8 @@ namespace Jazz2::UI class Cinematics : public IStateHandler { public: - static constexpr int DefaultWidth = 720; - static constexpr int DefaultHeight = 405; + static constexpr std::int32_t DefaultWidth = 720; + static constexpr std::int32_t DefaultHeight = 405; static constexpr std::uint8_t SfxListVersion = 1; @@ -34,7 +34,7 @@ namespace Jazz2::UI ~Cinematics() override; void OnBeginFrame() override; - void OnInitializeViewport(int width, int height) override; + void OnInitializeViewport(std::int32_t width, std::int32_t height) override; void OnKeyPressed(const KeyboardEvent& event) override; void OnKeyReleased(const KeyboardEvent& event) override; @@ -85,30 +85,30 @@ namespace Jazz2::UI SmallVector _sfxPlaylist; #endif std::function _callback; - uint32_t _width, _height; + std::uint32_t _width, _height; float _frameDelay, _frameProgress; - int _frameIndex; - int _framesLeft; + std::int32_t _frameIndex; + std::int32_t _framesLeft; std::unique_ptr _texture; - std::unique_ptr _buffer; - std::unique_ptr _lastBuffer; - std::unique_ptr _currentFrame; - uint32_t _palette[256]; + std::unique_ptr _buffer; + std::unique_ptr _lastBuffer; + std::unique_ptr _currentFrame; + std::uint32_t _palette[256]; MemoryStream _compressedStreams[4]; DeflateStream _decompressedStreams[4]; BitArray _pressedKeys; - uint32_t _pressedActions; + std::uint32_t _pressedActions; void Initialize(const StringView path); bool LoadCinematicsFromFile(const StringView path); bool LoadSfxList(const StringView path); void PrepareNextFrame(); - void Read(int streamIndex, void* buffer, uint32_t bytes); + void Read(std::int32_t streamIndex, void* buffer, std::uint32_t bytes); void UpdatePressedActions(); template - inline T ReadValue(int streamIndex) { + inline T ReadValue(std::int32_t streamIndex) { T buffer; Read(streamIndex, &buffer, sizeof(T)); return buffer; diff --git a/Sources/Jazz2/UI/ControlScheme.cpp b/Sources/Jazz2/UI/ControlScheme.cpp index a0bbd223..9889070e 100644 --- a/Sources/Jazz2/UI/ControlScheme.cpp +++ b/Sources/Jazz2/UI/ControlScheme.cpp @@ -215,18 +215,18 @@ namespace Jazz2::UI } // Also allow Return (Enter) as confirm key - if (pressedKeys[(uint32_t)KeySym::RETURN]) { - pressedActions |= (1 << (int32_t)PlayerActions::Fire); + if (pressedKeys[(std::uint32_t)KeySym::RETURN]) { + pressedActions |= (1 << (std::int32_t)PlayerActions::Fire); } #if defined(DEATH_TARGET_ANDROID) // Allow native Android back button as menu key - if (PreferencesCache::UseNativeBackButton && pressedKeys[(uint32_t)KeySym::BACK]) { - pressedActions |= (1 << (int32_t)PlayerActions::Menu); + if (PreferencesCache::UseNativeBackButton && pressedKeys[(std::uint32_t)KeySym::BACK]) { + pressedActions |= (1 << (std::int32_t)PlayerActions::Menu); } #endif // Use ChangeWeapon action as delete key - if (pressedKeys[(uint32_t)KeySym::Delete]) { - pressedActions |= (1 << (int32_t)PlayerActions::ChangeWeapon); + if (pressedKeys[(std::uint32_t)KeySym::Delete]) { + pressedActions |= (1 << (std::int32_t)PlayerActions::ChangeWeapon); } return pressedActions; diff --git a/Sources/Jazz2/UI/Font.cpp b/Sources/Jazz2/UI/Font.cpp index abba64a5..e8c90f17 100644 --- a/Sources/Jazz2/UI/Font.cpp +++ b/Sources/Jazz2/UI/Font.cpp @@ -13,7 +13,7 @@ using namespace Death; namespace Jazz2::UI { - Font::Font(const StringView path, const uint32_t* palette) + Font::Font(const StringView path, const std::uint32_t* palette) : _baseSpacing(0) { auto s = fs::Open(path + ".font"_s, FileAccess::Read); @@ -30,23 +30,23 @@ namespace Jazz2::UI return; } - int32_t w = texLoader->width(); - int32_t h = texLoader->height(); - auto pixels = (uint32_t*)texLoader->pixels(); + std::int32_t w = texLoader->width(); + std::int32_t h = texLoader->height(); + auto pixels = (std::uint32_t*)texLoader->pixels(); - /*uint8_t flags =*/ s->ReadValue(); - uint16_t width = s->ReadValue(); - uint16_t height = s->ReadValue(); - uint8_t cols = s->ReadValue(); - int32_t rows = h / height; - int16_t spacing = s->ReadValue(); - uint8_t asciiFirst = s->ReadValue(); - uint8_t asciiCount = s->ReadValue(); + /*std::uint8_t flags =*/ s->ReadValue(); + std::uint16_t width = s->ReadValue(); + std::uint16_t height = s->ReadValue(); + std::uint8_t cols = s->ReadValue(); + std::int32_t rows = h / height; + std::int16_t spacing = s->ReadValue(); + std::uint8_t asciiFirst = s->ReadValue(); + std::uint8_t asciiCount = s->ReadValue(); - uint8_t widths[128]; + std::uint8_t widths[128]; s->Read(widths, asciiCount); - int32_t i = 0; + std::int32_t i = 0; for (; i < asciiCount; i++) { _asciiChars[i + asciiFirst] = Rectf( (float)(i % cols) / cols, @@ -56,19 +56,19 @@ namespace Jazz2::UI ); } - int32_t unicodeCharCount = asciiCount + s->ReadValue(); + std::int32_t unicodeCharCount = asciiCount + s->ReadValue(); for (; i < unicodeCharCount; i++) { char c[4] {}; s->Read(c, 1); - int32_t remainingBytes = + std::int32_t remainingBytes = ((c[0] & 240) == 240) ? 3 : ( ((c[0] & 224) == 224) ? 2 : ( ((c[0] & 192) == 192) ? 1 : 0 )); if (remainingBytes == 0) { // Placeholder for unknown characters - uint8_t charWidth = s->ReadValue(); + std::uint8_t charWidth = s->ReadValue(); if (c[0] == 0) { _asciiChars[0] = Rectf( (float)(i % cols) / cols, @@ -81,7 +81,7 @@ namespace Jazz2::UI } s->Read(c + 1, remainingBytes); - uint8_t charWidth = s->ReadValue(); + std::uint8_t charWidth = s->ReadValue(); std::pair cursor = Utf8::NextChar(c, 0); _unicodeChars[cursor.first] = Rectf( @@ -95,8 +95,8 @@ namespace Jazz2::UI _charSize = Vector2i(width, height); _baseSpacing = spacing; - for (int32_t i = 0; i < w * h; i++) { - uint32_t color = palette[pixels[i] & 0xff]; + for (std::int32_t i = 0; i < w * h; i++) { + std::uint32_t color = palette[pixels[i] & 0xff]; pixels[i] = (color & 0xffffff) | ((((color >> 24) & 0xff) * ((pixels[i] >> 24) & 0xff) / 255) << 24); } @@ -137,7 +137,7 @@ namespace Jazz2::UI Vector2f Font::MeasureString(StringView text, float scale, float charSpacing, float lineSpacing) { - size_t textLength = text.size(); + std::size_t textLength = text.size(); if (textLength == 0 || _charSize.Y <= 0) { return Vector2f::Zero; } @@ -146,7 +146,7 @@ namespace Jazz2::UI float charSpacingPre = charSpacing; float scalePre = scale; - int32_t idx = 0; + std::int32_t idx = 0; do { std::pair cursor = Utf8::NextChar(text, idx); @@ -232,9 +232,9 @@ namespace Jazz2::UI return Vector2f(ceilf(totalWidth), ceilf(totalHeight)); } - void Font::DrawString(Canvas* canvas, StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, Colorf color, float scale, float angleOffset, float varianceX, float varianceY, float speed, float charSpacing, float lineSpacing) + void Font::DrawString(Canvas* canvas, StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, Colorf color, float scale, float angleOffset, float varianceX, float varianceY, float speed, float charSpacing, float lineSpacing) { - size_t textLength = text.size(); + std::size_t textLength = text.size(); if (textLength == 0 || _charSize.Y <= 0) { return; } @@ -243,7 +243,7 @@ namespace Jazz2::UI float phase = canvas->AnimTime * speed * 16.0f; // Maximum number of lines - center and right alignment starts to glitch if text has more lines, but it should be enough in most cases - constexpr int32_t MaxLines = 16; + constexpr std::int32_t MaxLines = 16; // Preprocessing float totalWidth = 0.0f, lastWidth = 0.0f, totalHeight = 0.0f; @@ -251,8 +251,8 @@ namespace Jazz2::UI float charSpacingPre = charSpacing; float scalePre = scale; - int32_t idx = 0; - int32_t line = 0; + std::int32_t idx = 0; + std::int32_t line = 0; do { std::pair cursor = Utf8::NextChar(text, idx); @@ -277,7 +277,7 @@ namespace Jazz2::UI cursor = Utf8::NextChar(text, idx); if (cursor.first == ':') { idx = cursor.second; - int32_t paramLength = 0; + std::int32_t paramLength = 0; char param[9]; do { cursor = Utf8::NextChar(text, idx); @@ -405,7 +405,7 @@ namespace Jazz2::UI cursor = Utf8::NextChar(text, idx); if (cursor.first == '#') { idx = cursor.second; - int32_t paramLength = 0; + std::int32_t paramLength = 0; char param[9]; do { cursor = Utf8::NextChar(text, idx); @@ -437,7 +437,7 @@ namespace Jazz2::UI cursor = Utf8::NextChar(text, idx); if (cursor.first == ':') { idx = cursor.second; - int32_t paramLength = 0; + std::int32_t paramLength = 0; char param[9]; do { cursor = Utf8::NextChar(text, idx); @@ -512,7 +512,7 @@ namespace Jazz2::UI pos.X = std::round(pos.X); pos.Y = std::round(pos.Y); - int32_t charWidth = _charSize.X; + std::int32_t charWidth = _charSize.X; if (charWidth > uvRect.W) { charWidth--; } diff --git a/Sources/Jazz2/UI/Font.h b/Sources/Jazz2/UI/Font.h index 2407f5e4..164495dc 100644 --- a/Sources/Jazz2/UI/Font.h +++ b/Sources/Jazz2/UI/Font.h @@ -17,14 +17,14 @@ namespace Jazz2::UI static constexpr Colorf RandomColor = Colorf(444.0f, 444.0f, 444.0f, 0.5f); static constexpr Colorf TransparentRandomColor = Colorf(444.0f, 444.0f, 444.0f, 0.36f); - Font(const StringView path, const uint32_t* palette); + Font(const StringView path, const std::uint32_t* palette); std::int32_t GetSizeInPixels() const; std::int32_t GetAscentInPixels() const; Vector2f MeasureChar(char32_t c) const; Vector2f MeasureString(StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f); Vector2f MeasureStringEx(StringView text, float scale, float charSpacing, float maxWidth, std::int32_t* charFit, float* charFitWidths); - void DrawString(Canvas* canvas, StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, Colorf color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f); + void DrawString(Canvas* canvas, StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, Colorf color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f); private: static constexpr Colorf RandomColors[] = { @@ -40,7 +40,7 @@ namespace Jazz2::UI }; Rectf _asciiChars[128]; - HashMap _unicodeChars; + HashMap _unicodeChars; Vector2i _charSize; std::int32_t _baseSpacing; std::unique_ptr _texture; diff --git a/Sources/Jazz2/UI/HUD.cpp b/Sources/Jazz2/UI/HUD.cpp index 977a7e82..520cb200 100644 --- a/Sources/Jazz2/UI/HUD.cpp +++ b/Sources/Jazz2/UI/HUD.cpp @@ -13,7 +13,7 @@ #include "../../nCine/Application.h" // Position of key in 22x6 grid -static const uint8_t KeyLayout[] = { +static const std::uint8_t KeyLayout[] = { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, @@ -205,7 +205,7 @@ namespace Jazz2::UI adjustedView.W = adjustedView.W - adjustedView.X - (195.0f + PreferencesCache::TouchRightPadding.X); } - int32_t charOffset = 0; + std::int32_t charOffset = 0; char stringBuffer[32]; auto& players = _levelHandler->GetPlayers(); @@ -265,7 +265,7 @@ namespace Jazz2::UI // FPS if (PreferencesCache::ShowPerformanceMetrics) { - i32tos((int32_t)std::round(theApplication().GetFrameTimer().GetAverageFps()), stringBuffer); + i32tos((std::int32_t)std::round(theApplication().GetFrameTimer().GetAverageFps()), stringBuffer); _smallFont->DrawString(this, stringBuffer, charOffset, view.W - 4.0f, view.Y + 1.0f, FontLayer, Alignment::TopRight, Font::DefaultColor, 0.8f, 0.0f, 0.0f, 0.0f, 0.0f, 0.96f); } @@ -302,23 +302,23 @@ namespace Jazz2::UI if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x * (float)ViewSize.X; float y = event.pointers[pointerIndex].y * (float)ViewSize.Y; - for (uint32_t i = 0; i < TouchButtonsCount; i++) { + for (std::uint32_t i = 0; i < TouchButtonsCount; i++) { auto& button = _touchButtons[i]; if (button.Action != PlayerActions::None) { if (button.CurrentPointerId == -1 && IsOnButton(button, x, y)) { button.CurrentPointerId = event.actionIndex; - overrideActions |= (1 << (int32_t)button.Action); + overrideActions |= (1 << (std::int32_t)button.Action); } } } } } else if (event.type == TouchEventType::Move) { - for (uint32_t i = 0; i < TouchButtonsCount; i++) { + for (std::uint32_t i = 0; i < TouchButtonsCount; i++) { auto& button = _touchButtons[i]; if (button.Action != PlayerActions::None) { if (button.CurrentPointerId != -1) { bool isPressed = false; - int32_t pointerIndex = event.findPointerIndex(button.CurrentPointerId); + std::int32_t pointerIndex = event.findPointerIndex(button.CurrentPointerId); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x * (float)ViewSize.X; float y = event.pointers[pointerIndex].y * (float)ViewSize.Y; @@ -327,7 +327,7 @@ namespace Jazz2::UI if (!isPressed) { button.CurrentPointerId = -1; - overrideActions &= ~(1 << (int32_t)button.Action); + overrideActions &= ~(1 << (std::int32_t)button.Action); } } else { // Only some buttons should allow roll-over (only when the player's on foot) @@ -335,12 +335,12 @@ namespace Jazz2::UI bool canPlayerMoveVertically = (!players.empty() && players[0]->CanMoveVertically()); if ((button.Align & AllowRollover) != AllowRollover && !canPlayerMoveVertically) continue; - for (uint32_t j = 0; j < event.count; j++) { + for (std::uint32_t j = 0; j < event.count; j++) { float x = event.pointers[j].x * (float)ViewSize.X; float y = event.pointers[j].y * (float)ViewSize.Y; if (IsOnButton(button, x, y)) { button.CurrentPointerId = event.pointers[j].id; - overrideActions |= (1 << (int32_t)button.Action); + overrideActions |= (1 << (std::int32_t)button.Action); break; } } @@ -348,20 +348,20 @@ namespace Jazz2::UI } } } else if (event.type == TouchEventType::Up) { - for (uint32_t i = 0; i < TouchButtonsCount; i++) { + for (std::uint32_t i = 0; i < TouchButtonsCount; i++) { auto& button = _touchButtons[i]; if (button.CurrentPointerId != -1) { button.CurrentPointerId = -1; - overrideActions &= ~(1 << (int32_t)button.Action); + overrideActions &= ~(1 << (std::int32_t)button.Action); } } } else if (event.type == TouchEventType::PointerUp) { - for (uint32_t i = 0; i < TouchButtonsCount; i++) { + for (std::uint32_t i = 0; i < TouchButtonsCount; i++) { auto& button = _touchButtons[i]; if (button.CurrentPointerId == event.actionIndex) { button.CurrentPointerId = -1; - overrideActions &= ~(1 << (int32_t)button.Action); + overrideActions &= ~(1 << (std::int32_t)button.Action); } } } @@ -377,7 +377,7 @@ namespace Jazz2::UI _levelTextTime = 0.0f; } - void HUD::ShowCoins(int32_t count) + void HUD::ShowCoins(std::int32_t count) { constexpr float StillTime = 120.0f; constexpr float TransitionTime = 60.0f; @@ -399,7 +399,7 @@ namespace Jazz2::UI } } - void HUD::ShowGems(int32_t count) + void HUD::ShowGems(std::int32_t count) { constexpr float StillTime = 120.0f; constexpr float TransitionTime = 60.0f; @@ -728,7 +728,7 @@ namespace Jazz2::UI float textScale = (ViewSize.X >= 360 ? 1.0f : 0.8f); - int32_t charOffsetShadow = charOffset; + std::int32_t charOffsetShadow = charOffset; _smallFont->DrawString(this, _levelText, charOffsetShadow, ViewSize.X * 0.5f + offset, ViewSize.Y * 0.04f + 2.5f, FontShadowLayer, Alignment::Top, Colorf(0.0f, 0.0f, 0.0f, 0.3f), textScale, 0.72f, 0.8f, 0.8f); @@ -741,7 +741,7 @@ namespace Jazz2::UI } } - void HUD::DrawCoins(int32_t& charOffset) + void HUD::DrawCoins(std::int32_t& charOffset) { constexpr float StillTime = 120.0f; constexpr float TransitionTime = 60.0f; @@ -774,7 +774,7 @@ namespace Jazz2::UI char stringBuffer[32]; snprintf(stringBuffer, arraySize(stringBuffer), "x%i", _coins); - int32_t charOffsetShadow = charOffset; + std::int32_t charOffsetShadow = charOffset; _smallFont->DrawString(this, stringBuffer, charOffsetShadow, ViewSize.X * 0.5f, ViewSize.Y * 0.92f + 2.5f + offset, FontShadowLayer, Alignment::Left, Colorf(0.0f, 0.0f, 0.0f, 0.3f * alpha), 1.0f, 0.0f, 0.0f, 0.0f); @@ -788,7 +788,7 @@ namespace Jazz2::UI } } - void HUD::DrawGems(int32_t& charOffset) + void HUD::DrawGems(std::int32_t& charOffset) { constexpr float StillTime = 120.0f; constexpr float TransitionTime = 60.0f; @@ -821,7 +821,7 @@ namespace Jazz2::UI char stringBuffer[32]; snprintf(stringBuffer, arraySize(stringBuffer), "x%i", _gems); - int32_t charOffsetShadow = charOffset; + std::int32_t charOffsetShadow = charOffset; _smallFont->DrawString(this, stringBuffer, charOffsetShadow, ViewSize.X * 0.5f, ViewSize.Y * 0.92f + 2.5f + offset, FontShadowLayer, Alignment::Left, Colorf(0.0f, 0.0f, 0.0f, 0.3f * alpha), 1.0f, 0.0f, 0.0f, 0.0f); @@ -835,7 +835,7 @@ namespace Jazz2::UI } } - void HUD::DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, float angle) + void HUD::DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, float angle) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -843,7 +843,7 @@ namespace Jazz2::UI } if (frame < 0) { - frame = res->FrameOffset + ((int32_t)(AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); + frame = res->FrameOffset + ((std::int32_t)(AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); } GenericGraphicResource* base = res->Base; @@ -851,8 +851,8 @@ namespace Jazz2::UI Vector2f adjustedPos = ApplyAlignment(align, Vector2f(x, y), size); Vector2i texSize = base->TextureDiffuse->size(); - int32_t col = frame % base->FrameConfiguration.X; - int32_t row = frame / base->FrameConfiguration.X; + std::int32_t col = frame % base->FrameConfiguration.X; + std::int32_t row = frame / base->FrameConfiguration.X; Vector4f texCoords = Vector4f( float(base->FrameDimensions.X) / float(texSize.X), float(base->FrameDimensions.X * col) / float(texSize.X), @@ -863,7 +863,7 @@ namespace Jazz2::UI DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending, angle); } - void HUD::DrawElementClipped(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float clipX, float clipY) + void HUD::DrawElementClipped(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float clipX, float clipY) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -871,7 +871,7 @@ namespace Jazz2::UI } if (frame < 0) { - frame = res->FrameOffset + ((int32_t)(AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); + frame = res->FrameOffset + ((std::int32_t)(AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); } GenericGraphicResource* base = res->Base; @@ -879,8 +879,8 @@ namespace Jazz2::UI Vector2f adjustedPos = ApplyAlignment(align, Vector2f(x, y), base->FrameDimensions.As()); Vector2i texSize = base->TextureDiffuse->size(); - int32_t col = frame % base->FrameConfiguration.X; - int32_t row = frame / base->FrameConfiguration.X; + std::int32_t col = frame % base->FrameConfiguration.X; + std::int32_t row = frame / base->FrameConfiguration.X; Vector4f texCoords = Vector4f( std::floor(float(base->FrameDimensions.X) * clipX) / float(texSize.X), float(base->FrameDimensions.X * col) / float(texSize.X), @@ -905,7 +905,7 @@ namespace Jazz2::UI offset.X += 6; } - if ((player->_weaponUpgrades[(int32_t)weapon] & 0x01) != 0) { + if ((player->_weaponUpgrades[(std::int32_t)weapon] & 0x01) != 0) { switch (weapon) { default: case WeaponType::Blaster: @@ -991,7 +991,7 @@ namespace Jazz2::UI _weaponWheelRenderCommandsCount = 0; float requestedAngle; - int32_t requestedIndex; + std::int32_t requestedIndex; if (h == 0.0f && v == 0.0f) { requestedAngle = NAN; requestedIndex = -1; @@ -1006,7 +1006,7 @@ namespace Jazz2::UI adjustedAngle -= fTwoPi; } - requestedIndex = (int32_t)(_weaponWheelCount * adjustedAngle / fTwoPi); + requestedIndex = (std::int32_t)(_weaponWheelCount * adjustedAngle / fTwoPi); } float alpha = _weaponWheelAnim / WeaponWheelAnimDuration; @@ -1021,7 +1021,7 @@ namespace Jazz2::UI } float angle = -fPiOver2; - for (int32_t i = 0, j = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { + for (std::int32_t i = 0, j = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { if (player->_weaponAmmo[i] != 0) { float x = cosf(angle) * distance; float y = sinf(angle) * distance; @@ -1054,7 +1054,7 @@ namespace Jazz2::UI ammoCount = stringBuffer; } - int32_t charOffset = 0; + std::int32_t charOffset = 0; _smallFont->DrawString(this, ammoCount, charOffset, center.X + cosf(angle) * distance * 1.4f, center.Y + sinf(angle) * distance * 1.4f, FontLayer, Alignment::Center, isSelected ? Colorf(0.62f, 0.44f, 0.34f, 0.5f * alpha) : Colorf(0.45f, 0.45f, 0.45f, 0.48f * alpha), 0.9f, 0.0f, 0.0f, 0.0f, 0.0f, 0.9f); } @@ -1079,7 +1079,7 @@ namespace Jazz2::UI } } - bool HUD::PrepareWeaponWheel(Actors::Player* player, int& weaponCount) + bool HUD::PrepareWeaponWheel(Actors::Player* player, std::int32_t& weaponCount) { weaponCount = 0; @@ -1114,11 +1114,11 @@ namespace Jazz2::UI return (weaponCount > 0); } - int32_t HUD::GetWeaponCount(Actors::Player* player) + std::int32_t HUD::GetWeaponCount(Actors::Player* player) { - int32_t weaponCount = 0; + std::int32_t weaponCount = 0; - for (int32_t i = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { + for (std::int32_t i = 0; i < static_cast(arraySize(player->_weaponAmmo)); i++) { if (player->_weaponAmmo[i] != 0) { weaponCount++; } @@ -1132,15 +1132,15 @@ namespace Jazz2::UI return weaponCount; } - void HUD::DrawWeaponWheelSegment(float x, float y, float width, float height, uint16_t z, float minAngle, float maxAngle, const Texture& texture, const Colorf& color) + void HUD::DrawWeaponWheelSegment(float x, float y, float width, float height, std::uint16_t z, float minAngle, float maxAngle, const Texture& texture, const Colorf& color) { width *= 0.5f; x += width; height *= 0.5f; y += height; float angleRange = std::min(maxAngle - minAngle, fRadAngle360); - int32_t segmentNum = std::clamp((int32_t)std::round(powf(std::max(width, height), 0.65f) * 3.5f * angleRange / fRadAngle360), 4, 128); + std::int32_t segmentNum = std::clamp((std::int32_t)std::round(powf(std::max(width, height), 0.65f) * 3.5f * angleRange / fRadAngle360), 4, 128); float angleStep = angleRange / (segmentNum - 1); - int32_t vertexCount = segmentNum + 2; + std::int32_t vertexCount = segmentNum + 2; float angle = minAngle; Vertex* vertices = &_weaponWheelVertices[_weaponWheelVerticesCount]; @@ -1154,14 +1154,14 @@ namespace Jazz2::UI constexpr float Mult = 2.2f; { - int32_t j = 0; + std::int32_t j = 0; vertices[j].X = x + cosf(angle) * (width * Mult - 0.5f); vertices[j].Y = y + sinf(angle) * (height * Mult - 0.5f); vertices[j].U = 0.0f; vertices[j].V = 0.0f; } - for (int32_t i = 1; i < vertexCount - 1; i++) { + for (std::int32_t i = 1; i < vertexCount - 1; i++) { vertices[i].X = x + cosf(angle) * (width - 0.5f); vertices[i].Y = y + sinf(angle) * (height - 0.5f); vertices[i].U = 0.15f + (0.7f * (float)(i - 1) / (vertexCount - 3)); @@ -1173,7 +1173,7 @@ namespace Jazz2::UI { angle -= angleStep; - int32_t j = vertexCount - 1; + std::int32_t j = vertexCount - 1; vertices[j].X = x + cosf(angle) * (width * Mult - 0.5f); vertices[j].Y = y + sinf(angle) * (height * Mult - 0.5f); vertices[j].U = 1.0f; @@ -1286,32 +1286,32 @@ namespace Jazz2::UI _rgbHealthLast = lerp(_rgbHealthLast, health, 0.2f); _rgbAmbientLight = _levelHandler->_ambientColor.W; - constexpr int32_t KeyMax2 = 14; + constexpr std::int32_t KeyMax2 = 14; Color colors[RgbLights::ColorsSize] { }; Color* captionTile = _levelHandler->_tileMap->GetCaptionTile(); if (captionTile != nullptr) { - for (int32_t i = 0; i < static_cast(arraySize(KeyLayout)); i++) { - int32_t x = KeyLayout[i] % AURA_KEYBOARD_WIDTH; - int32_t y = KeyLayout[i] / AURA_KEYBOARD_WIDTH; + for (std::int32_t i = 0; i < static_cast(arraySize(KeyLayout)); i++) { + std::int32_t x = KeyLayout[i] % AURA_KEYBOARD_WIDTH; + std::int32_t y = KeyLayout[i] / AURA_KEYBOARD_WIDTH; Color tileColor = captionTile[y * 32 + x]; colors[AURA_COLORS_LIMITED_SIZE + i] = ApplyRgbGradientAlpha(tileColor, x, y, _rgbLightsAnim, _rgbAmbientLight); } } - int32_t percent, percentR, percentG; - percent = (int32_t)(_rgbHealthLast * 255); + std::int32_t percent, percentR, percentG; + percent = (std::int32_t)(_rgbHealthLast * 255); percentG = percent * percent / 255; percentR = (255 - (percent - 120) * 2); percentR = std::clamp(percentR, 0, 255); - for (int32_t i = 0; i < KeyMax2; i++) { - int32_t intensity = (int32_t)((_rgbHealthLast - ((float)i / KeyMax2)) * 255 * KeyMax2); + for (std::int32_t i = 0; i < KeyMax2; i++) { + std::int32_t intensity = (std::int32_t)((_rgbHealthLast - ((float)i / KeyMax2)) * 255 * KeyMax2); intensity = std::clamp(intensity, 0, 200); if (intensity > 0) { - colors[(int32_t)AuraLight::Tilde + i] = Color(percentR * intensity / 255, percentG * intensity / 255, 0); - colors[(int32_t)AuraLight::Tab + i] = Color(percentR * intensity / (255 * 12), percentG * intensity / (255 * 12), 0); + colors[(std::int32_t)AuraLight::Tilde + i] = Color(percentR * intensity / 255, percentG * intensity / 255, 0); + colors[(std::int32_t)AuraLight::Tab + i] = Color(percentR * intensity / (255 * 12), percentG * intensity / (255 * 12), 0); } } diff --git a/Sources/Jazz2/UI/HUD.h b/Sources/Jazz2/UI/HUD.h index cc39d9af..89444577 100644 --- a/Sources/Jazz2/UI/HUD.h +++ b/Sources/Jazz2/UI/HUD.h @@ -28,8 +28,8 @@ namespace Jazz2::UI void OnTouchEvent(const TouchEvent& event, uint32_t& overrideActions); void ShowLevelText(const StringView text); - void ShowCoins(int32_t count); - void ShowGems(int32_t count); + void ShowCoins(std::int32_t count); + void ShowGems(std::int32_t count); void BeginFadeIn(); void BeginFadeOut(float delay = 0.0f); @@ -53,7 +53,7 @@ namespace Jazz2::UI float Height; GraphicResource* Graphics; - int32_t CurrentPointerId; + std::int32_t CurrentPointerId; Alignment Align; }; @@ -67,21 +67,21 @@ namespace Jazz2::UI : X(x), Y(y), U(u), V(v) {} }; - static constexpr uint32_t VertexBytes = sizeof(Vertex); - static constexpr uint32_t VertexFloats = VertexBytes / sizeof(float); + static constexpr std::uint32_t VertexBytes = sizeof(Vertex); + static constexpr std::uint32_t VertexFloats = VertexBytes / sizeof(float); static constexpr Alignment Fixed = (Alignment)0x40; static constexpr Alignment AllowRollover = (Alignment)0x80; - static constexpr uint16_t MainLayer = 100; - static constexpr uint16_t ShadowLayer = 80; - static constexpr uint16_t FontLayer = 200; - static constexpr uint16_t FontShadowLayer = 120; - static constexpr uint16_t TouchButtonsLayer = 400; - static constexpr int32_t TouchButtonsCount = 10; + static constexpr std::uint16_t MainLayer = 100; + static constexpr std::uint16_t ShadowLayer = 80; + static constexpr std::uint16_t FontLayer = 200; + static constexpr std::uint16_t FontShadowLayer = 120; + static constexpr std::uint16_t TouchButtonsLayer = 400; + static constexpr std::int32_t TouchButtonsCount = 10; static constexpr float WeaponWheelAnimDuration = 20.0f; - static constexpr int32_t WeaponWheelMaxVertices = 512; + static constexpr std::int32_t WeaponWheelMaxVertices = 512; LevelHandler* _levelHandler; Metadata* _metadata; @@ -90,22 +90,22 @@ namespace Jazz2::UI String _levelText; float _levelTextTime; - int32_t _coins; - int32_t _gems; + std::int32_t _coins; + std::int32_t _gems; float _coinsTime; float _gemsTime; float _activeBossTime; float _rgbAmbientLight; float _rgbHealthLast; - int32_t _weaponWheelCount; + std::int32_t _weaponWheelCount; float _weaponWheelAnim; bool _weaponWheelShown; SmallVector, 0> _weaponWheelRenderCommands; - int32_t _weaponWheelRenderCommandsCount; + std::int32_t _weaponWheelRenderCommandsCount; std::unique_ptr _weaponWheelVertices; - int32_t _weaponWheelVerticesCount; - int32_t _lastWeaponWheelIndex; + std::int32_t _weaponWheelVerticesCount; + std::int32_t _lastWeaponWheelIndex; float _rgbLightsAnim; float _rgbLightsTime; TransitionState _transitionState; @@ -119,18 +119,18 @@ namespace Jazz2::UI void DrawScore(const Rectf& view, Actors::Player* player); void DrawWeaponAmmo(const Rectf& adjustedView, Actors::Player* player); void DrawActiveBoss(const Rectf& adjustedView); - void DrawLevelText(int32_t& charOffset); - void DrawCoins(int32_t& charOffset); - void DrawGems(int32_t& charOffset); + void DrawLevelText(std::int32_t& charOffset); + void DrawCoins(std::int32_t& charOffset); + void DrawGems(std::int32_t& charOffset); - void DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, float angle = 0.0f); - void DrawElementClipped(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float clipX, float clipY); + void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, float angle = 0.0f); + void DrawElementClipped(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float clipX, float clipY); AnimState GetCurrentWeapon(Actors::Player* player, WeaponType weapon, Vector2f& offset); void DrawWeaponWheel(Actors::Player* player); - bool PrepareWeaponWheel(Actors::Player* player, int& weaponCount); - static int32_t GetWeaponCount(Actors::Player* player); - void DrawWeaponWheelSegment(float x, float y, float width, float height, uint16_t z, float minAngle, float maxAngle, const Texture& texture, const Colorf& color); + bool PrepareWeaponWheel(Actors::Player* player, std::int32_t& weaponCount); + static std::int32_t GetWeaponCount(Actors::Player* player); + void DrawWeaponWheelSegment(float x, float y, float width, float height, std::uint16_t z, float minAngle, float maxAngle, const Texture& texture, const Colorf& color); TouchButtonInfo CreateTouchButton(PlayerActions action, AnimState state, Alignment align, float x, float y, float w, float h); bool IsOnButton(const TouchButtonInfo& button, float x, float y); diff --git a/Sources/Jazz2/UI/LoadingHandler.cpp b/Sources/Jazz2/UI/LoadingHandler.cpp index 83bc6f25..29442c1c 100644 --- a/Sources/Jazz2/UI/LoadingHandler.cpp +++ b/Sources/Jazz2/UI/LoadingHandler.cpp @@ -37,7 +37,7 @@ namespace Jazz2::UI } } - void LoadingHandler::OnInitializeViewport(int32_t width, int32_t height) + void LoadingHandler::OnInitializeViewport(std::int32_t width, std::int32_t height) { constexpr float defaultRatio = (float)DefaultWidth / DefaultHeight; float currentRatio = (float)width / height; @@ -79,8 +79,8 @@ namespace Jazz2::UI Vector2f pos = Vector2f(ViewSize.X - size.X - 50.0f, ViewSize.Y - size.Y - 40.0f); Vector2i texSize = base->TextureDiffuse->size(); - int32_t col = frame % base->FrameConfiguration.X; - int32_t row = frame / base->FrameConfiguration.X; + std::int32_t col = frame % base->FrameConfiguration.X; + std::int32_t row = frame / base->FrameConfiguration.X; Vector4f texCoords = Vector4f( float(base->FrameDimensions.X) / float(texSize.X), float(base->FrameDimensions.X * col) / float(texSize.X), diff --git a/Sources/Jazz2/UI/LoadingHandler.h b/Sources/Jazz2/UI/LoadingHandler.h index 89c2b515..f1bfe041 100644 --- a/Sources/Jazz2/UI/LoadingHandler.h +++ b/Sources/Jazz2/UI/LoadingHandler.h @@ -11,8 +11,8 @@ namespace Jazz2::UI class LoadingHandler : public IStateHandler { public: - static constexpr int32_t DefaultWidth = 720; - static constexpr int32_t DefaultHeight = 405; + static constexpr std::int32_t DefaultWidth = 720; + static constexpr std::int32_t DefaultHeight = 405; LoadingHandler(IRootController* root); LoadingHandler(IRootController* root, const std::function& callback); @@ -20,7 +20,7 @@ namespace Jazz2::UI ~LoadingHandler() override; void OnBeginFrame() override; - void OnInitializeViewport(int32_t width, int32_t height) override; + void OnInitializeViewport(std::int32_t width, std::int32_t height) override; private: IRootController* _root; diff --git a/Sources/Jazz2/UI/Menu/BeginSection.cpp b/Sources/Jazz2/UI/Menu/BeginSection.cpp index fd2b3061..b893af99 100644 --- a/Sources/Jazz2/UI/Menu/BeginSection.cpp +++ b/Sources/Jazz2/UI/Menu/BeginSection.cpp @@ -126,10 +126,10 @@ namespace Jazz2::UI::Menu ExecuteSelected(); } else if (_root->ActionHit(PlayerActions::Menu)) { #if !defined(DEATH_TARGET_EMSCRIPTEN) && !defined(DEATH_TARGET_IOS) && !defined(DEATH_TARGET_SWITCH) - if (_selectedIndex != (int32_t)_items.size() - 1) { + if (_selectedIndex != (std::int32_t)_items.size() - 1) { _root->PlaySfx("MenuSelect"_s, 0.6f); _animation = 0.0f; - _selectedIndex = (int32_t)_items.size() - 1; + _selectedIndex = (std::int32_t)_items.size() - 1; } #endif } else if (_root->ActionHit(PlayerActions::Up)) { @@ -142,13 +142,13 @@ namespace Jazz2::UI::Menu goto SkipDisabledOnUp; } } else { - _selectedIndex = (int32_t)_items.size() - 1; + _selectedIndex = (std::int32_t)_items.size() - 1; } } else if (_root->ActionHit(PlayerActions::Down)) { _root->PlaySfx("MenuSelect"_s, 0.5f); _animation = 0.0f; SkipDisabledOnDown: - if (_selectedIndex < (int32_t)_items.size() - 1) { + if (_selectedIndex < (std::int32_t)_items.size() - 1) { _selectedIndex++; if (_items[_selectedIndex].Y <= DisabledItem) { goto SkipDisabledOnDown; @@ -168,12 +168,12 @@ namespace Jazz2::UI::Menu void BeginSection::OnDraw(Canvas* canvas) { Recti contentBounds = _root->GetContentBounds(); - Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.2f * (1.0f - 0.048f * (int32_t)_items.size())); + Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.2f * (1.0f - 0.048f * (std::int32_t)_items.size())); if (contentBounds.H < 230) { center.Y *= 0.85f; } - int32_t charOffset = 0; + std::int32_t charOffset = 0; #if !defined(DEATH_TARGET_EMSCRIPTEN) bool isPlayable = true; @@ -231,7 +231,7 @@ namespace Jazz2::UI::Menu } #endif - for (int32_t i = 0; i < (int32_t)_items.size(); i++) { + for (std::int32_t i = 0; i < (std::int32_t)_items.size(); i++) { _items[i].Y = center.Y; #if !defined(DEATH_TARGET_EMSCRIPTEN) @@ -294,7 +294,7 @@ namespace Jazz2::UI::Menu void BeginSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -307,7 +307,7 @@ namespace Jazz2::UI::Menu } #endif - for (int32_t i = 0; i < (int32_t)_items.size(); i++) { + for (std::int32_t i = 0; i < (std::int32_t)_items.size(); i++) { float itemHeight = (!isPlayable && i == 0 ? 60.0f : 22.0f); if (std::abs(x - 0.5f) < 0.22f && std::abs(y - _items[i].Y) < itemHeight) { if (_selectedIndex == i) { diff --git a/Sources/Jazz2/UI/Menu/BeginSection.h b/Sources/Jazz2/UI/Menu/BeginSection.h index c5a7b521..6f7145b6 100644 --- a/Sources/Jazz2/UI/Menu/BeginSection.h +++ b/Sources/Jazz2/UI/Menu/BeginSection.h @@ -39,13 +39,13 @@ namespace Jazz2::UI::Menu String Name; float Y; - ItemData(Item type, const StringView& name) : Type(type), Name(name), Y(0.0f) { } + ItemData(Item type, StringView name) : Type(type), Name(name), Y(0.0f) { } }; static constexpr float DisabledItem = -1024.0f; - SmallVector _items; - int32_t _selectedIndex; + SmallVector _items; + std::int32_t _selectedIndex; float _animation; float _transitionTime; bool _shouldStart; diff --git a/Sources/Jazz2/UI/Menu/ControlsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/ControlsOptionsSection.cpp index 30bfd949..cb3f83da 100644 --- a/Sources/Jazz2/UI/Menu/ControlsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/ControlsOptionsSection.cpp @@ -57,7 +57,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Controls"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } diff --git a/Sources/Jazz2/UI/Menu/ControlsOptionsSection.h b/Sources/Jazz2/UI/Menu/ControlsOptionsSection.h index fc9b9802..0f7416c2 100644 --- a/Sources/Jazz2/UI/Menu/ControlsOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/ControlsOptionsSection.h @@ -34,7 +34,7 @@ namespace Jazz2::UI::Menu void OnHandleInput() override; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.cpp b/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.cpp index 720b3c34..d3323af1 100644 --- a/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.cpp @@ -156,8 +156,8 @@ namespace Jazz2::UI::Menu _root->DrawElement(selectedDifficultyImage, _selectedDifficulty, center.X * 0.36f, center.Y * 1.4f, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, _imageTransition), 0.88f, 0.88f); - int32_t charOffset = 0; - for (int32_t i = 0; i < (int32_t)Item::Count; i++) { + std::int32_t charOffset = 0; + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (_selectedIndex == i) { float size = 0.5f + IMenuContainer::EaseOutElastic(_animation) * 0.6f; @@ -190,7 +190,7 @@ namespace Jazz2::UI::Menu spacing = 300.0f / _availableCharacters; } - for (int32_t j = 0; j < _availableCharacters; j++) { + for (std::int32_t j = 0; j < _availableCharacters; j++) { float x = center.X - offset + j * spacing; if (_selectedPlayerType == j) { _root->DrawElement(MenuGlow, 0, x, center.Y + 28.0f, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, 0.2f), (Utf8::GetLength(playerTypes[j]) + 3) * 0.4f, 2.2f, true, true); @@ -258,7 +258,7 @@ namespace Jazz2::UI::Menu void CreateServerOptionsSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (!_shouldStart && event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x * (float)viewSize.X; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -270,11 +270,11 @@ namespace Jazz2::UI::Menu return; } - for (int32_t i = 0; i < (int32_t)Item::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (std::abs(x - halfWidth) < 150.0f && std::abs(y - _items[i].TouchY) < 30.0f) { switch (i) { case 0: { - int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); + std::int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); if (_selectedPlayerType != selectedSubitem) { StartImageTransition(); _selectedPlayerType = selectedSubitem; @@ -283,7 +283,7 @@ namespace Jazz2::UI::Menu break; } /*case 1: { - int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); + std::int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); if (_selectedDifficulty != selectedSubitem) { StartImageTransition(); _selectedDifficulty = selectedSubitem; @@ -317,14 +317,14 @@ namespace Jazz2::UI::Menu void CreateServerOptionsSection::ExecuteSelected() { switch (_selectedIndex) { - case (int32_t)Item::GameMode: { + case (std::int32_t)Item::GameMode: { if (_episodeName == "unknown"_s) { _root->PlaySfx("MenuSelect"_s, 0.6f); _root->SwitchToSection(); } break; } - case (int32_t)Item::Start: { + case (std::int32_t)Item::Start: { _root->PlaySfx("MenuSelect"_s, 0.6f); _shouldStart = true; diff --git a/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.h b/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.h index d5298ae6..76d68be8 100644 --- a/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/CreateServerOptionsSection.h @@ -39,14 +39,14 @@ namespace Jazz2::UI::Menu String _previousEpisodeName; Multiplayer::MultiplayerGameMode _gameMode; - ItemData _items[(int32_t)Item::Count]; - int32_t _selectedIndex; - - int32_t _availableCharacters; - int32_t _selectedPlayerType; - int32_t _selectedDifficulty; - int32_t _lastPlayerType; - int32_t _lastDifficulty; + ItemData _items[(std::int32_t)Item::Count]; + std::int32_t _selectedIndex; + + std::int32_t _availableCharacters; + std::int32_t _selectedPlayerType; + std::int32_t _selectedDifficulty; + std::int32_t _lastPlayerType; + std::int32_t _lastDifficulty; float _imageTransition; float _animation; diff --git a/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.cpp b/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.cpp index 0f9d9444..0c30ecef 100644 --- a/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.cpp @@ -79,7 +79,7 @@ namespace Jazz2::UI::Menu if (_selectedIndex > 0) { _selectedIndex--; } else { - _selectedIndex = (int32_t)(_items.size() - 1); + _selectedIndex = (std::int32_t)(_items.size() - 1); } EnsureVisibleSelected(); _pressedCount = std::min(_pressedCount + 6, 10); @@ -121,7 +121,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Play Custom Levels"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } @@ -132,7 +132,7 @@ namespace Jazz2::UI::Menu float centerX = contentBounds.X + contentBounds.W * 0.5f; float topLine = contentBounds.Y + TopLine; float bottomLine = contentBounds.Y + contentBounds.H - BottomLine; - int32_t charOffset = 0; + std::int32_t charOffset = 0; if (_items.empty()) { _root->DrawStringShadow(_("No custom level found!"), charOffset, centerX, contentBounds.Y + contentBounds.H * 0.33f, IMenuContainer::FontLayer, @@ -150,7 +150,7 @@ namespace Jazz2::UI::Menu float column2 = contentBounds.X + (contentBounds.W >= 460 ? (contentBounds.W * 0.52f) : (contentBounds.W * 0.44f)); std::size_t itemsCount = _items.size(); - for (int32_t i = 0; i < itemsCount; i++) { + for (std::int32_t i = 0; i < itemsCount; i++) { _items[i].Y = center.Y; if (center.Y > topLine - ItemHeight && center.Y < bottomLine + ItemHeight) { @@ -188,7 +188,7 @@ namespace Jazz2::UI::Menu { switch (event.type) { case TouchEventType::Down: { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float y = event.pointers[pointerIndex].y * (float)viewSize.Y; if (y < 80.0f) { @@ -205,7 +205,7 @@ namespace Jazz2::UI::Menu } case TouchEventType::Move: { if (_touchStart != Vector2f::Zero) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { Vector2f touchMove = Vector2f(event.pointers[pointerIndex].x * (float)viewSize.X, event.pointers[pointerIndex].y * (float)viewSize.Y); _y += touchMove.Y - _touchLast.Y; @@ -223,7 +223,7 @@ namespace Jazz2::UI::Menu float halfW = viewSize.X * 0.5f; std::size_t itemsCount = _items.size(); - for (int32_t i = 0; i < itemsCount; i++) { + for (std::int32_t i = 0; i < itemsCount; i++) { if (std::abs(_touchLast.X - halfW) < 150.0f && std::abs(_touchLast.Y - _items[i].Y) < 22.0f) { if (_selectedIndex == i) { ExecuteSelected(); @@ -305,11 +305,11 @@ namespace Jazz2::UI::Menu auto s = fs::Open(levelFile, FileAccess::Read); RETURN_ASSERT_MSG(s->IsValid(), "Cannot open file for reading"); - uint64_t signature = s->ReadValue(); - uint8_t fileType = s->ReadValue(); + std::uint64_t signature = s->ReadValue(); + std::uint8_t fileType = s->ReadValue(); RETURN_ASSERT_MSG(signature == 0x2095A59FF0BFBBEF && fileType == ContentResolver::LevelFile, "File has invalid signature"); - uint16_t flags = s->ReadValue(); + std::uint16_t flags = s->ReadValue(); #if !defined(DEATH_DEBUG) // Don't show hidden levels in Release build if unlock cheat is not active, but show all levels in Debug build @@ -319,12 +319,12 @@ namespace Jazz2::UI::Menu #endif // Read compressed data - int32_t compressedSize = s->ReadValue(); + std::int32_t compressedSize = s->ReadValue(); DeflateStream uc(*s, compressedSize); // Read metadata - uint8_t nameSize = uc.ReadValue(); + std::uint8_t nameSize = uc.ReadValue(); String name(NoInit, nameSize); uc.Read(name.data(), nameSize); diff --git a/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.h b/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.h index 5b7bf91d..f6ab7a43 100644 --- a/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.h +++ b/Sources/Jazz2/UI/Menu/CustomLevelSelectSection.h @@ -35,14 +35,14 @@ namespace Jazz2::UI::Menu SmallVector _items; bool _multiplayer; - int32_t _selectedIndex; + std::int32_t _selectedIndex; float _animation; float _y; float _height; Vector2f _touchStart; Vector2f _touchLast; float _touchTime; - int32_t _pressedCount; + std::int32_t _pressedCount; float _noiseCooldown; #if defined(WITH_THREADS) && !defined(DEATH_TARGET_EMSCRIPTEN) Thread _indexingThread; diff --git a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp index f9c34622..cb1decde 100644 --- a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.cpp @@ -76,7 +76,7 @@ namespace Jazz2::UI::Menu if (_selectedIndex > 0) { _selectedIndex--; } else { - _selectedIndex = (int32_t)(_items.size() - 1); + _selectedIndex = (std::int32_t)(_items.size() - 1); } EnsureVisibleSelected(); } else if (_root->ActionHit(PlayerActions::Down)) { @@ -117,7 +117,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow( #if defined(WITH_MULTIPLAYER) _multiplayer ? _("Play Story in Cooperation") : _("Play Story"), @@ -128,7 +128,7 @@ namespace Jazz2::UI::Menu Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } - void EpisodeSelectSection::OnDrawEmptyText(Canvas* canvas, int32_t& charOffset) + void EpisodeSelectSection::OnDrawEmptyText(Canvas* canvas, std::int32_t& charOffset) { Vector2i viewSize = canvas->ViewSize; @@ -136,7 +136,7 @@ namespace Jazz2::UI::Menu Alignment::Center, Colorf(0.62f, 0.44f, 0.34f, 0.5f), 0.9f, 0.4f, 0.6f, 0.6f, 0.8f, 0.88f); } - void EpisodeSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void EpisodeSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; @@ -184,9 +184,9 @@ namespace Jazz2::UI::Menu } } } else { - int32_t prevEpisodeIndex = -1; + std::int32_t prevEpisodeIndex = -1; if (!item.Item.Description.PreviousEpisode.empty()) { - for (int32_t j = 0; j < _items.size(); j++) { + for (std::int32_t j = 0; j < _items.size(); j++) { if (item.Item.Description.PreviousEpisode == _items[j].Item.Description.Name) { prevEpisodeIndex = j; break; diff --git a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h index 199468d6..b69a66cf 100644 --- a/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h +++ b/Sources/Jazz2/UI/Menu/EpisodeSelectSection.h @@ -33,16 +33,16 @@ namespace Jazz2::UI::Menu void OnTouchEvent(const TouchEvent& event, const Vector2i& viewSize) override; private: - bool _multiplayer; float _expandedAnimation; - bool _expanded; float _transitionTime; + bool _multiplayer; + bool _expanded; bool _shouldStart; - void OnTouchUp(int32_t newIndex, const Vector2i& viewSize, const Vector2i& touchPos) override; + void OnTouchUp(std::int32_t newIndex, const Vector2i& viewSize, const Vector2i& touchPos) override; void OnExecuteSelected() override; - void OnDrawEmptyText(Canvas* canvas, int32_t& charOffset) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawEmptyText(Canvas* canvas, std::int32_t& charOffset) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnAfterTransition(); void AddEpisode(const StringView& episodeFile); diff --git a/Sources/Jazz2/UI/Menu/FirstRunSection.cpp b/Sources/Jazz2/UI/Menu/FirstRunSection.cpp index 0cca26d6..af5bf5a8 100644 --- a/Sources/Jazz2/UI/Menu/FirstRunSection.cpp +++ b/Sources/Jazz2/UI/Menu/FirstRunSection.cpp @@ -49,7 +49,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; // TRANSLATORS: Header in First Run section _root->DrawStringShadow(_("Welcome to \f[c:#9e7056]Jazz Jackrabbit 2\f[/c] reimplementation!"), charOffset, centerX, topLine - 66.0f - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Font::DefaultColor, 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); @@ -65,7 +65,7 @@ namespace Jazz2::UI::Menu item.Height = 68; } - void FirstRunSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void FirstRunSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/FirstRunSection.h b/Sources/Jazz2/UI/Menu/FirstRunSection.h index 57e4ef58..73186666 100644 --- a/Sources/Jazz2/UI/Menu/FirstRunSection.h +++ b/Sources/Jazz2/UI/Menu/FirstRunSection.h @@ -30,7 +30,7 @@ namespace Jazz2::UI::Menu bool _committed; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnBackPressed() override; void OnSelectionChanged(ListViewItem& item) override; void OnExecuteSelected() override; diff --git a/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.cpp b/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.cpp index da2c8b99..d36e5bd6 100644 --- a/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.cpp +++ b/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.cpp @@ -66,7 +66,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Enhancements"), charOffset, centerX, contentBounds.Y + TopLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); @@ -89,7 +89,7 @@ namespace Jazz2::UI::Menu item.Height = 52; } - void GameplayEnhancementsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void GameplayEnhancementsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.h b/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.h index 018f2ade..c5758ea8 100644 --- a/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.h +++ b/Sources/Jazz2/UI/Menu/GameplayEnhancementsSection.h @@ -36,7 +36,7 @@ namespace Jazz2::UI::Menu void OnHandleInput() override; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp b/Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp index 5932955e..fd24b796 100644 --- a/Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp @@ -89,7 +89,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Gameplay"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } @@ -99,7 +99,7 @@ namespace Jazz2::UI::Menu item.Height = (item.Item.HasBooleanValue ? 52 : ItemHeight); } - void GameplayOptionsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void GameplayOptionsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/GameplayOptionsSection.h b/Sources/Jazz2/UI/Menu/GameplayOptionsSection.h index 381f82fd..fe07e9f0 100644 --- a/Sources/Jazz2/UI/Menu/GameplayOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/GameplayOptionsSection.h @@ -44,7 +44,7 @@ namespace Jazz2::UI::Menu void OnHandleInput() override; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp index 4fee1092..32f1aee7 100644 --- a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.cpp @@ -70,7 +70,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Graphics"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } @@ -80,7 +80,7 @@ namespace Jazz2::UI::Menu item.Height = (item.Item.HasBooleanValue ? 52 : ItemHeight); } - void GraphicsOptionsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void GraphicsOptionsSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.h b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.h index 7cce8d75..2e98052d 100644 --- a/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/GraphicsOptionsSection.h @@ -36,7 +36,7 @@ namespace Jazz2::UI::Menu void OnHandleInput() override; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/IMenuContainer.h b/Sources/Jazz2/UI/Menu/IMenuContainer.h index 64454c80..c26699d1 100644 --- a/Sources/Jazz2/UI/Menu/IMenuContainer.h +++ b/Sources/Jazz2/UI/Menu/IMenuContainer.h @@ -27,11 +27,11 @@ namespace Jazz2::UI::Menu class IMenuContainer { public: - static constexpr uint16_t MainLayer = 600; - static constexpr uint16_t ShadowLayer = 580; - static constexpr uint16_t BackgroundLayer = 550; - static constexpr uint16_t FontLayer = 700; - static constexpr uint16_t FontShadowLayer = 620; + static constexpr std::uint16_t MainLayer = 600; + static constexpr std::uint16_t ShadowLayer = 580; + static constexpr std::uint16_t BackgroundLayer = 550; + static constexpr std::uint16_t FontLayer = 700; + static constexpr std::uint16_t FontShadowLayer = 620; virtual ~IMenuContainer() { } @@ -57,14 +57,14 @@ namespace Jazz2::UI::Menu virtual Vector2i GetViewSize() const = 0; virtual Recti GetContentBounds() const = 0; - virtual void DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, + virtual void DrawElement(AnimState state, int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) = 0; - virtual void DrawElement(AnimState state, float x, float y, uint16_t z, Alignment align, + virtual void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) = 0; - virtual void DrawSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) = 0; - virtual void DrawTexture(const Texture& texture, float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) = 0; + virtual void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) = 0; + virtual void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) = 0; virtual Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) = 0; - virtual void DrawStringShadow(const StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, + virtual void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f) = 0; virtual void PlaySfx(const StringView identifier, float gain = 1.0f) = 0; diff --git a/Sources/Jazz2/UI/Menu/ImportSection.cpp b/Sources/Jazz2/UI/Menu/ImportSection.cpp index ff61454f..65440f82 100644 --- a/Sources/Jazz2/UI/Menu/ImportSection.cpp +++ b/Sources/Jazz2/UI/Menu/ImportSection.cpp @@ -61,7 +61,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 1, center.X, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); center.Y = topLine + (bottomLine - topLine) * 0.4f; - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Import Episodes"), charOffset, center.X, contentBounds.Y + TopLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); @@ -96,7 +96,7 @@ namespace Jazz2::UI::Menu void ImportSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float y = event.pointers[pointerIndex].y * (float)viewSize.Y; if (y < 80.0f) { @@ -110,15 +110,15 @@ namespace Jazz2::UI::Menu } } - void ImportSection::FileDataCallback(void* context, std::unique_ptr data, size_t length, const StringView& name) + void ImportSection::FileDataCallback(void* context, std::unique_ptr data, std::size_t length, StringView name) { auto* _this = static_cast(context); _this->_fileCount--; - int32_t offset = 180; // Skip header - if (data != nullptr && length >= 262 && fs::GetExtension(name) == "j2l"_s && *(uint32_t*)&data[offset] == 0x4C56454C) { + std::int32_t offset = 180; // Skip header + if (data != nullptr && length >= 262 && fs::GetExtension(name) == "j2l"_s && *(std::uint32_t*)&data[offset] == 0x4C56454C) { offset += 4 + 4; - int32_t nameLength = 0; + std::int32_t nameLength = 0; while (data[offset + nameLength] != '\0' && nameLength < 32) { nameLength++; } @@ -131,7 +131,7 @@ namespace Jazz2::UI::Menu } } - void ImportSection::FileCountCallback(void* context, int32_t fileCount) + void ImportSection::FileCountCallback(void* context, std::int32_t fileCount) { auto* _this = static_cast(context); _this->_fileCount = fileCount; @@ -169,7 +169,7 @@ namespace Jazz2::UI::Menu } } - bool ImportSection::HasAllLevels(ArrayView levelNames) + bool ImportSection::HasAllLevels(ArrayView levelNames) { bool hasAll = true; for (std::size_t i = 0; i < levelNames.size(); i++) { diff --git a/Sources/Jazz2/UI/Menu/ImportSection.h b/Sources/Jazz2/UI/Menu/ImportSection.h index fd3c6501..de5e2389 100644 --- a/Sources/Jazz2/UI/Menu/ImportSection.h +++ b/Sources/Jazz2/UI/Menu/ImportSection.h @@ -34,15 +34,15 @@ namespace Jazz2::UI::Menu float _animation; State _state; - int32_t _fileCount; + std::int32_t _fileCount; float _timeout; HashMap _foundLevels; - static void FileDataCallback(void* context, std::unique_ptr data, size_t length, const StringView& name); - static void FileCountCallback(void* context, int32_t fileCount); + static void FileDataCallback(void* context, std::unique_ptr data, std::size_t length, StringView name); + static void FileCountCallback(void* context, std::int32_t fileCount); void CheckFoundLevels(); - bool HasAllLevels(ArrayView levelNames); + bool HasAllLevels(ArrayView levelNames); }; } diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.cpp b/Sources/Jazz2/UI/Menu/InGameMenu.cpp index 5683e94e..8fa98fcd 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.cpp +++ b/Sources/Jazz2/UI/Menu/InGameMenu.cpp @@ -88,7 +88,7 @@ namespace Jazz2::UI::Menu } } - void InGameMenu::OnInitializeViewport(int32_t width, int32_t height) + void InGameMenu::OnInitializeViewport(std::int32_t width, std::int32_t height) { UpdateContentBounds(Vector2i(width, height)); @@ -109,8 +109,8 @@ namespace Jazz2::UI::Menu Vector2i center = ViewSize / 2; - int32_t charOffset = 0; - int32_t charOffsetShadow = 0; + std::int32_t charOffset = 0; + std::int32_t charOffsetShadow = 0; float titleY = _owner->_contentBounds.Y - (ViewSize.Y >= 300 ? 30.0f : 12.0f); float logoBaseScale = (ViewSize.Y >= 300 ? 1.0f : 0.85f); @@ -306,7 +306,7 @@ namespace Jazz2::UI::Menu } } - void InGameMenu::DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, bool unaligned) + void InGameMenu::DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -314,7 +314,7 @@ namespace Jazz2::UI::Menu } if (frame < 0) { - frame = res->FrameOffset + ((int32_t)(_canvasBackground->AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); + frame = res->FrameOffset + ((std::int32_t)(_canvasBackground->AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); } Canvas* currentCanvas = GetActiveCanvas(); @@ -327,8 +327,8 @@ namespace Jazz2::UI::Menu } Vector2i texSize = base->TextureDiffuse->size(); - int32_t col = frame % base->FrameConfiguration.X; - int32_t row = frame / base->FrameConfiguration.X; + std::int32_t col = frame % base->FrameConfiguration.X; + std::int32_t row = frame / base->FrameConfiguration.X; Vector4f texCoords = Vector4f( float(base->FrameDimensions.X) / float(texSize.X), float(base->FrameDimensions.X * col) / float(texSize.X), @@ -339,7 +339,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending); } - void InGameMenu::DrawElement(AnimState state, float x, float y, uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) + void InGameMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -357,7 +357,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, false); } - void InGameMenu::DrawSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) + void InGameMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -367,7 +367,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawSolid(adjustedPos, z, size, color, additiveBlending); } - void InGameMenu::DrawTexture(const Texture& texture, float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) + void InGameMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -384,11 +384,11 @@ namespace Jazz2::UI::Menu return _smallFont->MeasureString(text, scale, charSpacing, lineSpacing); } - void InGameMenu::DrawStringShadow(const StringView text, int& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scale, + void InGameMenu::DrawStringShadow(const StringView text, int& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale, float angleOffset, float varianceX, float varianceY, float speed, float charSpacing, float lineSpacing) { Canvas* currentCanvas = GetActiveCanvas(); - int32_t charOffsetShadow = charOffset; + std::int32_t charOffsetShadow = charOffset; _smallFont->DrawString(currentCanvas, text, charOffsetShadow, x, y + 2.8f * scale, FontShadowLayer, align, Colorf(0.0f, 0.0f, 0.0f, 0.29f), scale, angleOffset, varianceX, varianceY, speed, charSpacing, lineSpacing); _smallFont->DrawString(currentCanvas, text, charOffset, x, y, z, @@ -400,7 +400,7 @@ namespace Jazz2::UI::Menu #if defined(WITH_AUDIO) auto it = _metadata->Sounds.find(String::nullTerminatedView(identifier)); if (it != _metadata->Sounds.end()) { - int32_t idx = (it->second.Buffers.size() > 1 ? Random().Next(0, (int32_t)it->second.Buffers.size()) : 0); + std::int32_t idx = (it->second.Buffers.size() > 1 ? Random().Next(0, (std::int32_t)it->second.Buffers.size()) : 0); auto& player = _playingSounds.emplace_back(std::make_shared(&it->second.Buffers[idx]->Buffer)); player->setPosition(Vector3f(0.0f, 0.0f, 100.0f)); player->setGain(gain * PreferencesCache::MasterVolume * PreferencesCache::SfxVolume); @@ -428,12 +428,12 @@ namespace Jazz2::UI::Menu bool InGameMenu::ActionPressed(PlayerActions action) { - return ((_pressedActions & (1 << (int32_t)action)) == (1 << (int32_t)action)); + return ((_pressedActions & (1 << (std::int32_t)action)) == (1 << (std::int32_t)action)); } bool InGameMenu::ActionHit(PlayerActions action) { - return ((_pressedActions & ((1 << (int32_t)action) | (1 << (16 + (int32_t)action)))) == (1 << (int32_t)action)); + return ((_pressedActions & ((1 << (std::int32_t)action) | (1 << (16 + (std::int32_t)action)))) == (1 << (std::int32_t)action)); } void InGameMenu::UpdateContentBounds(Vector2i viewSize) diff --git a/Sources/Jazz2/UI/Menu/InGameMenu.h b/Sources/Jazz2/UI/Menu/InGameMenu.h index 2cafc59d..3ab3917a 100644 --- a/Sources/Jazz2/UI/Menu/InGameMenu.h +++ b/Sources/Jazz2/UI/Menu/InGameMenu.h @@ -19,14 +19,14 @@ namespace Jazz2::UI::Menu class InGameMenu : public IMenuContainer { public: - static constexpr int32_t DefaultWidth = 720; - static constexpr int32_t DefaultHeight = 405; + static constexpr std::int32_t DefaultWidth = 720; + static constexpr std::int32_t DefaultHeight = 405; InGameMenu(LevelHandler* root); ~InGameMenu(); void OnTouchEvent(const nCine::TouchEvent& event); - void OnInitializeViewport(int32_t width, int32_t height); + void OnInitializeViewport(std::int32_t width, std::int32_t height); MenuSection* SwitchToSectionDirect(std::unique_ptr section) override; void LeaveSection() override; @@ -50,14 +50,14 @@ namespace Jazz2::UI::Menu return _contentBounds; } - void DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) override; - void DrawElement(AnimState state, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) override; - void DrawSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; - void DrawTexture(const Texture& texture, float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; + void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; + void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; - void DrawStringShadow(const StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; void PlaySfx(const StringView identifier, float gain = 1.0f) override; @@ -121,7 +121,7 @@ namespace Jazz2::UI::Menu #endif SmallVector, 8> _sections; - uint32_t _pressedActions; + std::uint32_t _pressedActions; float _touchButtonsTimer; void UpdateContentBounds(Vector2i viewSize); diff --git a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp index 712299d8..2a47dba2 100644 --- a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp +++ b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.cpp @@ -32,8 +32,8 @@ namespace Jazz2::UI::Menu bool shouldExit = false; const JoyMappedState* joyStates[ControlScheme::MaxConnectedGamepads]; - int32_t jc = 0; - for (int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { + std::int32_t jc = 0; + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { if (input.isJoyMapped(i)) { joyStates[jc] = &input.joyMappedState(i); if (joyStates[jc]->isButtonPressed(ButtonName::Start) && joyStates[jc]->isButtonPressed(ButtonName::Back)) { @@ -76,8 +76,8 @@ namespace Jazz2::UI::Menu auto& input = theApplication().GetInputManager(); const JoyMappedState* joyStates[ControlScheme::MaxConnectedGamepads]; - int32_t jc = 0; - for (int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { + std::int32_t jc = 0; + for (std::int32_t i = 0; i < IInputManager::MaxNumJoysticks && jc < static_cast(arraySize(joyStates)); i++) { if (input.isJoyPresent(i)) { jc++; } @@ -101,14 +101,14 @@ namespace Jazz2::UI::Menu const JoystickState& rawState = input.joystickState(_selectedIndex); const JoyMappedState& mappedState = input.joyMappedState(_selectedIndex); const char* joyName = input.joyName(_selectedIndex); - int32_t numAxes = input.joyNumAxes(_selectedIndex); - int32_t numButtons = input.joyNumButtons(_selectedIndex); - int32_t numHats = input.joyNumHats(_selectedIndex); + std::int32_t numAxes = input.joyNumAxes(_selectedIndex); + std::int32_t numButtons = input.joyNumButtons(_selectedIndex); + std::int32_t numHats = input.joyNumHats(_selectedIndex); char buffer[128]; formatString(buffer, sizeof(buffer), "%s (%i axes, %i buttons, %i hats)", joyName, numAxes, numButtons, numHats); - size_t joyNameStringLength = Utf8::GetLength(buffer); + std::size_t joyNameStringLength = Utf8::GetLength(buffer); float xMultiplier = joyNameStringLength * 0.5f; float easing = IMenuContainer::EaseOutElastic(_animation); float x = center.X * 0.4f + xMultiplier - easing * xMultiplier; @@ -146,7 +146,7 @@ namespace Jazz2::UI::Menu PrintAxisValue("LT", mappedState.axisValue(AxisName::LeftTrigger), center.X * 0.4f, topLine + 90.0f); PrintAxisValue("RT", mappedState.axisValue(AxisName::RightTrigger), center.X * 0.4f + 110.0f, topLine + 90.0f); - int32_t buttonsLength = 0; + std::int32_t buttonsLength = 0; buffer[0] = '\0'; if (mappedState.isButtonPressed(ButtonName::A)) buttonsLength += formatString(buffer + buttonsLength, sizeof(buffer) - buttonsLength, "A "); if (mappedState.isButtonPressed(ButtonName::B)) buttonsLength += formatString(buffer + buttonsLength, sizeof(buffer) - buttonsLength, "B "); @@ -177,7 +177,7 @@ namespace Jazz2::UI::Menu Alignment::Left, Colorf(0.62f, 0.44f, 0.34f, 0.5f), 0.8f, 0.0f, 4.0f, 4.0f, 0.4f, 0.88f); float sx = 0, sy = 0; - for (int32_t i = 0; i < numAxes; i++) { + for (std::int32_t i = 0; i < numAxes; i++) { formatString(buffer, sizeof(buffer), "a%i", i); PrintAxisValue(buffer, rawState.axisValue(i), center.X * 0.4f + sx, topLine + 140.0f + sy); sx += 110.0f; @@ -192,7 +192,7 @@ namespace Jazz2::UI::Menu sy += 15.0f; } - for (int32_t i = 0; i < numButtons; i++) { + for (std::int32_t i = 0; i < numButtons; i++) { formatString(buffer, sizeof(buffer), "b%i: %i", i, rawState.isButtonPressed(i) ? 1 : 0); _root->DrawStringShadow(buffer, charOffset, center.X * 0.4f + sx, topLine + 140.0f + sy, IMenuContainer::FontLayer, Alignment::Left, Font::DefaultColor, 0.8f, 0.0f, 4.0f, 4.0f, 0.4f, 0.88f); @@ -208,7 +208,7 @@ namespace Jazz2::UI::Menu sy += 15.0f; } - for (int32_t i = 0; i < numHats; i++) { + for (std::int32_t i = 0; i < numHats; i++) { formatString(buffer, sizeof(buffer), "h%i: %i", i, rawState.hatState(i)); _root->DrawStringShadow(buffer, charOffset, center.X * 0.4f + sx, topLine + 140.0f + sy, IMenuContainer::FontLayer, Alignment::Left, Font::DefaultColor, 0.8f, 0.0f, 4.0f, 4.0f, 0.4f, 0.88f); @@ -258,7 +258,7 @@ namespace Jazz2::UI::Menu void InputDiagnosticsSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -292,7 +292,7 @@ namespace Jazz2::UI::Menu char text[64]; formatString(text, sizeof(text), "%s: %0.2f", name, value); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(text, charOffset, x, y, IMenuContainer::FontLayer, Alignment::Left, Font::DefaultColor, 0.8f, 0.0f, 4.0f, 4.0f, 0.4f, 0.88f); } diff --git a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.h b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.h index e2908f0e..74cde165 100644 --- a/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.h +++ b/Sources/Jazz2/UI/Menu/InputDiagnosticsSection.h @@ -22,8 +22,8 @@ namespace Jazz2::UI::Menu } private: - int32_t _itemCount; - int32_t _selectedIndex; + std::int32_t _itemCount; + std::int32_t _selectedIndex; float _animation; void OnHandleInput(); diff --git a/Sources/Jazz2/UI/Menu/LanguageSelectSection.cpp b/Sources/Jazz2/UI/Menu/LanguageSelectSection.cpp index f593fb68..58264cc6 100644 --- a/Sources/Jazz2/UI/Menu/LanguageSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/LanguageSelectSection.cpp @@ -1,5 +1,4 @@ #include "LanguageSelectSection.h" -#include "MainMenu.h" #include "MenuResources.h" #include "../../PreferencesCache.h" #include "../../../nCine/I18n.h" @@ -39,19 +38,19 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Language"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } - void LanguageSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void LanguageSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; if (isSelected) { float size = 0.5f + IMenuContainer::EaseOutElastic(_animation) * 0.6f; - size_t realNameLength; + std::size_t realNameLength; StringView realNameEnd = item.Item.DisplayName.find('\f'); if (realNameEnd != nullptr) { realNameLength = realNameEnd.data() - item.Item.DisplayName.data() + 4; diff --git a/Sources/Jazz2/UI/Menu/LanguageSelectSection.h b/Sources/Jazz2/UI/Menu/LanguageSelectSection.h index 2ee111e5..67fb0cad 100644 --- a/Sources/Jazz2/UI/Menu/LanguageSelectSection.h +++ b/Sources/Jazz2/UI/Menu/LanguageSelectSection.h @@ -18,7 +18,7 @@ namespace Jazz2::UI::Menu private: void OnExecuteSelected() override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void AddLanguage(const StringView languageFile); }; diff --git a/Sources/Jazz2/UI/Menu/MainMenu.cpp b/Sources/Jazz2/UI/Menu/MainMenu.cpp index 08d5b55c..9bb221dc 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.cpp +++ b/Sources/Jazz2/UI/Menu/MainMenu.cpp @@ -142,18 +142,18 @@ namespace Jazz2::UI::Menu } } - void MainMenu::OnInitializeViewport(int32_t width, int32_t height) + void MainMenu::OnInitializeViewport(std::int32_t width, std::int32_t height) { constexpr float defaultRatio = (float)DefaultWidth / DefaultHeight; float currentRatio = (float)width / height; - int32_t w, h; + std::int32_t w, h; if (currentRatio > defaultRatio) { w = std::min(DefaultWidth, width); - h = (int32_t)(w / currentRatio); + h = (std::int32_t)(w / currentRatio); } else if (currentRatio < defaultRatio) { h = std::min(DefaultHeight, height); - w = (int32_t)(h * currentRatio); + w = (std::int32_t)(h * currentRatio); } else { w = std::min(DefaultWidth, width); h = std::min(DefaultHeight, height); @@ -211,8 +211,8 @@ namespace Jazz2::UI::Menu } Vector2i center = ViewSize / 2; - int32_t charOffset = 0; - int32_t charOffsetShadow = 0; + std::int32_t charOffset = 0; + std::int32_t charOffsetShadow = 0; float titleY = _owner->_contentBounds.Y - (ViewSize.Y >= 300 ? 30.0f : 12.0f); float logoBaseScale = (ViewSize.Y >= 300 ? 1.0f : 0.85f); @@ -428,7 +428,7 @@ namespace Jazz2::UI::Menu } } - void MainMenu::DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, bool unaligned) + void MainMenu::DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX, float scaleY, bool additiveBlending, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -436,7 +436,7 @@ namespace Jazz2::UI::Menu } if (frame < 0) { - frame = res->FrameOffset + ((int32_t)(_canvasBackground->AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); + frame = res->FrameOffset + ((std::int32_t)(_canvasBackground->AnimTime * res->FrameCount / res->AnimDuration) % res->FrameCount); } Canvas* currentCanvas = GetActiveCanvas(); @@ -449,8 +449,8 @@ namespace Jazz2::UI::Menu } Vector2i texSize = base->TextureDiffuse->size(); - int32_t col = frame % base->FrameConfiguration.X; - int32_t row = frame / base->FrameConfiguration.X; + std::int32_t col = frame % base->FrameConfiguration.X; + std::int32_t row = frame / base->FrameConfiguration.X; Vector4f texCoords = Vector4f( float(base->FrameDimensions.X) / float(texSize.X), float(base->FrameDimensions.X * col) / float(texSize.X), @@ -461,7 +461,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, additiveBlending); } - void MainMenu::DrawElement(AnimState state, float x, float y, uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) + void MainMenu::DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned) { auto* res = _metadata->FindAnimation(state); if (res == nullptr) { @@ -479,7 +479,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawTexture(*base->TextureDiffuse.get(), adjustedPos, z, size, texCoords, color, false); } - void MainMenu::DrawSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) + void MainMenu::DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -489,7 +489,7 @@ namespace Jazz2::UI::Menu currentCanvas->DrawSolid(adjustedPos, z, size, color, additiveBlending); } - void MainMenu::DrawTexture(const Texture& texture, float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) + void MainMenu::DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned) { Canvas* currentCanvas = GetActiveCanvas(); Vector2f adjustedPos = Canvas::ApplyAlignment(align, Vector2f(x, y), size); @@ -506,7 +506,7 @@ namespace Jazz2::UI::Menu return _smallFont->MeasureString(text, scale, charSpacing, lineSpacing); } - void MainMenu::DrawStringShadow(const StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scale, + void MainMenu::DrawStringShadow(const StringView text, int32_t& charOffset, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scale, float angleOffset, float varianceX, float varianceY, float speed, float charSpacing, float lineSpacing) { if (_logoTransition < 1.0f) { @@ -518,7 +518,7 @@ namespace Jazz2::UI::Menu } Canvas* currentCanvas = GetActiveCanvas(); - int32_t charOffsetShadow = charOffset; + std::int32_t charOffsetShadow = charOffset; _smallFont->DrawString(currentCanvas, text, charOffsetShadow, x, y + 2.8f * scale, FontShadowLayer, align, Colorf(0.0f, 0.0f, 0.0f, 0.29f), scale, angleOffset, varianceX, varianceY, speed, charSpacing, lineSpacing); _smallFont->DrawString(currentCanvas, text, charOffset, x, y, z, @@ -530,7 +530,7 @@ namespace Jazz2::UI::Menu #if defined(WITH_AUDIO) auto it = _metadata->Sounds.find(String::nullTerminatedView(identifier)); if (it != _metadata->Sounds.end()) { - int32_t idx = (it->second.Buffers.size() > 1 ? Random().Next(0, (int32_t)it->second.Buffers.size()) : 0); + std::int32_t idx = (it->second.Buffers.size() > 1 ? Random().Next(0, (std::int32_t)it->second.Buffers.size()) : 0); auto& player = _playingSounds.emplace_back(std::make_shared(&it->second.Buffers[idx]->Buffer)); player->setPosition(Vector3f(0.0f, 0.0f, 100.0f)); player->setGain(gain * PreferencesCache::MasterVolume * PreferencesCache::SfxVolume); @@ -545,12 +545,12 @@ namespace Jazz2::UI::Menu bool MainMenu::ActionPressed(PlayerActions action) { - return ((_pressedActions & (1 << (int32_t)action)) == (1 << (int32_t)action)); + return ((_pressedActions & (1 << (std::int32_t)action)) == (1 << (std::int32_t)action)); } bool MainMenu::ActionHit(PlayerActions action) { - return ((_pressedActions & ((1 << (int32_t)action) | (1 << (16 + (int32_t)action)))) == (1 << (int32_t)action)); + return ((_pressedActions & ((1 << (std::int32_t)action) | (1 << (16 + (std::int32_t)action)))) == (1 << (std::int32_t)action)); } void MainMenu::PlayMenuMusic() @@ -623,8 +623,8 @@ namespace Jazz2::UI::Menu void MainMenu::UpdateDebris(float timeMult) { if (_preset == Preset::Xmas && PreferencesCache::EnableReforgedMainMenu) { - int32_t weatherIntensity = Random().Fast(0, (int32_t)(3 * timeMult) + 1); - for (int32_t i = 0; i < weatherIntensity; i++) { + std::int32_t weatherIntensity = Random().Fast(0, (std::int32_t)(3 * timeMult) + 1); + for (std::int32_t i = 0; i < weatherIntensity; i++) { Vector2i viewSize = _canvasOverlay->ViewSize; Vector2f debrisPos = Vector2f(Random().FastFloat(viewSize.X * -0.3f, viewSize.X * 1.3f), Random().NextFloat(viewSize.Y * -0.5f, viewSize.Y * 0.5f)); @@ -654,9 +654,9 @@ namespace Jazz2::UI::Menu debris.Time = 160.0f; - int32_t curAnimFrame = res->FrameOffset + Random().Next(0, res->FrameCount); - int32_t col = curAnimFrame % resBase->FrameConfiguration.X; - int32_t row = curAnimFrame / resBase->FrameConfiguration.X; + std::int32_t curAnimFrame = res->FrameOffset + Random().Next(0, res->FrameCount); + std::int32_t col = curAnimFrame % resBase->FrameConfiguration.X; + std::int32_t row = curAnimFrame / resBase->FrameConfiguration.X; debris.TexScaleX = (float(resBase->FrameDimensions.X) / float(texSize.X)); debris.TexBiasX = (float(resBase->FrameDimensions.X * col) / float(texSize.X)); debris.TexScaleY = (float(resBase->FrameDimensions.Y) / float(texSize.Y)); @@ -669,8 +669,8 @@ namespace Jazz2::UI::Menu } } - int32_t size = (int32_t)_debrisList.size(); - for (int32_t i = 0; i < size; i++) { + std::int32_t size = (std::int32_t)_debrisList.size(); + for (std::int32_t i = 0; i < size; i++) { Tiles::TileMap::DestructibleDebris& debris = _debrisList[i]; if (debris.Scale <= 0.0f || debris.Alpha <= 0.0f) { @@ -743,10 +743,10 @@ namespace Jazz2::UI::Menu time_t t = time(nullptr); #if defined(DEATH_TARGET_WINDOWS) struct tm local; localtime_s(&local, &t); - int32_t month = local.tm_mon; + std::int32_t month = local.tm_mon; #else struct tm* local = localtime(&t); - int32_t month = local->tm_mon; + std::int32_t month = local->tm_mon; #endif bool hasXmas = ((month == 11 || month == 0) && TryLoadBackgroundPreset(Preset::Xmas)); if (!hasXmas && @@ -758,36 +758,36 @@ namespace Jazz2::UI::Menu return; } - constexpr int32_t Width = 8; - constexpr int32_t Height = 8; + constexpr std::int32_t Width = 8; + constexpr std::int32_t Height = 8; - constexpr int32_t StartIndexDefault = 360; - constexpr int32_t StartIndexXmas = 420; - constexpr int32_t StartIndexDemo = 240; - constexpr int32_t AdditionalIndexDemo = 451; - constexpr int32_t SplitRowDemo = 6; + constexpr std::int32_t StartIndexDefault = 360; + constexpr std::int32_t StartIndexXmas = 420; + constexpr std::int32_t StartIndexDemo = 240; + constexpr std::int32_t AdditionalIndexDemo = 451; + constexpr std::int32_t SplitRowDemo = 6; std::unique_ptr layout = std::make_unique(Width * Height); - int32_t n = 0; + std::int32_t n = 0; if (_preset == Preset::SharewareDemo) { // Shareware Demo tileset is not contiguous for some reason - for (int32_t i = StartIndexDemo; i < StartIndexDemo + SplitRowDemo * 10; i += 10) { - for (int32_t j = 0; j < 8; j++) { + for (std::int32_t i = StartIndexDemo; i < StartIndexDemo + SplitRowDemo * 10; i += 10) { + for (std::int32_t j = 0; j < 8; j++) { LayerTile& tile = layout[n++]; tile.TileID = i + j; } } - for (int32_t i = AdditionalIndexDemo; i < AdditionalIndexDemo + (Height - SplitRowDemo) * 10; i += 10) { - for (int32_t j = 0; j < 8; j++) { + for (std::int32_t i = AdditionalIndexDemo; i < AdditionalIndexDemo + (Height - SplitRowDemo) * 10; i += 10) { + for (std::int32_t j = 0; j < 8; j++) { LayerTile& tile = layout[n++]; tile.TileID = i + j; } } } else { - int32_t startIndex = (_preset == Preset::Xmas ? StartIndexXmas : StartIndexDefault); - for (int32_t i = startIndex; i < startIndex + Height * 10; i += 10) { - for (int32_t j = 0; j < 8; j++) { + std::int32_t startIndex = (_preset == Preset::Xmas ? StartIndexXmas : StartIndexDefault); + for (std::int32_t i = startIndex; i < startIndex + Height * 10; i += 10) { + for (std::int32_t j = 0; j < 8; j++) { LayerTile& tile = layout[n++]; tile.TileID = i + j; } @@ -1009,8 +1009,8 @@ namespace Jazz2::UI::Menu if (notInitialized) { Vector2i layoutSize = _owner->_texturedBackgroundLayer.LayoutSize; - int32_t width = layoutSize.X * TileSet::DefaultTileSize; - int32_t height = layoutSize.Y * TileSet::DefaultTileSize; + std::int32_t width = layoutSize.X * TileSet::DefaultTileSize; + std::int32_t height = layoutSize.Y * TileSet::DefaultTileSize; _camera = std::make_unique(); _camera->setOrthoProjection(0, static_cast(width), 0, static_cast(height)); @@ -1024,9 +1024,9 @@ namespace Jazz2::UI::Menu _target->setWrap(SamplerWrapping::Repeat); // Prepare render commands - int32_t renderCommandCount = (width * height) / (TileSet::DefaultTileSize * TileSet::DefaultTileSize); + std::int32_t renderCommandCount = (width * height) / (TileSet::DefaultTileSize * TileSet::DefaultTileSize); _renderCommands.reserve(renderCommandCount); - for (int32_t i = 0; i < renderCommandCount; i++) { + for (std::int32_t i = 0; i < renderCommandCount; i++) { std::unique_ptr& command = _renderCommands.emplace_back(std::make_unique(RenderCommand::Type::TileMap)); command->material().setShaderProgramType(Material::ShaderProgramType::Sprite); command->material().reserveUniformsDataMemory(); @@ -1057,11 +1057,11 @@ namespace Jazz2::UI::Menu TileMapLayer& layer = _owner->_texturedBackgroundLayer; Vector2i layoutSize = layer.LayoutSize; - int32_t renderCommandIndex = 0; + std::int32_t renderCommandIndex = 0; bool isAnimated = false; - for (int32_t y = 0; y < layoutSize.Y; y++) { - for (int32_t x = 0; x < layoutSize.X; x++) { + for (std::int32_t y = 0; y < layoutSize.Y; y++) { + for (std::int32_t x = 0; x < layoutSize.X; x++) { LayerTile& tile = layer.Layout[y * layer.LayoutSize.X + x]; auto command = _renderCommands[renderCommandIndex++].get(); @@ -1086,7 +1086,7 @@ namespace Jazz2::UI::Menu if (!isAnimated && _alreadyRendered) { // If it's not animated, it can be rendered only once - for (int32_t i = Viewport::chain().size() - 1; i >= 0; i--) { + for (std::int32_t i = Viewport::chain().size() - 1; i >= 0; i--) { auto& item = Viewport::chain()[i]; if (item == _view.get()) { Viewport::chain().erase(&item); diff --git a/Sources/Jazz2/UI/Menu/MainMenu.h b/Sources/Jazz2/UI/Menu/MainMenu.h index e93eae15..63e9d8ff 100644 --- a/Sources/Jazz2/UI/Menu/MainMenu.h +++ b/Sources/Jazz2/UI/Menu/MainMenu.h @@ -44,7 +44,7 @@ namespace Jazz2::UI::Menu void Reset(); void OnBeginFrame() override; - void OnInitializeViewport(int32_t width, int32_t height) override; + void OnInitializeViewport(std::int32_t width, std::int32_t height) override; void OnKeyPressed(const KeyboardEvent& event) override; void OnKeyReleased(const KeyboardEvent& event) override; @@ -72,14 +72,14 @@ namespace Jazz2::UI::Menu return _contentBounds; } - void DrawElement(AnimState state, int32_t frame, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawElement(AnimState state, std::int32_t frame, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, float scaleX = 1.0f, float scaleY = 1.0f, bool additiveBlending = false, bool unaligned = false) override; - void DrawElement(AnimState state, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawElement(AnimState state, float x, float y, std::uint16_t z, Alignment align, const Colorf& color, const Vector2f& size, const Vector4f& texCoords, bool unaligned = false) override; - void DrawSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; - void DrawTexture(const Texture& texture, float x, float y, uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; + void DrawSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool additiveBlending = false) override; + void DrawTexture(const Texture& texture, float x, float y, std::uint16_t z, Alignment align, const Vector2f& size, const Colorf& color, bool unaligned = false) override; Vector2f MeasureString(const StringView text, float scale = 1.0f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; - void DrawStringShadow(const StringView text, int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, + void DrawStringShadow(const StringView text, std::int32_t& charOffset, float x, float y, uint16_t z, Alignment align, const Colorf& color, float scale = 1.0f, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f, float charSpacing = 1.0f, float lineSpacing = 1.0f) override; void PlaySfx(const StringView identifier, float gain = 1.0f) override; @@ -186,7 +186,7 @@ namespace Jazz2::UI::Menu SmallVector, 8> _sections; BitArray _pressedKeys; - uint32_t _pressedActions; + std::uint32_t _pressedActions; float _touchButtonsTimer; void PlayMenuMusic(); diff --git a/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp b/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp index 46a8d1bd..e74bea7a 100644 --- a/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.cpp @@ -40,12 +40,12 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Select Game Mode"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } - void MultiplayerGameModeSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void MultiplayerGameModeSelectSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.h b/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.h index 77692f8f..5ad4aa60 100644 --- a/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.h +++ b/Sources/Jazz2/UI/Menu/MultiplayerGameModeSelectSection.h @@ -21,7 +21,7 @@ namespace Jazz2::UI::Menu private: void OnExecuteSelected() override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; }; } diff --git a/Sources/Jazz2/UI/Menu/OptionsSection.cpp b/Sources/Jazz2/UI/Menu/OptionsSection.cpp index 00091b4f..57e58ecf 100644 --- a/Sources/Jazz2/UI/Menu/OptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/OptionsSection.cpp @@ -37,7 +37,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Options"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } diff --git a/Sources/Jazz2/UI/Menu/OptionsSection.h b/Sources/Jazz2/UI/Menu/OptionsSection.h index 84fec88a..9f19d1a7 100644 --- a/Sources/Jazz2/UI/Menu/OptionsSection.h +++ b/Sources/Jazz2/UI/Menu/OptionsSection.h @@ -25,7 +25,7 @@ namespace Jazz2::UI::Menu private: void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/PauseSection.cpp b/Sources/Jazz2/UI/Menu/PauseSection.cpp index 8edd785a..a2ed5388 100644 --- a/Sources/Jazz2/UI/Menu/PauseSection.cpp +++ b/Sources/Jazz2/UI/Menu/PauseSection.cpp @@ -59,7 +59,7 @@ namespace Jazz2::UI::Menu { Recti contentBounds = _root->GetContentBounds(); Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.3f * (1.0f - 0.048f * (int32_t)Item::Count)); - int32_t charOffset = 0; + std::int32_t charOffset = 0; for (int32_t i = 0; i < (int32_t)Item::Count; i++) { _items[i].TouchY = center.Y; @@ -83,12 +83,12 @@ namespace Jazz2::UI::Menu void PauseSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; - for (int32_t i = 0; i < (int32_t)Item::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (std::abs(x - 0.5f) < 0.22f && std::abs(y - _items[i].TouchY) < 22.0f) { if (_selectedIndex == i) { ExecuteSelected(); @@ -109,13 +109,13 @@ namespace Jazz2::UI::Menu _root->PlaySfx("MenuSelect"_s, 0.6f); switch (_selectedIndex) { - case (int32_t)Item::Resume: + case (std::int32_t)Item::Resume: if (auto ingameMenu = dynamic_cast(_root)) { ingameMenu->ResumeGame(); } break; - case (int32_t)Item::Options: _root->SwitchToSection(); break; - case (int32_t)Item::Exit: + case (std::int32_t)Item::Options: _root->SwitchToSection(); break; + case (std::int32_t)Item::Exit: if (auto ingameMenu = dynamic_cast(_root)) { ingameMenu->GoToMainMenu(); } diff --git a/Sources/Jazz2/UI/Menu/PauseSection.h b/Sources/Jazz2/UI/Menu/PauseSection.h index b3947519..9a208cf5 100644 --- a/Sources/Jazz2/UI/Menu/PauseSection.h +++ b/Sources/Jazz2/UI/Menu/PauseSection.h @@ -28,8 +28,8 @@ namespace Jazz2::UI::Menu float TouchY; }; - ItemData _items[(int32_t)Item::Count]; - int32_t _selectedIndex; + ItemData _items[(std::int32_t)Item::Count]; + std::int32_t _selectedIndex; float _animation; void ExecuteSelected(); diff --git a/Sources/Jazz2/UI/Menu/PlayCustomSection.cpp b/Sources/Jazz2/UI/Menu/PlayCustomSection.cpp index 7d0e7ce7..77e61659 100644 --- a/Sources/Jazz2/UI/Menu/PlayCustomSection.cpp +++ b/Sources/Jazz2/UI/Menu/PlayCustomSection.cpp @@ -47,7 +47,7 @@ namespace Jazz2::UI::Menu item.Height = ItemHeight * 8 / 7; } - void PlayCustomSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void PlayCustomSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/PlayCustomSection.h b/Sources/Jazz2/UI/Menu/PlayCustomSection.h index 10e99c45..fc40deaf 100644 --- a/Sources/Jazz2/UI/Menu/PlayCustomSection.h +++ b/Sources/Jazz2/UI/Menu/PlayCustomSection.h @@ -27,7 +27,7 @@ namespace Jazz2::UI::Menu private: void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; void OnExecuteSelected() override; }; } diff --git a/Sources/Jazz2/UI/Menu/RefreshCacheSection.cpp b/Sources/Jazz2/UI/Menu/RefreshCacheSection.cpp index 500d470d..2a8e27f9 100644 --- a/Sources/Jazz2/UI/Menu/RefreshCacheSection.cpp +++ b/Sources/Jazz2/UI/Menu/RefreshCacheSection.cpp @@ -72,7 +72,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 1, center.X, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); center.Y = topLine + (bottomLine - topLine) * 0.4f; - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Refresh Cache"), charOffset, center.X, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); diff --git a/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp b/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp index 0a0fe109..e35bbee7 100644 --- a/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp +++ b/Sources/Jazz2/UI/Menu/RemapControlsSection.cpp @@ -119,7 +119,7 @@ namespace Jazz2::UI::Menu } } - for (std::size_t key = 0; key < (std::int32_t)KeySym::COUNT && waitingForInput; key++) { + for (std::size_t key = 0; key < (std::size_t)KeySym::COUNT && waitingForInput; key++) { bool isPressed = keyState.isKeyDown((KeySym)key); if (isPressed != _keysPressedLast[key]) { _keysPressedLast.set(key, isPressed); @@ -166,7 +166,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Remap Controls"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); @@ -229,7 +229,7 @@ namespace Jazz2::UI::Menu if (axisAnim != AnimState::Default) { _root->DrawElement(axisAnim, 0, centerX * (0.81f + j * 0.2f) + 2.0f, item.Y, IMenuContainer::MainLayer, Alignment::Center, Colorf::White); - for (int32_t i = 0; i < joyIdx + 1; i++) { + for (std::int32_t i = 0; i < joyIdx + 1; i++) { stringBuffer[i] = '1'; } stringBuffer[joyIdx + 1] = '\0'; @@ -275,7 +275,7 @@ namespace Jazz2::UI::Menu if (_waitForInput) { color = Colorf(0.62f, 0.44f, 0.34f, 0.5f); } else { - color = (_selectedIndex == (int32_t)PlayerActions::Menu && _selectedColumn == 0 ? Font::TransparentRandomColor : Font::RandomColor); + color = (_selectedIndex == (std::int32_t)PlayerActions::Menu && _selectedColumn == 0 ? Font::TransparentRandomColor : Font::RandomColor); } _root->DrawStringShadow(value, charOffset, centerX * (0.81f + j * 0.2f), item.Y, IMenuContainer::MainLayer - 10, @@ -303,7 +303,7 @@ namespace Jazz2::UI::Menu return; } - auto* mapping = &ControlScheme::_mappings[_currentPlayerIndex * (int32_t)PlayerActions::Count]; + auto* mapping = &ControlScheme::_mappings[_currentPlayerIndex * (std::int32_t)PlayerActions::Count]; if (_root->ActionHit(PlayerActions::Menu)) { OnBackPressed(); @@ -432,7 +432,7 @@ namespace Jazz2::UI::Menu _keysPressedLast.resetAll(); - for (int32_t key = 0; key < (int32_t)KeySym::COUNT; key++) { + for (std::int32_t key = 0; key < (int32_t)KeySym::COUNT; key++) { if (keyState.isKeyDown((KeySym)key)) { _keysPressedLast.set(key); } diff --git a/Sources/Jazz2/UI/Menu/RemapControlsSection.h b/Sources/Jazz2/UI/Menu/RemapControlsSection.h index 79ae08f0..62bb7096 100644 --- a/Sources/Jazz2/UI/Menu/RemapControlsSection.h +++ b/Sources/Jazz2/UI/Menu/RemapControlsSection.h @@ -25,14 +25,14 @@ namespace Jazz2::UI::Menu void OnDraw(Canvas* canvas) override; private: - int32_t _selectedColumn; - int32_t _currentPlayerIndex; - bool _isDirty; - bool _waitForInput; + std::int32_t _selectedColumn; + std::int32_t _currentPlayerIndex; float _timeout; float _hintAnimation; BitArray _keysPressedLast; JoyMappedState _joyStatesLast[ControlScheme::MaxConnectedGamepads]; + bool _isDirty; + bool _waitForInput; void OnLayoutItem(Canvas* canvas, ListViewItem& item) override; void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; diff --git a/Sources/Jazz2/UI/Menu/RescaleModeSection.cpp b/Sources/Jazz2/UI/Menu/RescaleModeSection.cpp index 509f6915..3992a6a3 100644 --- a/Sources/Jazz2/UI/Menu/RescaleModeSection.cpp +++ b/Sources/Jazz2/UI/Menu/RescaleModeSection.cpp @@ -9,8 +9,8 @@ namespace Jazz2::UI::Menu { RescaleModeSection::RescaleModeSection() { - int32_t currentMode = (int32_t)(PreferencesCache::ActiveRescaleMode & RescaleMode::TypeMask); - for (int32_t i = 0; i <= (int32_t)RescaleMode::Monochrome; i++) { + std::int32_t currentMode = (std::int32_t)(PreferencesCache::ActiveRescaleMode & RescaleMode::TypeMask); + for (std::int32_t i = 0; i <= (std::int32_t)RescaleMode::Monochrome; i++) { if (currentMode == _items.size()) { _selectedIndex = currentMode; } @@ -49,12 +49,12 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Select Rescale Mode"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } - void RescaleModeSection::OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) + void RescaleModeSection::OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) { float centerX = canvas->ViewSize.X * 0.5f; diff --git a/Sources/Jazz2/UI/Menu/RescaleModeSection.h b/Sources/Jazz2/UI/Menu/RescaleModeSection.h index 7739792f..46620914 100644 --- a/Sources/Jazz2/UI/Menu/RescaleModeSection.h +++ b/Sources/Jazz2/UI/Menu/RescaleModeSection.h @@ -19,6 +19,6 @@ namespace Jazz2::UI::Menu private: void OnExecuteSelected() override; - void OnDrawItem(Canvas* canvas, ListViewItem& item, int32_t& charOffset, bool isSelected) override; + void OnDrawItem(Canvas* canvas, ListViewItem& item, std::int32_t& charOffset, bool isSelected) override; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/ServerSelectSection.cpp b/Sources/Jazz2/UI/Menu/ServerSelectSection.cpp index 6150e1b7..1398ffe9 100644 --- a/Sources/Jazz2/UI/Menu/ServerSelectSection.cpp +++ b/Sources/Jazz2/UI/Menu/ServerSelectSection.cpp @@ -62,7 +62,7 @@ namespace Jazz2::UI::Menu if (_selectedIndex > 0) { _selectedIndex--; } else { - _selectedIndex = (int32_t)(_items.size() - 1); + _selectedIndex = (std::int32_t)(_items.size() - 1); } EnsureVisibleSelected(); _pressedCount = std::min(_pressedCount + 6, 10); @@ -104,7 +104,7 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, centerX, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, centerX, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Connect to Server"), charOffset, centerX, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); } @@ -115,7 +115,7 @@ namespace Jazz2::UI::Menu float centerX = contentBounds.X + contentBounds.W * 0.5f; float topLine = contentBounds.Y + TopLine; float bottomLine = contentBounds.Y + contentBounds.H - BottomLine; - int32_t charOffset = 0; + std::int32_t charOffset = 0; if (_items.empty()) { _root->DrawStringShadow(_("No servers found, but still searchin'!"), charOffset, centerX, contentBounds.Y + contentBounds.H * 0.33f, IMenuContainer::FontLayer, @@ -133,7 +133,7 @@ namespace Jazz2::UI::Menu float column2 = contentBounds.X + (contentBounds.W >= 460 ? (contentBounds.W * 0.52f) : (contentBounds.W * 0.44f)); std::size_t itemsCount = _items.size(); - for (int32_t i = 0; i < itemsCount; i++) { + for (std::int32_t i = 0; i < itemsCount; i++) { _items[i].Y = center.Y; if (center.Y > topLine - ItemHeight && center.Y < bottomLine + ItemHeight) { @@ -171,7 +171,7 @@ namespace Jazz2::UI::Menu { switch (event.type) { case TouchEventType::Down: { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float y = event.pointers[pointerIndex].y * (float)viewSize.Y; if (y < 80.0f) { @@ -188,7 +188,7 @@ namespace Jazz2::UI::Menu } case TouchEventType::Move: { if (_touchStart != Vector2f::Zero) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { Vector2f touchMove = Vector2f(event.pointers[pointerIndex].x * (float)viewSize.X, event.pointers[pointerIndex].y * (float)viewSize.Y); _y += touchMove.Y - _touchLast.Y; @@ -206,7 +206,7 @@ namespace Jazz2::UI::Menu float halfW = viewSize.X * 0.5f; std::size_t itemsCount = _items.size(); - for (int32_t i = 0; i < itemsCount; i++) { + for (std::int32_t i = 0; i < itemsCount; i++) { if (std::abs(_touchLast.X - halfW) < 150.0f && std::abs(_touchLast.Y - _items[i].Y) < 22.0f) { if (_selectedIndex == i) { ExecuteSelected(); diff --git a/Sources/Jazz2/UI/Menu/ServerSelectSection.h b/Sources/Jazz2/UI/Menu/ServerSelectSection.h index 40e73888..16081437 100644 --- a/Sources/Jazz2/UI/Menu/ServerSelectSection.h +++ b/Sources/Jazz2/UI/Menu/ServerSelectSection.h @@ -36,14 +36,14 @@ namespace Jazz2::UI::Menu static constexpr std::int32_t BottomLine = 42; SmallVector _items; - int32_t _selectedIndex; + std::int32_t _selectedIndex; float _animation; float _y; float _height; Vector2f _touchStart; Vector2f _touchLast; float _touchTime; - int32_t _pressedCount; + std::int32_t _pressedCount; float _noiseCooldown; Multiplayer::ServerDiscovery _discovery; diff --git a/Sources/Jazz2/UI/Menu/SoundsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/SoundsOptionsSection.cpp index 9ca2503a..d05aa884 100644 --- a/Sources/Jazz2/UI/Menu/SoundsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/SoundsOptionsSection.cpp @@ -12,11 +12,11 @@ namespace Jazz2::UI::Menu : _selectedIndex(0), _animation(0.0f), _isDirty(false), _pressedCooldown(0.0f), _pressedCount(0) { // TRANSLATORS: Menu item in Options > Sounds section - _items[(int32_t)Item::MasterVolume].Name = _("Master Volume"); + _items[(std::int32_t)Item::MasterVolume].Name = _("Master Volume"); // TRANSLATORS: Menu item in Options > Sounds section - _items[(int32_t)Item::SfxVolume].Name = _("SFX Volume"); + _items[(std::int32_t)Item::SfxVolume].Name = _("SFX Volume"); // TRANSLATORS: Menu item in Options > Sounds section - _items[(int32_t)Item::MusicVolume].Name = _("Music Volume"); + _items[(std::int32_t)Item::MusicVolume].Name = _("Music Volume"); } SoundsOptionsSection::~SoundsOptionsSection() @@ -88,7 +88,7 @@ namespace Jazz2::UI::Menu void SoundsOptionsSection::OnDraw(Canvas* canvas) { - constexpr int BlockCount = 33; + constexpr std::int32_t BlockCount = 33; Recti contentBounds = _root->GetContentBounds(); Vector2f center = Vector2f(contentBounds.X + contentBounds.W * 0.5f, contentBounds.Y + contentBounds.H * 0.5f); @@ -100,15 +100,15 @@ namespace Jazz2::UI::Menu _root->DrawElement(MenuLine, 0, center.X, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); _root->DrawElement(MenuLine, 1, center.X, bottomLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - center.Y = topLine + (bottomLine - topLine) * 0.35f / (int32_t)Item::Count; - int charOffset = 0; + center.Y = topLine + (bottomLine - topLine) * 0.35f / (std::int32_t)Item::Count; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Sounds"), charOffset, center.X, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); char stringBuffer[34]; - for (int i = 0; i < (int32_t)Item::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { _items[i].TouchY = center.Y; if (_selectedIndex == i) { @@ -128,15 +128,15 @@ namespace Jazz2::UI::Menu Alignment::Center, Font::DefaultColor, 0.9f); } - int currentBlockCount; + std::int32_t currentBlockCount; switch (i) { default: - case (int32_t)Item::MasterVolume: currentBlockCount = (int32_t)std::round(PreferencesCache::MasterVolume * BlockCount); break; - case (int32_t)Item::SfxVolume: currentBlockCount = (int32_t)std::round(PreferencesCache::SfxVolume * BlockCount); break; - case (int32_t)Item::MusicVolume: currentBlockCount = (int32_t)std::round(PreferencesCache::MusicVolume * BlockCount); break; + case (std::int32_t)Item::MasterVolume: currentBlockCount = (std::int32_t)std::round(PreferencesCache::MasterVolume * BlockCount); break; + case (std::int32_t)Item::SfxVolume: currentBlockCount = (std::int32_t)std::round(PreferencesCache::SfxVolume * BlockCount); break; + case (std::int32_t)Item::MusicVolume: currentBlockCount = (std::int32_t)std::round(PreferencesCache::MusicVolume * BlockCount); break; } - for (int i = 0; i < BlockCount; i++) { + for (std::int32_t i = 0; i < BlockCount; i++) { stringBuffer[i] = '|'; } stringBuffer[BlockCount] = '\0'; @@ -144,7 +144,7 @@ namespace Jazz2::UI::Menu _root->DrawStringShadow(stringBuffer, charOffset, center.X - 66.0f, center.Y + 24.0f, IMenuContainer::FontShadowLayer + 2, Alignment::Left, Colorf(0.38f, 0.37f, 0.34f, 0.34f), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); - for (int i = 0; i < currentBlockCount; i++) { + for (std::int32_t i = 0; i < currentBlockCount; i++) { stringBuffer[i] = '|'; } stringBuffer[currentBlockCount] = '\0'; @@ -153,14 +153,14 @@ namespace Jazz2::UI::Menu Alignment::Left, (_selectedIndex == i ? Font::RandomColor : Font::DefaultColor), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); - center.Y += (bottomLine - topLine) * 0.9f / (int32_t)Item::Count; + center.Y += (bottomLine - topLine) * 0.9f / (std::int32_t)Item::Count; } } void SoundsOptionsSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (event.type == TouchEventType::Down) { - int pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -171,15 +171,15 @@ namespace Jazz2::UI::Menu return; } - for (int i = 0; i < (int32_t)Item::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (std::abs(x - 0.5f) < 0.22f && std::abs(y - _items[i].TouchY) < 30.0f) { if (_selectedIndex == i) { float* value; switch (_selectedIndex) { default: - case (int32_t)Item::MasterVolume: value = &PreferencesCache::MasterVolume; break; - case (int32_t)Item::SfxVolume: value = &PreferencesCache::SfxVolume; break; - case (int32_t)Item::MusicVolume: value = &PreferencesCache::MusicVolume; break; + case (std::int32_t)Item::MasterVolume: value = &PreferencesCache::MasterVolume; break; + case (std::int32_t)Item::SfxVolume: value = &PreferencesCache::SfxVolume; break; + case (std::int32_t)Item::MusicVolume: value = &PreferencesCache::MusicVolume; break; } *value = std::clamp(*value + (x < 0.5f ? -0.03f : 0.03f), 0.0f, 1.0f); diff --git a/Sources/Jazz2/UI/Menu/SoundsOptionsSection.h b/Sources/Jazz2/UI/Menu/SoundsOptionsSection.h index 9998c3b5..e3cfdf3a 100644 --- a/Sources/Jazz2/UI/Menu/SoundsOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/SoundsOptionsSection.h @@ -29,11 +29,11 @@ namespace Jazz2::UI::Menu float TouchY; }; - ItemData _items[(int32_t)Item::Count]; - int32_t _selectedIndex; + ItemData _items[(std::int32_t)Item::Count]; + std::int32_t _selectedIndex; float _animation; - bool _isDirty; float _pressedCooldown; - int32_t _pressedCount; + std::int32_t _pressedCount; + bool _isDirty; }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp b/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp index a507384a..8d6a71d0 100644 --- a/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/StartGameOptionsSection.cpp @@ -15,11 +15,11 @@ namespace Jazz2::UI::Menu _imageTransition(1.0f), _animation(0.0f), _transitionTime(0.0f), _shouldStart(false) { // TRANSLATORS: Menu item to select player character (Jazz, Spaz, Lori) - _items[(int32_t)Item::Character].Name = _("Character"); + _items[(std::int32_t)Item::Character].Name = _("Character"); // TRANSLATORS: Menu item to select difficulty - _items[(int32_t)Item::Difficulty].Name = _("Difficulty"); + _items[(std::int32_t)Item::Difficulty].Name = _("Difficulty"); // TRANSLATORS: Menu item to start selected episode/level - _items[(int32_t)Item::Start].Name = _("Start"); + _items[(std::int32_t)Item::Start].Name = _("Start"); } void StartGameOptionsSection::OnShow(IMenuContainer* root) @@ -145,8 +145,8 @@ namespace Jazz2::UI::Menu _root->DrawElement(selectedDifficultyImage, _selectedDifficulty, imageOffsetX, imageOffsetY, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, _imageTransition), 0.88f * imageScale, 0.88f * imageScale); - int32_t charOffset = 0; - for (int32_t i = 0; i < (int32_t)Item::Count; i++) { + std::int32_t charOffset = 0; + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (_selectedIndex == i) { float size = 0.5f + IMenuContainer::EaseOutElastic(_animation) * 0.6f; @@ -160,8 +160,8 @@ namespace Jazz2::UI::Menu } if (i == 0) { - constexpr const StringView playerTypes[] = { "Jazz"_s, "Spaz"_s, "Lori"_s }; - constexpr Colorf playerColors[] = { + static const StringView playerTypes[] = { "Jazz"_s, "Spaz"_s, "Lori"_s }; + static const Colorf playerColors[] = { Colorf(0.2f, 0.45f, 0.2f, 0.5f), Colorf(0.45f, 0.27f, 0.22f, 0.5f), Colorf(0.5f, 0.45f, 0.22f, 0.5f) @@ -184,7 +184,7 @@ namespace Jazz2::UI::Menu spacing *= 0.7f; } - for (int32_t j = 0; j < _availableCharacters; j++) { + for (std::int32_t j = 0; j < _availableCharacters; j++) { float x = center.X - offset + j * spacing; if (_selectedPlayerType == j) { _root->DrawElement(MenuGlow, 0, x, center.Y + 28.0f, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, 0.2f), (Utf8::GetLength(playerTypes[j]) + 3) * 0.4f, 2.2f, true, true); @@ -204,10 +204,10 @@ namespace Jazz2::UI::Menu _items[i].TouchY = center.Y + 28.0f; } else if (i == 1) { - const StringView difficultyTypes[] = { _("Easy"), _("Medium"), _("Hard") }; + static const StringView difficultyTypes[] = { _("Easy"), _("Medium"), _("Hard") }; float spacing = (contentBounds.W >= 400 ? 100.0f : 70.0f); - for (int32_t j = 0; j < static_cast(arraySize(difficultyTypes)); j++) { + for (std::int32_t j = 0; j < static_cast(arraySize(difficultyTypes)); j++) { if (_selectedDifficulty == j) { _root->DrawElement(MenuGlow, 0, center.X + (j - 1) * spacing, center.Y + 28.0f, IMenuContainer::MainLayer, Alignment::Center, Colorf(1.0f, 1.0f, 1.0f, 0.2f), (Utf8::GetLength(difficultyTypes[j]) + 3) * 0.4f, 2.2f, true, true); @@ -259,7 +259,7 @@ namespace Jazz2::UI::Menu void StartGameOptionsSection::OnTouchEvent(const nCine::TouchEvent& event, const Vector2i& viewSize) { if (!_shouldStart && event.type == TouchEventType::Down) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x * (float)viewSize.X; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -271,11 +271,11 @@ namespace Jazz2::UI::Menu return; } - for (int32_t i = 0; i < (int32_t)Item::Count; i++) { + for (std::int32_t i = 0; i < (std::int32_t)Item::Count; i++) { if (std::abs(x - halfWidth) < 150.0f && std::abs(y - _items[i].TouchY) < 30.0f) { switch (i) { case 0: { - int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); + std::int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); if (_selectedPlayerType != selectedSubitem) { StartImageTransition(); _selectedPlayerType = selectedSubitem; @@ -284,7 +284,7 @@ namespace Jazz2::UI::Menu break; } case 1: { - int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); + std::int32_t selectedSubitem = (x < halfWidth - 50.0f ? 0 : (x > halfWidth + 50.0f ? 2 : 1)); if (_selectedDifficulty != selectedSubitem) { StartImageTransition(); _selectedDifficulty = selectedSubitem; @@ -324,8 +324,8 @@ namespace Jazz2::UI::Menu { bool playTutorial = (!PreferencesCache::TutorialCompleted && _episodeName == "prince"_s && _levelName == "01_castle1"_s); - PlayerType players[] = { (PlayerType)((int32_t)PlayerType::Jazz + _selectedPlayerType) }; - LevelInitialization levelInit(_episodeName, (playTutorial ? "trainer"_s : StringView(_levelName)), (GameDifficulty)((int32_t)GameDifficulty::Easy + _selectedDifficulty), + PlayerType players[] = { (PlayerType)((std::int32_t)PlayerType::Jazz + _selectedPlayerType) }; + LevelInitialization levelInit(_episodeName, (playTutorial ? "trainer"_s : StringView(_levelName)), (GameDifficulty)((std::int32_t)GameDifficulty::Easy + _selectedDifficulty), PreferencesCache::EnableReforgedGameplay, false, players, static_cast(arraySize(players))); if (!_previousEpisodeName.empty()) { diff --git a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp index 4c392d7a..9b988b17 100644 --- a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp +++ b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.cpp @@ -41,7 +41,7 @@ namespace Jazz2::UI::Menu Alignment::Top, Colorf::Black, Vector2f(680.0f, 200.0f), Vector4f(1.0f, 0.0f, -0.7f, 0.7f)); _root->DrawElement(MenuLine, 0, center.X, topLine, IMenuContainer::MainLayer, Alignment::Center, Colorf::White, 1.6f); - int32_t charOffset = 0; + std::int32_t charOffset = 0; _root->DrawStringShadow(_("Touch Controls"), charOffset, center.X, topLine - 21.0f, IMenuContainer::FontLayer, Alignment::Center, Colorf(0.46f, 0.46f, 0.46f, 0.5f), 0.9f, 0.7f, 1.1f, 1.1f, 0.4f, 0.9f); @@ -61,7 +61,7 @@ namespace Jazz2::UI::Menu { switch(event.type) { case TouchEventType::Down: { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { float x = event.pointers[pointerIndex].x; float y = event.pointers[pointerIndex].y * (float)viewSize.Y; @@ -75,7 +75,7 @@ namespace Jazz2::UI::Menu if (y > 120.0f) { if (x < 0.4f) { _selectedZone = SelectedZone::Left; - } else if(x > 0.6f) { + } else if (x > 0.6f) { _selectedZone = SelectedZone::Right; } _lastPos = Vector2f(event.pointers[pointerIndex].x, event.pointers[pointerIndex].y); @@ -86,7 +86,7 @@ namespace Jazz2::UI::Menu } case TouchEventType::Move: { if (event.actionIndex == _lastPointerId) { - int32_t pointerIndex = event.findPointerIndex(event.actionIndex); + std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); if (pointerIndex != -1) { Vector2f newPos = Vector2f(event.pointers[pointerIndex].x, event.pointers[pointerIndex].y); Vector2f diff = (newPos - _lastPos) * Vector2f(static_cast(viewSize.X), static_cast(viewSize.Y)); @@ -123,7 +123,7 @@ namespace Jazz2::UI::Menu } } - void TouchControlsOptionsSection::DrawOutlinedSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size) + void TouchControlsOptionsSection::DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size) { _root->DrawSolid(x, y, z, align, size, Colorf(1.0f, 1.0f, 1.0f, 0.5f)); diff --git a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h index c9dd1b01..332db576 100644 --- a/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h +++ b/Sources/Jazz2/UI/Menu/TouchControlsOptionsSection.h @@ -21,11 +21,11 @@ namespace Jazz2::UI::Menu Right }; - bool _isDirty; SelectedZone _selectedZone; Vector2f _lastPos; - int32_t _lastPointerId; + std::int32_t _lastPointerId; + bool _isDirty; - void DrawOutlinedSolid(float x, float y, uint16_t z, Alignment align, const Vector2f& size); + void DrawOutlinedSolid(float x, float y, std::uint16_t z, Alignment align, const Vector2f& size); }; } \ No newline at end of file diff --git a/Sources/Jazz2/UI/RgbLights.h b/Sources/Jazz2/UI/RgbLights.h index 1e6f79c3..90f3d7cb 100644 --- a/Sources/Jazz2/UI/RgbLights.h +++ b/Sources/Jazz2/UI/RgbLights.h @@ -38,10 +38,10 @@ namespace ChromaSDK::Keyboard } EFFECT_TYPE; //! Maximum number of rows in a keyboard. - const size_t MAX_ROW = 6; + const std::size_t MAX_ROW = 6; //! Maximum number of columns in a keyboard. - const size_t MAX_COLUMN = 22; + const std::size_t MAX_COLUMN = 22; //! Custom effect (This effect type has deprecated and should not be used). typedef struct CUSTOM_EFFECT_TYPE { diff --git a/Sources/Jazz2/UI/UpscaleRenderPass.cpp b/Sources/Jazz2/UI/UpscaleRenderPass.cpp index 4b8ef614..3544d59e 100644 --- a/Sources/Jazz2/UI/UpscaleRenderPass.cpp +++ b/Sources/Jazz2/UI/UpscaleRenderPass.cpp @@ -7,7 +7,7 @@ namespace Jazz2::UI { - void UpscaleRenderPass::Initialize(int32_t width, int32_t height, int32_t targetWidth, int32_t targetHeight) + void UpscaleRenderPass::Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight) { _targetSize = Vector2f((float)targetWidth, (float)targetHeight); @@ -16,8 +16,8 @@ namespace Jazz2::UI float widthFrac = modff((float)targetWidth / width, &widthRatio); float heightFrac = modff((float)targetHeight / height, &heightRatio); - int32_t requiredWidth = (int32_t)(widthFrac > 0.004f ? (width * (widthRatio + 1)) : targetWidth); - int32_t requiredHeight = (int32_t)(heightFrac > 0.004f ? (height * (heightRatio + 1)) : targetHeight); + std::int32_t requiredWidth = (std::int32_t)(widthFrac > 0.004f ? (width * (widthRatio + 1)) : targetWidth); + std::int32_t requiredHeight = (std::int32_t)(heightFrac > 0.004f ? (height * (heightRatio + 1)) : targetHeight); if (std::abs(requiredWidth - targetWidth) > 2 || std::abs(requiredHeight - targetHeight) > 2) { if (_antialiasing._target == nullptr) { @@ -182,7 +182,7 @@ namespace Jazz2::UI return true; } - void UpscaleRenderPassWithClipping::Initialize(int32_t width, int32_t height, int32_t targetWidth, int32_t targetHeight) + void UpscaleRenderPassWithClipping::Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight) { if (_clippedView != nullptr) { _clippedView->removeAllTextures(); diff --git a/Sources/Jazz2/UI/UpscaleRenderPass.h b/Sources/Jazz2/UI/UpscaleRenderPass.h index 60ed07c6..68965c30 100644 --- a/Sources/Jazz2/UI/UpscaleRenderPass.h +++ b/Sources/Jazz2/UI/UpscaleRenderPass.h @@ -21,7 +21,7 @@ namespace Jazz2::UI setVisitOrderState(SceneNode::VisitOrderState::Disabled); } - virtual void Initialize(int32_t width, int32_t height, int32_t targetWidth, int32_t targetHeight); + virtual void Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight); virtual void Register(); bool OnDraw(RenderQueue& renderQueue) override; @@ -82,7 +82,7 @@ namespace Jazz2::UI { } - void Initialize(int32_t width, int32_t height, int32_t targetWidth, int32_t targetHeight) override; + void Initialize(std::int32_t width, std::int32_t height, std::int32_t targetWidth, std::int32_t targetHeight) override; void Register() override; SceneNode* GetClippedNode() const { diff --git a/Sources/nCine/IO/EmscriptenLocalFile.cpp b/Sources/nCine/IO/EmscriptenLocalFile.cpp index 09af7b74..cd3c5347 100644 --- a/Sources/nCine/IO/EmscriptenLocalFile.cpp +++ b/Sources/nCine/IO/EmscriptenLocalFile.cpp @@ -7,6 +7,7 @@ #include "../../Common.h" #include +#include namespace nCine { @@ -20,8 +21,8 @@ namespace nCine auto eventType = event["type"].as(); if (eventType != "load") { // FileReader failed - Call user file data handler - EmscriptenLocalFile::FileDataCallbackType* fileDataCallback = reinterpret_cast(fileReader["data-dataCallback"].as()); - void* context = reinterpret_cast(fileReader["data-callbackContext"].as()); + EmscriptenLocalFile::FileDataCallbackType* fileDataCallback = reinterpret_cast(fileReader["data-dataCallback"].as()); + void* context = reinterpret_cast(fileReader["data-callbackContext"].as()); fileDataCallback(context, nullptr, 0, nullptr); return; } @@ -32,17 +33,17 @@ namespace nCine emscripten::val sourceTypedArray = Uint8Array.new_(result); // Allocate and set up destination typed array - const size_t size = result["byteLength"].as(); + std::size_t size = result["byteLength"].as(); char* buffer = new char[size]; - emscripten::val destinationTypedArray = Uint8Array.new_(emscripten::val::module_property("HEAPU8")["buffer"], size_t(buffer), size); + emscripten::val destinationTypedArray = Uint8Array.new_(emscripten::val::module_property("HEAPU8")["buffer"], std::size_t(buffer), size); destinationTypedArray.call("set", sourceTypedArray); auto fileName = fileReader["data-name"].as(); // Call user file data handler - EmscriptenLocalFile::FileDataCallbackType* fileDataCallback = reinterpret_cast(fileReader["data-dataCallback"].as()); - void* context = reinterpret_cast(fileReader["data-callbackContext"].as()); - fileDataCallback(context, std::unique_ptr(buffer), size, StringView(fileName.data(), fileName.size())); + EmscriptenLocalFile::FileDataCallbackType* fileDataCallback = reinterpret_cast(fileReader["data-dataCallback"].as()); + void* context = reinterpret_cast(fileReader["data-callbackContext"].as()); + fileDataCallback(context, std::unique_ptr(buffer), size, fileName); } void ReadFiles(emscripten::val event) @@ -50,15 +51,15 @@ namespace nCine // Read all selected files using FileReader emscripten::val target = event["target"]; emscripten::val files = target["files"]; - const int fileCount = files["length"].as(); + const std::int32_t fileCount = files["length"].as(); - EmscriptenLocalFile::FileCountCallbackType* doneCallback = reinterpret_cast(target["data-countCallback"].as()); - void* context = reinterpret_cast(target["data-callbackContext"].as()); + EmscriptenLocalFile::FileCountCallbackType* doneCallback = reinterpret_cast(target["data-countCallback"].as()); + void* context = reinterpret_cast(target["data-callbackContext"].as()); doneCallback(context, fileCount); auto fileCallback = emscripten::val::module_property("jsReadFileContent"); - for (int i = 0; i < fileCount; i++) { + for (std::int32_t i = 0; i < fileCount; i++) { emscripten::val file = files[i]; emscripten::val fileReader = emscripten::val::global("FileReader").new_(); fileReader.set("onload", fileCallback); @@ -133,10 +134,9 @@ namespace nCine function("jsReadFiles", &ReadFiles); function("jsReadFileContent", &ReadFileContent); }; - } - void EmscriptenLocalFile::Load(const StringView& fileFilter, bool multiple, FileDataCallbackType fileDataCallback, FileCountCallbackType fileCountCallback, void* userData) + void EmscriptenLocalFile::Load(StringView fileFilter, bool multiple, FileDataCallbackType fileDataCallback, FileCountCallbackType fileCountCallback, void* userData) { LoadFile(String::nullTerminatedView(fileFilter).data(), multiple, fileDataCallback, fileCountCallback, userData); } diff --git a/Sources/nCine/IO/EmscriptenLocalFile.h b/Sources/nCine/IO/EmscriptenLocalFile.h index 8267766a..b1bbe66a 100644 --- a/Sources/nCine/IO/EmscriptenLocalFile.h +++ b/Sources/nCine/IO/EmscriptenLocalFile.h @@ -18,16 +18,13 @@ namespace nCine class EmscriptenLocalFile { public: - using FileDataCallbackType = void(void* context, std::unique_ptr data, size_t length, const StringView& name); - using FileCountCallbackType = void(void* context, int fileCount); + using FileDataCallbackType = void(void* context, std::unique_ptr data, std::size_t length, StringView name); + using FileCountCallbackType = void(void* context, std::int32_t fileCount); - static void Load(const StringView& fileFilter, bool multiple, FileDataCallbackType fileDataCallback, FileCountCallbackType fileCountCallback, void* userData); + EmscriptenLocalFile() = delete; + ~EmscriptenLocalFile() = delete; - private: - /// Deleted copy constructor - EmscriptenLocalFile(const EmscriptenLocalFile&) = delete; - /// Deleted assignment operator - EmscriptenLocalFile& operator=(const EmscriptenLocalFile&) = delete; + static void Load(StringView fileFilter, bool multiple, FileDataCallbackType fileDataCallback, FileCountCallbackType fileCountCallback, void* userData); }; }