This commit is contained in:
aquiles 2011-03-05 13:24:42 +01:00
commit 7739a43750
33 changed files with 1939 additions and 435 deletions

View file

@ -67,11 +67,12 @@ namespace NLQT
virtual NL3D::UDriver *getDriver() = 0;
virtual NL3D::UScene *getScene() = 0;
virtual NL3D::UPlayListManager *getPlayListManager() = 0;
virtual void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z) = 0;
virtual void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z) = 0;
virtual bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction) = 0;
virtual void setVisible(bool visible) = 0;
virtual QWidget* getWidget() = 0;
virtual void setNelContext(NLMISC::INelContext &nelContext) = 0;
virtual QIcon* saveOneImage(std::string shapename) = 0;
};

View file

@ -41,6 +41,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <nel/3d/u_3d_mouse_listener.h>
#include <nel/3d/bloom_effect.h>
// Qt includes
#include <QIcon>
// Project includes
Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget)
@ -432,7 +435,7 @@ namespace NLQT
CAABBox bbox;
Entity.getShapeAABBox(bbox);
setCamera(bbox , Entity, true);
setCamera(_Scene, bbox , Entity, true);
_MouseListener->setMatrix(_Scene->getCam().getMatrix());
@ -576,7 +579,7 @@ namespace NLQT
_Entities.clear();
}
void CObjectViewerWidget::setCamera(CAABBox &bbox, UTransform &entity, bool high_z)
void CObjectViewerWidget::setCamera(NL3D::UScene *scene, CAABBox &bbox, UTransform &entity, bool high_z)
{
CVector pos(0.f, 0.f, 0.f);
CQuat quat(0.f, 0.f, 0.f, 0.f);
@ -586,87 +589,29 @@ namespace NLQT
{
inst.getDefaultPos(pos);
inst.getDefaultRotQuat(quat);
/*
if (quat.getAxis().isNull())
{
quat.set(0, 0, 0, 0);
inst.setRotQuat(quat);
}
*/
// quat.set(1.f, 1.f, 0.f, 0.f);
// inst.setRotQuat(quat);
// inst.getRotQuat(quat);
// check for presence of all textures from each sets
//bool allGood = true;
//for(uint s = 0; s < 5; ++s)
//{
// inst.selectTextureSet(s);
// uint numMat = inst.getNumMaterials();
// // by default, all textures are present
// allGood = true;
// for(uint i = 0; i < numMat; ++i)
// {
// UInstanceMaterial mat = inst.getMaterial(i);
// for(sint j = 0; j <= mat.getLastTextureStage(); ++j)
// {
// // if a texture is missing
// if (mat.isTextureFile(j) && mat.getTextureFileName(j) == "CTextureMultiFile:Dummy")
// allGood = false;
// }
// }
// // if all textures have been found for this set, skip other sets
// if (allGood)
// break;
//}
}
// fix scale (some shapes have a different value)
entity.setScale(1.f, 1.f, 1.f);
UCamera Camera = _Scene->getCam();
UCamera Camera = scene->getCam();
CVector max_radius = bbox.getHalfSize();
CVector center = bbox.getCenter();
entity.setPivot(center);
center += pos;
//_Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000);
//scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)w/h, 0.1f, 1000);
float fov = float(_CameraFocal * (float)Pi/180.0);
//Camera.setPerspective (fov, 1.0f, 0.1f, 1000.0f);
float radius = max(max(max_radius.x, max_radius.y), max_radius.z);
if (radius == 0.f) radius = 1.f;
float left, right, bottom, top, znear, zfar;
Camera.getFrustum(left, right, bottom, top, znear, zfar);
float dist = radius / (tan(fov/2));
float dist = (radius / (tan(fov/2))) * 0.2;
CVector eye(center);
/* if (axis == CVector::I)
eye.y -= dist+radius;
else if (axis == CVector::J)
eye.x += dist+radius;
*/
// quat.normalize();
CVector ax(quat.getAxis());
// float angle = quat.getAngle();
/*
if (ax.isNull())
{
if (int(angle*100.f) == int(NLMISC::Pi * 200.f))
{
ax = CVector::J;
}
}
else
*/
if (ax.isNull() || ax == CVector::I)
{
ax = CVector::J;
@ -675,12 +620,6 @@ namespace NLQT
{
ax = -CVector::J;
}
/* else if (ax.x < -0.9f && ax.y == 0.f && ax.z == 0.f)
{
ax = -CVector::J ;
}
*/
// ax.normalize();
eye -= ax * (dist+radius);
if (high_z)
@ -713,6 +652,73 @@ namespace NLQT
return true;
}
QIcon* CObjectViewerWidget::saveOneImage(string shapename)
{
int output_width = 128;
int output_height = 128;
// Create a scene
NL3D::UScene* Scene = _Driver->createScene(true);
if (!Scene) return 0;
// get scene camera
if (Scene->getCam().empty())
{
nlwarning("can't get camera from scene");
return 0;
}
// add an entity to the scene
UInstance Entity = Scene->createInstance(shapename.c_str());
// if we can't create entity, skip it
if (Entity.empty())
{
nlwarning("can't create instance from %s", shapename.c_str());
return 0;
}
// get AABox of Entity
CAABBox bbox;
Entity.getShapeAABBox(bbox);
setCamera(Scene, bbox , Entity, true);
Scene->getCam().setPerspective(_CameraFocal * (float)Pi/180.f, (float)output_width/output_height, 0.1f, 1000);
string filename = CPath::standardizePath("") + toString("%s.%s", shapename.c_str(), "png");
// the background is white
_Driver->clearBuffers();
// render the scene
Scene->render();
CBitmap btm;
_Driver->getBuffer(btm);
btm.resample(output_width, output_height);
COFile fs;
if (fs.open(filename))
{
if (!btm.writePNG(fs, 24))
{
nlwarning("can't save image to PNG");
return 0;
}
}
else
{
nlwarning("can't create %s", "test.png");
return 0;
}
fs.close();
QIcon *icon = new QIcon(QString(filename.c_str()));
//CFile::deleteFile(filename);
return icon;
}
#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

View file

@ -45,6 +45,7 @@ namespace NL3D
class U3dMouseListener;
}
class QIcon;
/**
namespace NLQT
@brief namespace NLQT
@ -153,9 +154,11 @@ namespace NLQT
/// @return pointer to the UPlayListManager
inline NL3D::UPlayListManager *getPlayListManager() { return _PlayListManager; }
void setCamera(NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z);
void setCamera(NL3D::UScene *scene, NLMISC::CAABBox &bbox, NL3D::UTransform &entity, bool high_z=false);
bool setupLight(const NLMISC::CVector &position, const NLMISC::CVector &direction);
QIcon* saveOneImage(std::string shapename);
virtual void setVisible(bool visible);
QWidget* getWidget() {return this;}

View file

@ -8,9 +8,27 @@ INCLUDE_DIRECTORIES(
INCLUDE( ${QT_USE_FILE} )
FILE(GLOB GEORGES_EDITOR_SRC *.cpp *.h)
SET(GEORGES_EDITOR_HDR georges_dirtree_dialog.h georges_treeview_dialog.h main_window.h
objectviewer_dialog.h settings_dialog.h progress_dialog.h)
SET(GEORGES_EDITOR_UIS settings_form.ui objectviewer_form.ui log_form.ui georges_treeview_form.ui georges_dirtree_form.ui)
SET(GEORGES_EDITOR_HDR
georges_dirtree_dialog.h
georges_treeview_dialog.h
main_window.h
objectviewer_dialog.h
settings_dialog.h
progress_dialog.h
new_dialog.h
completer_line_edit.h
georges_splash.h)
SET(GEORGES_EDITOR_UIS
settings_form.ui
objectviewer_form.ui
log_form.ui
georges_treeview_form.ui
georges_dirtree_form.ui
new_form.ui
splash.ui)
SET(GEORGES_EDITOR_RCS georges_editor_qt.qrc)
SET(QT_USE_QTGUI TRUE)

View file

@ -0,0 +1,150 @@
#include "completer_line_edit.h"
#include <QKeyEvent>
#include <QtGui/QListView>
#include <QtGui/QStringListModel>
#include <QDebug>
#include <QApplication>
#include <QScrollBar>
CompleteLineEdit::CompleteLineEdit(QWidget *parent, QStringList words)
: QLineEdit(parent), _words(words)
{
listView = new QListView(this);
model = new QStringListModel(this);
listView->setModel(model);
listView->setWindowFlags(Qt::ToolTip);
listView->setUniformItemSizes(true);
connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(setCompleter(const QString &)));
connect(listView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(completeText(const QModelIndex &)));
}
void CompleteLineEdit::setStringList(QStringList list)
{
_words = list;
}
//void CompleteLineEdit::focusOutEvent(QFocusEvent *e)
//{
// listView->hide();
//}
void CompleteLineEdit::keyPressEvent(QKeyEvent *e)
{
if (!listView->isHidden())
{
int key = e->key();
int count = listView->model()->rowCount();
QModelIndex currentIndex = listView->currentIndex();
if (Qt::Key_Down == key)
{
int row = currentIndex.row() + 1;
if (row >= count)
{
row = 0;
}
QModelIndex index = listView->model()->index(row, 0);
listView->setCurrentIndex(index);
}
else if (Qt::Key_Up == key)
{
int row = currentIndex.row() - 1;
if (row < 0)
{
row = count - 1;
}
QModelIndex index = listView->model()->index(row, 0);
listView->setCurrentIndex(index);
}
else if (Qt::Key_Escape == key)
{
listView->hide();
}
else if (Qt::Key_Enter == key || Qt::Key_Return == key)
{
if (currentIndex.isValid())
{
QString text = listView->currentIndex().data().toString();
setText(text);
}
listView->hide();
}
else
{
//listView->hide();
QLineEdit::keyPressEvent(e);
}
}
else
{
QLineEdit::keyPressEvent(e);
}
}
void CompleteLineEdit::setCompleter(const QString &text)
{
if (text.isEmpty())
{
listView->hide();
return;
}
if ((text.length() > 1) && (!listView->isHidden()))
{
//return;
}
QStringList sl;
Q_FOREACH(QString word, _words)
{
if (word.contains(text))
{
sl << word;
}
}
if (sl.isEmpty())
{
if (_words.isEmpty())
{
setText(tr("No files found"));
setEnabled(false);
return;
}
else
{
model->setStringList(_words);
}
}
else
{
model->setStringList(sl);
}
// Position the text edit
listView->setMinimumWidth(width());
listView->setMaximumWidth(width());
//listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QPoint p(0, height());
int x = mapToGlobal(p).x();
int y = mapToGlobal(p).y() + 1;
listView->move(x, y);
if(!listView->isVisible())
listView->show();
}
void CompleteLineEdit::completeText(const QModelIndex &index)
{
QString text = index.data().toString();
setText(text);
listView->hide();
}

View file

@ -0,0 +1,39 @@
#ifndef COMPLETELINEEDIT_H
#define COMPLETELINEEDIT_H
// code from
// http://www.cppblog.com/biao/archive/2009/10/31/99873.html
// there was no license attached
#include <QtGui/QLineEdit>
#include <QStringList>
class QListView;
class QStringListModel;
class QModelIndex;
class CompleteLineEdit : public QLineEdit
{
Q_OBJECT
public:
CompleteLineEdit(QWidget *parent = 0, QStringList words = QStringList());
void setStringList(QStringList list);
public Q_SLOTS:
void setCompleter(const QString &text);
void completeText(const QModelIndex &index);
protected:
virtual void keyPressEvent(QKeyEvent *e);
//virtual void focusOutEvent(QFocusEvent *e);
private:
QStringList _words;
QListView *listView;
QStringListModel *model;
};
#endif // COMPLETELINEEDIT_H

View file

@ -1,19 +1,19 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 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.
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 <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -38,188 +38,200 @@ using namespace std;
using namespace NLMISC;
namespace NLQT {
CConfiguration::CConfiguration()
{
}
CConfiguration::~CConfiguration()
{
}
void CConfiguration::init()
{
// load config
QFile file(NLQT_CONFIG_FILE);
if (!file.exists()) {
file.open( QIODevice::WriteOnly | QIODevice::Text );
file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };");
file.write("\nSearchPaths = {\"\"};");
file.write("\nRemapExtensions = { \"png\", \"tga\" };");
file.write("\nBackgroundColor = { 0, 0, 0 };");
//file.write("\nQtStyle = \"\";");
//file.write("\nQtPalette = \"\";");
file.close();
}
try {
ConfigFile.load(NLQT_CONFIG_FILE);
} catch(...) {
}
addLeveldesignPath();
addSearchPaths();
configRemapExtensions();
}
void CConfiguration::release()
{
//Modules::config().dropCallback("SearchPaths");
// save and release the config file
if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool())
CConfiguration::CConfiguration() : _progressCB(0)
{
ConfigFile.save();
}
ConfigFile.clear();
// release the search paths etc
CPath::releaseInstance();
}
void CConfiguration::updateUtilities()
{
//H_AUTO2
CConfigFile::checkConfigFiles();
}
void CConfiguration::addLeveldesignPath()
{
std::vector<std::string> list;
list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString()));
addSearchPaths(&list);
}
void CConfiguration::configRemapExtensions()
{
CConfigFile::CVar *var;
var = ConfigFile.getVarPtr("RemapExtensions");
uint varsize = var->size();
for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
}
float CConfiguration::getValue(const string &varName, float defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble((double)defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
double CConfiguration::getValue(const string &varName, double defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
int CConfiguration::getValue(const string &varName, int defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
string CConfiguration::getValue(const string &varName, const string &defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString();
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue)
{
if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString());
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue.toUtf8());
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
bool CConfiguration::getValue(const string &varName, bool defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue ? 1 : 0);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue)
{
if (ConfigFile.exists(varName))
CConfiguration::~CConfiguration()
{
return getValue(ConfigFile.getVar(varName), defaultValue);
}
else
{
// create a new value only if one doesn't exist
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue.R);
varToCopy.setAsInt(defaultValue.G, 1);
varToCopy.setAsInt(defaultValue.B, 2);
varToCopy.setAsInt(defaultValue.A, 3);
ConfigFile.insertVar(varName, varToCopy);
}
return defaultValue;
}
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue)
{
if (var.size() >= 3)
{
if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values");
return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255);
}
nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A);
return defaultValue;
}
void CConfiguration::addSearchPaths(std::vector<std::string>* list)
{
//Modules::config().getConfigFile().getVar("SearchPaths");
std::vector<std::string> *tmpList = list;
if (!tmpList)
{
NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths");
tmpList = new std::vector<std::string>();
for (uint i = 0; i < v.size(); ++i)
{
tmpList->push_back(v.asString(i));
void CConfiguration::init()
{
// load config
QFile file(NLQT_CONFIG_FILE);
if (!file.exists()) {
file.open( QIODevice::WriteOnly | QIODevice::Text );
file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };");
file.write("\nSearchPaths = {\"\"};");
file.write("\nRemapExtensions = { \"png\", \"tga\" };");
file.write("\nBackgroundColor = { 0, 0, 0 };");
//file.write("\nQtStyle = \"\";");
//file.write("\nQtPalette = \"\";");
file.close();
}
try {
ConfigFile.load(NLQT_CONFIG_FILE);
} catch(...) {
}
addLeveldesignPath();
addSearchPaths();
configRemapExtensions();
}
uint listsize = tmpList->size();
for (uint i = 0; i < listsize; ++i)
void CConfiguration::release()
{
CProgressDialog pcb;
pcb.DisplayString = tmpList->at(i);
pcb.show();
CPath::addSearchPath(tmpList->at(i), true, false, &pcb);
//Modules::config().dropCallback("SearchPaths");
// save and release the config file
if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool())
{
ConfigFile.save();
}
ConfigFile.clear();
// release the search paths etc
CPath::releaseInstance();
}
void CConfiguration::updateUtilities()
{
//H_AUTO2
CConfigFile::checkConfigFiles();
}
void CConfiguration::addLeveldesignPath()
{
std::vector<std::string> list;
list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString()));
addSearchPaths(&list);
}
void CConfiguration::configRemapExtensions()
{
CConfigFile::CVar *var;
var = ConfigFile.getVarPtr("RemapExtensions");
uint varsize = var->size();
for (uint i = 0; i < varsize; i += 2)
CPath::remapExtension(var->asString(i), var->asString(i + 1), true);
}
float CConfiguration::getValue(const string &varName, float defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble((double)defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
double CConfiguration::getValue(const string &varName, double defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble();
CConfigFile::CVar varToCopy;
varToCopy.forceAsDouble(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
int CConfiguration::getValue(const string &varName, int defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
string CConfiguration::getValue(const string &varName, const string &defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString();
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue)
{
if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString());
CConfigFile::CVar varToCopy;
varToCopy.forceAsString(defaultValue.toUtf8());
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
bool CConfiguration::getValue(const string &varName, bool defaultValue)
{
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool();
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue ? 1 : 0);
ConfigFile.insertVar(varName, varToCopy);
return defaultValue;
}
CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue)
{
if (ConfigFile.exists(varName))
{
return getValue(ConfigFile.getVar(varName), defaultValue);
}
else
{
// create a new value only if one doesn't exist
CConfigFile::CVar varToCopy;
varToCopy.forceAsInt(defaultValue.R);
varToCopy.setAsInt(defaultValue.G, 1);
varToCopy.setAsInt(defaultValue.B, 2);
varToCopy.setAsInt(defaultValue.A, 3);
ConfigFile.insertVar(varName, varToCopy);
}
return defaultValue;
}
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue)
{
if (var.size() >= 3)
{
if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values");
return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255);
}
nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A);
return defaultValue;
}
void CConfiguration::addSearchPaths(std::vector<std::string>* list)
{
//Modules::config().getConfigFile().getVar("SearchPaths");
std::vector<std::string> *tmpList = list;
if (!tmpList)
{
NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths");
tmpList = new std::vector<std::string>();
for (uint i = 0; i < v.size(); ++i)
{
tmpList->push_back(v.asString(i));
}
}
uint listsize = tmpList->size();
for (uint i = 0; i < listsize; ++i)
{
if(_progressCB) {
_progressCB->DisplayString = tmpList->at(i);
CPath::addSearchPath(tmpList->at(i), true, false, _progressCB);
}
else
{
CProgressDialog pcb;
pcb.DisplayString = tmpList->at(i);
pcb.show();
CPath::addSearchPath(tmpList->at(i), true, false, &pcb);
}
}
if (!list)
delete tmpList;
}
void CConfiguration::setProgressCallback(NLMISC::IProgressCallback *cb)
{
_progressCB = cb;
}
if (!list)
delete tmpList;
}
} /* namespace NLQT */

