Skip to content

Commit bbbb7ac

Browse files
committed
Merge branch 'master' into GLES
# Conflicts: # src/ru/nsu/ccfit/zuev/osu/MainActivity.java
2 parents c3d3bf7 + da55c4f commit bbbb7ac

27 files changed

Lines changed: 360 additions & 224 deletions

res/layout/loading_badge_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
tools:background="#FFF">
99

1010
<LinearLayout
11-
android:id="@+id/container"
1211
android:layout_width="wrap_content"
1312
android:layout_height="wrap_content"
1413
android:layout_margin="16dp"

src/com/osudroid/beatmaplisting/BeatmapListing.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ class BeatmapListing : BaseFragment(),
162162
.setOnSelectListener { value ->
163163
value as Int
164164
if (value != mirror.ordinal) {
165-
Config.setInt("beatmapMirror", value)
166165
mirror = BeatmapMirror.entries[Config.getInt("beatmapMirror", 0)]
167166

168167
logoView.text = mirror.description
@@ -338,7 +337,11 @@ class BeatmapListing : BaseFragment(),
338337
/**
339338
* The current selected beatmap mirror.
340339
*/
341-
var mirror = BeatmapMirror.entries[Config.getInt("beatmapMirror", 0)]
340+
var mirror
341+
get() = BeatmapMirror.entries[Config.getInt("beatmapMirror", 0)]
342+
set(value) {
343+
Config.setInt("beatmapMirror", value.ordinal)
344+
}
342345

343346
/**
344347
* Whether is a beatmap preview music playing or not.

src/com/osudroid/difficulty/attributes/TimedDifficultyAttributes.kt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,25 @@ class TimedDifficultyAttributes<TAttributes : DifficultyAttributes>(
1818
* The attributes.
1919
*/
2020
@JvmField
21-
val attributes: TAttributes
22-
) {
23-
operator fun compareTo(other: TimedDifficultyAttributes<TAttributes>) = time.compareTo(other.time)
21+
val attributes: TAttributes,
22+
23+
/**
24+
* The number of sliders in the beatmap up to this point.
25+
*/
26+
@JvmField
27+
val sliderCount: Int = 0,
28+
29+
/**
30+
* The number of slider ticks in the beatmap up to this point.
31+
*/
32+
@JvmField
33+
val sliderTickCount: Int = 0,
34+
35+
/**
36+
* The number of slider repeats in the beatmap up to this point.
37+
*/
38+
@JvmField
39+
val sliderRepeatCount: Int = 0
40+
) : Comparable<TimedDifficultyAttributes<TAttributes>> {
41+
override fun compareTo(other: TimedDifficultyAttributes<TAttributes>) = time.compareTo(other.time)
2442
}

src/com/osudroid/difficulty/calculator/DifficultyCalculator.kt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ abstract class DifficultyCalculator<TBeatmap : PlayableBeatmap, TObject : Diffic
179179
skills,
180180
difficultyObjects.sliceArray(0..<currentIndex),
181181
false
182-
)
182+
),
183+
progressiveBeatmap.hitObjects.sliderCount,
184+
progressiveBeatmap.hitObjects.sliderTickCount,
185+
progressiveBeatmap.hitObjects.sliderRepeatCount
183186
)
184187
}
185188

