From e9b146ac3abe7ff34118f149f8c6f467350053ce Mon Sep 17 00:00:00 2001 From: lltcggie Date: Fri, 23 Nov 2018 22:13:21 +0900 Subject: [PATCH] =?UTF-8?q?GUI=E3=81=A7=E3=83=A2=E3=83=87=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E8=BF=BD=E5=8A=A0=E3=81=8C=E3=82=82=E3=81=86=E5=B0=91?= =?UTF-8?q?=E3=81=97=E6=A5=BD=E3=81=AB=E3=81=AA=E3=82=8B=E6=A7=8B=E9=80=A0?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/MainDialog.cpp | 71 ++++++++------------------------ waifu2x-caffe-gui/MainDialog.h | 41 +++++++++++++----- 2 files changed, 48 insertions(+), 64 deletions(-) diff --git a/waifu2x-caffe-gui/MainDialog.cpp b/waifu2x-caffe-gui/MainDialog.cpp index 0b94889..3deb5bd 100644 --- a/waifu2x-caffe-gui/MainDialog.cpp +++ b/waifu2x-caffe-gui/MainDialog.cpp @@ -373,40 +373,13 @@ bool DialogEvent::SyncMember(const bool NotSyncCropSize, const bool silent) { const int cur = SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_GETCURSEL, 0, 0); - switch (cur) + for (int i = 0; i < eModelTypeEnd; i++) { - case 0: - model_dir = TEXT("models/upconv_7_anime_style_art_rgb"); - modelType = eModelTypeUpConvRGB; - break; - - case 1: - model_dir = TEXT("models/upconv_7_photo"); - modelType = eModelTypeUpConvPhoto; - break; - - case 2: - model_dir = TEXT("models/anime_style_art_rgb"); - modelType = eModelTypeRGB; - break; - - case 3: - model_dir = TEXT("models/photo"); - modelType = eModelTypePhoto; - break; - - case 4: - model_dir = TEXT("models/anime_style_art"); - modelType = eModelTypeY; - break; - - case 5: - model_dir = TEXT("models/upresnet10"); - modelType = eModelTypeUpResNet10; - break; - - default: - break; + if (cur == i) + { + model_dir = ModelPathList[i]; + modelType = (eModelType)i; + } } } @@ -1649,12 +1622,10 @@ void DialogEvent::SetWindowTextLang() SendMessage(hwndCombo, CB_DELETESTRING, 0, 0); } - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_UPCONV_RGB").c_str()); - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_UPCONV_PHOTO").c_str()); - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_RGB").c_str()); - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_PHOTO").c_str()); - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_Y").c_str()); - SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_UpResNet10").c_str()); + for (int i = 0; i < eModelTypeEnd; i++) + { + SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(ModelTitleLangKeyList[i].c_str()).c_str()); + } SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_SETCURSEL, cur, 0); } @@ -2106,20 +2077,14 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData) } int index = 0; - if (modelType == eModelTypeUpConvRGB) - index = 0; - else if (modelType == eModelTypeUpConvPhoto) - index = 1; - else if (modelType == eModelTypeRGB) - index = 2; - else if (modelType == eModelTypePhoto) - index = 3; - else if (modelType == eModelTypeY) - index = 4; - else if (modelType == eModelTypeUpResNet10) - index = 5; - else - index = 0; + for (int i = 0; i < eModelTypeEnd; i++) + { + if (modelType == i) + { + index = i; + break; + } + } SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_SETCURSEL, index, 0); diff --git a/waifu2x-caffe-gui/MainDialog.h b/waifu2x-caffe-gui/MainDialog.h index 5aacae9..ddcc545 100644 --- a/waifu2x-caffe-gui/MainDialog.h +++ b/waifu2x-caffe-gui/MainDialog.h @@ -22,6 +22,36 @@ #define WM_END_THREAD (WM_APP + 7) +enum eModelType +{ + eModelTypeUpConvRGB, + eModelTypeUpConvPhoto, + eModelTypeRGB, + eModelTypePhoto, + eModelTypeY, + eModelTypeUpResNet10, + eModelTypeEnd, +}; + +const tstring ModelPathList[eModelTypeEnd] = { + TEXT("models/upconv_7_anime_style_art_rgb"), + TEXT("models/upconv_7_photo"), + TEXT("models/anime_style_art_rgb"), + TEXT("models/photo"), + TEXT("models/anime_style_art"), + TEXT("models/upresnet10"), +}; + +const std::wstring ModelTitleLangKeyList[eModelTypeEnd] = { + L"IDC_RADIO_MODEL_UPCONV_RGB", + L"IDC_RADIO_MODEL_UPCONV_PHOTO", + L"IDC_RADIO_MODEL_RGB", + L"IDC_RADIO_MODEL_PHOTO", + L"IDC_RADIO_MODEL_Y", + L"IDC_RADIO_MODEL_UpResNet10", +}; + + // ダイアログ用 class DialogEvent { @@ -85,17 +115,6 @@ private: eScaleType scaleType; - enum eModelType - { - eModelTypeRGB, - eModelTypePhoto, - eModelTypeY, - eModelTypeUpConvRGB, - eModelTypeUpConvPhoto, - eModelTypeUpResNet10, - eModelTypeEnd, - }; - eModelType modelType; std::wstring LangName;