View file

@ -1,19 +1,19 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 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.
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 <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -34,46 +34,54 @@
#define NLQT_CONFIG_FILE "georges_editor.cfg"
namespace NLMISC {
class IProgressCallback;
}
namespace NLQT {
/**
* CConfiguration
* \brief CConfiguration
* \date 2010-02-05 15:44GMT
* \author Jan Boon (Kaetemi)
*/
class CConfiguration
{
public:
CConfiguration();
virtual ~CConfiguration();
/**
* CConfiguration
* \brief CConfiguration
* \date 2010-02-05 15:44GMT
* \author Jan Boon (Kaetemi)
*/
class CConfiguration
{
public:
CConfiguration();
virtual ~CConfiguration();
void init();
void release();
void updateUtilities();
void configRemapExtensions();
void addSearchPaths(std::vector<std::string>* list = 0);
void addLeveldesignPath();
void init();
void release();
float getValue(const std::string &varName, float defaultValue);
double getValue(const std::string &varName, double defaultValue);
int getValue(const std::string &varName, int defaultValue);
std::string getValue(const std::string &varName, const std::string &defaultValue);
ucstring getValue(const std::string &varName, const ucstring &defaultValue);
bool getValue(const std::string &varName, bool defaultValue);
NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue);
NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue);
inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; }
void updateUtilities();
void configRemapExtensions();
void addSearchPaths(std::vector<std::string>* list = 0);
void addLeveldesignPath();
private:
CConfiguration(const CConfiguration &);
CConfiguration &operator=(const CConfiguration &);
void setProgressCallback(NLMISC::IProgressCallback *_progressCB);
NLMISC::CConfigFile ConfigFile;
};/* class CConfiguration */
float getValue(const std::string &varName, float defaultValue);
double getValue(const std::string &varName, double defaultValue);
int getValue(const std::string &varName, int defaultValue);
std::string getValue(const std::string &varName, const std::string &defaultValue);
ucstring getValue(const std::string &varName, const ucstring &defaultValue);
bool getValue(const std::string &varName, bool defaultValue);
NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue);
NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue);
inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; }
private:
CConfiguration(const CConfiguration &);
CConfiguration &operator=(const CConfiguration &);
NLMISC::CConfigFile ConfigFile;
NLMISC::IProgressCallback *_progressCB;
};/* class CConfiguration */
} /* namespace NLQT */

