Fix inconsistent static/inline usage.

This commit is contained in:
Skyth 2024-12-13 14:51:13 +03:00
parent 87e3602f41
commit 417805ae38
21 changed files with 85 additions and 85 deletions

View file

@ -5,12 +5,12 @@
class App
{
public:
inline static bool s_isInit;
inline static bool s_isMissingDLC;
static inline bool s_isInit;
static inline bool s_isMissingDLC;
inline static ELanguage s_language;
static inline ELanguage s_language;
inline static double s_deltaTime;
static inline double s_deltaTime;
static void Restart(std::vector<std::string> restartArgs = {});
static void Exit();

View file

@ -1,7 +1,7 @@
#pragma once
template<size_t N>
static std::unique_ptr<uint8_t[]> decompressZstd(const uint8_t(&data)[N], size_t decompressedSize)
inline std::unique_ptr<uint8_t[]> decompressZstd(const uint8_t(&data)[N], size_t decompressedSize)
{
auto decompressedData = std::make_unique<uint8_t[]>(decompressedSize);
ZSTD_decompress(decompressedData.get(), decompressedSize, data, N);

View file

@ -22,19 +22,19 @@
_##procName* procName = (_##procName*)PROC_ADDRESS(libraryName, #procName);
template<typename T>
void ByteSwap(T& value)
inline void ByteSwap(T& value)
{
value = std::byteswap(value);
}
template<typename T>
T RoundUp(const T& in_rValue, uint32_t in_round)
inline T RoundUp(const T& in_rValue, uint32_t in_round)
{
return (in_rValue + in_round - 1) & ~(in_round - 1);
}
template<typename T>
T RoundDown(const T& in_rValue, uint32_t in_round)
inline T RoundDown(const T& in_rValue, uint32_t in_round)
{
return in_rValue & ~(in_round - 1);
}
@ -75,7 +75,7 @@ constexpr size_t FirstBitLow(TValue value)
return 0;
}
inline static std::unique_ptr<uint8_t[]> ReadAllBytes(const char* filePath, size_t& fileSize)
inline std::unique_ptr<uint8_t[]> ReadAllBytes(const char* filePath, size_t& fileSize)
{
FILE* file = fopen(filePath, "rb");

View file

@ -8,7 +8,7 @@ extern std::unordered_map<uint16_t, GuestTexture*> g_xdbfTextureCache;
namespace xdbf
{
inline static std::string& FixInvalidSequences(std::string& str)
inline std::string& FixInvalidSequences(std::string& str)
{
static std::vector<std::string> invalidSequences =
{

View file

@ -3,10 +3,10 @@
#include <user/config_detail.h>
#define CONFIG_DEFINE_LOCALE(name) \
inline static std::unordered_map<ELanguage, std::tuple<std::string, std::string>> g_##name##_locale =
inline std::unordered_map<ELanguage, std::tuple<std::string, std::string>> g_##name##_locale =
#define CONFIG_DEFINE_ENUM_LOCALE(type) \
inline static std::unordered_map<ELanguage, std::unordered_map<type, std::tuple<std::string, std::string>>> g_##type##_locale =
inline std::unordered_map<ELanguage, std::unordered_map<type, std::tuple<std::string, std::string>>> g_##type##_locale =
CONFIG_DEFINE_ENUM_LOCALE(bool)
{

View file

@ -2,9 +2,9 @@
#include <user/config.h>
inline static std::string g_localeMissing = "<missing string>";
inline std::string g_localeMissing = "<missing string>";
inline static std::unordered_map<std::string, std::unordered_map<ELanguage, std::string>> g_locale
inline std::unordered_map<std::string, std::unordered_map<ELanguage, std::string>> g_locale
{
{
"Options_Category_System",
@ -294,7 +294,7 @@ inline static std::unordered_map<std::string, std::unordered_map<ELanguage, std:
}
};
static std::string& Localise(const char* key)
inline std::string& Localise(const char* key)
{
if (!g_locale.count(key))
return g_localeMissing;

View file

@ -5,9 +5,9 @@
class AchievementOverlay
{
public:
inline static bool s_isVisible = false;
static inline bool s_isVisible = false;
inline static std::queue<uint16_t> s_queue{};
static inline std::queue<uint16_t> s_queue{};
static void Init();
static void Draw();

View file

@ -55,7 +55,7 @@ public:
class ButtonGuide
{
public:
inline static bool s_isVisible = false;
static inline bool s_isVisible = false;
static void Init();
static void Draw();

View file

@ -3,7 +3,7 @@
class Fader
{
public:
inline static bool s_isVisible = false;
static inline bool s_isVisible = false;
static void Draw();
static void SetFadeColour(ImU32 colour);

View file

@ -13,7 +13,7 @@
#define CENTRE_TEXT_HORZ(min, max, textSize) min.x + ((max.x - min.x) - textSize.x) / 2
#define CENTRE_TEXT_VERT(min, max, textSize) min.y + ((max.y - min.y) - textSize.y) / 2
static void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom)
inline void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 bottom)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetGradient);
callbackData->setGradient.boundsMin[0] = min.x;
@ -24,47 +24,47 @@ static void SetGradient(const ImVec2& min, const ImVec2& max, ImU32 top, ImU32 b
callbackData->setGradient.gradientBottom = bottom;
}
static void ResetGradient()
inline void ResetGradient()
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetGradient);
memset(&callbackData->setGradient, 0, sizeof(callbackData->setGradient));
}
static void SetShaderModifier(uint32_t shaderModifier)
inline void SetShaderModifier(uint32_t shaderModifier)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetShaderModifier);
callbackData->setShaderModifier.shaderModifier = shaderModifier;
}
static void SetOrigin(ImVec2 origin)
inline void SetOrigin(ImVec2 origin)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetOrigin);
callbackData->setOrigin.origin[0] = origin.x;
callbackData->setOrigin.origin[1] = origin.y;
}
static void SetScale(ImVec2 scale)
inline void SetScale(ImVec2 scale)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetScale);
callbackData->setScale.scale[0] = scale.x;
callbackData->setScale.scale[1] = scale.y;
}
static void SetTextSkew(float yCenter, float skewScale)
inline void SetTextSkew(float yCenter, float skewScale)
{
SetShaderModifier(IMGUI_SHADER_MODIFIER_TEXT_SKEW);
SetOrigin({ 0.0f, yCenter });
SetScale({ skewScale, 1.0f });
}
static void ResetTextSkew()
inline void ResetTextSkew()
{
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
SetOrigin({ 0.0f, 0.0f });
SetScale({ 1.0f, 1.0f });
}
static void SetMarqueeFade(ImVec2 min, ImVec2 max, float fadeScale)
inline void SetMarqueeFade(ImVec2 min, ImVec2 max, float fadeScale)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetMarqueeFade);
callbackData->setMarqueeFade.boundsMin[0] = min.x;
@ -76,26 +76,26 @@ static void SetMarqueeFade(ImVec2 min, ImVec2 max, float fadeScale)
SetScale({ fadeScale, 1.0f });
}
static void ResetMarqueeFade()
inline void ResetMarqueeFade()
{
ResetGradient();
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
SetScale({ 1.0f, 1.0f });
}
static void SetOutline(float outline)
inline void SetOutline(float outline)
{
auto callbackData = AddImGuiCallback(ImGuiCallback::SetOutline);
callbackData->setOutline.outline = outline;
}
static void ResetOutline()
inline void ResetOutline()
{
SetOutline(0.0f);
}
// Aspect ratio aware.
static float Scale(float size)
inline float Scale(float size)
{
auto& io = ImGui::GetIO();
@ -106,25 +106,25 @@ static float Scale(float size)
}
// Not aspect ratio aware. Will stretch.
static float ScaleX(float x)
inline float ScaleX(float x)
{
auto& io = ImGui::GetIO();
return x * io.DisplaySize.x / 1280.0f;
}
// Not aspect ratio aware. Will stretch.
static float ScaleY(float y)
inline float ScaleY(float y)
{
auto& io = ImGui::GetIO();
return y * io.DisplaySize.y / 720.0f;
}
static double ComputeMotion(double duration, double offset, double total)
inline double ComputeMotion(double duration, double offset, double total)
{
return sqrt(std::clamp((ImGui::GetTime() - duration - offset / 60.0) / total * 60.0, 0.0, 1.0));
}
static void DrawPauseContainer(GuestTexture* texture, ImVec2 min, ImVec2 max, float alpha = 1)
inline void DrawPauseContainer(GuestTexture* texture, ImVec2 min, ImVec2 max, float alpha = 1)
{
auto drawList = ImGui::GetForegroundDrawList();
@ -155,7 +155,7 @@ static void DrawPauseContainer(GuestTexture* texture, ImVec2 min, ImVec2 max, fl
drawList->AddImage(texture, { max.x - commonWidth, max.y - commonHeight }, { max.x, max.y + bottomHeight }, GET_UV_COORDS(br), colour);
}
static void DrawPauseHeaderContainer(GuestTexture* texture, ImVec2 min, ImVec2 max, float alpha = 1)
inline void DrawPauseHeaderContainer(GuestTexture* texture, ImVec2 min, ImVec2 max, float alpha = 1)
{
auto drawList = ImGui::GetForegroundDrawList();
@ -172,7 +172,7 @@ static void DrawPauseHeaderContainer(GuestTexture* texture, ImVec2 min, ImVec2 m
drawList->AddImage(texture, { max.x - commonWidth, min.y }, max, GET_UV_COORDS(right), colour);
}
static void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed)
inline void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 color, const char* text, double time, double delay, double speed)
{
auto drawList = ImGui::GetForegroundDrawList();
auto rectWidth = max.x - min.x;
@ -190,7 +190,7 @@ static void DrawTextWithMarquee(const ImFont* font, float fontSize, const ImVec2
drawList->PopClipRect();
}
static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 color, const char* text, float outlineSize, ImU32 outlineColor, uint32_t shaderModifier = IMGUI_SHADER_MODIFIER_NONE)
inline void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 color, const char* text, float outlineSize, ImU32 outlineColor, uint32_t shaderModifier = IMGUI_SHADER_MODIFIER_NONE)
{
auto drawList = ImGui::GetForegroundDrawList();
@ -207,7 +207,7 @@ static void DrawTextWithOutline(const ImFont* font, float fontSize, const ImVec2
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
}
static void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
inline void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2& pos, ImU32 colour, const char* text, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
{
auto drawList = ImGui::GetForegroundDrawList();
@ -220,7 +220,7 @@ static void DrawTextWithShadow(const ImFont* font, float fontSize, const ImVec2&
drawList->AddText(font, fontSize, pos, colour, text, nullptr);
}
static float CalcWidestTextSize(const ImFont* font, float fontSize, std::span<std::string> strs)
inline float CalcWidestTextSize(const ImFont* font, float fontSize, std::span<std::string> strs)
{
auto result = 0.0f;
@ -230,7 +230,7 @@ static float CalcWidestTextSize(const ImFont* font, float fontSize, std::span<st
return result;
}
static std::string Truncate(const std::string& input, size_t maxLength, bool useEllipsis = true, bool usePrefixEllipsis = false)
inline std::string Truncate(const std::string& input, size_t maxLength, bool useEllipsis = true, bool usePrefixEllipsis = false)
{
const std::string ellipsis = "...";
@ -256,7 +256,7 @@ static std::string Truncate(const std::string& input, size_t maxLength, bool use
return input;
}
static std::vector<std::string> Split(const char* str, char delimiter)
inline std::vector<std::string> Split(const char* str, char delimiter)
{
std::vector<std::string> result;
@ -282,7 +282,7 @@ static std::vector<std::string> Split(const char* str, char delimiter)
return result;
}
static ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMargin, std::vector<std::string> lines)
inline ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMargin, std::vector<std::string> lines)
{
auto x = 0.0f;
auto y = 0.0f;
@ -298,12 +298,12 @@ static ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float
return { x, y };
}
static ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMargin, const char* text)
inline ImVec2 MeasureCentredParagraph(const ImFont* font, float fontSize, float lineMargin, const char* text)
{
return MeasureCentredParagraph(font, fontSize, lineMargin, Split(text, '\n'));
}
static void DrawCentredParagraph(const ImFont* font, float fontSize, const ImVec2& centre, float lineMargin, const char* text, std::function<void(const char*, ImVec2)> drawMethod)
inline void DrawCentredParagraph(const ImFont* font, float fontSize, const ImVec2& centre, float lineMargin, const char* text, std::function<void(const char*, ImVec2)> drawMethod)
{
auto lines = Split(text, '\n');
auto paragraphSize = MeasureCentredParagraph(font, fontSize, lineMargin, lines);
@ -337,7 +337,7 @@ static void DrawCentredParagraph(const ImFont* font, float fontSize, const ImVec
}
}
static void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 colour, const char* text, double time, double delay, double speed, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
inline void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const ImVec2& pos, const ImVec2& min, const ImVec2& max, ImU32 colour, const char* text, double time, double delay, double speed, float offset = 2.0f, float radius = 1.0f, ImU32 shadowColour = IM_COL32(0, 0, 0, 255))
{
auto drawList = ImGui::GetForegroundDrawList();
auto rectWidth = max.x - min.x;
@ -355,27 +355,27 @@ static void DrawTextWithMarqueeShadow(const ImFont* font, float fontSize, const
drawList->PopClipRect();
}
static float Lerp(float a, float b, float t)
inline float Lerp(float a, float b, float t)
{
return a + (b - a) * t;
}
static float Cubic(float a, float b, float t)
inline float Cubic(float a, float b, float t)
{
return a + (b - a) * (t * t * t);
}
static float Hermite(float a, float b, float t)
inline float Hermite(float a, float b, float t)
{
return a + (b - a) * (t * t * (3 - 2 * t));
}
static ImVec2 Lerp(const ImVec2& a, const ImVec2& b, float t)
inline ImVec2 Lerp(const ImVec2& a, const ImVec2& b, float t)
{
return { a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t };
}
static ImU32 ColourLerp(ImU32 c0, ImU32 c1, float t)
inline ImU32 ColourLerp(ImU32 c0, ImU32 c1, float t)
{
auto a = ImGui::ColorConvertU32ToFloat4(c0);
auto b = ImGui::ColorConvertU32ToFloat4(c1);

View file

@ -4,7 +4,7 @@
struct InstallerWizard
{
inline static bool s_isVisible = false;
static inline bool s_isVisible = false;
static void Init();
static void Draw();

View file

@ -6,7 +6,7 @@
class MessageWindow
{
public:
inline static bool s_isVisible = false;
static inline bool s_isVisible = false;
static void Init();
static void Draw();

View file

@ -5,11 +5,11 @@
class OptionsMenu
{
public:
inline static bool s_isVisible = false;
inline static bool s_isPause = false;
inline static bool s_isRestartRequired = false;
static inline bool s_isVisible = false;
static inline bool s_isPause = false;
static inline bool s_isRestartRequired = false;
inline static SWA::EMenuType s_pauseMenuType;
static inline SWA::EMenuType s_pauseMenuType;
static void Init();
static void Draw();

View file

@ -36,9 +36,9 @@
#include <res/images/options_menu/thumbnails/window_size.dds.h>
#include <res/images/options_menu/thumbnails/xbox_color_correction.dds.h>
inline static std::unordered_map<std::string_view, std::unique_ptr<GuestTexture>> g_thumbnails;
inline std::unordered_map<std::string_view, std::unique_ptr<GuestTexture>> g_thumbnails;
static void LoadThumbnails()
inline void LoadThumbnails()
{
g_thumbnails[Config::Language.Name] = LOAD_ZSTD_TEXTURE(g_language);
g_thumbnails[Config::Hints.Name] = LOAD_ZSTD_TEXTURE(g_hints);
@ -73,7 +73,7 @@ static void LoadThumbnails()
g_thumbnails[Config::UIScaleMode.Name] = LOAD_ZSTD_TEXTURE(g_ui_scale_mode);
}
static GuestTexture* GetThumbnail(const std::string_view name)
inline GuestTexture* GetThumbnail(const std::string_view name)
{
if (!g_thumbnails.count(name))
return nullptr;

View file

@ -7,7 +7,7 @@ public:
virtual void OnSDLEvent(SDL_Event* event) = 0;
};
std::vector<ISDLEventListener*>& GetEventListeners();
extern std::vector<ISDLEventListener*>& GetEventListeners();
class SDLEventListener : public ISDLEventListener
{

View file

@ -18,17 +18,17 @@
class Window
{
public:
inline static SDL_Window* s_pWindow;
inline static HWND s_handle;
static inline SDL_Window* s_pWindow;
static inline HWND s_handle;
inline static int s_x;
inline static int s_y;
inline static int s_width = DEFAULT_WIDTH;
inline static int s_height = DEFAULT_HEIGHT;
static inline int s_x;
static inline int s_y;
static inline int s_width = DEFAULT_WIDTH;
static inline int s_height = DEFAULT_HEIGHT;
inline static bool s_isFocused;
inline static bool s_isIconNight;
inline static bool s_isFullscreenCursorVisible;
static inline bool s_isFocused;
static inline bool s_isIconNight;
static inline bool s_isFullscreenCursorVisible;
static SDL_Surface* GetIconSurface(void* pIconBmp, size_t iconSize)
{

View file

@ -5,7 +5,7 @@
#define SDL_USER_EVILSONIC (SDL_USEREVENT + 1)
inline static void SDL_ResizeEvent(SDL_Window* pWindow, int width, int height)
inline void SDL_ResizeEvent(SDL_Window* pWindow, int width, int height)
{
SDL_Event event{};
event.type = SDL_WINDOWEVENT;
@ -17,7 +17,7 @@ inline static void SDL_ResizeEvent(SDL_Window* pWindow, int width, int height)
SDL_PushEvent(&event);
}
inline static void SDL_MoveEvent(SDL_Window* pWindow, int x, int y)
inline void SDL_MoveEvent(SDL_Window* pWindow, int x, int y)
{
SDL_Event event{};
event.type = SDL_WINDOWEVENT;
@ -29,7 +29,7 @@ inline static void SDL_MoveEvent(SDL_Window* pWindow, int x, int y)
SDL_PushEvent(&event);
}
inline static void SDL_User_EvilSonic(SDL_Window* pWindow, bool isCtor)
inline void SDL_User_EvilSonic(SDL_Window* pWindow, bool isCtor)
{
SDL_Event event{};
event.type = SDL_USER_EVILSONIC;

View file

@ -43,7 +43,7 @@ public:
Record Records[ACH_RECORDS];
};
inline static Data Data{ ACH_SIGNATURE, ACH_VERSION };
static inline Data Data{ ACH_SIGNATURE, ACH_VERSION };
static std::filesystem::path GetDataPath()
{

View file

@ -8,7 +8,7 @@
class Config
{
public:
inline static std::vector<IConfigDef*> Definitions{};
static inline std::vector<IConfigDef*> Definitions{};
CONFIG_DEFINE_ENUM_LOCALISED("System", ELanguage, Language, ELanguage::English);
CONFIG_DEFINE_LOCALISED("System", bool, Hints, true);

View file

@ -1,22 +1,22 @@
#pragma once
#define CONFIG_DEFINE(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, defaultValue};
static inline ConfigDef<type> name{section, #name, defaultValue};
#define CONFIG_DEFINE_LOCALISED(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
#define CONFIG_DEFINE_ENUM(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, defaultValue, &g_##type##_template};
static inline ConfigDef<type> name{section, #name, defaultValue, &g_##type##_template};
#define CONFIG_DEFINE_ENUM_LOCALISED(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue, &g_##type##_template, &g_##type##_locale};
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue, &g_##type##_template, &g_##type##_locale};
#define CONFIG_DEFINE_CALLBACK(section, type, name, defaultValue, readCallback) \
inline static ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type>* def) readCallback};
static inline ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type>* def) readCallback};
#define CONFIG_DEFINE_ENUM_TEMPLATE(type) \
inline static std::unordered_map<std::string, type> g_##type##_template =
inline std::unordered_map<std::string, type> g_##type##_template =
#define CONFIG_LOCALE std::unordered_map<ELanguage, std::tuple<std::string, std::string>>
#define CONFIG_ENUM_LOCALE(type) std::unordered_map<ELanguage, std::unordered_map<type, std::tuple<std::string, std::string>>>
@ -275,7 +275,7 @@ public:
};
template<typename T>
class ConfigDef : public IConfigDef
class ConfigDef final : public IConfigDef
{
public:
std::string Section{};

View file

@ -2,12 +2,12 @@
#define USER_DIRECTORY "SWA"
static std::filesystem::path GetGamePath()
inline std::filesystem::path GetGamePath()
{
return std::filesystem::current_path();
}
static std::filesystem::path GetUserPath()
inline std::filesystem::path GetUserPath()
{
if (std::filesystem::exists("portable.txt"))
return std::filesystem::current_path();
@ -24,7 +24,7 @@ static std::filesystem::path GetUserPath()
return userPath;
}
static std::filesystem::path GetSavePath()
inline std::filesystem::path GetSavePath()
{
return GetUserPath() / "save";
}