Operating System Simulator Plugin  3.5.1
Unreal Engine plugin that simulates an Operating System Environment
Loading...
Searching...
No Matches
UOperatingSystemTerminal Class Reference

#include "OperatingSystemTerminal.h"

Inheritance diagram for UOperatingSystemTerminal:
[legend]
Collaboration diagram for UOperatingSystemTerminal:
[legend]

Public Member Functions

 UOperatingSystemTerminal ()
 
OPERATINGSYSTEMSIMULATOR_API void ProcessCommand (const FString &TestCommand, FGenericError &OutError)
 
bool ChangeCurrentPath (const FString &TargetPath)
 
void DestroyActiveCommand (const FGenericError &ErrorMessage)
 
void ChangeCurrentUser (const FOperatingSystemUser &NewUser)
 
OPERATINGSYSTEMSIMULATOR_API void PromptRootPassword ()
 
OPERATINGSYSTEMSIMULATOR_API void PromptUserContinue ()
 
OPERATINGSYSTEMSIMULATOR_API bool CheckRootPassword (const FText &TestPassword, const bool bCaseSensitive=true) const
 
void MessageReceivedFromCommand (const FText &CmdMsg, const EOperatingSystemTerminalMessageType &CmdMsgType)
 
OPERATINGSYSTEMSIMULATOR_API void VerifyUserPrompt (const bool bIsYes) const
 
OPERATINGSYSTEMSIMULATOR_API void ClearHistory ()
 
OPERATINGSYSTEMSIMULATOR_API bool HasRepository () const
 
OPERATINGSYSTEMSIMULATOR_API bool GetNextCommandFromHistory (FString &OutCommand) const
 
OPERATINGSYSTEMSIMULATOR_API bool GetPreviousCommandFromHistory (FString &OutCommand) const
 
OPERATINGSYSTEMSIMULATOR_API bool IsTerminalBusy () const
 Checks if the terminal is busy or not. A terminal is considered busy if there is an active command being executed.
 
FORCEINLINE bool ValidateFlags () const
 Gets the value of the bValidateFlags flag.
 
FORCEINLINE const TSet< FName > & GetCommandFlagPrefixes () const
 Returns the set of command flag prefixes.
 
FORCEINLINE FString GetMultiCommandOperatorString () const
 
- Public Member Functions inherited from UOperatingSystemBaseProgram
 UOperatingSystemBaseProgram ()
 
UOperatingSystemBaseProgramStartProgram (FGenericError &OutError)
 
bool IsRunning () const
 
bool CanAddToDesktop () const
 
UOperatingSystemGetOperatingSystem () const
 
UOperatingSystemProgramIconWidgetCreateIconWidget ()
 
UOperatingSystemProgramIconWidgetGetIconWidget () const
 
void OpenFile (UOperatingSystemFile *TargetFile, FGenericError &OutError)
 
void CloseProgram (const bool bIsFullClose, FGenericError &OutError)
 
void BringToFront (FGenericError &OutError) const
 
UDraggableWindowGetParentWindow () const
 
void IsCompatibleWithOS (const TWeakObjectPtr< const UOperatingSystem > TestOS, FGenericError &OutError) const
 
bool CanSaveSettings () const
 
void SetParentPartition (TWeakObjectPtr< UOperatingSystemPartition > OwningPartition)
 
void OnProgramWindowStateChanged (const EOperatingSystemProgramViewState &NewState) const
 
bool IsWindowMaximized () const
 Checks whether the window of the operating system base program is maximized.
 
virtual OPERATINGSYSTEMSIMULATOR_API FString GetSaveSlotName () const
 
TOptional< FVector2D > GetWindowPosition () const
 Retrieves the position of the window associated with the operating system program.
 
TWeakObjectPtr< UOperatingSystemPartitionGetParentPartition () const
 Get the parent partition of the current operating system program.
 
TSoftClassPtr< UOperatingSystemProgramIconWidgetGetIconWidgetClass () const
 Retrieves the class of the icon widget for the operating system program.
 
TSoftClassPtr< UOperatingSystemProgramWidgetGetWidgetClass () const
 Retrieves the widget class associated with the operating system base program. This method returns the widget class that should be used to create the program widget for the specific program.
 
TSoftClassPtr< UOperatingSystemProgramSettingsGetSettingsClass () const
 Get the settings class associated with this program. This method returns the class type of the settings object specific to this program.
 
TSoftClassPtr< UOperatingSystemProgramDataGetDataClass () const
 Retrieves the data class associated with the program.
 
TSoftClassPtr< UOperatingSystemTaskbarButtonGetTaskbarButtonClass () const
 Retrieves the taskbar button class associated with the program.
 
