terminal if the setup window is active.master
| @@ -58,7 +58,6 @@ void Neercs::TickGame(float seconds) | |||
| WorldEntity::TickGame(seconds); | |||
| } | |||
| void Neercs::TickDraw(float seconds) | |||
| { | |||
| WorldEntity::TickDraw(seconds); | |||
| @@ -23,6 +23,8 @@ using namespace lol; | |||
| #include "../neercs.h" | |||
| #include "term.h" | |||
| extern bool g_setup; | |||
| Term::Term(ivec2 size) | |||
| : m_pty(0), | |||
| m_caca(caca_create_canvas(size.x, size.y)), | |||
| @@ -44,31 +46,71 @@ void Term::TickGame(float seconds) | |||
| Entity::TickGame(seconds); | |||
| #if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H | |||
| bool have_ctrl = Input::GetStatus(Key::LeftCtrl) | |||
| || Input::GetStatus(Key::RightCtrl); | |||
| bool have_shift = Input::GetStatus(Key::LeftShift) | |||
| || Input::GetStatus(Key::RightShift); | |||
| for (int i = 0x0; i < 0x7f; ++i) | |||
| if (!g_setup) | |||
| { | |||
| if (Input::WasPressed((Key::Value)i)) | |||
| bool have_ctrl = Input::GetStatus(Key::LeftCtrl) | |||
| || Input::GetStatus(Key::RightCtrl); | |||
| bool have_shift = Input::GetStatus(Key::LeftShift) | |||
| || Input::GetStatus(Key::RightShift); | |||
| /* Check for standard ASCII keys */ | |||
| for (int i = 0x0; i < 0x7f; ++i) | |||
| { | |||
| if (have_ctrl && i >= 'a' && i <= 'z') | |||
| { | |||
| char c = i + 1 - 'a'; | |||
| m_pty->WriteData(&c, 1); | |||
| } | |||
| else if (have_shift && i >= 'a' && i <= 'z') | |||
| { | |||
| char c = i + 'A' - 'a'; | |||
| m_pty->WriteData(&c, 1); | |||
| } | |||
| else | |||
| if (Input::WasPressed((Key::Value)i)) | |||
| { | |||
| char c = i; | |||
| m_pty->WriteData(&c, 1); | |||
| if (have_ctrl && i >= 'a' && i <= 'z') | |||
| { | |||
| char c = i + 1 - 'a'; | |||
| m_pty->WriteData(&c, 1); | |||
| } | |||
| else if (have_shift && i >= 'a' && i <= 'z') | |||
| { | |||
| char c = i + 'A' - 'a'; | |||
| m_pty->WriteData(&c, 1); | |||
| } | |||
| else | |||
| { | |||
| char c = i; | |||
| m_pty->WriteData(&c, 1); | |||
| } | |||
| } | |||
| } | |||
| /* Check for special keys */ | |||
| static struct { Key::Value k; char const *str; int len; } const lut[] = | |||
| { | |||
| { Key::Up, "\033OA", 3 }, | |||
| { Key::Down, "\033OB", 3 }, | |||
| { Key::Right, "\033OC", 3 }, | |||
| { Key::Left, "\033OD", 3 }, | |||
| { Key::PageUp, "\033[5~", 4 }, | |||
| { Key::PageDown, "\033[6~", 4 }, | |||
| { Key::Home, "\033[1~", 4 }, | |||
| { Key::Insert, "\033[2~", 4 }, | |||
| { Key::Delete, "\033[3~", 4 }, | |||
| { Key::End, "\033[4~", 4 }, | |||
| #if 0 /* FIXME: disabled for now (used by the theme system */ | |||
| { Key::F1, "\033[11~", 5 }, | |||
| { Key::F2, "\033[12~", 5 }, | |||
| { Key::F3, "\033[13~", 5 }, | |||
| { Key::F4, "\033[14~", 5 }, | |||
| { Key::F5, "\033[15~", 5 }, | |||
| { Key::F6, "\033[17~", 5 }, | |||
| { Key::F7, "\033[18~", 5 }, | |||
| { Key::F8, "\033[19~", 5 }, | |||
| { Key::F9, "\033[20~", 5 }, | |||
| { Key::F10, "\033[21~", 5 }, | |||
| { Key::F11, "\033[23~", 5 }, | |||
| { Key::F12, "\033[24~", 5 }, | |||
| #endif | |||
| }; | |||
| for (size_t i = 0; i < sizeof(lut) / sizeof(*lut); i++) | |||
| { | |||
| if (!have_ctrl && !have_shift) | |||
| if (Input::WasPressed(lut[i].k)) | |||
| m_pty->WriteData(lut[i].str, lut[i].len); | |||
| } | |||
| } | |||
| /* This is the real terminal code */ | |||
| @@ -44,6 +44,11 @@ extern char const *lolfx_mirror; | |||
| #define PID M_PI/180.0f // pi ratio | |||
| /* | |||
| * Global variable -- ugly | |||
| */ | |||
| bool g_setup = true; | |||
| /* | |||
| * Various variables | |||
| */ | |||
| @@ -579,7 +584,6 @@ Render::Render(caca_canvas_t *caca) | |||
| m_ready(false), | |||
| m_pause(false), | |||
| m_polygon(true), | |||
| m_setup(true), | |||
| m_shader(true), | |||
| m_shader_glow(true), | |||
| m_shader_blur(true), | |||
| @@ -610,7 +614,7 @@ void Render::TickGame(float seconds) | |||
| */ | |||
| /* draw setup */ | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| /* background */ | |||
| caca_set_color_argb(m_cv_setup, setup_color.x, setup_color.y); | |||
| @@ -707,8 +711,8 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::F1)) | |||
| { | |||
| m_setup = !m_setup; | |||
| if (m_setup) setup_n = calc_item_length(); | |||
| g_setup = !g_setup; | |||
| if (g_setup) setup_n = calc_item_length(); | |||
| sync_flag = true; | |||
| sync_angle = main_angle; | |||
| } | |||
| @@ -728,7 +732,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Tab)) | |||
| { | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| setup_switch = !setup_switch; | |||
| setup_n = calc_item_length(); | |||
| @@ -737,7 +741,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Up)) | |||
| { | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| if (!setup_switch) | |||
| { | |||
| @@ -787,7 +791,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Down)) | |||
| { | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| if (!setup_switch) | |||
| { | |||
| @@ -837,7 +841,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::PageUp)) | |||
| { | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| if (!setup_switch) | |||
| { | |||
| @@ -886,7 +890,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::PageDown)) | |||
| { | |||
| if (m_setup) | |||
| if (g_setup) | |||
| { | |||
| if (!setup_switch) | |||
| { | |||
| @@ -935,7 +939,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Left)) | |||
| { | |||
| if (m_setup && setup_switch) | |||
| if (g_setup && setup_switch) | |||
| { | |||
| setup_var[setup_item_key].w -= setup_var[setup_item_key].z; | |||
| if (setup_var[setup_item_key].w < setup_var[setup_item_key].x) setup_var[setup_item_key].w = setup_var[setup_item_key].x; | |||
| @@ -944,7 +948,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Right)) | |||
| { | |||
| if (m_setup && setup_switch) | |||
| if (g_setup && setup_switch) | |||
| { | |||
| setup_var[setup_item_key].w += setup_var[setup_item_key].z; | |||
| if (setup_var[setup_item_key].w > setup_var[setup_item_key].y) setup_var[setup_item_key].w = setup_var[setup_item_key].y; | |||
| @@ -953,7 +957,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::Home)) | |||
| { | |||
| if (m_setup && setup_switch) | |||
| if (g_setup && setup_switch) | |||
| { | |||
| setup_var[setup_item_key].w = setup_var[setup_item_key].x; | |||
| UpdateVar(); | |||
| @@ -961,7 +965,7 @@ void Render::TickDraw(float seconds) | |||
| } | |||
| if (Input::WasPressed(Key::End)) | |||
| { | |||
| if (m_setup && setup_switch) | |||
| if (g_setup && setup_switch) | |||
| { | |||
| setup_var[setup_item_key].w = setup_var[setup_item_key].y; | |||
| UpdateVar(); | |||
| @@ -1041,7 +1045,7 @@ void Render::Draw2D() | |||
| /* Draw text in an offline buffer */ | |||
| m_txt_screen->Render(); | |||
| if (m_setup) | |||
| if (g_setup) | |||
| m_txt_setup->Render(); | |||
| if (m_shader) | |||
| @@ -1058,7 +1062,7 @@ void Render::Draw2D() | |||
| Video::Clear(ClearMask::Color | ClearMask::Depth); | |||
| m_txt_screen->Blit(border, canvas_size); | |||
| if (m_setup) | |||
| if (g_setup) | |||
| m_txt_setup->Blit((screen_size - setup_canvas_size) / 2, setup_canvas_size); | |||
| //if (m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH); | |||
| @@ -36,7 +36,6 @@ private: | |||
| bool m_ready; | |||
| bool m_pause; | |||
| bool m_polygon; | |||
| bool m_setup; | |||
| bool m_shader; | |||
| bool m_shader_glow; | |||
| bool m_shader_blur; | |||