summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-02-22 15:18:04 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2011-02-22 15:18:04 (GMT)
commitc9725c60047869fb0d645eb9e8cc259748cc9c0e (patch)
tree813862fe030dd2184092ab482aeb1112172d13cd /src
parentac7eda80a545ba8c0cbab80236df88570e1d33ad (diff)
parenta84234dcd4e5a3dfb4a62d73ff07df1e01bed086 (diff)
downloadpowder-c9725c60047869fb0d645eb9e8cc259748cc9c0e.zip
powder-c9725c60047869fb0d645eb9e8cc259748cc9c0e.tar.gz
Merge branch 'upstream' into dev
Conflicts: src/main.c
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c2
-rw-r--r--src/interface.c41
-rw-r--r--src/main.c207
3 files changed, 146 insertions, 104 deletions
diff --git a/src/graphics.c b/src/graphics.c
index a3cbf87..ea8d0d5 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -448,6 +448,8 @@ void draw_tool(pixel *vid_buf, int b, int sl, int sr, unsigned pc, unsigned iswa
int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
{
int i, j, c;
+ if (x > XRES-26 || x < 0)
+ return 26;
if (b>=UI_WALLSTART)
{
b = b-100;
diff --git a/src/interface.c b/src/interface.c
index 12f13f6..a762b39 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -1531,13 +1531,14 @@ void menu_ui(pixel *vid_buf, int i, int *sl, int *sr)
void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx, int my)
{
- int h,x,y,n=0,height,width,sy,rows=0;
+ int h,x,y,n=0,height,width,sy,rows=0,xoff=0,fwidth;
SEC = SEC2;
mx /= sdl_scale;
my /= sdl_scale;
rows = ceil((float)msections[i].itemcount/16.0f);
height = (ceil((float)msections[i].itemcount/16.0f)*18);
width = restrict_flt(msections[i].itemcount*31, 0, 16*31);
+ fwidth = msections[i].itemcount*31;
h = -1;
x = XRES-BARSIZE-18;
y = YRES+1;
@@ -1548,11 +1549,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
{
if (n!=SPC_AIR&&n!=SPC_HEAT&&n!=SPC_COOL&&n!=SPC_VACUUM)
{
- if (x-18<=2)
+ /*if (x-18<=2)
{
x = XRES-BARSIZE-18;
y += 19;
- }
+ }*/
x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
@@ -1585,11 +1586,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
{
if (n==SPC_AIR||n==SPC_HEAT||n==SPC_COOL||n==SPC_VACUUM)
{
- if (x-18<=0)
+ /*if (x-18<=0)
{
x = XRES-BARSIZE-18;
y += 19;
- }
+ }*/
x -= draw_tool_xy(vid_buf, x, y, n, mwalls[n-UI_WALLSTART].colour)+5;
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
@@ -1619,11 +1620,11 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
{
if (ptypes[n].menusection==i&&ptypes[n].menu==1)
{
- if (x-18<=0)
+ /*if (x-18<=0)
{
x = XRES-BARSIZE-18;
y += 19;
- }
+ }*/
x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5;
if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
{
@@ -1652,37 +1653,36 @@ void menu_ui_v3(pixel *vid_buf, int i, int *sl, int *sr, int b, int bq, int mx,
}
else
{
+ if (fwidth > XRES-BARSIZE){
+ float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
+ xoff = (int)(overflow / location);
+ }
for (n = 0; n<PT_NUM; n++)
{
if (ptypes[n].menusection==i&&ptypes[n].menu==1)
{
- if (x-18<=0)
- {
- x = XRES-BARSIZE-18;
- y += 19;
- }
- x -= draw_tool_xy(vid_buf, x, y, n, ptypes[n].pcolors)+5;
- if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15)
+ x -= draw_tool_xy(vid_buf, x-xoff, y, n, ptypes[n].pcolors)+5;
+ if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=y && my< y+15)
{
- drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
+ drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255);
h = n;
}
- if (!bq && mx>=x+32 && mx<x+58 && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
+ if (!bq && mx>=x+32-xoff && mx<x+58-xoff && my>=y && my< y+15&&(sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT)))
{
- drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255);
h = n;
}
else if (n==SLALT)
{
- drawrect(vid_buf, x+30, y-1, 29, 17, 0, 255, 255, 255);
+ drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 255, 255, 255);
}
else if (n==*sl)
{
- drawrect(vid_buf, x+30, y-1, 29, 17, 255, 0, 0, 255);
+ drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 255, 0, 0, 255);
}
else if (n==*sr)
{
- drawrect(vid_buf, x+30, y-1, 29, 17, 0, 0, 255, 255);
+ drawrect(vid_buf, x+30-xoff, y-1, 29, 17, 0, 0, 255, 255);
}
}
}
@@ -1889,6 +1889,7 @@ void set_cmode(int cm)
else if (cmode==CM_PERS)
{
memset(fire_bg, 0, XRES*YRES*PIXELSIZE);
+ memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
strcpy(itc_msg, "Persistent Display");
}
else if (cmode==CM_PRESS)
diff --git a/src/main.c b/src/main.c
index 9fcebfb..3dbebd3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -169,7 +169,8 @@ int FPSB = 0;
int MSIGN =-1;
//int CGOL = 0;
//int GSPEED = 1;//causes my .exe to crash..
-int sound_enable;
+int sound_enable = 0;
+int file_script = 0;
sign signs[MAXSIGNS];
@@ -1215,6 +1216,7 @@ int main(int argc, char *argv[])
pixel *load_img=NULL;//, *fbi_img=NULL;
int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
SDL_AudioSpec fmt;
+ int username_flash = 0, username_flash_t = 1;
GSPEED = 1;
/* Set 16-bit stereo audio at 22Khz */
@@ -1224,16 +1226,7 @@ int main(int argc, char *argv[])
fmt.samples = 512;
fmt.callback = mixaudio;
fmt.userdata = NULL;
- /* Open the audio device and start playing sound! */
- if ( SDL_OpenAudio(&fmt, NULL) < 0 )
- {
- fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
- }
- else
- {
- sound_enable = 1;
- SDL_PauseAudio(0);
- }
+
#ifdef MT
numCores = core_count();
#endif
@@ -1282,9 +1275,27 @@ int main(int argc, char *argv[])
else if (!strncmp(argv[i], "kiosk", 5))
{
kiosk_enable = 1;
- sdl_scale = 2;
+ //sdl_scale = 2; //Removed because some displays cannot handle the resolution
hud_enable = 0;
}
+ else if (!strncmp(argv[i], "sound", 5))
+ {
+ /* Open the audio device and start playing sound! */
+ if ( SDL_OpenAudio(&fmt, NULL) < 0 )
+ {
+ fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
+ }
+ else
+ {
+ sound_enable = 1;
+ SDL_PauseAudio(0);
+ }
+ }
+ else if (!strncmp(argv[i], "scripts", 5))
+ {
+ file_script = 1;
+ }
+
}
save_presets(0);
@@ -1401,7 +1412,6 @@ int main(int argc, char *argv[])
check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL);
if(http_ret==200 && check_data)
{
- printf("{%s}\n", check_data);
if(!strncmp(check_data, "EXPIRED", 7))
{
//Session expired
@@ -1425,6 +1435,7 @@ int main(int argc, char *argv[])
svf_own = 0;
svf_admin = 0;
svf_mod = 0;
+ error_ui(vid_buf, "Unable to log in", "Your account has been suspended, consider reading the rules.");
}
else if(!strncmp(check_data, "OK", 2))
{
@@ -1440,9 +1451,8 @@ int main(int argc, char *argv[])
{
svf_admin = 0;
svf_mod = 1;
- }
- }
- save_presets(0);
+ }
+ }
}
else
{
@@ -1456,9 +1466,26 @@ int main(int argc, char *argv[])
svf_admin = 0;
svf_mod = 0;
}
+ save_presets(0);
free(check_data);
}
http_session_check = NULL;
+ } else {
+ clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14);
+ drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255);
+ drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255);
+ if(username_flash>30){
+ username_flash_t = -1;
+ username_flash = 30;
+ } else if(username_flash<0) {
+ username_flash_t = 1;
+ username_flash = 0;
+ }
+ username_flash += username_flash_t;
+ if (svf_login)
+ drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5));
+ else
+ drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255);
}
do_s_check = (do_s_check+1) & 15;
}
@@ -2282,8 +2309,10 @@ int main(int argc, char *argv[])
if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476)))
{
login_ui(vid_buf);
- if (svf_login)
+ if (svf_login){
save_presets(0);
+ http_session_check = NULL;
+ }
}
if (x>=37 && x<=187 && svf_login)
{
@@ -2303,6 +2332,7 @@ int main(int argc, char *argv[])
{
search_ui(vid_buf);
memset(fire_bg, 0, XRES*YRES*PIXELSIZE);
+ memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
memset(fire_r, 0, sizeof(fire_r));
memset(fire_g, 0, sizeof(fire_g));
memset(fire_b, 0, sizeof(fire_b));
@@ -2736,83 +2766,92 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
else if(strcmp(console2, "file")==0)
{
- FILE *f=fopen(console3, "r");
- if(f)
- {
- char fileread[5000];//TODO: make this change with file size
- char pch[5000];
- char tokens[10];
- int tokensize;
- nx = 0;
- ny = 0;
- j = 0;
- m = 0;
- console_parse_coords(console4, &nx , &ny, console_error);
- memset(pch,0,sizeof(pch));
- memset(fileread,0,sizeof(fileread));
- fread(fileread,1,5000,f);
- for(i=0; i<strlen(fileread); i++)
- {
- if(fileread[i] != '\n')
+ if(file_script){
+ FILE *f=fopen(console3, "r");
+ if(f)
+ {
+ char fileread[5000];//TODO: make this change with file size
+ char pch[5000];
+ char tokens[10];
+ int tokensize;
+ nx = 0;
+ ny = 0;
+ j = 0;
+ m = 0;
+ console_parse_coords(console4, &nx , &ny, console_error);
+ memset(pch,0,sizeof(pch));
+ memset(fileread,0,sizeof(fileread));
+ fread(fileread,1,5000,f);
+ for(i=0; i<strlen(fileread); i++)
{
- pch[i-j] = fileread[i];
- if(fileread[i] != ' ')
- tokens[i-m] = fileread[i];
- }
- if(fileread[i] == ' ' || fileread[i] == '\n')
- {
- if(sregexp(tokens,"^x.[0-9],y.[0-9]")==0)//TODO: fix regex matching to work with x,y ect, right now it has to have a +0 or -0
+ if(fileread[i] != '\n')
{
- char temp[5];
- int starty = 0;
- tokensize = strlen(tokens);
- x = 0;
- y = 0;
- sscanf(tokens,"x%d,y%d",&x,&y);
- sscanf(tokens,"%9s,%9s",xcoord,ycoord);
- x += nx;
- y += ny;
- sprintf(xcoord,"%d",x);
- sprintf(ycoord,"%d",y);
- for(k = 0; k<strlen(xcoord);k++)//rewrite pch with numbers
- {
- pch[i-j-tokensize+k] = xcoord[k];
- starty = k+1;
- }
- pch[i-j-tokensize+starty] = ',';
- starty++;
- for(k=0;k<strlen(ycoord);k++)
+ pch[i-j] = fileread[i];
+ if(fileread[i] != ' ')
+ tokens[i-m] = fileread[i];
+ }
+ if(fileread[i] == ' ' || fileread[i] == '\n')
+ {
+ if(sregexp(tokens,"^x.[0-9],y.[0-9]")==0)//TODO: fix regex matching to work with x,y ect, right now it has to have a +0 or -0
{
- pch[i-j-tokensize+starty+k] = ycoord[k];
-
+ char temp[5];
+ int starty = 0;
+ tokensize = strlen(tokens);
+ x = 0;
+ y = 0;
+ sscanf(tokens,"x%d,y%d",&x,&y);
+ sscanf(tokens,"%9s,%9s",xcoord,ycoord);
+ x += nx;
+ y += ny;
+ sprintf(xcoord,"%d",x);
+ sprintf(ycoord,"%d",y);
+ for(k = 0; k<strlen(xcoord);k++)//rewrite pch with numbers
+ {
+ pch[i-j-tokensize+k] = xcoord[k];
+ starty = k+1;
+ }
+ pch[i-j-tokensize+starty] = ',';
+ starty++;
+ for(k=0;k<strlen(ycoord);k++)
+ {
+ pch[i-j-tokensize+starty+k] = ycoord[k];
+
+ }
+ pch[i-j-tokensize +strlen(xcoord) +1 +strlen(ycoord)] = ' ';
+ j = j -tokensize +strlen(xcoord) +1 +strlen(ycoord);
}
- pch[i-j-tokensize +strlen(xcoord) +1 +strlen(ycoord)] = ' ';
- j = j -tokensize +strlen(xcoord) +1 +strlen(ycoord);
+ memset(tokens,0,sizeof(tokens));
+ m = i+1;
}
- memset(tokens,0,sizeof(tokens));
- m = i+1;
- }
- if(fileread[i] == '\n')
- {
-
- if(do_next)
+ if(fileread[i] == '\n')
{
- if(strcmp(pch,"else")==0)
- do_next = 0;
- else
- do_next = process_command(vid_buf, pch, console_error);
+
+ if(do_next)
+ {
+ if(strcmp(pch,"else")==0)
+ do_next = 0;
+ else
+ do_next = process_command(vid_buf, pch, console_error);
+ }
+ else if(strcmp(pch,"endif")==0 || strcmp(pch,"else")==0)
+ do_next = 1;
+ memset(pch,0,sizeof(pch));
+ j = i+1;
}
- else if(strcmp(pch,"endif")==0 || strcmp(pch,"else")==0)
- do_next = 1;
- memset(pch,0,sizeof(pch));
- j = i+1;
}
+ //sprintf(console_error, "%s exists", console3);
+ fclose(f);
+ }
+ else
+ {
+ sprintf(console_error, "%s does not exist", console3);
}
- //sprintf(console_error, "%s exists", console3);
- fclose(f);
}
- else
- sprintf(console_error, "%s does not exist", console3);
+ else
+ {
+ sprintf(console_error, "Scripts are not enabled");
+ }
+
}
else if(strcmp(console2, "sound")==0)
{