TWeakObjectPtr< UOperatingSystemProgramSettingsGetSettings () const
 Get the settings object for the program.
 
TWeakObjectPtr< UOperatingSystemProgramDataGetDataObj () const
 Retrieves the data object associated with the operating system program.
 
TWeakObjectPtr< UOperatingSystemTaskbarButtonGetTaskbarButton () const
 Retrieves the taskbar button associated with the program.
 
UOperatingSystemProgramWidgetGetProgramWidget () const
 Returns the program widget associated with the operating system program.
 
template<class T >
T * GetSettings () const
 Get the settings object of type T.
 
template<class T >
T * GetDataObj () const
 Returns the data object associated with the program.
 
FORCEINLINE FString GetProgramName () const
 Returns the program name as a FString.
 
FORCEINLINE FName GetIdentifier () const
 Returns the identifier of the program. The identifier serves as a unique identification for the program.
 
FORCEINLINE bool IsSingleInstanceProgram () const
 Returns a boolean value indicating whether the program is a single instance program. A single instance program is a program that allows only one instance to run at a time.
 
FORCEINLINE bool IsSystemInstalledProgram () const
 Returns a boolean value indicating whether the program is installed on the system. If the program is installed, it will return true; otherwise, it will return false.
 
FORCEINLINE uint32 GetProcessID () const
 Retrieves the process ID of the current program. This method allows you to obtain the unique process ID of the program.
 
FORCEINLINE float GetSpaceRequiredInMB () const
 Get the space required by the program in megabytes. This method returns the space required by the program in megabytes.
 
FORCEINLINE bool ShouldRememberLastWindowPosition () const
 Indicates whether the program should remember the last window position.
 
OPERATINGSYSTEMSIMULATOR_API FORCEINLINE EOperatingSystemProgramCloseMethod GetCloseMethod () const
 Returns the close method of the operating system program.
 

Protected Member Functions

virtual OPERATINGSYSTEMSIMULATOR_API void OnValidate (FGenericError &OutError) const override
 OnValidate method for validating program-specific logic.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnStart (FGenericError &OutError) override
 Called when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program.
 
UOperatingSystemTerminalCommandGetCommand (const FString &TestCommand, FGenericError &OutError) const
 
OPERATINGSYSTEMSIMULATOR_API bool GetCurrentDirectoryPath (FString &OutPath) const
 
void K2_CommandFinished (const FGenericError &ErrorMessage)
 
void K2_UserChanged ()
 
void K2_PromptRootPassword ()
 
void K2_PromptUserContinue ()
 
void K2_MessageReceivedFromCommand (const FText &CmdMsg, const EOperatingSystemTerminalMessageType &CmdMsgType)
 
- Protected Member Functions inherited from UOperatingSystemBaseProgram
virtual OPERATINGSYSTEMSIMULATOR_API void OnClose (FGenericError &OutError)
 Called when the program is requested to be closed. It can be overridden by derived classes to perform necessary cleanup operations before the program is closed. The function receives an FGenericError& object as a parameter, which can be used to report any error that occurred during the closing process.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnOpenFile (UOperatingSystemFile *TargetFile, FGenericError &OutError)
 Called when a file is opened in the operating system program. It provides the target file that was opened, as well as an output error parameter for reporting any errors that occurred during the file opening process.
 
virtual OPERATINGSYSTEMSIMULATOR_API void OnThemeChanged (UOperatingSystemSettingModule_Theme *ThemePayload)
 Virtual method called when the theme is changed.
 
void K2_OnCreate ()
 
void K2_OnInstall ()
 
FGenericError K2_OnStart ()
 
void K2_OnClose ()
 
void K2_OnSettingsLoad (UOperatingSystemProgramSettings *LoadedSettings)
 
void K2_OnOpenFile (FGenericError &OutError)
 
void K2_OnValidate (FGenericError &OutError) const
 
FString K2_GetSaveSlotName () const
 

Protected Attributes

TSoftObjectPtr< UOperatingSystemCmdCollectionCommandCollection
 
uint8 bSupportMultipleCommands: 1
 
FName MultiCommandOperator
 
TSet< FName > CommandFlagPrefixes
 
bool bValidateFlags
 
- Protected Attributes inherited from UOperatingSystemBaseProgram
FText Name
 
FText Author
 
FText Description
 
FName Identifier
 
FOperatingSystemVersion Version
 
FText StoreDisplayName
 
FText StoreType
 
float StorePrice
 
FGameplayTagContainer SupportedOperatingSystems
 
uint8 bRequireMinOperatingSystemVersion: 1
 
