mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 18:06:41 +00:00
Return string_view from SoundId methods
This commit is contained in:
parent
4e9335f10a
commit
eaa108d25d
45 changed files with 137 additions and 131 deletions
|
@ -335,7 +335,7 @@ namespace MWBase
|
|||
/// Cycle to next or previous weapon
|
||||
virtual void cycleWeapon(bool next) = 0;
|
||||
|
||||
virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
virtual void playSound(std::string_view soundId, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
|
||||
virtual void addCell(MWWorld::CellStore* cell) = 0;
|
||||
virtual void removeCell(MWWorld::CellStore* cell) = 0;
|
||||
|
|
|
@ -132,11 +132,11 @@ namespace MWClass
|
|||
return MWWorld::Ptr(cell.insert(ref), &cell);
|
||||
}
|
||||
|
||||
std::string Activator::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view Activator::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
|
||||
{
|
||||
const std::string model = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
|
||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||
std::string creatureId;
|
||||
std::string_view creatureId;
|
||||
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||
|
||||
for (const ESM::Creature &iter : store.get<ESM::Creature>())
|
||||
|
@ -180,10 +180,10 @@ namespace MWClass
|
|||
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
int Activator::getSndGenTypeFromName(const std::string &name)
|
||||
int Activator::getSndGenTypeFromName(std::string_view name)
|
||||
{
|
||||
if (name == "left")
|
||||
return ESM::SoundGenerator::LeftFoot;
|
||||
|
@ -202,6 +202,6 @@ namespace MWClass
|
|||
if (name == "land")
|
||||
return ESM::SoundGenerator::Land;
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace MWClass
|
|||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||
|
||||
static int getSndGenTypeFromName(const std::string &name);
|
||||
static int getSndGenTypeFromName(std::string_view name);
|
||||
|
||||
public:
|
||||
void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const override;
|
||||
|
@ -45,7 +45,7 @@ namespace MWClass
|
|||
|
||||
bool isActivator() const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -67,14 +67,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Apparatus::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Apparatus::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Apparatus Up");
|
||||
return "Item Apparatus Up";
|
||||
}
|
||||
|
||||
std::string Apparatus::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Apparatus::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Apparatus Down");
|
||||
return "Item Apparatus Down";
|
||||
}
|
||||
|
||||
std::string Apparatus::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -36,10 +36,10 @@ namespace MWClass
|
|||
MWGui::ToolTipInfo getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const override;
|
||||
///< @return the content of the tool tip to be displayed. raises exception if the object has no tooltip.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -161,26 +161,26 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Armor::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Armor::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
int es = getEquipmentSkill(ptr);
|
||||
if (es == ESM::Skill::LightArmor)
|
||||
return std::string("Item Armor Light Up");
|
||||
return "Item Armor Light Up";
|
||||
else if (es == ESM::Skill::MediumArmor)
|
||||
return std::string("Item Armor Medium Up");
|
||||
return "Item Armor Medium Up";
|
||||
else
|
||||
return std::string("Item Armor Heavy Up");
|
||||
return "Item Armor Heavy Up";
|
||||
}
|
||||
|
||||
std::string Armor::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Armor::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
int es = getEquipmentSkill(ptr);
|
||||
if (es == ESM::Skill::LightArmor)
|
||||
return std::string("Item Armor Light Down");
|
||||
return "Item Armor Light Down";
|
||||
else if (es == ESM::Skill::MediumArmor)
|
||||
return std::string("Item Armor Medium Down");
|
||||
return "Item Armor Medium Down";
|
||||
else
|
||||
return std::string("Item Armor Heavy Down");
|
||||
return "Item Armor Heavy Down";
|
||||
}
|
||||
|
||||
std::string Armor::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -50,10 +50,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -84,14 +84,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Book::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Book::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Book Up");
|
||||
return "Item Book Up";
|
||||
}
|
||||
|
||||
std::string Book::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Book::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Book Down");
|
||||
return "Item Book Down";
|
||||
}
|
||||
|
||||
std::string Book::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -119,26 +119,26 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Clothing::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Clothing::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||
|
||||
if (ref->mBase->mData.mType == 8)
|
||||
{
|
||||
return std::string("Item Ring Up");
|
||||
return "Item Ring Up";
|
||||
}
|
||||
return std::string("Item Clothes Up");
|
||||
return "Item Clothes Up";
|
||||
}
|
||||
|
||||
std::string Clothing::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Clothing::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>();
|
||||
|
||||
if (ref->mBase->mData.mType == 8)
|
||||
{
|
||||
return std::string("Item Ring Down");
|
||||
return "Item Ring Down";
|
||||
}
|
||||
return std::string("Item Clothes Down");
|
||||
return "Item Clothes Down";
|
||||
}
|
||||
|
||||
std::string Clothing::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -42,10 +42,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -593,11 +593,11 @@ namespace MWClass
|
|||
return (ref->mBase->mRecordFlags & ESM::FLAG_Persistent) != 0;
|
||||
}
|
||||
|
||||
std::string Creature::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view Creature::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
|
||||
{
|
||||
int type = getSndGenTypeFromName(ptr, name);
|
||||
if (type < 0)
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
std::vector<const ESM::SoundGenerator*> sounds;
|
||||
std::vector<const ESM::SoundGenerator*> fallbacksounds;
|
||||
|
@ -650,7 +650,7 @@ namespace MWClass
|
|||
if (!fallbacksounds.empty())
|
||||
return fallbacksounds[Misc::Rng::rollDice(fallbacksounds.size(), prng)]->mSound;
|
||||
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
MWWorld::Ptr Creature::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
|
@ -680,7 +680,7 @@ namespace MWClass
|
|||
return isFlagBitSet(ptr, static_cast<ESM::Creature::Flags>(ESM::Creature::Walks | ESM::Creature::Bipedal));
|
||||
}
|
||||
|
||||
int Creature::getSndGenTypeFromName(const MWWorld::Ptr &ptr, const std::string &name)
|
||||
int Creature::getSndGenTypeFromName(const MWWorld::Ptr& ptr, std::string_view name)
|
||||
{
|
||||
if(name == "left")
|
||||
{
|
||||
|
@ -719,7 +719,7 @@ namespace MWClass
|
|||
if(name == "land")
|
||||
return ESM::SoundGenerator::Land;
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
|
||||
float Creature::getSkill(const MWWorld::Ptr &ptr, int skill) const
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace MWClass
|
|||
|
||||
MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const override;
|
||||
|
||||
static int getSndGenTypeFromName(const MWWorld::Ptr &ptr, const std::string &name);
|
||||
static int getSndGenTypeFromName(const MWWorld::Ptr& ptr, std::string_view name);
|
||||
|
||||
// cached GMSTs
|
||||
struct GMST
|
||||
|
@ -97,7 +97,7 @@ namespace MWClass
|
|||
|
||||
bool isPersistent (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
|
||||
MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const override;
|
||||
///< Return desired movement.
|
||||
|
|
|
@ -79,14 +79,14 @@ namespace MWClass
|
|||
return action;
|
||||
}
|
||||
|
||||
std::string Ingredient::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Ingredient::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Ingredient Up");
|
||||
return "Item Ingredient Up";
|
||||
}
|
||||
|
||||
std::string Ingredient::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Ingredient::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Ingredient Down");
|
||||
return "Item Ingredient Down";
|
||||
}
|
||||
|
||||
std::string Ingredient::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace MWClass
|
|||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -122,14 +122,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Light::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Light::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Misc Up");
|
||||
return "Item Misc Up";
|
||||
}
|
||||
|
||||
std::string Light::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Light::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Misc Down");
|
||||
return "Item Misc Down";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -78,14 +78,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Lockpick::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Lockpick::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Lockpick Up");
|
||||
return "Item Lockpick Up";
|
||||
}
|
||||
|
||||
std::string Lockpick::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Lockpick::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Lockpick Down");
|
||||
return "Item Lockpick Down";
|
||||
}
|
||||
|
||||
std::string Lockpick::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -105,18 +105,18 @@ namespace MWClass
|
|||
return value;
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Miscellaneous::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
if (isGold(ptr))
|
||||
return std::string("Item Gold Up");
|
||||
return std::string("Item Misc Up");
|
||||
return "Item Gold Up";
|
||||
return "Item Misc Up";
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Miscellaneous::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
if (isGold(ptr))
|
||||
return std::string("Item Gold Down");
|
||||
return std::string("Item Misc Down");
|
||||
return "Item Gold Down";
|
||||
return "Item Misc Down";
|
||||
}
|
||||
|
||||
std::string Miscellaneous::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -1229,13 +1229,13 @@ namespace MWClass
|
|||
}
|
||||
|
||||
|
||||
std::string Npc::getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const
|
||||
std::string_view Npc::getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const
|
||||
{
|
||||
if(name == "left" || name == "right")
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
if(world->isFlying(ptr))
|
||||
return std::string();
|
||||
return {};
|
||||
osg::Vec3f pos(ptr.getRefData().getPosition().asVec3());
|
||||
if(world->isSwimming(ptr))
|
||||
return (name == "left") ? "Swim Left" : "Swim Right";
|
||||
|
@ -1249,7 +1249,7 @@ namespace MWClass
|
|||
int weaponType = ESM::Weapon::None;
|
||||
MWMechanics::getActiveWeapon(ptr, &weaponType);
|
||||
if (weaponType == ESM::Weapon::None)
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
const MWWorld::InventoryStore &inv = Npc::getInventoryStore(ptr);
|
||||
|
@ -1267,12 +1267,12 @@ namespace MWClass
|
|||
return (name == "left") ? "FootHeavyLeft" : "FootHeavyRight";
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Morrowind ignores land soundgen for NPCs
|
||||
if(name == "land")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "swimleft")
|
||||
return "Swim Left";
|
||||
if(name == "swimright")
|
||||
|
@ -1282,13 +1282,13 @@ namespace MWClass
|
|||
// only for biped creatures?
|
||||
|
||||
if(name == "moan")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "roar")
|
||||
return std::string();
|
||||
return {};
|
||||
if(name == "scream")
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
throw std::runtime_error(std::string("Unexpected soundgen type: ")+name);
|
||||
throw std::runtime_error("Unexpected soundgen type: " + std::string(name));
|
||||
}
|
||||
|
||||
MWWorld::Ptr Npc::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace MWClass
|
|||
|
||||
bool isPersistent (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
||||
std::string getSoundIdFromSndGen(const MWWorld::Ptr &ptr, const std::string &name) const override;
|
||||
std::string_view getSoundIdFromSndGen(const MWWorld::Ptr& ptr, std::string_view name) const override;
|
||||
|
||||
std::string getModel(const MWWorld::ConstPtr &ptr) const override;
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Potion::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Potion::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Potion Up");
|
||||
return "Item Potion Up";
|
||||
}
|
||||
|
||||
std::string Potion::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Potion::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Potion Down");
|
||||
return "Item Potion Down";
|
||||
}
|
||||
|
||||
std::string Potion::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace MWClass
|
|||
std::unique_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr, bool force=false) const override;
|
||||
///< Generate action for using via inventory menu
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -78,14 +78,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Probe::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Probe::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Probe Up");
|
||||
return "Item Probe Up";
|
||||
}
|
||||
|
||||
std::string Probe::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Probe::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Probe Down");
|
||||
return "Item Probe Down";
|
||||
}
|
||||
|
||||
std::string Probe::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -38,10 +38,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -67,14 +67,14 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Repair::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Repair::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Repair Up");
|
||||
return "Item Repair Up";
|
||||
}
|
||||
|
||||
std::string Repair::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Repair::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
return std::string("Item Repair Down");
|
||||
return "Item Repair Down";
|
||||
}
|
||||
|
||||
std::string Repair::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -123,20 +123,18 @@ namespace MWClass
|
|||
return ref->mBase->mData.mValue;
|
||||
}
|
||||
|
||||
std::string Weapon::getUpSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Weapon::getUpSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||
int type = ref->mBase->mData.mType;
|
||||
std::string soundId = MWMechanics::getWeaponType(type)->mSoundId;
|
||||
return soundId + " Up";
|
||||
return MWMechanics::getWeaponType(type)->mSoundIdUp;
|
||||
}
|
||||
|
||||
std::string Weapon::getDownSoundId (const MWWorld::ConstPtr& ptr) const
|
||||
std::string_view Weapon::getDownSoundId(const MWWorld::ConstPtr& ptr) const
|
||||
{
|
||||
const MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>();
|
||||
int type = ref->mBase->mData.mType;
|
||||
std::string soundId = MWMechanics::getWeaponType(type)->mSoundId;
|
||||
return soundId + " Down";
|
||||
return MWMechanics::getWeaponType(type)->mSoundIdDown;
|
||||
}
|
||||
|
||||
std::string Weapon::getInventoryIcon (const MWWorld::ConstPtr& ptr) const
|
||||
|
|
|
@ -48,10 +48,10 @@ namespace MWClass
|
|||
int getValue (const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||
|
||||
std::string getUpSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getUpSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the pick up sound Id
|
||||
|
||||
std::string getDownSoundId (const MWWorld::ConstPtr& ptr) const override;
|
||||
std::string_view getDownSoundId(const MWWorld::ConstPtr& ptr) const override;
|
||||
///< Return the put down sound Id
|
||||
|
||||
std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const override;
|
||||
|
|
|
@ -290,7 +290,7 @@ namespace MWGui
|
|||
{
|
||||
update();
|
||||
|
||||
std::string sound = item.getClass().getUpSoundId(item);
|
||||
std::string_view sound = item.getClass().getUpSoundId(item);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace MWGui
|
|||
{
|
||||
// play the sound of the first object
|
||||
MWWorld::Ptr item = mModel->getItem(i).mBase;
|
||||
std::string sound = item.getClass().getUpSoundId(item);
|
||||
std::string_view sound = item.getClass().getUpSoundId(item);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode
|
|||
mSourceSortModel = playerFilterModel;
|
||||
}
|
||||
|
||||
std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||
std::string_view sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound (sound);
|
||||
|
||||
if (mSourceSortModel)
|
||||
|
@ -92,7 +92,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode
|
|||
|
||||
void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView)
|
||||
{
|
||||
std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
|
||||
std::string_view sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
// We can't drop a conjured item to the ground; the target container should always be the source container
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
const ItemStack& item = mTradeModel->getItem(index);
|
||||
std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getDownSoundId(item.mBase);
|
||||
|
||||
MWWorld::Ptr object = item.mBase;
|
||||
int count = item.mCount;
|
||||
|
@ -356,7 +356,7 @@ namespace MWGui
|
|||
{
|
||||
ensureSelectedItemUnequipped(count);
|
||||
const ItemStack& item = mTradeModel->getItem(mSelectedItem);
|
||||
std::string sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
if (item.mType == ItemStack::Type_Barter)
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace MWGui
|
|||
void TradeWindow::sellItem(MyGUI::Widget* sender, int count)
|
||||
{
|
||||
const ItemStack& item = mTradeModel->getItem(mItemToSell);
|
||||
std::string sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
std::string_view sound = item.mBase.getClass().getUpSoundId(item.mBase);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(sound);
|
||||
|
||||
TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel();
|
||||
|
|
|
@ -2105,7 +2105,7 @@ namespace MWGui
|
|||
mInventoryWindow->cycle(next);
|
||||
}
|
||||
|
||||
void WindowManager::playSound(const std::string& soundId, float volume, float pitch)
|
||||
void WindowManager::playSound(std::string_view soundId, float volume, float pitch)
|
||||
{
|
||||
if (soundId.empty())
|
||||
return;
|
||||
|
|
|
@ -374,7 +374,7 @@ namespace MWGui
|
|||
/// Cycle to next or previous weapon
|
||||
void cycleWeapon(bool next) override;
|
||||
|
||||
void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) override;
|
||||
void playSound(std::string_view soundId, float volume = 1.f, float pitch = 1.f) override;
|
||||
|
||||
void addCell(MWWorld::CellStore* cell) override;
|
||||
void removeCell(MWWorld::CellStore* cell) override;
|
||||
|
|
|
@ -936,13 +936,13 @@ void CharacterController::handleTextKey(std::string_view groupname, SceneUtil::T
|
|||
auto& charClass = mPtr.getClass();
|
||||
if (evt.substr(0, 10) == "soundgen: ")
|
||||
{
|
||||
std::string soundgen = std::string(evt.substr(10));
|
||||
std::string_view soundgen = evt.substr(10);
|
||||
|
||||
// The event can optionally contain volume and pitch modifiers
|
||||
float volume=1.f, pitch=1.f;
|
||||
if (soundgen.find(' ') != std::string::npos)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
std::vector<std::string_view> tokens;
|
||||
Misc::StringUtils::split(soundgen, tokens);
|
||||
soundgen = tokens[0];
|
||||
if (tokens.size() >= 2)
|
||||
|
@ -959,7 +959,7 @@ void CharacterController::handleTextKey(std::string_view groupname, SceneUtil::T
|
|||
}
|
||||
}
|
||||
|
||||
std::string sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
std::string_view sound = charClass.getSoundIdFromSndGen(mPtr, soundgen);
|
||||
if(!sound.empty())
|
||||
{
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
@ -1129,7 +1129,7 @@ bool CharacterController::updateWeaponState()
|
|||
|
||||
const bool isWerewolf = cls.isNpc() && cls.getNpcStats(mPtr).isWerewolf();
|
||||
|
||||
std::string downSoundId;
|
||||
std::string_view downSoundId;
|
||||
bool weaponChanged = false;
|
||||
bool ammunition = true;
|
||||
float weapSpeed = 1.f;
|
||||
|
@ -1304,7 +1304,7 @@ bool CharacterController::updateWeaponState()
|
|||
|
||||
if (!mWeapon.isEmpty() && mWeaponType != ESM::Weapon::HandToHand && isRealWeapon(weaptype))
|
||||
{
|
||||
std::string upSoundId = mWeapon.getClass().getUpSoundId(mWeapon);
|
||||
std::string_view upSoundId = mWeapon.getClass().getUpSoundId(mWeapon);
|
||||
if (!upSoundId.empty())
|
||||
sndMgr->playSound3D(mPtr, upSoundId, 1.0f, 1.0f);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ void WeaponAnimation::attachArrow(const MWWorld::Ptr& actor)
|
|||
ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(type)->mWeaponClass;
|
||||
if (weapclass == ESM::WeaponType::Thrown)
|
||||
{
|
||||
std::string soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
std::string_view soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot);
|
||||
if(!soundid.empty())
|
||||
{
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
|
|
|
@ -58,7 +58,7 @@ void MWWorld::Action::execute (const Ptr& actor, bool noSound)
|
|||
executeImp (actor);
|
||||
}
|
||||
|
||||
void MWWorld::Action::setSound (const std::string& id)
|
||||
void MWWorld::Action::setSound(std::string_view id)
|
||||
{
|
||||
mSoundId = id;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define GAME_MWWORLD_ACTION_H
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
||||
|
@ -39,7 +40,7 @@ namespace MWWorld
|
|||
|
||||
void execute (const Ptr& actor, bool noSound = false);
|
||||
|
||||
void setSound (const std::string& id);
|
||||
void setSound(std::string_view id);
|
||||
void setSoundOffset(float offset);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -251,17 +251,17 @@ namespace MWWorld
|
|||
getClasses().emplace(instance.getType(), &instance);
|
||||
}
|
||||
|
||||
std::string Class::getUpSoundId (const ConstPtr& ptr) const
|
||||
std::string_view Class::getUpSoundId (const ConstPtr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have an up sound");
|
||||
}
|
||||
|
||||
std::string Class::getDownSoundId (const ConstPtr& ptr) const
|
||||
std::string_view Class::getDownSoundId (const ConstPtr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have an down sound");
|
||||
}
|
||||
|
||||
std::string Class::getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const
|
||||
std::string_view Class::getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const
|
||||
{
|
||||
throw std::runtime_error("class does not support soundgen look up");
|
||||
}
|
||||
|
|
|
@ -235,15 +235,15 @@ namespace MWWorld
|
|||
///
|
||||
/// (default implementation: return false)
|
||||
|
||||
virtual std::string getUpSoundId (const ConstPtr& ptr) const;
|
||||
virtual std::string_view getUpSoundId(const ConstPtr& ptr) const;
|
||||
///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval
|
||||
/// (default implementation: throw an exception)
|
||||
|
||||
virtual std::string getDownSoundId (const ConstPtr& ptr) const;
|
||||
virtual std::string_view getDownSoundId(const ConstPtr& ptr) const;
|
||||
///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval
|
||||
/// (default implementation: throw an exception)
|
||||
|
||||
virtual std::string getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const;
|
||||
virtual std::string_view getSoundIdFromSndGen(const Ptr& ptr, std::string_view type) const;
|
||||
///< Returns the sound ID for \a ptr of the given soundgen \a type.
|
||||
|
||||
virtual float getArmorRating (const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -103,13 +103,20 @@ struct WeaponType
|
|||
//std::string mDisplayName; // TODO: will be needed later for editor
|
||||
std::string mShortGroup;
|
||||
std::string mLongGroup;
|
||||
std::string mSoundId;
|
||||
std::string mSoundIdDown;
|
||||
std::string mSoundIdUp;
|
||||
std::string mAttachBone;
|
||||
std::string mSheathingBone;
|
||||
Skill::SkillEnum mSkill;
|
||||
Class mWeaponClass;
|
||||
int mAmmoType;
|
||||
int mFlags;
|
||||
|
||||
WeaponType(std::string shortGroup, std::string longGroup, const std::string& soundId, std::string attachBone,
|
||||
std::string sheathingBone, Skill::SkillEnum skill, Class weaponClass, int ammoType, int flags) :
|
||||
mShortGroup(std::move(shortGroup)), mLongGroup(std::move(longGroup)), mSoundIdDown(soundId + " Down"),
|
||||
mSoundIdUp(soundId + " Up"), mAttachBone(std::move(attachBone)), mSheathingBone(std::move(sheathingBone)),
|
||||
mSkill(skill), mWeaponClass(weaponClass), mAmmoType(ammoType), mFlags(flags) {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue