This class represents a device that can run an operating system. It contains properties related to the device hardware, the operating system that the device is running, and the device state. It also provides functions to start and stop the operating system, manage the device's on-screen widget, and update the device state.
More...
#include "OperatingSystemBaseDevice.h"
This class represents a device that can run an operating system. It contains properties related to the device hardware, the operating system that the device is running, and the device state. It also provides functions to start and stop the operating system, manage the device's on-screen widget, and update the device state.
- Note
- This class is an abstract class and cannot be instantiated directly. It should be used as a base class for specific types of operating system devices.
◆ ApplyWidgetToScreen()
void UOperatingSystemBaseDevice::ApplyWidgetToScreen |
( |
| ) |
const |
Applies the device's on-screen widget to the viewport, allowing it to be displayed on the screen. The widget will only be added if it is valid and if the device actor can add widgets to the screen.
- Note
- The on-screen widget must be set using the SetOnScreenWidget() method before calling this method. Calling this method without setting the on-screen widget will have no effect.
◆ ChangeOnScreenWidget()
void UOperatingSystemBaseDevice::ChangeOnScreenWidget |
( |
UUserWidget * | NewOnScreenWidget = nullptr | ) |
|
|
protected |
Allows the user to change the on-screen widget of the operating system device. By providing a new widget, the current on-screen widget is replaced with the new one.
- Parameters
-
NewOnScreenWidget | The new on-screen widget to be set. If nullptr is provided, the current on-screen widget will be cleared. |
- Note
- This method updates the device's on-screen widget, applies the widget to the screen, and notifies the device actor about the widget change.
◆ CheckHardware()
void UOperatingSystemBaseDevice::CheckHardware |
( |
FGenericError & | OutError | ) |
|
|
protected |
Checks the hardware of the operating system base device. It ensures that all hardware components are valid and initializes them if necessary. If any errors occur during the hardware check, the method will return an error message via the OutError parameter.
- Parameters
-
OutError | A reference to a FGenericError object that will store any error messages if the hardware check fails. |
- Note
- This method is called internally and should not be called directly by external code.
◆ ClearOnScreenWidget()
void UOperatingSystemBaseDevice::ClearOnScreenWidget |
( |
| ) |
const |
Remove the on-screen widget from the device's viewport if it is currently valid and visible.
◆ ClockTick()
void UOperatingSystemBaseDevice::ClockTick |
( |
| ) |
|
◆ DestroyDevice()
void UOperatingSystemBaseDevice::DestroyDevice |
( |
| ) |
|
Destroys the operating system device.
This function is responsible for destroying the operating system device. It performs the necessary cleanup tasks and notifies the device actor that the device has been destroyed.
- Warning
- Once this function is called, the device will no longer be accessible or functional. Make sure to handle any necessary tasks before calling this function.
◆ DestroyDeviceAndRestart()
void UOperatingSystemBaseDevice::DestroyDeviceAndRestart |
( |
| ) |
|
|
protected |
DestroyDeviceAndRestart
This method destroys the device and restarts it. It internally calls the Internal_DestroyDevice() method to destroy the device and then calls the RestartDevice() method of the DeviceActor to restart the device.
- Note
- It assumes that the DeviceActor is already set and initialized.
◆ DeviceCreated()
Creates a new operating system device.
This method initializes the operating system device with the given parameters. It performs the following steps:
- Checks if the device name is set. If the name is empty or consists of only whitespace characters, an error is set and the method returns.
- Checks if the device widget class is null. If it is null, an error is set and the method returns.
- Sets the load game instance and owning device actor properties of the operating system device.
- Sets the device tag by getting it from the owning device actor.
- Creates an instance of the device widget using the UOperatingSystemDeviceWidget::CreateDeviceWidget() method.
- Updates the device state to "Starting" and sets the error parameter if there was an error during the state update.
- Changes the on-screen widget of the device to the newly created device widget.
- Logs a success message with the name of the device.
- Calls the OnDeviceCreated() method to notify listeners that the device was successfully created.
- If there was an error during the creation process, ends the device session.
- If there were no errors, schedules a timer to update the device state to "Running" after a delay specified by the PowerOnTime property.
- Parameters
-
OwningDeviceActor | The owning device actor that represents the physical device in the game world. |
NewLoadGameInstance | The load game instance to use for the operating system device. |
OutError | The error object that receives any errors that occur during the device creation process. |
◆ DeviceSessionEnd()
void UOperatingSystemBaseDevice::DeviceSessionEnd |
( |
const bool | bShouldRestart | ) |
|
End the session of the operating system device.
This method is used to end the session of the operating system device. It updates the device state and performs any necessary actions based on the given value of bShouldRestart. If bShouldRestart is true, the device state is updated to "Restarting". If bShouldRestart is false, the device state is updated to "ShuttingDown".
- Parameters
-
bShouldRestart | Indicates whether the device should be restarted after ending the session. |
◆ GetCurrentOperatingSystem()
UOperatingSystem * UOperatingSystemBaseDevice::GetCurrentOperatingSystem |
( |
| ) |
const |
Returns the active operating system on the device.
- Returns
- The current operating system running on the device.
◆ GetCurrentState()
Gets the current state of the operating system device.
- Returns
- The current state of the operating system device.
◆ GetHardwareByTag() [1/2]
template<class T >
UE_NODISCARD OPERATINGSYSTEMSIMULATOR_API T * UOperatingSystemBaseDevice::GetHardwareByTag |
( |
const FGameplayTag & | TestTag | ) |
const |
|
inline |
Retrieves the hardware instance associated with the specified tag.
This method searches for a hardware instance that is derived from UOperatingSystemBaseHardware and is associated with the given tag. It returns a pointer to the hardware instance if found, otherwise it returns nullptr.
- Warning
- This method will assert if T is not derived from UOperatingSystemBaseHardware.
- Parameters
-
TestTag | The tag used to search for the hardware instance. |
- Returns
- A pointer to the hardware instance associated with the tag, or nullptr if no hardware instance is found.
◆ GetHardwareByTag() [2/2]
Retrieves the hardware object associated with the specified tag.
- Parameters
-
TestTag | The gameplay tag used to search for the hardware object. |
- Returns
- Pointer to the hardware object if found, nullptr otherwise.
◆ GetMessenger()
Get the device messenger of the operating system base device.
This method returns the device messenger associated with the operating system base device. The device messenger is responsible for handling device communications, such as sending and receiving messages.
- Returns
- The device messenger of the operating system base device.
◆ GetOperatingSystemClass()
TSoftClassPtr< UOperatingSystem > UOperatingSystemBaseDevice::GetOperatingSystemClass |
( |
| ) |
const |
Returns the class of the operating system associated with this device. The operating system class is represented by the type TSoftClassPtr<UOperatingSystem>.
- Returns
- The class of the operating system associated with this device.
- Note
- The returned value is a soft class pointer to the operating system class. It represents the class type but does not instantiate the class itself.
◆ GetParentDeviceActor()
Retrieves the parent device actor associated with this operating system device.
- Returns
- The parent device actor, or nullptr if no parent device actor is set.
- See also
- DeviceActor
◆ GetSaveGameClass()
Returns the class pointer to the save game class associated with the device.
- Returns
- A class pointer to the save game class associated with the device. Returns nullptr if the device actor is invalid.
◆ OnDeviceCreated()
virtual OPERATINGSYSTEMSIMULATOR_API void UOperatingSystemBaseDevice::OnDeviceCreated |
( |
FGenericError & | OutError | ) |
|
|
inlineprotectedvirtual |
This method is called when a device is created.
- Note
- This method is virtual and should be overridden in derived classes to provide specific implementation. It is called after the device is created and allows for any necessary initialization code to be executed.
- Parameters
-
OutError | The error object to populate if an error occurs during device creation. |
◆ OnDeviceRestart()
void UOperatingSystemBaseDevice::OnDeviceRestart |
( |
| ) |
|
|
protected |
Restarts the operating system on the device.
This method is called to initiate a device restart. It performs the necessary operations to gracefully stop the current session, then restarts the operating system on the device.
◆ OnDeviceShutdown()
void UOperatingSystemBaseDevice::OnDeviceShutdown |
( |
| ) |
|
|
protected |
Triggers the device shutdown process.
This method is called when the device is being shut down. It triggers the necessary actions to gracefully shut down the device, such as saving data and closing connections. It does not perform the actual power-off or hardware shutdown.
◆ OnDeviceStartRunning()
void UOperatingSystemBaseDevice::OnDeviceStartRunning |
( |
| ) |
|
|
protected |
Callback function called when the device starts running.
This function is called when the device starts running. It first checks if the active operating system instance is valid. If not, it creates a new operating system instance and assigns it to the ActiveOperatingSystem member variable. If there is any error during the creation of the operating system instance, the error is passed to the DeviceWidget's OperatingSystemError function and the function returns.
After creating or validating the active operating system instance, it calls the StartOperatingSystem function, passing an OutError parameter. The StartOperatingSystem function is responsible for starting the operating system execution.
◆ OnFinishOperatingSystemInstallation()
bool UOperatingSystemBaseDevice::OnFinishOperatingSystemInstallation |
( |
| ) |
|
Executed when the operating system installation process completes successfully. It updates the device state to indicate that the operating system is installed, logs the installation, and determines whether a restart is required. If a restart is not required (e.g., device startup type is not set to "FullBoot"), it only updates the device state and returns false. If a restart is required, it updates the device state, clears the restart timer handle, destroys the device, restarts the system, changes the on-screen widget to the device widget, and returns true.
- Returns
- True if a restart is required and the on-screen widget is changed to the device widget, false otherwise.
◆ OnFinishSettingUpOperatingSystemPostInstallation()
void UOperatingSystemBaseDevice::OnFinishSettingUpOperatingSystemPostInstallation |
( |
| ) |
const |
Function to be called after the operating system has finished setting up post installation.
This function is called after the operating system of the device has finished setting up post installation. It is called internally within the UOperatingSystemBaseDevice class. The function saves the game by calling the SaveGame() function from the UOperatingSystemSaveGame class, passing in the DeviceActor member variable as the argument.
- Note
- This function is marked as const, indicating that it does not modify the state of the UOperatingSystemBaseDevice object. It should only be called after the operating system has finished setting up post installation. The DeviceActor member variable must be set before calling this function, otherwise it will not have any effect.
◆ OpenBIOS()
Opens the BIOS widget for the operating system device and sets it as the active widget. The BIOS widget is responsible for displaying BIOS-related information and providing options to interact with the device's BIOS settings.
- Parameters
-
InBiosWidget | The BIOS widget to be opened for the operating system device. It should be a reference to an instance of UOperatingSystemBiosWidget class. The BIOS widget is responsible for displaying BIOS-related information and providing options to interact with the device's BIOS settings. |
- Note
- This method is called internally to open the BIOS widget. It should not be called directly by external code.
◆ ReApplyWidget()
void UOperatingSystemBaseDevice::ReApplyWidget |
( |
| ) |
const |
Reapplies the widget to the device actor.
This function is called to update the widget of the device actor. It will reapply the widget to the device actor, ensuring that any changes made to the widget are reflected in the device actor's display.
- Note
- This function is const and does not modify the state of the device.
◆ ShowBSOD()
bool UOperatingSystemBaseDevice::ShowBSOD |
( |
| ) |
|
Displays the Blue Screen of Death (BSOD) on the operating system device. It updates the device state to indicate that the device is currently in a BSOD state.
- Returns
- True if the device state was successfully updated to BSOD, false otherwise.
◆ StartOperatingSystem()
void UOperatingSystemBaseDevice::StartOperatingSystem |
( |
FGenericError & | OutError | ) |
|
Starts the operating system on the base device. It checks if the loaded game instance is valid, then compares the operating system ID of the loaded device with the ID of the active operating system. If they do not match, an error is generated and the device's on-screen widget is updated to indicate the operating system mismatch. The active operating system is marked as garbage and set to nullptr.
If the operating system IDs match, the "bOperatingSystemInstalled" property of the device is updated based on the "bSaveLoad_OperatingSystemInstalled" property of the loaded device. The device's on-screen widget is updated with the active operating system's widget, and the "StartOperatingSystem" function is called on the active operating system with the loaded game instance and the "OutError" parameter.
If an error occurs during the start operation, the device's state is updated to "BSOD" (Blue Screen of Death). Otherwise, the "OnOperatingSystemStartedDelegate" is executed and a log message is written indicating that the operating system has started.
- Parameters
-
OutError | The error message to be populated in case an error occurs during the start operation. |
- Note
- This function assumes that the "ActiveOperatingSystem" and "LoadGameInstance" properties have already been set.
◆ UpdateDeviceState()
Update the state of the operating system device. It takes the new state as a parameter and updates the device's current state accordingly. If the new state is different from the current state, the method performs the necessary actions associated with the state change. These actions may include logging, hardware checks, on-screen widget changes, and event broadcasts. If the state is successfully updated, the method returns true; otherwise, it returns false.
- Parameters
-
NewState | The new state of the device (EOperatingSystemDeviceState enum). |
OutError | (output) Any error message that occurred during the state change. |
- Returns
- True if the state was successfully updated, false otherwise.
- See also
- EOperatingSystemDeviceState, FGenericError, CheckHardware, ChangeOnScreenWidget, OnDeviceStartRunning, OnDeviceRestart, OnDeviceShutdown, OnDeviceStateChanged
◆ ActiveOperatingSystem
Current operating system that is active.
◆ BiosWidget
Pointer to a weak reference of the BiosWidget which is used to interact with the BiosWidget instance in the operating system device.
◆ bOperatingSystemInstalled
uint8 UOperatingSystemBaseDevice::bOperatingSystemInstalled |
|
protected |
Indicates whether the operating system is installed on the device.
◆ bOperatingSystemIsPreInstalled_DEPRECATED
bool UOperatingSystemBaseDevice::bOperatingSystemIsPreInstalled_DEPRECATED |
|
protected |
DEPRECATED. Use Device Startup Type instead. Determine whether the operating system comes pre-installed on the device. If set to true, it indicates that the operating system is already present on the device. If set to false, it indicates that the operating system needs to be installed on the device.
◆ bRequiresGPU
uint8 UOperatingSystemBaseDevice::bRequiresGPU |
|
protected |
Does this device requires a GPU? If true, you must provide a valid class for Gpu Class.
◆ CurrentState
Represents the current state of the operating system device.
The CurrentState
variable is an instance of the EOperatingSystemDeviceState
enumeration, which defines the possible states that the operating system device can be in.
- See also
- EOperatingSystemDeviceState
◆ DeviceActor
Device Actor pointer that represents an operating system device.
This variable is a weak pointer to an object of class AOperatingSystemDeviceActor, which is an actor representing an operating system device. A weak pointer is used to prevent memory leaks and potential dangling references.
◆ DeviceName
FText UOperatingSystemBaseDevice::DeviceName |
|
protected |
Device name of the operating system device.
◆ DeviceStartupType
Determine whether the operating system should follow the normal installation flow or should it be preinstalled or directly boot to desktop.
◆ DeviceTag
FGameplayTag UOperatingSystemBaseDevice::DeviceTag |
|
protected |
Gameplay tag assigned from parent device actor.
◆ DeviceWidget
Represents the on-screen widget for an operating system device. It is used to display information and interact with the device's hardware and operating system.
◆ DeviceWidgetClass
Class is used to store the reference to the widget class that will be used to display a specific device in the operating system.
- Note
- This class should only be used internally and not be accessed directly.
◆ Hardwares
Array of operating system base hardware objects used to store hardware information related to the operating system device.
- See also
- UOperatingSystemBaseHardware
◆ LoadGameInstance
Holds a weak reference to an instance of a saved game for an operating system. The type of the saved game is UOperatingSystemSaveGame. If the object is destroyed, the weak reference will automatically become null.
- See also
- UOperatingSystemSaveGame
◆ MotherboardClass
Motherboard class for which this device will be created.
◆ OnDeviceStateChanged
FOnDeviceStateChanged UOperatingSystemBaseDevice::OnDeviceStateChanged |
A BlueprintAssignable event that is raised when the device state changes. This event can be bound to a delegate or a blueprint function to receive notifications when the device state changes.
◆ OnOperatingSystemStartedDelegate
Delegate for handling the event when the operating system has started.
This delegate is used to define a callback function that will be called when the operating system has started. It is used in conjunction with the OnOperatingSystemStarted event to provide a way to handle the event and perform any desired actions.
Use the BindDynamic function to bind a specific function to this delegate. The bound function will be called when the OnOperatingSystemStarted event is broadcast.
- See also
- OnOperatingSystemStarted event
◆ OnScreenWidget
TObjectPtr<UUserWidget> UOperatingSystemBaseDevice::OnScreenWidget |
|
protected |
The on-screen widget associated with the operating system device that is currently displayed on the player screen.
It is a reference to an instance of the UUserWidget class, which is the base class for all user interface widgets in the game engine. The widget may contain interactive controls, display information, or provide functionality specific to the operating system device.
◆ OperatingSystemClass
TSoftClassPtr<UOperatingSystem> UOperatingSystemBaseDevice::OperatingSystemClass |
|
protected |
Specify the class pointer of an operating system device in the editor.
◆ PowerOnTime
The PowerOnTime variable represents the range of time for which the operating system device needs to power on. This is a FOperatingSystemRangeTime object that provides a convenient way to store and manipulate the range of time values.
◆ PreviousState
Represents the previous state of an operating system device.
This variable is used to store the previous state of an operating system device. It is of type EOperatingSystemDeviceState, which is an enumeration that defines different states that the device can be in.
- See also
- EOperatingSystemDeviceState
◆ SessionEndTime
Shutdown and restart time.
◆ TimerHandle_SessionEnd
FTimerHandle UOperatingSystemBaseDevice::TimerHandle_SessionEnd |
|
protected |
Timer handle for the end of a session.
This variable represents the timer handle used to track the end of a session. It is used in the OnFinishOperatingSystemInstallation() method of the UOperatingSystemBaseDevice class. When the installation of the operating system finishes, the timer handle is cleared using GetWorld()->GetTimerManager().ClearTimer(TimerHandle_SessionEnd). This handle is associated with a timer set by the operating system device to manage the device state and perform actions such as restarting the device.
The documentation for this class was generated from the following files: