Skip to content

Commit

Permalink
Merge pull request #340 from Wieku/dev
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
Wieku authored Aug 13, 2023
2 parents 75c5e4f + 0096034 commit 59350ce
Show file tree
Hide file tree
Showing 115 changed files with 1,120 additions and 794 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '1.19.1'
go-version: '1.21.0'
cache: true

- name: Build danser
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '1.19.1'
go-version: '1.21.0'
cache: true

- name: Build danser
Expand Down
63 changes: 12 additions & 51 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/dustin/go-humanize"
"github.com/faiface/mainthread"
"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/mem"
"github.com/wieku/danser-go/app/audio"
"github.com/wieku/danser-go/app/beatmap"
difficulty2 "github.com/wieku/danser-go/app/beatmap/difficulty"
Expand All @@ -34,19 +30,16 @@ import (
"github.com/wieku/danser-go/framework/graphics/buffer"
"github.com/wieku/danser-go/framework/graphics/font"
"github.com/wieku/danser-go/framework/graphics/viewport"
"github.com/wieku/danser-go/framework/math/mutils"
"github.com/wieku/danser-go/framework/math/vector"
"github.com/wieku/danser-go/framework/platform"
"github.com/wieku/danser-go/framework/qpc"
"github.com/wieku/danser-go/framework/statistic"
"github.com/wieku/danser-go/framework/util"
"github.com/wieku/rplpa"
"io"
"io/ioutil"
"log"
"math"
"os"
"path/filepath"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -253,6 +246,8 @@ func run() {

newSettings := settings.LoadSettings(*settingsVersion)

log.Println("Current config:", settings.GetCompressedString())

if !newSettings && len(os.Args) == 1 {
platform.OpenURL("https://youtu.be/dQw4w9WgXcQ")
closeAfterSettingsLoad = true
Expand Down Expand Up @@ -334,6 +329,10 @@ func run() {
panic("Failed to initialize GLFW: " + err.Error())
}

if !closeAfterSettingsLoad {
log.Println("GLFW Initialized!")
}

platform.SetupContext()

glfw.WindowHint(glfw.Resizable, glfw.False)
Expand Down Expand Up @@ -393,6 +392,8 @@ func run() {
settings.SKIP = false
}

log.Println("Creating window...")

if settings.Graphics.Fullscreen {
glfw.WindowHint(glfw.RedBits, monitor.GetVideoMode().RedBits)
glfw.WindowHint(glfw.GreenBits, monitor.GetVideoMode().GreenBits)
Expand Down Expand Up @@ -426,7 +427,7 @@ func run() {

win.MakeContextCurrent()

log.Println("GLFW initialized!")
log.Println("Window created!")

err = platform.GLInit(*gldebug)
if err != nil {
Expand Down Expand Up @@ -538,7 +539,7 @@ func mainLoopRecord() {

ffmpeg.StartFFmpeg(int(fps), w, h, audioFPS, output)

updateFPS := math.Max(fps, 1000)
updateFPS := max(fps, 1000)
updateDelta := 1000 / updateFPS
fpsDelta := 1000 / fps
audioDelta := 1000.0 / audioFPS
Expand Down Expand Up @@ -653,7 +654,7 @@ func mainLoopNormal() {
case glfw.KeyEscape:
win.SetShouldClose(true)
case glfw.KeyMinus:
settings.DIVIDES = mutils.Max(1, settings.DIVIDES-1)
settings.DIVIDES = max(1, settings.DIVIDES-1)
case glfw.KeyEqual:
settings.DIVIDES += 1
case glfw.KeyO:
Expand Down Expand Up @@ -773,35 +774,6 @@ func checkForUpdates() {
}
}

func printPlatformInfo() {
const unknown = "Unknown"

osName, cpuName, ramAmount := unknown, unknown, unknown

hStat, err := host.Info()
if err == nil {
osName = hStat.Platform + " " + hStat.PlatformVersion
}

cStats, err := cpu.Info()
if err == nil && len(cStats) > 0 {
cpuName = fmt.Sprintf("%s, %d cores", strings.TrimSpace(cStats[0].ModelName), cStats[0].Cores)
}

mStat, err := mem.VirtualMemory()
if err == nil {
ramAmount = humanize.IBytes(mStat.Total)
}

log.Println("-------------------------------------------------------------------")
log.Println("danser-go version:", build.VERSION)
log.Println("Ran using:", os.Args)
log.Println("OS: ", osName)
log.Println("CPU:", cpuName)
log.Println("RAM:", ramAmount)
log.Println("-------------------------------------------------------------------")
}

func Run() {
defer func() {
var err any
Expand All @@ -816,18 +788,7 @@ func Run() {

goroutines.SetCrashHandler(closeHandler)

log.Println("danser-go version:", build.VERSION)

file, err := os.Create(filepath.Join(env.DataDir(), "danser.log"))
if err != nil {
panic(err)
}

log.SetOutput(file)

printPlatformInfo()

log.SetOutput(io.MultiWriter(os.Stdout, file))
platform.StartLogging("danser")

platform.DisableQuickEdit()

Expand Down
4 changes: 2 additions & 2 deletions app/audio/osuaudio.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func PlaySample(sampleSet, additionSet, hitsound, index int, volume float64, obj
additionSet = sampleSet
}

volume = mutils.Max(volume, 0.08)
volume = max(volume, 0.08)

// Play normal
if skin.GetInfo().LayeredHitSounds || hitsound&1 > 0 || hitsound == 0 {
Expand All @@ -94,7 +94,7 @@ func PlaySample(sampleSet, additionSet, hitsound, index int, volume float64, obj
func playSample(sampleSet int, hitsoundIndex, index int, volume float64, objNum int64, xPos float64) {
balance := 0.0
if settings.DIVIDES == 1 {
balance = mutils.ClampF((xPos-256)/512*settings.Audio.HitsoundPositionMultiplier, -1, 1)
balance = mutils.Clamp((xPos-256)/512*settings.Audio.HitsoundPositionMultiplier, -1, 1)
}

if settings.Audio.IgnoreBeatmapSampleVolume {
Expand Down
11 changes: 6 additions & 5 deletions app/beatmap/beatmap.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package beatmap

import (
"cmp"
"github.com/wieku/danser-go/app/audio"
"github.com/wieku/danser-go/app/beatmap/difficulty"
"github.com/wieku/danser-go/app/beatmap/objects"
"golang.org/x/exp/slices"
"math"
"slices"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -107,8 +108,8 @@ func (beatMap *BeatMap) Update(time float64) {
if toRemove > 0 {
beatMap.processed = append(beatMap.processed, beatMap.Queue[:toRemove]...)

slices.SortFunc(beatMap.processed, func(a, b objects.IHitObject) bool {
return a.GetEndTime() < b.GetEndTime()
slices.SortFunc(beatMap.processed, func(a, b objects.IHitObject) int {
return cmp.Compare(a.GetEndTime(), b.GetEndTime())
})

beatMap.Queue = beatMap.Queue[toRemove:]
Expand Down Expand Up @@ -147,8 +148,8 @@ func (beatMap *BeatMap) ParsePoint(point string) {

if !math.IsNaN(bpm) && bpm >= 0 {
rBPM := 60000 / bpm
beatMap.MinBPM = math.Min(beatMap.MinBPM, rBPM)
beatMap.MaxBPM = math.Max(beatMap.MaxBPM, rBPM)
beatMap.MinBPM = min(beatMap.MinBPM, rBPM)
beatMap.MaxBPM = max(beatMap.MaxBPM, rBPM)
}

signature := 4
Expand Down
12 changes: 6 additions & 6 deletions app/beatmap/difficulty/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (diff *Difficulty) calculate() {
hpDrain, cs, od, ar := diff.hp, diff.cs, diff.od, diff.ar

if diff.Mods&HardRock > 0 {
ar = math.Min(ar*1.4, 10)
cs = math.Min(cs*1.3, 10)
od = math.Min(od*1.4, 10)
hpDrain = math.Min(hpDrain*1.4, 10)
ar = min(ar*1.4, 10)
cs = min(cs*1.3, 10)
od = min(od*1.4, 10)
hpDrain = min(hpDrain*1.4, 10)
}

if diff.Mods&Easy > 0 {
Expand All @@ -97,7 +97,7 @@ func (diff *Difficulty) calculate() {
diff.PreemptU = DifficultyRate(ar, 1800, 1200, 450)
diff.Preempt = math.Floor(diff.PreemptU)

diff.TimeFadeIn = HitFadeIn * math.Min(1, diff.PreemptU/450)
diff.TimeFadeIn = HitFadeIn * min(1, diff.PreemptU/450)

diff.Hit50U = DifficultyRate(od, 200, 150, 100)
diff.Hit100U = DifficultyRate(od, 140, 100, 60)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (diff *Difficulty) GetScoreMultiplier() float64 {
if diff.Speed >= 0.75 {
baseMultiplier *= 0.3 + 0.7*(1-(1-diff.Speed)/0.25)
} else {
baseMultiplier *= math.Max(0, 0.3*(1-(0.75-diff.Speed)/0.75))
baseMultiplier *= max(0, 0.3*(1-(0.75-diff.Speed)/0.75))
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/beatmap/objects/circle.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ func (circle *Circle) SetDifficulty(diff *difficulty.Difficulty) {
circle.reverseArrow = sprite.NewSpriteSingle(skin.GetTexture("reversearrow"), 0, vector.NewVec2d(0, 0), vector.Centre)
circle.reverseArrow.SetAlpha(0)

circle.reverseArrow.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, startTime, math.Min(endTime, startTime+150), 0.0, 1.0))
circle.reverseArrow.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, startTime, min(endTime, startTime+150), 0.0, 1.0))
circle.reverseArrow.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, endTime, endTime, 1.0, 0.0))

circle.sprites = append(circle.sprites, circle.reverseArrow)

for t := circle.bounceStartTime; t < endTime; t += 300 {
length := math.Min(300, endTime-t)
length := min(300, endTime-t)
circle.reverseArrow.AddTransform(animation.NewSingleTransform(animation.Scale, easing.Linear, t, t+length, 1.3, 1.0))

if skin.GetInfo().Version < 2 {
Expand All @@ -216,7 +216,7 @@ func (circle *Circle) SetDifficulty(diff *difficulty.Difficulty) {
circle.sprites = append(circle.sprites, circle.approachCircle)

if !diff.CheckModActive(difficulty.Hidden) || circle.HitObjectID == 0 {
circle.approachCircle.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, startTime, math.Min(endTime, endTime-diff.Preempt+diff.TimeFadeIn*2), 0.0, 0.9))
circle.approachCircle.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, startTime, min(endTime, endTime-diff.Preempt+diff.TimeFadeIn*2), 0.0, 0.9))
circle.approachCircle.AddTransform(animation.NewSingleTransform(animation.Fade, easing.Linear, endTime, endTime, 0.0, 0.0))

circle.approachCircle.AddTransform(animation.NewSingleTransform(animation.Scale, easing.Linear, startTime, endTime, 4.0, 1.0))
Expand Down
Loading

0 comments on commit 59350ce

Please sign in to comment.