| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | // Aseprite
 | 
					
						
							|  |  |  | // Copyright (C) 2001-2018  David Capello
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This program is distributed under the terms of
 | 
					
						
							|  |  |  | // the End-User License Agreement for Aseprite.
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef APP_SCRIPTING_H_INCLUDED
 | 
					
						
							|  |  |  | #define APP_SCRIPTING_H_INCLUDED
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef ENABLE_SCRIPTING
 | 
					
						
							|  |  |  |   #error ENABLE_SCRIPTING must be defined
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-05 03:10:32 +08:00
										 |  |  | #include "app/color.h"
 | 
					
						
							|  |  |  | #include "doc/frame.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-04 05:04:44 +08:00
										 |  |  | #include "doc/image_ref.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | #include "doc/object_id.h"
 | 
					
						
							|  |  |  | #include "gfx/fwd.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <cstdio>
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							|  |  |  | #include <map>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct lua_State; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace doc { | 
					
						
							| 
									
										
										
										
											2018-08-31 07:47:11 +08:00
										 |  |  |   class Cel; | 
					
						
							| 
									
										
										
										
											2018-09-05 03:10:32 +08:00
										 |  |  |   class FrameTag; | 
					
						
							|  |  |  |   class Layer; | 
					
						
							|  |  |  |   class Palette; | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  |   class Sprite; | 
					
						
							| 
									
										
										
										
											2018-09-05 03:10:32 +08:00
										 |  |  |   class WithUserData; | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace app { | 
					
						
							|  |  |  |   class Site; | 
					
						
							| 
									
										
										
										
											2018-09-01 01:30:32 +08:00
										 |  |  |   namespace script { | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   class EngineDelegate { | 
					
						
							|  |  |  |   public: | 
					
						
							|  |  |  |     virtual ~EngineDelegate() { } | 
					
						
							|  |  |  |     virtual void onConsolePrint(const char* text) = 0; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class Engine { | 
					
						
							|  |  |  |   public: | 
					
						
							| 
									
										
										
										
											2018-09-01 01:30:32 +08:00
										 |  |  |     Engine(); | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  |     ~Engine(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-01 01:30:32 +08:00
										 |  |  |     void setDelegate(EngineDelegate* delegate) { | 
					
						
							|  |  |  |       m_delegate = delegate; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  |     void printLastResult(); | 
					
						
							|  |  |  |     bool evalCode(const std::string& code, | 
					
						
							|  |  |  |                   const std::string& filename = std::string()); | 
					
						
							|  |  |  |     bool evalFile(const std::string& filename); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   private: | 
					
						
							| 
									
										
										
										
											2018-09-01 01:30:32 +08:00
										 |  |  |     void onConsolePrint(const char* text); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  |     lua_State* L; | 
					
						
							|  |  |  |     EngineDelegate* m_delegate; | 
					
						
							|  |  |  |     bool m_printLastResult; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 05:04:44 +08:00
										 |  |  |   int push_image_iterator_function(lua_State* L, const doc::ImageRef& image); | 
					
						
							| 
									
										
										
										
											2018-09-05 03:10:32 +08:00
										 |  |  |   void push_cel_image(lua_State* L, doc::Cel* cel); | 
					
						
							|  |  |  |   void push_sprite_cel(lua_State* L, doc::Cel* cel); | 
					
						
							|  |  |  |   void push_sprite_cels(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_frame(lua_State* L, doc::Sprite* sprite, doc::frame_t frame); | 
					
						
							|  |  |  |   void push_sprite_frames(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_layers(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_palette(lua_State* L, doc::Sprite* sprite, doc::Palette* palette); | 
					
						
							|  |  |  |   void push_sprite_palettes(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_selection(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_slices(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_sprite_tags(lua_State* L, doc::Sprite* sprite); | 
					
						
							|  |  |  |   void push_userdata(lua_State* L, doc::WithUserData* userData); | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   gfx::Point convert_args_into_point(lua_State* L, int index); | 
					
						
							|  |  |  |   gfx::Rect convert_args_into_rect(lua_State* L, int index); | 
					
						
							|  |  |  |   gfx::Size convert_args_into_size(lua_State* L, int index); | 
					
						
							| 
									
										
										
										
											2018-09-05 03:10:32 +08:00
										 |  |  |   app::Color convert_args_into_color(lua_State* L, int index); | 
					
						
							|  |  |  |   doc::color_t convert_args_into_pixel_color(lua_State* L, int index); | 
					
						
							| 
									
										
										
										
											2018-08-20 22:25:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace script
 | 
					
						
							|  |  |  | } // namespace app
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |