Operating System Simulator Plugin
3.5.1
Unreal Engine plugin that simulates an Operating System Environment
|
#include "OperatingSystemBaseProgram.h"
Public Member Functions | |
UOperatingSystemBaseProgram () | |
UOperatingSystemBaseProgram * | StartProgram (FGenericError &OutError) |
bool | IsRunning () const |
bool | CanAddToDesktop () const |
UOperatingSystem * | GetOperatingSystem () const |
UOperatingSystemProgramIconWidget * | CreateIconWidget () |
UOperatingSystemProgramIconWidget * | GetIconWidget () const |
void | OpenFile (UOperatingSystemFile *TargetFile, FGenericError &OutError) |
void | CloseProgram (const bool bIsFullClose, FGenericError &OutError) |
void | BringToFront (FGenericError &OutError) const |
UDraggableWindow * | GetParentWindow () 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< UOperatingSystemPartition > | GetParentPartition () const |
Get the parent partition of the current operating system program. | |
TSoftClassPtr< UOperatingSystemProgramIconWidget > | GetIconWidgetClass () const |
Retrieves the class of the icon widget for the operating system program. | |
TSoftClassPtr< UOperatingSystemProgramWidget > | GetWidgetClass () 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< UOperatingSystemProgramSettings > | GetSettingsClass () const |
Get the settings class associated with this program. This method returns the class type of the settings object specific to this program. | |
TSoftClassPtr< UOperatingSystemProgramData > | GetDataClass () const |
Retrieves the data class associated with the program. | |
TSoftClassPtr< UOperatingSystemTaskbarButton > | GetTaskbarButtonClass () const |
Retrieves the taskbar button class associated with the program. | |
TWeakObjectPtr< UOperatingSystemProgramSettings > | GetSettings () const |
Get the settings object for the program. | |
TWeakObjectPtr< UOperatingSystemProgramData > | GetDataObj () const |
Retrieves the data object associated with the operating system program. | |
TWeakObjectPtr< UOperatingSystemTaskbarButton > | GetTaskbarButton () const |
Retrieves the taskbar button associated with the program. | |
UOperatingSystemProgramWidget * | GetProgramWidget () 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. | |
Static Public Member Functions | |
static UE_NODISCARD UOperatingSystemBaseProgram * | CreateProgram (TWeakObjectPtr< UOperatingSystem > OwningOS, const TSoftClassPtr< UOperatingSystemBaseProgram > &ProgramClass, FGenericError &OutError, const bool bInstalledWithOS=false) |
static OPERATINGSYSTEMSIMULATOR_API bool | IsStoreItemFree (const FOperatingSystemStoreProgramData &ProgramData) |
Public Attributes | |
FOnOperatingSystemProgramViewStateChanged | OnOperatingSystemProgramViewStateChanged |
Protected Member Functions | |
virtual OPERATINGSYSTEMSIMULATOR_API void | OnValidate (FGenericError &OutError) const |
OnValidate method for validating program-specific logic. | |
virtual OPERATINGSYSTEMSIMULATOR_API void | OnStart (FGenericError &OutError) |
Called when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program. | |
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 |
The base class for all operating system programs.
This class provides properties and functions that are common to all programs, such as the program name, author, description, version, and settings class.
To create a new program, derive from this class and implement the necessary functionality for the specific program.
UOperatingSystemBaseProgram::UOperatingSystemBaseProgram | ( | ) |
void UOperatingSystemBaseProgram::BringToFront | ( | FGenericError & | OutError | ) | const |
bool UOperatingSystemBaseProgram::CanAddToDesktop | ( | ) | const |
Check if the program can be added to the desktop.
This function is used to determine if the program can be added to the desktop. It checks if the property bAddToDesktop is set to true and if the IconWidgetClass is not null.
bool UOperatingSystemBaseProgram::CanSaveSettings | ( | ) | const |
Checks if the settings of the operating system base program can be saved.
void UOperatingSystemBaseProgram::CloseProgram | ( | const bool | bIsFullClose, |
FGenericError & | OutError ) |
Closes the program.
If the program has a blueprint on close, it calls the K2_OnClose() function. Then it calls the OnClose() function and provides an OutError parameter. The ProcessID is set to INVALID_PROCESS_ID. If a ChildFile object is valid, it closes the file, marks it as garbage, and sets it to nullptr.
If the SaveMethod is set to SaveOnExit or the ParentOS is shutting down or restarting and the SaveMethod is set to SaveOnOperatingSystemShutdown, it saves the program settings using the UOperatingSystemProgramSettings::SaveSettings() function.
If ProgramWidget is valid, it destroys the operating system base widget and sets ProgramWidget to nullptr.
If the Settings object is valid and the ParentOS is shutting down or restarting, it marks the Settings object as garbage and sets it to nullptr.
It then closes the ParentWindow and sets ParentWindow to nullptr.
Finally, it broadcasts the OnProgramClosed event with this program object as a parameter.
bIsFullClose | Determines if this program should be completely closed or not. |
OutError | The reference to an FGenericError object to store any error that occurred during the closing process. |
UOperatingSystemProgramIconWidget * UOperatingSystemBaseProgram::CreateIconWidget | ( | ) |
Creates an icon widget for the operating system program. This function creates an icon widget for the operating system program, if it has not been created before. If a cached icon widget exists, it is returned instead of creating a new one.
|
static |
Creates a program instance.
OwningOS | Operating System that will own the program. |
ProgramClass | The class of the program to create. |
OutError | The error that occurred during program creation. |
bInstalledWithOS | Whether the program is installed with the operating system. |
|
inline |
Returns the close method of the operating system program.
This method returns the close method of the operating system program. The close method determines how the program will be closed or terminated. It is an enumerated value of type EOperatingSystemProgramCloseMethod.
TSoftClassPtr< UOperatingSystemProgramData > UOperatingSystemBaseProgram::GetDataClass | ( | ) | const |
Retrieves the data class associated with the program.
This function returns a TSoftClassPtr<UOperatingSystemProgramData> which represents the data class associated with the program. The data class stores the program's data and provides functionality for manipulating and accessing the data.
TWeakObjectPtr< UOperatingSystemProgramData > UOperatingSystemBaseProgram::GetDataObj | ( | ) | const |
Retrieves the data object associated with the operating system program.
This function returns the data object associated with the operating system program. The data object stores information specific to the program, such as program settings, state, and other relevant data.
|
inline |
Returns the data object associated with the program.
This method returns a pointer to the data object associated with the program. The data object is of type T, which must be derived from UOperatingSystemProgramData. If T is not derived from UOperatingSystemProgramData, a static_assert will trigger and an error message will be displayed.
UOperatingSystemProgramIconWidget * UOperatingSystemBaseProgram::GetIconWidget | ( | ) | const |
Gets the icon widget for the Operating System program.
TSoftClassPtr< UOperatingSystemProgramIconWidget > UOperatingSystemBaseProgram::GetIconWidgetClass | ( | ) | const |
Retrieves the class of the icon widget for the operating system program.
This method returns the class of the widget that represents the icon of the operating system program. The widget class is a subclass of UOperatingSystemProgramIconWidget.
|
inline |
Returns the identifier of the program. The identifier serves as a unique identification for the program.
UOperatingSystem * UOperatingSystemBaseProgram::GetOperatingSystem | ( | ) | const |
Get the operating system associated with this program.
TWeakObjectPtr< UOperatingSystemPartition > UOperatingSystemBaseProgram::GetParentPartition | ( | ) | const |
Get the parent partition of the current operating system program.
This method returns a weak pointer to the parent partition of the program. The parent partition represents the operating system partition to which the program belongs.
To access the properties or call functions of the parent partition, you can use the returned weak pointer.
UDraggableWindow * UOperatingSystemBaseProgram::GetParentWindow | ( | ) | const |
Get the parent window of the program.
This function returns the parent window of the program. The parent window is the draggable window that contains the program's UI elements.
|
inline |
Retrieves the process ID of the current program. This method allows you to obtain the unique process ID of the program.
|
inline |
Returns the program name as a FString.
UOperatingSystemProgramWidget * UOperatingSystemBaseProgram::GetProgramWidget | ( | ) | const |
Returns the program widget associated with the operating system program.
|
virtual |
Retrieves the name of the save slot for the operating system program.
This method returns the name of the save slot for the operating system program. If the program has a blueprint implementation of K2_GetSaveSlotName
, that will be used to retrieve the save slot name. If the blueprint implementation returns a non-empty string, that string will be returned. Otherwise, the save slot name will be generated using the program's identifier and the unique ID of the parent device.
Reimplemented in UOperatingSystemStore.
TWeakObjectPtr< UOperatingSystemProgramSettings > UOperatingSystemBaseProgram::GetSettings | ( | ) | const |
Get the settings object for the program.
This method returns the settings object associated with the program. The settings object contains various properties and configurations specific to the program.
|
inline |
Get the settings object of type T.
This method returns the settings object of type T associated with the program. It is important that T is derived from UOperatingSystemProgramSettings. If T is not derived from UOperatingSystemProgramSettings, a compilation error will occur.
TSoftClassPtr< UOperatingSystemProgramSettings > UOperatingSystemBaseProgram::GetSettingsClass | ( | ) | const |
Get the settings class associated with this program. This method returns the class type of the settings object specific to this program.
|
inline |
Get the space required by the program in megabytes. This method returns the space required by the program in megabytes.
TWeakObjectPtr< UOperatingSystemTaskbarButton > UOperatingSystemBaseProgram::GetTaskbarButton | ( | ) | const |
Retrieves the taskbar button associated with the program.
This method returns a pointer to the taskbar button associated with the program. If the program does not have a taskbar button, the method returns nullptr.
TSoftClassPtr< UOperatingSystemTaskbarButton > UOperatingSystemBaseProgram::GetTaskbarButtonClass | ( | ) | const |
Retrieves the taskbar button class associated with the program.
This method retrieves the taskbar button class associated with the program. It returns a soft object pointer to the taskbar button class.
TSoftClassPtr< UOperatingSystemProgramWidget > UOperatingSystemBaseProgram::GetWidgetClass | ( | ) | 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.
TOptional< FVector2D > UOperatingSystemBaseProgram::GetWindowPosition | ( | ) | const |
Retrieves the position of the window associated with the operating system program.
If the program has a parent window, the method will call the GetWindowPosition() method of the parent window and return the result. If the program does not have a parent window, the method returns an empty optional value.
void UOperatingSystemBaseProgram::IsCompatibleWithOS | ( | const TWeakObjectPtr< const UOperatingSystem > | TestOS, |
FGenericError & | OutError ) const |
Checks if the given operating system is compatible with this program.
TestOS | The operating system to test compatibility with. |
OutError | The error message in case of incompatibility. |
bool UOperatingSystemBaseProgram::IsRunning | ( | ) | const |
Checks if the program is running.
|
inline |
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.
|
static |
Checks if a store item is free.
This function takes a FOperatingSystemStoreProgramData
object as input and checks if the program associated with it is free. It returns true if the program is free, and false otherwise.
ProgramData | The store program data to check. |
|
inline |
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.
bool UOperatingSystemBaseProgram::IsWindowMaximized | ( | ) | const |
Checks whether the window of the operating system base program is maximized.
This method checks if the window of the operating system base program is currently maximized. If the window is maximized, the method returns true; otherwise, it returns false.
|
protected |
Retrieves the save slot name.
This function is a Blueprint implementable event that allows getting the save slot name in Unreal Engine. It returns a FString object representing the name of the save slot.
|
protected |
BlueprintImplementableEvent for closing the operating system program.
This event is called when the operating system program needs to be closed.
|
protected |
Implementable event called when the program is created.
|
protected |
UFunction declaration for the blueprint implementable event K2_OnInstall
.
This function should be used to handle the installation logic for the operating system program. It is a blueprint implementable event, which means it can be overridden and implemented in blueprint classes.
|
protected |
Implementable event triggered when a file is opened. This event is called before calling ProgramWidget->OpenFile.
This event can be implemented in Blueprint to handle the opening of a file.
|
protected |
Blueprint event called when settings are loaded.
It is called when settings are loaded for an operating system program.
LoadedSettings | The loaded settings object. |
|
protected |
A function that is called when the operating system program starts.
This function is a blueprint implementable event. It is called when the operating system program is started. It returns an object of type FGenericError.
|
protected |
Implementable event triggered when validating this program. If you set the Output Error return value to something valid, this program will not be created at all.
OutError | Outputs error. |
|
inlineprotectedvirtual |
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.
OutError | The error object to report any error that occurred during the closing process. |
Reimplemented in UOperatingSystemAudioPlayer, and UOperatingSystemVideoPlayer.
|
inlineprotectedvirtual |
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.
TargetFile | The pointer to the UOperatingSystemFile object representing the opened file. |
OutError | The reference to the FGenericError object for reporting any errors occurred during the file opening process. |
Reimplemented in UOperatingSystemAudioPlayer, and UOperatingSystemVideoPlayer.
void UOperatingSystemBaseProgram::OnProgramWindowStateChanged | ( | const EOperatingSystemProgramViewState & | NewState | ) | const |
Called when the program window's state changes.
NewState | The new state of the program window. |
|
inlineprotectedvirtual |
Called when the program starts. It should be overridden in derived classes to provide the necessary functionality for the specific program.
OutError | A reference to the FGenericError object, used to report any errors that occur during startup. |
Reimplemented in UOperatingSystemStore, and UOperatingSystemTerminal.
|
inlineprotectedvirtual |
Virtual method called when the theme is changed.
This method is called when the theme is changed. It can be overridden by derived classes to handle theme change events.
ThemePayload | A pointer to the UOperatingSystemSettingModule_Theme object that represents the new |
|
inlineprotectedvirtual |
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.
OutError | The error object used to report any validation errors. |
Reimplemented in UOperatingSystemStore, and UOperatingSystemTerminal.
void UOperatingSystemBaseProgram::OpenFile | ( | UOperatingSystemFile * | TargetFile, |
FGenericError & | OutError ) |
Opens a file in the operating system.
TargetFile | The file to be opened. |
OutError | The error message if the file fails to open. |
void UOperatingSystemBaseProgram::SetParentPartition | ( | TWeakObjectPtr< UOperatingSystemPartition > | OwningPartition | ) |
Sets the parent partition of the program to the specified operating system partition.
OwningPartition | A weak object pointer to the operating system partition that owns this program. |
|
inline |
Indicates whether the program should remember the last window position.
This method returns a boolean value indicating whether the program should remember the last window position or not. If the value is true, the program should remember the last window position, otherwise it should not.
UOperatingSystemBaseProgram * UOperatingSystemBaseProgram::StartProgram | ( | FGenericError & | OutError | ) |
Starts a program in the operating system.
This function is used to start a program in the operating system. It checks if the program is already running. If the program is set to run in a single instance only and is already running, it returns the currently running instance. Otherwise, it creates a new instance of the program and initializes it.
OutError | The error message in case of any error during program start. |
|
protected |
The company or individual who created this program.
|
protected |
If true, add this program to the desktop after install.
|
protected |
Allows the user to drag the window of this program.
|
protected |
Allows the draggable window of this program to be resized by user.
|
protected |
If true, this program can run on portable device too.
|
protected |
If true, add a notification to the Operating System that this program installed.
|
protected |
Some programs might need access to its settings class before they are started. For example, to determine if the program itself should start automatically when os is started. In this case, you need to enable this.
|
protected |
Disables auto determining and set the window size as set by Override Window Size variable.
|
protected |
Set to true if the window position should be saved and restored automatically.
|
protected |
|
protected |
If true, then this program must have a valid data class set and the data object must return ShouldCreate true (by default it is). If not, program will not create.
|
protected |
If true, only one instance of this program is allowed to run.
|
protected |
Determines how the program should close. For a phone type of device, typically this should be set to Background.
|
protected |
|
protected |
A simple description for this program. Typically used on store apps.
|
protected |
Obvious right? C'mon its just an Icon. What you need a tooltip for ¯_(ツ)_/¯
|
protected |
Icon widget that represents this program.
|
protected |
A unique identifier (UID) for this program. Useful for terminal commands.
|
protected |
If non zero, window can only resize upto this value. Resizing will not go lower than this.
|
protected |
If enabled, this program will not install/run on an Operating System less than this version.
|
protected |
Name of this program.
FOnOperatingSystemProgramViewStateChanged UOperatingSystemBaseProgram::OnOperatingSystemProgramViewStateChanged |
A Blueprint assignable delegate that is triggered when the view state of an operating system program changes. This delegate can be used to handle view state changes of an operating system program, such as when a program window is minimized or maximized.
|
protected |
If not null, then use this class as draggable window when starting this program. If null, new window class should be set inside UOperatingSystemWidget::K2_CreateNewWindow
|
protected |
Forcefully set a window size instead of auto-determining
|
protected |
|
protected |
Determines when this program saves.
|
protected |
An optional class where you can save custom settings for this program. Example: Customizable options for a browser.
|
protected |
How much space does this program consume once installed.
|
protected |
Set the startup window state.
|
protected |
Only for store app. Overrides the name to show on store. If this is unset, Name property is used.
|
protected |
Only for store app. What price should be displayed on store. Set to 0 to make this free.
|
protected |
Only for store app. What category or type is this program? Example: Entertainment, Productivity, Financial, Game, Utilities, Tool etc.
|
protected |
If this container is empty, it is assumed all Operating Systems are supported.
|
protected |
|
protected |
Program version
|
protected |
Widget associated with this program.