aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIStructs.h
blob: 99c3d7bda423d1111cab83f391f822a2490bcfe3 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
#pragma once

#pragma message("UIStructs.h")

#include "UIEnums.h"

class Container;
class Inventory;
class BrewingStandTileEntity;
class DispenserTileEntity;
class FurnaceTileEntity;
class SignTileEntity;
class LevelGenerationOptions;
class LocalPlayer;
class Merchant;
class EntityHorse;
class BeaconTileEntity;
class Slot;
class AbstractContainerMenu;

// 4J Stu - Structs shared by Iggy and Xui scenes.
typedef struct _UIVec2D
{
	float x;
	float y;

	_UIVec2D& operator+=(const _UIVec2D &rhs)
	{
		x += rhs.x;
		y += rhs.y;
		return *this;
	}
} UIVec2D;

// Brewing
typedef struct _BrewingScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<BrewingStandTileEntity> brewingStand;
	int iPad;
	bool bSplitscreen;
} BrewingScreenInput;

// Chest
typedef struct _ContainerScreenInput
{
	shared_ptr<Container> inventory;
	shared_ptr<Container> container;
	int					  iPad;
	bool bSplitscreen;
} ContainerScreenInput;

// Dispenser
typedef struct _TrapScreenInput
{
	shared_ptr<Container> inventory;
	shared_ptr<DispenserTileEntity> trap;
	int iPad;
	bool bSplitscreen;
} TrapScreenInput;

// Inventory and creative inventory
typedef struct _InventoryScreenInput
{
	shared_ptr<LocalPlayer> player;
	bool bNavigateBack; // If we came here from the crafting screen, go back to it, rather than closing the xui menus
	int iPad;
	bool bSplitscreen;
} InventoryScreenInput;

// Enchanting		
typedef struct _EnchantingScreenInput
{
	shared_ptr<Inventory> inventory;
	Level *level;
	int x;
	int y;
	int z;
	int iPad;
	bool bSplitscreen;
	wstring name;
} 
EnchantingScreenInput;

// Furnace
typedef struct _FurnaceScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<FurnaceTileEntity> furnace;
	int iPad;
	bool bSplitscreen;
} FurnaceScreenInput;

// Crafting
typedef struct _CraftingPanelScreenInput
{
	shared_ptr<LocalPlayer> player;
	int						iContainerType; // RECIPE_TYPE_2x2 or RECIPE_TYPE_3x3
	bool					bSplitscreen;
	int						iPad;
	int						x;
	int						y;
	int						z;
} 
CraftingPanelScreenInput;

// Fireworks
typedef struct _FireworksScreenInput
{
	shared_ptr<LocalPlayer> player;
	bool					bSplitscreen;
	int						iPad;
	int						x;
	int						y;
	int						z;
} 
FireworksScreenInput;

// Trading
typedef struct _TradingScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<Merchant> trader;
	Level *level;
	int iPad;
	bool bSplitscreen;
}
TradingScreenInput;

// Anvil
typedef struct _AnvilScreenInput
{
	shared_ptr<Inventory> inventory;
	Level *level;
	int x;
	int y;
	int z;
	int iPad;
	bool bSplitscreen;
}
AnvilScreenInput;

// Hopper
typedef struct _HopperScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<Container> hopper;
	int iPad;
	bool bSplitscreen;
}
HopperScreenInput;

// Horse
typedef struct _HorseScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<Container> container;
	shared_ptr<EntityHorse> horse;
	int iPad;
	bool bSplitscreen;
}
HorseScreenInput;

// Beacon
typedef struct _BeaconScreenInput
{
	shared_ptr<Inventory> inventory;
	shared_ptr<BeaconTileEntity> beacon;
	int iPad;
	bool bSplitscreen;
}
BeaconScreenInput;

// Sign
typedef struct _SignEntryScreenInput
{
	shared_ptr<SignTileEntity> sign;
	int iPad;
} SignEntryScreenInput;

// Connecting progress
typedef struct _ConnectionProgressParams
{
	int iPad;
	int stringId;
	bool showTooltips;
	bool setFailTimer;
	int timerTime;
	void (*cancelFunc)(LPVOID param);
	LPVOID cancelFuncParam;

	_ConnectionProgressParams()
	{
		iPad = 0;
		stringId = -1;
		showTooltips = false;
		setFailTimer = false;
		timerTime = 0;
		cancelFunc = nullptr;
		cancelFuncParam = nullptr;
	}
} ConnectionProgressParams;

