Skip to content

Commit

Permalink
Merge branch 'game_setup'
Browse files Browse the repository at this point in the history
# Conflicts:
#	install/i18n/darkradiant.pot
#	install/i18n/de/LC_MESSAGES/darkradiant.mo
#	install/i18n/de/LC_MESSAGES/darkradiant.po
#	tools/i18n/darkradiant.pot
#	tools/xcode/DarkRadiant.xcodeproj/project.pbxproj
  • Loading branch information
codereader committed Dec 10, 2017
2 parents e1d0009 + 6f7b858 commit ef56bbf
Show file tree
Hide file tree
Showing 47 changed files with 2,226 additions and 1,059 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -59,3 +59,4 @@ Makefile.in
/tools/msvc/DarkRadiant.VC.db
/tools/innosetup/*.zip
/tools/lwo_analyse/.vs
/radiant/*.aps
89 changes: 59 additions & 30 deletions include/ifilesystem.h
Expand Up @@ -8,7 +8,10 @@

#include <cstddef>
#include <string>
#include <list>
#include <set>
#include <functional>
#include <algorithm>

#include "imodule.h"

Expand All @@ -18,9 +21,25 @@ class ArchiveTextFile;
typedef std::shared_ptr<ArchiveTextFile> ArchiveTextFilePtr;
class Archive;

class ModuleObserver;
namespace vfs
{

const std::string MODULE_VIRTUALFILESYSTEM("VirtualFileSystem");
// Extension of std::list to check for existing paths before inserting new ones
class SearchPaths :
public std::list<std::string>
{
public:
bool insertIfNotExists(const std::string& path)
{
if (std::find(begin(), end(), path) != end())
{
return false;
}

push_back(path);
return true;
}
};

/**
* Main interface for the virtual filesystem.
Expand All @@ -36,20 +55,22 @@ class VirtualFileSystem :
public RegisterableModule
{
public:
virtual ~VirtualFileSystem() {}

// Functor taking the filename as argument. The filename is relative
// to the base path passed to the GlobalFileSystem().foreach*() method.
typedef std::function<void (const std::string& filename)> VisitorFunc;
// to the base path passed to the GlobalFileSystem().foreach*() method.
typedef std::function<void(const std::string& filename)> VisitorFunc;

/**
* Interface for VFS observers.
*
* A VFS observer is automatically notified of events relating to the
* VFS, including startup and shutdown.
*/
class Observer {
class Observer
{
public:
virtual ~Observer() {}
virtual ~Observer() {}

/**
* Notification of VFS initialisation.
Expand All @@ -72,9 +93,10 @@ class VirtualFileSystem :
/// Called before \c initialise.
virtual void initDirectory(const std::string& path) = 0;

/// \brief Initialises the filesystem.
/// Called after all root search paths have been added.
virtual void initialise() = 0;
typedef std::set<std::string> ExtensionSet;

// Initialises the filesystem using the given search order.
virtual void initialise(const SearchPaths& vfsSearchPaths, const ExtensionSet& allowedArchiveExtensions) = 0;

/// \brief Shuts down the filesystem.
virtual void shutdown() = 0;
Expand All @@ -90,45 +112,52 @@ class VirtualFileSystem :
// greebo: Note: expects the filename to be normalised (forward slashes, trailing slash).
virtual ArchiveFilePtr openFile(const std::string& filename) = 0;

/// \brief Returns the file identified by \p filename opened in binary mode, or 0 if not found.
// This is a variant of openFile taking an absolute path as argument.
virtual ArchiveFilePtr openFileInAbsolutePath(const std::string& filename) = 0;
/// \brief Returns the file identified by \p filename opened in binary mode, or 0 if not found.
// This is a variant of openFile taking an absolute path as argument.
virtual ArchiveFilePtr openFileInAbsolutePath(const std::string& filename) = 0;

/// \brief Returns the file identified by \p filename opened in text mode, or 0 if not found.
virtual ArchiveTextFilePtr openTextFile(const std::string& filename) = 0;

/// \brief Returns the file identified by \p filename opened in text mode, or NULL if not found.
/// This is a variant of openTextFile taking an absolute path as argument.
virtual ArchiveTextFilePtr openTextFileInAbsolutePath(const std::string& filename) = 0;
/// \brief Returns the file identified by \p filename opened in text mode, or NULL if not found.
/// This is a variant of openTextFile taking an absolute path as argument.
virtual ArchiveTextFilePtr openTextFileInAbsolutePath(const std::string& filename) = 0;

/// \brief Calls the visitor function for each file under \p basedir matching \p extension.
/// Use "*" as \p extension to match all file extensions.
virtual void forEachFile(const std::string& basedir,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) = 0;

// Similar to forEachFile, this routine traverses an absolute path
// searching for files matching a certain extension and invoking
// the givne visitor functor on each occurrence.
virtual void forEachFileInAbsolutePath(const std::string& path,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) = 0;
virtual void forEachFile(const std::string& basedir,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) = 0;

// Similar to forEachFile, this routine traverses an absolute path
// searching for files matching a certain extension and invoking
// the givne visitor functor on each occurrence.
virtual void forEachFileInAbsolutePath(const std::string& path,
const std::string& extension,
const VisitorFunc& visitorFunc,
std::size_t depth = 1) = 0;

/// \brief Returns the absolute filename for a relative \p name, or "" if not found.
virtual std::string findFile(const std::string& name) = 0;

/// \brief Returns the filesystem root for an absolute \p name, or "" if not found.
/// This can be used to convert an absolute name to a relative name.
virtual std::string findRoot(const std::string& name) = 0;

// Returns the list of registered VFS paths, ordered by search priority
virtual const SearchPaths& getVfsSearchPaths() = 0;
};

inline VirtualFileSystem& GlobalFileSystem()
}

const char* const MODULE_VIRTUALFILESYSTEM("VirtualFileSystem");

inline vfs::VirtualFileSystem& GlobalFileSystem()
{
// Cache the reference locally
static VirtualFileSystem& _vfs(
*std::static_pointer_cast<VirtualFileSystem>(
static vfs::VirtualFileSystem& _vfs(
*std::static_pointer_cast<vfs::VirtualFileSystem>(
module::GlobalModuleRegistry().getModule(MODULE_VIRTUALFILESYSTEM)
)
);
Expand Down
26 changes: 14 additions & 12 deletions include/igame.h
@@ -1,12 +1,18 @@
#ifndef IGAMEMANAGER_H_
#define IGAMEMANAGER_H_
#pragma once

#include "xmlutil/Node.h"
#include "imodule.h"
#include <list>

// String identifier for the game manager module
const std::string MODULE_GAMEMANAGER("GameManager");
const char* const MODULE_GAMEMANAGER("GameManager");

const char* const RKEY_GAME_TYPE = "user/game/type";
const char* const RKEY_FS_GAME = "user/game/fs_game";
const char* const RKEY_FS_GAME_BASE = "user/game/fs_game_base";
const char* const RKEY_ENGINE_PATH = "user/paths/enginePath";
const char* const RKEY_MOD_PATH = "user/paths/modPath";
const char* const RKEY_MOD_BASE_PATH = "user/paths/modBasePath";

namespace game
{
Expand Down Expand Up @@ -61,12 +67,6 @@ class IGameManager :
// engine path is returned, e.g. /usr/local/doom3 or c:\games\doom3
virtual std::string getUserEnginePath() = 0;

// Returns the setting for fs_game
virtual const std::string& getFSGame() const = 0;

// Returns the setting for fs_game_base (can be empty)
virtual const std::string& getFSGameBase() const = 0;

/**
* greebo: Gets the mod path (e.g. ~/.doom3/gathers/).
* Returns the mod base path if the mod path itself is empty.
Expand All @@ -89,13 +89,17 @@ class IGameManager :
// Returns the list of ordered engine paths, which should
// be initialised by the Virtual Filesystem (in this exact order)
virtual const PathList& getVFSSearchPaths() const = 0;

typedef std::vector<IGamePtr> GameList;
virtual const GameList& getSortedGameList() = 0;
};
typedef std::shared_ptr<IGameManager> IGameManagerPtr;

} // namespace game

// This is the accessor for the game manager
inline game::IGameManager& GlobalGameManager() {
inline game::IGameManager& GlobalGameManager()
{
// Cache the reference locally
static game::IGameManager& _gameManager(
*std::static_pointer_cast<game::IGameManager>(
Expand All @@ -104,5 +108,3 @@ inline game::IGameManager& GlobalGameManager() {
);
return _gameManager;
}

#endif /*IGAMEMANAGER_H_*/
1 change: 0 additions & 1 deletion include/imodule.h
Expand Up @@ -25,7 +25,6 @@ const char* const RKEY_APP_PATH = "user/paths/appPath";
const char* const RKEY_HOME_PATH = "user/paths/homePath";
const char* const RKEY_SETTINGS_PATH = "user/paths/settingsPath";
const char* const RKEY_BITMAPS_PATH = "user/paths/bitmapsPath";
const char* const RKEY_ENGINE_PATH = "user/paths/enginePath";
const char* const RKEY_MAP_PATH = "user/paths/mapPath";
const char* const RKEY_PREFAB_PATH = "user/paths/prefabPath";

Expand Down
6 changes: 6 additions & 0 deletions install/games/darkmod.game
Expand Up @@ -22,6 +22,12 @@
registryKey="SOFTWARE\id\Doom 3"
registryValue="InstallPath"
>
<!-- Settings used by the Game Setup Dialog -->
<gameSetup>
<dialog type="TDM" /><!-- Indicates the TDM-style setup dialog showing options for engine path and mission -->
<missionFolder value="fms/" />
</gameSetup>

<!-- Types of resource files which are used by this game -->
<filetypes>
<texture>
Expand Down

0 comments on commit ef56bbf

Please sign in to comment.