Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Switch Dialog Menu in "tui.c" #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions src/tui.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static void detect_local_switch(void)
dialog_vars.begin_set = false;
dialog_msgbox("Setup",
"\nPlease enter the shoal now, then enter LAN mode "
"(Hold L+R, then press down the left thumbstick) "
"(Hold L+R, then press the left thumbstick) "
"and try to find a room ...", 10, 40, 1);
tui_clear();

Expand Down Expand Up @@ -325,7 +325,7 @@ static void detect_local_switch(void)
ip_str(switch_ip, ip);
mac_str(switch_mac, mac);

snprintf(buf, 100, "\nFound local Switch:\n\n%s (%s)",
snprintf(buf, 100, "\nFound Local Switch:\n\n%s (%s)",
ip, mac);
dialog_msgbox("Setup", buf, 9, 40, 1);
}
Expand Down Expand Up @@ -382,7 +382,7 @@ static void switch_gw_dialog(void)

res = dialog_inputbox("Setup",
"Please enter the IP this VM should use "
"for the GW functionality (normally 192.168.1.1):\n",
"for the Gateway functionality (normally 192.168.1.1):\n",
10, 40, tmpbuf, 0);
if (res)
return;
Expand All @@ -395,7 +395,7 @@ static void switch_gw_dialog(void)

break;
invalid_ip:
dialog_msgbox("Setup", "Invalid IP address", 7, 40, 1);
dialog_msgbox("Setup", "Invalid IP Address", 7, 40, 1);
snprintf(tmpbuf, IP_STR_BULEN, "%s", dialog_vars.input_result);
continue;
}
Expand Down Expand Up @@ -449,6 +449,34 @@ static void switch_gw_dialog(void)
}
}

static void switch_reDetect_dialog(void) {
DIALOG_LISTITEM switches[] = {
{"1", "Switch 1", dlg_strempty()},
{"2", "Switch 2", dlg_strempty()},
{"3", "Switch 3", dlg_strempty()},
{"4", "Switch 4", dlg_strempty()},
};
int switchSelected;
dlg_menu("Re-detect a Switch", "Please Select A Switch:", 11, 60, 4, 4, switches, &switchSelected, dlg_dummy_menutext);
if (res)
return;

switch(switchSelected) {
case 0:
detect_local_switch();
break;
case 1:
detect_local_switch();
break;
case 2:
detect_local_switch();
break;
case 3:
detect_local_switch();
break;
}
}

static void switch_information_dialog(void)
{
char ip[IP_STR_BULEN];
Expand Down Expand Up @@ -507,7 +535,7 @@ static void switch_information_dialog(void)
break;

invalid_mac:
dialog_msgbox("Setup", "Invalid MAC address", 7, 40, 1);
dialog_msgbox("Setup", "Invalid MAC Address", 7, 40, 1);
snprintf(mac, MAC_STR_BULEN, "%s", dialog_vars.input_result);
continue;
}
Expand Down Expand Up @@ -616,8 +644,8 @@ void tui_thread(void *arg)
dialog_vars.nocancel = true;

DIALOG_LISTITEM choices[] = {
{"1", "Refresh state", dlg_strempty()},
{"2", "Re-detect Switch", dlg_strempty()},
{"1", "Refresh State", dlg_strempty()},
{"2", "Re-detect a Switch", dlg_strempty()},
{"3", "Shutdown the VM", dlg_strempty()},
{"4", fake_gateway_ip ?
"Advanced: Setup VM as Gateway (currently enabled)" :
Expand All @@ -642,12 +670,12 @@ void tui_thread(void *arg)
detect_switch_online();
break;
case 1:
detect_local_switch();
switch_reDetect_dialog();
break;
case 2:
dialog_vars.begin_set = false;
res = dialog_yesno("Setup",
"\nDo you really want to shutdown the VM?",
"\nAre you sure you want to shutdown the VM?",
8, 40);
if (res)
break;
Expand Down Expand Up @@ -695,7 +723,7 @@ void tui_thread(void *arg)
case 6:
dialog_vars.begin_set = false;
res = dialog_yesno("Setup",
"\nDo you really want to reboot the VM?",
"\nAre you sure you want to reboot the VM?",
8, 40);
if (res)
break;
Expand Down