1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00
OpenMW/apps/openmw/mwdialogue/dialoguemanagerimp.hpp
fteppe 125b21de20 Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID

Slowly going through all the changes to make, still hundreds of errors

a lot of functions/structures use std::string or stringview to designate an ID. So it takes time

Continues slowly replacing ids. There are technically more and more compilation errors

I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type

Continue moving forward, changes to the stores

slowly moving along

Starting to see the fruit of those changes.

still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.

More replacements. Things are starting to get easier

I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.

Still moving forward, and for the first time error count is going down!

Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably

Cells are back to using string for the name, haven't fixed everything yet. Many other changes

Under the bar of 400 compilation errors.

more good progress <100 compile errors!

More progress

Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string

some more progress on other fronts

Mostly game settings clean

one error opened a lot of other errors. Down to 18, but more will prbably appear

only link errors left??

Fixed link errors

OpenMW compiles, and launches, with some issues, but still!
2022-12-27 19:15:54 +01:00

132 lines
4.4 KiB
C++

#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#include "../mwbase/dialoguemanager.hpp"
#include <map>
#include <set>
#include <unordered_map>
#include <components/compiler/streamerrorhandler.hpp>
#include <components/esm3/loadinfo.hpp>
#include <components/misc/strings/algorithm.hpp>
#include <components/translation/translation.hpp>
#include "../mwworld/ptr.hpp"
#include "../mwscript/compilercontext.hpp"
namespace ESM
{
struct Dialogue;
}
namespace MWDialogue
{
class DialogueManager : public MWBase::DialogueManager
{
struct ActorKnownTopicInfo
{
int mFlags;
const ESM::DialInfo* mInfo;
};
std::set<ESM::RefId> mKnownTopics; // Those are the topics the player knows.
// Modified faction reactions. <Faction1, <Faction2, Difference> >
typedef std::map<ESM::RefId, std::map<ESM::RefId, int>> ModFactionReactionMap;
ModFactionReactionMap mChangedFactionReaction;
std::map<ESM::RefId, ActorKnownTopicInfo> mActorKnownTopics;
Translation::Storage& mTranslationDataStorage;
MWScript::CompilerContext mCompilerContext;
Compiler::StreamErrorHandler mErrorHandler;
MWWorld::Ptr mActor;
bool mTalkedTo;
int mChoice;
ESM::RefId mLastTopic; // last topic ID, lowercase
bool mIsInChoice;
bool mGoodbye;
std::vector<std::pair<std::string, int>> mChoices;
int mOriginalDisposition;
int mCurrentDisposition;
int mPermanentDispositionChange;
std::vector<ESM::RefId> parseTopicIdsFromText(const std::string& text);
void addTopicsFromText(const std::string& text);
void updateActorKnownTopics();
void updateGlobals();
bool compile(const std::string& cmd, std::vector<Interpreter::Type_Code>& code, const MWWorld::Ptr& actor);
void executeScript(const std::string& script, const MWWorld::Ptr& actor);
void executeTopic(const ESM::RefId& topic, ResponseCallback* callback);
const ESM::Dialogue* searchDialogue(const ESM::RefId& id);
void updateOriginalDisposition();
public:
DialogueManager(const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage);
void clear() override;
bool isInChoice() const override;
bool startDialogue(const MWWorld::Ptr& actor, ResponseCallback* callback) override;
std::list<std::string> getAvailableTopics() override;
int getTopicFlag(const ESM::RefId& topicId) const override;
bool inJournal(const ESM::RefId& topicId, const ESM::RefId& infoId) const override;
void addTopic(const ESM::RefId& topic) override;
void addChoice(std::string_view text, int choice) override;
const std::vector<std::pair<std::string, int>>& getChoices() const override;
bool isGoodbye() const override;
void goodbye() override;
bool checkServiceRefused(ResponseCallback* callback, ServiceType service = ServiceType::Any) override;
void say(const MWWorld::Ptr& actor, const ESM::RefId& topic) override;
// calbacks for the GUI
void keywordSelected(const std::string& keyword, ResponseCallback* callback) override;
void goodbyeSelected() override;
void questionAnswered(int answer, ResponseCallback* callback) override;
void persuade(int type, ResponseCallback* callback) override;
/// @note Controlled by an option, gets discarded when dialogue ends by default
void applyBarterDispositionChange(int delta) override;
int countSavedGameRecords() const override;
void write(ESM::ESMWriter& writer, Loading::Listener& progress) const override;
void readRecord(ESM::ESMReader& reader, uint32_t type) override;
/// Changes faction1's opinion of faction2 by \a diff.
void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) override;
void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) override;
/// @return faction1's opinion of faction2
int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const override;
/// Removes the last added topic response for the given actor from the journal
void clearInfoActor(const MWWorld::Ptr& actor) const override;
};
}
#endif