// Fullscreen progress
typedef struct _UIFullscreenProgressCompletionData
{
	BOOL bRequiresUserAction;
	BOOL bShowBackground;
	BOOL bShowLogo;
	BOOL bShowTips;
	ProgressionCompletionType type;
	int iPad;
	EUIScene scene;

	_UIFullscreenProgressCompletionData()
	{
		bRequiresUserAction = FALSE;
		bShowBackground = TRUE;
		bShowLogo = TRUE;
		bShowTips = TRUE;
		type = e_ProgressCompletion_NoAction;
	}
} UIFullscreenProgressCompletionData;

// Create world
typedef struct _CreateWorldMenuInitData
{
	BOOL bOnline;
	BOOL bIsPrivate;
	int iPad;
} 
CreateWorldMenuInitData;

// Join/Load saves list
typedef struct _SaveListDetails
{
	int saveId;
	PBYTE pbThumbnailData;
	DWORD dwThumbnailSize;
#ifdef _DURANGO
	wchar_t UTF16SaveName[128];
	wchar_t UTF16SaveFilename[MAX_SAVEFILENAME_LENGTH];
#else
	char UTF8SaveName[128];
#ifndef _XBOX
	char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH];
#endif
#endif

	_SaveListDetails()
	{
		saveId = 0;
		pbThumbnailData = nullptr;
		dwThumbnailSize = 0;
#ifdef _DURANGO
		ZeroMemory(UTF16SaveName,sizeof(wchar_t)*128);
		ZeroMemory(UTF16SaveFilename,sizeof(wchar_t)*MAX_SAVEFILENAME_LENGTH);
#else
		ZeroMemory(UTF8SaveName,128);
#ifndef _XBOX
		ZeroMemory(UTF8SaveFilename,MAX_SAVEFILENAME_LENGTH);
#endif
#endif
	}

} SaveListDetails;

// Load world
typedef struct _LoadMenuInitData
{
	int iPad;
	int iSaveGameInfoIndex;
	LevelGenerationOptions *levelGen;
	SaveListDetails *saveDetails;
} 
LoadMenuInitData;

// Join Games
typedef struct _JoinMenuInitData
{
	FriendSessionInfo *selectedSession;
	int iPad;
#ifdef _WINDOWS64
	int serverIndex; // Index of the server in servers.db, -1 if not a saved server
#endif
} JoinMenuInitData;

// Native keyboard (Windows64 replacement for InputManager.RequestKeyboard WinAPI dialog)
#ifdef _WINDOWS64
typedef struct _UIKeyboardInitData
{
	const wchar_t* title;
	const wchar_t* defaultText;
	int maxChars;
	int(*callback)(LPVOID, const bool);
	LPVOID lpParam;
	bool pcMode; // When true, disables on-screen keyboard buttons (PC keyboard users only need the text field)

	_UIKeyboardInitData() : title(nullptr), defaultText(nullptr), maxChars(25), callback(nullptr), lpParam(nullptr), pcMode(false) {}
} UIKeyboardInitData;

// Stores the text typed in UIScene_Keyboard so callbacks can retrieve it
// without calling InputManager.GetText (which shows the WinAPI dialog result).
extern wchar_t g_Win64KeyboardResult[256];
inline void Win64_GetKeyboardText(uint16_t* outBuf, int maxChars)
{
	wcsncpy_s((wchar_t*)outBuf, maxChars, g_Win64KeyboardResult, _TRUNCATE);
}

// Returns true if any XInput controller is currently connected.
// Used to decide whether to show the in-game keyboard UI or fall back to PC input.
#include <Xinput.h>
inline bool Win64_IsControllerConnected()
{
	XINPUT_STATE state;
	for (DWORD i = 0; i < XUSER_MAX_COUNT; i++)
	{
		memset(&state, 0, sizeof(state));
		if (XInputGetState(i, &state) == ERROR_SUCCESS)
			return true;
	}
	return false;
}
#endif // _WINDOWS64

