Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienML committed Apr 16, 2024
1 parent c0d7901 commit 7f3bcac
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 276 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vs/
.vscode/
build/
build/
README BakkesPlugins.md
190 changes: 100 additions & 90 deletions BetterChat.cpp

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions BetterChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string>
constexpr auto plugin_version = stringify(VERSION_MAJOR) "." stringify(VERSION_MINOR) "." stringify(VERSION_PATCH) "." stringify(VERSION_BUILD);


class BetterChat: public BakkesMod::Plugin::BakkesModPlugin, public BakkesMod::Plugin::PluginSettingsWindow
{
// Quickchats id <=> Quickchats texts
Expand Down Expand Up @@ -74,12 +73,12 @@ class BetterChat: public BakkesMod::Plugin::BakkesModPlugin, public BakkesMod::P
};

//Functions
void resetBlacklist();

void resetWhitelist();

void jsonFileExists();
std::set<std::string> readJson(std::string category);
bool addToJson(std::string category, std::string idMsg);
bool removeFromJson(std::string category, std::string idMsg);
std::map<std::string, bool> readJson(std::string category);
void toggleQuickchatInJson(std::string category, std::string idMsg);

virtual void onLoad();
virtual void onUnload();
Expand Down
291 changes: 117 additions & 174 deletions BetterChatGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,24 @@ void BetterChat::RenderSettings() {
if (!toxicityScoreYCvar) { return; }
int toxicityScoreY = toxicityScoreYCvar.getIntValue();

list<string> categories = {"quickchats" , "default", "beforeKickoff", "afterAlliedGoal", "afterEnemyGoal", "afterPass", "afterSave"};

map<string, bool> defaultCheck = readJson("default");
map<string, bool> beforeKickoffCheck = readJson("beforeKickoff");
map<string, bool> afterAlliedGoalCheck = readJson("afterAlliedGoal");
map<string, bool> afterEnemyGoalCheck = readJson("afterEnemyGoal");
map<string, bool> afterPassCheck = readJson("afterPass");
map<string, bool> afterSaveCheck = readJson("afterSave");

map<string, map<string, bool>> maps = { {"default", defaultCheck}, {"beforeKickoff", beforeKickoffCheck}, { "afterAlliedGoal", afterAlliedGoalCheck }, {"afterEnemyGoal", afterEnemyGoalCheck}, {"afterPass", afterPassCheck}, {"afterSave", afterSaveCheck} };

if (enabled) {
ImGui::Text("\n");

/*if (ImGui::BeginTabBar("tabBar")) {
if (ImGui::BeginTabItem("1v1")) {*/
ImGui::PushID("1v1");

// AntiSpam button
if (ImGui::Checkbox("AntiSpam", &antiSpam)) {
antiSpamCvar.setValue(antiSpam);
Expand Down Expand Up @@ -112,197 +127,111 @@ void BetterChat::RenderSettings() {

if (chatFilter) {
ImGui::Text("\n");

ImGui::BeginChild("Quickchats", ImVec2(755, 450), true, ImGuiWindowFlags_MenuBar); ;
if (ImGui::BeginMenuBar())
{
ImGui::Text("Configuration");
ImGui::EndMenuBar();
}

// 1st header
ImGui::Columns(2, nullptr);

ImGui::Separator();
ImGui::Text("These quickchats are");
ImGui::SetColumnWidth(-1, 165);
ImGui::NextColumn();
ImGui::Text("Except in these situations:");
ImGui::SetColumnWidth(-1, 825);
ImGui::NextColumn();

// 2nd header
ImGui::Columns(6, nullptr);

ImGui::Text("forbidden:");
ImGui::SetColumnWidth(-1, 165);
float headerOffsetX;
float headerOffsetY = ImGui::GetTextLineHeight() * 0.5f + 2;

ImGui::Columns(7, nullptr);

ImGui::SetColumnWidth(-1, 150);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("Quickchats").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + headerOffsetY);
ImGui::Text("Quickchats");
ImGui::NextColumn();
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("Default").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + headerOffsetY);
ImGui::Text("Default");
ImGui::NextColumn();
ImGui::Text("Before kickoff:");
ImGui::SetColumnWidth(-1, 165);
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("Before kickoff").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + headerOffsetY);
ImGui::Text("Before kickoff");
ImGui::NextColumn();
ImGui::Text("After an allied goal:");
ImGui::SetColumnWidth(-1, 165);
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("After an allied").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::Text("After an allied");
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("goal").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::Text("goal");
ImGui::NextColumn();
ImGui::Text("After an enemy goal:");
ImGui::SetColumnWidth(-1, 165);
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("After an enemy").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::Text("After an enemy");
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("goal").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::Text("goal");
ImGui::NextColumn();
ImGui::Text("After an assist:");
ImGui::SetColumnWidth(-1, 165);
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("After an assist").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + headerOffsetY);
ImGui::Text("After an assist");
ImGui::NextColumn();
ImGui::Text("After a save:");
ImGui::SetColumnWidth(-1, 165);
ImGui::SetColumnWidth(-1, 100);
headerOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize("After a save").x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + headerOffsetX - 6);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + headerOffsetY);
ImGui::Text("After a save");
ImGui::NextColumn();
ImGui::Separator();