@@ -255,14 +258,24 @@ private class ProgressiveCalculationBeatmap(
255258
override fun add(obj: HitObject) {
256259
super.add(obj)
257260

258-
maxCombo += if (obj is Slider) obj.nestedHitObjects.size else 1
261+
if (obj is Slider) {
262+
maxCombo += obj.nestedHitObjects.size
263+
sliderRepeatCount += obj.repeatCount
264+
} else {
265+
maxCombo++
266+
}
259267
}
260268

261269
override fun remove(obj: HitObject): Boolean {
262270
val removed = super.remove(obj)
263271

264272
if (removed) {
265-
maxCombo -= if (obj is Slider) obj.nestedHitObjects.size else 1
273+
if (obj is Slider) {
274+
maxCombo -= obj.nestedHitObjects.size
275+
sliderRepeatCount -= obj.repeatCount
276+
} else {
277+
maxCombo--
278+
}
266279
}
267280

268281
return removed
@@ -272,7 +285,12 @@ private class ProgressiveCalculationBeatmap(
272285
val removed = super.remove(index)
273286

274287
if (removed != null) {
275-
maxCombo -= if (removed is Slider) removed.nestedHitObjects.size else 1
288+
if (removed is Slider) {
289+
maxCombo -= removed.nestedHitObjects.size
290+
sliderRepeatCount -= removed.repeatCount
291+
} else {
292+
maxCombo--
293+
}
276294
}
277295

278296
return removed

src/com/osudroid/difficulty/calculator/DroidPerformanceCalculationParameters.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.osudroid.difficulty.calculator
22

3-
import com.osudroid.beatmaps.IBeatmap
43
import com.osudroid.replay.SliderCheesePenalty
54
import ru.nsu.ccfit.zuev.osu.scoring.StatisticV2
65

@@ -26,13 +25,13 @@ class DroidPerformanceCalculationParameters : PerformanceCalculationParameters()
2625
@JvmField
2726
var totalScore = 0
2827

29-
override fun populate(beatmap: IBeatmap, stat: StatisticV2) {
30-
super.populate(beatmap, stat)
28+
override fun populate(stat: StatisticV2, sliderCount: Int, sliderTickCount: Int, sliderRepeatCount: Int) {
29+
super.populate(stat, sliderCount, sliderTickCount, sliderRepeatCount)
3130

3231
totalScore = stat.totalScoreWithMultiplier
3332

3433
comboBreakingSliderNestedMisses = if (stat.sliderHeadHits >= 0 && stat.sliderTickHits >= 0 && stat.sliderRepeatHits >= 0) {
35-
beatmap.hitObjects.sliderCount + beatmap.hitObjects.sliderTickCount + beatmap.hitObjects.sliderRepeatCount -
34+
sliderCount + sliderTickCount + sliderRepeatCount -
3635
(stat.sliderHeadHits + stat.sliderTickHits + stat.sliderRepeatHits)
3736
} else null
3837
}

src/com/osudroid/difficulty/calculator/PerformanceCalculationParameters.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,18 @@ open class PerformanceCalculationParameters(
6868
* @param beatmap The [IBeatmap] to populate this [PerformanceCalculationParameters] with.
6969
* @param stat The [StatisticV2] to populate this [PerformanceCalculationParameters]
7070
*/
71-
open fun populate(beatmap: IBeatmap, stat: StatisticV2) {
71+
open fun populate(beatmap: IBeatmap, stat: StatisticV2) =
72+
populate(stat, beatmap.hitObjects.sliderCount, beatmap.hitObjects.sliderTickCount, beatmap.hitObjects.sliderRepeatCount)
73+
74+
open fun populate(stat: StatisticV2, sliderCount: Int, sliderTickCount: Int, sliderRepeatCount: Int) {
7275
maxCombo = stat.getScoreMaxCombo()
7376
countGreat = stat.hit300
7477
countOk = stat.hit100
7578
countMeh = stat.hit50
7679
countMiss = stat.misses
7780

7881
nonComboBreakingSliderNestedMisses =
79-
if (stat.sliderEndHits >= 0) beatmap.hitObjects.sliderCount - stat.sliderEndHits else null
82+
if (stat.sliderEndHits >= 0) sliderCount - stat.sliderEndHits else null
8083
}
8184

8285
/**
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package com.osudroid.difficulty.calculator
22

3-
import com.osudroid.beatmaps.IBeatmap
43
import ru.nsu.ccfit.zuev.osu.scoring.StatisticV2
54

65
/**
76
* A class for specifying parameters for osu!standard performance calculation.
87
*/
98
class StandardPerformanceCalculationParameters : PerformanceCalculationParameters() {
10-
override fun populate(beatmap: IBeatmap, stat: StatisticV2) {
11-
super.populate(beatmap, stat)
9+
override fun populate(stat: StatisticV2, sliderCount: Int, sliderTickCount: Int, sliderRepeatCount: Int) {
10+
super.populate(stat, sliderCount, sliderTickCount, sliderRepeatCount)
1211

1312
comboBreakingSliderNestedMisses = if (stat.sliderTickHits >= 0 && stat.sliderRepeatHits >= 0) {
14-
beatmap.hitObjects.sliderTickCount + beatmap.hitObjects.sliderRepeatCount -
15-
(stat.sliderTickHits + stat.sliderRepeatHits)
13+
sliderTickCount + sliderRepeatCount - (stat.sliderTickHits + stat.sliderRepeatHits)
1614
} else null
1715
}
1816
}

src/com/osudroid/math/Interpolation.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,19 @@ object Interpolation {
5252
* @return The output of the reverse linear interpolation function calculated at [x].
5353
*/
5454
@JvmStatic
55-
fun reverseLinear(x: Double, start: Double, end: Double) =
56-
((x - start) / (end - start)).coerceIn(0.0, 1.0)
55+
fun reverseLinear(x: Float, start: Float, end: Float) = ((x - start) / (end - start)).coerceIn(0f, 1f)
56+
57+
/**
58+
* Calculates the reverse [linear interpolation](https://en.wikipedia.org/wiki/Linear_interpolation)
59+
* function at [x].
60+
*
61+
* @param x The value to calculate the function for.
62+
* @param start The [x] value at which the function returns 0.
63+
* @param end The [x] value at which the function returns 1.
64+
* @return The output of the reverse linear interpolation function calculated at [x].
65+
*/
66+
@JvmStatic
67+
fun reverseLinear(x: Double, start: Double, end: Double) = ((x - start) / (end - start)).coerceIn(0.0, 1.0)
5768

5869
/**
5970
* Interpolates between [start] and [end] using a given [base] and [exponent].

src/com/osudroid/ui/v1/LoadingBadgeFragment.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
package com.osudroid.ui.v1
22

33
import android.view.View
4-
import android.widget.LinearLayout
5-
import android.widget.RelativeLayout
64
import android.widget.TextView
7-
import androidx.core.view.updateLayoutParams
85
import com.edlplan.ui.fragment.BaseFragment
96
import com.google.android.material.progressindicator.CircularProgressIndicator
10-
import com.reco1l.toolkt.android.dp
11-
import kotlin.math.roundToInt
12-
import ru.nsu.ccfit.zuev.osu.Config
13-
import ru.nsu.ccfit.zuev.osu.ResourceManager
147
import ru.nsu.ccfit.zuev.osuplus.R
158

169
class LoadingBadgeFragment : BaseFragment() {
@@ -64,22 +57,6 @@ class LoadingBadgeFragment : BaseFragment() {
6457
}
6558

6659
override fun onLoadView() {
67-
findViewById<LinearLayout>(R.id.container)!!.updateLayoutParams<RelativeLayout.LayoutParams> {
68-
var fpsHeight = 0
69-
70-
if (Config.isShowFPS()) {
71-
val font = ResourceManager.getInstance().getFont("smallFont")
72-
73-
if (font != null) {
74-
val scale = resources.displayMetrics.widthPixels.toFloat() / Config.getRES_WIDTH()
75-
76-
fpsHeight = ((font.lineHeight + 4f) * scale).roundToInt()
77-
}
78-
}
79-
80-
bottomMargin = 16f.dp.roundToInt() + fpsHeight
81-
}
82-
8360
progressView = findViewById(R.id.progress)!!
8461
messageView = findViewById(R.id.message)!!
8562
textView = findViewById(R.id.text)!!

src/com/osudroid/ui/v2/GameLoaderScene.kt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package com.osudroid.ui.v2
33
import com.edlplan.framework.easing.*
44
import com.osudroid.data.*
55
import com.osudroid.multiplayer.*
6+
import com.osudroid.multiplayer.api.RoomAPI
7+
import com.osudroid.multiplayer.api.data.PlayerStatus
68
import com.osudroid.utils.ModHashMap
79
import com.reco1l.andengine.*
810
import com.reco1l.andengine.component.*
@@ -130,31 +132,29 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
130132
anchor = Anchor.BottomLeft
131133
origin = Anchor.BottomLeft
132134
x = 60f
133-
y = if (Multiplayer.isMultiplayer) -60f else -30f
135+
y = -30f
134136
spacing = 30f
135137

136138
+CircularProgressBar().apply {
137139
width = 32f
138140
height = 32f
139141
}
140142

141-
if (!Multiplayer.isMultiplayer) {
142-
+UITextButton().apply {
143-
text = "Back"
143+
+UITextButton().apply {
144+
text = "Back"
144145

145-
leadingIcon = UISprite().apply {
146-
textureRegion = ResourceManager.getInstance().getTexture("back-arrow")
147-
width = 28f
148-
height = 28f
149-
}
150-
151-
onActionUp = {
152-
ResourceManager.getInstance().getSound("click-short-confirm")?.play()
153-
cancel()
154-
}
146+
leadingIcon = UISprite().apply {
147+
textureRegion = ResourceManager.getInstance().getTexture("back-arrow")
148+
width = 28f
149+
height = 28f
150+
}
155151

156-
onActionCancel = { ResourceManager.getInstance().getSound("click-short")?.play() }
152+
onActionUp = {
153+
ResourceManager.getInstance().getSound("click-short-confirm")?.play()
154+
cancel()
157155
}
156+
157+
onActionCancel = { ResourceManager.getInstance().getSound("click-short")?.play() }
158158
}
159159
}
160160

@@ -163,15 +163,18 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
163163
}
164164

165165
/**
166-
* Cancels loading and goes back to the song menu.
166+
* Cancels loading and goes back to the song menu, or to the multiplayer room if in multiplayer.
167167
*/
168168
fun cancel() {
169+
gameScene.cancelLoading()
170+
169171
if (Multiplayer.isMultiplayer) {
172+
// Inform that the player has canceled loading.
173+
RoomAPI.setPlayerStatus(PlayerStatus.NotReady)
174+
Multiplayer.roomScene?.show()
170175
return
171176
}
172177

173-
gameScene.cancelLoading()
174-
175178
val global = GlobalManager.getInstance()
176179
val songMenu = global.songMenu
177180
val selectedBeatmap = songMenu.selectedBeatmap

0 commit comments

Comments
 (0)