Skip to content

Commit 960f0c1

Browse files
committed
Merge branch 'engine-scalling' into main-scene-v2
2 parents 61c925f + 5cc5404 commit 960f0c1

37 files changed

Lines changed: 300 additions & 442 deletions

assets/app/changelog.html

Lines changed: 0 additions & 70 deletions
This file was deleted.

res/values/strings_temporary_for_locals.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,9 @@
7070

7171
<string name="opt_remove_sliderlock_spinnerlock_title">Remove slider and spinner lock</string>
7272
<string name="opt_remove_sliderlock_spinnerlock_summary">[UNRANKED] Allow circles and sliders to be hittable when another slider or spinner is currently active.</string>
73+
74+
<string name="mp_room_category_lobby">Lobby</string>
75+
76+
<string name="mp_room_prefer_mod_acronym_title">Prefer mod acronyms over icons</string>
77+
<string name="mp_room_prefer_mod_acronym_summary">Replace mod icons in player cards with mod acronyms</string>
7378
</resources>

res/xml/multiplayer_player_settings.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto">
44

5-
<PreferenceCategory android:title="@string/mp_room_category_teams">
5+
<PreferenceCategory android:title="@string/mp_room_category_lobby">
66

77
<com.reco1l.osu.ui.SelectPreference
88
android:entries="@array/mp_team_names"
99
android:entryValues="@array/mp_team_values"
1010
android:key="player_team"
1111
android:summary="@string/mp_room_category_teams_summary"
1212
android:title="@string/mp_room_category_teams_title"
13-
app:layout="@layout/settings_preference_bottom" />
13+
app:layout="@layout/settings_preference" />
14+
15+
<CheckBoxPreference
16+
android:defaultValue="false"
17+
android:key="player_preferModAcronym"
18+
android:summary="@string/mp_room_prefer_mod_acronym_summary"
19+
android:title="@string/mp_room_prefer_mod_acronym_title"
20+
app:layout="@layout/settings_preference_checkbox_bottom" />
1421

1522
</PreferenceCategory>
1623

src/com/edlplan/replay/OsuDroidReplayPack.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,22 @@ public static byte[] pack(BeatmapInfo beatmapInfo, ScoreInfo scoreInfo) throws E
9595
}
9696

