Skip to content

Commit

Permalink
Switch - Disable chat notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
FlavioFS committed Feb 25, 2023
1 parent 4d8bb1a commit bede4e8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions ParsecSoda/MetadataCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ MetadataCache::Preferences MetadataCache::loadPreferences()
tryLoadBool("buttonLock.leftStick", preferences.buttonLock.leftStick, false);
tryLoadBool("buttonLock.rightStick", preferences.buttonLock.rightStick, false);
tryLoadBool("buttonLock.isEnabled", preferences.buttonLock.isEnabled, false);
tryLoadBool("enableNotifications", preferences.enableNotifications, true);

preferences.isValid = true;

Expand Down Expand Up @@ -236,6 +237,7 @@ bool MetadataCache::savePreferences(MetadataCache::Preferences preferences)
MTY_JSONObjSetBool(json, "buttonLock.leftStick", preferences.buttonLock.leftStick);
MTY_JSONObjSetBool(json, "buttonLock.rightStick", preferences.buttonLock.rightStick);
MTY_JSONObjSetBool(json, "buttonLock.isEnabled", preferences.buttonLock.isEnabled);
MTY_JSONObjSetBool(json, "enableNotifications", preferences.enableNotifications);

MTY_JSONWriteFile(filepath.c_str(), json);
MTY_JSONDestroy(&json);
Expand Down
1 change: 1 addition & 0 deletions ParsecSoda/MetadataCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MetadataCache
bool defaultMultitapValue = false;
bool defaultMirrorValue = false;
ButtonLock buttonLock;
bool enableNotifications = true;
};

static SessionCache loadSessionCache();
Expand Down
31 changes: 30 additions & 1 deletion ParsecSoda/Widgets/ChatWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool ChatWidget::render()
}
_messageCount = messages.size();

if (_onMessageCallback != nullptr)
if (MetadataCache::preferences.enableNotifications && _onMessageCallback != nullptr)
{
_onMessageCallback();
}
Expand Down Expand Up @@ -187,6 +187,12 @@ bool ChatWidget::renderTopBar(bool& isWindowLocked, bool& isClearChat)
ImGui::EndGroup();
}

ImGui::SameLine();

IconButton::render(AppIcons::cog, AppColors::primary, ImVec2(30, 30), "###Chat settings button");
TitleTooltipWidget::render("Chat Settings", "Press to open Chat Settings menu.");
renderOptionsMenu();

ImGui::SameLine();
cursor = ImGui::GetCursorPos();
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 40);
Expand Down Expand Up @@ -264,4 +270,27 @@ void ChatWidget::toClipboard(const string& message)
SetClipboardData(CF_TEXT, hg);
CloseClipboard();
GlobalFree(hg);
}


void ChatWidget::renderOptionsMenu()
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10));

if (ImGui::BeginPopupContextItem("Gamepad Options", ImGuiPopupFlags_MouseButtonLeft))
{
if (SwitchWidget::render(
MetadataCache::preferences.enableNotifications,
"###Enable notifications switch", "Enable notifications",
"Chat notifications [ON]", "Parsec Soda will blink in taskbar when new chat messages arrive.",
"Chat notifications [OFF]", "Parsec Soda will not notify when new messages arrive."
))
{
MetadataCache::savePreferences();
}

ImGui::EndPopup();
}

ImGui::PopStyleVar();
}
2 changes: 2 additions & 0 deletions ParsecSoda/Widgets/ChatWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../Hosting.h"
#include "../Stopwatch.h"
#include <functional>
#include "SwitchWidget.h"

class ChatWidget
{
Expand All @@ -22,6 +23,7 @@ class ChatWidget

private:
bool renderTopBar(bool& isWindowLocked, bool& isClearChat);
void renderOptionsMenu();

bool isDirty();
void sendMessage();
Expand Down
5 changes: 0 additions & 5 deletions ParsecSoda/Widgets/GamepadsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,6 @@ void GamepadsWidget::renderTopBar(bool& isWindowLocked, const ImVec2& windowSize

ImGui::SameLine();

ImGui::BeginPopupContextItem(NULL, ImGuiPopupFlags_MouseButtonRight);

ImGui::SameLine();


IconButton::render(AppIcons::cog, AppColors::primary, buttonSize, "###Gamepad settings button");
TitleTooltipWidget::render("Gamepad Settings", "Press to open Gamepad Settings menu.");
renderOptionsMenu();
Expand Down
2 changes: 1 addition & 1 deletion ParsecSoda/Widgets/VersionWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool VersionWidget::render()
ImGui::SetNextWindowSize(ImVec2(100, 32));
ImGui::Begin("##Version", (bool*)0, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
AppStyle::pushLabel();
ImGui::Text("v. 1.2.1");
ImGui::Text("v. 1.2.2");
AppStyle::pop();
ImGui::End();

Expand Down

0 comments on commit bede4e8

Please sign in to comment.