-
Notifications
You must be signed in to change notification settings - Fork 30
/
IResource.h
116 lines (96 loc) · 3.07 KB
/
IResource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#pragma once
#include "types/MValue.h"
#include "types/Permissions.h"
#include "ILocalStorage.h"
#include "script-objects/IWebView.h"
#include "script-objects/IWebSocketClient.h"
#include "script-objects/IBlip.h"
#include "script-objects/ICheckpoint.h"
#include "script-objects/INative.h"
#include "deps/alt-config/alt-config.h"
#include <vector>
#include <set>
#include <memory>
#include "deps/ConfigBase.h"
namespace alt
{
class IScriptRuntime;
class IPackage;
class CEvent;
class IResource
{
protected:
virtual ~IResource() = default;
public:
struct CreationInfo
{
std::string type;
std::string name;
std::string main;
IPackage *pkg;
};
class Impl
{
public:
#ifdef ALT_SERVER_API
virtual bool MakeClient(CreationInfo *info, std::vector<std::string> files)
{
return true;
}
#endif
virtual bool Start()
{
return true;
}
virtual bool Stop() { return true; }
virtual bool Mount() { return true; }
virtual void OnEvent(const CEvent *ev) { }
/**
* Clientside:
* If natives are enabled, it is not necessary to call PushNatives() to make natives invokable.
* */
virtual void OnTick(){}
virtual void OnCreateBaseObject(IBaseObject* object){}
virtual void OnRemoveBaseObject(IBaseObject* object){}
virtual ~Impl() = default;
};
virtual IScriptRuntime *GetRuntime() const = 0;
virtual Impl *GetImpl() const = 0;
virtual bool IsStarted() const = 0;
virtual const std::string& GetType() const = 0;
virtual const std::string& GetName() const = 0;
virtual const std::string& GetPath() const = 0;
virtual const std::string& GetMain() const = 0;
virtual IPackage *GetPackage() const = 0;
virtual MValueDict GetExports() const = 0;
virtual const std::vector<std::string> GetDependencies() const = 0;
virtual const std::vector<std::string> GetDependants() const = 0;
virtual const std::vector<Permission> GetRequiredPermissions() const = 0;
virtual const std::vector<Permission> GetOptionalPermissions() const = 0;
virtual void SetExports(MValueDict exports) = 0;
#ifdef ALT_SERVER_API
virtual std::string GetClientType() const = 0;
virtual std::string GetClientMain() const = 0;
virtual const std::vector<std::string>& GetClientFiles() const = 0;
#endif
virtual Config::Value::ValuePtr GetConfig() const = 0;
#ifdef ALT_SERVER_API
virtual std::set<std::string> GetMatchedFiles(const std::vector<std::string>& patterns) = 0;
#endif
#ifdef ALT_CLIENT_API
virtual void EnableNatives() = 0;
[[nodiscard]]
virtual std::shared_ptr<INative::Context> CreateNativesContext() const = 0;
[[nodiscard]]
virtual std::shared_ptr<INative::Scope> PushNativesScope() = 0;
virtual ILocalStorage *GetLocalStorage() = 0;
virtual void AddGxtText(uint32_t hash, const std::string& text) = 0;
virtual void RemoveGxtText(uint32_t hash) = 0;
virtual const std::string& GetGxtText(uint32_t hash) = 0;
virtual bool ToggleCursor(bool state) = 0;
virtual void ToggleGameControls(bool state) = 0;
virtual bool CursorVisible() = 0;
virtual bool GameControlsActive() = 0;
#endif
};
} // namespace alt