summaryrefslogtreecommitdiff
path: root/lib/chessh/ssh/client/menu.ex
diff options
context:
space:
mode:
authorLogan Hunt <logan.hunt@usu.edu>2023-01-13 17:48:00 -0700
committerLogan Hunt <logan.hunt@usu.edu>2023-01-13 17:48:00 -0700
commit9f56b735c65502ae0eec14071d1b06a1c2f1d747 (patch)
tree5377c14d2e31af2758756bf31690917d619aee8c /lib/chessh/ssh/client/menu.ex
parentb1b62f154ab5f74a9217dbf5a6422640ac929df3 (diff)
downloadchessh-9f56b735c65502ae0eec14071d1b06a1c2f1d747.tar.gz
chessh-9f56b735c65502ae0eec14071d1b06a1c2f1d747.zip
Selectable menu
Diffstat (limited to 'lib/chessh/ssh/client/menu.ex')
-rw-r--r--lib/chessh/ssh/client/menu.ex20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/chessh/ssh/client/menu.ex b/lib/chessh/ssh/client/menu.ex
index c207872..946928e 100644
--- a/lib/chessh/ssh/client/menu.ex
+++ b/lib/chessh/ssh/client/menu.ex
@@ -24,9 +24,11 @@ defmodule Chessh.SSH.Client.Menu do
end
@options [
- {"Option 1", {}},
- {"Option 2", {}},
- {"Option 3", {}}
+ {"Start A Game", {Chessh.SSH.Client.Board, %Chessh.SSH.Client.Board.State{}}},
+ {"Join A Game", {}},
+ {"My Games", {}},
+ {"Settings", {}},
+ {"Help", {}}
]
def input(width, height, action, %State{client_pid: client_pid, selected: selected} = state) do
@@ -41,15 +43,19 @@ defmodule Chessh.SSH.Client.Menu do
:down ->
%State{state | selected: Utils.wrap_around(selected, 1, length(@options))}
- # :return ->
- # {_, new_state} = Enum.at(@options, selected)
- # new_state
+ :return ->
+ {_option, {module, state}} = Enum.at(@options, selected)
+ send(client_pid, {:set_screen_process, module, state})
+ state
_ ->
state
end
- send(client_pid, {:send_to_ssh, render_state(width, height, new_state)})
+ if !(action == :return) do
+ send(client_pid, {:send_to_ssh, render_state(width, height, new_state)})
+ end
+
new_state
end