FOperatingSystemVersion MinOperatingSystemVersion
 
TSoftObjectPtr< UObject > IconObject
 
float SpaceRequiredInMB
 
TSoftClassPtr< UOperatingSystemProgramIconWidgetIconWidgetClass
 
TSoftClassPtr< UOperatingSystemProgramWidgetWidgetClass
 
EOperatingSystemProgramCloseMethod CloseMethod
 
EOperatingSystemProgramSaveMethod SaveMethod
 
TSoftClassPtr< UOperatingSystemProgramSettingsSettingsClass
 
TSoftClassPtr< UOperatingSystemProgramDataDataClass
 
uint8 bRequiresData: 1
 
uint8 bAddToDesktop: 1
 
uint8 bCreateNotification: 1
 
uint8 bSingleInstanceOnly: 1
 
uint8 bCanRunOnPortableDevice: 1
 
uint8 bCreateSettingsBeforeStarting: 1
 
uint8 bRememberLastWindowPosition: 1
 
uint8 bAllowDragging: 1
 
uint8 bAllowResizing: 1
 
uint8 bOverrideWindowSize: 1
 
FVector2D OverrideWindowSize
 
FVector2D MinimumWindowResize
 
EOperatingSystemWindowStartupState StartWindowState
 
TSoftClassPtr< UDraggableWindowOverrideWindowClass
 
TSoftClassPtr< UOperatingSystemTaskbarButtonTaskbarButtonClass
 
TWeakObjectPtr< UOperatingSystemPartitionParentPartition
 

Additional Inherited Members

- Static Public Member Functions inherited from UOperatingSystemBaseProgram
static UE_NODISCARD UOperatingSystemBaseProgramCreateProgram (TWeakObjectPtr< UOperatingSystem > OwningOS, const TSoftClassPtr< UOperatingSystemBaseProgram > &ProgramClass, FGenericError &OutError, const bool bInstalledWithOS=false)
 
static OPERATINGSYSTEMSIMULATOR_API bool IsStoreItemFree (const FOperatingSystemStoreProgramData &ProgramData)
 
- Public Attributes inherited from UOperatingSystemBaseProgram
FOnOperatingSystemProgramViewStateChanged OnOperatingSystemProgramViewStateChanged
 

Detailed Description

The UOperatingSystemTerminal class is a subclass of UOperatingSystemBaseProgram and represents a terminal in the Operating System. It allows users to execute commands and interact with the operating system.

Constructor & Destructor Documentation

◆ UOperatingSystemTerminal()

UOperatingSystemTerminal::UOperatingSystemTerminal ( )

Member Function Documentation

◆ ChangeCurrentPath()

bool UOperatingSystemTerminal::ChangeCurrentPath ( const FString & TargetPath)

Changes the current path to the specified target path.

Parameters
TargetPathThe target path to change to.
Returns
True if the current path was successfully changed, false otherwise.

◆ ChangeCurrentUser()

void UOperatingSystemTerminal::ChangeCurrentUser ( const FOperatingSystemUser & NewUser)

Changes the current user of the Operating System terminal.

This function changes the current user of the operating system terminal to the given user. If the given user is already the current user, the function returns without making any changes.

Parameters
NewUserThe new user to set as the current user.
Here is the call graph for this function:

◆ CheckRootPassword()

bool UOperatingSystemTerminal::CheckRootPassword ( const FText & TestPassword,
const bool bCaseSensitive = true ) const

This function checks if the provided password matches the password of the root user of the operating system. If the password matches, it will process the command as the root user.

Parameters
TestPasswordThe password to test against the root user's password.
bCaseSensitiveWhether the password comparison should be case-sensitive.
Returns
True if the provided password matches the root user's password and the command was processed as the root user, false otherwise.
See also
UOperatingSystemTerminal::GetOperatingSystem()
FOperatingSystem::GetRootUser()
UOperatingSystemTerminal::ActiveCommand
FTerminalCommand::ProcessCommandAsRoot()
Here is the call graph for this function:

◆ ClearHistory()

void UOperatingSystemTerminal::ClearHistory ( )

Clears the history of the operating system terminal.

◆ DestroyActiveCommand()

void UOperatingSystemTerminal::DestroyActiveCommand ( const FGenericError & ErrorMessage)

Destroys the active command and processes the next queued command (if any).

This function is called to destroy the active command and process the next command in the queue, if any. If the active command is a blueprint command, it calls the K2_CommandFinished function to notify the blueprint. Then, it marks the active command as garbage and sets it to nullptr. If there is no error message and there is a next command in the queue, it removes the next command from the queue and calls the ProcessCommand function to process it.

