mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-16 07:10:08 +00:00
Operators and retting rid of 'records'
This commit is contained in:
parent
a0989c3481
commit
4449b66846
@ -19,7 +19,7 @@ namespace
|
||||
|
||||
const ESM::Dialogue* foundDialogueFilteredOut(const ESM::Dialogue* possibleResult) const
|
||||
{
|
||||
if (possibleResult and possibleResult->mType == filter)
|
||||
if (possibleResult && possibleResult->mType == filter)
|
||||
{
|
||||
return possibleResult;
|
||||
}
|
||||
@ -56,7 +56,7 @@ namespace
|
||||
do
|
||||
{
|
||||
++mIter;
|
||||
} while (mIter->mType != filter and mIter != mEndIter);
|
||||
} while (mIter->mType != filter && mIter != mEndIter);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -66,13 +66,13 @@ namespace
|
||||
do
|
||||
{
|
||||
++mIter;
|
||||
} while (mIter->mType != filter and mIter != mEndIter);
|
||||
} while (mIter->mType != filter && mIter != mEndIter);
|
||||
return iter;
|
||||
}
|
||||
|
||||
FilteredDialogueIterator& operator+=(difference_type advance)
|
||||
{
|
||||
while (advance > 0 and mIter != mEndIter)
|
||||
while (advance > 0 && mIter != mEndIter)
|
||||
{
|
||||
++mIter;
|
||||
if (mIter->mType == filter)
|
||||
@ -85,7 +85,7 @@ namespace
|
||||
|
||||
bool operator==(const FilteredDialogueIterator& x) const { return mIter == x.mIter; }
|
||||
|
||||
bool operator!=(const FilteredDialogueIterator& x) const { return not(*this == x); }
|
||||
bool operator!=(const FilteredDialogueIterator& x) const { return !(*this == x); }
|
||||
|
||||
const value_type& operator*() const { return *mIter; }
|
||||
|
||||
@ -121,7 +121,7 @@ namespace
|
||||
iterator begin() const
|
||||
{
|
||||
iterator result{ mDialogueStore.begin(), mDialogueStore.end() };
|
||||
while (result != end() and result->mType != filter)
|
||||
while (result != end() && result->mType != filter)
|
||||
{
|
||||
++result;
|
||||
}
|
||||
@ -136,12 +136,6 @@ namespace
|
||||
{
|
||||
using StoreT = FilteredDialogueStore<filter>;
|
||||
|
||||
table["record"] = sol::overload(
|
||||
[](const MWLua::Object& obj) -> const ESM::Dialogue* { return obj.ptr().get<ESM::Dialogue>()->mBase; },
|
||||
[](std::string_view id) -> const ESM::Dialogue* {
|
||||
return StoreT{}.search(ESM::RefId::deserializeText(Misc::StringUtils::lowerCase(id)));
|
||||
});
|
||||
|
||||
sol::state_view& lua = context.mLua->sol();
|
||||
sol::usertype<StoreT> storeBindingsClass
|
||||
= lua.new_usertype<StoreT>("ESM3_Dialogue_Type" + std::to_string(filter) + " Store");
|
||||
@ -151,7 +145,7 @@ namespace
|
||||
storeBindingsClass[sol::meta_function::length] = [](const StoreT& store) { return store.getSize(); };
|
||||
storeBindingsClass[sol::meta_function::index] = sol::overload(
|
||||
[](const StoreT& store, size_t index) -> const ESM::Dialogue* {
|
||||
if (index == 0 or index > store.getSize())
|
||||
if (index == 0 || index > store.getSize())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@ -224,7 +218,7 @@ namespace
|
||||
recordInfosBindingsClass[sol::meta_function::index]
|
||||
= [](const DialogueInfos& store, size_t index) -> const ESM::DialInfo* {
|
||||
const ESM::Dialogue* dialogueRecord = store.getDialogueRecord();
|
||||
if (not dialogueRecord or index == 0 or index > dialogueRecord->mInfo.size())
|
||||
if (!dialogueRecord || index == 0 || index > dialogueRecord->mInfo.size())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@ -367,7 +361,7 @@ namespace
|
||||
return result == -1 ? sol::nil : sol::make_object(lua, result);
|
||||
});
|
||||
recordInfoBindingsClass["sound"] = sol::readonly_property([lua](const ESM::DialInfo& rec) -> sol::object {
|
||||
if (rec.mData.mType == ESM::Dialogue::Type::Journal or rec.mSound == "")
|
||||
if (rec.mData.mType == ESM::Dialogue::Type::Journal || rec.mSound == "")
|
||||
{
|
||||
return sol::nil;
|
||||
}
|
||||
|
@ -932,14 +932,14 @@
|
||||
-- @{#DialogueRecords} functions for journal (quest) read-only records.
|
||||
-- @field [parent=#Dialogue] journal
|
||||
-- @usage --print the name of the record, which is a capitalized version of its id
|
||||
-- print(core.dialogue.journal.record("ms_fargothring").name) -- MS_FargothRing
|
||||
-- print(core.dialogue.journal.records["ms_fargothring"].name) -- MS_FargothRing
|
||||
-- @usage --print ids of all journal records
|
||||
-- for _, journalRecord in pairs(core.dialogue.journal.records) do
|
||||
-- print(journalRecord.id)
|
||||
-- end
|
||||
-- @usage --print quest names for all quests the player has inside a player script
|
||||
-- for _, quest in pairs(types.Player.quests(self)) do
|
||||
-- print(quest.id, core.dialogue.journal.record(quest.id).questName)
|
||||
-- print(quest.id, core.dialogue.journal.records[quest.id].questName)
|
||||
-- end
|
||||
|
||||
---
|
||||
@ -950,7 +950,7 @@
|
||||
-- print(topicRecord.id)
|
||||
-- end
|
||||
-- @usage --print all NPC lines for "vivec"
|
||||
-- for idx, topicInfo in pairs(core.dialogue.topic.record("vivec").infos) do
|
||||
-- for idx, topicInfo in pairs(core.dialogue.topic.records["vivec"].infos) do
|
||||
-- print(idx, topicInfo.text)
|
||||
-- end
|
||||
|
||||
@ -962,7 +962,7 @@
|
||||
-- print(voiceRecord.id)
|
||||
-- end
|
||||
-- @usage --print all NPC lines & sounds for "flee"
|
||||
-- for idx, voiceInfo in pairs(core.dialogue.voice.record("flee").infos) do
|
||||
-- for idx, voiceInfo in pairs(core.dialogue.voice.records["flee"].infos) do
|
||||
-- print(idx, voiceInfo.text, voiceInfo.sound)
|
||||
-- end
|
||||
|
||||
@ -974,7 +974,7 @@
|
||||
-- print(greetingRecord.id)
|
||||
-- end
|
||||
-- @usage --print all NPC lines for "greeting 0"
|
||||
-- for idx, greetingInfo in pairs(core.dialogue.greeting.record("greeting 0").infos) do
|
||||
-- for idx, greetingInfo in pairs(core.dialogue.greeting.records["greeting 0"].infos) do
|
||||
-- print(idx, greetingInfo.text)
|
||||
-- end
|
||||
|
||||
@ -986,35 +986,25 @@
|
||||
-- print(persuasionRecord.id)
|
||||
-- end
|
||||
-- @usage --print all NPC lines for "admire success"
|
||||
-- for idx, persuasionInfo in pairs(core.dialogue.persuasion.record("admire success").infos) do
|
||||
-- for idx, persuasionInfo in pairs(core.dialogue.persuasion.records["admire success"].infos) do
|
||||
-- print(idx, persuasionInfo.text)
|
||||
-- end
|
||||
|
||||
---
|
||||
-- A read-only list of all @{#DialogueRecord}s in the world database, may be indexed by recordId, which doesn't have to be lowercase.
|
||||
-- @field [parent=#DialogueRecords] #list<#DialogueRecord> records
|
||||
-- Indexing is not case-sensitive.
|
||||
-- Implements [iterables#List](iterables.html#List) of #DialogueRecord.
|
||||
-- @field [parent=#DialogueRecords] #list<#DialogueRecord> records
|
||||
-- @usage local record = core.dialogue.journal.records['ms_fargothring']
|
||||
-- @usage local record = core.dialogue.journal.records['MS_FargothRing']
|
||||
-- @usage local record = core.dialogue.journal.records[1]
|
||||
-- @usage local record = core.dialogue.topic.records[1]
|
||||
-- @usage local record = core.dialogue.topic.records['background']
|
||||
-- @usage local record = core.dialogue.greeting.records[1]
|
||||
-- @usage local record = core.dialogue.greeting.records['greeting 0']
|
||||
-- @usage local record = core.dialogue.persuasion.records[1]
|
||||
-- @usage local record = core.dialogue.persuasion.records['admire success']
|
||||
-- @usage local record = core.dialogue.voice.records[1]
|
||||
|
||||
---
|
||||
-- Returns a read-only @{#DialogueRecord}
|
||||
-- @function [parent=#DialogueRecords] record
|
||||
-- @param #string recordId Doesn't have to be lowercase.
|
||||
-- @return #DialogueRecord
|
||||
-- @usage local record = core.dialogue.journal.record('a1_2_antabolisinformant')
|
||||
-- @usage local record = core.dialogue.journal.record('A1_2_AntabolisInformant')
|
||||
-- @usage local record = core.dialogue.topic.record('my trade')
|
||||
-- @usage local record = core.dialogue.greeting.record('greeting 0')
|
||||
-- @usage local record = core.dialogue.persuasion.record('admire success')
|
||||
-- @usage local record = core.dialogue.voice.record('flee')
|
||||
-- @usage local record = core.dialogue.voice.records["flee"]
|
||||
|
||||
---
|
||||
-- Depending on which store this read-only dialogue record is from, it may either be a journal, topic, greeting, persuasion or voice.
|
||||
@ -1023,9 +1013,9 @@
|
||||
-- @field #string name Same as id, but with upper cases preserved.
|
||||
-- @field #string questName Non-nil only for journal records with available value. Holds the quest name for this journal entry. Same info may be available under `infos[1].text` as well, but this variable is made for convenience.
|
||||
-- @field #list<#DialogueRecordInfo> infos A read-only list containing all @{#DialogueRecordInfo}s for this record, in order.
|
||||
-- @usage local journalId = core.dialogue.journal.record('A2_4_MiloGone').id -- "a2_4_milogone"
|
||||
-- @usage local journalName = core.dialogue.journal.record('A2_4_MiloGone').name -- "A2_4_MiloGone"
|
||||
-- @usage local questName = core.dialogue.journal.record('A2_4_MiloGone').questName -- "Mehra Milo and the Lost Prophecies"
|
||||
-- @usage local journalId = core.dialogue.journal.records['A2_4_MiloGone'].id -- "a2_4_milogone"
|
||||
-- @usage local journalName = core.dialogue.journal.records['A2_4_MiloGone'].name -- "A2_4_MiloGone"
|
||||
-- @usage local questName = core.dialogue.journal.records['A2_4_MiloGone'].questName -- "Mehra Milo and the Lost Prophecies"
|
||||
|
||||
---
|
||||
-- Holds the read-only data for one of many info entries inside a dialogue record. Depending on the type of the dialogue record (journal, topic, greeting, persuasion or voice), it could be, for example, a single journal entry or a NPC dialogue line.
|
||||
@ -1049,9 +1039,9 @@
|
||||
-- @field #string sound Non-nil only for non-journal records with available value for this parameter. Sound file path for this info entry.
|
||||
-- @field #string resultScript Non-nil only for non-journal records with available value for this parameter. MWScript (full script text) executed when this info is chosen.
|
||||
-- @usage --Variable `aa` below is "Congratulations, %PCName. You are now %PCName the %NextPCRank." in vanilla MW:
|
||||
-- local aa = core.dialogue.topic.record('advancement').infos[100].text
|
||||
-- local aa = core.dialogue.topic.records['advancement'].infos[100].text
|
||||
-- @usage --Variable `bb` below is "sound/vo/a/f/fle_af003.mp3" in vanilla MW:
|
||||
-- local bb = core.dialogue.voice.record('flee').infos[149].sound
|
||||
-- local bb = core.dialogue.voice.records['flee'].infos[149].sound
|
||||
|
||||
--- @{#Factions}: Factions
|
||||
-- @field [parent=#core] #Factions factions
|
||||
|
Loading…
Reference in New Issue
Block a user