1 /*****************************************************************************
2  * Copyright (c) 2014-2020 OpenRCT2 developers
3  *
4  * For a complete list of all authors, please refer to contributors.md
5  * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
6  *
7  * OpenRCT2 is licensed under the GNU General Public License version 3.
8  *****************************************************************************/
9 
10 #pragma once
11 
12 #include "common.h"
13 
14 #include <memory>
15 #include <string>
16 
17 namespace OpenRCT2
18 {
19     enum class DIRBASE : size_t
20     {
21         RCT1,          // Base directory for original RollerCoaster Tycoon 1 content.
22         RCT2,          // Base directory for original RollerCoaster Tycoon 2 content.
23         OPENRCT2,      // Base directory for OpenRCT2 installation.
24         USER,          // Base directory for OpenRCT2 user content.
25         CONFIG,        // Base directory for OpenRCT2 configuration.
26         CACHE,         // Base directory for OpenRCT2 cache files.
27         DOCUMENTATION, // Base directory for OpenRCT2 doc files.
28     };
29     constexpr size_t DIRBASE_COUNT = 7;
30     using DIRBASE_VALUES = std::string[DIRBASE_COUNT];
31 
32     enum class DIRID
33     {
34         DATA,        // Contains g1.dat, music etc.
35         LANDSCAPE,   // Contains scenario editor landscapes (SC6).
36         LANGUAGE,    // Contains language packs.
37         LOG_CHAT,    // Contains chat logs.
38         LOG_SERVER,  // Contains server logs.
39         NETWORK_KEY, // Contains the user's public and private keys.
40         OBJECT,      // Contains objects.
41         PLUGIN,      // Contains plugins (.js).
42         SAVE,        // Contains saved games (SV6).
43         SCENARIO,    // Contains scenarios (SC6).
44         SCREENSHOT,  // Contains screenshots.
45         SEQUENCE,    // Contains title sequences.
46         SHADER,      // Contains OpenGL shaders.
47         THEME,       // Contains interface themes.
48         TRACK,       // Contains track designs.
49         HEIGHTMAP,   // Contains heightmap data.
50         REPLAY,      // Contains recorded replays.
51         LOG_DESYNCS, // Contains desync reports.
52         CRASH,       // Contains crash dumps.
53     };
54 
55     enum class PATHID
56     {
57         CONFIG,                  // Main configuration (config.ini).
58         CONFIG_SHORTCUTS_LEGACY, // Old keyboard shortcuts (hotkeys.cfg)
59         CONFIG_SHORTCUTS,        // Shortcut bindings (shortcuts.json)
60         CACHE_OBJECTS,           // Object repository cache (objects.idx).
61         CACHE_TRACKS,            // Track repository cache (tracks.idx).
62         CACHE_SCENARIOS,         // Scenario repository cache (scenarios.idx).
63         MP_DAT,                  // Mega Park data, Steam RCT1 only (\RCTdeluxe_install\Data\mp.dat)
64         NETWORK_GROUPS,          // Server groups with permissions (groups.json).
65         NETWORK_SERVERS,         // Saved servers (servers.cfg).
66         NETWORK_USERS,           // Users and their groups (users.json).
67         SCORES,                  // Scenario scores (highscores.dat).
68         SCORES_LEGACY,           // Scenario scores, legacy (scores.dat).
69         SCORES_RCT2,             // Scenario scores, rct2 (\Saved Games\scores.dat).
70         CHANGELOG,               // Notable changes to the game between versions, distributed with the game.
71         PLUGIN_STORE,            // Shared storage for plugins.
72     };
73 
74     /**
75      * Interface for retrieving paths and other environment related things.
76      */
77     struct IPlatformEnvironment
78     {
79         virtual ~IPlatformEnvironment() = default;
80 
81         virtual std::string GetDirectoryPath(DIRBASE base) const abstract;
82         virtual std::string GetDirectoryPath(DIRBASE base, DIRID did) const abstract;
83         virtual std::string GetFilePath(PATHID pathid) const abstract;
84         virtual void SetBasePath(DIRBASE base, const std::string& path) abstract;
85     };
86 
87     [[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment(DIRBASE_VALUES basePaths);
88     [[nodiscard]] std::unique_ptr<IPlatformEnvironment> CreatePlatformEnvironment();
89 
90 } // namespace OpenRCT2
91