Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/kuroni/bongocat-osu
Browse files Browse the repository at this point in the history
  • Loading branch information
kuroni committed Jul 18, 2020
2 parents 10c74dd + b03c2a6 commit 427d626
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ Supported operating system:

_Notice_: If you're using WINE on Linux, make sure that osu! and this application run in the same `WINEPREFIX`.

## Todo
* Support other modes.
* Optimize further for consistency and speed.
* Allow even more customizations.

## For developers
This project uses [SFML](https://www.sfml-dev.org/index.php) and [JsonCpp](https://github.com/open-source-parsers/jsoncpp). JsonCpp libraries are directly included in the source using the provided `amalgamation.py` from the developers.

Expand All @@ -42,3 +37,5 @@ make test
```

Alternatively, you can copy the newly-compiled `bin/bongocat.exe` into the base directory and execute it.

If you have troubles compiling, it can be due to version mismatch between your compiler and SFML. See [#43](https://github.com/kuroni/bongocat-osu/issues/43) for more information.
1 change: 1 addition & 0 deletions src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void create_config() {
},
"osu": {
"mouse": true,
"toggleSmoke": false,
"paw": [255, 255, 255],
"pawEdge": [0, 0, 0],
"key1": [90],
Expand Down
30 changes: 27 additions & 3 deletions src/osu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ int horizontal, vertical;
int paw_r, paw_g, paw_b;
int paw_edge_r, paw_edge_g, paw_edge_b;
double scale;
bool is_mouse, is_letterbox, is_left_handed;
bool is_mouse, is_letterbox, is_left_handed, is_enable_toggle_smoke;
sf::Sprite bg, up, left, right, device, smoke, wave;

int key_state = 0;
bool left_key_state = false;
bool right_key_state = false;
bool wave_key_state = false;
bool previous_smoke_key_state = false;
bool current_smoke_key_state = false;
bool is_toggle_smoke = false;
double timer_left_key = -1;
double timer_right_key = -1;
double timer_wave_key = -1;
Expand All @@ -40,6 +43,7 @@ bool init() {
Json::Value osu = data::cfg["osu"];

is_mouse = osu["mouse"].asBool();
is_enable_toggle_smoke = osu["toggleSmoke"].asBool();

paw_r = osu["paw"][0].asInt();
paw_g = osu["paw"][1].asInt();
Expand Down Expand Up @@ -401,12 +405,32 @@ void draw() {
window.draw(device);
}

// drawing smoke
// draw smoke
bool is_smoke_key_pressed = false;

for (Json::Value &v : smoke_key_value) {
if (GetKeyState(v.asInt()) & WM_KEYDOWN) {
window.draw(smoke);
is_smoke_key_pressed = true;
break;
}
}

if (is_enable_toggle_smoke) {
previous_smoke_key_state = current_smoke_key_state;
current_smoke_key_state = is_smoke_key_pressed;

bool is_smoke_key_down = current_smoke_key_state && (current_smoke_key_state != previous_smoke_key_state);

if (is_smoke_key_down) {
is_toggle_smoke = !is_toggle_smoke;
}
}
else {
is_toggle_smoke = is_smoke_key_pressed;
}

if (is_toggle_smoke) {
window.draw(smoke);
}
}
}; // namespace osu

0 comments on commit 427d626

Please sign in to comment.