// Default

map<string, bool> defaultMsgCheck;
set<string> defaultMsg = readJson("default");
for (const auto& pair : BetterChat::idQuickchats) {
const string& id = pair.first;
bool check = defaultMsg.find(id) != defaultMsg.end();
defaultMsgCheck.emplace(id, check);
}

ImGui::PushID("defaultColumn");
for (const auto& pair : defaultMsgCheck) {
const string msg = pair.first;
bool defaultCheckbox = defaultMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &defaultCheckbox)) {
if (defaultCheckbox) {
addToJson("default", msg);
}
else {
removeFromJson("default", msg);
}
resetBlacklist();
}
}
ImGui::PopID();
ImGui::NextColumn();

// Before kick-off

map<string, bool> beforeKickoffMsgCheck;
set<string> beforeKickoffMsg = readJson("beforeKickoff");
for (const string& id : defaultMsg) {
bool check = beforeKickoffMsg.find(id) != beforeKickoffMsg.end();
beforeKickoffMsgCheck.emplace(id, check);
}

ImGui::PushID("beforeKickoffColumn");
for (const auto& pair : beforeKickoffMsgCheck) {
const string msg = pair.first;
bool checkbox = beforeKickoffMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &checkbox)) {
if (checkbox) {
addToJson("beforeKickoff", msg);
}
else {
removeFromJson("beforeKickoff", msg);
}
}
}
ImGui::PopID();
ImGui::NextColumn();

// After an allied goal

map<string, bool> afterAlliedGoalMsgCheck;
set<string> afterAlliedGoalMsg = readJson("afterAlliedGoal");
for (const string& id : defaultMsg) {
bool check = afterAlliedGoalMsg.find(id) != afterAlliedGoalMsg.end();
afterAlliedGoalMsgCheck.emplace(id, check);
}

ImGui::PushID("afterAlliedGoalColumn");
for (const auto& pair : afterAlliedGoalMsgCheck) {
const string msg = pair.first;
bool checkbox = afterAlliedGoalMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &checkbox)) {
if (checkbox) {
addToJson("afterAlliedGoal", msg);
}
else {
removeFromJson("afterAlliedGoal", msg);
}
}
}
ImGui::PopID();
ImGui::NextColumn();

// After an enemy goal

map<string, bool> afterEnemyGoalMsgCheck;
set<string> afterEnemyGoalMsg = readJson("afterEnemyGoal");
for (const string& id : defaultMsg) {
bool check = afterEnemyGoalMsg.find(id) != afterEnemyGoalMsg.end();
afterEnemyGoalMsgCheck.emplace(id, check);
}

ImGui::PushID("afterEnemyGoalColumn");
for (const auto& pair : afterEnemyGoalMsgCheck) {
const string msg = pair.first;
bool checkbox = afterEnemyGoalMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &checkbox)) {
if (checkbox) {
addToJson("afterEnemyGoal", msg);
}
else {
removeFromJson("afterEnemyGoal", msg);
}
}
}
ImGui::PopID();
ImGui::NextColumn();

// After an assist

map<string, bool> afterPassMsgCheck;
set<string> afterPassMsg = readJson("afterPass");
for (const string& id : defaultMsg) {
bool check = afterPassMsg.find(id) != afterPassMsg.end();
afterPassMsgCheck.emplace(id, check);
}

