Example #1
0
//--------- Begin of function FirmCamp::detect_camp_info ---------//
//
void FirmFort::detect_camp_info()
{
	FirmCamp::detect_camp_info();

	int rc = button_train.detect(0, 0, 1);
	if( rc )
	{
		if( !town_array.is_deleted(active_link_town_recno) 
			&& town_array[active_link_town_recno]->recruitable_pop(1) > 0)
		{
			recruit_soldier( active_link_town_recno, 0, COMMAND_PLAYER );
		}
		else
		{
			short townRecnoArray[MAX_RACE];
			int raceCount = scan_best_recruitable_town(townRecnoArray);
			if( rc == 1 && raceCount == 1 )	// only one race, recruit from that town
			{
				err_when( !townRecnoArray[0] );
				recruit_soldier( townRecnoArray[0], 0, COMMAND_PLAYER );
			}
			else if( rc == 2 || rc == 1 && raceCount > 1 )
			{
				firm_menu_mode = FIRM_MENU_TRAIN;
			}
		}
	//	se_ctrl.immediate_sound("TURN_ON");
		se_ctrl.immediate_sound("ARM-ALRT");
	}

	switch( button_tower_count.detect(0, 0, 1) )
	{
		case 1:		// left click increase
		{
			set_target_archer( -1, COMMAND_PLAYER );
			se_ctrl.immediate_sound("ARM-ALRT");
			break;
		}
		case 2:		// right click decrease
		{
			set_target_archer( -2, COMMAND_PLAYER );
			se_ctrl.immediate_sound("TURN_OFF");
			break;
		}
	}

}
Example #2
0
//--------- Begin of function FirmResearch::detect_research_menu ---------//
//
void FirmResearch::detect_research_menu()
{
	int i;
	for( i = 0; i < added_count; ++i )
	{
		if(button_research_array[i].detect() )
		{
			int techId = button_research_array[i].custom_para.value;
			if( tech_res[techId]->can_research(nation_recno) )
			{
				start_research(techId, COMMAND_PLAYER);
				// ##### begin Gilbert 25/9 ######//
				se_ctrl.immediate_sound("TURN_ON");
				// ##### end Gilbert 25/9 ######//

				research_menu_mode = RESEARCH_MENU_MAIN;
				info.disp();
			}
			else
			{
				// ##### begin Gilbert 25/9 ######//
				se_ctrl.immediate_sound("TURN_OFF");
				// ##### end Gilbert 25/9 ######//
			}
			break;
		}
	}

	//------ detect the cancel button --------//

	if( i >= added_count )		// no research button has been pressed
	{
		if( button_cancel.detect() )
		{
			// ##### begin Gilbert 25/9 ######//
			se_ctrl.immediate_sound("TURN_OFF");
			// ##### end Gilbert 25/9 ######//
			research_menu_mode = RESEARCH_MENU_MAIN;
			info.disp();
		}
	}
}
Example #3
0
//--------- Begin of function FirmHarbor::detect_build_menu ---------//
//
void FirmHarbor::detect_build_menu()
{
	int 	 	 unitId, x=INFO_X1+2, y=INFO_Y1, rc, quitFlag;
	UnitInfo* unitInfo;

	for(int b=0; b<added_count; ++b)
	{
		// ###### begin Gilbert 20/9 #########//
		unitId = button_ship[b].custom_para.value;
		// ###### end Gilbert 20/9 #########//
		unitInfo = unit_res[unitId];

		//------ detect pressing on the small queue count button -------//

		// ####### begin Gilbert 20/9 ########//
		rc = 0;
		if( (rc = button_queue_ship[b].detect(0,0,2)) != 0 )		// both button
		{
			quitFlag = 0;		// don't quit the menu right after pressing the button
		}

		//------ detect pressing on the big button -------//
		else if( (rc = button_ship[b].detect(0,0,2)) != 0 )
		{
			quitFlag = 1;		// quit the menu right after pressing the button
		}
		// ####### end Gilbert 20/9 ########//

		//------- process the action --------//

		if( rc > 0 )
		{
			if( rc==1 )		// left button
			{
				if( remote.is_enable() )
				{
					// packet structure : <firm recno> <unit Id>
					short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_BUILD_SHIP, 2*sizeof(short) );
					shortPtr[0] = firm_recno;
					shortPtr[1] = unitId;
				}
				else
					add_queue(unitId);
				// ##### begin Gilbert 25/9 ######//
				se_ctrl.immediate_sound("TURN_ON");
				// ##### end Gilbert 25/9 ######//
			}
			else 				// right button - remove queue
			{
				if( remote.is_enable() )
				{
					// packet structure : <firm recno> <unit Id>
					short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_BUILD_SHIP, 2*sizeof(short) );
					shortPtr[0] = firm_recno;
					shortPtr[1] = -unitId;
				}
				else
					remove_queue(unitId);

				// ##### begin Gilbert 25/9 ######//
				se_ctrl.immediate_sound("TURN_OFF");
				// ##### end Gilbert 25/9 ######//
			}

			if( quitFlag )
				info.disp();		// info.disp() will call put_info() which will switch mode back to the main menu mode
			else
			// ######## begin Gilbert 20/9 ########//
				// disp_queue_button(y+COUNT_BUTTON_OFFSET_Y, unitId, 1);
				info.update();
			// ######## end Gilbert 20/9 ########//

			return;
		}

		y += BUILD_BUTTON_HEIGHT;
	}

	//------ detect the cancel button --------//

	if( button_cancel.detect() || mouse.any_click(1) )		// press the cancel button or right click
	{
		harbor_menu_mode = HARBOR_MENU_MAIN;
		info.disp();
		// ###### begin Gilbert 26/9 #######//
		se_ctrl.immediate_sound("TURN_OFF");
		// ###### end Gilbert 26/9 #######//
	}
}
Example #4
0
//--------- Begin of function FirmInn::detect_info ---------//
//
void FirmInn::detect_info()
{
//	firm_inn_ptr = this;

	Firm::detect_info();

//	if( detect_basic_info() )
//		return;

	if( !should_show_info() )
		return;

	detect_unit_list();

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

	// since button_hire and button_spy_mobilize share the same place
	// if one is not visible, do not call detect() to avoid incorrect help text displayed

	if( button_hire_visible && button_hire.detect() 
		&& selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		InnUnit *innUnit = inn_unit_array + selected_unit_id - 1;

		se_ctrl.immediate_sound("TAXGRANT");

		se_res.far_sound(center_x, center_y, 1, 'S', 
			unit_res[innUnit->unit_id]->sprite_id,
			"RDY" );
		if(remote.is_enable())
		{
			// packet structure : <firm recno>, <hire Id> <nation no> <spy escape>
			short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_INN_HIRE, 4*sizeof(short));
			shortPtr[0] = firm_recno;
			shortPtr[1] = selected_unit_id;
			shortPtr[2] = nation_recno;
			// ###### begin Gilbert 13/2 #######//
			shortPtr[3] = 0;
			// ###### end Gilbert 13/2 #######//
		}
		else
		{
			hire(selected_unit_id, 0);
		}

		// ------ clear selected_unit_id ------//

		selected_unit_id = 0;
	}
	else if( button_spy_mobilize_visible && button_spy_mobilize.detect() 
		&& selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		se_res.far_sound(center_x, center_y, 1, 'S', 
			unit_res[inn_unit_array[selected_unit_id-1].unit_id]->sprite_id,
			"RDY" );

		err_when( spy_array.is_deleted(inn_unit_array[selected_unit_id-1].spy_recno) );
		Spy *spyPtr = spy_array[inn_unit_array[selected_unit_id-1].spy_recno];
		if( !remote.is_enable() )
		{
			if( spyPtr->mobilize_firm_spy() )
			{
				spyPtr->notify_cloaked_nation_flag = 0;		// reset it so the player can control it
			}
		}
		else
		{
			// packet structure <spy recno>
			short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_LEAVE_FIRM, sizeof(short) );
			*shortPtr = spyPtr->spy_recno;
		}

		// ------ clear selected_unit_id ------//

		selected_unit_id = 0;
	}

	// -------- detect buy item ------//

	if( selected_unit_id > 0 && selected_unit_id <= inn_unit_count )
	{
		InnUnit *innUnit = inn_unit_array + selected_unit_id - 1;

		if( button_buy_item.detect() )
		{
			se_ctrl.immediate_sound("TAXGRANT");

			if( !remote.is_enable() )
			{
				buy_item( selected_unit_id, 0 );
			}
			else
			{
				short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_INN_BUY_ITEM, 2*sizeof(short));
				// packet structure : <firm recno>, <inn unid id>
				shortPtr[0] = firm_recno;
				shortPtr[1] = selected_unit_id;
			}
			se_ctrl.immediate_sound("TURN_ON");
		}
		else if( innUnit->item.id )
		{
			help.set_custom_help( button_buy_item.x1, button_buy_item.y1, 
				button_buy_item.x2, button_buy_item.y2, 
				text_firm.str_buy_item_help( &innUnit->item ),
				innUnit->item.item_desc() );
		}
	}
}