Beispiel #1
0
//--------- Begin of function FirmResearch::disp_research_menu ---------//
//
void FirmResearch::disp_research_menu(int refreshFlag)
{
	if( refreshFlag != INFO_REPAINT )
		return;

	int techId, y=INFO_Y1;
	added_count=0;

	for( techId=1 ; techId<=tech_res.tech_count ; techId++ )
	{
		if( !tech_res[techId]->can_research(nation_recno) )
			continue;

		if( added_count < MAX_RESEARCH_OPTION )
		{
			button_research_array[added_count].paint(INFO_X1, y, INFO_X2, y+RESEARCH_OPTION_HEIGHT-2,
				i_disp_research_button, ButtonCustomPara(this, techId) );
			added_count++;
			y += RESEARCH_OPTION_HEIGHT;
		}
	}

	// ###### begin Gilbert 16/8 ######//
	// button_cancel.paint(INFO_X1, y, "CANCEL1", "CANCEL1D" );
	button_cancel.paint(INFO_X1, y, INFO_X2, y+RESEARCH_OPTION_HEIGHT*3/4,
		ButtonCustom::disp_text_button_func, ButtonCustomPara((void*)"Cancel",0) );
	// ###### end Gilbert 16/8 ######//
}
Beispiel #2
0
void FirmIncubator::disp_build_menu(int refreshFlag)
{
	int x1 = INFO_X1+13;
	int y1 = INFO_Y1+5;

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

	added_count = 0;
	int unitId, x=INFO_X1+2, y=INFO_Y1;
	UnitInfo* unitInfo;

	for( int i = 0; i < MAX_INCUBATE_TYPE; ++i )
	{
		unitId = incubate_unit_id[i];
		unitInfo = unit_res[unitId];

		if( refreshFlag == INFO_REPAINT )
		{
			button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, 
				i_disp_queue_button, ButtonCustomPara(this, unitId) );
			button_weapon[added_count].create(x1, y1+35, x1+67, y1+114,
				i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) );
		}

		button_weapon[added_count].visible_flag 
			= button_queue_weapon[added_count].visible_flag 
			= unitInfo->get_nation_tech_level(nation_recno) > 0;

		button_weapon[added_count].paint();
		button_queue_weapon[added_count].paint();

		added_count++;

		x1 += 68;
		if (added_count == 3)
		{
			x1 = INFO_X1+13;
			y1 = INFO_Y1+121;
		}
	}

	if( refreshFlag==INFO_REPAINT )
	{
		// ##### begin Gilbert 8/2 ######//
		int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3;
		int y1 = INFO_Y1 +281;
		// button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" );
		button_cancel.create( x1, y1, 'A', "CANCEL" );
		// ##### end Gilbert 8/2 ######//
	}
	button_cancel.paint();
}
Beispiel #3
0
//--------- Begin of function FirmHarbor::disp_build_menu ---------//
//
void FirmHarbor::disp_build_menu(int refreshFlag)
{
	// ###### begin Gilbert 20/9 ######//
	if( refreshFlag == INFO_UPDATE )
	{
		for( int b=0; b<added_count; ++b )
		{
			button_ship[b].paint(-1, 0);
			// button_queue_ship[b] is called by button_ship[b].paint();
		}
	}
	else if( refreshFlag == INFO_REPAINT )
	{
		added_count=0;
		int 	 unitId, x=INFO_X1, y=INFO_Y1;
		for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ )
		{
			if( unit_res[unitId]->unit_class == UNIT_CLASS_SHIP )
			{
				if( unit_res[unitId]->get_nation_tech_level(nation_recno) > 0 )
				{
					// disp_build_button( y, unitId, 1);
					button_queue_ship[added_count].create(x+COUNT_BUTTON_OFFSET_X, y+COUNT_BUTTON_OFFSET_Y,
						x+COUNT_BUTTON_OFFSET_X+COUNT_BUTTON_WIDTH-1, y+COUNT_BUTTON_OFFSET_Y+COUNT_BUTTON_HEIGHT-1,
						i_disp_queue_button, ButtonCustomPara(this, unitId) );
					button_ship[added_count].paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT-1,
						i_disp_build_button, ButtonCustomPara(&button_queue_ship[added_count], unitId) );

					err_when(added_count >= MAX_SHIP_TYPE);
					// button_unit_id[added_count++] = unitId;
					added_count++;
					y += BUILD_BUTTON_HEIGHT;
				}
			}
		}
		button_cancel.paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT*3/4,
			ButtonCustom::disp_text_button_func, ButtonCustomPara((void*)"Done",0) );
	}
	// ###### end Gilbert 20/9 ######//
}
Beispiel #4
0
//--------- Begin of function SpyArray::disp_view_secret_menu ---------//
//
void SpyArray::disp_view_secret_menu(int spyRecno, int refreshFlag)
{
//	vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") );
	vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("MISSBASE") );
	//------------------------------------//

