2022-09-23 04:44:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-03 19:49:28 +00:00
|
|
|
#include <map>
|
2022-12-28 23:01:50 +00:00
|
|
|
#include <string>
|
2022-09-23 04:44:54 +00:00
|
|
|
#include <unordered_map>
|
2022-12-28 23:01:50 +00:00
|
|
|
#include <variant>
|
2022-09-23 04:44:54 +00:00
|
|
|
|
2022-12-28 23:01:50 +00:00
|
|
|
using std::map;
|
2022-12-03 19:49:28 +00:00
|
|
|
using std::string;
|
|
|
|
using std::variant;
|
|
|
|
|
|
|
|
typedef variant<string, float, bool, int> ArgumentVariant;
|
|
|
|
typedef map<string, ArgumentVariant> ArgumentMap;
|
|
|
|
|
2023-03-08 20:41:13 +00:00
|
|
|
#include "blur.h"
|
|
|
|
#include "bounce.h"
|
|
|
|
#include "caption.h"
|
|
|
|
#include "caption2.h"
|
|
|
|
#include "circle.h"
|
|
|
|
#include "colors.h"
|
|
|
|
#include "crop.h"
|
|
|
|
#include "deepfry.h"
|
|
|
|
#include "explode.h"
|
|
|
|
#include "flag.h"
|
|
|
|
#include "flip.h"
|
|
|
|
#include "freeze.h"
|
|
|
|
#include "gamexplain.h"
|
|
|
|
#include "globe.h"
|
|
|
|
#include "homebrew.h"
|
|
|
|
#include "invert.h"
|
|
|
|
#include "jpeg.h"
|
|
|
|
#include "magik.h"
|
|
|
|
#include "meme.h"
|
|
|
|
#include "mirror.h"
|
|
|
|
#include "motivate.h"
|
|
|
|
#include "reddit.h"
|
|
|
|
#include "resize.h"
|
|
|
|
#include "reverse.h"
|
|
|
|
#include "scott.h"
|
|
|
|
#include "snapchat.h"
|
|
|
|
#include "sonic.h"
|
|
|
|
#include "speed.h"
|
|
|
|
#include "spin.h"
|
|
|
|
#include "squish.h"
|
|
|
|
#include "swirl.h"
|
|
|
|
#include "tile.h"
|
|
|
|
#include "togif.h"
|
|
|
|
#include "uncanny.h"
|
|
|
|
#include "uncaption.h"
|
|
|
|
#include "wall.h"
|
|
|
|
#include "watermark.h"
|
|
|
|
#include "whisper.h"
|
|
|
|
#include "zamn.h"
|
|
|
|
|
2022-12-03 19:49:28 +00:00
|
|
|
template <typename T>
|
|
|
|
T GetArgument(ArgumentMap map, string key) {
|
|
|
|
try {
|
|
|
|
return std::get<T>(map.at(key));
|
|
|
|
} catch (std::bad_variant_access&) {
|
|
|
|
throw "Invalid requested type from variant.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T GetArgumentWithFallback(ArgumentMap map, string key, T fallback) {
|
|
|
|
try {
|
|
|
|
return std::get<T>(map.at(key));
|
2022-12-28 23:01:50 +00:00
|
|
|
} catch (...) { // this is, not great...
|
2022-12-03 19:49:28 +00:00
|
|
|
return fallback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-27 19:03:07 +00:00
|
|
|
#define MAP_HAS(ARRAY, KEY) (ARRAY.count(KEY) > 0)
|
2022-12-28 23:01:50 +00:00
|
|
|
#define MAP_GET(ARRAY, KEY, TYPE) \
|
|
|
|
(MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) \
|
|
|
|
: NULL) // C++ has forced my hand
|
|
|
|
#define MAP_GET_FALLBACK(ARRAY, KEY, TYPE, FALLBACK) \
|
|
|
|
(MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) : FALLBACK)
|
2022-11-27 23:23:57 +00:00
|
|
|
|
|
|
|
#define ARG_TYPES std::variant<string, bool, int, float>
|
2022-11-27 19:03:07 +00:00
|
|
|
|
2022-12-28 23:01:50 +00:00
|
|
|
const std::unordered_map<std::string, std::string> fontPaths{
|
|
|
|
{"futura", "assets/fonts/caption.otf"},
|
|
|
|
{"helvetica", "assets/fonts/caption2.ttf"},
|
2023-03-08 20:41:13 +00:00
|
|
|
{"roboto", "assets/fonts/reddit.ttf"}};
|
|
|
|
|
|
|
|
const std::map<std::string,
|
2023-03-09 01:36:39 +00:00
|
|
|
char* (*)(string type, string* outType, char* BufferData, size_t BufferLength,
|
2023-03-08 20:41:13 +00:00
|
|
|
ArgumentMap Arguments, size_t* DataSize)>
|
|
|
|
FunctionMap = {{"blur", &Blur},
|
|
|
|
{"bounce", &Bounce},
|
|
|
|
{"caption", &Caption},
|
|
|
|
{"captionTwo", &CaptionTwo},
|
|
|
|
{"circle", &Circle},
|
|
|
|
{"colors", &Colors},
|
|
|
|
{"crop", &Crop},
|
|
|
|
{"deepfry", &Deepfry},
|
|
|
|
{"explode", &Explode},
|
|
|
|
{"flag", &Flag},
|
|
|
|
{"flip", &Flip},
|
|
|
|
{"freeze", &Freeze},
|
|
|
|
{"gamexplain", Gamexplain},
|
|
|
|
{"globe", Globe},
|
|
|
|
{"invert", Invert},
|
|
|
|
{"jpeg", Jpeg},
|
|
|
|
{"magik", Magik},
|
|
|
|
{"meme", Meme},
|
|
|
|
{"mirror", Mirror},
|
|
|
|
{"motivate", Motivate},
|
|
|
|
{"reddit", Reddit},
|
|
|
|
{"resize", Resize},
|
|
|
|
{"reverse", Reverse},
|
|
|
|
{"scott", Scott},
|
|
|
|
{"snapchat", Snapchat},
|
|
|
|
{"speed", &Speed},
|
|
|
|
{"spin", Spin},
|
|
|
|
{"squish", Squish},
|
|
|
|
{"swirl", Swirl},
|
|
|
|
{"tile", Tile},
|
|
|
|
{"togif", ToGif},
|
|
|
|
{"uncanny", Uncanny},
|
|
|
|
{"uncaption", &Uncaption},
|
|
|
|
{"wall", Wall},
|
|
|
|
{"watermark", &Watermark},
|
|
|
|
{"whisper", Whisper},
|
|
|
|
{"zamn", Zamn}};
|
|
|
|
|
|
|
|
const std::map<std::string,
|
2023-03-09 01:36:39 +00:00
|
|
|
char* (*)(string type, string* outType, ArgumentMap Arguments, size_t* DataSize)>
|
2023-03-08 20:41:13 +00:00
|
|
|
NoInputFunctionMap = {{"homebrew", Homebrew}, {"sonic", Sonic}};
|