Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_agi/ags_agi.h"
namespace AGS3 {
namespace Plugins {
namespace AGSAgi {
const char *AGSAgi::AGS_GetPluginName() {
return "AGS AGI Plugin stub (ags_agi.dll)";
}
void AGSAgi::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(SetAGIScalingMode, AGSAgi::SetAGIScalingMode);
SCRIPT_METHOD(GetAGIScalingMode, AGSAgi::GetAGIScalingMode);
SCRIPT_METHOD(UseAGIScaling, AGSAgi::UseAGIScaling);
}
void AGSAgi::SetAGIScalingMode(ScriptMethodParams &params) {
PARAMS1(int, mode);
// TODO rest of the code
_scaling_mode = mode;
}
void AGSAgi::GetAGIScalingMode(ScriptMethodParams &params) {
params._result = _scaling_mode;
}
void AGSAgi::UseAGIScaling(ScriptMethodParams &params) {
PARAMS1(int, active);
// TODO rest of the code
_enabled = active;
}
} // namespace AGSAgi
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,54 @@
/* 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_AGI_AGS_AGI_H
#define AGS_PLUGINS_AGS_AGI_AGS_AGI_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSAgi {
class AGSAgi : public PluginBase {
SCRIPT_HASH(AGSAgi)
private:
int _enabled = 0;
int _scaling_mode = 0;
private:
void SetAGIScalingMode(ScriptMethodParams &params);
void GetAGIScalingMode(ScriptMethodParams &params);
void UseAGIScaling(ScriptMethodParams &params);
public:
AGSAgi() : PluginBase() {}
virtual ~AGSAgi() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSAgi
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,107 @@
/* 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/>.
*
*/
// See https://github.com/ericoporto/agsappopenurl for original plugin source code
#include "ags/plugins/ags_app_open_url/ags_app_open_url.h"
#include "common/system.h"
#define MAX_URL_SIZE 2048
#define FAIL_LOG_AND_EXIT(X) \
do { \
_engine->PrintDebugConsole(X); \
params._result = 0; \
return; \
} while (0)
namespace AGS3 {
namespace Plugins {
namespace AGSAppOpenURL {
const char *AGSAppOpenURL::AGS_GetPluginName() {
return "AGS AppOpenURL";
}
void AGSAppOpenURL::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(AppOpenURL, AGSAppOpenURL::AppOpenURL);
}
void AGSAppOpenURL::AppOpenURL(ScriptMethodParams &params) {
PARAMS2(int, iags_protocol, const char *, iags_url);
enum AgsUrlProtocol {
eAgsUrlProt_https = 0,
eAgsUrlProt_http
};
if (!g_system->hasFeature(OSystem::kFeatureOpenUrl)) {
FAIL_LOG_AND_EXIT("AppOpenURL: open URL not supported on current platform.");
}
if (iags_url == nullptr || iags_url[0] == 0) {
FAIL_LOG_AND_EXIT("AppOpenURL: empty URL received.");
}
const char *found = (const char *)memchr(iags_url, '\0', MAX_URL_SIZE);
if (!found) {
FAIL_LOG_AND_EXIT("AppOpenURL: URL is too big.");
}
Common::String url_str(iags_url);
for (char c : {' ' , '\n', '\r', '\t'}) {
size_t pos;
while ((pos = url_str.rfind(c)) != Common::String::npos) {
url_str.deleteChar(pos);
}
}
if (url_str.empty()) {
FAIL_LOG_AND_EXIT("AppOpenURL: URL is empty after clean up.");
}
if (url_str[0] == ':' || (url_str.rfind("://") != Common::String::npos)) {
FAIL_LOG_AND_EXIT("AppOpenURL: URL includes protocol specifiers.");
}
switch (iags_protocol) {
case eAgsUrlProt_http:
url_str = "http://" + url_str;
break;
case eAgsUrlProt_https:
default:
url_str = "https://" + url_str;
break;
}
if (!g_system->openUrl(url_str)) {
FAIL_LOG_AND_EXIT("AppOpenURL: Fail to open URL.");
}
_engine->PrintDebugConsole("AppOpenURL: success opening url");
params._result = 1;
}
} // namespace AGSAppOpenURL
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,54 @@
/* 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_APP_OPEN_URL_H
#define AGS_PLUGINS_AGS_APP_OPEN_URL_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSAppOpenURL {
class AGSAppOpenURL : public PluginBase {
SCRIPT_HASH(AGSAppOpenURL)
private:
/**
* Opens a browser window using the specified
* string as URL.
*/
void AppOpenURL(ScriptMethodParams &params);
public:
AGSAppOpenURL() : PluginBase() {}
virtual ~AGSAppOpenURL() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSAppOpenURL
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,743 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_blend/ags_blend.h"
#include "ags/shared/core/platform.h"
#include "common/algorithm.h"
namespace AGS3 {
namespace Plugins {
namespace AGSBlend {
#pragma region Defines_and_Includes
#define MIN_EDITOR_VERSION 1
#define MIN_ENGINE_VERSION 3
#define DEFAULT_RGB_R_SHIFT_32 16
#define DEFAULT_RGB_G_SHIFT_32 8
#define DEFAULT_RGB_B_SHIFT_32 0
#define DEFAULT_RGB_A_SHIFT_32 24
#if !AGS_PLATFORM_OS_WINDOWS
#define min(x,y) (((x) < (y)) ? (x) : (y))
#define max(x,y) (((x) > (y)) ? (x) : (y))
#endif
#define abs(a) ((a)<0 ? -(a) : (a))
#define ChannelBlend_Normal(B,L) ((uint8)(B))
#define ChannelBlend_Lighten(B,L) ((uint8)((L > B) ? L:B))
#define ChannelBlend_Darken(B,L) ((uint8)((L > B) ? B:L))
#define ChannelBlend_Multiply(B,L) ((uint8)((B * L) / 255))
#define ChannelBlend_Average(B,L) ((uint8)((B + L) / 2))
#define ChannelBlend_Add(B,L) ((uint8)(min(255, (B + L))))
#define ChannelBlend_Subtract(B,L) ((uint8)((B + L < 255) ? 0:(B + L - 255)))
#define ChannelBlend_Difference(B,L) ((uint8)(abs(B - L)))
#define ChannelBlend_Negation(B,L) ((uint8)(255 - abs(255 - B - L)))
#define ChannelBlend_Screen(B,L) ((uint8)(255 - (((255 - B) * (255 - L)) >> 8)))
#define ChannelBlend_Exclusion(B,L) ((uint8)(B + L - 2 * B * L / 255))
#define ChannelBlend_Overlay(B,L) ((uint8)((L < 128) ? (2 * B * L / 255):(255 - 2 * (255 - B) * (255 - L) / 255)))
#define ChannelBlend_SoftLight(B,L) ((uint8)((L < 128)?(2*((B>>1)+64))*((float)L/255):(255-(2*(255-((B>>1)+64))*(float)(255-L)/255))))
#define ChannelBlend_HardLight(B,L) (ChannelBlend_Overlay(L,B))
#define ChannelBlend_ColorDodge(B,L) ((uint8)((L == 255) ? L:min(255, ((B << 8 ) / (255 - L)))))
#define ChannelBlend_ColorBurn(B,L) ((uint8)((L == 0) ? L:max(0, (255 - ((255 - B) << 8 ) / L))))
#define ChannelBlend_LinearDodge(B,L)(ChannelBlend_Add(B,L))
#define ChannelBlend_LinearBurn(B,L) (ChannelBlend_Subtract(B,L))
#define ChannelBlend_LinearLight(B,L)((uint8)(L < 128)?ChannelBlend_LinearBurn(B,(2 * L)):ChannelBlend_LinearDodge(B,(2 * (L - 128))))
#define ChannelBlend_VividLight(B,L) ((uint8)(L < 128)?ChannelBlend_ColorBurn(B,(2 * L)):ChannelBlend_ColorDodge(B,(2 * (L - 128))))
#define ChannelBlend_PinLight(B,L) ((uint8)(L < 128)?ChannelBlend_Darken(B,(2 * L)):ChannelBlend_Lighten(B,(2 * (L - 128))))
#define ChannelBlend_HardMix(B,L) ((uint8)((ChannelBlend_VividLight(B,L) < 128) ? 0:255))
#define ChannelBlend_Reflect(B,L) ((uint8)((L == 255) ? L:min(255, (B * B / (255 - L)))))
#define ChannelBlend_Glow(B,L) (ChannelBlend_Reflect(L,B))
#define ChannelBlend_Phoenix(B,L) ((uint8)(min(B,L) - max(B,L) + 255))
#define ChannelBlend_Alpha(B,L,O) ((uint8)(O * B + (1 - O) * L))
#define ChannelBlend_AlphaF(B,L,F,O) (ChannelBlend_Alpha(F(B,L),B,O))
#define STRINGIFY(s) STRINGIFY_X(s)
#define STRINGIFY_X(s) #s
#pragma endregion
const char *AGSBlend::AGS_GetPluginName() {
return "AGSBlend";
}
void AGSBlend::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
// Make sure it's got the version with the features we need
if (_engine->version < MIN_ENGINE_VERSION)
_engine->AbortGame("Plugin needs engine version " STRINGIFY(MIN_ENGINE_VERSION) " or newer.");
// Register functions
SCRIPT_METHOD(GetAlpha, AGSBlend::GetAlpha);
SCRIPT_METHOD(PutAlpha, AGSBlend::PutAlpha);
SCRIPT_METHOD(DrawAlpha, AGSBlend::DrawAlpha);
SCRIPT_METHOD(Blur, AGSBlend::Blur);
SCRIPT_METHOD(HighPass, AGSBlend::HighPass);
SCRIPT_METHOD(DrawAdd, AGSBlend::DrawAdd);
SCRIPT_METHOD(DrawSprite, AGSBlend::DrawSprite);
}
//------------------------------------------------------------------------------
#pragma region Color_Functions
int getr32(int c) {
return ((c >> DEFAULT_RGB_R_SHIFT_32) & 0xFF);
}
int getg32(int c) {
return ((c >> DEFAULT_RGB_G_SHIFT_32) & 0xFF);
}
int getb32(int c) {
return ((c >> DEFAULT_RGB_B_SHIFT_32) & 0xFF);
}
int geta32(int c) {
return ((c >> DEFAULT_RGB_A_SHIFT_32) & 0xFF);
}
int makeacol32(int r, int g, int b, int a) {
return ((r << DEFAULT_RGB_R_SHIFT_32) |
(g << DEFAULT_RGB_G_SHIFT_32) |
(b << DEFAULT_RGB_B_SHIFT_32) |
(a << DEFAULT_RGB_A_SHIFT_32));
}
#pragma endregion
#pragma region Pixel32_Definition
struct Pixel32 {
public:
int Red = 0;
int Green = 0;
int Blue = 0;
int Alpha = 0;
int GetColorAsInt() const {
return makeacol32(Red, Green, Blue, Alpha);
}
};
#pragma endregion
void AGSBlend::GetAlpha(ScriptMethodParams &params) {
PARAMS3(int, sprite, int, x, int, y);
BITMAP *engineSprite = _engine->GetSpriteGraphic(sprite);
uint8 *charbuffer = _engine->GetRawBitmapSurface(engineSprite);
uint32 *longbuffer = (uint32 *)charbuffer;
int pitch = _engine->GetBitmapPitch(engineSprite) / 4;
int alpha = geta32(longbuffer[y * pitch + x]);
_engine->ReleaseBitmapSurface(engineSprite);
params._result = alpha;
}
void AGSBlend::PutAlpha(ScriptMethodParams &params) {
PARAMS4(int, sprite, int, x, int, y, int, alpha);
BITMAP *engineSprite = _engine->GetSpriteGraphic(sprite);
uint8 *charbuffer = _engine->GetRawBitmapSurface(engineSprite);
uint32 *longbuffer = (uint32 *)charbuffer;
int pitch = _engine->GetBitmapPitch(engineSprite) / 4;
int pixel = y * pitch + x;
int r = getr32(longbuffer[pixel]);
int g = getg32(longbuffer[pixel]);
int b = getb32(longbuffer[pixel]);
longbuffer[pixel] = makeacol32(r, g, b, alpha);
_engine->ReleaseBitmapSurface(engineSprite);
params._result = alpha;
}
int AGSBlend::xytolocale(int x, int y, int width) {
return (y * width + x);
}
void AGSBlend::HighPass(ScriptMethodParams &params) {
PARAMS2(int, sprite, int, threshold);
BITMAP *src = _engine->GetSpriteGraphic(sprite);
int32 srcWidth, srcHeight;
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, nullptr);
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint32 *srclongbuffer = (uint32 *)srccharbuffer;
int pitch = _engine->GetBitmapPitch(src) / 4;
for (int y = 0, yi = 0; y < srcHeight; y++, yi += pitch) {
for (int x = 0; x < srcWidth; x++) {
int srcr = getb32(srclongbuffer[yi + x]);
int srcg = getg32(srclongbuffer[yi + x]);
int srcb = getr32(srclongbuffer[yi + x]);
int tempmaxim = max(srcr, srcg);
int maxim = max(tempmaxim, srcb);
int tempmin = min(srcr, srcg);
int minim = min(srcb, tempmin);
int light = (maxim + minim) / 2 ;
if (light < threshold)
srclongbuffer[yi + x] = makeacol32(0, 0, 0, 0);
}
}
params._result = 0;
}
void AGSBlend::Blur(ScriptMethodParams &params) {
PARAMS2(int, sprite, int, radius);
BITMAP *src = _engine->GetSpriteGraphic(sprite);
int32 srcWidth, srcHeight;
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, nullptr);
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint32 *srclongbuffer = (uint32 *)srccharbuffer;
int pitch = _engine->GetBitmapPitch(src) / 4;
int negrad = -1 * radius;
//use a 1Dimensional array since the array is on the free store, not the stack
Pixel32 *Pixels = new Pixel32[(srcWidth + (radius * 2)) * (srcHeight + (radius * 2))]; // this defines a copy of the individual channels in class form.
Pixel32 *Dest = new Pixel32[(srcWidth + (radius * 2)) * (srcHeight + (radius * 2))]; // this is the destination sprite. both have a border all the way round equal to the radius for the blurring.
Pixel32 *Temp = new Pixel32[(srcWidth + (radius * 2)) * (srcHeight + (radius * 2))];
int arraywidth = srcWidth + (radius * 2); //define the array width since its used many times in the algorithm
for (int y = 0, yi = 0; y < srcHeight; y++, yi += pitch) { //copy the sprite to the Pixels class array
for (int x = 0; x < srcWidth; x++) {
int locale = xytolocale(x + radius, y + radius, arraywidth);
Pixels[locale].Red = getr32(srclongbuffer[yi + x]);
Pixels[locale].Green = getg32(srclongbuffer[yi + x]);
Pixels[locale].Blue = getb32(srclongbuffer[yi + x]);
Pixels[locale].Alpha = geta32(srclongbuffer[yi + x]);
}
}
int numofpixels = (radius * 2 + 1);
for (int y = 0; y < srcHeight; y++) {
int totalr = 0;
int totalg = 0;
int totalb = 0;
int totala = 0;
// Process entire window for first pixel
for (int kx = negrad; kx <= radius; kx++) {
int locale = xytolocale(kx + radius, y + radius, arraywidth);
totala += Pixels[locale].Alpha;
totalr += (Pixels[locale].Red * Pixels[locale].Alpha) / 255;
totalg += (Pixels[locale].Green * Pixels[locale].Alpha) / 255;
totalb += (Pixels[locale].Blue * Pixels[locale].Alpha) / 255;
}
int locale = xytolocale(radius, y + radius, arraywidth);
Temp[locale].Red = totalr / numofpixels; // take an average and assign it to the destination array
Temp[locale].Green = totalg / numofpixels;
Temp[locale].Blue = totalb / numofpixels;
Temp[locale].Alpha = totala / numofpixels;
// Subsequent pixels just update window total
for (int x = 1; x < srcWidth; x++) {
// Subtract pixel leaving window
locale = xytolocale(x - 1, y + radius, arraywidth);
totala -= Pixels[locale].Alpha;
totalr -= (Pixels[locale].Red * Pixels[locale].Alpha) / 255;
totalg -= (Pixels[locale].Green * Pixels[locale].Alpha) / 255;
totalb -= (Pixels[locale].Blue * Pixels[locale].Alpha) / 255;
// Add pixel entering window
locale = xytolocale(x + radius + radius, y + radius, arraywidth);
totala += Pixels[locale].Alpha;
totalr += (Pixels[locale].Red * Pixels[locale].Alpha) / 255;
totalg += (Pixels[locale].Green * Pixels[locale].Alpha) / 255;
totalb += (Pixels[locale].Blue * Pixels[locale].Alpha) / 255;
locale = xytolocale(x + radius, y + radius, arraywidth);
Temp[locale].Red = totalr / numofpixels; // take an average and assign it to the destination array
Temp[locale].Green = totalg / numofpixels;
Temp[locale].Blue = totalb / numofpixels;
Temp[locale].Alpha = totala / numofpixels;
}
}
for (int x = 0; x < srcWidth; x++) {
int totalr = 0;
int totalg = 0;
int totalb = 0;
int totala = 0;
// Process entire window for first pixel
for (int ky = negrad; ky <= radius; ky++) {
int locale = xytolocale(x + radius, ky + radius, arraywidth);
totala += Temp[locale].Alpha;
totalr += (Temp[locale].Red * Temp[locale].Alpha) / 255;
totalg += (Temp[locale].Green * Temp[locale].Alpha) / 255;
totalb += (Temp[locale].Blue * Temp[locale].Alpha) / 255;
}
int locale = xytolocale(x + radius, radius, arraywidth);
Dest[locale].Red = totalr / numofpixels; // take an average and assign it to the destination array
Dest[locale].Green = totalg / numofpixels;
Dest[locale].Blue = totalb / numofpixels;
Dest[locale].Alpha = totala / numofpixels;
// Subsequent pixels just update window total
for (int y = 1; y < srcHeight; y++) {
// Subtract pixel leaving window
locale = xytolocale(x + radius, y - 1, arraywidth);
totala -= Temp[locale].Alpha;
totalr -= (Temp[locale].Red * Temp[locale].Alpha) / 255;
totalg -= (Temp[locale].Green * Temp[locale].Alpha) / 255;
totalb -= (Temp[locale].Blue * Temp[locale].Alpha) / 255;
// Add pixel entering window
locale = xytolocale(x + radius, y + radius + radius, arraywidth);
totala += Temp[locale].Alpha;
totalr += (Temp[locale].Red * Temp[locale].Alpha) / 255;
totalg += (Temp[locale].Green * Temp[locale].Alpha) / 255;
totalb += (Temp[locale].Blue * Temp[locale].Alpha) / 255;
locale = xytolocale(x + radius, y + radius, arraywidth);
Dest[locale].Red = totalr / numofpixels; // take an average and assign it to the destination array
Dest[locale].Green = totalg / numofpixels;
Dest[locale].Blue = totalb / numofpixels;
Dest[locale].Alpha = totala / numofpixels;
}
}
for (int y = 0, yi = 0; y < srcHeight; y++, yi += pitch) {
for (int x = 0; x < srcWidth; x++) {
int locale = xytolocale(x + radius, y + radius, arraywidth);
srclongbuffer[yi + x] = Dest[locale].GetColorAsInt(); //write the destination array to the main buffer
}
}
delete[] Pixels;
delete[] Dest;
delete[] Temp;
_engine->ReleaseBitmapSurface(src);
params._result = 0;
}
void AGSBlend::DrawSprite(ScriptMethodParams &params) {
PARAMS6(int, destination, int, sprite, int, x, int, y, int, DrawMode, int, trans);
trans = 100 - trans;
int32 srcWidth, srcHeight, destWidth, destHeight;
BITMAP *src = _engine->GetSpriteGraphic(sprite);
BITMAP *dest = _engine->GetSpriteGraphic(destination);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, nullptr);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, nullptr);
if (x > destWidth || y > destHeight || x + srcWidth < 0 || y + srcHeight < 0) {
// offscreen
params._result = 1;
return;
}
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint32 *srclongbuffer = (uint32 *)srccharbuffer;
int srcPitch = _engine->GetBitmapPitch(src) / 4;
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 *destlongbuffer = (uint32 *)destcharbuffer;
int destPitch = _engine->GetBitmapPitch(dest) / 4;
if (srcWidth + x > destWidth) srcWidth = destWidth - x - 1;
if (srcHeight + y > destHeight) srcHeight = destHeight - y - 1;
int srcr, srcg, srcb, srca, destr, destg, destb, desta;
int finalr = 0, finalg = 0, finalb = 0, finala = 0;
unsigned int col;
int starty = 0;
int startx = 0;
if (x < 0) startx = -1 * x;
if (y < 0) starty = -1 * y;
int ycount = 0;
int xcount = 0;
int srcy = starty * srcPitch;
int desty = (starty + y) * destPitch;
for (ycount = starty; ycount < srcHeight; ycount ++, srcy += srcPitch, desty += destPitch) {
for (xcount = startx; xcount < srcWidth; xcount ++) {
int destx = xcount + x;
srca = (geta32(srclongbuffer[srcy + xcount]));
if (srca != 0) {
srca = srca * trans / 100;
srcr = getr32(srclongbuffer[srcy + xcount]);
srcg = getg32(srclongbuffer[srcy + xcount]);
srcb = getb32(srclongbuffer[srcy + xcount]);
destr = getr32(destlongbuffer[desty + destx]);
destg = getg32(destlongbuffer[desty + destx]);
destb = getb32(destlongbuffer[desty + destx]);
desta = geta32(destlongbuffer[desty + destx]);
switch (DrawMode) {
case 0:
finalr = srcr;
finalg = srcg;
finalb = srcb;
break;
case 1:
finalr = ChannelBlend_Lighten(srcr, destr);
finalg = ChannelBlend_Lighten(srcg, destg);
finalb = ChannelBlend_Lighten(srcb, destb);
break;
case 2:
finalr = ChannelBlend_Darken(srcr, destr);
finalg = ChannelBlend_Darken(srcg, destg);
finalb = ChannelBlend_Darken(srcb, destb);
break;
case 3:
finalr = ChannelBlend_Multiply(srcr, destr);
finalg = ChannelBlend_Multiply(srcg, destg);
finalb = ChannelBlend_Multiply(srcb, destb);
break;
case 4:
finalr = ChannelBlend_Add(srcr, destr);
finalg = ChannelBlend_Add(srcg, destg);
finalb = ChannelBlend_Add(srcb, destb);
break;
case 5:
finalr = ChannelBlend_Subtract(srcr, destr);
finalg = ChannelBlend_Subtract(srcg, destg);
finalb = ChannelBlend_Subtract(srcb, destb);
break;
case 6:
finalr = ChannelBlend_Difference(srcr, destr);
finalg = ChannelBlend_Difference(srcg, destg);
finalb = ChannelBlend_Difference(srcb, destb);
break;
case 7:
finalr = ChannelBlend_Negation(srcr, destr);
finalg = ChannelBlend_Negation(srcg, destg);
finalb = ChannelBlend_Negation(srcb, destb);
break;
case 8:
finalr = ChannelBlend_Screen(srcr, destr);
finalg = ChannelBlend_Screen(srcg, destg);
finalb = ChannelBlend_Screen(srcb, destb);
break;
case 9:
finalr = ChannelBlend_Exclusion(srcr, destr);
finalg = ChannelBlend_Exclusion(srcg, destg);
finalb = ChannelBlend_Exclusion(srcb, destb);
break;
case 10:
finalr = ChannelBlend_Overlay(srcr, destr);
finalg = ChannelBlend_Overlay(srcg, destg);
finalb = ChannelBlend_Overlay(srcb, destb);
break;
case 11:
finalr = ChannelBlend_SoftLight(srcr, destr);
finalg = ChannelBlend_SoftLight(srcg, destg);
finalb = ChannelBlend_SoftLight(srcb, destb);
break;
case 12:
finalr = ChannelBlend_HardLight(srcr, destr);
finalg = ChannelBlend_HardLight(srcg, destg);
finalb = ChannelBlend_HardLight(srcb, destb);
break;
case 13:
finalr = ChannelBlend_ColorDodge(srcr, destr);
finalg = ChannelBlend_ColorDodge(srcg, destg);
finalb = ChannelBlend_ColorDodge(srcb, destb);
break;
case 14:
finalr = ChannelBlend_ColorBurn(srcr, destr);
finalg = ChannelBlend_ColorBurn(srcg, destg);
finalb = ChannelBlend_ColorBurn(srcb, destb);
break;
case 15:
finalr = ChannelBlend_LinearDodge(srcr, destr);
finalg = ChannelBlend_LinearDodge(srcg, destg);
finalb = ChannelBlend_LinearDodge(srcb, destb);
break;
case 16:
finalr = ChannelBlend_LinearBurn(srcr, destr);
finalg = ChannelBlend_LinearBurn(srcg, destg);
finalb = ChannelBlend_LinearBurn(srcb, destb);
break;
case 17:
finalr = ChannelBlend_LinearLight(srcr, destr);
finalg = ChannelBlend_LinearLight(srcg, destg);
finalb = ChannelBlend_LinearLight(srcb, destb);
break;
case 18:
finalr = ChannelBlend_VividLight(srcr, destr);
finalg = ChannelBlend_VividLight(srcg, destg);
finalb = ChannelBlend_VividLight(srcb, destb);
break;
case 19:
finalr = ChannelBlend_PinLight(srcr, destr);
finalg = ChannelBlend_PinLight(srcg, destg);
finalb = ChannelBlend_PinLight(srcb, destb);
break;
case 20:
finalr = ChannelBlend_HardMix(srcr, destr);
finalg = ChannelBlend_HardMix(srcg, destg);
finalb = ChannelBlend_HardMix(srcb, destb);
break;
case 21:
finalr = ChannelBlend_Reflect(srcr, destr);
finalg = ChannelBlend_Reflect(srcg, destg);
finalb = ChannelBlend_Reflect(srcb, destb);
break;
case 22:
finalr = ChannelBlend_Glow(srcr, destr);
finalg = ChannelBlend_Glow(srcg, destg);
finalb = ChannelBlend_Glow(srcb, destb);
break;
case 23:
finalr = ChannelBlend_Phoenix(srcr, destr);
finalg = ChannelBlend_Phoenix(srcg, destg);
finalb = ChannelBlend_Phoenix(srcb, destb);
break;
default:
break;
}
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * finalr / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * finalg / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * finalb / finala + desta * destb * (255 - srca) / finala / 255;
col = makeacol32(finalr, finalg, finalb, finala);
destlongbuffer[desty + destx] = col;
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
_engine->NotifySpriteUpdated(destination);
params._result = 0;
}
void AGSBlend::DrawAdd(ScriptMethodParams &params) {
PARAMS5(int, destination, int, sprite, int, x, int, y, float, scale);
int32 srcWidth, srcHeight, destWidth, destHeight;
BITMAP *src = _engine->GetSpriteGraphic(sprite);
BITMAP *dest = _engine->GetSpriteGraphic(destination);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, nullptr);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, nullptr);
if (x > destWidth || y > destHeight) {
// offscreen
params._result = 1;
return;
}
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint32 *srclongbuffer = (uint32 *)srccharbuffer;
int srcPitch = _engine->GetBitmapPitch(src) / 4;
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 *destlongbuffer = (uint32 *)destcharbuffer;
int destPitch = _engine->GetBitmapPitch(dest) / 4;
if (srcWidth + x > destWidth) srcWidth = destWidth - x - 1;
if (srcHeight + y > destHeight) srcHeight = destHeight - y - 1;
int srcr, srcg, srcb, srca, destr, destg, destb, desta, finalr, finalg, finalb, finala;
unsigned int col;
int ycount = 0;
int xcount = 0;
int starty = 0;
int startx = 0;
if (x < 0) startx = -1 * x;
if (y < 0) starty = -1 * y;
int srcy = starty * srcPitch;
int desty = (starty + y) * destPitch;
for (ycount = starty; ycount < srcHeight; ycount ++, srcy += srcPitch, desty += destPitch) {
for (xcount = startx; xcount < srcWidth; xcount ++) {
int destx = xcount + x;
srca = (geta32(srclongbuffer[srcy + xcount]));
if (srca != 0) {
srcr = getr32(srclongbuffer[srcy + xcount]) * srca / 255 * scale;
srcg = getg32(srclongbuffer[srcy + xcount]) * srca / 255 * scale;
srcb = getb32(srclongbuffer[srcy + xcount]) * srca / 255 * scale;
desta = geta32(destlongbuffer[desty + destx]);
if (desta == 0) {
destr = 0;
destg = 0;
destb = 0;
} else {
destr = getr32(destlongbuffer[desty + destx]);
destg = getg32(destlongbuffer[desty + destx]);
destb = getb32(destlongbuffer[desty + destx]);
}
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = CLIP(srcr + destr, 0, 255);
finalg = CLIP(srcg + destg, 0, 255);
finalb = CLIP(srcb + destb, 0, 255);
col = makeacol32(finalr, finalg, finalb, finala);
destlongbuffer[desty + destx] = col;
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
_engine->NotifySpriteUpdated(destination);
params._result = 0;
}
void AGSBlend::DrawAlpha(ScriptMethodParams &params) {
PARAMS5(int, destination, int, sprite, int, x, int, y, int, trans);
trans = 100 - trans;
int32 srcWidth, srcHeight, destWidth, destHeight;
BITMAP *src = _engine->GetSpriteGraphic(sprite);
BITMAP *dest = _engine->GetSpriteGraphic(destination);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, nullptr);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, nullptr);
if (x > destWidth || y > destHeight) {
// offscreen
params._result = 1;
return;
}
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint32 *srclongbuffer = (uint32 *)srccharbuffer;
int srcPitch = _engine->GetBitmapPitch(src) / 4;
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 *destlongbuffer = (uint32 *)destcharbuffer;
int destPitch = _engine->GetBitmapPitch(dest) / 4;
if (srcWidth + x > destWidth) srcWidth = destWidth - x - 1;
if (srcHeight + y > destHeight) srcHeight = destHeight - y - 1;
int srcr, srcg, srcb, srca, destr, destg, destb, desta, finalr, finalg, finalb, finala;
int ycount = 0;
int xcount = 0;
int starty = 0;
int startx = 0;
if (x < 0) startx = -1 * x;
if (y < 0) starty = -1 * y;
int srcy = starty * srcPitch;
int desty = (starty + y) * destPitch;
for (ycount = starty; ycount < srcHeight; ycount ++, srcy += srcPitch, desty += destPitch) {
for (xcount = startx; xcount < srcWidth; xcount ++) {
int destx = xcount + x;
srca = (geta32(srclongbuffer[srcy + xcount])) * trans / 100;
if (srca != 0) {
srcr = getr32(srclongbuffer[srcy + xcount]);
srcg = getg32(srclongbuffer[srcy + xcount]);
srcb = getb32(srclongbuffer[srcy + xcount]);
destr = getr32(destlongbuffer[desty + destx]);
destg = getg32(destlongbuffer[desty + destx]);
destb = getb32(destlongbuffer[desty + destx]);
desta = geta32(destlongbuffer[desty + destx]);
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * srcr / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * srcg / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * srcb / finala + desta * destb * (255 - srca) / finala / 255;
destlongbuffer[desty + destx] = makeacol32(finalr, finalg, finalb, finala);
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
_engine->NotifySpriteUpdated(destination);
params._result = 0;
}
} // namespace AGSBlend
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,71 @@
/* 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_BLEND_AGS_BLEND_H
#define AGS_PLUGINS_AGS_BLEND_AGS_BLEND_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSBlend {
/**
* Author: Steven Poulton
* Description: An AGS Plugin to allow true Alpha Blending
*/
class AGSBlend : public PluginBase {
SCRIPT_HASH(AGSBlend)
private:
/**
* Gets the alpha value at coords x,y
*/
void GetAlpha(ScriptMethodParams &params);
/**
* Sets the alpha value at coords x,y
*/
void PutAlpha(ScriptMethodParams &params);
/**
* Translates index from a 2D array to a 1D array
*/
int xytolocale(int x, int y, int width);
void HighPass(ScriptMethodParams &params);
void Blur(ScriptMethodParams &params);
void DrawSprite(ScriptMethodParams &params);
void DrawAdd(ScriptMethodParams &params);
void DrawAlpha(ScriptMethodParams &params);
public:
AGSBlend() : PluginBase() {}
virtual ~AGSBlend() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
};
} // namespace AGSBlend
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,47 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_bm_font_renderer/ags_bm_font_renderer.h"
#include "common/debug.h"
namespace AGS3 {
namespace Plugins {
namespace AGSBMFontRenderer {
const char *AGSBMFontRenderer::AGS_GetPluginName() {
return "AGS BMFontRenderer Plugin stub (agsbmfontrenderer.dll)";
}
void AGSBMFontRenderer::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(SetBMFont, AGSBMFontRenderer::SetBMFont);
}
void AGSBMFontRenderer::SetBMFont(ScriptMethodParams &params) {
// PARAMS2(const char *, file, int, fontNumber);
debug("AGSBMFontRenderer: SetBMFont is not implemented!");
}
} // namespace AGSBMFontRenderer
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,49 @@
/* 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_BM_FONT_RENDERER
#define AGS_PLUGINS_AGS_BM_FONT_RENDERER
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSBMFontRenderer {
class AGSBMFontRenderer : public PluginBase {
SCRIPT_HASH(AGSBMFontRenderer)
private:
void SetBMFont(ScriptMethodParams &params);
public:
AGSBMFontRenderer() : PluginBase() {}
virtual ~AGSBMFontRenderer() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSBMFontRenderer
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,54 @@
/* 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/>.
*
*/
#include "common/system.h"
#include "ags/plugins/ags_clipboard/ags_clipboard.h"
namespace AGS3 {
namespace Plugins {
namespace AGSClipboard {
const char *AGSClipboard::AGS_GetPluginName() {
return "AGS Clipboard Plugin v0.4";
}
void AGSClipboard::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(Clipboard::PasteText, AGSClipboard::Clipboard_PasteText);
SCRIPT_METHOD(Clipboard::CopyText^1, AGSClipboard::Clipboard_CopyText);
}
void AGSClipboard::Clipboard_PasteText(ScriptMethodParams &params) {
Common::U32String text = g_system->getTextFromClipboard();
_text = text;
params._result = _text.c_str();
}
void AGSClipboard::Clipboard_CopyText(ScriptMethodParams &params) {
PARAMS1(const char *, text);
g_system->setTextInClipboard(Common::U32String(text));
}
} // namespace AGSClipboard
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,51 @@
/* 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_CLIPBOARD_H
#define AGS_PLUGINS_AGS_CLIPBOARD_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSClipboard {
class AGSClipboard : public PluginBase {
SCRIPT_HASH(AGSClipboard)
private:
Common::String _text;
private:
void Clipboard_PasteText(ScriptMethodParams &params);
void Clipboard_CopyText(ScriptMethodParams &params);
public:
AGSClipboard() : PluginBase() {}
virtual ~AGSClipboard() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSClipboard
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,209 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_collision_detector/ags_collision_detector.h"
#include "ags/shared/util/geometry.h"
#include "common/config-manager.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCollisionDetector {
#define CD_NORMAL 0
#define CD_DEBUG 1
#define CD_OBJECT 0
#define CD_CHARACTER 1
#define CD_SYS_ERROR -2
#define CD_PARAM_ERROR -1
#define CD_NO_COLLISION 0
#define CD_COLLISION 1
#define CD_OK 0
#define CD_IGNORED 1
bool find_overlapping_area(Rect r1, Rect r2, Rect *overlap);
const char *AGSCollisionDetector::AGS_GetPluginName() {
return "AGS Collision Detector";
}
void AGSCollisionDetector::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(boundingBoxColDetect, AGSCollisionDetector::boundingBoxColDetect);
SCRIPT_METHOD(dumpInfo, AGSCollisionDetector::dumpInfo);
SCRIPT_METHOD(resetTransparencyThreshold, AGSCollisionDetector::resetTransparencyThreshold);
SCRIPT_METHOD(resetTransparentColor, AGSCollisionDetector::resetTransparentColor);
SCRIPT_METHOD(setDebugMode, AGSCollisionDetector::setDebugMode);
SCRIPT_METHOD(setTransparencyThreshold, AGSCollisionDetector::setTransparencyThreshold);
SCRIPT_METHOD(setTransparentColor, AGSCollisionDetector::setTransparentColor);
SCRIPT_METHOD(spritePixelColDetect, AGSCollisionDetector::spritePixelColDetect);
SCRIPT_METHOD(spriteSpriteColDetect, AGSCollisionDetector::spriteSpriteColDetect);
}
void AGSCollisionDetector::boundingBoxColDetect(ScriptMethodParams &params) {
// PARAMS8(int, id1, int, type1, int, slot1, int, scale1, int, id2, int, type2, int, slot2, int, scale2);
// TODO
warning("STUB: AGSCollisionDetector::boundingBoxColDetect is not implemented");
params._result = CD_NO_COLLISION;
}
void AGSCollisionDetector::dumpInfo(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSCollisionDetector::dumpInfo is not implemented");
params._result = CD_IGNORED;
}
void AGSCollisionDetector::resetTransparencyThreshold(ScriptMethodParams &params) {
transparencyTreshold = 100;
params._result = CD_OK;
}
void AGSCollisionDetector::resetTransparentColor(ScriptMethodParams &params) {
transparentColor.r = 255;
transparentColor.g = 0;
transparentColor.b = 255;
params._result = CD_OK;
}
void AGSCollisionDetector::setDebugMode(ScriptMethodParams &params) {
// PARAMS1(int, status);
// TODO
warning("STUB: AGSCollisionDetector::setDebugMode is not implemented");
params._result = CD_OK;
}
void AGSCollisionDetector::setTransparencyThreshold(ScriptMethodParams &params) {
PARAMS1(int, trans_thresh);
if ((trans_thresh >= 0) && (trans_thresh <= 100)) {
transparencyTreshold = trans_thresh;
params._result = CD_OK;
} else
params._result = CD_PARAM_ERROR;
}
void AGSCollisionDetector::setTransparentColor(ScriptMethodParams &params) {
PARAMS3(int, transparentRed, int, transparentGreen, int, transparentBlue);
if ((transparentRed < 0) || (transparentRed > 255) ||
(transparentGreen < 0) || (transparentGreen > 255) ||
(transparentBlue < 0) || (transparentBlue > 255)) {
params._result = CD_PARAM_ERROR;
return;
} else {
transparentColor.r = transparentRed;
transparentColor.g = transparentGreen;
transparentColor.b = transparentBlue;
params._result = CD_OK;
}
}
void AGSCollisionDetector::spritePixelColDetect(ScriptMethodParams &params) {
// PARAMS5(int, id, int, type, int, slot, int, pixelX, int, pixelY);
// TODO
warning("STUB: AGSCollisionDetector::spritePixelColDetect is not implemented");
params._result = CD_NO_COLLISION;
}
void AGSCollisionDetector::spriteSpriteColDetect(ScriptMethodParams &params) {
PARAMS6(int, id1, int, type1, int, slot1, int, id2, int, type2, int, slot2);
int32 spr1_w, spr1_h; // sprite sizes
int32 spr2_w, spr2_h;
Rect r1, r2;
Rect overlap(0, 0, 0, 0);
BITMAP *sprite1 = _engine->GetSpriteGraphic(slot1);
BITMAP *sprite2 = _engine->GetSpriteGraphic(slot2);
_engine->GetBitmapDimensions(sprite1, &spr1_w, &spr1_h, nullptr);
_engine->GetBitmapDimensions(sprite2, &spr2_w, &spr2_h, nullptr);
if (type1 == CD_OBJECT) { // object
if (id1 < _engine->GetNumObjects()) {
AGSObject *obj1 = _engine->GetObject(id1);
r1.Left = obj1->x;
r1.Top = obj1->y - spr1_h;
r1.Right = obj1->x + spr1_w;
r1.Bottom = obj1->y;
}
} else { // character
if (id1 < _engine->GetNumCharacters()) {
AGSCharacter *ch1 = _engine->GetCharacter(id1);
r1.Left = ch1->x - (spr1_w / 2);
r1.Top = ch1->y - spr1_h;
r1.Right = ch1->x + (spr1_w / 2);
r1.Bottom = ch1->y;
}
}
if (type2 == CD_OBJECT) { // object
if (id2 < _engine->GetNumObjects()) {
AGSObject *obj2 = _engine->GetObject(id2);
r2.Left = obj2->x;
r2.Top = obj2->y - spr2_h;
r2.Right = obj2->x + spr2_w;
r2.Bottom = obj2->y;
}
} else { // character
if (id2 < _engine->GetNumCharacters()) {
AGSCharacter *ch2 = _engine->GetCharacter(id2);
r2.Left = ch2->x - (spr2_w / 2);
r2.Top = ch2->y - spr2_h;
r2.Right = ch2->x + (spr2_w / 2);
r2.Bottom = ch2->y;
}
}
// WORKAROUND for bee sprite in Bear Story
if ((ConfMan.get("gameid") == "bear") && (slot1 == 87)) {
r1.Bottom -= 9;
}
if (find_overlapping_area(r1, r2, &overlap)) {
params._result = CD_COLLISION;
return;
}
params._result = CD_NO_COLLISION;
}
bool find_overlapping_area(Rect r1, Rect r2, Rect *overlap) {
overlap->Left = MAX(r1.Left, r2.Left);
overlap->Top = MAX(r1.Top, r2.Top);
overlap->Right = MIN(r1.Right, r2.Right);
overlap->Bottom = MIN(r1.Bottom, r2.Bottom);
if (overlap->Left >= overlap->Right || overlap->Top >= overlap->Bottom) // degenerate rect means no overlap
return false;
return true;
}
} // namespace AGSCollisionDetector
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,61 @@
/* 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_COLLISION_DETECTOR_H
#define AGS_PLUGINS_AGS_COLLISION_DETECTOR_H
#include "ags/plugins/ags_plugin.h"
#include "ags/lib/allegro.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCollisionDetector {
class AGSCollisionDetector : public PluginBase {
SCRIPT_HASH(AGSCollisionDetector)
private:
int32 transparencyTreshold = 100;
RGB transparentColor;
void boundingBoxColDetect(ScriptMethodParams &params);
void dumpInfo(ScriptMethodParams &params);
void resetTransparencyThreshold(ScriptMethodParams &params);
void resetTransparentColor(ScriptMethodParams &params);
void setDebugMode(ScriptMethodParams &params);
void setTransparencyThreshold(ScriptMethodParams &params);
void setTransparentColor(ScriptMethodParams &params);
void spritePixelColDetect(ScriptMethodParams &params);
void spriteSpriteColDetect(ScriptMethodParams &params);
public:
AGSCollisionDetector() : PluginBase() {}
virtual ~AGSCollisionDetector() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSCollisionDetector
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,120 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_consoles/ags_consoles.h"
namespace AGS3 {
namespace Plugins {
namespace AGSConsoles {
const char *AGSConsoles::AGS_GetPluginName() {
return "AGS Consoles";
}
void AGSConsoles::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(IsPS4, AGSConsoles::IsPS4);
SCRIPT_METHOD(IsPS5, AGSConsoles::IsPS5);
SCRIPT_METHOD(IsSwitch, AGSConsoles::IsSwitch);
SCRIPT_METHOD(IsPSVita, AGSConsoles::IsPSVita);
SCRIPT_METHOD(IsXboxOne, AGSConsoles::IsXboxOne);
SCRIPT_METHOD(IsSeriesX, AGSConsoles::IsSeriesX);
SCRIPT_METHOD(SendStat, AGSConsoles::SendStat);
SCRIPT_METHOD(SetAchievement, AGSConsoles::SetAchievement);
SCRIPT_METHOD(RequestAccountPicker, AGSConsoles::RequestAccountPicker);
SCRIPT_METHOD(LogMessage, AGSConsoles::LogMessage);
SCRIPT_METHOD(GetGamertag, AGSConsoles::GetGamertag);
SCRIPT_METHOD(StartStory, AGSConsoles::StartStory);
SCRIPT_METHOD(ShowKeyboard, AGSConsoles::ShowKeyboard);
SCRIPT_METHOD(ShouldOpenActivity, AGSConsoles::ShouldOpenActivity);
}
void AGSConsoles::IsPS4(ScriptMethodParams &params) {
warning("AGSConsoles::IsPS4 STUB: returning false");
params._result = false;
}
void AGSConsoles::IsPS5(ScriptMethodParams &params) {
warning("AGSConsoles::IsPS5 STUB: returning false");
params._result = false;
}
void AGSConsoles::IsSwitch(ScriptMethodParams &params) {
warning("AGSConsoles::IsSwitch STUB: returning false");
params._result = false;
}
void AGSConsoles::IsPSVita(ScriptMethodParams &params) {
warning("AGSConsoles::IsPSVita STUB: returning false");
params._result = false;
}
void AGSConsoles::IsXboxOne(ScriptMethodParams &params) {
warning("AGSConsoles::IsXboxOne STUB: returning false");
params._result = false;
}
void AGSConsoles::IsSeriesX(ScriptMethodParams &params) {
warning("AGSConsoles::IsSeriesX STUB: returning false");
params._result = false;
}
void AGSConsoles::SendStat(ScriptMethodParams &params) {
warning("AGSConsoles::SendStat STUB");
}
void AGSConsoles::SetAchievement(ScriptMethodParams &params) {
warning("AGSConsoles::SetAchievement STUB");
}
void AGSConsoles::RequestAccountPicker(ScriptMethodParams &params) {
warning("AGSConsoles::RequestAccountPicker STUB");
}
void AGSConsoles::LogMessage(ScriptMethodParams &params) {
PARAMS1(char *, msg);
char buf[1024];
snprintf(buf, sizeof(buf), "AGSConsoles: %s", msg);
_engine->PrintDebugConsole(buf);
}
void AGSConsoles::GetGamertag(ScriptMethodParams &params) {
warning("AGSConsoles::GetGamertag STUB: using \"ScummVM\"");
params._result = _engine->CreateScriptString("ScummVM");
}
void AGSConsoles::StartStory(ScriptMethodParams &params) {
warning("AGSConsoles::StartStory STUB");
}
void AGSConsoles::ShowKeyboard(ScriptMethodParams &params) {
warning("AGSConsoles::ShowKeyboard STUB");
}
void AGSConsoles::ShouldOpenActivity(ScriptMethodParams &params) {
warning("AGSConsoles::ShouldOpenActivity STUB");
}
} // namespace AGSConsoles
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,63 @@
/* 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_CONSOLES_H
#define AGS_PLUGINS_AGS_CONSOLES_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSConsoles {
class AGSConsoles : public PluginBase {
SCRIPT_HASH(AGSConsoles)
private:
void IsPS4(ScriptMethodParams &params);
void IsPS5(ScriptMethodParams &params);
void IsSwitch(ScriptMethodParams &params);
void IsPSVita(ScriptMethodParams &params);
void IsXboxOne(ScriptMethodParams &params);
void IsSeriesX(ScriptMethodParams &params);
void SendStat(ScriptMethodParams &params);
void SetAchievement(ScriptMethodParams &params);
void RequestAccountPicker(ScriptMethodParams &params);
void LogMessage(ScriptMethodParams &params);
void GetGamertag(ScriptMethodParams &params);
void StartStory(ScriptMethodParams &params);
void ShowKeyboard(ScriptMethodParams &params);
void ShouldOpenActivity(ScriptMethodParams &params);
public:
AGSConsoles() : PluginBase() {}
virtual ~AGSConsoles() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSConsoles
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,231 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_controller/ags_controller.h"
#include "ags/events.h"
#include "common/config-manager.h"
#include "common/system.h"
namespace AGS3 {
namespace Plugins {
namespace AGSController {
struct Controller : public IAGSScriptManagedObject {
public:
int Dispose(void *address, bool force) override {
return true;
}
const char *GetType() override {
return "Controller";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
Controller *ctrlInterface = nullptr;
ConReader *ctrlReader = nullptr;
Controller *getController() {
if (!ctrlInterface)
ctrlInterface = new Controller;
return ctrlInterface;
}
ConReader *getConReader() {
if (!ctrlReader)
ctrlReader = new ConReader;
return ctrlReader;
}
AGSController::~AGSController() {
delete ctrlInterface;
delete ctrlReader;
}
const char *AGSController::AGS_GetPluginName() {
return "AGSController";
}
void AGSController::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(ControllerCount, AGSController::ControllerCount);
SCRIPT_METHOD(Controller::Open, AGSController::Controller_Open);
SCRIPT_METHOD(Controller::Close, AGSController::Controller_Close);
SCRIPT_METHOD(Controller::Plugged, AGSController::Controller_Plugged);
SCRIPT_METHOD(Controller::GetAxis, AGSController::Controller_GetAxis);
SCRIPT_METHOD(Controller::GetPOV, AGSController::Controller_GetPOV);
SCRIPT_METHOD(Controller::IsButtonDown, AGSController::Controller_IsButtonDown);
SCRIPT_METHOD(Controller::GetName^0, AGSController::Controller_GetName);
SCRIPT_METHOD(Controller::Rumble, AGSController::Controller_Rumble);
SCRIPT_METHOD(Controller::IsButtonDownOnce, AGSController::Controller_IsButtonDownOnce);
SCRIPT_METHOD(Controller::PressAnyKey, AGSController::Controller_PressAnyKey);
SCRIPT_METHOD(Controller::BatteryStatus, AGSController::Controller_BatteryStatus);
SCRIPT_METHOD(ClickMouse, AGSController::ClickMouse);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->AddManagedObjectReader("Controller", getConReader());
}
int64 AGSController::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event == AGSE_PREGUIDRAW) {
Controller_Update();
}
return 0;
}
void AGSController::Controller_Update() {
// ::AGS::g_events->pollEvents();
}
void ConReader::Unserialize(int key, const char *serializedData, int dataSize) {
// no implementation
}
void AGSController::ControllerCount(ScriptMethodParams &params) {
// WORKAROUND: The current implementation doesn't work at all, in UIHY at least
// Just disable the gamepad for now, also to prevent accessing the controller options
// that crash everything
if ((ConfMan.get("gameid") == "untilihaveyou")) {
debug(0, "AGSController: Returning ControllerCount=0 to force-disable controller!");
params._result = 0;
return;
}
int joystickNum = ConfMan.getInt("joystick_num");
params._result = (joystickNum == -1) ? 0 : 1;
}
void AGSController::Controller_Open(ScriptMethodParams &params) {
Controller *newCtrl = new Controller();
_engine->RegisterManagedObject(newCtrl, getController());
params._result = newCtrl;
}
void AGSController::Controller_Close(ScriptMethodParams &params) {
// No implementation needed
}
void AGSController::Controller_Plugged(ScriptMethodParams &params) {
int joystickNum = ConfMan.getInt("joystick_num");
params._result = joystickNum != -1;
}
void AGSController::Controller_GetAxis(ScriptMethodParams &params) {
PARAMS1(int, axis);
if (axis < 0 || axis > 31)
params._result = false;
else
params._result = ::AGS::g_events->getJoystickAxis(axis);
}
void AGSController::Controller_GetPOV(ScriptMethodParams &params) {
// Not supported
debug(0, "AGSController: POV is not implemented");
params._result = 0;
}
void AGSController::Controller_IsButtonDown(ScriptMethodParams &params) {
PARAMS1(int, button);
if (button < 0 || button > 31)
params._result = false;
else
params._result = ::AGS::g_events->getJoystickButton(button);
}
void AGSController::Controller_GetName(ScriptMethodParams &params) {
int joystickNum = ConfMan.getInt("joystick_num");
params._result = (joystickNum != -1) ? _engine->CreateScriptString("Joystick")
: _engine->CreateScriptString("");
}
void AGSController::Controller_Rumble(ScriptMethodParams &params) {
// Not supported
debug(0, "AGSController: Rumble is not supported");
}
void AGSController::Controller_IsButtonDownOnce(ScriptMethodParams &params) {
PARAMS1(int, button);
if (button < 0 || button > 31)
params._result = false;
else
params._result = ::AGS::g_events->getJoystickButtonOnce(button);
}
void AGSController::Controller_PressAnyKey(ScriptMethodParams &params) {
params._result = -1;
for (int index = 0; index < 32; ++index) {
if (::AGS::g_events->getJoystickButton(index)) {
params._result = index;
break;
}
}
}
void AGSController::Controller_BatteryStatus(ScriptMethodParams &params) {
// Not supported, so return -1 for "UNKNOWN"
debug(0, "AGSController: Battery status is not supported");
params._result = -1;
}
void AGSController::ClickMouse(ScriptMethodParams &params) {
PARAMS1(int, button);
// WORKAROUND: This method is used to fake mouseclicks in the game menus (for keyboard
// and gamepad control) but the implementation using eventmanager doesn't seem to work
// Just use PluginSimulateMouseClick, which matches AGSController original implementation
if ((ConfMan.get("gameid") == "untilihaveyou")) {
PluginSimulateMouseClick(button);
return;
}
assert(button < 3);
Common::EventType DOWN[3] = {
Common::EVENT_LBUTTONDOWN, Common::EVENT_RBUTTONDOWN, Common::EVENT_MBUTTONDOWN
};
Common::EventType UP[3] = {
Common::EVENT_LBUTTONUP, Common::EVENT_RBUTTONUP, Common::EVENT_MBUTTONUP
};
Common::Point mousePos = ::AGS::g_events->getMousePos();
Common::Event down, up;
down.type = DOWN[button];
down.mouse.x = mousePos.x;
down.mouse.y = mousePos.y;
g_system->getEventManager()->pushEvent(down);
up.type = UP[button];
up.mouse.x = mousePos.x;
up.mouse.y = mousePos.y;
g_system->getEventManager()->pushEvent(up);
}
} // namespace AGSController
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,67 @@
/* 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_AGSCONTROLLER_AGSCONTROLLER_H
#define AGS_PLUGINS_AGSCONTROLLER_AGSCONTROLLER_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSController {
class ConReader : public IAGSManagedObjectReader {
public:
virtual void Unserialize(int key, const char *serializedData, int dataSize);
};
class AGSController : public PluginBase {
SCRIPT_HASH(AGSController)
protected:
void Controller_Update();
void ControllerCount(ScriptMethodParams &params);
void Controller_Open(ScriptMethodParams &params);
void Controller_Plugged(ScriptMethodParams &params);
void Controller_GetAxis(ScriptMethodParams &params);
void Controller_GetPOV(ScriptMethodParams &params);
void Controller_IsButtonDown(ScriptMethodParams &params);
void Controller_Close(ScriptMethodParams &params);
void Controller_GetName(ScriptMethodParams &params);
void Controller_Rumble(ScriptMethodParams &params);
void Controller_IsButtonDownOnce(ScriptMethodParams &params);
void Controller_PressAnyKey(ScriptMethodParams &params);
void Controller_BatteryStatus(ScriptMethodParams &params);
void ClickMouse(ScriptMethodParams &params);
public:
AGSController() : PluginBase() {}
virtual ~AGSController();
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};
} // namespace AGSController
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,75 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_controller/ags_controller.h"
#include "ags/plugins/ags_controller/ags_controller_arcnor.h"
#include "ags/events.h"
namespace AGS3 {
namespace Plugins {
namespace AGSController {
void AGSControllerArcnor::AGS_EngineStartup(IAGSEngine *engine) {
AGSController::AGS_EngineStartup(engine);
SCRIPT_METHOD(AGSControllerArcnor::Controller_Open^1, AGSControllerArcnor::Controller_Open);
SCRIPT_METHOD(AGSControllerArcnor::Controller_GetAxis^1, AGSControllerArcnor::Controller_GetAxis);
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonDown^1, AGSControllerArcnor::Controller_IsButtonDown);
SCRIPT_METHOD(AGSControllerArcnor::Controller_Rumble^3, AGSControllerArcnor::Controller_Rumble);
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonDownOnce^1, AGSControllerArcnor::Controller_IsButtonDownOnce);
SCRIPT_METHOD(AGSControllerArcnor::Controller_IsButtonUpOnce^1, AGSControllerArcnor::Controller_IsButtonUpOnce);
SCRIPT_METHOD(AGSControllerArcnor::Controller_PressAnyButton, AGSControllerArcnor::Controller_PressAnyKey);
SCRIPT_METHOD(AGSControllerArcnor::Controller_GetPlayerIndex^0, AGSControllerArcnor::Controller_GetPlayerIndex);
SCRIPT_METHOD(AGSControllerArcnor::Controller_SetPlayerIndex^1, AGSControllerArcnor::Controller_SetPlayerIndex);
SCRIPT_METHOD(RunVirtualKeyboard, AGSControllerArcnor::RunVirtualKeyboard);
}
void AGSControllerArcnor::Controller_IsButtonUpOnce(ScriptMethodParams &params) {
PARAMS1(int, button);
if (button < 0 || button > 31)
params._result = false;
else
params._result = !(::AGS::g_events->getJoystickButtonOnce(button));
}
void AGSControllerArcnor::Controller_GetPlayerIndex(ScriptMethodParams &params) {
// return -1 as "not available"
debug(0, "AGSController: GetPlayerIndex not implemented");
params._result = -1;
}
void AGSControllerArcnor::Controller_SetPlayerIndex(ScriptMethodParams &params) {
// PARAMS1(int, id);
// not implemented
debug(0, "AGSController: SetPlayerIndex not implemented");
}
void AGSControllerArcnor::RunVirtualKeyboard(ScriptMethodParams &params) {
// PARAMS6(int, keyboard_mode, const char *, initialtext, const char *, headertext, const char *, guidetext, const char *, oktext, int, maxchars);
debug(0, "AGSController: Virtual Keyboard not implemented");
params._result = _engine->CreateScriptString("");
}
} // namespace AGSController
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,51 @@
/* 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_AGSCONTROLLER_AGSCONTROLLER_ARCNOR_H
#define AGS_PLUGINS_AGSCONTROLLER_AGSCONTROLLER_ARCNOR_H
#include "ags/plugins/ags_controller/ags_controller.h"
namespace AGS3 {
namespace Plugins {
namespace AGSController {
class AGSControllerArcnor : public AGSController {
SCRIPT_HASH_SUB(AGSControllerArcnor, AGSController)
private:
void Controller_IsButtonUpOnce(ScriptMethodParams &params);
void Controller_PressAnyButton(ScriptMethodParams &params);
void Controller_GetPlayerIndex(ScriptMethodParams &params);
void Controller_SetPlayerIndex(ScriptMethodParams &params);
void RunVirtualKeyboard(ScriptMethodParams &params);
public:
AGSControllerArcnor() : AGSController() {}
virtual ~AGSControllerArcnor() {}
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSController
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,644 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_creditz/ags_creditz.h"
#include "ags/lib/allegro/surface.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
void AGSCreditz::draw() {
int endPoint;
if (_creditsRunning) {
_engine->PollSystem();
if (!_staticCredits) {
// Scrolling credits
if (_seqSettings[_creditSequence].automatic == 1)
endPoint = 0 - _calculatedSequenceHeight;
else
endPoint = _seqSettings[_creditSequence].endpoint;
if (_yPos >= endPoint) {
doCredits();
} else {
if (_seqSettings[_creditSequence].endwait > 0 && _timer <= _seqSettings[_creditSequence].endwait) {
_paused = true;
doCredits();
_timer++;
return;
} else {
_paused = false;
_timer = 0;
_creditsRunning = false;
_seqSettings[_creditSequence].finished = true;
}
}
_engine->MarkRegionDirty(0, 0, _screenWidth, _screenHeight);
} else {
// credits
if (!_singleStatic.bool_) {
if (_currentStatic < (int)_stCredits[_creditSequence].size()) {
if (_stCredits[_creditSequence][_currentStatic].pause > 0) {
// Pause
if (_timer <= _stCredits[_creditSequence][_currentStatic].pause) {
_timer++;
} else {
_timer = 0;
_currentStatic++;
}
} else {
if (_stCredits[_creditSequence][_currentStatic].image) {
// Image
if (_timer <= _stCredits[_creditSequence][_currentStatic].image_time) {
drawCredit(_creditSequence, _currentStatic);
_timer++;
} else {
_timer = 0;
_currentStatic++;
if (_stCredits[_creditSequence][_currentStatic].pause <= 0 &&
_currentStatic< (int)_stCredits[_creditSequence].size())
drawCredit(_creditSequence, _currentStatic);
else
return;
}
} else {
// Text
if (_timer <= (_stSeqSettings[_creditSequence].speed *
((int)_stCredits[_creditSequence][_currentStatic].title.size() +
(int)_stCredits[_creditSequence][_currentStatic].credit.size()))) {
drawCredit(_creditSequence, _currentStatic);
_timer++;
} else {
_timer = 0;
_currentStatic++;
if (_stCredits[_creditSequence][_currentStatic].pause <= 0 &&
(int)_currentStatic<= (int)_stCredits[_creditSequence].size())
drawCredit(_creditSequence, _currentStatic);
else
return;
}
}
}
} else {
_stSeqSettings[_creditSequence].finished = true;
_creditsRunning = false;
_creditSequence = -1;
_timer = 0;
_currentStatic= 1;
return;
}
} else {
// Single Static
if (_timer <= _singleStatic.time) {
if (_singleStatic.style == 0)
drawCredit(_creditSequence, _singleStatic.id);
else if (_singleStatic.style == 1)
drawStEffects(_creditSequence, _singleStatic.id, _singleStatic.style);
_timer++;
} else {
_timer = 0;
_singleStatic.bool_ = false;
_creditsRunning = false;
_staticCredits = false;
_stSeqSettings[_creditSequence].finished = true;
_creditSequence = -1;
}
}
}
}
}
int AGSCreditz::drawCredit(int sequence, int credit) {
int font, color;
int32 x_pos, leveys, korkeus = 0;
int32 scrn_width, scrn_height, coldepth, y_posit;
int slot, sprite_height, sprite_width, linecount, line, others;
Common::String text;
Common::String teksti;
BITMAP *sprite;
int result = 0;
_engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
if (!_staticCredits) {
// Scrolling Credits
if ((_yPos + _sequenceHeight) > scrn_height)
return 0;
if (_credits[sequence][credit]._image) {
slot = _credits[sequence][credit]._fontSlot;
sprite_height = _credits[sequence][credit]._colorHeight;
x_pos = _credits[sequence][credit]._x;
if (x_pos < 0) {
sprite_width = _engine->GetSpriteWidth(slot);
x_pos = (scrn_width - sprite_width) / 2;
} else {
x_pos = VGACheck(x_pos);
}
if (sprite_height < 0)
sprite_height = _engine->GetSpriteHeight(slot);
else
sprite_height = VGACheck(sprite_height);
korkeus = sprite_height;
sprite = _engine->GetSpriteGraphic(slot);
_engine->BlitBitmap(x_pos, _yPos + _sequenceHeight, sprite, 1);
} else {
font = _credits[sequence][credit]._fontSlot;
color = _credits[sequence][credit]._colorHeight;
text = _credits[sequence][credit]._text;
x_pos = _credits[sequence][credit]._x;
if (!text.empty()) {
_engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
if (x_pos < 0) {
x_pos = (scrn_width - leveys) / 2;
} else {
x_pos = VGACheck(x_pos);
}
if (text.contains('<')) {
specialEffect(sequence, credit, text, font, color, x_pos);
} else {
if (_credits[sequence][credit]._outline) {
// Outline
_engine->DrawText(x_pos - 1, _yPos + _sequenceHeight, font, 16, text.c_str());
_engine->DrawText(x_pos + 1, _yPos + _sequenceHeight, font, 16, text.c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight - 1, font, 16, text.c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight + 1, font, 16, text.c_str());
}
_engine->DrawText(x_pos, _yPos + _sequenceHeight, font, color, text.c_str());
}
}
}
result = korkeus;
} else {
if (_stCredits[sequence][credit].image) {
x_pos = _stCredits[sequence][credit].x;
y_posit = _stCredits[sequence][credit].y;
font = _stCredits[sequence][credit].image_slot;
sprite = _engine->GetSpriteGraphic(font);
_engine->GetBitmapDimensions(sprite, &leveys, &korkeus, &coldepth);
if (x_pos < 0)
x_pos = (scrn_width - leveys) / 2;
else
x_pos = VGACheck(x_pos);
if (y_posit < 0)
y_posit = (scrn_height - korkeus) / 2;
else
y_posit = VGACheck(y_posit);
_engine->BlitBitmap(x_pos, y_posit, sprite, 1);
result = 0;
} else {
// Title
font = _stCredits[sequence][credit].title_font;
color = _stCredits[sequence][credit].title_color;
text = _stCredits[sequence][credit].title;
x_pos = _stCredits[sequence][credit].title_x;
y_posit = _stCredits[sequence][credit].title_y;
if (!text.empty()) {
_engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
if (x_pos < 0)
x_pos = (scrn_width - leveys) / 2;
else
x_pos = VGACheck(x_pos);
if (y_posit < 0)
y_posit = (scrn_height - korkeus) / 2;
else
y_posit = VGACheck(y_posit);
if (_stCredits[sequence][credit].title_outline) {
_engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
_engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
}
_engine->DrawText(x_pos, y_posit, font, color, text.c_str());
_engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
}
// Credit
font = _stCredits[sequence][credit].font;
color = _stCredits[sequence][credit].color;
text = _stCredits[sequence][credit].credit;
x_pos = _stCredits[sequence][credit].x;
y_posit = _stCredits[sequence][credit].y;
if (!text.empty()) {
_engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
if (!text.contains("[[")) {
if (x_pos < 0)
x_pos = (scrn_width - leveys) / 2;
else
x_pos = VGACheck(x_pos);
if (y_posit < 0)
y_posit = (scrn_height - korkeus) / 2;
else
y_posit = VGACheck(y_posit);
if (_stCredits[sequence][credit].outline) {
_engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
_engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
}
_engine->DrawText(x_pos, y_posit, font, color, text.c_str());
_engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
} else {
linecount = countLines(text);
line = 1;
teksti = text;
others = 0;
if (y_posit < 0)
y_posit = (scrn_height - (korkeus * (linecount + 1))) / 2;
else
y_posit = VGACheck(y_posit);
while (line <= linecount + 1) {
text = extractParameter(teksti, "[[");
_engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
if (x_pos < 0)
x_pos = (scrn_width - leveys) / 2;
else
x_pos = VGACheck(x_pos);
if (_stCredits[sequence][credit].outline) {
_engine->DrawText(x_pos - 1, y_posit + others, font, 16, text.c_str());
_engine->DrawText(x_pos + 1, y_posit + others, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit + others - 1, font, 16, text.c_str());
_engine->DrawText(x_pos, y_posit + others + 1, font, 16, text.c_str());
}
_engine->DrawText(x_pos, y_posit + others, font, color, text.c_str());
_engine->MarkRegionDirty(x_pos, y_posit + others, x_pos + leveys, y_posit + others + korkeus + 15);
others += korkeus;
x_pos = _stCredits[sequence][credit].x;
line++;
}
}
}
result = 0;
}
}
return result;
}
void AGSCreditz::doCredits() {
int current_line;
int32 increment, dum;
current_line = 1;
_sequenceHeight = 0;
while (current_line < (int)_credits[_creditSequence].size()) {
if (_credits[_creditSequence][current_line]._isSet) {
if (_credits[_creditSequence][current_line]._image) {
increment = _engine->GetSpriteHeight(_credits[_creditSequence][current_line]._fontSlot);
if ((_yPos + _sequenceHeight + increment) <= 0) {
if (_credits[_creditSequence][current_line]._colorHeight >= 0)
increment = VGACheck(_credits[_creditSequence][current_line]._colorHeight);
}
} else {
_engine->GetTextExtent(_credits[_creditSequence][current_line]._fontSlot,
_credits[_creditSequence][current_line]._text.c_str(), &dum, &increment);
}
if ((_yPos + _sequenceHeight + increment) > 0)
increment = drawCredit(_creditSequence, current_line);
} else {
increment = VGACheck(_emptyLineHeight);
}
_sequenceHeight += increment;
current_line++;
}
if (!_paused)
speeder(_creditSequence);
}
int AGSCreditz::countLines(const Common::String &text) {
int lines;
Common::String teksti;
teksti = text;
lines = 0;
while (teksti.contains("[[")) {
extractParameter(teksti, "[[");
++lines;
}
return lines;
}
Common::String AGSCreditz::extractParameter(Common::String &line, const Common::String &separator) {
int p;
Common::String result;
p = line.find(separator, 0);
if (p != -1) {
if (p > 0) {
result = line.substr(0, p);
result.trim();
}
line = line.substr(p + separator.size());
} else if (!line.empty()) {
line.trim();
result.clear();
}
return result;
}
void AGSCreditz::specialEffect(int sequence, int credit, const Common::String &text,
int font, int color, int32 x_pos) {
Common::String creditt[3];
Common::String credit_text, dots;
int32 scrn_width, dum, rightside_width, leftside_width, dotwidth;
int space, dotcount, dotpos;
_engine->GetScreenDimensions(&scrn_width, &dum, &dum);
if (text.contains("<>")) {
if (x_pos < 0)
x_pos = 0;
credit_text = text;
creditt[0] = extractParameter(credit_text, "<");
creditt[1] = extractParameter(credit_text, ">");
creditt[2] = credit_text;
_engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
if (_credits[sequence][credit]._outline) {
_engine->DrawText(x_pos - 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(x_pos + 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight - 1, font, color, creditt[0].c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight + 1, font, color, creditt[0].c_str());
}
_engine->DrawText(x_pos, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
if (_credits[sequence][credit]._outline) {
_engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight - 1, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight + 1, font, color, creditt[2].c_str());
}
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight, font, color, creditt[2].c_str());
} else if (text.contains("<.>")) {
if (x_pos < 0)
x_pos = 0;
credit_text = text;
creditt[0] = extractParameter(credit_text, "<");
creditt[1] = extractParameter(credit_text, ">");
creditt[2] = credit_text;
_engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
_engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
if (_credits[sequence][credit]._outline) {
_engine->DrawText(x_pos - 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(x_pos + 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight - 1, font, color, creditt[0].c_str());
_engine->DrawText(x_pos, _yPos + _sequenceHeight + 1, font, color, creditt[0].c_str());
}
_engine->DrawText(x_pos, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
if (_credits[sequence][credit]._outline) {
_engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight - 1, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight + 1, font, color, creditt[2].c_str());
}
_engine->DrawText(scrn_width - (x_pos + rightside_width), _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->GetTextExtent(font, " .", &dotwidth, &dum);
space = scrn_width - (x_pos + leftside_width + x_pos + rightside_width);
dotcount = space / dotwidth;
dotpos = 0;
dots = "";
while (dotpos < dotcount) {
dots = dots + " .";
dotpos++;
}
if (_credits[sequence][credit]._outline) {
_engine->DrawText(x_pos + leftside_width - 1, _yPos + _sequenceHeight, font, color, dots.c_str());
_engine->DrawText(x_pos + leftside_width + 1, _yPos + _sequenceHeight, font, color, dots.c_str());
_engine->DrawText(x_pos + leftside_width, _yPos + _sequenceHeight - 1, font, color, dots.c_str());
_engine->DrawText(x_pos + leftside_width, _yPos + _sequenceHeight + 1, font, color, dots.c_str());
}
_engine->DrawText(x_pos + leftside_width, _yPos + _sequenceHeight, font, color, dots.c_str());
} else if (text.contains("<#>")) {
if (x_pos < 0)
x_pos = 0;
credit_text = text;
creditt[0] = extractParameter(credit_text, "<");
creditt[1] = extractParameter(credit_text, ">");
creditt[2] = credit_text;
_engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
_engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
if (_credits[sequence][credit]._outline) {
_engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width - 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width + 1, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
_engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _yPos + _sequenceHeight - 1, font, color, creditt[0].c_str());
_engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _yPos + _sequenceHeight + 1, font, color, creditt[0].c_str());
}
_engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _yPos + _sequenceHeight, font, color, creditt[0].c_str());
if (_credits[sequence][credit]._outline) {
_engine->DrawText(scrn_width / 2 + x_pos / 2 - 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width / 2 + x_pos / 2 + 1, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width / 2 + x_pos / 2, _yPos + _sequenceHeight - 1, font, color, creditt[2].c_str());
_engine->DrawText(scrn_width / 2 + x_pos / 2, _yPos + _sequenceHeight + 1, font, color, creditt[2].c_str());
}
_engine->DrawText(scrn_width / 2 + x_pos / 2, _yPos + _sequenceHeight, font, color, creditt[2].c_str());
}
}
void AGSCreditz::drawStEffects(int sequence, int id, int style) {
Common::String teksti;
Common::String teksti2;
int thischar;
Common::String text;
int font, color, set1, set2;
int32 x_pos, y_posit, scrn_width, leveys, scrn_height, korkeus, coldepth;
teksti = _stCredits[sequence][id].credit;
font = _stCredits[sequence][id].font;
color = _stCredits[sequence][id].color;
x_pos = _stCredits[sequence][id].x;
y_posit = _stCredits[sequence][id].y;
set1 = _singleStatic.settings1;
set2 = _singleStatic.settings2;
_engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
_engine->GetTextExtent(font, teksti.c_str(), &leveys, &korkeus);
if (style == 1) {
if (set2 >= 0 && _numChars < (int)teksti.size() && _timer2 == 0) {
_playSound(set2);
}
if (_timer2 <= set1) {
thischar = 0;
if (thischar <= _numChars && _numChars <= (int)teksti.size()) {
for (thischar = 0; thischar < _numChars; ++thischar)
teksti2 = teksti2 + teksti[thischar];
text = teksti2;
} else {
text = teksti;
}
if (x_pos < 0)
x_pos = (scrn_width - leveys) / 2;
else
x_pos = VGACheck(x_pos);
if (y_posit < 0)
y_posit = (scrn_height - korkeus) / 2;
else
y_posit = VGACheck(y_posit);
_engine->DrawText(x_pos, y_posit, font, color, text.c_str());
_timer2++;
x_pos = _stCredits[sequence][id].x;
y_posit = _stCredits[sequence][id].y;
} else {
_numChars++;
thischar = 0;
_timer2 = 0;
drawStEffects(sequence, id, style);
}
}
}
void AGSCreditz::speeder(int sequence) {
int speed = _seqSettings[sequence].speed;
if (_speedPoint == speed) {
_yPos -= VGACheck(1);
_speedPoint = 0;
} else {
_speedPoint++;
}
}
void AGSCreditz::calculateSequenceHeight(int sequence) {
int32 height, creditHeight, dum;
height = 0;
for (uint currentCredit = 0; currentCredit < _credits[sequence].size();
++currentCredit) {
if (_credits[sequence][currentCredit]._isSet) {
if (_credits[sequence][currentCredit]._image) {
if (_credits[sequence][currentCredit]._colorHeight < 0)
creditHeight = _engine->GetSpriteHeight(_credits[sequence][currentCredit]._fontSlot);
else
creditHeight = _credits[sequence][currentCredit]._colorHeight;
} else {
_engine->GetTextExtent(_credits[sequence][currentCredit]._fontSlot,
_credits[sequence][currentCredit]._text.c_str(),
&dum, &creditHeight);
}
height += creditHeight;
} else {
height += VGACheck(_emptyLineHeight);
}
}
_calculatedSequenceHeight = height;
}
int AGSCreditz::VGACheck(int value) {
int32 screenX, dum;
_engine->GetScreenDimensions(&screenX, &dum, &dum);
if (screenX == 640)
return value * 2;
else
return value;
}
void AGSCreditz::startSequence(int sequence) {
if (!_creditsRunning) {
_seqSettings[sequence].finished = false;
_creditsRunning = true;
_creditSequence = sequence;
_engine->GetScreenDimensions(&_screenWidth, &_screenHeight,
&_screenColorDepth);
if (_seqSettings[sequence].automatic) {
calculateSequenceHeight(sequence);
_yPos = _screenHeight + 1;
} else {
_yPos = _seqSettings[sequence].startpoint;
}
_speedPoint = 0;
_timer = 0;
draw();
} else {
_paused = false;
_creditsRunning = false;
_creditSequence = -1;
_seqSettings[sequence].finished = true;
}
}
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,146 @@
/* 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_AGSCREDITZ_AGSCREDITZ_H
#define AGS_PLUGINS_AGSCREDITZ_AGSCREDITZ_H
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/ags_creditz/drawing.h"
#include "common/array.h"
#include "common/rect.h"
#include "common/str.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
typedef int (*IntFunction)(int val1);
struct Credit {
Common::String _text;
int _x = 0;
int _y = 0;
int _fontSlot = 0;
int _colorHeight = 0;
bool _isSet = false;
bool _image = false;
bool _outline = false;
};
struct SequenceSettings {
int startpoint = 0;
int endpoint = 0;
int speed = 0;
bool finished = false;
int automatic = 0;
int endwait = 0;
int topmask = 0;
int bottommask = 0;
};
struct StCredit {
Common::String credit;
Common::String title;
int x = 0;
int y = 0;
int font = 0;
int color = 0;
int title_x = 0;
int title_y = 0;
int title_font = 0;
int title_color = 0;
bool title_centered = false;
bool title_outline = false;
int pause = 0;
bool image = false;
int image_slot = 0;
int image_time = 0;
bool outline = false;
};
struct StSequenceSettings {
int speed = 0;
bool finished = false;
};
struct SingleStatic {
int id = 0;
int time = 0;
int style = 0;
int settings1 = 01;
int settings2 = 0;
bool bool_ = false;
};
typedef Common::Array<Credit> CreditArray;
typedef Common::Array<StCredit> StCreditArray;
class AGSCreditz : public PluginBase, public Drawing {
private:
int drawCredit(int sequence, int credit);
void doCredits();
int countLines(const Common::String &text);
Common::String extractParameter(Common::String &line, const Common::String &separator);
void specialEffect(int sequence, int credit, const Common::String &text,
int font, int color, int32 x_pos);
void drawStEffects(int sequence, int id, int style);
void speeder(int sequence);
protected:
enum Version {
VERSION_11 = 11, VERSION_20 = 20
};
Version _version;
PluginMethod _playSound;
CreditArray _credits[10];
StCreditArray _stCredits[10];
bool _creditsRunning = 0, _paused = 0, _staticCredits = 0;
int _creditSequence = 0, _yPos = 0, _sequenceHeight = 0, _speedPoint = 0;
int _calculatedSequenceHeight = 0, _timer = 0, _currentStatic = 0;
int _numChars = 0, _timer2 = 0;
int _emptyLineHeight = 10;
int _strCredit[10];
SequenceSettings _seqSettings[10];
StSequenceSettings _stSeqSettings[10];
SingleStatic _singleStatic;
// Version 1.1 specific
bool _resolutionFlag = false;
int32 _screenWidth = 0, _screenHeight = 0, _screenColorDepth = 0;
int32 _staticScreenWidth = 0;
bool _staticWidthMatches = false;
void draw();
void calculateSequenceHeight(int sequence);
int VGACheck(int value);
void startSequence(int sequence);
public:
AGSCreditz() : PluginBase(), Drawing() {}
virtual ~AGSCreditz() {}
};
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,315 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_creditz/ags_creditz1.h"
#include "ags/lib/allegro/surface.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
const char *IMAGE_TEXT = "*i*m*a*g*e*";
AGSCreditz1::AGSCreditz1() : AGSCreditz() {
_version = VERSION_11;
}
const char *AGSCreditz1::AGS_GetPluginName() {
return "AGSCreditz v1.1 by AJA";
}
void AGSCreditz1::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
engine->RequestEventHook(AGSE_POSTSCREENDRAW);
_engine->GetScreenDimensions(&_screenWidth,
&_screenHeight, &_screenColorDepth);
SCRIPT_METHOD(SetCredit, AGSCreditz1::SetCredit);
SCRIPT_METHOD(ScrollCredits, AGSCreditz1::ScrollCredits);
SCRIPT_METHOD(GetCredit, AGSCreditz1::GetCredit);
SCRIPT_METHOD(IsCreditScrollingFinished, AGSCreditz1::IsCreditScrollingFinished);
SCRIPT_METHOD(IsFinished, AGSCreditz1::IsCreditScrollingFinished);
SCRIPT_METHOD(SetCreditImage, AGSCreditz1::SetCreditImage);
SCRIPT_METHOD(PauseScroll, AGSCreditz1::PauseScroll);
SCRIPT_METHOD(ScrollReset, AGSCreditz1::ScrollReset);
SCRIPT_METHOD(SetEmptyLineHeight, AGSCreditz1::SetEmptyLineHeight);
SCRIPT_METHOD(GetEmptyLineHeight, AGSCreditz1::GetEmptyLineHeight);
SCRIPT_METHOD(SetStaticCredit, AGSCreditz1::SetStaticCredit);
SCRIPT_METHOD(GetStaticCredit, AGSCreditz1::GetStaticCredit);
SCRIPT_METHOD(StartEndStaticCredits, AGSCreditz1::StartEndStaticCredits);
SCRIPT_METHOD(GetCurrentStaticCredit, AGSCreditz1::GetCurrentStaticCredit);
SCRIPT_METHOD(SetDefaultStaticDelay, AGSCreditz1::SetDefaultStaticDelay);
SCRIPT_METHOD(SetStaticPause, AGSCreditz1::SetStaticPause);
SCRIPT_METHOD(SetStaticCreditTitle, AGSCreditz1::SetStaticCreditTitle);
SCRIPT_METHOD(ShowStaticCredit, AGSCreditz1::ShowStaticCredit);
SCRIPT_METHOD(StaticReset, AGSCreditz1::StaticReset);
SCRIPT_METHOD(GetStaticCreditTitle, AGSCreditz1::GetStaticCreditTitle);
SCRIPT_METHOD(SetStaticCreditImage, AGSCreditz1::SetStaticCreditImage);
SCRIPT_METHOD(IsStaticCreditsFinished, AGSCreditz1::IsStaticCreditsFinished);
}
int64 AGSCreditz1::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event & AGSE_POSTSCREENDRAW)
draw();
return 0;
}
void AGSCreditz1::SetCredit(ScriptMethodParams &params) {
PARAMS7(int, ID, string, credit, int, colour, int, font, bool, center, int, xpos, int, generateoutline);
if (ID >= (int)_credits[0].size())
_credits[0].resize(ID + 1);
if (center) {
int32 creditW, creditH;
_engine->GetTextExtent(font, credit, &creditW, &creditH);
xpos = (_screenWidth - creditW) / 2;
}
Credit &c = _credits[0][ID];
c._text = credit;
c._fontSlot = font;
c._x = xpos;
c._isSet = true;
c._outline = generateoutline;
c._colorHeight = colour;
}
void AGSCreditz1::SetCreditImage(ScriptMethodParams &params) {
PARAMS5(int, ID, int, slot, bool, center, int, xpos, int, pixtonext);
if (ID >= (int)_credits[0].size())
_credits[0].resize(ID + 1);
BITMAP *gfx = _engine->GetSpriteGraphic(slot);
if (center)
xpos = (_screenWidth - gfx->w) / 2;
_credits[0][ID]._image = true;
_credits[0][ID]._isSet = true;
_credits[0][ID]._x = xpos;
_credits[0][ID]._fontSlot = slot;
if (pixtonext != -1) {
_credits[0][ID]._colorHeight = pixtonext;
} else {
_credits[0][ID]._colorHeight = gfx->h;
}
}
void AGSCreditz1::ScrollCredits(ScriptMethodParams &params) {
PARAMS7(int, onoff, int, speed, int, fromY, int, toY, int, isautom, int, wait, int, resolution);
if (onoff == 1) {
_seqSettings[0].speed = speed;
_seqSettings[0].endwait = wait;
_seqSettings[0].startpoint = fromY;
_seqSettings[0].endpoint = toY;
_seqSettings[0].automatic = isautom;
if (_screenWidth == 320) {
_resolutionFlag = (resolution != 2) ? 1 : 0;
} else if (_screenWidth == 640) {
_resolutionFlag = (resolution != 1) ? 1 : 0;
}
startSequence(0);
} else if (onoff == 0) {
_creditsRunning = false;
} else {
_engine->AbortGame("ScrollCredits: OnOff value must be 1 or 0!");
}
}
void AGSCreditz1::GetCredit(ScriptMethodParams &params) {
PARAMS1(int, ID);
params._result = (_credits[0][ID]._text == IMAGE_TEXT) ?
"image" : _credits[0][ID]._text.c_str();
}
void AGSCreditz1::IsCreditScrollingFinished(ScriptMethodParams &params) {
params._result = _seqSettings[0].finished;
}
void AGSCreditz1::PauseScroll(ScriptMethodParams &params) {
PARAMS1(bool, onoff);
_paused = onoff;
}
void AGSCreditz1::ScrollReset(ScriptMethodParams &params) {
_credits[0].clear();
_creditsRunning = false;
}
void AGSCreditz1::SetEmptyLineHeight(ScriptMethodParams &params) {
PARAMS1(int, emptylineheight);
_emptyLineHeight = emptylineheight;
}
void AGSCreditz1::GetEmptyLineHeight(ScriptMethodParams &params) {
params._result = _emptyLineHeight;
}
void AGSCreditz1::SetStaticCredit(ScriptMethodParams &params) {
PARAMS8(int, ID, int, x, int, y, int, font, int, creditcolour, \
bool, center, int, generateoutline, string, credit);
if (ID >= (int)_credits[0].size())
_credits[0].resize(ID + 1);
if (center) {
int32 creditW, creditH;
_engine->GetTextExtent(font, credit, &creditW, &creditH);
x = (_screenWidth - creditW) / 2;
}
StCredit &c = _stCredits[0][ID];
c.credit = credit;
c.font = font;
c.color = creditcolour;
c.x = x;
c.y = y;
c.outline = generateoutline;
}
void AGSCreditz1::GetStaticCredit(ScriptMethodParams &params) {
PARAMS1(int, ID);
StCredit &c = _stCredits[0][ID];
params._result = c.credit.c_str();
}
void AGSCreditz1::StartEndStaticCredits(ScriptMethodParams &params) {
PARAMS2(bool, onoff, int, res);
if (!onoff) {
_staticCredits = false;
} else if (res != 1 && res != 2) {
_engine->AbortGame("StartEndStaticCredits: Wrong resolution");
} else {
_currentStatic = 0;
_engine->GetScreenDimensions(&_screenWidth,
&_screenHeight, &_screenColorDepth);
_staticScreenWidth = (res == 1) ? 320 : 640;
_staticWidthMatches = _screenWidth == _staticScreenWidth;
}
}
void AGSCreditz1::GetCurrentStaticCredit(ScriptMethodParams &params) {
params._result = _currentStatic;
}
void AGSCreditz1::SetDefaultStaticDelay(ScriptMethodParams &params) {
PARAMS1(int, Cyclesperchar);
_stSeqSettings[0].speed = Cyclesperchar;
}
void AGSCreditz1::SetStaticPause(ScriptMethodParams &params) {
PARAMS2(int, ID, int, length);
_stCredits[0][ID].pause = length;
}
void AGSCreditz1::SetStaticCreditTitle(ScriptMethodParams &params) {
PARAMS8(int, ID, int, x, int, y, int, titlefont, int, titlecolour, \
int, centered, int, generateoutline, string, title);
StCredit &c = _stCredits[0][ID];
c.title_x = x;
c.title_y = y;
c.title_font = titlefont;
c.title_color = titlecolour;
c.title_centered = centered;
c.title_outline = generateoutline;
c.title = title;
}
void AGSCreditz1::ShowStaticCredit(ScriptMethodParams &params) {
PARAMS6(int, ID, int, time, int, style, int, transtime, \
int, sound, int, res);
const StCredit &c = _stCredits[0][ID];
if (!_staticCredits) {
if (c.credit.empty() && c.title.empty()) {
_engine->AbortGame("ShowStaticCredit: Credit not set!");
} else if (res == 1 || (res == 2 && c.credit != "P=A=U=S=E")) {
if (style == 1) {
// TODO: style 1 setup
warning("TODO: Use %d %d %d", transtime, time, sound);
}
_engine->GetScreenDimensions(&_screenWidth,
&_screenHeight, &_screenColorDepth);
_staticScreenWidth = (res == 1) ? 320 : 640;
_staticWidthMatches = _screenWidth == _staticScreenWidth;
_currentStatic = ID;
// TODO: Final setup
}
}
params._result = 0;
}
void AGSCreditz1::StaticReset(ScriptMethodParams &params) {
_stCredits[0].clear();
}
void AGSCreditz1::GetStaticCreditTitle(ScriptMethodParams &params) {
PARAMS1(int, ID);
const StCredit &c = _stCredits[0][ID];
params._result = c.title.c_str();
}
void AGSCreditz1::SetStaticCreditImage(ScriptMethodParams &params) {
PARAMS7(int, ID, int, x, int, y, int, slot, int, Hcentered, \
bool, Vcentered, int, time);
if (Hcentered) {
BITMAP *gfx = _engine->GetSpriteGraphic(slot);
if (Hcentered)
x = (_screenWidth - gfx->w) / 2;
}
StCredit &c = _stCredits[0][ID];
c.credit = "I=M=A=G=E";
c.x = x;
c.y = y;
c.font = slot;
// TODO: Below seems *weird*
c.outline = Vcentered;
c.color = time;
}
void AGSCreditz1::IsStaticCreditsFinished(ScriptMethodParams &params) {
params._result = _stSeqSettings[0].finished;
}
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,68 @@
/* 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_AGSCREDITZ_AGSCREDITZ1_H
#define AGS_PLUGINS_AGSCREDITZ_AGSCREDITZ1_H
#include "ags/plugins/ags_creditz/ags_creditz.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
class AGSCreditz1 : public AGSCreditz {
SCRIPT_HASH_SUB(AGSCreditz1, AGSCreditz)
private:
void SetCredit(ScriptMethodParams &params);
void ScrollCredits(ScriptMethodParams &params);
void GetCredit(ScriptMethodParams &params);
void IsCreditScrollingFinished(ScriptMethodParams &params);
void SetCreditImage(ScriptMethodParams &params);
void PauseScroll(ScriptMethodParams &params);
void ScrollReset(ScriptMethodParams &params);
void SetEmptyLineHeight(ScriptMethodParams &params);
void GetEmptyLineHeight(ScriptMethodParams &params);
void SetStaticCredit(ScriptMethodParams &params);
void GetStaticCredit(ScriptMethodParams &params);
void StartEndStaticCredits(ScriptMethodParams &params);
void GetCurrentStaticCredit(ScriptMethodParams &params);
void SetDefaultStaticDelay(ScriptMethodParams &params);
void SetStaticPause(ScriptMethodParams &params);
void SetStaticCreditTitle(ScriptMethodParams &params);
void ShowStaticCredit(ScriptMethodParams &params);
void StaticReset(ScriptMethodParams &params);
void GetStaticCreditTitle(ScriptMethodParams &params);
void SetStaticCreditImage(ScriptMethodParams &params);
void IsStaticCreditsFinished(ScriptMethodParams &params);
public:
AGSCreditz1();
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,280 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_creditz/ags_creditz2.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
AGSCreditz2::AGSCreditz2() : AGSCreditz() {
_version = VERSION_20;
}
const char *AGSCreditz2::AGS_GetPluginName() {
return "AGSCreditz 2.0 (by Dima Software: AJA)";
}
void AGSCreditz2::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
_playSound = _engine->GetScriptFunctionAddress("PlaySound");
engine->RequestEventHook(AGSE_POSTSCREENDRAW);
SCRIPT_METHOD(RunCreditSequence, AGSCreditz2::RunCreditSequence);
SCRIPT_METHOD(SetCredit, AGSCreditz2::SetCredit);
SCRIPT_METHOD(GetCredit, AGSCreditz2::GetCredit);
SCRIPT_METHOD(CreditsSettings, AGSCreditz2::CreditsSettings);
SCRIPT_METHOD(SequenceSettings, AGSCreditz2::SequenceSettings);
SCRIPT_METHOD(IsSequenceFinished, AGSCreditz2::IsSequenceFinished);
SCRIPT_METHOD(PauseScrolling, AGSCreditz2::PauseScrolling);
SCRIPT_METHOD(SetCreditImage, AGSCreditz2::SetCreditImage);
SCRIPT_METHOD(ResetSequence, AGSCreditz2::ResetSequence);
SCRIPT_METHOD(SetStaticCredit, AGSCreditz2::SetStaticCredit);
SCRIPT_METHOD(SetStaticCreditTitle, AGSCreditz2::SetStaticCreditTitle);
SCRIPT_METHOD(SetStaticPause, AGSCreditz2::SetStaticPause);
SCRIPT_METHOD(RunStaticCreditSequence, AGSCreditz2::RunStaticCreditSequence);
SCRIPT_METHOD(IsStaticSequenceFinished, AGSCreditz2::IsStaticSequenceFinished);
SCRIPT_METHOD(ShowStaticCredit, AGSCreditz2::ShowStaticCredit);
SCRIPT_METHOD(SetStaticImage, AGSCreditz2::SetStaticImage);
SCRIPT_METHOD(GetCurrentStaticCredit, AGSCreditz2::GetCurrentStaticCredit);
}
int64 AGSCreditz2::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event & AGSE_POSTSCREENDRAW)
draw();
return 0;
}
void AGSCreditz2::RunCreditSequence(ScriptMethodParams &params) {
PARAMS1(int, sequence);
startSequence(sequence);
}
void AGSCreditz2::SetCredit(ScriptMethodParams &params) {
PARAMS7(int, sequence, int, line, string, credit, int, x_pos, int, font, int, color, int, gen_outline);
assert(sequence >= 0 && sequence <= 10);
if (line >= (int)_credits[sequence].size())
_credits[sequence].resize(line + 1);
Credit &c = _credits[sequence][line];
c._text = credit;
c._fontSlot = font;
c._colorHeight = color;
c._x = x_pos;
c._isSet = true;
if (gen_outline > 0)
c._outline = true;
}
void AGSCreditz2::GetCredit(ScriptMethodParams &params) {
PARAMS2(int, sequence, int, ID);
params._result = _credits[sequence][ID]._text.c_str();
}
void AGSCreditz2::CreditsSettings(ScriptMethodParams &params) {
PARAMS1(int, emptylineheight);
if (emptylineheight >= 0)
_emptyLineHeight = emptylineheight;
}
void AGSCreditz2::SequenceSettings(ScriptMethodParams &params) {
PARAMS6(int, sequence, int, startpoint, int, endPoint, int, speed, int, automatic, int, endwait);
_seqSettings[sequence].startpoint = startpoint;
_seqSettings[sequence].endpoint = endPoint;
_seqSettings[sequence].speed = speed;
_seqSettings[sequence].automatic = automatic;
_seqSettings[sequence].endwait = endwait;
}
void AGSCreditz2::IsSequenceFinished(ScriptMethodParams &params) {
PARAMS1(int, sequence);
if (_seqSettings[sequence].finished) {
_seqSettings[sequence].finished = false;
params._result = 1;
} else {
params._result = 0;
}
}
void AGSCreditz2::PauseScrolling(ScriptMethodParams &params) {
if (_creditsRunning) {
_paused = !_paused;
}
}
void AGSCreditz2::SetCreditImage(ScriptMethodParams &params) {
PARAMS5(int, sequence, int, line, int, xPos, int, slot, int, height);
assert(sequence >= 0 && sequence <= 10);
if (line >= (int)_credits[sequence].size())
_credits[sequence].resize(line + 1);
_credits[sequence][line]._image = true;
_credits[sequence][line]._isSet = true;
_credits[sequence][line]._x = xPos;
_credits[sequence][line]._fontSlot = slot;
_credits[sequence][line]._colorHeight = height;
}
void AGSCreditz2::ResetSequence(ScriptMethodParams &params) {
PARAMS1(int, seqtype);
for (int i = 0; i < 10; ++i) {
if (seqtype != 2)
// Scrolling
_credits[i].clear();
else
// Static
_stCredits[i].clear();
}
}
void AGSCreditz2::SetStaticCredit(ScriptMethodParams &params) {
PARAMS8(int, sequence, int, id, string, credit, int, xPos, int, yPos,
int, font, int, color, int, genOutline);
assert(sequence >= 0 && sequence <= 10);
if (id >= (int)_stCredits[sequence].size())
_stCredits[sequence].resize(id + 1);
_stCredits[sequence][id].credit = credit;
_stCredits[sequence][id].x = xPos;
_stCredits[sequence][id].y = yPos;
_stCredits[sequence][id].font = font;
_stCredits[sequence][id].color = color;
if (genOutline > 0)
_stCredits[sequence][id].outline = true;
}
void AGSCreditz2::SetStaticCreditTitle(ScriptMethodParams &params) {
PARAMS8(int, sequence, int, id, string, title, int, xPos, int, yPos,
int, font, int, color, int, genOutline);
assert(sequence >= 0 && sequence < 10);
if (id >= (int)_stCredits[sequence].size())
_stCredits[sequence].resize(id + 1);
_stCredits[sequence][id].title = title;
_stCredits[sequence][id].title_x = xPos;
_stCredits[sequence][id].title_y = yPos;
_stCredits[sequence][id].title_font = font;
_stCredits[sequence][id].title_color = color;
if (genOutline > 0)
_stCredits[sequence][id].title_outline = true;
}
void AGSCreditz2::SetStaticPause(ScriptMethodParams &params) {
PARAMS3(int, sequence, int, id, int, length);
assert(sequence >= 0 && sequence <= 10);
if (id >= (int)_stCredits[sequence].size())
_stCredits[sequence].resize(id + 1);
_stCredits[sequence][id].pause = length;
}
void AGSCreditz2::RunStaticCreditSequence(ScriptMethodParams &params) {
PARAMS2(int, sequence, int, speed);
if (!_creditsRunning) {
_stSeqSettings[sequence].finished = false;
_stSeqSettings[sequence].speed = speed;
_creditSequence = sequence;
_staticCredits = true;
_creditsRunning = true;
_currentStatic = 1;
_timer = 0;
draw();
} else {
_staticCredits = false;
_creditSequence = -1;
_stSeqSettings[sequence].finished = false;
_creditsRunning = false;
_currentStatic = 0;
_timer = 0;
}
}
void AGSCreditz2::IsStaticSequenceFinished(ScriptMethodParams &params) {
PARAMS1(int, sequence);
int result = (_stSeqSettings[sequence].finished) ? 1 : 0;
_stSeqSettings[sequence].finished = false;
params._result = result;
}
void AGSCreditz2::ShowStaticCredit(ScriptMethodParams &params) {
PARAMS6(int, sequence, int, id, int, time, int, style,
int, styleSettings1, int, styleSettings2);
_creditSequence = sequence;
_creditsRunning = true;
_staticCredits = true;
_singleStatic.id = id;
_singleStatic.time = time;
_singleStatic.style = style;
_singleStatic.settings1 = styleSettings1;
_singleStatic.settings2 = styleSettings2;
_singleStatic.bool_ = true;
_stSeqSettings[sequence].finished = false;
_timer = 0;
_timer2 = 0;
_numChars = 0;
draw();
}
void AGSCreditz2::SetStaticImage(ScriptMethodParams &params) {
PARAMS6(int, sequence, int, id, int, slot, int, xPos, int, yPos, int, length);
assert(sequence >= 0 && sequence < 10);
if (id >= (int)_stCredits[sequence].size())
_stCredits[sequence].resize(id + 1);
_stCredits[sequence][id].image = true;
_stCredits[sequence][id].image_slot = slot;
_stCredits[sequence][id].x = xPos;
_stCredits[sequence][id].y = yPos;
_stCredits[sequence][id].image_time = length;
}
void AGSCreditz2::GetCurrentStaticCredit(ScriptMethodParams &params) {
int result = -1;
if (_creditsRunning && _staticCredits)
result = _currentStatic;
params._result = result;
}
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,65 @@
/* 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_AGSCREDITZ_AGSCREDITZ2_H
#define AGS_PLUGINS_AGSCREDITZ_AGSCREDITZ2_H
#include "ags/plugins/ags_creditz/ags_creditz.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
class AGSCreditz2 : public AGSCreditz {
SCRIPT_HASH_SUB(AGSCreditz2, AGSCreditz)
private:
void RunCreditSequence(ScriptMethodParams &params);
void SetCredit(ScriptMethodParams &params);
void GetCredit(ScriptMethodParams &params);
void CreditsSettings(ScriptMethodParams &params);
void SequenceSettings(ScriptMethodParams &params);
void IsSequenceFinished(ScriptMethodParams &params);
void PauseScrolling(ScriptMethodParams &params);
void SetCreditImage(ScriptMethodParams &params);
void ResetSequence(ScriptMethodParams &params);
void SetStaticCredit(ScriptMethodParams &params);
void SetStaticCreditTitle(ScriptMethodParams &params);
void SetStaticPause(ScriptMethodParams &params);
void RunStaticCreditSequence(ScriptMethodParams &params);
void IsStaticSequenceFinished(ScriptMethodParams &params);
void ShowStaticCredit(ScriptMethodParams &params);
void SetStaticImage(ScriptMethodParams &params);
void GetCurrentStaticCredit(ScriptMethodParams &params);
public:
AGSCreditz2();
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,31 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_creditz/drawing.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,66 @@
/* 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_AGSCREDITZ_DRAWING_H
#define AGS_PLUGINS_AGSCREDITZ_DRAWING_H
#include "common/scummsys.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
class Drawing {
public:
void drawPixel(uint8 *bitmap, int32 x, int32 y,
uint col, int32 pitch, int32 coldepth) {
switch (coldepth) {
case 8:
bitmap[x + y * pitch] = col;
break;
case 16:
*((uint16 *)(bitmap + y * pitch + x * 2)) = col;
break;
case 32:
*((uint32 *)(bitmap + y * pitch + x * 4)) = col;
break;
}
}
uint getPixelColor(uint8 *bitmap, int32 x, int32 y,
int32 pitch, int32 coldepth) {
switch (coldepth) {
case 8:
return bitmap[x + y * pitch];
case 16:
return *((uint16 *)(bitmap + y * pitch + x * 2));
case 32:
return *((uint32 *)(bitmap + y * pitch + x * 4));
}
return 0;
}
};
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,62 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_filedel/ags_filedel.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/savefile.h"
#include "common/system.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFileDel {
const char *AGSFileDel::AGS_GetPluginName() {
return "AGS FileDel";
}
void AGSFileDel::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(FileDelete, AGSFileDel::FileDelete);
}
void AGSFileDel::FileDelete(ScriptMethodParams &params) {
PARAMS1(const char *, filename);
if (!filename) {
warning("AGSFileDel: empty filename!");
params._result = 0;
} else {
Common::String fullPath(ConfMan.get("gameid") + "-" + filename);
if (g_system->getSavefileManager()->removeSavefile(fullPath)) {
debug(0, "AGSFileDel: Deleted file %s", fullPath.c_str());
params._result = 1;
} else {
debug(0, "AGSFileDel: Couldn't delete file %s", fullPath.c_str());
params._result = 0;
}
}
}
} // namespace AGSFileDel
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,52 @@
/* 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_FILEDEL_H
#define AGS_PLUGINS_AGS_FILEDEL_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFileDel {
class AGSFileDel : public PluginBase {
SCRIPT_HASH(AGSFileDel)
private:
/**
* Deletes file specified in <string>.
*/
void FileDelete(ScriptMethodParams &params);
public:
AGSFileDel() : PluginBase() {}
virtual ~AGSFileDel() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSFileDel
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,101 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_fire/ags_fire.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFire {
const char *AGSFire::AGS_GetPluginName() {
return "Fire Plugin stub (ags_fire.dll)";
}
void AGSFire::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(FireAddObject, AGSFire::FireAddObject);
SCRIPT_METHOD(FirePreHeat, AGSFire::FirePreHeat);
SCRIPT_METHOD(FireDisableSeeding, AGSFire::FireDisableSeeding);
SCRIPT_METHOD(FireEnableSeeding, AGSFire::FireEnableSeeding);
SCRIPT_METHOD(FireSetStrength, AGSFire::FireSetStrength);
SCRIPT_METHOD(FireRemoveObject, AGSFire::FireRemoveObject);
SCRIPT_METHOD(FireUpdate, AGSFire::FireUpdate);
SCRIPT_METHOD(FireStop, AGSFire::FireStop);
}
void AGSFire::FireAddObject(ScriptMethodParams &params) {
//PARAMS3(int, object, int, seedSprite, int, paletteSprite)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FirePreHeat(ScriptMethodParams &params) {
//PARAMS1(int, object)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FireDisableSeeding(ScriptMethodParams &params) {
//PARAMS1(int, object)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FireEnableSeeding(ScriptMethodParams &params) {
//PARAMS1(int, object)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FireSetStrength(ScriptMethodParams &params) {
//PARAMS2(int, object, int, strength)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FireRemoveObject(ScriptMethodParams &params) {
//PARAMS1(int, object)
// TODO rest of the code
params._result = 0;
}
void AGSFire::FireUpdate(ScriptMethodParams &params) {
// TODO rest of the owl
params._result = 0;
}
void AGSFire::FireStop(ScriptMethodParams &params) {
// TODO rest of the owl
params._result = 0;
}
} // namespace AGSFire
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,55 @@
/* 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_FIRE_AGS_FIRE_H
#define AGS_PLUGINS_AGS_FIRE_AGS_FIRE_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFire {
class AGSFire : public PluginBase {
SCRIPT_HASH(AGSFire)
private:
void FireAddObject(ScriptMethodParams &params);
void FirePreHeat(ScriptMethodParams &params);
void FireDisableSeeding(ScriptMethodParams &params);
void FireEnableSeeding(ScriptMethodParams &params);
void FireSetStrength(ScriptMethodParams &params);
void FireRemoveObject(ScriptMethodParams &params);
void FireUpdate(ScriptMethodParams &params);
void FireStop(ScriptMethodParams &params);
public:
AGSFire() : PluginBase() {}
virtual ~AGSFire() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSFire
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,326 @@
/* 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/>.
*
*/
#include "ags/lib/allegro.h"
#include "ags/plugins/ags_flashlight/ags_flashlight.h"
#include "ags/shared/core/platform.h"
#include "common/str.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFlashlight {
const uint32 Magic = 0xBABE0000;
const uint32 Version = 2;
const uint32 SaveMagic = Magic + Version;
const char *AGSFlashlight::AGS_GetPluginName() {
return "Flashlight plugin recreation";
}
void AGSFlashlight::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD(SetFlashlightTint, AGSFlashlight::SetFlashlightTint);
SCRIPT_METHOD(GetFlashlightTintRed, AGSFlashlight::GetFlashlightTintRed);
SCRIPT_METHOD(GetFlashlightTintGreen, AGSFlashlight::GetFlashlightTintGreen);
SCRIPT_METHOD(GetFlashlightTintBlue, AGSFlashlight::GetFlashlightTintBlue);
SCRIPT_METHOD(GetFlashlightMinLightLevel, AGSFlashlight::GetFlashlightMinLightLevel);
SCRIPT_METHOD(GetFlashlightMaxLightLevel, AGSFlashlight::GetFlashlightMaxLightLevel);
SCRIPT_METHOD(SetFlashlightDarkness, AGSFlashlight::SetFlashlightDarkness);
SCRIPT_METHOD(GetFlashlightDarkness, AGSFlashlight::GetFlashlightDarkness);
SCRIPT_METHOD(SetFlashlightDarknessSize, AGSFlashlight::SetFlashlightDarknessSize);
SCRIPT_METHOD(GetFlashlightDarknessSize, AGSFlashlight::GetFlashlightDarknessSize);
SCRIPT_METHOD(SetFlashlightBrightness, AGSFlashlight::SetFlashlightBrightness);
SCRIPT_METHOD(GetFlashlightBrightness, AGSFlashlight::GetFlashlightBrightness);
SCRIPT_METHOD(SetFlashlightBrightnessSize, AGSFlashlight::SetFlashlightBrightnessSize);
SCRIPT_METHOD(GetFlashlightBrightnessSize, AGSFlashlight::GetFlashlightBrightnessSize);
SCRIPT_METHOD(SetFlashlightPosition, AGSFlashlight::SetFlashlightPosition);
SCRIPT_METHOD(GetFlashlightPositionX, AGSFlashlight::GetFlashlightPositionX);
SCRIPT_METHOD(GetFlashlightPositionY, AGSFlashlight::GetFlashlightPositionY);
SCRIPT_METHOD(SetFlashlightFollowMouse, AGSFlashlight::SetFlashlightFollowMouse);
SCRIPT_METHOD(GetFlashlightFollowMouse, AGSFlashlight::GetFlashlightFollowMouse);
SCRIPT_METHOD(SetFlashlightFollowCharacter, AGSFlashlight::SetFlashlightFollowCharacter);
SCRIPT_METHOD(GetFlashlightFollowCharacter, AGSFlashlight::GetFlashlightFollowCharacter);
SCRIPT_METHOD(GetFlashlightCharacterDX, AGSFlashlight::GetFlashlightCharacterDX);
SCRIPT_METHOD(GetFlashlightCharacterDY, AGSFlashlight::GetFlashlightCharacterDY);
SCRIPT_METHOD(GetFlashlightCharacterHorz, AGSFlashlight::GetFlashlightCharacterHorz);
SCRIPT_METHOD(GetFlashlightCharacterVert, AGSFlashlight::GetFlashlightCharacterVert);
SCRIPT_METHOD(SetFlashlightMask, AGSFlashlight::SetFlashlightMask);
SCRIPT_METHOD(GetFlashlightMask, AGSFlashlight::GetFlashlightMask);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_PRESCREENDRAW);
_engine->RequestEventHook(AGSE_SAVEGAME);
_engine->RequestEventHook(AGSE_RESTOREGAME);
}
int64 AGSFlashlight::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event == AGSE_PREGUIDRAW) {
Update();
} else if (event == AGSE_RESTOREGAME) {
Serializer s(_engine, data, true);
syncGame(s);
} else if (event == AGSE_SAVEGAME) {
Serializer s(_engine, data, false);
syncGame(s);
} else if (event == AGSE_PRESCREENDRAW) {
// Get screen size once here.
_engine->GetScreenDimensions(&screen_width, &screen_height, &screen_color_depth);
// TODO: There's no reliable way to figure out if a game is running in legacy upscale mode from the
// plugin interface, so for now let's just play it conservatively and check it per-game
AGSGameInfo *gameInfo = new AGSGameInfo;
gameInfo->Version = 26;
_engine->GetGameInfo(gameInfo);
if (gameInfo->UniqueId == 1050154255 || // MMD, MMM04, MMM13, MMM28, MMM46, MMM56, MMM57, MMM68, MMM78, MMMD9, MMMH5
gameInfo->UniqueId == 1161197869) // MMM70
g_ScaleFactor = (screen_width > 320) ? 2 : 1;
delete gameInfo;
_engine->UnrequestEventHook(AGSE_PRESCREENDRAW);
}
return 0;
}
void AGSFlashlight::syncGame(Serializer &s) {
uint32 SaveVersion = SaveMagic;
s.syncAsInt(SaveVersion);
if (s.isLoading() && SaveVersion != SaveMagic) {
// The real AGSFlashlight, or at least the one included with
// Maniac Mansion Deluxe, doesn't persist any fields.
// So in such a case, revert the 4 bytes and skip everything else
s.unreadInt();
} else {
s.syncAsInt(g_RedTint);
s.syncAsInt(g_GreenTint);
s.syncAsInt(g_BlueTint);
s.syncAsInt(g_DarknessLightLevel);
s.syncAsInt(g_BrightnessLightLevel);
s.syncAsInt(g_DarknessSize);
s.syncAsInt(g_DarknessDiameter);
s.syncAsInt(g_BrightnessSize);
s.syncAsInt(g_FlashlightX);
s.syncAsInt(g_FlashlightY);
s.syncAsInt(g_FlashlightFollowMouse);
s.syncAsInt(g_FollowCharacterId);
s.syncAsInt(g_FollowCharacterDx);
s.syncAsInt(g_FollowCharacterDy);
s.syncAsInt(g_FollowCharacterHorz);
s.syncAsInt(g_FollowCharacterVert);
if (s.isLoading()) {
if (g_FollowCharacterId != 0)
g_FollowCharacter = _engine->GetCharacter(g_FollowCharacterId);
g_BitmapMustBeUpdated = true;
}
}
}
void AGSFlashlight::SetFlashlightTint(ScriptMethodParams &params) {
PARAMS3(int, RedTint, int, GreenTint, int, BlueTint);
ClipToRange(RedTint, -31, 31);
ClipToRange(GreenTint, -31, 31);
ClipToRange(BlueTint, -31, 31);
if ((RedTint != g_RedTint) || (GreenTint != g_GreenTint) || (BlueTint != g_BlueTint))
g_BitmapMustBeUpdated = true;
g_RedTint = RedTint;
g_GreenTint = GreenTint;
g_BlueTint = BlueTint;
}
void AGSFlashlight::GetFlashlightTintRed(ScriptMethodParams &params) {
params._result = g_RedTint;
}
void AGSFlashlight::GetFlashlightTintGreen(ScriptMethodParams &params) {
params._result = g_GreenTint;
}
void AGSFlashlight::GetFlashlightTintBlue(ScriptMethodParams &params) {
params._result = g_BlueTint;
}
void AGSFlashlight::GetFlashlightMinLightLevel(ScriptMethodParams &params) {
params._result = 0;
}
void AGSFlashlight::GetFlashlightMaxLightLevel(ScriptMethodParams &params) {
params._result = 100;
}
void AGSFlashlight::SetFlashlightDarkness(ScriptMethodParams &params) {
PARAMS1(int, LightLevel);
ClipToRange(LightLevel, 0, 100);
if (LightLevel != g_DarknessLightLevel) {
g_BitmapMustBeUpdated = true;
g_DarknessLightLevel = LightLevel;
if (g_DarknessLightLevel > g_BrightnessLightLevel)
g_BrightnessLightLevel = g_DarknessLightLevel;
}
}
void AGSFlashlight::GetFlashlightDarkness(ScriptMethodParams &params) {
params._result = g_DarknessLightLevel;
}
void AGSFlashlight::SetFlashlightDarknessSize(ScriptMethodParams &params) {
PARAMS1(int, Size);
if (Size * g_ScaleFactor != g_DarknessSize) {
g_BitmapMustBeUpdated = true;
g_DarknessSize = Size * g_ScaleFactor;
g_DarknessDiameter = g_DarknessSize * 2;
if (g_BrightnessSize > g_DarknessSize) {
ScriptMethodParams p(g_DarknessSize / g_ScaleFactor);
SetFlashlightBrightnessSize(p);
}
}
}
void AGSFlashlight::GetFlashlightDarknessSize(ScriptMethodParams &params) {
params._result = (g_DarknessSize / g_ScaleFactor);
}
void AGSFlashlight::SetFlashlightBrightness(ScriptMethodParams &params) {
PARAMS1(int, LightLevel);
ClipToRange(LightLevel, 0, 100);
if (LightLevel != g_BrightnessLightLevel) {
g_BitmapMustBeUpdated = true;
g_BrightnessLightLevel = LightLevel;
if (g_BrightnessLightLevel < g_DarknessLightLevel)
g_DarknessLightLevel = g_BrightnessLightLevel;
}
}
void AGSFlashlight::GetFlashlightBrightness(ScriptMethodParams &params) {
params._result = g_BrightnessLightLevel;
}
void AGSFlashlight::SetFlashlightBrightnessSize(ScriptMethodParams &params) {
PARAMS1(int, Size);
if (Size * g_ScaleFactor != g_BrightnessSize) {
g_BitmapMustBeUpdated = true;
g_BrightnessSize = Size * g_ScaleFactor;
if (g_DarknessSize < g_BrightnessSize) {
ScriptMethodParams p(g_BrightnessSize / g_ScaleFactor);
SetFlashlightDarknessSize(p);
}
}
}
void AGSFlashlight::GetFlashlightBrightnessSize(ScriptMethodParams &params) {
params._result = g_BrightnessSize / g_ScaleFactor;
}
void AGSFlashlight::SetFlashlightPosition(ScriptMethodParams &params) {
PARAMS2(int, X, int, Y);
g_FlashlightX = X;
g_FlashlightY = Y;
}
void AGSFlashlight::GetFlashlightPositionX(ScriptMethodParams &params) {
params._result = g_FlashlightX;
}
void AGSFlashlight::GetFlashlightPositionY(ScriptMethodParams &params) {
params._result = g_FlashlightY;
}
void AGSFlashlight::SetFlashlightFollowMouse(ScriptMethodParams &params) {
PARAMS1(int, OnOff);
g_FlashlightFollowMouse = (OnOff != 0);
}
void AGSFlashlight::GetFlashlightFollowMouse(ScriptMethodParams &params) {
params._result = g_FlashlightFollowMouse ? 1 : 0;
}
void AGSFlashlight::SetFlashlightFollowCharacter(ScriptMethodParams &params) {
PARAMS5(int, CharacterId, int, dx, int, dy, int, horz, int, vert);
g_FollowCharacterId = CharacterId;
g_FollowCharacterDx = dx;
g_FollowCharacterDy = dy;
g_FollowCharacterHorz = horz;
g_FollowCharacterVert = vert;
g_FollowCharacter = _engine->GetCharacter(CharacterId);
}
void AGSFlashlight::GetFlashlightFollowCharacter(ScriptMethodParams &params) {
params._result = g_FollowCharacterId;
}
void AGSFlashlight::GetFlashlightCharacterDX(ScriptMethodParams &params) {
params._result = g_FollowCharacterDx;
}
void AGSFlashlight::GetFlashlightCharacterDY(ScriptMethodParams &params) {
params._result = g_FollowCharacterDy;
}
void AGSFlashlight::GetFlashlightCharacterHorz(ScriptMethodParams &params) {
params._result = g_FollowCharacterHorz;
}
void AGSFlashlight::GetFlashlightCharacterVert(ScriptMethodParams &params) {
params._result = g_FollowCharacterVert;
}
void AGSFlashlight::SetFlashlightMask(ScriptMethodParams &params) {
//PARAMS1(int, SpriteSlot);
// Not implemented.
}
void AGSFlashlight::GetFlashlightMask(ScriptMethodParams &params) {
params._result = 0;
}
} // namespace AGSFlashlight
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,127 @@
/* 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_AGSFLASHLIGHT_AGSFLASHLIGHT_H
#define AGS_PLUGINS_AGSFLASHLIGHT_AGSFLASHLIGHT_H
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/serializer.h"
#include "ags/lib/allegro.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFlashlight {
/**
* This is not the AGS Flashlight plugin,
* but a workalike plugin originally created for the AGS engine PSP port.
*/
class AGSFlashlight : public PluginBase {
SCRIPT_HASH(AGSFlashlight)
private:
int32 screen_width = 320;
int32 screen_height = 200;
int32 screen_color_depth = 16;
bool g_BitmapMustBeUpdated = true;
int g_RedTint = 0;
int g_GreenTint = 0;
int g_BlueTint = 0;
int g_DarknessLightLevel = 100;
int g_BrightnessLightLevel = 100;
int g_DarknessSize = 0;
int g_DarknessDiameter = 0;
int g_BrightnessSize = 0;
int g_ScaleFactor = 1;
int32 g_FlashlightX = 0;
int32 g_FlashlightY = 0;
int32 g_FlashlightDrawAtX = 0;
int32 g_FlashlightDrawAtY = 0;
bool g_FlashlightFollowMouse = false;
int g_FollowCharacterId = 0;
int g_FollowCharacterDx = 0;
int g_FollowCharacterDy = 0;
int g_FollowCharacterHorz = 0;
int g_FollowCharacterVert = 0;
AGSCharacter *g_FollowCharacter = nullptr;
BITMAP *g_LightBitmap = nullptr;
uint32 flashlight_x = 0, flashlight_n = 0;
private:
/**
* This function is from Allegro, split for more performance.
* Combines a 32 bit RGBA sprite with a 16 bit RGB destination, optimised
* for when one pixel is in an RGB layout and the other is BGR.
*/
inline uint32 _blender_alpha16_bgr(uint32 y);
inline void calc_x_n(uint32 x);
inline void setPixel(int x, int y, uint32 color, uint32 *pixel);
void plotCircle(int xm, int ym, int r, uint32 color);
void ClipToRange(int &variable, int min, int max);
void AlphaBlendBitmap();
void DrawTint();
void DrawDarkness();
void CreateLightBitmap();
void Update();
uint32 blendPixel(uint32 col, bool isAlpha24, int light);
void syncGame(Serializer &s);
void SetFlashlightTint(ScriptMethodParams &params);
void GetFlashlightTintRed(ScriptMethodParams &params);
void GetFlashlightTintGreen(ScriptMethodParams &params);
void GetFlashlightTintBlue(ScriptMethodParams &params);
void GetFlashlightMinLightLevel(ScriptMethodParams &params);
void GetFlashlightMaxLightLevel(ScriptMethodParams &params);
void SetFlashlightDarkness(ScriptMethodParams &params);
void GetFlashlightDarkness(ScriptMethodParams &params);
void SetFlashlightDarknessSize(ScriptMethodParams &params);
void GetFlashlightDarknessSize(ScriptMethodParams &params);
void SetFlashlightBrightness(ScriptMethodParams &params);
void GetFlashlightBrightness(ScriptMethodParams &params);
void SetFlashlightBrightnessSize(ScriptMethodParams &params);
void GetFlashlightBrightnessSize(ScriptMethodParams &params);
void SetFlashlightPosition(ScriptMethodParams &params);
void GetFlashlightPositionX(ScriptMethodParams &params);
void GetFlashlightPositionY(ScriptMethodParams &params);
void SetFlashlightFollowMouse(ScriptMethodParams &params);
void GetFlashlightFollowMouse(ScriptMethodParams &params);
void SetFlashlightFollowCharacter(ScriptMethodParams &params);
void GetFlashlightFollowCharacter(ScriptMethodParams &params);
void GetFlashlightCharacterDX(ScriptMethodParams &params);
void GetFlashlightCharacterDY(ScriptMethodParams &params);
void GetFlashlightCharacterHorz(ScriptMethodParams &params);
void GetFlashlightCharacterVert(ScriptMethodParams &params);
void SetFlashlightMask(ScriptMethodParams &params);
void GetFlashlightMask(ScriptMethodParams &params);
public:
AGSFlashlight() : PluginBase() {}
virtual ~AGSFlashlight() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
int AGS_PluginV2() const override { return 1; };
};
} // namespace AGSFlashlight
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,373 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_flashlight/ags_flashlight.h"
namespace AGS3 {
namespace Plugins {
namespace AGSFlashlight {
void AGSFlashlight::calc_x_n(uint32 _x) {
flashlight_x = _x;
flashlight_n = flashlight_x >> 24;
if (flashlight_n)
flashlight_n = (flashlight_n + 1) / 8;
flashlight_x = ((flashlight_x >> 19) & 0x001F) | ((flashlight_x >> 5) & 0x07E0) | ((flashlight_x << 8) & 0xF800);
flashlight_x = (flashlight_x | (flashlight_x << 16)) & 0x7E0F81F;
}
uint32 AGSFlashlight::_blender_alpha16_bgr(uint32 y) {
uint32 result;
y = ((y & 0xFFFF) | (y << 16)) & 0x7E0F81F;
result = ((flashlight_x - y) * flashlight_n / 32 + y) & 0x7E0F81F;
return ((result & 0xFFFF) | (result >> 16));
}
void AGSFlashlight::setPixel(int x, int y, uint32 color, uint32 *pixel) {
if ((x >= g_DarknessDiameter) || (y >= g_DarknessDiameter) || (x < 0) || (y < 0))
return;
*(pixel + (y * g_DarknessDiameter) + x) = color;
}
void AGSFlashlight::plotCircle(int xm, int ym, int r, uint32 color) {
uint32 *pixel = (uint32 *)_engine->GetRawBitmapSurface(g_LightBitmap);
int x = -r;
int y = 0;
int err = 2 - 2 * r;
do {
setPixel(xm - x, ym + y, color, pixel); // I. Quadrant
setPixel(xm - x - 1, ym + y, color, pixel);
setPixel(xm - y, ym - x, color, pixel); // II. Quadrant
setPixel(xm - y, ym - x - 1, color, pixel);
setPixel(xm + x, ym - y, color, pixel); // III. Quadrant
setPixel(xm + x + 1, ym - y, color, pixel);
setPixel(xm + y, ym + x, color, pixel); // IV. Quadrant
setPixel(xm + y, ym + x + 1, color, pixel);
r = err;
if (r > x)
err += ++x * 2 + 1;
if (r <= y)
err += ++y * 2 + 1;
} while (x < 0);
_engine->ReleaseBitmapSurface(g_LightBitmap);
}
void AGSFlashlight::ClipToRange(int &variable, int min, int max) {
if (variable < min)
variable = min;
if (variable > max)
variable = max;
}
void AGSFlashlight::AlphaBlendBitmap() {
uint16 *destpixel = (uint16 *)_engine->GetRawBitmapSurface(_engine->GetVirtualScreen());
uint32 *sourcepixel = (uint32 *)_engine->GetRawBitmapSurface(g_LightBitmap);
uint16 *currentdestpixel = destpixel;
uint32 *currentsourcepixel = sourcepixel;
int x, y;
int targetX = (g_FlashlightDrawAtX > -1) ? g_FlashlightDrawAtX : 0;
int targetY = (g_FlashlightDrawAtY > -1) ? g_FlashlightDrawAtY : 0;
int startX = (g_FlashlightDrawAtX < 0) ? -1 * g_FlashlightDrawAtX : 0;
int endX = (g_FlashlightDrawAtX + g_DarknessDiameter < screen_width) ? g_DarknessDiameter : g_DarknessDiameter - ((g_FlashlightDrawAtX + g_DarknessDiameter) - screen_width);
int startY = (g_FlashlightDrawAtY < 0) ? -1 * g_FlashlightDrawAtY : 0;
int endY = (g_FlashlightDrawAtY + g_DarknessDiameter < screen_height) ? g_DarknessDiameter : g_DarknessDiameter - ((g_FlashlightDrawAtY + g_DarknessDiameter) - screen_height);
for (y = 0; y < endY - startY; y++) {
currentdestpixel = destpixel + (y + targetY) * screen_width + targetX;
currentsourcepixel = sourcepixel + (y + startY) * g_DarknessDiameter + startX;
for (x = 0; x < endX - startX; x++) {
calc_x_n(*currentsourcepixel);
*currentdestpixel = (uint16)_blender_alpha16_bgr(*currentdestpixel);
currentdestpixel++;
currentsourcepixel++;
}
}
_engine->ReleaseBitmapSurface(_engine->GetVirtualScreen());
_engine->ReleaseBitmapSurface(g_LightBitmap);
}
void AGSFlashlight::DrawTint() {
int x, y;
BITMAP *screen = _engine->GetVirtualScreen();
uint16 *destpixel = (uint16 *)_engine->GetRawBitmapSurface(screen);
int32 red, blue, green, alpha;
for (y = 0; y < screen_height; y++) {
for (x = 0; x < screen_width; x++) {
_engine->GetRawColorComponents(16, *destpixel, &red, &green, &blue, &alpha);
if (g_RedTint != 0) {
red += g_RedTint * 8;
if (red > 255)
red = 255;
else if (red < 0)
red = 0;
}
if (g_BlueTint != 0) {
blue += g_BlueTint * 8;
if (blue > 255)
blue = 255;
else if (blue < 0)
blue = 0;
}
if (g_GreenTint != 0) {
green += g_GreenTint * 8;
if (green > 255)
green = 255;
else if (green < 0)
green = 0;
}
*destpixel = _engine->MakeRawColorPixel(16, red, green, blue, alpha);
destpixel++;
}
}
_engine->ReleaseBitmapSurface(screen);
}
void AGSFlashlight::DrawDarkness() {
int x, y;
uint32 color = (255 - (int)((float)g_DarknessLightLevel * 2.55f)) << 24;
BITMAP *screen = _engine->GetVirtualScreen();
assert(screen->format.bytesPerPixel == 2);
uint16 *destpixel = (uint16 *)_engine->GetRawBitmapSurface(screen);
uint16 *currentpixel;
calc_x_n(color);
if (g_DarknessSize == 0) {
// Whole screen.
for (x = 0; x < screen_width * screen_height; x++) {
*destpixel = (uint16)_blender_alpha16_bgr(*destpixel);
destpixel++;
}
} else {
// Top.
if (g_FlashlightDrawAtY > -1) {
currentpixel = destpixel;
for (y = 0; y < g_FlashlightDrawAtY; y++) {
for (x = 0; x < screen_width; x++) {
*currentpixel = (uint16)_blender_alpha16_bgr(*currentpixel);
currentpixel++;
}
}
}
// Bottom.
if (g_FlashlightDrawAtY + g_DarknessDiameter < screen_height) {
currentpixel = destpixel + (g_FlashlightDrawAtY + g_DarknessDiameter) * screen_width;
for (y = g_FlashlightDrawAtY + g_DarknessDiameter; y < screen_height; y++) {
for (x = 0; x < screen_width; x++) {
*currentpixel = (uint16)_blender_alpha16_bgr(*currentpixel);
currentpixel++;
}
}
}
// Left.
if (g_FlashlightDrawAtX > 0) {
currentpixel = destpixel;
int startpoint = (g_FlashlightDrawAtY > 0) ? g_FlashlightDrawAtY : 0;
int endpoint = (g_FlashlightDrawAtY + g_DarknessDiameter >= screen_height) ? screen_height + 1 : g_FlashlightDrawAtY + g_DarknessDiameter + 1;
for (y = startpoint; y < endpoint; y++) {
for (x = 0; x < g_FlashlightDrawAtX; x++) {
*currentpixel = (uint16)_blender_alpha16_bgr(*currentpixel);
currentpixel++;
}
currentpixel = destpixel + screen_width * y;
}
}
// Right.
if (g_FlashlightDrawAtX + g_DarknessDiameter < screen_width) {
currentpixel = destpixel + (g_FlashlightDrawAtX + g_DarknessDiameter);
int startpoint = (g_FlashlightDrawAtY > 0) ? g_FlashlightDrawAtY : 0;
int endpoint = (g_FlashlightDrawAtY + g_DarknessDiameter >= screen_height) ? screen_height + 1 : g_FlashlightDrawAtY + g_DarknessDiameter + 1;
for (y = startpoint; y < endpoint; y++) {
for (x = g_FlashlightDrawAtX + g_DarknessDiameter; x < screen_width; x++) {
*currentpixel = (uint16)_blender_alpha16_bgr(*currentpixel);
currentpixel++;
}
currentpixel = destpixel + screen_width * y + (g_FlashlightDrawAtX + g_DarknessDiameter);
}
}
}
_engine->ReleaseBitmapSurface(screen);
}
void AGSFlashlight::CreateLightBitmap() {
if (g_DarknessSize == 0)
return;
if (g_LightBitmap)
_engine->FreeBitmap(g_LightBitmap);
g_LightBitmap = _engine->CreateBlankBitmap(g_DarknessDiameter, g_DarknessDiameter, 32);
// Fill with darkness color.
uint32 color = (255 - (int)((float)g_DarknessLightLevel * 2.55f)) << 24;
uint32 *pixel = (uint32 *)_engine->GetRawBitmapSurface(g_LightBitmap);
int i;
for (i = 0; i < g_DarknessDiameter * g_DarknessDiameter; i++)
*pixel++ = (uint32)color;
// Draw light circle if wanted.
if (g_DarknessSize > 0 && g_DarknessLightLevel != g_BrightnessLightLevel) {
uint32 current_value = 0;
color = (255 - (int)((float)g_BrightnessLightLevel * 2.55f));
uint32 targetcolor = ((255 - (int)((float)g_DarknessLightLevel * 2.55f)));
int increment = (targetcolor - color) / (g_DarknessSize - g_BrightnessSize);
float perfect_increment = (float)(targetcolor - color) / (float)(g_DarknessSize - g_BrightnessSize);
float error_term;
for (i = g_BrightnessSize; i < g_DarknessSize; i++) {
error_term = (perfect_increment * (i - g_BrightnessSize)) - current_value;
if (error_term >= 1.0f)
increment++;
else if (error_term <= -1.0f)
increment--;
current_value += increment;
if (current_value > targetcolor)
current_value = targetcolor;
plotCircle(g_DarknessSize, g_DarknessSize, i, (current_value << 24) + color);
}
}
// Draw inner fully lit circle.
if (g_BrightnessSize > 0) {
color = (255 - (int)((float)g_BrightnessLightLevel * 2.55f)) << 24;
for (i = 0; i < g_BrightnessSize; i++)
plotCircle(g_DarknessSize, g_DarknessSize, i, color);
}
_engine->ReleaseBitmapSurface(g_LightBitmap);
}
void AGSFlashlight::Update() {
if (g_BitmapMustBeUpdated) {
CreateLightBitmap();
g_BitmapMustBeUpdated = false;
}
if (g_FlashlightFollowMouse) {
_engine->GetMousePosition(&g_FlashlightX, &g_FlashlightY);
} else if (g_FollowCharacter != nullptr) {
g_FlashlightX = g_FollowCharacter->x + g_FollowCharacterDx;
g_FlashlightY = g_FollowCharacter->y + g_FollowCharacterDy;
if ((g_FollowCharacterHorz != 0) || (g_FollowCharacterVert != 0)) {
switch (g_FollowCharacter->loop) {
// Down
case 0:
case 4:
case 6:
g_FlashlightY += g_FollowCharacterVert;
break;
// Up
case 3:
case 5:
case 7:
g_FlashlightY -= g_FollowCharacterVert;
break;
// Left
case 1:
g_FlashlightX -= g_FollowCharacterHorz;
break;
// Right:
case 2:
g_FlashlightX += g_FollowCharacterHorz;
break;
}
}
}
g_FlashlightDrawAtX = g_FlashlightX - g_DarknessSize;
g_FlashlightDrawAtY = g_FlashlightY - g_DarknessSize;
if ((g_GreenTint != 0) || (g_RedTint != 0) || (g_BlueTint != 0))
DrawTint();
if (g_DarknessSize > 0)
AlphaBlendBitmap();
if (g_DarknessLightLevel != 100)
DrawDarkness();
_engine->MarkRegionDirty(0, 0, screen_width, screen_height);
}
} // namespace AGSFlashlight
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,251 @@
/* 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
* (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/>.
*
*/
#include "ags/metaengine.h"
#include "ags/ags.h"
#include "ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h"
#include "common/config-manager.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
struct SteamData : public IAGSScriptManagedObject {
public:
Common::String steamLanguage = "english";
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "SteamData";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
void AGS2Client::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(AGS2Client::IsAchievementAchieved^1, AGS2Client::IsAchievementAchieved);
SCRIPT_METHOD(AGS2Client::SetAchievementAchieved^1, AGS2Client::SetAchievementAchieved);
SCRIPT_METHOD(AGS2Client::ResetAchievement^1, AGS2Client::ResetAchievement);
SCRIPT_METHOD(AGS2Client::GetIntStat^1, AGS2Client::GetIntStat);
SCRIPT_METHOD(AGS2Client::GetFloatStat^1, AGS2Client::GetFloatStat);
SCRIPT_METHOD(AGS2Client::GetAverageRateStat^1, AGS2Client::GetAverageRateStat);
SCRIPT_METHOD(AGS2Client::SetIntStat^2, AGS2Client::SetIntStat);
SCRIPT_METHOD(AGS2Client::SetFloatStat^2, AGS2Client::SetFloatStat);
SCRIPT_METHOD(AGS2Client::UpdateAverageRateStat^3, AGS2Client::UpdateAverageRateStat);
SCRIPT_METHOD(AGS2Client::ResetStatsAndAchievements^0, AGS2Client::ResetStatsAndAchievements);
SCRIPT_METHOD(AGS2Client::get_Initialized, AGS2Client::get_Initialized);
SCRIPT_METHOD(AGS2Client::get_CurrentLeaderboardName, AGS2Client::get_CurrentLeaderboardName);
SCRIPT_METHOD(AGS2Client::RequestLeaderboard^3, AGS2Client::RequestLeaderboard);
SCRIPT_METHOD(AGS2Client::UploadScore^1, AGS2Client::UploadScore);
SCRIPT_METHOD(AGS2Client::geti_LeaderboardNames, AGS2Client::geti_LeaderboardNames);
SCRIPT_METHOD(AGS2Client::geti_LeaderboardScores, AGS2Client::geti_LeaderboardScores);
SCRIPT_METHOD(AGS2Client::get_LeaderboardCount, AGS2Client::get_LeaderboardCount);
SCRIPT_METHOD(AGS2Client::GetUserName^0, AGS2Client::GetUserName);
SCRIPT_METHOD(AGS2Client::GetCurrentGameLanguage^0, AGS2Client::GetCurrentGameLanguage);
SCRIPT_METHOD(AGS2Client::FindLeaderboard^1, AGS2Client::FindLeaderboard);
SCRIPT_METHOD(AGS2Client::Initialize^2, AGS2Client::Initialize);
Common::String gameTarget = ConfMan.getActiveDomainName();
const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
AchMan.setActiveDomain(meta->getAchievementsInfo(gameTarget));
}
void AGS2Client::IsAchievementAchieved(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = AchMan.isAchieved(id);
}
void AGS2Client::SetAchievementAchieved(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = AchMan.setAchievement(id);
}
void AGS2Client::ResetAchievement(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = AchMan.clearAchievement(id);
}
void AGS2Client::GetIntStat(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = AchMan.getStatInt(id);
}
void AGS2Client::GetFloatStat(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = PARAM_FROM_FLOAT(AchMan.getStatFloat(id));
}
void AGS2Client::GetAverageRateStat(ScriptMethodParams &params) {
PARAMS1(char *, id);
params._result = PARAM_FROM_FLOAT(AchMan.getAverageRateStatFloat(id));
}
void AGS2Client::SetIntStat(ScriptMethodParams &params) {
PARAMS2(char *, id, int, value);
params._result = AchMan.setStatInt(id, value);
}
void AGS2Client::SetFloatStat(ScriptMethodParams &params) {
PARAMS2(char *, id, int32, value);
params._result = AchMan.setStatFloat(id, PARAM_TO_FLOAT(value));
}
void AGS2Client::UpdateAverageRateStat(ScriptMethodParams &params) {
PARAMS3(char *, id, int32, count, int32, times);
params._result = AchMan.updateAverageRateStatFloat(id, PARAM_TO_FLOAT(count), PARAM_TO_FLOAT(times));
}
void AGS2Client::ResetStatsAndAchievements(ScriptMethodParams &params) {
AchMan.resetAllAchievements();
AchMan.resetAllStats();
}
void AGS2Client::get_Initialized(ScriptMethodParams &params) {
params._result = AchMan.isReady();
}
void AGS2Client::get_CurrentLeaderboardName(ScriptMethodParams &params) {
warning("AGS2Client::get_CurrentLeaderboardName() is not implemented");
params._result = 0;
}
void AGS2Client::RequestLeaderboard(ScriptMethodParams &params) {
warning("AGS2Client::RequestLeaderboard() is not implemented");
params._result = 0;
}
void AGS2Client::UploadScore(ScriptMethodParams &params) {
warning("AGS2Client::UploadScore() is not implemented");
params._result = 0;
}
void AGS2Client::geti_LeaderboardNames(ScriptMethodParams &params) {
warning("AGS2Client::geti_LeaderboardNames() is not implemented");
params._result = 0;
}
void AGS2Client::geti_LeaderboardScores(ScriptMethodParams &params) {
warning("AGS2Client::geti_LeaderboardScores() is not implemented");
params._result = 0;
}
void AGS2Client::get_LeaderboardCount(ScriptMethodParams &params) {
warning("AGS2Client::get_LeaderboardCount() is not implemented");
params._result = 0;
}
void AGS2Client::GetUserName(ScriptMethodParams &params) {
warning("AGS2Client::GetUserName() is not implemented - Returning \'Player\'");
params._result = _engine->CreateScriptString("Player");
}
void AGS2Client::GetCurrentGameLanguage(ScriptMethodParams &params) {
SteamData *steam_data = new SteamData();
_engine->RegisterManagedObject(steam_data, steam_data);
warning("AGS2Client::GetCurrentGameLanguage() is not implemented - Returning \'%s\'", steam_data->steamLanguage.c_str());
params._result = steam_data->steamLanguage.c_str();
}
void AGS2Client::FindLeaderboard(ScriptMethodParams &params) {
warning("AGS2Client::FindLeaderboard() is not implemented");
params._result = 0;
}
void AGS2Client::Initialize(ScriptMethodParams &params) {
PARAMS2(char *, clientId, char *, clientSecret);
AchMan.setSpecialString("clientId", clientId);
AchMan.setSpecialString("clientSecret", clientSecret);
params._result = 0;
}
/*------------------------------------------------------------------*/
const char *AGSGalaxy::AGS_GetPluginName() {
return "AGSGalaxy";
}
void AGSGalaxy::AGS_EngineStartup(IAGSEngine *engine) {
AGS2Client::AGS_EngineStartup(engine);
SCRIPT_METHOD(AGSGalaxy::IsAchievementAchieved^1, AGSGalaxy::IsAchievementAchieved);
SCRIPT_METHOD(AGSGalaxy::SetAchievementAchieved^1, AGSGalaxy::SetAchievementAchieved);
SCRIPT_METHOD(AGSGalaxy::ResetAchievement^1, AGSGalaxy::ResetAchievement);
SCRIPT_METHOD(AGSGalaxy::GetIntStat^1, AGSGalaxy::GetIntStat);
SCRIPT_METHOD(AGSGalaxy::GetFloatStat^1, AGSGalaxy::GetFloatStat);
SCRIPT_METHOD(AGSGalaxy::GetAverageRateStat^1, AGSGalaxy::GetAverageRateStat);
SCRIPT_METHOD(AGSGalaxy::SetIntStat^2, AGSGalaxy::SetIntStat);
SCRIPT_METHOD(AGSGalaxy::SetFloatStat^2, AGSGalaxy::SetFloatStat);
SCRIPT_METHOD(AGSGalaxy::UpdateAverageRateStat^3, AGSGalaxy::UpdateAverageRateStat);
SCRIPT_METHOD(AGSGalaxy::ResetStatsAndAchievements^0, AGSGalaxy::ResetStatsAndAchievements);
SCRIPT_METHOD(AGSGalaxy::get_Initialized, AGSGalaxy::get_Initialized);
SCRIPT_METHOD(AGSGalaxy::get_CurrentLeaderboardName, AGSGalaxy::get_CurrentLeaderboardName);
SCRIPT_METHOD(AGSGalaxy::RequestLeaderboard^3, AGSGalaxy::RequestLeaderboard);
SCRIPT_METHOD(AGSGalaxy::UploadScore^1, AGSGalaxy::UploadScore);
SCRIPT_METHOD(AGSGalaxy::geti_LeaderboardNames, AGSGalaxy::geti_LeaderboardNames);
SCRIPT_METHOD(AGSGalaxy::geti_LeaderboardScores, AGSGalaxy::geti_LeaderboardScores);
SCRIPT_METHOD(AGSGalaxy::get_LeaderboardCount, AGSGalaxy::get_LeaderboardCount);
SCRIPT_METHOD(AGSGalaxy::GetUserName^0, AGSGalaxy::GetUserName);
SCRIPT_METHOD(AGSGalaxy::GetCurrentGameLanguage^0, AGSGalaxy::GetCurrentGameLanguage);
SCRIPT_METHOD(AGSGalaxy::Initialize^2, AGSGalaxy::Initialize);
}
/*------------------------------------------------------------------*/
const char *AGSSteam::AGS_GetPluginName() {
return "AGSSteam";
}
void AGSSteam::AGS_EngineStartup(IAGSEngine *engine) {
AGS2Client::AGS_EngineStartup(engine);
SCRIPT_METHOD(AGSteam::IsAchievementAchieved^1, AGSSteam::IsAchievementAchieved);
SCRIPT_METHOD(AGSteam::SetAchievementAchieved^1, AGSSteam::SetAchievementAchieved);
SCRIPT_METHOD(AGSteam::ResetAchievement^1, AGSSteam::ResetAchievement);
SCRIPT_METHOD(AGSteam::GetIntStat^1, AGSSteam::GetIntStat);
SCRIPT_METHOD(AGSteam::GetFloatStat^1, AGSSteam::GetFloatStat);
SCRIPT_METHOD(AGSteam::GetAverageRateStat^1, AGSSteam::GetAverageRateStat);
SCRIPT_METHOD(AGSteam::SetIntStat^2, AGSSteam::SetIntStat);
SCRIPT_METHOD(AGSteam::SetFloatStat^2, AGSSteam::SetFloatStat);
SCRIPT_METHOD(AGSteam::UpdateAverageRateStat^3, AGSSteam::UpdateAverageRateStat);
SCRIPT_METHOD(AGSteam::ResetStatsAndAchievements^0, AGSSteam::ResetStatsAndAchievements);
SCRIPT_METHOD(AGSteam::get_Initialized, AGSSteam::get_Initialized);
SCRIPT_METHOD(AGSteam::get_CurrentLeaderboardName, AGSSteam::get_CurrentLeaderboardName);
SCRIPT_METHOD(AGSteam::RequestLeaderboard^3, AGSSteam::RequestLeaderboard);
SCRIPT_METHOD(AGSteam::UploadScore^1, AGSSteam::UploadScore);
SCRIPT_METHOD(AGSteam::geti_LeaderboardNames, AGSSteam::geti_LeaderboardNames);
SCRIPT_METHOD(AGSteam::geti_LeaderboardScores, AGSSteam::geti_LeaderboardScores);
SCRIPT_METHOD(AGSteam::get_LeaderboardCount, AGSSteam::get_LeaderboardCount);
SCRIPT_METHOD(AGSteam::GetUserName^0, AGSSteam::GetUserName);
SCRIPT_METHOD(AGSteam::GetCurrentGameLanguage^0, AGSSteam::GetCurrentGameLanguage);
SCRIPT_METHOD(AGSteam::FindLeaderboard^1, AGSSteam::FindLeaderboard);
}
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,91 @@
/* 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_GALAXY_STEAM_AGS_GALAXY_STEAM_H
#define AGS_PLUGINS_AGS_GALAXY_STEAM_AGS_GALAXY_STEAM_H
#include "ags/plugins/ags_plugin.h"
#include "common/array.h"
#include "common/rect.h"
#include "common/str.h"
#include "engines/achievements.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
class AGS2Client : public PluginBase {
SCRIPT_HASH(AGS2Client)
protected:
void IsAchievementAchieved(ScriptMethodParams &params);
void SetAchievementAchieved(ScriptMethodParams &params);
void ResetAchievement(ScriptMethodParams &params);
void GetIntStat(ScriptMethodParams &params);
void GetFloatStat(ScriptMethodParams &params);
void GetAverageRateStat(ScriptMethodParams &params);
void SetIntStat(ScriptMethodParams &params);
void SetFloatStat(ScriptMethodParams &params);
void UpdateAverageRateStat(ScriptMethodParams &params);
void ResetStatsAndAchievements(ScriptMethodParams &params);
void get_Initialized(ScriptMethodParams &params);
void get_CurrentLeaderboardName(ScriptMethodParams &params);
void RequestLeaderboard(ScriptMethodParams &params);
void UploadScore(ScriptMethodParams &params);
void geti_LeaderboardNames(ScriptMethodParams &params);
void geti_LeaderboardScores(ScriptMethodParams &params);
void get_LeaderboardCount(ScriptMethodParams &params);
void GetUserName(ScriptMethodParams &params);
void GetCurrentGameLanguage(ScriptMethodParams &params);
void FindLeaderboard(ScriptMethodParams &params);
void Initialize(ScriptMethodParams &params);
public:
AGS2Client() : PluginBase() {}
virtual ~AGS2Client() {}
void AGS_EngineStartup(IAGSEngine *engine) override;
};
class AGSGalaxy : public AGS2Client {
SCRIPT_HASH_SUB(AGSGalaxy, AGS2Client)
public:
AGSGalaxy() : AGS2Client() {}
virtual ~AGSGalaxy() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
class AGSSteam : public AGS2Client {
SCRIPT_HASH_SUB(AGSSteam, AGS2Client)
public:
AGSSteam() : AGS2Client() {}
virtual ~AGSSteam() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,68 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_galaxy_steam/ags_wadjeteye_steam.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
void AGSWadjetEyeSteam::AddAchievement(ScriptMethodParams &params) {
warning("AGSWadjetEyeSteam::AddAchievement() is not implemented");
params._result = 0;
}
void AGSWadjetEyeSteam::AddStat(ScriptMethodParams &params) {
warning("AGSWadjetEyeSteam::AddStat() is not implemented");
params._result = 0;
}
void AGSWadjetEyeSteam::AGS_EngineStartup(IAGSEngine *engine) {
AGSSteam::AGS_EngineStartup(engine);
SCRIPT_METHOD(Steam::AddAchievement^1, AGSWadjetEyeSteam::AddAchievement);
SCRIPT_METHOD(Steam::AddStat^2, AGSWadjetEyeSteam::AddStat);
SCRIPT_METHOD(Steam::IsAchievementAchieved^1, AGSWadjetEyeSteam::IsAchievementAchieved);
SCRIPT_METHOD(Steam::SetAchievementAchieved^1, AGSWadjetEyeSteam::SetAchievementAchieved);
SCRIPT_METHOD(Steam::ResetAchievement^1, AGSWadjetEyeSteam::ResetAchievement);
SCRIPT_METHOD(Steam::GetIntStat^1, AGSWadjetEyeSteam::GetIntStat);
SCRIPT_METHOD(Steam::GetFloatStat^1, AGSWadjetEyeSteam::GetFloatStat);
SCRIPT_METHOD(Steam::GetAverageRateStat^1, AGSWadjetEyeSteam::GetAverageRateStat);
SCRIPT_METHOD(Steam::SetIntStat^2, AGSWadjetEyeSteam::SetIntStat);
SCRIPT_METHOD(Steam::SetFloatStat^2, AGSWadjetEyeSteam::SetFloatStat);
SCRIPT_METHOD(Steam::UpdateAverageRateStat^3, AGSWadjetEyeSteam::UpdateAverageRateStat);
SCRIPT_METHOD(Steam::ResetStatsAndAchievements^0, AGSWadjetEyeSteam::ResetStatsAndAchievements);
SCRIPT_METHOD(Steam::get_Initialized, AGSWadjetEyeSteam::get_Initialized);
SCRIPT_METHOD(Steam::get_CurrentLeaderboardName, AGSWadjetEyeSteam::get_CurrentLeaderboardName);
SCRIPT_METHOD(Steam::RequestLeaderboard^3, AGSWadjetEyeSteam::RequestLeaderboard);
SCRIPT_METHOD(Steam::UploadScore^1, AGSWadjetEyeSteam::UploadScore);
SCRIPT_METHOD(Steam::geti_LeaderboardNames, AGSWadjetEyeSteam::geti_LeaderboardNames);
SCRIPT_METHOD(Steam::geti_LeaderboardScores, AGSWadjetEyeSteam::geti_LeaderboardScores);
SCRIPT_METHOD(Steam::get_LeaderboardCount, AGSWadjetEyeSteam::get_LeaderboardCount);
SCRIPT_METHOD(Steam::GetUserName^0, AGSWadjetEyeSteam::GetUserName);
SCRIPT_METHOD(Steam::GetCurrentGameLanguage^0, AGSWadjetEyeSteam::GetCurrentGameLanguage);
SCRIPT_METHOD(Steam::FindLeaderboard^1, AGSWadjetEyeSteam::FindLeaderboard);
SCRIPT_METHOD(Steam::Initialize^2, AGSWadjetEyeSteam::Initialize);
}
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_GALAXY_STEAM_AGS_BLACKWELL_STEAM_H
#define AGS_PLUGINS_AGS_GALAXY_STEAM_AGS_BLACKWELL_STEAM_H
#include "ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h"
namespace AGS3 {
namespace Plugins {
namespace AGSGalaxySteam {
class AGSWadjetEyeSteam : public AGSSteam {
SCRIPT_HASH_SUB(AGSWadjetEyeSteam, AGSSteam)
private:
void AddAchievement(ScriptMethodParams &params);
void AddStat(ScriptMethodParams &params);
public:
AGSWadjetEyeSteam() : AGSSteam() {}
virtual ~AGSWadjetEyeSteam() {}
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSGalaxySteam
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,119 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_joy/ags_joy.h"
#include "ags/shared/core/platform.h"
namespace AGS3 {
namespace Plugins {
namespace AGSJoy {
const char *AGSJoy::AGS_GetPluginName() {
return "AGSJoy";
}
void AGSJoy::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
// Register functions
SCRIPT_METHOD(JoystickCount, AGSJoy::Count);
SCRIPT_METHOD(JoystickName, AGSJoy::Name);
SCRIPT_METHOD(JoystickRescan, AGSJoy::Rescan);
SCRIPT_METHOD(Joystick::Open, AGSJoy::Open);
SCRIPT_METHOD(Joystick::IsOpen, AGSJoy::IsOpen);
SCRIPT_METHOD(Joystick::Click, AGSJoy::Click);
SCRIPT_METHOD(Joystick::Close, AGSJoy::Close);
SCRIPT_METHOD(Joystick::Valid, AGSJoy::Valid);
SCRIPT_METHOD(Joystick::Unplugged, AGSJoy::Unplugged);
SCRIPT_METHOD(Joystick::GetName, AGSJoy::GetName);
SCRIPT_METHOD(Joystick::GetAxis, AGSJoy::GetAxis);
SCRIPT_METHOD(Joystick::IsButtonDown, AGSJoy::IsButtonDown);
SCRIPT_METHOD(Joystick::IsJoyBtnDown, AGSJoy::IsJoyBtnDown);
SCRIPT_METHOD(Joystick::Update, AGSJoy::Update);
SCRIPT_METHOD(Joystick::DisableEvents, AGSJoy::DisableEvents);
SCRIPT_METHOD(Joystick::EnableEvents, AGSJoy::EnableEvents);
}
void AGSJoy::Count(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Name(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Rescan(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Open(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::IsOpen(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Click(ScriptMethodParams &params) {
PARAMS1(int, button);
PluginSimulateMouseClick(button);
}
void AGSJoy::Close(ScriptMethodParams &params) {
}
void AGSJoy::Valid(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Unplugged(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::GetName(ScriptMethodParams &params) {
params._result = NumberPtr();
}
void AGSJoy::GetAxis(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::IsButtonDown(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::IsJoyBtnDown(ScriptMethodParams &params) {
params._result = 0;
}
void AGSJoy::Update(ScriptMethodParams &params) {
}
void AGSJoy::DisableEvents(ScriptMethodParams &params) {
}
void AGSJoy::EnableEvents(ScriptMethodParams &params) {
}
} // namespace AGSJoy
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,63 @@
/* 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_JOY_AGS_JOY_H
#define AGS_PLUGINS_AGS_JOY_AGS_JOY_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSJoy {
class AGSJoy : public PluginBase {
SCRIPT_HASH(AGSJoy)
private:
void Count(ScriptMethodParams &params);
void Name(ScriptMethodParams &params);
void Rescan(ScriptMethodParams &params);
void Open(ScriptMethodParams &params);
void IsOpen(ScriptMethodParams &params);
void Click(ScriptMethodParams &params);
void Close(ScriptMethodParams &params);
void Valid(ScriptMethodParams &params);
void Unplugged(ScriptMethodParams &params);
void GetName(ScriptMethodParams &params);
void GetAxis(ScriptMethodParams &params);
void IsButtonDown(ScriptMethodParams &params);
void IsJoyBtnDown(ScriptMethodParams &params);
void Update(ScriptMethodParams &params);
void DisableEvents(ScriptMethodParams &params);
void EnableEvents(ScriptMethodParams &params);
public:
AGSJoy() : PluginBase() {}
virtual ~AGSJoy() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
};
} // namespace AGSJoy
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,103 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_maya/ags_maya.h"
#include "ags/engine/ac/math.h"
namespace AGS3 {
namespace Plugins {
namespace AGSMaya {
const char *AGSMaya::AGS_GetPluginName() {
return "AGS Maya";
}
void AGSMaya::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(sin, AGSMaya::Sin);
SCRIPT_METHOD(cos, AGSMaya::Cos);
SCRIPT_METHOD(fmul, AGSMaya::FMul);
SCRIPT_METHOD(fdiv, AGSMaya::FDiv);
SCRIPT_METHOD(int_to_float, AGSMaya::intToFloat);
SCRIPT_METHOD(ints_to_float, AGSMaya::intsToFloat);
SCRIPT_METHOD(float_to_int, AGSMaya::floatToInt);
}
void AGSMaya::Sin(ScriptMethodParams &params) {
PARAMS1(int, angle);
params._result = 1000 * Math_Sin(angle * 0.001f);
}
void AGSMaya::Cos(ScriptMethodParams &params) {
PARAMS1(int, angle);
params._result = 1000 * Math_Cos(angle * 0.001f);
}
void AGSMaya::FMul(ScriptMethodParams &params) {
PARAMS2(int, value1, int, value2);
int calculation = (value1 / 1000) * (value2 / 1000);
calculation *= 1000;
calculation += (((value1 % 1000) * (value2 % 1000)) / 1000);
params._result = calculation;
}
void AGSMaya::FDiv(ScriptMethodParams &params) {
PARAMS2(int, value1, int, value2);
if (value2) {
double division, decimals;
division = value1 / (double)value2;
modf(division, &decimals);
params._result = floor(division) * 1000 + decimals * 1000;
} else {
params._result = 0;
warning("AGSMaya::FDiv divide by zero!");
}
}
void AGSMaya::intToFloat(ScriptMethodParams &params) {
PARAMS1(int, value);
params._result = value * 1000;
}
void AGSMaya::floatToInt(ScriptMethodParams &params) {
PARAMS1(int, value);
if (value % 1000 > 500)
params._result = (value + 1000) / 1000; // round up
else
params._result = value / 1000;
}
void AGSMaya::intsToFloat(ScriptMethodParams &params) {
PARAMS2(int, units, int, thousandths);
params._result = units * 1000 + thousandths;
}
} // namespace AGSMaya
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,58 @@
/* 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_MAYA_H
#define AGS_PLUGINS_AGS_MAYA_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSMaya {
class AGSMaya : public PluginBase {
SCRIPT_HASH(AGSMaya)
private:
// Trig functions use radians
void Sin(ScriptMethodParams &params);
void Cos(ScriptMethodParams &params);
void FMul(ScriptMethodParams &params);
void FDiv(ScriptMethodParams &params);
void intToFloat(ScriptMethodParams &params);
void intsToFloat(ScriptMethodParams &params);
void floatToInt(ScriptMethodParams &params);
public:
AGSMaya() : PluginBase() {}
virtual ~AGSMaya() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSMaya
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,515 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_nickenstien_gfx/ags_nickenstien_gfx.h"
namespace AGS3 {
namespace Plugins {
namespace AGSNickenstienGFX {
const char *AGSNickenstienGFX::AGS_GetPluginName() {
return "Nickenstien\'s NGFX Graphics Library.";
}
void AGSNickenstienGFX::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_engine->version < 3)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD(NGFX_GRAPHICS_Initialise, AGSNickenstienGFX::NGFX_GRAPHICS_Initialise);
SCRIPT_METHOD(NGFX_GRAPHICS_Enable, AGSNickenstienGFX::NGFX_GRAPHICS_Enable);
SCRIPT_METHOD(NGFX_GRAPHICS_SetTimeScalar, AGSNickenstienGFX::NGFX_GRAPHICS_SetTimeScalar);
SCRIPT_METHOD(NGFX_GRAPHICS_FullScreenFadeOut, AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut);
SCRIPT_METHOD(NGFX_GRAPHICS_FullScreenFadeIn, AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeIn);
SCRIPT_METHOD(NGFX_GRAPHICS_FullScreenFadeOut_2, AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut_2);
SCRIPT_METHOD(NGFX_GRAPHICS_FullScreenFadeOut_2_SetBackgroundColour, AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut_2_SetBackgroundColour);
SCRIPT_METHOD(NGFX_GRAPHICS_FullScreenFadeIn_2, AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeIn_2);
SCRIPT_METHOD(NGFX_GRAPHICS_SetAnisotropicFilter, AGSNickenstienGFX::NGFX_GRAPHICS_SetAnisotropicFilter);
SCRIPT_METHOD(NGFX_TEXTURE_Load, AGSNickenstienGFX::NGFX_TEXTURE_Load);
SCRIPT_METHOD(NGFX_TEXTURE_Release, AGSNickenstienGFX::NGFX_TEXTURE_Release);
SCRIPT_METHOD(NGFX_TEXTURE_GetWidth, AGSNickenstienGFX::NGFX_TEXTURE_GetWidth);
SCRIPT_METHOD(NGFX_TEXTURE_GetHeight, AGSNickenstienGFX::NGFX_TEXTURE_GetHeight);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_Create, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Create);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_Release, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Release);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetType, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetType);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetLife, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetLife);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEmittionRate, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEmittionRate);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetParticlesPerEmittion, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticlesPerEmittion);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetPosition1, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetPosition1);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetPosition2, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetPosition2);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartVelocity, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartVelocity);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartVelocity_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartVelocity_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndVelocity, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndVelocity);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndVelocity_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndVelocity_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartWidth, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartWidth);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartWidth_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartWidth_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndWidth, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndWidth);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndWidth_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndWidth_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartHeight, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartHeight);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartHeight_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartHeight_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndHeight, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndHeight);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndHeight_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndHeight_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartAngle, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartAngle);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartAngle_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartAngle_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetRotation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetRotation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetRotation_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetRotation_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartColour, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartColour);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetStartColour_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartColour_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndColour, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndColour);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetEndColour_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndColour_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetBlendMode, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetBlendMode);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetTexture, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetTexture);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetForce, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetForce);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetParticleLife, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticleLife);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetParticleLife_Deviation, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticleLife_Deviation);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetNoTimeOut, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetNoTimeOut);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetDrawOrderReversed, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetDrawOrderReversed);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetProcessWhenOffScreen, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetProcessWhenOffScreen);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetUseVelocityParticles, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetUseVelocityParticles);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_SetChannelID, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetChannelID);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_Start, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Start);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_Clone, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Clone);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_ReleaseAll, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_ReleaseAll);
SCRIPT_METHOD(NGFX_PARTICLE_EMITTER_Evolve, AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Evolve);
SCRIPT_METHOD(NGFX_HasGameRoomChanged, AGSNickenstienGFX::NGFX_HasGameRoomChanged);
SCRIPT_METHOD(NGFX_HasGameRoomChanged_SecondTest, AGSNickenstienGFX::NGFX_HasGameRoomChanged_SecondTest);
SCRIPT_METHOD(NGFX_SPRITE_ResetForNewRoom, AGSNickenstienGFX::NGFX_SPRITE_ResetForNewRoom);
SCRIPT_METHOD(NGFX_SPRITE_Create, AGSNickenstienGFX::NGFX_SPRITE_Create);
SCRIPT_METHOD(NGFX_SPRITE_Release, AGSNickenstienGFX::NGFX_SPRITE_Release);
SCRIPT_METHOD(NGFX_SPRITE_SetChannelID, AGSNickenstienGFX::NGFX_SPRITE_SetChannelID);
SCRIPT_METHOD(NGFX_SPRITE_SetPosition, AGSNickenstienGFX::NGFX_SPRITE_SetPosition);
SCRIPT_METHOD(NGFX_SPRITE_SetPivot, AGSNickenstienGFX::NGFX_SPRITE_SetPivot);
SCRIPT_METHOD(NGFX_SPRITE_SetTexture, AGSNickenstienGFX::NGFX_SPRITE_SetTexture);
SCRIPT_METHOD(NGFX_SPRITE_SetBlendMode, AGSNickenstienGFX::NGFX_SPRITE_SetBlendMode);
SCRIPT_METHOD(NGFX_SPRITE_SetWidth, AGSNickenstienGFX::NGFX_SPRITE_SetWidth);
SCRIPT_METHOD(NGFX_SPRITE_SetHeight, AGSNickenstienGFX::NGFX_SPRITE_SetHeight);
SCRIPT_METHOD(NGFX_SPRITE_SetAngle, AGSNickenstienGFX::NGFX_SPRITE_SetAngle);
SCRIPT_METHOD(NGFX_SPRITE_SetColour_1, AGSNickenstienGFX::NGFX_SPRITE_SetColour_1);
SCRIPT_METHOD(NGFX_SPRITE_SetColour_2, AGSNickenstienGFX::NGFX_SPRITE_SetColour_2);
SCRIPT_METHOD(NGFX_SPRITE_SetColour_3, AGSNickenstienGFX::NGFX_SPRITE_SetColour_3);
SCRIPT_METHOD(NGFX_SPRITE_SetColour_4, AGSNickenstienGFX::NGFX_SPRITE_SetColour_4);
SCRIPT_METHOD(NGFX_SPRITE_SetClipRectangle, AGSNickenstienGFX::NGFX_SPRITE_SetClipRectangle);
SCRIPT_METHOD(NGFX_SPRITE_SetGourard, AGSNickenstienGFX::NGFX_SPRITE_SetGourard);
SCRIPT_METHOD(NGFX_SPRITE_SetFlipped_H, AGSNickenstienGFX::NGFX_SPRITE_SetFlipped_H);
SCRIPT_METHOD(NGFX_SPRITE_SetFlipped_V, AGSNickenstienGFX::NGFX_SPRITE_SetFlipped_V);
SCRIPT_METHOD(NGFX_SPRITE_AddToDrawList, AGSNickenstienGFX::NGFX_SPRITE_AddToDrawList);
SCRIPT_METHOD(NGFX_InitForNewGameLoop, AGSNickenstienGFX::NGFX_InitForNewGameLoop);
// TODO unnamed functions?
}
void AGSNickenstienGFX::NGFX_GRAPHICS_Initialise(ScriptMethodParams &params) {
//PARAMS2(int, GameNativeScreenWidth, int, GameNativeScreenHeight);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_Enable(ScriptMethodParams &params) {
//PARAMS1(bool, OnOff);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_SetTimeScalar(ScriptMethodParams &params) {
//PARAMS1(float, TimeScalar);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut(ScriptMethodParams &params) {
//PARAMS1(int, Time);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeIn(ScriptMethodParams &params) {
//PARAMS1(int, Time);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut_2(ScriptMethodParams &params) {
//PARAMS9(int, Time, int, BlendMode, int, R, int, G, int, B, int, NumLayers, float, BackSpeed, float, FrontSpeed, Common::String, TextureFilename);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeOut_2_SetBackgroundColour(ScriptMethodParams &params) {
//PARAMS3(int, Back_R, int, Back_G, int, Back_B);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_FullScreenFadeIn_2(ScriptMethodParams &params) {
//PARAMS1(int, Time);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_GRAPHICS_SetAnisotropicFilter(ScriptMethodParams &params) {
//PARAMS1(int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_TEXTURE_Load(ScriptMethodParams &params) {
//PARAMS1(Common::String, Filename);
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_TEXTURE_Release(ScriptMethodParams &params) {
//PARAMS1(int, TextureHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_TEXTURE_GetWidth(ScriptMethodParams &params) {
//PARAMS1(int, TextureHandle);
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_TEXTURE_GetHeight(ScriptMethodParams &params) {
//PARAMS1(int, TextureHandle);
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Create(ScriptMethodParams &params) {
//PARAMS1(int, MaxParticlesForThisEmitter);
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Release(ScriptMethodParams &params) {
//PARAMS1(int, ParticleEmitterHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetType(ScriptMethodParams &params) {
//PARAMS1(int, ParticleEmitterHandle, int, EmitterType);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetLife(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, EmitterLife);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEmittionRate(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, EmittionRate);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticlesPerEmittion(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, ParticlesPerEmittion);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetPosition1(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, PosX, float, PosY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetPosition2(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, PosX, float, PosY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartVelocity(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, VelocityX, float, VelocityY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartVelocity_Deviation(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, VelocityDeviationX, float, VelocityDeviationY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndVelocity(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, VelocityX, float, VelocityY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndVelocity_Deviation(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, VelocityDeviationX, float, VelocityDeviationY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartWidth(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Width);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartWidth_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, WidthDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndWidth(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Width);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndWidth_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, WidthDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartHeight(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Height);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartHeight_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, HeightDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndHeight(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Height);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndHeight_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, HeightDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartAngle(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Angle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartAngle_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, AngleDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetRotation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Rotation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetRotation_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, RotationDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartColour(ScriptMethodParams &params) {
//PARAMS5(int, ParticleEmitterHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetStartColour_Deviation(ScriptMethodParams &params) {
//PARAMS5(int, ParticleEmitterHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndColour(ScriptMethodParams &params) {
//PARAMS5(int, ParticleEmitterHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetEndColour_Deviation(ScriptMethodParams &params) {
//PARAMS5(int, ParticleEmitterHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetBlendMode(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, BlendMode);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetTexture(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, TextureHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetForce(ScriptMethodParams &params) {
//PARAMS3(int, ParticleEmitterHandle, float, ForceX, float, ForceY);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticleLife(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, Life);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetParticleLife_Deviation(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, LifeDeviation);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetNoTimeOut(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetDrawOrderReversed(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetProcessWhenOffScreen(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetUseVelocityParticles(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_SetChannelID(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, int, ChannelID);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Start(ScriptMethodParams &params) {
//PARAMS1(int, ParticleEmitterHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Clone(ScriptMethodParams &params) {
//PARAMS1(int, SourceParticleEmitterHandle);
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_ReleaseAll(ScriptMethodParams &params) {
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_PARTICLE_EMITTER_Evolve(ScriptMethodParams &params) {
//PARAMS2(int, ParticleEmitterHandle, float, TimeToEvolveBy);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_HasGameRoomChanged(ScriptMethodParams &params) {
//PARAMS1(int, CurrentGameRoom);
// TODO rest of the owl
params._result = true; // HACK stub
}
void AGSNickenstienGFX::NGFX_HasGameRoomChanged_SecondTest(ScriptMethodParams &params) {
//PARAMS1(int, CurrentGameRoom);
// TODO rest of the owl
params._result = true; // HACK stub
}
void AGSNickenstienGFX::NGFX_SPRITE_ResetForNewRoom(ScriptMethodParams &params) {
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_Create(ScriptMethodParams &params) {
// TODO rest of the owl
params._result = 0; // HACK stub
}
void AGSNickenstienGFX::NGFX_SPRITE_Release(ScriptMethodParams &params) {
//PARAMS1(int, SpriteHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetChannelID(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, ChannelID);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetPosition(ScriptMethodParams &params) {
//PARAMS3(int, SpriteHandle, float, x, float, y);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetPivot(ScriptMethodParams &params) {
//PARAMS3(int, SpriteHandle, float, x, float, y);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetTexture(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, TextureHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetBlendMode(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, BlendMode);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetWidth(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, float, Width);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetHeight(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, float, Height);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetAngle(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, float, Angle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetColour_1(ScriptMethodParams &params) {
//PARAMS5(int, SpriteHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetColour_2(ScriptMethodParams &params) {
//PARAMS5(int, SpriteHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetColour_3(ScriptMethodParams &params) {
//PARAMS5(int, SpriteHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetColour_4(ScriptMethodParams &params) {
//PARAMS5(int, SpriteHandle, int, R, int, G, int, B, int, A);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetClipRectangle(ScriptMethodParams &params) {
//PARAMS5(int, SpriteHandle, float, x, float, y, float, x2, float, y2);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetGourard(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetFlipped_H(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_SetFlipped_V(ScriptMethodParams &params) {
//PARAMS2(int, SpriteHandle, int, TrueFalse);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_SPRITE_AddToDrawList(ScriptMethodParams &params) {
//PARAMS1(int, SpriteHandle);
// TODO rest of the owl
}
void AGSNickenstienGFX::NGFX_InitForNewGameLoop(ScriptMethodParams &params) {
// TODO rest of the owl
}
} // namespace AGSNickenstienGFX
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,126 @@
/* 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_NICKENSTIEN_GFX_AGS_NICKENSTIEN_GFX_H
#define AGS_PLUGINS_AGS_NICKENSTIEN_GFX_AGS_NICKENSTIEN_GFX_H
#include "common/str.h"
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSNickenstienGFX {
class AGSNickenstienGFX : public PluginBase {
SCRIPT_HASH(AGSNickenstienGFX)
private:
void NGFX_GRAPHICS_Initialise(ScriptMethodParams &params);
void NGFX_GRAPHICS_Enable(ScriptMethodParams &params);
void NGFX_GRAPHICS_SetTimeScalar(ScriptMethodParams &params);
void NGFX_GRAPHICS_FullScreenFadeOut(ScriptMethodParams &params);
void NGFX_GRAPHICS_FullScreenFadeIn(ScriptMethodParams &params);
void NGFX_GRAPHICS_FullScreenFadeOut_2(ScriptMethodParams &params);
void NGFX_GRAPHICS_FullScreenFadeOut_2_SetBackgroundColour(ScriptMethodParams &params);
void NGFX_GRAPHICS_FullScreenFadeIn_2(ScriptMethodParams &params);
void NGFX_GRAPHICS_SetAnisotropicFilter(ScriptMethodParams &params);
void NGFX_TEXTURE_Load(ScriptMethodParams &params);
void NGFX_TEXTURE_Release(ScriptMethodParams &params);
void NGFX_TEXTURE_GetWidth(ScriptMethodParams &params);
void NGFX_TEXTURE_GetHeight(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_Create(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_Release(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetType(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetLife(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEmittionRate(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetParticlesPerEmittion(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetPosition1(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetPosition2(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartVelocity(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartVelocity_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndVelocity(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndVelocity_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartWidth(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartWidth_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndWidth(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndWidth_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartHeight(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartHeight_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndHeight(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndHeight_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartAngle(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartAngle_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetRotation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetRotation_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartColour(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetStartColour_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndColour(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetEndColour_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetBlendMode(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetTexture(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetForce(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetParticleLife(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetParticleLife_Deviation(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetNoTimeOut(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetDrawOrderReversed(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetProcessWhenOffScreen(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetUseVelocityParticles(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_SetChannelID(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_Start(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_Clone(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_ReleaseAll(ScriptMethodParams &params);
void NGFX_PARTICLE_EMITTER_Evolve(ScriptMethodParams &params);
void NGFX_HasGameRoomChanged(ScriptMethodParams &params);
void NGFX_HasGameRoomChanged_SecondTest(ScriptMethodParams &params);
void NGFX_SPRITE_ResetForNewRoom(ScriptMethodParams &params);
void NGFX_SPRITE_Create(ScriptMethodParams &params);
void NGFX_SPRITE_Release(ScriptMethodParams &params);
void NGFX_SPRITE_SetChannelID(ScriptMethodParams &params);
void NGFX_SPRITE_SetPosition(ScriptMethodParams &params);
void NGFX_SPRITE_SetPivot(ScriptMethodParams &params);
void NGFX_SPRITE_SetTexture(ScriptMethodParams &params);
void NGFX_SPRITE_SetBlendMode(ScriptMethodParams &params);
void NGFX_SPRITE_SetWidth(ScriptMethodParams &params);
void NGFX_SPRITE_SetHeight(ScriptMethodParams &params);
void NGFX_SPRITE_SetAngle(ScriptMethodParams &params);
void NGFX_SPRITE_SetColour_1(ScriptMethodParams &params);
void NGFX_SPRITE_SetColour_2(ScriptMethodParams &params);
void NGFX_SPRITE_SetColour_3(ScriptMethodParams &params);
void NGFX_SPRITE_SetColour_4(ScriptMethodParams &params);
void NGFX_SPRITE_SetClipRectangle(ScriptMethodParams &params);
void NGFX_SPRITE_SetGourard(ScriptMethodParams &params);
void NGFX_SPRITE_SetFlipped_H(ScriptMethodParams &params);
void NGFX_SPRITE_SetFlipped_V(ScriptMethodParams &params);
void NGFX_SPRITE_AddToDrawList(ScriptMethodParams &params);
void NGFX_InitForNewGameLoop(ScriptMethodParams &params);
public:
AGSNickenstienGFX() : PluginBase() {}
virtual ~AGSNickenstienGFX() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSNickenstienGFX
} // namespace Plugins
} // namespace AGS3
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,279 @@
/* 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_PAL_RENDER_AGS_PAL_RENDER_H
#define AGS_PLUGINS_AGS_PAL_RENDER_AGS_PAL_RENDER_H
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/serializer.h"
namespace AGS3 {
namespace Plugins {
namespace AGSPalRender {
class AGSPalRender : public PluginBase {
SCRIPT_HASH(AGSPalRender)
private:
void syncGame(Serializer &s);
public:
AGSPalRender() : PluginBase() {}
virtual ~AGSPalRender() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
void AGS_EngineShutdown() override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
/**
* @defgroup PALInternal
* @{
*/
void LoadCLUT(ScriptMethodParams &params);
void CycleRemap(ScriptMethodParams &params);
void GetColor565(ScriptMethodParams &params);
void GetLuminosityFromPalette(ScriptMethodParams &params);
void AGSFastSin(ScriptMethodParams &params);
void AGSFastCos(ScriptMethodParams &params);
void AGSFastRoot(ScriptMethodParams &params);
void GetRemappedSlot(ScriptMethodParams &params);
void ResetRemapping(ScriptMethodParams &params);
void GetModifiedBackgroundImage(ScriptMethodParams &params);
void WriteObjectivePalette(ScriptMethodParams &params);
void ReadObjectivePaletteR(ScriptMethodParams &params);
void ReadObjectivePaletteB(ScriptMethodParams &params);
void ReadObjectivePaletteG(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup LensDistort
* @{
*/
void SetLensPos(ScriptMethodParams &params);
void GetLensX(ScriptMethodParams &params);
void GetLensY(ScriptMethodParams &params);
void SetLensDrawn(ScriptMethodParams &params);
void GetLensDrawn(ScriptMethodParams &params);
void SetLensOffsetClamp(ScriptMethodParams &params);
void GetLensOffsetClamp(ScriptMethodParams &params);
void GetLensLevel(ScriptMethodParams &params);
void SetLensLevel(ScriptMethodParams &params);
void LensInitialize(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup Translucence
* @{
*/
void CreateTranslucentOverlay(ScriptMethodParams &params);
void DeleteTranslucentOverlay(ScriptMethodParams &params);
void MoveTranslucentOverlay(ScriptMethodParams &params);
void GetTranslucentOverlayX(ScriptMethodParams &params);
void GetTranslucentOverlayY(ScriptMethodParams &params);
void GetTranslucentOverlaySprite(ScriptMethodParams &params);
void GetTranslucentOverlayLevel(ScriptMethodParams &params);
void GetTranslucentOverlayEnabled(ScriptMethodParams &params);
void GetTranslucentOverlayAlpha(ScriptMethodParams &params);
void SetTranslucentOverlayAlpha(ScriptMethodParams &params);
void SetTranslucentOverlayEnabled(ScriptMethodParams &params);
void DrawTransSprite(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup Starfield
* @{
*/
void GetStarfieldOverscan(ScriptMethodParams &params);
void SetStarfieldOverscan(ScriptMethodParams &params);
void GetStarfieldOriginX(ScriptMethodParams &params);
void GetStarfieldOriginY(ScriptMethodParams &params);
void SetStarfieldDepthMultiplier(ScriptMethodParams &params);
void GetStarfieldDepthMultiplier(ScriptMethodParams &params);
void GetStarfieldMaxStars(ScriptMethodParams &params);
void SetStarSpriteScaleBoost(ScriptMethodParams &params);
void GetStarSpriteScaleBoost(ScriptMethodParams &params);
void SetStarMaxRadius(ScriptMethodParams &params);
void GetStarMaxRadius(ScriptMethodParams &params);
void GetStarX(ScriptMethodParams &params);
void GetStarY(ScriptMethodParams &params);
void GetStarZ(ScriptMethodParams &params);
void SetStarPosition(ScriptMethodParams &params);
void RotateStar(ScriptMethodParams &params);
void SetStarColor(ScriptMethodParams &params);
void GetStarColor(ScriptMethodParams &params);
void SetStarSprite(ScriptMethodParams &params);
void GetStarSprite(ScriptMethodParams &params);
void SetStarSpriteRange(ScriptMethodParams &params);
void InitializeStars(ScriptMethodParams &params);
void IterateStars(ScriptMethodParams &params);
void DrawStars(ScriptMethodParams &params);
void SetStarsOriginPoint(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup Plasma
* @{
*/
void DoFire(ScriptMethodParams &params);
void SetPlasmaType(ScriptMethodParams &params);
void ResetPlasmaSettings(ScriptMethodParams &params);
void DrawPlasma(ScriptMethodParams &params);
void SetPlasmaRootType(ScriptMethodParams &params);
void GetPlasmaRootType(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup Reflections
* @{
*/
void SetReflections(ScriptMethodParams &params);
void IsReflectionsOn(ScriptMethodParams &params);
void SetCharacterReflected(ScriptMethodParams &params);
void GetCharacterReflected(ScriptMethodParams &params);
void SetObjectReflected(ScriptMethodParams &params);
void GetObjectReflected(ScriptMethodParams &params);
void ReplaceCharacterReflectionView(ScriptMethodParams &params);
void SetObjectReflectionIgnoreScaling(ScriptMethodParams &params);
/**@}*/
/**
* @defgroup raycast
* @{
*/
void MakeTextures(ScriptMethodParams &params);
void Raycast_Render(ScriptMethodParams &params);
void MoveForward(ScriptMethodParams &params);
void MoveBackward(ScriptMethodParams &params);
void RotateLeft(ScriptMethodParams &params);
void RotateRight(ScriptMethodParams &params);
void Init_Raycaster(ScriptMethodParams &params);
void QuitCleanup(ScriptMethodParams &params);
void LoadMap(ScriptMethodParams &params);
void Ray_InitSprite(ScriptMethodParams &params);
void Ray_SetPlayerPosition(ScriptMethodParams &params);
void Ray_GetPlayerX(ScriptMethodParams &params);
void Ray_GetPlayerY(ScriptMethodParams &params);
void Ray_GetPlayerAngle(ScriptMethodParams &params);
void Ray_SetPlayerAngle(ScriptMethodParams &params);
void Ray_GetWallHotspot(ScriptMethodParams &params);
void Ray_GetWallTexture(ScriptMethodParams &params);
void Ray_GetWallSolid(ScriptMethodParams &params);
void Ray_GetWallIgnoreLighting(ScriptMethodParams &params);
void Ray_GetWallAlpha(ScriptMethodParams &params);
void Ray_GetWallBlendType(ScriptMethodParams &params);
void Ray_SelectTile(ScriptMethodParams &params);
void Ray_GetHotspotAt(ScriptMethodParams &params);
void Ray_GetObjectAt(ScriptMethodParams &params);
void Ray_DrawTile(ScriptMethodParams &params);
void Ray_DrawOntoTile(ScriptMethodParams &params);
void Ray_SetNoClip(ScriptMethodParams &params);
void Ray_GetNoClip(ScriptMethodParams &params);
void Ray_SetSpriteInteractObj(ScriptMethodParams &params);
void Ray_GetSpriteInteractObj(ScriptMethodParams &params);
void Ray_SetSpritePosition(ScriptMethodParams &params);
void Ray_SetSpriteVertOffset(ScriptMethodParams &params);
void Ray_GetSpriteVertOffset(ScriptMethodParams &params);
void Ray_GetSpriteX(ScriptMethodParams &params);
void Ray_GetSpriteY(ScriptMethodParams &params);
void Ray_SetWallHotspot(ScriptMethodParams &params);
void Ray_SetWallTextures(ScriptMethodParams &params);
void Ray_SetWallSolid(ScriptMethodParams &params);
void Ray_SetWallIgnoreLighting(ScriptMethodParams &params);
void Ray_SetWallAlpha(ScriptMethodParams &params);
void Ray_SetWallBlendType(ScriptMethodParams &params);
void Ray_GetMoveSpeed(ScriptMethodParams &params);
void Ray_SetMoveSpeed(ScriptMethodParams &params);
void Ray_GetRotSpeed(ScriptMethodParams &params);
void Ray_SetRotSpeed(ScriptMethodParams &params);
void Ray_GetWallAt(ScriptMethodParams &params);
void Ray_GetLightAt(ScriptMethodParams &params);
void Ray_SetLightAt(ScriptMethodParams &params);
void Ray_SetWallAt(ScriptMethodParams &params);
void Ray_GetPlaneY(ScriptMethodParams &params);
void Ray_SetPlaneY(ScriptMethodParams &params);
void Ray_GetDistanceAt(ScriptMethodParams &params);
void Ray_GetSpriteAngle(ScriptMethodParams &params);
void Ray_SetSpriteAngle(ScriptMethodParams &params);
void Ray_SetSpriteView(ScriptMethodParams &params);
void Ray_GetSpriteView(ScriptMethodParams &params);
void Ray_SetSpriteFrame(ScriptMethodParams &params);
void Ray_GetSpriteFrame(ScriptMethodParams &params);
void Ray_GetTileX_At(ScriptMethodParams &params);
void Ray_GetTileY_At(ScriptMethodParams &params);
void Ray_SetSkyBox(ScriptMethodParams &params);
void Ray_GetSkyBox(ScriptMethodParams &params);
void Ray_SetAmbientLight(ScriptMethodParams &params);
void Ray_GetAmbientLight(ScriptMethodParams &params);
void Ray_SetAmbientColor(ScriptMethodParams &params);
void Ray_GetSpriteAlpha(ScriptMethodParams &params);
void Ray_SetSpriteAlpha(ScriptMethodParams &params);
void Ray_GetSpritePic(ScriptMethodParams &params);
void Ray_SetSpritePic(ScriptMethodParams &params);
void Ray_GetSpriteScaleX(ScriptMethodParams &params);
void Ray_SetSpriteScaleX(ScriptMethodParams &params);
void Ray_GetSpriteScaleY(ScriptMethodParams &params);
void Ray_SetSpriteScaleY(ScriptMethodParams &params);
void Ray_SetSpriteBlendType(ScriptMethodParams &params);
void Ray_GetSpriteBlendType(ScriptMethodParams &params);
void Ray_SetFloorAt(ScriptMethodParams &params);
void Ray_SetCeilingAt(ScriptMethodParams &params);
void Ray_GetCeilingAt(ScriptMethodParams &params);
void Ray_GetFloorAt(ScriptMethodParams &params);
void Ray_GetLightingAt(ScriptMethodParams &params);
void Ray_SetLightingAt(ScriptMethodParams &params);
void Ray_GetAmbientWeight(ScriptMethodParams &params);
void Ray_HasSeenTile(ScriptMethodParams &params);
/**@}*/
};
} // namespace AGSPalRender
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,187 @@
/* 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_PAL_RENDER_PAL_RENDER_H
#define AGS_PLUGINS_AGS_PAL_RENDER_PAL_RENDER_H
#include "ags/lib/allegro.h"
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/plugin_base.h"
#include "common/algorithm.h"
namespace AGS3 {
namespace Plugins {
namespace AGSPalRender {
struct PALSTRUCT {
byte r;
byte b;
byte g;
};
extern IAGSEngine *engine;
extern unsigned char clut[65536];
extern unsigned char cycle_remap [256];
extern const int alphamultiply [4096];
extern PALSTRUCT objectivepal[256];
// this class exists solely to take advantage of g++'s
// -fvisibility-inlines-hidden option, so that these
// methods can be inlined without any trace or complaint
class Mix {
public:
//unsigned char MixColorAlpha (unsigned char fg,unsigned char bg,unsigned char alpha);
//unsigned char MixColorAdditive (unsigned char fg,unsigned char bg,unsigned char alpha);
static unsigned char MixColorAlpha(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
unsigned char rfg = cycle_remap[fg]; //Automatic remapping of palette slots.
//unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere.
AGSColor *palette = engine->GetPalette();
int i = 0;
//int out_r = (palette[fg].r>>1) * alpha + (palette[bg].r>>1) * (255 - alpha);
//int out_g = palette[fg].g * alpha + palette[bg].g * (255 - alpha);
//int out_b = (palette[fg].b>>1) * alpha + (palette[bg].b>>1) * (255 - alpha);
int out_r, out_g, out_b;
if (use_objpal == 0) {
out_r = (objectivepal[rfg].r >> 1) *alpha + (palette[bg].r >> 1) *(255 - alpha);
out_g = objectivepal[rfg].g * alpha + palette[bg].g * (255 - alpha);
out_b = (objectivepal[rfg].b >> 1) *alpha + (palette[bg].b >> 1) *(255 - alpha);
} else {
out_r = (objectivepal[rfg].r >> 1) *alpha + (objectivepal[bg].r >> 1) *(255 - alpha);
out_g = objectivepal[rfg].g * alpha + objectivepal[bg].g * (255 - alpha);
out_b = (objectivepal[rfg].b >> 1) *alpha + (objectivepal[bg].b >> 1) *(255 - alpha);
}
//char ralpha = MAX(0,MIN(63,alpha>>2));
//unsigned char invralpha = 64-ralpha;
//if (ralpha > alpha) engine->AbortGame ("oops");
//int out_r = alphamultiply[((palette[fg].r>>1)<<6) +ralpha] + alphamultiply[((palette[bg].r>>1)<<6) +(invralpha)];
//int out_g = alphamultiply[((palette[fg].g) <<6) +ralpha] + alphamultiply[((palette[bg].g) <<6) +(invralpha)];
//int out_b = alphamultiply[((palette[fg].b>>1)<<6) +ralpha] + alphamultiply[((palette[bg].b>>1)<<6) +(invralpha)];
out_r = (out_r + 1 + (out_r >> 8)) >> 8;
out_g = (out_g + 1 + (out_g >> 8)) >> 8;
out_b = (out_b + 1 + (out_b >> 8)) >> 8;
//out_r = (out_r + 1 + (out_r >> 6)) >> 6;
//out_g = (out_g + 1 + (out_g >> 6)) >> 6;
//out_b = (out_b + 1 + (out_b >> 6)) >> 6;
i = ((out_r << 11) | (out_g << 5) | out_b);
unsigned char *clutp = clut;
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
return cycle_remap[*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
//engine->ReleaseBitmapSurface (clutspr);
}
static unsigned char MixColorLightLevel(unsigned char fg, unsigned char intensity) {
unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots.
int i = 0;
//int dark_r = (((palette[fg].r>>1) * (intensity))>>8);
//int dark_b = (((palette[fg].b>>1) * (intensity))>>8);
//int dark_g = (((palette[fg].g) * (intensity))>>8);
int dark_r = (((objectivepal[rfg].r >> 1) * (intensity)) >> 8);
int dark_b = (((objectivepal[rfg].b >> 1) * (intensity)) >> 8);
int dark_g = (((objectivepal[rfg].g) * (intensity)) >> 8);
i = ((dark_r << 11) | (dark_g << 5) | dark_b);
unsigned char *clutp = clut;
return cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
}
static unsigned char MixColorAdditive(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
unsigned char rfg = cycle_remap[fg]; //Automatic remapping of palette slots.
//unsigned char rbg = cycle_remap[bg]; //Saves on typing elsewhere.
//BITMAP *clutspr = engine->GetSpriteGraphic (clutslot);
//if (!clutspr) engine->AbortGame ("MixColorAlpha: Can't load CLUT sprite into memory.");
//uint8 *clutarray = engine->GetRawBitmapSurface (clutspr);
AGSColor *palette = engine->GetPalette();
int i = 0;
int add_r, add_b, add_g = 0;
//char ralpha = MAX(0,MIN(63,alpha>>2));
//add_r = (((palette[fg].r>>1) * (alpha))>>8);
//add_b = (((palette[fg].b>>1) * (alpha))>>8);
//add_g = (((palette[fg].g) * (alpha))>>8);
add_r = (((objectivepal[rfg].r >> 1) * (alpha)) >> 8);
add_b = (((objectivepal[rfg].b >> 1) * (alpha)) >> 8);
add_g = (((objectivepal[rfg].g) * (alpha)) >> 8);
//int a_g = MAX(0,MIN(63,alpha>>2));
//add_r = ((alphamultiply[(palette[fg].r>>1)<<6)+ralpha])>>6);
//add_b = ((alphamultiply[(palette[fg].b>>1)<<6)+ralpha])>>6);
//add_g = ((alphamultiply[(palette[fg].g) <<6)+ralpha])>>6);
//int out_r = MIN(31,(palette[bg].r>>1) + add_r);
//int out_g = MIN(63, palette[bg].g + add_g);
//int out_b = MIN(31,(palette[bg].b>>1) + add_b);
int out_r, out_g, out_b;
if (use_objpal == 0) {
out_r = MIN(31, (palette[bg].r >> 1) + add_r);
out_g = MIN(63, palette[bg].g + add_g);
out_b = MIN(31, (palette[bg].b >> 1) + add_b);
} else {
out_r = MIN(31, (objectivepal [bg].r >> 1) + add_r);
out_g = MIN(63, objectivepal [bg].g + add_g);
out_b = MIN(31, (objectivepal [bg].b >> 1) + add_b);
}
i = ((out_r << 11) | (out_g << 5) | out_b);
unsigned char *clutp = clut;
unsigned char result = cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
//engine->ReleaseBitmapSurface (clutspr);
return result;
}
static unsigned char MixColorMultiply(unsigned char fg, unsigned char bg, unsigned char alpha, int use_objpal = 0) {
unsigned char rfg = cycle_remap [fg]; //Automatic remapping of palette slots.
unsigned char rbg = cycle_remap [bg]; //Saves on typing elsewhere.
AGSColor *palette = engine->GetPalette();
int i = 0;
int mul_r, mul_b, mul_g = 0;
int out_r, out_g, out_b = 0;
if (use_objpal == 0) {
mul_r = ((objectivepal[rfg].r >> 1) * (palette[rbg].r >> 1)) / 64;
mul_b = ((objectivepal[rfg].b >> 1) * (palette[rbg].b >> 1)) / 64;
mul_g = ((objectivepal[rfg].g * palette[rbg].g) / 64);
out_r = ((palette[rbg].r >> 1) * (63 - (alpha / 4)) + (mul_r * (alpha / 4))) / 63;
out_g = (palette[rbg].g * (63 - (alpha / 4)) + (mul_g * (alpha / 4))) / 63;
out_b = ((palette[rbg].b >> 1) * (63 - (alpha / 4)) + (mul_b * (alpha / 4))) / 63;
} else {
mul_r = ((objectivepal[rfg].r >> 1) * (objectivepal[rbg].r >> 1)) / 64;
mul_b = ((objectivepal[rfg].b >> 1) * (objectivepal[rbg].b >> 1)) / 64;
mul_g = ((objectivepal[rfg].g * objectivepal[rbg].g) / 64);
out_r = ((objectivepal[rbg].r >> 1) * (63 - (alpha / 4)) + (mul_r * (alpha / 4))) / 63;
out_g = (objectivepal[rbg].g * (63 - (alpha / 4)) + (mul_g * (alpha / 4))) / 63;
out_b = ((objectivepal[rbg].b >> 1) * (63 - (alpha / 4)) + (mul_b * (alpha / 4))) / 63;
}
i = ((out_r << 11) | (out_g << 5) | out_b);
unsigned char *clutp = clut;
unsigned char result = cycle_remap [*(clutp + i)]; //Once again, to make sure that the palette slot used is the right one.
//unsigned char result = cycle_remap [clut[i>>8][i%256]]; //Once again, to make sure that the palette slot used is the right one.
//engine->ReleaseBitmapSurface (clutspr);
return result;
}
};
void GetColor565(ScriptMethodParams &params);
unsigned short root(unsigned short x);
float FastSin(float x);
float FastCos(float x);
} // namespace AGSPalRender
} // namespace Plugins
} // namespace AGS3
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,108 @@
/* 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_PAL_RENDER_RAYCAST_H
#define AGS_PLUGINS_AGS_PAL_RENDER_RAYCAST_H
#include "ags/plugins/ags_pal_render/pal_render.h"
namespace AGS3 {
namespace Plugins {
namespace AGSPalRender {
#define MAP_WIDTH 64
#define MAP_HEIGHT 64
struct Sprite {
double x;
double y;
int texture;
byte alpha;
int blendmode;
double uDivW;
double uDivH;
double vMove;
double hMove;
int8 objectinteract;
int view;
int frame;
int angle;
};
struct wallType {
int texture[4];
int solid[4];
int ignorelighting[4];
int alpha[4];
int blendtype[4];
int mask[4];
byte hotspotinteract;
};
extern bool raycastOn;
extern double posX;
extern double posY; //x and y start position
extern double dirX;
extern double dirY; //initial direction vector
extern double planeX;
extern double planeY; //the 2d raycaster version of camera plane
extern double moveSpeed; //the constant value is in squares/second
extern double rotSpeed; //the constant value is in radians/second
extern unsigned char worldMap[MAP_WIDTH][MAP_HEIGHT];
extern unsigned char lightMap[MAP_WIDTH][MAP_HEIGHT];
extern int ceilingMap[MAP_WIDTH][MAP_HEIGHT];
extern int floorMap[MAP_WIDTH][MAP_HEIGHT];
extern int heightMap[MAP_WIDTH][MAP_HEIGHT];
extern unsigned char seenMap[MAP_WIDTH][MAP_HEIGHT];
extern int textureSlot;
extern int ambientlight;
#define numSprites 256
extern Sprite sprite[numSprites];
#define texWidth 64
#define texHeight 64
#define MAX_TEXTURES 512
extern unsigned char texture[][texWidth * texHeight];
extern bool heightmapOn;
extern wallType wallData[256];
//arrays used to sort the sprites
extern unsigned char **transcolorbuffer;
extern unsigned char **transalphabuffer;
extern double **transzbuffer;
extern bool *transslicedrawn;
extern int *transwallblendmode;
extern double **ZBuffer;
extern double *distTable;
extern short *interactionmap;
extern int skybox;
} // namespace AGSPalRender
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,176 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_parallax/ags_parallax.h"
#include "ags/shared/core/platform.h"
#include "common/endian.h"
namespace AGS3 {
namespace Plugins {
namespace AGSParallax {
const unsigned int Magic = 0xCAFE0000;
const unsigned int Version = 2;
const unsigned int SaveMagic = Magic + Version;
const char *AGSParallax::AGS_GetPluginName() {
return "Parallax plugin recreation";
}
void AGSParallax::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD(pxDrawSprite, AGSParallax::pxDrawSprite);
SCRIPT_METHOD(pxDeleteSprite, AGSParallax::pxDeleteSprite);
SCRIPT_METHOD(pxAddSprite, AGSParallax::pxDrawSprite);
SCRIPT_METHOD(pxRemoveAllSprites, AGSParallax::pxRemoveAllSprites);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_PRESCREENDRAW);
_engine->RequestEventHook(AGSE_ENTERROOM);
_engine->RequestEventHook(AGSE_SAVEGAME);
_engine->RequestEventHook(AGSE_RESTOREGAME);
}
int64 AGSParallax::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event == AGSE_PREGUIDRAW) {
Draw(true);
} else if (event == AGSE_PRESCREENDRAW) {
// Get screen size and then draw
_engine->GetScreenDimensions(&_screenWidth, &_screenHeight, &_screenColorDepth);
Draw(false);
} else if (event == AGSE_ENTERROOM) {
// Reset all _sprites
clear();
} else if (event == AGSE_RESTOREGAME) {
Serializer s(_engine, data, true);
syncGame(s);
} else if (event == AGSE_SAVEGAME) {
Serializer s(_engine, data, false);
syncGame(s);
}
return 0;
}
void AGSParallax::clear() {
for (int i = 0; i < MAX_SPRITES; i++) {
_sprites[i] = Sprite();
_sprites[i].slot = -1;
}
_enabled = false;
}
void AGSParallax::syncGame(Serializer &s) {
int saveVersion = SaveMagic;
s.syncAsInt(saveVersion);
if ((uint)saveVersion != SaveMagic) {
_engine->AbortGame("ags_parallax: bad save.");
return;
}
for (int i = 0; i < MAX_SPRITES; ++i)
_sprites[i].syncGame(s);
s.syncAsBool(_enabled);
}
void AGSParallax::Draw(bool foreground) {
if (!_enabled)
return;
BITMAP *bmp;
int i;
int32 offsetX = 0;
int32 offsetY = 0;
_engine->ViewportToRoom(&offsetX, &offsetY);
for (i = 0; i < MAX_SPRITES; i++) {
if (_sprites[i].slot > -1) {
if (foreground) {
if (_sprites[i].speed > 0) {
bmp = _engine->GetSpriteGraphic(_sprites[i].slot);
if (bmp)
_engine->BlitBitmap(_sprites[i].x - offsetX - (_sprites[i].speed * offsetX / 100), _sprites[i].y, bmp, 1);
}
} else {
if (_sprites[i].speed <= 0) {
bmp = _engine->GetSpriteGraphic(_sprites[i].slot);
if (bmp)
_engine->BlitBitmap(_sprites[i].x - offsetX - (_sprites[i].speed * offsetX / 1000), _sprites[i].y, bmp, 1);
}
}
}
}
}
void AGSParallax::pxDrawSprite(ScriptMethodParams &params) {
PARAMS5(int, id, int, x, int, y, int, slot, int, speed);
if ((id < 0) || (id >= MAX_SPRITES))
return;
if ((speed < -MAX_SPEED) || (speed > MAX_SPEED))
speed = 0;
_sprites[id].x = x;
_sprites[id].y = y;
_sprites[id].slot = slot;
_sprites[id].speed = speed;
_engine->RoomToViewport(&_sprites[id].x, &_sprites[id].y);
_enabled = true;
}
void AGSParallax::pxDeleteSprite(ScriptMethodParams &params) {
PARAMS1(int, id);
if ((id < 0) || (id >= MAX_SPRITES))
return;
_sprites[id].slot = -1;
}
void AGSParallax::pxRemoveAllSprites(ScriptMethodParams &params) {
for (int i = 0; i < MAX_SPRITES; i++) {
_sprites[i].slot = -1;
}
}
/*------------------------------------------------------------------*/
void Sprite::syncGame(Serializer &s) {
s.syncAsInt(x);
s.syncAsInt(y);
s.syncAsInt(slot);
s.syncAsInt(speed);
}
} // namespace AGSParallax
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,80 @@
/* 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_PARALLAX_AGS_PARALLAX_H
#define AGS_PLUGINS_AGS_PARALLAX_AGS_PARALLAX_H
#include "ags/plugins/plugin_base.h"
#include "ags/plugins/serializer.h"
namespace AGS3 {
namespace Plugins {
namespace AGSParallax {
struct Sprite {
int32 x = 0;
int32 y = 0;
int slot = -1;
int speed = 0;
void syncGame(Serializer &s);
};
#define MAX_SPEED 1000
#define MAX_SPRITES 100
/**
* This is not the AGS Parallax plugin by Scorpiorus
* but a workalike plugin created for the AGS engine ports.
*/
class AGSParallax : public PluginBase {
SCRIPT_HASH(AGSParallax)
private:
int32 _screenWidth = 320;
int32 _screenHeight = 200;
int32 _screenColorDepth = 32;
bool _enabled = false;
Sprite _sprites[MAX_SPRITES];
private:
void pxDrawSprite(ScriptMethodParams &params);
void pxDeleteSprite(ScriptMethodParams &params);
void pxRemoveAllSprites(ScriptMethodParams &params);
void syncGame(Serializer &s);
void Draw(bool foreground);
void clear();
public:
AGSParallax() : PluginBase() {}
virtual ~AGSParallax() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};
} // namespace AGSParallax
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,932 @@
/* 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
* (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/>.
*
*/
// For dangerous AGS API
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
#include "ags/lib/allegro.h"
#include "common/std/vector.h"
#include "ags/shared/core/platform.h"
#include "ags/plugins/core/core.h"
#include "ags/shared/ac/common.h"
#include "ags/shared/ac/view.h"
#include "ags/engine/ac/display.h"
#include "ags/engine/ac/draw.h"
#include "ags/engine/ac/dynamic_sprite.h"
#include "ags/engine/ac/file.h"
#include "ags/engine/ac/game.h"
#include "ags/engine/ac/game_setup.h"
#include "ags/shared/ac/game_setup_struct.h"
#include "ags/engine/ac/game_state.h"
#include "ags/engine/ac/global_audio.h"
#include "ags/engine/ac/global_walkable_area.h"
#include "ags/shared/ac/keycode.h"
#include "ags/engine/ac/mouse.h"
#include "ags/engine/ac/move_list.h"
#include "ags/engine/ac/parser.h"
#include "ags/engine/ac/path_helper.h"
#include "ags/engine/ac/room_status.h"
#include "ags/engine/ac/string.h"
#include "ags/engine/ac/sys_events.h"
#include "ags/shared/ac/sprite_cache.h"
#include "ags/engine/ac/dynobj/script_string.h"
#include "ags/engine/ac/dynobj/dynobj_manager.h"
#include "ags/shared/font/fonts.h"
#include "ags/engine/debugging/debug_log.h"
#include "ags/engine/debugging/debugger.h"
#include "ags/shared/debugging/out.h"
#include "ags/engine/device/mouse_w32.h"
#include "ags/shared/gfx/bitmap.h"
#include "ags/engine/gfx/graphics_driver.h"
#include "ags/engine/gfx/gfx_util.h"
#include "ags/engine/gfx/gfxfilter.h"
#include "ags/shared/gui/gui_defines.h"
#include "ags/engine/main/game_run.h"
#include "ags/engine/main/graphics_mode.h"
#include "ags/engine/main/engine.h"
#include "ags/engine/media/audio/audio_system.h"
#include "ags/plugins/plugin_engine.h"
#include "ags/engine/script/runtime_script_value.h"
#include "ags/engine/script/script.h"
#include "ags/engine/script/script_runtime.h"
#include "ags/shared/util/file_stream.h"
#include "ags/engine/util/library.h"
#include "ags/engine/util/library_scummvm.h"
#include "ags/shared/util/memory.h"
#include "ags/shared/util/stream.h"
#include "ags/shared/util/string_compat.h"
#include "ags/shared/util/wgt2_allg.h"
#include "ags/globals.h"
// hide internal constants conflicting with plugin API
#undef OBJF_NOINTERACT
#undef OBJF_NOWALKBEHINDS
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
using namespace AGS::Shared;
using namespace AGS::Engine;
const int PLUGIN_API_VERSION = 26;
// On save/restore, the Engine will provide the plugin with a handle. Because we only ever save to one file at a time,
// we can reuse the same handle.
void PluginSimulateMouseClick(int pluginButtonID) {
_G(simulatedClick) = static_cast<eAGSMouseButton>(pluginButtonID);
}
void IAGSEngine::AbortGame(const char *reason) {
quit(reason);
}
const char *IAGSEngine::GetEngineVersion() {
return get_engine_version();
}
void IAGSEngine::RegisterScriptFunction(const char *name, Plugins::ScriptContainer *instance) {
ccAddExternalPluginFunction(name, instance);
}
void IAGSEngine::RegisterBuiltInFunction(const char *name, Plugins::ScriptContainer *instance) {
ccAddExternalFunctionForPlugin(name, instance);
}
const char *IAGSEngine::GetGraphicsDriverID() {
if (_G(gfxDriver) == nullptr)
return nullptr;
return _G(gfxDriver)->GetDriverID();
}
BITMAP *IAGSEngine::GetScreen() {
// TODO: we could actually return stage buffer here, will that make a difference?
if (!_G(gfxDriver)->UsesMemoryBackBuffer())
quit("!This plugin requires software graphics driver.");
Bitmap *buffer = _G(gfxDriver)->GetMemoryBackBuffer();
return buffer ? (BITMAP *)buffer->GetAllegroBitmap() : nullptr;
}
BITMAP *IAGSEngine::GetVirtualScreen() {
Bitmap *stage = _G(gfxDriver)->GetStageBackBuffer(true);
return stage ? (BITMAP *)stage->GetAllegroBitmap() : nullptr;
}
void IAGSEngine::RequestEventHook(int32 event) {
if (event >= AGSE_TOOHIGH)
quit("!IAGSEngine::RequestEventHook: invalid event requested");
if ((event & AGSE_SCRIPTDEBUG) &&
((_GP(plugins)[this->pluginId].wantHook & AGSE_SCRIPTDEBUG) == 0)) {
_G(pluginsWantingDebugHooks)++;
ccSetDebugHook(scriptDebugHook);
}
if (event & AGSE_AUDIODECODE) {
quit("Plugin requested AUDIODECODE, which is no longer supported");
}
_GP(plugins)[this->pluginId].wantHook |= event;
}
void IAGSEngine::UnrequestEventHook(int32 event) {
if (event >= AGSE_TOOHIGH)
quit("!IAGSEngine::UnrequestEventHook: invalid event requested");
if ((event & AGSE_SCRIPTDEBUG) &&
(_GP(plugins)[this->pluginId].wantHook & AGSE_SCRIPTDEBUG)) {
_G(pluginsWantingDebugHooks)--;
if (_G(pluginsWantingDebugHooks) < 1)
ccSetDebugHook(nullptr);
}
_GP(plugins)[this->pluginId].wantHook &= ~event;
}
int IAGSEngine::GetSavedData(char *buffer, int32 bufsize) {
int savedatasize = _GP(plugins)[this->pluginId].savedata.size();
if (bufsize < savedatasize)
quit("!IAGSEngine::GetSavedData: buffer too small");
if (savedatasize > 0)
memcpy(buffer, &_GP(plugins)[this->pluginId].savedata.front(), savedatasize);
return savedatasize;
}
void IAGSEngine::DrawText(int32 x, int32 y, int32 font, int32 color, const char *text) {
Bitmap *ds = _G(gfxDriver)->GetStageBackBuffer(true);
if (!ds)
return;
color_t text_color = ds->GetCompatibleColor(color);
draw_and_invalidate_text(ds, x, y, font, text_color, text);
}
void IAGSEngine::GetScreenDimensions(int32 *width, int32 *height, int32 *coldepth) {
if (width)
*width = _GP(play).GetMainViewport().GetWidth();
if (height)
*height = _GP(play).GetMainViewport().GetHeight();
if (coldepth)
*coldepth = _GP(scsystem).coldepth;
}
int IAGSEngine::GetBitmapPitch(BITMAP *bmp) {
return bmp->pitch;
}
uint8 *IAGSEngine::GetRawBitmapSurface(BITMAP *bmp) {
Bitmap *stage = _G(gfxDriver)->GetStageBackBuffer(true);
if (stage && bmp == stage->GetAllegroBitmap())
_GP(plugins)[this->pluginId].invalidatedRegion = 0;
return (uint8 *)bmp->getPixels();
}
void IAGSEngine::ReleaseBitmapSurface(BITMAP *bmp) {
Bitmap *stage = _G(gfxDriver)->GetStageBackBuffer(true);
if (stage && bmp == stage->GetAllegroBitmap()) {
// plugin does not manaually invalidate stuff, so
// we must invalidate the whole screen to be safe
if (!_GP(plugins)[this->pluginId].invalidatedRegion)
invalidate_screen();
}
}
void IAGSEngine::GetMousePosition(int32 *x, int32 *y) {
if (x) x[0] = _G(mousex);
if (y) y[0] = _G(mousey);
}
int IAGSEngine::GetCurrentRoom() {
return _G(displayed_room);
}
int IAGSEngine::GetNumBackgrounds() {
return _GP(thisroom).BgFrameCount;
}
int IAGSEngine::GetCurrentBackground() {
return _GP(play).bg_frame;
}
BITMAP *IAGSEngine::GetBackgroundScene(int32 index) {
return (BITMAP *)_GP(thisroom).BgFrames[index].Graphic->GetAllegroBitmap();
}
void IAGSEngine::GetBitmapDimensions(BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth) {
if (bmp == nullptr)
return;
if (width != nullptr)
width[0] = bmp->w;
if (height != nullptr)
height[0] = bmp->h;
if (coldepth != nullptr)
coldepth[0] = bitmap_color_depth(bmp);
}
void pl_set_file_handle(long data, Stream *stream) {
_G(pl_file_handle) = data;
_G(pl_file_stream) = stream;
}
void pl_clear_file_handle() {
_G(pl_file_handle) = -1;
_G(pl_file_stream) = nullptr;
}
int IAGSEngine::FRead(void *buffer, int32 len, int32 handle) {
if (handle != _G(pl_file_handle)) {
quitprintf("IAGSEngine::FRead: invalid file handle: %d", handle);
}
if (!_G(pl_file_stream)) {
quit("IAGSEngine::FRead: file stream not set");
}
return _G(pl_file_stream)->Read(buffer, len);
}
int IAGSEngine::FWrite(void *buffer, int32 len, int32 handle) {
if (handle != _G(pl_file_handle)) {
quitprintf("IAGSEngine::FWrite: invalid file handle: %d", handle);
}
if (!_G(pl_file_stream)) {
quit("IAGSEngine::FWrite: file stream not set");
}
return _G(pl_file_stream)->Write(buffer, len);
}
bool IAGSEngine::FSeek(soff_t offset, int origin, int32 handle) {
if (handle != _G(pl_file_handle)) {
quitprintf("IAGSEngine::FWrite: invalid file handle: %d", handle);
}
if (!_G(pl_file_stream)) {
quit("IAGSEngine::FWrite: file stream not set");
}
return _G(pl_file_stream)->Seek(offset, (AGS::Shared::StreamSeek)origin);
}
void IAGSEngine::DrawTextWrapped(int32 xx, int32 yy, int32 wid, int32 font, int32 color, const char *text) {
// TODO: use generic function from the engine instead of having copy&pasted code here
const int linespacing = get_font_linespacing(font);
if (break_up_text_into_lines(text, _GP(Lines), wid, font) == 0)
return;
Bitmap *ds = _G(gfxDriver)->GetStageBackBuffer(true);
if (!ds)
return;
color_t text_color = ds->GetCompatibleColor(color);
data_to_game_coords((int *)&xx, (int *)&yy); // stupid! quick tweak
for (size_t i = 0; i < _GP(Lines).Count(); i++)
draw_and_invalidate_text(ds, xx, yy + linespacing * i, font, text_color, _GP(Lines)[i].GetCStr());
}
void IAGSEngine::SetVirtualScreen(BITMAP *bmp) {
if (!_G(gfxDriver)->UsesMemoryBackBuffer()) {
debug_script_warn("SetVirtualScreen: this plugin requires software graphics driver to work correctly.");
return;
}
if (bmp) {
_GP(glVirtualScreenWrap).WrapAllegroBitmap(bmp, true);
_G(gfxDriver)->SetStageBackBuffer(&_GP(glVirtualScreenWrap));
} else {
_GP(glVirtualScreenWrap).Destroy();
_G(gfxDriver)->SetStageBackBuffer(nullptr);
}
}
int IAGSEngine::LookupParserWord(const char *word) {
return find_word_in_dictionary(word);
}
void IAGSEngine::BlitBitmap(int32 x, int32 y, BITMAP *bmp, int32 masked) {
Bitmap *ds = _G(gfxDriver)->GetStageBackBuffer(true);
if (!ds)
return;
wputblock_raw(ds, x, y, bmp, masked);
invalidate_rect(x, y, x + bmp->w, y + bmp->h, false);
}
void IAGSEngine::BlitSpriteTranslucent(int32 x, int32 y, BITMAP *bmp, int32 trans) {
Bitmap *ds = _G(gfxDriver)->GetStageBackBuffer(true);
if (!ds)
return;
Bitmap wrap(bmp, true);
if (_G(gfxDriver)->UsesMemoryBackBuffer())
GfxUtil::DrawSpriteWithTransparency(ds, &wrap, x, y, trans);
else
GfxUtil::DrawSpriteBlend(ds, Point(x, y), &wrap, kBlendMode_Alpha, true, false, trans);
}
void IAGSEngine::BlitSpriteRotated(int32 x, int32 y, BITMAP *bmp, int32 angle) {
Bitmap *ds = _G(gfxDriver)->GetStageBackBuffer(true);
if (!ds)
return;
// FIXME: call corresponding Graphics Blit
rotate_sprite(ds->GetAllegroBitmap(), bmp, x, y, itofix(angle));
}
void IAGSEngine::PollSystem() {
update_polled_stuff();
ags_domouse();
eAGSMouseButton mbut;
int mwheelz;
if (run_service_mb_controls(mbut, mwheelz) && mbut > kMouseNone && !_GP(play).IsIgnoringInput())
pl_run_plugin_hooks(AGSE_MOUSECLICK, mbut);
KeyInput kp;
if (run_service_key_controls(kp) && !_GP(play).IsIgnoringInput()) {
pl_run_plugin_hooks(AGSE_KEYPRESS, kp.Key);
}
}
AGSCharacter *IAGSEngine::GetCharacter(int32 charnum) {
if (charnum >= _GP(game).numcharacters)
quit("!AGSEngine::GetCharacter: invalid character request");
return (AGSCharacter *)&_GP(game).chars[charnum];
}
AGSGameOptions *IAGSEngine::GetGameOptions() {
return (AGSGameOptions *)&_GP(play);
}
AGSColor *IAGSEngine::GetPalette() {
return (AGSColor *)&_G(palette)[0];
}
void IAGSEngine::SetPalette(int32 start, int32 finish, AGSColor *cpl) {
set_palette_range((RGB *)cpl, start, finish, 0);
}
int IAGSEngine::GetNumCharacters() {
return _GP(game).numcharacters;
}
int IAGSEngine::GetPlayerCharacter() {
return _GP(game).playercharacter;
}
void IAGSEngine::RoomToViewport(int32 *x, int32 *y) {
Point scrp = _GP(play).RoomToScreen(x ? data_to_game_coord(*x) : 0, y ? data_to_game_coord(*y) : 0);
if (x)
*x = scrp.X;
if (y)
*y = scrp.Y;
}
void IAGSEngine::ViewportToRoom(int32 *x, int32 *y) {
// NOTE: This is an old function that did not account for custom/multiple viewports
// and does not expect to fail, therefore we always use primary viewport here.
// (Not sure if it's good though)
VpPoint vpt = _GP(play).ScreenToRoom(x ? game_to_data_coord(*x) : 0, y ? game_to_data_coord(*y) : 0);
if (x)
*x = vpt.first.X;
if (y)
*y = vpt.first.Y;
}
int IAGSEngine::GetNumObjects() {
return _G(croom)->numobj;
}
AGSObject *IAGSEngine::GetObject(int32 num) {
if (num < 0 || static_cast<uint32_t>(num) >= _G(croom)->numobj)
quit("!IAGSEngine::GetObject: invalid object");
return (AGSObject *)&_G(croom)->obj[num];
}
BITMAP *IAGSEngine::CreateBlankBitmap(int32 width, int32 height, int32 coldep) {
// [IKM] We should not create Bitmap object here, because
// a) we are returning raw allegro bitmap and therefore losing control over it
// b) plugin won't use Bitmap anyway
BITMAP *tempb = create_bitmap_ex(coldep, width, height);
clear_to_color(tempb, bitmap_mask_color(tempb));
return tempb;
}
void IAGSEngine::FreeBitmap(BITMAP *tofree) {
if (tofree)
destroy_bitmap(tofree);
}
BITMAP *IAGSEngine::GetSpriteGraphic(int32 num) {
return (BITMAP *)_GP(spriteset)[num]->GetAllegroBitmap();
}
BITMAP *IAGSEngine::GetRoomMask(int32 index) {
if (index == MASK_WALKABLE)
return (BITMAP *)_GP(thisroom).WalkAreaMask->GetAllegroBitmap();
else if (index == MASK_WALKBEHIND)
return (BITMAP *)_GP(thisroom).WalkBehindMask->GetAllegroBitmap();
else if (index == MASK_HOTSPOT)
return (BITMAP *)_GP(thisroom).HotspotMask->GetAllegroBitmap();
else if (index == MASK_REGIONS)
return (BITMAP *)_GP(thisroom).RegionMask->GetAllegroBitmap();
else
quit("!IAGSEngine::GetRoomMask: invalid mask requested");
return nullptr;
}
AGSViewFrame *IAGSEngine::GetViewFrame(int32 view, int32 loop, int32 frame) {
view--;
if ((view < 0) || (view >= _GP(game).numviews))
quit("!IAGSEngine::GetViewFrame: invalid view");
if ((loop < 0) || (loop >= _GP(views)[view].numLoops))
quit("!IAGSEngine::GetViewFrame: invalid loop");
if ((frame < 0) || (frame >= _GP(views)[view].loops[loop].numFrames))
return nullptr;
return (AGSViewFrame *)&_GP(views)[view].loops[loop].frames[frame];
}
int IAGSEngine::GetRawPixelColor(int32 color) {
// Convert the standardized colour to the local gfx mode color
// NOTE: it is unclear whether this has to be game colour depth or display color depth.
// there was no difference in the original engine, but there is now.
int result;
__my_setcolor(&result, color, _GP(game).GetColorDepth());
return result;
}
int IAGSEngine::GetWalkbehindBaseline(int32 wa) {
if ((wa < 1) || (wa >= MAX_WALK_BEHINDS))
quit("!IAGSEngine::GetWalkBehindBase: invalid walk-behind area specified");
return _G(croom)->walkbehind_base[wa];
}
Plugins::PluginMethod IAGSEngine::GetScriptFunctionAddress(const char *funcName) {
return ccGetSymbolAddressForPlugin(funcName);
}
int IAGSEngine::GetBitmapTransparentColor(BITMAP *bmp) {
return bitmap_mask_color(bmp);
}
// get the character scaling level at a particular point
int IAGSEngine::GetAreaScaling(int32 x, int32 y) {
return GetScalingAt(x, y);
}
int IAGSEngine::IsGamePaused() {
return _G(game_paused);
}
int IAGSEngine::GetSpriteWidth(int32 slot) {
return _GP(game).SpriteInfos[slot].Width;
}
int IAGSEngine::GetSpriteHeight(int32 slot) {
return _GP(game).SpriteInfos[slot].Height;
}
void IAGSEngine::GetTextExtent(int32 font, const char *text, int32 *width, int32 *height) {
if ((font < 0) || (font >= _GP(game).numfonts)) {
if (width != nullptr) width[0] = 0;
if (height != nullptr) height[0] = 0;
return;
}
if (width != nullptr)
width[0] = get_text_width_outlined(text, font);
if (height != nullptr)
height[0] = get_font_height_outlined(font);
}
void IAGSEngine::PrintDebugConsole(const char *text) {
debug_script_log("[PLUGIN] %s", text);
}
int IAGSEngine::IsChannelPlaying(int32 channel) {
return AGS3::IsChannelPlaying(channel);
}
void IAGSEngine::PlaySoundChannel(int32 channel, int32 soundType, int32 volume, int32 loop, const char *filename) {
stop_and_destroy_channel(channel);
// Not sure if it's right to let it play on *any* channel, but this is plugin so let it go...
// we must correctly stop background voice speech if it takes over speech chan
if (channel == SCHAN_SPEECH && _GP(play).IsNonBlockingVoiceSpeech())
stop_voice_nonblocking();
SOUNDCLIP *newcha = nullptr;
AssetPath asset_name(filename, "audio");
switch (soundType) {
case PSND_WAVE:
newcha = my_load_wave(asset_name, (loop != 0)); break;
case PSND_MP3STREAM:
case PSND_MP3STATIC:
newcha = my_load_mp3(asset_name, (loop != 0)); break;
case PSND_OGGSTREAM:
case PSND_OGGSTATIC:
newcha = my_load_ogg(asset_name, (loop != 0)); break;
case PSND_MIDI:
if (_GP(play).silent_midi != 0 || _G(current_music_type) == MUS_MIDI) {
debug_script_warn("IAGSEngine::PlaySoundChannel: MIDI already in use");
return;
}
newcha = my_load_midi(asset_name, (loop != 0)); break;
case PSND_MOD:
newcha = my_load_mod(asset_name, (loop != 0)); break;
default:
debug_script_warn("IAGSEngine::PlaySoundChannel: unknown sound type %d", soundType);
return;
}
newcha->set_volume255(volume);
AudioChans::SetChannel(channel, newcha);
}
// Engine interface 12 and above are below
void IAGSEngine::MarkRegionDirty(int32 left, int32 top, int32 right, int32 bottom) {
invalidate_rect(left, top, right, bottom, false);
_GP(plugins)[this->pluginId].invalidatedRegion++;
}
AGSMouseCursor *IAGSEngine::GetMouseCursor(int32 cursor) {
if ((cursor < 0) || (cursor >= _GP(game).numcursors))
return nullptr;
return (AGSMouseCursor *)&_GP(game).mcurs[cursor];
}
void IAGSEngine::GetRawColorComponents(int32 coldepth, int32 color, int32 *red, int32 *green, int32 *blue, int32 *alpha) {
if (red)
*red = getr_depth(coldepth, color);
if (green)
*green = getg_depth(coldepth, color);
if (blue)
*blue = getb_depth(coldepth, color);
if (alpha)
*alpha = geta_depth(coldepth, color);
}
int IAGSEngine::MakeRawColorPixel(int32 coldepth, int32 red, int32 green, int32 blue, int32 alpha) {
return makeacol_depth(coldepth, red, green, blue, alpha);
}
int IAGSEngine::GetFontType(int32 fontNum) {
if ((fontNum < 0) || (fontNum >= _GP(game).numfonts))
return FNT_INVALID;
if (is_bitmap_font(fontNum))
return FNT_TTF;
return FNT_SCI;
}
int IAGSEngine::CreateDynamicSprite(int32 coldepth, int32 width, int32 height) {
if ((width < 1) || (height < 1))
quit("!IAGSEngine::CreateDynamicSprite: invalid width/height requested by plugin");
if (!_GP(spriteset).HasFreeSlots())
return 0;
std::unique_ptr<Bitmap> image(BitmapHelper::CreateTransparentBitmap(width, height, coldepth));
if (!image)
return 0;
// add it into the sprite set
return add_dynamic_sprite(std::move(image));
}
void IAGSEngine::DeleteDynamicSprite(int32 slot) {
free_dynamic_sprite(slot);
}
int IAGSEngine::IsSpriteAlphaBlended(int32 slot) {
if (_GP(game).SpriteInfos[slot].Flags & SPF_ALPHACHANNEL)
return 1;
return 0;
}
// disable AGS's sound engine
void IAGSEngine::DisableSound() {
shutdown_sound();
}
int IAGSEngine::CanRunScriptFunctionNow() {
if (_G(inside_script))
return 0;
return 1;
}
int IAGSEngine::CallGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, long arg1, long arg2, long arg3) {
if (_G(inside_script))
return -300;
ccInstance *toRun = GetScriptInstanceByType(globalScript ? kScInstGame : kScInstRoom);
RuntimeScriptValue params[]{
RuntimeScriptValue().SetPluginArgument(arg1),
RuntimeScriptValue().SetPluginArgument(arg2),
RuntimeScriptValue().SetPluginArgument(arg3),
};
int toret = RunScriptFunction(toRun, name, numArgs, params);
return toret;
}
void IAGSEngine::NotifySpriteUpdated(int32 slot) {
game_sprite_updated(slot);
}
void IAGSEngine::SetSpriteAlphaBlended(int32 slot, int32 isAlphaBlended) {
_GP(game).SpriteInfos[slot].Flags &= ~SPF_ALPHACHANNEL;
if (isAlphaBlended)
_GP(game).SpriteInfos[slot].Flags |= SPF_ALPHACHANNEL;
}
void IAGSEngine::QueueGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, long arg1, long arg2) {
if (!_G(inside_script)) {
this->CallGameScriptFunction(name, globalScript, numArgs, arg1, arg2, 0);
return;
}
if (numArgs < 0 || numArgs > 2)
quit("IAGSEngine::QueueGameScriptFunction: invalid number of arguments");
RuntimeScriptValue params[]{ RuntimeScriptValue().SetPluginArgument(arg1),
RuntimeScriptValue().SetPluginArgument(arg2) };
_G(curscript)->run_another(name, globalScript ? kScInstGame : kScInstRoom, numArgs, params);
}
int IAGSEngine::RegisterManagedObject(void *object, IAGSScriptManagedObject *callback) {
_GP(GlobalReturnValue).SetPluginObject(object, (IScriptObject *)callback);
return ccRegisterManagedObject(object, (IScriptObject *)callback, kScValPluginObject);
}
void IAGSEngine::AddManagedObjectReader(const char *typeName, IAGSManagedObjectReader *reader) {
if ((typeName == nullptr) || (typeName[0] == 0))
quit("Plugin error: IAGSEngine::AddObjectReader: invalid name for type");
for (const auto &pr : _GP(pluginReaders)) {
if (pr.Type == typeName)
quitprintf("Plugin error: IAGSEngine::AddObjectReader: type '%s' has been registered already", pr.Type.GetCStr());
}
_GP(pluginReaders).push_back(PluginObjectReader(typeName, reinterpret_cast<ICCObjectReader*>(reader)));
}
void IAGSEngine::RegisterUnserializedObject(int key, void *object, IAGSScriptManagedObject *callback) {
_GP(GlobalReturnValue).SetPluginObject(object, (IScriptObject *)callback);
ccRegisterUnserializedObject(key, object, (IScriptObject *)callback, kScValPluginObject);
}
int IAGSEngine::GetManagedObjectKeyByAddress(void *address) {
return ccGetObjectHandleFromAddress(address);
}
void *IAGSEngine::GetManagedObjectAddressByKey(int key) {
void *object;
IScriptObject *manager;
ScriptValueType obj_type = ccGetObjectAddressAndManagerFromHandle(key, object, manager);
_GP(GlobalReturnValue).SetScriptObject(obj_type, object, manager);
return object;
}
const char *IAGSEngine::CreateScriptString(const char *fromText) {
const char *string = CreateNewScriptString(fromText);
// Should be still standard dynamic object, because not managed by plugin
_GP(GlobalReturnValue).SetScriptObject(const_cast<char *>(string), &_GP(myScriptStringImpl));
return string;
}
int IAGSEngine::IncrementManagedObjectRefCount(void *address) {
return ccAddObjectReference(GetManagedObjectKeyByAddress(address));
}
int IAGSEngine::DecrementManagedObjectRefCount(void *address) {
return ccReleaseObjectReference(GetManagedObjectKeyByAddress(address));
}
void IAGSEngine::SetMousePosition(int32 x, int32 y) {
_GP(mouse).SetPosition(Point(x, y));
RefreshMouse();
}
void IAGSEngine::SimulateMouseClick(int32 button) {
AGS3::SimulateMouseClick(button);
}
int IAGSEngine::GetMovementPathWaypointCount(int32 pathId) {
return _GP(mls)[pathId % TURNING_AROUND].numstage;
}
int IAGSEngine::GetMovementPathLastWaypoint(int32 pathId) {
return _GP(mls)[pathId % TURNING_AROUND].onstage;
}
void IAGSEngine::GetMovementPathWaypointLocation(int32 pathId, int32 waypoint, int32 *x, int32 *y) {
*x = _GP(mls)[pathId % TURNING_AROUND].pos[waypoint].X;
*y = _GP(mls)[pathId % TURNING_AROUND].pos[waypoint].Y;
}
void IAGSEngine::GetMovementPathWaypointSpeed(int32 pathId, int32 waypoint, int32 *xSpeed, int32 *ySpeed) {
*xSpeed = _GP(mls)[pathId % TURNING_AROUND].xpermove[waypoint];
*ySpeed = _GP(mls)[pathId % TURNING_AROUND].ypermove[waypoint];
}
int IAGSEngine::IsRunningUnderDebugger() {
return (_G(editor_debugging_enabled) != 0) ? 1 : 0;
}
void IAGSEngine::GetPathToFileInCompiledFolder(const char *fileName, char *buffer) {
// TODO: this is very unsafe, deprecate and make a better API function if still necessary
strcpy(buffer, PathFromInstallDir(fileName).GetCStr());
}
void IAGSEngine::BreakIntoDebugger() {
_G(break_on_next_script_step) = 1;
}
IAGSFontRenderer *IAGSEngine::ReplaceFontRenderer(int fontNumber, IAGSFontRenderer *newRenderer) {
auto *old_render = font_replace_renderer(fontNumber, newRenderer);
GUI::MarkForFontUpdate(fontNumber);
return old_render;
}
const char *IAGSEngine::ResolveFilePath(const char *script_path) {
return File_ResolvePath(script_path);
}
void IAGSEngine::GetRenderStageDesc(AGSRenderStageDesc *desc) {
if (desc->Version >= 25) {
_G(gfxDriver)->GetStageMatrixes((RenderMatrixes &)desc->Matrixes);
}
}
void IAGSEngine::GetGameInfo(AGSGameInfo* ginfo) {
if (ginfo->Version >= 26) {
snprintf(ginfo->GameName, sizeof(ginfo->GameName), "%s", _GP(game).gamename.GetCStr());
snprintf(ginfo->Guid, sizeof(ginfo->Guid), "%s", _GP(game).guid);
ginfo->UniqueId = _GP(game).uniqueid;
}
}
IAGSFontRenderer* IAGSEngine::ReplaceFontRenderer2(int fontNumber, IAGSFontRenderer2 *newRenderer) {
auto *old_render = font_replace_renderer(fontNumber, newRenderer);
GUI::MarkForFontUpdate(fontNumber);
return old_render;
}
void IAGSEngine::NotifyFontUpdated(int fontNumber) {
font_recalc_metrics(fontNumber);
GUI::MarkForFontUpdate(fontNumber);
}
// *********** General plugin implementation **********
void pl_stop_plugins() {
uint a;
ccSetDebugHook(nullptr);
for (a = 0; a < _GP(plugins).size(); a++) {
if (_GP(plugins)[a].available) {
_GP(plugins)[a]._plugin->AGS_EngineShutdown();
_GP(plugins)[a].wantHook = 0;
if (!_GP(plugins)[a].builtin) {
_GP(plugins)[a].library.Unload();
}
}
}
_GP(plugins).clear();
_GP(plugins).reserve(MAXPLUGINS);
}
void pl_startup_plugins() {
for (uint i = 0; i < _GP(plugins).size(); i++) {
if (i == 0)
_GP(engineExports).AGS_EngineStartup(&_GP(plugins)[0].eiface);
if (_GP(plugins)[i].available) {
EnginePlugin &ep = _GP(plugins)[i];
ep._plugin->AGS_EngineStartup(&ep.eiface);
}
}
}
NumberPtr pl_run_plugin_hooks(int event, NumberPtr data) {
int retval = 0;
for (uint i = 0; i < _GP(plugins).size(); i++) {
if (_GP(plugins)[i].wantHook & event) {
retval = _GP(plugins)[i]._plugin->AGS_EngineOnEvent(event, data);
if (retval)
return retval;
}
}
return 0;
}
int pl_run_plugin_debug_hooks(const char *scriptfile, int linenum) {
int retval = 0;
for (uint i = 0; i < _GP(plugins).size(); i++) {
if (_GP(plugins)[i].wantHook & AGSE_SCRIPTDEBUG) {
retval = _GP(plugins)[i]._plugin->AGS_EngineDebugHook(scriptfile, linenum, 0);
if (retval)
return retval;
}
}
return 0;
}
bool pl_query_next_plugin_for_event(int event, uint32_t &pl_index, String &pl_name) {
for (uint32_t i = pl_index; i < _GP(plugins).size(); ++i) {
if (_GP(plugins)[i].wantHook & event) {
pl_index = i;
pl_name = _GP(plugins)[i].filename;
return true;
}
}
return false;
}
int pl_run_plugin_hook_by_index(uint32_t pl_index, int event, int data) {
if (pl_index >= _GP(plugins).size())
return 0;
auto &plugin = _GP(plugins)[pl_index];
if (plugin.wantHook & event) {
return plugin._plugin->AGS_EngineOnEvent(event, data);
}
return 0;
}
int pl_run_plugin_hook_by_name(Shared::String &pl_name, int event, int data) {
for (auto &plugin : _GP(plugins)) {
if ((plugin.wantHook & event) && plugin.filename.CompareNoCase(pl_name) == 0) {
return plugin._plugin->AGS_EngineOnEvent(event, data);
}
}
return 0;
}
void pl_run_plugin_init_gfx_hooks(const char *driverName, void *data) {
for (uint i = 0; i < _GP(plugins).size(); i++) {
_GP(plugins)[i]._plugin->AGS_EngineInitGfx(driverName, data);
}
}
Engine::GameInitError pl_register_plugins(const std::vector<PluginInfo> &infos) {
_GP(plugins).clear();
_GP(plugins).reserve(MAXPLUGINS);
for (size_t inf_index = 0; inf_index < infos.size(); ++inf_index) {
const Shared::PluginInfo &info = infos[inf_index];
String name = info.Name;
if (name.GetLast() == '!')
continue; // editor-only plugin, ignore it
// AGS Editor currently saves plugin names in game data with
// ".dll" extension appended; we need to take care of that
const String name_ext = ".dll";
if (name.GetLength() <= name_ext.GetLength() || name.CompareRightNoCase(name_ext, name_ext.GetLength())) {
return kGameInitErr_PluginNameInvalid;
}
// remove ".dll" from plugin's name
name.ClipRight(name_ext.GetLength());
_GP(plugins).resize(_GP(plugins).size() + 1);
EnginePlugin *apl = &_GP(plugins).back();
// Copy plugin info
apl->filename = name;
apl->savedata = info.Data;
// Compatibility with the old SnowRain module
if (apl->filename.CompareNoCase("ags_SnowRain20") == 0) {
apl->filename = "ags_snowrain";
}
if (apl->library.Load(apl->filename)) {
apl->_plugin = apl->library.getPlugin();
AGS::Shared::Debug::Printf(kDbgMsg_Info, "Plugin '%s' loaded, resolving imports...", apl->filename.GetCStr());
} else {
String expect_filename = apl->library.GetFilenameForLib(apl->filename);
AGS::Shared::Debug::Printf(kDbgMsg_Info, "Plugin '%s' could not be loaded (expected '%s')",
apl->filename.GetCStr(), expect_filename.GetCStr());
_GP(plugins).pop_back();
continue;
}
apl->eiface.pluginId = _GP(plugins).size() - 1;
apl->eiface.version = PLUGIN_API_VERSION;
apl->wantHook = 0;
apl->available = true;
}
return kGameInitErr_NoError;
}
bool pl_is_plugin_loaded(const char *pl_name) {
if (!pl_name)
return false;
for (uint i = 0; i < _GP(plugins).size(); ++i) {
if (ags_stricmp(pl_name, _GP(plugins)[i].filename) == 0)
return _GP(plugins)[i].available;
}
return false;
}
bool pl_any_want_hook(int event) {
for (uint i = 0; i < _GP(plugins).size(); ++i) {
if (_GP(plugins)[i].wantHook & event)
return true;
}
return false;
}
} // namespace AGS3

View File

@@ -0,0 +1,584 @@
/* 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
* (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/>.
*
*/
//=============================================================================
//
// AGS Plugin interface header file.
//
// #define THIS_IS_THE_PLUGIN beforehand if including from the plugin.
//
//=============================================================================
#ifndef AGS_PLUGINS_AGS_PLUGIN_H
#define AGS_PLUGINS_AGS_PLUGIN_H
#include "common/array.h"
#include "ags/shared/core/types.h"
#include "ags/shared/font/ags_font_renderer.h"
#include "ags/shared/util/string.h"
#include "ags/plugins/plugin_base.h"
#include "ags/plugins/ags_plugin_evts.h"
#include "ags/engine/util/library_scummvm.h"
namespace AGS3 {
// If the plugin isn't using DDraw, don't require the headers
#ifndef DIRECTDRAW_VERSION
typedef void *LPDIRECTDRAW2;
typedef void *LPDIRECTDRAWSURFACE2;
#endif
#ifndef DIRECTSOUND_VERSION
typedef void *LPDIRECTSOUND;
#endif
#ifndef DIRECTINPUT_VERSION
typedef void *LPDIRECTINPUTDEVICE;
#endif
class BITMAP;
// If not using windows.h, define HWND
#if !defined(_WINDOWS_)
typedef int HWND;
#endif
#define MAXPLUGINS 20
#define AGSIFUNC(type) virtual type
#define MASK_WALKABLE 1
#define MASK_WALKBEHIND 2
#define MASK_HOTSPOT 3
// MASK_REGIONS is interface version 11 and above only
#define MASK_REGIONS 4
#define PLUGIN_FILENAME_MAX (49)
// **** WARNING: DO NOT ALTER THESE CLASSES IN ANY WAY!
// **** CHANGING THE ORDER OF THE FUNCTIONS OR ADDING ANY VARIABLES
// **** WILL CRASH THE SYSTEM.
struct AGSColor {
unsigned char r, g, b;
unsigned char padding;
};
struct AGSGameOptions {
int32 score; // player's current score
int32 usedmode; // set by ProcessClick to last cursor mode used
int32 disabled_user_interface; // >0 while in cutscene/etc
int32 gscript_timer; // obsolete
int32 debug_mode; // whether we're in debug mode
int32 globalvars[50]; // obsolete
int32 messagetime; // time left for auto-remove messages
int32 usedinv; // inventory item last used
int32 inv_top, inv_numdisp, inv_numorder, inv_numinline;
int32 text_speed; // how quickly text is removed
int32 sierra_inv_color; // background used to paint defualt inv window
int32 talkanim_speed; // animation speed of talking anims
int32 inv_item_wid, inv_item_hit; // set by SetInvDimensions
int32 speech_text_shadow; // colour of outline fonts (default black)
int32 swap_portrait_side; // sierra-style speech swap sides
int32 speech_textwindow_gui; // textwindow used for sierra-style speech
int32 follow_change_room_timer; // delay before moving following characters into new room
int32 totalscore; // maximum possible score
int32 skip_display; // how the user can skip normal Display windows
int32 no_multiloop_repeat; // for backwards compatibility
int32 roomscript_finished; // on_call finished in room
int32 used_inv_on; // inv item they clicked on
int32 no_textbg_when_voice; // no textwindow bgrnd when voice speech is used
int32 max_dialogoption_width; // max width of dialog options text window
int32 no_hicolor_fadein; // fade out but instant in for hi-color
int32 bgspeech_game_speed; // is background speech relative to game speed
int32 bgspeech_stay_on_display; // whether to remove bg speech when DisplaySpeech is used
int32 unfactor_speech_from_textlength; // remove "&10" when calculating time for text to stay
int32 mp3_loop_before_end; // loop this time before end of track (ms)
int32 speech_music_drop; // how much to drop music volume by when speech is played
int32 in_cutscene; // we are between a StartCutscene and EndCutscene
int32 fast_forward; // player has elected to skip cutscene
int32 room_width; // width of current room
int32 room_height; // height of current room
};
// AGSCharacter.flags
#define CHF_NOSCALING 1
#define CHF_FIXVIEW 2 // between SetCharView and ReleaseCharView
#define CHF_NOINTERACT 4
#define CHF_NODIAGONAL 8
#define CHF_ALWAYSIDLE 0x10
#define CHF_NOLIGHTING 0x20
#define CHF_NOTURNING 0x40
#define CHF_NOWALKBEHINDS 0x80
struct AGSCharacter {
int32 defview = 0;
int32 talkview = 0;
int32 view = 0;
int32 room = 0, prevroom = 0;
int32 x = 0, y = 0, wait = 0;
int32 flags = 0;
short following = 0;
short followinfo = 0;
int32 idleview = 0; // the loop will be randomly picked
short idletime = 0, idleleft = 0; // num seconds idle before playing anim
short transparency = 0; // if character is transparent
short baseline = 0;
int32 activeinv = 0;
int32 talkcolor = 0;
int32 thinkview = 0;
int32 reserved[2];
short walkspeed_y = 0, pic_yoffs = 0;
int32 z = 0;
int32 reserved2[5];
short loop = 0, frame = 0;
short walking = 0, animating = 0;
short walkspeed = 0, animspeed = 0;
short inv[301];
short actx = 0, acty = 0;
char name[40];
char scrname[20];
int8 on = 0;
};
// AGSObject.flags
#define OBJF_NOINTERACT 0x01 // not clickable
#define OBJF_NOWALKBEHINDS 0x02 // ignore walk-behinds
struct AGSObject {
int32 x = 0, y = 0;
int32 transparent = 0; // current transparency setting
int32 reserved[4];
short num = 0; // sprite slot number
short baseline = 0; // <=0 to use Y co-ordinate; >0 for specific baseline
short view = 0, loop = 0, frame = 0; // only used to track animation - 'num' holds the current sprite
short wait = 0, moving = 0;
int8 cycling = 0; // is it currently animating?
int8 overall_speed = 0;
int8 on = 0;
int8 flags = 0;
};
// AGSViewFrame.flags
#define FRAF_MIRRORED 1 // flipped left to right
struct AGSViewFrame {
int32 pic = 0; // sprite slot number
short xoffs = 0, yoffs = 0;
short speed = 0;
int32 flags = 0;
int32 sound = 0; // play sound when this frame comes round
int32 reserved_for_future[2];
};
// AGSMouseCursor.flags
#define MCF_ANIMATEMOVE 1
#define MCF_DISABLED 2
#define MCF_STANDARD 4
#define MCF_ONLYANIMOVERHOTSPOT 8
struct AGSMouseCursor {
int32 pic = 0; // sprite slot number
short hotx = 0, hoty = 0; // x,y hotspot co-ordinates
short view = 0; // view (for animating cursors) or -1
char name[10]; // name of cursor mode
int8 flags = 0; // MCF_flags above
};
// The editor-to-plugin interface
class IAGSEditor {
public:
int32 version = 0;
int32 pluginId = 0; // used internally, do not touch this
public:
virtual ~IAGSEditor() {}
// get the HWND of the main editor frame
AGSIFUNC(HWND) GetEditorHandle();
// get the HWND of the current active window
AGSIFUNC(HWND) GetWindowHandle();
// add some script to the default header
AGSIFUNC(void) RegisterScriptHeader(const char *header);
// de-register a script header (pass same pointer as when added)
AGSIFUNC(void) UnregisterScriptHeader(const char *header);
};
// GetFontType font types
#define FNT_INVALID 0
#define FNT_SCI 1
#define FNT_TTF 2
// PlaySoundChannel sound types
#define PSND_WAVE 1
#define PSND_MP3STREAM 2
#define PSND_MP3STATIC 3
#define PSND_OGGSTREAM 4
#define PSND_OGGSTATIC 5
#define PSND_MIDI 6
#define PSND_MOD 7
class IAGSScriptManagedObject {
public:
// when a ref count reaches 0, this is called with the address
// of the object. Return 1 to remove the object from memory, 0 to
// leave it
virtual int Dispose(void *address, bool force) = 0;
// return the type name of the object
virtual const char *GetType() = 0;
// serialize the object into BUFFER (which is BUFSIZE bytes)
// return number of bytes used
virtual int Serialize(void *address, char *buffer, int bufsize) = 0;
protected:
IAGSScriptManagedObject() {
}
virtual ~IAGSScriptManagedObject() {
}
};
class IAGSManagedObjectReader {
public:
virtual void Unserialize(int key, const char *serializedData, int dataSize) = 0;
protected:
IAGSManagedObjectReader() {
}
virtual ~IAGSManagedObjectReader() {
}
};
struct AGSRenderMatrixes {
float WorldMatrix[16];
float ViewMatrix[16];
float ProjMatrix[16];
};
// Render stage description
struct AGSRenderStageDesc {
// Which version of the plugin interface the struct corresponds to;
// this field must be filled by a plugin before passing the struct into the engine!
int Version = 0;
// Stage's matrixes, for 3D rendering: Projection, World and View
AGSRenderMatrixes Matrixes;
};
// Game info
struct AGSGameInfo {
// Which version of the plugin interface the struct corresponds to;
// this field must be filled by a plugin before passing the struct into the engine!
int Version;
// Game title (human-readable text)
char GameName[50];
// Game's GUID
char Guid[40];
// Random key identifying the game (deprecated)
int UniqueId;
};
// The plugin-to-engine interface
class IAGSEngine {
public:
int32 version = 0;
int32 pluginId = 0; // used internally, do not touch
public:
virtual ~IAGSEngine() {}
// quit the game
AGSIFUNC(void) AbortGame(const char *reason);
// get engine version
AGSIFUNC(const char *) GetEngineVersion();
// register a script function with the system
AGSIFUNC(void) RegisterScriptFunction(const char *name,
Plugins::ScriptContainer *instance);
AGSIFUNC(void) RegisterBuiltInFunction(const char *name,
Plugins::ScriptContainer *instance);
#ifdef WINDOWS_VERSION
// get game window handle
AGSIFUNC(HWND) GetWindowHandle();
// get reference to main DirectDraw interface
AGSIFUNC(LPDIRECTDRAW2) GetDirectDraw2();
// get the DDraw surface associated with a bitmap
AGSIFUNC(LPDIRECTDRAWSURFACE2) GetBitmapSurface(BITMAP *);
#endif
// get a reference to the screen bitmap
AGSIFUNC(BITMAP *) GetScreen();
// *** BELOW ARE INTERFACE VERSION 2 AND ABOVE ONLY
// ask the engine to call back when a certain event happens
AGSIFUNC(void) RequestEventHook(int32 event);
// get the options data saved in the editor
AGSIFUNC(int) GetSavedData(char *buffer, int32 bufsize);
// *** BELOW ARE INTERFACE VERSION 3 AND ABOVE ONLY
// get the virtual screen
AGSIFUNC(BITMAP *) GetVirtualScreen();
// write text to the screen in the specified font and colour
AGSIFUNC(void) DrawText(int32 x, int32 y, int32 font, int32 color, const char *text);
// get screen dimensions
AGSIFUNC(void) GetScreenDimensions(int32 *width, int32 *height, int32 *coldepth);
// get screen surface pitch
AGSIFUNC(int) GetBitmapPitch(BITMAP *);
// get screen surface to draw on
AGSIFUNC(uint8 *) GetRawBitmapSurface(BITMAP *);
// release the surface
AGSIFUNC(void) ReleaseBitmapSurface(BITMAP *);
// get the current mouse co-ordinates
AGSIFUNC(void) GetMousePosition(int32 *x, int32 *y);
// *** BELOW ARE INTERFACE VERSION 4 AND ABOVE ONLY
// get the current room number
AGSIFUNC(int) GetCurrentRoom();
// get the number of background scenes in this room
AGSIFUNC(int) GetNumBackgrounds();
// get the current background frame
AGSIFUNC(int) GetCurrentBackground();
// get a background scene bitmap
AGSIFUNC(BITMAP *) GetBackgroundScene(int32);
// get dimensions of a bitmap
AGSIFUNC(void) GetBitmapDimensions(BITMAP *bmp, int32 *width, int32 *height, int32 *coldepth);
// *** BELOW ARE INTERFACE VERSION 5 AND ABOVE ONLY
// similar to fwrite - buffer, size, filehandle
AGSIFUNC(int) FWrite(void *, int32, int32);
// similar to fread - buffer, size, filehandle
AGSIFUNC(int) FRead(void *, int32, int32);
// similar to fseek
AGSIFUNC(bool)FSeek(soff_t offset, int origin, int32 handle);
// print text, wrapping as usual
AGSIFUNC(void) DrawTextWrapped(int32 x, int32 y, int32 width, int32 font, int32 color, const char *text);
// set the current active 'screen'
AGSIFUNC(void) SetVirtualScreen(BITMAP *);
// look up a word in the parser dictionary
AGSIFUNC(int) LookupParserWord(const char *word);
// draw a bitmap to the active screen
AGSIFUNC(void) BlitBitmap(int32 x, int32 y, BITMAP *, int32 masked);
// update the mouse and music
AGSIFUNC(void) PollSystem();
// *** BELOW ARE INTERFACE VERSION 6 AND ABOVE ONLY
// get number of characters in game
AGSIFUNC(int) GetNumCharacters();
// get reference to specified character struct
AGSIFUNC(AGSCharacter *) GetCharacter(int32);
// get reference to game struct
AGSIFUNC(AGSGameOptions *) GetGameOptions();
// get reference to current palette
AGSIFUNC(AGSColor *) GetPalette();
// update palette
AGSIFUNC(void) SetPalette(int32 start, int32 finish, AGSColor *);
// *** BELOW ARE INTERFACE VERSION 7 AND ABOVE ONLY
// get the current player character
AGSIFUNC(int) GetPlayerCharacter();
// adjust to main viewport co-ordinates
AGSIFUNC(void) RoomToViewport(int32 *x, int32 *y);
// adjust from main viewport co-ordinates (ignores viewport bounds)
AGSIFUNC(void) ViewportToRoom(int32 *x, int32 *y);
// number of objects in current room
AGSIFUNC(int) GetNumObjects();
// get reference to specified object
AGSIFUNC(AGSObject *) GetObject(int32);
// get sprite graphic
AGSIFUNC(BITMAP *) GetSpriteGraphic(int32);
// create a new blank bitmap
AGSIFUNC(BITMAP *) CreateBlankBitmap(int32 width, int32 height, int32 coldep);
// free a created bitamp
AGSIFUNC(void) FreeBitmap(BITMAP *);
// *** BELOW ARE INTERFACE VERSION 8 AND ABOVE ONLY
// get one of the room area masks
AGSIFUNC(BITMAP *) GetRoomMask(int32);
// *** BELOW ARE INTERFACE VERSION 9 AND ABOVE ONLY
// get a particular view frame
AGSIFUNC(AGSViewFrame *) GetViewFrame(int32 view, int32 loop, int32 frame);
// get the walk-behind baseline of a specific WB area
AGSIFUNC(int) GetWalkbehindBaseline(int32 walkbehind);
// get the address of a script function
AGSIFUNC(Plugins::PluginMethod) GetScriptFunctionAddress(const char *funcName);
// get the transparent colour of a bitmap
AGSIFUNC(int) GetBitmapTransparentColor(BITMAP *);
// get the character scaling level at a particular point
AGSIFUNC(int) GetAreaScaling(int32 x, int32 y);
// equivalent to the text script function
AGSIFUNC(int) IsGamePaused();
// *** BELOW ARE INTERFACE VERSION 10 AND ABOVE ONLY
// get the raw pixel value to use for the specified AGS colour
AGSIFUNC(int) GetRawPixelColor(int32 color);
// *** BELOW ARE INTERFACE VERSION 11 AND ABOVE ONLY
// get the width / height of the specified sprite
AGSIFUNC(int) GetSpriteWidth(int32);
AGSIFUNC(int) GetSpriteHeight(int32);
// get the dimensions of the specified string in the specified font
AGSIFUNC(void) GetTextExtent(int32 font, const char *text, int32 *width, int32 *height);
// print a message to the debug console
AGSIFUNC(void) PrintDebugConsole(const char *text);
// play a sound on the specified channel
AGSIFUNC(void) PlaySoundChannel(int32 channel, int32 soundType, int32 volume, int32 loop, const char *filename);
// same as text script function
AGSIFUNC(int) IsChannelPlaying(int32 channel);
// *** BELOW ARE INTERFACE VERSION 12 AND ABOVE ONLY
// invalidate a region of the virtual screen
AGSIFUNC(void) MarkRegionDirty(int32 left, int32 top, int32 right, int32 bottom);
// get mouse cursor details
AGSIFUNC(AGSMouseCursor *) GetMouseCursor(int32 cursor);
// get the various components of a pixel
AGSIFUNC(void) GetRawColorComponents(int32 coldepth, int32 color, int32 *red, int32 *green, int32 *blue, int32 *alpha);
// make a pixel colour from the supplied components
AGSIFUNC(int) MakeRawColorPixel(int32 coldepth, int32 red, int32 green, int32 blue, int32 alpha);
// get whether the font is TTF or SCI
AGSIFUNC(int) GetFontType(int32 fontNum);
// create a new dynamic sprite slot
AGSIFUNC(int) CreateDynamicSprite(int32 coldepth, int32 width, int32 height);
// free a created dynamic sprite
AGSIFUNC(void) DeleteDynamicSprite(int32 slot);
// check if a sprite has an alpha channel
AGSIFUNC(int) IsSpriteAlphaBlended(int32 slot);
// *** BELOW ARE INTERFACE VERSION 13 AND ABOVE ONLY
// un-request an event, requested earlier with RequestEventHook
AGSIFUNC(void) UnrequestEventHook(int32 event);
// draw a translucent bitmap to the active screen
AGSIFUNC(void) BlitSpriteTranslucent(int32 x, int32 y, BITMAP *, int32 trans);
// draw a sprite to the screen, but rotated around its centre
AGSIFUNC(void) BlitSpriteRotated(int32 x, int32 y, BITMAP *, int32 angle);
// *** BELOW ARE INTERFACE VERSION 14 AND ABOVE ONLY
#ifdef WINDOWS_VERSION
// get reference to main DirectSound interface
AGSIFUNC(LPDIRECTSOUND) GetDirectSound();
#endif
// disable AGS sound engine
AGSIFUNC(void) DisableSound();
// check whether a script function can be run now
AGSIFUNC(int) CanRunScriptFunctionNow();
// call a user-defined script function
AGSIFUNC(int) CallGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, long arg1 = 0, long arg2 = 0, long arg3 = 0);
// *** BELOW ARE INTERFACE VERSION 15 AND ABOVE ONLY
// force any sprites on-screen using the slot to be updated
AGSIFUNC(void) NotifySpriteUpdated(int32 slot);
// change whether the specified sprite is a 32-bit alpha blended image
AGSIFUNC(void) SetSpriteAlphaBlended(int32 slot, int32 isAlphaBlended);
// run the specified script function whenever script engine is available
AGSIFUNC(void) QueueGameScriptFunction(const char *name, int32 globalScript, int32 numArgs, long arg1 = 0, long arg2 = 0);
// register a new dynamic managed script object
AGSIFUNC(int) RegisterManagedObject(void *object, IAGSScriptManagedObject *callback);
// add an object reader for the specified object type
AGSIFUNC(void) AddManagedObjectReader(const char *typeName, IAGSManagedObjectReader *reader);
// register an un-serialized managed script object
AGSIFUNC(void) RegisterUnserializedObject(int key, void *object, IAGSScriptManagedObject *callback);
// *** BELOW ARE INTERFACE VERSION 16 AND ABOVE ONLY
// get the address of a managed object based on its key
AGSIFUNC(void *) GetManagedObjectAddressByKey(int key);
// get managed object's key from its address
AGSIFUNC(int) GetManagedObjectKeyByAddress(void *address);
// *** BELOW ARE INTERFACE VERSION 17 AND ABOVE ONLY
// create a new script string
AGSIFUNC(const char *) CreateScriptString(const char *fromText);
// *** BELOW ARE INTERFACE VERSION 18 AND ABOVE ONLY
// increment reference count
AGSIFUNC(int) IncrementManagedObjectRefCount(void *address);
// decrement reference count
AGSIFUNC(int) DecrementManagedObjectRefCount(void *address);
// set mouse position
AGSIFUNC(void) SetMousePosition(int32 x, int32 y);
// simulate the mouse being clicked
AGSIFUNC(void) SimulateMouseClick(int32 button);
// get number of waypoints on this movement path
AGSIFUNC(int) GetMovementPathWaypointCount(int32 pathId);
// get the last waypoint that the char/obj passed
AGSIFUNC(int) GetMovementPathLastWaypoint(int32 pathId);
// get the co-ordinates of the specified waypoint
AGSIFUNC(void) GetMovementPathWaypointLocation(int32 pathId, int32 waypoint, int32 *x, int32 *y);
// get the speeds of the specified waypoint
AGSIFUNC(void) GetMovementPathWaypointSpeed(int32 pathId, int32 waypoint, int32 *xSpeed, int32 *ySpeed);
// *** BELOW ARE INTERFACE VERSION 19 AND ABOVE ONLY
// get the current graphics driver ID
AGSIFUNC(const char *) GetGraphicsDriverID();
// *** BELOW ARE INTERFACE VERSION 22 AND ABOVE ONLY
// get whether we are running under the editor's debugger
AGSIFUNC(int) IsRunningUnderDebugger();
// tells the engine to break into the debugger when the next line of script is run
AGSIFUNC(void) BreakIntoDebugger();
// fills buffer with <install dir>\fileName, as appropriate
AGSIFUNC(void) GetPathToFileInCompiledFolder(const char *fileName, char *buffer);
// *** BELOW ARE INTERFACE VERSION 23 AND ABOVE ONLY
#ifdef WINDOWS_VERSION
// get reference to keyboard Direct Input device
AGSIFUNC(LPDIRECTINPUTDEVICE) GetDirectInputKeyboard();
// get reference to mouse Direct Input device
AGSIFUNC(LPDIRECTINPUTDEVICE) GetDirectInputMouse();
#endif
// install a replacement renderer for the specified font number
AGSIFUNC(IAGSFontRenderer *) ReplaceFontRenderer(int fontNumber, IAGSFontRenderer *newRenderer);
// *** BELOW ARE INTERFACE VERSION 25 AND ABOVE ONLY
// fills the provided AGSRenderStageDesc struct with current render stage description;
// please note that plugin MUST fill the struct's Version field before passing it into the function!
AGSIFUNC(void) GetRenderStageDesc(AGSRenderStageDesc *desc);
// *** BELOW ARE INTERFACE VERSION 26 AND ABOVE ONLY
// fills the provided AGSGameInfo struct
// please note that plugin MUST fill the struct's Version field before passing it into the function!
AGSIFUNC(void) GetGameInfo(AGSGameInfo* ginfo);
// install a replacement renderer (extended interface) for the specified font number
AGSIFUNC(IAGSFontRenderer*) ReplaceFontRenderer2(int fontNumber, IAGSFontRenderer2* newRenderer);
// notify the engine that certain custom font has been updated
AGSIFUNC(void) NotifyFontUpdated(int fontNumber);
// *** BELOW ARE INTERFACE VERSION 27 AND ABOVE ONLY
// Resolves a script path to a system filepath, same way as script command File.Open does.
AGSIFUNC(const char *) ResolveFilePath(const char *script_path);
};
struct EnginePlugin {
AGS::Shared::String filename;
AGS::Engine::Library library;
Plugins::PluginBase *_plugin = nullptr;
bool available = false;
std::vector<uint8_t> savedata;
int wantHook = 0;
int invalidatedRegion = 0;
bool builtin = false;
IAGSEngine eiface;
EnginePlugin() {
eiface.version = 0;
eiface.pluginId = 0;
}
};
extern void PluginSimulateMouseClick(int pluginButtonID);
} // namespace AGS3
#endif

View File

@@ -0,0 +1,70 @@
/* 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
* (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/>.
*
*/
//=============================================================================
//
// AGS Plugin interface header file.
// Engine events definition.
//
// If you are writing a plugin, include agsplugin.h instead.
//
//=============================================================================
#ifndef AGS_PLUGINS_AGS_PLUGIN_EVTS_H
#define AGS_PLUGINS_AGS_PLUGIN_EVTS_H
namespace AGS3 {
// Below are interface 3 and later
#define AGSE_KEYPRESS 1
#define AGSE_MOUSECLICK 2
#define AGSE_POSTSCREENDRAW 4
// Below are interface 4 and later
#define AGSE_PRESCREENDRAW 8
// Below are interface 5 and later
#define AGSE_SAVEGAME 0x10
#define AGSE_RESTOREGAME 0x20
// Below are interface 6 and later
#define AGSE_PREGUIDRAW 0x40
#define AGSE_LEAVEROOM 0x80
#define AGSE_ENTERROOM 0x100
#define AGSE_TRANSITIONIN 0x200
#define AGSE_TRANSITIONOUT 0x400
// Below are interface 12 and later
#define AGSE_FINALSCREENDRAW 0x800
#define AGSE_TRANSLATETEXT 0x1000
// Below are interface 13 and later
#define AGSE_SCRIPTDEBUG 0x2000
#define AGSE_AUDIODECODE 0x4000 // obsolete, no longer supported
// Below are interface 18 and later
#define AGSE_SPRITELOAD 0x8000
// Below are interface 21 and later
#define AGSE_PRERENDER 0x10000
// Below are interface 24 and later
#define AGSE_PRESAVEGAME 0x20000
#define AGSE_POSTRESTOREGAME 0x40000
// Below are interface 26 and later
#define AGSE_POSTROOMDRAW 0x80000
#define AGSE_TOOHIGH 0x100000
} // namespace AGS3
#endif

View File

@@ -0,0 +1,52 @@
/* 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
* (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/>.
*
*/
#include "ags/ags.h"
#include "ags/plugins/ags_shell/ags_shell.h"
namespace AGS3 {
namespace Plugins {
namespace AGSShell {
const char *AGSShell::AGS_GetPluginName() {
return "AGS shell plugin";
}
void AGSShell::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
// Make sure it's got the version with the features we need
if (_engine->version < 3)
_engine->AbortGame("Plugin needs engine version 3 or newer.");
SCRIPT_METHOD(ShellExecute, AGSShell::ShellExecute);
}
void AGSShell::ShellExecute(ScriptMethodParams &params) {
PARAMS3(const char *, operation, const char *, filename, const char *, parameters);
warning("Unsupported ShellExecute(%s, %s, %s) command", operation, filename, parameters);
params._result = 0;
}
} // namespace AGSShell
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_SHELL_H
#define AGS_PLUGINS_AGS_SHELL_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSShell {
class AGSShell : public PluginBase {
SCRIPT_HASH(AGSShell)
private:
void ShellExecute(ScriptMethodParams &params);
public:
AGSShell() : PluginBase() {}
virtual ~AGSShell() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
};
} // namespace AGSShell
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,225 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_snow_rain/ags_snow_rain.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSnowRain {
AGSSnowRain::AGSSnowRain() : PluginBase(),
_rain(false, _screenWidth, _screenHeight, _engine),
_snow(true, _screenWidth, _screenHeight, _engine) {
}
const char *AGSSnowRain::AGS_GetPluginName() {
// Return the plugin description
return "Snow/Rain plugin recreation";
}
void AGSSnowRain::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
SCRIPT_METHOD(srSetSnowDriftRange, AGSSnowRain::srSetSnowDriftRange);
SCRIPT_METHOD(srSetSnowDriftSpeed, AGSSnowRain::srSetSnowDriftSpeed);
SCRIPT_METHOD(srSetSnowFallSpeed, AGSSnowRain::srSetSnowFallSpeed);
SCRIPT_METHOD(srChangeSnowAmount, AGSSnowRain::srChangeSnowAmount);
SCRIPT_METHOD(srSetSnowBaseline, AGSSnowRain::srSetSnowBaseline);
SCRIPT_METHOD(srSetSnowTransparency, AGSSnowRain::srSetSnowTransparency);
SCRIPT_METHOD(srSetSnowDefaultView, AGSSnowRain::srSetSnowDefaultView);
SCRIPT_METHOD(srSetSnowWindSpeed, AGSSnowRain::srSetSnowWindSpeed);
SCRIPT_METHOD(srSetSnowAmount, AGSSnowRain::srSetSnowAmount);
SCRIPT_METHOD(srSetSnowView, AGSSnowRain::srSetSnowView);
SCRIPT_METHOD(srSetRainDriftRange, AGSSnowRain::srSetRainDriftRange);
SCRIPT_METHOD(srSetRainDriftSpeed, AGSSnowRain::srSetRainDriftSpeed);
SCRIPT_METHOD(srSetRainFallSpeed, AGSSnowRain::srSetRainFallSpeed);
SCRIPT_METHOD(srChangeRainAmount, AGSSnowRain::srChangeRainAmount);
SCRIPT_METHOD(srSetRainBaseline, AGSSnowRain::srSetRainBaseline);
SCRIPT_METHOD(srSetRainTransparency, AGSSnowRain::srSetRainTransparency);
SCRIPT_METHOD(srSetRainDefaultView, AGSSnowRain::srSetRainDefaultView);
SCRIPT_METHOD(srSetRainWindSpeed, AGSSnowRain::srSetRainWindSpeed);
SCRIPT_METHOD(srSetRainAmount, AGSSnowRain::srSetRainAmount);
SCRIPT_METHOD(srSetRainView, AGSSnowRain::srSetRainView);
SCRIPT_METHOD(srSetWindSpeed, AGSSnowRain::srSetWindSpeed);
SCRIPT_METHOD(srSetBaseline, AGSSnowRain::srSetBaseline);
_engine->RequestEventHook(AGSE_PREGUIDRAW);
_engine->RequestEventHook(AGSE_ENTERROOM);
_engine->RequestEventHook(AGSE_SAVEGAME);
_engine->RequestEventHook(AGSE_RESTOREGAME);
}
int64 AGSSnowRain::AGS_EngineOnEvent(int event, NumberPtr data) {
if (event == AGSE_PREGUIDRAW) {
if (_rain.IsActive())
_rain.Update();
if (_snow.IsActive())
_snow.UpdateWithDrift();
} else if (event == AGSE_ENTERROOM) {
// Get screen size when entering a room
_engine->GetScreenDimensions(&_screenWidth, &_screenHeight, &_screenColorDepth);
_rain.EnterRoom();
_snow.EnterRoom();
} else if (event == AGSE_RESTOREGAME) {
Serializer s(_engine, data, true);
_rain.syncGame(s);
_snow.syncGame(s);
} else if (event == AGSE_SAVEGAME) {
Serializer s(_engine, data, false);
_rain.syncGame(s);
_snow.syncGame(s);
}
return 0;
}
void AGSSnowRain::srSetWindSpeed(ScriptMethodParams &params) {
PARAMS1(int, value);
_snow.SetWindSpeed(value);
_rain.SetWindSpeed(value);
}
void AGSSnowRain::srSetBaseline(ScriptMethodParams &params) {
PARAMS2(int, top, int, bottom);
// FIXME: The original seems to take co-ordinates in 320x200,
// but still displays correctly at 640x400. So doubling must
// occur somewhere. For now, doing it here
if (_screenHeight == 400) {
top *= 2;
bottom *= 2;
}
_snow.SetBaseline(top, bottom);
_rain.SetBaseline(top, bottom);
}
void AGSSnowRain::srSetSnowDriftRange(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_snow.SetDriftRange(min_value, max_value);
}
void AGSSnowRain::srSetSnowDriftSpeed(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_snow.SetDriftSpeed(min_value, max_value);
}
void AGSSnowRain::srChangeSnowAmount(ScriptMethodParams &params) {
PARAMS1(int, amount);
_snow.ChangeAmount(amount);
}
void AGSSnowRain::srSetSnowView(ScriptMethodParams &params) {
PARAMS4(int, kind_id, int, event, int, view, int, loop);
_snow.SetView(kind_id, event, view, loop);
}
void AGSSnowRain::srSetSnowDefaultView(ScriptMethodParams &params) {
PARAMS2(int, view, int, loop);
_snow.SetDefaultView(view, loop);
}
void AGSSnowRain::srSetSnowTransparency(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_snow.SetTransparency(min_value, max_value);
}
void AGSSnowRain::srSetSnowWindSpeed(ScriptMethodParams &params) {
PARAMS1(int, value);
_snow.SetWindSpeed(value);
}
void AGSSnowRain::srSetSnowBaseline(ScriptMethodParams &params) {
PARAMS2(int, top, int, bottom);
_snow.SetBaseline(top, bottom);
}
void AGSSnowRain::srSetSnowAmount(ScriptMethodParams &params) {
PARAMS1(int, amount);
_snow.SetAmount(amount);
}
void AGSSnowRain::srSetSnowFallSpeed(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_snow.SetFallSpeed(min_value, max_value);
}
void AGSSnowRain::srSetRainDriftRange(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_rain.SetDriftRange(min_value, max_value);
}
void AGSSnowRain::srSetRainDriftSpeed(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_rain.SetDriftSpeed(min_value, max_value);
}
void AGSSnowRain::srChangeRainAmount(ScriptMethodParams &params) {
PARAMS1(int, amount);
_rain.ChangeAmount(amount);
}
void AGSSnowRain::srSetRainView(ScriptMethodParams &params) {
PARAMS4(int, kind_id, int, event, int, view, int, loop);
_rain.SetView(kind_id, event, view, loop);
}
void AGSSnowRain::srSetRainDefaultView(ScriptMethodParams &params) {
PARAMS2(int, view, int, loop);
_rain.SetDefaultView(view, loop);
}
void AGSSnowRain::srSetRainTransparency(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_rain.SetTransparency(min_value, max_value);
}
void AGSSnowRain::srSetRainWindSpeed(ScriptMethodParams &params) {
PARAMS1(int, value);
_rain.SetWindSpeed(value);
}
void AGSSnowRain::srSetRainBaseline(ScriptMethodParams &params) {
PARAMS2(int, top, int, bottom);
_rain.SetBaseline(top, bottom);
}
void AGSSnowRain::srSetRainAmount(ScriptMethodParams &params) {
PARAMS1(int, amount);
_rain.SetAmount(amount);
}
void AGSSnowRain::srSetRainFallSpeed(ScriptMethodParams &params) {
PARAMS2(int, min_value, int, max_value);
_rain.SetFallSpeed(min_value, max_value);
}
} // namespace AGSSnowRain
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,81 @@
/* 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_SNOW_RAIN_AGS_SNOW_RAIN_H
#define AGS_PLUGINS_AGS_SNOW_RAIN_AGS_SNOW_RAIN_H
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/ags_snow_rain/weather.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSnowRain {
/**
* This is not the original AGS SnowRain plugin, but a workalike
* plugin created for the AGS engine PSP port.
*/
class AGSSnowRain : public PluginBase {
SCRIPT_HASH(AGSSnowRain)
private:
int32 _screenWidth = 320;
int32 _screenHeight = 200;
int32 _screenColorDepth = 32;
Weather _rain;
Weather _snow;
private:
void srSetWindSpeed(ScriptMethodParams &params);
void srSetBaseline(ScriptMethodParams &params);
void srSetSnowDriftRange(ScriptMethodParams &params);
void srSetSnowDriftSpeed(ScriptMethodParams &params);
void srChangeSnowAmount(ScriptMethodParams &params);
void srSetSnowView(ScriptMethodParams &params);
void srSetSnowDefaultView(ScriptMethodParams &params);
void srSetSnowTransparency(ScriptMethodParams &params);
void srSetSnowWindSpeed(ScriptMethodParams &params);
void srSetSnowBaseline(ScriptMethodParams &params);
void srSetSnowAmount(ScriptMethodParams &params);
void srSetSnowFallSpeed(ScriptMethodParams &params);
void srSetRainDriftRange(ScriptMethodParams &params);
void srSetRainDriftSpeed(ScriptMethodParams &params);
void srChangeRainAmount(ScriptMethodParams &params);
void srSetRainView(ScriptMethodParams &params);
void srSetRainDefaultView(ScriptMethodParams &params);
void srSetRainTransparency(ScriptMethodParams &params);
void srSetRainWindSpeed(ScriptMethodParams &params);
void srSetRainBaseline(ScriptMethodParams &params);
void srSetRainAmount(ScriptMethodParams &params);
void srSetRainFallSpeed(ScriptMethodParams &params);
public:
AGSSnowRain();
virtual ~AGSSnowRain() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
int64 AGS_EngineOnEvent(int event, NumberPtr data) override;
};
} // namespace AGSSnowRain
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,389 @@
/* 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/>.
*
*/
#include "ags/lib/allegro.h"
#include "ags/plugins/ags_snow_rain/weather.h"
#include "ags/plugins/ags_snow_rain/ags_snow_rain.h"
#include "ags/ags.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSnowRain {
#define signum(x) ((x > 0) ? 1 : -1)
const unsigned int Magic = 0xCAFE0000;
const unsigned int Version = 2;
const unsigned int SaveMagic = Magic + Version;
void View::syncGame(Serializer &s) {
s.syncAsInt(view);
s.syncAsInt(loop);
s.syncAsBool(is_default);
// Pointer saved/loaded raw structure, which included bitmap pointer
int dummy = 0;
s.syncAsInt(dummy);
}
/*------------------------------------------------------------------*/
Weather::Weather(bool IsSnow, int32 &scrWidth, int32 &scrHeight, IAGSEngine *&engine) :
_mIsSnow(IsSnow), _screenWidth(scrWidth), _screenHeight(scrHeight), _engine(engine) {
Initialize();
}
void Weather::Update() {
if (_mTargetAmount > _mAmount)
_mAmount++;
else if (_mTargetAmount < _mAmount)
_mAmount--;
if (!ReinitializeViews())
return;
int i;
for (i = 0; i < _mAmount * 2; i++) {
_mParticles[i].y += _mParticles[i].speed;
_mParticles[i].x += _mWindSpeed;
if (_mParticles[i].x < 0)
_mParticles[i].x += _screenWidth;
if (_mParticles[i].x > _screenWidth - 1)
_mParticles[i].x -= _screenWidth;
if (_mParticles[i].y > _mParticles[i].max_y) {
_mParticles[i].y = -1 * (::AGS::g_vm->getRandomNumber(0x7fffffff) % _screenHeight);
_mParticles[i].x = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _screenWidth;
_mParticles[i].alpha = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaAlpha + _mMinAlpha;
_mParticles[i].speed = (float)(::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaFallSpeed + _mMinFallSpeed) / 50.0f;
_mParticles[i].max_y = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaBaseline + _mTopBaseline;
} else if ((_mParticles[i].y > 0) && (_mParticles[i].alpha > 0))
_engine->BlitSpriteTranslucent(_mParticles[i].x, _mParticles[i].y, _mViews[_mParticles[i].kind_id].bitmap, _mParticles[i].alpha);
}
_engine->MarkRegionDirty(0, 0, _screenWidth, _screenHeight);
}
void Weather::UpdateWithDrift() {
if (_mTargetAmount > _mAmount)
_mAmount++;
else if (_mTargetAmount < _mAmount)
_mAmount--;
if (!ReinitializeViews())
return;
int i, drift;
for (i = 0; i < _mAmount * 2; i++) {
_mParticles[i].y += _mParticles[i].speed;
drift = _mParticles[i].drift * sin((float)(_mParticles[i].y +
_mParticles[i].drift_offset) * _mParticles[i].drift_speed * 2.0f * M_PI / 360.0f);
if (signum(_mWindSpeed) == signum(drift))
_mParticles[i].x += _mWindSpeed;
else
_mParticles[i].x += _mWindSpeed / 4;
if (_mParticles[i].x < 0)
_mParticles[i].x += _screenWidth;
if (_mParticles[i].x > _screenWidth - 1)
_mParticles[i].x -= _screenWidth;
if (_mParticles[i].y > _mParticles[i].max_y) {
_mParticles[i].y = -1 * (::AGS::g_vm->getRandomNumber(0x7fffffff) % _screenHeight);
_mParticles[i].x = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _screenWidth;
_mParticles[i].alpha = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaAlpha + _mMinAlpha;
_mParticles[i].speed = (float)(::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaFallSpeed + _mMinFallSpeed) / 50.0f;
_mParticles[i].max_y = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaBaseline + _mTopBaseline;
_mParticles[i].drift = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaDrift + _mMinDrift;
_mParticles[i].drift_speed = (::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaDriftSpeed + _mMinDriftSpeed) / 50.0f;
} else if ((_mParticles[i].y > 0) && (_mParticles[i].alpha > 0))
_engine->BlitSpriteTranslucent(_mParticles[i].x + drift, _mParticles[i].y, _mViews[_mParticles[i].kind_id].bitmap, _mParticles[i].alpha);
}
_engine->MarkRegionDirty(0, 0, _screenWidth, _screenHeight);
}
void Weather::syncGame(Serializer &s) {
int saveVersion = SaveMagic;
s.syncAsInt(saveVersion);
if (s.isLoading() && (uint)saveVersion != SaveMagic) {
_engine->AbortGame("ags_snowrain: bad save.");
return;
}
// TODO: At some point check whether the original did a packed
// structure for Weather, or if bools were padded to 4 bytes
s.syncAsBool(_mIsSnow);
s.syncAsInt(_mMinDrift);
s.syncAsInt(_mMaxDrift);
s.syncAsInt(_mDeltaDrift);
s.syncAsInt(_mMinDriftSpeed);
s.syncAsInt(_mMaxDriftSpeed);
s.syncAsInt(_mDeltaDriftSpeed);
s.syncAsInt(_mAmount);
s.syncAsInt(_mTargetAmount);
s.syncAsInt(_mMinAlpha);
s.syncAsInt(_mMaxAlpha);
s.syncAsInt(_mDeltaAlpha);
s.syncAsFloat(_mWindSpeed);
s.syncAsInt(_mTopBaseline);
s.syncAsInt(_mBottomBaseline);
s.syncAsInt(_mDeltaBaseline);
s.syncAsInt(_mMinFallSpeed);
s.syncAsInt(_mMaxFallSpeed);
s.syncAsInt(_mDeltaFallSpeed);
for (int i = 0; i < 5; ++i)
_mViews[i].syncGame(s);
if (s.isLoading())
InitializeParticles();
}
bool Weather::ReinitializeViews() {
if ((_mViews[4].view == -1) || (_mViews[4].loop == -1))
return false;
AGSViewFrame *view_frame = _engine->GetViewFrame(_mViews[4].view, _mViews[4].loop, 0);
BITMAP *default_bitmap = _engine->GetSpriteGraphic(view_frame->pic);
int i;
for (i = 0; i < 5; i++) {
if (_mViews[i].bitmap != nullptr) {
if (_mViews[i].is_default)
_mViews[i].bitmap = default_bitmap;
else {
view_frame = _engine->GetViewFrame(_mViews[i].view, _mViews[i].loop, 0);
_mViews[i].bitmap = _engine->GetSpriteGraphic(view_frame->pic);
}
}
}
return true;
}
bool Weather::IsActive() {
return (_mAmount > 0) || (_mTargetAmount != _mAmount);
}
void Weather::EnterRoom() {
_mAmount = _mTargetAmount;
// If baseline is not fixed, reset and clamp to the new screenHeight
if (!_mBaselineFixed)
ResetBaseline();
}
void Weather::ClipToRange(int &variable, int min, int max) {
if (variable < min)
variable = min;
if (variable > max)
variable = max;
}
void Weather::Initialize() {
SetDriftRange(10, 100);
SetDriftSpeed(10, 120);
SetTransparency(0, 0);
SetWindSpeed(0);
ResetBaseline();
if (_mIsSnow)
SetFallSpeed(10, 70);
else
SetFallSpeed(100, 300);
_mViewsInitialized = false;
int i;
for (i = 0; i < 5; i++) {
_mViews[i].is_default = true;
_mViews[i].view = -1;
_mViews[i].loop = -1;
_mViews[i].bitmap = nullptr;
}
SetAmount(0);
}
void Weather::InitializeParticles() {
for (uint i = 0; i < ARRAYSIZE(_mParticles); i++) {
_mParticles[i].clear();
_mParticles[i].kind_id = ::AGS::g_vm->getRandomNumber(0x7fffffff) % 5;
_mParticles[i].y = ::AGS::g_vm->getRandomNumber(0x7fffffff) % (_screenHeight * 2) - _screenHeight;
_mParticles[i].x = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _screenWidth;
_mParticles[i].alpha = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaAlpha + _mMinAlpha;
_mParticles[i].speed = (float)(::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaFallSpeed + _mMinFallSpeed) / 50.0f;
_mParticles[i].max_y = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaBaseline + _mTopBaseline;
_mParticles[i].drift = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaDrift + _mMinDrift;
_mParticles[i].drift_speed = (::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaDriftSpeed + _mMinDriftSpeed) / 50.0f;
_mParticles[i].drift_offset = ::AGS::g_vm->getRandomNumber(0x7fffffff) % 100;
}
}
void Weather::SetDriftRange(int min_value, int max_value) {
ClipToRange(min_value, 0, 100);
ClipToRange(max_value, 0, 100);
if (min_value > max_value)
min_value = max_value;
_mMinDrift = min_value / 2;
_mMaxDrift = max_value / 2;
_mDeltaDrift = _mMaxDrift - _mMinDrift;
if (_mDeltaDrift == 0)
_mDeltaDrift = 1;
}
void Weather::SetDriftSpeed(int min_value, int max_value) {
ClipToRange(min_value, 0, 200);
ClipToRange(max_value, 0, 200);
if (min_value > max_value)
min_value = max_value;
_mMinDriftSpeed = min_value;
_mMaxDriftSpeed = max_value;
_mDeltaDriftSpeed = _mMaxDriftSpeed - _mMinDriftSpeed;
if (_mDeltaDriftSpeed == 0)
_mDeltaDriftSpeed = 1;
}
void Weather::ChangeAmount(int amount) {
ClipToRange(amount, 0, 1000);
_mTargetAmount = amount;
}
void Weather::SetView(int kind_id, int event, int view, int loop) {
AGSViewFrame *view_frame = _engine->GetViewFrame(view, loop, 0);
_mViews[kind_id].bitmap = _engine->GetSpriteGraphic(view_frame->pic);
_mViews[kind_id].is_default = false;
_mViews[kind_id].view = view;
_mViews[kind_id].loop = loop;
if (!_mViewsInitialized)
SetDefaultView(view, loop);
}
void Weather::SetDefaultView(int view, int loop) {
AGSViewFrame *view_frame = _engine->GetViewFrame(view, loop, 0);
BITMAP *bitmap = _engine->GetSpriteGraphic(view_frame->pic);
_mViewsInitialized = true;
int i;
for (i = 0; i < 5; i++) {
if (_mViews[i].is_default) {
_mViews[i].view = view;
_mViews[i].loop = loop;
_mViews[i].bitmap = bitmap;
}
}
}
void Weather::SetTransparency(int min_value, int max_value) {
ClipToRange(min_value, 0, 100);
ClipToRange(max_value, 0, 100);
if (min_value > max_value)
min_value = max_value;
_mMinAlpha = 255 - floor((float)max_value * 2.55f + 0.5f);
_mMaxAlpha = 255 - floor((float)min_value * 2.55f + 0.5f);
_mDeltaAlpha = _mMaxAlpha - _mMinAlpha;
if (_mDeltaAlpha == 0)
_mDeltaAlpha = 1;
int i;
for (i = 0; i < 2000; i++)
_mParticles[i].alpha = ::AGS::g_vm->getRandomNumber(0x7fffffff) % _mDeltaAlpha + _mMinAlpha;
}
void Weather::SetWindSpeed(int value) {
ClipToRange(value, -200, 200);
_mWindSpeed = (float)value / 20.0f;
}
void Weather::SetBaseline(int top, int bottom) {
if (_screenHeight > 0) {
ClipToRange(top, 0, _screenHeight);
ClipToRange(bottom, 0, _screenHeight);
}
if (top > bottom)
top = bottom;
_mTopBaseline = top;
_mBottomBaseline = bottom;
_mDeltaBaseline = _mBottomBaseline - _mTopBaseline;
if (_mDeltaBaseline == 0)
_mDeltaBaseline = 1;
_mBaselineFixed = true;
}
void Weather::ResetBaseline() {
_mTopBaseline = 0;
_mBottomBaseline = _screenHeight;
_mDeltaBaseline = _screenHeight;
_mBaselineFixed = false;
}
void Weather::SetAmount(int amount) {
ClipToRange(amount, 0, 1000);
_mAmount = _mTargetAmount = amount;
InitializeParticles();
}
void Weather::SetFallSpeed(int min_value, int max_value) {
ClipToRange(min_value, 0, 1000);
ClipToRange(max_value, 0, 1000);
if (min_value > max_value)
min_value = max_value;
_mMinFallSpeed = min_value;
_mMaxFallSpeed = max_value;
_mDeltaFallSpeed = _mMaxFallSpeed - _mMinFallSpeed;
if (_mDeltaFallSpeed == 0)
_mDeltaFallSpeed = 1;
}
} // namespace AGSSnowRain
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,139 @@
/* 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_SNOW_RAIN_WEATHER_H
#define AGS_PLUGINS_AGS_SNOW_RAIN_WEATHER_H
#include "ags/plugins/plugin_base.h"
#include "ags/plugins/serializer.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSnowRain {
struct View {
int view = 0;
int loop = 0;
bool is_default = false;
BITMAP *bitmap = nullptr;
void syncGame(Serializer &s);
};
struct Drop {
float x = 0;
float y = 0;
int alpha = 0;
float speed = 0;
int max_y = 0;
int kind_id = 0;
int drift = 0;
float drift_speed = 0;
float drift_offset = 0;
void clear() {
x = 0;
y = 0;
alpha = 0;
speed = 0;
max_y = 0;
kind_id = 0;
drift = 0;
drift_speed = 0;
drift_offset = 0;
}
};
class Weather {
private:
void ClipToRange(int &variable, int min, int max);
bool _mIsSnow;
int32 &_screenWidth;
int32 &_screenHeight;
IAGSEngine *&_engine;
int _mMinDrift = 0;
int _mMaxDrift = 0;
int _mDeltaDrift = 0;
int _mMinDriftSpeed = 0;
int _mMaxDriftSpeed = 0;
int _mDeltaDriftSpeed = 0;
int _mAmount = 0;
int _mTargetAmount = 0;
int _mMinAlpha = 0;
int _mMaxAlpha = 0;
int _mDeltaAlpha = 0;
float _mWindSpeed = 0;
bool _mBaselineFixed;
int _mTopBaseline = 0;
int _mBottomBaseline = 0;
int _mDeltaBaseline = 0;
int _mMinFallSpeed = 0;
int _mMaxFallSpeed = 0;
int _mDeltaFallSpeed = 0;
Drop _mParticles[2000];
View _mViews[5];
bool _mViewsInitialized;
public:
Weather(bool IsSnow, int32 &scrWidth, int32 &scrHeight, IAGSEngine *&engine);
void Initialize();
void InitializeParticles();
void syncGame(Serializer &s);
bool ReinitializeViews();
bool IsActive();
void Update();
void UpdateWithDrift();
void EnterRoom();
void SetDriftRange(int min_value, int max_value);
void SetDriftSpeed(int min_value, int max_value);
void ChangeAmount(int amount);
void SetView(int kind_id, int event, int view, int loop);
void SetDefaultView(int view, int loop);
void SetTransparency(int min_value, int max_value);
void SetWindSpeed(int value);
// Sets baseline and marks baseline as fixed
void SetBaseline(int top, int bottom);
// Resets baselines to the (0, screen_height);
// marks baseline for auto-update on screen change
void ResetBaseline();
void SetAmount(int amount);
void SetFallSpeed(int min_value, int max_value);
};
} // namespace AGSSnowRain
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,404 @@
/* 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/>.
*
*/
#include "common/array.h"
#include "common/str.h"
#include "ags/engine/ac/dynobj/cc_ags_dynamic_object.h"
#include "ags/plugins/ags_sock/ags_sock.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSock {
struct SockData : public IAGSScriptManagedObject, public Common::Array<byte> {
public:
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "SockData";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
struct SockAddr : public IAGSScriptManagedObject {
public:
int _port = 0;
Common::String _address;
Common::String _ip;
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "SockAddr";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
struct Socket : public IAGSScriptManagedObject {
public:
int _id = 0;
int _domain = 0;
int _type = 0;
int _protocol = 0;
int _lastError = 0;
Common::String _tag;
SockAddr *_local = nullptr;
SockAddr *_remote = nullptr;
bool _valid = false;
Common::String _errorString;
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "Socket";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
const char *AGSSock::AGS_GetPluginName() {
return "AGS Sock";
}
void AGSSock::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(SockData::Create^2, AGSSock::SockData_Create);
SCRIPT_METHOD(SockData::CreateEmpty^0, AGSSock::SockData_CreateEmpty);
SCRIPT_METHOD(SockData::CreateFromString^1, AGSSock::SockData_CreateFromString);
SCRIPT_METHOD(SockData::get_Size, AGSSock::SockData_get_Size);
SCRIPT_METHOD(SockData::set_Size, AGSSock::SockData_set_Size);
SCRIPT_METHOD(SockData::geti_Chars, AGSSock::SockData_geti_Chars);
SCRIPT_METHOD(SockData::seti_Chars, AGSSock::SockData_seti_Chars);
SCRIPT_METHOD(SockData::AsString^0, AGSSock::SockData_AsString);
SCRIPT_METHOD(SockData::Clear^0, AGSSock::SockData_Clear);
SCRIPT_METHOD(SockAddr::Create^1, AGSSock::SockAddr_Create);
SCRIPT_METHOD(SockAddr::CreateFromString^2, AGSSock::SockAddr_CreateFromString);
SCRIPT_METHOD(SockAddr::CreateFromData^1, AGSSock::SockAddr_CreateFromData);
SCRIPT_METHOD(SockAddr::CreateIP^2, AGSSock::SockAddr_CreateIP);
SCRIPT_METHOD(SockAddr::CreateIPv6^2, AGSSock::SockAddr_CreateIPv6);
SCRIPT_METHOD(SockAddr::get_Port, AGSSock::SockAddr_get_Port);
SCRIPT_METHOD(SockAddr::set_Port, AGSSock::SockAddr_set_Port);
SCRIPT_METHOD(SockAddr::get_Address, AGSSock::SockAddr_get_Address);
SCRIPT_METHOD(SockAddr::set_Address, AGSSock::SockAddr_set_Address);
SCRIPT_METHOD(SockAddr::get_IP, AGSSock::SockAddr_get_IP);
SCRIPT_METHOD(SockAddr::set_IP, AGSSock::SockAddr_set_IP);
SCRIPT_METHOD(SockAddr::GetData^0, AGSSock::SockAddr_GetData);
SCRIPT_METHOD(Socket::Create^3, AGSSock::Socket_Create);
SCRIPT_METHOD(Socket::CreateUDP^0, AGSSock::Socket_CreateUDP);
SCRIPT_METHOD(Socket::CreateTCP^0, AGSSock::Socket_CreateTCP);
SCRIPT_METHOD(Socket::CreateUDPv6^0, AGSSock::Socket_CreateUDPv6);
SCRIPT_METHOD(Socket::CreateTCPv6^0, AGSSock::Socket_CreateTCPv6);
SCRIPT_METHOD(Socket::get_Tag, AGSSock::Socket_get_Tag);
SCRIPT_METHOD(Socket::set_Tag, AGSSock::Socket_set_Tag);
SCRIPT_METHOD(Socket::get_Local, AGSSock::Socket_get_Local);
SCRIPT_METHOD(Socket::get_Remote, AGSSock::Socket_get_Remote);
SCRIPT_METHOD(Socket::get_Valid, AGSSock::Socket_get_Valid);
SCRIPT_METHOD(Socket::ErrorString^0, AGSSock::Socket_ErrorString);
SCRIPT_METHOD(Socket::Bind^1, AGSSock::Socket_Bind);
SCRIPT_METHOD(Socket::Listen^1, AGSSock::Socket_Listen);
SCRIPT_METHOD(Socket::Connect^2, AGSSock::Socket_Connect);
SCRIPT_METHOD(Socket::Accept^0, AGSSock::Socket_Accept);
SCRIPT_METHOD(Socket::Close^0, AGSSock::Socket_Close);
SCRIPT_METHOD(Socket::Send^1, AGSSock::Socket_Send);
SCRIPT_METHOD(Socket::SendTo^2, AGSSock::Socket_SendTo);
SCRIPT_METHOD(Socket::Recv^0, AGSSock::Socket_Recv);
SCRIPT_METHOD(Socket::RecvFrom^1, AGSSock::Socket_RecvFrom);
SCRIPT_METHOD(Socket::SendData^1, AGSSock::Socket_SendData);
SCRIPT_METHOD(Socket::SendDataTo^2, AGSSock::Socket_SendDataTo);
SCRIPT_METHOD(Socket::RecvData^0, AGSSock::Socket_RecvData);
SCRIPT_METHOD(Socket::RecvDataFrom^1, AGSSock::Socket_RecvDataFrom);
SCRIPT_METHOD(Socket::GetOption^2, AGSSock::Socket_GetOption);
SCRIPT_METHOD(Socket::SetOption^3, AGSSock::Socket_SetOption);
}
void AGSSock::SockData_Create(ScriptMethodParams &params) {
PARAMS2(int, size, char, defchar);
SockData *data = new SockData();
_engine->RegisterManagedObject(data, data);
data->resize(size);
Common::fill(&(*data)[0], &(*data)[0] + size, defchar);
params._result = data;
}
void AGSSock::SockData_CreateEmpty(ScriptMethodParams &params) {
params._result = new SockData();
}
void AGSSock::SockData_CreateFromString(ScriptMethodParams &params) {
PARAMS1(const char *, str);
size_t len = strlen(str);
SockData *data = new SockData();
_engine->RegisterManagedObject(data, data);
data->resize(len + 1);
Common::copy(str, str + len + 1, &(*data)[0]);
params._result = data;
}
void AGSSock::SockData_get_Size(ScriptMethodParams &params) {
PARAMS1(SockData *, sockData);
params._result = sockData->size();
}
void AGSSock::SockData_set_Size(ScriptMethodParams &params) {
PARAMS2(SockData *, sockData, size_t, size);
sockData->resize(size);
}
void AGSSock::SockData_geti_Chars(ScriptMethodParams &params) {
PARAMS1(SockData *, sockData);
params._result = &(*sockData)[0];
}
void AGSSock::SockData_seti_Chars(ScriptMethodParams &params) {
PARAMS2(SockData *, sockData, const byte *, chars);
Common::copy(chars, chars + sockData->size(), &(*sockData)[0]);
}
void AGSSock::SockData_AsString(ScriptMethodParams &params) {
PARAMS1(SockData *, sockData);
params._result = (const char *)&(*sockData)[0];
}
void AGSSock::SockData_Clear(ScriptMethodParams &params) {
PARAMS1(SockData *, sockData);
sockData->clear();
}
void AGSSock::SockAddr_Create(ScriptMethodParams &params) {
// PARAMS1(int, type);
SockAddr *sockAddr = new SockAddr();
_engine->RegisterManagedObject(sockAddr, sockAddr);
params._result = sockAddr;
}
void AGSSock::SockAddr_CreateFromString(ScriptMethodParams &params) {
// PARAMS2(const char *, address, int, type);
PARAMS1(const char *, address);
SockAddr *sockAddr = new SockAddr();
_engine->RegisterManagedObject(sockAddr, sockAddr);
sockAddr->_address = address;
params._result = sockAddr;
}
void AGSSock::SockAddr_CreateFromData(ScriptMethodParams &params) {
// PARAMS1(const SockData *, data);
SockAddr *sockAddr = new SockAddr();
_engine->RegisterManagedObject(sockAddr, sockAddr);
params._result = sockAddr;
}
void AGSSock::SockAddr_CreateIP(ScriptMethodParams &params) {
PARAMS2(const char *, address, int, port);
SockAddr *sockAddr = new SockAddr();
_engine->RegisterManagedObject(sockAddr, sockAddr);
sockAddr->_address = address;
sockAddr->_port = port;
params._result = sockAddr;
}
void AGSSock::SockAddr_CreateIPv6(ScriptMethodParams &params) {
//PARAMS2(const char *, address, int, port);
PARAMS1(const char *, address);
SockAddr *sockAddr = new SockAddr();
_engine->RegisterManagedObject(sockAddr, sockAddr);
sockAddr->_address = address;
params._result = sockAddr;
}
void AGSSock::SockAddr_get_Port(ScriptMethodParams &params) {
PARAMS1(const SockAddr *, sockAddr);
params._result = sockAddr->_port;
}
void AGSSock::SockAddr_set_Port(ScriptMethodParams &params) {
PARAMS2(SockAddr *, sockAddr, int, port);
sockAddr->_port = port;
}
void AGSSock::SockAddr_get_Address(ScriptMethodParams &params) {
PARAMS1(const SockAddr *, sockAddr);
params._result = sockAddr->_address.c_str();
}
void AGSSock::SockAddr_set_Address(ScriptMethodParams &params) {
PARAMS2(SockAddr *, sockAddr, const char *, address);
sockAddr->_address = address;
}
void AGSSock::SockAddr_get_IP(ScriptMethodParams &params) {
PARAMS1(const SockAddr *, sockAddr);
params._result = sockAddr->_ip.c_str();
}
void AGSSock::SockAddr_set_IP(ScriptMethodParams &params) {
PARAMS2(SockAddr *, sockAddr, const char *, IP);
sockAddr->_ip = IP;
}
void AGSSock::SockAddr_GetData(ScriptMethodParams &params) {
// PARAMS1(const SockAddr *, sockAddr);
params._result = new SockData();
}
void AGSSock::Socket_Create(ScriptMethodParams &params) {
//PARAMS3(int, domain, int, type, int, protocol);
Socket *socket = new Socket();
_engine->RegisterManagedObject(socket, socket);
params._result = socket;
}
void AGSSock::Socket_CreateUDP(ScriptMethodParams &params) {
Socket *socket = new Socket();
_engine->RegisterManagedObject(socket, socket);
params._result = socket;
}
void AGSSock::Socket_CreateTCP(ScriptMethodParams &params) {
Socket *socket = new Socket();
_engine->RegisterManagedObject(socket, socket);
params._result = socket;
}
void AGSSock::Socket_CreateUDPv6(ScriptMethodParams &params) {
Socket *socket = new Socket();
_engine->RegisterManagedObject(socket, socket);
params._result = socket;
}
void AGSSock::Socket_CreateTCPv6(ScriptMethodParams &params) {
Socket *socket = new Socket();
_engine->RegisterManagedObject(socket, socket);
params._result = socket;
}
void AGSSock::Socket_get_Tag(ScriptMethodParams &params) {
PARAMS1(const Socket *, socket);
params._result = socket->_tag.c_str();
}
void AGSSock::Socket_set_Tag(ScriptMethodParams &params) {
PARAMS2(Socket *, socket, const char *, tag);
socket->_tag = tag;
}
void AGSSock::Socket_get_Local(ScriptMethodParams &params) {
PARAMS1(const Socket *, socket);
params._result = socket->_local;
}
void AGSSock::Socket_get_Remote(ScriptMethodParams &params) {
PARAMS1(const Socket *, socket);
params._result = socket->_remote;
}
void AGSSock::Socket_get_Valid(ScriptMethodParams &params) {
PARAMS1(const Socket *, socket);
params._result = socket->_valid;
}
void AGSSock::Socket_ErrorString(ScriptMethodParams &params) {
PARAMS1(const Socket *, socket);
params._result = socket->_errorString.c_str();
}
void AGSSock::Socket_Bind(ScriptMethodParams &params) {
}
void AGSSock::Socket_Listen(ScriptMethodParams &params) {
}
void AGSSock::Socket_Connect(ScriptMethodParams &params) {
// Fail the connection
params._result = 0;
}
void AGSSock::Socket_Accept(ScriptMethodParams &params) {
}
void AGSSock::Socket_Close(ScriptMethodParams &params) {
}
void AGSSock::Socket_Send(ScriptMethodParams &params) {
}
void AGSSock::Socket_SendTo(ScriptMethodParams &params) {
}
void AGSSock::Socket_Recv(ScriptMethodParams &params) {
}
void AGSSock::Socket_RecvFrom(ScriptMethodParams &params) {
}
void AGSSock::Socket_SendData(ScriptMethodParams &params) {
}
void AGSSock::Socket_SendDataTo(ScriptMethodParams &params) {
}
void AGSSock::Socket_RecvData(ScriptMethodParams &params) {
}
void AGSSock::Socket_RecvDataFrom(ScriptMethodParams &params) {
}
void AGSSock::Socket_GetOption(ScriptMethodParams &params) {
}
void AGSSock::Socket_SetOption(ScriptMethodParams &params) {
}
} // namespace AGSSock
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,306 @@
/* 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_SOCK_H
#define AGS_PLUGINS_AGS_SOCK_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSock {
class AGSSock : public PluginBase {
SCRIPT_HASH(AGSSock)
private:
Common::String _text;
/**
* Creates a new data container with specified size
* (and what character to fill it with)
*/
void SockData_Create(ScriptMethodParams &params);
/**
* Creates a new data container of zero size
*/
void SockData_CreateEmpty(ScriptMethodParams &params);
/**
* Creates a data container from a string
*/
void SockData_CreateFromString(ScriptMethodParams &params);
/**
* Gets the size property
*/
void SockData_get_Size(ScriptMethodParams &params);
/**
* Sets the size property
*/
void SockData_set_Size(ScriptMethodParams &params);
/**
* Gets the chars array
*/
void SockData_geti_Chars(ScriptMethodParams &params);
/**
* Sets the chars array
*/
void SockData_seti_Chars(ScriptMethodParams &params);
/**
* Makes and returns a string from the data object.
* (Warning: anything after a null character will be truncated)
*/
void SockData_AsString(ScriptMethodParams &params);
/**
* Removes all the data from a socket data object,
* reducing it's size to zero
*/
void SockData_Clear(ScriptMethodParams &params);
/**
* Creates an empty socket address. (advanced: set type
* to IPv6 if you're using IPv6)
*/
void SockAddr_Create(ScriptMethodParams &params);
/**
* Creates a socket address from a string.
* (for example: "https://www.scummvm.org/"
*/
void SockAddr_CreateFromString(ScriptMethodParams &params);
/**
* Creates a socket address from raw data. (advanced)
*/
void SockAddr_CreateFromData(ScriptMethodParams &params);
/**
* Creates a socket address from an IP-address.
* (for example: "127.0.0.1")
*/
void SockAddr_CreateIP(ScriptMethodParams &params);
/**
* Creates a socket address from an IPv6-address.
* (for example: "::1")
*/
void SockAddr_CreateIPv6(ScriptMethodParams &params);
/**
* Gets the value of the port property
*/
void SockAddr_get_Port(ScriptMethodParams &params);
/**
* Sets the value of the port property
*/
void SockAddr_set_Port(ScriptMethodParams &params);
/**
* Gets the value of the address property
*/
void SockAddr_get_Address(ScriptMethodParams &params);
/**
* Sets the value of the address property
*/
void SockAddr_set_Address(ScriptMethodParams &params);
/**
* Gets the value of the IP property
*/
void SockAddr_get_IP(ScriptMethodParams &params);
/**
* Sets the value of the IP property
*/
void SockAddr_set_IP(ScriptMethodParams &params);
/**
* Returns a SockData object that contains the raw data
* of the socket address. (advanced)
*/
void SockAddr_GetData(ScriptMethodParams &params);
/**
* Creates a socket for the specified protocol. (advanced)
*/
void Socket_Create(ScriptMethodParams &params);
/**
* Creates a UDP socket. (unrealiable, connectionless, message based)
*/
void Socket_CreateUDP(ScriptMethodParams &params);
/**
* Creates a TCP socket. (reliable, connection based, streaming)
*/
void Socket_CreateTCP(ScriptMethodParams &params);
/**
* Creates a UDP socket for IPv6. (when in doubt use CreateUDP)
*/
void Socket_CreateUDPv6(ScriptMethodParams &params);
/**
* Creates a TCP socket for IPv6. (when in doubt use CreateTCP)
*/
void Socket_CreateTCPv6(ScriptMethodParams &params);
/**
* Gets the value of the Tag property
*/
void Socket_get_Tag(ScriptMethodParams &params);
/**
* Sets the value of the Tag property
*/
void Socket_set_Tag(ScriptMethodParams &params);
/**
* Gets the value of the Local property
*/
void Socket_get_Local(ScriptMethodParams &params);
/**
* Gets the value of the Remote property
*/
void Socket_get_Remote(ScriptMethodParams &params);
/**
* Gets the value of the Value property
*/
void Socket_get_Valid(ScriptMethodParams &params);
/**
* Returns the last error observed from this socket
* as an human readable string
*/
void Socket_ErrorString(ScriptMethodParams &params);
/**
* Binds the socket to a local address. (generally used
* before listening)
*/
void Socket_Bind(ScriptMethodParams &params);
/**
* Makes a socket listen for incoming connection requests.
* (TCP only) Backlog specifies how many requests can be
* queued. (optional)
*/
void Socket_Listen(ScriptMethodParams &params);
/**
* Makes a socket connect to a remote host. (for UDP it
* will simply bind to a remote address) Defaults to sync
* which makes it wait; see the manual for async use.
*/
void Socket_Connect(ScriptMethodParams &params);
/**
* Accepts a connection request and returns the resulting
* socket when successful. (TCP only)
*/
void Socket_Accept(ScriptMethodParams &params);
/**
* Closes the socket. (you can still receive until socket
* is marked invalid
*/
void Socket_Close(ScriptMethodParams &params);
/**
* Sends a string to the remote host. Returns whether
* successful. (no error means: try again later)
*/
void Socket_Send(ScriptMethodParams &params);
/**
* Sends a string to the specified remote host. (UDP only)
*/
void Socket_SendTo(ScriptMethodParams &params);
/**
* Receives a string from the remote host. (no error
* means: try again later)
*/
void Socket_Recv(ScriptMethodParams &params);
/**
* Receives a string from an unspecified host. The given
* address object will contain the remote address. (UDP only)
*/
void Socket_RecvFrom(ScriptMethodParams &params);
/**
* Sends raw data to the remote host. Returns whether
* successful. (no error means: try again later
*/
void Socket_SendData(ScriptMethodParams &params);
/**
* Sends raw data to the specified remote host. (UDP only)
*/
void Socket_SendDataTo(ScriptMethodParams &params);
/**
* Receives raw data from the remote host. (no error
* means: try again later
*/
void Socket_RecvData(ScriptMethodParams &params);
/**
* Receives raw data from an unspecified host. The given
* address object will contain the remote address. (UDP only)
*/
void Socket_RecvDataFrom(ScriptMethodParams &params);
/**
* Gets a socket option. (advanced)
*/
void Socket_GetOption(ScriptMethodParams &params);
/**
* Sets a socket option. (advanced)
*/
void Socket_SetOption(ScriptMethodParams &params);
public:
AGSSock() : PluginBase() {}
virtual ~AGSSock() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSSock
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,147 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/ags_sprite_font.h"
#include "ags/shared/core/platform.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
#pragma region Defines
#define MIN_EDITOR_VERSION 1
#define MIN_ENGINE_VERSION 3
#define DEFAULT_RGB_R_SHIFT_32 16
#define DEFAULT_RGB_G_SHIFT_32 8
#define DEFAULT_RGB_B_SHIFT_32 0
#define DEFAULT_RGB_A_SHIFT_32 24
#define abs(a) ((a)<0 ? -(a) : (a))
#define ChannelBlend_Normal(B,L) ((uint8)(B))
#define ChannelBlend_Lighten(B,L) ((uint8)((L > B) ? L:B))
#define ChannelBlend_Darken(B,L) ((uint8)((L > B) ? B:L))
#define ChannelBlend_Multiply(B,L) ((uint8)((B * L) / 255))
#define ChannelBlend_Average(B,L) ((uint8)((B + L) / 2))
#define ChannelBlend_Add(B,L) ((uint8)(min(255, (B + L))))
#define ChannelBlend_Subtract(B,L) ((uint8)((B + L < 255) ? 0:(B + L - 255)))
#define ChannelBlend_Difference(B,L) ((uint8)(abs(B - L)))
#define ChannelBlend_Negation(B,L) ((uint8)(255 - abs(255 - B - L)))
#define ChannelBlend_Screen(B,L) ((uint8)(255 - (((255 - B) * (255 - L)) >> 8)))
#define ChannelBlend_Exclusion(B,L) ((uint8)(B + L - 2 * B * L / 255))
#define ChannelBlend_Overlay(B,L) ((uint8)((L < 128) ? (2 * B * L / 255):(255 - 2 * (255 - B) * (255 - L) / 255)))
#define ChannelBlend_SoftLight(B,L) ((uint8)((L < 128)?(2*((B>>1)+64))*((float)L/255):(255-(2*(255-((B>>1)+64))*(float)(255-L)/255))))
#define ChannelBlend_HardLight(B,L) (ChannelBlend_Overlay(L,B))
#define ChannelBlend_ColorDodge(B,L) ((uint8)((L == 255) ? L:min(255, ((B << 8 ) / (255 - L)))))
#define ChannelBlend_ColorBurn(B,L) ((uint8)((L == 0) ? L:max(0, (255 - ((255 - B) << 8 ) / L))))
#define ChannelBlend_LinearDodge(B,L)(ChannelBlend_Add(B,L))
#define ChannelBlend_LinearBurn(B,L) (ChannelBlend_Subtract(B,L))
#define ChannelBlend_LinearLight(B,L)((uint8)(L < 128)?ChannelBlend_LinearBurn(B,(2 * L)):ChannelBlend_LinearDodge(B,(2 * (L - 128))))
#define ChannelBlend_VividLight(B,L) ((uint8)(L < 128)?ChannelBlend_ColorBurn(B,(2 * L)):ChannelBlend_ColorDodge(B,(2 * (L - 128))))
#define ChannelBlend_PinLight(B,L) ((uint8)(L < 128)?ChannelBlend_Darken(B,(2 * L)):ChannelBlend_Lighten(B,(2 * (L - 128))))
#define ChannelBlend_HardMix(B,L) ((uint8)((ChannelBlend_VividLight(B,L) < 128) ? 0:255))
#define ChannelBlend_Reflect(B,L) ((uint8)((L == 255) ? L:min(255, (B * B / (255 - L)))))
#define ChannelBlend_Glow(B,L) (ChannelBlend_Reflect(L,B))
#define ChannelBlend_Phoenix(B,L) ((uint8)(min(B,L) - max(B,L) + 255))
#define ChannelBlend_Alpha(B,L,O) ((uint8)(O * B + (1 - O) * L))
#define ChannelBlend_AlphaF(B,L,F,O) (ChannelBlend_Alpha(F(B,L),B,O))
#pragma endregion
#define STRINGIFY(s) STRINGIFY_X(s)
#define STRINGIFY_X(s) #s
const char *AGSSpriteFont::AGS_GetPluginName() {
return "AGSSpriteFont";
}
void AGSSpriteFont::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_fontRenderer == nullptr) {
_engine->PrintDebugConsole("AGSSpriteFont: Init fixed width renderer");
_fontRenderer = new SpriteFontRenderer(engine);
}
if (_vWidthRenderer == nullptr) {
_engine->PrintDebugConsole("AGSSpriteFont: Init vari width renderer");
_vWidthRenderer = new VariableWidthSpriteFontRenderer(engine);
}
// Make sure it's got the version with the features we need
if (_engine->version < MIN_ENGINE_VERSION)
_engine->AbortGame("Plugin needs engine version " STRINGIFY(MIN_ENGINE_VERSION) " or newer.");
// Register functions
_engine->PrintDebugConsole("AGSSpriteFont: Register functions");
SCRIPT_METHOD(SetSpriteFont, AGSSpriteFont::SetSpriteFont);
SCRIPT_METHOD(SetVariableSpriteFont, AGSSpriteFont::SetVariableSpriteFont);
SCRIPT_METHOD(SetGlyph, AGSSpriteFont::SetGlyph);
SCRIPT_METHOD(SetSpacing, AGSSpriteFont::SetSpacing);
SCRIPT_METHOD(SetLineHeightAdjust, AGSSpriteFont::SetLineHeightAdjust);
}
void AGSSpriteFont::AGS_EngineShutdown() {
delete _fontRenderer;
delete _vWidthRenderer;
}
void AGSSpriteFont::SetSpriteFont(ScriptMethodParams &params) {
PARAMS9(int, fontNum, int, sprite, int, rows, int, columns, int, charWidth, int, charHeight, int, charMin, int, charMax, bool, use32bit);
_engine->PrintDebugConsole("AGSSpriteFont: SetSpriteFont");
_fontRenderer->SetSpriteFont(fontNum, sprite, rows, columns, charWidth, charHeight, charMin, charMax, use32bit);
if (_engine->version >= 26)
_engine->ReplaceFontRenderer2(fontNum, _fontRenderer);
else
_engine->ReplaceFontRenderer(fontNum, _fontRenderer);
}
void AGSSpriteFont::SetVariableSpriteFont(ScriptMethodParams &params) {
PARAMS2(int, fontNum, int, sprite);
_engine->PrintDebugConsole("AGSSpriteFont: SetVariableFont");
_vWidthRenderer->SetSprite(fontNum, sprite);
if (_engine->version >= 26)
_engine->ReplaceFontRenderer2(fontNum, _vWidthRenderer);
else
_engine->ReplaceFontRenderer(fontNum, _vWidthRenderer);
}
void AGSSpriteFont::SetGlyph(ScriptMethodParams &params) {
PARAMS6(int, fontNum, int, charNum, int, x, int, y, int, width, int, height);
_engine->PrintDebugConsole("AGSSpriteFont: SetGlyph");
_vWidthRenderer->SetGlyph(fontNum, charNum, x, y, width, height);
}
void AGSSpriteFont::SetSpacing(ScriptMethodParams &params) {
PARAMS2(int, fontNum, int, spacing);
_engine->PrintDebugConsole("AGSSpriteFont: SetSpacing");
_vWidthRenderer->SetSpacing(fontNum, spacing);
}
void AGSSpriteFont::SetLineHeightAdjust(ScriptMethodParams &params) {
//PARAMS4(int, v1, int, v2, int, v3, int, v4);
// TODO
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,63 @@
/* 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_SPRITE_FONT_AGS_SPRITE_FONT_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_AGS_SPRITE_FONT_H
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/ags_sprite_font/sprite_font_renderer.h"
#include "ags/plugins/ags_sprite_font/variable_width_sprite_font.h"
namespace AGS3 {
class IAGSEngine;
}
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class AGSSpriteFont : public PluginBase {
SCRIPT_HASH(AGSSpriteFont)
protected:
SpriteFontRenderer *_fontRenderer;
VariableWidthSpriteFontRenderer *_vWidthRenderer;
private:
void SetSpriteFont(ScriptMethodParams &params);
void SetVariableSpriteFont(ScriptMethodParams &params);
void SetGlyph(ScriptMethodParams &params);
void SetSpacing(ScriptMethodParams &params);
void SetLineHeightAdjust(ScriptMethodParams &params);
public:
AGSSpriteFont() : PluginBase(), _fontRenderer(nullptr), _vWidthRenderer(nullptr) {}
virtual ~AGSSpriteFont() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
void AGS_EngineShutdown() override;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,52 @@
/* 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
* (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/>.
*
*/
#include "ags/plugins/ags_sprite_font/ags_sprite_font_clifftop.h"
#include "ags/plugins/ags_sprite_font/sprite_font_renderer_clifftop.h"
#include "ags/plugins/ags_sprite_font/variable_width_sprite_font_clifftop.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
void AGSSpriteFontClifftopGames::AGS_EngineStartup(IAGSEngine *engine) {
// Use custom font renderers
// They need to be set before calling AGSSpriteFont::AGS_EngineStartup()
engine->PrintDebugConsole("AGSSpriteFont: Init fixed width renderer");
_fontRenderer = new SpriteFontRenderer(engine);
engine->PrintDebugConsole("AGSSpriteFont: Init vari width renderer");
_vWidthRenderer = new VariableWidthSpriteFontRendererClifftop(engine);
AGSSpriteFont::AGS_EngineStartup(engine);
SCRIPT_METHOD(SetLineHeightAdjust, AGSSpriteFontClifftopGames::SetLineHeightAdjust);
}
void AGSSpriteFontClifftopGames::SetLineHeightAdjust(ScriptMethodParams &params) {
PARAMS4(int, fontNum, int, LineHeight, int, SpacingHeight, int, SpacingOverride);
_vWidthRenderer->SetLineHeightAdjust(fontNum, LineHeight, SpacingHeight, SpacingOverride);
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_SPRITE_FONT_CLIFFTOP_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_CLIFFTOP_H
#include "ags/plugins/ags_sprite_font/ags_sprite_font.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class AGSSpriteFontClifftopGames : public AGSSpriteFont {
SCRIPT_HASH_SUB(AGSSpriteFontClifftopGames, AGSSpriteFont)
private:
void SetLineHeightAdjust(ScriptMethodParams &params);
public:
AGSSpriteFontClifftopGames() : AGSSpriteFont() {}
virtual ~AGSSpriteFontClifftopGames() {}
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,41 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/character_entry.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
CharacterEntry::CharacterEntry(void) {
X = 0;
Y = 0;
Width = 0;
Height = 0;
Character = 0;
}
CharacterEntry::~CharacterEntry(void) {}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,44 @@
/* 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_SPRITE_FONT_CHAR_ENTRY_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_CHAR_ENTRY_H
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class CharacterEntry {
public:
CharacterEntry(void);
~CharacterEntry(void);
int X;
int Y;
int Width;
int Height;
char Character;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,57 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/color.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
int getr32(int c) {
return ((c >> DEFAULT_RGB_R_SHIFT_32) & 0xFF);
}
int getg32(int c) {
return ((c >> DEFAULT_RGB_G_SHIFT_32) & 0xFF);
}
int getb32(int c) {
return ((c >> DEFAULT_RGB_B_SHIFT_32) & 0xFF);
}
int geta32(int c) {
return ((c >> DEFAULT_RGB_A_SHIFT_32) & 0xFF);
}
int makeacol32(int r, int g, int b, int a) {
return ((r << DEFAULT_RGB_R_SHIFT_32) |
(g << DEFAULT_RGB_G_SHIFT_32) |
(b << DEFAULT_RGB_B_SHIFT_32) |
(a << DEFAULT_RGB_A_SHIFT_32));
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,50 @@
/* 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_SPRITE_FONT_COLOR_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_COLOR_H
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define DEFAULT_RGB_R_SHIFT_32 16
#define DEFAULT_RGB_G_SHIFT_32 8
#define DEFAULT_RGB_B_SHIFT_32 0
#define DEFAULT_RGB_A_SHIFT_32 24
#pragma region Color_Functions
int getr32(int c);
int getg32(int c);
int getb32(int c);
int geta32(int c);
int makeacol32(int r, int g, int b, int a);
#pragma endregion
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,35 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/sprite_font.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
SpriteFont::SpriteFont(void) {}
SpriteFont::~SpriteFont(void) {}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_SPRITE_FONT_SPRITE_FONT_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_SPRITE_FONT_H
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class SpriteFont {
public:
SpriteFont(void);
~SpriteFont(void);
int SpriteNumber;
int MinChar;
int MaxChar;
int Rows;
int Columns;
int FontReplaced;
int CharHeight;
int CharWidth;
bool Use32bit;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,215 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/sprite_font_renderer.h"
#include "ags/plugins/ags_sprite_font/color.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
SpriteFontRenderer::SpriteFontRenderer(IAGSEngine *engine) {
_engine = engine;
}
SpriteFontRenderer::~SpriteFontRenderer(void) {
}
void SpriteFontRenderer::FreeMemory(int fontNum) {
for(auto it = _fonts.begin(); it != _fonts.end() ; ++it) {
SpriteFont *font = *it;
if (font->FontReplaced == fontNum) {
_fonts.erase(it);
delete font;
return;
}
}
}
void SpriteFontRenderer::SetSpriteFont(int fontNum, int sprite, int rows, int columns, int charWidth, int charHeight, int charMin, int charMax, bool use32bit) {
SpriteFont *font = getFontFor(fontNum);
font->SpriteNumber = sprite;
font->Rows = rows;
font->Columns = columns;
font->MinChar = charMin;
font->MaxChar = charMax;
font->Use32bit = use32bit;
font->CharHeight = charHeight;
font->CharWidth = charWidth;
}
void SpriteFontRenderer::EnsureTextValidForFont(char *text, int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
for (int i = 0; i < (int)strlen(text); i++) {
if (text[i] < font->MinChar || text[i] > font->MaxChar) {
if (font->MinChar < 63 || font->MaxChar > 63) text[i] = 63;
else text[i] = font->MinChar;
}
}
}
bool SpriteFontRenderer::SupportsExtendedCharacters(int fontNumber) {
return false;
}
int SpriteFontRenderer::GetTextWidth(const char *text, int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
int len = (int)strlen(text);
return font->CharWidth * len;
}
int SpriteFontRenderer::GetTextHeight(const char *text, int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
return font->CharHeight;
}
int SpriteFontRenderer::GetFontHeight(int fontNumber) {
SpriteFont *font = getFontFor(fontNumber);
return font->CharHeight;
}
SpriteFont *SpriteFontRenderer::getFontFor(int fontNum) {
SpriteFont *font;
for (int i = 0; i < (int)_fonts.size(); i ++) {
font = _fonts.at(i);
if (font->FontReplaced == fontNum) return font;
}
//not found
font = new SpriteFont();
font->FontReplaced = fontNum;
_fonts.push_back(font);
return font;
}
void SpriteFontRenderer::RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) {
SpriteFont *font = getFontFor(fontNumber);
//BITMAP *vScreen = _engine->GetVirtualScreen();
//_engine->SetVirtualScreen(destination);
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
char c = text[i];
c -= font->MinChar;
int row = c / font->Columns;
int column = c % font->Columns;
BITMAP *src = _engine->GetSpriteGraphic(font->SpriteNumber);
Draw(src, destination, x + (i * font->CharWidth), y, column * font->CharWidth, row * font->CharHeight, font->CharWidth, font->CharHeight, colour);
}
//_engine->SetVirtualScreen(vScreen);
}
void SpriteFontRenderer::Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour) {
int32 srcWidth, srcHeight, destWidth, destHeight, srcColDepth, destColDepth;
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 transColor = _engine->GetBitmapTransparentColor(src);
int srcPitch = _engine->GetBitmapPitch(src);
int destPitch = _engine->GetBitmapPitch(dest);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, &srcColDepth);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, &destColDepth);
int bpp = destColDepth / 8;
if (srcy + height > srcHeight || srcx + width > srcWidth || srcx < 0 || srcy < 0) return;
if (width + destx > destWidth) width = destWidth - destx;
if (height + desty > destHeight) height = destHeight - desty;
int startx = MAX(0, (-1 * destx));
int starty = MAX(0, (-1 * desty));
int srca, srcr, srcg, srcb, desta, destr, destg, destb, finalr, finalg, finalb, finala, col, col_r, col_g, col_b;
col_r = getr32(colour);
col_g = getg32(colour);
col_b = getb32(colour);
int srcxx = (startx + srcx) * bpp;
int destxx = (startx + destx) * bpp;
for (int x = startx; x < width; ++x, srcxx += bpp, destxx += bpp) {
int srcyy = (starty + srcy) * srcPitch;
int destyy = (starty + desty) * destPitch;
for (int y = starty; y < height; ++y, srcyy += srcPitch, destyy += destPitch) {
uint8 *srcCol = srccharbuffer + srcyy + srcxx;
uint8 *destCol = destcharbuffer + destyy + destxx;
if (destColDepth == 8) {
if (*srcCol != transColor)
*destCol = *srcCol;
} else if (destColDepth == 16) {
if (*((uint16 *)srcCol) != transColor)
*((uint16 *)destCol) = *((uint16 *)srcCol);
} else if (destColDepth == 32) {
//if (*((uint32*)srcCol) != transColor)
// *((uint32*)destCol) = *((uint32*)srcCol);
uint32 srcargb = *((uint32 *)srcCol);
uint32 &destargb = *((uint32 *)destCol);
srca = (geta32(srcargb));
if (srca != 0) {
srcr = getr32(srcargb);
srcg = getg32(srcargb);
srcb = getb32(srcargb);
destr = getr32(destargb);
destg = getg32(destargb);
destb = getb32(destargb);
desta = geta32(destargb);
finalr = (col_r * srcr) / 255;
finalg = (col_g * srcg) / 255;
finalb = (col_b * srcb) / 255;
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * finalr / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * finalg / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * finalb / finala + desta * destb * (255 - srca) / finala / 255;
col = makeacol32(finalr, finalg, finalb, finala);
destargb = col;
}
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,70 @@
/* 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_SPRITE_FONT_SPR_FONT_RENDERER_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_SPR_FONT_RENDERER_H
#include "ags/plugins/ags_sprite_font/sprite_font.h"
#include "ags/plugins/ags_plugin.h"
#include "common/std/vector.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class SpriteFontRenderer : public IAGSFontRenderer2 {
protected:
IAGSEngine *_engine;
SpriteFont *getFontFor(int fontNum);
void Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour);
std::vector<SpriteFont *> _fonts;
public:
SpriteFontRenderer(IAGSEngine *engine);
virtual ~SpriteFontRenderer();
void SetSpriteFont(int fontNum, int sprite, int rows, int columns, int charWidth, int charHeight, int charMin, int charMax, bool use32bit);
// IAGSFontRenderer implementation
bool LoadFromDisk(int fontNumber, int fontSize) override {
return true;
}
void FreeMemory(int fontNumber) override;
bool SupportsExtendedCharacters(int fontNumber) override;
int GetTextWidth(const char *text, int fontNumber) override;
int GetTextHeight(const char *text, int fontNumber) override;
void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override;
void AdjustYCoordinateForFont(int *ycoord, int fontNumber) override { }
void EnsureTextValidForFont(char *text, int fontNumber) override;
// IAGSFontRenderer2 implementation
int GetVersion() override { return 26; /* compatible engine API ver */ }
const char *GetRendererName() override { return "SpriteFontRenderer"; }
const char *GetFontName(int fontNumber) override { return ""; /* not supported */ }
int GetFontHeight(int fontNumber) override;
int GetLineSpacing(int fontNumber) override { return 0; /* not specified */ }
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,138 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/sprite_font_renderer_clifftop.h"
#include "ags/plugins/ags_sprite_font/color.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
SpriteFontRendererClifftop::SpriteFontRendererClifftop(IAGSEngine *engine) : SpriteFontRenderer(engine) {
}
SpriteFontRendererClifftop::~SpriteFontRendererClifftop(void) {
}
bool SpriteFontRendererClifftop::SupportsExtendedCharacters(int fontNumber) {
return true;
}
void SpriteFontRendererClifftop::RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) {
SpriteFont *font = getFontFor(fontNumber);
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
char c = text[i];
c -= font->MinChar;
int row = c / font->Columns;
int column = c % font->Columns;
BITMAP *src = _engine->GetSpriteGraphic(font->SpriteNumber);
Draw(src, destination, x + (i * font->CharWidth), y, column * font->CharWidth, row * font->CharHeight, font->CharWidth, font->CharHeight, colour);
}
}
void SpriteFontRendererClifftop::Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour) {
int32 srcWidth = 0, srcHeight = 0, destWidth = 0, destHeight = 0, srcColDepth = 0, destColDepth = 0;
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 transColor = _engine->GetBitmapTransparentColor(src);
int srcPitch = _engine->GetBitmapPitch(src);
int destPitch = _engine->GetBitmapPitch(dest);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, &srcColDepth);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, &destColDepth);
int bpp = destColDepth / 8;
if (srcy + height > srcHeight || srcx + width > srcWidth || srcx < 0 || srcy < 0) return;
if (width + destx > destWidth) width = destWidth - destx;
if (height + desty > destHeight) height = destHeight - desty;
int startx = MAX(0, (-1 * destx));
int starty = MAX(0, (-1 * desty));
int srca, srcr, srcg, srcb, desta, destr, destg, destb, finalr, finalg, finalb, finala, col, col_r, col_g, col_b;
col_r = getr32(colour);
col_g = getg32(colour);
col_b = getb32(colour);
int srcxx = (startx + srcx) * bpp;
int destxx = (startx + destx) * bpp;
for (int x = startx; x < width; ++x, srcxx += bpp, destxx += bpp) {
int srcyy = (starty + srcy) * srcPitch;
int destyy = (starty + desty) * destPitch;
for (int y = starty; y < height; ++y, srcyy += srcPitch, destyy += destPitch) {
uint8 *srcCol = srccharbuffer + srcyy + srcxx;
uint8 *destCol = destcharbuffer + destyy + destxx;
if (destColDepth == 8) {
if (*srcCol != transColor)
*destCol = *srcCol;
} else if (destColDepth == 16) {
if (*((uint16 *)srcCol) != transColor)
*((uint16 *)destCol) = *((uint16 *)srcCol);
} else if (destColDepth == 32) {
//if (*((uint32*)srcCol) != transColor)
// *((uint32*)destCol) = *((uint32*)srcCol);
uint32 srcargb = *((uint32 *)srcCol);
uint32 &destargb = *((uint32 *)destCol);
srca = (geta32(srcargb));
if (srca != 0) {
srcr = getr32(srcargb);
srcg = getg32(srcargb);
srcb = getb32(srcargb);
destr = getr32(destargb);
destg = getg32(destargb);
destb = getb32(destargb);
desta = geta32(destargb);
finalr = (col_r * srcr) / 255;
finalg = (col_g * srcg) / 255;
finalb = (col_b * srcb) / 255;
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * col_r / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * col_g / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * col_b / finala + desta * destb * (255 - srca) / finala / 255;
col = makeacol32(finalr, finalg, finalb, finala);
destargb = col;
}
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_SPRITE_FONT_SPR_FONT_RENDERER_CLIFFTOP_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_SPR_FONT_RENDERER_CLIFFTOP_H
#include "ags/plugins/ags_sprite_font/sprite_font_renderer.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class SpriteFontRendererClifftop : public SpriteFontRenderer {
public:
SpriteFontRendererClifftop(IAGSEngine *engine);
~SpriteFontRendererClifftop(void) override;
bool SupportsExtendedCharacters(int fontNumber) override;
void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override;
private:
void Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour);
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,44 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/variable_width_font.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
void VariableWidthFont::SetGlyph(int character, int x, int y, int width, int height) {
characters[character].X = x;
characters[character].Y = y;
characters[character].Width = width;
characters[character].Height = height;
characters[character].Character = character;
}
void VariableWidthFont::SetLineHeightAdjust(int LineHeight, int SpacingHeight, int SpacingOverride) {
LineHeightAdjust = LineHeight;
LineSpacingAdjust = SpacingHeight;
LineSpacingOverride = SpacingOverride;
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,53 @@
/* 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_SPRITE_FONT_VAR_WIDTH_FONT_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_VAR_WIDTH_FONT_H
#include "ags/plugins/ags_sprite_font/character_entry.h"
#include "ags/plugins/ags_plugin.h"
#include "common/std/map.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class VariableWidthFont {
public:
int SpriteNumber = 0;
int FontReplaced = 0;
int Spacing = 0;
std::map<char, CharacterEntry> characters;
// Clifftop Games custom plugin support
int LineHeightAdjust = 0;
int LineSpacingAdjust = 0;
int LineSpacingOverride = 0;
public:
void SetGlyph(int character, int x, int y, int width, int height);
void SetLineHeightAdjust(int LineHeight, int SpacingHeight, int SpacingOverride);
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,260 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/variable_width_sprite_font.h"
#include "ags/plugins/ags_sprite_font/color.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
VariableWidthSpriteFontRenderer::VariableWidthSpriteFontRenderer(IAGSEngine *engine) {
_engine = engine;
}
VariableWidthSpriteFontRenderer::~VariableWidthSpriteFontRenderer(void) {
}
void VariableWidthSpriteFontRenderer::FreeMemory(int fontNum) {
for(auto it = _fonts.begin(); it != _fonts.end() ; ++it) {
VariableWidthFont *font = *it;
if (font->FontReplaced == fontNum) {
_fonts.erase(it);
delete font;
return;
}
}
}
bool VariableWidthSpriteFontRenderer::SupportsExtendedCharacters(int fontNumber) {
return false;
}
int VariableWidthSpriteFontRenderer::GetTextWidth(const char *text, int fontNumber) {
int total = 0;
VariableWidthFont *font = getFontFor(fontNumber);
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
if (font->characters.count(text[i]) > 0) {
total += font->characters[text[i]].Width;
if (text[i] != ' ') total += font->Spacing;
}
}
return total;
}
int VariableWidthSpriteFontRenderer::GetTextHeight(const char *text, int fontNumber) {
VariableWidthFont *font = getFontFor(fontNumber);
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
if (font->characters.count(text[i]) > 0) {
return font->characters[text[i]].Height;
}
}
return 0;
}
int VariableWidthSpriteFontRenderer::GetFontHeight(int fontNumber) {
VariableWidthFont *font = getFontFor(fontNumber);
if (font->characters.size() > 0) {
return font->characters.begin()->_value.Height + font->LineSpacingAdjust;
}
return 0;
}
int VariableWidthSpriteFontRenderer::GetLineSpacing(int fontNumber) {
// CHECKME: it's not clear whether LineSpacingOverride was ever meant as an
// actual, normal line spacing. In Clifftop's custom engine this value has
// been used specifically to tell the spacing for *empty lines* when
// printing a wrapped text on a GUI Label. Official engine does not have
// such functionality.
return 0; // use default (font height)
}
void VariableWidthSpriteFontRenderer::SetSpacing(int fontNum, int spacing) {
VariableWidthFont *font = getFontFor(fontNum);
font->Spacing = spacing;
}
void VariableWidthSpriteFontRenderer::SetLineHeightAdjust(int fontNum, int lineHeight, int spacingHeight, int spacingOverride) {
VariableWidthFont *font = getFontFor(fontNum);
font->LineHeightAdjust = lineHeight;
font->LineSpacingAdjust = spacingHeight;
font->LineSpacingOverride = spacingOverride;
char buf[1024];
snprintf(buf, sizeof(buf),
"VariableWidth::SetLineHeightAdjust: font %d, lineHeight %d, spacingHeight %d, spacingOverride %d",
fontNum, lineHeight, spacingHeight, spacingOverride);
_engine->PrintDebugConsole(buf);
if (_engine->version >= 26)
_engine->NotifyFontUpdated(fontNum);
}
void VariableWidthSpriteFontRenderer::EnsureTextValidForFont(char *text, int fontNumber) {
VariableWidthFont *font = getFontFor(fontNumber);
Common::String s(text);
size_t ln = s.size();
for (int i = (int)s.size() - 1; i >= 0 ; i--) {
if (font->characters.count(s[i]) == 0) {
s.erase(i, 1);
}
}
// We never grow the text
Common::strcpy_s(text, ln + 1, s.c_str());
}
void VariableWidthSpriteFontRenderer::SetGlyph(int fontNum, int charNum, int x, int y, int width, int height) {
VariableWidthFont *font = getFontFor(fontNum);
font->SetGlyph(charNum, x, y, width, height);
// Only notify engine at the first engine glyph,
// that should be enough for calculating font height metrics,
// and will reduce work load (sadly there's no Begin/EndUpdate functions).
if ((_engine->version >= 26) && (font->characters.size() == 1))
_engine->NotifyFontUpdated(fontNum);
}
void VariableWidthSpriteFontRenderer::SetSprite(int fontNum, int spriteNum) {
VariableWidthFont *font = getFontFor(fontNum);
font->SpriteNumber = spriteNum;
}
VariableWidthFont *VariableWidthSpriteFontRenderer::getFontFor(int fontNum) {
VariableWidthFont *font;
for (int i = 0; i < (int)_fonts.size(); i ++) {
font = _fonts.at(i);
if (font->FontReplaced == fontNum) return font;
}
//not found
font = new VariableWidthFont;
font->FontReplaced = fontNum;
_fonts.push_back(font);
return font;
}
void VariableWidthSpriteFontRenderer::RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) {
VariableWidthFont *font = getFontFor(fontNumber);
int totalWidth = 0;
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
char c = text[i];
BITMAP *src = _engine->GetSpriteGraphic(font->SpriteNumber);
Draw(src, destination, x + totalWidth, y, font->characters[c].X, font->characters[c].Y, font->characters[c].Width, font->characters[c].Height, colour);
totalWidth += font->characters[c].Width;
if (text[i] != ' ') totalWidth += font->Spacing;
}
}
void VariableWidthSpriteFontRenderer::Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour) {
int32 srcWidth, srcHeight, destWidth, destHeight, srcColDepth, destColDepth;
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 transColor = _engine->GetBitmapTransparentColor(src);
int srcPitch = _engine->GetBitmapPitch(src);
int destPitch = _engine->GetBitmapPitch(dest);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, &srcColDepth);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, &destColDepth);
int bpp = destColDepth / 8;
if (srcy + height > srcHeight || srcx + width > srcWidth || srcx < 0 || srcy < 0) return;
if (width + destx > destWidth) width = destWidth - destx;
if (height + desty > destHeight) height = destHeight - desty;
int startx = MAX(0, (-1 * destx));
int starty = MAX(0, (-1 * desty));
int srca, srcr, srcg, srcb, desta, destr, destg, destb, finalr, finalg, finalb, finala, col, col_r, col_g, col_b;;
col_r = getr32(colour);
col_g = getg32(colour);
col_b = getb32(colour);
int srcxx = (startx + srcx) * bpp;
int destxx = (startx + destx) * bpp;
for (int x = startx; x < width; ++x, srcxx += bpp, destxx += bpp) {
int srcyy = (starty + srcy) * srcPitch;
int destyy = (starty + desty) * destPitch;
for (int y = starty; y < height; ++y, srcyy += srcPitch, destyy += destPitch) {
uint8 *srcCol = srccharbuffer + srcyy + srcxx;
uint8 *destCol = destcharbuffer + destyy + destxx;
if (destColDepth == 8) {
if (*srcCol != transColor)
*destCol = *srcCol;
} else if (destColDepth == 16) {
if (*((uint16 *)srcCol) != transColor)
*((uint16 *)destCol) = *((uint16 *)srcCol);
} else if (destColDepth == 32) {
//if (*((uint32*)srcCol) != transColor)
// *((uint32*)destCol) = *((uint32*)srcCol);
uint32 srcargb = *((uint32 *)srcCol);
uint32 &destargb = *((uint32 *)destCol);
srca = (geta32(srcargb));
if (srca != 0) {
srcr = getr32(srcargb);
srcg = getg32(srcargb);
srcb = getb32(srcargb);
destr = getr32(destargb);
destg = getg32(destargb);
destb = getb32(destargb);
desta = geta32(destargb);
finalr = (col_r * srcr) / 255;
finalg = (col_g * srcg) / 255;
finalb = (col_b * srcb) / 255;
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * finalr / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * finalg / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * finalb / finala + desta * destb * (255 - srca) / finala / 255;
col = makeacol32(finalr, finalg, finalb, finala);
destargb = col;
}
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,75 @@
/* 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_SPRITE_FONT_VAR_WIDTH_SPR_FONT_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_VAR_WIDTH_SPR_FONT_H
#include "ags/plugins/plugin_base.h"
#include "ags/plugins/ags_plugin.h"
#include "ags/plugins/ags_sprite_font/variable_width_font.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class VariableWidthSpriteFontRenderer : public IAGSFontRenderer2 {
protected:
IAGSEngine *_engine;
std::vector<VariableWidthFont *> _fonts;
VariableWidthFont *getFontFor(int fontNum);
void Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour);
public:
VariableWidthSpriteFontRenderer(IAGSEngine *engine);
virtual ~VariableWidthSpriteFontRenderer();
void SetGlyph(int fontNum, int charNum, int x, int y, int width, int height);
void SetSprite(int fontNum, int spriteNum);
void SetSpacing(int fontNum, int spacing);
// Clifftop Games custom plugin support
void SetLineHeightAdjust(int fontNum, int LineHeight, int SpacingHeight, int SpacingOverride);
// IAGSFontRenderer implementation
bool LoadFromDisk(int fontNumber, int fontSize) override {
return true;
}
void FreeMemory(int fontNumber) override;
bool SupportsExtendedCharacters(int fontNumber) override;
int GetTextWidth(const char *text, int fontNumber) override;
int GetTextHeight(const char *text, int fontNumber) override;
void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override;
void AdjustYCoordinateForFont(int *ycoord, int fontNumber) override { }
void EnsureTextValidForFont(char *text, int fontNumber) override;
// IAGSFontRenderer2 implementation
int GetVersion() override { return 26; /* compatible engine API ver */ }
const char *GetRendererName() override { return "VariableWidthSpriteFontRenderer"; }
const char *GetFontName(int fontNumber) override { return ""; /* not supported */ }
int GetFontHeight(int fontNumber) override;
int GetLineSpacing(int fontNumber) override;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,136 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_sprite_font/variable_width_sprite_font_clifftop.h"
#include "ags/plugins/ags_sprite_font/color.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
VariableWidthSpriteFontRendererClifftop::VariableWidthSpriteFontRendererClifftop(IAGSEngine *engine) : VariableWidthSpriteFontRenderer(engine) {
}
VariableWidthSpriteFontRendererClifftop::~VariableWidthSpriteFontRendererClifftop(void) {
}
void VariableWidthSpriteFontRendererClifftop::RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) {
VariableWidthFont *font = getFontFor(fontNumber);
int totalWidth = 0;
int len_text = (int)strlen(text);
for (int i = 0; i < len_text; i++) {
char c = text[i];
BITMAP *src = _engine->GetSpriteGraphic(font->SpriteNumber);
Draw(src, destination, x + totalWidth, y, font->characters[c].X, font->characters[c].Y, font->characters[c].Width, font->characters[c].Height, colour);
totalWidth += font->characters[c].Width;
if (text[i] != ' ') totalWidth += font->Spacing;
}
}
void VariableWidthSpriteFontRendererClifftop::Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour) {
int32 srcWidth, srcHeight, destWidth, destHeight, srcColDepth, destColDepth;
uint8 *srccharbuffer = _engine->GetRawBitmapSurface(src);
uint8 *destcharbuffer = _engine->GetRawBitmapSurface(dest);
uint32 transColor = _engine->GetBitmapTransparentColor(src);
int srcPitch = _engine->GetBitmapPitch(src);
int destPitch = _engine->GetBitmapPitch(dest);
_engine->GetBitmapDimensions(src, &srcWidth, &srcHeight, &srcColDepth);
_engine->GetBitmapDimensions(dest, &destWidth, &destHeight, &destColDepth);
int bpp = destColDepth / 8;
if (srcy + height > srcHeight || srcx + width > srcWidth || srcx < 0 || srcy < 0) return;
if (width + destx > destWidth) width = destWidth - destx;
if (height + desty > destHeight) height = destHeight - desty;
int startx = MAX(0, (-1 * destx));
int starty = MAX(0, (-1 * desty));
int srca, srcr, srcg, srcb, desta, destr, destg, destb, finalr, finalg, finalb, finala, col, col_r, col_g, col_b;
col_r = getr32(colour);
col_g = getg32(colour);
col_b = getb32(colour);
int srcxx = (startx + srcx) * bpp;
int destxx = (startx + destx) * bpp;
for (int x = startx; x < width; ++x, srcxx += bpp, destxx += bpp) {
int srcyy = (starty + srcy) * srcPitch;
int destyy = (starty + desty) * destPitch;
for (int y = starty; y < height; ++y, srcyy += srcPitch, destyy += destPitch) {
uint8 *srcCol = srccharbuffer + srcyy + srcxx;
uint8 *destCol = destcharbuffer + destyy + destxx;
if (destColDepth == 8) {
if (*srcCol != transColor)
*destCol = *srcCol;
} else if (destColDepth == 16) {
if (*((uint16 *)srcCol) != transColor)
*((uint16 *)destCol) = *((uint16 *)srcCol);
} else if (destColDepth == 32) {
//if (*((uint32*)srcCol) != transColor)
// *((uint32*)destCol) = *((uint32*)srcCol);
uint32 srcargb = *((uint32 *)srcCol);
uint32 &destargb = *((uint32 *)destCol);
srca = (geta32(srcargb));
if (srca != 0) {
srcr = getr32(srcargb);
srcg = getg32(srcargb);
srcb = getb32(srcargb);
destr = getr32(destargb);
destg = getg32(destargb);
destb = getb32(destargb);
desta = geta32(destargb);
finalr = (col_r * srcr) / 255;
finalg = (col_g * srcg) / 255;
finalb = (col_b * srcb) / 255;
finala = 255 - (255 - srca) * (255 - desta) / 255;
finalr = srca * finalr / finala + desta * destr * (255 - srca) / finala / 255;
finalg = srca * finalg / finala + desta * destg * (255 - srca) / finala / 255;
finalb = srca * finalb / finala + desta * destb * (255 - srca) / finala / 255;
col = makeacol32(finalr, finalg, finalb, finala);
destargb = col;
}
}
}
}
_engine->ReleaseBitmapSurface(src);
_engine->ReleaseBitmapSurface(dest);
}
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,48 @@
/* 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_SPRITE_FONT_VAR_WIDTH_SPR_FONT_CLIFFTOP_H
#define AGS_PLUGINS_AGS_SPRITE_FONT_VAR_WIDTH_SPR_FONT_CLIFFTOP_H
#include "ags/plugins/ags_sprite_font/variable_width_sprite_font.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteFont {
class VariableWidthSpriteFontRendererClifftop : public VariableWidthSpriteFontRenderer {
private:
void Draw(BITMAP *src, BITMAP *dest, int destx, int desty, int srcx, int srcy, int width, int height, int colour);
public:
VariableWidthSpriteFontRendererClifftop(IAGSEngine *engine);
~VariableWidthSpriteFontRendererClifftop(void) override;
void RenderText(const char *text, int fontNumber, BITMAP *destination, int x, int y, int colour) override;
};
} // namespace AGSSpriteFont
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,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/>.
*
*/
#include "ags/plugins/ags_sprite_video/ags_sprite_video.h"
#include "common/debug.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteVideo {
const char *AGSSpriteVideo::AGS_GetPluginName() {
return "AGS SpriteVideo Plugin";
}
int LoopsPerSecond;
char video_filename[200];
struct D3D : public IAGSScriptManagedObject {
public:
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "D3D";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
struct D3DVideo : public IAGSScriptManagedObject {
public:
int Dispose(void *address, bool force) override {
delete this;
return true;
}
const char *GetType() override {
return "D3DVideo";
};
int Serialize(void *address, char *buffer, int bufsize) override {
return 0;
}
};
void AGSSpriteVideo::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(D3D::SetLoopsPerSecond^1, AGSSpriteVideo::SetLoopsPerSecond);
SCRIPT_METHOD(D3D::OpenVideo^1, AGSSpriteVideo::OpenVideo);
SCRIPT_METHOD(D3D::OpenSprite, AGSSpriteVideo::OpenSprite);
SCRIPT_METHOD(D3D::OpenSpriteFile, AGSSpriteVideo::OpenSpriteFile);
SCRIPT_METHOD(D3D_Video::get_scaling, AGSSpriteVideo::get_scaling);
SCRIPT_METHOD(D3D_Video::set_scaling, AGSSpriteVideo::set_scaling);
SCRIPT_METHOD(D3D_Video::get_relativeTo, AGSSpriteVideo::get_relativeTo);
SCRIPT_METHOD(D3D_Video::set_relativeTo, AGSSpriteVideo::set_relativeTo);
SCRIPT_METHOD(D3D_Video::get_isLooping, AGSSpriteVideo::get_isLooping);
SCRIPT_METHOD(D3D_Video::set_isLooping, AGSSpriteVideo::set_isLooping);
SCRIPT_METHOD(D3D_Video::SetAnchor^2, AGSSpriteVideo::SetAnchor);
SCRIPT_METHOD(D3D_Video::Autoplay^0, AGSSpriteVideo::Autoplay);
SCRIPT_METHOD(D3D_Video::IsAutoplaying, AGSSpriteVideo::IsAutoplaying);
SCRIPT_METHOD(D3D_Video::StopAutoplay, AGSSpriteVideo::StopAutoplay);
SCRIPT_METHOD(D3D_Video::get_renderStage, AGSSpriteVideo::get_renderstage);
SCRIPT_METHOD(D3D_Video::set_renderStage, AGSSpriteVideo::set_renderstage);
SCRIPT_METHOD(D3D_Video::NextFrame^0, AGSSpriteVideo::NextFrame);
}
void AGSSpriteVideo::SetLoopsPerSecond(ScriptMethodParams &params) {
PARAMS1(int, loops);
debug(0, "AGSSpriteVideo: STUB - D3D SetLoopsPerSecond: %d", loops);
LoopsPerSecond = loops;
}
void AGSSpriteVideo::OpenVideo(ScriptMethodParams &params) {
PARAMS1(char *, filename);
debug(0, "AGSSpriteVideo: STUB - D3D OpenVideo: %s", filename);
D3DVideo *video = new D3DVideo();
_engine->RegisterManagedObject(video, video);
strncpy(video_filename, filename, sizeof(video_filename) - 1);
LoopsPerSecond = 40;
params._result = video;
}
void AGSSpriteVideo::OpenSprite(ScriptMethodParams &params) {
// PARAMS1(int, graphic);
debug(0, "AGSSpriteVideo: STUB - D3D OpenSprite");
params._result = 0;
}
void AGSSpriteVideo::OpenSpriteFile(ScriptMethodParams &params) {
// PARAMS2(char *, filename, int, filtering);
debug(0, "AGSSpriteVideo: STUB - D3D OpenSpriteFile");
params._result = 0;
}
void AGSSpriteVideo::get_scaling(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3DVideo get_scaling");
params._result = 1;
}
void AGSSpriteVideo::set_scaling(ScriptMethodParams &params) {
// PARAMS1(float, scaling);
debug(0, "AGSSpriteVideo: STUB - D3DVideo set_scaling");
}
void AGSSpriteVideo::get_relativeTo(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3DVideo get_relativeTo");
params._result = 1;
}
void AGSSpriteVideo::set_relativeTo(ScriptMethodParams &params) {
// PARAMS1(int, relative_to);
debug(0, "AGSSpriteVideo: STUB - D3DVideo set_relativeTo");
}
void AGSSpriteVideo::get_isLooping(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3DVideo get_isLooping");
params._result = false;
}
void AGSSpriteVideo::set_isLooping(ScriptMethodParams &params) {
// PARAMS1(bool, looping);
debug(0, "AGSSpriteVideo: STUB - D3DVideo set_isLooping");
}
void AGSSpriteVideo::SetAnchor(ScriptMethodParams &params) {
// PARAMS2(float, x, float, y);
debug(0, "AGSSpriteVideo: STUB - D3DVideo SetAnchor");
}
void AGSSpriteVideo::Autoplay(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3DVideo Autoplay");
warning("Current video: %s", video_filename);
warning("Video playback is not yet implemented");
}
void AGSSpriteVideo::IsAutoplaying(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3D IsAutoPlaying");
params._result = false;
}
void AGSSpriteVideo::StopAutoplay(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3D StopAutoplay");
}
void AGSSpriteVideo::get_renderstage(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3D get_renderstage");
}
void AGSSpriteVideo::set_renderstage(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3D set_renderstage");
}
void AGSSpriteVideo::NextFrame(ScriptMethodParams &params) {
debug(0, "AGSSpriteVideo: STUB - D3D NextFrame");
}
} // namespace AGSSpriteVideo
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,66 @@
/* 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_SPRITE_VIDEO_H
#define AGS_PLUGINS_AGS_SPRITE_VIDEO_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSSpriteVideo {
class AGSSpriteVideo : public PluginBase {
SCRIPT_HASH(AGSSpriteVideo)
protected:
void SetLoopsPerSecond(ScriptMethodParams &params);
void OpenVideo(ScriptMethodParams &params);
void OpenSprite(ScriptMethodParams &params);
void OpenSpriteFile(ScriptMethodParams &params);
void get_scaling(ScriptMethodParams &params);
void set_scaling(ScriptMethodParams &params);
void get_relativeTo(ScriptMethodParams &params);
void set_relativeTo(ScriptMethodParams &params);
void get_isLooping(ScriptMethodParams &params);
void set_isLooping(ScriptMethodParams &params);
void SetAnchor(ScriptMethodParams &params);
void Autoplay(ScriptMethodParams &params);
void IsAutoplaying(ScriptMethodParams &params);
void StopAutoplay(ScriptMethodParams &params);
void get_renderstage(ScriptMethodParams &params);
void set_renderstage(ScriptMethodParams &params);
void NextFrame(ScriptMethodParams &params);
public:
AGSSpriteVideo() : PluginBase() {}
virtual ~AGSSpriteVideo() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSSpriteVideo
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,38 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_tcp_ip/ags_tcp_ip.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTcpIp {
const char *AGSTcpIp::AGS_GetPluginName() {
return "TCP/IP (a-v-o)";
}
void AGSTcpIp::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
}
} // namespace AGSTcpIp
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,46 @@
/* 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_TCP_IP_AGS_TCP_IP_H
#define AGS_PLUGINS_AGS_TCP_IP_AGS_TCP_IP_H
#include "ags/plugins/ags_plugin.h"
#include "ags/lib/allegro.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTcpIp {
class AGSTcpIp : public PluginBase {
SCRIPT_HASH(AGSTcpIp)
public:
AGSTcpIp() : PluginBase() {}
virtual ~AGSTcpIp() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSTcpIp
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,55 @@
/* 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/>.
*
*/
#include "common/system.h"
#include "ags/plugins/ags_touch/ags_touch.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTouch {
const char *AGSTouch::AGS_GetPluginName() {
return "Touch device control";
}
void AGSTouch::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(TouchShowKeyboard, AGSTouch::TouchShowKeyboard);
SCRIPT_METHOD(TouchHideKeyboard, AGSTouch::TouchHideKeyboard);
SCRIPT_METHOD(TouchIsKeyboardVisible, AGSTouch::TouchIsKeyboardVisible);
}
void AGSTouch::TouchShowKeyboard(ScriptMethodParams &params) {
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
}
void AGSTouch::TouchHideKeyboard(ScriptMethodParams &params) {
g_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
}
void AGSTouch::TouchIsKeyboardVisible(ScriptMethodParams &params) {
params._result = g_system->getFeatureState(OSystem::kFeatureVirtualKeyboard);
}
} // namespace AGSTouch
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,49 @@
/* 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_TOUCH_AGS_TOUCH_H
#define AGS_PLUGINS_AGS_TOUCH_AGS_TOUCH_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTouch {
class AGSTouch : public PluginBase {
SCRIPT_HASH(AGSTouch)
public:
AGSTouch() : PluginBase() {}
virtual ~AGSTouch() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
void TouchShowKeyboard(ScriptMethodParams &params);
void TouchHideKeyboard(ScriptMethodParams &params);
void TouchIsKeyboardVisible(ScriptMethodParams &params);
};
} // namespace AGSTouch
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,81 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_trans/ags_trans.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTrans {
const char *AGSTrans::AGS_GetPluginName() {
return "AGS Trans";
}
void AGSTrans::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(GenerateArray, AGSTrans::GenerateArray);
SCRIPT_METHOD(LoadArray, AGSTrans::LoadArray);
SCRIPT_METHOD(CreateTransparentOverlay, AGSTrans::CreateTransparentOverlay);
SCRIPT_METHOD(CreateColorisedOverlay, AGSTrans::CreateColorisedOverlay);
SCRIPT_METHOD(RemoveTransOverlay, AGSTrans::RemoveTransOverlay);
SCRIPT_METHOD(ChangeOverlayAlpha, AGSTrans::ChangeOverlayAlpha);
SCRIPT_METHOD(ChangeOverlayPosition, AGSTrans::ChangeOverlayPosition);
}
void AGSTrans::GenerateArray(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::GenerateArray");
}
void AGSTrans::LoadArray(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::LoadArray");
}
void AGSTrans::CreateTransparentOverlay(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::CreateTransparentOverlay");
}
void AGSTrans::CreateColorisedOverlay(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::CreateColorisedOverlay");
}
void AGSTrans::RemoveTransOverlay(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::RemoveTransOverlay");
}
void AGSTrans::ChangeOverlayAlpha(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::ChangeOverlayAlpha");
}
void AGSTrans::ChangeOverlayPosition(ScriptMethodParams &params) {
// TODO
warning("STUB: AGSTrans::ChangeOverlayPosition");
}
} // namespace AGSTrans
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,56 @@
/* 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_TRANS_H
#define AGS_PLUGINS_AGS_TRANS_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSTrans {
class AGSTrans : public PluginBase {
SCRIPT_HASH(AGSTrans)
private:
void GenerateArray(ScriptMethodParams &params);
void LoadArray(ScriptMethodParams &params);
void CreateTransparentOverlay(ScriptMethodParams &params);
void CreateColorisedOverlay(ScriptMethodParams &params);
void RemoveTransOverlay(ScriptMethodParams &params);
void ChangeOverlayAlpha(ScriptMethodParams &params);
void ChangeOverlayPosition(ScriptMethodParams &params);
public:
AGSTrans() : PluginBase() {}
virtual ~AGSTrans() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSTrans
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,53 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_utils/ags_utils.h"
#include "common/system.h"
namespace AGS3 {
namespace Plugins {
namespace AGSUtils {
const char *AGSUtils::AGS_GetPluginName() {
return "AGS Utils";
}
void AGSUtils::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
SCRIPT_METHOD(DebugPrint, AGSUtils::DebugPrint);
SCRIPT_METHOD(GetTime, AGSUtils::GetTime);
}
void AGSUtils::DebugPrint(ScriptMethodParams &params) {
PARAMS1(char *, message);
_engine->PrintDebugConsole(message);
}
void AGSUtils::GetTime(ScriptMethodParams &params) {
params._result = g_system->getMillis();
}
} // namespace AGSUtils
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,50 @@
/* 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_UTILS_H
#define AGS_PLUGINS_AGS_UTILS_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSUtils {
class AGSUtils : public PluginBase {
SCRIPT_HASH(AGSUtils)
private:
void DebugPrint(ScriptMethodParams &params);
void GetTime(ScriptMethodParams &params);
public:
AGSUtils() : PluginBase() {}
virtual ~AGSUtils() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *engine) override;
};
} // namespace AGSUtils
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,85 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_wadjet_util/ags_wadjet_util.h"
#include "ags/shared/core/platform.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWadjetUtil {
const char *AGSWadjetUtil::AGS_GetPluginName() {
return "AGSWadjetUtil";
}
void AGSWadjetUtil::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
// Register functions
SCRIPT_METHOD(IsOnPhone, AGSWadjetUtil::IsOnPhone);
SCRIPT_METHOD(FakeKeypress, AGSWadjetUtil::FakeKeypress);
SCRIPT_METHOD(IosSetAchievementValue, AGSWadjetUtil::IosSetAchievementValue);
SCRIPT_METHOD(IosGetAchievementValue, AGSWadjetUtil::IosGetAchievementValue);
SCRIPT_METHOD(IosShowAchievements, AGSWadjetUtil::IosShowAchievements);
SCRIPT_METHOD(IosResetAchievements, AGSWadjetUtil::IosResetAchievements);
SCRIPT_METHOD(MobileGetAchievement, AGSWadjetUtil::MobileGetAchievement);
SCRIPT_METHOD(MobileSetAchievement, AGSWadjetUtil::MobileSetAchievement);
SCRIPT_METHOD(MobileShowAchievements, AGSWadjetUtil::MobileShowAchievements);
SCRIPT_METHOD(MobileResetAchievements, AGSWadjetUtil::MobileResetAchievements);
}
void AGSWadjetUtil::IsOnPhone(ScriptMethodParams &params) {
params._result = false;
}
void AGSWadjetUtil::FakeKeypress(ScriptMethodParams &params) {
}
void AGSWadjetUtil::IosSetAchievementValue(ScriptMethodParams &params) {
}
void AGSWadjetUtil::IosGetAchievementValue(ScriptMethodParams &params) {
params._result = -1;
}
void AGSWadjetUtil::IosShowAchievements(ScriptMethodParams &params) {
}
void AGSWadjetUtil::IosResetAchievements(ScriptMethodParams &params) {
}
void AGSWadjetUtil::MobileGetAchievement(ScriptMethodParams &params) {
params._result = NumberPtr();
}
void AGSWadjetUtil::MobileSetAchievement(ScriptMethodParams &params) {
params._result = 0;
}
void AGSWadjetUtil::MobileShowAchievements(ScriptMethodParams &params) {
}
void AGSWadjetUtil::MobileResetAchievements(ScriptMethodParams &params) {
}
} // namespace AGSWadjetUtil
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,57 @@
/* 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_WADJET_UTIL_AGS_WADJET_UTIL_H
#define AGS_PLUGINS_AGS_WADJET_UTIL_AGS_WADJET_UTIL_H
#include "ags/plugins/ags_plugin.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWadjetUtil {
class AGSWadjetUtil : public PluginBase {
SCRIPT_HASH(AGSWadjetUtil)
private:
void IsOnPhone(ScriptMethodParams &params);
void FakeKeypress(ScriptMethodParams &params);
void IosSetAchievementValue(ScriptMethodParams &params);
void IosGetAchievementValue(ScriptMethodParams &params);
void IosShowAchievements(ScriptMethodParams &params);
void IosResetAchievements(ScriptMethodParams &params);
void MobileGetAchievement(ScriptMethodParams &params);
void MobileSetAchievement(ScriptMethodParams &params);
void MobileShowAchievements(ScriptMethodParams &params);
void MobileResetAchievements(ScriptMethodParams &params);
public:
AGSWadjetUtil() : PluginBase() {}
virtual ~AGSWadjetUtil() {}
const char *AGS_GetPluginName() override;
void AGS_EngineStartup(IAGSEngine *lpEngine) override;
};
} // namespace AGSWadjetUtil
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,199 @@
/* 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/>.
*
*/
#include "ags/plugins/ags_waves/ags_waves.h"
#include "ags/plugins/serializer.h"
#include "ags/ags.h"
#include "ags/globals.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWaves {
AGSWaves::AGSWaves() : PluginBase(), Vars() {
_mixer = ::AGS::g_vm->_mixer;
}
const char *AGSWaves::AGS_GetPluginName() {
return "AGS Waves";
}
void AGSWaves::AGS_EngineStartup(IAGSEngine *engine) {
PluginBase::AGS_EngineStartup(engine);
if (_engine->version < 13)
_engine->AbortGame("Engine interface is too old, need newer version of AGS.");
StartingValues();
Character_GetX = _engine->GetScriptFunctionAddress("Character::get_X");
Character_GetY = _engine->GetScriptFunctionAddress("Character::get_Y");
Character_ID = _engine->GetScriptFunctionAddress("Character::ID");
// Newer versions (after the 2025/04 update) no longer use the plugin to play sounds, so these
// bindings are not needed
if (_G(loaded_game_file_version) < 3060021) {
SCRIPT_METHOD(SFX_Play, AGSWaves::SFX_Play);
SCRIPT_METHOD(SFX_SetVolume, AGSWaves::SFX_SetVolume);
SCRIPT_METHOD(SFX_GetVolume, AGSWaves::SFX_GetVolume);
SCRIPT_METHOD(Music_Play, AGSWaves::Music_Play);
SCRIPT_METHOD(Music_GetVolume, AGSWaves::Music_GetVolume);
SCRIPT_METHOD(Music_SetVolume, AGSWaves::Music_SetVolume);
SCRIPT_METHOD(SFX_Stop, AGSWaves::SFX_Stop);
SCRIPT_METHOD(SFX_SetPosition, AGSWaves::SFX_SetPosition);
SCRIPT_METHOD(SFX_SetGlobalVolume, AGSWaves::SFX_SetGlobalVolume);
SCRIPT_METHOD(Load_SFX, AGSWaves::Load_SFX);
SCRIPT_METHOD(Audio_Apply_Filter, AGSWaves::Audio_Apply_Filter);
SCRIPT_METHOD(Audio_Remove_Filter, AGSWaves::Audio_Remove_Filter);
SCRIPT_METHOD(SFX_AllowOverlap, AGSWaves::SFX_AllowOverlap);
SCRIPT_METHOD(SFX_Filter, AGSWaves::SFX_Filter);
}
SCRIPT_METHOD(DrawScreenEffect, AGSWaves::DrawScreenEffect);
SCRIPT_METHOD(DrawBlur, AGSWaves::DrawBlur);
SCRIPT_METHOD(DrawTunnel, AGSWaves::DrawTunnel);
SCRIPT_METHOD(DrawCylinder, AGSWaves::DrawCylinder);
SCRIPT_METHOD(DrawForceField, AGSWaves::DrawForceField);
SCRIPT_METHOD(Grayscale, AGSWaves::Grayscale);
SCRIPT_METHOD(ReadWalkBehindIntoSprite, AGSWaves::ReadWalkBehindIntoSprite);
SCRIPT_METHOD(AdjustSpriteFont, AGSWaves::AdjustSpriteFont);
SCRIPT_METHOD(SpriteGradient, AGSWaves::SpriteGradient);
SCRIPT_METHOD(Outline, AGSWaves::Outline);
SCRIPT_METHOD(OutlineOnly, AGSWaves::OutlineOnly);
SCRIPT_METHOD(SaveVariable, AGSWaves::SaveVariable);
SCRIPT_METHOD(ReadVariable, AGSWaves::ReadVariable);
SCRIPT_METHOD(GameDoOnceOnly, AGSWaves::GameDoOnceOnly);
SCRIPT_METHOD(SetGDState, AGSWaves::SetGDState);
SCRIPT_METHOD(GetGDState, AGSWaves::GetGDState);
SCRIPT_METHOD(ResetAllGD, AGSWaves::ResetAllGD);
SCRIPT_METHOD(SpriteSkew, AGSWaves::SpriteSkew);
SCRIPT_METHOD(FireUpdate, AGSWaves::FireUpdate);
SCRIPT_METHOD(WindUpdate, AGSWaves::WindUpdate);
SCRIPT_METHOD(SetWindValues, AGSWaves::SetWindValues);
SCRIPT_METHOD(ReturnWidth, AGSWaves::ReturnWidth);
SCRIPT_METHOD(ReturnHeight, AGSWaves::ReturnHeight);
SCRIPT_METHOD(ReturnNewHeight, AGSWaves::ReturnNewHeight);
SCRIPT_METHOD(ReturnNewWidth, AGSWaves::ReturnNewWidth);
SCRIPT_METHOD(Warper, AGSWaves::Warper);
SCRIPT_METHOD(SetWarper, AGSWaves::SetWarper);
SCRIPT_METHOD(RainUpdate, AGSWaves::RainUpdate);
SCRIPT_METHOD(BlendTwoSprites, AGSWaves::BlendTwoSprites);
SCRIPT_METHOD(Blend, AGSWaves::Blend);
SCRIPT_METHOD(Dissolve, AGSWaves::Dissolve);
SCRIPT_METHOD(ReverseTransparency, AGSWaves::ReverseTransparency);
SCRIPT_METHOD(NoiseCreator, AGSWaves::NoiseCreator);
SCRIPT_METHOD(TintProper, AGSWaves::TintProper);
SCRIPT_METHOD(GetWalkbehindBaserine, AGSWaves::GetWalkbehindBaserine);
SCRIPT_METHOD(SetWalkbehindBaserine, AGSWaves::SetWalkbehindBaserine);
engine->RequestEventHook(AGSE_PREGUIDRAW);
engine->RequestEventHook(AGSE_PRESCREENDRAW);
engine->RequestEventHook(AGSE_SAVEGAME);
engine->RequestEventHook(AGSE_RESTOREGAME);
engine->RequestEventHook(AGSE_ENTERROOM);
}
AGSWaves::~AGSWaves() {
stopAllSounds();
}
void AGS_EngineShutdown() {
}
int64 AGSWaves::AGS_EngineOnEvent(int event, NumberPtr data) {
switch (event) {
case AGSE_PREGUIDRAW:
// Update();
break;
case AGSE_RESTOREGAME: {
stopAllSounds();
Serializer s(_engine, data, true);
for (int j = 0; j < 500 - 1; ++j) {
s.syncAsInt(SFX[j]._repeat);
s.syncAsInt(SFX[j]._volume);
s.syncAsInt(SFX[j]._playing);
}
break;
}
case AGSE_SAVEGAME: {
Serializer s(_engine, data, true);
for (int j = 0; j < 500 - 1; ++j) {
SFX[j]._playing = _mixer->isSoundHandleActive(SFX[j]._soundHandle);
s.syncAsInt(SFX[j]._repeat);
s.syncAsInt(SFX[j]._volume);
s.syncAsInt(SFX[j]._playing);
}
break;
}
case AGSE_PRESCREENDRAW:
// Get screen size once here.
_engine->GetScreenDimensions(&screen_width, &screen_height, &screen_color_depth);
//_engine->UnrequestEventHook(AGSE_SAVEGAME);
//_engine->UnrequestEventHook(AGSE_RESTOREGAME);
break;
case AGSE_ENTERROOM:
// The original unloads sfx that are not playing and are not on repeat
// I don't think we need to do anything here.
break;
default:
break;
}
return 0;
}
void AGSWaves::StartingValues() {
GeneralAudio.NumOfChannels = 0;
GeneralAudio.Initialized = false;
GeneralAudio.Disabled = false;
GeneralAudio.FilterFrequency = 10;
GeneralAudio.SoundValue = 0;
MFXStream.ID = 0;
MFXStream.Channel = -1;
MFXStream.Switch = false;
MFXStream.FadeTime = 0;
MFXStream.FadeRate = 0.0;
MFXStream.FadeVolume = 0.0;
MFXStream.HaltedZero = false;
MFXStream.HaltedOne = false;
int j = 0;
while (j < 2) {
globalStream[j].Filename = nullptr;
globalStream[j].repeat = 0;
globalStream[j].volume = 0;
globalStream[j].Vorbis = nullptr;
globalStream[j].fix_click = false;
j++;
}
}
} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,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

View File

@@ -0,0 +1,133 @@
/* 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/>.
*
*/
#include "common/util.h"
#include "ags/plugins/ags_waves/ags_waves.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWaves {
void AGSWaves::SaveVariable(ScriptMethodParams &params) {
PARAMS2(const char *, value, int, id);
if (GameDatavalue[id] != nullptr) {
free(GameDatavalue[id]);
}
if (value != nullptr) {
GameDatavalue[id] = scumm_strdup(value);
} else {
GameDatavalue[id] = nullptr;
}
}
void AGSWaves::ReadVariable(ScriptMethodParams &params) {
PARAMS1(int, id);
if (GameDatavalue[id] == nullptr) {
params._result = _engine->CreateScriptString("");
} else {
params._result = _engine->CreateScriptString(GameDatavalue[id]);
}
}
void AGSWaves::GameDoOnceOnly(ScriptMethodParams &params) {
// PARAMS1(const char *, value);
GetGDState(params);
if (params._result) {
// Set state to false
params.push_back(false);
SetGDState(params);
params._result = true;
} else {
params._result = false;
}
}
void AGSWaves::SetGDState(ScriptMethodParams &params) {
PARAMS2(const char *, value, bool, setValue);
int id = -1;
for (int i = 0; i <= usedTokens; i++) {
if (Token[i] != nullptr && strcmp(Token[i], value) == 0) {
id = i;
TokenUnUsed[i] = setValue;
i = usedTokens + 1;
}
}
if (id == -1) {
// It doesn't find it while trying to set its state
// create the thing with said state
id = usedTokens;
TokenUnUsed[id] = setValue;
if (Token[id] != nullptr)
free(Token[id]);
Token[id] = scumm_strdup(value);
usedTokens++;
}
}
void AGSWaves::GetGDState(ScriptMethodParams &params) {
PARAMS1(const char *, value);
int id = -1;
for (int i = 0; i <= usedTokens; i++) {
if (Token[i] != nullptr && strcmp(Token[i], value) == 0) {
id = i;
i = usedTokens + 1;
}
}
if (id == -1) {
params._result = true;
} else {
params._result = TokenUnUsed[id];
}
}
void AGSWaves::ResetAllGD(ScriptMethodParams &params) {
for (int i = 0; i <= usedTokens; i++) {
if (Token[i] != nullptr)
free(Token[i]);
Token[i] = nullptr;
TokenUnUsed[i] = true;
}
usedTokens = 0;
}
void AGSWaves::GetWalkbehindBaserine(ScriptMethodParams &params) {
PARAMS1(int, id);
params._result = Walkbehind[id];
}
void AGSWaves::SetWalkbehindBaserine(ScriptMethodParams &params) {
PARAMS2(int, id, int, base);
Walkbehind[id] = base;
}
} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,295 @@
/* 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/>.
*
*/
#include "audio/decoders/vorbis.h"
#include "common/util.h"
#include "ags/plugins/ags_waves/ags_waves.h"
#include "ags/shared/util/stdio_compat.h"
#include "ags/ags.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWaves {
//const float PI = 3.14159265f;
void AGSWaves::SFX_Play(ScriptMethodParams &params) {
PARAMS2(int, sfxNum, int, repeat);
SoundEffect &effect = SFX[sfxNum];
if (_mixer->isSoundHandleActive(effect._soundHandle)) {
if (effect._allow == 1) {
// In this case we should start the sound on a new channel, not stopping
// the one currently playing.
warning("TODO: play overlapping sound with SFX_Play");
}
return;
}
_mixer->stopHandle(effect._soundHandle);
Common::ArchiveMemberPtr member = getFile(Common::String::format("sounds/sound%d.sfx", sfxNum).c_str());
Audio::AudioStream *sound = loadOGG(member);
if (sound != nullptr) {
effect._volume = 255;
playStream(Audio::Mixer::kSFXSoundType, &effect._soundHandle, sound, repeat);
if (OGG_Filter && effect._filter && effect._volume > 1) {
warning("TODO: Mix_RegisterEffect(grabChan, LPEffect, NULL, NULL);");
}
effect._repeat = repeat;
} else {
debug(0, "AGSWaves::SFX_Play couldn't load sfx %d", sfxNum);
}
}
void AGSWaves::SFX_SetVolume(ScriptMethodParams &params) {
PARAMS2(int, sfxNum, int, volume);
SoundEffect &effect = SFX[sfxNum];
_mixer->setChannelVolume(effect._soundHandle, volume);
effect._volume = volume;
}
void AGSWaves::SFX_GetVolume(ScriptMethodParams &params) {
PARAMS1(int, sfxNum);
SoundEffect &effect = SFX[sfxNum];
params._result = _mixer->getChannelVolume(effect._soundHandle);
}
void AGSWaves::Music_Play(ScriptMethodParams &params) {
PARAMS6(int, MFX, int, repeat, int, fadeinMS, int, fadeoutMS, int, Position, bool, fixclick);
MusicPlay(MFX, repeat, fadeinMS, fadeoutMS, Position, false, fixclick);
}
void AGSWaves::Music_SetVolume(ScriptMethodParams &params) {
PARAMS1(int, volume);
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
}
void AGSWaves::Music_GetVolume(ScriptMethodParams &params) {
params._result = _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType);
}
void AGSWaves::SFX_Stop(ScriptMethodParams &params) {
PARAMS1(int, sfxNum); //, int, fademsOUT);
StopSFX(sfxNum);
}
void AGSWaves::SFX_SetPosition(ScriptMethodParams &params) {
#if 0
PARAMS4(int, sfxNum, int, xS, int, yS, int, intensity);
SoundEffect &effect = SFX[sfxNum];
if (_mixer->isSoundHandleActive(effect._soundHandle)) {
int angle = 0;
int dist = 0;
if (xS != 0 && yS != 0) {
int pid = _engine->GetPlayerCharacter();
playerCharacter = _engine->GetCharacter(pid);
int x1 = Character_GetX((intptr_t)playerCharacter);
int y1 = Character_GetY((intptr_t)playerCharacter);
int x2 = xS;
int y2 = yS;
int defx = (x1 - x2) * (x1 - x2);
int defy = (y1 - y2) * (y1 - y2);
float SquareRoot = sqrt(float(defx + defy));
dist = int(SquareRoot) - intensity;
if (dist > 255) dist = 255;
if (dist < 0) dist = 0;
float xDiff = float(x2 - x1);
float yDiff = float(y2 - y1);
float at2 = atan2(yDiff, xDiff);
float angles = (at2 * 360.0 / PI);
angle = int(angles);//%360;
}
// TODO: Change Mix_SetPosition to ScummVM equivalent
//Mix_SetPosition(id, angle, dist);
(void)angle;
(void)dist;
}
#endif
debug(0, "TODO: SFX_Setposition positional sound not yet implemented");
}
void AGSWaves::SFX_SetGlobalVolume(ScriptMethodParams &params) {
PARAMS1(int, volume);
_mixer->setVolumeForSoundType(Audio::Mixer::kPlainSoundType, volume);
}
void AGSWaves::Load_SFX(ScriptMethodParams &params) {
// PARAMS1(int, sfxNum);
// LoadSFX(sfxNum);
}
void AGSWaves::Audio_Apply_Filter(ScriptMethodParams &params) {
PARAMS1(int, Frequency);
GlitchFix();
ApplyFilter(Frequency);
}
void AGSWaves::Audio_Remove_Filter(ScriptMethodParams &params) {
}
void AGSWaves::SFX_AllowOverlap(ScriptMethodParams &params) {
PARAMS2(int, sfxNum, int, allow);
SFX[sfxNum]._allow = allow;
}
void AGSWaves::SFX_Filter(ScriptMethodParams &params) {
PARAMS2(int, sfxNum, int, enable);
// THIS ENABLES/DISABLES the SFX LOW PASS FILTER,
// I think by default all sound effects are affected by low pass, but there are some that i've manually disabled from being affected by it with this command
SFX[sfxNum]._filter = enable;
}
Audio::AudioStream *AGSWaves::loadOGG(const Common::ArchiveMemberPtr &member) {
#ifdef USE_VORBIS
if (member) {
Audio::AudioStream *stream = Audio::makeVorbisStream(member->createReadStream(), DisposeAfterUse::YES);
return stream;
}
#endif
return nullptr;
}
void AGSWaves::playStream(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, Audio::AudioStream *stream, int repeat) {
if (!handle || !stream)
return;
if (repeat != 0) {
Audio::SeekableAudioStream *sas =
dynamic_cast<Audio::SeekableAudioStream *>(stream);
assert(sas);
// -1 for infinite, >0 number of successive repeats
Audio::LoopingAudioStream *las =
new Audio::LoopingAudioStream(sas, repeat + 1);
_mixer->playStream(type, handle, las);
} else {
_mixer->playStream(type, handle, stream);
}
}
void AGSWaves::StopSFX(int sfxNum) {
SoundEffect &effect = SFX[sfxNum];
_mixer->stopHandle(effect._soundHandle);
effect._playing = 0;
effect._repeat = 0;
effect._channel = -2;
}
void AGSWaves::stopAllSounds() {
for (int i = 0; i < 500; ++i)
StopSFX(i);
_mixer->stopHandle(MFXStream._soundHandle);
}
void AGSWaves::GlitchFix() {
// TODO: Implementation
}
void AGSWaves::ApplyFilter(int setFrequency) {
// THIS TURNS ON THE LOW PASS FILTER
OGG_Filter = true;
GeneralAudio.FilterFrequency = setFrequency;
SetFilterFrequency(setFrequency);
}
void AGSWaves::SetFilterFrequency(int setFrequency) {
// TODO: Implementation
}
void AGSWaves::MusicPlay(int MusicToPlay, int repeat, int fadeinMS, int fadeoutMS, int pos, bool forceplay, bool fixclick) {
if (GeneralAudio.Disabled) {
return;
}
// Stop any previous music
_mixer->stopHandle(MFXStream._soundHandle);
// Load OGG file for music
Common::ArchiveMemberPtr member = getFile(Common::String::format("music/music%d.mfx", MusicToPlay).c_str());
Audio::AudioStream *musicStream = loadOGG(member);
if (!musicStream)
return;
bool samefile = currentMusic != MusicToPlay;
if (forceplay)
samefile = true;
if (samefile) {
currentMusicRepeat = repeat;
currentMusicFadein = fadeinMS;
currentMusic = MusicToPlay;
if (!MFXStream.Switch) {
MFXStream.Channel = 0;
playStream(Audio::Mixer::kMusicSoundType,
&MFXStream._soundHandle, musicStream, repeat);
MFXStream.ID = MusicToPlay;
MFXStream.FadeTime = (fadeinMS / 1000) * 40;
MFXStream.FadeRate = (float)_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType)
/ (float)MFXStream.FadeTime;
MFXStream.FadeVolume = 0.0;
MFXStream.HaltedZero = false;
//MusicVolCanBeAdjusted=true;
} else {
MFXStream.HaltedOne = false;
MFXStream.Channel = 1;
playStream(Audio::Mixer::kMusicSoundType,
&MFXStream._soundHandle, musicStream, repeat);
MFXStream.ID = MusicToPlay;
MFXStream.FadeTime = (fadeoutMS / 1000) * 40;
MFXStream.FadeVolume = 0.0;//float(MusicGetVolume());
MFXStream.FadeRate = (float)_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType)
/ (float)MFXStream.FadeTime;
//MusicVolCanBeAdjusted=false;
}
MFXStream.Switch = !MFXStream.Switch;
}
}
} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3

View File

@@ -0,0 +1,225 @@
/* 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_VARS_H
#define AGS_PLUGINS_AGS_WAVES_VARS_H
#include "audio/audiostream.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWaves {
#define texWidth 240
#define texHeight 240
#define screenWidth 640
#define screenHeight 360
// TODO: Dummy definitions that need to be fixed
typedef void *stb_vorbis;
typedef void *Mix_Chunk;
typedef int SDL_AudioSpec;
typedef int SDL_AudioDeviceID;
struct Particle {
int x;
int y;
int transp;
int life;
bool active;
int dx;
int dy;
int mlay;
int timlay;
int movedport;
int translay;
int translayHold;
int width;
int height;
int fx;
int fy;
bool doingcircle;
float angle;
float radius;
int doingCircleChance;
float angleLay;
int frame;
float anglespeed;
};
/*---------------------------------------------*/
typedef int (*SCAPI_CHARACTER_GETX)(AGSCharacter *ch);
typedef int (*SCAPI_CHARACTER_GETY)(AGSCharacter *ch);
typedef int (*SCAPI_CHARACTER_ID) (AGSCharacter *ch);
//WAVE SOUNDS FILES
struct SoundEffect {
Audio::SoundHandle _soundHandle;
int _repeat = 0;
int _volume = 0;
int _allow = 0;
int _channel = 0;
int _filter = 0;
int _playing = 0;
};
struct Aud {
int NumOfChannels = 0;
bool Initialized = false;
bool Disabled = false;
int FilterFrequency = 0;
int SoundValue = 0;
};
struct Mus {
int ID = 0;
int FadeTime = 0;
float FadeRate = 0;
float FadeVolume = 0;
int Channel = 0;
bool Switch = 0;
bool HaltedZero = 0;
bool HaltedOne = 0;
Audio::SoundHandle _soundHandle;
};
struct RainParticle {
int x = 0;
int y = 0;
int fx = 0;
int fy = 0;
int life = 0;
int trans = 0;
bool active = 0;
int translay = 0;
int transhold = 0;
};
struct MusicStream {
int volume = 0;
const char *Filename = nullptr;
int repeat = 0;
stb_vorbis *Vorbis = 0;
bool fix_click = false;
};
struct DustParticle {
int x = 0;
int y = 0;
int transp = 0;
int life = 0;
bool active = false;
int dx = 0;
int dy = 0;
int mlay = 0;
int timlay = 0;
int movedport = 0;
int translay = 0;
int translayHold = 0;
};
struct Vars {
int32 screen_width = 640;
int32 screen_height = 360;
int32 screen_color_depth = 32;
AGSCharacter *playerCharacter = nullptr;
PluginMethod Character_GetX;
PluginMethod Character_GetY;
PluginMethod Character_ID;
SoundEffect SFX[500];
RainParticle RainParticles[400];
RainParticle RainParticlesFore[400];
RainParticle RainParticlesBack[800];
Aud GeneralAudio;
Mus MFXStream;
int currentMusic = -1;
int currentMusicRepeat = -1;
int currentMusicFadein = 0;
double xv[3];
double yv[3];
double xvOGG[3];
double yvOGG[3];
Particle particles[110];
Particle particlesF[10];
Particle particles2[12];
int WForceX[400];
int WForceY[400];
int raysizeF = 4;
int dsizeF = 0;
int raysize = 100;
int dsize = 0;
int raysize2 = 12;
int dsize2 = 0;
int creationdelayf = 0;
int ww;
int hh;
int proom;
int prevroom;
bool OGG_Filter = false;
SDL_AudioSpec spec[2];
MusicStream globalStream[2];
SDL_AudioDeviceID getDevice[2];
bool AudioEnabled = false;
float ix = 0, iy = 0, ua = 0;
float b_time[5];
float d_time = 0;
// Y-coordinate first because we use horizontal scanlines
uint32 texture[texHeight][texWidth];
int distanceTable[screenHeight][screenWidth];
int angleTable[screenHeight][screenWidth];
bool generateonce = false;
DustParticle dusts[200];
int waitBy = 6;
int raysizeDust = 200;
int dsizeDust = 0;
int creationdelay = 0;
int Walkbehind[20];
char *GameDatavalue[40000];
char *Token[10000];
int TokenUnUsed[10000];
int usedTokens = 0;
int dY[30];
int tDy[30];
int direction[30];
// Warper fields
int _newWidth = 0, _newHeight = 0;
int _y2 = 0;
int _x3 = 0, _y3 = 0;
int _x4 = 0, _y4 = 0;
};
} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3
#endif

View File

@@ -0,0 +1,185 @@
/* 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/>.
*
*/
#include "common/util.h"
#include "ags/plugins/ags_waves/ags_waves.h"
namespace AGS3 {
namespace Plugins {
namespace AGSWaves {
void AGSWaves::ReturnNewHeight(ScriptMethodParams &params) {
params._result = _newHeight;
}
void AGSWaves::ReturnNewWidth(ScriptMethodParams &params) {
params._result = _newWidth;
}
void AGSWaves::Warper(ScriptMethodParams &params) {
PARAMS5(int, swarp, int, sadjust, int, x1, int, y1, int, x2);
ix = 0.0;
iy = 0.0;
ua = 0.0;
// some precautions against non-positive values for width and height
float ax = float(x1), ay = float(y1);
float bx = float(x2), by = float(_y2);
float cx = float(_x3), cy = float(_y3);
float dx = float(_x4), dy = float(_y4);
int w = int(max4(ax, bx, cx, dx)) + 1;
int h = int(max4(ay, by, cy, dy)) + 1;
BITMAP *refsrc = _engine->GetSpriteGraphic(swarp);
int32 refsrc_width = 640;
int32 refsrc_height = 360;
int32 refsrc_depth = 32;
_engine->GetBitmapDimensions(refsrc, &refsrc_width, &refsrc_height, &refsrc_depth);
unsigned int **refsprite_pixels = (unsigned int **)_engine->GetRawBitmapSurface(refsrc);
_engine->ReleaseBitmapSurface(refsrc);
// create temporary sprite holding the warped version
BITMAP *resizeb = _engine->GetSpriteGraphic(sadjust);
int32 src_width = 640;
int32 src_height = 360;
int32 src_depth = 32;
_engine->GetBitmapDimensions(resizeb, &src_width, &src_height, &src_depth);
unsigned int **sprite_pixels = (unsigned int **)_engine->GetRawBitmapSurface(resizeb);
int ow = refsrc_width, oh = refsrc_height;
int x, y; // pixel coords
float fx, fy; // original sprite's in between pixel coords
int il;
// calculate intersections of opposing sides
float orx_x, orx_y, ory_x, ory_y;
bool xp = false, yp = false; // parallel sides?
// AC and BD to get intersection of all "vertical lines"
il = IntersectLines(ax, ay, cx, cy, bx, by, dx, dy);
if (il == 0) {
// parallel sides, store directional vector
orx_x = cx - ax;
orx_y = cy - ay;
xp = true;
} else {
// store intersection of sides
orx_x = ix;
orx_y = iy;
}
// AB and CD to get intersection of all "horizontal lines"
il = IntersectLines(ax, ay, bx, by, cx, cy, dx, dy);
if (il == 0) {
// parallel sides, store directional vector
ory_x = bx - ax;
ory_y = by - ay;
yp = true;
} else {
// store intersection of sides
ory_x = ix;
ory_y = iy;
}
int xm = int(min4(ax, bx, cx, dx)); // x loop starts here
y = int(min4(ay, by, cy, dy));
while (y < h) {
x = xm;
while (x < w) {
// calculate original pixel
// x:
if (xp) il = IntersectLines(ax, ay, bx, by, float(x), float(y), float(x) + orx_x, float(y) + orx_y);
else il = IntersectLines(ax, ay, bx, by, float(x), float(y), orx_x, orx_y);
fx = float(ow - 1) * ua;
float ux = ua;
// y:
if (yp) il = IntersectLines(ax, ay, cx, cy, float(x), float(y), float(x) + ory_x, float(y) + ory_y);
else il = IntersectLines(ax, ay, cx, cy, float(x), float(y), ory_x, ory_y);
fy = float(oh - 1) * ua;
// only draw if within original sprite
if (ux >= 0.0 && ux <= 1.0 && ua >= 0.0 && ua <= 1.0) {
int refY = (int)CLIP(fy, (float)0.0, float(refsrc_height - 1));
int refX = (int)CLIP(fx, (float)0.0, float(refsrc_width - 1));
int setcolor = refsprite_pixels[refY][refX];
int setY = (int)CLIP((float)y, (float)0.0, (float)(src_height - 1));
int setX = (int)CLIP((float)x, (float)0.0, (float)(src_width - 1));
sprite_pixels[setY][setX] = setcolor;
}
x++;
}
y++;
}
_newWidth = w;
_newHeight = h;
_engine->ReleaseBitmapSurface(resizeb);
}
void AGSWaves::SetWarper(ScriptMethodParams &params) {
//PARAMS5(int, y2x, int, x3x, int, y3x, int, x4x, int, y4x);
}
int AGSWaves::IntersectLines(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) {
// check a
if (x1 == x2 && y1 == y2)
return -1;
// check b
if (x3 == x4 && y3 == y4)
return -1;
float den = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
float num12 = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3);
float num34 = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
if (den == 0.0) { // no intersection
if (num12 == 0.0 && num34 == 0.0)
return 2;
return 0;
}
ua = num12 / den;
ix = x1 + ua * (x2 - x1);
iy = y1 + ua * (y2 - y1);
return 1;
}
} // namespace AGSWaves
} // namespace Plugins
} // namespace AGS3

Some files were not shown because too many files have changed in this diff Show More