mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-07 09:14:11 +00:00
Merge pull request #31 from lordhoto/win-res
Embed engine/theme dists files into Win Executable. Check the following link for further discussion: https://github.com/scummvm/scummvm/pull/31
This commit is contained in:
commit
cf43b51f67
@ -63,14 +63,15 @@ endif
|
||||
ifneq ($(findstring $(MAKEFLAGS),s),s)
|
||||
ifneq ($(VERBOSE_BUILD),1)
|
||||
ifneq ($(VERBOSE_BUILD),yes)
|
||||
QUIET_CXX = @echo ' ' C++ ' ' $@;
|
||||
QUIET_AS = @echo ' ' AS ' ' $@;
|
||||
QUIET_NASM = @echo ' ' NASM ' ' $@;
|
||||
QUIET_AR = @echo ' ' AR ' ' $@;
|
||||
QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
|
||||
QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@;
|
||||
QUIET_LINK = @echo ' ' LINK ' ' $@;
|
||||
QUIET = @
|
||||
QUIET_CXX = @echo ' ' C++ ' ' $@;
|
||||
QUIET_AS = @echo ' ' AS ' ' $@;
|
||||
QUIET_NASM = @echo ' ' NASM ' ' $@;
|
||||
QUIET_AR = @echo ' ' AR ' ' $@;
|
||||
QUIET_RANLIB = @echo ' ' RANLIB ' ' $@;
|
||||
QUIET_PLUGIN = @echo ' ' PLUGIN ' ' $@;
|
||||
QUIET_LINK = @echo ' ' LINK ' ' $@;
|
||||
QUIET_WINDRES = @echo ' ' WINDRES '' $@;
|
||||
QUIET = @
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "backends/platform/sdl/win32/win32.h"
|
||||
#include "backends/fs/windows/windows-fs-factory.h"
|
||||
|
||||
#include "common/memstream.h"
|
||||
|
||||
#define DEFAULT_CONFIG_FILE "scummvm.ini"
|
||||
|
||||
//#define HIDE_CONSOLE
|
||||
@ -170,4 +172,88 @@ Common::WriteStream *OSystem_Win32::createLogFile() {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class Win32ResourceArchive : public Common::Archive {
|
||||
friend BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam);
|
||||
public:
|
||||
Win32ResourceArchive();
|
||||
|
||||
virtual bool hasFile(const Common::String &name);
|
||||
virtual int listMembers(Common::ArchiveMemberList &list);
|
||||
virtual Common::ArchiveMemberPtr getMember(const Common::String &name);
|
||||
virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
|
||||
private:
|
||||
typedef Common::List<Common::String> FilenameList;
|
||||
|
||||
FilenameList _files;
|
||||
};
|
||||
|
||||
BOOL CALLBACK EnumResNameProc(HMODULE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG_PTR lParam) {
|
||||
if (IS_INTRESOURCE(lpszName))
|
||||
return TRUE;
|
||||
|
||||
Win32ResourceArchive *arch = (Win32ResourceArchive *)lParam;
|
||||
arch->_files.push_back(lpszName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Win32ResourceArchive::Win32ResourceArchive() {
|
||||
EnumResourceNames(NULL, MAKEINTRESOURCE(256), &EnumResNameProc, (LONG_PTR)this);
|
||||
}
|
||||
|
||||
bool Win32ResourceArchive::hasFile(const Common::String &name) {
|
||||
for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) {
|
||||
if (i->equalsIgnoreCase(name))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) {
|
||||
int count = 0;
|
||||
|
||||
for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i, ++count)
|
||||
list.push_back(Common::ArchiveMemberPtr(new Common::GenericArchiveMember(*i, this)));
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) {
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *Win32ResourceArchive::createReadStreamForMember(const Common::String &name) const {
|
||||
HRSRC resource = FindResource(NULL, name.c_str(), MAKEINTRESOURCE(256));
|
||||
|
||||
if (resource == NULL)
|
||||
return 0;
|
||||
|
||||
HGLOBAL handle = LoadResource(NULL, resource);
|
||||
|
||||
if (handle == NULL)
|
||||
return 0;
|
||||
|
||||
const byte *data = (const byte *)LockResource(handle);
|
||||
|
||||
if (data == NULL)
|
||||
return 0;
|
||||
|
||||
uint32 size = SizeofResource(NULL, resource);
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
return new Common::MemoryReadStream(data, size);
|
||||
}
|
||||
|
||||
} // End of anonymous namespace
|
||||
|
||||
void OSystem_Win32::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||
s.add("Win32Res", new Win32ResourceArchive());
|
||||
|
||||
OSystem_SDL::addSysArchivesToSearchSet(s, priority);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,6 +32,7 @@ class OSystem_Win32 : public OSystem_SDL {
|
||||
public:
|
||||
virtual void init();
|
||||
|
||||
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
|
||||
protected:
|
||||
virtual Common::String getDefaultConfigFileName();
|
||||
virtual Common::WriteStream *createLogFile();
|
||||
|
2
configure
vendored
2
configure
vendored
@ -1639,7 +1639,7 @@ case $_host_os in
|
||||
mingw*)
|
||||
DEFINES="$DEFINES -DWIN32 -D__USE_MINGW_ANSI_STDIO=0"
|
||||
LIBS="$LIBS -lmingw32 -lwinmm"
|
||||
OBJS="$OBJS scummvmico.o"
|
||||
OBJS="$OBJS scummvmwinres.o"
|
||||
add_line_to_config_mk 'WIN32 = 1'
|
||||
;;
|
||||
mint*)
|
||||
|
@ -340,7 +340,6 @@ void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits,
|
||||
"\t\t\t<EntryPointSymbol>WinMainCRTStartup</EntryPointSymbol>\n"
|
||||
"\t\t</Link>\n"
|
||||
"\t\t<ResourceCompile>\n"
|
||||
"\t\t\t<PreprocessorDefinitions>HAS_INCLUDE_SET;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n"
|
||||
"\t\t\t<AdditionalIncludeDirectories>" << prefix << ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n"
|
||||
"\t\t</ResourceCompile>\n"
|
||||
"\t</ItemDefinitionGroup>\n"
|
||||
|
@ -240,7 +240,6 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b
|
||||
"\t/>\n"
|
||||
"\t<Tool\n"
|
||||
"\t\tName=\"VCResourceCompilerTool\"\n"
|
||||
"\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n"
|
||||
"\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n"
|
||||
"\t/>\n"
|
||||
"</VisualStudioPropertySheet>\n";
|
||||
|
@ -1,9 +1,47 @@
|
||||
#include "winresrc.h"
|
||||
|
||||
#if defined (__MINGW32__) || defined(__CYGWIN32__) || defined(HAS_INCLUDE_SET)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define FILE 256
|
||||
|
||||
IDI_ICON ICON DISCARDABLE "icons/scummvm.ico"
|
||||
#else
|
||||
IDI_ICON ICON DISCARDABLE "../../icons/scummvm.ico"
|
||||
|
||||
scummmodern.zip FILE "gui/themes/scummmodern.zip"
|
||||
#ifdef USE_TRANSLATION
|
||||
translations.dat FILE "gui/themes/translations.dat"
|
||||
#endif
|
||||
|
||||
#if ENABLE_DRASCULA == STATIC_PLUGIN
|
||||
drascula.dat FILE "dists/engine-data/drascula.dat"
|
||||
#endif
|
||||
#if ENABLE_HUGO == STATIC_PLUGIN
|
||||
hugo.dat FILE "dists/engine-data/hugo.dat"
|
||||
#endif
|
||||
#if ENABLE_KYRA == STATIC_PLUGIN
|
||||
kyra.dat FILE "dists/engine-data/kyra.dat"
|
||||
#endif
|
||||
#if ENABLE_LURE == STATIC_PLUGIN
|
||||
lure.dat FILE "dists/engine-data/lure.dat"
|
||||
#endif
|
||||
#if ENABLE_M4 == STATIC_PLUGIN
|
||||
m4.dat FILE "dists/engine-data/m4.dat"
|
||||
#endif
|
||||
#if ENABLE_QUEEN == STATIC_PLUGIN
|
||||
queen.tbl FILE "dists/engine-data/queen.tbl"
|
||||
#endif
|
||||
#if ENABLE_SKY == STATIC_PLUGIN
|
||||
sky.cpt FILE "dists/engine-data/sky.cpt"
|
||||
#endif
|
||||
#if ENABLE_TEENAGENT == STATIC_PLUGIN
|
||||
teenagent.dat FILE "dists/engine-data/teenagent.dat"
|
||||
#endif
|
||||
#if ENABLE_TOON == STATIC_PLUGIN
|
||||
toon.dat FILE "dists/engine-data/toon.dat"
|
||||
#endif
|
||||
#if ENABLE_AGI == STATIC_PLUGIN
|
||||
pred.dic FILE "dists/pred.dic"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
|
@ -1,9 +1,47 @@
|
||||
#include "winresrc.h"
|
||||
|
||||
#if defined (__MINGW32__) || defined(__CYGWIN32__) || defined(HAS_INCLUDE_SET)
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define FILE 256
|
||||
|
||||
IDI_ICON ICON DISCARDABLE "icons/scummvm.ico"
|
||||
#else
|
||||
IDI_ICON ICON DISCARDABLE "../../icons/scummvm.ico"
|
||||
|
||||
scummmodern.zip FILE "gui/themes/scummmodern.zip"
|
||||
#ifdef USE_TRANSLATION
|
||||
translations.dat FILE "gui/themes/translations.dat"
|
||||
#endif
|
||||
|
||||
#if ENABLE_DRASCULA == STATIC_PLUGIN
|
||||
drascula.dat FILE "dists/engine-data/drascula.dat"
|
||||
#endif
|
||||
#if ENABLE_HUGO == STATIC_PLUGIN
|
||||
hugo.dat FILE "dists/engine-data/hugo.dat"
|
||||
#endif
|
||||
#if ENABLE_KYRA == STATIC_PLUGIN
|
||||
kyra.dat FILE "dists/engine-data/kyra.dat"
|
||||
#endif
|
||||
#if ENABLE_LURE == STATIC_PLUGIN
|
||||
lure.dat FILE "dists/engine-data/lure.dat"
|
||||
#endif
|
||||
#if ENABLE_M4 == STATIC_PLUGIN
|
||||
m4.dat FILE "dists/engine-data/m4.dat"
|
||||
#endif
|
||||
#if ENABLE_QUEEN == STATIC_PLUGIN
|
||||
queen.tbl FILE "dists/engine-data/queen.tbl"
|
||||
#endif
|
||||
#if ENABLE_SKY == STATIC_PLUGIN
|
||||
sky.cpt FILE "dists/engine-data/sky.cpt"
|
||||
#endif
|
||||
#if ENABLE_TEENAGENT == STATIC_PLUGIN
|
||||
teenagent.dat FILE "dists/engine-data/teenagent.dat"
|
||||
#endif
|
||||
#if ENABLE_TOON == STATIC_PLUGIN
|
||||
toon.dat FILE "dists/engine-data/toon.dat"
|
||||
#endif
|
||||
#if ENABLE_AGI == STATIC_PLUGIN
|
||||
pred.dic FILE "dists/pred.dic"
|
||||
#endif
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
|
4
ports.mk
4
ports.mk
@ -161,8 +161,8 @@ osxsnap: bundle
|
||||
# Windows specific
|
||||
#
|
||||
|
||||
scummvmico.o: $(srcdir)/icons/scummvm.ico
|
||||
$(WINDRES) $(WINDRESFLAGS) -I$(srcdir) $(srcdir)/dists/scummvm.rc scummvmico.o
|
||||
scummvmwinres.o: $(srcdir)/icons/scummvm.ico $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(srcdir)/dists/scummvm.rc
|
||||
$(QUIET_WINDRES)$(WINDRES) -DHAVE_CONFIG_H $(WINDRESFLAGS) $(DEFINES) -I. -I$(srcdir) $(srcdir)/dists/scummvm.rc scummvmwinres.o
|
||||
|
||||
# Special target to create a win32 snapshot binary
|
||||
win32dist: $(EXECUTABLE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user