Esempio n. 1
0
  bool render(void)
  {
    if(vmenu<0) { menustack.setsize(0); return false; }
    if(vmenu==1) refreshservers();
    gmenu &m = menus[vmenu];
    sprintf_sd(title)(vmenu>1 ? "[ %s menu ]" : "%s", m.name);
    int mdisp = m.items.length();
    int w = 0;
    loopi(mdisp)
    {
      int x = text_width(m.items[i].text);
      if(x>w) w = x;
    }

    int tw = text_width(title);
    if(tw>w) w = tw;
    int step = FONTH/4*5;
    int h = (mdisp+2)*step;
    int y = (VIRTH-h)/2;
    int x = (VIRTW-w)/2;
    blendbox(x-FONTH/2*3, y-FONTH, x+w+FONTH/2*3, y+h+FONTH, true);
    draw_text(title, x, y,2);
    y += FONTH*2;

    if(vmenu) {
      int bh = y+m.menusel*step;
      blendbox(x-FONTH, bh-10, x+w+FONTH, bh+FONTH+10, false);
    }
    loopj(mdisp) {
      draw_text(m.items[j].text, x, y, 2);
      y += step;
    }
    return true;
  }
Esempio n. 2
0
    virtual void render(int x, int y, int w)
    {
        bool sel = isselection();
        int range = max_-min_;
        int cval = value-min_;

        int tw = text_width(text);
        if(sel) renderbg(x+w-sliderwidth, y, sliderwidth, NULL);
        draw_text(text, x, y);
        draw_text(curval, x+tw, y);

        blendbox(x+w-sliderwidth, y+FONTH/3, x+w, y+FONTH*2/3, false, -1, &gray);
        int offset = (int)(cval/((float)range)*sliderwidth);
        blendbox(x+w-sliderwidth+offset-FONTH/6, y, x+w-sliderwidth+offset+FONTH/6, y+FONTH, false, -1, sel ? &whitepulse : &white);
    }
Esempio n. 3
0
 virtual void render(int x, int y, int w)
 {
     int tk = text_width(keyname ? keyname : " ");
     static color capturec(0.4f, 0, 0);
     if(isselection()) blendbox(x+w-tk-FONTH, y-FONTH/6, x+w+FONTH, y+FONTH+FONTH/6, false, -1, capture ? &capturec : NULL);
     draw_text(text, x, y);
     draw_text(keyname, x+w-tk, y);
 }
Esempio n. 4
0
 virtual void render(int x, int y, int w)
 {
     mitem::render(x, y, w);
     if(image || altfont)
     {
         int xs = 0;
         if(image)
         {
             glBindTexture(GL_TEXTURE_2D, image->id);
             glDisable(GL_BLEND);
             glColor3f(1, 1, 1);
             xs = (FONTH*image->xs)/image->ys;
             glBegin(GL_TRIANGLE_STRIP);
             glTexCoord2f(0, 0); glVertex2f(x,    y);
             glTexCoord2f(1, 0); glVertex2f(x+xs, y);
             glTexCoord2f(0, 1); glVertex2f(x,    y+FONTH);
             glTexCoord2f(1, 1); glVertex2f(x+xs, y+FONTH);
             glEnd();
             xtraverts += 4;
             glEnable(GL_BLEND);
         }
         draw_text(text, !image || *text == '\t' ? x : x+xs + FONTH/2, y);
         if(altfont && strchr(text, '\a'))
         {
             char *r = newstring(text), *re, *l = r;
             while((re = strchr(l, '\a')) && re[1])
             {
                 *re = '\0';
                 x += text_width(l);
                 l = re + 2;
                 pushfont(altfont->name);
                 draw_textf("%c", x, y, re[1]);
                 popfont();
             }
             delete[] r;
         }
         if(image && isselection() && !hidebigmenuimages && image->ys > FONTH)
         {
             w += FONTH;
             int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs;
             x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2;
             blendbox(x - FONTH, y - FONTH, x + xs + FONTH, y + ys + FONTH, false);
             glBindTexture(GL_TEXTURE_2D, image->id);               // I just copy&pasted this...
             glDisable(GL_BLEND);
             glColor3f(1, 1, 1);
             glBegin(GL_TRIANGLE_STRIP);
             glTexCoord2f(0, 0); glVertex2f(x,    y);
             glTexCoord2f(1, 0); glVertex2f(x+xs, y);
             glTexCoord2f(0, 1); glVertex2f(x,    y+ys);
             glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys);
             glEnd();
             xtraverts += 4;
             glEnable(GL_BLEND);
         }
     }
     else mitemmanual::render(x, y, w);
 }
