#ifndef MAPGEN_H_INCLUDED #define MAPGEN_H_INCLUDED #include #include #include #include #include #include #undef protected #include "SimplexNoise.h" #include "fnv.h" #include "kblib/io.h" #include "kblib/stringops.h" enum class spiral { none = -1, logarithmic, archimedian, polynomial, }; inline auto parse_spiral(char c) -> spiral { if (c == 'a') { return spiral::archimedian; } else if (c == 'l') { return spiral::logarithmic; } else if (c == 'n') { return spiral::none; } else if (c == 's') { return spiral::polynomial; } else { return spiral::archimedian; } } template void genMap(std::vector inList); template png::image genMap_impl(unsigned cmapID, spiral archimedian, float xmin, float ymin, float width, int tileSize); using cmap_t = std::vector>; // Parses a file into a set of named palettes cmap_t scan_cmap(std::string maps, std::string sourcename); // Opens file and calls scan_cmap on it inline cmap_t read_cmap(std::string file) { auto maps = kblib::get_file_contents(file); return scan_cmap(maps.value(), file); } // Reads 6-character hexadecimal string into color png::color colorFromHex(std::string& hex); extern const std::string cmaps_default; extern cmap_t current_cmap; // Find map named by query // 1. find exact match // 2. convert query to number unsigned lookupMap(std::string query); class malformed_file_error : public std::runtime_error { public: malformed_file_error(std::string e) : std::runtime_error(e) {} }; bool& verbose(); #include "cmap.h" // Increase by changing the FIRST size parameter of cmap and adding new lines [[deprecated]] static constexpr int numMaps{sizeof(cmap) / sizeof(cmap[0])}; // enum class cmap {Greyscale, Natural, Arctic, Alien, Weird, Ratio, Elevation}; [[deprecated]] static constexpr std::array mapNames{ "Greyscale", "Natural", "Arctic", "Alien", "Weird", "LandRatio", "ElevLines", "ElevColor", "map_8", "map_9", "map_A", "map_B", "map_C", "map_D", "map_E", "Random", }; [[deprecated]] const int Greyscale = 0, Natural = 1, Arctic = 2, Alien = 3, Weird = 4, Ratio = 5, Elevation = 6; [[deprecated]] png::palette genColorMap(int type); #endif // MAPGEN_H_INCLUDED