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
29namespace AGS3 {
30namespace Plugins {
31namespace AGSFlashlight {
32
37class AGSFlashlight : public PluginBase {
38 SCRIPT_HASH(AGSFlashlight)
39private:
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 int g_ScaleFactor = 1;
53 int32 g_FlashlightX = 0;
54 int32 g_FlashlightY = 0;
55 int32 g_FlashlightDrawAtX = 0;
56 int32 g_FlashlightDrawAtY = 0;
57 bool g_FlashlightFollowMouse = false;
58 int g_FollowCharacterId = 0;
59 int g_FollowCharacterDx = 0;
60 int g_FollowCharacterDy = 0;
61 int g_FollowCharacterHorz = 0;
62 int g_FollowCharacterVert = 0;
63 AGSCharacter *g_FollowCharacter = nullptr;
64 BITMAP *g_LightBitmap = nullptr;
65 uint32 flashlight_x = 0, flashlight_n = 0;
66
67private:
73 inline uint32 _blender_alpha16_bgr(uint32 y);
74 inline void calc_x_n(uint32 x);
75 inline void setPixel(int x, int y, uint32 color, uint32 *pixel);
76 void plotCircle(int xm, int ym, int r, uint32 color);
77 void ClipToRange(int &variable, int min, int max);
78 void AlphaBlendBitmap();
79 void DrawTint();
80 void DrawDarkness();
81 void CreateLightBitmap();
82 void Update();
83 uint32 blendPixel(uint32 col, bool isAlpha24, int light);
84 void syncGame(Serializer &s);
85
86 void SetFlashlightTint(ScriptMethodParams &params);
87 void GetFlashlightTintRed(ScriptMethodParams &params);
88 void GetFlashlightTintGreen(ScriptMethodParams &params);
89 void GetFlashlightTintBlue(ScriptMethodParams &params);
90 void GetFlashlightMinLightLevel(ScriptMethodParams &params);
91 void GetFlashlightMaxLightLevel(ScriptMethodParams &params);
92 void SetFlashlightDarkness(ScriptMethodParams &params);
93 void GetFlashlightDarkness(ScriptMethodParams &params);
94 void SetFlashlightDarknessSize(ScriptMethodParams &params);
95 void GetFlashlightDarknessSize(ScriptMethodParams &params);
96 void SetFlashlightBrightness(ScriptMethodParams &params);
97 void GetFlashlightBrightness(ScriptMethodParams &params);
98 void SetFlashlightBrightnessSize(ScriptMethodParams &params);
99 void GetFlashlightBrightnessSize(ScriptMethodParams &params);
100 void SetFlashlightPosition(ScriptMethodParams &params);
101 void GetFlashlightPositionX(ScriptMethodParams &params);
102 void GetFlashlightPositionY(ScriptMethodParams &params);
103 void SetFlashlightFollowMouse(ScriptMethodParams &params);
104 void GetFlashlightFollowMouse(ScriptMethodParams &params);
105 void SetFlashlightFollowCharacter(ScriptMethodParams &params);
106 void GetFlashlightFollowCharacter(ScriptMethodParams &params);
107 void GetFlashlightCharacterDX(ScriptMethodParams &params);
108 void GetFlashlightCharacterDY(ScriptMethodParams &params);
109 void GetFlashlightCharacterHorz(ScriptMethodParams &params);
110 void GetFlashlightCharacterVert(ScriptMethodParams &params);
111 void SetFlashlightMask(ScriptMethodParams &params);
112 void GetFlashlightMask(ScriptMethodParams &params);
113public:
115 virtual ~AGSFlashlight() {}
116
117 const char *AGS_GetPluginName() override;
118 void AGS_EngineStartup(IAGSEngine *engine) override;
119 int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
120 int AGS_PluginV2() const override { return 1; };
121};
122
123} // namespace AGSFlashlight
124} // namespace Plugins
125} // namespace AGS3
126
127#endif
Definition: surface.h:32
Definition: ags_plugin.h:296
Definition: types.h:112
Definition: ags_flashlight.h:37
Definition: plugin_base.h:171
Definition: plugin_base.h:131
Definition: serializer.h:32
Definition: ags_plugin.h:132
Definition: color.h:49