Prepare for Android

This commit is contained in:
Vladislav Khorev 2018-07-14 15:49:31 +05:00
parent 2c8440db52
commit 7d411110a6
3 changed files with 22 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -20,9 +20,9 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
menuScale = scale; menuScale = scale;
/*...Read ptree from config...*/ /*...Read ptree from config...*/
std::string res_path = "../../../assets/";
boost::property_tree::ptree config_pt; boost::property_tree::ptree config_pt = SE::ReadJsonFile(ST::PathToResources + config_json);
boost::property_tree::json_parser::read_json(res_path + config_json, config_pt); //boost::property_tree::json_parser::read_json(res_path + config_json, config_pt);
/*..error ptree..*/ /*..error ptree..*/
boost::property_tree::ptree error_pt; boost::property_tree::ptree error_pt;

View File

@ -72,6 +72,8 @@ void TMyApplication::InnerInit()
ST::PathToResources = "assets/"; ST::PathToResources = "assets/";
#endif #endif
ST::PathToResources = "";
if (Console != NULL) if (Console != NULL)
{ {
*Console<<"APP INIT\n"; *Console<<"APP INIT\n";
@ -257,8 +259,9 @@ void TMyApplication::LoadResources()
// ::::::::::::::::::::::::::::::::::::: // :::::::::::::::::::::::::::::::::::::
// :::::::::::::PTREE LOAD:::::::::::::: // :::::::::::::PTREE LOAD::::::::::::::
boost::property_tree::ptree Textures_pt; boost::property_tree::ptree Textures_pt = SE::ReadJsonFile(ST::PathToResources + "bg_textures_config.json");
boost::property_tree::json_parser::read_json(ST::PathToResources + "bg_textures_config.json", Textures_pt); //boost::property_tree::json_parser::read_json(ST::PathToResources + "bg_textures_config.json", Textures_pt);
std::string bg_ext = ".jpeg"; std::string bg_ext = ".jpeg";
// ::::::::::::::::::::::::::::::::::::: // :::::::::::::::::::::::::::::::::::::
@ -307,12 +310,12 @@ void TMyApplication::LoadResources()
std::vector<int> galaxies; std::vector<int> galaxies;
galaxies.resize(1); galaxies.resize(1);
galaxies[0] = 3; galaxies[0] = 3;
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/matte_screen.png", "matte_screen")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("galax_menu/matte_screen.png", "matte_screen"));
for (int i = 0; i < galaxies.size(); i++) { for (int i = 0; i < galaxies.size(); i++) {
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/galaxies/galaxy_" + std::to_string(i) + ".png", "galaxy_" + std::to_string(i))); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("galax_menu/galaxies/galaxy_" + std::to_string(i) + ".png", "galaxy_" + std::to_string(i)));
for (int j = 0; j < galaxies[i]; j++) { for (int j = 0; j < galaxies[i]; j++) {
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j))); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j)));
TextureNamesToLoad.push_back(std::pair<std::string, std::string>("/galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover" + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover")); TextureNamesToLoad.push_back(std::pair<std::string, std::string>("galax_menu/planets/star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover" + ".png", "star_" + std::to_string(i) + "_" + std::to_string(j) + "_hover"));
} }
} }
@ -438,8 +441,11 @@ void TMyApplication::InnerUpdate(size_t dt)
if (TextureNamesToLoad.size() != 0) if (TextureNamesToLoad.size() != 0)
{ {
*SE::Console << "LOADING: " + TextureNamesToLoad.begin()->first;
ResourceManager->TexList.AddTexture(TextureNamesToLoad.begin()->first, TextureNamesToLoad.begin()->second); ResourceManager->TexList.AddTexture(TextureNamesToLoad.begin()->first, TextureNamesToLoad.begin()->second);
TextureNamesToLoad.erase(TextureNamesToLoad.begin()); TextureNamesToLoad.erase(TextureNamesToLoad.begin());
} }
else else
{ {
@ -640,33 +646,33 @@ void TMyApplication::InnerOnMouseMove(TMouseState& mouseState) {
void TMyApplication::EffectsInit() { void TMyApplication::EffectsInit() {
boost::property_tree::ptree JSONsource; boost::property_tree::ptree JSONsource;
boost::property_tree::ptree JSONconfig; boost::property_tree::ptree JSONconfig = SE::ReadJsonFile("config.json");
std::string effectJSON; std::string effectJSON;
boost::property_tree::json_parser::read_json(ST::PathToResources + "config.json", JSONconfig);
// LEFT // LEFT
effectJSON = JSONconfig.get<std::string>("lefteffect"); effectJSON = JSONconfig.get<std::string>("lefteffect");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource); //boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource);
JSONsource = SE::ReadJsonFile(ST::PathToResources + effectJSON);
lsparkler.parse(JSONsource); // parse JSON lsparkler.parse(JSONsource); // parse JSON
lsparkler.load(); // load textures lsparkler.load(); // load textures
// RIGHT // RIGHT
effectJSON = JSONconfig.get<std::string>("righteffect"); effectJSON = JSONconfig.get<std::string>("righteffect");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource); JSONsource = SE::ReadJsonFile(ST::PathToResources + effectJSON);
rsparkler.parse(JSONsource); rsparkler.parse(JSONsource);
rsparkler.load(); rsparkler.load();
// TOP // TOP
effectJSON = JSONconfig.get<std::string>("topeffect"); effectJSON = JSONconfig.get<std::string>("topeffect");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource); JSONsource = SE::ReadJsonFile(ST::PathToResources + effectJSON);
tsparkler.parse(JSONsource); tsparkler.parse(JSONsource);
tsparkler.load(); tsparkler.load();
// BOTTOM // BOTTOM
effectJSON = JSONconfig.get<std::string>("boteffect"); effectJSON = JSONconfig.get<std::string>("boteffect");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource); JSONsource = SE::ReadJsonFile(ST::PathToResources + effectJSON);
bsparkler.parse(JSONsource); bsparkler.parse(JSONsource);
bsparkler.load(); bsparkler.load();
// Level finish // Level finish
effectJSON = JSONconfig.get<std::string>("lvlFinish"); effectJSON = JSONconfig.get<std::string>("lvlFinish");
boost::property_tree::json_parser::read_json(ST::PathToResources + effectJSON, JSONsource); JSONsource = SE::ReadJsonFile(ST::PathToResources + effectJSON);
lvlFirework.parse(JSONsource); lvlFirework.parse(JSONsource);
lvlFirework.load(); lvlFirework.load();