1 /*
2 	This file is part of Warzone 2100.
3 	Copyright (C) 1999-2004  Eidos Interactive
4 	Copyright (C) 2005-2020  Warzone 2100 Project
5 
6 	Warzone 2100 is free software; you can redistribute it and/or modify
7 	it under the terms of the GNU General Public License as published by
8 	the Free Software Foundation; either version 2 of the License, or
9 	(at your option) any later version.
10 
11 	Warzone 2100 is distributed in the hope that it will be useful,
12 	but WITHOUT ANY WARRANTY; without even the implied warranty of
13 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 	GNU General Public License for more details.
15 
16 	You should have received a copy of the GNU General Public License
17 	along with Warzone 2100; if not, write to the Free Software
18 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 /** @file
21  *  Interface defines/externs for warzone frontend.
22  */
23 
24 #ifndef __INCLUDED_SRC_MULTIINT_H__
25 #define __INCLUDED_SRC_MULTIINT_H__
26 
27 #include "lib/ivis_opengl/ivisdef.h"
28 #include "lib/netplay/netplay.h"
29 #include "lib/widget/widgbase.h"
30 #include "lib/widget/form.h"
31 #include "lib/widget/button.h"
32 #include <functional>
33 #include <vector>
34 #include "lib/framework/wzstring.h"
35 #include "titleui/multiplayer.h"
36 #include "faction.h"
37 
38 #define MAX_LEN_AI_NAME   40
39 #define AI_CUSTOM        127
40 #define AI_OPEN           -2
41 #define AI_CLOSED         -1
42 #define AI_NOT_FOUND     -99
43 
44 // WzMultiplayerOptionsTitleUI is in titleui.h to prevent dependency explosions
45 
46 void calcBackdropLayoutForMultiplayerOptionsTitleUI(WIDGET *psWidget, unsigned int, unsigned int, unsigned int, unsigned int);
47 void readAIs();	///< step 1, load AI definition files
48 void loadMultiScripts();	///< step 2, load the actual AI scripts
49 const char *getAIName(int player);	///< only run this -after- readAIs() is called
50 const std::vector<WzString> getAINames();
51 int matchAIbyName(const char* name);	///< only run this -after- readAIs() is called
52 
53 LOBBY_ERROR_TYPES getLobbyError();
54 void setLobbyError(LOBBY_ERROR_TYPES error_type);
55 
56 /**
57  * Updates structure limit flags. Flags indicate which structures are disabled.
58  */
59 void updateStructureDisabledFlags();
60 
61 void intDisplayFeBox(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset);
62 
63 std::shared_ptr<W_BUTTON> addMultiBut(WIDGET &parent, UDWORD id, UDWORD x, UDWORD y, UDWORD width, UDWORD height, const char *tipres, UDWORD norm, UDWORD down, UDWORD hi, unsigned tc = MAX_PLAYERS);
64 /**
65  * @deprecated use `addMultiBut(WIDGET &parent, UDWORD id, UDWORD x, UDWORD y, UDWORD width, UDWORD height, const char *tipres, UDWORD norm, UDWORD down, UDWORD hi, unsigned tc = MAX_PLAYERS)` instead
66  **/
67 std::shared_ptr<W_BUTTON> addMultiBut(const std::shared_ptr<W_SCREEN> &screen, UDWORD formid, UDWORD id, UDWORD x, UDWORD y, UDWORD width, UDWORD height, const char *tipres, UDWORD norm, UDWORD down, UDWORD hi, unsigned tc = MAX_PLAYERS);
68 
69 Image mpwidgetGetFrontHighlightImage(Image image);
70 bool changeColour(unsigned player, int col, bool isHost);
71 
72 extern char sPlayer[128];
73 extern bool multiintDisableLobbyRefresh; // gamefind
74 
75 void kickPlayer(uint32_t player_id, const char *reason, LOBBY_ERROR_TYPES type);
76 void displayKickReasonPopup(const std::string &reason);
77 void loadMapPreview(bool hideInterface);
78 
79 bool changeReadyStatus(UBYTE player, bool bReady);
80 WzString formatGameName(WzString name);
81 void resetVoteData();
82 void sendRoomSystemMessage(char const *text);
83 void displayRoomSystemMessage(char const *text);
84 void displayRoomNotifyMessage(char const *text);
85 
86 // ////////////////////////////////////////////////////////////////
87 // CONNECTION SCREEN
88 
89 #define CON_TYPESID_START	10105
90 #define CON_TYPESID_END		10128
91 
92 #define CON_SETTINGS		10130
93 #define CON_SETTINGS_LABEL	10131
94 #define CON_SETTINGSX		220 + D_W
95 #define	CON_SETTINGSY		190 + D_H
96 #define CON_SETTINGSWIDTH	200
97 #define CON_SETTINGSHEIGHT	100
98 
99 #define CON_OK				10101
100 #define CON_OKX				CON_SETTINGSWIDTH-MULTIOP_OKW*2-13
101 #define CON_OKY				CON_SETTINGSHEIGHT-MULTIOP_OKH-3
102 
103 #define CON_CANCEL			10102
104 
105 #define CON_PHONE			10132
106 #define CON_PHONEX			20
107 
108 #define CON_IP				10133
109 #define CON_IPX				20
110 #define CON_IPY				45
111 
112 #define CON_IP_CANCEL		10134
113 
114 //for clients
115 #define CON_PASSWORD		10139
116 #define CON_PASSWORDYES		10141
117 #define CON_PASSWORDNO		10142
118 
119 
120 // ////////////////////////////////////////////////////////////////
121 // GAME FIND SCREEN
122 
123 #define GAMES_GAMESTART		10201
124 #define GAMES_GAMEEND		GAMES_GAMESTART+20
125 #define GAMES_GAMEWIDTH		540
126 #define GAMES_GAMEHEIGHT	28
127 // We can have a max of 4 icons for status, current icon size if 36x25.
128 #define GAMES_STATUS_START 393
129 #define GAMES_GAMENAME_START 2
130 #define GAMES_MAPNAME_START 173
131 #define GAMES_MODNAME_START 173 + 6		// indent a bit
132 #define GAMES_PLAYERS_START 360
133 
134 // ////////////////////////////////////////////////////////////////
135 // GAME OPTIONS SCREEN
136 
137 #define MULTIOP_PLAYERS			10231
138 #define MULTIOP_PLAYERSX		323
139 #define MULTIOP_PLAYERSY		1
140 #define MULTIOP_PLAYER_START	10232		//list of players
141 #define MULTIOP_PLAYER_END		10249
142 #define MULTIOP_PLAYERSW		298
143 #define MULTIOP_PLAYERSH		380
144 
145 #define MULTIOP_ROW_WIDTH		246
146 
147 //Team chooser
148 #define MULTIOP_TEAMS_START		102310			//List of teams
149 #define MULTIOP_TEAMS_END		102341
150 #define MULTIOP_TEAMSWIDTH		29
151 #define	MULTIOP_TEAMSHEIGHT		38
152 
153 #define MULTIOP_TEAMCHOOSER_FORM	102800
154 #define MULTIOP_TEAMCHOOSER			102810
155 #define MULTIOP_TEAMCHOOSER_END     102841
156 #define MULTIOP_TEAMCHOOSER_KICK	10289
157 
158 #define MULTIOP_INLINE_OVERLAY_ROOT_FRM	10287
159 
160 // 'Ready' button
161 #define MULTIOP_READY_FORM_ID		102900
162 #define MULTIOP_READY_START         (MULTIOP_READY_FORM_ID + MAX_PLAYERS + 1)
163 #define	MULTIOP_READY_END           (MULTIOP_READY_START + MAX_PLAYERS - 1)
164 #define MULTIOP_READY_WIDTH			41
165 #define MULTIOP_READY_HEIGHT		38
166 
167 #define MULTIOP_PLAYERWIDTH		282
168 #define	MULTIOP_PLAYERHEIGHT	38
169 
170 #define MULTIOP_OPTIONS			10250
171 #define MULTIOP_OPTIONSX		40
172 #define MULTIOP_OPTIONSY		1
173 #define MULTIOP_OPTIONSW		284
174 #define MULTIOP_OPTIONSH		380
175 
176 #define MULTIOP_EDITBOXW		196
177 #define	MULTIOP_EDITBOXH		30
178 
179 #define	MULTIOP_BLUEFORMW		226
180 
181 #define	MROW1					4
182 #define	MROW2					MROW1+MULTIOP_EDITBOXH
183 #define	MROW3					MROW2+MULTIOP_EDITBOXH
184 #define	MROW4					MROW3+MULTIOP_EDITBOXH
185 #define MROW5					MROW4+38
186 #define	MROW6					MROW5+29
187 
188 #define MCOL0					50
189 #define MCOL1					(MCOL0+26+10)	// rem 10 for 4 lines.
190 #define MCOL2					(MCOL1+38)
191 #define MCOL3					(MCOL2+38)
192 #define MCOL4					(MCOL3+38)
193 
194 #define MULTIOP_PNAME_ICON		10252
195 #define MULTIOP_PNAME			10253
196 #define MULTIOP_GNAME_ICON		10254
197 #define MULTIOP_GNAME			10255
198 #define MULTIOP_MAP_ICON		10258
199 #define MULTIOP_MAP				10259
200 #define MULTIOP_MAP_MOD			21013	// Warning, do not use sequential numbers until code is fixed.
201 #define MULTIOP_MAP_RANDOM      21014
202 
203 #define MULTIOP_REFRESH			10275
204 
205 #define MULTIOP_HOST			10276
206 #define MULTIOP_HOSTX			5
207 
208 #define MULTIOP_FILTER_TOGGLE   30277
209 
210 #define MULTIOP_STRUCTLIMITS	21277	// we are using 10277 already
211 
212 #define MULTIOP_CANCELX			6
213 #define MULTIOP_CANCELY			6
214 
215 #define MULTIOP_CHATBOX			10278
216 #define MULTIOP_CHATBOXX		MULTIOP_OPTIONSX
217 #define MULTIOP_CHATBOXY		380
218 #define MULTIOP_CHATBOXW		((MULTIOP_PLAYERSX+MULTIOP_PLAYERSW) - MULTIOP_OPTIONSX)
219 
220 #define MULTIOP_CONSOLEBOX		0x1A001		// TODO: these should be enums!
221 #define MULTIOP_CONSOLEBOXX		MULTIOP_OPTIONSX
222 #define MULTIOP_CONSOLEBOXY		422
223 #define MULTIOP_CONSOLEBOXW		((MULTIOP_PLAYERSX + MULTIOP_PLAYERSW) - MULTIOP_OPTIONSX)
224 #define MULTIOP_CONSOLEBOXH		64
225 
226 #define MULTIOP_CHATEDIT		10279
227 #define MULTIOP_CHATEDITX		4
228 #define MULTIOP_CHATEDITH		18
229 #define	MULTIOP_CHATEDITW		(MULTIOP_CHATBOXW - 8)
230 
231 #define MULTIOP_COLCHOOSER_FORM         10280
232 #define MULTIOP_COLCHOOSER              102711 //10281
233 #define MULTIOP_COLCHOOSER_END          102742 //10288
234 
235 #define MULTIOP_LIMIT			10292	// 2 for this (+label)
236 #define MULTIOP_GAMETYPE		10294
237 #define MULTIOP_POWER			10296
238 #define MULTIOP_ALLIANCES		10298
239 #define MULTIOP_RANDOM			10299
240 #define MULTIOP_BASETYPE		10300
241 #define MULTIOP_TECHLEVEL		10301
242 
243 #define MULTIOP_MAP_PREVIEW 920000
244 
245 #define MULTIOP_PASSWORD	920010
246 #define MULTIOP_PASSWORD_BUT 920012
247 #define MULTIOP_PASSWORD_EDIT 920013
248 
249 #define MULTIOP_NO_SOMETHING            10331
250 #define MULTIOP_NO_SOMETHINGX           3
251 #define MULTIOP_NO_SOMETHINGY           MROW5
252 #define MULTIOP_ICON_LIMITS_X2		41
253 #define MULTIOP_ICON_LIMITS_Y2		182
254 
255 #define MULTIOP_COLOUR_START		10332
256 #define MULTIOP_COLOUR_END		(MULTIOP_COLOUR_START + MAX_PLAYERS)
257 #define MULTIOP_COLOUR_WIDTH		31
258 
259 #define MULTIOP_AI_FORM			(MULTIOP_COLOUR_END + 1)
260 #define MULTIOP_AI_START		(MULTIOP_AI_FORM + 1)
261 #define MULTIOP_AI_END			(MULTIOP_AI_START * MAX_PLAYERS)
262 #define MULTIOP_AI_OPEN			(MULTIOP_AI_END + 1)
263 #define MULTIOP_AI_CLOSED		(MULTIOP_AI_END + 2)
264 
265 #define MULTIOP_DIFFICULTY_INIT_START	(MULTIOP_AI_END + 3)
266 #define	MULTIOP_DIFFICULTY_INIT_END	(MULTIOP_DIFFICULTY_INIT_START + MAX_PLAYERS)
267 
268 #define MULTIOP_DIFFICULTY_CHOOSE_START	(MULTIOP_DIFFICULTY_INIT_END + 1)
269 #define MULTIOP_DIFFICULTY_CHOOSE_END	(MULTIOP_DIFFICULTY_CHOOSE_START + MAX_PLAYERS)
270 
271 #define MULTIOP_FACTION_START		(MULTIOP_DIFFICULTY_CHOOSE_END + 100000)
272 #define MULTIOP_FACTION_END		(MULTIOP_FACTION_START + MAX_PLAYERS)
273 #define MULTIOP_FACTION_WIDTH		31
274 #define MULTIOP_FACCHOOSER		(MULTIOP_FACTION_END + 1)
275 #define MULTIOP_FACCHOOSER_END		(MULTIOP_FACCHOOSER + NUM_FACTIONS)
276 #define MULTIOP_FACCHOOSER_FORM		(MULTIOP_FACCHOOSER_END+1)
277 
278 
279 // ///////////////////////////////
280 // Many Button Variations..
281 
282 #define	CON_NAMEBOXWIDTH		CON_SETTINGSWIDTH-CON_PHONEX
283 #define	CON_NAMEBOXHEIGHT		15
284 
285 #define MULTIOP_OKW			37
286 #define MULTIOP_OKH			24
287 
288 #define MULTIOP_BUTW			35
289 #define MULTIOP_BUTH			24
290 
291 #endif // __INCLUDED_SRC_MULTIINT_H__
292