Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
IConsoleManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Misc/AccessDetection.h"
7#include "Misc/AssertionMacros.h"
8#include "Templates/UnrealTemplate.h"
9#include "Containers/UnrealString.h"
10#include "Logging/LogMacros.h"
11#include "Delegates/IDelegateInstance.h"
12#include "Delegates/Delegate.h"
13#include "Features/IModularFeature.h"
14#include "Templates/EnableIf.h"
15
16#define TRACK_CONSOLE_FIND_COUNT !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
17
18#if DO_CHECK && (!UE_BUILD_SHIPPING) // Disable even if checks in shipping are enabled.
19 #define cvarCheckCode( Code ) checkCode( Code )
20#else
21 #define cvarCheckCode(...)
22#endif
23
24template <class T> class TConsoleVariableData;
25
26/**
27 * Console variable usage guide:
28 *
29 * The variable should be creates early in the initialization but not before (not in global variable construction).
30 * Choose the right variable type, consider using a console command if more functionality is needed (see Exec()).
31 * Available types: bool, int, float, bool&, int&, float&, string
32 * Always provide a good help text, other should be able to understand the function of the console variable by reading this help.
33 * The help length should be limited to a reasonable width in order to work well for low res screen resolutions.
34 *
35 * Usage in the game console:
36 * <COMMAND> ? print the HELP
37 * <COMMAND> print the current state of the console variable
38 * <COMMAND> x set and print the new state of the console variable
39 *
40 * All variables support auto completion. The single line help that can show up there is currently not connected to the help as the help text
41 * is expected to be multi line.
42 * The former Exec() system can be used to access the console variables.
43 * Use console variables only in main thread.
44 * The state of console variables is not network synchronized or serialized (load/save). The plan is to allow to set the state in external files (game/platform/engine/local).
45 */
46
47/**
48 * Bitmask 0x1, 0x2, 0x4, ..
49 */
51{
52 /* Mask for flags. Use this instead of ~ECVF_SetByMask */
53 ECVF_FlagMask = 0x0000ffff,
54
55 /**
56 * Default, no flags are set, the value is set by the constructor
57 */
59 /**
60 * Console variables marked with this flag behave differently in a final release build.
61 * Then they are are hidden in the console and cannot be changed by the user.
62 */
64 /**
65 * Console variables cannot be changed by the user (from console).
66 * Changing from C++ or ini is still possible.
67 */
69 /**
70 * UnregisterConsoleObject() was called on this one.
71 * If the variable is registered again with the same type this object is reactivated. This is good for DLL unloading.
72 */
74 /**
75 * This flag is set by the ini loading code when the variable wasn't registered yet.
76 * Once the variable is registered later the value is copied over and the variable is destructed.
77 */
79 /**
80 * Maintains another shadow copy and updates the copy with render thread commands to maintain proper ordering.
81 * Could be extended for more/other thread.
82 * Note: On console variable references it assumes the reference is accessed on the render thread only
83 * (Don't use in any other thread or better don't use references to avoid the potential pitfall).
84 */
86
87 /* ApplyCVarSettingsGroupFromIni will complain if this wasn't set, should not be combined with ECVF_Cheat and ECVF_ExcludeFromPreview.
88 * They are automatically added as ECVF_Preview unless ECVF_ExcludeFromPreview is used
89 */
91
92 /* those cvars control other cvars with the flag ECVF_Scalability, names should start with "sg." */
94
95 /* CVars with this flag will be included in the device profile previews. */
96 ECVF_Preview = 0x100,
97
98 /* Cvars with this flag will modify the Shader Keystring for All Platforms*/
100
101 /* Cvars with this flag will modify the Shader Keystring for Mobile Platforms*/
103
104 /* Cvars with this flag will modify the Shader Keystring for Desktop Platforms*/
106
107 /* CVars with this flag will be excluded from the device profile previews. */
109
110 // ------------------------------------------------
111
112 /* Set flags */
113 ECVF_SetFlagMask = 0x00ff0000,
114
115 // Use to set a cvar without calling all cvar sinks. Much faster, but potentially unsafe. Use only if you know the particular cvar/setting does not require a sink call
117
118 // ------------------------------------------------
119
120 /* to get some history of where the last value was set by ( useful for track down why a cvar is in a specific state */
121 ECVF_SetByMask = 0xff000000,
122
123 // The ECVF_SetBy flags are sorted in override order (weak to strong), the value is not serialized. It only affects the override behavior when calling Set()
124
125 // Lowest priority (default after console variable creation)
127 // Set by scalability groups from Scalability.ini (lower priority than game settings so it's easier to override partially)
129 // Default priority for engine-level game user settings, platform-specific settings will override this
131 // Set by project settings UI or specific sections in ini file (higher priority than game setting to allow enforcing some settings for this project)
133 // Used by the [ConsoleVariables] section of Engine.ini as well as FSystemSettings
135 // Per device settings using the DeviceProfiles.ini hierarchy (e.g. specific iOS device, higher priority than per project to do device specific settings)
137 // User settable game overrides, used for GameUserSettings fields that need to override device specific settings
139 // Set by local consolevariables.ini, mostly used for testing multiple projects
141 // Used by some command line parameters, others use the Console priority instead
143 // Used for high priority temporary debugging or operation modes
144 ECVF_SetByCode = 0x09000000,
145 // Highest priority used via editor UI or or game/editor interactive console
146 ECVF_SetByConsole = 0x0A000000,
147
148
149 // ------------------------------------------------
150};
151
152class IConsoleVariable;
153
154#if !NO_CVARS
155
156/** Console variable delegate type This is a void callback function. */
157DECLARE_DELEGATE_OneParam( FConsoleVariableDelegate, IConsoleVariable* );
158
159/** Console variable multicast delegate type. */
160DECLARE_MULTICAST_DELEGATE_OneParam(FConsoleVariableMulticastDelegate, IConsoleVariable*);
161
162/** Console command delegate type (takes no arguments.) This is a void callback function. */
163DECLARE_DELEGATE( FConsoleCommandDelegate );
164
165/** Console command delegate type (with arguments.) This is a void callback function that always takes a list of arguments. */
166DECLARE_DELEGATE_OneParam( FConsoleCommandWithArgsDelegate, const TArray< FString >& );
167
168/** Console command delegate type with a world argument. This is a void callback function that always takes a world. */
169DECLARE_DELEGATE_OneParam( FConsoleCommandWithWorldDelegate, UWorld* );
170
171/** Console command delegate type (with a world and arguments.) This is a void callback function that always takes a list of arguments and a world. */
172DECLARE_DELEGATE_TwoParams(FConsoleCommandWithWorldAndArgsDelegate, const TArray< FString >&, UWorld*);
173
174/** Console command delegate type (with arguments and output device.) This is a void callback function that always takes a list of arguments and output device. */
175DECLARE_DELEGATE_TwoParams(FConsoleCommandWithArgsAndOutputDeviceDelegate, const TArray< FString >&, FOutputDevice&);
176
177/** Console command delegate type (with a world arguments and output device.) This is a void callback function that always takes a list of arguments, a world and output device. */
178DECLARE_DELEGATE_ThreeParams(FConsoleCommandWithWorldArgsAndOutputDeviceDelegate, const TArray< FString >&, UWorld*, FOutputDevice&);
179
180/** Console command delegate type with the output device passed through. */
181DECLARE_DELEGATE_OneParam( FConsoleCommandWithOutputDeviceDelegate, FOutputDevice& );
182
183#else
184
185template <typename DerivedType, typename... ParamTypes>
186struct FNullConsoleVariableDelegate
187{
188 /**
189 * Static: Creates a raw C++ pointer global function delegate
190 */
191 template <typename... VarTypes>
192 inline static DerivedType CreateStatic(typename TIdentity<void (*)(ParamTypes..., VarTypes...)>::Type, VarTypes...)
193 {
194 return {};
195 }
196
197 template<typename FunctorType, typename... VarTypes>
198 inline static DerivedType CreateLambda(FunctorType&&, VarTypes...)
199 {
200 return {};
201 }
202
203 template<typename UserClass, typename FunctorType, typename... VarTypes>
204 inline static DerivedType CreateWeakLambda(UserClass*, FunctorType&&, VarTypes...)
205 {
206 return {};
207 }
208
209 template <typename UserClass, typename... VarTypes>
210 inline static DerivedType CreateRaw(UserClass*, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
211 {
212 return {};
213 }
214 template <typename UserClass, typename... VarTypes>
215 inline static DerivedType CreateRaw(UserClass*, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
216 {
217 return {};
218 }
219
220 template <typename UserClass, typename... VarTypes>
221 inline static DerivedType CreateSP(const TSharedRef<UserClass>&, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
222 {
223 return {};
224 }
225 template <typename UserClass, typename... VarTypes>
226 inline static DerivedType CreateSP(const TSharedRef<UserClass>&, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
227 {
228 return {};
229 }
230
231 template <typename UserClass, typename... VarTypes>
232 inline static DerivedType CreateSP(UserClass*, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
233 {
234 return {};
235 }
236 template <typename UserClass, typename... VarTypes>
237 inline static DerivedType CreateSP(UserClass*, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
238 {
239 return {};
240 }
241
242 template <typename UserClass, typename... VarTypes>
243 inline static DerivedType CreateThreadSafeSP(const TSharedRef<UserClass, ESPMode::ThreadSafe>&, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
244 {
245 return {};
246 }
247 template <typename UserClass, typename... VarTypes>
248 inline static DerivedType CreateThreadSafeSP(const TSharedRef<UserClass, ESPMode::ThreadSafe>&, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
249 {
250 return {};
251 }
252
253 template <typename UserClass, typename... VarTypes>
254 inline static DerivedType CreateThreadSafeSP(UserClass*, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
255 {
256 return {};
257 }
258 template <typename UserClass, typename... VarTypes>
259 inline static DerivedType CreateThreadSafeSP(UserClass*, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
260 {
261 return {};
262 }
263
264 template <typename UObjectTemplate, typename... VarTypes>
265 inline static DerivedType CreateUFunction(UObjectTemplate*, const FName&, VarTypes...)
266 {
267 return {};
268 }
269
270 template <typename UserClass, typename... VarTypes>
271 inline static DerivedType CreateUObject(UserClass*, typename TMemFunPtrType<false, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
272 {
273 return {};
274 }
275 template <typename UserClass, typename... VarTypes>
276 inline static DerivedType CreateUObject(UserClass*, typename TMemFunPtrType<true, UserClass, void (ParamTypes..., VarTypes...)>::Type, VarTypes...)
277 {
278 return {};
279 }
280
281 FDelegateHandle GetHandle() const
282 {
283 return {};
284 }
285
286 bool ExecuteIfBound(ParamTypes...)
287 {
288 return false;
289 }
290};
291
292struct FConsoleVariableDelegate : FNullConsoleVariableDelegate<FConsoleVariableDelegate, IConsoleVariable*> {};
293struct FConsoleCommandDelegate : FNullConsoleVariableDelegate<FConsoleCommandDelegate> {};
294struct FConsoleCommandWithArgsDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithArgsDelegate, const TArray<FString>&> {};
295struct FConsoleCommandWithWorldDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithWorldDelegate, UWorld*> {};
296struct FConsoleCommandWithWorldAndArgsDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithWorldAndArgsDelegate, const TArray<FString>&, UWorld*> {};
297struct FConsoleCommandWithArgsAndOutputDeviceDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithArgsAndOutputDeviceDelegate, const TArray<FString>&, FOutputDevice&> {};
298struct FConsoleCommandWithWorldArgsAndOutputDeviceDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithWorldArgsAndOutputDeviceDelegate, const TArray<FString>&, UWorld*, FOutputDevice&> {};
299struct FConsoleCommandWithOutputDeviceDelegate : FNullConsoleVariableDelegate<FConsoleCommandWithOutputDeviceDelegate, FOutputDevice&> {};
300
301#endif
302
303template <class T> class TConsoleVariableData;
304
305/**
306 * Interface for console objects (variables and commands)
307 */
309{
310
311public:
312
315 : FindCallCount(0)
316#endif
317 {}
318
319 virtual ~IConsoleObject() {}
320
321 /**
322 * @return never 0, can be multi line ('\n')
323 */
324 virtual const TCHAR* GetHelp() const = 0;
325 /**
326 * @return never 0, can be multi line ('\n')
327 */
328 virtual void SetHelp(const TCHAR* Value) = 0;
329 /**
330 * Get the internal state of the flags.
331 */
332 virtual EConsoleVariableFlags GetFlags() const = 0;
333 /**
334 * Sets the internal flag state to the specified value.
335 */
336 virtual void SetFlags(const EConsoleVariableFlags Value) = 0;
337
338 // Convenience methods -------------------------------------
339
340 /**
341 * Removes the specified flags in the internal state.
342 */
344 {
345 uint32 New = (uint32)GetFlags() & ~(uint32)Value;
346
348 }
349 /**
350 * Test is any of the specified flags is set in the internal state.
351 */
352 bool TestFlags(const EConsoleVariableFlags Value) const
353 {
354 return ((uint32)GetFlags() & (uint32)Value) != 0;
355 }
356
357 /**
358 * Casts this object to an IConsoleVariable, returns 0 if it's not
359 */
361 {
362 return 0;
363 }
364
365 virtual bool IsVariableBool() const { return false; }
366 virtual bool IsVariableInt() const { return false; }
367 virtual bool IsVariableFloat() const { return false; }
368 virtual bool IsVariableString() const { return false; }
369
370 virtual class TConsoleVariableData<bool>* AsVariableBool()
371 {
372 ensureMsgf(false, TEXT("Attempted to access variable data of a console variable type that doesn't support it. For example FindTConsoleVariableData* on a FAutoConsoleVariableRef."));
373 return 0;
374 }
375
376 virtual class TConsoleVariableData<int32>* AsVariableInt()
377 {
378 ensureMsgf(false, TEXT("Attempted to access variable data of a console variable type that doesn't support it. For example FindTConsoleVariableData* on a FAutoConsoleVariableRef."));
379 return 0;
380 }
381
382 virtual class TConsoleVariableData<float>* AsVariableFloat()
383 {
384 ensureMsgf(false, TEXT("Attempted to access variable data of a console variable type that doesn't support it. For example FindTConsoleVariableData* on a FAutoConsoleVariableRef."));
385 return 0;
386 }
387
388 virtual class TConsoleVariableData<FString>* AsVariableString()
389 {
390 ensureMsgf(false, TEXT("Attempted to access variable data of a console variable type that doesn't support it. For example FindTConsoleVariableData* on a FAutoConsoleVariableRef."));
391 return 0;
392 }
393
394 /**
395 * Casts this object to an IConsoleCommand, verifying first that it is safe to do so
396 */
397 virtual struct IConsoleCommand* AsCommand()
398 {
399 return 0;
400 }
401
402private: // -----------------------------------------
403
405 // no longer pure visual, if that causes problems we can change the interface
406 // to track down FindConsoleObject/FindConsoleVariable calls without static
408#endif
409
410 /**
411 * should only be called by the manager, needs to be implemented for each instance
412 */
413 virtual void Release() = 0;
414
415 friend class FConsoleManager;
416};
417
418/**
419 * Interface for console variables
420 */
422{
423public:
424
425 /**
426 * Set the internal value from the specified string.
427 * @param SetBy anything in ECVF_LastSetMask e.g. ECVF_SetByScalability
428 **/
429 virtual void Set(const TCHAR* InValue, EConsoleVariableFlags SetBy = ECVF_SetByCode) = 0;
430
431 /**
432 * Get the internal value as a bool, works on bools, ints and floats.
433 */
434 virtual bool GetBool() const = 0;
435 /**
436 * Get the internal value as int (should not be used on strings).
437 * @return value is not rounded (simple cast)
438 */
439 virtual int32 GetInt() const = 0;
440 /** Get the internal value as float (works on all types). */
441 virtual float GetFloat() const = 0;
442 /** Get the internal value as string (works on all types). */
443 virtual FString GetString() const = 0;
444
445 /** Generic versions for templated code */
446 void GetValue(int32& OutIntValue)
447 {
448 OutIntValue = GetInt();
449 }
450 void GetValue(bool& OutBoolValue)
451 {
452 OutBoolValue = GetBool();
453 }
454 void GetValue(float& OutFloatValue)
455 {
456 OutFloatValue = GetFloat();
457 }
458 void GetValue(FString& OutStringValue)
459 {
460 OutStringValue = GetString();
461 }
462
463 /**
464 * Allows to specify a callback function that is called when the console variable value changes.
465 * Is even called if the value is the same as the value before. Will always be on the game thread.
466 * This can be dangerous (instead try to use RegisterConsoleVariableSink())
467 * - Setting other console variables in the delegate can cause infinite loops
468 * - Setting many console variables could result in wasteful cycles (e.g. if multiple console variables require to reattach all objects it would happen for each one)
469 * - The call can be at any time during initialization.
470 * As this cannot be specified during constructions you are not called on creation.
471 * We also don't call for the SetOnChangedCallback() call as this is up to the caller.
472 **/
473 virtual void SetOnChangedCallback(const FConsoleVariableDelegate& Callback) = 0;
474
475 virtual FConsoleVariableMulticastDelegate& OnChangedDelegate() = 0;
476
477 /**
478 * Get the saved off default value, in a cvar variable, if one was created
479 */
481 {
482 return nullptr;
483 }
484
486
487 /**
488 * Get a CVar opject that matches this cvar, but contains the value of the platform given.
489 */
491 {
492 // this could be called for some special subclass like FConsoleVariableBitRef that don't implement this (yet)
495 }
496
497 /**
498 * Used only for debugging/iterating, this will clear all of the other platform's cvar objects, which will
499 * force a fresh lookup (with fresh ini files, likely) on next call to GetPlatformValueVariable
500 */
502 {
503 }
504#endif
505
506 // convenience methods
507
508 /** Set the internal value from the specified bool. */
509 void Set(bool InValue, EConsoleVariableFlags SetBy = ECVF_SetByCode)
510 {
511 // NOTE: Bool needs to use 1 and 0 here rather than true/false, as this may be a int32 or something
512 // and eventually this code calls, TTypeFromString<T>::FromString which won't handle the true/false,
513 // but 1 and 0 will work for whatever.
514 // inefficient but no common code path
515 Set(InValue ? TEXT("1") : TEXT("0"), SetBy);
516 }
517 /** Set the internal value from the specified int. */
518 void Set(int32 InValue, EConsoleVariableFlags SetBy = ECVF_SetByCode)
519 {
520 // inefficient but no common code path
521 Set(*FString::Printf(TEXT("%d"), InValue), SetBy);
522 }
523 /** Set the internal value from the specified float. */
524 void Set(float InValue, EConsoleVariableFlags SetBy = ECVF_SetByCode)
525 {
526 // inefficient but no common code path
527 Set(*FString::Printf(TEXT("%g"), InValue), SetBy);
528 }
529
530 void SetWithCurrentPriority(bool InValue)
531 {
533 Set(InValue, CurFlags);
534 }
535 void SetWithCurrentPriority(int32 InValue)
536 {
538 Set(InValue, CurFlags);
539 }
540 void SetWithCurrentPriority(float InValue)
541 {
543 Set(InValue, CurFlags);
544 }
545 void SetWithCurrentPriority(const TCHAR* InValue)
546 {
548 Set(InValue, CurFlags);
549 }
550
551
552};
553
554/**
555 * Interface for console commands
556 */
558{
559 /**
560 * Executes this command (optionally, with arguments)
561 *
562 * @param Args Argument list for this command
563 * @param InWorld World context for this command
564 * @return True if the delegate for this command was executed successfully
565 */
566 virtual bool Execute( const TArray< FString >& Args, UWorld* InWorld, class FOutputDevice& OutputDevice ) = 0;
567};
568
569/**
570 * Interface to propagate changes of console variables to another thread
571 */
573{
574 virtual void OnCVarChange(int32& Dest, int32 NewValue) = 0;
575 virtual void OnCVarChange(float& Dest, float NewValue) = 0;
576 virtual void OnCVarChange(bool& Dest, bool NewValue) = 0;
577 virtual void OnCVarChange(FString& Dest, const FString& NewValue) = 0;
578};
579
580/**
581 * Declares a delegate type that's used by the console manager to call back into a user function for each
582 * known console object.
583 *
584 * First parameter is the Name string for the current console object
585 * Second parameter is the current console object
586 */
587DECLARE_DELEGATE_TwoParams( FConsoleObjectVisitor, const TCHAR*, IConsoleObject* );
588
589
590/**
591 * Class representing an handle to an online delegate.
592 */
594{
595public:
597 {
598 }
599
601 : Handle(InHandle)
602 {
603 }
604
605 template <typename MulticastDelegateType>
606 void RemoveFromDelegate(MulticastDelegateType& MulticastDelegate)
607 {
609 }
610
611 template <typename DelegateType>
612 bool HasSameHandle(const DelegateType& Delegate) const
613 {
614 return Delegate.GetHandle() == Handle;
615 }
616
617private:
619};
620
621
622/**
623 * Handles executing console commands
624 */
626{
627public:
628 virtual ~IConsoleCommandExecutor() = default;
629
630 /**
631 * Get the name identifying this modular feature set.
632 */
634 {
635 static const FName Name = TEXT("ConsoleCommandExecutor");
636 return Name;
637 }
638
639 /**
640 * Get the name of this executor.
641 */
642 virtual FName GetName() const = 0;
643
644 /**
645 * Get the display name of this executor.
646 */
647 virtual FText GetDisplayName() const = 0;
648
649 /**
650 * Get the description of this executor.
651 */
652 virtual FText GetDescription() const = 0;
653
654 /**
655 * Get the hint text of this executor.
656 */
657 virtual FText GetHintText() const = 0;
658
659 /**
660 * Get the list of auto-complete suggestions for the given command.
661 */
662 virtual void GetAutoCompleteSuggestions(const TCHAR* Input, TArray<FString>& Out) = 0;
663
664 /**
665 * Get the list of commands that this executor has recently processed.
666 */
667 virtual void GetExecHistory(TArray<FString>& Out) = 0;
668
669 /**
670 * Execute the given command using this executor.
671 * @return true if the command was recognized.
672 */
673 virtual bool Exec(const TCHAR* Input) = 0;
674
675 /**
676 * True if we allow the console to be closed using the "open console" hot-key.
677 * @note Some scripting languages use the default "open console" hot-key (~) in their code, so these should return false.
678 */
679 virtual bool AllowHotKeyClose() const = 0;
680
681 /**
682 * True if we allow the console to create multi-line commands.
683 */
684 virtual bool AllowMultiLine() const = 0;
685
686 /**
687 * Returns the hotkey for this executor
688 */
689 virtual struct FInputChord GetHotKey() const = 0;
690 /**
691 * Returns the hotkey to switch to the next executor. This is usually the same hotkey as GetHotKey but with a modifier,
692 * such as "`" turning into "Ctrl + `".
693 */
694 virtual struct FInputChord GetIterateExecutorHotKey() const = 0;
695};
696
697
698/**
699 * handles console commands and variables, registered console variables are released on destruction
700 */
702{
703 /**
704 * Create a bool console variable
705 * @param Name must not be 0
706 * @param Help must not be 0
707 * @param Flags bitmask combined from EConsoleVariableFlags
708 */
709 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, bool DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
710 /**
711 * Create a int console variable
712 * @param Name must not be 0
713 * @param Help must not be 0
714 * @param Flags bitmask combined from EConsoleVariableFlags
715 */
716 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, int32 DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
717 /**
718 * Create a float console variable
719 * @param Name must not be 0
720 * @param Help must not be 0
721 * @param Flags bitmask combined from EConsoleVariableFlags
722 */
723 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, float DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
724 /**
725 * Create a string console variable
726 * @param Name must not be 0
727 * @param Help must not be 0
728 * @param Flags bitmask combined from EConsoleVariableFlags
729 */
730 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, const TCHAR* DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
731 /**
732 * Create a string console variable
733 * @param Name must not be 0
734 * @param Help must not be 0
735 * @param Flags bitmask combined from EConsoleVariableFlags
736 */
737 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, const FString& DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
738 /**
739 * Create a reference to a bool console variable
740 * @param Name must not be 0
741 * @param Help must not be 0
742 * @param Flags bitmask combined from EConsoleVariableFlags
743 */
744 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
745 /**
746 * Create a reference to a int console variable
747 * @param Name must not be 0
748 * @param Help must not be 0
749 * @param Flags bitmask combined from EConsoleVariableFlags
750 */
751 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
752 /**
753 * Create a reference to a float console variable
754 * @param Name must not be 0
755 * @param Help must not be 0
756 * @param Flags bitmask combined from EConsoleVariableFlags
757 */
758 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
759 /**
760 * Create a reference to a string console variable
761 * @param Name must not be 0
762 * @param Help must not be 0
763 * @param Flags bitmask combined from EConsoleVariableFlags
764 */
765 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
766 /**
767 * Create a reference to a show flag variable
768 * @param CVarName must not be 0, e.g. "Show.PostProcessing"
769 * @param FlagName must not be 0, e.g. "PostProcessing"
770 * @param BitNumber in the memory defined by Force0MaskPtr and Force1MaskPtr
771 * @param Force0MaskPtr memory that contains the bits that should be forced to 0
772 * @param Force1MaskPtr memory that contains the bits that should be forced to 1
773 * @param Help must not be 0
774 * @param Flags bitmask combined from EConsoleVariableFlags
775 */
776 virtual IConsoleVariable* RegisterConsoleVariableBitRef(const TCHAR* CVarName, const TCHAR* FlagName, uint32 BitNumber, uint8* Force0MaskPtr, uint8* Force1MaskPtr, const TCHAR* Help, uint32 Flags = ECVF_Default) = 0;
777
778 // ----------
779
780 /**
781 * The sinks are only called if a change has been done since the last time
782 * Should be called in very few points:
783 * - after ini file loading
784 * - after user console input
785 * - user initiated a console variable change (it needs to be clear to user that a cvar can change e.g. game options menu)
786 * - beginning of Tick (to catch stray Set() calls, which are usually bad)
787 */
788 virtual void CallAllConsoleVariableSinks() = 0;
789
790 /**
791 * The registered command is executed at few defined points (see CallAllConsoleVariableSinks)
792 * @param Command
793 */
794 virtual FConsoleVariableSinkHandle RegisterConsoleVariableSink_Handle(const FConsoleCommandDelegate& Command) = 0;
795
796 /**
797 * The registered command is executed at few defined points (see CallAllConsoleVariableSinks)
798 * @param Command
799 */
801
802 // ----------
803
804 /**
805 * Register a console command that takes no arguments
806 *
807 * @param Name The name of this command (must not be nullptr)
808 * @param Help Help text for this command
809 * @param Command The user function to call when this command is executed
810 * @param Flags Optional flags bitmask
811 */
812 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandDelegate& Command, uint32 Flags = ECVF_Default) = 0;
813
814 /**
815 * Register a console command that takes arguments
816 *
817 * @param Name The name of this command (must not be nullptr)
818 * @param Help Help text for this command
819 * @param Command The user function to call when this command is executed
820 * @param Flags Optional flags bitmask
821 */
822 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command, uint32 Flags = ECVF_Default) = 0;
823
824 /**
825 * Register a console command that takes arguments
826 *
827 * @param Name The name of this command (must not be nullptr)
828 * @param Help Help text for this command
829 * @param Command The user function to call when this command is executed
830 * @param Flags Optional flags bitmask
831 */
832 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldDelegate& Command, uint32 Flags = ECVF_Default) = 0;
833
834 /**
835 * Register a console command that takes arguments
836 *
837 * @param Name The name of this command (must not be nullptr)
838 * @param Help Help text for this command
839 * @param Command The user function to call when this command is executed
840 * @param Flags Optional flags bitmask
841 */
842 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldAndArgsDelegate& Command, uint32 Flags = ECVF_Default) = 0;
843
844 /**
845 * Register a console command that takes arguments
846 *
847 * @param Name The name of this command (must not be nullptr)
848 * @param Help Help text for this command
849 * @param Command The user function to call when this command is executed
850 * @param Flags Optional flags bitmask
851 */
852 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default) = 0;
853
854 /**
855 * Register a console command that takes arguments
856 *
857 * @param Name The name of this command (must not be nullptr)
858 * @param Help Help text for this command
859 * @param Command The user function to call when this command is executed
860 * @param Flags Optional flags bitmask
861 */
862 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default) = 0;
863
864 /**
865 * Register a console command that takes arguments
866 *
867 * @param Name The name of this command (must not be nullptr)
868 * @param Help Help text for this command
869 * @param Command The user function to call when this command is executed
870 * @param Flags Optional flags bitmask
871 */
872 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default) = 0;
873
874 /**
875 * Register a console command that is handles by an Exec functions (for auto completion)
876 *
877 * @param Name The name of this command (must not be nullptr)
878 * @param Help Help text for this command
879 * @param Flags Optional flags bitmask
880 */
881 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, uint32 Flags = (uint32)ECVF_Default) = 0;
882
883 /**
884 * Unregisters a console object, if that object was registered. O(n), n is the console object count
885 *
886 * @param ConsoleObject - object to remove
887 * @param bKeepState if the current state is kept in memory until a cvar with the same name is registered
888 */
889 virtual void UnregisterConsoleObject( IConsoleObject* ConsoleObject, bool bKeepState = true) = 0;
890
891 /**
892 * Unregisters a console variable or command by name, if an object of that name was registered.
893 *
894 * @param Name - name of object to remove
895 * @param bKeepState if the current state is kept in memory until a cvar with the same name is registered
896 */
897 virtual void UnregisterConsoleObject(const TCHAR* Name, bool bKeepState = true) = 0;
898
899 /**
900 * Find a console variable
901 * @param Name must not be 0
902 * @return 0 if the object wasn't found
903 */
904 virtual IConsoleVariable* FindConsoleVariable(const TCHAR* Name, bool bTrackFrequentCalls = true) const = 0;
905
906 /**
907 * Find a console variable or command
908 * @param Name must not be 0
909 * @return 0 if the object wasn't found
910 */
911 virtual IConsoleObject* FindConsoleObject(const TCHAR* Name, bool bTrackFrequentCalls = true) const = 0;
912
913 /**
914 * Lookup the name of a console object by its pointer
915 * @param Object to lookup
916 * @return Name of the object, or an empty string if the object can't be found
917 */
918 virtual FString FindConsoleObjectName(const IConsoleObject* Obj) const = 0;
919
920 /**
921 * Find a typed console variable (faster access to the value, no virtual function call)
922 * @param Name must not be 0
923 * @return 0 if the object wasn't found
924 */
925 TConsoleVariableData<bool>* FindTConsoleVariableDataBool(const TCHAR* Name) const
926 {
928
929 return P ? P->AsVariableBool() : 0;
930 }
931
932 /**
933 * Find a typed console variable (faster access to the value, no virtual function call)
934 * @param Name must not be 0
935 * @return 0 if the object wasn't found
936 */
937 TConsoleVariableData<int32>* FindTConsoleVariableDataInt(const TCHAR* Name) const
938 {
940
941 return P ? P->AsVariableInt() : 0;
942 }
943
944 /**
945 * Find a typed console variable (faster access to the value, no virtual function call)
946 * @param Name must not be 0
947 * @return 0 if the object wasn't found
948 */
949 TConsoleVariableData<float>* FindTConsoleVariableDataFloat(const TCHAR* Name) const
950 {
952
953 return P ? P->AsVariableFloat() : 0;
954 }
955
956
957 /**
958 * Iterate in O(n), not case sensitive, does not guarantee that UnregisterConsoleObject() will work in the loop
959 * @param Visitor must not be 0
960 * @param ThatStartsWith must not be 0
961 */
962 virtual void ForEachConsoleObjectThatStartsWith( const FConsoleObjectVisitor& Visitor, const TCHAR* ThatStartsWith = TEXT("")) const = 0;
963
964 /**
965 * Not case sensitive, does not guarantee that UnregisterConsoleObject() will work in the loop
966 * @param Visitor must not be 0
967 * @param ThatContains must not be 0
968 */
969 virtual void ForEachConsoleObjectThatContains(const FConsoleObjectVisitor& Visitor, const TCHAR* ThatContains) const = 0;
970
971 /**
972 * Process user input
973 * e.g.
974 * "MyCVar" to get the current value of the console variable
975 * "MyCVar -5.2" to set the value to -5.2
976 * "MyCVar ?" to get the help text
977 * @param Input must not be 0
978 * @param Ar archive
979 * @param InWorld world context
980 * @return true if the command was recognized
981 */
982 virtual bool ProcessUserConsoleInput(const TCHAR* Input, FOutputDevice& Ar, UWorld* InWorld) = 0;
983
984 /**
985 * @param Input - must not be 0
986 */
987 virtual void AddConsoleHistoryEntry(const TCHAR* Key, const TCHAR* Input) = 0;
988
989 /**
990 */
991 virtual void GetConsoleHistory(const TCHAR* Key, TArray<FString>& Out) = 0;
992
993 /**
994 * Check if a name (command or variable) has been registered with the console manager
995 * @param Name - Name to check. Must not be 0
996 */
997 virtual bool IsNameRegistered(const TCHAR* Name) const = 0;
998
999 // currently only for render thread
1000 // @param InCallback 0 to disable the callbacks
1001 virtual void RegisterThreadPropagation(uint32 ThreadId = 0, IConsoleThreadPropagation* InCallback = 0) = 0;
1002
1003 /** Returns the singleton for the console manager **/
1005 {
1006 if (!Singleton)
1007 {
1009 check(Singleton != nullptr);
1010 }
1011 return *Singleton;
1012 }
1013
1015 /**
1016 * Walks over the best set of ini sections for another platform that can be used to emulate cvars as the platform
1017 * will have set - WITH THE NOTABLE EXCEPTION OF specific DeviceProfiles. Use the DeviceProfileManager code to get a DP
1018 * for a platform, as this code cannot easily access DeviceProfile logic.
1019 * It also won't include any UserSettings or ConsoleVariables.ini settings.
1020 *
1021 * @param PlatformName The platform name (the ini name, so Windows, not Win64)
1022 * @param DeviceProfileName If this is non-empty, the given deviceprofile will be loaded from the platform's inis and inserted into the CVars
1023 * @param Visit the callback to run for each CVar found
1024 */
1026#endif
1027
1028 virtual FConsoleVariableMulticastDelegate& OnCVarUnregistered() = 0;
1029
1030protected:
1031 virtual ~IConsoleManager() { }
1032
1033private:
1034 /** Singleton for the console manager **/
1036
1037 /** Function to create the singleton **/
1038 static void SetupSingleton();
1039};
1040
1041
1042/**
1043 * auto registering console variable sinks (register a callback function that is called when ever a cvar is changes by the user, changes are grouped and happen in specific engine spots during the frame/main loop)
1044 */
1046{
1047public:
1048 /** Constructor, saves the argument for future removal from the console variable system **/
1049 FAutoConsoleVariableSink(const FConsoleCommandDelegate& InCommand)
1050 : Command(InCommand)
1051 {
1053 }
1054 /** Destructor, removes the console variable sink **/
1056 {
1057//disabled for now, destruction order makes this not always working IConsoleManager::Get().UnregisterConsoleVariableSink_Handle(Handle);
1058 }
1059
1060 const FConsoleCommandDelegate& Command;
1062};
1063
1064
1065/**
1066 * Base class for autoregistering console commands.
1067 */
1069{
1070protected:
1071 /** Constructor, saves the argument for future removal from the console variable system **/
1073 : Target(InTarget)
1074 {
1075 check(Target);
1077 {
1078 AccessGeneralShaderChangeCvars().Add(this);
1079 }
1081 {
1082 AccessMobileShaderChangeCvars().Add(this);
1083 }
1085 {
1086 AccessDesktopShaderChangeCvars().Add(this);
1087 }
1088 }
1089public:
1090 /** Destructor, removes the console object **/
1092 {
1094 }
1095
1099
1100 /** returns the contained console object as an IConsoleVariable **/
1102 {
1103 checkSlow(Target->AsVariable());
1104 return static_cast<IConsoleVariable*>(Target);
1105 }
1106 /** returns the contained console object as an IConsoleVariable **/
1108 {
1109 checkSlow(Target->AsVariable());
1110 return static_cast<const IConsoleVariable*>(Target);
1111 }
1112
1113private:
1114 /** Contained console object, cannot be 0 **/
1116};
1117
1118#if !NO_CVARS
1119/**
1120 * Autoregistering float, int or string console variable
1121 */
1123{
1124public:
1125 /**
1126 * Create a bool console variable
1127 * @param Name must not be 0
1128 * @param Help must not be 0
1129 * @param Flags bitmask combined from EConsoleVariableFlags
1130 */
1131 FAutoConsoleVariable(const TCHAR* Name, bool DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1133 {
1134 }
1135 /**
1136 * Create a int console variable
1137 * @param Name must not be 0
1138 * @param Help must not be 0
1139 * @param Flags bitmask combined from EConsoleVariableFlags
1140 */
1141 FAutoConsoleVariable(const TCHAR* Name, int32 DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1143 {
1144 }
1145 /**
1146 * Create a float console variable
1147 * @param Name must not be 0
1148 * @param Help must not be 0
1149 * @param Flags bitmask combined from EConsoleVariableFlags
1150 */
1151 FAutoConsoleVariable(const TCHAR* Name, float DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1153 {
1154 }
1155 /**
1156 * Create a string console variable
1157 * @param Name must not be 0
1158 * @param Help must not be 0
1159 * @param Flags bitmask combined from EConsoleVariableFlags
1160 */
1161 FAutoConsoleVariable(const TCHAR* Name, const TCHAR* DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1163 {
1164 }
1165
1166 /**
1167 * Create a bool console variable
1168 * @param Name must not be 0
1169 * @param Help must not be 0
1170 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1171 * @param Flags bitmask combined from EConsoleVariableFlags
1172 */
1173 FAutoConsoleVariable(const TCHAR* Name, bool DefaultValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1175 {
1177 }
1178
1179 /**
1180 * Create a int console variable
1181 * @param Name must not be 0
1182 * @param Help must not be 0
1183 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1184 * @param Flags bitmask combined from EConsoleVariableFlags
1185 */
1186 FAutoConsoleVariable(const TCHAR* Name, int32 DefaultValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1188 {
1190 }
1191
1192 /**
1193 * Create a float console variable
1194 * @param Name must not be 0
1195 * @param Help must not be 0
1196 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1197 * @param Flags bitmask combined from EConsoleVariableFlags
1198 */
1199 FAutoConsoleVariable(const TCHAR* Name, float DefaultValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1201 {
1203 }
1204
1205 /**
1206 * Create a string console variable
1207 * @param Name must not be 0
1208 * @param Help must not be 0
1209 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1210 * @param Flags bitmask combined from EConsoleVariableFlags
1211 */
1212 FAutoConsoleVariable(const TCHAR* Name, const TCHAR* DefaultValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1214 {
1216 }
1217
1218 /** Dereference back to a console variable**/
1220 {
1221 return *AsVariable();
1222 }
1224 {
1225 return *AsVariable();
1226 }
1227 /** Dereference back to a console variable**/
1229 {
1230 return AsVariable();
1231 }
1233 {
1234 return AsVariable();
1235 }
1236};
1237#else
1238class FAutoConsoleVariable
1239{
1240public:
1241 FAutoConsoleVariable(const TCHAR* Name, int32 DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1242 {
1243 }
1244
1245 FAutoConsoleVariable(const TCHAR* Name, float DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1246 {
1247 }
1248
1249 FAutoConsoleVariable(const TCHAR* Name, const TCHAR* DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1250 {
1251 }
1252};
1253#endif
1254
1255#if !NO_CVARS
1256/**
1257 * Autoregistering float, int, bool, FString REF variable class...this changes that value when the console variable is changed.
1258 */
1260{
1261public:
1262 /**
1263 * Create a reference to a int console variable
1264 * @param Name must not be 0
1265 * @param Help must not be 0
1266 * @param Flags bitmask combined from EConsoleVariableFlags
1267 */
1268 FAutoConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1270 {
1271 }
1272 /**
1273 * Create a reference to a float console variable
1274 * @param Name must not be 0
1275 * @param Help must not be 0
1276 * @param Flags bitmask combined from EConsoleVariableFlags
1277 */
1278 FAutoConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1280 {
1281 }
1282 /**
1283 * Create a reference to a bool console variable
1284 * @param Name must not be 0
1285 * @param Help must not be 0
1286 * @param Flags bitmask combined from EConsoleVariableFlags
1287 */
1288 FAutoConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1290 {
1291 }
1292 /**
1293 * Create a reference to a FString console variable
1294 * @param Name must not be 0
1295 * @param Help must not be 0
1296 * @param Flags bitmask combined from EConsoleVariableFlags
1297 */
1298 FAutoConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1300 {
1301 }
1302
1303 /**
1304 * Create a reference to a int console variable
1305 * @param Name must not be 0
1306 * @param Help must not be 0
1307 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1308 * @param Flags bitmask combined from EConsoleVariableFlags
1309 */
1310 FAutoConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1312 {
1314 }
1315
1316 /**
1317 * Create a reference to a float console variable
1318 * @param Name must not be 0
1319 * @param Help must not be 0
1320 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1321 * @param Flags bitmask combined from EConsoleVariableFlags
1322 */
1323 FAutoConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1325 {
1327 }
1328
1329 /**
1330 * Create a reference to a bool console variable
1331 * @param Name must not be 0
1332 * @param Help must not be 0
1333 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1334 * @param Flags bitmask combined from EConsoleVariableFlags
1335 */
1336 FAutoConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1338 {
1340 }
1341
1342 /**
1343 * Create a reference to a FString console variable
1344 * @param Name must not be 0
1345 * @param Help must not be 0
1346 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1347 * @param Flags bitmask combined from EConsoleVariableFlags
1348 */
1349 FAutoConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1351 {
1353 }
1354
1356 {
1357 }
1358 /** Dereference back to a variable**/
1360 {
1361 return *AsVariable();
1362 }
1364 {
1365 return *AsVariable();
1366 }
1367 /** Dereference back to a variable**/
1369 {
1370 return AsVariable();
1371 }
1373 {
1374 return AsVariable();
1375 }
1376};
1377#else
1378class FAutoConsoleVariableRef
1379{
1380public:
1381 FAutoConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1382 {
1383 }
1384
1385 FAutoConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1386 {
1387 }
1388
1389 FAutoConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1390 {
1391 }
1392
1393 FAutoConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, uint32 Flags = ECVF_Default)
1394 {
1395 }
1396
1397 FAutoConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1398 {
1399 }
1400
1401 FAutoConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1402 {
1403 }
1404
1405 FAutoConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1406 {
1407 }
1408
1409 FAutoConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1410 {
1411 }
1412};
1413#endif // NO_CVARS
1414
1415
1416// currently only supports main and render thread
1417// optimized for read access speed (no virtual function call and no thread handling if using the right functions)
1418// T: int32, float
1419template <class T>
1420class TConsoleVariableData
1421{
1422public:
1423 // constructor
1424 TConsoleVariableData(const T DefaultValue)
1425 {
1426 for(uint32 i = 0; i < UE_ARRAY_COUNT(ShadowedValue); ++i)
1427 {
1428 ShadowedValue[i] = DefaultValue;
1429 }
1430 }
1431
1432 // faster than GetValueOnAnyThread()
1434 {
1435 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::CVar);
1436 // compiled out in shipping for performance (we can change in development later), if this get triggered you need to call GetValueOnRenderThread() or GetValueOnAnyThread(), the last one is a bit slower
1437 cvarCheckCode(ensure(GetShadowIndex() == 0)); // ensure to not block content creators, #if to optimize in shipping
1438 return ShadowedValue[0];
1439 }
1440
1441 // faster than GetValueOnAnyThread()
1443 {
1444 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::CVar);
1445#if !defined(__clang__) // @todo Mac: figure out how to make this compile
1446 // compiled out in shipping for performance (we can change in development later), if this get triggered you need to call GetValueOnGameThread() or GetValueOnAnyThread(), the last one is a bit slower
1447 cvarCheckCode(ensure(IsInParallelRenderingThread())); // ensure to not block content creators, #if to optimize in shipping
1448#endif
1449 return ShadowedValue[1];
1450 }
1451
1452 // convenient, for better performance consider using GetValueOnGameThread() or GetValueOnRenderThread()
1453 T GetValueOnAnyThread(bool bForceGameThread = false) const
1454 {
1455 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::CVar);
1456 return ShadowedValue[GetShadowIndex(bForceGameThread)];
1457 }
1458
1459private: // ----------------------------------------------------
1460
1461 // [0]:main thread, [1]: render thread, having them both in the same cache line should only hurt on write which happens rarely for cvars
1463
1464 // @return 0:main thread, 1: render thread, later more
1465 static uint32 GetShadowIndex(bool bForceGameThread = false)
1466 {
1467 if (bForceGameThread)
1468 {
1469 cvarCheckCode(ensure(!IsInActualRenderingThread()));
1470 return 0;
1471 }
1472 return IsInParallelGameThread() || IsInGameThread() ? 0 : 1;
1473 }
1474
1475 // needed for FConsoleVariable and FConsoleVariableRef2, intentionally not public
1476 T& GetReferenceOnAnyThread(bool bForceGameThread = false)
1477 {
1478 UE::AccessDetection::ReportAccess(UE::AccessDetection::EType::CVar);
1479 return ShadowedValue[GetShadowIndex(bForceGameThread)];
1480 }
1481
1482 template<class T2> friend class FConsoleVariable;
1483 template<class T2> friend class TAutoConsoleVariable;
1484};
1485
1486#if !NO_CVARS
1487/**
1488 * Autoregistering float, int variable class...this changes that value when the console variable is changed.
1489 */
1490template <class T>
1492{
1493public:
1494 /**
1495 * Create a float, int or string console variable
1496 * @param Name must not be 0
1497 * @param Help must not be 0
1498 * @param Flags bitmask combined from EConsoleVariableFlags
1499 */
1500 TAutoConsoleVariable(const TCHAR* Name, const T& DefaultValue, const TCHAR* Help, uint32 Flags = ECVF_Default);
1501
1502 /**
1503 * Create a float, int or string console variable
1504 * @param Name must not be 0
1505 * @param Help must not be 0
1506 * @param Callback Delegate called when the variable changes. @see IConsoleVariable::SetOnChangedCallback
1507 * @param Flags bitmask combined from EConsoleVariableFlags
1508 */
1509 TAutoConsoleVariable(const TCHAR* Name, const T& DefaultValue, const TCHAR* Help, const FConsoleVariableDelegate& Callback, uint32 Flags = ECVF_Default)
1511 {
1513 }
1514
1516 {
1517 return Ref->GetValueOnGameThread();
1518 }
1519
1521 {
1522 return Ref->GetValueOnRenderThread();
1523 }
1524
1525 T GetValueOnAnyThread(bool bForceGameThread = false) const
1526 {
1528 }
1529
1530 /** Dereference back to a variable**/
1532 {
1533 return *AsVariable();
1534 }
1536 {
1537 return *AsVariable();
1538 }
1539 /** Dereference back to a variable**/
1541 {
1542 return AsVariable();
1543 }
1545 {
1546 return AsVariable();
1547 }
1548private:
1549 TConsoleVariableData<T>* Ref;
1550};
1551
1552template <>
1553inline TAutoConsoleVariable<bool>::TAutoConsoleVariable(const TCHAR* Name, const bool& DefaultValue, const TCHAR* Help, uint32 Flags)
1554 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleVariable(Name, DefaultValue, Help, Flags))
1555{
1556 Ref = AsVariable()->AsVariableBool();
1557}
1558
1559template <>
1560inline TAutoConsoleVariable<int32>::TAutoConsoleVariable(const TCHAR* Name, const int32& DefaultValue, const TCHAR* Help, uint32 Flags)
1561 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleVariable(Name, DefaultValue, Help, Flags))
1562{
1563 Ref = AsVariable()->AsVariableInt();
1564}
1565
1566template <>
1567inline TAutoConsoleVariable<float>::TAutoConsoleVariable(const TCHAR* Name, const float& DefaultValue, const TCHAR* Help, uint32 Flags)
1568 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleVariable(Name, DefaultValue, Help, Flags))
1569{
1570 Ref = AsVariable()->AsVariableFloat();
1571}
1572
1573template <>
1574inline TAutoConsoleVariable<FString>::TAutoConsoleVariable(const TCHAR* Name, const FString& DefaultValue, const TCHAR* Help, uint32 Flags)
1575 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleVariable(Name, DefaultValue, Help, Flags))
1576{
1577 Ref = AsVariable()->AsVariableString();
1578}
1579#else
1580template <class T>
1581class TAutoConsoleVariable : public IConsoleVariable
1582{
1583public:
1584 TAutoConsoleVariable(const TCHAR* Name, const T& DefaultValue, const TCHAR* InHelp, uint32 InFlags = ECVF_Default)
1585 : Value(DefaultValue), Flags((EConsoleVariableFlags)InFlags)
1586 {
1587 }
1588
1589 T GetValueOnGameThread() const
1590 {
1591 return Value.GetValueOnGameThread();
1592 }
1593
1594 T GetValueOnRenderThread() const
1595 {
1596 return Value.GetValueOnRenderThread();
1597 }
1598
1599 T GetValueOnAnyThread(bool bForceGameThread = false) const
1600 {
1601 return Value.GetValueOnAnyThread(bForceGameThread);
1602 }
1603
1604 IConsoleVariable& operator*()
1605 {
1606 return *AsVariable();
1607 }
1608
1609 const IConsoleVariable& operator*() const
1610 {
1611 return *AsVariable();
1612 }
1613
1614 IConsoleVariable* operator->()
1615 {
1616 return AsVariable();
1617 }
1618
1619 const IConsoleVariable* operator->() const
1620 {
1621 return AsVariable();
1622 }
1623
1624 IConsoleVariable* AsVariable() { return this; }
1625 const IConsoleVariable* AsVariable() const { return this; }
1626
1627 virtual class TConsoleVariableData<int32>* AsVariableInt() override { return AsImpl<int32>(); }
1628 virtual class TConsoleVariableData<float>* AsVariableFloat() override { return AsImpl<float>(); }
1629 virtual class TConsoleVariableData<FString>* AsVariableString() override { return AsImpl<FString>(); }
1630
1631 virtual bool IsVariableInt() const override { return std::is_same_v<int32, T>; }
1632 virtual int32 GetInt() const override { return GetImpl<int32>(); }
1633 virtual float GetFloat() const override { return GetImpl<float>(); }
1634 virtual FString GetString() const override { return GetImpl<FString>(); }
1635 virtual bool GetBool() const override { return GetImpl<bool>(); }
1636
1637 virtual const TCHAR* GetHelp() const override
1638 {
1639 return TEXT("NO_CVARS, no help");
1640 }
1641
1642 virtual void SetHelp(const TCHAR* InHelp) override
1643 {
1644 check(false);
1645 }
1646
1647 virtual void Release() override
1648 {
1649 check(false);
1650 }
1651
1652 virtual void SetOnChangedCallback(const FConsoleVariableDelegate &) override
1653 {
1654 check(false);
1655 }
1656
1657 virtual FConsoleVariableMulticastDelegate& OnChangedDelegate()override
1658 {
1659 static FConsoleVariableMulticastDelegate Dummy;
1660 check(false);
1661 return Dummy;
1662 }
1663
1664 virtual EConsoleVariableFlags GetFlags() const override
1665 {
1666 return Flags;
1667 }
1668
1669 virtual void SetFlags(const EConsoleVariableFlags InFlags) override
1670 {
1671 Flags = InFlags;
1672 }
1673
1674 virtual void Set(const TCHAR* InValue, EConsoleVariableFlags SetBy) override
1675 {
1676 LexFromString(Value.ShadowedValue[0], InValue);
1677 }
1678
1679private:
1680 TConsoleVariableData<T> Value;
1681 FString Help;
1682 EConsoleVariableFlags Flags = EConsoleVariableFlags::ECVF_Default;
1683
1684 template<class Y>
1685 typename TEnableIf<!std::is_same_v<T, Y>, Y>::Type GetImpl() const
1686 {
1687 check(false);
1688 return Y();
1689 }
1690
1691 template<class Y>
1692 typename TEnableIf<std::is_same_v<T, Y>, Y>::Type GetImpl() const
1693 {
1694 return GetValueOnAnyThread();
1695 }
1696
1697 template<class Y>
1698 typename TEnableIf<!std::is_same_v<T, Y>, TConsoleVariableData<Y>*>::Type AsImpl()
1699 {
1700 check(false);
1701 return nullptr;
1702 }
1703
1704 template<class Y>
1705 typename TEnableIf<std::is_same_v<T, Y>, TConsoleVariableData<T>*>::Type AsImpl()
1706 {
1707 return &Value;
1708 }
1709};
1710#endif // NO_CVARS
1711
1712#if !NO_CVARS
1713/**
1714 * Autoregistering console command
1715 */
1716class FAutoConsoleCommand : private FAutoConsoleObject
1717{
1718public:
1719 /**
1720 * Register a console command that takes no arguments
1721 *
1722 * @param Name The name of this command (must not be nullptr)
1723 * @param Help Help text for this command
1724 * @param Command The user function to call when this command is executed
1725 * @param Flags Optional flags bitmask
1726 */
1727 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandDelegate& Command, uint32 Flags = ECVF_Default)
1728 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleCommand(Name, Help, Command, Flags))
1729 {
1730 }
1731
1732 /**
1733 * Register a console command that takes arguments
1734 *
1735 * @param Name The name of this command (must not be nullptr)
1736 * @param Help Help text for this command
1737 * @param Command The user function to call when this command is executed
1738 * @param Flags Optional flags bitmask
1739 */
1740 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command, uint32 Flags = ECVF_Default)
1741 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleCommand(Name, Help, Command, Flags))
1742 {
1743 }
1744
1745 /**
1746 * Register a console command that takes arguments, a world argument and an output device
1747 *
1748 * @param Name The name of this command (must not be nullptr)
1749 * @param Help Help text for this command
1750 * @param Command The user function to call when this command is executed
1751 * @param Flags Optional flags bitmask
1752 */
1753 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default)
1754 : FAutoConsoleObject(IConsoleManager::Get().RegisterConsoleCommand(Name, Help, Command, Flags))
1755 {
1756 }
1757};
1758#else
1759class FAutoConsoleCommand
1760{
1761public:
1762 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandDelegate& Command, uint32 Flags = ECVF_Default)
1763 {
1764 }
1765
1766 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command, uint32 Flags = ECVF_Default)
1767 {
1768 }
1769
1770 FAutoConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default)
1771 {
1772 }
1773};
1774#endif
1775
1776
1777#if !NO_CVARS
1778/**
1779 * Autoregistering console command with a world
1780 */
1782{
1783public:
1784 /**
1785 * Register a console command that takes a world argument
1786 *
1787 * @param Name The name of this command (must not be nullptr)
1788 * @param Help Help text for this command
1789 * @param Command The user function to call when this command is executed
1790 * @param Flags Optional flags bitmask
1791 */
1792 FAutoConsoleCommandWithWorld(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldDelegate& Command, uint32 Flags = ECVF_Default)
1794 {
1795 }
1796
1797
1798};
1799
1800/**
1801 * Autoregistering console command with a world and arguments
1802 */
1804{
1805public:
1806 /**
1807 * Register a console command that takes arguments and a world argument
1808 *
1809 * @param Name The name of this command (must not be nullptr)
1810 * @param Help Help text for this command
1811 * @param Command The user function to call when this command is executed
1812 * @param Flags Optional flags bitmask
1813 */
1814 FAutoConsoleCommandWithWorldAndArgs(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldAndArgsDelegate& Command, uint32 Flags = ECVF_Default)
1816 {
1817 }
1818};
1819
1820/**
1821 * Autoregistering console command with args and an output device
1822 */
1824{
1825public:
1826
1827 FAutoConsoleCommandWithArgsAndOutputDevice(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default)
1829 {
1830 }
1831};
1832
1833/**
1834 * Autoregistering console command with an output device
1835 */
1837{
1838public:
1839 /**
1840 * Register a console command that takes an output device
1841 *
1842 * @param Name The name of this command (must not be nullptr)
1843 * @param Help Help text for this command
1844 * @param Command The user function to call when this command is executed
1845 * @param Flags Optional flags bitmask
1846 */
1847 FAutoConsoleCommandWithOutputDevice(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default)
1849 {
1850 }
1851};
1852
1853/**
1854 * Autoregistering console command with world, args, an output device
1855 */
1857{
1858public:
1859 /**
1860 * Register a console command that takes an output device
1861 *
1862 * @param Name The name of this command (must not be nullptr)
1863 * @param Help Help text for this command
1864 * @param Command The user function to call when this command is executed
1865 * @param Flags Optional flags bitmask
1866 */
1867 FAutoConsoleCommandWithWorldArgsAndOutputDevice(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate& Command, uint32 Flags = ECVF_Default)
1869 {
1870 }
1871};
1872
1873#else
1874
1875class FAutoConsoleCommandWithWorld
1876{
1877public:
1878 template<class... Args> FAutoConsoleCommandWithWorld(const Args&...) {}
1879};
1880
1881class FAutoConsoleCommandWithWorldAndArgs
1882{
1883public:
1884 template<class... Args> FAutoConsoleCommandWithWorldAndArgs(const Args&...) {}
1885};
1886
1887class FAutoConsoleCommandWithOutputDevice
1888{
1889public:
1890 template<class... Args> FAutoConsoleCommandWithOutputDevice(const Args&...) {}
1891};
1892
1893class FAutoConsoleCommandWithWorldArgsAndOutputDevice
1894{
1895public:
1896 template<class... Args> FAutoConsoleCommandWithWorldArgsAndOutputDevice(const Args&...) {}
1897};
1898
1899#endif
1900
#define checkSlow(expr)
#define check(expr)
#define ensureMsgf( InExpression, InFormat,...)
#define UE_BUILD_TEST
Definition Build.h:23
#define DO_CHECK
Definition Build.h:311
#define UE_BUILD_SHIPPING
Definition Build.h:4
#define ALLOW_OTHER_PLATFORM_CONFIG
Definition Build.h:479
#define NO_CVARS
Definition CoreDefines.h:66
#define DECLARE_DELEGATE(DelegateName)
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
#define DECLARE_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
EConsoleVariableFlags
Definition Enums.h:5137
DECLARE_LOG_CATEGORY_EXTERN(LogChunkInstaller, Log, All)
#define TRACK_CONSOLE_FIND_COUNT
@ ECVF_SetByGameOverride
@ ECVF_Preview
@ ECVF_DesktopShaderChange
@ ECVF_SetByDeviceProfile
@ ECVF_ExcludeFromPreview
@ ECVF_Scalability
@ ECVF_Default
@ ECVF_RenderThreadSafe
@ ECVF_SetBySystemSettingsIni
@ ECVF_SetFlagMask
@ ECVF_SetByConstructor
@ ECVF_FlagMask
@ ECVF_GeneralShaderChange
@ ECVF_SetByCode
@ ECVF_SetByScalability
@ ECVF_SetByGameSetting
@ ECVF_SetByConsole
@ ECVF_MobileShaderChange
@ ECVF_SetByConsoleVariablesIni
@ ECVF_Unregistered
@ ECVF_SetByMask
@ ECVF_CreatedFromIni
@ ECVF_Cheat
@ ECVF_ReadOnly
@ ECVF_ScalabilityGroup
@ ECVF_SetByProjectSetting
@ ECVF_SetByCommandline
@ ECVF_Set_NoSinkCall_Unsafe
#define cvarCheckCode(...)
#define TEXT(x)
Definition Platform.h:1108
#define FORCEINLINE
Definition Platform.h:644
#define UE_ARRAY_COUNT(array)
FAutoConsoleCommandWithArgsAndOutputDevice(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandWithArgsAndOutputDeviceDelegate &Command, uint32 Flags=ECVF_Default)
FAutoConsoleCommandWithOutputDevice(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandWithOutputDeviceDelegate &Command, uint32 Flags=ECVF_Default)
FAutoConsoleCommandWithWorldAndArgs(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandWithWorldAndArgsDelegate &Command, uint32 Flags=ECVF_Default)
FAutoConsoleCommandWithWorldArgsAndOutputDevice(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate &Command, uint32 Flags=ECVF_Default)
FAutoConsoleCommandWithWorld(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandWithWorldDelegate &Command, uint32 Flags=ECVF_Default)
FAutoConsoleObject(IConsoleObject *InTarget)
FORCEINLINE IConsoleVariable * AsVariable()
IConsoleObject * Target
static TArray< const FAutoConsoleObject * > & AccessGeneralShaderChangeCvars()
static TArray< const FAutoConsoleObject * > & AccessMobileShaderChangeCvars()
FORCEINLINE const IConsoleVariable * AsVariable() const
static TArray< const FAutoConsoleObject * > & AccessDesktopShaderChangeCvars()
FORCEINLINE IConsoleVariable & operator*()
FAutoConsoleVariable(const TCHAR *Name, bool DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, const TCHAR *DefaultValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, float DefaultValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FORCEINLINE IConsoleVariable * operator->()
FORCEINLINE const IConsoleVariable & operator*() const
FORCEINLINE const IConsoleVariable * operator->() const
FAutoConsoleVariable(const TCHAR *Name, bool DefaultValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, float DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, int32 DefaultValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, int32 DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FAutoConsoleVariable(const TCHAR *Name, const TCHAR *DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FORCEINLINE const IConsoleVariable * operator->() const
FAutoConsoleVariableRef(const TCHAR *Name, bool &RefValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariableRef(const TCHAR *Name, int32 &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FAutoConsoleVariableRef(const TCHAR *Name, float &RefValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariableRef(const TCHAR *Name, int32 &RefValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariableRef(const TCHAR *Name, FString &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FORCEINLINE IConsoleVariable & operator*()
FAutoConsoleVariableRef(const TCHAR *Name, float &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FORCEINLINE const IConsoleVariable & operator*() const
FORCEINLINE IConsoleVariable * operator->()
FAutoConsoleVariableRef(const TCHAR *Name, FString &RefValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FAutoConsoleVariableRef(const TCHAR *Name, bool &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
FConsoleVariableSinkHandle Handle
const FConsoleCommandDelegate & Command
FAutoConsoleVariableSink(const FConsoleCommandDelegate &InCommand)
FConsoleVariableSinkHandle(FDelegateHandle InHandle)
bool HasSameHandle(const DelegateType &Delegate) const
void RemoveFromDelegate(MulticastDelegateType &MulticastDelegate)
FString & operator=(FString &&)=default
UE_NODISCARD FORCEINLINE const TCHAR * operator*() const UE_LIFETIMEBOUND
Definition Text.h:357
virtual ~IConsoleCommandExecutor()=default
virtual FText GetDescription() const =0
virtual bool AllowHotKeyClose() const =0
static FName ModularFeatureName()
virtual struct FInputChord GetHotKey() const =0
virtual bool AllowMultiLine() const =0
virtual void GetAutoCompleteSuggestions(const TCHAR *Input, TArray< FString > &Out)=0
virtual FName GetName() const =0
virtual FText GetHintText() const =0
virtual void GetExecHistory(TArray< FString > &Out)=0
virtual FText GetDisplayName() const =0
virtual bool Exec(const TCHAR *Input)=0
virtual bool IsVariableBool() const
virtual void SetHelp(const TCHAR *Value)=0
virtual bool IsVariableFloat() const
virtual void Release()=0
virtual void SetFlags(const EConsoleVariableFlags Value)=0
virtual class TConsoleVariableData< bool > * AsVariableBool()
virtual class IConsoleVariable * AsVariable()
bool TestFlags(const EConsoleVariableFlags Value) const
virtual const TCHAR * GetHelp() const =0
virtual class TConsoleVariableData< FString > * AsVariableString()
void ClearFlags(const EConsoleVariableFlags Value)
virtual ~IConsoleObject()
virtual bool IsVariableString() const
virtual bool IsVariableInt() const
virtual class TConsoleVariableData< int32 > * AsVariableInt()
virtual EConsoleVariableFlags GetFlags() const =0
virtual class TConsoleVariableData< float > * AsVariableFloat()
virtual struct IConsoleCommand * AsCommand()
void GetValue(FString &OutStringValue)
void SetWithCurrentPriority(bool InValue)
virtual bool GetBool() const =0
void GetValue(float &OutFloatValue)
virtual FConsoleVariableMulticastDelegate & OnChangedDelegate()=0
void GetValue(bool &OutBoolValue)
virtual FString GetString() const =0
void GetValue(int32 &OutIntValue)
virtual IConsoleVariable * GetDefaultValueVariable()
virtual float GetFloat() const =0
void Set(int32 InValue, EConsoleVariableFlags SetBy=ECVF_SetByCode)
void SetWithCurrentPriority(const TCHAR *InValue)
void SetWithCurrentPriority(float InValue)
void Set(bool InValue, EConsoleVariableFlags SetBy=ECVF_SetByCode)
void SetWithCurrentPriority(int32 InValue)
void Set(float InValue, EConsoleVariableFlags SetBy=ECVF_SetByCode)
virtual void Set(const TCHAR *InValue, EConsoleVariableFlags SetBy=ECVF_SetByCode)=0
virtual void SetOnChangedCallback(const FConsoleVariableDelegate &Callback)=0
virtual int32 GetInt() const =0
FORCEINLINE const IConsoleVariable * operator->() const
T GetValueOnAnyThread(bool bForceGameThread=false) const
TAutoConsoleVariable(const TCHAR *Name, const T &DefaultValue, const TCHAR *Help, const FConsoleVariableDelegate &Callback, uint32 Flags=ECVF_Default)
FORCEINLINE IConsoleVariable * operator->()
TAutoConsoleVariable(const TCHAR *Name, const T &DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)
TConsoleVariableData< T > * Ref
FORCEINLINE const IConsoleVariable & operator*() const
FORCEINLINE IConsoleVariable & operator*()
T & GetReferenceOnAnyThread(bool bForceGameThread=false)
friend class FConsoleVariable
TConsoleVariableData(const T DefaultValue)
T GetValueOnAnyThread(bool bForceGameThread=false) const
static uint32 GetShadowIndex(bool bForceGameThread=false)
virtual bool Execute(const TArray< FString > &Args, UWorld *InWorld, class FOutputDevice &OutputDevice)=0
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, FString &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual IConsoleCommand * RegisterConsoleCommand(const TCHAR *Name, const TCHAR *Help, uint32 Flags=(uint32) ECVF_Default)=0
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, bool DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual FConsoleVariableMulticastDelegate & OnCVarUnregistered()=0
virtual void UnregisterConsoleVariableSink_Handle(FConsoleVariableSinkHandle Handle)=0
virtual IConsoleVariable * FindConsoleVariable(const TCHAR *Name, bool bTrackFrequentCalls=true) const =0
virtual bool ProcessUserConsoleInput(const TCHAR *Input, FOutputDevice &Ar, UWorld *InWorld)=0
virtual bool IsNameRegistered(const TCHAR *Name) const =0
static IConsoleManager * Singleton
TConsoleVariableData< bool > * FindTConsoleVariableDataBool(const TCHAR *Name) const
TConsoleVariableData< int32 > * FindTConsoleVariableDataInt(const TCHAR *Name) const
TConsoleVariableData< float > * FindTConsoleVariableDataFloat(const TCHAR *Name) const
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, bool &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual void UnregisterConsoleObject(const TCHAR *Name, bool bKeepState=true)=0
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, float &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual void GetConsoleHistory(const TCHAR *Key, TArray< FString > &Out)=0
virtual IConsoleObject * FindConsoleObject(const TCHAR *Name, bool bTrackFrequentCalls=true) const =0
virtual void CallAllConsoleVariableSinks()=0
virtual FString FindConsoleObjectName(const IConsoleObject *Obj) const =0
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, int32 DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, float DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
static FORCEINLINE IConsoleManager & Get()
static void SetupSingleton()
virtual IConsoleCommand * RegisterConsoleCommand(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandDelegate &Command, uint32 Flags=ECVF_Default)=0
virtual void ForEachConsoleObjectThatStartsWith(const FConsoleObjectVisitor &Visitor, const TCHAR *ThatStartsWith=TEXT("")) const =0
virtual void ForEachConsoleObjectThatContains(const FConsoleObjectVisitor &Visitor, const TCHAR *ThatContains) const =0
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, int32 &RefValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual void RegisterThreadPropagation(uint32 ThreadId=0, IConsoleThreadPropagation *InCallback=0)=0
virtual void AddConsoleHistoryEntry(const TCHAR *Key, const TCHAR *Input)=0
virtual IConsoleVariable * RegisterConsoleVariableBitRef(const TCHAR *CVarName, const TCHAR *FlagName, uint32 BitNumber, uint8 *Force0MaskPtr, uint8 *Force1MaskPtr, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, const TCHAR *DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual void UnregisterConsoleObject(IConsoleObject *ConsoleObject, bool bKeepState=true)=0
virtual ~IConsoleManager()
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, const FString &DefaultValue, const TCHAR *Help, uint32 Flags=ECVF_Default)=0
virtual FConsoleVariableSinkHandle RegisterConsoleVariableSink_Handle(const FConsoleCommandDelegate &Command)=0
virtual void OnCVarChange(FString &Dest, const FString &NewValue)=0
virtual void OnCVarChange(float &Dest, float NewValue)=0
virtual void OnCVarChange(int32 &Dest, int32 NewValue)=0
virtual void OnCVarChange(bool &Dest, bool NewValue)=0