Skip to content

Commit

Permalink
Prevent showing non-applicable options, if a game is installing
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoVIII committed Apr 17, 2022
1 parent 28520df commit 588aa18
Showing 1 changed file with 32 additions and 27 deletions.
59 changes: 32 additions & 27 deletions src/Andromeda/AvaloniaApp/ViewComponents/GameList.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,45 @@ open Andromeda.AvaloniaApp.AvaloniaHelper

module GameList =
let gameTile dispatch (game: Game) : IView =
// Is something going on with this game?
let inProgress =
match game.status with
| Pending -> Some(0, 1, "Pending...")
| Downloading (current, max) ->
let current, max = (int current, int max)
// TODO: switch units if applicable
let text = sprintf "%i MiB / %i MiB" current max
Some(current, max, text)
| Installing -> Some(1, 1, "Installing...")
| GameStatus.Installed _ -> None

let gap = 5.0

Border.create [
Border.margin (0.0, 0.0, gap, gap)
Border.contextMenu (
ContextMenu.create [
ContextMenu.viewItems [
MenuItem.create [
MenuItem.header "Start"
MenuItem.onClick (
(fun _ -> game |> StartGame |> dispatch),
OnChangeOf game
)
]
MenuItem.create [
MenuItem.header "Update"
MenuItem.onClick (
(fun _ -> game |> UpgradeGame |> dispatch),
OnChangeOf game
)
]
MenuItem.create [ MenuItem.header "-" ]
match inProgress with
| Some _ -> ()
| None ->
yield!
[ MenuItem.create [
MenuItem.header "Start"
MenuItem.onClick (
(fun _ -> game |> StartGame |> dispatch),
OnChangeOf game
)
]
:> IView
MenuItem.create [
MenuItem.header "Update"
MenuItem.onClick (
(fun _ -> game |> UpgradeGame |> dispatch),
OnChangeOf game
)
]
MenuItem.create [ MenuItem.header "-" ] ]
MenuItem.create [
MenuItem.header "Open game folder"
MenuItem.onClick (
Expand All @@ -52,18 +69,6 @@ module GameList =
let height = 120.0
let width = 200.0

// Is something going on with this game?
let inProgress =
match game.status with
| Pending -> Some(0, 1, "Pending...")
| Downloading (current, max) ->
let current, max = (int current, int max)
// TODO: switch units if applicable
let text = sprintf "%i MiB / %i MiB" current max
Some(current, max, text)
| Installing -> Some(1, 1, "Installing...")
| GameStatus.Installed _ -> None

Canvas.create [
Canvas.height 120
Canvas.width 200
Expand Down

0 comments on commit 588aa18

Please sign in to comment.