Allow for changing control overlay image

This commit is contained in:
Varun Patil 2019-05-29 23:30:52 +05:30
parent 558a6511bc
commit ee3c189d6b
4 changed files with 17 additions and 4 deletions

View File

@ -480,7 +480,9 @@ parseOverlayButtonDesc(const ptree &pt, TouchOverlay::Button &out)
static void
parseOverlayDesc(const ptree &pt, TouchOverlay &out)
{
out.image = pt.get<std::string>("image");
for (auto &img : pt.get_child("images")) {
out.images[img.second.get<int>("id")] = img.second.get<std::string>("file");
}
const ptree &buttons = pt.get_child("buttons");
for (ptree::const_iterator ci = buttons.begin(); ci != buttons.end(); ++ci)

View File

@ -24,11 +24,12 @@
#include <string>
#include <vector>
#include <map>
#include <set>
struct TouchOverlay
{
std::string image;
std::map<int, std::string> images;
struct Button
{

View File

@ -503,12 +503,16 @@ struct GraphicsPrivate
TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
TEXFBO::linkFBO(frozenScene);
setOverlay(0);
FloatRect screenRect(0, 0, scRes.x, scRes.y);
screenQuad.setTexPosRect(screenRect, screenRect);
fpsLimiter.resetFrameAdjust();
const std::string &olImage = rtData->config.touchOverlay.image;
}
void setOverlay(int id) {
const std::string &olImage = threadData->config.touchOverlay.images[id];
if (!olImage.empty())
{
SDL_RWops *ops = SDL_RWFromFile(olImage.c_str(), "rb");
@ -862,6 +866,11 @@ void Graphics::frameReset()
p->fpsLimiter.resetFrameAdjust();
}
void Graphics::setOverlay(int id)
{
p->setOverlay(id);
}
static void guardDisposed() {}
DEF_ATTR_RD_SIMPLE(Graphics, FrameRate, int, p->frameRate)

View File

@ -40,6 +40,7 @@ public:
const char *filename = "",
int vague = 40);
void frameReset();
void setOverlay(int);
DECL_ATTR( FrameRate, int )
DECL_ATTR( FrameCount, int )