aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/Dataloader.hpp
blob: 67413617e97e78ee060d0305be1748f9d544cedb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once

#include <filesystem>
#include <functional>
#include <vector>

#include "openvic-simulation/dataloader/NodeTools.hpp"

namespace OpenVic {
   namespace fs = std::filesystem;

   struct GameManager;
   struct PopManager;
   struct Map;

   class Dataloader {
   public:
      using path_vector_t = std::vector<fs::path>;

   private:
      path_vector_t roots;

      bool _load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const;
      bool _load_map_dir(GameManager& game_manager, fs::path const& map_directory) const;

   public:
      Dataloader() = default;

      /* In reverse-load order, so base defines first and final loaded mod last */
      bool set_roots(path_vector_t new_roots);

      /* REQUIREMENTS:
       * DAT-24
       */
      fs::path lookup_file(fs::path const& path) const;
      path_vector_t lookup_files_in_dir(fs::path const& path, fs::path const& extension) const;
      bool apply_to_files_in_dir(fs::path const& path, fs::path const& extension,
         NodeTools::callback_t<fs::path const&> callback) const;

      bool load_defines(GameManager& game_manager) const;
      bool load_pop_history(GameManager& game_manager, fs::path const& path) const;

      enum locale_t : size_t {
         English, French, German, Polish, Spanish, Italian, Swedish, Czech, Hungarian, Dutch, Portugese, Russian, Finnish, _LocaleCount
      };
      static constexpr char const* locale_names[_LocaleCount] = {
         "en_GB", "fr_FR", "de_DE", "pl_PL", "es_ES", "it_IT", "sv_SE", "cs_CZ", "hu_HU", "nl_NL", "pt_PT", "ru_RU", "fi_FI"
      };

      /* Args: key, locale, localisation */
      using localisation_callback_t = NodeTools::callback_t<std::string_view, locale_t, std::string_view>;
      bool load_localisation_files(localisation_callback_t callback, fs::path const& localisation_dir = "localisation");
   };
}