mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
Multiple "scenes" for screen resize (#270)
## Link to GitHub Issue, if one exists Fixes #263 ## Description of change Add "scenes" to screen resize. * UI changes - F11 menu now has a "scene switcher" for `Scene 1/2/3/4`. Clean up other UI bits. * Add hotkeys for `Screen Resize Scene 1`, `Screen Resize 2`, and so on. * Detect hot key and trigger resizes. * Add additional objects to screen_resize.json for saving and loading the new scene settings. * Existing screen resize data is backwards compatible (can be loaded/saved to JSON), and is treated as `Scene 1`. * Add API endpoint for `Resize`, allow toggling resize on/off, switching active scene * Add Python wrapper. Did not bother with the other wrappers (Dart, C++, etc)... ## Compiling 🥇 ## Testing Still testing, but seems to work fine for TDJ.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include "resize.h"
|
||||
#include "external/rapidjson/document.h"
|
||||
#include "cfg/screen_resize.h"
|
||||
|
||||
using namespace std::placeholders;
|
||||
using namespace rapidjson;
|
||||
|
||||
namespace api::modules {
|
||||
|
||||
static thread_local std::vector<uint8_t> CAPTURE_BUFFER;
|
||||
|
||||
Resize::Resize() : Module("resize") {
|
||||
functions["image_resize_enable"] = std::bind(&Resize::image_resize_enable, this, _1, _2);
|
||||
functions["image_resize_set_scene"] = std::bind(&Resize::image_resize_set_scene, this, _1, _2);
|
||||
}
|
||||
|
||||
/**
|
||||
* image_resize_enable(enable: bool)
|
||||
*/
|
||||
void Resize::image_resize_enable(Request &req, Response &res) {
|
||||
if (req.params.Size() < 1) {
|
||||
return error_params_insufficient(res);
|
||||
}
|
||||
if (!req.params[0].IsBool()) {
|
||||
return error_type(res, "enable", "bool");
|
||||
}
|
||||
|
||||
cfg::SCREENRESIZE->enable_screen_resize = req.params[0].GetBool();
|
||||
}
|
||||
|
||||
/**
|
||||
* image_resize_set_scene(scene: int)
|
||||
*/
|
||||
void Resize::image_resize_set_scene(Request &req, Response &res) {
|
||||
if (req.params.Size() < 1) {
|
||||
return error_params_insufficient(res);
|
||||
}
|
||||
if (!req.params[0].IsInt()) {
|
||||
return error_type(res, "scene", "int");
|
||||
}
|
||||
|
||||
const auto scene = req.params[0].GetInt();
|
||||
if (scene < 0 || (int)std::size(cfg::SCREENRESIZE->scene_settings) < scene) {
|
||||
return error(res, "invalid scene number");
|
||||
}
|
||||
if (scene == 0) {
|
||||
cfg::SCREENRESIZE->enable_screen_resize = false;
|
||||
} else {
|
||||
cfg::SCREENRESIZE->enable_screen_resize = true;
|
||||
cfg::SCREENRESIZE->screen_resize_current_scene = scene - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "api/module.h"
|
||||
#include "api/request.h"
|
||||
|
||||
namespace api::modules {
|
||||
|
||||
class Resize : public Module {
|
||||
public:
|
||||
Resize();
|
||||
|
||||
private:
|
||||
|
||||
// function definitions
|
||||
void image_resize_enable(Request &req, Response &res);
|
||||
void image_resize_set_scene(Request &req, Response &res);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user