Esempio n. 5
0
    virtual void render(int x, int y, int w)
    {
        mitem::render(x, y, w);
        if(image)
        {
            //int xs = 0;
            draw_text(text, x, y); // !image || *text == '\t' ? x : x+xs + FONTH/2
            if(image && isselection() && !hidebigmenuimages && image->ys > FONTH)
            {
                w += FONTH;
                int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs;
                x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2;

                blendbox(x - FONTH, y - FONTH, x + xs + FONTH, y + ys + FONTH, false);
                glBindTexture(GL_TEXTURE_2D, image->id);               // I just copy&pasted this...
                glDisable(GL_BLEND);
                glColor3f(1, 1, 1);
                glBegin(GL_TRIANGLE_STRIP);
                glTexCoord2f(0, 0); glVertex2f(x,    y);
                glTexCoord2f(1, 0); glVertex2f(x+xs, y);
                glTexCoord2f(0, 1); glVertex2f(x,    y+ys);
                glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys);
                glEnd();
                xtraverts += 4;
                glEnable(GL_BLEND);
                if(maptitle[0]) // 2011feb09:ft: TODO - this would be better as bottom line in the menu, just need to ensure it doesn't make the menu change width all the time!
                {
                    int mlil = maploaditemlength;
                    string showt;
                    string restt;
                    restt[0] = '\0';
                    filtertext(showt, maptitle, 1);
                    if(mlil && mlil != 255) // 0 && 255 are 'off'
                    {
                        int tl = strlen(showt);
                        if(tl>mlil)
                        {
                            int cr = 0;
                            int mr = min(max(0, tl-mlil), mlil);
                            for(cr=0;cr<mr;cr++) { restt[cr] = showt[cr+mlil]; }
                            if(cr>0) { restt[cr+1] = '\0'; showt[mlil] = '\0'; }
                        }
                    }
                    draw_text(showt, 1*FONTH/2, VIRTH - FONTH/2);
                    draw_text(restt, 3*FONTH/2, VIRTH + FONTH/2);
                }
                //if(mapstats[0]) draw_text(mapstats, x, y+ys+5*FONTH/2);
            }
        }
        else mitemmanual::render(x, y, w);
    }
Esempio n. 6
0
 virtual void render(int x, int y, int w)
 {
     bool sel = isselection();
     const static int boxsize = FONTH;
     draw_text(text, x, y);
     if(isselection()) renderbg(x+w-boxsize, y, boxsize, NULL);
     blendbox(x+w-boxsize, y, x+w, y+boxsize, false, -1, &gray);
     if(checked)
     {
         int x1 = x+w-boxsize-FONTH/6, x2 = x+w+FONTH/6, y1 = y-FONTH/6, y2 = y+boxsize+FONTH/6;
         line(x1, y1, x2, y2, sel ? &whitepulse : &white);
         line(x2, y1, x1, y2, sel ? &whitepulse : &white);
     }
 }
Esempio n. 7
0
 virtual void render(int x, int y, int w)
 {
     const bool sel = isselection();
     const static int boxsize = FONTH;
     const int stats = status();
     draw_text(gettext(), x, y);
     if(sel) renderbg(x+w-boxsize, y, boxsize, NULL);
     blendbox(x+w-boxsize, y, x+w, y+boxsize, false, -1, (stats & 2) ? &red : &gray);
     if(stats & 1)
     {
         int x1 = x+w-boxsize-FONTH/6, x2 = x+w+FONTH/6, y1 = y-FONTH/6, y2 = y+boxsize+FONTH/6;
         line(x1, y1, x2, y2, sel ? &whitepulse : &white);
         line(x2, y1, x1, y2, sel ? &whitepulse : &white);
     }
 }
Esempio n. 8
0
    void render()
    {
        int conwidth = (fullconsole ? VIRTW : int(floor(getradarpos().x))) * 2 - 2 * CONSPAD - 2 * FONTH / 3;
        int h = VIRTH*2 - 2*CONSPAD - 2*FONTH/3;
        int conheight = min(fullconsole ? (h*(fullconsole == 1 ? altconsize : fullconsize)) / 100 : FONTH*consize, h);

        if (fullconsole) blendbox(CONSPAD, CONSPAD, conwidth + CONSPAD + 2 * FONTH / 3, conheight + CONSPAD + 2 * FONTH / 3, true);

        int numl = conlines.length(), offset = min(conskip, numl);

        if (!fullconsole && confade)
        {
            if(!conskip)
            {
                numl = 0;
                loopvrev(conlines) if(totalmillis-conlines[i].millis < confade*1000 + 1000) { numl = i+1; break; }
            }
            else offset--;
Esempio n. 9
0
void mitem::renderbg(int x, int y, int w, color *c)
{
    if(isselection()) blendbox(x-FONTH/4, y-FONTH/6, x+w+FONTH/4, y+FONTH+FONTH/6, false, -1, c);
    else blendbox(x, y, x+w, y+FONTH, false, -1, c);
}