From 866929d75e92d9156ff762d040585029a0ace573 Mon Sep 17 00:00:00 2001 From: Omar Aglan Date: Tue, 28 Jul 2026 13:00:42 +0300 Subject: [PATCH] unify(worldbuilder): Move WorldBuilder to Core --- Core/Tools/CMakeLists.txt | 1 + Core/Tools/WorldBuilder/CMakeLists.txt | 231 ++ .../WorldBuilder/include/AutoEdgeOutTool.h | 0 .../WorldBuilder/include/BaseBuildProps.h | 0 .../WorldBuilder/include/BlendEdgeTool.h | 0 .../WorldBuilder/include/BlendMaterial.h | 0 .../Tools/WorldBuilder/include/BorderTool.h | 0 .../Tools/WorldBuilder/include/BrushTool.h | 0 .../Tools/WorldBuilder/include/BuildList.h | 0 .../WorldBuilder/include/BuildListTool.h | 0 .../WorldBuilder/include/CButtonShowColor.h | 0 .../include/CFixTeamOwnerDialog.h | 0 .../Tools/WorldBuilder/include/CUndoable.h | 0 .../WorldBuilder/include/CameraOptions.h | 0 .../Tools/WorldBuilder/include/CellWidth.h | 0 .../WorldBuilder/include/ContourOptions.h | 0 .../Tools/WorldBuilder/include/DrawObject.h | 0 .../Tools/WorldBuilder/include/EditAction.h | 0 .../WorldBuilder/include/EditCondition.h | 0 .../WorldBuilder/include/EditCoordParameter.h | 0 .../Tools/WorldBuilder/include/EditGroup.h | 0 .../include/EditObjectParameter.h | 0 .../WorldBuilder/include/EditParameter.h | 0 .../include/ExportScriptsOptions.h | 0 .../WorldBuilder/include/EyedropperTool.h | 0 .../WorldBuilder/include/FeatherOptions.h | 0 .../Tools/WorldBuilder/include/FeatherTool.h | 0 .../Tools/WorldBuilder/include/FenceOptions.h | 0 .../Tools/WorldBuilder/include/FenceTool.h | 0 .../WorldBuilder/include/FloodFillTool.h | 0 .../WorldBuilder/include/GlobalLightOptions.h | 0 .../Tools/WorldBuilder/include/GroveOptions.h | 0 .../Tools/WorldBuilder/include/GroveTool.h | 0 .../WorldBuilder/include/HandScrollTool.h | 0 .../WorldBuilder/include/ImpassableOptions.h | 0 .../Tools/WorldBuilder/include/LayersList.h | 0 .../Tools/WorldBuilder/include/LightOptions.h | 0 .../Tools/WorldBuilder/include/MainFrm.h | 0 .../Tools/WorldBuilder/include/MapPreview.h | 0 .../Tools/WorldBuilder/include/MapSettings.h | 0 .../WorldBuilder/include/MeshMoldOptions.h | 0 .../Tools/WorldBuilder/include/MeshMoldTool.h | 0 .../Tools/WorldBuilder/include/MoundOptions.h | 0 .../Tools/WorldBuilder/include/MoundTool.h | 0 .../Tools/WorldBuilder/include/MyToolbar.h | 0 .../Tools/WorldBuilder/include/NewHeightMap.h | 0 .../WorldBuilder/include/ObjectOptions.h | 0 .../WorldBuilder/include/ObjectPreview.h | 0 .../Tools/WorldBuilder/include/ObjectTool.h | 0 .../Tools/WorldBuilder/include/OpenMap.h | 0 .../Tools/WorldBuilder/include/OptionsPanel.h | 0 .../WorldBuilder/include/PickUnitDialog.h | 0 .../Tools/WorldBuilder/include/PointerTool.h | 0 .../Tools/WorldBuilder/include/PolygonTool.h | 0 .../Tools/WorldBuilder/include/RampOptions.h | 0 .../Tools/WorldBuilder/include/RampTool.h | 0 .../Tools/WorldBuilder/include/RoadOptions.h | 0 .../Tools/WorldBuilder/include/RoadTool.h | 0 .../Tools/WorldBuilder/include/RulerOptions.h | 0 .../Tools/WorldBuilder/include/RulerTool.h | 0 .../Tools/WorldBuilder/include/SaveMap.h | 0 .../WorldBuilder/include/ScorchOptions.h | 0 .../Tools/WorldBuilder/include/ScorchTool.h | 0 .../WorldBuilder/include/ScriptActionsFalse.h | 0 .../WorldBuilder/include/ScriptActionsTrue.h | 0 .../WorldBuilder/include/ScriptConditions.h | 0 .../Tools/WorldBuilder/include/ScriptDialog.h | 0 .../WorldBuilder/include/ScriptProperties.h | 0 .../WorldBuilder/include/SelectMacrotexture.h | 0 .../WorldBuilder/include/ShadowOptions.h | 0 .../Tools/WorldBuilder/include/SplashScreen.h | 0 .../Tools/WorldBuilder/include/StdAfx.h | 0 .../Tools/WorldBuilder/include/TeamBehavior.h | 0 .../Tools/WorldBuilder/include/TeamGeneric.h | 0 .../Tools/WorldBuilder/include/TeamIdentity.h | 0 .../include/TeamObjectProperties.h | 0 .../WorldBuilder/include/TeamReinforcement.h | 0 .../WorldBuilder/include/TerrainMaterial.h | 0 .../Tools/WorldBuilder/include/TerrainModal.h | 0 .../WorldBuilder/include/TerrainSwatches.h | 0 .../Tools/WorldBuilder/include/TileTool.h | 0 .../Tools/WorldBuilder/include/Tool.h | 0 .../Tools/WorldBuilder/include/WBFrameWnd.h | 0 .../Tools/WorldBuilder/include/WBHeightMap.h | 0 .../WorldBuilder/include/WBPopupSlider.h | 0 .../WorldBuilder/include/WHeightMapEdit.h | 0 .../Tools/WorldBuilder/include/WaterOptions.h | 0 .../Tools/WorldBuilder/include/WaterTool.h | 0 .../WorldBuilder/include/WaypointOptions.h | 0 .../Tools/WorldBuilder/include/WaypointTool.h | 0 .../Tools/WorldBuilder/include/WorldBuilder.h | 0 .../WorldBuilder/include/WorldBuilderDoc.h | 0 .../WorldBuilder/include/WorldBuilderView.h | 0 .../WorldBuilder/include/addplayerdialog.h | 0 .../Tools/WorldBuilder/include/brushoptions.h | 0 .../WorldBuilder/include/mapobjectprops.h | 0 .../WorldBuilder/include/playerlistdlg.h | 0 .../Tools/WorldBuilder/include/propedit.h | 0 .../Tools/WorldBuilder/include/teamsdialog.h | 0 .../Tools/WorldBuilder/include/wbview.h | 0 .../Tools/WorldBuilder/include/wbview3d.h | 0 .../Tools/WorldBuilder/res/IDB_DownArrow.bmp | Bin .../WorldBuilder/res/IDB_ROAD_CORNERS.bmp | Bin .../WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur | Bin .../Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur | Bin .../WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur | Bin .../Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur | Bin .../WorldBuilder/res/IDC_BUILD_POINTER.cur | Bin .../WorldBuilder/res/IDC_BUILD_ROTATE.cur | Bin .../Tools/WorldBuilder/res/IDC_CLIFF.cur | Bin .../Tools/WorldBuilder/res/IDC_EYEDROPPER.cur | Bin .../Tools/WorldBuilder/res/IDC_FENCE.cur | Bin .../Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur | Bin .../Tools/WorldBuilder/res/IDC_GROVE.cur | Bin .../WorldBuilder/res/IDC_HAND_SCROLL.cur | Bin .../WorldBuilder/res/IDC_MOLD_POINTER.cur | Bin .../WorldBuilder/res/IDC_MOVE_POINTER.cur | Bin .../WorldBuilder/res/IDC_PLACE_OBJECT.cur | Bin .../Tools/WorldBuilder/res/IDC_POINTER.cur | Bin .../Tools/WorldBuilder/res/IDC_POLYGON.cur | Bin .../WorldBuilder/res/IDC_POLYGON_MOVE.cur | Bin .../WorldBuilder/res/IDC_POLYGON_PLUS.cur | Bin .../Tools/WorldBuilder/res/IDC_RAMP.cur | Bin .../Tools/WorldBuilder/res/IDC_ROAD.cur | Bin .../Tools/WorldBuilder/res/IDC_ROTATE.cur | Bin .../Tools/WorldBuilder/res/IDC_Scorch.cur | Bin .../Tools/WorldBuilder/res/IDC_WATER.cur | Bin .../Tools/WorldBuilder/res/IDC_WATER_MOVE.cur | Bin .../Tools/WorldBuilder/res/IDC_WATER_PLUS.cur | Bin .../Tools/WorldBuilder/res/IDC_WAYPOINT.cur | Bin .../Tools/WorldBuilder/res/IDI_Hide.ico | Bin .../Tools/WorldBuilder/res/IDI_Show.ico | Bin .../Tools/WorldBuilder/res/IDI_Thumb.ico | Bin .../Tools/WorldBuilder/res/TileTool.cur | Bin .../Tools/WorldBuilder/res/Toolbar.bmp | Bin .../Tools/WorldBuilder/res/WorldBuilder.ico | Bin .../Tools/WorldBuilder/res/WorldBuilder.rc | 6 +- .../Tools/WorldBuilder/res/WorldBuilder.rc2 | 0 .../WorldBuilder/res/WorldBuilderDoc.ico | Bin .../Tools/WorldBuilder/res/WorldBuilderV.bmp | Bin .../Tools/WorldBuilder/res/WorldBuilderZH.bmp | Bin .../Tools/WorldBuilder/res/cross.cur | Bin .../Tools/WorldBuilder/res/folder.bmp | Bin .../Tools/WorldBuilder/res/foldersc.bmp | Bin .../Tools/WorldBuilder/res/icon2.ico | Bin .../Tools/WorldBuilder/res/resource.h | 0 .../Tools/WorldBuilder/res/toolbar1.bmp | Bin .../Tools/WorldBuilder/res/toolbar2.bmp | Bin .../WorldBuilder/src/AutoEdgeOutTool.cpp | 0 .../Tools/WorldBuilder/src/BaseBuildProps.cpp | 0 .../Tools/WorldBuilder/src/BlendEdgeTool.cpp | 0 .../Tools/WorldBuilder/src/BlendMaterial.cpp | 0 .../Tools/WorldBuilder/src/BorderTool.cpp | 0 .../Tools/WorldBuilder/src/BrushTool.cpp | 0 .../Tools/WorldBuilder/src/BuildList.cpp | 0 .../Tools/WorldBuilder/src/BuildListTool.cpp | 0 .../WorldBuilder/src/CButtonShowColor.cpp | 0 .../WorldBuilder/src/CFixTeamOwnerDialog.cpp | 0 .../Tools/WorldBuilder/src/CUndoable.cpp | 0 .../Tools/WorldBuilder/src/CameraOptions.cpp | 0 .../Tools/WorldBuilder/src/CellWidth.cpp | 0 .../Tools/WorldBuilder/src/ContourOptions.cpp | 0 .../Tools/WorldBuilder/src/DrawObject.cpp | 0 .../Tools/WorldBuilder/src/EditAction.cpp | 0 .../Tools/WorldBuilder/src/EditCondition.cpp | 0 .../WorldBuilder/src/EditCoordParameter.cpp | 0 .../Tools/WorldBuilder/src/EditGroup.cpp | 0 .../WorldBuilder/src/EditObjectParameter.cpp | 0 .../Tools/WorldBuilder/src/EditParameter.cpp | 0 .../WorldBuilder/src/ExportScriptsOptions.cpp | 0 .../Tools/WorldBuilder/src/EyedropperTool.cpp | 0 .../Tools/WorldBuilder/src/FeatherOptions.cpp | 0 .../Tools/WorldBuilder/src/FeatherTool.cpp | 0 .../Tools/WorldBuilder/src/FenceOptions.cpp | 0 .../Tools/WorldBuilder/src/FenceTool.cpp | 0 .../Tools/WorldBuilder/src/FloodFillTool.cpp | 0 .../WorldBuilder/src/GlobalLightOptions.cpp | 0 .../Tools/WorldBuilder/src/GroveOptions.cpp | 0 .../Tools/WorldBuilder/src/GroveTool.cpp | 0 .../Tools/WorldBuilder/src/HandScrollTool.cpp | 0 .../WorldBuilder/src/ImpassableOptions.cpp | 0 .../Tools/WorldBuilder/src/LayersList.cpp | 0 .../Tools/WorldBuilder/src/LightOptions.cpp | 0 .../Tools/WorldBuilder/src/MainFrm.cpp | 0 .../Tools/WorldBuilder/src/MapPreview.cpp | 0 .../Tools/WorldBuilder/src/MapSettings.cpp | 0 .../WorldBuilder/src/MeshMoldOptions.cpp | 0 .../Tools/WorldBuilder/src/MeshMoldTool.cpp | 0 .../Tools/WorldBuilder/src/MoundOptions.cpp | 0 .../Tools/WorldBuilder/src/MoundTool.cpp | 0 .../Tools/WorldBuilder/src/MyToolbar.cpp | 0 .../Tools/WorldBuilder/src/NewHeightMap.cpp | 0 .../Tools/WorldBuilder/src/ObjectOptions.cpp | 0 .../Tools/WorldBuilder/src/ObjectPreview.cpp | 0 .../Tools/WorldBuilder/src/ObjectTool.cpp | 0 .../Tools/WorldBuilder/src/OpenMap.cpp | 0 .../Tools/WorldBuilder/src/OptionsPanel.cpp | 0 .../Tools/WorldBuilder/src/PickUnitDialog.cpp | 0 .../Tools/WorldBuilder/src/PointerTool.cpp | 0 .../Tools/WorldBuilder/src/PolygonTool.cpp | 0 .../Tools/WorldBuilder/src/RampOptions.cpp | 0 .../Tools/WorldBuilder/src/RampTool.cpp | 0 .../Tools/WorldBuilder/src/RoadOptions.cpp | 0 .../Tools/WorldBuilder/src/RoadTool.cpp | 0 .../Tools/WorldBuilder/src/RulerOptions.cpp | 0 .../Tools/WorldBuilder/src/RulerTool.cpp | 0 .../Tools/WorldBuilder/src/SaveMap.cpp | 0 .../Tools/WorldBuilder/src/ScorchOptions.cpp | 0 .../Tools/WorldBuilder/src/ScorchTool.cpp | 0 .../WorldBuilder/src/ScriptActionsFalse.cpp | 0 .../WorldBuilder/src/ScriptActionsTrue.cpp | 0 .../WorldBuilder/src/ScriptConditions.cpp | 0 .../Tools/WorldBuilder/src/ScriptDialog.cpp | 0 .../WorldBuilder/src/ScriptProperties.cpp | 0 .../WorldBuilder/src/SelectMacrotexture.cpp | 0 .../Tools/WorldBuilder/src/ShadowOptions.cpp | 0 .../Tools/WorldBuilder/src/SplashScreen.cpp | 0 .../Tools/WorldBuilder/src/StdAfx.cpp | 0 .../Tools/WorldBuilder/src/TeamBehavior.cpp | 0 .../Tools/WorldBuilder/src/TeamGeneric.cpp | 0 .../Tools/WorldBuilder/src/TeamIdentity.cpp | 0 .../WorldBuilder/src/TeamObjectProperties.cpp | 0 .../WorldBuilder/src/TeamReinforcement.cpp | 0 .../WorldBuilder/src/TerrainMaterial.cpp | 0 .../Tools/WorldBuilder/src/TerrainModal.cpp | 0 .../WorldBuilder/src/TerrainSwatches.cpp | 0 .../Tools/WorldBuilder/src/TileTool.cpp | 0 .../Tools/WorldBuilder/src/Tool.cpp | 0 .../Tools/WorldBuilder/src/WBFrameWnd.cpp | 0 .../Tools/WorldBuilder/src/WBHeightMap.cpp | 0 .../Tools/WorldBuilder/src/WBPopupSlider.cpp | 0 .../Tools/WorldBuilder/src/WHeightMapEdit.cpp | 0 .../Tools/WorldBuilder/src/WaterOptions.cpp | 0 .../Tools/WorldBuilder/src/WaterTool.cpp | 0 .../WorldBuilder/src/WaypointOptions.cpp | 0 .../Tools/WorldBuilder/src/WaypointTool.cpp | 0 .../Tools/WorldBuilder/src/WorldBuilder.cpp | 0 .../WorldBuilder/src/WorldBuilderDoc.cpp | 0 .../WorldBuilder/src/WorldBuilderView.cpp | 0 .../WorldBuilder/src/addplayerdialog.cpp | 0 .../Tools/WorldBuilder/src/brushoptions.cpp | 0 .../Tools/WorldBuilder/src/mapobjectprops.cpp | 0 .../Tools/WorldBuilder/src/playerlistdlg.cpp | 0 .../Tools/WorldBuilder/src/propedit.cpp | 0 .../Tools/WorldBuilder/src/teamsdialog.cpp | 0 .../Tools/WorldBuilder/src/wbview.cpp | 0 .../Tools/WorldBuilder/src/wbview3d.cpp | 0 .../Code/Tools/WorldBuilder/CMakeLists.txt | 229 +- .../Code/Tools/WorldBuilder/CMakeLists.txt | 225 +- .../WorldBuilder/include/AutoEdgeOutTool.h | 42 - .../WorldBuilder/include/BaseBuildProps.h | 72 - .../WorldBuilder/include/BlendEdgeTool.h | 46 - .../WorldBuilder/include/BlendMaterial.h | 86 - .../Tools/WorldBuilder/include/BorderTool.h | 48 - .../Tools/WorldBuilder/include/BrushTool.h | 63 - .../Tools/WorldBuilder/include/BuildList.h | 107 - .../WorldBuilder/include/BuildListTool.h | 77 - .../WorldBuilder/include/CButtonShowColor.h | 41 - .../include/CFixTeamOwnerDialog.h | 45 - .../Tools/WorldBuilder/include/CUndoable.h | 410 -- .../WorldBuilder/include/CameraOptions.h | 88 - .../Tools/WorldBuilder/include/CellWidth.h | 63 - .../WorldBuilder/include/ContourOptions.h | 84 - .../Tools/WorldBuilder/include/DrawObject.h | 190 - .../Tools/WorldBuilder/include/EditAction.h | 79 - .../WorldBuilder/include/EditCondition.h | 85 - .../WorldBuilder/include/EditCoordParameter.h | 70 - .../Tools/WorldBuilder/include/EditGroup.h | 63 - .../include/EditObjectParameter.h | 74 - .../WorldBuilder/include/EditParameter.h | 131 - .../include/ExportScriptsOptions.h | 73 - .../WorldBuilder/include/EyedropperTool.h | 42 - .../WorldBuilder/include/FeatherOptions.h | 93 - .../Tools/WorldBuilder/include/FeatherTool.h | 55 - .../Tools/WorldBuilder/include/FenceOptions.h | 94 - .../Tools/WorldBuilder/include/FenceTool.h | 56 - .../WorldBuilder/include/FloodFillTool.h | 50 - .../WorldBuilder/include/GlobalLightOptions.h | 137 - .../Tools/WorldBuilder/include/GroveOptions.h | 77 - .../Tools/WorldBuilder/include/GroveTool.h | 60 - .../WorldBuilder/include/HandScrollTool.h | 52 - .../WorldBuilder/include/ImpassableOptions.h | 45 - .../Tools/WorldBuilder/include/LayersList.h | 185 - .../Tools/WorldBuilder/include/LightOptions.h | 76 - .../Code/Tools/WorldBuilder/include/MainFrm.h | 155 - .../Tools/WorldBuilder/include/MapPreview.h | 83 - .../Tools/WorldBuilder/include/MapSettings.h | 63 - .../WorldBuilder/include/MeshMoldOptions.h | 112 - .../Tools/WorldBuilder/include/MeshMoldTool.h | 64 - .../Tools/WorldBuilder/include/MoundOptions.h | 98 - .../Tools/WorldBuilder/include/MoundTool.h | 71 - .../Tools/WorldBuilder/include/MyToolbar.h | 44 - .../Tools/WorldBuilder/include/NewHeightMap.h | 83 - .../WorldBuilder/include/ObjectOptions.h | 103 - .../WorldBuilder/include/ObjectPreview.h | 70 - .../Tools/WorldBuilder/include/ObjectTool.h | 52 - .../Code/Tools/WorldBuilder/include/OpenMap.h | 74 - .../Tools/WorldBuilder/include/OptionsPanel.h | 66 - .../WorldBuilder/include/PickUnitDialog.h | 110 - .../Tools/WorldBuilder/include/PointerTool.h | 76 - .../Tools/WorldBuilder/include/PolygonTool.h | 83 - .../Tools/WorldBuilder/include/RampOptions.h | 62 - .../Tools/WorldBuilder/include/RampTool.h | 64 - .../Tools/WorldBuilder/include/RoadOptions.h | 105 - .../Tools/WorldBuilder/include/RoadTool.h | 57 - .../Tools/WorldBuilder/include/RulerOptions.h | 73 - .../Tools/WorldBuilder/include/RulerTool.h | 55 - .../Code/Tools/WorldBuilder/include/SaveMap.h | 76 - .../WorldBuilder/include/ScorchOptions.h | 92 - .../Tools/WorldBuilder/include/ScorchTool.h | 50 - .../WorldBuilder/include/ScriptActionsFalse.h | 86 - .../WorldBuilder/include/ScriptActionsTrue.h | 86 - .../WorldBuilder/include/ScriptConditions.h | 91 - .../Tools/WorldBuilder/include/ScriptDialog.h | 165 - .../WorldBuilder/include/ScriptProperties.h | 83 - .../WorldBuilder/include/SelectMacrotexture.h | 63 - .../WorldBuilder/include/ShadowOptions.h | 69 - .../Tools/WorldBuilder/include/SplashScreen.h | 39 - .../Code/Tools/WorldBuilder/include/StdAfx.h | 46 - .../Tools/WorldBuilder/include/TeamBehavior.h | 78 - .../Tools/WorldBuilder/include/TeamGeneric.h | 47 - .../Tools/WorldBuilder/include/TeamIdentity.h | 96 - .../include/TeamObjectProperties.h | 106 - .../WorldBuilder/include/TeamReinforcement.h | 68 - .../WorldBuilder/include/TerrainMaterial.h | 111 - .../Tools/WorldBuilder/include/TerrainModal.h | 80 - .../WorldBuilder/include/TerrainSwatches.h | 64 - .../Tools/WorldBuilder/include/TileTool.h | 68 - .../Code/Tools/WorldBuilder/include/Tool.h | 87 - .../Tools/WorldBuilder/include/WBFrameWnd.h | 100 - .../Tools/WorldBuilder/include/WBHeightMap.h | 52 - .../WorldBuilder/include/WBPopupSlider.h | 178 - .../WorldBuilder/include/WHeightMapEdit.h | 165 - .../Tools/WorldBuilder/include/WaterOptions.h | 102 - .../Tools/WorldBuilder/include/WaterTool.h | 61 - .../WorldBuilder/include/WaypointOptions.h | 92 - .../Tools/WorldBuilder/include/WaypointTool.h | 57 - .../Tools/WorldBuilder/include/WorldBuilder.h | 195 - .../WorldBuilder/include/WorldBuilderDoc.h | 210 - .../WorldBuilder/include/WorldBuilderView.h | 158 - .../WorldBuilder/include/addplayerdialog.h | 69 - .../Tools/WorldBuilder/include/brushoptions.h | 95 - .../WorldBuilder/include/mapobjectprops.h | 209 - .../WorldBuilder/include/playerlistdlg.h | 86 - .../Tools/WorldBuilder/include/propedit.h | 71 - .../Tools/WorldBuilder/include/teamsdialog.h | 95 - .../Code/Tools/WorldBuilder/include/wbview.h | 253 -- .../Tools/WorldBuilder/include/wbview3d.h | 335 -- .../Tools/WorldBuilder/res/IDB_DownArrow.bmp | Bin 134 -> 0 bytes .../WorldBuilder/res/IDB_ROAD_CORNERS.bmp | Bin 502 -> 0 bytes .../WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_BUILD_POINTER.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_BUILD_ROTATE.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_CLIFF.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_EYEDROPPER.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_FENCE.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_GROVE.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_HAND_SCROLL.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_MOLD_POINTER.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_MOVE_POINTER.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_PLACE_OBJECT.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_POINTER.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_POLYGON.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_POLYGON_MOVE.cur | Bin 326 -> 0 bytes .../WorldBuilder/res/IDC_POLYGON_PLUS.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_RAMP.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_ROAD.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_ROTATE.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_Scorch.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDC_WATER.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_WATER_MOVE.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_WATER_PLUS.cur | Bin 326 -> 0 bytes .../Tools/WorldBuilder/res/IDC_WAYPOINT.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDI_Hide.ico | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDI_Show.ico | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/IDI_Thumb.ico | Bin 166 -> 0 bytes .../Code/Tools/WorldBuilder/res/TileTool.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/Toolbar.bmp | Bin 4318 -> 0 bytes .../Tools/WorldBuilder/res/WorldBuilder.ico | Bin 25214 -> 0 bytes .../Tools/WorldBuilder/res/WorldBuilder.rc | 2908 -------------- .../Tools/WorldBuilder/res/WorldBuilder.rc2 | 13 - .../WorldBuilder/res/WorldBuilderDoc.ico | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/cross.cur | Bin 326 -> 0 bytes .../Code/Tools/WorldBuilder/res/folder.bmp | Bin 758 -> 0 bytes .../Code/Tools/WorldBuilder/res/foldersc.bmp | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/icon2.ico | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/resource.h | 777 ---- .../Code/Tools/WorldBuilder/res/toolbar1.bmp | Bin 1078 -> 0 bytes .../Code/Tools/WorldBuilder/res/toolbar2.bmp | Bin 2158 -> 0 bytes .../WorldBuilder/src/AutoEdgeOutTool.cpp | 78 - .../Tools/WorldBuilder/src/BaseBuildProps.cpp | 127 - .../Tools/WorldBuilder/src/BlendEdgeTool.cpp | 91 - .../Tools/WorldBuilder/src/BlendMaterial.cpp | 283 -- .../Tools/WorldBuilder/src/BorderTool.cpp | 173 - .../Code/Tools/WorldBuilder/src/BrushTool.cpp | 203 - .../Code/Tools/WorldBuilder/src/BuildList.cpp | 789 ---- .../Tools/WorldBuilder/src/BuildListTool.cpp | 280 -- .../WorldBuilder/src/CButtonShowColor.cpp | 76 - .../WorldBuilder/src/CFixTeamOwnerDialog.cpp | 105 - .../Code/Tools/WorldBuilder/src/CUndoable.cpp | 1445 ------- .../Tools/WorldBuilder/src/CameraOptions.cpp | 328 -- .../Code/Tools/WorldBuilder/src/CellWidth.cpp | 83 - .../Tools/WorldBuilder/src/ContourOptions.cpp | 160 - .../Tools/WorldBuilder/src/DrawObject.cpp | 2510 ------------ .../Tools/WorldBuilder/src/EditAction.cpp | 455 --- .../Tools/WorldBuilder/src/EditCondition.cpp | 477 --- .../WorldBuilder/src/EditCoordParameter.cpp | 120 - .../Code/Tools/WorldBuilder/src/EditGroup.cpp | 84 - .../WorldBuilder/src/EditObjectParameter.cpp | 286 -- .../Tools/WorldBuilder/src/EditParameter.cpp | 2402 ------------ .../WorldBuilder/src/ExportScriptsOptions.cpp | 98 - .../Tools/WorldBuilder/src/EyedropperTool.cpp | 74 - .../Tools/WorldBuilder/src/FeatherOptions.cpp | 236 -- .../Tools/WorldBuilder/src/FeatherTool.cpp | 248 -- .../Tools/WorldBuilder/src/FenceOptions.cpp | 410 -- .../Code/Tools/WorldBuilder/src/FenceTool.cpp | 216 -- .../Tools/WorldBuilder/src/FloodFillTool.cpp | 120 - .../WorldBuilder/src/GlobalLightOptions.cpp | 966 ----- .../Tools/WorldBuilder/src/GroveOptions.cpp | 492 --- .../Code/Tools/WorldBuilder/src/GroveTool.cpp | 432 --- .../Tools/WorldBuilder/src/HandScrollTool.cpp | 142 - .../WorldBuilder/src/ImpassableOptions.cpp | 111 - .../Tools/WorldBuilder/src/LayersList.cpp | 1362 ------- .../Tools/WorldBuilder/src/LightOptions.cpp | 214 - .../Code/Tools/WorldBuilder/src/MainFrm.cpp | 527 --- .../Tools/WorldBuilder/src/MapPreview.cpp | 431 --- .../Tools/WorldBuilder/src/MapSettings.cpp | 166 - .../WorldBuilder/src/MeshMoldOptions.cpp | 387 -- .../Tools/WorldBuilder/src/MeshMoldTool.cpp | 276 -- .../Tools/WorldBuilder/src/MoundOptions.cpp | 282 -- .../Code/Tools/WorldBuilder/src/MoundTool.cpp | 248 -- .../Code/Tools/WorldBuilder/src/MyToolbar.cpp | 105 - .../Tools/WorldBuilder/src/NewHeightMap.cpp | 227 -- .../Tools/WorldBuilder/src/ObjectOptions.cpp | 834 ---- .../Tools/WorldBuilder/src/ObjectPreview.cpp | 320 -- .../Tools/WorldBuilder/src/ObjectTool.cpp | 170 - .../Code/Tools/WorldBuilder/src/OpenMap.cpp | 187 - .../Tools/WorldBuilder/src/OptionsPanel.cpp | 110 - .../Tools/WorldBuilder/src/PickUnitDialog.cpp | 406 -- .../Tools/WorldBuilder/src/PointerTool.cpp | 550 --- .../Tools/WorldBuilder/src/PolygonTool.cpp | 470 --- .../Tools/WorldBuilder/src/RampOptions.cpp | 87 - .../Code/Tools/WorldBuilder/src/RampTool.cpp | 187 - .../Tools/WorldBuilder/src/RoadOptions.cpp | 610 --- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 341 -- .../Tools/WorldBuilder/src/RulerOptions.cpp | 131 - .../Code/Tools/WorldBuilder/src/RulerTool.cpp | 187 - .../Code/Tools/WorldBuilder/src/SaveMap.cpp | 225 -- .../Tools/WorldBuilder/src/ScorchOptions.cpp | 268 -- .../Tools/WorldBuilder/src/ScorchTool.cpp | 149 - .../WorldBuilder/src/ScriptActionsFalse.cpp | 277 -- .../WorldBuilder/src/ScriptActionsTrue.cpp | 277 -- .../WorldBuilder/src/ScriptConditions.cpp | 444 --- .../Tools/WorldBuilder/src/ScriptDialog.cpp | 2164 ----------- .../WorldBuilder/src/ScriptProperties.cpp | 214 - .../WorldBuilder/src/SelectMacrotexture.cpp | 142 - .../Tools/WorldBuilder/src/ShadowOptions.cpp | 193 - .../Tools/WorldBuilder/src/SplashScreen.cpp | 94 - .../Code/Tools/WorldBuilder/src/StdAfx.cpp | 26 - .../Tools/WorldBuilder/src/TeamBehavior.cpp | 269 -- .../Tools/WorldBuilder/src/TeamGeneric.cpp | 241 -- .../Tools/WorldBuilder/src/TeamIdentity.cpp | 595 --- .../WorldBuilder/src/TeamObjectProperties.cpp | 684 ---- .../WorldBuilder/src/TeamReinforcement.cpp | 190 - .../WorldBuilder/src/TerrainMaterial.cpp | 554 --- .../Tools/WorldBuilder/src/TerrainModal.cpp | 300 -- .../WorldBuilder/src/TerrainSwatches.cpp | 116 - .../Code/Tools/WorldBuilder/src/TileTool.cpp | 205 - .../Code/Tools/WorldBuilder/src/Tool.cpp | 151 - .../Tools/WorldBuilder/src/WBFrameWnd.cpp | 178 - .../Tools/WorldBuilder/src/WBHeightMap.cpp | 314 -- .../Tools/WorldBuilder/src/WBPopupSlider.cpp | 592 --- .../Tools/WorldBuilder/src/WHeightMapEdit.cpp | 3448 ----------------- .../Tools/WorldBuilder/src/WaterOptions.cpp | 511 --- .../Code/Tools/WorldBuilder/src/WaterTool.cpp | 536 --- .../WorldBuilder/src/WaypointOptions.cpp | 573 --- .../Tools/WorldBuilder/src/WaypointTool.cpp | 208 - .../Tools/WorldBuilder/src/WorldBuilder.cpp | 715 ---- .../WorldBuilder/src/WorldBuilderDoc.cpp | 2659 ------------- .../WorldBuilder/src/WorldBuilderView.cpp | 1083 ------ .../WorldBuilder/src/addplayerdialog.cpp | 132 - .../Tools/WorldBuilder/src/brushoptions.cpp | 283 -- .../Tools/WorldBuilder/src/mapobjectprops.cpp | 2892 -------------- .../Tools/WorldBuilder/src/playerlistdlg.cpp | 890 ----- .../Code/Tools/WorldBuilder/src/propedit.cpp | 176 - .../Tools/WorldBuilder/src/teamsdialog.cpp | 643 --- .../Code/Tools/WorldBuilder/src/wbview.cpp | 1085 ------ .../Code/Tools/WorldBuilder/src/wbview3d.cpp | 3310 ---------------- 492 files changed, 240 insertions(+), 64287 deletions(-) create mode 100644 Core/Tools/WorldBuilder/CMakeLists.txt rename {Generals/Code => Core}/Tools/WorldBuilder/include/AutoEdgeOutTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BaseBuildProps.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BlendEdgeTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BlendMaterial.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BorderTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BrushTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BuildList.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/BuildListTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/CButtonShowColor.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/CUndoable.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/CameraOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/CellWidth.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ContourOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/DrawObject.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditAction.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditCondition.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditCoordParameter.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditGroup.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditObjectParameter.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EditParameter.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ExportScriptsOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/EyedropperTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/FeatherOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/FeatherTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/FenceOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/FenceTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/FloodFillTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/GlobalLightOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/GroveOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/GroveTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/HandScrollTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ImpassableOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/LayersList.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/LightOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MainFrm.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MapPreview.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MapSettings.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MeshMoldOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MeshMoldTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MoundOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MoundTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/MyToolbar.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/NewHeightMap.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ObjectOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ObjectPreview.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ObjectTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/OpenMap.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/OptionsPanel.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/PickUnitDialog.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/PointerTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/PolygonTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RampOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RampTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RoadOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RoadTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RulerOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/RulerTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/SaveMap.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScorchOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScorchTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScriptActionsFalse.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScriptActionsTrue.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScriptConditions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScriptDialog.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ScriptProperties.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/SelectMacrotexture.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/ShadowOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/SplashScreen.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/StdAfx.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TeamBehavior.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TeamGeneric.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TeamIdentity.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TeamObjectProperties.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TeamReinforcement.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TerrainMaterial.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TerrainModal.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TerrainSwatches.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/TileTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/Tool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WBFrameWnd.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WBHeightMap.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WBPopupSlider.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WHeightMapEdit.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WaterOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WaterTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WaypointOptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WaypointTool.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WorldBuilder.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WorldBuilderDoc.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/WorldBuilderView.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/addplayerdialog.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/brushoptions.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/mapobjectprops.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/playerlistdlg.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/propedit.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/teamsdialog.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/wbview.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/include/wbview3d.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDB_DownArrow.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_CLIFF.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_FENCE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_GROVE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_POINTER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_POLYGON.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_RAMP.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_ROAD.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_ROTATE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_Scorch.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_WATER.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDC_WAYPOINT.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDI_Hide.ico (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDI_Show.ico (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/IDI_Thumb.ico (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/TileTool.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/Toolbar.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/WorldBuilder.ico (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/WorldBuilder.rc (99%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/WorldBuilder.rc2 (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/WorldBuilderDoc.ico (100%) rename Generals/Code/Tools/WorldBuilder/res/WorldBuilder.bmp => Core/Tools/WorldBuilder/res/WorldBuilderV.bmp (100%) rename GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.bmp => Core/Tools/WorldBuilder/res/WorldBuilderZH.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/cross.cur (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/folder.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/foldersc.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/icon2.ico (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/resource.h (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/toolbar1.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/res/toolbar2.bmp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BaseBuildProps.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BlendEdgeTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BlendMaterial.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BorderTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BrushTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BuildList.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/BuildListTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/CButtonShowColor.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/CUndoable.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/CameraOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/CellWidth.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ContourOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/DrawObject.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditAction.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditCondition.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditCoordParameter.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditGroup.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditObjectParameter.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EditParameter.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ExportScriptsOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/EyedropperTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/FeatherOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/FeatherTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/FenceOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/FenceTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/FloodFillTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/GlobalLightOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/GroveOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/GroveTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/HandScrollTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ImpassableOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/LayersList.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/LightOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MainFrm.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MapPreview.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MapSettings.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MeshMoldOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MeshMoldTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MoundOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MoundTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/MyToolbar.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/NewHeightMap.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ObjectOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ObjectPreview.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ObjectTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/OpenMap.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/OptionsPanel.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/PickUnitDialog.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/PointerTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/PolygonTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RampOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RampTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RoadOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RoadTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RulerOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/RulerTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/SaveMap.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScorchOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScorchTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScriptActionsFalse.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScriptActionsTrue.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScriptConditions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScriptDialog.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ScriptProperties.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/SelectMacrotexture.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/ShadowOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/SplashScreen.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/StdAfx.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TeamBehavior.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TeamGeneric.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TeamIdentity.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TeamObjectProperties.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TeamReinforcement.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TerrainMaterial.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TerrainModal.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TerrainSwatches.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/TileTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/Tool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WBFrameWnd.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WBHeightMap.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WBPopupSlider.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WHeightMapEdit.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WaterOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WaterTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WaypointOptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WaypointTool.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WorldBuilder.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WorldBuilderDoc.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/WorldBuilderView.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/addplayerdialog.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/brushoptions.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/mapobjectprops.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/playerlistdlg.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/propedit.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/teamsdialog.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/wbview.cpp (100%) rename {Generals/Code => Core}/Tools/WorldBuilder/src/wbview3d.cpp (100%) delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BaseBuildProps.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BlendEdgeTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BlendMaterial.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BorderTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BrushTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BuildList.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/BuildListTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/CButtonShowColor.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/CUndoable.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/CameraOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/CellWidth.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ContourOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/DrawObject.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditAction.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditCondition.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditCoordParameter.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditGroup.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditObjectParameter.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EditParameter.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/EyedropperTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/FeatherOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/FeatherTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/FenceOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/FenceTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/FloodFillTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/GlobalLightOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/GroveOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/GroveTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/HandScrollTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ImpassableOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/LayersList.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/LightOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MainFrm.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MapPreview.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MapSettings.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MoundOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MoundTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/MyToolbar.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/NewHeightMap.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ObjectOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ObjectPreview.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ObjectTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/OpenMap.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/OptionsPanel.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/PickUnitDialog.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/PointerTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/PolygonTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RampOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RampTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RoadOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RoadTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RulerOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/RulerTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/SaveMap.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScorchOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScorchTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScriptConditions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScriptDialog.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ScriptProperties.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/SelectMacrotexture.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/ShadowOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/SplashScreen.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/StdAfx.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TeamBehavior.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TeamGeneric.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TeamIdentity.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TeamObjectProperties.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TeamReinforcement.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TerrainMaterial.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TerrainModal.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TerrainSwatches.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/TileTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/Tool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WBFrameWnd.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WBHeightMap.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WBPopupSlider.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WaterOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WaterTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WaypointOptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WaypointTool.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilder.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderView.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/addplayerdialog.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/brushoptions.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/mapobjectprops.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/playerlistdlg.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/propedit.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/teamsdialog.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/wbview.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/include/wbview3d.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDB_DownArrow.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_CLIFF.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_FENCE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_GROVE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POINTER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_RAMP.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_ROAD.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_ROTATE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_Scorch.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WAYPOINT.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDI_Hide.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDI_Show.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/IDI_Thumb.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/TileTool.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/Toolbar.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.rc delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilderDoc.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/cross.cur delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/folder.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/foldersc.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/icon2.ico delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/resource.h delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/toolbar1.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/res/toolbar2.bmp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BlendMaterial.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BorderTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BrushTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/BuildListTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/CUndoable.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/CameraOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/CellWidth.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ContourOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditAction.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditCondition.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditGroup.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EditParameter.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/EyedropperTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/FeatherOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/FeatherTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/FenceOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/FenceTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/FloodFillTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/GroveOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/GroveTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/HandScrollTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/LayersList.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/LightOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MainFrm.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MapPreview.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MapSettings.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MoundOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MoundTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/MyToolbar.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ObjectPreview.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ObjectTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/OptionsPanel.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/PointerTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/PolygonTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RampOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RulerOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/RulerTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScorchOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScorchTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScriptConditions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ScriptProperties.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/ShadowOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/SplashScreen.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/StdAfx.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TeamBehavior.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TeamIdentity.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TerrainModal.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/TileTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/Tool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WBHeightMap.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WaterOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WaterTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WaypointOptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WaypointTool.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/addplayerdialog.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/brushoptions.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/mapobjectprops.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/propedit.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/teamsdialog.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/wbview.cpp delete mode 100644 GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp diff --git a/Core/Tools/CMakeLists.txt b/Core/Tools/CMakeLists.txt index 0175ddaf1c7..074136d4c0b 100644 --- a/Core/Tools/CMakeLists.txt +++ b/Core/Tools/CMakeLists.txt @@ -27,6 +27,7 @@ if(RTS_BUILD_GENERALS_TOOLS OR RTS_BUILD_ZEROHOUR_TOOLS) add_subdirectory(ImagePacker) add_subdirectory(MapCacheBuilder) add_subdirectory(W3DView) + add_subdirectory(WorldBuilder) endif() # Add library interfaces here diff --git a/Core/Tools/WorldBuilder/CMakeLists.txt b/Core/Tools/WorldBuilder/CMakeLists.txt new file mode 100644 index 00000000000..4140258957e --- /dev/null +++ b/Core/Tools/WorldBuilder/CMakeLists.txt @@ -0,0 +1,231 @@ +set(WORLDBUILDER_SRC + "src/addplayerdialog.cpp" + "src/AutoEdgeOutTool.cpp" + "src/BaseBuildProps.cpp" + "src/BlendEdgeTool.cpp" + "src/BlendMaterial.cpp" + "src/BorderTool.cpp" + "src/brushoptions.cpp" + "src/BrushTool.cpp" + "src/BuildList.cpp" + "src/BuildListTool.cpp" + "src/CameraOptions.cpp" + "src/CButtonShowColor.cpp" + "src/CellWidth.cpp" + "src/CFixTeamOwnerDialog.cpp" + "src/ContourOptions.cpp" + "src/CUndoable.cpp" + "src/DrawObject.cpp" + "src/EditAction.cpp" + "src/EditCondition.cpp" + "src/EditCoordParameter.cpp" + "src/EditGroup.cpp" + "src/EditObjectParameter.cpp" + "src/EditParameter.cpp" + "src/ExportScriptsOptions.cpp" + "src/EyedropperTool.cpp" + "src/FeatherOptions.cpp" + "src/FeatherTool.cpp" + "src/FenceOptions.cpp" + "src/FenceTool.cpp" + "src/FloodFillTool.cpp" + "src/GlobalLightOptions.cpp" + "src/GroveOptions.cpp" + "src/GroveTool.cpp" + "src/HandScrollTool.cpp" + "src/ImpassableOptions.cpp" + "src/LayersList.cpp" + "src/LightOptions.cpp" + "src/MainFrm.cpp" + "src/mapobjectprops.cpp" + "src/MapPreview.cpp" + "src/MapSettings.cpp" + "src/MeshMoldOptions.cpp" + "src/MeshMoldTool.cpp" + "src/MoundOptions.cpp" + "src/MoundTool.cpp" + "src/MyToolbar.cpp" + "src/NewHeightMap.cpp" + "src/ObjectOptions.cpp" + "src/ObjectPreview.cpp" + "src/ObjectTool.cpp" + "src/OpenMap.cpp" + "src/OptionsPanel.cpp" + "src/PickUnitDialog.cpp" + "src/playerlistdlg.cpp" + "src/PointerTool.cpp" + "src/PolygonTool.cpp" + "src/propedit.cpp" + "src/RampOptions.cpp" + "src/RampTool.cpp" + "src/RoadOptions.cpp" + "src/RoadTool.cpp" + "src/RulerOptions.cpp" + "src/RulerTool.cpp" + "src/SaveMap.cpp" + "src/ScorchOptions.cpp" + "src/ScorchTool.cpp" + "src/ScriptActionsFalse.cpp" + "src/ScriptActionsTrue.cpp" + "src/ScriptConditions.cpp" + "src/ScriptDialog.cpp" + "src/ScriptProperties.cpp" + "src/SelectMacrotexture.cpp" + "src/ShadowOptions.cpp" + "src/SplashScreen.cpp" + "src/StdAfx.cpp" + "src/TeamBehavior.cpp" + "src/TeamGeneric.cpp" + "src/TeamIdentity.cpp" + "src/TeamObjectProperties.cpp" + "src/TeamReinforcement.cpp" + "src/teamsdialog.cpp" + "src/TerrainMaterial.cpp" + "src/TerrainModal.cpp" + "src/TerrainSwatches.cpp" + "src/TileTool.cpp" + "src/Tool.cpp" + "src/WaterOptions.cpp" + "src/WaterTool.cpp" + "src/WaypointOptions.cpp" + "src/WaypointTool.cpp" + "src/WBFrameWnd.cpp" + "src/WBHeightMap.cpp" + "src/WBPopupSlider.cpp" + "src/wbview.cpp" + "src/wbview3d.cpp" + "src/WHeightMapEdit.cpp" + "src/WorldBuilder.cpp" + "src/WorldBuilderDoc.cpp" + "src/WorldBuilderView.cpp" + "include/addplayerdialog.h" + "include/AutoEdgeOutTool.h" + "include/BaseBuildProps.h" + "include/BlendEdgeTool.h" + "include/BlendMaterial.h" + "include/BorderTool.h" + "include/brushoptions.h" + "include/BrushTool.h" + "include/BuildList.h" + "include/BuildListTool.h" + "include/CameraOptions.h" + "include/CButtonShowColor.h" + "include/CellWidth.h" + "include/CFixTeamOwnerDialog.h" + "include/ContourOptions.h" + "include/CUndoable.h" + "include/DrawObject.h" + "include/EditAction.h" + "include/EditCondition.h" + "include/EditCoordParameter.h" + "include/EditGroup.h" + "include/EditObjectParameter.h" + "include/EditParameter.h" + "include/ExportScriptsOptions.h" + "include/EyedropperTool.h" + "include/FeatherOptions.h" + "include/FeatherTool.h" + "include/FenceOptions.h" + "include/FenceTool.h" + "include/FloodFillTool.h" + "include/GlobalLightOptions.h" + "include/GroveOptions.h" + "include/GroveTool.h" + "include/HandScrollTool.h" + "include/ImpassableOptions.h" + "include/LayersList.h" + "include/LightOptions.h" + "include/MainFrm.h" + "include/mapobjectprops.h" + "include/MapPreview.h" + "include/MapSettings.h" + "include/MeshMoldOptions.h" + "include/MeshMoldTool.h" + "include/MoundOptions.h" + "include/MoundTool.h" + "include/MyToolbar.h" + "include/NewHeightMap.h" + "include/ObjectOptions.h" + "include/ObjectPreview.h" + "include/ObjectTool.h" + "include/OpenMap.h" + "include/OptionsPanel.h" + "include/PickUnitDialog.h" + "include/playerlistdlg.h" + "include/PointerTool.h" + "include/PolygonTool.h" + "include/propedit.h" + "include/RampOptions.h" + "include/RampTool.h" + "include/RoadOptions.h" + "include/RoadTool.h" + "include/RulerOptions.h" + "include/RulerTool.h" + "include/SaveMap.h" + "include/ScorchOptions.h" + "include/ScorchTool.h" + "include/ScriptActionsFalse.h" + "include/ScriptActionsTrue.h" + "include/ScriptConditions.h" + "include/ScriptDialog.h" + "include/ScriptProperties.h" + "include/SelectMacrotexture.h" + "include/ShadowOptions.h" + "include/SplashScreen.h" + "include/StdAfx.h" + "include/TeamBehavior.h" + "include/TeamGeneric.h" + "include/TeamIdentity.h" + "include/TeamObjectProperties.h" + "include/TeamReinforcement.h" + "include/teamsdialog.h" + "include/TerrainMaterial.h" + "include/TerrainModal.h" + "include/TerrainSwatches.h" + "include/TileTool.h" + "include/Tool.h" + "include/WaterOptions.h" + "include/WaterTool.h" + "include/WaypointOptions.h" + "include/WaypointTool.h" + "include/WBFrameWnd.h" + "include/WBHeightMap.h" + "include/WBPopupSlider.h" + "include/wbview.h" + "include/wbview3d.h" + "include/WHeightMapEdit.h" + "include/WorldBuilder.h" + "include/WorldBuilderDoc.h" + "include/WorldBuilderView.h" +) + +add_library(corei_worldbuilder INTERFACE) + +target_sources(corei_worldbuilder INTERFACE ${WORLDBUILDER_SRC}) + +target_include_directories(corei_worldbuilder INTERFACE + ${CMAKE_CURRENT_SOURCE_DIR} + include + res +) + +target_precompile_headers(corei_worldbuilder INTERFACE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 + [["WWLib/always.h"]] + [["Common/STLTypedefs.h"]] + [["StdAfx.h"]] + [["WWLib/WWCommon.h"]] +) + +target_link_libraries(corei_worldbuilder INTERFACE + core_browserdispatch + d3d8lib + imm32 + vfw32 + winmm +) + +if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") + target_link_options(corei_worldbuilder INTERFACE /NODEFAULTLIB:libci.lib /NODEFAULTLIB:libc.lib) + target_sources(corei_worldbuilder INTERFACE res/WorldBuilder.rc) +endif() diff --git a/Generals/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h b/Core/Tools/WorldBuilder/include/AutoEdgeOutTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h rename to Core/Tools/WorldBuilder/include/AutoEdgeOutTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BaseBuildProps.h b/Core/Tools/WorldBuilder/include/BaseBuildProps.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BaseBuildProps.h rename to Core/Tools/WorldBuilder/include/BaseBuildProps.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BlendEdgeTool.h b/Core/Tools/WorldBuilder/include/BlendEdgeTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BlendEdgeTool.h rename to Core/Tools/WorldBuilder/include/BlendEdgeTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BlendMaterial.h b/Core/Tools/WorldBuilder/include/BlendMaterial.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BlendMaterial.h rename to Core/Tools/WorldBuilder/include/BlendMaterial.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BorderTool.h b/Core/Tools/WorldBuilder/include/BorderTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BorderTool.h rename to Core/Tools/WorldBuilder/include/BorderTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BrushTool.h b/Core/Tools/WorldBuilder/include/BrushTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BrushTool.h rename to Core/Tools/WorldBuilder/include/BrushTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BuildList.h b/Core/Tools/WorldBuilder/include/BuildList.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BuildList.h rename to Core/Tools/WorldBuilder/include/BuildList.h diff --git a/Generals/Code/Tools/WorldBuilder/include/BuildListTool.h b/Core/Tools/WorldBuilder/include/BuildListTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/BuildListTool.h rename to Core/Tools/WorldBuilder/include/BuildListTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/CButtonShowColor.h b/Core/Tools/WorldBuilder/include/CButtonShowColor.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/CButtonShowColor.h rename to Core/Tools/WorldBuilder/include/CButtonShowColor.h diff --git a/Generals/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h b/Core/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h rename to Core/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h diff --git a/Generals/Code/Tools/WorldBuilder/include/CUndoable.h b/Core/Tools/WorldBuilder/include/CUndoable.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/CUndoable.h rename to Core/Tools/WorldBuilder/include/CUndoable.h diff --git a/Generals/Code/Tools/WorldBuilder/include/CameraOptions.h b/Core/Tools/WorldBuilder/include/CameraOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/CameraOptions.h rename to Core/Tools/WorldBuilder/include/CameraOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/CellWidth.h b/Core/Tools/WorldBuilder/include/CellWidth.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/CellWidth.h rename to Core/Tools/WorldBuilder/include/CellWidth.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ContourOptions.h b/Core/Tools/WorldBuilder/include/ContourOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ContourOptions.h rename to Core/Tools/WorldBuilder/include/ContourOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/DrawObject.h b/Core/Tools/WorldBuilder/include/DrawObject.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/DrawObject.h rename to Core/Tools/WorldBuilder/include/DrawObject.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditAction.h b/Core/Tools/WorldBuilder/include/EditAction.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditAction.h rename to Core/Tools/WorldBuilder/include/EditAction.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditCondition.h b/Core/Tools/WorldBuilder/include/EditCondition.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditCondition.h rename to Core/Tools/WorldBuilder/include/EditCondition.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditCoordParameter.h b/Core/Tools/WorldBuilder/include/EditCoordParameter.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditCoordParameter.h rename to Core/Tools/WorldBuilder/include/EditCoordParameter.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditGroup.h b/Core/Tools/WorldBuilder/include/EditGroup.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditGroup.h rename to Core/Tools/WorldBuilder/include/EditGroup.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditObjectParameter.h b/Core/Tools/WorldBuilder/include/EditObjectParameter.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditObjectParameter.h rename to Core/Tools/WorldBuilder/include/EditObjectParameter.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EditParameter.h b/Core/Tools/WorldBuilder/include/EditParameter.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EditParameter.h rename to Core/Tools/WorldBuilder/include/EditParameter.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h b/Core/Tools/WorldBuilder/include/ExportScriptsOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h rename to Core/Tools/WorldBuilder/include/ExportScriptsOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/EyedropperTool.h b/Core/Tools/WorldBuilder/include/EyedropperTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/EyedropperTool.h rename to Core/Tools/WorldBuilder/include/EyedropperTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/FeatherOptions.h b/Core/Tools/WorldBuilder/include/FeatherOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/FeatherOptions.h rename to Core/Tools/WorldBuilder/include/FeatherOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/FeatherTool.h b/Core/Tools/WorldBuilder/include/FeatherTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/FeatherTool.h rename to Core/Tools/WorldBuilder/include/FeatherTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/FenceOptions.h b/Core/Tools/WorldBuilder/include/FenceOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/FenceOptions.h rename to Core/Tools/WorldBuilder/include/FenceOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/FenceTool.h b/Core/Tools/WorldBuilder/include/FenceTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/FenceTool.h rename to Core/Tools/WorldBuilder/include/FenceTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/FloodFillTool.h b/Core/Tools/WorldBuilder/include/FloodFillTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/FloodFillTool.h rename to Core/Tools/WorldBuilder/include/FloodFillTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/GlobalLightOptions.h b/Core/Tools/WorldBuilder/include/GlobalLightOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/GlobalLightOptions.h rename to Core/Tools/WorldBuilder/include/GlobalLightOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/GroveOptions.h b/Core/Tools/WorldBuilder/include/GroveOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/GroveOptions.h rename to Core/Tools/WorldBuilder/include/GroveOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/GroveTool.h b/Core/Tools/WorldBuilder/include/GroveTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/GroveTool.h rename to Core/Tools/WorldBuilder/include/GroveTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/HandScrollTool.h b/Core/Tools/WorldBuilder/include/HandScrollTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/HandScrollTool.h rename to Core/Tools/WorldBuilder/include/HandScrollTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ImpassableOptions.h b/Core/Tools/WorldBuilder/include/ImpassableOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ImpassableOptions.h rename to Core/Tools/WorldBuilder/include/ImpassableOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/LayersList.h b/Core/Tools/WorldBuilder/include/LayersList.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/LayersList.h rename to Core/Tools/WorldBuilder/include/LayersList.h diff --git a/Generals/Code/Tools/WorldBuilder/include/LightOptions.h b/Core/Tools/WorldBuilder/include/LightOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/LightOptions.h rename to Core/Tools/WorldBuilder/include/LightOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MainFrm.h b/Core/Tools/WorldBuilder/include/MainFrm.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MainFrm.h rename to Core/Tools/WorldBuilder/include/MainFrm.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MapPreview.h b/Core/Tools/WorldBuilder/include/MapPreview.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MapPreview.h rename to Core/Tools/WorldBuilder/include/MapPreview.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MapSettings.h b/Core/Tools/WorldBuilder/include/MapSettings.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MapSettings.h rename to Core/Tools/WorldBuilder/include/MapSettings.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MeshMoldOptions.h b/Core/Tools/WorldBuilder/include/MeshMoldOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MeshMoldOptions.h rename to Core/Tools/WorldBuilder/include/MeshMoldOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MeshMoldTool.h b/Core/Tools/WorldBuilder/include/MeshMoldTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MeshMoldTool.h rename to Core/Tools/WorldBuilder/include/MeshMoldTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MoundOptions.h b/Core/Tools/WorldBuilder/include/MoundOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MoundOptions.h rename to Core/Tools/WorldBuilder/include/MoundOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MoundTool.h b/Core/Tools/WorldBuilder/include/MoundTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MoundTool.h rename to Core/Tools/WorldBuilder/include/MoundTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/MyToolbar.h b/Core/Tools/WorldBuilder/include/MyToolbar.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/MyToolbar.h rename to Core/Tools/WorldBuilder/include/MyToolbar.h diff --git a/Generals/Code/Tools/WorldBuilder/include/NewHeightMap.h b/Core/Tools/WorldBuilder/include/NewHeightMap.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/NewHeightMap.h rename to Core/Tools/WorldBuilder/include/NewHeightMap.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ObjectOptions.h b/Core/Tools/WorldBuilder/include/ObjectOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ObjectOptions.h rename to Core/Tools/WorldBuilder/include/ObjectOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ObjectPreview.h b/Core/Tools/WorldBuilder/include/ObjectPreview.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ObjectPreview.h rename to Core/Tools/WorldBuilder/include/ObjectPreview.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ObjectTool.h b/Core/Tools/WorldBuilder/include/ObjectTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ObjectTool.h rename to Core/Tools/WorldBuilder/include/ObjectTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/OpenMap.h b/Core/Tools/WorldBuilder/include/OpenMap.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/OpenMap.h rename to Core/Tools/WorldBuilder/include/OpenMap.h diff --git a/Generals/Code/Tools/WorldBuilder/include/OptionsPanel.h b/Core/Tools/WorldBuilder/include/OptionsPanel.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/OptionsPanel.h rename to Core/Tools/WorldBuilder/include/OptionsPanel.h diff --git a/Generals/Code/Tools/WorldBuilder/include/PickUnitDialog.h b/Core/Tools/WorldBuilder/include/PickUnitDialog.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/PickUnitDialog.h rename to Core/Tools/WorldBuilder/include/PickUnitDialog.h diff --git a/Generals/Code/Tools/WorldBuilder/include/PointerTool.h b/Core/Tools/WorldBuilder/include/PointerTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/PointerTool.h rename to Core/Tools/WorldBuilder/include/PointerTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/PolygonTool.h b/Core/Tools/WorldBuilder/include/PolygonTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/PolygonTool.h rename to Core/Tools/WorldBuilder/include/PolygonTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RampOptions.h b/Core/Tools/WorldBuilder/include/RampOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RampOptions.h rename to Core/Tools/WorldBuilder/include/RampOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RampTool.h b/Core/Tools/WorldBuilder/include/RampTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RampTool.h rename to Core/Tools/WorldBuilder/include/RampTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RoadOptions.h b/Core/Tools/WorldBuilder/include/RoadOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RoadOptions.h rename to Core/Tools/WorldBuilder/include/RoadOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RoadTool.h b/Core/Tools/WorldBuilder/include/RoadTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RoadTool.h rename to Core/Tools/WorldBuilder/include/RoadTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RulerOptions.h b/Core/Tools/WorldBuilder/include/RulerOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RulerOptions.h rename to Core/Tools/WorldBuilder/include/RulerOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/RulerTool.h b/Core/Tools/WorldBuilder/include/RulerTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/RulerTool.h rename to Core/Tools/WorldBuilder/include/RulerTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/SaveMap.h b/Core/Tools/WorldBuilder/include/SaveMap.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/SaveMap.h rename to Core/Tools/WorldBuilder/include/SaveMap.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScorchOptions.h b/Core/Tools/WorldBuilder/include/ScorchOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScorchOptions.h rename to Core/Tools/WorldBuilder/include/ScorchOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScorchTool.h b/Core/Tools/WorldBuilder/include/ScorchTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScorchTool.h rename to Core/Tools/WorldBuilder/include/ScorchTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h b/Core/Tools/WorldBuilder/include/ScriptActionsFalse.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h rename to Core/Tools/WorldBuilder/include/ScriptActionsFalse.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h b/Core/Tools/WorldBuilder/include/ScriptActionsTrue.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h rename to Core/Tools/WorldBuilder/include/ScriptActionsTrue.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScriptConditions.h b/Core/Tools/WorldBuilder/include/ScriptConditions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScriptConditions.h rename to Core/Tools/WorldBuilder/include/ScriptConditions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScriptDialog.h b/Core/Tools/WorldBuilder/include/ScriptDialog.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScriptDialog.h rename to Core/Tools/WorldBuilder/include/ScriptDialog.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ScriptProperties.h b/Core/Tools/WorldBuilder/include/ScriptProperties.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ScriptProperties.h rename to Core/Tools/WorldBuilder/include/ScriptProperties.h diff --git a/Generals/Code/Tools/WorldBuilder/include/SelectMacrotexture.h b/Core/Tools/WorldBuilder/include/SelectMacrotexture.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/SelectMacrotexture.h rename to Core/Tools/WorldBuilder/include/SelectMacrotexture.h diff --git a/Generals/Code/Tools/WorldBuilder/include/ShadowOptions.h b/Core/Tools/WorldBuilder/include/ShadowOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/ShadowOptions.h rename to Core/Tools/WorldBuilder/include/ShadowOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/SplashScreen.h b/Core/Tools/WorldBuilder/include/SplashScreen.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/SplashScreen.h rename to Core/Tools/WorldBuilder/include/SplashScreen.h diff --git a/Generals/Code/Tools/WorldBuilder/include/StdAfx.h b/Core/Tools/WorldBuilder/include/StdAfx.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/StdAfx.h rename to Core/Tools/WorldBuilder/include/StdAfx.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TeamBehavior.h b/Core/Tools/WorldBuilder/include/TeamBehavior.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TeamBehavior.h rename to Core/Tools/WorldBuilder/include/TeamBehavior.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TeamGeneric.h b/Core/Tools/WorldBuilder/include/TeamGeneric.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TeamGeneric.h rename to Core/Tools/WorldBuilder/include/TeamGeneric.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TeamIdentity.h b/Core/Tools/WorldBuilder/include/TeamIdentity.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TeamIdentity.h rename to Core/Tools/WorldBuilder/include/TeamIdentity.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TeamObjectProperties.h b/Core/Tools/WorldBuilder/include/TeamObjectProperties.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TeamObjectProperties.h rename to Core/Tools/WorldBuilder/include/TeamObjectProperties.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TeamReinforcement.h b/Core/Tools/WorldBuilder/include/TeamReinforcement.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TeamReinforcement.h rename to Core/Tools/WorldBuilder/include/TeamReinforcement.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TerrainMaterial.h b/Core/Tools/WorldBuilder/include/TerrainMaterial.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TerrainMaterial.h rename to Core/Tools/WorldBuilder/include/TerrainMaterial.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TerrainModal.h b/Core/Tools/WorldBuilder/include/TerrainModal.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TerrainModal.h rename to Core/Tools/WorldBuilder/include/TerrainModal.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TerrainSwatches.h b/Core/Tools/WorldBuilder/include/TerrainSwatches.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TerrainSwatches.h rename to Core/Tools/WorldBuilder/include/TerrainSwatches.h diff --git a/Generals/Code/Tools/WorldBuilder/include/TileTool.h b/Core/Tools/WorldBuilder/include/TileTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/TileTool.h rename to Core/Tools/WorldBuilder/include/TileTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/Tool.h b/Core/Tools/WorldBuilder/include/Tool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/Tool.h rename to Core/Tools/WorldBuilder/include/Tool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WBFrameWnd.h b/Core/Tools/WorldBuilder/include/WBFrameWnd.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WBFrameWnd.h rename to Core/Tools/WorldBuilder/include/WBFrameWnd.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WBHeightMap.h b/Core/Tools/WorldBuilder/include/WBHeightMap.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WBHeightMap.h rename to Core/Tools/WorldBuilder/include/WBHeightMap.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WBPopupSlider.h b/Core/Tools/WorldBuilder/include/WBPopupSlider.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WBPopupSlider.h rename to Core/Tools/WorldBuilder/include/WBPopupSlider.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h b/Core/Tools/WorldBuilder/include/WHeightMapEdit.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WHeightMapEdit.h rename to Core/Tools/WorldBuilder/include/WHeightMapEdit.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WaterOptions.h b/Core/Tools/WorldBuilder/include/WaterOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WaterOptions.h rename to Core/Tools/WorldBuilder/include/WaterOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WaterTool.h b/Core/Tools/WorldBuilder/include/WaterTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WaterTool.h rename to Core/Tools/WorldBuilder/include/WaterTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WaypointOptions.h b/Core/Tools/WorldBuilder/include/WaypointOptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WaypointOptions.h rename to Core/Tools/WorldBuilder/include/WaypointOptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WaypointTool.h b/Core/Tools/WorldBuilder/include/WaypointTool.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WaypointTool.h rename to Core/Tools/WorldBuilder/include/WaypointTool.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WorldBuilder.h b/Core/Tools/WorldBuilder/include/WorldBuilder.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WorldBuilder.h rename to Core/Tools/WorldBuilder/include/WorldBuilder.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h b/Core/Tools/WorldBuilder/include/WorldBuilderDoc.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h rename to Core/Tools/WorldBuilder/include/WorldBuilderDoc.h diff --git a/Generals/Code/Tools/WorldBuilder/include/WorldBuilderView.h b/Core/Tools/WorldBuilder/include/WorldBuilderView.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/WorldBuilderView.h rename to Core/Tools/WorldBuilder/include/WorldBuilderView.h diff --git a/Generals/Code/Tools/WorldBuilder/include/addplayerdialog.h b/Core/Tools/WorldBuilder/include/addplayerdialog.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/addplayerdialog.h rename to Core/Tools/WorldBuilder/include/addplayerdialog.h diff --git a/Generals/Code/Tools/WorldBuilder/include/brushoptions.h b/Core/Tools/WorldBuilder/include/brushoptions.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/brushoptions.h rename to Core/Tools/WorldBuilder/include/brushoptions.h diff --git a/Generals/Code/Tools/WorldBuilder/include/mapobjectprops.h b/Core/Tools/WorldBuilder/include/mapobjectprops.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/mapobjectprops.h rename to Core/Tools/WorldBuilder/include/mapobjectprops.h diff --git a/Generals/Code/Tools/WorldBuilder/include/playerlistdlg.h b/Core/Tools/WorldBuilder/include/playerlistdlg.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/playerlistdlg.h rename to Core/Tools/WorldBuilder/include/playerlistdlg.h diff --git a/Generals/Code/Tools/WorldBuilder/include/propedit.h b/Core/Tools/WorldBuilder/include/propedit.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/propedit.h rename to Core/Tools/WorldBuilder/include/propedit.h diff --git a/Generals/Code/Tools/WorldBuilder/include/teamsdialog.h b/Core/Tools/WorldBuilder/include/teamsdialog.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/teamsdialog.h rename to Core/Tools/WorldBuilder/include/teamsdialog.h diff --git a/Generals/Code/Tools/WorldBuilder/include/wbview.h b/Core/Tools/WorldBuilder/include/wbview.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/wbview.h rename to Core/Tools/WorldBuilder/include/wbview.h diff --git a/Generals/Code/Tools/WorldBuilder/include/wbview3d.h b/Core/Tools/WorldBuilder/include/wbview3d.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/include/wbview3d.h rename to Core/Tools/WorldBuilder/include/wbview3d.h diff --git a/Generals/Code/Tools/WorldBuilder/res/IDB_DownArrow.bmp b/Core/Tools/WorldBuilder/res/IDB_DownArrow.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDB_DownArrow.bmp rename to Core/Tools/WorldBuilder/res/IDB_DownArrow.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp b/Core/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp rename to Core/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur b/Core/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur rename to Core/Tools/WorldBuilder/res/IDC_AUTO_EDGE_OUT.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur b/Core/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur rename to Core/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur b/Core/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur rename to Core/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur b/Core/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur rename to Core/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur b/Core/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur rename to Core/Tools/WorldBuilder/res/IDC_BUILD_POINTER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur b/Core/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur rename to Core/Tools/WorldBuilder/res/IDC_BUILD_ROTATE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_CLIFF.cur b/Core/Tools/WorldBuilder/res/IDC_CLIFF.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_CLIFF.cur rename to Core/Tools/WorldBuilder/res/IDC_CLIFF.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur b/Core/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur rename to Core/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_FENCE.cur b/Core/Tools/WorldBuilder/res/IDC_FENCE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_FENCE.cur rename to Core/Tools/WorldBuilder/res/IDC_FENCE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur b/Core/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur rename to Core/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_GROVE.cur b/Core/Tools/WorldBuilder/res/IDC_GROVE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_GROVE.cur rename to Core/Tools/WorldBuilder/res/IDC_GROVE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur b/Core/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur rename to Core/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur b/Core/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur rename to Core/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur b/Core/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur rename to Core/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur b/Core/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur rename to Core/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_POINTER.cur b/Core/Tools/WorldBuilder/res/IDC_POINTER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_POINTER.cur rename to Core/Tools/WorldBuilder/res/IDC_POINTER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON.cur b/Core/Tools/WorldBuilder/res/IDC_POLYGON.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON.cur rename to Core/Tools/WorldBuilder/res/IDC_POLYGON.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur b/Core/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur rename to Core/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur b/Core/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur rename to Core/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_RAMP.cur b/Core/Tools/WorldBuilder/res/IDC_RAMP.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_RAMP.cur rename to Core/Tools/WorldBuilder/res/IDC_RAMP.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_ROAD.cur b/Core/Tools/WorldBuilder/res/IDC_ROAD.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_ROAD.cur rename to Core/Tools/WorldBuilder/res/IDC_ROAD.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_ROTATE.cur b/Core/Tools/WorldBuilder/res/IDC_ROTATE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_ROTATE.cur rename to Core/Tools/WorldBuilder/res/IDC_ROTATE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_Scorch.cur b/Core/Tools/WorldBuilder/res/IDC_Scorch.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_Scorch.cur rename to Core/Tools/WorldBuilder/res/IDC_Scorch.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_WATER.cur b/Core/Tools/WorldBuilder/res/IDC_WATER.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_WATER.cur rename to Core/Tools/WorldBuilder/res/IDC_WATER.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur b/Core/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur rename to Core/Tools/WorldBuilder/res/IDC_WATER_MOVE.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur b/Core/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur rename to Core/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDC_WAYPOINT.cur b/Core/Tools/WorldBuilder/res/IDC_WAYPOINT.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDC_WAYPOINT.cur rename to Core/Tools/WorldBuilder/res/IDC_WAYPOINT.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/IDI_Hide.ico b/Core/Tools/WorldBuilder/res/IDI_Hide.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDI_Hide.ico rename to Core/Tools/WorldBuilder/res/IDI_Hide.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/IDI_Show.ico b/Core/Tools/WorldBuilder/res/IDI_Show.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDI_Show.ico rename to Core/Tools/WorldBuilder/res/IDI_Show.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/IDI_Thumb.ico b/Core/Tools/WorldBuilder/res/IDI_Thumb.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/IDI_Thumb.ico rename to Core/Tools/WorldBuilder/res/IDI_Thumb.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/TileTool.cur b/Core/Tools/WorldBuilder/res/TileTool.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/TileTool.cur rename to Core/Tools/WorldBuilder/res/TileTool.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/Toolbar.bmp b/Core/Tools/WorldBuilder/res/Toolbar.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/Toolbar.bmp rename to Core/Tools/WorldBuilder/res/Toolbar.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/WorldBuilder.ico b/Core/Tools/WorldBuilder/res/WorldBuilder.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/WorldBuilder.ico rename to Core/Tools/WorldBuilder/res/WorldBuilder.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/WorldBuilder.rc b/Core/Tools/WorldBuilder/res/WorldBuilder.rc similarity index 99% rename from Generals/Code/Tools/WorldBuilder/res/WorldBuilder.rc rename to Core/Tools/WorldBuilder/res/WorldBuilder.rc index 0918509c0ea..8f3155bfa40 100644 --- a/Generals/Code/Tools/WorldBuilder/res/WorldBuilder.rc +++ b/Core/Tools/WorldBuilder/res/WorldBuilder.rc @@ -84,7 +84,11 @@ IDB_DownArrow BITMAP DISCARDABLE "IDB_DownArrow.bmp" IDB_FOLDER BITMAP DISCARDABLE "folder.bmp" IDB_ROAD_CORNERS BITMAP DISCARDABLE "IDB_ROAD_CORNERS.bmp" IDB_FOLDERSCRIPT BITMAP DISCARDABLE "foldersc.bmp" -IDB_WORLDBUILDERSPLASH BITMAP DISCARDABLE "WorldBuilder.bmp" +#if RTS_GENERALS +IDB_WORLDBUILDERSPLASH BITMAP DISCARDABLE "WorldBuilderV.bmp" +#elif RTS_ZEROHOUR +IDB_WORLDBUILDERSPLASH BITMAP DISCARDABLE "WorldBuilderZH.bmp" +#endif ///////////////////////////////////////////////////////////////////////////// // diff --git a/Generals/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 b/Core/Tools/WorldBuilder/res/WorldBuilder.rc2 similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 rename to Core/Tools/WorldBuilder/res/WorldBuilder.rc2 diff --git a/Generals/Code/Tools/WorldBuilder/res/WorldBuilderDoc.ico b/Core/Tools/WorldBuilder/res/WorldBuilderDoc.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/WorldBuilderDoc.ico rename to Core/Tools/WorldBuilder/res/WorldBuilderDoc.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/WorldBuilder.bmp b/Core/Tools/WorldBuilder/res/WorldBuilderV.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/WorldBuilder.bmp rename to Core/Tools/WorldBuilder/res/WorldBuilderV.bmp diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.bmp b/Core/Tools/WorldBuilder/res/WorldBuilderZH.bmp similarity index 100% rename from GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.bmp rename to Core/Tools/WorldBuilder/res/WorldBuilderZH.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/cross.cur b/Core/Tools/WorldBuilder/res/cross.cur similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/cross.cur rename to Core/Tools/WorldBuilder/res/cross.cur diff --git a/Generals/Code/Tools/WorldBuilder/res/folder.bmp b/Core/Tools/WorldBuilder/res/folder.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/folder.bmp rename to Core/Tools/WorldBuilder/res/folder.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/foldersc.bmp b/Core/Tools/WorldBuilder/res/foldersc.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/foldersc.bmp rename to Core/Tools/WorldBuilder/res/foldersc.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/icon2.ico b/Core/Tools/WorldBuilder/res/icon2.ico similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/icon2.ico rename to Core/Tools/WorldBuilder/res/icon2.ico diff --git a/Generals/Code/Tools/WorldBuilder/res/resource.h b/Core/Tools/WorldBuilder/res/resource.h similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/resource.h rename to Core/Tools/WorldBuilder/res/resource.h diff --git a/Generals/Code/Tools/WorldBuilder/res/toolbar1.bmp b/Core/Tools/WorldBuilder/res/toolbar1.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/toolbar1.bmp rename to Core/Tools/WorldBuilder/res/toolbar1.bmp diff --git a/Generals/Code/Tools/WorldBuilder/res/toolbar2.bmp b/Core/Tools/WorldBuilder/res/toolbar2.bmp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/res/toolbar2.bmp rename to Core/Tools/WorldBuilder/res/toolbar2.bmp diff --git a/Generals/Code/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp b/Core/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp rename to Core/Tools/WorldBuilder/src/AutoEdgeOutTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp b/Core/Tools/WorldBuilder/src/BaseBuildProps.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp rename to Core/Tools/WorldBuilder/src/BaseBuildProps.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp b/Core/Tools/WorldBuilder/src/BlendEdgeTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp rename to Core/Tools/WorldBuilder/src/BlendEdgeTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BlendMaterial.cpp b/Core/Tools/WorldBuilder/src/BlendMaterial.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BlendMaterial.cpp rename to Core/Tools/WorldBuilder/src/BlendMaterial.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BorderTool.cpp b/Core/Tools/WorldBuilder/src/BorderTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BorderTool.cpp rename to Core/Tools/WorldBuilder/src/BorderTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BrushTool.cpp b/Core/Tools/WorldBuilder/src/BrushTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BrushTool.cpp rename to Core/Tools/WorldBuilder/src/BrushTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BuildList.cpp b/Core/Tools/WorldBuilder/src/BuildList.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BuildList.cpp rename to Core/Tools/WorldBuilder/src/BuildList.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/BuildListTool.cpp b/Core/Tools/WorldBuilder/src/BuildListTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/BuildListTool.cpp rename to Core/Tools/WorldBuilder/src/BuildListTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp b/Core/Tools/WorldBuilder/src/CButtonShowColor.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp rename to Core/Tools/WorldBuilder/src/CButtonShowColor.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp b/Core/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp rename to Core/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/CUndoable.cpp b/Core/Tools/WorldBuilder/src/CUndoable.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/CUndoable.cpp rename to Core/Tools/WorldBuilder/src/CUndoable.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/CameraOptions.cpp b/Core/Tools/WorldBuilder/src/CameraOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/CameraOptions.cpp rename to Core/Tools/WorldBuilder/src/CameraOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/CellWidth.cpp b/Core/Tools/WorldBuilder/src/CellWidth.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/CellWidth.cpp rename to Core/Tools/WorldBuilder/src/CellWidth.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ContourOptions.cpp b/Core/Tools/WorldBuilder/src/ContourOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ContourOptions.cpp rename to Core/Tools/WorldBuilder/src/ContourOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp b/Core/Tools/WorldBuilder/src/DrawObject.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp rename to Core/Tools/WorldBuilder/src/DrawObject.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditAction.cpp b/Core/Tools/WorldBuilder/src/EditAction.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditAction.cpp rename to Core/Tools/WorldBuilder/src/EditAction.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditCondition.cpp b/Core/Tools/WorldBuilder/src/EditCondition.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditCondition.cpp rename to Core/Tools/WorldBuilder/src/EditCondition.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp b/Core/Tools/WorldBuilder/src/EditCoordParameter.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp rename to Core/Tools/WorldBuilder/src/EditCoordParameter.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditGroup.cpp b/Core/Tools/WorldBuilder/src/EditGroup.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditGroup.cpp rename to Core/Tools/WorldBuilder/src/EditGroup.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp b/Core/Tools/WorldBuilder/src/EditObjectParameter.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp rename to Core/Tools/WorldBuilder/src/EditObjectParameter.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EditParameter.cpp b/Core/Tools/WorldBuilder/src/EditParameter.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EditParameter.cpp rename to Core/Tools/WorldBuilder/src/EditParameter.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp b/Core/Tools/WorldBuilder/src/ExportScriptsOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp rename to Core/Tools/WorldBuilder/src/ExportScriptsOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/EyedropperTool.cpp b/Core/Tools/WorldBuilder/src/EyedropperTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/EyedropperTool.cpp rename to Core/Tools/WorldBuilder/src/EyedropperTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/FeatherOptions.cpp b/Core/Tools/WorldBuilder/src/FeatherOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/FeatherOptions.cpp rename to Core/Tools/WorldBuilder/src/FeatherOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/FeatherTool.cpp b/Core/Tools/WorldBuilder/src/FeatherTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/FeatherTool.cpp rename to Core/Tools/WorldBuilder/src/FeatherTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/FenceOptions.cpp b/Core/Tools/WorldBuilder/src/FenceOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/FenceOptions.cpp rename to Core/Tools/WorldBuilder/src/FenceOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/FenceTool.cpp b/Core/Tools/WorldBuilder/src/FenceTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/FenceTool.cpp rename to Core/Tools/WorldBuilder/src/FenceTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/FloodFillTool.cpp b/Core/Tools/WorldBuilder/src/FloodFillTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/FloodFillTool.cpp rename to Core/Tools/WorldBuilder/src/FloodFillTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp b/Core/Tools/WorldBuilder/src/GlobalLightOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp rename to Core/Tools/WorldBuilder/src/GlobalLightOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/GroveOptions.cpp b/Core/Tools/WorldBuilder/src/GroveOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/GroveOptions.cpp rename to Core/Tools/WorldBuilder/src/GroveOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/GroveTool.cpp b/Core/Tools/WorldBuilder/src/GroveTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/GroveTool.cpp rename to Core/Tools/WorldBuilder/src/GroveTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/HandScrollTool.cpp b/Core/Tools/WorldBuilder/src/HandScrollTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/HandScrollTool.cpp rename to Core/Tools/WorldBuilder/src/HandScrollTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp b/Core/Tools/WorldBuilder/src/ImpassableOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp rename to Core/Tools/WorldBuilder/src/ImpassableOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/LayersList.cpp b/Core/Tools/WorldBuilder/src/LayersList.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/LayersList.cpp rename to Core/Tools/WorldBuilder/src/LayersList.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/LightOptions.cpp b/Core/Tools/WorldBuilder/src/LightOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/LightOptions.cpp rename to Core/Tools/WorldBuilder/src/LightOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MainFrm.cpp b/Core/Tools/WorldBuilder/src/MainFrm.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MainFrm.cpp rename to Core/Tools/WorldBuilder/src/MainFrm.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp b/Core/Tools/WorldBuilder/src/MapPreview.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp rename to Core/Tools/WorldBuilder/src/MapPreview.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MapSettings.cpp b/Core/Tools/WorldBuilder/src/MapSettings.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MapSettings.cpp rename to Core/Tools/WorldBuilder/src/MapSettings.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp b/Core/Tools/WorldBuilder/src/MeshMoldOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp rename to Core/Tools/WorldBuilder/src/MeshMoldOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp b/Core/Tools/WorldBuilder/src/MeshMoldTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp rename to Core/Tools/WorldBuilder/src/MeshMoldTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MoundOptions.cpp b/Core/Tools/WorldBuilder/src/MoundOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MoundOptions.cpp rename to Core/Tools/WorldBuilder/src/MoundOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MoundTool.cpp b/Core/Tools/WorldBuilder/src/MoundTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MoundTool.cpp rename to Core/Tools/WorldBuilder/src/MoundTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/MyToolbar.cpp b/Core/Tools/WorldBuilder/src/MyToolbar.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/MyToolbar.cpp rename to Core/Tools/WorldBuilder/src/MyToolbar.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp b/Core/Tools/WorldBuilder/src/NewHeightMap.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/NewHeightMap.cpp rename to Core/Tools/WorldBuilder/src/NewHeightMap.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp b/Core/Tools/WorldBuilder/src/ObjectOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp rename to Core/Tools/WorldBuilder/src/ObjectOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ObjectPreview.cpp b/Core/Tools/WorldBuilder/src/ObjectPreview.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ObjectPreview.cpp rename to Core/Tools/WorldBuilder/src/ObjectPreview.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ObjectTool.cpp b/Core/Tools/WorldBuilder/src/ObjectTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ObjectTool.cpp rename to Core/Tools/WorldBuilder/src/ObjectTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp b/Core/Tools/WorldBuilder/src/OpenMap.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp rename to Core/Tools/WorldBuilder/src/OpenMap.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/OptionsPanel.cpp b/Core/Tools/WorldBuilder/src/OptionsPanel.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/OptionsPanel.cpp rename to Core/Tools/WorldBuilder/src/OptionsPanel.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp b/Core/Tools/WorldBuilder/src/PickUnitDialog.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp rename to Core/Tools/WorldBuilder/src/PickUnitDialog.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/PointerTool.cpp b/Core/Tools/WorldBuilder/src/PointerTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/PointerTool.cpp rename to Core/Tools/WorldBuilder/src/PointerTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/PolygonTool.cpp b/Core/Tools/WorldBuilder/src/PolygonTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/PolygonTool.cpp rename to Core/Tools/WorldBuilder/src/PolygonTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RampOptions.cpp b/Core/Tools/WorldBuilder/src/RampOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RampOptions.cpp rename to Core/Tools/WorldBuilder/src/RampOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp b/Core/Tools/WorldBuilder/src/RampTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RampTool.cpp rename to Core/Tools/WorldBuilder/src/RampTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/Core/Tools/WorldBuilder/src/RoadOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp rename to Core/Tools/WorldBuilder/src/RoadOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp b/Core/Tools/WorldBuilder/src/RoadTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp rename to Core/Tools/WorldBuilder/src/RoadTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RulerOptions.cpp b/Core/Tools/WorldBuilder/src/RulerOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RulerOptions.cpp rename to Core/Tools/WorldBuilder/src/RulerOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/RulerTool.cpp b/Core/Tools/WorldBuilder/src/RulerTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/RulerTool.cpp rename to Core/Tools/WorldBuilder/src/RulerTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp b/Core/Tools/WorldBuilder/src/SaveMap.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp rename to Core/Tools/WorldBuilder/src/SaveMap.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScorchOptions.cpp b/Core/Tools/WorldBuilder/src/ScorchOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScorchOptions.cpp rename to Core/Tools/WorldBuilder/src/ScorchOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScorchTool.cpp b/Core/Tools/WorldBuilder/src/ScorchTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScorchTool.cpp rename to Core/Tools/WorldBuilder/src/ScorchTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp b/Core/Tools/WorldBuilder/src/ScriptActionsFalse.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp rename to Core/Tools/WorldBuilder/src/ScriptActionsFalse.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp b/Core/Tools/WorldBuilder/src/ScriptActionsTrue.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp rename to Core/Tools/WorldBuilder/src/ScriptActionsTrue.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScriptConditions.cpp b/Core/Tools/WorldBuilder/src/ScriptConditions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScriptConditions.cpp rename to Core/Tools/WorldBuilder/src/ScriptConditions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp b/Core/Tools/WorldBuilder/src/ScriptDialog.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp rename to Core/Tools/WorldBuilder/src/ScriptDialog.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ScriptProperties.cpp b/Core/Tools/WorldBuilder/src/ScriptProperties.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ScriptProperties.cpp rename to Core/Tools/WorldBuilder/src/ScriptProperties.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp b/Core/Tools/WorldBuilder/src/SelectMacrotexture.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp rename to Core/Tools/WorldBuilder/src/SelectMacrotexture.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/ShadowOptions.cpp b/Core/Tools/WorldBuilder/src/ShadowOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/ShadowOptions.cpp rename to Core/Tools/WorldBuilder/src/ShadowOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/SplashScreen.cpp b/Core/Tools/WorldBuilder/src/SplashScreen.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/SplashScreen.cpp rename to Core/Tools/WorldBuilder/src/SplashScreen.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/StdAfx.cpp b/Core/Tools/WorldBuilder/src/StdAfx.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/StdAfx.cpp rename to Core/Tools/WorldBuilder/src/StdAfx.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TeamBehavior.cpp b/Core/Tools/WorldBuilder/src/TeamBehavior.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TeamBehavior.cpp rename to Core/Tools/WorldBuilder/src/TeamBehavior.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp b/Core/Tools/WorldBuilder/src/TeamGeneric.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TeamGeneric.cpp rename to Core/Tools/WorldBuilder/src/TeamGeneric.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TeamIdentity.cpp b/Core/Tools/WorldBuilder/src/TeamIdentity.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TeamIdentity.cpp rename to Core/Tools/WorldBuilder/src/TeamIdentity.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp b/Core/Tools/WorldBuilder/src/TeamObjectProperties.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp rename to Core/Tools/WorldBuilder/src/TeamObjectProperties.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp b/Core/Tools/WorldBuilder/src/TeamReinforcement.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp rename to Core/Tools/WorldBuilder/src/TeamReinforcement.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp b/Core/Tools/WorldBuilder/src/TerrainMaterial.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp rename to Core/Tools/WorldBuilder/src/TerrainMaterial.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TerrainModal.cpp b/Core/Tools/WorldBuilder/src/TerrainModal.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TerrainModal.cpp rename to Core/Tools/WorldBuilder/src/TerrainModal.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp b/Core/Tools/WorldBuilder/src/TerrainSwatches.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp rename to Core/Tools/WorldBuilder/src/TerrainSwatches.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/TileTool.cpp b/Core/Tools/WorldBuilder/src/TileTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/TileTool.cpp rename to Core/Tools/WorldBuilder/src/TileTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/Tool.cpp b/Core/Tools/WorldBuilder/src/Tool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/Tool.cpp rename to Core/Tools/WorldBuilder/src/Tool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp b/Core/Tools/WorldBuilder/src/WBFrameWnd.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp rename to Core/Tools/WorldBuilder/src/WBFrameWnd.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WBHeightMap.cpp b/Core/Tools/WorldBuilder/src/WBHeightMap.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WBHeightMap.cpp rename to Core/Tools/WorldBuilder/src/WBHeightMap.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp b/Core/Tools/WorldBuilder/src/WBPopupSlider.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp rename to Core/Tools/WorldBuilder/src/WBPopupSlider.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp b/Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp rename to Core/Tools/WorldBuilder/src/WHeightMapEdit.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WaterOptions.cpp b/Core/Tools/WorldBuilder/src/WaterOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WaterOptions.cpp rename to Core/Tools/WorldBuilder/src/WaterOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WaterTool.cpp b/Core/Tools/WorldBuilder/src/WaterTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WaterTool.cpp rename to Core/Tools/WorldBuilder/src/WaterTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WaypointOptions.cpp b/Core/Tools/WorldBuilder/src/WaypointOptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WaypointOptions.cpp rename to Core/Tools/WorldBuilder/src/WaypointOptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WaypointTool.cpp b/Core/Tools/WorldBuilder/src/WaypointTool.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WaypointTool.cpp rename to Core/Tools/WorldBuilder/src/WaypointTool.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp b/Core/Tools/WorldBuilder/src/WorldBuilder.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp rename to Core/Tools/WorldBuilder/src/WorldBuilder.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp b/Core/Tools/WorldBuilder/src/WorldBuilderDoc.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp rename to Core/Tools/WorldBuilder/src/WorldBuilderDoc.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp b/Core/Tools/WorldBuilder/src/WorldBuilderView.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp rename to Core/Tools/WorldBuilder/src/WorldBuilderView.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/addplayerdialog.cpp b/Core/Tools/WorldBuilder/src/addplayerdialog.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/addplayerdialog.cpp rename to Core/Tools/WorldBuilder/src/addplayerdialog.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/brushoptions.cpp b/Core/Tools/WorldBuilder/src/brushoptions.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/brushoptions.cpp rename to Core/Tools/WorldBuilder/src/brushoptions.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/mapobjectprops.cpp b/Core/Tools/WorldBuilder/src/mapobjectprops.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/mapobjectprops.cpp rename to Core/Tools/WorldBuilder/src/mapobjectprops.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/playerlistdlg.cpp b/Core/Tools/WorldBuilder/src/playerlistdlg.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/playerlistdlg.cpp rename to Core/Tools/WorldBuilder/src/playerlistdlg.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/propedit.cpp b/Core/Tools/WorldBuilder/src/propedit.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/propedit.cpp rename to Core/Tools/WorldBuilder/src/propedit.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/teamsdialog.cpp b/Core/Tools/WorldBuilder/src/teamsdialog.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/teamsdialog.cpp rename to Core/Tools/WorldBuilder/src/teamsdialog.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/wbview.cpp b/Core/Tools/WorldBuilder/src/wbview.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/wbview.cpp rename to Core/Tools/WorldBuilder/src/wbview.cpp diff --git a/Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp b/Core/Tools/WorldBuilder/src/wbview3d.cpp similarity index 100% rename from Generals/Code/Tools/WorldBuilder/src/wbview3d.cpp rename to Core/Tools/WorldBuilder/src/wbview3d.cpp diff --git a/Generals/Code/Tools/WorldBuilder/CMakeLists.txt b/Generals/Code/Tools/WorldBuilder/CMakeLists.txt index 24fbc8605a0..8b814756751 100644 --- a/Generals/Code/Tools/WorldBuilder/CMakeLists.txt +++ b/Generals/Code/Tools/WorldBuilder/CMakeLists.txt @@ -1,240 +1,15 @@ -set(WORLDBUILDER_SRC - "src/addplayerdialog.cpp" - "src/AutoEdgeOutTool.cpp" - "src/BaseBuildProps.cpp" - "src/BlendEdgeTool.cpp" - "src/BlendMaterial.cpp" - "src/BorderTool.cpp" - "src/brushoptions.cpp" - "src/BrushTool.cpp" - "src/BuildList.cpp" - "src/BuildListTool.cpp" - "src/CameraOptions.cpp" - "src/CButtonShowColor.cpp" - "src/CellWidth.cpp" - "src/CFixTeamOwnerDialog.cpp" - "src/ContourOptions.cpp" - "src/CUndoable.cpp" - "src/DrawObject.cpp" - "src/EditAction.cpp" - "src/EditCondition.cpp" - "src/EditCoordParameter.cpp" - "src/EditGroup.cpp" - "src/EditObjectParameter.cpp" - "src/EditParameter.cpp" - "src/ExportScriptsOptions.cpp" - "src/EyedropperTool.cpp" - "src/FeatherOptions.cpp" - "src/FeatherTool.cpp" - "src/FenceOptions.cpp" - "src/FenceTool.cpp" - "src/FloodFillTool.cpp" - "src/GlobalLightOptions.cpp" - "src/GroveOptions.cpp" - "src/GroveTool.cpp" - "src/HandScrollTool.cpp" - "src/ImpassableOptions.cpp" - "src/LayersList.cpp" - "src/LightOptions.cpp" - "src/MainFrm.cpp" - "src/mapobjectprops.cpp" - "src/MapPreview.cpp" - "src/MapSettings.cpp" - "src/MeshMoldOptions.cpp" - "src/MeshMoldTool.cpp" - "src/MoundOptions.cpp" - "src/MoundTool.cpp" - "src/MyToolbar.cpp" - "src/NewHeightMap.cpp" - "src/ObjectOptions.cpp" - "src/ObjectPreview.cpp" - "src/ObjectTool.cpp" - "src/OpenMap.cpp" - "src/OptionsPanel.cpp" - "src/PickUnitDialog.cpp" - "src/playerlistdlg.cpp" - "src/PointerTool.cpp" - "src/PolygonTool.cpp" - "src/propedit.cpp" - "src/RampOptions.cpp" - "src/RampTool.cpp" - "src/RoadOptions.cpp" - "src/RoadTool.cpp" - "src/RulerOptions.cpp" - "src/RulerTool.cpp" - "src/SaveMap.cpp" - "src/ScorchOptions.cpp" - "src/ScorchTool.cpp" - "src/ScriptActionsFalse.cpp" - "src/ScriptActionsTrue.cpp" - "src/ScriptConditions.cpp" - "src/ScriptDialog.cpp" - "src/ScriptProperties.cpp" - "src/SelectMacrotexture.cpp" - "src/ShadowOptions.cpp" - "src/SplashScreen.cpp" - "src/StdAfx.cpp" - "src/TeamBehavior.cpp" - "src/TeamGeneric.cpp" - "src/TeamIdentity.cpp" - "src/TeamObjectProperties.cpp" - "src/TeamReinforcement.cpp" - "src/teamsdialog.cpp" - "src/TerrainMaterial.cpp" - "src/TerrainModal.cpp" - "src/TerrainSwatches.cpp" - "src/TileTool.cpp" - "src/Tool.cpp" - "src/WaterOptions.cpp" - "src/WaterTool.cpp" - "src/WaypointOptions.cpp" - "src/WaypointTool.cpp" - "src/WBFrameWnd.cpp" - "src/WBHeightMap.cpp" - "src/WBPopupSlider.cpp" - "src/wbview.cpp" - "src/wbview3d.cpp" - "src/WHeightMapEdit.cpp" - "src/WorldBuilder.cpp" - "src/WorldBuilderDoc.cpp" - "src/WorldBuilderView.cpp" - "include/addplayerdialog.h" - "include/AutoEdgeOutTool.h" - "include/BaseBuildProps.h" - "include/BlendEdgeTool.h" - "include/BlendMaterial.h" - "include/BorderTool.h" - "include/brushoptions.h" - "include/BrushTool.h" - "include/BuildList.h" - "include/BuildListTool.h" - "include/CameraOptions.h" - "include/CButtonShowColor.h" - "include/CellWidth.h" - "include/CFixTeamOwnerDialog.h" - "include/ContourOptions.h" - "include/CUndoable.h" - "include/DrawObject.h" - "include/EditAction.h" - "include/EditCondition.h" - "include/EditCoordParameter.h" - "include/EditGroup.h" - "include/EditObjectParameter.h" - "include/EditParameter.h" - "include/ExportScriptsOptions.h" - "include/EyedropperTool.h" - "include/FeatherOptions.h" - "include/FeatherTool.h" - "include/FenceOptions.h" - "include/FenceTool.h" - "include/FloodFillTool.h" - "include/GlobalLightOptions.h" - "include/GroveOptions.h" - "include/GroveTool.h" - "include/HandScrollTool.h" - "include/ImpassableOptions.h" - "include/LayersList.h" - "include/LightOptions.h" - "include/MainFrm.h" - "include/mapobjectprops.h" - "include/MapPreview.h" - "include/MapSettings.h" - "include/MeshMoldOptions.h" - "include/MeshMoldTool.h" - "include/MoundOptions.h" - "include/MoundTool.h" - "include/MyToolbar.h" - "include/NewHeightMap.h" - "include/ObjectOptions.h" - "include/ObjectPreview.h" - "include/ObjectTool.h" - "include/OpenMap.h" - "include/OptionsPanel.h" - "include/PickUnitDialog.h" - "include/playerlistdlg.h" - "include/PointerTool.h" - "include/PolygonTool.h" - "include/propedit.h" - "include/RampOptions.h" - "include/RampTool.h" - "include/RoadOptions.h" - "include/RoadTool.h" - "include/RulerOptions.h" - "include/RulerTool.h" - "include/SaveMap.h" - "include/ScorchOptions.h" - "include/ScorchTool.h" - "include/ScriptActionsFalse.h" - "include/ScriptActionsTrue.h" - "include/ScriptConditions.h" - "include/ScriptDialog.h" - "include/ScriptProperties.h" - "include/SelectMacrotexture.h" - "include/ShadowOptions.h" - "include/SplashScreen.h" - "include/StdAfx.h" - "include/TeamBehavior.h" - "include/TeamGeneric.h" - "include/TeamIdentity.h" - "include/TeamObjectProperties.h" - "include/TeamReinforcement.h" - "include/teamsdialog.h" - "include/TerrainMaterial.h" - "include/TerrainModal.h" - "include/TerrainSwatches.h" - "include/TileTool.h" - "include/Tool.h" - "include/WaterOptions.h" - "include/WaterTool.h" - "include/WaypointOptions.h" - "include/WaypointTool.h" - "include/WBFrameWnd.h" - "include/WBHeightMap.h" - "include/WBPopupSlider.h" - "include/wbview.h" - "include/wbview3d.h" - "include/WHeightMapEdit.h" - "include/WorldBuilder.h" - "include/WorldBuilderDoc.h" - "include/WorldBuilderView.h" -) - add_executable(g_worldbuilder WIN32) -target_include_directories(g_worldbuilder PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - include - res -) - -target_compile_definitions(g_worldbuilder PRIVATE _AFXDLL) - -target_precompile_headers(g_worldbuilder PRIVATE - [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 - [["WWLib/always.h"]] - [["Common/STLTypedefs.h"]] - [["StdAfx.h"]] - [["WWLib/WWCommon.h"]] -) - target_link_libraries(g_worldbuilder PRIVATE - d3d8lib - core_browserdispatch + corei_worldbuilder g_gameengine g_gameenginedevice gi_always - imm32 - vfw32 - winmm ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - target_link_options(g_worldbuilder PRIVATE /NODEFAULTLIB:libci.lib /NODEFAULTLIB:libc.lib) - - target_sources(g_worldbuilder PRIVATE res/WorldBuilder.rc) + target_compile_definitions(g_worldbuilder PRIVATE _AFXDLL) set_target_properties(g_worldbuilder PROPERTIES OUTPUT_NAME "WorldBuilderV${RTS_BUILD_OUTPUT_SUFFIX}") else() set_target_properties(g_worldbuilder PROPERTIES OUTPUT_NAME "worldbuilderv${RTS_BUILD_OUTPUT_SUFFIX}") endif() - -target_sources(g_worldbuilder PRIVATE ${WORLDBUILDER_SRC}) diff --git a/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt b/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt index 414a3ce89ad..df96569dc6d 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt +++ b/GeneralsMD/Code/Tools/WorldBuilder/CMakeLists.txt @@ -1,239 +1,16 @@ -set(WORLDBUILDER_SRC - "src/addplayerdialog.cpp" - "src/AutoEdgeOutTool.cpp" - "src/BaseBuildProps.cpp" - "src/BlendEdgeTool.cpp" - "src/BlendMaterial.cpp" - "src/BorderTool.cpp" - "src/brushoptions.cpp" - "src/BrushTool.cpp" - "src/BuildList.cpp" - "src/BuildListTool.cpp" - "src/CameraOptions.cpp" - "src/CButtonShowColor.cpp" - "src/CellWidth.cpp" - "src/CFixTeamOwnerDialog.cpp" - "src/ContourOptions.cpp" - "src/CUndoable.cpp" - "src/DrawObject.cpp" - "src/EditAction.cpp" - "src/EditCondition.cpp" - "src/EditCoordParameter.cpp" - "src/EditGroup.cpp" - "src/EditObjectParameter.cpp" - "src/EditParameter.cpp" - "src/ExportScriptsOptions.cpp" - "src/EyedropperTool.cpp" - "src/FeatherOptions.cpp" - "src/FeatherTool.cpp" - "src/FenceOptions.cpp" - "src/FenceTool.cpp" - "src/FloodFillTool.cpp" - "src/GlobalLightOptions.cpp" - "src/GroveOptions.cpp" - "src/GroveTool.cpp" - "src/HandScrollTool.cpp" - "src/ImpassableOptions.cpp" - "src/LayersList.cpp" - "src/LightOptions.cpp" - "src/MainFrm.cpp" - "src/mapobjectprops.cpp" - "src/MapPreview.cpp" - "src/MapSettings.cpp" - "src/MeshMoldOptions.cpp" - "src/MeshMoldTool.cpp" - "src/MoundOptions.cpp" - "src/MoundTool.cpp" - "src/MyToolbar.cpp" - "src/NewHeightMap.cpp" - "src/ObjectOptions.cpp" - "src/ObjectPreview.cpp" - "src/ObjectTool.cpp" - "src/OpenMap.cpp" - "src/OptionsPanel.cpp" - "src/PickUnitDialog.cpp" - "src/playerlistdlg.cpp" - "src/PointerTool.cpp" - "src/PolygonTool.cpp" - "src/propedit.cpp" - "src/RampOptions.cpp" - "src/RampTool.cpp" - "src/RoadOptions.cpp" - "src/RoadTool.cpp" - "src/RulerOptions.cpp" - "src/RulerTool.cpp" - "src/SaveMap.cpp" - "src/ScorchOptions.cpp" - "src/ScorchTool.cpp" - "src/ScriptActionsFalse.cpp" - "src/ScriptActionsTrue.cpp" - "src/ScriptConditions.cpp" - "src/ScriptDialog.cpp" - "src/ScriptProperties.cpp" - "src/SelectMacrotexture.cpp" - "src/ShadowOptions.cpp" - "src/SplashScreen.cpp" - "src/StdAfx.cpp" - "src/TeamBehavior.cpp" - "src/TeamGeneric.cpp" - "src/TeamIdentity.cpp" - "src/TeamObjectProperties.cpp" - "src/TeamReinforcement.cpp" - "src/teamsdialog.cpp" - "src/TerrainMaterial.cpp" - "src/TerrainModal.cpp" - "src/TerrainSwatches.cpp" - "src/TileTool.cpp" - "src/Tool.cpp" - "src/WaterOptions.cpp" - "src/WaterTool.cpp" - "src/WaypointOptions.cpp" - "src/WaypointTool.cpp" - "src/WBFrameWnd.cpp" - "src/WBHeightMap.cpp" - "src/WBPopupSlider.cpp" - "src/wbview.cpp" - "src/wbview3d.cpp" - "src/WHeightMapEdit.cpp" - "src/WorldBuilder.cpp" - "src/WorldBuilderDoc.cpp" - "src/WorldBuilderView.cpp" - "include/addplayerdialog.h" - "include/AutoEdgeOutTool.h" - "include/BaseBuildProps.h" - "include/BlendEdgeTool.h" - "include/BlendMaterial.h" - "include/BorderTool.h" - "include/brushoptions.h" - "include/BrushTool.h" - "include/BuildList.h" - "include/BuildListTool.h" - "include/CameraOptions.h" - "include/CButtonShowColor.h" - "include/CellWidth.h" - "include/CFixTeamOwnerDialog.h" - "include/ContourOptions.h" - "include/CUndoable.h" - "include/DrawObject.h" - "include/EditAction.h" - "include/EditCondition.h" - "include/EditCoordParameter.h" - "include/EditGroup.h" - "include/EditObjectParameter.h" - "include/EditParameter.h" - "include/ExportScriptsOptions.h" - "include/EyedropperTool.h" - "include/FeatherOptions.h" - "include/FeatherTool.h" - "include/FenceOptions.h" - "include/FenceTool.h" - "include/FloodFillTool.h" - "include/GlobalLightOptions.h" - "include/GroveOptions.h" - "include/GroveTool.h" - "include/HandScrollTool.h" - "include/ImpassableOptions.h" - "include/LayersList.h" - "include/LightOptions.h" - "include/MainFrm.h" - "include/mapobjectprops.h" - "include/MapPreview.h" - "include/MapSettings.h" - "include/MeshMoldOptions.h" - "include/MeshMoldTool.h" - "include/MoundOptions.h" - "include/MoundTool.h" - "include/MyToolbar.h" - "include/NewHeightMap.h" - "include/ObjectOptions.h" - "include/ObjectPreview.h" - "include/ObjectTool.h" - "include/OpenMap.h" - "include/OptionsPanel.h" - "include/PickUnitDialog.h" - "include/playerlistdlg.h" - "include/PointerTool.h" - "include/PolygonTool.h" - "include/propedit.h" - "include/RampOptions.h" - "include/RampTool.h" - "include/RoadOptions.h" - "include/RoadTool.h" - "include/RulerOptions.h" - "include/RulerTool.h" - "include/SaveMap.h" - "include/ScorchOptions.h" - "include/ScorchTool.h" - "include/ScriptActionsFalse.h" - "include/ScriptActionsTrue.h" - "include/ScriptConditions.h" - "include/ScriptDialog.h" - "include/ScriptProperties.h" - "include/SelectMacrotexture.h" - "include/ShadowOptions.h" - "include/SplashScreen.h" - "include/StdAfx.h" - "include/TeamBehavior.h" - "include/TeamGeneric.h" - "include/TeamIdentity.h" - "include/TeamObjectProperties.h" - "include/TeamReinforcement.h" - "include/teamsdialog.h" - "include/TerrainMaterial.h" - "include/TerrainModal.h" - "include/TerrainSwatches.h" - "include/TileTool.h" - "include/Tool.h" - "include/WaterOptions.h" - "include/WaterTool.h" - "include/WaypointOptions.h" - "include/WaypointTool.h" - "include/WBFrameWnd.h" - "include/WBHeightMap.h" - "include/WBPopupSlider.h" - "include/wbview.h" - "include/wbview3d.h" - "include/WHeightMapEdit.h" - "include/WorldBuilder.h" - "include/WorldBuilderDoc.h" - "include/WorldBuilderView.h" -) - add_executable(z_worldbuilder WIN32) -target_sources(z_worldbuilder PRIVATE ${WORLDBUILDER_SRC}) - -target_include_directories(z_worldbuilder PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - include - res -) - -target_precompile_headers(z_worldbuilder PRIVATE - [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 - [["WWLib/always.h"]] - [["Common/STLTypedefs.h"]] - [["StdAfx.h"]] - [["WWLib/WWCommon.h"]] -) - target_link_libraries(z_worldbuilder PRIVATE core_debug core_profile_legacy - d3d8lib - imm32 - vfw32 - winmm - core_browserdispatch + corei_worldbuilder z_gameengine z_gameenginedevice zi_always ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - target_link_options(z_worldbuilder PRIVATE /NODEFAULTLIB:libci.lib /NODEFAULTLIB:libc.lib) target_compile_definitions(z_worldbuilder PRIVATE _AFXDLL) - target_sources(z_worldbuilder PRIVATE res/WorldBuilder.rc) set_target_properties(z_worldbuilder PROPERTIES OUTPUT_NAME "WorldBuilderZH${RTS_BUILD_OUTPUT_SUFFIX}") else() set_target_properties(z_worldbuilder PROPERTIES OUTPUT_NAME "worldbuilderzh${RTS_BUILD_OUTPUT_SUFFIX}") diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h deleted file mode 100644 index c255f07878a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/AutoEdgeOutTool.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// AutoEdgeOutTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** AutoEdgeOutTool - Does the BlendEdgesOut tool operation. -***************************************************************************/ -/// Blend edges out tool. -class AutoEdgeOutTool : public Tool -{ -public: - AutoEdgeOutTool(); - virtual ~AutoEdgeOutTool() override; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BaseBuildProps.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BaseBuildProps.h deleted file mode 100644 index 0837afac79d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BaseBuildProps.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// BaseBuildProps.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// BaseBuildProps dialog - -class BaseBuildProps : public CDialog -{ -// Construction -public: - BaseBuildProps(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(BaseBuildProps) - enum { IDD = IDD_BASE_BUILDING_PROPS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BaseBuildProps) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(BaseBuildProps) - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - AsciiString m_name; - AsciiString m_script; - Int m_health; - Bool m_unsellable; - -public: - void setProps(AsciiString name, AsciiString script, Int health, Bool unsellable); - AsciiString getName() {return m_name;} - AsciiString getScript() {return m_script;} - Int getHealth() {return m_health;} - Bool getUnsellable() {return m_unsellable;} -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BlendEdgeTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BlendEdgeTool.h deleted file mode 100644 index b6fc5d087cf..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BlendEdgeTool.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BlendEdgeTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** BlendEdgeTool - Does the BlendEdgesOut tool operation. -***************************************************************************/ -/// Blend edges out tool. -class BlendEdgeTool : public Tool -{ -protected: - Coord3D m_downPt; - -public: - BlendEdgeTool(); - virtual ~BlendEdgeTool() override; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BlendMaterial.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BlendMaterial.h deleted file mode 100644 index 963cd6d3c45..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BlendMaterial.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// BlendMaterial.h : header file -// - -#include "WBPopupSlider.h" -#include "TerrainSwatches.h" -#include "OptionsPanel.h" -class WorldHeightMapEdit; -///////////////////////////////////////////////////////////////////////////// -// BlendMaterial dialog - -class BlendMaterial : public COptionsPanel -{ -// Construction -public: - BlendMaterial(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(BlendMaterial) - enum { IDD = IDD_BLEND_MATERIAL }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BlendMaterial) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - enum {MIN_TILE_SIZE=2, MAX_TILE_SIZE = 100}; - // Generated message map functions - //{{AFX_MSG(BlendMaterial) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - static BlendMaterial *m_staticThis; - Bool m_updating; - static Int m_currentBlendTexture; - CTreeCtrl m_terrainTreeView; - -protected: - void updateTextures(); - void addTerrain(const char *pPath, Int terrainNdx, HTREEITEM parent); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - -public: - static Int getBlendTexClass() {return m_currentBlendTexture;} - - static void setBlendTexClass(Int texClass); - -public: - Bool setTerrainTreeViewSelection(HTREEITEM parent, Int selection); - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BorderTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BorderTool.h deleted file mode 100644 index 9a1e5c43631..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BorderTool.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -#include "Tool.h" - -class BorderTool : public Tool -{ - protected: - enum ModificationType { MOD_TYPE_INVALID, MOD_TYPE_UP, MOD_TYPE_FREE, MOD_TYPE_RIGHT }; - Bool m_mouseDown; - Bool m_addingNewBorder; - Int m_modifyBorderNdx; - ModificationType m_modificationType; - - - public: - BorderTool(); - virtual ~BorderTool() override; - - Int getToolID() {return m_toolID;} - virtual void setCursor() override; - - virtual void activate() override; - virtual void deactivate() override; - - virtual Bool followsTerrain() override { return false; } - - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BrushTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BrushTool.h deleted file mode 100644 index 1f028ca1fd3..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BrushTool.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BrushTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** BrushTool - Does the Height Brush tool operation. -***************************************************************************/ -/// Height brush tool. -class BrushTool : public Tool -{ -protected: - WorldHeightMapEdit *m_htMapEditCopy; ///< ref counted. - WorldHeightMapEdit *m_htMapFeatherCopy; ///< ref counted. - - static Int m_brushWidth; - static Int m_brushFeather; - static Bool m_brushSquare; - static Int m_brushHeight; - -public: - BrushTool(); - virtual ~BrushTool() override; - -public: - static Int getWidth() {return m_brushWidth;}; ///. -*/ - -#pragma once - -// BuildList.h : header file -// - -#include "TerrainSwatches.h" -#include "OptionsPanel.h" -#include "WBPopupSlider.h" -#include "Common/AsciiString.h" -class WorldHeightMapEdit; -class BuildListInfo; -///////////////////////////////////////////////////////////////////////////// -// BuildList dialog - -class BuildList : public COptionsPanel, public PopupSliderOwner -{ -// Construction -public: - BuildList(CWnd* pParent = nullptr); ///< standard constructor - - virtual ~BuildList() override; ///< standard destructor - enum { NAME_MAX_LEN = 64 }; -// Dialog Data - //{{AFX_DATA(BuildList) - enum { IDD = IDD_BUILD_LIST_PANEL }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BuildList) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(BuildList) - virtual BOOL OnInitDialog() override; - afx_msg void OnSelchangeSidesCombo(); - afx_msg void OnMoveUp(); - afx_msg void OnMoveDown(); - afx_msg void OnAddBuilding(); - afx_msg void OnSelchangeBuildList(); - afx_msg void OnAlreadyBuild(); - afx_msg void OnDeleteBuilding(); - afx_msg void OnSelendokRebuilds(); - afx_msg void OnEditchangeRebuilds(); - afx_msg void OnDblclkBuildList(); - afx_msg void OnChangeZOffset(); - afx_msg void OnChangeAngle(); - afx_msg void OnExport(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - Int m_curSide; - Int m_curBuildList; - WBPopupSliderButton m_heightSlider; - WBPopupSliderButton m_angleSlider; - Real m_angle; - Real m_height; - - static BuildList *m_staticThis; - static Bool m_updating; - -protected: - void loadSides(); - void updateCurSide(); - -public: - static void addBuilding(Coord3D loc, Real angle, AsciiString name); - static void update() {if (m_staticThis) m_staticThis->loadSides();}; - static void setSelectedBuildList(BuildListInfo *pInfo); - - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) override; - virtual void PopSliderChanged(const long sliderID, long theVal) override; - virtual void PopSliderFinished(const long sliderID, long theVal) override; - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/BuildListTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/BuildListTool.h deleted file mode 100644 index 774cd5e7db4..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/BuildListTool.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BuildListTool.h -// Build list tool for worldbuilder. -// Author: John Ahlquist, Nov 2001 - -#pragma once - -#include "Tool.h" -#include "Common/AsciiString.h" -#include "PickUnitDialog.h" -class WorldHeightMapEdit; -class BuildListInfo; - -/*************************************************************************/ -/** BuildListTool - Does the add item to build list tool operation. -***************************************************************************/ -class BuildListTool : public Tool -{ -protected: - CPoint m_downPt2d; - Coord3D m_downPt3d; - Coord3D m_prevPt3d; - BuildListInfo *m_curObject; - - Bool m_moving; ///< True if we are drag moving an object. - Bool m_rotating; ///< True if we are rotating an object. - - Bool m_mouseUpRotate;///< True if we are over the "rotate" hotspot. - HCURSOR m_rotateCursor; - Bool m_mouseUpMove;///< True if we are over the "move" hotspot. - HCURSOR m_moveCursor; - HCURSOR m_pointerCursor; - PickUnitDialog m_pickBuildingDlg; - Bool m_created; - - static PickUnitDialog *m_static_pickBuildingDlg; - static Bool m_isActive; - -public: - BuildListTool(); - virtual ~BuildListTool() override; - -private: - void createWindow(); - Bool isDoingAdd(); - -public: - static void addBuilding(); - static Bool isActive() {return m_isActive;}; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void setCursor() override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/CButtonShowColor.h b/GeneralsMD/Code/Tools/WorldBuilder/include/CButtonShowColor.h deleted file mode 100644 index 689f82f18c1..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/CButtonShowColor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -class CButtonShowColor : public CButton -{ - protected: - RGBColor m_color; - - public: - const RGBColor& getColor() const { return m_color; } - void setColor(Int color) { m_color.setFromInt(color); } - void setColor(const RGBColor& color) { m_color = color; } - virtual ~CButtonShowColor() override; - - - static COLORREF RGBtoBGR(Int color); - static Int BGRtoRGB(COLORREF color); - - - protected: - afx_msg void OnPaint(); - - DECLARE_MESSAGE_MAP(); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h b/GeneralsMD/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h deleted file mode 100644 index b05d5383cbf..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/CFixTeamOwnerDialog.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - - -#include "Common/AsciiString.h" -class TeamsInfo; -class SidesList; - -#pragma once - -class CFixTeamOwnerDialog : public CDialog -{ - public: - enum { IDD = IDD_CHANGE_TEAM_OWNER }; - CFixTeamOwnerDialog( TeamsInfo *ti, SidesList *sideList, UINT nIDTemplate = CFixTeamOwnerDialog::IDD, CWnd* pParentWnd = nullptr ); - AsciiString getSelectedOwner(); - Bool pickedValidTeam() { return m_pickedValidTeam; } - - protected: - virtual BOOL OnInitDialog() override; - virtual afx_msg void OnOK() override; - DECLARE_MESSAGE_MAP() - - protected: - Bool m_pickedValidTeam; - AsciiString m_selectedOwner; - TeamsInfo *m_ti; - SidesList *m_sl; -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/CUndoable.h b/GeneralsMD/Code/Tools/WorldBuilder/include/CUndoable.h deleted file mode 100644 index 9aae72df161..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/CUndoable.h +++ /dev/null @@ -1,410 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// CUndoable.h -// Class to handle undo/redo. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Lib/BaseType.h" -#include "../../GameEngine/Include/Common/MapObject.h" -#include "../../GameEngine/Include/Common/GameCommon.h" -#include "../../GameEngine/Include/GameLogic/SidesList.h" -#include - -class PolygonTrigger; -class BuildListInfo; -/************************************************************************* -** Undoable -***************************************************************************/ -/// Base command class for all undoable commands. Just the virtual shell. -class Undoable : public RefCountClass -{ -protected: - Undoable *mNext; - -public: - Undoable(); - - virtual ~Undoable() override; - -public: - virtual void Do()=0; ///< pure virtual. - virtual void Undo()=0;///< pure virtual. - virtual void Redo(); - - void LinkNext(Undoable *pNext); - Undoable *GetNext() {return mNext;}; - -}; - -class CWorldBuilderDoc; -class WorldHeightMapEdit; -class MapObject; -/************************************************************************* -** CWBDocUndoable -***************************************************************************/ -/// Command that saves & restores entire height map. -/** An undoable that actually undoes something. Saves and restores the -entire height map. */ -class WBDocUndoable : public Undoable -{ -protected: - CWorldBuilderDoc *mPDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - WorldHeightMapEdit *mPNewHeightMapData; ///< ref counted. - WorldHeightMapEdit *mPOldHeightMapData; ///< ref counted. - Bool m_offsetObjects; ///< If true, apply m_objOffset. - Coord3D m_objOffset; ///< Offset to adjust all objects. - - -public: - WBDocUndoable(CWorldBuilderDoc *pDoc, WorldHeightMapEdit *pNewHtMap, Coord3D *pObjOffset = nullptr); - - // destructor. - virtual ~WBDocUndoable() override; - virtual void Do() override; - virtual void Undo() override; - virtual void Redo() override; - -}; - -/// AddObjectUndoable -/** An undoable that actually undoes something. Adds an object -to the height map. If it is a linked list, adds all objects. */ -class AddObjectUndoable : public Undoable -{ -protected: - CWorldBuilderDoc *m_pDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - MapObject *m_objectToAdd; - Int m_numObjects; - Bool m_addedToList; - -public: - AddObjectUndoable(CWorldBuilderDoc *pDoc, MapObject *pObjectToAdd); - - // destructor. - virtual ~AddObjectUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - - -/// ModifyObjectUndoable -/** An undoable that actually undoes something. Modifies an object's -location and angle. */ -// Helper class -class MoveInfo -{ -public: - MoveInfo(MapObject *pObjToMove); - ~MoveInfo(); - void DoMove(CWorldBuilderDoc *pDoc); - void UndoMove(CWorldBuilderDoc *pDoc); - - void SetOffset(CWorldBuilderDoc *pDoc, Real x, Real y); - void SetZOffset(CWorldBuilderDoc *pDoc, Real z); - void RotateTo(CWorldBuilderDoc *pDoc, Real angle); - void SetThingTemplate(CWorldBuilderDoc *pDoc, const ThingTemplate* thing); - void SetName(CWorldBuilderDoc *pDoc, AsciiString name); - -public: - MapObject *m_objectToModify; - MoveInfo *m_next; - Real m_newAngle; - Real m_oldAngle; - Coord3D m_newLocation; - Coord3D m_oldLocation; - const ThingTemplate* m_oldThing; - const ThingTemplate* m_newThing; - AsciiString m_oldName; - AsciiString m_newName; -}; - -class ModifyObjectUndoable : public Undoable -{ -protected: - CWorldBuilderDoc* m_pDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - MoveInfo* m_moveList; - Bool m_inval; - -public: - ModifyObjectUndoable(CWorldBuilderDoc *pDoc); - // destructor. - virtual ~ModifyObjectUndoable() override; - - virtual void Do() override; - virtual void Undo() override; - virtual void Redo() override; - - void SetOffset(Real x, Real y); - void SetZOffset(Real z); - void RotateTo(Real angle); - void SetThingTemplate(const ThingTemplate* thing); - void SetName(AsciiString name); -}; - -/// ModifyFlagsUndoable -/** An undoable that actually undoes something. Modifies an object's -flags. */ -// Helper class -class FlagsInfo -{ -public: - FlagsInfo(MapObject *pObjToMove, Int flagMask, Int flagValue ); - ~FlagsInfo(); - void DoFlags(CWorldBuilderDoc *pDoc); - void UndoFlags(CWorldBuilderDoc *pDoc); - -public: - MapObject *m_objectToModify; - FlagsInfo *m_next; - Int m_flagMask; - Int m_newValue; - Int m_oldValue; -}; - -class ModifyFlagsUndoable : public Undoable -{ -protected: - CWorldBuilderDoc *m_pDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - FlagsInfo *m_flagsList; - -public: - ModifyFlagsUndoable(CWorldBuilderDoc *pDoc, Int flagMask, Int flagValue); - // destructor. - virtual ~ModifyFlagsUndoable() override; - - virtual void Do() override; - virtual void Undo() override; - virtual void Redo() override; - -}; - -class SidesListUndoable : public Undoable -{ -protected: - SidesList m_old, m_new; - CWorldBuilderDoc *m_pDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - -public: - - SidesListUndoable(const SidesList& newSL, CWorldBuilderDoc *pDoc); - virtual ~SidesListUndoable() override; - - virtual void Do() override; - virtual void Undo() override; - -}; - -class DictItemUndoable : public Undoable -{ -protected: - Int m_numDictsToModify; - std::vector m_dictToModify; - std::vector m_oldDictData; - Dict m_newDictData; - CWorldBuilderDoc *m_pDoc; - Bool m_inval; - NameKeyType m_key; - -public: - - static Dict buildSingleItemDict(AsciiString k, Dict::DataType t, AsciiString v); - - // if you want to just add/modify/remove a single dict item, pass the item's key. - // if you want to substitute the entire contents of the new dict, pass NAMEKEY_INVALID. - DictItemUndoable(Dict **d, Dict data, NameKeyType key, Int dictsToModify = 1, CWorldBuilderDoc *pDoc = nullptr, Bool inval = false); - // destructor. - virtual ~DictItemUndoable() override; - - virtual void Do() override; - virtual void Undo() override; - -}; - - -/// DeleteObjectUndoable -/** An undoable that actually undoes something. Deletes an object. */ -// Helper class -class DeleteInfo -{ -public: - DeleteInfo(MapObject *pObjToDelete); - ~DeleteInfo(); - void DoDelete(WorldHeightMapEdit *pMap); - void UndoDelete(WorldHeightMapEdit *pMap); - -public: - Bool m_didDelete; - MapObject *m_objectToDelete; - MapObject *m_priorObject; - DeleteInfo *m_next; -}; - - -class DeleteObjectUndoable : public Undoable -{ -protected: - CWorldBuilderDoc *m_pDoc; ///< Not ref counted. This undoable should be in a list attached to the doc anyway. - DeleteInfo *m_deleteList; -public: - DeleteObjectUndoable(CWorldBuilderDoc *pDoc); - - // destructor. - virtual ~DeleteObjectUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// AddPolygonUndoable -/** An undoable that actually undoes something. Adds a polygon. */ -class AddPolygonUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - Bool m_isTriggerInList; -public: - AddPolygonUndoable( PolygonTrigger *pTrig); - // destructor. - virtual ~AddPolygonUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// AddPolygonPointUndoable -/** An undoable that actually undoes something. Adds a polygon. */ -class AddPolygonPointUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - ICoord3D m_point; -public: - AddPolygonPointUndoable(PolygonTrigger *pTrig, ICoord3D pt); - // destructor. - virtual ~AddPolygonPointUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// ModifyPolygonPointUndoable -/** An undoable that actually undoes something. Modifys a polygon. */ -class ModifyPolygonPointUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - Int m_pointIndex; - ICoord3D m_point; - ICoord3D m_savPoint; -public: - ModifyPolygonPointUndoable(PolygonTrigger *pTrig, Int ndx); - // destructor. - virtual ~ModifyPolygonPointUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// MovePolygonUndoable -/** An undoable that actually undoes something. Moves a polygon. */ -class MovePolygonUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - ICoord3D m_point; - ICoord3D m_offset; -public: - MovePolygonUndoable(PolygonTrigger *pTrig); - // destructor. - virtual ~MovePolygonUndoable() override; - virtual void Do() override; - virtual void Undo() override; - - void SetOffset(const ICoord3D &offset); - PolygonTrigger *getTrigger() {return m_trigger;} -}; - -/// InsertPolygonPointUndoable -/** An undoable that actually undoes something. Inserts a polygon point. */ -class InsertPolygonPointUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - Int m_pointIndex; - ICoord3D m_point; -public: - InsertPolygonPointUndoable(PolygonTrigger *pTrig, ICoord3D pt, Int ndx); - // destructor. - virtual ~InsertPolygonPointUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// DeletePolygonPointUndoable -/** An undoable that actually undoes something. Deletes a polygon point. */ -class DeletePolygonPointUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - Int m_pointIndex; - ICoord3D m_point; -public: - DeletePolygonPointUndoable(PolygonTrigger *pTrig, Int ndx); - // destructor. - virtual ~DeletePolygonPointUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// DeletePolygonUndoable -/** An undoable that actually undoes something. Deletes a polygon. */ -class DeletePolygonUndoable : public Undoable -{ -protected: - PolygonTrigger *m_trigger; - Bool m_isTriggerInList; -public: - DeletePolygonUndoable(PolygonTrigger *pTrig); - // destructor. - virtual ~DeletePolygonUndoable() override; - virtual void Do() override; - virtual void Undo() override; -}; - -/// MultipleUndoable -/** - * An undoable that doesn't do anything; it just consolidates a number of other - * Undoables in a single logical undo step. - */ -class MultipleUndoable : public Undoable -{ -protected: - Undoable * m_undoableList; //< The head of the list of undoables, in the order they should be done. Reverse order for undoes -public: - MultipleUndoable(); - // destructor. - virtual ~MultipleUndoable() override; - - /** Add other undoables in the order you would want them UNdone; e.g. in the reverse order you want them done - * The MultipleUndoable object will then own the pointers. - */ - void addUndoable( Undoable * undoable ); - - virtual void Do() override; - virtual void Undo() override; - virtual void Redo() override; -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/CameraOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/CameraOptions.h deleted file mode 100644 index db805549d6b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/CameraOptions.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// CameraOptions.h : header file -// - -#define CAMERA_OPTIONS_PANEL_SECTION "CameraOptionsWindow" -#include "WBPopupSlider.h" - -///////////////////////////////////////////////////////////////////////////// -// CameraOptions dialog - -class CameraOptions : public CDialog, public PopupSliderOwner -{ -// Construction -public: - CameraOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(CameraOptions) - enum { IDD = IDD_CAMERA_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CameraOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CameraOptions) - afx_msg void OnCameraReset(); - afx_msg void OnDropWaypointButton(); - afx_msg void OnCenterOnSelectedButton(); - afx_msg void OnMove(int x, int y); - virtual BOOL OnInitDialog() override; - afx_msg void OnChangePitchEdit(); - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - void putInt( Int ctrlID, Int val ); - void putReal( Int ctrlID, Real val ); - void putAsciiString( Int ctrlID, AsciiString val ); - BOOL getReal( Int ctrlID, Real *rVal ); - void stuffValuesIntoFields(); - void applyCameraPitch( Real pitch ); - - WBPopupSliderButton m_pitchPopup; - Bool m_updating; - -public: // popup slider interface. - - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) override; - virtual void PopSliderChanged(const long sliderID, long theVal) override; - virtual void PopSliderFinished(const long sliderID, long theVal) override; - -public: - void update(); - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/CellWidth.h b/GeneralsMD/Code/Tools/WorldBuilder/include/CellWidth.h deleted file mode 100644 index ee16757e00b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/CellWidth.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// CellWidth.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -/// CellWidth modal dialog to set the cell width. - -class CellWidth : public CDialog -{ -// Construction -public: - CellWidth(int cellWidth, CWnd* pParent = nullptr); // standard constructor - - int GetCellWidth() {return mCellWidth;}; -// Dialog Data - //{{AFX_DATA(CellWidth) - enum { IDD = IDD_CellWidth }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CellWidth) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override; - //}}AFX_VIRTUAL - -// Implementation -protected: - int mCellWidth; - -protected: - - // Generated message map functions - //{{AFX_MSG(CellWidth) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ContourOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ContourOptions.h deleted file mode 100644 index 90f74267260..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ContourOptions.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ContourOptions.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -/// ContourOptions modeless (floating) dialog - allows entry and display of brush width and feather. - -class ContourOptions : public CDialog -{ -// Construction -public: - enum {MIN_CONTOUR_STEP=1, - MAX_CONTOUR_STEP=10, - MIN_CONTOUR_OFFSET=-10, - MAX_CONTOUR_OFFSET=+10, - MIN_WIDTH=1, - MAX_WIDTH=6}; - - ContourOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(ContourOptions) - enum { IDD = IDD_CONTOUR_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ContourOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(ContourOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg void OnShowContours(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static Int m_contourStep; ///< current contour step in the ui. - static Int m_contourOffset; ///< current contour offset in the ui. - static Int m_contourWidth; ///< current contour offset in the ui. - - Bool m_updating; ///. -*/ - -#pragma once - -#include "WWLib/always.h" -#include "WW3D2/rendobj.h" -#include "WW3D2/w3d_file.h" -#include "WW3D2/dx8vertexbuffer.h" -#include "WW3D2/dx8indexbuffer.h" -#include "WW3D2/shader.h" -#include "WW3D2/vertmaterial.h" -#include "Lib/BaseType.h" -#include "Common/AsciiString.h" - -// The draw objects draw a circle of diameter 1.0 cells. -#define THE_RADIUS (0.8f*MAP_XY_FACTOR) - -class MeshClass; -class PolygonTrigger; -class WaterRenderObjClass; -class MapObject; -class Render2DClass; -// -// DrawObject: Draws 3d feedback for tools & objects. -// -// -class DrawObject : public RenderObjClass -{ - -public: - - DrawObject(); - DrawObject(const DrawObject & src); - DrawObject & operator = (const DrawObject &); - virtual ~DrawObject() override; - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface - ///////////////////////////////////////////////////////////////////////////// - virtual RenderObjClass * Clone() const override; - virtual int Class_ID() const override; - virtual void Render(RenderInfoClass & rinfo) override; -// virtual void Special_Render(SpecialRenderInfoClass & rinfo); -// virtual void Set_Transform(const Matrix3D &m); -// virtual void Set_Position(const Vector3 &v); -//TODO: MW: do these later - only needed for collision detection - virtual Bool Cast_Ray(RayCollisionTestClass & raytest) override; -// virtual Bool Cast_AABox(AABoxCollisionTestClass & boxtest); -// virtual Bool Cast_OBBox(OBBoxCollisionTestClass & boxtest); -// virtual Bool Intersect_AABox(AABoxIntersectionTestClass & boxtest); -// virtual Bool Intersect_OBBox(OBBoxIntersectionTestClass & boxtest); - - virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const override; - virtual void Get_Obj_Space_Bounding_Box(AABoxClass & aabox) const override; - - -// virtual int Get_Num_Polys() const; -// virtual const char * Get_Name() const; -// virtual void Set_Name(const char * name); - -// unsigned int Get_Flags() { return Flags; } -// void Set_Flags(unsigned int flags) { Flags = flags; } -// void Set_Flag(unsigned int flag, Bool onoff) { Flags &= (~flag); if (onoff) Flags |= flag; } - - Int freeMapResources(); - int initData(); - - void setDrawObjects(Bool val, Bool waypoints, Bool poly, Bool bounding, Bool sight, Bool weapon, Bool sound, Bool testart, Bool letterbox) { m_drawObjects = val; m_drawWaypoints=waypoints; m_drawPolygonAreas = poly; m_drawBoundingBoxes = bounding; m_drawSightRanges = sight; m_drawWeaponRanges = weapon; m_drawSoundRanges = sound; m_drawTestArtHighlight = testart, m_drawLetterbox = letterbox;} - static void setDoBrushFeedback(Bool val) { m_toolWantsFeedback = val; m_meshFeedback=false;} - static void setDoMeshFeedback(Bool val) { m_meshFeedback = val; } - static void setDoRampFeedback(Bool val) { m_rampFeedback = val; } - static void setDoBoundaryFeedback(Bool val) { m_boundaryFeedback = val; } - - static void setDoAmbientSoundFeedback(Bool val) { m_ambientSoundFeedback = val; } - - static void setBrushFeedbackParms(Bool square, Int width, Int featherWidth) - { m_squareFeedback = square; m_brushWidth=width; - m_meshFeedback = false; m_brushFeatherWidth = featherWidth;} - static void disableFeedback() {m_disableFeedback = true;}; - static void enableFeedback() {m_disableFeedback = false;}; - static Bool isFeedbackEnabled() { return !m_disableFeedback;}; - static void setFeedbackPos(Coord3D pos); - - static void setWaypointDragFeedback(const Coord3D &start, const Coord3D &end); - static void setRampFeedbackParms(const Coord3D *start, const Coord3D *end, Real rampWidth); - static void stopWaypointDragFeedback(); - - - - - MeshClass *peekMesh() {return m_moldMesh;}; - void getMeshBounds(SphereClass *pSphere) {*pSphere = m_moldMeshBounds;}; - -protected: - enum {MAX_RADIUS = 50, NUM_FEEDBACK_VERTEX = 201*201, NUM_FEEDBACK_INDEX = 101*101*6}; - Int m_numTriangles; //dimensions of list - - DX8IndexBufferClass *m_indexBuffer; ///< indices defining a object icon - ShaderClass m_shaderClass; ///< shader or rendering state for heightmap - VertexMaterialClass *m_vertexMaterialClass; - DX8VertexBufferClass *m_vertexBufferTile1; ///< First vertex buffer. - DX8VertexBufferClass *m_vertexBufferTile2; ///< Second vertex buffer. - - DX8VertexBufferClass *m_vertexBufferWater; ///< Vertex buffer for the water plane. - DX8IndexBufferClass *m_indexWater; ///< indices defining a triangle strip for the water on terrain - Int m_waterVertexCount; - - WaterRenderObjClass *m_waterDrawObject; - - Bool m_drawObjects; - Bool m_drawWaypoints; - Bool m_drawPolygonAreas; - Bool m_drawBoundingBoxes; - Bool m_drawSightRanges; - Bool m_drawWeaponRanges; - Bool m_drawSoundRanges; - Bool m_drawTestArtHighlight; - Bool m_drawLetterbox; - - DX8VertexBufferClass *m_vertexFeedback; ///< Vertex buffer for brush feedback. - DX8IndexBufferClass *m_indexFeedback; ///< indices defining a triangle strip for the feedback on terrain - Int m_feedbackIndexCount; - Int m_feedbackVertexCount; - - AsciiString m_curMeshModelName; ///< Model name of m_moldMesh. - - MeshClass *m_moldMesh; ///< W3D mesh model for the mold. - SphereClass m_moldMeshBounds; ///< Bounding sphere for mold mesh. - Render2DClass *m_lineRenderer; //< Used to render 2D lines for bounding boxes. - CPoint m_winSize; //< Holds the size of the window. - -protected: // static state vars. - static Bool m_squareFeedback; ///< True for square brush feedback, false for round. - static Int m_brushWidth; ///< Width of brush feedback. - static Int m_brushFeatherWidth; ///< Width of brush feathered feedback. - static Bool m_toolWantsFeedback; ///< True to display brush feedback. - static Bool m_disableFeedback; ///< True to disable feedback. - static Coord3D m_feedbackPoint; ///< Current brush feedback location. - static CPoint m_cellCenter; ///< Cell to show feedback from. - static Bool m_meshFeedback; - static Bool m_rampFeedback; ///< should we be showing feedback for the ramp tool? - static Bool m_boundaryFeedback; - static Bool m_ambientSoundFeedback; - - static Bool m_dragWaypointFeedback; ///< True for the waypoint tool dragging. - static Coord3D m_dragWayStart;///< Start drag waypoint feedback. - static Coord3D m_dragWayEnd; ///< End drag waypoint. - - static Coord3D m_rampStartPoint; ///< Beginning ramp point - static Coord3D m_rampEndPoint; ///< End ramp point - static Real m_rampWidth; - -protected: - void addCircleToLineRenderer( const Coord3D & center, Real radius, Real width, unsigned long color, CameraClass* camera ); - Int updateVB(DX8VertexBufferClass *vertexBufferTile, Int color, Bool doArrow, Bool doDiamond); - void updatePolygonVB(PolygonTrigger *pTrig, Bool selected, Bool isOpen); - void updateFeedbackVB(); - void updateMeshVB(); - void updateRampVB(); - void updateWaypointVB(); - void updateForWater(); - void updateBoundaryVB(); - void updateAmbientSoundVB(); - void updateVBWithBoundingBox(MapObject *pMapObj, CameraClass* camera); - void updateVBWithSightRange(MapObject *pMapObj, CameraClass* camera); - void updateVBWithWeaponRange(MapObject *pMapObj, CameraClass* camera); - void updateVBWithTestArtHighlight(MapObject *pMapObj, CameraClass* camera); - void updateVBWithSoundRanges(MapObject *pMapObj, CameraClass* camera); - bool worldToScreen(const Coord3D *w, ICoord2D *s, CameraClass* camera); - -}; - -void BuildRectFromSegmentAndWidth(const Coord3D* b, const Coord3D* t, Real width, - Coord3D* outBL, Coord3D* outTL, Coord3D* outBR, Coord3D* outTR); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditAction.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditAction.h deleted file mode 100644 index 2e64f151d05..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditAction.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditAction.h : header file -// - - -class ScriptAction; -class SidesList; - -///////////////////////////////////////////////////////////////////////////// -// EditAction dialog - -class EditAction : public CDialog -{ -// Construction -public: - EditAction(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditAction) - enum { IDD = IDD_ScriptAction }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditAction) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -public: - void setAction(ScriptAction *pAction) {m_action = pAction;} - -protected: - void formatScriptActionText(Int parmNdx); -protected: - ScriptAction *m_action; - Bool m_updating; - Bool m_modifiedTextColor; - CRichEditCtrl m_myEditCtrl; - CHARRANGE m_curLinkChrg; - Int m_curEditParameter; - CTreeCtrl m_actionTreeView; - -protected: - - // Generated message map functions - //{{AFX_MSG(EditAction) - virtual BOOL OnInitDialog() override; - afx_msg void OnSelchangeScriptActionType(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditCondition.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditCondition.h deleted file mode 100644 index 90da61f7733..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditCondition.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditCondition.h : header file -// - - -class Condition; -class SidesList; - -class CMyTreeCtrl : public CTreeCtrl -{ -public: - virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) override; -}; - -///////////////////////////////////////////////////////////////////////////// -// EditCondition dialog - -class EditCondition : public CDialog -{ -// Construction -public: - EditCondition(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditCondition) - enum { IDD = IDD_ScriptCondition }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditCondition) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -public: - void setCondition(Condition *pCond) {m_condition = pCond;} - -protected: - void formatConditionText(Int parmNdx); -protected: - Condition *m_condition; - Bool m_updating; - Bool m_modifiedTextColor; - CRichEditCtrl m_myEditCtrl; - CHARRANGE m_curLinkChrg; - Int m_curEditParameter; - CTreeCtrl m_conditionTreeView; - -protected: - - // Generated message map functions - //{{AFX_MSG(EditCondition) - virtual BOOL OnInitDialog() override; - afx_msg void OnSelchangeConditionType(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditCoordParameter.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditCoordParameter.h deleted file mode 100644 index 9959dd1a379..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditCoordParameter.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditCoordParameter.h : header file -// -#include "GameLogic/Scripts.h" -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// EditCoordParameter dialog - -class EditCoordParameter : public CDialog -{ -friend class EditParameter; -// Construction -public: - EditCoordParameter(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditCoordParameter) - enum { IDD = IDD_EDIT_COORD_PARAMETER }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditCoordParameter) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation - - -protected: - -protected: - Parameter *m_parameter; - Coord3D m_coord; - -protected: - - // Generated message map functions - //{{AFX_MSG(EditCoordParameter) - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - virtual void OnCancel() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditGroup.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditGroup.h deleted file mode 100644 index c4cdeb5bd62..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditGroup.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditGroup.h : header file -// - -class ScriptGroup; -///////////////////////////////////////////////////////////////////////////// -// EditGroup dialog - -class EditGroup : public CDialog -{ -// Construction -public: - EditGroup(ScriptGroup *pGroup, CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditGroup) - enum { IDD = IDD_EDIT_GROUP }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditGroup) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation - protected: - ScriptGroup *m_scriptGroup; - -protected: - - // Generated message map functions - //{{AFX_MSG(EditGroup) - virtual void OnOK() override; - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditObjectParameter.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditObjectParameter.h deleted file mode 100644 index da951f252e4..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditObjectParameter.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditObjectParameter.h : header file -// -#include "GameLogic/Scripts.h" -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// EditObjectParameter dialog - -class EditObjectParameter : public CDialog -{ -friend class EditParameter; -// Construction -public: - EditObjectParameter(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditObjectParameter) - enum { IDD = IDD_EDIT_OBJECT_PARAMETER }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditObjectParameter) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation - - -protected: - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - void addObject( const ThingTemplate *thingTemplate ); - void addObjectLists( ); - -protected: - Parameter *m_parameter; - CTreeCtrl m_objectTreeView; - -protected: - - // Generated message map functions - //{{AFX_MSG(EditObjectParameter) - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - virtual void OnCancel() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EditParameter.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EditParameter.h deleted file mode 100644 index 3220d9a1862..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EditParameter.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// EditParameter.h : header file -// -#include "GameLogic/Scripts.h" -#include "Common/SubsystemInterface.h" - -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// EditParameter dialog - -class EditParameter : public CDialog -{ -// Construction -public: - EditParameter(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(EditParameter) - enum { IDD = IDD_EDIT_PARAMETER }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditParameter) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation - -public: - static Int edit( Parameter *pParm, Int keyPressed, AsciiString unitName = AsciiString::TheEmptyString ); - static AsciiString getWarningText(Parameter *pParm, Bool isAction); - static AsciiString getInfoText(Parameter *pParm); - static void setCurSidesList(SidesList *sidesListP) {m_sidesListP = sidesListP;}; - static Bool loadScripts(CComboBox *pCombo, Bool subr, AsciiString match = AsciiString::TheEmptyString); - static Bool loadWaypoints(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadTransports(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadObjectTypeList(CComboBox *pCombo, std::vector *strings = nullptr, AsciiString match = AsciiString::TheEmptyString); - -protected: - static Bool loadSides(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadTriggerAreas(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadCommandButtons(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadFontNames(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static void readFontFile( const char *filename ); - static Bool loadTeams(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadTeamOrUnit(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadUnits(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadBridges(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadObjectType(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadAudioType(Parameter::ParameterType comboType, CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadMovies(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool getMovieComment(AsciiString match, AsciiString& outCommentFromINI); - static Bool loadSpecialPowers(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadSciences(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadScienceAvailabilities(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadUpgrades(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadAbilities( CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString ); - static Bool loadAllAbilities( CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString ); - static Bool loadWaypointPaths(CComboBox *pCombo, AsciiString match= AsciiString::TheEmptyString); - static Bool loadObjectFlags(CComboBox *pCombo, AsciiString match= AsciiString::TheEmptyString); - - static Bool loadAttackPrioritySets(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static AsciiString loadLocalizedText(CComboBox *pCombo, AsciiString isStringInTable = AsciiString::TheEmptyString); - static Bool loadAttackSetParameter(Script *pScr, CComboBox *pCombo, AsciiString match); - static Bool loadCreateUnitParameter(Script *pScr, CComboBox *pCombo, AsciiString match); - static Bool loadCreateObjectListsParameter(Script *pScr, CComboBox *pCombo, std::vector *strings, AsciiString match); - static Bool loadRevealNames(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static Bool loadRevealNamesParameter(Script *pScr, CComboBox *pCombo, AsciiString match); - - static Bool loadEmoticons( CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString ); - static AsciiString getCreatedUnitTemplateName(AsciiString unitName); - - static Bool loadCounters(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - static void loadConditionParameter(Script *pScr, Parameter::ParameterType type, CComboBox *pCombo); - static Bool loadActionParameter(Script *pScr, Parameter::ParameterType type, CComboBox *pCombo, AsciiString match); - static Bool loadFlags(CComboBox *pCombo, AsciiString match = AsciiString::TheEmptyString); - - -protected: - Parameter *m_parameter; - static AsciiString m_unitName; //This is the name of the unit that this script command is dedicated to (if applicable). - AsciiString m_string; - Int m_int; - Real m_real; - - Int m_key; // key pressed to invoke the edit parameter dialog. - - static SidesList *m_sidesListP; - static AsciiString m_selectedLocalizedString; - -protected: - Bool scanReal(CEdit *pEdit, Real scale); - -protected: - // Generated message map functions - //{{AFX_MSG(EditParameter) - afx_msg void OnChangeEdit(); - afx_msg void OnEditchangeCombo(); - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnPreviewSound(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h deleted file mode 100644 index 06377f25507..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ExportScriptsOptions.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ExportScriptsOptions.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// ExportScriptsOptions dialog - -class ExportScriptsOptions : public CDialog -{ -// Construction -public: - ExportScriptsOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(ExportScriptsOptions) - enum { IDD = IDD_EXPORT_SCRIPTS_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ExportScriptsOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - static Bool m_units; - static Bool m_waypoints; - static Bool m_triggers; - static Bool m_allScripts; - static Bool m_sides; - -public: - Bool getDoUnits() {return m_units;} - Bool getDoWaypoints() {return m_waypoints;} - Bool getDoTriggers() {return m_triggers;} - Bool getDoAllScripts() {return m_allScripts;} - Bool getDoSides() {return m_sides;} - -protected: - - // Generated message map functions - //{{AFX_MSG(ExportScriptsOptions) - virtual void OnOK() override; - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/EyedropperTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/EyedropperTool.h deleted file mode 100644 index 8138b416ede..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/EyedropperTool.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EyedropperTool.h -// Texture selection tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** EyedropperTool - Does the select tile from drawing window tool operation. -***************************************************************************/ -/// Select tile tool. -class EyedropperTool : public Tool -{ -public: - EyedropperTool(); - virtual ~EyedropperTool() override; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/FeatherOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/FeatherOptions.h deleted file mode 100644 index f50ccc3a3fe..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/FeatherOptions.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// brushoptions.h : header file -// - -#include "WBPopupSlider.h" -#include "OptionsPanel.h" -///////////////////////////////////////////////////////////////////////////// -/// FeatherOptions modeless (floating) dialog - allows entry and display of brush width and feather. - -class FeatherOptions : public COptionsPanel , public PopupSliderOwner -{ -// Construction -public: - enum {MIN_FEATHER_SIZE=2, - MAX_FEATHER_SIZE=51, - MIN_RATE=1, - MAX_RATE=10, - MIN_RADIUS=1, - MAX_RADIUS=5}; - - FeatherOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(FeatherOptions) - enum { IDD = IDD_FEATHER_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(FeatherOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(FeatherOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeSizeEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static FeatherOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - static Int m_currentFeather; ///< current brush width in the ui. - static Int m_currentRadius; ///< current smoothing radius value. - static Int m_currentRate; ///< current smoothing rate. - - Bool m_updating; ///. -*/ - -// FeatherTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/**************************************************************************/ -/** FeatherTool - Does the smooth height map tool operation. -***************************************************************************/ -/// smooth height map tool. -class FeatherTool : public Tool -{ -protected: - WorldHeightMapEdit *m_htMapEditCopy; //< ref counted. - WorldHeightMapEdit *m_htMapFeatherCopy; //< ref counted. - WorldHeightMapEdit *m_htMapRateCopy; //< ref counted. - - static Int m_feather; - static Int m_rate; - static Int m_radius; -public: - FeatherTool(); - virtual ~FeatherTool() override; - - static void setFeather(Int feather); - static void setRate(Int rate); - static void setRadius(Int Radius); -public: - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual WorldHeightMapEdit *getHeightMap() override {return m_htMapEditCopy;}; - virtual void activate() override; ///< Become the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/FenceOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/FenceOptions.h deleted file mode 100644 index baa7c259422..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/FenceOptions.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// FenceOptions.h : header file -// - -#include "TerrainSwatches.h" -#include "OptionsPanel.h" -#include "Common/AsciiString.h" -class WorldHeightMapEdit; -class MapObject; -///////////////////////////////////////////////////////////////////////////// -// FenceOptions dialog - -class FenceOptions : public COptionsPanel -{ -// Construction -public: - FenceOptions(CWnd* pParent = nullptr); ///< standard constructor - - virtual ~FenceOptions() override; ///< standard destructor - enum { NAME_MAX_LEN = 64 }; -// Dialog Data - //{{AFX_DATA(FenceOptions) - enum { IDD = IDD_FENCE_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(FenceOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(FenceOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeFenceSpacingEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - static FenceOptions *m_staticThis; - static Bool m_updating; - static Int m_currentObjectIndex; - static Real m_fenceSpacing; - static Real m_fenceOffset; - - CTreeCtrl m_objectTreeView; - MapObject *m_objectsList; - Bool m_customSpacing; - -protected: - void addObject( MapObject *mapObject, const char *pPath, const char *name, - Int objectNdx, HTREEITEM parent ); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - Bool setObjectTreeViewSelection(HTREEITEM parent, Int selection); - void updateObjectOptions(); - -public: - static void update(); - static Bool hasSelectedObject(); - static Real getFenceSpacing() {return m_fenceSpacing;} - static Real getFenceOffset() {return m_fenceOffset;} -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/FenceTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/FenceTool.h deleted file mode 100644 index 1418c84b361..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/FenceTool.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FenceTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -class MapObject; -class Vector3; -/*************************************************************************/ -/** FenceTool - Does the fence tool operation. -***************************************************************************/ -class FenceTool : public Tool -{ -protected: - CPoint m_downPt2d; - Coord3D m_downPt3d; - MapObject *m_mapObjectList; - Real m_curObjectWidth; - Real m_curObjectOffset; - Int m_objectCount; - -public: - FenceTool(); - virtual ~FenceTool() override; - -protected: - void updateMapObjectList(Coord3D downPt, Coord3D curPt, WbView* pView, CWorldBuilderDoc *pDoc, Bool checkPlayers); - -public: - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/FloodFillTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/FloodFillTool.h deleted file mode 100644 index fd49b3b83e0..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/FloodFillTool.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FloodFillTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/************************************************************************** - FloodFillTool -***************************************************************************/ -/// Fill area with texture tool. -class FloodFillTool : public Tool -{ -public: - FloodFillTool(); - virtual ~FloodFillTool() override; - -protected: - Int m_textureClassToDraw; ///< The texture to fill with. Foreground for mousedDown, background for mouseDownRt. - HCURSOR m_cliffCursor; - static Bool m_adjustCliffTextures; - -public: - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual void setCursor() override; - - Bool getAdjustCliffs() {return m_adjustCliffTextures;} - void setAdjustCliffs(Bool val) {m_adjustCliffTextures = val;} - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/GlobalLightOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/GlobalLightOptions.h deleted file mode 100644 index 9b4a8871f2a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/GlobalLightOptions.h +++ /dev/null @@ -1,137 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// GLOBALLIGHTOPTIONS.h : header file -// - -#include "WBPopupSlider.h" -#include "resource.h" -#include "CButtonShowColor.h" -///////////////////////////////////////////////////////////////////////////// -/// GlobalLightOptions modeless (floating) dialog - allows entry and display of brush width and feather. - -#define GLOBALLIGHT_OPTIONS_PANEL_SECTION "LightOptionsWindow" - -class GlobalLightOptions : public CDialog , public PopupSliderOwner -{ -// Construction -public: - enum {K_TERRAIN=1, K_OBJECTS=2, K_BOTH=3}; - enum {K_SUN=0, K_ACCENT1=1, K_ACCENT2=2}; - int kUIRedIDs[3];// = {IDC_RD_EDIT, IDC_RD_EDIT1, IDC_RD_EDIT2}; - int kUIGreenIDs[3];// = {IDC_GD_EDIT, IDC_GD_EDIT1, IDC_GD_EDIT2}; - int kUIBlueIDs[3];// = {IDC_BD_EDIT, IDC_BD_EDIT1, IDC_BD_EDIT2}; - CButtonShowColor m_colorButton; - - GlobalLightOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(GlobalLightOptions) - enum { IDD = IDD_GLOBAL_LIGHT_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GlobalLightOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(GlobalLightOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); - afx_msg void OnMove(int x, int y); - afx_msg void OnChangeFrontBackEdit(); - afx_msg void OnChangeLeftRightEdit(); - afx_msg void OnChangeColorEdit(); - afx_msg void OnRadioEverything(); - afx_msg void OnRadioObjects(); - afx_msg void OnRadioTerrain(); - afx_msg void OnColorPress(); - afx_msg void OnResetLights(); - afx_msg void OnClose(); - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - Real ComponentToPercent(Int component) - { - Real percent; - if (component >= 255) { - return 1.0; - } - if (component <= 0) { - return 0.0; - } - percent = (Real)component/255.0; - return percent; - } - Int PercentToComponent(Real percent) - { - Int component; - if (percent >= 1.0) { - return 255; - } - if (percent <= 0.0) { - return 0; - } - component = (percent * 255.0); - return component; - }; - BOOL GetInt(Int ctrlID, Int *rVal); - void PutInt(Int ctrlID, Int val); - -protected: - - Bool m_updating; ///. -*/ - -#pragma once - -#include -#include -#include "WorldBuilder.h" -#include "OptionsPanel.h" -#include "Common/STLTypedefs.h" - -// Used to store Display names in conjunction with internal names. -typedef std::pair PairNameDisplayName; -typedef std::vector VecPairNameDisplayName; -typedef std::vector::iterator VecPairNameDisplayNameIt; - - -// This is a utility function useful to get a display string from a pair of AsciiString -// UnicodeStrings. It attempts to use the UnicodeString, and if that fails then turns -// to the AsciiString -// As a last resort, it returns the EmptyString. -UnicodeString GetDisplayNameFromPair(const PairNameDisplayName *pNamePair); - -class GroveOptions : public COptionsPanel -{ - protected: - std::vector/**/> mVecGroup; - VecPairNameDisplayName mVecDisplayNames; - - Int mNumTrees; - - public: - GroveOptions(CWnd* pParent = nullptr); - virtual ~GroveOptions() override; - void makeMain(); - - virtual BOOL OnInitDialog() override; - int getNumTrees(); - int getNumType(int type); - AsciiString getTypeName(int type); - int getTotalTreePerc(); - Bool getCanPlaceInWater(); - Bool getCanPlaceOnCliffs(); - - protected: - void _setTreesToLists(); - void _buildTreeList(); - void _setDefaultRatios(); - void _setDefaultNumTrees(); - void _setDefaultPlacementAllowed(); - - afx_msg void _updateTreeWeights(); - afx_msg void _updateTreeCount(); - afx_msg void _updateGroveMakeup(); - afx_msg void _updatePlacementAllowed(); - - virtual void OnOK() override; - virtual void OnClose(); - DECLARE_MESSAGE_MAP() -}; - -extern GroveOptions *TheGroveOptions; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/GroveTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/GroveTool.h deleted file mode 100644 index a57425159a5..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/GroveTool.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// GroveTool.h -// Author: John Ahlquist, May 2001 - -#pragma once - -#include "Lib/BaseType.h" -#include "Tool.h" -#include "Common/MapObject.h" -class WorldHeightMapEdit; - -/*************************************************************************/ -/** GroveTool - Does the add a grove of trees tool operation. -***************************************************************************/ -/// Add a grove of trees tool. -class GroveTool : public Tool -{ -protected: - enum {HYSTERESIS = 3}; - CPoint m_downPt; - Bool m_dragging; - MapObject *m_headMapObj; - -protected: - void plantTree( Coord3D *pos ); - void plantShrub( Coord3D *pos ); - void plantGrove( Coord3D pos, Coord3D prevDir, Real baseHeight, Int level, CPoint bounds ); - void _plantGroveInBox(CPoint tl, CPoint br, WbView* pView); - - void addObj(Coord3D *pos, AsciiString name); - virtual void activate() override; - -public: - GroveTool(); - virtual ~GroveTool() override; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/HandScrollTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/HandScrollTool.h deleted file mode 100644 index 7a54b4b18d8..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/HandScrollTool.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// HandScrollTool.h -// Scrolling tool for worldbuilder. -// Author: John Ahlquist, May 2001 - -#pragma once - -#include "Tool.h" -/************************************************************************** - HandScrollTool -***************************************************************************/ -/// Scroll tool. -class HandScrollTool : public Tool -{ -public: - HandScrollTool(); - virtual ~HandScrollTool() override; - -protected: - enum {HYSTERESIS = 3}; - CPoint m_prevPt2d; - CPoint m_downPt2d; - Bool m_scrolling; - UINT m_mouseDownTime; // if m_trackingMode != TRACK_NONE, tickcount when mouse went down - -public: - /// Start scrolling. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - /// Scroll. - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - /// End scroll. - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual Bool followsTerrain() override {return false;}; -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ImpassableOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ImpassableOptions.h deleted file mode 100644 index c0a70433005..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ImpassableOptions.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -class ImpassableOptions : public CDialog -{ - public: - enum { IDD = IDD_IMPASSABLEOPTIONS }; - - public: - ImpassableOptions(CWnd* pParent = nullptr, Real defaultSlope = 45.0f); - virtual ~ImpassableOptions() override; - Real GetSlopeToShow() const { return m_slopeToShow; } - Real GetDefaultSlope() const { return m_defaultSlopeToShow; } - void SetDefaultSlopeToShow(Real slopeToShow) { m_slopeToShow = slopeToShow; } - - protected: - Real m_slopeToShow; // Clamped in the range of [0,90] - Real m_defaultSlopeToShow; - Bool m_showImpassableAreas; - - Bool ValidateSlope(); // Returns TRUE if it was valid, FALSE if it had to adjust it. - - protected: - virtual BOOL OnInitDialog() override; - afx_msg void OnAngleChange(); - afx_msg void OnPreview(); - DECLARE_MESSAGE_MAP() -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/LayersList.h b/GeneralsMD/Code/Tools/WorldBuilder/include/LayersList.h deleted file mode 100644 index 5280b3a574a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/LayersList.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: LayersList.h -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: LayersList.h */ -/* Created: John K. McDonald, Jr., 5/10/2002 */ -/* Desc: Layers List Declarations */ -/* Revision History: */ -/* 5/10/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////// -#include "Common/AsciiString.h" -#include -#include - -// DEFINES //////////////////////////////////////////////////////////////////// - -// FORWARD DECLARATIONS /////////////////////////////////////////////////////// -class MapObject; -class PolygonTrigger; - -// TYPE DEFINES /////////////////////////////////////////////////////////////// -typedef std::list ListMapObjectPtr; -typedef ListMapObjectPtr::iterator ListMapObjectPtrIt; - -typedef std::list ListPolygonTriggerPtr; -typedef ListPolygonTriggerPtr::iterator ListPolygonTriggerPtrIt; - -struct Layer -{ - AsciiString layerName; - ListMapObjectPtr objectsInLayer; - ListPolygonTriggerPtr polygonTriggersInLayer; - Bool show; -}; - -typedef std::list ListLayer; -typedef ListLayer::iterator ListLayerIt; - -// Class Definition for overridden Tree control that supports Right-click context sensitive menu. -class CLLTreeCtrl : public CTreeCtrl -{ - public: - AsciiString getLastClickedLayer() { return mLastClickedLayer; } - AsciiString getLastClickedObject() { return mLastClickedObject; } - - protected: - AsciiString mLastClickedLayer; - AsciiString mLastClickedObject; - void buildMoveMenu(CMenu* pPopup, UINT firstID); - virtual void OnRButtonDown(UINT nFlags, CPoint point); - DECLARE_MESSAGE_MAP() - -}; - - -// Class Definition - -class LayersList : public CDialog -{ - - public: - enum { IDD = IDD_LAYERSLIST }; - LayersList(UINT nIDTemplate = LayersList::IDD, CWnd *parentWnd = nullptr); - virtual ~LayersList() override; - - void resetLayers(); - void addMapObjectToLayersList(IN MapObject *objToAdd, AsciiString layerToAddTo = AsciiString(TheDefaultLayerName.c_str())); - void addPolygonTriggerToLayersList(IN PolygonTrigger *triggerToAdd, AsciiString layerToAddTo = AsciiString(TheDefaultLayerName.c_str())); - AsciiString removeMapObjectFromLayersList(IN MapObject *objToRemove); - AsciiString removePolygonTriggerFromLayersList(IN PolygonTrigger *triggerToRemove); - - void changeMapObjectLayer(IN MapObject *objToChange, AsciiString layerToPlaceOn); - void changePolygonTriggerLayer(IN PolygonTrigger *triggerToChange, AsciiString layerToPlaceOn); - - void addLayerNamed(IN AsciiString layerToAdd); - void removeLayerNamed(IN AsciiString layerToRemove); - void changeLayerName(IN AsciiString oldLayerName, IN AsciiString newLayerName); - void mergeLayerInto(IN ListLayerIt src, IN ListLayerIt dst); - - Bool isLayerHidden(IN AsciiString layerToTest); - - void updateUIFromList(); - - void disableUpdates() { m_performUpdates = false; } - void enableUpdates() { m_performUpdates = true; updateUIFromList(); } - - const ListLayer& GetAllLayers() const { return mLayers; } - - static MapObject *findObjectByUID(AsciiString objectIDToFind); - static PolygonTrigger *findPolygonTriggerByUID(AsciiString objectIDToFind); - static Bool findAndSelectMapObject(AsciiString selectedItemAsciiString); - static Bool findAndSelectPolygonTrigger(AsciiString selectedItemAsciiString); - static void unselectAllMapObjects(); - static void unselectAllPolygonTriggers(); - - public: - // This is a string because making it an AsciiString makes us barf on construction. :-( - static std::string TheDefaultLayerName; - static std::string ThePolygonTriggerLayerName; - static std::string TheDefaultNewLayerName; - static std::string TheActiveLayerName; - static const std::string TheUnmutableDefaultLayerName; - - protected: - AsciiString mCurrentlyEditingLabel; - - ListLayer mLayers; - CLLTreeCtrl *mTree; - CImageList mImageList; - Bool m_performUpdates; - Bool m_activatedLayer; - - - HTREEITEM findTreeLayerNamed(const AsciiString& nameToFind); - HTREEITEM findTreeObjectNamed(const AsciiString& objectToFind, HTREEITEM layerItem); - - // This function takes an MapObject, and does one of the following: - // 1) Return true if the MapObject can be found, and - // layerIt points to a valid layer iterator in which the MapObject was found - // MapObjectIt points to a valid MapObject iterator on the layerIts MapObjectsInLayer member - // 2) Returns false if the MapObject cannot be found. - Bool findMapObjectAndList(IN MapObject *MapObjectToFind, OUT ListLayerIt *layerIt = nullptr, OUT ListMapObjectPtrIt *MapObjectIt = nullptr); - Bool findPolygonTriggerAndList(IN PolygonTrigger *PolygonTriggerToFind, OUT ListLayerIt *layerIt = nullptr, OUT ListPolygonTriggerPtrIt *PolygonTriggerIt = nullptr); - - // This function takes a layer name, and does one of the following: - // 1) Return true if the layer can be found, and - // layerIt points to a valid layer iterator named layerName - // 2) Returns false if the layer cannot be found. - Bool findLayerNamed(IN AsciiString layerName, OUT ListLayerIt *layerIt = nullptr); - - void addMapObjectToLayer(IN MapObject *objToAdd, IN ListLayerIt *layerIt); - void addPolygonTriggerToLayer(IN PolygonTrigger *objToAdd, IN ListLayerIt *layerIt); - void removeMapObjectFromLayer(IN MapObject *objToRemove, IN ListLayerIt *layerIt = nullptr, IN ListMapObjectPtrIt *MapObjectIt = nullptr); - void removePolygonTriggerFromLayer(IN PolygonTrigger *triggerToRemove, IN ListLayerIt *layerIt = nullptr, IN ListPolygonTriggerPtrIt *PolygonTriggerIt = nullptr); - void updateObjectRenderFlags(IN ListLayerIt *layerIt); - void updateTreeImages(); - - protected: - virtual void OnOK() override; - virtual void OnCancel() override; - virtual BOOL OnInitDialog() override; - - afx_msg void OnBeginEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult); - afx_msg void OnEndEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult); - - afx_msg void OnMergeLayer(UINT commandID); - afx_msg void OnMergeObject(UINT commandID); - afx_msg void OnMergeViewSelection(UINT commandID); - afx_msg void OnSelectActiveLayer(); - - - afx_msg void OnSelectLayerObject(); - afx_msg void OnNewLayer(); - afx_msg void OnDeleteLayer(); - afx_msg void OnHideShowLayer(); - DECLARE_MESSAGE_MAP() -}; - -extern LayersList *TheLayersList; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/LightOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/LightOptions.h deleted file mode 100644 index f44ea50f267..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/LightOptions.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// LightOptions.h : header file -// -#include "OptionsPanel.h" - -class MapObject; -///////////////////////////////////////////////////////////////////////////// -// LightOptions dialog - -class LightOptions : public COptionsPanel -{ - -// Construction -public: - LightOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(LightOptions) - enum { IDD = IDD_LIGHT_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LightOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(LightOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeLightEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static LightOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - Bool m_updating; ///. -*/ - -// MainFrm.h : interface of the CMainFrame class -// -///////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Lib/BaseType.h" -#include "MyToolbar.h" -#include "brushoptions.h" -#include "FeatherOptions.h" -#include "CellWidth.h" -#include "TerrainMaterial.h" -#include "BlendMaterial.h" -#include "MoundOptions.h" -#include "ObjectOptions.h" -#include "FenceOptions.h" -#include "RoadOptions.h" -#include "ContourOptions.h" -#include "MeshMoldOptions.h" -#include "WaypointOptions.h" -#include "WaterOptions.h" -#include "LightOptions.h" -#include "mapobjectprops.h" -#include "GroveOptions.h" -#include "RampOptions.h" -#include "GlobalLightOptions.h" -#include "CameraOptions.h" -#include "ScorchOptions.h" -#include "BuildList.h" -#include "RulerOptions.h" - -#define TWO_D_WINDOW_SECTION "TwoDWindow" -#define MAIN_FRAME_SECTION "MainFrame" - -class LayersList; -class ScriptDialog; - -class CMainFrame : public CFrameWnd -{ - DECLARE_DYNAMIC(CMainFrame) - -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - virtual BOOL PreCreateWindow(CREATESTRUCT& cs) override; - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMainFrame() override; -#ifdef RTS_DEBUG - virtual void AssertValid() const override; - virtual void Dump(CDumpContext& dc) const override; -#endif - - static CMainFrame *GetMainFrame() { return TheMainFrame; } - - void showOptionsDialog(Int dialogID); - void OnEditGloballightoptions(); - void ResetWindowPositions(); - void adjustWindowSize(); - Bool isAutoSaving() {return m_autoSaving;}; - void handleCameraChange(); - void onEditScripts(); - -protected: // control bar embedded members - CStatusBar m_wndStatusBar; - CToolBar m_wndToolBar; - CToolBar m_floatingToolBar; - BrushOptions m_brushOptions; - TerrainMaterial m_terrainMaterial; - BlendMaterial m_blendMaterial; - ObjectOptions m_objectOptions; - FenceOptions m_fenceOptions; - MapObjectProps m_mapObjectProps; - MoundOptions m_moundOptions; - RoadOptions m_roadOptions; - FeatherOptions m_featherOptions; - MeshMoldOptions m_meshMoldOptions; - WaypointOptions m_waypointOptions; - WaterOptions m_waterOptions; - LightOptions m_lightOptions; - BuildList m_buildListOptions; - GroveOptions m_groveOptions; - RampOptions m_rampOptions; - ScorchOptions m_scorchOptions; - COptionsPanel m_noOptions; - GlobalLightOptions m_globalLightOptions; - CameraOptions m_cameraOptions; - LayersList* m_layersList; - ScriptDialog* m_scriptDialog; - RulerOptions m_rulerOptions; - - CWnd *m_curOptions; - Int m_curOptionsX; - Int m_curOptionsY; - Int m_optionsPanelWidth; - Int m_optionsPanelHeight; - Int m_globalLightOptionsWidth; - Int m_globalLightOptionsHeight; - - Int m_3dViewWidth; - - Bool m_autoSaving; ///< True if we are autosaving. - UINT m_hAutoSaveTimer; ///< Timer that triggers for autosave. - Bool m_autoSave; ///< If true, then do autosaves. - Int m_autoSaveInterval; ///< Time between autosaves in seconds. - - static CMainFrame *TheMainFrame; - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnMove(int x, int y); - afx_msg void OnViewBrushfeedback(); - afx_msg void OnUpdateViewBrushfeedback(CCmdUI* pCmdUI); - afx_msg void OnDestroy(); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg void OnEditCameraoptions(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/MapPreview.h b/GeneralsMD/Code/Tools/WorldBuilder/include/MapPreview.h deleted file mode 100644 index 47f82577383..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/MapPreview.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: MapPreview.h ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Oct 2002 -// -// Filename: MapPreview.h -// -// author: Chris Huybregts -// -// purpose: -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// TYPE DEFINES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -enum -{ - MAP_PREVIEW_HEIGHT = 128,//256, - MAP_PREVIEW_WIDTH = 128,//256, -}; - -class MapPreview -{ -public: - MapPreview(); - void save( CString mapName ); -private: - void interpolateColorForHeight( RGBColor *color, Real height, Real hiZ, Real midZ, Real loZ ); - Bool mapPreviewToWorld(const ICoord2D *radar, Coord3D *world); - void buildMapPreviewTexture( CString tgaName ); - - UnsignedInt m_pixelBuffer[MAP_PREVIEW_HEIGHT][MAP_PREVIEW_WIDTH]; - - -}; -//----------------------------------------------------------------------------- -// INLINING /////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// EXTERNALS ////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/MapSettings.h b/GeneralsMD/Code/Tools/WorldBuilder/include/MapSettings.h deleted file mode 100644 index d40335d3e49..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/MapSettings.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// MapSettings.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// MapSettings dialog - -class MapSettings : public CDialog -{ -// Construction -public: - MapSettings(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(MapSettings) - enum { IDD = IDD_MAP_SETTINGS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MapSettings) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(MapSettings) - afx_msg void OnChangeMapTimeofday(); - afx_msg void OnChangeMapWeather(); - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - afx_msg void OnChangeMapTitle(); - afx_msg void OnChangeMapCompression(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldOptions.h deleted file mode 100644 index 7eb1c3c263a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldOptions.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// MeshMoldOptions.h : header file -// -#include "WBPopupSlider.h" -#include "OptionsPanel.h" -#include "Common/AsciiString.h" - -///////////////////////////////////////////////////////////////////////////// -// MeshMoldOptions dialog - -class MeshMoldOptions : public COptionsPanel , public PopupSliderOwner -{ -// Construction -public: - MeshMoldOptions(CWnd* pParent = nullptr); // standard constructor - enum {MIN_ANGLE=-180, - MAX_ANGLE=180, - MIN_HEIGHT=-10, - MAX_HEIGHT=256, - MIN_SCALE=1, - MAX_SCALE=200}; - -// Dialog Data - //{{AFX_DATA(MeshMoldOptions) - enum { IDD = IDD_MESHMOLD_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MeshMoldOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnInitDialog() override; - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(MeshMoldOptions) - afx_msg void OnPreview(); - afx_msg void OnApplyMesh(); - afx_msg void OnChangeScaleEdit(); - afx_msg void OnChangeHeightEdit(); - afx_msg void OnChangeAngleEdit(); - afx_msg void OnRaise(); - afx_msg void OnRaiseLower(); - afx_msg void OnLower(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - WBPopupSliderButton m_anglePopup; - WBPopupSliderButton m_scalePopup; - WBPopupSliderButton m_HeightPopup; - CTreeCtrl m_moldTreeView; - Bool m_updating; - AsciiString m_meshModelName; - - static Real m_currentHeight; - static Real m_currentScale; - static Int m_currentAngle; - static Bool m_doingPreview; - static Bool m_raiseOnly; - static Bool m_lowerOnly; - -public: - static void setScale(Real scale); - static void setHeight(Real height); - static void setAngle(Int angle); - - static Real getHeight() {return m_currentHeight;}; - static Real getScale() {return m_currentScale;}; - static Int getAngle() {return m_currentAngle;}; - static MeshMoldOptions *m_staticThis; - static Bool isDoingPreview() {return m_doingPreview;}; - static Bool isRaisingOnly() {return m_raiseOnly;}; - static Bool isLoweringOnly() {return m_lowerOnly;}; - static AsciiString getModelName() {if (m_staticThis) return m_staticThis->m_meshModelName; return "";}; - -public: //PopupSliderOwner methods. - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) override; - virtual void PopSliderChanged(const long sliderID, long theVal) override; - virtual void PopSliderFinished(const long sliderID, long theVal) override; -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldTool.h deleted file mode 100644 index c2f96107e5a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/MeshMoldTool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MeshMoldTool.h -// Terrain shaping tools for worldbuilder. -// Author: John Ahlquist, Oct. 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** MeshMoldTool - Does the Mesh Mold tool operation. -***************************************************************************/ -/// Height brush tool. -class MeshMoldTool : public Tool -{ -protected: - - CPoint m_prevViewPt; ///< Previous tracking location in view coords. - Bool m_offsettingZ; ///< True if we are raising or lowering the mesh along z axis. - Coord3D m_prevDocPt; ///< Previous tracking location in doc coords. - static Coord3D m_toolPos; ///< Current location of the mesh on the terrain. - static Bool m_tracking; ///< True if we are tracking a mesh on screen. - static WorldHeightMapEdit *m_htMapEditCopy; ///< ref counted. - -public: - MeshMoldTool(); - virtual ~MeshMoldTool() override; -protected: - static void applyMesh(CWorldBuilderDoc *pDoc); ///< Apply the mesh to copy of terrain. - -public: - static void apply(CWorldBuilderDoc *pDoc); ///< Apply the mesh to the terrain & execute undoable. - -public: //Tool methods. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual WorldHeightMapEdit *getHeightMap() override {return m_htMapEditCopy;}; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become the current tool. - virtual Bool followsTerrain() override {return false;}; - -public: // Methods specific to MeshMoldTool. - static void updateMeshLocation(Bool changePreview); - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/MoundOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/MoundOptions.h deleted file mode 100644 index 8a6cda92ba1..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/MoundOptions.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// MoundOptions.h : header file -// -#include "WBPopupSlider.h" -#include "OptionsPanel.h" - -///////////////////////////////////////////////////////////////////////////// -// MoundOptions dialog - -class MoundOptions : public COptionsPanel , public PopupSliderOwner -{ -// Construction -public: - enum {MIN_MOUND_HEIGHT=1, - MAX_MOUND_HEIGHT=21 - }; - -// Construction -public: - enum {MIN_BRUSH_SIZE=1, - MAX_BRUSH_SIZE=51, - MIN_FEATHER=0, - MAX_FEATHER=20}; - - MoundOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(MoundOptions) - enum { IDD = IDD_BRUSH_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MoundOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(MoundOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeFeatherEdit(); - afx_msg void OnChangeSizeEdit(); - afx_msg void OnChangeHeightEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static MoundOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - static Int m_currentWidth; ///< current brush width in the ui. - static Int m_currentFeather; ///< current feather width in the ui. - static Int m_currentHeight; - - Bool m_updating; ///. -*/ - -// MoundTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/************************************************************************* -** MoundTool -***************************************************************************/ -class MoundTool : public Tool -{ - enum {MIN_DELAY_TIME=60}; // 60 ms minimum delay between applications. -protected: - WorldHeightMapEdit *m_htMapEditCopy; //< ref counted. - WorldHeightMapEdit *m_htMapSaveCopy; //< ref counted. - Bool m_raising; ///< True if mounding, false if digging. - Int m_lastMoveTime; ///< Last system clock time. - - static Int m_moundHeight; - static Int m_brushWidth; - static Int m_brushFeather; - -public: - MoundTool(); - virtual ~MoundTool() override; - -public: - static Int getMoundHeight() {return m_moundHeight;}; - static void setMoundHeight(Int height); - static Int getWidth() {return m_brushWidth;}; ///. -*/ - -// MyToolBar.h -// Class to do custom toolbar. -// Author: John Ahlquist, April 2001 - -#pragma once - -/************************************************************************* -** CellSizeToolBar -***************************************************************************/ -class CellSizeToolBar : public CDialogBar -{ -protected: - static CellSizeToolBar* m_staticThis; - CSliderCtrl m_cellSlider; - -protected: - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) override; - DECLARE_MESSAGE_MAP() - -public: - virtual ~CellSizeToolBar() override; - void SetupSlider(); - static void CellSizeChanged(Int cellSize); - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/NewHeightMap.h b/GeneralsMD/Code/Tools/WorldBuilder/include/NewHeightMap.h deleted file mode 100644 index 8ecf703dee3..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/NewHeightMap.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// NewHeightMap.h : header file -// - -#include "Lib/BaseType.h" - -typedef struct { - Int xExtent; - Int yExtent; - Int initialHeight; - Int borderWidth; - Bool forResize; ///< If for resize, then the anchor bools are set. - Bool anchorTop; ///< It can be anchor top, or anchor bottom, or neither, but not both. - Bool anchorBottom; - Bool anchorLeft; ///< It can be anchor left, or anchor right, or neither but not both. - Bool anchorRight; -} TNewHeightInfo; - - -///////////////////////////////////////////////////////////////////////////// -// CNewHeightMap dialog - -class CNewHeightMap : public CDialog -{ -// Construction -public: - CNewHeightMap(TNewHeightInfo *hiP, const char *label, CWnd* pParent = nullptr); // standard constructor - - void GetHeightInfo(TNewHeightInfo *hiP) {*hiP = mHeightInfo; }; -// Dialog Data - //{{AFX_DATA(CNewHeightMap) - enum { IDD = IDD_NewHeightMap }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CNewHeightMap) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override; - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - TNewHeightInfo mHeightInfo; - const char *m_label; - -protected: - Bool doAnchorButton(Int buttonID); - -protected: - - // Generated message map functions - //{{AFX_MSG(CNewHeightMap) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectOptions.h deleted file mode 100644 index fe4fc594694..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectOptions.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ObjectOptions.h : header file -// - -#include "ObjectPreview.h" -#include "OptionsPanel.h" -#include "Common/AsciiString.h" -class WorldHeightMapEdit; -class MapObject; -///////////////////////////////////////////////////////////////////////////// -// ObjectOptions dialog - -class ObjectOptions : public COptionsPanel -{ -// Construction -public: - ObjectOptions(CWnd* pParent = nullptr); ///< standard constructor - - virtual ~ObjectOptions() override; ///< standard destructor - enum { NAME_MAX_LEN = 64 }; -// Dialog Data - //{{AFX_DATA(ObjectOptions) - enum { IDD = IDD_OBJECT_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ObjectOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(ObjectOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnEditchangeOwningteam(); - afx_msg void OnCloseupOwningteam(); - afx_msg void OnSelchangeOwningteam(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - static ObjectOptions *m_staticThis; - static Bool m_updating; - static Int m_currentObjectIndex; - static char m_currentObjectName[NAME_MAX_LEN]; - static AsciiString m_curOwnerName; - - CTreeCtrl m_objectTreeView; - MapObject *m_objectsList; - ObjectPreview m_objectPreview; - -protected: - void addObject( MapObject *mapObject, const char *pPath, - Int objectNdx, HTREEITEM parent ); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - HTREEITEM findOrDont(const char *pLabel); - HTREEITEM _FindOrDont(const char* pLabel, HTREEITEM startPoint); - Bool setObjectTreeViewSelection(HTREEITEM parent, Int selection); - void updateLabel(); - static MapObject *getCurMapObject(); - -public: - static const char * getCurObjectName() {return m_currentObjectName;}; - static MapObject *duplicateCurMapObjectForPlace(const Coord3D* loc, Real angle, Bool checkPlayers = true); - static MapObject *getObjectNamed(AsciiString name); - static Int getObjectNamedIndex(const AsciiString& name); - static void selectObject(const MapObject* pObj); - static Real getCurObjectHeight(); - static void update(); - static AsciiString getCurGdfName(); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectPreview.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectPreview.h deleted file mode 100644 index 9169b23dd48..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectPreview.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ObjectPreview.h : header file -// - -#include "Lib/BaseType.h" -///////////////////////////////////////////////////////////////////////////// -// ObjectPreview window - -class ThingTemplate; - -class ObjectPreview : public CWnd -{ -// Construction -public: - ObjectPreview(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ObjectPreview) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~ObjectPreview() override; - - void SetThingTemplate(const ThingTemplate *tTempl); - - // Generated message map functions -protected: - //{{AFX_MSG(ObjectPreview) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - void DrawMyTexture(CDC *pDc, int top, int left, Int width, Int height, UnsignedByte *rgbData); - - const ThingTemplate *m_tTempl; - -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectTool.h deleted file mode 100644 index 29929d98fca..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ObjectTool.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ObjectTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/*************************************************************************/ -/** ObjectTool - Does the BlendEdgesOut tool operation. -***************************************************************************/ -/// Blend edges out tool. -class ObjectTool : public Tool -{ -protected: - CPoint m_downPt2d; - Coord3D m_downPt3d; - -public: - ObjectTool(); - virtual ~ObjectTool() override; - -public: - static Real calcAngle(Coord3D downPt, Coord3D curPt, WbView* pView); - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/OpenMap.h b/GeneralsMD/Code/Tools/WorldBuilder/include/OpenMap.h deleted file mode 100644 index 02e0c48704d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/OpenMap.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// OpenMap.h : header file -// - -#define MAP_OPENSAVE_PANEL_SECTION "MapOpenSavePanel" - -typedef struct { - CString filename; - Bool browse; -} TOpenMapInfo; - -///////////////////////////////////////////////////////////////////////////// -// OpenMap dialog - -class OpenMap : public CDialog -{ -// Construction -public: - OpenMap(TOpenMapInfo *pInfo, CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(OpenMap) - enum { IDD = IDD_OPEN_MAP }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(OpenMap) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - TOpenMapInfo *m_pInfo; - void populateMapListbox( Bool systemMaps ); - Bool m_usingSystemDir; -protected: - - // Generated message map functions - //{{AFX_MSG(OpenMap) - afx_msg void OnBrowse(); - afx_msg void OnSystemMaps(); - afx_msg void OnUserMaps(); - virtual void OnOK() override; - virtual BOOL OnInitDialog() override; - afx_msg void OnDblclkOpenList(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/OptionsPanel.h b/GeneralsMD/Code/Tools/WorldBuilder/include/OptionsPanel.h deleted file mode 100644 index 648b9795dbe..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/OptionsPanel.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// OptionsPanel.h : header file -// - -#include "resource.h" - -#define OPTIONS_PANEL_SECTION "OptionsWindow" - -///////////////////////////////////////////////////////////////////////////// -// COptionsPanel dialog - -class COptionsPanel : public CDialog -{ -// Construction -public: - COptionsPanel(Int dlgid = 0, CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(COptionsPanel) - enum { IDD = IDD_NO_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(COptionsPanel) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(COptionsPanel) - afx_msg void OnMove(int x, int y); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnEditUndo(); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/PickUnitDialog.h b/GeneralsMD/Code/Tools/WorldBuilder/include/PickUnitDialog.h deleted file mode 100644 index 885f875a319..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/PickUnitDialog.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// PickUnitDialog.h : header file -// - -#include "Common/AsciiString.h" -#include "Common/ThingSort.h" - -#define BUILD_PICK_PANEL_SECTION "PickUnitWindow" - -class MapObject; -class ThingTemplate; -///////////////////////////////////////////////////////////////////////////// -// PickUnitDialog dialog - -class PickUnitDialog : public CDialog -{ -protected: - enum { NAME_MAX_LEN = 64 }; - void addObject( MapObject *mapObject, const char *pPath, Int index, HTREEITEM parent ); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - Int m_currentObjectIndex; - char m_currentObjectName[NAME_MAX_LEN]; - CTreeCtrl m_objectTreeView; - MapObject *m_objectsList; - Bool m_allowable[ES_NUM_SORTING_TYPES]; - Bool m_factionOnly; - -// Construction -public: - PickUnitDialog(CWnd* pParent = nullptr); // standard constructor - PickUnitDialog(UINT id, CWnd* pParent = nullptr); // standard constructor - virtual ~PickUnitDialog() override; ///< standard destructor - -// Dialog Data - //{{AFX_DATA(PickUnitDialog) - enum { IDD = IDD_PICKUNIT }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PickUnitDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(PickUnitDialog) - virtual BOOL OnInitDialog() override; - afx_msg void OnMove(int x, int y); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -public: - AsciiString getPickedUnit(); - Bool IsAllowableType(EditorSortingType sort, Bool isBuildable); - void SetAllowableType(EditorSortingType sort); - const ThingTemplate* getPickedThing(); - void SetFactionOnly(Bool faction) {m_factionOnly = faction;} - void SetupAsPanel(); -}; - -class ReplaceUnitDialog : public PickUnitDialog -{ -public: - ReplaceUnitDialog(CWnd* pParent = nullptr); // standard constructor - - void setMissing(AsciiString name) {m_missingName = name;}; - -protected: - - // Generated message map functions - //{{AFX_MSG(ReplaceUnitDialog) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - AsciiString m_missingName; - - enum { IDD = IDD_REPLACEUNIT }; -}; - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/PointerTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/PointerTool.h deleted file mode 100644 index ea207e939ff..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/PointerTool.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// PointerTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "PolygonTool.h" -class WorldHeightMapEdit; -#include "../../GameEngine/Include/Common/MapObject.h" - -class ModifyObjectUndoable; -/*************************************************************************/ -/** PointerTool - Does the select/move tool operation. -***************************************************************************/ -/// Blend edges out tool. -class PointerTool : public PolygonTool -{ -protected: - enum {HYSTERESIS = 3}; - CPoint m_downPt2d; - Coord3D m_downPt3d; - MapObject *m_curObject; - - Bool m_moving; ///< True if we are drag moving an object. - Bool m_rotating; ///< True if we are rotating an object. - Bool m_dragSelect; ///< True if we are drag selecting. - - Bool m_doPolyTool; ///< True if we are using the polygon tool to modify a polygon triggter. - - ModifyObjectUndoable *m_modifyUndoable; ///< The modify undoable that is in progress while we track the mouse. - - Bool m_mouseUpRotate;///< True if we are over the "rotate" hotspot. - HCURSOR m_rotateCursor; - Bool m_mouseUpMove;///< True if we are over the "move" hotspot. - HCURSOR m_moveCursor; - -protected: - void checkForPropertiesPanel(); - -public: - PointerTool(); - virtual ~PointerTool() override; - -public: - /// Clear the selection on activate or deactivate. - virtual void activate() override; - virtual void deactivate() override; - - virtual void setCursor() override; - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - -public: - static void clearSelection(); ///< Clears the selected objects selected flags. - static Bool allowPick(MapObject* pMapObj, WbView* pView); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/PolygonTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/PolygonTool.h deleted file mode 100644 index 52a03ca1520..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/PolygonTool.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// PolygonTool.h -// Polygon area trigger tool for worldbuilder. -// Author: John Ahlquist, Nov. 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -class MapObject; -class PolygonTrigger; -class MovePolygonUndoable; -/*************************************************************************/ -/** PolygonTool - Does the add/select polygon operation. -***************************************************************************/ -/// Select tile tool. -class PolygonTool : public Tool -{ -public: - PolygonTool(); - virtual ~PolygonTool() override; - -protected: - Coord3D m_poly_mouseDownPt; - Coord3D m_poly_unsnappedMouseDownPt; - Bool m_poly_isDraggingPoint; - Bool m_poly_justPicked; - - Bool m_poly_mouseUpPlus;///< True if we are over the "Add point" hotspot. - HCURSOR m_poly_plusCursor; - Bool m_poly_mouseUpMove;///< True if we are over the "move" hotspot. - HCURSOR m_poly_moveCursor; - - MovePolygonUndoable *m_poly_moveUndoable; - - static Bool m_poly_isAdding; - static Int m_poly_dragPointNdx; - static Bool m_poly_isActive; - static PolygonTrigger *m_poly_curSelectedPolygon; - -protected: - static Int poly_pickPoint(PolygonTrigger *pTrig, CPoint viewPt, WbView* pView); - static Int poly_getInsertIndex(PolygonTrigger *pTrig, Coord3D loc); - Bool poly_snapToPoly(Coord3D *pLoc); - static Bool poly_pickPoly(PolygonTrigger *pTrig, Coord3D pLoc, Int tolerance); - void poly_pickOnMouseDown(CPoint viewPt, WbView* pView); - void startMouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc); - -public: - static Bool isActive() {return m_poly_isActive;}; - static Bool deleteSelectedPolygon(); - static Bool isSelected(PolygonTrigger *pTrig) {return (pTrig && (pTrig==m_poly_curSelectedPolygon));}; - static Int getSelectedPointNdx() {return m_poly_dragPointNdx;}; - static PolygonTrigger *pickPolygon(Coord3D loc, CPoint viewPt, WbView* pView); - static Bool isSelectedOpen() {return m_poly_isAdding;}; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void setCursor() override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/RampOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/RampOptions.h deleted file mode 100644 index e9993d4c427..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/RampOptions.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: RampOptions.h -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: RampOptions.h */ -/* Created: John K. McDonald, Jr., 4/23/2002 */ -/* Desc: // Apply button for ramps. */ -/* Revision History: */ -/* 4/23/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////// -#include "OptionsPanel.h" -#include "resource.h" - -// DEFINES //////////////////////////////////////////////////////////////////// -// TYPE DEFINES /////////////////////////////////////////////////////////////// -// FORWARD DECLARATIONS /////////////////////////////////////////////////////// - -class RampOptions : public COptionsPanel -{ - Bool m_shouldApplyTheRamp; - Real m_rampWidth; - public: - enum { IDD = IDD_RAMP_OPTIONS }; - RampOptions(CWnd* pParent = nullptr); - virtual ~RampOptions() override; - - Bool shouldApplyTheRamp(); - Real getRampWidth() { return m_rampWidth; } - - afx_msg void OnApply(); - afx_msg void OnWidthChange(); - - DECLARE_MESSAGE_MAP() -}; - -extern RampOptions* TheRampOptions; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/RampTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/RampTool.h deleted file mode 100644 index 135c4a790b7..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/RampTool.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: RampTool.h -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: RampTool.h */ -/* Created: John K. McDonald, Jr., 4/19/2002 */ -/* Desc: // The ramp tool for the developers. */ -/* Revision History: */ -/* 4/19/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////// -#include "Tool.h" -// DEFINES //////////////////////////////////////////////////////////////////// -// TYPE DEFINES /////////////////////////////////////////////////////////////// -// FORWARD DECLARATIONS /////////////////////////////////////////////////////// - -class RampTool : public Tool -{ - Coord3D mStartPoint; - Coord3D mEndPoint; - Coord3D mCurvePoint; - - Bool mIsMouseDown; - - public: - RampTool(); - virtual void activate() override; - virtual void deactivate() override; ///< Become not the current tool. - - virtual Bool followsTerrain() override; - - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - - protected: - void drawFeedback(Coord3D* endPoint); - void applyRamp(CWorldBuilderDoc* pDoc); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/RoadOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/RoadOptions.h deleted file mode 100644 index 616dd382e49..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/RoadOptions.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// RoadOptions.h : header file -// - -#include "TerrainSwatches.h" -#include "OptionsPanel.h" -#include "Common/AsciiString.h" - -class WorldHeightMapEdit; -///////////////////////////////////////////////////////////////////////////// -// RoadOptions dialog - -class RoadOptions : public COptionsPanel -{ -// Construction -public: - RoadOptions(CWnd* pParent = nullptr); ///< standard constructor - - virtual ~RoadOptions() override; ///< standard destructor - enum { NAME_MAX_LEN = 64 }; -// Dialog Data - //{{AFX_DATA(RoadOptions) - enum { IDD = IDD_ROAD_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(RoadOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(RoadOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnTightCurve(); - afx_msg void OnAngled(); - afx_msg void OnBroadCurve(); - afx_msg void OnJoin(); - afx_msg void OnApplyRoad(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - static RoadOptions *m_staticThis; - static Bool m_updating; - static Int m_currentRoadIndex; - static Int m_numberOfRoads; - static Int m_numberOfBridges; - static AsciiString m_currentRoadName; - static Bool m_angleCorners; - static Bool m_tightCurve; - static Bool m_doJoin; - CTreeCtrl m_roadTreeView; - -protected: - void addRoad(char *pPath, Int objectNdx, HTREEITEM parent); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - Bool findAndSelect(HTREEITEM parent, AsciiString label); - Bool setRoadTreeViewSelection(HTREEITEM parent, Int selection); - void updateLabel(); - void ChangeRoadType(AsciiString newRoad); - void SelectConnected(); - -public: - static AsciiString getCurRoadName() {return m_currentRoadName;} - static Bool isBridge() {return (m_currentRoadIndex >= m_numberOfRoads);} - static Bool isAngled() {return m_angleCorners;} - static Bool isTightCurve() {return m_tightCurve;} - static Bool isJoin() {return m_doJoin;} - static void updateSelection(); - static Bool selectionIsRoadsOnly(); - void applyToSelection(); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/RoadTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/RoadTool.h deleted file mode 100644 index f0a091a72a7..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/RoadTool.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// RoadTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, June 2001 - -#pragma once - -#include "Tool.h" -#include "W3DDevice/GameClient/WorldHeightMap.h" -class WorldHeightMapEdit; -#define ROAD_SNAP_DISTANCE (1.0f) -/*************************************************************************/ -/** RoadTool - Does the Add a section of road tool operation. -***************************************************************************/ -/// Road segment tool. -class RoadTool : public Tool -{ -protected: - enum {HYSTERESIS = 3, - MIN_LENGTH = 4}; - MapObject *m_mapObj; - -private: - MapObject* findSegment(const Coord3D *pLoc, Coord3D *outLoc); - -public: - RoadTool(); - virtual ~RoadTool() override; - -public: - static Bool snap(Coord3D *pLoc, Bool skipLast); - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/RulerOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/RulerOptions.h deleted file mode 100644 index ce6e8a0ec27..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/RulerOptions.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// RulerOptions.h : header file -// -#include "OptionsPanel.h" - -///////////////////////////////////////////////////////////////////////////// -// RulerOptions dialog - -class RulerOptions : public COptionsPanel -{ - -// Construction -public: - - RulerOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(RulerOptions) - enum { IDD = IDD_RULER_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(RulerOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(RulerOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeWidthEdit(); - afx_msg void OnChangeCheckRuler(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static RulerOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - - Bool m_updating; ///. -*/ - -// RulerTool.h -// Author: Mike Lytle, January 2003 - -#pragma once - -#include "Tool.h" - -class RulerTool : public Tool -{ -protected: - Coord3D m_downPt3d; - int m_rulerType; - WbView* m_View; - Real m_savedLength; - - static RulerTool* m_staticThis; - -public: - RulerTool(); - virtual ~RulerTool() override; - -public: - /// Clear the selection on activate or deactivate. - virtual void activate() override; - virtual void deactivate() override; - - virtual void setCursor() override; - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual Bool followsTerrain() override {return false;}; - - static void setLength(Real length); - static Bool switchType(); - static int getType(); - static Real getLength(); - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/SaveMap.h b/GeneralsMD/Code/Tools/WorldBuilder/include/SaveMap.h deleted file mode 100644 index 09afb838d51..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/SaveMap.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// SaveMap.h : header file -// - -#define MAP_OPENSAVE_PANEL_SECTION "MapOpenSavePanel" - -typedef struct { - CString filename; - Bool browse; - Bool usingSystemDir; -} TSaveMapInfo; - -///////////////////////////////////////////////////////////////////////////// -// SaveMap dialog - -class SaveMap : public CDialog -{ -// Construction -public: - SaveMap(TSaveMapInfo *pInfo, CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(SaveMap) - enum { IDD = IDD_SAVE_MAP }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(SaveMap) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - TSaveMapInfo *m_pInfo; - void populateMapListbox( Bool systemMaps ); - Bool m_usingSystemDir; -protected: - - // Generated message map functions - //{{AFX_MSG(SaveMap) - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnBrowse(); - afx_msg void OnSystemMaps(); - afx_msg void OnUserMaps(); - afx_msg void OnSelchangeSaveList(); - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScorchOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScorchOptions.h deleted file mode 100644 index 20cbae58e0d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScorchOptions.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScorchOptions.h : header file -// - -#include "WBPopupSlider.h" -#include "OptionsPanel.h" -#include "Common/Dict.h" -#include "Common/GameType.h" - -class MapObject; -///////////////////////////////////////////////////////////////////////////// -// ScorchOptions dialog - -class ScorchOptions : public COptionsPanel, public PopupSliderOwner -{ -// Construction -public: - ScorchOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(ScorchOptions) - enum { IDD = IDD_SCORCH_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ScorchOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(ScorchOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeScorchtype(); - afx_msg void OnChangeSizeEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - static MapObject *getSingleSelectedScorch(); - void updateTheUI(); - WBPopupSliderButton m_radiusPopup; - std::vector m_allSelectedDicts; - Bool m_updating; ///. -*/ - -// ScorchTool.h -// Author: Dennis Griffin, April 2002 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -class MapObject; -/*************************************************************************/ -/** ScorchTool -***************************************************************************/ -/// Scorch tool. -class ScorchTool : public Tool -{ -public: - ScorchTool(); - virtual ~ScorchTool() override; - -protected: - Coord3D m_mouseDownPt; - -protected: - MapObject *pickScorch(Coord3D loc); - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h deleted file mode 100644 index fb8648ed473..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsFalse.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScriptActionsFalse.h : header file -// -class Script; -class ScriptAction; -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsFalse dialog - -class ScriptActionsFalse : public CPropertyPage -{ - DECLARE_DYNCREATE(ScriptActionsFalse) - -// Construction -public: - ScriptActionsFalse(); - virtual ~ScriptActionsFalse() override; - -// Dialog Data - //{{AFX_DATA(ScriptActionsFalse) - enum { IDD = IDD_ScriptActionsFalse }; - // NOTE - ClassWizard will add data members here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_DATA - - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(ScriptActionsFalse) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - void setScript(Script *pScript) {m_script = pScript;} - -protected: - Script *m_script; // Doesn't change. - ScriptAction *m_falseAction; // Currently selected action. - Int m_index; // Index of whatever is currently selected. - -protected: - void enableUI(); - void loadList(); - Bool doMoveDown(); - -protected: - // Generated message map functions - //{{AFX_MSG(ScriptActionsFalse) - virtual BOOL OnInitDialog() override; - afx_msg void OnEditAction(); - afx_msg void OnSelchangeActionList(); - afx_msg void OnDblclkActionList(); - afx_msg void OnNew(); - afx_msg void OnDelete(); - afx_msg void OnCopy(); - afx_msg void OnMoveDown(); - afx_msg void OnMoveUp(); - afx_msg void OnChangeEditComment(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h deleted file mode 100644 index 84d95a510ff..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptActionsTrue.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScriptActionsTrue.h : header file -// -class Script; -class ScriptAction; -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsTrue dialog - -class ScriptActionsTrue : public CPropertyPage -{ - DECLARE_DYNCREATE(ScriptActionsTrue) - -// Construction -public: - ScriptActionsTrue(); - virtual ~ScriptActionsTrue() override; - -// Dialog Data - //{{AFX_DATA(ScriptActionsTrue) - enum { IDD = IDD_ScriptActionsTrue }; - // NOTE - ClassWizard will add data members here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_DATA - - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(ScriptActionsTrue) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - void setScript(Script *pScript) {m_script = pScript;} - -protected: - Script *m_script; // Doesn't change. - ScriptAction *m_action; // Currently selected action. - Int m_index; // Index of whatever is currently selected. - -protected: - void enableUI(); - void loadList(); - Bool doMoveDown(); - -protected: - // Generated message map functions - //{{AFX_MSG(ScriptActionsTrue) - virtual BOOL OnInitDialog() override; - afx_msg void OnEditAction(); - afx_msg void OnSelchangeActionList(); - afx_msg void OnDblclkActionList(); - afx_msg void OnNew(); - afx_msg void OnDelete(); - afx_msg void OnCopy(); - afx_msg void OnMoveDown(); - afx_msg void OnMoveUp(); - afx_msg void OnChangeEditComment(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptConditions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptConditions.h deleted file mode 100644 index 006aeacec78..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptConditions.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScriptConditionsDlg.h : header file -// -class Script; -class OrCondition; -class Condition; -class SidesList; -///////////////////////////////////////////////////////////////////////////// -// ScriptConditionsDlg dialog - -class ScriptConditionsDlg : public CPropertyPage -{ - DECLARE_DYNCREATE(ScriptConditionsDlg) - -// Construction -public: - ScriptConditionsDlg(); - virtual ~ScriptConditionsDlg() override; - -// Dialog Data - //{{AFX_DATA(ScriptConditionsDlg) - enum { IDD = IDD_ScriptConditions }; - // NOTE - ClassWizard will add data members here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_DATA - - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(ScriptConditionsDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - void setScript(Script *pScript) {m_script = pScript;} - -protected: - Script *m_script; // Doesn't change. - OrCondition *m_orCondition; // Currently selected OR clause. - Condition *m_condition; // Currently selected condition. - Int m_index; // Index of whatever is currently selected. - -protected: - void enableUI(); - void loadList(); - Int doMoveUp( OrCondition **outWhichNow ); - Int doMoveDown( OrCondition **outWhichNow ); - void setSel(OrCondition *pOr, Condition *pCond); - -protected: - // Generated message map functions - //{{AFX_MSG(ScriptConditionsDlg) - virtual BOOL OnInitDialog() override; - afx_msg void OnEditCondition(); - afx_msg void OnSelchangeConditionList(); - afx_msg void OnDblclkConditionList(); - afx_msg void OnOr(); - afx_msg void OnNew(); - afx_msg void OnDelete(); - afx_msg void OnCopy(); - afx_msg void OnMoveDown(); - afx_msg void OnMoveUp(); - afx_msg void OnChangeEditComment(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptDialog.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptDialog.h deleted file mode 100644 index d7f51f2d782..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptDialog.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScriptDialog.h : header file -// - -#include "GameLogic/SidesList.h" - -class ListType { -public: - enum {BOGUS_TYPE = 0, PLAYER_TYPE = 1, GROUP_TYPE, SCRIPT_IN_PLAYER_TYPE, SCRIPT_IN_GROUP_TYPE}; - unsigned char m_objType; // 4 bits - unsigned char m_playerIndex; // 4 bits - unsigned short int m_groupIndex; // 12 bits - unsigned short int m_scriptIndex; // 12 bits - - ListType() {m_objType=BOGUS_TYPE;m_playerIndex=0;m_groupIndex = 0; m_scriptIndex=0;} - - Int ListToInt() { return((m_objType<<28)+(m_playerIndex<<24)+(m_groupIndex<<12)+m_scriptIndex);} - - void IntToList(int i) {m_objType = ((i)>>28)&0x0F; m_playerIndex = ((i)>>24)&0x0F; m_groupIndex = ((i)>>12)&0x0FFF; m_scriptIndex = (i)&0x0FFF;} -}; - -class ScriptList; -class ScriptGroup; -class Script; -class Parameter; - -/** Class Definition for overridden Tree control that - supports Right-click context sensitive menu.*/ -class CSDTreeCtrl : public CTreeCtrl -{ - public: - - protected: - virtual void OnRButtonDown(UINT nFlags, CPoint point); - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// -// ScriptDialog dialog - -class ScriptDialog : public CDialog -{ -// Construction -public: - ScriptDialog(CWnd* pParent = nullptr); // standard constructor - virtual ~ScriptDialog() override; // destructor - -// Dialog Data - //{{AFX_DATA(ScriptDialog) - enum { IDD = IDD_ScriptDialog }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ScriptDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - static void updateWarnings(Bool forceUpdate=false); - static void updateScriptWarning(Script *pScript); - - static void patchScriptParametersForGC(Script *pScript); - static void checkParametersForGC(); - - - /// To allow CSDTreeCtrl access to these member functions of ScriptDialog - Script *friend_getCurScript(); - ScriptGroup *friend_getCurGroup(); - -protected: - ListType m_curSelection; - CImageList m_imageList; - SidesList m_sides; - static ScriptDialog *m_staticThis; - CSDTreeCtrl *mTree; - Bool m_draggingTreeView; - Bool m_autoUpdateWarnings; ///< flag whether we should updateWarnings on script editor actions. - - HTREEITEM m_dragItem; - - MapObject *m_firstReadObject; - PolygonTrigger *m_firstTrigger; - Int m_waypointBase; - Int m_maxWaypoint; - - AsciiString m_readPlayerNames[MAX_PLAYER_COUNT]; - -protected: - HTREEITEM addPlayer(Int playerIndx); - void addScriptList(HTREEITEM hPlayer, Int playerIndex, ScriptList *pSL); - void doDropOn(HTREEITEM hDrop, HTREEITEM hTarget); - Script *getCurScript(); - ScriptGroup *getCurGroup(); - void reloadPlayer(Int playerIndex, ScriptList *pSL); - HTREEITEM findItem(ListType sel, Bool failSafe = FALSE); - void insertScript(Script *pNewScript); - void scanForWaypointsAndTeams(Script *pScript, Bool doUnits, Bool doWaypoints, Bool doTriggers); - void scanParmForWaypointsAndTeams(Parameter *pParm, Bool doUnits, Bool doWaypoints, Bool doTriggers); - void updateSelection(ListType sel); - void setIconScript(HTREEITEM item); - void setIconGroup(HTREEITEM item); - Bool updateIcons(HTREEITEM hItem); - void markWaypoint(MapObject *pObj); - - static Bool ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - static Bool ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - static Bool ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - static Bool ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - static Bool ParseTeamsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - static Bool ParsePlayersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - -protected: - - // Generated message map functions - //{{AFX_MSG(ScriptDialog) - afx_msg void OnSelchangedScriptTree(NMHDR* pNMHDR, LRESULT* pResult); - virtual BOOL OnInitDialog() override; - afx_msg void OnNewFolder(); - afx_msg void OnNewScript(); - afx_msg void OnEditScript(); - afx_msg void OnCopyScript(); - afx_msg void OnDelete(); - afx_msg void OnVerify(); - afx_msg void OnPatchGC(); - afx_msg void OnAutoVerify(); - afx_msg void OnSave(); - afx_msg void OnLoad(); - afx_msg void OnDblclkScriptTree(NMHDR* pNMHDR, LRESULT* pResult); - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnBegindragScriptTree(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnScriptActivate(); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnMove(int x, int y); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptProperties.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptProperties.h deleted file mode 100644 index 167efdde693..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ScriptProperties.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ScriptProperties.h : header file -// -class Script; -///////////////////////////////////////////////////////////////////////////// -// ScriptProperties dialog - -class ScriptProperties : public CPropertyPage -{ - DECLARE_DYNCREATE(ScriptProperties) - -// Construction -public: - ScriptProperties(); - virtual ~ScriptProperties() override; - -// Dialog Data - //{{AFX_DATA(ScriptProperties) - enum { IDD = IDD_ScriptProperties }; - // NOTE - ClassWizard will add data members here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_DATA - - -// Overrides - // ClassWizard generate virtual function overrides - //{{AFX_VIRTUAL(ScriptProperties) - public: - virtual BOOL OnSetActive() override; - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - void setScript(Script *pScript) {m_script = pScript;} -protected: - void enableControls(); - -protected: - Script *m_script; - Bool m_updating; - -protected: - // Generated message map functions - //{{AFX_MSG(ScriptProperties) - afx_msg void OnChangeScriptComment(); - afx_msg void OnChangeScriptName(); - afx_msg void OnScriptActive(); - afx_msg void OnOneShot(); - afx_msg void OnEasy(); - afx_msg void OnHard(); - afx_msg void OnNormal(); - afx_msg void OnScriptSubroutine(); - afx_msg void OnEveryFrame(); - afx_msg void OnEverySecond(); - afx_msg void OnChangeSecondsEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/SelectMacrotexture.h b/GeneralsMD/Code/Tools/WorldBuilder/include/SelectMacrotexture.h deleted file mode 100644 index bd21f74fa36..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/SelectMacrotexture.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// SelectMacrotexture.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// SelectMacrotexture dialog - -class SelectMacrotexture : public CDialog -{ -// Construction -public: - SelectMacrotexture(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(SelectMacrotexture) - enum { IDD = IDD_MACRO_TEXTURE }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(SelectMacrotexture) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -protected: - CTreeCtrl m_textureTreeView; - - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(SelectMacrotexture) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/ShadowOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/ShadowOptions.h deleted file mode 100644 index 9902f78055c..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/ShadowOptions.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// ShadowOptions.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// ShadowOptions dialog - -class ShadowOptions : public CDialog -{ -// Construction -public: - ShadowOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(ShadowOptions) - enum { IDD = IDD_SHADOW_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ShadowOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - Real m_red; - Real m_green; - Real m_blue; - Real m_intensity; - -protected: - void setShadowColor(); - - // Generated message map functions - //{{AFX_MSG(ShadowOptions) - afx_msg void OnChangeAlphaEdit(); - afx_msg void OnChangeBaEdit(); - afx_msg void OnChangeGaEdit(); - afx_msg void OnChangeRaEdit(); - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/SplashScreen.h b/GeneralsMD/Code/Tools/WorldBuilder/include/SplashScreen.h deleted file mode 100644 index f492f825f5d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/SplashScreen.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -class SplashScreen : public CDialog -{ - protected: - CRect m_rect; - CString m_loadString; - CFont m_font; - - public: - SplashScreen(); - - public: - void setTextOutputLocation(const CRect& rect); - void outputText(UINT nIDString); - - protected: - afx_msg void OnPaint(); - - DECLARE_MESSAGE_MAP() -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/StdAfx.h b/GeneralsMD/Code/Tools/WorldBuilder/include/StdAfx.h deleted file mode 100644 index 2b9de438d01..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/StdAfx.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - - -// To prevent pragma errors. -#include "Lib/BaseType.h" - -// TheSuperHackers @build xezon 24/03/2025 Prevent afxwin.h from loading d3d9types.h, colliding with our own DirectX library. -#define _d3d9TYPES_H_ - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamBehavior.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TeamBehavior.h deleted file mode 100644 index bc553f79f50..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamBehavior.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// TeamBehavior.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// TeamBehavior dialog - -class TeamBehavior : public CPropertyPage -{ -// Construction -public: - TeamBehavior(); // standard constructor - -// Dialog Data - //{{AFX_DATA(TeamBehavior) - enum { IDD = IDD_TeamBehavior }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TeamBehavior) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - Dict *m_teamDict; -protected: - void setupScript(NameKeyType keyScript, int idcScript); - void updateScript(NameKeyType keyScript, int idcScript); -public: - void setTeamDict(Dict *pDict) {m_teamDict = pDict;}; -protected: - - // Generated message map functions - //{{AFX_MSG(TeamBehavior) - afx_msg void OnSelchangeOnCreateScript(); - virtual BOOL OnInitDialog() override; - afx_msg void OnTransportsReturn(); - afx_msg void OnAvoidThreats(); - afx_msg void OnSelchangeOnEnemySighted(); - afx_msg void OnSelchangeOnDestroyed(); - afx_msg void OnSelchangeOnUnitDestroyed(); - afx_msg void OnPerimeterDefense(); - afx_msg void OnBaseDefense(); - afx_msg void OnChangePercentDestroyed(); - afx_msg void OnSelchangeEnemyInteractions(); - afx_msg void OnSelchangeOnAllClear(); - afx_msg void OnSelchangeOnIdleScript(); - afx_msg void OnAttackCommonTarget(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamGeneric.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TeamGeneric.h deleted file mode 100644 index c8c79ac1b61..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamGeneric.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -class Dict; - -class TeamGeneric : public CPropertyPage -{ - public: - TeamGeneric(); // standard constructor - - // Dialog Data - //{{AFX_DATA(TeamGeneric) - enum { IDD = IDD_TeamGeneric }; - //}}AFX_DATA - - void setTeamDict(Dict *dict) { m_teamDict = dict; } - protected: - void _fillComboBoxesWithScripts(); - void _dictToScripts(); - - protected: - Dict *m_teamDict; - - - protected: // Windows Functions - virtual BOOL OnInitDialog() override; - afx_msg void _scriptsToDict(); - afx_msg void OnScriptAdjust(); - DECLARE_MESSAGE_MAP() -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamIdentity.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TeamIdentity.h deleted file mode 100644 index a1ab9376eb6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamIdentity.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// TeamIdentity.h : header file -// -class Dict; -class SidesList; - -///////////////////////////////////////////////////////////////////////////// -// TeamIdentity dialog - -class TeamIdentity : public CPropertyPage -{ -// Construction -public: - TeamIdentity(); // standard constructor - -// Dialog Data - //{{AFX_DATA(TeamIdentity) - enum { IDD = IDD_TeamIdentity }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TeamIdentity) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam) override; - //}}AFX_VIRTUAL - -protected: - Dict *m_teamDict; - SidesList *m_sides; -protected: - void loadUnitsInfo(int idcMinUnit, NameKeyType keyMinUnit, - int idcMaxUnit, NameKeyType keyMaxUnit, - int idcUnitType, NameKeyType keyUnitType); - void OnUnitTypeButton(Int idcUnitType); - -public: - void setTeamDict(Dict *pDict) {m_teamDict = pDict;}; - void setSidesList(SidesList *pSides) {m_sides = pSides;}; -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(TeamIdentity) - virtual BOOL OnInitDialog() override; - afx_msg void OnAiRecruitable(); - afx_msg void OnAutoReinforce(); - afx_msg void OnBaseDefense(); - afx_msg void OnChangeDescription(); - afx_msg void OnChangeMax(); - afx_msg void OnChangePriorityDecrease(); - afx_msg void OnChangePriorityIncrease(); - afx_msg void OnSelchangeProductionCondition(); - afx_msg void OnChangeProductionPriority(); - afx_msg void OnSelchangeHomeWaypoint(); - afx_msg void OnUnitType1Button(); - afx_msg void OnUnitType2Button(); - afx_msg void OnUnitType3Button(); - afx_msg void OnUnitType4Button(); - afx_msg void OnUnitType5Button(); - afx_msg void OnUnitType6Button(); - afx_msg void OnUnitType7Button(); - afx_msg void OnExecuteActions(); - afx_msg void OnChangeTeamName(); - afx_msg void OnTeamSingleton(); - afx_msg void OnKillfocusTeamName(); - afx_msg void OnSelendokTeamowner(); - afx_msg void OnChangeTeamBuildFrames(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamObjectProperties.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TeamObjectProperties.h deleted file mode 100644 index 87fc7f27fad..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamObjectProperties.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TeamObjectProperties.h -// Mike Lytle -// January, 2003 -// (c) Electronic Arts 2003 - -#pragma once - -#include "resource.h" - -// Forward declarations. -class Dict; - - -// External Defines - -class TeamObjectProperties : public CPropertyPage -{ -// Construction -public: - TeamObjectProperties(Dict* dictToEdit = nullptr); - virtual ~TeamObjectProperties() override; - -// Dialog Data - //{{AFX_DATA(MapObjectProps) - enum { IDD = IDD_TeamObjectProperties }; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TeamObjectProperties) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - Dict* m_dictToEdit; - -#if 0 // Keys not implemented yet. jba. [3/26/2003]// - void updateTheUI(void); - - // Generated message map functions - //{{AFX_MSG(TeamObjectProperties) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void _HealthToDict(void); - afx_msg void _EnabledToDict(void); - afx_msg void _IndestructibleToDict(void); - afx_msg void _UnsellableToDict(void); - afx_msg void _PoweredToDict(void); - afx_msg void _AggressivenessToDict(void); - afx_msg void _VisibilityToDict(void); - afx_msg void _VeterancyToDict(void); - afx_msg void _ShroudClearingDistanceToDict(void); - afx_msg void _RecruitableAIToDict(void); - afx_msg void _SelectableToDict(void); - afx_msg void _WeatherToDict(void); - afx_msg void _TimeToDict(void); - afx_msg void _HPsToDict(); - afx_msg void _StoppingDistanceToDict(void); - afx_msg void _UpdateTeamMembers(void); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - - void _DictToHealth(void); - void _DictToHPs(void); - void _DictToEnabled(void); - void _DictToDestructible(void); - void _DictToUnsellable(void); - void _DictToPowered(void); - void _DictToAggressiveness(void); - void _DictToVisibilityRange(void); - void _DictToVeterancy(void); - void _DictToShroudClearingDistance(void); - void _DictToRecruitableAI(); - void _DictToSelectable(void); - void _DictToWeather(void); - void _DictToTime(void); - void _DictToStoppingDistance(void); - void _PropertiesToDict(void); -#endif -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamReinforcement.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TeamReinforcement.h deleted file mode 100644 index fde0bc9de5b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TeamReinforcement.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// TeamReinforcement.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// TeamReinforcement dialog - -class TeamReinforcement : public CPropertyPage -{ -// Construction -public: - TeamReinforcement(); // standard constructor - -// Dialog Data - //{{AFX_DATA(TeamReinforcement) - enum { IDD = IDD_TeamReinforcement }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TeamReinforcement) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - Dict *m_teamDict; -public: - void setTeamDict(Dict *pDict) {m_teamDict = pDict;}; -protected: - - // Generated message map functions - //{{AFX_MSG(TeamReinforcement) - afx_msg void OnDeployBy(); - afx_msg void OnTeamStartsFull(); - afx_msg void OnSelchangeTransportCombo(); - afx_msg void OnTransportsExit(); - afx_msg void OnSelchangeVeterancy(); - afx_msg void OnSelchangeWaypointCombo(); - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainMaterial.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainMaterial.h deleted file mode 100644 index 4974c8540ab..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainMaterial.h +++ /dev/null @@ -1,111 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// terrainmaterial.h : header file -// - -#include "WBPopupSlider.h" -#include "TerrainSwatches.h" -#include "OptionsPanel.h" -class WorldHeightMapEdit; -///////////////////////////////////////////////////////////////////////////// -// TerrainMaterial dialog - -class TerrainMaterial : public COptionsPanel, public PopupSliderOwner -{ -// Construction -public: - TerrainMaterial(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(TerrainMaterial) - enum { IDD = IDD_TERRAIN_MATERIAL }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TerrainMaterial) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; ///< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; ///< Modeless dialogs don't close on ESC, so eat this for modeless. - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - enum {MIN_TILE_SIZE=2, MAX_TILE_SIZE = 100}; - // Generated message map functions - //{{AFX_MSG(TerrainMaterial) - virtual BOOL OnInitDialog() override; - afx_msg void OnSwapTextures(); - afx_msg void OnChangeSizeEdit(); - afx_msg void OnImpassable(); - afx_msg void OnPassableCheck(); - afx_msg void OnPassable(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - -protected: - static TerrainMaterial *m_staticThis; - Bool m_updating; - static Int m_currentFgTexture; - static Int m_currentBgTexture; - CTreeCtrl m_terrainTreeView; - TerrainSwatches m_terrainSwatches; - WBPopupSliderButton m_widthPopup; - Int m_currentWidth; - - static Bool m_paintingPathingInfo; // If true, we are painting passable/impassable. If false, normal texture painting. - static Bool m_paintingPassable; - -protected: - void addTerrain(char *pPath, Int terrainNdx, HTREEITEM parent); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - void updateLabel(); - -public: - static Int getFgTexClass() {return m_currentFgTexture;} - static Int getBgTexClass() {return m_currentBgTexture;} - - static void setFgTexClass(Int texClass); - static void setBgTexClass(Int texClass); - static void updateTextures(WorldHeightMapEdit *pMap); - static void updateTextureSelection(); - static void setToolOptions(Bool singleCell); - static void setWidth(Int width); - - static Bool isPaintingPathingInfo() {return m_paintingPathingInfo;} - static Bool isPaintingPassable() {return m_paintingPassable;} - -public: - Bool setTerrainTreeViewSelection(HTREEITEM parent, Int selection); - - // Popup slider interface. - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) override; - virtual void PopSliderChanged(const long sliderID, long theVal) override; - virtual void PopSliderFinished(const long sliderID, long theVal) override; -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainModal.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainModal.h deleted file mode 100644 index 89c23708e93..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainModal.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// TerrainModal.h : header file -// - -#include "TerrainSwatches.h" -#include "Common/AsciiString.h" -class WorldHeightMapEdit; -///////////////////////////////////////////////////////////////////////////// -// TerrainModal dialog - -class TerrainModal : public CDialog -{ -// Construction -public: - TerrainModal(AsciiString path, WorldHeightMapEdit *pMap, CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(TerrainModal) - enum { IDD = IDD_TERRAIN_MODAL }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TerrainModal) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) override; - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(TerrainModal) - virtual BOOL OnInitDialog() override; - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - Int m_currentFgTexture; - AsciiString m_pathToReplace; - CTreeCtrl m_terrainTreeView; - TerrainSwatches m_terrainSwatches; - WorldHeightMapEdit *m_map; - -protected: - void addTerrain(char *pPath, Int terrainNdx, HTREEITEM parent); - HTREEITEM findOrAdd(HTREEITEM parent, const char *pLabel); - void updateLabel(); - void updateTextures(); - Bool setTerrainTreeViewSelection(HTREEITEM parent, Int selection); - -public: - Int getNewNdx() {return m_currentFgTexture;}; - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainSwatches.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainSwatches.h deleted file mode 100644 index 2c9e599882b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TerrainSwatches.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// TerrainSwatches.h : header file -// - -#include "Lib/BaseType.h" -///////////////////////////////////////////////////////////////////////////// -// TerrainSwatches window - -class TerrainSwatches : public CWnd -{ -// Construction -public: - TerrainSwatches(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TerrainSwatches) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~TerrainSwatches() override; - - // Generated message map functions -protected: - //{{AFX_MSG(TerrainSwatches) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - void DrawMyTexture(CDC *pDc, int top, int left, Int width, UnsignedByte *rgbData); - -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/TileTool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/TileTool.h deleted file mode 100644 index a75350fccb5..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/TileTool.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TileTool.h -// Texture tiling tools for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -/************************************************************************* -** TileTool -***************************************************************************/ -class TileTool : public Tool -{ -protected: - WorldHeightMapEdit *m_htMapEditCopy; //< ref counted. - Int m_textureClassToDraw; - CPoint m_prevViewPt; - -public: - TileTool(); - virtual ~TileTool() override; - -public: - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual WorldHeightMapEdit *getHeightMap() override {return m_htMapEditCopy;}; - virtual void activate() override; ///< Become the current tool. - virtual Int getWidth() {return 1;}; -}; - -/************************************************************************* -** BigTileTool -***************************************************************************/ -class BigTileTool : public TileTool -{ - -protected: - static Int m_currentWidth; - -public: - virtual void activate() override; ///< Become the current tool. - -public: - BigTileTool(); - - static void setWidth(Int width) ; - virtual Int getWidth() override {return m_currentWidth;}; - -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/Tool.h b/GeneralsMD/Code/Tools/WorldBuilder/include/Tool.h deleted file mode 100644 index 1198341693d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/Tool.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Tool.h -// Tool classes for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Lib/BaseType.h" -#include "Common/STLTypedefs.h" - -enum TTrackingMode { - TRACK_NONE, - TRACK_L, - TRACK_M, - TRACK_R -}; - -#include -typedef std::vector VecHeightMapIndexes; - -#define MAGIC_GROUND_Z (0) - -//#define IS_MAGIC_GROUND(z) ((z)==MAGIC_GROUND_Z) - -// for backwards compatibility with existing maps: -#define IS_MAGIC_GROUND(z) ((z)==0) - -class CWorldBuilderDoc; -class CWorldBuilderView; -class WorldHeightMapEdit; -class WbView; - -/************************************************************************* -** Tool -***************************************************************************/ -class Tool -{ -protected: - Int m_toolID; //< Tool button ui id in resource. - Int m_cursorID; //< Tool button ui id in resource. - HCURSOR m_cursor; - - Int m_prevXIndex; - Int m_prevYIndex; -public: - Tool(Int toolID, Int cursorID); - virtual ~Tool(); - -public: - Int getToolID() {return m_toolID;} - virtual void setCursor(); - - virtual void activate(); ///< Become the current tool. - virtual void deactivate(){}; ///< Become not the current tool. - - virtual Bool followsTerrain() {return true;}; ///< True if the tool tracks the terrain, generally false if it modifies the terrain heights. - - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {} - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {} - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) {} - virtual WorldHeightMapEdit *getHeightMap() {return nullptr;} - - static Real calcRoundBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth); - static Real calcSquareBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth); - static void getCenterIndex(Coord3D *docLocP, Int brushWidth, CPoint *center, CWorldBuilderDoc *pDoc); - static void getAllIndexesIn(const Coord3D *bl, const Coord3D *br, - const Coord3D *tl, const Coord3D *tr, - Int widthOutside, CWorldBuilderDoc *pDoc, - VecHeightMapIndexes* allIndices); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WBFrameWnd.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WBFrameWnd.h deleted file mode 100644 index 37d682543f6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WBFrameWnd.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// WBFrameWnd.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CWBFrameWnd frame - -class CWBFrameWnd : public CFrameWnd -{ - DECLARE_DYNCREATE(CWBFrameWnd) -protected: - CWBFrameWnd(); // protected constructor used by dynamic creation - -// Attributes -public: - -// Operations -public: - -// Overrides - //{{AFX_VIRTUAL(CWBFrameWnd) - public: - virtual BOOL LoadFrame(UINT nIDResource, - DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, - CWnd* pParentWnd = nullptr, - CCreateContext* pContext = nullptr) override; - // ClassWizard generated virtual function overrides - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual ~CWBFrameWnd() override; - - // Generated message map functions - //{{AFX_MSG(CWBFrameWnd) - afx_msg void OnMove(int x, int y); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -protected: - CellSizeToolBar m_cellSizeToolBar; - -}; - -class CWB3dFrameWnd : public CMainFrame -{ - DECLARE_DYNCREATE(CWB3dFrameWnd) -protected: - CWB3dFrameWnd(); // protected constructor used by dynamic creation -// Operations -public: -// Overrides - virtual BOOL LoadFrame(UINT nIDResource, - DWORD dwDefaultStyle = WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, - CWnd* pParentWnd = nullptr, - CCreateContext* pContext = nullptr) override; - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWB3dFrameWnd) - public: - //}}AFX_VIRTUAL -// Implementation -protected: - virtual ~CWB3dFrameWnd() override; - // Generated message map functions - //{{AFX_MSG(CWB3dFrameWnd) - afx_msg void OnMove(int x, int y); - afx_msg void OnWindowPreview1024x768(); - afx_msg void OnUpdateWindowPreview1024x768(CCmdUI* pCmdUI); - afx_msg void OnWindowPreview640x480(); - afx_msg void OnUpdateWindowPreview640x480(CCmdUI* pCmdUI); - afx_msg void OnWindowPreview800x600(); - afx_msg void OnUpdateWindowPreview800x600(CCmdUI* pCmdUI); - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WBHeightMap.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WBHeightMap.h deleted file mode 100644 index 57f0f640c1b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WBHeightMap.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -#include "W3DDevice/GameClient/FlatHeightMap.h" -#include "W3DDevice/GameClient/HeightMap.h" -#define dont_USE_FLAT_HEIGHT_MAP // Use the original height map for mission disk. jba. [4/15/2003] -#ifdef USE_FLAT_HEIGHT_MAP -class WBHeightMap : public FlatHeightMapRenderObjClass -#else -class WBHeightMap : public HeightMapRenderObjClass -#endif -{ - -public: - WBHeightMap(); - - ///////////////////////////////////////////////////////////////////////////// - // Render Object Interface (W3D methods) - ///////////////////////////////////////////////////////////////////////////// - virtual void Render(RenderInfoClass & rinfo) override; - virtual Bool Cast_Ray(RayCollisionTestClass & raytest) override; - - virtual Real getHeightMapHeight(Real x, Real y, Coord3D* normal); ///. -*/ - -#pragma once - -// WBPopupSliderButton.h : header file -// - -class PopupSliderOwner -{ -public: - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial)=0; - virtual void PopSliderChanged(const long sliderID, long theVal) = 0; - virtual void PopSliderFinished(const long sliderID, long theVal) = 0; -}; - -///////////////////////////////////////////////////////////////////////////// -// WBPopupSliderButton window - -// note: as of 990315, these things produce horizontal sliders by default! - -class WBPopupSliderButton : public CButton -{ -// Construction -public: - WBPopupSliderButton(); - -// Attributes -public: - -// Operations -public: - void SetupPopSliderButton(CWnd *pParentWnd, long controlID, - PopupSliderOwner *pOwner); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(WBPopupSliderButton) - protected: - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~WBPopupSliderButton() override; - - // Generated message map functions -protected: - //{{AFX_MSG(WBPopupSliderButton) - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - -private: - Int m_controlID; - Int m_sliderStyle; - PopupSliderOwner *m_owner; -}; - -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider window - -/* - note: PopupSlider is a self-deleting window. It cannot - be instantiated except through its New function, and once - its Create() function has been called successfully it should - not be deleted. Its PostNcDestroy method will handle that - for you. -*/ - -class PopupSlider : public CWnd -{ -// Construction -public: - PopupSlider(); - -public: - /* - the New function takes care of EVERYTHING for you! It - constructs the object, calls its create method, - and starts it running - */ - static void New(CWnd* pParentWnd, long kind, - PopupSliderOwner *pSliderOwner, long sliderID); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PopupSlider) - public: - virtual BOOL Create(const RECT& rect, CWnd* pParentWnd); - protected: - virtual void PostNcDestroy() override; - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~PopupSlider() override; - - // Generated message map functions -protected: - //{{AFX_MSG(PopupSlider) - afx_msg void OnPaint(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnDestroy(); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - void MoveThumbUnderMouse(int xNew); - - // our owner - PopupSliderOwner *mSliderOwner; - - // the slider value - long m_curValue; - - // setup values for the slider - long m_lineSize; - long m_lo; - long m_hi; - long m_kind; - long mSliderID; - - /* the value when the slider last called "Finished"; we keep this around to - see if we need to call Finished again on NcDestroy */ - long m_valOnLastFinished; - -private: - Bool mDraggingThumb; - Bool mClickThrough; - CPoint mOrigPt; - Bool mSetOrigPt; - Bool mEverMoved; - - // for the thumb icon - HICON mIcon; - -private: - // the one and only slider windoid that should ever be open - static PopupSlider *gPopupSlider; - - void GetChannelRect(CRect* rect); - void GetThumbIconRect(CRect* rect); - - // the background color brush - CBrush m_brush3dFaceColor; -}; - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h deleted file mode 100644 index 68b1044ef4e..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WHeightMapEdit.h +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WHeightMapEdit.h -// Class to contain the editing functions subclass of WorldHeightMap. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "W3DDevice/GameClient/WorldHeightMap.h" - -class DataChunkOutput; -class TerrainType; - -// helper class -class CProcessNode -{ -public: - const Int m_x, m_y; - Real m_len; ///< Length of texture coord on this node. - CProcessNode *m_next; -public: - CProcessNode(Int x, Int y):m_x(x),m_y(y),m_next(nullptr),m_len(0) {}; - ~CProcessNode() { }; -}; - -#define MAX_TILES_PER_CLASS 100 -/// Struct in memory. -typedef struct -{ -#ifdef DEBUG_CRASHING - Int forDebugOnly_fileTextureClass; -#endif - Int numTiles; - Int width; - Bool isBlendEdgeTile; - AsciiString name; - AsciiString filePath; - AsciiString uiName; - TileData *tiles[MAX_TILES_PER_CLASS]; - TerrainType *terrainType; -} TGlobalTextureClass; - - -class WorldHeightMapEdit : public WorldHeightMap -{ -protected: - Bool m_warnTooManyTex; ///< warning message flag. - Bool m_warnTooManyBlend; ///< warning message flag. - - // Texture classes. There is one texture class for each bitmap read in. - // A class may have more than one tile. For example, if the grass bitmap is - // 128x128, it creates 4 64x64 tiles, so the grass texture class will have 4 tiles. - static int m_numGlobalTextureClasses; - static TGlobalTextureClass m_globalTextureClasses[NUM_TEXTURE_CLASSES]; - -protected: - static void loadBitmap(char *path, const char *uiName); - static void loadDirectoryOfImages(const char *path); - static void loadImagesFromTerrainType( TerrainType *terrain ); - static void loadBaseImages(); - Int allocateTiles(Int textureClass); - Int allocateEdgeTiles(Int textureClass); - void blendToThisClass(Int xIndex, Int yIndex, Int textureClass, Int edgeClass); - void blendSpecificTiles(Int xIndex, Int yIndex, Int srcXIndex, Int srcYIndex, - Int curTileNdx, Int blendTileNdx, Bool longDiagonal, Int edgeClass); - Int findOrCreateBlendTile(TBlendTileInfo *pBlendInfo); - Int addCliffInfo(TCliffInfo *pCliffInfo); - Int getTileIndexFromTerrainType( TerrainType *terrain ); - Int getTileNdxForClass(Int xIndex, Int yIndex, Int textureClass); - Int getBlendTileNdxForClass(Int xIndex, Int yIndex, Int textureClass); - Int getTextureClassFromNdx(Int tileNdx); - void getTexClassNeighbors(Int xIndex, Int yIndex, Int textureClass, Int *pSideCount, Int *pTotalCount); - void updateForAdjacentCliffs(Int xIndex, Int yIndex, - UnsignedByte *pProcessed, TCliffInfo &cliffInfo); - Bool adjustForTiling(TCliffInfo &cliffInfo, Real textureWidth); - void updateFlatCellForAdjacentCliffs(Int xIndex, Int yIndex, - Int curTileClass, UnsignedByte *pProcessed=nullptr); - -public: // construction - WorldHeightMapEdit(Int xExtent, Int yExtent, UnsignedByte initialHeight, Int border); ///< create. - WorldHeightMapEdit(WorldHeightMapEdit *pThis); ///< duplicate. - WorldHeightMapEdit(ChunkInputStream *pStrm); ///< read from file. - virtual ~WorldHeightMapEdit() override; ///< destroy. - - void saveToFile(DataChunkOutput &chunkWriter); - WorldHeightMapEdit *duplicate(); - - static void init(); - static void shutdown(); - -public: /// Status methods. - void clearStatus() {m_warnTooManyTex = false;m_warnTooManyBlend = false;}; - Bool tooManyTextures() {return m_warnTooManyTex;}; - Bool tooManyBlends() {return m_warnTooManyBlend;}; - Bool canFitTexture(Int textureClass); ///< Returns true if we can fit this texture. - -public: // Editing methods. - static UnsignedByte *getPointerToClassTileData(Int texClass); - - void blendTile(Int xIndex, Int yIndex, Int srcXIndex, Int srcYIndex, Int srcClass, Int edgeClass); - void autoBlendOut(Int xIndex, Int yIndex, Int edgeIndex = -1); - Int getTextureClass(Int xIndex, Int yIndex, Bool baseClass=false); - void setHeight(Int xIndex, Int yIndex, UnsignedByte height); - void setCliff(Int xIndex, Int yIndex, Bool impassable) {setCliffState(xIndex, yIndex, impassable);} - Bool setTileNdx(Int xIndex, Int yIndex, Int textureClass, Bool singleTile); - Bool floodFill(Int xIndex, Int yIndex, Int textureClass, Bool doReplace); - static Int getNumTexClasses() {return m_numGlobalTextureClasses;}; - static AsciiString getTexClassName(int ndx) {return m_globalTextureClasses[ndx].name;} - static AsciiString getTexClassUiName(int ndx) ; - static Int getTexClassNumTiles(int ndx) {return m_globalTextureClasses[ndx].numTiles;} - static Int getTexClassIsBlendEdge(int ndx) {return m_globalTextureClasses[ndx].isBlendEdgeTile;} - - void addObject(MapObject *pMapObj); ///< Adds a map object to the front of the list. - void removeFirstObject(); ///< Removes the first map object from the list. - - Bool isTexClassUsed(Int textureClass); - Int getFirstTile(Int textureClass); - - Bool optimizeTiles(); ///< Optimizes tile allocations. - - void showTileStatusInfo(); ///< pops up a dialog box with tile mem usage. - - - Bool selectDuplicates(); ///< Selects any duplicate map objects. - Bool selectSimilar(); ///< Selects any duplicate map objects. - Bool selectInvalidTeam(); ///< Selects any objects with invalid teams. - - Bool resize(Int newXSize, Int newYSize, Int newHeight, Int newBorder, Bool anchorTop, Bool anchorBottom, - Bool anchorLeft, Bool anchorRight, Coord3D *pObjOffset); - Bool remapTextures(); ///< returns true if the operation had an effect. - void reloadTextures(); ///< Reloads textures from disk. - void resetResources(); ///< Releases textures in preparation for device reset. - - Bool getRawTileData(Short tileNdx, Int width, UnsignedByte *buffer, Int bufLen); - - void dbgVerifyAfterUndo(); ///< Verifies the structures are still consistent. - Bool doCliffAdjustment(Int xIndex, Int yIndex); - Bool removeCliffMapping(); - - Int getNumBoundaries() const ; - void getBoundary(Int ndx, ICoord2D* border) const; - void addBoundary(ICoord2D* boundaryToAdd); - void changeBoundary(Int ndx, ICoord2D *border); - void removeLastBoundary(); - - // outNdx must not be null, but outHandle can be. - // outHandle: 0 means BL, 1 means TL, 2 means TR, 3 means BR - void findBoundaryNear(Coord3D *pt, float okDistance, Int *outNdx, Int *outHandle); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WaterOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WaterOptions.h deleted file mode 100644 index d8b27bdf4e2..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WaterOptions.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// WaterOptions.h : header file -// -#include "WBPopupSlider.h" -#include "OptionsPanel.h" -#include "Common/WellKnownKeys.h" - -class MapObject; -class PolygonTrigger; -class MovePolygonUndoable; -///////////////////////////////////////////////////////////////////////////// -// WaterOptions dialog - -class WaterOptions : public COptionsPanel, public PopupSliderOwner -{ - -// Construction -public: - WaterOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(WaterOptions) - enum { IDD = IDD_WATER_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(WaterOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(WaterOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeWaterEdit(); - afx_msg void OnChangeHeightEdit(); - afx_msg void OnChangeSpacingEdit(); - afx_msg void OnWaterPolygon(); - afx_msg void OnMakeRiver(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static WaterOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - Bool m_updating; ///. -*/ - -// WaterTool.h -// Polygon area trigger tool for worldbuilder. -// Author: John Ahlquist, Nov. 2001 - -#pragma once - -#include "PolygonTool.h" -class WorldHeightMapEdit; -class MapObject; -class PolygonTrigger; -class MovePolygonUndoable; -/*************************************************************************/ -/** WaterTool - Does the add/select water polygon operation. -***************************************************************************/ -/// Select tile tool. -class WaterTool : public PolygonTool -{ -public: - WaterTool(); - virtual ~WaterTool() override; - -protected: - static Bool m_water_isActive; - - Real m_currentZ; - -public: - static Bool isActive() {return m_water_isActive;}; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void setCursor() override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. - -protected: - void fillTheArea(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc); - PolygonTrigger *adjustSpacing(PolygonTrigger *trigger, Real spacing); -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WaypointOptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WaypointOptions.h deleted file mode 100644 index 193d2791dd7..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WaypointOptions.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// WaypointOptions.h : header file -// -#include "OptionsPanel.h" -#include "Common/WellKnownKeys.h" - -class MapObject; -class PolygonTrigger; -class MovePolygonUndoable; -///////////////////////////////////////////////////////////////////////////// -// WaypointOptions dialog - -class WaypointOptions : public COptionsPanel -{ - -// Construction -public: - WaypointOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(WaypointOptions) - enum { IDD = IDD_WAYPOINT_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(WaypointOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(WaypointOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeWaypointnameEdit(); - afx_msg void OnChangeSelectedWaypoint(); - afx_msg void OnEditWaypointLocationX(); - afx_msg void OnEditWaypointLocationY(); - afx_msg void OnEditchangeWaypointlabel1Edit(); - afx_msg void OnEditchangeWaypointlabel2Edit(); - afx_msg void OnEditchangeWaypointlabel3Edit(); - afx_msg void OnWaypointBidirectional(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static WaypointOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - Bool m_updating; ///. -*/ - -// WaypointTool.h -// Texture selection tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#pragma once - -#include "Tool.h" -class WorldHeightMapEdit; -class MapObject; -/*************************************************************************/ -/** WaypointTool - Does the add/select waypoint operation. -***************************************************************************/ -/// Select tile tool. -class WaypointTool : public Tool -{ -public: - WaypointTool(); - virtual ~WaypointTool() override; - -protected: - Int m_downWaypointID; - Coord3D m_mouseDownPt; - static Bool m_isActive; - -protected: - MapObject *pickWaypoint(Coord3D loc); - -public: - static Bool isActive() {return m_isActive;}; - -public: - /// Perform tool on mouse down. - virtual void mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) override; - virtual void activate() override; ///< Become the current tool. - virtual void deactivate() override; ///< Become not the current tool. -}; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilder.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilder.h deleted file mode 100644 index 5d4f8295497..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilder.h +++ /dev/null @@ -1,195 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldBuilder.h : main header file for the WORLDBUILDER application -// - -#pragma once - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -#include "Common/STLTypedefs.h" - -#include "BrushTool.h" -#include "TileTool.h" -#include "FeatherTool.h" -#include "AutoEdgeOutTool.h" -#include "FloodFillTool.h" -#include "MoundTool.h" -#include "EyedropperTool.h" -#include "ObjectTool.h" -#include "FenceTool.h" -#include "PointerTool.h" -#include "BlendEdgeTool.h" -#include "BorderTool.h" -#include "GroveTool.h" -#include "HandScrollTool.h" -#include "RoadTool.h" -#include "MeshMoldTool.h" -#include "WaypointTool.h" -#include "PolygonTool.h" -#include "WaterTool.h" -#include "BuildListTool.h" -#include "RampTool.h" -#include "ScorchTool.h" -#include "RulerTool.h" -#include "Common/Debug.h" - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderApp: -// See WorldBuilder.cpp for the implementation of this class -// - -// Force maps into a directory structure. -#define DO_MAPS_IN_DIRECTORIES 1 - -#define NONE_STRING "" - - -enum {THREE_D_VIEW_WIDTH=800, THREE_D_VIEW_HEIGHT=600}; -enum {MAX_OBJECTS_IN_MAP = 3000}; - -class CWorldBuilderApp : public CWinApp -{ -public: - CWorldBuilderApp(); - virtual ~CWorldBuilderApp() override; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWorldBuilderApp) - public: - virtual BOOL InitInstance() override; - virtual int ExitInstance() override; - //}}AFX_VIRTUAL - -// Implementation - //{{AFX_MSG(CWorldBuilderApp) - afx_msg void OnAppAbout(); - afx_msg void OnResetWindows(); - afx_msg void OnFileOpen(); - afx_msg void OnTexturesizingMapclifftextures(); - afx_msg void OnUpdateTexturesizingMapclifftextures(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - - enum {NUM_VIEW_TOOLS=25}; - - Tool *m_tools[NUM_VIEW_TOOLS]; ///< array of tool pointers. - Tool *m_curTool; ///< Currently active tool. - Tool *m_selTool; ///< Normal tool. If we hit alt, curTool turns to eyedropper. - BrushTool m_brushTool; ///< Height brush tool. - TileTool m_tileTool; ///< Single texture tile tool. - BigTileTool m_bigTileTool; ///< Wide texture tile tool. - FeatherTool m_featherTool; ///< Feather the height values tool. - AutoEdgeOutTool m_autoEdgeOutTool; ///< Auto blend texture edges out tool. - FloodFillTool m_floodFillTool; ///< Flood fill tool. - MoundTool m_moundTool; ///< Add height to height values tool. - DigTool m_digTool; ///< Remove height from height values tool. - EyedropperTool m_eyedropperTool; ///< Eyedropper tool. - ObjectTool m_objectTool; ///< Add and orient object tool. - PointerTool m_pointerTool; ///< Select and move/rotate tool. - BlendEdgeTool m_blendEdgeTool; ///< Blend a single edge tool. - GroveTool m_groveTool; ///< Plant a grove of trees tool. - HandScrollTool m_handScrollTool; ///< Scroll tool. - RoadTool m_roadTool; ///< Road tool. - MeshMoldTool m_meshMoldTool; ///< Mesh shaping mold tool. - WaypointTool m_waypointTool; ///< Waypoint tool. - PolygonTool m_polygonTool; ///< Polygon tool. - WaterTool m_waterTool; ///< Water tool. - BuildListTool m_buildListTool; ///< Build List tool. - FenceTool m_fenceTool; ///< Fence tool. - RampTool m_rampTool; ///< Ramp tool. - ScorchTool m_scorchTool; ///< Scorch tool. - BorderTool m_borderTool; ///< Border tool. - RulerTool m_rulerTool; ///< Ruler tool. - - Int m_lockCurTool; - - AsciiString m_currentDirectory; ///< Current directory for open file. - - CDocTemplate *m_3dtemplate; - - MapObject *m_pasteMapObjList; ///< List of copied/cut map objects. - -protected: - void deletePasteObjList() - { - deleteInstance(m_pasteMapObjList); - m_pasteMapObjList = nullptr; - }; - -public: - - CDocTemplate *Get3dTemplate() { return m_3dtemplate; } - - /// Set the brush tool as the active tool. - void selectBrushTool() { setActiveTool(&m_brushTool); } - - /// Set the pointer tool as the active tool. - void selectPointerTool(); - - /// Set the hand tool as the cur tool (but not active tool) - void selectHandToolTemp() { m_curTool = &m_handScrollTool; } - - /// Set the tool that will be active. - void setActiveTool(Tool *newTool); - - /// Sets the current directory for file opens. - void setCurrentDirectory(AsciiString dir) {m_currentDirectory = dir;}; - - Tool *getCurTool() { return m_curTool; } - - /// Check to see if any keyboard overrides are changing the current tool. - void updateCurTool(Bool forceHand); - - /// Switch to the poly tool if we aren't already. - void setPolyTool(){ setActiveTool(&m_polygonTool); }; - - /// Return true if the hand scroll tool is active. - Bool isHandScroll() {return m_curTool == &m_handScrollTool; } - - void lockCurTool() { DEBUG_ASSERTCRASH(!m_lockCurTool,("already locked")); m_lockCurTool = 1; } - void unlockCurTool() { m_lockCurTool = 0; } - Bool isCurToolLocked() { return m_lockCurTool != 0; } - - /// Note - read only data - make yourself a copy. - MapObject *getMapObjPasteList() { return(m_pasteMapObjList);}; - - /// Note - the app owns this, and will delete it on close. - void setMapObjPasteList(MapObject *list) { deletePasteObjList(); m_pasteMapObjList = list; }; - - - /// Handles command messages. - virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, - AFX_CMDHANDLERINFO* pHandlerInfo) override; -}; - -inline CWorldBuilderApp *WbApp() { return (CWorldBuilderApp*)::AfxGetApp(); } - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h deleted file mode 100644 index 4bd88712af4..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderDoc.h +++ /dev/null @@ -1,210 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldBuilderDoc.h : interface of the CWorldBuilderDoc class -// -///////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Lib/BaseType.h" -#include "Common/MapObject.h" -#include "Tool.h" - -class CWorldBuilderView; -class WbView3d; -class WorldHeightMapEdit; -class Undoable; -class DataChunkInput; -struct DataChunkInfo; - -#define MAX_UNDOS 15 - -#define MIN_CELL_SIZE 1 -#define MAX_CELL_SIZE 64 - -class CWorldBuilderDoc : public CDocument -{ - friend class COptionsPanel; - - enum {MAX_WAYPOINTS=16000}; ///@todo - make it dynamic. jba. -protected: // create from serialization only - CWorldBuilderDoc(); - DECLARE_DYNCREATE(CWorldBuilderDoc) - -protected: - WorldHeightMapEdit *m_heightMap; - Undoable *m_undoList; ///< Head of undo/redo list. - int m_maxUndos; - int m_curRedo; ///< 0 means no redos available. - Bool m_linkCenters; ///< Flag whether the centers of the 2d and 3d views track together. - Bool m_needAutosave; ///< True if changes have been made since last autosave. - Int m_curWaypointID; - -protected: - std::vector m_boundaries; - -protected: // waypoint stuff. - MapObject *m_waypointTable[MAX_WAYPOINTS]; - Bool m_waypointTableNeedsUpdate; - struct { - Int waypoint1; - Int waypoint2; - Bool processedFlag; - } m_waypointLinks[MAX_WAYPOINTS]; - Int m_numWaypointLinks; -protected: - void updateWaypointTable(); - void compressWaypointIds(); - void updateLWL(MapObject *pWay, MapObject *pSrcWay); -public: - void addWaypointLink(Int waypointID1, Int waypointID2); - void removeWaypointLink(Int waypointID1, Int waypointID2); - MapObject *getWaypointByID(Int waypointID); - Int getNumWaypointLinks() {return m_numWaypointLinks;}; - void getWaypointLink(Int ndx, Int *waypoint1, Int *waypointID2); - Bool waypointLinkExists(Int waypointID1, Int waypointID2); - Bool isWaypointLinked(MapObject *pWay); - void updateLinkedWaypointLabels(MapObject *pWay); - - // Boundary stuff - Int getNumBoundaries() const ; - void getBoundary(Int ndx, ICoord2D* border) const; - void addBoundary(ICoord2D* boundaryToAdd); - void changeBoundary(Int ndx, ICoord2D *border); - void removeLastBoundary(); - - // outNdx must not be null, but outHandle can be. - // outHandle: 0 means BL, 1 means TL, 2 means TR, 3 means BR - void findBoundaryNear(Coord3D *pt, float okDistance, Int *outNdx, Int *outHandle); - - static Bool ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); - Bool ParseWaypointData(DataChunkInput &file, DataChunkInfo *info, void *userData); - -public: // overridden - virtual BOOL DoSave(LPCTSTR lpszPathName, BOOL bReplace = TRUE) override; - virtual BOOL DoFileSave() override; - -// Attributes -public: - - WorldHeightMapEdit *GetHeightMap() {return m_heightMap;} - void SetHeightMap(WorldHeightMapEdit *pMap, Bool doUpdate); - - void Create2DView(); - void Create3DView(); - - CWorldBuilderView *Get2DView(); - WbView3d *Get3DView(); - - static CWorldBuilderDoc *GetActiveDoc(); - static CWorldBuilderView *GetActive2DView(); - static WbView3d *GetActive3DView(); - - void invalObject(MapObject *pMapObj); - void invalCell(int xIndex, int yIndex); - - void updateAllViews(); - void updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange); - - /// Gets an xy index into the height map from a pixel location. - Bool getCellIndexFromCoord(Coord3D pt, CPoint *ndxP); - - void getCoordFromCellIndex(CPoint ndx, Coord3D* pt); - - /// Gets a real xy location from a pixel point. - Bool getCellPositionFromCoord(Coord3D pt, Coord3D *locP); - - /// Gets all of the indices within widthOutside of the rectangle and places them into - /// allIndices - Bool getAllIndexesInRect(const Coord3D* bl, const Coord3D* br, - const Coord3D* tl, const Coord3D* tr, - Int widthOutside, VecHeightMapIndexes* allIndices); - - /// Gets the arrow point location. - void getObjArrowPoint(MapObject *pObj, Coord3D *location); - - void syncViewCenters(Real x, Real y); - - Bool needAutoSave() {return m_needAutosave;}; - - Int getNextWaypointID() { return ++m_curWaypointID;}; - - void setNextWaypointID(Int newMax) { if (newMax>m_curWaypointID) m_curWaypointID = newMax;}; - - void autoSave(); - void validate(); -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWorldBuilderDoc) - public: - virtual BOOL OnNewDocument() override; - virtual void Serialize(CArchive& ar) override; - virtual BOOL OnOpenDocument(LPCTSTR lpszPathName) override; - virtual BOOL CanCloseFrame(CFrameWnd* pFrame) override; - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CWorldBuilderDoc() override; -#ifdef RTS_DEBUG - virtual void AssertValid() const override; - virtual void Dump(CDumpContext& dc) const override; -#endif - void AddAndDoUndoable(Undoable *pUndo); -// Generated message map functions -protected: - //{{AFX_MSG(CWorldBuilderDoc) - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnEditUndo(); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - afx_msg void OnTsInfo(); - afx_msg void OnTsCanonical(); - afx_msg void OnUpdateTsCanonical(CCmdUI* pCmdUI); - afx_msg void OnFileResize(); - afx_msg void OnJumpToGame(); - afx_msg void OnTsRemap(); - afx_msg void OnEditLinkCenters(); - afx_msg void OnUpdateEditLinkCenters(CCmdUI* pCmdUI); - afx_msg void OnViewTimeOfDay(); - afx_msg void OnWindow2dwindow(); - afx_msg void OnUpdateWindow2dwindow(CCmdUI* pCmdUI); - afx_msg void OnViewReloadtextures(); - afx_msg void OnEditScripts(); - afx_msg void OnViewHome(); - afx_msg void OnTexturesizingTile4x4(); - afx_msg void OnUpdateTexturesizingTile4x4(CCmdUI* pCmdUI); - afx_msg void OnTexturesizingTile6x6(); - afx_msg void OnUpdateTexturesizingTile6x6(CCmdUI* pCmdUI); - afx_msg void OnTexturesizingTile8x8(); - afx_msg void OnUpdateTexturesizingTile8x8(CCmdUI* pCmdUI); - afx_msg void OnDumpDocToText(); - afx_msg void OnRemoveclifftexmapping(); - afx_msg void OnTogglePitchAndRotation(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderView.h b/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderView.h deleted file mode 100644 index bf0a66e963c..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/WorldBuilderView.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldBuilderView.h : interface of the CWorldBuilderView class -// -///////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Lib/BaseType.h" -#include "W3DDevice/GameClient/WorldHeightMap.h" -#include "wbview.h" - -//#include "WW3D_SimpleWindow.h" - -#define MIN_GRID_SIZE 4 -class MapObject; -class CWorldBuilderDoc; - -class CWorldBuilderView : public WbView -{ -protected: // create from serialization only - CWorldBuilderView(); - DECLARE_DYNCREATE(CWorldBuilderView) - -// Operations -public: -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CWorldBuilderView) - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs) override; - protected: - virtual BOOL OnPreparePrinting(CPrintInfo* pInfo) override; - virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) override; - virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) override; - virtual void OnDraw(CDC* pDC) override; - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CWorldBuilderView() override; -#ifdef RTS_DEBUG - virtual void AssertValid() const override; - virtual void Dump(CDumpContext& dc) const override; -#endif - -protected: - - Int m_cellSize; ///< Size of a height map cell in pixels when drawn in the 2d view. - Bool m_showContours; ///< Flag whether contours are drawn in the 2d view. - - Bool m_showTexture; ///< Flag whether textures are drawn in the 2d view. - Bool mShowGrid; ///< Flag whether the gray grid is drawn in the 2d view. - - Int mXScrollOffset; ///< The x offset to the upper left corner of the screen. - Int mYScrollOffset; ///< The y offset to the upper left corner of the screen. - CPoint m_scrollMin; ///< The minimum scrollbar positions. - CPoint m_scrollMax; ///< The maximum scroll bar positions. - -protected: - - /// Draw a texture bitmap in a rectangle in the dc. - void drawMyTexture(CDC *pDc, CRect *pRect, Int width, UnsignedByte *rgbData); - - /// Get a color for a height value. - DWORD getColorForHeight(UnsignedByte ht); - - /// Draw the contours for the height map in the dc. - void drawContours(CDC *pDc, CRgn *pRgn, Int minX, Int maxX, Int minY, Int maxY); - - /// Compound boolean expression. - static Bool isBetween(Int cur, Int first, Int second) { - Bool is = false; - if (cur>=first && cur<=second) is = true; - if (cur<=first && cur>=second) is = true; - return(is); - } - - /// Interpolate the point at a given height between 2 points. - void interpolate(CPoint *pt, Int ht, CPoint pt1, Int ht1, CPoint pt2, Int ht2); - - /// Draw the object's icon in the dc at a given point. - void drawObjectInView(CDC *pDc, MapObject *pMapObj); - -public: - /// Get the current draw size in pixels in the 2d window of one height map cell. - Int getCellSize() {return m_cellSize;} - - /// Sets the current draw size. - void setCellSize(Int cellSize); - - /// Set whether contours are drawn. - Bool getShowContours() {return m_showContours;} - /// Set whether contours are drawn. - void setShowContours(Bool show); - /// Update the center to match a center point from the 3d view. - void updateCenterFromMapPoint(Real x, Real y); - -protected: - -public: - virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain) override; - virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt) override; - - /// Set the center for display. - virtual void setCenterInView(Real x, Real y) override; - - /// the doc has changed size; readjust view as necessary. - virtual void adjustDocSize() override; - - /// Invalidates an object. Pass null to inval all objects. - virtual void invalObjectInView(MapObject *pObj) override; - - /// Invalidates the area of one height map cell in the 2d view. - virtual void invalidateCellInView(int xIndex, int yIndex) override; - - /// Scrolls the window by this amount (doc coords). - virtual void scrollInView(Real x, Real y, Bool end) override; - -// Generated message map functions -protected: - //{{AFX_MSG(CWorldBuilderView) - afx_msg void OnPaint(); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg void OnShowGrid(); - afx_msg void OnUpdateShowGrid(CCmdUI* pCmdUI); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnViewShowtexture(); - afx_msg void OnUpdateViewShowtexture(CCmdUI* pCmdUI); -// afx_msg void OnViewShowcontours(); -// afx_msg void OnUpdateViewShowcontours(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/addplayerdialog.h b/GeneralsMD/Code/Tools/WorldBuilder/include/addplayerdialog.h deleted file mode 100644 index e1200daa304..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/addplayerdialog.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// addplayerdialog.h : header file -// - -#include "GameLogic/SidesList.h" - -///////////////////////////////////////////////////////////////////////////// -// AddPlayerDialog dialog - -class AddPlayerDialog : public CDialog -{ -private: - AsciiString m_side; - AsciiString m_addedSide; - -// Construction -public: - AddPlayerDialog(AsciiString side, CWnd* pParent = nullptr); // standard constructor - - AsciiString getAddedSide() { return m_addedSide; } - -// Dialog Data - //{{AFX_DATA(AddPlayerDialog) - enum { IDD = IDD_ADDPLAYER }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddPlayerDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(AddPlayerDialog) - virtual void OnOK() override; - virtual void OnCancel() override; - virtual BOOL OnInitDialog() override; - afx_msg void OnEditchangeCombo1(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/brushoptions.h b/GeneralsMD/Code/Tools/WorldBuilder/include/brushoptions.h deleted file mode 100644 index 0d1145e4187..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/brushoptions.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// brushoptions.h : header file -// - -#include "WBPopupSlider.h" -#include "OptionsPanel.h" -///////////////////////////////////////////////////////////////////////////// -/// BrushOptions modeless (floating) dialog - allows entry and display of brush width and feather. - -class BrushOptions : public COptionsPanel , public PopupSliderOwner -{ -// Construction -public: - enum {MIN_BRUSH_SIZE=1, - MAX_BRUSH_SIZE=51, - FREQ_BRUSH_TICKS=10, - MIN_FEATHER=0, - FREQ_FEATHER_TICKS=4, - MAX_FEATHER=20}; - - BrushOptions(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(BrushOptions) - enum { IDD = IDD_BRUSH_OPTIONS }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BrushOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - virtual void OnOK() override {return;}; //!< Modeless dialogs don't OK, so eat this for modeless. - virtual void OnCancel() override {return;}; //!< Modeless dialogs don't close on ESC, so eat this for modeless. - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(BrushOptions) - virtual BOOL OnInitDialog() override; - afx_msg void OnChangeFeatherEdit(); - afx_msg void OnChangeSizeEdit(); - afx_msg void OnChangeHeightEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - static BrushOptions *m_staticThis; ///< Reference to the floating panel so SetWidth and SetFeather can be static. - static Int m_currentWidth; ///< current brush width in the ui. - static Int m_currentFeather; ///< current feather width in the ui. - static Int m_currentHeight; - - Bool m_updating; ///. -*/ - -#pragma once - -// mapobjectprops.h : header file -// - -#include "OptionsPanel.h" -#include "Common/Dict.h" -#include "WBPopupSlider.h" - -class MapObject; -class ModifyObjectUndoable; -class MultipleUndoable; -class CWorldBuilderDoc; -class MapObject; - -///////////////////////////////////////////////////////////////////////////// -// External Defines -extern const char* NEUTRAL_TEAM_UI_STR; -extern const char* NEUTRAL_TEAM_INTERNAL_STR; - - -///////////////////////////////////////////////////////////////////////////// -// MapObjectProps dialog - -class MapObjectProps : public COptionsPanel, public PopupSliderOwner -{ -// Construction -public: - MapObjectProps(Dict* dictToEdit = nullptr, const char* title = nullptr, CWnd* pParent = nullptr); // standard constructor - virtual ~MapObjectProps() override; - void makeMain(); - -// Dialog Data - //{{AFX_DATA(MapObjectProps) - enum { IDD = IDD_MAPOBJECT_PROPS }; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MapObjectProps) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void getAllSelectedDicts(); - Dict** getAllSelectedDictsData(); - - static MapObjectProps *TheMapObjectProps; - - // Data common to all property pages - Dict* m_dictToEdit; - std::vector m_allSelectedDicts; - const char* m_title; - MapObject *m_selectedObject; - MapObject *m_dictSource; // Source object for m_dictToEdit. m_selectedObject is not always the current source - // of m_dictToEdit, and I don't understand why, so I'm making another MapObject pointer - // which is always kept in sync. - - Real m_angle; - Real m_height; - Real m_scale; - - WBPopupSliderButton m_heightSlider; - WBPopupSliderButton m_angleSlider; - WBPopupSliderButton m_scaleSlider; - - Int m_defaultEntryIndex; //< Index in the sound combobox of the entry labelled "default" - Bool m_defaultIsNone; //< The default for this object is no sound - AsciiString m_defaultEntryName; //< The original name of the default entry - - ModifyObjectUndoable *m_posUndoable; - Coord3D m_position; - - void deletePages(); - void updateTheUI(); - void enableButtons(); - int getSel(); - - - // Generated message map functions - //{{AFX_MSG(MapObjectProps) - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnSelchangeProperties(); - afx_msg void OnEditprop(); - afx_msg void OnNewprop(); - afx_msg void OnRemoveprop(); - afx_msg void OnDblclkProperties(); - - afx_msg void _TeamToDict(); - afx_msg void _NameToDict(); - afx_msg void _ScriptToDict(); - afx_msg void _WeatherToDict(); - afx_msg void _TimeToDict(); - afx_msg void _ScaleToDict(); - afx_msg void SetZOffset(); - afx_msg void SetAngle(); - afx_msg void SetPosition(); - afx_msg void OnScaleOn(); - afx_msg void OnScaleOff(); - afx_msg void OnKillfocusMAPOBJECTXYPosition(); - afx_msg void _PrebuiltUpgradesToDict(); - afx_msg void _HealthToDict(); - afx_msg void _EnabledToDict(); - afx_msg void _IndestructibleToDict(); - afx_msg void _UnsellableToDict(); - afx_msg void _TargetableToDict(); - afx_msg void _PoweredToDict(); - afx_msg void _AggressivenessToDict(); - afx_msg void _VisibilityToDict(); - afx_msg void _VeterancyToDict(); - afx_msg void _ShroudClearingDistanceToDict(); - afx_msg void _RecruitableAIToDict(); - afx_msg void _SelectableToDict(); - afx_msg void _HPsToDict(); - afx_msg void _StoppingDistanceToDict(); - afx_msg void attachedSoundToDict(); - afx_msg void customizeToDict(); - afx_msg void enabledToDict(); - afx_msg void loopingToDict(); - afx_msg void loopCountToDict(); - afx_msg void minVolumeToDict(); - afx_msg void volumeToDict(); - afx_msg void minRangeToDict(); - afx_msg void maxRangeToDict(); - afx_msg void priorityToDict(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - - void _DictToName(); - void _DictToTeam(); - void _DictToScript(); - void _DictToScale(); - void _DictToWeather(); - void _DictToTime(); - void _DictToPrebuiltUpgrades(); - void _DictToHealth(); - void _DictToHPs(); - void _DictToEnabled(); - void _DictToDestructible(); - void _DictToUnsellable(); - void _DictToTargetable(); - - void _DictToPowered(); - void _DictToAggressiveness(); - void _DictToVisibilityRange(); - void _DictToVeterancy(); - void _DictToShroudClearingDistance(); - void _DictToRecruitableAI(); - void _DictToSelectable(); - void _DictToStoppingDistance(); - void ShowZOffset(MapObject* pMapObj); - void ShowAngle(MapObject* pMapObj); - void ShowPosition(MapObject* pMapObj); - void dictToAttachedSound(); - void dictToCustomize(); - void dictToEnabled(); - void dictToLooping(); - void dictToLoopCount(); - void dictToMinVolume(); - void dictToVolume(); - void dictToMinRange(); - void dictToMaxRange(); - void dictToPriority(); - - void clearCustomizeFlag( CWorldBuilderDoc* pDoc, MultipleUndoable * ownerUndoable ); - - // Implementation of PopupSliderOwner callbacks - virtual void GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) override; - virtual void PopSliderChanged(const long sliderID, long theVal) override; - virtual void PopSliderFinished(const long sliderID, long theVal) override; - -public: - static MapObject *getSingleSelectedMapObject(); - static void update(); - -private: - /// Disallow copying: Object is not set up to be copied - MapObjectProps( const MapObjectProps & other ); // Deliberately undefined - MapObjectProps & operator=( const MapObjectProps & other ); // Deliberately undefined - void updateTheUI(MapObject *pMapObj); - void InitSound(); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/playerlistdlg.h b/GeneralsMD/Code/Tools/WorldBuilder/include/playerlistdlg.h deleted file mode 100644 index 26f8c78503d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/playerlistdlg.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// playerlistdlg.h : header file -// - -#include "GameLogic/SidesList.h" -#include "CButtonShowColor.h" - -///////////////////////////////////////////////////////////////////////////// -// PlayerListDlg dialog - -class PlayerListDlg : public CDialog -{ -// Construction -public: - PlayerListDlg(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(PlayerListDlg) - enum { IDD = IDD_PLAYERLIST }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PlayerListDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - Int m_updating; - SidesList m_sides; - Int m_curPlayerIdx; - CButtonShowColor m_colorButton; - - void updateTheUI(); - void PopulateColorComboBox(); - void SelectColor(RGBColor rgb); - - // Generated message map functions - //{{AFX_MSG(PlayerListDlg) - afx_msg void OnNewplayer(); - afx_msg void OnEditplayer(); - afx_msg void OnRemoveplayer(); - afx_msg void OnSelchangePlayers(); - virtual BOOL OnInitDialog() override; - afx_msg void OnDblclkPlayers(); - afx_msg void OnSelchangeAllieslist(); - afx_msg void OnSelchangeEnemieslist(); - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnPlayeriscomputer(); - afx_msg void OnEditchangePlayerfaction(); - afx_msg void OnChangePlayername(); - afx_msg void OnChangePlayerdisplayname(); - afx_msg void OnColorPress(); - afx_msg void OnSelectPlayerColor(); - afx_msg void OnAddskirmishplayers(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/propedit.h b/GeneralsMD/Code/Tools/WorldBuilder/include/propedit.h deleted file mode 100644 index 8eccbc3892a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/propedit.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// propedit.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// PropEdit dialog - -class PropEdit : public CDialog -{ -// Construction -public: - PropEdit(AsciiString* key, Dict::DataType* type, AsciiString* value, Bool valueOnly, CWnd *parent = nullptr); - -// Dialog Data - //{{AFX_DATA(PropEdit) - enum { IDD = IDD_PROPEDIT }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PropEdit) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - AsciiString* m_key; - Dict::DataType* m_type; - AsciiString* m_value; - Bool m_valueOnly; - int m_updating; - - void validate(); - - // Generated message map functions - //{{AFX_MSG(PropEdit) - afx_msg void OnChangeKeyname(); - afx_msg void OnEditchangeKeytype(); - afx_msg void OnCloseupKeytype(); - afx_msg void OnSelchangeKeytype(); - afx_msg void OnChangeValue(); - virtual BOOL OnInitDialog() override; - afx_msg void OnPropbool(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/teamsdialog.h b/GeneralsMD/Code/Tools/WorldBuilder/include/teamsdialog.h deleted file mode 100644 index 84d22cf5c35..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/teamsdialog.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -// teamsdialog.h : header file -// - -#include "GameLogic/SidesList.h" - -///////////////////////////////////////////////////////////////////////////// -// CTeamsDialog dialog - -class CTeamsDialog : public CDialog -{ -// Construction -public: - CTeamsDialog(CWnd* pParent = nullptr); // standard constructor - -// Dialog Data - //{{AFX_DATA(CTeamsDialog) - enum { IDD = IDD_TEAMS_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CTeamsDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CTeamsDialog) - virtual BOOL OnInitDialog() override; - virtual void OnOK() override; - virtual void OnCancel() override; - afx_msg void OnNewteam(); - afx_msg void OnDeleteteam(); - afx_msg void OnEditTemplate(); - afx_msg void OnSelchangePlayerList(); - afx_msg void OnClickTeamsList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDblclkTeamsList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnCopyteam(); - afx_msg void OnSelectTeamMembers(); - afx_msg void OnMoveDownTeam(); - afx_msg void OnMoveUpTeam(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - Int m_updating; - SidesList m_sides; - Int m_curTeam; - - enum - { - REBUILD_TEAMS = 0x01, - REBUILD_OWNERS = 0x02, - REBUILD_ALLIES = 0x04, - - REBUILD_NONE = 0x00, - REBUILD_ALL = 0xff - }; - - void updateUI(Int whatToRebuild); - void validateTeamOwners(); - Bool isValidTeamOwner( AsciiString ownerName ); - void doCorrectTeamOwnerDialog( TeamsInfo *ti ); - -private: - void UpdateTeamsList(); - -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/wbview.h b/GeneralsMD/Code/Tools/WorldBuilder/include/wbview.h deleted file mode 100644 index 38699a0555a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/wbview.h +++ /dev/null @@ -1,253 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#pragma once - -#include "Lib/BaseType.h" -#include "Tool.h" -#include "Common/Debug.h" -#include "Common/ThingSort.h" - -class CWorldBuilderDoc; -class BuildListInfo; -// wbview.h : header file -// - -enum TPickedStatus { - PICK_NONE, - PICK_CENTER, - PICK_ARROW -}; - -enum RulerTypeEnum { - RULER_NONE, - RULER_LINE, - RULER_CIRCLE, -}; - -///////////////////////////////////////////////////////////////////////////// -// WbView view - -class WbView : public CView -{ -protected: - WbView(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(WbView) - - TTrackingMode m_trackingMode; - Vector3 m_centerPt; - - void mouseDown(TTrackingMode m, CPoint viewPt); - void mouseMove(TTrackingMode m, CPoint viewPt); - void mouseUp(TTrackingMode m, CPoint viewPt); - - - void constrainCenterPt(); - - WorldHeightMapEdit *getTrackingHeightMap(); - - static Bool m_snapToGrid; - - Bool m_showObjects; ///< Flag whether object icons are drawn in the 2d and 3d view. - Bool m_showModels; ///< Flag whether models are drawn in the 2d and 3d view. - Bool m_showNames; ///< Flag whether names are drawn in the 2d and 3d view. - Bool m_showGarrisoned; - Bool m_showWaypoints; - Bool m_showPolygonTriggers; - Bool m_showTerrain; ///< Flag whether terrain is rendered or not. (Useful for debugging) - - Real m_hysteresis; - - Bool m_lockAngle; ///< Reflects the ui button. - //Bool m_lockVertical; ///< Reflects the ui button. - Bool m_doLockAngle; ///< True if we are currently locking. - //Bool m_doLockVertical; ///< True if we are currently locking. - CPoint m_mouseDownPoint; - Coord3D m_mouseDownDocPoint; - - // Box feedback. - RECT m_feedbackBox; - Bool m_doRectFeedback; - int m_doRulerFeedback; - Coord3D m_rulerPoints[2]; - Real m_rulerLength; - - // Light direction feedback - Coord3D m_lightDirection[3]; //direction of all 3 lights - Bool m_doLightFeedback; - - EditorSortingType m_pickConstraint; - - // Attributes -public: - - void doRectFeedback(Bool doFeedback, RECT &rect) {m_feedbackBox=rect;m_doRectFeedback = doFeedback;}; - void doRulerFeedback(int doRulerFeedback) {m_doRulerFeedback = doRulerFeedback;} - void rulerFeedbackInfo(Coord3D &point1, Coord3D &point2, Real dist); - - void doLightFeedback(Bool doFeedback, Coord3D direction, Int lightIndex) { m_doLightFeedback=doFeedback; if (m_doLightFeedback) m_lightDirection[lightIndex]=direction;} - - virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrained=true) { DEBUG_CRASH(("should not call")); newPt->zero(); return false; } - virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt) { DEBUG_CRASH(("should not call")); return false; } - - virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z) { return viewToDocCoords(curPt, newPt, false); } - - /// Set the center for display. - virtual void setCenterInView(Real x, Real y) { } - - /// Update the height map in the 3d window. - virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) { } - - /// the doc has changed size; readjust view as necessary. - virtual void adjustDocSize() { } - - /// Scrolls the window by this amount. - virtual void scrollInView(Real x, Real y, Bool end) { DEBUG_CRASH(("should not call")); } - - /// Invalidates an object. Pass null to inval all objects. - virtual void invalObjectInView(MapObject *pObj) { } - - /// Invalidates the area of one height map cell in the 2d view. - virtual void invalidateCellInView(int xIndex, int yIndex) { } - - virtual void setDefaultCamera() { } - virtual void rotateCamera(Real delta) { } - virtual void pitchCamera(Real delta) { } - - virtual Int getPickPixels() {return 4;} - virtual EditorSortingType GetPickConstraint() {return m_pickConstraint;} - -public: - CWorldBuilderDoc *WbDoc() { return ((CWorldBuilderDoc*)GetDocument()); } - - void snapPoint(Coord3D *thePt) {if (m_snapToGrid || m_lockAngle) {thePt->x = MAP_XY_FACTOR*floor(thePt->x/MAP_XY_FACTOR+0.5); thePt->y = MAP_XY_FACTOR*floor(thePt->y/MAP_XY_FACTOR+0.5);};}; - - virtual TPickedStatus picked(MapObject *pObj, Coord3D docPt); - virtual MapObject *picked3dObjectInView(CPoint viewPt) {return nullptr;}; - virtual BuildListInfo *pickedBuildObjectInView(CPoint viewPt) {return nullptr;}; - - Bool isPolygonTriggerVisible() {return m_showPolygonTriggers;}; - Bool isWaypointVisible() {return m_showWaypoints;}; - Bool isNamesVisible() {return m_showNames;}; - void setShowModels(Bool show) {m_showModels = show;} - Bool getShowModels() { return m_showModels;} - Bool getShowTerrain() { return m_showTerrain;} - - void setShowGarrisoned(Bool show) {m_showGarrisoned = show;} - Bool getShowGarrisoned() { return m_showGarrisoned;} - - virtual Bool isDoingPitch() { return false; } - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(WbView) - protected: - virtual void OnDraw(CDC* pDC) override; // overridden to draw this view - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual ~WbView() override; -#ifdef RTS_DEBUG - virtual void AssertValid() const override; - virtual void Dump(CDumpContext& dc) const override; -#endif - - // Generated message map functions -protected: - //{{AFX_MSG(WbView) - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnRButtonDown(UINT nFlags, CPoint point); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnMButtonUp(UINT nFlags, CPoint point); - afx_msg void OnMButtonDown(UINT nFlags, CPoint point); - afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnEditDelete(); - afx_msg void OnEditCopy(); - afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI); - afx_msg void OnEditCut(); - afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI); - afx_msg void OnEditPaste(); - afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI); - afx_msg void OnViewSnaptogrid(); - afx_msg void OnUpdateViewSnaptogrid(CCmdUI* pCmdUI); - afx_msg void OnViewShowObjects(); - afx_msg void OnUpdateViewShowObjects(CCmdUI* pCmdUI); - afx_msg void OnEditSelectdup(); - afx_msg void OnEditSelectsimilar(); - afx_msg void OnEditSelectinvalidteam(); - afx_msg void OnEditReplace(); - afx_msg void OnObjectpropertiesReflectsinmirror(); - afx_msg void OnLockHorizontal(); - afx_msg void OnUpdateLockHorizontal(CCmdUI* pCmdUI); - afx_msg void OnLockVertical(); - afx_msg void OnUpdateLockVertical(CCmdUI* pCmdUI); - afx_msg void OnEditGloballightoptions(); - afx_msg void OnViewShowwaypoints(); - afx_msg void OnUpdateViewShowwaypoints(CCmdUI* pCmdUI); - afx_msg void OnViewShowpolygontriggers(); - afx_msg void OnUpdateViewShowpolygontriggers(CCmdUI* pCmdUI); - afx_msg void OnEditPlayerlist(); - afx_msg void OnEditWorldinfo(); - afx_msg void OnEditTeamlist(); - afx_msg void OnUpdateObjectpropertiesReflectsinmirror(CCmdUI* pCmdUI); - afx_msg void OnPickStructures(); - afx_msg void OnUpdatePickStructures(CCmdUI* pCmdUI); - afx_msg void OnPickInfantry(); - afx_msg void OnUpdatePickInfantry(CCmdUI* pCmdUI); - afx_msg void OnPickVehicles(); - afx_msg void OnUpdatePickVehicles(CCmdUI* pCmdUI); - afx_msg void OnPickShrubbery(); - afx_msg void OnUpdatePickShrubbery(CCmdUI* pCmdUI); - afx_msg void OnPickManMade(); - afx_msg void OnUpdatePickManMade(CCmdUI* pCmdUI); - afx_msg void OnPickNatural(); - afx_msg void OnUpdatePickNatural(CCmdUI* pCmdUI); - afx_msg void OnPickDebris(); - afx_msg void OnUpdatePickDebris(CCmdUI* pCmdUI); - afx_msg void OnPickAnything(); - afx_msg void OnUpdatePickAnything(CCmdUI* pCmdUI); - afx_msg void OnPickWaypoints(); - afx_msg void OnUpdatePickWaypoints(CCmdUI* pCmdUI); - afx_msg void OnPickRoads(); - afx_msg void OnUpdatePickRoads(CCmdUI* pCmdUI); - afx_msg void OnPickSounds(); - afx_msg void OnUpdatePickSounds(CCmdUI* pCmdUI); - afx_msg void OnShowNames(); - afx_msg void OnUpdateShowNames(CCmdUI* pCmdUI); - afx_msg void OnValidationFixTeams(); - afx_msg void OnShowTerrain(); - afx_msg void OnUpdateShowTerrain(CCmdUI* pCmdUI); - afx_msg int OnCreate(LPCREATESTRUCT lpcs); - - - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/include/wbview3d.h b/GeneralsMD/Code/Tools/WorldBuilder/include/wbview3d.h deleted file mode 100644 index 7439499c471..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/include/wbview3d.h +++ /dev/null @@ -1,335 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - -// WbView3d.h -// Class to encapsulate height map. -// Author: Steven Johnson, Aug 2001 - -#pragma once - -// wbview3d.h : header file -// - -#include "Lib/BaseType.h" -#include "WW3D2/rendobj.h" -#include "WW3D2/robjlist.h" -#include "wbview.h" -#include "Common/GameType.h" -#include "Common/GlobalData.h" -#include "Common/ModelState.h" -#include "WW3D2/dx8wrapper.h" - -//#include "GameLogic/Module/BodyModule.h" -- Yikes... not necessary to include this! (KM) -enum BodyDamageType CPP_11(: Int); //Ahhhh much better! - -class WorldHeightMap; -class LayerClass; -class IntersectionClass; -class W3DAssetManager; -class SkeletonSceneClass; -class CameraClass; -class WBHeightMap; -class LightClass; -class MapObject; -class DrawObject; -class CWorldBuilderView; -class BuildListInfo; -class TransRenderObj; -struct ID3DXFont; - -///////////////////////////////////////////////////////////////////////////// -// WbView3d view - -class WbView3d : public WbView, public DX8_CleanupHook -{ -protected: - WbView3d(); // protected constructor used by dynamic creation - DECLARE_DYNCREATE(WbView3d) - -// Attributes -public: - - // DX8_CleanupHook methods - virtual void ReleaseResources() override; ///< Release all dx8 resources so the device can be reset. - virtual void ReAcquireResources() override; ///< Reacquire all resources after device reset. - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(WbView3d) - protected: - virtual void OnDraw(CDC* pDC) override; // overridden to draw this view - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual ~WbView3d() override; -#ifdef RTS_DEBUG - virtual void AssertValid() const override; - virtual void Dump(CDumpContext& dc) const override; -#endif - - // Generated message map functions -protected: - //{{AFX_MSG(WbView3d) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnPaint(); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg void OnDestroy(); - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); - afx_msg void OnViewShowwireframe(); - afx_msg void OnUpdateViewShowwireframe(CCmdUI* pCmdUI); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnViewShowentire3dmap(); - afx_msg void OnUpdateViewShowentire3dmap(CCmdUI* pCmdUI); - afx_msg void OnViewShowtopdownview(); - afx_msg void OnUpdateViewShowtopdownview(CCmdUI* pCmdUI); - afx_msg void OnViewShowclouds(); - afx_msg void OnUpdateViewShowclouds(CCmdUI* pCmdUI); - afx_msg void OnViewShowmacrotexture(); - afx_msg void OnUpdateViewShowmacrotexture(CCmdUI* pCmdUI); - afx_msg void OnEditSelectmacrotexture(); - afx_msg void OnLookEast(); - afx_msg void OnUpdateLookEast(CCmdUI* pCmdUI); - afx_msg void OnLookNorth(); - afx_msg void OnUpdateLookNorth(CCmdUI* pCmdUI); - afx_msg void OnLookSouth(); - afx_msg void OnUpdateLookSouth(CCmdUI* pCmdUI); - afx_msg void OnLookWest(); - afx_msg void OnUpdateLookWest(CCmdUI* pCmdUI); - afx_msg void OnViewShowshadows(); - afx_msg void OnUpdateViewShowshadows(CCmdUI* pCmdUI); - afx_msg void OnViewShowSoftWater(); - afx_msg void OnUpdateViewShowSoftWater(CCmdUI* pCmdUI); - afx_msg void OnViewExtraBlends(); - afx_msg void OnUpdateViewShowExtraBlends(CCmdUI* pCmdUI); - afx_msg void OnEditShadows(); - afx_msg void OnEditMapSettings(); - afx_msg void OnViewShowimpassableareas(); - afx_msg void OnUpdateViewShowimpassableareas(CCmdUI* pCmdUI); - afx_msg void OnImpassableAreaOptions(); - afx_msg void OnViewPartialmapsize96x96(); - afx_msg void OnUpdateViewPartialmapsize96x96(CCmdUI* pCmdUI); - afx_msg void OnViewPartialmapsize192x192(); - afx_msg void OnUpdateViewPartialmapsize192x192(CCmdUI* pCmdUI); - afx_msg void OnViewPartialmapsize160x160(); - afx_msg void OnUpdateViewPartialmapsize160x160(CCmdUI* pCmdUI); - afx_msg void OnViewPartialmapsize128x128(); - afx_msg void OnUpdateViewPartialmapsize128x128(CCmdUI* pCmdUI); - afx_msg void OnViewShowModels(); - afx_msg void OnUpdateViewShowModels(CCmdUI* pCmdUI); - afx_msg void OnViewBoundingBoxes(); - afx_msg void OnUpdateViewBoundingBoxes(CCmdUI* pCmdUI); - afx_msg void OnViewSightRanges(); - afx_msg void OnUpdateViewSightRanges(CCmdUI* pCmdUI); - afx_msg void OnViewWeaponRanges(); - afx_msg void OnUpdateViewWeaponRanges(CCmdUI* pCmdUI); - afx_msg void OnHighlightTestArt(); - afx_msg void OnUpdateHighlightTestArt(CCmdUI* pCmdUI); - afx_msg void OnShowLetterbox(); - afx_msg void OnUpdateShowLetterbox(CCmdUI* pCmdUI); - afx_msg void OnViewLayersList(); - afx_msg void OnUpdateViewLayersList(CCmdUI* pCmdUI); - afx_msg void OnViewGarrisoned(); - afx_msg void OnUpdateViewGarrisoned(CCmdUI* pCmdUI); - afx_msg void OnViewShowMapBoundaries(); - afx_msg void OnUpdateViewShowMapBoundaries(CCmdUI* pCmdUI); - afx_msg void OnViewShowAmbientSounds(); - afx_msg void OnUpdateViewShowAmbientSounds(CCmdUI* pCmdUI); - afx_msg void OnViewShowSoundCircles(); - afx_msg void OnUpdateViewShowSoundCircles(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - HINSTANCE m_hInst; - W3DAssetManager *m_assetManager; - SkeletonSceneClass *m_scene; - SkeletonSceneClass *m_overlayScene; - SkeletonSceneClass *m_baseBuildScene; - SkeletonSceneClass *m_transparentObjectsScene; - CameraClass *m_camera; - WBHeightMap *m_heightMapRenderObj; - - RenderObjClass *m_objectToolTrackingObj; - Bool m_showObjToolTrackingObj; - AsciiString m_objectToolTrackingModelName; - - Real m_mouseWheelOffset; - Real m_groundLevel; - Coord3D m_cameraOffset; - CPoint m_actualWinSize; - Real m_theta; - Real m_cameraAngle; - Real m_FXPitch; - Bool m_doPitch; - Real m_actualHeightAboveGround; // for camera tool display only - Vector3 m_cameraSource; // for camera tool display only - Vector3 m_cameraTarget; // for camera tool display only - Int m_time; - Int m_updateCount; - UINT m_timer; - DrawObject *m_drawObject; - RefRenderObjListClass m_lightList; - LayerClass *m_layer; - LayerClass *m_buildLayer; - IntersectionClass *m_intersector; - Bool m_showWireframe; - Bool m_ww3dInited; - Bool m_needToLoadRoads; - LightClass *m_globalLight[MAX_GLOBAL_LIGHTS]; - RenderObjClass *m_lightFeedbackMesh[MAX_GLOBAL_LIGHTS]; - - Real m_buildRedMultiplier; - - Real m_curTrackingZ; - - - Bool m_projection; ///< True if top down projection instead of "isometric" perspective. - Bool m_showEntireMap; ///< True if drawing entire map instead of cached fast subset. - Bool m_showShadows; ///< True if drawing shadows. - Bool m_firstPaint; ///< True if we haven't painted yet. - Bool m_showLayersList; ///< Flag whether the layers list is visible or not. - Bool m_showMapBoundaries; ///< Flag whether to show all the map boundaries or not - Bool m_showAmbientSounds; ///< Flag whether to show all the ambient sounds or not - Bool m_showSoundCircles; ///< Flag whether to show the minimum and maximum radii of the ambient sounds attached to the selected object - Bool m_showBoundingBoxes; - Bool m_showSightRanges; - Bool m_showWeaponRanges; - Bool m_highlightTestArt; - Bool m_showLetterbox; - - - ID3DXFont* m3DFont; - Int m_pickPixels; - Int m_partialMapSize; - -protected: - - UINT getLastDrawTime(); - void init3dScene(); - void initAssets(); - void initWW3D(); - void drawCircle( HDC hdc, const Coord3D & centerPoint, Real radius, COLORREF color ); - void drawLabels(HDC hdc); - void drawLabels(); - void shutdownWW3D(); - void killTheTimer(); - void render(); - void setupCamera(); - void updateHysteresis(); - void updateLights(); - void updateScorches(); - void updateTrees(); - -public: - virtual Bool viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain=true) override; - virtual Bool docToViewCoords(Coord3D curPt, CPoint* newPt) override; - - virtual void updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) override; - - /// Invalidates an object. Pass null to inval all objects. - virtual void invalObjectInView(MapObject *pObj) override; - - // find the best model for an object - AsciiString getBestModelName(const ThingTemplate* tt, const ModelConditionFlags& c); - - /// Invalidates an build list object. - void invalBuildListItemInView(BuildListInfo *pBuild); - - /// Invalidates the area of one height map cell in the 2d view. - virtual void invalidateCellInView(int xIndex, int yIndex) override; - - /// Scrolls the window by this amount. - virtual void scrollInView(Real x, Real y, Bool end) override; - - virtual void setDefaultCamera() override; - virtual void rotateCamera(Real delta) override; - virtual void pitchCamera(Real delta) override; - void setCameraPitch(Real absolutePitch); - Real getCameraPitch(); - Real getCurrentZoom(); //WST 10/17/2002 - Real getHeightAboveGround() { return m_actualHeightAboveGround; } - Vector3 getCameraSource() { return m_cameraSource; } - Vector3 getCameraTarget() { return m_cameraTarget; } - Real getCameraAngle() { return m_cameraAngle; } - CPoint getActualWinSize() {return m_actualWinSize;} - - virtual MapObject *picked3dObjectInView(CPoint viewPt) override; - virtual BuildListInfo *pickedBuildObjectInView(CPoint viewPt) override; - - void removeFenceListObjects(MapObject *pObject); - void updateFenceListObjects(MapObject *pObject); - - /// Removes all render objects. Call when swithing to a new map. - void resetRenderObjects(); - - void stepTimeOfDay(); - - void reset3dEngineDisplaySize(Int width, Int height); ///< Closes & reinitializes w3d. - void setLighting(const GlobalData::TerrainLighting *tl, Int whichLighting, Int whichLight=0); - - DrawObject *getDrawObject() {return m_drawObject;}; - - AsciiString getModelNameAndScale(MapObject *pMapObj, Real *scale, BodyDamageType curDamageState); - - virtual Int getPickPixels() override {return m_pickPixels;} - virtual Bool viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real Z) override; -public: - -// void init(CWorldBuilderView *pMainView, HINSTANCE hInstance, CWnd* parent); - void redraw(); - - virtual void setCenterInView(Real x, Real y) override; - - Bool getShowTerrain(); - Bool getShowWireframe(); - - void setObjTracking(MapObject *pMapObj, Coord3D pos, Real angle, Bool show); - void setViewLayersList(Bool showLayersList) { m_showLayersList = showLayersList; } - - Bool getShowMapBoundaryFeedback() const { return m_showMapBoundaries; } - Bool getShowAmbientSoundsFeedback() const { return m_showAmbientSounds; } - - void togglePitchAndRotation() { m_doPitch = !m_doPitch; } - virtual Bool isDoingPitch() override { return m_doPitch; } - void setShowBoundingBoxes(Bool toggle) {m_showBoundingBoxes = toggle;} - Bool getShowBoundingBoxes() { return m_showBoundingBoxes;} - void setShowSightRanges(Bool toggle) {m_showSightRanges = toggle;} - Bool getShowSightRanges() { return m_showSightRanges;} - void setShowWeaponRanges(Bool toggle) {m_showWeaponRanges = toggle;} - Bool getShowWeaponRanges() { return m_showWeaponRanges;} - void setHighlightTestArt(Bool toggle) {m_highlightTestArt = toggle;} - Bool getHighlightTestArt() { return m_highlightTestArt;} - void setShowLetterbox(Bool toggle) {m_showLetterbox = toggle;} - Bool getShowLetterbox() { return m_showLetterbox;} -}; - -inline UINT WbView3d::getLastDrawTime() { return m_time; } -inline Bool WbView3d::getShowWireframe() { return m_showWireframe; } - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDB_DownArrow.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/IDB_DownArrow.bmp deleted file mode 100644 index 720d25254cfc5f55b6f54de047c9f0b9ac10ba7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 134 zcmZ?rZDW9dG9aY^#B4y!0>q49l7T@0$VLbM|Nmz=cI+5LxS@fe0muT8KqkY10|yum z+&RGT;nXq)78Vu;4h{|m9v&VBK|w(VF)=X)85tRd^73+qa;0*HA|-VOB_$;W0OEQU AMF0Q* diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/IDB_ROAD_CORNERS.bmp deleted file mode 100644 index eb9d709e160d0c9e3c1c9dca4d3a86f4f89a7ff4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 502 zcmZ?r{l>@u24z4}1BeBH*Z_zb8CZZM149E;9?U@@8i0~OfrbVM1tft?h64u<0BMlK ze=uVB{~yExVju(w0f}<0w27zc0A0!Tv2dM+8hXJ4)C<5&t{{L@&@c%!IzIgQi{~!JT V|Nof}F&0FF_#km)bs+U1000CofD`}# diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BLEND_EDGE.cur deleted file mode 100644 index 3fe9afdd248d37c50cf3769f87adcf4acdfb39c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmbu(u?@m75QX7qA_WNws3>S~2PGT$_F;)EL`RQD$p|h}SUG+|s3Iz!^_``&t+TXJ zP>j+>dtHNckaPhp83OB_ZmP@T?#t${PUPTgzOz10V=|LWvB`=pb|xL^CH5PtDcns> lF|`lV)=Veo{1g80Po6wZ?jtG&6!ggGpyVSe1{Cy|^8y|}e+>Wt diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_LIST_TOOL.cur deleted file mode 100644 index fb81e94fa00bab94115e1bd6139d0ac7772c2fba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmbV`K@NgI3`KvzgpF(0EM0m7xdAHN2NE}$n0O_Qg+Wr^z$C=r%1&N?`Hc#&V;1~ZYGao$;?HT?zuT%d4*szWtX jqqkVQ4}61oEB%X}doTA^3s?F(&pwXdJXsS+A&d0~S*Uo9 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_BUILD_MOVE.cur deleted file mode 100644 index df222d491007a9b16add24cae1e6182440684149..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZY3F%AJi6vpvyW{52|SwvJ4TPT!nfN0!`t4I_aK&NvOH&9MudHxTH!fbx?W#7Dc zyHZq8T}vHu7Nnu1DJW@yz~gKC-v2i<`xV1ID_GW&+*uA?DIP7iPnHYnp7FrU9zC3E z3F;~t(f>#j?(DHf1wJ1mS}5Q%Yb>ypk|eV`zrkvh-p=Gm=~*g021=Q>8$A8p>wa$D b*WiXL_t9LiLdVB_1u}hW6*jwsT!3be4LacFn?PFI^~e{j@ClCn0_~e~YXATM diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_CLIFF.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_CLIFF.cur deleted file mode 100644 index f82dc2776675ed18002c659e78e040b9c1ead8fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZQzU}9ioP*7k10|Q0|1~DK@1BexX*a3(cfe;L!6oi8y|NsAw;Lw020W=eY3xK!+ zN+$qm2Ox$4pc}{nkF@vyfA<=QU(N^9k6!ennDZRSI}F6kK+KLr^8?xPKx_}h^*{^& DTm*Yb diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_EYEDROPPER.cur deleted file mode 100644 index 8d5878292cbe0cdca563af1a774dbe68051b748e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcma*hF$%&k6vpu{cF3j<#YsrUj*cBYibwDU1{^$>^df~`z_CN|`A@qPBH|0bmzT#Q ziL{YZjFMNalamgT8qm@ij+GNvk_Cq!1SlQFDmL6bW z`27G(gZcLp7;uThjF12_K)3*iE1+}&kahrK7y!BfFZjX0{+}HD@c;Awhk+(D12H=i P%@1VD1F=02*8?#Cx~y|H diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_FLOOD_FILL.cur deleted file mode 100644 index 3e0dbea713290e062184dbd4a6fb59d9435ea690..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmbWxy$!-J5QgE`0Xifk3JMxhQqobv2yDU#@gU5=3Z!8N8pMwmh?Ir`@$m_QQc=KJ zk9~JK=?ocxJck}bW&uXP)ZAie!RHmt^Df$3Qd|6xbw9IxCu5u2I>M>`~3WLxjw qxPP#feF^{Juc&J&U97ZND6!C$iOyCzuPAgwx(DfD+S{>_+Lcd}5_`u0 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_GROVE.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_GROVE.cur deleted file mode 100644 index faf43b84763577a8d4adc3375c3770ea1793f361..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmchRK?=f93`FPm04}?7(WOg|;H9L3lzOa!6i@Q;1Z~}vFO>EfZRLaAn=q5iK$u90 zoU%;XXsf-GQb{|5SvnY;^}8+~UK6l3|LoWgFfMqMasPV1vj|Xk;P24fnEEr}6d3B3 X(R-%mN;u{WRn(ZKiZ}F@^PDqZisXB2 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_HAND_SCROLL.cur deleted file mode 100644 index 590de07dabd0833a1530df1767faeca64e99847c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcma*hu@S;B429v}P^5uNM;n)Puz^{K8R8Kbg$>98?7#@z(NN^_cs6B#K*fz<%ZsJEcV{>jC%F2qSn)Of;r|Rt dDzedOs#=Y-dRC3b+<5mkvGa{@V=q1QF)u+ed^7+6 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOLD_POINTER.cur deleted file mode 100644 index 784df4bf50809754debc9dd1f1d0ac214697797e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZQzU}9ioP*7k10|Q0|1~DK@1BexX*a3(cfe-{5z$7N||NnnXK@vpR&o?k|Z+Bqe ztvbNK_P2q7wW@)Ec{|X6GY~^0fD{N90C5GBP5{ylKnw#wH;@G$Fv$N$#vd5$|AX)k jhWh`1824iVVW7!C>OVUY%@1VD1F=02*8?#C*gto9 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_MOVE_POINTER.cur deleted file mode 100644 index a1938398c1cbd118d040ae8aaa2dba0019fe191c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZvWK@I^y5Ji6v2@#Y%X6S}(DIWOx2qcajeO~W9WZmi zSPZ4?R%pyxA!noWzyP`zBQX^z^oRfPmVOoFb45PZWayK}R#juam+uy2kG##viwII7 Sj{L?#a)lhpv$%@8Nbv!m5_-)5 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_PLACE_OBJECT.cur deleted file mode 100644 index c65f57d771451f7c6d5319a355ccc650396304f8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZQzU}9ioP*7k1(mV_Xj0_B73=9k!KnxUOZ~$UPAOwL1Fo{Y0|NkFTkW>*Cpav!e zhWft{JNO0O<}W8|Vhgz;B@Tpa1_iFd%R41uNZ1*Iu+pWa8|YCS!%mOj2Ch~l9OL&^&8i#mO`boKZ)TE#0R?3V zBZlk?SOGg(QK@jXsXwznBBEdZ+8n)j>1;|^YF%)OIz@@LUV6mE#}&%hhMo Z&T|`aS98$#%d;kTXZI0t(?c)iyaD=keK-IB diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON.cur deleted file mode 100644 index cf1e32468d4af0ce5c1724ac5dad1e776a78934f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcma*hI}U0!AtI_GMJ)CFoB(BcCpI(8cX diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_MOVE.cur deleted file mode 100644 index 56a7b34a8900f283dffc5009a3695b4708cc8d9c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmaKmEe^s!5QX2iB$ZT=x~@cW18VRH4!{wRxRPK<5IqtC(K}!&I6!R$-N&2$C=%Z0 zo3}f&GrK?p2k$Xx_f$lOJUxy7r|zf?Z~6$ WJFodf!dR|u#^V%qk-6B4QhWhIqH}Nn diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_POLYGON_PLUS.cur deleted file mode 100644 index 59d276b2bc9dd0a2f1a2a15ec0b2051517d9174a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmaLRF%E)26olcoQcyx==-ATI8%V=FJc6YiCLX{eZDGMNEIa_Mg)sgLn3!M~^6e~d z31GG{XWrYGy))ag+rguPvEB_9Ij3B-$T#$*Hcuv6+CjndF~@!;T!(pPXe>q rJDv6|_t&7ImipnQmomhDsK)>`-6V8+maXoVDxu>W62#6>;(!JpJ^pi` diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_RAMP.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_RAMP.cur deleted file mode 100644 index 7481e83a69c7ff09c96bd1c4dd3bd8b92b4c7b7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmbu(u?>ST5QX9AP+XZVN{7poYyhKV1j>{d4Jk#|K*|Diq2lE?L}CEm={w&wwxyGj za@LwANf)LYGCCw`&Hvbzz1!ZG15dM~l|6^u9VZu=^d0WZd(Yu_Yb;{(=aFzmQK`w3B zJ#db3Bn{AurI0vmBLrDkXPML$bM!GnQ~bkM?aiK!StTU&RZ5duxxxfXvyxfK&XL^? Zr?^ket|-=MeUKMTmeQNq1vfm<)C-}BdTjsz diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_Scorch.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_Scorch.cur deleted file mode 100644 index 22e68ac9e43d79d15fbb74353561ce6474edc7f2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmaKmEe^s!5QX1%19j98Qb%P40*PynfkdM!Nf7i3+=zq=V7LG`z#$0BHw&98n9a9u z=jTmU%H&j4im`Okj8_d6wBR@~zVb`;*+YliOb8k1J(;E#Iy+?iU(q z8rAYxr*CsMU*aqAcdXcf=>}Rz!5{v|op#@Zmx{((!3J<0Q J%%On;ya5xcZ(;xd diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER.cur deleted file mode 100644 index e7737ebe01bd6f53985d71e779dd881414eef941..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmb7;F%H5o5Cqq_NJ)p%;gZr)9ze=GgC|giiY8JXMvLTM@Cw8-1W*b@kv)y?R(q09 zS}7T*Xwr8_siYyO<)OAwM(jQ-w*W^dmdwBH&wD1)-EZ5zB f^e4M%>~XZO<;UO1FXWNDD#ejsDpj~@Bkjc5-S@LOe{Q;sID7*qhPG0Cmu3uk_t~F^-r*>Lrje>j z%JaWDqtEE~T(80V4odile?UE4AT@iP&4$SAsnLD*=b`U$G;pmxm=%Rt+nU|FpZuV| T(kJw3*IB}te`O9!Si=$C8o71G diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WATER_PLUS.cur deleted file mode 100644 index 5f4f58e21749a911c6e921d5190f817ff737b066..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmb7;F%H5o5Cqq_NJ)p%;gZr)9ze=GgC|giiY8K?ML~TEiChaE2!qwRQRc diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WAYPOINT.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/IDC_WAYPOINT.cur deleted file mode 100644 index 1dff6479c174e5077ec7114f8310e8cda5d3d70b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcma*hF$%&!5QX8l31TBy2x67p($X84!h?8(lp=zPNAn^pIe?ZH!ST;ZAQA*;`DS)! zrx+=dQwU12a?+gJ5&5Jf-ej8rB^Nab)0k7S4CcIH?)j%99uZ^O_rj58J%`or%3*(E@jAE{HX zl%gEZUb?_BF7vUI&If6vmWV6S=}4B0d$(aU>6k4`S?#@rd>hpr$hT(BKc)Af8`IgUjHrWmWCt;dU^>LF<_b}8UXA33>u@It7;p*j_ Q1M6~LpRoH9zWW2b04>u2iU0rr diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/IDI_Show.ico b/GeneralsMD/Code/Tools/WorldBuilder/res/IDI_Show.ico deleted file mode 100644 index 14833fcd4ef2d1cca89f634eef58dcc594a1f5e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmeH`JraU26oi*(L1j2XDu-iu7B3;4>EKv7j%7N_=l5Xf7{;-&(1o{ed7I&HHd3RY zlsY*cK|0gBZn^Fo>2#2KW{J8`jgGLCS-XvliIelvV5CYZbT@21W#)?F@R8FWKm7;D zz*pfp_v9yP&3Qp@Ba?9)GCemK`Bu(%K62g&?1bA5RmXdc&mp#EA(`c9HC-W`6r!n> V&z0-QduU*yXJg3(u)QP#0+fsB`Lpyk+Ruyh88>LM2Vl z4Lo`{){*6$@i4Qv{Me*HdQ#0Ls4gS>L^WbSk30O~S2mfw3G^$33@NYVC{Uxrj2(K6 BdEfv5 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/Toolbar.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/Toolbar.bmp deleted file mode 100644 index 61478f4f724bf6a32968e3d208104ecdc76ceb53..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4318 zcmb7`KW^kU7{!@*v6_Jk=NKssIK|e%0IqU}R7Oe`Ldd~30vtdBwn?|}E!;W4G<%Yq zVQ;Ycz4wV4Y3v}#HzQFZzrT-_fg%k_SsI zrLGJdY#R@?MO!AD7yIDW?7C8p(n&mobeHU3YYX%#-O9gSp2Nw z1aSC4&~sDro!+j{zwgVzp&K6Wc`{eylF4|utLRI#>>+$&hGD}VU#69Dz;)9LhAcyob_sYK>xw{tm{ZK-tv7AZ+ogf2bHd7z>+ zoJawep%w^J1;jsusp(Z)M%Oozfz+XQAfxP+RKo=y_EvYb8w&_m zXLm3s2;;jJ6u|WCFAVo*zV!VH7nNk^oj5Rzlj#4dtsu2iIq0AmsKl(Iea2-bOeJN= z@-{Bo!Bwpc&oZx-n>8-X8SyfFIUZ+RL=`HrF=LC+!3^a0zw&!fNn2cAUNk`|_!78? zD7aqu0z~&4TnHl2ov3D6xLmYs6GLL7@D|5S=;%@`w2{Ub=0-ic%DFy>ILIYmI0q@t zrNxwMO7x@4D=CO*=QCf}cAq{ABvntg3h7rr(1|HY5?nuZZgKgDV3cn)q;(`R+e4qb z!$JEC$8@*FMZww;IHJr&Rhza>;!8E#wcr{uXgYoFfeqo5)&S$6%UifWmz}g2UBpn! zXDK3#P9nQq_LmF3xTqB_UPM@wt2_PVdV3zdAkQ0Ij9&2N{+|6svc&~2N+R;CoE|33 zrll6`F9O+9+x8a~;sVaN5Q@$TwSo36zQDbxOV+cnKus4?2bh^J0p6UR!pL)=VF<~E zg+?S)__M{FaY^|kZR>e|vGs~C-p?53oIaHNDDRJ5I!#lY)65L!>J3~dMMUAnEn{xy z^GI1}cVXCj48yN*2~H2$r}ArDL>KX8D_NUpbg`1;-We@?c{)BFkH;r#EcI%RSc1l7 zE}-!xKX)dKe45G%$P&Ai2d|^#0&@56aNu0}ppfuo`F@G@v&Mxb6nO`6w4`)G`TNEB z$^{doOHpL&(4I~3GSW2<%IS^o7j0Dym#~#V%)0!sk`#dqczCjZ#>Iirm{OQ%gNMqnen6R=VU1&g?UT>Hb3S^ty`49^y}FP5EW+ihhQ8`aq_OBcTIBi^`wLo;Cbj#7mz{b7m(}Pt zrFl}%7A&ySs)YM2Hg-LfqX}vf?Z5At50~3=5Dza1FsNXwcy9 z(gH(yEq9^%oV>@|&t< zaIn%*Lqk53lH&M$8LW(pOH#GM%V0i*h(fS3DNYE!2v&EHh+x^z>!9M?{-;6K{qsC= zF&HNNlQuv2-~;jHm+i!;;lsq>0e!{ipMESHY@NjRtw+W8*Ix)c`dQQ;y(!jIZWKwu zfnreKKB6rbcgeEN;?fg{+H_5Smsbo&)CyL_uC&P)<>!~BG)j+S_%#oMB? ze7(5vJH-B=f zioOE}3T#>@9%UtpyG!!K#eI84?a9kx-;#x5gT9tnIC;ECA2UcqjOrs4WBLfsF@uHc zuz@1e(nNgoMLW^8TQ`C7h2jSLyB6vruEqt6I+a4~Sx_V@!n{OsY`h4}E*0LH#lj;l zUD$Yd3U6agvDDR4eEa!lqRnTYiJw+fimUNaq}f-T2=ov&Cc0v+m4V2#GZD^Val#^{ zOqj*w3)6rYVdxSdq7;E*b4I*)|Gjs`p`2`SS*Z{Q{oKUfAP=$L!%9>I+KaTp`NA)E ziEvHG7M6-=Vdkk6E?$9RQDUrE8WSpJ7#WE>1$m-Y;V-J4?8IVYEs$k#1`(;w`5OrL~Rlaqtk%7M5b{fIi|~^86>CeJZ}-+`rqp)nE4f zf4cMj53Hv?6Si&Nu~X9i2LJJ#-neP=mg=oF>I_j)xqL;{%2lh^tX;QWmMJMMo4;V; zqQ&J)mM&v5Giy$E&fMI*{DQ)HMa4qI#Ky%ZBqk-Nq^6~3%ohFufr_ADWk_gPctm8B zD%#$`(aG7x)y>_*)63h(*U#9*)NH!>3=7MdRaZ0#mZ)|jHHr9D+gS5JSMfuWHY zGIZGR5hF*99y4~__z4qv$#n10vsdpvef#wvFmTXd67bd6-?absyAB;Yb?(ADg163x zAAQ{RlTSbUyxkYPU*ve+Y1yjvyYIDmU%pjmh&SKjk)%$jWP$%M$hz{J?Z7yJvGG1q z@h<%PpyFM`H@th)4}S9NfAKzI{eKqJS5REj+oUAtIPIjQgx49Z)UWxWYRE`TN^p(S zW&z$t46S%iX*;UZDw$?}Q;@Hf%A^EsS9Mk*3-H2oO=w6aCHV@G$Ttbv>esviWm=gS zoG5c;5Q6t%V$$pSNr_A+B_$@g#x=Z760L$+{&hl@m+4^EQDAi>pDCDW})4uhmvCL3<{;9w3)rB1TT zmr=64*RPqGD2MPzk~vLfUsq{*NNOGn@!<|3-jY#8cKiP`HufX?lzsOQ&H20)Q)J^7 z>c@ZStMVmHlgp@x%`shRP@y8#DwrxKapM3JM`1F&u;t@4gkCI(879J9iXayLJ}cyLS^kdi7xJDSGwp zDS9*ZXB^Bpl5t$`9zv^EcVW=8o0!p~tFU2oVsz`?S$KBuB7C}a5&qpei$KPp9-T!< zk1is-cNY=ex4TH{-&3Ry>MgQ{_7&N~`iZ%t28jHzgG9l&A!6Qyp`v)w2vIV5geaOk zQsirl7IPTW7!#+A7OKgkML1)~q|qX1;wTX?VU+M2KT7zHA1%Dbj}dMY#tMf?6NI(K zWHC!~im;xlEv)tQgv~SqVPjw@YPGn5u_e{ndBOOs_GF6nAXp2QATB3q?^ID^+V!f%J*f8BtY@BH(*3FtB zs%)%8g{_q+x3d-t7)$JJM82b)$aZoNX>Lv;-rZS5dbo-(4>zH7cNc-~p2Ek?OL)3^ z3l|q3Vdvz-``TMfxAzvt_Flrk&QlmV`Uztfg)nsw5$0ZzVuoLwunbHVGlNsbtk5(u zD`K{=ivqL@fgs0tHv!<8aCELdcR28o=IKrvStAm#=8iTOdkqCC)B ztPb!LoBce*b{}W4&&xp^_OcZx7*G4!i~0a(agH+68KsXn9qK1ega?Qt5eiWo6Cw`9 zg^S|}k)l2+N}NkkiL+_Z;%r8YIF*?oE-+r6lO(QYr;3}o8RB;SY;m_BQ`{)Z7FSAh z#g(!GacxnNxL#f&ZY(JiH!2p2n^jB1&DE9S;<{Dh)cUpJ058@pYqyBiYqpB2)it7G z&2F(|&3>_D{b8|m<1tZDeL}3>ep0O8c}i^Bby95Gb5iWxcT61Ie^k^RI3i9RJS^%N z&m2A~&Kx-|P8~ZfPS%|jr%zoLC(qmvhfm)YJ5SsZTTk20 zsxQA1HCKNY+iw0Uw%`6u?7aKC*nR(ZvFE|>V*i8R#G(7YildCjAO5D6kxo7SU7UIH zt2oPe{)eB%r5|32t3UiCZZh6rZ251577d~Gho86qw*A*_-*5FgqoL~S#Fx{Q3LAx$ zWk{HEM)$VON~piSZyM~9|sU_DDQBO)Rq zbYWoo*9GL`+v4gaKIIc8IoJ&uJZq|1R77~l{6*>l>iQk>*DZB+_8vaeVbb7%vviCj z!Xv|!B_&_6rhMPFaP87%E=$*W`xY&BP~^->O$;Lm3+I)SO8I{J?zQ{YFI(p|ew5!N ztGML&=;%mQWbne$>Y3{I9S(1=SnoP^nalWz-iqYJ)a2-B%0=M|7Zg>0ChG_9UG2Hv z)peE2xRFbWGty?K#zn`(M90oAE!kzo_pJ(QmRHuST6bXc=5>4Wj#Ko?&Pq*9j1QS# zQZSG2-`~G~`>uU!Dy!XG$1I(oNJ+^`O-W%Nk--a!cE8uMW#>bCR#t6vci-ghHg28s zsL=Gxl+={u*tpp6`HR+n*|O!do!eHftXaN%vxlqO`as)=)Y+*S8Ci)5@nJ#so?TnE zG}>9Sa`o zsIA5K)*Rovmk;65FSRw>_pe@AvwxZAI&a5`i*07vSQ*UFv1l#l_wud#PcLt(+PQrB z?xQXvyhaTj2$0{QQ@Tw;vvH8L@Qa(4h_khRo`#r)&P6 zeBYw*_ZQE8{_W?VUOapBtiHP1$I;J!vaOAlg+;f9^>26d_h(OE{q*yz$KOA{TUYHg zq1=9Q;H;UJhU8IMzeVTsFYY~k`t*7Io%6>}*5^Aco;=w`%gRtPx%zzz)0;2uKe&JM z$k7X@PS@AvHJ5s4`KSAmIM?Oc^nBO#5_1i!4sbaV`REXnZG~~;! zUy>yLr_vS2b(8t(5cLzygmNjho7!QSM5-D}4w?BHR8Q39nHvl!*>6+6v?H?ZC~i8L z&ymF?X=rL_I=;?-nG_}Sm2!!x=V)ti9%Om0OmHx$VI?^><+o(xFV!Udv5sB@W#AnK)@I(5Eg9Qh*7mDwUOO47seCdILE9BW82WkbxC8WruJY=lhb zs8Z+4Y=$T!r*KPL#uIY+e0^^Y)Unq$abmb@^;X#g1J| zLYrp`(L&Z>^MA=^A*#2^KehemivOdOoET}Q{z(@6PKc}W*^+0Me7^O^Qzg^1Q~dYy z-cU@$uc-%j>fDLCZZ9!tV1F@k*bp&( z^hhyrSCVYks z65fOR3s2hr-TUS6NiaB>ciPuqeO=GXpua1oQTz#D5CUetJTvGp|phu8|sK)>Z!qI z1|npJp@^UjJle`k#9Nt&)R{(N&I|*QZ>}#&rcV_MOf^Nh(G*cRO+&2G*ASZwv_y@u zuGnF!FZND15VbRm#G#oc;voG7`)sC*9riQC7Dr35&UvP&a-Ag>J6Ve|M;kHE!CK@x zQ>UdZd5)Kp$o6#;+5R3PJHT7a4)hhNiU5%q6e!|?6e2n(NJRPvh%g@?q4e|+N;ek~ z?CLBOE>6PN$x(PZI0!d8N8x1aC~R$=U{c>?{!%A_3@#MOd;^4Y<;voGy$Es`8y6D+$ zJ4OAD-Qvvded5&K1L9omL2>DDow#-4gt&eBl(>ENthjOMinw+Crnr0ip1AwqvAFa7 zGjZ$jOL6nr&*H|5U&YlIzljUae-ri3eiL;+{w@wb{aqZQj$2E8_rN{IyNuM0_g{S_ z_FVdjKB$*s`?;UQhWb}x?P)$wJr|o#d@t4?eJIw}-Vw|9+!RZ8ToX&SUJ~Wimqe@o zB)pc!n;xw{YTf$drc~pX#+Dn?4bP9i`nr9m&Ye3cJGKA%s}EZL>7}|x^PG>q_$Dww zXR4pJmbM}=C@4Uu{TClJe=jREOMeyQTj{8)G1D=y*8hs#?p-waUoIXz|#wqej^44;?DY z_vsQ77pDvg^!2H%>fBJFp?sSTWoxV#TeE!C@KGa&*i9HZVrVblSd~f@9UH0)^!4^w zTGe2GXej?>`R-ZPRmR3PRR>p9RjoL=%*Dkuw zMY`#8GE#HqMzVZtOjwxG+ugOYa*@mH@}Y-zZ(C=z-)j1Fll{gmxp%`l%YDz>3iIX_=N9DU=H(@)CdGMq zxK}J&u&lK#|K*X*2lpI4QZI=*Xks#U%rr9EB=Esr2^nSh}#iEMHo;ec#57 z8*42#TACj*pKfM0=Ahx2vEEtPg(+ECvr|$@zbZc3+snnKDuCrbD&4dF;O0%6YArWz zv^YA$V!EmEAtwX9q|BUxwCt?e8M%om$;ljnmy?0D(+6z7Y#+;S-h61&rj3?IEiI>4 zm7KP7bsMjhk(ZW~l{Kd@V|GGRK;J2objKU$u>E&W?%lp`)8@@bs(0?$bNR^8ix19S zu042Y|H6}}OUjDp<&}A*26ms)uWv7ni3X1EwrchM$vwO3j?~p%K6+$N&9QCg9)G`} z)@01+(Sr@_1`QoFaH3wX$=Xx=G&MD~Cr#5~`8KC79IM-2z4_>tE!C$U{P4r~56g~B zH!&VF+}3vRkU;|`PU_dcf4}bi`u3bMMOQ(3+MPaFU0c0n%dsOzpFF(t!?um<&1bQu^l{k@BqDu{aChpzkWTt_0$jikmL2L+g`hK`{^f-Zd|{8=l(uR3)6iwO^j_v z+qlNgiS6k&c>tU5(XU_k?mhIrmGd83w`0$-UtT`GT2sCC(%m07&M@0;Wnx>BTW&wR z*PsCo0|yM~r_sA#-)=p6=zcBBe_Ow6d;QCoKh$lmuGv#}WZSOO*Pc8(v}omlDuZd` zMpX9f-Dkj*e*OA&>(ygwJ6XQ%sk&oVpFFvL{phiyN6zlqvupd|+O>poRWQ@h&~?e}E)FH0}gU3~H4$*mf$G8fF!^3bc*Hbz6L#ts=Wc! z?$@tJ_wJe<+sg7SzNxSK`Ps|I_b=CM-Fj^6rj6@Qys|bi9=&Mn$dSV)*bf>ya7y>y zy}S18uEldvmVdYW(zB;8f4Fz&{`IFfE}Xym^NZ7_vixY4x7TNR-QK-=bnU6}ZR39b z>cX?N&2)%;GHjMU}d`}*9ydyk(yym$ZZ zy*rN{J$`!Y)z7~!JY;AvZQ9ZadXtG&y&H@@@bJ;Ydry9P z@$&Jnzy4NyQh)4td;1X+C+YU=uGy_i!zG|@pY@clp8WXo$%7X^JbZHU{I8c!o&;VM zSB_huKVhQdBr>Sx>szL={Cnlko^YHmUp~EYYGLV#vfqFE?H8UAWgfb^&XcuuwAIG4 zKj>-EqMgsxTTh=odG+erxf2&|&^q_aFDNdXziioj4<{$ZSB(a+#`amY{i&xfe>o5Q zQiNa6l@+3>u%NgwH`h^Dr`ZM8tbB{Fmb`lY47mF9jXO850EPJl#Y_1^P~moHzxc^$u%EGVm5QNAqrt0sG!x_IMFrmo(){gPAXU;T3W>Xl0u zPo6$f?$z-Nb$;WAys!UMp~WX(bo80Oq;!7S0xz$Q-+cHt^1xqfv}pZa+t1s5-u8nA zlX_#*4aBHB_^*64>PwCK(^aV;{kNX_|5_j4A?LA~o_|%Q|B0UZ5npv+d_(<7tU?PW z{wB~58^vr1ert-v$$&T+eDOs)5GT`=-&p2#9qGgUQ(fY3K>Q7ezX9<#ApQo#-+=fV z5P$QhcAD2E&IiQ#fH)rz=L6z=K%5VV^8s-_AkGKG`G7bd5a;u!b|g*26@j=S5LX1^ zia=Zuh${kdMIf#S#1(?crlvNCp#m{fAchLWP=OdK5JLrGs6Y%Ah@k>8R3L^5#8814DiA}Zu21|H zh~EP7TOfW5#BYK4EfBv2;1>(0r{1}KI1My=ZehkEq zf%q{HKL+B*K>Qep9|Q4YAbt$QkAe6x5I+Xu$3XlVh+hNoYao6N#IJ$)H4wiB;@3d@ z8i-#5@oOM{4aBd3_%#r}2IAL1{2Yj%1Mzbpeh$RXf%rL&B>=?Ff%rKPKL_IHK>Qqt zp9Ar8Abt+S&#C8t*gX)t2V(a?>>h~S1F?G`b`Qkvf!I9|y9Z+TK-f|$Xk`jUT$Qv`8}AWjj)DS|jf z5T^*@6hWLKh*Jb{iXcuA#3}x%uB=a7B#4UyagiV{62wJDjn{RkRWQr$N@0_OK3&6BrxM8I?SE{`U_Ot<{E+Xfe@|QG&`e7%d1?vHkGlj}`6O zwM*{WrAv0NZe5pl@6x%XbBFJeKmVky;=}jbc+hrd!LkO7qZs8h$TmJ@lx@nk|5+H% z7g3B`8ILlaVZ6oo?DO{RF>%r)DBRr<@8pPBD@(+?Iw90#8UkmS!Qa&b9(Jw>a(0CW z&(^79hN0ajAHQPVM~s&kWm|g~W!th3+1Fo#%t!Os>cbCVW@3yv-d-r;8JuftgE;Q7 zXzrC*b29{t8VVowGRBQTHv3J}nTm-1{Se%z7ov2v;6HXKoOF$0VdV!02Y)!*c*Ea40GXj7C=B*N zzpfpd(;)kjeKrQkA99V*gXix0>}>1~QDO`GT*Q7BXltU<(H>bmCsX?OL5_hQk~JnE zq<0qt_UnXj15Nl%)qu6WIcyw);N%vBSyt}wa`Zy5moM@;mWpU4x_|d|BMq`I*=J*r zJbLN9Pd-6OYAR|u*VP{G*x>Al<;Dis=;MhkkzrV3JrfITEKwB~g;IZ4CA(+Qa683NnTG|cjg zfR42*bY?oh%FP$1lr5|s*}tD3;sX7V6RyOzImrmNG?M+xeIfg745K>q>h{StfZV#?e2tSraG9XIRaTz`eLb{72>>X;1r$!gTQ3CMW?|jBpO;) z&d``{i|LLYFt&Ar&J26FI(s5f5rAxEAQr@iW9ytmeEs<+a&OA>p)nXlC=_^DQjB8( ze%Le15_M55tFMi9TH~>s{8M2x38hnqAbWC8EDv@-Y)m|y=dQwxxB|GR6u>Qh4yL*( zF~!as)0})^?Cc9oTW^?iA4CTQBQHFJJRO2vh1m$VF_&{7&!~pLGi&RdEZj;?M4g8# zj=DMF{G474FE>9gR3AE7(LN!73^PKAB}O zR^`GtA`6yLS+EOE>!-lx^|)P9 zfU~~tsONfL^^JanBE(Dw-A8Ys9Y{h=|M@94P&_{BjE1pf(S1sWY`*DwZjYy>)j){v3~kvT!#w z8P|P1a6Q}~_sZttT6`d`rUc@_n)%!pDx6(fgq_FF z;>qeNe804eaULG8CqHC|<3>gVZf#kK1N#nP<4vIAA?3NU6l^lk#j>%ZQ8c(e78p!L zp@}vk2Y-jKK^+l2c`#y(C&F)hANXnxhl2N{`=qh(pQZ)nbOU5t7-2-;UP~MMH#axW z#_E;$VNNC8m@=izd3G7et+9`%$TkDkAYL*&stvlDPCBM8-&#;BOU{)Z37 zB13%?^85|wJrmTS9aQ8I<%FSd?(`L$dUl1^=+Ut6+!1br1|o1G%d%$({DEN#RhG;V*(4X1F z|8KQyX?tz&9$@QQT)+AQwp|6z-~SEIR+r=P>?C}josJ)Oc3VAQirfgEi`zB$kHlnE;#BrX&DZ}{i?)ES;gdguxAIeN`z4exD zNut_lr|;&eZ_N-SlvDMJ~2(-iQ@E zgXRzIkJa`L$Q?Zri9Na@itC(186~jecL<;^5y5`F`}Bs}(7|vUI|jj8Q!sJl@IRe@ z>|f)H_TS*ruKhTAjylFAVAo^nEaW@lDsk+_bJX8{grkS{VMpBstiJLycCN3$a+A?0 z8`g_@r7Pxg-c$PYM8bf6$f0Z&+@%wg{rVu1^WaVWz>_@SMg7EenjTtGKa_no8^4rs zpJk_|;O-;f828vA>N+F?*BH+~1?ox9De~muJHKJi)#o^L;|bQ+)?s5&BKFOVN4fP3 z6qy>J*lrez+?^4xIRQyCOc2Yt4xBOxKHMX|({wSOJRtjGlzlb^DGS{C;>*uay?#4x zzXT56Cp&Nr&in?PrtU@631>*hZt8@?G`VrCi-y{`itlQ63tL`62d5&>eyV!?B37 z)JKrcScLGrv!aan5#=lPBctp~_SqPuEGT7u^?MT|ebk?OfHU`~f|D2bQUR?#^8)9t zJw)xM<=DEW3P<*A$C9nbkhA?7)*iZyoMoF(SW=4e`MF3_*dZg_53$ach;y}u`%H6u z*Xd7st?aA0{P~aacjxc0b~W{H?#2D5e#MSGm#}5`HB|4ph_Ve=u>Hg%Y~E3eoV6FR zp!x#BN)ID<#cpKITZF`v*~kd;Lz254tW1p1=EIK~$KCk+tNbnJA*ylwjn6MWZ;Ony zbQ~x1ow)+6+w}vk)ZfD|*T@*pf2L{mDpst!h^+GCh?%nnWyOn891})4D+I~DZqT4j z;ElK6Y3#H4Q}*@OFrFDQU()s`{i}1w_J|4(#g3W-xLki5H@PdwzRt`=toJ`oT8aM z%hGbGsewTWaURK?I(1YK7b0aE3&#IM|75lQ`GLpF|MK6l{DIr)pq>C#*Z=wR@V}@> z$!oL{tNBgpgN-~VbtB1lQb&>Zgybh%M#*3D-j@3$`HeT<%zpoa4@$%vZ!G2al8-+8 zAY10YelN?(^0thPJSp3fZOXP~ACkXipR#Ys^OBb4dO4GS8)O@@uQiNvze;^t?pdi< z%ClYWJ9)>vVnkz<=g@#5LojIQP)r;@9;U{|m_@sRx$ab$>*>PU+#DwQy3iay24ja0 z!SI3o(1v&A8*enVA={Jf%JyYHjkXopx1>SRB59JeHP`Q$Yzi`8)@`EeUwwa%_V#Z& zcEniPI(=w^iJ;vhVwM%6XcLK{Z98PT34+ZG5om4r5@ou0Jky1BSOMO#81?HO}Oe}fD2_2iPYcnWF7Pwbfvc4xENp@?%Pt6Rt^u%~Yi#*P69(C6&K2rt{#60rP9AhIy^zBXh z2Ox9^b-liwkzhR?!D9!(lX{7R9?w??B|N<&;o+?$4|&4X)(gJQ-U#;eMwl<{a$MJq zi4mBoJ*kPFX0-iPPL}tDJag4$TefNi4LyBqnO}w-qrX+%ke&!1)f*vWyVG9K8!=w4@O1HmnPVsn z-4kK#9t%rnC7eA2VZ?LE*2WD!q+dyYnTmZThlXKULJT$~g~M=yTDNIF4oPcsJwx7k zO=o|X-o25ZmWHF$ySC8Qx{h}JJuxaQ)1HFm)R(F(%uqu+)Sr|1{3;Yg#4EjX~bq^6tY2ZQH_|{)pqbbFqiK zUgP43Bk5_luwprmWX;AQ+OoDw-)GJoY$okxT9Z&Xc`W9P8G`t}9kGOaFIj6aB8Gj1 z5dD#G^AE>V&qTO}CBeo&0$Q`&p{us%I?|@=2uGhFSa4k|9NgjV;e+siK&VK2B5k{K zXcsAqjlhoC@yPOVLhF`IGQXr%(%cy2eJ1a33>h;9n@R6&(pz6#gyW>QzIYyX`}<(6 z{#2~envC)hL$E7?XOV>|iY5%lJgrg4)gFP=u|2RRiT+E&A&4>Rk3jBk>)0Y_IfcL@ zG!|~*@z9|iR@c@Ynilq$LOZavJAHh%uFy2Ifw7enyxqJIO*^}^ji)O7xDOOq6c>U0 zbCaPtVo>86NLriU!BT#D_2xS*F~77F_cw09McRz_aPGI#rgAJH7TavBu*K8}n`pOO zF?k#gr6;3ux<2Ml9fK0xF~~O=@Bhz7@Tn1~}OlO8B!#^n-feGof zA^Sj=_ET-n{ZvbP`iK2t<>C!(jzxc_6YmAeBD8&`hXko@+w;N{D2xooM(NL_uUpQs zq?J+9+!&-B2@{?-rxq{5Me_ZzFeMJq-n`3d2F}jS#t!oQcFHov@KFo+NhE+l#rpM&LBRLO28HLdE2!WA%5OjI& z>)3g~oW7V@UJ7Vhxni1wH_Y4u;N?jjm3HYI(ojUbtxQGxH0SG3(Hv;~u?BzG$tlN5 z9i9k3)F;H@3h6zr2*6=?7aXv*#D)C1*lDJR?Pj{zY^;HmQ-+}~ClwVsqp{Rr9Lmim zVv&UgicQC$cK#fc#_;^xv=hpLW$NghQi#y3BE;q`!1Rz5m?@KC;1dN6`qXq?>C^EG z!z5cDO!MH`#5jvK@A#&Xs4O@;61gxXVEzMeA>2nuMIYo zmEn4H6s{KJ;TU=6u&osi(XVs4xDZDa9ypyDhqLpuaAt8XezLrCU4#N;nP)SP(;%Pd5AW&u*? z&g0&QgL8NytQ9e^^x}_>f~c$W9?Rk$mi~d_mamTaacH)b zs|hOH$jw5%n5H3L(YRHdid&^=cyZwr?pEaD?&=a; zId%}oiK98Qe;0l{eG+Hq72@>#1vs&A0S@P7V|)H=Y+ADl8@Fyl-r}XGTvdw9rE8E` zvKX^-3z1h^h9JtfUa?8=C6Blp_J^P06xeld5BI^{5jJ@cBDud3Xge-3Bd*8Q9&f(& zR+FFV?bfZAZl}EPDmxSR(^K$c^(K5@xd@M|*D|ic%L^y*Xn8RnRukG;G1Vc8wplxbUETb7P0`j=e z!fY+^R*ScqbYT8qyJYW7-)8To--(7^`lW*LcwPY>M26yf>9Y&=zz^$}L&-pT~v16))*eBmIuuy26=09uKAiG$umHaisI? z4&1Vlg?;)-~yo(z@ zJ_e^9^^6w_GH}tx0;eseqn3Kj<-9!Xrk=Bob6-VY=ptKNaynW#AmIjC5 z5_mcXz?*bsP>&9w-NCCzXL$AL2Dh%A=$D%aZ~9}LdUkK1pV$`PiR0AvjC9JA`ox$> zn$?@P;Umh(!h(*OYCKCyz|)*`JX~9W?fY(H1$`worAIjH;f&L4_kgYrF45PygBZ{?nv=1_#~RrS=OZ?`0F}vUDB=7^4IPGX+UY`j zbbJNNAa_sNs!YaNL|;`tJ1m}2;l zfs+2HX7npY5=ZrT#}52V+4FH?IPTDoQblz6vQy*}`kY?u+k%IIE_kR4;@$|vqlIaB zyl*A0S5VGK3B#qd1RSH!>E``&sJ;CY_MX3i-75>QH8T*aLmhB%ULMv`CN3fm=h5Fa zhd!rxxyO~kh@kH?n0kIdzrOI|7{X}BaPQR<&eZ#zI5u~#hX-u~L0pFj;<w!Ngk z`TgtBhI$u&UO^|}CcN0N9M7*_P-7$y(kDi@1YX_0jptR1@oaeoo-SL8C&bY_-?a;O zGgEPQP8P1GB;g!otXs?Sh_RWA1EIv%WYV9UM*3;fIYPZ+9c9|Z+{X)O`zm#?N3P`z zRI%>tnHHGMyfnrH+91V9ZZ8cC|9*64Vmr)tufhy-ISUQVm9(kok6@`4Re-iD4aoxM9{juR)JEMTMBHu4Q zhd=qom(ibgmryNDxN{v`rGIwp7`RQG01wW+g0=$_y{Y)*qYvf$+cx7Lwf-`A)F|B9 zS%XK_HK;v&7ke%M>p6xUcN_NV-SdZVe?IX%IWD-9<$$L<7vWlh1I`Cn;Y`2`9Emi> ziRy*eeflcac$s3g&SWg(J}x3(>?P(bf6OS%9y9={jPX2^()cc)>mhx*A*5SDeu<`S zCWQ7F?}7c{F_^x7EiJf^&wOYL^D{MS^XKSmm1k!C_rKx7tw*T6@)YOqKE}B-^l=^DNB=bajb|QWIsJmiYPVv8?QpEt z9)pU><1vr+@_po!ywSsv$-S4(y&1=|rGR#gOxhVkdvr%Q>6MtdM5~zy7&rhvLk7ch z)JV8f*0(-AK!s126SP?b@i!8^XU}zWOJJOIj zpeNFKA0_qc2^H_AdBhgPay;R*jfD2+{VQ!q=BDuFedkR&ym$w?aNa%0L#`%<;P0>- zX_vG%*WaZrLT!I&`{^fyM=!-A(tPAL`JU(gQSRT9g!ghN;8BX3{PhUQ#_1n;u0Hvl zKIz|Zo;Z+W*Pr0XrTe)0=p||hEZ%kT4tCYmVgJG?oU2)n72eKRP8?4;ZMns^GqI^? z9&)Ll&at*YDrMOW+P;!$Qx7GcNx>Mv^>HJv#FO&6Huo=o;?YRIq_w&IMB0MX_Mf-k zejCF_3`Om(eYnhX^E~kaM>*G<$UM6!Bk+eZILqgi-+>E!-XUKdp&wnwy&UiUYd?a2 z9|{{z-^Z#Gcd_z79X2mipsp$(WtPNw5vNpWu8aJc(@;qnB}H!nQjN5cpr?V^-tLH) zrj20UX9{Apyp8qYMIFhA_ra&c&6CE)C~0kOzmm4NCi|N#H<`GglP7MYjx?R(IM!bz z#)u1Wob*Zz!~ycqKCa0*j^XI7U$Oq&bCi?cN>BcVQ+HpY^6(8TJ8&7rJI^40!w&4- zwi-E3lW21vhD`mwC~`GLvHMKKPwa)+7n>Ux&P+7 z?;7cDd`eoI+Yi5Fy2<`2>6dX9?~1yU_i%!A?<4(7jx?O5CrJAm$`lnG*M9QRiQBJG zy>1OQ>^MLS!vpY-31Rt~^;o%X6Be!Ch2rYts6KrYS(WQBPvwXl%i*X@@WUK?eI%QV zLHx84n9cJz%1DD}{5U8r4dKrzksbDw#$oM>m8joZjuq7V=hvJ<#`deo z-F_MC4xUH)k{YBJEkR1=Tr8_thy;}%65NPYbv8zdpEE*Csq@d&M;L9@p2Vn(9yg9O zt8ERUTe1JnI@8iaeM>un6 zFOF@lz^>X;ID6wUw(~4qU;h;42Okkna~)f1>ruS677MDlk1G~q)skWqB?e<|d<1gx zi;)-+hImg0#CbZy)4>h{1`olzZQA^m?#A>Uj-k2#;$QlYSQe8g|81b$fAZ2VSbczN zP!p@oLSn@o+I}A4@Sfe+u)GWr#dRp%dr6B@_Fuo3s|uEB0>s}BWQLF zA`AAQVBscY#;2kn*d2umS7f`B_o;7B(bC4ppZ@8b`8(QW-e3K9%u?&a|E#<^U!K41 z+kZ{psRPOvEy3CPJGgw~7xh?rL+izJ0@dze^TzYUe09v*FxBbA)br(sy4Dvqvm-IJ(FMa2e>ElgJ zjwi%+GkNJ0PS)Kap7SO#gr{-y!d<*Lc@}pM9>>`ur?GAMCdx)zu!k~VIc3)9@CX>1 zn4weGZvS?lulxUJ{%gKgk3s6ia(yI^$$cXCx;(FBJ$Y})yH71^@QJpRyE}CJ4$~;p z`xBpAR9J}gq*N?fyaWs9@i$e(LzmL-7em=Ul(POb`U8iK9M!Nl-)K5pWP7q**}m*Y z_9uN@vTsR)q(#ysX=^SwF!{GZ?gzQ2Fix Teams to correct this." -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_BRUSH_TOOL "Draw the height on the height map.\nHeight Brush" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FEATHERTOOL "Smooths the height levels in the height map.\nSmooth Height" - ID_BIG_TILE_TOOL "Draws a Brush Options Size block of the current texture tile. \nLarge Tile" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_BRUSH_ADD_TOOL "Adds height to (raises) the height map.\nMound" - ID_BRUSH_SUBTRACT_TOOL "Removes height from (lowers) the height map.\nDig" - ID_TILE_TOOL "Draws the current texture tile.\nSingle Tile" - ID_TILE_FLOOD_FILL "Fills an area with the current texture. Hold SHIFT key to replace all occurrences of the texture under the tool.\nFlood Fill" - ID_AUTO_EDGE_OUT_TOOL "Auto edges the current texture area outward.\nAuto Edge Out" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EYEDROPPER_TOOL "Hot key ALT. Selects the foreground texture by picking on the texture in the edit windows.\nEyedropper" - ID_PLACE_OBJECT_TOOL "Places the current object in Object Selection panel. Drag to orient.\nPlace Object" - ID_POINTER_TOOL "Hot key CTRL. Selects and moves or rotates. Shift or drag select multiple objects.\nSelect and Move" - ID_BLEND_EDGE_TOOL "Blends a single tile edge. Right mouse uses foreground texture.\nBlend Single Edge" - ID_GROVE_TOOL "Click to place random foliage, drag to place foliage in a rectangular area.\nGrove" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_TEAM_EDIT "Edit teams.\nEdit Teams" - ID_LOCK_HORIZONTAL "Lock tool movement to 45 degree increment.\nLock Angle" - ID_LOCK_VERTICAL "Lock tool movement to up and down.\nLock Vertical" - ID_WAYPOINT_TOOL "Add and connect waypoints.\nWaypoint Tool" - ID_POLYGON_TOOL "Create and modify polygon trigger areas.\nPolygon Tool" - ID_BUILD_LIST_TOOL "Add/modify the build list.\nBuild List Tool" - ID_HAND_SCROLL_TOOL "Hot key space bar. Scrolls the map.\nScroll" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_ROAD_TOOL "Click and Drag to make Roads.\nRoad" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_MOLD_TOOL "Shapes the terrain using a 3D mesh.\nMesh Mold Tool" - ID_RULER_TOOL "Measure distance between two points. \nRuler Tool" - ID_SCRIPT_EDIT "Edit scripts.\nEdit Scripts" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_FENCE_TOOL "Places a row of objects. Drag then use shift to stretch.\nFence" - ID_WATER_TOOL "Add and modify water areas.\nWater Tool" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_SCORCH_TOOL "Add Scorchmarks to the map\nAdd Scorchmarks" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_EDIT_MAPSETTINGS "Edit Map Settings" - ID_EDIT_PICKROADS "Pick only roads" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_LAYERS_LIST "Show or hide the layers list\nToggle LayersList" -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_BORDERTOOL "Add and adjust borders.\nBorder Tool" - ID_VALIDATION_GENERATEMAPREPORT - "Generate a report about Map validity, possible problems, etc." - ID_VALIDATION_FIXTEAMS "Adjust all teams so that they're ""Execute Associated Action"" is false." -END - -STRINGTABLE DISCARDABLE -BEGIN - ID_VIEW_SHOW_SOUND_CIRCLES - "Show the minimum and maximum radii around objects with ambient sounds\nShow Sound Circles" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\WorldBuilder.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#include "afxprint.rc" // printing/print preview resources -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 b/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 deleted file mode 100644 index e5a81104a71..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilder.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// WORLDBUILDER.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilderDoc.ico b/GeneralsMD/Code/Tools/WorldBuilder/res/WorldBuilderDoc.ico deleted file mode 100644 index 2a1f1ae6ef15e51df8c39bc028bbfb2171822ba5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmcJNF;c@Y5JlGsgIpoERJdY%i*S@2!JS&si6f-)RXoFGDAfg5;z_dQBoi_)1DpI^ z{oS?KlD%25H@>BZ{KJV|_dD9_G1MV<{5a&-}7^W%4AM)k- zx&P*V(j}a@*Y~UhksXTAK!NRyiYN-8NMyKz<)2v9@tUao7A!g+SzkAcsHvdq6!0vQ z#-rA6>0BAr)4*u6Y57EdkamnXf Uh-a7VEuQ2KJb_2>o71HC3-%7w@Bjb+ diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/cross.cur b/GeneralsMD/Code/Tools/WorldBuilder/res/cross.cur deleted file mode 100644 index a200191b7d0984d8bfed67656378e41678a7b150..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 326 zcmZQzU}9ioP*7lCUIciyCJGB8G|}>L{TNa0ToN1Lzj+KHgissGz|FOmZ=@olwdb9V b>cd63BF25+xIe%!@}Dr(O_cH={5W|5sq`YJ diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/foldersc.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/foldersc.bmp deleted file mode 100644 index 495e5c9a1c4ed50f02daf72da8030363b82b8c6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmbVLK~BRk5Hx}Z^clQ>2XN;bTq|)vM7iYXs)roWDpJ2uA})Cjx#Wm^b7$60>biyq zrm^G6cDy?q=ke*`&M00n-($RBY%p$22n@F%MKs3XGEEb1n6Wg&FyPLB*UNa%6$XBM zME+lJpNQ{g#nxG(^=n*fh+36cyLA)M`ZbLD1OCv(ft33G@f{ru4hPaJB{DBv>=UskXL3;wg+xFxD diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/icon2.ico b/GeneralsMD/Code/Tools/WorldBuilder/res/icon2.ico deleted file mode 100644 index 0bec4909604bf535991a40bc25afeda549359e11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmeH_F%H5o5Ck^?DINF;u27!AlhV12pXTRKrlT}-=eSFOL_q} zGCW4<28Ynr^B`SL(#$MUcWTg?E@k!}BV*#^+=z};DFrs8`m0(^Q9L%X_Qy~E0W$Da zSk5i^k?J`w=woCujzgxM=*YKn&Ly|~qPn`+cIG@=Z. -*/ - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by WorldBuilder.rc -// -#define IDPREVIEWSOUND 3 -#define IDC_PREVIEWSOUND 3 -#define IDD_ABOUTBOX 100 -#define IDR_MAINFRAME 128 -#define IDR_MAPDOC 128 -#define IDC_BRUSH_CROSS 130 -#define IDD_Height 131 -#define IDD_CellWidth 132 -#define IDD_NewHeightMap 133 -#define IDS_SKELETON 134 -#define IDR_TOOLBAR1 134 -#define IDR_TOOLBAR2 136 -#define IDC_FLOOD_FILL_CURSOR 137 -#define IDC_FLOOD_FILL 137 -#define IDC_TILE_CURSOR 138 -#define IDC_AUTO_EDGE_OUT 139 -#define IDD_CELL_SLIDER 140 -#define IDD_HEIGHT_OPTIONS 141 -#define IDD_BRUSH_OPTIONS 142 -#define IDD_TERRAIN_MATERIAL 143 -#define IDD_MOUND_OPTIONS 144 -#define IDD_OBJECT_OPTIONS 145 -#define IDC_EYEDROPPER 146 -#define IDD_CONTOUR_OPTIONS 146 -#define IDC_PLACE_OBJECT 147 -#define IDD_TERRAIN_MODAL 147 -#define IDC_POINTER 148 -#define IDD_ROAD_OPTIONS 148 -#define IDC_BLEND_EDGE 149 -#define IDD_NO_OPTIONS 149 -#define IDC_GROVE 150 -#define IDD_FEATHER_OPTIONS 150 -#define IDD_MESHMOLD_OPTIONS 151 -#define IDC_HAND_SCROLL 152 -#define IDD_MACRO_TEXTURE 152 -#define IDC_ROAD 153 -#define IDD_WAYPOINT_OPTIONS 153 -#define IDC_ROTATE 154 -#define IDD_GLOBAL_LIGHT_OPTIONS 154 -#define IDC_MOVE_POINTER 155 -#define IDD_LIGHT_OPTIONS 155 -#define IDB_DownArrow 157 -#define IDI_Thumb 160 -#define IDC_MOLD_POINTER 161 -#define IDC_WAYPOINT 162 -#define IDC_POLYGON 163 -#define IDC_POLYGON_PLUS 164 -#define IDC_POLYGON_MOVE 165 -#define IDD_OPEN_MAP 166 -#define IDC_BUILD_LIST_TOOL 166 -#define IDD_SAVE_MAP 167 -#define IDD_MAPOBJECT_PROPS 168 -#define IDD_PROPEDIT 169 -#define IDD_PLAYERLIST 170 -#define IDD_BUILD_LIST_PANEL 171 -#define IDC_BUILD_ROTATE 172 -#define IDD_SHADOW_OPTIONS 172 -#define IDC_BUILD_POINTER 173 -#define IDC_BUILD_MOVE 174 -#define IDD_ScriptDialog 175 -#define IDD_DIALOG2 176 -#define IDD_ScriptTabWindow 177 -#define IDD_ScriptConditions 178 -#define IDD_ScriptActionsTrue 179 -#define IDD_ScriptActionsFalse 180 -#define IDD_ScriptProperties 181 -#define IDD_ScriptCondition 182 -#define IDD_EDIT_PARAMETER 184 -#define IDD_ScriptAction 185 -#define IDB_FOLDER 186 -#define IDD_EDIT_GROUP 187 -#define IDD_TEAMS_DIALOG 188 -#define IDD_EDIT_COORD_PARAMETER 189 -#define IDD_EDIT_OBJECT_PARAMETER 190 -#define IDD_TeamIdentity 191 -#define IDD_TeamReinforcement 192 -#define IDD_TeamBehavior 193 -#define IDD_EXPORT_SCRIPTS_OPTIONS 194 -#define IDD_GROVE_OPTIONS 195 -#define IDD_FENCE_OPTIONS 196 -#define IDC_FENCE 197 -#define IDD_BLEND_MATERIAL 197 -#define IDB_ROAD_CORNERS 199 -#define IDI_ICON1 200 -#define IDC_WATER_PLUS 202 -#define IDC_WATER_MOVE 203 -#define IDC_WATER 204 -#define IDD_ADDPLAYER 205 -#define IDC_CLIFF 207 -#define IDC_SCORCH 208 -#define IDD_PICKUNIT 210 -#define IDC_CURSOR1 211 -#define IDD_BASE_BUILDING_PROPS 211 -#define IDD_LOADING 212 -#define IDC_RAMP 213 -#define IDD_SCORCH_OPTIONS 214 -#define IDD_RAMP_OPTIONS 215 -#define IDD_LAYERSLIST 216 -#define IDI_Show 217 -#define IDI_Hide 218 -#define IDR_LAYERSLISTPOPUP 220 -#define IDD_MAP_SETTINGS 221 -#define IDD_REPLACEUNIT 222 -#define IDR_SCRIPTDIALOGPOPUP 223 -#define IDD_WATER_OPTIONS 223 -#define IDB_FOLDERSCRIPT 224 -#define IDD_CAMERA_OPTIONS 225 -#define IDD_CHANGE_TEAM_OWNER 226 -#define IDB_WORLDBUILDERSPLASH 228 -#define IDD_TeamGeneric 229 -#define IDD_IMPASSABLEOPTIONS 230 -#define IDD_EULA_AGREEMENT 231 -#define IDD_RULER_OPTIONS 232 -#define IDD_TeamObjectProperties 233 -#define IDI_Selected 234 -#define IDD_MAPOBJECT_PROPPAGE_GENERAL 235 -#define IDD_MAPOBJECT_PROPPAGE_LOGICAL 236 -#define IDD_MAPOBJECT_PROPPAGE_VISUAL 237 -#define IDD_MAPOBJECT_PROPPAGE_UPGRADES 238 -#define IDD_MAPOBJECT_PROPPAGE_SOUND 239 -#define IDC_HEIGHT_COMBO 1000 -#define IDC_CELL_WIDTH 1001 -#define IDC_INITIAL_HEIGHT 1002 -#define IDC_Y_SIXE 1003 -#define IDC_Y_SIZE 1003 -#define IDC_HEIGHT_SNAP 1004 -#define IDC_BORDER_SIZE 1004 -#define IDC_HEIGHT_EDIT 1005 -#define IDC_SLIDER 1006 -#define IDC_RADIUS_EDIT 1007 -#define IDC_X_SIZE 1008 -#define IDC_SLIDER2 1009 -#define IDC_FEATHER_EDIT 1010 -#define IDC_BUTTON1 1011 -#define IDC_TOP_LEFT 1011 -#define IDC_GlobalLightingReset 1011 -#define IDC_UNIT_TYPE1_BUTTON 1011 -#define IDC_CHANGE_NAME 1011 -#define IDC_COPYTEAM 1011 -#define IDC_RO_APPLY 1011 -#define IDC_APPLY_ROAD 1011 -#define IDC_APPLY_MESH 1012 -#define IDC_TOP 1012 -#define IDC_UNIT_TYPE2_BUTTON 1012 -#define IDC_BROWSE 1013 -#define IDC_TOP_RIGHT 1013 -#define IDC_UNIT_TYPE3_BUTTON 1013 -#define IDC_NEWPROP 1014 -#define IDC_CENTER_LEFT 1014 -#define IDC_UNIT_TYPE4_BUTTON 1014 -#define IDC_NEWTEAM 1015 -#define IDC_CENTER 1015 -#define IDC_UNIT_TYPE5_BUTTON 1015 -#define IDC_TERRAIN_NAME 1016 -#define IDC_CENTER_RIGHT 1016 -#define IDC_UNIT_TYPE6_BUTTON 1016 -#define IDC_FEATHER_POPUP 1017 -#define IDC_BOTTOM_LEFT 1017 -#define IDC_UNIT_TYPE7_BUTTON 1017 -#define IDC_MOVE_DOWN 1018 -#define IDC_BOTTOM 1018 -#define IDC_TERRAIN_INFO 1019 -#define IDC_BOTTOM_RIGHT 1019 -#define IDC_IMPORT 1019 -#define IDC_MISSING_NAME 1020 -#define IDC_TERRAIN_SWATCHES 1021 -#define IDC_HEIGHT_POPUP 1022 -#define IDC_OBJECT_NAME 1023 -#define IDC_SIZE_POPUP2 1024 -#define IDC_SLIDER1 1025 -#define IDC_SHOW_CONTOURS 1026 -#define IDC_OBJECT_HEIGHT_EDIT 1027 -#define IDC_ROAD_NAME 1028 -#define IDC_ROAD_TREEVIEW 1029 -#define IDC_WIDTH_LABEL 1030 -#define IDC_HEIGHT_LABEL 1031 -#define IDC_PSEd_Color1 1031 -#define IDC_FEATHER_LABEL 1032 -#define IDC_WIDTH_LABEL3 1032 -#define IDC_TERRAIN_TREEVIEW 1033 -#define IDC_SLIDER3 1034 -#define IDC_SWAP_TEXTURES 1035 -#define IDC_SIZE_POPUP 1036 -#define IDC_SIZE_EDIT 1037 -#define IDC_MESHMOLD_TREEVIEW 1038 -#define IDC_PREVIEW 1039 -#define IDC_RADIUS_POPUP 1039 -#define IDC_ANGLE_EDIT 1040 -#define IDC_RATE_EDIT 1040 -#define IDC_FB_EDIT 1041 -#define IDC_RATE_POPUP 1041 -#define IDC_FB_POPUP 1042 -#define IDC_RA_EDIT 1043 -#define IDC_GA_EDIT 1044 -#define IDC_BA_EDIT 1045 -#define IDC_RD_EDIT 1046 -#define IDC_GD_EDIT 1047 -#define IDC_BD_EDIT 1048 -#define IDC_XYZ_STATIC 1049 -#define IDC_RD_EDIT1 1050 -#define IDC_OPEN_LIST 1051 -#define IDC_GD_EDIT1 1051 -#define IDC_SAVE_MAP_EDIT 1052 -#define IDC_BD_EDIT1 1052 -#define IDC_SAVE_LIST 1053 -#define IDC_FB_EDIT1 1053 -#define IDC_PROPERTIES 1054 -#define IDC_FB_POPUP1 1054 -#define IDC_KEYNAME 1055 -#define IDC_RD_EDIT2 1055 -#define IDC_VALUE 1056 -#define IDC_GD_EDIT2 1056 -#define IDC_KEYTYPE 1057 -#define IDC_BD_EDIT2 1057 -#define IDC_EDITPROP 1058 -#define IDC_FB_EDIT2 1058 -#define IDC_REMOVEPROP 1059 -#define IDC_FB_POPUP2 1059 -#define IDC_NEWPLAYER 1060 -#define IDC_EDITPLAYER 1061 -#define IDC_REMOVEPLAYER 1062 -#define IDC_PLAYERS 1063 -#define IDC_ADDSKIRMISHPLAYERS 1064 -#define IDC_OWNINGTEAM 1067 -#define IDC_PROPBOOL 1068 -#define IDC_SIDES_COMBO 1069 -#define IDC_BUILD_LIST 1070 -#define IDC_POWER 1071 -#define IDC_ALREADY_BUILD 1072 -#define IDC_REBUILDS 1073 -#define IDC_ADD_BUILDING 1074 -#define IDC_DELETE_BUILDING 1075 -#define IDC_MOVE_UP 1076 -#define IDC_RADIO_TERRAIN 1077 -#define IDC_EXPORT 1077 -#define IDC_RADIO_OBJECTS 1078 -#define IDC_RADIO_EVERYTHING 1079 -#define IDC_TIME_OF_DAY_CAPTION 1080 -#define IDC_ALPHA_EDIT 1081 -#define IDC_ACTION_LIST 1082 -#define IDC_LIST1 1100 -#define IDC_TEAMS_LIST 1100 -#define IDC_VALIDTEAMLIST 1100 -#define IDC_MAPOBJECT_BuildWithUpgrades 1100 -#define IDC_LIST2 1101 -#define IDC_PLAYER_LIST 1101 -#define IDC_BUTTON2 1103 -#define IDC_BUTTON3 1104 -#define IDC_BUTTON4 1105 -#define IDC_BUTTON5 1106 -#define IDC_OR 1107 -#define IDC_LOAD 1109 -#define IDC_SAVE 1110 -#define IDC_SCRIPT_TREE 1111 -#define IDC_TAB1 1112 -#define IDC_SCRIPT_ACTIVE 1116 -#define IDC_ONE_SHOT 1117 -#define IDC_SCRIPT_SUBROUTINE 1118 -#define IDC_SCRIPT_COMMENT 1119 -#define IDC_SCRIPT_DESCRIPTION 1121 -#define IDC_NEW_FOLDER 1122 -#define IDC_NEW_SCRIPT 1123 -#define IDC_EDIT_SCRIPT 1124 -#define IDC_COPY_SCRIPT 1125 -#define IDC_DELETE 1126 -#define IDC_SCRIPT_NAME 1127 -#define IDC_VERIFY 1127 -#define IDC_RICH_EDIT_HERE 1128 -#define IDC_PATCH_GC 1129 -#define IDC_CONDITION_TREE 1130 -#define IDC_CONDITION_LIST 1130 -#define IDC_EDIT_CONDITION 1131 -#define IDC_CONDITION_TYPE 1132 -#define IDC_CAPTION 1133 -#define IDC_COMBO 1134 -#define IDC_EDIT 1135 -#define IDC_LIST 1136 -#define IDC_NORMAL 1137 -#define IDC_HARD 1138 -#define IDC_NEW 1139 -#define IDC_COPY 1140 -#define IDC_EDIT_COMMENT 1141 -#define IDC_TEAMS_TREEVIEW 1142 -#define IDC_TEAM_SINGLETON 1143 -#define IDC_TEAMNAME 1144 -#define IDC_MAPOBJECT_Team 1144 -#define IDC_TEAMOWNER 1145 -#define IDC_MAPOBJECT_Script 1145 -#define IDC_ALLIESLIST 1146 -#define IDC_MAPOBJECT_Repairable 1146 -#define IDC_ENEMIESLIST 1147 -#define IDC_MAPOBJECT_IgnoreAllDistractions 1147 -#define IDC_DELETETEAM 1148 -#define IDC_MAPOBJECT_Powered 1148 -#define IDC_MAPOBJECT_RecruitableAI 1149 -#define IDC_SelectTeamMembers 1149 -#define IDC_STATICTEAMCAPTION 1150 -#define IDC_MOVEUPTEAM 1150 -#define IDC_PLAYERNAME 1151 -#define IDC_MOVEDOWNTEAM 1151 -#define IDC_PLAYERFACTION 1152 -#define IDC_GROUP_NAME 1153 -#define IDC_ANGLE_POPUP 1154 -#define IDC_RAISE 1155 -#define IDC_LOWER 1156 -#define IDC_SCALE_EDIT 1157 -#define IDC_TEXTURE_TREEVIEW 1158 -#define IDC_SCALE_POPUP 1159 -#define IDC_WAYPOINTNAME_EDIT 1160 -#define IDC_RAISE_LOWER 1161 -#define IDC_WAYPOINTLABEL1_EDIT 1161 -#define IDC_LR_EDIT 1162 -#define IDC_WAYPOINT_LOCATIONX 1162 -#define IDC_LR_POPUP 1163 -#define IDC_WAYPOINTLABEL2_EDIT 1163 -#define IDC_WAYPOINT_CAPTION 1164 -#define IDC_WAYPOINT_CAPTION1 1164 -#define IDC_LR_EDIT1 1164 -#define IDC_PLAYER_ATTITUDE_IN 1165 -#define IDC_WAYPOINTLABEL3_EDIT 1165 -#define IDC_LR_POPUP1 1165 -#define IDC_CHECK1 1166 -#define IDC_LR_EDIT2 1166 -#define IDC_DEPLOY_BY 1166 -#define IDC_WATER_POLYGON 1166 -#define IDC_LIST_OF_WAYPOINT_NAMES 1166 -#define IDC_MAPOBJECT_Selectable 1166 -#define IDC_PRODUCTION_EXECUTEACTIONS 1166 -#define IDC_PASSABLE_CHECK 1166 -#define IDC_AUTO_VERIFY 1166 -#define IDC_EASY 1167 -#define IDC_CHECK2 1167 -#define IDC_LR_POPUP2 1167 -#define IDC_TRANSPORTS_EXIT 1167 -#define IDC_MAKE_RIVER 1167 -#define IDC_WAYPOINT_LOCATIONY 1167 -#define IDC_PLAYERISCOMPUTER 1168 -#define IDC_CHECK3 1168 -#define IDC_TEAM_STARTS_FULL 1168 -#define IDC_WAYPOINT_BIDIRECTIONAL 1168 -#define IDC_GROUP_ACTIVE 1169 -#define IDC_MAPOBJECT_Selectable2 1169 -#define IDC_PLAYERDISPLAYNAME 1170 -#define IDC_CHECK4 1170 -#define IDC_TRANSPORTS_RETURN 1170 -#define IDC_PLAYER_ATTITUDE_OUT 1171 -#define IDC_CHECK5 1171 -#define IDC_AVOID_THREATS 1171 -#define IDC_WARNINGS_CAPTION 1172 -#define IDC_CHECK6 1172 -#define IDC_WARNINGS 1173 -#define IDC_EDIT_X 1174 -#define IDC_EDIT_Y 1175 -#define IDC_OBJECT_TREEVIEW 1175 -#define IDC_EDIT_Z 1176 -#define IDC_EDIT_TEMPLATE 1176 -#define IDC_EDIT1 1177 -#define IDC_MAX 1177 -#define IDC_PERCENT_DESTROYED 1177 -#define IDC_RO_WIDTH 1177 -#define IDC_MAP_TITLE 1177 -#define IDC_SPACING 1177 -#define IDC_SECONDS_EDIT 1177 -#define IDC_ANGLE 1177 -#define IDC_HOME_WAYPOINT 1178 -#define IDC_IDLE_FRAMES 1178 -#define IDC_MIN_UNIT1 1179 -#define IDC_MAX_UNIT1 1180 -#define IDC_UNIT_TYPE1 1181 -#define IDC_MIN_UNIT2 1182 -#define IDC_MAX_UNIT2 1183 -#define IDC_UNIT_TYPE2 1184 -#define IDC_MIN_UNIT3 1185 -#define IDC_MAX_UNIT3 1186 -#define IDC_UNIT_TYPE3 1187 -#define IDC_MIN_UNIT4 1188 -#define IDC_MAX_UNIT4 1189 -#define IDC_UNIT_TYPE4 1190 -#define IDC_MIN_UNIT5 1191 -#define IDC_MAX_UNIT5 1192 -#define IDC_UNIT_TYPE5 1193 -#define IDC_MIN_UNIT6 1194 -#define IDC_MAX_UNIT6 1195 -#define IDC_UNIT_TYPE6 1196 -#define IDC_EDIT4 1197 -#define IDC_DESCRIPTION 1197 -#define IDC_COMBO1 1198 -#define IDC_TEAM_BUILD_FRAMES 1198 -#define IDC_RADIO1 1199 -#define IDC_SYSTEMMAPS 1199 -#define IDC_TeamGeneric_Script2 1199 -#define IDC_PASSABLE 1199 -#define IDC_EVERY_FRAME 1199 -#define IDC_SCALE_OFF 1199 -#define IDC_MIN_UNIT7 1200 -#define IDC_RADIO2 1200 -#define IDC_USERMAPS 1200 -#define IDC_TeamGeneric_Script3 1200 -#define IDC_IMPASSABLE 1200 -#define IDC_EVERY_SECOND 1200 -#define IDC_SCALE_ON 1200 -#define IDC_MAX_UNIT7 1201 -#define IDC_RADIO3 1201 -#define IDC_TeamGeneric_Script4 1201 -#define IDC_UNIT_TYPE7 1202 -#define IDC_RADIO4 1202 -#define IDC_TeamGeneric_Script5 1202 -#define IDC_ON_CREATE_SCRIPT 1203 -#define IDC_TeamGeneric_Script6 1203 -#define IDC_WAYPOINTS 1204 -#define IDC_ON_IDLE_SCRIPT 1204 -#define IDC_TeamGeneric_Script7 1204 -#define IDC_TRIGGERS 1205 -#define IDC_ON_ENEMY_SIGHTED 1205 -#define IDC_TeamGeneric_Script8 1205 -#define IDC_UNITS 1206 -#define IDC_ON_DESTROYED 1206 -#define IDC_TeamGeneric_Script9 1206 -#define IDC_ALL_SCRIPTS 1207 -#define IDC_ON_ALL_CLEAR 1207 -#define IDC_TeamGeneric_Script10 1207 -#define IDC_SELECTED_SCRIPTS 1208 -#define IDC_ON_UNIT_DESTROYED_SCRIPT 1208 -#define IDC_TeamGeneric_Script11 1208 -#define IDC_TeamGeneric_Script12 1209 -#define IDC_Grove_Type1 1210 -#define IDC_TeamGeneric_Script13 1210 -#define IDC_Grove_Per1 1211 -#define IDC_TeamGeneric_Script14 1211 -#define IDC_Grove_Type2 1212 -#define IDC_TeamGeneric_Script15 1212 -#define IDC_Grove_Per2 1213 -#define IDC_TeamGeneric_Script16 1213 -#define IDC_Grove_Type3 1214 -#define IDC_Grove_Per3 1215 -#define IDC_Grove_Type4 1216 -#define IDC_Grove_Per4 1217 -#define IDC_Grove_PerTotal 1218 -#define IDC_Grove_Type5 1219 -#define IDC_Grove_Per5 1220 -#define IDC_Grove_NumberTrees 1221 -#define IDC_FENCE_SPACING_EDIT 1222 -#define IDC_AUTO_REINFORCE 1224 -#define IDC_PERIMETER_DEFENSE 1224 -#define IDC_AI_RECRUITABLE 1225 -#define IDC_ATTACK_COMMON_TARGET 1225 -#define IDC_BASE_DEFENSE 1226 -#define IDC_TEAM_NAME 1226 -#define IDC_PRODUCTION_CONDITION 1227 -#define IDC_PRODUCTION_PRIORITY 1228 -#define IDC_PRIORITY_INCREASE 1229 -#define IDC_ENEMY_INTERACTIONS 1229 -#define IDC_PRIORITY_DECREASE 1230 -#define IDC_MAPOBJECT_StartingHealthEdit 1231 -#define IDC_MAPOBJECT_Enabled 1232 -#define IDC_MAPOBJECT_Destructible 1233 -#define IDC_MAPOBJECT_Indestructible 1233 -#define IDC_MAPOBJECT_Sellable 1234 -#define IDC_MAPOBJECT_Whiner 1235 -#define IDC_MAPOBJECT_Deployed 1236 -#define IDC_MAPOBJECT_StartingHealth 1237 -#define IDC_MAPOBJECT_VisionDistance 1238 -#define IDC_MAPOBJECT_Aggressiveness 1239 -#define IDC_MAPOBJECT_Recruitable 1240 -#define IDC_MAPOBJECT_GroupNumber 1241 -#define IDC_MAPOBJECT_ShroudClearingDistance 1241 -#define IDC_MAPOBJECT_Name 1242 -#define IDC_MAPOBJECT_Veterancy 1243 -#define IDC_MAPOBJECT_ZOffset 1244 -#define IDC_MAPOBJECT_Angle 1245 -#define IDC_MAPOBJECT_StoppingDistance 1246 -#define IDC_GROUP_SUBROUTINE 1250 -#define IDC_BROAD_CURVE 1251 -#define IDC_TIGHT_CURVE 1252 -#define IDC_ANGLED 1253 -#define IDC_Grove_AllowWaterPlacement 1254 -#define IDC_Grove_AllowCliffPlacement 1255 -#define IDC_ANCHOR_LABEL 1256 -#define IDC_JOIN 1257 -#define IDC_WATER_HEIGHT1 1258 -#define IDC_WATER_HEIGHT2 1259 -#define IDC_WAYPOINT_CAPTION2 1260 -#define IDC_WAYPOINT_LOCATION 1260 -#define IDC_WAYPOINT_CAPTION3 1261 -#define IDC_WAYPOINT_PATHLABELS 1261 -#define IDC_LIST_WAYPOINTS 1262 -#define IDC_PlayerColor 1263 -#define IDC_PlayerColorCombo 1264 -#define IDC_SCORCHTYPE 1268 -#define IDC_MAP_WEATHER 1269 -#define IDC_MAP_TIMEOFDAY 1270 -#define IDC_MAP_DESCRIPTION 1271 -#define IDC_MAPOBJECT_Weather 1272 -#define IDC_MAP_COMPRESSION 1272 -#define IDC_MAPOBJECT_Time 1273 -#define IDC_MAPOBJECT_HitPoints 1274 -#define IDC_LL_TREE 1275 -#define IDC_TRANSPORT_COMBO 1276 -#define IDC_WAYPOINT_COMBO 1277 -#define IDC_VETERANCY 1278 -#define IDC_MISSINGLABEL 1279 -#define IDC_CameraReset 1281 -#define IDC_PITCH_POPUP 1282 -#define IDC_PITCH_EDIT 1283 -#define IDC_HEIGHTTEXT 1284 -#define IDC_ZOOMTEXT 1285 -#define IDC_POSTEXT 1286 -#define IDC_TARGETTEXT 1287 -#define IDC_WATERNAME_EDIT 1288 -#define IDC_REPLACETHISTEXT 1289 -#define IDC_COLORBUTTON 1290 -#define IDC_MAPOBJECT_Unsellable 1291 -#define IDC_MAPOBJECT_Targetable 1292 -#define IDC_SCRIPT_PREFIX1 1299 -#define IDC_SCRIPT_PREFIX2 1300 -#define IDC_SCRIPT_PREFIX3 1301 -#define IDC_SCRIPT_PREFIX4 1302 -#define IDC_SCRIPT_PREFIX5 1303 -#define IDC_SCRIPT_PREFIX6 1304 -#define IDC_SCRIPT_PREFIX7 1305 -#define IDC_SCRIPT_PREFIX8 1306 -#define IDC_SCRIPT_PREFIX9 1307 -#define IDC_SCRIPT_PREFIX10 1308 -#define IDC_SCRIPT_PREFIX11 1309 -#define IDC_SCRIPT_PREFIX12 1310 -#define IDC_SCRIPT_PREFIX13 1311 -#define IDC_SCRIPT_PREFIX14 1312 -#define IDC_SCRIPT_PREFIX15 1313 -#define IDC_SCRIPT_PREFIX16 1314 -#define IDC_TeamGeneric_Script1 1315 -#define IDC_DROP_WAYPOINT_BUTTON 1316 -#define IDC_ACTION_TREE 1326 -#define IDC_CENTER_ON_SELECTED 1327 -#define IDC_CHECK_RULER 1328 -#define IDC_SIDES 1329 -#define IDC_RULER_WIDTH 1330 -#define IDC_UPDATE_TEAM_MEMBERS 1331 -#define IDC_USE_TEAM_DEFAULTS 1332 -#define IDC_LOOPING_CHECKBOX 1333 -#define IDC_ENABLED_CHECKBOX 1334 -#define IDC_CUSTOMIZE_CHECKBOX 1335 -#define IDC_MAPOBJECT_Scale 1336 -#define IDC_SOUND_COMBO 1346 -#define IDC_LOOPCOUNT_EDIT 1347 -#define IDC_MIN_VOLUME_EDIT 1348 -#define IDC_PRIORITY_COMBO 1349 -#define IDC_MIN_RANGE_EDIT 1350 -#define IDC_MAX_RANGE_EDIT 1351 -#define IDC_VOLUME_EDIT 1352 -#define IDC_MAPOBJECT_XYPosition 1353 -#define IDC_STATIC_MAPOBJECT_GENERAL 1379 -#define IDC_STATIC_MAPOBJECT_LOGICAL 1380 -#define IDC_STATIC_MAPOBJECT_SOUND 1381 -#define IDC_STATIC_MAPOBJECT_VISUAL 1382 -#define IDC_MAPOBJECT_DISTANCE 1383 -#define ID_BRUSH_TOOL 32771 -#define IDM_ShowGrid 32772 -#define ID_FEATHERTOOL 32791 -#define ID_BIG_TILE_TOOL 32792 -#define ID_SLIDER 32793 -#define ID_TEXTURES_0 32800 -#define ID_TEXTURES_1 32801 -#define ID_TEXTURES_2 32802 -#define ID_TEXTURES_3 32803 -#define ID_TEXTURES_4 32804 -#define ID_BRUSH_ADD_TOOL 32900 -#define ID_BRUSH_SUBTRACT_TOOL 32901 -#define ID_TILE_TOOL 32902 -#define ID_TILE_FLOOD_FILL 32903 -#define ID_BUTTON32904 32904 -#define ID_AUTO_EDGE_OUT_TOOL 32905 -#define ID_AUTO_EDGE_IN_TOOL 32906 -#define ID_TS_MIP_EDGE 32907 -#define ID_TS_MIP_BASE 32908 -#define ID_TS_SUBSAMPLE 32909 -#define ID_TS_INFO 32910 -#define ID_EYEDROPPER_TOOL 32913 -#define ID_TS_32X32 32915 -#define ID_TS_CANONICAL 32916 -#define ID_FILE_RESIZE 32917 -#define ID_PLACE_OBJECT_TOOL 32918 -#define ID_TS_REFRESH 32919 -#define ID_POINTER_TOOL 32921 -#define ID_BLEND_EDGE_TOOL 32922 -#define ID_GROVE_TOOL 32924 -#define ID_EDIT_LINK_CENTERS 32925 -#define ID_VIEW_SHOW_OBJECTS 32926 -#define ID_VIEW_SHOWTEXTURE 32927 -#define ID_TS_REMAP 32929 -#define ID_VIEW_SHOWCONTOURS 32930 -#define ID_EDIT_DELETE 32931 -#define ID_VIEW_SHOWWIREFRAME 32934 -#define ID_VIEW_SHOWTERRAIN 32935 -#define ID_OBJECTPROPERTIES_REFLECTSINMIRROR 32936 -#define ID_ROAD_TOOL 32937 -#define ID_VIEW_TOGGLE_ROAD 32938 -#define ID_VIEW_SNAPTOGRID 32939 -#define ID_EDIT_SELECTDUP 32940 -#define ID_OBJECTPROPERTIES_ANGLEDCORNER 32941 -#define ID_VIEW_TIME_OF_DAY 32942 -#define ID_VIEW_SHOWENTIRE3DMAP 32943 -#define ID_VIEW_SHOWTOPDOWNVIEW 32944 -#define ID_VIEW_SHOWCLOUDS 32945 -#define ID_EDIT_CONTOUROPTIONS 32946 -#define IDM_RESET_WINDOWS 32947 -#define ID_WINDOW_PREVIEW640X480 32949 -#define ID_WINDOW_PREVIEW800X600 32950 -#define ID_WINDOW_PREVIEW1024X768 32951 -#define ID_WINDOW_2DWINDOW 32952 -#define ID_VIEW_BRUSHFEEDBACK 32954 -#define ID_MOLD_TOOL 32955 -#define ID_VIEW_SHOWMACROTEXTURE 32956 -#define ID_EDIT_SELECTMACROTEXTURE 32957 -#define ID_RULER_TOOL 32958 -#define ID_SCRIPT_EDIT 32959 -#define ID_TEAM_EDIT 32960 -#define ID_LOCK_HORIZONTAL 32962 -#define ID_LOCK_VERTICAL 32963 -#define ID_WAYPOINT_TOOL 32964 -#define ID_EDIT_GLOBALLIGHTOPTIONS 32965 -#define ID_VIEW_SHOWWAYPOINTS 32966 -#define ID_POLYGON_TOOL 32968 -#define ID_VIEW_SHOWPOLYGONTRIGGERS 32969 -#define ID_EDIT_PLAYERLIST 32970 -#define ID_EDIT_WORLDINFO 32971 -#define ID_BUILD_LIST_TOOL 32972 -#define ID_HAND_SCROLL_TOOL 32973 -#define ID_VIEW_RELOADTEXTURES 32974 -#define ID_EDIT_SHADOWS 32975 -#define ID_VIEW_SHOWSHADOWS 32976 -#define ID_EDIT_SCRIPTS 32977 -#define ID_EDIT_TEAMLIST 32978 -#define ID_FENCE_TOOL 32979 -#define ID_VIEW_SHOWIMPASSABLEAREAS 32981 -#define ID_TEXTURESIZING_TILE4X4 32982 -#define ID_TEXTURESIZING_TILE6X6 32983 -#define ID_TEXTURESIZING_TILE8X8 32984 -#define ID_WATER_TOOL 32986 -#define ID_TEXTURESIZING_MAPCLIFFTEXTURES 32987 -#define ID_EDIT_SELECTSIMILAR 32988 -#define ID_VIEW_PARTIALMAPSIZE_96X96 32989 -#define ID_VIEW_PARTIALMAPSIZE_128X128 32990 -#define ID_VIEW_PARTIALMAPSIZE_160X160 32991 -#define ID_VIEW_PARTIALMAPSIZE_192X192 32992 -#define ID_FILE_JUMPTOGAME 32993 -#define ID_EDIT_PICKSTRUCTS 32994 -#define ID_EDIT_PICKINFANTRY 32995 -#define ID_EDIT_PICKVEHICLES 32996 -#define ID_EDIT_PICKSHRUBBERY 32997 -#define ID_EDIT_PICKMANMADE 32998 -#define ID_EDIT_PICKNATURAL 32999 -#define ID_EDIT_PICKDEBRIS 33000 -#define ID_EDIT_PICKANYTHING 33001 -#define ID_EDIT_PICKWAYPOINTS 33002 -#define ID_VIEW_LABELS 33003 -#define ID_VIEW_SHOWMODELS 33004 -#define ID_EDIT_SELECTINVALIDTEAM 33005 -#define ID_FILE_DUMPTOFILE 33006 -#define ID_SCORCH_TOOL 33007 -#define ID_VIEW_BOUNDINGBOXES 33008 -#define ID_VIEW_SIGHTRANGES 33009 -#define ID_VIEW_WEAPONRANGES 33010 -#define ID_HIGHLIGHT_TESTART 33011 -#define ID_SHOW_LETTERBOX 33012 -#define ID_TEXTURESIZING_REMOVECLIFFTEXMAPPING 33014 -#define ID_VIEW_LAYERS_LIST 33015 -#define ID_INSERTNEWLAYER 33017 -#define ID_DELETECURRENTLAYER 33018 -#define ID_LAYERSLIST_MERGELAYERINTO_BOGUS 33021 -#define ID_LAYERSLIST_MERGELAYERINTO_BEGIN 33022 -#define ID_LAYERSLIST_MERGELAYERINTO_END 33121 -#define ID_LAYERSLIST_MERGEOBJECTINTO_BOGUS 33122 -#define ID_LAYERSLIST_MERGEOBJECTINTO_BEGIN 33123 -#define ID_LAYERSLIST_MERGEOBJECTINTO_END 33222 -#define ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_BOGUS 33223 -#define ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_BEGIN 33224 -#define ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_END 33323 -#define ID_HIDECURRENTLAYER 33324 -#define ID_EDIT_MAPSETTINGS 33325 -#define ID_VIEW_GARRISONED 33326 -#define ID_EDIT_PICKROADS 33327 -#define ID_SCRIPTACTIVATE 33328 -#define ID_BORDERTOOL 33330 -#define ID_VIEW_SHOWMAPBOUNDARIES 33331 -#define ID_TOGGLE_PITCH_AND_ROTATE 33332 -#define ID_EDIT_CAMERAOPTIONS 33333 -#define ID_VIEWHOME 33334 -#define ID_VIEW_SHOWSOFTWATER 33335 -#define ID_VALIDATION_GENERATEMAPREPORT 33337 -#define ID_VALIDATION_FIXTEAMS 33338 -#define ID_VIEW_SHOWEXTRABLENDS 33339 -#define ID_VIEW_SHOWAMBIENTSOUNDS 33340 -#define ID_EDIT_PICKSOUNDS 33341 -#define ID_VIEW_SHOW_TERRAIN 33342 -#define ID_VIEW_IMPASSABLEAREAOPTIONS 33343 -#define ID_SELECTLAYEROBJECT 33344 -#define ID_SELECTACTIVELAYER 33345 -#define ID_VIEW_SHOW_SOUND_CIRCLES 33346 -#define ID_LOOK_NORTH 33347 -#define ID_LOOK_SOUTH 33348 -#define ID_LOOK_WEST 33349 -#define ID_LOOK_EAST 33350 -#define IDS_NEW 61446 -#define IDS_RESIZE 61447 -#define IDS_REMOVING_INUSE_TEAM 61448 -#define IDS_RENAMING_INUSE_TEAM 61449 -#define IDS_NAME_IN_USE 61450 -#define IDS_BAD_OWNER_NAME 61451 -#define IDS_OUT_OF_MEMORY 61452 -#define IDS_BAD_FILE_DATA 61453 -#define IDS_BAD_VALUE 61454 -#define IDS_FILE_IS_READONLY 61455 -#define IDS_REPLACEFILE 61456 -#define IDS_ONLY_ONE_FILE 61457 -#define IDS_NO_AUTOSAVE 61458 -#define IDS_TOO_MANY_TILES 61459 -#define IDS_TOO_MANY_BLENDS 61460 -#define IDS_TEXTURE_TOO_LARGE 61461 -#define IDS_ALPHA_BLEND 61462 -#define IDS_SCRIPT_INFORMATION 61463 -#define IDS_SCRIPT_WARNINGS 61464 -#define IDS_SCRIPT_NOWARNINGS 61465 -#define IDS_CONFIRM_REPLACE_TEXTURE 61466 -#define ID_RAMP 61467 -#define ID_RAMPTOOL 61467 -#define IDS_CONFIRM_REMOVE_CLIFF_MAPPING 61468 -#define IDS_NUM_SELECTED_ON_TEAM 61469 -#define IDS_MAX_OBJECTS 61470 -#define IDS_REPLACEOWNER 61471 -#define IDS_SPLASH_LOADING 61472 -#define IDS_SINGLE_SELECTION_ONLY 61473 -#define IDS_NO_UPGRADES 61474 -#define IDS_TEAMS_FIXED 61475 -#define IDS_EULA_AGREEMENT1 61476 -#define IDS_EULA_AGREEMENT2 61477 -#define IDS_EULA_AGREEMENT3 61478 -#define IDS_EULA_AGREEMENT4 61479 -#define IDS_EULA_AGREEMENT5 61480 -#define IDS_MAPOBJECT_PROPS_TITLE 61481 -#define IDS_NO_PROBLEMS 61482 -#define IDS_DUPLICATE_TEAM_REMOVED 61483 -#define IDS_PLAYERLESS_TEAM_REMOVED 61484 -#define IDS_NEED_TO_FIX_TEAMS 61485 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 242 -#define _APS_NEXT_COMMAND_VALUE 33351 -#define _APS_NEXT_CONTROL_VALUE 1354 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/toolbar1.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/toolbar1.bmp deleted file mode 100644 index d59c166387aa0ed29654b0e424538231613e2242..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmZ?rHDh4_gEAng0mLFe900_O3=oL}%s>uS(7?a|L<|iL5DG{FnG6RG901ZFiT_~4 z@c%!E1;juI5&{zCaKM1Xo`}R&Lt<}0Vsjv|4h+rt;?_vw+(>L>^(;u@xZFT3aa?}kM)C_TyKuP^qP_s^Y2LZB=hh8K#3?C42jqG=d(=a4B%LjMb1^}%N Bv2y?b diff --git a/GeneralsMD/Code/Tools/WorldBuilder/res/toolbar2.bmp b/GeneralsMD/Code/Tools/WorldBuilder/res/toolbar2.bmp deleted file mode 100644 index bf79383f7fa8c270a04ee580eab265a61b1cef4f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2158 zcmaJ?F_Ii14CJa@1sQ&Z-{IU}aS>U{h77X((mjc6F2mgt?2c=vtl1eM5K_|!_UEtP zDVY4h_XpnZA0cGukMPa(beXZ?W`h-33Hx!=0QKo9{#_!D9=#t8-wRp2z$2enz64q^3DYG74NZxew5q% z@4XRz|Kccx;jlRAy#dI!muBoMjxren?nyM4CZ}04LpRwOZACtW@9t#>141MchsQF% zm=eN4R6A#Hduh&j?aG{G4x0uX^-GdWW&U zY}DFOBHLd24aXuxL-~^9jECa@9}Kv0NGAf95(zHnna3Q1=~sWTmhXC$+B)bZkdzXp zZ+q!C9E%VQsE(;|@iD;%4$i`{Dt_g&&BV%lS!$F=!>tHp! z>f?l1eR#1yfq)OTOCEV(o@J!XopUFg8Sf<_JTat$Jx++}jl*|kqL{G17FkP0ob%@X zV5x0^yX^zDH8zfQZVk!03rGkSZ}+LMbxi^>H#oqtMXU`t2n=$*?o*?~DDWYa>qVm7 zAMD`1EGc=Rd!P&RHy^?bly;A!kYF$i|C|38qr;}#$BxI-yr5bj^T h_FF!@. -*/ - -// AutoEdgeOutTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "AutoEdgeOutTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -// -// AutoEdgeOutTool class. -// -/// Constructor -AutoEdgeOutTool::AutoEdgeOutTool() : - Tool(ID_AUTO_EDGE_OUT_TOOL, IDC_AUTO_EDGE_OUT) -{ -} - -/// Destructor -AutoEdgeOutTool::~AutoEdgeOutTool() -{ -} - -/// Shows the brush options panel. -void AutoEdgeOutTool::activate() -{ - Tool::activate(); - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_BLEND_MATERIAL); -} - - -/** Execute the tool on mouse down - Create a copy of the height map -* to edit, blend the edges, and give the undoable command to the doc. */ -void AutoEdgeOutTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - CPoint ndx; - if (!pDoc->getCellIndexFromCoord(cpt, &ndx)) { - return; - } - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - WorldHeightMapEdit *htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - htMapEditCopy->autoBlendOut(ndx.x, ndx.y, BlendMaterial::getBlendTexClass()); - IRegion2D partialRange = {0,0,0,0}; - pDoc->updateHeightMap(htMapEditCopy, false, partialRange); - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(htMapEditCopy); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp deleted file mode 100644 index 1fe9c60f0ae..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BaseBuildProps.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BaseBuildProps.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "BaseBuildProps.h" -#include "EditParameter.h" - -///////////////////////////////////////////////////////////////////////////// -// BaseBuildProps dialog - - -BaseBuildProps::BaseBuildProps(CWnd* pParent /*=nullptr*/) - : CDialog(BaseBuildProps::IDD, pParent) -{ - //{{AFX_DATA_INIT(BaseBuildProps) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void BaseBuildProps::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(BaseBuildProps) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -BOOL BaseBuildProps::OnInitDialog() -{ - // add name - CWnd* pName = GetDlgItem(IDC_MAPOBJECT_Name); - if (pName) { - pName->SetWindowText(m_name.str()); - } - - // add script - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Script); - EditParameter::loadScripts(pCombo, true); - pCombo->AddString(""); - if (m_script.isEmpty()) { - pCombo->SelectString(-1, ""); - } else { - pCombo->SelectString(-1, m_script.str()); - } - - // add health - CWnd* pHealth = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", m_health); - pHealth->SetWindowText(buff); - - CButton* pItem; - pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - if (pItem) { - pItem->SetCheck(m_unsellable); - } - - return TRUE; -} - - -BEGIN_MESSAGE_MAP(BaseBuildProps, CDialog) - //{{AFX_MSG_MAP(BaseBuildProps) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// BaseBuildProps message handlers -void BaseBuildProps::setProps(AsciiString name, AsciiString script, Int health, Bool unsellable) -{ - m_name = name; - m_script = script; - m_health = health; - m_unsellable = unsellable; -} - -void BaseBuildProps::OnOK() -{ - CComboBox *combo; - CWnd* edit; - CString cstr; - static char buf[1024]; - - edit = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Name); - edit->GetWindowText(buf, sizeof(buf)-2); - m_name = AsciiString(buf); - - combo = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Script); - combo->GetWindowText(buf, sizeof(buf)-2); - m_script = AsciiString(buf); - - edit = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - edit->GetWindowText(cstr); - if (cstr.IsEmpty()) { - m_health = 100; - } else { - m_health = atoi(cstr.GetBuffer(0)); - if (m_health < 0) - m_health = 0; - } - - CButton *check; - check = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - m_unsellable = (check->GetCheck() != 0); - - CDialog::OnOK(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp deleted file mode 100644 index c1129b7f4b0..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BlendEdgeTool.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BlendEdgeTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "BlendEdgeTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -// -// BlendEdgeTool class. -// -/// Constructor -BlendEdgeTool::BlendEdgeTool() : - Tool(ID_BLEND_EDGE_TOOL, IDC_BLEND_EDGE) -{ -} - -/// Destructor -BlendEdgeTool::~BlendEdgeTool() -{ -} - - -/** Execute the tool on mouse down - Place an object. */ -void BlendEdgeTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - m_downPt = cpt; -} - -/** Execute the tool on mouse up - Blend an edge. Left mouse blends the from -texture to the to texture based on your drag. Right mouse blends the -foreground texture in the texture panel on top of the destination tile for -custom blends. */ -void BlendEdgeTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - CPoint from, to; - - Coord3D cpt; - // Don't constrain this tool. - pView->viewToDocCoords(viewPt, &cpt, false); - - if (!pDoc->getCellIndexFromCoord(m_downPt, &from) || !pDoc->getCellIndexFromCoord(cpt, &to)) { - return; - } - - if (from.x == to.x && from.y == to.y) { - return; - } - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - WorldHeightMapEdit *htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - if (m == TRACK_L) - htMapEditCopy->blendTile(to.x, to.y, from.x, from.y, -1, -1); // does all the work. - else - htMapEditCopy->blendTile(to.x, to.y, from.x, from.y, TerrainMaterial::getFgTexClass(), -1); // does all the work. - IRegion2D partialRange = {to.x, to.y, to.x+1, to.y+1}; - pDoc->updateHeightMap(htMapEditCopy, true, partialRange); //update the render object with new tile and/or height data. - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - REF_PTR_RELEASE(htMapEditCopy); - -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BlendMaterial.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BlendMaterial.cpp deleted file mode 100644 index 3981689ac4f..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BlendMaterial.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BlendMaterial.cpp : implementation file -// - -#define DEFINE_TERRAIN_TYPE_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "BlendMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "TileTool.h" -#include "Common/TerrainTypes.h" -#include "W3DDevice/GameClient/TerrainTex.h" - -BlendMaterial *BlendMaterial::m_staticThis = nullptr; - -static Int defaultMaterialIndex = -1; - -///////////////////////////////////////////////////////////////////////////// -// BlendMaterial dialog - -Int BlendMaterial::m_currentBlendTexture(-1); - -BlendMaterial::BlendMaterial(CWnd* pParent /*=nullptr*/) : - m_updating(false) -{ - //{{AFX_DATA_INIT(BlendMaterial) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void BlendMaterial::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(BlendMaterial) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(BlendMaterial, COptionsPanel) - //{{AFX_MSG_MAP(BlendMaterial) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// BlendMaterial data access method. - -/// Set foreground texture and invalidate swatches. -void BlendMaterial::setBlendTexClass(Int texClass) -{ - if (m_staticThis) { - m_staticThis->m_currentBlendTexture=texClass; - m_staticThis->setTerrainTreeViewSelection(TVI_ROOT, texClass); - } -} - - - -/// Set the selected texture in the tree view. -Bool BlendMaterial::setTerrainTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[_MAX_PATH]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&item); - if (item.lParam == selection) { - m_terrainTreeView.SelectItem(child); - return(true); - } - if (setTerrainTreeViewSelection(child, selection)) { - return(true); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - return(false); -} - - -///////////////////////////////////////////////////////////////////////////// -// BlendMaterial message handlers - -/// Setup the controls in the dialog. -BOOL BlendMaterial::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - CWnd *pWnd = GetDlgItem(IDC_TERRAIN_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_terrainTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_terrainTreeView.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_TERRAIN_SWATCHES); - pWnd->GetWindowRect(&rect); - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - //m_terrainSwatches.Create(nullptr, "", WS_CHILD, rect, this, IDC_TERRAIN_SWATCHES); - //m_terrainSwatches.ShowWindow(SW_SHOW); - - m_staticThis = this; - updateTextures(); - m_updating = false; - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM BlendMaterial::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = const_cast(pLabel); - ins.item.cchTextMax = strlen(pLabel); - child = m_terrainTreeView.InsertItem(&ins); - return(child); -} - -/** Add the terrain path to the tree view. */ -void BlendMaterial::addTerrain(const char *pPath, Int terrainNdx, HTREEITEM parent) -{ - AsciiString className; - if (terrainNdx >= 0) { - className = WorldHeightMapEdit::getTexClassName( terrainNdx ); - } - TerrainType *terrain = TheTerrainTypes->findTerrain( className ); - Bool doAdd = FALSE; - char buffer[_MAX_PATH]; - // - // if we have a 'terrain' entry, it means that our terrain index was properly defined - // in an INI file, otherwise it was from eval textures. We will sort all of - // the eval texture entries in a tree leaf all their own while the others are - // sorted according to a field specified in INI - // - if( terrain ) - { - if (!terrain->isBlendEdge()) { - return; // Only do blend edges to the blend material list. - } - - // set the name in the tree view to that of the entry - strlcpy(buffer, terrain->getName().str(), ARRAY_SIZE(buffer)); - - doAdd = TRUE; - } else if (terrainNdx==-1) { - strlcpy(buffer, pPath, ARRAY_SIZE(buffer)); - doAdd = true; - } else if (WorldHeightMapEdit::getTexClassIsBlendEdge(terrainNdx)) { - parent = findOrAdd( parent, "**EVAL**" ); - strlcpy(buffer, pPath, ARRAY_SIZE(buffer)); - doAdd = true; - } - -// Int tilesPerRow = TEXTURE_WIDTH/(2*TILE_PIXEL_EXTENT+TILE_OFFSET); -// Int availableTiles = 4 * tilesPerRow * tilesPerRow; -// Int percent = (WorldHeightMapEdit::getTexClassNumTiles(terrainNdx)*100 + availableTiles/2) / availableTiles; - - if( doAdd ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = buffer; - ins.item.cchTextMax = strlen(buffer)+2; - m_terrainTreeView.InsertItem(&ins); - } - -} - -//* Create the tree view of textures from the textures in pMap. */ -void BlendMaterial::updateTextures() -{ - m_updating = true; - m_terrainTreeView.DeleteAllItems(); - Int i; - CString label; - label.LoadString(IDS_ALPHA_BLEND); - addTerrain(label, -1, TVI_ROOT); - for (i=WorldHeightMapEdit::getNumTexClasses()-1; i>=0; i--) { - char path[_MAX_PATH]; - AsciiString uiName = WorldHeightMapEdit::getTexClassUiName(i); - strlcpy(path, uiName.str(), _MAX_PATH); - addTerrain(path, i, TVI_ROOT); - } - m_updating = false; - m_currentBlendTexture = defaultMaterialIndex; - setTerrainTreeViewSelection(TVI_ROOT, m_currentBlendTexture); -} - - - - -BOOL BlendMaterial::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_terrainTreeView.m_hWnd) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - HTREEITEM hItem = m_terrainTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = hItem; - m_terrainTreeView.GetItem(&item); - if (item.lParam >= -1) { - Int texClass = item.lParam; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return 0; - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - if (!pMap) return 0; - if (m_updating) return 0; - m_currentBlendTexture = texClass; - } else if (!(item.state & TVIS_EXPANDEDONCE) ) { - HTREEITEM child = m_terrainTreeView.GetChildItem(hItem); - while (child != nullptr) { - hItem = child; - child = m_terrainTreeView.GetChildItem(hItem); - } - if (hItem != m_terrainTreeView.GetSelectedItem()) { - m_terrainTreeView.SelectItem(hItem); - } - } - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BorderTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BorderTool.cpp deleted file mode 100644 index 1db6efb14da..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BorderTool.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "StdAfx.h" -#include "resource.h" - -#include "BorderTool.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "wbview3d.h" -#include "WorldBuilderDoc.h" - -const long BOUNDARY_PICK_DISTANCE = 5.0f; - -BorderTool::BorderTool() : Tool(ID_BORDERTOOL, IDC_POINTER), - m_mouseDown(false), - m_addingNewBorder(false), - m_modifyBorderNdx(-1) - -{ } - -BorderTool::~BorderTool() -{ - -} - -void BorderTool::setCursor() -{ - -} - -void BorderTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_NO_OPTIONS); - DrawObject::setDoBoundaryFeedback(TRUE); -} - -void BorderTool::deactivate() -{ - WbView3d *p3View = CWorldBuilderDoc::GetActive3DView(); - DrawObject::setDoBoundaryFeedback(p3View->getShowMapBoundaryFeedback()); -} - -void BorderTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - - if (m_addingNewBorder) { - Int count = pDoc->getNumBoundaries(); - ICoord2D current; - pDoc->getBoundary(count - 1, ¤t); - Coord3D new3DPoint; - pView->viewToDocCoords(viewPt, &new3DPoint, false); - - if (current.x < 0) { - current.x = 0; - } - - if (current.y < 0) { - current.y = 0; - } - - current.x = REAL_TO_INT((new3DPoint.x / MAP_XY_FACTOR) + 0.5f); - current.y = REAL_TO_INT((new3DPoint.y / MAP_XY_FACTOR) + 0.5f); - pDoc->changeBoundary(count - 1, ¤t); - return; - } - - if (m_modifyBorderNdx >= 0) { - ICoord2D currentBorder; - pDoc->getBoundary(m_modifyBorderNdx, ¤tBorder); - - Coord3D new3DPoint; - pView->viewToDocCoords(viewPt, &new3DPoint, false); - - switch (m_modificationType) - { - case MOD_TYPE_INVALID: m_modifyBorderNdx = -1; return; - case MOD_TYPE_UP: - currentBorder.y = REAL_TO_INT((new3DPoint.y / MAP_XY_FACTOR) + 0.5f); - break; - case MOD_TYPE_RIGHT: - currentBorder.x = REAL_TO_INT((new3DPoint.x / MAP_XY_FACTOR) + 0.5f); - break; - case MOD_TYPE_FREE: - currentBorder.x = REAL_TO_INT((new3DPoint.x / MAP_XY_FACTOR) + 0.5f); - currentBorder.y = REAL_TO_INT((new3DPoint.y / MAP_XY_FACTOR) + 0.5f); - break; - } - - if (currentBorder.x < 0) { - currentBorder.x = 0; - } - - if (currentBorder.y < 0) { - currentBorder.y = 0; - } - - - pDoc->changeBoundary(m_modifyBorderNdx, ¤tBorder); - } -} - -void BorderTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - - //static Coord3D zero = {0.0f, 0.0f, 0.0f}; - - Coord3D groundPt; - pView->viewToDocCoords(viewPt, &groundPt); - if (groundPt.length() < BOUNDARY_PICK_DISTANCE) { - m_addingNewBorder = true; - - ICoord2D initialBoundary = { 1, 1 }; - pDoc->addBoundary(&initialBoundary); - return; - } - - Int motion; - pDoc->findBoundaryNear(&groundPt, BOUNDARY_PICK_DISTANCE, &m_modifyBorderNdx, &motion); - - // if bottom left boundary grabbed - if (motion == 0) - { - // modifying the bottom left is not allowed. - m_modifyBorderNdx = -1; - } - // else if no boundary is near - else if (motion == -1) - { - // add a boundary - m_addingNewBorder = true; - - ICoord2D initialBoundary = { 1, 1 }; - pDoc->addBoundary(&initialBoundary); - } - else - { - m_modificationType = (ModificationType) motion; - } -} - -void BorderTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - - if (m_addingNewBorder) { - m_addingNewBorder = false; - // Do the undoable on the last border - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BrushTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BrushTool.cpp deleted file mode 100644 index 27b8e758660..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BrushTool.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BrushTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - - -#include "StdAfx.h" -#include "resource.h" - -#include "BrushTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "brushoptions.h" -#include "DrawObject.h" -// -// BrushTool class. -// - -Int BrushTool::m_brushWidth; -Int BrushTool::m_brushFeather; -Bool BrushTool::m_brushSquare; -Int BrushTool::m_brushHeight; - - - -/// Constructor -BrushTool::BrushTool() : - Tool(ID_BRUSH_TOOL, IDC_BRUSH_CROSS) -{ - m_htMapEditCopy = nullptr; - m_htMapFeatherCopy = nullptr; - - m_brushWidth = 0; - m_brushFeather = 0; - m_brushHeight = 0; - m_brushSquare = false; -} - -/// Destructor -BrushTool::~BrushTool() -{ - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapFeatherCopy); -} - -/// Set the brush height and notify the height options panel of the change. -void BrushTool::setHeight(Int height) -{ - if (m_brushHeight != height) { - m_brushHeight = height; - // notify height palette options panel - BrushOptions::setHeight(height); - } -}; - -/// Set the brush width and notify the height options panel of the change. -void BrushTool::setWidth(Int width) -{ - if (m_brushWidth != width) { - m_brushWidth = width; - // notify brush palette options panel - BrushOptions::setWidth(width); - DrawObject::setBrushFeedbackParms(m_brushSquare, m_brushWidth, m_brushFeather); - } -}; - -/// Set the brush feather and notify the height options panel of the change. -void BrushTool::setFeather(Int feather) -{ - if (m_brushFeather != feather) { - m_brushFeather = feather; - // notify height palette options panel - BrushOptions::setFeather(feather); - DrawObject::setBrushFeedbackParms(m_brushSquare, m_brushWidth, m_brushFeather); - } -}; - -/// Shows the brush options panel. -void BrushTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_BRUSH_OPTIONS); - DrawObject::setDoBrushFeedback(true); - DrawObject::setBrushFeedbackParms(m_brushSquare, m_brushWidth, m_brushFeather); -} - -/// Start tool. -/** Setup the tool to start brushing - make a copy of the height map -to edit, another copy because we need it :), and call mouseMovedDown. */ -void BrushTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - // just in case, release it. - REF_PTR_RELEASE(m_htMapEditCopy); - m_htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - m_prevXIndex = -1; - m_prevYIndex = -1; - REF_PTR_RELEASE(m_htMapFeatherCopy); - m_htMapFeatherCopy = m_htMapEditCopy->duplicate(); - mouseMoved(m, viewPt, pView, pDoc); -} - -/// End tool. -/** Finish the tool operation - create a command, pass it to the -doc to execute, and cleanup ref'd objects. */ -void BrushTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, m_htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapFeatherCopy); -} - -/// Execute the tool. -/** Apply the height brush at the current point. */ -void BrushTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - DrawObject::setFeedbackPos(cpt); - - if (m != TRACK_L) return; - - pView->viewToDocCoords(viewPt, &cpt); - - int brushWidth = m_brushWidth; - if (m_brushFeather>0) { - brushWidth += 2*m_brushFeather; - } - brushWidth += 2; - - CPoint ndx; - getCenterIndex(&cpt, m_brushWidth, &ndx, pDoc); - - if (m_prevXIndex == ndx.x && m_prevYIndex == ndx.y) return; - - m_prevXIndex = ndx.x; - m_prevYIndex = ndx.y; - - int sub = brushWidth/2; - int add = brushWidth-sub; - - Int i, j; - for (i=ndx.x-sub; i=m_htMapEditCopy->getXExtent()) { - continue; - } - for (j=ndx.y-sub; j=m_htMapEditCopy->getYExtent()) { - continue; - } - Real blendFactor; - if (m_brushSquare) { - blendFactor = calcSquareBlendFactor(ndx, i, j, m_brushWidth, m_brushFeather); - } else { - blendFactor = calcRoundBlendFactor(ndx, i, j, m_brushWidth, m_brushFeather); - } - Int curHeight = m_htMapFeatherCopy->getHeight(i,j); - float fNewHeight = blendFactor*m_brushHeight+((1.0f-blendFactor)*curHeight) ; - Int newHeight = floor(fNewHeight+0.5); - if (m_brushHeight > curHeight) { - if (m_htMapEditCopy->getHeight(i,j)>newHeight) { - newHeight = m_htMapEditCopy->getHeight(i,j); - } - } else { - if (m_htMapEditCopy->getHeight(i,j)getHeight(i,j); - } - } - m_htMapEditCopy->setHeight(i, j, newHeight); - } - } - IRegion2D partialRange; - partialRange.lo.x = ndx.x - brushWidth; - partialRange.hi.x = ndx.x + brushWidth; - partialRange.lo.y = ndx.y - brushWidth; - partialRange.hi.y = ndx.y + brushWidth; - pDoc->updateHeightMap(m_htMapEditCopy, true, partialRange); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp deleted file mode 100644 index 12b1d28219c..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp +++ /dev/null @@ -1,789 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BuildList.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "BuildList.h" -#include "BuildListTool.h" -#include "BaseBuildProps.h" -#include "CUndoable.h" -#include "PointerTool.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "GameLogic/SidesList.h" -#include "Common/PlayerTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingTemplate.h" -#include "Common/WellKnownKeys.h" -#include "wbview3d.h" - -BuildList *BuildList::m_staticThis = nullptr; -Bool BuildList::m_updating = false; - - -///////////////////////////////////////////////////////////////////////////// -// BuildList dialog - - -BuildList::BuildList(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(BuildList) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -BuildList::~BuildList() -{ -} - - -void BuildList::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(BuildList) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(BuildList, COptionsPanel) - //{{AFX_MSG_MAP(BuildList) - ON_CBN_SELCHANGE(IDC_SIDES_COMBO, OnSelchangeSidesCombo) - ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp) - ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown) - ON_BN_CLICKED(IDC_ADD_BUILDING, OnAddBuilding) - ON_LBN_SELCHANGE(IDC_BUILD_LIST, OnSelchangeBuildList) - ON_BN_CLICKED(IDC_ALREADY_BUILD, OnAlreadyBuild) - ON_BN_CLICKED(IDC_DELETE_BUILDING, OnDeleteBuilding) - ON_CBN_SELENDOK(IDC_REBUILDS, OnSelendokRebuilds) - ON_CBN_EDITCHANGE(IDC_REBUILDS, OnEditchangeRebuilds) - ON_LBN_DBLCLK(IDC_BUILD_LIST, OnDblclkBuildList) - ON_EN_CHANGE(IDC_MAPOBJECT_ZOffset, OnChangeZOffset) - ON_EN_CHANGE(IDC_MAPOBJECT_Angle, OnChangeAngle) - ON_BN_CLICKED(IDC_EXPORT, OnExport) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// BuildList data access method. - - - -///////////////////////////////////////////////////////////////////////////// -// BuildList message handlers - -/// Setup the controls in the dialog. -BOOL BuildList::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_heightSlider.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - m_angleSlider.SetupPopSliderButton(this, IDC_ANGLE_POPUP, this); - - m_updating = true; - loadSides(); - m_curSide = 0; - updateCurSide(); - OnSelchangeBuildList(); - m_staticThis = this; - m_updating = false; - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/// Load the sides in the sides list. -void BuildList::loadSides() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_SIDES_COMBO); - if (!pCombo) { - DEBUG_LOG(("*** BuildList::loadSides Missing resource!!!")); - return; - } - pCombo->ResetContent(); - Int i; - for (i=0; igetNumSides(); i++) { - Dict *d = TheSidesList->getSideInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_playerName); - UnicodeString uni = d->getUnicodeString(TheKey_playerDisplayName); - AsciiString fmt; - if (name.isEmpty()) - fmt = "(neutral player, cannot be edited)"; - else - fmt.format("%s=\"%ls\"",name.str(),uni.str()); - pCombo->AddString(fmt.str()); - } - updateCurSide(); -} - -/// Updates the current side, loading it's build list. -void BuildList::updateCurSide() -{ - if (TheSidesList->getNumSides() < 1) - return; - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_SIDES_COMBO); - if (!pCombo) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!!")); - return; - } - if (m_curSide<0 || m_curSide >= TheSidesList->getNumSides()) { - m_curSide = 0; - } - if (pCombo->GetCurSel() != m_curSide) { - pCombo->SetCurSel(m_curSide); - } - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - pList->ResetContent(); - - BuildListInfo *pBuild = pSide->getBuildList(); - while (pBuild) { - const char *pName = pBuild->getTemplateName().str(); - pList->AddString(pName); - pBuild = pBuild->getNext(); - } - OnSelchangeBuildList(); -} - -void BuildList::OnSelchangeSidesCombo() -{ - if (TheSidesList->getNumSides() < 1) - return; - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_SIDES_COMBO); - if (!pCombo) { - DEBUG_LOG(("*** BuildList::OnSelchangeSidesCombo Missing resource!!!")); - return; - } - - if (pCombo->GetCurSel() != m_curSide) { - m_curSide = pCombo->GetCurSel(); - updateCurSide(); - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (pList) { - pList->SetCurSel(0); - } - OnSelchangeBuildList(); - } - -} - -void BuildList::OnMoveUp() -{ - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 1) return; - SidesList sides; - sides = *TheSidesList; - - SidesInfo *pSide = sides.getSideInfo(m_curSide); - Int count = m_curBuildList; - - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - Int newSel = m_curBuildList-1; - pSide->reorderInBuildList(pBuildInfo, newSel); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - updateCurSide(); - pList->SetCurSel(newSel); - OnSelchangeBuildList(); -} - -void BuildList::OnMoveDown() -{ - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - if (m_curBuildList < 0) return; - SidesList sides; - sides = *TheSidesList; - - SidesInfo *pSide = sides.getSideInfo(m_curSide); - m_curBuildList = pList->GetCurSel(); - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - if (pBuildInfo->getNext() == nullptr) { - // there isn't one to move down after. - return; - } - Int newSel = m_curBuildList+1; - - pSide->reorderInBuildList(pBuildInfo, newSel); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - updateCurSide(); - pList->SetCurSel(newSel); - OnSelchangeBuildList(); -} - -void BuildList::OnAddBuilding() -{ - BuildListTool::addBuilding(); -} - - -void BuildList::addBuilding(Coord3D loc, Real angle, AsciiString name) -{ - if (!m_staticThis) { - return; - } - BuildListInfo *pBuildInfo = newInstance( BuildListInfo); - pBuildInfo->setAngle(angle); - pBuildInfo->setTemplateName(name); - pBuildInfo->setLocation(loc); - - SidesList sides; - sides = *TheSidesList; - - SidesInfo *pSide = sides.getSideInfo(m_staticThis->m_curSide); - pSide->addToBuildList(pBuildInfo, 1000); // add at end. - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_staticThis->updateCurSide(); - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->invalBuildListItemInView(pBuildInfo); -}; - - -void BuildList::setSelectedBuildList(BuildListInfo *pInfo) -{ - if (!m_staticThis) { - return; - } - Int i; - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - Int listSel = 0; - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - if (pInfo == pBuild) { - pBuild->setSelected(true); -// CComboBox *pCombo = (CComboBox*)m_staticThis->GetDlgItem(IDC_SIDES_COMBO); - if (m_staticThis->m_curSide != i) { - m_staticThis->m_curSide = i; - m_staticThis->updateCurSide(); - } - CListBox *pList = (CListBox*)m_staticThis->GetDlgItem(IDC_BUILD_LIST); - pList->SetCurSel(listSel); - m_staticThis->OnSelchangeBuildList(); - } else { - pBuild->setSelected(false); - } - listSel++; - } - } -}; - - -void BuildList::OnSelchangeBuildList() -{ - if (TheSidesList->getNumSides() < 1) - return; - - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - m_curBuildList = pList->GetCurSel(); - Int numBL = pList->GetCount(); - - SidesInfo *pSide = nullptr; - if (TheSidesList) { - pSide = TheSidesList->getSideInfo(m_curSide); - } - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = nullptr; - if (pSide) { - pBuildInfo = pSide->getBuildList(); - } - if (count<0) pBuildInfo = nullptr; - while (count && pBuildInfo) { - count--; - pBuildInfo = pBuildInfo->getNext(); - } - - Bool enableUp=false; - Bool enableDown=false; - Bool enableAttrs = true; - - Int energyConsumption = 0; - Int energyProduction = 0; - Real energyUsed = 0.0f; - const Dict *playerDict = pSide->getDict(); - AsciiString playerName = playerDict->getAsciiString(TheKey_playerName); - - // add up energy consumed/produced by objects on the map - const ThingTemplate *thingTemplate; - for (MapObject *pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - // get thing template based from map object name - thingTemplate = pMapObj->getThingTemplate(); - if (!thingTemplate) - continue; - Dict *d = pMapObj->getProperties(); - Bool exists; - AsciiString objectTeamName = d->getAsciiString(TheKey_originalOwner, &exists); - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(objectTeamName); - Dict *teamDict = (teamInfo)?teamInfo->getDict():nullptr; - AsciiString objectOwnerName = (teamDict)?teamDict->getAsciiString(TheKey_teamOwner):AsciiString::TheEmptyString; - - Int energy = 0; - if (objectOwnerName.compareNoCase(playerName) == 0) - energy = thingTemplate->getEnergyProduction(); - - if (energy > 0) - energyProduction += energy; - else - energyConsumption -= energy; // keep it positive - } - - // add up energy consumed/produced by objects in the build list - { - count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - if (count<0) pBuildInfo = nullptr; - while (count>=0 && pBuildInfo) { - AsciiString tName = pBuildInfo->getTemplateName(); - const ThingTemplate *templ = TheThingFactory->findTemplate(tName); - if (!templ) - break; - - Int energy = templ->getEnergyProduction(); - - if (energy > 0) - energyProduction += energy; - else - energyConsumption -= energy; // keep it positive - - count--; - pBuildInfo = pBuildInfo->getNext(); - } - } - - if (energyProduction) - { - energyUsed = (Real)energyConsumption/(Real)energyProduction; - energyUsed = min(1.0f, energyUsed); - energyUsed = max(0.0f, energyUsed); - } - else if (energyConsumption) - { - energyUsed = 1.0f; - } - //DEBUG_LOG(("Energy: %d/%d - %g", energyConsumption, energyProduction, energyUsed)); - CProgressCtrl *progressWnd = (CProgressCtrl *)GetDlgItem(IDC_POWER); - if (progressWnd) - { - progressWnd->EnableWindow(true); - progressWnd->SetPos((Int)((1.0f-energyUsed)*100)); - } - - if (pBuildInfo==nullptr) { - enableAttrs = false; - } - if (m_curBuildList > 0) { - enableUp = true; - } - if (m_curBuildList >= 0 && m_curBuildList < numBL-1) { - enableDown = true; - } - CWnd *pWnd = GetDlgItem(IDC_MOVE_UP); - if (pWnd) pWnd->EnableWindow(enableUp); - pWnd = GetDlgItem(IDC_MOVE_DOWN); - if (pWnd) pWnd->EnableWindow(enableDown); - pWnd = GetDlgItem(IDC_ALREADY_BUILD); - if (pWnd) pWnd->EnableWindow(enableAttrs); - pWnd = GetDlgItem(IDC_REBUILDS); - if (pWnd) pWnd->EnableWindow(enableAttrs); - pWnd = GetDlgItem(IDC_DELETE_BUILDING); - if (pWnd) pWnd->EnableWindow(enableAttrs); - PointerTool::clearSelection(); // unselect other stuff. - if (pBuildInfo) { - CWnd *edit; - static char buff[32]; - pBuildInfo->setSelected(true); - - m_angle = pBuildInfo->getAngle() * 180/PI; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle); - edit = GetDlgItem(IDC_MAPOBJECT_Angle); - edit->SetWindowText(buff); - - m_height = pBuildInfo->getLocation()->z; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_height); - edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - edit->SetWindowText(buff); - - CButton *pBtn = (CButton *)GetDlgItem(IDC_ALREADY_BUILD); - if (pBtn) pBtn->SetCheck(pBuildInfo->isInitiallyBuilt()?1:0); - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_REBUILDS); - if (pCombo==nullptr) return; - UnsignedInt nr = pBuildInfo->getNumRebuilds(); - if (nr == BuildListInfo::UNLIMITED_REBUILDS) { - pCombo->SetCurSel(6); - } else if (nr<6) { - pCombo->SetCurSel(nr); - } else { - CString str; - str.Format("%d", nr); - pCombo->SetWindowText(str); - } - } - - -} - -void BuildList::OnAlreadyBuild() -{ - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - CButton *pBtn = (CButton *)GetDlgItem(IDC_ALREADY_BUILD); - if (pBtn) { - pBuildInfo->setInitiallyBuilt(pBtn->GetCheck()==1); - } -} - -void BuildList::OnDeleteBuilding() -{ - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - if (!pList) { - DEBUG_LOG(("*** BuildList::updateCurSide Missing resource!!! IDC_BUILD_LIST")); - return; - } - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 0) return; - SidesList sides; - sides = *TheSidesList; - - SidesInfo *pSide = sides.getSideInfo(m_curSide); - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - pSide->removeFromBuildList(pBuildInfo); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - updateCurSide(); - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->invalBuildListItemInView(pBuildInfo); - pList->SetCurSel(-1); -} - -void BuildList::OnSelendokRebuilds() -{ - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_REBUILDS); - if (pCombo==nullptr) return; - Int sel = pCombo->GetCurSel(); - if (sel<0) return; // no selection. - UnsignedInt nr; - if (sel == 6) { - nr = BuildListInfo::UNLIMITED_REBUILDS; - } else if (sel<6) { - nr = sel; - } - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - pBuildInfo->setNumRebuilds(nr); -} - -void BuildList::OnEditchangeRebuilds() -{ - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_REBUILDS); - if (pCombo==nullptr) return; - Int sel = pCombo->GetCurSel(); - if (sel>=0) return; // An entry is selected, and handled by OnSelendokRebuilds.. - char buffer[_MAX_PATH]; - if (pCombo) { - pCombo->GetWindowText(buffer, sizeof(buffer)); - Int nr; - if (1==sscanf(buffer, "%d", &nr)) { - } - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - pBuildInfo->setNumRebuilds(nr); - } -} - -void BuildList::OnDblclkBuildList() -{ - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBI = pSide->getBuildList(); - while (count) { - count--; - pBI = pBI->getNext(); - if (pBI == nullptr) return; - } - - BaseBuildProps dlg; - dlg.setProps(pBI->getBuildingName(), pBI->getScript(), pBI->getHealth(), pBI->getUnsellable()); - if (dlg.DoModal() == IDOK) { - pBI->setBuildingName(dlg.getName()); - pBI->setScript(dlg.getScript()); - pBI->setHealth(dlg.getHealth()); - pBI->setUnsellable(dlg.getUnsellable()); - } -} - -void BuildList::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_HEIGHT_POPUP: - *pMin = -50; - *pMax = 50; - *pInitial = m_height; - *pLineSize = 1; - break; - - case IDC_ANGLE_POPUP: - *pMin = 0; - *pMax = 360; - *pInitial = m_angle; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void BuildList::PopSliderChanged(const long sliderID, long theVal) -{ -// CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - CWnd* edit; - static char buff[32]; - switch (sliderID) { - case IDC_HEIGHT_POPUP: - m_height = theVal; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_height); - edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - edit->SetWindowText(buff); - OnChangeZOffset(); - break; - - case IDC_ANGLE_POPUP: - m_angle = theVal; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle); - edit = GetDlgItem(IDC_MAPOBJECT_Angle); - edit->SetWindowText(buff); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void BuildList::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_HEIGHT_POPUP: - case IDC_ANGLE_POPUP: - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - -void BuildList::OnChangeZOffset() -{ - Real value = 0.0f; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atof(cstr); - } - m_height = value; - - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - Coord3D loc = *pBuildInfo->getLocation(); - loc.z = m_height; - pBuildInfo->setLocation(loc); - WbView3d *p3View = CWorldBuilderDoc::GetActiveDoc()->GetActive3DView(); - p3View->invalBuildListItemInView(pBuildInfo); -} - -void BuildList::OnChangeAngle() -{ - Real angle = 0.0f; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_Angle); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - angle = atof(cstr); - } - m_angle = angle; - SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); - CListBox *pList = (CListBox*)GetDlgItem(IDC_BUILD_LIST); - m_curBuildList = pList->GetCurSel(); - if (m_curBuildList < 0) return; - Int count = m_curBuildList; - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (count) { - count--; - pBuildInfo = pBuildInfo->getNext(); - if (pBuildInfo == nullptr) return; - } - pBuildInfo->setAngle(m_angle * PI/180); - WbView3d *p3View = CWorldBuilderDoc::GetActiveDoc()->GetActive3DView(); - p3View->invalBuildListItemInView(pBuildInfo); -} - -void BuildList::OnExport() -{ - static FILE *theLogFile = nullptr; - Bool open = false; - try { - char buffer[_MAX_PATH]; - ::GetModuleFileName(nullptr, buffer, sizeof(buffer)); - if (char* pEnd = strrchr(buffer, '\\')) - { - *(pEnd + 1) = 0; - } - - SidesInfo* pSide = TheSidesList->getSideInfo(m_curSide); - Dict* d = TheSidesList->getSideInfo(m_curSide)->getDict(); - AsciiString name = d->getAsciiString(TheKey_playerName); - strlcat(buffer, name.str(), ARRAY_SIZE(buffer)); - strlcat(buffer, "_BuildList.ini", ARRAY_SIZE(buffer)); - - theLogFile = fopen(buffer, "w"); - if (theLogFile == nullptr) - throw; - - AsciiString tmplname = d->getAsciiString(TheKey_playerFaction); - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname)); - DEBUG_ASSERTCRASH(pt != nullptr, ("PlayerTemplate %s not found -- this is an obsolete map (please open and resave in WB)",tmplname.str())); - - fprintf(theLogFile, ";Skirmish AI Build List\n"); - fprintf(theLogFile, "SkirmishBuildList %s\n", pt->getSide().str()); - - open = true; - - BuildListInfo *pBuildInfo = pSide->getBuildList(); - while (pBuildInfo) { - fprintf(theLogFile, " Structure %s\n", pBuildInfo->getTemplateName().str()); - if (!pBuildInfo->getBuildingName().isEmpty()) { - fprintf(theLogFile, " Name = %s\n", pBuildInfo->getBuildingName().str()); - } - fprintf(theLogFile, " Location = X:%.2f Y:%.2f\n", pBuildInfo->getLocation()->x, pBuildInfo->getLocation()->y); - fprintf(theLogFile, " Rebuilds = %d\n", pBuildInfo->getNumRebuilds()); - fprintf(theLogFile, " Angle = %.2f\n", pBuildInfo->getAngle()*180/PI); - fprintf(theLogFile, " InitiallyBuilt = %s\n", pBuildInfo->isInitiallyBuilt()?"Yes":"No"); - fprintf(theLogFile, " AutomaticallyBuild = %s\n", false?"Yes":"No"); - fprintf(theLogFile, " END ;Structure %s\n", pBuildInfo->getTemplateName().str()); - pBuildInfo = pBuildInfo->getNext(); - } - fprintf(theLogFile, "END ;SkirmishBuildList %s\n", tmplname.str()); - fclose(theLogFile); - open = false; - } catch (...) { - if (open) { - fclose(theLogFile); - } - } - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildListTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BuildListTool.cpp deleted file mode 100644 index e935114202d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildListTool.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// BuildListTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "BuildListTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "ObjectTool.h" -#include "PointerTool.h" -#include "PickUnitDialog.h" -#include "wbview3d.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "GameLogic/SidesList.h" -// -// BuildListTool class. -// - -Bool BuildListTool::m_isActive = false; -PickUnitDialog* BuildListTool::m_static_pickBuildingDlg = nullptr; - -/// Constructor -BuildListTool::BuildListTool() : - Tool(ID_BUILD_LIST_TOOL, IDC_BUILD_LIST_TOOL), - m_rotateCursor(nullptr), - m_pointerCursor(nullptr), - m_moveCursor(nullptr), - m_created(false) -{ - m_curObject = nullptr; -} - -/// Destructor -BuildListTool::~BuildListTool() -{ -} - -void BuildListTool::createWindow() -{ - CRect frameRect; - frameRect.top = ::AfxGetApp()->GetProfileInt(BUILD_PICK_PANEL_SECTION, "Top", 0); - frameRect.left =::AfxGetApp()->GetProfileInt(BUILD_PICK_PANEL_SECTION, "Left", 0); - - m_pickBuildingDlg.SetAllowableType(ES_STRUCTURE); - m_pickBuildingDlg.SetFactionOnly(true); - m_pickBuildingDlg.Create(IDD_PICKUNIT, CMainFrame::GetMainFrame()); - m_pickBuildingDlg.SetupAsPanel(); - m_pickBuildingDlg.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_static_pickBuildingDlg = &m_pickBuildingDlg; - m_created = true; -} - -Bool BuildListTool::isDoingAdd() -{ - if (!m_created) { - return false; - } - if (!m_pickBuildingDlg.IsWindowVisible()) { - return false; - } - if (m_pickBuildingDlg.getPickedUnit() == AsciiString::TheEmptyString) { - return false; - } - return true; -} - -/// Shows the object options panel. -void BuildListTool::addBuilding() -{ - //PickUnitDialog dlg; - //dlg.SetAllowableType(ES_STRUCTURE); - //dlg.SetFactionOnly(true); - //if (dlg.DoModal() == IDOK) { - //} - //CMainFrame::GetMainFrame()->showOptionsDialog(IDD_OBJECT_OPTIONS); - m_static_pickBuildingDlg->ShowWindow(SW_SHOWNA); -} - -/// Shows the object options panel. -void BuildListTool::activate() -{ - Bool wasActive = m_isActive; - m_isActive = true; - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_BUILD_LIST_PANEL); - DrawObject::setDoBrushFeedback(false); - BuildList::update(); - WbView3d *p3View = CWorldBuilderDoc::GetActive3DView(); - if (!wasActive) - { - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } - if (!m_created) { - createWindow(); - } - m_pickBuildingDlg.ShowWindow(SW_SHOWNA); -} - -/// Clears the isActive flag. -void BuildListTool::deactivate() -{ - m_isActive = false; - WbView3d *p3View = CWorldBuilderDoc::GetActive3DView(); - Coord3D loc; - loc.x=loc.y=loc.z=0; - p3View->setObjTracking(nullptr, loc, 0, false); // Turn off object cursor tracking. - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - m_pickBuildingDlg.ShowWindow(SW_HIDE); -} - -/** Set the cursor. */ -void BuildListTool::setCursor() -{ - if (isDoingAdd()) { - Tool::setCursor(); // Default cursor is the adding cursor - } else if (m_mouseUpMove) { - if (m_moveCursor == nullptr) { - m_moveCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_BUILD_MOVE)); - } - ::SetCursor(m_moveCursor); - } else if (m_mouseUpRotate) { - if (m_rotateCursor == nullptr) { - m_rotateCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_BUILD_ROTATE)); - } - ::SetCursor(m_rotateCursor); - } else { - if (m_pointerCursor == nullptr) { - m_pointerCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_BUILD_POINTER)); - } - ::SetCursor(m_pointerCursor); - } -} - -/** Execute the tool on mouse down - Place an object. */ -void BuildListTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - m_moving = false; - m_rotating = false; - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - m_downPt2d = viewPt; - m_downPt3d = cpt; - if (isDoingAdd()) return; - BuildListInfo *pInfo = pView->pickedBuildObjectInView(viewPt); - if (pInfo) { - m_curObject = pInfo; - Coord3D center = *pInfo->getLocation(); - center.x -= m_downPt3d.x; - center.y -= m_downPt3d.y; - center.z = 0; - Real len = center.length(); - // Check and see if we are within 1 cell size of the center. - if (pInfo->isSelected() && len>0.5f*MAP_XY_FACTOR && len < 1.5f*MAP_XY_FACTOR) { - m_rotating = true; - } - m_moving = true; - m_prevPt3d = m_downPt3d; - pView->snapPoint(&m_prevPt3d); - BuildList::setSelectedBuildList(pInfo); - } else { - PointerTool::clearSelection(); - } -} - -void BuildListTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt, false); - - WbView3d *p3View = pDoc->GetActive3DView(); - if (isDoingAdd()) { - Coord3D loc = cpt; - MapObject *pCur = ObjectOptions::getObjectNamed(m_pickBuildingDlg.getPickedUnit()); - loc.z = 0; - if (pCur) { - // Display the transparent version of this object. - p3View->setObjTracking(pCur, loc, 0, true); - } else { - // Don't display anything. - p3View->setObjTracking(nullptr, loc, 0, false); - } - return; - } - p3View->setObjTracking(nullptr, cpt, 0, false); - - if (m == TRACK_NONE) { - // See if the cursor is over an object. - BuildListInfo *pInfo = pView->pickedBuildObjectInView(viewPt); - m_mouseUpMove = false; - m_mouseUpRotate = false; - if (pInfo) { - Coord3D center = *pInfo->getLocation(); - center.x -= cpt.x; - center.y -= cpt.y; - center.z = 0; - Real len = center.length(); - // Check and see if we are within 1 cell size of the center. - if (pInfo->isSelected() && len>0.5f*MAP_XY_FACTOR && len < 1.5f*MAP_XY_FACTOR) { - m_mouseUpRotate = true; - } else { - m_mouseUpMove = true; - } - } - return; // setCursor will use the value of m_mouseUpRotate. jba. - } - - if (m != TRACK_L) return; - if (!m_moving || !m_curObject) return; - - Coord3D loc = *m_curObject->getLocation(); - if (m_rotating) { - Real angle = ObjectTool::calcAngle(m_downPt3d, cpt, pView); - m_curObject->setAngle(angle); - } else { - pView->snapPoint(&cpt); - Real xOffset = (cpt.x-m_prevPt3d.x); - Real yOffset = (cpt.y-m_prevPt3d.y); - loc.x += xOffset; - loc.y += yOffset; - m_curObject->setLocation(loc); - } - p3View->invalBuildListItemInView(m_curObject); - m_prevPt3d = cpt; - -} - - - -/** Execute the tool on mouse up - Place an object. */ -void BuildListTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - if (!isDoingAdd()) { - // Update the cursor. - mouseMoved(TRACK_NONE, viewPt, pView, pDoc); - setCursor(); - return; - } - // always check hysteresis in view coords. - enum {HYSTERESIS = 3}; - Bool justAClick = (abs(viewPt.x - m_downPt2d.x)viewToDocCoords(viewPt, &cpt, false); // Don't constrain. - - Coord3D loc = m_downPt3d; - pView->snapPoint(&loc); - loc.z = ObjectOptions::getCurObjectHeight(); - Real angle = justAClick ? 0 : ObjectTool::calcAngle(loc, cpt, pView); - if (!m_pickBuildingDlg.getPickedUnit().isEmpty()) { - BuildList::addBuilding(loc, angle, m_pickBuildingDlg.getPickedUnit()); - } - //CMainFrame::GetMainFrame()->showOptionsDialog(IDD_BUILD_LIST_PANEL); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp deleted file mode 100644 index c90376306ca..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/CButtonShowColor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "StdAfx.h" - -#include "GameClient/ParticleSys.h" -#include "CButtonShowColor.h" - -// CButtonShowColor /////////////////////////////////////////////////////////////////////////////// -void CButtonShowColor::OnPaint() -{ - try { - CPaintDC paintDC(this); - - CPen pen(PS_SOLID, 1, 0xFFFFFF00); - CBrush brush(RGBtoBGR(m_color.getAsInt())); - // Select my stuff - CPen *oldPen = paintDC.SelectObject(&pen); - - CRect rect; - GetWindowRect(&rect); - ScreenToClient(&rect); - - paintDC.FillRect(&rect, &brush); - paintDC.MoveTo(rect.left, rect.top); - paintDC.LineTo(rect.right, rect.top); - paintDC.LineTo(rect.right, rect.bottom); - paintDC.LineTo(rect.left, rect.bottom); - paintDC.LineTo(rect.left, rect.top); - - // Restore the states. - paintDC.SelectObject(oldPen); - - } catch (...) { - // Unlikely, but possible. - return; - } -} - -CButtonShowColor::~CButtonShowColor() -{ - DestroyWindow(); -} - -// Convert from 0x00RRGGBB to 0x00BBGGRR -COLORREF CButtonShowColor::RGBtoBGR(Int color) -{ - return ((color & 0x00FF0000) >> 16 | - (color & 0x0000FF00) << 0 | - (color & 0x000000FF) << 16); -} - -// Convert from 0x00BBGGRR to 0x00RRGGBB -Int CButtonShowColor::BGRtoRGB(COLORREF color) -{ - return RGBtoBGR(color); -} - -BEGIN_MESSAGE_MAP(CButtonShowColor, CButton) - ON_WM_PAINT() -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp deleted file mode 100644 index fca3eb953f0..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/CFixTeamOwnerDialog.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "StdAfx.h" -#include "resource.h" -#include "CFixTeamOwnerDialog.h" -#include "GameLogic/SidesList.h" -#include "Common/WellKnownKeys.h" - -static const char* NEUTRAL_NAME_STR = "(neutral)"; - -CFixTeamOwnerDialog::CFixTeamOwnerDialog( TeamsInfo *ti, SidesList *sl, UINT nIDTemplate, CWnd* pParentWnd) : CDialog( nIDTemplate, pParentWnd ) -{ - m_ti = ti; - m_sl = sl; - m_pickedValidTeam = false; -} - -AsciiString CFixTeamOwnerDialog::getSelectedOwner() -{ - return m_selectedOwner; -} - -BOOL CFixTeamOwnerDialog::OnInitDialog() -{ - AsciiString teamName = "No Name"; - - Bool exists; - AsciiString temp = m_ti->getDict()->getAsciiString(TheKey_teamName, &exists); - if (exists) { - teamName = temp; - } - - CString loadStr; - loadStr.Format(IDS_REPLACEOWNER, teamName.str()); - CWnd *pWnd = GetDlgItem(IDC_REPLACETHISTEXT); - pWnd->SetWindowText(loadStr); - - // now load all of the things with the other things - Int numSides = m_sl->getNumSides(); - CListBox *pList = (CListBox*) GetDlgItem(IDC_VALIDTEAMLIST); - - for (Int i = 0; i < numSides; ++i) { - SidesInfo *si = m_sl->getSideInfo(i); - if (!si) { - continue; - } - - Bool displayExists; - AsciiString displayName = si->getDict()->getAsciiString(TheKey_playerDisplayName, &displayExists); - if (displayExists) { - if (displayName.isEmpty()) { - displayName = NEUTRAL_NAME_STR; - } - pList->InsertString(-1, displayName.str()); - } else { - AsciiString internalName = si->getDict()->getAsciiString(TheKey_playerName, &displayExists); - if (internalName.isEmpty()) { - internalName = NEUTRAL_NAME_STR; - } - pList->InsertString(-1, internalName.str()); - } - } - - return FALSE; -} - -void CFixTeamOwnerDialog::OnOK() -{ - CDialog::OnOK(); - - CListBox *pList = (CListBox*) GetDlgItem(IDC_VALIDTEAMLIST); - int curSel = pList->GetCurSel(); - - if (curSel < 0) { - return; - } - - SidesInfo *si = m_sl->getSideInfo(curSel); - if (!si) { - return; - } - - m_pickedValidTeam = true; - Bool exists; - m_selectedOwner = si->getDict()->getAsciiString(TheKey_playerName, &exists); -} - -BEGIN_MESSAGE_MAP(CFixTeamOwnerDialog, CDialog) -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/CUndoable.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/CUndoable.cpp deleted file mode 100644 index 93d9ee1ce0e..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/CUndoable.cpp +++ /dev/null @@ -1,1445 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// CUndoable.cpp -// Class to handle undo/redo. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "CUndoable.h" -#include "PointerTool.h" -#include "RoadTool.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/SidesList.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/Debug.h" -#include "mapobjectprops.h" -#include "ObjectOptions.h" -#include "BuildList.h" -#include "wbview3d.h" -#include "LayersList.h" -#include "Common/WellKnownKeys.h" -#include "WorldBuilder.h" // for MAX_OBJECTS_IN_MAP -#include "Common/UnicodeString.h" - - -// base mostly virtual class. - -// -/// Undoable - destructor. -// -Undoable::~Undoable() -{ - REF_PTR_RELEASE(mNext); -} - - -// -/// Create a new undoable. -// -Undoable::Undoable(): - mNext(nullptr) -{ -} - -// -/// Link another undoable to this. -// -void Undoable::LinkNext(Undoable *pNext) -{ - REF_PTR_SET(mNext, pNext); -} - -// -/// Redo defaults to Do(). -// -void Undoable::Redo() -{ - Do(); -} - - -/************************************************************************* -** WBDocUndoable - An undoable that actually undoes something. Saves the entire height map - state, and restores it. -***************************************************************************/ -// -/// destructor. -// -WBDocUndoable::~WBDocUndoable() -{ - REF_PTR_RELEASE(mPNewHeightMapData); - REF_PTR_RELEASE(mPOldHeightMapData); - mPDoc = nullptr; // not ref counted. -} - - -// -/// Create a new undoable. -// -WBDocUndoable::WBDocUndoable(CWorldBuilderDoc *pDoc, WorldHeightMapEdit *pNewHtMap, Coord3D *pObjOffset): - mPNewHeightMapData(nullptr), - mPOldHeightMapData(nullptr), - mPDoc(nullptr) -{ - if (pObjOffset) { - m_offsetObjects = true; - m_objOffset = *pObjOffset; - } else { - m_offsetObjects = false; - m_objOffset.x = m_objOffset.y = m_objOffset.z = 0; - } - REF_PTR_SET(mPNewHeightMapData, pNewHtMap); - REF_PTR_SET(mPOldHeightMapData, pDoc->GetHeightMap()); - mPDoc = pDoc; // not ref counted. -} - -// -/// Set the new height map. -// -void WBDocUndoable::Do() -{ - mPDoc->SetHeightMap(mPNewHeightMapData, false); // SetHeightMap but don't inval. - if (m_offsetObjects) { - MapObject *pCur = MapObject::getFirstMapObject(); - while (pCur) { - Coord3D loc = *pCur->getLocation(); - loc.x += m_objOffset.x; - loc.y += m_objOffset.y; - loc.z += m_objOffset.z; - pCur->setLocation(&loc); - pCur = pCur->getNext(); - } - Int i; - // Update build lists. - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - // Update. - Coord3D loc = *pBuild->getLocation(); - loc.x += m_objOffset.x; - loc.y += m_objOffset.y; - loc.z += m_objOffset.z; - pBuild->setLocation(loc); - } - } - mPDoc->invalObject(nullptr); // Inval all objects. - } - mPNewHeightMapData->dbgVerifyAfterUndo(); -} - -// -/// Set the new height map. -// -void WBDocUndoable::Redo() -{ - // Cause the terrain texture to be regenerated. - mPNewHeightMapData->resetResources(); - mPNewHeightMapData->getTerrainTexture(); - - mPDoc->SetHeightMap(mPNewHeightMapData, true); // SetHeightMap and inval the world. - if (m_offsetObjects) { - MapObject *pCur = MapObject::getFirstMapObject(); - while (pCur) { - Coord3D loc = *pCur->getLocation(); - loc.x += m_objOffset.x; - loc.y += m_objOffset.y; - loc.z += m_objOffset.z; - pCur->setLocation(&loc); - pCur = pCur->getNext(); - } - mPDoc->invalObject(nullptr); // Inval all objects. - } - mPNewHeightMapData->dbgVerifyAfterUndo(); -} - -// -/// Restore the old height map. -// -void WBDocUndoable::Undo() -{ - // Cause the terrain texture to be regenerated. - mPOldHeightMapData->resetResources(); - mPOldHeightMapData->getTerrainTexture(); - - mPDoc->SetHeightMap(mPOldHeightMapData, true); // SetHeightMap and inval the world. - if (m_offsetObjects) { - MapObject *pCur = MapObject::getFirstMapObject(); - while (pCur) { - Coord3D loc = *pCur->getLocation(); - loc.x -= m_objOffset.x; - loc.y -= m_objOffset.y; - loc.z -= m_objOffset.z; - pCur->setLocation(&loc); - pCur = pCur->getNext(); - } - mPDoc->invalObject(nullptr); // Inval all objects. - } - mPOldHeightMapData->dbgVerifyAfterUndo(); -} - -/************************************************************************* -** AddObjectUndoable -***************************************************************************/ -// -// AddObjectUndoable - destructor. -// -AddObjectUndoable::~AddObjectUndoable() -{ - m_pDoc = nullptr; // not ref counted. - if (!m_addedToList) { - deleteInstance(m_objectToAdd); - m_objectToAdd=nullptr; - } -} - - -// -// AddObjectUndoable - create a new undoable. -// -AddObjectUndoable::AddObjectUndoable(CWorldBuilderDoc *pDoc, MapObject *pObjectToAdd): - m_pDoc(nullptr), - m_numObjects(0), - m_addedToList(false), - m_objectToAdd(nullptr) -{ - m_pDoc = pDoc; // not ref counted. - m_objectToAdd = pObjectToAdd; -} - -// -/// Set the new mipping values, and force an inval of the windows. -// -void AddObjectUndoable::Do() -{ -// WorldHeightMapEdit *pMap = m_pDoc->GetHeightMap(); - MapObject *pCur = m_objectToAdd; - MapObject *pLast = nullptr; - - // Clear selection. - PointerTool::clearSelection(); - m_numObjects = 0; - while (pCur) { - if (!pCur->getFlag(FLAG_ROAD_FLAGS) && !pCur->getFlag(FLAG_BRIDGE_FLAGS) && !pCur->isWaypoint()) - { - pCur->setSelected(true); - } - pLast = pCur; - m_numObjects++; - pCur = pCur->getNext(); - } - if (pLast==nullptr) { - return; - } - pLast->setNextMap(MapObject::getFirstMapObject()); - - MapObject::TheMapObjectListPtr = m_objectToAdd; - m_addedToList = true; - - pCur = m_objectToAdd; - for (int i = 0; i < m_numObjects; i++) { - // validate the object, giving it a valid ID and team. - pCur->validate(); - Dict *props = pCur->getProperties(); - Bool dontCare; - TheLayersList->addMapObjectToLayersList(pCur, props->getAsciiString(TheKey_objectLayer, &dontCare)); - - m_pDoc->invalObject(pCur); - pCur = pCur->getNext(); - } - - pCur = MapObject::getFirstMapObject(); - - const Int flagsWeDontWant = FLAG_ROAD_FLAGS | FLAG_ROAD_CORNER_ANGLED | FLAG_BRIDGE_FLAGS | FLAG_ROAD_CORNER_TIGHT | FLAG_ROAD_JOIN; - - Int numObjects = 0; - while (pCur) { - Int flags = pCur->getFlags(); - if (!(pCur->isWaypoint() || (flags & flagsWeDontWant) != 0)) - ++numObjects; - - pCur = pCur->getNext(); - } - - if (numObjects >= MAX_OBJECTS_IN_MAP) { - CString str, loadStr; - loadStr.Format(IDS_MAX_OBJECTS, MAX_OBJECTS_IN_MAP); - AfxMessageBox(loadStr, MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK); - } -} - -// -// Restore the old mipping values, and inval. -// -void AddObjectUndoable::Undo() -{ -// WorldHeightMapEdit *pMap = m_pDoc->GetHeightMap(); - DEBUG_ASSERTCRASH(m_addedToList,("oops")); - DEBUG_ASSERTCRASH(m_objectToAdd == MapObject::TheMapObjectListPtr,("oops")); - if (!m_addedToList || m_objectToAdd!=MapObject::TheMapObjectListPtr) { - return; - } - MapObject *pCur = MapObject::TheMapObjectListPtr; - while (pCur && (m_numObjects > 1)) { - m_pDoc->invalObject(pCur); - pCur = pCur->getNext(); - m_numObjects--; - } - if ((m_numObjects == 1) && pCur) { - MapObject::TheMapObjectListPtr = pCur->getNext(); - pCur->setNextMap(nullptr); - m_addedToList = false; - } - pCur = m_objectToAdd; - while (pCur) { - m_pDoc->invalObject(pCur); - // Note : This undoable can add multiple objects, and removes multiple objects. - TheLayersList->removeMapObjectFromLayersList(pCur); - pCur = pCur->getNext(); - } - -} - -/************************************************************************* -** MoveInfo -***************************************************************************/ -MoveInfo::~MoveInfo() -{ - m_objectToModify=nullptr; // The map info list owns these, don't delete. - MoveInfo *pCur = m_next; - MoveInfo *tmp; - while (pCur) { - tmp = pCur; - pCur = tmp->m_next; - tmp->m_next = nullptr; - delete tmp; - } -} - -MoveInfo::MoveInfo( MapObject *pObjToMove): - m_next(nullptr) -{ - m_objectToModify = pObjToMove; // Not copied. - m_newAngle = m_objectToModify->getAngle(); - m_newLocation = *m_objectToModify->getLocation(); - m_oldAngle = m_objectToModify->getAngle(); - m_oldLocation = *m_objectToModify->getLocation(); - m_newThing = m_objectToModify->getThingTemplate(); - m_oldThing = m_objectToModify->getThingTemplate(); -} - -// -/// Sets the offset for all the objects in the move list, and moves them there. -// -void MoveInfo::SetOffset(CWorldBuilderDoc *pDoc, Real x, Real y) -{ - m_newLocation = m_oldLocation; - m_newLocation.x += x; - m_newLocation.y += y; - if (m_objectToModify->getFlag(FLAG_ROAD_POINT1) || m_objectToModify->getFlag(FLAG_ROAD_POINT2)) { - RoadTool::snap(&m_newLocation, false); - } - DoMove(pDoc); -} - -void MoveInfo::SetZOffset(CWorldBuilderDoc *pDoc, Real z) -{ - m_newLocation = m_oldLocation; - m_newLocation.z = z; - if (m_objectToModify->getFlag(FLAG_ROAD_POINT1) || m_objectToModify->getFlag(FLAG_ROAD_POINT2)) { - RoadTool::snap(&m_newLocation, false); - } - DoMove(pDoc); -} - -void MoveInfo::SetThingTemplate(CWorldBuilderDoc *pDoc, const ThingTemplate* thing) -{ - m_newThing = thing; - DoMove(pDoc); -} - -void MoveInfo::SetName(CWorldBuilderDoc *pDoc, AsciiString name) -{ - m_newName = name; - DoMove(pDoc); -} - -// -/// Set the angle for all objects in the move list. -// -void MoveInfo::RotateTo(CWorldBuilderDoc *pDoc, Real angle) -{ - m_newAngle = angle; - DoMove(pDoc); -} - -// -/// Move the object. -// -void MoveInfo::DoMove(CWorldBuilderDoc *pDoc) -{ - pDoc->invalObject(m_objectToModify); - m_objectToModify->setAngle(m_newAngle); - m_objectToModify->setLocation(&m_newLocation); - pDoc->invalObject(m_objectToModify); - - if (m_newThing != m_oldThing) { - m_objectToModify->setThingTemplate(m_newThing); - } - if (m_newName != m_oldName) { - m_objectToModify->setName(m_newName); - } -} - -void MoveInfo::UndoMove(CWorldBuilderDoc *pDoc) -{ - pDoc->invalObject(m_objectToModify); - m_objectToModify->setAngle(m_oldAngle); - m_objectToModify->setLocation(&m_oldLocation); - pDoc->invalObject(m_objectToModify); - - if (m_newThing != m_oldThing) { - m_objectToModify->setThingTemplate(m_oldThing); - } - if (m_newName != m_oldName) { - m_objectToModify->setName(m_oldName); - } -} - -/************************************************************************* -** ModifyObjectUndoable -***************************************************************************/ -// -// ModifyObjectUndoable - destructor. -// -ModifyObjectUndoable::~ModifyObjectUndoable() -{ - m_pDoc = nullptr; // not ref counted. - if (m_moveList) { - delete m_moveList; - } - m_moveList = nullptr; -} - -// -// ModifyObjectUndoable - create a new undoable. -// -ModifyObjectUndoable::ModifyObjectUndoable(CWorldBuilderDoc *pDoc): - m_pDoc(nullptr), - m_moveList(nullptr), - m_inval(false) -{ - m_pDoc = pDoc; // not ref counted. - MapObject *curMapObj = MapObject::getFirstMapObject(); - MoveInfo *pCurInfo = nullptr; - while (curMapObj) { - if (curMapObj->isSelected()) { - MoveInfo *pNew = new MoveInfo(curMapObj); - if (pCurInfo == nullptr) { - m_moveList = pNew; - } else { - pCurInfo->m_next = pNew; - } - pCurInfo = pNew; - } - curMapObj = curMapObj->getNext(); - } -} - -// -/// Sets the offset for all the objects in the move list, and moves them there. -// -void ModifyObjectUndoable::SetOffset(Real x, Real y) -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->SetOffset(m_pDoc, x, y); - pCur = pCur->m_next; - } -// m_pDoc->updateAllViews(); -} - -void ModifyObjectUndoable::SetZOffset(Real z) -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->SetZOffset(m_pDoc, z); - pCur = pCur->m_next; - } -} - -// -/// Set the angle for all objects in the move list. -// -void ModifyObjectUndoable::RotateTo(Real angle) -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->RotateTo(m_pDoc, angle); - pCur = pCur->m_next; - } -// m_pDoc->updateAllViews(); -} - -void ModifyObjectUndoable::SetThingTemplate(const ThingTemplate* thing) -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->SetThingTemplate(m_pDoc, thing); - pCur = pCur->m_next; - } - m_inval = true; - if (m_inval) - { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -void ModifyObjectUndoable::SetName(AsciiString name) -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->SetName(m_pDoc, name); - pCur = pCur->m_next; - } - m_inval = true; - if (m_inval) - { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -// -/// Set the new values, and force an inval of the windows. -// -void ModifyObjectUndoable::Do() -{ - // Already done. -} - -// -/// Set the new values, and force an inval of the windows. -// -void ModifyObjectUndoable::Redo() -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->DoMove(m_pDoc); - pCur = pCur->m_next; - } - if (m_inval) - { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -// -// Restore the old mipping values, and inval. -// -void ModifyObjectUndoable::Undo() -{ - MoveInfo *pCur = m_moveList; - while (pCur) { - pCur->UndoMove(m_pDoc); - pCur = pCur->m_next; - } - if (m_inval) - { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -/************************************************************************* -** FlagsInfo -***************************************************************************/ -FlagsInfo::~FlagsInfo() -{ - m_objectToModify=nullptr; // The map info list owns these, don't delete. - FlagsInfo *pCur = m_next; - FlagsInfo *tmp; - while (pCur) { - tmp = pCur; - pCur = tmp->m_next; - tmp->m_next = nullptr; - delete tmp; - } -} - -FlagsInfo::FlagsInfo( MapObject *pObjToMove, Int flagMask, Int flagValue): - m_next(nullptr) -{ - m_objectToModify = pObjToMove; // Not copied. - m_flagMask = flagMask; - m_newValue = flagValue&flagMask; - m_oldValue = m_objectToModify->getFlags()&flagMask; -} - - -// -/// Move the object. -// -void FlagsInfo::DoFlags(CWorldBuilderDoc *pDoc) -{ - Bool found = false; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj == m_objectToModify) { - found = true; - break; - } - } - if (!found) return; - pDoc->invalObject(m_objectToModify); - m_objectToModify->clearFlag(m_flagMask); - m_objectToModify->setFlag(m_newValue); - pDoc->invalObject(m_objectToModify); -} - -void FlagsInfo::UndoFlags(CWorldBuilderDoc *pDoc) -{ - Bool found = false; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj == m_objectToModify) { - found = true; - break; - } - } - if (!found) return; - pDoc->invalObject(m_objectToModify); - m_objectToModify->clearFlag(m_flagMask); - m_objectToModify->setFlag(m_oldValue); - pDoc->invalObject(m_objectToModify); -} - -/************************************************************************* -** ModifyFlagsUndoable -***************************************************************************/ -// -// ModifyFlagsUndoable - destructor. -// -ModifyFlagsUndoable::~ModifyFlagsUndoable() -{ - m_pDoc = nullptr; // not ref counted. - - delete m_flagsList; - m_flagsList = nullptr; -} - -// -// ModifyFlagsUndoable - create a new undoable. -// -ModifyFlagsUndoable::ModifyFlagsUndoable(CWorldBuilderDoc *pDoc, Int flagMask, Int flagValue): - m_pDoc(nullptr), - m_flagsList(nullptr) -{ - m_pDoc = pDoc; // not ref counted. - MapObject *curMapObj = MapObject::getFirstMapObject(); - FlagsInfo *pCurInfo = nullptr; - while (curMapObj) { - if (curMapObj->isSelected()) { - FlagsInfo *pNew = new FlagsInfo(curMapObj, flagMask, flagValue); - if (pCurInfo == nullptr) { - m_flagsList = pNew; - } else { - pCurInfo->m_next = pNew; - } - pCurInfo = pNew; - } - curMapObj = curMapObj->getNext(); - } -} - - -// -/// Set the new values, and force an inval of the objects. -// -void ModifyFlagsUndoable::Do() -{ - FlagsInfo *pCur = m_flagsList; - while (pCur) { - pCur->DoFlags(m_pDoc); - pCur = pCur->m_next; - } -} - -// -/// Set the new values, and force an inval of the objects. -// -void ModifyFlagsUndoable::Redo() -{ - Do(); -} - -// -// Restore the old mipping values, and inval. -// -void ModifyFlagsUndoable::Undo() -{ - FlagsInfo *pCur = m_flagsList; - while (pCur) { - pCur->UndoFlags(m_pDoc); - pCur = pCur->m_next; - } -} - -/************************************************************************* -** SidesListUndoable -***************************************************************************/ - -SidesListUndoable::SidesListUndoable(const SidesList& newSL, CWorldBuilderDoc *pDoc): -m_pDoc(pDoc) -{ - m_old = *TheSidesList; - m_new = newSL; - // ensure the new setup is valid. (don't mess with the old one.) - Bool modified = m_new.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("*** had to clean up sides in SidesListUndoable! (caller should do this)")); -} - -SidesListUndoable::~SidesListUndoable() -{ -} - -void SidesListUndoable::Do() -{ - *TheSidesList = m_new; - MapObjectProps::update(); // ugh, hack to update panel - ObjectOptions::update(); - // Sides list contains build list, so inval the build list. - BuildList::update(); - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); -} - -void SidesListUndoable::Undo() -{ - *TheSidesList = m_old; - MapObjectProps::update(); // ugh, hack to update panel - ObjectOptions::update(); - // Sides list contains build list, so inval the build list. - BuildList::update(); - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); -} - -/************************************************************************* -** DictItemUndoable -***************************************************************************/ - -DictItemUndoable::DictItemUndoable(Dict **d, Dict data, NameKeyType key, Int dictsToModify, CWorldBuilderDoc *pDoc, Bool inval) : - m_newDictData(data), - m_key(key), - m_numDictsToModify(dictsToModify), - m_pDoc(pDoc), - m_inval(inval) -{ - m_dictToModify.resize(m_numDictsToModify); - m_oldDictData.resize(m_numDictsToModify); - - for (int i = 0; i < m_numDictsToModify; ++i) { - m_dictToModify[i] = d[i]; - if (m_key == NAMEKEY_INVALID) - m_oldDictData[i] = *d[i]; - else - { - DEBUG_ASSERTCRASH(data.getPairCount() <= 1, ("hmm")); - m_oldDictData[i].copyPairFrom(*d[i], m_key); - } - } -} - -DictItemUndoable::~DictItemUndoable() -{ -} - - -void DictItemUndoable::Do() -{ - for (int i = 0; i < m_numDictsToModify; ++i) { - if (m_key == NAMEKEY_INVALID) - *m_dictToModify[i] = m_newDictData; - else - m_dictToModify[i]->copyPairFrom(m_newDictData, m_key); - } - MapObjectProps::update(); // ugh, hack to update panel - ObjectOptions::update(); // ditto - if (m_inval && m_pDoc) { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -void DictItemUndoable::Undo() -{ - for (int i = 0; i < m_numDictsToModify; ++i) { - if (m_key == NAMEKEY_INVALID) - *m_dictToModify[i] = m_oldDictData[i]; - else - m_dictToModify[i]->copyPairFrom(m_oldDictData[i], m_key); - } - MapObjectProps::update(); // ugh, hack to update panel - ObjectOptions::update(); // ditto - if (m_inval && m_pDoc) { - WbView3d *p3View = m_pDoc->GetActive3DView(); - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } -} - -/*static*/ Dict DictItemUndoable::buildSingleItemDict(AsciiString k, Dict::DataType t, AsciiString v) -{ - Dict d; - NameKeyType key = TheNameKeyGenerator->nameToKey(k); - switch(t) - { - case Dict::DICT_BOOL: - d.setBool(key, strcmp(v.str(), "true") == 0); - break; - case Dict::DICT_INT: - d.setInt(key, atoi(v.str())); - break; - case Dict::DICT_REAL: - d.setReal(key, atof(v.str())); - break; - case Dict::DICT_ASCIISTRING: - d.setAsciiString(key, v); - break; - case Dict::DICT_UNICODESTRING: - { - UnicodeString tmp; - tmp.translate(v); - d.setUnicodeString(key, tmp); - } - break; - default: - DEBUG_CRASH(("bug")); - break; - } - return d; -} - -/************************************************************************* -** DeleteInfo -***************************************************************************/ -DeleteInfo::~DeleteInfo() -{ - if (m_didDelete) { - deleteInstance(m_objectToDelete); - } - DeleteInfo *pCur = m_next; - DeleteInfo *tmp; - while (pCur) { - tmp = pCur; - pCur = tmp->m_next; - tmp->m_next = nullptr; - delete tmp; - } - m_objectToDelete=nullptr; - m_priorObject=nullptr; -} - -DeleteInfo::DeleteInfo( MapObject *pObjectToDelete): - m_objectToDelete(nullptr), - m_didDelete(false), - m_next(nullptr), - m_priorObject(nullptr) -{ - m_objectToDelete = pObjectToDelete; // Not copied. -} - -// -/// Delete the object. -// -void DeleteInfo::DoDelete(WorldHeightMapEdit *pMap) -{ - DEBUG_ASSERTCRASH(!m_didDelete,("oops")); - m_priorObject = nullptr; - MapObject *curMapObj = MapObject::getFirstMapObject(); - Bool found = false; - while (curMapObj) { - if (curMapObj == m_objectToDelete) { - found = true; - break; - } - m_priorObject = curMapObj; - curMapObj = curMapObj->getNext(); - } - DEBUG_ASSERTCRASH(found,("not found")); - if (!found) { - m_objectToDelete = nullptr; - return; - } - if (m_priorObject) { - m_priorObject->setNextMap(m_objectToDelete->getNext()); - } else { - DEBUG_ASSERTCRASH(MapObject::TheMapObjectListPtr == m_objectToDelete,("oops")); - MapObject::TheMapObjectListPtr = MapObject::TheMapObjectListPtr->getNext(); - } - m_objectToDelete->setNextMap(nullptr); - m_didDelete = true; -} - -void DeleteInfo::UndoDelete(WorldHeightMapEdit *pMap) -{ - DEBUG_ASSERTCRASH(m_didDelete,("oops")); - if (!m_didDelete) return; - if (m_priorObject) { - m_objectToDelete->setNextMap(m_priorObject->getNext()); - m_priorObject->setNextMap(m_objectToDelete); - m_priorObject = nullptr; - } else { - m_objectToDelete->setNextMap(MapObject::TheMapObjectListPtr); - MapObject::TheMapObjectListPtr = m_objectToDelete; - } - m_didDelete = false; -} - -/************************************************************************* -** DeleteObjectUndoable -***************************************************************************/ -// -// DeleteObjectUndoable - destructor. -// -DeleteObjectUndoable::~DeleteObjectUndoable() -{ - m_pDoc = nullptr; // not ref counted. - - delete m_deleteList; - m_deleteList=nullptr; -} - - -// -// DeleteObjectUndoable - create a new undoable. Deletes all selected objects. -// -DeleteObjectUndoable::DeleteObjectUndoable(CWorldBuilderDoc *pDoc): - m_pDoc(nullptr), - m_deleteList(nullptr) -{ - // Note - you can't delete just one end of a map segment. So delete both. - MapObject *pMapObj; - MapObject *pMapObj2; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->getFlag(FLAG_ROAD_POINT1)) { - pMapObj2 = pMapObj->getNext(); - DEBUG_ASSERTCRASH(pMapObj2 && pMapObj2->getFlag(FLAG_ROAD_POINT2), ("oops")); - if (pMapObj2==nullptr) break; - if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; - // If one end of a road segment is selected, both are. - if (pMapObj->isSelected() || pMapObj2->isSelected()) { - pMapObj->setSelected(true); - pMapObj2->setSelected(true); - } - } - } - - - m_pDoc = pDoc; // not ref counted. - MapObject *curMapObj = MapObject::getFirstMapObject(); - DeleteInfo *pCurInfo = nullptr; - while (curMapObj) { - if (curMapObj->isSelected()) { - DeleteInfo *pNew = new DeleteInfo(curMapObj); - if (pCurInfo == nullptr) { - m_deleteList = pNew; - } else { - pCurInfo->m_next = pNew; - } - pCurInfo = pNew; - } - curMapObj = curMapObj->getNext(); - } -} - - -// -/// Delete the objects. -// -void DeleteObjectUndoable::Do() -{ - WorldHeightMapEdit *pMap = m_pDoc->GetHeightMap(); - DeleteInfo *pCur = m_deleteList; - DeleteInfo *pInvertedList = nullptr; - while (pCur) { - // first, remove it from the Layers list. - TheLayersList->removeMapObjectFromLayersList(pCur->m_objectToDelete); - - DeleteInfo *tmp; - pCur->DoDelete(pMap); - tmp = pCur; - pCur = pCur->m_next; - tmp->m_next = pInvertedList; - pInvertedList = tmp; - } - WbView3d *p3View = m_pDoc->GetActive3DView(); - if (p3View) { // Shouldn't ever be null, but just in case... jba. - p3View->resetRenderObjects(); - p3View->invalObjectInView(nullptr); - } - m_deleteList = pInvertedList; -} - -// -// Restore the old mipping values, and inval. -// -void DeleteObjectUndoable::Undo() -{ - WorldHeightMapEdit *pMap = m_pDoc->GetHeightMap(); - DeleteInfo *pCur = m_deleteList; - DeleteInfo *pInvertedList=nullptr; - while (pCur) { - // Re-Add it to the layers list - Dict* objDict = pCur->m_objectToDelete->getProperties(); - Bool exists; - TheLayersList->addMapObjectToLayersList(pCur->m_objectToDelete, objDict->getAsciiString(TheKey_objectLayer, &exists)); - - DeleteInfo *tmp; - pCur->UndoDelete(pMap); - tmp = pCur; - pCur = pCur->m_next; - tmp->m_next = pInvertedList; - pInvertedList = tmp; - m_pDoc->invalObject(tmp->m_objectToDelete); - } - m_deleteList = pInvertedList; -} - - -/************************************************************************* -** AddPolygonUndoable -***************************************************************************/ -// -// AddPolygonUndoable - destructor. -// -AddPolygonUndoable::~AddPolygonUndoable() -{ - if (m_trigger && !m_isTriggerInList) { - DEBUG_ASSERTCRASH(m_trigger->getNext()==nullptr, ("Logic error.")); - deleteInstance(m_trigger); - } - m_trigger=nullptr; -} - -// -// AddPolygonUndoable - create a new undoable. Adds a polygon trigger. -// -AddPolygonUndoable::AddPolygonUndoable(PolygonTrigger *pTrig): - m_trigger(pTrig), - m_isTriggerInList(false) -{ -} - -// -/// Add the trigger. -// -void AddPolygonUndoable::Do() -{ - // The call to LayersList must be done here because only the WorldBuilder knows about Layers. - TheLayersList->addPolygonTriggerToLayersList(m_trigger, m_trigger->getLayerName()); - PolygonTrigger::addPolygonTrigger(m_trigger); - m_isTriggerInList = true; -} - -// -// Remove the trigger. -// -void AddPolygonUndoable::Undo() -{ - // The call to LayersList must be done here because only the WorldBuilder knows about Layers. - TheLayersList->removePolygonTriggerFromLayersList(m_trigger); - PolygonTrigger::removePolygonTrigger(m_trigger); - m_isTriggerInList = false; -} - - -/************************************************************************* -** AddPolygonPointUndoable -***************************************************************************/ -// -// AddPolygonUndoable - destructor. -// -AddPolygonPointUndoable::~AddPolygonPointUndoable() -{ - m_trigger=nullptr; -} - -// -// AddPolygonUndoable - create a new undoable. Adds a polygon point. -// -AddPolygonPointUndoable::AddPolygonPointUndoable(PolygonTrigger *pTrig, - ICoord3D pt): - m_trigger(pTrig), - m_point(pt) -{ -} - -// -/// Add the trigger. -// -void AddPolygonPointUndoable::Do() -{ - m_trigger->addPoint(m_point); -} - -// -// Remove the trigger. -// -void AddPolygonPointUndoable::Undo() -{ - m_point = *m_trigger->getPoint(m_trigger->getNumPoints()-1); - m_trigger->deletePoint(m_trigger->getNumPoints()-1); -} - - -/************************************************************************* -** ModifyPolygonPointUndoable -***************************************************************************/ -// -// ModifyPolygonPointUndoable - destructor. -// -ModifyPolygonPointUndoable::~ModifyPolygonPointUndoable() -{ - m_trigger=nullptr; -} - -// -// ModifyPolygonPointUndoable - create a new undoable. Edit a polygon point. -// -ModifyPolygonPointUndoable::ModifyPolygonPointUndoable(PolygonTrigger *pTrig, Int ndx): - m_trigger(pTrig), - m_pointIndex(ndx) -{ - m_point = *pTrig->getPoint(ndx); -} - -// -/// Add the trigger. -// -void ModifyPolygonPointUndoable::Do() -{ - m_savPoint = *m_trigger->getPoint(m_pointIndex); - m_trigger->setPoint(m_point, m_pointIndex); -} - -// -// Remove the trigger. -// -void ModifyPolygonPointUndoable::Undo() -{ - m_point = *m_trigger->getPoint(m_pointIndex); - m_trigger->setPoint(m_savPoint, m_pointIndex); -} - -/************************************************************************* -** MovePolygonUndoable -***************************************************************************/ -// -// MovePolygonUndoable - destructor. -// -MovePolygonUndoable::~MovePolygonUndoable() -{ - m_trigger=nullptr; -} - -// -// MovePolygonUndoable - create a new undoable. Edit a polygon point. -// -MovePolygonUndoable::MovePolygonUndoable(PolygonTrigger *pTrig): - m_trigger(pTrig) -{ - m_offset.x = 0; - m_offset.y = 0; - m_offset.z = 0; -} - -void MovePolygonUndoable::SetOffset(const ICoord3D &offset) -{ - Int deltaX = offset.x - m_offset.x; - Int deltaY = offset.y - m_offset.y; - Int deltaZ = offset.z - m_offset.z; - if (!m_trigger->isWaterArea()) { - deltaZ = 0; - } - m_offset = offset; - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D iLoc = *m_trigger->getPoint(i); - iLoc.x += deltaX; - iLoc.y += deltaY; - iLoc.z += deltaZ; - m_trigger->setPoint(iLoc, i); - } -} - - -// -/// Offset the trigger. -// -void MovePolygonUndoable::Do() -{ - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D iLoc = *m_trigger->getPoint(i); - iLoc.x += m_offset.x; - iLoc.y += m_offset.y; - iLoc.z += m_offset.z; - m_trigger->setPoint(iLoc, i); - } -} - -// -// Unoffset the trigger. -// -void MovePolygonUndoable::Undo() -{ - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D iLoc = *m_trigger->getPoint(i); - iLoc.x -= m_offset.x; - iLoc.y -= m_offset.y; - iLoc.z -= m_offset.z; - m_trigger->setPoint(iLoc, i); - } -} - - -/************************************************************************* -** InsertPolygonPointUndoable -***************************************************************************/ -// -// InsertPolygonPointUndoable - destructor. -// -InsertPolygonPointUndoable::~InsertPolygonPointUndoable() -{ - m_trigger=nullptr; -} - -// -// InsertPolygonPointUndoable - create a new undoable. Edit a polygon point. -// -InsertPolygonPointUndoable::InsertPolygonPointUndoable(PolygonTrigger *pTrig, ICoord3D pt, Int ndx): - m_trigger(pTrig), - m_point(pt), - m_pointIndex(ndx) -{ -} - -// -/// Insert the point. -// -void InsertPolygonPointUndoable::Do() -{ - m_trigger->insertPoint(m_point, m_pointIndex); -} - -// -// Remove the point. -// -void InsertPolygonPointUndoable::Undo() -{ - m_trigger->deletePoint(m_pointIndex); -} - -/************************************************************************* -** DeletePolygonPointUndoable -***************************************************************************/ -// -// DeletePolygonPointUndoable - destructor. -// -DeletePolygonPointUndoable::~DeletePolygonPointUndoable() -{ - m_trigger=nullptr; -} - -// -// DeletePolygonPointUndoable - create a new undoable. Edit a polygon point. -// -DeletePolygonPointUndoable::DeletePolygonPointUndoable(PolygonTrigger *pTrig, Int ndx): - m_trigger(pTrig), - m_pointIndex(ndx) -{ - m_point = *pTrig->getPoint(ndx); -} - -// -/// Delete the point. -// -void DeletePolygonPointUndoable::Do() -{ - m_trigger->deletePoint(m_pointIndex); -} - -// -// Remove the point. -// -void DeletePolygonPointUndoable::Undo() -{ - m_trigger->insertPoint(m_point, m_pointIndex); -} - -/************************************************************************* -** DeletePolygonUndoable -***************************************************************************/ -// -// DeletePolygonUndoable - destructor. -// -DeletePolygonUndoable::~DeletePolygonUndoable() -{ - if (m_trigger && !m_isTriggerInList) { - DEBUG_ASSERTCRASH(m_trigger->getNext()==nullptr, ("Logic error.")); - deleteInstance(m_trigger); - } - m_trigger=nullptr; -} - -// -// DeletePolygonUndoable - create a new undoable. Edit a polygon point. -// -DeletePolygonUndoable::DeletePolygonUndoable(PolygonTrigger *pTrig): - m_trigger(pTrig), - m_isTriggerInList(true) -{ -} - -// -/// Delete the point. -// -void DeletePolygonUndoable::Do() -{ - TheLayersList->removePolygonTriggerFromLayersList(m_trigger); - PolygonTrigger::removePolygonTrigger(m_trigger); - m_isTriggerInList = false; -} - -// -// Remove the point. -// -void DeletePolygonUndoable::Undo() -{ - PolygonTrigger::addPolygonTrigger(m_trigger); - TheLayersList->addPolygonTriggerToLayersList(m_trigger, m_trigger->getLayerName()); - m_isTriggerInList = true; -} - - - -/************************************************************************* -** MultipleUndoable -***************************************************************************/ -// -// MultipleUndoable - constructor. -// -MultipleUndoable::MultipleUndoable() - : m_undoableList( nullptr ) -{ -} - -// -// MultipleUndoable - destructor -// -MultipleUndoable::~MultipleUndoable() -{ - if ( m_undoableList ) - { - REF_PTR_RELEASE(m_undoableList); - } -} - -// -// Add another undo to the list. -// -void MultipleUndoable::addUndoable( Undoable * undoable ) -{ - undoable->LinkNext( m_undoableList ); - - REF_PTR_SET( m_undoableList, undoable ); -} - - -// -/// Do all the list's actions. -// -void MultipleUndoable::Do() -{ - Undoable * undoable = m_undoableList; - - while ( undoable != nullptr ) - { - Undoable * next = undoable->GetNext(); - undoable->Do(); - undoable = next; - } -} - - -// -// Recursive function to help traverse a singly-linked list in reverse order -// -static void undoHelper(Undoable * undoable) -{ - if ( undoable == nullptr ) - return; - - undoHelper( undoable->GetNext() ); - - undoable->Undo(); -} - -// -// Undo all the list's actions. This is harder, because we need to do it in reverse order, for a -// singly linked list -// -void MultipleUndoable::Undo() -{ - undoHelper(m_undoableList); -} - - -// -/// Redo all the list's actions. -// -void MultipleUndoable::Redo() -{ - Undoable * undoable = m_undoableList; - - while ( undoable != nullptr ) - { - Undoable * next = undoable->GetNext(); - undoable->Redo(); - undoable = next; - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/CameraOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/CameraOptions.cpp deleted file mode 100644 index 220e3d5f22d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/CameraOptions.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// CameraOptions.cpp : implementation file -// - - -#include "StdAfx.h" -#include "resource.h" -#include "WorldBuilder.h" -#include "CameraOptions.h" -#include "wbview3d.h" -#include "WorldBuilderDoc.h" - - -#include "WaypointOptions.h" //WST 10/7/2002 -#include "CUndoable.h" //WST 10/7/2002 - -///////////////////////////////////////////////////////////////////////////// -// CameraOptions dialog - - -CameraOptions::CameraOptions(CWnd* pParent /*=nullptr*/) - : CDialog(CameraOptions::IDD, pParent) -{ - m_updating = false; - //{{AFX_DATA_INIT(CameraOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void CameraOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CameraOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CameraOptions, CDialog) - //{{AFX_MSG_MAP(CameraOptions) - ON_BN_CLICKED(IDC_CameraReset, OnCameraReset) - ON_BN_CLICKED(IDC_DROP_WAYPOINT_BUTTON, OnDropWaypointButton) - ON_BN_CLICKED(IDC_CENTER_ON_SELECTED, OnCenterOnSelectedButton) - ON_WM_MOVE() - ON_EN_CHANGE(IDC_PITCH_EDIT, OnChangePitchEdit) - ON_WM_SHOWWINDOW() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CameraOptions message handlers - -void CameraOptions::OnCameraReset() -{ - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - if (p3View) - { - p3View->setDefaultCamera(); - update(); - } -} - -//WST 10/7/2002 - Drop waypoint button for Adam Isgreen ----------- -void CameraOptions::OnDropWaypointButton() -{ - //The following code is taken from waypointTool.cpp. On mouse down. - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - Coord3D docPt; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - - Vector3 camTarget = p3View->getCameraTarget(); - docPt.x = camTarget.X; - docPt.y = camTarget.Y; - docPt.z = MAGIC_GROUND_Z; - - // - // MBL CNC3 INCURSION 10.29.2002 - Fix compile error w/ 10-15-2002 Drop - // - // MapObject *pNew = new MapObject(docPt, "*Waypoints/Waypoint", 0, 0, nullptr, nullptr ); - MapObject *pNew = newInstance(MapObject)(docPt, "*Waypoints/Waypoint", 0, 0, nullptr, nullptr ); - - Int id = pDoc->getNextWaypointID(); - AsciiString name = WaypointOptions::GenerateUniqueName(id); - pNew->setSelected(true); - pNew->setIsWaypoint(); - pNew->setWaypointID(id); - pNew->setWaypointName(name); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, "team"); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pNew = nullptr; // undoable owns it now. -} - -//WST 11/25/2002 - New Center Camera button for Designers ----------- -void CameraOptions::OnCenterOnSelectedButton() -{ - // Center camera on the selected map object - - int count = 0; - const Coord3D *objectPosition; - - MapObject *mapObject = MapObject::getFirstMapObject(); - while (mapObject) { - if (mapObject->isSelected()) { - objectPosition = mapObject->getLocation(); - count++; - } - mapObject = mapObject->getNext(); - } - - if (count==1) { - // Only center if there is only one object selected on map - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - if (p3View) { - p3View->setCenterInView(objectPosition->x/MAP_XY_FACTOR,objectPosition->y/MAP_XY_FACTOR); - } - } -} - - -void CameraOptions::OnMove(int x, int y) -{ - CDialog::OnMove(x, y); - - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(CAMERA_OPTIONS_PANEL_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(CAMERA_OPTIONS_PANEL_SECTION, "Left", frameRect.left); - } - -} - -void CameraOptions::putInt(Int ctrlID, Int val) -{ - CString str; - CWnd *pEdit = GetDlgItem(ctrlID); - if (pEdit) { - str.Format("%d", val); - pEdit->SetWindowText(str); - } -} - -void CameraOptions::putReal(Int ctrlID, Real val) -{ - CString str; - CWnd *pEdit = GetDlgItem(ctrlID); - if (pEdit) { - str.Format("%g", val); - pEdit->SetWindowText(str); - } -} - -void CameraOptions::putAsciiString(Int ctrlID, AsciiString val) -{ - CString str; - CWnd *pEdit = GetDlgItem(ctrlID); - if (pEdit) { - str.Format("%s", val.str()); - pEdit->SetWindowText(str); - } -} - -BOOL CameraOptions::getReal(Int ctrlID, Real *rVal) -{ - CWnd *pEdit = GetDlgItem(ctrlID); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Real val; - if (1==sscanf(buffer, "%f", &val)) { - *rVal = val; - return true; - } - } - return false; -} - -void CameraOptions::stuffValuesIntoFields() -{ - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - if (p3View) - { - m_updating = true; - putReal(IDC_PITCH_EDIT, p3View->getCameraPitch()); - m_updating = false; - - Real height = p3View->getHeightAboveGround(); - //WST 10/11/2002 This is inaccurate Real zoom = height/TheGlobalData->m_maxCameraHeight; - Real zoom = p3View->getCurrentZoom(); //WST 10.11.2002 - - putReal(IDC_ZOOMTEXT, zoom); - putReal(IDC_HEIGHTTEXT, height); - - Vector3 source = p3View->getCameraSource(); - Vector3 target = p3View->getCameraTarget(); -// Real angle = p3View->getCameraAngle(); - - AsciiString s; - s.format("(%g, %g)", target.X, target.Y); - putAsciiString(IDC_POSTEXT, s); - s.format("(%g, %g)", target.X - 1.0f*(source.X-target.X), target.Y - 1.0f*(source.Y-target.Y)); - putAsciiString(IDC_TARGETTEXT, s); - } -} - -void CameraOptions::update() -{ - stuffValuesIntoFields(); -} - -void CameraOptions::applyCameraPitch( Real pitch ) -{ - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - if (p3View) - { - p3View->setCameraPitch(pitch); - } -} - - - -void CameraOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_PITCH_POPUP: - *pMin = 0; - *pMax = 100; - *pInitial = 100; - *pLineSize = 1; - { - WbView3d * p3View = CWorldBuilderDoc::GetActive3DView(); - if (p3View) - { - *pInitial = (Int)(100.0f * p3View->getCameraPitch()); - } - } - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void CameraOptions::PopSliderChanged(const long sliderID, long theVal) -{ - switch (sliderID) { - - case IDC_PITCH_POPUP: - putReal(IDC_PITCH_EDIT, ((Real)theVal)*0.01f); - break; - - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void CameraOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_PITCH_POPUP: - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - - -BOOL CameraOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_pitchPopup.SetupPopSliderButton(this, IDC_PITCH_POPUP, this); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CameraOptions::OnChangePitchEdit() -{ - if (m_updating) - return; - - Real pitch; - if (getReal(IDC_PITCH_EDIT, &pitch)) - { - m_updating = true; - applyCameraPitch(pitch); - m_updating = false; - } -} - -void CameraOptions::OnShowWindow(BOOL bShow, UINT nStatus) -{ - CDialog::OnShowWindow(bShow, nStatus); - - update(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/CellWidth.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/CellWidth.cpp deleted file mode 100644 index 35277afd30b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/CellWidth.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// CellWidth.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "CellWidth.h" - -///////////////////////////////////////////////////////////////////////////// -// CellWidth dialog - -/// Constructor and set initial cell width. -CellWidth::CellWidth(int cellWidth, CWnd* pParent /*=nullptr*/) - : CDialog(CellWidth::IDD, pParent), - mCellWidth(cellWidth) -{ - //{{AFX_DATA_INIT(CellWidth) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void CellWidth::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CellWidth) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -///////////////////////////////////////////////////////////////////////////// -// CellWidth message handlers - -/// Get the cell width value from the ui on ok. -void CellWidth::OnOK() -{ - CWnd *combo = GetDlgItem(IDC_CELL_WIDTH); - CString val; - if (combo) { - combo->GetWindowText(val); - mCellWidth = atoi(val); - } - CDialog::OnOK(); -} - - -/// Set the initial value of cell width into the combobox. -BOOL CellWidth::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *combo = GetDlgItem(IDC_CELL_WIDTH); - CString val; - val.Format("%d", mCellWidth); - if (combo) combo->SetWindowText(val); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BEGIN_MESSAGE_MAP(CellWidth, CDialog) - //{{AFX_MSG_MAP(CellWidth) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ContourOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ContourOptions.cpp deleted file mode 100644 index 63109221a7e..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ContourOptions.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ContourOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "ContourOptions.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" - -Int ContourOptions::m_contourStep = 5; -Int ContourOptions::m_contourOffset = 0; -Int ContourOptions::m_contourWidth = 1; -///////////////////////////////////////////////////////////////////////////// -/// ContourOptions dialog trivial constructor - Create does the real work. - - -ContourOptions::ContourOptions(CWnd* pParent /*=nullptr*/) - : CDialog(ContourOptions::IDD, pParent) -{ - //{{AFX_DATA_INIT(ContourOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void ContourOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ContourOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - - -///////////////////////////////////////////////////////////////////////////// -// ContourOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL ContourOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *pWnd = GetDlgItem(IDC_SLIDER1); - CRect rect; - pWnd->GetWindowRect(&rect); - - pWnd->DestroyWindow(); - ScreenToClient(&rect); - - m_contourStepSlider.Create(TBS_HORZ|TBS_BOTTOM|TBS_AUTOTICKS, rect, this, IDC_SLIDER1); - m_contourStepSlider.SetRange(MIN_CONTOUR_STEP,MAX_CONTOUR_STEP); - m_contourStepSlider.SetTicFreq(1); - m_contourStepSlider.SetPos(MIN_CONTOUR_STEP + MAX_CONTOUR_STEP-m_contourStep); - m_contourStepSlider.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_SLIDER2); - pWnd->GetWindowRect(&rect); - - pWnd->DestroyWindow(); - ScreenToClient(&rect); - - m_contourOffsetSlider.Create(TBS_HORZ|TBS_BOTTOM|TBS_AUTOTICKS, rect, this, IDC_SLIDER2); - m_contourOffsetSlider.SetRange(MIN_CONTOUR_OFFSET,MAX_CONTOUR_OFFSET); - m_contourOffsetSlider.SetTicFreq(1); - m_contourOffsetSlider.SetPos(m_contourOffset); - m_contourOffsetSlider.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_SLIDER3); - pWnd->GetWindowRect(&rect); - - pWnd->DestroyWindow(); - ScreenToClient(&rect); - - m_contourWidthSlider.Create(TBS_HORZ|TBS_BOTTOM|TBS_AUTOTICKS, rect, this, IDC_SLIDER3); - m_contourWidthSlider.SetRange(MIN_WIDTH,MAX_WIDTH); - m_contourWidthSlider.SetTicFreq(1); - m_contourWidthSlider.SetPos(m_contourWidth); - m_contourWidthSlider.ShowWindow(SW_SHOW); - - CButton *pButton = (CButton*)GetDlgItem(IDC_SHOW_CONTOURS); - CWorldBuilderView *pView = CWorldBuilderDoc::GetActive2DView(); - if (pButton && pView) pButton->SetCheck(pView->getShowContours()?1:0); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/// Handles slider ui messages. -/** Gets the info, determines if it is the feather or width slider, - gets the new value, and updates the corresponding edit control - and the brush tool. */ -void ContourOptions::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - CString str; - m_updating = true; - Bool step = (pScrollBar && pScrollBar->m_hWnd == m_contourStepSlider.m_hWnd); - Bool offset = (pScrollBar && pScrollBar->m_hWnd == m_contourOffsetSlider.m_hWnd); - if (step) { - if (nSBCode != TB_THUMBTRACK) { - nPos = m_contourStepSlider.GetPos(); - } - m_contourStep = MIN_CONTOUR_STEP + MAX_CONTOUR_STEP - nPos; - } else if (offset) { // width - if (nSBCode != TB_THUMBTRACK) { - nPos = m_contourOffsetSlider.GetPos(); - } - m_contourOffset = nPos; - } else { // width - if (nSBCode != TB_THUMBTRACK) { - nPos = m_contourWidthSlider.GetPos(); - } - m_contourWidth = nPos; - } - if (nSBCode!=TB_THUMBTRACK) { - CWorldBuilderView *pView = CWorldBuilderDoc::GetActive2DView(); - if (pView) - pView->setCellSize(pView->getCellSize()); - } - m_updating = false; -} - - -BEGIN_MESSAGE_MAP(ContourOptions, CDialog) - //{{AFX_MSG_MAP(ContourOptions) - ON_WM_HSCROLL() - ON_BN_CLICKED(IDC_SHOW_CONTOURS, OnShowContours) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void ContourOptions::OnShowContours() -{ - CWorldBuilderView *pView = CWorldBuilderDoc::GetActive2DView(); - if (pView) { - Bool showContours = !pView->getShowContours(); - CButton *pButton = (CButton*)GetDlgItem(IDC_SHOW_CONTOURS); - if (pButton) pButton->SetCheck(showContours?1:0); - pView->setShowContours(showContours); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp deleted file mode 100644 index 0fe8c567085..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp +++ /dev/null @@ -1,2510 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "StdAfx.h" - -#include "DrawObject.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "Common/GlobalData.h" -#include "W3DDevice/GameClient/WorldHeightMap.h" -#include "W3DDevice/GameClient/TerrainTex.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "W3DDevice/GameClient/W3DAssetManager.h" -#include "W3DDevice/GameClient/W3DWater.h" -#include "WW3D2/dx8wrapper.h" -#include "WW3D2/mesh.h" -#include "WW3D2/meshmdl.h" -#include "WW3D2/shader.h" -#include "Common/MapObject.h" -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/SidesList.h" -#include "resource.h" -#include "wbview3d.h" -#include "WorldBuilderDoc.h" -#include "WHeightMapEdit.h" -#include "MeshMoldOptions.h" -#include "WaterTool.h" -#include "BuildListTool.h" -#include "LayersList.h" -#include "Common/WellKnownKeys.h" -#include "Common/BorderColors.h" -#include "Common/ThingTemplate.h" -#include "W3DDevice/Common/W3DConvert.h" -#include "WW3D2/render2d.h" -#include "GameLogic/Weapon.h" -#include "Common/AudioEventInfo.h" - -#ifdef RTS_DEBUG -#define NO_INTENSE_DEBUG 1 -#endif - -const Real LINE_THICKNESS = 2.0f; -const Real HANDLE_SIZE = (2.0f) * LINE_THICKNESS; - - -// Texturing, no zbuffer, disabled zbuffer write, primary gradient, alpha blending -#define SC_OPAQUE ( SHADE_CNST(ShaderClass::PASS_ALWAYS, ShaderClass::DEPTH_WRITE_DISABLE, ShaderClass::COLOR_WRITE_ENABLE, ShaderClass::SRCBLEND_ONE, \ - ShaderClass::DSTBLEND_ZERO, ShaderClass::FOG_DISABLE, ShaderClass::GRADIENT_DISABLE, ShaderClass::SECONDARY_GRADIENT_DISABLE, ShaderClass::TEXTURING_ENABLE, \ - ShaderClass::ALPHATEST_DISABLE, ShaderClass::CULL_MODE_DISABLE, \ - ShaderClass::DETAILCOLOR_DISABLE, ShaderClass::DETAILALPHA_DISABLE) ) - -// Texturing, no zbuffer, disabled zbuffer write, primary gradient, alpha blending -#define SC_ALPHA ( SHADE_CNST(ShaderClass::PASS_ALWAYS, ShaderClass::DEPTH_WRITE_DISABLE, ShaderClass::COLOR_WRITE_ENABLE, ShaderClass::SRCBLEND_SRC_ALPHA, \ - ShaderClass::DSTBLEND_ONE_MINUS_SRC_ALPHA, ShaderClass::FOG_DISABLE, ShaderClass::GRADIENT_MODULATE, ShaderClass::SECONDARY_GRADIENT_DISABLE, ShaderClass::TEXTURING_ENABLE, \ - ShaderClass::ALPHATEST_DISABLE, ShaderClass::CULL_MODE_ENABLE, \ - ShaderClass::DETAILCOLOR_DISABLE, ShaderClass::DETAILALPHA_DISABLE) ) - -// Texturing, no zbuffer, disabled zbuffer write, primary gradient, alpha blending -#define SC_ALPHA_Z ( SHADE_CNST(ShaderClass::PASS_LEQUAL, ShaderClass::DEPTH_WRITE_DISABLE, ShaderClass::COLOR_WRITE_ENABLE, ShaderClass::SRCBLEND_SRC_ALPHA, \ - ShaderClass::DSTBLEND_ONE_MINUS_SRC_ALPHA, ShaderClass::FOG_DISABLE, ShaderClass::GRADIENT_MODULATE, ShaderClass::SECONDARY_GRADIENT_DISABLE, ShaderClass::TEXTURING_ENABLE, \ - ShaderClass::ALPHATEST_DISABLE, ShaderClass::CULL_MODE_DISABLE, \ - ShaderClass::DETAILCOLOR_DISABLE, ShaderClass::DETAILALPHA_DISABLE) ) - -// Texturing, no zbuffer, disabled zbuffer write, primary gradient, alpha blending -#define SC_OPAQUE_Z ( SHADE_CNST(ShaderClass::PASS_LEQUAL, ShaderClass::DEPTH_WRITE_DISABLE, ShaderClass::COLOR_WRITE_ENABLE, ShaderClass::SRCBLEND_ONE, \ - ShaderClass::DSTBLEND_ZERO, ShaderClass::FOG_DISABLE, ShaderClass::GRADIENT_DISABLE, ShaderClass::SECONDARY_GRADIENT_DISABLE, ShaderClass::TEXTURING_ENABLE, \ - ShaderClass::ALPHATEST_DISABLE, ShaderClass::CULL_MODE_DISABLE, \ - ShaderClass::DETAILCOLOR_DISABLE, ShaderClass::DETAILALPHA_DISABLE) ) - - -Bool DrawObject::m_squareFeedback = false; -Int DrawObject::m_brushWidth = 3; -Int DrawObject::m_brushFeatherWidth = 3; -Bool DrawObject::m_toolWantsFeedback = true; -Bool DrawObject::m_disableFeedback = false; -Bool DrawObject::m_meshFeedback = false; -Bool DrawObject::m_rampFeedback = false; -Bool DrawObject::m_boundaryFeedback = false; -Bool DrawObject::m_ambientSoundFeedback = false; -Coord3D DrawObject::m_feedbackPoint; -CPoint DrawObject::m_cellCenter; - -Coord3D DrawObject::m_rampStartPoint; -Coord3D DrawObject::m_rampEndPoint; -Real DrawObject::m_rampWidth = 0.0f; - - -Bool DrawObject::m_dragWaypointFeedback = false; -Coord3D DrawObject::m_dragWayStart; -Coord3D DrawObject::m_dragWayEnd; - -static Int curHighlight = 0; -static const Int NUM_HIGHLIGHT = 3; - - - - -void DrawObject::setWaypointDragFeedback(const Coord3D &start, const Coord3D &end) -{ - m_dragWaypointFeedback = true; - m_dragWayStart = start; - m_dragWayEnd = end; -} - -void DrawObject::stopWaypointDragFeedback() -{ - m_dragWaypointFeedback = false; -} - - - -DrawObject::~DrawObject() -{ - freeMapResources(); - REF_PTR_RELEASE(m_waterDrawObject); - TheWaterRenderObj = nullptr; -} - -DrawObject::DrawObject() : - m_drawObjects(true), - m_drawPolygonAreas(true), - m_indexBuffer(nullptr), - m_vertexMaterialClass(nullptr), - m_vertexBufferTile1(nullptr), - m_vertexBufferTile2(nullptr), - m_vertexBufferWater(nullptr), - m_vertexFeedback(nullptr), - m_indexFeedback(nullptr), - m_indexWater(nullptr), - m_moldMesh(nullptr), - m_lineRenderer(nullptr), - m_drawSoundRanges(false) -{ - m_feedbackPoint.x = 20; - m_feedbackPoint.y = 20; - initData(); - m_waterDrawObject = new WaterRenderObjClass; - m_waterDrawObject->init(0, 0, 0, nullptr, WaterRenderObjClass::WATER_TYPE_0_TRANSLUCENT); - TheWaterRenderObj=m_waterDrawObject; - - //(gth) this was needed to fix the extents bug that is based off water and too small for our maps - Set_Force_Visible(true); -} - - -Bool DrawObject::Cast_Ray(RayCollisionTestClass & raytest) -{ - - return false; - -} - - -//@todo: MW Handle both of these properly!! -DrawObject::DrawObject(const DrawObject & src) -{ - *this = src; -} - -DrawObject & DrawObject::operator = (const DrawObject & that) -{ - DEBUG_CRASH(("oops")); - return *this; -} - -void DrawObject::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const -{ - // (gth) CNC3 these bounds don't actually work for all levels... - // we set the "force visible" flag for this object since it encapsulates all of the UI - // gadgets for the whole level anyway. - Vector3 ObjSpaceCenter(TheGlobalData->m_waterExtentX,TheGlobalData->m_waterExtentY,50*MAP_XY_FACTOR); - float length = ObjSpaceCenter.Length(); - sphere.Init(ObjSpaceCenter, length); -} - -void DrawObject::Get_Obj_Space_Bounding_Box(AABoxClass & box) const -{ - // (gth) CNC3 these bounds don't actually work for all levels... - // we set the "force visible" flag for this object since it encapsulates all of the UI - // gadgets for the whole level anyway. - Vector3 minPt(-2*TheGlobalData->m_waterExtentX,-2*TheGlobalData->m_waterExtentY,0); - Vector3 maxPt(2*TheGlobalData->m_waterExtentX,2*TheGlobalData->m_waterExtentY,100*MAP_XY_FACTOR); - box.Init(minPt,maxPt); -} - -Int DrawObject::Class_ID() const -{ - return RenderObjClass::CLASSID_UNKNOWN; -} - -RenderObjClass * DrawObject::Clone() const -{ - return new DrawObject(*this); -} - - -Int DrawObject::freeMapResources() -{ - - REF_PTR_RELEASE(m_indexBuffer); - REF_PTR_RELEASE(m_vertexBufferTile1); - REF_PTR_RELEASE(m_vertexBufferTile2); - REF_PTR_RELEASE(m_vertexBufferWater); - REF_PTR_RELEASE(m_vertexMaterialClass); - REF_PTR_RELEASE(m_vertexFeedback); - REF_PTR_RELEASE(m_indexFeedback); - REF_PTR_RELEASE(m_indexWater); - REF_PTR_RELEASE(m_moldMesh); - - delete m_lineRenderer; - m_lineRenderer = nullptr; - - return 0; -} - -// Total number of triangles -#define NUM_TRI 26 -// Number of triangles in the arrow. -#define NUM_ARROW_TRI 4 -// Number of triangles in the selection pyramid. -#define NUM_SELECT_TRI 16 -// Height of selection pyramid. -#define SELECT_PYRAMID_HEIGHT (1.0f) - - -Int DrawObject::initData() -{ - Int i; - - freeMapResources(); //free old data and ib/vb - - m_numTriangles = 2*NUM_TRI; - m_indexBuffer=NEW_REF(DX8IndexBufferClass,(m_numTriangles*3, DX8IndexBufferClass::USAGE_DYNAMIC)); - - // Fill up the IB - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexBuffer, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - - for (i=0; i<3*m_numTriangles; i+=3) - { - ib[0]=i; - ib[1]=i+1; - ib[2]=i+2; - - ib+=3; //skip the 3 indices we just filled - } - - m_vertexBufferTile1=NEW_REF(DX8VertexBufferClass,(DX8_FVF_XYZDUV1,m_numTriangles*3,DX8VertexBufferClass::USAGE_DYNAMIC)); - m_vertexBufferTile2=NEW_REF(DX8VertexBufferClass,(DX8_FVF_XYZDUV1,m_numTriangles*3,DX8VertexBufferClass::USAGE_DYNAMIC)); - - m_vertexFeedback=NEW_REF(DX8VertexBufferClass,(DX8_FVF_XYZDUV1,NUM_FEEDBACK_VERTEX,DX8VertexBufferClass::USAGE_DYNAMIC)); - m_indexFeedback=NEW_REF(DX8IndexBufferClass,(NUM_FEEDBACK_INDEX,DX8IndexBufferClass::USAGE_DYNAMIC)); - - //go with a preset material for now. - m_vertexMaterialClass=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); - - //use a multi-texture shader: (text1*diffuse)*text2. - m_shaderClass = ShaderClass(SC_OPAQUE);//_PresetOpaque2DShader;//ShaderClass(SC_OPAQUE); //_PresetOpaqueShader; - - m_shaderClass = ShaderClass::_PresetOpaque2DShader; - updateForWater(); - updateVB(m_vertexBufferTile1, 255<<8, true, false); - - return 0; -} - - -/** updateMeshVB puts mesh mold triangles into m_vertexFeedback. */ - -void DrawObject::updateMeshVB() -{ - const Int theAlpha = 64; - - if (m_curMeshModelName != MeshMoldOptions::getModelName()) { - REF_PTR_RELEASE(m_moldMesh); - m_curMeshModelName = MeshMoldOptions::getModelName(); - } - if (m_moldMesh == nullptr) { - WW3DAssetManager *pMgr = W3DAssetManager::Get_Instance(); - pMgr->Set_WW3D_Load_On_Demand(false); // We don't want it fishing for these assets in the game assets. - m_moldMesh = (MeshClass*)pMgr->Create_Render_Obj(m_curMeshModelName.str()); - if (m_moldMesh == nullptr) { - // Try loading the mold asset. - AsciiString path("data\\editor\\molds\\"); - path.concat(m_curMeshModelName); - path.concat(".w3d"); - pMgr->Load_3D_Assets(path.str()); - m_moldMesh = (MeshClass*)pMgr->Create_Render_Obj(m_curMeshModelName.str()); - } - if (m_moldMesh) { - m_moldMeshBounds = m_moldMesh->Get_Bounding_Sphere(); - } - pMgr->Set_WW3D_Load_On_Demand(true); - } - if (m_moldMesh == nullptr) { - return; - } - - - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - if (m_moldMesh == nullptr) { - return; - } - Int i; - Int numVertex = m_moldMesh->Peek_Model()->Get_Vertex_Count(); - Vector3 *pVert = m_moldMesh->Peek_Model()->Get_Vertex_Array(); - -// const Vector3 *pNormal = m_moldMesh->Peek_Model()->Get_Vertex_Normal_Array(); - - // If we happen to have too many vertex, stop. - if (numVertex+9>= NUM_FEEDBACK_VERTEX) { - return; - } - -#if 0 //this wasn't being used (see below) so I commented it out. -MW - Vector3 lightRay=Normalize(Vector3(-TheGlobalData->m_terrainLightPos[0].x, - -TheGlobalData->m_terrainLightPos[0].y, -TheGlobalData->m_terrainLightPos[0].z)); -#endif - - for (i=0; iu1 = 0; - curVb->v1 = 0; - Vector3 vLoc(pVert[i]); - vLoc *= MeshMoldOptions::getScale(); - vLoc.Rotate_Z(MeshMoldOptions::getAngle()*PI/180.0f); - vLoc.X += m_feedbackPoint.x; - vLoc.Y += m_feedbackPoint.y; - vLoc.Z += m_feedbackPoint.z; - curVb->x = vLoc.X; - curVb->y = vLoc.Y; - curVb->z = vLoc.Z; - - VertexFormatXYZDUV2 vb; - vb.x = vLoc.X; - vb.y = vLoc.Y; - vb.z = vLoc.Z; - -#if 1 - curVb->diffuse = 0x0000ffff | (theAlpha << 24); // bright cyan. -#else - TheTerrainRenderObject->doTheLight(&vb, &lightRay, (Vector3 *)(&pNormal[i]), nullptr, 1.0f); - vb.diffuse &= 0x0000ffff; - curVb->diffuse = vb.diffuse | (theAlpha << 24); -#endif - curVb++; - m_feedbackVertexCount++; - } - // Put in the "center anchor" - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x; - curVb->y = m_feedbackPoint.y; - curVb->z = 0; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x+1; - curVb->y = m_feedbackPoint.y+1; - curVb->z = m_feedbackPoint.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x; - curVb->y = m_feedbackPoint.y; - curVb->z = m_feedbackPoint.z-500; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x+1; - curVb->y = m_feedbackPoint.y+1; - curVb->z = m_feedbackPoint.z-500; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - - - Int numPoly = m_moldMesh->Get_Model()->Get_Polygon_Count(); - const TriIndex *pPoly =m_moldMesh->Get_Model()->Get_Polygon_Array(); - if (3*numPoly+9 >= NUM_FEEDBACK_INDEX) { - return; - } - - for (i=0; iu1 = INT_TO_REAL(i % widthVerts) / widthVerts; - curVb->v1 = INT_TO_REAL(i / lengthVerts) / lengthVerts; - - curVb->diffuse = curVb->diffuse = 0x0000ffff | (theAlpha << 24); // bright cyan. - - Vector3 vLoc; - vLoc.X = (br.X - bl.X) * INT_TO_REAL(i % widthVerts) / (widthVerts - 1) + - (tl.X - bl.X) * INT_TO_REAL(i / lengthVerts) / (lengthVerts - 1) + bl.X; - - vLoc.Y = (br.Y - bl.Y) * INT_TO_REAL(i % widthVerts) / (widthVerts - 1) + - (tl.Y - bl.Y) * INT_TO_REAL(i / lengthVerts) / (lengthVerts - 1) + bl.Y; - - vLoc.Z = (br.Z - bl.Z) * INT_TO_REAL(i % widthVerts) / (widthVerts - 1) + - (tl.Z - bl.Z) * INT_TO_REAL(i / lengthVerts) / (lengthVerts - 1) + bl.Z; - - curVb->x = vLoc.X; - curVb->y = vLoc.Y; - curVb->z = vLoc.Z; - - curVb++; - m_feedbackVertexCount++; - } - - // Now do the indices - for (i = 0; i < lengthVerts - 1; ++i) { - for (j = 0; j < widthVerts - 1; ++j) { - (*curIb++) = i * lengthVerts + j; - (*curIb++) = (i + 1) * lengthVerts + j; - (*curIb++) = (i + 1) * lengthVerts + j + 1; - - (*curIb++) = i * lengthVerts + j; - (*curIb++) = (i + 1) * lengthVerts + j + 1; - (*curIb++) = (i) * lengthVerts + j + 1; - m_feedbackIndexCount += 6; - } - - } -#if 0 - // Put in the "center anchor" - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x; - curVb->y = m_feedbackPoint.y; - curVb->z = 0; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x+1; - curVb->y = m_feedbackPoint.y+1; - curVb->z = m_feedbackPoint.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x; - curVb->y = m_feedbackPoint.y; - curVb->z = m_feedbackPoint.z-500; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = m_feedbackPoint.x+1; - curVb->y = m_feedbackPoint.y+1; - curVb->z = m_feedbackPoint.z-500; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; -#endif -} - -/** updateBoundaryVB puts boundaries into m_vertexFeedback. */ -void DrawObject::updateBoundaryVB() -{ -// const Int theAlpha = 64; - - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - Int numBoundaries = pDoc->getNumBoundaries(); - - Int i, j; - for (i = 0; i < numBoundaries; ++i) { - ICoord2D curBoundary; - pDoc->getBoundary(i, &curBoundary); - if (curBoundary.x == 0 || curBoundary.y == 0) { - // do not show feedback, this is a defunct boundary - continue; - } - - for (j = 0; j < 4; ++j) { - Coord3D startPt, endPt; - - if (j == 0) { - startPt.x = startPt.y = 0; - startPt.x *= MAP_XY_FACTOR; - startPt.y *= MAP_XY_FACTOR; - startPt.z = TheTerrainRenderObject->getHeightMapHeight(startPt.x, startPt.y, nullptr); - endPt.x = 0; - endPt.y = curBoundary.y; - endPt.x *= MAP_XY_FACTOR; - endPt.y *= MAP_XY_FACTOR; - endPt.z = TheTerrainRenderObject->getHeightMapHeight(endPt.x, endPt.y, nullptr); - } else if (j == 1) { - startPt = endPt; - endPt.x = curBoundary.x; - endPt.y = curBoundary.y; - endPt.x *= MAP_XY_FACTOR; - endPt.y *= MAP_XY_FACTOR; - endPt.z = TheTerrainRenderObject->getHeightMapHeight(endPt.x, endPt.y, nullptr); - } else if (j == 2) { - startPt = endPt; - endPt.x = curBoundary.x; - endPt.y = 0; - endPt.x *= MAP_XY_FACTOR; - endPt.y *= MAP_XY_FACTOR; - endPt.z = TheTerrainRenderObject->getHeightMapHeight(endPt.x, endPt.y, nullptr); - } else if (j == 3) { - startPt = endPt; - endPt.x = 0; - endPt.y = 0; - endPt.x *= MAP_XY_FACTOR; - endPt.y *= MAP_XY_FACTOR; - endPt.z = TheTerrainRenderObject->getHeightMapHeight(endPt.x, endPt.y, nullptr); - } - - if (m_feedbackVertexCount + 8 > NUM_FEEDBACK_VERTEX) { - return; - } - - if (m_feedbackIndexCount + 12 > NUM_FEEDBACK_INDEX) { - return; - } - - Vector3 normal(endPt.x - startPt.x, endPt.y - startPt.y, endPt.z - startPt.z); - normal.Normalize(); - normal *= LINE_THICKNESS; - normal.Rotate_Z(PI/2); - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x+normal.X; - curVb->y = startPt.y+normal.Y; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x-normal.X; - curVb->y = startPt.y-normal.Y; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = endPt.x+normal.X; - curVb->y = endPt.y+normal.Y; - curVb->z = endPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = endPt.x-normal.X; - curVb->y = endPt.y-normal.Y; - curVb->z = endPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-2; - m_feedbackIndexCount+=6; - - // draw a little nugget - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x; - curVb->y = startPt.y - HANDLE_SIZE; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x - HANDLE_SIZE; - curVb->y = startPt.y; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x; - curVb->y = startPt.y + HANDLE_SIZE; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x + HANDLE_SIZE; - curVb->y = startPt.y; - curVb->z = startPt.z; - curVb->diffuse = BORDER_COLORS[i % BORDER_COLORS_SIZE ].m_borderColor; - curVb++; - m_feedbackVertexCount++; - - *curIb++ = m_feedbackVertexCount - 4; - *curIb++ = m_feedbackVertexCount - 2; - *curIb++ = m_feedbackVertexCount - 3; - *curIb++ = m_feedbackVertexCount - 4; - *curIb++ = m_feedbackVertexCount - 1; - *curIb++ = m_feedbackVertexCount - 2; - m_feedbackIndexCount+=6; - } - // need to push handles in heie. - } -} - -// update the ambient sound Vertex buffers. -// We basically just draw a flag using 12 verts. -// |\ -// | \ -// | / -// |/ -// || -// || -static const Int poleHeight = 20; -static const Int poleWidth = 2; -static const Int flagHeight = 10; -static const Int flagWidth = 10; - -void DrawObject::updateAmbientSoundVB() -{ - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - MapObject* mo = MapObject::getFirstMapObject(); - - while (mo) { - if (!mo->getThingTemplate() || (mo->getThingTemplate()->getEditorSorting() != ES_AUDIO)) { - mo = mo->getNext(); - continue; - } - - Coord3D startPt = *mo->getLocation(); - startPt.z = TheTerrainRenderObject->getHeightMapHeight(startPt.x, startPt.y, nullptr); - - if (m_feedbackVertexCount + 6 > NUM_FEEDBACK_VERTEX) { - return; - } - - if (m_feedbackIndexCount + 12 > NUM_FEEDBACK_INDEX) { - return; - } - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x; - curVb->y = startPt.y; - curVb->z = startPt.z; - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x; - curVb->y = startPt.y; - curVb->z = startPt.z + poleHeight; - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x + poleWidth; - curVb->y = startPt.y; - curVb->z = startPt.z + poleHeight; - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x + poleWidth; - curVb->y = startPt.y; - curVb->z = startPt.z; - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x; - curVb->y = startPt.y; - curVb->z = startPt.z + poleHeight + flagHeight; - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = startPt.x + flagWidth; - curVb->y = startPt.y; - curVb->z = startPt.z + poleHeight + (flagHeight / 2); - curVb->diffuse = 0xFF2525EF; - ++curVb; - ++m_feedbackVertexCount; - - *curIb++ = m_feedbackVertexCount-6; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-5; - - *curIb++ = m_feedbackVertexCount-6; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-4; - - *curIb++ = m_feedbackVertexCount-5; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - - *curIb++ = m_feedbackVertexCount-5; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-1; - m_feedbackIndexCount += 12; - - mo = mo->getNext(); - } -} - -/** updateMeshVB puts waypoint path triangles into m_vertexFeedback. */ - -void DrawObject::updateWaypointVB() -{ -// const Int theAlpha = 64; - - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - Int i; - for (i = 0; i<=pDoc->getNumWaypointLinks(); i++) { - Bool gotLocation=false; - Coord3D loc1; - Coord3D loc2; - Bool exists; - Int waypointID1, waypointID2; - - Int k; - for (k=0; k<2; k++) { - Bool ok = false; - pDoc->getWaypointLink(i, &waypointID1, &waypointID2); - if (k==0 || i==pDoc->getNumWaypointLinks()) { - ok = (k==0); - } else { - MapObject *pWay = pDoc->getWaypointByID(waypointID1); - if (pWay) { - Bool biDirectional = pWay->getProperties()->getBool(TheKey_waypointPathBiDirectional, &exists); - if (biDirectional) { - ok = true; - pDoc->getWaypointLink(i, &waypointID2, &waypointID1); - } - } - } - - if (i==pDoc->getNumWaypointLinks()) { - if (m_dragWaypointFeedback) { - loc1 = m_dragWayStart; - loc2 = m_dragWayEnd; - gotLocation = true; - } - } else { - MapObject *pWay1, *pWay2; - pWay1 = pDoc->getWaypointByID(waypointID1); - pWay2 = pDoc->getWaypointByID(waypointID2); - if (pWay1 && pWay2) { - gotLocation = true; - loc1 = *pWay1->getLocation(); - loc2 = *pWay2->getLocation(); - AsciiString wayLayer; - wayLayer = pWay1->getProperties()->getAsciiString(TheKey_objectLayer, &exists); - if (exists && TheLayersList->isLayerHidden(wayLayer)) { - gotLocation = false; - } - - wayLayer = pWay2->getProperties()->getAsciiString(TheKey_objectLayer, &exists); - if (exists && TheLayersList->isLayerHidden(wayLayer)) { - gotLocation = false; - } - } - } - if (gotLocation) { - - Vector3 normal(loc2.x-loc1.x, loc2.y-loc1.y, loc2.z-loc1.z); - normal.Normalize(); - normal *= 0.5f; - // Rotate the normal 90 degrees. - normal.Rotate_Z(PI/2); - loc1.z = TheTerrainRenderObject->getHeightMapHeight(loc1.x, loc1.y, nullptr); - loc2.z = TheTerrainRenderObject->getHeightMapHeight(loc2.x, loc2.y, nullptr); - - if (m_feedbackVertexCount+9>= NUM_FEEDBACK_VERTEX) { - return; - } - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x+normal.X; - curVb->y = loc1.y+normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFF000000; // black. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x-normal.X; - curVb->y = loc1.y-normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFF000000; // black. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x+normal.X; - curVb->y = loc2.y+normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x-normal.X; - curVb->y = loc2.y-normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - - if (m_feedbackIndexCount+12 >= NUM_FEEDBACK_INDEX) { - return; - } - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-2; - m_feedbackIndexCount+=6; - - // Do arrowhead. - Vector3 vec(loc2.x-loc1.x, loc2.y-loc1.y, loc2.z-loc1.z); - vec.Normalize(); - const Real ARROWHEAD_LEN = 10.0f; - const Real NORMAL_SHIFT = 6.0f; - - vec *=ARROWHEAD_LEN; - loc1.x = loc2.x - vec.X; - loc1.y = loc2.y - vec.Y; - loc1.z = loc2.z - vec.Z; - if (m_feedbackVertexCount+9>= NUM_FEEDBACK_VERTEX) { - return; - } - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x+NORMAL_SHIFT*normal.X+normal.X; - curVb->y = loc1.y+NORMAL_SHIFT*normal.Y+normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x+NORMAL_SHIFT*normal.X; - curVb->y = loc1.y+NORMAL_SHIFT*normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x+normal.X; - curVb->y = loc2.y+normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x-normal.X; - curVb->y = loc2.y-normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - - if (m_feedbackIndexCount+12 >= NUM_FEEDBACK_INDEX) { - return; - } - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-2; - m_feedbackIndexCount+=6; - - if (m_feedbackVertexCount+9>= NUM_FEEDBACK_VERTEX) { - return; - } - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x-NORMAL_SHIFT*normal.X; - curVb->y = loc1.y-NORMAL_SHIFT*normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x-NORMAL_SHIFT*normal.X-normal.X; - curVb->y = loc1.y-NORMAL_SHIFT*normal.Y-normal.Y; - curVb->z = loc1.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x+normal.X; - curVb->y = loc2.y+normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x-normal.X; - curVb->y = loc2.y-normal.Y; - curVb->z = loc2.z; - curVb->diffuse = 0xFFFF0000; // red. - curVb++; - m_feedbackVertexCount++; - - if (m_feedbackIndexCount+12 >= NUM_FEEDBACK_INDEX) { - return; - } - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-2; - m_feedbackIndexCount+=6; - } - } - } -} - -/** updateMeshVB puts polygon trigger triangles into m_vertexFeedback. */ - -void DrawObject::updatePolygonVB(PolygonTrigger *pTrig, Bool selected, Bool isOpen) -{ -// const Int theAlpha = 64; - - Int green = 0; - if (selected) { - green = (255*curHighlight) / (NUM_HIGHLIGHT-1); - } - green = green<<8; - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - Int i; - for (i=0; igetNumPoints(); i++) { - Coord3D loc1; - Coord3D loc2; - ICoord3D iLoc = *pTrig->getPoint(i); - loc1.x = iLoc.x; - loc1.y = iLoc.y; - loc1.z = TheTerrainRenderObject->getHeightMapHeight(loc1.x, loc1.y, nullptr); - if (igetNumPoints()-1) { - iLoc = *pTrig->getPoint(i+1); - } else { - if (isOpen) break; - iLoc = *pTrig->getPoint(0); - } - loc2.x = iLoc.x; - loc2.y = iLoc.y; - loc2.z = TheTerrainRenderObject->getHeightMapHeight(loc2.x, loc2.y, nullptr); - Vector3 normal(loc2.x-loc1.x, loc2.y-loc1.y, loc2.z-loc1.z); - normal.Normalize(); - normal *= 0.5f; - // Rotate the normal 90 degrees. - normal.Rotate_Z(PI/2); - // Put in the "center anchor" - - if (m_feedbackVertexCount+9>= NUM_FEEDBACK_VERTEX) { - return; - } - Int diffuse = 0xFFFF0000+green; - if (pTrig->isWaterArea()) { - diffuse = 0xFF0000FF+green; - } - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x+normal.X; - curVb->y = loc1.y+normal.Y; - curVb->z = loc1.z; - curVb->diffuse = diffuse; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc1.x-normal.X; - curVb->y = loc1.y-normal.Y; - curVb->z = loc1.z; - curVb->diffuse = diffuse; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x+normal.X; - curVb->y = loc2.y+normal.Y; - curVb->z = loc2.z; - curVb->diffuse = diffuse; - curVb++; - m_feedbackVertexCount++; - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = loc2.x-normal.X; - curVb->y = loc2.y-normal.Y; - curVb->z = loc2.z; - curVb->diffuse = diffuse; - curVb++; - m_feedbackVertexCount++; - - if (m_feedbackIndexCount+12 >= NUM_FEEDBACK_INDEX) { - return; - } - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-1; - *curIb++ = m_feedbackVertexCount-2; - *curIb++ = m_feedbackVertexCount-4; - *curIb++ = m_feedbackVertexCount-3; - *curIb++ = m_feedbackVertexCount-2; - m_feedbackIndexCount+=6; - - } -} - - -/** updateFeedbackVB puts brush feedback triangles into m_vertexFeedback. */ - -void DrawObject::updateFeedbackVB() -{ - const Int theAlpha = 64; - m_feedbackVertexCount = 0; - m_feedbackIndexCount = 0; - DX8IndexBufferClass::WriteLockClass lockIdxBuffer(m_indexFeedback, D3DLOCK_DISCARD); - UnsignedShort *ib=lockIdxBuffer.Get_Index_Array(); - UnsignedShort *curIb = ib; - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexFeedback, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - VertexFormatXYZDUV1 *curVb = vb; - - Bool doubleResolution = 0; - Int brushWidth = m_brushWidth; - Int featherWidth = m_brushFeatherWidth; - - Int shadeR, shadeG, shadeB; - shadeR = 0; - shadeG = 125; - shadeB = 255; - Int diffuse=shadeB | (shadeG << 8) | (shadeR << 16) | (theAlpha << 24); - Int featherDiffuse = (shadeG << 8) ; - Real radius = m_brushWidth/2.0 + m_brushFeatherWidth; - - if (!m_squareFeedback) { - if (radius < MAX_RADIUS/2) { - brushWidth = brushWidth*2; - featherWidth = featherWidth*2; - doubleResolution = true; - radius = brushWidth/2.0 + featherWidth; - } - radius++; - } - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); -#define ADJUST_FROM_INDEX_TO_REAL(k) ((k-pMap->getBorderSize())*MAP_XY_FACTOR) - - if (radius > MAX_RADIUS) radius = MAX_RADIUS; - Real offset = 0; - if (m_brushWidth&1) offset = 0.5f; - Int minX = floor(m_cellCenter.x-radius+offset); - Int minY = floor(m_cellCenter.y-radius+offset); - Int maxX = minX+2*radius; - Int maxY = minY+2*radius; - maxX++; maxY++; - Int i, j; -// int sub = m_brushWidth/2; -// int add = m_brushWidth-sub; - for (j=minY; j= NUM_FEEDBACK_VERTEX) return; - if (m_squareFeedback) { - curVb->diffuse = diffuse; - } else { - Real blendFactor = Tool::calcRoundBlendFactor(m_cellCenter, i, j, brushWidth, featherWidth); - if (blendFactor > 0.99) { - curVb->diffuse = diffuse; - } else if (blendFactor > 0.05) { - curVb->diffuse = featherDiffuse | (theAlpha<<24); - } else { - curVb->diffuse = 0; - } - } - Real X, Y, theZ; - if (doubleResolution) { - X = ADJUST_FROM_INDEX_TO_REAL(i)/2.0f + ADJUST_FROM_INDEX_TO_REAL(2*offset+m_cellCenter.x) / 2.0; - Y = ADJUST_FROM_INDEX_TO_REAL(j)/2.0f + ADJUST_FROM_INDEX_TO_REAL(2*offset+m_cellCenter.y) / 2.0; - theZ = TheTerrainRenderObject->getHeightMapHeight(X, Y, nullptr); - } else { - X = ADJUST_FROM_INDEX_TO_REAL(i); - Y = ADJUST_FROM_INDEX_TO_REAL(j); - theZ = TheTerrainRenderObject->getHeightMapHeight(X, Y, nullptr); - } - curVb->u1 = 0; - curVb->v1 = 0; - curVb->x = X; - curVb->y = Y; - curVb->z = theZ; - curVb++; - m_feedbackVertexCount++; - } - } - Int yOffset = maxX-minX; - Int halfWidth = yOffset/2; - for (j=0; j NUM_FEEDBACK_INDEX) return; - { - Bool flipForBlend = false; - if (i>=halfWidth && j>=halfWidth) flipForBlend = true; - if (i0) return 1; - return 0; -} - - -/** updateForWater puts a blue rectangle into the vertex buffer. */ - -void DrawObject::updateForWater() -{ -} - -/* This is a code snippet that starts to attempt to solve the concave area problem, -but doesn't, really. - const Int maxPoints = 256; - Bool pointFlags[256]; - Int numPoints = pTrig->getNumPoints(); - ICoord3D pLL1, pLL2, pLL3; - if (numPoints < 3) continue; - pLL1 = *pTrig->getPoint(numPoints-1); - pLL2 = *pTrig->getPoint(0); - pLL3 = *pTrig->getPoint(1); - pointFlags[0] = true; - for (k=1; kgetPoint(k); - if (pt.y < pLL2.y || (pt.y==pLL2.y && pt.xgetPoint(k-1); - if (kgetPoint(k+1); - } else { - pLL3 = *pTrig->getPoint(0); - } - } - } - ICoord3D v1, v2; - v1.x = pLL2.x-pLL1.x; - v1.y = pLL2.y-pLL1.y; - v1.z = 0; - v2.x = pLL3.x-pLL2.x; - v2.y = pLL3.y-pLL2.y; - v2.z = 0; - Int windingXpdct = xpSign(v1, v2); - if (windingXpdct == 0) windingXpdct = -1; - Bool didSomething = true; - while (didSomething) { - didSomething = false; - - for (k=0; kgetNumPoints()-1; k++) { - if (!pointFlags[k]) continue; - Int kPlus1; - for (kPlus1 = k+1; kPlus1 < pTrig->getNumPoints()-1; kPlus1++) { - if (pointFlags[kPlus1]) break; - } - if (kPlus1 >= pTrig->getNumPoints()-1) continue; - Int kPlus2 = kPlus1+1; - for (kPlus2 = kPlus1+1; kPlus2 < pTrig->getNumPoints(); kPlus2++) { - if (pointFlags[kPlus2]) break; - } - - ICoord3D pt1 = *pTrig->getPoint(k); - ICoord3D pt2 = *pTrig->getPoint(kPlus1); - ICoord3D pt3 = *pTrig->getPoint(kPlus2); - - -*/ - - -/** updateVB puts a circle with an arrow into the vertex buffer. */ - -Int DrawObject::updateVB(DX8VertexBufferClass *pVB, Int color, Bool doArrow, Bool doDiamond) -{ - Int i, k; - - Real factor = TheGlobalData->m_terrainAmbient[0].red + - TheGlobalData->m_terrainAmbient[0].green + - TheGlobalData->m_terrainAmbient[0].blue; - if (factor > 1.0f) factor = 1.0f; - Int r = color&0xFF; - Int g = (color&0x00FF00)>>8; - Int b = (color&0xFF0000)>>16; - - r *= factor; - g *= factor; - b *= factor; - const Int theAlpha = 127; - static const Int highlightColors[NUM_HIGHLIGHT] = { ((255<<8) + (255<<16)) , - ((255<<16)), (255<<8) }; - Int diffuse = b + (g<<8) + (r<<16) + (theAlpha<<24); // b g<<8 r<<16 a<<24. - if (pVB ) - { - - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(pVB, D3DLOCK_DISCARD); - VertexFormatXYZDUV1 *vb = (VertexFormatXYZDUV1*)lockVtxBuffer.Get_Vertex_Array(); - - const Real theZ = 0.0f; - Real theRadius = THE_RADIUS; - Real halfLineWidth = 0.03f*MAP_XY_FACTOR; - if (doDiamond) { - theRadius *= 5.0; - } - else - { - theRadius *= 2.0; - } - - Int limit = NUM_TRI-(NUM_ARROW_TRI+NUM_SELECT_TRI); - float curAngle = 0; - float deltaAngle = 2*PI/limit; - if (doDiamond) { - deltaAngle = PI/2; - } - for (i=0; iz= theZ; - if (k==0) { - vb->x= 0; - vb->y= 0; - - Vector3 vec(0,0,theZ); - vec.Rotate_Z(curAngle+(deltaAngle/2)); - vb->x= vec.X; - vb->y= vec.Y; - } else if (k==1) { - Vector3 vec(theRadius/10,0,theZ); - vec.Rotate_Z(curAngle); - vb->x= vec.X; - vb->y= vec.Y; - } else if (k==2) { - Real angle = curAngle+deltaAngle; - if (i==limit-1) { - angle = 0; - } - Vector3 vec(theRadius/10,0,theZ); - vec.Rotate_Z(angle); - vb->x= vec.X; - vb->y= vec.Y; - } - vb->diffuse=diffuse; - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - if (k==0) { - vb[3*NUM_TRI].z += 3.0; - vb[3*NUM_TRI].diffuse = diffuse; - } - vb++; - } - curAngle += deltaAngle; - } - - if (!doDiamond) { - theRadius /= 2.0; - } - - if (!doArrow) { - theRadius /= 20; - halfLineWidth /= 20; - } - /* Now do the arrow. */ - for (k=0; k<3; k++) { - vb->x= (k&1)?2*theRadius:0.0f; - vb->y= -halfLineWidth + ((k&2)?2*halfLineWidth:0); - vb->z= theZ; - vb->diffuse=highlightColors[curHighlight] + (theAlpha<<24); - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - for (k=0; k<3; k++) { - vb->x= (k&1)?0.0f:2*theRadius; - vb->y= halfLineWidth - ((k&2)?2*halfLineWidth:0); - vb->z= theZ; - vb->diffuse=highlightColors[curHighlight] + (theAlpha<<24); - vb->u1=0; - vb->v1=0; - vb++; - } - for (k=0; k<3; k++) { - if (k==0) { vb->x=theRadius; vb->y = 0;} - else if (k==1) { vb->x=2*theRadius + 2*halfLineWidth; vb->y = 0;} - else { vb->x=theRadius; vb->y = 2*halfLineWidth;} - vb->z= theZ; - vb->diffuse=highlightColors[curHighlight] + (theAlpha<<24); - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - for (k=0; k<3; k++) { - if (k==0) { vb->x=theRadius; vb->y = 0;} - else if (k==1) { vb->x=theRadius; vb->y = -2*halfLineWidth;} - else { vb->x=2*theRadius + 2*halfLineWidth; vb->y = 0;} - vb->z= theZ; - vb->diffuse=highlightColors[curHighlight] + (theAlpha<<24); - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - - if (!doArrow) { - theRadius *= 20; - halfLineWidth *= 20; - } - - - limit = NUM_SELECT_TRI; - curAngle = 0; - deltaAngle = 2*PI/limit; - if (doDiamond) { - theRadius/=5.0f; - } - for (i=0; iz= theZ; - if (k==0) { - vb->x= 0; - vb->y= 0; - - Vector3 vec(theRadius*4/5,0,theZ); - vec.Rotate_Z(curAngle+(deltaAngle/2)); - vb->x= vec.X; - vb->y= vec.Y; - } else if (k==1) { - Vector3 vec(theRadius,0,theZ); - vec.Rotate_Z(curAngle); - vb->x= vec.X; - vb->y= vec.Y; - } else if (k==2) { - Real angle = curAngle+deltaAngle; - if (i==limit-1) { - angle = 0; - } - Vector3 vec(theRadius,0,theZ); - vec.Rotate_Z(angle); - vb->x= vec.X; - vb->y= vec.Y; - } - vb->diffuse = highlightColors[curHighlight] + (theAlpha<<24); - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - if (k==0) { - vb[3*NUM_TRI].z += 3.0; - vb[3*NUM_TRI].diffuse = highlightColors[curHighlight] + (theAlpha<<24); // b g<<8 r<<16 a<<24. - } - vb++; - } - curAngle += deltaAngle; - - } - -#if 0 - // Now do the highlight triangle. This is in yellow. - for (k=0; k<3; k++) { - vb->x = k==0?theRadius:0; - vb->y = k==1?theRadius:0; - vb->z= k==2?theZ+SELECT_PYRAMID_HEIGHT:theZ; - vb->diffuse= highlightColors[curHighlight] + (theAlpha<<24); // b g<<8 r<<16 a<<24. - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - for (k=0; k<3; k++) { - vb->x = k==1?-theRadius:0; - vb->y = k==0?theRadius:0; - vb->z= k==2?theZ+SELECT_PYRAMID_HEIGHT:theZ; - vb->diffuse= highlightColors[curHighlight] + (theAlpha<<24); // b g<<8 r<<16 a<<24. - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - - for (k=0; k<3; k++) { - vb->x = k==1?theRadius:0; - vb->y = k==0?-theRadius:0; - vb->z= k==2?theZ+SELECT_PYRAMID_HEIGHT:theZ; - vb->diffuse= highlightColors[curHighlight] + (theAlpha<<24); // b g<<8 r<<16 a<<24. - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } - for (k=0; k<3; k++) { - vb->x = k==0?-theRadius:0; - vb->y = k==1?-theRadius:0; - vb->z= k==2?theZ+SELECT_PYRAMID_HEIGHT:theZ; - vb->diffuse= highlightColors[curHighlight] + (theAlpha<<24); // b g<<8 r<<16 a<<24. - vb->u1=0; - vb->v1=0; - vb[3*NUM_TRI] = *vb; - vb++; - } -#endif - return 0; //success. - } - return -1; -} - -#define BOUNDING_BOX_LINE_WIDTH 2.0f -/** Draw an object's bounding box into the vertex buffer. **/ -// MLL C&C3 -void DrawObject::updateVBWithBoundingBox(MapObject *pMapObj, CameraClass* camera) -{ - if (!pMapObj || !m_lineRenderer || !pMapObj->getThingTemplate()) { - return; - } - - unsigned long color = 0xFFAA00AA; // Purple - - GeometryInfo ginfo = pMapObj->getThingTemplate()->getTemplateGeometryInfo(); - - Coord3D pos = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - // Make sure that the position is on the terrain. - pos.z += TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - switch (ginfo.getGeomType()) - { - //--------------------------------------------------------------------------------------------- - case GEOMETRY_BOX: - { - Real angle = pMapObj->getAngle(); - Real c = (Real)cos(angle); - Real s = (Real)sin(angle); - Real exc = ginfo.getMajorRadius()*c; - Real eyc = ginfo.getMinorRadius()*c; - Real exs = ginfo.getMajorRadius()*s; - Real eys = ginfo.getMinorRadius()*s; - Coord3D pts[4]; - pts[0].x = pos.x - exc - eys; - pts[0].y = pos.y + eyc - exs; - pts[0].z = 0; - pts[1].x = pos.x + exc - eys; - pts[1].y = pos.y + eyc + exs; - pts[1].z = 0; - pts[2].x = pos.x + exc + eys; - pts[2].y = pos.y - eyc + exs; - pts[2].z = 0; - pts[3].x = pos.x - exc + eys; - pts[3].y = pos.y - eyc - exs; - pts[3].z = 0; - Real z = pos.z; - for (int i = 0; i < 2; i++) { - for (int corner = 0; corner < 4; corner++) { - ICoord2D start, end; - pts[corner].z = z; - pts[(corner+1)&3].z = z; - bool shouldStart = worldToScreen(&pts[corner], &start, camera); - bool shouldEnd = worldToScreen(&pts[(corner+1)&3], &end, camera); - if (shouldStart && shouldEnd) { - m_lineRenderer->Add_Line(Vector2(start.x, start.y), Vector2(end.x, end.y), BOUNDING_BOX_LINE_WIDTH, color); - } - } - - z += ginfo.getMaxHeightAbovePosition(); - } - break; - } - - //--------------------------------------------------------------------------------------------- - case GEOMETRY_SPHERE: // not quite right, but close enough - case GEOMETRY_CYLINDER: - { - Real angle, inc = PI/4.0f; - Real radius = ginfo.getMajorRadius(); - Coord3D pnt, lastPnt; - ICoord2D start, end; - Real z = pos.z; - - bool shouldEnd, shouldStart; - // Draw the cylinder. - for (int i=0; i<2; i++) { - angle = 0.0f; - lastPnt.x = pos.x + radius * (Real)cos(angle); - lastPnt.y = pos.y + radius * (Real)sin(angle); - lastPnt.z = z; - shouldEnd = worldToScreen(&lastPnt, &end, camera); - - for( angle = inc; angle <= 2.0f * PI; angle += inc ) { - pnt.x = pos.x + radius * (Real)cos(angle); - pnt.y = pos.y + radius * (Real)sin(angle); - pnt.z = z; - shouldStart = worldToScreen(&pnt, &start, camera); - if (shouldStart && shouldEnd) { - m_lineRenderer->Add_Line(Vector2(start.x, start.y), Vector2(end.x, end.y), BOUNDING_BOX_LINE_WIDTH, color); - } - lastPnt = pnt; - end = start; - shouldEnd = shouldStart; - } - - // Next time around, draw the top of the cylinder. - z += ginfo.getMaxHeightAbovePosition(); - } - - // Draw centerline - pnt.x = pos.x; - pnt.y = pos.y; - pnt.z = pos.z; - shouldStart = worldToScreen( &pnt, &start, camera); - pnt.z = pos.z + ginfo.getMaxHeightAbovePosition(); - shouldEnd = worldToScreen( &pnt, &end, camera); - if (shouldStart && shouldEnd) { - m_lineRenderer->Add_Line(Vector2(start.x, start.y), Vector2(end.x, end.y), BOUNDING_BOX_LINE_WIDTH, color); - } - break; - } - } -} - -/** Draw a "circle" into the m_lineRenderer, e.g. to visualize weapon range, sight range, sound range **/ -void DrawObject::addCircleToLineRenderer( const Coord3D & center, Real radius, Real width, unsigned long color, CameraClass* camera ) -{ - Real angle, inc = PI/4.0f; - Coord3D pnt, lastPnt; - ICoord2D start, end; - Real z = center.z; - - // Draw the circle. - angle = 0.0f; - lastPnt.x = center.x + radius * (Real)cos(angle); - lastPnt.y = center.y + radius * (Real)sin(angle); - lastPnt.z = z; - bool shouldEnd = worldToScreen(&lastPnt, &end, camera); - - for( angle = inc; angle <= 2.0f * PI; angle += inc ) { - pnt.x = center.x + radius * (Real)cos(angle); - pnt.y = center.y + radius * (Real)sin(angle); - pnt.z = z; - - bool shouldStart = worldToScreen(&pnt, &start, camera); - if (shouldStart && shouldEnd) { - m_lineRenderer->Add_Line(Vector2(start.x, start.y), Vector2(end.x, end.y), width, color); - } - - lastPnt = pnt; - end = start; - shouldEnd = shouldStart; - } - -} - -#define SIGHT_RANGE_LINE_WIDTH 2.0f -/** Draw an object's sight range into the vertex buffer. **/ -// MLL C&C3 -void DrawObject::updateVBWithSightRange(MapObject *pMapObj, CameraClass* camera) -{ - if (!pMapObj || !m_lineRenderer || !pMapObj->getThingTemplate()) { - return; - } - - const unsigned long color = 0xFFF0F0F0; // Light blue. - - Real radius = pMapObj->getThingTemplate()->friend_calcVisionRange(); - - Coord3D pos = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - // Make sure that the position is on the terrain. - pos.z += TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - addCircleToLineRenderer(pos, radius, SIGHT_RANGE_LINE_WIDTH, color, camera ); -} - -#define WEAPON_RANGE_LINE_WIDTH 1.0f -/** Draw an object's weapon range into the vertex buffer. **/ -// MLL C&C3 -void DrawObject::updateVBWithWeaponRange(MapObject *pMapObj, CameraClass* camera) -{ - if (!pMapObj || !m_lineRenderer || !pMapObj->getThingTemplate()) { - return; - } - - const unsigned long colors[WEAPONSLOT_COUNT] = {0xFF00FF00, 0xFFE0F00A, 0xFFFF0000}; // Green, Yellow, Red - - - Coord3D pos = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - // Make sure that the position is on the terrain. - pos.z += TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - const WeaponTemplateSetVector& weapons = pMapObj->getThingTemplate()->getWeaponTemplateSets(); - - for (WeaponTemplateSetVector::const_iterator it = weapons.begin(); it != weapons.end(); ++it) { - if (it->hasAnyWeapons() == false) { - continue; - } - - for (int i = 0; i < WEAPONSLOT_COUNT; i++) { - const WeaponTemplate* tmpl = it->getNth((WeaponSlotType)i); - - if (tmpl == nullptr) { - continue; - } - - Real radius = tmpl->getUnmodifiedAttackRange(); - - addCircleToLineRenderer(pos, radius, WEAPON_RANGE_LINE_WIDTH, colors[i], camera ); - } - } -} - -#define SOUND_RANGE_LINE_WIDTH 1.0f -/** Draw an object's min & max sound ranges into the vertex buffer. **/ -// MLL C&C3 -void DrawObject::updateVBWithSoundRanges(MapObject *pMapObj, CameraClass* camera) -{ - if (!pMapObj || !m_lineRenderer) { - return; - } - - const unsigned long colors[2] = {0xFF0000FF, 0xFFFF00FF}; // Blue and purple - // Colors match those used in W3DView.cpp - - - Coord3D pos = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - // Make sure that the position is on the terrain. - pos.z += TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - // Does this object actually have an attached sound? - const AudioEventInfo * audioInfo = nullptr; - - Dict * properties = pMapObj->getProperties(); - - Bool exists = false; - AsciiString ambientName = properties->getAsciiString( TheKey_objectSoundAmbient, &exists ); - - if ( exists ) - { - if ( ambientName.isEmpty() ) - { - // User has removed normal sound - return; - } - else - { - if ( TheAudio == nullptr ) - { - DEBUG_CRASH( ("TheAudio is null! Can't draw sound circles") ); - return; - } - - audioInfo = TheAudio->findAudioEventInfo( ambientName ); - - if ( audioInfo == nullptr ) - { - DEBUG_CRASH( ("Override audio named %s is missing; Can't draw sound circles", ambientName.str() ) ); - return; - } - } - } - else - { - const ThingTemplate * thingTemplate = pMapObj->getThingTemplate(); - if ( thingTemplate == nullptr ) - { - // No sound if no template - return; - } - - if ( !thingTemplate->hasSoundAmbient() ) - { - return; - } - - const AudioEventRTS * event = thingTemplate->getSoundAmbient(); - - if ( event == nullptr ) - { - return; - } - - audioInfo = event->getAudioEventInfo(); - - if ( audioInfo == nullptr ) - { - // May just not be set up yet - if ( TheAudio == nullptr ) - { - DEBUG_CRASH( ("TheAudio is null! Can't draw sound circles") ); - return; - } - - audioInfo = TheAudio->findAudioEventInfo( event->getEventName() ); - - if ( audioInfo == nullptr ) - { - DEBUG_CRASH( ("Default ambient sound %s has no info; Can't draw sound circles", event->getEventName().str() ) ); - return; - } - } - } - - // Should have set up audioInfo or returned by now - DEBUG_ASSERTCRASH( audioInfo != nullptr, ("Managed to finish setting up audio info without setting it?!?" ) ); - if ( audioInfo == nullptr ) - { - return; - } - - // Get the current radius (could be overridden) - Real minRadius = audioInfo->m_minDistance; - Real maxRadius = audioInfo->m_maxDistance; - Bool customized = properties->getBool( TheKey_objectSoundAmbientCustomized, &exists ); - if ( exists && customized ) - { - Real valReal; - - valReal = properties->getReal( TheKey_objectSoundAmbientMinRange, &exists ); - if ( exists ) - { - minRadius = valReal; - } - valReal = properties->getReal( TheKey_objectSoundAmbientMaxRange, &exists ); - if ( exists ) - { - maxRadius = valReal; - } - } - addCircleToLineRenderer(pos, minRadius, SOUND_RANGE_LINE_WIDTH, colors[0], camera ); - addCircleToLineRenderer(pos, maxRadius, SOUND_RANGE_LINE_WIDTH, colors[1], camera ); -} - - -#define TEST_ART_HIGHLIGHT_LINE_WIDTH 5.0f -/** Draw test art with an X on it. **/ -// MLL C&C3 -void DrawObject::updateVBWithTestArtHighlight(MapObject *pMapObj, CameraClass* camera) -{ - if (!pMapObj || !m_lineRenderer || pMapObj->getThingTemplate() || pMapObj->isScorch()) { - // It is test art if it doesn't have a ThingTemplate. - return; - } - - unsigned long color = 0xFFA000A0; // Purple - - - Coord3D pos = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - // Make sure that the position is on the terrain. - pos.z += TheTerrainRenderObject->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - Real angle, inc = PI/2.0f; - Coord3D pnt, lastPnt; - ICoord2D start, end; - Real z = pos.z; - Real radius = 30.0f; - - // Draw the diamond. - angle = 0.0f; - lastPnt.x = pos.x + radius * (Real)cos(angle); - lastPnt.y = pos.y + radius * (Real)sin(angle); - lastPnt.z = z; - bool shouldEnd = worldToScreen(&lastPnt, &end, camera); - - for( angle = inc; angle <= 2.0f * PI; angle += inc ) { - pnt.x = pos.x + radius * (Real)cos(angle); - pnt.y = pos.y + radius * (Real)sin(angle); - pnt.z = z; - - bool shouldStart = worldToScreen(&pnt, &start, camera); - if (shouldStart && shouldEnd) { - m_lineRenderer->Add_Line(Vector2(start.x, start.y), Vector2(end.x, end.y), TEST_ART_HIGHLIGHT_LINE_WIDTH, color); - } - - lastPnt = pnt; - end = start; - shouldEnd = shouldStart; - } - -} - - -/** Transform a 3D Coordinate into 2D screen space **/ -// MLL C&C3 -bool DrawObject::worldToScreen(const Coord3D *w, ICoord2D *s, CameraClass* camera) -{ - - if ((w == nullptr) || (s == nullptr) || (camera == nullptr)) { - return false; - } - - Vector3 world; - Vector3 screen; - - world.Set(w->x, w->y, w->z); - camera->Project(screen, world); - - // - // note that the screen coord returned from the project W3D camera - // gave us a screen coords that range from (-1,-1) bottom left to - // (1,1) top right ... we are turning that into (0,0) upper left - // coords now - // - W3DLogicalScreenToPixelScreen(screen.X, screen.Y, &s->x, &s->y, m_winSize.x, m_winSize.y); - - if ((screen.X > 2.0f) || (screen.Y > 2.0f) || (screen.X < -2.0f) || (screen.Y < -2.0f)) { - // Too far off the screen. - return false; - } - - return (true); -} - -/** Tells drawobject where the tool is located, so it can draw feedback. */ -void DrawObject::setFeedbackPos(Coord3D pos) -{ - m_feedbackPoint = pos; - // center on half pixel for even widths. - if (!(m_brushWidth&1)) { - pos.x += MAP_XY_FACTOR/2; - pos.y += MAP_XY_FACTOR/2; - } - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return; - CPoint ndx; - pDoc->getCellIndexFromCoord(pos, &ndx); - if (ndx.x != m_cellCenter.x || ndx.y != m_cellCenter.y) { - m_cellCenter = ndx; - if (m_toolWantsFeedback && !m_disableFeedback) { - WbView3d *pView = pDoc->Get3DView(); - if (pView) { - pView->Invalidate(false); - } - } - } -} - -void DrawObject::setRampFeedbackParms(const Coord3D *start, const Coord3D *end, Real rampWidth) -{ - DEBUG_ASSERTCRASH(start && end, ("Parameter passed into setRampFeedbackParms was null. Not allowed")); - if (!(start && end)) { - return; - } - - m_rampStartPoint = *start; - m_rampEndPoint = *end; - m_rampWidth = rampWidth; - -} - - -bool _skip_drawobject_render = false; - -/** Render draws into the current 3d context. */ -void DrawObject::Render(RenderInfoClass & rinfo) -{ -//DEBUG! -if (_skip_drawobject_render) { - return; -} - - if (m_lineRenderer == nullptr) { - // This can't be created in init because the doc hasn't been created yet. - m_lineRenderer = new Render2DClass(); - ASSERT(m_lineRenderer); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - ASSERT(pDoc); - WbView3d *pView = pDoc->Get3DView(); - ASSERT(pView); - m_winSize = pView->getActualWinSize(); - m_lineRenderer->Set_Coordinate_Range(RectClass(0, 0, m_winSize.x, m_winSize.y)); - m_lineRenderer->Reset(); - m_lineRenderer->Enable_Texturing(FALSE); - } - - DX8Wrapper::Apply_Render_State_Changes(); - - DX8Wrapper::Set_Material(m_vertexMaterialClass); - DX8Wrapper::Set_Shader(m_shaderClass); - DX8Wrapper::Set_Texture(0, nullptr); - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - DX8Wrapper::Apply_Render_State_Changes(); - Int count=0; - Int i; - bool linesToRender = false; - - curHighlight++; - if (curHighlight >= NUM_HIGHLIGHT) { - curHighlight = 0; - } - m_waterDrawObject->update(); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile1); - if (m_drawObjects || m_drawWaypoints || m_drawBoundingBoxes || m_drawSightRanges || m_drawWeaponRanges || m_drawSoundRanges || m_drawTestArtHighlight) { - //Apply the shader and material - - //WST Variables below are for optimization to reduce VB updates which are extremely slow - // Optimization strategy is to remember last setting and avoid re-updating unless it changed - int rememberLastSettingVB1 = -99999; - int rememberLastSettingVB2 = -99999; - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - // simple Draw test. - if (pMapObj->getFlags() & FLAG_DONT_RENDER) { - continue; - } - -// DEBUG! -if (pMapObj->isSelected()) { - Transform.Get_Translation(); -} - Coord3D loc = *pMapObj->getLocation(); - if (TheTerrainRenderObject) { - loc.z += TheTerrainRenderObject->getHeightMapHeight(loc.x, loc.y, nullptr); - } - // Cull. - //SphereClass bounds(Vector3(loc.x, loc.y, loc.z), THE_RADIUS); - //if (rinfo.Camera.Cull_Sphere(bounds)) { - // continue; - //} - Bool doArrow = true; - if (pMapObj->getFlag(FLAG_ROAD_FLAGS) || pMapObj->getFlag(FLAG_BRIDGE_FLAGS) || pMapObj->isWaypoint()) - { - doArrow = false; - } - - Bool doDiamond = pMapObj->isWaypoint(); - if (doDiamond) { - if (!m_drawWaypoints) { - continue; - } - } else { - // MLL C&C3 - if (pMapObj->isSelected()) { - if (doArrow && m_drawBoundingBoxes) { - linesToRender = true; - updateVBWithBoundingBox(pMapObj, &rinfo.Camera); - } - if (doArrow && m_drawSightRanges) { - linesToRender = true; - updateVBWithSightRange(pMapObj, &rinfo.Camera); - } - if (doArrow && m_drawWeaponRanges) { - linesToRender = true; - updateVBWithWeaponRange(pMapObj, &rinfo.Camera); - } - if (doArrow && m_drawSoundRanges) { - linesToRender = true; - updateVBWithSoundRanges(pMapObj, &rinfo.Camera); - } - } - - if (doArrow && m_drawTestArtHighlight) { - linesToRender = true; - updateVBWithTestArtHighlight(pMapObj, &rinfo.Camera); - } - - if (!m_drawObjects) { - continue; - } - if (BuildListTool::isActive()) { - continue; - } - } - - if (count&1) { - int setting = pMapObj->getColor(); - - if (doArrow) { - setting |= (1<<25); - } - if (doDiamond) { - setting |= (1<<26); - } - - if (setting != rememberLastSettingVB1) { - rememberLastSettingVB1 = setting; - updateVB(m_vertexBufferTile1,pMapObj->getColor(), doArrow, doDiamond); - } - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile1); - - } else { - int setting = pMapObj->getColor(); - - if (doArrow) { - setting |= (1<<25); - } - if (doDiamond) { - setting |= (1<<26); - } - - if (setting != rememberLastSettingVB2) { - rememberLastSettingVB2 = setting; - updateVB(m_vertexBufferTile2, pMapObj->getColor(), doArrow, doDiamond); - } - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile2); - } - - ///@todo - remove the istree stuff, or get the info from the thing template. jba. - Bool isTree = false; - - Vector3 vec(loc.x, loc.y, loc.z); - Matrix3D tm(Transform); - Matrix3x3 rot(true); - rot.Rotate_Z(pMapObj->getAngle()); - - tm.Set_Translation(vec); - tm.Set_Rotation(rot); - int polyCount = NUM_TRI; - if (!pMapObj->isSelected()) { - polyCount -= NUM_ARROW_TRI+NUM_SELECT_TRI; - } - - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); - if (isTree) { - DX8Wrapper::Draw_Triangles( NUM_TRI*3,polyCount, 0, (m_numTriangles*3)); - } else { - DX8Wrapper::Draw_Triangles( 0,polyCount, 0, (m_numTriangles*3)); - } - - count++; - } - } - if (m_drawPolygonAreas) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferWater); - Int selected; - for (selected = 0; selected < 2; selected++) { - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - if (!pTrig->getShouldRender()) continue; - Bool polySelected = PolygonTool::isSelected(pTrig); - if (polySelected && !selected) continue; - if (!polySelected && selected) continue; - for (i=0; igetNumPoints(); i++) { - Bool pointSelected = (polySelected && PolygonTool::getSelectedPointNdx()==i); - ICoord3D iLoc = *pTrig->getPoint(i); - Coord3D loc; - loc.x = iLoc.x; - loc.y = iLoc.y; - loc.z = TheTerrainRenderObject->getHeightMapHeight(loc.x, loc.y, nullptr); - SphereClass bounds(Vector3(loc.x, loc.y, loc.z), THE_RADIUS); - if (rinfo.Camera.Cull_Sphere(bounds)) { - continue; - } - const Bool ARROW=false; - const Bool DIAMOND=true; - const Int RED = 0x0000FF; // red in BGR. - const Int BLUE = 0xFF7f00; // bright blue. - Int color = RED; - if (pTrig->isWaterArea()) { - color = BLUE; - } - if (count&1) { - updateVB(m_vertexBufferTile1, color, ARROW, DIAMOND); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile1); - } else { - updateVB(m_vertexBufferTile2, color, ARROW, DIAMOND); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile2); - } - count++; - - Vector3 vec(loc.x, loc.y, loc.z); - Matrix3D tm(Transform); - tm.Set_Translation(vec); - - int polyCount = NUM_TRI; - if (!pointSelected) { - polyCount -= NUM_ARROW_TRI+NUM_SELECT_TRI; - } - - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); - DX8Wrapper::Draw_Triangles( 0,polyCount, 0, (m_numTriangles*3)); - } - Matrix3D tmReset(Transform); - DX8Wrapper::Set_Transform(D3DTS_WORLD,tmReset); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile1); - updatePolygonVB(pTrig, polySelected, polySelected && PolygonTool::isSelectedOpen()); - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - } - } - - - if (BuildListTool::isActive()) for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - Coord3D loc = *pBuild->getLocation(); - if (TheTerrainRenderObject) { - loc.z += TheTerrainRenderObject->getHeightMapHeight(loc.x, loc.y, nullptr); - } - // Cull. - SphereClass bounds(Vector3(loc.x, loc.y, loc.z), THE_RADIUS); - if (rinfo.Camera.Cull_Sphere(bounds)) { - continue; - } - if (!m_drawObjects) { - continue; - } - const Int GREEN = 0x00FF00; // GREEN in BGR. - if (count&1) { - updateVB(m_vertexBufferTile1, GREEN, true, false); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile1); - } else { - updateVB(m_vertexBufferTile2, GREEN, true, false); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferTile2); - } - count++; -// ok to here. - Vector3 vec(loc.x, loc.y, loc.z); - Matrix3D tmXX(Transform); - Matrix3x3 rot(true); - rot.Rotate_Z(pBuild->getAngle()); - - tmXX.Set_Translation(vec); - tmXX.Set_Rotation(rot); - int polyCountA = NUM_TRI; - if (!pBuild->isSelected()) { - polyCountA -= NUM_ARROW_TRI+NUM_SELECT_TRI; - } - -#if 1 - DX8Wrapper::Set_Transform(D3DTS_WORLD,tmXX); - DX8Wrapper::Draw_Triangles( 0,polyCountA, 0, (m_numTriangles*3)); -#endif - - } - } - - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferWater); - Matrix3D tmReset(Transform); - DX8Wrapper::Set_Transform(D3DTS_WORLD,tmReset); - - if (m_drawWaypoints) { - updateWaypointVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(m_shaderClass); - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferWater); - } - } - - - -#if 1 - if (m_meshFeedback) { - updateMeshVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(SC_OPAQUE_Z); - DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME); - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } else if (m_toolWantsFeedback && !m_disableFeedback) { - updateFeedbackVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(ShaderClass::_PresetAlpha2DShader); - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } -#endif - -#if 1 - if (m_rampFeedback) { - updateRampVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(SC_OPAQUE_Z); - DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_WIREFRAME); // we want a solid ramp - DX8Wrapper::Set_DX8_Render_State(D3DRS_LIGHTING, FALSE); // disable lighting - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } -#endif - -#if 1 - if (m_boundaryFeedback) { - updateBoundaryVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(m_shaderClass); - DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, D3DCULL_NONE); - DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_SOLID); // we want a solid ramp - DX8Wrapper::Set_DX8_Render_State(D3DRS_LIGHTING, FALSE); // disable lighting - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } -#endif - - DX8Wrapper::Set_Vertex_Buffer(nullptr); //release reference to vertex buffer - DX8Wrapper::Set_Index_Buffer(nullptr,0); //release reference to vertex buffer - - - if (m_ambientSoundFeedback) { - updateAmbientSoundVB(); - if (m_feedbackIndexCount>0) { - DX8Wrapper::Set_Vertex_Buffer(m_vertexFeedback); - DX8Wrapper::Set_Index_Buffer(m_indexFeedback,0); - DX8Wrapper::Set_Shader(m_shaderClass); - DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, D3DCULL_NONE); - DX8Wrapper::Set_DX8_Render_State(D3DRS_FILLMODE,D3DFILL_SOLID); // we want a solid ramp - DX8Wrapper::Set_DX8_Render_State(D3DRS_LIGHTING, FALSE); // disable lighting - DX8Wrapper::Draw_Triangles( 0, m_feedbackIndexCount/3, 0, m_feedbackVertexCount); - } - } - - DX8Wrapper::Set_Index_Buffer(m_indexBuffer,0); - DX8Wrapper::Set_Vertex_Buffer(m_vertexBufferWater); - - if (m_waterDrawObject) { - m_waterDrawObject->renderWater(); - } - - if (m_drawLetterbox) { - int w = m_winSize.x; - int h = m_winSize.y; - int size = (int)((h - (9.0f / 16.0f * w)) * 0.5f); - RectClass rect(0, 0, w, size); - m_lineRenderer->Add_Quad(rect, 0xFF000000); - rect.Set(0, h - size, w, h); - m_lineRenderer->Add_Quad(rect, 0xFF000000); - linesToRender = true; - } - - // Render any lines that have been added, like bounding boxes. - // MLL C&C3 - if (linesToRender && m_lineRenderer) { - m_lineRenderer->Render(); - // Clear the old lines. - m_lineRenderer->Reset(); - } -} - - -void BuildRectFromSegmentAndWidth(const Coord3D* start, const Coord3D* end, Real width, - Coord3D* outBL, Coord3D* outTL, Coord3D* outBR, Coord3D* outTR) -{ -/* - Here's how we're generating the surface to render: - 1) Assign longSeg to be the segment from rampStartPoint to rampStopPoint - 2) Cross product with the segment (0, 0, 1) - 3) Normalize to get the unit vector (which is in the XY plane.) - 4) Multiply the unit vector by the ramp width / 2 - 5) Store the four corners of the ramp as startPoint + unit, startPoint - unit, - endPoint + unit and endPoint - unit. - 6) This gives us a surface that has endpoints which always lie flat along the ground. -*/ - - if (!(start && end && outBL && outTL && outBR && outTR)) { - return; - } - - // 1) - Vector3 longSeg; - if (start->length() > end->length()) { - longSeg.X = end->x - start->x; - longSeg.Y = end->y - start->y; - longSeg.Z = end->z - start->z; - } else { - longSeg.X = start->x - end->x; - longSeg.Y = start->y - end->y; - longSeg.Z = start->z - end->z; - } - - // 2) - Vector3 upSeg(0.0f, 0.0f, 1.0f); - Vector3 unitVec; - - Vector3::Cross_Product(longSeg, upSeg, &unitVec); - - // 3) - unitVec.Normalize(); - - // 4) - unitVec.Scale(Vector3(width, width, width)); - - Coord3D bl = { start->x + unitVec.X, start->y + unitVec.Y, start->z + unitVec.Z }; - Coord3D tl = { end->x + unitVec.X, end->y + unitVec.Y, end->z + unitVec.Z }; - Coord3D br = { start->x - unitVec.X, start->y - unitVec.Y, start->z - unitVec.Z }; - Coord3D tr = { end->x - unitVec.X, end->y - unitVec.Y, end->z - unitVec.Z }; - - - // 5) - (*outBL) = bl; - (*outTL) = tl; - (*outBR) = br; - (*outTR) = tr; - - // 6) - // all done -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditAction.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditAction.cpp deleted file mode 100644 index 53b43357247..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditAction.cpp +++ /dev/null @@ -1,455 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditAction.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "EditAction.h" -#include "EditParameter.h" -#include "GameLogic/ScriptEngine.h" - - -///////////////////////////////////////////////////////////////////////////// -// EditAction dialog - - -EditAction::EditAction(CWnd* pParent /*=nullptr*/) - : CDialog(EditAction::IDD, pParent) -{ - //{{AFX_DATA_INIT(EditAction) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void EditAction::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditAction) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditAction, CDialog) - //{{AFX_MSG_MAP(EditAction) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -static HTREEITEM findOrAdd(CTreeCtrl *tree, HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = tree->GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - tree->GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = tree->GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = tree->InsertItem(&ins); - return(child); -} - -///////////////////////////////////////////////////////////////////////////// -// EditAction message handlers - - -BOOL EditAction::OnInitDialog() -{ - CDialog::OnInitDialog(); - - -// CDC *pDc =GetDC(); - CRect rect; - - CTreeCtrl *pTree = (CTreeCtrl *)GetDlgItem(IDC_ACTION_TREE); - pTree->GetWindowRect(&rect); - - ScreenToClient(&rect); - m_actionTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP|WS_TABSTOP, rect, this, IDC_ACTION_TREE); - m_actionTreeView.ShowWindow(SW_SHOW); - pTree->DestroyWindow(); - - CWnd *pWnd = GetDlgItem(IDC_RICH_EDIT_HERE); - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_myEditCtrl.Create(WS_CHILD | WS_TABSTOP | ES_MULTILINE, rect, this, IDC_RICH_EDIT_HERE+1); - m_myEditCtrl.ShowWindow(SW_SHOW); - m_myEditCtrl.SetEventMask(m_myEditCtrl.GetEventMask() | ENM_LINK | ENM_SELCHANGE | ENM_KEYEVENTS); - - Int i; - HTREEITEM selItem = nullptr; - for (i=0; igetActionTemplate(i); - char prefix[_MAX_PATH]; - const char *name = pTemplate->getName().str(); - - Int count = 0; - HTREEITEM parent = TVI_ROOT; - do { - count = 0; - const char *nameStart = name; - while (*name && *name != '/') { - count++; - name++; - } - if (*name=='/') { - count++; - name++; - } else { - name = nameStart; - count = 0; - } - if (count>0) { - strlcpy(prefix, nameStart, count); - parent = findOrAdd(&m_actionTreeView, parent, prefix); - } - } while (count>0); - - TVINSERTSTRUCT ins; - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = i; - ins.item.pszText = (char*)name; - ins.item.cchTextMax = 0; - HTREEITEM item = m_actionTreeView.InsertItem(&ins); - if (i == m_action->getActionType()) { - selItem = item; - } - -#if RTS_ZEROHOUR - name = pTemplate->getName2().str(); - count = 0; - if (pTemplate->getName2().isEmpty()) continue; - parent = TVI_ROOT; - do { - count = 0; - const char *nameStart = name; - while (*name && *name != '/') { - count++; - name++; - } - if (*name=='/') { - count++; - name++; - } else { - name = nameStart; - count = 0; - } - if (count>0) { - strlcpy(prefix, nameStart, count); - parent = findOrAdd(&m_actionTreeView, parent, prefix); - } - } while (count>0); - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = i; - ins.item.pszText = (char*)name; - ins.item.cchTextMax = 0; - m_actionTreeView.InsertItem(&ins); -#endif - } - m_actionTreeView.Select(selItem, TVGN_FIRSTVISIBLE); - m_actionTreeView.SelectItem(selItem); - m_action->setWarnings(false); - m_myEditCtrl.SetWindowText(m_action->getUiText().str()); - m_myEditCtrl.SetSel(-1, -1); - formatScriptActionText(0); - m_actionTreeView.SetFocus(); - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -void EditAction::formatScriptActionText(Int parameterNdx) { - CHARFORMAT2 cf; - m_updating = true; - long startSel, endSel; - m_myEditCtrl.GetSel(startSel, endSel); - memset(&cf, 0, sizeof(cf)); - cf.cbSize = sizeof(cf); - cf.dwMask = CFM_FACE | CFM_SIZE |CFM_CHARSET | CFM_BOLD | CFM_LINK; - cf.bCharSet = DEFAULT_CHARSET; - cf.yHeight = 14; - cf.bPitchAndFamily = FF_DONTCARE; - strcpy(cf.szFaceName, "MS Sans Serif"); - cf.dwEffects = 0; - m_myEditCtrl.SetDefaultCharFormat(cf); - - m_myEditCtrl.SetSel(0, 1000); - m_myEditCtrl.SetSelectionCharFormat(cf); - //m_myEditCtrl.SetReadOnly(); - // Set up the links. - cf.dwMask = CFE_UNDERLINE | CFM_LINK | CFM_COLOR; - - cf.dwEffects = CFE_LINK | CFE_UNDERLINE; - cf.crTextColor = RGB(0,0,255); - m_curEditParameter = parameterNdx; - - AsciiString strings[MAX_PARMS]; - Int curChar = 0; - Int numChars = 0; - Int numStrings = m_action->getUiStrings(strings); - AsciiString warningText; - AsciiString informationText; - Int i; - for (i=0; igetNumParameters()) { - warningText.concat(EditParameter::getWarningText(m_action->getParameter(i), false)); - informationText.concat(EditParameter::getInfoText(m_action->getParameter(i))); - numChars = m_action->getParameter(i)->getUiText().getLength(); - if (curChar==0) { - curChar++; - numChars--; - } - m_myEditCtrl.SetSel(curChar, curChar+numChars); - if (i==parameterNdx) { - startSel = curChar; - endSel = curChar+numChars; - cf.crTextColor = RGB(0,0,0); //black - } else { - cf.crTextColor = RGB(0,0,255); //blue - } - m_myEditCtrl.SetSelectionCharFormat(cf); - curChar += numChars; - } - } - - CString cstr; - if (warningText.isEmpty()) { - if (informationText.isEmpty()) { - if (cstr.LoadString(IDS_SCRIPT_NOWARNINGS)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(false); - GetDlgItem(IDC_WARNINGS)->SetWindowText(""); - } else { - if (cstr.LoadString(IDS_SCRIPT_INFORMATION)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(true); - GetDlgItem(IDC_WARNINGS)->SetWindowText(informationText.str()); - } - } else { - if (cstr.LoadString(IDS_SCRIPT_WARNINGS)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(true); - GetDlgItem(IDC_WARNINGS)->SetWindowText(warningText.str()); - } - - m_modifiedTextColor = false; - m_myEditCtrl.SetSel(startSel, endSel); - m_curLinkChrg.cpMax = endSel; - m_curLinkChrg.cpMin = startSel; - m_updating = false; -} - - - -BOOL EditAction::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - - // Handle events from the tree control. - if (pHdr->hdr.idFrom == IDC_ACTION_TREE) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[_MAX_PATH]; - HTREEITEM hItem = m_actionTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_actionTreeView.GetItem(&item); - if (item.lParam >= 0) { - enum ScriptAction::ScriptActionType actionType = (enum ScriptAction::ScriptActionType)item.lParam; - if (m_action->getActionType() != actionType) { - m_action->setActionType( actionType ); - m_myEditCtrl.SetWindowText(m_action->getUiText().str()); - formatScriptActionText(0); - } - } - } else if (pHdr->hdr.code == TVN_KEYDOWN) { - NMTVKEYDOWN *pKey = (NMTVKEYDOWN*)lParam; - Int key = pKey->wVKey; - if (key==VK_SHIFT || key==VK_SPACE) { - HTREEITEM hItem = m_actionTreeView.GetSelectedItem(); - if (!m_actionTreeView.ItemHasChildren(hItem)) { - hItem = m_actionTreeView.GetParentItem(hItem); - } - m_actionTreeView.Expand(hItem, TVE_TOGGLE); - return 0; - } - return 0; - } - return TRUE; - } - - // Handle events from the rich edit control containing the action pieces. - if (LOWORD(wParam) == IDC_RICH_EDIT_HERE+1) { - NMHDR *pHdr = (NMHDR *)lParam; - if (pHdr->hwndFrom == m_myEditCtrl.m_hWnd) { - if (pHdr->code == EN_LINK) { - ENLINK *pLink = (ENLINK *)pHdr; - CHARRANGE chrg = pLink->chrg; - // Determine which parameter. - Int numChars = 0; - Int curChar = 0; - AsciiString strings[MAX_PARMS]; - Int numStrings = m_action->getUiStrings(strings); - Int i; - Bool match = false; - for (i=0; igetNumParameters()) { - numChars = m_action->getParameter(i)->getUiText().getLength(); - match = (curChar+numChars/2 > chrg.cpMin && curChar+numChars/2 < chrg.cpMax); - if (match) { - m_curEditParameter = i; - break; - } - curChar += numChars; - } - } - if (pLink->msg == WM_LBUTTONDOWN) - { - // Determine which parameter. - if (match) - { - if( m_action->getParameter( m_curEditParameter )->getParameterType() == Parameter::COMMANDBUTTON_ABILITY ) - { - EditParameter::edit(m_action->getParameter(m_curEditParameter), 0, m_action->getParameter(0)->getString() ); - } - else - { - EditParameter::edit(m_action->getParameter(m_curEditParameter), 0 ); - } - m_myEditCtrl.SetWindowText(m_action->getUiText().str()); - this->PostMessage(WM_TIMER, 0, 0); - return true; - } - } - CHARRANGE curChrg; - m_myEditCtrl.GetSel(curChrg); - if (curChrg.cpMin == chrg.cpMin && curChrg.cpMax == chrg.cpMax) { - return true; - } - if (m_modifiedTextColor) { - formatScriptActionText(m_curEditParameter); - } - m_curLinkChrg = chrg; - m_myEditCtrl.SetSel(chrg.cpMin, chrg.cpMax); - m_myEditCtrl.SetFocus(); - CHARFORMAT cf; - memset(&cf, 0, sizeof(cf)); - cf.cbSize = sizeof(cf); - cf.dwMask = CFM_COLOR; - cf.crTextColor = RGB(0,0,0); - m_myEditCtrl.SetSelectionCharFormat(cf); - m_modifiedTextColor = true; - return true; - } else if (pHdr->code == EN_SETFOCUS) { - this->PostMessage(WM_TIMER, 0, 0); - } else if (pHdr->code == EN_SELCHANGE) { - if (m_updating) { - return true; - } - CHARRANGE curChrg; - m_myEditCtrl.GetSel(curChrg); - if (curChrg.cpMin == m_curLinkChrg.cpMin && curChrg.cpMax == m_curLinkChrg.cpMax) { - return true; - } - m_myEditCtrl.SetSel(m_curLinkChrg.cpMin, m_curLinkChrg.cpMax); - if (m_modifiedTextColor) { - this->PostMessage(WM_TIMER, 0, 0); - } - } else if (pHdr->code == EN_MSGFILTER) { - MSGFILTER *pFilter = (MSGFILTER *)pHdr; - if (pFilter->msg == WM_CHAR) { - Int keyPressed = pFilter->wParam; - if (keyPressed==VK_RETURN) { - return 1; - } - if (keyPressed==VK_RETURN || keyPressed == VK_TAB) { - m_curEditParameter++; - if (m_curEditParameter >= m_action->getNumParameters()) { - m_curEditParameter = 0; - return 1; - } - this->PostMessage(WM_TIMER, 0, 0); - return 0; - } - EditParameter::edit(m_action->getParameter(m_curEditParameter), keyPressed); - m_curEditParameter++; - if (m_curEditParameter >= m_action->getNumParameters()) { - m_curEditParameter = 0; - } - this->PostMessage(WM_TIMER, 0, 0); - return 0; - } - return 1; - } - } - } - return CDialog::OnNotify(wParam, lParam, pResult); -} - -/** Not actually a timer - just used to send a delayed message to self because rich -edit control is stupid. jba. */ -void EditAction::OnTimer(UINT nIDEvent) -{ - m_myEditCtrl.SetWindowText(m_action->getUiText().str()); - formatScriptActionText(m_curEditParameter); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditCondition.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditCondition.cpp deleted file mode 100644 index c77b7253b6f..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditCondition.cpp +++ /dev/null @@ -1,477 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditCondition.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "EditCondition.h" -#include "EditParameter.h" -#include "GameLogic/ScriptEngine.h" - - -LRESULT CMyTreeCtrl::WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) -{ - if (message==WM_KEYDOWN) { - Int nVirtKey = (int) wParam; // virtual-key code - if (nVirtKey == ' ') { - return 0; - } - } - return CTreeCtrl::WindowProc(message, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////// -// EditCondition dialog - - -EditCondition::EditCondition(CWnd* pParent /*=nullptr*/) - : CDialog(EditCondition::IDD, pParent) -{ - //{{AFX_DATA_INIT(EditCondition) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void EditCondition::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditCondition) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditCondition, CDialog) - //{{AFX_MSG_MAP(EditCondition) - ON_CBN_SELCHANGE(IDC_CONDITION_TYPE, OnSelchangeConditionType) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -static HTREEITEM findOrAdd(CTreeCtrl *tree, HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = tree->GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - tree->GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = tree->GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = tree->InsertItem(&ins); - return(child); -} - -///////////////////////////////////////////////////////////////////////////// -// EditCondition message handlers - - -BOOL EditCondition::OnInitDialog() -{ - CDialog::OnInitDialog(); - - -// CDC *pDc =GetDC(); - CRect rect; - - CTreeCtrl *pTree = (CTreeCtrl *)GetDlgItem(IDC_CONDITION_TREE); - pTree->GetWindowRect(&rect); - - ScreenToClient(&rect); - m_conditionTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP|WS_TABSTOP, rect, this, IDC_CONDITION_TREE); - m_conditionTreeView.ShowWindow(SW_SHOW); - pTree->DestroyWindow(); - - CWnd *pWnd = GetDlgItem(IDC_RICH_EDIT_HERE); - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_myEditCtrl.Create(WS_CHILD | WS_TABSTOP | ES_MULTILINE, rect, this, IDC_RICH_EDIT_HERE+1); - m_myEditCtrl.ShowWindow(SW_SHOW); - m_myEditCtrl.SetEventMask(m_myEditCtrl.GetEventMask() | ENM_LINK | ENM_SELCHANGE | ENM_KEYEVENTS); - - Int i; - HTREEITEM selItem = nullptr; - for (i=0; igetConditionTemplate(i); - char prefix[_MAX_PATH]; - const char *name = pTemplate->getName().str(); - - Int count = 0; - HTREEITEM parent = TVI_ROOT; - do { - count = 0; - const char *nameStart = name; - while (*name && *name != '/') { - count++; - name++; - } - if (*name=='/') { - count++; - name++; - } else { - name = nameStart; - count = 0; - } - if (count>0) { - strlcpy(prefix, nameStart, count); - parent = findOrAdd(&m_conditionTreeView, parent, prefix); - } - } while (count>0); - - TVINSERTSTRUCT ins; - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = i; - ins.item.pszText = (char*)name; - ins.item.cchTextMax = 0; - HTREEITEM item = m_conditionTreeView.InsertItem(&ins); - if (i == m_condition->getConditionType()) { - selItem = item; - } - -#if RTS_ZEROHOUR - name = pTemplate->getName2().str(); - count = 0; - if (pTemplate->getName2().isEmpty()) continue; - parent = TVI_ROOT; - do { - count = 0; - const char *nameStart = name; - while (*name && *name != '/') { - count++; - name++; - } - if (*name=='/') { - count++; - name++; - } else { - name = nameStart; - count = 0; - } - if (count>0) { - strlcpy(prefix, nameStart, count); - parent = findOrAdd(&m_conditionTreeView, parent, prefix); - } - } while (count>0); - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = i; - ins.item.pszText = (char*)name; - ins.item.cchTextMax = 0; - m_conditionTreeView.InsertItem(&ins); -#endif - } - m_conditionTreeView.Select(selItem, TVGN_FIRSTVISIBLE); - m_conditionTreeView.SelectItem(selItem); - m_condition->setWarnings(false); - m_myEditCtrl.SetWindowText(m_condition->getUiText().str()); - m_myEditCtrl.SetSel(-1, -1); - formatConditionText(0); - m_conditionTreeView.SetFocus(); - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -void EditCondition::formatConditionText(Int parameterNdx) { - CHARFORMAT2 cf; - m_updating = true; - long startSel, endSel; - m_myEditCtrl.GetSel(startSel, endSel); - memset(&cf, 0, sizeof(cf)); - cf.cbSize = sizeof(cf); - cf.dwMask = CFM_FACE | CFM_SIZE |CFM_CHARSET | CFM_BOLD | CFM_LINK; - cf.bCharSet = DEFAULT_CHARSET; - cf.yHeight = 14; - cf.bPitchAndFamily = FF_DONTCARE; - strcpy(cf.szFaceName, "MS Sans Serif"); - cf.dwEffects = 0; - m_myEditCtrl.SetDefaultCharFormat(cf); - - m_myEditCtrl.SetSel(0, 1000); - m_myEditCtrl.SetSelectionCharFormat(cf); - //m_myEditCtrl.SetReadOnly(); - // Set up the links. - cf.dwMask = CFE_UNDERLINE | CFM_LINK | CFM_COLOR; - - cf.dwEffects = CFE_LINK | CFE_UNDERLINE; - cf.crTextColor = RGB(0,0,255); - m_curEditParameter = parameterNdx; - - AsciiString strings[MAX_PARMS]; - Int curChar = 0; - Int numChars = 0; - Int numStrings = m_condition->getUiStrings(strings); - AsciiString warningText; - AsciiString informationText; - Int i; - for (i=0; igetNumParameters()) { - warningText.concat(EditParameter::getWarningText(m_condition->getParameter(i), false)); - informationText.concat(EditParameter::getInfoText(m_condition->getParameter(i))); - numChars = m_condition->getParameter(i)->getUiText().getLength(); - if (curChar==0) { - curChar++; - numChars--; - } - m_myEditCtrl.SetSel(curChar, curChar+numChars); - if (i==parameterNdx) { - startSel = curChar; - endSel = curChar+numChars; - cf.crTextColor = RGB(0,0,0); //black - } else { - cf.crTextColor = RGB(0,0,255); //blue - } - m_myEditCtrl.SetSelectionCharFormat(cf); - curChar += numChars; - } - } - - CString cstr; - if (warningText.isEmpty()) { - if (informationText.isEmpty()) { - if (cstr.LoadString(IDS_SCRIPT_NOWARNINGS)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(false); - GetDlgItem(IDC_WARNINGS)->SetWindowText(""); - } else { - if (cstr.LoadString(IDS_SCRIPT_INFORMATION)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(true); - GetDlgItem(IDC_WARNINGS)->SetWindowText(informationText.str()); - } - } else { - if (cstr.LoadString(IDS_SCRIPT_WARNINGS)) { - GetDlgItem(IDC_WARNINGS_CAPTION)->SetWindowText(cstr); - } - GetDlgItem(IDC_WARNINGS_CAPTION)->EnableWindow(true); - GetDlgItem(IDC_WARNINGS)->SetWindowText(warningText.str()); - } - - m_modifiedTextColor = false; - m_myEditCtrl.SetSel(startSel, endSel); - m_curLinkChrg.cpMax = endSel; - m_curLinkChrg.cpMin = startSel; - m_updating = false; -} - - - -BOOL EditCondition::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - - // Handle events from the tree control. - if (pHdr->hdr.idFrom == IDC_CONDITION_TREE) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[_MAX_PATH]; - HTREEITEM hItem = m_conditionTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_conditionTreeView.GetItem(&item); - if (item.lParam >= 0) { - enum Condition::ConditionType conditionType = (enum Condition::ConditionType)item.lParam; - if (m_condition->getConditionType() != conditionType) { - m_condition->setConditionType( conditionType ); - m_myEditCtrl.SetWindowText(m_condition->getUiText().str()); - formatConditionText(0); - } - } - } else if (pHdr->hdr.code == TVN_KEYDOWN) { - NMTVKEYDOWN *pKey = (NMTVKEYDOWN*)lParam; - Int key = pKey->wVKey; - if (key==VK_SHIFT || key==VK_SPACE) { - HTREEITEM hItem = m_conditionTreeView.GetSelectedItem(); - if (!m_conditionTreeView.ItemHasChildren(hItem)) { - hItem = m_conditionTreeView.GetParentItem(hItem); - } - m_conditionTreeView.Expand(hItem, TVE_TOGGLE); - return 0; - } - return 0; - } - return TRUE; - } - - // Handle events from the rich edit control containing the condition pieces. - if (LOWORD(wParam) == IDC_RICH_EDIT_HERE+1) { - NMHDR *pHdr = (NMHDR *)lParam; - if (pHdr->hwndFrom == m_myEditCtrl.m_hWnd) { - if (pHdr->code == EN_LINK) { - ENLINK *pLink = (ENLINK *)pHdr; - CHARRANGE chrg = pLink->chrg; - // Determine which parameter. - Int numChars = 0; - Int curChar = 0; - AsciiString strings[MAX_PARMS]; - Int numStrings = m_condition->getUiStrings(strings); - Int i; - Bool match = false; - for (i=0; igetNumParameters()) { - numChars = m_condition->getParameter(i)->getUiText().getLength(); - match = (curChar+numChars/2 > chrg.cpMin && curChar+numChars/2 < chrg.cpMax); - if (match) { - m_curEditParameter = i; - break; - } - curChar += numChars; - } - } - if (pLink->msg == WM_LBUTTONDOWN) { - // Determine which parameter. - if (match) { - EditParameter::edit(m_condition->getParameter(m_curEditParameter), 0); - m_myEditCtrl.SetWindowText(m_condition->getUiText().str()); - this->PostMessage(WM_TIMER, 0, 0); - return true; - } - } - CHARRANGE curChrg; - m_myEditCtrl.GetSel(curChrg); - if (curChrg.cpMin == chrg.cpMin && curChrg.cpMax == chrg.cpMax) { - return true; - } - if (m_modifiedTextColor) { - formatConditionText(m_curEditParameter); - } - m_curLinkChrg = chrg; - m_myEditCtrl.SetSel(chrg.cpMin, chrg.cpMax); - m_myEditCtrl.SetFocus(); - CHARFORMAT cf; - memset(&cf, 0, sizeof(cf)); - cf.cbSize = sizeof(cf); - cf.dwMask = CFM_COLOR; - cf.crTextColor = RGB(0,0,0); - m_myEditCtrl.SetSelectionCharFormat(cf); - m_modifiedTextColor = true; - return true; - } else if (pHdr->code == EN_SETFOCUS) { - this->PostMessage(WM_TIMER, 0, 0); - } else if (pHdr->code == EN_SELCHANGE) { - if (m_updating) { - return true; - } - CHARRANGE curChrg; - m_myEditCtrl.GetSel(curChrg); - if (curChrg.cpMin == m_curLinkChrg.cpMin && curChrg.cpMax == m_curLinkChrg.cpMax) { - return true; - } - m_myEditCtrl.SetSel(m_curLinkChrg.cpMin, m_curLinkChrg.cpMax); - if (m_modifiedTextColor) { - this->PostMessage(WM_TIMER, 0, 0); - } - } else if (pHdr->code == EN_MSGFILTER) { - MSGFILTER *pFilter = (MSGFILTER *)pHdr; - if (pFilter->msg == WM_CHAR) { - Int keyPressed = pFilter->wParam; - if (keyPressed==VK_RETURN) { - return 1; - } - if (keyPressed==VK_RETURN || keyPressed == VK_TAB) { - m_curEditParameter++; - if (m_curEditParameter >= m_condition->getNumParameters()) { - m_curEditParameter = 0; - return 1; - } - this->PostMessage(WM_TIMER, 0, 0); - return 0; - } - EditParameter::edit(m_condition->getParameter(m_curEditParameter), keyPressed); - m_curEditParameter++; - if (m_curEditParameter >= m_condition->getNumParameters()) { - m_curEditParameter = 0; - } - this->PostMessage(WM_TIMER, 0, 0); - return 0; - } - return 1; - } - } - } - return CDialog::OnNotify(wParam, lParam, pResult); -} - -void EditCondition::OnSelchangeConditionType() -{ - CComboBox *pCmbo = (CComboBox *)GetDlgItem(IDC_CONDITION_TYPE); - Int index = 0; - CString str; - pCmbo->GetWindowText(str); - Int i; - for (i=0; igetConditionTemplate(i); - if (str == pTemplate->getName().str()) { - index = i; - break; - } - } - m_condition->setConditionType((enum Condition::ConditionType)index); - m_myEditCtrl.SetWindowText(m_condition->getUiText().str()); - formatConditionText(m_curEditParameter); -} - -/** Not actually a timer - just used to send a delayed message to self because rich -edit control is stupid. jba. */ -void EditCondition::OnTimer(UINT nIDEvent) -{ - m_myEditCtrl.SetWindowText(m_condition->getUiText().str()); - formatConditionText(m_curEditParameter); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp deleted file mode 100644 index 67bdbd48039..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditCoordParameter.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditCoordParameter.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "EditCoordParameter.h" -#include "GameLogic/Scripts.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/PolygonTrigger.h" - -///////////////////////////////////////////////////////////////////////////// -// EditCoordParameter dialog - - -EditCoordParameter::EditCoordParameter(CWnd* pParent /*=nullptr*/) - : CDialog(EditCoordParameter::IDD, pParent) -{ - //{{AFX_DATA_INIT(EditCoordParameter) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void EditCoordParameter::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditCoordParameter) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditCoordParameter, CDialog) - //{{AFX_MSG_MAP(EditCoordParameter) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EditCoordParameter message handlers - -BOOL EditCoordParameter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CEdit *pEditX = (CEdit *)GetDlgItem(IDC_EDIT_X); - CEdit *pEditY = (CEdit *)GetDlgItem(IDC_EDIT_Y); - CEdit *pEditZ = (CEdit *)GetDlgItem(IDC_EDIT_Z); - - m_parameter->getCoord3D(&m_coord); - CString string; - string.Format("%.2f", m_coord.x); - pEditX->SetWindowText(string); - string.Format("%.2f", m_coord.y); - pEditY->SetWindowText(string); - string.Format("%.2f", m_coord.z); - pEditZ->SetWindowText(string); - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void EditCoordParameter::OnOK() -{ - CEdit *pEditX = (CEdit *)GetDlgItem(IDC_EDIT_X); - CEdit *pEditY = (CEdit *)GetDlgItem(IDC_EDIT_Y); - CEdit *pEditZ = (CEdit *)GetDlgItem(IDC_EDIT_Z); - CString txt; - - pEditX->GetWindowText(txt); - Real theReal; - if (1==sscanf(txt, "%f", &theReal)) { - m_coord.x = theReal; - } else { - pEditX->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - pEditY->GetWindowText(txt); - if (1==sscanf(txt, "%f", &theReal)) { - m_coord.y = theReal; - } else { - pEditX->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - pEditZ->GetWindowText(txt); - if (1==sscanf(txt, "%f", &theReal)) { - m_coord.z = theReal; - } else { - pEditX->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - m_parameter->friend_setCoord3D(&m_coord); - CDialog::OnOK(); -} - -void EditCoordParameter::OnCancel() -{ - - CDialog::OnCancel(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditGroup.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditGroup.cpp deleted file mode 100644 index eb422984a62..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditGroup.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditGroup.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "EditGroup.h" -#include "GameLogic/Scripts.h" - -///////////////////////////////////////////////////////////////////////////// -// EditGroup dialog - - -EditGroup::EditGroup(ScriptGroup *pGroup, CWnd* pParent /*=nullptr*/) - : CDialog(EditGroup::IDD, pParent), - m_scriptGroup(pGroup) -{ - //{{AFX_DATA_INIT(EditGroup) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void EditGroup::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditGroup) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditGroup, CDialog) - //{{AFX_MSG_MAP(EditGroup) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EditGroup message handlers - -void EditGroup::OnOK() -{ - CString name; - GetDlgItem(IDC_GROUP_NAME)->GetWindowText(name); - m_scriptGroup->setName(AsciiString(name)); - CButton *pButton = (CButton*)GetDlgItem(IDC_GROUP_ACTIVE); - m_scriptGroup->setActive(pButton->GetCheck()==1); - pButton = (CButton*)GetDlgItem(IDC_GROUP_SUBROUTINE); - m_scriptGroup->setSubroutine(pButton->GetCheck()==1); - CDialog::OnOK(); -} - -BOOL EditGroup::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CButton *pButton = (CButton*)GetDlgItem(IDC_GROUP_ACTIVE); - pButton->SetCheck(m_scriptGroup->isActive()?1:0); - pButton = (CButton*)GetDlgItem(IDC_GROUP_SUBROUTINE); - pButton->SetCheck(m_scriptGroup->isSubroutine()?1:0); - - CEdit *pEdit = (CEdit*)GetDlgItem(IDC_GROUP_NAME); - pEdit->SetWindowText(m_scriptGroup->getName().str()); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp deleted file mode 100644 index 4d319482548..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditObjectParameter.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditObjectParameter.cpp : implementation file -// - -#define DEFINE_EDITOR_SORTING_NAMES - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "EditObjectParameter.h" -#include "EditParameter.h" - - -#include "GameLogic/Scripts.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/PolygonTrigger.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" - -///////////////////////////////////////////////////////////////////////////// -// EditObjectParameter dialog - - -EditObjectParameter::EditObjectParameter(CWnd* pParent /*=nullptr*/) - : CDialog(EditObjectParameter::IDD, pParent) -{ - //{{AFX_DATA_INIT(EditObjectParameter) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void EditObjectParameter::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditObjectParameter) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditObjectParameter, CDialog) - //{{AFX_MSG_MAP(EditObjectParameter) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EditObjectParameter message handlers - -BOOL EditObjectParameter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - - CWnd *pWnd = GetDlgItem(IDC_OBJECT_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_objectTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_objectTreeView.ShowWindow(SW_SHOW); - - // add entries from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - addObject(tTemplate); - - } - - - addObjectLists(); - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} -//------------------------------------------------------------------------------------------------- -/** Add the object hierarchy paths to the tree view. */ -//------------------------------------------------------------------------------------------------- -void EditObjectParameter::addObject( const ThingTemplate *thingTemplate ) -{ - HTREEITEM parent = TVI_ROOT; - const char *leafName; - // - // if we have an thing template in mapObject, we've read it from the new INI database, - // we will sort those items into the tree based on properties of the template that - // make it easier for us to browse when building levels - // - // Feel free to reorganize how this tree is constructed from the template - // data at will, whatever makes it easier for design - // - if( thingTemplate ) - { - - // first check for test sorted objects - if( thingTemplate->getEditorSorting() == ES_TEST ) - parent = findOrAdd( parent, "TEST" ); - - // first sort by Side, either create or find the tree item with matching side name - AsciiString side = thingTemplate->getDefaultOwningSide(); - DEBUG_ASSERTCRASH(!side.isEmpty(), ("null default side in template") ); - parent = findOrAdd( parent, side.str()); - - // next tier uses the editor sorting that design can specify in the INI - EditorSortingType i = ES_FIRST; - for( ; - i < ES_NUM_SORTING_TYPES; - i = (EditorSortingType)(i + 1) ) - { - - if( thingTemplate->getEditorSorting() == i ) - { - - parent = findOrAdd( parent, EditorSortingNames[ i ] ); - break; // exit for - - } - - } - - if( i == ES_NUM_SORTING_TYPES ) - parent = findOrAdd( parent, "UNSORTED" ); - - // the leaf name is the name of the template - leafName = thingTemplate->getName().str(); - - } - - // add to the tree view - if( leafName ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = 0; - ins.item.pszText = (char*)leafName; - ins.item.cchTextMax = strlen(leafName)+2; - m_objectTreeView.InsertItem(&ins); - - } - -} - -/** - -*/ -void EditObjectParameter::addObjectLists( ) -{ - HTREEITEM parent = TVI_ROOT; - const char *leafName; - - parent = findOrAdd(parent, "Object Lists"); - - std::vector strings; - EditParameter::loadObjectTypeList(nullptr, &strings); - - Int numItems = strings.size(); - - for (Int i = 0; i < numItems; ++i) { - // add to the tree view - - leafName = strings[i].str(); - - if( leafName ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = 0; - ins.item.pszText = (char*)leafName; - ins.item.cchTextMax = strlen(leafName)+2; - m_objectTreeView.InsertItem(&ins); - } - } -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM EditObjectParameter::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = m_objectTreeView.InsertItem(&ins); - return(child); -} - -BOOL EditObjectParameter::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - - // Handle events from the tree control. - if (pHdr->hdr.idFrom == IDC_TERRAIN_TREEVIEW) { - if (pHdr->hdr.code == TVN_KEYDOWN) { - NMTVKEYDOWN *pKey = (NMTVKEYDOWN*)lParam; - Int key = pKey->wVKey; - if (key==VK_SHIFT || key==VK_SPACE) { - HTREEITEM hItem = m_objectTreeView.GetSelectedItem(); - if (!m_objectTreeView.ItemHasChildren(hItem)) { - hItem = m_objectTreeView.GetParentItem(hItem); - } - m_objectTreeView.Expand(hItem, TVE_TOGGLE); - return 0; - } - return 0; - } - } - return CDialog::OnNotify(wParam, lParam, pResult); -} - -void EditObjectParameter::OnOK() -{ - char buffer[_MAX_PATH]; - HTREEITEM hItem = m_objectTreeView.GetSelectedItem(); - if (!hItem) { - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - AsciiString objName = buffer; - // We used to try to find the TT here, but now we don't because we - // use object lists as well. - m_parameter->friend_setString(objName); - CDialog::OnOK(); -} - -void EditObjectParameter::OnCancel() -{ - - CDialog::OnCancel(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EditParameter.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EditParameter.cpp deleted file mode 100644 index 9366cdc45ee..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EditParameter.cpp +++ /dev/null @@ -1,2402 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EditParameter.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "WorldBuilder.h" - -// This is used to allow sounds to be played via PlaySound -#include - -#define DEFINE_BUILDABLE_STATUS_NAMES -#define DEFINE_OBJECT_STATUS_NAMES -#define DEFINE_SCIENCE_AVAILABILITY_NAMES - -#include "EditParameter.h" -#include "EditCoordParameter.h" -#include "EditObjectParameter.h" - - -#include "Common/AudioEventInfo.h" -#include "Common/BorderColors.h" -#include "Common/file.h" -#include "Common/FileSystem.h" -#include "Common/GameAudio.h" -#include "Common/Player.h" -#include "Common/PlayerTemplate.h" -#include "Common/Radar.h" -#include "Common/SpecialPower.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/Upgrade.h" -#include "Common/WellKnownKeys.h" - -#include "GameClient/ControlBar.h" -#include "GameClient/GameText.h" -#include "GameClient/VideoPlayer.h" -#include "GameClient/Anim2D.h" -#include "GameClient/ShellHooks.h" - -#include "GameLogic/AI.h" -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/Scripts.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/ScriptEngine.h" - -#include "W3DDevice/GameClient/W3DGameFont.h" -#include "W3DDevice/GameClient/HeightMap.h" - - -// TYPE DEFINES /////////////////////////////////////////////////////////////////////////////////// -#define WORLDBUILDER_FONT_FILENAME "GUIEFont.txt" - -///////////////////////////////////////////////////////////////////////////// -// EditParameter dialog - -AsciiString EditParameter::m_selectedLocalizedString = AsciiString::TheEmptyString; -AsciiString EditParameter::m_unitName = AsciiString::TheEmptyString; - -EditParameter::EditParameter(CWnd* pParent /*=nullptr*/) - : CDialog(EditParameter::IDD, pParent), - m_int(0), - m_real(0) -{ - //{{AFX_DATA_INIT(EditParameter) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void EditParameter::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditParameter) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(EditParameter, CDialog) - //{{AFX_MSG_MAP(EditParameter) - ON_EN_CHANGE(IDC_EDIT, OnChangeEdit) - ON_CBN_EDITCHANGE(IDC_COMBO, OnEditchangeCombo) - ON_BN_CLICKED(IDC_PREVIEWSOUND, OnPreviewSound) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EditParameter message handlers -SidesList *EditParameter::m_sidesListP = nullptr; - -Int EditParameter::edit( Parameter *pParm, Int keyPressed, AsciiString unitName ) -{ - if (pParm->getParameterType() == Parameter::COORD3D) - { - EditCoordParameter editCoordDlg; - editCoordDlg.m_parameter = pParm; - Int ret = editCoordDlg.DoModal(); - return ret; - } - else if (pParm->getParameterType() == Parameter::OBJECT_TYPE) - { - EditObjectParameter editObjDlg; - editObjDlg.m_parameter = pParm; - Int ret = editObjDlg.DoModal(); - return ret; - } - else if (pParm->getParameterType() == Parameter::COLOR) - { - // convert from aarrggbb to 00bbggrr, with 0% alpha - UnsignedInt b = (pParm->getInt() & 0x000000ff); - UnsignedInt g = (pParm->getInt() & 0x0000ff00)>>8; - UnsignedInt r = (pParm->getInt() & 0x00ff0000)>>16; - UnsignedInt a = 0x00; - UnsignedInt colorref = (a<<24)|(b<<16)|(g<<8)|(r); - - CColorDialog editColorDlg(colorref, CC_ANYCOLOR|CC_FULLOPEN|CC_RGBINIT|CC_SOLIDCOLOR); - Int ret = editColorDlg.DoModal(); - if (ret == IDOK) - { - colorref = editColorDlg.GetColor(); - // convert from 00bbggrr to aarrggbb, with 100% alpha - r = (colorref & 0x000000ff); - g = (colorref & 0x0000ff00)>>8; - b = (colorref & 0x00ff0000)>>16; - a = 0xff; - pParm->friend_setInt((a<<24)|(r<<16)|(g<<8)|(b)); - } - return ret; - } - else - { - EditParameter editDlg; - editDlg.m_key = keyPressed; - editDlg.m_parameter = pParm; - //Set the name of the unit, because some parameters build information from the unit itself. - editDlg.m_unitName = unitName; - Int ret = editDlg.DoModal(); - return ret; - } -} - -AsciiString EditParameter::getWarningText(Parameter *pParm, Bool isAction) -{ - AsciiString warningText; - AsciiString uiString = pParm->getString(); - if (uiString.isEmpty()) - uiString = "???"; - switch (pParm->getParameterType()) { - default: - DEBUG_CRASH(("Unknown parameter type.")); - break; - case Parameter::SCRIPT: - if (!loadScripts(nullptr, false, uiString)) { - warningText.format("Script '%s' does not exist.", uiString.str()); - } - break; - case Parameter::SCRIPT_SUBROUTINE: - if (!loadScripts(nullptr, true, uiString)) { - if (!loadScripts(nullptr, false, uiString)) { - warningText.format("Script '%s' does not exist.", uiString.str()); - } else { - warningText.format("Script '%s' is not a subroutine.", uiString.str()); - } - } - break; - case Parameter::ATTACK_PRIORITY_SET: - if (!loadAttackPrioritySets(nullptr, uiString)) { - warningText.format("Attack priority set '%s' does not exist.", uiString.str()); - } - break; - case Parameter::WAYPOINT: - if (!loadWaypoints(nullptr, uiString)) { - warningText.format("Waypoint '%s' does not exist.", uiString.str()); - } - break; - case Parameter::WAYPOINT_PATH: - if (!loadWaypointPaths(nullptr, uiString)) { - warningText.format("Waypoint '%s' does not exist.", uiString.str()); - } - break; - case Parameter::TRIGGER_AREA: - if (!loadTriggerAreas(nullptr, uiString)) { - warningText.format("Waypoint '%s' does not exist.", uiString.str()); - } - break; - case Parameter::COMMAND_BUTTON: - if (!loadCommandButtons(nullptr, uiString)) { - warningText.format("Command button '%s' does not exist.", uiString.str()); - } - break; - case Parameter::FONT_NAME: - if(!loadFontNames(nullptr, uiString)) { - warningText.format("Font '%s' does not exist.", uiString.str()); - } - break; - case Parameter::TEAM_STATE: - break; - case Parameter::TEXT_STRING: - break; - case Parameter::LOCALIZED_TEXT: - if (loadLocalizedText(nullptr, uiString) == AsciiString::TheEmptyString) { - warningText.format("Localized string '%s' does not exist.", uiString.str()); - } - break; - case Parameter::SOUND: - if (!loadAudioType(Parameter::SOUND, nullptr, uiString)) { - warningText.format("Sound '%s' does not exist.", uiString.str()); - } - break; - case Parameter::TEAM: - if (!loadTeams(nullptr, uiString)) { - warningText.format("Team '%s' does not exist.", uiString.str()); - } - break; - case Parameter::BRIDGE: - if (!loadBridges(nullptr, uiString)) { - warningText.format("Bridge '%s' does not exist.", uiString.str()); - } - break; - case Parameter::UNIT: - if (!loadUnits(nullptr, uiString)) { - warningText.format("Unit '%s' does not exist.", uiString.str()); - } - break; - case Parameter::OBJECT_TYPE: - if (!loadObjectType(nullptr, uiString)) { - warningText.format("Object type '%s' does not exist.", uiString.str()); - } - break; - case Parameter::SIDE: - if (!loadSides(nullptr, uiString)) { - warningText.format("Player '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::OBJECT_PANEL_FLAG: - if (!loadObjectFlags(nullptr, uiString)) { - warningText.format("Object flag '%s' is unrecognized.", uiString.str()); - } - break; - - case Parameter::OBJECT_TYPE_LIST: - // No warning is possible. - break; - case Parameter::COUNTER: - if (!isAction && !loadCounters(nullptr, uiString)) { - warningText.format("Counter/Timer '%s' does not exist.", uiString.str()); - } - break; - case Parameter::INT: - break; - case Parameter::COLOR: - break; - case Parameter::KIND_OF_PARAM: - break; - case Parameter::COORD3D: - break; - case Parameter::ANGLE: - break; -#if RTS_ZEROHOUR - case Parameter::PERCENT: - break; -#endif - case Parameter::BOOLEAN: - break; - - case Parameter::REAL: - break; - - case Parameter::FLAG: - if (!isAction && !loadFlags(nullptr, uiString)) { - warningText.format("Flag '%s' is never initialized.", uiString.str()); - } - break; - case Parameter::COMPARISON: - break; - - case Parameter::AI_MOOD: - break; - - case Parameter::SKIRMISH_WAYPOINT_PATH: - break; - - case Parameter::RADAR_EVENT_TYPE: - break; - -#if RTS_ZEROHOUR - case Parameter::LEFT_OR_RIGHT: - break; -#endif - - case Parameter::RELATION: - break; - - case Parameter::DIALOG: - if (!loadAudioType(Parameter::DIALOG, nullptr, uiString)) { - warningText.format("Dialog '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::MUSIC: - if (!loadAudioType(Parameter::MUSIC, nullptr, uiString)) { - warningText.format("Track '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::MOVIE: - if (!loadMovies(nullptr, uiString)) { - AsciiString commentFromINI; - if (!getMovieComment(uiString, commentFromINI)) { - warningText.format("Movie '%s' does not exit.", uiString.str()); - } else { - warningText.format("'%s': %s", uiString.str(), commentFromINI.str()); - } - } - break; - - case Parameter::SPECIAL_POWER: - if (!loadSpecialPowers(nullptr, uiString)) { - warningText.format("Special Power '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::SCIENCE: - if (!loadSciences(nullptr, uiString)) { - warningText.format("Science '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::SCIENCE_AVAILABILITY: - if( !loadScienceAvailabilities( nullptr, uiString ) ) - { - warningText.format( "Science availability '%s' does not exist.", uiString.str() ); - } - break; - - case Parameter::UPGRADE: - if (!loadUpgrades(nullptr, uiString)) { - warningText.format("Upgrade '%s' does not exist.", uiString.str()); - } - break; - - case Parameter::COMMANDBUTTON_ABILITY: - case Parameter::COMMANDBUTTON_ALL_ABILITIES: - //Not sure if I need to do anything here. - break; - - - case Parameter::BOUNDARY: - if (TheTerrainRenderObject->getMap()->getAllBoundaries().size() <= pParm->getInt()) { - warningText.format("Border %s does not exist.", BORDER_COLORS[pParm->getInt() % BORDER_COLORS_SIZE]); - } - break; - - case Parameter::BUILDABLE: - break; - - case Parameter::SURFACES_ALLOWED: - break; - - case Parameter::SHAKE_INTENSITY: - break; - - case Parameter::OBJECT_STATUS: - break; - - case Parameter::FACTION_NAME: - break; - - case Parameter::EMOTICON: - break; - - case Parameter::REVEALNAME: - break; - - - } - if (warningText.isNotEmpty()) { - warningText.concat(" "); - } - return warningText; -} - - -AsciiString EditParameter::getInfoText(Parameter *pParm) -{ - AsciiString infoText; - AsciiString uiString = pParm->getString(); - if (uiString.isEmpty()) - uiString = "???"; - switch (pParm->getParameterType()) - { - default: - DEBUG_CRASH(("Unknown parameter type.")); - break; - case Parameter::SCRIPT: - case Parameter::SCRIPT_SUBROUTINE: - case Parameter::ATTACK_PRIORITY_SET: - case Parameter::WAYPOINT: - case Parameter::WAYPOINT_PATH: - case Parameter::TRIGGER_AREA: - case Parameter::COMMAND_BUTTON: - case Parameter::FONT_NAME: - case Parameter::TEAM_STATE: - case Parameter::TEXT_STRING: - case Parameter::SOUND: - case Parameter::TEAM: - case Parameter::BRIDGE: - case Parameter::UNIT: - case Parameter::OBJECT_TYPE: - case Parameter::KIND_OF_PARAM: - case Parameter::SIDE: - case Parameter::COUNTER: - case Parameter::INT: - case Parameter::COLOR: - case Parameter::COORD3D: - case Parameter::ANGLE: -#if RTS_ZEROHOUR - case Parameter::PERCENT: -#endif - case Parameter::BOOLEAN: - case Parameter::REAL: - case Parameter::FLAG: - case Parameter::COMPARISON: - case Parameter::AI_MOOD: - case Parameter::SKIRMISH_WAYPOINT_PATH: - case Parameter::RADAR_EVENT_TYPE: - case Parameter::RELATION: - case Parameter::DIALOG: - case Parameter::MUSIC: - case Parameter::SPECIAL_POWER: - case Parameter::SCIENCE: - case Parameter::SCIENCE_AVAILABILITY: - case Parameter::UPGRADE: - case Parameter::COMMANDBUTTON_ABILITY: - case Parameter::COMMANDBUTTON_ALL_ABILITIES: - case Parameter::BOUNDARY: - case Parameter::BUILDABLE: - case Parameter::SURFACES_ALLOWED: - case Parameter::SHAKE_INTENSITY: - case Parameter::OBJECT_STATUS: - case Parameter::FACTION_NAME: - case Parameter::EMOTICON: - case Parameter::OBJECT_TYPE_LIST: - case Parameter::REVEALNAME: - case Parameter::OBJECT_PANEL_FLAG: -#if RTS_ZEROHOUR - case Parameter::LEFT_OR_RIGHT: -#endif - - break; - - case Parameter::LOCALIZED_TEXT: - { - AsciiString localizedString; - localizedString.translate(TheGameText->fetch(uiString.str())); - infoText.format("'%s': %s", uiString.str(), localizedString.str()); - break; - } - case Parameter::MOVIE: - { - AsciiString commentFromINI; - if (getMovieComment(uiString, commentFromINI)) { - infoText.format("'%s': %s", uiString.str(), commentFromINI.str()); - } - break; - } - } - return infoText; -} - - - -void EditParameter::OnChangeEdit() -{ - -} - -void EditParameter::OnEditchangeCombo() -{ - -} - - -void EditParameter::loadConditionParameter(Script *pScr, Parameter::ParameterType type, CComboBox *pCombo) -{ - OrCondition *pOr; - if (pCombo==nullptr) return; // null pcombo is used in syntaxing commands. jba. - for (pOr= pScr->getOrCondition(); pOr; pOr = pOr->getNextOrCondition()) { - Condition *pCondition; - for (pCondition = pOr->getFirstAndCondition(); pCondition; pCondition = pCondition->getNext()) { - Int i; - for (i=0; igetNumParameters(); i++) { - if (type == pCondition->getParameter(i)->getParameterType()) { - if (CB_ERR == pCombo->FindStringExact(-1, pCondition->getParameter(i)->getString().str())) { - pCombo->AddString(pCondition->getParameter(i)->getString().str()); - } - } - } - } - } - if(type == Parameter::FLAG) - { - for(int i = 0; i < SHELL_SCRIPT_HOOK_TOTAL; i++) - { - if(pCombo->FindStringExact(-1,TheShellHookNames[i]) < 0) - pCombo->AddString(TheShellHookNames[i]); - } - } -} - -Bool EditParameter::loadActionParameter(Script *pScr, Parameter::ParameterType type, CComboBox *pCombo, AsciiString match) -{ - ScriptAction *pAction; - Bool found = false; - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - Int i; - for (i=0; igetNumParameters(); i++) { - if (type == pAction->getParameter(i)->getParameterType()) { - if (pCombo) { - if (CB_ERR == pCombo->FindStringExact(-1, pAction->getParameter(i)->getString().str())) { - pCombo->AddString(pAction->getParameter(i)->getString().str()); - } - } - if (match == pAction->getParameter(i)->getString()) { - found = true; - } - } - } - } - return found; -} - -Bool EditParameter::loadAttackSetParameter(Script *pScr, CComboBox *pCombo, AsciiString match) -{ - ScriptAction *pAction; - Bool found = false; - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - // Attack priorities are created by SET_ATTACK_PRIORITY_* actions, but - // referenced by *_APPLY_PRIORITY actions. So just load from the SET_... ones. - if (pAction->getActionType() != ScriptAction::SET_ATTACK_PRIORITY_KIND_OF && - pAction->getActionType() != ScriptAction::SET_DEFAULT_ATTACK_PRIORITY && - pAction->getActionType() != ScriptAction::SET_ATTACK_PRIORITY_THING) { - continue; - } - Int i; - for (i=0; igetNumParameters(); i++) { - if (Parameter::ATTACK_PRIORITY_SET == pAction->getParameter(i)->getParameterType()) { - if (match==pAction->getParameter(i)->getString()) { - found = true; - } - if (pCombo && CB_ERR == pCombo->FindStringExact(-1, pAction->getParameter(i)->getString().str())) { - pCombo->AddString(pAction->getParameter(i)->getString().str()); - } - } - } - } - return found; -} - -Bool EditParameter::loadCreateUnitParameter(Script *pScr, CComboBox *pCombo, AsciiString match) -{ - ScriptAction *pAction; - Bool found = false; - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - if (pAction->getActionType() != ScriptAction::CREATE_NAMED_ON_TEAM_AT_WAYPOINT - && pAction->getActionType() != ScriptAction::UNIT_SPAWN_NAMED_LOCATION_ORIENTATION) { - continue; - } - Int i; - for (i=0; igetNumParameters(); i++) { - if (Parameter::UNIT == pAction->getParameter(i)->getParameterType()) { - if (match==pAction->getParameter(i)->getString()) { - found = true; - } - if (pCombo && CB_ERR == pCombo->FindStringExact(-1, pAction->getParameter(i)->getString().str())) { - pCombo->AddString(pAction->getParameter(i)->getString().str()); - } - } - } - } - return found; -} - -Bool EditParameter::loadCreateObjectListsParameter(Script *pScr, CComboBox *pCombo, std::vector *strings, AsciiString match) -{ - ScriptAction *pAction; - Bool found = false; - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - if (pAction->getActionType() != ScriptAction::OBJECTLIST_ADDOBJECTTYPE) { - continue; - } - - if (Parameter::OBJECT_TYPE_LIST == pAction->getParameter(0)->getParameterType()) { - if (match == pAction->getParameter(0)->getString()) { - found = true; - } - if (pCombo && CB_ERR == pCombo->FindStringExact(-1, pAction->getParameter(0)->getString().str())) { - pCombo->AddString(pAction->getParameter(0)->getString().str()); - } - if (strings && std::find(strings->begin(), strings->end(), pAction->getParameter(0)->getString().str()) == strings->end()) { - strings->push_back(pAction->getParameter(0)->getString().str()); - } - } - } - - return found; -} - -AsciiString EditParameter::getCreatedUnitTemplateName(AsciiString unitName) -{ - SidesList *sidesListP = m_sidesListP; - - for (int i=0; igetNumSides(); i++) { - BuildListInfo *bldList = sidesListP->getSideInfo(i)->getBuildList(); - while (bldList) { - if (bldList->getBuildingName() == unitName) { - return bldList->getTemplateName(); - } - bldList = bldList->getNext(); - } - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - ScriptAction *pAction; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - if (pAction->getActionType() != ScriptAction::CREATE_NAMED_ON_TEAM_AT_WAYPOINT - && pAction->getActionType() != ScriptAction::UNIT_SPAWN_NAMED_LOCATION_ORIENTATION) { - continue; - } - Int i; - Bool thisOne = false; - for (i=0; igetNumParameters(); i++) { - if (Parameter::UNIT == pAction->getParameter(i)->getParameterType()) { - if (unitName==pAction->getParameter(i)->getString()) { - thisOne = true; - } - } - } - if (thisOne) { - for (i=0; igetNumParameters(); i++) { - if (Parameter::OBJECT_TYPE == pAction->getParameter(i)->getParameterType()) { - return pAction->getParameter(i)->getString(); - } - } - } - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - if (pAction->getActionType() != ScriptAction::CREATE_NAMED_ON_TEAM_AT_WAYPOINT - && pAction->getActionType() != ScriptAction::UNIT_SPAWN_NAMED_LOCATION_ORIENTATION) { - continue; - } - Int i; - Bool thisOne = false; - for (i=0; igetNumParameters(); i++) { - if (Parameter::UNIT == pAction->getParameter(i)->getParameterType()) { - if (unitName==pAction->getParameter(i)->getString()) { - thisOne = true; - } - } - } - if (thisOne) { - for (i=0; igetNumParameters(); i++) { - if (Parameter::OBJECT_TYPE == pAction->getParameter(i)->getParameterType()) { - return pAction->getParameter(i)->getString(); - } - } - } - } - } - } - } - return AsciiString::TheEmptyString; -} - -Bool EditParameter::loadCounters(CComboBox *pCombo, AsciiString match) -{ - Bool found = false; - if (pCombo) pCombo->ResetContent(); - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - loadConditionParameter(pScr, Parameter::COUNTER, pCombo); - if (loadActionParameter(pScr, Parameter::COUNTER, pCombo, match)) { - found = true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - loadConditionParameter(pScr, Parameter::COUNTER, pCombo); - if (loadActionParameter(pScr, Parameter::COUNTER, pCombo, match)) { - found = true; - } - } - } - } - return found; -} - -Bool EditParameter::loadAttackPrioritySets(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Int i; - Bool found = false; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadAttackSetParameter(pScr, pCombo, match)) { - found=true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadAttackSetParameter(pScr, pCombo, match)) { - found = true; - } - } - } - } - return found; -} - -Bool EditParameter::loadSpecialPowers(CComboBox *pCombo, AsciiString match) -{ - Bool retVal = false; - Int numPowers = TheSpecialPowerStore->getNumSpecialPowers(); - for (int i = 0; i < numPowers; ++i) { - const SpecialPowerTemplate *pPower = TheSpecialPowerStore->getSpecialPowerTemplateByIndex(i); - if (!pPower) { - continue; - } - - AsciiString powerName = pPower->getName(); - if (pCombo) { - pCombo->AddString(powerName.str()); - } - - if (match == powerName) { - retVal = true; - } - } - - return retVal; -} - -//============================================================================= -Bool EditParameter::loadSciences(CComboBox *pCombo, AsciiString match) -{ - Bool retVal = false; - - std::vector v = TheScienceStore->friend_getScienceNames(); - for (int i = 0; i < v.size(); ++i) - { - if (pCombo) - { - pCombo->AddString(v[i].str()); - } - - if (match.compare(v[i]) == 0) - { - retVal = true; - } - } - - - return retVal; -} - -//============================================================================= -Bool EditParameter::loadScienceAvailabilities( CComboBox *pCombo, AsciiString match ) -{ - Bool retVal = false; - for( Int i = 0; i < SCIENCE_AVAILABILITY_COUNT; i++ ) - { - if( pCombo ) - { - pCombo->AddString( ScienceAvailabilityNames[ i ] ); - } - - if( !match.compareNoCase( ScienceAvailabilityNames[ i ] ) ) - { - retVal = true; - } - } - - return retVal; -} - -//============================================================================= -Bool EditParameter::loadUpgrades(CComboBox *pCombo, AsciiString match) -{ - Bool retVal = false; - std::vector upgradeNames = TheUpgradeCenter->getUpgradeNames(); - Int numUpgrades = upgradeNames.size(); - - for (int i = 0; i < numUpgrades; ++i) { - - AsciiString upgradeName = upgradeNames[i]; - if (pCombo) { - pCombo->AddString(upgradeName.str()); - } - - if (match == upgradeName) { - retVal = true; - } - } - - return retVal; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadAbilities( CComboBox *pCombo, AsciiString match ) -{ - Bool retVal = FALSE; - - MapObject *theUnit; - for( theUnit = MapObject::getFirstMapObject(); theUnit; theUnit = theUnit->getNext() ) - { - Bool exists; - AsciiString objName = theUnit->getProperties()->getAsciiString(TheKey_objectName, &exists); - if( !exists ) - { - continue; - } - if( objName.isEmpty() ) - { - continue; - } - if( theUnit->getFlag(FLAG_BRIDGE_FLAGS) ) - { - continue; - } - if( objName == m_unitName ) - { - break; - } - } - const ThingTemplate *theTemplate = nullptr; - - if ( theUnit ) { - theTemplate = theUnit->getThingTemplate(); - } else { - // see if the object was created via script, and therefore wasn't in the mapobject list. - AsciiString tmplName = getCreatedUnitTemplateName(m_unitName); - if (!tmplName.isEmpty()) { - theTemplate = TheThingFactory->findTemplate(tmplName); - } - } - - if (!theTemplate) { - return false; - } - - //Find the object's commandset. - if( !TheControlBar ) - { - // create the command bar - TheControlBar = new ControlBar; - TheControlBar->init(); - } - const CommandSet *commandSet = TheControlBar->findCommandSet( theTemplate->friend_getCommandSetString() ); - - if( commandSet ) - { - for( Int i = 0; i < MAX_COMMANDS_PER_SET; i++ ) - { - //Get the command button. - const CommandButton *commandButton = commandSet->getCommandButton(i); - - if( commandButton ) - { - if( !commandButton->getName().isEmpty() ) - { - if( pCombo ) - { - pCombo->AddString( commandButton->getName().str() ); - if( match == commandButton->getName() ) - { - retVal = TRUE; - } - } - } - } - } - } - else - { - //This unit doesn't have a commandset. - return FALSE; - } - return retVal; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadAllAbilities( CComboBox *pCombo, AsciiString match ) -{ - Bool retVal = FALSE; - - if( !TheControlBar ) - { - // create the command bar - TheControlBar = new ControlBar; - TheControlBar->init(); - } - - //Iterate through all the command button definitions - const CommandButton *commandButton = TheControlBar->getCommandButtons(); - while( commandButton ) - { - if( !commandButton->getName().isEmpty() ) - { - if( pCombo ) - { - pCombo->AddString( commandButton->getName().str() ); - if( match == commandButton->getName() ) - { - retVal = TRUE; - } - } - } - commandButton = commandButton->getNext(); - } - return retVal; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadEmoticons( CComboBox *pCombo, AsciiString match ) -{ - Bool retVal = FALSE; - - Anim2DTemplate *animTemplate = TheAnim2DCollection->getTemplateHead(); - //Iterate through all the definitions - - while( animTemplate ) - { - if( animTemplate->getName().isNotEmpty() ) - { - if( pCombo ) - { - pCombo->AddString( animTemplate->getName().str() ); - if( match == animTemplate->getName() ) - { - retVal = TRUE; - } - } - } - animTemplate = TheAnim2DCollection->getNextTemplate( animTemplate ); - } - return retVal; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadFlags(CComboBox *pCombo, AsciiString match) -{ - Bool found = false; - if (pCombo) pCombo->ResetContent(); - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - loadConditionParameter(pScr, Parameter::FLAG, pCombo); - if (loadActionParameter(pScr, Parameter::FLAG, pCombo, match)) { - found = true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - loadConditionParameter(pScr, Parameter::FLAG, pCombo); - if (loadActionParameter(pScr, Parameter::FLAG, pCombo, match)) { - found = true; - } - } - } - } - return found; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadObjectType(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) - pCombo->ResetContent(); - - Bool didMatch = false; - - didMatch = loadObjectTypeList(pCombo, nullptr, match); - - // add entries from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - if (pCombo) - pCombo->AddString( tTemplate->getName().str()); - - if ((match==tTemplate->getName())) - didMatch = true; - } - return didMatch; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadObjectTypeList(CComboBox *pCombo, std::vector *strings, AsciiString match) -{ - Bool didMatch = false; - - if (pCombo) - pCombo->ResetContent(); - - if (strings) - strings->clear(); - - SidesList *sidesListP = m_sidesListP; - - // first, add any object lists that exist anywhere in the scripts - for (Int i=0; igetNumSides(); ++i) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadCreateObjectListsParameter(pScr, pCombo, strings, match)) { - didMatch=true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadCreateObjectListsParameter(pScr, pCombo, strings, match)) { - didMatch = true; - } - } - } - } - - return didMatch; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadRevealNames(CComboBox *pCombo, AsciiString match) -{ - Bool didMatch = false; - - if (pCombo) - pCombo->ResetContent(); - - SidesList *sidesListP = m_sidesListP; - - for (Int i = 0; i < sidesListP->getNumSides(); ++i) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr = pScr->getNext()) { - if (loadRevealNamesParameter(pScr, pCombo, match)) { - didMatch = true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - if (loadRevealNamesParameter(pScr, pCombo, match)) { - didMatch = true; - } - } - } - } - - return didMatch; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadRevealNamesParameter(Script *pScr, CComboBox *pCombo, AsciiString match) -{ - ScriptAction *pAction; - Bool found = false; - for (pAction = pScr->getAction(); pAction; pAction = pAction->getNext()) { - if (pAction->getActionType() != ScriptAction::MAP_REVEAL_PERMANENTLY_AT_WAYPOINT) { - continue; - } - - if (Parameter::REVEALNAME == pAction->getParameter(3)->getParameterType()) { - if (match == pAction->getParameter(3)->getString()) { - found = true; - } - if (pCombo && CB_ERR == pCombo->FindStringExact(-1, pAction->getParameter(3)->getString().str())) { - pCombo->AddString(pAction->getParameter(3)->getString().str()); - } - } - } - - return found; -} - - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadAudioType(Parameter::ParameterType comboType, CComboBox *pCombo, AsciiString match) -{ - Bool retVal = false; - AudioType type = AT_SoundEffect; - switch (comboType) - { - case Parameter::DIALOG: type = AT_Streaming; break; - case Parameter::SOUND: type = AT_SoundEffect; break; - case Parameter::MUSIC: type = AT_Music; break; - } - - std::vector eventInfos; - TheAudio->findAllAudioEventsOfType(type, eventInfos); - - for (int i = 0; i < eventInfos.size(); ++i) { - if (eventInfos[i]) { - if (pCombo) { - pCombo->AddString(eventInfos[i]->m_audioName.str()); - } - - if (match == eventInfos[i]->m_audioName) { - retVal = true; - } - } - } - return retVal; - -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadMovies(CComboBox *pCombo, AsciiString match) -{ - Bool retVal = false; - Int numVideos = TheVideoPlayer->getNumVideos(); - for (int i = 0; i < numVideos; ++i) { - const Video *pVideo = TheVideoPlayer->getVideo(i); - if (!pVideo) { - continue; - } - - AsciiString videoName = pVideo->m_internalName; - if (pCombo) { - pCombo->AddString(videoName.str()); - } - - if (match == videoName) { - retVal = true; - } - } - - return retVal; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::getMovieComment(AsciiString match, AsciiString& outCommentFromINI) -{ - Bool retVal = false; - Int numVideos = TheVideoPlayer->getNumVideos(); - for (int i = 0; i < numVideos; ++i) { - const Video *pVideo = TheVideoPlayer->getVideo(i); - if (!pVideo) { - continue; - } - - AsciiString videoName = pVideo->m_internalName; - if (match == videoName && pVideo->m_commentForWB != AsciiString::TheEmptyString) { - outCommentFromINI = pVideo->m_commentForWB; - retVal = true; - } - } - - return retVal; -} - - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadTriggerAreas(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - AsciiString trigName; - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - trigName = pTrig->getTriggerName(); - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - } - trigName = MY_INNER_PERIMETER; - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - trigName = MY_OUTER_PERIMETER; - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - trigName = ENEMY_OUTER_PERIMETER; - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - trigName = ENEMY_INNER_PERIMETER; - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - trigName = WATER_GRID; - if (pCombo) pCombo->AddString(trigName.str()); - if ((match==trigName)) didMatch = true; - return didMatch; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadCommandButtons(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - // gets the list of command buttons - File *fp = TheFileSystem->openFile("Data\\INI\\CommandButton.ini", File::READ | File::TEXT); - //sanity - DEBUG_ASSERTCRASH( fp, ("Cannot find file CommandButton.ini")); - - char buf[1024]; - char *string; - char *token; - char seps[] = " ,\t\n\r"; - - fp->nextLine(buf, 1024); - string = buf; - while (fp->eof() == FALSE) - { - token = strtok(string, seps); - if( token != nullptr ) - { - if( strcmp( token, "CommandButton" ) == 0) - { - token = strtok(nullptr, seps); - if( token != nullptr ) - { - if (pCombo) pCombo->AddString(token); - if (strcmp(match.str(), token) == 0) didMatch = true; - } - } - } - fp->nextLine(buf, 1024); - string = buf; - } - - fp->close(); - fp = nullptr; - - return didMatch; -} - -//------------------------------------------------------------------------------------------------- -Bool EditParameter::loadFontNames(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - GameFont *font; - - - // create the font library - TheFontLibrary = new W3DFontLibrary; - if( TheFontLibrary ) - TheFontLibrary->init(); - - // reads the font file into TheFontLibrary - readFontFile( WORLDBUILDER_FONT_FILENAME ); - - for( font = TheFontLibrary->firstFont(); font; font = TheFontLibrary->nextFont( font ) ) - { - AsciiString string = font->nameString; - string.concat( " - Size:" ); - Int size = font->pointSize; - char buffer[33]; - itoa( size, buffer, 10 ); - string.concat( buffer ); - if( font->bold ) - string.concat( " [Bold]" ); - if( string != AsciiString::TheEmptyString ) - { - if (pCombo) pCombo->AddString( string.str() ); - if( (match==string) ) didMatch = true; - } - } - - // delete the font library - TheFontLibrary->reset(); - delete TheFontLibrary; - TheFontLibrary = nullptr; - - return didMatch; -} - -// EditParameter::readFontFile ====================================================== -/** Read the font file definitions and load them */ -//============================================================================= -void EditParameter::readFontFile( const char *filename ) -{ - File *fp; - - // sanity - if( filename == nullptr ) - return; - - // open the file - fp = TheFileSystem->openFile( filename, File::READ | File::TEXT); - if( fp == nullptr ) - return; - - // read how many entries follow - Int fontCount; - fp->read(nullptr, sizeof("AVAILABLE_FONT_COUNT = ")); - fp->scanInt(fontCount); - - for( Int i = 0; i < fontCount; i++ ) - { - - // read all the font definitions - char fontBuffer[ 512 ]; - Int size, bold; - char c; - fp->read(&c, 1); - - // skip past the first quote - while( c != '\"' ) - fp->read(&c, 1); - fp->read(&c, 1); - - // copy the name till the next quote is read - Int index = 0; - while( c != '\"' ) - { - - fontBuffer[ index++ ] = c; - fp->read(&c, 1); - - } - fontBuffer[ index ] = '\0'; - fp->read(&c, 1); - - // read the size and bold data elements - fp->seek(strlen(" Size: ")); - fp->scanInt(size); - fp->seek(strlen(" Bold: ")); - fp->scanInt(bold); - fp->nextLine(); - - // set the font - GameFont *font = TheFontLibrary->getFont( AsciiString(fontBuffer), size, bold ); - if( font == nullptr ) - { - char buffer[ 1024 ]; - - snprintf( buffer, ARRAY_SIZE(buffer), "Warning: The font '%s' Size: '%d' Bold: '%d', specified in the config file could not be loaded. Does that font exist?", - fontBuffer, size, bold ); - //MessageBox( m_appHWnd, buffer, "Cannot Load Font", MB_OK ); - - } - - } - - // close the file - fp->close(); - fp = nullptr; - -} - -Bool EditParameter::loadWaypoints(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - AsciiString wayName = pMapObj->getWaypointName(); - if (pCombo&& (CB_ERR == pCombo->FindStringExact(-1, wayName.str()))) pCombo->AddString(wayName.str()); - if ((match==wayName)) didMatch = true; - } - } - return didMatch; -} - -Bool EditParameter::loadWaypointPaths(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - AsciiString wayName; - Bool exists; - wayName= pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel1, &exists); - if (!wayName.isEmpty()) { - if (pCombo && (CB_ERR == pCombo->FindStringExact(-1, wayName.str()))) { - pCombo->AddString(wayName.str()); - } - if ((match==wayName)) didMatch = true; - } - wayName= pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel2, &exists); - if (!wayName.isEmpty()) { - if (pCombo && (CB_ERR == pCombo->FindStringExact(-1, wayName.str()))) { - pCombo->AddString(wayName.str()); - } - if ((match==wayName)) didMatch = true; - } - wayName= pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel3, &exists); - if (!wayName.isEmpty()) { - if (pCombo && (CB_ERR == pCombo->FindStringExact(-1, wayName.str()))) { - pCombo->AddString(wayName.str()); - } - if ((match==wayName)) didMatch = true; - } - } - } - return didMatch; -} - -Bool EditParameter::loadObjectFlags(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - - Int i; - Bool didMatch = false; - - for (i = 0; TheObjectFlagsNames[i]; ++i) { - if (pCombo) - pCombo->AddString(TheObjectFlagsNames[i]); - if (match == TheObjectFlagsNames[i]) { - didMatch = true; - } - } - - return didMatch; -} - -Bool EditParameter::loadScripts(CComboBox *pCombo, Bool subr, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - Bool didMatch = false; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - if (pSL == nullptr) continue; - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - if (subr && !pScr->isSubroutine()) continue; - if (pCombo) pCombo->AddString(pScr->getName().str()); - if ((match==pScr->getName())) didMatch = true; - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - if (!subr || pGroup->isSubroutine()) { - if (pCombo) pCombo->AddString(pGroup->getName().str()); - if ((match==pGroup->getName())) didMatch = true; - } - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - if (subr && !pScr->isSubroutine()) continue; - if (pCombo) pCombo->AddString(pScr->getName().str()); - if ((match==pScr->getName())) didMatch = true; - } - } - } - return didMatch; -} - -Bool EditParameter::loadSides(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) { - pCombo->ResetContent(); - pCombo->AddString(LOCAL_PLAYER); - pCombo->AddString(THIS_PLAYER); - pCombo->AddString(THIS_PLAYER_ENEMY); - } - Bool didMatch = false; - if (match == LOCAL_PLAYER) didMatch=true; - if (match == THIS_PLAYER) didMatch=true; - if (match == THIS_PLAYER_ENEMY) didMatch=true; - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i=0; igetNumSides(); i++) { - Dict *d = sidesListP->getSideInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_playerName); - if (name.isEmpty()) continue; - if (pCombo) pCombo->AddString(name.str()); - if ((name==match)) didMatch = true; - } - return didMatch; -} - -Bool EditParameter::loadTeams(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) { - pCombo->ResetContent(); - pCombo->AddString(THIS_TEAM); - //pCombo->AddString(ANY_TEAM); - } - Bool didMatch = false; - if (match == THIS_TEAM) didMatch=true; - if (match == ANY_TEAM) didMatch=true; - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i = 0; i < sidesListP->getNumTeams(); i++) - { - Dict *d = sidesListP->getTeamInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_teamName); - DEBUG_ASSERTCRASH(!name.isEmpty(),("bad")); - - if (name == "team") { - // Neutral team. - continue; - } - if (pCombo) pCombo->AddString(name.str()); - if ((name==match)) didMatch = true; - } - return didMatch; -} - -Bool EditParameter::loadTeamOrUnit(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) { - pCombo->ResetContent(); - } - Bool didMatch = false; - Int i; - SidesList *sidesListP = m_sidesListP; - if (sidesListP==nullptr) sidesListP = TheSidesList; - for (i = 0; i < sidesListP->getNumTeams(); i++) - { - Dict *d = sidesListP->getTeamInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_teamName); - DEBUG_ASSERTCRASH(!name.isEmpty(),("bad")); - - if (name == "team") { - // Neutral team. - continue; - } - if (pCombo) pCombo->AddString(name.str()); - if ((name==match)) didMatch = true; - } - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - Bool exists; - AsciiString objName = pMapObj->getProperties()->getAsciiString(TheKey_objectName, &exists); - if (!exists) continue; - if (objName.isEmpty()) continue; - if (pCombo) pCombo->AddString(objName.str()); - if (objName == match) didMatch = true; - } - return didMatch; -} - -Bool EditParameter::loadUnits(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) - { - pCombo->ResetContent(); - pCombo->AddString(THIS_OBJECT); - //pCombo->AddString(ANY_OBJECT); - } - Bool didMatch = false; - if( match == THIS_OBJECT ) - { - didMatch = true; - } - if( match == ANY_OBJECT ) - { - didMatch=true; - } - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - Bool exists; - AsciiString objName = pMapObj->getProperties()->getAsciiString(TheKey_objectName, &exists); - if (!exists) - { - continue; - } - if (objName.isEmpty()) - { - continue; - } - if (pMapObj->getFlag(FLAG_ROAD_FLAGS)) - { - continue; - } - if (pCombo) - { - pCombo->AddString(objName.str()); - } - if (objName == match) - { - didMatch = true; - } - } - - SidesList *sidesListP = m_sidesListP; - Int i; - if (sidesListP==nullptr) - { - sidesListP = TheSidesList; - } - for (i = 0; i < sidesListP->getNumSides(); i++) - { - SidesInfo *pSide = sidesListP->getSideInfo(i); - - BuildListInfo *pBI = pSide->getBuildList(); - while (pBI) - { - if (pBI->getBuildingName().isNotEmpty()) - { - if (pCombo) - { - pCombo->AddString(pBI->getBuildingName().str()); - } - if (pBI->getBuildingName() == match) - { - didMatch = true; - } - } - pBI = pBI->getNext(); - } - } - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadCreateUnitParameter(pScr, pCombo, match)) { - didMatch=true; - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - // Attack priority sets get created in actions. - if (loadCreateUnitParameter(pScr, pCombo, match)) { - didMatch = true; - } - } - } - } - - return didMatch; -} - -Bool EditParameter::loadTransports(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) { - pCombo->ResetContent(); - } - Bool didMatch = false; - - // add transports from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - - if (tTemplate->isKindOf(KINDOF_TRANSPORT)) { - if (pCombo) pCombo->AddString( tTemplate->getName().str()); - if ((match==tTemplate->getName())) didMatch = true; - } - } - return didMatch; -} - -Bool EditParameter::loadBridges(CComboBox *pCombo, AsciiString match) -{ - if (pCombo) pCombo->ResetContent(); - Bool didMatch = false; - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - Bool exists; - AsciiString objName = pMapObj->getProperties()->getAsciiString(TheKey_objectName, &exists); - if (!exists) continue; - if (objName.isEmpty()) continue; - if (pMapObj->getFlag(FLAG_BRIDGE_POINT1)) { - if (pMapObj->getNext() && pMapObj->getNext()->getFlag(FLAG_BRIDGE_POINT2)) { - if (pCombo) pCombo->AddString(objName.str()); - if (objName == match) didMatch = true; - } - } - } - return didMatch; -} - -BOOL EditParameter::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *pCaption = GetDlgItem(IDC_CAPTION); - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO); - CComboBox *pList = (CComboBox*)GetDlgItem(IDC_LIST); - CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT); - - pCombo->ShowWindow(SW_HIDE); - pList->ShowWindow(SW_HIDE); - pEdit->ShowWindow(SW_HIDE); - - CString captionText; - Bool showCombo = false; - Bool showAudioButton = false; - CString editText; - Bool showList = false; - Int i; - - switch (m_parameter->getParameterType()) { - default: - DEBUG_CRASH(("Unknown parameter type.")); - break; - case Parameter::SCRIPT: - captionText = "Script named:"; - showCombo = true; - loadScripts(pCombo, false); - break; - case Parameter::SCRIPT_SUBROUTINE: - captionText = "Subroutine named:"; - showCombo = true; - loadScripts(pCombo, true); - break; - case Parameter::ATTACK_PRIORITY_SET: - captionText = "Attack priority set named:"; - showCombo = true; - loadAttackPrioritySets(pCombo); - break; - case Parameter::WAYPOINT: - captionText = "Waypoint named:"; - showCombo = true; - loadWaypoints(pCombo); - break; - - case Parameter::LOCALIZED_TEXT: - captionText = "Localized string:"; - showCombo = true; - loadLocalizedText(pCombo); - break; - case Parameter::WAYPOINT_PATH: - captionText = "Waypoint labeled:"; - showCombo = true; - loadWaypointPaths(pCombo); - break; - case Parameter::TRIGGER_AREA: - captionText = "Trigger area named:"; - showCombo = true; - loadTriggerAreas(pCombo); - break; - case Parameter::COMMAND_BUTTON: - captionText = "Command button named:"; - showCombo = true; - loadCommandButtons(pCombo); - break; - case Parameter::FONT_NAME: - captionText = "Text type named:"; - showCombo = true; - loadFontNames(pCombo); - break; - case Parameter::TEXT_STRING: - captionText = "Text String:"; - editText = m_parameter->getString().str(); - showCombo = false; - break; - case Parameter::TEAM_STATE: - captionText = "Team State:"; - editText = m_parameter->getString().str(); - showCombo = false; - break; - case Parameter::BRIDGE: - captionText = "Bridge named:"; - showCombo = true; - loadBridges(pCombo); - break; - case Parameter::TEAM: - captionText = "Team named:"; - showCombo = true; - loadTeams(pCombo); - break; - case Parameter::UNIT: - captionText = "Unit named:"; - showCombo = true; - loadUnits(pCombo); - break; - case Parameter::OBJECT_TYPE: - captionText = "Object type:"; - showList = true; - loadObjectType(pList); - break; - case Parameter::SIDE: - captionText = "Player named:"; - showCombo = true; - loadSides(pCombo); - break; - case Parameter::COUNTER: - captionText = "Counter named:"; - showCombo = true; - loadCounters(pCombo); - break; - case Parameter::INT: - captionText = "Integer:"; - editText.Format("%d", m_parameter->getInt()); - showCombo = false; - break; - case Parameter::COLOR: - DEBUG_CRASH(("should never get here for this data type")); - captionText = "Color:"; - editText.Format("%08lx", m_parameter->getInt()); - showCombo = false; - break; - case Parameter::BOOLEAN: - captionText = "Boolean:"; - pList->InsertString(-1, "False"); - pList->InsertString(-1, "True"); - pList->SetCurSel(m_parameter->getInt()); - showList = true; - break; - - case Parameter::REAL: - captionText = "Real number:"; - editText.Format("%.2f", m_parameter->getReal()); - showCombo = false; - break; - - case Parameter::ANGLE: - captionText = "Angle (degrees):"; - editText.Format("%.2f", m_parameter->getReal()*180/PI); - showCombo = false; - break; - -#if RTS_ZEROHOUR - case Parameter::PERCENT: - captionText = "Percent:"; - editText.Format("%.2f", m_parameter->getReal()*100.0f); - showCombo = false; - break; -#endif - - case Parameter::FLAG: - captionText = "Flag named:"; - showCombo = true; - loadFlags(pCombo); - break; - case Parameter::COMPARISON: - captionText = "Comparison:"; - pList->InsertString(-1, "LT Less Than"); - pList->InsertString(-1, "LE Less Than or Equal"); - pList->InsertString(-1, "EQ Equal To"); - pList->InsertString(-1, "GE Greater Than or Equal"); - pList->InsertString(-1, "GT Greater Than"); - pList->InsertString(-1, "NE Not Equal To"); - pList->SetCurSel(m_parameter->getInt()); - showList = true; - break; - - case Parameter::KIND_OF_PARAM: - captionText = "Kind of:"; - showList = true; - for (i=KINDOF_FIRST; iInsertString(-1, KindOfMaskType::getBitNames()[i-KINDOF_FIRST]); - } - pList->SetCurSel(m_parameter->getInt()); - break; - - case Parameter::OBJECT_PANEL_FLAG: - captionText = "Object Panel Flag:"; - showCombo = true; - loadObjectFlags(pCombo); - break; - - case Parameter::AI_MOOD: - captionText = "AI Mood:"; - pList->InsertString(-1, "Sleep"); - pList->InsertString(-1, "Passive"); - pList->InsertString(-1, "Normal"); - pList->InsertString(-1, "Alert"); - pList->InsertString(-1, "Aggressive"); - pList->SetCurSel(m_parameter->getInt() - ATTITUDE_SLEEP); - showList = true; - break; - - case Parameter::SKIRMISH_WAYPOINT_PATH: - captionText = "Skirmish Approach Path:"; - pList->InsertString(-1, "Center"); - pList->InsertString(-1, "Backdoor"); - pList->InsertString(-1, "Flank"); - pList->InsertString(-1, "Special"); - i = pList->FindStringExact(-1, m_parameter->getString().str()); - if (i!=CB_ERR) - pList->SetCurSel(i); - else - pList->SetCurSel(0); - showList = true; - break; - - case Parameter::RADAR_EVENT_TYPE: - captionText = "Radar Event Type:"; - pList->InsertString(-1,"Construction"); - pList->InsertString(-1,"Upgrade"); - pList->InsertString(-1,"Under Attack"); - pList->InsertString(-1,"Information"); - pList->SetCurSel(m_parameter->getInt() - RADAR_EVENT_CONSTRUCTION); - showList = true; - break; - - -#if RTS_ZEROHOUR - case Parameter::LEFT_OR_RIGHT: - captionText = "Evacuate Container Side Choices:"; - pList->InsertString(-1,"Left"); - pList->InsertString(-1,"Right"); - pList->InsertString(-1,"Center (Default)"); - pList->SetCurSel(m_parameter->getInt() - 1); - showList = true; - break; -#endif - - case Parameter::RELATION: - captionText = "Relation:"; - pList->InsertString(-1, "Enemy"); - pList->InsertString(-1, "Neutral"); - pList->InsertString(-1, "Friend"); - pList->SetCurSel(m_parameter->getInt()); - showList = true; - break; - - case Parameter::DIALOG: - captionText = "Dialog :"; - case Parameter::MUSIC: - captionText = "Music :"; - case Parameter::SOUND: - if (m_parameter->getParameterType() == Parameter::SOUND) { - captionText = "Sound :"; - } - captionText = "Locate the Audio name:"; - showCombo = true; - // enable the preview sound button only if we are dealing with a soundfx or speech - showAudioButton = true; - if (m_parameter->getParameterType() == Parameter::MUSIC) - showAudioButton = false; - loadAudioType(m_parameter->getParameterType(), pCombo); - break; - case Parameter::MOVIE: - captionText = "Locate the Audio name:"; - showCombo = true; - loadMovies(pCombo); - break; - - case Parameter::SPECIAL_POWER: - captionText = "Special Power:"; - showCombo = true; - loadSpecialPowers(pCombo); - break; - - case Parameter::SCIENCE: - captionText = "Science:"; - showCombo = true; - loadSciences(pCombo); - break; - - case Parameter::SCIENCE_AVAILABILITY: - captionText = "Science Availability:"; - showCombo = true; - loadScienceAvailabilities( pCombo ); - break; - - case Parameter::UPGRADE: - captionText = "Upgrade:"; - showCombo = true; - loadUpgrades(pCombo); - break; - - case Parameter::COMMANDBUTTON_ABILITY: - captionText = "Ability:"; - showCombo = true; - loadAbilities( pCombo ); - break; - - case Parameter::COMMANDBUTTON_ALL_ABILITIES: - captionText = "Ability:"; - showCombo = true; - loadAllAbilities( pCombo ); - break; - - case Parameter::BOUNDARY: - { - captionText = "Boundary:"; - showCombo = true; - int numBoundaries = TheTerrainRenderObject->getMap()->getAllBoundaries().size(); - for (int i = 0; i < numBoundaries; ++i) { - pCombo->InsertString(-1, BORDER_COLORS[i % BORDER_COLORS_SIZE].m_colorName); - } - break; - } - - case Parameter::BUILDABLE: - captionText = "Buidable:"; - showList = true; - - for (i = BSTATUS_YES; i < BSTATUS_NUM_TYPES; ++i) { - pList->InsertString(-1, BuildableStatusNames[i - BSTATUS_YES]); - } - pList->SetCurSel(m_parameter->getInt()); - break; - - case Parameter::SURFACES_ALLOWED: - { - captionText = "Surfaces allowed: "; - showList = true; - - for (i = 0; i < 3; ++i) { - pList->InsertString(-1, Surfaces[i]); - } - - // 0 is invalid for surfaces, so change this to a 3 (which means AIR and GROUND) - if (m_parameter->getInt() == 0) { - m_parameter->friend_setInt(3); - } - - pList->SetCurSel(m_parameter->getInt() - 1); - break; - } - - case Parameter::SHAKE_INTENSITY: - { - captionText = "Shake Intensity: "; - showList = true; - for (i = 0; i < View::SHAKE_COUNT; ++i) { - pList->InsertString(-1, ShakeIntensities[i]); - } - - pList->SetCurSel(m_parameter->getInt()); - break; - } - - case Parameter::OBJECT_STATUS: - { - captionText = "Object status:"; - showList = true; - for( i = 0; i < OBJECT_STATUS_COUNT; i++ ) - { - pList->InsertString( -1, ObjectStatusMaskType::getBitNames()[i] ); - } - pList->SelectString( -1, m_parameter->getString().str() ); - break; - } - - case Parameter::FACTION_NAME: - { - captionText = "Faction Name: "; - showList = true; - - AsciiStringList sideList; - ThePlayerTemplateStore->getAllSideStrings(&sideList); - - for (AsciiStringListIterator it = sideList.begin(); it != sideList.end(); ++it) { - pList->InsertString(-1, it->str()); - } - - pList->SetCurSel(0); - break; - } - - case Parameter::EMOTICON: - { - captionText = "Emoticons:"; - showCombo = true; - loadEmoticons( pCombo ); - break; - } - case Parameter::OBJECT_TYPE_LIST: - { - captionText = "Object type list:"; - showCombo = true; - loadObjectTypeList(pCombo); - break; - } - case Parameter::REVEALNAME: - { - captionText = "Reveal Name:"; - showCombo = true; - loadRevealNames(pCombo); - break; - } - - - } - if (showCombo) { - pCombo->ShowWindow(SW_SHOW); - pCombo->SetWindowText(m_parameter->getString().str()); - if (m_parameter->getString().isEmpty()) { - pCombo->SetCurSel(0); - } - pCombo->SetFocus(); - if (m_key && m_key != VK_SPACE) pCombo->PostMessage(WM_CHAR, m_key, 0); - } else if (showList) { - pList->ShowWindow(SW_SHOW); - pList->SetFocus(); - if (m_key && m_key != VK_SPACE) pList->PostMessage(WM_CHAR, m_key, 0); - } else { - pEdit->ShowWindow(SW_SHOW); - pEdit->SetWindowText(editText); - pEdit->SetSel(0, 999); - pEdit->SetFocus(); - if (m_key && m_key != VK_SPACE) pEdit->PostMessage(WM_CHAR, m_key, 0); - } - pCaption->SetWindowText(captionText); - - CButton *previewSound = (CButton*)GetDlgItem(IDPREVIEWSOUND); - if (previewSound) { - previewSound->ShowWindow(showAudioButton ? SW_SHOW : SW_HIDE); - } - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -Bool EditParameter::scanReal(CEdit *pEdit, Real scale) -{ - CString txt; - Real theReal; - - pEdit->GetWindowText(txt); - if (1==sscanf(txt, "%f", &theReal)) { - m_parameter->friend_setReal(theReal*scale); - return TRUE; - } else { - pEdit->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return FALSE; - } -} - -void EditParameter::OnOK() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO); - CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT); - CComboBox *pList = (CComboBox*)GetDlgItem(IDC_LIST); - CString txt; - AsciiString comboText; - switch (m_parameter->getParameterType()) { - default: - DEBUG_CRASH(("Unknown parameter type.")); - break; - case Parameter::UNIT: - case Parameter::SCRIPT: - case Parameter::SCRIPT_SUBROUTINE: - case Parameter::ATTACK_PRIORITY_SET: - case Parameter::SIDE: - case Parameter::WAYPOINT: - case Parameter::WAYPOINT_PATH: - case Parameter::TRIGGER_AREA: - case Parameter::COMMAND_BUTTON: - case Parameter::FONT_NAME: - case Parameter::TEAM: - case Parameter::OBJECT_TYPE: - case Parameter::OBJECT_TYPE_LIST: - case Parameter::BRIDGE: - case Parameter::FLAG: - case Parameter::COUNTER: - case Parameter::DIALOG: - case Parameter::MUSIC: - case Parameter::SPECIAL_POWER: - case Parameter::SCIENCE: - case Parameter::SCIENCE_AVAILABILITY: - case Parameter::UPGRADE: - case Parameter::SOUND: - case Parameter::MOVIE: - case Parameter::COMMANDBUTTON_ABILITY: - case Parameter::COMMANDBUTTON_ALL_ABILITIES: - case Parameter::EMOTICON: - case Parameter::REVEALNAME: - pCombo->GetWindowText(txt); - comboText = AsciiString(txt); - m_parameter->friend_setString(comboText); - break; - case Parameter::TEAM_STATE: - case Parameter::TEXT_STRING: - pEdit->GetWindowText(txt); - comboText = AsciiString(txt); - m_parameter->friend_setString(comboText); - break; - case Parameter::INT: - pEdit->GetWindowText(txt); - Int theInt; - if (1==sscanf(txt, "%d", &theInt)) { - m_parameter->friend_setInt(theInt); - } else { - pEdit->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - break; - - case Parameter::COLOR: - DEBUG_CRASH(("should never get here for this data type")); - pEdit->GetWindowText(txt); - if (1==sscanf(txt, "%08lx", &theInt)) { - m_parameter->friend_setInt(theInt); - } else { - pEdit->SetFocus(); - ::MessageBeep(MB_ICONEXCLAMATION); - return; - } - break; - - case Parameter::REAL: - if (! scanReal(pEdit, 1.0f)) { - return; - } - break; - - case Parameter::ANGLE: - if (! scanReal(pEdit, PI/180.0f)) { - return; - } - break; - -#if RTS_ZEROHOUR - case Parameter::PERCENT: - if (! scanReal(pEdit, 1.0f/100.0f)) { - return; - } - break; -#endif - - case Parameter::BOOLEAN: - case Parameter::COMPARISON: - m_parameter->friend_setInt(pList->GetCurSel()); - break; - case Parameter::KIND_OF_PARAM: - m_parameter->friend_setInt(pList->GetCurSel()+KINDOF_FIRST); - break; - - case Parameter::RELATION: - m_parameter->friend_setInt(pList->GetCurSel() + Parameter::REL_ENEMY); - break; - case Parameter::AI_MOOD: - m_parameter->friend_setInt(pList->GetCurSel() + ATTITUDE_SLEEP); - break; - case Parameter::SKIRMISH_WAYPOINT_PATH: { - CString cstr; - pList->GetLBText(pList->GetCurSel(), cstr); - m_parameter->friend_setString((LPCTSTR)cstr); - break; - } - case Parameter::RADAR_EVENT_TYPE: - m_parameter->friend_setInt(pList->GetCurSel() + RADAR_EVENT_CONSTRUCTION); - break; - - -#if RTS_ZEROHOUR - case Parameter::LEFT_OR_RIGHT: - m_parameter->friend_setInt(pList->GetCurSel() + 1); - break; -#endif - - case Parameter::LOCALIZED_TEXT: - pCombo->GetWindowText(txt); - comboText = AsciiString(txt); - m_parameter->friend_setString(loadLocalizedText(nullptr, comboText)); - break; - case Parameter::BOUNDARY: - { - Int curSel = pCombo->GetCurSel(); - if (curSel >= 0) { - m_parameter->friend_setInt(curSel); - } - break; - } - - case Parameter::BUILDABLE: - m_parameter->friend_setInt(pList->GetCurSel()+BSTATUS_YES); - break; - - case Parameter::SURFACES_ALLOWED: - m_parameter->friend_setInt(pList->GetCurSel() + 1); - break; - - case Parameter::SHAKE_INTENSITY: - m_parameter->friend_setInt(pList->GetCurSel()); - break; - - case Parameter::OBJECT_STATUS: - { - Int curSel = pList->GetCurSel(); - if( curSel >= 0 ) - { - m_parameter->friend_setString( ObjectStatusMaskType::getBitNames()[curSel] ); - } - else - { - m_parameter->friend_setString( AsciiString::TheEmptyString ); - } - break; - } - - case Parameter::FACTION_NAME: - { - Int curSel = pList->GetCurSel(); - if (curSel >= 0) { - CString str; - pList->GetWindowText(str); - m_parameter->friend_setString(str.GetBuffer(0)); - } - break; - } - - case Parameter::OBJECT_PANEL_FLAG: - { - CString str; - pCombo->GetWindowText(str); - m_parameter->friend_setString(str.GetBuffer(0)); - break; - } - } - CDialog::OnOK(); -} - -void EditParameter::OnCancel() -{ - - CDialog::OnCancel(); -} - -/* This function handles a left click on - the "preview sound" button */ -void EditParameter::OnPreviewSound() -{ - CString txt; - AsciiString comboText; - - //only execute if the script in the combo box deals with sound - if (m_parameter->getParameterType() == Parameter::SOUND || - m_parameter->getParameterType() == Parameter::DIALOG || - m_parameter->getParameterType() == Parameter::MUSIC) { - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_COMBO); - pCombo->GetWindowText(txt); - comboText = AsciiString(txt); - - //acquire and play song based on the string in the combo box - AudioEventRTS event; - event.setEventName(comboText); - event.setAudioEventInfo(TheAudio->findAudioEventInfo(comboText)); - event.generateFilename(); - - if (!event.getFilename().isEmpty()) { - PlaySound(event.getFilename().str(), nullptr, SND_ASYNC | SND_FILENAME | SND_PURGE); - } - } -} - -AsciiString EditParameter::loadLocalizedText(CComboBox *pCombo, AsciiString isStringInTable) -{ - static const AsciiString theScriptPrefix = "SCRIPT"; - AsciiStringVec vec = TheGameText->getStringsWithLabelPrefix(theScriptPrefix); - if (pCombo) { - pCombo->Clear(); - for (int i = 0; i < vec.size(); ++i) { - pCombo->AddString(vec[i].str()); - } - } - - if (isStringInTable != AsciiString::TheEmptyString) { - for (int i = 0; i < vec.size(); ++i) { - if (isStringInTable.compare(vec[i].str()) == 0) { - return vec[i]; - } - } - } - - return AsciiString::TheEmptyString; -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp deleted file mode 100644 index 227df718459..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ExportScriptsOptions.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ExportScriptsOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "ExportScriptsOptions.h" - -///////////////////////////////////////////////////////////////////////////// -// ExportScriptsOptions dialog -Bool ExportScriptsOptions::m_units = true; -Bool ExportScriptsOptions::m_waypoints = true; -Bool ExportScriptsOptions::m_triggers = true; -Bool ExportScriptsOptions::m_allScripts = false; -Bool ExportScriptsOptions::m_sides = true; - -ExportScriptsOptions::ExportScriptsOptions(CWnd* pParent /*=nullptr*/) - : CDialog(ExportScriptsOptions::IDD, pParent) -{ - //{{AFX_DATA_INIT(ExportScriptsOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void ExportScriptsOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ExportScriptsOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ExportScriptsOptions, CDialog) - //{{AFX_MSG_MAP(ExportScriptsOptions) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ExportScriptsOptions message handlers - -void ExportScriptsOptions::OnOK() -{ - // TODO: Add extra validation here - - CButton *pButton = (CButton*)GetDlgItem(IDC_WAYPOINTS); - m_waypoints = pButton->GetCheck()==1; - pButton = (CButton*)GetDlgItem(IDC_UNITS); - m_units = pButton->GetCheck()==1; - pButton = (CButton*)GetDlgItem(IDC_TRIGGERS); - m_triggers = pButton->GetCheck()==1; - pButton = (CButton*)GetDlgItem(IDC_ALL_SCRIPTS); - m_allScripts = pButton->GetCheck()==1; - pButton = (CButton*)GetDlgItem(IDC_SIDES); - m_sides = pButton->GetCheck()==1; - - - CDialog::OnOK(); -} - -BOOL ExportScriptsOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CButton *pButton = (CButton*)GetDlgItem(IDC_WAYPOINTS); - pButton->SetCheck(m_waypoints?1:0); - pButton = (CButton*)GetDlgItem(IDC_UNITS); - pButton->SetCheck(m_units?1:0); - pButton = (CButton*)GetDlgItem(IDC_TRIGGERS); - pButton->SetCheck(m_triggers?1:0); - pButton = (CButton*)GetDlgItem(IDC_ALL_SCRIPTS); - pButton->SetCheck(m_allScripts?1:0); - pButton = (CButton*)GetDlgItem(IDC_SELECTED_SCRIPTS); - pButton->SetCheck(m_allScripts?0:1); - pButton = (CButton*)GetDlgItem(IDC_SIDES); - pButton->SetCheck(m_sides?1:0); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/EyedropperTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/EyedropperTool.cpp deleted file mode 100644 index 1fbbe91a7b6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/EyedropperTool.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// EyedropperTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "EyedropperTool.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MainFrm.h" -#include "DrawObject.h" - -// -// EyedropperTool class. -// -/// Constructor -EyedropperTool::EyedropperTool() : - Tool(ID_EYEDROPPER_TOOL, IDC_EYEDROPPER) -{ -} - -/// Destructor -EyedropperTool::~EyedropperTool() -{ -} - - -/// Shows the terrain materials options panel. -void EyedropperTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_TERRAIN_MATERIAL); - TerrainMaterial::setToolOptions(true); - DrawObject::setDoBrushFeedback(false); -} - -/// Perform the tool behavior on mouse down. -/** Finds the current texture class, and tells the terrain material panel to use it as fg. */ -void EyedropperTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - CPoint ndx; - if (!pDoc->getCellIndexFromCoord(cpt, &ndx)) - return; - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - Int texClass = pMap->getTextureClass(ndx.x, ndx.y, true); - TerrainMaterial::setFgTexClass(texClass); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherOptions.cpp deleted file mode 100644 index 08755866b46..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherOptions.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// brushoptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "FeatherOptions.h" -#include "WorldBuilderView.h" -#include "FeatherTool.h" - -FeatherOptions *FeatherOptions::m_staticThis = nullptr; -Int FeatherOptions::m_currentFeather = 0; -Int FeatherOptions::m_currentRate = 3; -Int FeatherOptions::m_currentRadius = 1; -///////////////////////////////////////////////////////////////////////////// -/// FeatherOptions dialog trivial constructor - Create does the real work. - - -FeatherOptions::FeatherOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(FeatherOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void FeatherOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(FeatherOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -/// Sets the feather value in the dialog. -/** Update the value in the edit control and the slider. */ -void FeatherOptions::setFeather(Int feather) -{ - CString buf; - buf.Format("%d", feather); - m_currentFeather = feather; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - - -/// Sets the rate value in the dialog. -/** Update the value in the edit control and the slider. */ -void FeatherOptions::setRate(Int rate) -{ - CString buf; - buf.Format("%d", rate); - m_currentRate = rate; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_RATE_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - - -/// Sets the radius value in the dialog. -/** Update the value in the edit control and the slider. */ -void FeatherOptions::setRadius(Int radius) -{ - CString buf; - buf.Format("%d", radius); - m_currentRadius = radius; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_RADIUS_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - - - -///////////////////////////////////////////////////////////////////////////// -// FeatherOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL FeatherOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - m_featherPopup.SetupPopSliderButton(this, IDC_SIZE_POPUP, this); - m_radiusPopup.SetupPopSliderButton(this, IDC_RADIUS_POPUP, this); - m_ratePopup.SetupPopSliderButton(this, IDC_RATE_POPUP, this); - - - m_staticThis = this; - m_updating = false; - setFeather(m_currentFeather); - setRate(m_currentRate); - setRadius(m_currentRadius); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void FeatherOptions::OnChangeSizeEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int width; - m_updating = true; - if (1==sscanf(buffer, "%d", &width)) { - m_currentFeather = width; - FeatherTool::setFeather(m_currentFeather); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - - -void FeatherOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_SIZE_POPUP: - *pMin = MIN_FEATHER_SIZE; - *pMax = MAX_FEATHER_SIZE; - *pInitial = m_currentFeather; - *pLineSize = 1; - break; - - case IDC_RADIUS_POPUP: - *pMin = MIN_RADIUS; - *pMax = MAX_RADIUS; - *pInitial = m_currentRadius; - *pLineSize = 1; - break; - - case IDC_RATE_POPUP: - *pMin = MIN_RATE; - *pMax = MAX_RATE; - *pInitial = m_currentRate; - *pLineSize = 1; - break; - - - default: - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void FeatherOptions::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - switch (sliderID) { - - case IDC_SIZE_POPUP: - m_currentFeather = theVal; - str.Format("%d",m_currentFeather); - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - FeatherTool::setFeather(m_currentFeather); - break; - - case IDC_RADIUS_POPUP: - m_currentRadius = theVal; - str.Format("%d",m_currentRadius); - pEdit = m_staticThis->GetDlgItem(IDC_RADIUS_EDIT); - if (pEdit) pEdit->SetWindowText(str); - FeatherTool::setRadius(m_currentRadius); - break; - - case IDC_RATE_POPUP: - m_currentRate = theVal; - str.Format("%d",m_currentRate); - pEdit = m_staticThis->GetDlgItem(IDC_RATE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - FeatherTool::setRate(m_currentRate); - break; - - default: - break; - } -} - -void FeatherOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - case IDC_RADIUS_POPUP: - case IDC_RATE_POPUP: - break; - - default: - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - - -BEGIN_MESSAGE_MAP(FeatherOptions, COptionsPanel) - //{{AFX_MSG_MAP(FeatherOptions) - ON_EN_CHANGE(IDC_SIZE_EDIT, OnChangeSizeEdit) - ON_WM_HSCROLL() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherTool.cpp deleted file mode 100644 index b4cfeb0b5ce..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/FeatherTool.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FeatherTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - - -#include "StdAfx.h" -#include "resource.h" - -#include "FeatherTool.h" -#include "FeatherOptions.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -// -// FeatherTool class. -Int FeatherTool::m_feather = 0; -Int FeatherTool::m_rate = 0; -Int FeatherTool::m_radius = 0; - -// -/// Constructor -FeatherTool::FeatherTool() : - Tool(ID_FEATHERTOOL, IDC_BRUSH_CROSS) -{ - m_htMapEditCopy = nullptr; - m_htMapFeatherCopy = nullptr; - m_htMapRateCopy = nullptr; -} - -/// Destructor -FeatherTool::~FeatherTool() -{ - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapFeatherCopy); - REF_PTR_RELEASE(m_htMapRateCopy); -} - - - -/// Shows the brush options panel. -void FeatherTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_FEATHER_OPTIONS); - DrawObject::setDoBrushFeedback(true); - DrawObject::setBrushFeedbackParms(false, m_feather, 0); -} - -/// Set the brush feather and notify the height options panel of the change. -void FeatherTool::setFeather(Int feather) -{ - if (m_feather != feather) { - m_feather = feather; - // notify feather palette options panel - FeatherOptions::setFeather(m_feather); - DrawObject::setBrushFeedbackParms(false, m_feather, 0); - } -}; - -/// Set the brush feather and notify the height options panel of the change. -void FeatherTool::setRate(Int rate) -{ - if (m_rate != rate) { - m_rate = rate; - // notify feather palette options panel - FeatherOptions::setRate(rate); - } -}; - -/// Set the brush feather and notify the height options panel of the change. -void FeatherTool::setRadius(Int radius) -{ - if (m_radius != radius) { - m_radius = radius; - // notify feather palette options panel - FeatherOptions::setRadius(radius); - } -}; - -/// Start tool. -/** Setup the tool to start brushing - make a copy of the height map -to edit, another copy because we need it :), and call mouseMovedDown. */ -void FeatherTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - // just in case, release it. - REF_PTR_RELEASE(m_htMapEditCopy); - m_htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - m_htMapFeatherCopy = pDoc->GetHeightMap()->duplicate(); - m_htMapRateCopy = pDoc->GetHeightMap()->duplicate(); - Int size = m_htMapRateCopy->getXExtent() * m_htMapRateCopy->getYExtent(); - UnsignedByte *pData = m_htMapRateCopy->getDataPtr(); - Int i; - for (i=0; iAddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapFeatherCopy); - REF_PTR_RELEASE(m_htMapRateCopy); -} - -/// Execute the tool. -/** Smooth the height map at the current point. */ -void FeatherTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - DrawObject::setFeedbackPos(cpt); - if (m != TRACK_L) return; - - int brushWidth = m_feather; - - CPoint ndx; - getCenterIndex(&cpt, m_feather, &ndx, pDoc); - - //if (m_prevXIndex == ndx.x && m_prevYIndex == ndx.y) return; - - m_prevXIndex = ndx.x; - m_prevYIndex = ndx.y; - - int sub = brushWidth/2; - int add = brushWidth-sub; - - // round brush - Int i, j; - Bool redoRate = false; - - for (i= ndx.x-sub; i< ndx.x+add; i++) { - if (i<0 || i>=m_htMapEditCopy->getXExtent()) { - continue; - } - for (j=ndx.y-sub; j=m_htMapEditCopy->getYExtent()) { - continue; - } - Real blendFactor; - blendFactor = calcRoundBlendFactor(ndx, i, j, m_feather, 0); - // m_htMapEditCopy is the output. - // m_htMapFeatherCopy is the original input. - // m_htMapRateCopy is how much we use of the feathered data. - if (blendFactor > 0.0f) { - Int rate = m_htMapRateCopy->getHeight(i, j); - rate += blendFactor * m_rate*5; - if (rate>255) { - rate = 255; - redoRate = true; - } - m_htMapRateCopy->setHeight(i,j,rate); - Int total=0; - Real numSamples=0; - Int ii, jj; - Int radius = m_radius; - if (radius<1) radius=1; - if (radius>FeatherOptions::MAX_RADIUS) radius = FeatherOptions::MAX_RADIUS; - for (ii = i-radius; ii < i+radius+1; ii++) { - for (jj = j-radius; jjradius) { - factor = 0; - } else { - factor = 1.0f - (dist-1)/radius; - } - } - int iNdx = ii; - if (iNdx<0) iNdx = 1; - if (iNdx >=m_htMapEditCopy->getXExtent()) { - iNdx = m_htMapEditCopy->getXExtent()-1; - } - int jNdx = jj; - if (jNdx<0) jNdx = 1; - if (jNdx >=m_htMapEditCopy->getYExtent()) { - jNdx = m_htMapEditCopy->getYExtent()-1; - } - total += m_htMapFeatherCopy->getHeight(iNdx, jNdx); - numSamples+=1; - } - } - total = floor((total/numSamples)); - UnsignedByte origHeight = m_htMapFeatherCopy->getHeight(i, j); - float rateF = rate/255.0; - total = floor(origHeight*(1.0f-rateF) + total*rateF + 0.5f); - m_htMapEditCopy->setHeight(i, j, total); - pDoc->invalCell(i, j); - } - } - } - - IRegion2D partialRange; - partialRange.lo.x = ndx.x - brushWidth; - partialRange.hi.x = ndx.x + brushWidth; - partialRange.lo.y = ndx.y - brushWidth; - partialRange.hi.y = ndx.y + brushWidth; - pDoc->updateHeightMap(m_htMapEditCopy, true, partialRange); - if (redoRate) { - Int size = m_htMapRateCopy->getXExtent() * m_htMapRateCopy->getYExtent(); - UnsignedByte *pData = m_htMapRateCopy->getDataPtr(); - UnsignedByte *pFeather = m_htMapFeatherCopy->getDataPtr(); - UnsignedByte *pEdit = m_htMapEditCopy->getDataPtr(); - Int i; - for (i=0; i. -*/ - -// FenceOptions.cpp : implementation file -// - -/** The fence options is essentially a front for the object options panel. -The fence options panel has a subset of the objects available, and when one is -selected, makes the current object in the object options panel match this object. -Then the new object is created by the object options panel, so team parenting and -so forth is all handled in the object options panel. jba. */ - -#define DEFINE_EDITOR_SORTING_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "FenceOptions.h" -#include "ObjectOptions.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" -#include "GameLogic/SidesList.h" -#include "GameClient/Color.h" - -#include - -FenceOptions *FenceOptions::m_staticThis = nullptr; -Bool FenceOptions::m_updating = false; -Int FenceOptions::m_currentObjectIndex=-1; -Real FenceOptions::m_fenceSpacing=1; -Real FenceOptions::m_fenceOffset=0; - - -///////////////////////////////////////////////////////////////////////////// -// FenceOptions dialog - - -FenceOptions::FenceOptions(CWnd* pParent /*=nullptr*/) -{ - m_objectsList = nullptr; - m_customSpacing = false; - //{{AFX_DATA_INIT(FenceOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -FenceOptions::~FenceOptions() -{ - deleteInstance(m_objectsList); - m_objectsList = nullptr; -} - - -void FenceOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(FenceOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(FenceOptions, COptionsPanel) - //{{AFX_MSG_MAP(FenceOptions) - ON_EN_CHANGE(IDC_FENCE_SPACING_EDIT, OnChangeFenceSpacingEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// FenceOptions data access method. - -/*static*/ void FenceOptions::update() -{ - if (m_staticThis) { - m_staticThis->updateObjectOptions(); - } -} - -void FenceOptions::updateObjectOptions() -{ - if (m_currentObjectIndex >= 0) { - MapObject *pObj = m_objectsList; - int count = 0; - while (pObj) { - if (count == m_currentObjectIndex) { - ObjectOptions::selectObject(pObj); - const ThingTemplate *t = pObj->getThingTemplate(); - if (t && !m_customSpacing) { - if ( !m_customSpacing) { - m_fenceSpacing = t->getFenceWidth(); - } - m_fenceOffset = t->getFenceXOffset(); - } - break; - } - count++; - pObj = pObj->getNext(); - } - } - CWnd *pWnd = GetDlgItem(IDC_FENCE_SPACING_EDIT); - if (pWnd) { - CString s; - s.Format("%f",m_fenceSpacing); - pWnd->SetWindowText(s); - } -} - - -///////////////////////////////////////////////////////////////////////////// -// FenceOptions message handlers - -/// Setup the controls in the dialog. -BOOL FenceOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - -// CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - - // add entries from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - Coord3D loc = { 0, 0, 0 }; - MapObject *pMap; - - // Only add fence type objects. - if (tTemplate->getFenceWidth() == 0) continue; - - // create new map object - pMap = newInstance( MapObject)( loc, tTemplate->getName(), 0.0f, 0, nullptr, tTemplate ); - pMap->setNextMap( m_objectsList ); - m_objectsList = pMap; - - // get display color for the editor - Color cc = tTemplate->getDisplayColor(); - pMap->setColor(cc); - - } - - - CWnd *pWnd = GetDlgItem(IDC_OBJECT_HEIGHT_EDIT); - if (pWnd) { - CString s; - s.Format("%d",MAGIC_GROUND_Z); - pWnd->SetWindowText(s); - } - - pWnd = GetDlgItem(IDC_TERRAIN_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_objectTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_objectTreeView.ShowWindow(SW_SHOW); - - MapObject *pMap = m_objectsList; - Int index = 0; - while (pMap) { - - addObject( pMap, pMap->getName().str(), "", index, TVI_ROOT); - index++; - pMap = pMap->getNext(); - } - - - m_staticThis = this; - m_updating = false; - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM FenceOptions::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = m_objectTreeView.InsertItem(&ins); - return(child); -} - -//------------------------------------------------------------------------------------------------- -/** Add the object hierarchy paths to the tree view. */ -//------------------------------------------------------------------------------------------------- -void FenceOptions::addObject( MapObject *mapObject, const char *pPath, const char *name, - Int terrainNdx, HTREEITEM parent ) -{ - const char *leafName = nullptr; - - // sanity - if( mapObject == nullptr ) - return; - - // - // if we have an thing template in mapObject, we've read it from the new INI database, - // we will sort those items into the tree based on properties of the template that - // make it easier for us to browse when building levels - // - // Feel free to reorganize how this tree is constructed from the template - // data at will, whatever makes it easier for design - // - const ThingTemplate *thingTemplate = mapObject->getThingTemplate(); - if( thingTemplate ) - { - - // first check for test sorted objects - if( thingTemplate->getEditorSorting() == ES_TEST ) - parent = findOrAdd( parent, "TEST" ); - - // first sort by side, either create or find the tree item with matching side name - AsciiString side = thingTemplate->getDefaultOwningSide(); - DEBUG_ASSERTCRASH( !side.isEmpty(), ("null default side in template") ); - parent = findOrAdd( parent, side.str()); - - // next tier uses the editor sorting that design can specify in the INI - EditorSortingType i = ES_FIRST; - for( ; - i < ES_NUM_SORTING_TYPES; - i = (EditorSortingType)(i + 1) ) - { - - if( thingTemplate->getEditorSorting() == i ) - { - - parent = findOrAdd( parent, EditorSortingNames[ i ] ); - break; // exit for - - } - - } - - if( i == ES_NUM_SORTING_TYPES ) - parent = findOrAdd( parent, "UNSORTED" ); - - // the leaf name is the name of the template - leafName = thingTemplate->getName().str(); - - } - - // add to the tree view - if( leafName ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = (char*)leafName; - ins.item.cchTextMax = strlen(leafName)+2; - m_objectTreeView.InsertItem(&ins); - - } - -} - -Bool FenceOptions::hasSelectedObject() -{ - // If we have no selected object, return false. - if (m_currentObjectIndex==-1) return false; - // If the objects panel has no selected object, return false. - if (ObjectOptions::getCurGdfName() == AsciiString::TheEmptyString) return false; - // If our selection is valid, return true. - if (m_staticThis && m_currentObjectIndex >= 0) { - MapObject *pObj = m_staticThis->m_objectsList; - int count = 0; - while (pObj) { - if (count == m_currentObjectIndex) { - return(true); - } - count++; - pObj = pObj->getNext(); - } - } - return false; -} - -/// Set the selected object in the tree view. -Bool FenceOptions::setObjectTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[NAME_MAX_LEN]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - if (item.lParam == selection) { - m_objectTreeView.SelectItem(child); - return(true); - } - if (setObjectTreeViewSelection(child, selection)) - { - updateObjectOptions(); - return(true); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - return(false); -} - - -BOOL FenceOptions::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_objectTreeView.m_hWnd) { - - if (pHdr->hdr.code == TVN_ITEMEXPANDED) { - if (pHdr->action == TVE_COLLAPSE) { - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_STATE; - item.hItem = pHdr->itemOld.hItem; - m_objectTreeView.GetItem(&item); - item.state &= (~TVIS_EXPANDEDONCE); - item.mask = TVIF_STATE; - m_objectTreeView.SetItem(&item); - } - } - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[NAME_MAX_LEN]; - HTREEITEM hItem = m_objectTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - if (item.lParam >= 0) { - m_currentObjectIndex = item.lParam; - m_customSpacing = false; - } else if (m_objectTreeView.ItemHasChildren(item.hItem)) { - m_currentObjectIndex = -1; - } - updateObjectOptions(); - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - - - - -void FenceOptions::OnChangeFenceSpacingEdit() -{ - CWnd *pWnd = m_staticThis->GetDlgItem(IDC_FENCE_SPACING_EDIT); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - m_fenceSpacing = atof(val); - m_customSpacing = true; - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/FenceTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/FenceTool.cpp deleted file mode 100644 index 0a9a354aa2a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/FenceTool.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FenceTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "FenceTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "wbview3d.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "Common/WellKnownKeys.h" -// -// FenceTool class. -// - enum {MAX_OBJECTS = 200}; -/// Constructor -FenceTool::FenceTool() : - Tool(ID_FENCE_TOOL, IDC_FENCE), - m_mapObjectList(nullptr), - m_objectCount(1) -{ - m_curObjectWidth = 27.35f; - m_curObjectOffset = 0; -} - -/// Destructor -FenceTool::~FenceTool() -{ - deleteInstance(m_mapObjectList); - m_mapObjectList = nullptr; -} - -void FenceTool::updateMapObjectList(Coord3D downPt, Coord3D curPt, WbView* pView, CWorldBuilderDoc *pDoc, Bool checkPlayers) -{ - Bool shiftKey = (0x8000 & ::GetAsyncKeyState(VK_SHIFT))!=0; - Real angle = ObjectTool::calcAngle(downPt, curPt, pView); - Coord3D delta; - Coord3D normalDelta; - delta.x = curPt.x-downPt.x; - delta.y = curPt.y-downPt.y; - delta.z = 0; - Real length = delta.length(); - Int newCount = floor(length/m_curObjectWidth); - if (newCount<1) newCount = 1; - if (newCount > MAX_OBJECTS) newCount = MAX_OBJECTS; - if (shiftKey) { - // stretch the fence spacing. Keep the same count. - delta.x /= (m_objectCount*m_curObjectWidth); - delta.y /= (m_objectCount*m_curObjectWidth); - } else { - // Use exactly the spacing. - m_objectCount = newCount; - delta.normalize(); - } - normalDelta = delta; - if (angle==0) { - normalDelta.x = 1; - normalDelta.y = 0; - } - normalDelta.normalize(); - - Int i; - if (m_mapObjectList == nullptr) return; - MapObject *pCurObj = m_mapObjectList; - for (i=1; igetNext() == nullptr) { - pCurObj->setNextMap(ObjectOptions::duplicateCurMapObjectForPlace(&downPt, angle, checkPlayers)); - } - pCurObj=pCurObj->getNext(); - if (pCurObj == nullptr) return; - } - WbView3d *p3View = pDoc->GetActive3DView(); - MapObject *pXtraObjects = pCurObj->getNext(); - pCurObj->setNextMap(nullptr); - if (pXtraObjects) { - p3View->removeFenceListObjects(pXtraObjects); - deleteInstance(pXtraObjects); - pXtraObjects = nullptr; - } - - pCurObj = m_mapObjectList; - for (i=0; isetAngle(angle); - pCurObj->setLocation(&curLoc); - pCurObj=pCurObj->getNext(); - } - - p3View->updateFenceListObjects(m_mapObjectList); - -} - - - -/// Turn off object tracking. -void FenceTool::deactivate() -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return; - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); -} -/// Shows the object options panel -void FenceTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_FENCE_OPTIONS); - DrawObject::setDoBrushFeedback(false); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return; - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); - FenceOptions::update(); -} - -/** Execute the tool on mouse down - Place an object. */ -void FenceTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - pView->snapPoint(&cpt); - m_downPt2d = viewPt; - m_downPt3d = cpt; - - deleteInstance(m_mapObjectList); - m_mapObjectList = nullptr; - - if (FenceOptions::hasSelectedObject()) { - FenceOptions::update(); - m_curObjectWidth = FenceOptions::getFenceSpacing(); - m_curObjectOffset = FenceOptions::getFenceOffset(); - m_mapObjectList = ObjectOptions::duplicateCurMapObjectForPlace(&m_downPt3d, 0, false); - m_objectCount = 1; - mouseMoved(m, viewPt, pView, pDoc); - } -} - -/** Tracking - show the object. */ -void FenceTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ -// Bool justAClick = true; - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); // Do constrain. - WbView3d *p3View = pDoc->GetActive3DView(); - Coord3D loc = cpt; - pView->snapPoint(&loc); - Real angle = 0 ; - if (m == TRACK_L) { // Mouse is down, so fence. - p3View->setObjTracking(nullptr, loc, angle, false); - updateMapObjectList(m_downPt3d,loc, pView, pDoc, false); - return; - } - MapObject *pCur = ObjectOptions::getObjectNamed(AsciiString(ObjectOptions::getCurObjectName())); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); - loc.z = ObjectOptions::getCurObjectHeight(); - if (pCur && FenceOptions::hasSelectedObject()) { - // Display the transparent version of this object. - m_curObjectOffset = FenceOptions::getFenceOffset(); - loc.x += m_curObjectOffset; - p3View->setObjTracking(pCur, loc, angle, true); - } else { - // Don't display anything. - p3View->setObjTracking(nullptr, loc, angle, false); - } -} - -/** Execute the tool on mouse up - Place an object. */ -void FenceTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); // Do constrain. - Coord3D loc = cpt; - pView->snapPoint(&loc); - updateMapObjectList(m_downPt3d, loc, pView, pDoc, true); - WbView3d *p3View = pDoc->GetActive3DView(); - if (m_mapObjectList) { - p3View->removeFenceListObjects(m_mapObjectList); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, m_mapObjectList); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_mapObjectList = nullptr; // undoable owns it now. - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/FloodFillTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/FloodFillTool.cpp deleted file mode 100644 index 97b4084cdd3..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/FloodFillTool.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FloodFillTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - - -#include "StdAfx.h" -#include "resource.h" - -#include "FloodFillTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "TerrainMaterial.h" -// -// FloodFillTool class. -// - -Bool FloodFillTool::m_adjustCliffTextures = false; - -/// Constructor -FloodFillTool::FloodFillTool() : - Tool(ID_TILE_FLOOD_FILL, IDC_FLOOD_FILL), - m_cliffCursor(nullptr) -{ -} - -/// Destructor -FloodFillTool::~FloodFillTool() -{ - if (m_cliffCursor) { - ::DestroyCursor(m_cliffCursor); - } -} - - -/// Shows the terrain materials options panel. -void FloodFillTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_TERRAIN_MATERIAL); - TerrainMaterial::setToolOptions(true); - DrawObject::setDoBrushFeedback(false); - m_adjustCliffTextures = false; -} - -/** Set the cursor. */ -void FloodFillTool::setCursor() -{ - if (m_adjustCliffTextures) { - if (m_cliffCursor == nullptr) { - m_cliffCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_CLIFF)); - } - ::SetCursor(m_cliffCursor); - } else { - Tool::setCursor(); - } -} - - - -/// Left click code. Sets m_textureClassToDraw and calls eitherMouseDown() -/// Perform the tool behavior on mouse down. -/** Creates a copy of the height map, flood fills it at pt with m_textureClassToDraw which -has been set by the calling routine. Then builds -the command, and passes it to the doc. */ -void FloodFillTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - CPoint ndx; - if (!pDoc->getCellIndexFromCoord(cpt, &ndx)) { - return; - } - - if (m == TRACK_L) - m_textureClassToDraw = TerrainMaterial::getFgTexClass(); - else - m_textureClassToDraw = TerrainMaterial::getBgTexClass(); - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - WorldHeightMapEdit *htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - Bool didIt = false; - Bool shiftKey = (0x8000 & ::GetAsyncKeyState(VK_SHIFT))!=0; - if (m_adjustCliffTextures) { - didIt = htMapEditCopy->doCliffAdjustment(ndx.x, ndx.y); - } else { - didIt = htMapEditCopy->floodFill(ndx.x, ndx.y, m_textureClassToDraw, shiftKey); - } - if (didIt) { - htMapEditCopy->optimizeTiles(); // force to optimize tileset - IRegion2D partialRange = {0,0,0,0}; - pDoc->updateHeightMap(htMapEditCopy, false, partialRange); - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - REF_PTR_RELEASE(htMapEditCopy); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp deleted file mode 100644 index 02b654bcf9d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/GlobalLightOptions.cpp +++ /dev/null @@ -1,966 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// GlobalLightOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "GlobalLightOptions.h" -#include "WorldBuilderDoc.h" -#include "Common/GlobalData.h" -#include "wbview3d.h" - -///////////////////////////////////////////////////////////////////////////// -/// GlobalLightOptions dialog trivial constructor - Create does the real work. - - -GlobalLightOptions::GlobalLightOptions(CWnd* pParent /*=nullptr*/) - : CDialog(GlobalLightOptions::IDD, pParent) -{ - //{{AFX_DATA_INIT(GlobalLightOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void GlobalLightOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(GlobalLightOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -static void calcNewLight(Int lr, Int fb, Vector3 *newLight) -{ - newLight->Set(0,0,-1); - Real yAngle = PI*(lr-90)/180; - Real xAngle = PI*(fb-90)/180; - Real zAngle = xAngle * WWMath::Sin(yAngle); - xAngle *= WWMath::Cos(yAngle); - newLight->Rotate_Y(yAngle); - newLight->Rotate_X(xAngle); - newLight->Rotate_Z(zAngle); -} - -void GlobalLightOptions::updateEditFields() -{ - m_updating = true; - CString str; - CWnd *pEdit; - - str.Format("%d",m_angleAzimuth[K_SUN]); - pEdit = GetDlgItem(IDC_FB_EDIT); - if (pEdit) pEdit->SetWindowText(str); - str.Format("%d",m_angleElevation[K_SUN]); - pEdit = GetDlgItem(IDC_LR_EDIT); - if (pEdit) pEdit->SetWindowText(str); - - str.Format("%d",m_angleAzimuth[K_ACCENT1]); - pEdit = GetDlgItem(IDC_FB_EDIT1); - if (pEdit) pEdit->SetWindowText(str); - str.Format("%d",m_angleElevation[K_ACCENT1]); - pEdit = GetDlgItem(IDC_LR_EDIT1); - if (pEdit) pEdit->SetWindowText(str); - - str.Format("%d",m_angleAzimuth[K_ACCENT2]); - pEdit = GetDlgItem(IDC_FB_EDIT2); - if (pEdit) pEdit->SetWindowText(str); - str.Format("%d",m_angleElevation[K_ACCENT2]); - pEdit = GetDlgItem(IDC_LR_EDIT2); - if (pEdit) pEdit->SetWindowText(str); - - m_updating = false; -} - -void GlobalLightOptions::showLightFeedback(Int lightIndex) -{ - Vector3 light(0,0,0); - light.X = sin(PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI)*cos(m_angleAzimuth[lightIndex]/180.0f*PI);// -WWMath::Sin(PI*(m_angleLR[lightIndex]-90)/180); - light.Y = sin(PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI)*sin(m_angleAzimuth[lightIndex]/180.0f*PI);//-WWMath::Sin(PI*(m_angleFB[lightIndex]-90)/180); - light.Z = cos (PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI); - - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - Coord3D lightRay; - lightRay.x=light.X;lightRay.y=light.Y;lightRay.z=light.Z; - pView->doLightFeedback(true,lightRay,lightIndex); - } -} - -void GlobalLightOptions::applyAngle(Int lightIndex) -{ - Vector3 light(0,0,0); - light.X = sin(PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI)*cos(m_angleAzimuth[lightIndex]/180.0f*PI);// -WWMath::Sin(PI*(m_angleLR[lightIndex]-90)/180); - light.Y = sin(PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI)*sin(m_angleAzimuth[lightIndex]/180.0f*PI);//-WWMath::Sin(PI*(m_angleFB[lightIndex]-90)/180); - light.Z = cos (PI/2.0f+m_angleElevation[lightIndex]/180.0f*PI); - - CString str; - str.Format("XYZ: %.2f, %.2f, %.2f", light.X, light.Y, light.Z); - CWnd *pWnd = this->GetDlgItem(IDC_XYZ_STATIC); - if (pWnd) { - pWnd->SetWindowText(str); - } - GlobalData::TerrainLighting tl; - if (m_lighting == K_OBJECTS || m_lighting == K_BOTH) { - tl = TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } else { - tl = TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } - tl.lightPos.x = light.X; - tl.lightPos.y = light.Y; - tl.lightPos.z = light.Z; - - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - pView->setLighting(&tl, m_lighting, lightIndex); - Coord3D lightRay; - lightRay.x=light.X;lightRay.y=light.Y;lightRay.z=light.Z; - pView->doLightFeedback(true,lightRay,lightIndex); - } -} - -static void SpitLights() -{ -#ifdef DEBUG_LOGGING - DEBUG_LOG(("GlobalLighting\n")); - Int redA, greenA, blueA; - Int redD, greenD, blueD; - Real x, y, z; - const char* times[4]; - times[0] = "Morning"; - times[1] = "Afternoon"; - times[2] = "Evening"; - times[3] = "Night"; - const char* lights[3]; - lights[0] = ""; - lights[1] = "2"; - lights[2] = "3"; - - Int time=0; - for (; time<4; time++) { - for (Int light=0; light<3; light++) { - redA = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].ambient.red*255; - greenA = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].ambient.green*255; - blueA = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].ambient.blue*255; - - redD = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].diffuse.red*255; - greenD = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].diffuse.green*255; - blueD = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].diffuse.blue*255; - - x = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].lightPos.x; - y = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].lightPos.y; - z = TheGlobalData->m_terrainLighting[time+TIME_OF_DAY_FIRST][light].lightPos.z; - - DEBUG_LOG(("TerrainLighting%sAmbient%s = R:%d G:%d B:%d", times[time], lights[light], redA, greenA, blueA)); - DEBUG_LOG(("TerrainLighting%sDiffuse%s = R:%d G:%d B:%d", times[time], lights[light], redD, greenD, blueD)); - DEBUG_LOG(("TerrainLighting%sLightPos%s = X:%0.2f Y:%0.2f Z:%0.2f", times[time], lights[light], x, y, z)); - - redA = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].ambient.red*255; - greenA = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].ambient.green*255; - blueA = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].ambient.blue*255; - - redD = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].diffuse.red*255; - greenD = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].diffuse.green*255; - blueD = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].diffuse.blue*255; - - x = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].lightPos.x; - y = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].lightPos.y; - z = TheGlobalData->m_terrainObjectsLighting[time+TIME_OF_DAY_FIRST][light].lightPos.z; - - DEBUG_LOG(("TerrainObjectsLighting%sAmbient%s = R:%d G:%d B:%d", times[time], lights[light], redA, greenA, blueA)); - DEBUG_LOG(("TerrainObjectsLighting%sDiffuse%s = R:%d G:%d B:%d", times[time], lights[light], redD, greenD, blueD)); - DEBUG_LOG(("TerrainObjectsLighting%sLightPos%s = X:%0.2f Y:%0.2f Z:%0.2f", times[time], lights[light], x, y, z)); - - DEBUG_LOG_RAW(("\n")); - } - DEBUG_LOG_RAW(("\n")); - } - - DEBUG_LOG(("GlobalLighting Code\n")); - for (time=0; time<4; time++) { - for (Int light=0; light<3; light++) { - Int theTime = time+TIME_OF_DAY_FIRST; - GlobalData::TerrainLighting tl = TheGlobalData->m_terrainLighting[theTime][light]; - - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].ambient.red = %0.4ff;", theTime, light, tl.ambient.red)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].ambient.green = %0.4ff;", theTime, light, tl.ambient.green)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].ambient.blue = %0.4ff;", theTime, light, tl.ambient.blue)); - - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].diffuse.red = %0.4ff;", theTime, light, tl.diffuse.red)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].diffuse.green = %0.4ff;", theTime, light, tl.diffuse.green)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].diffuse.blue = %0.4ff;", theTime, light, tl.diffuse.blue)); - - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].lightPos.x = %0.4ff;", theTime, light, tl.lightPos.x)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].lightPos.y = %0.4ff;", theTime, light, tl.lightPos.y)); - DEBUG_LOG(("TheGlobalData->m_terrainLighting[%d][%d].lightPos.z = %0.4ff;", theTime, light, tl.lightPos.z)); - - tl = TheGlobalData->m_terrainObjectsLighting[theTime][light]; - - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].ambient.red = %0.4ff;", theTime, light, tl.ambient.red)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].ambient.green = %0.4ff;", theTime, light, tl.ambient.green)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].ambient.blue = %0.4ff;", theTime, light, tl.ambient.blue)); - - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].diffuse.red = %0.4ff;", theTime, light, tl.diffuse.red)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].diffuse.green = %0.4ff;", theTime, light, tl.diffuse.green)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].diffuse.blue = %0.4ff;", theTime, light, tl.diffuse.blue)); - - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].lightPos.x = %0.4ff;", theTime, light, tl.lightPos.x)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].lightPos.y = %0.4ff;", theTime, light, tl.lightPos.y)); - DEBUG_LOG(("TheGlobalData->m_terrainObjectsLighting[%d][%d].lightPos.z = %0.4ff;", theTime, light, tl.lightPos.z)); - - DEBUG_LOG_RAW(("\n")); - } - DEBUG_LOG_RAW(("\n")); - } -#endif -} - -void GlobalLightOptions::OnResetLights() -{ - TheWritableGlobalData->m_terrainLighting[1][0].ambient.red = 0.50f; - TheWritableGlobalData->m_terrainLighting[1][0].ambient.green = 0.39f; - TheWritableGlobalData->m_terrainLighting[1][0].ambient.blue = 0.30f; - TheWritableGlobalData->m_terrainLighting[1][0].diffuse.red = 0.90f; - TheWritableGlobalData->m_terrainLighting[1][0].diffuse.green = 0.71f; - TheWritableGlobalData->m_terrainLighting[1][0].diffuse.blue = 0.60f; - TheWritableGlobalData->m_terrainLighting[1][0].lightPos.x = -0.96f; - TheWritableGlobalData->m_terrainLighting[1][0].lightPos.y = 0.05f; - TheWritableGlobalData->m_terrainLighting[1][0].lightPos.z = -0.29f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].ambient.red = 0.50f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].ambient.green = 0.40f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].ambient.blue = 0.30f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].diffuse.red = 0.90f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].diffuse.green = 0.70f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].diffuse.blue = 0.60f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].lightPos.x = -0.96f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].lightPos.y = 0.05f; - TheWritableGlobalData->m_terrainObjectsLighting[1][0].lightPos.z = -0.29f; - - TheWritableGlobalData->m_terrainLighting[1][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][1].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][1].lightPos.z = -1.00f; - - TheWritableGlobalData->m_terrainLighting[1][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[1][2].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[1][2].lightPos.z = -1.00f; - - - TheWritableGlobalData->m_terrainLighting[2][0].ambient.red = 0.2196f; - TheWritableGlobalData->m_terrainLighting[2][0].ambient.green = 0.2039f; - TheWritableGlobalData->m_terrainLighting[2][0].ambient.blue = 0.1725f; - TheWritableGlobalData->m_terrainLighting[2][0].diffuse.red = 1.0000f; - TheWritableGlobalData->m_terrainLighting[2][0].diffuse.green = 1.0000f; - TheWritableGlobalData->m_terrainLighting[2][0].diffuse.blue = 1.0000f; - TheWritableGlobalData->m_terrainLighting[2][0].lightPos.x = -0.8100f; - TheWritableGlobalData->m_terrainLighting[2][0].lightPos.y = 0.3800f; - TheWritableGlobalData->m_terrainLighting[2][0].lightPos.z = -0.4500f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].ambient.red = 0.2196f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].ambient.green = 0.2039f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].ambient.blue = 0.1725f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].diffuse.red = 1.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].diffuse.green = 1.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].diffuse.blue = 1.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].lightPos.x = -0.8100f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].lightPos.y = 0.3800f; - TheWritableGlobalData->m_terrainObjectsLighting[2][0].lightPos.z = -0.4500f; - - TheWritableGlobalData->m_terrainLighting[2][1].ambient.red = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][1].ambient.green = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][1].ambient.blue = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][1].diffuse.red = 0.2353f; - TheWritableGlobalData->m_terrainLighting[2][1].diffuse.green = 0.2353f; - TheWritableGlobalData->m_terrainLighting[2][1].diffuse.blue = 0.4706f; - TheWritableGlobalData->m_terrainLighting[2][1].lightPos.x = 0.7900f; - TheWritableGlobalData->m_terrainLighting[2][1].lightPos.y = 0.6200f; - TheWritableGlobalData->m_terrainLighting[2][1].lightPos.z = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].ambient.red = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].ambient.green = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].ambient.blue = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].diffuse.red = 0.2353f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].diffuse.green = 0.2353f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].diffuse.blue = 0.3137f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].lightPos.x = 0.7900f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].lightPos.y = 0.6200f; - TheWritableGlobalData->m_terrainObjectsLighting[2][1].lightPos.z = 0.0000f; - - TheWritableGlobalData->m_terrainLighting[2][2].ambient.red = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][2].ambient.green = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][2].ambient.blue = 0.0000f; - TheWritableGlobalData->m_terrainLighting[2][2].diffuse.red = 0.1176f; - TheWritableGlobalData->m_terrainLighting[2][2].diffuse.green = 0.1176f; - TheWritableGlobalData->m_terrainLighting[2][2].diffuse.blue = 0.0784f; - TheWritableGlobalData->m_terrainLighting[2][2].lightPos.x = 0.8100f; - TheWritableGlobalData->m_terrainLighting[2][2].lightPos.y = -0.4800f; - TheWritableGlobalData->m_terrainLighting[2][2].lightPos.z = -0.3400f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].ambient.red = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].ambient.green = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].ambient.blue = 0.0000f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].diffuse.red = 0.1176f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].diffuse.green = 0.1176f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].diffuse.blue = 0.0784f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].lightPos.x = 0.8100f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].lightPos.y = -0.4800f; - TheWritableGlobalData->m_terrainObjectsLighting[2][2].lightPos.z = -0.3400f; - - - TheWritableGlobalData->m_terrainLighting[3][0].ambient.red = 0.25f; - TheWritableGlobalData->m_terrainLighting[3][0].ambient.green = 0.23f; - TheWritableGlobalData->m_terrainLighting[3][0].ambient.blue = 0.20f; - TheWritableGlobalData->m_terrainLighting[3][0].diffuse.red = 0.60f; - TheWritableGlobalData->m_terrainLighting[3][0].diffuse.green = 0.50f; - TheWritableGlobalData->m_terrainLighting[3][0].diffuse.blue = 0.40f; - TheWritableGlobalData->m_terrainLighting[3][0].lightPos.x = -1.00f; - TheWritableGlobalData->m_terrainLighting[3][0].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][0].lightPos.z = -0.20f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].ambient.red = 0.25f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].ambient.green = 0.23f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].ambient.blue = 0.20f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].diffuse.red = 0.60f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].diffuse.green = 0.50f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].diffuse.blue = 0.40f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].lightPos.x = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][0].lightPos.z = -0.20f; - - TheWritableGlobalData->m_terrainLighting[3][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][1].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][1].lightPos.z = -1.00f; - - TheWritableGlobalData->m_terrainLighting[3][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[3][2].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[3][2].lightPos.z = -1.00f; - - - TheWritableGlobalData->m_terrainLighting[4][0].ambient.red = 0.10f; - TheWritableGlobalData->m_terrainLighting[4][0].ambient.green = 0.10f; - TheWritableGlobalData->m_terrainLighting[4][0].ambient.blue = 0.15f; - TheWritableGlobalData->m_terrainLighting[4][0].diffuse.red = 0.20f; - TheWritableGlobalData->m_terrainLighting[4][0].diffuse.green = 0.20f; - TheWritableGlobalData->m_terrainLighting[4][0].diffuse.blue = 0.30f; - TheWritableGlobalData->m_terrainLighting[4][0].lightPos.x = -1.00f; - TheWritableGlobalData->m_terrainLighting[4][0].lightPos.y = 1.00f; - TheWritableGlobalData->m_terrainLighting[4][0].lightPos.z = -2.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].ambient.red = 0.10f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].ambient.green = 0.10f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].ambient.blue = 0.15f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].diffuse.red = 0.20f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].diffuse.green = 0.20f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].diffuse.blue = 0.30f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].lightPos.x = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].lightPos.y = 1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][0].lightPos.z = -2.00f; - - TheWritableGlobalData->m_terrainLighting[4][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][1].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][1].lightPos.z = -1.00f; - - TheWritableGlobalData->m_terrainLighting[4][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainLighting[4][2].lightPos.z = -1.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].ambient.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].ambient.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].ambient.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].diffuse.red = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].diffuse.green = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].diffuse.blue = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].lightPos.x = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].lightPos.y = 0.00f; - TheWritableGlobalData->m_terrainObjectsLighting[4][2].lightPos.z = -1.00f; - - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - pView->setLighting(&TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][K_SUN], K_TERRAIN, K_SUN); - pView->setLighting(&TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][K_ACCENT1], K_TERRAIN, K_ACCENT1); - pView->setLighting(&TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][K_ACCENT2], K_TERRAIN, K_ACCENT2); - - pView->setLighting(&TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][K_SUN], K_OBJECTS, K_SUN); - pView->setLighting(&TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][K_ACCENT1], K_OBJECTS, K_ACCENT1); - pView->setLighting(&TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][K_ACCENT2], K_OBJECTS, K_ACCENT2); - } - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); -} - -///////////////////////////////////////////////////////////////////////////// -// GlobalLightOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL GlobalLightOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - kUIRedIDs[0] = IDC_RD_EDIT; - kUIRedIDs[1] = IDC_RD_EDIT1; - kUIRedIDs[2] = IDC_RD_EDIT2; - - kUIGreenIDs[0] = IDC_GD_EDIT; - kUIGreenIDs[1] = IDC_GD_EDIT1; - kUIGreenIDs[2] = IDC_GD_EDIT2; - - kUIBlueIDs[0] = IDC_BD_EDIT; - kUIBlueIDs[1] = IDC_BD_EDIT1; - kUIBlueIDs[2] = IDC_BD_EDIT2; - - m_frontBackPopup.SetupPopSliderButton(this, IDC_FB_POPUP, this); - m_leftRightPopup.SetupPopSliderButton(this, IDC_LR_POPUP, this); - - m_frontBackPopupAccent1.SetupPopSliderButton(this, IDC_FB_POPUP1, this); - m_leftRightPopupAccent1.SetupPopSliderButton(this, IDC_LR_POPUP1, this); - - m_frontBackPopupAccent2.SetupPopSliderButton(this, IDC_FB_POPUP2, this); - m_leftRightPopupAccent2.SetupPopSliderButton(this, IDC_LR_POPUP2, this); - - CButton *pButton = (CButton *)GetDlgItem(IDC_RADIO_EVERYTHING); - pButton->SetCheck(1); - m_lighting = K_BOTH; - - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); - - CRect rect; - CWnd *item = GetDlgItem(IDC_PSEd_Color1); - if (item) { - item->GetWindowRect(&rect); - ScreenToClient(&rect); - DWORD style = item->GetStyle(); - m_colorButton.Create("", style, rect, this, IDC_PSEd_Color1); - item->DestroyWindow(); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - - -/** Displays the current values in the fields. */ -void GlobalLightOptions::stuffValuesIntoFields(Int lightIndex) -{ - const GlobalData::TerrainLighting *tl; - if (m_lighting == K_OBJECTS || m_lighting == K_BOTH) { - tl = &TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } else { - tl = &TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } - Real azimuth = 90; - Real elevation = 90; - - Vector3 light(tl->lightPos.x, tl->lightPos.y, tl->lightPos.z); - light.Normalize(); - - - Real angleAzimuth = atan2(light.Y,light.X);//WWMath::Asin(light.Y); - azimuth = angleAzimuth*180.0f/PI;//90-(angleFB/PI)*180; - if (azimuth < 0) { - azimuth += 360; - } - Real angleElevation = acos(light.Z);//WWMath::Asin(light.X); - elevation = (angleElevation-PI/2.0f)*180.0f/PI;//90-(angleLR/PI)*180; - - m_angleElevation[lightIndex] = elevation; - m_angleAzimuth[lightIndex] = azimuth; - - updateEditFields(); - - m_updating = true; - CString str; - str.Format("XYZ: %.2f, %.2f, %.2f", light.X, light.Y, light.Z); - CWnd *pWnd = this->GetDlgItem(IDC_XYZ_STATIC); - if (pWnd && lightIndex==0) { - pWnd->SetWindowText(str); - } - - switch (lightIndex) - { - case K_SUN: - default: - PutInt(IDC_RA_EDIT, PercentToComponent(tl->ambient.red)); - PutInt(IDC_GA_EDIT, PercentToComponent(tl->ambient.green)); - PutInt(IDC_BA_EDIT, PercentToComponent(tl->ambient.blue)); - - PutInt(IDC_RD_EDIT, PercentToComponent(tl->diffuse.red)); - PutInt(IDC_GD_EDIT, PercentToComponent(tl->diffuse.green)); - PutInt(IDC_BD_EDIT, PercentToComponent(tl->diffuse.blue)); - m_colorButton.setColor(tl->ambient); - break; - - case K_ACCENT1: - PutInt(IDC_RD_EDIT1, PercentToComponent(tl->diffuse.red)); - PutInt(IDC_GD_EDIT1, PercentToComponent(tl->diffuse.green)); - PutInt(IDC_BD_EDIT1, PercentToComponent(tl->diffuse.blue)); - break; - - case K_ACCENT2: - PutInt(IDC_RD_EDIT2, PercentToComponent(tl->diffuse.red)); - PutInt(IDC_GD_EDIT2, PercentToComponent(tl->diffuse.green)); - PutInt(IDC_BD_EDIT2, PercentToComponent(tl->diffuse.blue)); - break; - } - - m_updating = false; - pWnd = GetDlgItem(IDC_TIME_OF_DAY_CAPTION); - if (pWnd) { - switch (TheGlobalData->m_timeOfDay) { - default: - case TIME_OF_DAY_MORNING: pWnd->SetWindowText("Time of day: Morning."); break; - case TIME_OF_DAY_AFTERNOON: pWnd->SetWindowText("Time of day: Afternoon."); break; - case TIME_OF_DAY_EVENING: pWnd->SetWindowText("Time of day: Evening."); break; - case TIME_OF_DAY_NIGHT: pWnd->SetWindowText("Time of day: Night."); break; - } - } - showLightFeedback(lightIndex); -} - - -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ - -BOOL GlobalLightOptions::GetInt(Int ctrlID, Int *rVal) -{ - CWnd *pEdit = GetDlgItem(ctrlID); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int val; - if (1==sscanf(buffer, "%d", &val)) { - *rVal = val; - return true; - } - } - return false; -} - -void GlobalLightOptions::PutInt(Int ctrlID, Int val) -{ - CString str; - CWnd *pEdit = GetDlgItem(ctrlID); - if (pEdit) { - str.Format("%d", val); - pEdit->SetWindowText(str); - } -} - -void GlobalLightOptions::OnChangeFrontBackEdit() -{ - if (m_updating) return; - GetInt(IDC_FB_EDIT, &m_angleAzimuth[K_SUN]); - GetInt(IDC_FB_EDIT1, &m_angleAzimuth[K_ACCENT1]); - GetInt(IDC_FB_EDIT2, &m_angleAzimuth[K_ACCENT2]); - m_updating = true; - applyAngle(K_SUN); - applyAngle(K_ACCENT1); - applyAngle(K_ACCENT2); - m_updating = false; -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the angles. */ -void GlobalLightOptions::OnChangeLeftRightEdit() -{ - if (m_updating) return; - GetInt(IDC_LR_EDIT, &m_angleElevation[K_SUN]); - GetInt(IDC_LR_EDIT1, &m_angleElevation[K_ACCENT1]); - GetInt(IDC_LR_EDIT2, &m_angleElevation[K_ACCENT2]); - m_updating = true; - applyAngle(K_SUN); - applyAngle(K_ACCENT1); - applyAngle(K_ACCENT2); - m_updating = false; -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void GlobalLightOptions::applyColor(Int lightIndex) -{ - Int clr; - GlobalData::TerrainLighting tl; - if (m_lighting == K_OBJECTS || m_lighting == K_BOTH) { - tl = TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } else { - tl = TheGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][lightIndex]; - } - if (lightIndex == K_SUN) { - tl.ambient.red = TheGlobalData->m_terrainAmbient[K_SUN].red; - tl.ambient.green = TheGlobalData->m_terrainAmbient[K_SUN].green; - tl.ambient.blue = TheGlobalData->m_terrainAmbient[K_SUN].blue; - - if (GetInt(IDC_RA_EDIT, &clr)) - tl.ambient.red = ComponentToPercent(clr); - if (GetInt(IDC_GA_EDIT, &clr)) - tl.ambient.green = ComponentToPercent(clr); - if (GetInt(IDC_BA_EDIT, &clr)) - tl.ambient.blue = ComponentToPercent(clr); - } else { - tl.ambient.red = 0; - tl.ambient.green = 0; - tl.ambient.blue = 0; - } - - tl.diffuse.red = TheGlobalData->m_terrainDiffuse[lightIndex].red; - tl.diffuse.green = TheGlobalData->m_terrainDiffuse[lightIndex].green; - tl.diffuse.blue = TheGlobalData->m_terrainDiffuse[lightIndex].blue; - - if (GetInt(kUIRedIDs[lightIndex], &clr)) - tl.diffuse.red = ComponentToPercent(clr); - if (GetInt(kUIGreenIDs[lightIndex], &clr)) - tl.diffuse.green = ComponentToPercent(clr); - if (GetInt(kUIBlueIDs[lightIndex], &clr)) - tl.diffuse.blue = ComponentToPercent(clr); - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - pView->setLighting(&tl, m_lighting, lightIndex); - } -} - -void GlobalLightOptions::OnChangeColorEdit() -{ - if (m_updating) return; - applyColor(K_SUN); - applyColor(K_ACCENT1); - applyColor(K_ACCENT2); - -} - - -void GlobalLightOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_FB_POPUP: - *pMin = 0; - *pMax = 359; - *pInitial = m_angleAzimuth[K_SUN]; - *pLineSize = 1; - break; - case IDC_FB_POPUP1: - *pMin = 0; - *pMax = 359; - *pInitial = m_angleAzimuth[K_ACCENT1]; - *pLineSize = 1; - break; - case IDC_FB_POPUP2: - *pMin = 0; - *pMax = 359; - *pInitial = m_angleAzimuth[K_ACCENT2]; - *pLineSize = 1; - break; - - case IDC_LR_POPUP: - *pMin = 0; - *pMax = 90; - *pInitial = m_angleElevation[K_SUN]; - *pLineSize = 1; - break; - case IDC_LR_POPUP1: - *pMin = 0; - *pMax = 90; - *pInitial = m_angleElevation[K_ACCENT1]; - *pLineSize = 1; - break; - case IDC_LR_POPUP2: - *pMin = 0; - *pMax = 90; - *pInitial = m_angleElevation[K_ACCENT2]; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void GlobalLightOptions::PopSliderChanged(const long sliderID, long theVal) -{ - switch (sliderID) { - - case IDC_FB_POPUP: - m_angleAzimuth[K_SUN] = theVal; - PutInt(IDC_FB_EDIT, m_angleAzimuth[K_SUN]); - applyAngle(0); - break; - - case IDC_FB_POPUP1: - m_angleAzimuth[K_ACCENT1] = theVal; - PutInt(IDC_FB_EDIT1, m_angleAzimuth[K_ACCENT1]); - applyAngle(1); - break; - - case IDC_FB_POPUP2: - m_angleAzimuth[K_ACCENT2] = theVal; - PutInt(IDC_FB_EDIT2, m_angleAzimuth[K_ACCENT2]); - applyAngle(2); - break; - - case IDC_LR_POPUP: - m_angleElevation[K_SUN] = theVal; - PutInt(IDC_LR_EDIT, m_angleElevation[K_SUN]); - applyAngle(0); - break; - - case IDC_LR_POPUP1: - m_angleElevation[K_ACCENT1] = theVal; - PutInt(IDC_LR_EDIT1, m_angleElevation[K_ACCENT1]); - applyAngle(1); - break; - - case IDC_LR_POPUP2: - m_angleElevation[K_ACCENT2] = theVal; - PutInt(IDC_LR_EDIT2, m_angleElevation[K_ACCENT2]); - applyAngle(2); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void GlobalLightOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_FB_POPUP: - break; - case IDC_LR_POPUP: - break; - case IDC_FB_POPUP1: - break; - case IDC_LR_POPUP1: - break; - case IDC_FB_POPUP2: - break; - case IDC_LR_POPUP2: - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - - -BEGIN_MESSAGE_MAP(GlobalLightOptions, CDialog) - //{{AFX_MSG_MAP(GlobalLightOptions) - ON_WM_MOVE() - ON_WM_SHOWWINDOW() - ON_WM_CLOSE() - ON_EN_CHANGE(IDC_RA_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_BA_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_GA_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_FB_EDIT, OnChangeFrontBackEdit) - ON_EN_CHANGE(IDC_FB_EDIT1, OnChangeFrontBackEdit) - ON_EN_CHANGE(IDC_FB_EDIT2, OnChangeFrontBackEdit) - ON_EN_CHANGE(IDC_LR_EDIT, OnChangeLeftRightEdit) - ON_EN_CHANGE(IDC_LR_EDIT1, OnChangeLeftRightEdit) - ON_EN_CHANGE(IDC_LR_EDIT2, OnChangeLeftRightEdit) - ON_EN_CHANGE(IDC_RD_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_GD_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_BD_EDIT, OnChangeColorEdit) - ON_EN_CHANGE(IDC_RD_EDIT1, OnChangeColorEdit) - ON_EN_CHANGE(IDC_GD_EDIT1, OnChangeColorEdit) - ON_EN_CHANGE(IDC_BD_EDIT1, OnChangeColorEdit) - ON_EN_CHANGE(IDC_RD_EDIT2, OnChangeColorEdit) - ON_EN_CHANGE(IDC_GD_EDIT2, OnChangeColorEdit) - ON_EN_CHANGE(IDC_BD_EDIT2, OnChangeColorEdit) - ON_BN_CLICKED(IDC_RADIO_EVERYTHING, OnRadioEverything) - ON_BN_CLICKED(IDC_RADIO_OBJECTS, OnRadioObjects) - ON_BN_CLICKED(IDC_RADIO_TERRAIN, OnRadioTerrain) - ON_BN_CLICKED(IDC_PSEd_Color1, OnColorPress) - ON_BN_CLICKED(IDC_GlobalLightingReset, OnResetLights) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - - -void GlobalLightOptions::OnRadioEverything() -{ - m_lighting = K_BOTH; - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); -} - -void GlobalLightOptions::OnRadioObjects() -{ - m_lighting = K_OBJECTS; - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); -} - -void GlobalLightOptions::OnRadioTerrain() -{ - m_lighting = K_TERRAIN; - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); -} - -void GlobalLightOptions::OnColorPress() -{ - CColorDialog dlg; - if (dlg.DoModal() == IDOK) { - m_colorButton.setColor(CButtonShowColor::BGRtoRGB(dlg.GetColor())); - RGBColor color = m_colorButton.getColor(); - PutInt(IDC_RA_EDIT, PercentToComponent(color.red)); - PutInt(IDC_GA_EDIT, PercentToComponent(color.green)); - PutInt(IDC_BA_EDIT, PercentToComponent(color.blue)); - applyColor(K_SUN); - } -} - -void GlobalLightOptions::OnClose() -{ - ShowWindow(SW_HIDE); - - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - Coord3D lightRay; - lightRay.x=0.0f;lightRay.y=0.0f;lightRay.z=-1.0f; //default light above terrain. - pView->doLightFeedback(false,lightRay,0); //turn off the light direction indicator - } -}; - -void GlobalLightOptions::OnShowWindow(BOOL bShow, UINT nStatus) -{ - CDialog::OnShowWindow(bShow, nStatus); - - stuffValuesIntoFields(K_SUN); - stuffValuesIntoFields(K_ACCENT1); - stuffValuesIntoFields(K_ACCENT2); - if (!bShow) { - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - Coord3D lightRay; - lightRay.x=0.0f;lightRay.y=0.0f;lightRay.z=-1.0f; //default light above terrain. - pView->doLightFeedback(false,lightRay,0); //turn off the light direction indicator - pView->doLightFeedback(false,lightRay,1); //turn off the light direction indicator - pView->doLightFeedback(false,lightRay,2); //turn off the light direction indicator - } - } -#if 0 - SpitLights(); -#endif -}; - -void GlobalLightOptions::OnMove(int x, int y) -{ - CDialog::OnMove(x, y); - - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(GLOBALLIGHT_OPTIONS_PANEL_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(GLOBALLIGHT_OPTIONS_PANEL_SECTION, "Left", frameRect.left); - } - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/GroveOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/GroveOptions.cpp deleted file mode 100644 index 6171aef302e..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/GroveOptions.cpp +++ /dev/null @@ -1,492 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -#include "StdAfx.h" -#include "Common/STLTypedefs.h" -#include "GroveOptions.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" -#include "Common/ThingTemplate.h" - -#define ARBITRARY_BUFF_SIZE 128 - -/*extern*/ GroveOptions *TheGroveOptions = nullptr; - -void GroveOptions::makeMain() -{ - TheGroveOptions = this; -} - -GroveOptions::GroveOptions(CWnd* pParent) -{ - -} - -int GroveOptions::getNumTrees() -{ - CWnd* pWnd = GetDlgItem(IDC_Grove_NumberTrees); - if (!pWnd) { - return 0; - } - - static char buff[ARBITRARY_BUFF_SIZE]; - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - return atoi(buff); -} - - -int GroveOptions::getNumType(int type) -{ - static char buff[ARBITRARY_BUFF_SIZE]; - - if (type < 1 || type > 5) { - return -1; - } - - CWnd *pWnd; - CComboBox* pBox; - if (type == 1) { - pWnd = GetDlgItem(IDC_Grove_Per1); - pBox = (CComboBox*) GetDlgItem(IDC_Grove_Type1); - } else if (type == 2) { - pWnd = GetDlgItem(IDC_Grove_Per2); - pBox = (CComboBox*) GetDlgItem(IDC_Grove_Type2); - } else if (type == 3) { - pWnd = GetDlgItem(IDC_Grove_Per3); - pBox = (CComboBox*) GetDlgItem(IDC_Grove_Type3); - } else if (type == 4) { - pWnd = GetDlgItem(IDC_Grove_Per4); - pBox = (CComboBox*) GetDlgItem(IDC_Grove_Type4); - } else if (type == 5) { - pWnd = GetDlgItem(IDC_Grove_Per5); - pBox = (CComboBox*) GetDlgItem(IDC_Grove_Type5); - } - - if (pWnd && pBox) { - if (pBox->GetCurSel() > 0) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - return atoi(buff); - } - return 0; - } - return -1; -} - -AsciiString GroveOptions::getTypeName(int type) -{ - if (type < 1 || type > 5) { - return ""; - } - - CComboBox *pComboBox; - if (type == 1) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type1); - } else if (type == 2) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type2); - } else if (type == 3) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type3); - } else if (type == 4) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type4); - } else if (type == 5) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type5); - } - - int curSel = pComboBox->GetCurSel(); - if (curSel < 0 || curSel > mVecDisplayNames.size()) { - return ""; - } - CString cstr; - - pComboBox->GetLBText(curSel, cstr); - - return cstr.GetBuffer(0); -} - -int GroveOptions::getTotalTreePerc() -{ - static char buff[ARBITRARY_BUFF_SIZE]; - - CWnd* pWnd = GetDlgItem(IDC_Grove_PerTotal); - if (!pWnd) { - return -1; - } - - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - return atoi(buff); - } - return -1; -} - -Bool GroveOptions::getCanPlaceInWater() -{ - CButton* pButt; - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowWaterPlacement); - if (pButt) { - return (pButt->GetState() != 0); - } - return false; -} - -Bool GroveOptions::getCanPlaceOnCliffs() -{ - CButton* pButt; - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowCliffPlacement); - if (pButt) { - return (pButt->GetState() != 0); - } - return false; -} - -BOOL GroveOptions::OnInitDialog() -{ - _buildTreeList(); - _setTreesToLists(); - _setDefaultRatios(); - _updateTreeWeights(); - _setDefaultNumTrees(); - _setDefaultPlacementAllowed(); - return true; -} - -GroveOptions::~GroveOptions() -{ - TheGroveOptions = nullptr; -} - - -void GroveOptions::_setTreesToLists() -{ - CString str; - for (VecPairNameDisplayNameIt it = mVecDisplayNames.begin(); it != mVecDisplayNames.end(); it++) { - // TODO: If/when Models get Display strings, we need to replace the - // current (str = ...) line with the commented one JKMCD - str = it->first.str(); - //str = GetDisplayNameFromPair(it).str(); - - CComboBox* pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type1); - if (pComboBox) { - pComboBox->AddString(str); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type2); - if (pComboBox) { - pComboBox->AddString(str); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type3); - if (pComboBox) { - pComboBox->AddString(str); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type4); - if (pComboBox) { - pComboBox->AddString(str); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type5); - if (pComboBox) { - pComboBox->AddString(str); - } - } - - int selValue; - str = ""; - CComboBox* pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type1); - if (pComboBox) { - pComboBox->AddString(str); - selValue = AfxGetApp()->GetProfileInt("GroveOptions", "TreeType1", 0); - pComboBox->SetCurSel(selValue % mVecDisplayNames.size()); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type2); - if (pComboBox) { - pComboBox->AddString(str); - selValue = AfxGetApp()->GetProfileInt("GroveOptions", "TreeType2", 0); - pComboBox->SetCurSel(selValue % mVecDisplayNames.size()); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type3); - if (pComboBox) { - pComboBox->AddString(str); - selValue = AfxGetApp()->GetProfileInt("GroveOptions", "TreeType3", 0); - pComboBox->SetCurSel(selValue % mVecDisplayNames.size()); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type4); - if (pComboBox) { - pComboBox->AddString(str); - selValue = AfxGetApp()->GetProfileInt("GroveOptions", "TreeType4", 0); - pComboBox->SetCurSel(selValue % mVecDisplayNames.size()); - } - - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type5); - if (pComboBox) { - pComboBox->AddString(str); - selValue = AfxGetApp()->GetProfileInt("GroveOptions", "TreeType5", 0); - pComboBox->SetCurSel(selValue % mVecDisplayNames.size()); - } -} - -void GroveOptions::_buildTreeList() -{ - const ThingTemplate* pTemplate; - for (pTemplate = TheThingFactory->firstTemplate(); pTemplate; pTemplate = pTemplate->friend_getNextTemplate()) { - if (pTemplate->getEditorSorting() == ES_SHRUBBERY) { - PairNameDisplayName currentName; - currentName.first = pTemplate->getName(); - currentName.second = pTemplate->getDisplayName(); - mVecDisplayNames.push_back(currentName); - } - } -} - -void GroveOptions::_setDefaultRatios() -{ - static char buff[ARBITRARY_BUFF_SIZE]; - int defaultRatio; - - CWnd* pWnd = GetDlgItem(IDC_Grove_Per1); - if (pWnd) { - defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio1", 0); - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio); - pWnd->SetWindowText(buff); - } - - pWnd = GetDlgItem(IDC_Grove_Per2); - if (pWnd) { - defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio2", 0); - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio); - pWnd->SetWindowText(buff); - } - - pWnd = GetDlgItem(IDC_Grove_Per3); - if (pWnd) { - defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio3", 0); - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio); - pWnd->SetWindowText(buff); - } - - pWnd = GetDlgItem(IDC_Grove_Per4); - if (pWnd) { - defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio4", 0); - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio); - pWnd->SetWindowText(buff); - } - - pWnd = GetDlgItem(IDC_Grove_Per5); - if (pWnd) { - defaultRatio = AfxGetApp()->GetProfileInt("GroveOptions", "DefaultRatio5", 0); - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultRatio); - pWnd->SetWindowText(buff); - } -} - -void GroveOptions::_setDefaultNumTrees() -{ - CWnd* pWnd = GetDlgItem(IDC_Grove_NumberTrees); - if (!pWnd) { - return; - } - - int defaultNumTrees = AfxGetApp()->GetProfileInt("GroveOptions", "NumberofTrees", 10); - static char buff[ARBITRARY_BUFF_SIZE]; - snprintf(buff, ARRAY_SIZE(buff), "%d", defaultNumTrees); - - pWnd->SetWindowText(buff); -} - -void GroveOptions::_setDefaultPlacementAllowed() -{ - CButton* pButt; - int state; - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowCliffPlacement); - if (pButt) { - state = AfxGetApp()->GetProfileInt("GroveOptions", "AllowCliffPlace", 1); - pButt->SetCheck(state); - } - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowWaterPlacement); - if (pButt) { - state = AfxGetApp()->GetProfileInt("GroveOptions", "AllowWaterPlace", 1); - pButt->SetCheck(state); - } -} - - -void GroveOptions::_updateTreeWeights() -{ - static char buff[ARBITRARY_BUFF_SIZE]; - int val = 0; - int ratio; - CWnd* pWnd = GetDlgItem(IDC_Grove_Per1); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - ratio = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "DefaultRatio1", ratio); - val += ratio; - } - - pWnd = GetDlgItem(IDC_Grove_Per2); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - ratio = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "DefaultRatio2", ratio); - val += ratio; - } - - pWnd = GetDlgItem(IDC_Grove_Per3); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - ratio = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "DefaultRatio3", ratio); - val += ratio; - } - - pWnd = GetDlgItem(IDC_Grove_Per4); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - ratio = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "DefaultRatio4", ratio); - val += ratio; - } - - pWnd = GetDlgItem(IDC_Grove_Per5); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - ratio = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "DefaultRatio5", ratio); - val += ratio; - } - - pWnd = GetDlgItem(IDC_Grove_PerTotal); - if (pWnd) { - snprintf(buff, ARRAY_SIZE(buff), "%d", val); - pWnd->SetWindowText(buff); - } -} - -void GroveOptions::_updateTreeCount() -{ - static char buff[ARBITRARY_BUFF_SIZE]; - CWnd* pWnd = GetDlgItem(IDC_Grove_NumberTrees); - if (pWnd) { - pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); - int val = atoi(buff); - AfxGetApp()->WriteProfileInt("GroveOptions", "NumberofTrees", val); - } -} - -void GroveOptions::_updateGroveMakeup() -{ - for (int type = 1; type <= 5; ++type) { - CComboBox *pComboBox; - if (type == 1) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type1); - } else if (type == 2) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type2); - } else if (type == 3) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type3); - } else if (type == 4) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type4); - } else if (type == 5) { - pComboBox = (CComboBox*) GetDlgItem(IDC_Grove_Type5); - } - - if (!pComboBox) { - continue; - } - - int curSel = pComboBox->GetCurSel(); - if (type == 1) { - AfxGetApp()->WriteProfileInt("GroveOptions", "TreeType1", curSel); - } else if (type == 2) { - AfxGetApp()->WriteProfileInt("GroveOptions", "TreeType2", curSel); - } else if (type == 3) { - AfxGetApp()->WriteProfileInt("GroveOptions", "TreeType3", curSel); - } else if (type == 4) { - AfxGetApp()->WriteProfileInt("GroveOptions", "TreeType4", curSel); - } else if (type == 5) { - AfxGetApp()->WriteProfileInt("GroveOptions", "TreeType5", curSel); - } - } -} - -void GroveOptions::_updatePlacementAllowed() -{ - // huh huh huh-huh - CButton* pButt; - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowCliffPlacement); - if (pButt) { - AfxGetApp()->WriteProfileInt("GroveOptions", "AllowCliffPlace", pButt->GetCheck()); - } - - pButt = (CButton*) GetDlgItem(IDC_Grove_AllowWaterPlacement); - if (pButt) { - AfxGetApp()->WriteProfileInt("GroveOptions", "AllowWaterPlace", pButt->GetCheck()); - } - - -} - -void GroveOptions::OnOK() -{ - -} - -void GroveOptions::OnClose() -{ - - -} - -UnicodeString GetDisplayNameFromPair(const PairNameDisplayName* pNamePair) -{ - if (!pNamePair) { - return UnicodeString::TheEmptyString; - } - - if (!pNamePair->second.isEmpty()) { - return pNamePair->second; - } - - // The unicode portion of the pair was empty. We need to use the Ascii version instead. - UnicodeString retStr; - retStr.translate(pNamePair->first); - return retStr; -} - -BEGIN_MESSAGE_MAP(GroveOptions, CDialog) - ON_EN_KILLFOCUS(IDC_Grove_Per1, _updateTreeWeights) - ON_EN_KILLFOCUS(IDC_Grove_Per2, _updateTreeWeights) - ON_EN_KILLFOCUS(IDC_Grove_Per3, _updateTreeWeights) - ON_EN_KILLFOCUS(IDC_Grove_Per4, _updateTreeWeights) - ON_EN_KILLFOCUS(IDC_Grove_Per5, _updateTreeWeights) - ON_EN_KILLFOCUS(IDC_Grove_NumberTrees, _updateTreeCount) - ON_CBN_SELENDOK(IDC_Grove_Type1, _updateGroveMakeup) - ON_CBN_SELENDOK(IDC_Grove_Type2, _updateGroveMakeup) - ON_CBN_SELENDOK(IDC_Grove_Type3, _updateGroveMakeup) - ON_CBN_SELENDOK(IDC_Grove_Type4, _updateGroveMakeup) - ON_CBN_SELENDOK(IDC_Grove_Type5, _updateGroveMakeup) - ON_BN_CLICKED(IDC_Grove_AllowCliffPlacement, _updatePlacementAllowed) - ON_BN_CLICKED(IDC_Grove_AllowWaterPlacement, _updatePlacementAllowed) -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/GroveTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/GroveTool.cpp deleted file mode 100644 index b60c9d662a6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/GroveTool.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// GroveTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "GroveTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "Common/GlobalData.h" -#include "GameLogic/LogicRandomValue.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/Debug.h" -#include "DrawObject.h" -#include "GroveOptions.h" -#include "GameLogic/PolygonTrigger.h" -#include "mapobjectprops.h" - -#define DRAG_THRESHOLD 5 -#define MAX_TREE_RISE_OVER_RUN (1.5f) - -// surface normal Z must be greater than this to plant a tree -static Real flatTolerance = 0.8f; - -static Bool _positionIsTooCliffyForTrees(Coord3D pos); - -//------------------------------------------------------------------------------------------------- -/** See if a location is underwater, and what the water height is. */ -//------------------------------------------------------------------------------------------------- -Bool localIsUnderwater( Real x, Real y) -{ - ICoord3D iLoc; - iLoc.x = (floor(x+0.5f)); - iLoc.y = (floor(y+0.5f)); - iLoc.z = 0; - // Look for water areas. - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (!pTrig->isWaterArea()) { - continue; - } - // See if point is in a water area - if (pTrig->pointInTrigger(iLoc)) { - Real wZ = pTrig->getPoint(0)->z; - // See if the ground height is less than the water level. - Real curHeight = TheTerrainRenderObject->getHeightMapHeight(x, y, nullptr); - return (curHeightgetTotalTreePerc(); - int randVal = GameLogicRandomValue(0, totalValue - 1); - - - int runningCum = 0; - for (int i = 1; i <= 5; ++i) { - runningCum += TheGroveOptions->getNumType(i); - if (randVal < runningCum) { - if (TheGroveOptions->getTypeName(i).isEmpty()) { - return; - } - - treeName = TheGroveOptions->getTypeName(i).str(); - break; - } - } - - addObj(pos, treeName); -} - -void GroveTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_GROVE_OPTIONS); - DrawObject::setDoBrushFeedback(false); -} - - -// plant a shrub -void GroveTool::plantShrub( Coord3D *pos ) -{ -// TODO: Determine when we can tell something is a shurubbery, and plant it here - jkmcd -// addObj(pos, "Shrub"); -} - -void GroveTool::_plantGroveInBox(CPoint tl, CPoint br, WbView* pView) -{ - - int numTotalTrees = TheGroveOptions->getNumTrees(); - - Coord3D tl3d, tr3d, bl3d; - pView->viewToDocCoords(tl, &tl3d); - pView->viewToDocCoords(CPoint(tl.x, br.y), &bl3d); - pView->viewToDocCoords(CPoint(br.x, tl.y), &tr3d); - - tl3d.z = 0; - - bl3d.x -= tl3d.x; - bl3d.y -= tl3d.y; - bl3d.z = 0; - - tr3d.x -= tl3d.x; - tr3d.y -= tl3d.y; - tr3d.z = 0; - - for (int i = 0; i < numTotalTrees; ++i) { - Real trModifier = GameLogicRandomValueReal(0.0f, 1.0f); - Real blModifier = GameLogicRandomValueReal(0.0f, 1.0f); - - Vector3 tlVec(tl3d.x, tl3d.y, tl3d.z); - Vector3 trVec(tr3d.x * trModifier, tr3d.y * trModifier, tr3d.z); - Vector3 blVec(bl3d.x * blModifier, bl3d.y * blModifier, bl3d.z); - - tlVec = tlVec + trVec; - tlVec = tlVec + blVec; - - Coord3D position; - - position.x = tlVec.X; - position.y = tlVec.Y; - position.z = 0; - - // (maybe) don't put trees on steep slopes - // (maybe) tree must not be in the water - if (!TheGroveOptions->getCanPlaceInWater() && localIsUnderwater(position.x, position.y)) { - continue; - } - - if (!TheGroveOptions->getCanPlaceOnCliffs() && _positionIsTooCliffyForTrees(position)) { - continue; - } - // We've satisfied our conditions. Plant the little bugger - plantTree(&position); - } -} - -/** - * Plant a grove of trees, recursively. Given a "seed location", create child - * trees nearby, and recursively call the grove function on those children. - */ -void GroveTool::plantGrove( Coord3D pos, Coord3D prevDir, Real baseHeight, Int level, CPoint bounds ) -{ - Coord3D childPos, normal, dir; - Real childChance = 1.0f; - Real heightTolerance = 1.5f*MAP_XY_FACTOR; // was 4 - Real angle, spread; - Int numChildren = 2, retry, maxTries = 5; - - if (level == 1) - { - // plant a shrub around the outskirts of the grove - plantShrub( &pos ); - } - else - { - // plant a tree here - plantTree( &pos ); - } - - // if reached base level, stop - if (level == 0) - return; - - - // spawn child trees - for( Int i=0; igetHeightMapHeight( childPos.x, childPos.y, &normal ); - } - - dir.x = childPos.x - pos.x; - dir.y = childPos.y - pos.y; - - // don't select a spot too much towards where we came from - // (note that if prevDir the zero vector, it passes this test (for the 1st tree)) - // don't put trees on steep slopes - // dont' plant if height changed too much - // tree must be on map - // tree must not be in the water - if (dir.x * prevDir.x + dir.y * prevDir.y >= 0.0f && - normal.z > flatTolerance && - fabs(childPos.z - baseHeight) < heightTolerance && - childPos.x > 0 && childPos.y > 0 && - childPos.x < bounds.x && childPos.y < bounds.y && - (!localIsUnderwater(childPos.x, childPos.y))) - break; - } - - if (retry < maxTries) - plantGrove( childPos, dir, baseHeight, level-1, bounds ); - } - } -} - - -// -// GroveTool class. -// -/// Constructor -GroveTool::GroveTool() : - Tool(ID_GROVE_TOOL, IDC_GROVE) -{ - m_headMapObj = nullptr; -} - -/// Destructor -GroveTool::~GroveTool() -{ - deleteInstance(m_headMapObj); -} - -/** Execute the tool on mouse down - Place an object. */ -void GroveTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - m_downPt = viewPt; - m_dragging = false; -} - -/** Execute the tool on mouse up - Place an object. */ -void GroveTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - if (pView && m_dragging) { - CRect box; - box.left = viewPt.x; - box.top = viewPt.y; - box.right = m_downPt.x; - box.bottom = m_downPt.y; - box.NormalizeRect(); - pView->doRectFeedback(false, box); - pView->Invalidate(); - - _plantGroveInBox(m_downPt, viewPt, pView); - if (m_headMapObj != nullptr) { - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, m_headMapObj); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_headMapObj = nullptr; // undoable owns it now. - } - return; - } - - Coord3D loc; - - pView->viewToDocCoords(m_downPt, &loc); - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - CPoint bounds; - bounds.x = pMap->getXExtent()*MAP_XY_FACTOR; - bounds.y = pMap->getYExtent()*MAP_XY_FACTOR; -// Real angle = 0; - Int depth = 3; - Coord3D zeroDir; - - zeroDir.x = 0.0f; - zeroDir.y = 0.0f; - zeroDir.z = 0.0f; - loc.z = TheTerrainRenderObject ? TheTerrainRenderObject->getHeightMapHeight( loc.x, loc.y, nullptr ) : 0; - - // grow tree grove out from here - plantGrove( loc, zeroDir, loc.z, depth, bounds ); - if (m_headMapObj != nullptr) { - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, m_headMapObj); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_headMapObj = nullptr; // undoable owns it now. - } -} - -void GroveTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - - if (abs(viewPt.x - m_downPt.x) > DRAG_THRESHOLD || abs(viewPt.y - m_downPt.y) > DRAG_THRESHOLD) { - m_dragging = true; - } - - if (pView && m_dragging) { - CRect box; - box.left = viewPt.x; - box.bottom = viewPt.y; - box.top = m_downPt.y; - box.right = m_downPt.x; - box.NormalizeRect(); - pView->doRectFeedback(true, box); - pView->Invalidate(); - return; - - } -} - -void GroveTool::addObj(Coord3D *pos, AsciiString name) -{ - MapObject *pCur = ObjectOptions::getObjectNamed(name); - DEBUG_ASSERTCRASH(pCur!=nullptr, ("oops")); - if (!pCur) return; - Coord3D theLoc = *pos; - theLoc.z = 0; - Real angle = GameLogicRandomValueReal( 0.0f, 2.0f * PI ); - MapObject *pNew = newInstance( MapObject)(theLoc, pCur->getName(), angle, 0, nullptr, pCur->getThingTemplate() ); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew->setNextMap(m_headMapObj); - m_headMapObj = pNew; -} - - -#define SQRT_2 (1.41421356f) -static Bool _positionIsTooCliffyForTrees(Coord3D pos) -{ - Coord3D otherPos; - - otherPos = pos; - otherPos.x += MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / 1) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / 1) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.y += MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / 1) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / 1) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.y -= MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / 1) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / 1) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.x -= MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / 1) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / 1) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.x += MAP_XY_FACTOR; - otherPos.y += MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.x += MAP_XY_FACTOR; - otherPos.y -= MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.x -= MAP_XY_FACTOR; - otherPos.y -= MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - otherPos = pos; - otherPos.x -= MAP_XY_FACTOR; - otherPos.y += MAP_XY_FACTOR; - otherPos.z = TheTerrainRenderObject->getHeightMapHeight(otherPos.x, otherPos.y, nullptr); - - if (((pos.z / otherPos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN) || - ((otherPos.z / pos.z / SQRT_2) > MAX_TREE_RISE_OVER_RUN)) { - return true; - } - - return false; -} -#undef SQRT_2 diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/HandScrollTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/HandScrollTool.cpp deleted file mode 100644 index e74cd4ad878..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/HandScrollTool.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// HandScrollTool.cpp -// Scrolling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "HandScrollTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -// -// HandScrollTool class. -// - -inline Int IABS(Int x) { if (x>=0) return x; return -x;}; -static const Int MAX_SCROLL = 1000; - -/// Constructor -HandScrollTool::HandScrollTool() : - Tool(ID_HAND_SCROLL_TOOL, IDC_HAND_SCROLL) -{ -} - -/// Shows the terrain materials options panel. -void HandScrollTool::activate() -{ - // Hand scroll tool intentionally doesn't change tool panel. -} - -/// Destructor -HandScrollTool::~HandScrollTool() -{ -} - -void HandScrollTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L && m != TRACK_R && m != TRACK_M) return; - -// pView->viewToDocCoords(viewPt, &m_prevPt); - m_prevPt2d = viewPt; - m_downPt2d = viewPt; - m_scrolling = false; - // Save the start point. - m_mouseDownTime = ::GetTickCount(); -} - -/// Left button move code. -void HandScrollTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m == TRACK_NONE) - return; - - if (m == TRACK_M) { - - // camera rotation - const Real factor = 0.01f; - Real rot = factor * (viewPt.x - m_prevPt2d.x); - /* - if (pView->isDoingPitch()) - pView->pitchCamera(rot); - else - */ - pView->rotateCamera(rot); - m_prevPt2d = viewPt; - - } else if (m == TRACK_L || m == TRACK_R) { - if (!m_scrolling) { - // see if we moved enough to start scrolling. - if (abs(viewPt.x - m_downPt2d.x) > HYSTERESIS) m_scrolling = true; - if (abs(viewPt.y - m_downPt2d.y) > HYSTERESIS) m_scrolling = true; - } - if (!m_scrolling) { - return; - } - // Scroll dynamically. - Coord3D prev, cur; - if (pView->viewToDocCoords(m_prevPt2d, &prev, false) && - pView->viewToDocCoords(viewPt, &cur, false)) - { - - Real dx = cur.x - prev.x; - Real dy = cur.y - prev.y; - if (IABS(dx)>MAX_SCROLL) { - dx = 0; - } - if (IABS(dy)>MAX_SCROLL) { - dy = 0; - } - dx /= MAP_XY_FACTOR; - dy /= MAP_XY_FACTOR; - pView->scrollInView(dx, dy, false); - - m_prevPt2d = viewPt; - } - } -} - -void HandScrollTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m == TRACK_M) { - // if haven't moved, reset view - Bool moved = false; - if (abs(viewPt.x - m_downPt2d.x) > HYSTERESIS) moved = true; - if (abs(viewPt.y - m_downPt2d.y) > HYSTERESIS) moved = true; - - if (!moved && GetTickCount() - m_mouseDownTime < ::GetDoubleClickTime()) - { - pView->setDefaultCamera(); - } - } else if (m == TRACK_L || m == TRACK_R) { - if (m_scrolling) { - // Tell the view we are done scrolling. - pView->scrollInView(0,0,true); - } else if (m==TRACK_R) { - // Clicked right. Deselect & go to pointer. - WbApp()->selectPointerTool(); - } - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp deleted file mode 100644 index 2c59f005242..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ImpassableOptions.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ImpassableOptions.cpp -// Author: John McDonald, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "ImpassableOptions.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "wbview3d.h" -#include "WorldBuilderDoc.h" - -//------------------------------------------------------------------------------------------------- -ImpassableOptions::ImpassableOptions(CWnd* pParent, Real defaultSlope) : - CDialog(ImpassableOptions::IDD, pParent), - m_slopeToShow(defaultSlope), - m_defaultSlopeToShow(defaultSlope) -{ - // nada to do - m_showImpassableAreas = TheTerrainRenderObject->getShowImpassableAreas(); - TheTerrainRenderObject->setShowImpassableAreas(TRUE); -} - -//------------------------------------------------------------------------------------------------- -ImpassableOptions::~ImpassableOptions() -{ - TheTerrainRenderObject->setShowImpassableAreas(m_showImpassableAreas); -} - -//------------------------------------------------------------------------------------------------- -Bool ImpassableOptions::ValidateSlope() -{ - if (m_slopeToShow < 0.0f) { - m_slopeToShow = 0.0f; - return FALSE; - } - - if (m_slopeToShow >= 90.0f) { - m_slopeToShow = 89.9f; - return FALSE; - } - - return TRUE; -} - -//------------------------------------------------------------------------------------------------- -BOOL ImpassableOptions::OnInitDialog() -{ - CWnd* pWnd = GetDlgItem(IDC_ANGLE); - if (!pWnd) { - return FALSE; - } - - AsciiString astr; - astr.format("%.2f", m_slopeToShow); - pWnd->SetWindowText(astr.str()); - - return CDialog::OnInitDialog(); -} - -//------------------------------------------------------------------------------------------------- -void ImpassableOptions::OnAngleChange() -{ - CWnd* pWnd = GetDlgItem(IDC_ANGLE); - if (!pWnd) { - return; - } - - CString cstr; - pWnd->GetWindowText(cstr); - char* buff = cstr.GetBuffer(0); - - m_slopeToShow = (Real)atof(buff); - - if (!ValidateSlope()) { - AsciiString astr; - astr.format("%.2f", m_slopeToShow); - pWnd->SetWindowText(astr.str()); - } - TheTerrainRenderObject->setViewImpassableAreaSlope(m_slopeToShow); -} - -void ImpassableOptions::OnPreview() -{ - // update it. - IRegion2D range = {0,0,0,0}; - WbView3d *pView = CWorldBuilderDoc::GetActive3DView(); - pView->updateHeightMapInView(TheTerrainRenderObject->getMap(), false, range); -} - -BEGIN_MESSAGE_MAP(ImpassableOptions, CDialog) - ON_EN_UPDATE(IDC_ANGLE, OnAngleChange) - ON_BN_CLICKED(IDC_PREVIEW, OnPreview) -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/LayersList.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/LayersList.cpp deleted file mode 100644 index dfe282be47c..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/LayersList.cpp +++ /dev/null @@ -1,1362 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: LayersList.cpp -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: LayersList.cpp */ -/* Created: John K. McDonald, Jr., 5/10/2002 */ -/* Desc: The layers list implementation for WorldBuilder. */ -/* Revision History: */ -/* 5/10/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#include "StdAfx.h" -#include "Common/STLTypedefs.h" -#include "resource.h" -#include "LayersList.h" - -#include "Common/Dict.h" -#include "Common/MapObject.h" -#include "Common/WellKnownKeys.h" - -#include "PointerTool.h" -#include "WorldBuilderDoc.h" -#include "GameLogic/PolygonTrigger.h" - -#include - - -static int newLayerNum = 1; - -// CLLTreeCtrl Implementation ///////////////////////////////////////////////////////////////////// - -void CLLTreeCtrl::buildMoveMenu(CMenu* moveMenu, UINT firstID) -{ - LayersList* pParent = (LayersList*) GetParent(); - if (!pParent) { - return; - } - - // to save the copy - const ListLayer& layer = pParent->GetAllLayers(); - - ListLayer::const_iterator cit; - - int i = 0; - for (cit = layer.begin(); cit != layer.end(); ++cit) { - moveMenu->AppendMenu(MF_STRING, firstID + i, cit->layerName.str()); - ++i; - } -} - -enum LayersListMenuSelectionsEnum { - LAYERS_LIST_SELECT_OBJECT, - LAYERS_LIST_SELECT_ACTIVE_LAYER, - LAYERS_LIST_BREAK_1, - LAYERS_LIST_INSERT_NEW_LAYER, - LAYERS_LIST_DELETE_CURRENT_LAYER, - LAYERS_LIST_MERGE_LAYER_INTO, - LAYERS_LIST_MERGE_OBJECT_INTO, - LAYERS_LIST_MERGE_VIEW_SELECTION_INTO, - LAYERS_LIST_BREAK_2, - LAYERS_LIST_HIDE_CURRENT_LAYER, -}; -void CLLTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point) -{ - // first, if there's something under the mouse, select it. - - HTREEITEM item = HitTest(point); - Bool contextIsLayer = false; - SelectItem(item); - - if (item) { - if (GetParentItem(item) == nullptr) { - mLastClickedLayer = GetItemText(item); - mLastClickedObject = AsciiString::TheEmptyString; - contextIsLayer = true; - } else { - mLastClickedLayer = AsciiString::TheEmptyString; - mLastClickedObject = GetItemText(item); - } - } else { - mLastClickedLayer = AsciiString::TheEmptyString; - mLastClickedObject = AsciiString::TheEmptyString; - } - - CMenu menu; - VERIFY(menu.LoadMenu(IDR_LAYERSLISTPOPUP)); - CMenu* pPopup = menu.GetSubMenu(0); - if (!pPopup) { - return; - } - ClientToScreen(&point); - - CMenu *moveViewSelectionMenu = pPopup->GetSubMenu(LAYERS_LIST_MERGE_VIEW_SELECTION_INTO); - moveViewSelectionMenu->RemoveMenu(0, MF_BYPOSITION); - buildMoveMenu(moveViewSelectionMenu, ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_BEGIN); - - if (item) { - if (contextIsLayer) { - CString itemText = GetItemText(item); - if ((itemText.CompareNoCase(LayersList::TheActiveLayerName.c_str()) == 0) || - ((LayersList::TheActiveLayerName.c_str() == nullptr) && - (LayersList::TheUnmutableDefaultLayerName.compare(LayersList::TheDefaultLayerName) == 0))) { - // Don't allow the current layer to be hidden. - // Because the objects will immediately disappear when placed. - pPopup->EnableMenuItem(ID_HIDECURRENTLAYER, MF_GRAYED); - } else { - LayersList *ll = (LayersList*) GetParent(); - Bool hidden = ll->isLayerHidden(AsciiString(itemText)); - pPopup->CheckMenuItem(ID_HIDECURRENTLAYER, MF_BYCOMMAND | (hidden ? MF_CHECKED : MF_UNCHECKED)); - } - - CMenu *moveMenu = pPopup->GetSubMenu(LAYERS_LIST_MERGE_LAYER_INTO); - moveMenu->RemoveMenu(0, MF_BYPOSITION); - buildMoveMenu(moveMenu, ID_LAYERSLIST_MERGELAYERINTO_BEGIN); - - pPopup->RemoveMenu(LAYERS_LIST_MERGE_VIEW_SELECTION_INTO, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_MERGE_OBJECT_INTO, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_SELECT_OBJECT, MF_BYPOSITION); - - } else { - pPopup->EnableMenuItem(ID_DELETECURRENTLAYER, MF_GRAYED); - pPopup->EnableMenuItem(ID_HIDECURRENTLAYER, MF_GRAYED); - - CMenu* moveMenu = pPopup->GetSubMenu(LAYERS_LIST_MERGE_OBJECT_INTO); - moveMenu->RemoveMenu(0, MF_BYPOSITION); - buildMoveMenu(moveMenu, ID_LAYERSLIST_MERGEOBJECTINTO_BEGIN); - - pPopup->RemoveMenu(LAYERS_LIST_MERGE_LAYER_INTO, MF_BYPOSITION); - } - } else { - pPopup->RemoveMenu(LAYERS_LIST_HIDE_CURRENT_LAYER, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_MERGE_OBJECT_INTO, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_MERGE_LAYER_INTO, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_DELETE_CURRENT_LAYER, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_SELECT_ACTIVE_LAYER, MF_BYPOSITION); - pPopup->RemoveMenu(LAYERS_LIST_SELECT_OBJECT, MF_BYPOSITION); - } - - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, GetParent()); -} - -BEGIN_MESSAGE_MAP(CLLTreeCtrl, CTreeCtrl) - ON_WM_RBUTTONDOWN() -END_MESSAGE_MAP() - -// LayersList Implementation ////////////////////////////////////////////////////////////////////// - -LayersList::LayersList(UINT nIDTemplate, CWnd *parentWnd) : CDialog(nIDTemplate, parentWnd) -{ - mTree = nullptr; - m_activatedLayer = false; - resetLayers(); -} - -LayersList::~LayersList() -{ - // die die die - // free up windows resources. - DestroyWindow(); - delete mTree; -} - -void LayersList::resetLayers() -{ - // @todo Default needs to be a localizable string - Layer defaultLayer; - TheDefaultLayerName = TheUnmutableDefaultLayerName; - defaultLayer.layerName = AsciiString(TheDefaultLayerName.c_str()); - defaultLayer.show = true; - mLayers.clear(); - mLayers.push_back(defaultLayer); - defaultLayer.layerName = AsciiString(ThePolygonTriggerLayerName.c_str()); - mLayers.push_back(defaultLayer); - TheLayersList = this; - if (mTree) { - mTree->DeleteAllItems(); - updateUIFromList(); - } -} - -void LayersList::addMapObjectToLayersList(MapObject *objToAdd, AsciiString layerToAddTo) -{ - if (!objToAdd || findMapObjectAndList(objToAdd)) { - DEBUG_CRASH(("MapObject added was null or object already in Layers List. jkmcd")); - return; - } - ListLayerIt layerIt; - - if (!findLayerNamed(layerToAddTo, &layerIt)) { - // try to add a layer of that name. - addLayerNamed(layerToAddTo); - if (!findLayerNamed(layerToAddTo, &layerIt)) { - // Try to place it in the active layer. - if (!findLayerNamed(AsciiString(TheActiveLayerName.c_str()), &layerIt)) { - // if we still can't find that layer name, then try adding it to the default layer. - if (!findLayerNamed(AsciiString(TheDefaultLayerName.c_str()), &layerIt)) { - return; - } - } - } - } - - addMapObjectToLayer(objToAdd, &layerIt); -} - -void LayersList::addPolygonTriggerToLayersList(PolygonTrigger *triggerToAdd, AsciiString layerToAddTo) -{ - if (!triggerToAdd || findPolygonTriggerAndList(triggerToAdd)) { - DEBUG_CRASH(("PolygonTrigger added was null or object already in Layers List. jkmcd")); - return; - } - ListLayerIt layerIt; - - if (!findLayerNamed(layerToAddTo, &layerIt)) { - // try to add a layer of that name. - addLayerNamed(layerToAddTo); - if (!findLayerNamed(layerToAddTo, &layerIt)) { - // Try to place it in the active layer. - if (!findLayerNamed(AsciiString(TheActiveLayerName.c_str()), &layerIt)) { - // if we still can't find that layer name, then try adding it to the trigger layer. - if (!findLayerNamed(AsciiString(ThePolygonTriggerLayerName.c_str()), &layerIt)) { - return; - } - } - } - } - - addPolygonTriggerToLayer(triggerToAdd, &layerIt); -} - - -AsciiString LayersList::removeMapObjectFromLayersList(MapObject *objToRemove) -{ - ListLayerIt layerIt; - ListMapObjectPtrIt objIt; - if (!objToRemove || !findMapObjectAndList(objToRemove, &layerIt, &objIt)) { - DEBUG_CRASH(("Couldn't find that object in the layers list. jkmcd")); - return AsciiString::TheEmptyString; - } - - removeMapObjectFromLayer(objToRemove, &layerIt, &objIt); - return layerIt->layerName; -} - -AsciiString LayersList::removePolygonTriggerFromLayersList(PolygonTrigger *triggerToRemove) -{ - ListLayerIt layerIt; - ListPolygonTriggerPtrIt triggerIt; - if (!triggerToRemove || !findPolygonTriggerAndList(triggerToRemove, &layerIt, &triggerIt)) { - DEBUG_CRASH(("Couldn't find that polygon trigger in the layers list. jkmcd")); - return AsciiString::TheEmptyString; - } - - removePolygonTriggerFromLayer(triggerToRemove, &layerIt, &triggerIt); - return layerIt->layerName; -} - - -void LayersList::changeMapObjectLayer(MapObject *objToChange, AsciiString layerToPlaceOn) -{ - if (!objToChange) { - DEBUG_CRASH(("Attempted to change location of null object. jkmcd")); - return; - } - - removeMapObjectFromLayersList(objToChange); - addMapObjectToLayersList(objToChange, layerToPlaceOn); -} - -void LayersList::changePolygonTriggerLayer(PolygonTrigger *triggerToChange, AsciiString layerToPlaceOn) -{ - if (!triggerToChange) { - DEBUG_CRASH(("Attempted to change location of null object. jkmcd")); - return; - } - - removePolygonTriggerFromLayersList(triggerToChange); - addPolygonTriggerToLayersList(triggerToChange, layerToPlaceOn); -} - -void LayersList::addLayerNamed(IN AsciiString layerToAdd) -{ - if (findLayerNamed(layerToAdd)) { - DEBUG_CRASH(("Already found a layer named %s", layerToAdd.str())); - return; - } - - if (layerToAdd.isEmpty()) { - return; - } - - Layer newLayer; - newLayer.layerName = layerToAdd; - newLayer.show = true; - mLayers.push_back(newLayer); -} - -void LayersList::removeLayerNamed(IN AsciiString layerToRemove) -{ - ListLayerIt layerIt; - // Not allowed to remove the Default layer - if (layerToRemove.compareNoCase(TheDefaultLayerName.c_str()) == 0) { - return; - } - - // Not allowed to remove the Default trigger layer - if (layerToRemove.compareNoCase(ThePolygonTriggerLayerName.c_str()) == 0) { - return; - } - - - // If we can't find the layer, how can we remove it? - if (!findLayerNamed(layerToRemove, &layerIt)) { - DEBUG_CRASH(("Couldn't find layer named %s", layerToRemove.str())); - return; - } - - // Transfer all the objects from the old layer to the default layer. - for (ListMapObjectPtrIt obj = layerIt->objectsInLayer.begin(); obj != layerIt->objectsInLayer.end(); obj = layerIt->objectsInLayer.begin()) { - changeMapObjectLayer((*obj), AsciiString(TheDefaultLayerName.c_str())); - } - - // Finally, remove the layer itself. - mLayers.erase(layerIt); -} - -void LayersList::changeLayerName(IN AsciiString oldLayerName, AsciiString newLayerName) -{ - ListLayerIt layerIt; - if (!findLayerNamed(oldLayerName, &layerIt)) { - DEBUG_CRASH(("Couldn't find the layer named %s", oldLayerName.str())); - return; - } - - layerIt->layerName = newLayerName; - - if (oldLayerName.compareNoCase(TheDefaultLayerName.c_str())) { - TheDefaultLayerName = newLayerName.str(); - } -} - -void LayersList::mergeLayerInto(IN ListLayerIt src, IN ListLayerIt dst) -{ - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) { - return; - } - - ListMapObjectPtrIt mopIt; - for (mopIt = src->objectsInLayer.begin(); mopIt != src->objectsInLayer.end(); mopIt = src->objectsInLayer.begin()) { - changeMapObjectLayer(*mopIt, dst->layerName); - } - - ListPolygonTriggerPtrIt ptpIt; - for (ptpIt = src->polygonTriggersInLayer.begin(); ptpIt != src->polygonTriggersInLayer.end(); ptpIt = src->polygonTriggersInLayer.begin()) { - changePolygonTriggerLayer(*ptpIt, dst->layerName); - } - - - // Don't remove these layers. - if (src->layerName.compareNoCase(TheDefaultLayerName.c_str()) == 0) { - return; - } - if (src->layerName.compareNoCase(ThePolygonTriggerLayerName.c_str()) == 0) { - return; - } - - if (src->layerName.compareNoCase(TheActiveLayerName.c_str()) == 0) { - // The active layer is no longer available. - TheActiveLayerName = AsciiString::TheEmptyString.str(); - } - - - // remove the layer from the tree view - HTREEITEM itemToRemove = findTreeLayerNamed(src->layerName); - if (!itemToRemove) { - return; - } - - mTree->DeleteItem(itemToRemove); - - mLayers.erase(src); -} - -Bool LayersList::isLayerHidden(IN AsciiString layerToTest) -{ - ListLayerIt layerIt; - if (!findLayerNamed(layerToTest, &layerIt)) { - // those that we cannot find are always visible. (Not really, but pick one) - return false; - } - - // !show == hide - return (!layerIt->show); -} - -void LayersList::updateUIFromList() -{ - if (!m_performUpdates) { - return; - } - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - - if (!pTree) { - return; - } - - pTree->DeleteAllItems(); - -// int index = 0; - - for (ListLayerIt layersIt = mLayers.begin(); layersIt != mLayers.end(); ++layersIt) { - // Add a branch for each Layer. - int iconToShow = (layersIt->show ? 0 : 1); - HTREEITEM thisBranch = pTree->InsertItem(layersIt->layerName.str(), iconToShow, iconToShow); - - for (ListMapObjectPtrIt objIt = layersIt->objectsInLayer.begin(); objIt != layersIt->objectsInLayer.end(); ++objIt) { - Bool exists; - AsciiString uniqueID = (*objIt)->getProperties()->getAsciiString(TheKey_uniqueID, &exists); - if (exists) { - pTree->InsertItem(uniqueID.str(), iconToShow, iconToShow, thisBranch); - } else { - pTree->InsertItem((*objIt)->getName().str(), iconToShow, iconToShow, thisBranch); - } - } - - for (ListPolygonTriggerPtrIt triggerIt = layersIt->polygonTriggersInLayer.begin(); triggerIt != layersIt->polygonTriggersInLayer.end(); ++triggerIt) { - const AsciiString& uniqueID = (*triggerIt)->getTriggerName(); - pTree->InsertItem(uniqueID.str(), iconToShow, iconToShow, thisBranch); - } - } -} - -Bool LayersList::findMapObjectAndList(IN MapObject *objectToFind, OUT ListLayerIt *layerIt, OUT ListMapObjectPtrIt *objectIt) -{ - if (!objectToFind) { - return false; - } - - for (ListLayerIt layersIt = mLayers.begin(); layersIt != mLayers.end(); ++layersIt) { - for (ListMapObjectPtrIt objPtrIt = layersIt->objectsInLayer.begin(); objPtrIt != layersIt->objectsInLayer.end(); ++objPtrIt) { - if ((*objPtrIt) == objectToFind) { - if (layerIt) { - (*layerIt) = layersIt; - } - - if (objectIt) { - (*objectIt) = objPtrIt; - } - - return true; - } - } - } - - // if we get here, it means we didn't find the object anywhere in any of the layers - return false; -} - -Bool LayersList::findPolygonTriggerAndList(IN PolygonTrigger *triggerToFind, OUT ListLayerIt *layerIt, OUT ListPolygonTriggerPtrIt *triggerIt) -{ - if (!triggerToFind) { - return false; - } - - for (ListLayerIt layersIt = mLayers.begin(); layersIt != mLayers.end(); ++layersIt) { - for (ListPolygonTriggerPtrIt triggerPtrIt = layersIt->polygonTriggersInLayer.begin(); triggerPtrIt != layersIt->polygonTriggersInLayer.end(); ++triggerPtrIt) { - if ((*triggerPtrIt) == triggerToFind) { - if (layerIt) { - (*layerIt) = layersIt; - } - - if (triggerIt) { - (*triggerIt) = triggerPtrIt; - } - - return true; - } - } - } - - // if we get here, it means we didn't find the object anywhere in any of the layers - return false; -} - - -Bool LayersList::findLayerNamed(IN AsciiString layerName, OUT ListLayerIt *layerIt) -{ - if (layerName.isEmpty()) { - return false; - } - - for (ListLayerIt layersIt = mLayers.begin(); layersIt != mLayers.end(); ++layersIt) { - if (layersIt->layerName.compareNoCase(layerName) == 0) { - if (layerIt) { - (*layerIt) = layersIt; - } - - return true; - } - } - - // if we get here, it means we didn't find the named layer - return false; -} - -void LayersList::addMapObjectToLayer(IN MapObject *objectToAdd, IN ListLayerIt *layerIt) -{ - if (!objectToAdd) { - DEBUG_CRASH(("No object to add in addMapObjectToLayer. This should not happen. jkmcd")); - return; - } - - ListLayerIt layerToAddTo; - if (layerIt) { - layerToAddTo = *layerIt; - } else { - // By default, add to the default layer. - if (!findLayerNamed(AsciiString(TheDefaultLayerName.c_str()), &layerToAddTo)) { - // If we couldn't find that layer, then we're fuxored. - return; - } - } - - Dict *objProps = objectToAdd->getProperties(); - - if (layerToAddTo->layerName.compareNoCase(AsciiString(TheDefaultLayerName.c_str())) == 0) { - objProps->setAsciiString(TheKey_objectLayer, AsciiString::TheEmptyString); - } else { - objProps->setAsciiString(TheKey_objectLayer, layerToAddTo->layerName); - } - - // layerToAddTo now has a valid layer to add to. - layerToAddTo->objectsInLayer.push_back(objectToAdd); - - // only update this object. - HTREEITEM hItem = findTreeLayerNamed(layerToAddTo->layerName); - if (hItem) { - Bool dontcare; - AsciiString objName = objProps->getAsciiString(TheKey_uniqueID, &dontcare); - int iconToShow = (layerToAddTo->show ? 0 : 1); - mTree->InsertItem(objName.str(), iconToShow, iconToShow, hItem); - } - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) { - return; - } - - if (!layerToAddTo->show) { - objectToAdd->setFlag(FLAG_DONT_RENDER); - } else { - objectToAdd->clearFlag(FLAG_DONT_RENDER); - } - pDoc->invalObject(objectToAdd); - //PointerTool::clearSelection(); - -} - -void LayersList::addPolygonTriggerToLayer(IN PolygonTrigger *triggerToAdd, IN ListLayerIt *layerIt) -{ - if (!triggerToAdd) { - DEBUG_CRASH(("No trigger to add in addPolygonTriggerToLayer. This should not happen. jkmcd")); - return; - } - - ListLayerIt layerToAddTo; - if (layerIt) { - layerToAddTo = *layerIt; - } else { - // By default, add to the default layer. - if (!findLayerNamed(AsciiString(ThePolygonTriggerLayerName.c_str()), &layerToAddTo)) { - // If we couldn't find that layer, then we're fuxored. - return; - } - } - - if (layerToAddTo->layerName.compareNoCase(AsciiString(ThePolygonTriggerLayerName.c_str())) == 0) { - triggerToAdd->setLayerName(AsciiString::TheEmptyString); - } else { - triggerToAdd->setLayerName(layerToAddTo->layerName); - } - - // layerToAddTo now has a valid layer to add to. - layerToAddTo->polygonTriggersInLayer.push_back(triggerToAdd); - - // only update this object. - HTREEITEM hItem = findTreeLayerNamed(layerToAddTo->layerName); - if (hItem) { - const AsciiString& triggerName = triggerToAdd->getTriggerName(); - int iconToShow = (layerToAddTo->show ? 0 : 1); - mTree->InsertItem(triggerName.str(), iconToShow, iconToShow, hItem); - } - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) { - return; - } - - if (!layerToAddTo->show) { - triggerToAdd->setShouldRender(false); - } else { - triggerToAdd->setShouldRender(true); - } - -} - - -void LayersList::removeMapObjectFromLayer(IN MapObject *objectToRemove, IN ListLayerIt *layerIt, IN ListMapObjectPtrIt *objectIt) -{ - if (!objectToRemove) { - DEBUG_CRASH(("Attempted to remove null object from layers list. jkmcd")); - return; - } - - ListLayerIt layerToRemoveFrom; - ListMapObjectPtrIt objectBeingRemove; - - if (layerIt && objectIt) { - layerToRemoveFrom = (*layerIt); - objectBeingRemove = (*objectIt); - } else { - if (!findMapObjectAndList(objectToRemove, &layerToRemoveFrom, &objectBeingRemove)) { - DEBUG_CRASH(("Couldn't find the object anywhere. Why did we try to remove it? jkmcd")); - return; - } - } - - // only remove this object - HTREEITEM layer = findTreeLayerNamed(layerToRemoveFrom->layerName); - if (layer) { - Bool dontcare; - AsciiString objectUID = (*objectBeingRemove)->getProperties()->getAsciiString(TheKey_uniqueID, &dontcare); - HTREEITEM itemToDelete = findTreeObjectNamed(objectUID.str(), layer); - if (itemToDelete) { - mTree->DeleteItem(itemToDelete); - } - } - - // don't need to update the layer in the object because only 1 of 2 things can be happening: - // 1. We are about to delete the object - // 2. The object is about to be moved to the default layer (and will be updated anyways.) - - // layerToRemoveFrom and objectToRemove are now valid. Remove em. - layerToRemoveFrom->objectsInLayer.erase(objectBeingRemove); - -} - -void LayersList::removePolygonTriggerFromLayer(IN PolygonTrigger *triggerToRemove, IN ListLayerIt *layerIt, IN ListPolygonTriggerPtrIt *triggerIt) -{ - if (!triggerToRemove) { - DEBUG_CRASH(("Attempted to remove null trigger from layers list. jkmcd")); - return; - } - - ListLayerIt layerToRemoveFrom; - ListPolygonTriggerPtrIt triggerBeingRemove; - - if (layerIt && triggerIt) { - layerToRemoveFrom = (*layerIt); - triggerBeingRemove = (*triggerIt); - } else { - if (!findPolygonTriggerAndList(triggerToRemove, &layerToRemoveFrom, &triggerBeingRemove)) { - DEBUG_CRASH(("Couldn't find the object anywhere. Why did we try to remove it? jkmcd")); - return; - } - } - - // only remove this object - HTREEITEM layer = findTreeLayerNamed(layerToRemoveFrom->layerName); - if (layer) { - const AsciiString& triggerUID = (*triggerBeingRemove)->getTriggerName(); - HTREEITEM itemToDelete = findTreeObjectNamed(triggerUID.str(), layer); - if (itemToDelete) { - mTree->DeleteItem(itemToDelete); - } - } - - // don't need to update the layer in the object because only 1 of 2 things can be happening: - // 1. We are about to delete the object - // 2. The object is about to be moved to the default layer (and will be updated anyways.) - - // layerToRemoveFrom and objectToRemove are now valid. Remove em. - layerToRemoveFrom->polygonTriggersInLayer.erase(triggerBeingRemove); - -} - - -BOOL LayersList::OnInitDialog() -{ - // call the parent first - CDialog::OnInitDialog(); - - // Set up the initial tree. - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - - if (!pTree) { - return 1; - } - - CRect rect; - mTree = new CLLTreeCtrl; - pTree->GetWindowRect(&rect); - ScreenToClient(&rect); - - DWORD style = pTree->GetStyle(); - mTree->Create(style, rect, this, IDC_LL_TREE); - pTree->DestroyWindow(); - - pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - // pTree should == mTree now. - - mImageList.Create(16, 16, ILC_COLOR8, 3, 3); - - // If the order of these are changed, please update the enum in updateTreeImages. - mImageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_Show))); - mImageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_Hide))); - mImageList.Add(LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_Selected))); - - pTree->SetImageList(&mImageList, LVSIL_NORMAL); - pTree->InsertItem(TheDefaultLayerName.c_str(), 0, 0); - - - return 1; - -} - -// returning 0 means editing can continue. -// returning 1 means editing is cancelled -void LayersList::OnBeginEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult) -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - (*pResult) = 1; - return; - } - - TV_DISPINFO *ptvdi = (TV_DISPINFO*) pNotifyStruct; - if (ptvdi == nullptr) { - (*pResult) = 1; - return; - } - - if (!ptvdi->item.pszText) { - (*pResult) = 1; - return; - } - - if (strcmp(ptvdi->item.pszText, ThePolygonTriggerLayerName.c_str()) == 0) { - // Can't edit the default polygon trigger layer name. - (*pResult) = 1; - return; - } - - - CString str = pTree->GetItemText(ptvdi->item.hItem); - // if we can't find the layer of that name, then - if (!findLayerNamed(AsciiString(str))) { - // End the editing - (*pResult) = 1; - return; - } - - mCurrentlyEditingLabel = AsciiString(str); - (*pResult) = 0; -} - -void LayersList::OnEndEditLabel(NMHDR *pNotifyStruct, LRESULT* pResult) -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - TV_DISPINFO *ptvdi = (TV_DISPINFO*) pNotifyStruct; - if (!ptvdi->item.pszText) { - return; - } - - ListLayerIt layerIt; - if (!findLayerNamed(mCurrentlyEditingLabel, &layerIt)) { - return; - } - - AsciiString newLayerName(ptvdi->item.pszText); - Bool isDefaultLayer = mCurrentlyEditingLabel.compareNoCase(AsciiString(TheDefaultLayerName.c_str())) == 0; - Bool isActiveLayer = mCurrentlyEditingLabel.compareNoCase(TheActiveLayerName.c_str()) == 0; - AsciiString objectLayerName = isDefaultLayer ? AsciiString::TheEmptyString : newLayerName; - - // Keep persisted object and trigger assignments in sync with the renamed layer. - for (ListMapObjectPtrIt objectIt = layerIt->objectsInLayer.begin(); - objectIt != layerIt->objectsInLayer.end(); ++objectIt) { - (*objectIt)->getProperties()->setAsciiString(TheKey_objectLayer, objectLayerName); - } - for (ListPolygonTriggerPtrIt triggerIt = layerIt->polygonTriggersInLayer.begin(); - triggerIt != layerIt->polygonTriggersInLayer.end(); ++triggerIt) { - (*triggerIt)->setLayerName(newLayerName); - } - - layerIt->layerName = newLayerName; - if (isDefaultLayer) { - // update the default label to be the new layer name. - TheDefaultLayerName = layerIt->layerName.str(); - } - if (isActiveLayer) { - // The active layer is tracked by name. - TheActiveLayerName = layerIt->layerName.str(); - } - - // do this to prevent rebuilding the tree. - pTree->SetItemText(ptvdi->item.hItem, layerIt->layerName.str()); - - mCurrentlyEditingLabel = AsciiString::TheEmptyString; -} - - -void LayersList::OnNewLayer() -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - static char buffer[1024]; - snprintf(buffer, ARRAY_SIZE(buffer), "%s %d", TheDefaultNewLayerName.c_str(), newLayerNum); - addLayerNamed(buffer); - - HTREEITEM newItem = pTree->InsertItem(buffer, 0, 0); - pTree->SelectItem(newItem); - pTree->EditLabel(newItem); - - ++newLayerNum; -} - -void LayersList::OnDeleteLayer() -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - HTREEITEM item = pTree->GetSelectedItem(); - if (!item) { - return; - } - - CString catToDelete = pTree->GetItemText(item); - AsciiString asciiCatToDelete(catToDelete.GetBuffer(0)); - - if (asciiCatToDelete.compareNoCase(AsciiString(TheDefaultLayerName.c_str())) == 0) { - return; - } - - if (asciiCatToDelete.compareNoCase(AsciiString(ThePolygonTriggerLayerName.c_str())) == 0) { - return; - } - - ListLayerIt srcLayerIt, dstLayerIt; - if (!findLayerNamed(asciiCatToDelete, &srcLayerIt)) { - return; - } - - - if (asciiCatToDelete.compareNoCase(TheActiveLayerName.c_str()) == 0) { - // The active layer is being deleted. - TheActiveLayerName = AsciiString::TheEmptyString.str(); - updateTreeImages(); - - if (!findLayerNamed(AsciiString(TheDefaultLayerName.c_str()), &dstLayerIt)) { - return; - } - } else { - - if (!findLayerNamed(AsciiString(TheActiveLayerName.c_str()), &dstLayerIt)) { - if (!findLayerNamed(AsciiString(TheDefaultLayerName.c_str()), &dstLayerIt)) { - return; - } - } - } - - mergeLayerInto(srcLayerIt, dstLayerIt); - - HTREEITEM itemToRemove = findTreeLayerNamed(asciiCatToDelete); - if (itemToRemove) { - pTree->DeleteItem(itemToRemove); - } -} - -HTREEITEM LayersList::findTreeLayerNamed(const AsciiString& nameToFind) -{ - if (!mTree) { - return nullptr; - } - - HTREEITEM hItem = mTree->GetRootItem(); - - while (hItem) { - if (nameToFind.compareNoCase(mTree->GetItemText(hItem)) == 0) { - return hItem; - } - hItem = mTree->GetNextSiblingItem(hItem); - } - - return nullptr; -} - -HTREEITEM LayersList::findTreeObjectNamed(const AsciiString& objectToFind, HTREEITEM layerItem) -{ - if (!(layerItem && mTree)) { - return nullptr; - } - - HTREEITEM hItem = mTree->GetChildItem(layerItem); - - while (hItem) { - if (objectToFind.compareNoCase(mTree->GetItemText(hItem)) == 0) { - return hItem; - } - hItem = mTree->GetNextSiblingItem(hItem); - } - - return nullptr; -} - -void LayersList::OnHideShowLayer() -{ - // Hide/Show Layers List - // Toggle the current layer - AsciiString layerToToggle = mTree->getLastClickedLayer(); - ListLayerIt layerIt; - if (!findLayerNamed(layerToToggle, &layerIt)) { - return; - } - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) { - return; - } - - layerIt->show = !layerIt->show; - updateObjectRenderFlags(&layerIt); - updateTreeImages(); - //PointerTool::clearSelection(); -} - -void LayersList::OnOK() -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - // end editing in place with success - TreeView_EndEditLabelNow(pTree->GetSafeHwnd(), false); -} - -void LayersList::OnCancel() -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - // end editing in place with failure - TreeView_EndEditLabelNow(pTree->GetSafeHwnd(), true); -} - -void LayersList::OnMergeLayer(UINT commandID) -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - HTREEITEM item = pTree->GetSelectedItem(); - if (!item) { - return; - } - - int layerOffset = commandID - ID_LAYERSLIST_MERGELAYERINTO_BEGIN; - if (layerOffset < 0) { - return; - } - - ListLayerIt dstlayerIt = mLayers.begin(); - - while (layerOffset && dstlayerIt != mLayers.end()) { - ++dstlayerIt; - --layerOffset; - } - - AsciiString lastClickedLayer = mTree->getLastClickedLayer(); - ListLayerIt srclayerIt = mLayers.begin(); - while (srclayerIt != mLayers.end() && srclayerIt->layerName.compareNoCase(lastClickedLayer) != 0) { - ++srclayerIt; - } - - if (srclayerIt == mLayers.end()) { - return; - } - - mergeLayerInto(srclayerIt, dstlayerIt); -} - -void LayersList::OnMergeObject(UINT commandID) -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - HTREEITEM item = pTree->GetSelectedItem(); - if (!item) { - return; - } - - int layerOffset = commandID - ID_LAYERSLIST_MERGEOBJECTINTO_BEGIN; - if (layerOffset < 0) { - return; - } - - ListLayerIt layerIt = mLayers.begin(); - - while (layerOffset && layerIt != mLayers.end()) { - ++layerIt; - --layerOffset; - } - - AsciiString lastClickedObj = mTree->getLastClickedObject(); - MapObject *objToMove = findObjectByUID(lastClickedObj); - if (objToMove) { - changeMapObjectLayer(objToMove, layerIt->layerName); - } else { - PolygonTrigger* triggerToMove = findPolygonTriggerByUID(lastClickedObj); - changePolygonTriggerLayer(triggerToMove, layerIt->layerName); - } -} - -void LayersList::OnSelectActiveLayer() -{ - AsciiString lastClickedLayer = mTree->getLastClickedLayer(); - ListLayerIt srclayerIt = mLayers.begin(); - while (srclayerIt != mLayers.end() && srclayerIt->layerName.compareNoCase(lastClickedLayer) != 0) { - ++srclayerIt; - } - - if (srclayerIt == mLayers.end()) { - return; - } - - if (srclayerIt->layerName.compareNoCase(TheActiveLayerName.c_str()) == 0) { - // No layer is selected as default. - TheActiveLayerName = AsciiString::TheEmptyString.str(); - } else { - // Select this layer to be the default as new objects and triggers are added. - TheActiveLayerName = srclayerIt->layerName.str(); - // The active layer has to be shown. - srclayerIt->show = true; - - updateObjectRenderFlags(&srclayerIt); - } - - updateTreeImages(); -} - -void LayersList::updateObjectRenderFlags(ListLayerIt *updateLayer) -{ - ListLayerIt layerIt = *updateLayer; - - ListMapObjectPtrIt it; - for (it = layerIt->objectsInLayer.begin(); it != layerIt->objectsInLayer.end(); ++it) { - if (layerIt->show) { - (*it)->clearFlag(FLAG_DONT_RENDER); - } else { - (*it)->setFlag(FLAG_DONT_RENDER); - } - - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - pDoc->invalObject((*it)); - } - - ListPolygonTriggerPtrIt pit; - for (pit = layerIt->polygonTriggersInLayer.begin(); pit != layerIt->polygonTriggersInLayer.end(); ++pit) { - if (layerIt->show) { - (*pit)->setShouldRender(true); - } else { - (*pit)->setShouldRender(false); - } - //pDoc->invalObject((*it)); - } -} - -void LayersList::updateTreeImages() -{ - enum { - SHOW_ICON, - HIDE_ICON, - SELECTED_ICON, - }; - - if (!mTree) { - return; - } - - - ListLayerIt layerIt; - - for (layerIt = mLayers.begin(); layerIt != mLayers.end(); layerIt++) { - - HTREEITEM layer = findTreeLayerNamed(layerIt->layerName); - int childIcon = SHOW_ICON; - - if (layerIt->layerName.compareNoCase(TheActiveLayerName.c_str()) == 0) { - mTree->SetItemImage(layer, SELECTED_ICON, SELECTED_ICON); - childIcon = SHOW_ICON; - } else if (layerIt->show == false) { - childIcon = HIDE_ICON; - mTree->SetItemImage(layer, HIDE_ICON, HIDE_ICON); - } else { - childIcon = SHOW_ICON; - mTree->SetItemImage(layer, SHOW_ICON, SHOW_ICON); - } - - HTREEITEM item = mTree->GetChildItem(layer); - while (item) { - mTree->SetItemImage(item, childIcon, childIcon); - item = mTree->GetNextSiblingItem(item); - } - } -} - -void LayersList::OnMergeViewSelection(UINT commandID) -{ - int layerOffset = commandID - ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_BEGIN; - if (layerOffset < 0) { - return; - } - - ListLayerIt layerIt = mLayers.begin(); - - while (layerOffset && layerIt != mLayers.end()) { - ++layerIt; - --layerOffset; - } - - MapObject *mapObject = MapObject::getFirstMapObject(); - - std::stack allSelectedObjects; - while (mapObject) { - if (mapObject->isSelected()) { - allSelectedObjects.push(mapObject); - } - - mapObject = mapObject->getNext(); - } - - while (!allSelectedObjects.empty()) { - changeMapObjectLayer(allSelectedObjects.top(), layerIt->layerName); - allSelectedObjects.pop(); - } - - - PolygonTrigger *polygonTrigger = PolygonTrigger::getFirstPolygonTrigger(); - - std::stack allSelectedTriggers; - while (polygonTrigger) { - if (polygonTrigger->getSelected()) { - allSelectedTriggers.push(polygonTrigger); - } - - polygonTrigger = polygonTrigger->getNext(); - } - - while (!allSelectedTriggers.empty()) { - changePolygonTriggerLayer(allSelectedTriggers.top(), layerIt->layerName); - allSelectedTriggers.pop(); - } -} - - -//WST 11/23/2002 -void LayersList::unselectAllMapObjects() -{ - MapObject *mapObject = MapObject::getFirstMapObject(); - while (mapObject) { - mapObject->setSelected(false); - mapObject = mapObject->getNext(); - } -} - -void LayersList::unselectAllPolygonTriggers() -{ - PolygonTrigger *trigger = PolygonTrigger::getFirstPolygonTrigger(); - while (trigger) { - trigger->setSelected(false); - trigger = trigger->getNext(); - } -} - - -//WST 11/23/2002 -Bool LayersList::findAndSelectMapObject(AsciiString selectedItemAsciiString) -{ - MapObject *mapObject = MapObject::getFirstMapObject(); - - while (mapObject) { - Bool dontcare; - AsciiString mapObjectName = (mapObject)->getProperties()->getAsciiString(TheKey_uniqueID, &dontcare); - - if (mapObjectName.compareNoCase(selectedItemAsciiString) == 0) { - // Found it... select this object - mapObject->setSelected(true); - return (true); - } - mapObject = mapObject->getNext(); - } - - return (false); -} - - -Bool LayersList::findAndSelectPolygonTrigger(AsciiString selectedItemAsciiString) -{ - PolygonTrigger *trigger = PolygonTrigger::getFirstPolygonTrigger(); - - while (trigger) { - const AsciiString& triggerName = trigger->getTriggerName(); - - if (triggerName.compareNoCase(selectedItemAsciiString) == 0) { - // Found it... select this object - trigger->setSelected(true); - return (true); - } - trigger = trigger->getNext(); - } - return (false); -} - - - -//WST 11/21/02 New Design team request to select objects from layer view box -void LayersList::OnSelectLayerObject() -{ - CTreeCtrl *pTree = (CTreeCtrl*) GetDlgItem(IDC_LL_TREE); - if (!pTree) { - return; - } - - HTREEITEM item = pTree->GetSelectedItem(); - if (!item) { - return; - } - - - CString selectedItemCString = pTree->GetItemText(item); - AsciiString selectedItemAsciiString(selectedItemCString.GetBuffer(0)); - - //Unselect everything on the map and get ready to find the one user wanted - unselectAllMapObjects(); - unselectAllPolygonTriggers(); - - // Lets check and see if this is a layer that user selected or individual items - ListLayerIt srcLayerIt; - if (findLayerNamed(selectedItemAsciiString, &srcLayerIt)) { - // Ok, User selected the Layer, lets select all map objects in the layer - ListMapObjectPtrIt mopIt; - for (mopIt = srcLayerIt->objectsInLayer.begin(); mopIt != srcLayerIt->objectsInLayer.end(); ++mopIt) { - (*mopIt)->setSelected(true); - } - - ListPolygonTriggerPtrIt ptpIt; - for (ptpIt = srcLayerIt->polygonTriggersInLayer.begin(); ptpIt != srcLayerIt->polygonTriggersInLayer.end(); ++ptpIt) { - (*ptpIt)->setSelected(true); - } - } - else { - // User selected individual items - if (!findAndSelectMapObject(selectedItemAsciiString)) { - findAndSelectPolygonTrigger(selectedItemAsciiString); - } - } -} - -MapObject *LayersList::findObjectByUID(AsciiString objectIDToFind) -{ - MapObject *obj = MapObject::getFirstMapObject(); - Bool exists; - AsciiString testID; - while (obj) { - testID = obj->getProperties()->getAsciiString(TheKey_uniqueID, &exists); - if (exists) { - if (testID.compareNoCase(objectIDToFind) == 0) { - return obj; - } - } - obj = obj->getNext(); - } - - return nullptr; -} - -PolygonTrigger* LayersList::findPolygonTriggerByUID(AsciiString triggerIDToFind) -{ - PolygonTrigger *trigger = PolygonTrigger::getFirstPolygonTrigger(); - - while (trigger) { - const AsciiString& triggerName = trigger->getTriggerName(); - - if (triggerName.compareNoCase(triggerIDToFind) == 0) { - return (trigger); - } - trigger = trigger->getNext(); - } - - return (nullptr); -} - -BEGIN_MESSAGE_MAP(LayersList, CDialog) - ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_LL_TREE, OnBeginEditLabel) - ON_NOTIFY(TVN_ENDLABELEDIT, IDC_LL_TREE, OnEndEditLabel) - ON_COMMAND(ID_SELECTLAYEROBJECT, OnSelectLayerObject) - ON_COMMAND(ID_INSERTNEWLAYER, OnNewLayer) - ON_COMMAND(ID_DELETECURRENTLAYER, OnDeleteLayer) - ON_COMMAND(ID_HIDECURRENTLAYER, OnHideShowLayer) - ON_COMMAND(ID_SELECTACTIVELAYER, OnSelectActiveLayer) - ON_COMMAND_RANGE(ID_LAYERSLIST_MERGELAYERINTO_BEGIN, ID_LAYERSLIST_MERGELAYERINTO_END, OnMergeLayer) - ON_COMMAND_RANGE(ID_LAYERSLIST_MERGEOBJECTINTO_BEGIN, ID_LAYERSLIST_MERGEOBJECTINTO_END, OnMergeObject) - ON_COMMAND_RANGE(ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_BEGIN, ID_LAYERSLIST_MERGEVIEWSELECTIONINTO_END, OnMergeViewSelection) -END_MESSAGE_MAP() - - - -// for purposes of linking. -// TheDefaultLayerName is NOT constant, because it is okay to change it. -std::string LayersList::TheDefaultLayerName = "Default Object Layer"; -std::string LayersList::TheDefaultNewLayerName = "New Layer"; -std::string LayersList::ThePolygonTriggerLayerName = "Default Trigger Layer"; -std::string LayersList::TheActiveLayerName; -const std::string LayersList::TheUnmutableDefaultLayerName = "Default Object Layer"; -LayersList *TheLayersList = nullptr; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/LightOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/LightOptions.cpp deleted file mode 100644 index 3505989b30f..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/LightOptions.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// LightOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "LightOptions.h" -#include "WorldBuilderView.h" -#include "WorldBuilderDoc.h" -#include "wbview3d.h" -#include "Common/WellKnownKeys.h" - -LightOptions *LightOptions::m_staticThis = nullptr; -///////////////////////////////////////////////////////////////////////////// -/// LightOptions dialog trivial constructor - Create does the real work. - - -LightOptions::LightOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(LightOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void LightOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(LightOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -MapObject *LightOptions::getSingleSelectedLight() -{ - MapObject *pMapObj; - MapObject *theMapObj = nullptr; -// Bool found = false; - Int selCount=0; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected()) { - if (pMapObj->isLight()) { - theMapObj = pMapObj; - } - selCount++; - } - } - if (selCount==1 && theMapObj) { - return theMapObj; - } - return(nullptr); -} - - -void LightOptions::updateTheUI() -{ - MapObject *theMapObj = getSingleSelectedLight(); - if (!theMapObj) return; - Dict *props = theMapObj->getProperties(); - - CString str; - - Real lightHeightAboveTerrain, lightInnerRadius, lightOuterRadius; - RGBColor lightAmbientColor, lightDiffuseColor; - - lightHeightAboveTerrain = props->getReal(TheKey_lightHeightAboveTerrain); - lightInnerRadius = props->getReal(TheKey_lightInnerRadius); - lightOuterRadius = props->getReal(TheKey_lightOuterRadius); - lightAmbientColor.setFromInt(props->getInt(TheKey_lightAmbientColor)); - lightDiffuseColor.setFromInt(props->getInt(TheKey_lightDiffuseColor)); - - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_RA_EDIT); - if (pEdit) { - str.Format("%.2f", lightAmbientColor.red); - pEdit->SetWindowText(str); - } - pEdit = m_staticThis->GetDlgItem(IDC_GA_EDIT); - if (pEdit) { - str.Format("%.2f", lightAmbientColor.green); - pEdit->SetWindowText(str); - } - pEdit = m_staticThis->GetDlgItem(IDC_BA_EDIT); - if (pEdit) { - str.Format("%.2f", lightAmbientColor.blue); - pEdit->SetWindowText(str); - } - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) { - str.Format("%.2f", lightHeightAboveTerrain); - pEdit->SetWindowText(str); - } - pEdit = m_staticThis->GetDlgItem(IDC_RADIUS_EDIT); - if (pEdit) { - str.Format("%.2f", lightOuterRadius); - pEdit->SetWindowText(str); - } -} - -void LightOptions::update() -{ - if (m_staticThis) { - m_staticThis->updateTheUI(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// LightOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL LightOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - - m_staticThis = this; - m_updating = false; - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -BEGIN_MESSAGE_MAP(LightOptions, COptionsPanel) - //{{AFX_MSG_MAP(LightOptions) - ON_EN_CHANGE(IDC_RA_EDIT, OnChangeLightEdit) - ON_EN_CHANGE(IDC_GA_EDIT, OnChangeLightEdit) - ON_EN_CHANGE(IDC_BA_EDIT, OnChangeLightEdit) - ON_EN_CHANGE(IDC_HEIGHT_EDIT, OnChangeLightEdit) - ON_EN_CHANGE(IDC_RADIUS_EDIT, OnChangeLightEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -void LightOptions::OnChangeLightEdit() -{ - MapObject *theMapObj = getSingleSelectedLight(); - if (!theMapObj) return; - if (!theMapObj->isLight()) return; - - Real lightHeightAboveTerrain, lightInnerRadius, lightOuterRadius; - RGBColor lightAmbientColor, lightDiffuseColor; - - Dict *props = theMapObj->getProperties(); - lightHeightAboveTerrain = props->getReal(TheKey_lightHeightAboveTerrain); - lightInnerRadius = props->getReal(TheKey_lightInnerRadius); - lightOuterRadius = props->getReal(TheKey_lightOuterRadius); - lightAmbientColor.setFromInt(props->getInt(TheKey_lightAmbientColor)); - lightDiffuseColor.setFromInt(props->getInt(TheKey_lightDiffuseColor)); - - Real clr; - char buffer[_MAX_PATH]; - - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_RA_EDIT); - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) lightAmbientColor.red = clr; - } - pEdit = m_staticThis->GetDlgItem(IDC_GA_EDIT); - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) lightAmbientColor.green = clr; - } - pEdit = m_staticThis->GetDlgItem(IDC_BA_EDIT); - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) lightAmbientColor.blue = clr; - } - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - Real r; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &r)) lightHeightAboveTerrain = r; - } - pEdit = m_staticThis->GetDlgItem(IDC_RADIUS_EDIT); - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &r)) lightOuterRadius = r; - } - lightDiffuseColor.red = 0; - lightDiffuseColor.green = 0; - lightDiffuseColor.blue = 0; - lightInnerRadius = lightOuterRadius/2; - - props->setReal(TheKey_lightHeightAboveTerrain, lightHeightAboveTerrain); - props->setReal(TheKey_lightInnerRadius, lightInnerRadius); - props->setReal(TheKey_lightOuterRadius, lightOuterRadius); - props->setInt(TheKey_lightAmbientColor, lightAmbientColor.getAsInt()); - props->setInt(TheKey_lightDiffuseColor, lightDiffuseColor.getAsInt()); - - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - pView->invalObjectInView(theMapObj); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MainFrm.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MainFrm.cpp deleted file mode 100644 index 6395b3b4439..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MainFrm.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MainFrm.cpp : implementation of the CMainFrame class -// - -#include "StdAfx.h" -#include "MainFrm.h" - -#include "Common/GlobalData.h" - -#include "DrawObject.h" -#include "LayersList.h" -#include "WHeightMapEdit.h" -#include "wbview3d.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" - -#include "ScriptDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd) - -BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_WM_MOVE() - ON_COMMAND(ID_VIEW_BRUSHFEEDBACK, OnViewBrushfeedback) - ON_UPDATE_COMMAND_UI(ID_VIEW_BRUSHFEEDBACK, OnUpdateViewBrushfeedback) - ON_WM_DESTROY() - ON_WM_TIMER() - ON_WM_CANCELMODE() - ON_COMMAND(ID_EDIT_CAMERAOPTIONS, OnEditCameraoptions) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -CMainFrame *CMainFrame::TheMainFrame = nullptr; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - TheMainFrame = this; - m_curOptions = nullptr; - m_hAutoSaveTimer = 0; - m_autoSaving = false; - m_layersList = nullptr; - m_scriptDialog = nullptr; -} - -CMainFrame::~CMainFrame() -{ - delete m_layersList; - m_layersList = nullptr; - - delete m_scriptDialog; - m_scriptDialog = nullptr; - - SaveBarState("MainFrame"); - TheMainFrame = nullptr; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "AutoSave", m_autoSave); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "AutoSaveIntervalSeconds", m_autoSaveInterval); - CoUninitialize(); -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - adjustWindowSize(); - CRect frameRect; - GetWindowRect(&frameRect); - - CWnd *pDesk = GetDesktopWindow(); - CRect top; - pDesk->GetWindowRect(&top); - top.left += 10; - top.top += 10; - top.top = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Top", top.top); - top.left =::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Left", top.left); - SetWindowPos(nullptr, top.left, top.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - GetWindowRect(&frameRect); - EnableDocking(CBRS_ALIGN_TOP); - -#if 0 // For a floating toolbar. -#define WRAP(btn) m_floatingToolBar.SetButtonStyle( btn, m_floatingToolBar.GetButtonStyle( btn )|TBBS_WRAPPED) - if (!m_floatingToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_LEFT - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED ) || - !m_floatingToolBar.LoadToolBar(IDR_TOOLBAR2)) - WRAP(1); - WRAP(4); - WRAP(6); - WRAP(9); - WRAP(11); - WRAP(14); - WRAP(16); -#undef WRAP - CPoint pos(frameRect.left,frameRect.top+60); - this->FloatControlBar(&m_floatingToolBar, pos, CBRS_ALIGN_LEFT); - m_floatingToolBar.EnableDocking(CBRS_ALIGN_TOP); -#endif - - if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) - { - DEBUG_CRASH(("Failed to create status bar")); - } - - if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP - | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED ) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP); - - frameRect.left = frameRect.right; - frameRect.top = ::AfxGetApp()->GetProfileInt(OPTIONS_PANEL_SECTION, "Top", frameRect.top); - frameRect.left =::AfxGetApp()->GetProfileInt(OPTIONS_PANEL_SECTION, "Left", frameRect.left); - - - - m_brushOptions.Create(IDD_BRUSH_OPTIONS, this); - m_brushOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_brushOptions.GetWindowRect(&frameRect); - m_optionsPanelWidth = frameRect.Width(); - m_optionsPanelHeight = frameRect.Height(); - - m_featherOptions.Create(IDD_FEATHER_OPTIONS, this); - m_featherOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_featherOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - - m_noOptions.Create(IDD_NO_OPTIONS, this); - m_noOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_noOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_terrainMaterial.Create(IDD_TERRAIN_MATERIAL, this); - m_terrainMaterial.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_terrainMaterial.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_blendMaterial.Create(IDD_BLEND_MATERIAL, this); - m_blendMaterial.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_blendMaterial.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_moundOptions.Create(IDD_MOUND_OPTIONS, this); - m_moundOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_moundOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_rulerOptions.Create(IDD_RULER_OPTIONS, this); - m_rulerOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_rulerOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_objectOptions.Create(IDD_OBJECT_OPTIONS, this); - m_objectOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_objectOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_fenceOptions.Create(IDD_FENCE_OPTIONS, this); - m_fenceOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_fenceOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_mapObjectProps.Create(IDD_MAPOBJECT_PROPS, this); - m_mapObjectProps.makeMain(); - m_mapObjectProps.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_mapObjectProps.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_roadOptions.Create(IDD_ROAD_OPTIONS, this); - m_roadOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_roadOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_waypointOptions.Create(IDD_WAYPOINT_OPTIONS, this); - m_waypointOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_waypointOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_waterOptions.Create(IDD_WATER_OPTIONS, this); - m_waterOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_waterOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_lightOptions.Create(IDD_LIGHT_OPTIONS, this); - m_lightOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_lightOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_meshMoldOptions.Create(IDD_MESHMOLD_OPTIONS, this); - m_meshMoldOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_meshMoldOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_buildListOptions.Create(IDD_BUILD_LIST_PANEL, this); - m_buildListOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_buildListOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_groveOptions.Create(IDD_GROVE_OPTIONS, this); - m_groveOptions.makeMain(); - m_groveOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_groveOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_rampOptions.Create(IDD_RAMP_OPTIONS, this); - m_rampOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_rampOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - m_scorchOptions.Create(IDD_SCORCH_OPTIONS, this); - m_scorchOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_scorchOptions.GetWindowRect(&frameRect); - if (m_optionsPanelWidth < frameRect.Width()) m_optionsPanelWidth = frameRect.Width(); - if (m_optionsPanelHeight < frameRect.Height()) m_optionsPanelHeight = frameRect.Height(); - - frameRect.top = ::AfxGetApp()->GetProfileInt(GLOBALLIGHT_OPTIONS_PANEL_SECTION, "Top", frameRect.top); - frameRect.left =::AfxGetApp()->GetProfileInt(GLOBALLIGHT_OPTIONS_PANEL_SECTION, "Left", frameRect.left); - - m_globalLightOptions.Create(IDD_GLOBAL_LIGHT_OPTIONS, this); - m_globalLightOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_globalLightOptions.GetWindowRect(&frameRect); - m_globalLightOptionsWidth = frameRect.Width(); - m_globalLightOptionsHeight = frameRect.Height(); - - frameRect.top = ::AfxGetApp()->GetProfileInt(CAMERA_OPTIONS_PANEL_SECTION, "Top", frameRect.top); - frameRect.left =::AfxGetApp()->GetProfileInt(CAMERA_OPTIONS_PANEL_SECTION, "Left", frameRect.left); - - m_cameraOptions.Create(IDD_CAMERA_OPTIONS, this); - m_cameraOptions.SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_cameraOptions.GetWindowRect(&frameRect); - - // now, setup the Layers Panel - m_layersList = new LayersList(LayersList::IDD, this); - m_layersList->Create(LayersList::IDD, this); - m_layersList->ShowWindow(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowLayersList", 0) ? SW_SHOW : SW_HIDE); - - CRect optionsRect; - m_globalLightOptions.GetWindowRect(&optionsRect); - m_layersList->SetWindowPos(nullptr, optionsRect.left, optionsRect.bottom + 100, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - - Int sbf = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowBrushFeedback", 1); - if (sbf != 0) { - DrawObject::enableFeedback(); - } else { - DrawObject::disableFeedback(); - } - - Int autoSave = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "AutoSave", 1); - m_autoSave = autoSave != 0; - autoSave = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "AutoSaveIntervalSeconds", 120); - m_autoSaveInterval = autoSave; - m_hAutoSaveTimer = this->SetTimer(1, m_autoSaveInterval*1000, nullptr); - -#if USE_STREAMING_AUDIO - StartMusic(); -#endif - - return 0; -} - -void CMainFrame::adjustWindowSize() -{ - HWND hDesk = ::GetDesktopWindow(); - CRect top; - ::GetWindowRect(hDesk, &top); - top.right -= 2*::GetSystemMetrics(SM_CYCAPTION); - top.bottom -= 3*::GetSystemMetrics(SM_CYCAPTION); - - CRect client, window; - Int borderX = ::GetSystemMetrics(SM_CXEDGE); -// Int borderY = ::GetSystemMetrics(SM_CYEDGE); - Int viewWidth = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Width", THREE_D_VIEW_WIDTH); - Int viewHeight = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Height", THREE_D_VIEW_HEIGHT); - WbView3d * pView = CWorldBuilderDoc::GetActive3DView(); - if (pView) { - pView->GetClientRect(&client); - } else { - GetClientRect(&client); - client.right -= 2*borderX; - } - int widthDelta = client.Width() - (viewWidth); - int heightDelta = client.Height() - (viewHeight); - this->GetWindowRect(window); - Int newWidth = window.Width()-widthDelta; - Int newHeight = window.Height()-heightDelta; - this->SetWindowPos(nullptr, 0, - 0, newWidth, newHeight, - SWP_NOMOVE|SWP_NOZORDER); // MainFrm.cpp sets the top and left. - if (pView) { - pView->reset3dEngineDisplaySize(viewWidth, viewHeight); - } - m_3dViewWidth = viewWidth; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CFrameWnd::PreCreateWindow(cs) ) - return FALSE; - return TRUE; -} - -void CMainFrame::ResetWindowPositions() -{ - if (m_curOptions == nullptr) { - m_curOptions = &m_brushOptions; - } - SetWindowPos(nullptr, 20, 20, 0, 0, SWP_NOSIZE|SWP_NOZORDER); - ShowWindow(SW_SHOW); - m_curOptions->SetWindowPos(nullptr, 40, 40, 0, 0, SWP_NOSIZE|SWP_NOZORDER); - m_curOptions->ShowWindow(SW_SHOW); - CView *pView = CWorldBuilderDoc::GetActive2DView(); - if (pView) { - CWnd *pParent = pView->GetParentFrame(); - if (pParent) { - pParent->SetWindowPos(nullptr, 60, 60, 0, 0, SWP_NOSIZE|SWP_NOZORDER); - } - } - CPoint pos(20,200); - - this->FloatControlBar(&m_floatingToolBar, pos, CBRS_ALIGN_LEFT); - m_floatingToolBar.SetWindowPos(nullptr, pos.x, pos.y, 0, 0, SWP_NOSIZE|SWP_NOZORDER); - m_floatingToolBar.ShowWindow(SW_SHOW); -} - -void CMainFrame::showOptionsDialog(Int dialogID) -{ - CWnd *newOptions = nullptr; - switch(dialogID) { - case IDD_BRUSH_OPTIONS : newOptions = &m_brushOptions; break; - case IDD_TERRAIN_MATERIAL: newOptions = &m_terrainMaterial; break; - case IDD_BLEND_MATERIAL: newOptions = &m_blendMaterial; break; - case IDD_OBJECT_OPTIONS: newOptions = &m_objectOptions; break; - case IDD_FENCE_OPTIONS: newOptions = &m_fenceOptions; break; - case IDD_MAPOBJECT_PROPS: newOptions = &m_mapObjectProps; break; - case IDD_ROAD_OPTIONS:newOptions = &m_roadOptions; break; - case IDD_MOUND_OPTIONS:newOptions = &m_moundOptions; break; - case IDD_RULER_OPTIONS:newOptions = &m_rulerOptions; break; - case IDD_FEATHER_OPTIONS:newOptions = &m_featherOptions; break; - case IDD_MESHMOLD_OPTIONS:newOptions = &m_meshMoldOptions; break; - case IDD_WAYPOINT_OPTIONS:newOptions = &m_waypointOptions; break; - case IDD_WATER_OPTIONS:newOptions = &m_waterOptions; break; - case IDD_LIGHT_OPTIONS:newOptions = &m_lightOptions; break; - case IDD_BUILD_LIST_PANEL:newOptions = &m_buildListOptions; break; - case IDD_GROVE_OPTIONS:newOptions = &m_groveOptions; break; - case IDD_RAMP_OPTIONS:newOptions = &m_rampOptions; break; - case IDD_SCORCH_OPTIONS:newOptions = &m_scorchOptions; break; - case IDD_NO_OPTIONS:newOptions = &m_noOptions; break; - default : break; - } - CRect frameRect; - if (newOptions && newOptions != m_curOptions) { - newOptions->GetWindowRect(&frameRect); - if (m_curOptions) { - m_curOptions->GetWindowRect(&frameRect); - } - newOptions->SetWindowPos(m_curOptions, frameRect.left, frameRect.top, - m_optionsPanelWidth, m_optionsPanelHeight, - SWP_NOZORDER | SWP_NOACTIVATE ); - ::AfxGetApp()->WriteProfileInt(OPTIONS_PANEL_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(OPTIONS_PANEL_SECTION, "Left", frameRect.left); - newOptions->ShowWindow(SW_SHOWNA); - if (m_curOptions) { - m_curOptions->ShowWindow(SW_HIDE); - } - m_curOptions = newOptions; - } -} - -void CMainFrame::OnEditGloballightoptions() -{ - m_globalLightOptions.ShowWindow(SW_SHOWNA); -} - -void CMainFrame::onEditScripts() -{ - delete m_scriptDialog; - - CRect frameRect; - GetWindowRect(&frameRect); - - // Setup the Script Dialog. - // This needs to be recreated each time so that it will have the current data. - m_scriptDialog = new ScriptDialog(this); - m_scriptDialog->Create(IDD_ScriptDialog, this); - m_scriptDialog->SetWindowPos(nullptr, frameRect.left, frameRect.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - m_scriptDialog->GetWindowRect(&frameRect); - m_scriptDialog->ShowWindow(SW_SHOWNA); -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef RTS_DEBUG -void CMainFrame::AssertValid() const -{ - CFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CFrameWnd::Dump(dc); -} - -#endif //RTS_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - -#if DEAD - void CMainFrame::OnEditContouroptions() - { - ContourOptions contourOptsDialog(this); - contourOptsDialog.DoModal(); - } -#endif - -void CMainFrame::OnMove(int x, int y) -{ - CFrameWnd::OnMove(x, y); - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Left", frameRect.left); - } -} - -void CMainFrame::OnViewBrushfeedback() -{ - if (DrawObject::isFeedbackEnabled()) { - DrawObject::disableFeedback(); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowBrushFeedback", 0); - } else { - DrawObject::enableFeedback(); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowBrushFeedback", 1); - } -} - -void CMainFrame::OnUpdateViewBrushfeedback(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(DrawObject::isFeedbackEnabled()?1:0); -} - -void CMainFrame::OnDestroy() -{ - if (m_hAutoSaveTimer) { - KillTimer(m_hAutoSaveTimer); - } - m_hAutoSaveTimer = 0; - CFrameWnd::OnDestroy(); -} - -void CMainFrame::OnTimer(UINT nIDEvent) -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc && pDoc->needAutoSave()) { - m_autoSaving = true; - HCURSOR old = SetCursor(::LoadCursor(nullptr, IDC_WAIT)); - SetMessageText("Auto Saving map..."); - pDoc->autoSave(); - if (old) SetCursor(old); - SetMessageText("Auto Save Complete."); - m_autoSaving = false; - } -} - -void CMainFrame::OnEditCameraoptions() -{ - m_cameraOptions.ShowWindow(SW_SHOWNA); -} - -void CMainFrame::handleCameraChange() -{ - m_cameraOptions.update(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MapPreview.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MapPreview.cpp deleted file mode 100644 index d232f729992..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MapPreview.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: MapPreview.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Oct 2002 -// -// Filename: MapPreview.cpp -// -// author: Chris Huybregts -// -// purpose: Contains the code used to generate and save the map preview to -// the map file. (Original code was taken from the Radar code in -// game engine). -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -#include "StdAfx.h" -#include "resource.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "MapPreview.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/MapReaderWriterInfo.h" -#include "Common/FileSystem.h" -#include "WWLib/TARGA.h" -#include "Common/DataChunk.h" -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -Bool localIsUnderwater( Real x, Real y); -// ------------------------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------------------------ -MapPreview::MapPreview() -{ - memset(m_pixelBuffer, 0xffffffff, sizeof(m_pixelBuffer)); -} - -void MapPreview::save( CString mapName ) -{ - CString newStr = mapName; - newStr.Replace(".map", ".tga"); - buildMapPreviewTexture( newStr ); - -/* - chunkWriter.openDataChunk("MapPreview", K_MAPPREVIEW_VERSION_1); - chunkWriter.writeInt(MAP_PREVIEW_WIDTH); - chunkWriter.writeInt(MAP_PREVIEW_HEIGHT); - DEBUG_LOG(("BeginMapPreviewInfo")); - for(Int i = 0; i < MAP_PREVIEW_HEIGHT; ++i) - { - for(Int j = 0; j < MAP_PREVIEW_WIDTH; ++j) - { - chunkWriter.writeInt(m_pixelBuffer[i][j]); - DEBUG_LOG(("x:%d, y:%d, %X", j, i, m_pixelBuffer[i][j])); - } - } - chunkWriter.closeDataChunk(); - DEBUG_LOG(("EndMapPreviewInfo")); -*/ -} - -void MapPreview::interpolateColorForHeight( RGBColor *color, - Real height, - Real hiZ, - Real midZ, - Real loZ ) -{ - const Real howBright = 0.30f; // bigger is brighter (0.0 to 1.0) - const Real howDark = 0.60f; // bigger is darker (0.0 to 1.0) - - // sanity on map height (flat maps bomb) - if (hiZ == midZ) - hiZ = midZ+0.1f; - if (midZ == loZ) - loZ = midZ-0.1f; - if (hiZ == loZ) - hiZ = loZ+0.2f; - -// Real heightPercent = height / (hiZ - loZ); - Real t; - RGBColor colorTarget; - - // if "over" the middle height, interpolate lighter - if( height >= midZ ) - { - - // how far are we from the middleZ towards the hi Z - t = (height - midZ) / (hiZ - midZ); - - // compute what our "lightest" color possible we want to use is - colorTarget.red = color->red + (1.0f - color->red) * howBright; - colorTarget.green = color->green + (1.0f - color->green) * howBright; - colorTarget.blue = color->blue + (1.0f - color->blue) * howBright; - - } - else // interpolate darker - { - - // how far are we from the middleZ towards the low Z - t = (midZ - height) / (midZ - loZ); - - // compute what the "darkest" color possible we want to use is - colorTarget.red = color->red + (0.0f - color->red) * howDark; - colorTarget.green = color->green + (0.0f - color->green) * howDark; - colorTarget.blue = color->blue + (0.0f - color->blue) * howDark; - - } - - // interpolate toward the target color - color->red = color->red + (colorTarget.red - color->red) * t; - color->green = color->green + (colorTarget.green - color->green) * t; - color->blue = color->blue + (colorTarget.blue - color->blue) * t; - - // keep the color real - if( color->red < 0.0f ) - color->red = 0.0f; - if( color->red > 1.0f ) - color->red = 1.0f; - if( color->green < 0.0f ) - color->green = 0.0f; - if( color->green > 1.0f ) - color->green = 1.0f; - if( color->blue < 0.0f ) - color->blue = 0.0f; - if( color->blue > 1.0f ) - color->blue = 1.0f; - -} - -Bool MapPreview::mapPreviewToWorld(const ICoord2D *radar, Coord3D *world) -{ - Int x, y; - - // sanity - if( radar == nullptr || world == nullptr ) - return FALSE; - - // get the coords - x = radar->x; - y = radar->y; - - // more sanity - if( x < 0 ) - x = 0; - if( x >= MAP_PREVIEW_WIDTH ) - x = MAP_PREVIEW_WIDTH - 1; - if( y < 0 ) - y = 0; - if( y >= MAP_PREVIEW_HEIGHT ) - y = MAP_PREVIEW_HEIGHT - 1; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - Real xSample, ySample; - - xSample = INT_TO_REAL(pMap->getXExtent() - (2 * pMap->getBorderSize())) / MAP_PREVIEW_WIDTH; - ySample = INT_TO_REAL(pMap->getYExtent() - (2 * pMap->getBorderSize())) / MAP_PREVIEW_HEIGHT; - // translate to world - world->x = x * xSample + pMap->getBorderSize(); - world->y = y * ySample + pMap->getBorderSize(); - - // find the terrain height here -// world->z = pMap->gethigh -// TheTerrainLogic->getGroundHeight( world->x, world->y ); - - return TRUE; - -} - -void MapPreview::buildMapPreviewTexture( CString tgaName ) -{ -// SurfaceClass *surface; - RGBColor waterColor; - - // we will want to reconstruct our new view box now - //m_reconstructViewBox = TRUE; - - // setup our water color - waterColor.red = 0.55f; - waterColor.green = 0.55f; - waterColor.blue = 1.0f; - - // fill the terrain texture with a representation of the terrain -// Real mapDepth = m_mapExtent.depth(); - - // build the terrain - RGBColor sampleColor; - RGBColor color; - Int i, j, samples; - Int x, y, z; - ICoord2D radarPoint, boundary; - Coord3D worldPoint; - Real getTerrainAverageZ = 0; - Real maxHeight = 0; - Real minHeight = 100.0f; - Real tempHeight = 0; - Int terrainCount = 0; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - pMap->getBoundary(0, &boundary ); - for(i = 0; i < MAP_PREVIEW_HEIGHT; ++i) - { - for(j = 0; j < MAP_PREVIEW_WIDTH; ++j) - { - radarPoint.x = j; - radarPoint.y = i; - mapPreviewToWorld( &radarPoint, &worldPoint ); - tempHeight = pMap->getHeight(worldPoint.x, worldPoint.y); - getTerrainAverageZ += tempHeight; - if(tempHeight > maxHeight) - maxHeight = tempHeight; - if(tempHeight < minHeight) - minHeight = tempHeight; - ++terrainCount; - } - } - getTerrainAverageZ = getTerrainAverageZ /terrainCount; - - - -// Color paddingColor = GameMakeColor( 100, 100, 100, 255 ); - for( y = 0; y < MAP_PREVIEW_HEIGHT; y++ ) - { - - for( x = 0; x < MAP_PREVIEW_WIDTH; x++ ) - { - - // what point are we inspecting - radarPoint.x = x; - radarPoint.y = y; - mapPreviewToWorld( &radarPoint, &worldPoint ); - - - // get height of the terrain at this sample point - z = pMap->getHeight(worldPoint.x, worldPoint.y); - - // create a color based on the Z height of the map - //Real waterZ; - - if( localIsUnderwater( MAP_XY_FACTOR *(worldPoint.x - pMap->getBorderSize()), MAP_XY_FACTOR * ( worldPoint.y - pMap->getBorderSize())) ) - { - const Int waterSamplesAway = 1; // how many "tiles" from the center tile we will sample away - // to average a color for the tile color - - sampleColor.red = sampleColor.green = sampleColor.blue = 0.0f; - samples = 0; - - for( j = y - waterSamplesAway; j <= y + waterSamplesAway; j++ ) - { - - if( j >= 0 && j < MAP_PREVIEW_HEIGHT ) - { - - for( i = x - waterSamplesAway; i <= x + waterSamplesAway; i++ ) - { - - if( i >= 0 && i < MAP_PREVIEW_WIDTH ) - { - - // the the world point we are concerned with - radarPoint.x = i; - radarPoint.y = j; - mapPreviewToWorld( &radarPoint, &worldPoint ); - - // get Z at this sample height - Real underwaterZ = pMap->getHeight(worldPoint.x, worldPoint.y); - - // get color for this Z and add to our sample color - if( localIsUnderwater( MAP_XY_FACTOR *(worldPoint.x - pMap->getBorderSize()), MAP_XY_FACTOR * ( worldPoint.y - pMap->getBorderSize()))) - { - - // this is our "color" for water - color = waterColor; - - // interpolate the water color for height in the water table - interpolateColorForHeight( &color, underwaterZ, pMap->getMaxHeightValue(),getTerrainAverageZ, pMap->getMinHeightValue() ); - - // add color to our samples - sampleColor.red += color.red; - sampleColor.green += color.green; - sampleColor.blue += color.blue; - samples++; - - } - - } - - } - - } - - } - - // prevent divide by zeros - if( samples == 0 ) - samples = 1; - - // set the color to an average of the colors read - color.red = sampleColor.red / (Real)samples; - color.green = sampleColor.green / (Real)samples; - color.blue = sampleColor.blue / (Real)samples; - - } - else // regular terrain ... - { - const Int samplesAway = 1; // how many "tiles" from the center tile we will sample away - // to average a color for the tile color - - sampleColor.red = sampleColor.green = sampleColor.blue = 0.0f; - samples = 0; - - for( j = y - samplesAway; j <= y + samplesAway; j++ ) - { - - if( j >= 0 && j < MAP_PREVIEW_HEIGHT ) - { - - for( i = x - samplesAway; i <= x + samplesAway; i++ ) - { - - if( i >= 0 && i < MAP_PREVIEW_WIDTH ) - { - - // the the world point we are concerned with - radarPoint.x = i; - radarPoint.y = j; -// radarPoint.x = x; -// radarPoint.y = y; - mapPreviewToWorld( &radarPoint, &worldPoint ); - - // get the color at this point - pMap->getTerrainColorAt( MAP_XY_FACTOR *(worldPoint.x - pMap->getBorderSize()) ,MAP_XY_FACTOR * ( worldPoint.y - pMap->getBorderSize()), &color ); - - // interpolate the color for height - interpolateColorForHeight( &color, z, - maxHeight, getTerrainAverageZ, minHeight); - //pMap->getMaxHeightValue(),getTerrainAverageZ, pMap->getMinHeightValue() ); - - // add color to our sample - sampleColor.red += color.red; - sampleColor.green += color.green; - sampleColor.blue += color.blue; - samples++; - - } - - } - - } - - } - - // prevent divide by zeros - if( samples == 0 ) - samples = 1; - - // set the color to an average of the colors read - color.red = sampleColor.red / (Real)samples; - color.green = sampleColor.green / (Real)samples; - color.blue = sampleColor.blue / (Real)samples; - - } - - // - // draw the pixel for the terrain at this point, note that because of the orientation - // of our world we draw it with positive y in the "up" direction - // - // FYI: I tried making this faster by pulling out all the code inside DrawPixel - // and locking only once ... but it made absolutely *no* performance difference, - // the sampling and interpolation algorithm for generating pretty looking terrain - // and water for the radar is just, well, expensive. - // - m_pixelBuffer[y][x]= 255 | (REAL_TO_INT(color.red *255) << 8) | (REAL_TO_INT(color.green *255) << 16) | REAL_TO_INT(color.blue * 255)<< 24; - - } - - } - { - Targa tga; - tga.Header.Width = MAP_PREVIEW_WIDTH; - tga.Header.Height = MAP_PREVIEW_HEIGHT; - tga.Header.PixelDepth = 32; - tga.Header.ImageType = TGA_TRUECOLOR; - tga.SetImage((char *)m_pixelBuffer); - tga.Save(tgaName,TGAF_IMAGE, FALSE); - } - -} - - - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MapSettings.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MapSettings.cpp deleted file mode 100644 index 3c1b832903a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MapSettings.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MapSettings.cpp : implementation file -// - -#define DEFINE_TIME_OF_DAY_NAMES -#define DEFINE_WEATHER_NAMES - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "MapSettings.h" -#include "Common/GlobalData.h" -#include "Common/WellKnownKeys.h" -#include "Compression.h" - -///////////////////////////////////////////////////////////////////////////// -// MapSettings dialog - - -MapSettings::MapSettings(CWnd* pParent /*=nullptr*/) - : CDialog(MapSettings::IDD, pParent) -{ - //{{AFX_DATA_INIT(MapSettings) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void MapSettings::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(MapSettings) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(MapSettings, CDialog) - //{{AFX_MSG_MAP(MapSettings) - ON_CBN_SELENDOK(IDC_MAP_TIMEOFDAY, OnChangeMapTimeofday) - ON_CBN_SELENDOK(IDC_MAP_WEATHER, OnChangeMapWeather) - ON_EN_CHANGE(IDC_MAP_TITLE, OnChangeMapTitle) - ON_CBN_SELENDOK(IDC_MAP_COMPRESSION, OnChangeMapCompression) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// MapSettings message handlers - -void MapSettings::OnChangeMapTimeofday() -{ -} - -void MapSettings::OnChangeMapWeather() -{ -} - -BOOL MapSettings::OnInitDialog() -{ - CDialog::OnInitDialog(); - - Int i; - - CComboBox *timeofday = (CComboBox*)GetDlgItem(IDC_MAP_TIMEOFDAY); - timeofday->ResetContent(); - for (i = TIME_OF_DAY_FIRST; i < TIME_OF_DAY_COUNT; i++) - { - timeofday->AddString(TimeOfDayNames[i]); - } - timeofday->SetCurSel(TheGlobalData->m_timeOfDay-TIME_OF_DAY_FIRST); - - - CComboBox *weather = (CComboBox*)GetDlgItem(IDC_MAP_WEATHER); - weather->ResetContent(); - for (i = 0; i < WEATHER_COUNT; i++) - { - weather->AddString(WeatherNames[i]); - } - weather->SetCurSel(TheGlobalData->m_weather); - - Dict *worldDict = MapObject::getWorldDict(); - Bool exists = false; - AsciiString mapName = worldDict->getAsciiString(TheKey_mapName, &exists); - CEdit *mapTitle = (CEdit *)GetDlgItem(IDC_MAP_TITLE); - if (exists) - { - mapTitle->SetWindowText(mapName.str()); - } - else - { - mapTitle->SetWindowText(""); - } - - CComboBox *compressionComboBox = (CComboBox*)GetDlgItem(IDC_MAP_COMPRESSION); - compressionComboBox->ResetContent(); - for (i = COMPRESSION_MIN; i <= COMPRESSION_MAX; i++) - { - compressionComboBox->AddString(CompressionManager::getCompressionNameByType((CompressionType)i)); - } - exists = FALSE; - Int index = worldDict->getInt(TheKey_compression, &exists); - if (!exists) - index = CompressionManager::getPreferredCompression(); - compressionComboBox->SetCurSel(index); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void MapSettings::OnOK() -{ - CComboBox *timeofday = (CComboBox*)GetDlgItem(IDC_MAP_TIMEOFDAY); - CComboBox *weather = (CComboBox*)GetDlgItem(IDC_MAP_WEATHER); - TimeOfDay tod = (TimeOfDay) (timeofday->GetCurSel()+TIME_OF_DAY_FIRST); - Weather theWeather = (Weather) weather->GetCurSel(); - - TheWritableGlobalData->setTimeOfDay(tod); - TheWritableGlobalData->m_weather = theWeather; - - CEdit *mapTitle = (CEdit *)GetDlgItem(IDC_MAP_TITLE); - char munkee[256]; - AsciiString mapName; - mapTitle->GetWindowText(munkee, 256); - mapName = munkee; - Dict *worldDict = MapObject::getWorldDict(); - worldDict->setAsciiString(TheKey_mapName, mapName); - - CComboBox *compressionComboBox = (CComboBox*)GetDlgItem(IDC_MAP_COMPRESSION); - CompressionType compType = (CompressionType) (compressionComboBox->GetCurSel()+COMPRESSION_MIN); - worldDict->setInt(TheKey_compression, compType); - - CDialog::OnOK(); -} - -void MapSettings::OnChangeMapTitle() -{ - // TODO: If this is a RICHEDIT control, the control will not - // send this notification unless you override the CDialog::OnInitDialog() - // function and call CRichEditCtrl().SetEventMask() - // with the ENM_CHANGE flag ORed into the mask. - - // TODO: Add your control notification handler code here - -} - -void MapSettings::OnChangeMapCompression() -{ - // TODO: Add your control notification handler code here - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp deleted file mode 100644 index d97e2bfc42d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MeshMoldOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "MeshMoldOptions.h" -#include "Common/FileSystem.h" - -///////////////////////////////////////////////////////////////////////////// -// MeshMoldOptions dialog - -Real MeshMoldOptions::m_currentHeight=0; -Real MeshMoldOptions::m_currentScale=1.0f; -Int MeshMoldOptions::m_currentAngle=0; -MeshMoldOptions * MeshMoldOptions::m_staticThis=nullptr; -Bool MeshMoldOptions::m_doingPreview=false; -Bool MeshMoldOptions::m_raiseOnly=false; -Bool MeshMoldOptions::m_lowerOnly=false; - -MeshMoldOptions::MeshMoldOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(MeshMoldOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void MeshMoldOptions::DoDataExchange(CDataExchange* pDX) -{ - COptionsPanel::DoDataExchange(pDX); - //{{AFX_DATA_MAP(MeshMoldOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL MeshMoldOptions::OnInitDialog() -{ - COptionsPanel::OnInitDialog(); - - m_updating = true; - m_anglePopup.SetupPopSliderButton(this, IDC_ANGLE_POPUP, this); - m_scalePopup.SetupPopSliderButton(this, IDC_SCALE_POPUP, this); - m_HeightPopup.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - - CWnd *pWnd = GetDlgItem(IDC_MESHMOLD_TREEVIEW); - CRect rect(0,0,100,100); - if (pWnd) pWnd->GetWindowRect(&rect); - - CButton *pRaise = (CButton *)GetDlgItem(IDC_RAISE_LOWER); - if (pRaise) { - pRaise->SetCheck(1); - } - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_moldTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_moldTreeView.ShowWindow(SW_SHOW); - - { - char fileBuf[_MAX_PATH]; - Int i; - - FilenameList filenameList; - TheFileSystem->getFileListInDirectory(".\\data\\Editor\\Molds\\", "*.w3d", filenameList, FALSE); - - if (filenameList.size() > 0) { - HTREEITEM child = nullptr; - FilenameList::iterator it = filenameList.begin(); - do { - AsciiString filename = *it; - - int len = filename.getLength(); - if (len<5) continue; - strlcpy(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); - for (i=strlen(fileBuf)-1; i>0; i--) { - if (fileBuf[i] == '.') { - // strip off .w3d file extension. - fileBuf[i] = 0; - } - } - char *nameStart = fileBuf; - for (i=0; im_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } - MeshMoldTool::updateMeshLocation(false); -} - -void MeshMoldOptions::setScale(Real scale) -{ - char buffer[12]; - snprintf(buffer, ARRAY_SIZE(buffer), "%d", (int)floor(scale*100)); - m_currentScale = scale; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SCALE_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } - MeshMoldTool::updateMeshLocation(false); -} - -void MeshMoldOptions::setAngle(Int angle) -{ - char buffer[12]; - snprintf(buffer, ARRAY_SIZE(buffer), "%d", angle); - m_currentAngle = angle; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_ANGLE_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } -} - - -void MeshMoldOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - case IDC_ANGLE_POPUP: - *pMin = MIN_ANGLE; - *pMax = MAX_ANGLE; - *pInitial = m_currentAngle; - *pLineSize = 1; - break; - - case IDC_HEIGHT_POPUP: - *pMin = MIN_HEIGHT; - *pMax = MAX_HEIGHT; - *pInitial = floor(m_currentHeight/MAP_HEIGHT_SCALE+0.5f); - *pLineSize = 1; - break; - - case IDC_SCALE_POPUP: - *pMin = MIN_SCALE; - *pMax = MAX_SCALE; - *pInitial = floor(m_currentScale*100 + 0.5f); - if (*pInitial > *pMax/2) *pMax = *pInitial*2; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Missing ID.")); - break; - } -} - -void MeshMoldOptions::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - switch (sliderID) { - - case IDC_ANGLE_POPUP: - m_currentAngle = theVal; - str.Format("%d",m_currentAngle); - pEdit = m_staticThis->GetDlgItem(IDC_ANGLE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - break; - - case IDC_HEIGHT_POPUP: - m_currentHeight = theVal*MAP_HEIGHT_SCALE; - str.Format("%.2f",m_currentHeight); - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(str); - MeshMoldTool::updateMeshLocation(false); - break; - - case IDC_SCALE_POPUP: - m_currentScale = theVal/100.0f; //scale is in % - str.Format("%d",theVal); - pEdit = m_staticThis->GetDlgItem(IDC_SCALE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - MeshMoldTool::updateMeshLocation(false); - break; - - default: - DEBUG_CRASH(("Missing ID.")); - break; - } -} - -void MeshMoldOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_ANGLE_POPUP: - break; - case IDC_HEIGHT_POPUP: - break; - case IDC_SCALE_POPUP: - break; - - default: - DEBUG_CRASH(("Missing ID.")); - break; - } - -} - -BEGIN_MESSAGE_MAP(MeshMoldOptions, COptionsPanel) - //{{AFX_MSG_MAP(MeshMoldOptions) - ON_BN_CLICKED(IDC_PREVIEW, OnPreview) - ON_BN_CLICKED(IDC_APPLY_MESH, OnApplyMesh) - ON_EN_CHANGE(IDC_SCALE_EDIT, OnChangeScaleEdit) - ON_EN_CHANGE(IDC_HEIGHT_EDIT, OnChangeHeightEdit) - ON_EN_CHANGE(IDC_ANGLE_EDIT, OnChangeAngleEdit) - ON_BN_CLICKED(IDC_RAISE, OnRaise) - ON_BN_CLICKED(IDC_RAISE_LOWER, OnRaiseLower) - ON_BN_CLICKED(IDC_LOWER, OnLower) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// MeshMoldOptions message handlers - -void MeshMoldOptions::OnPreview() -{ - CButton *pButton = (CButton*)this->GetDlgItem(IDC_PREVIEW); - m_doingPreview = (pButton->GetCheck() == 1); - MeshMoldTool::updateMeshLocation(true); -} - -void MeshMoldOptions::OnApplyMesh() -{ - MeshMoldTool::apply(CWorldBuilderDoc::GetActiveDoc()); -} - -void MeshMoldOptions::OnChangeScaleEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SCALE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int scale; - m_updating = true; - if (1==sscanf(buffer, "%d", &scale)) { - m_currentScale = scale/100.0f; - MeshMoldTool::updateMeshLocation(false); - } - m_updating = false; - } -} - -void MeshMoldOptions::OnChangeHeightEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Real height; - m_updating = true; - if (1==sscanf(buffer, "%f", &height)) { - m_currentHeight = height; - MeshMoldTool::updateMeshLocation(false); - } - m_updating = false; - } -} - -void MeshMoldOptions::OnChangeAngleEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_ANGLE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int angle; - m_updating = true; - if (1==sscanf(buffer, "%d", &angle)) { - m_currentAngle = angle; - MeshMoldTool::updateMeshLocation(false); - } - m_updating = false; - } -} - - -BOOL MeshMoldOptions::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_moldTreeView.m_hWnd) { - - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[_MAX_PATH]; - HTREEITEM hItem = m_moldTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_moldTreeView.GetItem(&item); - m_meshModelName = AsciiString(buffer); - if (m_doingPreview) { - MeshMoldTool::updateMeshLocation(false); - } - } - } - return COptionsPanel::OnNotify(wParam, lParam, pResult); -} - - -void MeshMoldOptions::OnRaise() -{ - m_raiseOnly = true; - m_lowerOnly = false; - if (m_doingPreview) { - MeshMoldTool::updateMeshLocation(false); - } -} - -void MeshMoldOptions::OnRaiseLower() -{ - m_raiseOnly = false; - m_lowerOnly = false; - if (m_doingPreview) { - MeshMoldTool::updateMeshLocation(false); - } -} - -void MeshMoldOptions::OnLower() -{ - m_raiseOnly = false; - m_lowerOnly = true; - if (m_doingPreview) { - MeshMoldTool::updateMeshLocation(false); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp deleted file mode 100644 index dcf0e7a02f3..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldTool.cpp +++ /dev/null @@ -1,276 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MeshMoldTool.cpp -// Terrain shaping tool for worldbuilder. -// Author: John Ahlquist, Oct 2001 - - -#include "StdAfx.h" -#include "resource.h" - -#include "MeshMoldTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "WorldBuilder.h" -#include "DrawObject.h" -#include "wbview3d.h" -#include "WW3D2/mesh.h" -#include "WW3D2/meshmdl.h" -#include "W3DDevice/GameClient/HeightMap.h" -// -// MeshMoldTool class. -// - -Bool MeshMoldTool::m_tracking = false; -Coord3D MeshMoldTool::m_toolPos; -WorldHeightMapEdit *MeshMoldTool::m_htMapEditCopy = nullptr; - -/// Constructor -MeshMoldTool::MeshMoldTool() : - Tool(ID_MOLD_TOOL, IDC_MOLD_POINTER) -{ - m_offsettingZ = false; -} - -/// Destructor -MeshMoldTool::~MeshMoldTool() -{ - REF_PTR_RELEASE(m_htMapEditCopy); -} - - -/// Shows the mesh mold options panel. -void MeshMoldTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_MESHMOLD_OPTIONS); - m_prevXIndex = -1; - m_prevYIndex = -1; - if (m_tracking) { - DrawObject::setDoMeshFeedback(true); - } -} - -/// Shows the mesh mold options panel. -void MeshMoldTool::deactivate() -{ - m_tracking = false; - DrawObject::setDoMeshFeedback(false); - REF_PTR_RELEASE(m_htMapEditCopy); - if (MeshMoldOptions::isDoingPreview()) { - // Update the height map in case we were doing previews. - IRegion2D partialRange = {0,0,0,0}; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - pDoc->updateHeightMap(m_htMapEditCopy, false, partialRange); - } - } -} - -/// Start tool. -/** Setup the tool to start mesh molding - make a copy of the height map -to edit, another copy because we need it :), and call mouseMovedDown. */ -void MeshMoldTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - if (!m_tracking) { - m_tracking = true; - m_toolPos = cpt; - Real height = TheTerrainRenderObject->getHeightMapHeight(cpt.x, cpt.y, nullptr); - MeshMoldOptions::setHeight(height); - } - DrawObject::setDoMeshFeedback(true); - m_prevDocPt = cpt; - Bool shiftKey = (0x8000 & ::GetAsyncKeyState(VK_SHIFT))!=0; - if (shiftKey) { - m_offsettingZ = true; - m_prevViewPt = viewPt; - } else { - m_offsettingZ = false; - } - - mouseMoved(m, viewPt, pView, pDoc); -} - -/// End tool. -/** Finish the tool operation - create a command, pass it to the -doc to execute, and cleanup ref'd objects. */ -void MeshMoldTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - m_offsettingZ = false; -} - -/// Track the mouse. -void MeshMoldTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - if (m_offsettingZ) { - Real deltaZ = (m_prevViewPt.y - viewPt.y)*MAP_HEIGHT_SCALE*0.5f; - MeshMoldOptions::setHeight(MeshMoldOptions::getHeight()+deltaZ); - } else { - m_toolPos.x += cpt.x-m_prevDocPt.x; - m_toolPos.y += cpt.y-m_prevDocPt.y; - } - updateMeshLocation(false); - m_prevViewPt = viewPt; - m_prevDocPt = cpt; -} - - -/// Update the mesh location onscreen. -void MeshMoldTool::updateMeshLocation(Bool changePreview) -{ - if (m_tracking) { - m_toolPos.z = MeshMoldOptions::getHeight(); - DrawObject::setFeedbackPos(m_toolPos); - if (MeshMoldOptions::isDoingPreview() || changePreview) { - // doing preview - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (MeshMoldOptions::isDoingPreview()) { - applyMesh(pDoc); - } else if (m_htMapEditCopy) { - // Unapply the mesh :) - Int i, j; - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - for (j=0; jgetYExtent(); j++) { - for (i=0; igetXExtent(); i++) { - m_htMapEditCopy->setHeight(i, j, pMap->getHeight(i, j)); - } - } - IRegion2D partialRange = {0,0,0,0}; - pDoc->updateHeightMap(m_htMapEditCopy, false, partialRange); - } - } - } -} - -/// Apply the tool. -/** Apply the height mesh mold at the current point. */ -void MeshMoldTool::apply(CWorldBuilderDoc *pDoc) -{ - applyMesh(pDoc); - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, m_htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(m_htMapEditCopy); - -} - -/// Apply the tool. -/** Apply the height mesh mold at the current point. */ -void MeshMoldTool::applyMesh(CWorldBuilderDoc *pDoc) -{ - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - - HCURSOR old = SetCursor(::LoadCursor(nullptr, IDC_WAIT)); - if (m_htMapEditCopy == nullptr) { - m_htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - } else { - // Restore original heights to edit copy. - Int i, j; - for (j=0; jgetYExtent(); j++) { - for (i=0; igetXExtent(); i++) { - m_htMapEditCopy->setHeight(i, j, pMap->getHeight(i, j)); - } - } - } - Int border = m_htMapEditCopy->getBorderSize(); - WbView3d *p3View = pDoc->GetActive3DView(); - if (p3View) { - DrawObject *pDraw = p3View->getDrawObject(); - if (pDraw) { - MeshClass *pMesh = pDraw->peekMesh(); - if (pMesh) { - SphereClass bounds; - pDraw->getMeshBounds(&bounds); - bounds.Center *= MeshMoldOptions::getScale(); - bounds.Radius *= MeshMoldOptions::getScale(); - Int minX = ceil((m_toolPos.x+bounds.Center.X-bounds.Radius)/MAP_XY_FACTOR); - Int minY = ceil((m_toolPos.y+bounds.Center.Y-bounds.Radius)/MAP_XY_FACTOR); - Int maxX = floor((m_toolPos.x+bounds.Center.X+bounds.Radius)/MAP_XY_FACTOR); - Int maxY = floor((m_toolPos.y+bounds.Center.Y+bounds.Radius)/MAP_XY_FACTOR); - maxX++; maxY++; - if (minX<0) minX = 0; - if (minY<0) minY = 0; - if (maxX > m_htMapEditCopy->getXExtent()) { - maxX = m_htMapEditCopy->getXExtent(); - } - if (maxY > m_htMapEditCopy->getYExtent()) { - maxY = m_htMapEditCopy->getYExtent(); - } - Int i, j; - for (j=minY; jCast_Ray(rayCollide)) { - // get the point of intersection according to W3D - Vector3 intersection = castResult.ContactPoint; - intersection.Z *= MeshMoldOptions::getScale(); - Int newHeight = floor( ((intersection.Z+MeshMoldOptions::getHeight())/MAP_HEIGHT_SCALE)+0.5); - // check boundary values - if (newHeight < m_htMapEditCopy->getMinHeightValue()) newHeight = m_htMapEditCopy->getMinHeightValue(); - if (newHeight > m_htMapEditCopy->getMaxHeightValue()) newHeight = m_htMapEditCopy->getMaxHeightValue(); - Bool apply = true; - if (MeshMoldOptions::isRaisingOnly()) { - apply = newHeight > m_htMapEditCopy->getHeight(i+border, j+border); - } else if (MeshMoldOptions::isLoweringOnly()) { - apply = newHeight < m_htMapEditCopy->getHeight(i+border, j+border); - } - if (apply) { - m_htMapEditCopy->setHeight(i+border, j+border, newHeight); - } - } - } - } - IRegion2D partialRange; - // Offset by 2, because the normals change out two past the actual height change. - partialRange.lo.x = minX-2+border; - partialRange.hi.x = maxX+2+border; - partialRange.lo.y = minY-2+border; - partialRange.hi.y = maxY+2+border; - pDoc->updateHeightMap(m_htMapEditCopy, true, partialRange); - - } - } - } - if (old) SetCursor(old); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MoundOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MoundOptions.cpp deleted file mode 100644 index 63a05e0dde6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MoundOptions.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MoundOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "MoundOptions.h" -#include "WorldBuilderView.h" -#include "MoundTool.h" - -MoundOptions *MoundOptions::m_staticThis = nullptr; -Int MoundOptions::m_currentWidth = 0; -Int MoundOptions::m_currentHeight = 0; -Int MoundOptions::m_currentFeather = 0; -///////////////////////////////////////////////////////////////////////////// -/// MoundOptions dialog trivial constructor - Create does the real work. - - -MoundOptions::MoundOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(MoundOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void MoundOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(MoundOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -/// Sets the feather value in the dialog. -/** Update the value in the edit control and the slider. */ -void MoundOptions::setFeather(Int feather) -{ - CString buf; - buf.Format("%d", feather); - m_currentFeather = feather; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - -/// Sets the brush width value in the dialog. -/** Update the value in the edit control and the slider. */ -void MoundOptions::setWidth(Int width) -{ - CString buf; - buf.Format("%d", width); - m_currentWidth = width; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - -void MoundOptions::setHeight(Int height) -{ - char buffer[12]; - snprintf(buffer, ARRAY_SIZE(buffer), "%d", height); - m_currentHeight = height; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } -} - - - -///////////////////////////////////////////////////////////////////////////// -// MoundOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL MoundOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - m_brushWidthPopup.SetupPopSliderButton(this, IDC_SIZE_POPUP, this); - m_brushFeatherPopup.SetupPopSliderButton(this, IDC_FEATHER_POPUP, this); - m_brushHeightPopup.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - - - m_staticThis = this; - m_updating = false; - setFeather(m_currentFeather); - setWidth(m_currentWidth); - setHeight(m_currentHeight); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/// Handles feather edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void MoundOptions::OnChangeFeatherEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int feather; - m_updating = true; - if (1==sscanf(buffer, "%d", &feather)) { - m_currentFeather = feather; - MoundTool::setFeather(m_currentFeather); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void MoundOptions::OnChangeSizeEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int width; - m_updating = true; - if (1==sscanf(buffer, "%d", &width)) { - m_currentWidth = width; - MoundTool::setWidth(m_currentWidth); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void MoundOptions::OnChangeHeightEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int height; - m_updating = true; - if (1==sscanf(buffer, "%d", &height)) { - m_currentHeight = height; - MoundTool::setMoundHeight(m_currentHeight); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE); - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -void MoundOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_SIZE_POPUP: - *pMin = MIN_BRUSH_SIZE; - *pMax = MAX_BRUSH_SIZE; - *pInitial = m_currentWidth; - *pLineSize = 1; - break; - - case IDC_HEIGHT_POPUP: - *pMin = MIN_MOUND_HEIGHT; - *pMax = MAX_MOUND_HEIGHT; - *pInitial = m_currentHeight; - *pLineSize = 1; - break; - - case IDC_FEATHER_POPUP: - *pMin = MIN_FEATHER; - *pMax = MAX_FEATHER; - *pInitial = m_currentFeather; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void MoundOptions::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - switch (sliderID) { - - case IDC_SIZE_POPUP: - m_currentWidth = theVal; - str.Format("%d",m_currentWidth); - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - MoundTool::setWidth(m_currentWidth); - break; - - case IDC_HEIGHT_POPUP: - m_currentHeight = theVal; - str.Format("%d",m_currentHeight); - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(str); - MoundTool::setMoundHeight(m_currentHeight); - break; - - case IDC_FEATHER_POPUP: - m_currentFeather = theVal; - str.Format("%d",m_currentFeather); - pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - if (pEdit) pEdit->SetWindowText(str); - MoundTool::setFeather(m_currentFeather); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void MoundOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - break; - case IDC_HEIGHT_POPUP: - break; - case IDC_FEATHER_POPUP: - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - - -BEGIN_MESSAGE_MAP(MoundOptions, COptionsPanel) - //{{AFX_MSG_MAP(MoundOptions) - ON_WM_HSCROLL() - ON_EN_CHANGE(IDC_FEATHER_EDIT, OnChangeFeatherEdit) - ON_EN_CHANGE(IDC_SIZE_EDIT, OnChangeSizeEdit) - ON_EN_CHANGE(IDC_HEIGHT_EDIT, OnChangeHeightEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MoundTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MoundTool.cpp deleted file mode 100644 index 24a7f1291a7..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MoundTool.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MoundTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - - -#include "StdAfx.h" -#include "resource.h" - -#include "MoundTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MoundOptions.h" -// -// MoundTool class. -// - -Int MoundTool::m_moundHeight=0; -Int MoundTool::m_brushWidth; -Int MoundTool::m_brushFeather; - - - -/// Constructor -MoundTool::MoundTool() : - Tool(ID_BRUSH_ADD_TOOL, IDC_BRUSH_CROSS) -{ - m_htMapEditCopy = nullptr; - m_htMapSaveCopy = nullptr; - m_raising = true; -} - -/// Destructor -MoundTool::~MoundTool() -{ - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapSaveCopy); -} - - -void MoundTool::setMoundHeight(Int height) -{ - if (m_moundHeight != height) { - m_moundHeight = height; - // notify mound options panel - MoundOptions::setHeight(height); - DrawObject::setBrushFeedbackParms(false, m_brushWidth, m_brushFeather); - } -}; -/// Set the brush width and notify the height options panel of the change. -void MoundTool::setWidth(Int width) -{ - if (m_brushWidth != width) { - m_brushWidth = width; - // notify brush palette options panel - MoundOptions::setWidth(width); - DrawObject::setBrushFeedbackParms(false, m_brushWidth, m_brushFeather); - } -}; - -/// Set the brush feather and notify the height options panel of the change. -void MoundTool::setFeather(Int feather) -{ - if (m_brushFeather != feather) { - m_brushFeather = feather; - // notify height palette options panel - MoundOptions::setFeather(feather); - DrawObject::setBrushFeedbackParms(false, m_brushWidth, m_brushFeather); - } -}; - - -/// Shows the brush options panel. -void MoundTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_MOUND_OPTIONS); - DrawObject::setDoBrushFeedback(true); - DrawObject::setBrushFeedbackParms(false, m_brushWidth, m_brushFeather); -} - -void MoundTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - // just in case, release it. - REF_PTR_RELEASE(m_htMapEditCopy); - m_htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - m_prevXIndex = -1; - m_prevYIndex = -1; - REF_PTR_RELEASE(m_htMapSaveCopy); - m_htMapSaveCopy = m_htMapEditCopy->duplicate(); - m_lastMoveTime = ::GetTickCount(); - m_lastMoveTime -= MIN_DELAY_TIME + 1; // Make the tool fire the first time. - mouseMoved(m, viewPt, pView, pDoc); -} - -void MoundTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, m_htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(m_htMapEditCopy); - REF_PTR_RELEASE(m_htMapSaveCopy); -} - -void MoundTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - DrawObject::setFeedbackPos(cpt); - if (m != TRACK_L) return; - - Int curTime = ::GetTickCount(); - Int deltaTime = curTime - m_lastMoveTime; - if (deltaTime < MIN_DELAY_TIME) return; - m_lastMoveTime = curTime; - - - int brushWidth = m_brushWidth; - int setFeather = m_brushFeather; - if (setFeather>0) { - brushWidth += 2*setFeather; - brushWidth += 2; // for round brush. - } - - CPoint ndx; - getCenterIndex(&cpt, m_brushWidth, &ndx, pDoc); - - // do nothing if in the same cell.... - // if (m_prevXIndex == ndx.x && m_prevYIndex == ndx.y) return; - - m_prevXIndex = ndx.x; - m_prevYIndex = ndx.y; - - int sub = brushWidth/2; - int add = brushWidth-sub; - - Int htDelta = m_moundHeight; - if (!m_raising) htDelta = -m_moundHeight; - // round brush - Int i, j; - for (i=ndx.x-sub; i=m_htMapEditCopy->getXExtent()) { - continue; - } - for (j=ndx.y-sub; j=m_htMapEditCopy->getYExtent()) { - continue; - } -#if 1 - // New floating point based blending calculation. jba. - Real blendFactor; - blendFactor = calcRoundBlendFactor(ndx, i, j, m_brushWidth, m_brushFeather); - Int curHeight = m_htMapEditCopy->getHeight(i,j); - float fNewHeight = (blendFactor*(htDelta+curHeight))+((1.0f-blendFactor)*curHeight); - Int newHeight = floor(fNewHeight+0.5f); - - // check boundary values - if (newHeight < m_htMapSaveCopy->getMinHeightValue()) newHeight = m_htMapSaveCopy->getMinHeightValue(); - if (newHeight > m_htMapSaveCopy->getMaxHeightValue()) newHeight = m_htMapSaveCopy->getMaxHeightValue(); - - m_htMapEditCopy->setHeight(i, j, newHeight); - pDoc->invalCell(i, j); -#else - // Previous integer calculated mounding and blending. - // If not re-enabled by Dec 2001, delete as obsolete. - Int xd = abs( (2*(i-(ndx.x-sub)))+1 - brushWidth); - Int yd = abs( (2*(j-(ndx.y-sub)))+1 - brushWidth); - - float delta = (float)sqrt(xd*xd+yd*yd); - //Int curHeight = m_htMapSaveCopy->getHeight(i,j); - Int curHeight = m_htMapEditCopy->getHeight(i,j); - Int newHeight = curHeight + htDelta; - - // check boundary values - if (newHeight < m_htMapSaveCopy->getMinHeightValue()) newHeight = m_htMapSaveCopy->getMinHeightValue(); - if (newHeight > m_htMapSaveCopy->getMaxHeightValue()) newHeight = m_htMapSaveCopy->getMaxHeightValue(); - - if (deltasetHeight(i, j, newHeight); - pDoc->invalCell(i, j); - } else if (deltagetMinHeightValue()) newHeight = m_htMapSaveCopy->getMinHeightValue(); - if (newHeight > m_htMapSaveCopy->getMaxHeightValue()) newHeight = m_htMapSaveCopy->getMaxHeightValue(); - if (newHeight > m_htMapEditCopy->getHeight(i,j)) { - if (htDelta<0) { - newHeight = m_htMapEditCopy->getHeight(i,j); - } - } else { - if (htDelta>0) { - newHeight = m_htMapEditCopy->getHeight(i,j); - } - } - - m_htMapEditCopy->setHeight(i, j, newHeight); - pDoc->invalCell(i, j); - } -#endif - } - } - - IRegion2D partialRange; - partialRange.lo.x = ndx.x - brushWidth; - partialRange.hi.x = ndx.x + brushWidth; - partialRange.lo.y = ndx.y - brushWidth; - partialRange.hi.y = ndx.y + brushWidth; - pDoc->updateHeightMap(m_htMapEditCopy, true, partialRange); -} - -/************************************************************************* -** DigTool -***************************************************************************/ -/// Constructor -DigTool::DigTool() -{ - m_toolID = ID_BRUSH_SUBTRACT_TOOL; - m_raising = false; // digging. -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MyToolbar.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MyToolbar.cpp deleted file mode 100644 index 7847a4e6e10..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MyToolbar.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// MyToolBar.cpp -// Class to handle cell size slider. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" - -#include "Lib/BaseType.h" -#include "MyToolbar.h" -#include "resource.h" -#include "WorldBuilderView.h" -#include "WorldBuilderDoc.h" - -BEGIN_MESSAGE_MAP(CellSizeToolBar, CDialogBar) - //{{AFX_MSG_MAP(CellSizeToolBar) - ON_WM_VSCROLL() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -#define MAX_POS 7 -#define MIN_POS 1 - -CellSizeToolBar *CellSizeToolBar::m_staticThis = nullptr; - -void CellSizeToolBar::CellSizeChanged(Int cellSize) -{ - Int newSize = 1; - Int i; - for (i=MIN_POS; i= cellSize) break; - } - i = MAX_POS - i + MIN_POS; // Invert the range - if (m_staticThis != nullptr) { - m_staticThis->m_cellSlider.SetPos(i); - } -} - -CellSizeToolBar::~CellSizeToolBar() -{ - m_staticThis = nullptr; -} - -void CellSizeToolBar::SetupSlider() -{ - CWnd *pWnd = GetDlgItem(ID_SLIDER); - CRect rect; - pWnd->GetWindowRect(&rect); - - pWnd->DestroyWindow(); - ScreenToClient(&rect); - - m_cellSlider.Create(TBS_VERT|TBS_AUTOTICKS|TBS_RIGHT, rect, this, ID_SLIDER); - m_cellSlider.SetRange(MIN_POS,MAX_POS); - m_cellSlider.SetPos(3); - m_cellSlider.ShowWindow(SW_SHOW); - m_staticThis = this; -} - -void CellSizeToolBar::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - if (nSBCode != TB_THUMBTRACK) { - nPos = m_cellSlider.GetPos(); - } - UnsignedInt i; - // invert - nPos = MAX_POS - nPos + MIN_POS; - int newSize = 1; - for (i=1; i64) return; - - CWorldBuilderView* pView = CWorldBuilderDoc::GetActive2DView(); - if (pView == nullptr || newSize == pView->getCellSize()) return; - pView->setCellSize(newSize); -} - -LRESULT CellSizeToolBar::WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) -{ - if (message == WM_VSCROLL) { - int nScrollCode = (short)LOWORD(wParam); - int nPos = (short)HIWORD(wParam); - OnVScroll(nScrollCode, nPos, nullptr); - return(0); - } - return(CDialogBar::WindowProc(message, wParam, lParam)); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp deleted file mode 100644 index 5a7172d7359..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/NewHeightMap.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// NewHeightMap.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "NewHeightMap.h" - -///////////////////////////////////////////////////////////////////////////// -// CNewHeightMap dialog - - -CNewHeightMap::CNewHeightMap(TNewHeightInfo *hiP, const char *label, CWnd* pParent /*=nullptr*/) - : CDialog(CNewHeightMap::IDD, pParent) -{ - mHeightInfo = *hiP; - m_label = label; - //{{AFX_DATA_INIT(CNewHeightMap) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void CNewHeightMap::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CNewHeightMap) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CNewHeightMap, CDialog) - //{{AFX_MSG_MAP(CNewHeightMap) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CNewHeightMap message handlers - -BOOL CNewHeightMap::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *edit = GetDlgItem(IDC_INITIAL_HEIGHT); - CString val; - val.Format("%d", mHeightInfo.initialHeight); - if (edit) edit->SetWindowText(val); - - edit = GetDlgItem(IDC_X_SIZE); - val.Format("%d", mHeightInfo.xExtent); - if (edit) edit->SetWindowText(val); - - edit = GetDlgItem(IDC_BORDER_SIZE); - val.Format("%d", mHeightInfo.borderWidth); - if (edit) edit->SetWindowText(val); - - edit = GetDlgItem(IDC_Y_SIZE); - val.Format("%d", mHeightInfo.yExtent); - if (edit) edit->SetWindowText(val); - if (m_label) SetWindowText(m_label); - - - CButton *pButton; - if (mHeightInfo.forResize) { - pButton = (CButton*)GetDlgItem(IDC_CENTER); - pButton->SetCheck(1); - mHeightInfo.anchorBottom = false; - mHeightInfo.anchorTop = false; - mHeightInfo.anchorLeft = false; - mHeightInfo.anchorRight = false; - doAnchorButton(IDC_CENTER); - } else { - pButton = (CButton*)GetDlgItem(IDC_CENTER); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_TOP_LEFT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_TOP); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_TOP_RIGHT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_CENTER_LEFT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_CENTER_RIGHT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM_LEFT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM_RIGHT); - pButton->ShowWindow(SW_HIDE); - pButton = (CButton*)GetDlgItem(IDC_ANCHOR_LABEL); - pButton->ShowWindow(SW_HIDE); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Handles the button press for this button. */ -Bool CNewHeightMap::doAnchorButton(Int buttonID) -{ - TNewHeightInfo heightInfo = mHeightInfo; - Bool processed = true; - heightInfo.anchorBottom = false; - heightInfo.anchorTop = false; - heightInfo.anchorLeft = false; - heightInfo.anchorRight = false; - switch(buttonID) { - case IDC_CENTER: - break; - case IDC_TOP_LEFT: - heightInfo.anchorTop = true; - heightInfo.anchorLeft = true; - break; - case IDC_TOP: - heightInfo.anchorTop = true; - break; - case IDC_TOP_RIGHT: - heightInfo.anchorTop = true; - heightInfo.anchorRight = true; - break; - case IDC_CENTER_LEFT: - heightInfo.anchorLeft = true; - break; - case IDC_CENTER_RIGHT: - heightInfo.anchorRight = true; - break; - case IDC_BOTTOM: - heightInfo.anchorBottom = true; - break; - case IDC_BOTTOM_LEFT: - heightInfo.anchorBottom = true; - heightInfo.anchorLeft = true; - break; - case IDC_BOTTOM_RIGHT: - heightInfo.anchorBottom = true; - heightInfo.anchorRight = true; - break; - default: - processed = false; - break; - } - if (!processed) return(false); - mHeightInfo = heightInfo; - CButton *pButton; - pButton = (CButton*)GetDlgItem(IDC_CENTER); - pButton->SetCheck(buttonID==IDC_CENTER?1:0); - pButton = (CButton*)GetDlgItem(IDC_TOP_LEFT); - pButton->SetCheck(buttonID==IDC_TOP_LEFT?1:0); - pButton = (CButton*)GetDlgItem(IDC_TOP); - pButton->SetCheck(buttonID==IDC_TOP?1:0); - pButton = (CButton*)GetDlgItem(IDC_TOP_RIGHT); - pButton->SetCheck(buttonID==IDC_TOP_RIGHT?1:0); - pButton = (CButton*)GetDlgItem(IDC_CENTER_LEFT); - pButton->SetCheck(buttonID==IDC_CENTER_LEFT?1:0); - pButton = (CButton*)GetDlgItem(IDC_CENTER_RIGHT); - pButton->SetCheck(buttonID==IDC_CENTER_RIGHT?1:0); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM); - pButton->SetCheck(buttonID==IDC_BOTTOM?1:0); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM_LEFT); - pButton->SetCheck(buttonID==IDC_BOTTOM_LEFT?1:0); - pButton = (CButton*)GetDlgItem(IDC_BOTTOM_RIGHT); - pButton->SetCheck(buttonID==IDC_BOTTOM_RIGHT?1:0); - pButton = (CButton*)GetDlgItem(IDC_ANCHOR_LABEL); - pButton->SetCheck(buttonID==IDC_ANCHOR_LABEL?1:0); - return true; - -} - - -void CNewHeightMap::OnOK() -{ - CWnd *edit = GetDlgItem(IDC_INITIAL_HEIGHT); - CString val; - if (edit) { - edit->GetWindowText(val); - mHeightInfo.initialHeight = atoi(val); - } - edit = GetDlgItem(IDC_X_SIZE); - if (edit) { - edit->GetWindowText(val); - mHeightInfo.xExtent = atoi(val); - } - edit = GetDlgItem(IDC_Y_SIZE); - if (edit) { - edit->GetWindowText(val); - mHeightInfo.yExtent = atoi(val); - } - edit = GetDlgItem(IDC_BORDER_SIZE); - if (edit) { - edit->GetWindowText(val); - mHeightInfo.borderWidth = atoi(val); - } - CDialog::OnOK(); -} - - -BOOL CNewHeightMap::OnCommand(WPARAM wParam, LPARAM lParam) -{ - Int cmd = HIWORD(wParam); - if (cmd == BN_CLICKED) { - Int idButton = (int) LOWORD(wParam); // identifier of button - if (doAnchorButton(idButton)) { - return true; - } - } - - return CDialog::OnCommand(wParam, lParam); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp deleted file mode 100644 index 40240af3a56..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp +++ /dev/null @@ -1,834 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ObjectOptions.cpp : implementation file -// - -#define DEFINE_EDITOR_SORTING_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "ObjectOptions.h" -#include "WHeightMapEdit.h" -#include "addplayerdialog.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" -#include "Common/PlayerTemplate.h" -#include "Common/FileSystem.h" // for LOAD_TEST_ASSETS -#include "GameLogic/SidesList.h" -#include "GameClient/Color.h" - -#include - -ObjectOptions *ObjectOptions::m_staticThis = nullptr; -Bool ObjectOptions::m_updating = false; -char ObjectOptions::m_currentObjectName[NAME_MAX_LEN]; -Int ObjectOptions::m_currentObjectIndex=-1; -AsciiString ObjectOptions::m_curOwnerName; - -///////////////////////////////////////////////////////////////////////////// -// ObjectOptions dialog - - -ObjectOptions::ObjectOptions(CWnd* pParent /*=nullptr*/) -{ - m_objectsList = nullptr; - strcpy(m_currentObjectName, "No Selection"); - m_curOwnerName.clear(); - //{{AFX_DATA_INIT(ObjectOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -ObjectOptions::~ObjectOptions() -{ - deleteInstance(m_objectsList); - m_objectsList = nullptr; -} - - -void ObjectOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ObjectOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ObjectOptions, COptionsPanel) - //{{AFX_MSG_MAP(ObjectOptions) - ON_CBN_EDITCHANGE(IDC_OWNINGTEAM, OnEditchangeOwningteam) - ON_CBN_CLOSEUP(IDC_OWNINGTEAM, OnCloseupOwningteam) - ON_CBN_SELCHANGE(IDC_OWNINGTEAM, OnSelchangeOwningteam) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -static Int findSideListEntryWithPlayerOfSide(AsciiString side) -{ - for (int i = 0; i < TheSidesList->getNumSides(); i++) - { - AsciiString ptname = TheSidesList->getSideInfo(i)->getDict()->getAsciiString(TheKey_playerFaction); - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(ptname)); - if (pt && pt->getSide() == side) - { - return i; - } - } - - // DEBUG_CRASH(("no SideList entry found for %s!",side.str())); - return -1; -} - -///////////////////////////////////////////////////////////////////////////// -// ObjectOptions data access method. - -/*static*/ void ObjectOptions::update() -{ - if (m_staticThis) - m_staticThis->updateLabel(); -} - - -void ObjectOptions::updateLabel() -{ - CWnd *pLabel = GetDlgItem(IDC_OBJECT_NAME); - if (pLabel) { - pLabel->SetWindowText(m_currentObjectName); - } - - CComboBox *list = (CComboBox*)GetDlgItem(IDC_OWNINGTEAM); - list->ResetContent(); - - Bool found = false; - AsciiString defTeamName; - MapObject *pCur = getCurMapObject(); - if (!pCur) { - // No valid selection. Just return. - return; - } - if (pCur) - { - const ThingTemplate* tt = pCur->getThingTemplate(); - if (tt) - { - AsciiString defPlayerSide = tt->getDefaultOwningSide(); - Int i = findSideListEntryWithPlayerOfSide(defPlayerSide); - if (i >= 0) - { - defTeamName.set("team"); - defTeamName.concat(TheSidesList->getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName)); - found = true; - } - } - else - { - // put it on neutral - defTeamName.set("team"); - found = true; - } - } - - // flag the preview for redraw also - if (pCur && pCur->getThingTemplate()) - { - m_objectPreview.SetThingTemplate(pCur->getThingTemplate()); - } - else - { - m_objectPreview.SetThingTemplate(nullptr); - } - m_objectPreview.Invalidate(); - - Int neutral = -1; - Int sel = -1; - for (int i = 0; i < TheSidesList->getNumTeams(); i++) - { - Dict *d = TheSidesList->getTeamInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_teamName); - DEBUG_ASSERTCRASH(!name.isEmpty(),("bad")); - - if (name == defTeamName) - sel = i; - - if (name == "team") - { - name = "(neutral)"; // aka, neutral - neutral = i; - } - list->AddString(name.str()); - } - DEBUG_ASSERTCRASH(TheSidesList->getNumTeams() == 0 || neutral != -1, ("must have a neutral")); - if (sel == -1) - { - DEBUG_ASSERTCRASH(defTeamName.isEmpty(), ("owning team not found, using neutral")); - sel = neutral; - } - if (sel == -1) - { - DEBUG_ASSERTCRASH(!pCur || TheSidesList->getNumTeams()==0,("hmm, should not happen")); - m_curOwnerName.clear(); - } - else - { - DEBUG_ASSERTCRASH(pCur,("hmm, should not happen")); - m_curOwnerName = TheSidesList->getTeamInfo(sel)->getDict()->getAsciiString(TheKey_teamName); - } - list->SetCurSel(sel); -} - -#if 0 -///////////////////////////////////////////////////////////////////////////// -static const PlayerTemplate* findFirstPlayerTemplateOnSide(AsciiString side) -{ - if (side.isEmpty()) - return nullptr; // neutral, this is ok - - for (int i = 0; i < ThePlayerTemplateStore->getPlayerTemplateCount(); i++) - { - const PlayerTemplate* pt = ThePlayerTemplateStore->getNthPlayerTemplate(i); - if (pt && pt->getSide() == side) - { - return pt; - } - } - - DEBUG_CRASH(("no player found for %s!",side.str())); - return nullptr; -} -#endif - -///////////////////////////////////////////////////////////////////////////// -// ObjectOptions message handlers - -/// Setup the controls in the dialog. -BOOL ObjectOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - -// CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - - - // add entries from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - Coord3D loc = { 0, 0, 0 }; - MapObject *pMap; - - // create new map object - pMap = newInstance( MapObject)( loc, tTemplate->getName(), 0.0f, 0, nullptr, tTemplate ); - pMap->setNextMap( m_objectsList ); - m_objectsList = pMap; - - // get display color for the editor - Color cc = tTemplate->getDisplayColor(); - pMap->setColor(cc); - - } - -#if 0 // Lights are not working right now. - { - Coord3D pt = {0,0,0}; - char base[1024] = "*Lights/Light"; - MapObject *pMap = newInstance(MapObject)(pt, AsciiString(base), 0.0f, 0, nullptr, nullptr ); - pMap->setIsLight(); - - Dict *props = pMap->getProperties(); - RGBColor tmp; - tmp.red = tmp.green = tmp.blue = 1.0f; - Int tmpi = tmp.getAsInt(); - props->setReal(TheKey_lightHeightAboveTerrain, 0.0f); - props->setReal(TheKey_lightInnerRadius, 15.0f); - props->setReal(TheKey_lightOuterRadius, 25.0f); - props->setInt(TheKey_lightAmbientColor, tmpi); - props->setInt(TheKey_lightDiffuseColor, tmpi); - - pMap->setNextMap(m_objectsList); - m_objectsList = pMap; - } -#endif -#ifdef LOAD_TEST_ASSETS - { - char fileBuf[_MAX_PATH]; - Int i; - - FilenameList filenameList; - TheFileSystem->getFileListInDirectory(TEST_W3D_DIR_PATH, "*.w3d", filenameList, FALSE); - - if (!filenameList.empty()) { - FilenameList::iterator it = filenameList.begin(); - do { - AsciiString filename = *it; - int len = filename.getLength(); - if (len<5) continue; - // only do .w3d files - - // strip out the path, and just keep the filename itself. - AsciiString token; - while (filename.getLength() > 0) { - filename.nextToken(&token, "\\/"); - } - - strcpy(fileBuf, TEST_STRING); - strlcat(fileBuf, "/", ARRAY_SIZE(fileBuf)); - strlcat(fileBuf, token.str(), ARRAY_SIZE(fileBuf)); - for (i=strlen(fileBuf)-1; i>0; i--) { - if (fileBuf[i] == '.') { - // strip off .w3d file extension. - fileBuf[i] = 0; - break; // we stripped it already, we don't need to go any further. - } - } - Coord3D pt = {0,0,0}; - MapObject *pMap = newInstance(MapObject)(pt, AsciiString(fileBuf), 0.0f, 0, nullptr, nullptr ); - pMap->setNextMap(m_objectsList); - m_objectsList = pMap; - - ++it; - } while (it != filenameList.end()); - } - } -#endif - - CWnd *pWnd = GetDlgItem(IDC_OBJECT_HEIGHT_EDIT); - if (pWnd) { - CString s; - s.Format("%d",MAGIC_GROUND_Z); - pWnd->SetWindowText(s); - } - - pWnd = GetDlgItem(IDC_TERRAIN_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_objectTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_objectTreeView.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_TERRAIN_SWATCHES); - pWnd->GetWindowRect(&rect); - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_objectPreview.Create(nullptr, "", WS_CHILD, rect, this, IDC_TERRAIN_SWATCHES); - m_objectPreview.ShowWindow(SW_SHOW); - - MapObject *pMap = m_objectsList; - Int index = 0; - while (pMap) { - addObject( pMap, pMap->getName().str(), index, TVI_ROOT); - index++; - pMap = pMap->getNext(); - } - - - m_staticThis = this; - m_updating = false; - - updateLabel(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM ObjectOptions::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = m_objectTreeView.InsertItem(&ins); - return(child); -} - -HTREEITEM ObjectOptions::findOrDont(const char *pLabel) -{ - return _FindOrDont(pLabel, m_objectTreeView.GetRootItem()); -} - -HTREEITEM ObjectOptions::_FindOrDont(const char* pLabel, HTREEITEM startPoint) -{ - std::list itemsToEx; - itemsToEx.push_back(startPoint); - - while (!itemsToEx.empty()) { - char buffer[_MAX_PATH]; - HTREEITEM hItem = itemsToEx.front(); - itemsToEx.pop_front(); - DEBUG_ASSERTCRASH(hItem != nullptr, ("Unexpected tree item pointer in ObjectOptions::_FindOrDont")); - - if (!m_objectTreeView.ItemHasChildren(hItem)) { - TVITEM item; - memset(&item, 0, sizeof(item)); - - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - - const char* strToTest = strrchr(pLabel, '/'); -// if (strstr((strToTest ? strToTest : pLabel), buffer)) - if (strcmp((strToTest ? strToTest : pLabel), buffer) == 0) - { - return hItem; - } - } else { - // add the first child, the others will be caught by the adding of the siblings - itemsToEx.push_back(m_objectTreeView.GetChildItem(hItem)); - } - - if (m_objectTreeView.GetNextSiblingItem(hItem)) { - itemsToEx.push_back(m_objectTreeView.GetNextSiblingItem(hItem)); - } - } - return nullptr; -} - - -//------------------------------------------------------------------------------------------------- -/** Add the object hierarchy paths to the tree view. */ -//------------------------------------------------------------------------------------------------- -void ObjectOptions::addObject( MapObject *mapObject, const char *pPath, - Int terrainNdx, HTREEITEM parent ) -{ - char buffer[ _MAX_PATH ]; - const char *leafName = nullptr; - - // sanity - if( mapObject == nullptr ) - return; - - // - // if we have an thing template in mapObject, we've read it from the new INI database, - // we will sort those items into the tree based on properties of the template that - // make it easier for us to browse when building levels - // - // Feel free to reorganize how this tree is constructed from the template - // data at will, whatever makes it easier for design - // - const ThingTemplate *thingTemplate = mapObject->getThingTemplate(); - if( thingTemplate ) - { - - // first check for test sorted objects - if( thingTemplate->getEditorSorting() == ES_TEST ) - parent = findOrAdd( parent, "TEST" ); - - // first sort by side, either create or find the tree item with matching side name - AsciiString side = thingTemplate->getDefaultOwningSide(); - DEBUG_ASSERTCRASH( !side.isEmpty(), ("null default side in template") ); - parent = findOrAdd( parent, side.str()); - - // next tier uses the editor sorting that design can specify in the INI - EditorSortingType i = ES_FIRST; - for( ; - i < ES_NUM_SORTING_TYPES; - i = (EditorSortingType)(i + 1) ) - { - - if( thingTemplate->getEditorSorting() == i ) - { - - parent = findOrAdd( parent, EditorSortingNames[ i ] ); - break; // exit for - - } - - } - - if( i == ES_NUM_SORTING_TYPES ) - parent = findOrAdd( parent, "UNSORTED" ); - - // the leaf name is the name of the template - leafName = thingTemplate->getName().str(); - - } - else - { - - // all these old entries we will put in a tree for legacy GDF items - parent = findOrAdd( parent, "**TEST MODELS" ); - - Int i=0; - leafName = pPath; - while (pPath[i] && i 0 ) - { - buffer[ i ] = 0; - leafName = buffer; - - } - - } - - // add to the tree view - if( leafName ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = (char*)leafName; - ins.item.cchTextMax = strlen(leafName)+2; - m_objectTreeView.InsertItem(&ins); - - } - -} - -/// Set the selected object in the tree view. -Bool ObjectOptions::setObjectTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[NAME_MAX_LEN]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - if (item.lParam == selection) { - m_objectTreeView.SelectItem(child); - return(true); - } - if (setObjectTreeViewSelection(child, selection)) - { - strcpy(m_currentObjectName, buffer); - updateLabel(); - return(true); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - return(false); -} - - -BOOL ObjectOptions::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_objectTreeView.m_hWnd) { - - if (pHdr->hdr.code == TVN_ITEMEXPANDED) { - if (pHdr->action == TVE_COLLAPSE) { - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_STATE; - item.hItem = pHdr->itemOld.hItem; - m_objectTreeView.GetItem(&item); - item.state &= (~TVIS_EXPANDEDONCE); - item.mask = TVIF_STATE; - m_objectTreeView.SetItem(&item); - } - } - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[NAME_MAX_LEN]; - HTREEITEM hItem = m_objectTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - if (item.lParam >= 0) { - m_currentObjectIndex = item.lParam; - strcpy(m_currentObjectName, buffer); - } else if (m_objectTreeView.ItemHasChildren(item.hItem)) { - strcpy(m_currentObjectName, "No Selection"); - m_currentObjectIndex = -1; - } - updateLabel(); - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - - -MapObject *ObjectOptions::getCurMapObject() -{ - if (m_staticThis && m_currentObjectIndex >= 0) { - MapObject *pObj = m_staticThis->m_objectsList; - int count = 0; - while (pObj) { - if (count == m_currentObjectIndex) { - return(pObj); - } - count++; - pObj = pObj->getNext(); - } - } - return(nullptr); -} - -AsciiString ObjectOptions::getCurGdfName() -{ - MapObject *pCur = getCurMapObject(); - if (pCur) { - return pCur->getName(); - } - return AsciiString::TheEmptyString; -} - -MapObject *ObjectOptions::duplicateCurMapObjectForPlace(const Coord3D* loc, Real angle, Bool checkPlayers) -{ - MapObject *pCur = getCurMapObject(); - if (pCur) - { - - Bool found = false; - const ThingTemplate* tt = pCur->getThingTemplate(); - if (checkPlayers) - { - AsciiString defaultTeam("team"); - - AsciiString objectTeamName = m_curOwnerName; - if (objectTeamName != defaultTeam) { - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(objectTeamName); - if (teamInfo) { - AsciiString teamOwner = teamInfo->getDict()->getAsciiString(TheKey_teamOwner); - SidesInfo* pSide = TheSidesList->findSideInfo(teamOwner); - if (pSide) { - found = true; - } - } - } - if (!found && tt) - { - AsciiString defPlayerSide = tt->getDefaultOwningSide(); - Int si = findSideListEntryWithPlayerOfSide(defPlayerSide); - - found = (si >= 0); - if (!found) - { - AddPlayerDialog addPlyr(pCur->getThingTemplate()->getDefaultOwningSide()); - if (addPlyr.DoModal() == IDOK) - { - for (int i = 0; i < TheSidesList->getNumSides(); i++) - { - AsciiString playerTmplName = TheSidesList->getSideInfo(i)->getDict()->getAsciiString(TheKey_playerFaction); - if (playerTmplName == addPlyr.getAddedSide()) - { - m_curOwnerName.set("team"); - m_curOwnerName.concat(TheSidesList->getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName)); - found = true; - break; - } - } - } - } - } - else - { - if (!found) { - // neutral - m_curOwnerName.set("team"); - found = true; - } - } - } else { - found = true; - } - if (found) - { - MapObject *pNew = newInstance(MapObject)( *loc, pCur->getName(), angle, - pCur->getFlags(), pCur->getProperties(), - pCur->getThingTemplate() ); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, m_curOwnerName); - pNew->setColor(pCur->getColor()); - return pNew; - } - } - AfxMessageBox("Unable to add object."); - return(nullptr); -} - -Real ObjectOptions::getCurObjectHeight() -{ - if (m_staticThis) { - CWnd *pWnd = m_staticThis->GetDlgItem(IDC_OBJECT_HEIGHT_EDIT); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Real height = atoi(val); - if (height>0) { - height *= MAP_HEIGHT_SCALE; - } - return(height); - } - } - return(MAGIC_GROUND_Z); -} - -MapObject *ObjectOptions::getObjectNamed(AsciiString name) -{ - if (m_staticThis) { - MapObject *pObj = m_staticThis->m_objectsList; -// int count = 0; - while (pObj) { - if (name == pObj->getName()) { - return(pObj); - } - const char *curName = pObj->getName().str(); - const char *leaf = curName; - while (*curName) { - if (*curName == '/') { - leaf = curName+1; - } - curName++; - } - if (0==strcmp(leaf, name.str())) { - return(pObj); - } - pObj = pObj->getNext(); - } - } - return(nullptr); -} - -Int ObjectOptions::getObjectNamedIndex(const AsciiString& name) -{ - if (m_staticThis) { - MapObject *pObj = m_staticThis->m_objectsList; - int count = 0; - while (pObj) { - if (name == pObj->getName()) { - return(count); - } - const char *curName = pObj->getName().str(); - const char *leaf = curName; - while (*curName) { - if (*curName == '/') { - leaf = curName+1; - } - curName++; - } - if (0==strcmp(leaf, name.str())) { - return(count); - } - pObj = pObj->getNext(); - } - } - return(0); -} - - -void ObjectOptions::OnEditchangeOwningteam() -{ - CComboBox *list = (CComboBox*)GetDlgItem(IDC_OWNINGTEAM); - Int sel = list->GetCurSel(); - - m_curOwnerName.clear(); - if (sel >= 0) - { - // note, get playername from the dicts, NOT from the popup. - Dict *d = TheSidesList->getTeamInfo(sel)->getDict(); - m_curOwnerName = d->getAsciiString(TheKey_teamName); - } - // no, do NOT call this; it'll reset back to default - //updateLabel(); -} - -void ObjectOptions::selectObject(const MapObject* pObj) -{ - if (m_staticThis) { - - char buffer[NAME_MAX_LEN]; - HTREEITEM objToSel = m_staticThis->findOrDont(pObj->getName().str()); - if (objToSel == nullptr) { - return; - } - - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = objToSel; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_staticThis->m_objectTreeView.GetItem(&item); - - if (m_staticThis->m_objectTreeView.SelectItem(objToSel)) { - m_staticThis->m_currentObjectIndex = item.lParam; - strcpy(m_staticThis->m_currentObjectName, buffer); - } - } -} - -void ObjectOptions::OnCloseupOwningteam() -{ - OnEditchangeOwningteam(); -} - -void ObjectOptions::OnSelchangeOwningteam() -{ - OnEditchangeOwningteam(); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectPreview.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectPreview.cpp deleted file mode 100644 index 66850fee457..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectPreview.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ObjectPreview.cpp : implementation file -// - -#include -#include -#include - -#include "StdAfx.h" -#include "resource.h" - -#include "Lib/BaseType.h" - -#include "ObjectPreview.h" -#include "WorldBuilderDoc.h" -#include "WHeightMapEdit.h" -#include "ObjectOptions.h" -#include "addplayerdialog.h" -#include "CUndoable.h" -#include "wbview3d.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" -#include "Common/PlayerTemplate.h" -#include "Common/FileSystem.h" -#include "GameLogic/SidesList.h" -#include "GameClient/Color.h" - -#include "W3DDevice/GameClient/W3DAssetManager.h" -#include "WW3D2/dx8wrapper.h" -#include "WWLib/TARGA.h" - -///////////////////////////////////////////////////////////////////////////// -// ObjectPreview - -ObjectPreview::ObjectPreview() -{ - m_tTempl = nullptr; -} - -ObjectPreview::~ObjectPreview() -{ -} - -void ObjectPreview::SetThingTemplate(const ThingTemplate *tTempl) -{ - m_tTempl = tTempl; -} - - -BEGIN_MESSAGE_MAP(ObjectPreview, CWnd) - //{{AFX_MSG_MAP(ObjectPreview) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -#define SWATCH_OFFSET 20 - -#define PREVIEW_WIDTH 128 -#define PREVIEW_HEIGHT 128 - -static UnsignedByte * saveSurface(IDirect3DSurface8 *surface) -{ - D3DSURFACE_DESC desc; - IDirect3DSurface8 *tempSurface; - - surface->GetDesc(&desc); - - LPDIRECT3DDEVICE8 m_pDev=DX8Wrapper::_Get_D3D_Device8(); - - HRESULT hr=m_pDev->CreateImageSurface( desc.Width,desc.Height,desc.Format, &tempSurface); - - hr=m_pDev->CopyRects(surface,nullptr,0,tempSurface,nullptr); - - D3DLOCKED_RECT lrect; - - DX8_ErrorCode(tempSurface->LockRect(&lrect,nullptr,D3DLOCK_READONLY)); - - unsigned int x,y,index,index2,width,height; - - width=desc.Width; - height=desc.Height; - -#ifdef CAPTURE_TO_TARGA - char image[3*PREVIEW_WIDTH*PREVIEW_HEIGHT]; - //bytes are mixed in targa files, not rgb order. - for (y=0; y> 1); y++) - { - /* Compute address of lines to exchange. */ - ptr = (bgraImage + ((width * y) * 3)); - ptr1 = (bgraImage + ((width * (height - 1)) * 3)); - ptr1 -= ((width * y) * 3); - - /* Exchange all the pixels on this scan line. */ - for (x = 0; x < (width * 3); x++) - { - v = *ptr; - v1 = *ptr1; - *ptr = v1; - *ptr1 = v; - ptr++; - ptr1++; - } - } - - tempSurface->Release(); - - return bgraImage; -#endif -} - -// return an array of BGRA pixels -static UnsignedByte * generatePreview( const ThingTemplate *tt ) -{ - // find the default model to preview - RenderObjClass *model = nullptr; - Real scale = 1.0f; - AsciiString modelName = "No Model Name"; - if (tt) - { - ModelConditionFlags state; - state.clear(); - WbView3d *p3View = CWorldBuilderDoc::GetActiveDoc()->GetActive3DView(); - modelName = p3View->getBestModelName(tt, state); - scale = tt->getAssetScale(); - } - // set render object, or create if we need to - if( modelName.isEmpty() == FALSE && - strncmp( modelName.str(), "No ", 3 ) ) - { - WW3DAssetManager *pMgr = W3DAssetManager::Get_Instance(); - model = pMgr->Create_Render_Obj(modelName.str()); - if (model) - { - const AABoxClass bbox = model->Get_Bounding_Box(); -// Real height = bbox.Extent.Z; - const SphereClass sphere = model->Get_Bounding_Sphere(); - Real dist = sphere.Radius*0.5; - model->Set_Position(Vector3(-sphere.Center.X, -sphere.Center.Y, -sphere.Center.Z)); - - // Create reflection texture - TextureClass *objectTexture = DX8Wrapper::Create_Render_Target (PREVIEW_WIDTH, PREVIEW_HEIGHT); - if (!objectTexture) - { - model->Release_Ref(); - return nullptr; - } - - // Set the render target - DX8Wrapper::Set_Render_Target_With_Z(objectTexture); - - // create the camera - Bool orthoCamera = false; - CameraClass *camera = NEW_REF( CameraClass, () ); - Matrix3D camTran; - camTran.Look_At(Vector3(dist*2,dist*2,dist),Vector3(0.0f, 0.0f, 0.0f),0); - camera->Set_Transform( camTran); - - Vector2 minVec = Vector2( -1, -1 ); - Vector2 maxVec = Vector2( +1, +1 ); - camera->Set_View_Plane( minVec, maxVec ); - camera->Set_Clip_Planes( 0.995f, 600.0f ); - if (orthoCamera) - camera->Set_Projection_Type( CameraClass::ORTHO ); - - // Clear the backbuffer - WW3D::Begin_Render(true,true,Vector3(0.5f,0.5f,0.5f)); - //WW3D::Begin_Render(true,true,Vector3(1.0f,1.0f,1.0f)); - - RenderInfoClass rinfo(*camera); - LightEnvironmentClass lightEnv; - rinfo.light_environment = &lightEnv; - lightEnv.Reset(Vector3(0.0f, 0.0f, 0.0f), Vector3(1.0f, 1.0f, 1.0f)); - - WW3D::Render(*model, rinfo); - - WW3D::End_Render(false); - - // Change the rendertarget back to the main backbuffer - DX8Wrapper::Set_Render_Target((IDirect3DSurface8 *)nullptr); - - SurfaceClass *surface = objectTexture->Get_Surface_Level(); - UnsignedByte *data = saveSurface(surface->Peek_D3D_Surface()); - - REF_PTR_RELEASE(surface); - - REF_PTR_RELEASE(objectTexture); - REF_PTR_RELEASE(camera); - return data; - } - } - - return nullptr; -} - -///////////////////////////////////////////////////////////////////////////// -// ObjectPreview message handlers - -void ObjectPreview::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect clientRect; - GetClientRect(&clientRect); - - CRect previewRect; - previewRect = clientRect; - - CBrush brush; - brush.CreateSolidBrush(RGB(0,0,0)); - - UnsignedByte *pData; - pData = generatePreview(m_tTempl); - if (pData) { - DrawMyTexture(&dc, previewRect.top, previewRect.left, previewRect.Width(), previewRect.Height(), pData); - } else { - dc.FillSolidRect(&previewRect, RGB(128,128,128)); - } - dc.FrameRect(&previewRect, &brush); -} - -void ObjectPreview::DrawMyTexture(CDC *pDc, int top, int left, Int width, Int height, UnsignedByte *rgbData) -{ - // Just blast about some dib bits. - - LPBITMAPINFO pBI; -// long bytes = sizeof(BITMAPINFO); - pBI = new BITMAPINFO; - pBI->bmiHeader.biSize = sizeof(pBI->bmiHeader); - pBI->bmiHeader.biWidth = PREVIEW_WIDTH; - pBI->bmiHeader.biHeight = PREVIEW_HEIGHT; /* match display top left == 0,0 */ - pBI->bmiHeader.biPlanes = 1; - pBI->bmiHeader.biBitCount = 24; - pBI->bmiHeader.biCompression = BI_RGB; - pBI->bmiHeader.biSizeImage = (PREVIEW_WIDTH*PREVIEW_HEIGHT)*(pBI->bmiHeader.biBitCount/8); - pBI->bmiHeader.biXPelsPerMeter = 1000; - pBI->bmiHeader.biYPelsPerMeter = 1000; - pBI->bmiHeader.biClrUsed = 0; - pBI->bmiHeader.biClrImportant = 0; - - //::Sleep(10); - //int val=::StretchDIBits(pDc->m_hDC, left, top, width, height, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT, rgbData, pBI, - // DIB_RGB_COLORS, SRCCOPY); - /*int val=*/::StretchDIBits(pDc->m_hDC, left, top, width, height, PREVIEW_WIDTH/4, PREVIEW_HEIGHT/4, PREVIEW_WIDTH/2, PREVIEW_HEIGHT/2, rgbData, pBI, - DIB_RGB_COLORS, SRCCOPY); - delete(pBI); -} - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectTool.cpp deleted file mode 100644 index a95f4af1388..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectTool.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ObjectTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "ObjectTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "MainFrm.h" -#include "wbview3d.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "Common/ThingTemplate.h" -#include "Common/WellKnownKeys.h" -// -// ObjectTool class. -// - enum {HYSTERESIS = 3}; -/// Constructor -ObjectTool::ObjectTool() : - Tool(ID_PLACE_OBJECT_TOOL, IDC_PLACE_OBJECT) -{ -} - -/// Destructor -ObjectTool::~ObjectTool() -{ -} - -Real ObjectTool::calcAngle(Coord3D downPt, Coord3D curPt, WbView* pView) -{ - enum {HYSTERESIS = 3}; - double dx = curPt.x - downPt.x; - double dy = curPt.y - downPt.y; - double dist = sqrt(dx*dx+dy*dy); - double angle = 0; - if (dist < 0.1) // check for div-by-zero. - { - angle = 0; - } - else if (abs(dx) > abs(dy)) - { - angle = acos( (double)dx / dist); - if (dy<0) angle = -angle; - } - else - { - angle = asin( ((double)dy) / dist); - if (dx<0) angle = PI-angle; - } - if (angle > PI) angle -= 2*PI; -#ifdef RTS_DEBUG - CString buf; - buf.Format("Angle %f rad, %d degrees\n", angle, (int)(angle*180/PI)); - ::OutputDebugString(buf); -#endif - return((Real)angle); -} - - - -/// Turn off object tracking. -void ObjectTool::deactivate() -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return; - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); -} -/// Shows the object options panel -void ObjectTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_OBJECT_OPTIONS); - DrawObject::setDoBrushFeedback(false); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return; - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); -} - -/** Execute the tool on mouse down - Place an object. */ -void ObjectTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - m_downPt2d = viewPt; - m_downPt3d = cpt; -} - -/** Tracking - show the object. */ -void ObjectTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Bool justAClick = true; - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt, false); // Don't constrain. - Coord3D loc = cpt; - pView->snapPoint(&loc); - if (m == TRACK_L) { // Mouse is down, so preview the angle if > hysteresis. - // always check hysteresis in view coords. - justAClick = (abs(viewPt.x - m_downPt2d.x)getThingTemplate()) { - angle = pCur->getThingTemplate()->getPlacementViewAngle(); - } - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); - loc.z = ObjectOptions::getCurObjectHeight(); - if (pCur) { - // Display the transparent version of this object. - p3View->setObjTracking(pCur, loc, angle, true); - } else { - // Don't display anything. - p3View->setObjTracking(nullptr, loc, angle, false); - } -} - -/** Execute the tool on mouse up - Place an object. */ -void ObjectTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - // always check hysteresis in view coords. - Bool justAClick = (abs(viewPt.x - m_downPt2d.x)viewToDocCoords(viewPt, &cpt, false); // Don't constrain. - - Coord3D loc = m_downPt3d; - pView->snapPoint(&loc); - loc.z = ObjectOptions::getCurObjectHeight(); - Real angle = justAClick ? 0 : calcAngle(loc, cpt, pView); - MapObject *pNew = ObjectOptions::duplicateCurMapObjectForPlace(&loc, angle, true); - if (pNew) { - if (justAClick && pNew->getThingTemplate()) { - angle = pNew->getThingTemplate()->getPlacementViewAngle(); - pNew->setAngle(angle); - } - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pNew = nullptr; // undoable owns it now. - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp deleted file mode 100644 index c003e493bd0..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// OpenMap.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "OpenMap.h" -#include "Common/GlobalData.h" - -///////////////////////////////////////////////////////////////////////////// -// OpenMap dialog - - -OpenMap::OpenMap(TOpenMapInfo *pInfo, CWnd* pParent /*=nullptr*/) - : CDialog(OpenMap::IDD, pParent), - m_pInfo(pInfo) -{ - m_pInfo->browse = false; - m_usingSystemDir = ::AfxGetApp()->GetProfileInt(MAP_OPENSAVE_PANEL_SECTION, "UseSystemDir", TRUE); - - //{{AFX_DATA_INIT(OpenMap) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void OpenMap::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(OpenMap) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(OpenMap, CDialog) - //{{AFX_MSG_MAP(OpenMap) - ON_BN_CLICKED(IDC_BROWSE, OnBrowse) - ON_BN_CLICKED(IDC_SYSTEMMAPS, OnSystemMaps) - ON_BN_CLICKED(IDC_USERMAPS, OnUserMaps) - ON_LBN_DBLCLK(IDC_OPEN_LIST, OnDblclkOpenList) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// OpenMap message handlers - -void OpenMap::OnSystemMaps() -{ - populateMapListbox( TRUE ); -} - -void OpenMap::OnUserMaps() -{ - populateMapListbox( FALSE ); -} - -void OpenMap::OnBrowse() -{ - m_pInfo->browse = true; - OnOK(); -} - -void OpenMap::OnOK() -{ - CListBox *pList = (CListBox *)this->GetDlgItem(IDC_OPEN_LIST); - if (pList == nullptr) { - OnCancel(); - return; - } - - Int sel = pList->GetCurSel(); - if (sel == LB_ERR) { - m_pInfo->browse = true; - } else { - CString newName; - pList->GetText(sel, newName ); - if (m_usingSystemDir) - m_pInfo->filename = ".\\Maps\\" + newName + "\\" + newName + ".map"; - else - { - m_pInfo->filename = TheGlobalData->getPath_UserData().str(); - m_pInfo->filename = m_pInfo->filename + "Maps\\" + newName + "\\" + newName + ".map"; - } - } - CDialog::OnOK(); -} - -void OpenMap::populateMapListbox( Bool systemMaps ) -{ - m_usingSystemDir = systemMaps; - ::AfxGetApp()->WriteProfileInt(MAP_OPENSAVE_PANEL_SECTION, "UseSystemDir", m_usingSystemDir); - - HANDLE hFindFile = nullptr; - WIN32_FIND_DATA findData; - char dirBuf[_MAX_PATH]; - char findBuf[_MAX_PATH]; - char fileBuf[_MAX_PATH]; - - if (systemMaps) - strcpy(dirBuf, "Maps\\"); - else - { - snprintf(dirBuf, ARRAY_SIZE(dirBuf), "%sMaps\\", TheGlobalData->getPath_UserData().str()); - } - CListBox *pList = (CListBox *)this->GetDlgItem(IDC_OPEN_LIST); - if (pList == nullptr) return; - pList->ResetContent(); - snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf); - - Bool found = false; - - hFindFile = FindFirstFile(findBuf, &findData); - if (hFindFile != INVALID_HANDLE_VALUE) { - do { - if (strcmp(findData.cFileName, ".") == 0 || strcmp(findData.cFileName, "..") == 0) - continue; - if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { - continue; - } - - snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName); - try { - CFileStatus status; - if (CFile::GetStatus(fileBuf, status)) { - if (!(status.m_attribute & CFile::directory)) { - pList->AddString(findData.cFileName); - found = true; - }; - } - } catch(...) {} - - } while (FindNextFile(hFindFile, &findData)); - - if (hFindFile) FindClose(hFindFile); - } - if (found) { - pList->SetCurSel(0); - } else { - CWnd *pOk = GetDlgItem(IDOK); - if (pOk) pOk->EnableWindow(false); - } -} - -BOOL OpenMap::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CButton *pSystemMaps = (CButton *)this->GetDlgItem(IDC_SYSTEMMAPS); - if (pSystemMaps != nullptr) - pSystemMaps->SetCheck( m_usingSystemDir ); - - CButton *pUserMaps = (CButton *)this->GetDlgItem(IDC_USERMAPS); - if (pUserMaps != nullptr) - pUserMaps->SetCheck( !m_usingSystemDir ); - - // TheSuperHackers @tweak Originally World Builder has hidden the System Maps tab button in Release builds, - // perhaps with the intention to only show User Maps to community users. However, World Builder did release - // as a Debug build and always had the System Maps tab, therefore this now shows it always for simplicity. - - populateMapListbox( m_usingSystemDir ); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void OpenMap::OnDblclkOpenList() -{ - OnOK(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/OptionsPanel.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/OptionsPanel.cpp deleted file mode 100644 index c9973f81464..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/OptionsPanel.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// OptionsPanel.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "OptionsPanel.h" - -///////////////////////////////////////////////////////////////////////////// -// COptionsPanel dialog - - -COptionsPanel::COptionsPanel(Int dlgid /*=0*/, CWnd* pParent /*=nullptr*/) - : CDialog(dlgid ? dlgid : COptionsPanel::IDD, pParent) -{ - //{{AFX_DATA_INIT(COptionsPanel) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void COptionsPanel::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(COptionsPanel) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(COptionsPanel, CDialog) - //{{AFX_MSG_MAP(COptionsPanel) - ON_WM_MOVE() - ON_COMMAND(ID_EDIT_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) - ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsPanel message handlers - -void COptionsPanel::OnMove(int x, int y) -{ - CDialog::OnMove(x, y); - - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(OPTIONS_PANEL_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(OPTIONS_PANEL_SECTION, "Left", frameRect.left); - } - -} - - -void COptionsPanel::OnEditRedo() -{ - // Redirect undo/redo to the doc so they get executed. - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - pDoc->OnEditRedo(); - } -} - -void COptionsPanel::OnUpdateEditRedo(CCmdUI* pCmdUI) -{ - // Redirect undo/redo to the doc so they get executed. - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - pDoc->OnUpdateEditRedo(pCmdUI); - } -} - -void COptionsPanel::OnEditUndo() -{ - // Redirect undo/redo to the doc so they get executed. - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - pDoc->OnEditUndo(); - } -} - -void COptionsPanel::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - // Redirect undo/redo to the doc so they get executed. - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - pDoc->OnUpdateEditUndo(pCmdUI); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp deleted file mode 100644 index 10413a61100..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/PickUnitDialog.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// PickUnitDialog.cpp : implementation file -// - -#define DEFINE_EDITOR_SORTING_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "PickUnitDialog.h" - -#include "Common/ThingTemplate.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" - -///////////////////////////////////////////////////////////////////////////// -// PickUnitDialog dialog - - -ReplaceUnitDialog::ReplaceUnitDialog(CWnd* pParent /*=nullptr*/) - : PickUnitDialog(IDD, pParent) -{ - m_objectsList = nullptr; - m_currentObjectIndex = -1; - m_currentObjectName[0] = 0; - for (int i = ES_FIRST; iSetWindowText(m_missingName.str()); - - return TRUE; -} - -BEGIN_MESSAGE_MAP(ReplaceUnitDialog, CDialog) - //{{AFX_MSG_MAP(ReplaceUnitDialog) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -PickUnitDialog::PickUnitDialog(CWnd* pParent /*=nullptr*/) - : CDialog(IDD, pParent) -{ - m_objectsList = nullptr; - m_currentObjectIndex = -1; - m_currentObjectName[0] = 0; - for (int i = ES_FIRST; iIsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(BUILD_PICK_PANEL_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(BUILD_PICK_PANEL_SECTION, "Left", frameRect.left); - } - -} - -Bool PickUnitDialog::IsAllowableType(EditorSortingType sort, Bool isBuildable) -{ - if (m_factionOnly && !isBuildable) - { - return false; - } - return (m_allowable[sort]); -} - -void PickUnitDialog::SetAllowableType(EditorSortingType sort) -{ - m_allowable[sort] = true; -} - -void PickUnitDialog::SetupAsPanel() -{ - CWnd *pWnd = GetDlgItem(IDCANCEL); - if (pWnd) { - pWnd->ShowWindow(SW_HIDE); - } -} - -///////////////////////////////////////////////////////////////////////////// -// PickUnitDialog message handlers - -BOOL PickUnitDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - -// CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - - // add entries from the thing factory as the available objects to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - Coord3D loc = { 0, 0, 0 }; - MapObject *pMap; - - EditorSortingType sort = tTemplate->getEditorSorting(); - if (!IsAllowableType(sort, tTemplate->isBuildableItem())) continue; - - // create new map object - pMap = newInstance(MapObject)( loc, tTemplate->getName(), 0.0f, 0, nullptr, tTemplate ); - pMap->setNextMap( m_objectsList ); - m_objectsList = pMap; - } - - CWnd *pWnd = GetDlgItem(IDC_OBJECT_HEIGHT_EDIT); - if (pWnd) { - CString s; - s.Format("%d",MAGIC_GROUND_Z); - pWnd->SetWindowText(s); - } - - pWnd = GetDlgItem(IDC_OBJECT_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_objectTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_objectTreeView.ShowWindow(SW_SHOW); - - MapObject *pMap = m_objectsList; - Int index = 0; - while (pMap) { - addObject( pMap, pMap->getName().str(), index, TVI_ROOT); - index++; - pMap = pMap->getNext(); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM PickUnitDialog::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_objectTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_objectTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = (char*)pLabel; - ins.item.cchTextMax = strlen(pLabel); - child = m_objectTreeView.InsertItem(&ins); - return(child); -} - -BOOL PickUnitDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_objectTreeView.m_hWnd) { - - if (pHdr->hdr.code == TVN_ITEMEXPANDED) { - if (pHdr->action == TVE_COLLAPSE) { - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_STATE; - item.hItem = pHdr->itemOld.hItem; - m_objectTreeView.GetItem(&item); - item.state &= (~TVIS_EXPANDEDONCE); - item.mask = TVIF_STATE; - m_objectTreeView.SetItem(&item); - } - } - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[NAME_MAX_LEN]; - HTREEITEM hItem = m_objectTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_objectTreeView.GetItem(&item); - if (item.lParam >= 0) { - m_currentObjectIndex = item.lParam; - static_assert(ARRAY_SIZE(m_currentObjectName) >= ARRAY_SIZE(buffer), "Incorrect array size"); - strcpy(m_currentObjectName, buffer); - } else if (m_objectTreeView.ItemHasChildren(item.hItem)) { - strcpy(m_currentObjectName, ""); - m_currentObjectIndex = -1; - } - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -//------------------------------------------------------------------------------------------------- -/** Add the object hierarchy paths to the tree view. */ -//------------------------------------------------------------------------------------------------- -void PickUnitDialog::addObject( MapObject *mapObject, const char *pPath, Int index, HTREEITEM parent ) -{ - char buffer[ _MAX_PATH ]; - const char *leafName = nullptr; - - // sanity - if( mapObject == nullptr ) - return; - - // - // if we have an thing template in mapObject, we've read it from the new INI database, - // we will sort those items into the tree based on properties of the template that - // make it easier for us to browse when building levels - // - // Feel free to reorganize how this tree is constructed from the template - // data at will, whatever makes it easier for design - // - const ThingTemplate *thingTemplate = mapObject->getThingTemplate(); - if( thingTemplate ) - { - - // first check for test sorted objects - if( thingTemplate->getEditorSorting() == ES_TEST ) - parent = findOrAdd( parent, "TEST" ); - - // first sort by side, either create or find the tree item with matching side name - AsciiString side = thingTemplate->getDefaultOwningSide(); - DEBUG_ASSERTCRASH( !side.isEmpty(), ("null default side in template") ); - parent = findOrAdd( parent, side.str()); - - // next tier uses the editor sorting that design can specify in the INI - EditorSortingType i = ES_FIRST; - for( ; - i < ES_NUM_SORTING_TYPES; - i = (EditorSortingType)(i + 1) ) - { - - if( thingTemplate->getEditorSorting() == i ) - { - - parent = findOrAdd( parent, EditorSortingNames[ i ] ); - break; // exit for - - } - - } - - if( i == ES_NUM_SORTING_TYPES ) - parent = findOrAdd( parent, "UNSORTED" ); - - // the leaf name is the name of the template - leafName = thingTemplate->getName().str(); - - } - else - { - - // all these old entries we will put in a tree for legacy GDF items - parent = findOrAdd( parent, "**TEST MODELS" ); - - Int i=0; - leafName = pPath; - while (pPath[i] && i 0 ) - { - buffer[ i ] = 0; - leafName = buffer; - - } - - } - - // add to the tree view - if( leafName ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = index; - ins.item.pszText = (char*)leafName; - ins.item.cchTextMax = strlen(leafName)+2; - m_objectTreeView.InsertItem(&ins); - - } - -} - -AsciiString PickUnitDialog::getPickedUnit() -{ - if (m_currentObjectIndex >= 0) { - AsciiString retval(m_currentObjectName); - return retval; - } - return AsciiString::TheEmptyString; -} - -const ThingTemplate* PickUnitDialog::getPickedThing() -{ - if (m_currentObjectIndex >= 0) { - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) - { - if (m_currentObjectName == tTemplate->getName()) - return tTemplate; - } - } - return nullptr; -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/PointerTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/PointerTool.cpp deleted file mode 100644 index 9e80a811c99..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/PointerTool.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// PointerTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "PointerTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "GameLogic/SidesList.h" -#include "Common/ThingSort.h" -#include "Common/ThingTemplate.h" -#include "GameLogic/PolygonTrigger.h" -#include "wbview3d.h" -#include "ObjectTool.h" - -// -// Static helper functions -// This function spiders out and un/picks all Waypoints that have some form of indirect contact with this point -// Has a recursive helper function as well. -// -static void helper_pickAllWaypointsInPath( Int sourceID, CWorldBuilderDoc *pDoc, const Int numWaypointLinks, std::vector& alreadyTouched ); - -static void pickAllWaypointsInPath( Int sourceID, Bool select ) -{ - std::vector alreadyTouched; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - - helper_pickAllWaypointsInPath(sourceID, pDoc, pDoc->getNumWaypointLinks(), alreadyTouched); - - // already touched should now be filled with waypointIDs that want to be un/selected - MapObject *pMapObj = MapObject::getFirstMapObject(); - while (pMapObj) { - if (pMapObj->isWaypoint()) { - if (std::find(alreadyTouched.begin(), alreadyTouched.end(), pMapObj->getWaypointID()) != alreadyTouched.end()) { - pMapObj->setSelected(select); - } - } - pMapObj = pMapObj->getNext(); - } -} - -static void helper_pickAllWaypointsInPath( Int sourceID, CWorldBuilderDoc *pDoc, const Int numWaypointLinks, std::vector& alreadyTouched ) -{ - if (std::find(alreadyTouched.begin(), alreadyTouched.end(), sourceID) != alreadyTouched.end() ) { - return; - } - - alreadyTouched.push_back(sourceID); - for (int i = 0; i < numWaypointLinks; ++i) { - Int way1, way2; - pDoc->getWaypointLink(i, &way1, &way2); - if (way1 == sourceID) { - helper_pickAllWaypointsInPath(way2, pDoc, numWaypointLinks, alreadyTouched); - } - - if (way2 == sourceID) { - helper_pickAllWaypointsInPath(way1, pDoc, numWaypointLinks, alreadyTouched); - } - } -} - -// -// PointerTool class. -// - -/// Constructor -PointerTool::PointerTool() : - m_modifyUndoable(nullptr), - m_curObject(nullptr), - m_rotateCursor(nullptr), - m_moveCursor(nullptr) -{ - m_toolID = ID_POINTER_TOOL; - m_cursorID = IDC_POINTER; - -} - -/// Destructor -PointerTool::~PointerTool() -{ - REF_PTR_RELEASE(m_modifyUndoable); // belongs to pDoc now. - if (m_rotateCursor) { - ::DestroyCursor(m_rotateCursor); - } - if (m_moveCursor) { - ::DestroyCursor(m_moveCursor); - } -} - -/// See if a single obj is selected that has properties. -void PointerTool::checkForPropertiesPanel() -{ - MapObject *theMapObj = WaypointOptions::getSingleSelectedWaypoint(); - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - MapObject *theLightObj = LightOptions::getSingleSelectedLight(); - MapObject *theObj = MapObjectProps::getSingleSelectedMapObject(); - if (theMapObj) { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WAYPOINT_OPTIONS); - WaypointOptions::update(); - } else if (theTrigger) { - if (theTrigger->isWaterArea()) { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WATER_OPTIONS); - WaterOptions::update(); - } else { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WAYPOINT_OPTIONS); - WaypointOptions::update(); - } - } else if (theLightObj) { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_LIGHT_OPTIONS); - LightOptions::update(); - } else if (RoadOptions::selectionIsRoadsOnly()) { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_ROAD_OPTIONS); - RoadOptions::updateSelection(); - } else { - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_MAPOBJECT_PROPS); - MapObjectProps::update(); - if (theObj) { - ObjectOptions::selectObject(theObj); - } - } -} - -/// Clear the selection.. -void PointerTool::clearSelection() ///< Clears the selected objects selected flags. -{ - // Clear selection. - MapObject *pObj = MapObject::getFirstMapObject(); - while (pObj) { - if (pObj->isSelected()) { - pObj->setSelected(false); - } - pObj = pObj->getNext(); - } - // Clear selected build list items. - Int i; - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - if (pBuild->isSelected()) { - pBuild->setSelected(false); - } - } - } - m_poly_curSelectedPolygon = nullptr; -} - -/// Activate. -void PointerTool::activate() -{ - Tool::activate(); - m_mouseUpRotate = false; - m_mouseUpMove = false; - checkForPropertiesPanel(); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return; - WbView3d *p3View = pDoc->GetActive3DView(); - p3View->setObjTracking(nullptr, m_downPt3d, 0, false); -} - -/// deactivate. -void PointerTool::deactivate() -{ - m_curObject = nullptr; - PolygonTool::deactivate(); -} - -/** Set the cursor. */ -void PointerTool::setCursor() -{ - if (m_mouseUpRotate) { - if (m_rotateCursor == nullptr) { - m_rotateCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_ROTATE)); - } - ::SetCursor(m_rotateCursor); - } else if (m_mouseUpMove) { - if (m_moveCursor == nullptr) { - m_moveCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_MOVE_POINTER)); - } - ::SetCursor(m_moveCursor); - } else { - Tool::setCursor(); - } -} - -Bool PointerTool::allowPick(MapObject* pMapObj, WbView* pView) -{ - EditorSortingType sort = ES_NONE; - if (!pMapObj) { - return false; - } - const ThingTemplate *tt = pMapObj->getThingTemplate(); - if (tt && tt->getEditorSorting() == ES_AUDIO) { - if (pView->GetPickConstraint() == ES_NONE || pView->GetPickConstraint() == ES_AUDIO) { - return true; - } - } - if ((tt && !pView->getShowModels()) || (pMapObj->getFlags() & FLAG_DONT_RENDER)) { - return false; - } - if (pView->GetPickConstraint() != ES_NONE) { - if (tt) { - if (!pView->getShowModels()) { - return false; - } - sort = tt->getEditorSorting(); - } else { - if (pMapObj->isWaypoint()) { - sort = ES_WAYPOINT; - } - if (pMapObj->getFlag(FLAG_ROAD_FLAGS)) { - sort = ES_ROAD; - } - } - if (sort != ES_NONE && sort != pView->GetPickConstraint()) { - return false; - } - } - return true; -} - -/** Execute the tool on mouse down - Pick an object. */ -void PointerTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - Coord3D loc; - - m_downPt2d = viewPt; - m_downPt3d = cpt; - pView->snapPoint(&m_downPt3d); - m_moving = false; - m_rotating = false; - m_dragSelect = false; - Bool shiftKey = (0x8000 & ::GetAsyncKeyState(VK_SHIFT))!=0; - Bool ctrlKey = (0x8000 & ::GetAsyncKeyState(VK_CONTROL))!=0; - - m_doPolyTool = false; - if (pView->GetPickConstraint() == ES_NONE || pView->GetPickConstraint() == ES_WAYPOINT) { - // If polygon triggers are visible, see if we clicked on one. - if (pView->isPolygonTriggerVisible()) { - m_poly_unsnappedMouseDownPt = cpt; - poly_pickOnMouseDown(viewPt, pView); - if (m_poly_curSelectedPolygon) { - // picked on one. - if (!poly_snapToPoly(&cpt)) { - pView->snapPoint(&cpt); - } - m_poly_mouseDownPt = cpt; - m_poly_justPicked = true; // Makes poly tool move instead of inserting. - m_doPolyTool = true; - PolygonTool::startMouseDown(m, viewPt, pView, pDoc); - return; - } - m_poly_curSelectedPolygon = nullptr; - m_poly_dragPointNdx = -1; - } - } - - - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - m_curObject = nullptr; - MapObject *pObj = MapObject::getFirstMapObject(); - MapObject *p3DObj = pView->picked3dObjectInView(viewPt); - MapObject *pClosestPicked = nullptr; - if (allowPick(p3DObj, pView)) { - pClosestPicked = p3DObj; - } - Real pickDistSqr = 10000*MAP_XY_FACTOR; - pickDistSqr *= pickDistSqr; - - // Find the closest pick. - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (!allowPick(pObj, pView)) { - continue; - } - Bool picked = (pView->picked(pObj, cpt) != PICK_NONE); - if (picked) { - loc = *pObj->getLocation(); - Real dx = m_downPt3d.x-loc.x; - Real dy = m_downPt3d.y-loc.y; - Real distSqr = dx*dx+dy*dy; - if (distSqr < pickDistSqr) { - pClosestPicked = pObj; - pickDistSqr = distSqr; - } - } - } - - Bool anySelected = (pClosestPicked!=nullptr); - if (shiftKey) { - if (pClosestPicked && pClosestPicked->isSelected()) { - pClosestPicked->setSelected(false); - if (ctrlKey && pClosestPicked->isWaypoint()) { - pickAllWaypointsInPath(pClosestPicked->getWaypointID(), false); - } - } else if (pClosestPicked) { - pClosestPicked->setSelected(true); - if (ctrlKey && pClosestPicked->isWaypoint()) { - pickAllWaypointsInPath(pClosestPicked->getWaypointID(), true); - } - } - } else if (pClosestPicked && pClosestPicked->isSelected()) { - // We picked a selected object - m_curObject = pClosestPicked; - } else { - clearSelection(); - if (pClosestPicked) { - pClosestPicked->setSelected(true); - if (ctrlKey && pClosestPicked->isWaypoint()) { - pickAllWaypointsInPath(pClosestPicked->getWaypointID(), true); - } - - } - } - - // Grab both ends of a road. - if (pView->GetPickConstraint() == ES_NONE || pView->GetPickConstraint() == ES_ROAD) { - if (!shiftKey && pClosestPicked && (pClosestPicked->getFlags()&FLAG_ROAD_FLAGS) ) { - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (pObj->getFlags()&FLAG_ROAD_FLAGS) { - loc = *pObj->getLocation(); - Real dx = pClosestPicked->getLocation()->x - loc.x; - Real dy = pClosestPicked->getLocation()->y - loc.y; - Real dist = sqrt(dx*dx+dy*dy); - if (dist < MAP_XY_FACTOR/100) { - pObj->setSelected(true); - } - } - } - } - } - - if (anySelected) { - if (m_curObject) { - // See if we are picking on the arrow. - if (pView->picked(m_curObject, cpt) == PICK_ARROW) { - m_rotating = true; - } - } else { - pObj = MapObject::getFirstMapObject(); - while (pObj) { - if (pObj->isSelected()) { - m_curObject = pObj; - break; - } - pObj = pObj->getNext(); - } - } - if (m_curObject) { - // adjust the starting point so if we are snapping, the object snaps as well. - loc = *m_curObject->getLocation(); - Coord3D snapLoc = loc; - pView->snapPoint(&snapLoc); - m_downPt3d.x += (loc.x-snapLoc.x); - m_downPt3d.y += (loc.y-snapLoc.y); - } - } else { - m_dragSelect = true; - } -} - -/// Left button move code. -void PointerTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt, false); - if (m == TRACK_NONE) { - // See if the cursor is over an object. - MapObject *pObj = MapObject::getFirstMapObject(); - m_mouseUpRotate = false; - m_mouseUpMove = false; - while (pObj) { - if (allowPick(pObj, pView)) { - TPickedStatus stat = pView->picked(pObj, cpt); - if (stat==PICK_ARROW) { - m_mouseUpRotate = true; - break; - } - if (stat==PICK_CENTER) { - m_mouseUpMove = true; - break; - } - } - pObj = pObj->getNext(); - } - if (!m_mouseUpRotate) { - pObj = pView->picked3dObjectInView(viewPt); - if (allowPick(pObj, pView)) { - m_mouseUpMove = true; - } - } - if (pView->isPolygonTriggerVisible() && pickPolygon(cpt, viewPt, pView)) { - if (pView->GetPickConstraint() == ES_NONE || pView->GetPickConstraint() == ES_WAYPOINT) { - m_mouseUpMove = true; - m_mouseUpRotate = false; - } - } - return; // setCursor will use the value of m_mouseUpRotate. jba. - } - - if (m != TRACK_L) return; - if (m_doPolyTool) { - PolygonTool::mouseMoved(m, viewPt, pView, pDoc); - return; - } - - if (m_dragSelect) { - CRect box; - box.left = viewPt.x; - box.bottom = viewPt.y; - box.top = m_downPt2d.y; - box.right = m_downPt2d.x; - box.NormalizeRect(); - pView->doRectFeedback(true, box); - pView->Invalidate(); - return; - } - - if (m_curObject == nullptr) { - return; - } - pView->viewToDocCoords(viewPt, &cpt, !m_rotating); - if (!m_moving) { - // always use view coords (not doc coords) for hysteresis - Int dx = viewPt.x-m_downPt2d.x; - Int dy = viewPt.y-m_downPt2d.y; - if (abs(dx)>HYSTERESIS || abs(dy)>HYSTERESIS) { - m_moving = true; - m_modifyUndoable = new ModifyObjectUndoable(pDoc); - } - } - if (!m_moving || !m_modifyUndoable) return; - - MapObject *curMapObj = MapObject::getFirstMapObject(); - while (curMapObj) { - if (curMapObj->isSelected()) { - //pDoc->invalObject(curMapObj); // invaling in all views can be too slow. - pView->invalObjectInView(curMapObj); - } - curMapObj = curMapObj->getNext(); - } - - if (m_rotating) { - Coord3D center = *m_curObject->getLocation(); - m_modifyUndoable->RotateTo(ObjectTool::calcAngle(center, cpt, pView)); - } else { - pView->snapPoint(&cpt); - Real xOffset = (cpt.x-m_downPt3d.x); - Real yOffset = (cpt.y-m_downPt3d.y); - m_modifyUndoable->SetOffset(xOffset, yOffset); - } - - curMapObj = MapObject::getFirstMapObject(); - while (curMapObj) { - if (curMapObj->isSelected()) { - //pDoc->invalObject(curMapObj); // invaling in all views can be too slow. - pView->invalObjectInView(curMapObj); - } - curMapObj = curMapObj->getNext(); - } - - pDoc->updateAllViews(); - -} - - -/** Execute the tool on mouse up - if modifying, do the modify, -else update the selection. */ -void PointerTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - if (m_doPolyTool) { - m_doPolyTool = false; - PolygonTool::mouseUp(m, viewPt, pView, pDoc); - checkForPropertiesPanel(); - return; - } - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - if (m_curObject && m_moving) { - pDoc->AddAndDoUndoable(m_modifyUndoable); - REF_PTR_RELEASE(m_modifyUndoable); // belongs to pDoc now. - } else if (m_dragSelect) { - CRect box; - box.left = viewPt.x; - box.top = viewPt.y; - box.right = m_downPt2d.x; - box.bottom = m_downPt2d.y; - box.NormalizeRect(); - pView->doRectFeedback(false, box); - pView->Invalidate(); - - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - // Don't pick on invisible waypoints - if (pObj->isWaypoint() && !pView->isWaypointVisible()) { - continue; - } - if (!allowPick(pObj, pView)) { - continue; - } - Bool picked; - Coord3D loc = *pObj->getLocation(); - CPoint viewPt; - if (pView->docToViewCoords(loc, &viewPt)){ - picked = (viewPt.x>=box.left && viewPt.x<=box.right && viewPt.y>=box.top && viewPt.y<=box.bottom) ; - if (picked) { - if ((0x8000 && ::GetAsyncKeyState(VK_SHIFT))) { - pObj->setSelected(!pObj->isSelected()); - } else { - pObj->setSelected(true); - } - pDoc->invalObject(pObj); - } - } - } - - } - checkForPropertiesPanel(); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/PolygonTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/PolygonTool.cpp deleted file mode 100644 index f4882ce322b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/PolygonTool.cpp +++ /dev/null @@ -1,470 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// PolygonTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "PolygonTool.h" -#include "CUndoable.h" -#include "PointerTool.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "GameLogic/PolygonTrigger.h" -#include "W3DDevice/GameClient/HeightMap.h" - -// -// PolygonTool class. -// - -Bool PolygonTool::m_poly_isActive = false; -Bool PolygonTool::m_poly_isAdding = false; -PolygonTrigger *PolygonTool::m_poly_curSelectedPolygon = nullptr; -Int PolygonTool::m_poly_dragPointNdx = -1; - -enum {SNAP_DISTANCE = 5}; - -/// Constructor -PolygonTool::PolygonTool() : - Tool(ID_POLYGON_TOOL, IDC_POLYGON), - m_poly_plusCursor(nullptr), - m_poly_moveCursor(nullptr) -{ -} - - - -/// Destructor -PolygonTool::~PolygonTool() -{ - if (m_poly_plusCursor) { - ::DestroyCursor(m_poly_plusCursor); - } - if (m_poly_moveCursor) { - ::DestroyCursor(m_poly_moveCursor); - } -} - -/// Clears it's is active flag. -void PolygonTool::deactivate() -{ - m_poly_dragPointNdx = -1; - if (m_poly_curSelectedPolygon) { - Int numPoints = m_poly_curSelectedPolygon->getNumPoints(); - if (numPoints < 3) { - deleteSelectedPolygon(); - } - } - m_poly_isActive = false; - m_poly_curSelectedPolygon = nullptr; -} - -/// Shows the terrain materials options panel. -void PolygonTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WAYPOINT_OPTIONS); - WaypointOptions::update(); - if (!m_poly_curSelectedPolygon) { - PointerTool::clearSelection(); - DrawObject::setDoBrushFeedback(false); - m_poly_isActive = true; - m_poly_isAdding = false; - m_poly_mouseUpMove = false; - m_poly_mouseUpPlus = false; - } -} - -// Pick a polygon. -Bool PolygonTool::poly_pickPoly(PolygonTrigger *pTrig, Coord3D loc, Int tolerance) { - ICoord3D iDocPt; - iDocPt.x = floor(loc.x+0.5f); - iDocPt.y = floor(loc.y+0.5f); - iDocPt.z = floor(loc.z+0.5f); - Int i, j; - ICoord3D ptArray[9]; - for (i=0; i<3; i++) { - for (j=0; j<3; j++) { - ptArray[i+3*j].x = iDocPt.x + (1-i)*tolerance; - ptArray[i+3*j].y = iDocPt.y + (1-j)*tolerance; - ptArray[i+3*j].z = iDocPt.z; - } - } - int count = 0; - for (i=0; i<9; i++) { - if (pTrig->pointInTrigger(ptArray[i])) { - count++; - } - } - if (count>0 && count<8) { - return true; - } - return false; -} - - - -// Pick a polygon. -PolygonTrigger *PolygonTool::pickPolygon(Coord3D loc, CPoint viewPt, WbView* pView) { - PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); - for (; pTrig; pTrig = pTrig->getNext()) { - // For water, only do water - if (WaterTool::isActive() && !pTrig->isWaterArea()) { - continue; - } - if (poly_pickPoly(pTrig, loc, SNAP_DISTANCE/2)) { - return pTrig; - } - } - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (WaterTool::isActive() && !pTrig->isWaterArea()) { - continue; - } - Coord3D docPt = loc; - Int pt = poly_pickPoint(pTrig, viewPt, pView); - if (pt>=0) { - return pTrig; - } - if (poly_pickPoly(pTrig, docPt, 3*SNAP_DISTANCE/2)) { - return pTrig; - } - } - return nullptr; -} - -// Snap to other polys. -Bool PolygonTool::poly_snapToPoly(Coord3D *pLoc) { - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - Int i; - // Dont' snap to self. - if (pTrig == m_poly_curSelectedPolygon) continue; - for (i=0; igetNumPoints(); i++) { - ICoord3D iLoc = *pTrig->getPoint(i); - Coord3D cpt = *pLoc; - cpt.x -= iLoc.x; - cpt.y -= iLoc.y; - cpt.z = 0; - if (cpt.length() < 1.0f*SNAP_DISTANCE) { - pLoc->x = iLoc.x; - pLoc->y = iLoc.y; - return true; - } - } - } - return false; -} - -// Pick a point. -Int PolygonTool::poly_pickPoint(PolygonTrigger *pTrig, CPoint viewPt, WbView* pView) { - if (pTrig==nullptr) return -1; - Int i; - const Int PICK_PIXELS = pView->getPickPixels(); - for (i=0; igetNumPoints(); i++) { - ICoord3D iLoc = *pTrig->getPoint(i); - Coord3D cpt; - cpt.x = iLoc.x; - cpt.y = iLoc.y; - cpt.z = iLoc.z; - cpt.z = 0; - CPoint screenLoc; - pView->docToViewCoords(cpt, &screenLoc); - Int dx = screenLoc.x-viewPt.x; - Int dy = screenLoc.y - viewPt.y; - if (dy<0) dy = -dy; - if (dx<0) dx = -dx; - if (dx<=PICK_PIXELS && dy<= PICK_PIXELS) { - return i; - } - } - return -1; -} - -// Get the point to insert closest to loc. -Int PolygonTool::poly_getInsertIndex(PolygonTrigger *pTrig, Coord3D loc) { - if (pTrig==nullptr) return 0; - static Int tolerance = SNAP_DISTANCE; - - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D pt1 = *pTrig->getPoint(i); - ICoord3D pt2; - Int theNdx = i+1; - if (i==pTrig->getNumPoints()-1) { - pt2 = *pTrig->getPoint(0); - theNdx = 0; - } else { - pt2 = *pTrig->getPoint(i+1); - } - Int minX = loc.x-tolerance; - if (pt1.xmaxX && pt2.x>maxX) continue; - Int minY = loc.y-tolerance; - if (pt1.ymaxY && pt2.y>maxY) continue; - Int dy = pt2.y-pt1.y; - Int dx = pt2.x-pt1.x; - if (abs(dy)>abs(dx)) { - Real intersectionX = pt1.x + (dx * (loc.y-pt1.y)) / ((Real)dy); - if (intersectionX >= minX && intersectionX <= maxX) { - return theNdx; - } - } else { - Real intersectionY = pt1.y + (dy * (loc.x-pt1.x)) / ((Real)dx); - if (intersectionY >= minY && intersectionY <= maxY) { - return theNdx; - } - } - } - return 0; -} - -/** Do the pick on poly triggers. */ -void PolygonTool::poly_pickOnMouseDown(CPoint viewPt, WbView* pView) -{ - m_poly_dragPointNdx = -1; - if (m_poly_curSelectedPolygon) { - Bool found = false; - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (m_poly_curSelectedPolygon == pTrig) { - found = true; - break; - } - } - if (!found) { - m_poly_curSelectedPolygon = nullptr; // Undo probably made it go away. - } - } - m_poly_justPicked = false; // Always false here. Pointer tool sets to true. - if (m_poly_curSelectedPolygon == nullptr || !m_poly_isAdding) { - PolygonTrigger *pSel; - Coord3D docPt = m_poly_unsnappedMouseDownPt; - if (m_poly_curSelectedPolygon && poly_pickPoly(m_poly_curSelectedPolygon, docPt, SNAP_DISTANCE)) { - pSel = m_poly_curSelectedPolygon; - } else { - pSel = pickPolygon(docPt, viewPt, pView); - } - m_poly_curSelectedPolygon = pSel; - m_poly_isAdding = false; - } -} - - - -/// Perform the tool behavior on mouse down. -void PolygonTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - m_poly_unsnappedMouseDownPt = docPt; - poly_pickOnMouseDown(viewPt, pView); - if (!poly_snapToPoly(&docPt)) { - pView->snapPoint(&docPt); - } - m_poly_mouseDownPt = docPt; - startMouseDown(m, viewPt, pView, pDoc); -} - -/// Perform the tool behavior on mouse down. -void PolygonTool::startMouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - // Clear any selected map objects. - if (!m_poly_curSelectedPolygon) PointerTool::clearSelection(); - - ICoord3D iDocPt; - iDocPt.x = floor(m_poly_mouseDownPt.x+0.5f); - iDocPt.y = floor(m_poly_mouseDownPt.y+0.5f); - iDocPt.z = floor(m_poly_mouseDownPt.z+0.5f); - if (m_poly_curSelectedPolygon && m_poly_curSelectedPolygon->isWaterArea()) { - iDocPt.z = m_poly_curSelectedPolygon->getPoint(0)->z; - } - m_poly_dragPointNdx = -1; - m_poly_moveUndoable = nullptr; - if (m_poly_curSelectedPolygon==nullptr) { - // adding a new polygon. - m_poly_curSelectedPolygon = newInstance(PolygonTrigger)(32); - AsciiString name; - name.format("Area %d", m_poly_curSelectedPolygon->getID()); - m_poly_curSelectedPolygon->setTriggerName(name); - m_poly_curSelectedPolygon->addPoint(iDocPt); - m_poly_dragPointNdx = 0; - AddPolygonUndoable *pUndo = new AddPolygonUndoable(m_poly_curSelectedPolygon); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_poly_isAdding = true; - } else { - m_poly_dragPointNdx = poly_pickPoint(m_poly_curSelectedPolygon, viewPt, pView); - if (m_poly_isAdding) { - if (m_poly_dragPointNdx == 0) { - // closing the poly. - m_poly_isAdding = false; - } else { - m_poly_dragPointNdx = -1; - } - } - if (m_poly_isAdding && m_poly_dragPointNdx == -1) { - // Continuing to add points. - m_poly_dragPointNdx = m_poly_curSelectedPolygon->getNumPoints(); - AddPolygonPointUndoable *pUndo = new AddPolygonPointUndoable(m_poly_curSelectedPolygon, iDocPt); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } else if (m_poly_dragPointNdx != -1) { - // Moving a point on the polygon. - ModifyPolygonPointUndoable *pUndo = new ModifyPolygonPointUndoable(m_poly_curSelectedPolygon, m_poly_dragPointNdx); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } else if (m_poly_justPicked) { - // Move the entire polygon. - m_poly_moveUndoable = new MovePolygonUndoable(m_poly_curSelectedPolygon); - pDoc->AddAndDoUndoable(m_poly_moveUndoable); - } else { - // Insert a point. - Coord3D docPt = m_poly_unsnappedMouseDownPt; - m_poly_dragPointNdx = poly_getInsertIndex(m_poly_curSelectedPolygon, docPt); - InsertPolygonPointUndoable *pUndo = new InsertPolygonPointUndoable(m_poly_curSelectedPolygon, iDocPt, m_poly_dragPointNdx); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - } - WaypointOptions::update(); -} - -/// Delete the selected polygon or point. -Bool PolygonTool::deleteSelectedPolygon() -{ - if (m_poly_curSelectedPolygon) { - Bool found = false; - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (m_poly_curSelectedPolygon == pTrig) { - found = true; - break; - } - } - if (!found) { - m_poly_curSelectedPolygon = nullptr; // Undo probably made it go away. - } - } - if (m_poly_curSelectedPolygon == nullptr) { - return false; - } - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return false; - if (m_poly_dragPointNdx != -1) { - // Moving a point on the polygon. - DeletePolygonPointUndoable *pUndo = new DeletePolygonPointUndoable(m_poly_curSelectedPolygon, m_poly_dragPointNdx); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_poly_dragPointNdx = -1; - } else { - // delete the polygon. - DeletePolygonUndoable *pUndo = new DeletePolygonUndoable(m_poly_curSelectedPolygon); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_poly_curSelectedPolygon = nullptr; - m_poly_dragPointNdx = -1; - } - WaypointOptions::update(); - return true; -} - -/** Set the cursor. */ -void PolygonTool::setCursor() -{ - if (m_poly_mouseUpPlus || (m_poly_isAdding && m_poly_curSelectedPolygon)) { - if (m_poly_plusCursor == nullptr) { - m_poly_plusCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_POLYGON_PLUS)); - } - ::SetCursor(m_poly_plusCursor); - } else if (m_poly_mouseUpMove) { - if (m_poly_moveCursor == nullptr) { - m_poly_moveCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_POLYGON_MOVE)); - } - ::SetCursor(m_poly_moveCursor); - } else { - Tool::setCursor(); - } -} - - - -/// Left button move code. -void PolygonTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - if (m == TRACK_NONE) { - PolygonTrigger *pCur = m_poly_curSelectedPolygon; - Int curPt = m_poly_dragPointNdx; - m_poly_unsnappedMouseDownPt = docPt; - poly_pickOnMouseDown(viewPt, pView); - m_poly_mouseUpPlus = false; - m_poly_mouseUpMove = false; - if (m_poly_curSelectedPolygon) { - Int pt = poly_pickPoint(m_poly_curSelectedPolygon, viewPt, pView); - if (pt >= 0) { - m_poly_mouseUpMove = true; - } else { - m_poly_mouseUpPlus = true; - } - } - m_poly_curSelectedPolygon = pCur; - m_poly_dragPointNdx = curPt; - return; // setCursor will use the value of m_mouseUpRotate. jba. - } - - if (m != TRACK_L) return; - if (!poly_snapToPoly(&docPt)) { - pView->snapPoint(&docPt); - } - if (m_poly_moveUndoable) { - ICoord3D iDocPt; - iDocPt.x = floor(docPt.x+0.5f-m_poly_mouseDownPt.x); - iDocPt.y = floor(docPt.y+0.5f-m_poly_mouseDownPt.y); - iDocPt.z = 0; - m_poly_moveUndoable->SetOffset(iDocPt); - pView->Invalidate(); - return; - } - if (m_poly_dragPointNdx >= 0 && m_poly_curSelectedPolygon) { - ICoord3D iDocPt; - iDocPt.x = floor(docPt.x+0.5f); - iDocPt.y = floor(docPt.y+0.5f); - iDocPt.z = floor(docPt.z+0.5f); - if (m_poly_curSelectedPolygon->isWaterArea()) { - iDocPt.z = m_poly_curSelectedPolygon->getPoint(m_poly_dragPointNdx)->z; - } - m_poly_curSelectedPolygon->setPoint(iDocPt, m_poly_dragPointNdx); - pView->Invalidate(); - } -} - -/** Mouse up - not much. */ -void PolygonTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - REF_PTR_RELEASE(m_poly_moveUndoable); // belongs to pDoc now. -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RampOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RampOptions.cpp deleted file mode 100644 index 6553580b6f9..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RampOptions.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: RampOptions.cpp -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: RampOptions.cpp */ -/* Created: John K. McDonald, Jr., 4/23/2002 */ -/* Desc: // Ramp options. Contains the Apply button */ -/* Revision History: */ -/* 4/23/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#include "StdAfx.h" -#include "RampOptions.h" - -RampOptions::RampOptions(CWnd* pParent) : COptionsPanel(RampOptions::IDD, pParent) -{ - if (TheRampOptions) { - // oh shit. - return; - } - - TheRampOptions = this; - m_rampWidth = 20; - m_shouldApplyTheRamp = false; -} - -RampOptions::~RampOptions() -{ - TheRampOptions = nullptr; -} - -Bool RampOptions::shouldApplyTheRamp() -{ - if (m_shouldApplyTheRamp) { - m_shouldApplyTheRamp = false; - return true; - } - - return false; -} - -void RampOptions::OnApply() -{ - // Set m_shouldApplyTheRamp true. The call to shouldApplyRamp will set it false - m_shouldApplyTheRamp = true; -} - -void RampOptions::OnWidthChange() -{ - CString str; - CWnd* pWnd = GetDlgItem(IDC_RO_WIDTH); - if (!pWnd) { - return; - } - - pWnd->GetWindowText(str); - m_rampWidth = atof(str.GetBuffer(0)); -} - -RampOptions* TheRampOptions = nullptr; - -BEGIN_MESSAGE_MAP(RampOptions, COptionsPanel) - ON_BN_CLICKED(IDC_RO_APPLY, OnApply) - ON_EN_CHANGE(IDC_RO_WIDTH, OnWidthChange) -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp deleted file mode 100644 index 4e2cf875af8..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: RampTool.cpp -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: RampTool.cpp */ -/* Created: John K. McDonald, Jr., 4/19/2002 */ -/* Desc: // Ramp tool implementation */ -/* Revision History: */ -/* 4/19/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - - -#include "StdAfx.h" -#include "RampTool.h" - -#include "CUndoable.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "RampOptions.h" -#include "resource.h" -#include "wbview.h" -#include "WHeightMapEdit.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" - -#include "GameClient/Line2D.h" - - -#include "W3DDevice/GameClient/HeightMap.h" - -RampTool::RampTool() : Tool(ID_RAMPTOOL, IDC_RAMP ) -{ - -} - -void RampTool::activate() -{ - Tool::activate(); - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_RAMP_OPTIONS); - - mIsMouseDown = false; -} - -void RampTool::deactivate() -{ - DrawObject::setDoRampFeedback(false); - mIsMouseDown = false; -} - -Bool RampTool::followsTerrain() -{ - return true; -} - -void RampTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (!((m == TRACK_L) && mIsMouseDown)) { - if (TheRampOptions->shouldApplyTheRamp()) { - // Call me now for your free ramp application! - applyRamp(pDoc); - return; - } - } else if (m == TRACK_L) { - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - docPt.z = TheTerrainRenderObject->getHeightMapHeight(docPt.x, docPt.y, nullptr); - mEndPoint = docPt; - } - - drawFeedback(&mEndPoint); -} - -void RampTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) { - return; - } - - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - mStartPoint = docPt; - mStartPoint.z = TheTerrainRenderObject->getHeightMapHeight(mStartPoint.x, mStartPoint.y, nullptr); - - mIsMouseDown = true; -} - -void RampTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - - if (!((m == TRACK_L) && mIsMouseDown)) { - return; - } - - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - mEndPoint = docPt; - mEndPoint.z = TheTerrainRenderObject->getHeightMapHeight(mEndPoint.x, mEndPoint.y, nullptr); - - mIsMouseDown = false; -} - -void RampTool::drawFeedback(Coord3D* endPoint) -{ - DrawObject::setDoRampFeedback(true); - DrawObject::setRampFeedbackParms(&mStartPoint, endPoint, TheRampOptions->getRampWidth()); -} - -void RampTool::applyRamp(CWorldBuilderDoc* pDoc) -{ - Coord3D bl, tl, br, tr; - VecHeightMapIndexes indices; - - WorldHeightMapEdit *worldHeightDup = pDoc->GetHeightMap()->duplicate(); - - Real width = TheRampOptions->getRampWidth(); - - BuildRectFromSegmentAndWidth(&mStartPoint, &mEndPoint, width, - &bl, &tl, &br, &tr); - - if (bl == br || bl == tl) { - return; - } - - getAllIndexesIn(&bl, &br, &tl, &tr, 0, pDoc, &indices); - int indiceCount = indices.size(); - if (indiceCount == 0) { - return; - } - - /* - This part is pretty straightforward. Determine the U value for the shortest segment from the - index's actual location to the segments from mStartPoint to mEndPoint, and then apply a - linear gradient factor according to the height from the beginning to the end of mStartPoint - and mEndPoint. - */ - - for (int i = 0; i < indiceCount; ++i) { - Coord3D pt; - pDoc->getCoordFromCellIndex(indices[i], &pt); - - Real uVal; - Coord2D start = { mStartPoint.x, mStartPoint.y }; - Coord2D end = { mEndPoint.x, mEndPoint.y }; - Coord2D pt2D = { pt.x, pt.y }; - - ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); - Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); - - worldHeightDup->setHeight(indices[i].x, indices[i].y, (UnsignedByte) (height / MAP_HEIGHT_SCALE)); - } - - IRegion2D partialRange = {0,0,0,0}; - pDoc->updateHeightMap(worldHeightDup, false, partialRange); - - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, worldHeightDup); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(worldHeightDup); - - - // Once we've applied the ramp, its no longer a mutable thing, so blow away the feedback - DrawObject::setDoRampFeedback(false); -} - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp deleted file mode 100644 index 3e52ecb5864..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ /dev/null @@ -1,610 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// RoadOptions.cpp : implementation file -// - - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "RoadOptions.h" -#include "CUndoable.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/FileSystem.h" -#include "GameClient/TerrainRoads.h" - -#include - -RoadOptions *RoadOptions::m_staticThis = nullptr; -Bool RoadOptions::m_updating = false; -AsciiString RoadOptions::m_currentRoadName; -Int RoadOptions::m_currentRoadIndex=0; -Int RoadOptions::m_numberOfRoads=0; -Int RoadOptions::m_numberOfBridges=0; - -Bool RoadOptions::m_angleCorners = false; ///SetWindowText(tName); - } -} - -/** Returns true if only one or more roads is selected. */ -Bool RoadOptions::selectionIsRoadsOnly() -{ -// MapObject *theMapObj = nullptr; - Bool foundRoad = false; - Bool foundAnythingElse = false; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected()) { - if (pMapObj->getFlag(FLAG_ROAD_FLAGS)) { - foundRoad = true; - } else { - foundAnythingElse = true; - } - } - } - return (foundRoad && (!foundAnythingElse)); -} - -/** Returns true if only one or more roads is selected. */ -void RoadOptions::updateSelection() -{ -// MapObject *theMapObj = nullptr; - Int angled = 0; - Int tight = 0; - Int broad = 0; - Int join = 0; - AsciiString roadName; - Bool multipleNames = false; - - if (!m_staticThis) return; - MapObject *pMapObj; - - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected() && pMapObj->getFlag(FLAG_ROAD_FLAGS)) { - if (roadName.isEmpty()) { - roadName = pMapObj->getName(); - } else { - if (!(roadName==pMapObj->getName())) { - multipleNames = true; - } - } - if (pMapObj->getFlag(FLAG_ROAD_CORNER_ANGLED)) { - angled = 1; - } else if (pMapObj->getFlag(FLAG_ROAD_CORNER_TIGHT)) { - tight = 1; - } else { - broad = 1; - } - if (pMapObj->getFlag(FLAG_ROAD_JOIN)) { - join = 1; - } - } - } - if (!roadName.isEmpty() && !multipleNames) { - CWnd *pLabel = m_staticThis->GetDlgItem(IDC_ROAD_NAME); - if (pLabel) { - pLabel->SetWindowText(roadName.str()); - m_staticThis->findAndSelect(TVI_ROOT, roadName); - } - } else { - m_staticThis->setRoadTreeViewSelection(TVI_ROOT, m_currentRoadIndex); - } - if (angled+broad+tight==0) { - // nothing selected - if (m_angleCorners) { - angled = 1; - } else if (m_tightCurve) { - tight = 1; - } else { - broad = 1; - } - if (m_doJoin) { - join = 1; - } - } else if (angled+broad+tight==1) { - // One type selected - } else { - angled = tight = broad = join = 0; - } - if (m_staticThis) { - CButton *pButton = (CButton *)m_staticThis->GetDlgItem(IDC_TIGHT_CURVE); - pButton->SetCheck(tight); - pButton = (CButton *)m_staticThis->GetDlgItem(IDC_BROAD_CURVE); - pButton->SetCheck(broad); - pButton = (CButton *)m_staticThis->GetDlgItem(IDC_ANGLED); - pButton->SetCheck(angled); - pButton = (CButton *)m_staticThis->GetDlgItem(IDC_JOIN); - pButton->SetCheck(join); - } -} - -/** Applies road corner flags and road type to selection. */ -void RoadOptions::applyToSelection() -{ - Int flagMask = FLAG_ROAD_CORNER_ANGLED | FLAG_ROAD_CORNER_TIGHT; - Int flagVal = 0; - if (m_angleCorners) { - flagVal = FLAG_ROAD_CORNER_ANGLED; - } else if (m_tightCurve) { - flagVal = FLAG_ROAD_CORNER_TIGHT; - } - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - ModifyFlagsUndoable *pUndo = new ModifyFlagsUndoable(pDoc, flagMask, flagVal); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. -} - - -///////////////////////////////////////////////////////////////////////////// -// RoadOptions message handlers - -/// Setup the controls in the dialog. -BOOL RoadOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - - CWnd *pWnd = GetDlgItem(IDC_ROAD_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_roadTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_ROAD_TREEVIEW); - m_roadTreeView.ShowWindow(SW_SHOW); - - Int index = 0; - m_numberOfRoads = 0; - - // load roads from INI - TerrainRoadType *road; - for( road = TheTerrainRoads->firstRoad(); road; road = TheTerrainRoads->nextRoad( road ) ) - { - - addRoad( (char *)road->getName().str(), index, TVI_ROOT ); - index++; - m_numberOfRoads++; - - } - - // load roads from test assets -#ifdef LOAD_TEST_ASSETS - { - char fileBuf[_MAX_PATH]; - - FilenameList filenameList; - TheFileSystem->getFileListInDirectory(ROAD_DIRECTORY, "*.tga", filenameList, FALSE); - - if (!filenameList.empty()) { - FilenameList::iterator it = filenameList.begin(); - do { - AsciiString filename = *it; - - if ((filename.compare(".") == 0) || (filename.compare("..") == 0)) { - ++it; - continue; - } - int len = filename.getLength(); - if (len<5) { - ++it; - continue; - } - // only do .tga files - if (!(filename.endsWith(".tga"))) { - ++it; - continue; - } - static_assert(ARRAY_SIZE(fileBuf) >= ARRAY_SIZE(TEST_STRING), "Incorrect array size"); - strcpy(fileBuf, TEST_STRING); - strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); - strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); - addRoad(fileBuf, index, TVI_ROOT); - index++; - m_numberOfRoads++; - ++it; - } while (it != filenameList.end()); - - } - } -#endif - - m_numberOfBridges = 0; - // add bridge defs from INI - TerrainRoadType *bridge; - for( bridge = TheTerrainRoads->firstBridge(); - bridge; - bridge = TheTerrainRoads->nextBridge( bridge ) ) - { - - addRoad( (char *)bridge->getName().str(), index, TVI_ROOT ); - index++; - m_numberOfBridges++; - - } - - m_currentRoadIndex = 1; - setRoadTreeViewSelection(TVI_ROOT, m_currentRoadIndex); - updateLabel(); - m_staticThis = this; - updateSelection(); - m_updating = false; - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM RoadOptions::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_roadTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_roadTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_roadTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = const_cast(pLabel); - ins.item.cchTextMax = strlen(pLabel); - child = m_roadTreeView.InsertItem(&ins); - return(child); -} - -/** Locate and select child item in tree item parent with name pLabel. If not -found, false. If found, return true. */ -Bool RoadOptions::findAndSelect(HTREEITEM parent, AsciiString label) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_roadTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_roadTreeView.GetItem(&ins.item); - if (label.compare(buffer) == 0) { - m_roadTreeView.SelectItem(child); - return(true); - } - if (findAndSelect(child, label)) { - return true; - } - child = m_roadTreeView.GetNextSiblingItem(child); - } - return false; -} - -/** Add the road hierarchy paths to the tree view. */ -void RoadOptions::addRoad(char *pPath, Int terrainNdx, HTREEITEM parent) -{ - TerrainRoadType *road; - char buffer[_MAX_PATH]; - Bool doAdd = FALSE; - - // try to find the road in our INI definition - road = TheTerrainRoads->findRoadOrBridge( AsciiString( pPath ) ); - if( road ) - { - - // roads go in a road tree, bridges in their own tree - if( road->isBridge() == TRUE ) - parent = findOrAdd( parent, "Bridges" ); - else - parent = findOrAdd( parent, "Roads" ); - - // set the name to place as the name of the road entry in INI - strlcpy(buffer, road->getName().str(), ARRAY_SIZE(buffer)); - - // do the add - doAdd = TRUE; - - } - -#ifdef LOAD_TEST_ASSETS - if (!doAdd && !strncmp(TEST_STRING, pPath, strlen(TEST_STRING))) { - parent = findOrAdd(parent, TEST_STRING); - strlcpy(buffer, pPath + strlen(TEST_STRING) + 1, ARRAY_SIZE(buffer)); - doAdd = true; - } -#endif - - if( doAdd ) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = buffer; - ins.item.cchTextMax = strlen(buffer)+2; - m_roadTreeView.InsertItem(&ins); - } - -} - -/// Set the selected road in the tree view. -Bool RoadOptions::setRoadTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[NAME_MAX_LEN]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_roadTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_roadTreeView.GetItem(&item); - if (item.lParam == selection) { - m_roadTreeView.SelectItem(child); - m_currentRoadName = buffer; - return(true); - } - if (setRoadTreeViewSelection(child, selection)) { - return(true); - } - child = m_roadTreeView.GetNextSiblingItem(child); - } - return(false); -} - -void RoadOptions::SelectConnected() -{ - std::list roadSegs; - std::list connectedSegs; - for (MapObject* pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - if (pMapObj->getFlag(FLAG_ROAD_POINT1)) - { - if (pMapObj->isSelected() || pMapObj->getNext() && pMapObj->getNext()->isSelected()) - { - connectedSegs.push_back(pMapObj); - } - else - { - roadSegs.push_back(pMapObj); - } - } - } - Bool changed = true; - while (changed) - { - changed = false; - for (std::list::iterator it = roadSegs.begin(); it != roadSegs.end(); ++it) - { - MapObject* o = *it; - const Coord3D *oLoc = o->getLocation(); - const Coord3D *onLoc = o->getNext()->getLocation(); - for (std::list::iterator connected = connectedSegs.begin(); connected != connectedSegs.end(); ++connected) - { - MapObject* p = *connected; - const Coord3D *pLoc = p->getLocation(); - const Coord3D *pnLoc = p->getNext()->getLocation(); - - Real dx1 = oLoc->x - pLoc->x; - Real dy1 = oLoc->y - pLoc->y; - dx1 = abs(dx1); - dy1 = abs(dy1); - Real qd1 = max(dx1, dy1); - //Real dist1 = sqrt(dx1*dx1+dy1*dy1); - - Real dx2 = oLoc->x - pnLoc->x; - Real dy2 = oLoc->y - pnLoc->y; - dx2 = abs(dx2); - dy2 = abs(dy2); - Real qd2 = max(dx2, dy2); - //Real dist2 = sqrt(dx2*dx2+dy2*dy2); - - Real dx3 = onLoc->x - pLoc->x; - Real dy3 = onLoc->y - pLoc->y; - dx3 = abs(dx3); - dy3 = abs(dy3); - Real qd3 = max(dx3, dy3); - //Real dist3 = sqrt(dx3*dx3+dy3*dy3); - - Real dx4 = onLoc->x - pnLoc->x; - Real dy4 = onLoc->y - pnLoc->y; - dx4 = abs(dx4); - dy4 = abs(dy4); - Real qd4 = max(dx4, dy4); - //Real dist4 = sqrt(dx4*dx4+dy4*dy4); - - if (qd1 < MAP_XY_FACTOR/100 || qd2 < MAP_XY_FACTOR/100 || qd3 < MAP_XY_FACTOR/100 || qd4 < MAP_XY_FACTOR/100) { - connectedSegs.push_back(o); - roadSegs.erase(it); - changed = true; - break; - } - } - } - } - - for (std::list::iterator connected = connectedSegs.begin(); connected != connectedSegs.end(); ++connected) - { - MapObject* p = *connected; - if (p) { - p->setSelected(true); - p->getNext()->setSelected(true); - } - } -} - -void RoadOptions::ChangeRoadType(AsciiString newRoad) -{ - SelectConnected(); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - ModifyObjectUndoable *pUndo = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(pUndo); - pUndo->SetName(newRoad); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. -} - -BOOL RoadOptions::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_roadTreeView.m_hWnd) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[NAME_MAX_LEN]; - HTREEITEM hItem = m_roadTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_roadTreeView.GetItem(&item); - if (item.lParam >= 0) { - m_currentRoadIndex = item.lParam; - m_currentRoadName = buffer; - updateLabel(); - } else if (!(item.state & TVIS_EXPANDEDONCE) ) { - HTREEITEM child = m_roadTreeView.GetChildItem(hItem); - while (child != nullptr) { - hItem = child; - child = m_roadTreeView.GetChildItem(hItem); - } - if (hItem != m_roadTreeView.GetSelectedItem()) { - m_roadTreeView.SelectItem(hItem); - updateSelection(); - } - } - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - - -void RoadOptions::OnTightCurve() -{ - m_angleCorners = false; - m_tightCurve = true; - applyToSelection(); -} - -void RoadOptions::OnAngled() -{ - m_angleCorners = true; - m_tightCurve = false; - applyToSelection(); -} - -void RoadOptions::OnBroadCurve() -{ - m_angleCorners = false; - m_tightCurve = false; - applyToSelection(); -} - -void RoadOptions::OnJoin() -{ - CButton *pButton = (CButton *)m_staticThis->GetDlgItem(IDC_JOIN); - m_doJoin = pButton->GetCheck()==1; - Int flagMask = FLAG_ROAD_JOIN; - Int flagVal = 0; - if (m_doJoin) { - flagVal = FLAG_ROAD_JOIN; - } - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - ModifyFlagsUndoable *pUndo = new ModifyFlagsUndoable(pDoc, flagMask, flagVal); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. -} - -void RoadOptions::OnApplyRoad() -{ - if (m_currentRoadName != AsciiString::TheEmptyString) - { - ChangeRoadType(m_currentRoadName); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp deleted file mode 100644 index 39ea5558efd..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// RoadTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "RoadTool.h" -#include "CUndoable.h" -#include "DrawObject.h" -#include "PointerTool.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "GameClient/Line2D.h" -// -// RoadTool class. -// -/// Constructor -RoadTool::RoadTool() : - Tool(ID_ROAD_TOOL, IDC_ROAD) -{ - m_mapObj = nullptr; -} - -/// Destructor -RoadTool::~RoadTool() -{ - m_mapObj = nullptr; -} -//----------------------------------------------------------------------------- -// Public Functions -//----------------------------------------------------------------------------- - -MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) -{ - for (MapObject* pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - if (pMapObj->getFlag(FLAG_ROAD_POINT1)) - { - MapObject* pMapObj2 = pMapObj->getNext(); - if (pMapObj2==nullptr) - break; - if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) - continue; - Coord2D start, end, loc, snapLoc; - start.x = pMapObj->getLocation()->x; - start.y = pMapObj->getLocation()->y; - end.x = pMapObj2->getLocation()->x; - end.y = pMapObj2->getLocation()->y; - loc.x = pLoc->x; - loc.y = pLoc->y; - Real dist; - Real u; - - ShortestDistancePointToSegment2D(&start, &end, &loc, nullptr, &snapLoc, &u); - if (u < 0 || u > 1) { - continue; - } - Coord2D segment; - segment.x = loc.x - snapLoc.x; - segment.y = loc.y - snapLoc.y; - dist = segment.length(); - - if (dist < ROAD_SNAP_DISTANCE*MAP_XY_FACTOR) - { - outLoc->x = snapLoc.x; - outLoc->y = snapLoc.y; - outLoc->z = MAGIC_GROUND_Z; - return(pMapObj); - } - } - } - return nullptr; -} - -//============================================================================= -// RoadTool::snap -//============================================================================= -/** Snaps pLoc to another road endpoint if close enough. */ -//============================================================================= -Bool RoadTool::snap(Coord3D *pLoc, Bool skipFirst) -{ - MapObject *pMapObj; - MapObject *pMapObj2; - Real snapDist = ROAD_SNAP_DISTANCE*MAP_XY_FACTOR; - Coord3D newLoc = *pLoc; - Bool snapped = false; - - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (skipFirst) { - skipFirst = false; - continue; - } - if (pMapObj->getFlag(FLAG_ROAD_POINT1)) { - pMapObj2 = pMapObj->getNext(); - if (pMapObj2==nullptr) break; - if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; - Vector2 dist; - if (!pMapObj->isSelected()) { - dist.Set(pMapObj->getLocation()->x - pLoc->x, pMapObj->getLocation()->y - pLoc->y); - if (dist.Length() < snapDist) { - newLoc = *pMapObj->getLocation(); - snapDist = dist.Length(); - snapped = true; - } - } - if (!pMapObj2->isSelected()) { - dist.Set(pMapObj2->getLocation()->x - pLoc->x, pMapObj2->getLocation()->y - pLoc->y); - if (dist.Length() < snapDist) { - newLoc = *pMapObj2->getLocation(); - snapDist = dist.Length(); - snapped = true; - } - } - } - } - newLoc.z = MAGIC_GROUND_Z; // roads always snap to terrain. - if (snapped) { - *pLoc = newLoc; - } - return snapped; -} - - -/// Shows the road options panel. -void RoadTool::activate() -{ - PointerTool::clearSelection(); - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_ROAD_OPTIONS); - RoadOptions::updateSelection(); - DrawObject::setDoBrushFeedback(false); -} - -/** Execute the tool on mouse up - Place a road segment. */ -void RoadTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - Coord3D loc1, loc2, loc3; - loc1 = cpt; - if (!pDoc->getCellPositionFromCoord(cpt, &loc1)) - return; - - Bool isBridge = RoadOptions::isBridge(); - - if (isBridge) { - Bool isLandmark = false; - const ThingTemplate *tt = TheThingFactory->findTemplate(RoadOptions::getCurRoadName()); - if (tt) { - isLandmark = tt->isBridge(); - } - if (isLandmark) { - MapObject *pNew1 = newInstance(MapObject)(loc1, RoadOptions::getCurRoadName(), 0.0f, 0, nullptr, tt ); - pNew1->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew1); - pNew1->setSelected(true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_mapObj = nullptr; - return; - } - } - - - Bool snapped = false; - Bool divideSegment = false; - MapObject* pickedSegment = nullptr; - if (!isBridge) { - snapped = snap(&loc1, false); - if (!snapped) { - pickedSegment = findSegment(&loc1, &loc2); - if (pickedSegment) { - snapped = true; - divideSegment = true; - loc1 = *pickedSegment->getLocation(); - loc3 = *pickedSegment->getNext()->getLocation(); - } - } - } - if (!snapped) { - pView->snapPoint(&loc1); - } - - if (!divideSegment) { - loc2 = loc1; - } - - loc1.z = MAGIC_GROUND_Z; // roads stick to terrain anyway. - loc2.z = MAGIC_GROUND_Z; - loc3.z = MAGIC_GROUND_Z; - AsciiString roadName; - if (divideSegment) { - roadName = pickedSegment->getName(); - } else { - roadName = RoadOptions::getCurRoadName(); - } - - MapObject *pNew1 = newInstance(MapObject)(loc1, roadName, 0.0f, 0, nullptr, nullptr ); - MapObject *pNew2 = newInstance(MapObject)(loc2, roadName, 0.0f, 0, nullptr, nullptr ); - MapObject *pNew3 = nullptr; - MapObject *pNew4 = nullptr; - if (divideSegment) { - pNew3 = newInstance(MapObject)(loc2, roadName, 0.0f, 0, nullptr, nullptr ); - pNew4 = newInstance(MapObject)(loc3, roadName, 0.0f, 0, nullptr, nullptr ); - } - - pNew1->setColor(RGB(255,255,0)); // make road endpoints yellow. - pNew2->setColor(RGB(255,255,0)); // make road endpoints yellow. - if (divideSegment) { - pNew3->setColor(RGB(255,255,0)); // make road endpoints yellow. - pNew4->setColor(RGB(255,255,0)); // make road endpoints yellow. - } - - if (RoadOptions::isBridge()) { - pNew1->setFlag(FLAG_BRIDGE_POINT1); - pNew2->setFlag(FLAG_BRIDGE_POINT2); - } else { - pNew1->setFlag(FLAG_ROAD_POINT1); - pNew2->setFlag(FLAG_ROAD_POINT2); - if (divideSegment) { - pNew3->setFlag(FLAG_ROAD_POINT1); - pNew4->setFlag(FLAG_ROAD_POINT2); - } - } - - if (divideSegment) { - pNew1->setFlag(pickedSegment->getFlags()); - pNew4->setFlag(pickedSegment->getNext()->getFlags()); - } else { - if (RoadOptions::isAngled()) { - pNew1->setFlag(FLAG_ROAD_CORNER_ANGLED); - pNew2->setFlag(FLAG_ROAD_CORNER_ANGLED); - } else if (RoadOptions::isTightCurve()) { - pNew1->setFlag(FLAG_ROAD_CORNER_TIGHT); - pNew2->setFlag(FLAG_ROAD_CORNER_TIGHT); - } - } - - // Roads belong to the neutral player. :) - pNew1->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew2->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew1->setNextMap(pNew2); - m_mapObj = pNew2; - - if (divideSegment) { - // Roads belong to the neutral player. :) - pNew3->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew4->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew3->setNextMap(pNew4); - } - - if (divideSegment) { - PointerTool::clearSelection(); - pickedSegment->setSelected(true); - DeleteObjectUndoable *pDeleteUndo = new DeleteObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(pDeleteUndo); - REF_PTR_RELEASE(pDeleteUndo); // belongs to pDoc now. - } - // Clear the selection. - PointerTool::clearSelection(); - - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew1); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_mapObj->setSelected(true); - - if (divideSegment) { - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew3); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_mapObj = nullptr; - PointerTool::clearSelection(); - pNew2->setSelected(true); - pNew3->setSelected(true); - } - -} -/** Move the end of the road segment. */ -void RoadTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - Coord3D loc1 ; - if (m_mapObj == nullptr) { - return; - } - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - loc1.x=loc1.y=loc1.z=0; - if (!pDoc->getCellPositionFromCoord(cpt, &loc1)) - return; - - Bool isBridge = RoadOptions::isBridge(); - loc1.z = MAGIC_GROUND_Z; - Bool snapped = false; - if (!isBridge) { - snapped = snap(&loc1, false); - } - if (!snapped) { - pView->snapPoint(&loc1); - } - pDoc->invalObject(m_mapObj); - m_mapObj->setLocation(&loc1); - pDoc->invalObject(m_mapObj); -} - -void RoadTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - m_mapObj = nullptr; -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RulerOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RulerOptions.cpp deleted file mode 100644 index 735305edcb6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RulerOptions.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Mike Lytle -// 01/07/03 -// RulerOptions.cpp - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "RulerOptions.h" -#include "WorldBuilderView.h" -#include "RulerTool.h" - -RulerOptions* RulerOptions::m_staticThis = nullptr; - -///////////////////////////////////////////////////////////////////////////// -RulerOptions::RulerOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(RulerOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void RulerOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(RulerOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -/** Update the value in the edit control. */ -void RulerOptions::setWidth(Real width) -{ - CString buf; - // Multiply by 2 because we are changing from radius to diameter. - buf.Format("%f", width * 2.0f); - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_RULER_WIDTH); - if (pEdit && pEdit->IsWindowEnabled()) { - pEdit->SetWindowText(buf); - } - } -} - - -/// Dialog UI initialization. -BOOL RulerOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_staticThis = this; - m_updating = false; - if (RulerTool::getType() != RULER_CIRCLE) { - CWnd *pEdit = GetDlgItem(IDC_RULER_WIDTH); - if (pEdit) { - // Disable the edit box since the ruler isn't a circle. - pEdit->EnableWindow(false); - } - } else { - // Only the circle rulers use the edit box to change the size. - setWidth(RulerTool::getLength()); - } - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void RulerOptions::OnChangeWidthEdit() -{ - if (m_updating) return; - CWnd *pEdit = GetDlgItem(IDC_RULER_WIDTH); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - float width; - m_updating = true; - // Pull out the length from the text. - if (1 == sscanf(buffer, "%f", &width)) { - // Change from diameter to radius. - RulerTool::setLength(width / 2.0f); - } - m_updating = false; - } -} - -void RulerOptions::OnChangeCheckRuler() -{ - if (m_updating) return; - CWnd *pCheck = GetDlgItem(IDC_CHECK_RULER); - if (pCheck) { - if (RulerTool::switchType()) { - CWnd *pEdit = GetDlgItem(IDC_RULER_WIDTH); - if (pEdit) { - // The edit box is disabled when the ruler is a line. - pEdit->EnableWindow(!pEdit->IsWindowEnabled()); - // Make sure that the length is updated. - if (pEdit->IsWindowEnabled()) { - setWidth(RulerTool::getLength()); - } - } - } - } -} - - - - -BEGIN_MESSAGE_MAP(RulerOptions, COptionsPanel) - //{{AFX_MSG_MAP(RulerOptions) - ON_EN_CHANGE(IDC_RULER_WIDTH, OnChangeWidthEdit) - ON_BN_CLICKED(IDC_CHECK_RULER, OnChangeCheckRuler) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RulerTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RulerTool.cpp deleted file mode 100644 index de425122d29..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RulerTool.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// RulerTool.cpp -// Author: Mike Lytle, January 2003 - - -#include "StdAfx.h" -#include "resource.h" - -#include "RulerTool.h" -#include "MainFrm.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "wbview3d.h" -#include "ObjectTool.h" - - -// Saved off so that static functions can access its members. -RulerTool* RulerTool::m_staticThis = nullptr; - -/// Constructor -RulerTool::RulerTool() : -Tool(ID_RULER_TOOL, IDC_POINTER) -{ - m_downPt3d.set(0.0f, 0.0f, 0.0f); - m_rulerType = RULER_LINE; - m_View = nullptr; - m_staticThis = this; -} - -/// Destructor -RulerTool::~RulerTool() -{ -} - -// Activate. -void RulerTool::activate() -{ - Tool::activate(); - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_RULER_OPTIONS); - if (m_View != nullptr) { - // Is it dangerous to assume that the pointer is still good? - m_View->doRulerFeedback(m_rulerType); - } -} - -// Deactivate. -void RulerTool::deactivate() -{ - Tool::deactivate(); - - if (m_View != nullptr) { - m_View->doRulerFeedback(RULER_NONE); - } - -} - -/** Set the cursor. */ -void RulerTool::setCursor() -{ - Tool::setCursor(); -} - - -/** Execute the tool on mouse down */ -void RulerTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - if (m_View == nullptr) { - // Save so that when we are done the view can stop drawing the rulers. - m_View = pView; - } - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt); - - m_downPt3d = cpt; - pView->snapPoint(&m_downPt3d); -} - -/// Left button move code. -void RulerTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - - if (m_View == nullptr) { - // Save so that when we are done the view can stop drawing the rulers. - m_View = pView; - } - - Coord3D cpt; - pView->viewToDocCoords(viewPt, &cpt, false); - - if (m_rulerType == RULER_CIRCLE) { - Coord3D pt; - pt.x = cpt.x + m_savedLength; - pt.y = cpt.y + m_savedLength; - pt.z = cpt.z; - RulerOptions::setWidth(m_savedLength); - pView->doRulerFeedback(RULER_CIRCLE); - pView->rulerFeedbackInfo(cpt, pt, m_savedLength); - pView->Invalidate(); - } else { //m_rulerType == RULER_LINE - Coord3D diff; - diff.set(cpt); - diff.sub(m_downPt3d); - m_savedLength = diff.length(); - RulerOptions::setWidth(m_savedLength); - pView->doRulerFeedback(RULER_LINE); - pView->rulerFeedbackInfo(cpt, m_downPt3d, m_savedLength); - pView->Invalidate(); - } - - pDoc->updateAllViews(); -} - -void RulerTool::setLength(Real length) -{ - if (!m_staticThis || (m_staticThis->m_rulerType != RULER_CIRCLE)) { - // This should only be called when the ruler type is a circle. - // Line rulers are always extended by the mouse. - return; - } - - m_staticThis->m_savedLength = length; - if (m_staticThis->m_View) { - m_staticThis->m_View->rulerFeedbackInfo(m_staticThis->m_downPt3d, m_staticThis->m_downPt3d, length); - m_staticThis->m_View->Invalidate(); - } - - CString str; - str.Format("Diameter (in feet): %f", length * 2.0f); - CMainFrame::GetMainFrame()->SetMessageText(str); -} - -Bool RulerTool::switchType() -{ - if (!m_staticThis) { - return (FALSE); - } - - if (m_staticThis->m_rulerType == RULER_LINE) { - m_staticThis->m_rulerType = RULER_CIRCLE; - } else { - m_staticThis->m_rulerType = RULER_LINE; - } - if (m_staticThis->m_View != nullptr) { - m_staticThis->m_View->doRulerFeedback(m_staticThis->m_rulerType); - } - - return (TRUE); -} - -int RulerTool::getType() -{ - if (!m_staticThis) { - return (RULER_NONE); - } - - return (m_staticThis->m_rulerType); -} - -Real RulerTool::getLength() -{ - if (m_staticThis) { - return m_staticThis->m_savedLength; - } - - return (0.0f); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp deleted file mode 100644 index dd6ea4751fb..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// SaveMap.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "SaveMap.h" -#include "Common/GlobalData.h" - -///////////////////////////////////////////////////////////////////////////// -// SaveMap dialog - - -SaveMap::SaveMap(TSaveMapInfo *pInfo, CWnd* pParent /*=nullptr*/) - : CDialog(SaveMap::IDD, pParent), - m_pInfo(pInfo) -{ - m_pInfo->usingSystemDir = m_usingSystemDir = ::AfxGetApp()->GetProfileInt(MAP_OPENSAVE_PANEL_SECTION, "UseSystemDir", TRUE); - - //{{AFX_DATA_INIT(SaveMap) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void SaveMap::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(SaveMap) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(SaveMap, CDialog) - //{{AFX_MSG_MAP(SaveMap) - ON_BN_CLICKED(IDC_BROWSE, OnBrowse) - ON_BN_CLICKED(IDC_SYSTEMMAPS, OnSystemMaps) - ON_BN_CLICKED(IDC_USERMAPS, OnUserMaps) - ON_LBN_SELCHANGE(IDC_SAVE_LIST, OnSelchangeSaveList) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// SaveMap message handlers - -void SaveMap::OnSystemMaps() -{ - populateMapListbox( TRUE ); -} - -void SaveMap::OnUserMaps() -{ - populateMapListbox( FALSE ); -} - -void SaveMap::OnOK() -{ - CWnd *pEdit = GetDlgItem(IDC_SAVE_MAP_EDIT); - if (pEdit == nullptr) { - DEBUG_CRASH(("Bad resources.")); - OnCancel(); - return; - } - pEdit->GetWindowText(m_pInfo->filename); - m_pInfo->browse = false; - // Construct file name of .\Maps\mapname\mapname.map - CString testName; - if (m_usingSystemDir) - testName = ".\\Maps\\"; - else - { - testName = TheGlobalData->getPath_UserData().str(); - testName = testName + "Maps\\"; - } - testName += m_pInfo->filename + "\\" + m_pInfo->filename + ".map" ; - CFileStatus status; - if (CFile::GetStatus(testName, status)) { - CString warn; - warn.Format(IDS_REPLACEFILE, LPCTSTR(testName)); - Int ret = ::AfxMessageBox(warn, MB_YESNO); - if (ret == IDNO) { - return; - } - } - CDialog::OnOK(); -} - -void SaveMap::OnCancel() -{ - CDialog::OnCancel(); -} - -void SaveMap::OnBrowse() -{ - m_pInfo->browse = true; - CDialog::OnOK(); -} - -void SaveMap::populateMapListbox( Bool systemMaps ) -{ - m_pInfo->usingSystemDir = m_usingSystemDir = systemMaps; - ::AfxGetApp()->WriteProfileInt(MAP_OPENSAVE_PANEL_SECTION, "UseSystemDir", m_usingSystemDir); - - HANDLE hFindFile = nullptr; - WIN32_FIND_DATA findData; - char dirBuf[_MAX_PATH]; - char findBuf[_MAX_PATH]; - char fileBuf[_MAX_PATH]; - - if (systemMaps) - strcpy(dirBuf, ".\\Maps\\"); - else - snprintf(dirBuf, ARRAY_SIZE(dirBuf), "%sMaps\\", TheGlobalData->getPath_UserData().str()); - int len = strlen(dirBuf); - - if (len > 0 && dirBuf[len - 1] != '\\') { - dirBuf[len++] = '\\'; - dirBuf[len] = 0; - } - CListBox *pList = (CListBox *)this->GetDlgItem(IDC_SAVE_LIST); - if (pList == nullptr) return; - pList->ResetContent(); - snprintf(findBuf, ARRAY_SIZE(findBuf), "%s*.*", dirBuf); - - hFindFile = FindFirstFile(findBuf, &findData); - if (hFindFile != INVALID_HANDLE_VALUE) { - do { - if (strcmp(findData.cFileName, ".") == 0 || strcmp(findData.cFileName, "..") == 0) - continue; - if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { - continue; - } - snprintf(fileBuf, ARRAY_SIZE(fileBuf), "%s%s\\%s.map", dirBuf, findData.cFileName, findData.cFileName); - try { - CFileStatus status; - if (CFile::GetStatus(fileBuf, status)) { - if (!(status.m_attribute & CFile::directory)) { - pList->AddString(findData.cFileName); - }; - } - } catch(...) {} - - } while (FindNextFile(hFindFile, &findData)); - - if (hFindFile) FindClose(hFindFile); - } - CEdit *pEdit = (CEdit*)GetDlgItem(IDC_SAVE_MAP_EDIT); - if (pEdit != nullptr) { - strlcpy(fileBuf, m_pInfo->filename, ARRAY_SIZE(fileBuf)); - Int len = strlen(fileBuf); - if (len>4 && stricmp(".map", fileBuf+(len-4)) == 0) { - // strip of the .map - fileBuf[len-4] = 0; - } - while (len>0) { - if (fileBuf[len] == '\\') { - len++; - break; - } - len--; - } - pEdit->SetWindowText(&fileBuf[len]); - pEdit->SetSel(0, 1000, true); - pEdit->SetFocus(); - } -} - -void SaveMap::OnSelchangeSaveList() -{ - CListBox *pList = (CListBox *)this->GetDlgItem(IDC_SAVE_LIST); - if (pList == nullptr) { - return; - } - - Int sel = pList->GetCurSel(); - CString filename; - if (sel != LB_ERR) { - pList->GetText(sel, filename); - } - CWnd *pEdit = GetDlgItem(IDC_SAVE_MAP_EDIT); - if (pEdit == nullptr) { - return; - } - pEdit->SetWindowText(filename); -} - -BOOL SaveMap::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CButton *pSystemMaps = (CButton *)this->GetDlgItem(IDC_SYSTEMMAPS); - if (pSystemMaps != nullptr) - pSystemMaps->SetCheck( m_usingSystemDir ); - - CButton *pUserMaps = (CButton *)this->GetDlgItem(IDC_USERMAPS); - if (pUserMaps != nullptr) - pUserMaps->SetCheck( !m_usingSystemDir ); - - // TheSuperHackers @tweak Originally World Builder has hidden the System Maps tab button in Release builds, - // perhaps with the intention to only show User Maps to community users. However, World Builder did release - // as a Debug build and always had the System Maps tab, therefore this now shows it always for simplicity. - - populateMapListbox( m_usingSystemDir ); - - return FALSE; // return TRUE unless you set the focus to a control - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchOptions.cpp deleted file mode 100644 index 32b7ddd5f97..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchOptions.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScorchOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "ScorchOptions.h" -#include "CUndoable.h" -#include "wbview3d.h" -#include "Common/WellKnownKeys.h" -#include "WorldBuilderDoc.h" - -#define DEFAULT_SCORCHMARK_RADIUS 20 - -Scorches ScorchOptions::m_scorchtype = SCORCH_1; -Real ScorchOptions::m_scorchsize = DEFAULT_SCORCHMARK_RADIUS; -ScorchOptions *ScorchOptions::m_staticThis = nullptr; - -///////////////////////////////////////////////////////////////////////////// -// ScorchOptions dialog - - -ScorchOptions::ScorchOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(ScorchOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void ScorchOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScorchOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScorchOptions, CDialog) - //{{AFX_MSG_MAP(ScorchOptions) - ON_CBN_SELENDOK(IDC_SCORCHTYPE, OnChangeScorchtype) - ON_EN_CHANGE(IDC_SIZE_EDIT, OnChangeSizeEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -MapObject *ScorchOptions::getSingleSelectedScorch() -{ - MapObject *theMapObj = nullptr; -// Bool found = false; - Int selCount=0; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected()) { - if (pMapObj->isScorch()) { - theMapObj = pMapObj; - } - selCount++; - } - } - if (selCount==1 && theMapObj) { - return theMapObj; - } - - return(nullptr); -} - -void ScorchOptions::updateTheUI() -{ - m_updating = true; - MapObject *theMapObj = getSingleSelectedScorch(); - CString str; - CWnd *pEdit; - if (theMapObj) { - m_scorchtype = (Scorches) theMapObj->getProperties()->getInt(TheKey_scorchType); - m_scorchsize = theMapObj->getProperties()->getReal(TheKey_objectRadius); - } - CComboBox *scorch = (CComboBox*)GetDlgItem(IDC_SCORCHTYPE); - - scorch->SetCurSel((int)m_scorchtype); - str.Format("%f",m_scorchsize); - pEdit = GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) - pEdit->SetWindowText(str); - m_updating = false; -} - -void ScorchOptions::update() -{ - if (m_staticThis) { - m_staticThis->updateTheUI(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// ScorchOptions message handlers - -BOOL ScorchOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - m_staticThis = this; - - - m_radiusPopup.SetupPopSliderButton(this, IDC_SIZE_POPUP, this); - - CString str; - CComboBox *scorch = (CComboBox*)GetDlgItem(IDC_SCORCHTYPE); -/* Use the values in the .rc file. jba. - scorch->ResetContent(); - for (Int i = 0; i < SCORCH_COUNT; i++) - { - str.Format("Scorch %d", i); - scorch->InsertString(-1, str); - } -*/ - scorch->SetCurSel(0); - - update(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void ScorchOptions::OnChangeScorchtype() -{ - if (m_updating) - return; - CComboBox *scorch = (CComboBox*)GetDlgItem(IDC_SCORCHTYPE); - int curSel = scorch->GetCurSel(); - m_scorchtype = (Scorches) curSel; - changeScorch(); -} - -void ScorchOptions::OnChangeSizeEdit() -{ - if (m_updating) - return; - CWnd* edit = GetDlgItem(IDC_SIZE_EDIT); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - m_scorchsize = atof(cstr.GetBuffer(0)); - } - changeSize(); -} - - -void ScorchOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - *pMin = 0; - *pMax = 256; - *pInitial = m_scorchsize; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void ScorchOptions::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - m_updating = true; - switch (sliderID) { - case IDC_SIZE_POPUP: - m_scorchsize = theVal; - str.Format("%f",m_scorchsize); - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - break; - - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - m_updating = false; -} - -void ScorchOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - changeSize(); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - -void ScorchOptions::changeScorch() -{ - getAllSelectedDicts(); - - Dict newDict; - newDict.setInt(TheKey_scorchType, (Int)m_scorchtype); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - WbView3d *pView = CWorldBuilderDoc::GetActive3DView(); - pView->Invalidate(); -} - -void ScorchOptions::changeSize() -{ - getAllSelectedDicts(); - - Dict newDict; - newDict.setReal(TheKey_objectRadius, m_scorchsize); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - WbView3d *pView = CWorldBuilderDoc::GetActive3DView(); - pView->Invalidate(); -} - -void ScorchOptions::getAllSelectedDicts() -{ - m_allSelectedDicts.clear(); - - for (MapObject *pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (!pMapObj->isSelected() || !pMapObj->isScorch()) { - continue; - } - m_allSelectedDicts.push_back(pMapObj->getProperties()); - } -} - -Dict** ScorchOptions::getAllSelectedDictsData() -{ -#if defined(USING_STLPORT) || __cplusplus < 201103L - return !m_allSelectedDicts.empty() ? &m_allSelectedDicts.front() : nullptr; -#else - return m_allSelectedDicts.data(); -#endif -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchTool.cpp deleted file mode 100644 index f2868efdb7a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScorchTool.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScorchTool.cpp -// Author: Dennis Griffin, April 2002 - -#include "StdAfx.h" -#include "resource.h" - -#include "ScorchTool.h" -#include "PointerTool.h" -#include "CUndoable.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "ScorchOptions.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "Common/WellKnownKeys.h" - -// -// ScorchTool class. -// - -/// Constructor -ScorchTool::ScorchTool() : - Tool(ID_SCORCH_TOOL, IDC_SCORCH) -{ -} - -/// Destructor -ScorchTool::~ScorchTool() -{ -} - -/// Clears it's is active flag. -void ScorchTool::deactivate() -{ -} - -/// Shows the terrain materials options panel. -void ScorchTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_SCORCH_OPTIONS); - ScorchOptions::update(); - DrawObject::setDoBrushFeedback(false); -} - -// Pick a scorchmark. -MapObject *ScorchTool::pickScorch(Coord3D loc){ - // Tight check first. - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (!pObj->isScorch()) { - continue; - } - Coord3D cloc = *pObj->getLocation(); - // Check and see if we are within 1/2 cell size of the center. - Coord3D cpt = loc; - cpt.x -= cloc.x; - cpt.y -= cloc.y; - cpt.z = 0; - if (cpt.length() < 0.5f*MAP_XY_FACTOR) { - return pObj; - } - } - // Loose check - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (!pObj->isScorch()) { - continue; - } - Coord3D cloc = *pObj->getLocation(); - // Check and see if we are within 1 & 1/2 cell size of the center. - Coord3D cpt = loc; - cpt.x -= cloc.x; - cpt.y -= cloc.y; - cpt.z = 0; - if (cpt.length() < 1.5f*MAP_XY_FACTOR) { - return pObj; - } - } - return nullptr; -} - - -/// Perform the tool behavior on mouse down. -void ScorchTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - MapObject *pObj = pickScorch(docPt); - if (pObj) { - pObj->setSelected(true); - docPt = *pObj->getLocation(); - ScorchOptions::update(); - } else { - pView->snapPoint(&docPt); - MapObject *pNew = newInstance(MapObject)(docPt, "Scorch", 0, 0, nullptr, nullptr ); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, NEUTRAL_TEAM_INTERNAL_STR); - pNew->setSelected(true); - pNew->setIsScorch(); - pNew->getProperties()->setReal(TheKey_objectRadius, ScorchOptions::getScorchSize()); - pNew->getProperties()->setInt(TheKey_scorchType, ScorchOptions::getScorchType()); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pNew = nullptr; // undoable owns it now. - ScorchOptions::update(); - } - m_mouseDownPt = docPt; -} - -/// Left button move code. -void ScorchTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - MapObject *pObj = pickScorch(docPt); - if (pObj) { - docPt = *pObj->getLocation(); - } else { - pView->snapPoint(&docPt); - } - pView->Invalidate(); -} - -/** Execute the tool on mouse up - Place an object. */ -void ScorchTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp deleted file mode 100644 index d91367f6180..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsFalse.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScriptActionsFalse.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "ScriptActionsFalse.h" -#include "GameLogic/Scripts.h" -#include "EditAction.h" -#include "ScriptDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsFalse property page - -IMPLEMENT_DYNCREATE(ScriptActionsFalse, CPropertyPage) - -ScriptActionsFalse::ScriptActionsFalse() : CPropertyPage(ScriptActionsFalse::IDD), -m_falseAction(nullptr), -m_index(0) -{ - //{{AFX_DATA_INIT(ScriptActionsFalse) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -ScriptActionsFalse::~ScriptActionsFalse() -{ -} - -void ScriptActionsFalse::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScriptActionsFalse) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScriptActionsFalse, CPropertyPage) - //{{AFX_MSG_MAP(ScriptActionsFalse) - ON_BN_CLICKED(IDC_EDIT, OnEditAction) - ON_LBN_SELCHANGE(IDC_ACTION_LIST, OnSelchangeActionList) - ON_LBN_DBLCLK(IDC_ACTION_LIST, OnDblclkActionList) - ON_BN_CLICKED(IDC_NEW, OnNew) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_COPY, OnCopy) - ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown) - ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp) - ON_EN_CHANGE(IDC_EDIT_COMMENT, OnChangeEditComment) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsFalse message handlers - -BOOL ScriptActionsFalse::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - pWnd->SetWindowText(m_script->getActionComment().str()); - loadList(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void ScriptActionsFalse::loadList() -{ - m_falseAction = nullptr; - ScriptDialog::updateScriptWarning(m_script); - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - Int count = 0; - if (pList) { - pList->ResetContent(); - ScriptAction *pAction = m_script->getFalseAction(); - while (pAction) { - AsciiString astr = pAction->getUiText(); - if (astr.isEmpty()) { - astr = "Invalid Action"; - } - - pList->AddString(astr.str()); - pAction = pAction->getNext(); - count++; - } - if (count>0 && count<=m_index) { - m_index = count-1; - } - pList->SetCurSel(m_index); - OnSelchangeActionList(); - } -} - - -void ScriptActionsFalse::OnEditAction() -{ - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - if (m_falseAction == nullptr) { - return; - } - EditAction cDlg; - cDlg.setAction(m_falseAction); - if (cDlg.DoModal() == IDOK) - { - ScriptDialog::updateScriptWarning(m_script); - pList->DeleteString(m_index); - pList->InsertString(m_index, m_falseAction->getUiText().str()); - pList->SetCurSel(m_index); - } -} - -void ScriptActionsFalse::enableUI() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT); - pWnd->EnableWindow(m_falseAction!=nullptr); - - pWnd = GetDlgItem(IDC_COPY); - pWnd->EnableWindow(m_falseAction!=nullptr); - - pWnd = GetDlgItem(IDC_DELETE); - pWnd->EnableWindow(m_falseAction!=nullptr); - - pWnd = GetDlgItem(IDC_MOVE_DOWN); - pWnd->EnableWindow(m_falseAction && m_falseAction->getNext()); - - pWnd = GetDlgItem(IDC_MOVE_UP); - pWnd->EnableWindow(m_falseAction && m_index>0); - -} - -void ScriptActionsFalse::OnSelchangeActionList() -{ - m_falseAction = nullptr; - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - if (pList) { - Int count = pList->GetCurSel(); - m_index = count; - if (count<0) { - enableUI(); - return; - } - count++; - m_falseAction = m_script->getFalseAction(); - while (m_falseAction) { - count--; - if (count==0) { - enableUI(); // Enable buttons based on selection. - return; - } - m_falseAction = m_falseAction->getNext(); - } - } - enableUI(); // Enable buttons based on selection. -} - -void ScriptActionsFalse::OnDblclkActionList() -{ - OnEditAction(); -} - - - -void ScriptActionsFalse::OnNew() -{ - ScriptAction *pAct = newInstance( ScriptAction)(ScriptAction::DEBUG_MESSAGE_BOX); - EditAction aDlg; - aDlg.setAction(pAct); - if (IDOK==aDlg.DoModal()) { - if (m_falseAction) { - pAct->setNextAction(m_falseAction->getNext()); - m_falseAction->setNextAction(pAct); - } else { - pAct->setNextAction(m_script->getFalseAction()); - m_script->setFalseAction(pAct); - } - m_index++; - loadList(); - } else { - deleteInstance(pAct); - } -} - -void ScriptActionsFalse::OnDelete() -{ - if (m_falseAction) { - m_script->deleteFalseAction(m_falseAction); - loadList(); - } -} - -void ScriptActionsFalse::OnCopy() -{ - if (m_falseAction) { - ScriptAction *pCopy = m_falseAction->duplicate(); - pCopy->setNextAction(m_falseAction->getNext()); - m_falseAction->setNextAction(pCopy); - m_index++; - loadList(); - } -} - -Bool ScriptActionsFalse::doMoveDown() -{ - if (m_falseAction && m_falseAction->getNext()) { - ScriptAction *pNext = m_falseAction->getNext(); - ScriptAction *pCur = m_script->getFalseAction(); - ScriptAction *pPrev = nullptr; - while (pCur != m_falseAction) { - pPrev = pCur; - pCur = pCur->getNext(); - } - DEBUG_ASSERTCRASH(pCur, ("Didn't find action in list.")); - if (!pCur) return false; - if (pPrev) { - pPrev->setNextAction(pNext); - pCur->setNextAction(pNext->getNext()); - pNext->setNextAction(pCur); - } else { - DEBUG_ASSERTCRASH(m_falseAction == m_script->getFalseAction(), ("Logic error.")); - pCur->setNextAction(pNext->getNext()); - pNext->setNextAction(pCur); - m_script->setFalseAction(pNext); - } - return true; - } - return false; -} - -void ScriptActionsFalse::OnMoveDown() -{ - if (doMoveDown()) { - m_index++; - loadList(); - } -} - -void ScriptActionsFalse::OnMoveUp() -{ - if (m_falseAction && m_index>0) { -// ScriptAction *pNext = m_falseAction; - ScriptAction *pPrev = m_script->getFalseAction(); - while (pPrev->getNext() != m_falseAction) { - pPrev = pPrev->getNext(); - } - if (pPrev) { - m_falseAction = pPrev; - m_index--; - if (doMoveDown()) { - loadList(); - } - } - } -} - -void ScriptActionsFalse::OnChangeEditComment() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - CString comment; - pWnd->GetWindowText(comment); - m_script->setActionComment(AsciiString((LPCTSTR)comment)); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp deleted file mode 100644 index b71cdebebeb..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptActionsTrue.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScriptActionsTrue.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "ScriptActionsTrue.h" -#include "GameLogic/Scripts.h" -#include "EditAction.h" -#include "ScriptDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsTrue property page - -IMPLEMENT_DYNCREATE(ScriptActionsTrue, CPropertyPage) - -ScriptActionsTrue::ScriptActionsTrue() : CPropertyPage(ScriptActionsTrue::IDD), -m_action(nullptr), -m_index(0) -{ - //{{AFX_DATA_INIT(ScriptActionsTrue) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -ScriptActionsTrue::~ScriptActionsTrue() -{ -} - -void ScriptActionsTrue::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScriptActionsTrue) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScriptActionsTrue, CPropertyPage) - //{{AFX_MSG_MAP(ScriptActionsTrue) - ON_BN_CLICKED(IDC_EDIT, OnEditAction) - ON_LBN_SELCHANGE(IDC_ACTION_LIST, OnSelchangeActionList) - ON_LBN_DBLCLK(IDC_ACTION_LIST, OnDblclkActionList) - ON_BN_CLICKED(IDC_NEW, OnNew) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_COPY, OnCopy) - ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown) - ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp) - ON_EN_CHANGE(IDC_EDIT_COMMENT, OnChangeEditComment) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptActionsTrue message handlers - -BOOL ScriptActionsTrue::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - pWnd->SetWindowText(m_script->getActionComment().str()); - loadList(); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void ScriptActionsTrue::loadList() -{ - m_action = nullptr; - ScriptDialog::updateScriptWarning(m_script); - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - Int count = 0; - if (pList) { - pList->ResetContent(); - ScriptAction *pAction = m_script->getAction(); - while (pAction) { - AsciiString astr = pAction->getUiText(); - if (astr.isEmpty()) { - astr = "Invalid Action"; - } - - pList->AddString(astr.str()); - pAction = pAction->getNext(); - count++; - } - if (count>0 && count<=m_index) { - m_index = count-1; - } - pList->SetCurSel(m_index); - OnSelchangeActionList(); - } -} - - -void ScriptActionsTrue::OnEditAction() -{ - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - if (m_action == nullptr) { - return; - } - EditAction cDlg; - cDlg.setAction(m_action); - if (cDlg.DoModal() == IDOK) - { - ScriptDialog::updateScriptWarning(m_script); - pList->DeleteString(m_index); - pList->InsertString(m_index, m_action->getUiText().str()); - pList->SetCurSel(m_index); - } -} - -void ScriptActionsTrue::enableUI() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT); - pWnd->EnableWindow(m_action!=nullptr); - - pWnd = GetDlgItem(IDC_COPY); - pWnd->EnableWindow(m_action!=nullptr); - - pWnd = GetDlgItem(IDC_DELETE); - pWnd->EnableWindow(m_action!=nullptr); - - pWnd = GetDlgItem(IDC_MOVE_DOWN); - pWnd->EnableWindow(m_action && m_action->getNext()); - - pWnd = GetDlgItem(IDC_MOVE_UP); - pWnd->EnableWindow(m_action && m_index>0); - -} - -void ScriptActionsTrue::OnSelchangeActionList() -{ - m_action = nullptr; - CListBox *pList = (CListBox *)GetDlgItem(IDC_ACTION_LIST); - if (pList) { - Int count = pList->GetCurSel(); - m_index = count; - if (count<0) { - enableUI(); - return; - } - count++; - m_action = m_script->getAction(); - while (m_action) { - count--; - if (count==0) { - enableUI(); // Enable buttons based on selection. - return; - } - m_action = m_action->getNext(); - } - } - enableUI(); // Enable buttons based on selection. -} - -void ScriptActionsTrue::OnDblclkActionList() -{ - OnEditAction(); -} - - - -void ScriptActionsTrue::OnNew() -{ - ScriptAction *pAct = newInstance( ScriptAction)(ScriptAction::DEBUG_MESSAGE_BOX); - EditAction aDlg; - aDlg.setAction(pAct); - if (IDOK==aDlg.DoModal()) { - if (m_action) { - pAct->setNextAction(m_action->getNext()); - m_action->setNextAction(pAct); - } else { - pAct->setNextAction(m_script->getAction()); - m_script->setAction(pAct); - } - m_index++; - loadList(); - } else { - deleteInstance(pAct); - } -} - -void ScriptActionsTrue::OnDelete() -{ - if (m_action) { - m_script->deleteAction(m_action); - loadList(); - } -} - -void ScriptActionsTrue::OnCopy() -{ - if (m_action) { - ScriptAction *pCopy = m_action->duplicate(); - pCopy->setNextAction(m_action->getNext()); - m_action->setNextAction(pCopy); - m_index++; - loadList(); - } -} - -Bool ScriptActionsTrue::doMoveDown() -{ - if (m_action && m_action->getNext()) { - ScriptAction *pNext = m_action->getNext(); - ScriptAction *pCur = m_script->getAction(); - ScriptAction *pPrev = nullptr; - while (pCur != m_action) { - pPrev = pCur; - pCur = pCur->getNext(); - } - DEBUG_ASSERTCRASH(pCur, ("Didn't find action in list.")); - if (!pCur) return false; - if (pPrev) { - pPrev->setNextAction(pNext); - pCur->setNextAction(pNext->getNext()); - pNext->setNextAction(pCur); - } else { - DEBUG_ASSERTCRASH(m_action == m_script->getAction(), ("Logic error.")); - pCur->setNextAction(pNext->getNext()); - pNext->setNextAction(pCur); - m_script->setAction(pNext); - } - return true; - } - return false; -} - -void ScriptActionsTrue::OnMoveDown() -{ - if (doMoveDown()) { - m_index++; - loadList(); - } -} - -void ScriptActionsTrue::OnMoveUp() -{ - if (m_action && m_index>0) { -// ScriptAction *pNext = m_action; - ScriptAction *pPrev = m_script->getAction(); - while (pPrev->getNext() != m_action) { - pPrev = pPrev->getNext(); - } - if (pPrev) { - m_action = pPrev; - m_index--; - if (doMoveDown()) { - loadList(); - } - } - } -} - -void ScriptActionsTrue::OnChangeEditComment() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - CString comment; - pWnd->GetWindowText(comment); - m_script->setActionComment(AsciiString((LPCTSTR)comment)); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptConditions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptConditions.cpp deleted file mode 100644 index e7bb1d89337..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptConditions.cpp +++ /dev/null @@ -1,444 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScriptConditions.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "ScriptConditions.h" -#include "GameLogic/Scripts.h" -#include "EditCondition.h" -#include "ScriptDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// ScriptConditionsDlg property page - -IMPLEMENT_DYNCREATE(ScriptConditionsDlg, CPropertyPage) - -ScriptConditionsDlg::ScriptConditionsDlg() : CPropertyPage(ScriptConditionsDlg::IDD), -m_condition(nullptr), -m_orCondition(nullptr), -m_index(0) -{ - //{{AFX_DATA_INIT(ScriptConditionsDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -ScriptConditionsDlg::~ScriptConditionsDlg() -{ -} - -void ScriptConditionsDlg::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScriptConditionsDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScriptConditionsDlg, CPropertyPage) - //{{AFX_MSG_MAP(ScriptConditionsDlg) - ON_BN_CLICKED(IDC_EDIT_CONDITION, OnEditCondition) - ON_LBN_SELCHANGE(IDC_CONDITION_LIST, OnSelchangeConditionList) - ON_LBN_DBLCLK(IDC_CONDITION_LIST, OnDblclkConditionList) - ON_BN_CLICKED(IDC_OR, OnOr) - ON_BN_CLICKED(IDC_NEW, OnNew) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_COPY, OnCopy) - ON_BN_CLICKED(IDC_MOVE_DOWN, OnMoveDown) - ON_BN_CLICKED(IDC_MOVE_UP, OnMoveUp) - ON_EN_CHANGE(IDC_EDIT_COMMENT, OnChangeEditComment) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptConditionsDlg message handlers - -BOOL ScriptConditionsDlg::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - loadList(); - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - pWnd->SetWindowText(m_script->getConditionComment().str()); - CListBox *pList = (CListBox *)GetDlgItem(IDC_CONDITION_LIST); - pList->SetHorizontalExtent(10000); // band-aid fix until more precise length can be determined - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void ScriptConditionsDlg::loadList() -{ - Int count = 0; - ScriptDialog::updateScriptWarning(m_script); - CListBox *pList = (CListBox *)GetDlgItem(IDC_CONDITION_LIST); - if (pList) { - pList->ResetContent(); - OrCondition *pOr = m_script->getOrCondition(); - while (pOr) { - if (count==0) { - pList->AddString("*** IF ***"); - } else { - pList->AddString("*** OR ***"); - } - Condition *pCond = pOr->getFirstAndCondition(); - Bool first = true; - while (pCond) { - AsciiString label; - if (first) label = " "; - else label = " *AND* "; - first = false; - label.concat(pCond->getUiText()); - pList->AddString(label.str()); - pCond = pCond->getNext(); - } - count++; - pOr = pOr->getNextOrCondition(); - } - if (count>0) pList->SetCurSel(1); - OnSelchangeConditionList(); - } -} - - -void ScriptConditionsDlg::OnEditCondition() -{ - CListBox *pList = (CListBox *)GetDlgItem(IDC_CONDITION_LIST); - if (m_condition == nullptr) { - return; - } - EditCondition cDlg; - cDlg.setCondition(m_condition); - if (cDlg.DoModal() == IDOK) - { - ScriptDialog::updateScriptWarning(m_script); - pList->DeleteString(m_index); - AsciiString label; - Bool first = false; - if (m_orCondition && m_orCondition->getFirstAndCondition() == m_condition) { - first = true; - } - if (first) label = " "; - else label = " AND "; - label.concat(m_condition->getUiText()); - pList->InsertString(m_index, label.str()); - } -} - -void ScriptConditionsDlg::enableUI() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT_CONDITION); - pWnd->EnableWindow(m_condition!=nullptr); - - pWnd = GetDlgItem(IDC_COPY); - pWnd->EnableWindow(m_condition!=nullptr); - - pWnd = GetDlgItem(IDC_DELETE); - pWnd->EnableWindow(m_condition || m_orCondition); -} - -void ScriptConditionsDlg::setSel(OrCondition *pOr, Condition *pCond) -{ - m_orCondition = nullptr; - m_condition = nullptr; - CListBox *pList = (CListBox *)GetDlgItem(IDC_CONDITION_LIST); - if (pList) { - pList->SetCurSel(-1); - Int count = 0; - m_orCondition = m_script->getOrCondition(); - while (m_orCondition) { - if (m_orCondition==pOr && pCond==nullptr) { - pList->SetCurSel(count); - m_index = count; - enableUI(); - return; - } - count++; - m_condition = m_orCondition->getFirstAndCondition(); - while (m_condition) { - if (m_condition == pCond) { - pList->SetCurSel(count); - m_index = count; - enableUI(); - return; - } - count++; - m_condition = m_condition->getNext(); - } - m_orCondition = m_orCondition->getNextOrCondition(); - } - } - enableUI(); -} - -void ScriptConditionsDlg::OnSelchangeConditionList() -{ - m_orCondition = nullptr; - m_condition = nullptr; - CListBox *pList = (CListBox *)GetDlgItem(IDC_CONDITION_LIST); - if (pList) { - Int count = pList->GetCurSel(); - m_index = count; - if (count<0) return; - count+=1; - m_orCondition = m_script->getOrCondition(); - while (m_orCondition) { - count--; - if (count==0) { - enableUI(); // Enable buttons based on selection. - return; - } - m_condition = m_orCondition->getFirstAndCondition(); - while (m_condition) { - count--; - if (count==0) { - enableUI(); // Enable buttons based on selection. - return; - } - m_condition = m_condition->getNext(); - } - m_orCondition = m_orCondition->getNextOrCondition(); - } - } -} - -void ScriptConditionsDlg::OnDblclkConditionList() -{ - OnEditCondition(); -} - - -void ScriptConditionsDlg::OnOr() -{ - OrCondition *pOr = newInstance( OrCondition); - if (m_orCondition) { - pOr->setNextOrCondition(m_orCondition->getNextOrCondition()); - m_orCondition->setNextOrCondition(pOr); - } else { - pOr->setNextOrCondition(m_script->getOrCondition()); - m_script->setOrCondition(pOr); - } - loadList(); - setSel(pOr, nullptr); -} - -void ScriptConditionsDlg::OnNew() -{ - Condition *pCond = newInstance( Condition)(Condition::CONDITION_TRUE); - EditCondition cDlg; - cDlg.setCondition(pCond); - if (IDOK==cDlg.DoModal()) { - OrCondition *pSavOr = m_orCondition; - if (m_condition) { - pCond->setNextCondition(m_condition->getNext()); - m_condition->setNextCondition(pCond); - } else { - if (m_orCondition == nullptr) { - OrCondition *pOr = newInstance( OrCondition); - pOr->setNextOrCondition(m_script->getOrCondition()); - m_script->setOrCondition(pOr); - m_orCondition = pOr; - } - pCond->setNextCondition(m_orCondition->getFirstAndCondition()); - m_orCondition->setFirstAndCondition(pCond); - } - loadList(); - setSel(pSavOr, pCond); - } else { - deleteInstance(pCond); - } -} - -void ScriptConditionsDlg::OnDelete() -{ - if (m_condition && m_orCondition) { - m_orCondition->deleteCondition(m_condition); - loadList(); - } else if (m_orCondition) { - m_script->deleteOrCondition(m_orCondition); - loadList(); - } -} - -void ScriptConditionsDlg::OnCopy() -{ - if (m_condition) { - OrCondition *pSavOr = m_orCondition; - Condition *pCopy = m_condition->duplicate(); - pCopy->setNextCondition(m_condition->getNext()); - m_condition->setNextCondition(pCopy); - loadList(); - setSel(pSavOr, pCopy); - } -} - -Int ScriptConditionsDlg::doMoveDown( OrCondition **outWhichNow ) -{ - (*outWhichNow) = m_orCondition; - if (m_condition && m_orCondition) { - Condition *pNext = m_condition->getNext(); - if (pNext==nullptr) { - OrCondition *pNOr = m_orCondition->getNextOrCondition(); - if (!pNOr) { - pNOr = newInstance( OrCondition); - m_orCondition->setNextOrCondition(pNOr); - } - Condition *newNext = pNOr->getFirstAndCondition(); - pNOr->setFirstAndCondition(m_condition); - m_orCondition->removeCondition(m_condition); - m_condition->setNextCondition(newNext); - - *outWhichNow = pNOr; - return 2; // we moved 2 indices, not just one. - } - - Condition *pCur = m_orCondition->getFirstAndCondition(); - Condition *pPrev = nullptr; - while (pCur != m_condition) { - pPrev = pCur; - pCur = pCur->getNext(); - } - DEBUG_ASSERTCRASH(pCur, ("Didn't find condition in list.")); - if (!pCur) return 0; - if (pPrev) { - pPrev->setNextCondition(pNext); - pCur->setNextCondition(pNext->getNext()); - pNext->setNextCondition(pCur); - } else { - DEBUG_ASSERTCRASH(m_condition == m_orCondition->getFirstAndCondition(), ("Logic error.")); - pCur->setNextCondition(pNext->getNext()); - pNext->setNextCondition(pCur); - m_orCondition->setFirstAndCondition(pNext); - } - return 1; - } else if (m_orCondition) { - OrCondition *pNext = m_orCondition->getNextOrCondition(); - if (pNext==nullptr) return 0; - OrCondition *pCur = m_script->getOrCondition(); - OrCondition *pPrev = nullptr; - while (pCur != m_orCondition) { - pPrev = pCur; - pCur = pCur->getNextOrCondition(); - } - DEBUG_ASSERTCRASH(pCur, ("Didn't find Or in list.")); - if (!pCur) return 0; - if (pPrev) { - pPrev->setNextOrCondition(pNext); - pCur->setNextOrCondition(pNext->getNextOrCondition()); - pNext->setNextOrCondition(pCur); - } else { - DEBUG_ASSERTCRASH(m_orCondition == m_script->getOrCondition(), ("Logic error.")); - pCur->setNextOrCondition(pNext->getNextOrCondition()); - pNext->setNextOrCondition(pCur); - m_script->setOrCondition(pNext); - } - return 1; - } - return 0; -} - -Int ScriptConditionsDlg::doMoveUp( OrCondition **outWhichNow ) -{ - (*outWhichNow) = m_orCondition; - if (m_condition && m_orCondition) { - (*outWhichNow) = m_orCondition; - Condition *pPrev = m_orCondition->findPreviousCondition(m_condition); - if (pPrev == nullptr) { - OrCondition *pNOr = m_script->findPreviousOrCondition(m_orCondition); - if (!pNOr) { - pNOr = newInstance( OrCondition); - pNOr->setNextOrCondition(m_orCondition); - m_script->setOrCondition(pNOr); - } - Condition *previous = pNOr->findPreviousCondition(nullptr); - if (previous) { - m_orCondition->removeCondition(m_condition); - previous->setNextCondition(m_condition); - } else { - m_orCondition->removeCondition(m_condition); - pNOr->setFirstAndCondition(m_condition); - } - - (*outWhichNow) = pNOr; - return 2; // we moved 2 indices, not just one. - } - - pPrev->setNextCondition(m_condition->getNext()); - m_condition->setNextCondition(pPrev); - - Condition *pPrevPrev = m_orCondition->findPreviousCondition(pPrev); - if (pPrevPrev) { - pPrevPrev->setNextCondition(m_condition); - } else { - m_orCondition->setFirstAndCondition(m_condition); - } - - return 1; - } else if (m_orCondition) { - OrCondition *pOrPrev = m_script->findPreviousOrCondition(m_orCondition); - if (!pOrPrev) { - return 0; - } - - pOrPrev->setNextOrCondition(m_orCondition->getNextOrCondition()); - m_orCondition->setNextOrCondition(pOrPrev); - - OrCondition *pOrPrevPrev = m_script->findPreviousOrCondition(pOrPrev); - if (pOrPrevPrev) { - pOrPrevPrev->setNextOrCondition(m_orCondition); - } else { - m_script->setOrCondition(m_orCondition); - } - return 1; - } - return 0; -} - -void ScriptConditionsDlg::OnMoveDown() -{ - Condition *pSav = m_condition; - OrCondition *pSavOr; - if (doMoveDown(&pSavOr) == 0) { - return; - } - - loadList(); - setSel(pSavOr, pSav); -} - -void ScriptConditionsDlg::OnMoveUp() -{ - Condition *pSav = m_condition; - OrCondition *pSavOr; - if (doMoveUp(&pSavOr) == 0) { - return; - } - - loadList(); - setSel(pSavOr, pSav); -} - -void ScriptConditionsDlg::OnChangeEditComment() -{ - CWnd *pWnd = GetDlgItem(IDC_EDIT_COMMENT); - CString comment; - pWnd->GetWindowText(comment); - m_script->setConditionComment(AsciiString((LPCTSTR)comment)); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp deleted file mode 100644 index 4aaff366cb1..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp +++ /dev/null @@ -1,2164 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScriptDialog.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" -#include "ScriptDialog.h" -#include "GameLogic/ScriptEngine.h" -#include "ScriptProperties.h" -#include "ScriptConditions.h" -#include "ScriptActionsTrue.h" -#include "ScriptActionsFalse.h" -#include "CFixTeamOwnerDialog.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/PolygonTrigger.h" -#include "Common/WellKnownKeys.h" -#include "Common/DataChunk.h" -#include "Common/FileSystem.h" -#include "EditGroup.h" -#include "EditParameter.h" -#include "ExportScriptsOptions.h" -#include "Common/ThingFactory.h" -#include "WaypointOptions.h" -#include "Common/UnicodeString.h" -#include "LayersList.h" - - -static const Int K_LOCAL_TEAMS_VERSION_1 = 1; - -#define SCRIPT_DIALOG_SECTION "ScriptDialog" - -static const char* NEUTRAL_NAME_STR = "(neutral)"; -ScriptDialog *ScriptDialog::m_staticThis = nullptr; - -static AsciiString formatScriptLabel(Script *pScr) { - AsciiString fmt; - if (pScr->isSubroutine()) { - fmt.concat("[S "); - } else { - fmt.concat("[ns "); - } - if (pScr->isActive()) { - fmt.concat("A "); - } else { - fmt.concat("na "); - } - if (pScr->isOneShot()) { - fmt.concat("D] ["); - } else { - fmt.concat("nd] ["); - } - if (pScr->isEasy()) { - fmt.concat("E "); - } - if (pScr->isNormal()) { - fmt.concat("N "); - } - if (pScr->isHard()) { - fmt.concat("H]"); - } else { - fmt.concat("]"); - } - fmt.concat(pScr->getName().str()); - return fmt; -} - -static AsciiString formatScriptLabel(ScriptGroup *pScrGrp) { - AsciiString fmt; - if (pScrGrp->isSubroutine()) - { - fmt.concat("[S "); - } - else - { - fmt.concat("[ns "); - } - if (pScrGrp->isActive()) - { - fmt.concat("A]"); - } - else - { - fmt.concat("na]"); - } - fmt.concat(pScrGrp->getName().str()); - return fmt; -} - -// CSDTreeCtrl Implementation ///////////////////////////////////////////////////////////////////// - -/** This function reacts to a right button push on a - script or group to create a drop down menu */ -void CSDTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point) -{ - /// first, if there's something under the mouse, select it. - HTREEITEM item = HitTest(point); - SelectItem(item); - - CMenu menu; - VERIFY(menu.LoadMenu(IDR_SCRIPTDIALOGPOPUP)); - CMenu* pPopup = menu.GetSubMenu(0); - if (!pPopup) - { - return; - } - ClientToScreen(&point); - - /// Display a check mark to signify status of active-ness - if (item) - { - ScriptDialog *sd = (ScriptDialog*) GetParent(); - if (sd->friend_getCurScript() != nullptr) - { - Bool active = sd->friend_getCurScript()->isActive(); - pPopup->CheckMenuItem(ID_SCRIPTACTIVATE, MF_BYCOMMAND | (active ? MF_CHECKED : MF_UNCHECKED)); - } - else if (sd->friend_getCurGroup() != nullptr) - { - Bool active = sd->friend_getCurGroup()->isActive(); - pPopup->CheckMenuItem(ID_SCRIPTACTIVATE, MF_BYCOMMAND | (active ? MF_CHECKED : MF_UNCHECKED)); - } - - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x, point.y, GetParent()); - } -} - -BEGIN_MESSAGE_MAP(CSDTreeCtrl, CTreeCtrl) - ON_WM_RBUTTONDOWN() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptDialog dialog - - -ScriptDialog::ScriptDialog(CWnd* pParent /*=nullptr*/) - : CDialog(ScriptDialog::IDD, pParent) -{ - m_draggingTreeView = false; - m_autoUpdateWarnings = true; - //{{AFX_DATA_INIT(ScriptDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -ScriptDialog::~ScriptDialog() -{ - EditParameter::setCurSidesList(nullptr); - m_staticThis=nullptr; -} - - -void ScriptDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScriptDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScriptDialog, CDialog) - //{{AFX_MSG_MAP(ScriptDialog) - ON_NOTIFY(TVN_SELCHANGED, IDC_SCRIPT_TREE, OnSelchangedScriptTree) - ON_BN_CLICKED(IDC_NEW_FOLDER, OnNewFolder) - ON_BN_CLICKED(IDC_NEW_SCRIPT, OnNewScript) - ON_BN_CLICKED(IDC_EDIT_SCRIPT, OnEditScript) - ON_BN_CLICKED(IDC_COPY_SCRIPT, OnCopyScript) - ON_BN_CLICKED(IDC_DELETE, OnDelete) - ON_BN_CLICKED(IDC_VERIFY, OnVerify) - ON_BN_CLICKED(IDC_PATCH_GC, OnPatchGC) - ON_BN_CLICKED(IDC_AUTO_VERIFY, OnAutoVerify) - ON_BN_CLICKED(IDC_SAVE, OnSave) - ON_BN_CLICKED(IDC_LOAD, OnLoad) - ON_NOTIFY(NM_DBLCLK, IDC_SCRIPT_TREE, OnDblclkScriptTree) - ON_NOTIFY(TVN_BEGINDRAG, IDC_SCRIPT_TREE, OnBegindragScriptTree) - ON_COMMAND(ID_SCRIPTACTIVATE, OnScriptActivate) - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONUP() - ON_WM_MOVE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptDialog message handlers - -void ScriptDialog::OnSelchangedScriptTree(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - if (pNMTreeView->itemNew.hItem==nullptr) { - m_curSelection.IntToList(0); - m_curSelection.m_objType = ListType::PLAYER_TYPE; - } else { - m_curSelection.IntToList(pNMTreeView->itemNew.lParam); - DEBUG_ASSERTCRASH(m_curSelection.m_playerIndex m_draggingTreeView) { - pTree->SelectDropTarget(pNMTreeView->itemNew.hItem); - } - Script *pScript = getCurScript(); - ScriptGroup *pGroup = getCurGroup(); - - CWnd *pWnd = GetDlgItem(IDC_EDIT_SCRIPT); - pWnd->EnableWindow(pScript!=nullptr || pGroup!=nullptr); - - pWnd = GetDlgItem(IDC_COPY_SCRIPT); - pWnd->EnableWindow(pScript!=nullptr); - - pWnd = GetDlgItem(IDC_DELETE); - pWnd->EnableWindow(m_curSelection.m_objType != ListType::PLAYER_TYPE); - - AsciiString scriptComment; - AsciiString scriptText; - if (pScript) { - scriptComment = pScript->getComment(); - scriptText = pScript->getUiText(); - } - - pWnd = GetDlgItem(IDC_SCRIPT_COMMENT); - pWnd->SetWindowText(scriptComment.str()); - - pWnd = GetDlgItem(IDC_SCRIPT_DESCRIPTION); - pWnd->SetWindowText(scriptText.str()); - - *pResult = 0; -} - -/* The purpose of these two functions is to allow -the inner class CSDTreeCtrl the ability to check -what Script and ScriptGroup belong to the cursor location */ -Script *ScriptDialog::friend_getCurScript() -{ - return getCurScript(); -} - -ScriptGroup *ScriptDialog::friend_getCurGroup() -{ - return getCurGroup(); -} - -Script *ScriptDialog::getCurScript() -{ - if (m_curSelection.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE || m_curSelection.m_objType == ListType::SCRIPT_IN_GROUP_TYPE) { - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - if (pSL) { - Script *pScr=nullptr; - if (m_curSelection.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE) { - pScr = pSL->getScript(); - } else { - Int groupNdx; - ScriptGroup *pGroup = pSL->getScriptGroup(); - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - if (groupNdx == m_curSelection.m_groupIndex) { - pScr = pGroup->getScript(); - break; - } - } - } - Int scriptNdx; - for (scriptNdx = 0; pScr; scriptNdx++,pScr=pScr->getNext()) { - if (scriptNdx == m_curSelection.m_scriptIndex) { - return pScr; - } - } - } - } - return nullptr; -} - -ScriptGroup *ScriptDialog::getCurGroup() -{ - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - if (m_curSelection.m_objType == ListType::PLAYER_TYPE) { - return nullptr; - } - if (m_curSelection.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE) { - return nullptr; - } - if (pSL) { - Int groupNdx; - ScriptGroup *pGroup = pSL->getScriptGroup(); - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - if (groupNdx == m_curSelection.m_groupIndex) { - return pGroup; - } - } - } - return nullptr; -} - -/** Updates the warning flags in a script, & script conditions & actions. */ -void ScriptDialog::updateScriptWarning(Script *pScript) -{ - pScript->setWarnings(false); - OrCondition *pOr; - for (pOr= pScript->getOrCondition(); pOr; pOr = pOr->getNextOrCondition()) { - Condition *pCondition; - for (pCondition = pOr->getFirstAndCondition(); pCondition; pCondition = pCondition->getNext()) { - pCondition->setWarnings(false); - Int i; - for (i=0; igetNumParameters(); i++) { - AsciiString warning; - warning = EditParameter::getWarningText(pCondition->getParameter(i), FALSE); - if (!warning.isEmpty()) { - pScript->setWarnings(true); - pCondition->setWarnings(true); - } - } - } - } - ScriptAction *pAction; - for (pAction = pScript->getAction(); pAction; pAction = pAction->getNext()) { - pAction->setWarnings(false); - Int i; - for (i=0; igetNumParameters(); i++) { - AsciiString warning; - warning = EditParameter::getWarningText(pAction->getParameter(i), TRUE); - if (!warning.isEmpty()) { - pScript->setWarnings(true); - pAction->setWarnings(true); - } - } - } -} - -void ScriptDialog::OnPatchGC() -{ - checkParametersForGC(); - updateIcons(TVI_ROOT); -/* //Put up a dialog asking for search/replace parameters instead of hard-coded GC_ prefix. - ReplaceParameter editDlg(); - if (IDOK==editDlg.DoModal()) - { - - }*/ -} - -/**Force a pass over all the scripts to make sure no warnings. I moved this -to user control because this function is VERY slow. 7-15-03 -MW*/ -void ScriptDialog::OnVerify() -{ - updateWarnings(true); //force an update of warnings - updateIcons(TVI_ROOT); -} - -void ScriptDialog::OnAutoVerify() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_AUTO_VERIFY); - m_autoUpdateWarnings=(pButton->GetCheck()==1); - ::AfxGetApp()->WriteProfileInt(SCRIPT_DIALOG_SECTION, "AutoVerifyScripts", m_autoUpdateWarnings?1:0); - //if user wants to check warnings manually, enable the verify button - CWnd *pWnd = GetDlgItem(IDC_VERIFY); - pWnd->EnableWindow(!m_autoUpdateWarnings); -} - -/** Updates the warning flags in the scripts, script groups & script conditions & actions. */ -void ScriptDialog::updateWarnings(Bool forceUpdate) -{ - if (m_staticThis && m_staticThis->m_autoUpdateWarnings == false && forceUpdate == false) - return; //user has disabled warnings to speed up the script editor - - SidesList *sidesListP = TheSidesList; - Int i; - if (m_staticThis) sidesListP = &m_staticThis->m_sides; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - updateScriptWarning(pScr); - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - pGroup->setWarnings(false); - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - updateScriptWarning(pScr); - if (pScr->hasWarnings()) { - pGroup->setWarnings(true); - } - } - } - } -} - -extern AsciiString ConvertToNonGCName(AsciiString name, Bool checkTemplate=true); - -void ScriptDialog::patchScriptParametersForGC(Script *pScript) -{ - AsciiString swapString; - pScript->setWarnings(false); - OrCondition *pOr; - for (pOr= pScript->getOrCondition(); pOr; pOr = pOr->getNextOrCondition()) { - Condition *pCondition; - for (pCondition = pOr->getFirstAndCondition(); pCondition; pCondition = pCondition->getNext()) { - pCondition->setWarnings(false); - Int i; - for (i=0; igetNumParameters(); i++) { - AsciiString warning; - Parameter *pParm = pCondition->getParameter(i); - warning = EditParameter::getWarningText(pParm, FALSE); - if (!warning.isEmpty()) { - if (pParm->getParameterType() == Parameter::OBJECT_TYPE) - { //see if removing the GC prefix fixes this warning: - AsciiString uiString = pParm->getString(); - if (uiString.isEmpty()) - uiString = "???"; - if (uiString.startsWith("GC_")) - { swapString = ConvertToNonGCName(uiString, false); - pParm->friend_setString(swapString); - warning = EditParameter::getWarningText(pParm, FALSE); - if (!warning.isEmpty()) - { //Removing GC prefix didn't help, so restore original - pParm->friend_setString(uiString); - } - else - continue; //warning was fixed so leave swapped parameter. - } - } - pScript->setWarnings(true); - pCondition->setWarnings(true); - } - } - } - } - ScriptAction *pAction; - for (pAction = pScript->getAction(); pAction; pAction = pAction->getNext()) { - pAction->setWarnings(false); - Int i; - for (i=0; igetNumParameters(); i++) { - AsciiString warning; - Parameter *pParm=pAction->getParameter(i); - warning = EditParameter::getWarningText(pParm, TRUE); - if (!warning.isEmpty()) { - if (pParm->getParameterType() == Parameter::OBJECT_TYPE) - { //see if removing the GC prefix fixes this warning: - AsciiString uiString = pParm->getString(); - if (uiString.isEmpty()) - uiString = "???"; - if (uiString.startsWith("GC_")) - { swapString = ConvertToNonGCName(uiString,false); - pParm->friend_setString(swapString); - warning = EditParameter::getWarningText(pParm, FALSE); - if (!warning.isEmpty()) - { //Removing GC prefix didn't help, so restore original - pParm->friend_setString(uiString); - } - else - continue; //warning was fixed so leave swapped parameter. - } - } - pScript->setWarnings(true); - pAction->setWarnings(true); - } - } - } -} - -/*Checks all script parameters for obsolete values (example: mission disk using GC_ templates)*/ -void ScriptDialog::checkParametersForGC() -{ - SidesList *sidesListP = TheSidesList; - Int i; - if (m_staticThis) sidesListP = &m_staticThis->m_sides; - for (i=0; igetNumSides(); i++) { - ScriptList *pSL = sidesListP->getSideInfo(i)->getScriptList(); - Script *pScr; - for (pScr = pSL->getScript(); pScr; pScr=pScr->getNext()) { - updateScriptWarning(pScr); - if (pScr->hasWarnings()) - { //check if this is using invalid GC parameters - patchScriptParametersForGC(pScr); - } - } - ScriptGroup *pGroup; - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - pGroup->setWarnings(false); - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - updateScriptWarning(pScr); - if (pScr->hasWarnings()) { - //check if this is using invalid GC parameters. - patchScriptParametersForGC(pScr); - if (pScr->hasWarnings()) //patching may have removed warning - pGroup->setWarnings(true); - } - } - } - } -} - -BOOL ScriptDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_autoUpdateWarnings=::AfxGetApp()->GetProfileInt(SCRIPT_DIALOG_SECTION, "AutoVerifyScripts", 1); - - CButton *pButton = (CButton*)GetDlgItem(IDC_AUTO_VERIFY); - pButton->SetCheck(m_autoUpdateWarnings ? 1:0); - - //if user wants to check warnings manually, enable the verify button - CWnd *pWnd = GetDlgItem(IDC_VERIFY); - pWnd->EnableWindow(!m_autoUpdateWarnings); - - m_staticThis = this; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - - // replace current Tree Dialog with CSDTreeCtrl - - CRect rect; - mTree = new CSDTreeCtrl; - pTree->GetWindowRect(&rect); - ScreenToClient(&rect); - - DWORD style = pTree->GetStyle(); - mTree->Create(style, rect, this, IDC_SCRIPT_TREE); - pTree->DestroyWindow(); - - pTree = (CTreeCtrl*) GetDlgItem(IDC_SCRIPT_TREE); - // pTree should == mTree now. - - Bool didSelect = false; - ScriptList::updateDefaults(); - m_sides = *TheSidesList; - EditParameter::setCurSidesList(&m_sides); - Int i; - updateWarnings(true); - if (pTree) { - m_imageList.Create(IDB_FOLDERSCRIPT, 16, 2, ILC_COLOR4); - pTree->SetImageList(&m_imageList, TVSIL_STATE); - for (i=0; iSelectItem(hItem); - didSelect = true; - } - } - pTree->SetFocus(); - } - - CRect top; - GetWindowRect(&top); - top.top = ::AfxGetApp()->GetProfileInt(SCRIPT_DIALOG_SECTION, "Top", top.top); - top.left =::AfxGetApp()->GetProfileInt(SCRIPT_DIALOG_SECTION, "Left", top.left); - SetWindowPos(nullptr, top.left, top.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE); - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -HTREEITEM ScriptDialog::addPlayer(Int playerIndx) -{ - - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - TVINSERTSTRUCT ins; - Dict *d = m_sides.getSideInfo(playerIndx)->getDict(); - AsciiString name = d->getAsciiString(TheKey_playerName); - UnicodeString uni = d->getUnicodeString(TheKey_playerDisplayName); - AsciiString fmt; - if (name.isEmpty()) - fmt.format("%s", NEUTRAL_NAME_STR); - else - fmt.format("%s",name.str()); - ::memset(&ins, 0, sizeof(ins)); - ListType lt; - lt.m_objType=ListType::PLAYER_TYPE; - lt.m_playerIndex = playerIndx; - ins.hParent = TVI_ROOT; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - ins.item.state = INDEXTOSTATEIMAGEMASK(1); - ins.item.stateMask = TVIS_STATEIMAGEMASK ; - ins.item.lParam = lt.ListToInt(); - ins.item.pszText = (char *)fmt.str(); - ins.item.cchTextMax = 0; - HTREEITEM hItem = pTree->InsertItem(&ins); - ScriptList *pSL = m_sides.getSideInfo(playerIndx)->getScriptList(); - if (pSL) { - addScriptList(hItem, playerIndx, pSL); - } - updateIcons(TVI_ROOT); - return hItem; -} - -void ScriptDialog::setIconGroup(HTREEITEM item) -{ - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - - if (getCurGroup()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - - if (!getCurGroup()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(5), TVIS_STATEIMAGEMASK); - - if (getCurGroup()->hasWarnings()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK); -} - -void ScriptDialog::setIconScript(HTREEITEM item) -{ - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - - if (getCurScript()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK); - - if (!getCurScript()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(6), TVIS_STATEIMAGEMASK); - - if (getCurScript()->hasWarnings()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(4), TVIS_STATEIMAGEMASK); -} - -Bool ScriptDialog::updateIcons(HTREEITEM hItem) -{ - const ListType saveList = m_curSelection; - Bool warnings = false; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM child = pTree->GetChildItem(hItem); - - while (child != nullptr) { - ListType lt; - lt.IntToList(pTree->GetItemData(child)); - - /// player type - if (lt.m_objType == ListType::PLAYER_TYPE) - { - if (updateIcons(child)) { - pTree->SetItemState(child, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK); - } else { - pTree->SetItemState(child, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - } - } - - /// script group - else if (lt.m_objType == ListType::GROUP_TYPE) - { - m_curSelection = lt; - if (updateIcons(child)) { - pTree->SetItemState(child, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK); - warnings = true; - } else { - setIconGroup(child); - } - } - - /// script - else - { - m_curSelection = lt; - Script *pScr = getCurScript(); - DEBUG_ASSERTCRASH(pScr, ("Unexpected.")); - if (pScr) { - if (pScr->hasWarnings()) { - pTree->SetItemState(child, INDEXTOSTATEIMAGEMASK(4), TVIS_STATEIMAGEMASK); - warnings = true; - } else { - setIconScript(child); - } - } - } - - child = pTree->GetNextSiblingItem(child); - } - m_curSelection = saveList; - return warnings; -} - -void ScriptDialog::addScriptList(HTREEITEM hPlayer, Int playerIndex, ScriptList *pSL) -{ - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - TVINSERTSTRUCT ins; - Int groupNdx; - ScriptGroup *pGroup = pSL->getScriptGroup(); - Bool warnings = false; - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - AsciiString fmt; - if (pGroup->getName().isEmpty()) - continue; - else - fmt = formatScriptLabel(pGroup); - ::memset(&ins, 0, sizeof(ins)); - ListType lt; - lt.m_objType=ListType::GROUP_TYPE; - lt.m_playerIndex = playerIndex; - lt.m_groupIndex = groupNdx; - ins.hParent = hPlayer; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - ins.item.lParam = lt.ListToInt(); - ins.item.pszText = (char *)fmt.str(); - ins.item.cchTextMax = 0; - ins.item.state = INDEXTOSTATEIMAGEMASK(1); - if (pGroup->hasWarnings()) { - ins.item.state = INDEXTOSTATEIMAGEMASK(3); - warnings = true; - } - ins.item.stateMask = TVIS_STATEIMAGEMASK ; - HTREEITEM hItem = pTree->InsertItem(&ins); - Script *pScr = pGroup->getScript(); - if (pScr) { - Int scriptNdx; - for (scriptNdx = 0; pScr; scriptNdx++,pScr=pScr->getNext()) { - AsciiString fmt; - if (pScr->getName().isEmpty()) - continue; - fmt = formatScriptLabel(pScr); - ::memset(&ins, 0, sizeof(ins)); - ListType lt; - lt.m_objType=ListType::SCRIPT_IN_GROUP_TYPE; - lt.m_playerIndex = playerIndex; - lt.m_groupIndex = groupNdx; - lt.m_scriptIndex = scriptNdx; - ins.hParent = hItem; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - ins.item.state = INDEXTOSTATEIMAGEMASK(2); - if (pScr->hasWarnings()) { - ins.item.state = INDEXTOSTATEIMAGEMASK(4); - warnings = true; - } - ins.item.stateMask = TVIS_STATEIMAGEMASK ; - ins.item.lParam = lt.ListToInt(); - ins.item.pszText = (char *)fmt.str(); - ins.item.cchTextMax = 0; - /*HTREEITEM hItem =*/ pTree->InsertItem(&ins); - } - } - } - Script *pScr = pSL->getScript(); - if (pScr) { - Int scriptNdx; - for (scriptNdx = 0; pScr; scriptNdx++,pScr=pScr->getNext()) { - AsciiString fmt; - if (pScr->getName().isEmpty()) - continue; - fmt = formatScriptLabel(pScr); - ::memset(&ins, 0, sizeof(ins)); - ListType lt; - lt.m_objType=ListType::SCRIPT_IN_PLAYER_TYPE; - lt.m_playerIndex = playerIndex; - lt.m_groupIndex = 0; - lt.m_scriptIndex = scriptNdx; - ins.hParent = hPlayer; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - ins.item.state = INDEXTOSTATEIMAGEMASK(2); - if (pScr->hasWarnings()) { - ins.item.state = INDEXTOSTATEIMAGEMASK(4); - warnings = true; - } - ins.item.stateMask = TVIS_STATEIMAGEMASK ; - ins.item.lParam = lt.ListToInt(); - ins.item.pszText = (char *)fmt.str(); - ins.item.cchTextMax = 0; - /*HTREEITEM hItem =*/ pTree->InsertItem(&ins); - } - } - if (warnings) { - pTree->SetItemState(hPlayer, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK); - } else { - pTree->SetItemState(hPlayer, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - } -} - -void ScriptDialog::reloadPlayer(Int playerIndex, ScriptList *pSL) -{ -// Dict *d = m_sides.getSideInfo(playerIndex)->getDict(); - updateWarnings(); - - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM player = pTree->GetChildItem(TVI_ROOT); - while (player != nullptr) { - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = player; - pTree->GetItem(&item); - ListType lt; - lt.IntToList(item.lParam); - if (lt.m_playerIndex==playerIndex) { - break; - } - player = pTree->GetNextSiblingItem(player); - } - DEBUG_ASSERTCRASH(player, ("Couldn't find player.")); - if (!player) return; - HTREEITEM child; - ListType currentSel = m_curSelection; - - if (currentSel.m_objType == ListType::SCRIPT_IN_GROUP_TYPE) { - if (currentSel.m_scriptIndex > 0) { - --currentSel.m_scriptIndex; - } - } - - do { - child = pTree->GetChildItem(player); - if (child) pTree->DeleteItem(child); - } while (child); - m_curSelection = currentSel; - addScriptList(player, playerIndex, pSL); -} - -void ScriptDialog::updateSelection(ListType sel) -{ - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM item = findItem(sel, TRUE); - if (item) { - pTree->SelectItem(item); - } -} - -HTREEITEM ScriptDialog::findItem(ListType sel, Bool failSafe) -{ - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM player = pTree->GetChildItem(TVI_ROOT); - TVITEM item; - while (player != nullptr) { - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = player; - pTree->GetItem(&item); - ListType lt; - lt.IntToList(item.lParam); - if (lt.m_playerIndex==sel.m_playerIndex) { - break; - } - player = pTree->GetNextSiblingItem(player); - } - DEBUG_ASSERTCRASH(player, ("Couldn't find player.")); - if (!player) return nullptr; - if (sel.m_objType == ListType::PLAYER_TYPE) { - return player; - } - - HTREEITEM group; - if (sel.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE) { - group = player; // top level scripts are grouped under player. - } else { - group = pTree->GetChildItem(player); - while (group != nullptr) { - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = group; - pTree->GetItem(&item); - ListType lt; - lt.IntToList(item.lParam); - if (lt.m_groupIndex==sel.m_groupIndex) { - break; - } - DEBUG_ASSERTCRASH(lt.m_objType == ListType::GROUP_TYPE, ("Not group")); - group = pTree->GetNextSiblingItem(group); - } - } - DEBUG_ASSERTCRASH(group, ("Couldn't find group.")); - if (!group) return nullptr; - if (sel.m_objType == ListType::GROUP_TYPE) { - return group; - } - - HTREEITEM script; - for (script = pTree->GetChildItem(group); script != nullptr; script = pTree->GetNextSiblingItem(script)) { - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = script; - pTree->GetItem(&item); - ListType lt; - lt.IntToList(item.lParam); - if (sel.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE && lt.m_objType == ListType::GROUP_TYPE) { - continue; - } - DEBUG_ASSERTCRASH(lt.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE || lt.m_objType == ListType::SCRIPT_IN_GROUP_TYPE, ("Not script")); - if (lt.m_scriptIndex==sel.m_scriptIndex) { - break; - } - } - - if (script || !failSafe) { - DEBUG_ASSERTCRASH(script, ("Couldn't find script.")); - return script; - } - - // at least select the group if possible. - return group; -} - -void ScriptDialog::OnNewFolder() -{ - Int ndx; - if (m_curSelection.m_objType == ListType::PLAYER_TYPE) { - ndx = 0; - } else { - ndx = m_curSelection.m_groupIndex+1; - } - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - if (pSL) { - ListType savSel = m_curSelection; - ScriptGroup *pNewGroup = newInstance( ScriptGroup); - EditGroup editDlg(pNewGroup); - if (IDOK==editDlg.DoModal()) { - pSL->addGroup(pNewGroup, ndx); - reloadPlayer(savSel.m_playerIndex, pSL); - savSel.m_groupIndex = ndx; - savSel.m_objType = ListType::GROUP_TYPE; - updateSelection(savSel); - } else { - deleteInstance(pNewGroup); - } - } - updateIcons(TVI_ROOT); -} - -void ScriptDialog::OnNewScript() -{ - Script *pNewScript = newInstance( Script); - - Int id = ScriptList::getNextID(); - AsciiString name; - name.format("Script %d", id); - pNewScript->setName(name); - - Condition *pFalse1 = newInstance( Condition)(Condition::CONDITION_TRUE); - OrCondition *pOr = newInstance( OrCondition); - pOr->setFirstAndCondition(pFalse1); - pNewScript->setOrCondition(pOr); - - ScriptAction *action = newInstance( ScriptAction)(ScriptAction::NO_OP); - pNewScript->setAction(action); - - CPropertySheet editDialog; - editDialog.Construct(name.str()); - ScriptProperties sp; - sp.setScript(pNewScript); - ScriptConditionsDlg sc; - sc.setScript(pNewScript); - ScriptActionsTrue st; - st.setScript(pNewScript); - ScriptActionsFalse sf; - sf.setScript(pNewScript); - editDialog.AddPage(&sp); - editDialog.AddPage(&sc); - editDialog.AddPage(&st); - editDialog.AddPage(&sf); - - if (IDOK == editDialog.DoModal()) { - insertScript(pNewScript); - } else { - deleteInstance(pNewScript); - } - updateIcons(TVI_ROOT); -} - -void ScriptDialog::insertScript(Script *pNewScript) -{ - Int ndx; - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - if (pSL) { - ListType savSel = m_curSelection; - Bool inGroup = savSel.m_objType == ListType::GROUP_TYPE || - savSel.m_objType == ListType::SCRIPT_IN_GROUP_TYPE; - if (inGroup) { - if (savSel.m_objType == ListType::GROUP_TYPE ) { - ndx = 0; - } else { - ndx = savSel.m_scriptIndex+1; - } - Int groupNdx; - ScriptGroup *pGroup = pSL->getScriptGroup(); - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - if (groupNdx == savSel.m_groupIndex) { - pGroup->addScript(pNewScript, ndx); - savSel.m_objType = ListType::SCRIPT_IN_GROUP_TYPE; - savSel.m_scriptIndex = ndx; - break; - } - } - } else { - if (m_curSelection.m_objType == ListType::PLAYER_TYPE ) { - ndx = 0; - } else { - ndx = m_curSelection.m_scriptIndex+1; - } - pSL->addScript(pNewScript, ndx); - savSel.m_objType = ListType::SCRIPT_IN_PLAYER_TYPE; - savSel.m_scriptIndex = ndx; - } - - reloadPlayer(savSel.m_playerIndex, pSL); - updateSelection(savSel); - } - updateIcons(TVI_ROOT); -} - -void ScriptDialog::OnEditScript() -{ - Script *pScript = getCurScript(); - ScriptGroup *pGroup = getCurGroup(); - DEBUG_ASSERTCRASH(pScript || pGroup, ("Null script.")); - if (pScript == nullptr) { - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM item = findItem(m_curSelection); - if (pGroup) { - EditGroup editDlg(pGroup); - if (IDOK==editDlg.DoModal()) { - if (item) { - pTree->SetItemText(item, pGroup->getName().str()); - pTree->SelectItem(nullptr); - updateWarnings(); - pTree->SelectItem(item); - } - } - } - updateIcons(TVI_ROOT); - pTree->SetItemText(item, formatScriptLabel(pGroup).str()); - return; - } - - Script *pDup = pScript->duplicate(); - - CPropertySheet editDialog; - editDialog.Construct(pScript->getName().str()); - ScriptProperties sp; - sp.setScript(pDup); - ScriptConditionsDlg sc; - sc.setScript(pDup); - ScriptActionsTrue st; - st.setScript(pDup); - ScriptActionsFalse sf; - sf.setScript(pDup); - editDialog.AddPage(&sp); - editDialog.AddPage(&sc); - editDialog.AddPage(&st); - editDialog.AddPage(&sf); - - if (IDOK == editDialog.DoModal()) { - pScript->updateFrom(pDup); - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM item = findItem(m_curSelection); - if (item) { - pTree->SetItemText(item, formatScriptLabel(pScript).str()); - pTree->SelectItem(nullptr); - updateWarnings(); - pTree->SelectItem(item); // Updates the comment field & text field. - } - } - updateIcons(TVI_ROOT); - deleteInstance(pDup); -} - -void ScriptDialog::OnCopyScript() -{ - Script *pScript = getCurScript(); - DEBUG_ASSERTCRASH(pScript, ("Null script.")); - if (pScript == nullptr) return; - Script *pDup = pScript->duplicate(); - AsciiString newName = pDup->getName(); - newName.concat(" C"); - pDup->setName(newName); - insertScript(pDup); - updateIcons(TVI_ROOT); -} - -void ScriptDialog::OnDelete() -{ - Script *pScript = getCurScript(); - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - if (pSL) { - Bool inGroup = m_curSelection.m_objType != ListType::SCRIPT_IN_PLAYER_TYPE; - if (inGroup) { - Int groupNdx; - ScriptGroup *pGroup = pSL->getScriptGroup(); - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - if (groupNdx == m_curSelection.m_groupIndex) { - if (m_curSelection.m_objType == ListType::GROUP_TYPE) { - pSL->deleteGroup(pGroup); - m_curSelection.m_objType = ListType::PLAYER_TYPE; - } else { - pGroup->deleteScript(pScript); - if (pGroup->getScript()==nullptr) { - m_curSelection.m_objType = ListType::GROUP_TYPE; - } - } - break; - } - } - } else { - pSL->deleteScript(pScript); - if (pSL->getScript()==nullptr) { - m_curSelection.m_objType = ListType::PLAYER_TYPE; - } - } - reloadPlayer(m_curSelection.m_playerIndex, pSL); - updateSelection(m_curSelection); - } - updateIcons(TVI_ROOT); -} - -class LocalMFCFileOutputStream : public OutputStream -{ -protected: - CFile *m_file; -public: - LocalMFCFileOutputStream(CFile *pFile):m_file(pFile) {}; - virtual Int write(const void *pData, Int numBytes) override { - Int numBytesWritten = 0; - try { - m_file->Write(pData, numBytes); - numBytesWritten = numBytes; - } catch(...) { - DEBUG_CRASH(("threw exception in LocalMFCFileOutputStream")); - } - return(numBytesWritten); - }; -}; - -void ScriptDialog::markWaypoint(MapObject *pObj) -{ - Bool exists; - if (!pObj) return; - if (pObj->isWaypoint() && !pObj->getProperties()->getBool(TheKey_exportWithScript, &exists)) { - pObj->getProperties()->setBool(TheKey_exportWithScript, true); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - Int curID = pObj->getWaypointID(); - Int i; - for (i = 0; igetNumWaypointLinks(); i++) { -// Bool gotLocation=false; - Int waypointID1, waypointID2; - pDoc->getWaypointLink(i, &waypointID1, &waypointID2); - if (curID == waypointID1) { - markWaypoint(pDoc->getWaypointByID(waypointID2)); - } - if (curID == waypointID2) { - markWaypoint(pDoc->getWaypointByID(waypointID1)); - } - } - } -} - -/** Looks for referenced waypoints & teams. */ -void ScriptDialog::scanParmForWaypointsAndTeams(Parameter *pParm, Bool doUnits, Bool doWaypoints, Bool doTriggers) -{ - if (pParm->getParameterType() == Parameter::WAYPOINT && doWaypoints) { - AsciiString waypointName = pParm->getString(); - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (pObj->isWaypoint() && pObj->getWaypointName()==waypointName) { - markWaypoint(pObj); - } - } - } - if (pParm->getParameterType() == Parameter::WAYPOINT_PATH && doWaypoints) { - AsciiString waypointPathLabel = pParm->getString(); - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (pObj->isWaypoint() ) { - Bool exists; - if (waypointPathLabel == pObj->getProperties()->getAsciiString(TheKey_waypointPathLabel1, &exists)) { - markWaypoint(pObj); - } - if (waypointPathLabel == pObj->getProperties()->getAsciiString(TheKey_waypointPathLabel2, &exists)) { - markWaypoint(pObj); - } - if (waypointPathLabel == pObj->getProperties()->getAsciiString(TheKey_waypointPathLabel3, &exists)) { - markWaypoint(pObj); - } - } - } - } - if (pParm->getParameterType() == Parameter::TEAM) { - AsciiString teamName = pParm->getString(); - TeamsInfo * pInfo = m_sides.findTeamInfo(teamName); - if (pInfo) { - pInfo->getDict()->setBool(TheKey_exportWithScript, true); - } - if (doUnits) { - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - Bool exists; - AsciiString objsTeamName = pObj->getProperties()->getAsciiString(TheKey_originalOwner, &exists); - if (objsTeamName==teamName) { - pObj->getProperties()->setBool(TheKey_exportWithScript, true); - } - } - } - } - if (pParm->getParameterType() == Parameter::UNIT) { - AsciiString unitName = pParm->getString(); - if (doUnits) { - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - Bool exists; - AsciiString objsTeamName = pObj->getProperties()->getAsciiString(TheKey_originalOwner, &exists); - AsciiString objsUnitName = pObj->getProperties()->getAsciiString(TheKey_objectName, &exists); - if (objsUnitName==unitName) { - pObj->getProperties()->setBool(TheKey_exportWithScript, true); - TeamsInfo * pInfo = m_sides.findTeamInfo(objsTeamName); - if (pInfo) { - pInfo->getDict()->setBool(TheKey_exportWithScript, true); - } - } - } - } - } - if (pParm->getParameterType() == Parameter::TRIGGER_AREA && doTriggers) { - PolygonTrigger *pTrig; - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (pTrig->getTriggerName() == pParm->getString()) { - pTrig->setDoExportWithScripts(true); - } - } - } -} - -/** Looks for referenced waypoints & teams. */ -void ScriptDialog::scanForWaypointsAndTeams(Script *pScript, Bool doUnits, Bool doWaypoints, Bool doTriggers) -{ - pScript->setWarnings(false); - OrCondition *pOr; - for (pOr= pScript->getOrCondition(); pOr; pOr = pOr->getNextOrCondition()) { - Condition *pCondition; - for (pCondition = pOr->getFirstAndCondition(); pCondition; pCondition = pCondition->getNext()) { - Int i; - for (i=0; igetNumParameters(); i++) { - scanParmForWaypointsAndTeams(pCondition->getParameter(i), doUnits, doWaypoints, doTriggers); - } - } - } - ScriptAction *pAction; - for (pAction = pScript->getAction(); pAction; pAction = pAction->getNext()) { - pAction->setWarnings(false); - Int i; - for (i=0; igetNumParameters(); i++) { - scanParmForWaypointsAndTeams(pAction->getParameter(i), doUnits, doWaypoints, doTriggers); - } - } -} - -#define K_PLAYERS_NAMES_FOR_SCRIPTS_VERSION_1 1 -#define K_PLAYERS_NAMES_FOR_SCRIPTS_VERSION_2 2 - -/** Write out selected scripts, and possibly waypoints, trigger areas & teams. */ -void ScriptDialog::OnSave() -{ - Bool doWaypoints = true; - Bool doTriggerAreas = true; - Bool doUnits = true; - Bool doAllScripts = true; - Bool doSides = true; - Int i; - - ExportScriptsOptions optionsDlg; - if (IDCANCEL == optionsDlg.DoModal()) { - return; - } - doWaypoints = optionsDlg.getDoWaypoints(); - doUnits = optionsDlg.getDoUnits(); - doTriggerAreas = optionsDlg.getDoTriggers(); - doAllScripts = optionsDlg.getDoAllScripts(); - doSides = optionsDlg.getDoSides(); - - Script *pScript = getCurScript(); - ScriptGroup *pGroup = getCurGroup(); - - ScriptList *scripts[MAX_PLAYER_COUNT]; - for (i=0; igetNext()) { - pObj->getProperties()->setBool(TheKey_exportWithScript, false); - if (pObj->isWaypoint() && (doWaypoints&&doAllScripts)) { - pObj->getProperties()->setBool(TheKey_exportWithScript, true); - } - } - - PolygonTrigger *pTrig; - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - pTrig->setDoExportWithScripts(doAllScripts && doTriggerAreas); - if (pTrig->isWaterArea()) { - pTrig->setDoExportWithScripts(false); // don't export water. - } - } - - for (i = 0; i < m_sides.getNumTeams(); i++) { - m_sides.getTeamInfo(i)->getDict()->setBool(TheKey_exportWithScript, doAllScripts); - } - Int numScriptLists = 0; - if (doAllScripts) { - numScriptLists = m_sides.getNumSides(); - for (i=0; igetScriptList(); - } - } else { - numScriptLists = 1; - if (m_curSelection.m_objType == ListType::PLAYER_TYPE) { - scripts[0] = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - scripts[0] = scripts[0]->duplicate(); - } else if (pGroup) { - pGroup = pGroup->duplicate(); - scripts[0] = newInstance( ScriptList); - scripts[0]->addGroup(pGroup, 0); - } else if (pScript) { - pScript = pScript->duplicate(); - scripts[0] = newInstance( ScriptList); - scripts[0]->addScript(pScript, 0); - } - if (scripts[0] == nullptr) { - ::AfxMessageBox("No scripts selected - aborting export.", MB_OK); - return; - } - } - for (i=0; igetScript(); pScr; pScr=pScr->getNext()) { - scanForWaypointsAndTeams(pScr, doUnits, doWaypoints, doTriggerAreas); - } - for (pGroup = pSL->getScriptGroup(); pGroup; pGroup=pGroup->getNext()) { - for (pScr = pGroup->getScript(); pScr; pScr=pScr->getNext()) { - scanForWaypointsAndTeams(pScr, doUnits, doWaypoints, doTriggerAreas); - } - } - } - - - CString path = fileDlg.GetPathName(); - - CFile theFile(path, CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite|CFile::typeBinary); - try { - LocalMFCFileOutputStream theStream(&theFile); - DataChunkOutput chunkWriter(&theStream); - ScriptList::WriteScriptsDataChunk(chunkWriter, scripts, numScriptLists); - - /***************Players DATA ***************/ - chunkWriter.openDataChunk("ScriptsPlayers", K_PLAYERS_NAMES_FOR_SCRIPTS_VERSION_2); - chunkWriter.writeInt(doSides); - if (doAllScripts || doSides) { - chunkWriter.writeInt(m_sides.getNumSides()); - for (i=0; igetDict()->getAsciiString(TheKey_playerName); - chunkWriter.writeAsciiString(name); - - if (doSides) { - // The user has requested that the sides get exported. - chunkWriter.writeDict(*m_sides.getSideInfo(i)->getDict()); - } - - } - } else { - chunkWriter.writeInt(1); - chunkWriter.writeAsciiString("**SELECTION**"); - } - chunkWriter.closeDataChunk(); - - /***************OBJECTS DATA ***************/ - chunkWriter.openDataChunk("ObjectsList", K_OBJECTS_VERSION_3); - - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) - { - if (!pObj->getProperties()->getBool(TheKey_exportWithScript)) { - continue; - }; - chunkWriter.openDataChunk("Object", K_OBJECTS_VERSION_3); - Coord3D loc = *pObj->getLocation(); - chunkWriter.writeReal( loc.x); - chunkWriter.writeReal( loc.y); - chunkWriter.writeReal( loc.z); - chunkWriter.writeReal( pObj->getAngle()); - chunkWriter.writeInt(pObj->getFlags()); - chunkWriter.writeAsciiString(pObj->getName()); - - chunkWriter.writeDict(*pObj->getProperties()); - - chunkWriter.closeDataChunk(); - } - chunkWriter.closeDataChunk(); - - /***************POLYGON TRIGGERS DATA ***************/ - // Version 4 preserves polygon trigger layer assignments in script bundles. - chunkWriter.openDataChunk("PolygonTriggers", K_TRIGGERS_VERSION_4); - - PolygonTrigger *pTrig; - Int count = 0; - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (pTrig->doExportWithScripts()) { - count++; - } - } - chunkWriter.writeInt(count); - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (!pTrig->doExportWithScripts()) continue; - chunkWriter.writeAsciiString(pTrig->getTriggerName()); - chunkWriter.writeAsciiString(pTrig->getLayerName()); - chunkWriter.writeInt(pTrig->getID()); - chunkWriter.writeByte(pTrig->isWaterArea()); - chunkWriter.writeByte(pTrig->isRiver()); - chunkWriter.writeInt(pTrig->getRiverStart()); - chunkWriter.writeInt(pTrig->getNumPoints()); - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D loc = *pTrig->getPoint(i); - chunkWriter.writeInt( loc.x); - chunkWriter.writeInt( loc.y); - chunkWriter.writeInt( loc.z); - } - } - chunkWriter.closeDataChunk(); - /***************TEAMS DATA ***************/ - chunkWriter.openDataChunk("ScriptTeams", K_LOCAL_TEAMS_VERSION_1); - for (i = 0; i < m_sides.getNumTeams(); i++) - { - if (m_sides.getTeamInfo(i)->getDict()->getBool(TheKey_exportWithScript)) { - chunkWriter.writeDict(*m_sides.getTeamInfo(i)->getDict()); - } - } - - - chunkWriter.closeDataChunk(); - /***************WAYPOINTS DATA ***************/ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - Int i; - count = 0; - for (i = 0; igetNumWaypointLinks(); i++) { - Int waypointID1, waypointID2; - MapObject *pWay1, *pWay2; - pDoc->getWaypointLink(i, &waypointID1, &waypointID2); - pWay1 = pDoc->getWaypointByID(waypointID1); - pWay2 = pDoc->getWaypointByID(waypointID2); - if (pWay1 && pWay2) { - if (!pWay1->getProperties()->getBool(TheKey_exportWithScript)) { - continue; - }; - if (!pWay1->getProperties()->getBool(TheKey_exportWithScript)) { - continue; - }; - count++; - } - } - - chunkWriter.openDataChunk("WaypointsList", K_WAYPOINTS_VERSION_1); - chunkWriter.writeInt(count); - for (i = 0; igetNumWaypointLinks(); i++) { - Int waypointID1, waypointID2; - MapObject *pWay1, *pWay2; - pDoc->getWaypointLink(i, &waypointID1, &waypointID2); - pWay1 = pDoc->getWaypointByID(waypointID1); - pWay2 = pDoc->getWaypointByID(waypointID2); - if (pWay1 && pWay2) { - if (!pWay1->getProperties()->getBool(TheKey_exportWithScript)) { - continue; - }; - if (!pWay1->getProperties()->getBool(TheKey_exportWithScript)) { - continue; - }; - chunkWriter.writeInt(waypointID1); - chunkWriter.writeInt(waypointID2); - } - } - chunkWriter.closeDataChunk(); - - } catch(...) { - DEBUG_CRASH(("threw exception in ScriptDialog::OnSave")); - } - if (!doAllScripts) { - deleteInstance(scripts[0]); - } - theFile.Close(); -} - -void ScriptDialog::OnLoad() -{ - CFileDialog fileDlg(true, ".scb", nullptr, 0, - "Script files (.scb)|*.scb||", this); - - Int result = fileDlg.DoModal(); - - // Open document dialog may change working directory, - // change it back. - char buf[_MAX_PATH]; - ::GetModuleFileName(nullptr, buf, sizeof(buf)); - if (char *pEnd = strrchr(buf, '\\')) { - *pEnd = 0; - } - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - ::SetCurrentDirectory(buf); - if (IDCANCEL==result) { - return; - } - - CString path = fileDlg.GetPathName(); - - CachedFileInputStream theInputStream; - if (theInputStream.open(AsciiString(path))) - try { - ChunkInputStream *pStrm = &theInputStream; - DataChunkInput file( pStrm ); - m_firstReadObject = nullptr; - m_firstTrigger = nullptr; - m_waypointBase = pDoc->getNextWaypointID(); - m_maxWaypoint = m_waypointBase; - file.registerParser( "PlayerScriptsList", AsciiString::TheEmptyString, ScriptList::ParseScriptsDataChunk ); - file.registerParser( "ObjectsList", AsciiString::TheEmptyString, ParseObjectsDataChunk ); - file.registerParser( "PolygonTriggers", AsciiString::TheEmptyString, ParsePolygonTriggersDataChunk ); - file.registerParser( "WaypointsList", AsciiString::TheEmptyString, ParseWaypointDataChunk ); - file.registerParser( "ScriptTeams", AsciiString::TheEmptyString, ParseTeamsDataChunk ); - file.registerParser( "ScriptsPlayers", AsciiString::TheEmptyString, ParsePlayersDataChunk ); - if (!file.parse(this)) { - throw(ERROR_CORRUPT_FILE_FORMAT); - } - pDoc->setNextWaypointID(m_maxWaypoint); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(m_sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_sides = *TheSidesList; - - if (m_firstReadObject) { - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, m_firstReadObject); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_firstReadObject = nullptr; // undoable owns it now. - } - PolygonTrigger *pTrig; - PolygonTrigger *pNextTrig; - for (pTrig=m_firstTrigger; pTrig; pTrig = pNextTrig) { - pNextTrig = pTrig->getNext(); - pTrig->setNextPoly(nullptr); - // Register the imported trigger with its serialized WorldBuilder layer. - TheLayersList->addPolygonTriggerToLayersList(pTrig, pTrig->getLayerName()); - PolygonTrigger::addPolygonTrigger(pTrig); - } - - ScriptList *scripts[MAX_PLAYER_COUNT]; - Int count = ScriptList::getReadScripts(scripts); - Int i; - for (i=0; igetScript() == nullptr && scripts[i]->getScriptGroup()==nullptr) continue; - Int curSide = -1; - if (count==1) { - curSide = m_curSelection.m_playerIndex; - } else { - Int j; - for (j=0; jgetDict()->getAsciiString(TheKey_playerName); - if (name == m_readPlayerNames[j]) { - curSide = j; - break; - } - } - if (curSide == -1) { - CString msg = "Could not find player"; - msg += m_readPlayerNames[i].str(); - msg += ", discarding scripts for this player."; - ::AfxMessageBox(msg); - - deleteInstance(scripts[i]); - scripts[i] = nullptr; - continue; - } - } - if (curSide>= m_sides.getNumSides()) { - curSide = 0; - ::AfxMessageBox("Imported scripts came from more players than exist in this map. Additional scripts moved to Neutral player."); - } - - ScriptList *pSL = m_sides.getSideInfo(curSide)->getScriptList(); - if (pSL) { - Script *pScr; - Script *pNextScr; - Int j=0; - for (pScr = scripts[i]->getScript(); pScr; pScr=pNextScr) { - pNextScr=pScr->getNext(); - pScr->setNextScript(nullptr); - pSL->addScript(pScr, j); //unlink it and add. - j++; - } - j=0; - ScriptGroup *pGroup; - ScriptGroup *pNextGroup; - for (pGroup = scripts[i]->getScriptGroup(); pGroup; pGroup=pNextGroup) { - pNextGroup=pGroup->getNext(); - pGroup->setNextGroup(nullptr); - pSL->addGroup(pGroup, j); - j++; - } - scripts[i]->discard(); /* Frees the script list, but none of it's children, as they have been - copied into the current scripts. */ - scripts[i] = nullptr; - //reloadPlayer(curSide, pSL); - } else { - deleteInstance(scripts[i]); - scripts[i] = nullptr; - } - } - - for (i = 0; i < m_sides.getNumSides(); i++) { - // Make sure that the dialog tree is updated. - ScriptList *pSL = m_sides.getSideInfo(i)->getScriptList(); - reloadPlayer(i, pSL); - updateIcons(TVI_ROOT); - } - - - } catch(...) { - DEBUG_CRASH(("threw exception in ScriptDialog::OnLoad")); - } -} - -/** -* ScriptDialog::ParseObjectsDataChunk - read an objects chunk. -* Format is the newer CHUNKY format. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - file.m_currentObject = nullptr; - file.registerParser( "Object", info->label, ParseObjectDataChunk ); - return (file.parse(userData)); -} - -/** -* WorldHeightMap::ParseObjectData - read a object info chunk. -* Format is the newer CHUNKY format. -* See WHeightMapEdit.cpp for the writer. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - ScriptDialog *pThis = (ScriptDialog *)userData; - MapObject *pPrevious = (MapObject *)file.m_currentObject; - - Coord3D loc; - loc.x = file.readReal(); - loc.y = file.readReal(); - loc.z = file.readReal(); - Real angle = file.readReal(); - Int flags = file.readInt(); - AsciiString name = file.readAsciiString(); - Dict d; - d = file.readDict(); - MapObject *pThisOne; - - // create the map object - pThisOne = newInstance( MapObject)( loc, name, angle, flags, &d, - TheThingFactory->findTemplate( name ) ); - - if (pThisOne->getProperties()->getType(TheKey_waypointID) == Dict::DICT_INT) { - pThisOne->setIsWaypoint(); - pThisOne->setWaypointID(pThisOne->getWaypointID()+pThis->m_waypointBase); - if (pThis->m_maxWaypoint < pThisOne->getWaypointID()) pThis->m_maxWaypoint = pThisOne->getWaypointID(); - } - - DEBUG_LOG(("Adding object %s (%s)", name.str(), pThisOne->getProperties()->getAsciiString(TheKey_originalOwner).str())); - // Check for duplicates. - - MapObject *pObj; - Bool duplicate = false; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - Coord3D curLoc; - curLoc = *pObj->getLocation(); - Bool locsMatch = (loc.x==curLoc.x&&loc.y==curLoc.y); - // If the locations match, and they are both waypoints or both not waypoints, and the names match, - // They're duplicate. - if (locsMatch && (pObj->isWaypoint() == pThisOne->isWaypoint()) && (pObj->getName() == pThisOne->getName())) { - duplicate = true; - } - if (pThisOne->isWaypoint() && pObj->isWaypoint() ) { - // If both waypoints, and the names match, are dupes. - if (!duplicate && (pThisOne->getWaypointName()==pObj->getWaypointName())) { - AsciiString warning; - warning.format("Duplicate named waypoints '%s', renaming imported waypoint.", pThisOne->getWaypointName().str()); - ::AfxMessageBox(warning.str(), MB_OK); - AsciiString name = WaypointOptions::GenerateUniqueName(pThisOne->getWaypointID()); - name.concat("-imp"); - } - } - if (duplicate) break; - } - if (duplicate) { - deleteInstance(pThisOne); - return true; - } - - if (pPrevious) { - DEBUG_ASSERTCRASH(pThis->m_firstReadObject != nullptr && pPrevious->getNext() == nullptr, ("Bad linkage.")); - pPrevious->setNextMap(pThisOne); - } else { - DEBUG_ASSERTCRASH(pThis->m_firstReadObject == nullptr, ("Bad linkage.")); - pThis->m_firstReadObject = pThisOne; - } - file.m_currentObject = pThisOne; - return true; -} - -/** -* ScriptDialog::ParseWaypointData - read waypoint data chunk. -* Format is the newer CHUNKY format. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - Int count = file.readInt(); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - ScriptDialog *pThis = (ScriptDialog *)userData; - Int i; - for (i=0; iaddWaypointLink(waypoint1+pThis->m_waypointBase, waypoint2+pThis->m_waypointBase); - if (pThis->m_maxWaypoint < waypoint1+pThis->m_waypointBase) pThis->m_maxWaypoint = waypoint1+pThis->m_waypointBase; - if (pThis->m_maxWaypoint < waypoint2+pThis->m_waypointBase) pThis->m_maxWaypoint = waypoint1+pThis->m_waypointBase; - } - DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over.")); - return true; -} - -/** -* ScriptDialog::ParseTeamsDataChunk - read teams data chunk. -* Format is the newer CHUNKY format. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParseTeamsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - ScriptDialog *pThis = (ScriptDialog *)userData; - while (!file.atEndOfChunk()) { - Dict teamDict = file.readDict(); - AsciiString teamName = teamDict.getAsciiString(TheKey_teamName); - if (pThis->m_sides.findTeamInfo(teamName)) { - continue; - } - DEBUG_LOG(("Adding team %s", teamName.str())); - AsciiString player = teamDict.getAsciiString(TheKey_teamOwner); - if (pThis->m_sides.findSideInfo(player)) { - // player exists, so just add it. - pThis->m_sides.addTeam(&teamDict); - } else { - AsciiString warning; - warning.format("Importing team %s of player %s. Player %s doesn't exist, Select player..", - teamName.str(), player.str(), player.str()); - - ::AfxMessageBox(warning.str(), MB_OK); - TeamsInfo ti; - ti.init(&teamDict); - CFixTeamOwnerDialog fix(&ti, &pThis->m_sides); - bool nameSet = false; - if (fix.DoModal() == IDOK) { - if (fix.pickedValidTeam()) { - teamDict.setAsciiString(TheKey_teamOwner, fix.getSelectedOwner()); - nameSet = true; - } - } - - if (nameSet == false) { - AsciiString neutralPlayerName; // neutral player name is empty string - // player doesn't exist, so add it to the neutral player. - teamDict.setAsciiString(TheKey_teamOwner, neutralPlayerName); - } - pThis->m_sides.addTeam(&teamDict); - } - } - DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over.")); - return true; -} - -/** -* ScriptDialog::ParsePlayersDataChunk - read players names data chunk. -* Format is the newer CHUNKY format. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParsePlayersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - ScriptDialog *pThis = (ScriptDialog *)userData; - Int readDicts = 0; - if (info->version >= K_PLAYERS_NAMES_FOR_SCRIPTS_VERSION_2) { - readDicts = file.readInt(); - } - Int numNames = file.readInt(); - Int i; - for (i=0; i=MAX_PLAYER_COUNT) break; - pThis->m_readPlayerNames[i] = file.readAsciiString(); - if (readDicts) { - Dict sideDict = file.readDict(); - bool nameFound = false; - for (Int j=0; j < pThis->m_sides.getNumSides(); j++) { - AsciiString name = pThis->m_sides.getSideInfo(j)->getDict()->getAsciiString(TheKey_playerName); - - if (name == pThis->m_readPlayerNames[i]) { - // The side already exists so don't add it or overwrite the old data. - nameFound = true; - break; - } - } - if (nameFound == false) { - // This side doesn't currently exist, so add it. - pThis->m_sides.addSide(&sideDict); - ScriptList* pList = newInstance(ScriptList); - SidesInfo* sides = pThis->m_sides.findSideInfo(pThis->m_readPlayerNames[i]); - // A script list must be created. - sides->setScriptList(pList); - // Update the dialog. - pThis->addPlayer(i); - } - } - } - DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over.")); - return true; -} - -/** -* ScriptDialog::ParsePolygonTriggersDataChunk - read a polygon triggers chunk. -* Format is the newer CHUNKY format. -* See PolygonTrigger::WritePolygonTriggersDataChunk for the writer. -* Input: DataChunkInput -* -*/ -Bool ScriptDialog::ParsePolygonTriggersDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - Int count; - Int numPoints; - Int triggerID; -// Int maxTriggerId = 0; - AsciiString triggerName; - AsciiString layerName; - // Remove any existing polygon triggers, if any. - ScriptDialog *pThis = (ScriptDialog *)userData; - pThis->m_firstTrigger = nullptr; - PolygonTrigger *pPrevTrig = nullptr; - count = file.readInt(); - Bool isRiver; - Int riverStart; - while (count>0) { - count--; - Bool isWater = false; - triggerName = file.readAsciiString(); - if (info->version >= K_TRIGGERS_VERSION_4) { - layerName = file.readAsciiString(); - } - triggerID = file.readInt(); - if (info->version >= K_TRIGGERS_VERSION_2) { - isWater = file.readByte(); - } - isRiver = false; - riverStart = 0; - if (info->version >= K_TRIGGERS_VERSION_3) { - isRiver = file.readByte(); - riverStart = file.readInt(); - } - numPoints = file.readInt(); - PolygonTrigger *pTrig = newInstance(PolygonTrigger)(numPoints+1); - pTrig->setTriggerName(triggerName); - if (info->version >= K_TRIGGERS_VERSION_4) { - pTrig->setLayerName(layerName); - } - pTrig->setWaterArea(isWater); - pTrig->setRiver(isRiver); - pTrig->setRiverStart(riverStart); - Int i; - for (i=0; iaddPoint(loc); - } - // Check for duplicates. - Bool duplicate = false; - PolygonTrigger *pCurrentTrigger; - for (pCurrentTrigger=PolygonTrigger::getFirstPolygonTrigger(); pCurrentTrigger; pCurrentTrigger = pCurrentTrigger->getNext()) { - if (triggerName == pCurrentTrigger->getTriggerName()) { - duplicate = true; - AsciiString warning; - warning.format("Duplicated trigger named '%s' discarded.", triggerName.str()); - ::AfxMessageBox(warning.str(), MB_OK); - break; - } - } - if (duplicate ) { - deleteInstance(pTrig); - } else { - if (pPrevTrig) { - pPrevTrig->setNextPoly(pTrig); - } else { - pThis->m_firstTrigger = pTrig; - } - pPrevTrig = pTrig; - } - } - DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Incorrect data file length.")); - return true; -} - - -void ScriptDialog::OnDblclkScriptTree(NMHDR* pNMHDR, LRESULT* pResult) -{ - Script *pScript = getCurScript(); - ScriptGroup *pGroup = getCurGroup(); - if (pScript == nullptr && pGroup == nullptr) return; - OnEditScript(); - *pResult = 0; -} - -void ScriptDialog::OnOK() -{ - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(m_sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - CDialog::OnOK(); -} - -void ScriptDialog::OnCancel() -{ - - CDialog::OnCancel(); -} - -void ScriptDialog::OnBegindragScriptTree(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - - m_curSelection.IntToList(pNMTreeView->itemNew.lParam); - if (m_curSelection.m_objType != ListType::PLAYER_TYPE) { - m_dragItem = pNMTreeView->itemNew.hItem; - pTree->SelectItem(m_dragItem); - m_draggingTreeView = true; - SetCapture(); - } - *pResult = 0; -} - -void ScriptDialog::OnMouseMove(UINT nFlags, CPoint point) -{ - if (m_draggingTreeView) { - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - - HTREEITEM htiTarget; // handle to target item - TVHITTESTINFO tvht; // hit test information - - const Int CENTER_OFFSET = 12; - point.y -= CENTER_OFFSET; - tvht.pt = point; - if ((htiTarget = pTree->HitTest( &tvht)) != nullptr) { - pTree->SelectDropTarget(htiTarget); - } - } - - CDialog::OnMouseMove(nFlags, point); -} - -void ScriptDialog::OnLButtonUp(UINT nFlags, CPoint point) -{ - if (m_draggingTreeView) { - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - m_draggingTreeView = false; - - ReleaseCapture(); - HTREEITEM htiTarget; // handle to target item - TVHITTESTINFO tvht; // hit test information - - const Int CENTER_OFFSET = 12; - point.y -= CENTER_OFFSET; - tvht.pt = point; - if ((htiTarget = pTree->HitTest( &tvht)) != nullptr) { - pTree->SelectItem(htiTarget); - pTree->SelectDropTarget(htiTarget); - doDropOn(m_dragItem, htiTarget); - } - } - CDialog::OnLButtonUp(nFlags, point); -} - -void ScriptDialog::doDropOn(HTREEITEM hDrag, HTREEITEM hTarget) -{ - if (hDrag == hTarget) return; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - ListType drag; - drag.IntToList(pTree->GetItemData(hDrag)); - ListType target; - target.IntToList(pTree->GetItemData(hTarget)); - - Script *dragScript = nullptr; - ScriptGroup *dragGroup = nullptr; - m_curSelection = drag; - Script *pScript = getCurScript(); - ScriptList *pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - ScriptGroup *pGroup = getCurGroup(); - if (pSL == nullptr) return; - if (pScript) { - dragScript = pScript->duplicate(); - if (pGroup) { - pGroup->deleteScript(pScript); - } else { - pSL->deleteScript(pScript); - } - if (drag.m_objType == target.m_objType && - drag.m_playerIndex == target.m_playerIndex && - drag.m_groupIndex == target.m_groupIndex && - drag.m_scriptIndex < target.m_scriptIndex) { - target.m_scriptIndex--; - } - } else if (drag.m_objType == ListType::GROUP_TYPE) { - dragGroup = pGroup->duplicate(); - pSL->deleteGroup(pGroup); - if (drag.m_objType != ListType::SCRIPT_IN_PLAYER_TYPE && - drag.m_playerIndex == target.m_playerIndex && - drag.m_groupIndex < target.m_groupIndex) { - target.m_groupIndex--; - } - } - pTree->DeleteItem(hDrag); - m_curSelection = target; - pScript = getCurScript(); - pSL = m_sides.getSideInfo(m_curSelection.m_playerIndex)->getScriptList(); - pGroup = getCurGroup(); - DEBUG_ASSERTCRASH((pSL), ("Hmm - bad data. jba.")); - if (pSL == nullptr) return; - - // If we are dragging a group onto a script, adjust the group index so we add after. - if (drag.m_objType == ListType::GROUP_TYPE) { - if (target.m_objType == ListType::SCRIPT_IN_PLAYER_TYPE) { - target.m_groupIndex = 9999; - } - if (target.m_objType == ListType::SCRIPT_IN_GROUP_TYPE) { - target.m_groupIndex++; - } - target.m_objType = ListType::GROUP_TYPE; - } - - if (dragScript) { - if (pGroup) { - pGroup->addScript(dragScript, target.m_scriptIndex); - } else { - pSL->addScript(dragScript, target.m_scriptIndex); - } - } else if (dragGroup) { - pSL->addGroup(dragGroup, target.m_groupIndex); - Int count = 0; - ScriptGroup *pGroup = pSL->getScriptGroup(); - while (pGroup->getNext()) { - if (pGroup==dragGroup) break; - count++; - pGroup = pGroup->getNext(); - } - target.m_groupIndex = count; - } - if (target.m_playerIndex != drag.m_playerIndex) { - reloadPlayer(drag.m_playerIndex, m_sides.getSideInfo(drag.m_playerIndex)->getScriptList()); - } - reloadPlayer(target.m_playerIndex, pSL); - updateSelection(target); - updateIcons(TVI_ROOT); -} - -void ScriptDialog::OnMove(int x, int y) -{ - CDialog::OnMove(x, y); - - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(SCRIPT_DIALOG_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(SCRIPT_DIALOG_SECTION, "Left", frameRect.left); - } - -} - -/** This function reacts to the selection of "active" from - the right click drop down menu */ -void ScriptDialog::OnScriptActivate() -{ - AsciiString newName; - Bool active; - CTreeCtrl *pTree = (CTreeCtrl*)GetDlgItem(IDC_SCRIPT_TREE); - HTREEITEM item = findItem(m_curSelection); - - if (getCurScript() != nullptr) - { - /// Updates attributes - active = getCurScript()->isActive(); - getCurScript()->setActive(!active); - - /// Updates screen to reflect change - Script *pScript = getCurScript(); - pTree->SetItemText(item, formatScriptLabel(pScript).str()); - - if (getCurScript()->hasWarnings()) - { - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(4), TVIS_STATEIMAGEMASK); - } - else - { - if (getCurScript()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(2), TVIS_STATEIMAGEMASK); - else - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(6), TVIS_STATEIMAGEMASK); - } - } - else if (getCurGroup() != nullptr) - { - /// Updates attributes - active = getCurGroup()->isActive(); - getCurGroup()->setActive(!active); - - /// Updates screen to reflect change - ScriptGroup *pScriptGroup = getCurGroup(); - pTree->SetItemText(item, formatScriptLabel(pScriptGroup).str()); - - if (getCurGroup()->hasWarnings()) - { - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(3), TVIS_STATEIMAGEMASK); - } - else - { - if (getCurGroup()->isActive()) - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(1), TVIS_STATEIMAGEMASK); - else - pTree->SetItemState(item, INDEXTOSTATEIMAGEMASK(5), TVIS_STATEIMAGEMASK); - } - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptProperties.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptProperties.cpp deleted file mode 100644 index 4f5cda9d1df..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ScriptProperties.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ScriptProperties.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "ScriptProperties.h" -#include "GameLogic/Scripts.h" - -///////////////////////////////////////////////////////////////////////////// -// ScriptProperties property page - -IMPLEMENT_DYNCREATE(ScriptProperties, CPropertyPage) - -ScriptProperties::ScriptProperties() : m_updating(false), m_script(nullptr), -CPropertyPage(ScriptProperties::IDD) -{ - //{{AFX_DATA_INIT(ScriptProperties) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -ScriptProperties::~ScriptProperties() -{ -} - -void ScriptProperties::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ScriptProperties) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ScriptProperties, CPropertyPage) - //{{AFX_MSG_MAP(ScriptProperties) - ON_EN_CHANGE(IDC_SCRIPT_COMMENT, OnChangeScriptComment) - ON_EN_CHANGE(IDC_SCRIPT_NAME, OnChangeScriptName) - ON_BN_CLICKED(IDC_SCRIPT_ACTIVE, OnScriptActive) - ON_BN_CLICKED(IDC_ONE_SHOT, OnOneShot) - ON_BN_CLICKED(IDC_EASY, OnEasy) - ON_BN_CLICKED(IDC_HARD, OnHard) - ON_BN_CLICKED(IDC_NORMAL, OnNormal) - ON_BN_CLICKED(IDC_SCRIPT_SUBROUTINE, OnScriptSubroutine) - ON_BN_CLICKED(IDC_EVERY_FRAME, OnEveryFrame) - ON_BN_CLICKED(IDC_EVERY_SECOND, OnEverySecond) - ON_EN_CHANGE(IDC_SECONDS_EDIT, OnChangeSecondsEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ScriptProperties message handlers - -BOOL ScriptProperties::OnSetActive() -{ - if ( CPropertyPage::OnSetActive()) { - CWnd *pWnd = GetDlgItem(IDC_SCRIPT_COMMENT); - pWnd->SetWindowText(m_script->getComment().str()); - - pWnd = GetDlgItem(IDC_SCRIPT_NAME); - pWnd->SetWindowText(m_script->getName().str()); - enableControls(); - return true; - } - return false; -} - -void ScriptProperties::enableControls() -{ - Bool isSubroutine = m_script->isSubroutine(); - CButton *pButton = (CButton*)GetDlgItem(IDC_SCRIPT_SUBROUTINE); - pButton->SetCheck(isSubroutine ? 1:0); - pButton = (CButton*)GetDlgItem(IDC_SCRIPT_ACTIVE); - pButton->SetCheck(m_script->isActive() ? 1:0); - //pButton->EnableWindow(!isSubroutine); - pButton = (CButton*)GetDlgItem(IDC_ONE_SHOT); - pButton->SetCheck(m_script->isOneShot() ? 1:0); - //pButton->EnableWindow(!isSubroutine); - pButton = (CButton*)GetDlgItem(IDC_EASY); - pButton->SetCheck(m_script->isEasy() ? 1:0); - //pButton->EnableWindow(!isSubroutine); - pButton = (CButton*)GetDlgItem(IDC_NORMAL); - pButton->SetCheck(m_script->isNormal() ? 1:0); - //pButton->EnableWindow(!isSubroutine); - pButton = (CButton*)GetDlgItem(IDC_HARD); - pButton->SetCheck(m_script->isHard() ? 1:0); - //pButton->EnableWindow(!isSubroutine); - - m_updating = true; - Int delay = m_script->getDelayEvalSeconds(); - pButton = (CButton*)GetDlgItem(IDC_EVERY_SECOND); - pButton->SetCheck(delay>0); - pButton = (CButton*)GetDlgItem(IDC_EVERY_FRAME); - pButton->SetCheck(delay==0); - CString text=""; - if (delay>0) text.Format("%d", delay); - GetDlgItem(IDC_SECONDS_EDIT)->SetWindowText(text); - m_updating = false; -} - -void ScriptProperties::OnChangeScriptComment() -{ - CWnd *pWnd = GetDlgItem(IDC_SCRIPT_COMMENT); - CString comment; - pWnd->GetWindowText(comment); - m_script->setComment(AsciiString((LPCTSTR)comment)); -} - -void ScriptProperties::OnChangeScriptName() -{ - CWnd *pWnd = GetDlgItem(IDC_SCRIPT_NAME); - CString name; - pWnd->GetWindowText(name); - m_script->setName(AsciiString((LPCTSTR)name)); - GetParent()->SetWindowText(name); -} - -void ScriptProperties::OnScriptActive() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_SCRIPT_ACTIVE); - m_script->setActive(pButton->GetCheck()==1); -} - -void ScriptProperties::OnOneShot() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_ONE_SHOT); - m_script->setOneShot(pButton->GetCheck()==1); -} - -void ScriptProperties::OnEasy() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_EASY); - m_script->setEasy(pButton->GetCheck()==1); -} - -void ScriptProperties::OnHard() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_HARD); - m_script->setHard(pButton->GetCheck()==1); -} - -void ScriptProperties::OnNormal() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_NORMAL); - m_script->setNormal(pButton->GetCheck()==1); -} - -void ScriptProperties::OnScriptSubroutine() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_SCRIPT_SUBROUTINE); - Bool isSubroutine = pButton->GetCheck()==1; - m_script->setSubroutine(isSubroutine); - - enableControls(); - -} - -void ScriptProperties::OnEveryFrame() -{ - m_updating = true; - CButton *pButton = (CButton*)GetDlgItem(IDC_EVERY_SECOND); - pButton->SetCheck(0); - pButton = (CButton*)GetDlgItem(IDC_EVERY_FRAME); - pButton->SetCheck(1); - GetDlgItem(IDC_SECONDS_EDIT)->SetWindowText(""); - m_script->setDelayEvalSeconds(0); - m_updating = false; -} - -void ScriptProperties::OnEverySecond() -{ - m_updating = true; - CButton *pButton = (CButton*)GetDlgItem(IDC_EVERY_SECOND); - pButton->SetCheck(1); - pButton = (CButton*)GetDlgItem(IDC_EVERY_FRAME); - pButton->SetCheck(0); - GetDlgItem(IDC_SECONDS_EDIT)->SetWindowText("1"); - m_script->setDelayEvalSeconds(1); - m_updating = false; -} - -void ScriptProperties::OnChangeSecondsEdit() -{ - if (m_updating) return; - CButton *pButton = (CButton*)GetDlgItem(IDC_EVERY_SECOND); - pButton->SetCheck(1); - pButton = (CButton*)GetDlgItem(IDC_EVERY_FRAME); - pButton->SetCheck(0); - CWnd *pEdit = GetDlgItem(IDC_SECONDS_EDIT); - CString text; - pEdit->GetWindowText(text); - Int theInt; - if (1==sscanf(text, "%d", &theInt)) { - m_script->setDelayEvalSeconds(theInt); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp deleted file mode 100644 index 9bb7546994a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/SelectMacrotexture.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// SelectMacrotexture.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "SelectMacrotexture.h" -#include "Common/FileSystem.h" -#include "Common/GlobalData.h" -#include "W3DDevice/GameClient/HeightMap.h" - -///////////////////////////////////////////////////////////////////////////// -// SelectMacrotexture dialog - - -SelectMacrotexture::SelectMacrotexture(CWnd* pParent /*=nullptr*/) - : CDialog(SelectMacrotexture::IDD, pParent) -{ - //{{AFX_DATA_INIT(SelectMacrotexture) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void SelectMacrotexture::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(SelectMacrotexture) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(SelectMacrotexture, CDialog) - //{{AFX_MSG_MAP(SelectMacrotexture) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -#define DEFAULT "***Default" - -///////////////////////////////////////////////////////////////////////////// -// SelectMacrotexture message handlers - -BOOL SelectMacrotexture::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *pWnd = GetDlgItem(IDC_TEXTURE_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_textureTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_textureTreeView.ShowWindow(SW_SHOW); - - { - char fileBuf[_MAX_PATH]; - - FilenameList filenameList; - TheFileSystem->getFileListInDirectory("..\\TestArt\\", "*.tga", filenameList, FALSE); - - if (!filenameList.empty()) { - TVINSERTSTRUCT ins; - HTREEITEM child = nullptr; - FilenameList::iterator it = filenameList.begin(); - do { - AsciiString filename = *it; - int len = filename.getLength(); - if (len<5) continue; - strlcpy(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = TVI_ROOT; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = fileBuf; - ins.item.cchTextMax = strlen(fileBuf); - child = m_textureTreeView.InsertItem(&ins); - ++it; - } while (it != filenameList.end()); - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = TVI_ROOT; - ins.hInsertAfter = TVI_SORT; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - char defaultText[] = DEFAULT; - ins.item.pszText = defaultText; - ins.item.cchTextMax = strlen(defaultText); - child = m_textureTreeView.InsertItem(&ins); - - } - } - - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BOOL SelectMacrotexture::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_textureTreeView.m_hWnd) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - char buffer[_MAX_PATH]; - HTREEITEM hItem = m_textureTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT|TVIF_STATE; - item.hItem = hItem; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_textureTreeView.GetItem(&item); - if (0==strcmp(buffer, DEFAULT)) { - TheTerrainRenderObject->updateMacroTexture(""); - } else { - TheTerrainRenderObject->updateMacroTexture(AsciiString(buffer)); - } - TheWritableGlobalData->m_useLightMap = true; - } - } - return CDialog::OnNotify(wParam, lParam, pResult); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ShadowOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ShadowOptions.cpp deleted file mode 100644 index 451f24aacf2..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ShadowOptions.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// ShadowOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "Lib/BaseType.h" -#include "WW3D2/rendobj.h" -#include "Common/GlobalData.h" -#include "ShadowOptions.h" -#include "W3DDevice/GameClient/W3DShadow.h" - -///////////////////////////////////////////////////////////////////////////// -// ShadowOptions dialog - - -ShadowOptions::ShadowOptions(CWnd* pParent /*=nullptr*/) - : CDialog(ShadowOptions::IDD, pParent) -{ - //{{AFX_DATA_INIT(ShadowOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void ShadowOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ShadowOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(ShadowOptions, CDialog) - //{{AFX_MSG_MAP(ShadowOptions) - ON_EN_CHANGE(IDC_ALPHA_EDIT, OnChangeAlphaEdit) - ON_EN_CHANGE(IDC_BA_EDIT, OnChangeBaEdit) - ON_EN_CHANGE(IDC_GA_EDIT, OnChangeGaEdit) - ON_EN_CHANGE(IDC_RA_EDIT, OnChangeRaEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ShadowOptions message handlers - -void ShadowOptions::setShadowColor() -{ - Int r, g, b, shift; - - shift = (1.0-m_intensity)*255; - if (shift>255) shift = 255; - if (shift<0) shift = 0; - - r = m_intensity*m_red*255 + shift; - if (r>255) r = 255; - if (r<0) r = 0; - - g = m_intensity*m_green*255 + shift; - if (g>255) g = 255; - if (g<0) g = 0; - - b = m_intensity*m_blue*255 + shift; - if (b>255) b = 255; - if (b<0) b = 0; - - UnsignedInt clr = (255<<24) + (r<<16) + (g<<8) + b; - DEBUG_LOG(("Setting shadows to %x", clr)); - TheW3DShadowManager->setShadowColor(clr); -} - -void ShadowOptions::OnChangeAlphaEdit() -{ - CWnd *pEdit = GetDlgItem(IDC_ALPHA_EDIT); - Real clr; - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) { - m_intensity = clr; - setShadowColor(); - } - } -} - -void ShadowOptions::OnChangeBaEdit() -{ - CWnd *pEdit = GetDlgItem(IDC_BA_EDIT); - Real clr; - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) { - m_blue = clr; - setShadowColor(); - } - } -} - -void ShadowOptions::OnChangeGaEdit() -{ - CWnd *pEdit = GetDlgItem(IDC_GA_EDIT); - Real clr; - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) { - m_green = clr; - setShadowColor(); - } - } -} - -void ShadowOptions::OnChangeRaEdit() -{ - CWnd *pEdit = GetDlgItem(IDC_RA_EDIT); - Real clr; - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - if (1==sscanf(buffer, "%f", &clr)) { - m_red = clr; - setShadowColor(); - } - } -} - -BOOL ShadowOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - UnsignedInt clr = TheW3DShadowManager->getShadowColor(); - m_red = ((clr>>16)&0x00FF)/255.0f; - m_green = ((clr>>8)&0x00FF)/255.0f; - m_blue = ((clr)&0x00FF)/255.0f; - - m_intensity = m_red; - if (m_greenSetWindowText(text); - } - pEdit = GetDlgItem(IDC_BA_EDIT); - if (pEdit) { - text.Format("%.2f", m_blue); - pEdit->SetWindowText(text); - } - pEdit = GetDlgItem(IDC_GA_EDIT); - if (pEdit) { - text.Format("%.2f", m_green); - pEdit->SetWindowText(text); - } - pEdit = GetDlgItem(IDC_ALPHA_EDIT); - if (pEdit) { - text.Format("%.2f", m_intensity); - pEdit->SetWindowText(text); - } - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/SplashScreen.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/SplashScreen.cpp deleted file mode 100644 index ba08c559812..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/SplashScreen.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - -#include "StdAfx.h" -#include "SplashScreen.h" - -//------------------------------------------------------------------------------------------------- -SplashScreen::SplashScreen() -{ - m_rect.left = 0; - m_rect.right = 0; - m_rect.top = 0; - m_rect.bottom = 0; - - m_loadString = "Cock & Beer"; - - - LOGFONT lf; - lf.lfHeight = 12; - lf.lfWidth = 0; - lf.lfEscapement = 0; - lf.lfOrientation = 0; - lf.lfWeight = FW_NORMAL; - lf.lfItalic = FALSE; - lf.lfUnderline = FALSE; - lf.lfStrikeOut = FALSE; - lf.lfCharSet = ANSI_CHARSET; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - strcpy(lf.lfFaceName, "Arial"); - - m_font.CreateFontIndirect(&lf); -} - -//------------------------------------------------------------------------------------------------- -void SplashScreen::setTextOutputLocation(const CRect& rect) -{ - m_rect = rect; -} - -//------------------------------------------------------------------------------------------------- -void SplashScreen::outputText(UINT nIDString) -{ - CString str; - if (!str.LoadString(nIDString)) { - return; - } - - m_loadString = str; - - RedrawWindow(&m_rect, nullptr); -} - -//------------------------------------------------------------------------------------------------- -void SplashScreen::OnPaint() -{ - // we're extending the default behavior - CDialog::OnPaint(); - - - CDC *dc = GetDC(); - - // Save off the old font - CFont *oldFont = dc->SelectObject(&m_font); - COLORREF oldRef = dc->SetTextColor(0x00000000); - -// dc->DrawText(m_loadString, m_rect, DT_VCENTER | DT_LEFT); - - // restore the old font - dc->SelectObject(oldFont); - dc->SetTextColor(oldRef); -} - -BEGIN_MESSAGE_MAP(SplashScreen, CDialog) - ON_WM_PAINT() -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/StdAfx.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/StdAfx.cpp deleted file mode 100644 index 27b9a90ba32..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/StdAfx.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// stdafx.cpp : source file that includes just the standard includes -// WorldBuilder.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "StdAfx.h" - - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamBehavior.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TeamBehavior.cpp deleted file mode 100644 index 8e7a08076ea..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamBehavior.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TeamBehavior.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "TeamBehavior.h" -#include "EditParameter.h" -#include "Common/WellKnownKeys.h" -#include "GameLogic/AI.h" - -///////////////////////////////////////////////////////////////////////////// -// TeamBehavior dialog - -TeamBehavior::TeamBehavior() - : CPropertyPage(TeamBehavior::IDD) -{ - //{{AFX_DATA_INIT(TeamBehavior) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void TeamBehavior::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TeamBehavior) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(TeamBehavior, CPropertyPage) - //{{AFX_MSG_MAP(TeamBehavior) - ON_CBN_SELCHANGE(IDC_ON_CREATE_SCRIPT, OnSelchangeOnCreateScript) - ON_BN_CLICKED(IDC_TRANSPORTS_RETURN, OnTransportsReturn) - ON_BN_CLICKED(IDC_AVOID_THREATS, OnAvoidThreats) - ON_CBN_SELCHANGE(IDC_ON_ENEMY_SIGHTED, OnSelchangeOnEnemySighted) - ON_CBN_SELCHANGE(IDC_ON_DESTROYED, OnSelchangeOnDestroyed) - ON_CBN_SELCHANGE(IDC_ON_UNIT_DESTROYED_SCRIPT, OnSelchangeOnUnitDestroyed) - ON_BN_CLICKED(IDC_PERIMETER_DEFENSE, OnPerimeterDefense) - ON_BN_CLICKED(IDC_BASE_DEFENSE, OnBaseDefense) - ON_EN_CHANGE(IDC_PERCENT_DESTROYED, OnChangePercentDestroyed) - ON_CBN_SELCHANGE(IDC_ENEMY_INTERACTIONS, OnSelchangeEnemyInteractions) - ON_CBN_SELCHANGE(IDC_ON_ALL_CLEAR, OnSelchangeOnAllClear) - ON_CBN_SELCHANGE(IDC_ON_IDLE_SCRIPT, OnSelchangeOnIdleScript) - ON_BN_CLICKED(IDC_ATTACK_COMMON_TARGET, OnAttackCommonTarget) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TeamBehavior message handlers - -void TeamBehavior::updateScript(NameKeyType keyScript, int idcScript) -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(idcScript); - CString txt; - Int curSel = pCombo->GetCurSel(); - pCombo->GetLBText(curSel, txt); - AsciiString comboText = AsciiString(txt); - if (comboText == NONE_STRING) { - comboText.clear(); - } - m_teamDict->setAsciiString(keyScript, comboText); -} - -void TeamBehavior::setupScript(NameKeyType keyScript, int idcScript) -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(idcScript); - // Load the subroutine scripts into the combo box. - EditParameter::loadScripts(pCombo, true); - Int stringNdx = pCombo->AddString(NONE_STRING); - pCombo->SetFocus(); - Bool exists; - AsciiString script = m_teamDict->getAsciiString(keyScript, &exists); - if (exists && !script.isEmpty()) { - Int ndx = pCombo->FindStringExact(-1, script.str()); - if (ndx != CB_ERR) { - stringNdx = ndx; - } else { - AsciiString badName = "*"; - badName.concat(script); - stringNdx = pCombo->AddString(badName.str()); - } - } - pCombo->SetCurSel(stringNdx); -} - - -BOOL TeamBehavior::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - - setupScript(TheKey_teamOnCreateScript, IDC_ON_CREATE_SCRIPT); - setupScript(TheKey_teamOnIdleScript, IDC_ON_IDLE_SCRIPT); - setupScript(TheKey_teamEnemySightedScript, IDC_ON_ENEMY_SIGHTED); - setupScript(TheKey_teamOnDestroyedScript, IDC_ON_DESTROYED); - setupScript(TheKey_teamAllClearScript, IDC_ON_ALL_CLEAR); - setupScript(TheKey_teamOnUnitDestroyedScript, IDC_ON_UNIT_DESTROYED_SCRIPT); - - Bool exists; - - CButton *pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_RETURN); - Bool transportsReturn = m_teamDict->getBool(TheKey_teamTransportsReturn, &exists); - pCheck->SetCheck(transportsReturn?1:0); - - pCheck = (CButton *) GetDlgItem(IDC_BASE_DEFENSE); - if( pCheck ) - { - Bool baseDef = m_teamDict->getBool(TheKey_teamIsBaseDefense, &exists); - pCheck->SetCheck(baseDef?1:0); - } - - pCheck = (CButton *) GetDlgItem(IDC_PERIMETER_DEFENSE); - if( pCheck ) - { - Bool perimeter = m_teamDict->getBool(TheKey_teamIsPerimeterDefense, &exists); - pCheck->SetCheck(perimeter?1:0); - } - - pCheck = (CButton *) GetDlgItem(IDC_AVOID_THREATS); - Bool avoid = m_teamDict->getBool(TheKey_teamAvoidThreats, &exists); - pCheck->SetCheck(avoid?1:0); - - pCheck = (CButton *) GetDlgItem(IDC_ATTACK_COMMON_TARGET); - Bool attack = m_teamDict->getBool(TheKey_teamAttackCommonTarget, &exists); - pCheck->SetCheck(attack?1:0); - - AsciiString description; - - CWnd *pWnd = GetDlgItem(IDC_PERCENT_DESTROYED); - Real threshold = m_teamDict->getReal(TheKey_teamDestroyedThreshold, &exists); - if (!exists) threshold = 0.5f; - Int percent = floor((threshold*100)+0.5); - description.format("%d", percent); - pWnd->SetWindowText(description.str()); - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_ENEMY_INTERACTIONS); - pCombo->SetCurSel(m_teamDict->getInt(TheKey_teamAggressiveness, &exists) - ATTITUDE_SLEEP); - - - return FALSE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void TeamBehavior::OnTransportsReturn() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_RETURN); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamTransportsReturn, checked); -} - -void TeamBehavior::OnAvoidThreats() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_AVOID_THREATS); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamAvoidThreats, checked); -} - -void TeamBehavior::OnSelchangeOnEnemySighted() -{ - updateScript(TheKey_teamEnemySightedScript, IDC_ON_ENEMY_SIGHTED); -} - -void TeamBehavior::OnSelchangeOnDestroyed() -{ - updateScript(TheKey_teamOnDestroyedScript, IDC_ON_DESTROYED); -} - -void TeamBehavior::OnSelchangeOnUnitDestroyed() -{ - updateScript(TheKey_teamOnUnitDestroyedScript, IDC_ON_UNIT_DESTROYED_SCRIPT); -} - -void TeamBehavior::OnSelchangeOnCreateScript() -{ - updateScript(TheKey_teamOnCreateScript, IDC_ON_CREATE_SCRIPT); -} - -void TeamBehavior::OnPerimeterDefense() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_PERIMETER_DEFENSE); - if( pCheck ) - { - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamIsPerimeterDefense, checked); - if (checked) { // Can't be both base & perimeter defense. - pCheck = (CButton *) GetDlgItem(IDC_BASE_DEFENSE); - if( pCheck ) - { - pCheck->SetCheck(0); - m_teamDict->setBool(TheKey_teamIsBaseDefense, false); - } - } - } -} - -void TeamBehavior::OnBaseDefense() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_BASE_DEFENSE); - if( pCheck ) - { - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamIsBaseDefense, checked); - if (checked) { // Can't be both base & perimeter defense. - pCheck = (CButton *) GetDlgItem(IDC_PERIMETER_DEFENSE); - if( pCheck ) - { - pCheck->SetCheck(0); - m_teamDict->setBool(TheKey_teamIsPerimeterDefense, false); - } - } - } -} - -void TeamBehavior::OnChangePercentDestroyed() -{ - CWnd *pWnd = GetDlgItem(IDC_PERCENT_DESTROYED); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int percent = atoi(val); - Real value = percent/100.0f; - m_teamDict->setReal(TheKey_teamDestroyedThreshold, value); - } -} - -void TeamBehavior::OnSelchangeEnemyInteractions() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_ENEMY_INTERACTIONS); - Int mode = pCombo->GetCurSel(); - if (mode >= 0) { - m_teamDict->setInt(TheKey_teamAggressiveness, mode + ATTITUDE_SLEEP); - } -} - -void TeamBehavior::OnSelchangeOnAllClear() -{ - updateScript(TheKey_teamAllClearScript, IDC_ON_ALL_CLEAR); -} - -void TeamBehavior::OnSelchangeOnIdleScript() -{ - updateScript(TheKey_teamOnIdleScript, IDC_ON_IDLE_SCRIPT); -} - -void TeamBehavior::OnAttackCommonTarget() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_ATTACK_COMMON_TARGET); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamAttackCommonTarget, checked); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp deleted file mode 100644 index 77f2a89f60d..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamGeneric.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - - -#include "StdAfx.h" -#include "resource.h" - -#include "TeamGeneric.h" -#include "EditParameter.h" -#include "WorldBuilder.h" - -#include "Common/AsciiString.h" -#include "Common/Dict.h" -#include "Common/WellKnownKeys.h" - -static const UINT s_allControls[][2] = -{ - { IDC_SCRIPT_PREFIX1, IDC_TeamGeneric_Script1, }, - { IDC_SCRIPT_PREFIX2, IDC_TeamGeneric_Script2, }, - { IDC_SCRIPT_PREFIX3, IDC_TeamGeneric_Script3, }, - { IDC_SCRIPT_PREFIX4, IDC_TeamGeneric_Script4, }, - { IDC_SCRIPT_PREFIX5, IDC_TeamGeneric_Script5, }, - { IDC_SCRIPT_PREFIX6, IDC_TeamGeneric_Script6, }, - { IDC_SCRIPT_PREFIX7, IDC_TeamGeneric_Script7, }, - { IDC_SCRIPT_PREFIX8, IDC_TeamGeneric_Script8, }, - { IDC_SCRIPT_PREFIX9, IDC_TeamGeneric_Script9, }, - { IDC_SCRIPT_PREFIX10, IDC_TeamGeneric_Script10, }, - { IDC_SCRIPT_PREFIX11, IDC_TeamGeneric_Script11, }, - { IDC_SCRIPT_PREFIX12, IDC_TeamGeneric_Script12, }, - { IDC_SCRIPT_PREFIX13, IDC_TeamGeneric_Script13, }, - { IDC_SCRIPT_PREFIX14, IDC_TeamGeneric_Script14, }, - { IDC_SCRIPT_PREFIX15, IDC_TeamGeneric_Script15, }, - { IDC_SCRIPT_PREFIX16, IDC_TeamGeneric_Script16, }, - { 0,0, }, -}; - -TeamGeneric::TeamGeneric() : CPropertyPage(TeamGeneric::IDD) -{ - -} - -BOOL TeamGeneric::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - // Fill all the combo boxes with the scripts we have. - _fillComboBoxesWithScripts(); - - // Set up the dialog as appropriate. - _dictToScripts(); - - return FALSE; -} - -void TeamGeneric::_fillComboBoxesWithScripts() -{ - int i = 0; - while (s_allControls[i][1]) { - CComboBox *pCombo = (CComboBox*) GetDlgItem(s_allControls[i][1]); - if (!pCombo) { - continue; - } - - // Load all the scripts, then add the NONE string. - EditParameter::loadScripts(pCombo, true); - pCombo->InsertString(0, NONE_STRING); - ++i; - } -} - -void TeamGeneric::_dictToScripts() -{ - CWnd *pText = nullptr; - CComboBox *pCombo = nullptr; - - if (!m_teamDict) { - return; - } - - int i = 0; - while (s_allControls[i][1]) { - - pText = GetDlgItem(s_allControls[i][0]); - if (!pText) { - continue; - } - - pCombo = (CComboBox*) GetDlgItem(s_allControls[i][1]); - if (!pCombo) { - continue; - } - - Bool exists; - AsciiString scriptString; - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_teamGenericScriptHook).str(), i); - scriptString = m_teamDict->getAsciiString(NAMEKEY(keyName), &exists); - - pText->ShowWindow(SW_SHOW); - pCombo->ShowWindow(SW_SHOW); - - if (exists) { - Int selNdx = pCombo->FindStringExact(-1, scriptString.str()); - if (selNdx == LB_ERR) { - pCombo->SetCurSel(0); - } else { - pCombo->SetCurSel(selNdx); - } - } else { - break; - } - - ++i; - } - - if (!s_allControls[i][1]) { - // We filled everything. - return; - } - - if (!pCombo) { - // We filled nothing, or there was an error. - return; - } - - pCombo->SetCurSel(0); - - ++i; - while (s_allControls[i][1]) { - pText = GetDlgItem(s_allControls[i][0]); - if (!pText) { - continue; - } - - pCombo = (CComboBox*) GetDlgItem(s_allControls[i][1]); - if (!pCombo) { - continue; - } - - pText->ShowWindow(SW_HIDE); - pCombo->ShowWindow(SW_HIDE); - ++i; - } -} - -void TeamGeneric::_scriptsToDict() -{ - if (!m_teamDict) { - return; - } - - CWnd *pText = nullptr; - CComboBox *pCombo = nullptr; - - int scriptNum = 0; - - int i = 0; - while (s_allControls[i][1]) { - - pText = GetDlgItem(s_allControls[i][0]); - if (!pText) { - continue; - } - - pCombo = (CComboBox*) GetDlgItem(s_allControls[i][1]); - if (!pCombo) { - continue; - } - - // i should always be incremented, so just do it here. - ++i; - - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_teamGenericScriptHook).str(), scriptNum); - - int curSel = pCombo->GetCurSel(); - if (curSel == CB_ERR || curSel == 0) { - if (m_teamDict->known(NAMEKEY(keyName), Dict::DICT_ASCIISTRING)) { - // remove it if we know it. - m_teamDict->remove(NAMEKEY(keyName)); - } - - continue; - } - - CString cstr; - pCombo->GetLBText(curSel, cstr); - - AsciiString scriptString = static_cast(cstr); - m_teamDict->setAsciiString(NAMEKEY(keyName), scriptString); - ++scriptNum; - } - - for ( ; s_allControls[scriptNum][1]; ++scriptNum ) { - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_teamGenericScriptHook).str(), scriptNum); - - if (m_teamDict->known(NAMEKEY(keyName), Dict::DICT_ASCIISTRING)) { - m_teamDict->remove(NAMEKEY(keyName)); - } - } -} - -void TeamGeneric::OnScriptAdjust() -{ - _scriptsToDict(); - _dictToScripts(); -} - -BEGIN_MESSAGE_MAP(TeamGeneric, CPropertyPage) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script1, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script2, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script3, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script4, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script5, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script6, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script7, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script8, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script9, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script10, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script11, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script12, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script13, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script14, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script15, OnScriptAdjust) - ON_CBN_SELCHANGE(IDC_TeamGeneric_Script16, OnScriptAdjust) -END_MESSAGE_MAP() diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamIdentity.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TeamIdentity.cpp deleted file mode 100644 index e495b235f1b..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamIdentity.cpp +++ /dev/null @@ -1,595 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TeamIdentity.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "TeamIdentity.h" -#include "EditParameter.h" -#include "PickUnitDialog.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/ThingSort.h" -#include "GameLogic/SidesList.h" - -static const char* NEUTRAL_NAME_STR = "(neutral)"; - -///////////////////////////////////////////////////////////////////////////// -// TeamIdentity dialog - - -TeamIdentity::TeamIdentity() - : CPropertyPage(TeamIdentity::IDD) -{ - //{{AFX_DATA_INIT(TeamIdentity) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void TeamIdentity::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TeamIdentity) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(TeamIdentity, CPropertyPage) - //{{AFX_MSG_MAP(TeamIdentity) - ON_BN_CLICKED(IDC_AI_RECRUITABLE, OnAiRecruitable) - ON_BN_CLICKED(IDC_AUTO_REINFORCE, OnAutoReinforce) - ON_EN_CHANGE(IDC_DESCRIPTION, OnChangeDescription) - ON_EN_CHANGE(IDC_MAX, OnChangeMax) - ON_EN_CHANGE(IDC_PRIORITY_DECREASE, OnChangePriorityDecrease) - ON_EN_CHANGE(IDC_PRIORITY_INCREASE, OnChangePriorityIncrease) - ON_CBN_SELCHANGE(IDC_PRODUCTION_CONDITION, OnSelchangeProductionCondition) - ON_EN_CHANGE(IDC_PRODUCTION_PRIORITY, OnChangeProductionPriority) - ON_CBN_SELCHANGE(IDC_HOME_WAYPOINT, OnSelchangeHomeWaypoint) - ON_BN_CLICKED(IDC_UNIT_TYPE1_BUTTON, OnUnitType1Button) - ON_BN_CLICKED(IDC_UNIT_TYPE2_BUTTON, OnUnitType2Button) - ON_BN_CLICKED(IDC_UNIT_TYPE3_BUTTON, OnUnitType3Button) - ON_BN_CLICKED(IDC_UNIT_TYPE4_BUTTON, OnUnitType4Button) - ON_BN_CLICKED(IDC_UNIT_TYPE5_BUTTON, OnUnitType5Button) - ON_BN_CLICKED(IDC_UNIT_TYPE6_BUTTON, OnUnitType6Button) - ON_BN_CLICKED(IDC_UNIT_TYPE7_BUTTON, OnUnitType7Button) - ON_BN_CLICKED(IDC_PRODUCTION_EXECUTEACTIONS, OnExecuteActions) - ON_EN_CHANGE(IDC_TEAM_NAME, OnChangeTeamName) - ON_BN_CLICKED(IDC_TEAM_SINGLETON, OnTeamSingleton) - ON_EN_KILLFOCUS(IDC_TEAM_NAME, OnKillfocusTeamName) - ON_CBN_SELENDOK(IDC_TEAMOWNER, OnSelendokTeamowner) - ON_EN_CHANGE(IDC_TEAM_BUILD_FRAMES, OnChangeTeamBuildFrames) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TeamIdentity message handlers - -BOOL TeamIdentity::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - - loadUnitsInfo(IDC_MIN_UNIT1, TheKey_teamUnitMinCount1, - IDC_MAX_UNIT1, TheKey_teamUnitMaxCount1, - IDC_UNIT_TYPE1, TheKey_teamUnitType1); - - loadUnitsInfo(IDC_MIN_UNIT2, TheKey_teamUnitMinCount2, - IDC_MAX_UNIT2, TheKey_teamUnitMaxCount2, - IDC_UNIT_TYPE2, TheKey_teamUnitType2); - - loadUnitsInfo(IDC_MIN_UNIT3, TheKey_teamUnitMinCount3, - IDC_MAX_UNIT3, TheKey_teamUnitMaxCount3, - IDC_UNIT_TYPE3, TheKey_teamUnitType3); - - loadUnitsInfo(IDC_MIN_UNIT4, TheKey_teamUnitMinCount4, - IDC_MAX_UNIT4, TheKey_teamUnitMaxCount4, - IDC_UNIT_TYPE4, TheKey_teamUnitType4); - - loadUnitsInfo(IDC_MIN_UNIT5, TheKey_teamUnitMinCount5, - IDC_MAX_UNIT5, TheKey_teamUnitMaxCount5, - IDC_UNIT_TYPE5, TheKey_teamUnitType5); - - loadUnitsInfo(IDC_MIN_UNIT6, TheKey_teamUnitMinCount6, - IDC_MAX_UNIT6, TheKey_teamUnitMaxCount6, - IDC_UNIT_TYPE6, TheKey_teamUnitType6); - - loadUnitsInfo(IDC_MIN_UNIT7, TheKey_teamUnitMinCount7, - IDC_MAX_UNIT7, TheKey_teamUnitMaxCount7, - IDC_UNIT_TYPE7, TheKey_teamUnitType7); - - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_HOME_WAYPOINT); - Bool exists; - EditParameter::loadWaypoints(pCombo); - AsciiString homeWaypoint = m_teamDict->getAsciiString(TheKey_teamHome, &exists); - Int stringNdx = pCombo->AddString(NONE_STRING); - if (exists) { - Int ndx = pCombo->FindStringExact(-1, homeWaypoint.str()); - if (ndx != CB_ERR) { - stringNdx = ndx; - } - } - pCombo->SetCurSel(stringNdx); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_TEAMOWNER); - owner->ResetContent(); - for (Int i = 0; i < TheSidesList->getNumSides(); i++) - { - AsciiString name = TheSidesList->getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - if (name.isEmpty()) - name = NEUTRAL_NAME_STR; - owner->AddString(name.str()); - } - - // must re-find, since list is sorted - AsciiString cur_oname = m_teamDict->getAsciiString(TheKey_teamOwner); - Int myPlayerIndex = -1; - TheSidesList->findSideInfo(cur_oname, &myPlayerIndex); - AsciiString oname_ui = TheSidesList->getSideInfo(myPlayerIndex)->getDict()->getAsciiString(TheKey_playerName); - int oindex_in_list = owner->FindStringExact(-1, oname_ui.str()); - DEBUG_ASSERTCRASH(oindex_in_list >= 0, ("hmm")); - owner->SetCurSel(oindex_in_list); - - CButton *pCheck = (CButton *) GetDlgItem(IDC_AUTO_REINFORCE); - Bool autoReinf = m_teamDict->getBool(TheKey_teamAutoReinforce, &exists); - pCheck->SetCheck(autoReinf?1:0); - - pCheck = (CButton*)GetDlgItem(IDC_TEAM_SINGLETON); - Bool singleton = m_teamDict->getBool(TheKey_teamIsSingleton, &exists); - pCheck->SetCheck(singleton?1:0); - - pCheck = (CButton *) GetDlgItem(IDC_AI_RECRUITABLE); - - Bool aiRecruit = m_teamDict->getBool(TheKey_teamIsAIRecruitable, &exists); - pCheck->SetCheck(aiRecruit?1:0); - - CWnd *pWnd = GetDlgItem(IDC_DESCRIPTION); - AsciiString description = m_teamDict->getAsciiString(TheKey_teamDescription, &exists); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_TEAM_NAME); - description = m_teamDict->getAsciiString(TheKey_teamName, &exists); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_MAX); - Int maxInstances = m_teamDict->getInt(TheKey_teamMaxInstances, &exists); - if (!exists) maxInstances = 1; - description.format("%d", maxInstances); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_PRODUCTION_PRIORITY); - Int priority = m_teamDict->getInt(TheKey_teamProductionPriority, &exists); - description.format("%d", priority); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_PRIORITY_INCREASE); - Int increase = m_teamDict->getInt(TheKey_teamProductionPrioritySuccessIncrease, &exists); - description.format("%d", increase); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_PRIORITY_DECREASE); - Int decrease = m_teamDict->getInt(TheKey_teamProductionPriorityFailureDecrease, &exists); - description.format("%d", decrease); - pWnd->SetWindowText(description.str()); - - pWnd = GetDlgItem(IDC_TEAM_BUILD_FRAMES); - Int idleFrames = m_teamDict->getInt(TheKey_teamInitialIdleFrames, &exists); - description.format("%d", idleFrames); - pWnd->SetWindowText(description.str()); - - pCombo = (CComboBox*)GetDlgItem(IDC_PRODUCTION_CONDITION); - // Load the subroutine scripts into the combo box. - EditParameter::loadScripts(pCombo, true); - stringNdx = pCombo->AddString(NONE_STRING); - pCombo->SetFocus(); - AsciiString script = m_teamDict->getAsciiString(TheKey_teamProductionCondition, &exists); - if (exists) { - Int ndx = pCombo->FindStringExact(-1, script.str()); - if (ndx != CB_ERR) { - stringNdx = ndx; - } - } - pCombo->SetCurSel(stringNdx); - - CButton *pButton = (CButton*) GetDlgItem(IDC_PRODUCTION_EXECUTEACTIONS); - if (pButton) { - Bool executeActions = m_teamDict->getBool(TheKey_teamExecutesActionsOnCreate, &exists); - if (!exists) { - m_teamDict->setBool(TheKey_teamExecutesActionsOnCreate, false); - executeActions = false; - } - pButton->SetCheck(executeActions ? 1 : 0); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void TeamIdentity::loadUnitsInfo(int idcMinUnit, NameKeyType keyMinUnit, - int idcMaxUnit, NameKeyType keyMaxUnit, - int idcUnitType, NameKeyType keyUnitType) -{ - CEdit *pEdit = (CEdit *)GetDlgItem(idcMinUnit); - CString text; - Bool exists; - text.Format("%d", m_teamDict->getInt(keyMinUnit, &exists)); - pEdit->SetWindowText(text); - - pEdit = (CEdit *)GetDlgItem(idcMaxUnit); - text.Format("%d", m_teamDict->getInt(keyMaxUnit, &exists)); - pEdit->SetWindowText(text); - - AsciiString type = m_teamDict->getAsciiString(keyUnitType, &exists); - if (type.isEmpty()) type = NONE_STRING; - - CComboBox *pCombo = (CComboBox *)GetDlgItem(idcUnitType); - pCombo->ResetContent(); - - Bool found = false; - - // add entries from the thing factory as the available UNITS to use - const ThingTemplate *tTemplate; - for( tTemplate = TheThingFactory->firstTemplate(); - tTemplate; - tTemplate = tTemplate->friend_getNextTemplate() ) { - - // next tier uses the editor sorting bits that design can specify in the INI - EditorSortingType sort = tTemplate->getEditorSorting(); - // TheSuperHackers @tweak DayV 20/07/2025 Allow structures in teams. - if (sort != ES_VEHICLE && sort != ES_INFANTRY && sort != ES_STRUCTURE) { - continue; - } - - Int ndx = pCombo->AddString(tTemplate->getName().str()); - if (type == tTemplate->getName()) { - found = true; - pCombo->SetCurSel(ndx); - } - } - - Int ndx = pCombo->AddString(NONE_STRING); - if (!found) { - pCombo->SetCurSel(ndx); - } - -} - - -BOOL TeamIdentity::OnCommand(WPARAM wParam, LPARAM lParam) -{ - - Int wNotifyCode = HIWORD(wParam); // notification code - Int wID = LOWORD(wParam); // item, control, or accelerator identifier - NameKeyType key; - if (wNotifyCode == EN_CHANGE) { - Int editCtrl = wID; - switch (editCtrl) { - default: editCtrl = 0; - case IDC_MIN_UNIT1: key = TheKey_teamUnitMinCount1; break; - case IDC_MAX_UNIT1: key = TheKey_teamUnitMaxCount1; break; - - case IDC_MIN_UNIT2: key = TheKey_teamUnitMinCount2; break; - case IDC_MAX_UNIT2: key = TheKey_teamUnitMaxCount2; break; - - case IDC_MIN_UNIT3: key = TheKey_teamUnitMinCount3; break; - case IDC_MAX_UNIT3: key = TheKey_teamUnitMaxCount3; break; - - case IDC_MIN_UNIT4: key = TheKey_teamUnitMinCount4; break; - case IDC_MAX_UNIT4: key = TheKey_teamUnitMaxCount4; break; - - case IDC_MIN_UNIT5: key = TheKey_teamUnitMinCount5; break; - case IDC_MAX_UNIT5: key = TheKey_teamUnitMaxCount5; break; - - case IDC_MIN_UNIT6: key = TheKey_teamUnitMinCount6; break; - case IDC_MAX_UNIT6: key = TheKey_teamUnitMaxCount6; break; - - case IDC_MIN_UNIT7: key = TheKey_teamUnitMinCount7; break; - case IDC_MAX_UNIT7: key = TheKey_teamUnitMaxCount7; break; - } - if (editCtrl != 0) { - CEdit *pEdit = (CEdit *)GetDlgItem(editCtrl); - CString txt; - pEdit->GetWindowText(txt); - Int theInt; - if (1==sscanf(txt, "%d", &theInt)) { - m_teamDict->setInt(key, theInt); - } - return true; - } - } else if (wNotifyCode == CBN_SELCHANGE) { - Int cmboCtrl = wID; - switch (cmboCtrl) { - case IDC_UNIT_TYPE1: key = TheKey_teamUnitType1; break; - case IDC_UNIT_TYPE2: key = TheKey_teamUnitType2; break; - case IDC_UNIT_TYPE3: key = TheKey_teamUnitType3; break; - case IDC_UNIT_TYPE4: key = TheKey_teamUnitType4; break; - case IDC_UNIT_TYPE5: key = TheKey_teamUnitType5; break; - case IDC_UNIT_TYPE6: key = TheKey_teamUnitType6; break; - case IDC_UNIT_TYPE7: key = TheKey_teamUnitType7; break; - default: cmboCtrl = 0; - } - if (cmboCtrl != 0) { - CComboBox *pCombo = (CComboBox*)GetDlgItem(cmboCtrl); - CString txt; - pCombo->GetWindowText(txt); - AsciiString comboText = AsciiString(txt); - m_teamDict->setAsciiString(key, comboText); - return true; - } - } - - return CPropertyPage::OnCommand(wParam, lParam); -} - -void TeamIdentity::OnAiRecruitable() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_AI_RECRUITABLE); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamIsAIRecruitable, checked); -} - -void TeamIdentity::OnAutoReinforce() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_AUTO_REINFORCE); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamAutoReinforce, checked); -} - - -void TeamIdentity::OnChangeDescription() -{ - CWnd *pWnd = GetDlgItem(IDC_DESCRIPTION); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - AsciiString des = static_cast(val); - m_teamDict->setAsciiString(TheKey_teamDescription, des); - } -} - -void TeamIdentity::OnChangeMax() -{ - CWnd *pWnd = GetDlgItem(IDC_MAX); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int maxInstances = atoi(val); - m_teamDict->setInt(TheKey_teamMaxInstances, maxInstances); - } -} - -void TeamIdentity::OnChangePriorityDecrease() -{ - CWnd *pWnd = GetDlgItem(IDC_PRIORITY_DECREASE); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int decrease = atoi(val); - m_teamDict->setInt(TheKey_teamProductionPriorityFailureDecrease, decrease); - } -} - -void TeamIdentity::OnChangePriorityIncrease() -{ - CWnd *pWnd = GetDlgItem(IDC_PRIORITY_INCREASE); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int increase = atoi(val); - m_teamDict->setInt(TheKey_teamProductionPrioritySuccessIncrease, increase); - } -} - -void TeamIdentity::OnSelchangeProductionCondition() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_PRODUCTION_CONDITION); - CString txt; - Int curSel = pCombo->GetCurSel(); - pCombo->GetLBText(curSel, txt); - AsciiString comboText = AsciiString(txt); - if (comboText == NONE_STRING) { - comboText.clear(); - } - m_teamDict->setAsciiString(TheKey_teamProductionCondition, comboText); -} - -void TeamIdentity::OnChangeProductionPriority() -{ - CWnd *pWnd = GetDlgItem(IDC_PRODUCTION_PRIORITY); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int priority = atoi(val); - m_teamDict->setInt(TheKey_teamProductionPriority, priority); - } -} - -void TeamIdentity::OnSelchangeHomeWaypoint() -{ - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_HOME_WAYPOINT); - CString txt; - Int curSel = pCombo->GetCurSel(); - pCombo->GetLBText(curSel, txt); - AsciiString comboText = AsciiString(txt); - if (comboText == NONE_STRING) { - comboText.clear(); - } - m_teamDict->setAsciiString(TheKey_teamHome, comboText); -} - -void TeamIdentity::OnUnitTypeButton(Int idcUnitType) -{ - PickUnitDialog dlg; - dlg.SetAllowableType(ES_VEHICLE); - dlg.SetAllowableType(ES_INFANTRY); - // TheSuperHackers @tweak DayV 20/07/2025 Allow structures in teams. - dlg.SetAllowableType(ES_STRUCTURE); - if (dlg.DoModal() == IDOK) { - AsciiString unit = dlg.getPickedUnit(); - NameKeyType keyUnitType; - - switch (idcUnitType) - { - case IDC_UNIT_TYPE1: - keyUnitType = TheKey_teamUnitType1; - break; - case IDC_UNIT_TYPE2: - keyUnitType = TheKey_teamUnitType2; - break; - case IDC_UNIT_TYPE3: - keyUnitType = TheKey_teamUnitType3; - break; - case IDC_UNIT_TYPE4: - keyUnitType = TheKey_teamUnitType4; - break; - case IDC_UNIT_TYPE5: - keyUnitType = TheKey_teamUnitType5; - break; - case IDC_UNIT_TYPE6: - keyUnitType = TheKey_teamUnitType6; - break; - case IDC_UNIT_TYPE7: - keyUnitType = TheKey_teamUnitType7; - break; - } - m_teamDict->setAsciiString(keyUnitType, unit); - CComboBox *pCombo = (CComboBox *)GetDlgItem(idcUnitType); - pCombo->SelectString(-1, unit.str()); - } - -} - -void TeamIdentity::OnUnitType1Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE1); -} - -void TeamIdentity::OnUnitType2Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE2); -} - -void TeamIdentity::OnUnitType3Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE3); -} - -void TeamIdentity::OnUnitType4Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE4); -} - -void TeamIdentity::OnUnitType5Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE5); -} - -void TeamIdentity::OnUnitType6Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE6); -} - -void TeamIdentity::OnUnitType7Button() -{ - OnUnitTypeButton(IDC_UNIT_TYPE7); -} - -void TeamIdentity::OnExecuteActions() -{ - CButton *pButton = (CButton*) GetDlgItem(IDC_PRODUCTION_EXECUTEACTIONS); - if (!pButton) { - return; - } - - m_teamDict->setBool(TheKey_teamExecutesActionsOnCreate, pButton->GetCheck() ? true : false); -} - -void TeamIdentity::OnChangeTeamName() -{ - -} - -void TeamIdentity::OnTeamSingleton() -{ - CButton *singleton = (CButton*)GetDlgItem(IDC_TEAM_SINGLETON); - m_teamDict->setBool(TheKey_teamIsSingleton, singleton->GetCheck() != 0); -} - -void TeamIdentity::OnKillfocusTeamName() -{ - CWnd *pWnd = GetDlgItem(IDC_TEAM_NAME); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - AsciiString tnamenew = static_cast(val); - AsciiString tnamecur = m_teamDict->getAsciiString(TheKey_teamName); - Bool set = true; - if (tnamecur != tnamenew) { - if (m_sides->findTeamInfo(tnamenew) || m_sides->findSideInfo(tnamenew)) - { - ::AfxMessageBox(IDS_NAME_IN_USE); - set = false; - } - else - { - Int count = MapObject::countMapObjectsWithOwner(tnamecur); - if (count > 0) - { - set = false; - CString msg; - msg.Format(IDS_RENAMING_INUSE_TEAM, count); - if (::AfxMessageBox(msg, MB_YESNO) == IDYES) - set = true; - } - } - } - if (set) { - m_teamDict->setAsciiString(TheKey_teamName, tnamenew); - } else { - Bool exists; - AsciiString description = m_teamDict->getAsciiString(TheKey_teamName, &exists); - pWnd->SetWindowText(description.str()); - } - } -} - -void TeamIdentity::OnSelendokTeamowner() -{ - CWnd *pWnd = GetDlgItem(IDC_TEAMOWNER); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - AsciiString des = static_cast(val); - m_teamDict->setAsciiString(TheKey_teamOwner, des); - } -} - -void TeamIdentity::OnChangeTeamBuildFrames() -{ - CWnd *pWnd = GetDlgItem(IDC_TEAM_BUILD_FRAMES); - if (pWnd) { - CString val; - pWnd->GetWindowText(val); - Int idleFrames = atoi(val); - m_teamDict->setInt(TheKey_teamInitialIdleFrames, idleFrames); - } - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp deleted file mode 100644 index cb8df0b90a3..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamObjectProperties.cpp +++ /dev/null @@ -1,684 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TeamObjectProperties.cpp -// Mike Lytle -// January, 2003 -// (c) Electronic Arts 2003 - -#include "StdAfx.h" -#include "TeamObjectProperties.h" -#include "Common/MapObject.h" -#include "Common/WellKnownKeys.h" - - -///////////////////////////////////////////////////////////////////////////// -// TeamObjectProperties dialog - -TeamObjectProperties::TeamObjectProperties(Dict* dictToEdit) - : CPropertyPage(TeamObjectProperties::IDD), - m_dictToEdit(dictToEdit) -{ - //{{AFX_DATA_INIT(TeamObjectProperties) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -TeamObjectProperties::~TeamObjectProperties() -{ -} - -void TeamObjectProperties::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TeamObjectProperties) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -#if 0 -BEGIN_MESSAGE_MAP(TeamObjectProperties, CPropertyPage) - //{{AFX_MSG_MAP(TeamObjectProperties) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_StartingHealth, _HealthToDict) - ON_CBN_SELENDOK(IDC_MAPOBJECT_HitPoints, _HPsToDict) - ON_CBN_KILLFOCUS(IDC_MAPOBJECT_HitPoints, _HPsToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Enabled, _EnabledToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Indestructible, _IndestructibleToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Unsellable, _UnsellableToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Powered, _PoweredToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Aggressiveness, _AggressivenessToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_VisionDistance, _VisibilityToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_ShroudClearingDistance, _ShroudClearingDistanceToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Veterancy, _VeterancyToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_RecruitableAI, _RecruitableAIToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Selectable, _SelectableToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Weather, _WeatherToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Time, _TimeToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_StoppingDistance, _StoppingDistanceToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_StartingHealthEdit, _HealthToDict) - ON_BN_CLICKED(IDC_UPDATE_TEAM_MEMBERS, _UpdateTeamMembers) - - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TeamObjectProperties message handlers - -BOOL TeamObjectProperties::OnInitDialog() -{ - CDialog::OnInitDialog(); - updateTheUI(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void TeamObjectProperties::OnOK() -{ - _PropertiesToDict(); -} - -void TeamObjectProperties::updateTheUI() -{ - _DictToHealth(); - _DictToHPs(); - _DictToEnabled(); - _DictToDestructible(); - _DictToPowered(); - _DictToUnsellable(); - _DictToAggressiveness(); - _DictToVisibilityRange(); - _DictToVeterancy(); - _DictToWeather(); - _DictToTime(); - _DictToShroudClearingDistance(); - _DictToRecruitableAI(); - _DictToSelectable(); - _DictToStoppingDistance(); -} - -void TeamObjectProperties::_DictToHealth() -{ - Int value = 100; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectInitialHealth, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_StartingHealth); - CWnd* pItem2 = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - if (pItem && pItem2) { - if (value == 0) { - pItem->SelectString(-1, "0%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 25) { - pItem->SelectString(-1, "25%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 50) { - pItem->SelectString(-1, "50%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 75) { - pItem->SelectString(-1, "75%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 100) { - pItem->SelectString(-1, "100%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else { - pItem->SelectString(-1, "Other"); - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", value); - pItem2->SetWindowText(buff); - pItem2->EnableWindow(TRUE); - } - } -} - -void TeamObjectProperties::_DictToHPs() -{ - Int value = -1; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectMaxHPs, &exists); - if (!exists) - value = -1; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_HitPoints); - pItem->ResetContent(); - CString str; - str.Format("Default For Unit"); - pItem->InsertString(-1, str); - - if (value != -1) { - str.Format("%d", value); - pItem->InsertString(-1, str); - pItem->SetCurSel(1); - } else { - pItem->SetCurSel(0); - } -} - -void TeamObjectProperties::_DictToEnabled() -{ - Bool enabled = true; - Bool exists; - if (m_dictToEdit) { - enabled = m_dictToEdit->getBool(TheKey_teamObjectEnabled, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Enabled); - if (pItem) { - pItem->SetCheck(enabled); - } -} - -void TeamObjectProperties::_DictToDestructible() -{ - Bool destructible = true; - Bool exists; - if (m_dictToEdit) { - destructible = m_dictToEdit->getBool(TheKey_teamObjectIndestructible, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Indestructible); - if (pItem) { - pItem->SetCheck(destructible); - } -} - -void TeamObjectProperties::_DictToUnsellable() -{ - Bool unsellable = false; - Bool exists; - if (m_dictToEdit) { - unsellable = m_dictToEdit->getBool(TheKey_teamObjectUnsellable, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - if (pItem) { - pItem->SetCheck(unsellable); - } -} - -void TeamObjectProperties::_DictToPowered() -{ - Bool powered = true; - Bool exists; - if (m_dictToEdit) { - powered = m_dictToEdit->getBool(TheKey_teamObjectPowered, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Powered); - if (pItem) { - pItem->SetCheck(powered); - } - -} - -void TeamObjectProperties::_DictToAggressiveness() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectAggressiveness, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Aggressiveness); - if (pItem) { - if (value == -2) { - pItem->SelectString(-1, "Sleep"); - } else if (value == -1) { - pItem->SelectString(-1, "Passive"); - } else if (value == 0) { - pItem->SelectString(-1, "Normal"); - } else if (value == 1) { - pItem->SelectString(-1, "Alert"); - } else if (value == 2) { - pItem->SelectString(-1, "Aggressive"); - } - } -} - -void TeamObjectProperties::_DictToVisibilityRange() -{ - Int distance = 0; - Bool exists; - if (m_dictToEdit) { - distance = m_dictToEdit->getInt(TheKey_teamObjectVisualRange, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_VisionDistance); - if (pItem) { - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", distance); - if (distance == 0) { - pItem->SetWindowText(""); - } else { - pItem->SetWindowText(buff); - } - } -} - -void TeamObjectProperties::_DictToVeterancy() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectVeterancy, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Veterancy); - if (pItem) { - pItem->SetCurSel(value); - } -} - -void TeamObjectProperties::_DictToWeather() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectWeather, &exists); - if (!exists) - value = 0; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Weather); - pItem->SetCurSel(value); -} - -void TeamObjectProperties::_DictToTime() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_teamObjectTime, &exists); - if (!exists) - value = 0; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Time); - pItem->SetCurSel(value); -} - -void TeamObjectProperties::_DictToShroudClearingDistance() -{ - Int distance = 0; - Bool exists; - if (m_dictToEdit) { - distance = m_dictToEdit->getInt(TheKey_teamObjectShroudClearingDistance, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_ShroudClearingDistance); - if (pItem) { - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", distance); - if (distance == 0) { - pItem->SetWindowText(""); - } else { - pItem->SetWindowText(buff); - } - } -} - -void TeamObjectProperties::_DictToRecruitableAI() -{ - Bool recruitableAI = true; - Bool exists; - if (m_dictToEdit) { - recruitableAI = m_dictToEdit->getBool(TheKey_teamObjectRecruitableAI, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_RecruitableAI); - if (pItem) { - pItem->SetCheck(recruitableAI); - } -} - -void TeamObjectProperties::_DictToSelectable() -{ - Bool selectable = true; - Bool exists; - if (m_dictToEdit) { - selectable = m_dictToEdit->getBool(TheKey_teamObjectSelectable, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Selectable); - if (pItem) { - pItem->SetCheck(selectable); - } -} - -void TeamObjectProperties::_DictToStoppingDistance() -{ - Real stoppingDistance = 1.0f; - Bool exists = false; - if (m_dictToEdit) { - stoppingDistance = m_dictToEdit->getReal(TheKey_teamObjectStoppingDistance, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_StoppingDistance); - if (pItem) { - static char buff[64]; - sprintf(buff, ARRAY_SIZE(buff), "%g", stoppingDistance); - if (stoppingDistance == 0) { - pItem->SetWindowText(""); - } else { - pItem->SetWindowText(buff); - } - } -} - -void TeamObjectProperties::_HealthToDict() -{ - Int value; - static char buf[1024]; - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_StartingHealth); - owner->GetWindowText(buf, sizeof(buf)-2); - if (strcmp(buf, "Dead") == 0) { - value = 0; - } else if (strcmp(buf, "25%") == 0) { - value = 25; - } else if (strcmp(buf, "50%") == 0) { - value = 50; - } else if (strcmp(buf, "75%") == 0) { - value = 75; - } else if (strcmp(buf, "100%") == 0) { - value = 100; - } else if (strcmp(buf, "Other") == 0) { - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (cstr.IsEmpty()) { - return; - } - value = atoi(cstr.GetBuffer(0)); - } - - m_dictToEdit->setInt(TheKey_teamObjectInitialHealth, value); -} - -void TeamObjectProperties::_EnabledToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Enabled); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectEnabled, isChecked); -} - - -void TeamObjectProperties::_IndestructibleToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Indestructible); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectIndestructible, isChecked); -} - -void TeamObjectProperties::_UnsellableToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectUnsellable, isChecked); -} - -void TeamObjectProperties::_PoweredToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Powered); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectPowered, isChecked); -} - -void TeamObjectProperties::_AggressivenessToDict() -{ - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Aggressiveness); - static char buf[1024]; - owner->GetWindowText(buf, sizeof(buf)-2); - int value = 0; - - if (strcmp(buf, "Sleep") == 0) { - value = -2; - } else if (strcmp(buf, "Passive") == 0) { - value = -1; - } else if (strcmp(buf, "Normal") == 0) { - value = 0; - } else if (strcmp(buf, "Alert") == 0) { - value = 1; - } else if (strcmp(buf, "Aggressive") == 0) { - value = 2; - } - - m_dictToEdit->setInt(TheKey_teamObjectAggressiveness, value); -} - -void TeamObjectProperties::_VisibilityToDict() -{ - int value = -1; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_VisionDistance); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atoi(cstr.GetBuffer(0)); - } - - if (value != -1) { - m_dictToEdit->setInt(TheKey_teamObjectVisualRange, value); - } -} - -void TeamObjectProperties::_VeterancyToDict() -{ - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Veterancy); - static char buf[1024]; - int curSel = owner->GetCurSel(); - int value = 0; - if (curSel >= 0) { - value=curSel; - } - - m_dictToEdit->setInt(TheKey_teamObjectVeterancy, value); -} - -void TeamObjectProperties::_WeatherToDict() -{ - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Weather); - static char buf[1024]; - int curSel = owner->GetCurSel(); - - m_dictToEdit->setInt(TheKey_teamObjectWeather, curSel); -} - -void TeamObjectProperties::_TimeToDict() -{ - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Time); - static char buf[1024]; - int curSel = owner->GetCurSel(); - - m_dictToEdit->setInt(TheKey_teamObjectTime, curSel); -} - -void TeamObjectProperties::_ShroudClearingDistanceToDict() -{ - int value = -1; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_ShroudClearingDistance); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atoi(cstr.GetBuffer(0)); - } - - if (value != -1) { - m_dictToEdit->setInt(TheKey_teamObjectShroudClearingDistance, value); - } -} - -void TeamObjectProperties::_RecruitableAIToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_RecruitableAI); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectRecruitableAI, isChecked); -} - -void TeamObjectProperties::_SelectableToDict() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Selectable); - Bool isChecked = (owner->GetCheck() != 0); - - m_dictToEdit->setBool(TheKey_teamObjectSelectable, isChecked); -} - -void TeamObjectProperties::_HPsToDict() -{ - Int value; - static char buf[1024]; - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_HitPoints); - owner->GetWindowText(buf, sizeof(buf)-2); - value = atoi(buf); - if (value == 0) - value = -1; - - m_dictToEdit->setInt(TheKey_teamObjectMaxHPs, value); -} - -void TeamObjectProperties::_StoppingDistanceToDict() -{ - Real value; - static char buf[1024]; - - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_StoppingDistance); - CString cstr; - edit->GetWindowText(cstr); - if (cstr.IsEmpty()) { - return; - } - value = atof(cstr.GetBuffer(0)); - - m_dictToEdit->setReal(TheKey_teamObjectStoppingDistance, value); -} - -void TeamObjectProperties::_UpdateTeamMembers() -{ - CString msg; - msg.Format("Are you sure you want to change the team members?"); - if (::AfxMessageBox(msg, MB_YESNO) == IDNO) { - return; - } - - AsciiString teamName = m_dictToEdit->getAsciiString(TheKey_teamName); - - MapObject *pObj; - for (pObj=MapObject::getFirstMapObject(); pObj; pObj=pObj->getNext()) { - Dict* objectDict = pObj->getProperties(); - DEBUG_ASSERTCRASH(objectDict, ("objectDict shouldn't be null")); - - AsciiString objectsTeam = objectDict->getAsciiString(TheKey_originalOwner); - - if (teamName == objectsTeam) { - DEBUG_ASSERTCRASH(m_dictToEdit, ("m_dictToEdit shouldn't be null")); - Bool exists; - - Int value = m_dictToEdit->getInt(TheKey_teamObjectInitialHealth, &exists); - objectDict->setInt(TheKey_objectInitialHealth, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectMaxHPs, &exists); - objectDict->setInt(TheKey_objectMaxHPs, value); - - Bool enabled = m_dictToEdit->getBool(TheKey_teamObjectEnabled, &exists); - objectDict->setBool(TheKey_objectEnabled, enabled); - - enabled = m_dictToEdit->getBool(TheKey_teamObjectIndestructible, &exists); - objectDict->setBool(TheKey_objectIndestructible, enabled); - - enabled = m_dictToEdit->getBool(TheKey_teamObjectUnsellable, &exists); - objectDict->setBool(TheKey_objectUnsellable, enabled); - - enabled = m_dictToEdit->getBool(TheKey_teamObjectPowered, &exists); - objectDict->setBool(TheKey_objectPowered, enabled); - - value = m_dictToEdit->getInt(TheKey_teamObjectAggressiveness, &exists); - objectDict->setInt(TheKey_objectAggressiveness, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectVisualRange, &exists); - objectDict->setInt(TheKey_objectVisualRange, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectVeterancy, &exists); - objectDict->setInt(TheKey_objectVeterancy, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectWeather, &exists); - objectDict->setInt(TheKey_objectWeather, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectTime, &exists); - objectDict->setInt(TheKey_objectTime, value); - - value = m_dictToEdit->getInt(TheKey_teamObjectShroudClearingDistance, &exists); - objectDict->setInt(TheKey_objectShroudClearingDistance, value); - - enabled = m_dictToEdit->getBool(TheKey_teamObjectRecruitableAI, &exists); - objectDict->setBool(TheKey_objectRecruitableAI, enabled); - - enabled = m_dictToEdit->getBool(TheKey_teamObjectSelectable, &exists); - objectDict->setBool(TheKey_objectSelectable, enabled); - - Real dist = m_dictToEdit->getReal(TheKey_teamObjectStoppingDistance, &exists); - objectDict->setReal(TheKey_objectStoppingDistance, dist); - - } - } -} - - -void TeamObjectProperties::_PropertiesToDict() -{ - // Make sure that the attributes are in the dictionary. - _HealthToDict(); - _HPsToDict(); - _EnabledToDict(); - _IndestructibleToDict(); - _UnsellableToDict(); - _PoweredToDict(); - _AggressivenessToDict(); - _VisibilityToDict(); - _ShroudClearingDistanceToDict(); - _VeterancyToDict(); - _RecruitableAIToDict(); - _SelectableToDict(); - _WeatherToDict(); - _TimeToDict(); - _StoppingDistanceToDict(); - _HealthToDict(); -} - -#endif - -BOOL TeamObjectProperties::OnCommand(WPARAM wParam, LPARAM lParam) -{ - return CPropertyPage::OnCommand(wParam, lParam); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp deleted file mode 100644 index ac5045b099a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TeamReinforcement.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TeamReinforcement.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "TeamReinforcement.h" -#include "EditParameter.h" -#include "Common/WellKnownKeys.h" - -///////////////////////////////////////////////////////////////////////////// -// TeamReinforcement dialog - - -TeamReinforcement::TeamReinforcement() - : CPropertyPage(TeamReinforcement::IDD) , - m_teamDict(nullptr) -{ - //{{AFX_DATA_INIT(TeamReinforcement) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void TeamReinforcement::DoDataExchange(CDataExchange* pDX) -{ - CPropertyPage::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TeamReinforcement) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(TeamReinforcement, CPropertyPage) - //{{AFX_MSG_MAP(TeamReinforcement) - ON_BN_CLICKED(IDC_DEPLOY_BY, OnDeployBy) - ON_BN_CLICKED(IDC_TEAM_STARTS_FULL, OnTeamStartsFull) - ON_CBN_SELCHANGE(IDC_TRANSPORT_COMBO, OnSelchangeTransportCombo) - ON_BN_CLICKED(IDC_TRANSPORTS_EXIT, OnTransportsExit) - ON_CBN_SELCHANGE(IDC_VETERANCY, OnSelchangeVeterancy) - ON_CBN_SELCHANGE(IDC_WAYPOINT_COMBO, OnSelchangeWaypointCombo) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TeamReinforcement message handlers - -BOOL TeamReinforcement::OnInitDialog() -{ - CPropertyPage::OnInitDialog(); - Bool exists; - - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_TRANSPORT_COMBO); - EditParameter::loadTransports(pCombo); - AsciiString transport = m_teamDict->getAsciiString(TheKey_teamTransport, &exists); - Int stringNdx = pCombo->AddString(NONE_STRING); - Int noneNdx = stringNdx; - if (exists && !transport.isEmpty()) { - Int ndx = pCombo->FindStringExact(-1, transport.str()); - if (ndx != CB_ERR) { - stringNdx = ndx; - } - } - pCombo->SetCurSel(stringNdx); - - CButton *pCheck = (CButton *) GetDlgItem(IDC_TEAM_STARTS_FULL); - Bool teamStartsFull = m_teamDict->getBool(TheKey_teamStartsFull, &exists); - pCheck->SetCheck(teamStartsFull?1:0); - - pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_EXIT); - Bool transportsExit = m_teamDict->getBool(TheKey_teamTransportsExit, &exists); - pCheck->SetCheck(transportsExit?1:0); - Bool enable = !(stringNdx==noneNdx); - pCheck->EnableWindow(enable); - pCombo->EnableWindow(enable); - - pCheck = (CButton *) GetDlgItem(IDC_DEPLOY_BY); - pCheck->SetCheck( (stringNdx==noneNdx)?0:1); - - pCombo = (CComboBox *)GetDlgItem(IDC_VETERANCY); - Int value = m_teamDict->getInt(TheKey_teamVeterancy, &exists); - pCombo->SetCurSel(value); - - pCombo = (CComboBox *)GetDlgItem(IDC_WAYPOINT_COMBO); - EditParameter::loadWaypoints(pCombo); - AsciiString homeWaypoint = m_teamDict->getAsciiString(TheKey_teamReinforcementOrigin, &exists); - stringNdx = pCombo->AddString(NONE_STRING); - if (exists) { - Int ndx = pCombo->FindStringExact(-1, homeWaypoint.str()); - if (ndx != CB_ERR) { - stringNdx = ndx; - } - } - pCombo->SetCurSel(stringNdx); - - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void TeamReinforcement::OnDeployBy() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_DEPLOY_BY); - if (pCheck->GetCheck()) { - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_TRANSPORT_COMBO); - pCombo->SetCurSel(0); - pCombo->EnableWindow(); - pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_EXIT); - pCheck->EnableWindow(); - } else { - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_TRANSPORT_COMBO); - pCombo->SetCurSel(-1); - pCombo->EnableWindow(false); - pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_EXIT); - pCheck->EnableWindow(false); - m_teamDict->setAsciiString(TheKey_teamTransport, AsciiString::TheEmptyString); - } -} - -void TeamReinforcement::OnTeamStartsFull() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_TEAM_STARTS_FULL); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamStartsFull, checked); -} - -void TeamReinforcement::OnSelchangeTransportCombo() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_TRANSPORT_COMBO); - CString txt; - Int curSel = pCombo->GetCurSel(); - pCombo->GetLBText(curSel, txt); - AsciiString comboText = AsciiString(txt); - if (comboText == NONE_STRING) { - comboText.clear(); - } - m_teamDict->setAsciiString(TheKey_teamTransport, comboText); -} - -void TeamReinforcement::OnTransportsExit() -{ - CButton *pCheck = (CButton *) GetDlgItem(IDC_TRANSPORTS_EXIT); - Bool checked = pCheck->GetCheck()==1; - m_teamDict->setBool(TheKey_teamTransportsExit, checked); -} - -void TeamReinforcement::OnSelchangeVeterancy() -{ - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_VETERANCY); - static char buf[1024]; - int curSel = owner->GetCurSel(); - int value = 0; - if (curSel >= 0) { - value=curSel; - } - m_teamDict->setInt(TheKey_teamVeterancy, value); -} - -void TeamReinforcement::OnSelchangeWaypointCombo() -{ - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_WAYPOINT_COMBO); - CString txt; - Int curSel = pCombo->GetCurSel(); - if (curSel >= 0) { - pCombo->GetLBText(curSel, txt); - } - AsciiString comboText = AsciiString(txt); - if (comboText == NONE_STRING) { - comboText.clear(); - } - m_teamDict->setAsciiString(TheKey_teamReinforcementOrigin, comboText); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp deleted file mode 100644 index 92e828d7138..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainMaterial.cpp +++ /dev/null @@ -1,554 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TerrainMaterial.cpp : implementation file -// - -#define DEFINE_TERRAIN_TYPE_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "TileTool.h" -#include "wbview3d.h" -#include "Common/TerrainTypes.h" -#include "W3DDevice/GameClient/TerrainTex.h" -#include "W3DDevice/GameClient/HeightMap.h" - -TerrainMaterial *TerrainMaterial::m_staticThis = nullptr; - -static Int defaultMaterialIndex = 0; - -///////////////////////////////////////////////////////////////////////////// -// TerrainMaterial dialog - -Int TerrainMaterial::m_currentFgTexture(3); -Int TerrainMaterial::m_currentBgTexture(6); - -Bool TerrainMaterial::m_paintingPathingInfo; -Bool TerrainMaterial::m_paintingPassable; - -TerrainMaterial::TerrainMaterial(CWnd* pParent /*=nullptr*/) : - m_updating(false), - m_currentWidth(3) -{ - //{{AFX_DATA_INIT(TerrainMaterial) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void TerrainMaterial::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TerrainMaterial) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(TerrainMaterial, COptionsPanel) - //{{AFX_MSG_MAP(TerrainMaterial) - ON_BN_CLICKED(IDC_SWAP_TEXTURES, OnSwapTextures) - ON_EN_CHANGE(IDC_SIZE_EDIT, OnChangeSizeEdit) - ON_BN_CLICKED(IDC_IMPASSABLE, OnImpassable) - ON_BN_CLICKED(IDC_PASSABLE_CHECK, OnPassableCheck) - ON_BN_CLICKED(IDC_PASSABLE, OnPassable) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TerrainMaterial data access method. - -/// Set foreground texture and invalidate swatches. -void TerrainMaterial::setFgTexClass(Int texClass) -{ - if (m_staticThis) { - m_staticThis->m_currentFgTexture=texClass; - m_staticThis->m_terrainSwatches.Invalidate(); - updateTextureSelection(); - } -} - - -/// Set backgroundground texture and invalidate swatches. -void TerrainMaterial::setBgTexClass(Int texClass) -{ - if (m_staticThis) { - m_staticThis->m_currentBgTexture=texClass; - m_staticThis->m_terrainSwatches.Invalidate(); - } -} - -/// Sets the setWidth value in the dialog. -/** Update the value in the edit control and the slider. */ -void TerrainMaterial::setWidth(Int width) -{ - CString buf; - buf.Format("%d", width); - if (m_staticThis && !m_staticThis->m_updating) { - m_staticThis->m_currentWidth = width; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - -/// Sets the tool option - single & multi tile use this panel, -// and only multi tile uses the width. -/** Update the ui for the tool. */ -void TerrainMaterial::setToolOptions(Bool singleCell) -{ - CString buf; - if (m_staticThis ) { - m_staticThis->m_updating = true; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) { - pEdit->EnableWindow(!singleCell); - if (singleCell) { - pEdit->SetWindowText("1"); - } - } - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_POPUP); - if (pEdit) { - pEdit->EnableWindow(!singleCell); - } - m_staticThis->m_updating = false; - } -} - -void TerrainMaterial::updateLabel() -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return; - - AsciiString name = pDoc->GetHeightMap()->getTexClassUiName(m_currentFgTexture); - const char *tName = name.str(); - if (tName == nullptr || tName[0] == 0) { - tName = pDoc->GetHeightMap()->getTexClassUiName(m_currentFgTexture).str(); - } - if (tName == nullptr) { - return; - } - const char *leaf = tName; - while (*tName) { - if ((tName[0] == '\\' || tName[0] == '/')&& tName[1]) { - leaf = tName+1; - } - tName++; - } - CWnd *pLabel = GetDlgItem(IDC_TERRAIN_NAME); - if (pLabel) { - pLabel->SetWindowText(leaf); - } -} - -void TerrainMaterial::updateTextureSelection() -{ - if (m_staticThis) { - m_staticThis->setTerrainTreeViewSelection(TVI_ROOT, m_staticThis->m_currentFgTexture); - m_staticThis->updateLabel(); - } -} - -/// Set the selected texture in the tree view. -Bool TerrainMaterial::setTerrainTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[_MAX_PATH]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&item); - if (item.lParam == selection) { - m_terrainTreeView.SelectItem(child); - return(true); - } - if (setTerrainTreeViewSelection(child, selection)) { - return(true); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - return(false); -} - - -///////////////////////////////////////////////////////////////////////////// -// TerrainMaterial message handlers - -/// Setup the controls in the dialog. -BOOL TerrainMaterial::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - CWnd *pWnd = GetDlgItem(IDC_TERRAIN_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_terrainTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_terrainTreeView.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_TERRAIN_SWATCHES); - pWnd->GetWindowRect(&rect); - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_terrainSwatches.Create(nullptr, "", WS_CHILD, rect, this, IDC_TERRAIN_SWATCHES); - m_terrainSwatches.ShowWindow(SW_SHOW); - - m_paintingPathingInfo = false; - m_paintingPassable = false; - CButton *button = (CButton *)GetDlgItem(IDC_PASSABLE_CHECK); - button->SetCheck(false); - button = (CButton *)GetDlgItem(IDC_PASSABLE); - button->SetCheck(false); - button->EnableWindow(false); - button = (CButton *)GetDlgItem(IDC_IMPASSABLE); - button->SetCheck(true); - button->EnableWindow(false); - - m_widthPopup.SetupPopSliderButton(this, IDC_SIZE_POPUP, this); - m_staticThis = this; - m_updating = false; - setWidth(m_currentWidth); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM TerrainMaterial::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = const_cast(pLabel); - ins.item.cchTextMax = strlen(pLabel); - child = m_terrainTreeView.InsertItem(&ins); - return(child); -} - -/** Add the terrain path to the tree view. */ -void TerrainMaterial::addTerrain(char *pPath, Int terrainNdx, HTREEITEM parent) -{ - TerrainType *terrain = TheTerrainTypes->findTerrain( WorldHeightMapEdit::getTexClassName( terrainNdx ) ); - Bool doAdd = FALSE; - char buffer[_MAX_PATH]; - // - // if we have a 'terrain' entry, it means that our terrain index was properly defined - // in an INI file, otherwise it was from eval textures. We will sort all of - // the eval texture entries in a tree leaf all their own while the others are - // sorted according to a field specified in INI - // - if( terrain ) - { - if (terrain->isBlendEdge()) { - return; // Don't add blend edges to the materials list. - } - for( TerrainClass i = TERRAIN_NONE; i < TERRAIN_NUM_CLASSES; i = (TerrainClass)(i + 1) ) - { - - if( terrain->getClass() == i ) - { - - parent = findOrAdd( parent, terrainTypeNames[ i ] ); - break; // exit for - - } - - } - - // set the name in the tree view to that of the entry - strlcpy(buffer, terrain->getName().str(), ARRAY_SIZE(buffer)); - - doAdd = TRUE; - } - else if (!WorldHeightMapEdit::getTexClassIsBlendEdge(terrainNdx)) - { - - // all these old entries we will put in a tree for eval textures - parent = findOrAdd( parent, "**Eval" ); - Int i=0; - while (pPath[i] && i0 && (i>1 || buffer[0]!='.') ) { // skip the "." directory. - buffer[i] = 0; - parent = findOrAdd(parent, buffer); - } - pPath+= i+1; - i = 0; - } - buffer[i] = pPath[i]; - buffer[i+1] = 0; // terminate at next character - doAdd = TRUE; - i++; - } - } - - Int tilesPerRow = TEXTURE_WIDTH/(2*TILE_PIXEL_EXTENT+TILE_OFFSET); - Int availableTiles = 4 * tilesPerRow * tilesPerRow; - Int percent = (WorldHeightMapEdit::getTexClassNumTiles(terrainNdx)*100 + availableTiles/2) / availableTiles; - - char label[_MAX_PATH]; - snprintf(label, ARRAY_SIZE(label), "%d%% %s", percent, buffer); - - - if( doAdd ) - { - if (percent<3 && defaultMaterialIndex==0) { - defaultMaterialIndex = terrainNdx; - } - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = label; - ins.item.cchTextMax = strlen(label)+2; - m_terrainTreeView.InsertItem(&ins); - } - -} - -//* Create the tree view of textures from the textures in pMap. */ -void TerrainMaterial::updateTextures(WorldHeightMapEdit *pMap) -{ -#if 1 - if (m_staticThis) { - m_staticThis->m_updating = true; - m_staticThis->m_terrainTreeView.DeleteAllItems(); - Int i; - for (i=0; igetNumTexClasses(); i++) { - char path[_MAX_PATH]; - AsciiString uiName = pMap->getTexClassUiName(i); - strlcpy(path, uiName.str(), _MAX_PATH); - m_staticThis->addTerrain(path, i, TVI_ROOT); - } - m_staticThis->m_updating = false; - m_staticThis->m_currentFgTexture = defaultMaterialIndex; - updateTextureSelection(); - } -#endif -} - -/** Swap the foreground and background textures. */ -void TerrainMaterial::OnSwapTextures() -{ - - Int tmp = m_currentFgTexture; - m_currentFgTexture = m_currentBgTexture; - m_currentBgTexture = tmp; - m_terrainSwatches.Invalidate(); - updateTextureSelection(); -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void TerrainMaterial::OnChangeSizeEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int width; - m_updating = true; - if (1==sscanf(buffer, "%d", &width)) { - m_currentWidth = width; - BigTileTool::setWidth(m_currentWidth); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -void TerrainMaterial::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_SIZE_POPUP: - *pMin = MIN_TILE_SIZE; - *pMax = MAX_TILE_SIZE; - *pInitial = m_currentWidth; - *pLineSize = 1; - break; - default: - break; - } -} - - -void TerrainMaterial::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - switch (sliderID) { - - case IDC_SIZE_POPUP: - m_currentWidth = theVal; - str.Format("%d",m_currentWidth); - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - BigTileTool::setWidth(m_currentWidth); - break; - - default: - break; - } -} - -void TerrainMaterial::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - break; - - default: - break; - } - -} - - -BOOL TerrainMaterial::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_terrainTreeView.m_hWnd) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - HTREEITEM hItem = m_terrainTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = hItem; - m_terrainTreeView.GetItem(&item); - if (item.lParam >= 0) { - Int texClass = item.lParam; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return 0; - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - if (!pMap) return 0; - if (m_updating) return 0; - if (pMap->canFitTexture(texClass)) { - m_currentFgTexture = texClass; - updateLabel(); - m_terrainSwatches.Invalidate(); - } else { - if (m_currentFgTexture != texClass) { - // Tried to switch to a too large texture. - ::AfxMessageBox(IDS_TEXTURE_TOO_LARGE); - ::AfxGetMainWnd()->SetFocus(); - } - m_currentFgTexture = texClass; - updateLabel(); - m_terrainSwatches.Invalidate(); - } - } else if (!(item.state & TVIS_EXPANDEDONCE) ) { - HTREEITEM child = m_terrainTreeView.GetChildItem(hItem); - while (child != nullptr) { - hItem = child; - child = m_terrainTreeView.GetChildItem(hItem); - } - if (hItem != m_terrainTreeView.GetSelectedItem()) { - m_terrainTreeView.SelectItem(hItem); - } - } - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -void TerrainMaterial::OnImpassable() -{ - m_paintingPassable = false; - CButton *button = (CButton *)GetDlgItem(IDC_PASSABLE); - button->SetCheck(0); -} - -void TerrainMaterial::OnPassableCheck() -{ - CButton *owner = (CButton*) GetDlgItem(IDC_PASSABLE_CHECK); - Bool isChecked = (owner->GetCheck() != 0); - CButton *button = (CButton *)GetDlgItem(IDC_PASSABLE); - button->EnableWindow(isChecked); - button = (CButton *)GetDlgItem(IDC_IMPASSABLE); - button->EnableWindow(isChecked); - Bool showImpassable = false; - if (TheTerrainRenderObject) { - showImpassable = TheTerrainRenderObject->getShowImpassableAreas(); - } - m_terrainSwatches.EnableWindow(!isChecked); - m_terrainTreeView.EnableWindow(!isChecked); - m_paintingPathingInfo = isChecked; - if (showImpassable != isChecked) { - TheTerrainRenderObject->setShowImpassableAreas(isChecked); - // Force the entire terrain mesh to be rerendered. - IRegion2D range = {0,0,0,0}; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - WbView3d *p3View = pDoc->GetActive3DView(); - if (p3View) { - p3View->updateHeightMapInView(pDoc->GetHeightMap(), false, range); - } - } - } -} - -void TerrainMaterial::OnPassable() -{ - m_paintingPassable = true; - CButton *button = (CButton *)GetDlgItem(IDC_IMPASSABLE); - button->SetCheck(0); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainModal.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainModal.cpp deleted file mode 100644 index 031155d7a4a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainModal.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TerrainModal.cpp : implementation file -// - -#define DEFINE_TERRAIN_TYPE_NAMES - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "TerrainModal.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "Common/TerrainTypes.h" - -///////////////////////////////////////////////////////////////////////////// -// TerrainModal dialog - - -TerrainModal::TerrainModal(AsciiString path, WorldHeightMapEdit *pMap, CWnd* pParent /*=nullptr*/) - : CDialog(TerrainModal::IDD, pParent) -{ - //{{AFX_DATA_INIT(TerrainModal) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - m_pathToReplace = path; - m_map = pMap; -} - - -void TerrainModal::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(TerrainModal) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -void TerrainModal::updateLabel() -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc) return; - - const char *tName = pDoc->GetHeightMap()->getTexClassUiName(m_currentFgTexture).str(); - if (tName == nullptr || tName[0] == 0) { - tName = pDoc->GetHeightMap()->getTexClassUiName(m_currentFgTexture).str(); - } - if (tName == nullptr) { - return; - } - const char *leaf = tName; - while (*tName) { - if ((tName[0] == '\\' || tName[0] == '/')&& tName[1]) { - leaf = tName+1; - } - tName++; - } - CWnd *pLabel = GetDlgItem(IDC_TERRAIN_NAME); - if (pLabel) { - pLabel->SetWindowText(leaf); - } -} - -/// Setup the controls in the dialog. -BOOL TerrainModal::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *pWnd = GetDlgItem(IDC_TERRAIN_TREEVIEW); - CRect rect; - pWnd->GetWindowRect(&rect); - - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_terrainTreeView.Create(TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS| - TVS_SHOWSELALWAYS|TVS_DISABLEDRAGDROP, rect, this, IDC_TERRAIN_TREEVIEW); - m_terrainTreeView.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_TERRAIN_SWATCHES); - pWnd->GetWindowRect(&rect); - ScreenToClient(&rect); - rect.DeflateRect(2,2,2,2); - m_terrainSwatches.Create(nullptr, "", WS_CHILD, rect, this, IDC_TERRAIN_SWATCHES); - m_terrainSwatches.ShowWindow(SW_SHOW); - - pWnd = GetDlgItem(IDC_MISSING_NAME); - if (pWnd) pWnd->SetWindowText(m_pathToReplace.str()); - m_currentFgTexture = 0; - updateTextures(); - TerrainMaterial::setFgTexClass(m_currentFgTexture); - SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/** Locate the child item in tree item parent with name pLabel. If not -found, add it. Either way, return child. */ -HTREEITEM TerrainModal::findOrAdd(HTREEITEM parent, const char *pLabel) -{ - TVINSERTSTRUCT ins; - char buffer[_MAX_PATH]; - ::memset(&ins, 0, sizeof(ins)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - ins.item.mask = TVIF_HANDLE|TVIF_TEXT; - ins.item.hItem = child; - ins.item.pszText = buffer; - ins.item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&ins.item); - if (strcmp(buffer, pLabel) == 0) { - return(child); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - - // not found, so add it. - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = -1; - ins.item.pszText = const_cast(pLabel); - ins.item.cchTextMax = strlen(pLabel); - child = m_terrainTreeView.InsertItem(&ins); - return(child); -} - -/** Add the terrain path to the tree view. */ -void TerrainModal::addTerrain(char *pPath, Int terrainNdx, HTREEITEM parent) -{ - TerrainType *terrain = TheTerrainTypes->findTerrain( WorldHeightMapEdit::getTexClassName( terrainNdx ) ); - Bool doAdd = FALSE; - char buffer[_MAX_PATH]; - - // - // if we have a 'terrain' entry, it means that our terrain index was properly defined - // in an INI file, otherwise it was from legacy GDF stuff. We will sort all of - // the legacy GDF terrain entries in a tree leaf all their own while the others are - // sorted according to a field specified in INI - // - if( terrain ) - { - - for( TerrainClass i = TERRAIN_NONE; i < TERRAIN_NUM_CLASSES; i = (TerrainClass)(i + 1) ) - { - - if( terrain->getClass() == i ) - { - - parent = findOrAdd( parent, terrainTypeNames[ i ] ); - break; // exit for - - } - - } - - strlcpy(buffer, terrain->getName().str(), ARRAY_SIZE(buffer)); - - doAdd = TRUE; - - } - else - { - - // all these old entries we will put in a tree for legacy GDF items - parent = findOrAdd( parent, "**LegacyGDF" ); - - Int i=0; - while (pPath[i] && i0 && (i>1 || buffer[0]!='.') ) { // skip the "." directory. - buffer[i] = 0; - parent = findOrAdd(parent, buffer); - } - pPath+= i+1; - i = 0; - } - buffer[i] = pPath[i]; - buffer[i+1] = 0; // terminate at next char - i++; - doAdd = TRUE; - } - - } - - if (doAdd) - { - TVINSERTSTRUCT ins; - - ::memset(&ins, 0, sizeof(ins)); - ins.hParent = parent; - ins.hInsertAfter = TVI_LAST; - ins.item.mask = TVIF_PARAM|TVIF_TEXT; - ins.item.lParam = terrainNdx; - ins.item.pszText = buffer; - ins.item.cchTextMax = strlen(buffer)+2; - m_terrainTreeView.InsertItem(&ins); - } - -} - -//* Create the tree view of textures from the textures in pMap. */ -void TerrainModal::updateTextures() -{ - m_terrainTreeView.DeleteAllItems(); - Int i; - for (i=0; iisTexClassUsed(i)) { - if (m_currentFgTexture == i) { - m_currentFgTexture++; - } - // continue; - } - const char *tName = WorldHeightMapEdit::getTexClassName(i).str(); - char path[_MAX_PATH]; - strlcpy(path, tName, _MAX_PATH); - addTerrain(path, i, TVI_ROOT); - } - setTerrainTreeViewSelection(TVI_ROOT, m_currentFgTexture); - updateLabel(); -} -/// Set the selected texture in the tree view. -Bool TerrainModal::setTerrainTreeViewSelection(HTREEITEM parent, Int selection) -{ - TVITEM item; - char buffer[_MAX_PATH]; - ::memset(&item, 0, sizeof(item)); - HTREEITEM child = m_terrainTreeView.GetChildItem(parent); - while (child != nullptr) { - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = child; - item.pszText = buffer; - item.cchTextMax = sizeof(buffer)-2; - m_terrainTreeView.GetItem(&item); - if (item.lParam == selection) { - m_terrainTreeView.SelectItem(child); - return(true); - } - if (setTerrainTreeViewSelection(child, selection)) { - return(true); - } - child = m_terrainTreeView.GetNextSiblingItem(child); - } - return(false); -} - - - -BOOL TerrainModal::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - NMTREEVIEW *pHdr = (NMTREEVIEW *)lParam; - if (pHdr->hdr.hwndFrom == m_terrainTreeView.m_hWnd) { - if (pHdr->hdr.code == TVN_SELCHANGED) { - HTREEITEM hItem = m_terrainTreeView.GetSelectedItem(); - TVITEM item; - ::memset(&item, 0, sizeof(item)); - item.mask = TVIF_HANDLE|TVIF_PARAM; - item.hItem = hItem; - m_terrainTreeView.GetItem(&item); - if (item.lParam >= 0) { - m_currentFgTexture = item.lParam; - TerrainMaterial::setFgTexClass(m_currentFgTexture); - updateLabel(); - m_terrainSwatches.Invalidate(); - } - } - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -BEGIN_MESSAGE_MAP(TerrainModal, CDialog) - //{{AFX_MSG_MAP(TerrainModal) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// TerrainModal message handlers diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp deleted file mode 100644 index f95f55c2574..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TerrainSwatches.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TerrainSwatches.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "TerrainSwatches.h" -#include "TerrainMaterial.h" -#include "WorldBuilderDoc.h" -#include "WHeightMapEdit.h" - -///////////////////////////////////////////////////////////////////////////// -// TerrainSwatches - -TerrainSwatches::TerrainSwatches() -{ -} - -TerrainSwatches::~TerrainSwatches() -{ -} - - -BEGIN_MESSAGE_MAP(TerrainSwatches, CWnd) - //{{AFX_MSG_MAP(TerrainSwatches) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -#define SWATCH_OFFSET 20 -///////////////////////////////////////////////////////////////////////////// -// TerrainSwatches message handlers - -void TerrainSwatches::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect clientRect; - GetClientRect(&clientRect); - - CRect bgRect; - bgRect = clientRect; - bgRect.top = bgRect.bottom-TILE_PIXEL_EXTENT; - bgRect.left = bgRect.right-TILE_PIXEL_EXTENT; - - CRect fgRect = clientRect; - fgRect.bottom = fgRect.top+TILE_PIXEL_EXTENT; - fgRect.right = fgRect.left+TILE_PIXEL_EXTENT; - - CBrush brush; - brush.CreateSolidBrush(RGB(0,0,0)); - - Int fgTexClass = TerrainMaterial::getFgTexClass(); - Int bgTexClass = TerrainMaterial::getBgTexClass(); - UnsignedByte *pData; - pData = WorldHeightMapEdit::getPointerToClassTileData(bgTexClass); - if (pData) { - DrawMyTexture(&dc, bgRect.top, bgRect.left, TILE_PIXEL_EXTENT, pData); - } else { - dc.FillSolidRect(&bgRect, RGB(0,128,0)); - } - dc.FrameRect(&bgRect, &brush); - pData = WorldHeightMapEdit::getPointerToClassTileData(fgTexClass); - if (pData) { - DrawMyTexture(&dc, fgRect.top, fgRect.left, TILE_PIXEL_EXTENT, pData); - } else { - dc.FillSolidRect(&fgRect, RGB(128,0,0)); - } - dc.FrameRect(&fgRect, &brush); - - -} - -void TerrainSwatches::DrawMyTexture(CDC *pDc, int top, int left, Int width, UnsignedByte *rgbData) -{ - // Just blast about some dib bits. - - LPBITMAPINFO pBI; -// long bytes = sizeof(BITMAPINFO); - pBI = new BITMAPINFO; - pBI->bmiHeader.biSize = sizeof(pBI->bmiHeader); - pBI->bmiHeader.biWidth = width; - pBI->bmiHeader.biHeight = width; /* match display top left == 0,0 */ - pBI->bmiHeader.biPlanes = 1; - pBI->bmiHeader.biBitCount = 32; - pBI->bmiHeader.biCompression = BI_RGB; - pBI->bmiHeader.biSizeImage = (width*width)*(pBI->bmiHeader.biBitCount/8); - pBI->bmiHeader.biXPelsPerMeter = 1000; - pBI->bmiHeader.biYPelsPerMeter = 1000; - pBI->bmiHeader.biClrUsed = 0; - pBI->bmiHeader.biClrImportant = 0; - - //::Sleep(10); - /*int val=*/::StretchDIBits(pDc->m_hDC, left, top, width, width, 0, 0, width, width, rgbData, pBI, - DIB_RGB_COLORS, SRCCOPY); - delete(pBI); -} - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/TileTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/TileTool.cpp deleted file mode 100644 index aa2688ecb2a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/TileTool.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// TileTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "TileTool.h" -#include "CUndoable.h" -#include "MainFrm.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "BrushTool.h" -#include "DrawObject.h" -// -// TileTool class. -// - - -/// Constructor -TileTool::TileTool() : - Tool(ID_TILE_TOOL, IDC_TILE_CURSOR) -{ - m_htMapEditCopy = nullptr; -} - -/// Destructor -TileTool::~TileTool() -{ - REF_PTR_RELEASE(m_htMapEditCopy); -} - -/// Shows the terrain materials options panel. -void TileTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_TERRAIN_MATERIAL); - TerrainMaterial::setToolOptions(true); - DrawObject::setDoBrushFeedback(true); - DrawObject::setBrushFeedbackParms(true, 1, 0); -} - - -/// Common mouse down code for left and right clicks. -void TileTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m == TRACK_L) - m_textureClassToDraw = TerrainMaterial::getFgTexClass(); - else if (m == TRACK_R) - m_textureClassToDraw = TerrainMaterial::getBgTexClass(); - else - return; - -// WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - // just in case, release it. - REF_PTR_RELEASE(m_htMapEditCopy); - m_htMapEditCopy = pDoc->GetHeightMap()->duplicate(); - m_prevXIndex = -1; - m_prevYIndex = -1; - m_prevViewPt = viewPt; - mouseMoved(m, viewPt, pView, pDoc); -} - -/// Common mouse up code for left and right clicks. -void TileTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L && m != TRACK_R) return; -#define DONT_DO_FULL_UPDATE -#ifdef DO_FULL_UPDATE - m_htMapEditCopy->optimizeTiles(); // force to optimize tileset - IRegion2D partialRange = {0,0,0,0}; - pDoc->updateHeightMap(m_htMapEditCopy, false, partialRange); -#endif - WBDocUndoable *pUndo = new WBDocUndoable(pDoc, m_htMapEditCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - REF_PTR_RELEASE(m_htMapEditCopy); -} - -/// Common mouse moved code for left and right clicks. -void TileTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Bool didAnything = false; - Bool fullUpdate = false; - Coord3D cpt; - - pView->viewToDocCoords(viewPt, &cpt); - DrawObject::setFeedbackPos(cpt); - if (m != TRACK_L && m != TRACK_R) return; - Int dx = m_prevViewPt.x - viewPt.x; - Int dy = m_prevViewPt.y - viewPt.y; - Int count = sqrt(dx*dx + dy*dy); - Int k; - - Int totalMinX = m_htMapEditCopy->getXExtent(); - Int totalMinY = m_htMapEditCopy->getYExtent(); - Int totalMaxX = 0; - Int totalMaxY = 0; - - count /= 2; - if (count<1) count = 1; - for (k=0; k<=count; k++) { - CPoint curViewPt; - curViewPt.x = viewPt.x + ((count-k)*dx)/count; - curViewPt.y = viewPt.y + ((count-k)*dy)/count; - - if (k==0) { - DEBUG_ASSERTCRASH(curViewPt.x == m_prevViewPt.x, ("Bad x")); - DEBUG_ASSERTCRASH(curViewPt.y == m_prevViewPt.y, ("Bad y")); - } - if (k==count) { - DEBUG_ASSERTCRASH(curViewPt.x == viewPt.x, ("Bad x")); - DEBUG_ASSERTCRASH(curViewPt.y == viewPt.y, ("Bad y")); - } - CPoint ndx; - Int width = getWidth(); - pView->viewToDocCoords(curViewPt, &cpt); - getCenterIndex(&cpt, width, &ndx, pDoc); - if (m_prevXIndex == ndx.x && m_prevYIndex == ndx.y) continue; - - m_prevXIndex = ndx.x; - m_prevYIndex = ndx.y; - - Int i, j; - Int minX = ndx.x - (width)/2; - Int minY = ndx.y - (width)/2; - for (i=minX; i=m_htMapEditCopy->getXExtent()) continue; - for (j=minY; j=m_htMapEditCopy->getYExtent()) continue; - if (TerrainMaterial::isPaintingPathingInfo()) { - m_htMapEditCopy->setCliff(i, j, !TerrainMaterial::isPaintingPassable()); - } else { - if (m_htMapEditCopy->setTileNdx(i, j, m_textureClassToDraw, width==1)) { - fullUpdate = true; - } - } - didAnything = true; - if (totalMinX>i) totalMinX = i; - if (totalMinY>j) totalMinY = j; - if (totalMaxXoptimizeTiles(); // force to optimize tileset - } - pDoc->updateHeightMap(m_htMapEditCopy, !fullUpdate, partialRange); - } - pView->UpdateWindow(); - m_prevViewPt = viewPt; -} - -/************************************************************************* -** BigTileTool -***************************************************************************/ -Int BigTileTool::m_currentWidth = 0; - -/// Constructor -BigTileTool::BigTileTool() -{ - m_toolID = ID_BIG_TILE_TOOL; -} - -/// Shows the terrain materials options panel. -void BigTileTool::setWidth(Int width) -{ - m_currentWidth = width; - DrawObject::setBrushFeedbackParms(true, m_currentWidth, 0); -} - -/// Shows the terrain materials options panel. -void BigTileTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_TERRAIN_MATERIAL); - TerrainMaterial::setToolOptions(false); - TerrainMaterial::setWidth(m_currentWidth); - DrawObject::setDoBrushFeedback(true); - DrawObject::setBrushFeedbackParms(true, m_currentWidth, 0); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/Tool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/Tool.cpp deleted file mode 100644 index c179749f17f..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/Tool.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// Tool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "WorldBuilderDoc.h" -#include "Common/MapObject.h" - -#include "Tool.h" -// -/// Tool class. -// -/// Constructor -Tool::Tool(Int toolID, Int cursorID) -{ - m_toolID = toolID; - m_cursorID = cursorID; - m_cursor = nullptr; -} - - -/// Destructor -Tool::~Tool() -{ - if (m_cursor) { - ::DestroyCursor(m_cursor); - } -} - - -/// Shows the "no options" options panel. -void Tool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_NO_OPTIONS); - DrawObject::setDoBrushFeedback(false); -} - - -void Tool::setCursor() -{ - if (m_cursor == nullptr) { - m_cursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(m_cursorID)); - } - ::SetCursor(m_cursor); -} - -/// Calculate the round blend factor. -/** Calculates the blend amount of the brush. 1.0 means the brush sets the -height, 0.0 means no change, and between blends proportionally. */ -Real Tool::calcRoundBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth) -{ - Real offset = 0; - if (brushWidth&1) offset = 0.5; - const Real CLOSE_ENOUGH = 0.05f; // We are working on an integer grid. - - Real dx = abs(center.x+offset-x); - Real dy = abs(center.y+offset-y); - - Real dist = (Real)sqrt(dx*dx+dy*dy); - - if (dist <= (brushWidth/2.0f)+CLOSE_ENOUGH) return (1.0f); - - dist -= (brushWidth/2.0f); - - if (featherWidth < 1) { - return(0); - } - - if (dist <= featherWidth) { - return (featherWidth-dist)/featherWidth; - } - - return(0); -} - -/// Calculate the square blend factor. -/** Calculates the blend amount of the brush. 1.0 means the brush sets the -height, 0.0 means no change, and between blends proportionally. */ -Real Tool::calcSquareBlendFactor(CPoint center, Int x, Int y, Int brushWidth, Int featherWidth) -{ - Real offset = 0; - if (brushWidth&1) offset = 0.5; - - Real dx = abs(center.x+offset-x); - Real dy = abs(center.y+offset-y); - - Real dist = dx; - if (dy>dist) dist = dy; - - if (dist <= (brushWidth/2.0f)) return (1.0f); - - dist -= (brushWidth/2.0f); - - if (featherWidth < 1) { - return(0); - } - - if (dist <= featherWidth) { - return (featherWidth-dist)/featherWidth; - } - - return(0); -} - -/// Gets the cell index for the center of the brush. -/** Converts from document coordinates to cell index coordinates. */ -void Tool::getCenterIndex(Coord3D *docLocP, Int brushWidth, CPoint *center, CWorldBuilderDoc *pDoc) -{ - Coord3D cpt = *docLocP; - // center on half pixel for even widths. - if (!(brushWidth&1)) { - cpt.x += MAP_XY_FACTOR/2; - cpt.y += MAP_XY_FACTOR/2; - } - if (!pDoc->getCellIndexFromCoord(cpt, center)) { - return; - } -} - -void Tool::getAllIndexesIn(const Coord3D *bl, const Coord3D *br, - const Coord3D *tl, const Coord3D *tr, - Int widthOutside, CWorldBuilderDoc *pDoc, - VecHeightMapIndexes* allIndices) -{ - if (!(bl && br && tl && tr && pDoc && allIndices)) { - return; - } - - pDoc->getAllIndexesInRect(bl, br, tl, tr, widthOutside, allIndices); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp deleted file mode 100644 index 878a03f1909..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WBFrameWnd.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WBFrameWnd.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "MainFrm.h" -#include "WBFrameWnd.h" -#include "WorldBuilderDoc.h" -#include "WHeightMapEdit.h" -#include "wbview3d.h" - -///////////////////////////////////////////////////////////////////////////// -// CWBFrameWnd - -IMPLEMENT_DYNCREATE(CWBFrameWnd, CFrameWnd) - -CWBFrameWnd::CWBFrameWnd() -{ -} - -CWBFrameWnd::~CWBFrameWnd() -{ -} - -BOOL CWBFrameWnd::LoadFrame(UINT nIDResource, - DWORD dwDefaultStyle, - CWnd* pParentWnd, - CCreateContext* pContext) { - //dwDefaultStyle &= ~(WS_SIZEBOX|WS_MAXIMIZEBOX|WS_SYSMENU); - - BOOL ret = CFrameWnd::LoadFrame(nIDResource, dwDefaultStyle, CMainFrame::GetMainFrame(), pContext); - if (ret) { - Int top = ::AfxGetApp()->GetProfileInt(TWO_D_WINDOW_SECTION, "Top", 10); - Int left =::AfxGetApp()->GetProfileInt(TWO_D_WINDOW_SECTION, "Left", 10); - this->SetWindowPos(nullptr, left, - top, 0, 0, - SWP_NOZORDER|SWP_NOSIZE); - if (!m_cellSizeToolBar.Create(this, IDD_CELL_SLIDER, CBRS_LEFT, IDD_CELL_SLIDER)) - { - DEBUG_CRASH(("Failed to create toolbar")); - } - EnableDocking(CBRS_ALIGN_ANY); - m_cellSizeToolBar.SetupSlider(); - m_cellSizeToolBar.EnableDocking(CBRS_ALIGN_ANY); - DockControlBar(&m_cellSizeToolBar); - } - return(ret); -} - -void CWBFrameWnd::OnMove(int x, int y) -{ - CFrameWnd::OnMove(x, y); - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(TWO_D_WINDOW_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(TWO_D_WINDOW_SECTION, "Left", frameRect.left); - } -} - - -BEGIN_MESSAGE_MAP(CWBFrameWnd, CFrameWnd) - //{{AFX_MSG_MAP(CWBFrameWnd) - ON_WM_MOVE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWBFrameWnd message handlers - - -///////////////////////////////////////////////////////////////////////////// -// CWB3dFrameWnd - -IMPLEMENT_DYNCREATE(CWB3dFrameWnd, CMainFrame) - -CWB3dFrameWnd::CWB3dFrameWnd() -{ -} - -CWB3dFrameWnd::~CWB3dFrameWnd() -{ -} - - -BEGIN_MESSAGE_MAP(CWB3dFrameWnd, CMainFrame) - //{{AFX_MSG_MAP(CWB3dFrameWnd) - // NOTE - the ClassWizard will add and remove mapping macros here. - ON_WM_MOVE() - ON_COMMAND(ID_WINDOW_PREVIEW1024X768, OnWindowPreview1024x768) - ON_UPDATE_COMMAND_UI(ID_WINDOW_PREVIEW1024X768, OnUpdateWindowPreview1024x768) - ON_COMMAND(ID_WINDOW_PREVIEW640X480, OnWindowPreview640x480) - ON_UPDATE_COMMAND_UI(ID_WINDOW_PREVIEW640X480, OnUpdateWindowPreview640x480) - ON_COMMAND(ID_WINDOW_PREVIEW800X600, OnWindowPreview800x600) - ON_UPDATE_COMMAND_UI(ID_WINDOW_PREVIEW800X600, OnUpdateWindowPreview800x600) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CWB3dFrameWnd message handlers -BOOL CWB3dFrameWnd::LoadFrame(UINT nIDResource, - DWORD dwDefaultStyle, - CWnd* pParentWnd, - CCreateContext* pContext) { - dwDefaultStyle &= ~(WS_SIZEBOX); - - BOOL ret = CMainFrame::LoadFrame(nIDResource, dwDefaultStyle, CMainFrame::GetMainFrame(), pContext); - return(ret); -} - - -void CWB3dFrameWnd::OnMove(int x, int y) -{ - CFrameWnd::OnMove(x, y); - if (this->IsWindowVisible() && !this->IsIconic()) { - CRect frameRect; - GetWindowRect(&frameRect); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Top", frameRect.top); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Left", frameRect.left); - } -} - -void CWB3dFrameWnd::OnWindowPreview1024x768() -{ - if (m_3dViewWidth == 1024) return; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Width", 1024); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Height", 768); - adjustWindowSize(); -} - -void CWB3dFrameWnd::OnUpdateWindowPreview1024x768(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_3dViewWidth==1024?1:0); -} - -void CWB3dFrameWnd::OnWindowPreview640x480() -{ - if (m_3dViewWidth == 640) return; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Width", 640); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Height", 480); - adjustWindowSize(); -} - -void CWB3dFrameWnd::OnUpdateWindowPreview640x480(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_3dViewWidth==640?1:0); -} - -void CWB3dFrameWnd::OnWindowPreview800x600() -{ - if (m_3dViewWidth == 800) return; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Width", 800); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "Height", 600); - adjustWindowSize(); -} - -void CWB3dFrameWnd::OnUpdateWindowPreview800x600(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_3dViewWidth==800?1:0); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WBHeightMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WBHeightMap.cpp deleted file mode 100644 index c013a07b049..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WBHeightMap.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: Heightmap.cpp //////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: Heightmap.cpp -// -// Created: Mark W., John Ahlquist, April/May 2001 -// -// Desc: Draw the terrain and scorchmarks in a scene. -// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Includes -//----------------------------------------------------------------------------- -#include "WBHeightMap.h" -#include "Common/GlobalData.h" -#include -#include -#include - -#define dontUSE_FLAT_HEIGHT_MAP -//----------------------------------------------------------------------------- -// Private Data -//----------------------------------------------------------------------------- - -//============================================================================= -// WBHeightMap::WBHeightMap -//============================================================================= -WBHeightMap::WBHeightMap() : - m_drawEntireMap(false), - m_flattenHeights(false) -{ -} - -//============================================================================= -// WBHeightMap::Render -//============================================================================= -/** Renders (draws) the terrain. */ -//============================================================================= -void WBHeightMap::setFlattenHeights(Bool flat) -{ - if (m_flattenHeights != flat) { - m_flattenHeights = flat; -#ifndef USE_FLAT_HEIGHT_MAP - m_originX = 0; - m_originY = 0; - updateBlock(0, 0, m_x-1, m_y-1, m_map, nullptr); -#endif - } -} - -// THE_Z is just above the water plane, so the flattened terrain doesn't draw -// under water. -#define THE_Z (10) -//============================================================================= -// WBHeightMap::flattenHeights -//============================================================================= -/** Flattens the terrain for the top down view.. */ -//============================================================================= -void WBHeightMap::flattenHeights() { -#ifndef USE_FLAT_HEIGHT_MAP - Real theZ = THE_Z; - Int i, j; - for (j=0; jz = theZ; - vbHardware++; - } - } -#endif -} - -//============================================================================= -// WBHeightMap::getMaxCellHeight -//============================================================================= -/** Returns maximum height of the 4 corners containing the given point */ -//============================================================================= -Real WBHeightMap::getMaxCellHeight(Real x, Real y) -{ - if (!m_flattenHeights) { - return BaseHeightMapRenderObjClass::getMaxCellHeight(x,y); - } - // If we are flattening the height, all z values aret THE_Z. jba. - return THE_Z; -} - - -//============================================================================= -// WBHeightMap::getHeight -//============================================================================= -/** return the height and normal of the triangle plane containing given location within heightmap. */ -//============================================================================= -Real WBHeightMap::getHeightMapHeight(Real x, Real y, Coord3D* normal) -{ - if (!m_flattenHeights) { - return BaseHeightMapRenderObjClass::getHeightMapHeight(x,y,normal); - } - // If we are flattening the height, all z values aret THE_Z. jba. - if (normal) { - normal->x = 0; - normal->y = 0; - normal->z = 1; - } - return THE_Z; -} - - - -//============================================================================= -// WBHeightMap::Cast_Ray -//============================================================================= -/** Return intersection of a ray with the heightmap mesh. - -*/ -//============================================================================= -Bool WBHeightMap::Cast_Ray(RayCollisionTestClass & raytest) -{ - if (!m_flattenHeights) { - return BaseHeightMapRenderObjClass::Cast_Ray(raytest); - } - Real theZ = THE_Z; - TriClass tri; - Bool hit = false; - Int X,Y; - Vector3 normal,P0,P1,P2,P3; - - if (!m_map) - return false; //need valid pointer to heightmap samples -// HeightSampleType *pData = m_map->getDataPtr(); - //Clip ray to extents of heightfield - AABoxClass hbox; - LineSegClass lineseg,lineseg2; - CastResultStruct result; - Int StartCellX; - Int EndCellX; - Int StartCellY; - Int EndCellY; - const Int overhang = 2*32; // Allow picking past the edge for scrolling & objects. - Vector3 minPt(MAP_XY_FACTOR*(-overhang), MAP_XY_FACTOR*(-overhang), -MAP_XY_FACTOR); - Vector3 maxPt(MAP_XY_FACTOR*(m_map->getXExtent()+overhang), - MAP_XY_FACTOR*(m_map->getYExtent()+overhang), MAP_HEIGHT_SCALE*m_map->getMaxHeightValue()+MAP_XY_FACTOR); - MinMaxAABoxClass mmbox(minPt, maxPt); - hbox.Init(mmbox); - - lineseg=raytest.Ray; - - //Set initial ray endpoints - P0 = raytest.Ray.Get_P0(); - P1 = raytest.Ray.Get_P1(); - result.ComputeContactPoint=true; - - Int p; - for (p=0; p<3; p++) { - //find intersection point of ray and terrain bounding box - if (CollisionMath::Collide(lineseg,hbox,&result)) - { //ray intersects terrain or starts inside the terrain. - if (!result.StartBad) //check if start point inside terrain - P0 = result.ContactPoint; //make intersection point the new start of the ray. - - //reverse direction of original ray and clip again to extent of - //heightmap - result.Fraction=1.0f; //reset the result - result.StartBad=false; - lineseg2.Set(lineseg.Get_P1(),lineseg.Get_P0()); //reverse line segment - if (CollisionMath::Collide(lineseg2,hbox,&result)) - { if (!result.StartBad) //check if end point inside terrain - P1 = result.ContactPoint; //make intersection point the new end pont of ray - } - } else { - return(false); - } - - // Take the 2D bounding box of ray and check heights - // inside this box for intersection. - if (P0.X > P1.X) { //flip start/end points - StartCellX = floor(P1.X/MAP_XY_FACTOR); - EndCellX = ceil(P0.X/MAP_XY_FACTOR); - } else { - StartCellX = floor(P0.X/MAP_XY_FACTOR); - EndCellX = ceil(P1.X/MAP_XY_FACTOR); - } - if (P0.Y > P1.Y) { //flip start/end points - StartCellY=floor(P1.Y/MAP_XY_FACTOR); - EndCellY=ceil(P0.Y/MAP_XY_FACTOR); - } else { - StartCellY = floor(P0.Y/MAP_XY_FACTOR); - EndCellY = ceil(P1.Y/MAP_XY_FACTOR); - } - - Vector3 minPt(MAP_XY_FACTOR*(StartCellX-1), MAP_XY_FACTOR*(StartCellY-1), theZ-1); - Vector3 maxPt(MAP_XY_FACTOR*(EndCellX+1), MAP_XY_FACTOR*(EndCellY+1), theZ+1); - MinMaxAABoxClass mmbox(minPt, maxPt); - hbox.Init(mmbox); - } - - raytest.Result->ComputeContactPoint=true; //tell CollisionMath that we need point. - - Int offset; - for (offset = 1; offset < 5; offset *= 3) { - for (Y=StartCellY-offset; Y<=EndCellY+offset; Y++) { - //if (Y<0) continue; - //if (Y>=m_map->getYExtent()-1) continue; - - for (X=StartCellX-offset; X<=EndCellX+offset; X++) { - //test the 2 triangles in this cell - // 3-----2 - // | /| - // | / | - // |/ | - // 0-----1 - - //bottom triangle first - P0.X=X*MAP_XY_FACTOR; - P0.Y=Y*MAP_XY_FACTOR; - P0.Z=THE_Z; - - P1.X=(X+1)*MAP_XY_FACTOR; - P1.Y=Y*MAP_XY_FACTOR; - P1.Z=THE_Z; - - P2.X=(X+1)*MAP_XY_FACTOR; - P2.Y=(Y+1)*MAP_XY_FACTOR; - P2.Z=THE_Z; - - P3.X=X*MAP_XY_FACTOR; - P3.Y=(Y+1)*MAP_XY_FACTOR; - P3.Z=THE_Z; - - - tri.V[0] = &P0; - tri.V[1] = &P1; - tri.V[2] = &P2; - - tri.N = &normal; - - tri.Compute_Normal(); - - hit = hit | CollisionMath::Collide(raytest.Ray, tri, raytest.Result); - - if (raytest.Result->StartBad) - return true; - - //top triangle - tri.V[0] = &P2; - tri.V[1] = &P3; - tri.V[2] = &P0; - - tri.N = &normal; - - tri.Compute_Normal(); - - hit = hit | CollisionMath::Collide(raytest.Ray, tri, raytest.Result); - - if (hit) - raytest.Result->SurfaceType = SURFACE_TYPE_DEFAULT; ///@todo: WW3D uses this to return dirt, grass, etc. Do we need this? - } - if (hit) break; - } - if (hit) break; - } - return hit; -} - - -//============================================================================= -// WBHeightMap::Render -//============================================================================= -/** Renders (draws) the terrain. */ -//============================================================================= -void WBHeightMap::Render(RenderInfoClass & rinfo) -{ - if (m_flattenHeights) { - flattenHeights(); - } -#ifdef USE_FLAT_HEIGHT_MAP - FlatHeightMapRenderObjClass::Render(rinfo); -#else - HeightMapRenderObjClass::Render(rinfo); -#endif -} - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp deleted file mode 100644 index 1d2d782a920..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WBPopupSlider.cpp +++ /dev/null @@ -1,592 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WBPopupSlider.cpp implementation file -// - -#include "StdAfx.h" - -#include "Lib/BaseType.h" -#include "WBPopupSlider.h" -#include "resource.h" -#include "Common/Debug.h" - -///////////////////////////////////////////////////////////////////////////// -// WBPopupSliderButton public member functions - -void WBPopupSliderButton::SetupPopSliderButton -( - CWnd *pParentWnd, - long controlID, - PopupSliderOwner *pOwner -) -{ - SubclassWindow(pParentWnd->GetDlgItem(controlID)->GetSafeHwnd()); - - m_controlID = controlID; - m_sliderStyle = SB_VERT; - m_owner = pOwner; - - HBITMAP hBm = (HBITMAP) ::LoadImage((HINSTANCE) AfxGetResourceHandle(), - MAKEINTRESOURCE(IDB_DownArrow), - IMAGE_BITMAP, 0, 0, - LR_LOADMAP3DCOLORS); - - HBITMAP hbmOld = (HBITMAP) SendMessage(BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBm); - - if (hbmOld) - ::DeleteObject(hbmOld); - hbmOld = nullptr; - -} - - -///////////////////////////////////////////////////////////////////////////// -// WBPopupSliderButton - -WBPopupSliderButton::WBPopupSliderButton() -{ - m_owner = nullptr; -} - -WBPopupSliderButton::~WBPopupSliderButton() -{ -} - - -BEGIN_MESSAGE_MAP(WBPopupSliderButton, CButton) - //{{AFX_MSG_MAP(WBPopupSliderButton) - ON_WM_LBUTTONDOWN() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// WBPopupSliderButton message handlers - -void WBPopupSliderButton::OnLButtonDown(UINT nFlags, CPoint point) -{ -nFlags; -point; - - // just create the slider; it will delete itself when the user is done scrolling - PopupSlider::New(this, m_sliderStyle, m_owner, m_controlID); -} - - - - - - -///////////////////////////////////////////////////////////////////////////// -// defines and typedefs - -#define POPUP_SLIDER_SMALLDIMENSION 16 -#define POPUP_SLIDER_BIGDIMENSION 120 -#define SLIDER_INSET_AMOUNT 1 - -// two guesses what these are -#define THUMB_ICON_WIDTH 5 -#define THUMB_ICON_HEIGHT 8 - -// the width between the end of the channel and the edge of the window -#define CHANNEL_X_INSET_AMOUNT 5 - -// the height between the top of the thumb and the top of the window -#define PIXELS_ABOVE_SLIDER 3 - -// the height between the top of the thumb and the top of the channel -#define CHANNEL_BELOW_THUMB_TOP 1 - -// the height between the bottom of the channel and the bottom of the thumb -#define CHANNEL_ABOVE_THUMB_BOTTOM 3 - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider static member variables - -PopupSlider *PopupSlider::gPopupSlider = nullptr; - - -///////////////////////////////////////////////////////////////////////////// -// internal routines - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider private member functions - -void PopupSlider::GetChannelRect(CRect* rect) -{ - GetClientRect(rect); - if(SB_HORZ == m_kind) { - rect->InflateRect(-CHANNEL_X_INSET_AMOUNT, 0); - rect->top = PIXELS_ABOVE_SLIDER + CHANNEL_BELOW_THUMB_TOP; - rect->bottom = THUMB_ICON_HEIGHT - (CHANNEL_BELOW_THUMB_TOP + CHANNEL_ABOVE_THUMB_BOTTOM); - rect->bottom += rect->top; - } else { - rect->InflateRect(0, -CHANNEL_X_INSET_AMOUNT); - rect->left = PIXELS_ABOVE_SLIDER + CHANNEL_BELOW_THUMB_TOP + 2; - rect->right = THUMB_ICON_HEIGHT - (CHANNEL_BELOW_THUMB_TOP + CHANNEL_ABOVE_THUMB_BOTTOM); - rect->right += rect->left; - } -} - -void PopupSlider::GetThumbIconRect(CRect* rect) -{ - CRect channelRect; - GetChannelRect(&channelRect); - - int range = m_hi - m_lo; - - int along = m_curValue - m_lo; - - if(SB_HORZ == m_kind) { - int thumbMiddle = along * channelRect.Width(); - thumbMiddle /= range; - thumbMiddle += channelRect.left; - - if (thumbMiddle < channelRect.left) thumbMiddle = channelRect.left; - if (thumbMiddle > channelRect.right) thumbMiddle = channelRect.right; - - rect->top = channelRect.top - CHANNEL_BELOW_THUMB_TOP; - rect->bottom = channelRect.bottom + CHANNEL_ABOVE_THUMB_BOTTOM; - rect->left = thumbMiddle - (THUMB_ICON_WIDTH / 2); - rect->right = rect->left + THUMB_ICON_WIDTH; - } else { - int thumbMiddle = along * channelRect.Height(); - thumbMiddle /= range; - thumbMiddle = channelRect.bottom - thumbMiddle; - - if (thumbMiddle < channelRect.top) thumbMiddle = channelRect.top; - if (thumbMiddle > channelRect.bottom) thumbMiddle = channelRect.bottom; - - rect->top = thumbMiddle - (THUMB_ICON_WIDTH / 2); - rect->bottom = thumbMiddle + (THUMB_ICON_WIDTH/2); - rect->left = channelRect.left - CHANNEL_BELOW_THUMB_TOP; - rect->right = channelRect.right + CHANNEL_ABOVE_THUMB_BOTTOM; - } -} - -void PopupSlider::MoveThumbUnderMouse(int xNew) -{ - CRect channelRect; - GetChannelRect(&channelRect); - - int newVal = m_hi - m_lo; - if(SB_HORZ == m_kind) { - int along = xNew - channelRect.left; - - newVal *= along; - newVal /= channelRect.Width(); - newVal += m_lo; - } else { - int along = channelRect.bottom - xNew; - - newVal *= along; - newVal /= channelRect.Height(); - newVal += m_lo; - } - if (newVal < m_lo) newVal = m_lo; - if (newVal > m_hi) newVal = m_hi; - - CRect iconRect; - GetThumbIconRect(&iconRect); - iconRect.InflateRect(3, 3); - InvalidateRect(&iconRect, FALSE); - - m_curValue = newVal; - - GetThumbIconRect(&iconRect); - iconRect.InflateRect(3, 3); - InvalidateRect(&iconRect, FALSE); -} - - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider static member functions - -void PopupSlider::New(CWnd *pParentWnd, long kind, - PopupSliderOwner *pSliderOwner, - long sliderID) -{ - PopupSlider * pPopupSlider; - - DEBUG_ASSERTCRASH(((SB_HORZ == kind) || (SB_VERT == kind)), - ("PopupSlider - unexpected kind of slider!")); - - DEBUG_ASSERTCRASH(pSliderOwner, ("slider owner is null!")); - - try { - CRect rect; - - pParentWnd->GetWindowRect(&rect); - - rect.left = rect.right; - pPopupSlider = new PopupSlider(); - - pPopupSlider->mSliderOwner = pSliderOwner; - pPopupSlider->mSliderID = sliderID; - pPopupSlider->m_kind = kind; - - pSliderOwner->GetPopSliderInfo(pPopupSlider->mSliderID, - &(pPopupSlider->m_lo), - &(pPopupSlider->m_hi), - &(pPopupSlider->m_lineSize), - &(pPopupSlider->m_curValue)); - - DEBUG_ASSERTCRASH(pPopupSlider->m_hi != pPopupSlider->m_lo, ("PopupSlider: endpoint values are the same!")); - DEBUG_ASSERTCRASH(pPopupSlider->m_lineSize != 0, ("PopupSlider: line size is zero!")); - - pPopupSlider->Create(rect, pParentWnd); - - /* if the slider is successfully created, it will - be deleted automatically by its PostNcDestroy - member function */ - } catch (...) { - // don't rethrow - delete pPopupSlider; - pPopupSlider = nullptr; - - } - - gPopupSlider = pPopupSlider; - // gPopupSlider will be deleted when its PostNcDestroy method is called -} - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider - -PopupSlider::PopupSlider() -{ - mSliderOwner = nullptr; - - mDraggingThumb = false; - mClickThrough = false; - mSetOrigPt = false; - mEverMoved = false; - mIcon = nullptr; - m_lo = m_hi = m_curValue = 0; - - m_valOnLastFinished = 0; -} - -PopupSlider::~PopupSlider() -{ - if (mIcon) { - BOOL bRet = DestroyIcon(mIcon); - (void)bRet; - DEBUG_ASSERTCRASH(bRet != 0, ("Oops.")); - - mIcon = nullptr; - } -} - - -BEGIN_MESSAGE_MAP(PopupSlider, CWnd) - //{{AFX_MSG_MAP(PopupSlider) - ON_WM_PAINT() - ON_WM_LBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_WM_DESTROY() - ON_WM_MOUSEMOVE() - ON_WM_KEYDOWN() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// PopupSlider message handlers - -BOOL PopupSlider::Create(const RECT& rect, CWnd* pParentWnd) -{ - BOOL retVal; - - try { - if (FALSE == m_brush3dFaceColor.CreateSolidBrush(GetSysColor(COLOR_3DFACE))) { - throw(-1); - } - - mIcon = (HICON) LoadImage(AfxGetResourceHandle(), - MAKEINTRESOURCE(IDI_Thumb), - IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS); - - - DWORD dwExStyle = WS_EX_TOPMOST; - DWORD dwStyle = WS_POPUP; - UINT nClassStyle = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNCLIENT | CS_SAVEBITS; - HCURSOR hCursor = ::LoadCursor(nullptr, IDC_ARROW); - CString className = AfxRegisterWndClass(nClassStyle, hCursor, (HBRUSH) m_brush3dFaceColor); - - long winWidth, winHeight; - - winWidth = ((SB_HORZ == m_kind) ? POPUP_SLIDER_BIGDIMENSION : POPUP_SLIDER_SMALLDIMENSION); - winHeight = ((SB_HORZ == m_kind) ? POPUP_SLIDER_SMALLDIMENSION : POPUP_SLIDER_BIGDIMENSION); - - CRect winRect(rect.right - winWidth, rect.bottom, rect.right, rect.bottom + winHeight); - - // we'll just use "this" for the child ID - if (FALSE == CWnd::CreateEx(dwExStyle, (LPCTSTR) className, "", - dwStyle, winRect.left, winRect.top, - winRect.Width(), winRect.Height(), - pParentWnd->GetSafeHwnd(), - nullptr, nullptr)) - throw(-1); - - - // New code to center the slider's thumb under the parent window - if(pParentWnd) { - // Calculate the center of the parent window - CPoint parentWindowCenter; - GetCursorPos(&parentWindowCenter); - - // Calculate the center of the thumb - CRect iconRect; - GetThumbIconRect(&iconRect); - CPoint iconCenter = iconRect.CenterPoint(); - ClientToScreen(&iconCenter); - - // from the centers, calculate how far to move the window - int hAdjustToCenter = 0; - int vAdjustToCenter = 0; - if(SB_HORZ == m_kind) - hAdjustToCenter = parentWindowCenter.x - iconCenter.x; - // This may work for vertical sliders, but has not been tested - if(SB_VERT == m_kind) - vAdjustToCenter = parentWindowCenter.y - iconCenter.y; - - // Move the window - CRect myWindowRect; - GetWindowRect(&myWindowRect); - myWindowRect.OffsetRect(hAdjustToCenter, vAdjustToCenter); - SetWindowPos(nullptr, myWindowRect.left, myWindowRect.top, myWindowRect.Width(), myWindowRect.Height(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW); - } - - // finally, make sure the window appears on screen - //MakeSureWindowIsVisible(GetSafeHwnd()); - ShowWindow(SW_SHOW); - - SetCapture(); - - // success (we'll set the capture after all the failable operations) - retVal = TRUE; - } catch (...) { - // don't rethrow - retVal = FALSE; - } - - return retVal; -} - -void PopupSlider::PostNcDestroy() -{ - if (mSliderOwner && (m_valOnLastFinished != m_curValue)) { - mSliderOwner->PopSliderFinished(mSliderID, m_curValue); - } - - CWnd::PostNcDestroy(); - - // now that the window has gone away, delete ourselves - if (gPopupSlider == this) { - delete gPopupSlider; - gPopupSlider = nullptr; - } -} - -void PopupSlider::OnPaint() -{ - CPaintDC dc(this); // device context for painting - CRect rc; - CBrush cbr(GetSysColor(COLOR_BTNFACE)); - CBrush *pCbrOld; - CPen cpen(PS_NULL, 0, RGB(0x00, 0x00, 0x00)); - CPen *pPenOld; - COLORREF ulColor, brColor; - - pCbrOld = dc.SelectObject(&cbr); - pPenOld = dc.SelectObject(&cpen); - - this->GetClientRect(&rc); - - dc.Rectangle(&rc); - - ulColor = GetSysColor(COLOR_3DHILIGHT); - brColor = GetSysColor(COLOR_3DSHADOW); - - dc.Draw3dRect(&rc, ulColor, brColor); - - dc.SelectObject(pCbrOld); - dc.SelectObject(pPenOld); - - CRect channelRect; - GetChannelRect(&channelRect); - dc.Draw3dRect(&channelRect, GetSysColor(COLOR_3DSHADOW), ulColor); - channelRect.InflateRect(-1, -1); - dc.Draw3dRect(&channelRect, GetSysColor(COLOR_3DDKSHADOW), GetSysColor(COLOR_3DLIGHT)); - - if (mIcon) { - CRect iconRect; - GetThumbIconRect(&iconRect); - ::DrawIconEx(dc.GetSafeHdc(), iconRect.left, iconRect.top, - mIcon, 0, 0, 0, nullptr, DI_NORMAL); - } - // Do not call CWnd::OnPaint() for painting messages -} - -void PopupSlider::OnLButtonDown(UINT nFlags, CPoint point) -{ -nFlags; - CRect rc; - GetClientRect(&rc); - if (!mSetOrigPt) { - mOrigPt = point; - } - mSetOrigPt = true; - - - if (rc.PtInRect((POINT) point)) { - CRect iconRect; - GetThumbIconRect(&iconRect); - - // 990909: inflate the rect a little to make it easier to grab the thumb - if(SB_HORZ == m_kind) { - iconRect.InflateRect(3, 6); - } else { - iconRect.InflateRect(6, 3); - } - - if (iconRect.PtInRect((POINT) point)) { - mDraggingThumb = true; - } else { - CRect channelRect; - GetChannelRect(&channelRect); - - if (channelRect.PtInRect((POINT) point)) { - if(SB_HORZ == m_kind) { - MoveThumbUnderMouse(point.x); - } else { - MoveThumbUnderMouse(point.y); - } - mDraggingThumb = true; - mEverMoved = true; - } - } - } else { - try { - if (mSliderOwner) { - mSliderOwner->PopSliderFinished(mSliderID, m_curValue); - } - - m_valOnLastFinished = m_curValue; - } catch (...) { - } - - // user clicked outside our area, close the windoid - PostMessage(WM_CLOSE, 0, 0); - } -} - -void PopupSlider::OnLButtonUp(UINT nFlags, CPoint point) -{ - if (mDraggingThumb) { - mDraggingThumb = false; - - if (mSliderOwner) { - try { - mSliderOwner->PopSliderChanged(mSliderID, m_curValue); - if (mClickThrough && mEverMoved) { - mSliderOwner->PopSliderFinished(mSliderID, m_curValue); - } - - m_valOnLastFinished = m_curValue; - } catch (...) { - } - } - - if (mClickThrough && mEverMoved) { - PostMessage(WM_CLOSE, 0, 0); - } - } else { - CWnd::OnLButtonUp(nFlags, point); - } - mClickThrough = false; -} - -void PopupSlider::OnDestroy() -{ - mEverMoved = false; - ReleaseCapture(); - - CWnd::OnDestroy(); -} - - -void PopupSlider::OnMouseMove(UINT nFlags, CPoint point) -{ - if (!mSetOrigPt) { - mOrigPt = point; - } - mSetOrigPt = true; - if (mDraggingThumb) { - mEverMoved = true; - if(SB_HORZ == m_kind) { - MoveThumbUnderMouse(point.x); - } else { - MoveThumbUnderMouse(point.y); - } - - if (mSliderOwner) { - mSliderOwner->PopSliderChanged(mSliderID, m_curValue); - } - } else if (nFlags & MK_LBUTTON) { - CRect rc; - GetChannelRect(&rc); - if(SB_HORZ == m_kind) { - rc.InflateRect(0, 6); - } else { - rc.InflateRect(6, 0); - } - - if (rc.PtInRect(point)) { - // user just clicked thru, so mark the slider for click through - mDraggingThumb = true; - - if(SB_HORZ == m_kind) { - if (mOrigPt.x != point.x) { - MoveThumbUnderMouse(point.x); - } - mClickThrough = true; - } else { - if (mOrigPt.y != point.y) { - MoveThumbUnderMouse(point.y); - } - mClickThrough = true; - } - - if (mSliderOwner) { - mSliderOwner->PopSliderChanged(mSliderID, m_curValue); - } - } - } -} - -void PopupSlider::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - CWnd::OnKeyDown(nChar, nRepCnt, nFlags); - - if ((VK_RETURN == nChar) || (VK_ESCAPE == nChar)) { - // close the window - PostMessage(WM_CLOSE, 0, 0); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp deleted file mode 100644 index 89af322f931..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp +++ /dev/null @@ -1,3448 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldHeightMapEdit.cpp -// Class to encapsulate height map. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" -#include "Common/STLTypedefs.h" -#include "WHeightMapEdit.h" -#include "W3DDevice/GameClient/TileData.h" -#include "W3DDevice/GameClient/TerrainTex.h" -#include "TerrainModal.h" -#include "Common/Debug.h" -#include "Common/GlobalData.h" -#include "Common/MapReaderWriterInfo.h" -#include "Common/FileSystem.h" -#include "Common/TerrainTypes.h" -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/SidesList.h" -#include "WW3D2/rendobj.h" -#include "W3DDevice/GameClient/W3DShadow.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "Common/WellKnownKeys.h" -#include "mapobjectprops.h" -#include "LayersList.h" - -#include "Common/DataChunk.h" - - -int WorldHeightMapEdit::m_numGlobalTextureClasses=0; -TGlobalTextureClass WorldHeightMapEdit::m_globalTextureClasses[NUM_TEXTURE_CLASSES]; -/** Destructor -. -*/ -WorldHeightMapEdit::~WorldHeightMapEdit() -{ -} - -void WorldHeightMapEdit::shutdown() -{ - Int i, j; - for (i=0; ifreeListOfMapObjects(); - - m_width = width; - m_height = height; - m_borderSize = border; - m_tileNdxes = new Short[m_dataSize]; - m_blendTileNdxes = new Short[m_dataSize]; - m_extraBlendTileNdxes = new Short[m_dataSize]; - m_cliffInfoNdxes = new Short[m_dataSize]; - m_data = new UnsignedByte[m_dataSize + m_width+1]; - m_numBitmapTiles = 0; - m_numBlendedTiles = 1; - m_numCliffInfo = 1; - // Note - we have one less cell than the width & height. But for paranoia, allocate - // extra row. jba. - // - Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags - Int numBytesY = m_height; - - m_flipStateWidth=numBytesX; - - m_cellFlipState = new UnsignedByte[numBytesX*numBytesY]; - m_cellCliffState = new UnsignedByte[numBytesX*numBytesY]; - memset(m_cellFlipState,0,numBytesX*numBytesY); //clear all flags - memset(m_cellCliffState,0,numBytesX*numBytesY); //clear all flags - - - Int j; - if (m_data == nullptr) { - AfxMessageBox(IDS_OUT_OF_MEMORY); - m_dataSize = 0; - } else { - Int i; - for (i=0; im_alphaEdgeTex); - REF_PTR_SET(m_terrainTex, pThis->m_terrainTex); - REF_PTR_SET(m_alphaTerrainTex, pThis->m_alphaTerrainTex); - m_dataSize = pThis->m_dataSize; - m_terrainTexHeight = pThis->m_terrainTexHeight; - m_alphaTexHeight = pThis->m_alphaTexHeight; - m_alphaEdgeHeight = pThis->m_alphaEdgeHeight; - m_width = pThis->m_width; -#ifdef EVAL_TILING_MODES - m_tileMode = pThis->m_tileMode; -#endif - m_height = pThis->m_height; - m_borderSize = pThis->m_borderSize; - m_drawOriginX = pThis->m_drawOriginX; - m_drawOriginY = pThis->m_drawOriginY; - m_drawWidthX = pThis->m_drawWidthX; - m_drawHeightY = pThis->m_drawHeightY; - m_numBitmapTiles = pThis->m_numBitmapTiles; - m_numEdgeTiles = pThis->m_numEdgeTiles; - m_numBlendedTiles = pThis->m_numBlendedTiles; - m_numCliffInfo = pThis->m_numCliffInfo; - m_numTextureClasses = pThis->m_numTextureClasses; - for (i=0; im_textureClasses[i]; - } - m_numEdgeTextureClasses = pThis->m_numEdgeTextureClasses; - for (i=0; im_edgeTextureClasses[i]; - } - m_tileNdxes = new Short[m_dataSize]; - m_blendTileNdxes = new Short[m_dataSize]; - m_extraBlendTileNdxes = new Short[m_dataSize]; - m_cliffInfoNdxes = new Short[m_dataSize]; - // Note - we have one less cell than the width & height. But for paranoia, allocate - // extra row. jba. - // - Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags - Int numBytesY = m_height; - - m_flipStateWidth=numBytesX; - - m_cellFlipState = new UnsignedByte[numBytesX*numBytesY]; - m_cellCliffState = new UnsignedByte[numBytesX*numBytesY]; - memset(m_cellFlipState,0,numBytesX*numBytesY); //clear all flags - memset(m_cellCliffState,0,numBytesX*numBytesY); //clear all flags - m_data = new UnsignedByte[m_dataSize + m_width+1]; - if (m_data == nullptr) { - AfxMessageBox(IDS_OUT_OF_MEMORY); - m_dataSize = 0; - } else { - Int i; - for (i=0; im_sourceTiles[i]); - REF_PTR_SET(m_edgeTiles[i], pThis->m_edgeTiles[i]); - } - for (i=0; im_numBlendedTiles; i++) { - m_blendedTiles[i] = pThis->m_blendedTiles[i]; - } - for (i=0; im_numCliffInfo; i++) { - m_cliffInfo[i] = pThis->m_cliffInfo[i]; - } - for (i=0; im_data[i]; - m_tileNdxes[i] = pThis->m_tileNdxes[i]; - m_blendTileNdxes[i] = pThis->m_blendTileNdxes[i]; - m_extraBlendTileNdxes[i] = pThis->m_extraBlendTileNdxes[i]; - m_cliffInfoNdxes[i] = pThis->m_cliffInfoNdxes[i]; - } - for (i=0; im_cellFlipState[i]; - m_cellCliffState[i] = pThis->m_cellCliffState[i]; - } - } - - m_boundaries = pThis->m_boundaries; -} - -/** - WorldHeightMapEdit - read a height map from a file. - Just calls WorldHeightMap::WorldHeightMap(FILE *pStrm), - then loads the texture classes. -*/ -WorldHeightMapEdit::WorldHeightMapEdit(ChunkInputStream *pStrm): - WorldHeightMap(pStrm), - m_warnTooManyTex(false), - m_warnTooManyBlend(false) -{ - Bool didMajorRemap = false; - Int i, j; - for (i=0; i= 0, ("oops")); - } - - for (i=0; im_tileNdxes[i]; - DEBUG_ASSERTCRASH( (texNdx>>2) < m_numBitmapTiles,("oops")); - Int texClass = getTextureClassFromNdx(texNdx); - DEBUG_ASSERTCRASH(texClass>=0,("oops")); - } -#endif -} - -/****************************************************************** - remapTextures - Remaps the textures in the map. -*/ -Bool WorldHeightMapEdit::remapTextures() -{ - Int i; - Bool anyChanges; - for (i=0; i= 1; width--) { - if (numTiles >= width*width) { - numTiles = width*width; - break; - } - } - -#define BLEND_TILE_PREFIX "TE" - ok = readTiles(pStrm, m_globalTextureClasses[texToUse].tiles, width); - if (!ok) return; - m_globalTextureClasses[texToUse].numTiles = numTiles; - m_globalTextureClasses[texToUse].width = width; - m_globalTextureClasses[texToUse].name = path; - m_globalTextureClasses[texToUse].uiName = uiName; - Bool isBlend = (0==strncmp(BLEND_TILE_PREFIX, uiName, strlen(BLEND_TILE_PREFIX))); - m_globalTextureClasses[texToUse].isBlendEdgeTile = isBlend; - m_globalTextureClasses[texToUse].filePath = path; - m_numGlobalTextureClasses++; -} - -/// Load the available bitmap images. -void WorldHeightMapEdit::loadBaseImages() -{ - - /// @todo - take this out when we are done evaluating terrain textures. -#if defined(RTS_DEBUG) - loadDirectoryOfImages("..\\TestArt\\TestTerrain"); -#endif - - // load terrain types from INI definitions - TerrainType *terrain; - - for( terrain = TheTerrainTypes->firstTerrain(); - terrain; - terrain = TheTerrainTypes->nextTerrain( terrain ) ) - { - if (m_numGlobalTextureClasses == NUM_TEXTURE_CLASSES) - { - break; - } - // load the terrain definition for the WorldBuilder to reference - loadImagesFromTerrainType( terrain ); - - } - -} - -/// Loads all the images in a directory (including subdirectories) -void WorldHeightMapEdit::loadDirectoryOfImages(const char *pFilePath) -{ - char dirBuf[_MAX_PATH]; - char fileBuf[_MAX_PATH]; - - strlcpy(dirBuf, pFilePath, ARRAY_SIZE(dirBuf)); - int len = strlen(dirBuf); - - if (len > 0 && dirBuf[len - 1] != '\\') { - dirBuf[len++] = '\\'; - dirBuf[len] = 0; - } - - FilenameList filenameList; - TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), "*.*", filenameList, TRUE); - - if (filenameList.empty()) { - return; - } - FilenameList::iterator it = filenameList.begin(); - do { - AsciiString filename = *it; - strlcpy(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); - loadBitmap(fileBuf, filename.str()); - - ++it; - } while (it != filenameList.end()); -} - - -/** Loads all the all terrain information for the WorldBuilder given the logical - * TerrainType entity (i.e. tga file)*/ -void WorldHeightMapEdit::loadImagesFromTerrainType( TerrainType *terrain ) -{ - - // sanity - if( terrain == nullptr ) - return; - - char buffer[ _MAX_PATH ]; - - // build path to texture file - snprintf( buffer, ARRAY_SIZE(buffer), "%s%s", TERRAIN_TGA_DIR_PATH, terrain->getTexture().str() ); - - // create ascii string for texture path - AsciiString texturePath( buffer ); - - // open file - CachedFileInputStream stream; - if( !stream.open( texturePath ) ) - return; - - // get pointer to stream - InputStream *pStrm = &stream; - - // could the tiles in the file - Int numTiles = WorldHeightMap::countTiles( pStrm ); - Int width; - if( numTiles < 1 ) - return; - - // rewind the stream - stream.rewind(); - - // setup our entry in the global textures classes - Int texToUse = m_numGlobalTextureClasses; - Int j; - for( j = 0; j < MAX_TILES_PER_CLASS; j++ ) - REF_PTR_RELEASE( m_globalTextureClasses[ texToUse ].tiles[ j ] ); - - for (width = 10; width >= 1; width--) { - if (numTiles >= width*width) { - numTiles = width*width; - break; - } - } - -// --> - - // read the tiles out of .tga file - Bool ok = readTiles( pStrm, m_globalTextureClasses[ texToUse ].tiles, width ); - if( !ok ) - return; - m_globalTextureClasses[ texToUse ].name = terrain->getName(); - m_globalTextureClasses[ texToUse ].numTiles = numTiles; - m_globalTextureClasses[ texToUse ].width = width; - m_globalTextureClasses[ texToUse ].filePath = texturePath; - m_globalTextureClasses[ texToUse ].uiName = terrain->getName(); - m_globalTextureClasses[ texToUse ].terrainType = terrain; - m_globalTextureClasses[ texToUse ].isBlendEdgeTile = terrain->isBlendEdge(); - m_numGlobalTextureClasses++; - -} - -Bool WorldHeightMapEdit::getRawTileData(Short tileNdx, Int width, UnsignedByte *buffer, Int bufLen) -{ - TileData *pSrc = nullptr; - if (tileNdx / 4 < NUM_SOURCE_TILES) { - pSrc = m_sourceTiles[tileNdx / 4]; - } - if (bufLen < (width * width * TILE_BYTES_PER_PIXEL)) { - return false; - } - if (pSrc && pSrc->hasRGBDataForWidth(2 * width)) { - UnsignedByte *pSrcData = pSrc->getRGBDataForWidth(2 * width); - Int xOffset = (tileNdx & 1) ? width : 0; - Int yOffset = (tileNdx & 2) ? width : 0; - for (Int j = 0; j < width; ++j) { - UnsignedByte *pDestData = buffer + j * width * TILE_BYTES_PER_PIXEL; - UnsignedByte *pSrcRow = pSrcData + (j + yOffset) * width * TILE_BYTES_PER_PIXEL * 2; - pSrcRow += xOffset * TILE_BYTES_PER_PIXEL; - memcpy(pDestData, pSrcRow, width * TILE_BYTES_PER_PIXEL); - } - return true; - } - return false; -} - -UnsignedByte * WorldHeightMapEdit::getPointerToClassTileData(Int texClass) -{ - TileData *pSrc = nullptr; - if (texClass >= 0 && texClass <= m_numGlobalTextureClasses) { - pSrc = m_globalTextureClasses[texClass].tiles[0]; - } - if (pSrc != nullptr) { - return(pSrc->getDataPtr()); - } - return(nullptr); -} - - - -void WorldHeightMapEdit::getTexClassNeighbors(Int xIndex, Int yIndex, Int textureClass, - Int *pSideCount, Int *pTotalCount) -{ - Int i,j; - int sideCount=0; - int totalCount=0; - for (i=xIndex-1; i=m_width) x = m_width-1; - if (y>=m_height) y = m_height-1; - - Int curClass = this->getTextureClass(x, y); - - if (curClass == textureClass) { - totalCount++; - if (i==xIndex || j==yIndex) { - sideCount++; - } - } - } - } - *pSideCount = sideCount; - *pTotalCount = totalCount; -} - - - - -// -/// SaveToFile - saves a height map to a file. -// Format is -// tag - 4 bytes 'HtMp' -// version - 2 bytes -// width, height, length - 4 byte Int little endian. -// -// length bytes of map data. -// length bytes of tile ndxes. -// numBitmapTiles, numBlendedTiles - 4 byte int little endian -// numBlendedTiles of tile data. -// -// -// -void WorldHeightMapEdit::saveToFile(DataChunkOutput &chunkWriter) -{ - // This is the chunk writer stuff. - int i; - - /**********HEIGHT MAP DATA ***********************/ - chunkWriter.openDataChunk("HeightMapData", K_HEIGHT_MAP_VERSION_4); - Int numBoundaries = m_boundaries.size(); - chunkWriter.writeInt(m_width); - chunkWriter.writeInt(m_height); - chunkWriter.writeInt(m_borderSize); - chunkWriter.writeInt(numBoundaries); - for (i = 0; i < numBoundaries; ++i) { - chunkWriter.writeInt(m_boundaries[i].x); - chunkWriter.writeInt(m_boundaries[i].y); - } - chunkWriter.writeInt(m_dataSize); - chunkWriter.writeArrayOfBytes((char *)m_data, m_dataSize); - - /* - chunkWriter.writeInt(m_width); - chunkWriter.writeInt(m_height); - chunkWriter.writeInt(m_borderSize); - chunkWriter.writeInt(m_dataSize); - chunkWriter.writeArrayOfBytes((char *)m_data, m_dataSize); - */ - - chunkWriter.closeDataChunk(); - - /***************BLEND TILE DATA ***************/ -#if RTS_GENERALS - chunkWriter.openDataChunk("BlendTileData", K_BLEND_TILE_VERSION_7); -#else - chunkWriter.openDataChunk("BlendTileData", K_BLEND_TILE_VERSION_8); -#endif - chunkWriter.writeInt(m_dataSize); - chunkWriter.writeArrayOfBytes((char*)m_tileNdxes, m_dataSize*sizeof(Short)); - chunkWriter.writeArrayOfBytes((char*)m_blendTileNdxes, m_dataSize*sizeof(Short)); - chunkWriter.writeArrayOfBytes((char*)m_extraBlendTileNdxes, m_dataSize*sizeof(Short)); - chunkWriter.writeArrayOfBytes((char*)m_cliffInfoNdxes, m_dataSize*sizeof(Short)); - chunkWriter.writeArrayOfBytes((char*)m_cellCliffState, m_height*m_flipStateWidth); - chunkWriter.writeInt(m_numBitmapTiles); - chunkWriter.writeInt(m_numBlendedTiles); - chunkWriter.writeInt(m_numCliffInfo); - - // write out the terrain texture information - // --> - chunkWriter.writeInt(m_numTextureClasses); - for (i=0; i - chunkWriter.writeInt(m_numEdgeTiles); - chunkWriter.writeInt(m_numEdgeTextureClasses); - for (i=0; isetInt(TheKey_weather, (Int)TheGlobalData->m_weather); - chunkWriter.openDataChunk("WorldInfo", K_WORLDDICT_VERSION_1); - chunkWriter.writeDict(*MapObject::getWorldDict()); - chunkWriter.closeDataChunk(); - - /***************PLAYER DATA ***************/ - /* important, must write this chunk BEFORE the object-list chunk */ - SidesList::WriteSidesDataChunk(chunkWriter); // Player data dicts are in the sides chunk. - - /***************OBJECTS DATA ***************/ - chunkWriter.openDataChunk("ObjectsList", K_OBJECTS_VERSION_3); - - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) - { - chunkWriter.openDataChunk("Object", K_OBJECTS_VERSION_3); - Coord3D loc = *pObj->getLocation(); - chunkWriter.writeReal( loc.x); - chunkWriter.writeReal( loc.y); - chunkWriter.writeReal( loc.z); - chunkWriter.writeReal( pObj->getAngle()); - chunkWriter.writeInt(pObj->getFlags()); - chunkWriter.writeAsciiString(pObj->getName()); - - chunkWriter.writeDict(*pObj->getProperties()); - -#ifdef NOT_IN_USE - if (pObj->getFlag(FLAG_WAYPOINT)) { - chunkWriter.writeInt(pObj->getWaypointID()); - chunkWriter.writeAsciiString(AsciiString(pObj->getWaypointName())); - } - else if (pObj->getFlag(FLAG_LIGHT)) { - TLightInfo info; - pObj->getLightInfo(&info); - chunkWriter.writeReal(info.m_heightAboveTerrain); - chunkWriter.writeReal(info.m_innerRadius); - chunkWriter.writeReal(info.m_outerRadius); - chunkWriter.writeReal(info.m_lightAmbientColor.red); - chunkWriter.writeReal(info.m_lightAmbientColor.green); - chunkWriter.writeReal(info.m_lightAmbientColor.blue); - chunkWriter.writeReal(info.m_lightDiffuseColor.red); - chunkWriter.writeReal(info.m_lightDiffuseColor.green); - chunkWriter.writeReal(info.m_lightDiffuseColor.blue); - } -#endif - chunkWriter.closeDataChunk(); - } - chunkWriter.closeDataChunk(); - - /***************POLY TRIGGER DATA ***************/ - PolygonTrigger::WritePolygonTriggersDataChunk(chunkWriter); - - /***************GLOBAL LIGHTING DATA ***************/ - chunkWriter.openDataChunk("GlobalLighting", K_LIGHTING_VERSION_3); - chunkWriter.writeInt(TheGlobalData->m_timeOfDay); - for (i=0; i<4; i++) { - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].ambient.red); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].ambient.green); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].ambient.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].diffuse.red); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].diffuse.green); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].diffuse.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].lightPos.x); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].lightPos.y); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][0].lightPos.z); - - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].ambient.red); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].ambient.green); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].ambient.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].diffuse.red); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].diffuse.green); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].diffuse.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].lightPos.x); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].lightPos.y); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][0].lightPos.z); - - Int j=1; - for (; jm_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].ambient.red); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].ambient.green); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].ambient.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].diffuse.red); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].diffuse.green); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].diffuse.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].lightPos.x); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].lightPos.y); - chunkWriter.writeReal(TheGlobalData->m_terrainObjectsLighting[i+TIME_OF_DAY_FIRST][j].lightPos.z); - } - for (j=1; jm_terrainLighting[i+TIME_OF_DAY_FIRST][j].ambient.red); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].ambient.green); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].ambient.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].diffuse.red); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].diffuse.green); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].diffuse.blue); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].lightPos.x); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].lightPos.y); - chunkWriter.writeReal(TheGlobalData->m_terrainLighting[i+TIME_OF_DAY_FIRST][j].lightPos.z); - } - } - chunkWriter.writeInt(TheW3DShadowManager->getShadowColor()); - - chunkWriter.closeDataChunk(); - -#ifdef DEBUG_CRASHING - for (i=0; im_tileNdxes[i]; - DEBUG_ASSERTCRASH((texNdx>>2) < m_numBitmapTiles,("oops")); - Int texClass = getTextureClassFromNdx(texNdx); - DEBUG_ASSERTCRASH(texClass>=0,("oops")); - } -#endif - -} - -// -// duplicate - Makes a copy. -// Returns null if allocation failed. - -WorldHeightMapEdit *WorldHeightMapEdit::duplicate() -{ - WorldHeightMapEdit *newMap = new WorldHeightMapEdit(this); - if (newMap->m_data == nullptr) { - delete newMap; - return(nullptr); - } - return(newMap); -} - - - -Bool WorldHeightMapEdit::setTileNdx(Int xIndex, Int yIndex, Int textureClass, Bool singleTile) -{ - Int ndx = (yIndex*m_width)+xIndex; - Int numClasses = m_numTextureClasses; - DEBUG_ASSERTCRASH(ndx>=0 && ndxm_dataSize,("oops")); - if (ndx<0 || ndx >= this->m_dataSize) return false; - Int texNdx = getTileNdxForClass(xIndex, yIndex, textureClass); - DEBUG_ASSERTCRASH((texNdx>>2)>2; - for (i=0; i= m_textureClasses[i].firstTile && - tileNdx < m_textureClasses[i].firstTile+m_textureClasses[i].numTiles) { - return(m_textureClasses[i].globalTextureClass); - } - } - return(-1); -} -/*Get index into globalTextureClasses*/ -Int WorldHeightMapEdit::getTextureClass(Int xIndex, Int yIndex, Bool baseClass) -{ - Int ndx = (yIndex*m_width)+xIndex; - DEBUG_ASSERTCRASH((ndx>=0 && ndxm_dataSize),("oops")); - if (ndx<0 || ndx >= this->m_dataSize) return(-1); - Int textureNdx = m_tileNdxes[ndx]; - if (!baseClass && (m_blendTileNdxes[ndx] != 0 || m_extraBlendTileNdxes[ndx] != 0)) { - return(-1); // blended, so not of the original class. - } - return getTextureClassFromNdx(textureNdx); //get globalTextureClass index -} -/*Get index of sub-tile that would show up here if it wasn't blended but tiled across*/ -Int WorldHeightMapEdit::getBlendTileNdxForClass(Int xIndex, Int yIndex, Int textureClass) -{ - Int ndx = getTileNdxForClass(xIndex, yIndex, textureClass); - return ndx; -} - -Int WorldHeightMapEdit::getTileIndexFromTerrainType( TerrainType *terrain ) -{ - - // sanity - if( terrain == nullptr ) - return -1; - - // search the texture list for a matching texture filename - for( Int i = 0; i< NUM_TEXTURE_CLASSES; i++ ) - if( m_globalTextureClasses[ i ].terrainType == terrain ) - return i; - - // not found - return -1; - -} - -Int WorldHeightMapEdit::allocateTiles(Int textureClass) -{ -// int tileNdx = 0; - if (textureClass >= 0 && textureClass = 0) return firstTile; - // hasn't been copied into m_sourceTiles yet. - if (this->m_numBitmapTiles + m_globalTextureClasses[textureClass].numTiles>NUM_SOURCE_TILES) { - m_warnTooManyTex = true; - return(-1); - } - Int i; - m_textureClasses[m_numTextureClasses].globalTextureClass = textureClass; - m_textureClasses[m_numTextureClasses].firstTile = m_numBitmapTiles; - firstTile = m_numBitmapTiles; - m_textureClasses[m_numTextureClasses].numTiles = m_globalTextureClasses[textureClass].numTiles; - m_textureClasses[m_numTextureClasses].width = m_globalTextureClasses[textureClass].width; - m_textureClasses[m_numTextureClasses].name = m_globalTextureClasses[textureClass].name; - m_textureClasses[m_numTextureClasses].isBlendEdgeTile = m_globalTextureClasses[textureClass].isBlendEdgeTile; - m_numTextureClasses++; - REF_PTR_RELEASE(m_terrainTex); // need to update the texture. - updateTileTexturePositions(nullptr); - for (i=0; i= 0 && globalTextureClass NUM_SOURCE_TILES) { - m_warnTooManyTex = true; - return(-1); - } - Int i; - localClass = m_numEdgeTextureClasses; - m_edgeTextureClasses[m_numEdgeTextureClasses].globalTextureClass = globalTextureClass; - m_edgeTextureClasses[m_numEdgeTextureClasses].firstTile = m_numEdgeTiles; - firstTile = m_numBitmapTiles; - m_edgeTextureClasses[m_numEdgeTextureClasses].numTiles = m_globalTextureClasses[globalTextureClass].numTiles; - m_edgeTextureClasses[m_numEdgeTextureClasses].width = m_globalTextureClasses[globalTextureClass].width; - m_edgeTextureClasses[m_numEdgeTextureClasses].name = m_globalTextureClasses[globalTextureClass].name; - m_edgeTextureClasses[m_numEdgeTextureClasses].isBlendEdgeTile = m_globalTextureClasses[globalTextureClass].isBlendEdgeTile; - m_numEdgeTextureClasses++; - REF_PTR_RELEASE(m_terrainTex); // need to update the texture. - updateTileTexturePositions(nullptr); - for (i=0; i= 0 && textureClass = 0 && textureClass = 0) return true; // already present. - if (this->m_numBitmapTiles + m_globalTextureClasses[textureClass].numTiles>NUM_SOURCE_TILES) { - // No room at the inn. - return(false); - } - Int i; - m_textureClasses[m_numTextureClasses].globalTextureClass = textureClass; - m_textureClasses[m_numTextureClasses].firstTile = 0; - m_textureClasses[m_numTextureClasses].numTiles = m_globalTextureClasses[textureClass].numTiles; - m_textureClasses[m_numTextureClasses].width = m_globalTextureClasses[textureClass].width; - m_numTextureClasses++; - - updateTileTexturePositions(nullptr); - m_numTextureClasses--; - for (i=0; i= 0) { //get index of sub-tile that would show up here if we continued tiling src. - blendTileNdx = getBlendTileNdxForClass(xIndex, yIndex, textureClass); - DEBUG_ASSERTCRASH((blendTileNdx/4 < m_numBitmapTiles),("oops")); //check it falls into one of the 64x64 tiles of textures used on map. - } - - if (curTileNdx == blendTileNdx) {//destination already contains continuation of source tile so no blend needed. - m_tileNdxes[ndx] = blendTileNdx; - m_blendTileNdxes[ndx] = 0; - m_extraBlendTileNdxes[ndx] = 0; - return; - } - //Updates m_blendTileNdxes[] for this coordinate with index into m_blendedTiles[] - blendSpecificTiles(xIndex, yIndex, srcXIndex, srcYIndex, curTileNdx, blendTileNdx, false, edgeClass); -} - -/*Allocate a new blend description or return existing one out of m_blendedTiles[] and increment m_numBlendedTiles*/ -Int WorldHeightMapEdit::findOrCreateBlendTile(TBlendTileInfo *pBlendInfo) -{ - TileData *pBlendTile; - Short sourceNdx = pBlendInfo->blendNdx; - sourceNdx = sourceNdx>>2; - pBlendTile = m_sourceTiles[sourceNdx]; - if (pBlendTile == nullptr) { - return(-1); - } - // Make a quick scan through the blended tiles, and see if we already got this one. - int k; - for (k=1; kx==pBlendInfo->x) - if (MATCH(blendNdx) && MATCH(horiz) && MATCH(vert) && MATCH(rightDiagonal) && - MATCH(leftDiagonal) && MATCH(longDiagonal) && MATCH(inverted) && MATCH(customBlendEdgeClass)) { - // got a match. - return k; - } - #undef MATCH - } - - if (m_numBlendedTiles>=NUM_BLEND_TILES) { - m_warnTooManyBlend = true; - return -1; // out of new tiles - } - Short newNdx = m_numBlendedTiles; - m_blendedTiles[newNdx] = *pBlendInfo; - m_numBlendedTiles++; - - return(newNdx); - -} -/*Blend blendTileNdx over curTileNdx. Blend from srcIndex to Index coordinates. -Updates m_blendTileNdxes[] for this coordinate with index into m_blendedTiles[]*/ -void WorldHeightMapEdit::blendSpecificTiles(Int xIndex, Int yIndex, Int srcXIndex, Int srcYIndex, - Int curTileNdx, Int blendTileNdx, Bool longDiagonal, Int edgeClass) -{ - TBlendTileInfo blendInfo; - blendInfo.blendNdx=blendTileNdx; //store the tile that will blend over existing tile - blendInfo.horiz = false; - blendInfo.vert = false; - blendInfo.rightDiagonal = false; - blendInfo.leftDiagonal = false; - blendInfo.inverted = false; - blendInfo.longDiagonal = longDiagonal; - blendInfo.customBlendEdgeClass = edgeClass; - - //Check if there is already a blend tile at the destination and record its flip state. - //We need to know this so that we don't accidentally apply a third blend layer with - //a different flip and introduce z-fighting over this tile. - Bool baseNeedsFlip = false; - UnsignedByte baseIsDiagonal = 0; - Int ndx = (yIndex*m_width)+xIndex; - TBlendTileInfo *baseBlendInfo=nullptr; - if (TheGlobalData->m_use3WayTerrainBlends && m_blendTileNdxes[ndx] != 0) - { baseBlendInfo=&m_blendedTiles[m_blendTileNdxes[ndx]]; - //Figure out if this tile will eventually need flipping when rendered - baseIsDiagonal = baseBlendInfo->rightDiagonal || baseBlendInfo->leftDiagonal; - if (baseBlendInfo->rightDiagonal && !baseBlendInfo->inverted) - baseNeedsFlip = true; - else - if (baseBlendInfo->leftDiagonal && baseBlendInfo->inverted) - baseNeedsFlip = true; - } - - Bool flipped = false; - if (srcYIndex == yIndex) { //same vertical coordinates so horizontal blend - blendInfo.horiz = true; - blendInfo.inverted = (srcXIndex < xIndex); //blend from opaque at left to transparent at right. - //check if this blend tile will end up in a third blend layer and if so, copy flip state - //from base layer. - if (baseBlendInfo && baseNeedsFlip) - blendInfo.inverted |= FLIPPED_MASK; - } else if (srcXIndex == xIndex) { - blendInfo.vert = true; //same horizontal coordinates so vertical blend - blendInfo.inverted = (srcYIndex < yIndex); //invert if blend from bottom to top - if (baseBlendInfo && baseNeedsFlip) - blendInfo.inverted |= FLIPPED_MASK; - } else { //diagonal blends - if (srcXIndex > xIndex) { - blendInfo.rightDiagonal = true; - } else { - blendInfo.leftDiagonal = true; - } - blendInfo.inverted = (srcYIndex < yIndex); - blendInfo.longDiagonal = longDiagonal; - if (longDiagonal) { // Flip it. - blendInfo.inverted = !blendInfo.inverted; - blendInfo.rightDiagonal = !blendInfo.rightDiagonal; - blendInfo.leftDiagonal = !blendInfo.leftDiagonal; - } - //Figure out if this tile will eventually need flipping when rendered - if (blendInfo.rightDiagonal && !blendInfo.inverted) - flipped = true; - else - if (blendInfo.leftDiagonal && blendInfo.inverted) - flipped = true; - //Check if this tile will end up in 3rd layer and if so, make sure it can match flip of base layer. - if (baseBlendInfo && baseIsDiagonal && baseNeedsFlip != flipped) - return; //the base requires a certain flip state which we can't alter so can't apply extra blend here. - } - updateFlatCellForAdjacentCliffs(xIndex, yIndex, getTextureClassFromNdx(blendTileNdx)); - - //Check if this tile is really necessary or if the base blend already does the same thing as the 3way blend. - if (baseBlendInfo && baseBlendInfo->blendNdx == blendTileNdx) - return; - - Short newNdx = findOrCreateBlendTile(&blendInfo); - if (newNdx >= 0) { - Int ndx = (yIndex*m_width)+xIndex; - m_tileNdxes[ndx] = curTileNdx; - if (TheGlobalData->m_use3WayTerrainBlends && m_blendTileNdxes[ndx] != 0) - { //this tile already has a blend applied to it. So we put the new blend into the - //secondary layer. - m_extraBlendTileNdxes[ndx]=newNdx; - //force the primary layer to flip if the extra blend layer needs flip. - //we only do this on vertical/horizontal base blends because they work in either flip cases. - if (flipped && !baseIsDiagonal) - { //Find a new tile so as not to affect other cells using the base one. - TBlendTileInfo tempBlendTileInfo=m_blendedTiles[m_blendTileNdxes[ndx]]; - tempBlendTileInfo.inverted |= FLIPPED_MASK; - Short newNdx = findOrCreateBlendTile(&tempBlendTileInfo); - m_blendTileNdxes[ndx] = newNdx; //remap this tile to use a new one. - } - } - else - m_blendTileNdxes[ndx] = newNdx; - } -} - - - -/****************************************************************** - autoBlendOut - auto edges the texture region at xIndex, yIndex outwards. - The region is defined by the texture at xIndex, yIndex. - The edges are blended out, to whatever texture is already there. - If edgeClass == -1, use an alpha blend. Otherwise, use tile class edgeClass. -*/ -void WorldHeightMapEdit::autoBlendOut(Int xIndex, Int yIndex, Int globalEdgeClass) -{ - Int ndx = (yIndex*m_width)+xIndex; - Int curTileClass = getTextureClass(xIndex, yIndex); - if (curTileClass < 0) { - return; - } - Int localEdgeClass=-1; - static Bool foo = false; - if (foo) { - if (globalEdgeClass<0) { - for (globalEdgeClass=m_numGlobalTextureClasses-1; globalEdgeClass>=0; globalEdgeClass--) { - if (m_globalTextureClasses[globalEdgeClass].isBlendEdgeTile) { - break; - } - } - } - } - if (globalEdgeClass>=0) { - localEdgeClass = allocateEdgeTiles(globalEdgeClass); - } - - Int i,j; - UnsignedByte *pProcessed = new UnsignedByte[m_dataSize]; - for (i=0; im_next; - pCurNode->m_next = nullptr; - Int curNdx = (pCurNode->m_y*m_width)+pCurNode->m_x; - for (i=pCurNode->m_x-1; im_x+2; i++) { - if (i<0) continue; - if (i>=m_width) continue; - for (j=pCurNode->m_y-1; jm_y+2; j++) { - if (j<0) continue; - if (j>=m_height) continue; - curNdx = (j*m_width)+i; - if (pProcessed[curNdx]) { - continue; - } - if (curTileClass != getTextureClass(i,j, true)) { - // This is a not us tile. If it is mostly surrounded by us, - // convert it to us, cause if we blend in from 3 sides, it basically - // obliterates it. - Int sides, total; - getTexClassNeighbors(i, j, curTileClass, &sides, &total); - if (sides>2 || total>5) { - m_tileNdxes[curNdx] = getTileNdxForClass(i, j, curTileClass); - m_blendTileNdxes[curNdx] = 0; // no blend. - } else { - continue; - } - } else { - // If we are already blended, skip it. - if (m_blendTileNdxes[curNdx] > 0) continue; - } - CProcessNode *pNewNode = new CProcessNode(i,j); - pNewNode->m_next = pNodesToProcess; - pNodesToProcess = pNewNode; - pProcessed[curNdx] = true; // mark self as processed. - } - } - Int sameSides, sameTotal; - getTexClassNeighbors(pCurNode->m_x, pCurNode->m_y, curTileClass, &sameSides, &sameTotal); - if (sameTotal==8) { - // I am surrounded by my fellow tiles, so I don't need to do any blending. - delete pCurNode; - } else { - // I have some edges with other tiles that will need blending. - pCurNode->m_next = pProcessedNodes; - pProcessedNodes = pCurNode; - } - nodesProcessed++; - } - - // Reinit the processed flags; - for (i=0; im_next; - pCurNode->m_next = nullptr; - Int curNdx = (pCurNode->m_y*m_width)+pCurNode->m_x; - for (i=pCurNode->m_x-1; im_x+2; i++) { - if (i<0) continue; - if (i>=m_width) continue; - for (j=pCurNode->m_y-1; jm_y+2; j++) { - if (j<0) continue; - if (j>=m_height) continue; -// int thisTexClass = - curNdx = (j*m_width)+i; - if (pProcessed[curNdx]) { - continue; - } - // If already blended to us skip it. - if (m_blendTileNdxes[curNdx] > 0) { - if (curTileClass == getTextureClassFromNdx(m_blendedTiles[ m_blendTileNdxes[curNdx]].blendNdx)) { - continue; - } - } - if (curTileClass != getTextureClass(i,j, true)) { - // blend this tile. - blendToThisClass(i,j,curTileClass, localEdgeClass); - } - pProcessed[curNdx] = true; // mark self as processed. - } - } - delete pCurNode; - } - - delete[] pProcessed; - pProcessed = nullptr; -} - -/****************************************************************** - blendToThisClass - blends the texture at xIndex, yIndex to textureClass. - Used by auto edging. The texture at xIndex, yIndex is being - edged into by surrounding textures of textureClass. -*/ -void WorldHeightMapEdit::blendToThisClass(Int xIndex, Int yIndex, - Int textureClass, Int edgeClass) -{ - Int sides, total; - getTexClassNeighbors(xIndex, yIndex, textureClass, &sides, &total); - DEBUG_ASSERTCRASH((total>0),("oops")); // if no neighbors, should not happen. - DEBUG_ASSERTCRASH((sides<3),("oops")); // Should have been squished out earlier. - if (total<1) return; - Int i,j; -// Bool longDiagonal = false; - if (sides==0) { - // corner blend. - for (i=xIndex-1; i=m_width) continue; - for (j=yIndex-1; j=m_height) continue; - if (i==xIndex && j==yIndex) continue; // don't do self. - Int curClass = this->getTextureClass(i, j); - if (curClass == textureClass) { - blendTile(xIndex, yIndex, i, j, -1, edgeClass); - return; // done! - } - } - } - - } else if (sides==1) { - // slide blend. - for (i=xIndex-1; i=m_width) continue; - for (j=yIndex-1; j=m_height) continue; - if (i==xIndex && j==yIndex) continue; // don't do self. - Int curClass = this->getTextureClass(i, j); - if (curClass == textureClass) { - blendTile(xIndex, yIndex, i, j, -1, edgeClass); - return; // done! - } - } - } - - } else if (sides==2) { - // corner funny blend. - Bool top=false; - Bool bottom=false; - Bool left=false; - Bool right=false; - for (i=xIndex-1; i=m_width) continue; - for (j=yIndex-1; j=m_height) continue; - if (i==xIndex && j==yIndex) continue; // don't do self. - Int curClass = this->getTextureClass(i, j); - if (curClass == textureClass) { - if (i==xIndex) { - if (j>yIndex) top=true; - else bottom=true; - } else { - if (iSetFocus(); - if (msg == IDNO) { - return false; - } - doReplace = true; - } - - if (!textureExistsInMap && doReplace) { - if (m_globalTextureClasses[textureClass].numTiles <= m_globalTextureClasses[curTileClass].numTiles) { - Int i; - Int localClass = -1; - for (i=0; igetTextureClassFromNdx(blendInfo.blendNdx)) { - blendInfo.blendNdx = getTileNdxForClass(i, j, textureClass); - blendNdx = findOrCreateBlendTile(&blendInfo); - m_blendTileNdxes[ndx] = blendNdx; - m_cliffInfoNdxes[ndx] = 0; - } - continue; - } - } - } - } else { - CProcessNode *pNodesToProcess = nullptr; - Int nodesProcessed = 0; - pNodesToProcess = new CProcessNode(xIndex, yIndex); - while (pNodesToProcess) { - CProcessNode *pCurNode = pNodesToProcess; - pNodesToProcess = pCurNode->m_next; - pCurNode->m_next = nullptr; - Int ndx = (pCurNode->m_y*m_width)+pCurNode->m_x; - Int blendNdx = m_blendTileNdxes[ndx]; - setTileNdx(pCurNode->m_x, pCurNode->m_y, textureClass, false); - m_blendTileNdxes[ndx] = blendNdx; - m_cliffInfoNdxes[ndx] = 0; // remove any cliff adjustment as we are doing a new texture. - for (i=pCurNode->m_x-1; im_x+2; i++) { - if (i<0) continue; - if (i>=m_width-1) continue; - for (j=pCurNode->m_y-1; jm_y+2; j++) { - if (j<0) continue; - if (j>=m_height-1) continue; - ndx = (j*m_width)+i; - blendNdx = m_blendTileNdxes[ndx]; - if (curTileClass != getTextureClass(i,j,true)) { - /* Check blend */ - if (blendNdx == 0) continue; // no blend. - TBlendTileInfo blendInfo = m_blendedTiles[blendNdx]; - if (curTileClass == this->getTextureClassFromNdx(blendInfo.blendNdx)) { - blendInfo.blendNdx = getTileNdxForClass(i, j, textureClass); - blendNdx = findOrCreateBlendTile(&blendInfo); - m_blendTileNdxes[ndx] = blendNdx; - m_cliffInfoNdxes[ndx] = 0; - } - continue; - } - if (i!=pCurNode->m_x && j!=pCurNode->m_y) { - continue; // skip corners. - } - if (curTileClass == getTextureClass(i,j,true)) { - // Matches the current fill, so flood into it, - CProcessNode *pNewNode = new CProcessNode(i,j); - pNewNode->m_next = pNodesToProcess; - pNodesToProcess = pNewNode; - } - } - } - delete pCurNode; - nodesProcessed++; - } - - } - - REF_PTR_RELEASE(m_terrainTex); - REF_PTR_RELEASE(m_alphaEdgeTex); - return(true); -} - - -/****************************************************************** - resetResources - releases textures so things like device reset can be done. -*/ -void WorldHeightMapEdit::resetResources() -{ - REF_PTR_RELEASE(m_terrainTex); - REF_PTR_RELEASE(m_alphaEdgeTex); -} - -/****************************************************************** - reloadTextures - reloads textures from files. -*/ -void WorldHeightMapEdit::reloadTextures() -{ - Int i; - for (i=0; iReleaseResources(); - TheTerrainRenderObject->ReAcquireResources(); - } - REF_PTR_RELEASE(m_terrainTex); - REF_PTR_RELEASE(m_alphaTerrainTex); - REF_PTR_RELEASE(m_alphaEdgeTex); -} - -/****************************************************************** - showTileStatusInfo - provides human readable tile statistics. -*/ -void WorldHeightMapEdit::showTileStatusInfo() -{ - CString message; - Int tilesPerRow = TEXTURE_WIDTH/(2*TILE_PIXEL_EXTENT+TILE_OFFSET); - Int availableTiles = 4 * tilesPerRow * tilesPerRow; - Int availableBlends = NUM_BLEND_TILES; - - CString tmp; - tmp.Format("Base tiles used %d of %d (%d%%)\n", m_numBitmapTiles, availableTiles, - (m_numBitmapTiles*100+50)/availableTiles); - message += tmp; - tmp.Format("Blend tiles used %d of %d (%d%%)\n", m_numBlendedTiles, availableBlends, - (m_numBlendedTiles*100+50)/availableBlends); - message += tmp; - ::AfxMessageBox(message); -} - - -/****************************************************************** - setHeight - This sets the height, and adjusts the cliff flag for the cells affected. -*/ -void WorldHeightMapEdit::setHeight(Int xIndex, Int yIndex, UnsignedByte height) { - Int ndx = (yIndex*m_width)+xIndex; - if ((ndx>=0) && (ndxm_tileNdxes[i]; - Int texClass = getTextureClassFromNdx(texNdx); - DEBUG_ASSERTCRASH((texClass>=0),("oops")); - if (texClass<0) texClass=0; - m_tileNdxes[i] = texClass; - } - - // Run through all the blend tiles changing tile index to class. - TBlendTileInfo blendInfo[NUM_BLEND_TILES]; - for (i=1; i=0),("oops")); - if (blendInfo[i].blendNdx<0) blendInfo[i].blendNdx=0; - } - - // Run through all the blend tiles changing tile index to class. - for (i=1; i0),("oops")); - } - if (newBlendNdx < 0) newBlendNdx = 0; - } - } - m_blendTileNdxes[i] = blendNdx = newBlendNdx; - - //Optimize blend descriptions to remove redundant ones. - if (extraBlendNdx == 0) { - newBlendNdx = 0; - } else { - TBlendTileInfo curBlendInfo = blendInfo[extraBlendNdx]; - curBlendInfo.blendNdx = getBlendTileNdxForClass(x,y,curBlendInfo.blendNdx); - //only allow 3-way blend if base already blended and if base - //does not already contain the same texture - if (!blendNdx || curBlendInfo.blendNdx == m_tileNdxes[i] || - m_blendedTiles[blendNdx].blendNdx == curBlendInfo.blendNdx) - newBlendNdx = 0; - else - { newBlendNdx = findOrCreateBlendTile(&curBlendInfo); - if (m_numBlendedTiles < NUM_BLEND_TILES) { - DEBUG_ASSERTCRASH((newBlendNdx>0),("oops")); - } - if (newBlendNdx < 0) newBlendNdx = 0; - } - } - m_extraBlendTileNdxes[i] = newBlendNdx; - - } - } - // Run through all the blend tiles changing tile index to class. - for (i=1; ix = 0; - pObjOffset->y = 0; - pObjOffset->z = 0; - Int xOffset = m_borderSize-newBorder; - Int sizeChange = (m_width-2*m_borderSize) - (newXSize - 2*newBorder); - if (anchorLeft) { - // Nothing - same xOffset. - } else if (anchorRight) { - xOffset += sizeChange; - pObjOffset->x = -sizeChange*MAP_XY_FACTOR; - } else { - xOffset += (sizeChange)/2; - pObjOffset->x = -((sizeChange)/2)*MAP_XY_FACTOR; - } - - Int yOffset = m_borderSize - newBorder; - sizeChange = (m_height-2*m_borderSize) - (newYSize - 2*newBorder); - if (anchorBottom) { - // Nothing - same yOffset. - } else if (anchorTop) { - yOffset += sizeChange; - pObjOffset->y = -sizeChange*MAP_XY_FACTOR; - } else { - yOffset += (sizeChange)/2; - pObjOffset->y = -((sizeChange)/2)*MAP_XY_FACTOR; - } - - - Short *tileNdxes = new Short[newDataSize]; - Short *blendTileNdxes = new Short[newDataSize]; - Short *extraBlendTileNdxes = new Short[newDataSize]; - UnsignedByte *data = new UnsignedByte[newDataSize]; - Short *cliffInfoNdxes = new Short[newDataSize]; - - Int i, j; - for (i=0; i=m_width-1) { - oldI=m_width-2; - inRange = false; - } - if (oldI<0) { - oldI = 0; - inRange = false; - } - Int oldJ = j+yOffset; - if (oldJ>=m_height-1) { - oldJ = m_height-2; - inRange = false; - } - if (oldJ<0) { - oldJ = 0; - inRange = false; - } - Int oldNdx = oldI+oldJ*m_width; - if (inRange) { - data[newNdx] = m_data[oldNdx]; - tileNdxes[newNdx] = m_tileNdxes[oldNdx]; - blendTileNdxes[newNdx] = m_blendTileNdxes[oldNdx]; - extraBlendTileNdxes[newNdx] = m_extraBlendTileNdxes[oldNdx]; - cliffInfoNdxes[newNdx] = m_cliffInfoNdxes[oldNdx]; - } else { - data[newNdx] = m_data[oldNdx]; - tileNdxes[newNdx] = m_tileNdxes[oldNdx]; - blendTileNdxes[newNdx] = 0; - extraBlendTileNdxes[newNdx] = 0; - cliffInfoNdxes[newNdx] = 0; - } - } - } - - delete(m_tileNdxes); - delete(m_cliffInfoNdxes); - delete(m_blendTileNdxes); - delete(m_extraBlendTileNdxes); - delete(m_data); - m_tileNdxes = tileNdxes; - m_blendTileNdxes = blendTileNdxes; - m_extraBlendTileNdxes = extraBlendTileNdxes; - m_cliffInfoNdxes = cliffInfoNdxes; - m_data = data; - m_width = newXSize; - m_height = newYSize; - m_borderSize = newBorder; - m_dataSize = newDataSize; - delete(m_cellCliffState); - delete(m_cellFlipState); - Int numBytesX = (m_width+7)/8; //how many bytes to fit all bitflags - m_flipStateWidth=numBytesX; - - m_cellFlipState = MSGNEW("WorldHeightMapEdit::resize") UnsignedByte[numBytesX*m_height]; - m_cellCliffState = MSGNEW("WorldHeightMapEdit::resize") UnsignedByte[numBytesX*m_height]; - - // Verify index remapping - for(i=0; i= m_numCliffInfo) { - m_cliffInfoNdxes[i] = 0; - } - if (m_blendTileNdxes[i]<0 || m_blendTileNdxes[i]>= m_numBlendedTiles) { - m_blendTileNdxes[i] = 0; - } - if (m_extraBlendTileNdxes[i]<0 || m_extraBlendTileNdxes[i]>= m_numBlendedTiles) { - m_extraBlendTileNdxes[i] = 0; - } - } - initCliffFlagsFromHeights(); - - optimizeTiles(); - return(true); -} - - -/** Returns true if the texture class is used in the current -map. If false, the texture is not used or loaded in the -current map. */ -Bool WorldHeightMapEdit::isTexClassUsed(Int textureClass) -{ - Int i; - for (i=0; i= 0),("oops")); - DEBUG_ASSERTCRASH((globalClass < m_numGlobalTextureClasses),("oops")); - if (m_globalTextureClasses[globalClass].forDebugOnly_fileTextureClass != j) { - DEBUG_ASSERTCRASH((m_globalTextureClasses[globalClass].forDebugOnly_fileTextureClass == -1),("oops")); - m_globalTextureClasses[globalClass].forDebugOnly_fileTextureClass = j; - } - DEBUG_ASSERTCRASH((m_textureClasses[j].width == m_globalTextureClasses[globalClass].width),("oops")); - DEBUG_ASSERTCRASH((m_textureClasses[j].numTiles == m_globalTextureClasses[globalClass].numTiles),("oops")); - TileData *pTile = m_sourceTiles[m_textureClasses[j].firstTile]; - DEBUG_ASSERTCRASH((pTile == m_globalTextureClasses[globalClass].tiles[0]),("oops")); - DEBUG_ASSERTCRASH((j == m_globalTextureClasses[globalClass].forDebugOnly_fileTextureClass),("oops")); - } - - for (i=0; i= 0) { - DEBUG_ASSERTCRASH((localClass < m_numTextureClasses),("oops")); - DEBUG_ASSERTCRASH((m_textureClasses[localClass].globalTextureClass == i),("oops")); - DEBUG_ASSERTCRASH((m_textureClasses[localClass].width == m_globalTextureClasses[i].width),("oops")); - DEBUG_ASSERTCRASH((m_textureClasses[localClass].numTiles == m_globalTextureClasses[i].numTiles),("oops")); - TileData *pTile = m_sourceTiles[m_textureClasses[localClass].firstTile]; - DEBUG_ASSERTCRASH((pTile == m_globalTextureClasses[i].tiles[0]),("oops")); - DEBUG_ASSERTCRASH((m_textureClasses[localClass].numTiles == m_globalTextureClasses[i].numTiles),("oops")); - } - } - - for (i=0; i= 0),("oops")); - if (m_textureClasses[i].globalTextureClass >= 0) { - AsciiString path1 = m_globalTextureClasses[m_textureClasses[i].globalTextureClass].name; - AsciiString path2 = m_textureClasses[i].name; - DEBUG_ASSERTCRASH(path1==path2,("oops")); - DEBUG_ASSERTCRASH((m_globalTextureClasses[m_textureClasses[i].globalTextureClass].forDebugOnly_fileTextureClass==i),("oops")); - } - } - - for (i=0; im_tileNdxes[i]; - DEBUG_ASSERTCRASH(( (texNdx>>2) < m_numBitmapTiles),("oops")); - Int texClass = getTextureClassFromNdx(texNdx); - DEBUG_ASSERTCRASH((texClass>=0),("oops")); - } -#endif -} - -void WorldHeightMapEdit::addObject(MapObject *pMapObj) -{ - MapObject *newObj = pMapObj->duplicate(); - newObj->setNextMap(MapObject::TheMapObjectListPtr); - MapObject::TheMapObjectListPtr = newObj; -} - -void WorldHeightMapEdit::removeFirstObject() -{ - MapObject *firstObj = MapObject::TheMapObjectListPtr; - MapObject::TheMapObjectListPtr = firstObj->getNext(); - firstObj->setNextMap(nullptr); // so we don't delete the whole list. - deleteInstance(firstObj); -} - -//============================================================================= -// W3DRoadBuffer::selectDuplicates -//============================================================================= -/** Selects any duplicate objects. */ -//============================================================================= -Bool WorldHeightMapEdit::selectDuplicates() -{ - const float DELTA = 0.05f; - MapObject *firstObj = MapObject::TheMapObjectListPtr; - MapObject *pObj; -// MapObject *pPrevRoad = nullptr; - Bool anySelected = false; - for (pObj=firstObj; pObj; pObj=pObj->getNext()) { - pObj->setSelected(false); - MapObject *prevObj; - Coord3D curLoc = *pObj->getLocation(); - - for (prevObj=firstObj; prevObj != pObj; prevObj=prevObj->getNext()) { - if (pObj->getName() != prevObj->getName()) { - continue; // names don't match. - } - if (pObj->isWaypoint()) { - // Don't delete duplicate waypoints. - continue; - } - Coord3D prevLoc = *prevObj->getLocation(); - if (abs(curLoc.x-prevLoc.x)>DELTA) { - continue; // locations don't match. - } - if (abs(curLoc.y-prevLoc.y)>DELTA) { - continue; // locations don't match. - } - - if (pObj->getFlag(FLAG_ROAD_FLAGS)) { - if (pObj->getNext() == nullptr) continue; - if (!pObj->getFlag(FLAG_ROAD_POINT1)) { - continue; - } - if (!prevObj->getFlag(FLAG_ROAD_POINT1)) { - continue; - } - Coord3D nextLoc = *pObj->getNext()->getLocation(); - prevObj = prevObj->getNext(); - if (!prevObj) continue; - if (!prevObj->getFlag(FLAG_ROAD_POINT2)) { - continue; - } - prevLoc = *prevObj->getLocation(); - if (abs(nextLoc.x-prevLoc.x)>DELTA) { - continue; // locations don't match. - } - if (abs(nextLoc.y-prevLoc.y)>DELTA) { - continue; // locations don't match. - } - pObj->setSelected(true); - pObj = pObj->getNext(); - pObj->setSelected(true); - anySelected = true; - break; - } else { - pObj->setSelected(true); - anySelected = true; - break; - } - } - } - return anySelected; -} - -//============================================================================= -// selectSimilar -//============================================================================= -/** Selects any similar objects. */ -//============================================================================= -Bool WorldHeightMapEdit::selectSimilar() -{ -// const float DELTA = 0.05f; - MapObject *firstObj = MapObject::TheMapObjectListPtr; - MapObject *selectedObj; - MapObject *otherObj; - Bool anySelected = false; - for (selectedObj=firstObj; selectedObj; selectedObj=selectedObj->getNext()) { - if (selectedObj->getFlag(FLAG_ROAD_FLAGS)) { - continue; - } - if (selectedObj->isSelected()) { - anySelected = true; - break; - } - } - if (!anySelected) { - return false; - } - - for (otherObj=firstObj; otherObj != nullptr; otherObj=otherObj->getNext()) { - if (otherObj->getName() != selectedObj->getName()) { - continue; // names don't match. - } - - if (otherObj->getFlag(FLAG_ROAD_FLAGS)) { - continue; - } - - Bool exists; - AsciiString layerName = otherObj->getProperties()->getAsciiString(TheKey_objectLayer, &exists); - if (exists && TheLayersList->isLayerHidden(layerName)) { - continue; - } - - otherObj->setSelected(true); - } - return anySelected; -} - -//============================================================================= -// selectInvalidTeam -//============================================================================= -/** Selects any objects with invalid teams. */ -//============================================================================= -Bool WorldHeightMapEdit::selectInvalidTeam() -{ - Int i; - AsciiString name; - - // make a table of valid team names - std::set validTeamNames; - std::set invalidTeamNames; - std::set::const_iterator it; - for (i = 0; i < TheSidesList->getNumTeams(); i++) - { - name = TheSidesList->getTeamInfo(i)->getDict()->getAsciiString(TheKey_teamName); - if (name == NEUTRAL_TEAM_INTERNAL_STR) - name = NEUTRAL_TEAM_UI_STR; - validTeamNames.insert(name); - } - - MapObject *obj; - Bool anySelected = FALSE; - for (obj=MapObject::TheMapObjectListPtr; obj; obj=obj->getNext()) { - if (obj->getFlag(FLAG_ROAD_FLAGS)) { - continue; - } - - const Dict *d = obj->getProperties(); - if (d) - { - Bool exists; - name = d->getAsciiString(TheKey_originalOwner, &exists); - if (!exists) - { - invalidTeamNames.insert(""); - obj->setSelected(true); - anySelected = TRUE; - continue; - } - - if (name == NEUTRAL_TEAM_INTERNAL_STR) - name = NEUTRAL_TEAM_UI_STR; - - it = validTeamNames.find(name); - if (it == validTeamNames.end()) - { - invalidTeamNames.insert(name); - obj->setSelected(true); - anySelected = TRUE; - } - } - } - - AsciiString report; - AsciiString line; - -#if 0 - // I'm removing this because its causing buffer overflows, and we're really interested in - // teams that are invalid anyways. I've confirmed that this is okay behavior with JL. (jkmcd) - for (it=validTeamNames.begin(); it!=validTeamNames.end(); ++it) - { - line.format("Valid team '%s'\n", it->str()); - report.concat(line); - } - report.concat("\n"); -#endif - - for (it=invalidTeamNames.begin(); it!=invalidTeamNames.end(); ++it) - { - line.format("Invalid team '%s'\n", it->str()); - report.concat(line); - } - - if (anySelected) - { - DEBUG_LOG(("%s", report.str())); - MessageBox(nullptr, report.str(), "Missing team report", MB_OK); - } - - return anySelected; -} - - - - - -AsciiString WorldHeightMapEdit::getTexClassUiName(int ndx) -{ - return(m_globalTextureClasses[ndx].uiName); -} - -static const Real HEIGHT_SCALE = MAP_HEIGHT_SCALE / MAP_XY_FACTOR; -static const Real STRETCH_LIMIT = 1.5f; // If it is stretching less than this, don't adjust. -static inline Int IABS(Int x) { if (x>=0) return x; return -x;}; - -static const Real TEX_PER_CELL = 32.0f/TEXTURE_WIDTH; // we use 32 texels per cell. - -static const Real MIN_U_SPAN = TEX_PER_CELL * 0.4f; - -static Bool debugToggle = true; - -/****************************************************************** - doCliffAdjustment - Does a cliff adjustment the region at xIndex, yIndex. -*/ -Bool WorldHeightMapEdit::doCliffAdjustment(Int xIndex, Int yIndex) -{ - - debugToggle = !debugToggle; - - Int ndx = (yIndex*m_width)+xIndex; - Int curTileClass = getTextureClass(xIndex, yIndex, true); - if (curTileClass < 0) { - return(false); - } - Real textureClassExtent = m_globalTextureClasses[curTileClass].width*TILE_PIXEL_EXTENT; - textureClassExtent /= TEXTURE_WIDTH; - Real startU = textureClassExtent/2; // Center in the texture. - Real startV = 0; // We'll adjust the V values later. - - Int i, j; - UnsignedByte *pProcessed = new UnsignedByte[m_dataSize]; - for (i=0; im_next; - pCurNode->m_next = nullptr; - - if (pNodesToProcess == nullptr) { - if (pMutantNodes) { - pNodesToProcess = pMutantNodes; - pMutantNodes = pMutantNodes->m_next; - pNodesToProcess->m_next = nullptr; - pProcessTail = pNodesToProcess; - } - } - - ndx = (pCurNode->m_y*m_width)+pCurNode->m_x; - Bool skip = pProcessed[ndx]; - Bool classMatch = false; - if (curTileClass == getTextureClass(pCurNode->m_x,pCurNode->m_y,true)) { - classMatch = true; - } - Int blend = m_blendTileNdxes[ndx]; - if (blend && curTileClass == getTextureClassFromNdx(m_blendedTiles[blend].blendNdx)) { - classMatch = true; - } - if (!classMatch) skip = true; - if (skip) { - delete pCurNode; - continue; - } - - static Real HEIGHT_SCALE = MAP_HEIGHT_SCALE / MAP_XY_FACTOR; - static Real STRETCH_LIMIT = 1.5f; // If it is stretching less than this, don't adjust. - Int h0 = m_data[ndx]; - Int h1 = m_data[ndx+1]; - Int h2 = m_data[ndx+m_width+1]; - Int h3 = m_data[ndx+m_width]; - - Int deltaH, maxH; - - maxH = IABS(h0-h1); - deltaH = IABS(h1-h2); - if (deltaH>maxH)maxH = deltaH; - deltaH = IABS(h2-h3); - if (deltaH>maxH)maxH = deltaH; - deltaH = IABS(h3-h0); - if (deltaH>maxH)maxH = deltaH; - - Bool isCliff = maxH*HEIGHT_SCALE > STRETCH_LIMIT/2.0f; - - Bool flip = IABS(h2-h0) >= IABS(h3-h1); - - // Convert h1-3 to deltas. - h1 -= h0; - h2 -= h0; - h3 -= h0; - h0 = 0; - - - Int minHeightDelta = 0.7f/HEIGHT_SCALE; - - if (!isCliff) { - // Handle the uncliffy nodes in a moment. - pCurNode->m_next = pUnCliffyNodes; - pUnCliffyNodes = pCurNode; - continue; - } - - if (isCliff) { - TCliffInfo cliffInfo; - if (flip) { - Vector2 uVec((h3-h0), -(h1-h0)); - Vector2 uVec2((h2-h1), -(h2-h3)); - if (uVec.X==0 && uVec.Y==0) { - uVec = uVec2; - } - if (uVec2.X==0 && uVec2.Y==0) { - uVec2 = uVec; - } - - if (IABS(h2-h1)delta2) delta = delta2; - if (h2delta2) delta = delta2; - if (h0delta2) delta = delta2; - if (h1delta2) delta = delta2; - if (h3m_x, pCurNode->m_y, pProcessed, cliffInfo); - - /*Bool fits =*/ adjustForTiling(cliffInfo, textureClassExtent); - - Int cliffNdx=addCliffInfo(&cliffInfo); - m_cliffInfoNdxes[ndx] = cliffNdx; - pProcessed[ndx] = true; - if (uvRange.lo.x>cliffInfo.u0) uvRange.lo.x=cliffInfo.u0; - if (uvRange.lo.x>cliffInfo.u1) uvRange.lo.x=cliffInfo.u1; - if (uvRange.lo.x>cliffInfo.u2) uvRange.lo.x=cliffInfo.u2; - if (uvRange.lo.x>cliffInfo.u3) uvRange.lo.x=cliffInfo.u3; - if (uvRange.lo.y>cliffInfo.v0) uvRange.lo.y=cliffInfo.v0; - if (uvRange.lo.y>cliffInfo.v1) uvRange.lo.y=cliffInfo.v1; - if (uvRange.lo.y>cliffInfo.v2) uvRange.lo.y=cliffInfo.v2; - if (uvRange.lo.y>cliffInfo.v3) uvRange.lo.y=cliffInfo.v3; - if (uvRange.hi.xm_x-1; im_x+2; i++) { - if (i<0) continue; - if (i>=m_width-1) continue; - for (j=pCurNode->m_y-1; jm_y+2; j++) { - if (i==pCurNode->m_x && j==pCurNode->m_y) continue; - if (i!=pCurNode->m_x && j!=pCurNode->m_y) continue; - if (j<0) continue; - if (j>=m_height-1) continue; - ndx = (j*m_width)+i; - if (pProcessed[ndx]) continue; - CProcessNode *pNewNode = new CProcessNode(i,j); - DEBUG_LOG(("Adding node %d, %d", i, j)); - pNodes[k++] = pNewNode; - Real dx, dy; - if (im_x) { - // left. - dx = cliffInfo.u3 - cliffInfo.u0; - dy = cliffInfo.v3 - cliffInfo.v0; - } else if (i>pCurNode->m_x) { - // right. - dx = cliffInfo.u2 - cliffInfo.u1; - dy = cliffInfo.v2 - cliffInfo.v1; - } else if (jm_y) { - // bottom. - dx = cliffInfo.u1 - cliffInfo.u0; - dy = cliffInfo.v1 - cliffInfo.v0; - } else if (jm_y) { - // top. - dx = cliffInfo.u2 - cliffInfo.u3; - dy = cliffInfo.v2 - cliffInfo.v3; - } - pNewNode->m_len = dx*dx + dy*dy; - } - } - while (k) { - Real maxLen = -1; - Int curNdx = -1; - for (i=0; im_len > maxLen) { - curNdx = i; - maxLen = pNodes[i]->m_len; - } - } - } - if (curNdx>=0) { - if (cliffInfo.mutant) { - pNodes[curNdx]->m_next = pMutantNodes; - pMutantNodes = pNodes[curNdx]; - pNodes[curNdx] = nullptr; - } else { - if (pProcessTail) { - pProcessTail->m_next = pNodes[curNdx]; - } - pProcessTail = pNodes[curNdx]; - if (pNodesToProcess == nullptr) { - pNodesToProcess = pNodes[curNdx]; - } - pNodes[curNdx] = nullptr; - } - } else { - k = 0; - } - } - - - nodesProcessed++; - //if (nodesProcessed>2) break; - } - delete pCurNode; - } - - while (pUnCliffyNodes) { - CProcessNode *pCurNode = pUnCliffyNodes; - pUnCliffyNodes = pCurNode->m_next; - pCurNode->m_next = nullptr; - ndx = (pCurNode->m_y*m_width)+pCurNode->m_x; - if (!pProcessed[ndx]) { - m_cliffInfoNdxes[ndx] = 0; - updateFlatCellForAdjacentCliffs(pCurNode->m_x, pCurNode->m_y, curTileClass, pProcessed); - pProcessed[ndx] = true; - } - delete pCurNode; - } - - if (nodesProcessed) { - Real vDelta = (-textureClassExtent/2) - (uvRange.hi.y + uvRange.lo.y)/2; - for (i=0; icliffInfo.u1) minU=cliffInfo.u1; - if (maxUcliffInfo.u2) minU=cliffInfo.u2; - if (maxUcliffInfo.u3) minU=cliffInfo.u3; - if (maxU textureWidth*0.5) { - Real mid = (minU + maxU) / 2.0f; - if (-minU > maxU-textureWidth) { - // biased negative, so add. - if (cliffInfo.u0 < mid) cliffInfo.u0 += textureWidth; - if (cliffInfo.u1 < mid) cliffInfo.u1 += textureWidth; - if (cliffInfo.u2 < mid) cliffInfo.u2 += textureWidth; - if (cliffInfo.u3 < mid) cliffInfo.u3 += textureWidth; - } else { - // biased past tex width, so add. - if (cliffInfo.u0 > mid) cliffInfo.u0 -= textureWidth; - if (cliffInfo.u1 > mid) cliffInfo.u1 -= textureWidth; - if (cliffInfo.u2 > mid) cliffInfo.u2 -= textureWidth; - if (cliffInfo.u3 > mid) cliffInfo.u3 -= textureWidth; - } - // Recalculate min/max - minU = cliffInfo.u0; - maxU = minU; - if (minU>cliffInfo.u1) minU=cliffInfo.u1; - if (maxUcliffInfo.u2) minU=cliffInfo.u2; - if (maxUcliffInfo.u3) minU=cliffInfo.u3; - if (maxU= textureWidth-delta) { - cliffInfo.u0 -= textureWidth; - cliffInfo.u1 -= textureWidth; - cliffInfo.u2 -= textureWidth; - cliffInfo.u3 -= textureWidth; - minU -= textureWidth; - maxU -= textureWidth; - } - if (maxU < delta) { - cliffInfo.u0 += textureWidth; - cliffInfo.u1 += textureWidth; - cliffInfo.u2 += textureWidth; - cliffInfo.u3 += textureWidth; - minU += textureWidth; - maxU += textureWidth; - } - - - Real uBorder = TEX_PER_CELL * 0.5; - if (minU>=uBorder && maxU=-delta && maxU<= textureWidth+delta) { - if (cliffInfo.u0textureWidth-uBorder) cliffInfo.u0 = textureWidth; - if (cliffInfo.u1>textureWidth-uBorder) cliffInfo.u1 = textureWidth; - if (cliffInfo.u2>textureWidth-uBorder) cliffInfo.u2 = textureWidth; - if (cliffInfo.u3>textureWidth-uBorder) cliffInfo.u3 = textureWidth; - return true; - } - - if (minU < textureWidth-delta && maxU>textureWidth+delta) { - cliffInfo.u0 -= textureWidth; - cliffInfo.u1 -= textureWidth; - cliffInfo.u2 -= textureWidth; - cliffInfo.u3 -= textureWidth; - minU -= textureWidth; - maxU -= textureWidth; - } - TCliffInfo tmpCliff = cliffInfo; -// Bool doOffset = false; - Real offset; - - DEBUG_ASSERTLOG(minU<-delta && maxU > delta, ("Oops, wrong.")) ; - - // Straddles the 0 line. - if (maxU > -minU) { - offset = -minU; - // push min up to 0 - if (cliffInfo.u0<0) cliffInfo.u0 = 0; - if (cliffInfo.u1<0) cliffInfo.u1 = 0; - if (cliffInfo.u2<0) cliffInfo.u2 = 0; - if (cliffInfo.u3<0) cliffInfo.u3 = 0; - } else { - // push max down to 0, & offset. - offset = -maxU; - if (cliffInfo.u0>0) cliffInfo.u0 = 0; - if (cliffInfo.u1>0) cliffInfo.u1 = 0; - if (cliffInfo.u2>0) cliffInfo.u2 = 0; - if (cliffInfo.u3>0) cliffInfo.u3 = 0; - cliffInfo.u0 += textureWidth; - cliffInfo.u1 += textureWidth; - cliffInfo.u2 += textureWidth; - cliffInfo.u3 += textureWidth; - } - Real triMinU; - Real triMaxU; - Bool tooSmall = false; - triMinU = cliffInfo.u0; - triMaxU = triMinU; - if (triMinU>cliffInfo.u1) triMinU=cliffInfo.u1; - if (triMaxUcliffInfo.u3) triMinU=cliffInfo.u3; - if (triMaxUcliffInfo.u2) triMinU=cliffInfo.u2; - if (triMaxUcliffInfo.u3) triMinU=cliffInfo.u3; - if (triMaxUcliffInfo.u1) triMinU=cliffInfo.u1; - if (triMaxUcliffInfo.u2) triMinU=cliffInfo.u2; - if (triMaxUcliffInfo.u2) triMinU=cliffInfo.u2; - if (triMaxUcliffInfo.u3) triMinU=cliffInfo.u3; - if (triMaxU3*TEX_PER_CELL) return true; - if (u2==0 && u1>3*TEX_PER_CELL) return true; - return false; -} - -void WorldHeightMapEdit::updateForAdjacentCliffs(Int xIndex, Int yIndex, - UnsignedByte *pProcessed, TCliffInfo &cliffInfo) -{ -#define PROMOTE_DIAGONALS 0 // Don't promote them. -#define ADJUST_SNAPS 1 - TCliffInfo tmpCliff = cliffInfo; - Int useMutant; - for (useMutant=0; useMutant<2; useMutant++) { - Bool lock0 = false; - Bool lock1 = false; - Bool lock2 = false; - Bool lock3 = false; - Bool anyMutant = false; - Int i, j; - for (i=xIndex-1; i=m_width-1) continue; - for (j=yIndex-1; j=m_height-1) continue; - Int ndx = (j*m_width)+i; - if (!pProcessed[ndx]) continue; - if (m_cliffInfoNdxes[ndx]) { - TCliffInfo info = m_cliffInfo[m_cliffInfoNdxes[ndx]]; - if (info.mutant) { - anyMutant = true; - if (!useMutant) { - continue; // don't propagate warped stuff. - } - } - Bool shifted = false; - if (i==xIndex){ - if (jtmpCliff.u1) minU=tmpCliff.u1; - if (maxUtmpCliff.u3) minU=tmpCliff.u3; - if (maxUtmpCliff.u2) minU=tmpCliff.u2; - if (maxUtmpCliff.u3) minU=tmpCliff.u3; - if (maxUtmpCliff.u1) minU=tmpCliff.u1; - if (maxUtmpCliff.u2) minU=tmpCliff.u2; - if (maxUtmpCliff.u2) minU=tmpCliff.u2; - if (maxUtmpCliff.u3) minU=tmpCliff.u3; - if (maxU=0 && ndxm_dataSize),("oops")); - if (ndx<0 || ndx >= this->m_dataSize) return; - Bool okToProcess = true; - if (pProcessed && pProcessed[ndx]) okToProcess = false; - if (!pProcessed && m_cliffInfoNdxes[ndx]) { - if (curTileClass != getTextureClassFromNdx(m_cliffInfo[m_cliffInfoNdxes[ndx]].tileIndex)) { - okToProcess = false; - } - } - if (!okToProcess) return; - Real textureClassExtent = m_globalTextureClasses[curTileClass].width*TILE_PIXEL_EXTENT; - textureClassExtent /= TEXTURE_WIDTH; - Int i, j; - for (i=xIndex-1; i=m_width-1) continue; - for (j=yIndex-1; j=m_height-1) continue; - Int ndx = (j*m_width)+i; - if (m_cliffInfoNdxes[ndx]) { - TCliffInfo info = m_cliffInfo[m_cliffInfoNdxes[ndx]]; - okToProcess = true; - if (pProcessed && !pProcessed[ndx]) okToProcess = false; - if (info.mutant) okToProcess = false; - if (!pProcessed && m_cliffInfoNdxes[ndx]) { - if (curTileClass != getTextureClassFromNdx(info.tileIndex)) { - okToProcess = false; - } - } - if (!okToProcess) continue; - Bool shifted = false; - if (i==xIndex){ - if (jtmpCliff.u1) minU=tmpCliff.u1; - if (maxUtmpCliff.u2) minU=tmpCliff.u2; - if (maxUtmpCliff.u3) minU=tmpCliff.u3; - if (maxU tmpCliff.v2-tmpCliff.v0) { - lock1 = lock2 = false; - } else { - lock3 = lock2 = false; - } - lockCount = 2; - } - } - - - - if (lockCount==4) { - adjustForTiling(tmpCliff, textureClassExtent); - tmpCliff.tileIndex = getFirstTile(curTileClass)<<2; - Int cliffNdx=addCliffInfo(&tmpCliff); - m_cliffInfoNdxes[yIndex*m_width + xIndex] = cliffNdx; - return; // all were adjusted. - } - - Vector2 xVec(0,0); - Vector2 yVec(0,0); - Bool gotXVec = false; - Bool gotYVec = false; - if (lock0 && lock1) { - gotXVec = true; - xVec.U = tmpCliff.u1 - tmpCliff.u0; - xVec.V = tmpCliff.v1 - tmpCliff.v0; - } - if (lock1 && lock2) { - gotYVec = true; - yVec.U = tmpCliff.u2 - tmpCliff.u1; - yVec.V = tmpCliff.v2 - tmpCliff.v1; - } - if (lock2 && lock3) { - gotXVec = true; - xVec.U = tmpCliff.u2 - tmpCliff.u3; - xVec.V = tmpCliff.v2 - tmpCliff.v3; - } - if (lock3 && lock0) { - gotYVec = true; - yVec.U = tmpCliff.u3 - tmpCliff.u0; - yVec.V = tmpCliff.v3 - tmpCliff.v0; - } - - if (!gotXVec && !gotYVec) { - DEBUG_LOG(("Unexpected. jba")); - return; - } - if (gotXVec && !gotYVec) { - yVec.V = -xVec.U; - yVec.U = xVec.V; - } - if (gotYVec && !gotXVec) { - xVec.V = yVec.U; - xVec.U = -yVec.V; - } - - - if (!lock0) { - if (lock1) { - tmpCliff.u0 = tmpCliff.u1 - xVec.U; - tmpCliff.v0 = tmpCliff.v1 - xVec.V; - } else if (lock3) { - tmpCliff.u0 = tmpCliff.u3 - yVec.U; - tmpCliff.v0 = tmpCliff.v3 - yVec.V; - } - } - if (!lock1) { - if (lock0) { - tmpCliff.u1 = tmpCliff.u0 + xVec.U; - tmpCliff.v1 = tmpCliff.v0 + xVec.V; - } else if (lock2) { - tmpCliff.u1 = tmpCliff.u2 - yVec.U; - tmpCliff.v1 = tmpCliff.v2 - yVec.V; - } - } - if (!lock2) { - if (lock3) { - tmpCliff.u2 = tmpCliff.u3 + xVec.U; - tmpCliff.v2 = tmpCliff.v3 + xVec.V; - } else if (lock1) { - tmpCliff.u2 = tmpCliff.u1 + yVec.U; - tmpCliff.v2 = tmpCliff.v1 + yVec.V; - } - } - if (!lock3) { - if (lock2) { - tmpCliff.u3 = tmpCliff.u2 - xVec.U; - tmpCliff.v3 = tmpCliff.v2 - xVec.V; - } else if (lock0) { - tmpCliff.u3 = tmpCliff.u0 + yVec.U; - tmpCliff.v3 = tmpCliff.v0 + yVec.V; - } - } - tmpCliff.mutant = false; - tmpCliff.tileIndex = getFirstTile(curTileClass)<<2; - adjustForTiling(tmpCliff, textureClassExtent); - Int cliffNdx=addCliffInfo(&tmpCliff); - m_cliffInfoNdxes[yIndex*m_width + xIndex] = cliffNdx; -} - - -Int WorldHeightMapEdit::addCliffInfo(TCliffInfo *pCliffInfo) -{ - if (m_numCliffInfo>=NUM_CLIFF_INFO) { - m_warnTooManyBlend = true; - return 0; // out of new cliffs - } - Short newNdx = m_numCliffInfo; - m_cliffInfo[newNdx] = *pCliffInfo; - m_numCliffInfo++; - - return(newNdx); - -} - -Int WorldHeightMapEdit::getNumBoundaries() const -{ - return m_boundaries.size(); -} - -void WorldHeightMapEdit::getBoundary(Int ndx, ICoord2D* border) const -{ - if (!border || ndx < 0 || ndx >= m_boundaries.size()) { - DEBUG_CRASH(("Invalid border request. jkmcd")); - return; - } - - (*border) = m_boundaries[ndx]; -} - -void WorldHeightMapEdit::addBoundary(ICoord2D* boundaryToAdd) -{ - if (!boundaryToAdd) { - DEBUG_CRASH(("Invalid border addition. jkmcd")); - return; - } - - m_boundaries.push_back((*boundaryToAdd)); -} - -void WorldHeightMapEdit::changeBoundary(Int ndx, ICoord2D *border) -{ - if (!border || ndx < 0 || ndx >= m_boundaries.size()) { - DEBUG_CRASH(("Invalid border change request. jkmcd")); - return; - } - - m_boundaries[ndx] = (*border); -} - -void WorldHeightMapEdit::removeLastBoundary() -{ - if (m_boundaries.empty()) { - DEBUG_CRASH(("Invalid border remove request. jkmcd")); - return; - } - - m_boundaries.pop_back(); -} - -void WorldHeightMapEdit::findBoundaryNear(Coord3D *pt, float okDistance, Int *outNdx, Int *outHandle) -{ - if (!outNdx) { - return; - } - - if (!pt) { - (*outNdx) = -1; - } - - int numBoundaries = m_boundaries.size(); - for (int i = 0; i < numBoundaries; ++i) { - Vector3 vecPt(pt->x / MAP_XY_FACTOR, pt->y / MAP_XY_FACTOR, 0); - - if (m_boundaries[i].x == 0 || m_boundaries[i].y == 0) { - continue; - } - - Vector3 vecTestPt(m_boundaries[i].x, m_boundaries[i].y, 0); - if (Vector3::Distance(vecPt, vecTestPt) <= okDistance) { - (*outNdx) = i; - if (outHandle) { - (*outHandle) = 2; - } - return; - } - - vecTestPt.X = 0; - if (Vector3::Distance(vecPt, vecTestPt) <= okDistance) { - (*outNdx) = i; - if (outHandle) { - (*outHandle) = 1; - } - return; - } - - vecTestPt.X = m_boundaries[i].x; - vecTestPt.Y = 0; - if (Vector3::Distance(vecPt, vecTestPt) <= okDistance) { - (*outNdx) = i; - if (outHandle) { - (*outHandle) = 3; - } - return; - } - - vecTestPt.X = 0; - vecTestPt.Y = 0; - if (Vector3::Distance(vecPt, vecTestPt) <= okDistance) { - (*outNdx) = i; - if (outHandle) { - (*outHandle) = 0; - } - return; - } - } - - (*outNdx) = -1; - (*outHandle) = -1; -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WaterOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WaterOptions.cpp deleted file mode 100644 index 5203b6d73dd..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WaterOptions.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WaterOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "CUndoable.h" -#include "WaterOptions.h" -#include "WaypointOptions.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "wbview3d.h" -#include "PolygonTool.h" -#include "WaypointTool.h" -#include "GameLogic/PolygonTrigger.h" -#include "Common/WellKnownKeys.h" -#include "LayersList.h" - -WaterOptions *WaterOptions::m_staticThis = nullptr; -Int WaterOptions::m_waterHeight = 7; -Int WaterOptions::m_waterPointSpacing = MAP_XY_FACTOR; -Bool WaterOptions::m_creatingWaterAreas = false; -///////////////////////////////////////////////////////////////////////////// -/// WaterOptions dialog trivial constructor - Create does the real work. - - -WaterOptions::WaterOptions(CWnd* pParent /*=nullptr*/): -m_moveUndoable(nullptr) -{ - //{{AFX_DATA_INIT(WaterOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void WaterOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(WaterOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -void WaterOptions::setHeight(Int height) -{ - char buffer[12]; - snprintf(buffer, ARRAY_SIZE(buffer), "%d", height); - m_waterHeight = height; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } -} - -void WaterOptions::updateTheUI() -{ - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - - CWnd *pWnd = this->GetDlgItem(IDC_WATERNAME_EDIT); - - if (theTrigger && pWnd) { - pWnd->SetWindowText(theTrigger->getTriggerName().str()); - setHeight(theTrigger->getPoint(0)->z); - } - CButton *pButton = (CButton*)GetDlgItem(IDC_WATER_POLYGON); - pButton->SetCheck(m_creatingWaterAreas ? 1:0); - Bool isRiver = false; - if (theTrigger) { - isRiver = theTrigger->isRiver(); - } - pButton = (CButton*)GetDlgItem(IDC_MAKE_RIVER); - pButton->SetCheck(isRiver ? 1:0); - pButton->EnableWindow(theTrigger!=nullptr); - - pWnd = m_staticThis->GetDlgItem(IDC_SPACING); - char buffer[12]; - if (pWnd) { - snprintf(buffer, ARRAY_SIZE(buffer), "%d", m_waterPointSpacing); - pWnd->SetWindowText(buffer); - } -} - -void WaterOptions::update() -{ - if (m_staticThis) { - m_staticThis->updateTheUI(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// WaterOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL WaterOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - - m_waterHeightPopup.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - m_waterPointSpacing = 2*MAP_XY_FACTOR; - m_staticThis = this; - m_updating = false; - setHeight(m_waterHeight); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -BEGIN_MESSAGE_MAP(WaterOptions, COptionsPanel) - //{{AFX_MSG_MAP(WaterOptions) - ON_CBN_KILLFOCUS(IDC_WATERNAME_EDIT, OnChangeWaterEdit) - ON_EN_CHANGE(IDC_HEIGHT_EDIT, OnChangeHeightEdit) - ON_EN_CHANGE(IDC_SPACING, OnChangeSpacingEdit) - ON_BN_CLICKED(IDC_WATER_POLYGON, OnWaterPolygon) - ON_BN_CLICKED(IDC_MAKE_RIVER, OnMakeRiver) - ON_CBN_SELENDOK(IDC_WATERNAME_EDIT, OnChangeWaterEdit) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void WaterOptions::OnChangeWaterEdit() -{ - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - - // get the combo box - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_WATERNAME_EDIT); - if (pCombo) { - // get the text out of the combo. If it is user-typed, sel will be -1, otherwise it will be >=0 - CString theText; - Int sel = pCombo->GetCurSel(); - if (sel >= 0) { - pCombo->GetLBText(sel, theText); - } else { - pCombo->GetWindowText(theText); - } - AsciiString name((LPCTSTR)theText); - - // check to see if the user-entered name is already in use. - Bool didMatch = false; - - // check trigger area objects - PolygonTrigger *pTrig; - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) { - if (pTrig==theTrigger) continue; // don't check against yourself. - const AsciiString& trigName = pTrig->getTriggerName(); - if (name == trigName) { - if (pTrig->isValid()) { - didMatch = true; - } else { - // Keep layer membership in sync when discarding the invalid trigger. - TheLayersList->removePolygonTriggerFromLayersList(pTrig); - PolygonTrigger::removePolygonTrigger(pTrig); - } - break; - } - } - - // if there's a match, throw up a messagebox, otherwise set the name - if (didMatch) { - ::AfxMessageBox("Name already in use"); - } else { - if (theTrigger) { - theTrigger->setTriggerName(name); - } - } - } -} - - -void WaterOptions::OnWaterPolygon() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_WATER_POLYGON); - m_creatingWaterAreas = (pButton->GetCheck()==1); -} - -void WaterOptions::OnMakeRiver() -{ - CButton *pButton = (CButton*)GetDlgItem(IDC_MAKE_RIVER); - Bool river = (pButton->GetCheck()==1); - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - if (theTrigger) { - theTrigger->setRiver(river); - if (river) { - Int curPoint = PolygonTool::getSelectedPointNdx(); - if (curPoint >= 0) { - Real endLen=0; - Int newPoint = curPoint; - if (curPoint>0) curPoint--; - if (curPoint>0) curPoint--; - Int i; - for (i=curPoint; igetNumPoints()-1 && igetPoint(i); - ICoord3D outerPt = *theTrigger->getPoint(i+1); - Real dx = innerPt.x-outerPt.x; - Real dy = innerPt.y-outerPt.y; - Real curLen = sqrt(dx*dx+dy*dy); - if ( curLen>endLen) { - newPoint = i; - endLen = curLen; - } - } - theTrigger->setRiverStart(newPoint); - - // Now find the other end. -// Real sourceWidth = endLen; - - endLen=0; - Int endPoint = 0; - for (i=0; igetNumPoints()-1; i++) { - if (i>=newPoint-1 && i<=newPoint+1) continue; - ICoord3D innerPt = *theTrigger->getPoint(i); - ICoord3D outerPt = *theTrigger->getPoint(i+1); - Real dx = innerPt.x-outerPt.x; - Real dy = innerPt.y-outerPt.y; - Real curLen = sqrt(dx*dx+dy*dy); - if ( curLen>endLen) { - endPoint = i; - endLen = curLen; - } - } - Int pointsOut = endPoint - newPoint; - Int pointsIn = newPoint - endPoint; - if (pointsOut<0) pointsOut += theTrigger->getNumPoints(); - if (pointsIn<0) pointsIn += theTrigger->getNumPoints(); - Int delta = pointsIn-pointsOut; - if (delta<0) delta = -delta; - if (delta>1) { - PolygonTrigger *pNew; - if (pointsOutsetRiverStart(pointsIn); - } else { - pNew = adjustCount(theTrigger, endPoint+1, newPoint, pointsOut-1); - theTrigger->setRiverStart(0); - } - while(theTrigger->getNumPoints()) theTrigger->deletePoint(theTrigger->getNumPoints()-1); - for (i=0; igetNumPoints(); i++) { - theTrigger->addPoint(*pNew->getPoint(i)); - } - deleteInstance(pNew); - } - } - } - } -} - -/// Adjust the spacing. -PolygonTrigger * WaterOptions::adjustCount(PolygonTrigger *trigger, Int firstPt, Int lastPt, Int desiredPointCount) -{ - PolygonTrigger *pNew = newInstance(PolygonTrigger)(trigger->getNumPoints()); -// Real endLen=0; - Real totalLen=0; - Real curSpacingLen = 10; - Int curPoint = lastPt; - ICoord3D pt; - while (curPoint != firstPt) { - pt = *trigger->getPoint(curPoint); - pNew->addPoint(pt); - curPoint++; - if (curPoint>=trigger->getNumPoints()) { - curPoint = 0; - } - } - - curPoint = firstPt; - while (curPoint != lastPt) { - Int nextPoint = curPoint; - nextPoint++; - if (nextPoint>=trigger->getNumPoints()) { - nextPoint = 0; - } - ICoord3D curPt = *trigger->getPoint(curPoint); - ICoord3D nextPt = *trigger->getPoint(nextPoint); - Real dx = nextPt.x-curPt.x; - Real dy = nextPt.y-curPt.y; - Real curLen = sqrt(dx*dx+dy*dy); - totalLen += curLen; - curPoint = nextPoint; - } - Real spacing = totalLen/(desiredPointCount-1); - - Bool didCurPoint = true; - - curPoint = firstPt; - pt = *trigger->getPoint(curPoint); - pNew->addPoint(pt); - while (curPoint != lastPt) { - Int nextPoint = curPoint; - nextPoint++; - if (nextPoint>=trigger->getNumPoints()) { - nextPoint = 0; - } - ICoord3D curPt = *trigger->getPoint(curPoint); - ICoord3D nextPt = *trigger->getPoint(nextPoint); - Real dx = nextPt.x-curPt.x; - Real dy = nextPt.y-curPt.y; - Real curLen = sqrt(dx*dx+dy*dy); - if (curLen > 4*MAP_XY_FACTOR && curLen>2*spacing) { - if (!didCurPoint) pNew->addPoint(curPt); - else pNew->setPoint(curPt, pNew->getNumPoints()-1); - pNew->addPoint(nextPt); - didCurPoint = true; - curSpacingLen = spacing; - } else if (curSpacingLen>curLen) { - curSpacingLen -= curLen; - } else { - while (curLen >= curSpacingLen) { - // cur len > curSpacingLen. - Real factor = curSpacingLen/curLen; - curPt.x += dx*factor; - curPt.y += dy*factor; - pNew->addPoint(curPt); - didCurPoint = false; - dx = nextPt.x-curPt.x; - dy = nextPt.y-curPt.y; - curLen -= curSpacingLen; - curSpacingLen = spacing; - } - curSpacingLen -= curLen; - if ((curLen)GetDlgItem(IDC_HEIGHT_EDIT); - m_updating = true; - if (pEdit) pEdit->SetWindowText(str); - startUpdateHeight(); - updateHeight(); - m_updating = false; - break; - - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void WaterOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_HEIGHT_POPUP: - updateHeight(); - endUpdateHeight(); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - -void WaterOptions::startUpdateHeight() -{ - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - if (!theTrigger) { - REF_PTR_RELEASE(m_moveUndoable); - return; - } - if (!theTrigger->isWaterArea()) { - REF_PTR_RELEASE(m_moveUndoable); - return; - } - if (m_moveUndoable && theTrigger == m_moveUndoable->getTrigger()) { - return; - } - m_originalHeight = theTrigger->getPoint(0)->z; - Int i; - for (i=0; igetNumPoints(); i++) { - ICoord3D loc = *theTrigger->getPoint(i); - loc.z = m_originalHeight; - theTrigger->setPoint(loc, i); - } - m_moveUndoable = new MovePolygonUndoable(theTrigger); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - pDoc->AddAndDoUndoable(m_moveUndoable); -} - - -void WaterOptions::updateHeight() -{ - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - if (!theTrigger || !m_moveUndoable) { - REF_PTR_RELEASE(m_moveUndoable); // belongs to pDoc now. - return; - } - if (!theTrigger->isWaterArea()) { - REF_PTR_RELEASE(m_moveUndoable); // belongs to pDoc now. - return; - } - if (theTrigger != m_moveUndoable->getTrigger()) { - REF_PTR_RELEASE(m_moveUndoable); // belongs to pDoc now. - return; - } - ICoord3D iLoc; - Int dz = m_waterHeight - m_originalHeight; - iLoc.x = 0; - iLoc.y = 0; - iLoc.z = dz; - m_moveUndoable->SetOffset(iLoc); - WbView3d *pView = CWorldBuilderDoc::GetActive3DView(); - pView->Invalidate(); -} - -void WaterOptions::endUpdateHeight() -{ - REF_PTR_RELEASE(m_moveUndoable); // belongs to pDoc now. -} - - - /// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void WaterOptions::OnChangeHeightEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int height; - m_updating = true; - if (1==sscanf(buffer, "%d", &height)) { - m_waterHeight = height; - startUpdateHeight(); - updateHeight(); - endUpdateHeight(); - } - m_updating = false; - } -} - - /// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void WaterOptions::OnChangeSpacingEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SPACING); - char buffer[12]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int height; - m_updating = true; - if (1==sscanf(buffer, "%d", &height)) { - m_waterPointSpacing = height; - } else { - snprintf(buffer, ARRAY_SIZE(buffer), "%d", m_waterPointSpacing); - pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WaterTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WaterTool.cpp deleted file mode 100644 index aa52fa42821..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WaterTool.cpp +++ /dev/null @@ -1,536 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WaterTool.cpp -// Water area tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "WaterTool.h" -#include "CUndoable.h" -#include "PointerTool.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "GameLogic/PolygonTrigger.h" -#include "Common/GlobalData.h" - -// -// WaterTool class. -// -Bool WaterTool::m_water_isActive = false; - -/// Constructor -WaterTool::WaterTool() -{ - m_toolID = ID_WATER_TOOL; - m_cursorID = IDC_WATER; - - m_currentZ = 0; - -} - - - -/// Destructor -WaterTool::~WaterTool() -{ - if (m_poly_plusCursor) { - ::DestroyCursor(m_poly_plusCursor); - } - if (m_poly_moveCursor) { - ::DestroyCursor(m_poly_moveCursor); - } -} - -/// Clears it's is active flag. -void WaterTool::deactivate() -{ - PolygonTool::deactivate(); - m_water_isActive = false; -} - -static Bool doIt = false; - -/// Shows the no options panel. -void WaterTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WATER_OPTIONS); - m_water_isActive = true; - PointerTool::clearSelection(); - DrawObject::setDoBrushFeedback(false); - m_poly_isActive = false; - m_poly_isAdding = false; - m_poly_mouseUpMove = false; - m_poly_mouseUpPlus = false; - m_currentZ = WaterOptions::getHeight(); - doIt = true; -} - - -#define WATER_FILL -#define INTENSE_DEBUG - -/// Perform the tool behavior on mouse down. -void WaterTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - if (WaterOptions::getCreatingWaterAreas()) { - fillTheArea(m, viewPt, pView, pDoc); - return; - } - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - m_poly_unsnappedMouseDownPt = docPt; - poly_pickOnMouseDown(viewPt, pView); - if (!poly_snapToPoly(&docPt)) { - pView->snapPoint(&docPt); - } - docPt.z = m_currentZ; - m_poly_mouseDownPt = docPt; - if (m_poly_curSelectedPolygon) { - DEBUG_ASSERTCRASH(m_poly_curSelectedPolygon->isWaterArea(), ("Should be water.")); - m_currentZ = m_poly_curSelectedPolygon->getPoint(0)->z; - m_poly_mouseDownPt.z = m_currentZ; - } - startMouseDown(m, viewPt, pView, pDoc); - m_poly_curSelectedPolygon->setWaterArea(true); - -} - - - -/** Set the cursor. */ -void WaterTool::setCursor() -{ - if (m_poly_mouseUpPlus || (m_poly_isAdding && m_poly_curSelectedPolygon)) { - if (m_poly_plusCursor == nullptr) { - m_poly_plusCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_WATER_PLUS)); - } - ::SetCursor(m_poly_plusCursor); - } else if (m_poly_mouseUpMove) { - if (m_poly_moveCursor == nullptr) { - m_poly_moveCursor = AfxGetApp()->LoadCursor(MAKEINTRESOURCE(IDC_WATER_MOVE)); - } - ::SetCursor(m_poly_moveCursor); - } else { - Tool::setCursor(); - } -} - - - -/// Left button move code. -void WaterTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - if (m == TRACK_NONE) { - PolygonTrigger *pCur = m_poly_curSelectedPolygon; - Int curPt = m_poly_dragPointNdx; - m_poly_unsnappedMouseDownPt = docPt; - poly_pickOnMouseDown(viewPt, pView); - m_poly_mouseUpPlus = false; - m_poly_mouseUpMove = false; - if (m_poly_curSelectedPolygon) { - if (poly_pickPoint(m_poly_curSelectedPolygon, viewPt, pView) >= 0) { - m_poly_mouseUpMove = true; - } else { - m_poly_mouseUpPlus = true; - } - } - m_poly_curSelectedPolygon = pCur; - m_poly_dragPointNdx = curPt; - return; // setCursor will use the value of m_mouseUpRotate. jba. - } - - if (m != TRACK_L) return; - if (!poly_snapToPoly(&docPt)) { - pView->snapPoint(&docPt); - } - if (m_poly_moveUndoable) { - ICoord3D iDocPt; - iDocPt.x = floor(docPt.x+0.5f-m_poly_mouseDownPt.x); - iDocPt.y = floor(docPt.y+0.5f-m_poly_mouseDownPt.y); - iDocPt.z = 0; - m_poly_moveUndoable->SetOffset(iDocPt); - pView->Invalidate(); - return; - } - if (m_poly_dragPointNdx >= 0 && m_poly_curSelectedPolygon) { - ICoord3D iDocPt; - iDocPt.x = floor(docPt.x+0.5f); - iDocPt.y = floor(docPt.y+0.5f); - iDocPt.z = m_currentZ; - m_poly_curSelectedPolygon->setPoint(iDocPt, m_poly_dragPointNdx); - pView->Invalidate(); - } -} - -/** Mouse up - not much. */ -void WaterTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - REF_PTR_RELEASE(m_poly_moveUndoable); // belongs to pDoc now. -} - -inline static Real mapZtoHeight(UnsignedByte mapZ) { - return (mapZ * MAP_HEIGHT_SCALE)+0.01f; -} - -/// Perform the fill water area on mouse down. -void WaterTool::fillTheArea(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - Int waterHeight = m_currentZ; - - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - - Int pointLimit = 3000; // In case we get lost. - - PolygonTrigger *pNew = newInstance(PolygonTrigger)(100); - AsciiString name; - name.format("Water Area %d", pNew->getID()); - pNew->setTriggerName(name); - - CPoint ndx; - Int width = 1; - getCenterIndex(&docPt, width, &ndx, pDoc); - Int i, j; - i = ndx.x; - j = ndx.y; - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - if (i<0 || i>=pMap->getXExtent()-1) return; - if (j<0 || j>=pMap->getYExtent()-1) return; - - Int intMapHeight = pMap->getHeight(i, j); - if (waterHeight0) { - i--; - intMapHeight = pMap->getHeight(i, j); - if (waterHeight0) { - if (curPoint>2 && i==startI && j==startJ) break; - pointLimit--; - pt.x = i*MAP_XY_FACTOR; - pt.y = j*MAP_XY_FACTOR; - pt.z = waterHeight; - intMapHeight = pMap->getHeight(i, j); -#ifdef INTENSE_DEBUG - if (bottom) { - DEBUG_LOG(("Bottom %d,%d", i, j)); - } else if (left) { - DEBUG_LOG(("Left %d,%d", i, j)); - } else if (right) { - DEBUG_LOG(("Right %d,%d", i, j)); - } else if (top) { - DEBUG_LOG(("Top %d,%d", i, j)); - } -#endif - if (bottom) { - bottom = false; - if (waterHeightmapZtoHeight(pMap->getHeight(i+1, j)), ("Logic error. jba.")); - Real dx = (mapZtoHeight(pMap->getHeight(i,j))-waterHeight) / (mapZtoHeight(pMap->getHeight(i,j)-pMap->getHeight(i+1,j))); - pt.x += dx*MAP_XY_FACTOR; - Bool topLeftDry = (waterHeightgetHeight(i, j+1))); - Bool topRightDry = (waterHeightgetHeight(i+1, j+1))); - if (topRightDry) { - i++; - left = true; - } else if (topLeftDry) { - if (jgetYExtent()-2) { - j++; - bottom = true; - } else { - tmpPt = pt; - pt.y += MAP_XY_FACTOR; - tmpPt.x -= pMap->getBorderSize()*MAP_XY_FACTOR; - tmpPt.y -= pMap->getBorderSize()*MAP_XY_FACTOR; - pNew->addPoint(tmpPt); - left = true; - i++; - } - } else { - if (i>0) { - i--; - right = true; - } else { - j++; - bottom = true; - } - } - } else { - DEBUG_ASSERTCRASH(i==0, ("Logic error. jba.")); - left = true; - while (jgetYExtent()-2 && waterHeight>mapZtoHeight(pMap->getHeight(i, j+1))) { - j++; - } - pt.y = (j)*MAP_XY_FACTOR; - if (waterHeight>mapZtoHeight(pMap->getHeight(i, j+1))) { - pt.y = (j+1)*MAP_XY_FACTOR; - } else { - continue; - } - - } - } else if (left) { - left = false; - if (waterHeightgetHeight(i, j+1))) { - DEBUG_ASSERTCRASH(waterHeight>mapZtoHeight(intMapHeight), ("Logic error. jba.")); - Real dy = (waterHeight-mapZtoHeight(pMap->getHeight(i,j))) / (mapZtoHeight(pMap->getHeight(i,j+1)-pMap->getHeight(i,j))); - pt.y += dy*MAP_XY_FACTOR; - Bool bottomRightDry = (waterHeightgetHeight(i+1, j))); - Bool topRightDry = (waterHeightgetHeight(i+1, j+1))); - if (bottomRightDry) { - j--; - top = true; - } else if (topRightDry) { - if (igetXExtent()-2) { - i++; - left = true; - } else { - tmpPt = pt; - pt.x += MAP_XY_FACTOR; - tmpPt.x -= pMap->getBorderSize()*MAP_XY_FACTOR; - tmpPt.y -= pMap->getBorderSize()*MAP_XY_FACTOR; - pNew->addPoint(tmpPt); - top = true; - j--; - } - } else { - if (jgetYExtent()-1) { - j++; - bottom = true; - } else { - i++; - left = true; - } - } - } else { - pt.y = (j+1)*MAP_XY_FACTOR; - DEBUG_ASSERTCRASH(j==pMap->getYExtent()-2, ("Logic error. jba.")); - while (igetXExtent()-2 && waterHeight>mapZtoHeight(pMap->getHeight(i+1, j+1))) { - i++; - } - top = true; - pt.x = i*MAP_XY_FACTOR; - if (waterHeight>mapZtoHeight(pMap->getHeight(i+1, j+1))) { - pt.x = (i+1)*MAP_XY_FACTOR; - } else { - continue; - } - } - } else if (right) { - right = false; - pt.x = (i+1)*MAP_XY_FACTOR; - if (waterHeightgetHeight(i+1, j))) { - DEBUG_ASSERTCRASH(waterHeight>mapZtoHeight(pMap->getHeight(i+1,j+1)), ("Logic error. jba.")); - Real dy = (mapZtoHeight(pMap->getHeight(i+1,j))-waterHeight) / (mapZtoHeight(pMap->getHeight(i+1,j)-pMap->getHeight(i+1,j+1))); - pt.y += dy*MAP_XY_FACTOR; - Bool bottomLeftDry = (waterHeightgetHeight(i, j))); - Bool topLeftDry = (waterHeightgetHeight(i, j+1))); - if (topLeftDry) { - j++; - bottom = true; - } else if (bottomLeftDry) { - if (i>0) { - i--; - right = true; - } else { - tmpPt = pt; - pt.x -= MAP_XY_FACTOR; - tmpPt.x -= pMap->getBorderSize()*MAP_XY_FACTOR; - tmpPt.y -= pMap->getBorderSize()*MAP_XY_FACTOR; - pNew->addPoint(tmpPt); - bottom = true; - j++; - } - } else { - if (j>0) { - j--; - top = true; - } else { - i--; - right = true; - } - } - } else { - DEBUG_ASSERTCRASH(j==0, ("Logic error. jba.")); - while (i>0 && waterHeight>mapZtoHeight(pMap->getHeight(i, j))) { - i--; - } - bottom = true; - pt.x = (i)*MAP_XY_FACTOR; - if (waterHeightgetHeight(i, j))) { - continue; - } - } - } else if (top) { - top = false; - pt.y = (j+1)*MAP_XY_FACTOR; - if (waterHeightgetHeight(i+1, j+1))) { - DEBUG_ASSERTCRASH(waterHeight>mapZtoHeight(pMap->getHeight(i, j+1)), ("Logic error. jba.")); - Real dx = (waterHeight-mapZtoHeight(pMap->getHeight(i,j+1))) / (mapZtoHeight(pMap->getHeight(i+1,j+1)-pMap->getHeight(i,j+1))); - pt.x += dx*MAP_XY_FACTOR; - Bool bottomLeftDry = (waterHeightgetHeight(i, j))); - Bool bottomRightDry = (waterHeightgetHeight(i+1, j))); - if (bottomLeftDry) { - i--; - right = true; - } else if (bottomRightDry) { - if (j>0) { - j--; - top = true; - } else { - tmpPt = pt; - pt.y -= MAP_XY_FACTOR; - tmpPt.x -= pMap->getBorderSize()*MAP_XY_FACTOR; - tmpPt.y -= pMap->getBorderSize()*MAP_XY_FACTOR; - pNew->addPoint(tmpPt); - i--; - right = true; - } - } else { - if (igetXExtent()-2) { - i++; - left = true; - } else { - j--; - top = true; - } - } - } else { - DEBUG_ASSERTCRASH(i==pMap->getXExtent()-2, ("Logic error. jba.")); - while (j>0 && waterHeight>mapZtoHeight(pMap->getHeight(i+1, j))) { - j--; - } - right = true; - pt.y = (j+1)*MAP_XY_FACTOR; - if (waterHeight>mapZtoHeight(pMap->getHeight(i, j))) { - pt.y = (j)*MAP_XY_FACTOR; - } else { - continue; - } - pt.x = (i+1)*MAP_XY_FACTOR; - } - } else { - DEBUG_CRASH(("Logic error. jba.")); // shouldn't get here. - } - pt.x -= pMap->getBorderSize()*MAP_XY_FACTOR; - pt.y -= pMap->getBorderSize()*MAP_XY_FACTOR; - pNew->addPoint(pt); - curPoint++; - if (firstTime) { - startI = i; - startJ = j; - firstTime = false; - } - - } - - if (pNew->getNumPoints()>2) { - PolygonTrigger *pBetter = adjustSpacing(pNew, WaterOptions::getSpacing()); - deleteInstance(pNew); - pNew = pBetter; - pNew->setWaterArea(true); - AddPolygonUndoable *pUndo = new AddPolygonUndoable(pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - m_poly_curSelectedPolygon = pNew; - m_poly_dragPointNdx = -1; - WaterOptions::update(); - } else { - deleteInstance(pNew); - } - -} - -/// Adjust the spacing. -PolygonTrigger * WaterTool::adjustSpacing(PolygonTrigger *trigger, Real spacing) -{ - PolygonTrigger *pNew = newInstance(PolygonTrigger)(trigger->getNumPoints()); -// Real endLen=0; - Int i; - Real curSpacingLen = spacing; - ICoord3D pt = *trigger->getPoint(0); - pNew->addPoint(pt); - Bool didCurPoint = true; - for (i=0; igetNumPoints()-1; i++) { - ICoord3D curPt = *trigger->getPoint(i); - ICoord3D nextPt = *trigger->getPoint(i+1); - Real dx = nextPt.x-curPt.x; - Real dy = nextPt.y-curPt.y; - Real curLen = sqrt(dx*dx+dy*dy); - if (curLen > 4*MAP_XY_FACTOR && curLen>2*spacing) { - if (!didCurPoint) pNew->addPoint(curPt); - else pNew->setPoint(curPt, pNew->getNumPoints()-1); - pNew->addPoint(nextPt); - didCurPoint = true; - curSpacingLen = spacing; - } else if (curSpacingLen>curLen) { - curSpacingLen -= curLen; - } else { - while (curLen >= curSpacingLen) { - // cur len > curSpacingLen. - Real factor = curSpacingLen/curLen; - curPt.x += dx*factor; - curPt.y += dy*factor; - pNew->addPoint(curPt); - didCurPoint = false; - dx = nextPt.x-curPt.x; - dy = nextPt.y-curPt.y; - curLen -= curSpacingLen; - curSpacingLen = spacing; - } - curSpacingLen -= curLen; - if ((curLen)setTriggerName(trigger->getTriggerName()); - return pNew; -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointOptions.cpp deleted file mode 100644 index 316757ca84c..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointOptions.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WaypointOptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "CUndoable.h" -#include "WaypointOptions.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "wbview3d.h" -#include "PolygonTool.h" -#include "WaypointTool.h" -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/Scripts.h" -#include "Common/WellKnownKeys.h" -#include "LayersList.h" - -WaypointOptions *WaypointOptions::m_staticThis = nullptr; -///////////////////////////////////////////////////////////////////////////// -/// WaypointOptions dialog trivial constructor - Create does the real work. - - -WaypointOptions::WaypointOptions(CWnd* pParent /*=nullptr*/): -m_moveUndoable(nullptr) -{ - //{{AFX_DATA_INIT(WaypointOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void WaypointOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(WaypointOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -MapObject *WaypointOptions::getSingleSelectedWaypoint() -{ - MapObject *theMapObj = nullptr; -// Bool found = false; - Int selCount=0; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected()) { - if (pMapObj->isWaypoint()) { - theMapObj = pMapObj; - } - selCount++; - } - } - if (selCount==1 && theMapObj) { - return theMapObj; - } - - return(nullptr); -} - -PolygonTrigger *WaypointOptions::getSingleSelectedPolygon() -{ - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc==nullptr) return nullptr; - WbView3d *p3View = pDoc->GetActive3DView(); - Bool showPoly = false; - if (p3View) { - showPoly = p3View->isPolygonTriggerVisible(); - } - if (showPoly || PolygonTool::isActive()) { - for (PolygonTrigger *pTrig=PolygonTrigger::getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) { - if (PolygonTool::isSelected(pTrig)) { - return pTrig; - } - } - } - return(nullptr); -} - -void WaypointOptions::updateTheUI() -{ - Tool *curTool = ((CWorldBuilderApp*)AfxGetApp())->getCurTool(); - - Bool isWaypointTool = (curTool && (curTool->getToolID() == ID_WAYPOINT_TOOL)); - MapObject *theMapObj = getSingleSelectedWaypoint(); - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - - CWnd *pWnd = this->GetDlgItem(IDC_WAYPOINTNAME_EDIT); - CWnd *pCaption1 = this->GetDlgItem(IDC_WAYPOINT_CAPTION1); - CWnd *pCaption2 = this->GetDlgItem(IDC_WAYPOINT_PATHLABELS); - CWnd *pCaption3 = this->GetDlgItem(65535); - CWnd *pCaption4 = this->GetDlgItem(65534); - CWnd *pCaption5 = this->GetDlgItem(IDC_LIST_WAYPOINTS); - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_WAYPOINTNAME_EDIT); - CComboBox *pListWayptNames = (CComboBox*)GetDlgItem(IDC_LIST_OF_WAYPOINT_NAMES); - - CWnd *pWaypointLabel1 = GetDlgItem(IDC_WAYPOINTLABEL1_EDIT); - CWnd *pWaypointLabel2 = GetDlgItem(IDC_WAYPOINTLABEL2_EDIT); - CWnd *pWaypointLabel3 = GetDlgItem(IDC_WAYPOINTLABEL3_EDIT); - - CWnd *pWaypointLocation = this->GetDlgItem(IDC_WAYPOINT_LOCATION); - CWnd *pWaypointX = GetDlgItem(IDC_WAYPOINT_LOCATIONX); - CWnd *pWaypointY = GetDlgItem(IDC_WAYPOINT_LOCATIONY); - CButton *pBiDirCheck = (CButton *)GetDlgItem(IDC_WAYPOINT_BIDIRECTIONAL); - - if (theTrigger) { - pCaption1->ShowWindow(SW_SHOW); - pWnd->ShowWindow(SW_SHOW); - } else { - pCaption1->ShowWindow(SW_HIDE); - pCaption2->ShowWindow(SW_HIDE); - pWnd->ShowWindow(SW_HIDE); - } - - if (pCombo && !theTrigger) { - pCombo->ResetContent(); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_InitialCameraPosition)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_1_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_2_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_3_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_4_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_5_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_6_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_7_Start)).str()); - pCombo->AddString((TheNameKeyGenerator->keyToName(TheKey_Player_8_Start)).str()); - pCombo->ShowWindow(SW_SHOW); - } else if (pCombo && theTrigger) { - pCombo->ResetContent(); - AsciiString trigger; - trigger = INNER_PERIMETER; - trigger.concat("1"); - pCombo->AddString(trigger.str()); - trigger = OUTER_PERIMETER; - trigger.concat("1"); - pCombo->AddString(trigger.str()); - trigger = INNER_PERIMETER; - trigger.concat("2"); - pCombo->AddString(trigger.str()); - trigger = OUTER_PERIMETER; - trigger.concat("2"); - pCombo->AddString(trigger.str()); - trigger = INNER_PERIMETER; - trigger.concat("3"); - pCombo->AddString(trigger.str()); - trigger = OUTER_PERIMETER; - trigger.concat("3"); - pCombo->AddString(trigger.str()); - trigger = INNER_PERIMETER; - trigger.concat("4"); - pCombo->AddString(trigger.str()); - trigger = OUTER_PERIMETER; - trigger.concat("4"); - pCombo->AddString(trigger.str()); - pCombo->ShowWindow(SW_SHOW); - } - - // display the list of waypoint names drop down menu - if (pListWayptNames && !theTrigger) { - - // reset everything and start fresh again - pListWayptNames->ResetContent(); - - // get the first map object, and then cycle through the rest - MapObject *tempObj = MapObject::getFirstMapObject(); - while (true) { - - if (!tempObj) - break; - - // if it is a waypoint, add its name to the combo box - if (tempObj->isWaypoint()) - pListWayptNames->AddString(tempObj->getWaypointName().str()); - - tempObj = tempObj->getNext(); - } - - // make sure the window is displayed - pCombo->ShowWindow(SW_SHOW); - } - - if ((theMapObj || isWaypointTool) && pWnd ) { - if (theMapObj) { - Bool exists; - pWnd->EnableWindow(); - pWnd->SetWindowText(theMapObj->getProperties()->getAsciiString(TheKey_waypointName).str()); - pCaption1->SetWindowText("Waypoint name:"); - SetWindowText("Waypoint Options"); - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - - /* display location of waypoint */ - - pWaypointLocation->ShowWindow(SW_SHOW); - pWaypointY->ShowWindow(SW_SHOW); - pWaypointX->ShowWindow(SW_SHOW); - pListWayptNames->ShowWindow(SW_SHOW); - pCaption5->ShowWindow(SW_SHOW); - const Coord3D *waypointLocation = getSingleSelectedWaypoint()->getLocation(); - AsciiString locX, locY; - - // convert the location coordinates to strings - locX.format("%f", waypointLocation->x); - locY.format("%f", waypointLocation->y); - - // set the window text to reflect the current position of the waypoint - pWaypointX->SetWindowText(locX.str()); - pWaypointY->SetWindowText(locY.str()); - - if (pDoc->isWaypointLinked(theMapObj)) { - pCaption2->ShowWindow(SW_SHOW); - AsciiString name; - name = theMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel1, &exists); - pWaypointLabel1->ShowWindow(SW_SHOW); - pWaypointLabel1->SetWindowText(name.str()); - name = theMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel2, &exists); - pWaypointLabel2->ShowWindow(SW_SHOW); - pWaypointLabel2->SetWindowText(name.str()); - name = theMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel3, &exists); - pWaypointLabel3->ShowWindow(SW_SHOW); - pWaypointLabel3->SetWindowText(name.str()); - } else { - pCaption2->ShowWindow(SW_HIDE); - pWaypointLabel1->ShowWindow(SW_HIDE); - pWaypointLabel2->ShowWindow(SW_HIDE); - pWaypointLabel3->ShowWindow(SW_HIDE); - } - if (pBiDirCheck) { - pBiDirCheck->ShowWindow(SW_SHOW); - Bool checked = theMapObj->getProperties()->getBool(TheKey_waypointPathBiDirectional, &exists); - pBiDirCheck->SetCheck(checked); - } - } - } else if (theTrigger && pWnd) { - pListWayptNames->ShowWindow(SW_HIDE); - pWaypointLocation->ShowWindow(SW_HIDE); - pWaypointY->ShowWindow(SW_HIDE); - pWaypointX->ShowWindow(SW_HIDE); - pCaption3->ShowWindow(SW_HIDE); - pCaption4->ShowWindow(SW_HIDE); - pCaption5->ShowWindow(SW_HIDE); - pWaypointLabel1->ShowWindow(SW_HIDE); - pWaypointLabel2->ShowWindow(SW_HIDE); - pWaypointLabel3->ShowWindow(SW_HIDE); - pCaption2->ShowWindow(SW_HIDE); - pBiDirCheck->ShowWindow(SW_HIDE); - pCaption1->SetWindowText("Area name:"); - SetWindowText("Area Trigger Options"); - pWnd->SetWindowText(theTrigger->getTriggerName().str()); - pWnd->EnableWindow(); - } else if (pWnd) { - pCaption2->ShowWindow(SW_HIDE); - pWnd->EnableWindow(false); - pWnd->SetWindowText(""); - } -} - -void WaypointOptions::update() -{ - if (m_staticThis) { - m_staticThis->updateTheUI(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// WaypointOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL WaypointOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - - m_staticThis = this; - m_updating = false; - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - - -BEGIN_MESSAGE_MAP(WaypointOptions, COptionsPanel) - //{{AFX_MSG_MAP(WaypointOptions) - ON_CBN_KILLFOCUS(IDC_WAYPOINTNAME_EDIT, OnChangeWaypointnameEdit) - ON_CBN_KILLFOCUS(IDC_LIST_OF_WAYPOINT_NAMES, OnChangeSelectedWaypoint) - ON_EN_CHANGE(IDC_WAYPOINT_LOCATIONX, OnEditWaypointLocationX) - ON_EN_CHANGE(IDC_WAYPOINT_LOCATIONY, OnEditWaypointLocationY) - ON_EN_CHANGE(IDC_WAYPOINTLABEL1_EDIT, OnEditchangeWaypointlabel1Edit) - ON_EN_CHANGE(IDC_WAYPOINTLABEL2_EDIT, OnEditchangeWaypointlabel2Edit) - ON_EN_CHANGE(IDC_WAYPOINTLABEL3_EDIT, OnEditchangeWaypointlabel3Edit) - ON_CBN_SELENDOK(IDC_LIST_OF_WAYPOINT_NAMES, OnChangeSelectedWaypoint) - ON_CBN_SELENDOK(IDC_WAYPOINTNAME_EDIT, OnChangeWaypointnameEdit) - ON_BN_CLICKED(IDC_WAYPOINT_BIDIRECTIONAL, OnWaypointBidirectional) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void WaypointOptions::OnChangeSelectedWaypoint() -{ - // deselect whatever is currently selected - MapObject *currentlySelected = getSingleSelectedWaypoint(), *pMapObj, *waypt; - if (!currentlySelected) - return; - currentlySelected->setSelected(false); - - // retrieve information from dialog box, if user-typed -- sel will be -1, otherwise it will be >=0 - CString theText; - CComboBox *pListWayptNames = (CComboBox*)GetDlgItem(IDC_LIST_OF_WAYPOINT_NAMES); - Int sel = pListWayptNames->GetCurSel(); - if (sel >= 0) { - pListWayptNames->GetLBText(sel, theText); - } else { - pListWayptNames->GetWindowText(theText); - } - AsciiString name((LPCTSTR)theText); - - // find and store the waypoint that corresponds to the information in the dialog box - Bool foundWaypoint = false; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - if (pMapObj->getWaypointName() != AsciiString::TheEmptyString) { - if (pMapObj->getWaypointName() == name) { - foundWaypoint = true; - waypt = pMapObj; - break; - } - } - } - } - - // if no waypoint corresponds to whatever is in the dialog box, then don't do anything - if (!foundWaypoint) - return; - - // select the waypoint and set camera position to position of waypoint - waypt->setSelected(true); - Coord3D pos = *waypt->getLocation(); - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - WbView3d *p3View = pDoc->GetActive3DView(); - if (p3View) { - p3View->setCenterInView(pos.x/MAP_XY_FACTOR, pos.y/MAP_XY_FACTOR); - } - } - - update(); -} - -void WaypointOptions::OnEditWaypointLocationX() -{ - CString tempName; - AsciiString name; - - //make sure that only one waypoint is being selected currently - MapObject *waypt = getSingleSelectedWaypoint(); - if (!waypt) - return; - - // get old waypoint information - const Coord3D *waypointLocation = waypt->getLocation(); - Coord3D newWaypointLocation; - - // retrieve information from dialog box - CWnd *pWnd = GetDlgItem(IDC_WAYPOINT_LOCATIONX); - pWnd->GetWindowText(tempName); - name = ((LPCTSTR)tempName); - - // make sure that there is a value in the field, otherwise funky stuff would happen - if (name.isEmpty()) - return; - - // determine new values of waypoint location - newWaypointLocation.x = atof(name.str()); - newWaypointLocation.y = waypointLocation->y; - newWaypointLocation.z = 0; - - // set the new information into both the waypointa and the window - waypt->setLocation(&newWaypointLocation); -} - -void WaypointOptions::OnEditWaypointLocationY() -{ - CString tempName; - AsciiString name; - - //make sure that only one waypoint is being selected currently - MapObject *waypt = getSingleSelectedWaypoint(); - if (!waypt) - return; - - // get old waypoint information - const Coord3D *waypointLocation = waypt->getLocation(); - Coord3D newWaypointLocation; - - // retrieve information from dialog box - CWnd *pWnd = GetDlgItem(IDC_WAYPOINT_LOCATIONY); - pWnd->GetWindowText(tempName); - name = ((LPCTSTR)tempName); - - // make sure that there is a value in the field, otherwise funky stuff would happen - if (name.isEmpty()) - return; - - // determine new values of waypoint location - newWaypointLocation.y = atof(name.str()); - newWaypointLocation.x = waypointLocation->x; - newWaypointLocation.z = 0; - - // set the new information into both the waypointa and the window - waypt->setLocation(&newWaypointLocation); -} - -Bool WaypointOptions::isUnique(AsciiString name, MapObject* theMapObj) -{ - MapObject *pMapObj; - Bool didMatch = false; - for (pMapObj = MapObject::getFirstMapObject(); !didMatch && pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - if (pMapObj == theMapObj) continue; // don't check against self. - AsciiString wayName = pMapObj->getWaypointName(); - if (name == wayName) { - didMatch = true; - break; - } - } - } - return (didMatch == false); -} - -AsciiString WaypointOptions::GenerateUniqueName(Int id) -{ - AsciiString name; - name.format("Waypoint %d", id); - while (!isUnique(name)) { - id++; - name.format("Waypoint %d", id); - } - - return name; -} - -void WaypointOptions::OnChangeWaypointnameEdit() -{ - MapObject *theMapObj = getSingleSelectedWaypoint(); - PolygonTrigger *theTrigger = WaypointOptions::getSingleSelectedPolygon(); - - // get the combo box - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_WAYPOINTNAME_EDIT); - if (pCombo) { - // get the text out of the combo. If it is user-typed, sel will be -1, otherwise it will be >=0 - CString theText; - Int sel = pCombo->GetCurSel(); - if (sel >= 0) { - pCombo->GetLBText(sel, theText); - } else { - pCombo->GetWindowText(theText); - } - AsciiString name((LPCTSTR)theText); - - // check to see if the user-entered name is already in use. - Bool didMatch = false; - - // check waypoint objects. - didMatch = !isUnique(name, theMapObj); - - // check trigger area objects - PolygonTrigger *pTrig; - for (pTrig=PolygonTrigger::getFirstPolygonTrigger(); !didMatch && pTrig; pTrig = pTrig->getNext()) { - if (pTrig==theTrigger) continue; // don't check against yourself. - const AsciiString& trigName = pTrig->getTriggerName(); - if (name == trigName) { - if (pTrig->isValid()) { - didMatch = true; - } else { - // Keep layer membership in sync when discarding the invalid trigger. - TheLayersList->removePolygonTriggerFromLayersList(pTrig); - PolygonTrigger::removePolygonTrigger(pTrig); - } - break; - } - } - - // if there's a match, throw up a messagebox, otherwise set the name - if (didMatch) { - ::AfxMessageBox("Name already in use"); - } else { - if (theMapObj) { - AsciiString layerName = TheLayersList->removeMapObjectFromLayersList(theMapObj); - theMapObj->setWaypointName(name); - theMapObj->validate(); - TheLayersList->addMapObjectToLayersList(theMapObj, layerName); - } else if (theTrigger) { - theTrigger->setTriggerName(name); - } - } - } -} - - -void WaypointOptions::OnEditchangeWaypointlabel1Edit() -{ - changeWaypointLabel(IDC_WAYPOINTLABEL1_EDIT, TheKey_waypointPathLabel1); -} - -void WaypointOptions::changeWaypointLabel(Int editControlID, NameKeyType key) -{ - MapObject *theMapObj = getSingleSelectedWaypoint(); - if (theMapObj==nullptr) return; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc->isWaypointLinked(theMapObj)) { - return; - } - // get the edit box - CWnd *pWnd = GetDlgItem(editControlID); - if (pWnd) { - // get the text - CString theText; - pWnd->GetWindowText(theText); - AsciiString name((LPCTSTR)theText); - theMapObj->getProperties()->setAsciiString(key, name); - pDoc->updateLinkedWaypointLabels(theMapObj); - } -} - -void WaypointOptions::OnEditchangeWaypointlabel2Edit() -{ - changeWaypointLabel(IDC_WAYPOINTLABEL2_EDIT, TheKey_waypointPathLabel2); -} - -void WaypointOptions::OnEditchangeWaypointlabel3Edit() -{ - changeWaypointLabel(IDC_WAYPOINTLABEL3_EDIT, TheKey_waypointPathLabel3); -} - -void WaypointOptions::OnWaypointBidirectional() -{ - MapObject *theMapObj = getSingleSelectedWaypoint(); - if (theMapObj==nullptr) return; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (!pDoc->isWaypointLinked(theMapObj)) { - return; - } - // get the edit box - CButton *pWnd = (CButton *)GetDlgItem(IDC_WAYPOINT_BIDIRECTIONAL); - if (pWnd) { - Bool checked = pWnd->GetCheck()==1; - // get the text - CString theText; - pWnd->GetWindowText(theText); - AsciiString name((LPCTSTR)theText); - theMapObj->getProperties()->setBool(TheKey_waypointPathBiDirectional, checked); - pDoc->updateLinkedWaypointLabels(theMapObj); - } -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointTool.cpp deleted file mode 100644 index 7a469ef50c4..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WaypointTool.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WaypointTool.cpp -// Texture tiling tool for worldbuilder. -// Author: John Ahlquist, April 2001 - -#include "StdAfx.h" -#include "resource.h" - -#include "WaypointTool.h" -#include "PointerTool.h" -#include "CUndoable.h" -#include "TerrainMaterial.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MainFrm.h" -#include "DrawObject.h" -#include "Common/WellKnownKeys.h" - -// -// WaypointTool class. -// - -Bool WaypointTool::m_isActive = false; - - -/// Constructor -WaypointTool::WaypointTool() : - Tool(ID_WAYPOINT_TOOL, IDC_WAYPOINT) -{ -} - -/// Destructor -WaypointTool::~WaypointTool() -{ -} - -/// Clears it's is active flag. -void WaypointTool::deactivate() -{ - m_isActive = false; -} - -/// Shows the terrain materials options panel. -void WaypointTool::activate() -{ - CMainFrame::GetMainFrame()->showOptionsDialog(IDD_WAYPOINT_OPTIONS); - WaypointOptions::update(); - DrawObject::setDoBrushFeedback(false); - m_isActive = true; -} - -// Pick a waypoint. -MapObject *WaypointTool::pickWaypoint(Coord3D loc){ - // Tight check first. - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (!pObj->isWaypoint()) { - continue; - } - Coord3D cloc = *pObj->getLocation(); - // Check and see if we are within 1/2 cell size of the center. - Coord3D cpt = loc; - cpt.x -= cloc.x; - cpt.y -= cloc.y; - cpt.z = 0; - if (cpt.length() < 0.5f*MAP_XY_FACTOR) { - return pObj; - } - } - // Loose check - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (!pObj->isWaypoint()) { - continue; - } - Coord3D cloc = *pObj->getLocation(); - // Check and see if we are within 1 & 1/2 cell size of the center. - Coord3D cpt = loc; - cpt.x -= cloc.x; - cpt.y -= cloc.y; - cpt.z = 0; - if (cpt.length() < 1.5f*MAP_XY_FACTOR) { - return pObj; - } - } - return nullptr; -} - - -/// Perform the tool behavior on mouse down. -void WaypointTool::mouseDown(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - m_downWaypointID = 0; - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - MapObject *pObj = pickWaypoint(docPt); - if (pObj) { - pObj->setSelected(true); - m_downWaypointID = pObj->getWaypointID(); - docPt = *pObj->getLocation(); - WaypointOptions::update(); - } else { - pView->snapPoint(&docPt); - MapObject *pNew = newInstance( MapObject)(docPt, "*Waypoints/Waypoint", 0, 0, nullptr, nullptr ); - Int id = pDoc->getNextWaypointID(); - AsciiString name = WaypointOptions::GenerateUniqueName(id); - pNew->setSelected(true); - pNew->setIsWaypoint(); - pNew->setWaypointID(id); - pNew->setWaypointName(name); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, "team"); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pNew = nullptr; // undoable owns it now. - m_downWaypointID = id; - WaypointOptions::update(); - } - m_mouseDownPt = docPt; -} - -/// Left button move code. -void WaypointTool::mouseMoved(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - if (m != TRACK_L) return; - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - MapObject *pObj = pickWaypoint(docPt); - if (pObj) { - docPt = *pObj->getLocation(); - } else { - pView->snapPoint(&docPt); - } - DrawObject::setWaypointDragFeedback(m_mouseDownPt, docPt); - pView->Invalidate(); -} - -/** Execute the tool on mouse up - Place an object. */ -void WaypointTool::mouseUp(TTrackingMode m, CPoint viewPt, WbView* pView, CWorldBuilderDoc *pDoc) -{ - DrawObject::stopWaypointDragFeedback(); - if (m != TRACK_L) return; - - Coord3D docPt; - pView->viewToDocCoords(viewPt, &docPt); - MapObject *pObj; - PointerTool::clearSelection(); - pObj = pickWaypoint(docPt); - if (pObj == nullptr) { - pView->snapPoint(&docPt); - MapObject *pNew = newInstance( MapObject)(docPt, "*Waypoints/Waypoint", 0, 0, nullptr, nullptr ); - Int id = pDoc->getNextWaypointID(); - AsciiString name; - name.format("Waypoint %d", id); - pNew->setSelected(true); - pNew->setIsWaypoint(); - pNew->setWaypointID(id); - pNew->setWaypointName(name); - pNew->getProperties()->setAsciiString(TheKey_originalOwner, "team"); - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pNew); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pObj = pNew; - pNew = nullptr; // undoable owns it now. - } - if (pObj) - { - pObj->setSelected(true); - if (m_downWaypointID && (pObj->getWaypointID() != m_downWaypointID)) - { - Int waypointID = pObj->getWaypointID(); - // If a link - if (pDoc->waypointLinkExists(m_downWaypointID, waypointID)) - { - pDoc->removeWaypointLink(m_downWaypointID, waypointID); - } - else if (m_downWaypointID != waypointID) - { - pDoc->addWaypointLink(m_downWaypointID, waypointID); - } - MapObject *pDown = pDoc->getWaypointByID(m_downWaypointID); - if (pDown) { - pDoc->updateLinkedWaypointLabels(pDown); - } - } - WaypointOptions::update(); - } - -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp deleted file mode 100644 index 888d8ef5c4e..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp +++ /dev/null @@ -1,715 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldBuilder.cpp : Defines the class behaviors for the application. -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "MainFrm.h" -#include "OpenMap.h" -#include "SplashScreen.h" -#include "WW3D2/textureloader.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "WBFrameWnd.h" -#include "wbview3d.h" - -//#include -#include "W3DDevice/GameClient/W3DFileSystem.h" -#include "Common/FramePacer.h" -#include "Common/GlobalData.h" -#include "WHeightMapEdit.h" -//#include "Common/GameFileSystem.h" -#include "Common/FileSystem.h" -#include "Common/ArchiveFileSystem.h" -#include "Common/LocalFileSystem.h" -#include "Common/Debug.h" -#include "Common/StackDump.h" -#include "Common/GameMemory.h" -#include "Common/Science.h" -#include "Common/ThingFactory.h" -#include "Common/INI.h" -#include "Common/GameAudio.h" -#include "Common/SpecialPower.h" -#include "Common/TerrainTypes.h" -#include "Common/DamageFX.h" -#include "Common/Upgrade.h" -#include "Common/ModuleFactory.h" -#include "Common/PlayerTemplate.h" -#include "Common/MultiplayerSettings.h" - -#include "GameLogic/Armor.h" -#include "GameLogic/CaveSystem.h" -#include "GameLogic/CrateSystem.h" -#include "GameLogic/ObjectCreationList.h" -#include "GameLogic/Weapon.h" -#include "GameLogic/RankInfo.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/ScriptEngine.h" -#include "GameLogic/ScriptActions.h" -#include "GameClient/Anim2D.h" -#include "GameClient/GameText.h" -#include "GameClient/ParticleSys.h" -#include "GameClient/Water.h" -#include "GameClient/TerrainRoads.h" -#include "GameClient/FXList.h" -#include "GameClient/VideoPlayer.h" -#include "GameLogic/Locomotor.h" - -#include "W3DDevice/Common/W3DModuleFactory.h" -#include "W3DDevice/GameClient/W3DParticleSys.h" -#include "MilesAudioDevice/MilesAudioManager.h" - -#include -#include "Win32Device/GameClient/Win32Mouse.h" -#include "Win32Device/Common/Win32LocalFileSystem.h" -#include "Win32Device/Common/Win32BIGFileSystem.h" - - -static SubsystemInterfaceList TheSubsystemListRecord; - -template -void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = nullptr, const char* path2 = nullptr) -{ - sysref = sys; - TheSubsystemListRecord.initSubsystem(sys, path1, path2, nullptr); -} - - -#define APP_SECTION "WorldbuilderApp" -#define OPEN_FILE_DIR "OpenDirectory" - -Win32Mouse *TheWin32Mouse = nullptr; -const char *gAppPrefix = "wb_"; /// So WB can have a different debug log file name. -const Char *g_strFile = "data\\Generals.str"; -const Char *g_csfFile = "data\\%s\\Generals.csf"; - -///////////////////////////////////////////////////////////////////////////// -// WBGameFileClass - extends the file system a bit so we can get at some -// wb only data. jba. - -class WBGameFileClass : public GameFileClass -{ - -public: - WBGameFileClass(char const *filename):GameFileClass(filename){}; - virtual char const * Set_Name(char const *filename) override; -}; - -//------------------------------------------------------------------------------------------------- -/** Sets the file name, and finds the GDI asset if present. */ -//------------------------------------------------------------------------------------------------- -char const * WBGameFileClass::Set_Name( char const *filename ) -{ - char const *pChar = GameFileClass::Set_Name(filename); - if (this->Is_Available()) { - return pChar; // it was found by the parent class. - } - - if (TheFileSystem->doesFileExist(filename)) { - strlcpy(m_filePath, filename, ARRAY_SIZE(m_filePath)); - m_fileExists = true; - } - return m_filename; -} - - - -///////////////////////////////////////////////////////////////////////////// -// WB_W3DFileSystem - extends the file system a bit so we can get at some -// wb only data. jba. - -class WB_W3DFileSystem : public W3DFileSystem { - virtual FileClass * Get_File( char const *filename ) override; -}; - -//------------------------------------------------------------------------------------------------- -/** Gets a file with the specified filename. */ -//------------------------------------------------------------------------------------------------- -FileClass * WB_W3DFileSystem::Get_File( char const *filename ) -{ - WBGameFileClass *pFile = new WBGameFileClass( filename ); - if (!pFile->Is_Available()) { - pFile->Set_Name(filename); - } - return pFile; -} - - - - -///////////////////////////////////////////////////////////////////////////// -// The one and only CWorldBuilderApp object - -static CWorldBuilderApp theApp; -HWND ApplicationHWnd = nullptr; - -/** - * The ApplicationHInstance is needed for the WOL code, - * which needs it for the COM initialization of WOLAPI.DLL. - * Of course, the WOL code is in gameengine, while the - * HINSTANCE is only in the various projects' main files. - * So, we need to create the HINSTANCE, even if it always - * stays null. Just to make COM happy. Whee. - */ -HINSTANCE ApplicationHInstance = nullptr; - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderApp - -BEGIN_MESSAGE_MAP(CWorldBuilderApp, CWinApp) - //{{AFX_MSG_MAP(CWorldBuilderApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(IDM_RESET_WINDOWS, OnResetWindows) - ON_COMMAND(ID_FILE_OPEN, OnFileOpen) - ON_COMMAND(ID_TEXTURESIZING_MAPCLIFFTEXTURES, OnTexturesizingMapclifftextures) - ON_UPDATE_COMMAND_UI(ID_TEXTURESIZING_MAPCLIFFTEXTURES, OnUpdateTexturesizingMapclifftextures) - //}}AFX_MSG_MAP - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) - // Standard print setup command - ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -static Int gFirstCP = 0; - -// CWorldBuilderApp construction - -CWorldBuilderApp::CWorldBuilderApp() : - m_curTool(nullptr), - m_selTool(nullptr), - m_lockCurTool(0), - m_3dtemplate(nullptr), - m_pasteMapObjList(nullptr) -{ - - for (Int i=0; iExceptionRecord->ExceptionCode, e_info); - return EXCEPTION_EXECUTE_HANDLER; -} - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderApp initialization - -BOOL CWorldBuilderApp::InitInstance() -{ - ApplicationHWnd = GetDesktopWindow(); - - // initialization - SetUnhandledExceptionFilter(UnHandledExceptionFilter); - - // initialize the memory manager early - initMemoryManager(); - -#ifdef DEBUG_LOGGING - // Turn on console output jba [3/20/2003] - DebugSetFlags(DebugGetFlags() | DEBUG_FLAG_LOG_TO_CONSOLE); -#endif - - DEBUG_LOG(("starting Worldbuilder.")); - -#ifdef RTS_DEBUG - DEBUG_LOG(("RTS_DEBUG defined.")); -#endif -#ifdef MEMORYPOOL_CHECKPOINTING - gFirstCP = TheMemoryPoolFactory->debugSetCheckpoint(); -#endif - - SplashScreen loadWindow; - loadWindow.Create(IDD_LOADING, loadWindow.GetDesktopWindow()); - loadWindow.SetWindowText("Loading Worldbuilder"); - loadWindow.ShowWindow(SW_SHOW); - loadWindow.UpdateWindow(); - - CRect rect(15, 315, 230, 333); - loadWindow.setTextOutputLocation(rect); - loadWindow.outputText(IDS_SPLASH_LOADING); - - // not part of the subsystem list, because it should normally never be reset! - TheNameKeyGenerator = new NameKeyGenerator; - TheNameKeyGenerator->init(); - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - // Set the current directory to the app directory. - char buf[_MAX_PATH]; - GetModuleFileName(nullptr, buf, sizeof(buf)); - if (char *pEnd = strrchr(buf, '\\')) { - *pEnd = 0; - } - ::SetCurrentDirectory(buf); - - TheFileSystem = new FileSystem; - - initSubsystem(TheLocalFileSystem, (LocalFileSystem*)new Win32LocalFileSystem); - initSubsystem(TheArchiveFileSystem, (ArchiveFileSystem*)new Win32BIGFileSystem); - - // Just for kicks, get the HINSTANCE that WOL would need - // if we were going to use it, which we aren't. - ApplicationHInstance = AfxGetInstanceHandle(); - - INI ini; - - initSubsystem(TheWritableGlobalData, new GlobalData(), "Data\\INI\\Default\\GameData", "Data\\INI\\GameData"); - - TheFramePacer = new FramePacer(); - -#if defined(RTS_DEBUG) - ini.loadFileDirectory( "Data\\INI\\GameDataDebug", INI_LOAD_MULTIFILE, nullptr ); -#endif - -#ifdef DEBUG_CRASHING - TheWritableGlobalData->m_debugIgnoreAsserts = false; -#endif - - DEBUG_LOG(("TheWritableGlobalData %x", TheWritableGlobalData)); -#if 1 - // srj sez: put INI into our user data folder, not the ap dir - free((void*)m_pszProfileName); - strlcpy(buf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(buf)); - strlcat(buf, "WorldBuilder.ini", ARRAY_SIZE(buf)); -#else - strlcat(buf, "//", ARRAY_SIZE(buf)); - strlcat(buf, m_pszProfileName, ARRAY_SIZE(buf)); - free((void*)m_pszProfileName); -#endif - m_pszProfileName = (const char *)malloc(strlen(buf)+2); - strcpy((char*)m_pszProfileName, buf); - - // ensure the user maps dir exists - snprintf(buf, ARRAY_SIZE(buf), "%sMaps\\", TheGlobalData->getPath_UserData().str()); - CreateDirectory(buf, nullptr); - - // read the water settings from INI (must do prior to initing GameClient, apparently) - ini.loadFileDirectory( "Data\\INI\\Default\\Water", INI_LOAD_OVERWRITE, nullptr ); - ini.loadFileDirectory( "Data\\INI\\Water", INI_LOAD_OVERWRITE, nullptr ); - - initSubsystem(TheGameText, CreateGameTextInterface()); - initSubsystem(TheScienceStore, new ScienceStore(), "Data\\INI\\Default\\Science", "Data\\INI\\Science"); - initSubsystem(TheMultiplayerSettings, new MultiplayerSettings(), "Data\\INI\\Default\\Multiplayer", "Data\\INI\\Multiplayer"); - initSubsystem(TheTerrainTypes, new TerrainTypeCollection(), "Data\\INI\\Default\\Terrain", "Data\\INI\\Terrain"); - initSubsystem(TheTerrainRoads, new TerrainRoadCollection(), "Data\\INI\\Default\\Roads", "Data\\INI\\Roads"); - - WorldHeightMapEdit::init(); - - initSubsystem(TheScriptEngine, (ScriptEngine*)(new ScriptEngine())); - -#if RTS_ZEROHOUR - TheScriptEngine->turnBreezeOff(); // stop the tree sway. -#endif - - // [2/11/2003] - ini.loadFileDirectory( "Data\\Scripts\\Scripts", INI_LOAD_OVERWRITE, nullptr ); - - initSubsystem(TheAudio, (AudioManager*)new MilesAudioManager()); - initSubsystem(TheVideoPlayer, (VideoPlayerInterface*)(new VideoPlayer())); - initSubsystem(TheModuleFactory, (ModuleFactory*)(new W3DModuleFactory())); - initSubsystem(TheSidesList, new SidesList()); - initSubsystem(TheCaveSystem, new CaveSystem()); - initSubsystem(TheRankInfoStore, new RankInfoStore(), nullptr, "Data\\INI\\Rank"); - initSubsystem(ThePlayerTemplateStore, new PlayerTemplateStore(), "Data\\INI\\Default\\PlayerTemplate", "Data\\INI\\PlayerTemplate"); - initSubsystem(TheSpecialPowerStore, new SpecialPowerStore(), "Data\\INI\\Default\\SpecialPower", "Data\\INI\\SpecialPower" ); - initSubsystem(TheParticleSystemManager, (ParticleSystemManager*)(new W3DParticleSystemManager())); - initSubsystem(TheFXListStore, new FXListStore(), "Data\\INI\\Default\\FXList", "Data\\INI\\FXList"); - initSubsystem(TheWeaponStore, new WeaponStore(), nullptr, "Data\\INI\\Weapon"); - initSubsystem(TheObjectCreationListStore, new ObjectCreationListStore(), "Data\\INI\\Default\\ObjectCreationList", "Data\\INI\\ObjectCreationList"); - initSubsystem(TheLocomotorStore, new LocomotorStore(), nullptr, "Data\\INI\\Locomotor"); - initSubsystem(TheDamageFXStore, new DamageFXStore(), nullptr, "Data\\INI\\DamageFX"); - initSubsystem(TheArmorStore, new ArmorStore(), nullptr, "Data\\INI\\Armor"); - initSubsystem(TheThingFactory, new ThingFactory(), "Data\\INI\\Default\\Object", "Data\\INI\\Object"); - initSubsystem(TheCrateSystem, new CrateSystem(), "Data\\INI\\Default\\Crate", "Data\\INI\\Crate"); - initSubsystem(TheUpgradeCenter, new UpgradeCenter, "Data\\INI\\Default\\Upgrade", "Data\\INI\\Upgrade"); - initSubsystem(TheAnim2DCollection, new Anim2DCollection ); //Init's itself. - - TheSubsystemListRecord.postProcessLoadAll(); - - TheW3DFileSystem = new WB_W3DFileSystem; - - // Just to be sure - wb doesn't do well with half res terrain. - DEBUG_ASSERTCRASH(!TheGlobalData->m_useHalfHeightMap, ("TheGlobalData->m_useHalfHeightMap : Don't use this setting in WB.")); - TheWritableGlobalData->m_useHalfHeightMap = false; - -#if ENABLE_CONFIGURABLE_SHROUD - // WB never uses the shroud. With shroud, terrain is black. - TheWritableGlobalData->m_shroudOn = FALSE; -#endif - - TheWritableGlobalData->m_isWorldBuilder = TRUE; - - // Change the registry key under which our settings are stored. - // TODO: You should modify this string to be something appropriate - // such as the name of your company or organization. - //SetRegistryKey(_T("Local AppWizard-Generated Applications")); - - LoadStdProfileSettings(); // Load standard INI file options (including MRU) - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - m_3dtemplate = new CSingleDocTemplate( - IDR_MAPDOC, - RUNTIME_CLASS(CWorldBuilderDoc), - RUNTIME_CLASS(CWB3dFrameWnd), - RUNTIME_CLASS(WbView3d)); - - AddDocTemplate(m_3dtemplate); - -#ifdef MDI - CMainFrame* pMainFrame = new CMainFrame; - if (!pMainFrame->LoadFrame(IDR_MAPDOC)) - return FALSE; - m_pMainWnd = pMainFrame; -#endif - - // Parse command line for standard shell commands, DDE, file open - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - if (!ProcessShellCommand(cmdInfo)) - return FALSE; - - // The one and only window has been initialized, so show and update it. - m_pMainWnd->ShowWindow(SW_SHOW); - m_pMainWnd->UpdateWindow(); - - // Parse command line for standard shell commands, DDE, file open -// CCommandLineInfo cmdInfo; -// ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line -// if (!ProcessShellCommand(cmdInfo)) -// return FALSE; - - selectPointerTool(); - - CString openDir = this->GetProfileString(APP_SECTION, OPEN_FILE_DIR); - m_currentDirectory = openDir; - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderApp message handlers - -BOOL CWorldBuilderApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, - AFX_CMDHANDLERINFO* pHandlerInfo) -{ - // If pHandlerInfo is null, then handle the message - if (pHandlerInfo == nullptr) - { - for (Int i=0; igetToolID()) { - if (nCode == CN_COMMAND) - { - // Handle WM_COMMAND message - setActiveTool(pTool); - } - else if (nCode == CN_UPDATE_COMMAND_UI) - { - // Update UI element state - CCmdUI *pUI = (CCmdUI*)pExtra; - pUI->SetCheck(m_curTool == pTool?1:0); - pUI->Enable(true); - } - return TRUE; - } - } - } - - // If we didn't process the command, call the base class - // version of OnCmdMsg so the message-map can handle the message - return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); -} - -//============================================================================= -// CWorldBuilderApp::selectPointerTool -//============================================================================= -/** Sets the active tool to the pointer, and clears the selection. */ -//============================================================================= -void CWorldBuilderApp::selectPointerTool() -{ - setActiveTool(&m_pointerTool); - // Clear selection. - m_pointerTool.clearSelection(); -} - -//============================================================================= -// CWorldBuilderApp::setActiveTool -//============================================================================= -/** Sets the active tool, and activates it after deactivating the current tool. */ -//============================================================================= -void CWorldBuilderApp::setActiveTool(Tool *pNewTool) -{ - if (m_curTool == pNewTool) { - // same tool - return; - } - if (m_selTool && m_selTool != pNewTool) { - m_selTool->deactivate(); - } - if (pNewTool) { - pNewTool->activate(); - } - m_curTool = pNewTool; - m_selTool = pNewTool; -} - -//============================================================================= -// CWorldBuilderApp::updateCurTool -//============================================================================= -/** Checks to see if any key modifiers (ctrl or alt) are pressed. If so, -selects the appropriate tool, else uses the normal tool. */ -//============================================================================= -void CWorldBuilderApp::updateCurTool(Bool forceHand) -{ - Tool *curTool = m_curTool; - DEBUG_ASSERTCRASH((m_lockCurTool>=0),("oops")); - if (!m_lockCurTool) { // don't change tools that are doing something. - if (forceHand || (0x8000 & ::GetAsyncKeyState(VK_SPACE))) { - // Space bar gives scroll hand. - m_curTool = &m_handScrollTool; - } else if (0x8000 & ::GetAsyncKeyState(VK_MENU)) { - // Alt key gives eyedropper. - m_curTool = &m_eyedropperTool; - } else if (0x8000 & ::GetAsyncKeyState(VK_CONTROL)) { - // Control key gives pointer. - m_curTool = &m_pointerTool; - } else { - // Else the tool selected in the tool palette. - m_curTool = m_selTool; - } - } - if (curTool != m_curTool) { - m_curTool->activate(); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CWorldBuilderApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderApp message handlers - -int CWorldBuilderApp::ExitInstance() -{ - - WriteProfileString(APP_SECTION, OPEN_FILE_DIR, m_currentDirectory.str()); - m_currentDirectory.clear(); - - ScriptList::reset(); - - TheSubsystemListRecord.shutdownAll(); - - WorldHeightMapEdit::shutdown(); - - delete TheFramePacer; - TheFramePacer = nullptr; - - delete TheFileSystem; - TheFileSystem = nullptr; - - delete TheW3DFileSystem; - TheW3DFileSystem = nullptr; - - delete TheNameKeyGenerator; - TheNameKeyGenerator = nullptr; - -#ifdef MEMORYPOOL_CHECKPOINTING - Int lastCP = TheMemoryPoolFactory->debugSetCheckpoint(); -#endif -#ifdef MEMORYPOOL_CHECKPOINTING - TheMemoryPoolFactory->debugMemoryReport(REPORT_FACTORYINFO | REPORT_CP_LEAKS | REPORT_CP_STACKTRACE, gFirstCP, lastCP); -#endif - #ifdef MEMORYPOOL_DEBUG - TheMemoryPoolFactory->debugMemoryReport(REPORT_POOLINFO | REPORT_POOL_OVERFLOW | REPORT_SIMPLE_LEAKS, 0, 0); - #endif - shutdownMemoryManager(); - - return CWinApp::ExitInstance(); -} - -void CWorldBuilderApp::OnResetWindows() -{ - if (CMainFrame::GetMainFrame()) { - CMainFrame::GetMainFrame()->ResetWindowPositions(); - } - -} - -void CWorldBuilderApp::OnFileOpen() -{ -#ifdef DO_MAPS_IN_DIRECTORIES - TOpenMapInfo info; - OpenMap mapDlg(&info); - if (mapDlg.DoModal() == IDOK) { - if (!info.browse) { - OpenDocumentFile(info.filename); - return; - } - } else { - // cancelled so return. - return; - } -#endif - - CFileStatus status; - if (!m_currentDirectory.isEmpty()) try { - if (CFile::GetStatus(m_currentDirectory.str(), status)) { - if (status.m_attribute & CFile::directory) { - ::SetCurrentDirectory(m_currentDirectory.str()); - } - } - } catch(...) {} - - CWinApp::OnFileOpen(); -} - -void CWorldBuilderApp::OnTexturesizingMapclifftextures() -{ - setActiveTool(&m_floodFillTool); - m_floodFillTool.setAdjustCliffs(true); - -} - -void CWorldBuilderApp::OnUpdateTexturesizingMapclifftextures(CCmdUI* pCmdUI) -{ - // TODO: Add your command update UI handler code here - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp deleted file mode 100644 index 185b81dd1b2..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp +++ /dev/null @@ -1,2659 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// WorldBuilderDoc.cpp : implementation of the CWorldBuilderDoc class -// - -#include "StdAfx.h" -#include "WorldBuilder.h" - -#include -#include -#include - -#include "Common/Debug.h" -#include "Common/DataChunk.h" -#include "Common/PlayerTemplate.h" -#include "Common/MapReaderWriterInfo.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" -#include "Common/WellKnownKeys.h" - -#include "GameClient/Line2D.h" -#include "GameClient/View.h" -#include "GameClient/GameText.h" - -#include "GameLogic/PolygonTrigger.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/ScriptEngine.h" - - -#include "Compression.h" -#include "CUndoable.h" -#include "LayersList.h" -#include "MainFrm.h" -#include "NewHeightMap.h" -#include "SaveMap.h" -#include "ScriptDialog.h" -#include "TerrainMaterial.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "wbview3d.h" -#include "wbview.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "MapPreview.h" - - -// Can't currently have multiple open... jba. -#define notONLY_ONE_AT_A_TIME - -#ifdef ONLY_ONE_AT_A_TIME -static Bool gAlreadyOpen = false; -#endif - -enum DIRECTION -{ - PREFER_CENTER, - PREFER_LEFT, - PREFER_TOP, - PREFER_RIGHT, - PREFER_BOTTOM, -}; - -static bool secondGreaterThan(const std::pair& __t1, const std::pair& __t2) -{ - return __t1.second > __t2.second; -} - -static void FindIndexNearest(CWorldBuilderDoc* pDoc, const Coord3D* point, CPoint* outNdx, DIRECTION pref ); -static Bool IndexInRect(CWorldBuilderDoc* pDoc, const Coord3D* bl, const Coord3D* tl, const Coord3D* br, const Coord3D* tr, CPoint* index); -static Bool AddUniqueAndNeighbors(CWorldBuilderDoc* pDoc, const Coord3D* bl, const Coord3D* tl, const Coord3D* br, const Coord3D* tr, CPoint ndx, VecHeightMapIndexes* allIndices); -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderDoc - -IMPLEMENT_DYNCREATE(CWorldBuilderDoc, CDocument) - -BEGIN_MESSAGE_MAP(CWorldBuilderDoc, CDocument) - //{{AFX_MSG_MAP(CWorldBuilderDoc) - ON_COMMAND(ID_EDIT_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) - ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) - ON_COMMAND(ID_TS_INFO, OnTsInfo) - ON_COMMAND(ID_TS_CANONICAL, OnTsCanonical) - ON_UPDATE_COMMAND_UI(ID_TS_CANONICAL, OnUpdateTsCanonical) - ON_COMMAND(ID_FILE_RESIZE, OnFileResize) - ON_COMMAND(ID_FILE_JUMPTOGAME, OnJumpToGame) - ON_COMMAND(ID_TS_REMAP, OnTsRemap) - ON_COMMAND(ID_EDIT_LINK_CENTERS, OnEditLinkCenters) - ON_UPDATE_COMMAND_UI(ID_EDIT_LINK_CENTERS, OnUpdateEditLinkCenters) - ON_COMMAND(ID_VIEW_TIME_OF_DAY, OnViewTimeOfDay) - ON_COMMAND(ID_WINDOW_2DWINDOW, OnWindow2dwindow) - ON_UPDATE_COMMAND_UI(ID_WINDOW_2DWINDOW, OnUpdateWindow2dwindow) - ON_COMMAND(ID_VIEW_RELOADTEXTURES, OnViewReloadtextures) - ON_COMMAND(ID_EDIT_SCRIPTS, OnEditScripts) - ON_COMMAND(ID_SCRIPT_EDIT, OnEditScripts) - ON_COMMAND(ID_VIEWHOME, OnViewHome) - ON_COMMAND(ID_TEXTURESIZING_TILE4X4, OnTexturesizingTile4x4) - ON_UPDATE_COMMAND_UI(ID_TEXTURESIZING_TILE4X4, OnUpdateTexturesizingTile4x4) - ON_COMMAND(ID_TEXTURESIZING_TILE6X6, OnTexturesizingTile6x6) - ON_UPDATE_COMMAND_UI(ID_TEXTURESIZING_TILE6X6, OnUpdateTexturesizingTile6x6) - ON_COMMAND(ID_TEXTURESIZING_TILE8X8, OnTexturesizingTile8x8) - ON_UPDATE_COMMAND_UI(ID_TEXTURESIZING_TILE8X8, OnUpdateTexturesizingTile8x8) - ON_COMMAND(ID_FILE_DUMPTOFILE, OnDumpDocToText) - ON_COMMAND(ID_TEXTURESIZING_REMOVECLIFFTEXMAPPING, OnRemoveclifftexmapping) - ON_COMMAND(ID_TOGGLE_PITCH_AND_ROTATE, OnTogglePitchAndRotation) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderDoc construction/destruction - -CWorldBuilderDoc::CWorldBuilderDoc() : - m_heightMap(nullptr), - m_undoList(nullptr), - m_maxUndos(MAX_UNDOS), /// @todo: get from pref? - m_curRedo(0), - m_needAutosave(false), - m_curWaypointID(0), - m_numWaypointLinks(0), - m_waypointTableNeedsUpdate(true), - m_linkCenters(true) -{ -} - -CWorldBuilderDoc::~CWorldBuilderDoc() -{ -#ifdef ONLY_ONE_AT_A_TIME - if (m_heightMap != nullptr ) { - gAlreadyOpen = false; - } -#endif - REF_PTR_RELEASE(m_heightMap); - REF_PTR_RELEASE(m_undoList); -} - - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderDoc serialization - -class MFCFileOutputStream : public OutputStream -{ -protected: - CFile *m_file; -public: - MFCFileOutputStream(CFile *pFile):m_file(pFile) {}; - virtual Int write(const void *pData, Int numBytes) override { - Int numBytesWritten = 0; - try { - m_file->Write(pData, numBytes); - numBytesWritten = numBytes; - } catch(...) {} - return(numBytesWritten); - }; -}; - -struct CachedChunk -{ - UnsignedByte *pData; - Int size; -}; - -class CachedMFCFileOutputStream : public OutputStream -{ -protected: - CFile *m_file; - std::list m_cachedChunks; - Int m_totalBytes; -public: - CachedMFCFileOutputStream(CFile *pFile):m_file(pFile), m_totalBytes(0) {}; - virtual Int write(const void *pData, Int numBytes) override { - UnsignedByte *tmp = new UnsignedByte[numBytes]; - memcpy(tmp, pData, numBytes); - CachedChunk c; - c.pData = tmp; - c.size = numBytes; - m_cachedChunks.push_back(c); - DEBUG_LOG(("Caching %d bytes in chunk %d", numBytes, m_cachedChunks.size())); - m_totalBytes += numBytes; - return(numBytes); - }; - virtual void flush() { - while (!m_cachedChunks.empty())//!m_cachedChunks.empty()) - { - CachedChunk c = m_cachedChunks.front(); - m_cachedChunks.pop_front(); - try { - DEBUG_LOG(("Flushing %d bytes", c.size)); - m_file->Write(c.pData, c.size); - } catch(...) {} - delete[] c.pData; - m_totalBytes -= c.size; - } - } -}; - -class CompressedCachedMFCFileOutputStream : public OutputStream -{ -protected: - CFile *m_file; - std::list m_cachedChunks; - Int m_totalBytes; -public: - CompressedCachedMFCFileOutputStream(CFile *pFile):m_file(pFile), m_totalBytes(0) {}; - virtual Int write(const void *pData, Int numBytes) override { - UnsignedByte *tmp = new UnsignedByte[numBytes]; - memcpy(tmp, pData, numBytes); - CachedChunk c; - c.pData = tmp; - c.size = numBytes; - m_cachedChunks.push_back(c); - //DEBUG_LOG(("Caching %d bytes in chunk %d", numBytes, m_cachedChunks.size())); - m_totalBytes += numBytes; - return(numBytes); - }; - virtual void flush() { - if (!m_totalBytes) - return; - UnsignedByte *srcBuffer = NEW UnsignedByte[m_totalBytes]; - UnsignedByte *insertPos = srcBuffer; - while (!m_cachedChunks.empty()) - { - CachedChunk c = m_cachedChunks.front(); - m_cachedChunks.pop_front(); - try { - //DEBUG_LOG(("Flushing %d bytes", c.size)); - memcpy(insertPos, c.pData, c.size); - insertPos += c.size; - } catch(...) {} - delete[] c.pData; - } - CompressionType compressionToUse = CompressionManager::getPreferredCompression(); - Dict *worldDict = MapObject::getWorldDict(); - if (worldDict) - { - Bool exists = FALSE; - compressionToUse = (CompressionType)worldDict->getInt(TheKey_compression, &exists); - if (!exists || compressionToUse > COMPRESSION_MAX || compressionToUse < COMPRESSION_MIN) - compressionToUse = CompressionManager::getPreferredCompression(); - } - - Int compressedLen = CompressionManager::getMaxCompressedSize( m_totalBytes, compressionToUse ); - UnsignedByte *destBuffer = NEW UnsignedByte[compressedLen]; - compressedLen = CompressionManager::compressData( compressionToUse, srcBuffer, m_totalBytes, destBuffer, compressedLen ); - DEBUG_LOG(("Compressed %d bytes to %d bytes - compression of %g%%", m_totalBytes, compressedLen, - compressedLen/(Real)m_totalBytes*100.0f)); - DEBUG_ASSERTCRASH(compressedLen, ("Failed to compress!")); - if (compressedLen) - { - m_file->Write(destBuffer, compressedLen); - } - else - { - m_file->Write(srcBuffer, m_totalBytes); - } - delete[] srcBuffer; - srcBuffer = nullptr; - delete[] destBuffer; - destBuffer = nullptr; - } -}; - - -void CWorldBuilderDoc::Serialize(CArchive& ar) -{ - ar.Flush(); - m_waypointTableNeedsUpdate = true; - if (ar.IsStoring() && m_heightMap) - { - try { - Int i; - MapPreview mPreview; - mPreview.save(ar.GetFile()->GetFilePath()); - - CompressedCachedMFCFileOutputStream theStream(ar.GetFile()); - DataChunkOutput *chunkWriter = new DataChunkOutput(&theStream); - - - m_heightMap->saveToFile(*chunkWriter); - /***************WAYPOINTS DATA ***************/ - chunkWriter->openDataChunk("WaypointsList", K_WAYPOINTS_VERSION_1); - chunkWriter->writeInt(this->m_numWaypointLinks); - for (i=0; iwriteInt(this->m_waypointLinks[i].waypoint1); - chunkWriter->writeInt(this->m_waypointLinks[i].waypoint2); - } - chunkWriter->closeDataChunk(); - - delete chunkWriter; - chunkWriter = nullptr; - theStream.flush(); - } catch(...) { - const char *msg = "WorldHeightMapEdit::WorldHeightMapEdit height map file write failed: "; - AfxMessageBox(msg); - return; - } - } - else - { - WorldHeightMapEdit *pOldHeightMap = m_heightMap; - CString pth = ar.GetFile()->GetFilePath(); - CachedFileInputStream theInputStream; - if (theInputStream.open(AsciiString((const char *)pth))) - try { - - WbApp()->selectPointerTool(); - PolygonTrigger::deleteTriggers(); - ChunkInputStream *pStrm = &theInputStream; - - // Read the logical data (map objects, waypoints, etc.) - WorldHeightMap *terrainHeightMap = new WorldHeightMap(pStrm, true); - REF_PTR_RELEASE(terrainHeightMap); - pStrm->absoluteSeek(0); - // Read & keep the graphical data. - m_heightMap = NEW_REF(WorldHeightMapEdit, (pStrm)); - pStrm->absoluteSeek(0); - try { - DataChunkInput file( pStrm ); - if (file.isValidFileType()) { // Backwards compatible files aren't valid data chunk files. - // Read the waypoints. - file.registerParser( "WaypointsList", AsciiString::TheEmptyString, ParseWaypointDataChunk ); - if (!file.parse(this)) { - throw(ERROR_CORRUPT_FILE_FORMAT); - } - } - } catch(...) { - // just eat the error - legacy files aren't chunk format. - } - theInputStream.close(); - - validate(); - - compressWaypointIds(); // remove any unused waypoint ids. - WbView3d * p3View = Get3DView(); - if (p3View) { - p3View->resetRenderObjects(); - } - m_heightMap->optimizeTiles(); // force to optimize tileset - SetHeightMap(m_heightMap, true); - Coord3D center; - center.x = MAP_XY_FACTOR*m_heightMap->getXExtent()/2; - center.y = MAP_XY_FACTOR*m_heightMap->getYExtent()/2; - center.x -= m_heightMap->getBorderSize(); - center.y -= m_heightMap->getBorderSize(); - /* update objects. */ - AsciiString startingCamName = TheNameKeyGenerator->keyToName(TheKey_InitialCameraPosition); - - TheLayersList->resetLayers(); - AsciiString layerName; - Bool exists; - - // always assign unique IDs. The things will still live in the correct layers, so this isn't - // an especially big deal. - MapObject::fastAssignAllUniqueIDs(); - - TheLayersList->disableUpdates(); - MapObject *pMapObj = MapObject::getFirstMapObject(); - while (pMapObj) { - - // Then, add it to the Layers List - layerName = pMapObj->getProperties()->getAsciiString(TheKey_objectLayer, &exists); - if (exists) { - TheLayersList->addMapObjectToLayersList(pMapObj, layerName); - } else { - TheLayersList->addMapObjectToLayersList(pMapObj); - } - - MapObject *pTemplateObj = ObjectOptions::getObjectNamed(pMapObj->getName()); - if (pTemplateObj) { - pMapObj->setColor(pTemplateObj->getColor()); - } - if (pMapObj->isWaypoint()) { - if (pMapObj->getWaypointID() >= m_curWaypointID) { - m_curWaypointID = pMapObj->getWaypointID(); - } - if (startingCamName == pMapObj->getWaypointName()) { - center = *pMapObj->getLocation(); - } - } - pMapObj = pMapObj->getNext(); - } - - PolygonTrigger* polyTrigger = PolygonTrigger::getFirstPolygonTrigger(); - // Add the triggers to the layers list. - while (polyTrigger) { - layerName = polyTrigger->getLayerName(); - TheLayersList->addPolygonTriggerToLayersList(polyTrigger, layerName); - - polyTrigger = polyTrigger->getNext(); - } - - TheLayersList->enableUpdates(); - - TerrainMaterial::updateTextures(m_heightMap); - - REF_PTR_RELEASE(m_undoList); - m_curRedo = 0; - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->setCenterInView(center.x/MAP_XY_FACTOR, center.y/MAP_XY_FACTOR); - } - REF_PTR_RELEASE(pOldHeightMap); - if (p3View) { - p3View->setDefaultCamera(); - } - - } catch(...) { - m_heightMap = pOldHeightMap; - } - - // note - mHeight map has ref count of 1. - } -} - -AsciiString ConvertToNonGCName(AsciiString name, Bool checkTemplate=true) -{ - const char* replacePrefix = "GC_"; - const size_t offset = name.startsWith(replacePrefix) ? strlen(replacePrefix) : 0u; - char newName[256]; - strlcpy(newName, name.str() + offset, ARRAY_SIZE(newName)); - AsciiString swapName; - swapName.set(newName); - if (checkTemplate) - { - const ThingTemplate *tt = TheThingFactory->findTemplate(swapName); - if (tt) { - return swapName; - } - return AsciiString::TheEmptyString; - } - return swapName; -} - -AsciiString ConvertName(AsciiString name) -{ - const char* replacePrefix = "Fundamentalist"; - const size_t offset = name.startsWith(replacePrefix) ? strlen(replacePrefix) : 0u; - char newName[256]; - strcpy(newName, "GLA"); - strlcat(newName, name.str() + offset, ARRAY_SIZE(newName)); - AsciiString swapName; - swapName.set(newName); - const ThingTemplate *tt = TheThingFactory->findTemplate(swapName); - if (tt) { - return swapName; - } - return AsciiString::TheEmptyString; -} - -AsciiString ConvertFaction(AsciiString name) -{ - const char* replacePrefix = "FactionFundamentalist"; - const size_t offset = name.startsWith(replacePrefix) ? strlen(replacePrefix) : 0u; - char newName[256]; - strcpy(newName, "FactionGLA"); - strlcat(newName, name.str() + offset, ARRAY_SIZE(newName)); - AsciiString swapName; - swapName.set(newName); - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(swapName)); - if (pt) { - return swapName; - } - return AsciiString::TheEmptyString; -} - -void CWorldBuilderDoc::validate() -{ - DEBUG_LOG(("Validating")); - - Dict swapDict; - Bool changed = false; - AsciiString swapName; - - Bool needToFixTeams = false; - - // verify/fix the build lists - for (int side=0; sidegetNumSides(); side++) { - SidesInfo *pSide = TheSidesList->getSideInfo(side); - - AsciiString tmplname = pSide->getDict()->getAsciiString(TheKey_playerFaction); - AsciiString playername = pSide->getDict()->getAsciiString(TheKey_playerName); - if (tmplname.isEmpty()) { - continue; // Neutral player has empty template. jba. [8/8/2003] - } - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname)); - if (!pt) { - DEBUG_LOG(("Player '%s' Faction '%s' could not be found in sides list!", playername.str(), tmplname.str())); - if (tmplname.startsWith("FactionFundamentalist")) { - swapName = ConvertFaction(tmplname); - if (swapName != AsciiString::TheEmptyString) { - DEBUG_LOG(("Changing Faction from %s to %s", tmplname.str(), swapName.str())); - pSide->getDict()->setAsciiString(TheKey_playerFaction, swapName); - } - } - } - - BuildListInfo *pBuild = pSide->getBuildList(); - while (pBuild) { - AsciiString name = pBuild->getTemplateName(); - if (name.startsWith("Fundamentalist")) { - swapName = ConvertName(name); - if (swapName != AsciiString::TheEmptyString) { - DEBUG_LOG(("Changing BuildList from %s to %s", name.str(), swapName.str())); - pBuild->setTemplateName(swapName); - } - } - pBuild = pBuild->getNext(); - } - } - - -#define FIX_TEAM(key) \ - type = teamDict->getAsciiString(key, &exists); \ - if (exists) { \ - if (type.startsWith("Fundamentalist")) { \ - swapName = ConvertName(type); \ - if (swapName != AsciiString::TheEmptyString) { \ - DEBUG_LOG(("Changing Team Ref from %s to %s", type.str(), swapName.str())); \ - teamDict->setAsciiString(key, swapName); \ - } \ - } \ - } \ - - // verify/fix the team definitions - Int numTeams = TheSidesList->getNumTeams(); - for (Int team=0; teamgetTeamInfo(team); - Dict* teamDict = ti->getDict(); - AsciiString type; - Bool exists; - FIX_TEAM(TheKey_teamUnitType1) - FIX_TEAM(TheKey_teamUnitType2) - FIX_TEAM(TheKey_teamUnitType3) - FIX_TEAM(TheKey_teamUnitType4) - FIX_TEAM(TheKey_teamUnitType5) - FIX_TEAM(TheKey_teamUnitType6) - FIX_TEAM(TheKey_teamUnitType7) - } - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - // there is no validation code for these items as of yet. - if (pMapObj->isScorch() || pMapObj->isWaypoint() || pMapObj->isLight() || pMapObj->getFlag(FLAG_ROAD_FLAGS) || pMapObj->getFlag(FLAG_BRIDGE_FLAGS)) - { - continue; - } - - // at this point, only objects with models and teams should be left to process - - // start by verifying the ThingTemplate for the object. - // swapDict contains a 'history' of missing model swaps done this load, so all objects with a - // particular name are replaced with the exact same model. - AsciiString name = pMapObj->getName(); - if (pMapObj->getThingTemplate() == nullptr) - { - Bool exists = false; - swapName = swapDict.getAsciiString(NAMEKEY(name), &exists); - - // quick hack to make loading models with "Fundamentalist" switch to "GLA" - if (name.startsWith("Fundamentalist")) { - swapName = ConvertName(name); - if (swapName != AsciiString::TheEmptyString) { - swapDict.setAsciiString(NAMEKEY(name), swapName); - exists = true; - } - } - - // quick hack to remove "GC_" objects from Generals mission disk maps. - if (name.startsWith("GC_")) { - swapName = ConvertToNonGCName(name); - if (swapName != AsciiString::TheEmptyString) { - swapDict.setAsciiString(NAMEKEY(name), swapName); - exists = true; - } - } - - if (!exists) { - ReplaceUnitDialog dlg; - dlg.setMissing(name); - for (int i = ES_FIRST; igetName(); - swapDict.setAsciiString(NAMEKEY(name), swapName); - } - } - } - swapName = swapDict.getAsciiString(NAMEKEY(name), &exists); - if (exists) - { - const ThingTemplate *tt = TheThingFactory->findTemplate(swapName); - if (tt) { - changed = true; - pMapObj->setName(swapName); - pMapObj->setThingTemplate(tt); - DEBUG_LOG(("Changing Map Object from %s to %s", name.str(), swapName.str())); - } - } - } - - - // the following code verifies and fixes the team name, player name, and faction linkages - Bool exists; - AsciiString teamName = pMapObj->getProperties()->getAsciiString(TheKey_originalOwner, &exists); - if (exists) { - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(teamName); - if (teamInfo) { - AsciiString teamOwner = teamInfo->getDict()->getAsciiString(TheKey_teamOwner); - SidesInfo* pSide = TheSidesList->findSideInfo(teamOwner); - if (pSide) { -// Bool hasColor = false; - AsciiString tmplname = pSide->getDict()->getAsciiString(TheKey_playerFaction); - AsciiString playername = pSide->getDict()->getAsciiString(TheKey_playerName); - if (tmplname.isEmpty()) { - continue; // Neutral player has empty template. jba. [8/8/2003] - } - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname)); - if (!pt) { - DEBUG_LOG(("Player '%s' Faction '%s' could not be found in sides list!", playername.str(), tmplname.str())); - if (tmplname.startsWith("FactionFundamentalist")) { - swapName = ConvertFaction(tmplname); - if (swapName != AsciiString::TheEmptyString) { - DEBUG_LOG(("Changing Faction from %s to %s", tmplname.str(), swapName.str())); - pSide->getDict()->setAsciiString(TheKey_playerFaction, swapName); - } - } - } - } else { - needToFixTeams = true; - DEBUG_LOG(("Side '%s' could not be found in sides list!", teamOwner.str())); - } - } else { - needToFixTeams = true; - DEBUG_LOG(("Team '%s' could not be found in sides list!", teamName.str())); - } - } else { - needToFixTeams = true; - DEBUG_LOG(("Object '%s' does not have a team at all!", name.str())); - } - } - if (needToFixTeams) { - AfxMessageBox(IDS_NEED_TO_FIX_TEAMS, MB_OK|MB_ICONERROR); - } -} - -void CWorldBuilderDoc::OnJumpToGame() -{ - try { - DoFileSave(); - CString filename; - DEBUG_LOG(("strTitle=%s strPathName=%s", m_strTitle, m_strPathName)); - if (strstr(m_strPathName, TheGlobalData->getPath_UserData().str()) != nullptr) - filename.Format("%sMaps\\%s", TheGlobalData->getPath_UserData().str(), static_cast(m_strTitle)); - else - filename.Format("Maps\\%s", static_cast(m_strTitle)); - - /*int retval =*/ _spawnl(_P_NOWAIT, "\\projects\\rts\\run\\rtsi.exe", "ignored", "-scriptDebug", "-win", "-file", static_cast(filename), nullptr); - } catch (...) { - } -} - -BOOL CWorldBuilderDoc::DoFileSave() -{ - DWORD dwAttrib = GetFileAttributes(m_strPathName); - if (dwAttrib & FILE_ATTRIBUTE_READONLY) - { - if (dwAttrib != 0xFFFFFFFF) { - ::AfxMessageBox(IDS_FILE_IS_READONLY); - return FALSE; - } - // File does not exist, dwAttrib==0xffffffff - // we do not have read-write access or the file does not (now) exist - if (!DoSave(nullptr)) - { - TRACE0("Warning: File save with new name failed.\n"); - return FALSE; - } - } - else - { - if (!DoSave(m_strPathName)) - { - TRACE0("Warning: File save failed.\n"); - return FALSE; - } - } - return TRUE; -} - -BOOL CWorldBuilderDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace) - // Save the document data to a file - // lpszPathName = path name where to save document file - // if lpszPathName is null then the user will be prompted (SaveAs) - // note: lpszPathName can be different than 'm_strPathName' - // if 'bReplace' is TRUE will change file name if successful (SaveAs) - // if 'bReplace' is FALSE will not change path name (SaveCopyAs) -{ - CString newName = lpszPathName; - if (newName.IsEmpty()) - { - CDocTemplate* pTemplate = GetDocTemplate(); - ASSERT(pTemplate != nullptr); - - newName = m_strPathName; - if (bReplace && newName.IsEmpty()) - { - newName = m_strTitle; - // check for dubious filename - int iBad = newName.FindOneOf(_T(" #%;/\\")); - if (iBad != -1) - newName.ReleaseBuffer(iBad); - - // append the default suffix if there is one - CString strExt; - if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) && - !strExt.IsEmpty()) - { - ASSERT(strExt[0] == '.'); - newName += strExt; - } - } - - TSaveMapInfo info; - info.filename = newName; - SaveMap saveDlg(&info); - if (saveDlg.DoModal() == IDCANCEL) { - return FALSE; - } - if (info.browse) { - if (!AfxGetApp()->DoPromptFileName(newName, - bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY, - OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate)) - return FALSE; // don't even attempt to save - } else { - // Construct file name of .\Maps\mapname\mapname.map - if (info.usingSystemDir) - newName = ".\\Maps\\"; - else - { - newName = TheGlobalData->getPath_UserData().str(); - newName = newName + "Maps\\"; - } - newName += info.filename; - // Create directory. - CFileStatus status; - if (CFile::GetStatus(newName, status)) { - if (!(status.m_attribute&CFile::directory)) { - CString error = "Error: file '" + newName + "' exists, and is not a directory."; - ::AfxMessageBox(error); - return FALSE; - } - } else { - Int status = ::_mkdir(newName); - if (status != 0) { - CString error = "Error: could not create directory '" + newName + "'."; - ::AfxMessageBox(error); - return FALSE; - } - } - newName += "\\"; - newName += info.filename; - newName += ".map"; - } - } - - CWaitCursor wait; - - if (!OnSaveDocument(newName)) - { - if (lpszPathName == nullptr) - { - // be sure to delete the file - try - { - CFile::Remove(newName); - } - catch(...) - { - TRACE0("Warning: failed to delete file after failed SaveAs.\n"); - } - } - return FALSE; - } - - // reset the title and change the document name - if (bReplace) - SetPathName(newName); - - return TRUE; // success -} - - -/** -* CWorldBuilderDoc::ParseWaypointDataChunk - read a waypoint chunk. -* Format is the newer CHUNKY format. -* See WHeightMapEdit.cpp for the writer. -* Input: DataChunkInput -* -*/ -Bool CWorldBuilderDoc::ParseWaypointDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - CWorldBuilderDoc *pThis = (CWorldBuilderDoc *)userData; - return pThis->ParseWaypointData(file, info, userData); -} - -/** -* CWorldBuilderDoc::ParseWaypointData - read waypoint data chunk. -* Format is the newer CHUNKY format. -* See WorldBuilderDoc.cpp for the writer. -* Input: DataChunkInput -* -*/ -Bool CWorldBuilderDoc::ParseWaypointData(DataChunkInput &file, DataChunkInfo *info, void *userData) -{ - m_numWaypointLinks = file.readInt(); - Int i; - for (i=0; im_waypointLinks[i].waypoint1 = file.readInt(); - this->m_waypointLinks[i].waypoint2 = file.readInt(); - //DEBUG_LOG(("Waypoint link from %d to %d", m_waypointLinks[i].waypoint1, m_waypointLinks[i].waypoint2)); - } - DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over.")); - return true; -} - -void CWorldBuilderDoc::autoSave() -{ - // srj sez: put autosave into our user data folder, not the ap dir - AsciiString autosave1 = TheGlobalData->getPath_UserData(); - AsciiString autosave2 = TheGlobalData->getPath_UserData(); - AsciiString autosave3 = TheGlobalData->getPath_UserData(); - autosave1.concat("WorldBuilderAutoSave1.map"); - autosave2.concat("WorldBuilderAutoSave2.map"); - autosave3.concat("WorldBuilderAutoSave3.map"); - - if (m_heightMap) try { - CFileStatus status; - try { - if (CFile::GetStatus(autosave3.str(), status)) { - CFile::Remove(autosave3.str()); - } - } catch(...) {} - try { - if (CFile::GetStatus(autosave2.str(), status)) { - CFile::Rename(autosave2.str(), autosave3.str()); - } - } catch(...){} - try { - if (CFile::GetStatus(autosave1.str(), status)) { - CFile::Rename(autosave1.str(), autosave2.str()); - } - } catch(...){} - - CFile theFile(autosave1.str(), CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite|CFile::typeBinary); - try { - Int i; - MFCFileOutputStream theStream(&theFile); - DataChunkOutput chunkWriter(&theStream); - - m_heightMap->saveToFile(chunkWriter); - /***************WAYPOINTS DATA ***************/ - chunkWriter.openDataChunk("WaypointsList", K_WAYPOINTS_VERSION_1); - chunkWriter.writeInt(this->m_numWaypointLinks); - for (i=0; im_waypointLinks[i].waypoint1); - chunkWriter.writeInt(this->m_waypointLinks[i].waypoint2); - } - chunkWriter.closeDataChunk(); - - } catch(...) { - } - theFile.Close(); - m_needAutosave = false; - } catch(...) { - ::AfxMessageBox(IDS_NO_AUTOSAVE); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderDoc diagnostics - -#ifdef RTS_DEBUG -void CWorldBuilderDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -void CWorldBuilderDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //RTS_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderDoc commands - -void CWorldBuilderDoc::SetHeightMap(WorldHeightMapEdit *pMap, Bool doUpdate) -{ - REF_PTR_SET(m_heightMap, pMap); - if (doUpdate) { - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - IRegion2D partialRange = {0,0,0,0}; - ASSERT_VALID(pWView); - pWView->updateHeightMapInView(m_heightMap, false, partialRange); - pWView->Invalidate(false); - } - } -} - -void CWorldBuilderDoc::AddAndDoUndoable(Undoable *pUndo) -{ - Undoable *pCurUndo = m_undoList; - Int count = m_curRedo; - while(count>0 && pCurUndo != nullptr) { - count--; - pCurUndo = pCurUndo->GetNext(); - } - m_needAutosave = true; - m_waypointTableNeedsUpdate=true; - m_curRedo = 0; - pUndo->LinkNext(pCurUndo); - REF_PTR_SET(m_undoList, pUndo); - pUndo->Do(); - SetModifiedFlag(); - pCurUndo = m_undoList; - count = 0; - while (pCurUndo) { - count++; - if (count >= MAX_UNDOS) { - pCurUndo->LinkNext(nullptr); - break; - } - pCurUndo = pCurUndo->GetNext(); - } -} - -void CWorldBuilderDoc::OnEditRedo() -{ - Undoable *pUndo = m_undoList; - m_needAutosave = true; - m_waypointTableNeedsUpdate=true; - if (m_curRedo>0) { - Int count = m_curRedo-1; - while(count>0) { - count--; - pUndo = pUndo->GetNext(); - } - DEBUG_ASSERTCRASH((pUndo != nullptr),("oops")); - if (pUndo) { - pUndo->Redo(); - SetModifiedFlag(); - m_curRedo--; - } - } -} - -void CWorldBuilderDoc::OnUpdateEditRedo(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(m_undoList!=nullptr && m_curRedo>0); -} - -void CWorldBuilderDoc::OnEditUndo() -{ - Undoable *pUndo = m_undoList; - m_needAutosave = true; - m_waypointTableNeedsUpdate=true; - Int count = m_curRedo; - while(count>0 && pUndo != nullptr) { - count--; - pUndo = pUndo->GetNext(); - } - if (pUndo != nullptr) { - pUndo->Undo(); - SetModifiedFlag(); - m_curRedo++; - } -} - -void CWorldBuilderDoc::OnTogglePitchAndRotation() -{ - WbView3d * p3View = Get3DView(); - if (p3View) - { - p3View->togglePitchAndRotation(); - } -} - -void CWorldBuilderDoc::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - Bool canUndo=false; - if (m_undoList!=nullptr) { - if (m_curRedo == 0) { - canUndo = true; // haven't undone any yet. - } else { - Undoable *pUndo = m_undoList; - Int count = m_curRedo; - while(count>0 && pUndo != nullptr) { - count--; - pUndo = pUndo->GetNext(); - } - canUndo = pUndo != nullptr; - } - } - pCmdUI->Enable(canUndo); -} - - -void CWorldBuilderDoc::OnTsInfo() -{ - if (m_heightMap) { - m_heightMap->showTileStatusInfo(); - } -} - - -void CWorldBuilderDoc::OnTsCanonical() -{ - if (m_heightMap) { - - WorldHeightMapEdit *htMapEditCopy = GetHeightMap()->duplicate(); - if (htMapEditCopy == nullptr) return; - if (htMapEditCopy->optimizeTiles()) { // does all the work. - IRegion2D partialRange = {0,0,0,0}; - updateHeightMap(htMapEditCopy, false, partialRange); - WBDocUndoable *pUndo = new WBDocUndoable(this, htMapEditCopy); - this->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to this now. - } else { - ::Beep(1000,500); - } - REF_PTR_RELEASE(htMapEditCopy); - } -} - -void CWorldBuilderDoc::OnUpdateTsCanonical(CCmdUI* pCmdUI) -{ -} - -void CWorldBuilderDoc::OnFileResize() -{ - TNewHeightInfo hi; - hi.initialHeight = 8; - hi.xExtent = m_heightMap->getXExtent()-2*m_heightMap->getBorderSize(); - hi.yExtent = m_heightMap->getYExtent()-2*m_heightMap->getBorderSize(); - hi.borderWidth = m_heightMap->getBorderSize(); - hi.forResize = true; - CString label; - label.LoadString(IDS_RESIZE); - CNewHeightMap htDialog(&hi, label); - if (IDOK == htDialog.DoModal()) { - htDialog.GetHeightInfo(&hi); - } else { - return; - } - - WorldHeightMapEdit *htMapEditCopy = GetHeightMap()->duplicate(); - if (htMapEditCopy == nullptr) return; - Coord3D objOffset; - if (htMapEditCopy->resize(hi.xExtent, hi.yExtent, hi.initialHeight, hi.borderWidth, - hi.anchorTop, hi.anchorBottom, hi.anchorLeft, hi.anchorRight, &objOffset)) { // does all the work. - WBDocUndoable *pUndo = new WBDocUndoable(this, htMapEditCopy, &objOffset); - this->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to this now. - POSITION pos = GetFirstViewPosition(); - IRegion2D partialRange = {0,0,0,0}; - Get3DView()->updateHeightMapInView(m_heightMap, false, partialRange); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->adjustDocSize(); - pWView->Invalidate(); - } - } else { - ::Beep(1000,500); - } - REF_PTR_RELEASE(htMapEditCopy); - -} - - -void CWorldBuilderDoc::OnTsRemap() -{ - if (m_heightMap) { - WorldHeightMapEdit *htMapEditCopy = GetHeightMap()->duplicate(); - if (htMapEditCopy == nullptr) return; - if (htMapEditCopy->remapTextures()) { // does all the work. - IRegion2D partialRange = {0,0,0,0}; - updateHeightMap(htMapEditCopy, false, partialRange); - WBDocUndoable *pUndo = new WBDocUndoable(this, htMapEditCopy); - this->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to this now. - } else { - ::Beep(1000,500); - } - REF_PTR_RELEASE(htMapEditCopy); - } -} - -/* static */ CWorldBuilderDoc *CWorldBuilderDoc::GetActiveDoc() -{ -#ifdef MDI - CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; - if (pFrame) { - DEBUG_ASSERTCRASH((pFrame == CMainFrame::GetMainFrame()),("oops")); - // Get the active MDI child window. - CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); - if (pChild) { - // Get the active view attached to the active MDI child - // window. - WbView *pView = (WbView *) pChild->GetActiveView(); - if (pView) { - return pView->WbDoc(); - } - } - } - -#else -// only works for SDI, not MDI - return (CWorldBuilderDoc*)CMainFrame::GetMainFrame()->GetActiveDocument(); -#endif - return nullptr; -} - -/* static */ CWorldBuilderView *CWorldBuilderDoc::GetActive2DView() -{ - CWorldBuilderDoc* pDoc = GetActiveDoc(); - if (pDoc) { - return pDoc->Get2DView(); - } - return nullptr; -} - -/* static */ WbView3d *CWorldBuilderDoc::GetActive3DView() -{ - CWorldBuilderDoc* pDoc = GetActiveDoc(); - if (pDoc) { - return pDoc->Get3DView(); - } - return nullptr; -} - -CWorldBuilderView *CWorldBuilderDoc::Get2DView() -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - if (pView->IsKindOf(RUNTIME_CLASS(CWorldBuilderView))) - return (CWorldBuilderView*)pView; - } - - return nullptr; -} - -WbView3d *CWorldBuilderDoc::Get3DView() -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - if (pView->IsKindOf(RUNTIME_CLASS(WbView3d))) - return (WbView3d*)pView; - } - - return nullptr; -} - -void CWorldBuilderDoc::Create2DView() -{ -} - -void CWorldBuilderDoc::Create3DView() -{ - if (Get3DView()) - return; -#ifdef ONLY_ONE_AT_A_TIME - gAlreadyOpen = true; -#endif -#if 1 - CDocTemplate* pTemplate = WbApp()->Get3dTemplate(); - IRegion2D partialRange = {0,0,0,0}; - ASSERT_VALID(pTemplate); - CFrameWnd* pFrame = pTemplate->CreateNewFrame(this, nullptr); - if (pFrame == nullptr) - { - TRACE0("Warning: failed to create new frame.\n"); - return; // command failed - } - pTemplate->InitialUpdateFrame(pFrame, this); - Get3DView()->updateHeightMapInView(m_heightMap, false, partialRange); -#endif -} - - -BOOL CWorldBuilderDoc::OnNewDocument() -{ -#ifdef ONLY_ONE_AT_A_TIME - if (gAlreadyOpen) { - ::AfxMessageBox(IDS_ONLY_ONE_FILE); - return FALSE; - } -#endif - if (!CDocument::OnNewDocument()) - return FALSE; - static Bool firstTime = true; - - // clear out map-specific text - TheGameText->reset(); - - TNewHeightInfo hi; - hi.initialHeight = AfxGetApp()->GetProfileInt("GameOptions", "Default Map Height", 16); - hi.xExtent = AfxGetApp()->GetProfileInt("GameOptions", "Default Map X-size", 100); - hi.yExtent = AfxGetApp()->GetProfileInt("GameOptions", "Default Map Y-size", 100); - hi.borderWidth = AfxGetApp()->GetProfileInt("GameOptions", "Default Map Border", 30); - hi.forResize = false; - if (!firstTime) { - CString label; - label.LoadString(IDS_NEW); - CNewHeightMap htDialog(&hi, label); - if (IDOK == htDialog.DoModal()) { - htDialog.GetHeightInfo(&hi); - AfxGetApp()->WriteProfileInt("GameOptions", "Default Map Height", hi.initialHeight); - AfxGetApp()->WriteProfileInt("GameOptions", "Default Map X-size", hi.xExtent); - AfxGetApp()->WriteProfileInt("GameOptions", "Default Map Y-size", hi.yExtent); - AfxGetApp()->WriteProfileInt("GameOptions", "Default Map Border", hi.borderWidth); - } else { - return(false); - } - } - REF_PTR_RELEASE(m_heightMap); - REF_PTR_RELEASE(m_undoList); - m_curRedo = 0; - m_numWaypointLinks = 0; - m_waypointTableNeedsUpdate = true; - m_curWaypointID = 0; - WbApp()->selectPointerTool(); - - // Make sure that all the old units are removed from the list. - // Bug fix by MLL 1/14/03 - TheLayersList->enableUpdates(); - TheLayersList->resetLayers(); - TheLayersList->disableUpdates(); - - // TheSuperHackers @bugfix Caball009 20/06/2025 Must not delete polygon triggers before calling enableUpdates. - PolygonTrigger::deleteTriggers(); - - TheSidesList->clear(); - TheSidesList->validateSides(); - - WbView3d * p3View = Get3DView(); - if (p3View) { - p3View->resetRenderObjects(); - } - firstTime = false; - m_heightMap = NEW_REF(WorldHeightMapEdit,(hi.xExtent,hi.yExtent,hi.initialHeight, hi.borderWidth)); - // note - mHeight map has ref count of 1. - - // Create a default water area. - PolygonTrigger *pTrig = newInstance(PolygonTrigger)(4); - ICoord3D loc; - pTrig->setWaterArea(true); - pTrig->setTriggerName("Default Water"); - loc.x = -hi.borderWidth*MAP_XY_FACTOR; - loc.y = -hi.borderWidth*MAP_XY_FACTOR; - loc.z = TheGlobalData->m_waterPositionZ; - pTrig->addPoint(loc); - loc.x = (hi.xExtent+hi.borderWidth)*MAP_XY_FACTOR; - pTrig->addPoint(loc); - loc.y = (hi.yExtent+hi.borderWidth)*MAP_XY_FACTOR; - pTrig->addPoint(loc); - loc.x = -hi.borderWidth*MAP_XY_FACTOR; - pTrig->addPoint(loc); - PolygonTrigger::addPolygonTrigger(pTrig); - TheLayersList->addPolygonTriggerToLayersList(pTrig, pTrig->getLayerName()); - SetHeightMap(m_heightMap, true); - TerrainMaterial::updateTextures(m_heightMap); - - Create3DView(); - - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->setCenterInView(m_heightMap->getXExtent()/2-m_heightMap->getBorderSize(), m_heightMap->getYExtent()/2-m_heightMap->getBorderSize()); - } - if (p3View) { - p3View->setDefaultCamera(); - } - return TRUE; -} - -void CWorldBuilderDoc::invalObject(MapObject *pMapObj) -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->invalObjectInView(pMapObj); - } -} - -void CWorldBuilderDoc::invalCell(int xIndex, int yIndex) -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->invalidateCellInView(xIndex, yIndex); - } -} - -void CWorldBuilderDoc::syncViewCenters(Real x, Real y) -{ - if (!m_linkCenters) - return; - - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->setCenterInView(x, y); - } -} - - -void CWorldBuilderDoc::updateAllViews() -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->UpdateWindow(); - } -} - -void CWorldBuilderDoc::updateHeightMap(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) -{ - POSITION pos = GetFirstViewPosition(); - while (pos != nullptr) - { - CView* pView = GetNextView(pos); - WbView* pWView = (WbView *)pView; - ASSERT_VALID(pWView); - pWView->updateHeightMapInView(htMap, partial, partialRange); - pWView->Invalidate(); - } -} - -BOOL CWorldBuilderDoc::OnOpenDocument(LPCTSTR lpszPathName) -{ -#ifdef ONLY_ONE_AT_A_TIME - if (gAlreadyOpen) { - ::AfxMessageBox(IDS_ONLY_ONE_FILE); - return FALSE; - } -#endif - - // Open document dialog may change working directory, - // let the app know what it was for future opens, and change it back. - char buf[_MAX_PATH]; - ::GetCurrentDirectory(_MAX_PATH, buf); - - // clear out map-specific text - TheGameText->reset(); - AsciiString s = lpszPathName; - const char* lastSep = s.reverseFind('\\'); - if (lastSep != nullptr) - { - s.truncateTo(lastSep - s.str() + 1); - } - s.concat("map.str"); - DEBUG_LOG(("Looking for map-specific text in [%s]", s.str())); - TheGameText->initMapStringFile(s); - - WbApp()->setCurrentDirectory(AsciiString(buf)); - ::GetModuleFileName(nullptr, buf, sizeof(buf)); - if (char *pEnd = strrchr(buf, '\\')) { - *pEnd = 0; - } - ::SetCurrentDirectory(buf); - - if (!CDocument::OnOpenDocument(lpszPathName)) - return FALSE; - - Create3DView(); - - return TRUE; -} - -//============================================================================= -// CWorldBuilderView::getCellIndexFromPoint -//============================================================================= -/** Given a cursor location, return the x and y index into the height map. -If the location is outside the height map, returns false. */ -//============================================================================= -Bool CWorldBuilderDoc::getCellIndexFromCoord(Coord3D cpt, CPoint *ndxP) -{ - // Set up default return value. - ndxP->x = -1; - ndxP->y = -1; - Bool inMap = true; - - WorldHeightMapEdit *pMap = GetHeightMap(); - if (pMap == nullptr) return false; - - Int xIndex = floor(cpt.x/MAP_XY_FACTOR); - xIndex += pMap->getBorderSize(); - - // If negative, outside of map so return false. - if (xIndex<0) { - inMap = false; - xIndex = 0; - } - // If larger than the map, return default. - if (xIndex >= pMap->getXExtent()) { - inMap = false; - xIndex = pMap->getXExtent()-1; - } - Int yIndex = floor(cpt.y/MAP_XY_FACTOR); - - yIndex += pMap->getBorderSize(); - - - // If negative, outside of map so return default. - if (yIndex<0) { - inMap = false; - yIndex = 0; - } - - // If larger than the map, return default. - if (yIndex >= pMap->getYExtent()) { - inMap = false; - yIndex = pMap->getYExtent()-1; - } - - - ndxP->x = xIndex; - ndxP->y = yIndex; - - return inMap; -} - -void CWorldBuilderDoc::getCoordFromCellIndex(CPoint ndx, Coord3D* pt) -{ - if (!pt) { - return; - } - WorldHeightMap* hm = GetHeightMap(); - if (!hm) { - return; - } - - (*pt).x = (ndx.x - hm->getBorderSize()) * MAP_XY_FACTOR; - (*pt).y = (ndx.y - hm->getBorderSize()) * MAP_XY_FACTOR; -} - -//============================================================================= -// CWorldBuilderView::getAllIndexesInRect -//============================================================================= -//============================================================================= -Bool CWorldBuilderDoc::getAllIndexesInRect(const Coord3D* bl, const Coord3D* br, - const Coord3D* tl, const Coord3D* tr, - Int widthOutside, VecHeightMapIndexes* allIndices) -{ - // given the four corners of this rectangle, find all indices that are within - // widthOutside of the rect and place them into allIndices. - if (!(bl && br && tl && tr && allIndices)) { - return false; - } - - Coord3D center = { (bl->x + tr->x) / 2, (bl->y + tr->y) / 2, (bl->z + tr->z) / 2 }; - - allIndices->clear(); - - CPoint ndx; - - FindIndexNearest(this, ¢er, &ndx, PREFER_CENTER); - AddUniqueAndNeighbors(this, bl, br, tl, tr, ndx, allIndices); - - FindIndexNearest(this, ¢er, &ndx, PREFER_LEFT); - AddUniqueAndNeighbors(this, bl, br, tl, tr, ndx, allIndices); - - FindIndexNearest(this, ¢er, &ndx, PREFER_TOP); - AddUniqueAndNeighbors(this, bl, br, tl, tr, ndx, allIndices); - - FindIndexNearest(this, ¢er, &ndx, PREFER_RIGHT); - AddUniqueAndNeighbors(this, bl, br, tl, tr, ndx, allIndices); - - FindIndexNearest(this, ¢er, &ndx, PREFER_BOTTOM); - AddUniqueAndNeighbors(this, bl, br, tl, tr, ndx, allIndices); - - return (!allIndices->empty()); -} - - -//============================================================================= -// CWorldBuilderView::getCellPositionFromPoint -//============================================================================= -/** Given a pixel position, returns the x/y location in the height map. This -will return real values, so a position can be 1.7, 2.4 or such. If the position -is not over the height map, return -1, -1. */ -//============================================================================= -Bool CWorldBuilderDoc::getCellPositionFromCoord(Coord3D cpt, Coord3D *locP) -{ - // Set up default values. - locP->x = -1; - locP->y = -1; - WorldHeightMapEdit *pMap = GetHeightMap(); - if (pMap == nullptr) return(false); -// yLocation = pMap->getYExtent() - yLocation; - CPoint curNdx; - if (getCellIndexFromCoord(cpt, &curNdx)) { - locP->x = cpt.x; - locP->y = cpt.y; - locP->z = pMap->getHeight(curNdx.x, curNdx.y)*MAP_HEIGHT_SCALE; - return(true); - } - return false; -} - -//============================================================================= -// CWorldBuilderDoc::getObjArrowPoint -//============================================================================= -/** Gets the location in pixels of the arrowhead point for an object. */ -//============================================================================= -void CWorldBuilderDoc::getObjArrowPoint(MapObject *pObj, Coord3D *location) -{ - // Get the center location, and the angle. - Coord3D loc = *pObj->getLocation(); - float angle = pObj->getAngle(); - // The arrow starts in the +x direction. - Vector3 arrow(1.2f*MAP_XY_FACTOR, 0, 0); - // Rotate - arrow.Rotate_Z(angle); - // Rotated. - location->x = arrow.X; - location->y = arrow.Y; - // Add the rotated offset to the center. - location->x += loc.x; - location->y += loc.y; - //location->z += loc.z; -} - -void CWorldBuilderDoc::OnEditLinkCenters() -{ - m_linkCenters = !m_linkCenters; -} - -void CWorldBuilderDoc::OnUpdateEditLinkCenters(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_linkCenters?1:0); -} - -BOOL CWorldBuilderDoc::CanCloseFrame(CFrameWnd* pFrame) -{ - CView *pView = this->Get2DView(); - if (pView && pView->GetParentFrame() == pFrame) { - return true; // can always close the 2d window. - } - return SaveModified(); -} - -void CWorldBuilderDoc::OnViewTimeOfDay() -{ - WbView3d * pView = Get3DView(); - if (pView) { - pView->stepTimeOfDay(); - } -} - -void CWorldBuilderDoc::OnWindow2dwindow() -{ -/* - CView *pView = this->Get2DView(); - if (pView) { - CFrameWnd *pFrame = pView->GetParentFrame(); - if (pFrame->IsIconic()) { - pFrame->ShowWindow(SW_RESTORE); - } else { - pFrame->DestroyWindow(); - } - } else { - Create2DView(); - } -*/ -} - -void CWorldBuilderDoc::OnUpdateWindow2dwindow(CCmdUI* pCmdUI) -{ -/* - CView *pView = this->Get2DView(); - pCmdUI->SetCheck(pView?1:0); -*/ -} - -//============================================================================= -// CWorldBuilderDoc::compressWaypointIds -//============================================================================= -/** Renumbers the waypoints and the links that reference them, removing any -unused ids. */ -//============================================================================= -void CWorldBuilderDoc::compressWaypointIds() -{ - updateWaypointTable(); - m_curWaypointID = 0; - MapObject *pMapObj = nullptr; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - Int nwpid = getNextWaypointID(); - pMapObj->setWaypointID(nwpid); - } - } - Int i, j; - for (i=0; igetWaypointID(); - m_waypointLinks[i].waypoint2 = pWay2->getWaypointID(); - } else { - // Delete the link. - for (j=i; jgetWaypointID() == m_waypointLinks[i].waypoint1, ("Bad waypoint.")); - DEBUG_ASSERTCRASH(pWay2 && pWay2->getWaypointID() == m_waypointLinks[i].waypoint2, ("Bad waypoint.")); - } - int count = 1; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - DEBUG_ASSERTCRASH(pMapObj->getWaypointID()==count, ("Bad waypoint")); - DEBUG_ASSERTCRASH(pMapObj==getWaypointByID(count), ("Bad waypoint")); - count++; - } - } -#endif -} - -//============================================================================= -// CWorldBuilderDoc::updateWaypointTable -//============================================================================= -/** If any waypoints have changed (m_waypointTableNeedsUpdate) updates the waypoint -table. The waypoint table is used to locate waypoints by id, without searching -the objects list. (See getWaypointByID()) */ -//============================================================================= -void CWorldBuilderDoc::updateWaypointTable() -{ - if (m_waypointTableNeedsUpdate) { - m_waypointTableNeedsUpdate=false; - Int i; - for (i=0; igetNext()) { - if (pMapObj->isWaypoint()) { - Int id = pMapObj->getWaypointID(); - DEBUG_ASSERTCRASH(id>0 && id0 && idsetWaypointID(getNextWaypointID()); - m_waypointTableNeedsUpdate=true; - } else { - m_waypointTable[id] = pMapObj; - } - } - } - } - } -} - -//============================================================================= -// CWorldBuilderDoc::addWaypointLink -//============================================================================= -/** Adds a waypoint link between two waypoints, referenced by waypoint id. */ -//============================================================================= -void CWorldBuilderDoc::addWaypointLink(Int waypointID1, Int waypointID2) -{ - Int i; - for (i=0; i=0 && waypointID0 && waypointIDisWaypoint()) { - return pObj; - } - DEBUG_ASSERTCRASH(pObj==nullptr, ("Waypoint links to an obj that isn't a waypoint.")); - } - return nullptr; -} - -//============================================================================= -// CWorldBuilderDoc::isWaypointLinked -//============================================================================= -/** Returns true if a waypoint is part of a linked waypoint path. */ -//============================================================================= -Bool CWorldBuilderDoc::isWaypointLinked(MapObject *pWay) -{ - updateWaypointTable(); - Int i; - for (i=0; i=0 && waypointID0 && waypointID=0 && waypointID0 && waypointIDgetProperties()->getAsciiString(TheKey_waypointPathLabel1, &exists); - if (exists) { - pWay->getProperties()->setAsciiString(TheKey_waypointPathLabel1, label); - } else if (pWay->getProperties()->known(TheKey_waypointPathLabel1, Dict::DICT_ASCIISTRING)) { - pWay->getProperties()->remove(TheKey_waypointPathLabel1); - } - label = pSrcWay->getProperties()->getAsciiString(TheKey_waypointPathLabel2, &exists); - if (exists) { - pWay->getProperties()->setAsciiString(TheKey_waypointPathLabel2, label); - } else if (pWay->getProperties()->known(TheKey_waypointPathLabel2, Dict::DICT_ASCIISTRING)){ - pWay->getProperties()->remove(TheKey_waypointPathLabel2); - } - label = pSrcWay->getProperties()->getAsciiString(TheKey_waypointPathLabel3, &exists); - if (exists) { - pWay->getProperties()->setAsciiString(TheKey_waypointPathLabel3, label); - } else if (pWay->getProperties()->known(TheKey_waypointPathLabel3, Dict::DICT_ASCIISTRING)) { - pWay->getProperties()->remove(TheKey_waypointPathLabel3); - } - - Bool biDirectional; - biDirectional = pSrcWay->getProperties()->getBool(TheKey_waypointPathBiDirectional, &exists); - if (exists) { - pWay->getProperties()->setBool(TheKey_waypointPathBiDirectional, biDirectional); - } - - MapObject *pCurWay = pWay; - pWay = nullptr; - Int i; - - for (i=0; i=0 && waypointID1=0 && waypointID20 && waypointID10 && waypointID2=0 && ndx <= m_numWaypointLinks) { - *waypointID1 = m_waypointLinks[ndx].waypoint1; - *waypointID2 = m_waypointLinks[ndx].waypoint2; - } -} - -//============================================================================= -// CWorldBuilderDoc::waypointLinkExists -//============================================================================= -/** Returns true if the two waypoint ID's are linked. Note that due to edits, one -or both waypoints may have been deleted. */ -//============================================================================= -Bool CWorldBuilderDoc::waypointLinkExists(Int waypointID1, Int waypointID2) -{ - Int i; - for (i=0; ireloadTextures(); - IRegion2D range = {0,0,0,0}; - updateHeightMap(pMap, false, range); -} - -void CWorldBuilderDoc::OnEditScripts() -{ - ASSERT(CMainFrame::GetMainFrame()); - CMainFrame::GetMainFrame()->onEditScripts(); -} - -/* when "home" key is pressed, goes to the initial camera waypoint or if - no such waypoint exists, goes to the center of the map */ -void CWorldBuilderDoc::OnViewHome() -{ - // !!! needs to be updated if/when camera stuff for worldbuilder changes !!! - Coord3D pos; - AsciiString startingCamName = TheNameKeyGenerator->keyToName(TheKey_InitialCameraPosition); - MapObject *pMapObj = MapObject::getFirstMapObject(); - - // set pos to be the coordinates of the center of the map - pos.x = MAP_XY_FACTOR*m_heightMap->getXExtent()/2; - pos.y = MAP_XY_FACTOR*m_heightMap->getYExtent()/2; - pos.x -= MAP_XY_FACTOR*m_heightMap->getBorderSize(); - pos.y -= MAP_XY_FACTOR*m_heightMap->getBorderSize(); - - // if waypoint "InitialCameraPosition" exists, replace pos with the appropriate coordinates - while (pMapObj) { - if (pMapObj->isWaypoint()) { - if (startingCamName == pMapObj->getWaypointName()) { - pos = *pMapObj->getLocation(); - } - } - pMapObj = pMapObj->getNext(); - } - - // set camera position to pos - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - WbView3d *p3View = pDoc->GetActive3DView(); - if (p3View) { - p3View->setCenterInView(pos.x/MAP_XY_FACTOR, pos.y/MAP_XY_FACTOR); - } - } -} - -void CWorldBuilderDoc::OnTexturesizingTile4x4() -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pMap->m_tileMode = WorldHeightMap::TILE_4x4; - IRegion2D range = {0,0,0,0}; - updateHeightMap(pMap, false, range); -#else - ::AfxMessageBox("Feature not currently enabled.", MB_OK); -#endif -} - -void CWorldBuilderDoc::OnUpdateTexturesizingTile4x4(CCmdUI* pCmdUI) -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pCmdUI->SetCheck(pMap->m_tileMode == WorldHeightMap::TILE_4x4?1:0); -#endif -} - -void CWorldBuilderDoc::OnTexturesizingTile6x6() -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pMap->m_tileMode = WorldHeightMap::TILE_6x6; - IRegion2D range = {0,0,0,0}; - updateHeightMap(pMap, false, range); -#else - ::AfxMessageBox("Feature not currently enabled.", MB_OK); -#endif -} - -void CWorldBuilderDoc::OnUpdateTexturesizingTile6x6(CCmdUI* pCmdUI) -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pCmdUI->SetCheck(pMap->m_tileMode == WorldHeightMap::TILE_6x6?1:0); -#endif -} - -void CWorldBuilderDoc::OnTexturesizingTile8x8() -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pMap->m_tileMode = WorldHeightMap::TILE_8x8; - IRegion2D range = {0,0,0,0}; - updateHeightMap(pMap, false, range); -#else - ::AfxMessageBox("Feature not currently enabled.", MB_OK); -#endif -} - -void CWorldBuilderDoc::OnUpdateTexturesizingTile8x8(CCmdUI* pCmdUI) -{ -#ifdef EVAL_TILING_MODES - WorldHeightMapEdit *pMap = GetHeightMap(); - pCmdUI->SetCheck(pMap->m_tileMode == WorldHeightMap::TILE_8x8?1:0); -#endif -} - -static AsciiString formatScriptLabel(Script *pScr) { - AsciiString fmt; - if (pScr->isSubroutine()) { - fmt.concat("[S "); - } else { - fmt.concat("[ns "); - } - if (pScr->isActive()) { - fmt.concat("A "); - } else { - fmt.concat("na "); - } - if (pScr->isOneShot()) { - fmt.concat("D] ["); - } else { - fmt.concat("nd] ["); - } - if (pScr->isEasy()) { - fmt.concat("E "); - } - if (pScr->isNormal()) { - fmt.concat("N "); - } - if (pScr->isHard()) { - fmt.concat("H]"); - } else { - fmt.concat("]"); - } - fmt.concat(pScr->getName().str()); - return fmt; -} - - -static void writeScript(FILE *theLogFile, const char * str) -{ - while (*str) { - if (*str != '\r') { - fputc(*str, theLogFile); - } - str++; - } -} - -#define DUMP_RAW_DICTS -#ifdef DUMP_RAW_DICTS -static void writeRawDict( FILE *theLogFile, const char* nm, const Dict* d ) -{ - if (!d) - { - fprintf(theLogFile, "Dict %s is null!\n", nm); - return; - } - - UnsignedShort len = d->getPairCount(); - fprintf(theLogFile, "Dict %s has %d entries\n", nm, len); - for (int i = 0; i < len; i++) - { - NameKeyType k = d->getNthKey(i); - AsciiString kname = TheNameKeyGenerator->keyToName(k); - - Dict::DataType t = d->getNthType(i); - - const char* typenames[] = { "Bool", "int", "float", "ascii", "unicode" }; - fprintf(theLogFile, "Entry %d is %s: %s = ",i,typenames[t], kname.str()); - - switch(t) - { - case Dict::DICT_BOOL: - fprintf(theLogFile,"%s\n",d->getNthBool(i)?"true":"false"); - break; - case Dict::DICT_INT: - fprintf(theLogFile,"%d\n",d->getNthInt(i)); - break; - case Dict::DICT_REAL: - fprintf(theLogFile,"%f\n",d->getNthReal(i)); - break; - case Dict::DICT_ASCIISTRING: - fprintf(theLogFile,"%s\n",d->getNthAsciiString(i).str()); - break; - case Dict::DICT_UNICODESTRING: - fprintf(theLogFile,"%ls\n",d->getNthUnicodeString(i).str()); - break; - default: - DEBUG_CRASH(("impossible")); - break; - } - } -} -#endif - -static void fprintUnit(FILE *theLogFile, Dict *teamDict, NameKeyType keyMinUnit, NameKeyType keyMaxUnit, - NameKeyType keyUnitType) -{ - Bool exists; - Int minCount = teamDict->getInt(keyMinUnit, &exists); - Int maxCount = teamDict->getInt(keyMaxUnit, &exists); - AsciiString type = teamDict->getAsciiString(keyUnitType, &exists); - if (type.isEmpty()) type = ""; - if (minCount || maxCount) { - fprintf(theLogFile, " %d-%d %s", minCount, maxCount, type.str()); - } - -} - -void CWorldBuilderDoc::OnDumpDocToText() -{ - MapObject *pMapObj = nullptr; - const char* vetStrings[] = {"Green", "Regular", "Veteran", "Elite"}; - const char* aggroStrings[] = {"Passive", "Normal", "Guard", "Hunt", "Aggressive", "Sleep"}; - AsciiString noOwner = "No Owner"; - static FILE *theLogFile = nullptr; - Bool open = false; - try { - char curbuf[_MAX_PATH]; - GetModuleFileName(nullptr, curbuf, sizeof(curbuf)); - if (char *pEnd = strrchr(curbuf, '\\')) - { - *(pEnd + 1) = 0; - } - - strlcat(curbuf, m_strTitle, ARRAY_SIZE(curbuf)); - strlcat(curbuf, ".txt", ARRAY_SIZE(curbuf)); - - theLogFile = fopen(curbuf, "w"); - if (theLogFile == nullptr) - throw; - - open = true; - - fprintf(theLogFile,"\n\n\nDump of Doc Contents\n"); - -#ifdef DUMP_RAW_DICTS - - writeRawDict(theLogFile, "WorldDict", MapObject::getWorldDict()); - - fprintf(theLogFile,"Raw Map Object\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - Dict *d = pMapObj->getProperties(); - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(d->getAsciiString(TheKey_originalOwner)); - Dict *teamDict = (teamInfo)?teamInfo->getDict():nullptr; - writeRawDict( theLogFile, "MapObject",d ); - writeRawDict( theLogFile, "MapObjectTeam",teamDict ); - } -#endif - - // dump the Buildings - fprintf(theLogFile,"\nBuildings\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - const ThingTemplate* tt = pMapObj->getThingTemplate(); - if (tt) { - if (tt->getEditorSorting() == ES_STRUCTURE) { - Dict *d = pMapObj->getProperties(); - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(d->getAsciiString(TheKey_originalOwner)); - Dict *teamDict = (teamInfo)?teamInfo->getDict():nullptr; - AsciiString objectOwnerName = (teamDict)?teamDict->getAsciiString(TheKey_teamOwner):noOwner; - - Bool showScript = false; - AsciiString script = d->getAsciiString(TheKey_objectScriptAttachment, &showScript); - - Bool showName = false; - AsciiString name = d->getAsciiString(TheKey_objectName, &showName); - - fprintf(theLogFile," %s", tt->getName().str()); - fprintf(theLogFile,", %s", objectOwnerName.str()); - fprintf(theLogFile,", @ (%0.0f,%0.0f)", pMapObj->getLocation()->x, pMapObj->getLocation()->y); - fprintf(theLogFile,", Angle %0.0f", pMapObj->getAngle() * 180 / PI); - fprintf(theLogFile,", %d%%", d->getInt(TheKey_objectInitialHealth)); - if (showName) { - fprintf(theLogFile,", Name %s", name.str()); - } else { - fprintf(theLogFile,", Unnamed"); - } - if (showScript) { - fprintf(theLogFile,", Script %s", script.str()); - } else { - fprintf(theLogFile,", No Script"); - } - - fprintf(theLogFile,"\n"); - } - } - } - fprintf(theLogFile,"End of Buildings\n"); - - // dump the units - fprintf(theLogFile,"\nUnits\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - const ThingTemplate* tt = pMapObj->getThingTemplate(); - if (tt) { - if (tt->getEditorSorting() == ES_VEHICLE || tt->getEditorSorting() == ES_INFANTRY) { - Bool exists; - Dict *d = pMapObj->getProperties(); - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(d->getAsciiString(TheKey_originalOwner)); - Dict *teamDict = (teamInfo)?teamInfo->getDict():nullptr; - - AsciiString objectOwnerName = (teamDict)?teamDict->getAsciiString(TheKey_teamOwner):noOwner; - Int veterancy = d->getInt(TheKey_objectVeterancy, &exists); - if (!exists) { - veterancy = 0; - } - Int aggro = d->getInt(TheKey_objectAggressiveness, &exists); - if (!exists) { - aggro = 0; - } - aggro++; - - Bool showScript = false; - AsciiString script = d->getAsciiString(TheKey_objectScriptAttachment, &showScript); - - Bool showName = false; - AsciiString name = d->getAsciiString(TheKey_objectName, &showName); - - fprintf(theLogFile," %s", tt->getName().str()); - fprintf(theLogFile,", %s", objectOwnerName.str()); - fprintf(theLogFile,", @ %0.0f.%0.0f", pMapObj->getLocation()->x/10, pMapObj->getLocation()->y/10); - fprintf(theLogFile,", Angle %0.0f", pMapObj->getAngle() * 180 / PI); - fprintf(theLogFile,", %d%%", d->getInt(TheKey_objectInitialHealth)); - if (showName) { - fprintf(theLogFile,", Name %s", name.str()); - } else { - fprintf(theLogFile,", Unnamed"); - } - if (showScript) { - fprintf(theLogFile,", Script %s", script.str()); - } else { - fprintf(theLogFile,", No Script"); - } - fprintf(theLogFile,", Team %s", d->getAsciiString(TheKey_originalOwner).str()); - fprintf(theLogFile,", %s", d->getBool(TheKey_objectRecruitableAI, &exists)?"AIRecruitable":"Not AIRecruitable"); - fprintf(theLogFile,", %s", d->getBool(TheKey_objectSelectable, &exists)?"Selectable":"Not Selectable"); - fprintf(theLogFile,", %s", aggroStrings[aggro]); - fprintf(theLogFile,", %s", vetStrings[veterancy]); - - fprintf(theLogFile,"\n"); - } - } - } - fprintf(theLogFile,"End of Units\n"); - - fprintf(theLogFile,"\nObject Types summary\n"); - { - Int totalObjectCount = 0; - std::map mapOfTemplates; - std::map::iterator it; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->getThingTemplate()) { - ++totalObjectCount; - - it = mapOfTemplates.find(pMapObj->getThingTemplate()->getName()); - if (it == mapOfTemplates.end()) { - mapOfTemplates.insert(std::make_pair(pMapObj->getThingTemplate()->getName(), 1)); - } else { - ++(it->second); - } - } - } - - fprintf(theLogFile, "Total Map Objects (with ThingTemplates): %d\n", totalObjectCount); - - while (!mapOfTemplates.empty()) { - std::map::iterator storedIt = mapOfTemplates.begin(); - - for (it = mapOfTemplates.begin(); it != mapOfTemplates.end(); ++it) { - if (storedIt->second < it->second) { - storedIt = it; - } - } - - fprintf(theLogFile, "Map Object: %s, Instances: %d\n", storedIt->first.str(), storedIt->second); - - // Now, erase it. - mapOfTemplates.erase(storedIt); - } - } - fprintf(theLogFile,"\nEnd of Object Types summary\n"); - - // dump the waypoints - fprintf(theLogFile,"\nWaypoints\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isWaypoint()) { - fprintf(theLogFile," %s, @ %0.0f.%0.0f\n", pMapObj->getWaypointName().str(), pMapObj->getLocation()->x/10, pMapObj->getLocation()->y/10); - } - } - fprintf(theLogFile,"End of Waypoints\n"); - - fprintf(theLogFile,"\nProps\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - const ThingTemplate* tt = pMapObj->getThingTemplate(); - if (tt) { - if (tt->getEditorSorting() == ES_MISC_MAN_MADE) { - Dict *d = pMapObj->getProperties(); - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(d->getAsciiString(TheKey_originalOwner)); - Dict *teamDict = (teamInfo)?teamInfo->getDict():nullptr; - - AsciiString objectOwnerName = (teamDict)?teamDict->getAsciiString(TheKey_teamOwner):noOwner; - - Bool showName = false; - AsciiString name = d->getAsciiString(TheKey_objectName, &showName); - - fprintf(theLogFile," %s", tt->getName().str()); - fprintf(theLogFile,", %s", objectOwnerName.str()); - fprintf(theLogFile,", @ %0.0f.%0.0f", pMapObj->getLocation()->x/10, pMapObj->getLocation()->y/10); - fprintf(theLogFile,", Angle %0.0f", pMapObj->getAngle() * 180 / PI); - fprintf(theLogFile,", %d%%", d->getInt(TheKey_objectInitialHealth)); - if (showName) { - fprintf(theLogFile,", Name %s", name.str()); - } else { - fprintf(theLogFile,", Unnamed"); - } - - fprintf(theLogFile,"\n"); - } - } - } - fprintf(theLogFile,"End of Props\n"); - - fprintf(theLogFile,"\nAudio\n"); - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - const ThingTemplate* tt = pMapObj->getThingTemplate(); - if (tt) { - if (tt->getEditorSorting() == ES_AUDIO) { - Dict *d = pMapObj->getProperties(); - - Bool showName = false; - AsciiString name = d->getAsciiString(TheKey_objectName, &showName); - - fprintf(theLogFile," %s", tt->getName().str()); - fprintf(theLogFile,", @ %0.0f.%0.0f", pMapObj->getLocation()->x/10, pMapObj->getLocation()->y/10); - if (showName) { - fprintf(theLogFile,", Name %s", name.str()); - } else { - fprintf(theLogFile,", Unnamed"); - } - - fprintf(theLogFile,"\n"); - } - } - } - fprintf(theLogFile,"End of Audio\n"); - - fprintf(theLogFile,"\nTeams\n"); - Int j; - for (j=0; jgetNumSides(); j++) { - Dict *d = TheSidesList->getSideInfo(j)->getDict(); -#ifdef DUMP_RAW_DICTS -writeRawDict( theLogFile, "TeamDict",d ); -#endif - AsciiString name = d->getAsciiString(TheKey_playerName); - AsciiString fmt; - if (name.isEmpty()) - fmt.format("%s", "(neutral)"); - else - fmt.format("%s",name.str()); - fprintf(theLogFile, "PLAYER %s\n", fmt.str()); - Int numTeams = TheSidesList->getNumTeams(); - for (Int i=0; igetTeamInfo(i); -#ifdef DUMP_RAW_DICTS -writeRawDict( theLogFile, "TeamInfo",ti->getDict() ); -#endif - if (ti->getDict()->getAsciiString(TheKey_teamOwner) == name) - { - Bool exists; - AsciiString teamName = ti->getDict()->getAsciiString(TheKey_teamName); - AsciiString waypoint = ti->getDict()->getAsciiString(TheKey_teamHome, &exists); - CString pri; - pri.Format(TEXT("%d"), ti->getDict()->getInt(TheKey_teamProductionPriority, &exists)); - AsciiString trigger = ti->getDict()->getAsciiString(TheKey_teamProductionCondition, &exists); - - fprintf(theLogFile, "TEAM %s home '%s', priority %s, condition '%s',\n", teamName.str(), - waypoint.str(), static_cast(pri), trigger.str()); - fprintf(theLogFile, " UNITS:"); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount1, TheKey_teamUnitMaxCount1, TheKey_teamUnitType1); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount2, TheKey_teamUnitMaxCount2, TheKey_teamUnitType2); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount3, TheKey_teamUnitMaxCount3, TheKey_teamUnitType3); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount4, TheKey_teamUnitMaxCount4, TheKey_teamUnitType4); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount5, TheKey_teamUnitMaxCount5, TheKey_teamUnitType5); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount6, TheKey_teamUnitMaxCount6, TheKey_teamUnitType6); - fprintUnit(theLogFile, ti->getDict(), TheKey_teamUnitMinCount7, TheKey_teamUnitMaxCount7, TheKey_teamUnitType7); - fprintf(theLogFile, "\n SCRIPTS: "); - AsciiString script = ti->getDict()->getAsciiString(TheKey_teamOnCreateScript, &exists); - if (script.isEmpty()) script=""; - fprintf(theLogFile, "OnCreate='%s'", script.str()); - script = ti->getDict()->getAsciiString(TheKey_teamOnIdleScript, &exists); - if (script.isEmpty()) script=""; - fprintf(theLogFile, " OnIdle='%s'", script.str()); - script = ti->getDict()->getAsciiString(TheKey_teamOnDestroyedScript, &exists); - if (script.isEmpty()) script=""; - fprintf(theLogFile, " OnDestroyed='%s'", script.str()); - script = ti->getDict()->getAsciiString(TheKey_teamEnemySightedScript, &exists); - if (script.isEmpty()) script=""; - fprintf(theLogFile, " OnEnemySighted='%s'", script.str()); - script = ti->getDict()->getAsciiString(TheKey_teamAllClearScript, &exists); - if (script.isEmpty()) script=""; - fprintf(theLogFile, " OnAllClear='%s'\n", script.str()); - } - } - } - fprintf(theLogFile,"End of Teams\n"); - - fprintf(theLogFile,"\nScripts\n"); - Int i, groupNdx; - for (i=0; igetNumSides(); i++) { - Dict *d = TheSidesList->getSideInfo(i)->getDict(); -#ifdef DUMP_RAW_DICTS -writeRawDict( theLogFile, "Scripts",d ); -#endif - AsciiString name = d->getAsciiString(TheKey_playerName); - UnicodeString uni = d->getUnicodeString(TheKey_playerDisplayName); - AsciiString fmt; - if (name.isEmpty()) - fmt.format("%s", "(neutral)"); - else - fmt.format("%s",name.str()); - fprintf(theLogFile, "PLAYER %s\n", fmt.str()); - ScriptList *pSL = TheSidesList->getSideInfo(i)->getScriptList(); - if (pSL) { - ScriptGroup *pGroup = pSL->getScriptGroup(); - for (groupNdx = 0; pGroup; groupNdx++,pGroup=pGroup->getNext()) { - AsciiString fmt; - if (pGroup->getName().isEmpty()) - continue; - else - fmt.format("%s",pGroup->getName().str()); - fprintf(theLogFile, "GROUP %s\n", fmt.str()); - Script *pScr = pGroup->getScript(); - if (pScr) { - Int scriptNdx; - for (scriptNdx = 0; pScr; scriptNdx++,pScr=pScr->getNext()) { - AsciiString fmt; - if (pScr->getName().isEmpty()) - continue; - fmt = formatScriptLabel(pScr); - fprintf(theLogFile, "%s:\n", fmt.str()); - AsciiString scriptComment; - AsciiString scriptText; - if (pScr) { - scriptComment = pScr->getComment(); - scriptText = pScr->getUiText(); - } - if (scriptComment.isNotEmpty()) { - fprintf(theLogFile, "//:%s:\n", scriptComment.str()); - } - writeScript(theLogFile, scriptText.str()); - fprintf(theLogFile, "\n"); - - } - } - } - Script *pScr = pSL->getScript(); - if (pScr) { - Int scriptNdx; - for (scriptNdx = 0; pScr; scriptNdx++,pScr=pScr->getNext()) { - AsciiString fmt; - if (pScr->getName().isEmpty()) - continue; - fmt = formatScriptLabel(pScr); - fprintf(theLogFile, "%s:\n", fmt.str()); - AsciiString scriptComment; - AsciiString scriptText; - if (pScr) { - scriptComment = pScr->getComment(); - scriptText = pScr->getUiText(); - } - if (scriptComment.isNotEmpty()) { - fprintf(theLogFile, "//:%s:\n", scriptComment.str()); - } - writeScript(theLogFile, scriptText.str()); - fprintf(theLogFile, "\n"); - } - } - } - } - fprintf(theLogFile,"End of Scripts\n"); - fclose(theLogFile); - open = false; - } catch (...) { - if (open) { - fclose(theLogFile); - } - } -} - -// Find the index nearest the point in the preferred direction -void FindIndexNearest(CWorldBuilderDoc* pDoc, const Coord3D* point, CPoint* outNdx, DIRECTION pref ) -{ - Coord3D testPoint = *point; - switch(pref) - { - case PREFER_CENTER: - { - break; - } - case PREFER_LEFT: - { - testPoint.x -= MAP_XY_FACTOR / 2; - break; - } - case PREFER_TOP: - { - testPoint.y += MAP_XY_FACTOR / 2; - break; - } - case PREFER_RIGHT: - { - testPoint.x += MAP_XY_FACTOR / 2; - break; - } - case PREFER_BOTTOM: - { - testPoint.y -= MAP_XY_FACTOR / 2; - break; - } - }; - - pDoc->getCellIndexFromCoord(testPoint, outNdx); -} - -Bool IndexInRect(CWorldBuilderDoc* pDoc, const Coord3D* bl, const Coord3D* tl, const Coord3D* br, const Coord3D* tr, CPoint* index) -{ - Coord3D testPoint; - pDoc->getCoordFromCellIndex(*index, &testPoint); - return PointInsideRect3D(bl, tl, br, tr, &testPoint); -} - -Bool AddUniqueAndNeighbors(CWorldBuilderDoc* pDoc, const Coord3D* bl, const Coord3D* tl, const Coord3D* br, const Coord3D* tr, CPoint ndx, VecHeightMapIndexes* allIndices) -{ - if (!allIndices) { - return false; - } - - if (!IndexInRect(pDoc, bl, tl, br, tr, &ndx)) { - return false; - } - - if (std::find(allIndices->begin(), allIndices->end(), ndx) != allIndices->end()) { - return false; - } - - // we have a winner. This index is both inside the rectangle and not already in the index list. - allIndices->push_back(ndx); - - // now attempt to add the neighbors. - // first left - ndx.x += 1; - AddUniqueAndNeighbors(pDoc, bl, tl, br, tr, ndx, allIndices); - - // then right - ndx.x -= 2; - AddUniqueAndNeighbors(pDoc,bl, tl, br, tr, ndx, allIndices); - - // then top - ndx.x += 1; - ndx.y += 1; - AddUniqueAndNeighbors(pDoc,bl, tl, br, tr, ndx, allIndices); - - // then bottom - ndx.y -= 2; - AddUniqueAndNeighbors(pDoc, bl, tl, br, tr, ndx, allIndices); - - return true; -} - - -void CWorldBuilderDoc::OnRemoveclifftexmapping() -{ - if (::AfxMessageBox(IDS_CONFIRM_REMOVE_CLIFF_MAPPING, MB_YESNO) == IDYES) { - if (m_heightMap) { - - WorldHeightMapEdit *htMapEditCopy = GetHeightMap()->duplicate(); - if (htMapEditCopy == nullptr) return; - if (htMapEditCopy->removeCliffMapping()) { // does all the work. - IRegion2D partialRange = {0,0,0,0}; - updateHeightMap(htMapEditCopy, false, partialRange); - WBDocUndoable *pUndo = new WBDocUndoable(this, htMapEditCopy); - this->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to this now. - } - REF_PTR_RELEASE(htMapEditCopy); - } - } -} - -Int CWorldBuilderDoc::getNumBoundaries() const -{ - return m_heightMap->getNumBoundaries(); -} - -void CWorldBuilderDoc::getBoundary(Int ndx, ICoord2D* border) const -{ - m_heightMap->getBoundary(ndx, border); -} - -void CWorldBuilderDoc::addBoundary(ICoord2D* boundaryToAdd) -{ - m_heightMap->addBoundary(boundaryToAdd); -} - -void CWorldBuilderDoc::changeBoundary(Int ndx, ICoord2D *border) -{ - m_heightMap->changeBoundary(ndx, border); -} - -void CWorldBuilderDoc::removeLastBoundary() -{ - m_heightMap->removeLastBoundary(); -} - -void CWorldBuilderDoc::findBoundaryNear(Coord3D *pt, float okDistance, Int *outNdx, Int *outHandle) -{ - m_heightMap->findBoundaryNear(pt, okDistance, outNdx, outHandle); -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp deleted file mode 100644 index 671787ff327..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderView.cpp +++ /dev/null @@ -1,1083 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// FILE: WorldBuilderView.cpp //////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: WorldBuilderView.cpp -// -// Created: John Ahlquist, April 2001 -// -// Desc: 2D view for the map data - textures, object icons and -// contour info. -// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Includes -//----------------------------------------------------------------------------- - -#include "StdAfx.h" -#include "WorldBuilder.h" - -#include "WorldBuilderDoc.h" -#include "WorldBuilderView.h" -#include "WHeightMapEdit.h" -#include "Common/GlobalData.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "W3DDevice/GameClient/W3DRoadBuffer.h" -#include "CellWidth.h" -#include "ContourOptions.h" -#include "MainFrm.h" -#include "CUndoable.h" -#include "Common/Debug.h" - -//----------------------------------------------------------------------------- -// Private Data -//----------------------------------------------------------------------------- -#define ROUND(x) (Int)(floor((x)+0.5)) - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderView - -//----------------------------------------------------------------------------- -// Private Functions -//----------------------------------------------------------------------------- - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderView construction/destruction - -CWorldBuilderView::CWorldBuilderView() : - m_cellSize(16), - m_showContours(false), - mXScrollOffset(0), - mYScrollOffset(0), - m_scrollMin(0,0), - m_scrollMax(0,0), - mShowGrid(true), - m_showTexture(true) -{ - Int show; - show = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowContours", 0); - m_showContours = (show!=0); - - show = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowGrid", 0); - mShowGrid = (show!=0); - - show = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowTexture", 1); - m_showTexture = (show!=0); - - -} - -CWorldBuilderView::~CWorldBuilderView() -{ -} - -BOOL CWorldBuilderView::PreCreateWindow(CREATESTRUCT& cs) -{ - return WbView::PreCreateWindow(cs); -} - -int CWorldBuilderView::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (WbView::OnCreate(lpCreateStruct) == -1) - return -1; - - return 0; -} - -void CWorldBuilderView::OnDraw(CDC* pDC) -{ - // Not used. See OnPaint. -} - - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderView printing - -BOOL CWorldBuilderView::OnPreparePrinting(CPrintInfo* pInfo) -{ - // default preparation - return DoPreparePrinting(pInfo); -} - -void CWorldBuilderView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ -} - -void CWorldBuilderView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CWorldBuilderView diagnostics - -#ifdef RTS_DEBUG -void CWorldBuilderView::AssertValid() const -{ - WbView::AssertValid(); -} - -void CWorldBuilderView::Dump(CDumpContext& dc) const -{ - WbView::Dump(dc); -} - -#endif //RTS_DEBUG - -/** Set the cell size, and invalidate. */ -void CWorldBuilderView::setCellSize(Int cellSize) -{ - if (cellSize >= MIN_CELL_SIZE && cellSize<=MAX_CELL_SIZE) { - m_cellSize = cellSize; - adjustDocSize(); - Invalidate(); - } -} - -void CWorldBuilderView::setCenterInView(Real x, Real y) -{ - if (x != m_centerPt.X || y != m_centerPt.Y) { - m_centerPt.X=x; - m_centerPt.Y=y; - adjustDocSize(); - Invalidate(); - } -} - -/** Set the show contours flag, and invalidate. */ -void CWorldBuilderView::setShowContours(Bool show) -{ - m_showContours=show; - Invalidate(); -} -//----------------------------------------------------------------------------- -// Public Functions -//----------------------------------------------------------------------------- - -//============================================================================= -// CWorldBuilderView::getColorForHeight -//============================================================================= -/** Gets the color for a given height in the height map. Used when we -are not displaying terrain, and for the contour lines. */ -//============================================================================= -DWORD CWorldBuilderView::getColorForHeight(UnsignedByte ht) -{ - Int fromR, fromG, fromB; - Int toR, toG, toB; - Int min, max; - // black blue red green magenta cyan yellow white - // 0x00 0x24 0x48 0x6c 0x90 0xb4 0xd8 0xff - if (ht<0x24) { - // 0 - 0x24 goes from black to blue - fromR = fromG = fromB = toR = toG = 0; - toB = 0xff; - min = 0; - max = 0x24; - } else if (ht < 0x48) { - // 0x24-0x48 goes from blue to red - fromR = 0; fromG = 0; fromB = 0xFF; - toR = 0xff; toG = 0; toB = 0x00; - min = 0x24; - max = 0x48; - } else if (ht < 0x6c) { - // 0x48-0x6c goes from red to green - fromR = 0xFF; fromG = 0; fromB = 0; - toR = 0; toG = 0xff; toB = 0; - min = 0x48; - max = 0x6c; - } else if (ht < 0x90) { - // 0x6c-0x90 goes from green to magenta - fromR = 0; fromG =0xFF; fromB = 0; - toR = 0xff; toG = 0; toB = 0xff; - min = 0x6c; - max = 0x90; - } else if (ht < 0xb4) { - // 0x90-0xb4 goes from magenta to cyan - fromR = 0xff; fromG =0; fromB = 0xff; - toR = 0; toG = 0xFF; toB = 0xff; - min = 0x90; - max = 0xb4; - } else if (ht < 0xd8) { - // 0xb4-0xd8 goes from cyan to yellow - fromR = 0; fromG =0xf; fromB = 0xff; - toR = 0xff; toG = 0xFF; toB = 0; - min = 0xb4; - max = 0xd8; - } else { - // 0xd8-0xff goes from yellow to white - fromR = 0xff; fromG =0xff; fromB = 0; - toR = 0xff; toG = 0xFF; toB = 0xFF; - min = 0xd8; - max = 0xff; - } - Int delta = max-min; - Int to = ht-min; - Int from = max-ht; - // Interpolate red value. - Int r = (fromR*from + toR*to +delta/2)/delta; - if (r<0) r = 0; - if (r>255) r = 255; - // Interpolate green value. - Int g = (fromG*from + toG*to +delta/2)/delta; - if (g<0) g = 0; - if (g>255) g = 255; - // Interpolate blue value. - Int b = (fromB*from + toB*to +delta/2)/delta; - if (b<0) b = 0; - if (b>255) b = 255; - return(RGB(r,g,b)); -} - -//============================================================================= -// CWorldBuilderView::OnPaint -//============================================================================= -/** This draws the window. */ -//============================================================================= -void CWorldBuilderView::OnPaint() -{ - CWorldBuilderDoc* pDoc = WbDoc(); - ASSERT_VALID(pDoc); - - // If we are editing with a tool, draw the map being edited, if one exists. - WorldHeightMapEdit *pMap = getTrackingHeightMap(); - - // If no map yet, there is nothing to draw. - if (pMap==nullptr) return; - - Int minJ = 0; - Int minI = 0; - Int maxJ = pMap->getYExtent(); - Int maxI = pMap->getXExtent(); - - CRect updateRect; - CRgn updateRgn; - updateRgn.CreateRectRgn(0,0,1,1); - if (NULLREGION != GetUpdateRgn(&updateRgn)) { - // The region isn't null, so get the bounding box. - updateRgn.GetRgnBox(&updateRect); - // Get the visible pixel bounds. - Int left = updateRect.left + mXScrollOffset; - Int right = updateRect.right + mXScrollOffset; - Int top = updateRect.top + mYScrollOffset; - Int bottom = updateRect.bottom + mYScrollOffset; - // Convert the visible pixel bounds to the index bounds for the map. - minI = (left/m_cellSize); - maxI = (right/m_cellSize)+1; - // Clip the bounds to the size of the actual height map. - if (minI<0) minI=0; - if (maxI>=pMap->getXExtent()) maxI = pMap->getXExtent()-1; - - // screen goes down, map goes up, so gotta dance a little on the verticals. - Int min = (top/m_cellSize); - Int max = (bottom/m_cellSize)+1; - - if (min<0) min=0; - // Clip the bounds to the size of the actual height map. - if (max>=pMap->getYExtent()) max = pMap->getYExtent(); - - - maxJ = pMap->getYExtent() - min; - minJ = pMap->getYExtent() - max; - if (maxJ>=pMap->getYExtent()) maxJ = pMap->getYExtent()-1; - } - - - CPaintDC dc(this); // device context for painting - // Offset the origin so that we can draw on 0 based coordinates. - dc.SetViewportOrg(-mXScrollOffset, -mYScrollOffset); - updateRgn.OffsetRgn(mXScrollOffset, mYScrollOffset); - Int i, j; - CRect rect; - CBrush brush; - // gray brush for drawing the grid. - brush.CreateSolidBrush(RGB(128,128,128)); - CRect clientRect; - GetClientRect(&clientRect); - clientRect.OffsetRect(mXScrollOffset, mYScrollOffset); - if (maxJ == pMap->getYExtent()-1) { - rect = clientRect; // Do top. - rect.bottom = (1)*m_cellSize; - dc.FillSolidRect(&rect, RGB(255,255,255)); - } - if (minJ == 0) { - rect = clientRect; // Do bottom. - rect.top = (pMap->getYExtent())*m_cellSize; - dc.FillSolidRect(&rect, RGB(255,255,255)); - } - if (minI == 0) { - rect = clientRect; // Do left; - rect.right = 0; - dc.FillSolidRect(&rect, RGB(255,255,255)); - } - if (maxI == pMap->getXExtent()-1) { - rect = clientRect; // Do left; - rect.left = (pMap->getYExtent()-1)*m_cellSize; - dc.FillSolidRect(&rect, RGB(255,255,255)); - } - - for (j=maxJ-1; j>=minJ; j--) { // map goes up, screen goes down. - - rect.bottom = (pMap->getYExtent()-j)*m_cellSize; - rect.top = rect.bottom-m_cellSize; - for (i=minI; igetHeight(i, j); - rect.left = i*m_cellSize; - rect.right = rect.left+m_cellSize; - // If this cell is not visible, don't bother drawing it. - if (!updateRgn.RectInRegion(&rect)) { - continue; - } -#ifdef INTENSE_DEBUG - dc.FillSolidRect(&rect, RGB(0,255,0)); - ::Sleep(5); -#endif - Int width = m_cellSize; - UnsignedByte *pData = nullptr; - if (m_showTexture) { - } - // Draw the texture if we have one, else the height color. - if ((pData!=nullptr)) { - drawMyTexture(&dc, &rect, width, pData); - } else { - dc.FillSolidRect(&rect, getColorForHeight(ht)); - } - // Draw the grid. It doesn't make sense to draw it if the width - // in pixels is less than 3, as all you see is the grid. - if (mShowGrid && m_cellSize>=MIN_GRID_SIZE) { - CRect frameRect=rect; - frameRect.bottom++; frameRect.right++; - dc.FrameRect(&frameRect, &brush); - } - } - } - - // Draw the contours if they are on. - if (m_cellSize>=MIN_GRID_SIZE && m_showContours) { - drawContours(&dc, &updateRgn, minI, maxI, minJ, maxJ); - } - - // Draw the icons for the objects if they are turned on. - if (m_showObjects) { - MapObject *pMapObj = MapObject::getFirstMapObject(); - while (pMapObj) { - // Assume objects draw approx grids across. - CPoint lpt; - docToViewCoords(*pMapObj->getLocation(), &lpt); - lpt.x += mXScrollOffset; - lpt.y += mYScrollOffset; - // Create a rect centered on the object and 2 cells wide & tall. - CRect rect; - rect.bottom = lpt.y - m_cellSize; - rect.top = lpt.y + m_cellSize; - rect.left = lpt.x - m_cellSize; - rect.right = lpt.x + m_cellSize; - // If visible in the update region, draw it. - if (updateRgn.RectInRegion(&rect)) - { - drawObjectInView(&dc, pMapObj); - } - pMapObj = pMapObj->getNext(); - } - } - -} - - -//============================================================================= -// CWorldBuilderView::invalObjectInView -//============================================================================= -/** Causes the bounds of an object to be invalidated. */ -//============================================================================= -void CWorldBuilderView::invalObjectInView(MapObject *pMapObj) -{ - if (pMapObj == nullptr) { - Invalidate(false); - return; - } - - CPoint lpt; - docToViewCoords(*pMapObj->getLocation(), &lpt); - - // Calculate the bounds of the circle. - CRect bounds(lpt, lpt); - bounds.InflateRect( m_cellSize/2+2, m_cellSize/2+2); - - // Calculate the bounds of the arrowhead. - Coord3D ac; - WbDoc()->getObjArrowPoint(pMapObj, &ac); - CPoint arrpt; - docToViewCoords(ac, &arrpt); - - CRect arrow(arrpt.x, arrpt.y, arrpt.x, arrpt.y); - arrow.InflateRect(1,1); - // Union the two bounds. - CRect fullBounds; - fullBounds.UnionRect(&bounds, &arrow); -// fullBounds.OffsetRect(-mXScrollOffset, -mYScrollOffset); - // Invalidate it. - InvalidateRect(&fullBounds, false); -} - -//============================================================================= -// CWorldBuilderView::drawObject -//============================================================================= -/** Draws the icon for an object at a given location. Called by OnPaint. */ -//============================================================================= -void CWorldBuilderView::drawObjectInView(CDC *pDc, MapObject *pMapObj) -{ - CPoint lpt; - docToViewCoords(*pMapObj->getLocation(), &lpt); - // un-adjuse by scroll offset since we are called from OnPaint, which adjusts by this amt - lpt.x += mXScrollOffset; - lpt.y += mYScrollOffset; - - CRect circle(lpt, lpt); - circle.InflateRect(m_cellSize/2, m_cellSize/2); - CPen ovalPen; - CBrush brush; - CGdiObject *savPen; - CGdiObject *savBrush; - // Create a pen to draw the icon of the object's color. - ovalPen.CreatePen(PS_SOLID, 1, pMapObj->getColor()); - // Null brush, as the object icon is not filled. - brush.CreateStockObject(NULL_BRUSH); - // Select the pen & brush. - savPen = pDc->SelectObject(&ovalPen); - savBrush = pDc->SelectObject(&brush); - // Draw the object's circle. - pDc->Ellipse(&circle); - - // Draw the arrow - Int delta = (m_cellSize+4)/4; - Int smallDelta = (delta+4)/4; - - float angle = pMapObj->getAngle(); - - Vector3 head1(m_cellSize - delta, smallDelta, 0); - Vector3 head2(m_cellSize - delta, -smallDelta, 0); - head1.Rotate_Z(-angle); - head2.Rotate_Z(-angle); - - Coord3D cpt2; - WbDoc()->getObjArrowPoint(pMapObj, &cpt2); - CPoint pt2; - docToViewCoords(cpt2, &pt2); - // un-adjuse by scroll offset since we are called from OnPaint, which adjusts by this amt - pt2.x += mXScrollOffset; - pt2.y += mYScrollOffset; - pDc->MoveTo(lpt.x,lpt.y); - pDc->LineTo(pt2.x, pt2.y); - - CPoint pt1; - pt1.x = pt2.x - ROUND(head1.X); - pt1.y = pt2.y - ROUND(head1.Y); - pDc->LineTo(pt1); - - pDc->MoveTo(pt2.x, pt2.y); - pt1.x = pt2.x - ROUND(head2.X); - pt1.y = pt2.y - ROUND(head2.Y); - pDc->LineTo(pt1); - - if (pMapObj->isSelected()) { - // The object is selected, so draw selection feedback. - CPoint pts[3]; - pts[0].x = lpt.x; - pts[0].y = lpt.y; - // Solid yellow pen and brush, as the selection feedback is filled. - CPen selectPen; - selectPen.CreatePen(PS_SOLID, 1, RGB(255,255,0)); - CBrush selectBrush; - selectBrush.CreateSolidBrush(RGB(255,255,0)); - pDc->SelectObject(&selectPen); - pDc->SelectObject(&selectBrush); - // Draw a triangle centered about the object center. - pts[0].x += delta; - pts[0].y += delta; - pts[1] = pts[0]; - pts[1].x -= 2*delta; - pts[2].x = lpt.x; - pts[2].y = lpt.y; - pts[2].y -= 2*delta; - pDc->Polygon(pts, 3); - // Restore the previous brush & pen to prevent leaks. - pDc->SelectObject(&ovalPen); - pDc->SelectObject(&brush); - } - - // Restore the previous brush & pen to prevent leaks. - pDc->SelectObject(savPen); - pDc->SelectObject(savBrush); -} - -//============================================================================= -// CWorldBuilderView::drawContours -//============================================================================= -/** Draws the height contours on the map. Called by OnPaint. */ -//============================================================================= -void CWorldBuilderView::drawContours(CDC *pDc, CRgn *pRgn, Int minX, Int maxX, Int minY, Int maxY) -{ - CWorldBuilderDoc* pDoc = WbDoc(); - ASSERT_VALID(pDoc); - - WorldHeightMapEdit *pMap = getTrackingHeightMap(); - // We do cell and cell+1 in the loop, so trim back the max limits. - if (maxX == pMap->getXExtent()) maxX--; - if (maxY == pMap->getYExtent()) maxY--; - - Int curHeight; - Bool didWater = false; // We do the water level first, then step through the contours. - for (curHeight = ContourOptions::getContourOffset(); curHeight < 255; - curHeight+= ContourOptions::getContourStep()) { - Bool doingWater = false; - CPen pen; - CGdiObject *savObj; - Int width = ContourOptions::getContourWidth(); - if (!didWater) { - // Do the water first. - didWater = true; - doingWater = true; - curHeight = ROUND(TheGlobalData->m_waterPositionZ/MAP_HEIGHT_SCALE); - pen.CreatePen(PS_SOLID, width+1, RGB(0, 255, 255)); - } else { - pen.CreatePen(PS_SOLID, width, getColorForHeight(curHeight)); - } - savObj = pDc->SelectObject(&pen); - Int i, j; - CRect rect; - for (i=minX; igetYExtent()-j)*m_cellSize; - rect.top = rect.bottom-m_cellSize; - rect.left = i*m_cellSize; - rect.right = rect.left+m_cellSize; - if (!pRgn->RectInRegion(&rect)) { - continue; - } - CPoint lowerLeftPt, lowerRightPt, upperLeftPt, upperRightPt; - Int lowerLeft = pMap->getHeight(i, j); - Int upperLeft = pMap->getHeight(i, j+1); - Int upperRight = pMap->getHeight(i+1, j+1); - Int lowerRight = pMap->getHeight(i+1, j); - lowerLeftPt.x = rect.left; - lowerLeftPt.y = rect.bottom; - upperLeftPt.x = rect.left; - upperLeftPt.y = rect.top; - lowerRightPt.x = rect.right; - lowerRightPt.y = rect.bottom; - upperRightPt.x = rect.right; - upperRightPt.y = rect.top; - - // if the square is flat, we have no contours. - if (lowerLeft==upperRight && lowerLeft == upperLeft && upperLeft == lowerRight) { - continue; - } - // If it is all below or all above, we have no contours. - if (lowerLeftcurHeight && upperLeft>curHeight && upperRight>curHeight && lowerRight>curHeight) { - continue; - } - Bool drawLine = false; - CPoint pt1, pt2; - // Consider the lower left, upper left, upper right triangle. - while (true) { - if (lowerLeft != upperLeft || lowerLeft != upperRight) { - if (lowerLeft == curHeight) { - if (isBetween(curHeight, upperRight, upperLeft)) { - pt1 = lowerLeftPt; - interpolate(&pt2, curHeight, upperLeftPt, upperLeft, upperRightPt, upperRight); - drawLine = true; - } - break; - } - if (upperLeft == curHeight) { - if (isBetween(curHeight, upperRight, lowerLeft)) { - pt1 = upperLeftPt; - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerLeftPt, lowerLeft); - drawLine = true; - } - break; - } - if (upperRight == curHeight) { - if (isBetween(curHeight, lowerLeft, upperLeft)) { - pt1 = upperRightPt; - interpolate(&pt2, curHeight, lowerLeftPt, lowerLeft, upperLeftPt, upperLeft); - drawLine = true; - } - break; - } - if (isBetween(curHeight, lowerLeft, upperLeft)) { - interpolate(&pt1, curHeight, lowerLeftPt, lowerLeft, upperLeftPt, upperLeft); - if (isBetween(curHeight, upperRight, upperLeft)) { - interpolate(&pt2, curHeight, upperLeftPt, upperLeft, upperRightPt, upperRight); - drawLine = true; - } - if (isBetween(curHeight, upperRight, lowerLeft)) { - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerLeftPt, lowerLeft); - drawLine = true; - } - break; - } - if (isBetween(curHeight, upperRight, upperLeft)) { - interpolate(&pt1, curHeight, upperLeftPt, upperLeft, upperRightPt, upperRight); - if (isBetween(curHeight, upperRight, lowerLeft)) { - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerLeftPt, lowerLeft); - drawLine = true; - } - break; - } - } - break; - } - if (drawLine) { - pDc->MoveTo(pt1); - pDc->LineTo(pt2); - } - - drawLine = false; - // Consider the lower left, upper right, lowerRight triangle. - while (true) { - if (lowerLeft != lowerRight || lowerLeft != upperRight) { - if (lowerLeft == curHeight) { - if (isBetween(curHeight, upperRight, lowerRight)) { - pt1 = lowerLeftPt; - interpolate(&pt2, curHeight, lowerRightPt, lowerRight, upperRightPt, upperRight); - drawLine = true; - } - break; - } - if (lowerRight == curHeight) { - if (isBetween(curHeight, upperRight, lowerLeft)) { - pt1 = lowerRightPt; - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerLeftPt, lowerLeft); - drawLine = true; - } - break; - } - if (upperRight == curHeight) { - if (isBetween(curHeight, lowerLeft, lowerRight)) { - pt1 = upperRightPt; - interpolate(&pt2, curHeight, lowerLeftPt, lowerLeft, lowerRightPt, lowerRight); - drawLine = true; - } - break; - } - - if (isBetween(curHeight, lowerLeft, lowerRight)) { - interpolate(&pt1, curHeight, lowerLeftPt, lowerLeft, lowerRightPt, lowerRight); - if (isBetween(curHeight, upperRight, lowerLeft)) { - interpolate(&pt2, curHeight, lowerLeftPt, lowerLeft, upperRightPt, upperRight); - drawLine = true; - } - if (isBetween(curHeight, upperRight, lowerRight)) { - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerRightPt, lowerRight); - drawLine = true; - } - break; - } - if (isBetween(curHeight, upperRight, lowerRight)) { - interpolate(&pt1, curHeight, lowerRightPt, lowerRight, upperRightPt, upperRight); - if (isBetween(curHeight, upperRight, lowerLeft)) { - interpolate(&pt2, curHeight, upperRightPt, upperRight, lowerLeftPt, lowerLeft); - drawLine = true; - } - break; - } - } - break; - } - if (drawLine) { - pDc->MoveTo(pt1); - pDc->LineTo(pt2); - } - } - } - pDc->SelectObject(savObj); - if (doingWater) { - curHeight = ContourOptions::getContourOffset() - ContourOptions::getContourStep(); - } - } -} - - -//============================================================================= -// CWorldBuilderView::interpolate -//============================================================================= -/** Given 2 points, pt1 and pt2, with different height values ht1 and ht2, -determines where the height ht occurs along the line. */ -//============================================================================= -void CWorldBuilderView::interpolate(CPoint *pt, Int ht, CPoint pt1, Int ht1, CPoint pt2, Int ht2) -{ - DEBUG_ASSERTCRASH((ht1!=ht2),("oops")); - // Paranoid check to avoid divide by zero. - if (ht1==ht2) { - *pt = pt1; - return; - } - Int delta = ht2 - ht1; - Int d1 = ht2-ht; - Int d2 = ht-ht1; - DEBUG_ASSERTCRASH((d1+d2==delta),("oops")); - // Interpolate between pt1 and pt2. - pt->x = (pt1.x*d1 + pt2.x*d2)/delta; - pt->y = (pt1.y*d1 + pt2.y*d2)/delta; -} - -//============================================================================= -// CWorldBuilderView::drawMyTexture -//============================================================================= -/** Draws the tile data rgbData at pRect. The tile data is square 4 byte -data, width pixels wide and tall. */ -//============================================================================= -void CWorldBuilderView::drawMyTexture(CDC *pDc, CRect *pRect, Int width, UnsignedByte *rgbData) -{ - // Just blast about some dib bits. - BITMAPINFO bi; - bi.bmiHeader.biSize = sizeof(bi.bmiHeader); - bi.bmiHeader.biWidth = width; - bi.bmiHeader.biHeight = width; /* match display top left == 0,0 */ - bi.bmiHeader.biPlanes = 1; - bi.bmiHeader.biBitCount = 32; - bi.bmiHeader.biCompression = BI_RGB; - bi.bmiHeader.biSizeImage = (width*width)*(bi.bmiHeader.biBitCount/8); - bi.bmiHeader.biXPelsPerMeter = 1000; - bi.bmiHeader.biYPelsPerMeter = 1000; - bi.bmiHeader.biClrUsed = 0; - bi.bmiHeader.biClrImportant = 0; - - /*int val=*/::StretchDIBits(pDc->m_hDC, pRect->left, pRect->top, pRect->Width(), pRect->Height(), 0, 0, width, width, rgbData, &bi, - DIB_RGB_COLORS, SRCCOPY); -} - - -//============================================================================= -// CWorldBuilderView::invalidateCellInView -//============================================================================= -/** Invalidates the pixel area for the height map call at a particular location. */ -//============================================================================= -void CWorldBuilderView::invalidateCellInView(int xIndex, int yIndex) -{ - CWorldBuilderDoc* pDoc = WbDoc(); - ASSERT_VALID(pDoc); - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - - // Convert the index to pixel coordinates. - CRect cell; - // Flip the y. - cell.bottom = (pMap->getYExtent()-yIndex)*m_cellSize; - // Adjust for scrolling. - cell.bottom -= mYScrollOffset; - cell.top = cell.bottom-m_cellSize; - // Convert to pixel coord. - cell.left = xIndex*m_cellSize; - // adjust for scrolling. - cell.left -= mXScrollOffset; - cell.right = cell.left+m_cellSize; - InvalidateRect(&cell, false); -} - - -void CWorldBuilderView::adjustDocSize() -{ - CWorldBuilderDoc* pDoc = WbDoc(); - ASSERT_VALID(pDoc); - // Initialize to a sensible default as we may get redrawn before we load a map. - Int height = m_cellSize*256; - Int width = m_cellSize*256; - - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - // If we have a map loaded, use the actual size. - if (pMap) { - height = m_cellSize * pMap->getYExtent(); - width = m_cellSize * pMap->getXExtent(); - } - CRect clientRect; - GetClientRect(&clientRect); - Int flippedY = m_centerPt.Y; - if (pMap && flippedY>0) { - flippedY = pMap->getYExtent()-flippedY; - } - // Calculate the scroll offset to place the cell m_centerX, m_centerY in the middle. - mXScrollOffset = (m_centerPt.X*m_cellSize)-clientRect.Width()/2; - mYScrollOffset = (flippedY*m_cellSize)-clientRect.Height()/2; - // Calculate the scroll bar limits so we can have up to 1/2 screen of white space. - m_scrollMin.x = -clientRect.Width()/2; - m_scrollMax.x = width-clientRect.Width()/2; - m_scrollMin.y = -clientRect.Height()/2; - m_scrollMax.y = width-clientRect.Height()/2; - // Clip the offset so it fits inside the range. - if (mXScrollOffset > m_scrollMax.x) { - mXScrollOffset = m_scrollMax.x; - } - if (mYScrollOffset > m_scrollMax.y) { - mYScrollOffset = m_scrollMax.y; - } - // Set the scroll range - SetScrollRange(SB_HORZ, m_scrollMin.x, m_scrollMax.x, false); - SetScrollRange(SB_VERT, m_scrollMin.y, m_scrollMax.y, false); - // Set the position of the scroll button in the scroll bars. - SetScrollPos(SB_HORZ, mXScrollOffset, true); - SetScrollPos(SB_VERT, mYScrollOffset, true); -} - -//============================================================================= -// CWorldBuilderView::OnSize -//============================================================================= -/** Standard window handler method for when the window size changes. */ -//============================================================================= -void CWorldBuilderView::OnSize(UINT nType, int cx, int cy) -{ - // Do parent class processing. - WbView::OnSize(nType, cx, cy); - adjustDocSize(); -} - - -//============================================================================= -// CWorldBuilderView::OnVScroll -//============================================================================= -/** Standard window handler method for when the vertical scroll bar is used. */ -//============================================================================= -void CWorldBuilderView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - int scrollPixels=0; - // Based on the opcode, determine how may pixels to scroll. - switch(nSBCode) { - case SB_LINEDOWN: scrollPixels = m_cellSize; break; - case SB_LINEUP: scrollPixels = -m_cellSize; break; - case SB_PAGEDOWN: scrollPixels = 10*m_cellSize; break; - case SB_PAGEUP: scrollPixels = -10*m_cellSize; break; - case SB_THUMBPOSITION: scrollPixels = nPos-mYScrollOffset; break; - case SB_THUMBTRACK: scrollPixels = nPos-mYScrollOffset; break; - default: break; - } - scrollInView(0, -(Real)scrollPixels/m_cellSize, nSBCode != SB_THUMBTRACK); -} - -//============================================================================= -// CWorldBuilderView::OnHScroll -//============================================================================= -/** Standard window handler method for when the horizontal scroll bar is used. */ -//============================================================================= -void CWorldBuilderView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - int scrollPixels=0; - - switch(nSBCode) { - case SB_LINEDOWN: scrollPixels = m_cellSize; break; - case SB_LINEUP: scrollPixels = -m_cellSize; break; - case SB_PAGEDOWN: scrollPixels = 10*m_cellSize; break; - case SB_PAGEUP: scrollPixels = -10*m_cellSize; break; - case SB_THUMBPOSITION: scrollPixels = nPos-mXScrollOffset; break; - case SB_THUMBTRACK: scrollPixels = nPos-mXScrollOffset; break; - default: return; - } - scrollInView((Real)scrollPixels/m_cellSize, 0, nSBCode != SB_THUMBTRACK); -} - -//============================================================================= -// CWorldBuilderView::scroll -//============================================================================= -/** Scrolls the window. */ -//============================================================================= -void CWorldBuilderView::scrollInView(Real xScroll, Real yScroll, Bool end) -{ - // Calculate new scroll offset. - Int newOffset = mXScrollOffset + xScroll*m_cellSize; - // Clip it to our maximum scroll range. - if (newOffset < m_scrollMin.x) newOffset = m_scrollMin.x; - if (newOffset > m_scrollMax.x) newOffset = m_scrollMax.x; - // Back calculate the number of pixels to scroll. - xScroll = newOffset - mXScrollOffset; - mXScrollOffset = newOffset; - - // Calculate new scroll offset. - newOffset = mYScrollOffset - yScroll*m_cellSize; - // Clip it to our maximum scroll range. - if (newOffset < m_scrollMin.y) newOffset = m_scrollMin.y; - if (newOffset > m_scrollMax.y) newOffset = m_scrollMax.y; - // Back calculate the number of pixels to scroll. - yScroll = newOffset - mYScrollOffset; - mYScrollOffset = newOffset; - - if (xScroll || yScroll) { - ScrollWindow(-xScroll, -yScroll); - SetScrollPos(SB_HORZ, mXScrollOffset, true); - SetScrollPos(SB_VERT, mYScrollOffset, true); - // Update the center indexes. - CRect client; - GetClientRect(&client); - // pt is the center point in pixels, 0 based. - CPoint pt((client.left+client.right)/2+mXScrollOffset, (client.bottom+client.top)/2+mYScrollOffset); - CWorldBuilderDoc* pDoc = WbDoc(); - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - if (pMap==nullptr) return; - m_centerPt.X = (Real)(pt.x)/m_cellSize; - m_centerPt.Y = pMap->getYExtent() - (Real)(pt.y)/m_cellSize; - constrainCenterPt(); - } - if (end) - WbDoc()->syncViewCenters(m_centerPt.X, m_centerPt.Y); -} - - - -/** Toggles the show grid flag and invals the window. */ -void CWorldBuilderView::OnShowGrid() -{ - mShowGrid = !mShowGrid; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowGrid", mShowGrid?1:0); - Invalidate(false); -} - -/** Sets the check in the menu to match the show grid flag. */ -void CWorldBuilderView::OnUpdateShowGrid(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(mShowGrid?1:0); - // Note - grid doesn't show if the cell size < 4, so disable. - pCmdUI->Enable(m_cellSize>=MIN_GRID_SIZE); - -} - -#if DEAD -/** Toggles the show contours flag and invals the window. */ -void CWorldBuilderView::OnViewShowcontours() -{ - m_showContours = !m_showContours; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowContours", m_showContours?1:0); - Invalidate(false); -} - -/** Sets the check in the menu to match the show contours flag. */ -void CWorldBuilderView::OnUpdateViewShowcontours(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showContours?1:0); - // Note - contours don't show if the cell size < 4, so disable. - pCmdUI->Enable(m_cellSize>=MIN_GRID_SIZE); -} -#endif - - -/** Toggles the show texture flag and invals the window. */ -void CWorldBuilderView::OnViewShowtexture() -{ - m_showTexture = !m_showTexture; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowTexture", m_showTexture?1:0); - Invalidate(false); -} - -/** Sets the check in the menu to match the show texture flag. */ -void CWorldBuilderView::OnUpdateViewShowtexture(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showTexture?1:0); -} - - -// This code confuses doxygen, so stick it at the end of the file. - -IMPLEMENT_DYNCREATE(CWorldBuilderView, WbView) - -BEGIN_MESSAGE_MAP(CWorldBuilderView, WbView) - //{{AFX_MSG_MAP(CWorldBuilderView) - ON_WM_PAINT() - ON_WM_SIZE() - ON_WM_VSCROLL() - ON_WM_HSCROLL() - ON_COMMAND(IDM_ShowGrid, OnShowGrid) - ON_UPDATE_COMMAND_UI(IDM_ShowGrid, OnUpdateShowGrid) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_SHOWTEXTURE, OnViewShowtexture) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWTEXTURE, OnUpdateViewShowtexture) -// ON_COMMAND(ID_VIEW_SHOWCONTOURS, OnViewShowcontours) -// ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWCONTOURS, OnUpdateViewShowcontours) - //}}AFX_MSG_MAP - // Standard printing commands - ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) - ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) -END_MESSAGE_MAP() - - - -// ---------------------------------------------------------------------------- -Bool CWorldBuilderView::viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain) -{ - // Flip the y. - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - newPt->x = (Real)(curPt.x + mXScrollOffset)/m_cellSize; - newPt->y = pMap->getYExtent() - (Real)(curPt.y + mYScrollOffset)/m_cellSize; - newPt->x *= MAP_XY_FACTOR; - newPt->y *= MAP_XY_FACTOR; - newPt->z = MAGIC_GROUND_Z; - if (constrain) { - if (m_doLockAngle) { - Real dy = fabs(m_mouseDownDocPoint.y - newPt->y); - Real dx = fabs(m_mouseDownDocPoint.x - newPt->x); - if (dx>2*dy) { - // lock to dx. - newPt->y = m_mouseDownDocPoint.y; - } else if (dy>2*dx) { - //lock to dy. - newPt->x = m_mouseDownDocPoint.x; - } else { - // Lock to 45 degree. - dx = (dx+dy)/2; - dy = dx; - if (newPt->x < m_mouseDownDocPoint.x) dx = -dx; - if (newPt->y < m_mouseDownDocPoint.y) dy = -dy; - newPt->x = m_mouseDownDocPoint.x+dx; - newPt->y = m_mouseDownDocPoint.y+dy; - } - } - } -#ifdef X_DEBUG -CPoint curPt2; -docToViewCoords(*newPt, &curPt2); -DEBUG_ASSERTCRASH((curPt.x==curPt2.x),("oops")); -DEBUG_ASSERTCRASH((curPt.y==curPt2.y),("oops")); -#endif - return true; -} - -// ---------------------------------------------------------------------------- -Bool CWorldBuilderView::docToViewCoords(Coord3D curPt, CPoint* newPt) -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - newPt->x = (curPt.x/MAP_XY_FACTOR) * m_cellSize - mXScrollOffset; - newPt->y = (pMap->getYExtent() - curPt.y/MAP_XY_FACTOR) * m_cellSize - mYScrollOffset; -#ifdef X_DEBUG -Coord3D curPt2; -viewToDocCoords(*newPt, &curPt2); -DEBUG_ASSERTCRASH((abs(curPt.x-curPt2.x)<1),("oops")); -DEBUG_ASSERTCRASH((abs(curPt.y-curPt2.y)<1),("oops")); -#endif - return true; -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/addplayerdialog.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/addplayerdialog.cpp deleted file mode 100644 index f1ca63b41b6..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/addplayerdialog.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// addplayerdialog.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "addplayerdialog.h" -#include "Common/WellKnownKeys.h" -#include "Common/PlayerTemplate.h" -#include "GameLogic/SidesList.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" - -///////////////////////////////////////////////////////////////////////////// -// AddPlayerDialog dialog - - -AddPlayerDialog::AddPlayerDialog(AsciiString side, CWnd* pParent /*=nullptr*/) - : CDialog(AddPlayerDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(AddPlayerDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - m_side = side; - m_addedSide.clear(); -} - - -void AddPlayerDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(AddPlayerDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(AddPlayerDialog, CDialog) - //{{AFX_MSG_MAP(AddPlayerDialog) - ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditchangeCombo1) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// AddPlayerDialog message handlers - -void AddPlayerDialog::OnOK() -{ - CComboBox *faction = (CComboBox*)GetDlgItem(IDC_COMBO1); - - if (faction) - { - // get the text out of the combo. If it is user-typed, sel will be -1, otherwise it will be >=0 - CString theText; - Int sel = faction->GetCurSel(); - if (sel >= 0) { - faction->GetLBText(sel, theText); - } else { - faction->GetWindowText(theText); - } - - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY((LPCTSTR)theText)); - if (pt) - { - m_addedSide = pt ? pt->getName() : AsciiString::TheEmptyString; - SidesList newSides = *TheSidesList; - newSides.addPlayerByTemplate(m_addedSide); - Bool modified = newSides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in AddPlayerDialog::OnOK")); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(newSides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - } - - CDialog::OnOK(); -} - -void AddPlayerDialog::OnCancel() -{ - m_addedSide.clear(); - CDialog::OnCancel(); -} - -BOOL AddPlayerDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CComboBox *factions = (CComboBox*)GetDlgItem(IDC_COMBO1); - factions->ResetContent(); - if (ThePlayerTemplateStore) - { - for (int i = 0; i < ThePlayerTemplateStore->getPlayerTemplateCount(); i++) - { - const PlayerTemplate* pt = ThePlayerTemplateStore->getNthPlayerTemplate(i); - if (!pt) - continue; - if (m_side.isEmpty() || m_side == pt->getSide()) - factions->AddString(pt->getName().str()); - } - } - factions->SetCurSel(0); - - return TRUE; -} - -void AddPlayerDialog::OnEditchangeCombo1() -{ - // TODO: Add your control notification handler code here - -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/brushoptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/brushoptions.cpp deleted file mode 100644 index bcbb966fa22..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/brushoptions.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// brushoptions.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "Lib/BaseType.h" -#include "brushoptions.h" -#include "WorldBuilderView.h" -#include "BrushTool.h" - -BrushOptions *BrushOptions::m_staticThis = nullptr; -Int BrushOptions::m_currentWidth = 0; -Int BrushOptions::m_currentHeight = 0; -Int BrushOptions::m_currentFeather = 0; -///////////////////////////////////////////////////////////////////////////// -/// BrushOptions dialog trivial constructor - Create does the real work. - - -BrushOptions::BrushOptions(CWnd* pParent /*=nullptr*/) -{ - //{{AFX_DATA_INIT(BrushOptions) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -/// Windows default stuff. -void BrushOptions::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(BrushOptions) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -/// Sets the feather value in the dialog. -/** Update the value in the edit control and the slider. */ -void BrushOptions::setFeather(Int feather) -{ - CString buf; - buf.Format("%d", feather); - m_currentFeather = feather; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - -/// Sets the brush width value in the dialog. -/** Update the value in the edit control and the slider. */ -void BrushOptions::setWidth(Int width) -{ - CString buf; - buf.Format("%d", width); - m_currentWidth = width; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(buf); - } -} - -void BrushOptions::setHeight(Int height) -{ - char buffer[12]; - snprintf(buffer, ARRAY_SIZE(buffer), "%d", height); - m_currentHeight = height; - if (m_staticThis && !m_staticThis->m_updating) { - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(buffer); - } -} - - - -///////////////////////////////////////////////////////////////////////////// -// BrushOptions message handlers - -/// Dialog UI initialization. -/** Creates the slider controls, and sets the initial values for -width and feather in the ui controls. */ -BOOL BrushOptions::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = true; - m_brushWidthPopup.SetupPopSliderButton(this, IDC_SIZE_POPUP, this); - m_brushFeatherPopup.SetupPopSliderButton(this, IDC_FEATHER_POPUP, this); - m_brushHeightPopup.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - - - m_staticThis = this; - m_updating = false; - setFeather(m_currentFeather); - setWidth(m_currentWidth); - setHeight(m_currentHeight); - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/// Handles feather edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void BrushOptions::OnChangeFeatherEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int feather; - m_updating = true; - if (1==sscanf(buffer, "%d", &feather)) { - m_currentFeather = feather; - BrushTool::setFeather(m_currentFeather); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentFeather*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void BrushOptions::OnChangeSizeEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int width; - m_updating = true; - if (1==sscanf(buffer, "%d", &width)) { - m_currentWidth = width; - BrushTool::setWidth(m_currentWidth); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentWidth*MAP_XY_FACTOR); - pEdit = m_staticThis->GetDlgItem(IDC_WIDTH_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -/// Handles width edit ui messages. -/** Gets the new edit control text, converts it to an int, then updates - the slider and brush tool. */ -void BrushOptions::OnChangeHeightEdit() -{ - if (m_updating) return; - CWnd *pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - char buffer[_MAX_PATH]; - if (pEdit) { - pEdit->GetWindowText(buffer, sizeof(buffer)); - Int height; - m_updating = true; - if (1==sscanf(buffer, "%d", &height)) { - m_currentHeight = height; - BrushTool::setHeight(m_currentHeight); - snprintf(buffer, ARRAY_SIZE(buffer), "%.1f FEET.", m_currentHeight*MAP_HEIGHT_SCALE); - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_LABEL); - if (pEdit) pEdit->SetWindowText(buffer); - } - m_updating = false; - } -} - -void BrushOptions::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_SIZE_POPUP: - *pMin = 1; - *pMax = 30; - *pInitial = m_currentWidth; - *pLineSize = 1; - break; - - case IDC_HEIGHT_POPUP: - *pMin = 0; - *pMax = 255; - *pInitial = m_currentHeight; - *pLineSize = 1; - break; - - case IDC_FEATHER_POPUP: - *pMin = 0; - *pMax = 20; - *pInitial = m_currentFeather; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void BrushOptions::PopSliderChanged(const long sliderID, long theVal) -{ - CString str; - CWnd *pEdit; - switch (sliderID) { - - case IDC_SIZE_POPUP: - m_currentWidth = theVal; - str.Format("%d",m_currentWidth); - pEdit = m_staticThis->GetDlgItem(IDC_SIZE_EDIT); - if (pEdit) pEdit->SetWindowText(str); - BrushTool::setWidth(m_currentWidth); - break; - - case IDC_HEIGHT_POPUP: - m_currentHeight = theVal; - str.Format("%d",m_currentHeight); - pEdit = m_staticThis->GetDlgItem(IDC_HEIGHT_EDIT); - if (pEdit) pEdit->SetWindowText(str); - BrushTool::setHeight(m_currentHeight); - break; - - case IDC_FEATHER_POPUP: - m_currentFeather = theVal; - str.Format("%d",m_currentFeather); - pEdit = m_staticThis->GetDlgItem(IDC_FEATHER_EDIT); - if (pEdit) pEdit->SetWindowText(str); - BrushTool::setFeather(m_currentFeather); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -void BrushOptions::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_SIZE_POPUP: - break; - case IDC_HEIGHT_POPUP: - break; - case IDC_FEATHER_POPUP: - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - - -BEGIN_MESSAGE_MAP(BrushOptions, COptionsPanel) - //{{AFX_MSG_MAP(BrushOptions) - ON_EN_CHANGE(IDC_FEATHER_EDIT, OnChangeFeatherEdit) - ON_EN_CHANGE(IDC_SIZE_EDIT, OnChangeSizeEdit) - ON_EN_CHANGE(IDC_HEIGHT_EDIT, OnChangeHeightEdit) - ON_WM_HSCROLL() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/mapobjectprops.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/mapobjectprops.cpp deleted file mode 100644 index deb3bb4da35..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/mapobjectprops.cpp +++ /dev/null @@ -1,2892 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// mapobjectprops.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "wbview.h" -#include "mapobjectprops.h" -#include "propedit.h" -#include "CUndoable.h" -#include "EditParameter.h" - -#include "Common/ThingTemplate.h" -#include "Common/UnicodeString.h" -#include "Common/WellKnownKeys.h" -#include "Common/AudioEventInfo.h" - -#include "GameLogic/Module/UpgradeModule.h" -#include "GameLogic/Module/GenerateMinefieldBehavior.h" - -const char* NEUTRAL_TEAM_UI_STR = "(neutral)"; -const char* NEUTRAL_TEAM_INTERNAL_STR = "team"; - - - -///////////////////////////////////////////////////////////////////////////// -// MapObjectProps dialog - -/*static*/ MapObjectProps *MapObjectProps::TheMapObjectProps = nullptr; - -void MapObjectProps::makeMain() -{ - DEBUG_ASSERTCRASH(TheMapObjectProps == nullptr, ("already have a main props")); - if (TheMapObjectProps == nullptr) - TheMapObjectProps = this; -} - - -MapObjectProps::MapObjectProps(Dict* dictToEdit, const char* title, CWnd* pParent /*=nullptr*/) : - COptionsPanel(MapObjectProps::IDD, pParent), - m_dictToEdit(dictToEdit), - m_title(title), - m_selectedObject(nullptr), - m_dictSource(nullptr), - m_scale( 1.0f ), - m_height( 0 ), - m_posUndoable( nullptr ), - m_angle( 0 ), - m_defaultEntryIndex(0), - m_defaultIsNone(true) -{ - - - //{{AFX_DATA_INIT(MapObjectProps) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -MapObjectProps::~MapObjectProps() -{ - if (TheMapObjectProps == this) - TheMapObjectProps = nullptr; - - if ( m_posUndoable != nullptr ) - { - REF_PTR_RELEASE( m_posUndoable ); - } - - if ( m_hWnd ) - DestroyWindow(); -} - -void MapObjectProps::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(MapObjectProps) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(MapObjectProps, CDialog) - //{{AFX_MSG_MAP(MapObjectProps) - ON_BN_CLICKED(IDC_CUSTOMIZE_CHECKBOX, customizeToDict) - ON_BN_CLICKED(IDC_EDITPROP, OnEditprop) - ON_BN_CLICKED(IDC_ENABLED_CHECKBOX, enabledToDict) - ON_BN_CLICKED(IDC_LOOPING_CHECKBOX, loopingToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Enabled, _EnabledToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Indestructible, _IndestructibleToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Powered, _PoweredToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_RecruitableAI, _RecruitableAIToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Selectable, _SelectableToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Targetable, _TargetableToDict) - ON_BN_CLICKED(IDC_MAPOBJECT_Unsellable, _UnsellableToDict) - ON_BN_CLICKED(IDC_NEWPROP, OnNewprop) - ON_BN_CLICKED(IDC_REMOVEPROP, OnRemoveprop) - ON_BN_CLICKED(IDC_SCALE_OFF, OnScaleOff) - ON_BN_CLICKED(IDC_SCALE_ON, OnScaleOn) - ON_CBN_KILLFOCUS(IDC_MAPOBJECT_HitPoints, _HPsToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Aggressiveness, _AggressivenessToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Script, _ScriptToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_StartingHealth, _HealthToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Team, _TeamToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Time, _TimeToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Veterancy, _VeterancyToDict) - ON_CBN_SELCHANGE(IDC_MAPOBJECT_Weather, _WeatherToDict) - ON_CBN_SELCHANGE(IDC_PRIORITY_COMBO, priorityToDict) - ON_CBN_SELCHANGE(IDC_SOUND_COMBO, attachedSoundToDict) - ON_CBN_SELENDOK(IDC_MAPOBJECT_HitPoints, _HPsToDict) - ON_EN_KILLFOCUS(IDC_LOOPCOUNT_EDIT, loopCountToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_Angle, SetAngle) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_Name, _NameToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_Scale, _ScaleToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_ShroudClearingDistance, _ShroudClearingDistanceToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_StartingHealthEdit, _HealthToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_StoppingDistance, _StoppingDistanceToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_VisionDistance, _VisibilityToDict) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_XYPosition, OnKillfocusMAPOBJECTXYPosition) - ON_EN_KILLFOCUS(IDC_MAPOBJECT_ZOffset, SetZOffset) - ON_EN_KILLFOCUS(IDC_MAX_RANGE_EDIT, maxRangeToDict) - ON_EN_KILLFOCUS(IDC_MIN_RANGE_EDIT, minRangeToDict) - ON_EN_KILLFOCUS(IDC_MIN_VOLUME_EDIT, minVolumeToDict) - ON_EN_KILLFOCUS(IDC_VOLUME_EDIT, volumeToDict) - ON_LBN_DBLCLK(IDC_PROPERTIES, OnDblclkProperties) - ON_LBN_SELCHANGE(IDC_MAPOBJECT_BuildWithUpgrades, _PrebuiltUpgradesToDict) - ON_LBN_SELCHANGE(IDC_PROPERTIES, OnSelchangeProperties) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -static AsciiString getNthKeyStr(const Dict* d, int i) -{ - NameKeyType k = d->getNthKey(i); - AsciiString kstr = TheNameKeyGenerator->keyToName(k); - return kstr; -} - -static AsciiString getNthValueStr(const Dict* d, int i, Bool* enquote) -{ - *enquote = false; - AsciiString vstr; - switch(d->getNthType(i)) - { - case Dict::DICT_BOOL: - vstr.format("%s", d->getNthBool(i) ? "true" : "false"); - break; - case Dict::DICT_INT: - vstr.format("%d", d->getNthInt(i), d->getNthInt(i)); - break; - case Dict::DICT_REAL: - vstr.format("%f", d->getNthReal(i)); - break; - case Dict::DICT_ASCIISTRING: - vstr.format("%s", d->getNthAsciiString(i).str()); - *enquote = true; - break; - case Dict::DICT_UNICODESTRING: - vstr.format("%ls", d->getNthUnicodeString(i).str()); - *enquote = true; - break; - } - return vstr; -} - -int MapObjectProps::getSel() -{ -// CListBox *list = (CListBox*)GetDlgItem(IDC_PROPERTIES); -// int sel = list->GetCurSel(); -// if (!m_dictToEdit || sel == LB_ERR || sel < 0 || sel >= m_dictToEdit->getPairCount()) - return -1; -// return sel; -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToTeam() -{ - int i; - - AsciiString name; - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Team); - owner->ResetContent(); - for (i = 0; i < TheSidesList->getNumTeams(); i++) - { - name = TheSidesList->getTeamInfo(i)->getDict()->getAsciiString(TheKey_teamName); - if (name == NEUTRAL_TEAM_INTERNAL_STR) - name = NEUTRAL_TEAM_UI_STR; - owner->AddString(name.str()); - } - // re-find, since the list is sorted - i = -1; - if (m_dictToEdit) - { - name = m_dictToEdit->getAsciiString(TheKey_originalOwner); - if (name == NEUTRAL_TEAM_INTERNAL_STR) - name = NEUTRAL_TEAM_UI_STR; - i = owner->FindStringExact(-1, name.str()); - DEBUG_ASSERTLOG(i >= 0, ("missing team '%s'. Non-fatal (jkmcd)", name.str())); - - } - owner->SetCurSel(i); -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToName() -{ - AsciiString name; - Bool exists; - if (m_dictToEdit) - { - name = m_dictToEdit->getAsciiString(TheKey_objectName, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_Name); - if (pItem) - { - pItem->SetWindowText(name.str()); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToScript() -{ - if (!m_dictToEdit) - { - return; - } - - Bool exists; - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Script); - // Load the subroutine scripts into the combo box. - EditParameter::loadScripts(pCombo, true); - /*Int stringNdx =*/ pCombo->AddString(""); - AsciiString script = m_dictToEdit->getAsciiString(TheKey_objectScriptAttachment, &exists); - - if (script.isEmpty()) { - pCombo->SelectString(-1, ""); - } else { - pCombo->SelectString(-1, script.str()); - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_TeamToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Team); - static char buf[1024]; - owner->GetWindowText(buf, sizeof(buf)-2); - if (strcmp(buf, NEUTRAL_TEAM_UI_STR)==0) - strlcpy(buf, NEUTRAL_TEAM_INTERNAL_STR, ARRAY_SIZE(buf)); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - newDict.setAsciiString(TheKey_originalOwner, AsciiString(buf)); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_NameToDict() -{ - getAllSelectedDicts(); - - CWnd *owner = GetDlgItem(IDC_MAPOBJECT_Name); - CString cstr; - owner->GetWindowText(cstr); - - // Note: when starting up, this is called before a document exists. Just ignore such - // calls, since there can't be an object to affect. - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - newDict.setAsciiString(TheKey_objectName, cstr.GetBuffer(0)); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_ScriptToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Script); - static char buf[1024]; - owner->GetWindowText(buf, sizeof(buf)-2); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - newDict.setAsciiString(TheKey_objectScriptAttachment, AsciiString(buf)); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - - -/// Move data from object to dialog controls -void MapObjectProps::_DictToScale() -{ -// Currently not in the Mission Disk. -#if 0 - m_scale = 1; - Bool exists; - if (m_dictToEdit) { - m_scale = m_dictToEdit->getReal(TheKey_objectPrototypeScale, &exists); - } - if (!exists) { - m_scale = 1; - } - - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_Scale); - CString cstr; - cstr.Format("%.2f", m_scale); - edit->SetWindowText(cstr); - - CButton *off = (CButton*) GetDlgItem(IDC_SCALE_OFF); - CButton *on = (CButton*) GetDlgItem(IDC_SCALE_ON); - if (!exists) { - off->SetCheck(1); - on->SetCheck(0); - edit->EnableWindow(false); - GetDlgItem(IDC_SCALE_POPUP)->EnableWindow(false); - } else { - off->SetCheck(0); - on->SetCheck(1); - edit->EnableWindow(TRUE); - GetDlgItem(IDC_SCALE_POPUP)->EnableWindow(true); - } -#endif - -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToWeather() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectWeather, &exists); - if (!exists) - value = 0; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Weather); - pItem->SetCurSel(value); -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToTime() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectTime, &exists); - if (!exists) - value = 0; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Time); - pItem->SetCurSel(value); -} - -/// Move data from dialog controls to object -void MapObjectProps::_WeatherToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Weather); - static char buf[1024]; - int curSel = owner->GetCurSel(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - newDict.setInt(TheKey_objectWeather, curSel); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_TimeToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Time); - static char buf[1024]; - int curSel = owner->GetCurSel(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - newDict.setInt(TheKey_objectTime, curSel); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_ScaleToDict() -{ -// Currently not in mission disk. -#if 0 - getAllSelectedDicts(); - - Real value = 0.0f; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_Scale); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atof(cstr); - } - m_scale = value; - - CButton *off = (CButton*) GetDlgItem(IDC_SCALE_OFF); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - Dict newDict; - if (off->GetCheck() == 1) { - newDict.remove(TheKey_objectPrototypeScale); - } else { - newDict.setReal(TheKey_objectPrototypeScale, m_scale); - } - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -#endif -} - -/// Move data from object to dialog controls -void MapObjectProps::ShowZOffset(MapObject *pMapObj) -{ - const Coord3D *loc = pMapObj->getLocation(); - static char buff[32]; - m_height = loc->z; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", loc->z); - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - edit->SetWindowText(buff); -} - -/// Move data from dialog controls to object -void MapObjectProps::SetZOffset() -{ - Real value = 0.0f; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atof(cstr); - } - m_height = value; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - ModifyObjectUndoable *pUndo = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(pUndo); - pUndo->SetZOffset(value); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } -} - -/// Move data from object to dialog controls -void MapObjectProps::ShowAngle(MapObject *pMapObj) -{ - m_angle = pMapObj->getAngle() * 180 / PI; - static char buff[32]; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle); - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_Angle); - edit->SetWindowText(buff); - m_angle = atof(buff); -} - -/// Move data from object to dialog controls -void MapObjectProps::ShowPosition(MapObject *pMapObj) -{ - m_position = *pMapObj->getLocation(); - static char buff[64]; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f, %0.2f", m_position.x, m_position.y); - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_XYPosition); - edit->SetWindowText(buff); - sscanf(buff, "%f,%f", &m_position.x, &m_position.y); -} - -/// Move data from dialog controls to object -void MapObjectProps::SetAngle() -{ - Real angle = m_angle; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_Angle); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - angle = atof(cstr); - } - if (m_selectedObject==nullptr) return; - if (m_angle!=angle) - { - m_angle = angle; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - ModifyObjectUndoable *pUndo = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(pUndo); - pUndo->RotateTo(angle * PI/180); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - } -} - -/// Move data from dialog controls to object -void MapObjectProps::SetPosition() -{ - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_XYPosition); - CString cstr; - edit->GetWindowText(cstr); - Coord3D loc; - loc = m_position; - if (m_selectedObject==nullptr) return; - if (!cstr.IsEmpty()) { - if (sscanf(cstr, "%f, %f", &loc.x, &loc.y)!=2) - loc = m_position; - } - if (loc.x!=m_position.x || loc.y != m_position.y) { - m_position = loc; - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc ) - { - ModifyObjectUndoable *pUndo = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(pUndo); - if (m_selectedObject) { - loc = *m_selectedObject->getLocation(); - } - pUndo->SetOffset(m_position.x-loc.x, m_position.y-loc.y); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - } -} - -/// Slider control -void MapObjectProps::GetPopSliderInfo(const long sliderID, long *pMin, long *pMax, long *pLineSize, long *pInitial) -{ - switch (sliderID) { - - case IDC_HEIGHT_POPUP: - *pMin = -50; - *pMax = 50; - *pInitial = m_height; - *pLineSize = 1; - break; - - case IDC_ANGLE_POPUP: - *pMin = 0; - *pMax = 360; - *pInitial = m_angle; - *pLineSize = 1; - break; - - case IDC_SCALE_POPUP: - *pMin = 1; - *pMax = 500; - *pInitial = m_scale*100; - *pLineSize = 1; - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -/// Slider control -void MapObjectProps::PopSliderChanged(const long sliderID, long theVal) -{ - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc == nullptr ) - return; - - CWnd* edit; - static char buff[32]; - switch (sliderID) { - case IDC_HEIGHT_POPUP: - if (!m_posUndoable) { - m_posUndoable = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(m_posUndoable); - } - m_posUndoable->SetZOffset(theVal); - m_height = theVal; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_height); - edit = GetDlgItem(IDC_MAPOBJECT_ZOffset); - edit->SetWindowText(buff); - break; - - case IDC_ANGLE_POPUP: - if (!m_posUndoable) { - m_posUndoable = new ModifyObjectUndoable(pDoc); - pDoc->AddAndDoUndoable(m_posUndoable); - } - m_posUndoable->RotateTo(theVal * PI/180); - m_angle = theVal; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_angle); - edit = GetDlgItem(IDC_MAPOBJECT_Angle); - edit->SetWindowText(buff); - break; - - case IDC_SCALE_POPUP: - m_scale = theVal/100.0f; - snprintf(buff, ARRAY_SIZE(buff), "%0.2f", m_scale); - edit = GetDlgItem(IDC_MAPOBJECT_Scale); - edit->SetWindowText(buff); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } -} - -/// Slider control -void MapObjectProps::PopSliderFinished(const long sliderID, long theVal) -{ - switch (sliderID) { - case IDC_HEIGHT_POPUP: - case IDC_ANGLE_POPUP: - if ( m_posUndoable != nullptr ) - { - REF_PTR_RELEASE(m_posUndoable); // belongs to pDoc now. - } - m_posUndoable = nullptr; - break; - - case IDC_SCALE_POPUP: - _ScaleToDict(); - break; - - default: - // uh-oh! - DEBUG_CRASH(("Slider message from unknown control")); - break; - } - -} - -/// Move data from dialog controls to object -void MapObjectProps::_PrebuiltUpgradesToDict() -{ - getAllSelectedDicts(); - - CListBox *pBox = (CListBox *) GetDlgItem(IDC_MAPOBJECT_BuildWithUpgrades); - if (!pBox) { - return; - } - - // We only work for single selections - if (m_allSelectedDicts.size() != 1) { - return; - } - - if (m_selectedObject) { - if ( !m_selectedObject->getThingTemplate() ) { - return; - } - } - - Bool exists; - int upgradeNum = 0; - AsciiString upgradeString; - - // We're going to sub this entire dict for the existing entire dict. - Dict newDict = *m_allSelectedDicts[0]; - - // First, clear out any existing notions of what we should upgrade. - do { - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_objectGrantUpgrade).str(), upgradeNum); - upgradeString = newDict.getAsciiString(NAMEKEY(keyName), &exists); - - if (exists) { - newDict.remove(NAMEKEY(keyName)); - } - - ++upgradeNum; - } while (!upgradeString.isEmpty()); - - upgradeNum = 0; - // We've now removed them, so lets add the ones that are selected now. - Int countOfItems = pBox->GetCount(); - for (Int i = 0; i < countOfItems; ++i) { - if (pBox->GetSel(i) > 0) { - CString selTxt; - // This thing is selected. Get its text, and add it to the dict. - pBox->GetText(i, selTxt); - - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_objectGrantUpgrade).str(), upgradeNum); - newDict.setAsciiString(NAMEKEY(keyName), AsciiString(selTxt.GetBuffer(0))); - ++upgradeNum; - } - } - - // Now, do the Undoable - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, NAMEKEY_INVALID, m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToPrebuiltUpgrades() -{ - getAllSelectedDicts(); - - CListBox *pBox = (CListBox*) GetDlgItem(IDC_MAPOBJECT_BuildWithUpgrades); - if (!pBox) { - return; - } - - // First, clear out the list - pBox->ResetContent(); - CString cstr; - - // Then, if there's multiple units selected, add the Single Selection Only string - if (m_allSelectedDicts.size() > 1) { - cstr.LoadString(IDS_SINGLE_SELECTION_ONLY); - pBox->AddString(cstr); - return; - } - - if (m_selectedObject == nullptr) { - return; - } - - // Otherwise, fill it with the upgrades available for this unit - const ThingTemplate *tt = m_selectedObject->getThingTemplate(); - if (tt == nullptr) { - // This is valid. For instance, Scorch marks do not have thing templates. - return; - } - - Bool noUpgrades = false; - - // Now do any behaviors that are also upgrades. - const ModuleInfo& mi = tt->getBehaviorModuleInfo(); - if (mi.getCount() == 0) { - if (noUpgrades) { - cstr.LoadString(IDS_NO_UPGRADES); - pBox->AddString(cstr); - return; - } - } else { - Int numBehaviorModules = mi.getCount(); - - Int numBehaviorsWithUpgrades = 0; - - for (int i = 0; i < numBehaviorModules; ++i) { - if (mi.getNthName(i).compareNoCase("GenerateMinefieldBehavior") == 0) { - const GenerateMinefieldBehaviorModuleData *gmbmd = (const GenerateMinefieldBehaviorModuleData *)mi.getNthData(i); - if (!gmbmd) { - continue; - } - if (!gmbmd->m_upgradeMuxData.m_activationUpgradeNames.empty()) { - cstr = gmbmd->m_upgradeMuxData.m_activationUpgradeNames[0].str(); - if (pBox->FindString(-1, cstr) == LB_ERR) { - pBox->AddString(cstr); - ++numBehaviorsWithUpgrades; - } - } - } - } - - if (numBehaviorsWithUpgrades == 0) { - if (noUpgrades) { - cstr.LoadString(IDS_NO_UPGRADES); - pBox->AddString(cstr); - return; - } - } - } - - // Finally, walk through the upgrades that he already has, and select the appropriate members - // from the list - - Bool exists; - int upgradeNum = 0; - AsciiString upgradeString; - - do { - AsciiString keyName; - keyName.format("%s%d", TheNameKeyGenerator->keyToName(TheKey_objectGrantUpgrade).str(), upgradeNum); - upgradeString = m_dictToEdit->getAsciiString(NAMEKEY(keyName), &exists); - - if (exists) { - Int selNdx = pBox->FindStringExact(-1, upgradeString.str()); - if (selNdx == LB_ERR) { - DEBUG_CRASH(("Object claims '%s', but it wasn't found in the list of possible upgrades.", upgradeString.str())); - ++upgradeNum; - continue; - } - pBox->SetSel(selNdx); - - } else { - upgradeString.clear(); - } - - ++upgradeNum; - } while (!upgradeString.isEmpty()); -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToHealth() -{ - Int value = 100; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectInitialHealth, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_StartingHealth); - CWnd* pItem2 = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - if (pItem && pItem2) { - if (value == 0) { - pItem->SelectString(-1, "0%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 25) { - pItem->SelectString(-1, "25%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 50) { - pItem->SelectString(-1, "50%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 75) { - pItem->SelectString(-1, "75%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else if (value == 100) { - pItem->SelectString(-1, "100%"); - pItem2->SetWindowText(""); - pItem2->EnableWindow(FALSE); - } else { - pItem->SelectString(-1, "Other"); - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", value); - pItem2->SetWindowText(buff); - pItem2->EnableWindow(TRUE); - } - } -} - - -/// Move data from object to dialog controls -void MapObjectProps::_DictToHPs() -{ - Int value = -1; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectMaxHPs, &exists); - if (!exists) - value = -1; - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_HitPoints); - pItem->ResetContent(); - CString str; - str.Format("Default For Unit"); - pItem->InsertString(-1, str); - - if (value != -1) { - str.Format("%d", value); - pItem->InsertString(-1, str); - pItem->SetCurSel(1); - } else { - pItem->SetCurSel(0); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToEnabled() -{ - Bool enabled = true; - Bool exists; - if (m_dictToEdit) { - enabled = m_dictToEdit->getBool(TheKey_objectEnabled, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Enabled); - if (pItem) { - pItem->SetCheck(enabled); - } -} - - -/// Move data from object to dialog controls -void MapObjectProps::_DictToDestructible() -{ - Bool destructible = true; - Bool exists; - if (m_dictToEdit) { - destructible = m_dictToEdit->getBool(TheKey_objectIndestructible, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Indestructible); - if (pItem) { - pItem->SetCheck(destructible); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToUnsellable() -{ - Bool unsellable = false; - Bool exists; - if (m_dictToEdit) { - unsellable = m_dictToEdit->getBool(TheKey_objectUnsellable, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - if (pItem) { - pItem->SetCheck(unsellable); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToTargetable() -{ - Bool targetable = false; - Bool exists; - if( m_dictToEdit ) - { - targetable = m_dictToEdit->getBool( TheKey_objectTargetable, &exists ); - } - - CButton* pItem = (CButton*) GetDlgItem( IDC_MAPOBJECT_Targetable ); - if( pItem ) - { - pItem->SetCheck( targetable ); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToPowered() -{ - Bool powered = true; - Bool exists; - if (m_dictToEdit) { - powered = m_dictToEdit->getBool(TheKey_objectPowered, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Powered); - if (pItem) { - pItem->SetCheck(powered); - } - -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToAggressiveness() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectAggressiveness, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Aggressiveness); - if (pItem) { - if (value == -2) { - pItem->SelectString(-1, "Sleep"); - } else if (value == -1) { - pItem->SelectString(-1, "Passive"); - } else if (value == 0) { - pItem->SelectString(-1, "Normal"); - } else if (value == 1) { - pItem->SelectString(-1, "Alert"); - } else if (value == 2) { - pItem->SelectString(-1, "Aggressive"); - } - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToVisibilityRange() -{ - Int distance = 0; - Bool exists; - if (m_dictToEdit) { - distance = m_dictToEdit->getInt(TheKey_objectVisualRange, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_VisionDistance); - if (pItem) { - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", distance); - if (distance == 0) { - pItem->SetWindowText(""); - } else { - pItem->SetWindowText(buff); - } - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToVeterancy() -{ - Int value = 0; - Bool exists; - if (m_dictToEdit) { - value = m_dictToEdit->getInt(TheKey_objectVeterancy, &exists); - } - - CComboBox* pItem = (CComboBox*) GetDlgItem(IDC_MAPOBJECT_Veterancy); - if (pItem) { - pItem->SetCurSel(value); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToShroudClearingDistance() -{ - Int distance = 0; - Bool exists; - if (m_dictToEdit) { - distance = m_dictToEdit->getInt(TheKey_objectShroudClearingDistance, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_ShroudClearingDistance); - if (pItem) { - static char buff[12]; - snprintf(buff, ARRAY_SIZE(buff), "%d", distance); - if (distance == 0) { - pItem->SetWindowText(""); - } else { - pItem->SetWindowText(buff); - } - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToRecruitableAI() -{ - Bool recruitableAI = true; - Bool exists; - if (m_dictToEdit) { - recruitableAI = m_dictToEdit->getBool(TheKey_objectRecruitableAI, &exists); - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_RecruitableAI); - if (pItem) { - pItem->SetCheck(recruitableAI); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToSelectable() -{ - Int selectable = true; - Bool exists=false; - if (m_dictToEdit) { - selectable = m_dictToEdit->getBool(TheKey_objectSelectable, &exists); - } - if (!exists) { - selectable = 2; - } - - CButton* pItem = (CButton*) GetDlgItem(IDC_MAPOBJECT_Selectable); - if (pItem) { - pItem->SetCheck(selectable); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::_DictToStoppingDistance() -{ - Real stoppingDistance = 1.0f; - Bool exists = false; - if (m_dictToEdit) { - stoppingDistance = m_dictToEdit->getReal(TheKey_objectStoppingDistance, &exists); - } - - CWnd* pItem = GetDlgItem(IDC_MAPOBJECT_StoppingDistance); - if (pItem) { - static char buff[32]; - snprintf(buff, ARRAY_SIZE(buff), "%g", stoppingDistance); - pItem->SetWindowText(buff); - } -} - - -/// Move data from dialog controls to object -void MapObjectProps::_HealthToDict() -{ - getAllSelectedDicts(); - - Int value; - static char buf[1024]; - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_StartingHealth); - owner->GetWindowText(buf, sizeof(buf)-2); - if (strcmp(buf, "Dead") == 0) { - value = 0; - } else if (strcmp(buf, "25%") == 0) { - value = 25; - } else if (strcmp(buf, "50%") == 0) { - value = 50; - } else if (strcmp(buf, "75%") == 0) { - value = 75; - } else if (strcmp(buf, "100%") == 0) { - value = 100; - } else if (strcmp(buf, "Other") == 0) { - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_StartingHealthEdit); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (cstr.IsEmpty()) { - return; - } - value = atoi(cstr.GetBuffer(0)); - } - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setInt(TheKey_objectInitialHealth, value); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - - -/// Move data from dialog controls to object -void MapObjectProps::_EnabledToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Enabled); - Bool isChecked = (owner->GetCheck() != 0); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool(TheKey_objectEnabled, isChecked); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_IndestructibleToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Indestructible); - Bool isChecked = (owner->GetCheck() != 0); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool(TheKey_objectIndestructible, isChecked); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_UnsellableToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Unsellable); - Bool isChecked = (owner->GetCheck() != 0); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool(TheKey_objectUnsellable, isChecked); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_TargetableToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*)GetDlgItem( IDC_MAPOBJECT_Targetable ); - Bool isChecked = owner->GetCheck() != 0; - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool( TheKey_objectTargetable, isChecked ); - DictItemUndoable *pUndo = new DictItemUndoable( getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size() ); - pDoc->AddAndDoUndoable( pUndo ); - REF_PTR_RELEASE( pUndo ); // belongs to pDoc now. - // Update is called by Do - } -} - - -/// Move data from dialog controls to object -void MapObjectProps::_PoweredToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Powered); - Bool isChecked = (owner->GetCheck() != 0); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool(TheKey_objectPowered, isChecked); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_AggressivenessToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Aggressiveness); - static char buf[1024]; - owner->GetWindowText(buf, sizeof(buf)-2); - int value = 0; - - if (strcmp(buf, "Sleep") == 0) { - value = -2; - } else if (strcmp(buf, "Passive") == 0) { - value = -1; - } else if (strcmp(buf, "Normal") == 0) { - value = 0; - } else if (strcmp(buf, "Alert") == 0) { - value = 1; - } else if (strcmp(buf, "Aggressive") == 0) { - value = 2; - } - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setInt(TheKey_objectAggressiveness, value); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_VisibilityToDict() -{ - getAllSelectedDicts(); - - int value = -1; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_VisionDistance); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atoi(cstr.GetBuffer(0)); - } - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - if (value != -1) { - newDict.setInt(TheKey_objectVisualRange, value); - } - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, TheKey_objectVisualRange, m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_VeterancyToDict() -{ - getAllSelectedDicts(); - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_Veterancy); - static char buf[1024]; - int curSel = owner->GetCurSel(); - int value = 0; - if (curSel >= 0) { - value=curSel; - } - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setInt(TheKey_objectVeterancy, value); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_ShroudClearingDistanceToDict() -{ - getAllSelectedDicts(); - - int value = -1; - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_ShroudClearingDistance); - edit->EnableWindow(TRUE); - CString cstr; - edit->GetWindowText(cstr); - if (!cstr.IsEmpty()) { - value = atoi(cstr.GetBuffer(0)); - } - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - if (value != -1) { - newDict.setInt(TheKey_objectShroudClearingDistance, value); - } - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, TheKey_objectShroudClearingDistance, m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_RecruitableAIToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_RecruitableAI); - Bool isChecked = (owner->GetCheck() != 0); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setBool(TheKey_objectRecruitableAI, isChecked); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_SelectableToDict() -{ - getAllSelectedDicts(); - - CButton *owner = (CButton*) GetDlgItem(IDC_MAPOBJECT_Selectable); - Bool isChecked = (owner->GetCheck() == 1); - Bool isTristate = (owner->GetCheck() == 2); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - if (isTristate) { - newDict.remove(TheKey_objectSelectable); - } else { - newDict.setBool(TheKey_objectSelectable, isChecked); - } - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Do - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_HPsToDict() -{ - getAllSelectedDicts(); - - Int value; - static char buf[1024]; - - CComboBox *owner = (CComboBox*)GetDlgItem(IDC_MAPOBJECT_HitPoints); - owner->GetWindowText(buf, sizeof(buf)-2); - value = atoi(buf); - if (value == 0) - value = -1; - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - newDict.setInt(TheKey_objectMaxHPs, value); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size()); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } -} - -/// Move data from dialog controls to object -void MapObjectProps::_StoppingDistanceToDict() -{ - getAllSelectedDicts(); - - Real value; - static char buf[1024]; - - CWnd* edit = GetDlgItem(IDC_MAPOBJECT_StoppingDistance); - CString cstr; - edit->GetWindowText(cstr); - if (cstr.IsEmpty()) { - return; - } - value = atof(cstr.GetBuffer(0)); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - newDict.setReal(TheKey_objectStoppingDistance, value); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - - -void MapObjectProps::OnEditprop() -{ - int sel = getSel(); - if (sel == -1 || !m_dictToEdit) - return; - - Bool enquote; - AsciiString kstr = getNthKeyStr(m_dictToEdit, sel); - AsciiString vstr = getNthValueStr(m_dictToEdit, sel, &enquote); - Dict::DataType type = m_dictToEdit->getNthType(sel); - - PropEdit propDlg(&kstr, &type, &vstr, true, this); - if (propDlg.DoModal() == IDOK) - { - Dict newDict = DictItemUndoable::buildSingleItemDict(kstr, type, vstr); - if (this == TheMapObjectProps) - { - // it's the floating panel; use an undoable - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - DictItemUndoable *pUndo = new DictItemUndoable(&m_dictToEdit, newDict, newDict.getNthKey(0)); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - else - { - // we're running modal; just slam it in the dict - m_dictToEdit->copyPairFrom(newDict, newDict.getNthKey(0)); - } - updateTheUI(); - } -} - -void MapObjectProps::OnNewprop() -{ - if (!m_dictToEdit) - return; - - // TODO: Add your control notification handler code here - static Dict::DataType lastNewType = Dict::DICT_BOOL; - AsciiString key, value; - - PropEdit propDlg(&key, &lastNewType, &value, false, this); - if (propDlg.DoModal() == IDOK) - { - Dict newDict = DictItemUndoable::buildSingleItemDict(key, lastNewType, value); - if (this == TheMapObjectProps) - { - // it's the floating panel; use an undoable - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - DictItemUndoable *pUndo = new DictItemUndoable(&m_dictToEdit, newDict, newDict.getNthKey(0)); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - else - { - // we're running modal; just slam it in the dict - m_dictToEdit->copyPairFrom(newDict, newDict.getNthKey(0)); - } - updateTheUI(); - } -} - -void MapObjectProps::OnRemoveprop() -{ - int sel = getSel(); - if (sel == -1) - return; - - NameKeyType k = m_dictToEdit->getNthKey(sel); - if (this == TheMapObjectProps) - { - // it's the floating panel; use an undoable - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - Dict newDict; // empty dict - DictItemUndoable *pUndo = new DictItemUndoable(&m_dictToEdit, newDict, k); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - else - { - // we're running modal; just slam it in the dict - m_dictToEdit->remove(k); - } - updateTheUI(); -} - -void MapObjectProps::OnDblclkProperties() -{ - OnEditprop(); -} - - -static const Char NO_SOUND_STRING[] = "(None)"; -static const Char BASE_DEFAULT_STRING[] = "Default"; - -void MapObjectProps::OnSelchangeProperties() -{ - -} - -/// Initialize dialog, especially drop down lists -BOOL MapObjectProps::OnInitDialog() -{ - CDialog::OnInitDialog(); - - if (m_title) - SetWindowText(m_title); - - m_heightSlider.SetupPopSliderButton(this, IDC_HEIGHT_POPUP, this); - m_angleSlider.SetupPopSliderButton(this, IDC_ANGLE_POPUP, this); - m_scaleSlider.SetupPopSliderButton(this, IDC_SCALE_POPUP, this); - m_posUndoable = nullptr; - m_angle = 0; - m_height = 0; - m_scale = 1.0f; - - InitSound(); - updateTheUI(); - - return TRUE; -} - -//--------------------------------------------------------------------------------------------------- -/*static*/ void MapObjectProps::update() -{ - if (TheMapObjectProps) - { - TheMapObjectProps->updateTheUI(); - } -} - -void MapObjectProps::updateTheUI() -{ - if (this != TheMapObjectProps) { - return; - } - for (MapObject *pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (!pMapObj->isSelected() || pMapObj->isWaypoint() || pMapObj->isLight()) { - continue; - } - - m_dictSource = pMapObj; - // Select correct dictionary - m_dictToEdit = m_dictSource ? m_dictSource->getProperties() : nullptr; - - updateTheUI(m_dictSource); - - // simply break after the first one that's selected - break; - } -} - -/// Move *all* data from object to dialog controls -void MapObjectProps::updateTheUI(MapObject *pMapObj) -{ - _DictToName(); - _DictToTeam(); - _DictToScript(); - _DictToWeather(); - _DictToTime(); - _DictToScale(); - _DictToPrebuiltUpgrades(); - _DictToHealth(); - _DictToHPs(); - _DictToEnabled(); - _DictToDestructible(); - _DictToPowered(); - _DictToAggressiveness(); - _DictToVisibilityRange(); - _DictToVeterancy(); - _DictToShroudClearingDistance(); - _DictToRecruitableAI(); - _DictToSelectable(); - _DictToStoppingDistance(); - _DictToUnsellable(); - _DictToTargetable(); - ShowZOffset(pMapObj); - ShowAngle(pMapObj); - ShowPosition(pMapObj); - - // Warning: order is important. dictToAttachedSound() must come before dictToCustomize(), - // dictToCustomize() must come before any of the customization controls, dictToLooping() - // must come before dictToLoopCount(), and dictToLooping() and dictToLoopCount() must - // come before dictToEnabled(). - dictToAttachedSound(); - dictToCustomize(); - dictToLooping(); - dictToLoopCount(); - dictToEnabled(); - dictToMinVolume(); - dictToVolume(); - dictToMinRange(); - dictToMaxRange(); - dictToPriority(); -} - -//--------------------------------------------------------------------------------------------------- - -void MapObjectProps::InitSound() -{ - CComboBox * priorityComboBox = (CComboBox *)GetDlgItem(IDC_PRIORITY_COMBO); - DEBUG_ASSERTCRASH( priorityComboBox != nullptr, ("Cannot find sound priority combobox" ) ); - - if ( priorityComboBox != nullptr ) - { - Int i; - for ( i = 0; i <= AP_CRITICAL; i++ ) - { - Int index = priorityComboBox->InsertString( i,theAudioPriorityNames[i] ); - (void)index; - DEBUG_ASSERTCRASH( index == i, ("insert string returned %d, expected %d", index, i ) ); - } - } - - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - DEBUG_ASSERTCRASH( soundComboBox != nullptr, ("Cannot find sound combobox" ) ); - m_defaultEntryIndex = 0; - m_defaultIsNone = true; - - // Load up combobox - if ( soundComboBox != nullptr ) - { - // Add all the sound names in order. Since the combobox has the SORTED style, - // we can just add the strings in and let the combo box sort them - const AudioEventInfoHash & audioEventHash = TheAudio->getAllAudioEvents(); - - AudioEventInfoHash::const_iterator it; - for ( it = audioEventHash.begin(); it != audioEventHash.end(); it++ ) - { - if ( it->second->m_soundType == AT_SoundEffect ) - { - // Hmm, should we be filtering the list in any other way? Oh well. - soundComboBox->AddString( it->second->m_audioName.str() ); - } - } - - m_defaultEntryIndex = soundComboBox->InsertString( 0, BASE_DEFAULT_STRING ); - m_defaultEntryName = NO_SOUND_STRING; - m_defaultIsNone = true; - - soundComboBox->InsertString( 1, NO_SOUND_STRING ); - } - -} - - -// Adds a series of Undoable's to the given MultipleUndoable which clears the -// objectSoundAmbientCustomized flag and all the customization flags out of -// all the selected dictionaries. -// NOTE: assumes getAllSelectedDicts() has already been called -void MapObjectProps::clearCustomizeFlag( CWorldBuilderDoc* pDoc, MultipleUndoable * ownerUndoable ) -{ - Dict empty; - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientCustomized, m_allSelectedDicts.size(), pDoc, true); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - // Note: we can set all the undoes in between the first and last undo to not invalidate, - // since the first (last for doing) and last invalidate after these changes anyway - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientMaxRange, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientMinVolume, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientVolume, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientMinRange, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientLooping, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientLoopCount, m_allSelectedDicts.size(), pDoc, false); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. - - pUndo = new DictItemUndoable(getAllSelectedDictsData(), empty, TheKey_objectSoundAmbientPriority, m_allSelectedDicts.size(), pDoc, true); - ownerUndoable->addUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to ownerUndoable now. -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::attachedSoundToDict() -{ - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - MultipleUndoable *pUndo = new MultipleUndoable; - - Dict newDict; - - // For the default, erase the objectSoundAmbient key - if ( soundComboBox->GetCurSel() != m_defaultEntryIndex ) - { - CString selectionText; - soundComboBox->GetLBText( soundComboBox->GetCurSel(), selectionText ); - if ( selectionText == NO_SOUND_STRING ) - { - newDict.setAsciiString(TheKey_objectSoundAmbient, ""); - // Can't customize the null sound - clearCustomizeFlag( pDoc, pUndo ); - } - else - { - newDict.setAsciiString(TheKey_objectSoundAmbient, static_cast< const char * >( selectionText) ); - } - } - else if ( m_defaultIsNone ) - { - // Can't customize the null sound - clearCustomizeFlag( pDoc, pUndo ); - } - - DictItemUndoable *pDictUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, TheKey_objectSoundAmbient, m_allSelectedDicts.size(), pDoc, true); - pUndo->addUndoable( pDictUndo ); - pDoc->AddAndDoUndoable( pUndo ); - REF_PTR_RELEASE( pDictUndo ); // belongs to pUndo - REF_PTR_RELEASE( pUndo ); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::customizeToDict() -{ - CButton * customizeCheckbox = (CButton *)GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - // For space reasons, erase key instead of added "false" key. Should be treated the same - if ( customizeCheckbox->GetCheck() == 1 ) - { - newDict.setBool( TheKey_objectSoundAmbientCustomized, true ); - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, TheKey_objectSoundAmbientCustomized, m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } - else - { - MultipleUndoable *pUndo = new MultipleUndoable; - clearCustomizeFlag( pDoc, pUndo ); - pDoc->AddAndDoUndoable( pUndo ); - REF_PTR_RELEASE( pUndo ); // belongs to pDoc now. - // Update is called by Doc - } - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::enabledToDict() -{ - CButton * enabledCheckbox = (CButton *)GetDlgItem(IDC_ENABLED_CHECKBOX); - if ( enabledCheckbox == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - newDict.setBool( TheKey_objectSoundAmbientEnabled, enabledCheckbox->GetCheck() != 0 ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::loopingToDict() -{ - CButton * loopingCheckbox = (CButton *)GetDlgItem(IDC_LOOPING_CHECKBOX); - if ( loopingCheckbox == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - newDict.setBool( TheKey_objectSoundAmbientLooping, loopingCheckbox->GetCheck() != 0 ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::loopCountToDict() -{ - CEdit * loopCountEdit = (CEdit *)GetDlgItem(IDC_LOOPCOUNT_EDIT); - if ( loopCountEdit == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - CString loopCountString; - loopCountEdit->GetWindowText(loopCountString); - - newDict.setInt( TheKey_objectSoundAmbientLoopCount, atoi( loopCountString ) ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::minVolumeToDict() -{ - CEdit * minVolumeEdit = (CEdit *)GetDlgItem(IDC_MIN_VOLUME_EDIT); - if ( minVolumeEdit == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - CString minVolumeString; - minVolumeEdit->GetWindowText(minVolumeString); - - // Note: min volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - newDict.setReal( TheKey_objectSoundAmbientMinVolume, INT_TO_REAL( atoi( minVolumeString ) ) / 100.0f ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::volumeToDict() -{ - CEdit * volumeEdit = (CEdit *)GetDlgItem(IDC_VOLUME_EDIT); - if ( volumeEdit == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - CString volumeString; - volumeEdit->GetWindowText(volumeString); - - // Note: volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - newDict.setReal( TheKey_objectSoundAmbientVolume, INT_TO_REAL( atoi( volumeString ) ) / 100.0f ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - - -/// Move data from dialog controls to object(s) -void MapObjectProps::minRangeToDict() -{ - CEdit * minRangeEdit = (CEdit *)GetDlgItem(IDC_MIN_RANGE_EDIT); - if ( minRangeEdit == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - CString minRangeString; - minRangeEdit->GetWindowText(minRangeString); - - newDict.setReal( TheKey_objectSoundAmbientMinRange, INT_TO_REAL( atoi( minRangeString ) ) ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::maxRangeToDict() -{ - CEdit * maxRangeEdit = (CEdit *)GetDlgItem(IDC_MAX_RANGE_EDIT); - if ( maxRangeEdit == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - CString maxRangeString; - maxRangeEdit->GetWindowText(maxRangeString); - - newDict.setReal( TheKey_objectSoundAmbientMaxRange, INT_TO_REAL( atoi( maxRangeString ) ) ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - -/// Move data from dialog controls to object(s) -void MapObjectProps::priorityToDict() -{ - CComboBox * priorityComboBox = (CComboBox *)GetDlgItem(IDC_PRIORITY_COMBO); - if ( priorityComboBox == nullptr ) - return; - - getAllSelectedDicts(); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - if ( pDoc != nullptr ) - { - Dict newDict; - - newDict.setInt( TheKey_objectSoundAmbientPriority, priorityComboBox->GetCurSel() ); - - DictItemUndoable *pUndo = new DictItemUndoable(getAllSelectedDictsData(), newDict, newDict.getNthKey(0), m_allSelectedDicts.size(), pDoc, true); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - // Update is called by Doc - } -} - - -/// Move data from object to dialog controls -void MapObjectProps::dictToAttachedSound() -{ - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - return; - - // Update the string for the "default" entry - m_defaultIsNone = true; - m_defaultEntryName = NO_SOUND_STRING; - soundComboBox->DeleteString(m_defaultEntryIndex); - const ThingTemplate * thingTemplate = nullptr; - if (m_dictSource) - { - thingTemplate = m_dictSource->getThingTemplate(); - } - - if ( thingTemplate ) - { - AsciiString string( BASE_DEFAULT_STRING ); - - const AudioEventRTS * defaultAudioEvent; - - // Note: getSoundAmbient will return a non-null pointer even if there is no real sound attached to the object - if ( thingTemplate->hasSoundAmbient() ) - { - defaultAudioEvent = thingTemplate->getSoundAmbient(); - } - else - { - defaultAudioEvent = nullptr; - } - - if ( defaultAudioEvent == nullptr || defaultAudioEvent == TheAudio->getValidSilentAudioEvent() ) - { - string.concat( " " ); - } - else - { - string.concat( " <" ); - string.concat( defaultAudioEvent->getEventName() ); - string.concat( '>' ); - m_defaultEntryName = defaultAudioEvent->getEventName(); - m_defaultIsNone = false; - } - m_defaultEntryIndex = soundComboBox->InsertString(0, string.str()); - } - else - { - m_defaultEntryIndex = soundComboBox->InsertString(0, BASE_DEFAULT_STRING); - } - - // Now select the correct entry in the list box - AsciiString sound; - Bool exists = false; - if (m_dictToEdit) - { - sound = m_dictToEdit->getAsciiString(TheKey_objectSoundAmbient, &exists); - } - - if ( !exists ) - { - // Use the "default" entry - soundComboBox->SetCurSel( m_defaultEntryIndex ); - return; - } - - if ( sound.isEmpty() ) - { - // Use the entry "(None)" - sound = NO_SOUND_STRING; - } - - // Note: better than SelectString because we want the exact string not a prefix - Int index = soundComboBox->FindStringExact( -1, sound.str() ); - if ( index > -1 ) - { - soundComboBox->SetCurSel( index ); - } - else - { - DEBUG_CRASH( ("Could not find existing sound's name %s in combo box", sound.str() ) ); - soundComboBox->SetCurSel( m_defaultEntryIndex ); - } -} - -/// Move data from object to dialog controls -void MapObjectProps::dictToCustomize() -{ - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr ) - return; - - // If the current sound is "none", disable the customize button - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - return; - - int index = soundComboBox->GetCurSel(); - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || - ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - customizeCheckbox->SetCheck( 0 ); - customizeCheckbox->EnableWindow( false ); - return; - } - - // Sound is not "none", so we can customize if we wish - customizeCheckbox->EnableWindow( true ); - - Bool exists = false; - Bool customized = false; - if (m_dictToEdit) - { - customized = m_dictToEdit->getBool(TheKey_objectSoundAmbientCustomized, &exists); - } - - customizeCheckbox->SetCheck( exists && customized ? 1 : 0 ); -} - - -/// Move data from object to dialog controls -void MapObjectProps::dictToLooping() -{ - CButton * loopingCheckbox = ( CButton * )GetDlgItem(IDC_LOOPING_CHECKBOX); - if ( loopingCheckbox == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - loopingCheckbox->EnableWindow( false ); - } - else - { - loopingCheckbox->EnableWindow( true ); - - // If customization is enabled, look to see if the looping flag has already been - // customized - Bool exists = false; - Bool looping = false; - if (m_dictToEdit) - { - looping = m_dictToEdit->getBool(TheKey_objectSoundAmbientLooping, &exists); - } - - if ( exists ) - { - loopingCheckbox->SetCheck( looping ? 1 : 0 ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the looping checkbox - - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - loopingCheckbox->SetCheck( 0 ); - return; - } - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - loopingCheckbox->SetCheck( 0 ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - loopingCheckbox->SetCheck( ( audioEventInfo && ( audioEventInfo->m_control & AC_LOOP ) ) ? 1 : 0 ); -} - -/// Move data from object to dialog controls -void MapObjectProps::dictToLoopCount() -{ - CEdit * loopCountEdit = ( CEdit * )GetDlgItem(IDC_LOOPCOUNT_EDIT); - if ( loopCountEdit == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - // If the looping checkbox is off, the loop count control is disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - CButton * loopingCheckbox = ( CButton * )GetDlgItem(IDC_LOOPING_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 || - loopingCheckbox == nullptr || loopingCheckbox->GetCheck() == 0 ) - { - loopCountEdit->EnableWindow( false ); - } - else - { - loopCountEdit->EnableWindow( true ); - - // If customization is enabled, look to see if the loop count has already been - // customized - Bool exists = false; - Int loopCount = 0; - if (m_dictToEdit) - { - loopCount = m_dictToEdit->getInt(TheKey_objectSoundAmbientLoopCount, &exists); - } - - if ( exists ) - { - CString loopCountText; - loopCountText.Format( "%d", loopCount ); - loopCountEdit->SetWindowText( loopCountText ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the loop count - - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - loopCountEdit->SetWindowText( "0" ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - loopCountEdit->SetWindowText( "0" ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - loopCountEdit->SetWindowText( "0" ); - return; - } - - CString loopCountText; - loopCountText.Format( "%d", audioEventInfo->m_loopCount ); - loopCountEdit->SetWindowText( loopCountText ); -} - -/// Move data from object to dialog controls -void MapObjectProps::dictToEnabled() -{ - CButton * enableCheckbox = ( CButton * )GetDlgItem(IDC_ENABLED_CHECKBOX); - if ( enableCheckbox == nullptr ) - return; - - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - - // If we don't have a sound, we can't enable it - CString currentString; - if ( soundComboBox == nullptr ) - { - enableCheckbox->EnableWindow( false ); - enableCheckbox->SetCheck( 0 ); - return; - } - - Int soundIndex = soundComboBox->GetCurSel(); - soundComboBox->GetLBText( soundIndex, currentString ); - if ( currentString == NO_SOUND_STRING || - ( soundIndex == m_defaultEntryIndex && m_defaultIsNone ) ) - { - enableCheckbox->SetCheck( 0 ); - enableCheckbox->EnableWindow( false ); - return; - } - else - { - enableCheckbox->EnableWindow( true ); - - // Look to see if the enabled flag has already been customized - Bool exists = false; - Bool enabled = false; - if (m_dictToEdit) - { - enabled = m_dictToEdit->getBool(TheKey_objectSoundAmbientEnabled, &exists); - } - - if ( exists ) - { - enableCheckbox->SetCheck( enabled ? 1 : 0 ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the enabled checkbox - - // Look up sound and see if it's looping. Looping-forever sounds start enabled; - // non-looping ones don't. - // Actually, by now, dictToLooping and dictToLoopCount will have looked up the - // info we need for us - // NOTE: This test should match the tests done in Object::updateObjValuesFromMapProperties() - // when it decided whether or not to enable a customized sound - CButton * loopingCheckbox = (CButton *)GetDlgItem(IDC_LOOPING_CHECKBOX); - CEdit * loopCountEdit = (CEdit *)GetDlgItem(IDC_LOOPCOUNT_EDIT); - if ( loopingCheckbox && loopCountEdit && loopingCheckbox->GetCheck() == 1 ) - { - CString loopCount; - loopCountEdit->GetWindowText( loopCount ); - - if ( atoi(loopCount) == 0 ) - { - enableCheckbox->SetCheck( 1 ); - return; - } - } - - enableCheckbox->SetCheck( 0 ); -} - - -/// Move data from object to dialog controls -void MapObjectProps::dictToMinVolume() -{ - CEdit * minVolumeEdit = ( CEdit * )GetDlgItem(IDC_MIN_VOLUME_EDIT); - if ( minVolumeEdit == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - minVolumeEdit->EnableWindow( false ); - } - else - { - minVolumeEdit->EnableWindow( true ); - - // If customization is enabled, look to see if the minimum volume has already been - // customized - Bool exists = false; - Real minVolume = 0.0f; - if (m_dictToEdit) - { - minVolume = m_dictToEdit->getReal(TheKey_objectSoundAmbientMinVolume, &exists); - } - - if ( exists ) - { - // Note: min volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - CString minVolumeText; - minVolumeText.Format( "%d", REAL_TO_INT( ( minVolume * 100.0f ) + 0.5 ) ); - minVolumeEdit->SetWindowText( minVolumeText ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the minimum volume - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - minVolumeEdit->SetWindowText( "40" ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - minVolumeEdit->SetWindowText( "40" ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - minVolumeEdit->SetWindowText( "40" ); - return; - } - - // Note: min volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - CString minVolumeText; - minVolumeText.Format( "%d", REAL_TO_INT( ( audioEventInfo->m_minVolume * 100.0f ) + 0.5 ) ); - minVolumeEdit->SetWindowText( minVolumeText ); -} - -/// Move data from object to dialog controls -void MapObjectProps::dictToVolume() -{ - CEdit * volumeEdit = ( CEdit * )GetDlgItem(IDC_VOLUME_EDIT); - if ( volumeEdit == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - volumeEdit->EnableWindow( false ); - } - else - { - volumeEdit->EnableWindow( true ); - - // If customization is enabled, look to see if the volume has already been - // customized - Bool exists = false; - Real volume = 0.0f; - if (m_dictToEdit) - { - volume = m_dictToEdit->getReal(TheKey_objectSoundAmbientVolume, &exists); - } - - if ( exists ) - { - // Note: min volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - CString volumeText; - volumeText.Format( "%d", REAL_TO_INT( ( volume * 100.0f ) + 0.5 ) ); - volumeEdit->SetWindowText( volumeText ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the volume - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - volumeEdit->SetWindowText( "100" ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - volumeEdit->SetWindowText( "100" ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - volumeEdit->SetWindowText( "100" ); - return; - } - - // Note: volume is stored as Real between 0.0 and 1.0, but displayed as a percentage from 0 to 100 - CString volumeText; - volumeText.Format( "%d", REAL_TO_INT( ( audioEventInfo->m_volume * 100.0f ) + 0.5 ) ); - volumeEdit->SetWindowText( volumeText ); -} - - -/// Move data from object to dialog controls -void MapObjectProps::dictToMinRange() -{ - CEdit * minRangeEdit = ( CEdit * )GetDlgItem(IDC_MIN_RANGE_EDIT); - if ( minRangeEdit == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - minRangeEdit->EnableWindow( false ); - } - else - { - minRangeEdit->EnableWindow( true ); - - // If customization is enabled, look to see if the minimum range has already been - // customized - Bool exists = false; - Real minRange = 0.0f; - if (m_dictToEdit) - { - minRange = m_dictToEdit->getReal(TheKey_objectSoundAmbientMinRange, &exists); - } - - if ( exists ) - { - CString minRangeText; - minRangeText.Format( "%d", REAL_TO_INT(minRange) ); - minRangeEdit->SetWindowText( minRangeText ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the minimum range - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - minRangeEdit->SetWindowText( "175" ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - minRangeEdit->SetWindowText( "175" ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - minRangeEdit->SetWindowText( "175" ); - return; - } - - CString minRangeText; - minRangeText.Format( "%d", REAL_TO_INT( audioEventInfo->m_minDistance ) ); - minRangeEdit->SetWindowText( minRangeText ); -} - - -/// Move data from object to dialog controls -void MapObjectProps::dictToMaxRange() -{ - CEdit * maxRangeEdit = ( CEdit * )GetDlgItem(IDC_MAX_RANGE_EDIT); - if ( maxRangeEdit == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - maxRangeEdit->EnableWindow( false ); - } - else - { - maxRangeEdit->EnableWindow( true ); - - // If customization is enabled, look to see if the maximum range has already been - // customized - Bool exists = false; - Real maxRange = 0.0f; - if (m_dictToEdit) - { - maxRange = m_dictToEdit->getReal(TheKey_objectSoundAmbientMaxRange, &exists); - } - - if ( exists ) - { - CString maxRangeText; - maxRangeText.Format( "%d", REAL_TO_INT( maxRange ) ); - maxRangeEdit->SetWindowText( maxRangeText ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the minimum range - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - maxRangeEdit->SetWindowText( "600" ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - maxRangeEdit->SetWindowText( "600" ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - maxRangeEdit->SetWindowText( "600" ); - return; - } - - CString maxRangeText; - maxRangeText.Format( "%d", REAL_TO_INT( audioEventInfo->m_maxDistance ) ); - maxRangeEdit->SetWindowText( maxRangeText ); -} - -/// Move data from object to dialog controls -void MapObjectProps::dictToPriority() -{ - CComboBox * priorityComboBox = ( CComboBox * )GetDlgItem(IDC_PRIORITY_COMBO); - if ( priorityComboBox == nullptr ) - return; - - // If the customized checkbox is off, all customization controls are disabled - CButton * customizeCheckbox = ( CButton * )GetDlgItem(IDC_CUSTOMIZE_CHECKBOX); - if ( customizeCheckbox == nullptr || customizeCheckbox->GetCheck() == 0 ) - { - priorityComboBox->EnableWindow( false ); - } - else - { - priorityComboBox->EnableWindow( true ); - - // If customization is enabled, look to see if the maximum range has already been - // customized - Bool exists = false; - Int priorityEnum = AP_LOWEST; - if (m_dictToEdit) - { - priorityEnum = m_dictToEdit->getInt(TheKey_objectSoundAmbientPriority, &exists); - } - - if ( exists ) - { - if ( priorityEnum < 0 || priorityEnum > AP_CRITICAL ) - { - DEBUG_CRASH( ("Bad soundAmbientPriority key %d", priorityEnum ) ); - priorityEnum = AP_LOWEST; - } - - // Note: indexes of priority combobox map to priority enum - priorityComboBox->SetCurSel( priorityEnum ); - - // Don't use defaults, just return - return; - } - } - - // If we get here, we need the default for the priority - CComboBox * soundComboBox = (CComboBox *)GetDlgItem(IDC_SOUND_COMBO); - if ( soundComboBox == nullptr ) - { - priorityComboBox->SetCurSel( AP_LOWEST ); - return; - } - - Int index = soundComboBox->GetCurSel(); - - CString currentString; - soundComboBox->GetLBText( index, currentString ); - if ( currentString == NO_SOUND_STRING || ( index == m_defaultEntryIndex && m_defaultIsNone ) ) - { - priorityComboBox->SetCurSel( AP_LOWEST ); - return; - } - - if ( index == m_defaultEntryIndex ) - { - // Correct the current string e.g. remove "Default <" and ">" - currentString = m_defaultEntryName.str(); - } - - AudioEventInfo * audioEventInfo = TheAudio->findAudioEventInfo(static_cast< const char * >( currentString ) ); - - if ( audioEventInfo == nullptr ) - { - priorityComboBox->SetCurSel( AP_LOWEST ); - return; - } - - priorityComboBox->SetCurSel( audioEventInfo->m_priority ); -} - - -// Special message to handle pages being resized to new sheet size -// see knowledge base article Q143291 -const Int RESIZE_PAGE_MESSAGE = WM_USER + 117; - - -///////////////////////////////////////////////////////////////////////////// -// MapObjectProps message handlers - - - -void MapObjectProps::enableButtons() -{ - // do nothing -} - - -/*static*/ MapObject *MapObjectProps::getSingleSelectedMapObject() -{ - MapObject *pMapObj; - MapObject *theMapObj = nullptr; -// Bool found = false; - Int selCount=0; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->isSelected()) { - if (!pMapObj->isWaypoint() && !pMapObj->isLight()) - { - theMapObj = pMapObj; - } - selCount++; - } - } - if (selCount==1 && theMapObj) { - return theMapObj; - } - return(nullptr); -} - - - - - -void MapObjectProps::OnOK() -{ - // Make sure CPropertySheet functions don't close the window -} - -void MapObjectProps::OnCancel() -{ - // Make sure CPropertySheet functions don't close the window -} - - - -void MapObjectProps::getAllSelectedDicts() -{ - m_allSelectedDicts.clear(); - - for (MapObject *pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - - /* If a bridge exists, and either end is selected, do both ends. */ - if (pMapObj->getFlag(FLAG_BRIDGE_POINT1)) { - MapObject *pMapObj2 = pMapObj->getNext(); - if (pMapObj2 && pMapObj2->getFlag(FLAG_BRIDGE_POINT2)) { - // Got a bridge. - if (pMapObj->isSelected() || pMapObj2->isSelected()) { - m_allSelectedDicts.push_back(pMapObj->getProperties()); - m_allSelectedDicts.push_back(pMapObj2->getProperties()); - pMapObj = pMapObj2; - continue; - } - } - } - - - if (!pMapObj->isSelected() || pMapObj->isWaypoint() || pMapObj->isLight()) { - continue; - } - m_allSelectedDicts.push_back(pMapObj->getProperties()); - m_selectedObject = pMapObj; - } -} - -Dict** MapObjectProps::getAllSelectedDictsData() -{ -#if defined(USING_STLPORT) || __cplusplus < 201103L - return !m_allSelectedDicts.empty() ? &m_allSelectedDicts.front() : nullptr; -#else - return m_allSelectedDicts.data(); -#endif -} - -/// Move data from dialog controls to object -void MapObjectProps::OnScaleOn() -{ - _ScaleToDict(); -} - -/// Move data from dialog controls to object -void MapObjectProps::OnScaleOff() -{ - _ScaleToDict(); -} - -/// Move data from dialog controls to object -void MapObjectProps::OnKillfocusMAPOBJECTXYPosition() -{ - SetPosition(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp deleted file mode 100644 index ec228afedaa..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/playerlistdlg.cpp +++ /dev/null @@ -1,890 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// playerlistdlg.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "playerlistdlg.h" -#include "mapobjectprops.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" -#include "addplayerdialog.h" -#include "Common/WellKnownKeys.h" -#include "Common/PlayerTemplate.h" -#include "Common/MultiplayerSettings.h" -#include "GameLogic/SidesList.h" -#include "GameClient/GameText.h" -#include "Common/UnicodeString.h" - -static const char* NEUTRAL_NAME_STR = "(neutral)"; - -static Int thePrevCurPlyr = 0; - -static Bool islegalplayernamechar(char c) -{ - // note, spaces are NOT allowed. - return ::isalnum(c) || c == '_'; -} - -static void fixDefaultTeamName(SidesList& sides, AsciiString oldpname, AsciiString newpname) -{ - AsciiString tname; - tname.set("team"); - tname.concat(oldpname); - TeamsInfo *ti = sides.findTeamInfo(tname); - if (ti) - { - tname.set("team"); - tname.concat(newpname); - DEBUG_LOG(("rename team %s -> %s",ti->getDict()->getAsciiString(TheKey_teamName).str(),tname.str())); - ti->getDict()->setAsciiString(TheKey_teamName, tname); - ti->getDict()->setAsciiString(TheKey_teamOwner, newpname); - } - else - { - DEBUG_CRASH(("team not found")); - } -} - -static void updateAllTeams(SidesList& sides, AsciiString oldpname, AsciiString newpname) -{ - Int numTeams = sides.getNumTeams(); - for (Int i = 0; i < numTeams; ++i) { - TeamsInfo *teamInfo = sides.getTeamInfo(i); - if (teamInfo) { - Bool exists; - Dict *dict = teamInfo->getDict(); - - AsciiString teamOwner = dict->getAsciiString(TheKey_teamOwner, &exists); - - if (exists && teamOwner.compare(oldpname) == 0) { - dict->setAsciiString(TheKey_teamOwner, newpname); - } - } - } -} - - - -static void ensureValidPlayerName(Dict *d) -{ - // ensure there are no illegal chars in it. (in particular, no spaces!) - char buf[1024]; - strlcpy(buf, d->getAsciiString(TheKey_playerName).str(), ARRAY_SIZE(buf)); - for (char* p = buf; *p; ++p) - if (!islegalplayernamechar(*p)) - *p = '_'; - d->setAsciiString(TheKey_playerName, AsciiString(buf)); -} - -static AsciiString playerNameForUI(SidesList& sides, int i) -{ - AsciiString b = sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - if (b.isEmpty()) - b = NEUTRAL_NAME_STR; - return b; -} - -static AsciiString UIToInternal(SidesList& sides, const AsciiString& n) -{ - Int i; - for (i = 0; i < sides.getNumSides(); i++) - { - if (playerNameForUI(sides, i) == n) - return sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - } - - DEBUG_CRASH(("ui name not found")); - return AsciiString::TheEmptyString; -} - -static Bool containsToken(const AsciiString& cur_allies, const AsciiString& tokenIn) -{ - AsciiString name, token; - - name = cur_allies; - while (name.nextToken(&token)) - { - if (token == tokenIn) - return true; - } - return false; -} - -static AsciiString removeDupsFromEnemies(const AsciiString& cur_allies, const AsciiString& cur_enemies) -{ - AsciiString new_enemies, tmp, token; - - tmp = cur_enemies; - while (tmp.nextToken(&token)) - { - if (containsToken(cur_allies, token)) - continue; - if (!new_enemies.isEmpty()) - new_enemies.concat(" "); - new_enemies.concat(token); - } - return new_enemies; -} - -static AsciiString extractFromAlliesList(CListBox *alliesList, SidesList& sides) -{ - char buffer[1024]; - AsciiString allies; - for (Int i = 0; i < alliesList->GetCount(); i++) - { - if (alliesList->GetSel(i) > 0) - { - alliesList->GetText(i, buffer); - AsciiString nm(buffer); - if (!allies.isEmpty()) - allies.concat(" "); - allies.concat(UIToInternal(sides, nm)); - } - } -//DEBUG_LOG(("a/e is (%s)",allies.str())); - return allies; -} - -static void buildAlliesList(CListBox *alliesList, SidesList& sides, const AsciiString& omitPlayer) -{ - Int i; - AsciiString name, token, oname; - - alliesList->ResetContent(); - for (i = 0; i < sides.getNumSides(); i++) - { - name = sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - if (name == omitPlayer || name.isEmpty()) - continue; - name = playerNameForUI(sides, i); - alliesList->AddString(name.str()); - } -} - -static void selectAlliesList(CListBox *alliesList, SidesList& sides, const AsciiString& cur_allies) -{ - Int oindex_in_list; - AsciiString name, token, oname; - - if (extractFromAlliesList(alliesList, sides) == cur_allies) - return; - - alliesList->SetSel(-1, false); - name = cur_allies; - while (name.nextToken(&token)) - { - Int i; - SidesInfo *si = sides.findSideInfo(token, &i); - if (!si) - { - DEBUG_CRASH(("player %s not found",token.str())); - continue; - } - // must re-find, since list is sorted - oindex_in_list = alliesList->FindStringExact(-1, playerNameForUI(sides, i).str()); - if (oindex_in_list == -1) - { - DEBUG_CRASH(("hmm, should not happen")); - continue; - } - alliesList->SetSel(oindex_in_list, true); - } -} - -// returns a str describing how t1 considers t2. (implies nothing about how t2 considers t1) -static const char* calcRelationStr(SidesList& sides, int t1, int t2) -{ - const char* allied = "Ally"; - const char* enemies = "Enemy"; - const char* neutral = "Neutral"; - - SidesInfo* ti1; - SidesInfo* ti2; - AsciiString t2name; - - - // we use the relationship between our player's default teams. - ti1 = sides.getSideInfo(t1); - ti2 = sides.getSideInfo(t2); - t2name = ti2->getDict()->getAsciiString(TheKey_playerName); - if (containsToken(ti1->getDict()->getAsciiString(TheKey_playerAllies), t2name)) - return allied; - else if (containsToken(ti1->getDict()->getAsciiString(TheKey_playerEnemies), t2name)) - return enemies; - - // no relation, so assume neutral - return neutral; -} - -///////////////////////////////////////////////////////////////////////////// -// PlayerListDlg dialog - - -PlayerListDlg::PlayerListDlg(CWnd* pParent /*=nullptr*/) - : CDialog(PlayerListDlg::IDD, pParent), m_updating(0) -{ - //{{AFX_DATA_INIT(PlayerListDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void PlayerListDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(PlayerListDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(PlayerListDlg, CDialog) - //{{AFX_MSG_MAP(PlayerListDlg) - ON_BN_CLICKED(IDC_NEWPLAYER, OnNewplayer) - ON_BN_CLICKED(IDC_EDITPLAYER, OnEditplayer) - ON_BN_CLICKED(IDC_REMOVEPLAYER, OnRemoveplayer) - ON_LBN_SELCHANGE(IDC_PLAYERS, OnSelchangePlayers) - ON_LBN_DBLCLK(IDC_PLAYERS, OnDblclkPlayers) - ON_LBN_SELCHANGE(IDC_ALLIESLIST, OnSelchangeAllieslist) - ON_LBN_SELCHANGE(IDC_ENEMIESLIST, OnSelchangeEnemieslist) - ON_BN_CLICKED(IDC_PLAYERISCOMPUTER, OnPlayeriscomputer) - ON_CBN_SELENDOK(IDC_PLAYERFACTION, OnEditchangePlayerfaction) - ON_BN_CLICKED(IDC_CHANGE_NAME, OnChangePlayername) - ON_EN_CHANGE(IDC_PLAYERDISPLAYNAME, OnChangePlayerdisplayname) - ON_BN_CLICKED(IDC_PlayerColor, OnColorPress) - ON_CBN_SELENDOK(IDC_PlayerColorCombo, OnSelectPlayerColor) - ON_BN_CLICKED(IDC_ADDSKIRMISHPLAYERS, OnAddskirmishplayers) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - //ON_EN_CHANGE(IDC_PLAYERNAME, OnChangePlayername) - -///////////////////////////////////////////////////////////////////////////// -// PlayerListDlg message handlers - -void PlayerListDlg::OnNewplayer() -{ - if (m_sides.getNumSides() >= MAX_PLAYER_COUNT - 1) ///Added -1 so we can always have an observer even for Single player games. - return; - - AddPlayerDialog addPlyr(""); - if (addPlyr.DoModal() != IDOK) - return; - - AsciiString addedPTName = addPlyr.getAddedSide(); - - AsciiString pname; - UnicodeString pnameu; - Int num = 1; - do { - pname.format("player%04d",num); - pnameu.format(L"Player %04d's Display Name",num); - num++; - } while (m_sides.findSideInfo(pname)); - - Dict newPlayerDict; - newPlayerDict.setAsciiString(TheKey_playerName, pname); - newPlayerDict.setBool(TheKey_playerIsHuman, true); - newPlayerDict.setUnicodeString(TheKey_playerDisplayName, pnameu); - newPlayerDict.setAsciiString(TheKey_playerFaction, addedPTName); - newPlayerDict.setAsciiString(TheKey_playerEnemies, ""); - newPlayerDict.setAsciiString(TheKey_playerAllies, ""); - -#ifdef NOT_IN_USE - // auto-open the advanced prop editor - MapObjectProps editor(&newPlayerDict, "Create New Player", this); - if (editor.DoModal() == IDOK) -#endif - { - if (newPlayerDict.getAsciiString(TheKey_playerName).isEmpty()) - { - // sorry, no more than one neutral - } - else - { - ensureValidPlayerName(&newPlayerDict); - m_sides.addSide(&newPlayerDict); - - Bool modified = m_sides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in PlayerListDlg::OnNewplayer")); - m_curPlayerIdx = m_sides.getNumSides()-1; - updateTheUI(); - } - } -} - -void PlayerListDlg::OnEditplayer() -{ - // TODO: the dialog referenced here has no ok or cancel buttons, so locks the editor - // re-enable this routine once it is not a guaranteed hang - AfxMessageBox("Implement me. (Sorry.)"); - return; - -#if 0 - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - AsciiString pnameold = playerDict->getAsciiString(TheKey_playerName); - Bool isneutral = pnameold.isEmpty(); - if (isneutral) - return; - - Dict playerDictCopy = *playerDict; - MapObjectProps editor(&playerDictCopy, "Edit Player", this); - if (editor.DoModal() == IDOK) - { - ensureValidPlayerName(&playerDictCopy); - - if (playerDict->getAsciiString(TheKey_playerName) != playerDictCopy.getAsciiString(TheKey_playerName)) - { - AsciiString tname; - tname.set("team"); - tname.concat(playerDict->getAsciiString(TheKey_playerName)); - Int count = MapObject::countMapObjectsWithOwner(tname); - if (count > 0) - { - CString msg; - msg.Format(IDS_RENAMING_INUSE_TEAM, count); - if (::AfxMessageBox(msg, MB_YESNO) == IDNO) - return; - } - } - - *m_sides.getSideInfo(m_curPlayerIdx)->getDict() = playerDictCopy; - - AsciiString pnamenew = playerDictCopy.getAsciiString(TheKey_playerName); - fixDefaultTeamName(m_sides, pnameold, pnamenew); - - Bool modified = m_sides.validateSides(); - DEBUG_ASSERTLOG(!modified,("had to clean up sides in PlayerListDlg::OnEditplayer")); - - updateTheUI(); - } -#endif -} - -void PlayerListDlg::OnRemoveplayer() -{ - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - AsciiString pname = playerDict->getAsciiString(TheKey_playerName); - Bool isneutral = pname.isEmpty(); - if (isneutral) - return; - - Int i; - Int count = 0; - for (i = 0; i < m_sides.getNumTeams(); i++) - { - Dict *tdict = m_sides.getTeamInfo(i)->getDict(); - if (tdict->getAsciiString(TheKey_teamOwner) == pname) - { - count += MapObject::countMapObjectsWithOwner(tdict->getAsciiString(TheKey_teamName)); - } - } - - if (count > 0) - { - CString msg; - msg.Format(IDS_REMOVING_INUSE_TEAM, count); - if (::AfxMessageBox(msg, MB_YESNO) == IDNO) - return; - } - - if (m_sides.getNumSides() <= 1) - return; - - m_sides.removeSide(m_curPlayerIdx); -try_again: - for (i = 0; i < m_sides.getNumTeams(); i++) - { - Dict *tdict = m_sides.getTeamInfo(i)->getDict(); - if (tdict->getAsciiString(TheKey_teamOwner) == pname) - { - m_sides.removeTeam(i); - goto try_again; - } - } - - Bool modified = m_sides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in PlayerListDlg::OnRemoveplayer")); - updateTheUI(); -} - -void PlayerListDlg::OnSelchangePlayers() -{ - CListBox *list = (CListBox*)GetDlgItem(IDC_PLAYERS); - m_curPlayerIdx = list->GetCurSel(); - updateTheUI(); -} - -void PlayerListDlg::updateTheUI() -{ - char buffer[1024]; - - if (m_updating) - return; - - ++m_updating; - - // make sure everything is canonical. - Bool modified = m_sides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in PlayerListDlg::updateTheUI! (caller should do this)")); - - if (m_curPlayerIdx < 0) m_curPlayerIdx = 0; - if (m_curPlayerIdx >= m_sides.getNumSides()) - m_curPlayerIdx = m_sides.getNumSides()-1; - - // update player list - CListBox *list = (CListBox*)GetDlgItem(IDC_PLAYERS); - list->ResetContent(); - - Int len = m_sides.getNumSides(); - int i = 0; - for (; i < len; i++) - { - Dict *d = m_sides.getSideInfo(i)->getDict(); - AsciiString name = d->getAsciiString(TheKey_playerName); - UnicodeString uni = d->getUnicodeString(TheKey_playerDisplayName); - AsciiString fmt; - if (name.isEmpty()) - fmt = NEUTRAL_NAME_STR; - else - fmt.format("%s=\"%ls\"",name.str(),uni.str()); - list->AddString(fmt.str()); - } - - Dict *pdict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - AsciiString cur_pname = pdict->getAsciiString(TheKey_playerName); - UnicodeString cur_pdname = pdict->getUnicodeString(TheKey_playerDisplayName); - Bool isNeutral = cur_pname.isEmpty(); - - // update player name - { - CWnd *playername = GetDlgItem(IDC_PLAYERNAME); - playername->EnableWindow(!isNeutral); // neutral names are not editable - playername->GetWindowText(buffer, sizeof(buffer)-2); - if (strcmp(cur_pname.str(), buffer) != 0) - playername->SetWindowText(cur_pname.str()); - } - - // update display name - { - CWnd *playerdname = GetDlgItem(IDC_PLAYERDISPLAYNAME); - playerdname->EnableWindow(!isNeutral); // neutral names are not editable - playerdname->GetWindowText(buffer, sizeof(buffer)-2); - AsciiString cur_pdnamea; - cur_pdnamea.translate(cur_pdname); - if (strcmp(cur_pdnamea.str(), buffer) != 0) - playerdname->SetWindowText(cur_pdnamea.str()); - } - - // update color button - { - RGBColor rgb; - Bool hasColor = false; - Int color = pdict->getInt(TheKey_playerColor, &hasColor); - if (hasColor) { - rgb.setFromInt(color); - } else { - AsciiString tmplname = pdict->getAsciiString(TheKey_playerFaction); - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname)); - if (pt) { - rgb = *pt->getPreferredColor(); - } - } - m_colorButton.setColor(rgb); - SelectColor(rgb); - - } - - // update control button - { - Bool isHuman = pdict->getBool(TheKey_playerIsHuman); - CButton *controller = (CButton*)GetDlgItem(IDC_PLAYERISCOMPUTER); - controller->SetCheck(isHuman ? 0 : 1); - controller->EnableWindow(!isNeutral); - } - - // update factions popup - { - CComboBox *factions = (CComboBox*)GetDlgItem(IDC_PLAYERFACTION); - factions->ResetContent(); - if (ThePlayerTemplateStore) - { - for (i = 0; i < ThePlayerTemplateStore->getPlayerTemplateCount(); i++) - { - AsciiString nm = ThePlayerTemplateStore->getNthPlayerTemplate(i)->getName(); - factions->AddString(nm.str()); - } - } - i = factions->FindStringExact(-1, pdict->getAsciiString(TheKey_playerFaction).str()); - factions->SetCurSel(i); - } - - // update allies & enemies - CListBox *allieslist = (CListBox*)GetDlgItem(IDC_ALLIESLIST); - CListBox *enemieslist = (CListBox*)GetDlgItem(IDC_ENEMIESLIST); - CListBox *regardOthers = (CListBox*)GetDlgItem(IDC_PLAYER_ATTITUDE_OUT); - CListBox *regardMe = (CListBox*)GetDlgItem(IDC_PLAYER_ATTITUDE_IN); - - AsciiString cur_allies = m_sides.getSideInfo(m_curPlayerIdx)->getDict()->getAsciiString(TheKey_playerAllies); - buildAlliesList(allieslist, m_sides, cur_pname); - selectAlliesList(allieslist, m_sides, cur_allies); - allieslist->EnableWindow(!isNeutral); - - AsciiString cur_enemies = m_sides.getSideInfo(m_curPlayerIdx)->getDict()->getAsciiString(TheKey_playerEnemies); - buildAlliesList(enemieslist, m_sides, cur_pname); - selectAlliesList(enemieslist, m_sides, cur_enemies); - enemieslist->EnableWindow(!isNeutral); - - regardOthers->ResetContent(); - regardMe->ResetContent(); - const char* rstr; - AsciiString pname; - for (i = 0; i < m_sides.getNumSides(); i++) - { - pname = m_sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - if (pname.isEmpty() || pname == cur_pname) - continue; // skip neutral and self - pname = playerNameForUI(m_sides, i); - - rstr = calcRelationStr(m_sides, m_curPlayerIdx, i); - snprintf(buffer, ARRAY_SIZE(buffer), "%s: %s",pname.str(),rstr); - regardOthers->AddString(buffer); - - rstr = calcRelationStr(m_sides, i, m_curPlayerIdx); - snprintf(buffer, ARRAY_SIZE(buffer), "%s: %s",pname.str(),rstr); - regardMe->AddString(buffer); - } - - list->SetCurSel(m_curPlayerIdx); - - CWnd *newbtn = GetDlgItem(IDC_NEWPLAYER); - CWnd *editbtn = GetDlgItem(IDC_EDITPLAYER); - CWnd *rmvbtn = GetDlgItem(IDC_REMOVEPLAYER); - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - Bool isneutral = playerDict->getAsciiString(TheKey_playerName).isEmpty(); - if( newbtn ) - newbtn->EnableWindow(m_sides.getNumSides() < MAX_PLAYER_COUNT); - if( editbtn ) - editbtn->EnableWindow(!isneutral); - if( rmvbtn ) - rmvbtn->EnableWindow(m_sides.getNumSides() > 1 && !isneutral); - - Invalidate(); - UpdateWindow(); - - --m_updating; -} - - -BOOL PlayerListDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_updating = 0; - m_sides = *TheSidesList; - m_curPlayerIdx = thePrevCurPlyr; - - CRect rect; - CWnd *item = GetDlgItem(IDC_PlayerColor); - if (item) { - item->GetWindowRect(&rect); - ScreenToClient(&rect); - DWORD style = item->GetStyle(); - m_colorButton.Create("", style, rect, this, IDC_PlayerColor); - item->DestroyWindow(); - } - - updateTheUI(); - PopulateColorComboBox(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void PlayerListDlg::OnDblclkPlayers() -{ - OnEditplayer(); -} - -void PlayerListDlg::OnColorPress() -{ - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - CColorDialog dlg; - if (dlg.DoModal() == IDOK) { - m_colorButton.setColor(CButtonShowColor::BGRtoRGB(dlg.GetColor())); - RGBColor color = m_colorButton.getColor(); - playerDict->setInt(TheKey_playerColor, color.getAsInt()); - } - updateTheUI(); -} - -void PlayerListDlg::PopulateColorComboBox() -{ - Int numColors = TheMultiplayerSettings->getNumColors(); - AsciiString colorName; - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_PlayerColorCombo); - if (pCombo) { - for (Int c=0; cgetColor(c); - if (!def) - continue; - UnicodeString colorName = TheGameText->fetch(def->getTooltipName().str()); - AsciiString str; - str.translate(colorName); - pCombo->AddString(str.str()); - } - } -} - -void PlayerListDlg::SelectColor(RGBColor rgb) -{ - Int numColors = TheMultiplayerSettings->getNumColors(); - AsciiString colorName; - Bool selected = false; - - CComboBox *pCombo = (CComboBox*)GetDlgItem(IDC_PlayerColorCombo); - if (pCombo) { - for (Int c=0; cgetColor(c); - if (!def) - continue; - if (rgb.getAsInt() == def->getRGBValue().getAsInt()) { - pCombo->SetCurSel(c); - selected = true; - break; - } - } - if (!selected) { - pCombo->SetCurSel(-1); - } - } -} - -void PlayerListDlg::OnSelectPlayerColor() -{ - CComboBox *pCombo = (CComboBox *)GetDlgItem(IDC_PlayerColorCombo); - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - if (pCombo && playerDict) { - CString str; - pCombo->GetWindowText(str); - Int index = -1; - Int numColors = TheMultiplayerSettings->getNumColors(); - Int c=0; - for (; cgetColor(c); - if (!def) - continue; - UnicodeString colorName = TheGameText->fetch(def->getTooltipName().str()); - AsciiString asciiColor; - asciiColor.translate(colorName); - - if (str == asciiColor.str()) { - index = c; - break; - } - } - if (index >= 0) { - Int color = TheMultiplayerSettings->getColor(c)->getColor(); - playerDict->setInt(TheKey_playerColor, color); - } - } - updateTheUI(); -} - -void PlayerListDlg::OnSelchangeAllieslist() -{ - Dict *playerDict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - AsciiString pname = playerDict->getAsciiString(TheKey_playerName); - Bool isneutral = pname.isEmpty(); - if (isneutral) - return; - - CListBox *allieslist = (CListBox*)GetDlgItem(IDC_ALLIESLIST); - AsciiString allies = extractFromAlliesList(allieslist, m_sides); - - CListBox *enemieslist = (CListBox*)GetDlgItem(IDC_ENEMIESLIST); - AsciiString enemies = extractFromAlliesList(enemieslist, m_sides); - - enemies = removeDupsFromEnemies(allies, enemies); - - m_sides.getSideInfo(m_curPlayerIdx)->getDict()->setAsciiString(TheKey_playerAllies, allies); - m_sides.getSideInfo(m_curPlayerIdx)->getDict()->setAsciiString(TheKey_playerEnemies, enemies); - - updateTheUI(); -} - -void PlayerListDlg::OnSelchangeEnemieslist() -{ - OnSelchangeAllieslist(); -} - -void PlayerListDlg::OnOK() -{ - Bool modified = m_sides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in CTeamsDialog::OnOK")); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(m_sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - thePrevCurPlyr = m_curPlayerIdx; - - CDialog::OnOK(); -} - -void PlayerListDlg::OnCancel() -{ - CDialog::OnCancel(); -} - -void PlayerListDlg::OnPlayeriscomputer() -{ - CButton *b = (CButton*)GetDlgItem(IDC_PLAYERISCOMPUTER); - m_sides.getSideInfo(m_curPlayerIdx)->getDict()->setBool(TheKey_playerIsHuman, b->GetCheck() == 0); - - updateTheUI(); -} - -void PlayerListDlg::OnEditchangePlayerfaction() -{ - CComboBox *faction = (CComboBox*)GetDlgItem(IDC_PLAYERFACTION); - - if (faction) { - // get the text out of the combo. If it is user-typed, sel will be -1, otherwise it will be >=0 - CString theText; - Int sel = faction->GetCurSel(); - if (sel >= 0) { - faction->GetLBText(sel, theText); - } else { - faction->GetWindowText(theText); - } - AsciiString name((LPCTSTR)theText); - - Dict *pdict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - pdict->setAsciiString(TheKey_playerFaction, name); - - updateTheUI(); - } -} - -void PlayerListDlg::OnChangePlayername() -{ - CWnd *playername = GetDlgItem(IDC_PLAYERNAME); - char buf[1024]; - playername->GetWindowText(buf, sizeof(buf)-2); - - Dict *pdict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - AsciiString pnamenew(buf); - AsciiString pnameold = pdict->getAsciiString(TheKey_playerName); - - if (pnameold == pnamenew) - return; // hmm, no change, so just punt. - - if (m_sides.findSideInfo(pnamenew)) - { - ::AfxMessageBox(IDS_NAME_IN_USE); - } - else - { - pdict->setAsciiString(TheKey_playerName, pnamenew); - ensureValidPlayerName(pdict); - - updateAllTeams(m_sides, pnameold, pnamenew); - fixDefaultTeamName(m_sides, pnameold, pnamenew); - } - - updateTheUI(); -} - -void PlayerListDlg::OnChangePlayerdisplayname() -{ - CWnd *playername = GetDlgItem(IDC_PLAYERDISPLAYNAME); - char buf[1024]; - playername->GetWindowText(buf, sizeof(buf)-2); - - Dict *pdict = m_sides.getSideInfo(m_curPlayerIdx)->getDict(); - - AsciiString tmp(buf); - UnicodeString pnamenew; - pnamenew.translate(tmp); - UnicodeString pnameold = pdict->getUnicodeString(TheKey_playerDisplayName); - - if (pnameold == pnamenew) - return; // hmm, no change, so just punt. - - pdict->setUnicodeString(TheKey_playerDisplayName, pnamenew); - - updateTheUI(); -} - -static void addSide(SidesList *sides, AsciiString faction, - AsciiString playerName, const wchar_t *playerUName) -{ - if (!sides->findSideInfo(playerName)) { - - Dict newPlayerDict; - UnicodeString playerUStr; - playerUStr = playerUName; - newPlayerDict.setAsciiString(TheKey_playerName, playerName); - newPlayerDict.setBool(TheKey_playerIsHuman, false); - newPlayerDict.setUnicodeString(TheKey_playerDisplayName, playerUStr); - newPlayerDict.setAsciiString(TheKey_playerFaction, faction); - newPlayerDict.setAsciiString(TheKey_playerEnemies, ""); - newPlayerDict.setAsciiString(TheKey_playerAllies, ""); - - ensureValidPlayerName(&newPlayerDict); - sides->addSide(&newPlayerDict); - - Bool modified = sides->validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in PlayerListDlg::OnNewplayer")); - } -} - -void PlayerListDlg::OnAddskirmishplayers() -{ - // PlyrCivilian - - addSide(&m_sides, "FactionCivilian", "PlyrCivilian", L"PlyrCivilian"); - addSide(&m_sides, "FactionAmerica", "SkirmishAmerica", L"SkirmishAmerica"); - addSide(&m_sides, "FactionChina", "SkirmishChina", L"SkirmishChina"); - addSide(&m_sides, "FactionGLA", "SkirmishGLA", L"SkirmishGLA"); - - addSide(&m_sides, "FactionAmericaAirForceGeneral", "SkirmishAmericaAirForceGeneral", L"SkirmishAmericaAirForceGeneral"); - addSide(&m_sides, "FactionAmericaLaserGeneral", "SkirmishAmericaLaserGeneral", L"SkirmishAmericaLaserGeneral"); - addSide(&m_sides, "FactionAmericaSuperWeaponGeneral", "SkirmishAmericaSuperWeaponGeneral", L"SkirmishAmericaSuperWeaponGeneral"); - addSide(&m_sides, "FactionChinaTankGeneral", "SkirmishChinaTankGeneral", L"SkirmishChinaTankGeneral"); - addSide(&m_sides, "FactionChinaNukeGeneral", "SkirmishChinaNukeGeneral", L"SkirmishChinaNukeGeneral"); - addSide(&m_sides, "FactionChinaInfantryGeneral", "SkirmishChinaInfantryGeneral", L"SkirmishChinaInfantryGeneral"); - addSide(&m_sides, "FactionGLADemolitionGeneral", "SkirmishGLADemolitionGeneral", L"SkirmishGLADemolitionGeneral"); - addSide(&m_sides, "FactionGLAToxinGeneral", "SkirmishGLAToxinGeneral", L"SkirmishGLAToxinGeneral"); - addSide(&m_sides, "FactionGLAStealthGeneral", "SkirmishGLAStealthGeneral", L"SkirmishGLAStealthGeneral"); - updateTheUI(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/propedit.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/propedit.cpp deleted file mode 100644 index 266f0b48c33..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/propedit.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// propedit.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "../include/propedit.h" - -///////////////////////////////////////////////////////////////////////////// -// PropEdit dialog - -#define NO_RESTRICT_KEYS - -PropEdit::PropEdit(AsciiString* key, Dict::DataType* type, AsciiString* value, Bool valueOnly, CWnd *parent) - : CDialog(PropEdit::IDD, parent), m_key(key), m_type(type), m_value(value), m_updating(0), m_valueOnly(valueOnly) -{ - //{{AFX_DATA_INIT(PropEdit) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void PropEdit::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(PropEdit) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(PropEdit, CDialog) - //{{AFX_MSG_MAP(PropEdit) - ON_EN_CHANGE(IDC_KEYNAME, OnChangeKeyname) - ON_CBN_EDITCHANGE(IDC_KEYTYPE, OnEditchangeKeytype) - ON_CBN_CLOSEUP(IDC_KEYTYPE, OnCloseupKeytype) - ON_CBN_SELCHANGE(IDC_KEYTYPE, OnSelchangeKeytype) - ON_EN_CHANGE(IDC_VALUE, OnChangeValue) - ON_BN_CLICKED(IDC_PROPBOOL, OnPropbool) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void PropEdit::validate() -{ - if (m_updating > 0) - return; - - Bool enabOK = true; - CWnd *ok = GetDlgItem(IDOK); - CWnd *keyname = GetDlgItem(IDC_KEYNAME); - CWnd *valuename = GetDlgItem(IDC_VALUE); - CComboBox *keytype = (CComboBox*)GetDlgItem(IDC_KEYTYPE); - CButton *valuebool = (CButton*)GetDlgItem(IDC_PROPBOOL); - *m_type = (Dict::DataType)keytype->GetCurSel(); - - valuename->ShowWindow(*m_type != Dict::DICT_BOOL ? SW_SHOW : SW_HIDE); - valuebool->ShowWindow(*m_type == Dict::DICT_BOOL ? SW_SHOW : SW_HIDE); - - keyname->EnableWindow(!m_valueOnly); - keytype->EnableWindow(!m_valueOnly); - - CString tmp; - - keyname->GetWindowText(tmp); -#ifdef RESTRICT_KEYS - tmp.MakeLower(); // we force user-entered keys to all-lowercase, to prevent case issues -#endif - *m_key = (LPCTSTR)tmp; - - if (!m_valueOnly) - { - int len = tmp.GetLength(); - if (len <= 0) - enabOK = false; - -#ifdef RESTRICT_KEYS - // only letters, numbers, and underline allowed - for (int i = 0; i < len; i++) - if (!isalnum(tmp[i]) && tmp[i] != '_') - enabOK = false; -#endif - } - - valuename->GetWindowText(tmp); - *m_value = (LPCTSTR)tmp; - switch (*m_type) - { - case Dict::DICT_BOOL: - *m_value = valuebool->GetCheck() ? "true" : "false"; - break; - case Dict::DICT_INT: - break; - case Dict::DICT_REAL: - break; - case Dict::DICT_ASCIISTRING: - break; - case Dict::DICT_UNICODESTRING: - break; - default: - enabOK = false; - break; - } - - ok->EnableWindow(enabOK); -} - -///////////////////////////////////////////////////////////////////////////// -// PropEdit message handlers - -void PropEdit::OnChangeKeyname() -{ - validate(); -} - -void PropEdit::OnEditchangeKeytype() -{ - validate(); -} - -void PropEdit::OnCloseupKeytype() -{ - validate(); -} - -void PropEdit::OnSelchangeKeytype() -{ - validate(); -} - -void PropEdit::OnChangeValue() -{ - validate(); -} - - -BOOL PropEdit::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CWnd *keyname = GetDlgItem(IDC_KEYNAME); - CWnd *valuename = GetDlgItem(IDC_VALUE); - CComboBox *keytype = (CComboBox*)GetDlgItem(IDC_KEYTYPE); - CButton *valuebool = (CButton*)GetDlgItem(IDC_PROPBOOL); - - ++m_updating; - keytype->SetCurSel((Int)*m_type); - keyname->SetWindowText(m_key->str()); - valuename->SetWindowText(m_value->str()); - valuebool->SetCheck(strcmp(m_value->str(), "true")==0 ? 1 : 0); - --m_updating; - validate(); - - return TRUE; // return TRUE unless you set the focus to a control -} - -void PropEdit::OnPropbool() -{ - validate(); -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/teamsdialog.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/teamsdialog.cpp deleted file mode 100644 index f8e2189b643..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/teamsdialog.cpp +++ /dev/null @@ -1,643 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// teamsdialog.cpp : implementation file -// - -#include "StdAfx.h" -#include "WorldBuilder.h" -#include "teamsdialog.h" -#include "CFixTeamOwnerDialog.h" - -#include "Common/WellKnownKeys.h" -#include "GameLogic/SidesList.h" -#include "TeamBehavior.h" -#include "TeamGeneric.h" -#include "TeamIdentity.h" -#include "TeamReinforcement.h" -#include "TeamObjectProperties.h" -#include "WorldBuilderDoc.h" -#include "CUndoable.h" -#include "wbview3d.h" - -static Int thePrevCurTeam = 0; - -static const char* NEUTRAL_NAME_STR = "(neutral)"; - -///////////////////////////////////////////////////////////////////////////// -// CTeamsDialog dialog - - -CTeamsDialog::CTeamsDialog(CWnd* pParent /*=nullptr*/) - : CDialog(CTeamsDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(CTeamsDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void CTeamsDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CTeamsDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CTeamsDialog, CDialog) - //{{AFX_MSG_MAP(CTeamsDialog) - ON_BN_CLICKED(IDC_NEWTEAM, OnNewteam) - ON_BN_CLICKED(IDC_DELETETEAM, OnDeleteteam) - ON_LBN_SELCHANGE(IDC_PLAYER_LIST, OnSelchangePlayerList) - ON_NOTIFY(NM_CLICK, IDC_TEAMS_LIST, OnClickTeamsList) - ON_NOTIFY(NM_DBLCLK, IDC_TEAMS_LIST, OnDblclkTeamsList) - ON_BN_CLICKED(IDC_COPYTEAM, OnCopyteam) - ON_BN_CLICKED(IDC_SelectTeamMembers, OnSelectTeamMembers) - ON_BN_CLICKED(IDC_MOVEDOWNTEAM, OnMoveDownTeam) - ON_BN_CLICKED(IDC_MOVEUPTEAM, OnMoveUpTeam) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTeamsDialog message handlers - -static Bool isPlayerDefaultTeamIndex(SidesList& sides, Int i) -{ - return sides.isPlayerDefaultTeam(sides.getTeamInfo(i)); -} - -static AsciiString playerNameForUI(SidesList& sides, int i) -{ - AsciiString b = sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - if (b.isEmpty()) - b = NEUTRAL_NAME_STR; - return b; -} - -static AsciiString teamNameForUI(SidesList& sides, int i) -{ - TeamsInfo *ti = sides.getTeamInfo(i); - if (sides.isPlayerDefaultTeam(ti)) - { - AsciiString ostr = ti->getDict()->getAsciiString(TheKey_teamOwner); - if (ostr.isEmpty()) - ostr = NEUTRAL_NAME_STR; - AsciiString n; - n.format("(default team)"); - return n; - } - - return ti->getDict()->getAsciiString(TheKey_teamName); -} - -static AsciiString UIToInternal(SidesList& sides, const AsciiString& n) -{ - Int i; - for (i = 0; i < sides.getNumSides(); i++) - { - if (playerNameForUI(sides, i) == n) - return sides.getSideInfo(i)->getDict()->getAsciiString(TheKey_playerName); - } - - DEBUG_CRASH(("ui name not found")); - return AsciiString::TheEmptyString; -} - -static Int findTeamParentIndex(SidesList& sides, Int i) -{ - AsciiString oname = sides.getTeamInfo(i)->getDict()->getAsciiString(TheKey_teamOwner); - - for (int j = 0; j < sides.getNumSides(); j++) - { - if (oname == sides.getSideInfo(j)->getDict()->getAsciiString(TheKey_playerName)) - { - return -(j+1); - } - } - DEBUG_CRASH(("hmm")); - return 0; -} - -void CTeamsDialog::updateUI(Int whatToRebuild) -{ - if (m_updating) - return; - - ++m_updating; - - // make sure everything is canonical. - Bool modified = m_sides.validateSides(); - DEBUG_ASSERTLOG(!modified,("had to clean up sides in CTeamsDialog::updateUI! (caller should do this)")); - if (modified) - { - whatToRebuild = REBUILD_ALL; // assume the worst. - } - - // constrain team index. - if (m_curTeam < 0) m_curTeam = 0; - if (m_curTeam >= m_sides.getNumTeams()) - m_curTeam = m_sides.getNumTeams()-1; - - if (whatToRebuild & REBUILD_TEAMS) - { - UpdateTeamsList(); - } - - Bool isDefault = true; - - if (m_curTeam >= 0) { - isDefault = isPlayerDefaultTeamIndex(m_sides, m_curTeam); - } - - // update delete button - CButton *del = (CButton*)GetDlgItem(IDC_DELETETEAM); - del->EnableWindow(!isDefault); // toplevel team names are delete-able, but "default" teams are not - CButton *copyteam = (CButton*)GetDlgItem(IDC_COPYTEAM); - copyteam->EnableWindow(!isDefault); // toplevel team names are delete-able, but "default" teams are not - - //update move up and move down buttons - CButton *moveup = (CButton*)GetDlgItem(IDC_MOVEUPTEAM); - moveup->EnableWindow(!isDefault); - CButton *movedown = (CButton*)GetDlgItem(IDC_MOVEDOWNTEAM); - movedown->EnableWindow(!isDefault); - - CListBox *players = (CListBox*)GetDlgItem(IDC_PLAYER_LIST); - Int whichPlayer = players->GetCurSel(); - - CButton *newteam = (CButton*)GetDlgItem(IDC_NEWTEAM); - newteam->EnableWindow(whichPlayer>0); // toplevel team names are delete-able, but "default" teams are not - - - --m_updating; -} - -BOOL CTeamsDialog::OnInitDialog() -{ - CRect rect; - - CDialog::OnInitDialog(); - - // default values for our vars - m_updating = 0; - m_sides = *TheSidesList; - m_curTeam = thePrevCurTeam; - - CListCtrl *pList = (CListCtrl *)GetDlgItem(IDC_TEAMS_LIST); - pList->InsertColumn(0, "Team Name", LVCFMT_LEFT, 150, 0); - pList->InsertColumn(1, "Origin", LVCFMT_LEFT, 150, 1); - pList->InsertColumn(2, "Priority", LVCFMT_LEFT, 50, 2); - pList->InsertColumn(3, "Script", LVCFMT_LEFT, 150, 3); - pList->InsertColumn(4, "Trigger", LVCFMT_LEFT, 150, 4); - - - CListBox *players = (CListBox*)GetDlgItem(IDC_PLAYER_LIST); - players->ResetContent(); - for (int i = 0; i < m_sides.getNumSides(); i++) - { - players->AddString(playerNameForUI(m_sides, i).str()); - } - - validateTeamOwners(); - - updateUI(REBUILD_ALL); - - return TRUE; -} - -void CTeamsDialog::OnOK() -{ - Bool modified = m_sides.validateSides(); - (void)modified; - DEBUG_ASSERTLOG(!modified,("had to clean up sides in CTeamsDialog::OnOK")); - - CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc(); - SidesListUndoable *pUndo = new SidesListUndoable(m_sides, pDoc); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - - thePrevCurTeam = m_curTeam; - - CDialog::OnOK(); -} - -void CTeamsDialog::OnCancel() -{ - CDialog::OnCancel(); -} - -void CTeamsDialog::OnNewteam() -{ - Int num = 1; - AsciiString tname; - do - { - tname.format("team%04d",num++); - } - while (m_sides.findTeamInfo(tname)); - - AsciiString oname = m_sides.getTeamInfo(m_curTeam)->getDict()->getAsciiString(TheKey_teamOwner); - - Dict d; - d.setAsciiString(TheKey_teamName, tname); - d.setAsciiString(TheKey_teamOwner, oname); // owned by the parent of whatever is selected. - d.setBool(TheKey_teamIsSingleton, false); - - m_sides.addTeam(&d); - Int i; - if (m_sides.findTeamInfo(tname, &i)) { - m_curTeam = i; - OnEditTemplate(); - } - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::OnDeleteteam() -{ - if (m_curTeam < 0) - return; - - Bool isDefault = isPlayerDefaultTeamIndex(m_sides, m_curTeam); - if (isDefault) - { - DEBUG_CRASH(("should not be allowed")); - return; - } - - AsciiString tname = m_sides.getTeamInfo(m_curTeam)->getDict()->getAsciiString(TheKey_teamName); - Int count = MapObject::countMapObjectsWithOwner(tname); - if (count > 0) - { - CString msg; - msg.Format(IDS_REMOVING_INUSE_TEAM, count); - if (::AfxMessageBox(msg, MB_YESNO) == IDNO) - return; - } - - m_sides.removeTeam(m_curTeam); - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::OnEditTemplate() -{ - CPropertySheet editDialog; - editDialog.Construct("Edit Team Template."); - TeamIdentity identity; - identity.setTeamDict(m_sides.getTeamInfo(m_curTeam)->getDict()); - identity.setSidesList(&m_sides); - TeamReinforcement reinforcements; - reinforcements.setTeamDict(m_sides.getTeamInfo(m_curTeam)->getDict()); - TeamBehavior behavior; - behavior.setTeamDict(m_sides.getTeamInfo(m_curTeam)->getDict()); - - TeamGeneric generic; - generic.setTeamDict(m_sides.getTeamInfo(m_curTeam)->getDict()); - - TeamObjectProperties object(m_sides.getTeamInfo(m_curTeam)->getDict()); - - editDialog.AddPage(&identity); - editDialog.AddPage(&reinforcements); - editDialog.AddPage(&behavior); - editDialog.AddPage(&generic); - editDialog.AddPage(&object); - - if (IDOK == editDialog.DoModal()) { - } - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::UpdateTeamsList() -{ - CListCtrl *pList = (CListCtrl *)GetDlgItem(IDC_TEAMS_LIST); - pList->DeleteAllItems(); - CListBox *players = (CListBox*)GetDlgItem(IDC_PLAYER_LIST); - - Int which = players->GetCurSel(); - if (which < 0) - return; - - Int numTeams = m_sides.getNumTeams(); - Bool selected = false; - Int inserted = 0; - - for (Int i=0; igetDict()->getAsciiString(TheKey_teamOwner) == playerNameForUI(m_sides, which).str()) - { - Bool exists; - AsciiString teamName = teamNameForUI(m_sides, i); - AsciiString waypoint = ti->getDict()->getAsciiString(TheKey_teamHome, &exists); - AsciiString script = ti->getDict()->getAsciiString(TheKey_teamOnCreateScript, &exists); - CString pri; - pri.Format(TEXT("%d"), ti->getDict()->getInt(TheKey_teamProductionPriority, &exists)); - AsciiString trigger = ti->getDict()->getAsciiString(TheKey_teamProductionCondition, &exists); - - pList->InsertItem(LVIF_TEXT, inserted, teamName.str(), 0, 0, 0, 0); - pList->SetItemText(inserted, 1, waypoint.str()); - pList->SetItemText(inserted, 2, pri); - pList->SetItemText(inserted, 3, script.str()); - pList->SetItemText(inserted, 4, trigger.str()); - - pList->SetItemData(inserted, i); - if (m_curTeam == i) { - selected = true; - pList->SetItemState(inserted, LVIS_SELECTED, LVIS_SELECTED); - pList->EnsureVisible(inserted, false); - } - inserted++; - } - } - if (!selected) { - m_curTeam = -1; - if (inserted > 0) { - m_curTeam = pList->GetItemData(0); - pList->SetItemState(0, LVIS_SELECTED, LVIS_SELECTED); - pList->EnsureVisible(0, false); - } - } -} - -void CTeamsDialog::OnSelchangePlayerList() -{ - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::OnClickTeamsList(NMHDR* pNMHDR, LRESULT* pResult) -{ - CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_TEAMS_LIST); - - int nItem = pList->GetNextItem(-1, LVNI_SELECTED); - if (nItem >= 0) - { - m_curTeam = pList->GetItemData(nItem); - pList->SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED); - } - updateUI(REBUILD_ALL); - - *pResult = 0; -} - -void CTeamsDialog::OnDblclkTeamsList(NMHDR* pNMHDR, LRESULT* pResult) -{ - CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_TEAMS_LIST); - - int nItem = pList->GetNextItem(-1, LVNI_SELECTED); - if (nItem >= 0) - { - m_curTeam = pList->GetItemData(nItem); - } - if (m_curTeam >= 0 && !isPlayerDefaultTeamIndex(m_sides, m_curTeam)) { - OnEditTemplate(); - } - - *pResult = 0; -} - -void CTeamsDialog::OnCopyteam() -{ - Dict d = *m_sides.getTeamInfo(m_curTeam)->getDict(); - AsciiString origName = d.getAsciiString(TheKey_teamName); - - Int num = 1; - AsciiString tname; - do - { - tname.format("%s.%2d",origName.str(), num++); - } - while (m_sides.findTeamInfo(tname)); - - d.setAsciiString(TheKey_teamName, tname); - m_sides.addTeam(&d); - - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::OnSelectTeamMembers() -{ - Int count = 0; - Dict d = *m_sides.getTeamInfo(m_curTeam)->getDict(); - AsciiString teamName = d.getAsciiString(TheKey_teamName); - Coord3D pos; - MapObject *pObj; - for (pObj=MapObject::getFirstMapObject(); pObj; pObj=pObj->getNext()) { - pObj->setSelected(false); - AsciiString objectsTeam = pObj->getProperties()->getAsciiString(TheKey_originalOwner); - if (teamName==objectsTeam) { - pObj->setSelected(true); - pos = *pObj->getLocation(); - count++; - } - } - CString info; - info.Format(IDS_NUM_SELECTED_ON_TEAM, teamName.str(), count); - if (count>0) { - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - WbView3d *p3View = pDoc->GetActive3DView(); - if (p3View) { - p3View->setCenterInView(pos.x/MAP_XY_FACTOR, pos.y/MAP_XY_FACTOR); - } - } - } - ::AfxMessageBox(info, MB_OK); -} - -/** This function moves a team up the list in the teams list dialog */ -void CTeamsDialog::OnMoveUpTeam() -{ - // don't move up if already at top of list - if (m_curTeam <= 1) - return; - - Dict temp, current; - int startRemove; - int totalTeams = m_sides.getNumTeams(); - - // iterates through all modified entries in the teams list - for (int i=m_curTeam-1; igetDict(); - m_sides.removeTeam(i); - startRemove = i; - } - - /* saves the selected item, deletes from the list, then adds it - to the bottom of the list -- then adds the saved "temp" item - to the bottom of the list */ - else if (i == m_curTeam) { - current = *m_sides.getTeamInfo(startRemove)->getDict(); - m_sides.removeTeam(startRemove); - m_sides.addTeam(¤t); - m_sides.addTeam(&temp); - } - - /* saves each following item, deletes from the list, and then - adds it to the bottom of the list */ - else if (i > m_curTeam) { - current = *m_sides.getTeamInfo(startRemove)->getDict(); - m_sides.removeTeam(startRemove); - m_sides.addTeam(¤t); - } - } - - // modify cursor - m_curTeam--; - - // rebuild user interface to reflect changes -/* - LVITEM *pItem = nullptr; - CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_TEAMS_LIST); - Bool result = pList->GetItem(pItem); - pList->DeleteItem(m_curTeam); - pList->InsertItem(pItem); - for (i=0; iUpdate(i); - pList->SetItemState(m_curTeam, LVIS_SELECTED, LVIS_SELECTED); -*/ - updateUI(REBUILD_ALL); -} - -/// This function moves a team down the list in the teams list dialog -void CTeamsDialog::OnMoveDownTeam() -{ - // don't move down if already at bottom of list - if (m_curTeam >= m_sides.getNumTeams()-1) - return; - - Dict temp, current; - int startRemove; - int totalTeams = m_sides.getNumTeams(); - - // iterates through all modified entries in the teams list - for (int i=m_curTeam; igetDict(); - m_sides.removeTeam(i); - startRemove = i; - } - - /* saves the one right after the selected item, deletes it from the list, - then adds it to the bottom of the list -- then adds the saved "temp" item - to the bottom of the list */ - else if (i == (m_curTeam+1)) { - current = *m_sides.getTeamInfo(startRemove)->getDict(); - m_sides.removeTeam(startRemove); - m_sides.addTeam(¤t); - m_sides.addTeam(&temp); - } - - /* saves each following item, deletes from the list, and then - adds it to the bottom of the list */ - else if (i > m_curTeam+1) { - current = *m_sides.getTeamInfo(startRemove)->getDict(); - m_sides.removeTeam(startRemove); - m_sides.addTeam(¤t); - } - } - - // modify cursor - m_curTeam++; - - // rebuild user interface to reflect changes -/* LVITEM *pItem = nullptr; - CListCtrl* pList = (CListCtrl*) GetDlgItem(IDC_TEAMS_LIST); - Bool result = pList->GetItem(pItem); - pList->DeleteItem(m_curTeam); - pList->InsertItem(pItem); - for (i=0; iUpdate(i); - pList->SetItemState(m_curTeam, LVIS_SELECTED, LVIS_SELECTED); -*/ - updateUI(REBUILD_ALL); -} - -void CTeamsDialog::validateTeamOwners() -{ - Int numTeams = m_sides.getNumTeams(); - for (Int i = 0; i < numTeams; ++i) { - TeamsInfo *ti = m_sides.getTeamInfo(i); - if (!ti) { - continue; - } - - Bool exists; - AsciiString owner = ti->getDict()->getAsciiString(TheKey_teamOwner, &exists); - - if (exists) { - if (isValidTeamOwner(owner)) { - continue; - } - } - - doCorrectTeamOwnerDialog(ti); - } - -} - -Bool CTeamsDialog::isValidTeamOwner( AsciiString ownerName ) -{ - Int numOwners = m_sides.getNumSides(); - for (Int i = 0; i < numOwners; ++i) { - SidesInfo *side = m_sides.getSideInfo(i); - if (!side) { - continue; - } - - Bool exists; - AsciiString sideOwnerName = side->getDict()->getAsciiString(TheKey_playerName, &exists); - - if (!exists) { - continue; - } - - if (ownerName == sideOwnerName) { - return true; - } - - if (sideOwnerName.isEmpty()) { - sideOwnerName = NEUTRAL_NAME_STR; - } - - if (ownerName == sideOwnerName) { - return true; - } - } - - return false; -} - -void CTeamsDialog::doCorrectTeamOwnerDialog( TeamsInfo *ti ) -{ - CFixTeamOwnerDialog fix(ti, &m_sides); - if (fix.DoModal() == IDOK) { - if (fix.pickedValidTeam()) { - ti->getDict()->setAsciiString(TheKey_teamOwner, fix.getSelectedOwner()); - } - } -} - diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview.cpp deleted file mode 100644 index 5796898fd7a..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview.cpp +++ /dev/null @@ -1,1085 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// wbview.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "CUndoable.h" -#include "CFixTeamOwnerDialog.h" -#include "WorldBuilder.h" -#include "WorldBuilderDoc.h" -#include "wbview.h" -#include "WHeightMapEdit.h" -#include "MainFrm.h" -#include "Common/Debug.h" -#include "Common/ThingTemplate.h" -#include "W3DDevice/GameClient/HeightMap.h" -#include "GlobalLightOptions.h" -#include "playerlistdlg.h" -#include "teamsdialog.h" -#include "LayersList.h" - -Bool WbView::m_snapToGrid = false; - -///////////////////////////////////////////////////////////////////////////// -// WbView - -IMPLEMENT_DYNCREATE(WbView, CView) - -WbView::WbView() : - m_trackingMode(TRACK_NONE), - m_centerPt(15,40,0), - m_hysteresis(0), - m_lockAngle(false), - m_doLightFeedback(FALSE), - m_pickConstraint(ES_NONE), - m_doRulerFeedback(RULER_NONE) -{ - Int showWay = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowWaypoints", 1); - m_showWaypoints = (showWay!=0); - Int showPoly = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowPolygonTriggers", 1); - m_showPolygonTriggers = (showPoly!=0); - Int showObj = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowObjectIcons", 1); - m_showObjects = (showObj!=0); - Int showNames = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowNames", 1); - m_showNames = (showNames!=0); - Int snapToGrid = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "SnapToGrid", 0); - m_snapToGrid = (snapToGrid!=0); - Int showTerrain = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowTerrain", 1); - m_showTerrain = (showTerrain!=0); -} - -WbView::~WbView() -{ -} - - -BEGIN_MESSAGE_MAP(WbView, CView) - //{{AFX_MSG_MAP(WbView) - ON_WM_RBUTTONUP() - ON_WM_RBUTTONDOWN() - ON_WM_MOUSEMOVE() - ON_WM_LBUTTONUP() - ON_WM_LBUTTONDOWN() - ON_WM_MBUTTONUP() - ON_WM_MBUTTONDOWN() - ON_WM_SETCURSOR() - ON_WM_KEYDOWN() - ON_WM_KEYUP() - ON_COMMAND(ID_EDIT_DELETE, OnEditDelete) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_UPDATE_COMMAND_UI(ID_EDIT_CUT, OnUpdateEditCut) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste) - ON_COMMAND(ID_VIEW_SNAPTOGRID, OnViewSnaptogrid) - ON_UPDATE_COMMAND_UI(ID_VIEW_SNAPTOGRID, OnUpdateViewSnaptogrid) - ON_COMMAND(ID_VIEW_SHOW_OBJECTS, OnViewShowObjects) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOW_OBJECTS, OnUpdateViewShowObjects) - ON_COMMAND(ID_EDIT_SELECTDUP, OnEditSelectdup) - ON_COMMAND(ID_EDIT_SELECTSIMILAR, OnEditSelectsimilar) - ON_COMMAND(ID_EDIT_REPLACE, OnEditReplace) - ON_COMMAND(ID_EDIT_SELECTINVALIDTEAM, OnEditSelectinvalidteam) - ON_COMMAND(ID_OBJECTPROPERTIES_REFLECTSINMIRROR, OnObjectpropertiesReflectsinmirror) - ON_COMMAND(ID_LOCK_HORIZONTAL, OnLockHorizontal) - ON_UPDATE_COMMAND_UI(ID_LOCK_HORIZONTAL, OnUpdateLockHorizontal) - ON_COMMAND(ID_EDIT_GLOBALLIGHTOPTIONS, OnEditGloballightoptions) - ON_COMMAND(ID_VIEW_SHOWWAYPOINTS, OnViewShowwaypoints) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWWAYPOINTS, OnUpdateViewShowwaypoints) - ON_COMMAND(ID_VIEW_SHOWPOLYGONTRIGGERS, OnViewShowpolygontriggers) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWPOLYGONTRIGGERS, OnUpdateViewShowpolygontriggers) - ON_COMMAND(ID_EDIT_PLAYERLIST, OnEditPlayerlist) - ON_COMMAND(ID_EDIT_WORLDINFO, OnEditWorldinfo) - ON_COMMAND(ID_EDIT_TEAMLIST, OnEditTeamlist) - ON_COMMAND(ID_TEAM_EDIT, OnEditTeamlist) - ON_UPDATE_COMMAND_UI(ID_OBJECTPROPERTIES_REFLECTSINMIRROR, OnUpdateObjectpropertiesReflectsinmirror) - ON_COMMAND(ID_EDIT_PICKSTRUCTS, OnPickStructures) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKSTRUCTS, OnUpdatePickStructures) - ON_COMMAND(ID_EDIT_PICKINFANTRY, OnPickInfantry) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKINFANTRY, OnUpdatePickInfantry) - ON_COMMAND(ID_EDIT_PICKVEHICLES, OnPickVehicles) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKVEHICLES, OnUpdatePickVehicles) - ON_COMMAND(ID_EDIT_PICKSHRUBBERY, OnPickShrubbery) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKSHRUBBERY, OnUpdatePickShrubbery) - ON_COMMAND(ID_EDIT_PICKMANMADE, OnPickManMade) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKMANMADE, OnUpdatePickManMade) - ON_COMMAND(ID_EDIT_PICKNATURAL, OnPickNatural) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKNATURAL, OnUpdatePickNatural) - ON_COMMAND(ID_EDIT_PICKDEBRIS, OnPickDebris) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKDEBRIS, OnUpdatePickDebris) - ON_COMMAND(ID_EDIT_PICKANYTHING, OnPickAnything) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKANYTHING, OnUpdatePickAnything) - ON_COMMAND(ID_EDIT_PICKWAYPOINTS, OnPickWaypoints) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKWAYPOINTS, OnUpdatePickWaypoints) - ON_COMMAND(ID_EDIT_PICKROADS, OnPickRoads) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKROADS, OnUpdatePickRoads) - ON_COMMAND(ID_EDIT_PICKSOUNDS, OnPickSounds) - ON_UPDATE_COMMAND_UI(ID_EDIT_PICKSOUNDS, OnUpdatePickSounds) - ON_COMMAND(ID_VIEW_LABELS, OnShowNames) - ON_UPDATE_COMMAND_UI(ID_VIEW_LABELS, OnUpdateShowNames) - ON_COMMAND(ID_VALIDATION_FIXTEAMS, OnValidationFixTeams) - ON_COMMAND(ID_VIEW_SHOW_TERRAIN, OnShowTerrain) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOW_TERRAIN, OnUpdateShowTerrain) - ON_WM_CREATE() - - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// WbView drawing - -void WbView::OnDraw(CDC* pDC) -{ - DEBUG_ASSERTCRASH((0),("oops")); -} - -///////////////////////////////////////////////////////////////////////////// -// WbView diagnostics - -#ifdef RTS_DEBUG -void WbView::AssertValid() const -{ - CView::AssertValid(); -} - -void WbView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} -#endif //RTS_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// WbView message handlers - -// ---------------------------------------------------------------------------- -void WbView::mouseDown(TTrackingMode m, CPoint viewPt) -{ - // can happen if you press 2 mouse buttons. DEBUG_ASSERTCRASH((m_trackingMode==TRACK_NONE),("oops")); - if (m_trackingMode != TRACK_NONE) - return; - - SetCapture(); - m_mouseDownPoint = viewPt; - viewToDocCoords(viewPt, &m_mouseDownDocPoint); - m_trackingMode = m; - WbApp()->updateCurTool(m == TRACK_R || m == TRACK_M); - WbApp()->lockCurTool(); - // If we have a tool, invoke it's mouse down method. - if (WbApp()->getCurTool()) { - WbApp()->getCurTool()->mouseDown(m, viewPt, this, WbDoc()); - } -} - -// ---------------------------------------------------------------------------- -void WbView::mouseMove(TTrackingMode m, CPoint viewPt) -{ - MSG msg; - while (::PeekMessage(&msg, m_hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) { - viewPt.x = (short)LOWORD(msg.lParam); // horizontal position of cursor - viewPt.y = (short)HIWORD(msg.lParam); // vertical position of cursor - DEBUG_LOG(("Peek mouse %d, %d", viewPt.x, viewPt.y)); - } - - if (m_trackingMode == TRACK_NONE) { - // Don't lock while the mouse is up. - m_doLockAngle = false; - } else { - m_doLockAngle = m_lockAngle; - } - if (m_trackingMode == m) { - WbApp()->updateCurTool(false); - if (WbApp()->getCurTool()) { - WbApp()->getCurTool()->mouseMoved(m, viewPt, this, WbDoc()); - } - } - if (CMainFrame::GetMainFrame()->isAutoSaving()) { - return; - } - - if (m_doRulerFeedback != RULER_NONE) { - // If the user is measuring stuff, no need to do the rest of the text. - CString str; - if (m_doRulerFeedback == RULER_CIRCLE) { - str.Format("Diameter (in feet): %f", m_rulerLength * 2.0f); - } else { - str.Format("Length (in feet): %f", m_rulerLength); - } - CMainFrame::GetMainFrame()->SetMessageText(str); - return; - } - - // Generate the status text display with coordinates and height. - Coord3D cpt; - viewToDocCoords(viewPt, &cpt); - - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - MapObject *pObj = MapObject::getFirstMapObject(); - Int totalObjects = 0; - Int totalWaypoints = 0; - Int numSelected = 0; - while(pObj) { - if (pObj->isSelected()) { - numSelected++; - } - const Int flagsWeDontWant = FLAG_ROAD_FLAGS | FLAG_ROAD_CORNER_ANGLED | FLAG_BRIDGE_FLAGS | FLAG_ROAD_CORNER_TIGHT | FLAG_ROAD_JOIN; - Int flags = pObj->getFlags(); - if (!(pObj->isWaypoint() || (flags & flagsWeDontWant) != 0)) - ++totalObjects; - else - ++totalWaypoints; - - pObj = pObj->getNext(); - } - - // See if the cursor is over an object. - pObj = MapObject::getFirstMapObject(); - while (pObj) { - if (picked(pObj, cpt)) { - break; - } - pObj = pObj->getNext(); - } - if (pObj==nullptr) { - pObj = picked3dObjectInView(viewPt); - } - Real height = TheTerrainRenderObject->getHeightMapHeight(cpt.x, cpt.y, nullptr); - CString str, str2, str3; - // If a layer has been activated, display it. - if (strcmp(AsciiString::TheEmptyString.str(), LayersList::TheActiveLayerName.c_str()) != 0) { - str.Format("Active Layer: (%s) %d object(s), ", LayersList::TheActiveLayerName.c_str(), totalObjects); - } else { - str.Format("%d object(s), ", totalObjects); - } - str2.Format("%d waypoint(s), ", totalWaypoints); - str3.Format("(%.2f,%.2f), height %.2f", cpt.x, cpt.y, height); - str += str2; - str += str3; - if (numSelected) { - CString numSel; - numSel.Format("(%d selected) ", numSelected); - str += numSel; - } - if (pObj) { - // If we have an object, add the object's name and index to the status. - const char *pName; - const char *pFullName = pObj->getName().str(); - Coord3D loc = *pObj->getLocation(); - pName = pFullName; - while (*pFullName) { - if (*pFullName == '/') { - pName = pFullName+1; - } - pFullName++; - } - - Bool exists; - AsciiString objectID = pObj->getProperties()->getAsciiString(TheKey_uniqueID, &exists); - CString obj; - if (exists) { - obj.Format(" - object %s(%.2f,%.2f)", objectID.str(), loc.x, loc.y); - } else { - obj.Format(" - object %s(%.2f,%.2f)", pName, loc.x, loc.y); - } - str += obj; - } - RGBColor color; - pMap->getTerrainColorAt(cpt.x, cpt.y, &color); - CString colorStr; - colorStr.Format("{r%f,g%f,b%f}", color.red,color.green,color.blue); - str += colorStr; - CMainFrame::GetMainFrame()->SetMessageText(str); -} - -// ---------------------------------------------------------------------------- -void WbView::mouseUp(TTrackingMode m, CPoint viewPt) -{ - //DEBUG_ASSERTCRASH((m_trackingMode!=TRACK_NONE),("oops")); - if (m_trackingMode == TRACK_NONE) - return; - - if (GetCapture() == this) - { - ReleaseCapture(); - } - - // If we were tracking a tool, call its mouseup method. - if (WbApp()->getCurTool()) { - WbApp()->getCurTool()->mouseUp(m, viewPt, this, WbDoc()); - // Give warning messages at this point. - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap->tooManyTextures()) { - AfxMessageBox(IDS_TOO_MANY_TILES); - } - if (pMap->tooManyBlends()) { - AfxMessageBox(IDS_TOO_MANY_BLENDS); - } - pMap->clearStatus(); - } - WbApp()->unlockCurTool(); - // We don't update the tool while tracking down, wouldn't want the eyedropper - // to suddenly turn into the flood fill tool, so now we update in case a key - // was released while tracking. - WbApp()->updateCurTool(false); - m_trackingMode = TRACK_NONE; -} - -void WbView::OnMouseMove(UINT nFlags, CPoint point) -{ - mouseMove(m_trackingMode, point); -} - -void WbView::OnRButtonUp(UINT nFlags, CPoint point) -{ - mouseUp(TRACK_R, point); -} - -void WbView::OnRButtonDown(UINT nFlags, CPoint point) -{ - mouseDown(TRACK_R, point); -} - -void WbView::OnLButtonUp(UINT nFlags, CPoint point) -{ - mouseUp(TRACK_L, point); -} - -void WbView::OnLButtonDown(UINT nFlags, CPoint point) -{ - mouseDown(TRACK_L, point); -} - -void WbView::OnMButtonUp(UINT nFlags, CPoint point) -{ - mouseUp(TRACK_M, point); -} - -void WbView::OnMButtonDown(UINT nFlags, CPoint point) -{ - mouseDown(TRACK_M, point); -} - -//============================================================================= -// WbView::pickedInView -//============================================================================= -/** Returns true if the pixel location picks the object. */ -//============================================================================= -TPickedStatus WbView::picked(MapObject *pObj, Coord3D docPt) -{ - Coord3D cloc = *pObj->getLocation(); - if (!m_showObjects && !pObj->isWaypoint()) { - return PICK_NONE; - } - if (!m_showWaypoints && !WaypointTool::isActive() && pObj->isWaypoint()) { - return PICK_NONE; - } - - Bool doArrow = pObj->isSelected(); - // Check and see if we are within 1/2 cell size of the center. - Coord3D cpt = docPt; - cpt.x -= cloc.x; - cpt.y -= cloc.y; - cpt.z = 0; - if (cpt.length() < 0.5f*MAP_XY_FACTOR+m_hysteresis) { - return PICK_CENTER; - } - if (pObj->getFlag(FLAG_ROAD_FLAGS) || pObj->getFlag(FLAG_BRIDGE_FLAGS) || pObj->isWaypoint()) { - doArrow = false; - } - // Check and see if we are within 1 cell size of the center. - if (doArrow && cpt.length() < 1.5f*MAP_XY_FACTOR+m_hysteresis) { - return PICK_ARROW; - } - return PICK_NONE; -} - -//============================================================================= -WorldHeightMapEdit *WbView::getTrackingHeightMap() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - // If we are editing with a tool, draw the map being edited, if one exists. - if (m_trackingMode != TRACK_NONE && WbApp()->getCurTool()) { - pMap = WbApp()->getCurTool()->getHeightMap(); - } - // If we aren't editing, or the tool doesn't provide a map, use the current one. - if (pMap == nullptr) { - pMap = WbDoc()->GetHeightMap(); - } - return pMap; -} - -//============================================================================= -void WbView::constrainCenterPt() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap==nullptr) return; -#if 0 - if (m_centerPt.X >= pMap->getXExtent()) m_centerPt.X = pMap->getXExtent()-1; - if (m_centerPt.X<0) m_centerPt.X = 0; - if (m_centerPt.Y >= pMap->getYExtent()) m_centerPt.Y = pMap->getYExtent() - 1; - if (m_centerPt.Y<0) m_centerPt.Y=0; -#endif -} - -//============================================================================= -// WbView::OnSetCursor -//============================================================================= -/** Standard window handler method for updating the cursor. */ -//============================================================================= -BOOL WbView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) -{ - if (nHitTest == HTCLIENT) { - // If we are tracking in our window, update the tool. - WbApp()->updateCurTool(false); - if (WbApp()->getCurTool()) { - // Let the current tool set it's cursor. - WbApp()->getCurTool()->setCursor(); - } else { - // Else just use the system arrow cursor. This shouldn't normally happen. - ::SetCursor(::LoadCursor(nullptr, IDC_ARROW)); - } - return(0); - } - // Otherwise let the parent window handle the other cursors like window resize etc. - return(CView::OnSetCursor(pWnd, nHitTest, message)); -} - - -/** Handles the delete menu action. */ -void WbView::OnEditDelete() -{ - if (PolygonTool::isActive() || m_showPolygonTriggers) { - if (PolygonTool::deleteSelectedPolygon()) { - return; - } - } - CWorldBuilderDoc* pDoc = WbDoc(); - // create a delete undoable. - DeleteObjectUndoable *pUndo = new DeleteObjectUndoable(pDoc); - // Execute it. - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. -} - -/** Handles the key down event. Currently, handles delete keys, and checks -for updates to the current tool. */ -void WbView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - if (nChar == VK_DELETE || nChar == VK_BACK) { - OnEditDelete(); - } - WbApp()->updateCurTool(false); - OnSetCursor(this,HTCLIENT,0); -} - -/** Handles the key up event. Currently, handles delete keys, and checks -for updates to the current tool. */ -void WbView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) -{ - WbApp()->updateCurTool(false); - OnSetCursor(this,HTCLIENT,0); -} - -void WbView::OnEditCopy() -{ - MapObject *pTheCopy = nullptr; - MapObject *pTmp = nullptr; - - MapObject *pObj = MapObject::getFirstMapObject(); - // Note - map segments come in pairs. So copy both. - MapObject *pMapObj; - MapObject *pMapObj2; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (pMapObj->getFlag(FLAG_ROAD_POINT1)) { - pMapObj2 = pMapObj->getNext(); - DEBUG_ASSERTCRASH(pMapObj2 && pMapObj2->getFlag(FLAG_ROAD_POINT2), ("oops")); - if (pMapObj2==nullptr) break; - if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; - // If one end of a road segment is selected, both are. - if (pMapObj->isSelected() || pMapObj2->isSelected()) { - pMapObj->setSelected(true); - pMapObj2->setSelected(true); - } - } - if (pMapObj->isWaypoint()) { - pMapObj->setSelected(false); - } - } - - pObj = MapObject::getFirstMapObject(); - while (pObj) { - if (pObj->isSelected()) { - pTmp = pObj->duplicate(); - pTmp->setNextMap(pTheCopy); - pTheCopy = pTmp; - } - pObj = pObj->getNext(); - } - WbApp()->setMapObjPasteList(pTheCopy); - pTheCopy = nullptr; // belongs to the app. -} - -void WbView::OnUpdateEditCopy(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(); -} - -void WbView::OnEditCut() -{ - OnEditCopy(); - OnEditDelete(); -} - -void WbView::OnUpdateEditCut(CCmdUI* pCmdUI) -{ - pCmdUI->Enable(); -} - -void WbView::OnEditPaste() -{ - CWorldBuilderDoc* pDoc = WbDoc(); - MapObject *pTheCopy = nullptr; - MapObject *pTmp = nullptr; - - /* First, clear the selection. */ - PointerTool::clearSelection(); - - MapObject *pObj = WbApp()->getMapObjPasteList(); - while (pObj) { - pTmp = pObj->duplicate(); - pTmp->setNextMap(pTheCopy); - pTmp->validate(); - - pTheCopy = pTmp; - pTmp->setSelected(true); - pObj = pObj->getNext(); - } - AddObjectUndoable *pUndo = new AddObjectUndoable(pDoc, pTheCopy); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - pTheCopy = nullptr; // undoable owns it now. - -} - -/** Toggles the show objects flag and invals the window. */ -void WbView::OnViewShowObjects() -{ - m_showObjects = !m_showObjects; - Invalidate(false); - WbView *pView = (WbView *)WbDoc()->GetActive2DView(); - if (pView != nullptr && pView != this) { - pView->Invalidate(!m_showObjects); - } - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowObjectIcons", m_showObjects?1:0); -} - -/** Sets the check in the menu to match the show objects flag. */ -void WbView::OnUpdateViewShowObjects(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showObjects?1:0); -} - -void WbView::OnUpdateEditPaste(CCmdUI* pCmdUI) -{ - MapObject *pTheCopy = WbApp()->getMapObjPasteList(); - pCmdUI->Enable(pTheCopy != nullptr); -} - -void WbView::OnViewSnaptogrid() -{ - m_snapToGrid = !m_snapToGrid; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "SnapToGrid", m_snapToGrid?1:0); -} - -void WbView::OnUpdateViewSnaptogrid(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_snapToGrid?1:0); -} - -void WbView::OnEditSelectdup() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap==nullptr) return; - pMap->selectDuplicates(); -} -void WbView::OnEditSelectsimilar() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap==nullptr) return; - pMap->selectSimilar(); -} -void WbView::OnEditSelectinvalidteam() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap==nullptr) return; - pMap->selectInvalidTeam(); -} - -void WbView::OnEditReplace() -{ - WorldHeightMapEdit *pMap = WbDoc()->GetHeightMap(); - if (pMap==nullptr) return; - - EditorSortingType sort = ES_NONE; - for (MapObject* pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (pObj->isSelected()) { - const ThingTemplate* tt = pObj->getThingTemplate(); - if (tt) { - sort = tt->getEditorSorting(); - break; - } - } - } - - PickUnitDialog dlg; - if (sort == ES_NONE) { - for (int i = ES_FIRST; iAddAndDoUndoable(pUndo); - pUndo->SetThingTemplate(thing); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } - } -} - - -/** Shows the selected status of the reflects in mirror flag. */ -void WbView::OnUpdateObjectpropertiesReflectsinmirror(CCmdUI* pCmdUI) -{ - Bool reflects = false; - Bool multiple = false; - Bool first = true; - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (!pMapObj->isSelected()) { - continue; - } - if (pMapObj->getFlag(FLAG_DRAWS_IN_MIRROR)) { - if (!first && !reflects) { - multiple = true; - } - reflects = true; - } else { - if (!first && reflects) { - multiple = true; - } - } - first = false; - } - Int val=0; - if (reflects) val = 1; - if (multiple) val = 2; - pCmdUI->SetCheck(val); -} - -void WbView::OnObjectpropertiesReflectsinmirror() -{ - Bool reflects = false; - - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - if (!pMapObj->isSelected()) { - continue; - } - if (pMapObj->getFlag(FLAG_DRAWS_IN_MIRROR)) { - reflects = true; - } - } - - CWorldBuilderDoc* pDoc = WbDoc(); - ModifyFlagsUndoable *pUndo = new ModifyFlagsUndoable(pDoc, FLAG_DRAWS_IN_MIRROR, !reflects); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. -} - -// This is actually lock angle - used to be horizontal & vertical, now just 1. -void WbView::OnLockHorizontal() -{ - m_lockAngle = !m_lockAngle; -} - -// This is actually lock angle - used to be horizontal & vertical, now just 1. -void WbView::OnUpdateLockHorizontal(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_lockAngle?1:0); -} - -// Obsolete. Delete Jan15,2002 if nobody complains about it being missing. jba. -void WbView::OnLockVertical() -{ -// m_lockVertical = !m_lockVertical; -// if (m_lockVertical) { -// m_lockHorizontal = false; -// } -} - -// Obsolete. Delete Jan15,2002 if nobody complains about it being missing. jba. -void WbView::OnUpdateLockVertical(CCmdUI* pCmdUI) -{ -// pCmdUI->SetCheck(m_lockVertical?1:0); -} - -void WbView::OnEditGloballightoptions() -{ - CMainFrame::GetMainFrame()->OnEditGloballightoptions(); - -// GlobalLightOptions globalLightDialog(this); -// globalLightDialog.DoModal(); -// Coord3D lightRay; -// lightRay.x=0.0f;lightRay.y=0.0f;lightRay.z=-1.0f; //default light above terrain. -// doLightFeedback(false,lightRay,0); //turn off the light direction indicator -} - -void WbView::OnViewShowwaypoints() -{ - m_showWaypoints = !m_showWaypoints; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowWaypoints", m_showWaypoints?1:0); - PointerTool::clearSelection(); -} - -void WbView::OnUpdateViewShowwaypoints(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showWaypoints?1:0); -} - -void WbView::OnViewShowpolygontriggers() -{ - m_showPolygonTriggers = !m_showPolygonTriggers; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowPolygonTriggers", m_showPolygonTriggers?1:0); -} - -void WbView::OnUpdateViewShowpolygontriggers(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showPolygonTriggers?1:0); -} - -void WbView::OnEditPlayerlist() -{ - PlayerListDlg dlg; - dlg.DoModal(); -} - -void WbView::OnEditWorldinfo() -{ - // TODO jkmcd: are we going to ever use this? If so, implement it. -#if 0 - Dict *d = MapObject::getWorldDict(); - Dict dcopy = *d; - MapObjectProps editor(&dcopy, "Edit World Info", nullptr); - if (editor.DoModal() == IDOK) - { - CWorldBuilderDoc* pDoc = WbDoc(); - DictItemUndoable *pUndo = new DictItemUndoable(d, dcopy, NAMEKEY_INVALID); - pDoc->AddAndDoUndoable(pUndo); - REF_PTR_RELEASE(pUndo); // belongs to pDoc now. - } -#endif -} - -void WbView::OnPickStructures() -{ - m_pickConstraint = ES_STRUCTURE; -} - -void WbView::OnUpdatePickStructures(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_STRUCTURE)?1:0); -} - -void WbView::OnPickInfantry() -{ - m_pickConstraint = ES_INFANTRY; -} - -void WbView::OnUpdatePickInfantry(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_INFANTRY)?1:0); -} - -void WbView::OnPickVehicles() -{ - m_pickConstraint = ES_VEHICLE; -} - -void WbView::OnUpdatePickVehicles(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_VEHICLE)?1:0); -} - -void WbView::OnPickShrubbery() -{ - m_pickConstraint = ES_SHRUBBERY; -} - -void WbView::OnUpdatePickShrubbery(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_SHRUBBERY)?1:0); -} - -void WbView::OnPickManMade() -{ - m_pickConstraint = ES_MISC_MAN_MADE; -} - -void WbView::OnUpdatePickManMade(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_MISC_MAN_MADE)?1:0); -} - -void WbView::OnPickNatural() -{ - m_pickConstraint = ES_MISC_NATURAL; -} - -void WbView::OnUpdatePickNatural(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_MISC_NATURAL)?1:0); -} - -void WbView::OnPickDebris() -{ - m_pickConstraint = ES_DEBRIS; -} - -void WbView::OnUpdatePickDebris(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_DEBRIS)?1:0); -} - -void WbView::OnPickAnything() -{ - m_pickConstraint = ES_NONE; -} - -void WbView::OnUpdatePickAnything(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_NONE)?1:0); -} - -void WbView::OnPickWaypoints() -{ - m_pickConstraint = ES_WAYPOINT; -} - -void WbView::OnUpdatePickWaypoints(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_WAYPOINT)?1:0); -} - -void WbView::OnPickRoads() -{ - m_pickConstraint = ES_ROAD; -} - -void WbView::OnUpdatePickRoads(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_ROAD)?1:0); -} - -void WbView::OnPickSounds() -{ - m_pickConstraint = ES_AUDIO; -} - -void WbView::OnUpdatePickSounds(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck((m_pickConstraint == ES_AUDIO) ? 1 : 0); -} - -void WbView::OnShowNames() -{ - m_showNames = m_showNames ? false : true; - Invalidate(false); - WbView *pView = (WbView *)WbDoc()->GetActive2DView(); - if (pView != nullptr && pView != this) { - pView->Invalidate(false); - } - - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowNames", m_showNames?1:0); -} - -void WbView::OnUpdateShowNames(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showNames ? 1 : 0); -} - -void WbView::OnValidationFixTeams() -{ - Bool anyFixes = false; - Int i; - // Check for duplicate teams. - for (i = 0; i < TheSidesList->getNumTeams(); ++i) - { - Dict *d = TheSidesList->getTeamInfo(i)->getDict(); - - AsciiString tname = d->getAsciiString(TheKey_teamName); - Int j; - for (j=0; jgetTeamInfo(j)->getDict(); - if (prevd->getAsciiString(TheKey_teamName).compare(tname)==0) { - anyFixes = true; - CString msg; - msg.Format(IDS_DUPLICATE_TEAM_REMOVED, tname.str()); - AfxMessageBox(msg, MB_OK); - TheSidesList->removeTeam(i); - i--; - break; - } - } - } - - // Check for teams with invalid owners. - for (i = 0; i < TheSidesList->getNumTeams(); ++i) - { - Dict *d = TheSidesList->getTeamInfo(i)->getDict(); - AsciiString oname = d->getAsciiString(TheKey_teamOwner); - AsciiString tname = d->getAsciiString(TheKey_teamName); - SidesInfo* pSide = TheSidesList->findSideInfo(oname); - Bool found = pSide!=nullptr; - if (!found) { - CString msg; - msg.Format(IDS_PLAYERLESS_TEAM_REMOVED, tname.str(), oname.str()); - AfxMessageBox(msg, MB_OK); - anyFixes = true; - TheSidesList->removeTeam(i); - i--; - } - } - - // Check for objects with invalid teams. [8/8/2003] - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - // there is no validation code for these items as of yet. - if (pMapObj->isScorch() || pMapObj->isWaypoint() || pMapObj->isLight() || pMapObj->getFlag(FLAG_ROAD_FLAGS) || pMapObj->getFlag(FLAG_BRIDGE_FLAGS)) - { - continue; - } - - if (pMapObj->getThingTemplate()==nullptr) { - continue; // Objects that don't have templates don't need teams. [8/8/2003] - } - // at this point, only objects with models and teams should be left to process - - AsciiString name = pMapObj->getName(); - AsciiString tmplName = pMapObj->getThingTemplate()->getName(); - - // the following code verifies and fixes the team name, player name, and faction linkages - Bool teamExists; - AsciiString teamName = pMapObj->getProperties()->getAsciiString(TheKey_originalOwner, &teamExists); - if (teamExists) { - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(teamName); - if (teamInfo) { - AsciiString teamOwner = teamInfo->getDict()->getAsciiString(TheKey_teamOwner); - SidesInfo* pSide = TheSidesList->findSideInfo(teamOwner); - if (!pSide) { - teamExists = false; - DEBUG_LOG(("Side '%s' could not be found in sides list!", teamOwner.str())); - } - } else { - // Couldn't find team. [8/8/2003] - teamExists = false; - } - } else { - // Object doesn't even have a team name at all. bad. jba. [8/8/2003] - teamExists = false; - } - if (!teamExists) { - // Query the user for a player, and stick it on the default team. [8/8/2003] - AsciiString warning; - warning.format("Object '%s' named '%s' on team '%s' - team doesn't exist. Select player for object...", - tmplName.str(), name.str(), teamName.str()); - - anyFixes = true; - ::AfxMessageBox(warning.str(), MB_OK); - TeamsInfo ti; - CFixTeamOwnerDialog fix(&ti, TheSidesList); - if (fix.DoModal() == IDOK) { - if (fix.pickedValidTeam()) { - AsciiString team; - team.set("team"); - team.concat(fix.getSelectedOwner()); - if (TheSidesList->findTeamInfo(team)==nullptr) { - team.set("team"); // neutral. - } - pMapObj->getProperties()->setAsciiString(TheKey_originalOwner, team); - } - } - } - } - - - if (anyFixes) { - // Show a message indicating success. - AfxMessageBox(IDS_TEAMS_FIXED, MB_OK|MB_ICONWARNING); - } else { - AfxMessageBox(IDS_NO_PROBLEMS, MB_OK); - } -} - -void WbView::OnShowTerrain() -{ - m_showTerrain = !m_showTerrain; - Invalidate(false); - WbView *pView = (WbView *)WbDoc()->GetActive2DView(); - if (pView != nullptr && pView != this) { - pView->Invalidate(false); - } - - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowTerrain", m_showTerrain ? 1 : 0); -} - -void WbView::OnUpdateShowTerrain(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showTerrain ? 1 : 0); -} - - -void WbView::OnEditTeamlist() -{ - CTeamsDialog dlg; - dlg.DoModal(); -} - -// A sleazy hack for a sleazy hack. -extern HWND ApplicationHWnd; -int WbView::OnCreate(LPCREATESTRUCT lpcs) -{ - ApplicationHWnd = m_hWnd; - return CView::OnCreate(lpcs); -} - -void WbView::rulerFeedbackInfo(Coord3D &point1, Coord3D &point2, Real dist) -{ - m_rulerPoints[0] = point1; - m_rulerPoints[1] = point2; - m_rulerLength = dist; -} diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp deleted file mode 100644 index ccfe7c33acb..00000000000 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/wbview3d.cpp +++ /dev/null @@ -1,3310 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -// wbview3d.cpp : implementation file -// - -#include "StdAfx.h" -#include "resource.h" -#include "WWMath/wwmath.h" -#include "WW3D2/ww3d.h" -#include "WW3D2/scene.h" -#include "WW3D2/rendobj.h" -#include "WW3D2/camera.h" -#include "WW3D2/intersec.h" -#include "W3DDevice/GameClient/W3DAssetManager.h" -#include "W3DDevice/GameClient/Module/W3DModelDraw.h" -#include "W3DDevice/GameClient/Module/W3DTreeDraw.h" -#include "WW3D2/agg_def.h" -#include "WW3D2/part_ldr.h" -#include "WW3D2/hanim.h" -#include "WW3D2/dx8wrapper.h" -#include "WW3D2/dx8indexbuffer.h" -#include "WW3D2/dx8vertexbuffer.h" -#include "WW3D2/dx8renderer.h" -#include "WW3D2/dx8fvf.h" -#include "WW3D2/vertmaterial.h" -#include "WW3D2/font3d.h" -#include "WW3D2/render2d.h" -#include "WW3D2/rddesc.h" -#include "WW3D2/textdraw.h" -#include "WWMath/rect.h" -#include "WW3D2/mesh.h" -#include "WW3D2/meshmdl.h" -#include "WW3D2/line3d.h" -#include "WW3D2/dynamesh.h" -#include "WW3D2/sphereobj.h" -#include "WW3D2/ringobj.h" -#include "WW3D2/surfaceclass.h" -#include "WWMath/vector2i.h" -#include "WW3D2/bmp2d.h" -#include "WW3D2/decalsys.h" -#include "WW3D2/shattersystem.h" -#include "WW3D2/light.h" -#include "WW3D2/texproject.h" -#include "MapSettings.h" -#include "WW3D2/predlod.h" -#include "SelectMacrotexture.h" -#include "WorldBuilderView.h" -#include "WHeightMapEdit.h" -#include "WorldBuilderDoc.h" -#include "MainFrm.h" -#include "W3DDevice/GameClient/WorldHeightMap.h" -#include "W3DDevice/GameClient/W3DShaderManager.h" -#include "W3DDevice/GameClient/W3DDynamicLight.h" -#include "WBHeightMap.h" -#include "W3DDevice/GameClient/W3DScene.h" -#include "W3DDevice/Common/W3DConvert.h" -#include "W3DDevice/GameClient/W3DShadow.h" -#include "DrawObject.h" -#include "Common/MapObject.h" -#include "Common/GlobalData.h" -#include "ShadowOptions.h" -#include "WorldBuilder.h" -#include "wbview3d.h" -#include "Common/Debug.h" -#include "Common/FramePacer.h" -#include "Common/ThingFactory.h" -#include "GameClient/Water.h" -#include "Common/WellKnownKeys.h" -#include "Common/ThingTemplate.h" -#include "Common/Language.h" -#include "Common/FileSystem.h" -#include "Common/PlayerTemplate.h" -#include "GameLogic/SidesList.h" -#include "GameLogic/TerrainLogic.h" -#include "GameClient/View.h" -#include "GlobalLightOptions.h" -#include "LayersList.h" -#include "ImpassableOptions.h" - - -#include - - -// ---------------------------------------------------------------------------- -// Misc. Forward Declarations -// ---------------------------------------------------------------------------- -class SkeletonSceneClass; - -// ---------------------------------------------------------------------------- -// Constants: -// ---------------------------------------------------------------------------- -#define MAX_LOADSTRING 100 -#define WINDOW_WIDTH 640 -#define WINDOW_HEIGHT 480 -#define UPDATE_TIME 100 /* 10 frames a second */ -#define MOUSE_WHEEL_FACTOR 32 - -#define SAMPLE_DYNAMIC_LIGHT 1 -#ifdef SAMPLE_DYNAMIC_LIGHT -static W3DDynamicLight * theDynamicLight = nullptr; -static Real theLightXOffset = 0.1f; -static Real theLightYOffset = 0.07f; -static Int theFlashCount = 0; -#endif - -// ---------------------------------------------------------------------------- -// Global Variables: -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// Static Functions -// ---------------------------------------------------------------------------- - -static void WWDebug_Message_Callback(DebugType type, const char * message); -static void WWAssert_Callback(const char * message); -static void Debug_Refs(); - -// ---------------------------------------------------------------------------- -static void WWDebug_Message_Callback(DebugType type, const char * message) -{ -#ifdef RTS_DEBUG - ::OutputDebugString(message); - ::OutputDebugString("\n"); -#endif -} - -// ---------------------------------------------------------------------------- -static void WWAssert_Callback(const char * message) -{ -#ifdef RTS_DEBUG - ::OutputDebugString(message); - ::OutputDebugString("\n"); - ::DebugBreak(); -#endif -} - - -// The W3DShadowManager accesses TheTacticalView, so we have to create -// a stub class & object in Worldbuilder for it to access. -class PlaceholderView : public View -{ -protected: - Int m_width, m_height; ///< Dimensions of the view - Int m_originX, m_originY; ///< Location of top/left view corner - -protected: - virtual View *prependViewToList( View *list ) override {return nullptr;}; ///< Prepend this view to the given list, return the new list - virtual View *getNextView() override { return nullptr; } ///< Return next view in the set -public: - - virtual void init() override {}; - - virtual UnsignedInt getID() override { return 1; } - - virtual Drawable *pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType ) override {return nullptr;}; ///< pick drawable given the screen pixel coords - - /// all drawables in the 2D screen region will call the 'callback' - virtual Int iterateDrawablesInRegion( IRegion2D *screenRegion, - Bool (*callback)( Drawable *draw, void *userData ), - void *userData ) override {return 0;}; - virtual WorldToScreenReturn worldToScreenTriReturn( const Coord3D *w, ICoord2D *s ) override { return WTS_INVALID; }; ///< Transform world coordinate "w" into screen coordinate "s" - virtual Bool screenToTerrain( const ICoord2D *screen, Coord3D *world ) override { return false; } - virtual PlaneClass::IntersectionResType screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) override { return PlaneClass::NO_INTERSECTION; } - virtual PlaneClass::IntersectionResType getScreenCornerWorldPointsAtZ( Coord3D *topLeft, Coord3D *topRight, - Coord3D *bottomRight, Coord3D *bottomLeft, - Real z, ViewportClass viewPort = ViewportClass() ) override { return PlaneClass::NO_INTERSECTION; } - - virtual void drawView() override {}; ///< Render the world visible in this view. - virtual void updateView() override {}; ///< Render the world visible in this view. - virtual void stepView() override {}; ///< Update view for every fixed time step - - virtual void setZoomLimited( Bool limit ) override {} ///< limit the zoom height - virtual Bool isZoomLimited() const override { return TRUE; } ///< get status of zoom limit - - virtual void setWidth( Int width ) override { m_width = width; } - virtual Int getWidth() override { return m_width; } - virtual void setHeight( Int height ) override { m_height = height; } - virtual Int getHeight() override { return m_height; } - virtual void setOrigin( Int x, Int y) override { m_originX=x; m_originY=y;} ///< Sets location of top-left view corner on display - virtual void getOrigin( Int *x, Int *y) override { *x=m_originX; *y=m_originY;} ///< Return location of top-left view corner on display - - virtual void forceRedraw() override { } - - virtual Bool isDoingScriptedCamera() override { return false; } - virtual void stopDoingScriptedCamera() override {} - - virtual void lookAt( const Coord3D *o ) override {}; ///< Center the view on the given coordinate - virtual void initHeightForMap() override {}; ///< Init the camera height for the map at the current position. - virtual void scrollBy( Coord2D *delta ){}; ///< Shift the view by the given delta - virtual void moveCameraTo(const Coord3D *o, Int frames, Int shutter, - Bool orient, Real easeIn, Real easeOut) override {lookAt(o);}; - virtual void moveCameraAlongWaypointPath(Waypoint *way, Int frames, Int shutter, - Bool orient, Real easeIn, Real easeOut) override {}; - virtual Bool isCameraMovementFinished() override {return true;}; - virtual void resetCamera(const Coord3D *location, Int frames, Real easeIn, Real easeOut) override {}; ///< Move camera to location, and reset to default angle & zoom. - virtual void rotateCamera(Real rotations, Int frames, Real easeIn, Real easeOut) override {}; ///< Rotate camera about current viewpoint. - virtual void rotateCameraTowardObject(ObjectID id, Int milliseconds, Int holdMilliseconds, Real easeIn, Real easeOut) override {}; ///< Rotate camera to face an object, and hold on it - virtual void cameraModFinalZoom(Real finalZoom, Real easeIn, Real easeOut) override {}; ///< Final zoom for current camera movement. - virtual void cameraModRollingAverage(Int framesToAverage) override {}; ///< Number of frames to average movement for current camera movement. - virtual void cameraModFinalTimeMultiplier(Int finalMultiplier) override {}; ///< Final time multiplier for current camera movement. - virtual void cameraModFinalPitch(Real finalPitch, Real easeIn, Real easeOut) override {}; ///< Final pitch for current camera movement. - virtual void cameraModFreezeTime() override {} ///< Freezes time during the next camera movement. - virtual void cameraModFreezeAngle() override {} ///< Freezes time during the next camera movement. - virtual void cameraModLookToward(Coord3D *pLoc) override {} ///< Sets a look at point during camera movement. - virtual void cameraModFinalLookToward(Coord3D *pLoc) override {} ///< Sets a look at point during camera movement. - virtual void cameraModFinalMoveTo(Coord3D *pLoc) override { }; ///< Sets a final move to. - virtual Bool isTimeFrozen() override { return false;} ///< Freezes time during the next camera movement. - virtual Int getTimeMultiplier() override {return 1;}; ///< Get the time multiplier. - virtual void setTimeMultiplier(Int multiple) override {}; ///< Set the time multiplier. - virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) override {}; - virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn, Real easeOut ) override {}; - virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn, Real easeOut ) override {}; - - virtual void setAngle( Real angle ) override {}; ///< Rotate the view around the up axis to the given angle - virtual Real getAngle() override { return 0; } - virtual void setPitch( Real angle ) override {}; ///< Rotate the view around the horizontal axis to the given angle - virtual Real getPitch() override { return 0; } ///< Return current camera pitch - virtual void setAngleToDefault() override {} ///< Set the view angle back to default - virtual void setPitchToDefault() override {} ///< Set the view pitch back to default - virtual void getPosition(Coord3D *pos) {} ///< Return camera position - - virtual Real getHeightAboveGround() override { return 1; } - virtual void setHeightAboveGround(Real z) override { } - virtual Real getZoom() override { return 1; } - virtual void setZoom(Real z) override { } - virtual void zoomIn() { } ///< Zoom in, closer to the ground, limit to min - virtual void zoomOut() { } ///< Zoom out, farther away from the ground, limit to max - virtual void setZoomToDefault() override { } ///< Set zoom to default value - virtual Real getMaxZoom() { return 0.0f; } - virtual void setOkToAdjustHeight( Bool val ) override { } ///< Set this to adjust camera height - - virtual Real getTerrainHeightAtPivot() override { return 0.0f; } - virtual Real getCurrentHeightAboveGround() override { return 0.0f; } - - virtual void getLocation ( ViewLocation *location ) override {}; ///< write the view's current location in to the view location object - virtual void setLocation ( const ViewLocation *location ) override {}; ///< set the view's current location from to the view location object - - virtual ObjectID getCameraLock() const override { return INVALID_ID; } - virtual void setCameraLock(ObjectID id) override { } - virtual void snapToCameraLock() override { } - virtual void setSnapMode( CameraLockType lockType, Real lockDist ) override { } - - virtual Drawable *getCameraLockDrawable() const override { return nullptr; } - virtual void setCameraLockDrawable(Drawable *drawable) override { } - - virtual void setMouseLock( Bool mouseLocked ) override {} ///< lock/unlock the mouse input to the tactical view - virtual Bool isMouseLocked() override { return FALSE; } ///< is the mouse input locked to the tactical view? - - virtual void setFieldOfView( Real angle ) override {}; ///< Set the horizontal field of view angle - virtual Real getFieldOfView() override {return 0;}; ///< Get the horizontal field of view angle - - virtual Bool setViewFilterMode(enum FilterModes) override {return FALSE;} ///First(); - while(!sceneIter->Is_Done()) { - if (obj==sceneIter->Current_Item()) { - found = true; - break; - } - sceneIter->Next(); - } - Destroy_Iterator(sceneIter); - return found; -} - -// ---------------------------------------------------------------------------- - -void SkeletonSceneClass::Remove_Render_Object(RenderObjClass * obj) -{ - if (RenderList.Contains(obj)) { - RenderObjClass *refPtr = nullptr; - REF_PTR_SET(refPtr, obj); // ref it, as when it gets removed from the scene, may get deleted otherwise. - RTS3DScene::Remove_Render_Object(obj); - REF_PTR_RELEASE(refPtr); - } -} - - -void WbView3d::setObjTracking(MapObject *pMapObj, Coord3D pos, Real angle, Bool show) -{ - m_showObjToolTrackingObj = show; - if (!show) return; - Real scale; - AsciiString modelName = getModelNameAndScale(pMapObj, &scale, BODY_PRISTINE); - if (modelName != m_objectToolTrackingModelName) { - m_objectToolTrackingModelName = modelName; - REF_PTR_RELEASE(m_objectToolTrackingObj); - m_objectToolTrackingObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, 0); - } - if (m_objectToolTrackingObj == nullptr) { - return; - } - pos.z += m_heightMapRenderObj->getHeightMapHeight(pos.x, pos.y, nullptr); - Matrix3D renderObjPos(true); // init to identity - renderObjPos.Translate(pos.x, pos.y, pos.z); - renderObjPos.Rotate_Z(angle); - m_objectToolTrackingObj->Set_Transform( renderObjPos ); -} - -// ---------------------------------------------------------------------------- -// WbView3d -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -IMPLEMENT_DYNCREATE(WbView3d, WbView) - -// ---------------------------------------------------------------------------- -WbView3d::WbView3d() : - m_assetManager(nullptr), - m_scene(nullptr), - m_overlayScene(nullptr), - m_transparentObjectsScene(nullptr), - m_baseBuildScene(nullptr), - m_objectToolTrackingObj(nullptr), - m_showObjToolTrackingObj(false), - m_camera(nullptr), - m_heightMapRenderObj(nullptr), - m_mouseWheelOffset(0), - m_actualWinSize(0, 0), - m_cameraAngle(0.0), - m_FXPitch(1.0f), - m_actualHeightAboveGround(0.0f), - m_doPitch(false), - m_theta(0.0), - m_time(0), - m_updateCount(0), - m_needToLoadRoads(0), - m_timer(0), - m_drawObject(nullptr), - m_layer(nullptr), - m_buildLayer(nullptr), - m_intersector(nullptr), - m_showEntireMap(false), - m_partialMapSize(129), - m_showWireframe(false), - m_projection(false), - m_showShadows(false), - m_firstPaint(true), - m_groundLevel(10), - m_curTrackingZ(10), - m_ww3dInited(false), - m_showLayersList(false), - m_showMapBoundaries(false), - m_showBoundingBoxes(false), - m_showSightRanges(false), - m_showWeaponRanges(false), - m_highlightTestArt(false), - m_showLetterbox(false), - m_showSoundCircles(false) -{ - TheTacticalView = &bogusTacticalView; - m_actualWinSize.x = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Width", THREE_D_VIEW_WIDTH); - m_actualWinSize.y = ::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "Height", THREE_D_VIEW_HEIGHT); - m_cameraOffset.x = m_cameraOffset.y = m_cameraOffset.z = 1; - - for (Int i=0; iGetProfileInt(MAIN_FRAME_SECTION, "ShowWireframe", 0) != 0); - m_showEntireMap = (::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowEntireMap", 1) != 0); - m_projection = (::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowTopDownView", 0) != 0); - m_showShadows = (::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowShadows", 1) != 0); - TheWritableGlobalData->m_useShadowDecals = m_showShadows; - TheWritableGlobalData->m_useShadowVolumes = m_showShadows; - TheWritableGlobalData->m_showSoftWaterEdge = (::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowSoftWater", 1) != 0); - TheWritableGlobalData->m_use3WayTerrainBlends = (::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowExtraBlends", 1) > 1 ? 2 : 1); - setShowModels(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowModels", 1) != 0); - setShowBoundingBoxes(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowBoundingBoxes", 0) != 0); - setShowSightRanges(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowSightRanges", 0) != 0); - setShowWeaponRanges(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowWeaponRanges", 0) != 0); - setShowGarrisoned(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowGarrisoned", 0) != 0); - setHighlightTestArt(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "HighlightTestArt", 0) != 0); - setShowLetterbox(::AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowLetterbox", 0) != 0); -} - -// ---------------------------------------------------------------------------- -WbView3d::~WbView3d() -{ - for (Int i=0; iRemove(); - REF_PTR_RELEASE(m_lightFeedbackMesh[i]); - } - } - REF_PTR_RELEASE(m_drawObject) ; - REF_PTR_RELEASE(m_heightMapRenderObj); - W3DShaderManager::shutdown(); - shutdownWW3D(); -} -// ---------------------------------------------------------------------------- -void WbView3d::shutdownWW3D() -{ - delete m_intersector; - m_intersector = nullptr; - - delete m_layer; - m_layer = nullptr; - - delete m_buildLayer; - m_buildLayer = nullptr; - - if (m3DFont) { - m3DFont->Release(); - m3DFont = nullptr; - } - if (m_ww3dInited) { - m_lightList.Reset_List(); - - if (m_assetManager) { - PredictiveLODOptimizerClass::Free(); /// @todo: where does this need to be done? - m_assetManager->Free_Assets(); - delete m_assetManager; - m_assetManager = nullptr; - } - - if (TheW3DShadowManager) - { - TheW3DShadowManager->removeAllShadows(); - delete TheW3DShadowManager; - TheW3DShadowManager=nullptr; - } - REF_PTR_RELEASE(m_transparentObjectsScene); - REF_PTR_RELEASE(m_overlayScene); - REF_PTR_RELEASE(m_baseBuildScene); - REF_PTR_RELEASE(m_objectToolTrackingObj); - REF_PTR_RELEASE(m_scene); - REF_PTR_RELEASE(m_camera); - REF_PTR_RELEASE(m_heightMapRenderObj); - REF_PTR_RELEASE(m_drawObject); - for (Int i=0; iReleaseResources(); - } - if (m3DFont) { - m3DFont->Release(); - } - m3DFont = nullptr; - if (m_drawObject) { - m_drawObject->freeMapResources(); - } -} - -//============================================================================= -// WbView3d::ReAcquireResources -//============================================================================= -/** Reallocates all W3D assets after a reset.. */ -//============================================================================= -void WbView3d::ReAcquireResources() -{ - if (TheTerrainRenderObject) { - TheTerrainRenderObject->ReAcquireResources(); - TheTerrainRenderObject->loadRoadsAndBridges(nullptr,FALSE); - TheTerrainRenderObject->worldBuilderUpdateBridgeTowers( m_assetManager, m_scene ); - } - m_drawObject->initData(); - IDirect3DDevice8* pDev = DX8Wrapper::_Get_D3D_Device8(); - if (pDev) { - -// CDC* pDC = GetDC(); - LOGFONT logFont; - logFont.lfHeight = 20; - logFont.lfWidth = 0; - logFont.lfEscapement = 0; - logFont.lfOrientation = 0; - logFont.lfWeight = FW_REGULAR; - logFont.lfItalic = FALSE; - logFont.lfUnderline = FALSE; - logFont.lfStrikeOut = FALSE; - logFont.lfCharSet = ANSI_CHARSET; - logFont.lfOutPrecision = OUT_DEFAULT_PRECIS; - logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; - logFont.lfQuality = DEFAULT_QUALITY; - logFont.lfPitchAndFamily = DEFAULT_PITCH; - strcpy(logFont.lfFaceName, "Arial"); - - HFONT hFont = CreateFontIndirect(&logFont); - if (hFont) { - D3DXCreateFont(pDev, hFont, &m3DFont); - DeleteObject(hFont); - } else { - m3DFont = nullptr; - } - - } else { - m3DFont = nullptr; - } - -} - -// ---------------------------------------------------------------------------- -void WbView3d::killTheTimer() -{ - if (m_timer != 0) { - KillTimer(m_timer); - m_timer = 0; - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::reset3dEngineDisplaySize(Int width, Int height) -{ - if (m_actualWinSize.x == width && - m_actualWinSize.y == height) { - return; - } - bogusTacticalView.setWidth(width); - bogusTacticalView.setHeight(height); - bogusTacticalView.setOrigin(0,0); - m_actualWinSize.x = width; - m_actualWinSize.y = height; - if (m_ww3dInited) { - WW3D::Set_Device_Resolution(m_actualWinSize.x, m_actualWinSize.y, true); - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::initAssets() -{ - - m_assetManager = new W3DAssetManager; - m_assetManager->Register_Prototype_Loader(&_ParticleEmitterLoader ); - m_assetManager->Register_Prototype_Loader(&_AggregateLoader); - m_assetManager->Set_WW3D_Load_On_Demand(true); -} - -// ---------------------------------------------------------------------------- -#define TERRAIN_SAMPLE_SIZE 40.0f -static Real getHeightAroundPos(WBHeightMap *heightMap, Real x, Real y) -{ - Real terrainHeight = heightMap->getHeightMapHeight(x, y, nullptr); - - // find best approximation of max terrain height we can see - Real terrainHeightMax = terrainHeight; - terrainHeightMax = max(terrainHeightMax, heightMap->getHeightMapHeight(x+TERRAIN_SAMPLE_SIZE, y-TERRAIN_SAMPLE_SIZE, nullptr)); - terrainHeightMax = max(terrainHeightMax, heightMap->getHeightMapHeight(x-TERRAIN_SAMPLE_SIZE, y-TERRAIN_SAMPLE_SIZE, nullptr)); - terrainHeightMax = max(terrainHeightMax, heightMap->getHeightMapHeight(x+TERRAIN_SAMPLE_SIZE, y+TERRAIN_SAMPLE_SIZE, nullptr)); - terrainHeightMax = max(terrainHeightMax, heightMap->getHeightMapHeight(x-TERRAIN_SAMPLE_SIZE, y+TERRAIN_SAMPLE_SIZE, nullptr)); - - return terrainHeightMax; -} - -// ---------------------------------------------------------------------------- -void WbView3d::setupCamera() -{ - Matrix3D camtransform(1); - float zOffset = - m_mouseWheelOffset / 1200; - Real zoom = 1.0f; - if (zOffset != 0) { - Real zPos = (m_cameraOffset.length()-m_groundLevel)/m_cameraOffset.length(); - Real zAbs = zOffset + zPos; - if (zAbs<0) zAbs = -zAbs; - if (zAbs<0.01) zAbs = 0.01f; - //DEBUG_LOG(("zOffset = %.2f, zAbs = %.2f, zPos = %.2f", zOffset, zAbs, zPos)); - if (zOffset > 0) { - zOffset *= zAbs; - } else if (zOffset < -0.3f) { - zOffset = -0.15f + zOffset/2.0f; - } - if (zOffset < -0.6f) { - zOffset = -0.3f + zOffset/2.0f; - } - //DEBUG_LOG(("zOffset = %.2f", zOffset)); - zoom = zAbs; - } - -///////////////////////////////////////////////////////////////// - Vector3 sourcePos, targetPos; - - Real angle = m_cameraAngle; - Real pitch = 0; - Coord3D pos; - pos.x = m_centerPt.X* MAP_XY_FACTOR; - pos.y = m_centerPt.Y* MAP_XY_FACTOR; - pos.z = m_centerPt.Z* MAP_XY_FACTOR; - - Real groundLevel = m_heightMapRenderObj?getHeightAroundPos(m_heightMapRenderObj, pos.x, pos.y) : 0; - - // set position of camera itself - /* - sourcePos.X = m_cameraOffset.x; - sourcePos.Y = m_cameraOffset.y; - sourcePos.Z = m_cameraOffset.z; - */ - sourcePos.X = m_cameraOffset.x * zoom; - sourcePos.Y = m_cameraOffset.y * zoom; - sourcePos.Z = m_cameraOffset.z * zoom; - - // camera looking at origin - targetPos.X = 0; - targetPos.Y = 0; - targetPos.Z = 0; - - - Real factor = 1.0 - (groundLevel/sourcePos.Z ); - - // construct a matrix to rotate around the up vector by the given angle - Matrix3D angleTransform( Vector3( 0.0f, 0.0f, 1.0f ), angle ); - - // construct a matrix to rotate around the horizontal vector by the given angle - Matrix3D pitchTransform( Vector3( 1.0f, 0.0f, 0.0f ), pitch ); - - // rotate camera position (pitch, then angle) -#ifdef ALLOW_TEMPORARIES - sourcePos = pitchTransform * sourcePos; - sourcePos = angleTransform * sourcePos; -#else - pitchTransform.mulVector3(sourcePos); - angleTransform.mulVector3(sourcePos); -#endif - //sourcePos *= factor+zOffset; - sourcePos *= factor; - - // translate to current XY position - sourcePos.X += pos.x; - sourcePos.Y += pos.y; - sourcePos.Z += pos.z+groundLevel; - - targetPos.X += pos.x; - targetPos.Y += pos.y; - targetPos.Z += pos.z+groundLevel; - - // do fxPitch adjustment - Real height = sourcePos.Z - targetPos.Z; - height *= m_FXPitch; - targetPos.Z = sourcePos.Z - height; - - // Just for kicks, lets see how high we are above the ground - m_actualHeightAboveGround = m_cameraOffset.z * zoom - groundLevel; - m_cameraSource = sourcePos; - m_cameraTarget = targetPos; - /* - DEBUG_LOG(("Camera: pos=(%g,%g) height=%g pitch=%g FXPitch=%g yaw=%g groundLevel=%g", - targetPos.X, targetPos.Y, - m_actualHeightAboveGround, - pitch, - m_FXPitch, - angle, m_groundLevel)); - */ - - // build new camera transform - camtransform.Make_Identity(); - if (factor < 0) { //WST 11/11/02. Fix camera flipping over when near the ground too early - targetPos = sourcePos + (sourcePos-targetPos); - } - camtransform.Look_At( sourcePos, targetPos, 0 ); - ///////////////////////////////////////////////////////////// - targetPos.Z = 0; - Real lookDistance = (targetPos-sourcePos).Length(); - Real nearZ, farZ; - if (lookDistance < 300) lookDistance = 300; - m_camera->Get_Clip_Planes(nearZ, farZ); - m_camera->Set_Clip_Planes(lookDistance/200, lookDistance*3); - - if (m_heightMapRenderObj) { - if (m_projection) { - camtransform.Make_Identity(); - camtransform.Set_Translation(Vector3(targetPos.X, targetPos.Y, lookDistance)); - m_heightMapRenderObj->setFlattenHeights(true); - //m_camera->Set_Projection_Type(CameraClass::ORTHO); - } else { - m_heightMapRenderObj->setFlattenHeights(false); - //m_camera->Set_Projection_Type(CameraClass::PERSPECTIVE); - } - } - m_camera->Set_Transform( camtransform ); - if (m_heightMapRenderObj) { - m_heightMapRenderObj->setDrawEntireMap(m_showEntireMap); - } -// not needed, handled in OnSize -// m_camera->Set_Aspect_Ratio((float)m_actualWinSize.x/(float)m_actualWinSize.y); -} - -// ---------------------------------------------------------------------------- -void WbView3d::init3dScene() -{ - // build scene - REF_PTR_RELEASE(m_overlayScene); - REF_PTR_RELEASE(m_transparentObjectsScene); - REF_PTR_RELEASE(m_baseBuildScene); - REF_PTR_RELEASE(m_scene); - REF_PTR_RELEASE(m_camera); - REF_PTR_RELEASE(m_heightMapRenderObj); - - m_scene = NEW_REF(SkeletonSceneClass,()); -#ifdef SAMPLE_DYNAMIC_LIGHT - REF_PTR_RELEASE(theDynamicLight); - theDynamicLight = NEW_REF(W3DDynamicLight, ()); - Real red = 1; - Real green = 1; - Real blue = 0; - if(red==0 && blue==0 && green==0) { - red = green = blue = 1; - } - theDynamicLight->Set_Ambient( Vector3( red, green, blue ) ); - theDynamicLight->Set_Diffuse( Vector3( red, green, blue) ); - theDynamicLight->Set_Position(Vector3(211, 363, 10)); - theDynamicLight->Set_Far_Attenuation_Range(5, 15); - // Note: Don't Add_Render_Object dynamic lights. - m_scene->addDynamicLight( theDynamicLight ); -#endif - m_overlayScene = NEW_REF(SkeletonSceneClass,()); - m_baseBuildScene = NEW_REF(SkeletonSceneClass,()); - m_transparentObjectsScene = NEW_REF(SkeletonSceneClass,()); -// m_scene->Set_Polygon_Mode(SceneClass::LINE); - m_scene->Set_Ambient_Light(Vector3(0.5f,0.5f,0.5f)); - m_overlayScene->Set_Ambient_Light(Vector3(0.5f,0.5f,0.5f)); - m_baseBuildScene->Set_Ambient_Light(Vector3(0.5f,0.5f,0.5f)); - - // Scene needs camera to be rendered with ---------------------------------- - m_camera = NEW_REF(CameraClass,()); - -} - -// ---------------------------------------------------------------------------- -void WbView3d::resetRenderObjects() -{ - if (!m_scene) return; - if (TheW3DShadowManager) { - TheW3DShadowManager->removeAllShadows(); - } - - SceneIterator *sceneIter = m_scene->Create_Iterator(); - sceneIter->First(); - while(!sceneIter->Is_Done()) { - RenderObjClass * robj = sceneIter->Current_Item(); - robj->Add_Ref(); - m_scene->Remove_Render_Object(robj); - robj->Release_Ref(); - sceneIter->Next(); - } - m_scene->Destroy_Iterator(sceneIter); - sceneIter = m_baseBuildScene->Create_Iterator(); - sceneIter->First(); - while(!sceneIter->Is_Done()) { - RenderObjClass * robj = sceneIter->Current_Item(); - robj->Add_Ref(); - m_baseBuildScene->Remove_Render_Object(robj); - robj->Release_Ref(); - sceneIter->Next(); - } - m_baseBuildScene->Destroy_Iterator(sceneIter); - MapObject *pMapObj = MapObject::getFirstMapObject(); - // Erase references to render objs that have been removed. - while (pMapObj) - { - pMapObj->setRenderObj(nullptr); - pMapObj = pMapObj->getNext(); - } - - Int i; - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - BuildListInfo *pBuild = pSide->getBuildList(); - while (pBuild) { - pBuild->setRenderObj(nullptr); - pBuild = pBuild->getNext(); - } - } - - m_needToLoadRoads = true; // load roads next time we redraw. - - if (TheW3DShadowManager) - TheW3DShadowManager->Reset(); - - updateLights(); - if (m_heightMapRenderObj) { - m_scene->Add_Render_Object(m_heightMapRenderObj); - m_heightMapRenderObj->removeAllTrees(); - m_heightMapRenderObj->removeAllProps(); - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::stepTimeOfDay() -{ - TheWritableGlobalData->m_timeOfDay = (TimeOfDay)(TheGlobalData->m_timeOfDay+1); - if (TheGlobalData->m_timeOfDay >= TIME_OF_DAY_COUNT) { - TheWritableGlobalData->m_timeOfDay = TIME_OF_DAY_FIRST; - } - resetRenderObjects(); - invalObjectInView(nullptr); -} - -// ---------------------------------------------------------------------------- -void WbView3d::setLighting(const GlobalData::TerrainLighting *tl, Int whichLighting, Int whichLight) -{ - if (whichLighting == GlobalLightOptions::K_TERRAIN) { - TheWritableGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][whichLight]= *tl; - } else if (whichLighting == GlobalLightOptions::K_OBJECTS) { - TheWritableGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][whichLight] = *tl; - } else if (whichLighting == GlobalLightOptions::K_BOTH) { - TheWritableGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][whichLight] = *tl; - TheWritableGlobalData->m_terrainLighting[TheGlobalData->m_timeOfDay][whichLight] = *tl; - } - const GlobalData::TerrainLighting *ol = &TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][whichLight]; - TheWritableGlobalData->setTimeOfDay(TheGlobalData->m_timeOfDay); - if( m_globalLight ) { - m_globalLight[whichLight]->Set_Ambient( Vector3( 0.0f, 0.0f, 0.0f ) ); - m_globalLight[whichLight]->Set_Diffuse( Vector3(ol->diffuse.red, ol->diffuse.green, ol->diffuse.blue ) ); - m_globalLight[whichLight]->Set_Specular( Vector3(0,0,0) ); - Matrix3D mtx; - mtx.Set(Vector3(1,0,0), Vector3(0,1,0), Vector3(ol->lightPos.x, ol->lightPos.y, ol->lightPos.z), Vector3(0,0,0)); - m_globalLight[whichLight]->Set_Transform(mtx); - if( m_scene && whichLight == 0) { //only let the first light contribute to ambient - m_scene->Set_Ambient_Light( Vector3(ol->ambient.red, ol->ambient.green, ol->ambient.blue) ); - m_baseBuildScene->Set_Ambient_Light( Vector3(ol->ambient.red, ol->ambient.green, ol->ambient.blue) ); - } - } - if(TheTerrainRenderObject) { - TheTerrainRenderObject->setTimeOfDay(TheGlobalData->m_timeOfDay); - } - if (TheW3DShadowManager) { - TheW3DShadowManager->setTimeOfDay(TheGlobalData->m_timeOfDay); - } - m_needToLoadRoads = true; // load roads next time we redraw. - Invalidate(false); -} - -// ---------------------------------------------------------------------------- -void WbView3d::updateLights() -{ - ++m_updateCount; - - // Update lights list. - m_lightList.Reset_List(); - - { - TheWritableGlobalData->setTimeOfDay(TheGlobalData->m_timeOfDay); - const GlobalData::TerrainLighting *ol = &TheGlobalData->m_terrainObjectsLighting[TheGlobalData->m_timeOfDay][0]; - - if( m_scene ) - { - m_scene->Set_Ambient_Light( Vector3(ol->ambient.red, ol->ambient.green, ol->ambient.blue) ); - m_baseBuildScene->Set_Ambient_Light( Vector3(ol->ambient.red, ol->ambient.green, ol->ambient.blue) ); - } - - if (TheW3DShadowManager) { - TheW3DShadowManager->setTimeOfDay(TheGlobalData->m_timeOfDay); - } - - for (Int i=0; im_terrainObjectsLighting[TheGlobalData->m_timeOfDay][i]; - m_globalLight[i]->Set_Ambient( Vector3( 0.0f, 0.0f, 0.0f ) ); - m_globalLight[i]->Set_Diffuse( Vector3(ol->diffuse.red, ol->diffuse.green, ol->diffuse.blue ) ); - m_globalLight[i]->Set_Specular( Vector3(0,0,0) ); - Matrix3D mtx; - mtx.Set(Vector3(1,0,0), Vector3(0,1,0), Vector3(ol->lightPos.x, ol->lightPos.y, ol->lightPos.z), Vector3(0,0,0)); - m_globalLight[i]->Set_Transform(mtx); - m_scene->setGlobalLight(m_globalLight[i],i); - m_baseBuildScene->setGlobalLight(m_globalLight[i],i); - } - } - if(TheTerrainRenderObject) { - TheTerrainRenderObject->setTimeOfDay(TheGlobalData->m_timeOfDay); - } - - - } - - MapObject *pMapObj = MapObject::getFirstMapObject(); - while (pMapObj && m_heightMapRenderObj) { - if (pMapObj->isLight()) { - Coord3D loc = *pMapObj->getLocation(); - loc.z += m_heightMapRenderObj->getHeightMapHeight(loc.x, loc.y, nullptr); - RenderObjClass *renderObj= pMapObj->getRenderObj(); - if (renderObj) { - m_scene->Remove_Render_Object(renderObj); - pMapObj->setRenderObj(nullptr); - } - // It is a light, and handled at the device level. jba. - LightClass* lightP = NEW_REF(LightClass, (LightClass::POINT)); - - Dict *props = pMapObj->getProperties(); - - Real lightHeightAboveTerrain, lightInnerRadius, lightOuterRadius; - RGBColor lightAmbientColor, lightDiffuseColor; - lightHeightAboveTerrain = props->getReal(TheKey_lightHeightAboveTerrain); - lightInnerRadius = props->getReal(TheKey_lightInnerRadius); - lightOuterRadius = props->getReal(TheKey_lightOuterRadius); - lightAmbientColor.setFromInt(props->getInt(TheKey_lightAmbientColor)); - lightDiffuseColor.setFromInt(props->getInt(TheKey_lightDiffuseColor)); - - lightP->Set_Ambient( Vector3( lightAmbientColor.red, lightAmbientColor.green, lightAmbientColor.blue ) ); - lightP->Set_Diffuse( Vector3( lightDiffuseColor.red, lightDiffuseColor.green, lightDiffuseColor.blue) ); - - lightP->Set_Position(Vector3(loc.x, loc.y, loc.z+lightHeightAboveTerrain)); - - lightP->Set_Far_Attenuation_Range(lightInnerRadius, lightOuterRadius); - - m_lightList.Add(lightP); - m_scene->Add_Render_Object(lightP); - pMapObj->setRenderObj(lightP); - REF_PTR_RELEASE( lightP ); - } - pMapObj = pMapObj->getNext(); - } - - --m_updateCount; -} - -// ---------------------------------------------------------------------------- -void WbView3d::updateScorches() -{ - TheTerrainRenderObject->clearAllScorches(); - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - if (pMapObj->isScorch()) - { - const Coord3D *pos = pMapObj->getLocation(); - Real radius = pMapObj->getProperties()->getReal(TheKey_objectRadius); - Scorches type = (Scorches) pMapObj->getProperties()->getInt(TheKey_scorchType); - - Vector3 loc(pos->x, pos->y, pos->z); - TheTerrainRenderObject->addScorch(loc, radius, type); - } - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::updateTrees() -{ - TheTerrainRenderObject->removeAllTrees(); - TheTerrainRenderObject->removeAllProps(); - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - const ThingTemplate *tTemplate; - - tTemplate = pMapObj->getThingTemplate(); - if (tTemplate && tTemplate->isKindOf(KINDOF_OPTIMIZED_TREE) ) - { - Real scale = tTemplate->getAssetScale(); - const ModuleInfo& mi = tTemplate->getDrawModuleInfo(); - if (mi.getCount() > 0) - { - const ModuleData* mdd = mi.getNthData(0); - AsciiString name = KEYNAME(mdd->getModuleTagNameKey()); - const W3DTreeDrawModuleData* md = mdd ? mdd->getAsW3DTreeDrawModuleData(): nullptr; - if (md) - { - Coord3D pos = *pMapObj->getLocation(); - if (m_heightMapRenderObj) { - pos.z += m_heightMapRenderObj->getHeightMapHeight(pos.x, pos.y, nullptr); - TheTerrainRenderObject->addTree((DrawableID)(Int)pMapObj, pos, scale, pMapObj->getAngle(), - 0.0f /*no random scaling*/, md); - } - } - } - } - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::invalidateCellInView(int xIndex, int yIndex) -{ - Invalidate(false); /// @todo be smarter about invaling the area -} - -// ---------------------------------------------------------------------------- -void WbView3d::updateFenceListObjects(MapObject *pObject) -{ - MapObject *pMapObj; - for (pMapObj = pObject; pMapObj; pMapObj = pMapObj->getNext()) - { - - Coord3D loc = *pMapObj->getLocation(); - loc.z += m_heightMapRenderObj->getHeightMapHeight(loc.x, loc.y, nullptr); - - RenderObjClass *renderObj=nullptr; - REF_PTR_SET( renderObj, pMapObj->getRenderObj() ); - if (!renderObj) { - Real scale = 1.0; - AsciiString modelName = getModelNameAndScale(pMapObj, &scale, BODY_PRISTINE); - // set render object, or create if we need to - if( renderObj == nullptr && modelName.isEmpty() == FALSE && - strncmp( modelName.str(), "No ", 3 ) ) - { - - renderObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, 0); - - } - } - - if (renderObj) { - pMapObj->setRenderObj(renderObj); - - // set item's position to loc, and get scale from item and apply it. - - Matrix3D renderObjPos(true); // init to identity - renderObjPos.Translate(loc.x, loc.y, loc.z); - renderObjPos.Rotate_Z(pMapObj->getAngle()); - renderObj->Set_Transform( renderObjPos ); - - - m_scene->Add_Render_Object(renderObj); - - REF_PTR_RELEASE(renderObj); // belongs to m_scene now. - } - } - - Invalidate(false); -} - - -// ---------------------------------------------------------------------------- -void WbView3d::removeFenceListObjects(MapObject *pObject) -{ - MapObject *pMapObj; - for (pMapObj = pObject; pMapObj; pMapObj = pMapObj->getNext()) - { - if (pMapObj->getRenderObj()) { - m_scene->Remove_Render_Object(pMapObj->getRenderObj()); - pMapObj->setRenderObj(nullptr); - } - } - - Invalidate(false); -} - -// ---------------------------------------------------------------------------- -/// @todo srj -- this is a terrible hack, since things can have multiple models, and it's private info. fix later. -AsciiString WbView3d::getBestModelName(const ThingTemplate* tt, const ModelConditionFlags& c) -{ - if (tt) - { - const ModuleInfo& mi = tt->getDrawModuleInfo(); - if (mi.getCount() > 0) - { -// const W3DModelDrawModuleData* md = dynamic_cast(mi->getNthData(0)); - const ModuleData* mdd = mi.getNthData(0); - const W3DModelDrawModuleData* md = mdd ? mdd->getAsW3DModelDrawModuleData() : nullptr; - if (md) - { - return md->getBestModelNameForWB(c); - } - - // TheSuperHackers @bugfix ViTeXFTW 15/02/2026 Fix tree objects not showing a preview in - // WB object placer. The W3DTreeDraw module stores its model name differently from W3DModelDraw. - const W3DTreeDrawModuleData* treeData = mdd ? mdd->getAsW3DTreeDrawModuleData() : nullptr; - if (treeData) - { - return treeData->m_modelName; - } - } - } - // removing this crash as sounds can (and should) have no model - jkmcd - return AsciiString::TheEmptyString; -} - -// ---------------------------------------------------------------------------- -void WbView3d::invalBuildListItemInView(BuildListInfo *pBuildToInval) -{ - Int i; - Bool found = false; - - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - - // find which player color we should use - Int playerColor = 0xFFFFFF; - const Dict *sideDict = pSide->getDict(); - if (sideDict) - { - Bool exists = false; - Int color = sideDict->getInt(TheKey_playerColor, &exists); - if (exists) - { - playerColor = color; - } - } - - - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - if (pBuildToInval == pBuild) { - found = true; - } - if (!found && pBuildToInval) { - continue; - } - if (!BuildListTool::isActive() && !pBuild->isInitiallyBuilt()) { - continue; - } - // Update. - Coord3D loc = *pBuild->getLocation(); - loc.z += m_heightMapRenderObj->getHeightMapHeight(loc.x, loc.y, nullptr); - RenderObjClass *renderObj=nullptr; - Shadow *shadowObj=nullptr; - // Build list render obj is not refcounted, so check & make sure it exists in the scene. - if (pBuild->getRenderObj()) { - if (!m_baseBuildScene->safeContains(pBuild->getRenderObj())) { - pBuild->setRenderObj(nullptr); - } - } - - REF_PTR_SET(renderObj, pBuild->getRenderObj()); - if (!renderObj) { - Real scale = 1.0; - AsciiString thingName = pBuild->getTemplateName(); - const ThingTemplate *tTemplate = TheThingFactory->findTemplate(thingName); - - AsciiString modelName = "No Model Name"; - if (tTemplate) { - ModelConditionFlags state; - state.clear(); - modelName = getBestModelName(tTemplate, state); - scale = tTemplate->getAssetScale(); - } - // set render object, or create if we need to - if( renderObj == nullptr && modelName.isEmpty() == FALSE && - strncmp( modelName.str(), "No ", 3 ) ) - { - - renderObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, playerColor); - if( m_showShadows && tTemplate->getShadowType() != SHADOW_NONE) - { - //add correct type of shadow - Shadow::ShadowTypeInfo shadowInfo; - shadowInfo.allowUpdates=FALSE; //shadow image will never update - shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects - strlcpy(shadowInfo.m_ShadowName, tTemplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); - DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); - shadowInfo.m_type=(ShadowType)tTemplate->getShadowType(); - shadowInfo.m_sizeX=tTemplate->getShadowSizeX(); - shadowInfo.m_sizeY=tTemplate->getShadowSizeY(); - shadowInfo.m_offsetX=tTemplate->getShadowOffsetX(); - shadowInfo.m_offsetY=tTemplate->getShadowOffsetY(); - shadowObj=TheW3DShadowManager->addShadow(renderObj, &shadowInfo); - } - } - } - if (renderObj) { - pBuild->setRenderObj(renderObj); - pBuild->setShadowObj(shadowObj); - // set item's position to loc. - Matrix3D renderObjPos(true); // init to identity - renderObjPos.Translate(loc.x, loc.y, loc.z); - renderObjPos.Rotate_Z(pBuild->getAngle()); - renderObj->Set_Transform( renderObjPos ); - - m_baseBuildScene->Add_Render_Object(renderObj); - - REF_PTR_RELEASE(renderObj); // belongs to m_scene now. - } - if (found) break; - } - } - - // Build list render obj is not refcounted, so check & make sure it exists in the scene. - if (!found && pBuildToInval && pBuildToInval->getRenderObj()) { - if (!m_baseBuildScene->safeContains(pBuildToInval->getRenderObj())) { - pBuildToInval->setRenderObj(nullptr); - } - } - if (!found && pBuildToInval && pBuildToInval->getRenderObj()) { - m_baseBuildScene->Remove_Render_Object(pBuildToInval->getRenderObj()); - pBuildToInval->setRenderObj(nullptr); - } - Invalidate(false); -} - - -AsciiString WbView3d::getModelNameAndScale(MapObject *pMapObj, Real *scale, BodyDamageType curDamageState) -{ - ModelConditionFlags state; - switch (curDamageState) - { - case BODY_PRISTINE: - default: - state.clear(); - break; - - case BODY_DAMAGED: - state.set(MODELCONDITION_DAMAGED); - break; - - case BODY_REALLYDAMAGED: - state.set(MODELCONDITION_REALLY_DAMAGED); - break; - - case BODY_RUBBLE: - state.set(MODELCONDITION_RUBBLE); - break; - } - - if (getShowGarrisoned()) - { - state.set(MODELCONDITION_GARRISONED); - } - Int objWeather = 0; - Bool exists; - if (pMapObj && pMapObj->getProperties()) - { - objWeather = pMapObj->getProperties()->getInt(TheKey_objectWeather, &exists); - } - switch (objWeather) - { - default: - case 0: - if (TheGlobalData->m_weather == WEATHER_SNOWY) - { - state.set(MODELCONDITION_SNOW); - } - break; - case 2: - state.set(MODELCONDITION_SNOW); - break; - } - - Int objTime = 0; - if (pMapObj && pMapObj->getProperties()) - { - objTime = pMapObj->getProperties()->getInt(TheKey_objectTime, &exists); - } - switch (objTime) - { - default: - case 0: - if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT) - { - state.set(MODELCONDITION_NIGHT); - } - break; - case 2: - state.set(MODELCONDITION_NIGHT); - break; - } - - AsciiString modelName; - *scale = 1.0f; - -#ifdef LOAD_TEST_ASSETS - char buffer[ _MAX_PATH ]; - - if (strncmp(TEST_STRING, pMapObj->getName().str(), strlen(TEST_STRING)) == 0) - { - /* Handle test art models here */ - strlcpy(buffer, pMapObj->getName().str(), ARRAY_SIZE(buffer)); - - Int i; - for (i=0; buffer[i]; i++) { - if (buffer[i] == '/') { - i++; - break; - } - } - modelName = buffer+i; - } -#endif - - if (modelName.isEmpty()) - { - modelName = "No Model Name"; // must be this while GDF exists (it's the default) - const ThingTemplate *tTemplate; - - tTemplate = pMapObj->getThingTemplate(); - if( tTemplate && !(pMapObj->getFlags() & FLAG_DONT_RENDER)) - { - - // get visual data from the thing template - modelName = getBestModelName(tTemplate, state); - *scale = tTemplate->getAssetScale(); - - } - } - return modelName; -} - -// ---------------------------------------------------------------------------- -void WbView3d::invalObjectInView(MapObject *pMapObjIn) -{ - ++m_updateCount; - Bool updateAllTrees = false; - if (m_heightMapRenderObj == nullptr) { - m_heightMapRenderObj = NEW_REF(WBHeightMap,()); - - m_scene->Add_Render_Object(m_heightMapRenderObj); - } - if (pMapObjIn == nullptr) { - invalBuildListItemInView(nullptr); - } - Bool found = false; - Bool isRoad = false; - Bool isLight = false; - Bool isScorch = false; - if (pMapObjIn == nullptr) - isScorch = true; - MapObject *pMapObj; - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) - { - if (found) break; - if (pMapObjIn == pMapObj) - found = true; - if (pMapObjIn != nullptr && !found) { - continue; - } - if (pMapObj->getFlags() & (FLAG_ROAD_FLAGS|FLAG_BRIDGE_FLAGS)) { - isRoad = true; - continue; // Roads don't create drawable objects. - } - if (pMapObj->isLight() ) { - isLight = true; - continue; // Lights don't create drawable objects. - } - if (pMapObj->isScorch()) { - if (pMapObj == pMapObjIn) { - isScorch = true; - } - continue; - } - - - Coord3D loc = *pMapObj->getLocation(); - loc.z += m_heightMapRenderObj->getHeightMapHeight(loc.x, loc.y, nullptr); - - const ThingTemplate *tTemplate = pMapObj->getThingTemplate(); - if (tTemplate && tTemplate->isKindOf(KINDOF_OPTIMIZED_TREE)) { - if (!m_heightMapRenderObj->updateTreePosition((DrawableID)(Int)pMapObj, loc, pMapObj->getAngle())) { - // Couldn't find it, so update them all. [5/27/2003] - updateAllTrees = true; - } - if (found) break; - } - - RenderObjClass *renderObj=nullptr; - Shadow *shadowObj=nullptr; - - REF_PTR_SET( renderObj, pMapObj->getRenderObj() ); - Int playerColor = 0xFFFFFF; - BodyDamageType curDamageState = BODY_PRISTINE; - Bool isVehicle = false; - - Bool exists; - if (tTemplate && !(pMapObj->getFlags() & FLAG_DONT_RENDER)) - { - isVehicle = tTemplate->isKindOf(KINDOF_VEHICLE); - AsciiString objectTeamName = pMapObj->getProperties()->getAsciiString(TheKey_originalOwner, &exists); - if (exists) { - TeamsInfo *teamInfo = TheSidesList->findTeamInfo(objectTeamName); - if (teamInfo) { - AsciiString teamOwner = teamInfo->getDict()->getAsciiString(TheKey_teamOwner); - SidesInfo* pSide = TheSidesList->findSideInfo(teamOwner); - if (pSide) { - Bool hasColor = false; - Int color = pSide->getDict()->getInt(TheKey_playerColor, &hasColor); - if (hasColor) { - playerColor = color; - } else { - AsciiString tmplname = pSide->getDict()->getAsciiString(TheKey_playerFaction); - const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(tmplname)); - if (pt) { - playerColor = pt->getPreferredColor()->getAsInt(); - } - } - } - } - } - } - Int health = 100; - health = pMapObj->getProperties()->getInt(TheKey_objectInitialHealth, &exists); - Real ratio = health/100.0; - if (ratio > TheGlobalData->m_unitDamagedThresh) - { - curDamageState = BODY_PRISTINE; - } - else if (ratio > TheGlobalData->m_unitReallyDamagedThresh) - { - curDamageState = BODY_DAMAGED; - } - else if (ratio > 0.0f) - { - curDamageState = BODY_REALLYDAMAGED; - } - else - { - curDamageState = BODY_RUBBLE; - } - - - if (!renderObj) { - Real scale = 1.0; - AsciiString modelName = getModelNameAndScale(pMapObj, &scale, curDamageState); - // set render object, or create if we need to - if( renderObj == nullptr && modelName.isEmpty() == FALSE && - strncmp( modelName.str(), "No ", 3 ) ) - { - - if (!getShowModels()) { - continue; - } - renderObj = m_assetManager->Create_Render_Obj( modelName.str(), scale, playerColor); - if( m_showShadows ) - { - Shadow::ShadowTypeInfo shadowInfo; - shadowInfo.allowUpdates=FALSE; //shadow image will never update - shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects - if (tTemplate && tTemplate->getShadowType() != SHADOW_NONE && !(pMapObj->getFlags() & FLAG_DONT_RENDER)) - { //add correct type of shadow - strlcpy(shadowInfo.m_ShadowName, tTemplate->getShadowTextureName().str(), ARRAY_SIZE(shadowInfo.m_ShadowName)); - DEBUG_ASSERTCRASH(shadowInfo.m_ShadowName[0] != '\0', ("this should be validated in ThingTemplate now")); - shadowInfo.m_type=(ShadowType)tTemplate->getShadowType(); - shadowInfo.m_sizeX=tTemplate->getShadowSizeX(); - shadowInfo.m_sizeY=tTemplate->getShadowSizeY(); - shadowInfo.m_offsetX=tTemplate->getShadowOffsetX(); - shadowInfo.m_offsetY=tTemplate->getShadowOffsetY(); - shadowObj=TheW3DShadowManager->addShadow(renderObj, &shadowInfo); - } else if (!tTemplate) { - shadowInfo.m_type=(ShadowType)SHADOW_VOLUME; - shadowObj=TheW3DShadowManager->addShadow(renderObj, &shadowInfo); - } - } - } - } - - if (renderObj && !(pMapObj->getFlags() & FLAG_DONT_RENDER)) { - pMapObj->setRenderObj(renderObj); - pMapObj->setShadowObj(shadowObj); - - // set item's position to loc, and get scale from item and apply it. - - Matrix3D renderObjPos(true); // init to identity - renderObjPos.Translate(loc.x, loc.y, loc.z); - renderObjPos.Rotate_Z(pMapObj->getAngle()); - renderObj->Set_Transform( renderObjPos ); - - if (isVehicle) { - // note that this affects our orientation, but NOT our position... specifically, - // it does NOT force us to "stick" to the ground! - Matrix3D mtx; - Coord3D terrainNormal; - m_heightMapRenderObj->getHeightMapHeight(loc.x, loc.y, &terrainNormal ); - makeAlignToNormalMatrix(pMapObj->getAngle(), loc, terrainNormal, mtx); - renderObj->Set_Transform( mtx ); - } - - m_scene->Add_Render_Object(renderObj); - - REF_PTR_RELEASE(renderObj); // belongs to m_scene now. - } else if (renderObj) { - m_scene->Remove_Render_Object(renderObj); - } - if (found) break; - } - if (!found && pMapObjIn) { - if (pMapObjIn->getFlags() & (FLAG_ROAD_FLAGS|FLAG_BRIDGE_FLAGS)) { - isRoad = true; - } - const ThingTemplate *tTemplate = pMapObjIn->getThingTemplate(); - if (tTemplate && tTemplate->isKindOf(KINDOF_OPTIMIZED_TREE)) { - updateAllTrees = true; - } - } - if (!found && pMapObjIn && pMapObjIn->getRenderObj()) { - if( m_showShadows ) { - resetRenderObjects(); - invalObjectInView(nullptr); - --m_updateCount; - return; - } - m_scene->Remove_Render_Object(pMapObjIn->getRenderObj()); - pMapObjIn->setRenderObj(nullptr); - } - - if (isRoad) { - m_needToLoadRoads = true; // load roads next time we redraw. - } - if (updateAllTrees) { - updateTrees(); - } - if (isLight) { - updateLights(); - } - if (isScorch) { - updateScorches(); - } - Invalidate(false); - - --m_updateCount; -} - - -// ---------------------------------------------------------------------------- -void WbView3d::updateHeightMapInView(WorldHeightMap *htMap, Bool partial, const IRegion2D &partialRange) -{ - if (htMap == nullptr) - return; - ++m_updateCount; - - if (m_heightMapRenderObj == nullptr) { - m_heightMapRenderObj = NEW_REF(WBHeightMap,()); - m_scene->Add_Render_Object(m_heightMapRenderObj); - partial = false; - } - - - if (m_heightMapRenderObj) { - - Int curTicks = ::GetTickCount(); - - RefRenderObjListIterator lightListIt(&m_lightList); - if (partial) { - m_heightMapRenderObj->doPartialUpdate(partialRange, htMap, &lightListIt); - } else { - if (m_showEntireMap) { - htMap->setDrawOrg(0, 0); - htMap->setDrawWidth(htMap->getXExtent()); - htMap->setDrawHeight(htMap->getYExtent()); - m_heightMapRenderObj->initHeightData(htMap->getXExtent(), htMap->getYExtent(), htMap, &lightListIt); - } else { - htMap->setDrawWidth(std::min(m_partialMapSize, htMap->getXExtent())); - htMap->setDrawHeight(std::min(m_partialMapSize, htMap->getYExtent())); - m_heightMapRenderObj->initHeightData(htMap->getDrawWidth(), htMap->getDrawHeight(), htMap, &lightListIt); - } - m_heightMapRenderObj->updateViewImpassableAreas(); - } - curTicks = GetTickCount() - curTicks; - if (curTicks < 1) curTicks = 1; - } - - invalObjectInView(nullptr); // update all the map objects, to account for ground changes - - --m_updateCount; -} - -// ---------------------------------------------------------------------------- -void WbView3d::setCenterInView(Real x, Real y) -{ - if (x != m_centerPt.X || y != m_centerPt.Y) { - m_centerPt.X = x; - m_centerPt.Y = y; - constrainCenterPt(); - redraw(); - updateHysteresis(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); - } -} - -//============================================================================= -// WbView3d::picked3dObjectInView -//============================================================================= -/** Returns true if the pixel location picks the object. */ -//============================================================================= -MapObject *WbView3d::picked3dObjectInView(CPoint viewPt) -{ - // This code picks on all 3d objects. - if (m_intersector && m_layer) { - CRect client; - this->GetClientRect(&client); - float logX = (Real)viewPt.x / (Real)client.Width(); - float logY = (Real)viewPt.y / (Real)client.Height(); - //m_intersector->Result.CollisionType = COLLISION_TYPE_0|COLLISION_TYPE_1; - // do the intersection using W3D intersector class - Bool hit = m_intersector->Intersect_Screen_Point_Layer( logX, logY, *m_layer ); - if( hit ) - { - MapObject *pObj; - for (pObj = MapObject::getFirstMapObject(); pObj; pObj = pObj->getNext()) { - if (pObj->getRenderObj() == m_intersector->Result.IntersectedRenderObject) { - return pObj; - } - } - } - } - - return nullptr; -} - -//============================================================================= -// WbView3d::pickedBuildObjectInView -//============================================================================= -/** Returns true if the pixel location picks the object. */ -//============================================================================= -BuildListInfo *WbView3d::pickedBuildObjectInView(CPoint viewPt) -{ - Coord3D cpt; - Int i; - viewToDocCoords(viewPt, &cpt, false); - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - Coord3D center = *pBuild->getLocation(); - center.x -= cpt.x; - center.y -= cpt.y; - center.z = 0; - Real len = center.length(); - // Check and see if we are within 1.5 cell size of the center. - if (len < 1.5f*MAP_XY_FACTOR) { - return pBuild; - } - } - } - // This code picks on all 3d build objects. - if (m_intersector && m_buildLayer) { - CRect client; - this->GetClientRect(&client); - float logX = (Real)viewPt.x / (Real)client.Width(); - float logY = (Real)viewPt.y / (Real)client.Height(); - - // do the intersection using W3D intersector class - Bool hit = m_intersector->Intersect_Screen_Point_Layer( logX, logY, *m_buildLayer ); - if( hit ) { - for (i=0; igetNumSides(); i++) { - SidesInfo *pSide = TheSidesList->getSideInfo(i); - for (BuildListInfo *pBuild = pSide->getBuildList(); pBuild; pBuild = pBuild->getNext()) { - if (pBuild->getRenderObj() == m_intersector->Result.IntersectedRenderObject) { - return pBuild; - } - } - } - } - } - - return nullptr; -} - -// ---------------------------------------------------------------------------- -Bool WbView3d::viewToDocCoords(CPoint curPt, Coord3D *newPt, Bool constrain) -{ - DEBUG_ASSERTCRASH((this),("oops")); -// const Int VIEW_BORDER = 3000; // keeps you from falling off the edge of the world. - Bool result = false; - CRect client; - this->GetClientRect(&client); - - // get our "logical" or relative screen coords - float logX = (Real)curPt.x / (Real)client.Width(); - float logY = (Real)curPt.y / (Real)client.Height(); - Vector3 intersection(0,0,0); - // determine the ray corresponding to the camera and distance to projection plane - Matrix3D camera_matrix = m_camera->Get_Transform(); - - Vector3 camera_location = m_camera->Get_Position(); - - Vector3 rayLocation; - Vector3 rayDirection; - Vector3 rayDirectionPt; - // the projected ray has the same origin as the camera - rayLocation = camera_location; - // determine the location of the screen coordinate in camera-model space - const ViewportClass &viewport = m_camera->Get_Viewport(); - - Vector2 min,max; - m_camera->Get_View_Plane(min,max); - float xscale = (max.X - min.X); - float yscale = (max.Y - min.Y); - - float zmod = -1.0; // Scene->vpd; // Note: view plane distance is now always 1.0 from the camera - float xmod = (-logX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - float ymod = (logY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - - // transform the screen coordinates by the camera's matrix into world coordinates. - float x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - float y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - float z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - - rayDirection.Set(x,y,z); - rayDirection.Normalize(); - float MaxDistance = m_camera->Get_Depth()*MAP_XY_FACTOR; - rayDirectionPt = rayLocation + rayDirection*MaxDistance; - - LineSegClass ray(rayLocation, rayDirectionPt); - - // Note - there are 2 ways to track. One is for tools (like paint texture) - // that follow the terrain. They want to track the terrain, so the texturing - // follows the cursor. Most tools, however, don't want to jump up & down clifs - // and such. So they use a fixed z plane when tracking, so things don't move - // depending what you move over. - Bool followTerrain = true; - if (WbApp()->isCurToolLocked()) { - followTerrain = WbApp()->getCurTool()->followsTerrain(); - } - if (followTerrain && TheTerrainRenderObject) { - CastResultStruct castResult; - RayCollisionTestClass rayCollide(ray, &castResult) ; - if( TheTerrainRenderObject->Cast_Ray(rayCollide) ) - { - // get the point of intersection according to W3D - intersection = castResult.ContactPoint; - m_curTrackingZ = intersection.Z; - result = true; - } - } - if (!result) { - intersection.X = Vector3::Find_X_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - intersection.Y = Vector3::Find_Y_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - result = true; - } - newPt->x = intersection.X; - newPt->y = intersection.Y; - newPt->z = MAGIC_GROUND_Z; - if (constrain) { -#if 1 - if (m_doLockAngle) { - Real dy = fabs(m_mouseDownDocPoint.y - newPt->y); - Real dx = fabs(m_mouseDownDocPoint.x - newPt->x); - if (dx>2*dy) { - // lock to dx. - newPt->y = m_mouseDownDocPoint.y; - } else if (dy>2*dx) { - //lock to dy. - newPt->x = m_mouseDownDocPoint.x; - } else { - // Lock to 45 degree. - dx = (dx+dy)/2; - dy = dx; - if (newPt->x < m_mouseDownDocPoint.x) dx = -dx; - if (newPt->y < m_mouseDownDocPoint.y) dy = -dy; - newPt->x = m_mouseDownDocPoint.x+dx; - newPt->y = m_mouseDownDocPoint.y+dy; - } - } -#else - if (m_cameraAngle > PI) { - m_cameraAngle -= 2*PI; - } - if (m_cameraAngle < -PI) { - m_cameraAngle += 2*PI; - } - Bool flip = false; - // If we are looking sideways, flip the locks. - if (PI/4m_cameraAngle && m_cameraAngle > -3*PI/4) { - flip = true; - } - - if (flip) { - if (m_doLockVertical) { - newPt->y = m_mouseDownDocPoint.y; - } else if (m_doLockHorizontal) { - newPt->x = m_mouseDownDocPoint.x; - } - } else { - if (m_doLockHorizontal) { - newPt->y = m_mouseDownDocPoint.y; - } else if (m_doLockVertical) { - newPt->x = m_mouseDownDocPoint.x; - } - } -#endif - } - return result; -} - -// ---------------------------------------------------------------------------- -Bool WbView3d::viewToDocCoordZ(CPoint curPt, Coord3D *newPt, Real theZ) -{ - DEBUG_ASSERTCRASH((this),("oops")); - CRect client; - this->GetClientRect(&client); - - // get our "logical" or relative screen coords - float logX = (Real)curPt.x / (Real)client.Width(); - float logY = (Real)curPt.y / (Real)client.Height(); - Vector3 intersection(0,0,0); - // determine the ray corresponding to the camera and distance to projection plane - Matrix3D camera_matrix = m_camera->Get_Transform(); - - Vector3 camera_location = m_camera->Get_Position(); - - Vector3 rayLocation; - Vector3 rayDirection; - Vector3 rayDirectionPt; - // the projected ray has the same origin as the camera - rayLocation = camera_location; - // determine the location of the screen coordinate in camera-model space - const ViewportClass &viewport = m_camera->Get_Viewport(); - - Vector2 min,max; - m_camera->Get_View_Plane(min,max); - float xscale = (max.X - min.X); - float yscale = (max.Y - min.Y); - - float zmod = -1.0; // Scene->vpd; // Note: view plane distance is now always 1.0 from the camera - float xmod = (-logX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - float ymod = (logY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - - // transform the screen coordinates by the camera's matrix into world coordinates. - float x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - float y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - float z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - - rayDirection.Set(x,y,z); - rayDirection.Normalize(); - float MaxDistance = m_camera->Get_Depth()*MAP_XY_FACTOR; - rayDirectionPt = rayLocation + rayDirection*MaxDistance; - - LineSegClass ray(rayLocation, rayDirectionPt); - - intersection.X = Vector3::Find_X_At_Z(theZ, rayLocation, rayDirectionPt); - intersection.Y = Vector3::Find_Y_At_Z(theZ, rayLocation, rayDirectionPt); - - newPt->x = intersection.X; - newPt->y = intersection.Y; - newPt->z = theZ; - return true; -} - -// ---------------------------------------------------------------------------- -void WbView3d::updateHysteresis() -{ - CRect client; - GetClientRect(&client); - CPoint curPt; - curPt.x = (client.left+client.right)/2; - curPt.y = (client.bottom+client.top)/2; - // get our "logical" or relative screen coords - float logX = (Real)curPt.x / (Real)client.Width(); - float logY = (Real)curPt.y / (Real)client.Height(); - Vector3 intersection(0,0,0); - // determine the ray corresponding to the camera and distance to projection plane - Matrix3D camera_matrix = m_camera->Get_Transform(); - - Vector3 camera_location = m_camera->Get_Position(); - - Vector3 rayLocation; - Vector3 rayDirection; - Vector3 rayDirectionPt; - // the projected ray has the same origin as the camera - rayLocation = camera_location; - // determine the location of the screen coordinate in camera-model space - const ViewportClass &viewport = m_camera->Get_Viewport(); - - Vector2 min,max; - m_camera->Get_View_Plane(min,max); - float xscale = (max.X - min.X); - float yscale = (max.Y - min.Y); - - float zmod = -1.0; // Scene->vpd; // Note: view plane distance is now always 1.0 from the camera - float xmod = (-logX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - float ymod = (logY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - - // transform the screen coordinates by the camera's matrix into world coordinates. - float x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - float y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - float z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - - rayDirection.Set(x,y,z); - rayDirectionPt = rayLocation + rayDirection; - - intersection.X = Vector3::Find_X_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - intersection.Y = Vector3::Find_Y_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - - // Calculate the point offset by 3 pixels. - logX = (Real)(curPt.x+3) / (Real)client.Width(); - Vector3 offset(0,0,0); - - xmod = (-logX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - ymod = (logY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - - // transform the screen coordinates by the camera's matrix into world coordinates. - x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - rayDirection.Set(x,y,z); - rayDirectionPt = rayLocation + rayDirection; - offset.X = Vector3::Find_X_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - offset.Y = Vector3::Find_Y_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - offset = offset - intersection; - m_hysteresis = offset.Length(); - - logX = (Real)(curPt.x) / (Real)client.Width(); - logY = (Real)(curPt.y+3) / (Real)client.Height(); - - xmod = (-logX + 0.5 + viewport.Min.X) * zmod * xscale;// / aspect; - ymod = (logY - 0.5 - viewport.Min.Y) * zmod * yscale;// * aspect; - - // transform the screen coordinates by the camera's matrix into world coordinates. - x = zmod * camera_matrix[0][2] + xmod * camera_matrix[0][0] + ymod * camera_matrix[0][1]; - y = zmod * camera_matrix[1][2] + xmod * camera_matrix[1][0] + ymod * camera_matrix[1][1]; - z = zmod * camera_matrix[2][2] + xmod * camera_matrix[2][0] + ymod * camera_matrix[2][1]; - rayDirection.Set(x,y,z); - rayDirectionPt = rayLocation + rayDirection; - offset.X = Vector3::Find_X_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - offset.Y = Vector3::Find_Y_At_Z(m_curTrackingZ, rayLocation, rayDirectionPt); - offset = offset - intersection; - if (m_hysteresis < offset.Length()) m_hysteresis = offset.Length(); - - CPoint pt1, pt2; - Coord3D loc; - loc.x = intersection.X; - loc.y = intersection.Y; - loc.z = intersection.Z; - this->docToViewCoords(loc, &pt1); - loc.x += MAP_XY_FACTOR*0.4f; - loc.y += MAP_XY_FACTOR*0.4f; - this->docToViewCoords(loc, &pt2); - Int dx = pt1.x-pt2.x; - if (dx<0) dx = -dx; - Int dy = pt1.y-pt2.y; - if (dy<0) dy = -dy; - if (dxx = -1000; - newPt->y = -1000; - if (m_heightMapRenderObj) { - curPt.z += m_heightMapRenderObj->getHeightMapHeight(curPt.x, curPt.y, nullptr); - } - - world.Set( curPt.x, curPt.y, curPt.z ); - if (m_camera->Project( screen, world ) != CameraClass::INSIDE_FRUSTUM) { - coordInsideFrustum = false; - } else { - coordInsideFrustum = true; - } - - CRect rClient; - GetClientRect(&rClient); - - // - // note that the screen coord returned from the project W3D camera - // gave us a screen coords that range from (-1,-1) bottom left to - // (1,1) top right ... we are turning that into (0,0) upper left - // coords now - // - Int sx, sy; - W3DLogicalScreenToPixelScreen( screen.X, screen.Y, - &sx, &sy, - rClient.right-rClient.left, rClient.bottom-rClient.top ); - - newPt->x = rClient.left + sx; - newPt->y = rClient.top + sy; - - return coordInsideFrustum; -} - -// ---------------------------------------------------------------------------- -void WbView3d::redraw() -{ - if (m_updateCount > 0) { - return; - } - if (IsIconic()) { - return; - } - if (!IsWindowVisible()) { - return; - } - if (!m_ww3dInited) { - return; - } - - setupCamera(); - - DEBUG_ASSERTCRASH((m_heightMapRenderObj),("oops")); - if (m_heightMapRenderObj) { - if (m_needToLoadRoads) { - m_heightMapRenderObj->loadRoadsAndBridges(nullptr,FALSE); - m_heightMapRenderObj->worldBuilderUpdateBridgeTowers( m_assetManager, m_scene ); - m_needToLoadRoads = false; - } - ++m_updateCount; - Int curTicks = GetTickCount(); - RefRenderObjListIterator lightListIt(&m_lightList); - m_heightMapRenderObj->updateCenter(m_camera, &m_cameraTarget, &lightListIt); - m_heightMapRenderObj->On_Frame_Update(); - --m_updateCount; - - curTicks = GetTickCount()-curTicks; -// if (curTicks>2) { -// WWDEBUG_SAY(("%d ms for updateCenter, %d FPS", curTicks, 1000/curTicks)); -// } - } - if (m_drawObject) { - m_drawObject->setDrawObjects(m_showObjects, - m_showWaypoints || WaypointTool::isActive(), - m_showPolygonTriggers || PolygonTool::isActive(), - m_showBoundingBoxes, m_showSightRanges, m_showWeaponRanges, m_showSoundCircles, m_highlightTestArt, m_showLetterbox); - } - - WW3D::Update_Logic_Frame_Time(TheFramePacer->getLogicTimeStepMilliseconds()); - WW3D::Sync(WW3D::Get_Fractional_Sync_Milliseconds() >= WWSyncMilliseconds); - - m_buildRedMultiplier += (GetTickCount()-m_time)/500.0f; - if (m_buildRedMultiplier>4.0f || m_buildRedMultiplier<0) { - m_buildRedMultiplier = 0; - } - - render(); - - TheFramePacer->update(); - - m_time = ::GetTickCount(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::render() -{ - ++m_updateCount; - - if (WW3D::Begin_Render(true,true,Vector3(0.5f,0.5f,0.5f), TheWaterTransparency->m_minWaterOpacity) == WW3D_ERROR_OK) - { - - DEBUG_ASSERTCRASH((m_heightMapRenderObj),("oops")); - - - if (m_heightMapRenderObj) { - m_heightMapRenderObj->Set_Hidden((m_showTerrain ? 0 : 1)); - m_heightMapRenderObj->doTextures(true); - } - m_scene->Set_Polygon_Mode(SceneClass::FILL); - // Render 3D scene - WW3D::Render(m_scene,m_camera); - Vector3 amb = m_baseBuildScene->Get_Ambient_Light(); - Vector3 newAmb(amb); - Real mul = m_buildRedMultiplier; - if (mul>2.0f) mul = 4.0f-mul; - Real gMul = 2.0-mul; - newAmb.X *= mul; - newAmb.Y *= gMul; - if (newAmb.X>1) newAmb.X = 1; - m_baseBuildScene->Set_Ambient_Light(newAmb); - WW3D::Render(m_baseBuildScene,m_camera); - m_baseBuildScene->Set_Ambient_Light(amb); - - if (m_showWireframe) { - if (m_heightMapRenderObj) { - m_heightMapRenderObj->doTextures(false); - m_scene->Set_Polygon_Mode(SceneClass::LINE); - // Render 3D scene - WW3D::Render(m_scene,m_camera); - WW3D::Render(m_baseBuildScene,m_camera); - m_heightMapRenderObj->doTextures(true); - } - } - if (m_showObjToolTrackingObj && m_objectToolTrackingObj) { - m_transparentObjectsScene->Add_Render_Object(m_objectToolTrackingObj); - DX8TextureCategoryClass::SetForceMultiply(true); - TheDX8MeshRenderer.Enable_Lighting(false); - Real lightLevel = 1.0f; - m_transparentObjectsScene->Set_Ambient_Light(Vector3(lightLevel,lightLevel,lightLevel)); - WW3D::Render(m_transparentObjectsScene, m_camera); - TheDX8MeshRenderer.Enable_Lighting(true); - DX8TextureCategoryClass::SetForceMultiply(false); - m_transparentObjectsScene->Remove_Render_Object(m_objectToolTrackingObj); - } - - // Draw the 3d obj icons on top of the rest of the data. - WW3D::Render(m_overlayScene,m_camera); - //if (mytext) mytext->Render(); - if (m3DFont) { - drawLabels(nullptr); - } - - - WW3D::End_Render(); - } - --m_updateCount; -} - -// ---------------------------------------------------------------------------- -BEGIN_MESSAGE_MAP(WbView3d, WbView) - //{{AFX_MSG_MAP(WbView3d) - ON_WM_CREATE() - ON_WM_PAINT() - ON_WM_SIZE() - ON_WM_MOUSEWHEEL() - ON_WM_TIMER() - ON_WM_DESTROY() - ON_WM_SHOWWINDOW() - ON_COMMAND(ID_VIEW_SHOWWIREFRAME, OnViewShowwireframe) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWWIREFRAME, OnUpdateViewShowwireframe) - ON_WM_ERASEBKGND() - ON_COMMAND(ID_VIEW_SHOWENTIRE3DMAP, OnViewShowentire3dmap) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWENTIRE3DMAP, OnUpdateViewShowentire3dmap) - ON_COMMAND(ID_VIEW_SHOWTOPDOWNVIEW, OnViewShowtopdownview) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWTOPDOWNVIEW, OnUpdateViewShowtopdownview) - ON_COMMAND(ID_VIEW_SHOWCLOUDS, OnViewShowclouds) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWCLOUDS, OnUpdateViewShowclouds) - ON_COMMAND(ID_VIEW_SHOWMACROTEXTURE, OnViewShowmacrotexture) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWMACROTEXTURE, OnUpdateViewShowmacrotexture) - ON_COMMAND(ID_EDIT_SELECTMACROTEXTURE, OnEditSelectmacrotexture) - ON_COMMAND(ID_LOOK_EAST, OnLookEast) - ON_UPDATE_COMMAND_UI(ID_LOOK_EAST, OnUpdateLookEast) - ON_COMMAND(ID_LOOK_NORTH, OnLookNorth) - ON_UPDATE_COMMAND_UI(ID_LOOK_NORTH, OnUpdateLookNorth) - ON_COMMAND(ID_LOOK_SOUTH, OnLookSouth) - ON_UPDATE_COMMAND_UI(ID_LOOK_SOUTH, OnUpdateLookSouth) - ON_COMMAND(ID_LOOK_WEST, OnLookWest) - ON_UPDATE_COMMAND_UI(ID_LOOK_WEST, OnUpdateLookWest) - ON_COMMAND(ID_VIEW_SHOWSOFTWATER, OnViewShowSoftWater) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWEXTRABLENDS, OnUpdateViewShowExtraBlends) - ON_COMMAND(ID_VIEW_SHOWEXTRABLENDS, OnViewExtraBlends) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWSOFTWATER, OnUpdateViewShowSoftWater) - ON_COMMAND(ID_VIEW_SHOWSHADOWS, OnViewShowshadows) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWSHADOWS, OnUpdateViewShowshadows) - ON_COMMAND(ID_EDIT_SHADOWS, OnEditShadows) - ON_COMMAND(ID_EDIT_MAPSETTINGS, OnEditMapSettings) - ON_COMMAND(ID_VIEW_SHOWIMPASSABLEAREAS, OnViewShowimpassableareas) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWIMPASSABLEAREAS, OnUpdateViewShowimpassableareas) - ON_COMMAND(ID_VIEW_IMPASSABLEAREAOPTIONS, OnImpassableAreaOptions) - ON_COMMAND(ID_VIEW_PARTIALMAPSIZE_96X96, OnViewPartialmapsize96x96) - ON_UPDATE_COMMAND_UI(ID_VIEW_PARTIALMAPSIZE_96X96, OnUpdateViewPartialmapsize96x96) - ON_COMMAND(ID_VIEW_PARTIALMAPSIZE_192X192, OnViewPartialmapsize192x192) - ON_UPDATE_COMMAND_UI(ID_VIEW_PARTIALMAPSIZE_192X192, OnUpdateViewPartialmapsize192x192) - ON_COMMAND(ID_VIEW_PARTIALMAPSIZE_160X160, OnViewPartialmapsize160x160) - ON_UPDATE_COMMAND_UI(ID_VIEW_PARTIALMAPSIZE_160X160, OnUpdateViewPartialmapsize160x160) - ON_COMMAND(ID_VIEW_PARTIALMAPSIZE_128X128, OnViewPartialmapsize128x128) - ON_UPDATE_COMMAND_UI(ID_VIEW_PARTIALMAPSIZE_128X128, OnUpdateViewPartialmapsize128x128) - ON_COMMAND(ID_VIEW_SHOWMODELS, OnViewShowModels) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWMODELS, OnUpdateViewShowModels) - ON_COMMAND(ID_VIEW_BOUNDINGBOXES, OnViewBoundingBoxes) - ON_UPDATE_COMMAND_UI(ID_VIEW_BOUNDINGBOXES, OnUpdateViewBoundingBoxes) - ON_COMMAND(ID_VIEW_SIGHTRANGES, OnViewSightRanges) - ON_UPDATE_COMMAND_UI(ID_VIEW_SIGHTRANGES, OnUpdateViewSightRanges) - ON_COMMAND(ID_VIEW_WEAPONRANGES, OnViewWeaponRanges) - ON_UPDATE_COMMAND_UI(ID_VIEW_WEAPONRANGES, OnUpdateViewWeaponRanges) - ON_COMMAND(ID_HIGHLIGHT_TESTART, OnHighlightTestArt) - ON_UPDATE_COMMAND_UI(ID_HIGHLIGHT_TESTART, OnUpdateHighlightTestArt) - ON_COMMAND(ID_SHOW_LETTERBOX, OnShowLetterbox) - ON_UPDATE_COMMAND_UI(ID_SHOW_LETTERBOX, OnUpdateShowLetterbox) - ON_COMMAND(ID_VIEW_GARRISONED, OnViewGarrisoned) - ON_UPDATE_COMMAND_UI(ID_VIEW_GARRISONED, OnUpdateViewGarrisoned) - ON_COMMAND(ID_VIEW_LAYERS_LIST, OnViewLayersList) - ON_UPDATE_COMMAND_UI(ID_VIEW_LAYERS_LIST, OnUpdateViewLayersList) - ON_COMMAND(ID_VIEW_SHOWMAPBOUNDARIES, OnViewShowMapBoundaries) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWMAPBOUNDARIES, OnUpdateViewShowMapBoundaries) - ON_COMMAND(ID_VIEW_SHOWAMBIENTSOUNDS, OnViewShowAmbientSounds) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWAMBIENTSOUNDS, OnUpdateViewShowAmbientSounds) - ON_COMMAND(ID_VIEW_SHOW_SOUND_CIRCLES, OnViewShowSoundCircles) - ON_UPDATE_COMMAND_UI(ID_VIEW_SHOW_SOUND_CIRCLES, OnUpdateViewShowSoundCircles) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// ---------------------------------------------------------------------------- -// WbView3d drawing - -void WbView3d::OnDraw(CDC* pDC) -{ - // Not used. See OnPaint. -} - -// ---------------------------------------------------------------------------- -// WbView3d diagnostics - -#ifdef RTS_DEBUG -// ---------------------------------------------------------------------------- -void WbView3d::AssertValid() const -{ - WbView::AssertValid(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::Dump(CDumpContext& dc) const -{ - WbView::Dump(dc); -} -#endif //RTS_DEBUG - -// ---------------------------------------------------------------------------- -void WbView3d::initWW3D() -{ - // only want to do once per instance, but do lazily. - if (!m_ww3dInited) { - - - - m_ww3dInited = true; - - WWMath::Init(); - - WW3D::Set_Prelit_Mode(WW3D::PRELIT_MODE_VERTEX); - - initAssets(); - WW3D::Init(m_hWnd); - WW3D::Set_Prelit_Mode( WW3D::PRELIT_MODE_LIGHTMAP_MULTI_PASS ); - WW3D::Set_Collision_Box_Display_Mask(0x00); ///Add_Render_Object(m_drawObject); - -#if 1 - TheWritableGlobalData->m_useShadowVolumes = true; - TheWritableGlobalData->m_useShadowDecals = true; - TheWritableGlobalData->m_enableBehindBuildingMarkers = false; //this is only for the game. - if (TheW3DShadowManager==nullptr) - { TheW3DShadowManager = new W3DShadowManager; - TheW3DShadowManager->init(); - } -#endif - updateLights(); - resetRenderObjects(); - } -} - -// ---------------------------------------------------------------------------- -// WbView3d message handlers - -// ---------------------------------------------------------------------------- -int WbView3d::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (WbView::OnCreate(lpCreateStruct) == -1) - return -1; - - // install debug callbacks - WWDebug_Install_Message_Handler(WWDebug_Message_Callback); - WWDebug_Install_Assert_Handler(WWAssert_Callback); - - m_timer = SetTimer(0, UPDATE_TIME, nullptr); - - initWW3D(); - TheWritableGlobalData->m_useCloudMap = AfxGetApp()->GetProfileInt("GameOptions", "cloudMap", 0); - AfxGetApp()->WriteProfileInt("GameOptions", "cloudMap", TheGlobalData->m_useCloudMap); // Just in case it wasn't already there - m_partialMapSize = AfxGetApp()->GetProfileInt("GameOptions", "partialMapSize", 97); - - m_showLayersList = AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowLayersList", 0); - m_showMapBoundaries = AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowMapBoundaries", 0); - m_showAmbientSounds = AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowAmbientSounds", 0); - m_showSoundCircles = AfxGetApp()->GetProfileInt(MAIN_FRAME_SECTION, "ShowSoundCircles", 0); - - DrawObject::setDoBoundaryFeedback(m_showMapBoundaries); - DrawObject::setDoAmbientSoundFeedback(m_showAmbientSounds); - return 0; -} - -// ---------------------------------------------------------------------------- -void WbView3d::OnPaint() -{ - - PAINTSTRUCT ps; - HDC hdc = ::BeginPaint(m_hWnd, &ps); - if (!m_firstPaint) { - redraw(); - } - drawLabels(hdc); - ::EndPaint(m_hWnd, &ps); - if (m_firstPaint) { - CMainFrame::GetMainFrame()->adjustWindowSize(); - m_firstPaint = false; - } - DX8Wrapper::SetCleanupHook(this); - -} - -////////////////////////////////////////////////////////////////////////// -/// Draw a (not very good) circle into the hdc -void WbView3d::drawCircle( HDC hdc, const Coord3D & centerPoint, Real radius, COLORREF color ) -{ - CPoint rulerPoints[2]; - Coord3D pnt; - Real angle = 0.0f; - Real inc = PI/4.0f; - - // Create and select a correctly colored pen. Remember the old one so that it can be restored. - HPEN pen = CreatePen(PS_SOLID, 2, color); - HPEN penOld = (HPEN)SelectObject(hdc, pen); - - - // Get the starting point on the circumference of the circle. - pnt.x = centerPoint.x + radius * (Real)cosf(angle); - pnt.y = centerPoint.y + radius * (Real)sinf(angle); - pnt.z = centerPoint.z; - docToViewCoords(pnt, &rulerPoints[0]); - - angle += inc; - for(; angle <= 2.0f * PI; angle += inc) { - // Get a new point on the circumference of the circle. - pnt.x = centerPoint.x + radius * (Real)cosf(angle); - pnt.y = centerPoint.y + radius * (Real)sinf(angle); - pnt.z = centerPoint.z; - - docToViewCoords(pnt, &rulerPoints[1]); - - ::Polyline(hdc, rulerPoints, 2); - - // Remember the last point to use as the starting point for the next line. - rulerPoints[0].x = rulerPoints[1].x; - rulerPoints[0].y = rulerPoints[1].y; - } - - // Restore previous pen. - SelectObject(hdc, penOld); - // Delete new pen. - DeleteObject(pen); -} - - -void WbView3d::drawLabels() -{ - CDC * pDC = GetDC(); - drawLabels(pDC->m_hDC); - ReleaseDC(pDC); -} - -/// This is actually draw any 2d graphics and/or feedback. -void WbView3d::drawLabels(HDC hdc) -{ - Coord3D selectedPos; //position of selected object - Real selectedRadius=120.0f; //default distance of lightfeeback model from object - selectedPos.x=0;selectedPos.y=0;selectedPos.z=0; - - // Draw labels. - MapObject *pMapObj; - if (isNamesVisible()) - { - for (pMapObj = MapObject::getFirstMapObject(); pMapObj; pMapObj = pMapObj->getNext()) { - AsciiString name; - Coord3D pos; - - if (pMapObj->getFlags() & FLAG_DONT_RENDER) { - continue; - } - - if (m_doLightFeedback && pMapObj->isSelected()) - { //find out position of selected object in order to use it for light feedback tracking. - selectedPos=*pMapObj->getLocation(); - selectedPos.z = m_heightMapRenderObj->getHeightMapHeight(selectedPos.x, selectedPos.y, nullptr); - RenderObjClass *selRobj=pMapObj->getRenderObj(); - if (selRobj) - { - SphereClass sphere; - selRobj->Get_Obj_Space_Bounding_Sphere(sphere); - selectedRadius=sphere.Radius + sphere.Center.Length()+20.0f; - } - - } - - if (pMapObj->isWaypoint() && m_showWaypoints) { - name = pMapObj->getWaypointName(); - pos = *pMapObj->getLocation(); - pos.z = m_heightMapRenderObj->getHeightMapHeight(pos.x, pos.y, nullptr); - } else if (pMapObj->getThingTemplate() && !(pMapObj->getFlags() & (FLAG_ROAD_FLAGS|FLAG_BRIDGE_FLAGS)) && - pMapObj->getRenderObj() == nullptr && !pMapObj->getThingTemplate()->isKindOf(KINDOF_OPTIMIZED_TREE)) { - name = pMapObj->getThingTemplate()->getName(); - pos = *pMapObj->getLocation(); - pos.z += m_heightMapRenderObj->getHeightMapHeight(pos.x, pos.y, nullptr); - } - Int i; - for (i=0; i<4; i++) { - Bool exists; - switch(i) { - case 0 : break; - case 1: name = pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel1, &exists); break; - case 2: name = pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel2, &exists); break; - case 3: name = pMapObj->getProperties()->getAsciiString(TheKey_waypointPathLabel3, &exists); break; - default: name.clear(); - } - if (!name.isEmpty() && m_showWaypoints) { - CPoint pt; - Vector3 world, screen; - world.Set( pos.x+MAP_XY_FACTOR/2, pos.y, pos.z ); - if (CameraClass::INSIDE_FRUSTUM != m_camera->Project( screen, world )) { - continue; - } - if (!name.isEmpty()) { - CPoint pt; - Vector3 world, screen; - world.Set( pos.x+MAP_XY_FACTOR/2, pos.y, pos.z ); - if (CameraClass::INSIDE_FRUSTUM != m_camera->Project( screen, world )) { - continue; - } - - CRect rClient; - GetClientRect(&rClient); - - // - // note that the screen coord returned from the project W3D camera - // gave us a screen coords that range from (-1,-1) bottom left to - // (1,1) top right ... we are turning that into (0,0) upper left - // coords now - // - Int sx, sy; - W3DLogicalScreenToPixelScreen( screen.X, screen.Y, - &sx, &sy, - rClient.right-rClient.left, rClient.bottom-rClient.top ); - pt.x = rClient.left+sx; - pt.y = rClient.top+sy; - pt.y += i*15; - - Int red, green; - if (i==0) { - red = 0; green = 255; - } else { - red = 255, green = 0; - } - - if (m3DFont && !hdc) { - RECT rct; - pt.y -= 5; - pt.x += 1; - rct.top = rct.bottom = pt.y; - rct.left = rct.right = pt.x; - m3DFont->DrawText(name.str(), name.getLength(), &rct, - DT_LEFT | DT_NOCLIP | DT_TOP | DT_SINGLELINE, 0xAF000000 + (red<<16) + (green<<8)); - - } else if (!m3DFont) { - //docToViewCoords(pos, &pt); - ::SetBkMode(hdc, TRANSPARENT); - pt.y -= 5; - pt.x += 1; - ::SetTextColor(hdc, RGB(red,green,0)); - ::TextOut(hdc, pt.x, pt.y, name.str(), name.getLength()); - } - } - } - } - } - } - - // Draw tracking box. - if (hdc && m_doRectFeedback) { - CBrush brush; - // green brush for drawing the grid. - brush.CreateSolidBrush(RGB(0,255,0)); - ::FrameRect(hdc, &m_feedbackBox, (HBRUSH)brush.GetSafeHandle()); - } - - if (hdc && m_doRulerFeedback) { - if (m_doRulerFeedback == RULER_LINE) { - // Change world coords to screen viewport coords. - CPoint rulerPoints[2]; - docToViewCoords(m_rulerPoints[0], &rulerPoints[0]); - docToViewCoords(m_rulerPoints[1], &rulerPoints[1]); - - // Create and select a green pen. Remember the old one so that it can be restored. - HPEN pen = CreatePen(PS_SOLID, 2, RGB(0,255,0)); - HPEN penOld = (HPEN)SelectObject(hdc, pen); - // Draw the line ruler. - ::Polyline(hdc, rulerPoints, 2); - - // Restore previous pen. - SelectObject(hdc, penOld); - // Delete new pen. - DeleteObject(pen); - } else if (m_doRulerFeedback == RULER_CIRCLE) { - drawCircle( hdc, m_rulerPoints[0], m_rulerLength, RGB( 0, 255, 0 ) ); - } - } - - if (hdc && m_doLightFeedback) - { //Draw Lines to indicate the direction of each light source -// Int LightColors[MAX_GLOBAL_LIGHTS]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255)}; - - for (Int lIndex=0; lIndexCreate_Render_Obj(nameBuf); - } - if (m_lightFeedbackMesh[lIndex]==nullptr) { - break; - } - Matrix3D lightMat; - - lightMat.Look_At(worldEnd,worldStart,0); - lightMat.Set_Translation(worldEnd); - - m_lightFeedbackMesh[lIndex]->Add(m_scene); - m_lightFeedbackMesh[lIndex]->Set_Transform(lightMat); -#ifdef DRAW_LIGHT_DIRECTION_RAYS - if (CameraClass::INSIDE_FRUSTUM == m_camera->Project( screenStart, worldStart ) && - CameraClass::INSIDE_FRUSTUM == m_camera->Project( screenEnd, worldEnd )) - { - CRect rClient; - GetClientRect(&rClient); - - // - // note that the screen coord returned from the project W3D camera - // gave us a screen coords that range from (-1,-1) bottom left to - // (1,1) top right ... we are turning that into (0,0) upper left - // coords now - // - Int sxStart, syStart; - Int sxEnd, syEnd; - - W3DLogicalScreenToPixelScreen( screenStart.X, screenStart.Y, &sxStart, &syStart,rClient.right-rClient.left, rClient.bottom-rClient.top ); - W3DLogicalScreenToPixelScreen( screenEnd.X, screenEnd.Y, &sxEnd, &syEnd,rClient.right-rClient.left, rClient.bottom-rClient.top ); - - POINT rayPoints[2]; - - rayPoints[0].x = rClient.left+sxStart; - rayPoints[0].y= rClient.top+syStart; - - rayPoints[1].x = rClient.left+sxEnd; - rayPoints[1].y= rClient.top+syEnd; - - HPEN pen=CreatePen( PS_SOLID,2, LightColors[lIndex]); - HPEN penOld = (HPEN)SelectObject(hdc, pen); - Polyline(hdc,rayPoints,2); - SelectObject(hdc, penOld); //restore previous pen - DeleteObject(pen); //delete new pen - } -#endif //DRAW_LIGHT_DIRECTION_RAYS - } - } - else - { if (!m_doLightFeedback) - { //not in light feedback mode. Make sure the temporary feedback models are gone - - for (Int lIndex=0; lIndexRemove(); - REF_PTR_RELEASE(m_lightFeedbackMesh[lIndex]); - } - } - } - } -} - - -// ---------------------------------------------------------------------------- -void WbView3d::OnSize(UINT nType, int cx, int cy) -{ - WbView::OnSize(nType, cx, cy); - -} - -// ---------------------------------------------------------------------------- -BOOL WbView3d::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) -{ - if (m_trackingMode == TRACK_NONE) { - - //WST 11/21/02 New Triple speed camera zoom request by designers - if (getCurrentZoom() > 2.0f) - { - m_mouseWheelOffset += zDelta; - } - else if (getCurrentZoom() > 1.0f) - { - m_mouseWheelOffset += zDelta/2; - } - else - { - m_mouseWheelOffset += zDelta/8; - } - - MSG msg; - while (::PeekMessage(&msg, m_hWnd, WM_MOUSEWHEEL, WM_MOUSEWHEEL, PM_REMOVE)) { - zDelta = (short) HIWORD(msg.wParam); // wheel rotation - m_mouseWheelOffset += zDelta; - } - redraw(); - updateHysteresis(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); - } - return true; -} - -// ---------------------------------------------------------------------------- -void WbView3d::setDefaultCamera() -{ - - m_mouseWheelOffset = 0; - m_cameraAngle = 0; - m_FXPitch = 1.0f; - if (m_centerPt.X < 0) m_centerPt.X = 0; - if (m_centerPt.Y < 0) m_centerPt.Y = 0; - CWorldBuilderDoc *pDoc = CWorldBuilderDoc::GetActiveDoc(); - if (pDoc) { - WorldHeightMapEdit *pMap = pDoc->GetHeightMap(); - if (pMap) { - if (m_centerPt.X > pMap->getXExtent()) { - m_centerPt.X = pMap->getXExtent(); - } - if (m_centerPt.Y > pMap->getYExtent()) { - m_centerPt.Y = pMap->getYExtent(); - } - } - } - m_groundLevel = 10.0; - Coord3D pos; - pos.x = m_centerPt.X; - pos.y = m_centerPt.Y; - pos.z = m_centerPt.Z; - AsciiString startingCamName = TheNameKeyGenerator->keyToName(TheKey_InitialCameraPosition); - MapObject *pMapObj = MapObject::getFirstMapObject(); - while (pMapObj) { - if (pMapObj->isWaypoint()) { - if (startingCamName == pMapObj->getWaypointName()) { - pos = *pMapObj->getLocation(); - } - } - pMapObj = pMapObj->getNext(); - } - - if (m_heightMapRenderObj) { - m_groundLevel = m_heightMapRenderObj->getHeightMapHeight(pos.x, pos.y, nullptr); - } - - //m_cameraOffset.z = m_groundLevel+TheGlobalData->m_cameraHeight; - m_cameraOffset.z = m_groundLevel+TheGlobalData->m_maxCameraHeight; - m_cameraOffset.y = -(m_cameraOffset.z / tan(TheGlobalData->m_cameraPitch * (PI / 180.0))); - m_cameraOffset.x = -(m_cameraOffset.y * tan(TheGlobalData->m_cameraYaw * (PI / 180.0))); - - m_cameraOffset.x *= 1.0f; - m_cameraOffset.y *= 1.0f; - m_cameraOffset.z *= 1.0f; - /* - m_cameraOffset.x *= TheGlobalData->m_maxZoom; - m_cameraOffset.y *= TheGlobalData->m_maxZoom; - m_cameraOffset.z *= TheGlobalData->m_maxZoom; - */ - - redraw(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::rotateCamera(Real delta) -{ - if (m_projection) return; // camera doesn't rotate in top down view. - m_cameraAngle += delta; - redraw(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::pitchCamera(Real delta) -{ - if (m_projection) return; // camera doesn't pitch in top down view. - m_FXPitch += delta; - redraw(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::setCameraPitch(Real absolutePitch) -{ - if (m_projection) return; // camera doesn't pitch in top down view. - m_FXPitch = absolutePitch; - redraw(); - drawLabels(); - CMainFrame::GetMainFrame()->handleCameraChange(); -} - -// ---------------------------------------------------------------------------- -Real WbView3d::getCameraPitch() -{ - return m_FXPitch; -} - - -//WST 10.17.2002 ---------------------------------------------------------------------------- -Real WbView3d::getCurrentZoom() -{ - float zOffset = - m_mouseWheelOffset / 1200; //WST 11/21/02 new triple speed camera zoom. - Real zoom = 1.0f; - if (zOffset != 0) { - Real zPos = (m_cameraOffset.length()-m_groundLevel)/m_cameraOffset.length(); - Real zAbs = zOffset + zPos; - if (zAbs<0) zAbs = -zAbs; - if (zAbs<0.01) zAbs = 0.01f; - //DEBUG_LOG(("zOffset = %.2f, zAbs = %.2f, zPos = %.2f", zOffset, zAbs, zPos)); - if (zOffset > 0) { - zOffset *= zAbs; - } else if (zOffset < -0.3f) { - zOffset = -0.15f + zOffset/2.0f; - } - if (zOffset < -0.6f) { - zOffset = -0.3f + zOffset/2.0f; - } - //DEBUG_LOG(("zOffset = %.2f", zOffset)); - zoom = zAbs; - } - return zoom; -} - -// ---------------------------------------------------------------------------- -void WbView3d::OnTimer(UINT nIDEvent) -{ - if (getLastDrawTime()+UPDATE_TIME<::GetTickCount()) - { - Invalidate(false); - } -} - -// ---------------------------------------------------------------------------- -void WbView3d::OnDestroy() -{ - killTheTimer(); - WbView::OnDestroy(); -} - -// ---------------------------------------------------------------------------- -void WbView3d::OnShowWindow(BOOL bShow, UINT nStatus) -{ - WbView::OnShowWindow(bShow, nStatus); -} - -//============================================================================= -// CWorldBuilderView::scroll -//============================================================================= -/** Scrolls the window. */ -//============================================================================= -void WbView3d::scrollInView(Real xScroll, Real yScroll, Bool end) -{ - m_centerPt.X += xScroll; - m_centerPt.Y += yScroll; - constrainCenterPt(); - redraw(); - drawLabels(); - if (end) - WbDoc()->syncViewCenters(m_centerPt.X, m_centerPt.Y); - CMainFrame::GetMainFrame()->handleCameraChange(); -} - -void WbView3d::OnViewShowwireframe() -{ - m_showWireframe = !m_showWireframe; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowWireframe", m_showWireframe?1:0); -} - -void WbView3d::OnUpdateViewShowwireframe(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showWireframe?1:0); - -} - -BOOL WbView3d::OnEraseBkgnd(CDC* pDC) -{ - // Never erase the background. The 3d view always draws the entire - // window, so erasing just makes it flicker. jba. - return true; // act like we erased. -} - -void WbView3d::OnViewShowentire3dmap() -{ - m_showEntireMap = !m_showEntireMap; - IRegion2D range = {0,0,0,0}; - this->updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - Invalidate(false); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowEntireMap", m_showEntireMap?1:0); -} - -void WbView3d::OnUpdateViewShowentire3dmap(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showEntireMap?1:0); -} - -void WbView3d::OnViewShowtopdownview() -{ - m_projection = !m_projection; - m_heightMapRenderObj->setFlattenHeights(m_projection); - invalObjectInView(nullptr); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowTopDownView", m_projection?1:0); -} - -void WbView3d::OnUpdateViewShowtopdownview(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_projection?1:0); -} - -void WbView3d::OnViewShowclouds() -{ - TheWritableGlobalData->m_useCloudMap = !TheGlobalData->m_useCloudMap; - AfxGetApp()->WriteProfileInt("GameOptions", "cloudMap", TheGlobalData->m_useCloudMap); -} - -void WbView3d::OnUpdateViewShowclouds(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(TheGlobalData->m_useCloudMap?1:0); -} - -void WbView3d::OnViewShowmacrotexture() -{ - Bool show = !TheGlobalData->m_useLightMap; - TheWritableGlobalData->m_useLightMap = show; -} - -void WbView3d::OnUpdateViewShowmacrotexture(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(TheGlobalData->m_useLightMap?1:0); -} - -void WbView3d::OnEditSelectmacrotexture() -{ - SelectMacrotexture dlg; - - // The macrotexture dialog sets the macrotexture in the 3d engine. - dlg.DoModal(); - -} - -void WbView3d::OnLookEast() -{ - m_cameraAngle = -PI / 2; -} - -void WbView3d::OnUpdateLookEast(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_cameraAngle == -PI / 2 ? 1 : 0); -} - -void WbView3d::OnLookNorth() -{ - m_cameraAngle = 0; -} - -void WbView3d::OnUpdateLookNorth(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_cameraAngle == 0 ? 1 : 0); -} - -void WbView3d::OnLookSouth() -{ - m_cameraAngle = PI; -} - -void WbView3d::OnUpdateLookSouth(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_cameraAngle == PI ? 1 : 0); -} - -void WbView3d::OnLookWest() -{ - m_cameraAngle = PI / 2; -} - -void WbView3d::OnUpdateLookWest(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_cameraAngle == PI / 2 ? 1 : 0); -} - -void WbView3d::OnViewShowshadows() -{ - m_showShadows = !m_showShadows; - if (m_showShadows) { - int w,h,bits; - Bool windowed; - WW3D::Get_Device_Resolution(w,h,bits,windowed); - - if (bits != 32) { - ::AfxMessageBox("Shadows require a 32 bit color desktop.", IDOK); - m_showShadows = false; - } else { - resetRenderObjects(); - invalObjectInView(nullptr); - } - } else { - TheW3DShadowManager->removeAllShadows(); - } - TheWritableGlobalData->m_useShadowDecals = m_showShadows; - TheWritableGlobalData->m_useShadowVolumes = m_showShadows; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowShadows", m_showShadows?1:0); -} - -void WbView3d::OnUpdateViewShowshadows(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showShadows?1:0); -} - -void WbView3d::OnViewShowSoftWater() -{ - TheWritableGlobalData->m_showSoftWaterEdge = !TheGlobalData->m_showSoftWaterEdge; - if (TheGlobalData->m_showSoftWaterEdge) - { //we just turned it on, so recompute shoreline tiles since they may not exist. - TheTerrainRenderObject->updateShorelineTiles(0,0,WbDoc()->GetHeightMap()->getXExtent()-1,WbDoc()->GetHeightMap()->getYExtent()-1, - WbDoc()->GetHeightMap()); - } - - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowSoftWater", TheGlobalData->m_showSoftWaterEdge ? 1 : 0); -} - -void WbView3d::OnUpdateViewShowSoftWater(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(TheGlobalData->m_showSoftWaterEdge ? 1 : 0); -} - -void WbView3d::OnViewExtraBlends() -{ - if (TheGlobalData->m_use3WayTerrainBlends==1) - TheWritableGlobalData->m_use3WayTerrainBlends = 2; //debug mode which draws the tiles in black - else - TheWritableGlobalData->m_use3WayTerrainBlends = 1; - - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowExtraBlends", TheGlobalData->m_use3WayTerrainBlends > 1 ? 1 : 0); -} - -void WbView3d::OnUpdateViewShowExtraBlends(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(TheGlobalData->m_use3WayTerrainBlends > 1 ? 1 : 0); -} - -void WbView3d::OnEditMapSettings() -{ - MapSettings dlg; - - if (dlg.DoModal() == IDOK) { - resetRenderObjects(); - invalObjectInView(nullptr); - } -} - -void WbView3d::OnEditShadows() -{ - if (!m_showShadows) { - OnViewShowshadows(); // turn them on. - } - ShadowOptions dlg; - dlg.DoModal(); -} - -void WbView3d::OnViewShowModels() -{ - setShowModels(!getShowModels()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowModels", getShowModels()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -void WbView3d::OnUpdateViewShowModels(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowModels()?1:0); -} - -// MLL C&C3 -void WbView3d::OnViewBoundingBoxes() -{ - setShowBoundingBoxes(!getShowBoundingBoxes()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowBoundingBoxes", getShowBoundingBoxes()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -// MLL C&C3 -void WbView3d::OnUpdateViewBoundingBoxes(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowBoundingBoxes()?1:0); -} - - -// MLL C&C3 -void WbView3d::OnViewSightRanges() -{ - setShowSightRanges(!getShowSightRanges()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowSightRanges", getShowSightRanges()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -// MLL C&C3 -void WbView3d::OnUpdateViewSightRanges(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowSightRanges()?1:0); -} - -// MLL C&C3 -void WbView3d::OnViewWeaponRanges() -{ - setShowWeaponRanges(!getShowWeaponRanges()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowWeaponRanges", getShowWeaponRanges()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -// MLL C&C3 -void WbView3d::OnUpdateViewWeaponRanges(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowWeaponRanges()?1:0); -} - -// MLL C&C3 -void WbView3d::OnHighlightTestArt() -{ - setHighlightTestArt(!getHighlightTestArt()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "HighlightTestArt", getHighlightTestArt()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -// MLL C&C3 -void WbView3d::OnUpdateHighlightTestArt(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getHighlightTestArt()?1:0); -} - - -// MLL C&C3 -void WbView3d::OnShowLetterbox() -{ - setShowLetterbox(!getShowLetterbox()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowLetterBox", getShowLetterbox()?1:0); -} -// MLL C&C3 -void WbView3d::OnUpdateShowLetterbox(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowLetterbox()?1:0); -} - - -void WbView3d::OnViewGarrisoned() -{ - setShowGarrisoned(!getShowGarrisoned()); - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowGarrisoned", getShowGarrisoned()?1:0); - resetRenderObjects(); - invalObjectInView(nullptr); -} -void WbView3d::OnUpdateViewGarrisoned(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(getShowGarrisoned()?1:0); -} - -void WbView3d::OnViewShowimpassableareas() -{ - Bool showImpassable = false; - if (TheTerrainRenderObject) { - showImpassable = TheTerrainRenderObject->getShowImpassableAreas(); - TheTerrainRenderObject->setShowImpassableAreas(!showImpassable); - // Force the entire terrain mesh to be rerendered. - IRegion2D range = {0,0,0,0}; - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - } -} - -void WbView3d::OnUpdateViewShowimpassableareas(CCmdUI* pCmdUI) -{ - Bool showImpassable = false; - if (TheTerrainRenderObject) { - showImpassable = TheTerrainRenderObject->getShowImpassableAreas(); - } - pCmdUI->SetCheck(showImpassable?1:0); -} - -void WbView3d::OnImpassableAreaOptions() -{ - if (TheTerrainRenderObject) { - { - ImpassableOptions opts; - opts.SetDefaultSlopeToShow(TheTerrainRenderObject->getViewImpassableAreaSlope()); - if (opts.DoModal() == IDOK) { - TheTerrainRenderObject->setViewImpassableAreaSlope(opts.GetSlopeToShow()); - } else { - TheTerrainRenderObject->setViewImpassableAreaSlope(opts.GetDefaultSlope()); - } - } - - IRegion2D range = {0,0,0,0}; - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - } -} - -void WbView3d::OnViewPartialmapsize96x96() -{ - m_partialMapSize = 97; - AfxGetApp()->WriteProfileInt("GameOptions", "partialMapSize", m_partialMapSize); - m_showEntireMap = false; - IRegion2D range = {0,0,0,0}; - WbDoc()->GetHeightMap()->setDrawOrg(0, 0); - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - Invalidate(false); -} - -void WbView3d::OnUpdateViewPartialmapsize96x96(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_partialMapSize == 97?1:0); -} - -void WbView3d::OnViewPartialmapsize192x192() -{ - m_partialMapSize = 192; - AfxGetApp()->WriteProfileInt("GameOptions", "partialMapSize", m_partialMapSize); - m_showEntireMap = false; - IRegion2D range = {0,0,0,0}; - WbDoc()->GetHeightMap()->setDrawOrg(0, 0); - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - Invalidate(false); -} - -void WbView3d::OnUpdateViewPartialmapsize192x192(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_partialMapSize == 192?1:0); -} - -void WbView3d::OnViewPartialmapsize160x160() -{ - m_partialMapSize = 161; - AfxGetApp()->WriteProfileInt("GameOptions", "partialMapSize", m_partialMapSize); - m_showEntireMap = false; - IRegion2D range = {0,0,0,0}; - WbDoc()->GetHeightMap()->setDrawOrg(0, 0); - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - Invalidate(false); -} - -void WbView3d::OnUpdateViewPartialmapsize160x160(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_partialMapSize == 161?1:0); -} - -void WbView3d::OnViewPartialmapsize128x128() -{ - m_partialMapSize = 129; - AfxGetApp()->WriteProfileInt("GameOptions", "partialMapSize", m_partialMapSize); - m_showEntireMap = false; - IRegion2D range = {0,0,0,0}; - WbDoc()->GetHeightMap()->setDrawOrg(0, 0); - updateHeightMapInView(WbDoc()->GetHeightMap(), false, range); - Invalidate(false); -} - -void WbView3d::OnUpdateViewPartialmapsize128x128(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_partialMapSize == 129?1:0); -} - -void WbView3d::OnViewLayersList() -{ - m_showLayersList = !m_showLayersList; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowLayersList", m_showLayersList ? 1 : 0); - TheLayersList->ShowWindow(m_showLayersList ? SW_SHOW : SW_HIDE); - if (m_showLayersList) { - TheLayersList->enableUpdates(); - } else { - TheLayersList->disableUpdates(); - } -} - -void WbView3d::OnUpdateViewLayersList(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showLayersList ? 1 : 0); -} - -void WbView3d::OnViewShowMapBoundaries() -{ - m_showMapBoundaries = !m_showMapBoundaries; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowMapBoundaries", m_showMapBoundaries ? 1 : 0); - DrawObject::setDoBoundaryFeedback(m_showMapBoundaries); -} - -void WbView3d::OnUpdateViewShowMapBoundaries(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showMapBoundaries ? 1 : 0); -} - - -void WbView3d::OnViewShowAmbientSounds() -{ - m_showAmbientSounds = !m_showAmbientSounds; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowAmbientSounds", m_showAmbientSounds ? 1 : 0); - DrawObject::setDoAmbientSoundFeedback(m_showAmbientSounds); -} - -void WbView3d::OnUpdateViewShowAmbientSounds(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showAmbientSounds ? 1 : 0); -} - -void WbView3d::OnViewShowSoundCircles() -{ - m_showSoundCircles = !m_showSoundCircles; - ::AfxGetApp()->WriteProfileInt(MAIN_FRAME_SECTION, "ShowSoundCircles", m_showSoundCircles ? 1 : 0); - resetRenderObjects(); - invalObjectInView(nullptr); -} - -void WbView3d::OnUpdateViewShowSoundCircles(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(m_showSoundCircles ? 1 : 0); -}