Skip to content

Commit 694b333

Browse files
committed
Write new name to skin.ini when renaming skin via settings
Reported at https://osu.ppy.sh/comments/3681620, with appropriate levels of rage bait (DID ANYONE TEST THIS?!?!?!?!?!?!?!?!?!111!!) Reasoning for this is that without this, users' skin names can be dropped after an external edit because they're never persisted anywhere outside of realm. The only other choice I see is to stop re-populating skin metadata from the `.ini` upon completing an external edit, which is very doable but seems worse than this. Dunno.
1 parent b4502d3 commit 694b333

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

osu.Game/Overlays/Settings/Sections/SkinSection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using osu.Framework.Graphics.UserInterface;
1818
using osu.Framework.Localisation;
1919
using osu.Framework.Logging;
20+
using osu.Game.Beatmaps;
2021
using osu.Game.Database;
2122
using osu.Game.Graphics;
2223
using osu.Game.Graphics.UserInterface;
@@ -310,11 +311,11 @@ protected override void PopIn()
310311
base.PopIn();
311312
}
312313

313-
private void rename() => skins.CurrentSkinInfo.Value.PerformWrite(skin =>
314+
private void rename()
314315
{
315-
skin.Name = textBox.Text;
316+
skins.Rename(skins.CurrentSkinInfo.Value, textBox.Text);
316317
PopOut();
317-
});
318+
}
318319
}
319320
}
320321
}

osu.Game/Skinning/SkinImporter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,17 @@ private void checkSkinIniMetadata(SkinInfo item, Realm realm)
157157
// Regardless of whether this is an import or not, let's write the skin.ini if non-existing or non-matching.
158158
// This is (weirdly) done inside ComputeHash to avoid adding a new method to handle this case. After switching to realm it can be moved into another place.
159159
if (skinIniSourcedName != item.Name)
160-
updateSkinIniMetadata(item, realm);
160+
UpdateSkinIniMetadata(item, realm);
161161
}
162162

163-
private void updateSkinIniMetadata(SkinInfo item, Realm realm)
163+
public void UpdateSkinIniMetadata(SkinInfo item, Realm realm)
164164
{
165165
string nameLine = @$"Name: {item.Name}";
166166
string authorLine = @$"Author: {item.Creator}";
167167

168168
List<string> newLines = new List<string>
169169
{
170-
@"// The following content was automatically added by osu! during import, based on filename / folder metadata.",
170+
@"// The following content was automatically added by osu! in order to use metadata that more closely matches user expectations.",
171171
@"[General]",
172172
nameLine,
173173
authorLine,

osu.Game/Skinning/SkinManager.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ public void Delete([CanBeNull] Expression<Func<SkinInfo, bool>> filter = null, b
349349
});
350350
}
351351

352+
public void Rename(Live<SkinInfo> skin, string newName)
353+
{
354+
skin.PerformWrite(s =>
355+
{
356+
s.Name = newName;
357+
skinImporter.UpdateSkinIniMetadata(s, s.Realm!);
358+
});
359+
}
360+
352361
public void SetSkinFromConfiguration(string guidString)
353362
{
354363
Live<SkinInfo> skinInfo = null;

0 commit comments

Comments
 (0)