Fission FSN
Loading...
Searching...
No Matches
fsCShareCard.h
Go to the documentation of this file.
1/********************************************************************
2*
3* File: fsCShareCard.h
4*
5* Purpose: Renders a share card layout offscreen to an image file.
6* Text sprites may hold {field} placeholders; image slots
7* are entities named in images, fitted inside their layout
8* size. A plain sprite the layout gives no image is an
9* optional slot, hidden unless it is filled. Needs
10* fsOffscreenRender (axmol).
11*
12*********************************************************************/
13
14#ifndef fsCShareCardhdr
15#define fsCShareCardhdr
16
17#include <functional>
18#include <map>
19#include <memory>
20#include <string>
21
22#include <fsCore/fsPoint.h>
23#include <fsCore/fsSColour.h>
24#include <fsCore/fsStr.h>
26
27class fsCBrush;
28
30{
31public:
32
33 struct sSpec
34 {
36 std::map<std::string, std::string> mFields;
37 std::map<fsStr, std::shared_ptr<fsCBrush>> mImages;
38 fsStr mPath; // absolute; .png or .jpg
39 };
40
41 using DoneCallback = std::function<void(fsBool pSaved, const fsPoint& pSize)>;
42
44
45 // Queued for the next render pass; pDone follows once the file is written.
46 static void render(const sSpec& pSpec, DoneCallback pDone);
47
48 // Exposed for tests and tools: fills fields and images into an already built card tree.
49 static void fill(class fsINode* pNode, const sSpec& pSpec);
50
51 // Tools: renders any layout as it would sit on screen, pSize design units around the screen's
52 // centre (e.g. the whole 1920 x 1080 canvas). pPrepare can set the gui up first, as the game would.
53 static void layoutRender(const fsCResourceName& pLayout, const fsPoint& pSize, const fsSColour4B& pClear,
54 const fsStr& pPath, std::function<void(class fsCEntity*)> pPrepare, DoneCallback pDone);
55};
56
57#endif
Definition fsCBrush.h:26
Definition fsCEntity.h:39
Definition fsCResourceName.h:32
Definition fsCShareCard.h:30
static fsBool supportedGet()
static void render(const sSpec &pSpec, DoneCallback pDone)
std::function< void(fsBool pSaved, const fsPoint &pSize)> DoneCallback
Definition fsCShareCard.h:41
static void fill(class fsINode *pNode, const sSpec &pSpec)
static void layoutRender(const fsCResourceName &pLayout, const fsPoint &pSize, const fsSColour4B &pClear, const fsStr &pPath, std::function< void(class fsCEntity *)> pPrepare, DoneCallback pDone)
Definition fsINode.h:30
Definition fsStr.h:23
bool fsBool
Definition fsBaseTypes.h:26
Definition fsCShareCard.h:34
std::map< fsStr, std::shared_ptr< fsCBrush > > mImages
Definition fsCShareCard.h:37
fsStr mPath
Definition fsCShareCard.h:38
fsCResourceName mLayout
Definition fsCShareCard.h:35
std::map< std::string, std::string > mFields
Definition fsCShareCard.h:36
Definition fsPoint.h:17
Definition fsSColour.h:54