@@ -2721,6 +2721,8 @@ void Renderer::cutEnt() {
27212721 DeleteEntityCommand* deleteCommand = new DeleteEntityCommand (" Cut Entity" , pickInfo);
27222722 deleteCommand->execute ();
27232723 pushUndoCommand (deleteCommand);
2724+
2725+ ImGui::SetClipboardText (copiedEnt->serialize ().c_str ());
27242726}
27252727
27262728void Renderer::copyEnt () {
@@ -2733,6 +2735,8 @@ void Renderer::copyEnt() {
27332735 Bsp* map = mapRenderers[pickInfo.mapIdx ]->map ;
27342736 copiedEnt = new Entity ();
27352737 *copiedEnt = *map->ents [pickInfo.entIdx ];
2738+
2739+ ImGui::SetClipboardText (copiedEnt->serialize ().c_str ());
27362740}
27372741
27382742void Renderer::pasteEnt (bool noModifyOrigin) {
@@ -2770,6 +2774,31 @@ void Renderer::pasteEnt(bool noModifyOrigin) {
27702774 selectEnt (map, map->ents .size () - 1 );
27712775}
27722776
2777+ void Renderer::pasteEntsFromText (string text) {
2778+ Bsp* map = pickInfo.map ? pickInfo.map : mapRenderers[0 ]->map ;
2779+
2780+ CreateEntityFromTextCommand* createCommand =
2781+ new CreateEntityFromTextCommand (" Paste entities from clipboard" , pickInfo.mapIdx , text);
2782+ createCommand->execute ();
2783+ pushUndoCommand (createCommand);
2784+
2785+ if (createCommand->createdEnts == 1 ) {
2786+ Entity* createdEnt = map->ents [map->ents .size ()-1 ];
2787+ vec3 oldOrigin = getEntOrigin (map, createdEnt);
2788+ vec3 modelOffset = getEntOffset (map, createdEnt);
2789+ vec3 mapOffset = mapRenderers[pickInfo.mapIdx ]->mapOffset ;
2790+
2791+ vec3 moveDist = (cameraOrigin + cameraForward * 100 ) - oldOrigin;
2792+ vec3 newOri = (oldOrigin + moveDist) - (modelOffset + mapOffset);
2793+ vec3 rounded = gridSnappingEnabled ? snapToGrid (newOri) : newOri;
2794+ createdEnt->setOrAddKeyvalue (" origin" , rounded.toKeyvalueString (!gridSnappingEnabled));
2795+ createCommand->refresh ();
2796+ }
2797+
2798+ pickInfo.valid = true ;
2799+ selectEnt (map, map->ents .size () - 1 );
2800+ }
2801+
27732802void Renderer::deleteEnt () {
27742803 if (!pickInfo.valid || pickInfo.entIdx <= 0 )
27752804 return ;
0 commit comments