Пример #1
0
void
CmpLoadDlg::Show()
{
	FormWindow::Show();

	Campaign* campaign = Campaign::GetCampaign();

	if (campaign) {
		Bitmap* bmp = campaign->GetImage(3);
		if (img_title && bmp) {
			Rect tgt_rect;
			tgt_rect.w = img_title->Width();
			tgt_rect.h = img_title->Height();

			img_title->SetTargetRect(tgt_rect);
			img_title->SetPicture(*bmp);
		}

		if (lbl_title)
		lbl_title->SetText(campaign->Name());
	}

	show_time = Game::RealTime();
}
void
MsnSelectDlg::Show()
{
	FormWindow::Show();
	campaign = Campaign::GetCampaign();

	if (cmb_campaigns) {
		int n = 0;
		cmb_campaigns->ClearItems();
		ListIter<Campaign> iter = Campaign::GetAllCampaigns();
		while (++iter) {
			Campaign* c = iter.value();

			if (c->GetCampaignId() >= Campaign::SINGLE_MISSIONS) {
				cmb_campaigns->AddItem(c->Name());

				if (campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS) {
					campaign = Campaign::SelectCampaign(c->Name());
					cmb_campaigns->SetSelection(n);
				}

				else if (campaign->GetCampaignId() == c->GetCampaignId()) {
					cmb_campaigns->SetSelection(n);
				}

				n++;
			}
		}
	}

	else if (lst_campaigns) {
		int n = 0;
		lst_campaigns->ClearItems();
		ListIter<Campaign> iter = Campaign::GetAllCampaigns();
		while (++iter) {
			Campaign* c = iter.value();

			if (c->GetCampaignId() >= Campaign::SINGLE_MISSIONS) {
				lst_campaigns->AddItem(c->Name());

				if (campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS) {
					campaign = Campaign::SelectCampaign(c->Name());
					lst_campaigns->SetSelected(n);
				}

				else if (campaign->GetCampaignId() == c->GetCampaignId()) {
					lst_campaigns->SetSelected(n);
				}

				n++;
			}
		}
	}

	if (campaign) {
		int id = campaign->GetCampaignId();
		editable = (id >= Campaign::MULTIPLAYER_MISSIONS &&
		id <= Campaign::CUSTOM_MISSIONS);

		if (btn_new)  btn_new->SetEnabled(editable);
		if (btn_edit) btn_edit->SetEnabled(false);
		if (btn_del)  btn_del->SetEnabled(false);
	}

	if (description)
	description->SetText(Game::GetText("MsnSelectDlg.choose"));

	if (lst_missions) {
		lst_missions->ClearItems();

		if (campaign) {
			ListIter<MissionInfo> iter = campaign->GetMissionList();
			while (++iter) {
				MissionInfo* info = iter.value();
				Mission*     m    = info->mission;

				lst_missions->AddItem(info->name);

				if (m && m == edit_mission) {
					lst_missions->SetSelected(lst_missions->NumItems()-1);
				}
			}

			if (selected_mission >= 0 && lst_missions->GetSelCount() == 0) {
				lst_missions->SetSelected(selected_mission);
			}
		}

		OnMissionSelect(0);
		edit_mission = 0;
	}
}