sonolusgo

package module
v0.8.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 7 Imported by: 2

README

sonolusgo

一个使用Go语言和Gin框架构建Sonolus服务器的框架库

适用版本 V0.8.11 当前版本 V0.8.11-1

基于Go的版本号要求,和本项目修改bug的需要,本框架的版本号将全部以rc结尾。rc越大,版本越新。

正在建设中(With in Progress)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailsHandler

func DetailsHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func GetEmptyItem

func GetEmptyItem[ItemType SonolusItem](name string) (item ItemType, description string, err error)

func GetEmptyList

func GetEmptyList[ItemType SonolusItem](page int, queryMap map[string]string) (pageCount int, items []ItemType)

func GetEmptyRecommend

func GetEmptyRecommend[ItemType SonolusItem](name string) (items []ItemType)

func GetItem

func GetItem[ItemType SonolusItem](name string) (item ItemType, description string, err error)

func GetList

func GetList[ItemType SonolusItem](page int, queryMap map[string]string) (pageCount int, items []ItemType)

func InfoHandler

func InfoHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func ListHandler

func ListHandler[Item SonolusItem](handler SonolusService[Item]) gin.HandlerFunc

func ServerInfoHandler

func ServerInfoHandler(server *Server) gin.HandlerFunc

TODO: Localization

func SonolusVersionHandler

func SonolusVersionHandler(ctx *gin.Context)

Types

type Background

type Background struct {
	SonolusItemBase
	Thumbnail     SRL `json:"thumbnail"`
	Data          SRL `json:"data"`
	Image         SRL `json:"image"`
	Configuration SRL `json:"configuration"`
}

func (Background) GetCategory

func (item Background) GetCategory() SonolusCategory

func (Background) GetName

func (item Background) GetName() string

type Configuration

type Configuration struct {
	Options []any `json:"options"` // Not Certain here
}

type Effect

type Effect struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Audio     SRL `json:"audio"`
}

func (Effect) GetCategory

func (item Effect) GetCategory() SonolusCategory

func (Effect) GetName

func (item Effect) GetName() string

type Engine

type Engine struct {
	SonolusItemBase
	Skin          Skin       `json:"skin"`
	Background    Background `json:"background"`
	Effect        Effect     `json:"effect"`
	Particle      Particle   `json:"particle"`
	Thumbnail     SRL        `json:"thumbnail"`
	PlayData      SRL        `json:"playData"`
	WatchData     SRL        `json:"watchData"`
	PreviewData   SRL        `json:"previewData"`
	TutorialData  SRL        `json:"tutorialData"`
	Rom           *SRL       `json:"rom,omitempty"`
	Configuration SRL        `json:"configuration"`
}

func (Engine) GetCategory

func (item Engine) GetCategory() SonolusCategory

func (Engine) GetName

func (item Engine) GetName() string

type Handlers

type Handlers struct {
	Posts       SonolusService[Post]
	Playlist    SonolusService[Playlist]
	Levels      SonolusService[Level]
	Skins       SonolusService[Skin]
	Backgrounds SonolusService[Background]
	Effects     SonolusService[Effect]
	Particles   SonolusService[Particle]
	Engines     SonolusService[Engine]
	Replay      SonolusService[Replay]
}

type ItemDetail

type ItemDetail[ItemType SonolusItem] struct {
	Item         ItemType                `json:"item"`
	Description  string                  `json:"description"`
	HasCommunity bool                    `json:"hasCommunity"`
	Leaderboards []interface{}           `json:"leaderboards"`
	Actions      []interface{}           `json:"actions"`
	Sections     []ItemSection[ItemType] `json:"sections"`
}

type ItemInfo

type ItemInfo[ItemType SonolusItem] struct {
	Banner   SRL                     `json:"banner"`
	Sections []ItemSection[ItemType] `json:"sections"`
	Searches []ServerForm            `json:"searches"`
}

type ItemList

type ItemList[ItemType SonolusItem] struct {
	PageCount int          `json:"pageCount"`
	Items     []ItemType   `json:"items"`
	Searches  []ServerForm `json:"searches"`
}

type ItemSection

type ItemSection[ItemType SonolusItem] struct {
	Title    string     `json:"title"`
	Items    []ItemType `json:"items"`
	ItemType string     `json:"itemType"`
	Icon     string     `json:"icon,omitempty"`
}

type Level

