aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/i18n/en_us.h26
-rw-r--r--client/setup.c1
-rw-r--r--client/strings.c11
-rw-r--r--client/strings.h4
-rw-r--r--client/ui.c11
-rw-r--r--client/ui.h17
-rw-r--r--client/ui_dirc.c2
-rw-r--r--client/ui_start.c7
-rw-r--r--client/ui_tabbar.c25
9 files changed, 90 insertions, 14 deletions
diff --git a/client/i18n/en_us.h b/client/i18n/en_us.h
index 5547db5..ff3ae91 100644
--- a/client/i18n/en_us.h
+++ b/client/i18n/en_us.h
@@ -17,3 +17,29 @@
#define W2_UI_MODE_MAZE "maze"
#define W2_UI_MODE_SCAL "sensor calibration"
#define W2_UI_MODE_SPIN "wet floor simulation"
+#define W2_UI_TAB_LABEL_START "info"
+#define W2_UI_TAB_LABEL_DIRC "direct control"
+#define W2_UI_TAB_LABEL_ERRCATCH "logs"
+#define W2_UI_TAB_LABEL_MCFG "map"
+#define W2_UI_TAB_LABEL_ORDERS "orders"
+#define W2_UI_TAB_LABEL_MODE "set mode"
+#define W2_UI_TAB_START_MESSAGE "" \
+ "welcome to the wall-e2 console application!\n" \
+ "this is client version " W2_BUILD_STR "\n" \
+ "\n" \
+ "this application is functionally similar to a BIOS.\n" \
+ "here's a brief summary of keyboard commands:\n" \
+ "\n" \
+ "<left>/<right>, <h>/<l> switch tabs\n" \
+ "<up>/<down>, <j>/<k> select option\n" \
+ "<enter>, <i> edit option\n" \
+ "<home>, <g> scroll to top\n" \
+ "<end>, <G> scroll to bottom\n" \
+ "<escape> back\n" \
+ "<q> exit\n" \
+ "\n" \
+ "tab shortcuts:\n" \
+ "<N> info <o> orders\n" \
+ "<S> logs <M> set mode\n" \
+ "<d> direct control <m> map\n"
+
diff --git a/client/setup.c b/client/setup.c
index 22f7e4c..e51965f 100644
--- a/client/setup.c
+++ b/client/setup.c
@@ -36,6 +36,7 @@ void w2_client_setup(int argc, char **argv) {
w2_strings_init();
w2_cmd_setup_handlers();
+ w2_ui_tabbar_init();
w2_send_info();
diff --git a/client/strings.c b/client/strings.c
index a119d9a..720f7b8 100644
--- a/client/strings.c
+++ b/client/strings.c
@@ -1,6 +1,7 @@
#include "strings.h"
char *g_w2_mode_strings[W2_MODE_COUNT];
+char *g_w2_tab_strings[W2_UI_TAB_COUNT];
void w2_strings_modes_init() {
g_w2_mode_strings[W2_M_CHRG] = W2_UI_MODE_CHRG;
@@ -12,4 +13,12 @@ void w2_strings_modes_init() {
g_w2_mode_strings[W2_M_SPIN] = W2_UI_MODE_SPIN;
}
-void w2_strings_init() { w2_strings_modes_init(); }
+void w2_strings_tabs_init() {
+ g_w2_tab_strings[W2_UI_TAB_START] = W2_UI_TAB_LABEL_START;
+ g_w2_tab_strings[W2_UI_TAB_DIRC] = W2_UI_TAB_LABEL_DIRC;
+}
+
+void w2_strings_init() {
+ w2_strings_modes_init();
+ w2_strings_tabs_init();
+}
diff --git a/client/strings.h b/client/strings.h
index 0085228..ec1f415 100644
--- a/client/strings.h
+++ b/client/strings.h
@@ -2,9 +2,9 @@
#include "../shared/modes.h"
#include "i18n.h"
-
-#define W2_STRINGS_MODE_MAP_BUFFER_SIZE 32
+#include "ui.h"
extern char *g_w2_mode_strings[W2_MODE_COUNT];
+extern char *g_w2_tab_strings[W2_UI_TAB_COUNT];
void w2_strings_init();
diff --git a/client/ui.c b/client/ui.c
index 7731215..a1d15ad 100644
--- a/client/ui.c
+++ b/client/ui.c
@@ -15,8 +15,8 @@ WINDOW *g_w2_ui_pad_tabbar;
WINDOW *g_w2_ui_pad_body;
unsigned int g_w2_ui_width = 0;
unsigned int g_w2_ui_height = 0;
-void (*g_w2_ui_current_tab)(bool first) = &w2_ui_dirc;
-void (*g_w2_ui_last_tab)(bool first) = NULL;
+w2_e_ui_tab g_w2_ui_current_tab = W2_UI_TAB_START;
+w2_e_ui_tab g_w2_ui_last_tab;
void w2_wmvaddstr(WINDOW *win, unsigned int y, unsigned int x, char *str) {
wmove(win, y, x);
@@ -38,7 +38,7 @@ void w2_ui_main() {
void w2_ui_paint() {
w2_ui_paint_statusbar();
if (w2_timer_end(W2_TIMER_UPDATE) >= (1000 / W2_UI_UPDATE_FPS)) {
- (*g_w2_ui_current_tab)(g_w2_ui_last_tab != g_w2_ui_current_tab);
+ (*g_w2_tab_ptrs[g_w2_ui_current_tab])(g_w2_ui_last_tab != g_w2_ui_current_tab);
g_w2_ui_last_tab = g_w2_ui_current_tab;
w2_timer_start(W2_TIMER_UPDATE);
}
@@ -78,8 +78,3 @@ void w2_ui_paint_statusbar() {
mvaddnstr(3, 0, temp, g_w2_ui_width);
}
-void w2_ui_paint_tabbar() {
- char temp[g_w2_ui_width];
- sprintf(temp, "-- tab bar here --");
- w2_wmvaddstr(g_w2_ui_pad_tabbar, 0, g_w2_ui_width / 2 - strlen(temp) / 2, temp);
-}
diff --git a/client/ui.h b/client/ui.h
index a4c4ed1..cbf18ee 100644
--- a/client/ui.h
+++ b/client/ui.h
@@ -5,12 +5,19 @@
#define W2_UI_UPDATE_FPS (60)
+#define W2_UI_TAB_COUNT 2
+typedef enum {
+ W2_UI_TAB_START = 0,
+ W2_UI_TAB_DIRC = 1,
+} w2_e_ui_tab;
+
extern WINDOW *g_w2_ui_win;
extern WINDOW *g_w2_ui_pad_tabbar;
extern WINDOW *g_w2_ui_pad_body;
extern unsigned int g_w2_ui_width;
extern unsigned int g_w2_ui_height;
-extern void (*g_w2_ui_current_tab)(bool first);
+extern void (*g_w2_tab_ptrs[W2_UI_TAB_COUNT])(bool first);
+extern w2_e_ui_tab g_w2_ui_current_tab;
/** update terminal props */
void w2_ui_update();
@@ -26,7 +33,13 @@ void w2_ui_paint_statusbar();
/** draw tab bar */
void w2_ui_paint_tabbar();
-void w2_ui_dirc(bool first);
+void w2_ui_tabbar_init();
+
+void w2_ui_tab_dirc(bool first);
+void w2_ui_tab_start(bool first);
void w2_wmvaddstr(WINDOW *win, unsigned int y, unsigned int x, char *str);
void w2_wmvaddnstr(WINDOW *win, unsigned int y, unsigned int x, char *str, unsigned int len);
+
+
+
diff --git a/client/ui_dirc.c b/client/ui_dirc.c
index c23134b..d275ddf 100644
--- a/client/ui_dirc.c
+++ b/client/ui_dirc.c
@@ -86,7 +86,7 @@ void w2_ui_dirc_paint(int left, int right) {
"<space> send dirc mode command");
}
-void w2_ui_dirc(bool first) {
+void w2_ui_tab_dirc(bool first) {
if (first) w2_ui_dirc_init();
int ch = 0;
unsigned int lb = 0;
diff --git a/client/ui_start.c b/client/ui_start.c
new file mode 100644
index 0000000..b656c35
--- /dev/null
+++ b/client/ui_start.c
@@ -0,0 +1,7 @@
+#include "ui.h"
+#include "i18n.h"
+
+void w2_ui_tab_start(bool first) {
+ refresh();
+ w2_wmvaddstr(g_w2_ui_pad_body, 0, 0, W2_UI_TAB_START_MESSAGE);
+}
diff --git a/client/ui_tabbar.c b/client/ui_tabbar.c
new file mode 100644
index 0000000..fc43db9
--- /dev/null
+++ b/client/ui_tabbar.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "ui.h"
+
+unsigned int g_w2_ui_tabbar_scroll = 0;
+unsigned int g_w2_ui_tabbar_lengths[W2_UI_TAB_COUNT];
+void (*g_w2_tab_ptrs[W2_UI_TAB_COUNT])(bool first);
+
+void w2_ui_tabbar_init() {
+ g_w2_tab_ptrs[W2_UI_TAB_START] = &w2_ui_tab_start;
+ g_w2_tab_ptrs[W2_UI_TAB_DIRC] = &w2_ui_tab_dirc;
+}
+
+char* w2_ui_tabbar_format_tab(char* name, bool selected) {
+ char* ret_val = malloc(strlen(name) + 3);
+ printf("%c%s%c", selected ? '[' : ' ', name, selected ? ']' : ' ');
+ return ret_val;
+}
+
+void w2_ui_paint_tabbar() {
+ char temp[g_w2_ui_width];
+ sprintf(temp, "-- tab bar here --");
+ w2_wmvaddstr(g_w2_ui_pad_tabbar, 0, g_w2_ui_width / 2 - strlen(temp) / 2, temp);
+}