forked from mirror/openmw-tes3mp
moved list of enum literals from ViewManager to Columns (which makes them available to the rest of model now)
This commit is contained in:
parent
9f0b34eae0
commit
649ef6f120
5 changed files with 129 additions and 72 deletions
|
@ -196,4 +196,85 @@ int CSMWorld::Columns::getId (const std::string& name)
|
|||
return sNames[i].mId;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static const char *sSpecialisations[] =
|
||||
{
|
||||
"Combat", "Magic", "Stealth", 0
|
||||
};
|
||||
|
||||
static const char *sAttributes[] =
|
||||
{
|
||||
"Strength", "Intelligence", "Willpower", "Agility", "Speed", "Endurance", "Personality",
|
||||
"Luck", 0
|
||||
};
|
||||
|
||||
static const char *sSpellTypes[] =
|
||||
{
|
||||
"Spell", "Ability", "Blight", "Disease", "Curse", "Power", 0
|
||||
};
|
||||
|
||||
static const char *sApparatusTypes[] =
|
||||
{
|
||||
"Mortar & Pestle", "Albemic", "Calcinator", "Retort", 0
|
||||
};
|
||||
|
||||
static const char *sArmorTypes[] =
|
||||
{
|
||||
"Helmet", "Cuirass", "Left Pauldron", "Right Pauldron", "Greaves", "Boots", "Left Gauntlet",
|
||||
"Right Gauntlet", "Shield", "Left Bracer", "Right Bracer", 0
|
||||
};
|
||||
|
||||
static const char *sClothingTypes[] =
|
||||
{
|
||||
"Pants", "Shoes", "Shirt", "Belt", "Robe", "Right Glove", "Left Glove", "Skirt", "Ring",
|
||||
"Amulet", 0
|
||||
};
|
||||
|
||||
static const char *sCreatureTypes[] =
|
||||
{
|
||||
"Creature", "Deadra", "Undead", "Humanoid", 0
|
||||
};
|
||||
|
||||
static const char *sWeaponTypes[] =
|
||||
{
|
||||
"Short Blade 1H", "Long Blade 1H", "Long Blade 2H", "Blunt 1H", "Blunt 2H Close",
|
||||
"Blunt 2H Wide", "Spear 2H", "Axe 1H", "Axe 2H", "Bow", "Crossbow", "Thrown", "Arrow",
|
||||
"Bolt", 0
|
||||
};
|
||||
|
||||
const char **getEnumNames (CSMWorld::Columns::ColumnId column)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case CSMWorld::Columns::ColumnId_Specialisation: return sSpecialisations;
|
||||
case CSMWorld::Columns::ColumnId_Attribute: return sAttributes;
|
||||
case CSMWorld::Columns::ColumnId_SpellType: return sSpellTypes;
|
||||
case CSMWorld::Columns::ColumnId_ApparatusType: return sApparatusTypes;
|
||||
case CSMWorld::Columns::ColumnId_ArmorType: return sArmorTypes;
|
||||
case CSMWorld::Columns::ColumnId_ClothingType: return sClothingTypes;
|
||||
case CSMWorld::Columns::ColumnId_CreatureType: return sCreatureTypes;
|
||||
case CSMWorld::Columns::ColumnId_WeaponType: return sWeaponTypes;
|
||||
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CSMWorld::Columns::hasEnums (ColumnId column)
|
||||
{
|
||||
return getEnumNames (column)!=0;
|
||||
}
|
||||
|
||||
std::vector<std::string> CSMWorld::Columns::getEnums (ColumnId column)
|
||||
{
|
||||
std::vector<std::string> enums;
|
||||
|
||||
if (const char **table = getEnumNames (column))
|
||||
for (int i=0; table[i]; ++i)
|
||||
enums.push_back (table[i]);
|
||||
|
||||
return enums;
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
#define CSM_WOLRD_COLUMNS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
|
@ -180,6 +181,11 @@ namespace CSMWorld
|
|||
|
||||
int getId (const std::string& name);
|
||||
///< Will return -1 for an invalid name.
|
||||
|
||||
bool hasEnums (ColumnId column);
|
||||
|
||||
std::vector<std::string> getEnums (ColumnId column);
|
||||
///< Returns an empty vector, if \æ column isn't an enum type column.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
|
||||
#include "../world/util.hpp"
|
||||
#include "../world/enumdelegate.hpp"
|
||||
|
@ -43,51 +44,6 @@ void CSVDoc::ViewManager::updateIndices()
|
|||
CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
||||
: mDocumentManager (documentManager), mExitOnSaveStateChange(false), mUserWarned(false)
|
||||
{
|
||||
static const char *sSpecialisations[] =
|
||||
{
|
||||
"Combat", "Magic", "Stealth", 0
|
||||
};
|
||||
|
||||
static const char *sAttributes[] =
|
||||
{
|
||||
"Strength", "Intelligence", "Willpower", "Agility", "Speed", "Endurance", "Personality",
|
||||
"Luck", 0
|
||||
};
|
||||
|
||||
static const char *sSpellTypes[] =
|
||||
{
|
||||
"Spell", "Ability", "Blight", "Disease", "Curse", "Power", 0
|
||||
};
|
||||
|
||||
static const char *sApparatusTypes[] =
|
||||
{
|
||||
"Mortar & Pestle", "Albemic", "Calcinator", "Retort", 0
|
||||
};
|
||||
|
||||
static const char *sArmorTypes[] =
|
||||
{
|
||||
"Helmet", "Cuirass", "Left Pauldron", "Right Pauldron", "Greaves", "Boots", "Left Gauntlet",
|
||||
"Right Gauntlet", "Shield", "Left Bracer", "Right Bracer", 0
|
||||
};
|
||||
|
||||
static const char *sClothingTypes[] =
|
||||
{
|
||||
"Pants", "Shoes", "Shirt", "Belt", "Robe", "Right Glove", "Left Glove", "Skirt", "Ring",
|
||||
"Amulet", 0
|
||||
};
|
||||
|
||||
static const char *sCreatureTypes[] =
|
||||
{
|
||||
"Creature", "Deadra", "Undead", "Humanoid", 0
|
||||
};
|
||||
|
||||
static const char *sWeaponTypes[] =
|
||||
{
|
||||
"Short Blade 1H", "Long Blade 1H", "Long Blade 2H", "Blunt 1H", "Blunt 2H Close",
|
||||
"Blunt 2H Wide", "Spear 2H", "Axe 1H", "Axe 2H", "Bow", "Crossbow", "Thrown", "Arrow",
|
||||
"Bolt", 0
|
||||
};
|
||||
|
||||
mDelegateFactories = new CSVWorld::CommandDelegateFactoryCollection;
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GmstVarType,
|
||||
|
@ -96,38 +52,37 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_GlobalVarType,
|
||||
new CSVWorld::VarTypeDelegateFactory (ESM::VT_Short, ESM::VT_Long, ESM::VT_Float));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_Specialisation,
|
||||
new CSVWorld::EnumDelegateFactory (sSpecialisations));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_Attribute,
|
||||
new CSVWorld::EnumDelegateFactory (sAttributes, true));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_SpellType,
|
||||
new CSVWorld::EnumDelegateFactory (sSpellTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_ApparatusType,
|
||||
new CSVWorld::EnumDelegateFactory (sApparatusTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_ArmorType,
|
||||
new CSVWorld::EnumDelegateFactory (sArmorTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_ClothingType,
|
||||
new CSVWorld::EnumDelegateFactory (sClothingTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_CreatureType,
|
||||
new CSVWorld::EnumDelegateFactory (sCreatureTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_WeaponType,
|
||||
new CSVWorld::EnumDelegateFactory (sWeaponTypes));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState,
|
||||
new CSVWorld::RecordStatusDelegateFactory() );
|
||||
new CSVWorld::RecordStatusDelegateFactory());
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType,
|
||||
new CSVWorld::RefIdTypeDelegateFactory() );
|
||||
new CSVWorld::RefIdTypeDelegateFactory());
|
||||
|
||||
struct Mapping
|
||||
{
|
||||
CSMWorld::ColumnBase::Display mDisplay;
|
||||
CSMWorld::Columns::ColumnId mColumnId;
|
||||
bool mAllowNone;
|
||||
};
|
||||
|
||||
static const Mapping sMapping[] =
|
||||
{
|
||||
{ CSMWorld::ColumnBase::Display_Specialisation, CSMWorld::Columns::ColumnId_Specialisation, false },
|
||||
{ CSMWorld::ColumnBase::Display_Attribute, CSMWorld::Columns::ColumnId_Attribute, true },
|
||||
{ CSMWorld::ColumnBase::Display_SpellType, CSMWorld::Columns::ColumnId_SpellType, false },
|
||||
{ CSMWorld::ColumnBase::Display_ApparatusType, CSMWorld::Columns::ColumnId_ApparatusType, false },
|
||||
{ CSMWorld::ColumnBase::Display_ArmorType, CSMWorld::Columns::ColumnId_ArmorType, false },
|
||||
{ CSMWorld::ColumnBase::Display_ClothingType, CSMWorld::Columns::ColumnId_ClothingType, false },
|
||||
{ CSMWorld::ColumnBase::Display_CreatureType, CSMWorld::Columns::ColumnId_CreatureType, false },
|
||||
{ CSMWorld::ColumnBase::Display_WeaponType, CSMWorld::Columns::ColumnId_WeaponType, false }
|
||||
};
|
||||
|
||||
for (std::size_t i=0; i<sizeof (sMapping)/sizeof (Mapping); ++i)
|
||||
mDelegateFactories->add (sMapping[i].mDisplay, new CSVWorld::EnumDelegateFactory (
|
||||
CSMWorld::Columns::getEnums (sMapping[i].mColumnId), sMapping[i].mAllowNone));
|
||||
|
||||
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||
}
|
||||
|
||||
CSVDoc::ViewManager::~ViewManager()
|
||||
|
|
|
@ -109,6 +109,18 @@ CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names, bool all
|
|||
add (i, names[i]);
|
||||
}
|
||||
|
||||
CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const std::vector<std::string>& names,
|
||||
bool allowNone)
|
||||
{
|
||||
if (allowNone)
|
||||
add (-1, "");
|
||||
|
||||
int size = static_cast<int> (names.size());
|
||||
|
||||
for (int i=0; i<size; ++i)
|
||||
add (i, names[i].c_str());
|
||||
}
|
||||
|
||||
CSVWorld::CommandDelegate *CSVWorld::EnumDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||
QObject *parent) const
|
||||
{
|
||||
|
|
|
@ -54,6 +54,9 @@ namespace CSVWorld
|
|||
///< \param names Array of char pointer with a 0-pointer as end mark
|
||||
/// \param allowNone Use value of -1 for "none selected" (empty string)
|
||||
|
||||
EnumDelegateFactory (const std::vector<std::string>& names, bool allowNone = false);
|
||||
/// \param allowNone Use value of -1 for "none selected" (empty string)
|
||||
|
||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||
|
||||
|
|
Loading…
Reference in a new issue