Skip to content

Commit

Permalink
CommandHandler: Fixed issue with the !ToggleConfig bang
Browse files Browse the repository at this point in the history
071b6f7 made the second parameter of the ActivateConfig bang optional. ToggleConfig was never fixed to allow for this optional parameter. Also, if there was an error when activating, the wrong bang name was logged.
  • Loading branch information
brianferguson committed Aug 6, 2023
1 parent cadf1b4 commit 55b75a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
30 changes: 18 additions & 12 deletions Library/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,7 @@ std::vector<std::wstring> CommandHandler::ParseString(const WCHAR* str, ConfigPa

void CommandHandler::DoActivateSkinBang(std::vector<std::wstring>& args, Skin* skin)
{
if (args.size() == 1)
{
if (GetRainmeter().ActivateSkin(args[0])) return;
}
else if (args.size() > 1)
{
if (GetRainmeter().ActivateSkin(args[0], args[1])) return;
}

LogErrorF(skin, L"!ActivateConfig: Invalid parameters");
Internal_DoActivateBang(args, skin, L"ActivateConfig");
}

void CommandHandler::DoDeactivateSkinBang(std::vector<std::wstring>& args, Skin* skin)
Expand All @@ -683,7 +674,7 @@ void CommandHandler::DoDeactivateSkinBang(std::vector<std::wstring>& args, Skin*

void CommandHandler::DoToggleSkinBang(std::vector<std::wstring>& args, Skin* skin)
{
if (args.size() >= 2)
if (args.size() >= 1)
{
Skin* skin = GetRainmeter().GetSkin(args[0]);
if (skin)
Expand All @@ -693,7 +684,7 @@ void CommandHandler::DoToggleSkinBang(std::vector<std::wstring>& args, Skin* ski
}

// If the skin wasn't active, activate it.
DoActivateSkinBang(args, nullptr);
Internal_DoActivateBang(args, skin, L"ToggleConfig");
}
else
{
Expand Down Expand Up @@ -1091,3 +1082,18 @@ void CommandHandler::DoLsBoxHookBang(std::vector<std::wstring>& args, Skin* skin
{
// Deprecated.
}

void CommandHandler::Internal_DoActivateBang(std::vector<std::wstring>& args, Skin* skin, LPCWSTR bangName)
{
// References: CommandHandler::DoActivateSkinBang, CommandHandler::DoToggleSkinBang
if (args.size() == 1)
{
if (GetRainmeter().ActivateSkin(args[0])) return;
}
else if (args.size() > 1)
{
if (GetRainmeter().ActivateSkin(args[0], args[1])) return;
}

LogErrorF(skin, L"!%s: Invalid parameters", bangName);
}
3 changes: 3 additions & 0 deletions Library/CommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class CommandHandler
static void DoSetWindowPositionBang(std::vector<std::wstring>& args, Skin* skin);

static void DoLsBoxHookBang(std::vector<std::wstring>& args, Skin* skin);

private:
static void Internal_DoActivateBang(std::vector<std::wstring>& args, Skin* skin, LPCWSTR bangName);
};

#endif

0 comments on commit 55b75a8

Please sign in to comment.