mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
added value column to gmst table
This commit is contained in:
parent
cce2d63433
commit
828695f295
@ -28,7 +28,8 @@ namespace CSMWorld
|
||||
{
|
||||
Display_String,
|
||||
Display_Integer,
|
||||
Display_Float
|
||||
Display_Float,
|
||||
Display_Var
|
||||
};
|
||||
|
||||
std::string mTitle;
|
||||
|
@ -95,7 +95,7 @@ namespace CSMWorld
|
||||
template<typename ESXRecordT>
|
||||
struct VarTypeColumn : public Column<ESXRecordT>
|
||||
{
|
||||
VarTypeColumn() : Column<ESXRecordT> ("Type", ColumnBase::Display_Float) {}
|
||||
VarTypeColumn() : Column<ESXRecordT> ("Type", ColumnBase::Display_Integer) {}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
@ -114,6 +114,45 @@ namespace CSMWorld
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct VarValueColumn : public Column<ESXRecordT>
|
||||
{
|
||||
VarValueColumn() : Column<ESXRecordT> ("Value", ColumnBase::Display_Var) {}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
switch (record.get().mType)
|
||||
{
|
||||
case ESM::VT_String: return record.get().mStr.c_str(); break;
|
||||
case ESM::VT_Int: return record.get().mI; break;
|
||||
case ESM::VT_Float: return record.get().mF; break;
|
||||
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||
{
|
||||
ESXRecordT base = record.getBase();
|
||||
|
||||
switch (record.get().mType)
|
||||
{
|
||||
case ESM::VT_String: base.mStr = data.toString().toUtf8().constData(); break;
|
||||
case ESM::VT_Int: base.mI = data.toInt(); break;
|
||||
case ESM::VT_Float: base.mF = data.toFloat(); break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
record.setModified (base);
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -32,7 +32,7 @@ CSMWorld::Data::Data()
|
||||
mGmsts.addColumn (new RecordStateColumn<ESM::GameSetting>);
|
||||
mGmsts.addColumn (new FixedRecordTypeColumn<ESM::GameSetting> (UniversalId::Type_Gmst));
|
||||
mGmsts.addColumn (new VarTypeColumn<ESM::GameSetting>);
|
||||
///< \todo add value
|
||||
mGmsts.addColumn (new VarValueColumn<ESM::GameSetting>);
|
||||
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||
|
@ -64,6 +64,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||
/// \todo configure widget properly (range, format?)
|
||||
layout->addWidget (widget = new QDoubleSpinBox, i, 1);
|
||||
break;
|
||||
|
||||
default: break; // silence warnings for other times for now
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -76,6 +78,8 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM
|
||||
|
||||
layout->addWidget (widget = new QLabel, i, 1);
|
||||
break;
|
||||
|
||||
default: break; // silence warnings for other times for now
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user