LeviLamina
Loading...
Searching...
No Matches
ScreenView.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/gui/CardinalDirection.h"
7#include "mc/client/gui/DirtyFlag.h"
8#include "mc/client/gui/GameEventNotification.h"
9#include "mc/client/gui/controls/TextCharEventResult.h"
10#include "mc/client/gui/screens/ControlCollectionChange.h"
11#include "mc/client/gui/screens/ControlCollectionFlag.h"
12#include "mc/client/gui/screens/GamepadCursorData.h"
13#include "mc/client/gui/screens/TextEditFocusedListener.h"
14#include "mc/deps/core/utility/NonOwnerPointer.h"
15#include "mc/deps/core/utility/pub_sub/Publisher.h"
16#include "mc/deps/core/utility/pub_sub/Subscription.h"
17#include "mc/deps/input/InputMode.h"
18#include "mc/deps/input/TextboxTextUpdateReason.h"
19#include "mc/deps/input/enums/ButtonState.h"
20#include "mc/deps/input/enums/DirectionId.h"
21#include "mc/deps/input/enums/FocusImpact.h"
22
23// auto generated forward declare list
24// clang-format off
25class AbstractScene;
27class FocusComponent;
28class FocusManager;
29class KeyboardManager;
30class LayoutManager;
31class RectangleArea;
36class ScreenSettings;
37class ScreenViewProxy;
38class SliderComponent;
41class UIControl;
44class UIPropertyBag;
45class UIRenderContext;
46class VisualTree;
47struct ITTSEventManager;
48struct ScreenEvent;
50namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
51namespace Json { class Value; }
52// clang-format on
53
54class ScreenView {
55public:
56 // ScreenView inner types declare
57 // clang-format off
58 struct DelayedCommand;
59 struct TouchPadData;
60 // clang-format on
61
62 // ScreenView inner types define
63 enum class DelayedCommandLocation : int {
64 DirtyVisualTree = 0,
65 PostLayout = 1,
66 };
67
68 struct DelayedCommand {
69 public:
70 // DelayedCommand inner types define
71 using Result = ::std::pair<::ui::DirtyFlag, bool>;
72
73 public:
74 // member variables
75 // NOLINTBEGIN
76 ::ll::TypedStorage<8, 64, ::std::function<::std::pair<::ui::DirtyFlag, bool>()>> mAction;
77 ::ll::TypedStorage<4, 4, ::ScreenView::DelayedCommandLocation> location;
78 // NOLINTEND
79
80 public:
81 // member functions
82 // NOLINTBEGIN
83 MCAPI ~DelayedCommand();
84 // NOLINTEND
85
86 public:
87 // destructor thunk
88 // NOLINTBEGIN
89 MCFOLD void $dtor();
90 // NOLINTEND
91 };
92
93 struct TouchPadData {
94 public:
95 // member variables
96 // NOLINTBEGIN
97 ::ll::TypedStorage<4, 4, int> mTouchId;
98 ::ll::TypedStorage<4, 8, ::glm::vec2> mPreviousPosition;
99 ::ll::TypedStorage<4, 8, ::glm::vec2> mCurrentPosition;
100 // NOLINTEND
101 };
102
103 using clock_type = ::std::chrono::steady_clock;
104
105 using duration_sec = ::std::chrono::duration<float, ::std::ratio<1, 1>>;
106
107public:
108 // member variables
109 // NOLINTBEGIN
110 ::ll::TypedStorage<4, 4, float> mLastTime;
111 ::ll::TypedStorage<4, 4, float> mTickTime;
112 ::ll::TypedStorage<8, 8, double> mLastRawJoystickEventTime;
113 ::ll::TypedStorage<4, 8, ::glm::vec2> mSize;
114 ::ll::TypedStorage<4, 4, int> mMenuUpButtonId;
115 ::ll::TypedStorage<4, 4, int> mMenuDownButtonId;
116 ::ll::TypedStorage<4, 4, int> mMenuLeftButtonId;
117 ::ll::TypedStorage<4, 4, int> mMenuRightButtonId;
118 ::ll::TypedStorage<4, 4, int> mMenuTabLeftButtonId;
119 ::ll::TypedStorage<4, 4, int> mMenuTabRightButtonId;
120 ::ll::TypedStorage<4, 8, ::std::array<uint, 2>> mPointerButtonIds;
121 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScreenController>> mController;
122 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::VisualTree>> mVisualTree;
123 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysBindControls;
124 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mInputControls;
125 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mScrollViewControls;
126 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mOutOfModalScopeScrollViewControls;
127 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAnimationControls;
128 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFactoryControls;
129 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mTextEditBoxControls;
130 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysListeningInputControls;
131 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mRenderableControls;
132 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFlyingItemRendererControls;
133 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mSliderControls;
134 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomRendererControls;
135 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomFrameUpdateControls;
136 ::ll::TypedStorage<
137 8,
138 16,
139 ::std::map<::std::vector<::std::shared_ptr<::UIControl>>*, ::std::vector<::std::shared_ptr<::UIControl>>>>
140 mControlsToRemove;
141 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenRenderBatch>> mRootRenderBatch;
142 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIAnimationController>> mAnimationController;
143 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint, ::std::vector<::std::weak_ptr<::UIControl>>>>
144 mReservedButtonUpEvents;
145 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mSelectedControl;
146 ::ll::TypedStorage<4, 4, ::InputMode> mInputMode;
147 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LayoutManager>> mLayoutManager;
148 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FocusManager>> mFocusManager;
149 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ITTSEventManager>> mTTSEventManager;
150 ::ll::TypedStorage<1, 1, bool> mTextToSpeechEnabled;
151 ::ll::TypedStorage<8, 32, ::std::string> mTTSSectionHeader;
152 ::ll::TypedStorage<4, 4, float> mCurrentSliderValue;
153 ::ll::TypedStorage<1, 1, bool> mIsGUIScaleSlider;
154 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::ui::CardinalDirection>> mControllerStickDirections;
155 ::ll::TypedStorage<4, 4, int> mControllerLastMoved;
156 ::ll::TypedStorage<4, 4, int> mCursorTick;
157 ::ll::TypedStorage<4, 4, float const> mControllerXThreshold;
158 ::ll::TypedStorage<4, 4, float const> mControllerYThreshold;
159 ::ll::TypedStorage<4, 72, ::glm::vec2[9]> mControllerStickValues;
160 ::ll::TypedStorage<4, 8, ::GamepadCursorData> mGamepadCursorData;
161 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadCursorPosition;
162 ::ll::TypedStorage<1, 1, bool> mHasSetInitialPosition;
163 ::ll::TypedStorage<1, 1, bool> mGamepadCursorFocusModeEnabled;
164 ::ll::TypedStorage<1, 1, bool> mGamepadCursorMagnetEnabled;
165 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mGamepadMagnetControl;
166 ::ll::TypedStorage<4, 4, float> mGamepadMoveTime;
167 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadTrackedDirection;
168 ::ll::TypedStorage<1, 1, bool> mGamepadHasTapped;
169 ::ll::TypedStorage<4, 20, ::ScreenView::TouchPadData> mTouchPadData;
170 ::ll::TypedStorage<4, 8, ::glm::vec2> mPointerLocationPrevious;
171 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastPointInTime;
172 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mCurrentTime;
173 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mTimeAccumulator;
174 ::ll::TypedStorage<4, 4, ::std::chrono::duration<float, ::std::ratio<1, 1>> const> mFixedAnimationUpdateRate;
175 ::ll::TypedStorage<4, 4, float> mKeyboardHeight;
176 ::ll::TypedStorage<1, 1, bool> mShouldShowKeyboard;
177 ::ll::TypedStorage<1, 1, bool> mInitKeyboard;
178 ::ll::TypedStorage<4, 4, float> mCurrentObfuscateTime;
179 ::ll::TypedStorage<8, 8, ::KeyboardManager&> mKeyboardManager;
180 ::ll::TypedStorage<8, 24, ::std::vector<::RectangleArea>> mInputAreas;
181 ::ll::TypedStorage<8, 8, ::UIMeasureStrategy&> mMeasureStrategy;
182 ::ll::TypedStorage<1, 1, bool> mCanMoveFocus;
183 ::ll::TypedStorage<1, 1, ::FocusImpact> mNextFocusAction;
184 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::UIControlFactory>> mControlFactory;
185 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mAnimationEvents;
186 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mCustomRendererEvents;
187 ::ll::TypedStorage<4, 8, ::glm::vec2> mStartLocation;
188 ::ll::TypedStorage<4, 4, float> mTimeUntilNextPointerHeldEvent;
189 ::ll::TypedStorage<4, 4, float> mDelayBetweenEachPointerHeldEvent;
190 ::ll::TypedStorage<1, 1, bool> mShouldSendPointerHeldEvents;
191 ::ll::TypedStorage<8, 24, ::std::vector<::ScreenView::DelayedCommand>> mDelayedCommands;
192 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenViewProxy>> mProxy;
193 ::ll::TypedStorage<8, 40, ::std::queue<::std::string, ::std::deque<::std::string>>> mQueuedTextChange;
194 ::ll::TypedStorage<1, 1, bool> mIsExiting;
195 ::ll::TypedStorage<1, 1, bool> mIsEntering;
196 ::ll::TypedStorage<1, 1, bool> mIsInitialized;
197 ::ll::TypedStorage<1, 1, bool> mHasFocus;
198 ::ll::TypedStorage<1, 1, bool> mHasHadFocus;
199 ::ll::TypedStorage<1, 1, bool> mIsTerminating;
200 ::ll::TypedStorage<1, 1, bool> mDirectionalButtonWasPressed;
201 ::ll::TypedStorage<1, 1, bool> mDelayedFocusRefresh;
202 ::ll::TypedStorage<1, 1, ::TextEditFocusedListener> mTextEditFocusedListener;
203 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker>> mScreenLoadTimeTracker;
204 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mFocusChangeSub;
205 // NOLINTEND
206
207public:
208 // prevent constructor by default
209 ScreenView& operator=(ScreenView const&);
210 ScreenView(ScreenView const&);
211 ScreenView();
212
213public:
214 // member functions
215 // NOLINTBEGIN
216 MCAPI ScreenView(
217 ::KeyboardManager& keyboardManager,
218 ::std::shared_ptr<::ScreenController> controller,
219 ::std::unique_ptr<::VisualTree> visualTree,
220 ::std::shared_ptr<::UIControlFactory> controlFactory,
221 ::UIMeasureStrategy& measureStrategy,
222 ::std::unique_ptr<::LayoutManager> layoutManager,
223 ::GamepadCursorData gamepadCursorData,
224 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
225 );
226
227 MCAPI void _addToControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
228
229 MCAPI void _adjustFocusedControlToScrollRegion(bool isRightStickScrolling);
230
231 MCAPI void _adjustScrollToControl(::UIControl& control);
232
233 MCAPI void
234 _adjustScrollToFocusedControl(::UIControl& focusedControl, bool selectNearestControl, bool isRightStickScrolling);
235
236 MCAPI void _adjustScrollToIncludePosition(
237 ::UIControl& parent,
238 ::glm::vec2 position,
239 ::glm::vec2 size,
240 bool isRightStickScrolling
241 );
242
243 MCAPI void _adjustScrollToTopPosition();
244
245 MCAPI void _advanceToNextToggleInNavigationTabGroup(bool right);
246
247 MCAPI void _bindData(bool doAllBinds);
248
249 MCAPI void
250 _changeInputControlCollection(::UIControl& control, ::ControlCollectionChange change, bool isRemoveCallback);
251
252 MCAPI void _clearTTSQueue();
253
254 MCAPI void _consumeFocusImpact(::FocusImpact focusImpact);
255
256 MCAPI void _debugRenderControl(::UIRenderContext& context, ::UIControl const& control) const;
257
258 MCAPI void _debugRenderFocusControl(
259 ::UIRenderContext& context,
260 ::UIControl const& control,
261 ::std::vector<::UIControl const*>& visited
262 ) const;
263
264 MCAPI void _deselectControl(bool forceDeselect, bool hoverAfterDeselect);
265
266 MCAPI void _executeDelayedCommands(::ScreenView::DelayedCommandLocation location);
267
268 MCAPI void _findAndSetFocusOnFocusableControlNotClippedVertical(
269 ::std::shared_ptr<::UIControl> rootControl,
270 bool searchUpwards,
271 bool isRightScrolling
272 );
273
274 MCAPI void _fireSelectedStateChangeEvent(::TextEditComponent const& textEditComponent, bool state);
275
276 MCAPI void _fireTextChangedEvent(
277 bool finished,
278 ::TextCharEventResult result,
279 uint id,
280 int index,
281 ::UIPropertyBag* propertyBag
282 );
283
284 MCAPI void _fireTextChangedEventTextEditControl(
285 ::TextEditComponent const& textEditComponent,
286 bool finished,
287 ::TextCharEventResult result
288 );
289
290 MCAPI void _focusChangeCallback(
291 ::std::weak_ptr<::UIControl> previousFocusControl,
292 ::std::weak_ptr<::UIControl> currentFocusControl
293 );
294
295 MCAPI void _focusControl(::UIControl& control);
296
297 MCAPI void _forwardEventToAnimationControls(::ScreenEvent const& screenEvent);
298
299 MCAPI ::std::shared_ptr<::UIControl> _getGamepadCursorFocusedControl() const;
300
301 MCAPI ::ScreenSettings const* _getScreenComponent() const;
302
303 MCAPI void _handleDirtyVisualTree(bool overrideFocusControl, bool doAllBinds);
304
305 MCAPI void _handlePointerLocation(
306 ::glm::vec2 const& position,
307 ::FocusImpact focusImpact,
308 bool forceHandleWhenMotionless,
309 bool isRightStickScrolling
310 );
311
312 MCAPI bool _handleScreenViewRefresh();
313
314 MCAPI void _handleSliderMovement();
315
316 MCAPI void _handleStickScrolling(::DirectionId directionId);
317
318 MCAPI void
319 _handleTTSOnSliderMovement(::SliderComponent* sliderComponent, ::std::shared_ptr<::UIControl>& focusedControl);
320
321 MCAPI bool _hasVisibleAnimationWithEndEventId(uint id) const;
322
323 MCAPI bool _isFocusable(::FocusComponent const& focus) const;
324
325 MCAPI bool _isTouchTTSEnabled() const;
326
327 MCAPI bool _notifyLayoutChange();
328
329 MCAPI void _passViewCommand();
330
331 MCAPI void _prepResevedButtonUpLists(::ScreenInputContext& context);
332
333 MCAPI void _processControllerCursorMove(::DirectionId directionId);
334
335 MCAPI void _processControllerDirection(::DirectionId directionId);
336
337 MCAPI void _processControllerFocusChange(::DirectionId directionId);
338
339 MCAPI void _processEvents(::ScreenInputContext& context);
340
341 MCAPI void _processQueuedText();
342
343 MCAPI void _queueTextToSpeechIfEnabled(
344 ::std::shared_ptr<::UIControl> focusedControl,
345 bool excludeControlHeader,
346 bool notInterruptible
347 );
348
349 MCAPI void _queueTextToSpeechTextboxCharacter(::std::string const& inputStr);
350
351 MCAPI void _removeFromControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
352
353 MCAPI void _renderBatches(::UIRenderContext& context, ::ScreenRenderBatch& screenRenderBatch, float deltaTime);
354
355 MCAPI void _resetFocusedControl();
356
357 MCAPI void _scrollToGridItem(::UIControl* gridControl, int itemIndex, int numItems);
358
359 MCAPI void _selectControl(::UIControl& control, bool isHandlingTextChar);
360
361 MCAPI void _selectNextFocusObject(
362 ::ui::CardinalDirection direction,
363 bool overrideOrigin,
364 ::glm::vec2 overridePos,
365 bool isRightStickScrolling
366 );
367
368 MCAPI void _sendScrollEvent(::UIControl& parent, float delta) const;
369
370 MCAPI void _setGamepadCursorFocusMode(bool focusModeEnabled);
371
372 MCAPI void _setKeyboardHeight(float height);
373
374 MCAPI void _setupControlFactoryCallbacks();
375
376 MCAPI void _switchTabToTargetIndex(::std::vector<::std::shared_ptr<::UIControl>>& tabControls, int targetIndex);
377
378 MCAPI void _update();
379
380 MCAPI bool _updateControlCollections(bool overrideFocusControl);
381
382 MCAPI void
383 _updateFocusControl(bool forceUpdate, bool forceFocusToAdjust, bool isRightStickScrolling, bool isHandlingTextChar);
384
385 MCAPI void _updateInputAreas();
386
387 MCAPI void _updateKeyboardVisibility();
388
389 MCAPI bool _updateSelectedControl(::ScreenInputContext& context, uint buttonId, ::ButtonState buttonState);
390
391 MCAPI void cleanInputComponents();
392
393 MCAPI ::std::string getRoute() const;
394
395 MCAPI ::std::string getScreenName() const;
396
397 MCAPI ::std::string getScreenTelemetryName() const;
398
399 MCAPI void handleButtonEvent(uint buttonId, ::ButtonState buttonState, ::FocusImpact focusImpact);
400
401 MCAPI void handleControlEvent(::ScreenEvent screenEvent);
402
403 MCAPI void handleDirection(::DirectionId directionId, float x, float y, ::FocusImpact focusImpact);
404
405 MCAPI void handleInputModeChanged(::InputMode inputMode);
406
407 MCAPI bool
408 handlePointerLocation(::glm::vec2 const& position, bool forceMotionlessPointer, ::FocusImpact focusImpact);
409
410 MCAPI void handleTextChar(::std::string const& inputUtf8, ::FocusImpact focusImpact);
411
412 MCAPI void handleTouchPadTouch(::TouchPadTouchEventData const& touchEventData, ::FocusImpact focusImpact);
413
414 MCAPI bool isGamepadDeflectionModeEnabled() const;
415
416 MCAPI void onFocusGained();
417
418 MCAPI void onGameEventNotification(::ui::GameEventNotification notification);
419
420 MCAPI void onScreenEntrance(bool isRevisiting, bool doScreenTransitions);
421
422 MCAPI void onScreenExit(bool isPopping, bool doScreenTransitions, ::std::shared_ptr<::AbstractScene> pushedScene);
423
424 MCAPI void reload(::Json::Value const& globalVars);
425
426 MCAPI void render(::UIRenderContext& uiRenderContext);
427
428 MCAPI void resize();
429
430 MCAPI void setInitialized();
431
432 MCAPI void setScreenLoadTimeTracker(::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker> tracker);
433
434 MCAPI void setTextboxText(::std::string const& text, ::TextboxTextUpdateReason reason);
435
436 MCAPI ~ScreenView();
437 // NOLINTEND
438
439public:
440 // static functions
441 // NOLINTBEGIN
442 MCAPI static bool _shouldBindChildren(bool doAllBinds, ::UIControl& control, ::DataBindingComponent& dataBinding);
443 // NOLINTEND
444
445public:
446 // static variables
447 // NOLINTBEGIN
448 MCAPI static ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>&
449 mDebugChangePublisher();
450
451 MCAPI static bool& sIsDebuggingFocus();
452
453 MCAPI static bool& sRenderDebugControls();
454 // NOLINTEND
455
456public:
457 // constructor thunks
458 // NOLINTBEGIN
459 MCAPI void* $ctor(
460 ::KeyboardManager& keyboardManager,
461 ::std::shared_ptr<::ScreenController> controller,
462 ::std::unique_ptr<::VisualTree> visualTree,
463 ::std::shared_ptr<::UIControlFactory> controlFactory,
464 ::UIMeasureStrategy& measureStrategy,
465 ::std::unique_ptr<::LayoutManager> layoutManager,
466 ::GamepadCursorData gamepadCursorData,
467 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
468 );
469 // NOLINTEND
470
471public:
472 // destructor thunk
473 // NOLINTBEGIN
474 MCAPI void $dtor();
475 // NOLINTEND
476};
Definition AbstractScene.h:5
Definition DataBindingComponent.h:5
Definition FocusComponent.h:5
Definition FocusManager.h:5
Definition Value.h:16
Definition KeyboardManager.h:5
Definition LayoutManager.h:5
Definition RectangleArea.h:5
Definition ScreenController.h:5
Definition ScreenInputContext.h:5
Definition ScreenLoadTimeTracker.h:5
Definition ScreenRenderBatch.h:5
Definition ScreenSettings.h:5
Definition ScreenViewProxy.h:5
Definition ScreenView.h:5
Definition SliderComponent.h:5
Definition TextEditComponent.h:5
Definition UIAnimationController.h:5
Definition UIControlFactory.h:5
Definition UIControl.h:5
Definition UIMeasureStrategy.h:5
Definition UIPropertyBag.h:5
Definition UIRenderContext.h:5
Definition VisualTree.h:5
Definition ITTSEventManager.h:5
Definition ScreenEvent.h:5
Definition ScreenView.h:18
Definition ScreenView.h:16
Definition TouchPadTouchEventData.h:5