Skip to content

Commit

Permalink
Install filter no longer removes all consoles on older versions of …
Browse files Browse the repository at this point in the history
…Onion
  • Loading branch information
Aemiii91 committed Jul 14, 2022
1 parent c116087 commit 9619109
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.PHONY: clean

TARGET=SearchFilter
VERSION=1.2
VERSION=1.2.1

###########################################################

Expand Down
37 changes: 25 additions & 12 deletions src/common/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,33 @@ struct ConfigEmu
return config;
}

string toJson(void)
string toJson(bool new_lines = true)
{
string json_str = "{";
json_str += "\"label\":\"" + label + "\",";
json_str += "\"icon\":\"" + icon + "\",";
json_str += "\"iconsel\":\"" + iconsel + "\",";
json_str += "\"launch\":\"" + launch + "\",";
json_str += "\"rompath\":\"" + rompath + "\",";
json_str += "\"imgpath\":\"" + imgpath + "\",";
json_str += "\"gamelist\":\"" + gamelist + "\",";
json_str += "\"useswap\":" + to_string(useswap) + ",";
json_str += "\"shortname\":" + to_string(shortname) + ",";
json_str += "\"hidebios\":" + to_string(hidebios) + ",";
json_str += "\"extlist\":\"" + extlist + "\"";

auto addLine = [&json_str, new_lines](string key, string value,
bool is_number = false,
bool remove_empty = false,
bool is_last = false) {
if (value.length() == 0 && remove_empty)
return;
json_str += wrapQuotes(key) + ":" + (is_number ? value : wrapQuotes(value));
if (!is_last) json_str += ",";
if (new_lines) json_str += "\n";
};

addLine("label", label);
addLine("icon", icon);
addLine("iconsel", iconsel, false, true);
addLine("launch", launch);
addLine("rompath", rompath);
addLine("imgpath", imgpath);
addLine("gamelist", gamelist, false, true);
addLine("useswap", to_string(useswap), true);
addLine("shortname", to_string(shortname), true);
addLine("hidebios", to_string(hidebios), true);
addLine("extlist", extlist, false, false, true);

json_str += "}";
return json_str;
}
Expand Down
4 changes: 4 additions & 0 deletions src/common/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ string trim(const string &s) {
return rtrim(ltrim(s));
}

string wrapQuotes(const string &s, const string quote_char = "\"") {
return quote_char + s + quote_char;
}

string dirname(string path)
{
int pos = path.find_last_of("/");
Expand Down

0 comments on commit 9619109

Please sign in to comment.