ScummVM API documentation
ags_flashlight.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * of the License, or(at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGS_PLUGINS_AGSFLASHLIGHT_AGSFLASHLIGHT_H
23 #define AGS_PLUGINS_AGSFLASHLIGHT_AGSFLASHLIGHT_H
24 
25 #include "ags/plugins/ags_plugin.h"
26 #include "ags/plugins/serializer.h"
27 #include "ags/lib/allegro.h"
28 
29 namespace AGS3 {
30 namespace Plugins {
31 namespace AGSFlashlight {
32 
37 class AGSFlashlight : public PluginBase {
38  SCRIPT_HASH(AGSFlashlight)
39 private:
40  int32 screen_width = 320;
41  int32 screen_height = 200;
42  int32 screen_color_depth = 16;
43  bool g_BitmapMustBeUpdated = true;
44  int g_RedTint = 0;
45  int g_GreenTint = 0;
46  int g_BlueTint = 0;
47  int g_DarknessLightLevel = 100;
48  int g_BrightnessLightLevel = 100;
49  int g_DarknessSize = 0;
50  int g_DarknessDiameter = 0;
51  int g_BrightnessSize = 0;
52  int32 g_FlashlightX = 0;
53  int32 g_FlashlightY = 0;
54  int32 g_FlashlightDrawAtX = 0;
55  int32 g_FlashlightDrawAtY = 0;
56  bool g_FlashlightFollowMouse = false;
57  int g_FollowCharacterId = 0;
58  int g_FollowCharacterDx = 0;
59  int g_FollowCharacterDy = 0;
60  int g_FollowCharacterHorz = 0;
61  int g_FollowCharacterVert = 0;
62  AGSCharacter *g_FollowCharacter = nullptr;
63  BITMAP *g_LightBitmap = nullptr;
64  uint32 flashlight_x = 0, flashlight_n = 0;
65 
66 private:
72  inline uint32 _blender_alpha16_bgr(uint32 y);
73  inline void calc_x_n(uint32 x);
74  inline void setPixel(int x, int y, uint32 color, uint32 *pixel);
75  void plotCircle(int xm, int ym, int r, uint32 color);
76  void ClipToRange(int &variable, int min, int max);
77  void AlphaBlendBitmap();
78  void DrawTint();
79  void DrawDarkness();
80  void CreateLightBitmap();
81  void Update();
82  uint32 blendPixel(uint32 col, bool isAlpha24, int light);
83  void syncGame(Serializer &s);
84 
85  void SetFlashlightTint(ScriptMethodParams &params);
86  void GetFlashlightTintRed(ScriptMethodParams &params);
87  void GetFlashlightTintGreen(ScriptMethodParams &params);
88  void GetFlashlightTintBlue(ScriptMethodParams &params);
89  void GetFlashlightMinLightLevel(ScriptMethodParams &params);
90  void GetFlashlightMaxLightLevel(ScriptMethodParams &params);
91  void SetFlashlightDarkness(ScriptMethodParams &params);
92  void GetFlashlightDarkness(ScriptMethodParams &params);
93  void SetFlashlightDarknessSize(ScriptMethodParams &params);
94  void GetFlashlightDarknessSize(ScriptMethodParams &params);
95  void SetFlashlightBrightness(ScriptMethodParams &params);
96  void GetFlashlightBrightness(ScriptMethodParams &params);
97  void SetFlashlightBrightnessSize(ScriptMethodParams &params);
98  void GetFlashlightBrightnessSize(ScriptMethodParams &params);
99  void SetFlashlightPosition(ScriptMethodParams &params);
100  void GetFlashlightPositionX(ScriptMethodParams &params);
101  void GetFlashlightPositionY(ScriptMethodParams &params);
102  void SetFlashlightFollowMouse(ScriptMethodParams &params);
103  void GetFlashlightFollowMouse(ScriptMethodParams &params);
104  void SetFlashlightFollowCharacter(ScriptMethodParams &params);
105  void GetFlashlightFollowCharacter(ScriptMethodParams &params);
106  void GetFlashlightCharacterDX(ScriptMethodParams &params);
107  void GetFlashlightCharacterDY(ScriptMethodParams &params);
108  void GetFlashlightCharacterHorz(ScriptMethodParams &params);
109  void GetFlashlightCharacterVert(ScriptMethodParams &params);
110  void SetFlashlightMask(ScriptMethodParams &params);
111  void GetFlashlightMask(ScriptMethodParams &params);
112 public:
113  AGSFlashlight() : PluginBase() {}
114  virtual ~AGSFlashlight() {}
115 
116  const char *AGS_GetPluginName() override;
117  void AGS_EngineStartup(IAGSEngine *engine) override;
118  int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
119 };
120 
121 } // namespace AGSFlashlight
122 } // namespace Plugins
123 } // namespace AGS3
124 
125 #endif
Definition: ags_plugin.h:131
Definition: serializer.h:32
Definition: types.h:111
Definition: surface.h:32
Definition: plugin_base.h:171
Definition: plugin_base.h:131
Definition: color.h:49
Definition: ags_plugin.h:328
Definition: ags.h:40
Definition: ags_flashlight.h:37