Mercurial > msvpvf
changeset 81:c06dcab17923 v2.1
*: change license to BSD, update README for Unicode
src/gui: use tchar.h for unicode instead of our own macros
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Fri, 22 Mar 2024 22:04:16 -0400 |
parents | 719570851563 |
children | 59a86b638d40 |
files | LICENSE Makefile README.md src/gui.c src/main.c |
diffstat | 5 files changed, 96 insertions(+), 101 deletions(-) [+] |
line wrap: on
line diff
--- a/LICENSE Wed Mar 20 17:09:43 2024 -0400 +++ b/LICENSE Fri Mar 22 22:04:16 2024 -0400 @@ -1,21 +1,29 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2022 Paper +Copyright (c) 2022-2024, Paper. +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
--- a/Makefile Wed Mar 20 17:09:43 2024 -0400 +++ b/Makefile Fri Mar 22 22:04:16 2024 -0400 @@ -6,7 +6,7 @@ # this is a unix-like version, barely functional on windows. msvpvf: src/main.o src/common.o - $(CC) $(_CFLAGS) -o $@ $^ $(_LDFLAGS) + $(CC) $(_CFLAGS) -o $@ $^ $(_LDFLAGS) # windows-specific gui: src/gui.o src/common.o
--- a/README.md Wed Mar 20 17:09:43 2024 -0400 +++ b/README.md Fri Mar 22 22:04:16 2024 -0400 @@ -1,29 +1,34 @@ # msvpvf C port of [msvpvf](https://archive.org/details/msvpvf-1.3-movie-studio-vegas-pro-version-faker-msvpvf-updated-to-1.31-focus-on-vegas) -![msvpvf CI](https://github.com/mrpapersonic/msvpvf/actions/workflows/build.yml/badge.svg) +## What is this?? +msvpvf is a tool used to "downgrade" VEGAS Pro project files, written entirely +in C. -## What is this?? -msvpvf is a tool used to "downgrade" VEGAS Pro project files, written entirely in C. It has no runtime libraries, making it incredibly lightweight. Binaries for OS X and Windows are less than a megabyte in size. - -Currently, the GUI doesn't look that great. Making pretty apps with `windows.h` is not the easiest job in the world; if someone is willing enough to make it look prettier, be my guest. - -It is based on an old tool under the same name that was written in C#/.NET, but the original website is now down and it hasn't been maintained in over 2 years. +It is based on an old tool under the same name that was written in C#/.NET, +but it's horribly slow for what it does (set some magic bytes at some offsets) # Compatibility There are 3 generations of modern Vegas project files: -Gen 1 | Gen 2 | Gen 3 ---- | --- | --- -8.0 - 11.0 | 12.0 - 14.0 | 15.0 - Now +Gen 1 | Gen 2 | Gen 3 onwards | +---------- | ----------- | ------------- | +8.0 - 11.0 | 12.0 - 14.0 | 15.0 - ??? | -Any version in Gen 3 cannot be ported to Gen 2, and Gen 2 cannot be ported to Gen 1. That's just too complicated for a simple bit modifier. **However**, any file created in an older Vegas will work in a newer one. +I haven't used any Vegas version after 14, so I have no idea if this even works +for newer versions anymore. ## Compilation ``` git clone https://github.com/mrpapersonic/msvpvf cd msvpvf + +# CLI (macos/linux, unicode filenames are unsupported on Windows) make + +# windows GUI application +# set the two UNICODE flags to 0 or 1 for ANSI and Unicode respectfully +make gui CFLAGS="-DUNICODE=0 -D_UNICODE=0" ``` NOTE: if you are using Windows, there is a GUI available. To compile it, use `make gui`.
--- a/src/gui.c Wed Mar 20 17:09:43 2024 -0400 +++ b/src/gui.c Fri Mar 22 22:04:16 2024 -0400 @@ -1,31 +1,4 @@ -/** - * msvpvf GUI for Windows - * Copyright (c) Paper 2022-2024 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. -**/ - -/* change these macros to configure the window size */ -#define WINDOW_WIDTH 225 -#define WINDOW_HEIGHT 200 - -/* mingw */ +/* mingw hack */ #ifdef UNICODE #define NTDDI_VERSION 0x06000000 #define _WIN32_WINNT 0x0600 @@ -36,40 +9,46 @@ #include <windef.h> #include <winbase.h> #include <shlwapi.h> -#include <shobjidl.h> #include <stdint.h> #include <stdio.h> +#include <tchar.h> /* tchar versions of string.h functions */ + #include "common.h" -/* we use COM when `UNICODE=1` to avoid file paths being cut off */ -#define COM_INITFLAGS (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE) - -#define OPEN_FILE_BUTTON 0 -#define COMBOBOX 1 -#define LISTBOX 2 -#define SAVE_FILE_BUTTON 3 -#define VERSION 4 - -/* adjust for these functions for Unicode */ -#if UNICODE -#define _tstrncpy wcsncpy -#define _tstrdup _wcsdup -#define _tfopen _wfopen -#define _sntprintf _snwprintf -#else -#define _tstrncpy strncpy -#define _tstrdup _strdup -#define _tfopen fopen -#define _sntprintf _snprintf +/* make sure this is defined... */ +#ifndef _MAX_ULTOSTR_BASE10_COUNT +#define _MAX_ULTOSTR_BASE10_COUNT (10 + 1) #endif -/* enumerate over this */ -static const enum types types[] = {TYPES_VF, TYPES_VEG}; +/* put all of our types in an array */ +static const enum types types[] = { TYPES_VF, TYPES_VEG }; + +/* HWND ids */ +enum { + OPEN_FILE_BUTTON = 0, + COMBOBOX, + LISTBOX, + SAVE_FILE_BUTTON, + VERSION +}; + +#if UNICODE +/* use COM when `UNICODE=1` to avoid file paths being cut off */ +#include <shobjidl.h> + +static const DWORD COM_INITFLAGS = (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); +#endif + +/* user-adjustable. set these values to whatever you want, the GUI will scale */ +#define WINDOW_WIDTH 225U +#define WINDOW_HEIGHT 200U static LPTSTR file_path = NULL; -static uint8_t version = 13; + +/* these values are loaded by AddControls() if they're valid */ +static uint8_t version = 11; static enum types type = TYPES_VEG; /* we edit this from display_file() */ @@ -243,7 +222,7 @@ #endif /* fallback to OPENFILENAME if COM fucks up for whatever reason (or we're on ANSI)... */ output = calloc(MAX_PATH + 1, sizeof(TCHAR)); - _tstrncpy(output, output_template, MAX_PATH); + _tcsncpy(output, output_template, MAX_PATH); free(output_template); OPENFILENAME ofn = {0}; @@ -298,37 +277,38 @@ WINDOW_WIDTH * 7 / 18, WINDOW_HEIGHT * 3 / 20, WINDOW_WIDTH * 2 / 9, WINDOW_HEIGHT, hWnd, (HMENU)COMBOBOX, NULL, NULL); - static LPCTSTR versions[] = {TEXT("8"), TEXT("9"), TEXT("10"), - TEXT("11"), TEXT("12"), TEXT("13"), - TEXT("14"), TEXT("15"), TEXT("16"), - TEXT("17"), TEXT("18"), TEXT("19"), - TEXT("20"), TEXT("21")}; /* wuss 9+10 */ + for (size_t v = 8; v <= 21; v++) { + TCHAR v_str[_MAX_ULTOSTR_BASE10_COUNT] = {'\0'}; + + _ultot(v, v_str, 10); - for (size_t i = 0; i < ARRAYSIZE(versions); i++) - SendMessage(combobox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)versions[i]); - - SendMessage(combobox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); + LRESULT pos = SendMessage(combobox, CB_ADDSTRING, 0, (LPARAM)v_str); + SendMessage(combobox, CB_SETITEMDATA, pos, v); + if (v == version) + SendMessage(combobox, CB_SETCURSEL, pos, 0); + } /* Type */ HWND listbox = CreateWindow(TEXT("Listbox"), NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, WINDOW_WIDTH * 5 / 18, WINDOW_HEIGHT * 11 / 40, WINDOW_WIDTH * 4 / 9, WINDOW_HEIGHT / 5, hWnd, (HMENU)LISTBOX, NULL, NULL); for (size_t i = 0; i < ARRAYSIZE(types); i++) { LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); - SendMessage(listbox, LB_SETITEMDATA, pos, (LPARAM)types[i]); + SendMessage(listbox, LB_SETITEMDATA, pos, types[i]); if (types[i] == type) - SendMessage(listbox, LB_SETCURSEL, (WPARAM)pos, (LPARAM)0); + SendMessage(listbox, LB_SETCURSEL, pos, 0); } /* Save File */ HWND save_button = CreateWindow(TEXT("Button"), TEXT("Save"), WS_VISIBLE | WS_CHILD, WINDOW_WIDTH * 7 / 18, WINDOW_HEIGHT * 9 / 20, WINDOW_WIDTH * 2 / 9, WINDOW_HEIGHT / 10, hWnd, (HMENU)SAVE_FILE_BUTTON, NULL, NULL); /* Version and Type display */ - hwnd_version = CreateWindow(TEXT("Edit"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_READONLY | ES_CENTER | ES_MULTILINE | SS_CENTER, WINDOW_WIDTH / 6, WINDOW_HEIGHT * 3 / 5, WINDOW_WIDTH * 2 / 3, WINDOW_HEIGHT / 5, hWnd, (HMENU)VERSION, NULL, NULL); + hwnd_version = CreateWindow(TEXT("Edit"), TEXT("No file opened!"), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_READONLY | ES_CENTER | ES_MULTILINE | SS_CENTER, WINDOW_WIDTH / 6, WINDOW_HEIGHT * 3 / 5, WINDOW_WIDTH * 2 / 3, WINDOW_HEIGHT / 5, hWnd, (HMENU)VERSION, NULL, NULL); if (!open_button || !save_button || !listbox || !combobox || !hwnd_version) MessageBox(hWnd, TEXT("how did you even trigger this"), TEXT("GUI could not be initialized!"), MB_ICONEXCLAMATION); } -int CALLBACK SetFont(HWND child, LPARAM font) { +/* Make the fonts not as ugly */ +BOOL CALLBACK SetFont(HWND child, LPARAM font) { SendMessage(child, WM_SETFONT, font, 1); return 1; } @@ -338,12 +318,14 @@ case WM_COMMAND: if (HIWORD(wParam) == CBN_SELCHANGE) { switch (LOWORD(wParam)) { - case COMBOBOX: - version = (uint8_t)(8+SendMessage((HWND)lParam, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0)); + case COMBOBOX: { + LRESULT i = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0); + version = (uint8_t)SendMessage((HWND)lParam, CB_GETITEMDATA, i, 0); break; + } case LISTBOX: { - LRESULT i = SendMessage((HWND)lParam, (UINT)LB_GETCURSEL, (WPARAM)0, (LPARAM)0); - type = (enum types)SendMessage((HWND)lParam, (UINT)LB_GETITEMDATA, (WPARAM)i, (LPARAM)0); + LRESULT i = SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0); + type = (enum types)SendMessage((HWND)lParam, LB_GETITEMDATA, i, 0); break; } default: @@ -366,7 +348,7 @@ break; case WM_CREATE: AddControls(hWnd); - EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT)); + EnumChildWindows(hWnd, SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT)); break; case WM_DESTROY: PostQuitMessage(0);