1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 | /********************************************************************
*
* Created: 13/1/2015 14:34
*
* File: gfCWordSearchMinigameLoaderComponent.h
*
* Author: Martin P. King
*
* Purpose: Logic for word search - control grid of
* fsCWordSearchMinigameComponents
*
*********************************************************************/
#ifndef gfCWordSearchMinigameLoaderComponenthdr
#define gfCWordSearchMinigameLoaderComponenthdr
#include <fsCore/fsPoint.h>
#include <fsCore/fsGrid.h>
#include <fsCore/fsSColour.h>
#include "../../gfIMinigameLogic.h"
#include "gfComponents/components/subScene/gfIOpaqueLensComponent.h"
class fsCResourceName;
class gfCMinigameLetterTileComponent;
class gfCWordSearchMinigameGenerateComponent;
class gfCMazeMinigameGenerateComponent;
class gfCWordSearchMinigameLogicComponent : public gfIMinigameLogic
{
friend class fsCComponentFactory;
public:
struct sWordSearchMessageParam : public fsIMessageDispatcher::sStrMessageParam
{
fsCEntity* mEnt;
};
static const fsCUniqueId mTypeId;
static const fsStr mEntityPrefix;
static const fsStr mSelectionPrefix;
fsBool hintActivate();
std::vector<fsCEntity*> selectedWordsGet() const;
void wordSelected();
void tilesSelect(gfIOpaqueLensComponent::fsSSwipe const& pSwipe);
void tilesHilite(gfIOpaqueLensComponent::fsSSwipe const& pSwipe);
void tileTap(const fsPoint& pTapPos);
fsStr tileSetGet() const { return mTileSet; }
void initialiseWithGenerator(gfCWordSearchMinigameGenerateComponent* pGenerator);
void initialiseWithGenerator(gfCMazeMinigameGenerateComponent* pGenerator);
~gfCWordSearchMinigameLogicComponent();<--- Destructor in derived class
protected:
void skipDo() override;
void listenersRegisterDo() override;<--- Function in derived class
void listenersDeregisterDo() override;<--- Function in derived class
fsBool messageProcessDo(const fsCUniqueId& pMessageType,<--- Function in derived class
const fsIMessageDispatcher::sMessageParameters& pParam) override;
void resetDo() override;
void deserialiseDo() override;
void serialiseDo() override;
void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
static fsIComponent* create(fsCEntity* pParent);
gfCWordSearchMinigameLogicComponent(fsCEntity* pParent);
private:
struct fsSSelection
{
fsStr mWord = {""};
std::vector<fsCEntity*> mLines;
std::vector<gfCMinigameLetterTileComponent*> mTiles;
std::vector<fsPoint> mGridPoints;
fsSSelection() = default;
~fsSSelection() = default;
fsBool empty() const;
void tilesTint(fsSColour4B const& pTint);
void clear();
};
static const fsSColour4B mTileTint;
std::vector<fsPoint> selectionLineSmooth(fsSSelection& pSelection);
void selectionLineCreate(fsSSelection& pSelection, fsSColour4B const& pTint);
void checkWords();
void snakeWordSelect(fsPoint const& pTapPos);
fsBool legalSnakeWord(const fsPoint& pTapPos);
void tilesSelectionHighlight(fsPoint tileAlignedStart, fsPoint tileAlignedEnd);
void gridInit(std::vector<std::vector<fsStr>>& pTileGrid, fsPoint const& pOrigin, fsPoint const& pGridDimensions);
fsStr wordCandidate();
void selectionAdjust(fsCEntity* pSelection, fsPoint const& pStart, fsPoint const& pEnd);
fsCEntity* selectionSpriteCreate(fsSSelection& pSelection, const fsCResourceName& pBrushName,fsSColour4B const& pTint);
void selectionSegmentCreate(fsSSelection& pSelection, fsPoint const& pStart, fsPoint const& pEnd, fsSColour4B const& pTint);
void selectionCapAdjust(fsCEntity* pSelection, fsPoint const& pPos, fsF32 pAngle);
fsPoint selectionCapOffsetGet(fsCEntity* pSelection, fsPoint const& pStart, fsPoint const& pEnd) const;
fsPoint selectionEndConstrainedGet(fsPoint const& pStart, fsPoint const& pEnd) const;
fsBool selectionDiagonalGet(fsPoint const& pSize) const;
fsF32 selectionAngleGet(fsPoint const& pStart, fsPoint const& pEnd) const;
fsBool selection2Available() const;
gfCMinigameLetterTileComponent* const tileComponentGet(fsCEntity* pEnt);
gfCMinigameLetterTileComponent* const tileCreate(fsPoint const& pGridPos,
std::vector<std::vector<fsStr>>& pLoadingLetterGrid);
void selectionsClear();
void selectionRecreate(fsStr& pSelectedWord);
void selectionsRecreate();
fsBool wordFindInGrid(fsSSelection& pSelection);
void wordsEntitiesGenerate();
static const fsStr mSelectionChunkMarker;
fsStr mTileSet = {""};
fsBool mMaze = {false};
fsGrid<gfCMinigameLetterTileComponent*> mTileGrid;
std::vector<fsStr> mHiddenWords;
fsSSelection mHintSelection;
fsSSelection mActiveSelection;
std::vector<std::unique_ptr<fsSSelection>> mFoundWords;
std::unique_ptr<fsCResourceName> mHilight;
std::unique_ptr<fsCResourceName> mHilight2;
std::unique_ptr<fsCResourceName> mHilight2End;
};
#endif
|