copy_paste.h

00001 /* $Id: command_queue.h 4998 2006-05-30 16:13:41Z Frostregen $ */
00002 
00003 #ifndef COPY_PASTE_H
00004 #define COPY_PASTE_H
00005 
00006 #include "map_type.h"
00007 #include "command_type.h"
00008 #include "signal_type.h"
00009 #include "track_type.h"
00010 #include "slope_type.h"
00011 #include "road_map.h"
00012 #include "saveload/saveload.h"
00013 
00014 class CopyPaste {
00015 public:
00016   bool  m_copy_with_rail;          
00017   bool  m_copy_with_road;          
00018   bool  m_copy_with_other;         
00019 
00020   uint8 m_paste_vacant_terrain;    
00021   bool  m_convert_rail;            
00022   bool  m_clear_before_build;      
00023   bool  m_toggle_signal_direction; 
00024 
00025 private:
00026   uint32   m_width;
00027   uint32   m_height;
00028         StringID error_str;
00029   char     *error_msg;
00030 
00031   CommandCost m_costs; 
00032 
00036   int8   *m_heightmap;      
00037   uint8  *m_terrain_needed; 
00038   uint8  *m_tiletype;       
00039   uint8  *m_railroad;       
00040   uint16 *m_signals;        
00041   //TODO: uint8 *m_station;
00042 
00043 public:
00044   enum CopyPasteTileType {
00045     CP_TILE_CLEAR,
00046     CP_TILE_RAIL,
00047     CP_TILE_ROAD,
00048     CP_TILE_TUNNELBRIDGE,
00049     CP_TILE_STATION,
00050   };
00051   explicit CopyPaste();
00052   ~CopyPaste();
00053 
00054   SaveOrLoadResult SaveLoadTemplate(const char *filename, int mode);
00055   const char *GetErrorString();
00056   bool IsSomethingCopied(); 
00057   void AllocateMapArray(uint32 max_tiles); 
00058   void ClearCopyArrays();   
00059 
00060   void CopyArea(TileIndex end, TileIndex start); 
00061   void PasteArea(TileIndex tile);                
00062 
00063   void RotateSelectionCCW();
00064   void RotateSelectionCW();
00065   void MirrorSelectionHorizontal();
00066   void MirrorSelectionVertical();
00067   uint GetHeight(uint baseh, uint index);
00068   Slope GetSlope(uint index);
00069   CopyPasteTileType GetCPTileType(uint index);
00070   uint GetCPMinorTileType(uint index);
00071   TrackBits GetCPTrackBits(uint index);
00072 
00073   FORCEINLINE uint32 GetWidth()  { return m_width;  };  
00074   FORCEINLINE uint32 GetHeight() { return m_height; };
00075 
00076 private:
00077   void SetError(StringID message, StringID extra = INVALID_STRING_ID);
00078 
00079   void internal_PasteArea(TileIndex tile); 
00080 
00081   void CP_DoCommand(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd); 
00082 
00083   void CP_RaiseLowerLand  (TileIndex tile, int mode);
00084   void CP_PlaceRail       (TileIndex tile, int cmd, uint32 railtype);
00085   void CP_PlaceSignals    (TileIndex tile, Track track, SignalType type, uint direction, bool semaphore);
00086   void CP_PlaceRoad       (TileIndex tile, uint8 road_bits);
00087   void CP_PlaceRoadStop(TileIndex tile, uint8 direction, uint8 roadtype, bool truck_stop, bool drive_through);
00088   void CP_PlaceRail_Tunnel(TileIndex tile, uint32 railtype);
00089   void CP_PlaceRoad_Tunnel(TileIndex tile, uint8 roadtype);
00090   void CP_Build_Bridge    (TileIndex start, TileIndex end, uint8 bridgetype, uint8 transport_type, uint8 rail_road_type);
00091   void CP_PlaceRail_Depot (TileIndex tile, uint8 railtype, uint8 direction);
00092   void CP_PlaceRoad_Depot (TileIndex tile, uint8 direction_type);
00093   void CP_PlaceWaypoint   (TileIndex tile, uint8 waypoint_type);
00094   void CP_ClearTile       (TileIndex start_tile, TileIndex end_tile);
00095     
00096   uint8 MirrorSignalDirection(uint8 direction);
00097   DisallowedRoadDirections MirrorOneWayRoadDirection(DisallowedRoadDirections drd);
00098   void SwapSignalInfo(uint index);
00099   void PasteSignals(uint index, TileIndex tile);
00100   void PasteLandscape(TileIndex tile);
00101 
00102   void TerrainNeededAroundTile(TileIndex tindex, TileIndex bindex);
00103   int8 ClampToRight(TileIndex index, int8 baseh, int8 h_tile);
00104   int8 ClampToUp(TileIndex index, int8 baseh, int8 h_tile, int32 size_x);
00105 
00106   FORCEINLINE void SetWidth(uint32 width)   { m_width  = width;  };
00107   FORCEINLINE void SetHeight(uint32 height) { m_height = height; }; 
00108 };
00109 
00110 extern CopyPaste _copy_paste;
00111 
00112 #endif /* COPY_PASTE_H */
00113