55#include " recorder_layer.hpp"
66#include " nodes.hpp"
77#include " version.hpp"
8+ #include < filesystem>
89
910bool OverlayLayer::init () {
1011 if (!initWithColor ({ 0 , 0 , 0 , 105 })) return false ;
@@ -209,16 +210,22 @@ void OverlayLayer::_update_default_fps() {
209210}
210211
211212void OverlayLayer::FLAlert_Clicked (gd::FLAlertLayer* alert, bool btn2) {
212- if (!btn2) {
213- auto & rs = ReplaySystem::get ();
214- int tag = alert->getTag ();
215- if (tag == 1 ) {
216- rs.toggle_recording ();
213+ if (alert->getTag () == 1 ) {
214+ if (!btn2) {
215+ CCApplication::sharedApplication ()->openURL (" https://www.gyan.dev/ffmpeg/builds/" );
216+ }
217+ } else {
218+ if (!btn2) {
219+ auto & rs = ReplaySystem::get ();
220+ int tag = alert->getTag ();
221+ if (tag == 1 ) {
222+ rs.toggle_recording ();
223+ update_info_text ();
224+ } else if (tag == 2 ) {
225+ _handle_load_replay ();
226+ }
217227 update_info_text ();
218- } else if (tag == 2 ) {
219- _handle_load_replay ();
220228 }
221- update_info_text ();
222229 }
223230}
224231
@@ -317,14 +324,28 @@ void OverlayLayer::on_toggle_showcase(CCObject* toggle_) {
317324void OverlayLayer::on_recorder (CCObject*) {
318325 static bool has_ffmpeg = false ;
319326 if (!has_ffmpeg) {
320- // theres prob a way to do it by not spawning a process but im lazy and hate dealing with winapi
321- auto process = subprocess::Popen (" where ffmpeg" );
322- if (process.close ())
323- gd::FLAlertLayer::create (nullptr , " Error" , " Ok" , nullptr , " ffmpeg was not found in your path, recorder will not work without it" )->show ();
324- else
327+ char buffer[MAX_PATH];
328+ GetModuleFileNameA (GetModuleHandleA (NULL ), buffer, MAX_PATH);
329+ const auto path = std::filesystem::path (buffer).parent_path () / " ffmpeg.exe" ;
330+ if (std::filesystem::exists (path)) {
325331 has_ffmpeg = true ;
326- if (!has_ffmpeg)
327- return ;
332+ ReplaySystem::get ().recorder .m_ffmpeg_path = path.string ();
333+ } else {
334+ // theres prob a way to do it by not spawning a process but im lazy and hate dealing with winapi
335+ auto process = subprocess::Popen (" where ffmpeg" );
336+ if (process.close ()) {
337+ auto popup = gd::FLAlertLayer::create (this , " Error" ,
338+ " Download" , " Cancel" ,
339+ " ffmpeg was not found, recorder will not work without it. "
340+ " To install ffmpeg download it and place the ffmpeg.exe (found inside the bin folder in the zip) in the gd folder"
341+ );
342+ popup->setTag (1 );
343+ popup->show ();
344+ } else
345+ has_ffmpeg = true ;
346+ if (!has_ffmpeg)
347+ return ;
348+ }
328349 }
329350 RecorderLayer::create ()->show ();
330351}
0 commit comments