Skip to content

Commit 4c2f98b

Browse files
committed
Update the game codebase to reflect the engine changes
1 parent d1afd9b commit 4c2f98b

40 files changed

+631
-616
lines changed

src/com/edlplan/osu/support/slider/SliderBody.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ public void setHintColor(Color4 color, float alpha) {
124124
}
125125

126126

127-
public void setBorderWidth(float value) {
127+
public void setTrackBorderWidth(float value) {
128128
borderWidth = value;
129129
}
130130

131-
public void setBorderColor(Color4 color) {
131+
public void setTrackBorderColor(Color4 color) {
132132
border.setColor(color);
133133
}
134134

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import com.reco1l.andengine.container.Orientation
88
import com.reco1l.andengine.container.UILinearContainer
99
import com.reco1l.andengine.container.UIScrollableContainer
1010
import com.reco1l.andengine.text.UIText
11+
import com.reco1l.andengine.theme.FontSize
12+
import com.reco1l.andengine.theme.pct
1113
import com.reco1l.andengine.ui.UIModal
1214
import com.reco1l.framework.Color4
1315
import com.reco1l.framework.math.Vec4
@@ -25,7 +27,6 @@ import com.rian.osu.utils.CircleSizeCalculator
2527
import com.rian.osu.utils.ModUtils
2628
import kotlin.math.roundToInt
2729
import ru.nsu.ccfit.zuev.osu.GlobalManager
28-
import ru.nsu.ccfit.zuev.osu.ResourceManager
2930

3031
/**
3132
* A [UIScene] containing a [UIModal] that shows the attributes of a beatmap, adjusted for the given mods.
@@ -134,15 +135,15 @@ open class BeatmapAttributeDisplay(difficulty: BeatmapDifficulty, mods: Iterable
134135
spacing = 5f
135136

136137
+UIText().apply {
137-
font = ResourceManager.getInstance().getFont("font")
138+
138139
text = name
139-
applyTheme = { color = it.accentColor }
140+
style = { color = it.accentColor }
140141
}
141142

142143
+UIText().apply {
143-
font = ResourceManager.getInstance().getFont("smallFont")
144+
fontSize = FontSize.SM
144145
text = description
145-
applyTheme = { color = it.accentColor }
146+
style = { color = it.accentColor }
146147
}
147148
}
148149

@@ -151,9 +152,9 @@ open class BeatmapAttributeDisplay(difficulty: BeatmapDifficulty, mods: Iterable
151152

152153
metrics.fastForEach { metric ->
153154
+UIText().apply {
154-
font = ResourceManager.getInstance().getFont("smallFont")
155+
fontSize = FontSize.SM
155156
text = "${metric.name}: ${metric.value}"
156-
applyTheme = { color = metric.color ?: (it.accentColor * 0.8f) }
157+
style = { color = metric.color ?: (it.accentColor * 0.8f) }
157158
}
158159
}
159160
}
@@ -164,17 +165,17 @@ open class BeatmapAttributeDisplay(difficulty: BeatmapDifficulty, mods: Iterable
164165

165166
if (originalValue != adjustedValue) {
166167
+UIText().apply {
167-
font = ResourceManager.getInstance().getFont("smallFont")
168+
fontSize = FontSize.SM
168169
text = "This value is being adjusted by mods (${originalValue.roundBy(2)}${adjustedValue.roundBy(2)})."
169-
applyTheme = { color = it.accentColor * 0.6f }
170+
style = { color = it.accentColor * 0.6f }
170171
}
171172
}
172173

173174
additionalInfo.fastForEach { info ->
174175
+UIText().apply {
175-
font = ResourceManager.getInstance().getFont("smallFont")
176+
fontSize = FontSize.SM
176177
text = info
177-
applyTheme = { color = it.accentColor * 0.6f }
178+
style = { color = it.accentColor * 0.6f }
178179
}
179180
}
180181
}
@@ -185,9 +186,8 @@ open class BeatmapAttributeDisplay(difficulty: BeatmapDifficulty, mods: Iterable
185186
private inner class BeatmapAttributeModal : UIModal(
186187
UIScrollableContainer().apply {
187188
scrollAxes = Axes.Y
188-
relativeSizeAxes = Axes.Both
189-
width = 0.8f
190-
height = 0.75f
189+
width = 0.8f.pct
190+
height = 0.75f.pct
191191
anchor = Anchor.Center
192192
origin = Anchor.Center
193193
clipToBounds = true

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.reco1l.andengine.*
77
import com.reco1l.andengine.container.*
88
import com.reco1l.andengine.sprite.*
99
import com.reco1l.andengine.text.*
10+
import com.reco1l.andengine.theme.FontSize
11+
import com.reco1l.andengine.theme.Size
1012
import com.reco1l.andengine.ui.*
1113
import com.reco1l.toolkt.*
1214
import com.rian.osu.*
@@ -40,37 +42,35 @@ class BeatmapInfoLayout : UILinearContainer() {
4042

4143

4244
init {
43-
width = FillParent
45+
width = Size.Full
4446
orientation = Orientation.Vertical
4547
spacing = 6f
4648

47-
flexContainer {
48-
width = FillParent
49+
fillContainer {
50+
width = Size.Full
4951

5052
linearContainer {
51-
flexRules {
52-
grow = 1f
53-
}
53+
width = Size.Full
5454
orientation = Orientation.Vertical
5555

5656
artistText = text {
57-
font = ResourceManager.getInstance().getFont("smallFont")
57+
fontSize = FontSize.SM
5858
text = "Unknown"
59-
applyTheme = { color = it.accentColor * 0.9f}
59+
style = { color = it.accentColor * 0.9f }
6060
}
6161

6262
titleText = text {
63-
width = FillParent
64-
font = ResourceManager.getInstance().getFont("smallFont")
63+
width = Size.Full
64+
fontSize = FontSize.SM
6565
text = "No selected beatmap"
66-
applyTheme = { color = it.accentColor }
66+
style = { color = it.accentColor }
6767
clipToBounds = true
6868
}
6969

7070
versionText = text {
71-
font = ResourceManager.getInstance().getFont("smallFont")
71+
fontSize = FontSize.SM
7272
text = "Unknown"
73-
applyTheme = { color = it.accentColor * 0.8f}
73+
style = { color = it.accentColor * 0.8f }
7474
}
7575
}
7676

@@ -85,15 +85,15 @@ class BeatmapInfoLayout : UILinearContainer() {
8585
lengthText = compoundText {
8686
leadingIcon = UISprite(ResourceManager.getInstance().getTexture("clock"))
8787
text = "00:00"
88-
applyTheme = { color = it.accentColor }
89-
font = ResourceManager.getInstance().getFont("xs")
88+
style = { color = it.accentColor }
89+
fontSize = FontSize.XS
9090
}
9191

9292
bpmText = compoundText {
9393
leadingIcon = UISprite(ResourceManager.getInstance().getTexture("bpm"))
9494
text = "0"
95-
applyTheme = { color = it.accentColor }
96-
font = ResourceManager.getInstance().getFont("xs")
95+
style = { color = it.accentColor }
96+
fontSize = FontSize.XS
9797
}
9898
}
9999

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import com.osudroid.data.*
55
import com.osudroid.multiplayer.*
66
import com.reco1l.andengine.*
77
import com.reco1l.andengine.component.*
8-
import com.reco1l.andengine.component.UIComponent.Companion.FillParent
98
import com.reco1l.andengine.container.*
109
import com.reco1l.andengine.modifier.*
1110
import com.reco1l.andengine.shape.*
1211
import com.reco1l.andengine.sprite.*
12+
import com.reco1l.andengine.theme.FontSize
13+
import com.reco1l.andengine.theme.Size
1314
import com.reco1l.andengine.ui.*
1415
import com.reco1l.andengine.ui.form.*
1516
import com.reco1l.framework.*
@@ -40,24 +41,24 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
4041

4142
// Background
4243
sprite {
43-
width = FillParent
44-
height = FillParent
44+
width = Size.Full
45+
height = Size.Full
4546
scaleType = ScaleType.Crop
4647
textureRegion = ResourceManager.getInstance().getTexture(if (Config.isSafeBeatmapBg()) "menu-background" else "::background")
4748
}
4849

4950
// Dim
5051
dimBox = box {
51-
width = FillParent
52-
height = FillParent
52+
width = Size.Full
53+
height = Size.Full
5354
color = Color4.Black
5455
alpha = 0.7f
5556
}
5657

5758
// Beatmap info
5859
mainContainer = container {
59-
width = FillParent
60-
height = FillParent
60+
width = Size.Full
61+
height = Size.Full
6162
alpha = 0f
6263
scaleX = 0.9f
6364
scaleY = 0.9f
@@ -83,7 +84,7 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
8384
}
8485

8586
text {
86-
font = ResourceManager.getInstance().getFont("smallFont")
87+
fontSize = FontSize.SM
8788
text = StringTable.get(com.osudroid.resources.R.string.epilepsy_warning)
8889
}
8990
}
@@ -98,28 +99,28 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
9899

99100
// Title
100101
text {
101-
font = ResourceManager.getInstance().getFont("bigFont")
102+
fontSize = FontSize.XL
102103
text = beatmapInfo.titleText
103104
width = 700f
104105
clipToBounds = true
105106
autoScrollSpeed = 30f
106-
applyTheme = { color = it.accentColor }
107+
style = { color = it.accentColor }
107108
}
108109

109110
// Difficulty
110111
text {
111-
font = ResourceManager.getInstance().getFont("middleFont")
112+
fontSize = FontSize.LG
112113
text = beatmapInfo.version
113114
width = 700f
114115
clipToBounds = true
115-
applyTheme = { color = it.accentColor }
116+
style = { color = it.accentColor }
116117
}
117118

118119
// Creator
119120
text {
120-
font = ResourceManager.getInstance().getFont("middleFont")
121+
fontSize = FontSize.LG
121122
text = "by ${beatmapInfo.artistText}"
122-
applyTheme = { color = it.accentColor * 0.9f }
123+
style = { color = it.accentColor * 0.9f }
123124
}
124125

125126
// Mods
@@ -240,19 +241,19 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
240241
anchor = Anchor.CenterRight
241242
origin = Anchor.CenterRight
242243
width = 460f
243-
height = FillParent
244+
height = Size.Full
244245
x = -20f
245246
scrollAxes = Axes.Y
246247
alpha = 0.5f
247248

248249
linearContainer {
249-
width = FillParent
250+
width = Size.Full
250251
spacing = 20f
251252
padding = Vec4(0f, 20f)
252253
orientation = Orientation.Vertical
253254

254255
collapsibleCard {
255-
width = FillParent
256+
width = Size.Full
256257
title = "Beatmap"
257258

258259
content.apply {
@@ -308,7 +309,7 @@ class GameLoaderScene(private val gameScene: GameScene, private val beatmapInfo:
308309
}
309310

310311
collapsibleCard {
311-
width = FillParent
312+
width = Size.Full
312313
title = "Settings"
313314

314315
content.apply {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class StarRatingBadge : UIBadge() {
2323
}
2424
}
2525

26-
// Badge color is determined by rating and should not be affected by themes.
27-
override var applyTheme: UIComponent.(Theme) -> Unit = {}
2826

2927
private var ratingChanged = true
3028

3129
init {
30+
// Badge color is determined by rating and should not be affected by themes.
31+
style = {}
3232
text = "0.00"
3333
leadingIcon = UISprite(ResourceManager.getInstance().getTexture("star-xs"))
3434
}
@@ -38,10 +38,9 @@ class StarRatingBadge : UIBadge() {
3838
ratingChanged = false
3939

4040
clearEntityModifiers()
41-
background?.clearEntityModifiers()
4241

4342
text = "%.2f".format(rating)
44-
background?.colorTo(OsuColors.getStarRatingColor(rating), 0.1f)
43+
backgroundColor = OsuColors.getStarRatingColor(rating)
4544

4645
if (rating >= 6.5) {
4746
colorTo(Color4(0xFFFFD966), 0.1f)

src/com/osudroid/ui/v2/hud/HUDElement.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,16 @@ abstract class HUDElement : UIContainer(), IGameplayEvents {
157157
isInEditMode = value
158158

159159
if (value) {
160-
background = UIBox().apply {
161-
color = Color4(0x29F27272)
162-
alpha = 0.15f
163-
}
160+
backgroundColor = Color4(0x29F27272) / 0.15f
164161
editorOverlay = HUDElementOverlay(this)
165162

166163
parent!!.attachChild(editorOverlay!!)
167164
} else {
168165
connectionLine?.detachSelf()
169166
editorOverlay?.detachSelf()
170167

168+
backgroundColor = Color4.Transparent
171169
connectionLine = null
172-
background = null
173170
editorOverlay = null
174171
}
175172
}
@@ -179,8 +176,7 @@ abstract class HUDElement : UIContainer(), IGameplayEvents {
179176
*/
180177
open fun onSelectionStateChange(isSelected: Boolean) {
181178

182-
background?.clearEntityModifiers()
183-
background?.fadeTo(if (isSelected) 0.5f else 0.15f, 0.1f)
179+
backgroundColor /= if (isSelected) 0.5f else 0.15f
184180

185181
editorOverlay?.clearEntityModifiers()
186182
editorOverlay?.fadeTo(if (isSelected) 1f else 0f, 0.1f)

0 commit comments

Comments
 (0)