// More Options
typedef struct _LaunchMoreOptionsMenuInitData
{
	bool bOnlineGame;
	bool bInviteOnly;
	bool bAllowFriendsOfFriends;

	bool bGenerateOptions;
	bool bStructures;
	bool bFlatWorld;
	bool bBonusChest;

	bool bPVP;
	bool bTrust;
	bool bFireSpreads;
	bool bTNT;

	bool bHostPrivileges;
	bool bResetNether;

	bool bMobGriefing;
	bool bKeepInventory;
	bool bDoMobSpawning;
	bool bDoMobLoot;
	bool bDoTileDrops;
	bool bNaturalRegeneration;
	bool bDoDaylightCycle;

	bool bOnlineSettingChangedBySystem;

	int iPad;

	DWORD dwTexturePack;

	wstring seed;
	int worldSize;
	bool bDisableSaving;

	EGameHostOptionWorldSize currentWorldSize;
	EGameHostOptionWorldSize newWorldSize;
	bool newWorldSizeOverwriteEdges;

	_LaunchMoreOptionsMenuInitData()
	{
		memset(this,0,sizeof(_LaunchMoreOptionsMenuInitData));
		bOnlineGame = true;
		bAllowFriendsOfFriends = true;
		bPVP = true;
		bFireSpreads = true;
		bTNT = true;
		iPad = -1;
		worldSize = 3;
		seed = L"";
		bDisableSaving = false;
		newWorldSize = e_worldSize_Unknown;
		newWorldSizeOverwriteEdges = false;

		bMobGriefing = true;
		bKeepInventory = false;
		bDoMobSpawning = true;
		bDoMobLoot = true;
		bDoTileDrops = true;
		bNaturalRegeneration = true;
		bDoDaylightCycle = true;
	}
} 
LaunchMoreOptionsMenuInitData;

typedef struct _LoadingInputParams
{
	C4JThreadStartFunc* func;
	LPVOID lpParam;
	UIFullscreenProgressCompletionData *completionData;

	int cancelText;
	void (*cancelFunc)(LPVOID param);
	void (*completeFunc)(LPVOID param);
	LPVOID m_cancelFuncParam;
	LPVOID m_completeFuncParam;
	bool waitForThreadToDelete;

	_LoadingInputParams()
	{
		func = nullptr;
		lpParam = nullptr;
		completionData = nullptr;

		cancelText = -1;
		cancelFunc = nullptr;
		completeFunc = nullptr;
		m_cancelFuncParam = nullptr;
		m_completeFuncParam = nullptr;
		waitForThreadToDelete = false;
	}
} LoadingInputParams;

// Tutorial
#ifndef _XBOX
class UIScene;
#endif
class Tutorial;
typedef struct _TutorialPopupInfo
{
#ifdef _XBOX
	CXuiScene *interactScene;
#else
	UIScene *interactScene;
#endif
	LPCWSTR desc;
	LPCWSTR title;
	int icon;
	int iAuxVal /* = 0 */;
	bool isFoil /* = false */;
	bool allowFade /* = true */;
	bool isReminder /*= false*/;
	Tutorial *tutorial;

	_TutorialPopupInfo()
	{
		interactScene = nullptr;
		desc = L"";
		title = L"";
		icon = -1;
		iAuxVal = 0;
		isFoil = false;
		allowFade = true;
		isReminder = false;
		tutorial = nullptr;
	}

} TutorialPopupInfo;

// Quadrant sign in
typedef struct _SignInInfo
{
	int( *Func)(LPVOID,const bool, const int iPad);
	LPVOID lpParam;
	bool requireOnline;
} SignInInfo;

// Credits
typedef struct 
{
	LPCWSTR				m_Text;				// Should contain string, optionally with %s to add in translated string ... e.g. "Andy West - %s"
	int					m_iStringID[2];		// May be NO_TRANSLATED_STRING if we do not require to add any translated string.
	ECreditTextTypes	m_eType;
}
SCreditTextItemDef;

// Message box
typedef struct _MessageBoxInfo
{
	UINT uiTitle;
	UINT uiText;
	UINT *uiOptionA;
	UINT uiOptionC;
	DWORD dwPad;
	int( *Func)(LPVOID,int,const C4JStorage::EMessageResult);
	LPVOID lpParam;
	//C4JStringTable *pStringTable; // 4J Stu - We don't need this for our internal message boxes
	WCHAR *pwchFormatString;
	DWORD dwFocusButton;
} MessageBoxInfo;

typedef struct _DLCOffersParam
{
	int iPad;
	int iOfferC;
	int iType;		
} 
DLCOffersParam;

typedef struct _InGamePlayerOptionsInitData
{
	int iPad;
	BYTE networkSmallId;
	unsigned int playerPrivileges;
} InGamePlayerOptionsInitData;

typedef struct _DebugSetCameraPosition
{
	int player;
	double m_camX, m_camY, m_camZ, m_yRot, m_elev;
} DebugSetCameraPosition;

typedef struct _TeleportMenuInitData
{
	int iPad;
	bool teleportToPlayer;
} TeleportMenuInitData;

typedef struct _CustomDrawData
{
	float x0, y0, x1, y1;     // the bounding box of the original DisplayObject, in object space
	float mat[16];
} CustomDrawData;

typedef struct _ItemEditorInput
{
	int iPad;
	Slot *slot;
	AbstractContainerMenu *menu;
} ItemEditorInput;