Changed: #1301 Added load landscape from file. Added initial snapshot dialog.
--HG-- branch : gsoc2011-worldeditorqthg/feature/sse2
parent
0a870aeb12
commit
7099b96a90
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SnapshotDialog</class>
|
||||
<widget class="QDialog" name="SnapshotDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>286</width>
|
||||
<height>182</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Snapshot</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="originalSizeRadioButton">
|
||||
<property name="text">
|
||||
<string>Original size</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="customSizeRadioButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="widthSpinBox">
|
||||
<property name="maximum">
|
||||
<number>99999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>512</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>heightSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="heightSpinBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>99999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>512</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>widthSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="keepRatioCheckBox">
|
||||
<property name="text">
|
||||
<string>Keep bitmap ratio</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>originalSizeRadioButton</tabstop>
|
||||
<tabstop>customSizeRadioButton</tabstop>
|
||||
<tabstop>widthSpinBox</tabstop>
|
||||
<tabstop>heightSpinBox</tabstop>
|
||||
<tabstop>keepRatioCheckBox</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SnapshotDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>227</x>
|
||||
<y>164</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>SnapshotDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>276</x>
|
||||
<y>170</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>285</x>
|
||||
<y>158</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>customSizeRadioButton</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>groupBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>59</x>
|
||||
<y>39</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>78</x>
|
||||
<y>62</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>keepRatioCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>heightSpinBox</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>84</x>
|
||||
<y>122</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>178</x>
|
||||
<y>106</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>keepRatioCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>label_2</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>55</x>
|
||||
<y>129</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>48</x>
|
||||
<y>103</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -0,0 +1,45 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Project includes
|
||||
#include "snapshot_dialog.h"
|
||||
#include "landscape_editor_constants.h"
|
||||
|
||||
#include "../core/icore.h"
|
||||
#include "../core/core_constants.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFileDialog>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
SnapshotDialog::SnapshotDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
}
|
||||
|
||||
SnapshotDialog::~SnapshotDialog()
|
||||
{
|
||||
}
|
||||
|
||||
} /* namespace LandscapeEditor */
|
@ -0,0 +1,47 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef SNAPSHOT_DIALOG_H
|
||||
#define SNAPSHOT_DIALOG_H
|
||||
|
||||
// Project includes
|
||||
#include "ui_shapshot_dialog.h"
|
||||
|
||||
// Qt includes
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
class SnapshotDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SnapshotDialog(QWidget *parent = 0);
|
||||
~SnapshotDialog();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Ui::SnapshotDialog m_ui;
|
||||
}; /* class SnapshotDialog */
|
||||
|
||||
} /* namespace LandscapeEditor */
|
||||
|
||||
#endif // SNAPSHOT_DIALOG_H
|
@ -0,0 +1,119 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Project includes
|
||||
#include "zone_region_editor.h"
|
||||
|
||||
// NeL includes
|
||||
#include <nel/misc/debug.h>
|
||||
#include <nel/misc/file.h>
|
||||
#include <nel/misc/i_xml.h>
|
||||
#include <nel/misc/o_xml.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
ZoneRegionEditor::ZoneRegionEditor()
|
||||
{
|
||||
m_fileName = "";
|
||||
}
|
||||
|
||||
ZoneRegionEditor::~ZoneRegionEditor()
|
||||
{
|
||||
}
|
||||
|
||||
bool ZoneRegionEditor::load(const std::string &fileName)
|
||||
{
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
// Open it
|
||||
NLMISC::CIFile fileIn;
|
||||
if (fileIn.open(fileName))
|
||||
{
|
||||
NLMISC::CIXml xml(true);
|
||||
xml.init(fileIn);
|
||||
m_zoneRegion.serial(xml);
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Can't open file %s for reading", fileName.c_str());
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
catch (NLMISC::Exception& e)
|
||||
{
|
||||
nlwarning("Error reading file %s : %s", fileName.c_str(), e.what ());
|
||||
result = false;
|
||||
}
|
||||
if (result)
|
||||
m_fileName = fileName;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ZoneRegionEditor::save()
|
||||
{
|
||||
if (m_fileName.empty())
|
||||
return false;
|
||||
|
||||
bool result = true;
|
||||
// Save the landscape
|
||||
try
|
||||
{
|
||||
|
||||
// Open file for writing
|
||||
NLMISC::COFile fileOut;
|
||||
if (fileOut.open(m_fileName, false, false, true))
|
||||
{
|
||||
// Be careful with the flushing of the COXml object
|
||||
{
|
||||
NLMISC::COXml xmlOut;
|
||||
xmlOut.init(&fileOut);
|
||||
m_zoneRegion.serial(xmlOut);
|
||||
// Done
|
||||
m_modified = false;
|
||||
}
|
||||
fileOut.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Can't open file %s for writing.", m_fileName.c_str());
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
catch (NLMISC::Exception& e)
|
||||
{
|
||||
nlwarning("Error writing file %s : %s", m_fileName.c_str(), e.what());
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void ZoneRegionEditor::setFileName(const std::string &fileName)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
}
|
||||
|
||||
NLLIGO::CZoneRegion &ZoneRegionEditor::zoneRegion()
|
||||
{
|
||||
return m_zoneRegion;
|
||||
}
|
||||
|
||||
} /* namespace LandscapeEditor */
|
@ -0,0 +1,62 @@
|
||||
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef LANDSCAPE_EDITOR_H
|
||||
#define LANDSCAPE_EDITOR_H
|
||||
|
||||
// Project includes
|
||||
|
||||
// NeL includes
|
||||
#include <nel/ligo/zone_bank.h>
|
||||
#include <nel/ligo/zone_region.h>
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
|
||||
// Qt includes
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
class ZoneRegionEditor
|
||||
{
|
||||
public:
|
||||
ZoneRegionEditor();
|
||||
~ZoneRegionEditor();
|
||||
|
||||
// Load landscape data from file
|
||||
bool load(const std::string &fileName);
|
||||
|
||||
// Save landscape data to file
|
||||
bool save();
|
||||
|
||||
// Set file name
|
||||
void setFileName(const std::string &fileName);
|
||||
|
||||
NLLIGO::CZoneRegion &zoneRegion();
|
||||
|
||||
private:
|
||||
|
||||
bool m_modified;
|
||||
bool m_editable;
|
||||
std::string m_fileName;
|
||||
NLLIGO::CZoneRegion m_zoneRegion;
|
||||
};
|
||||
|
||||
} /* namespace LandscapeEditor */
|
||||
|
||||
#endif // LANDSCAPE_EDITOR_H
|
Loading…
Reference in New Issue