forked from teamnwah/openmw-tes3coop
Merge branch 'master' of https://github.com/zinnschlag/openmw.git into AICombat
Conflicts: apps/openmw/mwmechanics/actors.cpp apps/openmw/mwscript/docs/vmformat.txtactorid
commit
d587f3c946
@ -1,24 +1,53 @@
|
||||
build
|
||||
*~
|
||||
Doxygen
|
||||
prebuilt
|
||||
apps/openmw/config.hpp
|
||||
Docs/mainpage.hpp
|
||||
## make
|
||||
CMakeFiles
|
||||
*/CMakeFiles
|
||||
CMakeCache.txt
|
||||
moc_*.cxx
|
||||
cmake_install.cmake
|
||||
*.[ao]
|
||||
CMakeLists.txt.user
|
||||
Makefile
|
||||
makefile
|
||||
data
|
||||
build
|
||||
prebuilt
|
||||
|
||||
## doxygen
|
||||
Doxygen
|
||||
|
||||
## ides/editors
|
||||
*~
|
||||
*.kdev4
|
||||
CMakeLists.txt.user
|
||||
*.swp
|
||||
*.swo
|
||||
*.kate-swp
|
||||
.cproject
|
||||
.project
|
||||
.settings/
|
||||
.settings
|
||||
.directory
|
||||
|
||||
## resources
|
||||
data
|
||||
resources
|
||||
/*.cfg
|
||||
/*.desktop
|
||||
/*.install
|
||||
|
||||
## binaries
|
||||
/esmtool
|
||||
/mwiniimport
|
||||
/omwlauncher
|
||||
/openmw
|
||||
/opencs
|
||||
|
||||
## generated objects
|
||||
apps/openmw/config.hpp
|
||||
Docs/mainpage.hpp
|
||||
moc_*.cxx
|
||||
*.cxx_parameters
|
||||
*qrc_launcher.cxx
|
||||
*qrc_resources.cxx
|
||||
*__*
|
||||
*ui_datafilespage.h
|
||||
*ui_graphicspage.h
|
||||
*ui_mainwindow.h
|
||||
*ui_playpage.h
|
||||
*.[ao]
|
||||
*.so
|
||||
|
@ -1,6 +0,0 @@
|
||||
#include "ocspropertywidget.hpp"
|
||||
|
||||
OcsPropertyWidget::OcsPropertyWidget(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef OCSPROPERTYWIDGET_HPP
|
||||
#define OCSPROPERTYWIDGET_HPP
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class OcsPropertyWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OcsPropertyWidget(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // OCSPROPERTYWIDGET_HPP
|
@ -0,0 +1,91 @@
|
||||
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QStyle>
|
||||
|
||||
CSVDoc::AdjusterWidget::AdjusterWidget (QWidget *parent)
|
||||
: QWidget (parent), mValid (false)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout (this);
|
||||
|
||||
mIcon = new QLabel (this);
|
||||
|
||||
layout->addWidget (mIcon, 0);
|
||||
|
||||
mMessage = new QLabel (this);
|
||||
mMessage->setWordWrap (true);
|
||||
mMessage->setSizePolicy (QSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum));
|
||||
|
||||
layout->addWidget (mMessage, 1);
|
||||
|
||||
setName ("", false);
|
||||
|
||||
setLayout (layout);
|
||||
}
|
||||
|
||||
void CSVDoc::AdjusterWidget::setLocalData (const boost::filesystem::path& localData)
|
||||
{
|
||||
mLocalData = localData;
|
||||
}
|
||||
|
||||
boost::filesystem::path CSVDoc::AdjusterWidget::getPath() const
|
||||
{
|
||||
if (!mValid)
|
||||
throw std::logic_error ("invalid content file path");
|
||||
|
||||
return mResultPath;
|
||||
}
|
||||
|
||||
void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
||||
{
|
||||
QString message;
|
||||
|
||||
if (name.isEmpty())
|
||||
{
|
||||
mValid = false;
|
||||
message = "No name.";
|
||||
}
|
||||
else
|
||||
{
|
||||
boost::filesystem::path path (name.toUtf8().data());
|
||||
|
||||
path.replace_extension (addon ? ".omwaddon" : ".omwgame");
|
||||
|
||||
if (path.parent_path().string()==mLocalData.string())
|
||||
{
|
||||
// path already points to the local data directory
|
||||
message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str());
|
||||
mResultPath = path;
|
||||
mValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// path points somewhere else or is a leaf name.
|
||||
path = mLocalData / path.filename();
|
||||
|
||||
message = QString::fromUtf8 (("Will be saved as: " + path.string()).c_str());
|
||||
mResultPath = path;
|
||||
mValid = true;
|
||||
|
||||
if (boost::filesystem::exists (path))
|
||||
{
|
||||
/// \todo add an user setting to make this an error.
|
||||
message += "<p>But a file with the same name already exists. If you continue, it will be overwritten.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mMessage->setText (message);
|
||||
mIcon->setPixmap (style()->standardIcon (
|
||||
mValid ? QStyle::SP_MessageBoxInformation : QStyle::SP_MessageBoxWarning).
|
||||
pixmap (QSize (16, 16)));
|
||||
|
||||
emit stateChanged (mValid);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#ifndef CSV_DOC_ADJUSTERWIDGET_H
|
||||
#define CSV_DOC_ADJUSTERWIDGET_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class AdjusterWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
boost::filesystem::path mLocalData;
|
||||
QLabel *mMessage;
|
||||
QLabel *mIcon;
|
||||
bool mValid;
|
||||
boost::filesystem::path mResultPath;
|
||||
|
||||
public:
|
||||
|
||||
AdjusterWidget (QWidget *parent = 0);
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
|
||||
boost::filesystem::path getPath() const;
|
||||
///< This function must not be called if there is no valid path.
|
||||
|
||||
public slots:
|
||||
|
||||
void setName (const QString& name, bool addon);
|
||||
|
||||
signals:
|
||||
|
||||
void stateChanged (bool valid);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,53 @@
|
||||
|
||||
#include "filewidget.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegExp>
|
||||
|
||||
QString CSVDoc::FileWidget::getExtension() const
|
||||
{
|
||||
return mAddon ? ".omwaddon" : ".omwgame";
|
||||
}
|
||||
|
||||
CSVDoc::FileWidget::FileWidget (QWidget *parent) : QWidget (parent), mAddon (false)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout (this);
|
||||
|
||||
mInput = new QLineEdit (this);
|
||||
mInput->setValidator (new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$")));
|
||||
|
||||
layout->addWidget (mInput, 1);
|
||||
|
||||
mType = new QLabel (this);
|
||||
|
||||
layout ->addWidget (mType);
|
||||
|
||||
connect (mInput, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
||||
|
||||
setLayout (layout);
|
||||
}
|
||||
|
||||
void CSVDoc::FileWidget::setType (bool addon)
|
||||
{
|
||||
mAddon = addon;
|
||||
|
||||
mType->setText (getExtension());
|
||||
}
|
||||
|
||||
QString CSVDoc::FileWidget::getName() const
|
||||
{
|
||||
QString text = mInput->text();
|
||||
|
||||
if (text.isEmpty())
|
||||
return "";
|
||||
|
||||
return text + getExtension();
|
||||
}
|
||||
|
||||
void CSVDoc::FileWidget::textChanged (const QString& text)
|
||||
{
|
||||
emit nameChanged (getName(), mAddon);
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
#ifndef CSV_DOC_FILEWIDGET_H
|
||||
#define CSV_DOC_FILEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QString;
|
||||
class QLineEdit;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class FileWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
bool mAddon;
|
||||
QLineEdit *mInput;
|
||||
QLabel *mType;
|
||||
|
||||
QString getExtension() const;
|
||||
|
||||
public:
|
||||
|
||||
FileWidget (QWidget *parent = 0);
|
||||
|
||||
void setType (bool addon);
|
||||
|
||||
QString getName() const;
|
||||
|
||||
private slots:
|
||||
|
||||
void textChanged (const QString& text);
|
||||
|
||||
signals:
|
||||
|
||||
void nameChanged (const QString& file, bool addon);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,68 @@
|
||||
|
||||
#include "newgame.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "filewidget.hpp"
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
CSVDoc::NewGameDialogue::NewGameDialogue()
|
||||
{
|
||||
setWindowTitle ("Create New Game");
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout (this);
|
||||
|
||||
mFileWidget = new FileWidget (this);
|
||||
mFileWidget->setType (false);
|
||||
|
||||
layout->addWidget (mFileWidget, 1);
|
||||
|
||||
mAdjusterWidget = new AdjusterWidget (this);
|
||||
|
||||
layout->addWidget (mAdjusterWidget, 1);
|
||||
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox (this);
|
||||
|
||||
mCreate = new QPushButton ("Create", this);
|
||||
mCreate->setDefault (true);
|
||||
mCreate->setEnabled (false);
|
||||
|
||||
buttons->addButton (mCreate, QDialogButtonBox::AcceptRole);
|
||||
|
||||
QPushButton *cancel = new QPushButton ("Cancel", this);
|
||||
|
||||
buttons->addButton (cancel, QDialogButtonBox::RejectRole);
|
||||
|
||||
layout->addWidget (buttons);
|
||||
|
||||
setLayout (layout);
|
||||
|
||||
connect (mAdjusterWidget, SIGNAL (stateChanged (bool)), this, SLOT (stateChanged (bool)));
|
||||
connect (mCreate, SIGNAL (clicked()), this, SLOT (create()));
|
||||
connect (cancel, SIGNAL (clicked()), this, SLOT (reject()));
|
||||
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
||||
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
||||
|
||||
QRect scr = QApplication::desktop()->screenGeometry();
|
||||
QRect rect = geometry();
|
||||
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
||||
}
|
||||
|
||||
void CSVDoc::NewGameDialogue::setLocalData (const boost::filesystem::path& localData)
|
||||
{
|
||||
mAdjusterWidget->setLocalData (localData);
|
||||
}
|
||||
|
||||
void CSVDoc::NewGameDialogue::stateChanged (bool valid)
|
||||
{
|
||||
mCreate->setEnabled (valid);
|
||||
}
|
||||
|
||||
void CSVDoc::NewGameDialogue::create()
|
||||
{
|
||||
emit createRequest (mAdjusterWidget->getPath());
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
#ifndef CSV_DOC_NEWGAME_H
|
||||
#define CSV_DOC_NEWGAME_H
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMetaType>
|
||||
|
||||
Q_DECLARE_METATYPE (boost::filesystem::path)
|
||||
|
||||
class QPushButton;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class FileWidget;
|
||||
class AdjusterWidget;
|
||||
|
||||
class NewGameDialogue : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QPushButton *mCreate;
|
||||
FileWidget *mFileWidget;
|
||||
AdjusterWidget *mAdjusterWidget;
|
||||
|
||||
public:
|
||||
|
||||
NewGameDialogue();
|
||||
|
||||
void setLocalData (const boost::filesystem::path& localData);
|
||||
|
||||
signals:
|
||||
|
||||
void createRequest (const boost::filesystem::path& file);
|
||||
|
||||
private slots:
|
||||
|
||||
void stateChanged (bool valid);
|
||||
|
||||
void create();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,46 @@
|
||||
#include "idtypedelegate.hpp"
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
||||
{}
|
||||
|
||||
bool CSVWorld::IdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||
{
|
||||
/// \todo make the setting key a member variable, that is initialised from a constructor argument
|
||||
if (settingName == "Referenceable ID Type Display")
|
||||
{
|
||||
if (settingValue == "Icon and Text")
|
||||
mDisplayMode = Mode_IconAndText;
|
||||
|
||||
else if (settingValue == "Icon Only")
|
||||
mDisplayMode = Mode_IconOnly;
|
||||
|
||||
else if (settingValue == "Text Only")
|
||||
mDisplayMode = Mode_TextOnly;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CSVWorld::IdTypeDelegateFactory::IdTypeDelegateFactory()
|
||||
{
|
||||
for (int i=0; i<CSMWorld::UniversalId::NumberOfTypes; ++i)
|
||||
{
|
||||
CSMWorld::UniversalId id (static_cast<CSMWorld::UniversalId::Type> (i));
|
||||
|
||||
DataDisplayDelegateFactory::add (id.getType(), QString::fromUtf8 (id.getTypeName().c_str()),
|
||||
QString::fromUtf8 (id.getIcon().c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
CSVWorld::CommandDelegate *CSVWorld::IdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||
QObject *parent) const
|
||||
{
|
||||
return new IdTypeDelegate (mValues, mIcons, undoStack, parent);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
#include "refidtypedelegate.hpp"
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
CSVWorld::RefIdTypeDelegate::RefIdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
||||
{}
|
||||
|
||||
bool CSVWorld::RefIdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||
{
|
||||
if (settingName == "Referenceable ID Type Display")
|
||||
{
|
||||
if (settingValue == "Icon and Text")
|
||||
mDisplayMode = Mode_IconAndText;
|
||||
|
||||
else if (settingValue == "Icon Only")
|
||||
mDisplayMode = Mode_IconOnly;
|
||||
|
||||
else if (settingValue == "Text Only")
|
||||
mDisplayMode = Mode_TextOnly;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CSVWorld::RefIdTypeDelegateFactory::RefIdTypeDelegateFactory()
|
||||
{
|
||||
UidTypeList uIdList = buildUidTypeList();
|
||||
|
||||
for (UidTypeList::const_iterator it = uIdList.begin(); it != uIdList.end(); it++)
|
||||
{
|
||||
int i = it->first;
|
||||
DataDisplayDelegateFactory::add (i, QString::fromStdString(CSMWorld::UniversalId(it->first, "").getTypeName()), it->second);
|
||||
}
|
||||
}
|
||||
|
||||
CSVWorld::CommandDelegate *CSVWorld::RefIdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||
QObject *parent) const
|
||||
{
|
||||
return new RefIdTypeDelegate (mValues, mIcons, undoStack, parent);
|
||||
}
|
||||
|
||||
CSVWorld::RefIdTypeDelegateFactory::UidTypeList CSVWorld::RefIdTypeDelegateFactory::buildUidTypeList() const
|
||||
{
|
||||
UidTypeList list;
|
||||
|
||||
std::vector<CSMWorld::UniversalId::Type> types = CSMWorld::UniversalId::listReferenceableTypes();
|
||||
|
||||
for (std::vector<CSMWorld::UniversalId::Type>::const_iterator iter (types.begin());
|
||||
iter!=types.end(); ++iter)
|
||||
{
|
||||
CSMWorld::UniversalId id (*iter, "");
|
||||
|
||||
list.push_back (std::make_pair (id.getType(), id.getIcon().c_str()));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
|
||||
#include "scenesubview.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../filter/filterbox.hpp"
|
||||
|
||||
#include "tablebottombox.hpp"
|
||||
#include "creator.hpp"
|
||||
#include "scenetoolbar.hpp"
|
||||
#include "scenetoolmode.hpp"
|
||||
|
||||
CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: SubView (id)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
layout->addWidget (mBottom =
|
||||
new TableBottomBox (NullCreatorFactory(), document.getData(), document.getUndoStack(), id,
|
||||
this), 0);
|
||||
|
||||
QHBoxLayout *layout2 = new QHBoxLayout;
|
||||
|
||||
layout2->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||
// test
|
||||
SceneToolMode *tool = new SceneToolMode (toolbar);
|
||||
tool->addButton (":door.png", "a");
|
||||
tool->addButton (":GMST.png", "b");
|
||||
tool->addButton (":Info.png", "c");
|
||||
toolbar->addTool (tool);
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
layout2->addWidget (toolbar, 0);
|
||||
|
||||
/// \todo replace with rendering widget
|
||||
QPalette palette2 (palette());
|
||||
palette2.setColor (QPalette::Background, Qt::white);
|
||||
QLabel *placeholder = new QLabel ("Here goes the 3D scene", this);
|
||||
placeholder->setAutoFillBackground (true);
|
||||
placeholder->setPalette (palette2);
|
||||
placeholder->setAlignment (Qt::AlignHCenter);
|
||||
|
||||
layout2->addWidget (placeholder, 1);
|
||||
|
||||
layout->insertLayout (0, layout2, 1);
|
||||
|
||||
CSVFilter::FilterBox *filterBox = new CSVFilter::FilterBox (document.getData(), this);
|
||||
|
||||
layout->insertWidget (0, filterBox);
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
|
||||
widget->setLayout (layout);
|
||||
|
||||
setWidget (widget);
|
||||
}
|
||||
|
||||
void CSVWorld::SceneSubView::setEditLock (bool locked)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSVWorld::SceneSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSVWorld::SceneSubView::setStatusBar (bool show)
|
||||
{
|
||||
mBottom->setStatusBar (show);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#ifndef CSV_WORLD_SCENESUBVIEW_H
|
||||
#define CSV_WORLD_SCENESUBVIEW_H
|
||||
|
||||
#include "../doc/subview.hpp"
|
||||
|
||||
class QModelIndex;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class Table;
|
||||
class TableBottomBox;
|
||||
class CreatorFactoryBase;
|
||||
|
||||
class SceneSubView : public CSVDoc::SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
TableBottomBox *mBottom;
|
||||
|
||||
public:
|
||||
|
||||
SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
virtual void updateEditorSetting (const QString& key, const QString& value);
|
||||
|
||||
virtual void setStatusBar (bool show);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
|
||||
#include "scenetool.hpp"
|
||||
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent)
|
||||
{
|
||||
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
setFixedSize (parent->getButtonSize(), parent->getButtonSize());
|
||||
|
||||
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
||||
}
|
||||
|
||||
void CSVWorld::SceneTool::openRequest()
|
||||
{
|
||||
showPanel (parentWidget()->mapToGlobal (pos()));
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
#ifndef CSV_WORLD_SCENETOOL_H
|
||||
#define CSV_WORLD_SCENETOOL_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class SceneToolbar;
|
||||
|
||||
///< \brief Tool base class
|
||||
class SceneTool : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SceneTool (SceneToolbar *parent);
|
||||
|
||||
virtual void showPanel (const QPoint& position) = 0;
|
||||
|
||||
private slots:
|
||||
|
||||
void openRequest();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "scenetool.hpp"
|
||||
|
||||
CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
|
||||
: QWidget (parent), mButtonSize (buttonSize)
|
||||
{
|
||||
setFixedWidth (mButtonSize);
|
||||
|
||||
mLayout = new QVBoxLayout (this);
|
||||
mLayout->setAlignment (Qt::AlignTop);
|
||||
|
||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
setLayout (mLayout);
|
||||
}
|
||||
|
||||
void CSVWorld::SceneToolbar::addTool (SceneTool *tool)
|
||||
{
|
||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||
}
|
||||
|
||||
int CSVWorld::SceneToolbar::getButtonSize() const
|
||||
{
|
||||
return mButtonSize;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
#ifndef CSV_WORLD_SCENETOOLBAR_H
|
||||
#define CSV_WORLD_SCENETOOLBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class SceneTool;
|
||||
|
||||
class SceneToolbar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QVBoxLayout *mLayout;
|
||||
int mButtonSize;
|
||||
|
||||
public:
|
||||
|
||||
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
||||
|
||||
void addTool (SceneTool *tool);
|
||||
|
||||
int getButtonSize() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,56 @@
|
||||
|
||||
#include "scenetoolmode.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QFrame>
|
||||
#include <QSignalMapper>
|
||||
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent)
|
||||
: SceneTool (parent), mButtonSize (parent->getButtonSize())
|
||||
{
|
||||
mPanel = new QFrame (this, Qt::Popup);
|
||||
|
||||
mLayout = new QHBoxLayout (mPanel);
|
||||
|
||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
mPanel->setLayout (mLayout);
|
||||
}
|
||||
|
||||
void CSVWorld::SceneToolMode::showPanel (const QPoint& position)
|
||||
{
|
||||
mPanel->move (position);
|
||||
mPanel->show();
|
||||
}
|
||||
|
||||
void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::string& id)
|
||||
{
|
||||
QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel);
|
||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
button->setFixedSize (mButtonSize, mButtonSize);
|
||||
|
||||
mLayout->addWidget (button);
|
||||
|
||||
mButtons.insert (std::make_pair (button, id));
|
||||
|
||||
connect (button, SIGNAL (clicked()), this, SLOT (selected()));
|
||||
|
||||
if (mButtons.size()==1)
|
||||
setIcon (button->icon());
|
||||
}
|
||||
|
||||
void CSVWorld::SceneToolMode::selected()
|
||||
{
|
||||
std::map<QPushButton *, std::string>::const_iterator iter =
|
||||
mButtons.find (dynamic_cast<QPushButton *> (sender()));
|
||||
|
||||
if (iter!=mButtons.end())
|
||||
{
|
||||
mPanel->hide();
|
||||
|
||||
setIcon (iter->first->icon());
|
||||
emit modeChanged (iter->second);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#ifndef CSV_WORLD_SCENETOOL_MODE_H
|
||||
#define CSV_WORLD_SCENETOOL_MODE_H
|
||||
|
||||
#include "scenetool.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
class QHBoxLayout;
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class SceneToolbar;
|
||||
|
||||
///< \brief Mode selector tool
|
||||
class SceneToolMode : public SceneTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QWidget *mPanel;
|
||||
QHBoxLayout *mLayout;
|
||||
std::map<QPushButton *, std::string> mButtons; // widget, id
|
||||
int mButtonSize;
|
||||
|
||||
public:
|
||||
|
||||
SceneToolMode (SceneToolbar *parent);
|
||||
|
||||
virtual void showPanel (const QPoint& position);
|
||||
|
||||
void addButton (const std::string& icon, const std::string& id);
|
||||
|
||||
signals:
|
||||
|
||||
void modeChanged (const std::string& id);
|
||||
|
||||
private slots:
|
||||
|
||||
void selected();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue