File: ags_waves.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (189 lines) | stat: -rw-r--r-- 6,875 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * of the License, or(at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H
#define AGS_PLUGINS_AGS_WAVES_AGS_WAVES_H

#include "audio/mixer.h"
#include "common/fs.h"
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/ags_waves/vars.h"

namespace AGS3 {
namespace Plugins {
namespace AGSWaves {

class AGSWaves : public PluginBase, public Vars {
	SCRIPT_HASH(AGSWaves)
private:
	Audio::Mixer *_mixer;
private:
	void DrawScreenEffect(ScriptMethodParams &params);
	void SFX_Play(ScriptMethodParams &params);
	void SFX_SetVolume(ScriptMethodParams &params);
	void SFX_GetVolume(ScriptMethodParams &params);
	void Music_Play(ScriptMethodParams &params);
	void Music_GetVolume(ScriptMethodParams &params);
	void Music_SetVolume(ScriptMethodParams &params);
	void SFX_Stop(ScriptMethodParams &params);
	void SFX_SetPosition(ScriptMethodParams &params);
	void SFX_SetGlobalVolume(ScriptMethodParams &params);
	void Load_SFX(ScriptMethodParams &params);
	void Audio_Apply_Filter(ScriptMethodParams &params);
	void Audio_Remove_Filter(ScriptMethodParams &params);
	void SFX_AllowOverlap(ScriptMethodParams &params);
	void SFX_Filter(ScriptMethodParams &params);
	void DrawBlur(ScriptMethodParams &params);
	void DrawTunnel(ScriptMethodParams &params);
	void DrawCylinder(ScriptMethodParams &params);
	void DrawForceField(ScriptMethodParams &params);
	void Grayscale(ScriptMethodParams &params);
	void ReadWalkBehindIntoSprite(ScriptMethodParams &params);
	void AdjustSpriteFont(ScriptMethodParams &params);
	void SpriteGradient(ScriptMethodParams &params);
	void Outline(ScriptMethodParams &params);
	void OutlineOnly(ScriptMethodParams &params);
	void SaveVariable(ScriptMethodParams &params);
	void ReadVariable(ScriptMethodParams &params);
	void GameDoOnceOnly(ScriptMethodParams &params);
	void SetGDState(ScriptMethodParams &params);
	void GetGDState(ScriptMethodParams &params);
	void ResetAllGD(ScriptMethodParams &params);
	void SpriteSkew(ScriptMethodParams &params);
	void FireUpdate(ScriptMethodParams &params);
	void WindUpdate(ScriptMethodParams &params);
	void SetWindValues(ScriptMethodParams &params);
	void ReturnWidth(ScriptMethodParams &params);
	void ReturnHeight(ScriptMethodParams &params);
	void ReturnNewHeight(ScriptMethodParams &params);
	void ReturnNewWidth(ScriptMethodParams &params);
	void Warper(ScriptMethodParams &params);
	void SetWarper(ScriptMethodParams &params);
	void RainUpdate(ScriptMethodParams &params);
	void BlendTwoSprites(ScriptMethodParams &params);
	void Blend(ScriptMethodParams &params);
	void Dissolve(ScriptMethodParams &params);
	void ReverseTransparency(ScriptMethodParams &params);
	void NoiseCreator(ScriptMethodParams &params);
	void TintProper(ScriptMethodParams &params);
	void GetWalkbehindBaserine(ScriptMethodParams &params);
	void SetWalkbehindBaserine(ScriptMethodParams &params);

private:
	void StartingValues();
	void Update();

	void CastWave(int delayMax, int PixelsWide, int n);
	void DrawEffect(int sprite_a, int sprite_b, int id, int n);
	int Random(int threshold);

	inline static int getRcolor(int color) {
		return ((color >> 16) & 0xFF);
	}
	inline static int getGcolor(int color) {
		return ((color >> 8) & 0xFF);
	}
	inline static int getBcolor(int color) {
		return ((color >> 0) & 0xFF);
	}
	inline static int getAcolor(int color) {
		return ((color >> 24) & 0xFF);
	}
	static int BlendColor(int Ln, int Bn, int perc) {
		return ((Ln < 128) ? (2 * Bn * Ln / perc) : (perc - 2 * (perc - Bn) * (perc - Ln) / perc));
	}
	static int BlendColorScreen(int Ln, int Bn, int perc) {
		return (Bn == perc) ? Bn :
			MIN(perc, (Ln * Ln / (perc - Bn)));
	}
	static int SetColorRGBA(int r, int g, int b, int a);
	static int ConvertColorToGrayScale(int color);
	static bool IsPixelTransparent(int color);
	float noiseField(float tx, float ty, float tz);

	int IntersectLines(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);

	static inline float fracts(float value) {
		return value - floor(value);
	}
	static inline float lerp(float x, float y, float fn) {
		return x * (1.0 - fn) + y * fn;
	}
	static inline float hasher(float n) {
		return fracts(sin(n) * 153.5453123);
	}
	static float min4(float m1, float m2, float m3, float m4) {
		return MIN(MIN(m1, m2), MIN(m3, m4));
	}
	static float max4(float m1, float m2, float m3, float m4) {
		return MAX(MAX(m1, m2), MAX(m3, m4));
	}

	// Weather
	void DrawLineCustom(int x1, int y1, int x2, int y2, int graphic, int setR, int setG, int setB, int setA, int TranDif);
	void CreateParticle(int xx, int yy, int ForceX, int ForceY);
	void CreateParticle2(int xx, int yy, int ForceX, int ForceY);
	void CreateParticleF(int xx, int yy, int ForceX, int ForceY);
	void CreateDustParticle(int xx, int yy);
	void CreateRainParticleMid(int x, int y, int fx, int fy, int maxpart);
	void CreateRainParticleFore(int x, int y, int fx, int fy, int maxpart);
	void CreateRainParticleBack(int x, int y, int fx, int fy, int maxpart);

	// Sound
	/**
	 * Plays a sound from the sounds.sfx in the Sounds/ folder
	 * @param soundToPlay	The sound to play
	 * @param repeat		Times to repeat, -1 for indefine
	 */
	void PlaySFX(int SoundToPlay, int repeat);

	/**
	 * Stops a playing sound effect
	 */
	void StopSFX(int sfxNum);

	/**
	 * Loads a ScummVM OGG stream for playback
	 */
	Audio::AudioStream *loadOGG(const Common::ArchiveMemberPtr member);

	void playStream(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, Audio::AudioStream *stream, int repeat);

	void stopAllSounds();
	void GlitchFix();
	void ApplyFilter(int SetFrequency);
	void SetFilterFrequency(int setFrequency);
	void MusicPlay(int MusicToPlay, int repeat, int fadeinMS, int fadeoutMS, int pos, bool forceplay, bool fixclick);

public:
	AGSWaves();
	virtual ~AGSWaves();

	const char *AGS_GetPluginName() override;
	void AGS_EngineStartup(IAGSEngine *engine) override;
	int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};

} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3

#endif