View file

@ -76,23 +76,23 @@ CEntity::~CEntity(void)
if (_PlayList != NULL)
{
_PlayList->resetAllChannels();
Modules::objViewInt().getPlayListManager()->deletePlayList (_PlayList);
Modules::objViewInt()->getPlayListManager()->deletePlayList (_PlayList);
_PlayList = NULL;
}
if (_AnimationSet != NULL)
{
Modules::objViewInt().getDriver()->deleteAnimationSet(_AnimationSet);
Modules::objViewInt()->getDriver()->deleteAnimationSet(_AnimationSet);
_AnimationSet = NULL;
}
if (!_Skeleton.empty())
{
_Skeleton.detachSkeletonSon(_Instance);
Modules::objViewInt().getScene()->deleteSkeleton(_Skeleton);
Modules::objViewInt()->getScene()->deleteSkeleton(_Skeleton);
_Skeleton = NULL;
}
if (!_Instance.empty())
{
Modules::objViewInt().getScene()->deleteInstance(_Instance);
Modules::objViewInt()->getScene()->deleteInstance(_Instance);
_Instance = NULL;
}
}

View file

@ -58,7 +58,13 @@ namespace NLQT
if (value.isEmpty() || !mp || !m)
return 0;
const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType();
CFormItem* curItem = m->getItem(mp->mapToSource(index));
NLGEORGES::UFormElm *curElm = curItem->getFormElm();
if (!curElm) {
// TODO: create new Element
return 0;
}
const NLGEORGES::UType *type = curElm->getType();
if(type)
{
int numDefinitions = type->getNumDefinition();
@ -273,36 +279,36 @@ namespace NLQT
//option.decorationAlignment = QStyleOptionViewItem::Right;
}
void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItemV4 optionV4 = option;
optionV4.decorationPosition = QStyleOptionViewItem::Right;
//optionV4.decorationSize = QSize(32,32);
initStyleOption(&optionV4, index);
//void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
//{
// QStyleOptionViewItemV4 optionV4 = option;
// optionV4.decorationPosition = QStyleOptionViewItem::Right;
// //optionV4.decorationSize = QSize(32,32);
// initStyleOption(&optionV4, index);
QStyledItemDelegate::paint(painter,optionV4,index);
// QStyledItemDelegate::paint(painter,optionV4,index);
//QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style();
// //QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style();
//QTextDocument doc;
//doc.setHtml(optionV4.text);
// //QTextDocument doc;
// //doc.setHtml(optionV4.text);
///// Painting item without text
//optionV4.text = QString();
//style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter);
// ///// Painting item without text
// //optionV4.text = QString();
// //style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter);
//QAbstractTextDocumentLayout::PaintContext ctx;
// //QAbstractTextDocumentLayout::PaintContext ctx;
//// Highlighting text if item is selected
//if (optionV4.state & QStyle::State_Selected)
// ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));
// //// Highlighting text if item is selected
// //if (optionV4.state & QStyle::State_Selected)
// // ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));
//QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4);
//painter->save();
//painter->translate(textRect.topLeft());
//painter->setClipRect(textRect.translated(-textRect.topLeft()));
//doc.documentLayout()->draw(painter, ctx);
//painter->restore();
}
// //QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4);
// //painter->save();
// //painter->translate(textRect.topLeft());
// //painter->setClipRect(textRect.translated(-textRect.topLeft()));
// //doc.documentLayout()->draw(painter, ctx);
// //painter->restore();
//}
} /* namespace NLQT */

