From fc4c6ca7f06ee622829a1560a43336bf23ec3005 Mon Sep 17 00:00:00 2001 From: JAJames Date: Mon, 1 Feb 2016 01:24:59 -0500 Subject: [PATCH] Initial commit --- Rx_SetStartupMovie.sln | 28 ++++ Rx_SetStartupMovie/Rx_SetStartupMovie.c | 115 +++++++++++++++++ Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj | 121 ++++++++++++++++++ .../Rx_SetStartupMovie.vcxproj.filters | 22 ++++ 4 files changed, 286 insertions(+) create mode 100644 Rx_SetStartupMovie.sln create mode 100644 Rx_SetStartupMovie/Rx_SetStartupMovie.c create mode 100644 Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj create mode 100644 Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj.filters diff --git a/Rx_SetStartupMovie.sln b/Rx_SetStartupMovie.sln new file mode 100644 index 0000000..0cbdfd0 --- /dev/null +++ b/Rx_SetStartupMovie.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Rx_SetStartupMovie", "Rx_SetStartupMovie\Rx_SetStartupMovie.vcxproj", "{1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Debug|x64.ActiveCfg = Debug|x64 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Debug|x64.Build.0 = Debug|x64 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Debug|x86.ActiveCfg = Debug|Win32 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Debug|x86.Build.0 = Debug|Win32 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Release|x64.ActiveCfg = Release|x64 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Release|x64.Build.0 = Release|x64 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Release|x86.ActiveCfg = Release|Win32 + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Rx_SetStartupMovie/Rx_SetStartupMovie.c b/Rx_SetStartupMovie/Rx_SetStartupMovie.c new file mode 100644 index 0000000..f938fa3 --- /dev/null +++ b/Rx_SetStartupMovie/Rx_SetStartupMovie.c @@ -0,0 +1,115 @@ +/** + * Copyright (C) 2016 Jessica James. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Written by Jessica James + */ + +#define _CRT_SECURE_NO_WARNINGS + +#include // wcstombs +#include // wchar_t, wcscmp +#include // fopen, fclose, rename +#include // strcpy + +/** Directory that movies are stored in */ +#define MOVIES_DIRECTORY "..\\..\\..\\UDKGame\\Movies\\" + + /** Movie file extension */ +#define MOVIE_FILE_EXTENSION ".bik" +const char movie_file_extension[] = MOVIE_FILE_EXTENSION; + +/** Name of the movie which is loaded by UDK */ +const char movie_filename[] = MOVIES_DIRECTORY "UDKFrontEnd.udk_loading" MOVIE_FILE_EXTENSION; + +/** Prefix of the loading screens which we are to use */ +const char movie_prefix[] = MOVIES_DIRECTORY "LoadingScreen_"; + +__declspec(dllexport) void SetStartupMovie(wchar_t *in_leaving_level, wchar_t *in_loading_level) +{ + FILE *file; + size_t leaving_level_length; + size_t loading_level_length; + char leaving_level[256]; + char loading_level[256]; + char loading_level_movie_filename[256]; + char leaving_level_movie_filename[256]; + + if (wcscmp(in_leaving_level, in_loading_level) == 0) + return; // Nothing to change. + + // Copy inputs to character arrays (interactions with files require this) + leaving_level_length = wcstombs(leaving_level, in_leaving_level, sizeof(leaving_level)); + loading_level_length = wcstombs(loading_level, in_loading_level, sizeof(loading_level)); + + // Ensure that our strings are null-terminated + if (leaving_level_length == sizeof(leaving_level)) + --leaving_level_length; + leaving_level[leaving_level_length] = '\0'; + + if (loading_level_length == sizeof(loading_level)) + --loading_level_length; + loading_level[loading_level_length] = '\0'; + + // Ensure that our strings are null-terminated + leaving_level[sizeof(leaving_level) / sizeof(char) - 1] = '\0'; + loading_level[sizeof(loading_level) / sizeof(char) - 1] = '\0'; + + strcpy(loading_level_movie_filename, movie_prefix); + strcpy(loading_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1, loading_level); + strcpy(loading_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1 + loading_level_length, movie_file_extension); + + file = fopen(loading_level_movie_filename, "rb"); + if (file != NULL) // level-specific movie exists; move it into place + { + fclose(file); + + // check if default movie is in position + file = fopen(movie_prefix, "rb"); + if (file != NULL) + { + fclose(file); + + // A level-specific movie is currently in position; move it + strcpy(leaving_level_movie_filename, movie_prefix); + strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1, leaving_level); + strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1 + leaving_level_length, movie_file_extension); + rename(movie_filename, leaving_level_movie_filename); + } + else // The default movie is currently in position; move it. + rename(movie_filename, movie_prefix); + + // Move level-specific movie into place + rename(loading_level_movie_filename, movie_filename); + } + else // level-specific movie doesn't exist; ensure that current movie is default + { + // check if default movie is in position + file = fopen(movie_prefix, "rb"); + if (file != NULL) + { + fclose(file); + + // A level-specific movie is currently in position; move it + strcpy(leaving_level_movie_filename, movie_prefix); + strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1, leaving_level); + strcpy(leaving_level_movie_filename + sizeof(movie_prefix) / sizeof(char) - 1 + leaving_level_length, movie_file_extension); + rename(movie_filename, leaving_level_movie_filename); + + // Move the default movie into position + rename(movie_prefix, movie_filename); + } + // else // Default movie is already in position; nothing to do + } +} diff --git a/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj b/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj new file mode 100644 index 0000000..845e792 --- /dev/null +++ b/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {1DEF81B5-47F8-4028-90CC-0915FF7FBA8D} + Rx_SetStartupMovie + 8.1 + + + + DynamicLibrary + true + v140 + MultiByte + true + + + DynamicLibrary + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Full + true + MultiThreaded + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + MultiThreaded + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + \ No newline at end of file diff --git a/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj.filters b/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj.filters new file mode 100644 index 0000000..af0d8df --- /dev/null +++ b/Rx_SetStartupMovie/Rx_SetStartupMovie.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file