Skip to content

Commit

Permalink
Supports Vulkan Convert over x4
Browse files Browse the repository at this point in the history
  • Loading branch information
YukihoAA committed Oct 3, 2022
1 parent 4c2fc71 commit b29ba67
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 15 deletions.
53 changes: 43 additions & 10 deletions waifu2x_snowshell/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdL
if (!bIsWow64)
MessageBox(NULL, L"This program only works on 64bit system", L"Error", MB_OK | MB_ICONERROR);

hWnd = CreateWindow(lpszClass, L"waifu2x - Snowshell v2.3", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_BORDER, CW_USEDEFAULT, CW_USEDEFAULT, 530, 370, NULL, NULL, hInstance, NULL);
hWnd = CreateWindow(lpszClass, L"waifu2x - Snowshell v2.4", WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_BORDER, CW_USEDEFAULT, CW_USEDEFAULT, 530, 370, NULL, NULL, hInstance, NULL);

ShowWindow(hWnd, nCmdShow);

Expand Down Expand Up @@ -107,6 +107,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
SendMessage(hCombo, WM_SETFONT, (WPARAM) hSFont, 0);
DragAcceptFiles(hWnd, TRUE);


return TRUE;
case WM_INITMENU:
SnowSetting::checkMenuAll(hMenu);
Expand Down Expand Up @@ -205,7 +207,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
case ID_MENU_SCALE_CUSTOM:
if (SnowSetting::getConfirm() == CONFIRM_SHOW && MessageBox(hWnd, STRING_TEXT_CONFIRM_CUSTOM_SCALE_MESSAGE.c_str(), STRING_TEXT_CONFIRM_CUSTOM_SCALE_TITLE.c_str(), MB_YESNO | MB_ICONEXCLAMATION | MB_SYSTEMMODAL) == IDNO)
return TRUE;
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, SettingDlgProc);
if (SnowSetting::CurrentConverter == &SnowSetting::CONVERTER_VULKAN)
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG3), hWnd, SettingDlgProcVulkan);
else
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG1), hWnd, SettingDlgProc);
case ID_MENU_SCALE_x1_0:
case ID_MENU_SCALE_x1_5:
case ID_MENU_SCALE_x1_6:
Expand Down Expand Up @@ -380,6 +385,40 @@ INT_PTR CALLBACK SettingDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
return FALSE;
}

INT_PTR CALLBACK SettingDlgProcVulkan(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
static HWND hCombo, hText, hButton;
switch (uMsg)
{
case WM_INITDIALOG:
hCombo = GetDlgItem(hDlg, IDC_COMBO1);
hText = GetDlgItem(hDlg, IDC_TEXT1);
hButton = GetDlgItem(hDlg, IDOK);

for (int i = 0; i < SnowSetting::VulkanScaleNum; i++) {
SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)SnowSetting::VulkanScale[i]);
if (!wcscmp(SnowSetting::getScaleRatio().c_str(), SnowSetting::VulkanScale[i]))
SendMessage(hCombo, CB_SETCURSEL, i, 0);
}

SetWindowText(hText, STRING_TEXT_SCALE.c_str());
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
SnowSetting::setScaleRatio(SnowSetting::VulkanScale[SendMessage(hCombo, CB_GETCURSEL, 0, 0)]);

EndDialog(hDlg, IDCANCEL);
return TRUE;
}
return FALSE;
case WM_CLOSE:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
return FALSE;
}