View file

@ -37,8 +37,8 @@ namespace NLQT
const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint ( QPainter * painter, const QStyleOptionViewItem & option,
const QModelIndex & index ) const;
//void paint ( QPainter * painter, const QStyleOptionViewItem & option,
// const QModelIndex & index ) const;
};
}

View file

@ -22,7 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// NeL includes
#include <nel/misc/o_xml.h>
#include <nel/georges/u_type.h>
#include <nel/georges/form.h>
namespace NLQT
{
@ -101,19 +103,61 @@ namespace NLQT
case NLGEORGES::UType::SignedInt:
case NLGEORGES::UType::Double:
case NLGEORGES::UType::String:
nldebug(QString("string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toStdString().c_str());
parentItem->formElm->setValueByName(
value.toString().toStdString().c_str(),itemData[0].toString().toStdString().c_str());
if (parentItem->formElm->isArray())
{
//((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName(
//if(parentItem->formElm->getArrayNode(elmName, num))
//{
//}
bool ok;
// TODO: the node can be renamed from eg "#0" to "foobar"
int arrayIndex = itemData[0].toString().remove("#").toInt(&ok);
if(ok)
{
NLGEORGES::UFormElm *elmt = 0;
if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt)
{
if (elmt->isAtom())
{
((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toStdString().c_str());
nldebug(QString("array element string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toStdString().c_str());
}
}
}
}
else
{
if(parentItem->formElm->setValueByName(
value.toString().toStdString().c_str(),
itemData[0].toString().toStdString().c_str()))
{
nldebug(QString("string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toStdString().c_str());
}
else
{
nldebug(QString("FAILED string %1 %2")
.arg(itemData[0].toString()).arg(value.toString())
.toStdString().c_str());
}
}
break;
case NLGEORGES::UType::Color:
nldebug("Color is TODO");
break;
default:
break;
}
}
}
else
{
nldebug("setting sth other than Atom");
}
//formElm->setValueByName();
return true;
}

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// NeL includes
#include <nel/georges/u_form_loader.h>
#include <nel/georges/u_form.h>
#include <nel/georges/u_type.h>
// Project includes
@ -48,4 +49,18 @@ namespace NLQT
return form;
}
UFormDfn *CGeorges::loadFormDfn(std::string formName)
{
UFormDfn *formdfn = FormLoader->loadFormDfn(formName.c_str());
return formdfn;
}
UType *CGeorges::loadFormType(std::string formName)
{
UType *type = FormLoader->loadFormType(formName.c_str());
return type;
}
} /* namespace NLQT */

View file

@ -32,7 +32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace NLGEORGES
{
class UType;
class UForm;
class UFormDfn;
class UFormLoader;
}
@ -54,6 +56,10 @@ namespace NLQT
// Load the given form root
UForm* loadForm(std::string formName);
// Load a dfn
UFormDfn* loadFormDfn(std::string formName);
// Load a type
UType *loadFormType (std::string formName);
// A form loader
UFormLoader *FormLoader;

View file

@ -48,7 +48,7 @@ namespace NLQT
QString _ldPath;
Q_SIGNALS:
void selectedForm(QString);
void selectedForm(const QString);
public Q_SLOTS:
void ldPathChanged(QString path);

View file

@ -9,5 +9,7 @@
<file>images/preferences.png</file>
<file>images/pqrticles.png</file>
<file>images/khead.png</file>
<file>images/georges_logo.png</file>
<file>images/mp_generic.png</file>
</qresource>
</RCC>

View file

@ -0,0 +1,73 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 <http://www.gnu.org/licenses/>.
*/
#include "georges_splash.h"
// Qt includes
#include <QtGui/QWidget>
#include <QDebug>
#include <QFileInfo>
// NeL includes
// Project includes
namespace NLMISC {
class IProgressCallback;
}
namespace NLQT
{
CGeorgesSplash::CGeorgesSplash(QWidget *parent)
: QWidget(parent)
{
_ui.setupUi(this);
setWindowFlags(Qt::SplashScreen);
_ui.imageLabel->setPixmap(
QPixmap(":/images/georges_logo.png").
scaledToHeight(_ui.imageLabel->height(),Qt::SmoothTransformation));
//setWindowIcon(QIcon(":/images/georges_logo.png"));
}
CGeorgesSplash::~CGeorgesSplash()
{
}
void CGeorgesSplash::progress (float progressValue)
{
QString display = DisplayString.c_str();
// UNCOMMENT if shorter strings are needed
//QFileInfo info(display);
//display = info.filePath();
//QString sec = display.section("/",-2,-1,
// QString::SectionSkipEmpty |
// QString::SectionIncludeTrailingSep |
// QString::SectionIncludeLeadingSep);
//if(display != sec)
// display = sec.prepend("...");
_ui.splashLabel->setText(QString(tr("Adding Folder:\n%1")).arg(display));
_ui.progressBar->setValue(getCropedValue(progressValue) * 100);
QApplication::processEvents();
}
} /* namespace NLQT */

View file

@ -0,0 +1,56 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 <http://www.gnu.org/licenses/>.
*/
#ifndef GEORGES_SPLASH_H
#define GEORGES_SPLASH_H
// Qt includes
#include <QtGui/QWidget>
// STL includes
// NeL includes
// NeL includes
#include <nel/misc/progress_callback.h>
// Project includes
#include "ui_splash.h"
namespace NLMISC {
class IProgressCallback;
}
namespace NLQT
{
class CGeorgesSplash: public QWidget, public NLMISC::IProgressCallback
{
Q_OBJECT
Ui::CGeorgesSplash _ui;
void progress (float progressValue);
public:
CGeorgesSplash(QWidget *parent = 0);
~CGeorgesSplash();
}; /* CGeorgesSplash */
} /* namespace NLQT */
#endif // GEORGES_SPLASH_H

View file

@ -25,10 +25,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QFileDialog>
// NeL includes
#include <nel/georges/u_form.h>
#include <nel/misc/path.h>
#include <nel/misc/file.h>
#include <nel/misc/o_xml.h>
#include <nel/georges/form.h>
// Project includes
#include "modules.h"
@ -47,7 +47,7 @@ namespace NLQT
CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/, bool emptyView /*= false*/)
: QDockWidget(parent)
{
_georges = new NLQT::CGeorges;
_georges = new NLQT::CGeorges;
loadedForm = "";
_modified = false;
@ -80,14 +80,65 @@ namespace NLQT
CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog()
{
delete _ui.treeView->itemDelegateForColumn(1);
delete _form;
deleteLater();
//QSettings settings("RyzomCore", "GeorgesQt");
//settings.setValue("dirViewGeometry", saveGeometry());
}
void CGeorgesTreeViewDialog::selectedForm(QString formName)
void CGeorgesTreeViewDialog::setForm(const CForm *form)
{
_form = _georges->loadForm(formName.toStdString());
_form = (UForm*)form;
}
CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName)
{
if(NLMISC::CPath::exists(formName.toStdString()))
{
return (CForm*)_georges->loadForm(formName.toStdString());
}
else
{
CForm *form = 0;
// Load the DFN
std::string extStr = NLMISC::CFile::getExtension( formName.toStdString() );
QString dfnName = QString("%1.dfn").arg(extStr.c_str());
UFormDfn *formdfn;
if (NLMISC::CPath::exists(dfnName.toStdString()))
{
formdfn = _georges->loadFormDfn (dfnName.toStdString());
if (!formdfn)
{
nlwarning("Failed to load dfn: %s", dfnName.toStdString().c_str());
return 0;
}
}
else
{
nlwarning("Cannot find dfn: %s", dfnName.toStdString().c_str());
return 0;
}
form = new CForm;
// Build the root element
((CFormElmStruct*)&form->getRootNode())->build((CFormDfn*)formdfn);
uint i;
for (i=0; i<CForm::HeldElementCount; i++)
{
((CFormElmStruct*)(((CForm*)form)->HeldElements[i]))->build ((CFormDfn*)formdfn);
}
return form;
}
return 0;
}
void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form)
{
if(form)
_form = form;
if (_form)
{
@ -118,7 +169,7 @@ namespace NLQT
Q_FOREACH(std::string str, dependencies)
{
QString file = str.c_str();
if (file == formName) continue;
if (str == _form->getFilename()) continue;
deps[file.remove(0,file.indexOf(".")+1)] << str.c_str();
}
nlinfo("typ's %d",deps["typ"].count());
@ -127,7 +178,7 @@ namespace NLQT
//nlwarning(strList.join(";").toStdString().c_str());
if (root)
{
loadedForm = formName;
loadedForm = _form->getFilename().c_str();
CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents);
CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel();
@ -145,12 +196,17 @@ namespace NLQT
connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)),
this, SLOT(modifiedFile()));
Modules::mainWin().setWindowTitle("Qt Georges Editor - " + formName);
Modules::mainWin().setWindowTitle("Qt Georges Editor - " + loadedForm);
//Modules::mainWin().getTabBar();
}
}
}
void CGeorgesTreeViewDialog::addParentForm(CForm *form)
{
((CForm*)_form)->insertParent(((CForm*)_form)->getParentCount(), form->getFilename().c_str(), form);
}
void CGeorgesTreeViewDialog::modifiedFile( )
{
if (!_modified)
@ -249,7 +305,7 @@ namespace NLQT
CGeorgesFormModel *m =
dynamic_cast<CGeorgesFormModel *>(mp->sourceModel());
QModelIndex in = mp->mapToSource(index);
// col containing additional stuff like icons
if (index.column() == 2)
{
@ -279,9 +335,12 @@ namespace NLQT
{
if (path.contains(".shape"))
{
Modules::objViewInt().resetScene();
//Modules::config().configRemapExtensions();
Modules::objViewInt().loadMesh(path.toStdString(),"");
if (Modules::objViewInt())
{
Modules::objViewInt()->resetScene();
//Modules::config().configRemapExtensions();
Modules::objViewInt()->loadMesh(path.toStdString(),"");
}
return;
}
}
@ -289,7 +348,7 @@ namespace NLQT
// open eg parent files
if (!path.isEmpty())
Q_EMIT changeFile(path);
}
}

