GUIでモデルの追加がもう少し楽になる構造にした

This commit is contained in:
lltcggie 2018-11-23 22:13:21 +09:00
parent 0add9fa2c9
commit e9b146ac3a
2 changed files with 48 additions and 64 deletions

View File

@ -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); const int cur = SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_GETCURSEL, 0, 0);
switch (cur) for (int i = 0; i < eModelTypeEnd; i++)
{ {
case 0: if (cur == i)
model_dir = TEXT("models/upconv_7_anime_style_art_rgb"); {
modelType = eModelTypeUpConvRGB; model_dir = ModelPathList[i];
break; modelType = (eModelType)i;
}
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;
} }
} }
@ -1649,12 +1622,10 @@ void DialogEvent::SetWindowTextLang()
SendMessage(hwndCombo, CB_DELETESTRING, 0, 0); SendMessage(hwndCombo, CB_DELETESTRING, 0, 0);
} }
SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)langStringList.GetString(L"IDC_RADIO_MODEL_UPCONV_RGB").c_str()); for (int i = 0; i < eModelTypeEnd; i++)
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(ModelTitleLangKeyList[i].c_str()).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());
SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_SETCURSEL, cur, 0); 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; int index = 0;
if (modelType == eModelTypeUpConvRGB) for (int i = 0; i < eModelTypeEnd; i++)
index = 0; {
else if (modelType == eModelTypeUpConvPhoto) if (modelType == i)
index = 1; {
else if (modelType == eModelTypeRGB) index = i;
index = 2; break;
else if (modelType == eModelTypePhoto) }
index = 3; }
else if (modelType == eModelTypeY)
index = 4;
else if (modelType == eModelTypeUpResNet10)
index = 5;
else
index = 0;
SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_SETCURSEL, index, 0); SendMessage(GetDlgItem(dh, IDC_COMBO_MODEL), CB_SETCURSEL, index, 0);

View File

@ -22,6 +22,36 @@
#define WM_END_THREAD (WM_APP + 7) #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 class DialogEvent
{ {
@ -85,17 +115,6 @@ private:
eScaleType scaleType; eScaleType scaleType;
enum eModelType
{
eModelTypeRGB,
eModelTypePhoto,
eModelTypeY,
eModelTypeUpConvRGB,
eModelTypeUpConvPhoto,
eModelTypeUpResNet10,
eModelTypeEnd,
};
eModelType modelType; eModelType modelType;
std::wstring LangName; std::wstring LangName;