mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Reversed indexing
This commit is contained in:
@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
public IReadOnlyList<string> MessageHistory => messageHistory;
|
public IReadOnlyList<string> MessageHistory => messageHistory;
|
||||||
|
|
||||||
private int historyIndex = -1;
|
private int historyIndex;
|
||||||
|
|
||||||
private string originalMessage = string.Empty;
|
private string originalMessage = string.Empty;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Current.ValueChanged += text =>
|
Current.ValueChanged += text =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text.NewValue))
|
if (string.IsNullOrEmpty(text.NewValue))
|
||||||
historyIndex = -1;
|
historyIndex = messageHistory.Count;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,28 +31,28 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.Up:
|
case Key.Up:
|
||||||
if (historyIndex == -1)
|
if (historyIndex == messageHistory.Count)
|
||||||
originalMessage = Text;
|
originalMessage = Text;
|
||||||
|
|
||||||
if (historyIndex == messageHistory.Count - 1)
|
if (historyIndex == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Text = messageHistory[++historyIndex];
|
Text = messageHistory[--historyIndex];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Key.Down:
|
case Key.Down:
|
||||||
if (historyIndex == -1)
|
if (historyIndex == messageHistory.Count)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (historyIndex == 0)
|
if (historyIndex == messageHistory.Count - 1)
|
||||||
{
|
{
|
||||||
historyIndex = -1;
|
historyIndex = messageHistory.Count;
|
||||||
Text = originalMessage;
|
Text = originalMessage;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Text = messageHistory[--historyIndex];
|
Text = messageHistory[++historyIndex];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -63,9 +63,9 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
protected override void Commit()
|
protected override void Commit()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Text))
|
if (!string.IsNullOrEmpty(Text))
|
||||||
messageHistory.Insert(0, Text);
|
messageHistory.Add(Text);
|
||||||
|
|
||||||
historyIndex = -1;
|
historyIndex = messageHistory.Count;
|
||||||
|
|
||||||
base.Commit();
|
base.Commit();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user