Commit a284ed8e authored by fallenstardust's avatar fallenstardust
parents 6a5598dd 1bee0fe7
...@@ -69,6 +69,21 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) { ...@@ -69,6 +69,21 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
return fp; return fp;
} }
#if !defined(_WIN32)
#define myfopen std::fopen
#elif defined(WDK_NTDDI_VERSION) && (WDK_NTDDI_VERSION >= 0x0A000005) // Redstone 4, Version 1803, Build 17134.
#define FOPEN_WINDOWS_SUPPORT_UTF8
#define myfopen std::fopen
#else
inline FILE* myfopen(const char* filename, const char* mode) {
wchar_t wfilename[256]{};
BufferIO::DecodeUTF8(filename, wfilename);
wchar_t wmode[20]{};
BufferIO::CopyCharArray(mode, wmode);
return _wfopen(wfilename, wmode);
}
#endif
#include <irrlicht.h> #include <irrlicht.h>
using namespace irr::io; using namespace irr::io;
using namespace irr::os; using namespace irr::os;
......
...@@ -104,7 +104,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) { ...@@ -104,7 +104,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
return ret; return ret;
} }
bool DataManager::LoadStrings(const char* file) { bool DataManager::LoadStrings(const char* file) {
FILE* fp = std::fopen(file, "r"); FILE* fp = myfopen(file, "r");
if(!fp) if(!fp)
return false; return false;
char linebuf[TEXT_LINE_SIZE]{}; char linebuf[TEXT_LINE_SIZE]{};
...@@ -422,9 +422,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl ...@@ -422,9 +422,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
return scriptBuffer; return scriptBuffer;
} }
unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) { unsigned char* DataManager::ReadScriptFromFile(const char* script_name, int* slen) {
wchar_t fname[256]{}; FILE* fp = myfopen(script_name, "rb");
BufferIO::DecodeUTF8(script_name, fname);
FILE* fp = mywfopen(fname, "rb");
if (!fp) if (!fp)
return nullptr; return nullptr;
size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp); size_t len = std::fread(scriptBuffer, 1, sizeof scriptBuffer, fp);
......
...@@ -10,7 +10,7 @@ DeckManager deckManager; ...@@ -10,7 +10,7 @@ DeckManager deckManager;
void DeckManager::LoadLFListSingle(const char* path) { void DeckManager::LoadLFListSingle(const char* path) {
auto cur = _lfList.rend(); auto cur = _lfList.rend();
FILE* fp = std::fopen(path, "r"); FILE* fp = myfopen(path, "r");
char linebuf[256]{}; char linebuf[256]{};
wchar_t strBuffer[256]{}; wchar_t strBuffer[256]{};
char str1[16]{}; char str1[16]{};
...@@ -340,10 +340,7 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) { ...@@ -340,10 +340,7 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
return true; return true;
} }
bool DeckManager::DeleteDeck(const wchar_t* file) { bool DeckManager::DeleteDeck(const wchar_t* file) {
char filefn[256]; return FileSystem::RemoveFile(file);
BufferIO::EncodeUTF8(file, filefn);
int result = unlink(filefn);
return result == 0;
} }
bool DeckManager::CreateCategory(const wchar_t* name) { bool DeckManager::CreateCategory(const wchar_t* name) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck")) if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
......
...@@ -86,6 +86,14 @@ public: ...@@ -86,6 +86,14 @@ public:
return DeleteDir(wdir); return DeleteDir(wdir);
} }
static bool RemoveFile(const wchar_t* wfile) {
return DeleteFileW(wfile);
}
static bool RemoveFile(const char* file) {
return DeleteFileA(file);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) { static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024]; wchar_t findstr[1024];
std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%ls/*", wpath); std::swprintf(findstr, sizeof findstr / sizeof findstr[0], L"%ls/*", wpath);
...@@ -94,7 +102,7 @@ public: ...@@ -94,7 +102,7 @@ public:
if(fh == INVALID_HANDLE_VALUE) if(fh == INVALID_HANDLE_VALUE)
return; return;
do { do {
if(mywcsncasecmp(fdataw.cFileName, L".", 1) && mywcsncasecmp(fdataw.cFileName, L"..", 2)) if(std::wcscmp(fdataw.cFileName, L".") && std::wcscmp(fdataw.cFileName, L".."))
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)); cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
} while(FindNextFileW(fh, &fdataw)); } while(FindNextFileW(fh, &fdataw));
FindClose(fh); FindClose(fh);
...@@ -195,6 +203,16 @@ public: ...@@ -195,6 +203,16 @@ public:
return success; return success;
} }
static bool RemoveFile(const wchar_t* wfile) {
char file[1024];
BufferIO::EncodeUTF8(wfile, file);
return RemoveFile(file);
}
static bool RemoveFile(const char* file) {
return unlink(file) == 0;
}
struct file_unit { struct file_unit {
std::string filename; std::string filename;
bool is_dir; bool is_dir;
...@@ -216,7 +234,7 @@ public: ...@@ -216,7 +234,7 @@ public:
stat(fname, &fileStat); stat(fname, &fileStat);
funit.filename = std::string(dirp->d_name); funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode); funit.is_dir = S_ISDIR(fileStat.st_mode);
if(funit.is_dir && (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0)) if(funit.is_dir && (std::strcmp(dirp->d_name, ".") == 0 || std::strcmp(dirp->d_name, "..") == 0))
continue; continue;
file_list.push_back(funit); file_list.push_back(funit);
} }
......
...@@ -27,7 +27,7 @@ struct HostInfo { ...@@ -27,7 +27,7 @@ struct HostInfo {
uint8_t no_shuffle_deck{}; uint8_t no_shuffle_deck{};
// byte padding[3] // byte padding[3]
uint32_t start_lp{}; int32_t start_lp{};
uint8_t start_hand{}; uint8_t start_hand{};
uint8_t draw_count{}; uint8_t draw_count{};
uint16_t time_limit{}; uint16_t time_limit{};
......
...@@ -24,7 +24,7 @@ void Replay::BeginRecord() { ...@@ -24,7 +24,7 @@ void Replay::BeginRecord() {
#else #else
if(is_recording) if(is_recording)
std::fclose(fp); std::fclose(fp);
fp = std::fopen("./replay/_LastReplay.yrp", "wb"); fp = myfopen("./replay/_LastReplay.yrp", "wb");
if(!fp) if(!fp)
return; return;
#endif #endif
...@@ -154,15 +154,7 @@ bool Replay::CheckReplay(const wchar_t* name) { ...@@ -154,15 +154,7 @@ bool Replay::CheckReplay(const wchar_t* name) {
bool Replay::DeleteReplay(const wchar_t* name) { bool Replay::DeleteReplay(const wchar_t* name) {
wchar_t fname[256]; wchar_t fname[256];
myswprintf(fname, L"./replay/%ls", name); myswprintf(fname, L"./replay/%ls", name);
#ifdef _WIN32 return FileSystem::RemoveFile(fname);
BOOL result = DeleteFileW(fname);
return !!result;
#else
char filefn[256];
BufferIO::EncodeUTF8(fname, filefn);
int result = unlink(filefn);
return result == 0;
#endif
} }
bool Replay::RenameReplay(const wchar_t* oldname, const wchar_t* newname) { bool Replay::RenameReplay(const wchar_t* oldname, const wchar_t* newname) {
wchar_t oldfname[256]; wchar_t oldfname[256];
......
...@@ -17,13 +17,13 @@ constexpr int MAX_REPLAY_SIZE = 0x20000; ...@@ -17,13 +17,13 @@ constexpr int MAX_REPLAY_SIZE = 0x20000;
constexpr int MAX_COMP_SIZE = UINT16_MAX + 1; constexpr int MAX_COMP_SIZE = UINT16_MAX + 1;
struct ReplayHeader { struct ReplayHeader {
unsigned int id{}; uint32_t id{};
unsigned int version{}; uint32_t version{};
unsigned int flag{}; uint32_t flag{};
unsigned int seed{}; uint32_t seed{};
unsigned int datasize{}; uint32_t datasize{};
unsigned int start_time{}; uint32_t start_time{};
unsigned char props[8]{}; uint8_t props[8]{};
}; };
class Replay { class Replay {
......
package cn.garymb.ygomobile.ui.plus; package cn.garymb.ygomobile.ui.plus;
import android.content.Intent;
import android.net.Uri;
import com.ourygo.lib.duelassistant.util.DARecord; import com.ourygo.lib.duelassistant.util.DARecord;
import com.ourygo.lib.duelassistant.util.DuelAssistantManagement; import com.ourygo.lib.duelassistant.util.DuelAssistantManagement;
import com.tencent.smtt.sdk.WebView; import com.tencent.smtt.sdk.WebView;
...@@ -26,6 +29,13 @@ public class DefWebViewClient extends WebViewClient { ...@@ -26,6 +29,13 @@ public class DefWebViewClient extends WebViewClient {
DuelAssistantManagement.getInstance().deckCheck(url, daCheckId); DuelAssistantManagement.getInstance().deckCheck(url, daCheckId);
return true; return true;
} }
if (!url.startsWith("http://")
&& !url.startsWith("https://")) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
view.getContext().startActivity(intent);
return true;
}
return false; return false;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment