Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
9e0033149d
@ -2,20 +2,17 @@ package domain
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
|
||||||
"git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/skirdasession"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type SkirdaDomain struct {
|
type SkirdaDomain struct {
|
||||||
DomainId string
|
DomainId string `json:"domainId"`
|
||||||
skirdagame.SkirdaGames
|
SkirdaGames `json:"games"`
|
||||||
skirdasession.SkirdaSessions
|
// skirdasession.SkirdaSessions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (domain SkirdaDomain) BuildDomain(newGames []skirdagame.SkirdaGame, newSessions []skirdasession.SkirdaSession) {
|
func (domain SkirdaDomain) BuildDomain(newGames []SkirdaGame, newSessions []SkirdaSession) {
|
||||||
domain.AddGames(newGames)
|
domain.AddGames(newGames)
|
||||||
domain.AddSessions(newSessions)
|
// domain.AddSessions(newSessions)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Domains []SkirdaDomain
|
type Domains []SkirdaDomain
|
||||||
@ -24,7 +21,7 @@ func (domains Domains) Set(newDomains []SkirdaDomain) {
|
|||||||
domains = append([]SkirdaDomain{}, newDomains...)
|
domains = append([]SkirdaDomain{}, newDomains...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (domains Domains) FindGameByID(gameId string) (skirdagame.SkirdaGame, error) {
|
func (domains Domains) FindGameByID(gameId string) (SkirdaGame, error) {
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
game, _ := domain.FindGameByID(gameId)
|
game, _ := domain.FindGameByID(gameId)
|
||||||
if game.GetSkirdaGameId() == gameId {
|
if game.GetSkirdaGameId() == gameId {
|
||||||
@ -35,21 +32,21 @@ func (domains Domains) FindGameByID(gameId string) (skirdagame.SkirdaGame, error
|
|||||||
return nil, errors.New("")
|
return nil, errors.New("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (domains Domains) GetGames() skirdagame.SkirdaGames {
|
func (domains Domains) GetGames() SkirdaGames {
|
||||||
allGames := skirdagame.SkirdaGames{}
|
allGames := SkirdaGames{}
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
allGames = append(allGames, domain.SkirdaGames...)
|
allGames = append(allGames, domain.SkirdaGames...)
|
||||||
}
|
}
|
||||||
return allGames
|
return allGames
|
||||||
}
|
}
|
||||||
|
|
||||||
func (domains Domains) GetSessions() skirdasession.SkirdaSessions {
|
// func (domains Domains) GetSessions() SkirdaSessions {
|
||||||
plainSessions := skirdasession.SkirdaSessions{}
|
// plainSessions := SkirdaSessions{}
|
||||||
for _, domain := range domains {
|
// for _, domain := range domains {
|
||||||
plainSessions = append(plainSessions, domain.SkirdaSessions...)
|
// plainSessions = append(plainSessions, SkirdaSessions...)
|
||||||
}
|
// }
|
||||||
return plainSessions
|
// return plainSessions
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (domains Domains) FindDomain(domainId string) (SkirdaDomain, error) {
|
func (domains Domains) FindDomain(domainId string) (SkirdaDomain, error) {
|
||||||
for _, domain := range domains {
|
for _, domain := range domains {
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package minecraftgame
|
package domain
|
||||||
|
|
||||||
import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
// const gameType = "minecraft"
|
||||||
|
|
||||||
const gameType = "minecraft"
|
|
||||||
|
|
||||||
type MinecraftGame struct {
|
type MinecraftGame struct {
|
||||||
SkirdaGameId string
|
SkirdaGameId string
|
||||||
Assets skirdagame.GameUIAssets
|
Assets GameUIAssets
|
||||||
Versions []string
|
Versions []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +12,7 @@ func (game MinecraftGame) GetSkirdaGameId() string {
|
|||||||
return game.SkirdaGameId
|
return game.SkirdaGameId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game MinecraftGame) GetUIAssets() skirdagame.GameUIAssets {
|
func (game MinecraftGame) GetUIAssets() GameUIAssets {
|
||||||
return game.Assets
|
return game.Assets
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,11 +21,11 @@ func (game MinecraftGame) GetLaunchArgs() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (game MinecraftGame) GetType() string {
|
func (game MinecraftGame) GetType() string {
|
||||||
return gameType
|
return "minecraft"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game MinecraftGame) GetArguments() skirdagame.Arguments {
|
func (game MinecraftGame) GetArguments() Arguments {
|
||||||
return skirdagame.Arguments{}
|
return Arguments{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game MinecraftGame) GetVersions() []string {
|
func (game MinecraftGame) GetVersions() []string {
|
@ -1,4 +1,4 @@
|
|||||||
package skirdagame
|
package domain
|
||||||
|
|
||||||
import "errors"
|
import "errors"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package skirdasession
|
package domain
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -1,14 +1,10 @@
|
|||||||
package steamgame
|
package domain
|
||||||
|
|
||||||
import "git.gregbrzezinski.com/Skirda/skirdaGoLauncher/sharedutils/games/skirdagame"
|
|
||||||
|
|
||||||
const gameType = "steam"
|
|
||||||
|
|
||||||
type SteamGame struct {
|
type SteamGame struct {
|
||||||
SkirdaGameId string
|
SkirdaGameId string
|
||||||
SteamId string
|
SteamId string
|
||||||
Assets skirdagame.GameUIAssets
|
Assets GameUIAssets
|
||||||
Arguments skirdagame.Arguments
|
Arguments Arguments
|
||||||
// CurrentVersion string
|
// CurrentVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +12,7 @@ func (game SteamGame) GetSkirdaGameId() string {
|
|||||||
return game.SkirdaGameId
|
return game.SkirdaGameId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game SteamGame) GetUIAssets() skirdagame.GameUIAssets {
|
func (game SteamGame) GetUIAssets() GameUIAssets {
|
||||||
return game.Assets
|
return game.Assets
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,9 +21,9 @@ func (game SteamGame) GetLaunchArgs() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (game SteamGame) GetType() string {
|
func (game SteamGame) GetType() string {
|
||||||
return gameType
|
return "steam"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (game SteamGame) GetArguments() skirdagame.Arguments {
|
func (game SteamGame) GetArguments() Arguments {
|
||||||
return game.Arguments
|
return game.Arguments
|
||||||
}
|
}
|
161
domain/structures.go
Normal file
161
domain/structures.go
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
|
type JavaVersion struct {
|
||||||
|
VersionNums `json:"version"`
|
||||||
|
Specifics []JavaVersionSpecifics `json:"specifics"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jVer *JavaVersion) GetVersionString() string {
|
||||||
|
return strconv.Itoa(jVer.Major) + "." + strconv.Itoa(jVer.Minor) + "." + strconv.Itoa(jVer.Patch)
|
||||||
|
}
|
||||||
|
|
||||||
|
type JavaVersionSpecifics struct {
|
||||||
|
Os string `json:"os"`
|
||||||
|
Arch string `json:"arch"`
|
||||||
|
URL string `json:"URL"`
|
||||||
|
Sha1 string `json:"SHA1"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (jv *JavaVersion) FindOs(os string, arch string) *JavaVersionSpecifics {
|
||||||
|
for _, s := range jv.Specifics {
|
||||||
|
if s.Os == os && s.Arch == arch {
|
||||||
|
return &s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type VersionNums struct {
|
||||||
|
Major int `json:"major"`
|
||||||
|
Minor int `json:"minor"`
|
||||||
|
Patch int `json:"patch"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *VersionNums) FillFromString(maj string, min string, patch string) error {
|
||||||
|
iMaj, err := strconv.Atoi(maj)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
iMin := 0
|
||||||
|
iMin, err = strconv.Atoi(min)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
iPatch := 0
|
||||||
|
iPatch, err = strconv.Atoi(patch)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
v.Major = iMaj
|
||||||
|
v.Minor = iMin
|
||||||
|
v.Patch = iPatch
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Version struct {
|
||||||
|
AssetIndex AssetIndex `json:"assetIndex"`
|
||||||
|
Downloads struct {
|
||||||
|
Client Artifact `json:"client"`
|
||||||
|
Server Artifact `json:"server"`
|
||||||
|
Mods struct {
|
||||||
|
Required []ModArtifact `json:"required"`
|
||||||
|
} `json:"mods"`
|
||||||
|
} `json:"downloads"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
Libraries []Lib `json:"libraries"`
|
||||||
|
//ClientLog LogCfg
|
||||||
|
MainClass string `json:"mainClass"`
|
||||||
|
GameArgs []Argument
|
||||||
|
JVMArgs []Argument
|
||||||
|
Type string `json:"type"`
|
||||||
|
JavaVersion JavaVersion `json:"javaVersion"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type AssetIndex struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
TotalSize uint64 `json:"totalSize"`
|
||||||
|
Artifact
|
||||||
|
}
|
||||||
|
|
||||||
|
// type Argument struct {
|
||||||
|
// Value string `json:"value"`
|
||||||
|
// Rules []Rule `json:"rules"`
|
||||||
|
// }
|
||||||
|
|
||||||
|
type JavaVersionClientDistribution struct { //TODO Rename
|
||||||
|
Component string `json:"component"`
|
||||||
|
MajorVersion int `json:"majorVersion"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Rule struct {
|
||||||
|
Action RuleAct `json:"action" mapstructure:"action"`
|
||||||
|
// OS information. All fields are regexes.
|
||||||
|
OS struct {
|
||||||
|
Name string `json:"name" mapstructure:"name"`
|
||||||
|
Version string `json:"version" mapstructure:"version"`
|
||||||
|
Arch string `json:"arch" mapstructure:"arch"`
|
||||||
|
} `json:"os" mapstructure:"os"`
|
||||||
|
Features struct {
|
||||||
|
IsDemoUser *bool `json:"is_demo_user" mapstructure:"is_demo_user"`
|
||||||
|
HasCustomResolution *bool `json:"has_custom_resolution" mapstructure:"has_custom_resolution"`
|
||||||
|
} `json:"features" mapstructure:"features"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type RuleAct string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ActAllow RuleAct = "allow"
|
||||||
|
ActDisallow RuleAct = "disallow"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LibClassifiers struct {
|
||||||
|
JavaDoc *Artifact `json:"javadoc"`
|
||||||
|
NativesLinux *Artifact `json:"natives-linux"`
|
||||||
|
NativesMacOS *Artifact `json:"natives-osx"`
|
||||||
|
NativesWin *Artifact `json:"natives-windows"`
|
||||||
|
Sources *Artifact `json:"sources"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Lib struct {
|
||||||
|
Downloads struct {
|
||||||
|
MainJar *Artifact `json:"artifact"`
|
||||||
|
LibClassifiers `json:"classifiers"`
|
||||||
|
} `json:"downloads"`
|
||||||
|
NativeSuffixes struct {
|
||||||
|
Linux string `json:"linux"`
|
||||||
|
MacOS string `json:"osx"`
|
||||||
|
Windows string `json:"windows"`
|
||||||
|
} `json:"natives"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Rules []Rule `json:"rules"`
|
||||||
|
ExtractRules struct {
|
||||||
|
Exclude []string `json:"exclude"`
|
||||||
|
} `json:"extract"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Artifact struct {
|
||||||
|
SHA1 string `json:"sha1"`
|
||||||
|
Size uint64 `json:"size"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ModArtifact struct {
|
||||||
|
Artifact
|
||||||
|
File string
|
||||||
|
Name string
|
||||||
|
Version string
|
||||||
|
}
|
||||||
|
|
||||||
|
type VersionMeta struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
|
||||||
|
Installed bool
|
||||||
|
}
|
@ -7,10 +7,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WriteStructAsJSON(data interface{}, versionJsonPath string) error {
|
func WriteStructAsJSON(data interface{}, JsonPath string) error {
|
||||||
file, _ := json.MarshalIndent(data, "", " ")
|
file, _ := json.MarshalIndent(data, "", " ")
|
||||||
|
|
||||||
directory, err := GetParentDir(versionJsonPath)
|
directory, err := GetParentDir(JsonPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ func WriteStructAsJSON(data interface{}, versionJsonPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(versionJsonPath, file, 0644)
|
err = ioutil.WriteFile(JsonPath, file, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -31,6 +31,7 @@ func ReadJsonFromDisk(target interface{}, filePath string) error {
|
|||||||
// if we os.Open returns an error then handle it
|
// if we os.Open returns an error then handle it
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println("Successfully Opened users.json")
|
// fmt.Println("Successfully Opened users.json")
|
||||||
|
Loading…
Reference in New Issue
Block a user