Merge branch 'master' of git://github.com/OpenMW/openmw into appveyor
commit
b3e985fca2
@ -0,0 +1,93 @@
|
||||
|
||||
#include "instanceselectionmode.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
|
||||
#include "worldspacewidget.hpp"
|
||||
#include "object.hpp"
|
||||
|
||||
bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu)
|
||||
{
|
||||
if (menu)
|
||||
{
|
||||
menu->addAction (mSelectAll);
|
||||
menu->addAction (mDeselectAll);
|
||||
menu->addAction (mSelectSame);
|
||||
menu->addAction (mDeleteSelection);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent,
|
||||
WorldspaceWidget& worldspaceWidget)
|
||||
: CSVWidget::SceneToolMode (parent, "Selection Mode"), mWorldspaceWidget (worldspaceWidget)
|
||||
{
|
||||
addButton (":placeholder", "cube-centre",
|
||||
"Centred cube"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection cube outwards</li>"
|
||||
"<li>The selection cube is aligned to the word space axis</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
addButton (":placeholder", "cube-corner",
|
||||
"Cube corner to corner"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from one corner of the selection cube to the opposite corner</li>"
|
||||
"<li>The selection cube is aligned to the word space axis</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
addButton (":placeholder", "sphere",
|
||||
"Centred sphere"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection sphere outwards</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
|
||||
mSelectAll = new QAction ("Select all instances", this);
|
||||
mDeselectAll = new QAction ("Clear selection", this);
|
||||
mDeleteSelection = new QAction ("Delete selected instances", this);
|
||||
mSelectSame = new QAction ("Extend selection to instances with same object ID", this);
|
||||
connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll()));
|
||||
connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection()));
|
||||
connect (mDeleteSelection, SIGNAL (triggered ()), this, SLOT (deleteSelection()));
|
||||
connect (mSelectSame, SIGNAL (triggered ()), this, SLOT (selectSame()));
|
||||
}
|
||||
|
||||
void CSVRender::InstanceSelectionMode::selectAll()
|
||||
{
|
||||
mWorldspaceWidget.selectAll (Mask_Reference);
|
||||
}
|
||||
|
||||
void CSVRender::InstanceSelectionMode::clearSelection()
|
||||
{
|
||||
mWorldspaceWidget.clearSelection (Mask_Reference);
|
||||
}
|
||||
|
||||
void CSVRender::InstanceSelectionMode::deleteSelection()
|
||||
{
|
||||
std::vector<osg::ref_ptr<TagBase> > selection =
|
||||
mWorldspaceWidget.getSelection (Mask_Reference);
|
||||
|
||||
CSMWorld::IdTable& referencesTable =
|
||||
dynamic_cast<CSMWorld::IdTable&> (*mWorldspaceWidget.getDocument().getData().
|
||||
getTableModel (CSMWorld::UniversalId::Type_References));
|
||||
|
||||
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin());
|
||||
iter!=selection.end(); ++iter)
|
||||
{
|
||||
CSMWorld::DeleteCommand *command = new CSMWorld::DeleteCommand (referencesTable,
|
||||
static_cast<ObjectTag *> (iter->get())->mObject->getReferenceId());
|
||||
|
||||
mWorldspaceWidget.getDocument().getUndoStack().push (command);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVRender::InstanceSelectionMode::selectSame()
|
||||
{
|
||||
mWorldspaceWidget.selectAllWithSameParentId (Mask_Reference);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
#ifndef CSV_RENDER_INSTANCE_SELECTION_MODE_H
|
||||
#define CSV_RENDER_INSTANCE_SELECTION_MODE_H
|
||||
|
||||
#include "../widget/scenetoolmode.hpp"
|
||||
|
||||
class QAction;
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class WorldspaceWidget;
|
||||
|
||||
class InstanceSelectionMode : public CSVWidget::SceneToolMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
WorldspaceWidget& mWorldspaceWidget;
|
||||
QAction *mSelectAll;
|
||||
QAction *mDeselectAll;
|
||||
QAction *mDeleteSelection;
|
||||
QAction *mSelectSame;
|
||||
|
||||
/// Add context menu items to \a menu.
|
||||
///
|
||||
/// \attention menu can be a 0-pointer
|
||||
///
|
||||
/// \return Have there been any menu items to be added (if menu is 0 and there
|
||||
/// items to be added, the function must return true anyway.
|
||||
virtual bool createContextMenu (QMenu *menu);
|
||||
|
||||
public:
|
||||
|
||||
InstanceSelectionMode (CSVWidget::SceneToolbar *parent, WorldspaceWidget& worldspaceWidget);
|
||||
|
||||
private slots:
|
||||
|
||||
void selectAll();
|
||||
|
||||
void clearSelection();
|
||||
|
||||
void deleteSelection();
|
||||
|
||||
void selectSame();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,20 +1,118 @@
|
||||
#include "startscriptcreator.hpp"
|
||||
|
||||
CSVWorld::StartScriptCreator::StartScriptCreator(CSMWorld::Data &data, QUndoStack &undoStack, const CSMWorld::UniversalId &id, bool relaxedIdRules):
|
||||
GenericCreator (data, undoStack, id, true)
|
||||
{}
|
||||
#include <QLabel>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/data.hpp"
|
||||
#include "../../model/world/idcompletionmanager.hpp"
|
||||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
#include "../widget/droplineedit.hpp"
|
||||
|
||||
std::string CSVWorld::StartScriptCreator::getId() const
|
||||
{
|
||||
return mScript->text().toUtf8().constData();
|
||||
}
|
||||
|
||||
CSMWorld::IdTable& CSVWorld::StartScriptCreator::getStartScriptsTable() const
|
||||
{
|
||||
return dynamic_cast<CSMWorld::IdTable&> (
|
||||
*getData().getTableModel(getCollectionId())
|
||||
);
|
||||
}
|
||||
|
||||
void CSVWorld::StartScriptCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const
|
||||
{
|
||||
CSMWorld::IdTable& table = getStartScriptsTable();
|
||||
int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
||||
|
||||
// Set script ID to be added to start scripts table.
|
||||
command.addValue(column, mScript->text());
|
||||
}
|
||||
|
||||
CSVWorld::StartScriptCreator::StartScriptCreator(
|
||||
CSMWorld::Data &data,
|
||||
QUndoStack &undoStack,
|
||||
const CSMWorld::UniversalId &id,
|
||||
CSMWorld::IdCompletionManager& completionManager
|
||||
) : GenericCreator(data, undoStack, id, true)
|
||||
{
|
||||
setManualEditing(false);
|
||||
|
||||
// Add script ID input label.
|
||||
QLabel *label = new QLabel("Script ID", this);
|
||||
insertBeforeButtons(label, false);
|
||||
|
||||
// Add script ID input with auto-completion.
|
||||
CSMWorld::ColumnBase::Display displayType = CSMWorld::ColumnBase::Display_Script;
|
||||
mScript = new CSVWidget::DropLineEdit(displayType, this);
|
||||
mScript->setCompleter(completionManager.getCompleter(displayType).get());
|
||||
insertBeforeButtons(mScript, true);
|
||||
|
||||
connect(mScript, SIGNAL (textChanged(const QString&)), this, SLOT (scriptChanged()));
|
||||
}
|
||||
|
||||
void CSVWorld::StartScriptCreator::cloneMode(
|
||||
const std::string& originId,
|
||||
const CSMWorld::UniversalId::Type type)
|
||||
{
|
||||
CSVWorld::GenericCreator::cloneMode(originId, type);
|
||||
|
||||
// Look up cloned record in start scripts table and set script ID text.
|
||||
CSMWorld::IdTable& table = getStartScriptsTable();
|
||||
int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
||||
mScript->setText(table.data(table.getModelIndex(originId, column)).toString());
|
||||
}
|
||||
|
||||
std::string CSVWorld::StartScriptCreator::getErrors() const
|
||||
{
|
||||
std::string errors;
|
||||
std::string scriptId = getId();
|
||||
|
||||
errors = getIdValidatorResult();
|
||||
if (errors.length() > 0)
|
||||
return errors;
|
||||
else if (getData().getScripts().searchId(getId()) == -1)
|
||||
// Check user input for any errors.
|
||||
std::string errors;
|
||||
if (scriptId.empty())
|
||||
{
|
||||
errors = "No Script ID entered";
|
||||
}
|
||||
else if (getData().getScripts().searchId(scriptId) == -1)
|
||||
{
|
||||
errors = "Script ID not found";
|
||||
else if (getData().getStartScripts().searchId(getId()) > -1 )
|
||||
}
|
||||
else if (getData().getStartScripts().searchId(scriptId) > -1)
|
||||
{
|
||||
errors = "Script with this ID already registered as Start Script";
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
void CSVWorld::StartScriptCreator::focus()
|
||||
{
|
||||
mScript->setFocus();
|
||||
}
|
||||
|
||||
void CSVWorld::StartScriptCreator::reset()
|
||||
{
|
||||
CSVWorld::GenericCreator::reset();
|
||||
mScript->setText("");
|
||||
}
|
||||
|
||||
void CSVWorld::StartScriptCreator::scriptChanged()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
CSVWorld::Creator *CSVWorld::StartScriptCreatorFactory::makeCreator(
|
||||
CSMDoc::Document& document,
|
||||
const CSMWorld::UniversalId& id) const
|
||||
{
|
||||
return new StartScriptCreator(
|
||||
document.getData(),
|
||||
document.getUndoStack(),
|
||||
id,
|
||||
document.getIdCompletionManager()
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue