Skip to content

Commit

Permalink
chore: 删除不需要的 const 说明符
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed Apr 23, 2024
1 parent 8f6a272 commit 669ef4d
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/Magpie.App/AutoStartHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

namespace winrt::Magpie::App {

static constexpr const DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2; // Domain Name + '\' + User Name + '\0'
static constexpr const DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0'
static constexpr DWORD USERNAME_DOMAIN_LEN = DNLEN + UNLEN + 2; // Domain Name + '\' + User Name + '\0'
static constexpr DWORD USERNAME_LEN = UNLEN + 1; // User Name + '\0'


static std::wstring GetTaskName(std::wstring_view userName) noexcept {
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie.App/EffectsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct EffectParameterDesc;
namespace winrt::Magpie::App {

struct EffectInfoFlags {
static constexpr const uint32_t CanScale = 1;
static constexpr uint32_t CanScale = 1;
};

struct EffectInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie.App/ProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ fire_and_forget ProfileViewModel::_LoadIcon(FrameworkElement const& rootPage) {

co_await resume_background();

static constexpr const UINT ICON_SIZE = 32;
static constexpr UINT ICON_SIZE = 32;
if (isPackaged) {
AppXReader appxReader;
[[maybe_unused]] bool result = appxReader.Initialize(path);
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie.App/RootPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace Windows::UI::Xaml::Media::Imaging;

namespace winrt::Magpie::App::implementation {

static constexpr const uint32_t FIRST_PROFILE_ITEM_IDX = 4;
static constexpr uint32_t FIRST_PROFILE_ITEM_IDX = 4;

RootPage::RootPage() {
_themeChangedRevoker = AppSettings::Get().ThemeChanged(auto_revoke, [this](Theme) { _UpdateTheme(); });
Expand Down
4 changes: 2 additions & 2 deletions src/Magpie.Core/EffectCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ void serialize(Archive& ar, EffectDesc& o) {
ar& o.name& o.params& o.textures& o.samplers& o.passes& o.flags;
}

static constexpr const uint32_t MAX_CACHE_COUNT = 127;
static constexpr uint32_t MAX_CACHE_COUNT = 127;

// 缓存版本
// 当缓存文件结构有更改时更新它,使旧缓存失效
static constexpr const uint32_t EFFECT_CACHE_VERSION = 13;
static constexpr uint32_t EFFECT_CACHE_VERSION = 13;


static std::wstring GetLinearEffectName(std::wstring_view effectName) {
Expand Down
8 changes: 4 additions & 4 deletions src/Magpie.Core/EffectCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
namespace Magpie::Core {

struct EffectCompilerFlags {
static constexpr const uint32_t NoCache = 1;
static constexpr const uint32_t SaveSources = 1 << 1;
static constexpr const uint32_t WarningsAreErrors = 1 << 2;
static constexpr uint32_t NoCache = 1;
static constexpr uint32_t SaveSources = 1 << 1;
static constexpr uint32_t WarningsAreErrors = 1 << 2;
// 只解析输出尺寸和参数,供用户界面使用
static constexpr const uint32_t NoCompile = 1 << 3;
static constexpr uint32_t NoCompile = 1 << 3;
};

struct EffectCompiler {
Expand Down
6 changes: 3 additions & 3 deletions src/Magpie.Core/EffectDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ struct EffectPassDesc {

struct EffectFlags {
// 输入
static constexpr const uint32_t InlineParams = 1;
static constexpr const uint32_t FP16 = 1 << 1;
static constexpr uint32_t InlineParams = 1;
static constexpr uint32_t FP16 = 1 << 1;
// 输出
// 此效果需要帧数和鼠标位置
static constexpr const uint32_t UseDynamic = 1 << 4;
static constexpr uint32_t UseDynamic = 1 << 4;
};

struct EffectDesc {
Expand Down
6 changes: 3 additions & 3 deletions src/Magpie.Core/FrameSourceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace Magpie::Core {

static constexpr const uint16_t INITIAL_CHECK_COUNT = 16;
static constexpr const uint16_t INITIAL_SKIP_COUNT = 1;
static constexpr const uint16_t MAX_SKIP_COUNT = 16;
static constexpr uint16_t INITIAL_CHECK_COUNT = 16;
static constexpr uint16_t INITIAL_SKIP_COUNT = 1;
static constexpr uint16_t MAX_SKIP_COUNT = 16;

FrameSourceBase::FrameSourceBase() noexcept :
_nextSkipCount(INITIAL_SKIP_COUNT), _framesLeft(INITIAL_CHECK_COUNT) {}
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie.Core/ImGuiFontsCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace Magpie::Core {

// 缓存版本
// 当缓存文件结构有更改时更新它,使旧缓存失效
static constexpr const uint32_t FONTS_CACHE_VERSION = 1;
static constexpr uint32_t FONTS_CACHE_VERSION = 1;

static std::wstring GetCacheFileName(const std::wstring_view& language) noexcept {
return StrUtils::Concat(CommonSharedConstants::CACHE_DIR, L"fonts_", language);
Expand Down
34 changes: 17 additions & 17 deletions src/Magpie.Core/ScalingOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ struct Cropping {
};

struct ScalingFlags {
static constexpr const uint32_t DisableWindowResizing = 1;
static constexpr const uint32_t BreakpointMode = 1 << 1;
static constexpr const uint32_t DisableEffectCache = 1 << 2;
static constexpr const uint32_t SaveEffectSources = 1 << 3;
static constexpr const uint32_t WarningsAreErrors = 1 << 4;
static constexpr const uint32_t SimulateExclusiveFullscreen = 1 << 5;
static constexpr const uint32_t Is3DGameMode = 1 << 6;
static constexpr const uint32_t ShowFPS = 1 << 7;
static constexpr const uint32_t CaptureTitleBar = 1 << 10;
static constexpr const uint32_t AdjustCursorSpeed = 1 << 11;
static constexpr const uint32_t DrawCursor = 1 << 12;
static constexpr const uint32_t DisableDirectFlip = 1 << 13;
static constexpr const uint32_t DisableFontCache = 1 << 14;
static constexpr const uint32_t AllowScalingMaximized = 1 << 15;
static constexpr const uint32_t EnableStatisticsForDynamicDetection = 1 << 16;
static constexpr uint32_t DisableWindowResizing = 1;
static constexpr uint32_t BreakpointMode = 1 << 1;
static constexpr uint32_t DisableEffectCache = 1 << 2;
static constexpr uint32_t SaveEffectSources = 1 << 3;
static constexpr uint32_t WarningsAreErrors = 1 << 4;
static constexpr uint32_t SimulateExclusiveFullscreen = 1 << 5;
static constexpr uint32_t Is3DGameMode = 1 << 6;
static constexpr uint32_t ShowFPS = 1 << 7;
static constexpr uint32_t CaptureTitleBar = 1 << 10;
static constexpr uint32_t AdjustCursorSpeed = 1 << 11;
static constexpr uint32_t DrawCursor = 1 << 12;
static constexpr uint32_t DisableDirectFlip = 1 << 13;
static constexpr uint32_t DisableFontCache = 1 << 14;
static constexpr uint32_t AllowScalingMaximized = 1 << 15;
static constexpr uint32_t EnableStatisticsForDynamicDetection = 1 << 16;
};

enum class ScalingType {
Expand All @@ -54,8 +54,8 @@ enum class ScalingType {
};

struct EffectOptionFlags {
static constexpr const uint32_t InlineParams = 1;
static constexpr const uint32_t FP16 = 1 << 1;
static constexpr uint32_t InlineParams = 1;
static constexpr uint32_t FP16 = 1 << 1;
};

struct EffectOption {
Expand Down
2 changes: 1 addition & 1 deletion src/Magpie/ThemeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ThemeHelper::SetWindowTheme(HWND hWnd, bool darkBorder, bool darkMenu) noex
// 使标题栏适应黑暗模式
// build 18985 之前 DWMWA_USE_IMMERSIVE_DARK_MODE 的值不同
// https://github.com/MicrosoftDocs/sdk-api/pull/966/files
constexpr const DWORD DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
static constexpr DWORD DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19;
BOOL value = darkBorder;
DwmSetWindowAttribute(
hWnd,
Expand Down
3 changes: 1 addition & 2 deletions src/Magpie/XamlApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ XamlApp::XamlApp() {}
XamlApp::~XamlApp() {}

bool XamlApp::_CheckSingleInstance() noexcept {
static constexpr const wchar_t* SINGLE_INSTANCE_MUTEX_NAME = L"{4C416227-4A30-4A2F-8F23-8701544DD7D6}";
static constexpr const wchar_t* ELEVATED_MUTEX_NAME = L"{E494C456-F587-4DAF-B68F-366278D31C45}";

if (Win32Utils::IsProcessElevated()) {
Expand All @@ -189,7 +188,7 @@ bool XamlApp::_CheckSingleInstance() noexcept {

bool alreadyExists = false;
if (!_hSingleInstanceMutex.try_create(
SINGLE_INSTANCE_MUTEX_NAME,
CommonSharedConstants::SINGLE_INSTANCE_MUTEX_NAME,
CREATE_MUTEX_INITIAL_OWNER,
MUTEX_ALL_ACCESS,
nullptr,
Expand Down
16 changes: 10 additions & 6 deletions src/Shared/CommonSharedConstants.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once

struct CommonSharedConstants {
static constexpr const wchar_t* SINGLE_INSTANCE_MUTEX_NAME = L"{4C416227-4A30-4A2F-8F23-8701544DD7D6}";

static constexpr const wchar_t* MAIN_WINDOW_CLASS_NAME = L"Magpie_Main";
static constexpr const wchar_t* TITLE_BAR_WINDOW_CLASS_NAME = L"Magpie_TitleBar";
static constexpr const wchar_t* NOTIFY_ICON_WINDOW_CLASS_NAME = L"Magpie_NotifyIcon";
static constexpr const wchar_t* HOTKEY_WINDOW_CLASS_NAME = L"Magpie_Hotkey";
static constexpr const wchar_t* SCALING_WINDOW_CLASS_NAME = L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22";
static constexpr const wchar_t* DDF_WINDOW_CLASS_NAME = L"Window_Magpie_C322D752-C866-4630-91F5-32CB242A8930";

static constexpr const COLORREF LIGHT_TINT_COLOR = RGB(243, 243, 243);
static constexpr const COLORREF DARK_TINT_COLOR = RGB(32, 32, 32);
#ifndef NOGDI
static constexpr COLORREF LIGHT_TINT_COLOR = RGB(243, 243, 243);
static constexpr COLORREF DARK_TINT_COLOR = RGB(32, 32, 32);
#endif

static constexpr const char* LOG_PATH = "logs\\magpie.log";
static constexpr const wchar_t* CONFIG_DIR = L"config\\";
Expand All @@ -24,12 +28,12 @@ struct CommonSharedConstants {

#ifndef IDI_APP
// 来自 Magpie\resource.h
static constexpr const UINT IDI_APP = 101;
static constexpr UINT IDI_APP = 101;
#endif

static constexpr const UINT WM_NOTIFY_ICON = WM_USER;
static constexpr const UINT WM_QUIT_MAGPIE = WM_USER + 1;
static constexpr const UINT WM_RESTART_MAGPIE = WM_USER + 2;
static constexpr UINT WM_NOTIFY_ICON = WM_USER;
static constexpr UINT WM_QUIT_MAGPIE = WM_USER + 1;
static constexpr UINT WM_RESTART_MAGPIE = WM_USER + 2;

static constexpr const wchar_t* WM_MAGPIE_SHOWME = L"WM_MAGPIE_SHOWME";
static constexpr const wchar_t* WM_MAGPIE_QUIT = L"WM_MAGPIE_QUIT";
Expand Down
5 changes: 2 additions & 3 deletions src/Updater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Version.h"
#include "PackageFiles.h"
#include "Utils.h"
#include "../Shared/CommonSharedConstants.h"

// 将当前目录设为程序所在目录
static void SetWorkingDir() noexcept {
Expand All @@ -33,11 +34,9 @@ static void SetWorkingDir() noexcept {
}

static bool WaitForMagpieToExit() noexcept {
static constexpr const wchar_t* SINGLE_INSTANCE_MUTEX_NAME = L"{4C416227-4A30-4A2F-8F23-8701544DD7D6}";

{
wil::unique_mutex_nothrow hSingleInstanceMutex;
if (hSingleInstanceMutex.try_create(SINGLE_INSTANCE_MUTEX_NAME)) {
if (hSingleInstanceMutex.try_create(CommonSharedConstants::SINGLE_INSTANCE_MUTEX_NAME)) {
wil::handle_wait(hSingleInstanceMutex.get(), 10000);
}
}
Expand Down

0 comments on commit 669ef4d

Please sign in to comment.