mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
use the new API dll
This commit is contained in:
parent
aacbdb359a
commit
11f3c25ede
4 changed files with 253 additions and 34 deletions
|
|
@ -2,11 +2,21 @@
|
|||
#include "binding-types.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include "chromasdk/ChromaSDKImpl.h"
|
||||
#include "chromasdk/ChromaApi.h"
|
||||
|
||||
bool INIT_SUCCESS = false;
|
||||
|
||||
CChromaSDKImpl* chromaImpl = NULL;
|
||||
HINSTANCE hLib = NULL;
|
||||
|
||||
//dynamic-loaded proc pointers
|
||||
PluginPlayAnimation _playAnimation = NULL;
|
||||
PluginOpenAnimation _openAnimation = NULL;
|
||||
PluginIsInitialized _pluginIsInitialized = NULL;
|
||||
PluginInit _pluginInit = NULL;
|
||||
PluginUninit _pluginUninit = NULL;
|
||||
|
||||
int lastAnimId = -1;
|
||||
|
||||
|
||||
void _attemptLinkSdk() {
|
||||
Debug() << "Attempting to bind Chroma SDK";
|
||||
|
|
@ -18,43 +28,65 @@ void _attemptLinkSdk() {
|
|||
return;
|
||||
#endif
|
||||
|
||||
chromaImpl = new CChromaSDKImpl();
|
||||
Debug() << "Chroma Impl @" << chromaImpl;
|
||||
chromaImpl->Initialize();
|
||||
INIT_SUCCESS = true;
|
||||
hLib = LoadLibrary(L"ChromaApi.dll");
|
||||
if (hLib != NULL) {
|
||||
Debug() << "Chroma Impl @" << hLib;
|
||||
INIT_SUCCESS = true;
|
||||
|
||||
_playAnimation = (PluginPlayAnimation) GetProcAddress(hLib, "PluginPlayAnimation");
|
||||
INIT_SUCCESS &= _playAnimation != NULL;
|
||||
Debug() << "Plugin method @" << (long)_playAnimation;
|
||||
|
||||
_openAnimation = (PluginOpenAnimation) GetProcAddress(hLib, "PluginOpenAnimation");
|
||||
INIT_SUCCESS &= _openAnimation != NULL;
|
||||
|
||||
_pluginInit = (PluginInit) GetProcAddress(hLib, "PluginInit");
|
||||
INIT_SUCCESS &= _pluginInit != NULL;
|
||||
|
||||
_pluginIsInitialized = (PluginIsInitialized) GetProcAddress(hLib, "PluginIsInitialized");
|
||||
INIT_SUCCESS &= _pluginInit != NULL;
|
||||
if (INIT_SUCCESS && !_pluginIsInitialized()) {
|
||||
Debug() << "Initializing chroma plugin";
|
||||
_pluginInit();
|
||||
}
|
||||
_pluginUninit = (PluginUninit) GetProcAddress(hLib, "PluginUninit");
|
||||
INIT_SUCCESS &= _pluginUninit != NULL;
|
||||
Debug() << "Plugin init success:" << INIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
RB_METHOD(chromaSetBase) {
|
||||
Debug() << "Chroma: Attempting to set base colour";
|
||||
RB_UNUSED_PARAM;
|
||||
if (INIT_SUCCESS) {
|
||||
ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE effect = {};
|
||||
for (unsigned int y = 0; y < ChromaSDK::Keyboard::MAX_ROW; y++) {
|
||||
for (unsigned int x = 0; x < ChromaSDK::Keyboard::MAX_COLUMN; x++) {
|
||||
effect.Color[y][x] = RGB(0xFF, 0, 0xFF);
|
||||
}
|
||||
}
|
||||
chromaImpl->CreateKeyboardEffectImpl(
|
||||
ChromaSDK::Keyboard::CHROMA_CUSTOM,
|
||||
&effect,
|
||||
NULL);
|
||||
Debug() << "Chroma: Set base colour effect";
|
||||
}
|
||||
return Qnil;
|
||||
|
||||
RB_METHOD(chromaPlayAnimation) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
Debug() << "Chroma: Attempting to play animation.";
|
||||
const char* animfile;
|
||||
bool loop;
|
||||
|
||||
rb_get_args(argc, argv, "zb", &animfile, &loop RB_ARG_END);
|
||||
|
||||
if (INIT_SUCCESS) {
|
||||
Debug() << "Opening animation:" << animfile;
|
||||
lastAnimId = _openAnimation(animfile);
|
||||
Debug() << "ID:" << lastAnimId;
|
||||
_playAnimation(lastAnimId);
|
||||
}
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void chromaBindingInit() {
|
||||
_attemptLinkSdk();
|
||||
|
||||
VALUE module = rb_define_module("Chroma");
|
||||
_rb_define_module_function(module, "setBase", chromaSetBase);
|
||||
_rb_define_module_function(module, "playAnim", chromaPlayAnimation);
|
||||
}
|
||||
|
||||
void chromaBindingRelease() {
|
||||
if (chromaImpl) {
|
||||
chromaImpl->UnInitialize();
|
||||
delete chromaImpl;
|
||||
chromaImpl = NULL;
|
||||
if (hLib != NULL) {
|
||||
_pluginUninit();
|
||||
FreeLibrary(hLib);
|
||||
hLib = NULL;
|
||||
INIT_SUCCESS = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
175
chromasdk/ChromaApi.h
Normal file
175
chromasdk/ChromaApi.h
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
|
||||
typedef int (*PluginInit)();
|
||||
typedef double (*PluginInitD)();
|
||||
|
||||
typedef bool (*PluginIsPlatformSupported)();
|
||||
typedef double (*PluginIsPlatformSupportedD)();
|
||||
|
||||
typedef bool (*PluginIsInitialized)();
|
||||
typedef double (*PluginIsInitializedD)();
|
||||
|
||||
typedef bool (*PluginIsDialogOpen)();
|
||||
typedef double (*PluginIsDialogOpenD)();
|
||||
|
||||
typedef int (*PluginOpenEditorDialog)(const char* path);
|
||||
typedef double (*PluginOpenEditorDialogD)(const char* path);
|
||||
|
||||
typedef int (*PluginOpenEditorDialogAndPlay)(const char* path);
|
||||
typedef double (*PluginOpenEditorDialogAndPlayD)(const char* path);
|
||||
|
||||
typedef int (*PluginOpenAnimation)(const char* path);
|
||||
typedef double (*PluginOpenAnimationD)(const char* path);
|
||||
|
||||
typedef int (*PluginLoadAnimation)(int animationId);
|
||||
typedef double (*PluginLoadAnimationD)(double animationId);
|
||||
|
||||
typedef int (*PluginUnloadAnimation)(int animationId);
|
||||
typedef double (*PluginUnloadAnimationD)(double animationId);
|
||||
|
||||
typedef int (*PluginPlayAnimation)(int animationId);
|
||||
typedef double (*PluginPlayAnimationD)(double animationId);
|
||||
|
||||
typedef bool (*PluginIsPlaying)(int animationId);
|
||||
typedef double (*PluginIsPlayingD)(double animationId);
|
||||
|
||||
typedef int (*PluginStopAnimation)(int animationId);
|
||||
typedef double (*PluginStopAnimationD)(double animationId);
|
||||
|
||||
typedef int (*PluginCloseAnimation)(int animationId);
|
||||
typedef double (*PluginCloseAnimationD)(double animationId);
|
||||
|
||||
typedef int (*PluginUninit)();
|
||||
typedef double (*PluginUninitD)();
|
||||
|
||||
typedef int (*PluginCreateAnimationInMemory)(int deviceType, int device);
|
||||
typedef int (*PluginCreateAnimation)(const char* path, int deviceType, int device);
|
||||
typedef int (*PluginSaveAnimation)(int animationId, const char* path);
|
||||
typedef int (*PluginResetAnimation)(int animationId);
|
||||
|
||||
typedef int (*PluginGetDeviceType)(int animationId);
|
||||
typedef int (*PluginGetDeviceTypeName)(const char* path);
|
||||
typedef double (*PluginGetDeviceTypeNameD)(const char* path);
|
||||
|
||||
typedef int (*PluginGetDevice)(int animationId);
|
||||
typedef int (*PluginGetDeviceName)(const char* path);
|
||||
typedef double (*PluginGetDeviceNameD)(const char* path);
|
||||
|
||||
typedef int (*PluginSetDevice)(int animationId, int deviceType, int device);
|
||||
|
||||
typedef int (*PluginGetMaxLeds)(int device);
|
||||
typedef double (*PluginGetMaxLedsD)(double device);
|
||||
|
||||
typedef int (*PluginGetMaxRow)(int device);
|
||||
typedef double (*PluginGetMaxRowD)(double device);
|
||||
|
||||
typedef int (*PluginGetMaxColumn)(int device);
|
||||
typedef double (*PluginGetMaxColumnD)(double device);
|
||||
|
||||
typedef int (*PluginAddFrame)(int animationId, float duration, int* colors, int length);
|
||||
typedef int (*PluginUpdateFrame)(int animationId, int frameIndex, float duration, int* colors, int length);
|
||||
typedef int (*PluginGetFrame)(int animationId, int frameIndex, float* duration, int* colors, int length);
|
||||
|
||||
typedef int (*PluginPreviewFrame)(int animationId, int frameIndex);
|
||||
typedef double (*PluginPreviewFrameD)(double animationId, double frameIndex);
|
||||
|
||||
typedef int (*PluginOverrideFrameDuration)(int animationId, float duration);
|
||||
typedef double (*PluginOverrideFrameDurationD)(double animationId, double duration);
|
||||
|
||||
typedef int (*PluginReverse)(int animationId);
|
||||
typedef int (*PluginMirrorHorizontally)(int animationId);
|
||||
typedef int (*PluginMirrorVertically)(int animationId);
|
||||
|
||||
typedef int (*PluginGetAnimation)(const char* name);
|
||||
typedef double (*PluginGetAnimationD)(const char* name);
|
||||
|
||||
typedef void (*PluginCloseAnimationName)(const char* path);
|
||||
typedef double (*PluginCloseAnimationNameD)(const char* path);
|
||||
|
||||
typedef void (*PluginPlayAnimationLoop)(int animationId, bool loop);
|
||||
typedef void (*PluginPlayAnimationName)(const char* path, bool loop);
|
||||
typedef double (*PluginPlayAnimationNameD)(const char* path, double loop);
|
||||
|
||||
typedef void (*PluginPlayAnimationFrame)(int animationId, int frameId, bool loop);
|
||||
typedef void (*PluginPlayAnimationFrameName)(const char* path, int frameId, bool loop);
|
||||
typedef double (*PluginPlayAnimationFrameNameD)(const char* path, double frameId, double loop);
|
||||
|
||||
typedef void (*PluginStopAnimationName)(const char* path);
|
||||
typedef double (*PluginStopAnimationNameD)(const char* path);
|
||||
|
||||
typedef void (*PluginStopAnimationType)(int deviceType, int device);
|
||||
typedef double (*PluginStopAnimationTypeD)(double deviceType, double device);
|
||||
|
||||
typedef bool (*PluginIsPlayingName)(const char* path);
|
||||
typedef double (*PluginIsPlayingNameD)(const char* path);
|
||||
|
||||
typedef bool (*PluginIsPlayingType)(int deviceType, int device);
|
||||
typedef double (*PluginIsPlayingTypeD)(double deviceType, double device);
|
||||
|
||||
typedef void (*PluginPlayComposite)(const char* name, bool loop);
|
||||
typedef double (*PluginPlayCompositeD)(const char* name, double loop);
|
||||
|
||||
typedef void (*PluginStopComposite)(const char* name);
|
||||
typedef double (*PluginStopCompositeD)(const char* name);
|
||||
|
||||
typedef void (*PluginCloseComposite)(const char* name);
|
||||
typedef double (*PluginCloseCompositeD)(const char* name);
|
||||
|
||||
typedef int (*PluginGetKeyColor)(int animationId, int frameId, int rzkey);
|
||||
typedef int (*PluginGetKeyColorName)(const char* path, int frameId, int rzkey);
|
||||
typedef double (*PluginGetKeyColorD)(const char* path, double frameId, double rzkey);
|
||||
|
||||
typedef int (*PluginGet1DColor)(int animationId, int frameId, int led);
|
||||
typedef int (*PluginGet1DColorName)(const char* path, int frameId, int led);
|
||||
typedef double (*PluginGet1DColorNameD)(const char* path, double frameId, double led);
|
||||
|
||||
typedef int (*PluginGet2DColor)(int animationId, int frameId, int row, int column);
|
||||
typedef int (*PluginGet2DColorName)(const char* path, int frameId, int row, int column);
|
||||
typedef double (*PluginGet2DColorNameD)(const char* path, double frameId, double row, double column);
|
||||
|
||||
typedef void (*PluginSetKeyColor)(int animationId, int frameId, int rzkey, int color);
|
||||
typedef void (*PluginSetKeyColorName)(const char* path, int frameId, int rzkey, int color);
|
||||
typedef double (*PluginSetKeyColorNameD)(const char* path, double frameId, double rzkey, double color);
|
||||
|
||||
typedef void (*PluginSet1DColor)(int animationId, int frameId, int led, int color);
|
||||
typedef void (*PluginSet1DColorName)(const char* path, int frameId, int led, int color);
|
||||
typedef double (*PluginSet1DColorNameD)(const char* path, double frameId, double led, double color);
|
||||
|
||||
typedef void (*PluginSet2DColor)(int animationId, int frameId, int row, int column, int color);
|
||||
typedef void (*PluginSet2DColorName)(const char* path, int frameId, int row, int column, int color);
|
||||
typedef double (*PluginSet2DColorNameD)(const char* path, double frameId, double rowColumnIndex, double color);
|
||||
|
||||
typedef void (*PluginCopyKeyColor)(int sourceAnimationId, int targetAnimationId, int frameId, int rzkey);
|
||||
typedef void (*PluginCopyKeyColorName)(const char* sourceAnimation, const char* targetAnimation, int frameId, int rzkey);
|
||||
typedef double (*PluginCopyKeyColorNameD)(const char* sourceAnimation, const char* targetAnimation, double frameId, double rzkey);
|
||||
|
||||
typedef void (*PluginCopyNonZeroKeyColor)(int sourceAnimationId, int targetAnimationId, int frameId, int rzkey);
|
||||
typedef void (*PluginCopyNonZeroKeyColorName)(const char* sourceAnimation, const char* targetAnimation, int frameId, int rzkey);
|
||||
typedef double (*PluginCopyNonZeroKeyColorNameD)(const char* sourceAnimation, const char* targetAnimation, double frameId, double rzkey);
|
||||
|
||||
typedef int (*PluginGetFrameCount)(int animationId);
|
||||
typedef int (*PluginGetFrameCountName)(const char* path);
|
||||
typedef double (*PluginGetFrameCountNameD)(const char* path);
|
||||
|
||||
typedef int (*PluginGetCurrentFrame)(int animationId);
|
||||
typedef int (*PluginGetCurrentFrameName)(const char* path);
|
||||
typedef double (*PluginGetCurrentFrameNameD)(const char* path);
|
||||
|
||||
typedef void (*PluginSetCurrentFrame)(int animationId, int frameId);
|
||||
typedef void (*PluginSetCurrentFrameName)(const char* path, int frameId);
|
||||
typedef double (*PluginSetCurrentFrameNameD)(const char* path, double frameId);
|
||||
|
||||
typedef void (*PluginPauseAnimation)(int animationId);
|
||||
typedef void (*PluginPauseAnimationName)(const char* path);
|
||||
typedef double (*PluginPauseAnimationNameD)(const char* path);
|
||||
|
||||
typedef bool (*PluginIsAnimationPaused)(int animationId);
|
||||
typedef bool (*PluginIsAnimationPausedName)(const char* path);
|
||||
typedef double (*PluginIsAnimationPausedNameD)(const char* path);
|
||||
|
||||
typedef bool (*PluginHasAnimationLoop)(int animationId);
|
||||
typedef bool (*PluginHasAnimationLoopName)(const char* path);
|
||||
typedef double (*PluginHasAnimationLoopNameD)(const char* path);
|
||||
|
||||
typedef void (*PluginResumeAnimation)(int animationId, bool loop);
|
||||
typedef void (*PluginResumeAnimationName)(const char* path, bool loop);
|
||||
typedef double (*PluginResumeAnimationNameD)(const char* path, double loop);
|
||||
|
|
@ -16,7 +16,6 @@ begin
|
|||
|
||||
# Load persistent data
|
||||
Persistent.load
|
||||
Chroma.setBase
|
||||
|
||||
# Prepare for transition
|
||||
Graphics.freeze
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ class Scene_Map
|
|||
# Update fast travel
|
||||
@fast_travel.update
|
||||
@window_settings.update
|
||||
|
||||
|
||||
if Input.trigger?(Input::F8) && !$game_switches[123]
|
||||
if Graphics.fullscreen == true
|
||||
Graphics.fullscreen = false
|
||||
|
|
@ -276,11 +276,24 @@ class Scene_Map
|
|||
$game_temp.player_new_x = $data_system.start_x
|
||||
$game_temp.player_new_y = $data_system.start_y
|
||||
end
|
||||
# If debug mode is ON and F9 key was pressed
|
||||
if $debug and Input.press?(Input::F9)
|
||||
# Set debug calling flag
|
||||
$game_temp.debug_calling = true
|
||||
# debug && F6
|
||||
if $debug and Input.press?(Input::F6) and $lastpress != 6
|
||||
$lastpress = 6
|
||||
Chroma.playAnim("chroma/blank_keyboard.chroma", false);
|
||||
end
|
||||
if $debug and Input.press?(Input::F7) and $lastpress != 7
|
||||
$lastpress = 7
|
||||
Chroma.playAnim("chroma/Fire_Keyboard.chroma", true);
|
||||
end
|
||||
if $debug and Input.press?(Input::F9) and $lastpress != 9
|
||||
$lastpress = 9
|
||||
Chroma.playAnim("chroma/Random_Keyboard.chroma", false);
|
||||
end
|
||||
# If debug mode is ON and F9 key was pressed
|
||||
# if $debug and Input.press?(Input::F9)
|
||||
# # Set debug calling flag
|
||||
# $game_temp.debug_calling = true
|
||||
# end
|
||||
# If player is not moving
|
||||
unless $game_player.moving?
|
||||
# Run calling of each screen
|
||||
|
|
|
|||
Loading…
Reference in a new issue