X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=contrib%2Fbobtoolz%2Ffunchandlers-GTK.cpp;h=5d1f16a910c749b058816a74152ed53b8861ed69;hp=deb3ff829d5668e8eefe6907dba5f1d7ce6e9966;hb=68159d9ed443f990fecf207847408a673eb641f7;hpb=12b372f89ce109a4db9d510884fbe7d05af79870 diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index deb3ff82..5d1f16a9 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -17,7 +17,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "StdAfx.h" +#include "funchandlers.h" #ifdef WIN32 #pragma warning(disable : 4786) @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "dialogs/dialogs-gtk.h" -#include "gtkr_list.h" +#include #include "str.h" #include "DPoint.h" @@ -40,18 +40,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "DTrainDrawer.h" #include "misc.h" -#include "scriptparser.h" +#include "ScriptParser.h" #include "DTreePlanter.h" #include "shapes.h" #include "lists.h" -#include "funchandlers.h" #include "visfind.h" #include "iundo.h" -#include "refcounted_ptr.h" - #include #include #include @@ -60,13 +57,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "scenelib.h" // for autocaulk -list exclusionList; // whole brush exclusion -list exclusionList_Face; // single face exclusion +std::list exclusionList; // whole brush exclusion +std::list exclusionList_Face; // single face exclusion -bool el1Loaded = FALSE; -bool el2Loaded = FALSE; -bool clrLst1Loaded = FALSE; -bool clrLst2Loaded = FALSE; +bool el1Loaded = false; +bool el2Loaded = false; +bool clrLst1Loaded = false; +bool clrLst2Loaded = false; DBobView* g_PathView = NULL; DVisDrawer* g_VisView = NULL; @@ -95,6 +92,7 @@ void LoadLists() void DoIntersect() { + UndoableCommand undo("bobToolz.intersect"); IntersectRS rs; if(DoIntersectBox(&rs) == eIDCANCEL) @@ -120,7 +118,7 @@ void DoIntersect() } case BRUSH_OPT_WHOLE_MAP: { - world.LoadFromEntity(0, FALSE); + world.LoadFromEntity(GlobalRadiant().getMapWorldEntity(), false); break; } } @@ -145,6 +143,7 @@ void DoPolygonsTB() void DoPolygons() { + UndoableCommand undo("bobToolz.polygons"); // ensure we have something selected if( GlobalSelectionSystem().countSelected() != 1 ) { @@ -163,10 +162,10 @@ void DoPolygons() { scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin); - VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax); + VectorSubtract(instance.worldAABB().origin, instance.worldAABB().extents, vMin); + VectorAdd(instance.worldAABB().origin, instance.worldAABB().extents, vMax); - instance.path().parent()->m_traverse->erase(instance.path().top()); + Path_deleteTop(instance.path()); } if(rs.bInverse) @@ -186,16 +185,18 @@ void DoPolygons() void DoFixBrushes() { + UndoableCommand undo("bobToolz.fixBrushes"); DMap world; world.LoadAll(); int count = world.FixBrushes(); - Sys_Printf("%i invalid/duplicate planes removed\n", count); + globalOutputStream() << count << " invalid/duplicate planes removed\n"; } void DoResetTextures() { + UndoableCommand undo("bobToolz.resetTextures"); static ResetTextureRS rs; const char* texName; @@ -221,12 +222,12 @@ void DoResetTextures() DEntity world; world.LoadSelectedBrushes(); world.ResetTextures(texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName, - rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, TRUE); + rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation, true); } else { DMap world; - world.LoadAll(TRUE); + world.LoadAll(true); world.ResetTextures(texName, rs.fScale, rs.fShift, rs.rotation, rs.newTextureName, rs.bResetTextureName, rs.bResetScale, rs.bResetShift, rs.bResetRotation); } @@ -234,6 +235,7 @@ void DoResetTextures() void DoBuildStairs() { + UndoableCommand undo("bobToolz.buildStairs"); BuildStairsRS rs; strcpy(rs.mainTexture, GetCurrentTexture()); @@ -252,8 +254,8 @@ void DoBuildStairs() { scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin); - VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax); + VectorSubtract(instance.worldAABB().origin, instance.worldAABB().extents, vMin); + VectorAdd(instance.worldAABB().origin, instance.worldAABB().extents, vMax); } // calc brush size @@ -269,7 +271,7 @@ void DoBuildStairs() { { scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - instance.path().parent()->m_traverse->erase(instance.path().top()); + Path_deleteTop(instance.path()); } // Get Step Count @@ -293,7 +295,7 @@ void DoBuildStairs() // Build Base For Stair (bob's style) if(rs.style == STYLE_BOB) - Build_Wedge(rs.direction, vMin, vMax, TRUE); + Build_Wedge(rs.direction, vMin, vMax, true); // Set First Step Starting Position @@ -322,6 +324,7 @@ void DoBuildStairs() void DoBuildDoors() { + UndoableCommand undo("bobToolz.buildDoors"); // ensure we have something selected if( GlobalSelectionSystem().countSelected() != 1 ) { @@ -338,9 +341,9 @@ void DoBuildDoors() { scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin); - VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax); - instance.path().parent()->m_traverse->erase(instance.path().top()); + VectorSubtract(instance.worldAABB().origin, instance.worldAABB().extents, vMin); + VectorAdd(instance.worldAABB().origin, instance.worldAABB().extents, vMax); + Path_deleteTop(instance.path()); } BuildDoorsX2(vMin, vMax, @@ -353,6 +356,7 @@ void DoBuildDoors() void DoPathPlotter() { + UndoableCommand undo("bobToolz.pathPlotter"); PathPlotterRS rs; EMessageBoxReturn ret = DoPathPlotterBox(&rs); if(ret == eIDCANCEL) @@ -371,44 +375,16 @@ void DoPathPlotter() return; } - scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - - DEntity world; - world.LoadEPairList(instance.path().top()->m_entity); - - DEPair* trigger_ep = world.FindEPairByKey("targetname"); - - if(trigger_ep) - { - if(!strcmp(world.m_Classname, "trigger_push")) - { - DEPair* target_ep = world.FindEPairByKey("target"); - if(target_ep) - { - scene::Path* entTarget = FindEntityFromTargetname(target_ep->value, NULL); - if(entTarget) - { - if(g_PathView) - delete g_PathView; - g_PathView = new DBobView; - - g_PathView->Begin(trigger_ep->value, target_ep->value, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra); - } - else - DoMessageBox("trigger_push target could not be found.", "Error", eMB_OK); - } - else - DoMessageBox("trigger_push has no target.", "Error", eMB_OK); - } - else - DoMessageBox("You must select a 'trigger_push' entity.", "Error", eMB_OK); - } - else - DoMessageBox("Entity must have a targetname", "Error", eMB_OK); + Entity* entity = Node_getEntity(GlobalSelectionSystem().ultimateSelected().path().top()); + if(entity != 0) + { + DBobView_setEntity(*entity, rs.fMultiplier, rs.nPoints, rs.fGravity, rs.bNoUpdate, rs.bShowExtra); + } } void DoPitBuilder() { + UndoableCommand undo("bobToolz.pitBuilder"); // ensure we have something selected if( GlobalSelectionSystem().countSelected() != 1 ) { @@ -419,8 +395,8 @@ void DoPitBuilder() vec3_t vMin, vMax; scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - VectorSubtract(instance.aabb_world().origin, instance.aabb_world().extents, vMin); - VectorAdd(instance.aabb_world().origin, instance.aabb_world().extents, vMax); + VectorSubtract(instance.worldAABB().origin, instance.worldAABB().extents, vMin); + VectorAdd(instance.worldAABB().origin, instance.worldAABB().extents, vMax); DShape pit; @@ -428,7 +404,7 @@ void DoPitBuilder() { pit.Commit(); - instance.path().parent()->m_traverse->erase(instance.path().top()); + Path_deleteTop(instance.path()); } else DoMessageBox("Failed To Make Pit\nTry Making The Brush Bigger", "Error", eMB_OK); @@ -436,6 +412,7 @@ void DoPitBuilder() void DoMergePatches() { + UndoableCommand undo("bobToolz.mergePatch"); patch_merge_t merge_info; DPatch mrgPatches[2]; int i; @@ -447,19 +424,19 @@ void DoMergePatches() return; } - scene::Node* patches[2]; - patches[0] = GlobalSelectionSystem().ultimateSelected().path().top(); - patches[1] = GlobalSelectionSystem().penultimateSelected().path().top(); + scene::Instance* patches[2]; + patches[0] = &GlobalSelectionSystem().ultimateSelected(); + patches[1] = &GlobalSelectionSystem().penultimateSelected(); for (i = 0; i < 2; i++) { - if (!patches[i]->m_patch) + if (!Node_isPatch(patches[i]->path().top())) { DoMessageBox("You must select ONLY patches", "Error", eMB_OK); return; } - mrgPatches[0].LoadFromBrush(patches[i]); + mrgPatches[i].LoadFromPatch(*patches[i]); } /* mrgPatches[0].Transpose(); @@ -470,9 +447,9 @@ void DoMergePatches() if (merge_info.mergable) { - Sys_Printf("%i %i", merge_info.pos1, merge_info.pos2); + globalOutputStream() << merge_info.pos1 << " " << merge_info.pos2; - Sys_Printf("Patches Mergable\n"); + globalOutputStream() << "Patches Mergable\n"; DPatch* newPatch = mrgPatches[0].MergePatches(merge_info, &mrgPatches[0], &mrgPatches[1]); /* mrgPatches[0].RemoveFromRadiant(); @@ -488,16 +465,22 @@ void DoMergePatches() { } else { - mrgPatches[0].RemoveFromRadiant(); - mrgPatches[1].RemoveFromRadiant(); + Path_deleteTop(patches[0]->path()); + Path_deleteTop(patches[1]->path()); newPatch->BuildInRadiant(); delete newPatch; } } + else + { + globalOutputStream() << "bobToolz.mergePatch: the selected patches are not mergable\n"; + } } void DoSplitPatch() { + UndoableCommand undo("bobToolz.splitPatch"); + DPatch patch; // ensure we have something selected @@ -507,21 +490,21 @@ void DoSplitPatch() { return; } - scene::Node* node = GlobalSelectionSystem().ultimateSelected().path().top(); + scene::Instance& instance = GlobalSelectionSystem().ultimateSelected(); - if( !node->m_patch ) { + if( !Node_isPatch(instance.path().top()) ) { DoMessageBox("You must select ONLY patches", "Error", eMB_OK); return; } - patch.LoadFromBrush(node); + patch.LoadFromPatch(instance); - list patchList = patch.Split( true, true ); - for(list::iterator patches = patchList.begin(); patches != patchList.end(); patches++) { + std::list patchList = patch.Split( true, true ); + for(std::list::iterator patches = patchList.begin(); patches != patchList.end(); patches++) { (*patches).BuildInRadiant(); } - patch.RemoveFromRadiant(); + Path_deleteTop(instance.path()); } void DoVisAnalyse() @@ -544,7 +527,7 @@ void DoVisAnalyse() return; } - scene::Node* brush = GlobalSelectionSystem().ultimateSelected().path().top(); + scene::Instance& brush = GlobalSelectionSystem().ultimateSelected(); DBrush orgBrush; orgBrush.LoadFromBrush(brush, false); @@ -556,7 +539,7 @@ void DoVisAnalyse() origin[2] = (orgBrush.bbox_max[2] + orgBrush.bbox_min[2])/2.f; - const char* rad_filename = g_FuncTable.m_pfnGetMapName(); + const char* rad_filename = GlobalRadiant().getMapName(); if(!rad_filename) { DoMessageBox("An Error Occurred While Trying\n To Get The Map Filename", "Error", eMB_OK); @@ -568,12 +551,11 @@ void DoVisAnalyse() char* ext = strrchr(filename, '.')+1; strcpy(ext, "bsp");// rename the extension - list *pointList = BuildTrace(filename, origin); + std::list *pointList = BuildTrace(filename, origin); if(!g_VisView) { g_VisView = new DVisDrawer; - g_VisView->Register(); } g_VisView->SetList(pointList); @@ -589,6 +571,7 @@ void DoTrainPathPlot() { } void DoCaulkSelection() { + UndoableCommand undo("bobToolz.caulkSelection"); DEntity world; float fScale[2] = { 0.5f, 0.5f }; @@ -603,6 +586,7 @@ void DoCaulkSelection() { } void DoTreePlanter() { + UndoableCommand undo("bobToolz.treePlanter"); if(g_TreePlanter) { delete g_TreePlanter; g_TreePlanter = NULL; @@ -613,12 +597,14 @@ void DoTreePlanter() { } void DoDropEnts() { + UndoableCommand undo("bobToolz.dropEntities"); if(g_TreePlanter) { g_TreePlanter->DropEntsToGround(); } } void DoMakeChain() { + UndoableCommand undo("bobToolz.makeChain"); DTreePlanter pl; pl.MakeChain(); } @@ -628,6 +614,7 @@ typedef DPoint* pntTripple[3]; bool bFacesNoTop[6] = {true, true, true, true, true, false}; void DoFlipTerrain() { + UndoableCommand undo("bobToolz.flipTerrain"); vec3_t vUp = { 0.f, 0.f, 1.f }; int i; @@ -638,15 +625,15 @@ void DoFlipTerrain() { return; } - scene::Node* brushes[2]; - brushes[0] = GlobalSelectionSystem().ultimateSelected().path().top(); - brushes[1] = GlobalSelectionSystem().penultimateSelected().path().top(); + scene::Instance* brushes[2]; + brushes[0] = &GlobalSelectionSystem().ultimateSelected(); + brushes[1] = &GlobalSelectionSystem().penultimateSelected(); DBrush Brushes[2]; DPlane* Planes[2]; pntTripple Points[2]; for( i = 0; i < 2; i++ ) { - Brushes[i].LoadFromBrush( brushes[i], false ); + Brushes[i].LoadFromBrush( *brushes[i], false ); if(!(Planes[i] = Brushes[i].FindPlaneWithClosestNormal( vUp )) || Brushes[i].FindPointsForPlane( Planes[i], Points[i], 3 ) != 3) { DoMessageBox("Error", "Error", eMB_OK); return; @@ -657,14 +644,6 @@ void DoFlipTerrain() { Brushes[0].GetBounds( mins1, maxs1 ); Brushes[1].GetBounds( mins2, maxs2 ); - scene::Node* ents[2]; - ents[0] = GlobalSelectionSystem().ultimateSelected().path().parent(); - ents[1] = GlobalSelectionSystem().penultimateSelected().path().parent(); - - for( i = 0; i < 2; i++ ) { - Brushes[i].RemoveFromRadiant(); - } - int dontmatch[2] = { -1, -1 }; @@ -783,7 +762,8 @@ void DoFlipTerrain() { for( i = 0; i < 2; i++ ) { newBrushes[i]->RemoveRedundantPlanes(); - newBrushes[i]->BuildInRadiant( false, NULL, ents[i] ); + newBrushes[i]->BuildInRadiant( false, NULL, brushes[i]->path().parent().get_pointer() ); + Path_deleteTop(brushes[i]->path()); delete newBrushes[i]; }