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