Skip to content

Commit

Permalink
Merge #4269 Draw progress bar when ProgressBarRenderer.IsSupported is…
Browse files Browse the repository at this point in the history
… false
  • Loading branch information
HebaruSan committed Nov 30, 2024
2 parents a705ca5 + f4575f3 commit 670f5dc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Minor tray icon improvements (#4231 by: HebaruSan)
- [Multiple] Translation updates from Crowdin (#4233 by: vixnig38, ambition, tinygrox; reviewed: HebaruSan)
- [Multiple] Cache migration and other fixes (#4240 by: HebaruSan)
- [Multiple] Start installing mods while downloads are still in progress (#4249, #4255 by: HebaruSan)
- [Multiple] Start installing mods while downloads are still in progress (#4249, #4255, #4269 by: HebaruSan)
- [Multiple] Sort dependencies first in modpacks (#4252 by: HebaruSan)
- [Multiple] Allow installs and removals to be cancelled (#4253 by: HebaruSan)
- [CLI] Include `supports` relationship in `ckan show` (#4262 by: HebaruSan)
Expand Down
31 changes: 24 additions & 7 deletions GUI/Controls/LabeledProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,31 @@ public LabeledProgressBar()

protected override void OnPaint(PaintEventArgs e)
{
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, ClientRectangle);
ProgressBarRenderer.DrawHorizontalChunks(e.Graphics,
new Rectangle(ClientRectangle.X,
ClientRectangle.Y,
ClientRectangle.Width
* (Value - Minimum)
if (ProgressBarRenderer.IsSupported)
{
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, ClientRectangle);
ProgressBarRenderer.DrawHorizontalChunks(e.Graphics,
new Rectangle(ClientRectangle.X,
ClientRectangle.Y,
ClientRectangle.Width * (Value - Minimum)
/ (Maximum - Minimum),
ClientRectangle.Height));
}
else
{
const int borderWidth = 1;
var innerRect = Rectangle.Inflate(ClientRectangle, -2 * borderWidth,
-2 * borderWidth);
innerRect.Offset(borderWidth, borderWidth);
e.Graphics.DrawRectangle(SystemPens.ControlDark, ClientRectangle);
e.Graphics.FillRectangle(SystemBrushes.Control, innerRect);
e.Graphics.FillRectangle(SystemBrushes.Highlight,
new Rectangle(innerRect.X,
innerRect.Y,
innerRect.Width * (Value - Minimum)
/ (Maximum - Minimum),
ClientRectangle.Height));
innerRect.Height));
}
TextRenderer.DrawText(e.Graphics, Text, Font,
new Point((Width - textSize.Width) / 2,
(Height - textSize.Height) / 2),
Expand Down
2 changes: 1 addition & 1 deletion GUI/Dialogs/ManageGameInstancesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private void InstanceFileOK(object? sender, CancelEventArgs? e)
// so we have to re-enforce the filter ourselves
var chosen = Path.GetFileName(dlg.FileName);
var allowed = manager.AllInstanceAnchorFiles;
if (!allowed.Contains(chosen))
if (!allowed.Contains(chosen, Platform.PathComparer))
{
e.Cancel = true;
user.RaiseError(Properties.Resources.ManageGameInstancesInvalidFileSelected,
Expand Down

0 comments on commit 670f5dc

Please sign in to comment.