Skip to content

Commit 59350ce

Browse files
authored
Merge pull request #340 from Wieku/dev
0.9.0
2 parents 75c5e4f + 0096034 commit 59350ce

File tree

115 files changed

+1120
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1120
-794
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install golang
3131
uses: actions/setup-go@v3
3232
with:
33-
go-version: '1.19.1'
33+
go-version: '1.21.0'
3434
cache: true
3535

3636
- name: Build danser
@@ -67,7 +67,7 @@ jobs:
6767
- name: Install golang
6868
uses: actions/setup-go@v3
6969
with:
70-
go-version: '1.19.1'
70+
go-version: '1.21.0'
7171
cache: true
7272

7373
- name: Build danser

app/app.go

Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import (
55
"encoding/json"
66
"flag"
77
"fmt"
8-
"github.com/dustin/go-humanize"
98
"github.com/faiface/mainthread"
109
"github.com/go-gl/gl/v3.3-core/gl"
1110
"github.com/go-gl/glfw/v3.3/glfw"
12-
"github.com/shirou/gopsutil/cpu"
13-
"github.com/shirou/gopsutil/host"
14-
"github.com/shirou/gopsutil/mem"
1511
"github.com/wieku/danser-go/app/audio"
1612
"github.com/wieku/danser-go/app/beatmap"
1713
difficulty2 "github.com/wieku/danser-go/app/beatmap/difficulty"
@@ -34,19 +30,16 @@ import (
3430
"github.com/wieku/danser-go/framework/graphics/buffer"
3531
"github.com/wieku/danser-go/framework/graphics/font"
3632
"github.com/wieku/danser-go/framework/graphics/viewport"
37-
"github.com/wieku/danser-go/framework/math/mutils"
3833
"github.com/wieku/danser-go/framework/math/vector"
3934
"github.com/wieku/danser-go/framework/platform"
4035
"github.com/wieku/danser-go/framework/qpc"
4136
"github.com/wieku/danser-go/framework/statistic"
4237
"github.com/wieku/danser-go/framework/util"
4338
"github.com/wieku/rplpa"
44-
"io"
4539
"io/ioutil"
4640
"log"
4741
"math"
4842
"os"
49-
"path/filepath"
5043
"runtime"
5144
"strings"
5245
"time"
@@ -253,6 +246,8 @@ func run() {
253246

254247
newSettings := settings.LoadSettings(*settingsVersion)
255248

249+
log.Println("Current config:", settings.GetCompressedString())
250+
256251
if !newSettings && len(os.Args) == 1 {
257252
platform.OpenURL("https://youtu.be/dQw4w9WgXcQ")
258253
closeAfterSettingsLoad = true
@@ -334,6 +329,10 @@ func run() {
334329
panic("Failed to initialize GLFW: " + err.Error())
335330
}
336331

332+
if !closeAfterSettingsLoad {
333+
log.Println("GLFW Initialized!")
334+
}
335+
337336
platform.SetupContext()
338337

339338
glfw.WindowHint(glfw.Resizable, glfw.False)
@@ -393,6 +392,8 @@ func run() {
393392
settings.SKIP = false
394393
}
395394

395+
log.Println("Creating window...")
396+
396397
if settings.Graphics.Fullscreen {
397398
glfw.WindowHint(glfw.RedBits, monitor.GetVideoMode().RedBits)
398399
glfw.WindowHint(glfw.GreenBits, monitor.GetVideoMode().GreenBits)
@@ -426,7 +427,7 @@ func run() {
426427

427428
win.MakeContextCurrent()
428429

429-
log.Println("GLFW initialized!")
430+
log.Println("Window created!")
430431

431432
err = platform.GLInit(*gldebug)
432433
if err != nil {
@@ -538,7 +539,7 @@ func mainLoopRecord() {
538539

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

541-
updateFPS := math.Max(fps, 1000)
542+
updateFPS := max(fps, 1000)
542543
updateDelta := 1000 / updateFPS
543544
fpsDelta := 1000 / fps
544545
audioDelta := 1000.0 / audioFPS
@@ -653,7 +654,7 @@ func mainLoopNormal() {
653654
case glfw.KeyEscape:
654655
win.SetShouldClose(true)
655656
case glfw.KeyMinus:
656-
settings.DIVIDES = mutils.Max(1, settings.DIVIDES-1)
657+
settings.DIVIDES = max(1, settings.DIVIDES-1)
657658
case glfw.KeyEqual:
658659
settings.DIVIDES += 1
659660
case glfw.KeyO:
@@ -773,35 +774,6 @@ func checkForUpdates() {
773774
}
774775
}
775776

776-
func printPlatformInfo() {
777-
const unknown = "Unknown"
778-
779-
osName, cpuName, ramAmount := unknown, unknown, unknown
780-
781-
hStat, err := host.Info()
782-
if err == nil {
783-
osName = hStat.Platform + " " + hStat.PlatformVersion
784-
}
785-
786-
cStats, err := cpu.Info()
787-
if err == nil && len(cStats) > 0 {
788-
cpuName = fmt.Sprintf("%s, %d cores", strings.TrimSpace(cStats[0].ModelName), cStats[0].Cores)
789-
}
790-
791-
mStat, err := mem.VirtualMemory()
792-
if err == nil {
793-
ramAmount = humanize.IBytes(mStat.Total)
794-
}
795-
796-
log.Println("-------------------------------------------------------------------")
797-
log.Println("danser-go version:", build.VERSION)
798-
log.Println("Ran using:", os.Args)
799-
log.Println("OS: ", osName)
800-
log.Println("CPU:", cpuName)
801-
log.Println("RAM:", ramAmount)
802-
log.Println("-------------------------------------------------------------------")
803-
}
804-
805777
func Run() {
806778
defer func() {
807779
var err any
@@ -816,18 +788,7 @@ func Run() {
816788

817789
goroutines.SetCrashHandler(closeHandler)
818790

819-
log.Println("danser-go version:", build.VERSION)
820-
821-
file, err := os.Create(filepath.Join(env.DataDir(), "danser.log"))
822-
if err != nil {
823-
panic(err)
824-
}
825-
826-
log.SetOutput(file)
827-
828-
printPlatformInfo()
829-
830-
log.SetOutput(io.MultiWriter(os.Stdout, file))
791+
platform.StartLogging("danser")
831792

832793
platform.DisableQuickEdit()
833794

app/audio/osuaudio.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func PlaySample(sampleSet, additionSet, hitsound, index int, volume float64, obj
6868
additionSet = sampleSet
6969
}
7070

71-
volume = mutils.Max(volume, 0.08)
71+
volume = max(volume, 0.08)
7272

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

100100
if settings.Audio.IgnoreBeatmapSampleVolume {

app/beatmap/beatmap.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package beatmap
22

33
import (
4+
"cmp"
45
"github.com/wieku/danser-go/app/audio"
56
"github.com/wieku/danser-go/app/beatmap/difficulty"
67
"github.com/wieku/danser-go/app/beatmap/objects"
7-
"golang.org/x/exp/slices"
88
"math"
9+
"slices"
910
"strconv"
1011
"strings"
1112
"time"
@@ -107,8 +108,8 @@ func (beatMap *BeatMap) Update(time float64) {
107108
if toRemove > 0 {
108109
beatMap.processed = append(beatMap.processed, beatMap.Queue[:toRemove]...)
109110

110-
slices.SortFunc(beatMap.processed, func(a, b objects.IHitObject) bool {
111-
return a.GetEndTime() < b.GetEndTime()
111+
slices.SortFunc(beatMap.processed, func(a, b objects.IHitObject) int {
112+
return cmp.Compare(a.GetEndTime(), b.GetEndTime())
112113
})
113114

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

148149
if !math.IsNaN(bpm) && bpm >= 0 {
149150
rBPM := 60000 / bpm
150-
beatMap.MinBPM = math.Min(beatMap.MinBPM, rBPM)
151-
beatMap.MaxBPM = math.Max(beatMap.MaxBPM, rBPM)
151+
beatMap.MinBPM = min(beatMap.MinBPM, rBPM)
152+
beatMap.MaxBPM = max(beatMap.MaxBPM, rBPM)
152153
}
153154

154155
signature := 4

app/beatmap/difficulty/difficulty.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ func (diff *Difficulty) calculate() {
7676
hpDrain, cs, od, ar := diff.hp, diff.cs, diff.od, diff.ar
7777

7878
if diff.Mods&HardRock > 0 {
79-
ar = math.Min(ar*1.4, 10)
80-
cs = math.Min(cs*1.3, 10)
81-
od = math.Min(od*1.4, 10)
82-
hpDrain = math.Min(hpDrain*1.4, 10)
79+
ar = min(ar*1.4, 10)
80+
cs = min(cs*1.3, 10)
81+
od = min(od*1.4, 10)
82+
hpDrain = min(hpDrain*1.4, 10)
8383
}
8484

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

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

102102
diff.Hit50U = DifficultyRate(od, 200, 150, 100)
103103
diff.Hit100U = DifficultyRate(od, 140, 100, 60)
@@ -146,7 +146,7 @@ func (diff *Difficulty) GetScoreMultiplier() float64 {
146146
if diff.Speed >= 0.75 {
147147
baseMultiplier *= 0.3 + 0.7*(1-(1-diff.Speed)/0.25)
148148
} else {
149-
baseMultiplier *= math.Max(0, 0.3*(1-(0.75-diff.Speed)/0.75))
149+
baseMultiplier *= max(0, 0.3*(1-(0.75-diff.Speed)/0.75))
150150
}
151151
}
152152

app/beatmap/objects/circle.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ func (circle *Circle) SetDifficulty(diff *difficulty.Difficulty) {
196196
circle.reverseArrow = sprite.NewSpriteSingle(skin.GetTexture("reversearrow"), 0, vector.NewVec2d(0, 0), vector.Centre)
197197
circle.reverseArrow.SetAlpha(0)
198198

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

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

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

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

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

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

0 commit comments

Comments
 (0)