Fix for 12.41
This commit is contained in:
parent
75d2310eb6
commit
2b9ab97d4d
|
@ -16,7 +16,7 @@ import (
|
||||||
var (
|
var (
|
||||||
PlaylistImages = map[string][]byte{
|
PlaylistImages = map[string][]byte{
|
||||||
"Playlist_DefaultSolo": {},
|
"Playlist_DefaultSolo": {},
|
||||||
// "Playlist_DefaultDuo": {},
|
"Playlist_DefaultDuo": {},
|
||||||
// "Playlist_DefaultSquad": {},
|
// "Playlist_DefaultSquad": {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -68,4 +68,53 @@ func GenerateSoloImage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistImages["Playlist_DefaultSolo"] = bytes.Bytes()
|
PlaylistImages["Playlist_DefaultSolo"] = bytes.Bytes()
|
||||||
|
}
|
||||||
|
|
||||||
|
func GenerateDuoImage() {
|
||||||
|
background := *storage.Asset("background.png")
|
||||||
|
|
||||||
|
itemFound := Cosmetics.GetRandomItemByType("AthenaCharacter")
|
||||||
|
for itemFound.Images.Featured == "" {
|
||||||
|
itemFound = Cosmetics.GetRandomItemByType("AthenaCharacter")
|
||||||
|
}
|
||||||
|
aid.Print(itemFound.Images.Featured)
|
||||||
|
|
||||||
|
res, err := http.Get(itemFound.Images.Featured)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
data, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bg, _, err := image.Decode(bytes.NewReader(background))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
soloPlayer, _, err := image.Decode(bytes.NewReader(data))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m := image.NewRGBA(bg.Bounds())
|
||||||
|
draw.Draw(m, m.Bounds(), bg, image.Point{0, 0}, draw.Src)
|
||||||
|
|
||||||
|
resized := resize.Resize(0, uint(float64(m.Bounds().Dy()) * 1.4), soloPlayer, resize.Lanczos3)
|
||||||
|
centre := image.Point{
|
||||||
|
m.Bounds().Dx()/2 - resized.Bounds().Dx()/2,
|
||||||
|
(m.Bounds().Dy()/2 - resized.Bounds().Dy()/2) + 200,
|
||||||
|
}
|
||||||
|
draw.Draw(m, resized.Bounds().Add(centre), resized, image.Point{0, 0}, draw.Over)
|
||||||
|
|
||||||
|
var bytes bytes.Buffer
|
||||||
|
err = png.Encode(&bytes, m)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistImages["Playlist_DefaultDuo"] = bytes.Bytes()
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ectrc/snow/aid"
|
"github.com/ectrc/snow/aid"
|
||||||
|
@ -75,7 +76,7 @@ func createPlaylist(mnemonic string, image string) aid.JSON {
|
||||||
func PostDiscovery(c *fiber.Ctx) error {
|
func PostDiscovery(c *fiber.Ctx) error {
|
||||||
results := []aid.JSON{}
|
results := []aid.JSON{}
|
||||||
for playlist := range fortnite.PlaylistImages {
|
for playlist := range fortnite.PlaylistImages {
|
||||||
results = append(results, createPlaylist(playlist, "http://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png"))
|
results = append(results, createPlaylist(playlist, "http://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999))))
|
||||||
}
|
}
|
||||||
results = append(results, createPlaylist("Playlist_DefaultSolo", "http://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png"))
|
results = append(results, createPlaylist("Playlist_DefaultSolo", "http://bucket.retrac.site/55737fa15677cd57fab9e7f4499d62f89cfde320.png"))
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ func GetContentPages(c *fiber.Ctx) error {
|
||||||
playlists := []aid.JSON{}
|
playlists := []aid.JSON{}
|
||||||
for playlist := range fortnite.PlaylistImages {
|
for playlist := range fortnite.PlaylistImages {
|
||||||
playlists = append(playlists, aid.JSON{
|
playlists = append(playlists, aid.JSON{
|
||||||
"image": "http://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png",
|
"image": "http://" + aid.Config.API.Host + aid.Config.API.Port + "/snow/image/" + playlist + ".png?cache="+strconv.Itoa(rand.Intn(9999)),
|
||||||
"playlist_name": playlist,
|
"playlist_name": playlist,
|
||||||
"hidden": false,
|
"hidden": false,
|
||||||
})
|
})
|
||||||
|
|
|
@ -35,6 +35,7 @@ func PostProfileAction(c *fiber.Ctx) error {
|
||||||
|
|
||||||
profile := person.GetProfileFromType(c.Query("profileId"))
|
profile := person.GetProfileFromType(c.Query("profileId"))
|
||||||
if profile == nil {
|
if profile == nil {
|
||||||
|
aid.Print(c.Query("profileId"), "not found")
|
||||||
return c.Status(404).JSON(aid.ErrorBadRequest("No Profile Found"))
|
return c.Status(404).JSON(aid.ErrorBadRequest("No Profile Found"))
|
||||||
}
|
}
|
||||||
defer profile.ClearProfileChanges()
|
defer profile.ClearProfileChanges()
|
||||||
|
|
|
@ -14,6 +14,7 @@ type Person struct {
|
||||||
CommonPublicProfile *Profile
|
CommonPublicProfile *Profile
|
||||||
Profile0Profile *Profile
|
Profile0Profile *Profile
|
||||||
CollectionsProfile *Profile
|
CollectionsProfile *Profile
|
||||||
|
CreativeProfile *Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
type Option struct {
|
type Option struct {
|
||||||
|
@ -31,6 +32,7 @@ func NewPerson() *Person {
|
||||||
CommonPublicProfile: NewProfile("common_public"),
|
CommonPublicProfile: NewProfile("common_public"),
|
||||||
Profile0Profile: NewProfile("profile0"),
|
Profile0Profile: NewProfile("profile0"),
|
||||||
CollectionsProfile: NewProfile("collections"),
|
CollectionsProfile: NewProfile("collections"),
|
||||||
|
CreativeProfile: NewProfile("creative"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ func findHelper(databasePerson *storage.DB_Person) *Person {
|
||||||
commonPublicProfile := NewProfile("common_public")
|
commonPublicProfile := NewProfile("common_public")
|
||||||
profile0 := NewProfile("profile0")
|
profile0 := NewProfile("profile0")
|
||||||
collectionsProfile := NewProfile("collections")
|
collectionsProfile := NewProfile("collections")
|
||||||
|
creativeProfile := NewProfile("creative")
|
||||||
|
|
||||||
for _, profile := range databasePerson.Profiles {
|
for _, profile := range databasePerson.Profiles {
|
||||||
if profile.Type == "athena" {
|
if profile.Type == "athena" {
|
||||||
|
@ -102,6 +105,11 @@ func findHelper(databasePerson *storage.DB_Person) *Person {
|
||||||
collectionsProfile.ID = profile.ID
|
collectionsProfile.ID = profile.ID
|
||||||
collectionsProfile = FromDatabaseProfile(&profile)
|
collectionsProfile = FromDatabaseProfile(&profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if profile.Type == "creative" {
|
||||||
|
creativeProfile.ID = profile.ID
|
||||||
|
creativeProfile = FromDatabaseProfile(&profile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
person := &Person{
|
person := &Person{
|
||||||
|
@ -113,6 +121,7 @@ func findHelper(databasePerson *storage.DB_Person) *Person {
|
||||||
CommonPublicProfile: commonPublicProfile,
|
CommonPublicProfile: commonPublicProfile,
|
||||||
Profile0Profile: profile0,
|
Profile0Profile: profile0,
|
||||||
CollectionsProfile: collectionsProfile,
|
CollectionsProfile: collectionsProfile,
|
||||||
|
CreativeProfile: creativeProfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.SavePerson(person)
|
cache.SavePerson(person)
|
||||||
|
@ -155,6 +164,8 @@ func (p *Person) GetProfileFromType(profileType string) *Profile {
|
||||||
return p.Profile0Profile
|
return p.Profile0Profile
|
||||||
case "collections":
|
case "collections":
|
||||||
return p.CollectionsProfile
|
return p.CollectionsProfile
|
||||||
|
case "creative":
|
||||||
|
return p.CreativeProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -179,6 +190,7 @@ func (p *Person) ToDatabase() *storage.DB_Person {
|
||||||
"common_public": p.CommonPublicProfile,
|
"common_public": p.CommonPublicProfile,
|
||||||
"profile0": p.Profile0Profile,
|
"profile0": p.Profile0Profile,
|
||||||
"collections": p.CollectionsProfile,
|
"collections": p.CollectionsProfile,
|
||||||
|
"creative": p.CreativeProfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
for profileType, profile := range profilesToConvert {
|
for profileType, profile := range profilesToConvert {
|
||||||
|
@ -247,5 +259,6 @@ func (p *Person) Snapshot() *PersonSnapshot {
|
||||||
CommonPublicProfile: *p.CommonPublicProfile.Snapshot(),
|
CommonPublicProfile: *p.CommonPublicProfile.Snapshot(),
|
||||||
Profile0Profile: *p.Profile0Profile.Snapshot(),
|
Profile0Profile: *p.Profile0Profile.Snapshot(),
|
||||||
CollectionsProfile: *p.CollectionsProfile.Snapshot(),
|
CollectionsProfile: *p.CollectionsProfile.Snapshot(),
|
||||||
|
CreativeProfile: *p.CreativeProfile.Snapshot(),
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ type PersonSnapshot struct {
|
||||||
CommonPublicProfile ProfileSnapshot
|
CommonPublicProfile ProfileSnapshot
|
||||||
Profile0Profile ProfileSnapshot
|
Profile0Profile ProfileSnapshot
|
||||||
CollectionsProfile ProfileSnapshot
|
CollectionsProfile ProfileSnapshot
|
||||||
|
CreativeProfile ProfileSnapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProfileSnapshot struct {
|
type ProfileSnapshot struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user