mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-28 19:21:04 +00:00
Use std::string_view for esmtool labels
This commit is contained in:
parent
7e6011751c
commit
40e899f56d
@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
#include <components/misc/strings/format.hpp>
|
#include <components/misc/strings/format.hpp>
|
||||||
|
|
||||||
std::string bodyPartLabel(int idx)
|
std::string_view bodyPartLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 26)
|
if (idx >= 0 && idx <= 26)
|
||||||
{
|
{
|
||||||
static const char *bodyPartLabels[] = {
|
static constexpr std::string_view bodyPartLabels[] = {
|
||||||
"Head",
|
"Head",
|
||||||
"Hair",
|
"Hair",
|
||||||
"Neck",
|
"Neck",
|
||||||
@ -54,11 +54,11 @@ std::string bodyPartLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshPartLabel(int idx)
|
std::string_view meshPartLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= ESM::BodyPart::MP_Tail)
|
if (idx >= 0 && idx <= ESM::BodyPart::MP_Tail)
|
||||||
{
|
{
|
||||||
static const char *meshPartLabels[] = {
|
static constexpr std::string_view meshPartLabels[] = {
|
||||||
"Head",
|
"Head",
|
||||||
"Hair",
|
"Hair",
|
||||||
"Neck",
|
"Neck",
|
||||||
@ -81,11 +81,11 @@ std::string meshPartLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string meshTypeLabel(int idx)
|
std::string_view meshTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= ESM::BodyPart::MT_Armor)
|
if (idx >= 0 && idx <= ESM::BodyPart::MT_Armor)
|
||||||
{
|
{
|
||||||
static const char *meshTypeLabels[] = {
|
static constexpr std::string_view meshTypeLabels[] = {
|
||||||
"Skin",
|
"Skin",
|
||||||
"Clothing",
|
"Clothing",
|
||||||
"Armor"
|
"Armor"
|
||||||
@ -96,11 +96,11 @@ std::string meshTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string clothingTypeLabel(int idx)
|
std::string_view clothingTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 9)
|
if (idx >= 0 && idx <= 9)
|
||||||
{
|
{
|
||||||
static const char *clothingTypeLabels[] = {
|
static constexpr std::string_view clothingTypeLabels[] = {
|
||||||
"Pants",
|
"Pants",
|
||||||
"Shoes",
|
"Shoes",
|
||||||
"Shirt",
|
"Shirt",
|
||||||
@ -118,11 +118,11 @@ std::string clothingTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string armorTypeLabel(int idx)
|
std::string_view armorTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 10)
|
if (idx >= 0 && idx <= 10)
|
||||||
{
|
{
|
||||||
static const char *armorTypeLabels[] = {
|
static constexpr std::string_view armorTypeLabels[] = {
|
||||||
"Helmet",
|
"Helmet",
|
||||||
"Cuirass",
|
"Cuirass",
|
||||||
"Left Pauldron",
|
"Left Pauldron",
|
||||||
@ -141,11 +141,11 @@ std::string armorTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dialogTypeLabel(int idx)
|
std::string_view dialogTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 4)
|
if (idx >= 0 && idx <= 4)
|
||||||
{
|
{
|
||||||
static const char *dialogTypeLabels[] = {
|
static constexpr std::string_view dialogTypeLabels[] = {
|
||||||
"Topic",
|
"Topic",
|
||||||
"Voice",
|
"Voice",
|
||||||
"Greeting",
|
"Greeting",
|
||||||
@ -160,11 +160,11 @@ std::string dialogTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string questStatusLabel(int idx)
|
std::string_view questStatusLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 4)
|
if (idx >= 0 && idx <= 4)
|
||||||
{
|
{
|
||||||
static const char *questStatusLabels[] = {
|
static constexpr std::string_view questStatusLabels[] = {
|
||||||
"None",
|
"None",
|
||||||
"Name",
|
"Name",
|
||||||
"Finished",
|
"Finished",
|
||||||
@ -177,11 +177,11 @@ std::string questStatusLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string creatureTypeLabel(int idx)
|
std::string_view creatureTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 3)
|
if (idx >= 0 && idx <= 3)
|
||||||
{
|
{
|
||||||
static const char *creatureTypeLabels[] = {
|
static constexpr std::string_view creatureTypeLabels[] = {
|
||||||
"Creature",
|
"Creature",
|
||||||
"Daedra",
|
"Daedra",
|
||||||
"Undead",
|
"Undead",
|
||||||
@ -193,11 +193,11 @@ std::string creatureTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string soundTypeLabel(int idx)
|
std::string_view soundTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 7)
|
if (idx >= 0 && idx <= 7)
|
||||||
{
|
{
|
||||||
static const char *soundTypeLabels[] = {
|
static constexpr std::string_view soundTypeLabels[] = {
|
||||||
"Left Foot",
|
"Left Foot",
|
||||||
"Right Foot",
|
"Right Foot",
|
||||||
"Swim Left",
|
"Swim Left",
|
||||||
@ -213,11 +213,11 @@ std::string soundTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string weaponTypeLabel(int idx)
|
std::string_view weaponTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 13)
|
if (idx >= 0 && idx <= 13)
|
||||||
{
|
{
|
||||||
static const char *weaponTypeLabels[] = {
|
static constexpr std::string_view weaponTypeLabels[] = {
|
||||||
"Short Blade One Hand",
|
"Short Blade One Hand",
|
||||||
"Long Blade One Hand",
|
"Long Blade One Hand",
|
||||||
"Long Blade Two Hand",
|
"Long Blade Two Hand",
|
||||||
@ -239,7 +239,7 @@ std::string weaponTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string aiTypeLabel(int type)
|
std::string_view aiTypeLabel(int type)
|
||||||
{
|
{
|
||||||
if (type == ESM::AI_Wander) return "Wander";
|
if (type == ESM::AI_Wander) return "Wander";
|
||||||
else if (type == ESM::AI_Travel) return "Travel";
|
else if (type == ESM::AI_Travel) return "Travel";
|
||||||
@ -249,11 +249,11 @@ std::string aiTypeLabel(int type)
|
|||||||
else return "Invalid";
|
else return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string magicEffectLabel(int idx)
|
std::string_view magicEffectLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 142)
|
if (idx >= 0 && idx <= 142)
|
||||||
{
|
{
|
||||||
const char* magicEffectLabels [] = {
|
static constexpr std::string_view magicEffectLabels [] = {
|
||||||
"Water Breathing",
|
"Water Breathing",
|
||||||
"Swift Swim",
|
"Swift Swim",
|
||||||
"Water Walking",
|
"Water Walking",
|
||||||
@ -404,11 +404,11 @@ std::string magicEffectLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string attributeLabel(int idx)
|
std::string_view attributeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 7)
|
if (idx >= 0 && idx <= 7)
|
||||||
{
|
{
|
||||||
const char* attributeLabels [] = {
|
static constexpr std::string_view attributeLabels [] = {
|
||||||
"Strength",
|
"Strength",
|
||||||
"Intelligence",
|
"Intelligence",
|
||||||
"Willpower",
|
"Willpower",
|
||||||
@ -424,11 +424,11 @@ std::string attributeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string spellTypeLabel(int idx)
|
std::string_view spellTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 5)
|
if (idx >= 0 && idx <= 5)
|
||||||
{
|
{
|
||||||
const char* spellTypeLabels [] = {
|
static constexpr std::string_view spellTypeLabels [] = {
|
||||||
"Spells",
|
"Spells",
|
||||||
"Abilities",
|
"Abilities",
|
||||||
"Blight Disease",
|
"Blight Disease",
|
||||||
@ -442,11 +442,11 @@ std::string spellTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string specializationLabel(int idx)
|
std::string_view specializationLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 2)
|
if (idx >= 0 && idx <= 2)
|
||||||
{
|
{
|
||||||
const char* specializationLabels [] = {
|
static constexpr std::string_view specializationLabels [] = {
|
||||||
"Combat",
|
"Combat",
|
||||||
"Magic",
|
"Magic",
|
||||||
"Stealth"
|
"Stealth"
|
||||||
@ -457,11 +457,11 @@ std::string specializationLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string skillLabel(int idx)
|
std::string_view skillLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 26)
|
if (idx >= 0 && idx <= 26)
|
||||||
{
|
{
|
||||||
const char* skillLabels [] = {
|
static constexpr std::string_view skillLabels [] = {
|
||||||
"Block",
|
"Block",
|
||||||
"Armorer",
|
"Armorer",
|
||||||
"Medium Armor",
|
"Medium Armor",
|
||||||
@ -496,11 +496,11 @@ std::string skillLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string apparatusTypeLabel(int idx)
|
std::string_view apparatusTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 3)
|
if (idx >= 0 && idx <= 3)
|
||||||
{
|
{
|
||||||
const char* apparatusTypeLabels [] = {
|
static constexpr std::string_view apparatusTypeLabels [] = {
|
||||||
"Mortar",
|
"Mortar",
|
||||||
"Alembic",
|
"Alembic",
|
||||||
"Calcinator",
|
"Calcinator",
|
||||||
@ -512,11 +512,11 @@ std::string apparatusTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rangeTypeLabel(int idx)
|
std::string_view rangeTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 2)
|
if (idx >= 0 && idx <= 2)
|
||||||
{
|
{
|
||||||
const char* rangeTypeLabels [] = {
|
static constexpr std::string_view rangeTypeLabels [] = {
|
||||||
"Self",
|
"Self",
|
||||||
"Touch",
|
"Touch",
|
||||||
"Target"
|
"Target"
|
||||||
@ -527,11 +527,11 @@ std::string rangeTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string schoolLabel(int idx)
|
std::string_view schoolLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 5)
|
if (idx >= 0 && idx <= 5)
|
||||||
{
|
{
|
||||||
const char* schoolLabels [] = {
|
static constexpr std::string_view schoolLabels [] = {
|
||||||
"Alteration",
|
"Alteration",
|
||||||
"Conjuration",
|
"Conjuration",
|
||||||
"Destruction",
|
"Destruction",
|
||||||
@ -545,11 +545,11 @@ std::string schoolLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string enchantTypeLabel(int idx)
|
std::string_view enchantTypeLabel(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 3)
|
if (idx >= 0 && idx <= 3)
|
||||||
{
|
{
|
||||||
const char* enchantTypeLabels [] = {
|
static constexpr std::string_view enchantTypeLabels [] = {
|
||||||
"Cast Once",
|
"Cast Once",
|
||||||
"Cast When Strikes",
|
"Cast When Strikes",
|
||||||
"Cast When Used",
|
"Cast When Used",
|
||||||
@ -561,11 +561,11 @@ std::string enchantTypeLabel(int idx)
|
|||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ruleFunction(int idx)
|
std::string_view ruleFunction(int idx)
|
||||||
{
|
{
|
||||||
if (idx >= 0 && idx <= 72)
|
if (idx >= 0 && idx <= 72)
|
||||||
{
|
{
|
||||||
std::string ruleFunctions[] = {
|
static constexpr std::string_view ruleFunctions[] = {
|
||||||
"Reaction Low",
|
"Reaction Low",
|
||||||
"Reaction High",
|
"Reaction High",
|
||||||
"Rank Requirement",
|
"Rank Requirement",
|
||||||
|
@ -3,25 +3,25 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string bodyPartLabel(int idx);
|
std::string_view bodyPartLabel(int idx);
|
||||||
std::string meshPartLabel(int idx);
|
std::string_view meshPartLabel(int idx);
|
||||||
std::string meshTypeLabel(int idx);
|
std::string_view meshTypeLabel(int idx);
|
||||||
std::string clothingTypeLabel(int idx);
|
std::string_view clothingTypeLabel(int idx);
|
||||||
std::string armorTypeLabel(int idx);
|
std::string_view armorTypeLabel(int idx);
|
||||||
std::string dialogTypeLabel(int idx);
|
std::string_view dialogTypeLabel(int idx);
|
||||||
std::string questStatusLabel(int idx);
|
std::string_view questStatusLabel(int idx);
|
||||||
std::string creatureTypeLabel(int idx);
|
std::string_view creatureTypeLabel(int idx);
|
||||||
std::string soundTypeLabel(int idx);
|
std::string_view soundTypeLabel(int idx);
|
||||||
std::string weaponTypeLabel(int idx);
|
std::string_view weaponTypeLabel(int idx);
|
||||||
|
|
||||||
// This function's a bit different because the types are record types,
|
// This function's a bit different because the types are record types,
|
||||||
// not consecutive values.
|
// not consecutive values.
|
||||||
std::string aiTypeLabel(int type);
|
std::string_view aiTypeLabel(int type);
|
||||||
|
|
||||||
// This one's also a bit different, because it enumerates dialog
|
// This one's also a bit different, because it enumerates dialog
|
||||||
// select rule functions, not types. Structurally, it still converts
|
// select rule functions, not types. Structurally, it still converts
|
||||||
// indexes to strings for display.
|
// indexes to strings for display.
|
||||||
std::string ruleFunction(int idx);
|
std::string_view ruleFunction(int idx);
|
||||||
|
|
||||||
// The labels below here can all be loaded from GMSTs, but are not
|
// The labels below here can all be loaded from GMSTs, but are not
|
||||||
// currently because among other things, that requires loading the
|
// currently because among other things, that requires loading the
|
||||||
@ -32,15 +32,15 @@ std::string ruleFunction(int idx);
|
|||||||
// and the indexes for referencing the types in other records in the
|
// and the indexes for referencing the types in other records in the
|
||||||
// database. Then a single label function could work for all types.
|
// database. Then a single label function could work for all types.
|
||||||
|
|
||||||
std::string magicEffectLabel(int idx);
|
std::string_view magicEffectLabel(int idx);
|
||||||
std::string attributeLabel(int idx);
|
std::string_view attributeLabel(int idx);
|
||||||
std::string spellTypeLabel(int idx);
|
std::string_view spellTypeLabel(int idx);
|
||||||
std::string specializationLabel(int idx);
|
std::string_view specializationLabel(int idx);
|
||||||
std::string skillLabel(int idx);
|
std::string_view skillLabel(int idx);
|
||||||
std::string apparatusTypeLabel(int idx);
|
std::string_view apparatusTypeLabel(int idx);
|
||||||
std::string rangeTypeLabel(int idx);
|
std::string_view rangeTypeLabel(int idx);
|
||||||
std::string schoolLabel(int idx);
|
std::string_view schoolLabel(int idx);
|
||||||
std::string enchantTypeLabel(int idx);
|
std::string_view enchantTypeLabel(int idx);
|
||||||
|
|
||||||
// The are the flag functions that convert a bitmask into a list of
|
// The are the flag functions that convert a bitmask into a list of
|
||||||
// human readble strings representing the set bits.
|
// human readble strings representing the set bits.
|
||||||
|
@ -73,7 +73,7 @@ std::string ruleString(const ESM::DialInfo::SelectStruct& ss)
|
|||||||
{
|
{
|
||||||
case '1':
|
case '1':
|
||||||
type_str = "Function";
|
type_str = "Function";
|
||||||
func_str = ruleFunction(func);
|
func_str = std::string(ruleFunction(func));
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (indicator == 's') type_str = "Global short";
|
if (indicator == 's') type_str = "Global short";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user