123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #pragma once
- #include <ReferenceCounter.h>
- #include <Text.h>
- #include "Entity.h"
- class ChatCommandParameter;
- class ChatCommand : public Framework::ConsoleCommand
- {
- private:
- Framework::Text description;
- int securityLevel;
- Framework::RCArray<ChatCommandParameter> params;
- public:
- ChatCommand(
- Framework::Text name, Framework::Text description, int securityLevel);
- protected:
- void addParam(ChatCommandParameter* param);
- public:
- virtual bool execute(
- Framework::RCArray<Framework::Text>& params, Entity* zActor) const
- = 0;
- bool execute(Framework::RCArray<Framework::Text>& params) const override;
- void addAutocompletePossibilities(
- const Framework::RCArray<Framework::Text>& args,
- bool appendToLast,
- Framework::RCArray<Framework::Text>& possibilities) const override;
- const Framework::RCArray<ChatCommandParameter>& getParams() const;
- Framework::Text getHelp() const;
- virtual int getSecurityLevel(
- Framework::RCArray<Framework::Text> params) const;
- };
- class ChatCommandParameter : public virtual Framework::ReferenceCounter
- {
- private:
- Framework::Text name;
- Framework::Text description;
- bool optional;
- public:
- ChatCommandParameter(
- Framework::Text name, Framework::Text description, bool optional);
- virtual bool isLegalValue(Framework::Text value) const;
- virtual Framework::Text getDefaultValue(Entity* zActor) const;
- Framework::Text getName() const;
- Framework::Text getDescription() const;
- bool isOptional() const;
- virtual Framework::RCArray<Framework::Text> getAutocompleteValues(
- const Framework::Text& current) const;
- };
- class PlayerNameParameter : public ChatCommandParameter
- {
- public:
- PlayerNameParameter();
- bool isLegalValue(Framework::Text value) const override;
- Framework::Text getDefaultValue(Entity* zActor) const override;
- Framework::RCArray<Framework::Text> getAutocompleteValues(
- const Framework::Text& current) const override;
- };
- class IntegerParameter : public ChatCommandParameter
- {
- private:
- std::function<int(Entity* zEntity)> calculateDefault;
- public:
- IntegerParameter(Framework::Text name,
- Framework::Text description,
- bool optional,
- std::function<int(Entity* zEntity)> calculateDefault);
- bool isLegalValue(Framework::Text value) const override;
- Framework::Text getDefaultValue(Entity* zActor) const override;
- };
|