Esempio n. 1
0
//--------- Begin of function UnitCaravan::detect_stop ---------//
//
void UnitCaravan::detect_stop()
{
	int i, x=INFO_X1;

	for( i=0 ; i<MAX_STOP_FOR_CARAVAN ; i++ )
	{
		if( is_own() && button_set_stop[i].detect() )
			power.issue_command( COMMAND_SET_CARAVAN_STOP, sprite_recno, i+1 );		// i+1 - stop id., passed as a parameter of the command

		if( !stop_array[i].firm_recno )
			continue;

		if( button_go_stop[i].detect() )
		{
			Firm* firmPtr = firm_array[ stop_array[i].firm_recno ];
			world.go_loc( firmPtr->center_x, firmPtr->center_y );
		}

		if( !is_own() )
			continue;

		if(button_cancel_stop[i].detect())
		{
			if(is_visible())
			{
				del_stop(i+1, COMMAND_PLAYER);
				se_ctrl.immediate_sound("TURN_OFF");
			}
		}

		if(button_reset_stop[i].detect() )
		{
			if( is_visible() )
			{
				set_stop_pick_up(i+1, NO_PICK_UP, COMMAND_PLAYER);
				se_ctrl.immediate_sound("TURN_OFF");
			}
		}

		for(int b=0; b<MAX_GOODS_SELECT_BUTTON; ++b)
		{
			if(button_select_array[i][b].detect())
			{
				se_ctrl.immediate_sound(
					button_select_array[i][b].elastic_flag || button_select_array[i][b].pushed_flag ?
					(char*)"TURN_ON" : (char*)"TURN_OFF");

				set_stop_pick_up(i+1, b+FIRST_GOODS_SELECT_BUTTON, COMMAND_PLAYER); // b = 1 - MAX_PICK_UP_GOODS
			}
		}
	}
}
Esempio n. 2
0
//--------- Begin of function UnitCaravan::detect_info ---------//
//
void UnitCaravan::detect_info()
{
	if( detect_unit_profile() )
		return;

//	if(!is_visible())
//		return;

	if( detect_basic_info() )
		return;

	if( !is_own() && !config.show_ai_info )
		return;
	
	detect_stop();

	if( is_own() )
	{
		int i;
		int rc =  button_auto_trade_group.detect();
		if( rc >= 0 )
		{
			if( remote.is_enable() )
			{
				// ##### begin Gilbert 7/10 ######//
				// packet structure : <unit recno> <0=manual, 1=auto>
				short *shortPtr = (short *)remote.new_send_queue_msg(MSG_U_CARA_SET_AUTO, 2*sizeof(short));
				*shortPtr = sprite_recno;
				shortPtr[1] = rc;
				return;
				// ##### end Gilbert 7/10 ######//
			}
			else
			{
				default_market_trade_mode = (char) rc;
				for( i = 0; i < MAX_STOP_FOR_CARAVAN; ++i )
					if( stop_array[i].firm_recno && stop_array[i].firm_id == FIRM_MARKET )
						set_stop_pick_up(i+1, rc ? AUTO_PICK_UP : MANUAL_PICK_UP, COMMAND_AUTO);
			}
		}

		if( button_duplicate_caravan.detect() )
		{
			se_ctrl.immediate_sound("CV-M3-5");
			duplicate_caravan(COMMAND_PLAYER);			
		}
	}
}
Esempio n. 3
0
//--------- Begin of function FirmCamp::disp_camp_upgrade ---------//
//
void FirmCamp::disp_camp_upgrade(int dispY1, int refreshFlag)
{
	if( is_own() )
	{
		int x2 = INFO_X1 +13;
		int y2 = INFO_Y1 +281;
		char iconName[]="CTOF-00";
	
		if( refreshFlag==INFO_REPAINT )
		{
			button_camp_upgrade.create( x2 + 162, y2, 'A', iconName );
			button_camp_upgrade.set_help_code( "CAMPTOFORT" );
		}
		button_camp_upgrade.enable_flag = 1;

		if ( upgrading_firm_id )
		{
			iconName[5] = '0' + upgrade_completion_percent/40;
			iconName[6] = '0' + upgrade_completion_percent/4 % 10;
			vga.active_buf->put_bitmap( x2 +162, y2, image_spict.read(iconName) );
		}
		else
			button_camp_upgrade.paint();
	}
}
Esempio n. 4
0
//--------- Begin of function FirmMonsterFortress::detect_camp_info ---------//
//
void FirmMonsterFortress::detect_camp_info()
{
	if( is_own() )
	{
		//----------- detect patrol -----------//

		if( button_transform_grokken.detect() )
		{
			// ##### patch begin Gilbert 7/8 #####//
			se_ctrl.immediate_sound("TURN_ON");
			sell_firm(COMMAND_PLAYER);
			return;
			// ##### patch end Gilbert 7/8 #####//
		}
		
		if( button_patrol.detect() )
		{
			if(remote.is_enable())
			{
				// packet structure : <firm recno> <patrol_state>
				short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, 2 * sizeof(short));
				shortPtr[0] = firm_recno;
				shortPtr[1] = 0;
			}
			else
			{
				patrol();
			}
		//	se_ctrl.immediate_sound("SORTIE");
			if( archer_count > 0 )
			{
				Unit *unitPtr = unit_array[archer_unit_recno[0]];
				se_res.sound( center_x, center_y, 1, 'S', unitPtr->sprite_id, "ACK");
			}
		}

		//----------- detect reward -----------//

		if( selected_archer_id > 0 && selected_archer_id <= archer_count  
			&& button_reward.detect() )
		{
			if( !remote.is_enable() )
			{
				unit_array[archer_unit_recno[selected_archer_id-1]]->reward(nation_array.player_recno);
			}
			else
			{
				// packet structure : <rewarding nation> <unit count> <unit recno> ...
				short *shortPtr = (short *)remote.new_send_queue_msg(MSG_UNIT_REWARD, 3*sizeof(short));
				// reserve two short more in case selected_recno is slightly smalled then the actual selected
				shortPtr[0] = nation_array.player_recno;
				shortPtr[1] = 1;
				shortPtr[2] = archer_unit_recno[selected_archer_id-1];
			}
			se_ctrl.immediate_sound("TURN_ON");
		}
	}
}
Esempio n. 5
0
//--------- Begin of function FirmCamp::next_day ---------//
//
void FirmCamp::next_day()
{
	//----- call next_day() of the base class -----//

	Firm::next_day();

	//----- update the patrol_unit_array -----//

	validate_patrol_unit();
	validate_soldier();

	//------- update loyalty --------//

	if( info.game_date%30 == firm_recno%30 )
		update_loyalty();

	//-------- consume food --------//

	if( soldier_count>0 )
		consume_food();

	// ------- process train ---------//

	if( config.fast_build && is_own() )
	{
		for( int i=0 ; i<100 ; i++ )
			basic_train();
	}
	else
		basic_train();

	//--------------------------------------//

	if( info.game_date%30 == firm_recno%30 )			// once a week
	{
		advanced_train();
	}

	if( info.game_date%8 == firm_recno%8 )
	{
		recover_hit_point();
	}

	// ------ process item --------//

	Soldier* soldierPtr = soldier_array;

	for( int i=0 ; i<soldier_count ; i++, soldierPtr++ )
	{
		soldierPtr->item.next_day();
	}

	//----------- debugging code -----------//

	err_when( overseer_recno && unit_array[overseer_recno]->skill_level()==0 );

	err_when( overseer_recno && unit_array[overseer_recno]->nation_recno != nation_recno );
}
Esempio n. 6
0
//--------- Begin of function FirmMarket::put_info ---------//
//
void FirmMarket::put_info(int refreshFlag)
{
	Firm::put_info(refreshFlag);

	vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("MARKBASE") );
	disp_market_info( INFO_Y1, refreshFlag );

	//--- only display market info if the player is allowed to trade with this market ---//

	if( config.show_ai_info || is_own() )
	{
		disp_income(INFO_Y1+209, refreshFlag );	  // 1-display income figure
	}

	button_hire_caravan.create( INFO_X1+13, INFO_Y1+281, 'A', "HIRECARA" );
	button_hire_caravan.enable_flag = 0;

	if( is_own() )
	{
		button_hire_caravan.enable_flag = can_hire_caravan();
		button_hire_caravan.paint();
	}