BOOL Execute(HWND hWnd, ConvertOption *convertOption, LPCWSTR fileName, bool noLabel) {
int FileNameLength;
int MaxInputLength;
Expand Down Expand Up @@ -409,10 +448,7 @@ BOOL Execute(HWND hWnd, ConvertOption *convertOption, LPCWSTR fileName, bool noL
}
switch (SnowSetting::getScale()) {
case SCALE_x1_0:
if (SnowSetting::CurrentConverter == &SnowSetting::CONVERTER_VULKAN)
convertOption->setScaleRatio(L"1");
else
convertOption->setScaleRatio(L"1.0");
convertOption->setScaleRatio(L"1.0");
break;
case SCALE_x1_5:
convertOption->setScaleRatio(L"1.5");
Expand All @@ -421,10 +457,7 @@ BOOL Execute(HWND hWnd, ConvertOption *convertOption, LPCWSTR fileName, bool noL
convertOption->setScaleRatio(L"1.6");
break;
case SCALE_x2_0:
if (SnowSetting::CurrentConverter == &SnowSetting::CONVERTER_VULKAN)
convertOption->setScaleRatio(L"2");
else
convertOption->setScaleRatio(L"2.0");
convertOption->setScaleRatio(L"2.0");
break;
case SCALE_CUSTOM:
convertOption->setScaleRatio(SnowSetting::getScaleRatio());
Expand Down
1 change: 1 addition & 0 deletions waifu2x_snowshell/Main.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ extern HINSTANCE g_hInst;
BOOL Execute(HWND hWnd, ConvertOption *convertOption, LPCWSTR fileName, bool noLabel = false);
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK SettingDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK SettingDlgProcVulkan(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void prtTextBorder(HDC hdc, int x, int y, LPCWSTR str, int c, COLORREF borderColor, int borderSize, COLORREF textColor = NULL);
17 changes: 12 additions & 5 deletions waifu2x_snowshell/SnowSetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const int SnowSetting::LangNum = 7;
wstring SnowSetting::LangName[7] = { L"한국어", L"English", L"日本語", L"中文", L"Deutsch", L"Svenska" , L"Portuguese" };
wstring SnowSetting::LangFile[7] = { L"Korean.ini", L"English.ini", L"Japanese.ini", L"Chinese.ini", L"German.ini", L"Swedish.ini", L"Portuguese.ini" };


const int SnowSetting::VulkanScaleNum = 6;
LPWSTR SnowSetting::VulkanScale[6] = { L"1.0", L"2.0", L"4.0", L"8.0", L"16.0", L"32.0" };

SnowSetting::SnowSetting()
{
LPWSTR path = new WCHAR[MAX_PATH];
Expand Down Expand Up @@ -821,9 +825,9 @@ void SnowSetting::setScale(int Scale)
Init();

if (Scale > SCALE_MAX || Scale < 0)
Scale = 0;
Scale = SCALE_x2_0;

if (CurrentConverter == &CONVERTER_VULKAN && Scale != SCALE_x1_0 && Scale != SCALE_x2_0)
if (CurrentConverter == &CONVERTER_VULKAN && Scale != SCALE_x1_0 && Scale != SCALE_x2_0 && Scale != SCALE_CUSTOM)
Scale = SCALE_x2_0;

Singletone->Scale = Scale;
Expand Down Expand Up @@ -904,6 +908,11 @@ void SnowSetting::setConverterNum(int ConverterNum)
if (CONVERTER_VULKAN.getAvailable()) {
Singletone->CurrentConverter = &CONVERTER_VULKAN;
Singletone->ConverterNum = ConverterNum;
for (int i = 0; i < VulkanScaleNum; i++) {
if (!wcscmp(VulkanScale[i], Singletone->ScaleRatio.c_str()))
return;
}
Singletone->ScaleRatio = L"2.0";
}
break;
}
Expand Down Expand Up @@ -969,14 +978,12 @@ void SnowSetting::checkScale(HMENU hMenu, int sel)
if (CurrentConverter == &CONVERTER_VULKAN) {
EnableMenuItem(hSubMenu, SCALE_x1_5, MF_BYPOSITION | MF_GRAYED);
EnableMenuItem(hSubMenu, SCALE_x1_6, MF_BYPOSITION | MF_GRAYED);
EnableMenuItem(hSubMenu, SCALE_CUSTOM, MF_BYPOSITION | MF_GRAYED);
if (getScale() != SCALE_x1_0 && getScale() != SCALE_x2_0)
if (getScale() == SCALE_x1_5 && getScale() == SCALE_x1_6)
setScale(SCALE_x2_0);
}
else {
EnableMenuItem(hSubMenu, SCALE_x1_5, MF_BYPOSITION | MF_ENABLED);
EnableMenuItem(hSubMenu, SCALE_x1_6, MF_BYPOSITION | MF_ENABLED);
EnableMenuItem(hSubMenu, SCALE_CUSTOM, MF_BYPOSITION | MF_ENABLED);
}

CheckMenuItem(hSubMenu, getScale(), MF_BYPOSITION | MF_CHECKED);
Expand Down
2 changes: 2 additions & 0 deletions waifu2x_snowshell/SnowSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class SnowSetting {
static void loadLocale();

public:
static LPWSTR VulkanScale[];
const static int VulkanScaleNum;
static std::wstring OutputDirName;
static std::wstring CurrPath;

Expand Down
Binary file modified waifu2x_snowshell/resource.h
Binary file not shown.
Binary file modified waifu2x_snowshell/waifu2x_snowshell.rc
Binary file not shown.

0 comments on commit b29ba67

Please sign in to comment.