From 18b7447713930b43d97424ba03026fba4a3f8620 Mon Sep 17 00:00:00 2001 From: rez Date: Sat, 15 Sep 2012 23:44:17 +0000 Subject: [PATCH] NEERCS: multiple pageup/pagedown now works --- neercs/video/render.cpp | 104 +++++++++++++++++++++++++++++++++------- neercs/video/text.lolfx | 3 +- 2 files changed, 88 insertions(+), 19 deletions(-) diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index bd0e156..4489efc 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -120,7 +120,7 @@ ivec2 border = vec2(3,1) * ratio_2d * font_size; // border width /* setup variable */ bool setup_switch = false; // switch [option/item] int setup_n = 0; // item/option number -int setup_h = 6; // height +int setup_h = 3; // height int setup_cursor = 0; // cursor position int setup_option_i = 0; // selected option int setup_option_n = 10; // option number @@ -130,8 +130,8 @@ int setup_item_n = 8; // item number int setup_item_p = 0; // item position int setup_item_key = 0; // item array key ivec2 setup_p(1,1); // position [x,y] -ivec3 setup_size(30,7,12); // size [w,h,split] -ivec2 setup_color(0x678,0x234); // color [foreground,background] +ivec3 setup_size(29,4,12); // size [w,h,split] +ivec2 setup_color(0xaaa,0x222); // color [foreground,background] 0x678,0x234 char const *setup_text[] = { "main", "2d ratio w", @@ -462,7 +462,7 @@ int Render::InitDraw(void) glEnable(GL_CULL_FACE); // disable cull face glCullFace(GL_BACK); // don't draw front face - /* Initialise framebuffer objects */ + /* initialise framebuffer objects */ fbo_back = new FrameBuffer(screen_size); fbo_front = new FrameBuffer(screen_size); fbo_buffer = new FrameBuffer(screen_size); @@ -529,7 +529,8 @@ int Render::InitDraw(void) shader_postfx_corner = shader_postfx->GetUniformLocation("corner"); shader_postfx_sync = shader_postfx->GetUniformLocation("sync"); shader_postfx_beat = shader_postfx->GetUniformLocation("beat"); - + // initialize setup + setup_n = calc_item_length(); return true; } @@ -621,10 +622,9 @@ void Render::TickGame(float seconds) if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 1) { /* Work around a bug in libcaca */ - if (setup_p.x + setup_size.x - 4 < caca_get_canvas_width(m_caca)) - caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w); + if (setup_p.x + setup_size.x - 4 < caca_get_canvas_width(m_caca)) caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w); caca_draw_line(m_caca, x, y, x - bar_x + bar_w * setup_var[setup_item_key].y, y,'.'); - if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_caca, x, y, x - bar_x + bar_w * setup_var[setup_item_key].w, y,'x'); + if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_caca, x, y, x - bar_x + bar_w * setup_var[setup_item_key].w, y, 'x'); } else { @@ -634,6 +634,10 @@ void Render::TickGame(float seconds) } } } + else + { + caca_printf(m_caca, setup_p.x + 1, y, "%d/%d [%d]", setup_option_i, setup_n, setup_option_p); + } /* informations */ int w = caca_get_canvas_width(m_caca); @@ -790,14 +794,46 @@ void Render::TickDraw(float seconds) { if (!setup_switch) { - setup_option_i -= setup_cursor; - setup_cursor = 0; - setup_item_i = 0; + if (setup_cursor > 0) + { + setup_option_i -= setup_cursor; + setup_cursor = 0; + } + else + { + if (setup_option_i > setup_h) + { + setup_option_i -= setup_h; + setup_option_p -= setup_h; + } + else + { + setup_option_i = 0; + setup_option_p = 0; + } + } + setup_item_i = 0; } else { - setup_item_i -= setup_cursor; - setup_cursor = 0; + if (setup_cursor > 0) + { + setup_item_i -= setup_cursor; + setup_cursor = 0; + } + else + { + if (setup_item_i > setup_h) + { + setup_item_i -= setup_h; + setup_item_p -= setup_h; + } + else + { + setup_item_i = 0; + setup_item_p = 0; + } + } } } } @@ -807,14 +843,46 @@ void Render::TickDraw(float seconds) { if (!setup_switch) { - setup_option_i += setup_h - setup_cursor - 1; - setup_cursor = setup_h - 1; - setup_item_i = 0; + if (setup_cursor < setup_h - 1) + { + setup_option_i += setup_h - setup_cursor - 1; + setup_cursor = setup_h - 1; + setup_item_i = 0; + } + else + { + if (setup_option_i < setup_option_n - setup_h - 1) + { + setup_option_i += setup_h; + setup_option_p += setup_h; + } + else + { + setup_option_i = setup_option_n - 1; + setup_option_p = setup_option_n - setup_h; + } + } } else { - setup_item_i += (setup_n < setup_h) ? setup_n - setup_cursor : setup_h - setup_cursor - 1; - setup_cursor = (setup_n < setup_h) ? setup_n : setup_h - 1; + if (setup_cursor < setup_h - 1) + { + setup_item_i += (setup_n < setup_h) ? setup_n - setup_cursor : setup_h - setup_cursor - 1; + setup_cursor = (setup_n < setup_h) ? setup_n : setup_h - 1; + } + else + { + if (setup_item_i < setup_n - setup_h + 1) + { + setup_item_i += setup_h; + setup_item_p += setup_h; + } + else + { + setup_item_i = setup_n; + setup_item_p = setup_n - setup_h + 1; + } + } } } } diff --git a/neercs/video/text.lolfx b/neercs/video/text.lolfx index bdd28e0..4b701ed 100644 --- a/neercs/video/text.lolfx +++ b/neercs/video/text.lolfx @@ -50,7 +50,8 @@ void main() float H = 1.0; #endif - pass_Background = vec4(0.125, 0.125, 0.125, 1.0 - A);//vec4(B, C, D, 1.0 - A); + //pass_Background = vec4(B, C, D, 1.0 - A); // original + pass_Background = vec4(B + 0.0625, C + 0.125, D + 0.125, 1.0 - A); pass_Foreground = vec4(F, G, H, 1.0 - E); if (B + C + D < 0.01) A = 1.0; if (F + G + H < 0.01) E = 1.0;