/*
	disp_basic_info(INFO_Y1, refreshFlag);

	//--- only display market info if the player is allowed to trade with this market ---//

	put_market_info(INFO_Y1+50, refreshFlag);

	//------------------------------------------------//

	if( !config.show_ai_info && nation_recno!=nation_array.player_recno )
		return;

	disp_income(INFO_Y1+209, refreshFlag );	  // 1-display income figure

	button_hire_caravan.paint( INFO_X1, INFO_Y1+236, 'A', "HIRECARA" );

	if( can_hire_caravan() )
		button_hire_caravan.enable();
	else
		button_hire_caravan.disable();
*/
}
Esempio n. 7
0
//--------- Begin of function FirmMarket::detect_info ---------//
//
void FirmMarket::detect_info()
{
	Firm::detect_info();

	detect_market_info();

	if( is_own() )
	{
		if( button_hire_caravan.detect() )
		{
			hire_caravan(COMMAND_PLAYER);
			se_ctrl.immediate_sound("TURN_ON");
		}
	}

/*
	if( detect_basic_info() )
		return;

	if( !config.show_ai_info && nation_recno!=nation_array.player_recno )
		return;

	if( nation_recno != nation_array.player_recno )		// the following controls are only available for player's firms
		return;

	//----- detect clear stock buttons -------//

	for( int i=0 ; i<MAX_MARKET_GOODS ; i++ )
	{
		if( button_clear_stock[i].detect() )
		{
			if( !remote.is_enable() )
			{
				MarketGoods* marketGoods = market_goods_array+i;
				
				clear_market_goods(i+1);
				info.disp();
				return;
			}
			else
			{
				// message structure : <firm recno> <cell no 0-3>
				short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_MARKET_SCRAP, sizeof(short)+sizeof(short) );
				shortPtr[0] = firm_recno;
				shortPtr[1] = i;
			}
			se_ctrl.immediate_sound("TURN_OFF");
		}
	}

	//----- detect hire caravan button -------//

	if( button_hire_caravan.detect() )
		hire_caravan(COMMAND_PLAYER);

*/
}
Esempio n. 8
0
void FirmWork::detect_info()
{
	detect_firm_info();
	if( !should_show_info() )
		return;
	
	if (is_own())
	{
		detect_worker_list();
		detect_worker_info();
	}
}
Esempio n. 9
0
// -------- begin of function FirmWar::detect_firm_info --------//
//
void FirmWar::detect_firm_info()
{
	if( is_own() )
	{
		//---------- detect cancel build ------------//

		if(build_unit_id)
		{
			if(button_cancel_build.detect())
			{
				se_ctrl.immediate_sound("TURN_OFF");
				if( !remote.is_enable() )
					cancel_build_unit();
				else
				{
					short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_WAR_SKIP_WEAPON, sizeof(short) );
					shortPtr[0] = firm_recno;
				}
			}
		}

		//------ detect the select build button -------//

		if( button_select_build.detect() )
		{
			war_tech_class = TECH_CLASS_WEAPON;
			war_menu_mode = WAR_MENU_BUILD;
			se_ctrl.immediate_sound("TURN_ON");
		}

		if( button_select_build2.detect() )
		{
			war_tech_class = TECH_CLASS_MEGA_WEAPON;
			war_menu_mode = WAR_MENU_BUILD;
			se_ctrl.immediate_sound("TURN_ON");
		}

		// ------- display rally points button ------//

		if( button_go_rally.detect() )
		{
			world.go_loc( rally_dest_x, rally_dest_y, 0 );
			se_ctrl.immediate_sound("TURN_ON");
		}

		if( button_clear_rally.detect() )
		{
			clear_rally_point(COMMAND_PLAYER);
			se_ctrl.immediate_sound("TURN_OFF");
		}
	}
}
Esempio n. 10
0
//--------- Begin of function Unit::disp_basic_info ---------//
//
void Unit::disp_basic_info(int dispY1, int refreshFlag)
{
	//------- display the name of the unit --------//

	if( refreshFlag == INFO_REPAINT )
	{
		int dispName = unit_id == UNIT_CARAVAN || unit_res[unit_id]->unit_class == UNIT_CLASS_SHIP;		// only display names for caravans and ships as their names are not displayed in the other part of the interface

		vga_util.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+21 );

		if( nation_recno )
		{
			int dispTitle = is_own() || nation_recno==0;		// only display title for own units or independent units (which is for rebel leader only)

			if( dispName )
				font_san.center_put( INFO_X1+21, dispY1, INFO_X2-2, dispY1+21, unit_name(dispTitle) );

			vga_util.d3_panel_down( INFO_X1+3, dispY1+3, INFO_X1+20, dispY1+18 );

			//------- display the nation color box -------//

			char *nationPict = image_button.get_ptr("V_COLCOD");

			vga_front.put_bitmap_remap(INFO_X1+3, dispY1+2, nationPict, game.get_color_remap_table(nation_recno, 0) );
		}
		else
		{
			if( dispName )
				font_san.center_put( INFO_X1, dispY1, INFO_X2-2, dispY1+21, unit_name() );
		}
	}

	dispY1+=23;

	//-------- display the hit points bar --------//

	if( refreshFlag == INFO_REPAINT )
	{
		vga_util.d3_panel_up( INFO_X1, dispY1, INFO_X2, dispY1+27 );

		if( nation_recno == nation_array.player_recno &&
			 can_resign())
		{
			button_resign.paint( INFO_X1+4, dispY1+1, "V_X-U", "V_X-D" );
			button_resign.set_help_code( "RESIGN" );
		}
	}

	//-------- display hit points in numbers --------//

	disp_hit_point(dispY1);
}
Esempio n. 11
0
void FirmOffensive::detect_main_menu()
{
	Firm::detect_info();

	if( !is_own() )
		return;

	String str;

	if( button_cast.detect() )
	{
		menu_mode_para = magic_id_upper_limit;
		se_ctrl.immediate_sound("TURN_ON");
		switch(magic_id_upper_limit) //bug
		{
			case MAGIC_FREEZE_LASER:
				cast_magic( MAGIC_FREEZE_LASER, center_x, center_y, 0, COMMAND_PLAYER );
				break;

			case MAGIC_GOD_POWER:
				menu_mode = FIRM_MAGIC_MENU_CAST;
				power.issue_command(COMMAND_FIRM_MAGIC, firm_recno, menu_mode_para);
				break;

			case MAGIC_LASER:
				cast_magic( MAGIC_LASER, center_x, center_y, 0, COMMAND_PLAYER );
				break;

			default:
				err_here();
		}
	}

	switch(magic_id_upper_limit) //bug
	{
		case MAGIC_FREEZE_LASER:
			help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC7" );
			break;

		case MAGIC_GOD_POWER:
			help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC6" );
			break;

		case MAGIC_LASER:
			help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC5" );
			break;

		default:
			err_here();
	}
}
Esempio n. 12
0
//--------- Begin of function Unit::detect_main_menu ---------//
//
void Unit::detect_main_menu()
{
	if( detect_basic_info() )
		return;

	if( detect_unit_profile() )
		return;

	if( is_own_spy() )
		detect_spy_menu(INFO_Y1+187);

	if( is_own() )
		detect_button();
}
Esempio n. 13
0
void FirmIncubator::disp_firm_info(int dispY1, int refreshFlag)
{
	String str;

	if( refreshFlag == INFO_REPAINT )
	{
		button_select_build.create( INFO_X1 +13, INFO_Y1 +281, 'A', "MAKEWEAP" );

		// ###### begin Gilbert 11/3 ########//
		button_go_rally.create( INFO_X1+13+BUTTON_DISTANCE*2, INFO_Y1+235, 'A', "RALLY-GO" );
		button_clear_rally.create( INFO_X1+13+BUTTON_DISTANCE*3, INFO_Y1+235, 'A', "RALLY-NO" );
		// ###### end Gilbert 11/3 ########//
	}

	disp_war_info(INFO_Y1+54, refreshFlag);

	if ( build_unit_id )
	{
		int limit = 2;
		
		if ( animate_seqno >=(limit*3) )
			animate_seqno = 1;
		
		char animate[] = "GEARW-0";
		animate[6] = '3' - animate_seqno / limit;
		
		animate_seqno ++;

		vga.active_buf->put_bitmap( INFO_X1+140, INFO_Y1+61, image_icon.read( animate ) );	
	}

	int x2 = INFO_X1 +13;
	int y2 = INFO_Y1 +281;
	button_select_build.enable_flag = 0;
	if( is_own() )
	{
		button_select_build.enable_flag = 1;
		button_select_build.paint();

		// ------- display rally points button ------//

		if( (button_go_rally.visible_flag = rally_enable_flag != 0) )
			button_go_rally.paint();

		if( (button_clear_rally.visible_flag = rally_enable_flag != 0) )
			button_clear_rally.paint();
	}	

}
Esempio n. 14
0
void FirmOffensive::disp_main_menu(int refreshFlag)
{
	Firm::put_info(refreshFlag);

	button_cast.create( INFO_X1 +13, INFO_Y1 +259, 'A', "GBA-1" );
	
	if( !should_show_info() )
		return;

	vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") );

	// display delay

	if( cast_delay > 0 )
	{
		short*	hitPointBitmap =NULL;
		int ratio = cast_delay *40 / cast_delay_max;
		int size = cast_delay *76 / cast_delay_max;
		
		//106 x 35 --- 15 to 90 ie. 0 to 40
		int offsetX = -35;
		int offsetY = -40;
		hitPointBitmap = (short *)mem_add( BitmapW::size(15 +size, 35) );	
		if (ratio <11)
			vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_10"));
		else
		if (ratio <40)
			vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_39"));
		else
			vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_40"));
		
		vga.active_buf->read_bitmapW( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, INFO_X1 +94 +20 +size +offsetX, INFO_Y1 +80 +offsetY, hitPointBitmap );
		vga.active_buf->put_bitmap_trans( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, image_spict.read("MTR_00"));
		vga.active_buf->put_bitmapW( INFO_X1 +80 +20 +offsetX, INFO_Y1 +49 +offsetY, hitPointBitmap );
		mem_del( hitPointBitmap );				
	}

	if( !is_own() )
		return;

	char fileName[] = "GBA-1";
	
	if (button_cast.enable_flag)
		fileName[4] = '1' + (char) (sys.frame_count%3);

	button_cast.update_bitmap( fileName );
	button_cast.enable_flag = can_cast(magic_id_upper_limit);
	button_cast.paint();
}
Esempio n. 15
0
//-------- Begin of function Unit::should_show_info ------//
//
int Unit::should_show_info()
{
	if( config.show_ai_info || is_own() )
		return 1;

	//---- if there is a phoenix of the player over this firm ----//

	if( nation_array.player_recno &&
		 (~nation_array)->revealed_by_phoenix(next_x_loc(), next_y_loc()) )
	{
		return 1;
	}

	return 0;
}
Esempio n. 16
0
// -------- begin of function FirmResearch::detect_firm_info --------//
//
void FirmResearch::detect_firm_info()
{
	// ##### begin Gilbert 5/10 ######//
	if( is_own() )
	{
		//------ detect the select research button -------//

		if( button_select_research.detect() )
		{
			research_menu_mode = RESEARCH_MENU_RESEARCH_CLASS;
			se_ctrl.immediate_sound("TURN_ON");
		}
	}
	// ##### end Gilbert 5/10 ######//
}
Esempio n. 17
0
void	command(t_env *env, char *s)
{
	char	**sa;

	if (s == NULL)
		return ;
	sa = NULL;
	rm_tabs(&s);
	sa = ft_strsplit(s, ' ');
	if (is_own(s))
		own_command(env, sa, s);
	else
		link_files(env, s);
	free2d(sa);
}
Esempio n. 18
0
//--------- Begin of function UnitGod::detect_info ---------//
//
void UnitGod::detect_info()
{
	if( detect_basic_info() )
		return;

	if( detect_unit_profile() )
		return;

	if( !is_own() )
		return;

	if( game.game_mode == GAME_TEST )
		return;

	if( god_res[god_id]->can_cast_power )
	{
		// ###### begin Gilbert 14/10 ######//
		int rc=0;
		char castPowerType = 0;

		if( button_cast.detect() )
		{
			// cast_power_type = 1;
			castPowerType = 1;
			rc = 1;
		}

		if( button_cast2.detect() )
		{
			castPowerType = 2;
			//cast_power_type = 2;
			//cast_origin_x = cur_x_loc();
			//cast_origin_y = cur_y_loc();
			rc = 1;
		}

		//----------------------------------------//

		if( rc && castPowerType)
		{
			if( god_id == GOD_VIKING && castPowerType == 1 )	// summon rain, summon immediately, no need to select target
				go_cast_power(next_x_loc(), next_y_loc(), castPowerType, COMMAND_PLAYER);
			else
				power.issue_command(COMMAND_GOD_CAST_POWER, sprite_recno, castPowerType);
		}
		// ###### end Gilbert 14/10 ######//
	}
}
Esempio n. 19
0
// -------- begin of function FirmBase::detect_firm_info --------//
//
void FirmBase::detect_firm_info()
{
	if( !is_own() )
		return;

	//----------- detect invoke -----------//

	if( button_invoke.detect() && can_invoke() )
	{
		if(remote.is_enable())
		{
			// packet structure : <firm recno>
			short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_BASE_INVOKE_GOD, sizeof(short));
			shortPtr[0] = firm_recno;
		}
		else
		{
			invoke_god();
			// ##### patch begin Gilbert 21/10 #######//
			return;		// call selecting new god now, return immediately
			// ##### patch end Gilbert 21/10 #######//
		}
	}

	// ---------- detect unknown effect -----//

	if( button_unknown_effect.detect() && can_make_wish() )
	{
		invoke_random_effect( 0, COMMAND_PLAYER);
		invoked_effect_last = 3;
		se_ctrl.immediate_sound("TURN_ON");
	}

	// ----- detect clear invoked_effect_text button -----//

	if( button_clear_text.detect() )
	{
		invoked_effect_text[0] = '\0';
		se_ctrl.immediate_sound("TURN_ON");
	}
 
//	help.set_help( INFO_X1+13+54, INFO_Y1+261, INFO_X1+13+53+44, INFO_Y1+280+48, "GDINVOKE" );
//	help.set_help( INFO_X1+13+108, INFO_Y1+261, INFO_X1+13+107+44, INFO_Y1+280+48, "BLESS" );
}
Esempio n. 20
0
//--------- Begin of function FirmMonsterFortress::disp_camp_info ---------//
//
void FirmMonsterFortress::disp_camp_info(int dispY1, int refreshFlag)
{
	if( is_own() )
	{
		int x1 = INFO_X1 +13;
		int y1 = INFO_Y1 +235;
		int x2 = INFO_X1 +13;
		int y2 = INFO_Y1 +281;
		if( refreshFlag==INFO_REPAINT )
		{
			button_patrol.create( x2, y2, 'A', "PATROL" );
			button_transform_grokken.create( x1+BUTTON_DISTANCE, y1, 'A', "FORTRS-2" );
			button_reward.create( x1, y1, 'A', "F_REWARD" );
		}
		button_patrol.enable_flag = archer_count > 0;
		button_patrol.paint();

		button_transform_grokken.enable_flag = 1;
		button_transform_grokken.paint();

		if( nation_array[nation_recno]->cash >= REWARD_COST 
			&& selected_archer_id > 0 && selected_archer_id <= archer_count
			&& unit_array[archer_unit_recno[selected_archer_id-1]]->rank_id != RANK_KING )
			button_reward.enable_flag = 1;			// call paint
		else
			button_reward.enable_flag = 0;		// call paint
		button_reward.paint();


		// display number of supporter

		info.draw_unit_icon( INFO_X1+40, INFO_Y1+52,
			support_unit_id, nation_recno,
			INFO_X1+15, INFO_Y1+5, INFO_X1+68, INFO_Y1+84, 1 );

		String str;
		str = unit_res[support_unit_id]->name;
		str += " x ";
		str += extra_builder_count;
		font_snds.center_put( INFO_X1+88, INFO_Y1+15, INFO_X1+217, INFO_Y1+74, str, 0, 0 );
	}
}
Esempio n. 21
0
//--------- Begin of function Unit::disp_main_menu ---------//
//
void Unit::disp_main_menu(int refreshFlag)
{
	disp_basic_info(INFO_Y1, refreshFlag);
	disp_unit_profile( INFO_Y1+52, refreshFlag );

	if( !should_show_info() )
		return;

	//---------------------------------//

	int y=INFO_Y1+98;

	if( race_id )
	{
		disp_unit_info( y, refreshFlag );
		y += 89;
	}

	//---------------------------------//

	if( is_own_spy() )
	{
		disp_spy_menu(y, refreshFlag);
		y+=spy_menu_height()+3;
	}

	if( is_own() )
	{
		if( refreshFlag == INFO_REPAINT )
			disp_button(y);

		y+=BUTTON_ACTION_HEIGHT;
	}

	#ifdef DEBUG
		if( sys.debug_session || sys.testing_session )
			disp_debug_info(this, INFO_Y2-68, refreshFlag);
	#endif
}
Esempio n. 22
0
//--------- Begin of function UnitCaravan::disp_info ---------//
//
void UnitCaravan::disp_info(int refreshFlag)
{
	char *nationPict = image_spict.get_ptr("V_COLCOD");
	vga.active_buf->put_bitmap_trans_remap_decompress(INFO_X1+16, INFO_Y1-28, nationPict, game.get_color_remap_table(nation_recno, 0) );

	vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("CARABASE") );