ImGui::PushID("afterPassColumn");
for (const auto& pair : afterPassMsgCheck) {
const string msg = pair.first;
bool checkbox = afterPassMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &checkbox)) {
if (checkbox) {
addToJson("afterPass", msg);
for (const auto& chat : idQuickchats) {
for (const string column : categories) {
ImGui::PushID(column.c_str());
if (column == "quickchats") {
float textOffsetX = (ImGui::GetColumnWidth() - ImGui::CalcTextSize(chat.second.c_str()).x) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + textOffsetX - 6);
ImGui::Text(chat.second.c_str());
}
else {
removeFromJson("afterPass", msg);
const string msg = chat.first;
map<string, bool> map = maps[column];
bool check = map[msg];
string btn = check ? "Allowed" : "Forbidden";
if (check) {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.8f, 0.2f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.3f, 0.9f, 0.3f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.1f, 0.7f, 0.1f, 1.0f));
}
else {
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.2f, 0.2f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.9f, 0.3f, 0.3f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.7f, 0.1f, 0.1f, 1.0f));
}

ImGui::PushID(msg.c_str());
float btnOffsetX = (ImGui::GetColumnWidth() - 80) * 0.5f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + btnOffsetX - 6);
if (ImGui::Button(btn.c_str(), ImVec2(80, 18))) {
toggleQuickchatInJson(column, msg);
resetWhitelist();
}
ImGui::PopID();
ImGui::PopStyleColor(3);
}
ImGui::PopID();
ImGui::NextColumn();
}
}
ImGui::PopID();
ImGui::NextColumn();

// After a save

map<string, bool> afterSaveMsgCheck;
set<string> afterSaveMsg = readJson("afterSave");
for (const string& id : defaultMsg) {
bool check = afterSaveMsg.find(id) != afterSaveMsg.end();
afterSaveMsgCheck.emplace(id, check);
}

ImGui::PushID("afterSaveColumn");
for (const auto& pair : afterSaveMsgCheck) {
const string msg = pair.first;
bool checkbox = afterSaveMsgCheck[msg];
if (ImGui::Checkbox(BetterChat::idQuickchats[msg].c_str(), &checkbox)) {
if (checkbox) {
addToJson("afterSave", msg);
}
else {
removeFromJson("afterSave", msg);
}
}
}
ImGui::PopID();
ImGui::NextColumn();
ImGui::Separator();
ImGui::EndChild();
//ImGui::Separator();
ImGui::Columns(1, nullptr);

if (ImGui::Button("Reset table")) {
string path = gameWrapper->GetDataFolder().string() + "/BetterChat_Blacklist.json";
string path = gameWrapper->GetDataFolder().string() + "/BetterChat_config.json";
remove(path.c_str());
jsonFileExists();
}
Expand Down Expand Up @@ -342,5 +271,19 @@ void BetterChat::RenderSettings() {
}
}
}
ImGui::PopID();
/*ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("2v2")) {
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("3v3")) {
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}*/
}
}
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ In the Anti-Spam section, you can set the delay between two identical quickchat
| :-------------: |:-------------:|
| ![Gif3](https://user-images.githubusercontent.com/108280870/297386506-b0152ce6-dd2c-41ab-b528-f302037bab8c.gif) | ![Gif4](https://user-images.githubusercontent.com/108280870/297386316-dc14da4c-5fab-49f0-ae75-6e4aec44fe33.gif) |

In the Message Filter section, you can disallow the quickchat you want by checking them in the first column on the table.
In the Message Filter section, you can allow/disallow the quickchat you want at the moment you want by pressing the corresponding button:

Once you check a quickchat, it appears in the other columns, which correspond to different events in the game. In this way, you can allow quickchat only for certain events (for exemple, you can authorize the 'What a save!' quickchat only after a save).

![Menu3](https://github.com/JulienML/BetterChat/assets/108280870/55e854ac-9a82-45db-87f8-a2130453f0f2)
![Menu3](https://github.com/JulienML/BetterChat/assets/108280870/12da1a67-6017-4221-8529-1a4e5d4140c8)

At the bottom, you can configure the position of the toxicity scores at the end of the game:

Expand Down
Binary file modified plugins/BetterChat.dll
Binary file not shown.
Binary file modified plugins/BetterChat.exp
Binary file not shown.
Binary file modified plugins/BetterChat.lib
Binary file not shown.
Binary file modified plugins/BetterChat.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#define VERSION_MAJOR 1
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_PATCH 0
#define VERSION_BUILD 106
#define VERSION_BUILD 199

#define stringify(a) stringify_(a)
#define stringify_(a) #a
Expand Down

0 comments on commit 7f3bcac

Please sign in to comment.