Skip to content

Commit

Permalink
Merge pull request #282 from Wieku/dev
Browse files Browse the repository at this point in the history
0.8.0
  • Loading branch information
Wieku authored Sep 18, 2022
2 parents b3d070d + eca94c3 commit fe48533
Show file tree
Hide file tree
Showing 82 changed files with 2,367 additions and 1,047 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build danser

on:
workflow_dispatch:
inputs:
version:
description: 'Danser version'
type: string
required: true
draft:
description: 'Create draft release'
type: boolean
required: false
default: true

jobs:
build_windows:
name: Building windows version
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout master branch
uses: actions/checkout@v3

- name: Install winlibs
uses: bwoodsend/setup-winlibs-action@v1

- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '1.19'
cache: true

- name: Build danser
run: |
version="${{ github.event.inputs.version }}"
./dist-win.sh $version
if [ ! -f "dist/artifacts/danser-${version// /-s}-win.zip" ]; then
echo "Danser failed to build"
exit 1
fi
id: build

- name: Upload artifact
uses: actions/upload-artifact@v3
if: ${{ !failure() && steps.build.conclusion != 'failure' }}
with:
name: danser
path: dist/artifacts/*

build_linux:
name: Building linux version
runs-on: ubuntu-latest
steps:
- name: Checkout master branch
uses: actions/checkout@v3

- name: Install needed packages
run: sudo apt-get install xorg-dev libgl1-mesa-dev libgtk-3-dev

- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '1.19'
cache: true

- name: Build danser
run: |
version="${{ github.event.inputs.version }}"
chmod +x dist-linux.sh
./dist-linux.sh $version
if [ ! -f "dist/artifacts/danser-${version// /-s}-linux.zip" ]; then
echo "Danser failed to build"
exit 1
fi
id: build

- name: Upload artifact
uses: actions/upload-artifact@v3
if: ${{ !failure() && steps.build.conclusion != 'failure' }}
with:
name: danser
path: dist/artifacts/*

publish_release:
name: Publish draft release
if: ${{ !cancelled() && needs.build_windows.result == 'success' && needs.build_linux.result == 'success' && github.event.inputs.draft }}
needs: [build_windows, build_linux]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: danser
path: artifacts
- name: Create release
id: create_release
run: |
set -xe
shopt -s nullglob
version="${{ github.event.inputs.version }}"
NAME="${version// / snapshot }"
TAGNAME="${version// /-s}"
hub release create --draft $(for a in artifacts/*.{zip,tar.xz}; do echo -a $a; done) -m "$NAME" -t "master" "$TAGNAME"
env:
GITHUB_TOKEN: ${{ github.token }}
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ You need to clone it or download as a .zip (and unpack it to desired directory)

#### Prerequisites

* [64-bit go (1.18 at least)](https://golang.org/dl/)
* gcc (Linux/Unix), [WinLibs](http://winlibs.com/) (Windows, TDM-GCC won't work, mingw-w64 is outdated)
* OpenGL library (shipped with drivers)
* xorg-dev (Linux)
* libgtk-3 and libgtk-3-dev (Linux)
* [64-bit go (1.19 at least)](https://go.dev/dl/)
* gcc/g++ (Linux/Unix), [WinLibs](http://winlibs.com/) (Windows, TDM-GCC won't work, mingw-w64 is outdated)
* OpenGL library (shipped with drivers, `libgl1-mesa-dev` when building on Linux servers)
* xorg-dev, libgtk-3 and libgtk-3-dev (Linux)

#### Building and running the project

Expand Down
112 changes: 31 additions & 81 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
"runtime"
"strings"
"time"
"unsafe"
)

const (
Expand Down Expand Up @@ -84,6 +83,8 @@ var screenshotTime float64

var preciseProgress bool

var monitorHz int

func run() {
defer func() {
if err := recover(); err != nil {
Expand All @@ -109,16 +110,16 @@ func run() {
creator := flag.String("creator", "", creatorDesc)
flag.StringVar(creator, "c", "", creatorDesc+shorthand)

settingsVersion := flag.String("settings", "", "Specify settings version, -settings=abc means that settings/abc.json will be loaded")
settingsVersion := flag.String("settings", "", "Specify settings version, -settings=b/abc means that settings/b/abc.json will be loaded. \"Credentials\"")
cursors := flag.Int("cursors", 1, "How many repeated cursors should be visible, recommended 2 for mirror, 8 for mandala")
tag := flag.Int("tag", 1, "How many cursors should be \"playing\" specific map. 2 means that 1st cursor clicks the 1st object, 2nd clicks 2nd object, 1st clicks 3rd and so on")

knockout := flag.Bool("knockout", false, "Use knockout feature")
knockout2 := flag.String("knockout2", "", "Use knockout feature, but using compatible replays provided in a JSON list")
knockout := flag.Bool("knockout", false, "Use (classic) knockout feature. Replays are sourced from \"replays/{a}\" where {a} is an md5 hash of .osu file. Danser automatically organizes replay files put directly in \"replays\", using maps' md5s provided by the replay files.")
knockout2 := flag.String("knockout2", "", "Use (new) knockout feature, JSON list of paths to compatible replay files has to be provided. \"Knockout.ExcludeMods\" and \"Knockout.MaxPlayers\" options are ignored, they have to be filtered beforehand.")

speed := flag.Float64("speed", 1.0, "Specify music's speed, set to 1.5 to have DoubleTime mod experience")
pitch := flag.Float64("pitch", 1.0, "Specify music's pitch, set to 1.5 with -speed=1.5 to have Nightcore mod experience")
debug := flag.Bool("debug", false, "Show info about map and rendering engine, overrides Graphics.ShowFPS setting")
debug := flag.Bool("debug", false, "Show info about map and rendering engine, overrides Graphics.ShowFPS setting. Ignored in record/screenshot modes.")

gldebug := flag.Bool("gldebug", false, "Turns on OpenGL debug logging, may reduce performance heavily")

Expand All @@ -134,14 +135,14 @@ func run() {
out := flag.String("out", "", "If -ss flag is used, sets the name of screenshot, extension is PNG. If not, it overrides -record flag, specifies the name of recorded video file, extension is managed by settings")
ss := flag.Float64("ss", math.NaN(), "Screenshot mode. Snap single frame from danser at given time in seconds. Specify the name of file by -out, resolution is managed by Recording settings")

mods := flag.String("mods", "", "Specify beatmap/play mods. If NC/DT/HT is selected, overrides -speed and -pitch flags")
mods := flag.String("mods", "", "Specify beatmap/play mods")

replay := flag.String("replay", "", replayDesc)
flag.StringVar(replay, "r", "", replayDesc+shorthand)

skin := flag.String("skin", "", "Replace Skin.CurrentSkin setting temporarily")

noDbCheck := flag.Bool("nodbcheck", false, "Don't validate the database and import new beatmaps if there are any. Useful for slow drives.")
noDbCheck := flag.Bool("nodbcheck", false, "Don't validate the database and only import new beatmap sets if there are any. Useful for slow drives.")
noUpdCheck := flag.Bool("noupdatecheck", strings.HasPrefix(env.LibDir(), "/usr/lib/"), "Don't check for updates. Speeds up startup if older version of danser is needed for various reasons. Has no effect if danser is running as a linux package")

ar := flag.Float64("ar", math.NaN(), "Modify map's AR, only in cursordance/play modes")
Expand Down Expand Up @@ -334,17 +335,17 @@ func run() {
panic("Failed to initialize GLFW: " + err.Error())
}

glfw.WindowHint(glfw.ContextVersionMajor, 3)
glfw.WindowHint(glfw.ContextVersionMinor, 3)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
platform.SetupContext()

glfw.WindowHint(glfw.Resizable, glfw.False)
glfw.WindowHint(glfw.Samples, 0)
glfw.WindowHint(glfw.Visible, glfw.False)

monitor := glfw.GetPrimaryMonitor()
mWidth, mHeight := monitor.GetVideoMode().Width, monitor.GetVideoMode().Height

monitorHz = monitor.GetVideoMode().RefreshRate

if newSettings {
settings.Graphics.SetDefaults(int64(mWidth), int64(mHeight))
settings.Save()
Expand Down Expand Up @@ -437,51 +438,9 @@ func run() {

log.Println("GLFW initialized!")

gl.Init()

extensionCheck()

glVendor := C.GoString((*C.char)(unsafe.Pointer(gl.GetString(gl.VENDOR))))
glRenderer := C.GoString((*C.char)(unsafe.Pointer(gl.GetString(gl.RENDERER))))
glVersion := C.GoString((*C.char)(unsafe.Pointer(gl.GetString(gl.VERSION))))
glslVersion := C.GoString((*C.char)(unsafe.Pointer(gl.GetString(gl.SHADING_LANGUAGE_VERSION))))

// HACK HACK HACK: please see github.com/wieku/danser-go/framework/graphics/buffer.IsIntel for more info
if strings.Contains(strings.ToLower(glVendor), "intel") {
buffer.IsIntel = true
}

var extensions string

var numExtensions int32
gl.GetIntegerv(gl.NUM_EXTENSIONS, &numExtensions)

for i := int32(0); i < numExtensions; i++ {
extensions += C.GoString((*C.char)(unsafe.Pointer(gl.GetStringi(gl.EXTENSIONS, uint32(i)))))
extensions += " "
}

log.Println("GL Vendor: ", glVendor)
log.Println("GL Renderer: ", glRenderer)
log.Println("GL Version: ", glVersion)
log.Println("GLSL Version: ", glslVersion)
log.Println("GL Extensions:", extensions)
log.Println("OpenGL initialized!")

if *gldebug {
gl.Enable(gl.DEBUG_OUTPUT)
gl.DebugMessageCallback(func(
source uint32,
gltype uint32,
id uint32,
severity uint32,
length int32,
message string,
userParam unsafe.Pointer) {
log.Println("GL:", message)
}, gl.Ptr(nil))

gl.DebugMessageControl(gl.DONT_CARE, gl.DONT_CARE, gl.DONT_CARE, 0, nil, true)
err = platform.GLInit(*gldebug)
if err != nil {
panic("Failed to initialize OpenGL: " + err.Error())
}

if !settings.RECORD {
Expand Down Expand Up @@ -701,14 +660,20 @@ func mainLoopNormal() {
win.SetKeyCallback(func(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
if action == glfw.Press {
switch key {
case glfw.KeyF2:
scheduleScreenshot = true
case glfw.KeyEscape:
win.SetShouldClose(true)
case glfw.KeyMinus:
settings.DIVIDES = mutils.Max(1, settings.DIVIDES-1)
case glfw.KeyEqual:
settings.DIVIDES += 1
case glfw.KeyO:
if mods == glfw.ModControl {
log.Println("Launcher: Open settings")
}
default:
if platform.GetKeyName(key, scancode) == settings.Input.ScreenshotKey {
scheduleScreenshot = true
}
}
}

Expand Down Expand Up @@ -741,6 +706,13 @@ func mainLoopNormal() {
win.SwapBuffers()

if !settings.Graphics.VSync {
fCap := int(settings.Graphics.FPSCap)

if fCap < 0 {
fCap = -fCap*monitorHz
}

limiter.FPS = fCap
limiter.Sync()
}

Expand All @@ -750,28 +722,6 @@ func mainLoopNormal() {
settings.CloseWatcher()
}

func extensionCheck() {
extensions := []string{
"GL_ARB_clear_texture",
"GL_ARB_direct_state_access",
"GL_ARB_texture_storage",
"GL_ARB_vertex_attrib_binding",
"GL_ARB_buffer_storage",
}

var notSupported []string

for _, ext := range extensions {
if !glfw.ExtensionSupported(ext) {
notSupported = append(notSupported, ext)
}
}

if len(notSupported) > 0 {
panic(fmt.Sprintf("Your GPU does not support one or more required OpenGL extensions: %s. Please update your graphics drivers or upgrade your GPU", notSupported))
}
}

func pushFrame() {
statistic.Reset()

Expand Down Expand Up @@ -825,7 +775,7 @@ func checkForUpdates() {
log.Println("You're using the newest version of danser.")
case utils.Snapshot:
log.Println("You're using a snapshot version of danser.")
log.Println("For newer version of snapshots please visit an official danser discord server at:", url)
log.Println("For newer version of snapshots please visit the official danser discord server at:", url)
case utils.UpdateAvailable:
log.Println("You're using an older version of danser.")
log.Println("You can download a newer version here:", url)
Expand Down
7 changes: 7 additions & 0 deletions app/audio/osuaudio.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,10 @@ func LoadBeatmapSamples(dir string) {
func LoadSample(name string) *bass.Sample {
return skin.GetSample(name)
}

func PlayFailSound() {
sample := LoadSample("failsound")
if sample != nil {
sample.Play()
}
}
2 changes: 1 addition & 1 deletion app/beatmap/objects/circle.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (circle *Circle) PlaySound() {
audio.PlaySample(sampleSet, circle.BasicHitSound.AdditionSet, circle.sample, index, point.SampleVolume, circle.HitObjectID, circle.GetStackedStartPosition().X64())
}

func (circle *Circle) SetTiming(timings *Timings, _ bool) {
func (circle *Circle) SetTiming(timings *Timings, _ int, _ bool) {
circle.Timings = timings
}

Expand Down
4 changes: 2 additions & 2 deletions app/beatmap/objects/hitobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type IHitObject interface {
Update(time float64) bool
SetTiming(timings *Timings, diffCalcOnly bool) //diffCalcOnly skips stables' path generation which is quite memory consuming
SetTiming(timings *Timings, beatmapVersion int, diffCalcOnly bool) //diffCalcOnly skips stables' path generation which is quite memory consuming
UpdateStacking()
SetDifficulty(difficulty *difficulty.Difficulty)

Expand Down Expand Up @@ -94,7 +94,7 @@ type HitObject struct {

func (hitObject *HitObject) Update(_ float64) bool { return true }

func (hitObject *HitObject) SetTiming(_ *Timings, _ bool) {}
func (hitObject *HitObject) SetTiming(_ *Timings, _ int, _ bool) {}

func (hitObject *HitObject) UpdateStacking() {}

Expand Down
Loading

0 comments on commit fe48533

Please sign in to comment.