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. private with Physics.Clip_Maps; 
  10.  
  11. package Widgets.Containers.Scenes.Ked is 
  12.  
  13.     type Ked_Scene is new Scene with private; 
  14.     type A_Ked_Scene is access all Ked_Scene'Class; 
  15.  
  16.     function Create_Scene( view : not null access Game_Views.Game_View'Class; 
  17.                            id   : String ) return A_Ked_Scene; 
  18.     pragma Precondition( id'Length > 0 ); 
  19.     pragma Postcondition( Create_Scene'Result /= null ); 
  20.  
  21.     -- Returns the layer currently active for tools. 
  22.     function Get_Active_Layer( this : not null access Ked_Scene'Class ) return Natural; 
  23.  
  24.     -- Returns the scene's X focus in world coordinates. 
  25.     function Get_Focus_X( this : not null access Ked_Scene'Class ) return Float; 
  26.  
  27.     -- Returns the scene's Y focus in world coordinates. 
  28.     function Get_Focus_Y( this : not null access Ked_Scene'Class ) return Float; 
  29.  
  30.     -- Sets the active layer for editing tiles. 
  31.     procedure Set_Active_Layer( this  : not null access Ked_Scene'Class; 
  32.                                 layer : Positive ); 
  33.  
  34.     -- Sets the visibility for a layer. 
  35.     procedure Set_Layer_Visible( this    : not null access Ked_Scene'Class; 
  36.                                  layer   : Positive; 
  37.                                  visible : Boolean ); 
  38.  
  39.     -- Moves the focus point of the scene relative to it's current location. 
  40.     procedure Shift_Focus( this : not null access Ked_Scene'Class; x,y : Float ); 
  41.  
  42.     -- Zooms in, keeping the scene focus centered. 
  43.     procedure Zoom_In( this : not null access Ked_Scene'Class ); 
  44.  
  45.     -- Zooms out, keeping the scene focus centered. 
  46.     procedure Zoom_Out( this : not null access Ked_Scene'Class ); 
  47.  
  48.     -- Sets the absolute zoom factor for the scene, keeping the current focus 
  49.     -- point centered. 
  50.     procedure Zoom_With_Focus( this   : not null access Ked_Scene'Class; 
  51.                                factor : Float ); 
  52.  
  53. private 
  54.  
  55.     use Physics.Clip_Maps; 
  56.  
  57.     type Ked_Scene is new Scene with 
  58.         record 
  59.             leftMouse       : Boolean := False; 
  60.             rightMouse      : Boolean := False; 
  61.             middleMouse     : Boolean := False; 
  62.             activeModifiers : Modifiers_Array := Modifiers_Array'(others=>False); 
  63.             activeLayer     : Natural := 0; 
  64.             scrollSpeed     : Float := 0.0; 
  65.             clipMap         : A_Clip_Map := null; 
  66.             dragStartX, 
  67.             dragStartY      : Integer := -1; 
  68.         end record; 
  69.  
  70.     procedure Construct( this : access Ked_Scene; 
  71.                          view : not null access Game_Views.Game_View'Class; 
  72.                          id   : String ); 
  73.     pragma Precondition( id'Length > 0 ); 
  74.  
  75.     procedure Delete( this : in out Ked_Scene ); 
  76.  
  77.     procedure Draw_Layer( this   : access Ked_Scene; 
  78.                           layer  : Positive; 
  79.                           startX, 
  80.                           startY : Integer; 
  81.                           tileX1, 
  82.                           tileY1, 
  83.                           tileX2, 
  84.                           tileY2 : Integer ); 
  85.  
  86.     procedure Draw_Layer_Overlay( this   : access Ked_Scene; 
  87.                                   startX, 
  88.                                   startY : Integer; 
  89.                                   tileX1, 
  90.                                   tileY1, 
  91.                                   tileX2, 
  92.                                   tileY2 : Integer ); 
  93.  
  94.     procedure Handle_Entity_Created( this : access Ked_Scene; 
  95.                                      evt  : not null A_Entity_Created_Event ); 
  96.  
  97.     procedure Handle_Tile_Changed( this : access Ked_Scene; 
  98.                                    evt  : not null A_Tile_Changed_Event ); 
  99.  
  100.     procedure Handle_World_Loaded( this : access Ked_Scene; 
  101.                                    evt  : not null A_World_Loaded_Event ); 
  102.  
  103.     procedure On_Exit( this : access Ked_Scene ); 
  104.  
  105.     procedure On_Mouse_Move( this : access Ked_Scene; 
  106.                              evt  : not null A_Mouse_Event ); 
  107.  
  108.     procedure On_Mouse_Press( this : access Ked_Scene; 
  109.                               evt  : not null A_Mouse_Button_Event ); 
  110.  
  111.     procedure On_Mouse_Release( this : access Ked_Scene; 
  112.                                 evt  : not null A_Mouse_Button_Event ); 
  113.  
  114.     procedure On_Mouse_Scroll( this    : access Ked_Scene; 
  115.                                x, y    : Integer; 
  116.                                amount  : Integer; 
  117.                                handled : in out Boolean ); 
  118.  
  119.     procedure On_Resize( this : access Ked_Scene ); 
  120.  
  121. end Widgets.Containers.Scenes.Ked;