moving signs! i think everything still works, click the weird random extra button, someone can add an icon later.

This commit is contained in:
Philip
2010-10-29 23:37:15 -04:00
parent bb3b1a52ac
commit 8f397f3a03
4 changed files with 30 additions and 5 deletions

View File

@@ -90,7 +90,7 @@ extern int death;
struct sign struct sign
{ {
int x,y,ju; int x,y,ju,m;
char text[256]; char text[256];
}; };
typedef struct sign sign; typedef struct sign sign;

View File

@@ -153,6 +153,8 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h);
void add_sign_ui(pixel *vid_buf, int mx, int my); void add_sign_ui(pixel *vid_buf, int mx, int my);
void move_sign(pixel *vid_buf,int i);
void ui_edit_draw(pixel *vid_buf, ui_edit *ed); void ui_edit_draw(pixel *vid_buf, ui_edit *ed);
void ui_edit_process(int mx, int my, int mb, ui_edit *ed); void ui_edit_process(int mx, int my, int mb, ui_edit *ed);

View File

@@ -2198,7 +2198,7 @@ void draw_parts(pixel *vid)
void render_signs(pixel *vid_buf) void render_signs(pixel *vid_buf)
{ {
int i, j, x, y, w, h, dx, dy; int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
char buff[30]; //Buffer char buff[30]; //Buffer
for(i=0; i<MAXSIGNS; i++) for(i=0; i<MAXSIGNS; i++)
if(signs[i].text[0]) if(signs[i].text[0])
@@ -2226,6 +2226,7 @@ void render_signs(pixel *vid_buf)
//Usual text //Usual text
if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}")) if(strcmp(signs[i].text, "{p}") && strcmp(signs[i].text, "{t}"))
drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255); drawtext(vid_buf, x+3, y+3, signs[i].text, 255, 255, 255, 255);
x = signs[i].x; x = signs[i].x;
y = signs[i].y; y = signs[i].y;
dx = 1 - signs[i].ju; dx = 1 - signs[i].ju;
@@ -2236,6 +2237,15 @@ void render_signs(pixel *vid_buf)
x+=dx; x+=dx;
y+=dy; y+=dy;
} }
if(signs[i].m==1)
{
bq = b;
b = SDL_GetMouseState(&mx, &my);
mx /= sdl_scale;
my /= sdl_scale;
signs[i].x = mx;
signs[i].y = my;
}
} }
} }

View File

@@ -97,14 +97,19 @@ void get_sign_pos(int i, int *x0, int *y0, int *w, int *h)
void add_sign_ui(pixel *vid_buf, int mx, int my) void add_sign_ui(pixel *vid_buf, int mx, int my)
{ {
int i, w, h, x, y, nm=0, ju; int i, w, h, x, y, nm=0, ju,movesign = 0;
int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq; int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq;
ui_edit ed; ui_edit ed;
// check if it is an existing sign // check if it is an existing sign
for(i=0; i<MAXSIGNS; i++) for(i=0; i<MAXSIGNS; i++)
if(signs[i].text[0]) if(signs[i].text[0])
{ {
if(signs[i].m == 1)
{
signs[i].m = 0;
return;
}
get_sign_pos(i, &x, &y, &w, &h); get_sign_pos(i, &x, &y, &w, &h);
if(mx>=x && mx<=x+w && my>=y && my<=y+h) if(mx>=x && mx<=x+w && my>=y && my<=y+h)
break; break;
@@ -119,7 +124,6 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
} }
if(i >= MAXSIGNS) if(i >= MAXSIGNS)
return; return;
if(nm) if(nm)
{ {
signs[i].x = mx; signs[i].x = mx;
@@ -165,6 +169,10 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1); draw_icon(vid_buf, x0+68, y0+42, 0x9E, ju == 1);
draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2); draw_icon(vid_buf, x0+86, y0+42, 0x9F, ju == 2);
drawrect(vid_buf,x0+104,y0+42,26,15,255,255,255,255);
if(!nm) if(!nm)
{ {
drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255); drawtext(vid_buf, x0+138, y0+45, "\x86", 160, 48, 32, 255);
@@ -187,6 +195,11 @@ void add_sign_ui(pixel *vid_buf, int mx, int my)
if(b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59) if(b && !bq && mx>=x0+86 && mx<=x0+103 && my>=y0+42 && my<=y0+59)
ju = 2; ju = 2;
if(b && !bq && mx>=x0+104 && mx<=x0+130 && my>=y0+42 && my<=y0+59)
{
signs[i].m = 1;
break;
}
if(b && !bq && mx>=x0+9 && mx<x0+23 && my>=y0+22 && my<y0+36) if(b && !bq && mx>=x0+9 && mx<x0+23 && my>=y0+22 && my<y0+36)
break; break;
if(b && !bq && mx>=x0 && mx<x0+192 && my>=y0+64 && my<=y0+80) if(b && !bq && mx>=x0 && mx<x0+192 && my>=y0+64 && my<=y0+80)