RigsofRods
Soft-body Physics Simulation
ContentManager.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2018 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
23 
24 #pragma once
25 
26 #include "CacheSystem.h"
27 #include "Application.h"
28 
29 #include <OgreResourceGroupManager.h>
30 #include <OgreScriptCompiler.h>
31 #include <rapidjson/document.h>
32 
33 namespace RoR {
34 
36  public Ogre::ResourceLoadingListener, // Ogre::ResourceGroupManager::getSingleton().setLoadingListener()
37  public Ogre::ScriptCompilerListener // Ogre::ScriptCompilerManager::getSingleton().setListener()
38 {
39 public:
40 
41  struct ResourcePack
42  {
43  ResourcePack(const char* name, const char* resource_group_name):
45  {}
46 
47  static const ResourcePack OGRE_CORE;
48  static const ResourcePack WALLPAPERS;
49  static const ResourcePack AIRFOILS;
50  static const ResourcePack BEAM_OBJECTS;
51  static const ResourcePack CAELUM;
52  static const ResourcePack CUBEMAPS;
53  static const ResourcePack DASHBOARDS;
54  static const ResourcePack FAMICONS;
55  static const ResourcePack FLAGS;
56  static const ResourcePack FONTS;
57  static const ResourcePack HYDRAX;
58  static const ResourcePack ICONS;
59  static const ResourcePack MATERIALS;
60  static const ResourcePack MESHES;
61  static const ResourcePack MYGUI;
62  static const ResourcePack OVERLAYS;
63  static const ResourcePack PAGED;
64  static const ResourcePack PARTICLES;
65  static const ResourcePack PSSM;
66  static const ResourcePack SKYX;
67  static const ResourcePack RTSHADER;
68  static const ResourcePack SCRIPTS;
69  static const ResourcePack SOUNDS;
70  static const ResourcePack TEXTURES;
71 
72  const char* name;
73  const char* resource_group_name;
74  };
75 
78  void AddResourcePack(ResourcePack const& resource_pack, std::string const& override_rgn = "");
79  void InitManagedMaterials(std::string const & rg_name);
80  void InitContentManager();
81  void InitModCache(CacheValidity validity);
82  void LoadGameplayResources();
83  std::string ListAllUserContent();
84  bool DeleteDiskFile(std::string const& filename, std::string const& rg_name);
85 
86  // JSON:
87  bool LoadAndParseJson(std::string const& filename, std::string const& rg_name, rapidjson::Document& j_doc);
88  bool SerializeAndWriteJson(std::string const& filename, std::string const& rg_name, rapidjson::Document& j_doc);
89 
90 private:
91 
92  // Ogre::ResourceLoadingListener
93  Ogre::DataStreamPtr resourceLoading(const Ogre::String& name, const Ogre::String& group, Ogre::Resource* resource) override;
94  void resourceStreamOpened(const Ogre::String& name, const Ogre::String& group, Ogre::Resource* resource, Ogre::DataStreamPtr& dataStream) override;
95  bool resourceCollision(Ogre::Resource* resource, Ogre::ResourceManager* resourceManager) override;
96 
97  // Ogre::ScriptCompilerListener
98  bool handleEvent(Ogre::ScriptCompiler *compiler, Ogre::ScriptCompilerEvent *evt, void *retval) override;
99 
101 };
102 
103 } // namespace RoR
RoR::ContentManager::ResourcePack::HYDRAX
static const ResourcePack HYDRAX
Definition: ContentManager.h:57
RoR::ContentManager::InitContentManager
void InitContentManager()
Definition: ContentManager.cpp:147
RoR::ContentManager::ResourcePack::CUBEMAPS
static const ResourcePack CUBEMAPS
Definition: ContentManager.h:52
RoR::ContentManager::DeleteDiskFile
bool DeleteDiskFile(std::string const &filename, std::string const &rg_name)
Definition: ContentManager.cpp:515
RoR::ContentManager::ResourcePack::WALLPAPERS
static const ResourcePack WALLPAPERS
Definition: ContentManager.h:48
RoR::ContentManager::resourceLoading
Ogre::DataStreamPtr resourceLoading(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource) override
Definition: ContentManager.cpp:318
RoR::ContentManager::InitManagedMaterials
void InitManagedMaterials(std::string const &rg_name)
Definition: ContentManager.cpp:372
RoR::ContentManager::ResourcePack::PAGED
static const ResourcePack PAGED
Definition: ContentManager.h:63
RoR::ContentManager::handleEvent
bool handleEvent(Ogre::ScriptCompiler *compiler, Ogre::ScriptCompilerEvent *evt, void *retval) override
Definition: ContentManager.cpp:339
RoR::ContentManager::resourceCollision
bool resourceCollision(Ogre::Resource *resource, Ogre::ResourceManager *resourceManager) override
Definition: ContentManager.cpp:327
RoR::ContentManager::ResourcePack::CAELUM
static const ResourcePack CAELUM
Definition: ContentManager.h:51
RoR::ContentManager
Definition: ContentManager.h:35
RoR::ContentManager::ResourcePack
Definition: ContentManager.h:41
RoR::ContentManager::SerializeAndWriteJson
bool SerializeAndWriteJson(std::string const &filename, std::string const &rg_name, rapidjson::Document &j_doc)
Definition: ContentManager.cpp:482
RoR::ContentManager::ResourcePack::DASHBOARDS
static const ResourcePack DASHBOARDS
Definition: ContentManager.h:53
RoR::ContentManager::ResourcePack::name
const char * name
Definition: ContentManager.h:72
RoR::ContentManager::ResourcePack::BEAM_OBJECTS
static const ResourcePack BEAM_OBJECTS
Definition: ContentManager.h:50
RoR::ContentManager::ResourcePack::ResourcePack
ResourcePack(const char *name, const char *resource_group_name)
Definition: ContentManager.h:43
CacheSystem.h
A database of user-installed content alias 'mods' (vehicles, terrains...)
RoR::CacheValidity
CacheValidity
Definition: CacheSystem.h:203
RoR::ContentManager::ResourcePack::FLAGS
static const ResourcePack FLAGS
Definition: ContentManager.h:55
RoR::ContentManager::ResourcePack::SCRIPTS
static const ResourcePack SCRIPTS
Definition: ContentManager.h:68
RoR::ContentManager::ResourcePack::AIRFOILS
static const ResourcePack AIRFOILS
Definition: ContentManager.h:49
RoR::ContentManager::ResourcePack::TEXTURES
static const ResourcePack TEXTURES
Definition: ContentManager.h:70
RoR::ContentManager::resourceStreamOpened
void resourceStreamOpened(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource, Ogre::DataStreamPtr &dataStream) override
Definition: ContentManager.cpp:323
RoR::ContentManager::LoadAndParseJson
bool LoadAndParseJson(std::string const &filename, std::string const &rg_name, rapidjson::Document &j_doc)
Definition: ContentManager.cpp:452
Application.h
Central state/object manager and communications hub.
RoR::ContentManager::ResourcePack::MATERIALS
static const ResourcePack MATERIALS
Definition: ContentManager.h:59
RoR::ContentManager::ResourcePack::ICONS
static const ResourcePack ICONS
Definition: ContentManager.h:58
RoR::ContentManager::ResourcePack::PARTICLES
static const ResourcePack PARTICLES
Definition: ContentManager.h:64
RoR::ContentManager::AddResourcePack
void AddResourcePack(ResourcePack const &resource_pack, std::string const &override_rgn="")
Loads resources if not already loaded.
Definition: ContentManager.cpp:98
RoR::ContentManager::ResourcePack::OVERLAYS
static const ResourcePack OVERLAYS
Definition: ContentManager.h:62
RoR::ContentManager::ResourcePack::OGRE_CORE
static const ResourcePack OGRE_CORE
Definition: ContentManager.h:47
RoR::ContentManager::ResourcePack::SOUNDS
static const ResourcePack SOUNDS
Definition: ContentManager.h:69
RoR::ContentManager::LoadGameplayResources
void LoadGameplayResources()
Checks GVar settings and loads required resources.
Definition: ContentManager.cpp:399
RoR::ContentManager::ResourcePack::PSSM
static const ResourcePack PSSM
Definition: ContentManager.h:65
RoR::ContentManager::ResourcePack::resource_group_name
const char * resource_group_name
Definition: ContentManager.h:73
RoR::ContentManager::InitModCache
void InitModCache(CacheValidity validity)
Definition: ContentManager.cpp:248
RoR::ContentManager::ResourcePack::RTSHADER
static const ResourcePack RTSHADER
Definition: ContentManager.h:67
RoR::ContentManager::ResourcePack::SKYX
static const ResourcePack SKYX
Definition: ContentManager.h:66
RoR::ContentManager::ResourcePack::FAMICONS
static const ResourcePack FAMICONS
Definition: ContentManager.h:54
RoR::ContentManager::ResourcePack::MYGUI
static const ResourcePack MYGUI
Definition: ContentManager.h:61
RoR::ContentManager::ListAllUserContent
std::string ListAllUserContent()
Used by ModCache for quick detection of added/removed content.
Definition: ContentManager.cpp:427
RoR::ContentManager::m_base_resource_loaded
bool m_base_resource_loaded
Definition: ContentManager.h:100
RoR
Definition: AppContext.h:36
RoR::ContentManager::ResourcePack::FONTS
static const ResourcePack FONTS
Definition: ContentManager.h:56
RoR::ContentManager::ResourcePack::MESHES
static const ResourcePack MESHES
Definition: ContentManager.h:60