Skip to content

Commit

Permalink
final wchar fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Feb 3, 2024
1 parent 5be1402 commit 2f70c2f
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/ui/nong_add_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Geode/cocos/CCDirector.h"
#include "Geode/cocos/label_nodes/CCLabelBMFont.h"
#include "Geode/loader/Log.hpp"
#include "Geode/utils/MiniFunction.hpp"
#include "Geode/utils/permission.hpp"
#include "Geode/utils/string.hpp"
#include "../random_string.hpp"
Expand Down Expand Up @@ -82,36 +83,32 @@ void NongAddPopup::openFile(CCObject* target) {
{}
};

auto callback = [this](ghc::filesystem::path result) {
auto path = fs::path(result.c_str());
#ifdef GEODE_IS_WINDOWS
auto strPath = geode::utils::string::wideToUtf8(result.c_str());
#else
std::string strPath = result.c_str();
#endif
this->addPathLabel(strPath);
m_songPath = path;
};
auto failedCallback = []() {
FLAlertLayer::create("Error", "Failed to open file", "Ok")->show();
};

if (!geode::utils::permission::getPermissionStatus(permission::Permission::ReadAudio)) {
geode::utils::permission::requestPermission(permission::Permission::ReadAudio, [this, options](bool allowed) {
geode::utils::permission::requestPermission(permission::Permission::ReadAudio, [this, options, callback, failedCallback](bool allowed) {
if (!allowed) {
FLAlertLayer::create("Error", "You need to allow media permissions to import songs!", "Ok")->show();
return;
}
file::pickFile(file::PickMode::OpenFile , options, [this](ghc::filesystem::path result) {
auto path = fs::path(result.c_str());
#ifdef GEODE_IS_WINDOWS
auto strPath = geode::utils::string::wideToUtf8(result.c_str());
#else
std::string strPath = result.c_str();
#endif
this->addPathLabel(strPath);
m_songPath = path;
}, []() {
FLAlertLayer::create("Error", "Failed to open file", "Ok")->show();
});
file::pickFile(file::PickMode::OpenFile, options, callback, failedCallback);
});
return;
}

file::pickFile(file::PickMode::OpenFile , options, [this](ghc::filesystem::path result) {
auto path = fs::path(result.c_str());
auto strPath = geode::utils::string::wideToUtf8(result.c_str());
this->addPathLabel(strPath);
m_songPath = path;
}, []() {
FLAlertLayer::create("Error", "Failed to open file", "Ok")->show();
});
file::pickFile(file::PickMode::OpenFile, options, callback, failedCallback);
}

void NongAddPopup::createInputs() {
Expand Down

0 comments on commit 2f70c2f

Please sign in to comment.