Files
palera1n/src/tui_screen_main.c
T

47 lines
1.5 KiB
C
Raw Normal View History

2023-01-28 20:41:18 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>
2023-01-29 01:02:47 +08:00
#include <assert.h>
2023-01-28 20:41:18 +08:00
2023-02-06 01:03:29 +08:00
#include <palerain.h>
2023-01-28 20:54:06 +08:00
#include <tui.h>
2023-01-28 20:41:18 +08:00
2023-01-29 13:08:48 +08:00
tui_screen_t tui_screen_main() {
2023-02-04 21:29:49 +08:00
int ret = MAIN_SCREEN;
bool can_start = false;
2023-02-05 03:00:29 +08:00
newtCenteredWindow(WIDTH, HEIGHT, NULL);
2023-02-05 14:37:01 +08:00
newtComponent optionsButton = newtCompactButton(46, 18, "Options");
newtComponent startButton = newtCompactButton(57, 18, "Start");
newtComponent exitButton = newtCompactButton(66, 18, "Exit");
2023-02-04 21:29:49 +08:00
newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!");
2023-02-05 14:37:01 +08:00
newtComponent deviceMsg = newtTextbox(1, 2, 40, 3, NEWT_FLAG_WRAP);
2023-02-05 15:04:42 +08:00
set_tui_log(deviceMsg);
LOG(LOG_INFO, "Connect your iPhone, iPad or iPod Touch to begin.");
2023-02-05 14:37:01 +08:00
newtTextboxSetColors(deviceMsg, PI_LOG_COLOR, PI_LOG_COLOR);
2023-02-05 15:04:42 +08:00
set_tui_log(deviceMsg);
2023-02-04 21:29:49 +08:00
newtComponent form = newtForm(NULL, NULL, 0);
2023-02-05 14:37:01 +08:00
newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome,
deviceMsg, NULL);
2023-02-04 21:29:49 +08:00
newtRunForm(form);
newtRefresh();
newtComponent buttonPressed = newtFormGetCurrent(form);
if (buttonPressed == optionsButton) {
ret = OPTIONS_SCREEN;
} else if (buttonPressed == startButton) {
if (can_start)
ret = ENTER_RECOVERY_SCREEN;
else
ret = MAIN_SCREEN;
} else if (buttonPressed == exitButton) {
ret = EXIT_SCREEN;
2023-01-29 01:02:47 +08:00
}
2023-02-05 15:04:42 +08:00
set_tui_log(NULL);
2023-02-05 02:42:12 +08:00
newtFormDestroy(form);
2023-01-29 01:02:47 +08:00
return ret;
2023-01-28 20:41:18 +08:00
}