Test case for dialog XMLs in-engine
This commit is contained in:
@@ -16,15 +16,7 @@ extern std::ostream& std_fmterr(std::ostream& out);
|
||||
class DialogLoader : public ResMgr::cLoader<DialogDefn> {
|
||||
/// Load a dialog definition from an XML file.
|
||||
DialogDefn* operator() (const fs::path& fpath) const override {
|
||||
TiXmlBase::SetCondenseWhiteSpace(false);
|
||||
ticpp::Document xml(fpath.string().c_str());
|
||||
try {
|
||||
xml.LoadFile();
|
||||
} catch(ticpp::Exception& e) {
|
||||
std::cerr << "Error reading XML file: " << e.what();
|
||||
throw ResMgr::xError(ResMgr::ERR_LOAD, "Failed to load dialog: " + fpath.string());
|
||||
}
|
||||
return new DialogDefn{fpath.stem().string(), std::move(xml)};
|
||||
return load_dialog_defn(fpath);
|
||||
}
|
||||
|
||||
ResourceList expand(const std::string& name) const override {
|
||||
@@ -36,6 +28,18 @@ class DialogLoader : public ResMgr::cLoader<DialogDefn> {
|
||||
}
|
||||
};
|
||||
|
||||
DialogDefn* load_dialog_defn(const fs::path& fpath) {
|
||||
TiXmlBase::SetCondenseWhiteSpace(false);
|
||||
ticpp::Document xml(fpath.string().c_str());
|
||||
try {
|
||||
xml.LoadFile();
|
||||
} catch(ticpp::Exception& e) {
|
||||
std::cerr << "Error reading XML file: " << e.what();
|
||||
throw ResMgr::xError(ResMgr::ERR_LOAD, "Failed to load dialog: " + fpath.string());
|
||||
}
|
||||
return new DialogDefn{fpath.stem().string(), std::move(xml)};
|
||||
}
|
||||
|
||||
// TODO: What's a good max dialogs count?
|
||||
static DialogLoader loader;
|
||||
ResMgr::cPool<DialogDefn> ResMgr::dialogs(loader, 80);
|
||||
|
@@ -19,6 +19,8 @@ struct DialogDefn {
|
||||
/// The XML definition of the dialog.
|
||||
ticpp::Document defn;
|
||||
};
|
||||
/// Load a dialog definition from an XML file.
|
||||
DialogDefn* load_dialog_defn(const fs::path& fpath);
|
||||
|
||||
using DialogRsrc = ResMgr::cPointer<DialogDefn>;
|
||||
|
||||
|
Reference in New Issue
Block a user