/* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT * file distributed with this source distribution. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ /* * This code is based on the CRAB engine * * Copyright (c) Arvind Raja Yadav * * Licensed under MIT * */ #include "crab/GameParam.h" #include "crab/XMLDoc.h" namespace Crab { // Are we in debug mode or not? bool GameDebug = false; FilePaths::FilePaths() : _common("res/levels/common.xml"), _modPath("mods/"), _modExt(".unrmod"), _modCur("res/default.xml"), _mainmenuL("res/layout/main_menu_l.xml"), _mainmenuR("res/layout/main_menu_r.xml"), _soundEffect("res/sounds/effects.xml"), _soundMusic("res/sounds/music.xml"), _font("res/fonts/fonts.xml"), _icon("res/gfx/icon.bmp"), _saveDir("save/"), _saveExt(".unr"), _shaders("res/shaders/list.xml"), _colors("res/gfx/colors.xml"), _currentR("res/layout/main_menu_r.xml") { _level.clear(); _loaded = false; warning("FilePaths::FilePaths() setting appdata directory to game dir"); _appdata = "./"; } void FilePaths::loadLevel(const Common::Path &filename) { _level.clear(); XMLDoc lev_list(filename); if (lev_list.ready()) { rapidxml::xml_node *node = lev_list.doc()->first_node("world"); for (rapidxml::xml_node *n = node->first_node("loc"); n != nullptr; n = n->next_sibling("loc")) { LevelPath l; l.load(n); Common::String id; loadStr(id, "id", n); _level[id] = Common::move(l); } } } void FilePaths::load(const Common::Path &filename) { XMLDoc settings(filename); if (settings.ready()) { rapidxml::xml_node *node = settings.doc()->first_node("paths"); if (nodeValid(node) && !_loaded) { if (nodeValid("icon", node)) { rapidxml::xml_node *iconode = node->first_node("icon"); _icon = iconode->value(); } if (nodeValid("common", node)) { rapidxml::xml_node *commonnode = node->first_node("common"); _common = commonnode->value(); } if (nodeValid("font", node)) { rapidxml::xml_node *fontnode = node->first_node("font"); _font = fontnode->value(); } if (nodeValid("shader", node)) { rapidxml::xml_node *shadnode = node->first_node("shader"); _shaders = shadnode->value(); } if (nodeValid("color", node)) { rapidxml::xml_node *colnode = node->first_node("color"); _colors = colnode->value(); } if (nodeValid("mod", node)) { rapidxml::xml_node *modnode = node->first_node("mod"); loadPath(_modPath, "path", modnode); loadPath(_modCur, "cur", modnode); loadStr(_modExt, "ext", modnode); } if (nodeValid("main_menu", node)) { rapidxml::xml_node *menunode = node->first_node("main_menu"); loadPath(_mainmenuL, "l", menunode); loadPath(_mainmenuR, "r", menunode); _currentR = _mainmenuR; } if (nodeValid("sound", node)) { rapidxml::xml_node *soundnode = node->first_node("sound"); loadPath(_soundEffect, "effect", soundnode); loadPath(_soundMusic, "music", soundnode); } if (nodeValid("save", node)) { rapidxml::xml_node *savenode = node->first_node("save"); loadPath(_saveDir, "dir", savenode); loadStr(_saveExt, "ext", savenode); Common::String custom_path; if (loadStr(custom_path, "custom", savenode)) { warning("In FilePaths::load(), customPath : %s", custom_path.c_str()); } } _loaded = true; } } } } // End of namespace Crab