#include "ButtonNextMainMenuSubScript.h" #include "MenusConfig.h" #include "ValueBroker.h" #include "manager/SaveManager.h" #include "../Config.h" #include #include using namespace crepe; using namespace std; void ButtonNextMainMenuSubScript::init() { IButtonScript::init(); this->subscribe([this](const ButtonPressEvent & e) { return this->on_button_press(e); }); } bool ButtonNextMainMenuSubScript::on_button_press(const ButtonPressEvent & e) { RefVector audios = this->get_components_by_name("background_music"); for (AudioSource & audio : audios) { audio.stop(); } SaveManager & savemgr = this->get_save_manager(); ValueBroker coins = savemgr.get(TOTAL_COINS_RUN, 0); ValueBroker coins_game = savemgr.get(TOTAL_COINS_GAME, 0); savemgr.set(TOTAL_COINS_GAME, coins_game.get() + coins.get()); ValueBroker distance = savemgr.get(DISTANCE_RUN, 0); ValueBroker distance_game = savemgr.get(DISTANCE_GAME, 0); if (distance.get() > distance_game.get()) savemgr.set(DISTANCE_GAME, distance.get()); this->set_next_scene(MAINMENU_SCENE); return false; }