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
/********************************************************************
*
*	Created:	24/3/2014   14:57
*
*	File:		fsCSplashScreenGui.h
*
*	Author:		Mick Waites
*	
*	Purpose:	Displays copyright screens before the main Guis are
*				presented.
*
*********************************************************************/

#ifndef fsCSplashScreenGuihdr
#define fsCSplashScreenGuihdr

#include <vector>

#include <fsCore/src/fsCUniqueId.h>
#include <fsCore/fsStr.h>

#include "fsIMessageListenerGuiComponent.h"

class fsCEntity;
class fsINode;
class fsISpriteComponent;


class fsCSplashScreenGui : public fsIMessageListenerGuiComponent
{
	friend class fsCComponentFactory;

public:

	static const fsCUniqueId mTypeId;

protected:

	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
	void updateDo(fsS32 pDeltaMs) override;

	void listenersRegisterDo() override;
	void listenersDeregisterDo() override;
	fsBool messageProcessDo(const fsCUniqueId& pMessageType,
	                        const fsIMessageDispatcher::sMessageParameters& pParam) override;

	static fsIComponent* create(fsCEntity* pParent);

	fsCSplashScreenGui(fsCEntity* pParent);
	virtual ~fsCSplashScreenGui();<--- Destructor in derived class

private:

	void nextScreenPrepare();
	void nextScreenPresent();
	void nextGuiLoad();

	void variablesRead(const fsCVariableTable& pVars);
	void screenFileNamesRead(const fsCVariableTable& pVars);
	void firstScreenDisplay();

	std::vector<fsStr> mScreens;

	fsStr mNextGui;

	fsISpriteComponent* mSprComp;

	fsS32 mCurrentScreenIndex;

	fsS32 mMinDurationMs;
	fsS32 mMaxDurationMs;

	fsS32 mTimeOnCurrentScreen;

	// Guards against nextGuiLoad() firing more than once. With zero
	// configured screens, firstScreenDisplay() calls nextGuiLoad()
	// straight away without ever advancing mCurrentScreenIndex, so
	// updateDo()'s "mCurrentScreenIndex == 0" check kept re-entering it
	// every single frame - each call created another main-menu instance
	// and re-destroyed the (already-destroyed) parent entity.
	fsBool mNextGuiLoaded;
};

#endif