Esempio n. 1
0
//------- Begin of function Town::draw -----------//
//
// Draw the town section on the zoom map
//
// [int] displayLayer   : 1 = normal layer          (default : 1)
//                      : 2 = layer above the town
//                      : 4 = layer below the town
//
void Town::draw(int displayLayer)
{
	TownLayout* townLayout = town_res.get_layout(layout_id);
	TownSlot*   townSlot   = town_res.get_slot(townLayout->first_slot_recno);

	int sectionX1 = loc_x1 * ZOOM_LOC_WIDTH;
	int sectionY1 = loc_y1 * ZOOM_LOC_HEIGHT;

	if( displayLayer==4 )
	{
		int townX1 = ZOOM_X1 + (loc_x1-world.zoom_matrix->top_x_loc) * ZOOM_LOC_WIDTH;
		int townY1 = ZOOM_Y1 + (loc_y1-world.zoom_matrix->top_y_loc) * ZOOM_LOC_HEIGHT;

		townX1 += (STD_TOWN_LOC_WIDTH  * ZOOM_LOC_WIDTH  - get_bitmap_width(townLayout->ground_bitmap_ptr))/2;		// adjust offset
		townY1 += (STD_TOWN_LOC_HEIGHT * ZOOM_LOC_HEIGHT - get_bitmap_height(townLayout->ground_bitmap_ptr))/2;	// adjust offset

		world.zoom_matrix->put_bitmap_remap_clip( townX1, townY1, townLayout->ground_bitmap_ptr );
		return;
	}

	//-------- draw plants, buildings and flags --------//

	for( int i=0 ; i<townLayout->slot_count ; i++, townSlot++ )
	{
		//----- build_type==0 if plants -----//

		switch(townSlot->build_type)
		{
			//----- build_type>0 if town buildings -----//

			case TOWN_OBJECT_HOUSE:
				town_res.get_build( slot_object_id_array[i] )
					->draw(town_recno, sectionX1+townSlot->base_x, sectionY1+townSlot->base_y );
				break;

			case TOWN_OBJECT_PLANT:
				plant_res.get_bitmap( slot_object_id_array[i] )
					->draw_at(sectionX1+townSlot->base_x, sectionY1+townSlot->base_y);
				break;

			case TOWN_OBJECT_FARM:
				draw_farm(sectionX1+townSlot->base_x, sectionY1+townSlot->base_y, townSlot->build_code );
				break;

			case TOWN_OBJECT_FLAG:
				if( nation_recno )
					draw_flag(sectionX1+townSlot->base_x, sectionY1+townSlot->base_y);
				break;
		}
	}
}
Esempio n. 2
0
void CKXDialog::rest_position(char *p)
{
 if(p!=0)
  prefix=p;

 if(prefix==0)
  prefix=(char *)get_class_name();

 int bm_width=get_bitmap_width();
 if(bm_width<=0)
  bm_width=600;
 int bm_height=get_bitmap_height();
 if(bm_height<=0)
  bm_height=340;
 int prev_x=GetSystemMetrics(SM_CXFULLSCREEN)/2-bm_width/2,
     prev_y=GetSystemMetrics(SM_CYFULLSCREEN)/2-bm_height/2;

 kSettings cfg;
 char tmp_str[21];
 char tmp_key[21];

 sprintf(tmp_key,"Prev%sX",prefix);
 if(cfg.read_abs("Mixer",tmp_key,tmp_str,21)==0)
   sscanf(tmp_str,"%d",&prev_x);

 sprintf(tmp_key,"Prev%sY",prefix);
 if(cfg.read_abs("Mixer",tmp_key,tmp_str,21)==0)
   sscanf(tmp_str,"%d",&prev_y);

 if((prev_x<GetSystemMetrics(SM_CXFULLSCREEN)-16) &&
	   (prev_y<GetSystemMetrics(SM_CYFULLSCREEN)-16)&&
	   (prev_x>-bm_width+16) &&
	   (prev_y>-bm_height+16) &&
	   (prev_x>-2048) &&
	   (prev_y>-2048))
 {
 	SetWindowPos(NULL, prev_x, 
   		prev_y,
    		-1, -1,
   		SWP_NOSIZE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOACTIVATE);
 } else CenterWindow();
}