Class SaveTerrainUserToolStateBase<TScreen, TCallback>
Provides a base class for user tool states that manage saving terrain data through a UI screen and callback mechanism.
Inheritance
Implements
Inherited Members
Namespace: Fwt.HexTerrains.UserTools.SM.States
Assembly: fwt.hexterrains.dll
Syntax
public abstract class SaveTerrainUserToolStateBase<TScreen, TCallback> : HexTerrainUserToolStateBase, ISmState where TScreen : UIScreen, IViewDataReceiver<TCallback> where TCallback : SaveTerrainCallbackDataSource, new()
Type Parameters
| Name | Description |
|---|---|
| TScreen | The type of UI screen used to display save terrain controls. Must implement UIScreen and receive view data of type TCallback. |
| TCallback | The type of callback data source used to handle save and cancel operations for terrain saving. Must inherit from SaveTerrainCallbackDataSource and have a parameterless constructor. |
Remarks
This class coordinates the interaction between the terrain saving workflow and the user interface, including showing and hiding the relevant UI screen and managing callbacks for save and cancel actions. Derived classes can override virtual members to customize UI behavior or callback handling. The class is intended to be used within a state machine managing user tool states.
Constructors
SaveTerrainUserToolStateBase(ISmState)
Declaration
protected SaveTerrainUserToolStateBase(ISmState parent)
Parameters
| Type | Name | Description |
|---|---|---|
| ISmState | parent |
Properties
CallbackDataSource
Gets or sets the callback data source used to provide data for callback operations.
Declaration
protected virtual TCallback CallbackDataSource { get; set; }
Property Value
| Type | Description |
|---|---|
| TCallback |
Remarks
Derived classes can override this property to customize how callback data is supplied or managed. The value should be set before initiating any operations that depend on the callback data source.
Screen
Gets or sets the current screen instance associated with the object.
Declaration
protected virtual TScreen Screen { get; set; }
Property Value
| Type | Description |
|---|---|
| TScreen |
Remarks
Derived classes can override this property to provide custom screen management behavior. The value may be null if no screen is currently assigned.
UserToolType
Type identifier for the user tool. Allows state machine to change states based on tool type instead of state index.
Declaration
public override int UserToolType { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
CancelLoading()
Cancels the current loading operation and switches the parent state machine to the pointer tool state.
Declaration
protected virtual void CancelLoading()
Remarks
Override this method to customize the behavior when a loading operation is cancelled. This method is typically called in response to user actions that interrupt or abort loading processes.
CreateScreenCallback()
Creates and initializes a new instance of the screen callback object with default save and cancel actions.
Declaration
protected virtual TCallback CreateScreenCallback()
Returns
| Type | Description |
|---|---|
| TCallback | A new instance of |
GetCallbackDataSource()
Retrieves the current callback data source, creating it if it does not already exist.
Declaration
protected virtual TCallback GetCallbackDataSource()
Returns
| Type | Description |
|---|---|
| TCallback | The callback data source instance of type |
Remarks
This method ensures that the callback data source is initialized before returning it. Derived classes may override this method to customize the initialization or retrieval logic.
GetUIScreen()
Retrieves the current UI screen instance of type TScreen. If the screen does not
exist, a new instance is created and returned.
Declaration
protected virtual TScreen GetUIScreen()
Returns
| Type | Description |
|---|---|
| TScreen | The UI screen instance of type |
Remarks
Subsequent calls return the same instance unless the screen is reset externally. This method is typically used to access or initialize the UI screen for interaction or display purposes.
HideUIScreen()
Hides the associated UI screen if it is currently visible.
Declaration
protected virtual void HideUIScreen()
Remarks
Override this method to customize the behavior when hiding the UI screen. This method does nothing if the screen reference is null.
PrepareToRun()
Performs any necessary initialization or setup required before executing the main operation. Called by state machine once when state becomes active. If state is disabled and then enabled again, this method will be called again.
Declaration
public override void PrepareToRun()
Overrides
Remarks
Override this method to implement preparation logic specific to the derived class. This method should be called prior to running the core functionality to ensure all prerequisites are met.
PrepareToStop()
Performs any necessary actions to prepare the object for stopping or shutdown. Called when the state is about to be deactivated.
Declaration
public override void PrepareToStop()
Overrides
Remarks
Implementations should ensure that all resources are released and any ongoing operations are safely terminated before the object is stopped. This method is typically called prior to disposing or shutting down the object to ensure a clean transition.
SaveTerrain(string)
Saves the current terrain data to the specified file path.
Declaration
public virtual void SaveTerrain(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The path of the file where the terrain data will be saved. Must be a valid, writable file path. |
Remarks
After saving, the active user tool is reset to the pointer tool. If the parent state machine is not set, the tool will not be switched.
ShowUIScreen()
Displays the associated UI screen and updates its view data using the current callback data source.
Declaration
protected virtual void ShowUIScreen()
Remarks
Override this method to customize how the UI screen is shown or how its view data is set. If no UI screen is available, the method performs no action.