MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / XcomResourcePack

Method XcomResourcePack

src/Resource/XcomResourcePack.cpp:79–733  ·  view source on GitHub ↗

* Initializes the resource pack by loading all the resources * contained in the original game folder. * @param extraSprites List of mod extra sprites. * @param extraSounds List of mod extra sounds. */

Source from the content-addressed store, hash-verified

77 * @param extraSounds List of mod extra sounds.
78 */
79XcomResourcePack::XcomResourcePack(std::vector<std::pair<std::string, ExtraSprites *> > extraSprites, std::vector<std::pair<std::string, ExtraSounds *> > extraSounds) : ResourcePack()
80{
81 // Load palettes
82 const char *pal[] = {"PAL_GEOSCAPE", "PAL_BASESCAPE", "PAL_GRAPHS", "PAL_UFOPAEDIA", "PAL_BATTLEPEDIA"};
83 for (size_t i = 0; i < sizeof(pal) / sizeof(pal[0]); ++i)
84 {
85 std::string s = "GEODATA/PALETTES.DAT";
86 _palettes[pal[i]] = new Palette();
87 _palettes[pal[i]]->loadDat(CrossPlatform::getDataFile(s), 256, Palette::palOffset(i));
88 }
89 {
90 std::string s1 = "GEODATA/BACKPALS.DAT";
91 std::string s2 = "BACKPALS.DAT";
92 _palettes[s2] = new Palette();
93 _palettes[s2]->loadDat(CrossPlatform::getDataFile(s1), 128);
94 }
95
96 // Correct Battlescape palette
97 {
98 std::string s1 = "GEODATA/PALETTES.DAT";
99 std::string s2 = "PAL_BATTLESCAPE";
100 _palettes[s2] = new Palette();
101 _palettes[s2]->loadDat(CrossPlatform::getDataFile(s1), 256, Palette::palOffset(4));
102
103 // Last 16 colors are a greyish gradient
104 SDL_Color gradient[] = {{140, 152, 148, 255},
105 {132, 136, 140, 255},
106 {116, 124, 132, 255},
107 {108, 116, 124, 255},
108 {92, 104, 108, 255},
109 {84, 92, 100, 255},
110 {76, 80, 92, 255},
111 {56, 68, 84, 255},
112 {48, 56, 68, 255},
113 {40, 48, 56, 255},
114 {32, 36, 48, 255},
115 {24, 28, 32, 255},
116 {16, 20, 24, 255},
117 {8, 12, 16, 255},
118 {3, 4, 8, 255},
119 {3, 3, 6, 255}};
120 for (size_t i = 0; i < sizeof(gradient)/sizeof(gradient[0]); ++i)
121 {
122 SDL_Color *color = _palettes[s2]->getColors(Palette::backPos + 16 + i);
123 *color = gradient[i];
124 }
125 }
126
127 // Load fonts
128 YAML::Node doc = YAML::LoadFile(CrossPlatform::getDataFile("Language/Font.dat"));
129 Font::setIndex(Language::utf8ToWstr(doc["chars"].as<std::string>()));
130 for (YAML::const_iterator i = doc["fonts"].begin(); i != doc["fonts"].end(); ++i)
131 {
132 std::string id = (*i)["id"].as<std::string>();
133 Font *font = new Font();
134 font->load(*i);
135 _fonts[id] = font;
136 }

Callers

nothing calls this directly

Calls 15

getDataFileFunction · 0.85
getFolderContentsFunction · 0.85
noExtFunction · 0.85
fileExistsFunction · 0.85
ExceptionClass · 0.85
getColorsMethod · 0.80
loadScrMethod · 0.80
setPixelMethod · 0.80
getPixelMethod · 0.80
loadSpkMethod · 0.80
loadImageMethod · 0.80
loadPckMethod · 0.80

Tested by

no test coverage detected