1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Directions;                        use Directions; 
  10.  
  11. private with Physics.Clip_Maps; 
  12.  
  13. package Widgets.Containers.Scenes.Ked is 
  14.  
  15.     type Ked_Scene is new Scene with private; 
  16.     type A_Ked_Scene is access all Ked_Scene'Class; 
  17.  
  18.     function Create_Scene( view : not null access Game_Views.Game_View'Class; 
  19.                            id   : String ) return A_Ked_Scene; 
  20.     pragma Precondition( id'Length > 0 ); 
  21.     pragma Postcondition( Create_Scene'Result /= null ); 
  22.  
  23.     -- Returns the layer currently active for tools. 
  24.     function Get_Active_Layer( this : not null access Ked_Scene'Class ) return Natural; 
  25.  
  26.     -- Returns the scene's X focus in world coordinates. 
  27.     function Get_Focus_X( this : not null access Ked_Scene'Class ) return Float; 
  28.  
  29.     -- Returns the scene's Y focus in world coordinates. 
  30.     function Get_Focus_Y( this : not null access Ked_Scene'Class ) return Float; 
  31.  
  32.     -- Scrolls the scene view in the direction of 'dir' by one increment. The 
  33.     -- scroll increment size is controlled by the scene.scroll_speed preference. 
  34.     procedure Scroll_Increment( this : not null access Ked_Scene'Class; 
  35.                                 dir  : Cardinal_Direction ); 
  36.  
  37.     -- Sets the active layer for editing tiles. 
  38.     procedure Set_Active_Layer( this  : not null access Ked_Scene'Class; 
  39.                                 layer : Positive ); 
  40.  
  41.     -- Sets the visibility for a layer. 
  42.     procedure Set_Layer_Visible( this    : not null access Ked_Scene'Class; 
  43.                                  layer   : Positive; 
  44.                                  visible : Boolean ); 
  45.  
  46.     -- Moves the focus point of the scene relative to it's current location. 
  47.     procedure Shift_Focus( this : not null access Ked_Scene'Class; x,y : Float ); 
  48.  
  49.     -- Zooms in, keeping the scene focus centered. 
  50.     procedure Zoom_In( this : not null access Ked_Scene'Class ); 
  51.  
  52.     -- Zooms out, keeping the scene focus centered. 
  53.     procedure Zoom_Out( this : not null access Ked_Scene'Class ); 
  54.  
  55.     -- Sets the absolute zoom factor for the scene, keeping the current focus 
  56.     -- point centered. 
  57.     procedure Zoom_With_Focus( this   : not null access Ked_Scene'Class; 
  58.                                factor : Float ); 
  59.  
  60. private 
  61.  
  62.     use Physics.Clip_Maps; 
  63.  
  64.     type Ked_Scene is new Scene with 
  65.         record 
  66.             leftMouse       : Boolean := False; 
  67.             rightMouse      : Boolean := False; 
  68.             middleMouse     : Boolean := False; 
  69.             activeModifiers : Modifiers_Array := Modifiers_Array'(others=>False); 
  70.             activeLayer     : Natural := 0; 
  71.             scrollSpeed     : Float := 0.0; 
  72.             clipMap         : A_Clip_Map := null; 
  73.             dragStartX, 
  74.             dragStartY      : Integer := -1; 
  75.         end record; 
  76.  
  77.     procedure Construct( this : access Ked_Scene; 
  78.                          view : not null access Game_Views.Game_View'Class; 
  79.                          id   : String ); 
  80.     pragma Precondition( id'Length > 0 ); 
  81.  
  82.     procedure Delete( this : in out Ked_Scene ); 
  83.  
  84.     procedure Draw_Layer( this   : access Ked_Scene; 
  85.                           dc     : Drawing_Context; 
  86.                           layer  : Positive; 
  87.                           startX, 
  88.                           startY : Integer; 
  89.                           tileX1, 
  90.                           tileY1, 
  91.                           tileX2, 
  92.                           tileY2 : Integer ); 
  93.  
  94.     procedure Draw_Layer_Overlay( this   : access Ked_Scene; 
  95.                                   dc     : Drawing_Context; 
  96.                                   startX, 
  97.                                   startY : Integer; 
  98.                                   tileX1, 
  99.                                   tileY1, 
  100.                                   tileX2, 
  101.                                   tileY2 : Integer ); 
  102.  
  103.     procedure Handle_Entity_Created( this : access Ked_Scene; 
  104.                                      evt  : not null A_Entity_Created_Event ); 
  105.  
  106.     procedure Handle_Exit( this : access Ked_Scene ); 
  107.  
  108.     procedure Handle_Mouse_Move( this : access Ked_Scene; 
  109.                                  evt  : not null A_Mouse_Event ); 
  110.  
  111.     procedure Handle_Mouse_Press( this : access Ked_Scene; 
  112.                                   evt  : not null A_Mouse_Button_Event ); 
  113.  
  114.     procedure Handle_Mouse_Release( this : access Ked_Scene; 
  115.                                     evt  : not null A_Mouse_Button_Event ); 
  116.  
  117.     function Handle_Mouse_Scroll( this   : access Ked_Scene; 
  118.                                   x, y   : Integer; 
  119.                                   amount : Integer ) return Boolean; 
  120.  
  121.     procedure Handle_Resize( this : access Ked_Scene ); 
  122.  
  123.     procedure Handle_Tile_Changed( this : access Ked_Scene; 
  124.                                    evt  : not null A_Tile_Changed_Event ); 
  125.  
  126.     procedure Handle_World_Loaded( this : access Ked_Scene; 
  127.                                    evt  : not null A_World_Loaded_Event ); 
  128.  
  129.  
  130. end Widgets.Containers.Scenes.Ked;