[Gcblue-commits] gcb_wx/src/scriptinterface tcScenarioInterface.cpp,1.6,1.7
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-01-01 23:46:47
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1:/tmp/cvs-serv6686/src/scriptinterface Modified Files: tcScenarioInterface.cpp Log Message: more briefing and scenario generation features Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcScenarioInterface.cpp 31 Dec 2003 17:34:10 -0000 1.6 --- tcScenarioInterface.cpp 1 Jan 2004 23:44:47 -0000 1.7 *************** *** 56,60 **** } ! void tcScenarioUnit::SetDatum(double lon_deg, double lat_deg, float alt_m) { lon = lon_deg; --- 56,65 ---- } ! void tcScenarioUnit::ClearOrders() ! { ! orders.clear(); ! } ! ! void tcScenarioUnit::SetPosition(double lon_deg, double lat_deg, float alt_m) { lon = lon_deg; *************** *** 63,66 **** --- 68,92 ---- } + /** + * Test that fields are valid. Display message box if not. + * @return true if validation okay + */ + bool tcScenarioUnit::Validate() + { + if (className == "Not defined") + { + wxMessageBox("Scenario unit class not defined","Error",wxICON_ERROR); + return false; + } + if (unitName == "Not defined") + { + wxString s = wxString::Format("Scenario unit name not defined (class: %s)",className.c_str()); + wxMessageBox(s.c_str(),"Error",wxICON_ERROR); + return false; + } + return true; + + } + tcDirector* tcScenarioInterface::director = NULL; tcMapData* tcScenarioInterface::mapData = NULL; *************** *** 93,97 **** .def_readwrite("speed",&tcScenarioUnit::speed) .def("AddOrder",&tcScenarioUnit::AddOrder) ! .def("SetDatum",&tcScenarioUnit::SetDatum) ; --- 119,124 ---- .def_readwrite("speed",&tcScenarioUnit::speed) .def("AddOrder",&tcScenarioUnit::AddOrder) ! .def("ClearOrders",&tcScenarioUnit::ClearOrders) ! .def("SetPosition",&tcScenarioUnit::SetPosition) ; *************** *** 128,131 **** --- 155,160 ---- // camera and 3D viewer events .def("FlybyCamera",&tcScenarioInterface::FlybyCamera) + .def("TrackCamera",&tcScenarioInterface::TrackCamera) + .def("Text3D",&tcScenarioInterface::Text3D) // goal creation workaround .def("CompoundGoal",&tcScenarioInterface::CompoundGoal) *************** *** 140,143 **** --- 169,174 ---- bool tcScenarioInterface::AddUnitToAlliance(tcScenarioUnit unit, int alliance) { + if (!unit.Validate()) return false; + tcDatabaseObject *dbObj = simState->mpDatabase->GetObject(unit.className); if (dbObj == NULL) *************** *** 439,442 **** --- 470,500 ---- C_PIOVER180*el1_deg, C_PIOVER180*el2_deg, r1_m, r2_m)); + } + + void tcScenarioInterface::TrackCamera(std::string unitName, double duration, float x1, float x2, + float y1, float y2, float z1, float z2) + { + wxASSERT(director); + + // repeated code from HookPlatform, refactor this + wxASSERT(simState); + tcGameObject* obj = simState->GetObjectByName(unitName); + if (obj == NULL) + { + std::cerr << "TrackCamera: Object not found (" + << unitName << ")\n"; + return; + } + director->AddEvent(new tcTrackCameraEvent(eventTime, eventTime+duration, obj->mnID, + x1, x2, y1, y2, z1, z2)); + } + + void tcScenarioInterface::Text3D(std::string text, double duration, + float x, float y, float size, int effect) + { + wxASSERT(director); + + director->AddEvent(new tc3DTextEvent(text, eventTime, eventTime+duration, + x, y, size, effect)); } |