//	disp_basic_info(INFO_Y1, refreshFlag);
	disp_unit_profile(10, refreshFlag);

	if( !config.show_ai_info && !is_own() )
		return;

	disp_stop(INFO_Y1+54, refreshFlag);

	// display auto/manual button

	button_duplicate_caravan.create( INFO_X1+13, INFO_Y1+281, 'A', "CARACOPY" );

	// manual button
	button_auto_trade_group[0].create( INFO_X1+BUTTON_DISTANCE+13, INFO_Y1+235,
		INFO_X1+BUTTON_DISTANCE+56-1, INFO_Y1+280,
		i_disp_auto_trade_button, ButtonCustomPara(this, 0), 0 );

	// auto button
	button_auto_trade_group[1].create( INFO_X1+13, INFO_Y1+235,
		INFO_X1+56-1, INFO_Y1+280,
		i_disp_auto_trade_button, ButtonCustomPara(this, 1), 0 );
	button_auto_trade_group[1].set_help_code( "AUTOPICK" );
	button_auto_trade_group.paint( default_market_trade_mode );
	
	button_duplicate_caravan.enable_flag = can_duplicate_caravan();
	button_duplicate_caravan.paint();

	disp_goods(INFO_Y1+235, refreshFlag);
}
Esempio n. 23
0
//--------- Begin of function FirmWar::detect_main_menu ---------//
//
void FirmWar::detect_main_menu()
{
	detect_firm_info();
	if( !should_show_info() )
		return;

	if( !is_own() )
		return;

	//----------- detect worker -----------//
	detect_worker_list();
	detect_worker_info();


	//------ detect the select research button -------//

//	if( button_select_build.detect() )
//	{
//		war_menu_mode = WAR_MENU_BUILD;
	//	disable_refresh = 1;    // static var for disp_info() only
	//	info.disp();
	//	disable_refresh = 0;
//	}
}
Esempio n. 24
0
//--------- Begin of function FirmCamp::disp_camp_info ---------//
//
void FirmFort::disp_camp_info(int dispY1, int refreshFlag)
{
	FirmCamp::disp_camp_info(dispY1, refreshFlag);

	// ----- display train button -------//

	int x2 = INFO_X1 +13;
	int y2 = INFO_Y1 +281;
	if (!is_monster())
		button_train.create( INFO_X1+13, INFO_Y1+281, 'A', "TRAIN" );
	else
		button_train.create( INFO_X1+13, INFO_Y1+281, 'A', "F_TRAIN" );

	// scan any available population to train

	// ##### begin Gilbert 23/12 #######//
	if( (button_train.visible_flag = is_own()) )
	{
		button_train.enable_flag = can_recruit(active_link_town_recno);
		button_train.paint();
	}
	// ##### end Gilbert 23/12 #######//

	// ------- display tower count -----//

	button_tower_count.create( INFO_X1+13+3*BUTTON_DISTANCE+6, INFO_Y1+235+6,
		INFO_X1+13+3*BUTTON_DISTANCE+6+TOWER_COUNT_BUTTON_WIDTH-1,
		INFO_Y1+235+6+TOWER_COUNT_BUTTON_HEIGHT-1,
		disp_tower_count, ButtonCustomPara( NULL, 0 ) );

//#ifdef DEBUG
	// BUGHERE : ARM_TOWERS is longer than 8 characters
	// button_tower_count.set_help_code("ARM_TOWERS");
	button_tower_count.set_help_code("ARM_TOWE");
//#endif

	button_tower_count.enable_flag = is_own();
	button_tower_count.custom_para = ButtonCustomPara( NULL, target_archer_count );
	button_tower_count.paint();

	// ------- display towers ----------//

	err_when( !image_spict.read_all );			// must read_all
	char *towerFull = image_spict.read("TOWER-F");
	char *towerEmpty = image_spict.read("TOWER-E");
	char *towerBuilding = image_spict.read("TOWER-D");
	int towerHeight = ((Bitmap *)towerFull)->get_height();
	err_when( ((Bitmap *)towerEmpty)->get_height() != towerHeight );
	err_when( ((Bitmap *)towerBuilding)->get_height() != towerHeight );
	int towerWidth = ((Bitmap *)towerFull)->get_width();

//	static int towerXTable[MAX_FORT_ARCHER] = { 180, 202, 191, 180, 202 };
//	static int towerYTable[MAX_FORT_ARCHER] = { 280, 280, 292, 304, 304 };
	static int towerXTable[MAX_FORT_ARCHER] = { 180, 202, 191, 180, 202 };
	static int towerYTable[MAX_FORT_ARCHER] = { 304, 304, 292, 280, 280 };

	for( int i = 0; i < MAX_FORT_ARCHER; ++i )
	{
		int towerX = INFO_X1 + towerXTable[i];
		int towerY = INFO_Y1 + towerYTable[i];

		if( i < current_archer_count )
		{
			// display full tower
			vga.active_buf->put_bitmap( towerX, towerY, towerFull );
		}
		else if( i == current_archer_count )
		{
			// display building tower
			vga.active_buf->put_bitmap( towerX, towerY, towerEmpty );

			// display portion of towerFull at bottom
			int subTowerHeight = train_archer_progress * towerHeight / MAX_TRAIN_ARCHER_PROGRESS;
			if( subTowerHeight > 0 )
			{
				vga.active_buf->put_bitmap_area( towerX, towerY, towerBuilding, 
					0, towerHeight-subTowerHeight, towerWidth-1, towerHeight-1 );
			}
		}
		else
		{
			// display disabled tower	
			vga.active_buf->put_bitmap( towerX, towerY, towerEmpty );
		}
	}

	help.set_help( INFO_X1+176, INFO_Y1+278, INFO_X1+176+39, INFO_Y1+278+48, "TOWERS" );
}
Esempio n. 25
0
void FirmOffensive::disp_magic_menu(int refreshFlag)
{
	// ----- create cancel button -------//

	button_cancel.create( INFO_X1 +13, INFO_Y1 +235, 'A', "CANCEL" );
	if( !should_show_info() )
		return;

	vga.active_buf->put_bitmap(INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") );

	if( !is_own() )
		return;

	// display instruction
//	String str;

	switch( menu_mode )
	{
	case FIRM_MAGIC_MENU_CAST:
		font_snds.center_put_paragraph( INFO_X1 +20 , INFO_Y1 +20, INFO_X2 -10, INFO_Y1 +60, 
			text_firm.str_cast_magic_instruct(menu_mode_para), 2, 0, 0);
		break;

	case FIRM_MAGIC_MENU_UNIT:
		// str = "Select a Unit to Teleport";
		font_snds.center_put_paragraph( INFO_X1 +20 , INFO_Y1 +20, INFO_X2 -10, INFO_Y1 +60, 
			text_firm.str_cast_teleport_source(), 2, 0, 0);
		break;

	default:
		err_here();
	}

	// display magic name

//	font_snds.center_put_paragraph( INFO_X1 +20 , INFO_Y1 +60, INFO_X2 -10, INFO_Y1 +80,
//		tech_res[magic_info_array[menu_mode_para-1].tech_id]->tech_des(), 2, 0, 0);

	// display cost

	if( menu_mode == FIRM_MAGIC_MENU_CAST )
	{
		char mobileType;
		int pointedXLoc;
		int pointedYLoc;

		if( world.zoom_matrix->get_detect_location(mouse.cur_x, mouse.cur_y, &pointedXLoc, &pointedYLoc, &mobileType) )
		{
			//	int x2 = font_snds.put( INFO_X1+20, INFO_Y1+70, "Life Point Cost : ");
			//	font_snds.put( x2, INFO_Y1+70, calc_live_point_cost( menu_mode_para, pointedXLoc, pointedYLoc, teleport_unit_recno) );
			switch( menu_mode_para )
			{
			case MAGIC_DESTROY_BUILDING:
			case MAGIC_FREEZE_UNIT:
			case MAGIC_DAMAGE_AREA:
			case MAGIC_GOD_POWER:
				font_snds.center_put_paragraph( INFO_X1 +20 , INFO_Y1 +80, INFO_X2 -10, INFO_Y1 +120, 
					text_firm.str_cast_cost_cash(calc_cash_cost( menu_mode_para, pointedXLoc, pointedYLoc, 0)),
					2, 0, 0);
				break;

			case MAGIC_TELEPORT:
				font_snds.center_put_paragraph( INFO_X1 +20 , INFO_Y1 +80, INFO_X2 -10, INFO_Y1 +120,
					text_firm.str_teleport_cost_cash(calc_cash_cost( menu_mode_para, pointedXLoc, pointedYLoc, teleport_unit_recno)),
					2, 0, 0);
				break;
			}
		}
	}

	// display cancel button

	button_cancel.paint();
}
Esempio n. 26
0
//--------- Begin of function FirmCamp::detect_camp_info ---------//
//
void FirmCamp::detect_camp_info()
{
	int rc;
	if( is_own() )
	{
		//----------- detect patrol -----------//

		if( (rc = button_patrol.detect(0, 0, 1)) )
		{
			if (rc == 2)
			{
				patrol_state = (++patrol_state) % 3;
			}
			else
			if(remote.is_enable())
			{
				// packet structure : <firm recno> <patrol_state>
				short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, 2 * sizeof(short));
				shortPtr[0] = firm_recno;
				shortPtr[1] = patrol_state;
			}
			else
			{
				patrol(patrol_state);
			}
		//	se_ctrl.immediate_sound("SORTIE");
			if( overseer_recno )
			{
				Unit *overseer = unit_array[overseer_recno];
				se_res.sound( center_x, center_y, 1, 'S', overseer->sprite_id, "ACK");
			}
			else
			if( soldier_count > 0 )
			{
				Soldier *soldierPtr = &soldier_array[0];
				int unitId = soldierPtr->unit_id;
				UnitInfo *unitInfo = unit_res[unitId];
				se_res.sound( center_x, center_y, 1, 'S', unitInfo->sprite_id, "ACK");
			}				
		}

		//----------- detect reward -----------//

		if( button_reward.detect() )
		{
			reward(selected_soldier_id, COMMAND_PLAYER);
			se_ctrl.immediate_sound("TURN_ON");
		}

		if( firm_id==FIRM_CAMP && button_camp_upgrade.detect() )
		{
			if (!upgrading_firm_id)
			{
				se_ctrl.immediate_sound("TURN_ON");
				start_upgrade(FIRM_FORT, COMMAND_PLAYER);	
			}
		}

		//----- detect defense mode button -------//

		if( button_defense.detect() )
		{
			se_ctrl.immediate_sound( !defense_flag?"TURN_ON":"TURN_OFF");

			if( !remote.is_enable() )
			{
				// update RemoteMsg::toggle_camp_patrol()
				defense_flag = !defense_flag;
			}
			else
			{
				// packet structure : <firm recno> <defense_flag>
				short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_TOGGLE_PATROL, 2*sizeof(short));
				shortPtr[0] = firm_recno;
				shortPtr[1] = !defense_flag;
			}

//			button_defense.update_bitmap( defense_flag ? "DEFENSE1" : "DEFENSE0" );
		}

		if( button_promote.detect() )
		{
			promote_soldier( selected_soldier_id, COMMAND_PLAYER );
			se_ctrl.immediate_sound("PROMOTE");
		}
	}
}
Esempio n. 27
0
// ------- begin of function FirmMonsterTrain::detect_trainee_list -------//
//
// int FirmMonsterTrain::detect_trainee_list(int selectSpyMenu)
int FirmMonsterTrain::detect_trainee_list()
{
	int selectSpyMenu = 0;

	int dispY1 = disp_trainee_list_y1;

	// display in ascending order to select the overseer first

	for( int i = 1; i <= trainee_count; ++i )
	{
		// display trainee i

		int x = INFO_X1 + 18 + (i-1) * TRAINEE_X_SPACING;
		int y = INFO_Y1 + 136;
		int yHp = INFO_Y1 + 93;

		int windowX1 = INFO_X1 + 16;
		int windowX2 = INFO_X1 + 220;
		int windowY1 = INFO_Y1 + 89;
		int windowY2 = windowY1 + 80 - 1 ;

		int unitId;
		int representAttribute;
		int ownSpy;

		// trainee
		MonsterTrainee *traineePtr = &trainee_array[i-1];
		unitId = traineePtr->unit_id;
		representAttribute = represent_attribute(i);
		ownSpy = 0;	 //traineePtr->is_own_spy() ? traineePtr->spy_recno : 0;

		if( selectSpyMenu && !ownSpy )
			continue;

		int rc = info.draw_unit_icon( x+TRAINEE_X_SPACING/2, y,
			unitId, nation_recno, 
			windowX1, windowY1, windowX2, windowY2, 24 );			// detect left button (8) and right button (16)

		if( !rc )
			continue;

		if( selectSpyMenu == 0 )
		{
			// -------- main menu ---------//

			if( rc & 8 )
			{
				// ----- left click select trainee/overseer -------//

				selected_trainee_id = i;
				return 1;
			}
			else if( rc & 16 && is_own() )
			{
				// ------ right click mobilize solidier/overseer ------//
				// ####### begin Gilbert 26/1 #######//
				if( !trainee_array[i-1].is_under_training() )
					mobilize_trainee(i, COMMAND_PLAYER);
				else
					cancel_train_trainee(i, COMMAND_PLAYER);
				// ####### end Gilbert 26/1 #######//
				return 2;
			}
		}
		else if( selectSpyMenu == 1 )
		{
			if( rc & 8 && ownSpy )
			{
				selected_trainee_id = i;
				return ownSpy;
			}
		}
	}

	return 0;
}
Esempio n. 28
0
// ------- begin of function FirmMonsterTrain::disp_firm_info -------//
//
void FirmMonsterTrain::disp_firm_info(int dispY1, int refreshFlag )
{
	int i;

	if( refreshFlag == INFO_REPAINT )
	{
		button_mobilize.create( INFO_X1+13, INFO_Y1+235, 'A', "MOBILIZE" );
		button_mobilize.enable_flag = 0;
		if ((train_type_count == 1) && (train_unit_id[0] == UNIT_BEE))
			button_patrol.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, 'A', "PATROL-B" );
		else
		if ((train_type_count == 1) && (train_unit_id[0] == UNIT_TERMITE))
			button_patrol.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, 'A', "PATROL-T" );
		else
			button_patrol.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, 'A', "PATROL" );

		button_patrol.enable_flag = 0;
		for( i = 0; i < train_type_count; ++i )
		{
			if( i < 4 )		// 4 buttons at bottom line
			{
				if ((train_type_count == 1) && (train_unit_id[0] == UNIT_BEE))
					button_train[i].create( INFO_X1+13+i*BUTTON_DISTANCE, INFO_Y1+281, 'A', "TRAIN-B" );
				else
				if ((train_type_count == 1) && (train_unit_id[0] == UNIT_TERMITE))
					button_train[i].create( INFO_X1+13+i*BUTTON_DISTANCE, INFO_Y1+281, 'A', "TRAIN-T" );
				else
					button_train[i].create( INFO_X1+13+i*BUTTON_DISTANCE, INFO_Y1+281, 'A', "F_TRAIN" );
			}
			else
			{
				if ((train_type_count == 1) && (train_unit_id[0] == UNIT_BEE))
					button_train[i].create( INFO_X1+13+(7-i)*BUTTON_DISTANCE, INFO_Y1+235, 'A', "TRAIN-B" );
				else
				if ((train_type_count == 1) && (train_unit_id[0] == UNIT_TERMITE))
					button_train[i].create( INFO_X1+13+(7-i)*BUTTON_DISTANCE, INFO_Y1+235, 'A', "TRAIN-T" );
				else
					button_train[i].create( INFO_X1+13+(7-i)*BUTTON_DISTANCE, INFO_Y1+235, 'A', "F_TRAIN" );
			}
			button_train[i].enable_flag = 0;
		}

		// ###### begin Gilbert 11/3 ########//
		button_go_rally.create( INFO_X1+13+BUTTON_DISTANCE*2, INFO_Y1+235, 'A', "RALLY-GO" );
		button_clear_rally.create( INFO_X1+13+BUTTON_DISTANCE*3, INFO_Y1+235, 'A', "RALLY-NO" );
		// ###### end Gilbert 11/3 ########//
	}

	if( !should_show_info() )
		return;

	// ------ display mobilize button -------//

	button_mobilize.enable_flag = 0;

	if( is_own() )
	{
		if( selected_trainee_id > 0 && selected_trainee_id <= trainee_count )
		{
			MonsterTrainee *traineePtr = trainee_array + selected_trainee_id - 1;
			button_mobilize.enable_flag = !traineePtr->is_under_training();
		}

		button_mobilize.paint();

		// ----- display mobilize all button -------//

		for( i = 0; i < trainee_count && trainee_array[i].is_under_training(); ++i );
		button_patrol.enable_flag = i < trainee_count;
		button_patrol.paint();

		// ----- display train button ----------// 

		for( i = 0; i < train_type_count; ++i )
		{
			button_train[i].enable_flag = can_recruit(train_unit_id[i]);
			button_train[i].paint();
		}

		// ------- display rally points button ------//

		if( (button_go_rally.visible_flag = rally_enable_flag != 0) )
			button_go_rally.paint();

		if( (button_clear_rally.visible_flag = rally_enable_flag != 0) )
			button_clear_rally.paint();
	}
}
Esempio n. 29
0
//--------- Begin of function FirmCamp::detect_soldier_list ---------//
//
// <int> selecteSpyMenu        0=main menu; 1=selecting spy
// when selectSpyMenu is 0, return 1 if left click on a unit, return 2 if right click on a unit
// when selectSpyMenu is 1, return spy_recno of the clicked spy, 0 if no own spy is clicked
//
int FirmCamp::detect_soldier_list(int selectSpyMenu)
{
	int dispY1 = disp_soldier_list_y1;

	// display in ascending order to select the overseer first

	for( int i = 0; i <= soldier_count; ++i )
	{
		// display soldier i

		int row = i/SOLDIER_PER_ROW;
		int x = INFO_X1 + 18 + (i % SOLDIER_PER_ROW) * SOLDIER_X_SPACING;
		int y = INFO_Y1 + 50 + row * SOLDIER_Y_SPACING;
		int yHp = INFO_Y1 + 7 + row * SOLDIER_Y_SPACING;

		int windowX1 = INFO_X1 + 16;
		int windowX2 = INFO_X1 + 220;
		int windowY1 = INFO_Y1 + 5 + row * 84;	// 5,89
		int windowY2 = windowY1 + 80 - 1 ;

		int unitId;
		int hp;
		int maxHp;
		// ##### begin Gilbert 21/9 ######//
		int combatLevel;
		int skillLevel;
		int loyalty;
		// ##### end Gilbert 21/9 ######//
		int ownSpy;

		if( i==0 )
		{
			if( !overseer_recno )
				continue;

			// overseer
			Unit *overseer = unit_array[overseer_recno];
			unitId = overseer->unit_id;

			hp = (int) overseer->hit_points;
			maxHp = overseer->max_hit_points();
			combatLevel = (int) overseer->combat_level();
			skillLevel = (int) overseer->skill_level();

			if( overseer->rank_id != RANK_GENERAL )
				loyalty = overseer->loyalty;
			else
				loyalty = -1;		// king or other(?)

			ownSpy = overseer->is_own_spy() ? overseer->spy_recno : 0;
		}
		else
		{
			// soldier
			Soldier *soldierPtr = &soldier_array[i-1];
			unitId = soldierPtr->unit_id;

			hp = soldierPtr->hit_points;
			maxHp = soldierPtr->max_hit_points();
			combatLevel = (int) soldierPtr->combat_level();
			skillLevel = (int) soldierPtr->skill_level();

			if( soldierPtr->race_id )
				loyalty = soldierPtr->loyalty;
			else
				loyalty = -1;
			ownSpy = soldierPtr->is_own_spy() ? soldierPtr->spy_recno : 0;
		}

		if( selectSpyMenu && !ownSpy )
			continue;

		int rc = info.draw_unit_icon( x+SOLDIER_X_SPACING/2, y,
			unitId, nation_recno, 
			windowX1, windowY1, windowX2, windowY2, 24 );		// detect left button (8) and right button(16)

		if( !rc )
			continue;

		if( selectSpyMenu == 0 )
		{
			// -------- main menu ---------//

			if( rc & 8 )
			{
				// ----- left click select soldier/overseer -------//

				selected_soldier_id = i;
				return 1;
			}
			else if( rc & 16 && is_own() )
			{
				// ------ right click mobilize solidier/overseer ------//

				if( i == 0 )
				{
					if(remote.is_enable())
					{
						// packet structure : <firm recno>
						short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short));
						shortPtr[0] = firm_recno;
					}
					else
					{
						assign_overseer(0);		// the overseer quits the camp
					}
				}
				else
				{
					// #### begin Gilbert 26/1 #####//
					if( !soldier_array[i-1].is_under_training() )
						mobilize_soldier(i, COMMAND_PLAYER);
					else
						cancel_train_soldier(i, COMMAND_PLAYER);
					// #### end Gilbert 26/1 #####//
				}
				return 2;
			}
		}
		else if( selectSpyMenu == 1 )
		{
			if( rc & 8 && ownSpy )
			{
				selected_soldier_id = i;
				return ownSpy;
			}
		}
	}

	return 0;

	/*
	if( !should_show_info() )
		return 0;

	if( is_own() )
	{
		//------ detect the overseer button -----//
		int rc = mouse.single_click(INFO_X1+6, INFO_Y1+58,
					INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, 2 );

		if( rc==1 )
		{
			selected_soldier_id = 0;
			return 1;
		}
		else if( rc==2 && is_own() )
		{
			if(remote.is_enable())
			{
				// packet structure : <firm recno>
				short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short));
				shortPtr[0] = firm_recno;
			}
			else
			{
				assign_overseer(0);		// the overseer quits the camp
			}
			return 1;
		}
	}

	//------- detect buttons on hiring firm soldiers -------//

	int i, x, y;

	for( i=0 ; i<soldier_count ; i++ )
	{
		x = INFO_X1+6+i%4*50;
		y = pop_disp_y1+1+i/4*29;

		switch( mouse.single_click(x, y, x+27, y+23, 2) )
		{
		case 1:         // left button to select soldier
			selected_soldier_id = i+1;
			return 1;

		case 2:
			if( is_own() )		// only if this is our own firm
			{
				//--- if the town where the unit lives belongs to the nation of this firm ---//

				mobilize_soldier(i+1, COMMAND_PLAYER);
				return 1;
			}
			break;
		}
	}

	return 0;
	*/
}
Esempio n. 30
0
//--------- Begin of function Unit::disp_button ---------//
//
void Unit::disp_button(int dispY1)
{
	int x=INFO_X1;

	//---- if currently in the mode of selecting a unit to succeed the king ----//

	if( nation_array.player_recno &&
		 nation_recno == nation_array.player_recno &&
		 (~nation_array)->king_unit_recno == 0 )
	{
		if( race_id )
			button_succeed_king.paint( x, dispY1, 'A', "SUCCEED" );

		return;
	}

	//------- display aggressive mode button ------//

	button_aggressive_mode.paint( x, dispY1, 'A', aggressive_mode ? (char*)"AGGRESS1" : (char*)"AGGRESS0" );
	x += BUTTON_ACTION_WIDTH;

	//---------- only for human units ---------//

	// Reset all buttons, and activate them as-needed
	button_build.reset();
	button_settle.reset();
	button_promote.reset();
	button_demote.reset();
	button_reward.reset();
	button_return_camp.reset();
	// button_burn.reset();
	// button_assign.reset();

	if( unit_res[unit_id]->unit_class == UNIT_CLASS_HUMAN && race_id )
	{
		int firmId;
		for( firmId=1; firmId<=MAX_FIRM_TYPE ; firmId++ )
		{
			if( firm_res[firmId]->can_build(sprite_recno) )
				break;
		}

		if( firmId<=MAX_FIRM_TYPE &&
			 nation_recno == nation_array.player_recno ) 	// a spy cannot build structure for another nation
		{
			button_build.paint( x, dispY1, 'A', "BUILD" );
			x += BUTTON_ACTION_WIDTH;
		}

		//-------- settle button ----------//

		if( mobile_type==UNIT_LAND && rank_id != RANK_KING )
		{
			button_settle.paint( x, dispY1, 'A', "SETTLE" );
			x += BUTTON_ACTION_WIDTH;
		}

		//-------- promote/demote button --------//


		if( nation_recno == nation_array.player_recno )		// you can't promote your spy in other nation
		{
			if( rank_id==RANK_SOLDIER && skill.skill_id==SKILL_LEADING )
			{
				if(unit_array.selected_count==1)
				{
					button_promote.paint( x, dispY1, 'A', "PROMOTE" );
					x += BUTTON_ACTION_WIDTH;
				}
			}
			else if( rank_id == RANK_GENERAL )
			{
				if( unit_array.selected_count==1 )
				{
					button_demote.paint( x, dispY1, 'A', "DEMOTE"  );
					x += BUTTON_ACTION_WIDTH;
				}
			}
		}

		if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 )
		{
			x  = INFO_X1;
			dispY1 += BUTTON_ACTION_HEIGHT;
		}

		//------------ "reward" button ---------//

		if( nation_array.player_recno && is_own() &&	// Can only reward if the player is still alive. Can reward own spies (even when cloaked).
			 rank_id != RANK_KING )
		{
			button_reward.paint( x, dispY1, 'A', "REWARD" );
			x += BUTTON_ACTION_WIDTH;

			if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 )
			{
				x  = INFO_X1;
				dispY1 += BUTTON_ACTION_HEIGHT;
			}
		}

		/*
		//-------- burn button ----------//

		if( skill.combat_level > BURN_COMBAT_LEVEL && mobile_type==UNIT_LAND  )
		{
			button_burn.paint_text( x, dispY1, "Burn" );
			x += 60;
		}

		//-------- assign to firm button --------//

		if( mobile_type==UNIT_LAND )
		{
			button_assign.paint_text( x, dispY1, "Assign" );
			x+=60;
		}
		*/
	}

	//------ "Return Camp" button -------//

	if( home_camp_firm_recno &&
		 (unit_res[unit_id]->unit_class == UNIT_CLASS_HUMAN || unit_res[unit_id]->unit_class == UNIT_CLASS_WEAPON) &&
		 firm_array[home_camp_firm_recno]->region_id == region_id() )
	{
		button_return_camp.paint( x, dispY1, 'A', "RETCAMP" );
		x += BUTTON_ACTION_WIDTH;

		if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 )
		{
			x  = INFO_X1;
			dispY1 += BUTTON_ACTION_HEIGHT;
		}
	}

	//------- spy notify button ------//

	if( spy_recno && true_nation_recno() == nation_array.player_recno )
	{
		int notifyFlag = spy_array[spy_recno]->notify_cloaked_nation_flag;

		button_spy_notify.paint( x, dispY1, 'A', notifyFlag ? (char*)"SPYNOTI1" : (char*)"SPYNOTI0" );
		x += BUTTON_ACTION_WIDTH;

		if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 )
		{
			x  = INFO_X1;
			dispY1 += BUTTON_ACTION_HEIGHT;
		}

		button_spy_drop_identity.paint( x, dispY1, 'A', "NOSPY" );
	}
	else
	{
		button_spy_notify.reset();
		button_spy_drop_identity.reset();
	}

	//---- display button for changing nation color scheme ----//

	if( sys.debug_session )
		button_change_color.paint_text( INFO_X1, INFO_Y2-20, "Change Nation Color" );
}