diff options
Diffstat (limited to 'Stars45/CmdMissionsDlg.cpp')
-rw-r--r-- | Stars45/CmdMissionsDlg.cpp | 430 |
1 files changed, 215 insertions, 215 deletions
diff --git a/Stars45/CmdMissionsDlg.cpp b/Stars45/CmdMissionsDlg.cpp index 0295d68..24ec940 100644 --- a/Stars45/CmdMissionsDlg.cpp +++ b/Stars45/CmdMissionsDlg.cpp @@ -1,15 +1,15 @@ /* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2004. All Rights Reserved.
+ Destroyer Studios LLC
+ Copyright © 1997-2004. All Rights Reserved.
- SUBSYSTEM: Stars.exe
- FILE: CmdMissionsDlg.cpp
- AUTHOR: John DiCamillo
+ SUBSYSTEM: Stars.exe
+ FILE: CmdMissionsDlg.cpp
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Operational Command Dialog (Mission List Tab)
+ OVERVIEW
+ ========
+ Operational Command Dialog (Mission List Tab)
*/
#include "MemDebug.h"
@@ -50,14 +50,14 @@ DEF_MAP_CLIENT(CmdMissionsDlg, OnAccept); // +--------------------------------------------------------------------+
CmdMissionsDlg::CmdMissionsDlg(Screen* s, FormDef& def, CmpnScreen* mgr)
- : FormWindow(s, 0, 0, s->Width(), s->Height()), CmdDlg(mgr), manager(mgr),
- lst_missions(0), txt_desc(0), btn_accept(0),
- stars(0), campaign(0), mission(0)
+: FormWindow(s, 0, 0, s->Width(), s->Height()), CmdDlg(mgr), manager(mgr),
+lst_missions(0), txt_desc(0), btn_accept(0),
+stars(0), campaign(0), mission(0)
{
- stars = Starshatter::GetInstance();
- campaign = Campaign::GetCampaign();
+ stars = Starshatter::GetInstance();
+ campaign = Campaign::GetCampaign();
- Init(def);
+ Init(def);
}
CmdMissionsDlg::~CmdMissionsDlg()
@@ -69,31 +69,31 @@ CmdMissionsDlg::~CmdMissionsDlg() void
CmdMissionsDlg::RegisterControls()
{
- lst_missions = (ListBox*) FindControl(401);
- txt_desc = FindControl(402);
- btn_accept = (Button*) FindControl(403);
+ lst_missions = (ListBox*) FindControl(401);
+ txt_desc = FindControl(402);
+ btn_accept = (Button*) FindControl(403);
- RegisterCmdControls(this);
+ RegisterCmdControls(this);
- if (btn_save)
- REGISTER_CLIENT(EID_CLICK, btn_save, CmdMissionsDlg, OnSave);
+ if (btn_save)
+ REGISTER_CLIENT(EID_CLICK, btn_save, CmdMissionsDlg, OnSave);
- if (btn_exit)
- REGISTER_CLIENT(EID_CLICK, btn_exit, CmdMissionsDlg, OnExit);
+ if (btn_exit)
+ REGISTER_CLIENT(EID_CLICK, btn_exit, CmdMissionsDlg, OnExit);
- for (int i = 0; i < 5; i++) {
- if (btn_mode[i])
- REGISTER_CLIENT(EID_CLICK, btn_mode[i], CmdMissionsDlg, OnMode);
- }
+ for (int i = 0; i < 5; i++) {
+ if (btn_mode[i])
+ REGISTER_CLIENT(EID_CLICK, btn_mode[i], CmdMissionsDlg, OnMode);
+ }
- if (lst_missions) {
- REGISTER_CLIENT(EID_SELECT, lst_missions, CmdMissionsDlg, OnMission);
- }
+ if (lst_missions) {
+ REGISTER_CLIENT(EID_SELECT, lst_missions, CmdMissionsDlg, OnMission);
+ }
- if (btn_accept) {
- btn_accept->SetEnabled(false);
- REGISTER_CLIENT(EID_CLICK, btn_accept, CmdMissionsDlg, OnAccept);
- }
+ if (btn_accept) {
+ btn_accept->SetEnabled(false);
+ REGISTER_CLIENT(EID_CLICK, btn_accept, CmdMissionsDlg, OnAccept);
+ }
}
// +--------------------------------------------------------------------+
@@ -101,153 +101,153 @@ CmdMissionsDlg::RegisterControls() void
CmdMissionsDlg::Show()
{
- mode = MODE_MISSIONS;
-
- FormWindow::Show();
- ShowCmdDlg();
-
- campaign = Campaign::GetCampaign();
-
- if (campaign) {
- if (lst_missions) {
- lst_missions->ClearItems();
-
- Player* player = Player::GetCurrentPlayer();
- List<MissionInfo>& missions = campaign->GetMissionList();
- for (int i = 0; i < missions.size(); i++) {
- MissionInfo* info = missions[i];
- lst_missions->AddItemWithData(info->name, info->id);
-
- Mission* m = info->mission;
- if (m) {
- if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
- lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
- }
- else {
- lst_missions->SetItemText(i, 1, m->TypeName());
- }
- }
-
- char start_time[64];
- FormatDayTime(start_time, info->start);
- lst_missions->SetItemText(i, 2, start_time);
- }
- }
- }
+ mode = MODE_MISSIONS;
+
+ FormWindow::Show();
+ ShowCmdDlg();
+
+ campaign = Campaign::GetCampaign();
+
+ if (campaign) {
+ if (lst_missions) {
+ lst_missions->ClearItems();
+
+ Player* player = Player::GetCurrentPlayer();
+ List<MissionInfo>& missions = campaign->GetMissionList();
+ for (int i = 0; i < missions.size(); i++) {
+ MissionInfo* info = missions[i];
+ lst_missions->AddItemWithData(info->name, info->id);
+
+ Mission* m = info->mission;
+ if (m) {
+ if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
+ lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
+ }
+ else {
+ lst_missions->SetItemText(i, 1, m->TypeName());
+ }
+ }
+
+ char start_time[64];
+ FormatDayTime(start_time, info->start);
+ lst_missions->SetItemText(i, 2, start_time);
+ }
+ }
+ }
}
void
CmdMissionsDlg::ExecFrame()
{
- CmdDlg::ExecFrame();
-
- if (campaign) {
- List<MissionInfo>& missions = campaign->GetMissionList();
- Player* player = Player::GetCurrentPlayer();
-
- if (missions.size() > lst_missions->NumItems()) {
- while (missions.size() > lst_missions->NumItems()) {
- MissionInfo* info = missions[lst_missions->NumItems()];
- int i = lst_missions->AddItemWithData(info->name, info->id) - 1;
-
- Mission* m = info->mission;
- if (m) {
- if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
- lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
- }
- else {
- lst_missions->SetItemText(i, 1, m->TypeName());
- }
- }
-
- char start_time[64];
- FormatDayTime(start_time, info->start);
- lst_missions->SetItemText(i, 2, start_time);
- }
- }
-
- else if (missions.size() < lst_missions->NumItems()) {
- lst_missions->ClearItems();
-
- for (int i = 0; i < missions.size(); i++) {
- MissionInfo* info = missions[i];
- lst_missions->AddItemWithData(info->name, info->id);
-
- Mission* m = info->mission;
- if (m) {
- if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
- lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
- }
- else {
- lst_missions->SetItemText(i, 1, m->TypeName());
- }
- }
-
- char start_time[64];
- FormatDayTime(start_time, info->start);
- lst_missions->SetItemText(i, 2, start_time);
- }
- }
-
- else if (missions.size() > 0 && lst_missions->NumItems() > 0) {
- int id = lst_missions->GetItemData(0);
- MissionInfo* info = campaign->GetMissionInfo(id);
-
- if (!info) {
- int seln = -1;
- int seln_id = 0;
-
- for (int i = 0; i < lst_missions->NumItems(); i++)
- if (lst_missions->IsSelected(i))
- seln = i;
-
- if (seln >= 0)
- seln_id = lst_missions->GetItemData(seln);
-
- lst_missions->ClearItems();
- seln = -1;
-
- for (int i = 0; i < missions.size(); i++) {
- MissionInfo* info = missions[i];
- lst_missions->AddItemWithData(info->name, info->id);
-
- Mission* m = info->mission;
- if (m) {
- if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
- lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
- }
- else {
- lst_missions->SetItemText(i, 1, m->TypeName());
- }
- }
-
- char start_time[64];
- FormatDayTime(start_time, info->start);
- lst_missions->SetItemText(i, 2, start_time);
-
- if (info->id == seln_id)
- seln = i;
- }
-
- if (seln >= 0)
- lst_missions->SetSelected(seln);
- }
- }
-
- bool found = false;
-
- for (int i = 0; i < missions.size() && !found; i++) {
- MissionInfo* info = missions[i];
- if (info->mission == mission)
- found = true;
- }
-
- if (!found) {
- mission = 0;
- txt_desc->SetText("");
- btn_accept->SetEnabled(false);
- }
- }
+ CmdDlg::ExecFrame();
+
+ if (campaign) {
+ List<MissionInfo>& missions = campaign->GetMissionList();
+ Player* player = Player::GetCurrentPlayer();
+
+ if (missions.size() > lst_missions->NumItems()) {
+ while (missions.size() > lst_missions->NumItems()) {
+ MissionInfo* info = missions[lst_missions->NumItems()];
+ int i = lst_missions->AddItemWithData(info->name, info->id) - 1;
+
+ Mission* m = info->mission;
+ if (m) {
+ if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
+ lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
+ }
+ else {
+ lst_missions->SetItemText(i, 1, m->TypeName());
+ }
+ }
+
+ char start_time[64];
+ FormatDayTime(start_time, info->start);
+ lst_missions->SetItemText(i, 2, start_time);
+ }
+ }
+
+ else if (missions.size() < lst_missions->NumItems()) {
+ lst_missions->ClearItems();
+
+ for (int i = 0; i < missions.size(); i++) {
+ MissionInfo* info = missions[i];
+ lst_missions->AddItemWithData(info->name, info->id);
+
+ Mission* m = info->mission;
+ if (m) {
+ if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
+ lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
+ }
+ else {
+ lst_missions->SetItemText(i, 1, m->TypeName());
+ }
+ }
+
+ char start_time[64];
+ FormatDayTime(start_time, info->start);
+ lst_missions->SetItemText(i, 2, start_time);
+ }
+ }
+
+ else if (missions.size() > 0 && lst_missions->NumItems() > 0) {
+ int id = lst_missions->GetItemData(0);
+ MissionInfo* info = campaign->GetMissionInfo(id);
+
+ if (!info) {
+ int seln = -1;
+ int seln_id = 0;
+
+ for (int i = 0; i < lst_missions->NumItems(); i++)
+ if (lst_missions->IsSelected(i))
+ seln = i;
+
+ if (seln >= 0)
+ seln_id = lst_missions->GetItemData(seln);
+
+ lst_missions->ClearItems();
+ seln = -1;
+
+ for (int i = 0; i < missions.size(); i++) {
+ MissionInfo* info = missions[i];
+ lst_missions->AddItemWithData(info->name, info->id);
+
+ Mission* m = info->mission;
+ if (m) {
+ if (m->Type() == Mission::TRAINING && player->HasTrained(m->Identity())) {
+ lst_missions->SetItemText(i, 1, Game::GetText("CmdMissionsDlg.training"));
+ }
+ else {
+ lst_missions->SetItemText(i, 1, m->TypeName());
+ }
+ }
+
+ char start_time[64];
+ FormatDayTime(start_time, info->start);
+ lst_missions->SetItemText(i, 2, start_time);
+
+ if (info->id == seln_id)
+ seln = i;
+ }
+
+ if (seln >= 0)
+ lst_missions->SetSelected(seln);
+ }
+ }
+
+ bool found = false;
+
+ for (int i = 0; i < missions.size() && !found; i++) {
+ MissionInfo* info = missions[i];
+ if (info->mission == mission)
+ found = true;
+ }
+
+ if (!found) {
+ mission = 0;
+ txt_desc->SetText("");
+ btn_accept->SetEnabled(false);
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -255,19 +255,19 @@ CmdMissionsDlg::ExecFrame() void
CmdMissionsDlg::OnSave(AWEvent* event)
{
- CmdDlg::OnSave(event);
+ CmdDlg::OnSave(event);
}
void
CmdMissionsDlg::OnExit(AWEvent* event)
{
- CmdDlg::OnExit(event);
+ CmdDlg::OnExit(event);
}
void
CmdMissionsDlg::OnMode(AWEvent* event)
{
- CmdDlg::OnMode(event);
+ CmdDlg::OnMode(event);
}
@@ -276,34 +276,34 @@ CmdMissionsDlg::OnMode(AWEvent* event) void
CmdMissionsDlg::OnMission(AWEvent* event)
{
- if (campaign && lst_missions) {
- MissionInfo* info = 0;
- mission = 0;
-
- for (int i = 0; i < lst_missions->NumItems(); i++) {
- if (lst_missions->IsSelected(i)) {
- int id = lst_missions->GetItemData(i);
- info = campaign->GetMissionInfo(id);
- }
- }
-
- btn_accept->SetEnabled((info != 0) ? true : false);
-
- if (info) {
- Text desc("<font Limerick12><color ffff80>");
- desc += info->name;
- desc += "<font Verdana><color ffffff>\n\n";
- desc += info->player_info;
- desc += "\n\n";
- desc += info->description;
-
- txt_desc->SetText(desc);
- mission = info->mission;
- }
- else {
- txt_desc->SetText(" ");
- }
- }
+ if (campaign && lst_missions) {
+ MissionInfo* info = 0;
+ mission = 0;
+
+ for (int i = 0; i < lst_missions->NumItems(); i++) {
+ if (lst_missions->IsSelected(i)) {
+ int id = lst_missions->GetItemData(i);
+ info = campaign->GetMissionInfo(id);
+ }
+ }
+
+ btn_accept->SetEnabled((info != 0) ? true : false);
+
+ if (info) {
+ Text desc("<font Limerick12><color ffff80>");
+ desc += info->name;
+ desc += "<font Verdana><color ffffff>\n\n";
+ desc += info->player_info;
+ desc += "\n\n";
+ desc += info->description;
+
+ txt_desc->SetText(desc);
+ mission = info->mission;
+ }
+ else {
+ txt_desc->SetText(" ");
+ }
+ }
}
// +--------------------------------------------------------------------+
@@ -311,15 +311,15 @@ CmdMissionsDlg::OnMission(AWEvent* event) void
CmdMissionsDlg::OnAccept(AWEvent* event)
{
- if (!campaign || !mission) {
- ::Print(" ERROR CMD::Accept campaign=0x%08x mission=0x%08x\n", campaign, mission);
- return;
- }
+ if (!campaign || !mission) {
+ ::Print(" ERROR CMD::Accept campaign=0x%08x mission=0x%08x\n", campaign, mission);
+ return;
+ }
- ::Print(" CMD::Accept Mission %d\n", mission->Identity());
+ ::Print(" CMD::Accept Mission %d\n", mission->Identity());
- Mouse::Show(false);
- campaign->SetMissionId(mission->Identity());
- campaign->StartMission();
- stars->SetGameMode(Starshatter::PREP_MODE);
+ Mouse::Show(false);
+ campaign->SetMissionId(mission->Identity());
+ campaign->StartMission();
+ stars->SetGameMode(Starshatter::PREP_MODE);
}
|