Skip to content

Commit

Permalink
Clean-up some coding issue created before.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Oct 31, 2020
1 parent 0c01177 commit dc1edbf
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void TestDecodeTranslate()
Assert.IsTrue(translates != null);

// Check translate count
Assert.AreEqual(translates.Count(), 2);
Assert.AreEqual(translates.Length, 2);

// All lyric should have two translates
Assert.AreEqual(lyrics[0].Translates.Count, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public abstract class KaraokeModPerfectTestScene : ModPerfectTestScene
{
protected override Ruleset CreatePlayerRuleset() => new KaraokeRuleset();

public KaraokeModPerfectTestScene(ModPerfect mod)
protected KaraokeModPerfectTestScene(ModPerfect mod)
: base(mod)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,15 @@ private void processTranslate(Beatmap beatmap, IEnumerable<string> translateLine
value = translate.Split('=').LastOrDefault()
}).GroupBy(x => x.key, y => y.value).ToList();

for (int i = 0; i < translates.Count(); i++)
for (int i = 0; i < translates.Count; i++)
{
var id = i + 1;
var singleLanguage = translates[i];

var key = singleLanguage.Key;
var values = singleLanguage.ToList();

var size = Math.Min(lyrics.Count(), singleLanguage.Count());
var size = Math.Min(lyrics.Count, singleLanguage.Count());

for (int j = 0; j < size; j++)
{
Expand Down
7 changes: 5 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/Import/ImportLyricDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public ImportLyricDialog(FileInfo info, Action<bool> resetAction = null)
new PopupDialogOkButton
{
Text = @"Yes. Go for it.",
Action = () => {
Action = () =>
{
var success = processImport(info);
resetAction?.Invoke(true);
resetAction?.Invoke(success);
}
},
new PopupDialogCancelButton
Expand Down Expand Up @@ -67,6 +68,7 @@ private bool processImport(FileInfo info)
BodyText = fileNotFoundException.Message,
});
break;

case FileLoadException loadException:
dialogOverlay.Push(new OkPopupDialog
{
Expand All @@ -76,6 +78,7 @@ private bool processImport(FileInfo info)
});
break;
}

return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Import/ImportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void ImportLrcFile(FileInfo info)

var set = beatmap.Value.BeatmapSetInfo;
var oldFile = set.Files?.FirstOrDefault(f => f.Filename == backup_lrc_name);

using (var stream = info.OpenRead())
{
// todo : make a backup if has new lyric file.
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Karaoke/Edit/Layout/LayoutManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class LayoutManager : Component
private void load()
{
var layoutLookups = source.GetConfig<KaraokeIndexLookup, IDictionary<int, string>>(KaraokeIndexLookup.Layout)?.Value;

foreach (var layoutLookup in layoutLookups)
{
var lookup = new KaraokeSkinLookup(KaraokeSkinConfiguration.LyricLayout, layoutLookup.Key);
Expand All @@ -49,6 +50,7 @@ private void load()
EditLayout.Value = Layouts.FirstOrDefault();

var skinLookups = source.GetConfig<KaraokeIndexLookup, IDictionary<int, string>>(KaraokeIndexLookup.Style)?.Value;

foreach (var skinLookup in skinLookups)
{
PreviewFontSelections.Add(skinLookup.Key, skinLookup.Value);
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Karaoke/Edit/Layout/LayoutPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void load(LayoutManager manager)
{
manager.PreviewLyric.BindValueChanged(e =>
{
if(e.NewValue != null)
if (e.NewValue != null)
Child = new PreviewDrawableLyric(e.NewValue);
}, true);

Expand All @@ -94,7 +94,7 @@ public class PreviewDrawableLyric : DrawableLyric
private KaraokeLayout layout;

public PreviewDrawableLyric(Lyric hitObject)
: base(hitObject)
: base(hitObject)
{
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Edit/Layout/LayoutScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class LayoutScreen : EditorScreen
protected readonly LayoutManager LayoutManager;

public LayoutScreen()
: base(EditorScreenMode.SongSetup)
: base(EditorScreenMode.SongSetup)
{
ColourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
Content.Add(LayoutManager = new LayoutManager());
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Edit/Layout/LayoutSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal abstract class LayoutSection : Container

protected abstract string Title { get; }

public LayoutSection()
protected LayoutSection()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Expand Down
73 changes: 37 additions & 36 deletions osu.Game.Rulesets.Karaoke/Edit/Layout/PreviewSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
using osu.Game.IO;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Karaoke.Beatmaps.Formats;
Expand Down Expand Up @@ -64,6 +62,7 @@ private void load(LayoutManager manager)
Height = 9
};
break;

case PreviewRatio.LegacyScreen:
manager.PreviewScreenRatio.Value = new DisplayRatio
{
Expand Down Expand Up @@ -91,44 +90,46 @@ private Lyric getLyricSampleBySelection(PreviewSample previewSample)
{
case PreviewSample.SampeSmall:
return createDefaultLyric("@カラオケ",
new[]
{
"@Ruby1=カ,か",
"@Ruby2=ラ,ら",
"@Ruby3=オ,お",
"@Ruby4=ケ,け"
},
new[]
{
"@Romaji1=カ,ka",
"@Romaji2=ラ,ra",
"@Romaji3=オ,o",
"@Romaji4=ケ,ke"
}
, "karaoke");
new[]
{
"@Ruby1=カ,か",
"@Ruby2=ラ,ら",
"@Ruby3=オ,お",
"@Ruby4=ケ,け"
},
new[]
{
"@Romaji1=カ,ka",
"@Romaji2=ラ,ra",
"@Romaji3=オ,o",
"@Romaji4=ケ,ke"
}
, "karaoke");

case PreviewSample.SampleMedium:
return createDefaultLyric("@[00:18:58]た[00:18:81]だ[00:19:36]風[00:20:09]に[00:20:29]揺[00:20:49]ら[00:20:68]れ[00:20:89]て[00:20:93]",
new[]
{
"@Ruby1=風,かぜ",
"@Ruby2=揺,ゆ"
},
new[]
{
"@Romaji1=た,ta",
"@Romaji2=だ,da",
"@Romaji3=風,kaze",
"@Romaji4=に,ni",
"@Romaji5=揺,yu",
"@Romaji6=ら,ra",
"@Romaji7=れ,re",
"@Romaji8=て,te"
}
, "karaoke");
new[]
{
"@Ruby1=風,かぜ",
"@Ruby2=揺,ゆ"
},
new[]
{
"@Romaji1=た,ta",
"@Romaji2=だ,da",
"@Romaji3=風,kaze",
"@Romaji4=に,ni",
"@Romaji5=揺,yu",
"@Romaji6=ら,ra",
"@Romaji7=れ,re",
"@Romaji8=て,te"
}
, "karaoke");

case PreviewSample.SampleLarge:
return createDefaultLyric("@灰色(いろ)(いろ)の景色(いろ)(いろ)さえ色づき始める",
Array.Empty<string>(), Array.Empty<string>(), "karaoke");
Array.Empty<string>(), Array.Empty<string>(), "karaoke");

default:
return null;
}
Expand Down Expand Up @@ -209,7 +210,7 @@ private class StyleDropdown : SettingsDropdown<KeyValuePair<int, string>>
private class StyleDropdownControl : DropdownControl
{
protected override string GenerateItemText(KeyValuePair<int, string> item)
=> item.Value ?? $"Style{item.Key}";
=> item.Value ?? $"Style{item.Key}";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Beatmaps.Formats;
using osu.Game.Rulesets.Karaoke.Edit.Import;
using osu.Game.Rulesets.Karaoke.Edit.Timelines;
using osu.Game.Rulesets.Karaoke.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public Lyric[] Lyrics
private TableColumn[] createHeaders()
{
var columns = new List<TableColumn>
{
new TableColumn("Number", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
new TableColumn("Lyric", Anchor.Centre),
};
{
new TableColumn("Number", Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)),
new TableColumn("Lyric", Anchor.Centre),
};

return columns.ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Edit/Style/StyleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class StyleScreen : EditorScreen
protected readonly StyleManager StyleManager;

public StyleScreen()
: base(EditorScreenMode.SongSetup)
: base(EditorScreenMode.SongSetup)
{
ColourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
Content.Add(StyleManager = new StyleManager());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ protected override void LoadComplete()
base.LoadComplete();

textBox.Current.Value = language.Name;
textBox.Current.BindValueChanged(x => {
textBox.Current.BindValueChanged(x =>
{
// Update name
languageManager.UpdateLanguagename(language, x.NewValue);

// Create new
// Create new
createNewLanguage();
}, true);
IsCreated.BindValueChanged(created => textBoxPaddingContainer.Padding = new MarginPadding { Right = created.NewValue ? button_width : 0 }, true);
Expand Down
24 changes: 12 additions & 12 deletions osu.Game.Rulesets.Karaoke/Edit/Translate/TranslateEditSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
{
Padding = new MarginPadding(10);

var columnDimensions = new Dimension[]
var columnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, 200),
new Dimension(GridSizeMode.Absolute, column_spacing),
new Dimension(GridSizeMode.Absolute, 400),
new Dimension(GridSizeMode.Absolute, column_spacing),
new Dimension(GridSizeMode.Distributed)
new Dimension()
};

Child = new FillFlowContainer
Expand All @@ -54,7 +54,7 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
new GridContainer
{
Name = "LanguageSelection",
RowDimensions = new []
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize)
},
Expand All @@ -63,7 +63,7 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
AutoSizeAxes = Axes.Y,
Content = new Drawable[][]
{
new []
new[]
{
null,
null,
Expand All @@ -80,20 +80,20 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new []
Children = new[]
{
new GridContainer
{
Name = "Background",
RowDimensions = new []
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize)
},
ColumnDimensions = columnDimensions,
RelativeSizeAxes = Axes.Both,
Content = new []
Content = new[]
{
new []
new[]
{
new CornerBackground
{
Expand All @@ -104,7 +104,7 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
null,
null,
},
new []
new[]
{
timeSectionBackground = new CornerBackground
{
Expand Down Expand Up @@ -135,8 +135,8 @@ public TranslateEditSection(EditorBeatmap editorBeatmap)
};

Dimension[] createRowDimension() => editorBeatmap.HitObjects.OfType<Lyric>()
.Select(x => new Dimension(GridSizeMode.Absolute, row_height))
.ToArray();
.Select(x => new Dimension(GridSizeMode.Absolute, row_height))
.ToArray();
}

[BackgroundDependencyLoader]
Expand All @@ -154,7 +154,7 @@ private Drawable[][] createContent(EditorBeatmap editorBeatmap, Bindable<Beatmap

return lyrics.Select(x =>
{
return new Drawable[]
return new[]
{
createTimeDrawable(x),
null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays;
using osu.Game.Rulesets.Karaoke.Edit.Translate.Components;
using osu.Game.Screens.Edit;

namespace osu.Game.Rulesets.Karaoke.Edit.Translate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public TitleFocusedOverlayContainer()
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Icon = FontAwesome.Solid.Times,
Icon = FontAwesome.Solid.Times,
Scale = new Vector2(0.8f),
X = -10,
Action = () => State.Value = Visibility.Hidden
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class BackgroundToolTip : VisibilityContainer, ITooltip

protected override Container<Drawable> Content => content;

public BackgroundToolTip()
protected BackgroundToolTip()
{
AutoSizeAxes = Axes.Both;
Masking = true;
Expand Down
Loading

0 comments on commit dc1edbf

Please sign in to comment.