From 167c9769e166147be6a69749be8209ce4515f811 Mon Sep 17 00:00:00 2001 From: TobyAdd <66429886+TobyAdd@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:04:42 +0200 Subject: [PATCH] pizdec(); --- src/gui_mobile.cpp | 55 ++++++++++++++++++++++++++++++++++++++-------- src/utils.cpp | 26 +--------------------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/gui_mobile.cpp b/src/gui_mobile.cpp index 9227b93..14dddcd 100644 --- a/src/gui_mobile.cpp +++ b/src/gui_mobile.cpp @@ -202,14 +202,22 @@ bool HacksLayer::setup() { auto engineTab = CCMenu::create(); engineTab->setContentSize({325, 210}); - record_toggle = CCMenuItemExt::createTogglerWithStandardSprites(0.75f, [this, &config, &engine](CCMenuItemToggler* sender) { + auto info_label = CCLabelBMFont::create(fmt::format("Frame: {}\nReplay Size: {}", engine.get_frame(), engine.get_actions_size()).c_str(), "chatFont.fnt"); + info_label->setAnchorPoint({0.f, 0.5f}); + info_label->setPosition({8, 15}); + info_label->setScale(0.5f); + engineTab->addChild(info_label); + + record_toggle = CCMenuItemExt::createTogglerWithStandardSprites(0.75f, [this, &config, &engine, info_label](CCMenuItemToggler* sender) { play_toggle->toggle(false); if (!sender->isOn()) { bool canRecord = (!engine.engine_v2 && config.get("tps_enabled", false)) || (engine.engine_v2 && !config.get("tps_enabled", false)); if (canRecord) { + engine.clear(); engine.mode = state::record; + info_label->setString(fmt::format("Frame: {}\nReplay Size: {}/{}", engine.get_frame(), engine.get_current_index(), engine.get_actions_size()).c_str()); } else { @@ -272,12 +280,6 @@ bool HacksLayer::setup() { replayListClick->setPosition({255.f, 155.f}); engineTab->addChild(replayListClick); - auto info_label = CCLabelBMFont::create(fmt::format("Frame: {}\nReplay Size: {}", engine.get_frame(), engine.get_actions_size()).c_str(), "chatFont.fnt"); - info_label->setAnchorPoint({0.f, 0.5f}); - info_label->setPosition({8, 15}); - info_label->setScale(0.5f); - engineTab->addChild(info_label); - auto saveButton = ButtonSprite::create("Save", 40, true, "bigFont.fnt", "GJ_button_01.png", 30.f, 0.7f); auto saveButtonClick = CCMenuItemExt::createSpriteExtra(saveButton, [this, &engine, info_label](CCMenuItemSpriteExtra* sender) { FLAlertLayer::create("Info", engine.save(engine.replay_name).c_str(), "OK")->show(); @@ -288,7 +290,7 @@ bool HacksLayer::setup() { auto loadButton = ButtonSprite::create("Load", 40, true, "bigFont.fnt", "GJ_button_01.png", 30.f, 0.7f); auto loadButtonClick = CCMenuItemExt::createSpriteExtra(loadButton, [this, &engine, info_label](CCMenuItemSpriteExtra* sender) { FLAlertLayer::create("Info", engine.load(engine.replay_name).c_str(), "OK")->show(); - info_label->setString(fmt::format("Frame: {}\nReplay Size: {}", engine.get_frame(), engine.get_actions_size()).c_str()); + info_label->setString(fmt::format("Frame: {}\nReplay Size: {}/{}", engine.get_frame(), engine.get_current_index(), engine.get_actions_size()).c_str()); }); loadButtonClick->setPosition({95, 120}); engineTab->addChild(loadButtonClick); @@ -334,8 +336,43 @@ bool HacksLayer::setup() { engineTab->addChild(engineV2_label); auto justATestButton = ButtonSprite::create("Just a test", 80, true, "bigFont.fnt", "GJ_button_01.png", 30.f, 0.7f); - auto justATestButtonClick = CCMenuItemExt::createSpriteExtra(justATestButton, [this, &engine, info_label](CCMenuItemSpriteExtra* sender) { + auto justATestButtonClick = CCMenuItemExt::createSpriteExtra(justATestButton, [this](CCMenuItemSpriteExtra* sender) { + auto& recorder = Recorder::get(); + if (recorder.is_recording) { + recorder.stop(); + FLAlertLayer::create("Recorder", "Recording stopped!", "OK")->show(); + } + + geode::utils::file::pick(geode::utils::file::PickMode::OpenFolder, {std::nullopt, {}}).listen( + [&](geode::Result* path) { + if (!path->isErr()) { + auto path_final = path->unwrap(); + auto pl = PlayLayer::get(); + if (pl) { + recorder.folderShowcasesPath = path_final; + + recorder.video_name = pl->m_level->m_levelName + ".flvc"; + + auto size = CCEGLView::get()->getFrameSize(); + recorder.width = size.width; + recorder.height = size.height; + + if (!recorder.is_recording) { + recorder.start(""); + FLAlertLayer::create("Recorder", fmt::format("Recording started!\nFilename: {}\nPath {}\nSize: {}x{}\nFPS: {}", + recorder.video_name, recorder.folderShowcasesPath, recorder.width, recorder.height, recorder.fps).c_str(), "OK")->show(); + } + + } + else { + FLAlertLayer::create("Recorder", "Not in PlayLayer", "OK")->show(); + } + } + else { + FLAlertLayer::create("Recorder", "Not selected directory", "OK")->show(); + } + }); }); justATestButtonClick->setPosition({270, 25}); engineTab->addChild(justATestButtonClick); diff --git a/src/utils.cpp b/src/utils.cpp index 9da6bc8..b89fbbe 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -242,28 +242,4 @@ std::string utilsH::GetKeyName(int key) { default: return "Unknown"; } } -#endif - - -void utilsH::getFolder() { - geode::utils::file::pick(geode::utils::file::PickMode::OpenFolder, {std::nullopt, {}}).listen( - [](geode::Result* path) { - if (!path->isErr()) { - auto path_final = path->unwrap(); - geode::log::debug("{}", path_final); - std::ofstream outFile(path_final / "replay_engine.txt"); - - if (outFile.is_open()) { - outFile << "Hello, this is a text file saved by C++!" << std::endl; - outFile.close(); - - FLAlertLayer::create("Info", fmt::format("Saved as {}", path_final / "replay_engine.txt"), "OK")->show(); - } else { - FLAlertLayer::create("Info", fmt::format("Error openning file"), "OK")->show(); - } - } - else { - FLAlertLayer::create("info", "goddamn??", "OK")->show(); - } - }); -} \ No newline at end of file +#endif \ No newline at end of file