Operating System Simulator Plugin
3.5.1
Unreal Engine plugin that simulates an Operating System Environment
|
Class that represents a Unix-based operating system in the Operating System Simulator. This class is a child class of UOperatingSystem and provides additional functionality specific to Unix systems. More...
#include "OperatingSystemUnix.h"
Public Member Functions | |
UOperatingSystemUnix () | |
virtual UOperatingSystemDirectory * | CreateDirectoryInPath (const FString &TargetPath, const FString &DirectoryName, TSoftClassPtr< UOperatingSystemDirectory > DirectoryClass, UOperatingSystemPartition *TargetPartition, const bool bIsFromSaveGame, FGenericError &OutError) override |
const TSet< TSoftObjectPtr< UOperatingSystemProgramsCollection > > & | GetRepositoryClasses () const |
Retrieves the repository classes in the Operating System Simulator. | |
Public Member Functions inherited from UOperatingSystem | |
template<class T > | |
T * | GetAs () const |
Get a pointer to the object casted as type T. | |
template<class T > | |
FORCEINLINE const T * | GetAsConst () const |
Get a pointer to the object casted as type T. | |
OPERATINGSYSTEMSIMULATOR_API bool | AddNotification (const FOperatingSystemNotification &NewNotification) |
Adds a notification to the operating system. | |
OPERATINGSYSTEMSIMULATOR_API bool | AddNotification (const FGenericError &GenericError, const EOperatingSystemNotificationCategory &Category, const EOperatingSystemNotificationType Verbosity=EOperatingSystemNotificationType::Error) |
Adds a notification to the operating system. This method allows adding a notification to the operating system with the specified error, category, and verbosity. | |
void | StartOperatingSystem (const TWeakObjectPtr< const UOperatingSystemSaveGame > LoadGameInstance, FGenericError &OutError) |
Start the operating system. This method starts the operating system. It performs the necessary initialization and loads the settings and programs. | |
void | PostLoadOperatingSystem () |
Calls the PostLoadOperatingSystemImpl method and handles any error that occurs. | |
void | FinishInstallation () |
Finish the installation of the operating system. | |
void | InstallStartupPrograms () |
Install the startup programs for the operating system. | |
void | ShutdownOS () |
Shuts down the operating system. | |
void | RestartOS () |
Restarts the operating system. | |
void | DestroyOS () |
Destroys the operating system instance. | |
int32 | AddRunningProgram (UOperatingSystemBaseProgram *NewProgram, FGenericError &OutError) |
Adds a running program to the operating system. | |
void | ProgramStarted (UOperatingSystemBaseProgram *StartedProgram, const bool bIsRestored) |
Notifies the operating system that a program has started. | |
bool | IsProgramRunning (const TWeakObjectPtr< const UOperatingSystemBaseProgram > TestProgram) const |
Check if a program is running. | |
bool | IsProgramRunning (const TSubclassOf< UOperatingSystemBaseProgram > TestProgramClass) const |
Checks if a program of the specified class is currently running. | |
UDraggableWindow * | CreateNewWindow (TWeakObjectPtr< UOperatingSystemBaseProgram > TargetProgram) const |
Creates a new window for the target program. | |
void | BringWindowToFront (UDraggableWindow *TargetWindow) |
Bring the specified window to the front. | |
bool | CreateProgramsFromRepository (const TSoftObjectPtr< UOperatingSystemProgramsCollection > &TargetRepository, const bool bIsInstalledWithOS) |
Create programs from a given repository. | |
void | SetToInstallStartupPrograms (const bool bInstall) |
bool | ShouldInstallStartupPrograms () const |
void | SetDeviceName (const FText &NewName) |
FText | GetDeviceName () const |
void | SetAutoLogin (const bool bEnableAutoLogin) |
bool | CanAutoLogin () const |
float | GetInstallationTime () const |
float | GetLoadingTime () const |
float | GetInitialLoadingTime () const |
const TArray< FOperatingSystemNotification > & | GetNotifications () const |
void | ClearAllNotifications () |
OPERATINGSYSTEMSIMULATOR_API void | ConsumeSpaceInMB (const float &NewSizeInMB, UOperatingSystemPartition *Partition, FGenericError &OutError) |
OPERATINGSYSTEMSIMULATOR_API void | ConsumeSpaceInGB (const float &NewSizeInGB, UOperatingSystemPartition *Partition, FGenericError &OutError) |
OPERATINGSYSTEMSIMULATOR_API FText | GetSizeAsText (const EOperatingSystemSizeMethod SizeMethod, const UOperatingSystemPartition *Partition, FGenericError &OutError) const |
OPERATINGSYSTEMSIMULATOR_API float | GetStoragePercentage (const UOperatingSystemPartition *Partition, FGenericError &OutError) const |
OPERATINGSYSTEMSIMULATOR_API double | GetHardDiskSize (FGenericError &OutError, const EOperatingSystemSizeMethod SizeMethod=EOperatingSystemSizeMethod::GB) const |
void | UninstallProgram (const FName &ProgramIdentifier, FGenericError &OutErrorIfAny) |
void | UninstallProgramByClass (const TSoftClassPtr< UOperatingSystemBaseProgram > ProgramClass, FGenericError &OutErrorIfAny) |
UOperatingSystemBaseProgram * | InstallProgramFromPackage (const FName &ProgramIdentifier, FGenericError &OutErrorIfAny) |
UOperatingSystemBaseProgram * | InstallProgramFromClass (FGenericError &OutErrorIfAny, const TSoftClassPtr< UOperatingSystemBaseProgram > ProgramClass, UOperatingSystemPartition *TargetPartition=nullptr) |
void | BeginInstallation (UOperatingSystemPartition *TargetPartition, FGenericError &OutError) |
UOperatingSystemPartition * | AllocatePartition (const double SizeInBytes, FGenericError &OutError) |
void | RemovePartition (UOperatingSystemPartition *PartitionToDelete, FGenericError &OutError) |
void | RefreshPartitions () |
void | InstallationCompleted (const bool bSwitchToDesktop=true) |
bool | CreateNewUser (const FOperatingSystemUser &NewUser, const bool bSetAsActive=false) |
bool | LoginUser (const FText &Username, const FText &Password) |
bool | UpdateCurrentUserDetails (const FOperatingSystemUser &UpdatedDetails) |
bool | HasEnoughSpace (const double &TestSizeInBytes, const UOperatingSystemPartition *InPartition) const |
TArray< UOperatingSystemPartition * > | GetDiskPartitions () const |
UOperatingSystemPartition * | GetOperatingSystemPartition () const |
void | CloseProgram (UOperatingSystemBaseProgram *TargetProgram, FGenericError &OutError) |
bool | BringBackgroundProgramToFront (UOperatingSystemBaseProgram *TargetProgram) |
bool | IsProgramInBackground (UOperatingSystemBaseProgram *TestProgram) const |
void | MinimizeProgram (UOperatingSystemBaseProgram *TargetProgram) |
void | CloseAllRunningPrograms () |
void | RestoreMinimizedProgram (const UOperatingSystemBaseProgram *TargetProgram) |
Restores a minimized program to the foreground on the operating system's taskbar. | |
UObject * | GetDirectoryIconObject (const FGameplayTag &TestTag) const |
bool | IsUnix () const |
float | GetBsodOnScreenTime () const |
float | GetToastNotificationDisplayTime () const |
TArray< UOperatingSystemBaseProgram * > | GetInstalledPrograms () const |
void | GetInstalledProgramsMap (TMap< FName, UOperatingSystemBaseProgram * > &OutInstalledPrograms) |
UOperatingSystemBaseProgram * | GetInstalledProgram (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const |
bool | IsProgramInstalled (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const |
UOperatingSystemBaseProgram * | GetRunningProgram (const TSoftClassPtr< UOperatingSystemBaseProgram > TestClass) const |
bool | IsPreInstalledOperatingSystem () const |
UOperatingSystemSettingsData * | GetSettings () const |
bool | IsRunningOnPortableDevice () const |
virtual UOperatingSystemPartition * | FindPartitionFromLetter (const FName &TargetDiskLetter) const |
Find a partition in the operating system from a given disk letter. | |
bool | HasValidRootCommandAndUser () const |
Determines whether the root command and user are valid. | |
bool | IsShuttingDown () const |
Check if the operating system is in the process of shutting down. | |
bool | IsRestarting () const |
Checks if the operating system is currently restarting. | |
TArray< FOperatingSystemUser > | GetAllUsers () const |
Returns an array of all users registered in the operating system. This function retrieves information about all users registered in the operating system. | |
Protected Member Functions | |
virtual void | OnValidate (FGenericError &OutError) const override |
Validates the Unix-based operating system. | |
virtual void | FinalizePreInstallation (FGenericError &OutError) override |
Finalizes the pre-installation process for a Unix-based operating system. | |
virtual void | PrepareOperatingSystemInstallImpl (FGenericError &OutError) override |
PrepareOperatingSystemInstallImpl function prepares the Unix-based operating system for installation. | |
virtual bool | StartOperatingSystemImpl (FGenericError &OutError) override |
Starts the Unix-based operating system. | |
virtual void | PostLoadOperatingSystemImpl (FGenericError &OutError) override |
Executes additional post-loading operations specific to Unix-based operating systems. | |
virtual TOptional< FText > | GetRootCommand () const override final |
Gets the root command for the Unix-based operating system. | |
virtual TOptional< FOperatingSystemUser > | GetRootUser () const override final |
Retrieves the root user of the Unix-based operating system. | |
virtual TSoftClassPtr< UOperatingSystemBaseProgram > | FindProgramFromPackage (const FName &ProgramIdentifier) override |
Finds a program from a package based on its identifier. | |
bool | CreateRootDirectory (const bool bIsFromSaveGame) |
Creates the root directory for the Unix-based operating system if it does not already exist. The root directory is determined by finding the Unix root directory among all the available directories. If the root directory exists, this method returns true. Otherwise, it attempts to create the root directory using the first directory with the tag "Root". If the root directory is successfully created, this method returns true. Otherwise, it returns false. | |
Protected Member Functions inherited from UOperatingSystem | |
virtual OPERATINGSYSTEMSIMULATOR_API void | OnShowNotification (const FOperatingSystemNotification &NewNotification) |
This method is called when a new notification should be shown on the operating system. | |
virtual OPERATINGSYSTEMSIMULATOR_API void | OnAllOnNotificationsCleared () |
Callback triggered when all notifications are cleared. | |
virtual OPERATINGSYSTEMSIMULATOR_API void | FinishInstallationImpl () |
Performs the finishing steps of the installation process. | |
virtual OPERATINGSYSTEMSIMULATOR_API void | InstallStartupProgramsImpl () |
Allows the derived classes to implement their own logic for installing startup programs. This method should be overridden in derived classes to define the actual logic for installing startup programs. | |
virtual OPERATINGSYSTEMSIMULATOR_API void | OnPartitionLoaded (UOperatingSystemPartition &LoadedPartition, const FOperatingSystemPartitionSaveLoad &SaveLoadData) |
Callback method called when a partition is loaded. | |
bool | K2_CanStartOperatingSystem (FGenericError &ReturnError) |
Determines if the operating system can start. | |
Additional Inherited Members | |
Static Public Member Functions inherited from UOperatingSystem | |
static FName | GetOperatingSystemProgramRestoredEventName () |
static UE_NODISCARD UOperatingSystem * | CreateOperatingSystem (UOperatingSystemBaseDevice *OwningDevice, FGenericError &OutError) |
Creates a new instance of the operating system associated with the specified device. | |
static UE_NODISCARD FString | GetOperatingSystemUniqueID (const UOperatingSystem *TestOperatingSystem) |
Gets the unique ID of the operating system. This method retrieves the unique ID of the operating system represented by the given TestOperatingSystem object. | |
Public Attributes inherited from UOperatingSystem | |
FOperatingSystemProgramDelegate | OnProgramStarted |
Delegate representing the event when a program starts in the operating system. | |
FOperatingSystemProgramDelegate | OnProgramClosed |
Delegate for handling the program closed event. | |
FOperatingSystemProgramDelegate | OnProgramInstalled |
Delegate representing the event when a program is installed in the operating system. | |
FOperatingSystemProgramDelegate | OnProgramUninstalled |
Class that represents a Unix-based operating system in the Operating System Simulator. This class is a child class of UOperatingSystem and provides additional functionality specific to Unix systems.
UOperatingSystemUnix::UOperatingSystemUnix | ( | ) |
|
overridevirtual |
Creates a directory within a given path.
This method creates a directory with the specified name within the given target path. If the target path is the special root directory name, it creates the root directory and returns it. Otherwise, it iterates through the path array in reverse order and checks if the new directory exists. If the new directory does not exist, it creates the directory and returns it. If the new directory exists and its name matches the specified directory name, it returns the new directory. Otherwise, it updates the current directory to the new directory and continues the iteration.
TargetPath | The target path where the directory will be created. |
DirectoryName | The name of the directory to be created. |
DirectoryClass | The class pointer of the directory to be created. |
TargetPartition | The target partition where the directory will be added. |
bIsFromSaveGame | Indicates whether the directory is from a save game. |
OutError | The reference to the error object that will hold the error message in case of failure. |
Reimplemented from UOperatingSystem.
|
protected |
Creates the root directory for the Unix-based operating system if it does not already exist. The root directory is determined by finding the Unix root directory among all the available directories. If the root directory exists, this method returns true. Otherwise, it attempts to create the root directory using the first directory with the tag "Root". If the root directory is successfully created, this method returns true. Otherwise, it returns false.
bIsFromSaveGame | A boolean indicating whether the root directory is being created from a save game. |
|
overrideprotectedvirtual |
Finalizes the pre-installation process for a Unix-based operating system.
This method is called to finalize the pre-installation process for a Unix-based operating system. It allocates a new partition on the target hard disk and begins the installation process on the new partition. After this, it clears the installation timer and finishes the installation.
OutError | The reference to the error object that will hold the error message in case of failure. |
Reimplemented from UOperatingSystem.
|
overrideprotectedvirtual |
Finds a program from a package based on its identifier.
This method searches for a program with the given identifier in the repository classes of the Unix-based operating system. If a program is found with the matching identifier, it returns a soft class pointer to the program's class. Otherwise, it returns nullptr.
ProgramIdentifier | The identifier of the program to search for. |
Reimplemented from UOperatingSystem.
|
inline |
Retrieves the repository classes in the Operating System Simulator.
This method returns the set of repository classes, represented by TSoftObjectPtr<UOperatingSystemProgramsCollection>.
|
finaloverrideprotectedvirtual |
Gets the root command for the Unix-based operating system.
This method returns the root command for the Unix-based operating system. If the root command is empty or consists of only white space, the method returns an empty optional.
Reimplemented from UOperatingSystem.
|
finaloverrideprotectedvirtual |
Retrieves the root user of the Unix-based operating system.
This method returns an optional object containing the root user of the Unix-based operating system.
Reimplemented from UOperatingSystem.
|
overrideprotectedvirtual |
Validates the Unix-based operating system.
This method validates various properties of the Unix-based operating system. It checks if the root command is valid and not empty. If it is empty, an error message is generated. It also checks if at least one repository class is provided. If not, an error message is generated. It then checks if any of the repository classes are null. If all repository classes are null, an error message is generated. Finally, it checks if the root directory is set. If the root directory is not set, an error message is generated.
OutError | The reference to the error object that will hold the error message in case of validation failure. |
Reimplemented from UOperatingSystem.
|
overrideprotectedvirtual |
Executes additional post-loading operations specific to Unix-based operating systems.
This method is called after the operating system has finished loading. It performs additional operations that are specific to Unix-based operating systems.
If the operating system is starting for the first time or if the current user is not valid, the method will show the initial startup screen.
If the current user's password is empty or if the device startup type is FullBoot, the method will switch to the desktop tab.
Otherwise, the method will show the logon screen.
OutError | The error message in case of any failure during post-loading operations. |
Reimplemented from UOperatingSystem.
|
overrideprotectedvirtual |
PrepareOperatingSystemInstallImpl function prepares the Unix-based operating system for installation.
This method is called to prepare the Unix-based operating system for installation. It adds a notification to indicate the start of the installation, and calls the PrepareToInstall function of the OperatingSystemWidget.
OutError | The reference to the error object that will hold the error message in case of failure. |
Reimplemented from UOperatingSystem.
|
overrideprotectedvirtual |
Starts the Unix-based operating system.
This method is responsible for starting the Unix-based operating system. It performs necessary initialization tasks such as creating the root directory and checking for the presence of the desktop directory. It also sets the disk letter for the disk partition associated with the operating system.
OutError | A reference to an FGenericError object that will be populated with error details if the operating system fails to start. |
Reimplemented from UOperatingSystem.
|
protected |
Simulates the effect of sudo apt-get stuff. You can add as many classes you want and even let users add their own repository via terminal.
|
protected |
Root command name. Defaults to sudo.
|
protected |
Root user for this Operating System.