View file

@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace NLGEORGES
{
class UForm;
class CForm;
}
using namespace NLGEORGES;
@ -53,6 +54,9 @@ namespace NLQT
bool modified() {return _modified;}
void setModified(bool m) {_modified = m;}
CForm* getFormByName(const QString);
void addParentForm(CForm *form);
void write ( );
QString loadedForm;
@ -64,10 +68,11 @@ namespace NLQT
void changeFile(QString);
void modified(bool);
public Q_SLOTS:
void selectedForm(QString);
void setForm(const CForm*);
void loadFormIntoDialog(CForm *form = 0);
void modifiedFile( );
private Q_SLOTS:
void doubleClicked ( const QModelIndex & index );
void modifiedFile( );
void filterRows();
private:

View file

@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// project includes
#include "formitem.h"
#include "modules.h"
using namespace NLGEORGES;
@ -141,7 +142,21 @@ namespace NLQT
if (value.contains(".shape"))
{
return QIcon(":/images/pqrticles.png");
if (Modules::objViewInt())
{
QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString());
if (icon)
{
if(icon->isNull())
return QIcon(":/images/pqrticles.png");
else
return QIcon(*icon);
}
else
{
return QIcon();
}
}
}
else if(value.contains(".tga") || value.contains(".png"))
{
@ -166,7 +181,14 @@ namespace NLQT
if (value.contains(".shape"))
{
return QIcon(":/images/pqrticles.png");
if (Modules::objViewInt())
{
QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString());
if (icon->isNull())
return QIcon(":/images/pqrticles.png");
else
return QIcon(*icon);
}
}
else if(value.contains(".tga") || value.contains(".png"))
{
@ -218,6 +240,7 @@ namespace NLQT
if (result)
Q_EMIT dataChanged(index, this->index(index.row(),index.column()+1,index.parent()));
setupModelData();
return result;
}
@ -385,6 +408,10 @@ namespace NLQT
elmtType.append("_unknownType");
}
}
else
{
elmtType.append("_noType");
}
if (numDefinitions)
{
@ -485,9 +512,6 @@ namespace NLQT
columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType;
parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN));
//columnData << QString(elmName.c_str()) << QString("default") << QString("default");
//parent->appendChild(new CFormItem(elmt, columnData, parent, UFormElm::ValueDefaultDfn, UFormElm::NodeDfn));
}
}
else
@ -510,7 +534,6 @@ namespace NLQT
QList<QVariant> columnData;
std::string value;
QString elmtType = "";
//root->getValueByName(value, elmName.c_str());
UFormElm *elmt = 0;
if(root->getArrayNode(&elmt,0) && elmt)
@ -527,6 +550,8 @@ namespace NLQT
}
if (elmt->isVirtualStruct())
elmtType = "VirtualStruct";
elmtType.append("_arrayValue");
columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType;
parent->appendChild(new CFormItem(elmt, columnData, parent));
loadFormData(elmt, parent->child(parent->childCount()-1));

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -7,6 +7,7 @@
#include <QFile>
#include <QDateTime>
#include <QTextStream>
#include <QSplashScreen>
// NeL includes
#include <nel/misc/debug.h>
@ -18,6 +19,7 @@
// Project includes
#include "modules.h"
#include "georges_splash.h"
// nel_qt log file name
#define NLQT_LOG_FILE "nel_qt.log"
@ -84,6 +86,11 @@ void messageHandler(QtMsgType p_type, const char* p_msg)
sint main(int argc, char **argv)
{
QApplication app(argc, argv);
QPixmap pixmap(":/images/georges_logo.png");
NLQT::CGeorgesSplash splash;
splash.show();
app.processEvents();
NLMISC::CApplicationContext myApplicationContext;
#if defined(NL_OS_MAC)
@ -120,9 +127,10 @@ sint main(int argc, char **argv)
NLMISC::CPath::remapExtension("tga", "png", true);
}
Modules::init();
Modules::init(&splash);
//Modules::mainWin().resize(800,600);
Modules::mainWin().show();
splash.close();
int result = app.exec();
Modules::release();
return result;

View file

