示例#1
0
void
DebriefDlg::Show()
{
    FormWindow::Show();
    Game::SetTimeCompression(1);

    mission  = 0;
    campaign = Campaign::GetCampaign();
    sim      = Sim::GetSim();

    if (sim)
    ship  = sim->GetPlayerShip();

    if (campaign)
    mission = campaign->GetMission();

    if (mission_name) {
        if (mission)
        mission_name->SetText(mission->Name());
        else
        mission_name->SetText(Game::GetText("DebriefDlg.mission-name"));
    }

    if (mission_system) {
        mission_system->SetText("");

        if (mission) {
            StarSystem* sys = mission->GetStarSystem();

            if (sys)
            mission_system->SetText(sys->Name());
        }
    }

    if (mission_sector) {
        mission_sector->SetText("");

        if (mission) {
            MissionElement* elem = mission->GetElements()[0];

            if (elem)
            mission_sector->SetText(elem->Region());
        }
    }

    if (mission_time_start) {
        if (mission) {
            char txt[32];
            FormatDayTime(txt, mission->Start());
            mission_time_start->SetText(txt);
        }
    }

    if (objectives) {
        bool found_objectives = false;

        if (sim && sim->GetPlayerElement()) {
            Text     text;
            Element* elem = sim->GetPlayerElement();

            for (int i = 0; i < elem->NumObjectives(); i++) {
                Instruction* obj = elem->GetObjective(i);
                text += Text("* ") + obj->GetDescription() + Text("\n");

                found_objectives = true;
            }

            objectives->SetText(text);
        }

        if (!found_objectives) {
            if (mission)
            objectives->SetText(mission->Objective());
            else
            objectives->SetText(Game::GetText("DebriefDlg.unspecified"));
        }
    }

    if (situation) {
        if (mission)
        situation->SetText(mission->Situation());
        else
        situation->SetText(Game::GetText("DebriefDlg.unknown"));
    }

    if (mission_score) {
        mission_score->SetText(Game::GetText("DebriefDlg.no-stats"));

        if (ship) {
            for (int i = 0; i < ShipStats::NumStats(); i++) {
                ShipStats* stats = ShipStats::GetStats(i);
                if (stats && !strcmp(ship->Name(), stats->GetName())) {
                    stats->Summarize();

                    Player* player = Player::GetCurrentPlayer();
                    int     points = stats->GetPoints() + stats->GetCommandPoints();

                    if (player && sim)
                        points = player->GetMissionPoints(stats, sim->StartTime()) + stats->GetCommandPoints();

                    char score[32];
                    sprintf_s(score, "%d %s", points, Game::GetText("DebriefDlg.points").data());
                    mission_score->SetText(score);
                    break;
                }
            }
        }
    }

    DrawUnits();
}