Beispiel #1
0
 int image(Texture *t, float scale, bool overlaid)
 {
     autotab();
     if(scale==0) scale = 1;
     int size = (int)(scale*2*FONTH)-SHADOW;
     if(visible()) icon_(t, overlaid, curx, cury, size, ishit(size+SHADOW, size+SHADOW));
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #2
0
 int texture(VSlot &vslot, float scale, bool overlaid)
 {
     autotab();
     if(scale==0) scale = 1;
     int size = (int)(scale*2*FONTH)-SHADOW;
     if(visible()) previewslot(vslot, overlaid, curx, cury, size, ishit(size+SHADOW, size+SHADOW));
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #3
0
 int texture(Texture *t, float scale, int rotate, int xoff, int yoff, Texture *glowtex, const vec &glowcolor, Texture *layertex)
 {
     autotab();
     if(scale==0) scale = 1;
     int size = (int)(scale*2*FONTH)-SHADOW;
     if(t!=notexture && visible()) icon_(t, true, true, curx, cury, size, ishit(size+SHADOW, size+SHADOW), rotate, xoff, yoff, glowtex, glowcolor, layertex);
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #4
0
 int playerpreview(int model, int team, int weap, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             glDisable(GL_TEXTURE_2D);
             notextureshader->set();
             glColor4f(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             glEnable(GL_TEXTURE_2D);
             defaultshader->set();
         }
         int x1 = int(floor(screenw*(xi*scale.x+origin.x))), y1 = int(floor(screenh*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screenw*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screenh*(1 - (yi*scale.y+origin.y))));
         glViewport(x1, y1, x2-x1, y2-y1);
         glScissor(x1, y1, x2-x1, y2-y1);
         glEnable(GL_SCISSOR_TEST);
         glDisable(GL_BLEND);
         modelpreview::start(overlaid);
         game::renderplayerpreview(model, team, weap);
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         modelpreview::end();
         glDisable(GL_SCISSOR_TEST);
         glViewport(0, 0, screenw, screenh);
         if(overlaid)
         {
             if(hit)
             {
                 glDisable(GL_TEXTURE_2D);
                 notextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 glColor3f(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 glEnable(GL_TEXTURE_2D);
                 defaultshader->set();
             }
             if(!overlaytex) {
                 string otname;
                 inexor::filesystem::appendmediadir(otname, "guioverlay.png", DIR_UI);
                 overlaytex = textureload(otname, 3);
             }
             glColor3fv(light.v);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #5
0
 int modelpreview(const char *name, int anim, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             hudnotextureshader->set();
             gle::colorf(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             hudshader->set();
         }
         int x1 = int(floor(screen->w*(xi*scale.x+origin.x))), y1 = int(floor(screen->h*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screen->w*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screen->h*(1 - (yi*scale.y+origin.y))));
         glDisable(GL_BLEND);
         modelpreview::start(x1, y1, x2-x1, y2-y1, overlaid);
         model *m = loadmodel(name);
         if(m)
         {
             entitylight light;
             light.color = vec(1, 1, 1);
             light.dir = vec(0, -1, 2).normalize();
             vec center, radius;
             m->boundbox(center, radius);
             float yaw;
             vec o = calcmodelpreviewpos(radius, yaw).sub(center);
             rendermodel(&light, name, anim, o, yaw, 0, 0, NULL, NULL, 0);
         }
         modelpreview::end();
         hudshader->set();
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         if(overlaid)
         {
             if(hit)
             {
                 hudnotextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 gle::colorf(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 hudshader->set();
             }
             if(!overlaytex) overlaytex = textureload("data/guioverlay.png", 3);
             gle::color(light);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #6
0
    void slider(int &val, int vmin, int vmax, int color, char *label)
    {
        autotab();
        int x = curx;
        int y = cury;
        line_(10);
        if(visible())
        {
            if(!label)
            {
                static string s;
                formatstring(s)("%d", val);
                label = s;
            }
            int w = text_width(label);

            bool hit;
            int px, py;
            if(ishorizontal())
            {
                hit = ishit(FONTH, ysize, x, y);
                px = x + (FONTH-w)/2;
                py = y + (ysize-FONTH) - ((ysize-FONTH)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at bottom
            }
            else
            {
                hit = ishit(xsize, FONTH, x, y);
                px = x + FONTH/2 - w/2 + ((xsize-w)*(val-vmin))/((vmax==vmin) ? 1 : (vmax-vmin)); //vmin at left
                py = y;
            }

            if(hit) color = 0xFF0000;
            text_(label, px, py, color, hit && actionon);
            if(hit && actionon)
            {
                int vnew = (vmin < vmax ? 1 : -1)+vmax-vmin;
                if(ishorizontal()) vnew = int(vnew*(y+ysize-FONTH/2-hity)/(ysize-FONTH));
                else vnew = int(vnew*(hitx-x-FONTH/2)/(xsize-w));
                vnew += vmin;
                vnew = vmin < vmax ? clamp(vnew, vmin, vmax) : clamp(vnew, vmax, vmin);
                if(vnew != val) val = vnew;
            }
        }
    }
Beispiel #7
0
 int prefabpreview(const char *prefab, const vec &color, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             hudnotextureshader->set();
             gle::colorf(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             hudshader->set();
         }
         int x1 = int(floor(screen->w*(xi*scale.x+origin.x))), y1 = int(floor(screen->h*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screen->w*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screen->h*(1 - (yi*scale.y+origin.y))));
         glDisable(GL_BLEND);
         modelpreview::start(x1, y1, x2-x1, y2-y1, overlaid);
         previewprefab(prefab, color);
         modelpreview::end();
         hudshader->set();
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         if(overlaid)
         {
             if(hit)
             {
                 hudnotextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 gle::colorf(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 hudshader->set();
             }
             if(!overlaytex) overlaytex = textureload("data/guioverlay.png", 3);
             gle::color(light);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }
Beispiel #8
0
 void progress(float percent) { autotab(); line_((FONTH*4)/5, percent); }
Beispiel #9
0
 void separator() { autotab(); line_(FONTH/3); }
Beispiel #10
0
 int title (const char *text, int color, const char *icon) { autotab(); return button_(text, color, icon, false, true); }
Beispiel #11
0
 int button(const char *text, int color, const char *icon) { autotab(); return button_(text, color, icon, true, false); }
Beispiel #12
0
 void separator() { autotab(); line_(5); }
Beispiel #13
0
 int modelpreview(const char *name, int anim, float sizescale, bool overlaid)
 {
     autotab();
     if(sizescale==0) sizescale = 1;
     int size = (int)(sizescale*2*FONTH)-SHADOW;
     if(visible())
     {
         bool hit = ishit(size+SHADOW, size+SHADOW);
         float xs = size, ys = size, xi = curx, yi = cury;
         if(overlaid && hit && actionon)
         {
             glDisable(GL_TEXTURE_2D);
             notextureshader->set();
             glColor4f(0, 0, 0, 0.75f);
             rect_(xi+SHADOW, yi+SHADOW, xs, ys);
             glEnable(GL_TEXTURE_2D);
             defaultshader->set();
         }
         int x1 = int(floor(screenw*(xi*scale.x+origin.x))), y1 = int(floor(screenh*(1 - ((yi+ys)*scale.y+origin.y)))),
             x2 = int(ceil(screenw*((xi+xs)*scale.x+origin.x))), y2 = int(ceil(screenh*(1 - (yi*scale.y+origin.y))));
         glViewport(x1, y1, x2-x1, y2-y1);
         glScissor(x1, y1, x2-x1, y2-y1);
         glEnable(GL_SCISSOR_TEST);
         glDisable(GL_BLEND);
         modelpreview::start(overlaid);
         model *m = loadmodel(name);
         if(m)
         {
             entitylight light;
             light.color = vec(1, 1, 1);
             light.dir = vec(0, -1, 2).normalize();
             vec center, radius;
             m->boundbox(center, radius);
             float dist =  2.0f*max(radius.magnitude2(), 1.1f*radius.z),
                   yaw = fmod(lastmillis/10000.0f*360.0f, 360.0f);
             vec o(-center.x, dist - center.y, -0.1f*dist - center.z);
             rendermodel(&light, name, anim, o, yaw, 0, 0, NULL, NULL, 0);
         }
         modelpreview::end();
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glEnable(GL_BLEND);
         glDisable(GL_SCISSOR_TEST);
         glViewport(0, 0, screenw, screenh);
         if(overlaid)
         {
             if(hit)
             {
                 glDisable(GL_TEXTURE_2D);
                 notextureshader->set();
                 glBlendFunc(GL_ZERO, GL_SRC_COLOR);
                 glColor3f(1, 0.5f, 0.5f);
                 rect_(xi, yi, xs, ys);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 glEnable(GL_TEXTURE_2D);
                 defaultshader->set();
             }
             if(!overlaytex) {
                 string otname;
                 inexor::filesystem::appendmediadir(otname, "guioverlay.png", DIR_UI);
                 overlaytex = textureload(otname, 3);
             }
             glColor3fv(light.v);
             glBindTexture(GL_TEXTURE_2D, overlaytex->id);
             rect_(xi, yi, xs, ys, 0);
         }
     }
     return layout(size+SHADOW, size+SHADOW);
 }