1 /*
2 ** g_intermission.h
3 **
4 **---------------------------------------------------------------------------
5 ** Copyright 2012 Braden Obrzut
6 ** All rights reserved.
7 **
8 ** Redistribution and use in source and binary forms, with or without
9 ** modification, are permitted provided that the following conditions
10 ** are met:
11 **
12 ** 1. Redistributions of source code must retain the above copyright
13 **    notice, this list of conditions and the following disclaimer.
14 ** 2. Redistributions in binary form must reproduce the above copyright
15 **    notice, this list of conditions and the following disclaimer in the
16 **    documentation and/or other materials provided with the distribution.
17 ** 3. The name of the author may not be used to endorse or promote products
18 **    derived from this software without specific prior written permission.
19 **
20 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 **---------------------------------------------------------------------------
31 **
32 **
33 */
34 
35 #include "g_mapinfo.h"
36 #include "tarray.h"
37 #include "wl_text.h"
38 #include "zstring.h"
39 #include "textures/textures.h"
40 
41 class IntermissionAction
42 {
43 public:
44 	struct DrawData
45 	{
46 	public:
47 		FTextureID		Image;
48 		unsigned int	X;
49 		unsigned int	Y;
50 	};
51 
52 	enum BackgroundType
53 	{
54 		UNSET,
55 
56 		NORMAL,
57 		HIGHSCORES,
58 		TITLEPAGE,
59 		LOADMAP
60 	};
61 
IntermissionAction()62 	IntermissionAction() : Type(UNSET), Time(0), BackgroundTile(false)
63 	{
64 		// Invalid background means use previous.
65 		Background.SetInvalid();
66 	}
67 
68 	FTextureID			Background;
69 	BackgroundType		Type;
70 	TArray<DrawData>	Draw;
71 	FString				Music;
72 	FString				Palette;
73 	unsigned int		Time;
74 	bool				BackgroundTile;
75 
76 	FString				MapName;
77 };
78 
79 class CastIntermissionAction : public IntermissionAction
80 {
81 public:
82 	const ClassDef *Class;
83 	FString Name;
84 };
85 
86 class FaderIntermissionAction : public IntermissionAction
87 {
88 public:
89 	enum FadeType
90 	{
91 		FADEIN,
92 		FADEOUT
93 	};
94 
95 	FadeType	Fade;
96 };
97 
98 class TextScreenIntermissionAction : public IntermissionAction
99 {
100 public:
TextScreenIntermissionAction()101 	TextScreenIntermissionAction() : IntermissionAction(), FadeTime(0),
102 		Alignment(TS_Left), Anchor(TS_Middle), TextFont(SmallFont),
103 		TextColor(CR_UNTRANSLATED), TextDelay(20), TextSpeed(4)
104 	{
105 	}
106 
107 	unsigned int	FadeTime;
108 	unsigned int	PrintX;
109 	unsigned int	PrintY;
110 	ETSAlignment	Alignment;
111 	ETSAnchor		Anchor;
112 	TArray<FString>	Text;
113 	FFont			*TextFont;
114 	EColorRange		TextColor;
115 	unsigned int	TextDelay;
116 	unsigned int	TextSpeed;
117 };
118 
119 class IntermissionInfo
120 {
121 public:
122 	static IntermissionInfo *Find(const FName &name);
123 
IntermissionInfo()124 	IntermissionInfo() : Link(NAME_None) {}
125 	// Clear on destruct requires move semantics
126 	//~IntermissionInfo() { Clear(); }
127 
128 	void Clear();
129 
130 	enum ActionType
131 	{
132 		IMAGE,
133 		FADER,
134 		CAST,
135 		GOTOTITLE,
136 		TEXTSCREEN,
137 		VICTORYSTATS
138 	};
139 
140 	struct Action
141 	{
142 		ActionType			type;
143 		IntermissionAction	*action;
144 	};
145 	TArray<Action>	Actions;
146 	FName			Link;
147 };
148 
149 // Returns true if the game should return to the menu instead of the title screen.
150 bool ShowIntermission(const IntermissionInfo *intermission, bool demoMode=false);
151