diff --git a/bin/lang/english.json b/bin/lang/english.json index 9dfabac..0b8d5a5 100644 --- a/bin/lang/english.json +++ b/bin/lang/english.json @@ -86,5 +86,6 @@ "MessageAllFileFolder":"All files and folders(*.*)", "MessageTitleInputDialog":"Please select input file or folder", "MessageTimeLeftUnkown":"Time Left: Unkown", -"MessageTimeLeft":"Time Left" +"MessageTimeLeft":"Time Left", +"MessageNoOverwrite":"Already file exists in the destination: %s" } diff --git a/bin/lang/japanese.json b/bin/lang/japanese.json index 678c011..a915075 100644 --- a/bin/lang/japanese.json +++ b/bin/lang/japanese.json @@ -86,5 +86,6 @@ "MessageAllFileFolder":"すべてのファイル、フォルダ(*.*)", "MessageTitleInputDialog":"入力するファイルかフォルダを選択してください", "MessageTimeLeftUnkown":"残り時間: 不明", -"MessageTimeLeft":"残り時間" +"MessageTimeLeft":"残り時間", +"MessageNoOverwrite":"出力先に既にファイルが存在します: %s" } diff --git a/waifu2x-caffe-gui/MainDialog.cpp b/waifu2x-caffe-gui/MainDialog.cpp index 8bc5562..e04d308 100644 --- a/waifu2x-caffe-gui/MainDialog.cpp +++ b/waifu2x-caffe-gui/MainDialog.cpp @@ -690,6 +690,18 @@ void DialogEvent::ProcessWaifu2x() const auto fileNum = file_paths.size(); for (const auto &p : file_paths) { + if (isOutputNoOverwrite && boost::filesystem::exists(p.second)) // ㏑֎~Ȃ烁bZ[W\Ė + { + SendMessage(dh, WM_ON_WAIFU2X_NO_OVERWRITE, (WPARAM)p.first.c_str(), (LPARAM)p.second.c_str()); + + num++; + ProgessFunc(maxFile, num); + + count++; + + continue; + } + ret = w.waifu2x(p.first, p.second, [this]() { return cancelFlag; @@ -1272,6 +1284,17 @@ void DialogEvent::OnWaifu2xError(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID } } +void DialogEvent::OnWaifu2xNoOverwrite(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) +{ + const TCHAR *input = (const TCHAR *)wParam; + const TCHAR *output = (const TCHAR *)lParam; + + TCHAR msg[1024] = TEXT(""); + _stprintf(msg, langStringList.GetString(L"MessageNoOverwrite").c_str(), output); + + AddLogMessage(msg); +} + void DialogEvent::SetWindowTextLang() { #define SET_WINDOW_TEXT(id) SetWindowTextW(GetDlgItem(dh, id), langStringList.GetString(L#id).c_str()); diff --git a/waifu2x-caffe-gui/MainDialog.h b/waifu2x-caffe-gui/MainDialog.h index 0c06633..5abf787 100644 --- a/waifu2x-caffe-gui/MainDialog.h +++ b/waifu2x-caffe-gui/MainDialog.h @@ -17,6 +17,7 @@ #define WM_FAILD_CREATE_DIR (WM_APP + 5) #define WM_ON_WAIFU2X_ERROR (WM_APP + 6) +#define WM_ON_WAIFU2X_NO_OVERWRITE (WM_APP + 8) #define WM_END_THREAD (WM_APP + 7) @@ -169,6 +170,8 @@ public: void OnWaifu2xError(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData); + void OnWaifu2xNoOverwrite(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData); + void SetWindowTextLang(); void SetDepthAndQuality(const bool SetDefaultQuality = true); diff --git a/waifu2x-caffe-gui/Source.cpp b/waifu2x-caffe-gui/Source.cpp index 97edb63..841ea61 100644 --- a/waifu2x-caffe-gui/Source.cpp +++ b/waifu2x-caffe-gui/Source.cpp @@ -96,6 +96,7 @@ int WINAPI WinMain(HINSTANCE hInstance, cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnDialogEnd, &cDialogEvent), NULL, WM_CLOSE); cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnFaildCreateDir, &cDialogEvent), NULL, WM_FAILD_CREATE_DIR); cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnWaifu2xError, &cDialogEvent), NULL, WM_ON_WAIFU2X_ERROR); + cDialog.SetEventCallBack(SetClassFunc(DialogEvent::OnWaifu2xNoOverwrite, &cDialogEvent), NULL, WM_ON_WAIFU2X_NO_OVERWRITE); cDialog.SetEventCallBack(SetClassFunc(DialogEvent::WaitThreadExit, &cDialogEvent), NULL, WM_END_THREAD); cDialog.SetEventCallBack(SetClassFunc(DialogEvent::Timer, &cDialogEvent), NULL, WM_TIMER);