Example #1
0
/**************************************************************************
...
**************************************************************************/
static void refresh_happiness_bitmap(HBITMAP bmp,
				     struct city *pcity,
				     enum citizen_feeling index)
{
  enum citizen_category citizens[MAX_CITY_SIZE];
  RECT rc;
  int i;
  int num_citizens = get_city_citizen_types(pcity, index, citizens);
  int pix_width = HAPPINESS_PIX_WIDTH * tileset_small_sprite_width(tileset);
  int offset = MIN(tileset_small_sprite_width(tileset), pix_width / num_citizens);
  /* int true_pix_width = (num_citizens - 1) * offset + tileset_small_sprite_width(tileset); */
  HDC hdc = CreateCompatibleDC(NULL);
  HBITMAP old=SelectObject(hdc,bmp);

  rc.left=0;
  rc.top=0;
  rc.right=pix_width;
  rc.bottom=tileset_small_sprite_height(tileset);
  FillRect(hdc,&rc,(HBRUSH)GetClassLong(root_window,GCL_HBRBACKGROUND));

  for (i = 0; i < num_citizens; i++) {
    draw_sprite(get_citizen_sprite(tileset, citizens[i], i, pcity),
		hdc, i * offset, 0);
  }

  SelectObject(hdc,old);
  DeleteDC(hdc);
}
Example #2
0
/**************************************************************************
...
**************************************************************************/
struct happiness_dlg *create_happiness_box(struct city *pcity,
					   struct fcwin_box *hbox,
					   HWND win)
{
  int i;
  HDC hdc;
  struct happiness_dlg *dlg;
  struct fcwin_box *vbox;
  vbox=fcwin_vbox_new(win,FALSE);
  fcwin_box_add_groupbox(hbox,_("Happiness"),vbox,0,
			 TRUE,TRUE,0);
  dlg=fc_malloc(sizeof(struct happiness_dlg));
  dlg->win=win;
  dlg->pcity=pcity;
  for(i=0;i<NUM_HAPPINESS_MODIFIERS;i++) {
    fcwin_box_add_generic(vbox,bmp_row_minsize,bmp_row_setsize,NULL,
			  &(dlg->mod_bmp_pos[i]),FALSE,FALSE,0);
    dlg->mod_label[i]=fcwin_box_add_static(vbox," ",0,SS_LEFT,
					   FALSE,FALSE,5);
  }
  hdc=GetDC(win);
  for(i=0;i<NUM_HAPPINESS_MODIFIERS;i++) {
    dlg->mod_bmp[i]=
      CreateCompatibleBitmap(hdc,
			     HAPPINESS_PIX_WIDTH*tileset_small_sprite_width(tileset),
			     tileset_small_sprite_height(tileset));
  }
  ReleaseDC(win,hdc);
  return dlg;
}
Example #3
0
void repaint_happiness_box(struct happiness_dlg *dlg, HDC hdc)
{
  int i;
  HDC hdcsrc;
  HBITMAP old;
  hdcsrc=CreateCompatibleDC(hdc);
  for(i=0;i<NUM_HAPPINESS_MODIFIERS;i++) {
    old=SelectObject(hdcsrc,dlg->mod_bmp[i]);
    BitBlt(hdc,dlg->mod_bmp_pos[i].x,dlg->mod_bmp_pos[i].y,
	   HAPPINESS_PIX_WIDTH*tileset_small_sprite_width(tileset),
	   tileset_small_sprite_height(tileset),hdcsrc,0,0,SRCCOPY);
    SelectObject(hdcsrc,old);
  }
  DeleteDC(hdcsrc);
}
Example #4
0
/**************************************************************************
...
**************************************************************************/
void setup_widgets(void)
{
  long i;
  int econ_label_count=10, econ_label_space=1;

  main_form = XtVaCreateManagedWidget("mainform", formWidgetClass, 
				      toplevel, 
				      NULL);   

  menu_form = XtVaCreateManagedWidget("menuform", formWidgetClass,	
				      main_form,        
				      NULL);	        
  setup_menus(menu_form); 

/*
 main_vpane= XtVaCreateManagedWidget("mainvpane", 
				      panedWidgetClass, 
				      main_form,
				      NULL);
  
  below_menu_form = XtVaCreateManagedWidget("belowmenuform", 
					    formWidgetClass, 
					    main_vpane,
					    NULL);
*/
  below_menu_form = XtVaCreateManagedWidget("belowmenuform", 
					    formWidgetClass, 
					    main_form,
					    NULL);

  left_column_form = XtVaCreateManagedWidget("leftcolumnform", 
					     formWidgetClass, 
					     below_menu_form, 
					     NULL);

  map_form = XtVaCreateManagedWidget("mapform", 
				     formWidgetClass, 
				     below_menu_form, 
				     NULL);

  bottom_form = XtVaCreateManagedWidget("bottomform", 
					formWidgetClass, 
					/*main_vpane,*/ main_form, 
					NULL);
  
  overview_canvas = XtVaCreateManagedWidget("overviewcanvas", 
					    xfwfcanvasWidgetClass,
					    left_column_form,
					    "exposeProc", 
					    (XtArgVal)overview_canvas_expose,
					    "exposeProcData", 
					    (XtArgVal)NULL,
					    NULL);
  
  info_command = XtVaCreateManagedWidget("infocommand", 
				       commandWidgetClass, 
				       left_column_form, 
				       XtNfromVert, 
				       (XtArgVal)overview_canvas,
				       NULL);   


  /* Don't put the citizens in here yet because not loaded yet */
  for(i=0;i<econ_label_count;i++)  {
    econ_label[i] = XtVaCreateManagedWidget("econlabels",
					    commandWidgetClass,
					    left_column_form,
					    XtNwidth, tileset_small_sprite_width(tileset),
					    XtNheight, tileset_small_sprite_height(tileset),
					    i?XtNfromHoriz:NULL, 
					    i?econ_label[i-1]:NULL,
					    XtNhorizDistance, econ_label_space,
					    NULL);  
  }
  
  bulb_label = XtVaCreateManagedWidget("bulblabel", 
				       labelWidgetClass,
				       left_column_form,
				       NULL);

  sun_label = XtVaCreateManagedWidget("sunlabel", 
				      labelWidgetClass, 
				      left_column_form,
				      NULL);

  flake_label = XtVaCreateManagedWidget("flakelabel", 
					labelWidgetClass, 
					left_column_form,
					NULL);

  government_label = XtVaCreateManagedWidget("governmentlabel", 
					    labelWidgetClass, 
					    left_column_form,
					    NULL);

  timeout_label = XtVaCreateManagedWidget("timeoutlabel", 
					  labelWidgetClass, 
					  left_column_form,
					  NULL);


  turn_done_button =
    I_LW(XtVaCreateManagedWidget("turndonebutton", 
				 commandWidgetClass,
				 left_column_form,
				 XtNwidth, econ_label_count*
						(tileset_small_sprite_width(tileset)+econ_label_space),
				 NULL));

  
  unit_info_label = XtVaCreateManagedWidget("unitinfolabel", 
					    labelWidgetClass, 
					    left_column_form, 
					    NULL);

  unit_pix_canvas = XtVaCreateManagedWidget("unitpixcanvas", 
					   pixcommWidgetClass,
					   left_column_form, 
					   XtNwidth, tileset_full_tile_width(tileset),
					   XtNheight, tileset_full_tile_height(tileset),
					   NULL);

  for(i=0; i<num_units_below; i++) {
    char unit_below_name[32];
    my_snprintf(unit_below_name, sizeof(unit_below_name),
		"unitbelowcanvas%ld", i);
    unit_below_canvas[i] = XtVaCreateManagedWidget(unit_below_name,
						   pixcommWidgetClass,
						   left_column_form, 
						   XtNwidth,
						   tileset_full_tile_width(tileset),
						   XtNheight,
						   tileset_full_tile_height(tileset),
						   NULL);
    XtAddCallback(unit_below_canvas[i], XtNcallback, unit_icon_callback,
		  (XtPointer)i);  
  }

  more_arrow_label =
    XtVaCreateManagedWidget("morearrowlabel", 
			    labelWidgetClass,
			    left_column_form,
			    XtNfromHoriz,
			    (XtArgVal)unit_below_canvas[num_units_below-1],
			    NULL);

  map_vertical_scrollbar = XtVaCreateManagedWidget("mapvertiscrbar", 
						   scrollbarWidgetClass, 
						   map_form,
						   NULL);

  map_canvas = XtVaCreateManagedWidget("mapcanvas", 
				       xfwfcanvasWidgetClass,
				       map_form,
				       "exposeProc", 
				       (XtArgVal)map_canvas_expose,
				       "exposeProcData", 
				       (XtArgVal)NULL,
				       NULL);

  map_horizontal_scrollbar = XtVaCreateManagedWidget("maphorizscrbar", 
						     scrollbarWidgetClass, 
						     map_form,
						     NULL);



  outputwindow_text= I_SW(XtVaCreateManagedWidget("outputwindowtext", 
						  asciiTextWidgetClass, 
						  bottom_form,
						  NULL));


  inputline_text= XtVaCreateManagedWidget("inputlinetext", 
					  asciiTextWidgetClass, 
					  bottom_form,
					  NULL);

}
Example #5
0
/**************************************************************************
...
**************************************************************************/
static void bmp_row_minsize(POINT *minsize, void *data)
{
  minsize->x=HAPPINESS_PIX_WIDTH*tileset_small_sprite_width(tileset);
  minsize->y=tileset_small_sprite_height(tileset);
}