void
MsnSelectDlg::OnCampaignSelect(AWEvent* event)
{
	const char* selected_campaign = 0;

	if (cmb_campaigns)
	selected_campaign = cmb_campaigns->GetSelectedItem();
	else if (lst_campaigns)
	selected_campaign = lst_campaigns->GetSelectedItem();

	Campaign* c = Campaign::SelectCampaign(selected_campaign);

	if (c) {
		campaign = c;

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

			ListIter<MissionInfo> iter = campaign->GetMissionList();
			while (++iter) {
				cmb_campaigns->AddItem(iter->name);
			}
		}

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

			ListIter<MissionInfo> iter = campaign->GetMissionList();
			while (++iter) {
				lst_missions->AddItem(iter->name);
			}

			lst_missions->ScrollTo(0);
		}

		if (btn_accept)
		btn_accept->SetEnabled(false);

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

		int id = c->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);
	}
}
Пример #2
0
void
DebriefDlg::OnClose(AWEvent* event)
{
    Sim* sim = Sim::GetSim();

    sim->CommitMission();
    sim->UnloadMission();

    NetLobby* lobby = NetLobby::GetInstance();
    if (lobby && lobby->IsHost()) {
        lobby->SelectMission(0);
        lobby->ExecFrame();
    }

    Player* player = Player::GetCurrentPlayer();
    if (player && player->ShowAward()) {
        manager->ShowAwardDlg();
    }

    else {
        Starshatter* stars = Starshatter::GetInstance();

        if (stars) {
            Mouse::Show(false);

            Campaign* campaign = Campaign::GetCampaign();
            if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS)
            stars->SetGameMode(Starshatter::CMPN_MODE);
            else
            stars->SetGameMode(Starshatter::MENU_MODE);
        }

        else {
            Game::Panic("DebriefDlg::OnClose() - Game instance not found");
        }
    }
}
Пример #3
0
void
QuitView::ExecFrame()
{
    sim = Sim::GetSim();

    if (show_menu) {
        Color::SetFade(1, Color::Black, 0);
        int action = 0;

        if (Mouse::LButton()) {
            mouse_latch = true;
        }
        else if (mouse_latch) {
            mouse_latch = false;

            if (Mouse::X() > xcenter - w2 && Mouse::X() < xcenter + w2) {
                int y0 = ycenter - h2;

                for (int i = 0; i < 4; i++)
                if (Mouse::Y() >= y0 + 75 + i * 30 && Mouse::Y() <= y0 + 105 + i * 30)
                action = i+1;
            }
        }

        for (int i = 1; i <= 4; i++) {
            if (Keyboard::KeyDown('0' + i))
            action = i;
        }

        // was mission long enough to accept?
        if (action == 1 && !CanAccept()) {
            Button::PlaySound(Button::SND_REJECT);
            action = 3;
        }

        // exit and accept:
        if (action == 1) {
            CloseMenu();
            Game::SetTimeCompression(1);

            Starshatter* stars = Starshatter::GetInstance();
            stars->SetGameMode(Starshatter::PLAN_MODE);
        }

        // quit and discard results:
        else if (action == 2) {
            CloseMenu();
            Game::SetTimeCompression(1);

            Starshatter*   stars    = Starshatter::GetInstance();
            Campaign*      campaign = Campaign::GetCampaign();

            // discard mission and events:
            if (sim) sim->UnloadMission();
            else ShipStats::Initialize();

            if (campaign && campaign->GetCampaignId() < Campaign::SINGLE_MISSIONS) {
                campaign->RollbackMission();
                stars->SetGameMode(Starshatter::CMPN_MODE);
            }

            else {
                stars->SetGameMode(Starshatter::MENU_MODE);
            }
        }

        // resume:
        else if (action == 3) {
            CloseMenu();
        }

        // controls:
        else if (action == 4) {
            GameScreen* game_screen = GameScreen::GetInstance();

            if (game_screen)
            game_screen->ShowCtlDlg();
            else
            CloseMenu();
        }
    }
}
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;
	}
}