Advertisement
Guest User

Untitled

a guest
Feb 18th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.66 KB | None | 0 0
  1. //=============================================================================
  2. //
  3. // Adventure Game Studio (AGS)
  4. //
  5. // Copyright (C) 1999-2011 Chris Jones and 2011-2025 various contributors
  6. // The full list of copyright holders can be found in the Copyright.txt
  7. // file, which is part of this source code distribution.
  8. //
  9. // The AGS source code is provided under the Artistic License 2.0.
  10. // A copy of this license can be found in the file License.txt and at
  11. // https://opensource.org/license/artistic-2-0/
  12. //
  13. //=============================================================================
  14. //
  15. // AGS Plugin interface header file.
  16. //
  17. // #define THIS_IS_THE_PLUGIN beforehand if including from the plugin.
  18. //
  19. //=============================================================================
  20. #ifndef _AGS_PLUGIN_H
  21. #define _AGS_PLUGIN_H
  22.  
  23. #include <stddef.h> // for size_t
  24. #include <stdint.h>
  25.  
  26. // If the plugin isn't using DDraw, don't require the headers
  27. #ifndef DIRECTDRAW_VERSION
  28. typedef void *LPDIRECTDRAW2;
  29. typedef void *LPDIRECTDRAWSURFACE2;
  30. #endif
  31.  
  32. #ifndef DIRECTSOUND_VERSION
  33. typedef void *LPDIRECTSOUND;
  34. #endif
  35.  
  36. #ifndef DIRECTINPUT_VERSION
  37. typedef void *LPDIRECTINPUTDEVICE;
  38. #endif
  39.  
  40. // If the user isn't using Allegro or WinGDI, define the BITMAP into something
  41. #if !defined(ALLEGRO_H) && !defined(_WINGDI_) && !defined(BITMAP_DEFINED)
  42. typedef void BITMAP;
  43. #endif
  44.  
  45. // If not using windows.h, define HWND
  46. #if !defined(_WINDOWS_)
  47. typedef void *HWND;
  48. #endif
  49.  
  50. // This file is distributed as part of the Plugin API docs, so
  51. // ensure that WINDOWS_VERSION is defined (if applicable)
  52. #if defined(_WIN32)
  53. #undef WINDOWS_VERSION
  54. #define WINDOWS_VERSION
  55. #endif
  56.  
  57. // DOS engine doesn't know about stdcall / neither does Linux version
  58. #if !defined (_WIN32)
  59. #define __stdcall
  60. #endif
  61.  
  62. #ifndef int32
  63. typedef int int32;
  64. #endif
  65.  
  66. #define AGSIFUNC(type) virtual type __stdcall
  67.  
  68. #define MASK_WALKABLE 1
  69. #define MASK_WALKBEHIND 2
  70. #define MASK_HOTSPOT 3
  71. // MASK_REGIONS is interface version 11 and above only
  72. #define MASK_REGIONS 4
  73.  
  74. // **** WARNING: DO NOT ALTER THESE CLASSES IN ANY WAY!
  75. // **** CHANGING THE ORDER OF THE FUNCTIONS OR ADDING ANY VARIABLES
  76. // **** WILL CRASH THE SYSTEM.
  77.  
  78. struct AGSColor {
  79. unsigned char r,g,b;
  80. unsigned char padding;
  81. };
  82.  
  83. struct AGSGameOptions {
  84. int32 score; // player's current score
  85. int32 usedmode; // set by ProcessClick to last cursor mode used
  86. int32 disabled_user_interface; // >0 while in cutscene/etc
  87. int32 gscript_timer; // obsolete
  88. int32 debug_mode; // whether we're in debug mode
  89. int32 globalvars[50]; // obsolete
  90. int32 messagetime; // time left for auto-remove messages
  91. int32 usedinv; // inventory item last used
  92. int32 inv_top,inv_numdisp,inv_numorder,inv_numinline;
  93. int32 text_speed; // how quickly text is removed
  94. int32 sierra_inv_color; // background used to paint defualt inv window
  95. int32 talkanim_speed; // animation speed of talking anims
  96. int32 inv_item_wid,inv_item_hit; // set by SetInvDimensions
  97. int32 speech_text_shadow; // colour of outline fonts (default black)
  98. int32 swap_portrait_side; // sierra-style speech swap sides
  99. int32 speech_textwindow_gui; // textwindow used for sierra-style speech
  100. int32 follow_change_room_timer; // delay before moving following characters into new room
  101. int32 totalscore; // maximum possible score
  102. int32 skip_display; // how the user can skip normal Display windows
  103. int32 no_multiloop_repeat; // for backwards compatibility
  104. int32 roomscript_finished; // on_call finished in room
  105. int32 used_inv_on; // inv item they clicked on
  106. int32 no_textbg_when_voice; // no textwindow bgrnd when voice speech is used
  107. int32 max_dialogoption_width; // max width of dialog options text window
  108. int32 no_hicolor_fadein; // fade out but instant in for hi-color
  109. int32 bgspeech_game_speed; // is background speech relative to game speed
  110. int32 bgspeech_stay_on_display; // whether to remove bg speech when DisplaySpeech is used
  111. int32 unfactor_speech_from_textlength; // remove "&10" when calculating time for text to stay
  112. int32 mp3_loop_before_end; // loop this time before end of track (ms)
  113. int32 speech_music_drop; // how much to drop music volume by when speech is played
  114. int32 in_cutscene; // we are between a StartCutscene and EndCutscene
  115. int32 fast_forward; // player has elected to skip cutscene
  116. int32 room_width; // width of current room
  117. int32 room_height; // height of current room
  118. };
  119.  
  120. // AGSCharacter.flags
  121. #define CHF_NOSCALING 1
  122. #define CHF_FIXVIEW 2 // between SetCharView and ReleaseCharView
  123. #define CHF_NOINTERACT 4
  124. #define CHF_NODIAGONAL 8
  125. #define CHF_ALWAYSIDLE 0x10
  126. #define CHF_NOLIGHTING 0x20
  127. #define CHF_NOTURNING 0x40
  128. #define CHF_NOWALKBEHINDS 0x80
  129.  
  130. struct AGSCharacter {
  131. int32 defview;
  132. int32 talkview;
  133. int32 view;
  134. int32 room, prevroom;
  135. int32 x, y, wait;
  136. int32 flags;
  137. short following;
  138. short followinfo;
  139. int32 idleview; // the loop will be randomly picked
  140. short idletime, idleleft; // num seconds idle before playing anim
  141. short transparency; // if character is transparent
  142. short baseline;
  143. int32 activeinv;
  144. int32 talkcolor;
  145. int32 thinkview;
  146. int32 reserved[2];
  147. short walkspeed_y, pic_yoffs;
  148. int32 z;
  149. int32 reserved2[5];
  150. short loop, frame;
  151. short walking, animating;
  152. short walkspeed, animspeed;
  153. short inv[301];
  154. short actx, acty;
  155. char name[40];
  156. char scrname[20];
  157. char on;
  158. };
  159.  
  160. // AGSObject.flags
  161. #define OBJF_NOINTERACT 1 // not clickable
  162. #define OBJF_NOWALKBEHINDS 2 // ignore walk-behinds
  163.  
  164. struct AGSObject {
  165. int32 x,y;
  166. int32 transparent; // current transparency setting
  167. int32 reserved[4];
  168. short num; // sprite slot number
  169. short baseline; // <=0 to use Y co-ordinate; >0 for specific baseline
  170. short view,loop,frame; // only used to track animation - 'num' holds the current sprite
  171. short wait,moving;
  172. char cycling; // is it currently animating?
  173. char overall_speed;
  174. char on;
  175. char flags;
  176. };
  177.  
  178. // AGSViewFrame.flags
  179. #define FRAF_MIRRORED 1 // flipped left to right
  180.  
  181. struct AGSViewFrame {
  182. int32 pic; // sprite slot number
  183. short xoffs, yoffs;
  184. short speed;
  185. int32 flags;
  186. int32 sound; // play sound when this frame comes round
  187. int32 reserved_for_future[2];
  188. };
  189.  
  190. // AGSMouseCursor.flags
  191. #define MCF_ANIMATEMOVE 1
  192. #define MCF_DISABLED 2
  193. #define MCF_STANDARD 4
  194. #define MCF_ONLYANIMOVERHOTSPOT 8
  195.  
  196. struct AGSMouseCursor {
  197. int32 pic; // sprite slot number
  198. short hotx, hoty; // x,y hotspot co-ordinates
  199. short view; // view (for animating cursors) or -1
  200. char name[10]; // name of cursor mode
  201. char flags; // MCF_flags above
  202. };
  203.  
  204. // GetFontType font types
  205. #define FNT_INVALID 0
  206. #define FNT_SCI 1
  207. #define FNT_TTF 2
  208.  
  209. // PlaySoundChannel sound types
  210. #define PSND_WAVE 1
  211. #define PSND_MP3STREAM 2
  212. #define PSND_MP3STATIC 3
  213. #define PSND_OGGSTREAM 4
  214. #define PSND_OGGSTATIC 5
  215. #define PSND_MIDI 6
  216. #define PSND_MOD 7
  217.  
  218. class IAGSScriptManagedObject {
  219. public:
  220. // when a ref count reaches 0, this is called with the address
  221. // of the object. Return 1 to remove the object from memory, 0 to
  222. // leave it
  223. virtual int Dispose(void *address, bool force) = 0;
  224. // return the type name of the object
  225. virtual const char *GetType() = 0;
  226. // serialize the object into BUFFER (which is BUFSIZE bytes)
  227. // return number of bytes used
  228. virtual int Serialize(void *address, char *buffer, int bufsize) = 0;
  229. protected:
  230. IAGSScriptManagedObject() {};
  231. ~IAGSScriptManagedObject() {};
  232. };
  233.  
  234. class IAGSManagedObjectReader {
  235. public:
  236. virtual void Unserialize(int key, const char *serializedData, int dataSize) = 0;
  237. protected:
  238. IAGSManagedObjectReader() {};
  239. ~IAGSManagedObjectReader() {};
  240. };
  241.  
  242. class IAGSFontRenderer {
  243. public:
  244. virtual bool LoadFromDisk(int fontNumber, int fontSize) = 0;
  245. virtual void FreeMemory(int fontNumber) = 0;
  246. virtual bool SupportsExtendedCharacters(int fontNumber) = 0;
  247. virtual int GetTextWidth(const char *text, int fontNumber) = 0;
  248. virtual int GetTextHeight(const char *text, int fontNumber) = 0;
  249. virtual void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) = 0;
  250. virtual void AdjustYCoordinateForFont(int *ycoord, int fontNumber) = 0;
  251. virtual void EnsureTextValidForFont(char *text, int fontNumber) = 0;
  252. protected:
  253. IAGSFontRenderer() = default;
  254. ~IAGSFontRenderer() = default;
  255. };
  256.  
  257. class IAGSFontRenderer2 : public IAGSFontRenderer {
  258. virtual int GetVersion() = 0;
  259. virtual const char *GetRendererName() = 0;
  260. virtual const char *GetFontName(int fontNumber) = 0;
  261. virtual int GetFontHeight(int fontNumber) = 0;
  262. virtual int GetLineSpacing(int fontNumber) = 0;
  263. protected:
  264. IAGSFontRenderer2() = default;
  265. ~IAGSFontRenderer2() = default;
  266. };
  267.  
  268. struct AGSRenderMatrixes {
  269. float WorldMatrix[16];
  270. float ViewMatrix[16];
  271. float ProjMatrix[16];
  272. };
  273.  
  274. // Render stage description
  275. struct AGSRenderStageDesc {
  276. // Which version of the plugin interface the struct corresponds to;
  277. // this field must be filled by a plugin before passing the struct into the engine!
  278. int Version;
  279. // Stage's matrixes, for 3D rendering: Projection, World and View
  280. AGSRenderMatrixes Matrixes;
  281. };
  282.  
  283. // Game info
  284. struct AGSGameInfo {
  285. // Which version of the plugin interface the struct corresponds to;
  286. // this field must be filled by a plugin before passing the struct into the engine!
  287. int Version;
  288. // Game title (human-readable text)
  289. char GameName[50];
  290. // Game's GUID
  291. char Guid[40];
  292. // Random key identifying the game (deprecated)
  293. int UniqueId;
  294. };
  295.  
  296. // File open modes
  297. // Opens existing file, fails otherwise
  298. #define AGSSTREAM_FILE_OPEN 1
  299. // Opens existing file, creates one if it did not exist
  300. #define AGSSTREAM_FILE_CREATE 2
  301. // Always creates a new file, completely overwrites any existing one
  302. #define AGSSTREAM_FILE_CREATEALWAYS 3
  303.  
  304. // Stream work modes
  305. // Read-only
  306. #define AGSSTREAM_MODE_READ 0x01
  307. // Write-only
  308. #define AGSSTREAM_MODE_WRITE 0x02
  309. // Supports both read and write
  310. #define AGSSTREAM_MODE_READWRITE (AGSSTREAM_MODE_READ | AGSSTREAM_MODE_WRITE)
  311. // Supports seeking
  312. #define AGSSTREAM_MODE_SEEK 0x04
  313.  
  314. // Stream seek origins
  315. // Seek from the beginning of a stream (towards positive offset)
  316. #define AGSSTREAM_SEEK_SET 0
  317. // Seek from the current position (towards positive or negative offset)
  318. #define AGSSTREAM_SEEK_CUR 1
  319. // Seek from the end of a stream (towards negative offset)
  320. #define AGSSTREAM_SEEK_END 2
  321.  
  322. class IAGSStream {
  323. public:
  324. // Tells which mode the stream is working in, which defines
  325. // supported io operations, such as reading, writing, seeking, etc.
  326. // Returns combination of AGSSTREAM_MODE_* flags.
  327. // Invalid or non-functional streams return 0.
  328. virtual int GetMode() const = 0;
  329. // Returns an optional stream's source description.
  330. // This may be a file path, or a resource name, or anything of that kind,
  331. // and is purely for diagnostic purposes.
  332. virtual const char *GetPath() const = 0;
  333. // Tells whether this stream's position is at its end;
  334. // note that unlike standard C feof this does not wait for a read attempt
  335. // past the stream end, and reports positive when position = length.
  336. virtual bool EOS() const = 0;
  337. // Tells if there were errors during previous io operation(s);
  338. // the call to GetError() *resets* the error record.
  339. virtual bool GetError() const = 0;
  340. // Returns the total stream's length in bytes
  341. virtual int64_t GetLength() const = 0;
  342. // Returns stream's position
  343. virtual int64_t GetPosition() const = 0;
  344.  
  345. // Reads number of bytes into the provided buffer
  346. virtual size_t Read(void *buffer, size_t len) = 0;
  347. // ReadByte conforms to standard C fgetc behavior:
  348. // - on success returns an *unsigned char* packed in the int32
  349. // - on failure (EOS or other error), returns -1
  350. virtual int32_t ReadByte() = 0;
  351. // Writes number of bytes from the provided buffer
  352. virtual size_t Write(const void *buffer, size_t len) = 0;
  353. // WriteByte conforms to standard C fputc behavior:
  354. // - on success, returns the written unsigned char packed in the int32
  355. // - on failure, returns -1
  356. virtual int32_t WriteByte(uint8_t b) = 0;
  357. // Seeks to offset from the origin defined by AGSSTREAM_SEEK_* constants:
  358. // * AGSSTREAM_SEEK_SET - seek from the beginning;
  359. // * AGSSTREAM_SEEK_CUR - seek from the current position;
  360. // * AGSSTREAM_SEEK_END - seek from the end (pass negative offset)
  361. // Returns new position in stream, or -1 on error.
  362. virtual int64_t Seek(int64_t offset, int origin) = 0;
  363. // Flushes stream, forcing it to write any buffered data to the
  364. // underlying device. Note that the effect may depend on implementation.
  365. virtual bool Flush() = 0;
  366. // Flushes and closes the stream.
  367. // Usually you do not have to call this, use Dispose() to close
  368. // and delete stream object instead.
  369. virtual void Close() = 0;
  370.  
  371. // Closes the stream and deallocates the stream object.
  372. // After calling this the IAGSStream pointer becomes INVALID.
  373. virtual void Dispose() = 0;
  374.  
  375. protected:
  376. IAGSStream() = default;
  377. ~IAGSStream() = default;
  378. };
  379.  
  380.  
  381. // Plugin events
  382. //
  383. // Below are interface 3 and later
  384. #define AGSE_KEYPRESS 0x01
  385. #define AGSE_MOUSECLICK 0x02
  386. #define AGSE_POSTSCREENDRAW 0x04
  387. // Below are interface 4 and later
  388. #define AGSE_PRESCREENDRAW 0x08
  389. // Below are interface 5 and later
  390. #define AGSE_SAVEGAME 0x10
  391. #define AGSE_RESTOREGAME 0x20
  392. // Below are interface 6 and later
  393. #define AGSE_PREGUIDRAW 0x40
  394. #define AGSE_LEAVEROOM 0x80
  395. #define AGSE_ENTERROOM 0x100
  396. #define AGSE_TRANSITIONIN 0x200
  397. #define AGSE_TRANSITIONOUT 0x400
  398. // Below are interface 12 and later
  399. #define AGSE_FINALSCREENDRAW 0x800
  400. #define AGSE_TRANSLATETEXT 0x1000
  401. // Below are interface 13 and later
  402. #define AGSE_SCRIPTDEBUG 0x2000
  403. // AGSE_AUDIODECODE is no longer supported
  404. #define AGSE_AUDIODECODE 0x4000
  405. // Below are interface 18 and later
  406. #define AGSE_SPRITELOAD 0x8000
  407. // Below are interface 21 and later
  408. #define AGSE_PRERENDER 0x10000
  409. // Below are interface 24 and later
  410. #define AGSE_PRESAVEGAME 0x20000
  411. #define AGSE_POSTRESTOREGAME 0x40000
  412. // Below are interface 26 and later
  413. #define AGSE_POSTROOMDRAW 0x80000
  414. #define AGSE_TOOHIGH 0x100000
  415.  
  416. // Logging levels
  417. #define AGSLOG_LEVEL_NONE 0
  418. #define AGSLOG_LEVEL_ALERT 1
  419. #define AGSLOG_LEVEL_FATAL 2
  420. #define AGSLOG_LEVEL_ERROR 3
  421. #define AGSLOG_LEVEL_WARN 4
  422. #define AGSLOG_LEVEL_INFO 5
  423. #define AGSLOG_LEVEL_DEBUG 6
  424.  
  425.  
  426. // The plugin-to-engine interface
  427. class IAGSEngine {
  428. public:
  429. int32 version;
  430. int32 pluginId; // used internally, do not touch
  431.  
  432. public:
  433. // quit the game
  434. AGSIFUNC(void) AbortGame (const char *reason);
  435. // get engine version
  436. AGSIFUNC(const char*) GetEngineVersion ();
  437. // register a script function with the system
  438. AGSIFUNC(void) RegisterScriptFunction (const char *name, void *address);
  439. #ifdef WINDOWS_VERSION
  440. // get game window handle
  441. AGSIFUNC(HWND) GetWindowHandle();
  442. // get reference to main DirectDraw interface
  443. AGSIFUNC(LPDIRECTDRAW2) GetDirectDraw2 ();
  444. // get the DDraw surface associated with a bitmap
  445. AGSIFUNC(LPDIRECTDRAWSURFACE2) GetBitmapSurface (BITMAP *);
  446. #endif
  447. // get a reference to the screen bitmap
  448. AGSIFUNC(BITMAP *) GetScreen ();
  449.  
  450. // *** BELOW ARE INTERFACE VERSION 2 AND ABOVE ONLY
  451. // ask the engine to call back when a certain event happens
  452. AGSIFUNC(void) RequestEventHook (int32 event);
  453. // get the options data saved in the editor
  454. AGSIFUNC(int) GetSavedData (char *buffer, int32 bufsize);
  455.  
  456. // *** BELOW ARE INTERFACE VERSION 3 AND ABOVE ONLY
  457. // get the virtual screen
  458. AGSIFUNC(BITMAP *) GetVirtualScreen ();
  459. // write text to the screen in the specified font and colour
  460. AGSIFUNC(void) DrawText (int32 x, int32 y, int32 font, int32 color, char *text);
  461. // get screen dimensions
  462. AGSIFUNC(void) GetScreenDimensions (int32 *width, int32 *height, int32 *coldepth);
  463. // get screen surface to draw on
  464. AGSIFUNC(unsigned char**) GetRawBitmapSurface (BITMAP *);
  465. // release the surface
  466. AGSIFUNC(void) ReleaseBitmapSurface (BITMAP *);
  467. // get the current mouse co-ordinates
  468. AGSIFUNC(void) GetMousePosition (int32 *x, int32 *y);
  469.  
  470. // *** BELOW ARE INTERFACE VERSION 4 AND ABOVE ONLY
  471. // get the current room number
  472. AGSIFUNC(int) GetCurrentRoom ();
  473. // get the number of background scenes in this room
  474. AGSIFUNC(int) GetNumBackgrounds ();
  475. // get the current background frame
  476. AGSIFUNC(int) GetCurrentBackground ();
  477. // get a background scene bitmap
  478. AGSIFUNC(BITMAP *) GetBackgroundScene (int32);
  479. // get dimensions of a bitmap
  480. AGSIFUNC(void) GetBitmapDimensions (BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth);
  481.  
  482. // *** BELOW ARE INTERFACE VERSION 5 AND ABOVE ONLY
  483. // similar to fwrite - buffer, size, filehandle
  484. AGSIFUNC(int) FWrite (void *out_buf, int32 len, int32 fhandle);
  485. // similar to fread - buffer, size, filehandle
  486. AGSIFUNC(int) FRead (void *in_buf, int32 len, int32 fhandle);
  487. // print text, wrapping as usual
  488. AGSIFUNC(void) DrawTextWrapped (int32 x, int32 y, int32 width, int32 font, int32 color, const char *text);
  489. // set the current active 'screen'
  490. AGSIFUNC(void) SetVirtualScreen (BITMAP *);
  491. // look up a word in the parser dictionary
  492. AGSIFUNC(int) LookupParserWord (const char *word);
  493. // draw a bitmap to the active screen
  494. AGSIFUNC(void) BlitBitmap (int32 x, int32 y, BITMAP *, int32 masked);
  495. // update the mouse and music
  496. AGSIFUNC(void) PollSystem ();
  497.  
  498. // *** BELOW ARE INTERFACE VERSION 6 AND ABOVE ONLY
  499. // get number of characters in game
  500. AGSIFUNC(int) GetNumCharacters ();
  501. // get reference to specified character struct
  502. AGSIFUNC(AGSCharacter*) GetCharacter (int32);
  503. // get reference to game struct
  504. AGSIFUNC(AGSGameOptions*) GetGameOptions ();
  505. // get reference to current palette
  506. AGSIFUNC(AGSColor*) GetPalette();
  507. // update palette
  508. AGSIFUNC(void) SetPalette (int32 start, int32 finish, AGSColor*);
  509.  
  510. // *** BELOW ARE INTERFACE VERSION 7 AND ABOVE ONLY
  511. // get the current player character
  512. AGSIFUNC(int) GetPlayerCharacter ();
  513. // adjust to main viewport co-ordinates
  514. AGSIFUNC(void) RoomToViewport (int32 *x, int32 *y);
  515. // adjust from main viewport co-ordinates (ignores viewport bounds)
  516. AGSIFUNC(void) ViewportToRoom (int32 *x, int32 *y);
  517. // number of objects in current room
  518. AGSIFUNC(int) GetNumObjects ();
  519. // get reference to specified object
  520. AGSIFUNC(AGSObject*) GetObject (int32);
  521. // get sprite graphic
  522. AGSIFUNC(BITMAP *) GetSpriteGraphic (int32);
  523. // create a new blank bitmap
  524. AGSIFUNC(BITMAP *) CreateBlankBitmap (int32 width, int32 height, int32 coldep);
  525. // free a created bitamp
  526. AGSIFUNC(void) FreeBitmap (BITMAP *);
  527.  
  528. // *** BELOW ARE INTERFACE VERSION 8 AND ABOVE ONLY
  529. // get one of the room area masks
  530. AGSIFUNC(BITMAP *) GetRoomMask(int32);
  531.  
  532. // *** BELOW ARE INTERFACE VERSION 9 AND ABOVE ONLY
  533. // get a particular view frame
  534. AGSIFUNC(AGSViewFrame *) GetViewFrame(int32 view, int32 loop, int32 frame);
  535. // get the walk-behind baseline of a specific WB area
  536. AGSIFUNC(int) GetWalkbehindBaseline(int32 walkbehind);
  537. // get the address of a script function
  538. AGSIFUNC(void *) GetScriptFunctionAddress(const char * funcName);
  539. // get the transparent colour of a bitmap
  540. AGSIFUNC(int) GetBitmapTransparentColor(BITMAP *);
  541. // get the character scaling level at a particular point
  542. AGSIFUNC(int) GetAreaScaling (int32 x, int32 y);
  543. // equivalent to the text script function
  544. AGSIFUNC(int) IsGamePaused();
  545.  
  546. // *** BELOW ARE INTERFACE VERSION 10 AND ABOVE ONLY
  547. // get the raw pixel value to use for the specified AGS colour
  548. AGSIFUNC(int) GetRawPixelColor (int32 color);
  549.  
  550. // *** BELOW ARE INTERFACE VERSION 11 AND ABOVE ONLY
  551. // get the width / height of the specified sprite
  552. AGSIFUNC(int) GetSpriteWidth (int32);
  553. AGSIFUNC(int) GetSpriteHeight (int32);
  554. // get the dimensions of the specified string in the specified font
  555. AGSIFUNC(void) GetTextExtent (int32 font, const char *text, int32 *width, int32 *height);
  556. // print a message to the debug console
  557. AGSIFUNC(void) PrintDebugConsole (const char *text);
  558. // play a sound on the specified channel
  559. AGSIFUNC(void) PlaySoundChannel (int32 channel, int32 soundType, int32 volume, int32 loop, const char *filename);
  560. // same as text script function
  561. AGSIFUNC(int) IsChannelPlaying (int32 channel);
  562.  
  563. // *** BELOW ARE INTERFACE VERSION 12 AND ABOVE ONLY
  564. // invalidate a region of the virtual screen
  565. AGSIFUNC(void) MarkRegionDirty(int32 left, int32 top, int32 right, int32 bottom);
  566. // get mouse cursor details
  567. AGSIFUNC(AGSMouseCursor *) GetMouseCursor(int32 cursor);
  568. // get the various components of a pixel
  569. AGSIFUNC(void) GetRawColorComponents(int32 coldepth, int32 color, int32 *red, int32 *green, int32 *blue, int32 *alpha);
  570. // make a pixel colour from the supplied components
  571. AGSIFUNC(int) MakeRawColorPixel(int32 coldepth, int32 red, int32 green, int32 blue, int32 alpha);
  572. // get whether the font is TTF or SCI
  573. AGSIFUNC(int) GetFontType(int32 fontNum);
  574. // create a new dynamic sprite slot
  575. AGSIFUNC(int) CreateDynamicSprite(int32 coldepth, int32 width, int32 height);
  576. // free a created dynamic sprite
  577. AGSIFUNC(void) DeleteDynamicSprite(int32 slot);
  578. // check if a sprite has an alpha channel
  579. AGSIFUNC(int) IsSpriteAlphaBlended(int32 slot);
  580.  
  581. // *** BELOW ARE INTERFACE VERSION 13 AND ABOVE ONLY
  582. // un-request an event, requested earlier with RequestEventHook
  583. AGSIFUNC(void) UnrequestEventHook(int32 event);
  584. // draw a translucent bitmap to the active screen
  585. AGSIFUNC(void) BlitSpriteTranslucent(int32 x, int32 y, BITMAP *, int32 trans);
  586. // draw a sprite to the screen, but rotated around its centre
  587. AGSIFUNC(void) BlitSpriteRotated(int32 x, int32 y, BITMAP *, int32 angle);
  588.  
  589. // *** BELOW ARE INTERFACE VERSION 14 AND ABOVE ONLY
  590. #ifdef WINDOWS_VERSION
  591. // get reference to main DirectSound interface
  592. AGSIFUNC(LPDIRECTSOUND) GetDirectSound();
  593. #endif
  594. // disable AGS sound engine
  595. AGSIFUNC(void) DisableSound();
  596. // check whether a script function can be run now
  597. AGSIFUNC(int) CanRunScriptFunctionNow();
  598. // call a user-defined script function
  599. AGSIFUNC(int) CallGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, intptr_t arg1 = 0, intptr_t arg2 = 0, intptr_t arg3 = 0);
  600.  
  601. // *** BELOW ARE INTERFACE VERSION 15 AND ABOVE ONLY
  602. // force any sprites on-screen using the slot to be updated
  603. AGSIFUNC(void) NotifySpriteUpdated(int32 slot);
  604. // change whether the specified sprite is a 32-bit alpha blended image
  605. AGSIFUNC(void) SetSpriteAlphaBlended(int32 slot, int32 isAlphaBlended);
  606. // run the specified script function whenever script engine is available
  607. AGSIFUNC(void) QueueGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, intptr_t arg1 = 0, intptr_t arg2 = 0);
  608. // register a new dynamic managed script object
  609. AGSIFUNC(int) RegisterManagedObject(void *object, IAGSScriptManagedObject *callback);
  610. // add an object reader for the specified object type
  611. AGSIFUNC(void) AddManagedObjectReader(const char *typeName, IAGSManagedObjectReader *reader);
  612. // register an un-serialized managed script object
  613. AGSIFUNC(void) RegisterUnserializedObject(int key, void *object, IAGSScriptManagedObject *callback);
  614.  
  615. // *** BELOW ARE INTERFACE VERSION 16 AND ABOVE ONLY
  616. // get the address of a managed object based on its key
  617. AGSIFUNC(void*) GetManagedObjectAddressByKey(int key);
  618. // get managed object's key from its address
  619. AGSIFUNC(int) GetManagedObjectKeyByAddress(void *address);
  620.  
  621. // *** BELOW ARE INTERFACE VERSION 17 AND ABOVE ONLY
  622. // create a new script string
  623. AGSIFUNC(const char*) CreateScriptString(const char *fromText);
  624.  
  625. // *** BELOW ARE INTERFACE VERSION 18 AND ABOVE ONLY
  626. // increment reference count
  627. AGSIFUNC(int) IncrementManagedObjectRefCount(void *address);
  628. // decrement reference count
  629. AGSIFUNC(int) DecrementManagedObjectRefCount(void *address);
  630. // set mouse position
  631. AGSIFUNC(void) SetMousePosition(int32 x, int32 y);
  632. // simulate the mouse being clicked
  633. AGSIFUNC(void) SimulateMouseClick(int32 button);
  634. // get number of waypoints on this movement path
  635. AGSIFUNC(int) GetMovementPathWaypointCount(int32 pathId);
  636. // get the last waypoint that the char/obj passed
  637. AGSIFUNC(int) GetMovementPathLastWaypoint(int32 pathId);
  638. // get the co-ordinates of the specified waypoint
  639. AGSIFUNC(void) GetMovementPathWaypointLocation(int32 pathId, int32 waypoint, int32 *x, int32 *y);
  640. // get the speeds of the specified waypoint
  641. AGSIFUNC(void) GetMovementPathWaypointSpeed(int32 pathId, int32 waypoint, int32 *xSpeed, int32 *ySpeed);
  642.  
  643. // *** BELOW ARE INTERFACE VERSION 19 AND ABOVE ONLY
  644. // get the current graphics driver ID
  645. AGSIFUNC(const char*) GetGraphicsDriverID();
  646.  
  647. // *** BELOW ARE INTERFACE VERSION 22 AND ABOVE ONLY
  648. // get whether we are running under the editor's debugger
  649. AGSIFUNC(int) IsRunningUnderDebugger();
  650. // tells the engine to break into the debugger when the next line of script is run
  651. AGSIFUNC(void) BreakIntoDebugger();
  652. // fills buffer with <install dir>\fileName, as appropriate
  653. AGSIFUNC(void) GetPathToFileInCompiledFolder(const char* fileName, char* buffer);
  654.  
  655. // *** BELOW ARE INTERFACE VERSION 23 AND ABOVE ONLY
  656. #ifdef WINDOWS_VERSION
  657. // get reference to keyboard Direct Input device
  658. AGSIFUNC(LPDIRECTINPUTDEVICE) GetDirectInputKeyboard();
  659. // get reference to mouse Direct Input device
  660. AGSIFUNC(LPDIRECTINPUTDEVICE) GetDirectInputMouse();
  661. #endif
  662. // install a replacement renderer for the specified font number
  663. AGSIFUNC(IAGSFontRenderer*) ReplaceFontRenderer(int fontNumber, IAGSFontRenderer* newRenderer);
  664.  
  665. // *** BELOW ARE INTERFACE VERSION 25 AND ABOVE ONLY
  666. // fills the provided AGSRenderStageDesc struct with current render stage description;
  667. // please note that plugin MUST fill the struct's Version field before passing it into the function!
  668. AGSIFUNC(void) GetRenderStageDesc(AGSRenderStageDesc* desc);
  669.  
  670. // *** BELOW ARE INTERFACE VERSION 26 AND ABOVE ONLY
  671. // fills the provided AGSGameInfo struct
  672. // please note that plugin MUST fill the struct's Version field before passing it into the function!
  673. AGSIFUNC(void) GetGameInfo(AGSGameInfo* ginfo);
  674. // install a replacement renderer (extended interface) for the specified font number
  675. AGSIFUNC(IAGSFontRenderer*) ReplaceFontRenderer2(int fontNumber, IAGSFontRenderer2* newRenderer);
  676. // notify the engine that certain custom font has been updated
  677. AGSIFUNC(void) NotifyFontUpdated(int fontNumber);
  678.  
  679. // *** BELOW ARE INTERFACE VERSION 27 AND ABOVE ONLY
  680. // Resolve a script path to a system filepath, same way as script command File.Open does.
  681. // Caller should provide an output buffer and its length in bytes.
  682. // Passing NULL instead of a buffer pointer will make function calculate and return
  683. // length necessary to store a resulting path (in bytes).
  684. AGSIFUNC(size_t) ResolveFilePath(const char *script_path, char *buf, size_t buf_len);
  685.  
  686. // *** BELOW ARE INTERFACE VERSION 28 AND ABOVE ONLY
  687. // Opens a data stream, resolving a script path.
  688. // File mode should contain one of the AGSSTREAM_FILE_* values,
  689. // work mode should contain flag set of the AGSSTREAM_MODE_* values.
  690. // Returns IAGSStream object, or null on failure. The returned stream object
  691. // is owned by the caller, and must be deleted by calling its Dispose() method.
  692. AGSIFUNC(IAGSStream*) OpenFileStream(const char *script_path, int file_mode, int work_mode);
  693. // Returns IAGSStream object identified by the given stream handle.
  694. // This lets to retrieve IAGSStream object from a handle received in a event callback.
  695. // *IMPORTANT*: The returned stream's ownership is NOT passed to the caller;
  696. // this stream should not be closed or disposed, doing so will lead to errors in the engine.
  697. // Returns null if handle is invalid.
  698. AGSIFUNC(IAGSStream*) GetFileStreamByHandle(int32 fhandle);
  699.  
  700. // *** BELOW ARE INTERFACE VERSION 29 AND ABOVE ONLY
  701. // Print message to the engine's log, under one of the log levels AGSLOG_LEVEL_*.
  702. AGSIFUNC(void) Log(int level, const char *fmt, ...);
  703.  
  704. // *** BELOW ARE INTERFACE VERSION 30 AND ABOVE ONLY
  705. // Create a new dynamic array, allocating space for the given number of elements
  706. // of the given size. Optionally instructs to create an array for managed handles,
  707. // in which case the element size must be sizeof(int32).
  708. // IMPORTANT: you MUST correctly tell if this is going to be an array of handles, because
  709. // otherwise engine won't know to release their references, which may lead to memory leaks.
  710. // IMPORTANT: when writing handles into this array, you MUST inc ref count for each one
  711. // of them (see IncrementManagedObjectRefCount), otherwise these objects may get disposed
  712. // before the array itself, making these handles invalid!
  713. // Dynamic arrays have their meta data allocated prior to array of elements;
  714. // this function returns a pointer to the element array, which you may write to.
  715. // You may return this pointer from the registered plugin's function just like any other
  716. // managed object pointer.
  717. AGSIFUNC(void*) CreateDynamicArray(size_t elem_count, size_t elem_size, bool is_managed_type);
  718. // Retrieves dynamic array's length (number of elements).
  719. // You should pass a dynamic array object either received from the engine in your registered
  720. // script function, or created by you with CreateDynamicArray().
  721. AGSIFUNC(size_t) GetDynamicArrayLength(const void *arr);
  722. // Retrieves dynamic array's size (total capacity in bytes).
  723. AGSIFUNC(size_t) GetDynamicArraySize(const void *arr);
  724. };
  725.  
  726.  
  727. // The editor-to-plugin interface
  728. class IAGSEditor {
  729. public:
  730. int32 version;
  731. int32 pluginId; // used internally, do not touch this
  732.  
  733. public:
  734. // get the HWND of the main editor frame
  735. AGSIFUNC(HWND) GetEditorHandle ();
  736. // get the HWND of the current active window
  737. AGSIFUNC(HWND) GetWindowHandle ();
  738. // add some script to the default header
  739. AGSIFUNC(void) RegisterScriptHeader (const char *header);
  740. // de-register a script header (pass same pointer as when added)
  741. AGSIFUNC(void) UnregisterScriptHeader (const char *header);
  742. };
  743.  
  744.  
  745. #ifdef THIS_IS_THE_PLUGIN
  746.  
  747. #ifdef WINDOWS_VERSION
  748. #define DLLEXPORT extern "C" __declspec(dllexport)
  749. #else
  750. // MAC VERSION: compile with -fvisibility=hidden
  751. // gcc -dynamiclib -std=gnu99 agsplugin.c -fvisibility=hidden -o agsplugin.dylib
  752. #define DLLEXPORT extern "C" __attribute__((visibility("default")))
  753. #endif
  754.  
  755. DLLEXPORT const char * AGS_GetPluginName(void);
  756. DLLEXPORT int AGS_EditorStartup (IAGSEditor *);
  757. DLLEXPORT void AGS_EditorShutdown (void);
  758. DLLEXPORT void AGS_EditorProperties (HWND);
  759. DLLEXPORT int AGS_EditorSaveGame (char *, int);
  760. DLLEXPORT void AGS_EditorLoadGame (char *, int);
  761. DLLEXPORT void AGS_EngineStartup (IAGSEngine *);
  762. DLLEXPORT void AGS_EngineShutdown (void);
  763. DLLEXPORT intptr_t AGS_EngineOnEvent (int, intptr_t);
  764. DLLEXPORT int AGS_EngineDebugHook(const char *, int, int);
  765. DLLEXPORT void AGS_EngineInitGfx(const char* driverID, void *data);
  766. // Export this to let engine verify that this is a compatible AGS Plugin;
  767. // exact return value is not essential, but should be non-zero for consistency.
  768. DLLEXPORT int AGS_PluginV2 ();
  769.  
  770. #endif // THIS_IS_THE_PLUGIN
  771.  
  772. #endif // _AGS_PLUGIN_H
  773.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement