Added a settings option to draw a wall frame around screen.

This commit is contained in:
Savely Skresanov 2012-05-31 17:47:52 +07:00
parent 65e79b4b8f
commit 19ae18c059
5 changed files with 59 additions and 2 deletions

View File

@ -186,6 +186,7 @@ extern int hud_enable;
extern int pretty_powder;
extern int drawgrav_enable;
extern int ngrav_enable;
extern char bframe;
int limitFPS;
int water_equal_test;
extern int quickoptions_tooltip_fade;

View File

@ -78,6 +78,10 @@ void *file_load(char *fn, int *size);
void clipboard_push_text(char * text);
void draw_bframe();
void erase_bframe();
char * clipboard_pull_text();
extern char *clipboard_text;

View File

@ -6971,7 +6971,7 @@ void render_ui(pixel * vid_buf, int xcoord, int ycoord, int orientation)
void simulation_ui(pixel * vid_buf)
{
int xsize = 300;
int ysize = 246;
int ysize = 260;
int x0=(XRES-xsize)/2,y0=(YRES-MENUSIZE-ysize)/2,b=1,bq,mx,my;
int new_scale, new_kiosk;
ui_checkbox cb;
@ -6980,6 +6980,7 @@ void simulation_ui(pixel * vid_buf)
ui_checkbox cb4;
ui_checkbox cb5;
ui_checkbox cb6;
ui_checkbox cb7;
char * airModeList[] = {"On", "Pressure Off", "Velocity Off", "Off", "No Update"};
int airModeListCount = 5;
char * gravityModeList[] = {"Vertical", "Off", "Radial"};
@ -7016,6 +7017,11 @@ void simulation_ui(pixel * vid_buf)
cb6.y = y0+107;
cb6.focus = 0;
cb6.checked = water_equal_test;
cb7.x = x0+xsize-16; //Block frame
cb7.y = y0+227;
cb7.focus = 0;
cb7.checked = bframe;
list.x = x0+xsize-76; //Air Mode
list.y = y0+135;
@ -7081,6 +7087,9 @@ void simulation_ui(pixel * vid_buf)
drawtext(vid_buf, x0+8, y0+214, "Fullscreen", 255, 255, 255, 255);
drawtext(vid_buf, x0+12+textwidth("Fullscreen"), y0+214, "Fill the entire screen", 255, 255, 255, 180);
drawtext(vid_buf, x0+8, y0+228, "Block frame", 255, 255, 255, 255);
drawtext(vid_buf, x0+12+textwidth("Block frame"), y0+228, "Draws a wall frame around screen", 255, 255, 255, 180);
//TODO: Options for Air and Normal gravity
//Maybe save/load defaults too.
@ -7093,6 +7102,7 @@ void simulation_ui(pixel * vid_buf)
ui_checkbox_draw(vid_buf, &cb4);
ui_checkbox_draw(vid_buf, &cb5);
ui_checkbox_draw(vid_buf, &cb6);
ui_checkbox_draw(vid_buf, &cb7);
ui_list_draw(vid_buf, &list);
ui_list_draw(vid_buf, &list2);
#ifdef OGLR
@ -7105,6 +7115,7 @@ void simulation_ui(pixel * vid_buf)
ui_checkbox_process(mx, my, b, bq, &cb4);
ui_checkbox_process(mx, my, b, bq, &cb5);
ui_checkbox_process(mx, my, b, bq, &cb6);
ui_checkbox_process(mx, my, b, bq, &cb7);
ui_list_process(vid_buf, mx, my, b, &list);
ui_list_process(vid_buf, mx, my, b, &list2);
@ -7138,6 +7149,11 @@ void simulation_ui(pixel * vid_buf)
else
stop_grav_async();
}
if(cb7.checked && !bframe)
draw_bframe();
if(!cb7.checked && bframe)
erase_bframe();
bframe = cb7.checked;
while (!sdl_poll())
{

View File

@ -307,6 +307,8 @@ void dump_frame(pixel *src, int w, int h, int pitch)
* STATE MANAGEMENT *
***********************************************************/
char bframe = 0;
void clear_sim(void)
{
int i, x, y;
@ -352,6 +354,8 @@ void clear_sim(void)
hv[y][x] = 273.15f+22.0f; //Set to room temperature
}
}
if(bframe)
draw_bframe();
}
// stamps library
@ -801,7 +805,6 @@ int main(int argc, char *argv[])
parts = calloc(sizeof(particle), NPART);
cb_parts = calloc(sizeof(particle), NPART);
init_can_move();
clear_sim();
#ifdef LUACONSOLE
luacon_open();
@ -854,6 +857,7 @@ int main(int argc, char *argv[])
}
load_presets();
clear_sim();
for (i=1; i<argc; i++)
{

View File

@ -135,6 +135,36 @@ void clean_text(char *text, int vwidth)
}
}
void draw_bframe()
{
int i;
for(i=0; i<(XRES/CELL); i++)
{
bmap[0][i]=WL_WALL;
bmap[YRES/CELL-1][i]=WL_WALL;
}
for(i=1; i<((YRES/CELL)-1); i++)
{
bmap[i][0]=WL_WALL;
bmap[i][XRES/CELL-1]=WL_WALL;
}
}
void erase_bframe()
{
int i;
for(i=0; i<(XRES/CELL); i++)
{
bmap[0][i]=0;
bmap[YRES/CELL-1][i]=0;
}
for(i=1; i<((YRES/CELL)-1); i++)
{
bmap[i][0]=0;
bmap[i][XRES/CELL-1]=0;
}
}
void save_presets(int do_update)
{
char * outputdata;
@ -186,6 +216,7 @@ void save_presets(int do_update)
//General settings
cJSON_AddStringToObject(root, "proxy", http_proxy_string);
cJSON_AddNumberToObject(root, "scale", sdl_scale);
cJSON_AddNumberToObject(root, "bframe", bframe);
outputdata = cJSON_Print(root);
cJSON_Delete(root);
@ -324,6 +355,7 @@ void load_presets(void)
if((tmpobj = cJSON_GetObjectItem(root, "proxy")) && tmpobj->type == cJSON_String) strncpy(http_proxy_string, tmpobj->valuestring, 255); else http_proxy_string[0] = 0;
//TODO: Translate old cmode value into new *_mode values
if(tmpobj = cJSON_GetObjectItem(root, "scale")) sdl_scale = tmpobj->valueint;
if(tmpobj = cJSON_GetObjectItem(root, "bframe")) bframe = tmpobj->valueint;
cJSON_Delete(root);
free(prefdata);