diff --git a/.github/ISSUE_TEMPLATE/BUG.yml b/.github/ISSUE_TEMPLATE/BUG.yml index 2a1171f..455d6e8 100644 --- a/.github/ISSUE_TEMPLATE/BUG.yml +++ b/.github/ISSUE_TEMPLATE/BUG.yml @@ -21,8 +21,10 @@ body: id: version attributes: label: Version - description: What version of our software are you running? + description: What version of the Discord Game SDK Godot plugin are you running? options: + - 3.1 + - 3.0 - 2.4 - 2.3 - 2.2 @@ -41,8 +43,8 @@ body: id: gd-version attributes: label: Godot Version - description: This addon is ONLY for 4.0 and above! - placeholder: e.g. 4.0.2-stable + description: This addon is ONLY for 4.1 and above! + placeholder: e.g. 4.1.0-stable validations: required: true - type: textarea diff --git a/README.md b/README.md index 0b773d5..2f7b98c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - Invites - Steam and launch command registering - User information +- Relationship Manager (Get friendlist and its updates) - Overlay management - Editor Presence (optional) diff --git a/extended-user-info-api/.env.example b/extended-user-info-api/.env.example new file mode 100644 index 0000000..85898ec --- /dev/null +++ b/extended-user-info-api/.env.example @@ -0,0 +1 @@ +BOT_TOKEN="" \ No newline at end of file diff --git a/extended-user-info-api/.gitignore b/extended-user-info-api/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/extended-user-info-api/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/extended-user-info-api/go.mod b/extended-user-info-api/go.mod new file mode 100644 index 0000000..b46595e --- /dev/null +++ b/extended-user-info-api/go.mod @@ -0,0 +1,33 @@ +module discord-sdk-godot.vercel.app + +go 1.21.0 + +require github.com/gin-gonic/gin v1.9.1 + +require ( + github.com/bytedance/sonic v1.9.1 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect + github.com/joho/godotenv v1.5.1 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + golang.org/x/arch v0.3.0 // indirect + golang.org/x/crypto v0.9.0 // indirect + golang.org/x/net v0.10.0 // indirect + golang.org/x/sys v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/extended-user-info-api/go.sum b/extended-user-info-api/go.sum new file mode 100644 index 0000000..f2890d0 --- /dev/null +++ b/extended-user-info-api/go.sum @@ -0,0 +1,80 @@ +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= +github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= +github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= +golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/extended-user-info-api/main.go b/extended-user-info-api/main.go new file mode 100644 index 0000000..f427127 --- /dev/null +++ b/extended-user-info-api/main.go @@ -0,0 +1,137 @@ +package main + +import ( + "encoding/json" + "io" + "net/http" + "os" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" + "github.com/joho/godotenv" +) + +type User struct { + GlobalName string `json:"global_name"` + PublicFlags int `json:"public_flags"` + Flags int `json:"flags"` + AccentColor string `json:"accent_color"` + AvatarDecorationURL string `json:"avatar_decoration"` + BannerURL string `json:"banner_url"` + BannerColor string `json:"banner_color"` +} + +func main() { + r := gin.Default() + r.GET("/:userIDs", func(c *gin.Context) { + userIDs := strings.Split(c.Param("userIDs"), ",") + + if len(userIDs) == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "No user IDs provided"}) + return + } + + godotenv.Load() + botToken := os.Getenv("BOT_TOKEN") + client := &http.Client{} + + userResponses := make(map[string]User) + + for _, userID := range userIDs { + for { + req, err := http.NewRequest("GET", "https://discord.com/api/v10/users/"+userID, nil) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + req.Header.Add("Authorization", "Bot "+botToken) + req.Header.Add("Content-Type", "application/json") + + res, err := client.Do(req) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + defer res.Body.Close() + + if res.StatusCode == http.StatusTooManyRequests { + retryAfter := parseRetryAfterHeader(res.Header) + if retryAfter > 0 { + time.Sleep(retryAfter) + continue // Retry the request after waiting + } + } + + body, err := io.ReadAll(res.Body) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + + var jsonMap map[string]interface{} + if err := json.Unmarshal(body, &jsonMap); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + + user := User{ + GlobalName: getStringFromMap(jsonMap, "global_name"), + PublicFlags: getIntFromMap(jsonMap, "public_flags"), + Flags: getIntFromMap(jsonMap, "flags"), + AccentColor: getStringFromMap(jsonMap, "accent_color"), + BannerColor: getStringFromMap(jsonMap, "banner_color"), + } + + if avatarDecoration, ok := jsonMap["avatar_decoration"].(string); ok { + user.AvatarDecorationURL = "https://cdn.discordapp.com/avatar-decorations/" + userID + "/" + avatarDecoration + ".png" + } + + if banner, ok := jsonMap["banner"].(string); ok { + user.BannerURL = "https://cdn.discordapp.com/banners/" + userID + "/" + banner + ".png" + } + + userResponses[userID] = user + break // Exit the loop and process the next user ID + } + } + + c.JSON(http.StatusOK, userResponses) + }) + + r.GET("/", func(c *gin.Context) { + c.Writer.WriteHeader(http.StatusOK) + c.Writer.Write([]byte("Please provide a comma-separated list of Discord user IDs or a single user ID in the URL. Example: /688778053408784415,369216554950328320
GitHub project")) + }) + + r.Run(":8080") +} + +func parseRetryAfterHeader(headers http.Header) time.Duration { + retryAfterStr := headers.Get("Retry-After") + if retryAfterStr == "" { + return 0 + } + + retryAfter, err := strconv.Atoi(retryAfterStr) + if err != nil { + return 0 + } + + return time.Duration(retryAfter) * time.Millisecond +} + +func getStringFromMap(m map[string]interface{}, key string) string { + if val, ok := m[key].(string); ok { + return val + } + return "" +} + +func getIntFromMap(m map[string]interface{}, key string) int { + if val, ok := m[key].(float64); ok { + return int(val) + } + return 0 +} diff --git a/project/addons/discord-sdk-gd/Logo_V2_No_Bg.png b/project/addons/discord-sdk-gd/Logo_V2_No_Bg.png new file mode 100644 index 0000000..fb6c700 Binary files /dev/null and b/project/addons/discord-sdk-gd/Logo_V2_No_Bg.png differ diff --git a/project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png.import b/project/addons/discord-sdk-gd/Logo_V2_No_Bg.png.import similarity index 64% rename from project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png.import rename to project/addons/discord-sdk-gd/Logo_V2_No_Bg.png.import index 5bf804a..4d6ea22 100644 --- a/project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png.import +++ b/project/addons/discord-sdk-gd/Logo_V2_No_Bg.png.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://cq8lwj2matk6x" -path="res://.godot/imported/flow_spritesheet.png-4637bb4103771b4d4bbc78a0bb858512.ctex" +uid="uid://csl0e2px0cwc1" +path="res://.godot/imported/Logo_V2_No_Bg.png-9c8178062d6891c8370df63a912bd8e2.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png" -dest_files=["res://.godot/imported/flow_spritesheet.png-4637bb4103771b4d4bbc78a0bb858512.ctex"] +source_file="res://addons/discord-sdk-gd/Logo_V2_No_Bg.png" +dest_files=["res://.godot/imported/Logo_V2_No_Bg.png-9c8178062d6891c8370df63a912bd8e2.ctex"] [params] diff --git a/project/addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension b/project/addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension new file mode 100644 index 0000000..6343608 --- /dev/null +++ b/project/addons/discord-sdk-gd/bin/discord-rpc-gd.gdextension @@ -0,0 +1,30 @@ +[configuration] + +entry_symbol = "discordsdkgd_library_init" +compatibility_minimum = 4.1 + +[libraries] + +macos.debug = "macos/libdiscord_game_sdk_binding_debug.dylib" +macos.release = "macos/libdiscord_game_sdk_binding.dylib" +windows.debug.x86_64 = "windows/discord_game_sdk_binding_debug.dll" +windows.release.x86_64 = "windows/discord_game_sdk_binding.dll" +linux.debug.x86_64 = "linux/libdiscord_game_sdk_binding_debug.so" +linux.release.x86_64 = "linux/libdiscord_game_sdk_binding.so" +linux.debug.arm64 = "linux/libdiscord_game_sdk_binding_debug.so" +linux.release.arm64 = "linux/libdiscord_game_sdk_binding.so" +linux.debug.rv64 = "linux/libdiscord_game_sdk_binding_debug.so" +linux.release.rv64 = "linux/libdiscord_game_sdk_binding.so" + +[dependencies] + +macos.debug = { "macos/libdiscord_game_sdk.dylib": "" } +macos.release = { "macos/libdiscord_game_sdk.dylib": "" } +windows.debug.x86_64 = { "windows/discord_game_sdk.dll": "" } +windows.release.x86_64 = { "windows/discord_game_sdk.dll": "" } +linux.debug.x86_64 = { "linux/libdiscord_game_sdk.so": "" } +linux.release.x86_64 = { "linux/libdiscord_game_sdk.so": "" } +linux.debug.arm64 = { "linux/libdiscord_game_sdk.so": "" } +linux.release.arm64 = { "linux/libdiscord_game_sdk.so": "" } +linux.debug.rv64 = { "linux/libdiscord_game_sdk.so": "" } +linux.release.rv64 = { "linux/libdiscord_game_sdk.so": "" } diff --git a/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding.so b/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding.so index d157868..a623387 100755 Binary files a/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding.so and b/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding.so differ diff --git a/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding_debug.so b/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding_debug.so index 2173359..7689ebe 100755 Binary files a/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding_debug.so and b/project/addons/discord-sdk-gd/bin/linux/libdiscord_game_sdk_binding_debug.so differ diff --git a/project/addons/discord-sdk-gd/bin/version.txt b/project/addons/discord-sdk-gd/bin/version.txt deleted file mode 100644 index 676327c..0000000 --- a/project/addons/discord-sdk-gd/bin/version.txt +++ /dev/null @@ -1,4 +0,0 @@ -Version: 1.2 -Windows: build-1 -Linux: build-1 -MacOS: build-1 \ No newline at end of file diff --git a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll index 7f9c787..28db412 100644 Binary files a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll and b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding.dll differ diff --git a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll index 2d23261..1493a27 100644 Binary files a/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll and b/project/addons/discord-sdk-gd/bin/windows/discord_game_sdk_binding_debug.dll differ diff --git a/project/addons/discord-sdk-gd/discord-rpc-gd.gdextension b/project/addons/discord-sdk-gd/discord-rpc-gd.gdextension deleted file mode 100644 index ad454ef..0000000 --- a/project/addons/discord-sdk-gd/discord-rpc-gd.gdextension +++ /dev/null @@ -1,30 +0,0 @@ -[configuration] - -entry_symbol = "discordsdkgd_library_init" -compatibility_minimum = 4.1 - -[libraries] - -macos.debug = "bin/macos/libdiscord_game_sdk_binding_debug.dylib" -macos.release = "bin/macos/libdiscord_game_sdk_binding.dylib" -windows.debug.x86_64 = "bin/windows/discord_game_sdk_binding_debug.dll" -windows.release.x86_64 = "bin/windows/discord_game_sdk_binding.dll" -linux.debug.x86_64 = "bin/linux/libdiscord_game_sdk_binding_debug.so" -linux.release.x86_64 = "bin/linux/libdiscord_game_sdk_binding.so" -linux.debug.arm64 = "bin/linux/libdiscord_game_sdk_binding_debug.so" -linux.release.arm64 = "bin/linux/libdiscord_game_sdk_binding.so" -linux.debug.rv64 = "bin/linux/libdiscord_game_sdk_binding_debug.so" -linux.release.rv64 = "bin/linux/libdiscord_game_sdk_binding.so" - -[dependencies] - -macos.debug = { "bin/macos/libdiscord_game_sdk.dylib": "" } -macos.release = { "bin/macos/libdiscord_game_sdk.dylib": "" } -windows.debug.x86_64 = { "bin/windows/discord_game_sdk.dll": "" } -windows.release.x86_64 = { "bin/windows/discord_game_sdk.dll": "" } -linux.debug.x86_64 = { "bin/linux/libdiscord_game_sdk.so": "" } -linux.release.x86_64 = { "bin/linux/libdiscord_game_sdk.so": "" } -linux.debug.arm64 = { "bin/linux/libdiscord_game_sdk.so": "" } -linux.release.arm64 = { "bin/linux/libdiscord_game_sdk.so": "" } -linux.debug.rv64 = { "bin/linux/libdiscord_game_sdk.so": "" } -linux.release.rv64 = { "bin/linux/libdiscord_game_sdk.so": "" } diff --git a/project/addons/discord-sdk-gd/nodes/Debug.tscn b/project/addons/discord-sdk-gd/nodes/Debug.tscn index 8d5fabf..7b39f88 100644 --- a/project/addons/discord-sdk-gd/nodes/Debug.tscn +++ b/project/addons/discord-sdk-gd/nodes/Debug.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=68 format=3 uid="uid://c1slhdnlsv2qt"] +[gd_scene load_steps=9 format=3 uid="uid://c1slhdnlsv2qt"] -[ext_resource type="Texture2D" uid="uid://cq8lwj2matk6x" path="res://addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png" id="4_gvc3o"] +[ext_resource type="Texture2D" uid="uid://dnfq6kug4x6o2" path="res://addons/discord-sdk-gd/nodes/assets/Checked.svg" id="2_q6tao"] +[ext_resource type="Texture2D" uid="uid://compmm3kviqqe" path="res://addons/discord-sdk-gd/nodes/assets/Unchecked.svg" id="3_5cyem"] +[ext_resource type="Texture2D" uid="uid://dtc6ckladq0td" path="res://addons/discord-sdk-gd/nodes/assets/circle.svg" id="3_goflf"] [sub_resource type="GDScript" id="GDScript_ak1tp"] resource_name = "Debug" @@ -11,15 +13,16 @@ func _ready(): func _process(_delta): if(discord_sdk.get_is_discord_working()): - $AnimatedSprite2D.play(\"default\") + $Panel/TextureRect.self_modulate = Color(\"#3eff8d\") + $Panel/TextureRect/AnimationPlayer.play(\"pulsate\") debug_text_update() else: - $AnimatedSprite2D.stop() - $AnimatedSprite2D.animation = \"gray\" + $Panel/TextureRect.self_modulate = Color(\"#797979\") + $Panel/TextureRect/AnimationPlayer.stop() debug_text_update() func debug_text_update(): - $Info.text = \"Application ID : {id} + $Panel/Info.text = \"Application ID : {id} Details: {details} State: {state} @@ -41,7 +44,7 @@ Is party public: {ppublic} (needs to be activated in Discord client settings) Is instanced: {instanced} \" - $Info.text = $Info.text.replace(\"{ppublic}\",str(discord_sdk.is_public_party)).replace(\"{instanced}\",str(discord_sdk.instanced)).replace(\"{ssecret}\",discord_sdk.spectate_secret).replace(\"{jsecret}\",discord_sdk.join_secret).replace(\"{msecret}\",discord_sdk.match_secret).replace(\"{mpartysize}\",str(discord_sdk.max_party_size)).replace(\"{cpartysize}\",str(discord_sdk.current_party_size)).replace(\"{partyid}\",discord_sdk.party_id).replace(\"{id}\",str(discord_sdk.app_id)).replace(\"{details}\",discord_sdk.details).replace(\"{state}\",discord_sdk.state).replace(\"{lkey}\",discord_sdk.large_image).replace(\"{ltext}\",discord_sdk.large_image_text).replace(\"{skey}\",discord_sdk.small_image).replace(\"{stext}\",discord_sdk.small_image_text).replace(\"{stimestamp}\",str(discord_sdk.start_timestamp)).replace(\"{etimestamp}\",str(discord_sdk.end_timestamp)) + $Panel/Info.text = $Panel/Info.text.replace(\"{ppublic}\",str(discord_sdk.is_public_party)).replace(\"{instanced}\",str(discord_sdk.instanced)).replace(\"{ssecret}\",discord_sdk.spectate_secret).replace(\"{jsecret}\",discord_sdk.join_secret).replace(\"{msecret}\",discord_sdk.match_secret).replace(\"{mpartysize}\",str(discord_sdk.max_party_size)).replace(\"{cpartysize}\",str(discord_sdk.current_party_size)).replace(\"{partyid}\",discord_sdk.party_id).replace(\"{id}\",str(discord_sdk.app_id)).replace(\"{details}\",discord_sdk.details).replace(\"{state}\",discord_sdk.state).replace(\"{lkey}\",discord_sdk.large_image).replace(\"{ltext}\",discord_sdk.large_image_text).replace(\"{skey}\",discord_sdk.small_image).replace(\"{stext}\",discord_sdk.small_image_text).replace(\"{stimestamp}\",str(discord_sdk.start_timestamp)).replace(\"{etimestamp}\",str(discord_sdk.end_timestamp)) var user_request = {}; @@ -49,504 +52,87 @@ func _on_activity_join_request(user_requesting): print(user_requesting) user_request = user_requesting -func _on_button_pressed(): +func _on_accept_join_request_pressed(): if(!user_request.is_empty()): discord_sdk.accept_join_request(user_request.id) -func _on_line_edit_text_submitted(new_text): +func _on_invite_with_user_id_text_submitted(new_text): discord_sdk.send_invite(int(new_text),true,\"this is a test invite sent from godot\") -func _on_line_edit_2_text_submitted(new_text): +func _on_accept_with_user_id_text_submitted(new_text): discord_sdk.accept_invite(int(new_text)) -func _on_button_2_pressed(): +func _on_print_current_user_on_console_pressed(): print(discord_sdk.get_current_user()) -func _on_check_button_toggled(button_pressed): +func _on_toggle_sdk_toggled(button_pressed): if(button_pressed): - debug_text_update() + discord_sdk.unclear() else: discord_sdk.clear() - debug_text_update() +func _on_print_friends_pressed(): + print(discord_sdk.get_all_relationships()) " -[sub_resource type="AtlasTexture" id="AtlasTexture_85oj4"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 0, 512, 512) +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_8abo6"] -[sub_resource type="AtlasTexture" id="AtlasTexture_vv4mb"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 0, 512, 512) +[sub_resource type="Animation" id="Animation_mmtmn"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.4), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Vector2(0.5, 0.5)] +} -[sub_resource type="AtlasTexture" id="AtlasTexture_kwv3j"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 0, 512, 512) +[sub_resource type="Animation" id="Animation_5u02v"] +resource_name = "pulsate" +loop_mode = 1 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.5, 1), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector2(0.5, 0.5), Vector2(0.8, 0.8), Vector2(0.5, 0.5)] +} -[sub_resource type="AtlasTexture" id="AtlasTexture_ij57t"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 0, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_w2du1"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 512, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_4pma1"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 512, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_fcoqp"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 512, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_tjcb7"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 512, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_oudh8"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 512, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_csja0"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 1024, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_0xbpk"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 1024, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_p84pv"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 1024, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_1gjwh"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 1024, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_mrm73"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 1024, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_8rkne"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 1536, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_c15qo"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 1536, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_74tpk"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 1536, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_v5nxq"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 1536, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_0mf44"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 1536, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_kb0hn"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 2048, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_o22ug"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 2048, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_21q7w"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 2048, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gitfl"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 2048, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_8hg1o"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 2048, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_niuoc"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 2560, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_mt5ft"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 2560, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ub7uo"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 2560, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2uxnl"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 2560, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_bh4ts"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 2560, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_lcu0i"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 3072, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_mmqt1"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 3072, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_orode"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 3072, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_ricn8"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 3072, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_6ftll"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 3072, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_fm4jy"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 3584, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_7qcot"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 3584, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2y47g"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 3584, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gpr0t"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 3584, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_nn332"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 3584, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_jg384"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 4096, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_g0wvw"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 4096, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_e6fmf"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 4096, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_n1rtv"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 4096, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_365g3"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 4096, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_frkrx"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 4608, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_j8adw"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 4608, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_76fh7"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 4608, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_gmmrx"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 4608, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_rlh42"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 4608, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_wijf7"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 5120, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_2n5hs"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 5120, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_yrp6k"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 5120, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_w411h"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 5120, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_pe7po"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 5120, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_sr5kq"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 5632, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_kgesr"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 5632, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_vfk6x"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 5632, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_4d1t3"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 5632, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_6bexm"] -atlas = ExtResource("4_gvc3o") -region = Rect2(2048, 5632, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_tadlo"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 6144, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_g2h20"] -atlas = ExtResource("4_gvc3o") -region = Rect2(512, 6144, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_x351d"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1024, 6144, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_0jq3r"] -atlas = ExtResource("4_gvc3o") -region = Rect2(1536, 6144, 512, 512) - -[sub_resource type="AtlasTexture" id="AtlasTexture_1eeyl"] -atlas = ExtResource("4_gvc3o") -region = Rect2(0, 0, 512, 512) - -[sub_resource type="SpriteFrames" id="SpriteFrames_kudgl"] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_85oj4") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_vv4mb") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_kwv3j") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ij57t") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_w2du1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_4pma1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_fcoqp") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_tjcb7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_oudh8") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_csja0") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_0xbpk") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_p84pv") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_1gjwh") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_mrm73") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_8rkne") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_c15qo") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_74tpk") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_v5nxq") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_0mf44") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_kb0hn") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_o22ug") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_21q7w") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gitfl") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_8hg1o") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_niuoc") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_mt5ft") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ub7uo") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_2uxnl") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_bh4ts") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_lcu0i") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_mmqt1") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_orode") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_ricn8") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_6ftll") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_fm4jy") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_7qcot") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_2y47g") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gpr0t") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_nn332") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_jg384") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_g0wvw") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_e6fmf") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_n1rtv") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_365g3") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_frkrx") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_j8adw") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_76fh7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_gmmrx") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_rlh42") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_wijf7") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_2n5hs") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_yrp6k") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_w411h") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_pe7po") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_sr5kq") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_kgesr") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_vfk6x") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_4d1t3") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_6bexm") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_tadlo") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_g2h20") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_x351d") -}, { -"duration": 1.0, -"texture": SubResource("AtlasTexture_0jq3r") -}], -"loop": true, -"name": &"default", -"speed": 30.0 -}, { -"frames": [{ -"duration": 1.0, -"texture": SubResource("AtlasTexture_1eeyl") -}], -"loop": true, -"name": &"gray", -"speed": 5.0 -}] +[sub_resource type="AnimationLibrary" id="AnimationLibrary_a7ofc"] +_data = { +"RESET": SubResource("Animation_mmtmn"), +"pulsate": SubResource("Animation_5u02v") +} [node name="DebugNodeGroup" type="Node"] editor_description = "This is a Debug Node wich will show (only if the project runs) some usefull info and buttons/input" script = SubResource("GDScript_ak1tp") -[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -position = Vector2(389, 477.375) -scale = Vector2(0.14209, 0.14209) -sprite_frames = SubResource("SpriteFrames_kudgl") -frame_progress = 0.417812 +[node name="Panel" type="Panel" parent="."] +anchors_preset = -1 +anchor_right = 0.373 +anchor_bottom = 1.0 +offset_left = -5.0 +offset_right = 0.303955 +grow_horizontal = 2 +grow_vertical = 2 -[node name="Info" type="RichTextLabel" parent="."] -offset_left = 7.0 -offset_top = 6.0 -offset_right = 424.0 -offset_bottom = 312.0 +[node name="Info" type="RichTextLabel" parent="Panel"] +layout_mode = 0 +offset_left = 12.0 +offset_top = 21.0 +offset_right = 429.0 +offset_bottom = 461.0 theme_override_font_sizes/normal_font_size = 14 text = "Application ID : {id} Details: {details} @@ -572,52 +158,109 @@ Is instanced: {instanced} " fit_content = true -[node name="PrintCurrentUserOnConsole" type="Button" parent="."] +[node name="PrintCurrentUserOnConsole" type="Button" parent="Panel"] +layout_mode = 1 anchors_preset = 4 anchor_top = 0.5 anchor_bottom = 0.5 -offset_left = 7.0 -offset_top = 141.375 -offset_right = 240.0 -offset_bottom = 174.375 +offset_left = 12.0 +offset_top = 138.375 +offset_right = 245.0 +offset_bottom = 171.375 grow_vertical = 2 text = "Print current user on console" -[node name="AcceptInviteRequest" type="Button" parent="."] +[node name="PrintFriends" type="Button" parent="Panel"] +layout_mode = 1 anchors_preset = 4 anchor_top = 0.5 anchor_bottom = 0.5 -offset_left = 7.0 -offset_top = 178.875 -offset_right = 149.0 -offset_bottom = 209.875 +offset_left = 12.0 +offset_top = 176.5 +offset_right = 204.0 +offset_bottom = 207.5 +grow_vertical = 2 +text = "Print friends on console" + +[node name="AcceptJoinRequest" type="Button" parent="Panel"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 12.0 +offset_top = 212.875 +offset_right = 154.0 +offset_bottom = 243.875 grow_vertical = 2 text = "ACCEPT REQUEST" -[node name="InviteWithUserID" type="LineEdit" parent="."] +[node name="InviteWithUserID" type="LineEdit" parent="Panel"] +layout_mode = 1 anchors_preset = 4 anchor_top = 0.5 anchor_bottom = 0.5 -offset_left = 6.0 -offset_top = 215.375 -offset_right = 205.0 -offset_bottom = 246.375 +offset_left = 11.0 +offset_top = 250.375 +offset_right = 210.0 +offset_bottom = 281.375 grow_vertical = 2 size_flags_horizontal = 0 placeholder_text = "Invite with user_id here" -[node name="AcceptWithUserID" type="LineEdit" parent="."] +[node name="AcceptWithUserID" type="LineEdit" parent="Panel"] +layout_mode = 1 anchors_preset = 4 anchor_top = 0.5 anchor_bottom = 0.5 -offset_left = 6.0 -offset_top = 250.875 -offset_right = 255.0 -offset_bottom = 281.875 +offset_left = 11.0 +offset_top = 286.875 +offset_right = 260.0 +offset_bottom = 317.875 grow_vertical = 2 placeholder_text = "Accept Invite with user_id here" -[connection signal="pressed" from="PrintCurrentUserOnConsole" to="." method="_on_button_2_pressed"] -[connection signal="pressed" from="AcceptInviteRequest" to="." method="_on_button_pressed"] -[connection signal="text_submitted" from="InviteWithUserID" to="." method="_on_line_edit_text_submitted"] -[connection signal="text_submitted" from="AcceptWithUserID" to="." method="_on_line_edit_2_text_submitted"] +[node name="ToggleSDK" type="CheckButton" parent="Panel"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 298.0 +offset_top = 157.375 +offset_right = 1144.0 +offset_bottom = 665.375 +grow_vertical = 2 +scale = Vector2(0.05, 0.05) +theme_override_icons/checked = ExtResource("2_q6tao") +theme_override_icons/unchecked = ExtResource("3_5cyem") +theme_override_styles/focus = SubResource("StyleBoxEmpty_8abo6") +button_pressed = true + +[node name="TextureRect" type="TextureRect" parent="Panel"] +self_modulate = Color(0.47451, 0.47451, 0.47451, 1) +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.88 +anchor_top = 0.762 +anchor_right = 0.88 +anchor_bottom = 0.762 +offset_left = -28.8 +offset_top = -28.776 +offset_right = 28.0841 +offset_bottom = 28.1082 +grow_horizontal = 2 +grow_vertical = 2 +scale = Vector2(0.5, 0.5) +pivot_offset = Vector2(29.0693, 29.0693) +texture = ExtResource("3_goflf") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Panel/TextureRect"] +libraries = { +"": SubResource("AnimationLibrary_a7ofc") +} + +[connection signal="pressed" from="Panel/PrintCurrentUserOnConsole" to="." method="_on_print_current_user_on_console_pressed"] +[connection signal="pressed" from="Panel/PrintFriends" to="." method="_on_print_friends_pressed"] +[connection signal="pressed" from="Panel/AcceptJoinRequest" to="." method="_on_accept_join_request_pressed"] +[connection signal="text_submitted" from="Panel/InviteWithUserID" to="." method="_on_invite_with_user_id_text_submitted"] +[connection signal="text_submitted" from="Panel/AcceptWithUserID" to="." method="_on_accept_with_user_id_text_submitted"] +[connection signal="toggled" from="Panel/ToggleSDK" to="." method="_on_toggle_sdk_toggled"] diff --git a/project/addons/discord-sdk-gd/nodes/assets/Group_1.svg b/project/addons/discord-sdk-gd/nodes/assets/Group_1.svg deleted file mode 100644 index d01f59d..0000000 --- a/project/addons/discord-sdk-gd/nodes/assets/Group_1.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/project/addons/discord-sdk-gd/nodes/assets/circle.svg b/project/addons/discord-sdk-gd/nodes/assets/circle.svg new file mode 100644 index 0000000..acd3753 --- /dev/null +++ b/project/addons/discord-sdk-gd/nodes/assets/circle.svg @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/project/addons/discord-sdk-gd/nodes/assets/Group_1.svg.import b/project/addons/discord-sdk-gd/nodes/assets/circle.svg.import similarity index 70% rename from project/addons/discord-sdk-gd/nodes/assets/Group_1.svg.import rename to project/addons/discord-sdk-gd/nodes/assets/circle.svg.import index 69adaea..d7598a8 100644 --- a/project/addons/discord-sdk-gd/nodes/assets/Group_1.svg.import +++ b/project/addons/discord-sdk-gd/nodes/assets/circle.svg.import @@ -2,16 +2,16 @@ importer="texture" type="CompressedTexture2D" -uid="uid://c70jidlptani4" -path="res://.godot/imported/Group_1.svg-8cf36058739c5884a9a47a4dfa7d001a.ctex" +uid="uid://dtc6ckladq0td" +path="res://.godot/imported/circle.svg-ca71b895eb1c5e7e6f2f2afe081d28dd.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://addons/discord-sdk-gd/nodes/assets/Group_1.svg" -dest_files=["res://.godot/imported/Group_1.svg-8cf36058739c5884a9a47a4dfa7d001a.ctex"] +source_file="res://addons/discord-sdk-gd/nodes/assets/circle.svg" +dest_files=["res://.godot/imported/circle.svg-ca71b895eb1c5e7e6f2f2afe081d28dd.ctex"] [params] diff --git a/project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png b/project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png deleted file mode 100644 index ce00889..0000000 Binary files a/project/addons/discord-sdk-gd/nodes/assets/flow_spritesheet.png and /dev/null differ diff --git a/project/addons/discord-sdk-gd/nodes/core_updater.gd b/project/addons/discord-sdk-gd/nodes/core_updater.gd index 22a93d1..6ecca2d 100644 --- a/project/addons/discord-sdk-gd/nodes/core_updater.gd +++ b/project/addons/discord-sdk-gd/nodes/core_updater.gd @@ -5,8 +5,19 @@ ## You don't need to use it. ## ## @tutorial: https://github.com/vaporvee/discord-sdk-godot/wiki +@tool class_name core_updater extends Node -func _process(delta) -> void: - discord_sdk.coreupdate() +func _process(_delta): + if(ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled") && Engine.is_editor_hint()): + if(discord_sdk.app_id != 1108142249990176808): + discord_sdk.app_id = 1108142249990176808 + discord_sdk.details = ProjectSettings.get_setting("application/config/name") + discord_sdk.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\"" + discord_sdk.large_image = "godot" + discord_sdk.large_image_text = str(Engine.get_version_info().string) + discord_sdk.start_timestamp = int(Time.get_unix_time_from_system()) + discord_sdk.refresh() + if(discord_sdk.app_id == 1108142249990176808 || !Engine.is_editor_hint()): + discord_sdk.coreupdate() diff --git a/project/addons/discord-sdk-gd/nodes/debug.gd b/project/addons/discord-sdk-gd/nodes/debug.gd index 4b323a7..a4e8ee0 100644 --- a/project/addons/discord-sdk-gd/nodes/debug.gd +++ b/project/addons/discord-sdk-gd/nodes/debug.gd @@ -3,6 +3,7 @@ ## The DiscordSDK Debug Node will show info about the current values of its variables and some buttons to change them. ## ## @tutorial: https://github.com/vaporvee/discord-sdk-godot/wiki +@tool extends Node func _ready() -> void: diff --git a/project/addons/discord-sdk-gd/plugin.cfg b/project/addons/discord-sdk-gd/plugin.cfg index a7b06ab..174bf53 100644 --- a/project/addons/discord-sdk-gd/plugin.cfg +++ b/project/addons/discord-sdk-gd/plugin.cfg @@ -3,5 +3,5 @@ name="DiscordSDK" description="Discord Game SDK support for GDScript in Godot" author="vaporvee" -version="2.4" +version="3.1" script="plugin.gd" diff --git a/project/addons/discord-sdk-gd/plugin.gd b/project/addons/discord-sdk-gd/plugin.gd index fb8b99e..3acc7db 100644 --- a/project/addons/discord-sdk-gd/plugin.gd +++ b/project/addons/discord-sdk-gd/plugin.gd @@ -4,33 +4,36 @@ extends EditorPlugin const DiscordSDKDebug = preload("res://addons/discord-sdk-gd/nodes/debug.gd") const DiscordSDKDebug_icon = preload("res://addons/discord-sdk-gd/nodes/assets/Debug.svg") var loaded_DiscordSDKDebug = DiscordSDKDebug.new() +var restart_window: Control = preload("res://addons/discord-sdk-gd/restart_window.tscn").instantiate() func _enter_tree() -> void: add_custom_type("DiscordSDKDebug","Node",DiscordSDKDebug,DiscordSDKDebug_icon) add_autoload_singleton("DiscordSDKLoader", "res://addons/discord-sdk-gd/nodes/core_updater.gd") - -func _enable_plugin() -> void: - print("DiscordSDK Addon got enabled (PLEASE RESTART THE EDITOR)") ProjectSettings.set_setting("DiscordSDK/EditorPresence/enabled",false) + ProjectSettings.set_as_basic("DiscordSDK/EditorPresence/enabled",true) ProjectSettings.set_initial_value("DiscordSDK/EditorPresence/enabled",false) ProjectSettings.set_restart_if_changed("DiscordSDK/EditorPresence/enabled",true) +func _enable_plugin() -> void: + if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore"): + DirAccess.remove_absolute(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/bin/.gdignore") + if FileAccess.file_exists(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/nodes/.gdignore"): + DirAccess.remove_absolute(ProjectSettings.globalize_path("res://") + "addons/discord-sdk-gd/nodes/.gdignore") + add_control_to_container(EditorPlugin.CONTAINER_TOOLBAR,restart_window) + restart_window.get_child(0).connect("canceled",save_restart) + restart_window.get_child(0).connect("confirmed",restart) + func _disable_plugin() -> void: - print("DiscordSDK Addon got disabled") + FileAccess.open("res://addons/discord-sdk-gd/bin/.gdignore",FileAccess.WRITE) + FileAccess.open("res://addons/discord-sdk-gd/nodes/.gdignore",FileAccess.WRITE) + push_warning("DiscordSDK Addon got disabled. PLEASE RESTART THE EDITOR!") remove_autoload_singleton("DiscordSDKLoader") remove_custom_type("DiscordSDKDebug") ProjectSettings.clear("DiscordSDK/EditorPresence/enabled") -func _process(_delta): - if(ProjectSettings.get_setting("DiscordSDK/EditorPresence/enabled")&&!get_editor_interface().is_playing_scene()): - if(discord_sdk.app_id != 1108142249990176808): - discord_sdk.app_id = 1108142249990176808 - discord_sdk.details = ProjectSettings.get_setting("application/config/name") - discord_sdk.state = "Editing: \""+ str(get_tree().edited_scene_root.scene_file_path).replace("res://","") +"\"" - discord_sdk.large_image = "godot" - discord_sdk.large_image_text = str(Engine.get_version_info().string) - discord_sdk.start_timestamp = int(Time.get_unix_time_from_system()) - discord_sdk.refresh() - if(discord_sdk.app_id == 1108142249990176808): - discord_sdk.coreupdate() +func save_restart() -> void: + get_editor_interface().restart_editor(true) + +func restart() -> void: + get_editor_interface().restart_editor(false) diff --git a/project/addons/discord-sdk-gd/restart_window.tscn b/project/addons/discord-sdk-gd/restart_window.tscn new file mode 100644 index 0000000..fa51a4d --- /dev/null +++ b/project/addons/discord-sdk-gd/restart_window.tscn @@ -0,0 +1,115 @@ +[gd_scene load_steps=8 format=3 uid="uid://byc4c6d5tpomq"] + +[ext_resource type="Texture2D" uid="uid://csl0e2px0cwc1" path="res://addons/discord-sdk-gd/Logo_V2_No_Bg.png" id="1_f828l"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_1t7mm"] + +[sub_resource type="Theme" id="Theme_swwco"] +Button/styles/focus = SubResource("StyleBoxEmpty_1t7mm") + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5vqdt"] + +[sub_resource type="Image" id="Image_inmd8"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 168, 224, 224, 224, 233, 224, 224, 224, 236, 224, 224, 224, 170, 231, 231, 231, 31, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 234, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 239, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 168, 224, 224, 224, 255, 224, 224, 224, 186, 224, 224, 224, 32, 224, 224, 224, 33, 224, 224, 224, 187, 224, 224, 224, 255, 225, 225, 225, 167, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 227, 227, 227, 36, 224, 224, 224, 255, 224, 224, 224, 234, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 237, 224, 224, 224, 255, 224, 224, 224, 33, 255, 255, 255, 0, 255, 255, 255, 0, 229, 229, 229, 38, 224, 224, 224, 255, 224, 224, 224, 229, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 164, 224, 224, 224, 255, 224, 224, 224, 187, 225, 225, 225, 34, 227, 227, 227, 36, 224, 224, 224, 192, 224, 224, 224, 255, 224, 224, 224, 162, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 225, 225, 225, 215, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 229, 224, 224, 224, 32, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 24, 224, 224, 224, 216, 224, 224, 224, 255, 224, 224, 224, 210, 224, 224, 224, 161, 224, 224, 224, 232, 224, 224, 224, 231, 225, 225, 225, 159, 230, 230, 230, 30, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 107, 224, 224, 224, 255, 224, 224, 224, 210, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 105, 230, 230, 230, 20, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 224, 224, 224, 130, 255, 255, 255, 1, 255, 255, 255, 1, 225, 225, 225, 134, 224, 224, 224, 224, 225, 225, 225, 223, 224, 224, 224, 132, 255, 255, 255, 1, 255, 255, 255, 6, 224, 224, 224, 137, 224, 224, 224, 231, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 130, 225, 225, 225, 133, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 129, 224, 224, 224, 137, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 220, 225, 225, 225, 223, 224, 224, 224, 255, 226, 226, 226, 61, 224, 224, 224, 65, 224, 224, 224, 255, 224, 224, 224, 222, 224, 224, 224, 231, 224, 224, 224, 255, 227, 227, 227, 62, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 222, 224, 224, 224, 255, 227, 227, 227, 63, 225, 225, 225, 67, 224, 224, 224, 255, 224, 224, 224, 219, 224, 224, 224, 230, 224, 224, 224, 255, 227, 227, 227, 63, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 127, 224, 224, 224, 129, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 126, 225, 225, 225, 135, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 221, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 1, 224, 224, 224, 128, 224, 224, 224, 220, 224, 224, 224, 219, 225, 225, 225, 127, 255, 255, 255, 0, 255, 255, 255, 5, 225, 225, 225, 134, 224, 224, 224, 229, 224, 224, 224, 255, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_gdtpn"] +image = SubResource("Image_inmd8") + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_7v0rg"] + +[node name="RestartWindow" type="Control"] +layout_mode = 3 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -200.0 +offset_top = -171.5 +offset_right = 200.0 +offset_bottom = 171.5 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="ConfirmationDialog" type="ConfirmationDialog" parent="."] +title = "Restart required" +initial_position = 2 +size = Vector2i(416, 400) +visible = true +transient = false +unresizable = true +theme = SubResource("Theme_swwco") +ok_button_text = "Restart" +cancel_button_text = "Save and restart" + +[node name="Panel" type="Panel" parent="ConfirmationDialog"] +offset_left = 8.0 +offset_top = 8.0 +offset_right = 408.0 +offset_bottom = 351.0 +mouse_filter = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="ConfirmationDialog/Panel"] +custom_minimum_size = Vector2(400, 0) +layout_mode = 0 +offset_right = 400.0 +offset_bottom = 309.0 + +[node name="HSeparator" type="HSeparator" parent="ConfirmationDialog/Panel/VBoxContainer"] +layout_mode = 2 +mouse_filter = 1 +theme_override_constants/separation = 15 +theme_override_styles/separator = SubResource("StyleBoxEmpty_5vqdt") + +[node name="HBoxContainer" type="HBoxContainer" parent="ConfirmationDialog/Panel/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="DocsIcon" type="TextureRect" parent="ConfirmationDialog/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 8 +size_flags_vertical = 4 +texture = SubResource("ImageTexture_gdtpn") +stretch_mode = 2 + +[node name="LinkButton" type="LinkButton" parent="ConfirmationDialog/Panel/VBoxContainer/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +mouse_default_cursor_shape = 16 +text = "Plugin Docs" +uri = "https://github.com/vaporvee/discord-sdk-godot/wiki" + +[node name="TextureRect" type="TextureRect" parent="ConfirmationDialog/Panel/VBoxContainer"] +custom_minimum_size = Vector2(128, 128) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 0 +texture = ExtResource("1_f828l") +expand_mode = 1 + +[node name="RichTextLabel" type="RichTextLabel" parent="ConfirmationDialog/Panel/VBoxContainer"] +custom_minimum_size = Vector2(400, 200) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 0 +mouse_filter = 1 +theme_override_styles/normal = SubResource("StyleBoxEmpty_7v0rg") +bbcode_enabled = true +text = "[center]Thanks for enabling the +[rainbow]Discord Game SDK Plugin[/rainbow] +made by vaporvee. ❤️ + + +You need to [wave]restart[/wave] the editor to fully enable this plugin! +Do you want to [wave]save[/wave] your project before restarting? +(Error messages after the first restart are normal. Please ignore them)" diff --git a/project/assets/Logo_V2_No_Bg_Small.png.import b/project/assets/Logo_V2_No_Bg_Small.png.import new file mode 100644 index 0000000..10f42c5 --- /dev/null +++ b/project/assets/Logo_V2_No_Bg_Small.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bjns3n0prshdy" +path="res://.godot/imported/Logo_V2_No_Bg_Small.png-6c9c0ba88b8e0a9cb7aa1acb948a1191.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Logo_V2_No_Bg_Small.png" +dest_files=["res://.godot/imported/Logo_V2_No_Bg_Small.png-6c9c0ba88b8e0a9cb7aa1acb948a1191.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/project/export_presets.cfg b/project/export_presets.cfg index 983ae28..ccf6593 100644 --- a/project/export_presets.cfg +++ b/project/export_presets.cfg @@ -8,18 +8,17 @@ custom_features="" export_filter="all_resources" include_filter="" exclude_filter="" -export_path="../../exportestt/discord_sdk_demo.exe" +export_path="../../testexpoort/discord_sdk_demo.exe" encryption_include_filters="" encryption_exclude_filters="" encrypt_pck=false encrypt_directory=false -script_encryption_key="" [preset.0.options] custom_template/debug="" custom_template/release="" -debug/export_console_script=1 +debug/export_console_wrapper=1 binary_format/embed_pck=true texture_format/bptc=true texture_format/s3tc=true @@ -27,9 +26,6 @@ texture_format/etc=false texture_format/etc2=false binary_format/architecture="x86_64" codesign/enable=false -codesign/identity_type=0 -codesign/identity="" -codesign/password="" codesign/timestamp=true codesign/timestamp_server_url="" codesign/digest_algorithm=1 diff --git a/project/main.gd b/project/main.gd index 8354aa4..ca2fc32 100644 --- a/project/main.gd +++ b/project/main.gd @@ -5,6 +5,8 @@ func _ready() -> void: discord_sdk.connect("activity_join_request",_on_activity_join_request) discord_sdk.connect("activity_join",_on_activity_join) discord_sdk.connect("activity_spectate",_on_activity_spectate) + discord_sdk.connect("relationships_init",_on_relationship_init) + discord_sdk.connect("updated_relationship", _on_updated_relationship) func set_activity() -> void: discord_sdk.clear() @@ -18,8 +20,8 @@ func set_activity() -> void: discord_sdk.small_image_text = "Fighting the end boss! D:" discord_sdk.end_timestamp = int(Time.get_unix_time_from_system()) + 3600 # +1 hour in unix time - # It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server - # understands and returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others. + # It is NOT recommended to manage secrets locally! It's meant to be a payload wich the server understands and + # returns the other variables like current_party_size, party_id etc. Most of the values must differ from the others. var my_secret: String = str(randi_range(0,999999)) discord_sdk.party_id = "mylobbycanbeeverything_" + my_secret @@ -52,9 +54,10 @@ func _on_activity_join(secret) -> void: func _on_activity_spectate(secret) -> void: print(secret) - -func _on_toggle_sdk_toggled(button_pressed): - if(button_pressed): - set_activity() - else: - discord_sdk.clear() + +func _on_relationship_init(): + print("initialized") + +func _on_updated_relationship(relationship): + print(relationship) + diff --git a/project/main.tscn b/project/main.tscn index 5d6c8ba..662b902 100644 --- a/project/main.tscn +++ b/project/main.tscn @@ -1,13 +1,9 @@ -[gd_scene load_steps=7 format=3 uid="uid://dyc3kseph4el7"] +[gd_scene load_steps=4 format=3 uid="uid://dyc3kseph4el7"] [ext_resource type="Script" path="res://main.gd" id="1_kl8ri"] [ext_resource type="Texture2D" uid="uid://b3qm246m7pnsx" path="res://assets/Logo_V2.png" id="2_gd222"] -[ext_resource type="Texture2D" uid="uid://dnfq6kug4x6o2" path="res://addons/discord-sdk-gd/nodes/assets/Checked.svg" id="3_wajuo"] -[ext_resource type="Texture2D" uid="uid://compmm3kviqqe" path="res://addons/discord-sdk-gd/nodes/assets/Unchecked.svg" id="4_8hvtu"] [ext_resource type="Script" path="res://addons/discord-sdk-gd/nodes/debug.gd" id="6_ujijw"] -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_phc3u"] - [node name="Node" type="Node"] script = ExtResource("1_kl8ri") @@ -23,7 +19,7 @@ color = Color(0.345098, 0.396078, 0.94902, 1) [node name="Sprite2D" type="Sprite2D" parent="."] texture_filter = 4 -position = Vector2(580, 308) +position = Vector2(789, 330.5) scale = Vector2(0.408203, 0.408203) texture = ExtResource("2_gd222") @@ -33,10 +29,10 @@ anchor_left = 0.293 anchor_top = 0.59 anchor_right = 0.736 anchor_bottom = 0.727 -offset_left = -0.536011 -offset_top = -0.319977 -offset_right = 0.12793 -offset_bottom = -0.0960388 +offset_left = 208.464 +offset_top = 22.18 +offset_right = 209.128 +offset_bottom = 22.4039 grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 4 @@ -46,20 +42,3 @@ text = "[center][font s=60]DiscordSDK Test" [node name="DiscordSDKDebug" type="Node" parent="."] script = ExtResource("6_ujijw") - -[node name="ToggleSDK" type="CheckButton" parent="."] -anchors_preset = 4 -anchor_top = 0.5 -anchor_bottom = 0.5 -offset_left = 293.0 -offset_top = 142.375 -offset_right = 1139.0 -offset_bottom = 650.375 -grow_vertical = 2 -scale = Vector2(0.05, 0.05) -theme_override_icons/checked = ExtResource("3_wajuo") -theme_override_icons/unchecked = ExtResource("4_8hvtu") -theme_override_styles/focus = SubResource("StyleBoxEmpty_phc3u") -button_pressed = true - -[connection signal="toggled" from="ToggleSDK" to="." method="_on_toggle_sdk_toggled"] diff --git a/project/project.godot b/project/project.godot index 5916d7b..259e006 100644 --- a/project/project.godot +++ b/project/project.godot @@ -11,6 +11,7 @@ config_version=5 [application] config/name="GDExtension DiscordSDK Test Project" +config/tags=PackedStringArray("vaporvee") run/main_scene="res://main.tscn" config/features=PackedStringArray("4.1") boot_splash/bg_color=Color(0.25098, 0.305882, 0.929412, 1) diff --git a/release.py b/release.py index db0f790..354f3a0 100644 --- a/release.py +++ b/release.py @@ -6,6 +6,12 @@ if os.path.exists("release/ADDON-Discord-SDK-Godot/addons"): shutil.rmtree("release/ADDON-Discord-SDK-Godot/addons", ignore_errors=True) copy_tree("project/addons/", "release/temp/ADDON-Discord-SDK-Godot/addons") +open( + "release/temp/ADDON-Discord-SDK-Godot/addons/discord-sdk-gd/bin/.gdignore", "a" +).close() +open( + "release/temp/ADDON-Discord-SDK-Godot/addons/discord-sdk-gd/nodes/.gdignore", "a" +).close() shutil.make_archive("release/ADDON-Discord-SDK-Godot", "zip", "release/temp/") diff --git a/src/discordgodot.cpp b/src/discordgodot.cpp index ee52c92..c826456 100644 --- a/src/discordgodot.cpp +++ b/src/discordgodot.cpp @@ -83,8 +83,12 @@ void discord_sdk::_bind_methods() ADD_SIGNAL(MethodInfo("activity_spectate", PropertyInfo(Variant::STRING, "spectate_secret"))); ADD_SIGNAL(MethodInfo("activity_join_request", PropertyInfo(Variant::DICTIONARY, "user_requesting"))); + ADD_SIGNAL(MethodInfo("relationships_init")); + ADD_SIGNAL(MethodInfo("updated_relationship", PropertyInfo(Variant::DICTIONARY, "relationship"))); + ClassDB::bind_method(D_METHOD("refresh"), &discord_sdk::refresh); - ClassDB::bind_method(D_METHOD("clear"), &discord_sdk::clear); + ClassDB::bind_method(D_METHOD("clear", "reset_values"), &discord_sdk::clear, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("unclear"), &discord_sdk::unclear); ClassDB::bind_method(D_METHOD("register_command", "command"), &discord_sdk::register_command); ClassDB::bind_method(D_METHOD("register_steam", "steam_id"), &discord_sdk::register_steam); @@ -94,6 +98,7 @@ void discord_sdk::_bind_methods() ClassDB::bind_method(D_METHOD("accept_invite", "user_id"), &discord_sdk::accept_invite); ClassDB::bind_method(D_METHOD("get_current_user"), &discord_sdk::get_current_user); + ClassDB::bind_method(D_METHOD("get_all_relationships"), &discord_sdk::get_all_relationships); ClassDB::bind_method(D_METHOD("get_is_overlay_enabled"), &discord_sdk::get_is_overlay_enabled); ClassDB::bind_method(D_METHOD("get_is_overlay_locked"), &discord_sdk::get_is_overlay_locked); @@ -154,44 +159,44 @@ void discord_sdk::debug() void discord_sdk::set_app_id(int64_t value) { app_id = value; - result = discord::Core::Create(value, DiscordCreateFlags_NoRequireDiscord, &core); // after setting app_ID it initializes everything - - if (result == discord::Result::Ok && app_id > 0) + if (app_id > 0) { - // initialize currentuser stuff - core->UserManager().OnCurrentUserUpdate.Connect([]() - {discord::User user{}; - core->UserManager().GetCurrentUser(&user); }); - // signals - core->ActivityManager().OnActivityJoin.Connect([](const char *secret) - { discord_sdk::get_singleton() - ->emit_signal("activity_join", secret); }); - core->ActivityManager().OnActivitySpectate.Connect([](const char *secret) - { discord_sdk::get_singleton() - ->emit_signal("activity_spectate", secret); }); - core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user) - { Dictionary user_requesting; - user_requesting["avatar"] = user.GetAvatar(); //can be empty when user has no avatar - user_requesting["is_bot"] = user.GetBot(); - user_requesting["discriminator"] = user.GetDiscriminator(); - user_requesting["id"] = user.GetId(); - user_requesting["username"] = user.GetUsername(); - if(String(user_requesting["avatar"]).is_empty()) - user_requesting["avatar_url"] = String(std::string("https://cdn.discordapp.com/embed/avatars/" + std::to_string((user_requesting["discriminator"].INT % 5) - 1)+ ".png").c_str()); - else - user_requesting["avatar_url"] = String(std::string("https://cdn.discordapp.com/avatars/" + std::to_string(user.GetId()) + "/" + user.GetAvatar() + ".png?size=512").c_str());//I don't know what the hell i did there but removing ?size=512 will crash the whole editor - user_requesting.make_read_only(); - discord_sdk::get_singleton() - ->emit_signal("activity_join_request",user_requesting); }); + result = discord::Core::Create(value, DiscordCreateFlags_NoRequireDiscord, &core); // after setting app_ID it initializes everything - core->OverlayManager().OnToggle.Connect([](bool is_locked) - { discord_sdk::get_singleton() - ->emit_signal("overlay_toggle", is_locked); }); + if (result == discord::Result::Ok) + { + // initialize currentuser stuff + core->UserManager().OnCurrentUserUpdate.Connect([]() + {discord::User user{}; + core->UserManager().GetCurrentUser(&user); }); + // signals + core->ActivityManager().OnActivityJoin.Connect([](const char *secret) + { discord_sdk::get_singleton() + ->emit_signal("activity_join", secret); }); + core->ActivityManager().OnActivitySpectate.Connect([](const char *secret) + { discord_sdk::get_singleton() + ->emit_signal("activity_spectate", secret); }); + core->ActivityManager().OnActivityJoinRequest.Connect([this](discord::User const &user) + { discord_sdk::get_singleton() + ->emit_signal("activity_join_request", user2dict(user)); }); + + core->OverlayManager().OnToggle.Connect([](bool is_locked) + { discord_sdk::get_singleton() + ->emit_signal("overlay_toggle", is_locked); }); + core->RelationshipManager().OnRefresh.Connect([&]() + { discord_sdk::get_singleton() + ->emit_signal("relationships_init"); }); + core->RelationshipManager().OnRelationshipUpdate.Connect([&](discord::Relationship const &relationship) + { discord_sdk::get_singleton() + ->emit_signal("updated_relationship", relationship2dict(relationship)); }); + } } } int64_t discord_sdk::get_app_id() { - return app_id; + if (app_id != 0) + return app_id; + return old_app_id; } void discord_sdk::set_state(String value) @@ -225,34 +230,52 @@ void discord_sdk::refresh() UtilityFunctions::push_warning("Discord Activity couldn't be updated. It could be that Discord isn't running!"); } -void discord_sdk::clear() +void discord_sdk::clear(bool reset_values = false) { if (result == discord::Result::Ok) { - app_id = 0; - state = ""; - details = ""; - large_image = ""; - large_image_text = ""; - small_image = ""; - small_image_text = ""; - start_timestamp = 0; - end_timestamp = 0; - party_id = ""; - current_party_size = 0; - max_party_size = 0; - match_secret = ""; - join_secret = ""; - spectate_secret = ""; - instanced = false; - is_public_party = false; - is_overlay_locked = false; - + if (reset_values) + { + old_app_id = 0; + set_state(""); + set_details(""); + set_large_image(""); + set_large_image_text(""); + set_small_image(""); + set_small_image_text(""); + set_start_timestamp(0); + set_end_timestamp(0); + set_party_id(""); + set_current_party_size(0); + set_max_party_size(0); + set_match_secret(""); + set_join_secret(""); + set_spectate_secret(""); + set_instanced(false); + set_is_public_party(false); + set_is_overlay_locked(false); + core->ActivityManager().ClearActivity([](discord::Result result) {}); + } + else + old_app_id = app_id; + set_app_id(0); delete core; core = nullptr; } } +void discord_sdk::unclear() +{ + if (old_app_id > 0) + { + set_app_id(old_app_id); + refresh(); + old_app_id = 0; + } + else + UtilityFunctions::push_warning("Discord Activity couldn't be uncleared. Maybe it didn't get cleared before?"); +} + void discord_sdk::set_large_image(String value) { large_image = value; @@ -455,20 +478,40 @@ Dictionary discord_sdk::get_current_user() { discord::User user{}; core->UserManager().GetCurrentUser(&user); - userdict["avatar"] = user.GetAvatar(); // can be empty when user has no avatar - userdict["is_bot"] = user.GetBot(); - userdict["discriminator"] = user.GetDiscriminator(); - userdict["id"] = user.GetId(); - userdict["username"] = user.GetUsername(); - if (String(userdict["avatar"]).is_empty()) - userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/embed/avatars/" + std::to_string((userdict["discriminator"].INT % 5) - 1) + ".png").c_str()); - else - userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/avatars/" + std::to_string(user.GetId()) + "/" + user.GetAvatar() + ".png?size=512").c_str()); - userdict.make_read_only(); + return user2dict(user); } return userdict; } +Dictionary discord_sdk::get_relationship(int64_t user_id) +{ + if (result == discord::Result::Ok && app_id > 0) + { + discord::Relationship relationship{}; + core->RelationshipManager().Get(user_id, &relationship); + return relationship2dict(relationship); + } + Dictionary dict; + return dict; +} + +Array discord_sdk::get_all_relationships() +{ + Array all_relationships; + core->RelationshipManager().Filter( + [](discord::Relationship const &relationship) -> bool + { return true; }); + int32_t friendcount{0}; + core->RelationshipManager().Count(&friendcount); + for (int i = 0; i < friendcount; i++) + { + discord::Relationship relationship{}; + core->RelationshipManager().GetAt(i, &relationship); + all_relationships.append(relationship2dict(relationship)); + } + return all_relationships; +} + bool discord_sdk::get_is_discord_working() { return result == discord::Result::Ok && app_id > 0; @@ -478,3 +521,91 @@ int discord_sdk::get_result_int() { return static_cast(result); } + +Dictionary discord_sdk::user2dict(discord::User user) +{ + Dictionary userdict; + userdict["avatar"] = user.GetAvatar(); // can be empty when user has no avatar + userdict["is_bot"] = user.GetBot(); + userdict["discriminator"] = user.GetDiscriminator(); + userdict["id"] = user.GetId(); + userdict["username"] = user.GetUsername(); + if (String(userdict["avatar"]).is_empty()) + userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/embed/avatars/" + std::to_string((userdict["discriminator"].INT % 5) - 1) + ".png").c_str()); + else + userdict["avatar_url"] = String(std::string("https://cdn.discordapp.com/avatars/" + std::to_string(user.GetId()) + "/" + user.GetAvatar() + ".png").c_str()); + userdict.make_read_only(); + return userdict; +} + +Dictionary discord_sdk::relationship2dict(discord::Relationship relationship) +{ + Dictionary dict_relationship; + Dictionary presence; + Dictionary presence_activity; + switch (static_cast(relationship.GetPresence().GetStatus())) + { + case 0: + presence["status"] = "Offline"; + break; + case 1: + presence["status"] = "Online"; + break; + case 2: + presence["status"] = "Idle"; + break; + case 3: + presence["status"] = "DoNotDisturb"; + break; + default: + presence["status"] = "NotAvailable"; + break; + } + presence_activity["application_id"] = relationship.GetPresence().GetActivity().GetApplicationId(); + presence_activity["name"] = relationship.GetPresence().GetActivity().GetName(); + presence_activity["state"] = relationship.GetPresence().GetActivity().GetState(); + presence_activity["details"] = relationship.GetPresence().GetActivity().GetDetails(); + presence_activity["large_image"] = relationship.GetPresence().GetActivity().GetAssets().GetLargeImage(); + presence_activity["large_text"] = relationship.GetPresence().GetActivity().GetAssets().GetLargeText(); + presence_activity["small_image"] = relationship.GetPresence().GetActivity().GetAssets().GetSmallImage(); + presence_activity["small_text"] = relationship.GetPresence().GetActivity().GetAssets().GetSmallText(); + presence_activity["timestamps_start"] = relationship.GetPresence().GetActivity().GetTimestamps().GetStart(); + presence_activity["timestamps_end"] = relationship.GetPresence().GetActivity().GetTimestamps().GetEnd(); + presence_activity["instance"] = relationship.GetPresence().GetActivity().GetInstance(); + presence_activity["party_id"] = relationship.GetPresence().GetActivity().GetParty().GetId(); + presence_activity["current_party_size"] = relationship.GetPresence().GetActivity().GetParty().GetSize().GetCurrentSize(); + presence_activity["max_party_size"] = relationship.GetPresence().GetActivity().GetParty().GetSize().GetMaxSize(); + presence_activity["join_secret"] = relationship.GetPresence().GetActivity().GetSecrets().GetJoin(); + presence_activity["spectate_secret"] = relationship.GetPresence().GetActivity().GetSecrets().GetSpectate(); + presence_activity["match_secret"] = relationship.GetPresence().GetActivity().GetSecrets().GetMatch(); + presence["activity"] = presence_activity; + presence.make_read_only(); + switch (relationship.GetType()) + { + case discord::RelationshipType::None: + dict_relationship["type"] = "None"; + break; + case discord::RelationshipType::Friend: + dict_relationship["type"] = "Friend"; + break; + case discord::RelationshipType::Blocked: + dict_relationship["type"] = "Blocked"; + break; + case discord::RelationshipType::PendingIncoming: + dict_relationship["type"] = "PendingIncoming"; + break; + case discord::RelationshipType::PendingOutgoing: + dict_relationship["type"] = "PendingOutgoing"; + break; + case discord::RelationshipType::Implicit: + dict_relationship["type"] = "Implicit"; + break; + default: + dict_relationship["type"] = "NotAvailable"; + break; + } + dict_relationship["user"] = user2dict(relationship.GetUser()); + dict_relationship["presence"] = presence; + dict_relationship.make_read_only(); + return dict_relationship; +} \ No newline at end of file diff --git a/src/discordgodot.h b/src/discordgodot.h index 1e08a39..d531790 100644 --- a/src/discordgodot.h +++ b/src/discordgodot.h @@ -17,7 +17,19 @@ class discord_sdk : public RefCounted protected: static void _bind_methods(); -private: +public: + static discord_sdk * + get_singleton(); + + discord_sdk(); + ~discord_sdk(); + + // INTERBNAL + int64_t old_app_id; + Dictionary relationship2dict(discord::Relationship relationship); + Dictionary user2dict(discord::User user); + /// + int64_t app_id = 0; String state; @@ -44,18 +56,12 @@ private: bool is_overlay_locked; -public: - static discord_sdk * - get_singleton(); - - discord_sdk(); - ~discord_sdk(); - void debug(); void coreupdate(); void refresh(); - void clear(); + void clear(bool reset_values); + void unclear(); int64_t get_app_id(); void set_app_id(int64_t value); String get_state(); @@ -112,6 +118,8 @@ public: void register_steam(int32_t value); Dictionary get_current_user(); + Dictionary get_relationship(int64_t user_id); + Array get_all_relationships(); bool get_is_discord_working(); int get_result_int();