type Level struct {
	Name          string              `json:"name"`
	Source        string              `json:"source"`
	Version       int                 `json:"version"`
	Rating        int                 `json:"rating"`
	Title         string              `json:"title"`
	Artists       string              `json:"artists"`
	Author        string              `json:"author"`
	Tags          []Tag               `json:"tags"`
	Engine        Engine              `json:"engine"`
	UseSkin       UseItem[Skin]       `json:"useSkin"`
	UseBackground UseItem[Background] `json:"useBackground"`
	UseEffect     UseItem[Effect]     `json:"useEffect"`
	UseParticle   UseItem[Particle]   `json:"useParticle"`
	Cover         SRL                 `json:"cover"`
	Bgm           SRL                 `json:"bgm"`
	Preview       *SRL                `json:"preview,omitempty"`
	Data          SRL                 `json:"data"`
}

func (Level) GetCategory

func (item Level) GetCategory() SonolusCategory

func (Level) GetName

func (item Level) GetName() string

type Particle

type Particle struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Texture   SRL `json:"texture"`
}

func (Particle) GetCategory

func (item Particle) GetCategory() SonolusCategory

func (Particle) GetName

func (item Particle) GetName() string

type Playlist

type Playlist struct {
	Name      string  `json:"name"`
	Source    string  `json:"source,omitempty"`
	Version   int     `json:"version"`
	Title     string  `json:"title"`
	Subtitle  string  `json:"subtitle"`
	Author    string  `json:"author"`
	Tags      []Tag   `json:"tags"`
	Levels    []Level `json:"levels"`
	Thumbnail SRL     `json:"thumbnail"`
}

func (Playlist) GetCategory

func (item Playlist) GetCategory() SonolusCategory

func (Playlist) GetName

func (item Playlist) GetName() string

type Post

type Post struct {
	Name      string `json:"name"`
	Source    string `json:"source,omitempty"`
	Version   int    `json:"version"`
	Title     string `json:"title"`
	Time      string `json:"time"`
	Author    string `json:"author"`
	Tags      []Tag  `json:"tags"`
	Thumbnail SRL    `json:"thumbnail"`
}

func (Post) GetCategory

func (item Post) GetCategory() SonolusCategory

func (Post) GetName

func (item Post) GetName() string

type Replay

type Replay struct {
	Name      string  `json:"name"`
	Source    string  `json:"source,omitempty"`
	Version   int     `json:"version"`
	Title     string  `json:"title"`
	Subtitle  string  `json:"subtitle"`
	Author    string  `json:"author"`
	Tags      []Tag   `json:"tags"`
	Levels    []Level `json:"levels"`
	Data      SRL     `json:"data"`
	Thumbnail SRL     `json:"thumbnail"`
}

func (Replay) GetCategory

func (item Replay) GetCategory() SonolusCategory

func (Replay) GetName

func (item Replay) GetName() string

type RouterGroups

type RouterGroups struct {
	Sonolus     *gin.RouterGroup
	Posts       *gin.RouterGroup
	Playlist    *gin.RouterGroup
	Levels      *gin.RouterGroup
	Skins       *gin.RouterGroup
	Backgrounds *gin.RouterGroup
	Effects     *gin.RouterGroup
	Particles   *gin.RouterGroup
	Engines     *gin.RouterGroup
	Replays     *gin.RouterGroup
}

type SRL

type SRL struct {
	Hash string `json:"hash"`
	Url  string `json:"url"`
}

type Server

type Server struct {
	RepoDir      string
	ServerName   string
	ServerBanner SRL
	ServerInfo   ServerInfoFilePath
	Handlers     Handlers
	RouterGroups RouterGroups
}

func DefaultConfig

func DefaultConfig() *Server

func (*Server) LoadHandlers

func (server *Server) LoadHandlers(parentHandler *gin.Engine)

type ServerForm

type ServerForm struct {
	Type                string         `json:"type"`
	Title               string         `json:"title"`
	Icon                string         `json:"icon,omitempty"`
	Description         string         `json:"description,omitempty"`
	Help                string         `json:"help,omitempty"`
	RequireConfirmation bool           `json:"requireConfirmation"`
	Options             []ServerOption `json:"options"`
}

func GetEmptySearch

func GetEmptySearch() (search []ServerForm)

type ServerInfo

type ServerInfo struct {
	Title             string                 `json:"title"`
	Description       string                 `json:"description,omitempty"`
	HasAuthentication bool                   `json:"hasAuthentication"`
	HasMultiplayer    bool                   `json:"hasMultiplayer"`
	Buttons           []ServerInfoButtonType `json:"buttons"`
	Banner            SRL                    `json:"banner"`
	Configuration     Configuration          `json:"configuration"`
}

type ServerInfoButtonType

type ServerInfoButtonType struct {
	Type string `json:"type"`
}

type ServerInfoFilePath

