no message
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@962 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -278,6 +278,9 @@ int main(int argc, char **argv)
|
||||
preload_hudguns();
|
||||
preload_entmodels();
|
||||
|
||||
initlog("docs");
|
||||
execfile("config/docs.cfg");
|
||||
|
||||
execute("start_game");
|
||||
|
||||
initlog("localconnect");
|
||||
|
||||
@@ -62,6 +62,13 @@ void drawarrow(int dir, int x, int y, int size, float r = 1.0f, float g = 1.0f,
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
void drawmenubg(int x1, int y1, int x2, int y2, bool border)
|
||||
{
|
||||
static Texture *tex = NULL;
|
||||
if(!tex) tex = textureload("packages/textures/makke/menu.jpg");
|
||||
blendbox(x1, y1, x2, y2, border, tex->id);
|
||||
};
|
||||
|
||||
#define MAXMENU 17
|
||||
|
||||
bool rendermenu()
|
||||
@@ -93,9 +100,7 @@ bool rendermenu()
|
||||
int h = (mdisp+2)*step;
|
||||
int y = (VIRTH-h)/2;
|
||||
int x = (VIRTW-w)/2;
|
||||
static Texture *menutex = NULL;
|
||||
if(!menutex) menutex = textureload("packages/textures/makke/menu.jpg");
|
||||
blendbox(x-FONTH*3/2, y-FONTH, x+w+FONTH*3/2, y+h+FONTH, true, menutex->id);
|
||||
drawmenubg(x-FONTH*3/2, y-FONTH, x+w+FONTH*3/2, y+h+FONTH, true);
|
||||
if(offset>0) drawarrow(1, x+w+FONTH*3/2-FONTH*5/6, y-FONTH*5/6, FONTH*2/3);
|
||||
if(offset+MAXMENU<m.items.length()) drawarrow(0, x+w+FONTH*3/2-FONTH*5/6, y+h+FONTH/6, FONTH*2/3);
|
||||
draw_text(title, x, y);
|
||||
|
||||
@@ -33,6 +33,7 @@ extern void *addmenu(char *name, char *title = NULL, bool allowinput = true, voi
|
||||
extern void rendermenumdl();
|
||||
extern void menuset(void *m);
|
||||
extern void menuselect(void *menu, int sel);
|
||||
extern void drawmenubg(int x1, int y1, int x2, int y2, bool border);
|
||||
|
||||
// serverbrowser
|
||||
extern void addserver(char *servername);
|
||||
@@ -175,6 +176,7 @@ extern void keyrepeat(bool on);
|
||||
// rendertext
|
||||
extern void draw_text(const char *str, int left, int top);
|
||||
extern void draw_textf(const char *fstr, int left, int top, ...);
|
||||
extern int draw_textblock(char *text, int x, int y, uint width);
|
||||
extern int char_width(int c, int x = 0);
|
||||
extern int text_width(const char *str, int limit = -1);
|
||||
extern int text_visible(const char *str, int max);
|
||||
@@ -331,4 +333,6 @@ extern PFNGLACTIVETEXTUREARBPROC glActiveTexture_;
|
||||
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f_;
|
||||
extern PFNGLMULTITEXCOORD3FARBPROC glMultiTexCoord3f_;
|
||||
|
||||
// docs
|
||||
extern void renderdoc(int x, int y);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex)
|
||||
if(tex>=0) glDisable(GL_TEXTURE_2D);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glBegin(GL_POLYGON);
|
||||
glColor3f(0.6f, 0.6f, 0.6f); //glColor3d(0.2, 0.7, 0.4);
|
||||
glColor3f(0.6f, 0.6f, 0.6f); //glColor3d(0.2, 0.7, 0.4);
|
||||
glVertex2i(x1, y1);
|
||||
glVertex2i(x2, y1);
|
||||
glVertex2i(x2, y2);
|
||||
|
||||
@@ -280,7 +280,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
|
||||
}
|
||||
|
||||
char *infostr = editinfo();
|
||||
if(getcurcommand()) rendercommand(20, 1570);
|
||||
bool command = getcurcommand() ? true : false;
|
||||
if(command) rendercommand(20, 1570);
|
||||
else if(infostr) draw_text(infostr, 20, 1570);
|
||||
else if(targetplayer) draw_text(targetplayer->name, 20, 1570);
|
||||
|
||||
@@ -288,6 +289,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
|
||||
glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1);
|
||||
|
||||
renderconsole();
|
||||
if(command) renderdoc(40, VIRTH);
|
||||
if(!hidestats)
|
||||
{
|
||||
const int left = (VIRTW-225-10)*2, top = (VIRTH*7/8)*2;
|
||||
@@ -452,5 +454,4 @@ void show_out_of_renderloop_progress(float bar1, const char *text1, float bar2,
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -210,7 +210,8 @@ void draw_text(const char *str, int left, int top)
|
||||
case '2': glColor3ub(255, 192, 64); i++; continue; // yellow: gameplay action messages, only actions done by players
|
||||
case '3': glColor3ub(255, 64, 64); i++; continue; // red: important errors
|
||||
case '4': glColor3ub(128, 128, 128); i++; continue; // gray
|
||||
default: glColor3ub(255, 255, 255); i++; continue; // white: everything else
|
||||
case '5': glColor3ub(255, 255, 255); i++; continue; // white: everything else
|
||||
default: i++; continue;
|
||||
}
|
||||
|
||||
case ' ':
|
||||
@@ -241,3 +242,24 @@ void draw_text(const char *str, int left, int top)
|
||||
}
|
||||
}
|
||||
|
||||
// draw text block using a fixed width and dynamic height, cheap word wrapping based on char number
|
||||
int draw_textblock(char *text, int x, int y, uint width)
|
||||
{
|
||||
uint numlines = 0;
|
||||
char *lastline = text;
|
||||
for(char *t = text; *t; t++)
|
||||
{
|
||||
size_t len = t-lastline+1;
|
||||
if(len >= width || !*(t+1)) // EOL or EOS
|
||||
{
|
||||
if(len == width && *(t+1) && *(t+1) != ' ') while(*t && *t != ' ') if((len = --t-lastline) <= 0) { t = lastline+width; break; } // wrap word
|
||||
char *s = new char[len+1];
|
||||
s_strncpy(s, lastline, len+1);
|
||||
draw_textf("%s", x, y+FONTH*numlines, *s == ' ' ? s+1 : s);
|
||||
delete s;
|
||||
lastline = t;
|
||||
numlines++;
|
||||
}
|
||||
}
|
||||
return numlines;
|
||||
}
|
||||
Reference in New Issue
Block a user