Skip to content

Commit

Permalink
common event support, more switch support, json support
Browse files Browse the repository at this point in the history
yet another large refactor (kill me)
add .json output support via '.json' filename
add support for scripts in if statements
add support for finding $gameSwitches for script commands or queries
add support for searching common events
add support for scraping common event triggers for switch usages
fix crash on if statement using switches
fix missing logic for switches when printing results
  • Loading branch information
nithax committed Apr 8, 2021
1 parent 7ce8f0a commit a49eba3
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 118 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ list references to variable id '24' and store the results in 'var_24.txt'
> `RPGMakerScraper -v 24 var_24.txt`
list references to switch id '27'
> `RPGMakerScaper -s 27`
> `RPGMakerScraper -s 27`
list references to variable id '79' and output as .json
> `RPGMakerScraper -v 79 var_79.json`
it's that easy.

Expand Down
25 changes: 20 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

using colors = logger::console_colors;

bool string_ends_with(std::string str, std::string suffix) {
return str.size() >= suffix.size() &&
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
}

void print_usage() {
log_colored(colors::RED, colors::BLACK,
"incorrect usage - please use the program like so:\n"
"RPGMakerScraper -v 143 test_output.txt\n"
"RPGMakerScraper -s 21");
"RPGMakerScraper -s 21\n"
"RPGMakerScraper -s 714 test_output.json");
}

int main(int argc, const char *argv[]) {
Expand All @@ -18,6 +24,7 @@ int main(int argc, const char *argv[]) {

constexpr const char *search_type_variables = "-v";
constexpr const char *search_type_switches = "-s";
constexpr const char *as_json = ".json";

// check the argument count
if (argc < expected_minimum_argc) {
Expand Down Expand Up @@ -74,19 +81,27 @@ int main(int argc, const char *argv[]) {
throw std::invalid_argument(R"(unable to create output file)");
}

file << scraper;
file.close();
if (string_ends_with(file_name, as_json)) {

log_info(R"(writing results as json..)");

if (scraper->output_json()) {
file << *scraper->output_json();
}
} else {
file << scraper;
file.close();
}

log_ok(R"(results wrote successfully.)");
}
}

} catch (const std::exception &e) {
log_err(R"(exception caught: %s)", e.what());
}

log_nopre("\n");
log_ok(R"(press any key to close the program...)");
log_ok(R"(press enter to close the program...)");

std::cin.get();
return 0;
Expand Down
Loading

0 comments on commit a49eba3

Please sign in to comment.