Ticket #96: progress_1_96.diff
File progress_1_96.diff, 7.5 KB (added by , 10 years ago) |
---|
-
source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp
49 49 + (m_ScreenPos.type1.y-m_Target.type1.y)*(m_ScreenPos.type1.y-m_Target.type1.y); 50 50 bool useTarget = (dragDistSq >= 16*16); 51 51 if (preview) 52 POST_MESSAGE(ObjectPreview, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed ));52 POST_MESSAGE(ObjectPreview, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed,true)); 53 53 else 54 54 { 55 55 POST_COMMAND(CreateObject, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed)); -
source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp
23 23 #include "Common/MiscState.h" 24 24 #include "Common/ObjectSettings.h" 25 25 #include "GameInterface/Messages.h" 26 #include <wx/clipbrd.h> 27 #include <wx/xml/xml.h> 28 #include <wx/sstream.h> 26 29 27 30 using AtlasMessage::Position; 28 31 … … 52 55 POST_MESSAGE(SetSelectionPreview, (g_SelectedObjects)); 53 56 } 54 57 58 void TransformObject::OnPasteStart() 59 { 60 //PASTE 61 wxString entities; 62 if (wxTheClipboard->Open()) 63 { 64 if (wxTheClipboard->IsSupported(wxDF_TEXT)) 65 { 66 wxTextDataObject data; 67 wxTheClipboard->GetData(data); 68 entities = data.GetText(); 69 } 70 } 71 else 72 { 73 //TODO: Show something when the clipboard couldnt open 74 } 75 76 //First do we need to check if it is a correct xml string 77 wxInputStream* is = new wxStringInputStream(entities); 78 wxXmlDocument doc; 79 if (!doc.Load(*is)) 80 { 81 return; 82 } 55 83 84 // Entities, Entity(1.*) 85 wxXmlNode* root = doc.GetRoot(); 86 if (root->GetName() != wxT("Entities")) 87 { 88 return; 89 } 90 // Template, position,orientation 91 const wxXmlNode* child = root->GetChildren(); 92 93 while (child) 94 { 95 if (child->GetName() != wxT("Entity")) 96 { 97 return; 98 } 99 //TODO Validate all attributes 100 child = child->GetNext(); 101 } 102 103 //Update selectedObjects?? 104 g_SelectedObjects.empty(); 105 106 // is the source code get here now you can add the objects to scene(preview) 107 // store id to move 108 child = root->GetChildren(); 109 110 while (child) 111 { 112 wxString objectId; 113 Position objectPos; 114 unsigned int actorSeed; 115 const wxXmlNode* xmlData = child->GetChildren(); 116 while (xmlData) 117 { 118 if (xmlData->GetName() == wxT("Template")) 119 { 120 objectId = xmlData->GetContent(); 121 } 122 else if (xmlData->GetName() == wxT("Position")) 123 { 124 wxString x, z; 125 xmlData->GetAttribute(wxT("x"), &x); 126 xmlData->GetAttribute(wxT("z"), &z); 127 128 objectPos = Position(); 129 //x.ToDouble(&objectPos.) 130 } 131 } 132 133 //POST_MESSAGE(ObjectPreview, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed)); 134 } 135 136 137 //Send new Object 138 //Set state paste for preview the new objects 139 } 140 141 void TransformObject::OnPasteEnd() 142 { 143 //when all is done set default state 144 this->SetState(&this->Waiting); 145 } 146 56 147 // TODO: keys to rotate/move object? 57 148 58 149 struct sWaiting : public State … … 167 258 obj->GetScenarioEditor().GetObjectSettings().NotifyObservers(); 168 259 return true; 169 260 } 261 else if (evt.GetModifiers() == wxMOD_CONTROL) 262 { 263 if (!g_SelectedObjects.empty()) 264 { 265 if (evt.GetKeyCode() == 'C') 266 { 267 //COPY current selections 268 AtlasMessage::qGetObjectMapSettings info(g_SelectedObjects); 269 info.Post(); 270 271 //In xmldata is the configuration 272 //now send to clipboard 273 if (wxTheClipboard->Open()) 274 { 275 wxString text(info.xmldata.c_str()); 276 wxTheClipboard->SetData(new wxTextDataObject(text)); 277 wxTheClipboard->Close(); 278 } 279 else 280 { 281 //TODO: Say something about couldnt open clipboard 282 } 283 284 } 285 else if (evt.GetKeyCode() == 'V') 286 { 287 obj->OnPasteStart(); 288 } 289 } 290 } 170 291 else 171 292 return false; 172 293 } -
source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp
49 49 #include "simulation2/components/ICmpTemplateManager.h" 50 50 #include "simulation2/components/ICmpVisual.h" 51 51 #include "simulation2/helpers/Selection.h" 52 #include "ps/XML/XMLWriter.h" 52 53 53 54 54 55 namespace AtlasMessage { … … 218 219 msg->settings = settings; 219 220 } 220 221 222 QUERYHANDLER(GetObjectMapSettings) 223 { 224 std::vector<entity_id_t> ids = *msg->ids; 225 226 CmpPtr<ICmpTemplateManager> cmpTemplateManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY); 227 ENSURE(cmpTemplateManager); 228 229 XML_Start(); 230 { 231 XML_Element("Entities"); 232 { 233 for (size_t i = 0; i < ids.size(); ++i) 234 { 235 entity_id_t id = (entity_id_t)ids[i]; 236 XML_Element("Entity"); 237 { 238 //Template name 239 XML_Setting("Template", cmpTemplateManager->GetCurrentTemplateName(id)); 240 241 //Player 242 CmpPtr<ICmpOwnership> cmpOwnership(*g_Game->GetSimulation2(), id); 243 if (cmpOwnership) 244 XML_Setting("Player", (int)cmpOwnership->GetOwner()); 245 246 //Adding position to make some relative position later 247 CmpPtr<ICmpPosition> cmpPosition(*g_Game->GetSimulation2(), id); 248 if (cmpPosition) 249 { 250 CFixedVector3D pos = cmpPosition->GetPosition(); 251 CFixedVector3D rot = cmpPosition->GetRotation(); 252 { 253 XML_Element("Position"); 254 XML_Attribute("x", pos.X); 255 XML_Attribute("z", pos.Z); 256 // TODO: height offset etc 257 } 258 { 259 XML_Element("Orientation"); 260 XML_Attribute("y", rot.Y); 261 // TODO: X, Z maybe 262 } 263 } 264 } 265 } 266 } 267 } 268 269 const CStr& data = XML_GetOutput(); 270 msg->xmldata = std::wstring(data.begin(), data.end()); 271 } 272 221 273 BEGIN_COMMAND(SetObjectSettings) 222 274 { 223 275 player_id_t m_PlayerOld, m_PlayerNew; … … 317 369 if (*msg->id != g_PreviewUnitName) 318 370 { 319 371 // Delete old entity 320 if (g_PreviewEntityID != INVALID_ENTITY )372 if (g_PreviewEntityID != INVALID_ENTITY && msg->deleteLastPreview) 321 373 g_Game->GetSimulation2()->DestroyEntity(g_PreviewEntityID); 322 374 323 375 // Create the new entity -
source/tools/atlas/GameInterface/Messages.h
344 344 ((Position, target)) 345 345 ((float, angle)) 346 346 ((unsigned int, actorseed)) 347 ((bool, deleteLastPreview)) // use with "paste" option 347 348 ); 348 349 349 350 COMMAND(CreateObject, NOMERGE, … … 590 591 ((sObjectSettings, settings)) 591 592 ); 592 593 594 QUERY(GetObjectMapSettings, 595 ((std::vector<ObjectID>, ids)) 596 , 597 ((std::wstring,xmldata)) 598 ); 599 593 600 QUERY(GetPlayerObjects, 594 601 ((int, player)) 595 602 ,