//	vga.d3_panel_up( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+42 );
//	font_san.put_paragraph( INFO_X1+7, INFO_Y1+5, INFO_X2-7, INFO_Y2-5,
//									"Steal which type of secrets?" );
	font_whbl.put_paragraph( INFO_X1+18, INFO_Y1+12, INFO_X2-14, INFO_Y1+72, 
		text_firm.str_spy_steal_info() ); // "Which category of information do you wish to view?" );

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

	int  y=INFO_Y1+45;

	err_when( spy_array.is_deleted(spyRecno) );

	Spy* spyPtr = spy_array[spyRecno];

	int i;
	for( i=0 ; i<SECRET_REPORT_COUNT ; i++ )
	{
//		button_secret_report_array[i].create( INFO_X1+18, y, INFO_X2-10, y+21, 
//			disp_text_button, ButtonCustomPara( secret_report_str_array[i], i), 0 );
		button_secret_report_array[i].create( INFO_X1+18, y, INFO_X2-10, y+21, 
			disp_text_button, ButtonCustomPara( text_reports.str_report_mode(i+1), i), 0 );

		button_secret_report_array[i].enable_flag = 
			tech_res[TECH_INFO_THEFT]->get_nation_tech_level(spyPtr->true_nation_recno) 
			&& spyPtr->spy_skill >= secret_view_skill_array[i];

		y+=23;
	}

	// push the first enabled button
	for( i = 0; i < SECRET_REPORT_COUNT; i++ )
	{
		if( button_secret_report_array[i].enable_flag )
		{
			button_secret_report_array.push(i, 0);
			break;
		}
	}
	button_secret_report_array.paint();

	button_view_secret.create( INFO_X1+13, INFO_Y1+281, 'A', "VSECRET" );
	button_secret_report_cancel.create( INFO_X1+13+3*BUTTON_DISTANCE, INFO_Y1+281, 'A', "PREVMENU" );
	button_view_secret.enable_flag = button_secret_report_array[button_secret_report_array()].enable_flag;
	button_view_secret.paint();
	button_secret_report_cancel.paint();
}
Beispiel #5
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);
}
Beispiel #6
0
//--------- Begin of function Unit::disp_build_menu ---------//
//
void Unit::disp_build_menu(int refreshFlag)
{
	//---------- paint buttons ------------//

	if( refreshFlag == INFO_REPAINT )
	{
		// ####### begin Gilbert 3/10 ########//
		int firmId, x=INFO_X1, y=INFO_Y1, addedCount=0;
		String str;

		for( int i = 0; i < MAX_FIRM_TYPE; ++i )
		{
			firmId = build_firm_button_order[i];

			//---- check if the unit is the right race to build this firm ----//

			button_build_flag[i] = 0;

			if( firm_res[firmId]->can_build(sprite_recno) )
			{
				// button_build_array[firmId-1].paint( x, y, str, "F-DOWN");

				button_build_array[i].paint( x, y, x+99-1, y+60-1,
					disp_firm_button, ButtonCustomPara( game.get_color_remap_table(nation_recno,0) ,
					(unit_id << 16) + (race_id << 8) + firmId) );

				button_build_flag[i] = 1;
				addedCount++;

				if( addedCount & 1)
				{
					// old number, increase in x
					x += 102;
				}
				else
				{
					// even number, increase in y, reset x
					x -= 102;
					y += 63;
				}
			}
		}
		// ####### end Gilbert 3/10 ########//

		button_cancel.paint( x, y, 'A', "CANCEL" );
	}
}
Beispiel #7
0
//--------- Begin of function FirmResearch::disp_research_class_menu ---------//
//
void FirmResearch::disp_research_class_menu(int refreshFlag)
{
	int classTechId;
	int x=INFO_X1+23, y=INFO_Y1+13;
	int x2 = INFO_X1 +13;
	int y2 = INFO_Y1 +281;
	// String str;

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

	// ##### patch begin Gilbert 28/9 ########//
	//str = "Select a technology class to research";
	// font_snds.center_put( INFO_X1+7, INFO_Y1+13, INFO_X2, INFO_Y1+28, str );
	// font_snds.center_put( INFO_X1+7, INFO_Y1+13, INFO_X2, INFO_Y1+28, 
	//		text_firm.str_select_tech_class() );
	font_snds.put_paragraph( x, y, INFO_X2-6, INFO_Y1+52,
		text_firm.str_select_tech_class() );
	y = font_snds.next_text_y + 2;

	for( classTechId=FIRST_TECH_CLASS_RESEARCH ; classTechId<=LAST_TECH_CLASS_RESEARCH ; classTechId++ )
	{
		int b = classTechId-FIRST_TECH_CLASS_RESEARCH;
		if( tech_res.tech_class(classTechId)->researchable_tech_count(nation_array.player_recno) ==0 )
			continue;

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

//		button_research_class_array[b].create( x, y+(b+1)*20, x +187, y+(b+1)*20+17,
//			i_disp_research_class_button, ButtonCustomPara( this, classTechId) );
		button_research_class_array[b].create( x, y+b*20, x +187, y+b*20+17,
			i_disp_research_class_button, ButtonCustomPara( this, classTechId) );

		button_research_class_array[classTechId-1].paint();
	}
	// ##### patch end Gilbert 28/9 ########//
	
	x2 +=  3 * BUTTON_DISTANCE;
	button_cancel.create( x2, y2, 'A', "CANCEL" );
	button_cancel.paint();
}
Beispiel #8
0
// ----- begin of function ScenarioEditor::disp_monster_main ------//
//
void ScenarioEditor::disp_monster_main(int refreshFlag)
{
	String str;

	// unit or structure button group

	button_unit_or_struct[0].create_text( INFO_X1+15, INFO_Y1+5, INFO_X1+110, INFO_Y1+25,
		text_editor.str_unit(), 0 ); // "Unit", 0 );
	button_unit_or_struct[1].create_text( INFO_X1+115, INFO_Y1+5, INFO_X1+210, INFO_Y1+25,
		text_editor.str_structure(), 0 ); //"Structure", 0 );

	font_zoom.put( INFO_X1+10, INFO_Y2-28, text_editor.str_double_left_add(), 0, INFO_X2-5);
	font_zoom.put( INFO_X1+10, INFO_Y2-14, text_editor.str_double_right_del(), 0, INFO_X2-5);

	button_unit_or_struct.paint(unit_or_struct);

	{
		// player number button group

		for( int nationRecno = 0; nationRecno <= MAX_NATION; ++nationRecno )
		{
			button_player_recno[nationRecno].create( INFO_X1+16+nationRecno*25, INFO_Y1+30,
				INFO_X1+16+(nationRecno+1)*25-2, INFO_Y1+57, i_disp_nation_button,
				ButtonCustomPara(NULL, nationRecno), 0 );
			button_player_recno[nationRecno].visible_flag = 
				button_player_recno[nationRecno].enable_flag =
				!nationRecno || !nation_array.is_deleted(nationRecno);		// nation 0 always enable
		}
	}

	if( brush_player_recno && nation_array.is_deleted(brush_player_recno) )
	{
		brush_player_recno = 0;			// set to nation 0 if that nation is deleted
	}
	button_player_recno.paint(brush_player_recno);

	// display browser

	collect_monster_unit(monster_race_filter);
	collect_monster_firm(monster_race_filter);

	// display browser 

	if( !unit_or_struct )
	{
		// init unit browser
		vbrowse_unit_id.init( INFO_X1+5, INFO_Y1+80, INFO_X2-5, INFO_Y2-30,
			-1, 20, monster_unit_id_count, disp_monster_unit_id );
		vbrowse_unit_id.open(monster_unit_id_browse_recno);
		browse_unit_width = vbrowse_unit_id.ix2 - vbrowse_unit_id.ix1 + 1;
		vbrowse_unit_id.paint();
		vbrowse_unit_id.refresh();
	}
	else
	{
		// init firm browser
		vbrowse_firm_build.init( INFO_X1+5, INFO_Y1+80, INFO_X2-5, INFO_Y2-30,
			-1, 20, monster_firm_group_count, disp_monster_firm_group );
		vbrowse_firm_build.open(monster_firm_group_browse_recno);
		browse_firm_width = vbrowse_firm_build.ix2 - vbrowse_firm_build.ix1 + 1;
		vbrowse_firm_build.paint();
		vbrowse_firm_build.refresh();
	}

	// init race filter button

//	int raceLength = ((INFO_X2-4) - (INFO_X1+5) + 1) / (1+MAX_MONSTER_TYPE);
//	char raceAbbr[2] = " ";
//	for( int r = 0; r <= MAX_MONSTER_TYPE; ++r )
//	{
//		if( r > 0 ) 
//			raceAbbr[0] = monster_res[r]->name[0];
//		button_race_group[r].create_text( INFO_X1+5+r*raceLength, INFO_Y1+58,
//			INFO_X1+5+(r+1)*raceLength-1, INFO_Y1+78, raceAbbr );
//	}
	spinner_race_group.create( INFO_X1+80, INFO_Y1+58, INFO_X1+210, INFO_Y1+78, 200,//146,
		0, 1+MAX_MONSTER_TYPE, i_disp_race_spinner, -monster_race_filter );
	// button_race_group.paint(-monster_race_filter);
	spinner_race_group.paint(-monster_race_filter);

}
Beispiel #9
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" );
}
Beispiel #10
0
//--------- Begin of function UnitCaravan::disp_stop ---------//
//
void UnitCaravan::disp_stop(int dispY1, int refreshFlag)
{
	int y = INFO_Y1 + 94;

	int i, j;

	for( i = 0; i < MAX_STOP_FOR_CARAVAN; ++i, y += 70 )
	{
		TradeStop *tradeStop = stop_array+i;

		button_go_stop[i].create( INFO_X1+17, y+2, INFO_X1+167, y+35, i_button_go_stop,
			ButtonCustomPara( this, tradeStop->firm_recno ) );
		button_go_stop[i].set_help_code( "CGOSTOP" );

		button_set_stop[i].create( INFO_X1+169, y+2, INFO_X1+215, y+20, i_button_set_stop,
			ButtonCustomPara( NULL, 0 ) );
		button_set_stop[i].set_help_code( "CSETSTOP" );

		button_cancel_stop[i].create( INFO_X1+169, y+21, INFO_X1+215, y+39, i_button_cancel_stop,
			ButtonCustomPara( NULL, 0 ) );
		button_cancel_stop[i].set_help_code( "CDELSTOP" );

		button_reset_stop[i].create( INFO_X1+169, y+42, INFO_X1+215, y+60, i_button_reset_stop,
			ButtonCustomPara( NULL, 0 ) );
		button_reset_stop[i].set_help_code( "CCLRSEL" );

		for( j = 0; j < MAX_GOODS_SELECT_BUTTON; ++j )
			button_select_array[i][j].create( INFO_X1+17+carv_gdd_x[j], y+34, INFO_X1+17+carv_gdd_x[j+1]-1, y+61,
			i_disp_caravan_select_button, ButtonCustomPara( NULL, j ), 0 );

		button_go_stop[i].custom_para = ButtonCustomPara( this, tradeStop->firm_recno );
		button_go_stop[i].paint();
		button_set_stop[i].paint();
		button_cancel_stop[i].paint();
		button_reset_stop[i].paint();

		Firm *firmPtr = NULL;
		if( !firm_array.is_deleted(tradeStop->firm_recno))
			firmPtr = firm_array[tradeStop->firm_recno];

		for( j = 0; j < MAX_GOODS_SELECT_BUTTON; ++j )
		{
			// display quantity on the firm

			int rawId = j+FIRST_GOODS_SELECT_BUTTON-PICK_UP_RAW_FIRST+1;
			if( rawId < 1 || rawId > MAX_RAW )
				rawId = 0;
			int productId = j+FIRST_GOODS_SELECT_BUTTON-PICK_UP_PRODUCT_FIRST+1;
			if( productId < 1 || productId > MAX_PRODUCT )
				productId = 0;

			int stock = -1;

			if( firmPtr )
			{
				if( firmPtr->cast_to_FirmMarket() )
				{
					MarketGoods *marketGoods;
					if( rawId )
					{
						marketGoods = firmPtr->cast_to_FirmMarket()->market_raw_array(rawId);
						err_when( marketGoods && marketGoods->raw_id != rawId );
					}
					else if( productId )
					{
						marketGoods = firmPtr->cast_to_FirmMarket()->market_product_array(productId);
						err_when( marketGoods && marketGoods->product_raw_id != productId );
					}
					else
					{
						err_here();
						marketGoods = NULL;
					}

					if( marketGoods )
						stock = (int) marketGoods->stock_qty;
				}
				else if( firmPtr->cast_to_FirmMine() )
				{
					if( rawId && firmPtr->cast_to_FirmMine()->raw_id == rawId )
					{
						stock = (int) firmPtr->cast_to_FirmMine()->stock_qty;
					}
				}
				else if( firmPtr->cast_to_FirmFactory() )
				{
					if( productId && firmPtr->cast_to_FirmFactory()->product_raw_id == productId )
					{
						stock = (int) firmPtr->cast_to_FirmFactory()->stock_qty;
					}
					//else if( rawId && firmPtr->cast_to_FirmFactory()->product_raw_id == rawId )
					//{
					// stock = (int) firmPtr->cast_to_FirmFactory()->raw_stock_qty;
					//}
				}
			}

			if( stock >= 0 )
			{
				// display button

				button_select_array[i][j].enable_flag = 1;
				button_select_array[i][j].paint( tradeStop->pick_up_array[j] );
			}
			else
			{
				button_select_array[i][j].enable_flag = 0;
				button_select_array[i][j].pushed_flag = tradeStop->pick_up_array[j];
			}
		}
	}
}
Beispiel #11
0
void OptionMenu::enter(char untilExitFlag)
{
	if( is_active() )
		return;

	int bx = (VGA_WIDTH - PAGE_WIDTH) / 2;
	int by = (VGA_HEIGHT - PAGE_HEIGHT) / 2;

	int i;
	refresh_flag = IGOPTION_ALL;
	update_flag = 0;
	// active_flag = 1;
	set_active();

	info.save_game_scr();

	Config& tempConfig = config;
	old_config = config;

	// -------- initialize sound effect volume --------//
//	se_vol_slide.init_slide(264, 123, 420, 123+SLIDE_BUTTON_HEIGHT-1, 
//		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	se_vol_slide.init_slide(bx+140, by+118, bx+140+10*SLIDE_BUTTON_WIDTH+9*2, by+118+SLIDE_BUTTON_HEIGHT-1, 
		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	se_vol_slide.set(0, 100, tempConfig.sound_effect_flag ? tempConfig.sound_effect_volume : 0);

	// -------- initialize music volume --------//
//	music_vol_slide.init_slide(566, 123, 722, 123+SLIDE_BUTTON_HEIGHT-1, 
//		SLIDE_BUTTON_WIDTH, disp_slide_bar);
//	music_vol_slide.init_slide(bx+140, by+173, bx+140+10*SLIDE_BUTTON_WIDTH+9*2, by+173+SLIDE_BUTTON_HEIGHT-1, 
//		SLIDE_BUTTON_WIDTH, disp_slide_bar);
//	music_vol_slide.set(0, 100, tempConfig.music_flag ? tempConfig.wav_music_volume : 0);

	int cx = bx + 124;
	int cy = by + 173;
	for( i = 0; i < 2; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_no_yes(i)) + 9;
		music_group[i].create(cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_no_yes(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// -------- initialize frame speed volume --------//
//	frame_speed_slide.init_slide(196, 410, 352, 410+SLIDE_BUTTON_HEIGHT-1, 
//		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	frame_speed_slide.init_slide(bx+140, by+338, bx+140+10*SLIDE_BUTTON_WIDTH+9*2, by+338+SLIDE_BUTTON_HEIGHT-1, 
		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	frame_speed_slide.set(0, 31, tempConfig.frame_speed <= 30 ? tempConfig.frame_speed: 31);
	// use frame 31 to represent full speed (i.e. 99)

	// -------- initialize scroll speed volume --------//
//	scroll_speed_slide.init_slide(196, 454, 352, 454+SLIDE_BUTTON_HEIGHT-1, 
//		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	scroll_speed_slide.init_slide(bx+140, by+398, bx+140+10*SLIDE_BUTTON_WIDTH+9*2, by+398+SLIDE_BUTTON_HEIGHT-1, 
		SLIDE_BUTTON_WIDTH, disp_slide_bar);
	scroll_speed_slide.set(0, 10, tempConfig.scroll_speed );

	// --------- initialize race buttons ---------- //

//	for( i = 0; i < MAX_RACE; ++i )
//	{
//		race_button[i].create(181+i*BASIC_OPTION_X_SPACE, 162,
//			181+(i+1)*BASIC_OPTION_X_SPACE-1, 162+BASIC_OPTION_HEIGHT-1,
//			disp_virtual_button, ButtonCustomPara(NULL, race_table[i]));
//	}

	// --------- initialize help button group ---------- //

	cx = bx + 124;
	cy = by + 226;
	for( i = 0; i < 3; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_help_options(i)) + 9;
		help_group[i].create(cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_help_options(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// --------- initialize news button group ---------- //

	cx = bx + 124;
	cy = by + 281;
	for( i = 0; i < 2; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_news_options(i)) + 9;
		news_group[i].create(cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_news_options(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// --------- initialize report button group ---------- //

	cx = bx + 417;
	cy = by + 116;
	for( i = 0; i < 2; ++i )
	{
		int cx2 = cx + font_thin_black.text_width( text_game_menu.str_report_options(i) ) + 9;
		report_group[i].create( cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_report_options(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// --------- initialize show icon button group ---------- //

	cx = bx + 417;
	cy = by + 181;
	for( i = 0; i < 2; ++i )
	{
		int cx2 = cx + font_thin_black.text_width( text_game_menu.str_show_icon_options(i) ) + 9;
		show_icon_group[i].create( cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_show_icon_options(i), i), 0, 0);
		cx = cx2 + 10;
	}

	// --------- initialize show path button group ---------- //

	cx = bx + 417;
	cy = by + 256;
	for( i = 0; i < 4; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_show_path_options(i)) + 9;
		show_path_group[i].create( cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_show_path_options(i), i), 0, 0);
		if( i & 1 )
		{
			cx = bx+417;
			cy += font_thin_black.max_font_height + 3;
		}
		else
		{
			// ####### begin Gilbert 7/6 ########//
			cx = cx2 + 20;
			// ####### end Gilbert 7/6 ########//
		}
	}

	// --------- initialize inside info button group ----------//

	cx = bx + 417;
	cy = by + 331;
	for( i = 0; i < 3; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_inside_info_options(i)) + 9;
		inside_info_group[i].create( cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara( text_game_menu.str_inside_info_options(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// -------- initialize scroll method group -------//

	cx = bx + 417;
	cy = by + 391;
	for( i = 0; i < 2; ++i )
	{
		int cx2 = cx + font_thin_black.text_width(text_game_menu.str_scroll_method_options(i)) + 9;
		scroll_method_group[i].create( cx, cy, cx2, cy + font_thin_black.max_font_height+3,
			disp_text_button, ButtonCustomPara(text_game_menu.str_scroll_method_options(i), i), 0, 0);
		cx = cx2 + 5;
	}

	// --------- other buttons --------//
	start_button.create_text( bx+BUTTON2_X1, by+BUTTON2_Y1, bx+BUTTON2_X2, by+BUTTON2_Y2, text_game_menu.str_return() );
	cancel_button.create_text( bx+BUTTON4_X1, by+BUTTON4_Y1, bx+BUTTON4_X2, by+BUTTON4_Y2, text_game_menu.str_cancel() );

	mouse_cursor.set_icon(CURSOR_NORMAL);
	mouse_cursor.set_frame(0);

   power.win_opened = 1;

	if( untilExitFlag )
	{
		while( is_active() )
		{
			sys.yield();
			mouse.get_event();
			if( config.music_flag )
			{
				if( !music.is_playing() )
					music.play( music.random_bgm_track(music.song_id), sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
			}
			else
				music.stop();

			disp();
			sys.blt_virtual_buf();
			music.yield();
			detect();
		}
	}
}
Beispiel #12
0
// ------- Begin of function Game::select_campaign_menu -----//
//
// select which campaign to play, set config as well
//
// return 0=cancel, >0 for campaign selected
//
int Game::select_campaign_menu()
{
	// static char *campaignList[] = { "Occidental Heroes" };	//, "Human Learning Campaign", "Fryhtan Campaign", "Fryhtan Learning Campaign", };
	static const char *campaignList[] = 
	{
		text_campaign.str_campaign_name(CAMPAIGN_EAST_WEST),
	};
	int campaignCount = sizeof(campaignList) / sizeof(campaignList[0]);

	Config tempConfig = config;

	// ------ adjust config ------//

	tempConfig.default_campaign_setting();

	if( tempConfig.race_id < 0 )		// human race only
		tempConfig.race_id = 1;

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

	int optionMode;
	if (campaignCount == 1)
		optionMode = OPTION_BASIC;
	else
		optionMode = OPTION_CAMPAIGN;

	TempGameSet tempGameSet(1);		// game_set.open_set
	TempUnitRes tempUnitRes;			// unit_res.init
	TempRaceRes tempRaceRes;			// race_res.init

	// take name from profile

	if( player_profile.is_registered() )
	{
		strcpy( tempConfig.player_name, player_profile.player_name );
	}

	//--------- initialize variable ---------//

	int i;
	int w, h;
	int cx, cy;
	String str;
	long refreshFlag = SGOPTION_ALL;
	int retFlag = 0;

	// -------- generate palette ------//

	short colorRemapTable[0x100];
	{
		str = DIR_IMAGE;
		str += "CHOOSE.COL";

		File palFile;
		palFile.file_open(str);
		ColorTable colorTable;

		BYTE palBuf[0x100][3];
		palFile.file_seek(8);     				// bypass the header info
		palFile.file_read(palBuf, sizeof(palBuf));
		palFile.file_close();

		// ------- palette description -------------//

		PalDesc palBufDesc( palBuf, 3, 0x100, 8 );

		//-------- create color remap table ---------//

		colorTable.generate_table_fast( 0, palBufDesc, ColorTable::bright_func );
		memcpy( colorRemapTable, colorTable.get_table(0), sizeof(colorRemapTable) );
	}

	// ------ initialize human / fryhtan button ------//

	ButtonCustomGroup campaignGroup(campaignCount);

	for( i = 0; i < campaignCount; ++i )
	{
		// divide 125, 680 into campaignCount partitions
		// cx is the center of each parition
		// campaignCount = 1 , (1:1)
		// campaignCount = 2 , (3:1), (1:3)
		// campaignCount = 3 , (5:1), (3:3), (1:5)
		//cx = ( 125*((campaignCount-i)*2-1) + 680*(i*2+1)) / (campaignCount*2);
		//cy = 136;
		cx = 390;
		cy = ( 136 * ((campaignCount-i)*2-1) + 280*(i*2+1)) / (campaignCount*2);

		w = font_thin_black.text_width( campaignList[i] );
		h = font_thin_black.text_height();
		campaignGroup[i].create( cx-w/2-10, cy-h/2-5, cx+w/2+10, cy+h/2+5,
		i_disp_text_button, ButtonCustomPara( campaignList[i], 0 ), 0 );
	}

	// -------- initialize player name field ------//

	GetA playerNameField;
	playerNameField.init( 364, 89, 688, tempConfig.player_name,
		tempConfig.PLAYER_NAME_LEN, &font_bold_black, 0, 1 );

	// -------- initialize human group ---------//

	ButtonCustomGroup raceGroup(MAX_RACE);

	err_when( !race_res.init_flag );
	cx = 210;
	cy = 160;
	const int raceGroupYSpacing = 22;
	for( i = 0; i < MAX_RACE; ++i, (cy += raceGroupYSpacing) )
	{
		w = font_thin_black.text_width( race_res[i+1]->name );
		h = raceGroupYSpacing;
		raceGroup[i].create( cx-w/2-5, cy-h/2, cx+w/2+5, cy+h/2,
			i_disp_race_button, ButtonCustomPara( NULL, i+1 ), 0 );
	}

	// ------- create color group --------//

	ButtonCustomGroup colorGroup(MAX_COLOR_SCHEME);
	const int colorButtonFrameX = 382;
	const int colorButtonFrameY = 155;
	cx = 391;
	cy = 162;
	const int colorButtonWidth = 29;
	const int colorButtonHeight = 30;
	for(i = 0; i < MAX_COLOR_SCHEME; ++i, (cx+=colorButtonWidth) )
	{
		colorGroup[i].create( cx, cy, cx+colorButtonWidth-1, cy+colorButtonHeight-1, 
			i_disp_color_button, ButtonCustomPara(NULL, i+1), 0 );
	}

	// ---------- initialize campaign difficulty_level button group -------//

	ButtonCustomGroup campDiffGroup(5);
	char campDiffButtonStr[5][10];
	cx = 410;
	cy = 331;
	for( i = 0; i < 5; ++i )
	{
		strcpy( campDiffButtonStr[i], misc.roman_number(i+1) );

		w = font_thin_black.text_width(campDiffButtonStr[i]);
		h = font_thin_black.text_height();
		campDiffGroup[i].create( cx, cy, cx+w+10, cy+h+10,
			i_disp_text_button, ButtonCustomPara(campDiffButtonStr[i], i+1), 0);
		cx += w + 20;
	}

	// --------- initialize building size --------//

	ButtonCustomGroup buildingSizeGroup(2);
	const char *buildingSizeButtonStr[2] =
	{
		text_game_menu.str_building_set(1),
		text_game_menu.str_building_set(2),
	};
	cx = 370+63;
	cy = 386;
	for( i = 0; i < buildingSizeGroup.button_num; ++i )
	{
		w = font_thin_black.text_width(buildingSizeButtonStr[i]);
		h = font_thin_black.text_height();
		buildingSizeGroup[i].create( cx, cy, cx+w+10, cy+h+10, 
			i_disp_text_button, ButtonCustomPara(buildingSizeButtonStr[i], i+1), 0 );
		cx += w + 12;
	}

	// ------ initialize fog of war ------//

	const int option3X = 320;
	ButtonCustomGroup fogGroup(2);
	cx = option3X;
	cy = 173; // cy = 143;
	w = font_thin_black.text_width( text_game_menu.str_off_on(0) );	// Off
	h = font_thin_black.text_height();
	fogGroup[0].create( cx, cy, cx+w+10, cy+h+10,
		i_disp_text_button, ButtonCustomPara( text_game_menu.str_off_on(0), 0), 0 );		// Off
	cx += w+20;
	w = font_thin_black.text_width( text_game_menu.str_off_on(1) );	// On
	fogGroup[1].create( cx, cy, cx+w+10, cy+h+10,
		i_disp_text_button, ButtonCustomPara( text_game_menu.str_off_on(1), 1), 0 );	// On

/*
	// --------- initialize spy methodology-------//

	char *spyMethodStr[2] = { "Must  Research", "All  Available" };

	ButtonCustomGroup spyMethodGroup(2);
	cx = option3X-10;
	cy = 348;
	for( i = 0; i < 2; ++i )
	{
		w = font_thin_black.text_width( spyMethodStr[i] );
		h = font_thin_black.text_height();
		spyMethodGroup[i].create( cx, cy, cx+w+10, cy+h+10,
			i_disp_text_button, ButtonCustomPara( spyMethodStr[i], i), 0 );
		cx += w+20;
	}
*/
	// --------- initialize random_event_frequency button group --------//

	const char *randomEventStr[4] =
	{
		text_game_menu.str_never_to_frequent(OPTION_NONE),
		text_game_menu.str_never_to_frequent(OPTION_LOW),
		text_game_menu.str_never_to_frequent(OPTION_MODERATE),
		text_game_menu.str_never_to_frequent(OPTION_HIGH),
	};

	ButtonCustomGroup randomEventGroup(4);
	cx = option3X;
	cy = 314; // cy = 384;
	for( i = 0; i < 4; ++i )
	{
		w = font_thin_black.text_width( randomEventStr[i] );
		h = font_thin_black.text_height();
		randomEventGroup[i].create(cx, cy, cx+w+10, cy+h+6,
			i_disp_text_button, ButtonCustomPara(randomEventStr[i], i), 0);
		if( (i+1) % 2 == 0 )
		{
			// line feed
			cx = option3X;
			cy += 26;
		}
		else
		{
			cx += 144;
		}
	}


	// ------- loop ---------//

	{
		VgaFrontLock vgaLock;

		while(1)
		{
#if 0  // FIXME
			MSG msg;
			if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE))
			{
				if (!GetMessage( &msg, NULL, 0, 0))
				{
					sys.signal_exit_flag = 1;
					// BUGHERE : vga_front is unlocked
					return 0;
				}
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				continue;
			}
			else if( sys.paused_flag || !sys.active_flag )
			{
				WaitMessage();
				continue;
			}
#endif

			if( sys.need_redraw_flag )
			{
				refreshFlag = SGOPTION_ALL;
				sys.need_redraw_flag = 0;
			}

			VgaFrontReLock vgaReLock;

			sys.yield();
			mouse.get_event();
			if( config.music_flag )
			{
				if( !music.is_playing(3) )
					music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
			}
			else
			{
				music.stop();
			}

			// -------- display ----------//

			if( refreshFlag )
			{
				if( optionMode == OPTION_CAMPAIGN )
				{
					if( refreshFlag & SGOPTION_PAGE )
					{
						vga.use_back();
						vga_util.disp_image_file("CHOOSE");

						// ------- display option Mode ------//

						for( i = OPTION_CAMPAIGN; i <= OPTION_ADVANCED; ++i )
						{
							// red font for selected
							Font *fontPtr = (i == optionMode ? &font_bold_red : &font_bold_black );

							fontPtr->center_put(OPTION_SWITCH_X1, OPTION_SWITCH_Y1+OPTION_SWITCH_Y_SPACING*i,
								OPTION_SWITCH_X2, OPTION_SWITCH_Y2+OPTION_SWITCH_Y_SPACING*i, 
								misc.roman_number(i+1) );
						}

						// ----- display start, cancel button ------//

						font_thin_black.center_put( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2,
							text_game_menu.str_start() );
						font_thin_black.center_put( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2,
							text_game_menu.str_cancel() );

						vga.use_front();
						vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
					}

					if( refreshFlag & SGOPTION_CAMPAIGN )
						campaignGroup.paint();
				}

				// ------- display basic option ---------//

				if( optionMode == OPTION_BASIC )
				{
					if( refreshFlag & SGOPTION_PAGE )
					{
						vga.use_back();
						vga_util.disp_image_file("CHOOSE");
						// BUGHERE : option menu column and finger

						font_bold_black.right_put( playerNameField.x, playerNameField.y,
							text_game_menu.str_king_name() );
						font_bold_black.center_put( 116, 126, 303, 146,	text_game_menu.str_nationality() );
						font_bold_black.center_put( 382, 129, 600, 149, text_game_menu.str_color() );
						font_bold_black.center_put( 341, 305, 654, 324, text_game_menu.str_difficulty_level() );
						font_bold_black.center_put( 341, 365, 660, 384, text_game_menu.str_building_set() );
						
						// ------- display option Mode ------//

						for( i = OPTION_CAMPAIGN; i <= OPTION_ADVANCED; ++i )
						{
							// red font for selected
							Font *fontPtr = (i == optionMode ? &font_bold_red : &font_bold_black );

							fontPtr->center_put(OPTION_SWITCH_X1, OPTION_SWITCH_Y1+OPTION_SWITCH_Y_SPACING*i,
								OPTION_SWITCH_X2, OPTION_SWITCH_Y2+OPTION_SWITCH_Y_SPACING*i, 
								misc.roman_number(i+1) );
						}

						// ----- display start, cancel button ------//

						font_thin_black.center_put( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2,
							text_game_menu.str_start() );
						font_thin_black.center_put( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2,
							text_game_menu.str_cancel() );

						vga.use_front();
						vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
					}

					if( refreshFlag & SGOPTION_RACE )
						raceGroup.paint( tempConfig.race_id-1 );
					if( refreshFlag & SGOPTION_COLOR )
					{
						vga.use_back();		// to avoid flickering

						// ------ put color box ------ //
						char *bitmapPtr = image_button.read("F-COLOR");
						vga.active_buf->put_bitmap_trans_remap_decompress(
							colorButtonFrameX, colorButtonFrameY, bitmapPtr,
							game.color_remap_array[tempConfig.player_nation_color].color_table );
						colorGroup.paint(tempConfig.player_nation_color-1);

						vga.use_front();

						vga_util.blt_buf( colorButtonFrameX, colorButtonFrameY,
							colorButtonFrameX + ((Bitmap *)bitmapPtr)->get_width() - 1,
							colorButtonFrameY + ((Bitmap *)bitmapPtr)->get_height() - 1, 0 );
					}
					if( refreshFlag & SGOPTION_DIFFICULTY )
						campDiffGroup.paint(tempConfig.campaign_difficulty-1);
					if( refreshFlag & SGOPTION_BUILDING_SIZE )
						buildingSizeGroup.paint(tempConfig.building_size-1);
					if( refreshFlag & SGOPTION_NAME_FIELD )
						playerNameField.paint();
				}

				// ------- display advanced option ---------//
				if( optionMode == OPTION_ADVANCED )
				{
					if( refreshFlag & SGOPTION_PAGE )
					{
						vga.use_back();
						vga_util.disp_image_file("CHOOSE");

						font_bold_black.put_paragraph( 126, 173, option3X-10, 213-1,
							text_game_menu.str_fog_of_war() );

//						font_bold_black.put_paragraph( 126, 339, option3X-10, 389-1,
//							text_game_menu.str_spy_methodology() );

						font_bold_black.put_paragraph( 126, 314, option3X-10, 364-1,
							text_game_menu.str_random_events() );

						// ------- display option Mode ------//

						for( i = OPTION_CAMPAIGN; i <= OPTION_ADVANCED; ++i )
						{
							// red font for selected
							Font *fontPtr = (i == optionMode ? &font_bold_red : &font_bold_black );

							fontPtr->center_put(OPTION_SWITCH_X1, OPTION_SWITCH_Y1+OPTION_SWITCH_Y_SPACING*i,
								OPTION_SWITCH_X2, OPTION_SWITCH_Y2+OPTION_SWITCH_Y_SPACING*i,
								misc.roman_number(i+1) );
						}

						// ----- display start, cancel button ------//

						font_thin_black.center_put( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2,
							text_game_menu.str_start() );
						font_thin_black.center_put( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2,
							text_game_menu.str_cancel() );

						vga.use_front();
						vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 );
					}
					if( refreshFlag & SGOPTION_FOG )
						fogGroup.paint(tempConfig.fog_of_war);

//					if( refreshFlag & SGOPTION_SPY_METHOD )
//						spyMethodGroup.paint(tempConfig.spy_methodology);

					if( refreshFlag & SGOPTION_RANDOM_EVENT )
						randomEventGroup.paint(tempConfig.random_event_frequency);
				}

				refreshFlag = 0;
			}

			sys.blt_virtual_buf();

			if( config.music_flag )
			{
				if( !music.is_playing(3) )
					music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
			}
			else
				music.stop();

			// ------- detect --------//

			if( optionMode == OPTION_CAMPAIGN )
			{
				if( campaignGroup.detect() >= 0 
					|| campaignGroup[campaignGroup()].detect(0,0,0,1) )	// detect pushed button, but suspend pop
				{
					optionMode = OPTION_BASIC;		// auto change to basic mode
					refreshFlag = SGOPTION_ALL;
				}
			}

			else if( optionMode == OPTION_BASIC )
			{
				if( raceGroup.detect() >= 0)
				{
					tempConfig.race_id = raceGroup[raceGroup()].custom_para.value;
					//refreshFlag |= SGOPTION_RACE;
				}
				else if( colorGroup.detect() >= 0)
				{
					tempConfig.player_nation_color = colorGroup[colorGroup()].custom_para.value;
					refreshFlag |= SGOPTION_COLOR;
				}
				else if( campDiffGroup.detect() >= 0)
				{
					tempConfig.campaign_difficulty = campDiffGroup[campDiffGroup()].custom_para.value;
					refreshFlag |= SGOPTION_DIFFICULTY;
				}
				else if( buildingSizeGroup.detect() >= 0)
				{
					tempConfig.building_size = buildingSizeGroup[buildingSizeGroup()].custom_para.value;
					//refreshFlag |= SGOPTION_BUILDING_SIZE;
				}
				else if( playerNameField.detect() )
				{
					refreshFlag |= SGOPTION_NAME_FIELD;
				}
			}

			else if( optionMode == OPTION_ADVANCED )
			{
				if( fogGroup.detect() >= 0 )
				{
					tempConfig.fog_of_war = fogGroup[fogGroup()].custom_para.value;
					// refreshFlag |= SGOPTION_FOG;
				}
/*
				else if( spyMethodGroup.detect() >= 0 )
				{
					tempConfig.spy_methodology = spyMethodGroup[spyMethodGroup()].custom_para.value;
					// refreshFlag |= SGOPTION_SPY_METHOD;
				}
*/
				else if( randomEventGroup.detect() >= 0)
				{
					tempConfig.random_event_frequency = randomEventGroup[randomEventGroup()].custom_para.value;
					refreshFlag |= SGOPTION_RANDOM_EVENT;
				}
			}

			// -------- detect switch option button ---------//

			for( i = OPTION_CAMPAIGN; i <= OPTION_ADVANCED; ++i )
			{
				if( mouse.single_click( OPTION_SWITCH_X1, OPTION_SWITCH_Y1+OPTION_SWITCH_Y_SPACING*i,
					OPTION_SWITCH_X2, OPTION_SWITCH_Y2+OPTION_SWITCH_Y_SPACING*i) )
				{
					optionMode = i;
					refreshFlag = SGOPTION_ALL;
				}
			}

			// -------- detect start button --------//

			if( mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2 ) )
			{
				retFlag = campaignGroup() + 1;
				break;			// break  while(1)
			}

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

			if( mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2 ) )
			{
				retFlag = 0;
				break;			// break  while(1)
			}

		}	// end while
	} // end of scope of VgaLock

	if( retFlag )
	{
		tempConfig.human_difficulty_rating = tempConfig.single_player_difficulty(1);
		tempConfig.monster_difficulty_rating = tempConfig.single_player_difficulty(-1);
		config = tempConfig;
	}

	return retFlag;
}
Beispiel #13
0
//--------- Begin of function FirmWar::disp_build_menu ---------//
//
void FirmWar::disp_build_menu(int refreshFlag)
{
	int x1 = INFO_X1+13;
	int y1 = INFO_Y1+5;

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


	if( refreshFlag == INFO_REPAINT )
	{
		added_count=0;
	}
	int b = 0;

	TechClass *techClass = tech_res.tech_class(war_tech_class);	// war_tech_class is set the which tech class of weapon to build

	// int x=INFO_X1+2, y=INFO_Y1;

	for( int techId = techClass->first_tech_id; techId<techClass->first_tech_id+techClass->tech_count; ++techId )
	{
		short unitId = tech_res[techId]->unit_id;
		if( !unitId )
			continue;

		UnitInfo* unitInfo = unit_res[unitId];

		if( unitInfo->unit_class != UNIT_CLASS_WEAPON )
			continue;

		if( refreshFlag == INFO_REPAINT )
		{
			err_when( b != added_count);

			button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, 
				i_disp_queue_button, ButtonCustomPara(this, unitId) );
			button_queue_weapon[added_count].set_help_code( "WEAPNUM" );

			button_weapon[added_count].create(x1, y1+35, x1+67, y1+114,
				i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) );

			added_count++;
			x1 += 68;
			if (added_count == 3)
			{
				x1 = INFO_X1+13;
				y1 = INFO_Y1+121;
			}

			err_when(added_count > MAX_WEAPON_TYPE);
		}

		if( unitInfo->get_nation_tech_level(nation_recno) > 0 )
			button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 1;
		else
			button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 0;

		button_queue_weapon[b].paint();
		button_weapon[b].paint();

		++b;
	}
			
	if( refreshFlag==INFO_REPAINT )
	{
		// ##### begin Gilbert 8/2 ######//
		int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3;
		int y1 = INFO_Y1 +281;
		// button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" );
		button_cancel.create( x1, y1, 'A', "CANCEL" );
		// ##### end Gilbert 8/2 ######//
	}
	button_cancel.paint();
}
Beispiel #14
0
//--------- Begin of function FirmInn::put_info ---------//
//
void FirmInn::put_info(int refreshFlag)
{
	if( selected_unit_id < 0 )
		selected_unit_id = 0;
	if( selected_unit_id > inn_unit_count )
		selected_unit_id = inn_unit_count;

	Firm::put_info(refreshFlag);

	button_hire.create(INFO_X1+13, INFO_Y1+235, 'A', "HIREUNIT" );
	button_hire.enable_flag = 0;
	button_spy_mobilize.create(INFO_X1+13, INFO_Y1+235, 'A', "MOBILSPY" );
	button_spy_mobilize.enable_flag = 0;
	button_buy_item.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, 
		INFO_X1+13+BUTTON_DISTANCE+ITEM_ICON_WIDTH, INFO_Y1+235+ITEM_ICON_HEIGHT,
		disp_item_button, ButtonCustomPara(NULL, 0) );
	button_buy_item.visible_flag = 0;

	button_hire_visible = button_spy_mobilize_visible = 0;

	if( !should_show_info() )
		return;

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

	disp_unit_list( INFO_Y1, refreshFlag );

	disp_unit_info( INFO_Y1 + 165, refreshFlag );

	// ------ main interface --------//

	// ------ display hire button -------//

	button_hire.enable_flag = 0;
	button_spy_mobilize.enable_flag = 0;

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

		if( innUnit->is_own_spy() )
		{
			button_spy_mobilize.enable_flag = 1;
			button_spy_mobilize.paint();
			button_spy_mobilize_visible = 1;
		}
		else if( is_own() )
		{
			button_hire.enable_flag = (~nation_array)->cash >= innUnit->hire_cost;
			button_hire.paint();
			button_hire_visible = 1;
		}
		else
		{
			button_spy_mobilize.paint();
			button_spy_mobilize_visible = 1;
		}

		if( (button_buy_item.visible_flag = innUnit->item.id != 0) )
		{
			button_buy_item.enable_flag = is_own() && buy_item( selected_unit_id, 1 );		// checking only
			button_buy_item.custom_para.value = innUnit->item.id;
			button_buy_item.paint();
		}
	}
	else
	{
		if( is_own() )
		{
			button_hire.paint();
			button_hire_visible = 1;
		}
		else
		{
			button_spy_mobilize.paint();
			button_spy_mobilize_visible = 0;
		}

		button_buy_item.visible_flag = 0;
	}
}
Beispiel #15
0
//--------- Begin of function FirmResearch::disp_research_menu ---------//
//
void FirmResearch::disp_research_menu(int refreshFlag)
{
	int techId;
	added_count=0;
//	String str;

	int x=INFO_X1+23, y=INFO_Y1+15;
	int x2 = INFO_X1 +13;
	int y2 = INFO_Y1 +281;

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

	// ##### end Gilbert 5/11 ######//
	// if too many buttons, reduce ySpacing

	int ySpacing = 23;
	added_count = 0;
	for( techId = research_list_start ; techId<research_list_end ; techId++ )
	{
		if( tech_res[techId]->can_research(nation_recno) )
		{
			added_count++;
		}
	}
	if( added_count > 9 )
	{
		y -= 4;
		ySpacing = 18;
	}

	// ----- create button ------//

	added_count = 0;
	for( techId = research_list_start ; techId<research_list_end ; techId++ )
	{
		// ##### begin Gilbert 5/11 ######//
		button_research_array[added_count].create( x, y +added_count*ySpacing, x +187, y +added_count*ySpacing +17,
			i_disp_research_button, ButtonCustomPara(this, techId) );
		// ##### end Gilbert 5/11 ######//

		if( (button_research_array[added_count].enable_flag = tech_res[techId]->can_research(nation_recno)) )
		{
			button_research_array[added_count].paint();
			added_count++;
		}
	}
	
	if (added_count == 0)
	{
//		str = "All Technology in this";
//		font_snds.center_put( INFO_X1+7, INFO_Y1+11, INFO_X2, INFO_Y1+28, str );
//		str = "class has been researched !";
//		font_snds.center_put( INFO_X1+7, INFO_Y1+45, INFO_X2, INFO_Y1+62, str );

		font_snds.center_put_paragraph( INFO_X1+17, INFO_Y1+11, INFO_X2-12, INFO_Y1+62,
			text_firm.str_tech_class_finished(), DEFAULT_LINE_SPACE, 0, 0 );
	}

	x2 +=  3 * BUTTON_DISTANCE;
	button_cancel.paint( x2, y2, 'A', "CANCEL" );
}