forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_xml.cpp
More file actions
56 lines (45 loc) · 1.16 KB
/
gui_xml.cpp
File metadata and controls
56 lines (45 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Aseprite
// Copyright (C) 2001-2016 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/gui_xml.h"
#include "app/resource_finder.h"
#include "app/xml_document.h"
#include "app/xml_exception.h"
#include "base/fs.h"
namespace app {
// static
GuiXml* GuiXml::instance()
{
static GuiXml* singleton = 0;
if (!singleton)
singleton = new GuiXml();
return singleton;
}
GuiXml::GuiXml()
{
LOG("GUIXML: Loading gui.xml file\n");
ResourceFinder rf;
rf.includeDataDir("gui.xml");
if (!rf.findFirst())
throw base::Exception("gui.xml was not found");
// Load the XML file. As we've already checked "path" existence,
// in a case of exception we should show the error and stop.
m_doc = app::open_xml(rf.filename());
}
std::string GuiXml::version()
{
TiXmlHandle handle(m_doc.get());
TiXmlElement* xmlKey = handle.FirstChild("gui").ToElement();
if (xmlKey && xmlKey->Attribute("version")) {
const char* guixml_version = xmlKey->Attribute("version");
return guixml_version;
}
else
return "";
}
} // namespace app