Changeset 1763


Ignore:
Timestamp:
Aug 16, 2012, 5:49:51 PM (8 years ago)
Author:
rez
Message:

calculate the number of items for the current setup menu (avoid selection of empty slot)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/render.cpp

    r1759 r1763  
    8585float beat_value = 0;      // value
    8686float beat_speed = 2.0f;   // speed
     87/* common variable */
     88float value, angle, radius, scale, speed;
     89/* shader variable */
     90vec2 buffer(0.7f,0.3f);         // [new frame mix,old frame mix]
     91vec2 remanency(0.3f,0.7f);      // remanency [source mix,buffer mix]
     92vec2 glow_mix(0.6f,0.4f);       // glow mix [source mix,glow mix]
     93vec2 glow_large(2.0f,2.0f);     // large glow radius [center,corner]
     94vec2 glow_small(1.0f,1.0f);     // small glow radius [center,corner]
     95vec2 blur(0.25f,0.5f);          // glow radius [center,corner]
     96vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom]
     97vec3 postfx_filter(0.8f,0.9f,0.4f);   // color filter [red,green,blue]
     98vec3 postfx_color(1.8f,1.5f,0.5f);    // color modifier [brightness,contrast,grayscale]
     99vec2 postfx_corner(0.75f,0.95f);      // corner [radius,blur]
     100vec3 postfx_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed]
     101vec2 postfx_offset(3.0f,3.0f);  // random line [horizontal,vertical]
     102float postfx_noise = 0.15f;     // noise
     103float postfx_aberration = 3.0f; // chromatic aberration
     104vec4 postfx_ghost(0.1f,0.25f,0.1f,0.5f);        // ghost picture [distance,strength,distance,strength]
     105vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);    // vertical moire [base,variable,repeat x,repeat y]
     106vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);    // horizontal moire [base,variable,repeat x,repeat y]
     107vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f); // vertical scanline [base,variable,repeat x,repeat y]
     108vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat x,repeat y]
    87109/* window variable */
    88110ivec2 border;              // border width
     
    94116ivec2 canvas_size(0,0);    // caca size
    95117/* setup variable */
    96 bool setup_switch=false;        // switch [option/item]
    97 int setup_option=0;             // selected option
    98 int setup_option_n=9;           // option number
    99 int setup_item=0;               // selected item
    100 int setup_item_n=8;             // item number
    101 int setup_item_key=0;           // item array key
     118bool setup_switch = false;      // switch [option/item]
     119int setup_option = 0;           // selected option
     120int setup_option_n = 10;        // option number
     121int setup_item = 0;             // selected item
     122int setup_item_n = 8;           // item number
     123int setup_item_key = 0;         // item array key
     124int setup_n = 0;                // contextual option/item number
    102125ivec2 setup_p(1,1);             // position [x,y]
    103126ivec3 setup_size(30,0,12);      // size [w,h,split]
    104 ivec2 setup_color(0x678,0x234); // size [w,h]
     127ivec2 setup_color(0x678,0x234); // color [foreground,background]
     128//vec3 radial(2.0f,0.8f,0);     // radial [mix,strength,color mode]
    105129char const *setup_text[] = {
     130    "theme",
     131        "default",
     132        "ye olde monitor",
     133        "green screen",
     134        "",
     135        "",
     136        "",
     137        "",
     138        "",
    106139    "remanency",
    107140        "enable",
     
    135168        "deform ratio",
    136169        "zoom base",
    137         "zoom variable",
    138170        "corner radius",
    139171        "corner blur",
     172        "",
    140173        "",
    141174        "",
     
    186219        "v repeat y"
    187220    };
    188 /* common variable */
    189 float value, angle, radius, scale, speed;
    190 /* shader variable */
    191 vec2 buffer(0.7f,0.3f);         // [new frame mix,old frame mix]
    192 vec2 remanency(0.3f,0.7f);      // remanency [source mix,buffer mix]
    193 vec2 glow_mix(0.6f,0.4f);       // glow mix [source mix,glow mix]
    194 vec2 glow_large(2.0f,2.0f);     // large glow radius [center,corner]
    195 vec2 glow_small(1.0f,1.0f);     // small glow radius [center,corner]
    196 vec2 blur(0.25f,0.5f);          // glow radius [center,corner]
    197 //vec3 radial(2.0f,0.8f,0);     // radial [mix,strength,color mode]
    198 //------------------------------// [IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I
    199 vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom]
    200 vec3 postfx_filter(0.8f,0.9f,0.4f);   // color filter [red,green,blue]
    201 vec3 postfx_color(1.8f,1.5f,0.5f);    // color modifier [brightness,contrast,grayscale]
    202 vec2 postfx_corner(0.75f,0.95f);      // corner [radius,blur]
    203 vec3 postfx_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed]
    204 vec2 postfx_offset(3.0f,3.0f);  // random line [horizontal,vertical]
    205 float postfx_noise = 0.15f;     // noise
    206 float postfx_aberration = 3.0f; // chromatic aberration
    207 vec4 postfx_ghost(0.1f,0.25f,0.1f,0.5f);        // ghost picture [distance,strength,distance,strength]
    208 vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);    // vertical moire [base,variable,repeat x,repeat y]
    209 vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);    // horizontal moire [base,variable,repeat x,repeat y]
    210 vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f); // vertical scanline [base,variable,repeat x,repeat y]
    211 vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat x,repeat y]
    212 //------------------------------//
    213 vec4 setup_var[]={
     221vec4 setup_var[]={ // setup variable [start,end,step,value]
     222    vec4(0), /* theme */
     223        vec4(0),
     224        vec4(0),
     225        vec4(0),
     226        vec4(0),
     227        vec4(0),
     228        vec4(0),
     229        vec4(0),
     230        vec4(0),
    214231    vec4(0), /* remanency */
    215232        vec4(0, 1, 1, 1),
     
    298315void Render::UpdateVar()
    299316{
    300     int k = 1;
     317    int k = 1; /* theme */
     318    k += 9; /* remanency */
    301319    m_shader_remanency = (setup_var[k].w == 1) ? true : false; k++;
    302320    buffer = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    303321    remanency = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    304     k += 4;
     322    k += 4; /* glow */
    305323    m_shader_glow = (setup_var[k].w == 1) ? true : false; k++;
    306324    glow_mix = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    307325    glow_large = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    308326    glow_small = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    309     k += 2;
     327    k += 2; /* blur */
    310328    m_shader_blur = (setup_var[k].w == 1) ? true : false; k++;
    311329    blur = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    312     k += 6;
     330    k += 6; /* screen */
    313331    m_shader_postfx = (setup_var[k].w == 1) ? true : false; k++;
    314332    postfx_deform = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    315333    postfx_corner = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    316     k += 4;
     334    k += 4; /* color */
    317335    postfx_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    318336    postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    319     k += 3;
     337    k += 3; /* noise */
    320338    postfx_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    321339    postfx_noise = setup_var[k].w; k++;
    322340    postfx_aberration = setup_var[k].w; k++;
    323341    postfx_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    324     k += 2;
     342    k += 2; /* ghost */
    325343    postfx_ghost = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    326     k += 5;
     344    k += 5; /* moire */
    327345    postfx_moire_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    328346    postfx_moire_v = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    329     k++;
     347    k++; /* scanline */
    330348    postfx_scanline_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    331349    postfx_scanline_v = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
     350}
     351
     352int calc_item_length()
     353{
     354    int n = !setup_switch ? setup_option_n : setup_item_n;
     355    int v = 0;
     356    for (int i = 0; i < n; i++)
     357    {
     358        int k = !setup_switch ? (i * (setup_item_n + 1)) : (setup_option * (setup_item_n + 1) + 1 + i);
     359        if (setup_text[k] == "") return i;
     360    }
     361    return n - 1;
    332362}
    333363
     
    486516    setup_p = (canvas_char - setup_size.xy) / 2;
    487517
     518    setup_n = calc_item_length();
     519
    488520    InitDraw();
    489521    return true;
     
    552584        {
    553585            setup_switch = !setup_switch;
     586            setup_n = calc_item_length();
    554587        }
    555588        timer_key = timer;
     
    562595            {
    563596                setup_option--;
    564                 if (setup_option < 0) setup_option = setup_option_n - 1;
     597                if (setup_option < 0) setup_option = setup_n;
    565598                setup_item = 0;
    566599            }
     
    568601            {
    569602                setup_item--;
    570                 if (setup_item < 0) setup_item = setup_item_n - 1;
     603                if (setup_item < 0) setup_item = setup_n;
    571604            }
    572605        }
     
    580613            {
    581614                setup_option++;
    582                 if (setup_option > setup_option_n - 1) setup_option = 0;
     615                if (setup_option > setup_n) setup_option = 0;
    583616                setup_item = 0;
    584617            }
     
    586619            {
    587620                setup_item++;
    588                 if (setup_item > setup_item_n - 1) setup_item = 0;
     621                if (setup_item > setup_n) setup_item = 0;
    589622            }
    590623        }
     
    612645            if (!setup_switch)
    613646            {
    614                 setup_option = setup_option_n - 1;
     647                setup_option = setup_n;
    615648                setup_item = 0;
    616649            }
    617650            else
    618651            {
    619                 setup_item = setup_item_n - 1;
     652                setup_item = setup_n;
    620653            }
    621654        }
     
    734767        {
    735768            int y = setup_p.y + 1 + i;
    736             int k = setup_option * (setup_item_n + 1) + 1;
     769            int k = setup_option * (setup_item_n + 1) + 1 + i;
    737770            if (setup_item != i || !setup_switch)
    738771            {
    739772                caca_set_color_argb(m_caca, setup_color.x, setup_color.y);
    740                 caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k + i]);
     773                caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k]);
    741774            }
    742775            else
     
    744777                caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    745778                caca_draw_line(m_caca, setup_p.x + setup_size.z, y, setup_p.x + setup_size.x, y,' ');
    746                 caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k + i]);
     779                caca_put_str(m_caca, setup_p.x + setup_size.z + 1, y, setup_text[k]);
    747780            }
    748781        }
     
    752785        caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
    753786        caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' ');
    754         if (setup_switch && setup_text[setup_item_key] != "")
     787        if (setup_switch)
    755788        {
    756789            int w = setup_size.x - 3 - 4;
Note: See TracChangeset for help on using the changeset viewer.