mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-28 11:50:53 +00:00
CHANGED: #1471 Extended the project file parser a little, now it also takes a MasterGroup name, and the name of a group that's activated after parsing. These are used to activate the groups, so that the Nel GUI widgets can be drawn.
This commit is contained in:
parent
5d04c95e1c
commit
cda0199889
7 changed files with 62 additions and 20 deletions
|
@ -140,9 +140,9 @@ namespace GUIEditor
|
||||||
setCursor( Qt::ArrowCursor );
|
setCursor( Qt::ArrowCursor );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
projectFiles.clear();
|
projectFiles.clearAll();
|
||||||
parser.getProjectFiles( projectFiles );
|
parser.getProjectFiles( projectFiles );
|
||||||
currentProject = parser.getProjectName().c_str();
|
currentProject = projectFiles.projectName.c_str();
|
||||||
projectWindow->setupFiles( projectFiles );
|
projectWindow->setupFiles( projectFiles );
|
||||||
if( viewPort->parse( projectFiles ) )
|
if( viewPort->parse( projectFiles ) )
|
||||||
viewPort->draw();
|
viewPort->draw();
|
||||||
|
|
|
@ -80,6 +80,12 @@ namespace GUIEditor
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CWidgetManager::getInstance()->updateAllLocalisedElements();
|
CWidgetManager::getInstance()->updateAllLocalisedElements();
|
||||||
|
CWidgetManager::getInstance()->activateMasterGroup( files.masterGroup, true );
|
||||||
|
|
||||||
|
CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( files.activeGroup );
|
||||||
|
if( e != NULL )
|
||||||
|
e->setActive( true );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ namespace GUIEditor
|
||||||
projectFiles.mapFiles.resize( files.mapFiles.size() );
|
projectFiles.mapFiles.resize( files.mapFiles.size() );
|
||||||
std::copy( files.guiFiles.begin(), files.guiFiles.end(), projectFiles.guiFiles.begin() );
|
std::copy( files.guiFiles.begin(), files.guiFiles.end(), projectFiles.guiFiles.begin() );
|
||||||
std::copy( files.mapFiles.begin(), files.mapFiles.end(), projectFiles.mapFiles.begin() );
|
std::copy( files.mapFiles.begin(), files.mapFiles.end(), projectFiles.mapFiles.begin() );
|
||||||
|
projectFiles.projectName = files.projectName;
|
||||||
|
projectFiles.masterGroup = files.masterGroup;
|
||||||
|
projectFiles.activeGroup = files.activeGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CProjectFileParser::parseXMLFile(QFile &f)
|
bool CProjectFileParser::parseXMLFile(QFile &f)
|
||||||
|
@ -85,18 +88,37 @@ namespace GUIEditor
|
||||||
|
|
||||||
bool CProjectFileParser::parseHeader( QXmlStreamReader &reader )
|
bool CProjectFileParser::parseHeader( QXmlStreamReader &reader )
|
||||||
{
|
{
|
||||||
while( !reader.atEnd() && !( reader.isStartElement() && ( reader.name() == "name" ) ) )
|
while( !reader.atEnd() && !( reader.isEndElement() && ( reader.name() == "header" ) ) )
|
||||||
reader.readNext();
|
{
|
||||||
if( reader.atEnd() )
|
if( reader.isStartElement() )
|
||||||
return false;
|
{
|
||||||
|
if( reader.name() == "name" )
|
||||||
|
{
|
||||||
|
QString name = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
|
||||||
|
if( name.isEmpty() )
|
||||||
|
return false;
|
||||||
|
files.projectName = name.toStdString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( reader.name() == "mastergroup" )
|
||||||
|
{
|
||||||
|
QString mg = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
|
||||||
|
if( mg.isEmpty() )
|
||||||
|
return false;
|
||||||
|
files.masterGroup = mg.toStdString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( reader.name() == "activegroup" )
|
||||||
|
{
|
||||||
|
QString ag = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
|
||||||
|
if( ag.isEmpty() )
|
||||||
|
return false;
|
||||||
|
files.activeGroup = ag.toStdString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString name = reader.readElementText( QXmlStreamReader::ErrorOnUnexpectedElement );
|
|
||||||
if( name.isEmpty() )
|
|
||||||
return false;
|
|
||||||
projectName = name.toStdString();
|
|
||||||
|
|
||||||
while( !reader.atEnd() && !( reader.isEndElement() ) && ( reader.name() == "header" ) )
|
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
|
}
|
||||||
if( reader.atEnd() )
|
if( reader.atEnd() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace GUIEditor
|
||||||
~CProjectFileParser();
|
~CProjectFileParser();
|
||||||
|
|
||||||
bool parseProjectFile( std::string &name );
|
bool parseProjectFile( std::string &name );
|
||||||
const std::string& getProjectName() const{ return projectName; }
|
|
||||||
void getProjectFiles( SProjectFiles &projectFiles ) const;
|
void getProjectFiles( SProjectFiles &projectFiles ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -44,7 +43,6 @@ namespace GUIEditor
|
||||||
bool parseMapFiles( QXmlStreamReader &reader );
|
bool parseMapFiles( QXmlStreamReader &reader );
|
||||||
|
|
||||||
SProjectFiles files;
|
SProjectFiles files;
|
||||||
std::string projectName;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,25 @@ namespace GUIEditor
|
||||||
struct SProjectFiles
|
struct SProjectFiles
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
std::string projectName;
|
||||||
|
std::string masterGroup;
|
||||||
|
std::string activeGroup;
|
||||||
std::vector< std::string > guiFiles;
|
std::vector< std::string > guiFiles;
|
||||||
std::vector< std::string > mapFiles;
|
std::vector< std::string > mapFiles;
|
||||||
|
|
||||||
void clear()
|
void clearFiles()
|
||||||
{
|
{
|
||||||
guiFiles.clear();
|
guiFiles.clear();
|
||||||
mapFiles.clear();
|
mapFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearAll()
|
||||||
|
{
|
||||||
|
clearFiles();
|
||||||
|
projectName = "";
|
||||||
|
masterGroup = "";
|
||||||
|
activeGroup = "";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
<project>
|
<project>
|
||||||
<header>
|
<header>
|
||||||
<name>login</name>
|
<name>login</name>
|
||||||
|
<mastergroup>ui:login</mastergroup>
|
||||||
|
<activegroup>ui:login:checkpass</activegroup>
|
||||||
</header>
|
</header>
|
||||||
<files>
|
<guifiles>
|
||||||
<file>login_config.xml</file>
|
<file>login_config.xml</file>
|
||||||
<file>login_keys.xml</file>
|
|
||||||
<file>login_main.xml</file>
|
|
||||||
<file>login_widgets.xml</file>
|
<file>login_widgets.xml</file>
|
||||||
</files>
|
<file>login_main.xml</file>
|
||||||
|
<file>login_keys.xml</file>
|
||||||
|
</guifiles>
|
||||||
|
<mapfiles>
|
||||||
|
<file>texture_interfaces_v3_login.tga</file>
|
||||||
|
</mapfiles>
|
||||||
</project>
|
</project>
|
|
@ -77,7 +77,7 @@ namespace GUIEditor
|
||||||
|
|
||||||
void ProjectWindow::updateFiles( SProjectFiles &projectFiles )
|
void ProjectWindow::updateFiles( SProjectFiles &projectFiles )
|
||||||
{
|
{
|
||||||
projectFiles.clear();
|
projectFiles.clearFiles();
|
||||||
|
|
||||||
QTreeWidgetItem *topItem;
|
QTreeWidgetItem *topItem;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue