gosu

package module
v0.0.0-...-d386931 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2018 License: MIT Imports: 9 Imported by: 0

README

GOSU

go-osu library for reading (and writing) osu! DB binary blobs.

USAGE

import (
  "os"
  "github.com/Stymphalian/gosu"
)

func Foo() {
  path := "data/osu!.db"
  file, _ := os.Open(path)
  defer file.Close()

  var db gosu.OsuDb
  err = db.UnmarshalBinary(file, gosu.Int(20180101))
  if err != nil {
    return
  }

  fmt.Println(db.Version)
}

INSTALLATION

go get -v github.com/Stymphalian/gosu

INFO

LICENSE: MIT
Last Updated: 2018/02/04

TODO: Fix the performance TODO: sqlite TODO: web interface TODO: other binary formats

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invoke

func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value

Invoke - call a method on the given interface using reflection Args:

any: Any object for which you want to call a method on. Be sure to pass
  in the pointer if the method belongs to the pointer interface
name: The method name to invoke.
args: Vardiadic number of args to pass to the method.

func MarshalAny

func MarshalAny(db interface{}, buf io.Writer, version Int) error

Use reflection to marshal all the fields in the given interface This will loop through every field and call the 'MarshalOsuBinary' method on the type passing in the 'buf' which is the source of all the bytes. A special case is where a field is a slice. In this case:

  1. We look up the field name like "Num<SliceFieldName>" and retrieve the number of elements to exepect from the stream
  2. Create a new slice
  3. Iterate through each slice element and run the MarshalOsuBinary method

Args:

db: The object to unmarshal

/ buf: The buffer in which to write the marshalled bytes

func PrettyPrint

func PrettyPrint(v interface{})

A helper method for Pretty printing any object

func UnmarshalAny

func UnmarshalAny(db interface{}, buf io.Reader, version Int) error

Use reflection to unmarshal all the fields in the given interface This will loop through every field and call the 'UnmarshalOsuBinary' method on the type passing in the 'buf' which is the source of all the bytes. A special case is where a field is a slice. In this case:

  1. We look up the field name like "Num<SliceFieldName>" and retrieve the number of elements to exepect from the stream
  2. Create a new slice
  3. Iterate through each slice element and run the UnmarshalOsuBinary method

Args:

db: The object to unmarshal

/ buf: The buffer in which we retrieve bytes to unmarshal

Types

type BeatMap

type BeatMap struct {
	SizeOfBeatmapBytes       Int
	ArtistName               String
	ArtistNameUnicode        String
	SongTitle                String
	SongTitleUnicode         String
	CreatorName              String
	Difficulty               String
	AudioFileName            String
	Md5                      String
	OsuFileName              String
	RankedStatus             Byte
	NumHitCircles            Short
	NumOfSliders             Short
	NumOfSpinners            Short
	LastModTimeTicks         Long
	ApproachRateByte         Byte `osu-end:"20140609"`
	CircleSizeByte           Byte `osu-end:"20140609"`
	HPDrainRateByte          Byte `osu-end:"20140609"`
	OverallDifficultyByte    Byte `osu-end:"20140609"`
	ApproachRate             Single
	CircleSize               Single
	HPDrainRate              Single
	OverallDifficulty        Single
	SliderVelocity           Double
	NumOsuStandardStarRating Int             `osu-start:"20140609"`
	OsuStandardStarRating    []IntDoublePair `osu-start:"20140609"`
	NumTaikoStarRating       Int             `osu-start:"20140609"`
	TaikoStarRating          []IntDoublePair `osu-start:"20140609"`
	NumCTBStarRating         Int             `osu-start:"20140609"`
	CTBStarRating            []IntDoublePair `osu-start:"20140609"`
	NumManiaStarRating       Int             `osu-start:"20140609"`
	ManiaStarRating          []IntDoublePair `osu-start:"20140609"`
	DrainTimeSecs            Int
	TotalTimeMsec            Int
	AudioPreviewMsec         Int
	NumTimingPoints          Int
	TimingPoints             []TimingPoint
	BeatmapID                Int
	BeatmapSetID             Int
	ThreadID                 Int
	GradeOsuStandard         Byte
	GradeTaiko               Byte
	GradeCTB                 Byte
	GradeMania               Byte
	LocalBeatmapOffset       Short
	StackLeniency            Single
	OsuGameplayMode          Byte
	SongSource               String
	SongTags                 String
	OnlineOffset             Short
	TitleFont                String
	IsPlayed                 Boolean
	LastTimePlayed           Long
	IsOsz2Format             Boolean
	RelativeFolderName       String
	LastTimeCheckedWithRepo  Long
	IgnoreBeatmapSound       Boolean
	IgnoreBeatmapSkin        Boolean
	DisableStoryboard        Boolean
	DisableVideo             Boolean
	UnknownShortField        Short `osu-end:"20140609"`
	VisualOverride           Boolean
	LastModificationTime     Int
	ManiaScrollSpeed         Byte
}

func (*BeatMap) MarshalOsuBinary

func (this *BeatMap) MarshalOsuBinary(buf io.Writer, version Int) error

func (*BeatMap) UnmarshalOsuBinary

func (this *BeatMap) UnmarshalOsuBinary(buf io.Reader, version Int) error

type BinaryOsuCodec

type BinaryOsuCodec interface {
	BinaryOsuMarshaler
	BinaryOsuUnmarshaler
}

type BinaryOsuMarshaler

type BinaryOsuMarshaler interface {
	MarshalOsuBinary(buf io.Writer, version Int) error
}

Marshaler interface for Osu Binary blobs

type BinaryOsuUnmarshaler

type BinaryOsuUnmarshaler interface {
	UnmarshalOsuBinary(buf io.Reader, version Int) error
}

Unmarshaler interface for Osu Binary blobs

type Boolean

type Boolean uint8

func (*Boolean) MarshalOsuBinary

func (this *Boolean) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Boolean) UnmarshalOsuBinary

func (this *Boolean) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Byte

type Byte uint8

Type aliases so that the number of bytes match what osu is expecting. Exceptions: 1. ULEB128 is aliased to uint64 (hopefully this is big enough) 2. String is aliased to a struct with all the required information.

func (*Byte) MarshalOsuBinary

func (this *Byte) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Byte) UnmarshalOsuBinary

func (this *Byte) UnmarshalOsuBinary(buf io.Reader, version Int) error

type CollectionDb

type CollectionDb struct {
	Version        Int
	NumCollections Int
	Collections    []CollectionDbElement
}

func (*CollectionDb) MarshalOsuBinary

func (this *CollectionDb) MarshalOsuBinary(buf io.Writer, version Int) error

func (*CollectionDb) UnmarshalOsuBinary

func (this *CollectionDb) UnmarshalOsuBinary(buf io.Reader, version Int) error

type CollectionDbElement

type CollectionDbElement struct {
	Name                String
	NumBeatmapMd5Hashes Int
	BeatmapMd5Hashes    []String
}

func (*CollectionDbElement) MarshalOsuBinary

func (this *CollectionDbElement) MarshalOsuBinary(buf io.Writer, version Int) error

func (*CollectionDbElement) UnmarshalOsuBinary

func (this *CollectionDbElement) UnmarshalOsuBinary(buf io.Reader, version Int) error

type DateTime

type DateTime struct {
	Value uint64
}

func (*DateTime) MarshalOsuBinary

func (this *DateTime) MarshalOsuBinary(buf io.Writer, version Int) error

func (*DateTime) UnmarshalOsuBinary

func (this *DateTime) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Double

type Double float64

func (*Double) MarshalOsuBinary

func (this *Double) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Double) UnmarshalOsuBinary

func (this *Double) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Int

type Int uint32

func GetVersionOfBinary

func GetVersionOfBinary(buf io.Reader) (Int, error)

func (*Int) MarshalOsuBinary

func (this *Int) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Int) UnmarshalOsuBinary

func (this *Int) UnmarshalOsuBinary(buf io.Reader, version Int) error

type IntDoublePair

type IntDoublePair struct {
	ExtraBeforeInt    Byte
	IntValue          Int
	ExtraBeforeDouble Byte
	DoubleValue       Double
}

func (*IntDoublePair) MarshalOsuBinary

func (this *IntDoublePair) MarshalOsuBinary(buf io.Writer, version Int) error

func (*IntDoublePair) UnmarshalOsuBinary

func (this *IntDoublePair) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Long

type Long uint64

func (*Long) MarshalOsuBinary

func (this *Long) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Long) UnmarshalOsuBinary

func (this *Long) UnmarshalOsuBinary(buf io.Reader, version Int) error

type OsuDb

type OsuDb struct {
	Version         Int
	FolderCount     Int
	AccountUnlocked Boolean
	Datetime        DateTime
	PlayerName      String
	NumBeatmaps     Int
	Beatmaps        []BeatMap
	Extra           Int
}

func (*OsuDb) MarshalOsuBinary

func (this *OsuDb) MarshalOsuBinary(buf io.Writer, version Int) error

func (*OsuDb) UnmarshalOsuBinary

func (this *OsuDb) UnmarshalOsuBinary(buf io.Reader, version Int) error

type PlayerPresence

type PlayerPresence struct {
	PlayerId         Int
	PlayerName       String
	UtcOffset        Byte
	Country          Byte
	UnknownByteField Byte
	Longitude        Single
	Latitude         Single
	GlobalRank       Int
	DateModified     DateTime
}

func (*PlayerPresence) MarshalOsuBinary

func (this *PlayerPresence) MarshalOsuBinary(buf io.Writer, version Int) error

func (*PlayerPresence) UnmarshalOsuBinary

func (this *PlayerPresence) UnmarshalOsuBinary(buf io.Reader, version Int) error

type PresenceDb

type PresenceDb struct {
	Version    Int
	NumPlayers Int
	Players    []PlayerPresence
}

func (*PresenceDb) MarshalOsuBinary

func (this *PresenceDb) MarshalOsuBinary(buf io.Writer, version Int) error

func (*PresenceDb) UnmarshalOsuBinary

func (this *PresenceDb) UnmarshalOsuBinary(buf io.Reader, version Int) error

type ScoresDb

type ScoresDb struct {
	Version     Int
	NumBeatmaps Int
	Beatmaps    []ScoresDbBeatMap
}

func (*ScoresDb) MarshalOsuBinary

func (this *ScoresDb) MarshalOsuBinary(buf io.Writer, version Int) error

func (*ScoresDb) UnmarshalOsuBinary

func (this *ScoresDb) UnmarshalOsuBinary(buf io.Reader, version Int) error

type ScoresDbBeatMap

type ScoresDbBeatMap struct {
	Md5Hash   String
	NumScores Int
	Scores    []ScoresDbBeatMapScore
}

func (*ScoresDbBeatMap) MarshalOsuBinary

func (this *ScoresDbBeatMap) MarshalOsuBinary(buf io.Writer, version Int) error

func (*ScoresDbBeatMap) UnmarshalOsuBinary

func (this *ScoresDbBeatMap) UnmarshalOsuBinary(buf io.Reader, version Int) error

type ScoresDbBeatMapScore

type ScoresDbBeatMapScore struct {
	GameplayMode                 Byte
	Version                      Int
	Md5Hash                      String
	PlayerName                   String
	ReplayMd5Hash                String
	Num300                       Short
	Num200                       Short
	Num50                        Short
	NumMax300                    Short
	Num100                       Short
	NumMiss                      Short
	ReplayScore                  Int
	MaxCombo                     Short
	IsPerfectCombo               Boolean
	Mods                         Int
	EmptyString                  String
	TimestampOfReplayWindowTicks Long
	AlwaysNegativeOne            Int
	OnlineScoreId                Long
}

func (*ScoresDbBeatMapScore) MarshalOsuBinary

func (this *ScoresDbBeatMapScore) MarshalOsuBinary(buf io.Writer, version Int) error

func (*ScoresDbBeatMapScore) UnmarshalOsuBinary

func (this *ScoresDbBeatMapScore) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Short

type Short uint16

func (*Short) MarshalOsuBinary

func (this *Short) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Short) UnmarshalOsuBinary

func (this *Short) UnmarshalOsuBinary(buf io.Reader, version Int) error

type Single

type Single float32

func (*Single) MarshalOsuBinary

func (this *Single) MarshalOsuBinary(buf io.Writer, version Int) error

func (*Single) UnmarshalOsuBinary

func (this *Single) UnmarshalOsuBinary(buf io.Reader, version Int) error

type String

type String struct {
	Cond Byte
	Len  ULEB128
	Text string
}

func (*String) MarshalOsuBinary

func (this *String) MarshalOsuBinary(buf io.Writer, version Int) error

func (*String) UnmarshalOsuBinary

func (this *String) UnmarshalOsuBinary(buf io.Reader, version Int) error

type TimingPoint

type TimingPoint struct {
	BPM         Double
	OffsetMsec  Double
	IsInherited Boolean
}

func (*TimingPoint) MarshalOsuBinary

func (this *TimingPoint) MarshalOsuBinary(buf io.Writer, version Int) error

func (*TimingPoint) UnmarshalOsuBinary

func (this *TimingPoint) UnmarshalOsuBinary(buf io.Reader, version Int) error

type ULEB128

type ULEB128 uint64

func (*ULEB128) MarshalOsuBinary

func (this *ULEB128) MarshalOsuBinary(buf io.Writer, version Int) error

func (*ULEB128) UnmarshalOsuBinary

func (this *ULEB128) UnmarshalOsuBinary(buf io.Reader, version Int) error

Jump to

Keyboard shortcuts

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