9797
public static ReplayEntry unpack(InputStream raw) throws IOException, JSONException {
98-
ZipInputStream inputStream = new ZipInputStream(raw);
9998
ReplayEntry entry = new ReplayEntry();
10099
Map<String, byte[]> zipEntryMap = new HashMap<>();
101-
for (ZipEntry zipEntry = inputStream.getNextEntry(); zipEntry != null; zipEntry = inputStream.getNextEntry()) {
102-
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
103-
byte[] buffer = new byte[1024];
104-
int l;
105-
while ((l = inputStream.read(buffer)) != -1) {
106-
byteArrayOutputStream.write(buffer, 0, l);
100+
101+
try (var inputStream = new ZipInputStream(raw)) {
102+
for (ZipEntry zipEntry = inputStream.getNextEntry(); zipEntry != null; zipEntry = inputStream.getNextEntry()) {
103+
try (var byteArrayOutputStream = new ByteArrayOutputStream()) {
104+
byte[] buffer = new byte[1024];
105+
int l;
106+
while ((l = inputStream.read(buffer)) != -1) {
107+
byteArrayOutputStream.write(buffer, 0, l);
108+
}
109+
zipEntryMap.put(zipEntry.getName(), byteArrayOutputStream.toByteArray());
110+
System.out.println("解压文件:" + zipEntry.getName() + " size: " + zipEntryMap.get(zipEntry.getName()).length);
111+
}
107112
}
108-
zipEntryMap.put(zipEntry.getName(), byteArrayOutputStream.toByteArray());
109-
System.out.println("解压文件:" + zipEntry.getName() + " size: " + zipEntryMap.get(zipEntry.getName()).length);
110113
}
111-
inputStream.close();
112114

113115
var json = new JSONObject(new String(zipEntryMap.get("entry.json")));
114116
int version = json.getInt("version");

src/com/osudroid/UpdateManager.kt

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

33
import android.content.*
4+
import android.net.*
45
import android.util.*
56
import androidx.core.content.*
67
import com.osudroid.resources.R
@@ -40,19 +41,8 @@ object UpdateManager: IFileRequestObserver
4041
.addButton("Yes") {
4142
it.dismiss()
4243

43-
val changelogFile = File(activity.cacheDir, "changelog.html")
44-
45-
// Copying the changelog file to the cache directory.
46-
activity.assets.open("app/changelog.html").use { i ->
47-
changelogFile.outputStream().use { o -> i.copyTo(o) }
48-
}
49-
50-
val changelogUri = FileProvider.getUriForFile(activity, "${BuildConfig.APPLICATION_ID}.fileProvider", changelogFile)
51-
52-
GlobalManager.getInstance().mainActivity.startActivity(Intent(Intent.ACTION_VIEW).apply {
53-
setDataAndType(changelogUri, "text/html")
54-
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
55-
})
44+
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://osudroid.moe/changelog/latest"))
45+
GlobalManager.getInstance().mainActivity.startActivity(intent)
5646
}
5747
.addButton("No", clickListener = MessageDialog::dismiss)
5848
.show()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class SettingsFragment : SettingsFragment() {
263263
GlobalManager.getInstance().songService.isGaming = false
264264
} else if (Multiplayer.isConnected) {
265265
Multiplayer.roomScene?.chat?.show()
266+
Multiplayer.roomScene?.updatePlayerList()
266267
}
267268

268269
GlobalManager.getInstance().songService.volume = Config.getBgmVolume()

src/com/osudroid/ui/v2/modmenu/ModSettingComponent.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.rian.osu.mods.settings.ModSetting
1010
/**
1111
* Interface for a component that controls a [ModSetting].
1212
*/
13-
interface IModSettingComponent<V : Any?> {
13+
interface IModSettingComponent<V> {
1414
/**
1515
* The [Mod] that this [IModSettingComponent] belongs to.
1616
*/
@@ -40,7 +40,7 @@ interface IModSettingComponent<V : Any?> {
4040
* @param TSettingValue The type of the value in the [ModSetting].
4141
* @param TControlValue The type of the value in the [FormControl] that is used to display this [ModSettingComponent].
4242
*/
43-
sealed class ModSettingComponent<TSettingValue : Any?, TControlValue : Any>(
43+
sealed class ModSettingComponent<TSettingValue, TControlValue : Any>(
4444
final override val mod: Mod,
4545
final override val setting: ModSetting<TSettingValue>
4646
) : UIContainer(), IModSettingComponent<TSettingValue> {
@@ -62,11 +62,7 @@ sealed class ModSettingComponent<TSettingValue : Any?, TControlValue : Any>(
6262
}
6363
}
6464

65-
final override var isEnabled
66-
get() = control.isEnabled
67-
set(value) {
68-
control.isEnabled = value
69-
}
65+
final override var isEnabled by control::isEnabled
7066

7167
init {
7268
width = Size.Full

src/com/osudroid/ui/v2/modmenu/ModSettingSlider.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.rian.osu.mods.settings.*
99
sealed class ModSettingSlider<V : Number?>(mod: Mod, setting: ModSetting<V>) :
1010
ModSettingComponent<V, Float>(mod, setting) {
1111

12+
@Suppress("UNCHECKED_CAST")
1213
final override fun update() {
1314
val slider = (control as FormSlider).control
1415

@@ -18,19 +19,17 @@ sealed class ModSettingSlider<V : Number?>(mod: Mod, setting: ModSetting<V>) :
1819
val valueChanged = control.onValueChanged
1920
control.onValueChanged = null
2021

21-
slider.precision = when (setting) {
22-
is FloatModSetting -> setting.precision
23-
is NullableFloatModSetting -> setting.precision
24-
else -> slider.precision
22+
if (setting is IModSettingWithPrecision) {
23+
slider.precision = setting.precision
2524
}
2625

27-
if (setting is RangeConstrainedModSetting<V>) {
28-
slider.min = convertSettingValue(setting.minValue)
29-
slider.max = convertSettingValue(setting.maxValue)
26+
if (setting is IRangeConstrainedModSetting<*>) {
27+
slider.min = convertSettingValue(setting.minValue as V)
28+
slider.max = convertSettingValue(setting.maxValue as V)
3029
}
3130

32-
if (setting is NumberModSetting<V>) {
33-
slider.step = convertSettingValue(setting.step)
31+
if (setting is INumberModSetting<*>) {
32+
slider.step = convertSettingValue(setting.step as V)
3433
}
3534

3635
control.onValueChanged = valueChanged

src/com/osudroid/ui/v2/multi/RoomPlayerCard.kt

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import com.reco1l.andengine.shape.*
1515
import com.reco1l.andengine.sprite.UISprite
1616
import com.reco1l.andengine.text.UIText
1717
import com.reco1l.andengine.theme.Colors
18+
import com.reco1l.andengine.theme.FontSize
1819
import com.reco1l.andengine.theme.Size
1920
import com.reco1l.andengine.theme.pct
2021
import com.reco1l.andengine.theme.rem
2122
import com.reco1l.andengine.theme.srem
2223
import com.reco1l.andengine.ui.*
2324
import com.reco1l.framework.*
2425
import com.reco1l.framework.math.*
26+
import ru.nsu.ccfit.zuev.osu.Config
2527
import ru.nsu.ccfit.zuev.osu.ResourceManager
2628
import ru.nsu.ccfit.zuev.osu.helper.StringTable
2729
import ru.nsu.ccfit.zuev.osuplus.R
@@ -41,7 +43,7 @@ class RoomPlayerCard : UILinearContainer() {
4143
style = {
4244
width = 0.025f.pct
4345
height = Size.Full
44-
cornerRadius = 2f.rem
46+
radius = 2f.rem
4547
}
4648
}
4749

@@ -70,9 +72,11 @@ class RoomPlayerCard : UILinearContainer() {
7072
private class RoomPlayerButton : UIButton() {
7173

7274
private lateinit var nameText: UIText
73-
private lateinit var modsIndicator: ModsIndicator
7475
private lateinit var missingIndicator: UISprite
7576

77+
private val innerContainer: UILinearContainer
78+
private var modDisplay: UIComponent? = null
79+
7680

7781
init {
7882
width = Size.Full
@@ -86,7 +90,7 @@ class RoomPlayerCard : UILinearContainer() {
8690
backgroundColor = Theme.current.accentColor * 0.1f
8791
}
8892

89-
linearContainer {
93+
innerContainer = linearContainer {
9094
orientation = Orientation.Vertical
9195
inheritAncestorsColor = false
9296

@@ -105,12 +109,6 @@ class RoomPlayerCard : UILinearContainer() {
105109
size = Vec2(18f)
106110
}
107111
}
108-
109-
+ModsIndicator().apply {
110-
minHeight = 18f // Force to take space even if no mods are enabled
111-
iconSize = 18f
112-
modsIndicator = this
113-
}
114112
}
115113

116114
}
@@ -125,7 +123,37 @@ class RoomPlayerCard : UILinearContainer() {
125123

126124
nameText.text = player.name
127125
missingIndicator.isVisible = player.status == MissingBeatmap
128-
modsIndicator.mods = if (room.gameplaySettings.isFreeMod) player.mods.values else null
126+
127+
if (Config.isPreferModAcronymInMultiplayer()) {
128+
if (modDisplay !is UIText) {
129+
modDisplay?.detachSelf()
130+
131+
modDisplay = UIText().apply {
132+
minHeight = 18f // Force to take space even if no mods are enabled
133+
style += {
134+
fontSize = FontSize.XS
135+
color = it.accentColor * 0.8f
136+
}
137+
}
138+
139+
innerContainer += modDisplay!!
140+
}
141+
142+
(modDisplay as UIText).text = player.mods.toDisplayModString()
143+
} else {
144+
if (modDisplay !is ModsIndicator) {
145+
modDisplay?.detachSelf()
146+
147+
modDisplay = ModsIndicator().apply {
148+
minHeight = 18f // Force to take space even if no mods are enabled
149+
iconSize = 18f
150+
}
151+
152+
innerContainer += modDisplay!!
153+
}
154+
155+
(modDisplay as ModsIndicator).mods = if (room.gameplaySettings.isFreeMod) player.mods.values else null
156+
}
129157

130158
onActionLongPress = {
131159
UIDropdown(this@RoomPlayerButton).apply dropdown@{

src/com/osudroid/ui/v2/multi/RoomScene.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ class RoomScene(val room: Room) : UIScene(), IRoomEventListener, IPlayerEventLis
536536
modsIndicator.mods = room.mods.values
537537
}
538538

539-
private fun updatePlayerList() {
539+
fun updatePlayerList() {
540540

541541
val shouldReload = currentPlayers.size != room.playersMap.size
542542
|| !currentPlayers.all { room.playersMap.containsKey(it) }

0 commit comments

Comments
 (0)