Skip to content

Commit e92439c

Browse files
authored
Merge pull request #34125 from bdach/write-skin-name-to-ini-on-rename
Write new name to `skin.ini` when renaming skin via settings
2 parents 1648664 + db93c2a commit e92439c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ protected override void PopIn()
310310
base.PopIn();
311311
}
312312

313-
private void rename() => skins.CurrentSkinInfo.Value.PerformWrite(skin =>
313+
private void rename()
314314
{
315-
skin.Name = textBox.Text;
315+
skins.Rename(skins.CurrentSkinInfo.Value, textBox.Text);
316316
PopOut();
317-
});
317+
}
318318
}
319319
}
320320
}

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)