VKEYBD: Fallback to SearchMan when loading keyboard packs
This commit is contained in:
parent
2c8afb2bd2
commit
8fe7d520be
2 changed files with 21 additions and 25 deletions
|
@ -38,21 +38,21 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
VirtualKeyboard::VirtualKeyboard() : _currentMode(0) {
|
VirtualKeyboard::VirtualKeyboard() :
|
||||||
|
_currentMode(nullptr),
|
||||||
|
_fileArchive(nullptr, DisposeAfterUse::NO) {
|
||||||
assert(g_system);
|
assert(g_system);
|
||||||
_system = g_system;
|
_system = g_system;
|
||||||
|
|
||||||
_parser = new VirtualKeyboardParser(this);
|
_parser = new VirtualKeyboardParser(this);
|
||||||
_kbdGUI = new VirtualKeyboardGUI(this);
|
_kbdGUI = new VirtualKeyboardGUI(this);
|
||||||
_submitKeys = _loaded = false;
|
_submitKeys = _loaded = false;
|
||||||
_fileArchive = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualKeyboard::~VirtualKeyboard() {
|
VirtualKeyboard::~VirtualKeyboard() {
|
||||||
deleteEvents();
|
deleteEvents();
|
||||||
delete _kbdGUI;
|
delete _kbdGUI;
|
||||||
delete _parser;
|
delete _parser;
|
||||||
delete _fileArchive;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VirtualKeyboard::deleteEvents() {
|
void VirtualKeyboard::deleteEvents() {
|
||||||
|
@ -74,33 +74,31 @@ void VirtualKeyboard::reset() {
|
||||||
_kbdGUI->reset();
|
_kbdGUI->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VirtualKeyboard::openPack(const String &packName, const FSNode &node) {
|
bool VirtualKeyboard::openPack(const String &packName, Archive *searchPath, DisposeAfterUse::Flag disposeSearchPath) {
|
||||||
if (node.getChild(packName + ".xml").exists()) {
|
if (searchPath->hasFile(packName + ".xml")) {
|
||||||
_fileArchive = new FSDirectory(node, 1);
|
_fileArchive.reset(searchPath, disposeSearchPath);
|
||||||
|
|
||||||
// uncompressed keyboard pack
|
// uncompressed keyboard pack
|
||||||
if (!_parser->loadFile(node.getChild(packName + ".xml"))) {
|
if (!_parser->loadStream(searchPath->createReadStreamForMember(packName + ".xml"))) {
|
||||||
delete _fileArchive;
|
_fileArchive.reset();
|
||||||
_fileArchive = 0;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.getChild(packName + ".zip").exists()) {
|
if (searchPath->hasFile(packName + ".zip")) {
|
||||||
// compressed keyboard pack
|
// compressed keyboard pack
|
||||||
_fileArchive = makeZipArchive(node.getChild(packName + ".zip"));
|
Archive *zip = makeZipArchive(searchPath->createReadStreamForMember(packName + ".zip"));
|
||||||
|
_fileArchive.reset(zip, DisposeAfterUse::YES);
|
||||||
if (_fileArchive && _fileArchive->hasFile(packName + ".xml")) {
|
if (_fileArchive && _fileArchive->hasFile(packName + ".xml")) {
|
||||||
if (!_parser->loadStream(_fileArchive->createReadStreamForMember(packName + ".xml"))) {
|
if (!_parser->loadStream(_fileArchive->createReadStreamForMember(packName + ".xml"))) {
|
||||||
delete _fileArchive;
|
_fileArchive.reset();
|
||||||
_fileArchive = 0;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warning("Could not find %s.xml file in %s.zip virtual keyboard pack", packName.c_str(), packName.c_str());
|
warning("Could not find %s.xml file in %s.zip virtual keyboard pack", packName.c_str(), packName.c_str());
|
||||||
delete _fileArchive;
|
_fileArchive.reset();
|
||||||
_fileArchive = 0;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,19 +111,18 @@ bool VirtualKeyboard::openPack(const String &packName, const FSNode &node) {
|
||||||
bool VirtualKeyboard::loadKeyboardPack(const String &packName) {
|
bool VirtualKeyboard::loadKeyboardPack(const String &packName) {
|
||||||
_kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight());
|
_kbdGUI->initSize(_system->getOverlayWidth(), _system->getOverlayHeight());
|
||||||
|
|
||||||
delete _fileArchive;
|
_fileArchive.reset();
|
||||||
_fileArchive = 0;
|
|
||||||
_loaded = false;
|
_loaded = false;
|
||||||
|
|
||||||
bool opened = false;
|
bool opened = false;
|
||||||
if (ConfMan.hasKey("vkeybdpath"))
|
if (ConfMan.hasKey("vkeybdpath"))
|
||||||
opened = openPack(packName, FSNode(ConfMan.get("vkeybdpath")));
|
opened = openPack(packName, new FSDirectory(ConfMan.get("vkeybdpath")), DisposeAfterUse::YES);
|
||||||
else if (ConfMan.hasKey("extrapath"))
|
else if (ConfMan.hasKey("extrapath"))
|
||||||
opened = openPack(packName, FSNode(ConfMan.get("extrapath")));
|
opened = openPack(packName, new FSDirectory(ConfMan.get("extrapath")), DisposeAfterUse::YES);
|
||||||
|
|
||||||
// fallback to the current dir
|
// fallback to SearchMan
|
||||||
if (!opened)
|
if (!opened)
|
||||||
opened = openPack(packName, FSNode("."));
|
opened = openPack(packName, &SearchMan, DisposeAfterUse::NO);
|
||||||
|
|
||||||
if (opened) {
|
if (opened) {
|
||||||
_parser->setParseMode(VirtualKeyboardParser::kParseFull);
|
_parser->setParseMode(VirtualKeyboardParser::kParseFull);
|
||||||
|
@ -136,8 +133,7 @@ bool VirtualKeyboard::loadKeyboardPack(const String &packName) {
|
||||||
} else {
|
} else {
|
||||||
warning("Error parsing the virtual keyboard pack '%s'", packName.c_str());
|
warning("Error parsing the virtual keyboard pack '%s'", packName.c_str());
|
||||||
|
|
||||||
delete _fileArchive;
|
_fileArchive.reset();
|
||||||
_fileArchive = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warning("Virtual keyboard disabled due to missing pack file");
|
warning("Virtual keyboard disabled due to missing pack file");
|
||||||
|
|
|
@ -226,7 +226,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
Archive *_fileArchive;
|
DisposablePtr<Archive> _fileArchive;
|
||||||
|
|
||||||
friend class VirtualKeyboardGUI;
|
friend class VirtualKeyboardGUI;
|
||||||
VirtualKeyboardGUI *_kbdGUI;
|
VirtualKeyboardGUI *_kbdGUI;
|
||||||
|
@ -237,7 +237,7 @@ protected:
|
||||||
VirtualKeyboardParser *_parser;
|
VirtualKeyboardParser *_parser;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
bool openPack(const String &packName, const FSNode &node);
|
bool openPack(const String &packName, Archive *searchPath, DisposeAfterUse::Flag disposeSearchPath);
|
||||||
void deleteEvents();
|
void deleteEvents();
|
||||||
bool checkModeResolutions();
|
bool checkModeResolutions();
|
||||||
void switchMode(Mode *newMode);
|
void switchMode(Mode *newMode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue