1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-28 00:15:06 +00:00
OpenMW/components/interpreter/context.hpp
florent.teppe 65cdd489fb create a specific esm reader function for RefID to avoid allocation for string and then again for RefId
Fixed some types

removed useless header

applied clang format

fixed compile tests

fixed clang tidy, and closer to logic before this MR

Removed hardcoded refids

unless there is a returned value we don't use static RefIds
can use == between RefId and hardcoded string

Fix clang format

Fixed a few instances where std::string was used, when only const std::string& was needed

removed unused variable
2022-12-27 19:15:57 +01:00

97 lines
3.0 KiB
C++

#ifndef INTERPRETER_CONTEXT_H_INCLUDED
#define INTERPRETER_CONTEXT_H_INCLUDED
#include <components/esm/refid.hpp>
#include <string>
#include <string_view>
#include <vector>
namespace Interpreter
{
class Context
{
public:
virtual ~Context() {}
virtual const ESM::RefId& getTarget() const = 0;
virtual int getLocalShort(int index) const = 0;
virtual int getLocalLong(int index) const = 0;
virtual float getLocalFloat(int index) const = 0;
virtual void setLocalShort(int index, int value) = 0;
virtual void setLocalLong(int index, int value) = 0;
virtual void setLocalFloat(int index, float value) = 0;
virtual void messageBox(std::string_view message, const std::vector<std::string>& buttons) = 0;
void messageBox(std::string_view message)
{
std::vector<std::string> empty;
messageBox(message, empty);
}
virtual void report(const std::string& message) = 0;
virtual int getGlobalShort(std::string_view name) const = 0;
virtual int getGlobalLong(std::string_view name) const = 0;
virtual float getGlobalFloat(std::string_view name) const = 0;
virtual void setGlobalShort(std::string_view name, int value) = 0;
virtual void setGlobalLong(std::string_view name, int value) = 0;
virtual void setGlobalFloat(std::string_view name, float value) = 0;
virtual std::vector<std::string> getGlobals() const = 0;
virtual char getGlobalType(std::string_view name) const = 0;
virtual std::string getActionBinding(std::string_view action) const = 0;
virtual std::string_view getActorName() const = 0;
virtual std::string_view getNPCRace() const = 0;
virtual std::string_view getNPCClass() const = 0;
virtual std::string_view getNPCFaction() const = 0;
virtual std::string_view getNPCRank() const = 0;
virtual std::string_view getPCName() const = 0;
virtual std::string_view getPCRace() const = 0;
virtual std::string_view getPCClass() const = 0;
virtual std::string_view getPCRank() const = 0;
virtual std::string_view getPCNextRank() const = 0;
virtual int getPCBounty() const = 0;
virtual std::string_view getCurrentCellName() const = 0;
virtual int getMemberShort(const ESM::RefId& id, std::string_view name, bool global) const = 0;
virtual int getMemberLong(const ESM::RefId& id, std::string_view name, bool global) const = 0;
virtual float getMemberFloat(const ESM::RefId& id, std::string_view name, bool global) const = 0;
virtual void setMemberShort(const ESM::RefId& id, std::string_view name, int value, bool global) = 0;
virtual void setMemberLong(const ESM::RefId& id, std::string_view name, int value, bool global) = 0;
virtual void setMemberFloat(const ESM::RefId& id, std::string_view name, float value, bool global) = 0;
};
}
#endif