You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a full guide on how to get started with the AddonHost and implement your own addon. This guide will remain build-system agnostic and avoid compiler extensions where possible.
2
+
This is a complete guide on how to get started with the AddonHost and implement your own addon. It is build-system agnostic and avoids compiler-specific extensions where possible.
3
3
4
4
\note
5
-
This guide will be using the C++ programming language. Creation of addons in languages other than C++ are outside the scope of this guide.
6
-
If you want to program in another language, check out the [community bindings](@ref bindings)
5
+
This guide uses the C++ programming language. Creating addons in languages other than C++ is outside the scope of this guide.
6
+
If you want to program in another language, check out the [community bindings](@ref bindings).
7
7
8
-
If all you need is an example, see [The Compass Addon](https://github.com/RaidcoreGG/GW2-Compass) (Built with Visual Studio)
9
-
Alternately, see [NexPad](https://github.com/ChristopherJTrent/NexPad) for a GNU make + GCC example using Msys2
8
+
If all you need is an example, numerous Nexus addons are open source, notably:
9
+
1.[The Compass Addon](https://github.com/RaidcoreGG/GW2-Compass), which includes Visual Studio project files
10
+
2.[NexPad](https://github.com/ChristopherJTrent/NexPad), a GNU Make + GCC example using MSYS2
11
+
3.[TrueWorldCompletion](https://github.com/jsantorek/GW2-TrueWorldCompletion), which uses CMake and Clang (with Docker and Conan as options)
10
12
11
-
Each addon loaded by nexus is required to export a function matching the signature `AddonDefinition_t* GetAddonDef()`. See [AddonDefinition_t](@ref AddonDefinition_t) for the full struct definition
13
+
Each addon loaded by Nexus is required to export a function matching the signature `AddonDefinition_t* GetAddonDef()`. See [AddonDefinition_t](@ref AddonDefinition_t) for the full struct definition.
12
14
13
-
Example implementation of GetAddonDef
15
+
### Example implementation of `GetAddonDef`
14
16
```cpp
17
+
#include<Nexus.h>
18
+
15
19
AddonDefinition_t AddonDef{};
16
20
17
-
voidAddonLoad(AddonAPI_t*) {} //add a body as needed.
18
-
void AddonUnload() {} //add a body as needed.
21
+
voidAddonLoad(AddonAPI_t*) {} // Add a body as needed.
AddonDef.Signature = -1; //This must be positive and unused if your addon is available on nexus and negative otherwise.
23
-
AddonDef.APIVersion = NEXUS_API_VERSION; //this is defined in nexus.h, and contains the current latest version of nexus.
24
-
AddonDef.Name = "Example Addon";
25
-
AddonDef.Version.Major = 1; //Treat AddonDef.Version as a SemVer compatible version number.
26
-
AddonDef.Version.Minor = 0;
27
-
AddonDef.Version.Build = 0;
28
-
AddonDef.Version.Revision = 1;
29
-
AddonDef.Author = "Raidcore";
30
-
AddonDef.Description = "Example Addon for Documentation";
31
-
AddonDef.Load = *AddonLoad;
32
-
AddonDef.Unload = *AddonUnload;
33
-
34
-
//Optional:
35
-
AddonDef.Provider = EUpdateProvider::UP_None; //See EUpdateProvider in nexus.h
36
-
AddonDef.UpdateLink = "https://github.com/RaidcoreGG/GW2-Example-Addon" // this link doesn't actually exist.
26
+
AddonDef.Signature = -1; // Must be positive and unused if hosted on Nexus; negative otherwise.
27
+
AddonDef.APIVersion = NEXUS_API_VERSION; // Defined in Nexus.h; the latest supported API version.
28
+
AddonDef.Name = "Example Addon";
29
+
AddonDef.Version.Major = 1; // Treat AddonDef.Version as a SemVer-compatible version.
30
+
AddonDef.Version.Minor = 0;
31
+
AddonDef.Version.Build = 0;
32
+
AddonDef.Version.Revision = 1;
33
+
AddonDef.Author = "Raidcore";
34
+
AddonDef.Description = "Example Addon for Documentation";
35
+
AddonDef.Load = &AddonLoad;
36
+
AddonDef.Unload = &AddonUnload;
37
+
38
+
// Optional:
39
+
AddonDef.Provider = EUpdateProvider::EUpdateProvider_None; // See EUpdateProvider in Nexus.h
40
+
AddonDef.UpdateLink = "https://github.com/RaidcoreGG/GW2-Example-Addon"; // This link doesn't actually exist.
41
+
42
+
return &AddonDef;
37
43
}
38
44
```
39
-
Fields not explicitly marked as optional are required.
40
-
`Load()` will be called when your addon is loaded, and should initialize anything your addon needs. The `AddonAPI_t*` it receives will contain a version of the nexus API matching the one specified in `AddonDef.APIVersion`. See [AddonAPI_t](@ref AddonAPI_t) for the current version of that API.
41
-
`Unload()` will be called when the game shuts down, when your addon is updated, and when it is unloaded. If your addon should not be able to be unloaded at runtime, set `AddonDef.Flags` to `EAddonFlags::DisableHotloading`.
45
+
Fields not explicitly marked as optional are required.
46
+
47
+
`Load()` will be called when your addon is loaded and should initialize anything the addon needs. The `AddonAPI*` parameter will contain a version of the Nexus API matching the one specified in `AddonDef.APIVersion`. See [AddonAPI_t](@ref AddonAPI_t) for the current API definition.
42
48
43
-
### Addon Signatures
44
-
If your addon is hosted on Raidcore, this should be the unique ID of your addon.
45
-
If your addon is *not* hosted on Raidcore, it should be any negative integer.
49
+
`Unload()` will be called when the game shuts down, when your addon is updated, or when it is manually unloaded. If your addon must not be unloaded at runtime, set `AddonDef.Flags` to `EAddonFlags::DisableHotloading`.
50
+
51
+
### Addon Signatures
52
+
If your addon is hosted on Raidcore, this should be the unique ID of your addon.
53
+
If your addon is *not* hosted on Raidcore, it should be any negative integer.
46
54
47
55
\note
48
-
Do not set it to 0, and do not use the signature of another addon.
56
+
Do not set the signature to 0, and do not use the signature of another addon.
49
57
50
58
### API Versions
51
-
If you don't use any of Nexus's functions, set APIVersion to 0.
52
-
If APIVersion is a non-zero value, it must be a current or previous `NEXUS_API_VERSION`.
59
+
If you do not use any Nexus API functions, set APIVersion to 0.
60
+
If APIVersion is non-zero, it must be a current or previous `NEXUS_API_VERSION`.
53
61
54
62
\warning
55
-
Your addon will not load if you set APIVersion to an invalid value.
63
+
Your addon will not load if APIVersion is set to an invalid value.
56
64
57
65
## The Addon API reference
58
-
It is recommended to store the reference to the addon API in a shared place, so you can include it in any files that need it. An example of how to do this is shown below.
66
+
It is recommended to store the addon API reference in a shared location so it can be accessed from any file that needs it. An example is shown below.
59
67
60
68
### `Shared.h`
61
69
```cpp
62
70
#pragma once
63
-
#include "nexus.h"
71
+
#include "Nexus.h"
64
72
//#include "imgui.h"
65
73
66
74
extern AddonAPI_t* Addon_API;
@@ -78,18 +86,20 @@ AddonAPI_t Addon_API;
78
86
voidAddonLoad(AddonAPI_t* API) {
79
87
Addon_API = API;
80
88
81
-
//Uncomment the next two lines if you are using imgui, and have included it in shared.h
89
+
//Uncomment the next two lines if you are using ImGui and have included it in Shared.h
0 commit comments