Parameters
ErrorMessageThe error message to pass to the K2_CommandFinished function, if applicable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCommand()

UOperatingSystemTerminalCommand * UOperatingSystemTerminal::GetCommand ( const FString & TestCommand,
FGenericError & OutError ) const
protected

Retrieves the command associated with the given test command string.

Parameters
TestCommandThe test command string to match with a command.
OutError[out] The error message if an error occurs.
Returns
The command associated with the test command string, or nullptr if no command is found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCommandFlagPrefixes()

FORCEINLINE const TSet< FName > & UOperatingSystemTerminal::GetCommandFlagPrefixes ( ) const
inline

Returns the set of command flag prefixes.

This method returns a reference to the set of command flag prefixes used in the operating system terminal. A command flag prefix is a character or string that is placed before a command parameter to indicate that it is a flag.

Returns
A reference to the set of command flag prefixes.

◆ GetCurrentDirectoryPath()

bool UOperatingSystemTerminal::GetCurrentDirectoryPath ( FString & OutPath) const
protected

Retrieves the current directory path and stores it in the provided output parameter.

Parameters
OutPath[out] The output parameter to store the current directory path.
Returns
True if the current directory path was successfully retrieved, false otherwise.

◆ GetMultiCommandOperatorString()

FORCEINLINE FString UOperatingSystemTerminal::GetMultiCommandOperatorString ( ) const
inline

Returns the multi-command operator string.

The GetMultiCommandOperatorString method returns the string representation of the multi-command operator. If the multi-command operator is set to None, the method returns the string " && ". Otherwise, it retrieves the string representation of the multi-command operator, removes any spaces, and formats it using the FString::Printf function with the format specifier "%s". The formatted string is then returned.

Returns
The multi-command operator string.
Here is the caller graph for this function:

◆ GetNextCommandFromHistory()

bool UOperatingSystemTerminal::GetNextCommandFromHistory ( FString & OutCommand) const

Retrieves the next command from the history of the operating system terminal.

Parameters
OutCommand[out] - The next command retrieved from the terminal history.
Returns
True if the retrieval is successful, false otherwise.
See also
GetPreviousCommandFromHistory

◆ GetPreviousCommandFromHistory()

bool UOperatingSystemTerminal::GetPreviousCommandFromHistory ( FString & OutCommand) const

Retrieves the previous command from the command history.

Parameters
OutCommand[out] - The output parameter that will contain the previous command if it exists
Returns
True if the previous command was successfully retrieved from the history, false otherwise.
See also
GetNextCommandFromHistory

◆ HasRepository()

bool UOperatingSystemTerminal::HasRepository ( ) const

Checks if the operating system terminal has a repository.

It will return true if there is at least one valid repository class, otherwise it will return false.

It first checks if the operating system is Unix. If it is, it retrieves the repository classes from the Unix operating system object. It then iterates through each repository class and checks if it is null. If at least one repository class is not null, the function returns true. If all repository classes are null or the operating system is not Unix, the function returns false.

Returns
True if the operating system terminal has at least one valid repository class, false otherwise.
Here is the call graph for this function:

◆ IsTerminalBusy()

bool UOperatingSystemTerminal::IsTerminalBusy ( ) const

Checks if the terminal is busy or not. A terminal is considered busy if there is an active command being executed.

Returns
true if the terminal is busy (there is an active command), false otherwise.
Here is the caller graph for this function:

◆ K2_CommandFinished()

void UOperatingSystemTerminal::K2_CommandFinished ( const FGenericError & ErrorMessage)
protected

A function that is called when a command finishes execution.

Parameters
ErrorMessageThe error message generated during the command execution.
Here is the caller graph for this function:

◆ K2_MessageReceivedFromCommand()

void UOperatingSystemTerminal::K2_MessageReceivedFromCommand ( const FText & CmdMsg,
const EOperatingSystemTerminalMessageType & CmdMsgType )
protected

BlueprintImplementableEvent function for receiving messages from the operating system terminal. This function is tied to a blueprint and is called when a message is received from the operating system terminal.

Parameters
CmdMsgThe received message from the operating system terminal as a FText object
CmdMsgTypeThe type of the received message as an EOperatingSystemTerminalMessageType enumeration value
Here is the caller graph for this function:

◆ K2_PromptRootPassword()

void UOperatingSystemTerminal::K2_PromptRootPassword ( )
protected

Event triggered when the root password is prompted.

Here is the caller graph for this function:

◆ K2_PromptUserContinue()

void UOperatingSystemTerminal::K2_PromptUserContinue ( )
protected

Event triggered when user wants to continue.

Here is the caller graph for this function:

◆ K2_UserChanged()

void UOperatingSystemTerminal::K2_UserChanged ( )
protected

This function is called when the user is changed. It can be implemented in blueprints to handle the event of user change in the operating system terminal.

Here is the caller graph for this function:

◆ MessageReceivedFromCommand()

void UOperatingSystemTerminal::MessageReceivedFromCommand ( const FText & CmdMsg,
const EOperatingSystemTerminalMessageType & CmdMsgType )

Function to handle received messages from the command. This function is called when a message is received from the command. It can be used to handle and process the message in the operating system terminal.

Parameters
CmdMsgThe message received from the command.
CmdMsgTypeThe type of the message received.
Here is the call graph for this function:

◆ OnStart()

void UOperatingSystemTerminal::OnStart ( FGenericError & OutError)
overrideprotectedvirtual

Called when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program.

Parameters
OutErrorA reference to the FGenericError object, used to report any errors that occur during startup.
See also
FGenericError

Reimplemented from UOperatingSystemBaseProgram.

Here is the call graph for this function:

◆ OnValidate()

void UOperatingSystemTerminal::OnValidate ( FGenericError & OutError) const
overrideprotectedvirtual

OnValidate method for validating program-specific logic.

This method is a virtual function that can be overridden by derived classes to perform additional validation specific to the program's requirements. The method takes an FGenericError& parameter, which can be used to report any validation errors encountered during the validation process.

Parameters
OutErrorThe error object used to report any validation errors.
See also
FGenericError

Reimplemented from UOperatingSystemBaseProgram.

◆ ProcessCommand()

void UOperatingSystemTerminal::ProcessCommand ( const FString & TestCommand,
FGenericError & OutError )

Process the given command in the Operating System terminal If the terminal is busy, it sets the output error indicating that the terminal is busy and cannot run new commands. If the command is empty, it destroys the active command and returns. If the command is not recognized, it sets the output error indicating that the command is not recognized. If the command supports multiple commands and contains a multi-command operator, it splits the command into multiple commands and processes them one by one.

Parameters
TestCommandThe command to be processed.
OutErrorThe output error if any error occurs during the command processing
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PromptRootPassword()

void UOperatingSystemTerminal::PromptRootPassword ( )

Prompts the user for the root password.

Note
This function does not have any real implementation. It only calls K2_PromptRootPassword BlueprintImplementableEvent. You will have to implement K2_PromptRootPassword in Blueprint and do the actual logic.
Here is the call graph for this function:

◆ PromptUserContinue()

void UOperatingSystemTerminal::PromptUserContinue ( )

Prompts the user to continue the execution in the operating system terminal.

Note
K2_PromptUserContinue must be implemented in Blueprints for actual logic.
Here is the call graph for this function:

◆ ValidateFlags()

FORCEINLINE bool UOperatingSystemTerminal::ValidateFlags ( ) const
inline

Gets the value of the bValidateFlags flag.

This method returns the value of the bValidateFlags flag. The bValidateFlags flag is used to determine whether the flags are being validated or not.

Returns
True if the flags are being validated, false otherwise.

◆ VerifyUserPrompt()

void UOperatingSystemTerminal::VerifyUserPrompt ( const bool bIsYes) const

Verifies the user prompt and takes the appropriate action. It checks if the user prompt is "Yes" or "No" and performs the necessary action based on the value of bIsYes parameter.

Parameters
bIsYesA boolean indicating if the user prompt is "Yes" or "No".

Member Data Documentation

◆ bSupportMultipleCommands

uint8 UOperatingSystemTerminal::bSupportMultipleCommands
protected

Determines if the OperatingSystemTerminal supports multiple commands.

If set to true, the OperatingSystemTerminal supports executing multiple commands at once. If set to false, the OperatingSystemTerminal only supports executing one command at a time.

◆ bValidateFlags

bool UOperatingSystemTerminal::bValidateFlags
protected

The flag to indicate whether to validate the operating system terminal.

◆ CommandCollection

TSoftObjectPtr<UOperatingSystemCmdCollection> UOperatingSystemTerminal::CommandCollection
protected

Soft Object Pointer representing the UOperatingSystemCmdCollection for the operating system terminal.

◆ CommandFlagPrefixes

TSet<FName> UOperatingSystemTerminal::CommandFlagPrefixes
protected

List of prefixes that must be included when adding flags.

◆ MultiCommandOperator

FName UOperatingSystemTerminal::MultiCommandOperator
protected

String to use for separating multiple commands. E.g: pwd && ls. NOTE: Does not support space so if you have space, it is automatically removed.


The documentation for this class was generated from the following files: