// // Completed // // Give the assigned units to the squad and notify the // script manager that the request was completed // void Asset::Request::Completed(Manager &manager) { // Get the strategic object Object & object = manager.GetObject(); // Clear the currently selected units Orders::Game::ClearSelected::Generate(object); // Build a unit list from the asset list UnitObjList units; for (NList<Asset>::Iterator a(&assigned); *a; a++) { UnitObj *unit = (*a)->GetUnit(); if (unit) { units.Append(unit); } } if (units.GetCount()) { // Get the strategic player to select the assigned objects Orders::Game::AddSelected::Generate(object, units); // Clear out the temporary unit list units.Clear(); // Assign these objects to the squad if (script.Alive() && script->IsSquadAlive()) { Orders::Squad::AddSelected::Generate(object, script->GetSquad()->Id()); } } if (script.Alive()) { // Notify that the recruit is completed Orders::Squad::Notify::Generate(object, script->GetSquad()->Id(), 0xE6DC8EF5, handle); // "Squad::RecruitComplete" } // Delete the assigned assets assigned.UnlinkAll(); }
// // HandleEvent // // Pass any events to the registered handler // U32 TeamList::HandleEvent(::Event &e) { if (e.type == IFace::EventID()) { switch (e.subType) { case IFace::NOTIFY: { // Do specific handling switch (e.iface.p1) { case 0x23C19271: // "Edit" { if (data.team) { // Promote if (TeamEditor *editor = IFace::Find<TeamEditor>("TeamEditor")) { // Set the color var to our own editor->SetTeam(data.team); // Activate it IFace::Activate(editor); } } break; } case 0xC9FCFE2A: // "Clear" { data.team = NULL; break; } case 0x5989306C: // "Change" { data.team = Team::Name2Team(currentTeam->GetStringValue()); break; } case 0xB884B9E8: // "CreateTeam" { // Ignore if already exists if (!Team::Name2Team(createTeam->GetStringValue())) { // Create a new team new Team(createTeam->GetStringValue(), Team::NewId()); // Rebuild team list BuildList(); } break; } case 0x74EF9BE3: // "Destroy" { // Delete the current team if (data.team) { // Transfer all units to another list because of upgrades UnitObjList list; for (NList<UnitObj>::Iterator u(&data.team->GetUnitObjects()); *u; ++u) { list.Append(*u); } // Now delete each member of the team for (UnitObjList::Iterator i(&list); *i; ++i) { (**i)->SetTeam(NULL); (**i)->MarkForDeletion(); } list.Clear(); // Now it is safe to delete the team delete data.team; data.team = NULL; // Rebuild team list BuildList(); } break; } default : ICWindow::HandleEvent(e); break; } return (TRUE); } } } return (ICWindow::HandleEvent(e)); }