@ -24,11 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtGui/QtGui>
// NeL includes
#include <nel/misc/path.h>
// Project includes
#include "modules.h"
#include "settings_dialog.h"
#include "log_dialog.h"
#include "new_dialog.h"
#include "objectviewer_dialog.h"
#include "georges_dirtree_dialog.h"
#include "georges_treeview_dialog.h"
@ -60,16 +62,16 @@ namespace NLQT
_currentView = 0;
// load and set leveldesign path from config
QString ldPath = Modules::config().
_leveldesignPath = Modules::config().
getValue("LeveldesignPath", QString("").toStdString()).c_str();
QFileInfo info(ldPath);
QFileInfo info(_leveldesignPath);
if (!info.isDir())
ldPath = "";
_leveldesignPath = "";
// create georges dir dock widget
_GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(ldPath, this);
_GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(_leveldesignPath, this);
addDockWidget(Qt::LeftDockWidgetArea, _GeorgesDirTreeDialog);
if (ldPath == "")
if (_leveldesignPath == "")
{
if (QMessageBox::information(this, tr("Missing leveldesign path"),
tr("Your leveldesign path seems to be empty or incorrect.\nDo you want to set it now?"),
@ -101,8 +103,8 @@ namespace NLQT
connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
_statusBarTimer->start(5000);
connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(QString)),
this, SLOT(openTreeView(QString)));
connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(const QString)),
this, SLOT(loadFile(const QString)));
}
CMainWindow::~CMainWindow()
@ -135,11 +137,11 @@ namespace NLQT
event->accept();
}
void CMainWindow::openTreeView(QString file)
CGeorgesTreeViewDialog * CMainWindow::createTreeView(QString file)
{
// create or/and raise tree view dock widget for current file
setCurrentFile(file);
//setCurrentFile(file);
CGeorgesTreeViewDialog *newView = 0;
@ -172,7 +174,9 @@ namespace NLQT
}
_treeViewList.append(newView);
newView->selectedForm(file);
//newView->selectedForm(file);
_currentView = newView;
connect(newView, SIGNAL(changeFile(QString)),
@ -182,6 +186,8 @@ namespace NLQT
}
QApplication::processEvents();
newView->raise();
return newView;
}
void CMainWindow::settings()
@ -210,33 +216,9 @@ namespace NLQT
void CMainWindow::open()
{
/*QStringList fileNames = QFileDialog::getOpenFileNames(this,
tr("Open NeL data file"), _lastDir,
tr("All NeL files (*.shape *.ps);;"
"NeL shape files (*.shape);;"
"NeL particle system files (*.ps)"));
setCursor(Qt::WaitCursor);
if (!fileNames.isEmpty())
{
QStringList list = fileNames;
QStringList::Iterator it = list.begin();
_lastDir = QFileInfo(*it).absolutePath();
QString skelFileName = QFileDialog::getOpenFileName(this,
tr("Open skeleton file"), _lastDir,
tr("NeL skeleton file (*.skel)"));
while(it != list.end())
{
loadFile(*it, skelFileName);
++it;
}
_AnimationSetDialog->updateListObject();
_AnimationSetDialog->updateListAnim();
_SlotManagerDialog->updateUiSlots();
}
setCursor(Qt::ArrowCursor);*/
// TODO: FileDialog & loadFile();
QString fileName = QFileDialog::getOpenFileName();
loadFile(fileName);
}
void CMainWindow::save()
@ -246,6 +228,21 @@ namespace NLQT
setCursor(Qt::WaitCursor);
//TODO: if not exists open FileDialog SaveAs...
if(!CPath::exists(_currentView->loadedForm.toStdString()))
{
QString fileName = QFileDialog::getSaveFileName(
this,
QString(),
_currentView->loadedForm
);
QFile file(fileName);
file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
file.close();
CPath::addSearchFile(fileName.toStdString());
//QFileInfo info = QFileInfo(file);
//m->setData(in2, info.fileName());
}
_currentView->write();
setWindowTitle(windowTitle().remove("*"));
_saveAction->setEnabled(false);
@ -255,6 +252,31 @@ namespace NLQT
void CMainWindow::create()
{
QStringList lst;
CGeorgesNewDialog dlg(lst);
dlg.exec();
qDebug() << lst;
if (!lst.isEmpty() && !lst.at(0).isEmpty())
{
QString formName = lst.takeFirst();
CGeorgesTreeViewDialog * newView = 0;
newView = createTreeView(formName);
CForm* form = newView->getFormByName(formName);
newView->setForm(form);
Q_FOREACH(QString dep, lst)
{
newView->addParentForm(newView->getFormByName(dep));
}
newView->loadFormIntoDialog();
//TODO: look into setFilename for new Form object
if(newView->loadedForm.isEmpty())
{
newView->loadedForm = formName;
setWindowTitle("Qt Georges Editor - " + formName);
}
newView->modifiedFile();
}
}
void CMainWindow::createEmptyView(QDockWidget* w)
@ -442,6 +464,24 @@ namespace NLQT
}
}
void CMainWindow::loadFile(QString fileName){
QFileInfo info(fileName);
fileName = info.fileName();
// TODO: make georges static and stuff
CGeorgesTreeViewDialog *newView = new CGeorgesTreeViewDialog;
CForm *form = newView->getFormByName(fileName);
if (form)
{
delete newView;
newView = createTreeView(fileName);
newView->setForm(form);
newView->loadFormIntoDialog(form);
setCurrentFile(fileName);
return;
}
delete newView;
}
void CMainWindow::openRecentFile()
{
QAction *action = qobject_cast<QAction *>(sender());
@ -496,28 +536,6 @@ namespace NLQT
_separatorAction->setVisible(numRecentFiles > 0);
}
void CMainWindow::loadFile(const QString &fileName)
{
/*QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Recent Files"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return;
}
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
textEdit->setPlainText(in.readAll());
QApplication::restoreOverrideCursor();*/
openTreeView(fileName);
setCurrentFile(fileName);
//statusBar()->showMessage(tr("File loaded"), 2000);
}
} /* namespace NLQT */
/* end of file */

View file

@ -60,6 +60,8 @@ namespace NLQT
void createEmptyView(QDockWidget* w = 0);
void closeEvent(QCloseEvent *event);
QString leveldesignPath() { return _leveldesignPath; }
private Q_SLOTS:
void open();
void create();
@ -67,9 +69,10 @@ namespace NLQT
void settings();
void about();
void updateStatusBar();
void openTreeView(QString);
CGeorgesTreeViewDialog * createTreeView(QString);
void tabChanged(int);
void openRecentFile();
void loadFile(QString fileName);
private:
void createActions();
@ -77,8 +80,7 @@ namespace NLQT
void createToolBars();
void createStatusBar();
void createDialogs();
void loadFile(const QString &fileName);
void updateRecentFileActions();
void setCurrentFile(const QString &fileName);
@ -113,6 +115,7 @@ namespace NLQT
QAction *_aboutQtAction;
QAction *_separatorAction;
QString _leveldesignPath;
enum { MaxRecentFiles = 5 };
QAction *recentFileActs[MaxRecentFiles];

View file

@ -29,14 +29,17 @@ NLQT::CConfiguration *Modules::_configuration = NULL;
NLQT::IObjectViewer *Modules::_objViewerInterface = NULL;
NLQT::CMainWindow *Modules::_mainWindow = NULL;
void Modules::init()
void Modules::init(NLMISC::IProgressCallback *cb)
{
loadPlugin();
if (loadPlugin())
{
_objViewerInterface->setNelContext(NLMISC::INelContext::getInstance());
}
if (_configuration == NULL) _configuration = new NLQT::CConfiguration;
_configuration->setProgressCallback(cb);
config().init();
_configuration->setProgressCallback(0);
if (_mainWindow == NULL) _mainWindow = new NLQT::CMainWindow;
}

View file

