diff options
author | Cameron Cawley | 2020-01-02 21:23:35 +0000 |
---|---|---|
committer | Filippos Karapetis | 2020-01-11 17:34:12 +0200 |
commit | aa9a41545ad331acb37dde0790adfa8298b1f8b5 (patch) | |
tree | 6a962b560dc6bf29658b5e97c02c0c685e493601 /devtools | |
parent | 46056aba3ca7d9f51833b1a5154f8a9cc371f340 (diff) | |
download | scummvm-rg350-aa9a41545ad331acb37dde0790adfa8298b1f8b5.tar.gz scummvm-rg350-aa9a41545ad331acb37dde0790adfa8298b1f8b5.tar.bz2 scummvm-rg350-aa9a41545ad331acb37dde0790adfa8298b1f8b5.zip |
COMMON: Add a common base class for the Windows resource classes
Diffstat (limited to 'devtools')
-rw-r--r-- | devtools/create_titanic/winexe.cpp | 14 | ||||
-rw-r--r-- | devtools/create_titanic/winexe.h | 35 | ||||
-rw-r--r-- | devtools/create_titanic/winexe_pe.cpp | 14 | ||||
-rw-r--r-- | devtools/create_titanic/winexe_pe.h | 4 |
4 files changed, 51 insertions, 16 deletions
diff --git a/devtools/create_titanic/winexe.cpp b/devtools/create_titanic/winexe.cpp index c23bd84a89..49be23dbd4 100644 --- a/devtools/create_titanic/winexe.cpp +++ b/devtools/create_titanic/winexe.cpp @@ -80,4 +80,18 @@ String WinResourceID::toString() const { return ""; } +bool WinResources::loadFromEXE(const String &fileName) { + if (fileName.empty()) + return false; + + File *file = new File(); + + if (!file->open(fileName.c_str())) { + delete file; + return false; + } + + return loadFromEXE(file); +} + } // End of namespace Common diff --git a/devtools/create_titanic/winexe.h b/devtools/create_titanic/winexe.h index 102f1494fd..6bfe2a25a0 100644 --- a/devtools/create_titanic/winexe.h +++ b/devtools/create_titanic/winexe.h @@ -23,6 +23,7 @@ #ifndef COMMON_WINEXE_H #define COMMON_WINEXE_H +#include "file.h" #include "hash-str.h" #include "str.h" @@ -90,6 +91,40 @@ struct WinResourceID_EqualTo { bool operator()(const WinResourceID &id1, const WinResourceID &id2) const { return id1 == id2; } }; +/** + * A class able to load resources from a Windows Executable, such + * as cursors, bitmaps, and sounds. + */ +class WinResources { +public: + virtual ~WinResources() {} + + /** Clear all information. */ + virtual void clear() = 0; + + /** Load from an EXE file. */ + virtual bool loadFromEXE(const String &fileName); + + virtual bool loadFromEXE(File *stream) = 0; + + /** Return a list of IDs for a given type. */ + virtual const Array<WinResourceID> getIDList(const WinResourceID &type) const = 0; + + /** Return a list of languages for a given type and ID. */ + virtual const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const { + Array<WinResourceID> array; + return array; + }; + + /** Return a stream to the specified resource, taking the first language found (or 0 if non-existent). */ + virtual File *getResource(const WinResourceID &type, const WinResourceID &id) = 0; + + /** Return a stream to the specified resource (or 0 if non-existent). */ + virtual File *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) { + return getResource(type, id); + } +}; + } // End of namespace Common #endif diff --git a/devtools/create_titanic/winexe_pe.cpp b/devtools/create_titanic/winexe_pe.cpp index 9d35f592fc..f55740f692 100644 --- a/devtools/create_titanic/winexe_pe.cpp +++ b/devtools/create_titanic/winexe_pe.cpp @@ -44,20 +44,6 @@ void PEResources::clear() { delete _exe; _exe = 0; } -bool PEResources::loadFromEXE(const String &fileName) { - if (fileName.empty()) - return false; - - File *file = new File(); - - if (!file->open(fileName.c_str())) { - delete file; - return false; - } - - return loadFromEXE(file); -} - bool PEResources::loadFromEXE(File *stream) { clear(); diff --git a/devtools/create_titanic/winexe_pe.h b/devtools/create_titanic/winexe_pe.h index f72b6fbb04..6ab7ae847a 100644 --- a/devtools/create_titanic/winexe_pe.h +++ b/devtools/create_titanic/winexe_pe.h @@ -38,7 +38,7 @@ class SeekableReadStream; * A class able to load resources from a Windows Portable Executable, such * as cursors, bitmaps, and sounds. */ -class PEResources { +class PEResources : WinResources { public: PEResources(); ~PEResources(); @@ -47,7 +47,7 @@ public: void clear(); /** Load from an EXE file. */ - bool loadFromEXE(const String &fileName); + using WinResources::loadFromEXE; bool loadFromEXE(File *stream); |