Mercurial > msvpvf
comparison src/gui.c @ 51:0f6c604b6863
We don't need to specify that it's ANSI
because MinGW does it for us (I think)
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Sun, 22 May 2022 04:11:30 -0400 |
parents | 7cb4ca7cf257 |
children | cf9a14755472 |
comparison
equal
deleted
inserted
replaced
50:0fa325f60f07 | 51:0f6c604b6863 |
---|---|
45 vf, | 45 vf, |
46 veg | 46 veg |
47 } type; | 47 } type; |
48 char* file_name = " "; | 48 char* file_name = " "; |
49 | 49 |
50 | |
51 void display_file(char* path) { | 50 void display_file(char* path) { |
52 /* Read the file to memory */ | 51 /* Read the file to memory */ |
53 FILE* file; | 52 FILE* file; |
54 file = fopen(path, "rb"); | 53 file = fopen(path, "rb"); |
55 fseek(file, 0, SEEK_END); | 54 fseek(file, 0, SEEK_END); |
62 free(data); | 61 free(data); |
63 fclose(file); | 62 fclose(file); |
64 } | 63 } |
65 | 64 |
66 char* open_file(HWND hWnd) { | 65 char* open_file(HWND hWnd) { |
67 OPENFILENAMEA ofn; | 66 OPENFILENAME ofn; |
68 char filename[256]; | 67 char filename[256]; |
69 | 68 |
70 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); | 69 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); |
71 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; | 70 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
72 ofn.hwndOwner = hWnd; | 71 ofn.hwndOwner = hWnd; |
74 ofn.lpstrFile[0] = '\0'; | 73 ofn.lpstrFile[0] = '\0'; |
75 ofn.nMaxFile = 256; | 74 ofn.nMaxFile = 256; |
76 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; | 75 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; |
77 ofn.nFilterIndex = 1; | 76 ofn.nFilterIndex = 1; |
78 | 77 |
79 if (GetOpenFileNameA(&ofn) == 0) { | 78 if (GetOpenFileName(&ofn) == 0) { |
80 return " "; | 79 return " "; |
81 } | 80 } |
82 | 81 |
83 display_file(filename); | 82 display_file(filename); |
84 | 83 |
85 return strdup(filename); | 84 return strdup(filename); |
86 } | 85 } |
87 | 86 |
88 void save_file(HWND hWnd, char* input_file) { | 87 void save_file(HWND hWnd, char* input_file) { |
89 if (strcmp(input_file, " ") == 0) { | 88 if (strcmp(input_file, " ") == 0) { |
90 MessageBoxA(hWnd, | 89 MessageBox(hWnd, |
91 "Please open a file first!", | 90 "Please open a file first!", |
92 "Invalid input file!", | 91 "Invalid input file!", |
93 MB_ICONEXCLAMATION); | 92 MB_ICONEXCLAMATION); |
94 return; | 93 return; |
95 } | 94 } |
96 OPENFILENAMEA ofn; | 95 OPENFILENAME ofn; |
97 char output_file[256]; | 96 char output_file[256]; |
98 | 97 |
99 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); | 98 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); |
100 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; | 99 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
101 ofn.hwndOwner = hWnd; | 100 ofn.hwndOwner = hWnd; |
103 ofn.lpstrFile[0] = '\0'; | 102 ofn.lpstrFile[0] = '\0'; |
104 ofn.nMaxFile = 256; | 103 ofn.nMaxFile = 256; |
105 ofn.lpstrFilter = "Movie Studio project files\0*.vf\0VEGAS Pro project files\0*.veg\0All files\0*.*\0"; | 104 ofn.lpstrFilter = "Movie Studio project files\0*.vf\0VEGAS Pro project files\0*.veg\0All files\0*.*\0"; |
106 ofn.nFilterIndex = (int)type+1; | 105 ofn.nFilterIndex = (int)type+1; |
107 | 106 |
108 if (GetSaveFileNameA(&ofn) == 0) { | 107 if (GetSaveFileName(&ofn) == 0) { |
109 return; | 108 return; |
110 } | 109 } |
111 | 110 |
112 copy_file(input_file, output_file); | 111 copy_file(input_file, output_file); |
113 FILE* output = fopen(output_file, "r+b"); | 112 FILE* output = fopen(output_file, "r+b"); |
114 if (output == NULL) { | 113 if (output == NULL) { |
115 MessageBoxA(hWnd, "Failed to save project file!", "Saving project failed!", MB_ICONEXCLAMATION); | 114 MessageBox(hWnd, "Failed to save project file!", "Saving project failed!", MB_ICONEXCLAMATION); |
116 return; | 115 return; |
117 } | 116 } |
118 | 117 |
119 switch ((int)type) { | 118 switch ((int)type) { |
120 case vf: { | 119 case vf: { |
134 fclose(output); | 133 fclose(output); |
135 } | 134 } |
136 | 135 |
137 void AddControls(HWND hWnd) { | 136 void AddControls(HWND hWnd) { |
138 /* Versions */ | 137 /* Versions */ |
139 hWndComboBox = CreateWindowA("ComboBox", NULL, | 138 hWndComboBox = CreateWindow("ComboBox", NULL, |
140 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, | 139 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, |
141 (int)((225 - 50)/2), 30, 50, 200, | 140 (int)((225 - 50)/2), 30, 50, 200, |
142 hWnd, (HMENU)COMBOBOX, NULL, NULL); /** | 141 hWnd, (HMENU)COMBOBOX, NULL, NULL); /** |
143 * I don't understand what half of | 142 * I don't understand what half of |
144 * these arguments are for, so chances | 143 * these arguments are for, so chances |
153 for (i = 0; i < ARRAYSIZE(versions); i++) { | 152 for (i = 0; i < ARRAYSIZE(versions); i++) { |
154 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)versions[i]); | 153 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)versions[i]); |
155 } | 154 } |
156 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); | 155 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); |
157 /* Open File */ | 156 /* Open File */ |
158 HWND open_button = CreateWindowA("Button", "Open", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 5, 50, 20, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL); | 157 HWND open_button = CreateWindow("Button", "Open", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 5, 50, 20, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL); |
159 /* Type */ | 158 /* Type */ |
160 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")}; | 159 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")}; |
161 hWndListBox = CreateWindowA("Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL); | 160 hWndListBox = CreateWindow("Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL); |
162 for (i = 0; i < ARRAYSIZE(listbox_items); i++) { | 161 for (i = 0; i < ARRAYSIZE(listbox_items); i++) { |
163 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]); | 162 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]); |
164 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i); | 163 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i); |
165 } | 164 } |
166 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0); | 165 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0); |
204 } | 203 } |
205 case WM_DESTROY: | 204 case WM_DESTROY: |
206 PostQuitMessage(0); | 205 PostQuitMessage(0); |
207 break; | 206 break; |
208 default: | 207 default: |
209 return DefWindowProcA(hWnd, msg, wParam, lParam); | 208 return DefWindowProc(hWnd, msg, wParam, lParam); |
210 } | 209 } |
211 return false; | 210 return false; |
212 } | 211 } |
213 | 212 |
214 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { | 213 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { |
215 WNDCLASSA wc = {0}; | 214 WNDCLASS wc = {0}; |
216 | 215 |
217 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; | 216 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; |
218 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 217 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
219 wc.hInstance = hInstance; | 218 wc.hInstance = hInstance; |
220 wc.lpszClassName = "msvpvf"; | 219 wc.lpszClassName = "msvpvf"; |
221 wc.lpfnWndProc = WindowProcedure; | 220 wc.lpfnWndProc = WindowProcedure; |
222 | 221 |
223 if (!RegisterClassA(&wc)) return -1; | 222 if (!RegisterClass(&wc)) return -1; |
224 | 223 |
225 CreateWindowA("msvpvf", "Movie Studio / Vegas Pro version spoofer", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL); | 224 CreateWindow("msvpvf", "Movie Studio / Vegas Pro version spoofer", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL); |
226 | 225 |
227 MSG msg = {0}; | 226 MSG msg = {0}; |
228 | 227 |
229 while (GetMessage(&msg, NULL, 0, 0)) { | 228 while (GetMessage(&msg, NULL, 0, 0)) { |
230 TranslateMessage(&msg); | 229 TranslateMessage(&msg); |