@ -23,14 +23,18 @@
#include "main_window.h"
#include "interfaces.h"
namespace NLMISC {
class IProgressCallback;
}
class Modules
{
public:
static void init();
static void init(NLMISC::IProgressCallback *cb);
static void release();
static NLQT::CConfiguration &config() { return *_configuration; }
static NLQT::IObjectViewer &objViewInt() { return *_objViewerInterface; }
static NLQT::IObjectViewer* objViewInt() { return _objViewerInterface; }
static NLQT::CMainWindow &mainWin() { return *_mainWindow; }
private:
static bool loadPlugin();

View file

@ -0,0 +1,341 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 <http://www.gnu.org/licenses/>.
*/
#include "new_dialog.h"
// Qt includes
#include <QtGui/QWidget>
#include <QFile>
#include <QDateTime>
#include <QTextStream>
#include <QMessageBox>
#include <QDebug>
// NeL includes
#include <nel/misc/path.h>
// Project includes
#include "modules.h"
#include "completer_line_edit.h"
namespace NLQT
{
CGeorgesNewDialog::CGeorgesNewDialog(QStringList& result, QWidget *parent)
: QDialog(parent),
_result(result),
_descriptionTemplate(QString())
{
_ui.setupUi(this);
setWindowIcon(QIcon(":/images/georges_logo.png"));
_ui.parentLineEdit->setEnabled(false);
_ui.addParentButton->setEnabled(true);
// wizard page
connect(_ui.wizardBtn, SIGNAL(clicked(bool)),
this, SLOT(wizardBtnClicked(bool)));
connect(_ui.wizardList, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(wizardItemActivated(QListWidgetItem *)));
// form page
connect(_ui.formBtn, SIGNAL(clicked(bool)),
this, SLOT(formBtnClicked(bool)));
connect(_ui.addParentButton, SIGNAL(clicked()),
this, SLOT(addParentClicked()));
connect(_ui.deleteParentButton, SIGNAL(clicked()),
this, SLOT(deleteParentClicked()));
connect(_ui.formList, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(formItemActivated(QListWidgetItem *)));
connect(_ui.formList, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(formItemActivated(QListWidgetItem *)));
connect(_ui.parentLineEdit, SIGNAL(editingFinished()),
this, SLOT(validateParentCombo()));
// dfn page
connect(_ui.dfnTypeBtn, SIGNAL(clicked(bool)),
this, SLOT(dfnTypeClicked(bool)));
connect(_ui.buttonBox, SIGNAL(accepted()),
this, SLOT(buttonBoxAccepted()));
connect(_ui.buttonBox, SIGNAL(rejected()),
this, SLOT(buttonBoxRejected()));
// wizard list
QListWidgetItem *mpWiz = new QListWidgetItem(QIcon(":/images/mp_generic.png"),tr("Raw Material Generator"));
_ui.wizardList->addItem(mpWiz);
// form list
QString path = Modules::mainWin().leveldesignPath();
QStringList typelist;
//nlinfo ("Searching files in directory '%s'...", dir.c_str());
NLMISC::CPath::getPathContent(path.toStdString(),true,false,true,_files);
getTypes(path.toStdString());
//nlinfo ("%d supported file types :",FileTypeToId.size());
for ( std::map<std::string,uint8>::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it )
{
typelist.append(QString((*it).first.c_str()));
//nlinfo("%s",(*it).first.c_str());
}
_ui.formList->addItems(typelist);
for(uint i = 0; i < _files.size(); i++)
{
std::string extStr = NLMISC::CFile::getExtension( _files[i] );
// filter files without existing dfn
if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString()) &&
!NLMISC::CPath::exists(QString("%1.typ").arg(extStr.c_str()).toStdString()))
{
continue;
}
_filelist.append(QString(NLMISC::CFile::getFilename(_files[i]).c_str()));
}
_ui.parentFrame->hide();
// replace "Heading" and "Descriptive Text" with your string
_descriptionTemplate =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\""
"\"http://www.w3.org/TR/REC-html40/strict.dtd\">"
"\n<html><head><meta name=\"qrichtext\" content=\"1\" />"
"<style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style>"
"</head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">"
"\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
"<span style=\" font-size:8pt; font-weight:600;\">Heading</span></p>"
"\n<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
"<span style=\" font-size:8pt;\">Descriptive Text</span></p></body></html>";
}
CGeorgesNewDialog::~CGeorgesNewDialog()
{
}
void CGeorgesNewDialog::wizardBtnClicked(bool p_checked)
{
if(p_checked)
_ui.stackedWidget->setCurrentWidget(_ui.wizardPage);
else
_ui.wizardBtn->setChecked(true);
}
void CGeorgesNewDialog::formBtnClicked(bool p_checked)
{
if(p_checked)
_ui.stackedWidget->setCurrentWidget(_ui.formPage);
else
_ui.formBtn->setChecked(true);
}
void CGeorgesNewDialog::dfnTypeClicked(bool p_checked)
{
if(p_checked)
_ui.stackedWidget->setCurrentWidget(_ui.dfnTypePage);
else
_ui.dfnTypeBtn->setChecked(true);
}
void CGeorgesNewDialog::addParentClicked()
{
if (!_filelist.contains(_ui.parentLineEdit->text()))
{
_ui.parentLineEdit->clear();
return;
}
_ui.parentFrame->show();
QList<QListWidgetItem *> itemList = _ui.parentList->
findItems(_ui.parentLineEdit->text(), Qt::MatchFixedString);
if ((itemList.count() == 0) && (!_ui.parentLineEdit->text().isEmpty()))
{
_ui.parentList->insertItem(_ui.parentList->count(), _ui.parentLineEdit->text());
}
_ui.parentLineEdit->clear();
}
void CGeorgesNewDialog::deleteParentClicked()
{
_ui.parentList->takeItem(_ui.parentList->currentRow());
if (_ui.parentList->count() == 0)
{
_ui.parentFrame->hide();
}
}
void CGeorgesNewDialog::buttonBoxAccepted()
{
if (_ui.stackedWidget->currentWidget() == _ui.formPage)
{
_result << _ui.formFileNameEdit->text();
for (int i = 0; i < _ui.parentList->count(); i++)
{
_result << _ui.parentList->item(i)->text();
}
}
else
{
QMessageBox::information(this,"Information","Not yet included.\nSoon to come! :)");
}
}
void CGeorgesNewDialog::buttonBoxRejected()
{
// TODO
}
void CGeorgesNewDialog::formItemActivated(QListWidgetItem *item)
{
_ui.formFileNameEdit->setText(QString(tr("newfile.%1").arg(item->text())));
_ui.parentLineEdit->setEnabled(true);
_ui.parentLineEdit->setText("");
//_ui.addParentButton->setEnabled(false);
QStringList list = _filelist.filter(item->text());
_ui.parentLineEdit->setStringList(list);
_ui.formFileNameEdit->setFocus();
_ui.formFileNameEdit->setSelection(0, tr("newfile").size());
}
void CGeorgesNewDialog::wizardItemActivated(QListWidgetItem *item)
{
QString myDescription = _descriptionTemplate;
myDescription = myDescription.replace("Heading", item->text());
if (item->text() == tr("Raw Material Generator"))
{
myDescription = myDescription.replace("Descriptive Text",
tr("Automatically creates MP (resources) for every creature in the assets."));
}
_ui.wizDescLabel->setText(myDescription);
}
void CGeorgesNewDialog::getTypes( std::string& dir )
{
//nlinfo ("Found %d files in directory '%s'", files.size(), dir.c_str());
for(uint i = 0; i < _files.size(); i++)
{
addType(NLMISC::CFile::getFilename(_files[i]));
QApplication::processEvents();
}
}
void CGeorgesNewDialog::addType( std::string fileName )
{
if(fileName.empty() || fileName=="." || fileName==".." || fileName[0]=='_' || fileName.find(".#")==0)
{
//nlinfo("Discarding file '%s'", fileName.c_str());
return;
}
else
{
std::string extStr = NLMISC::CFile::getExtension( fileName );
if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString()))
{
return;
}
}
// if the file is new
std::map<std::string,TFormId>::iterator itFI = FormToId.find( fileName );
if( itFI == FormToId.end() )
{
// double check : if file not found we check with lower case version of filename
std::map<std::string,TFormId>::iterator itFILwr = FormToId.find( NLMISC::toLower(fileName) );
if( itFILwr != FormToId.end() )
{
nlwarning("Trying to add %s but the file %s is already known ! be careful with lower case and upper case.", fileName.c_str(), NLMISC::toLower(fileName).c_str());
return;
}
std::string fileType;
if( getFileType( fileName, fileType ) )
{
std::map<std::string,uint8>::iterator itFTI = FileTypeToId.find( fileType );
TFormId fid;
memset( &fid, 0, sizeof(TFormId) );
// if the type of this file is a new type
if( itFTI == FileTypeToId.end() )
{
sint16 firstFreeFileTypeId = getFirstFreeFileTypeId();
if( firstFreeFileTypeId == -1 )
{
nlwarning("MORE THAN 256 FILE TYPES!!!!");
}
else
{
FileTypeToId.insert( std::make_pair(fileType,(uint8)firstFreeFileTypeId) );
IdToFileType.insert( std::make_pair((uint8)firstFreeFileTypeId,fileType) );
fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId;
fid.FormIDInfos.Id = 0;
//nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId);
}
}
else
{
return;
}
FormToId.insert( make_pair(fileName,fid) );
//nlinfo("Adding file '%s' id %d with type '%s' id %d", fileName.c_str(), fid.FormIDInfos.Id, fileType.c_str(), fid.FormIDInfos.Type);
}
else
{
nlinfo("Unknown file type for the file : '%s' --> not added",fileName.c_str());
}
}
else
{
nlinfo("Skipping file '%s', already in the file", fileName.c_str());
}
}
bool CGeorgesNewDialog::getFileType( std::string& fileName, std::string& fileType )
{
fileType = NLMISC::CFile::getExtension(NLMISC::CFile::getFilename(fileName));
return !fileType.empty();
}
sint16 CGeorgesNewDialog::getFirstFreeFileTypeId()
{
for( sint16 id=0; id<256; ++id )
{
if( IdToFileType.find((uint8)id) == IdToFileType.end() )
{
return id;
}
}
return -1;
}
void CGeorgesNewDialog::validateParentCombo() {
// TODO: clear if no valid text
//if (!_filelist.contains(_ui.parentLineEdit->text()))
// _ui.parentLineEdit->clear();
}
} /* namespace NLQT */