type ServerInfoFilePath struct {
	Posts       string
	Playlist    string
	Levels      string
	Skins       string
	Backgrounds string
	Effects     string
	Particles   string
	Engines     string
	Replays     string
}
var InfoFilePath *ServerInfoFilePath

type ServerOption

type ServerOption interface {
	GetQuery() string
	GetValueStr(queryResult string) string
}

type ServerSelectOption

type ServerSelectOption struct {
	Query       string   `json:"query"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Required    bool     `json:"required"`
	Type        string   `json:"type"`
	Def         int      `json:"def"`
	Values      []string `json:"values,omitempty"`
}

func NewServerSelectOption

func NewServerSelectOption(query string, name string, description string, required bool, def int, values []string) ServerSelectOption

func (ServerSelectOption) GetQuery

func (o ServerSelectOption) GetQuery() string

func (ServerSelectOption) GetValueStr

func (o ServerSelectOption) GetValueStr(queryResult string) string

type ServerSliderOption

type ServerSliderOption struct {
	Query       string  `json:"query"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Required    bool    `json:"required"`
	Type        string  `json:"type"`
	Def         float64 `json:"def"`
	Min         float64 `json:"min"`
	Max         float64 `json:"max"`
	Step        float64 `json:"step"`
	Unit        string  `json:"unit"`
}

func NewServerSliderOption

func NewServerSliderOption(query string, name string, description string, required bool, def float64, min float64, max float64, step float64, unit string) ServerSliderOption

func (ServerSliderOption) GetQuery

func (o ServerSliderOption) GetQuery() string

func (ServerSliderOption) GetValueStr

func (o ServerSliderOption) GetValueStr(queryResult string) string

type ServerTextOption

type ServerTextOption struct {
	Query       string   `json:"query"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Required    bool     `json:"required"`
	Type        string   `json:"type"`
	Def         string   `json:"def"`
	PlaceHolder string   `json:"placeHolder"`
	Limit       int      `json:"limit"`
	Shortcuts   []string `json:"shortcuts"`
}

func NewServerTextOption

func NewServerTextOption(query string, name string, description string, required bool, def string, placeHolder string, limit int, shortcuts []string) ServerTextOption

func (ServerTextOption) GetQuery

func (o ServerTextOption) GetQuery() string

func (ServerTextOption) GetValueStr

func (o ServerTextOption) GetValueStr(queryResult string) string

type ServerToggleOption

type ServerToggleOption struct {
	Query       string `json:"query"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Type        string `json:"type"`
	Def         int    `json:"def"`
}

func NewServerToggleOption

func NewServerToggleOption(query string, name string, description string, required bool, def int) ServerToggleOption

func (ServerToggleOption) GetQuery

func (o ServerToggleOption) GetQuery() string

func (ServerToggleOption) GetValueStr

func (o ServerToggleOption) GetValueStr(queryResult string) string

type Skin

type Skin struct {
	SonolusItemBase
	Thumbnail SRL `json:"thumbnail"`
	Data      SRL `json:"data"`
	Texture   SRL `json:"texture"`
}

func (Skin) GetCategory

func (item Skin) GetCategory() SonolusCategory

func (Skin) GetName

func (item Skin) GetName() string

type SonolusCategory

type SonolusCategory int
const (
	CategoryPostItem SonolusCategory = iota
	CategoryPlaylist
	CategoryLevels
	CategorySkins
	CategoryBackgrounds
	CategoryEffect
	CategoryParticle
	CategoryEngine
	CategoryReplayItem
	TotalCategoryCnt
)

type SonolusItem

type SonolusItem interface {
	Post | Playlist | Level | Skin | Background | Effect | Particle | Engine | Replay
	GetName() string
	GetCategory() SonolusCategory
}

type SonolusItemBase

type SonolusItemBase struct {
	Name     string `json:"name"`
	Source   string `json:"source,omitempty"`
	Version  int    `json:"version"`
	Title    string `json:"title"`
	Subtitle string `json:"subtitle"`
	Author   string `json:"author"`
	Tags     []Tag  `json:"tags"`
}

type SonolusService

type SonolusService[ItemType SonolusItem] struct {
	List      func(page int, queryMap map[string]string) (pageCount int, items []ItemType)
	Search    func() (search []ServerForm)
	Item      func(name string) (item ItemType, description string, err error)
	Recommend func(name string) (items []ItemType)
	Banner    SRL
}

type Tag

type Tag struct {
	Title string `json:"title"`
	Icon  string `json:"icon,omitempty"`
}

type UseItem

type UseItem[ItemType Skin | Background | Effect | Particle] struct {
	UseDefault bool      `json:"useDefault"`
	Item       *ItemType `json:"item,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL