annotate src/gui.c @ 19:6d14538a109e

Update gui.c
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Thu, 07 Apr 2022 19:30:53 -0400
parents b5df3f47a30e
children bf872a9c70d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
1 /**
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
2 * msvpvf GUI for Windows
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
3 * Copyright (c) Paper 2022
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
4 *
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
5 * View this file with 4-tab spacing; if you don't it will be a formatting nightmare.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
6 *
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
8 * of this software and associated documentation files (the "Software"), to deal
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
9 * in the Software without restriction, including without limitation the rights
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
11 * copies of the Software, and to permit persons to whom the Software is
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
12 * furnished to do so, subject to the following conditions:
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
13 *
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
14 * The above copyright notice and this permission notice shall be included in all
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
15 * copies or substantial portions of the Software.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
16 *
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
23 * SOFTWARE.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
24 **/
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 #include <stdio.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26 #include <windows.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 #include <stdint.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 #include <stdbool.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 #include <commdlg.h>
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 #define OPEN_FILE_BUTTON 0
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 #define COMBOBOX 1
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32 #define LISTBOX 2
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 #define SAVE_FILE_BUTTON 3
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 HWND hWndListBox, hWndComboBox;
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
36 int16_t version = 11;
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
37 enum type {
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
38 vf,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
39 veg
19
6d14538a109e Update gui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 18
diff changeset
40 };
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
41 char* file_name = " ";
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 void set_data(unsigned char magic[], uint16_t version, FILE* target) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44 int i;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 fseek(target, 0x46, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 fputc(version, target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 for (i=0; i<=sizeof(*magic); ++i) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 fseek(target, 0x18+i, SEEK_SET);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49 fputc(magic[i], target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 int copy_file(char* source_file, char* target_file) {
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
54 /* Copy a file */
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 FILE *source, *target;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 source = fopen(source_file, "rb");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 if (source == NULL) return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 target = fopen(target_file, "wb");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60 if (target == NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 fclose(source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 return 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 size_t n, m;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 unsigned char buff[8192];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 do {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68 n = fread(buff, 1, sizeof(buff), source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 if (n) m = fwrite(buff, 1, n, target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 else m = 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 } while ((n > 0) && (n == m));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 fclose(target);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74 fclose(source);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 return 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 void display_file(char* path) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79 /* Read the file to memory */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 FILE* file;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 file = fopen(path, "rb");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 fseek(file, 0, SEEK_END);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 int _size = ftell(file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 rewind(file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 char* data = calloc(_size+1, sizeof(char*));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86 fread(data, _size, 1, file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 data[_size] = '\0';
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 free(data);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 fclose(file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 char* open_file(HWND hWnd) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 OPENFILENAME ofn;
9
d2cd8c5672fa Increase filename limit
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
95 char filename[256];
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 ZeroMemory(&ofn, sizeof(OPENFILENAME));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98 ofn.lStructSize = sizeof(OPENFILENAME);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 ofn.hwndOwner = hWnd;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100 ofn.lpstrFile = filename;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 ofn.lpstrFile[0] = '\0';
9
d2cd8c5672fa Increase filename limit
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
102 ofn.nMaxFile = 256;
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0";
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 ofn.nFilterIndex = 1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 GetOpenFileName(&ofn);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 display_file(filename);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110 return _strdup(filename);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 void save_file(HWND hWnd, char* input_file) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 if (strcmp(input_file, " ") == 0) {
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
115 MessageBoxW(hWnd,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
116 L"Please open a file first!",
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
117 L"Invalid input file!",
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
118 MB_ICONEXCLAMATION);
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 return;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121 OPENFILENAME ofn;
9
d2cd8c5672fa Increase filename limit
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
122 char output_file[256];
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124 ZeroMemory(&ofn, sizeof(OPENFILENAME));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125 ofn.lStructSize = sizeof(OPENFILENAME);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126 ofn.hwndOwner = hWnd;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 ofn.lpstrFile = output_file;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 ofn.lpstrFile[0] = '\0';
9
d2cd8c5672fa Increase filename limit
Paper <mrpapersonic@gmail.com>
parents: 6
diff changeset
129 ofn.nMaxFile = 256;
17
812089083c89 GUI: automatically select project file extension
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 14
diff changeset
130 ofn.lpstrFilter = "Movie Studio project files\0*.vf\0VEGAS Pro project files\0*.veg\0All files\0*.*\0";
812089083c89 GUI: automatically select project file extension
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 14
diff changeset
131 ofn.nFilterIndex = type+1;
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 GetSaveFileName(&ofn);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 copy_file(input_file, output_file);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 FILE* output = fopen(output_file, "r+b");
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 if (output == NULL) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 MessageBoxW(hWnd, L"Failed to save project file!", L"Saving project failed!", MB_ICONEXCLAMATION);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139 return;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
142 switch (type) {
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
143 case vf:
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
144 unsigned char magic[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
145 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A};
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
146 set_data(magic, version, output);
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
147 break;
19
6d14538a109e Update gui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 18
diff changeset
148 default:
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
149 unsigned char magic[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
150 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F};
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
151 set_data(magic, version, output);
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
152 break;
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155 fclose(output);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 void AddControls(HWND hWnd) {
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
159 /* Versions */
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
160 hWndComboBox = CreateWindowW(L"ComboBox", NULL,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
161 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
162 (int)((225 - 50)/2), 30, 50, 200,
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
163 hWnd, (HMENU)COMBOBOX, NULL, NULL); /**
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
164 * I don't understand what half of
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
165 * these arguments are for, so chances
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
166 * are that you don't either.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
167 **/
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
168 TCHAR versions[][10] = {TEXT("8"), TEXT("9"), TEXT("10"),
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
169 TEXT("11"), TEXT("12"), TEXT("13"),
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
170 TEXT("14"), TEXT("15"), TEXT("16"),
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
171 TEXT("17"), TEXT("18"), TEXT("19")};
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173 TCHAR A[16];
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
174
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
175 /**
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
176 * Here we can't just use a for loop
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
177 * and cast all of those to `TEXT()`.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
178 * Why? I don't know. My brain is too
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
179 * small to figure it out.
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
180 **/
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181 memset(&A,0,sizeof(A));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182 int i = 0;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183 for (i = 0; i <= 11; i++) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184 wcscpy_s((WCHAR*)A, sizeof(A)/sizeof(TCHAR), (WCHAR*)versions[i]);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
185 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
187 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0);
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
188 /* Open File */
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
189 HWND open_button = CreateWindowW(L"Button", L"Open", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 5, 50, 20, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL);
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
190 /* Type */
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
192 hWndListBox = CreateWindowW(L"Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
193 for (i = 0; i < ARRAYSIZE(listbox_items); i++) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
194 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
195 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
197 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
18
b5df3f47a30e Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 17
diff changeset
198 /* Save File */
6
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
199 HWND save_button = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 90, 50, 20, hWnd, (HMENU)SAVE_FILE_BUTTON, NULL, NULL);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
200 if (open_button == NULL || save_button == NULL || hWndListBox == NULL || hWndComboBox == NULL)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
201 MessageBoxW(hWnd, L"how did you even trigger this", L"GUI could not be initialized!", MB_ICONEXCLAMATION);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
202 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
203
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
204 bool CALLBACK SetFont(HWND child, LPARAM font) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205 SendMessage(child, WM_SETFONT, font, true);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
206 return true;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
207 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
208
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
209 LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
210 switch(msg) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
211 case WM_COMMAND:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
212 if(HIWORD(wParam) == CBN_SELCHANGE) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
213 if (LOWORD(wParam) == COMBOBOX)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
214 version = (int16_t)(8+SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
215 if (LOWORD(wParam) == LISTBOX)
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
216 type = SendMessage((HWND) lParam, (UINT) LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
217 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
218 switch(wParam) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
219 case OPEN_FILE_BUTTON:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220 file_name = open_file(hWnd);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
221 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
222 case COMBOBOX:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
223 break; /* NOTE: remove these 4 lines if we don't end up doing anything with them */
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
224 case LISTBOX:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
225 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
226 case SAVE_FILE_BUTTON:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
227 save_file(hWnd, file_name);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
228 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
229 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
230 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
231 case WM_CREATE: {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
232 AddControls(hWnd);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
233 EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT));
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
234 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236 case WM_DESTROY:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237 PostQuitMessage(0);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
238 break;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
239 default:
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
240 return DefWindowProcW(hWnd, msg, wParam, lParam);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
241 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
242 return false;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
243 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
244
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
245 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
246 WNDCLASSW wc = {0};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
247
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
248 wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
249 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
250 wc.hInstance = hInstance;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
251 wc.lpszClassName = L"msvpvf";
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
252 wc.lpfnWndProc = WindowProcedure;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
253
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
254 if (!RegisterClassW(&wc)) return -1;
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
255
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
256 CreateWindowW(L"msvpvf", L"Movie Studio / Vegas Pro version spoofer", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
257
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
258 MSG msg = {0};
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
259
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
260 while (GetMessage(&msg, NULL, 0, 0)) {
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
261 TranslateMessage(&msg);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
262 DispatchMessage(&msg);
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
263 }
d1e5b8390cd3 Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
264 }