View file

@ -0,0 +1,88 @@
/*
Georges Editor Qt
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com>
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 <http://www.gnu.org/licenses/>.
*/
#ifndef NEW_DIALOG_H
#define NEW_DIALOG_H
// Qt includes
#include <QtGui/QWidget>
// STL includes
// NeL includes
#include <nel/misc/types_nl.h>
#include <nel/misc/file.h>
// Project includes
#include "ui_new_form.h"
namespace NLQT
{
class CGeorgesNewDialog: public QDialog
{
Q_OBJECT
union TFormId
{
uint32 Id;
struct
{
uint32 Type : 8;
uint32 Id : 24;
} FormIDInfos;
void serial(NLMISC::IStream &f) { f.serial(Id); };
};
Ui::CGeorgesNewDialog _ui;
QStringList _filelist;
QStringList &_result;
QString _descriptionTemplate;
std::map<std::string,TFormId> FormToId;
std::map<std::string,uint8> FileTypeToId;
std::map<uint8,std::string> IdToFileType;
std::vector<std::string> _files;
void getTypes( std::string& dir );
void addType( std::string fileName );
bool getFileType( std::string& fileName, std::string& fileType );
sint16 getFirstFreeFileTypeId();
public:
CGeorgesNewDialog(QStringList& result, QWidget *parent = 0);
~CGeorgesNewDialog();
private Q_SLOTS:
void wizardBtnClicked(bool checked);
void formBtnClicked (bool checked);
void dfnTypeClicked (bool p_checked);
void addParentClicked();
void deleteParentClicked();
void formItemActivated(QListWidgetItem *);
void wizardItemActivated(QListWidgetItem *);
void validateParentCombo();
void buttonBoxAccepted();
void buttonBoxRejected();
friend class CMainWindow;
}; /* CGeorgesNewDialog */
} /* namespace NLQT */
#endif // NEW_DIALOG_H

View file

@ -0,0 +1,428 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CGeorgesNewDialog</class>
<widget class="QDialog" name="CGeorgesNewDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>885</width>
<height>520</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Create new form ...</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2" rowspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3" rowspan="2">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="wizardPage">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="wizardGroupBox">
<property name="title">
<string>Choose a wizard ...</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QListWidget" name="wizardList">
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="wizDescGroupBox">
<property name="title">
<string>Description</string>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QLabel" name="wizDescLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="formPage">
<layout class="QGridLayout" name="gridLayout_3">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="formGroupBox">
<property name="title">
<string>Choose type of form ...</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0" colspan="3">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QListWidget" name="formList">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QFrame" name="parentFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>55</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>55</height>
</size>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0" rowspan="2">
<widget class="QListWidget" name="parentList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>55</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="deleteParentButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="formAddParentLabel">
<property name="text">
<string>Add Parent</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="CompleteLineEdit" name="parentLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addParentButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="formFilenameLabel">
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="formFileNameEdit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="dfnTypePage">
<layout class="QGridLayout" name="gridLayout_6">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="dfnTypeGroupBox">
<property name="title">
<string>Create a new dfn or typ file ...</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QRadioButton" name="dfnRadioButton">
<property name="text">
<string>DFN</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="typeRadioButton">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLineEdit" name="filenameLineEdit"/>
</item>
<item row="2" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="3" colspan="2">
<widget class="QFrame" name="frame">
<layout class="QGridLayout" name="gridLayout_8">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCommandLinkButton" name="wizardBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wizards ...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCommandLinkButton" name="formBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Create New Form ...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCommandLinkButton" name="dfnTypeBtn">
<property name="text">
<string>Create DFN or Type ...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>169</width>
<height>308</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CompleteLineEdit</class>
<extends>QLineEdit</extends>
<header>completer_line_edit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>wizardBtn</tabstop>
<tabstop>formBtn</tabstop>
<tabstop>dfnTypeBtn</tabstop>
<tabstop>wizardList</tabstop>
<tabstop>formList</tabstop>
<tabstop>parentList</tabstop>
<tabstop>formFileNameEdit</tabstop>
<tabstop>dfnRadioButton</tabstop>
<tabstop>typeRadioButton</tabstop>
<tabstop>filenameLineEdit</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CGeorgesNewDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>350</x>
<y>598</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CGeorgesNewDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>418</x>
<y>598</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -41,14 +41,17 @@ using namespace NL3D;
namespace NLQT
{
CObjectViewerDialog::CObjectViewerDialog(QWidget *parent)
: QDockWidget(parent)
CObjectViewerDialog::CObjectViewerDialog(QWidget *parent) :QDockWidget(parent),
_nlw(0)
{
_ui.setupUi(this);
_nlw = dynamic_cast<QNLWidget*>(Modules::objViewInt().getWidget());
//_nlw->setObjectName(QString::fromUtf8("nlwidget"));
_ui.gridLayout->addWidget(_nlw, 0, 0);
if (Modules::objViewInt())
{
_nlw = dynamic_cast<QNLWidget*>(Modules::objViewInt()->getWidget());
//_nlw->setObjectName(QString::fromUtf8("nlwidget"));
_ui.gridLayout->addWidget(_nlw, 0, 0);
}
}
CObjectViewerDialog::~CObjectViewerDialog()
@ -97,8 +100,10 @@ namespace NLQT
{
//nldebug("%d %d",_nlw->width(), _nlw->height());
QDockWidget::resizeEvent(resizeEvent);
if (Modules::objViewInt().getDriver())
Modules::objViewInt().setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height());
if (Modules::objViewInt()) {
if (Modules::objViewInt()->getDriver())
Modules::objViewInt()->setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height());
}
// The OpenGL driver does not resize automatically.
// The Direct3D driver breaks the window mode to include window borders when calling setMode windowed.

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QLabel>
#include <QApplication>
#include <QProgressBar>
#include <QIcon>
// STL includes
// NeL includes
@ -47,6 +48,7 @@ namespace NLQT
resize(250, 100);
_progressBar->setMinimum(0);
_progressBar->setMaximum(100);
setWindowIcon(QIcon(":/images/georges_logo.png"));
}
CProgressDialog::~CProgressDialog()

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CGeorgesSplash</class>
<widget class="QWidget" name="CGeorgesSplash">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>337</width>
<height>214</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0" colspan="2">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="splashLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Initializing ...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;Georges Editor Qt&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;for&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Ryzom Core&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;by&lt;/span&gt;&lt;/p&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;aquiles&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="imageLabel">
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>