diff options
author | Simponic <loganhunt@simponic.xyz> | 2023-01-20 23:12:23 -0700 |
---|---|---|
committer | Simponic <loganhunt@simponic.xyz> | 2023-01-20 23:12:23 -0700 |
commit | 06f1ca76037397fb61c69319802ed029ac73e715 (patch) | |
tree | 37cdf1ebf5fcbaefda58d377bb6b4e3a8a11410b /lib/chessh/ssh/client/menus/main_menu.ex | |
parent | e0058fedfb191db8802a95548cbaf96b6fe58f80 (diff) | |
download | chessh-06f1ca76037397fb61c69319802ed029ac73e715.tar.gz chessh-06f1ca76037397fb61c69319802ed029ac73e715.zip |
Add pagination menus
Diffstat (limited to 'lib/chessh/ssh/client/menus/main_menu.ex')
-rw-r--r-- | lib/chessh/ssh/client/menus/main_menu.ex | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/chessh/ssh/client/menus/main_menu.ex b/lib/chessh/ssh/client/menus/main_menu.ex new file mode 100644 index 0000000..167a0ef --- /dev/null +++ b/lib/chessh/ssh/client/menus/main_menu.ex @@ -0,0 +1,45 @@ +defmodule Chessh.SSH.Client.MainMenu do + alias IO.ANSI + alias Chessh.PlayerSession + + require Logger + + @logo " Simponic's + dP MP\"\"\"\"\"\"`MM MP\"\"\"\"\"\"`MM M\"\"MMMMM\"\"MM + 88 M mmmmm..M M mmmmm..M M MMMMM MM +.d8888b. 88d888b. .d8888b. M. `YM M. `YM M `M +88' `\"\" 88' `88 88ooood8 MMMMMMM. M MMMMMMM. M M MMMMM MM +88. ... 88 88 88. ... M. .MMM' M M. .MMM' M M MMMMM MM +`88888P' dP dP `88888P' Mb. .dM Mb. .dM M MMMMM MM + MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMMM" |> String.split("\n") + @logo_cols @logo |> Enum.map(&String.length/1) |> Enum.max() + + use Chessh.SSH.Client.SelectPaginatePoller + + def dynamic_options(), do: false + def tick_delay_ms(), do: 1000 + def max_displayed_options(), do: 4 + def max_box_cols(), do: @logo_cols + def title(), do: @logo + + def initial_options(%State{player_session: %PlayerSession{} = player_session}) do + [ + {"Start A Game (Light)", + {Chessh.SSH.Client.Game, + %Chessh.SSH.Client.Game.State{player_session: player_session, color: :light}}}, + {"Start A Game (Dark)", + {Chessh.SSH.Client.Game, + %Chessh.SSH.Client.Game.State{player_session: player_session, color: :dark}}}, + {"Current Games", + {Chessh.SSH.Client.SelectCurrentGame, + %Chessh.SSH.Client.SelectPaginatePoller.State{player_session: player_session}}}, + {"Joinable Games (lobby)", + {Chessh.SSH.Client.SelectJoinableGame, + %Chessh.SSH.Client.SelectPaginatePoller.State{player_session: player_session}}} + ] + end + + def make_process_tuple(selected, _state) do + selected + end +end |