From 9f56b735c65502ae0eec14071d1b06a1c2f1d747 Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Fri, 13 Jan 2023 17:48:00 -0700 Subject: Selectable menu --- lib/chessh/ssh/client/menu.ex | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'lib/chessh/ssh/client/menu.ex') 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 -- cgit v1.2.3-70-g09d2