Table of Contents

Class PhoneApp

Namespace
S1API.PhoneApp
Assembly
S1API.dll

Abstract base class for creating custom applications to be used within an in-game phone system.

public abstract class PhoneApp : Registerable
Inheritance
PhoneApp
Inherited Members
Extension Methods

Remarks

This class provides an extensible framework for defining application behaviors, user interface elements, and registration mechanics for integration into the phone's ecosystem.

Constructors

PhoneApp()

protected PhoneApp()

Fields

Logger

Logger instance used for logging messages, warnings, or errors related to the functionality of in-game phone applications.

protected static readonly Log Logger

Field Value

Log

Properties

AppName

Gets the unique identifier for the application within the phone system.

protected abstract string AppName { get; }

Property Value

string

Remarks

This property is used as a key to identify the application when creating UI elements or interacting with other components of the in-game phone system. It must be implemented in derived classes to provide a consistent and unique name for the application.

AppTitle

Gets the display title of the application as it appears in the in-game phone system.

protected abstract string AppTitle { get; }

Property Value

string

Remarks

This property specifies the human-readable name of the application, different from the internal AppName that uniquely identifies the app within the system. It is displayed to the user on the application icon or within the application UI.

IconFileName

Specifies the file name of the icon used to represent the phone application in the in-game phone system.

protected abstract string IconFileName { get; }

Property Value

string

Remarks

The value of this property is typically a string containing the file name of the icon asset, such as "icon-name.png". It is used to identify and load the appropriate icon for the application.

IconLabel

Gets the label text displayed on the application's icon.

protected abstract string IconLabel { get; }

Property Value

string

A string representing the label text displayed under the app icon, which explains or identifies the app to the user.

Remarks

The IconLabel property is an abstract member that must be overridden by each implementation of the PhoneApp class. It specifies the label text shown directly below the application's icon on the in-game phone's home screen. This property is utilized when creating or modifying the app's icon, as part of the SpawnIcon method, to ensure that the label represents the application's name or a relevant description. The value should be concise and contextually meaningful to the user.

IconSprite

Optional direct icon sprite. If provided, it takes precedence over IconFileName.

protected virtual Sprite? IconSprite { get; }

Property Value

Sprite

Orientation

Gets the orientation of the phone app (Horizontal or Vertical). Determines how the phone is rotated when the app is opened.

protected virtual PhoneApp.EOrientation Orientation { get; }

Property Value

PhoneApp.EOrientation

Methods

CloseApp()

Closes this phone application, cleaning up its state.

public void CloseApp()

Exit(ExitAction)

Handles exit/home button functionality. Called when user presses escape or home.

public virtual void Exit(ExitAction exit)

Parameters

exit ExitAction

IsOpen()

Determines if this phone app is currently open.

public bool IsOpen()

Returns

bool

True if the app is open, false otherwise

OnCreated()

Invoked when the PhoneApp instance is created. Responsible for registering the app with the PhoneAppRegistry, integrating it into the in-game phone system.

protected override void OnCreated()

OnCreatedUI(GameObject)

Invoked to define the user interface layout when the application panel is created. The method is used to populate the provided container with custom UI elements specific to the application.

protected abstract void OnCreatedUI(GameObject container)

Parameters

container GameObject

The GameObject container where the application's UI elements will be added.

OnDestroyed()

Cleans up resources and resets state when the app is destroyed. This method ensures any associated UI elements and resources are properly disposed of and variables tracking the app state are reset.

protected override void OnDestroyed()

OnPhoneClosed()

Called when the in-game phone is closed. Override in derived apps to reset state.

protected virtual void OnPhoneClosed()

OpenApp()

Opens this phone application, managing proper app state transitions.

public void OpenApp()

SetIconSprite(Sprite)

Sets the app icon directly from a sprite, bypassing file loading. If the icon is not yet spawned, stores the sprite to apply later.

public bool SetIconSprite(Sprite sprite)

Parameters

sprite Sprite

Sprite to use for the app icon.

Returns

bool

True if applied immediately or stored for later application.

SetIconTexture(Texture2D)

Sets the app icon directly from a texture by creating a sprite.

public bool SetIconTexture(Texture2D texture)

Parameters

texture Texture2D

Texture to convert into a sprite for the app icon.

Returns

bool

True if applied or stored; false if texture is null.