Skip to content

Commit

Permalink
configure to mute overworld
Browse files Browse the repository at this point in the history
  • Loading branch information
tmarenko committed May 16, 2023
1 parent 3974202 commit 410635f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
language=eng
# how many wrong letters is allowed for Paimon's name. lesser value == more strict text recognition; default = 1 letter
ocr_max_errors=1
# also mute Paimon during her dialogues in overworld; default = 1 (mute on)
mute_overworld=1

[genshin_window_name]
genshin_chi_sim=原神
Expand Down
3 changes: 2 additions & 1 deletion source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ std::map<std::string, std::string> ParseConfig(const std::string &fileName) {
{"language", "eng"},
{"genshin_eng", "Genshin Impact"},
{"paimon_eng", "Paimon"},
{"ocr_max_errors", "1"}
{"ocr_max_errors", "1"},
{"mute_overworld", "1"}
};
std::ifstream file(fileName);
if (file.is_open()) {
Expand Down
14 changes: 10 additions & 4 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef struct GenshinWindowInfo {
std::wstring windowName = L"Genshin Impact";
std::wstring windowClass = L"UnityWndClass";
int maxOcrErrors = 1;
bool muteOverworld = true;
HWND hwnd = nullptr;
int width = 0;
int height = 0;
Expand Down Expand Up @@ -155,11 +156,15 @@ bool IsPaimonSpeaking(const std::string &paimonName) {
return false;

cv::Rect defaultDialoguePos = GetDialogueRect(frame.size(), "DEFAULT");
cv::Rect overworldDialoguePos = GetDialogueRect(frame.size(), "OVERWORLD");
std::string defaultDialogue = GetTextFromImageByRect(frame, defaultDialoguePos);
std::string overworldDialogue = GetTextFromImageByRect(frame, overworldDialoguePos);
return IsStringsSimilar(defaultDialogue, paimonName, gwi.maxOcrErrors) ||
IsStringsSimilar(overworldDialogue, paimonName, gwi.maxOcrErrors);

if (gwi.muteOverworld){
cv::Rect overworldDialoguePos = GetDialogueRect(frame.size(), "OVERWORLD");
std::string overworldDialogue = GetTextFromImageByRect(frame, overworldDialoguePos);
return IsStringsSimilar(defaultDialogue, paimonName, gwi.maxOcrErrors) ||
IsStringsSimilar(overworldDialogue, paimonName, gwi.maxOcrErrors);
}
return IsStringsSimilar(defaultDialogue, paimonName, gwi.maxOcrErrors);
}


Expand Down Expand Up @@ -239,6 +244,7 @@ int PaimonShutUp() {
return 1;

gwi.maxOcrErrors = std::stoi(configMap["ocr_max_errors"]);
gwi.muteOverworld = configMap["mute_overworld"] == "1";
std::string paimonName = configMap["paimon_" + configMap["language"]];
std::cout << "Waiting for GenshinImpact.exe process." << std::endl;
bool paimonWasHere = false;
Expand Down

0 comments on commit 410635f

Please sign in to comment.