mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 22:32:55 +08:00
Disable the import button when no file is selected, rather than weird flash logic
This commit is contained in:
parent
cba4657021
commit
33f77f81f2
@ -32,6 +32,8 @@ namespace osu.Game.Screens.Import
|
|||||||
private TextFlowContainer currentFileText;
|
private TextFlowContainer currentFileText;
|
||||||
private OsuScrollContainer fileNameScroll;
|
private OsuScrollContainer fileNameScroll;
|
||||||
|
|
||||||
|
private TriangleButton importButton;
|
||||||
|
|
||||||
private const float duration = 300;
|
private const float duration = 300;
|
||||||
private const float button_height = 50;
|
private const float button_height = 50;
|
||||||
private const float button_vertical_margin = 15;
|
private const float button_vertical_margin = 15;
|
||||||
@ -100,7 +102,7 @@ namespace osu.Game.Screens.Import
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new TriangleButton
|
importButton = new TriangleButton
|
||||||
{
|
{
|
||||||
Text = "Import",
|
Text = "Import",
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
@ -109,14 +111,7 @@ namespace osu.Game.Screens.Import
|
|||||||
Height = button_height,
|
Height = button_height,
|
||||||
Width = 0.9f,
|
Width = 0.9f,
|
||||||
Margin = new MarginPadding { Vertical = button_vertical_margin },
|
Margin = new MarginPadding { Vertical = button_vertical_margin },
|
||||||
Action = () =>
|
Action = () => startImport(currentFile.Value?.FullName)
|
||||||
{
|
|
||||||
var d = currentFile.Value?.FullName;
|
|
||||||
if (d != null)
|
|
||||||
startImport(d);
|
|
||||||
else
|
|
||||||
currentFileText.FlashColour(Color4.Red, 500);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,21 +120,22 @@ namespace osu.Game.Screens.Import
|
|||||||
fileNameScroll.ScrollContent.Anchor = Anchor.Centre;
|
fileNameScroll.ScrollContent.Anchor = Anchor.Centre;
|
||||||
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
fileNameScroll.ScrollContent.Origin = Anchor.Centre;
|
||||||
|
|
||||||
currentFile.BindValueChanged(updateFileSelectionText, true);
|
currentFile.BindValueChanged(fileChanged, true);
|
||||||
currentDirectory.BindValueChanged(onCurrentDirectoryChanged);
|
currentDirectory.BindValueChanged(directoryChanged);
|
||||||
|
|
||||||
currentDirectory.BindTo(fileSelector.CurrentPath);
|
currentDirectory.BindTo(fileSelector.CurrentPath);
|
||||||
currentFile.BindTo(fileSelector.CurrentFile);
|
currentFile.BindTo(fileSelector.CurrentFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCurrentDirectoryChanged(ValueChangedEvent<DirectoryInfo> v)
|
private void directoryChanged(ValueChangedEvent<DirectoryInfo> v)
|
||||||
{
|
{
|
||||||
currentFile.Value = null;
|
currentFile.Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFileSelectionText(ValueChangedEvent<FileInfo> v)
|
private void fileChanged(ValueChangedEvent<FileInfo> selectedFile)
|
||||||
{
|
{
|
||||||
currentFileText.Text = v.NewValue?.Name ?? "Select a file";
|
importButton.Enabled.Value = selectedFile.NewValue != null;
|
||||||
|
currentFileText.Text = selectedFile.NewValue?.Name ?? "Select a file";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnEntering(IScreen last)
|
public override void OnEntering(IScreen last)
|
||||||
|
Loading…
Reference in New Issue
Block a user