VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVreExternalLoadingPageLogic Class Reference

Detailed Description

DtVreExternalLoadingPageLogic manages a separate process that displays a loading screen with a progress bar. It communicates with this process via TCP sockets to update loading status, progress, and estimated completion time. This allows resource-intensive operations like terrain loading to display progress without blocking the main application.

#include <vreExternalLoadingPageLogic.h>

Inheritance diagram for makVre::DtVreExternalLoadingPageLogic:
[legend]

Public Slots

virtual void newConnection ()
 
void gotDisconnection ()
 
void readClient ()
 

Signals

void smbDisconnected ()
 

Public Member Functions

 DtVreExternalLoadingPageLogic ()
 
virtual ~DtVreExternalLoadingPageLogic () override
 
virtual void initializeServer (unsigned short int port=0)
 
virtual void initializeProcess (int timeoutTime, int currentTime, int seed, const QString &initialMessage="Loading...")
 
virtual void shutdown ()
 
virtual void sendStatus (const QString &msg)
 
virtual void sendCurrentTime (int ms)
 
virtual void sendMaximumTime (int ms)
 
virtual bool isLoadingScreenReady ()
 

Protected Member Functions

virtual void sendData (const QString &msg)
 

Protected Attributes

QList< QTcpSocket * > myClients
 
std::shared_ptr< QTcpServer > myTCPServer
 
quint16 myNextBlockSize
 
QProcess myProcess
 
bool myScreenReady
 

Constructor & Destructor Documentation

◆ DtVreExternalLoadingPageLogic()

makVre::DtVreExternalLoadingPageLogic::DtVreExternalLoadingPageLogic ( )

Constructor.

Creates a new external loading page logic manager with default state.

◆ ~DtVreExternalLoadingPageLogic()

virtual makVre::DtVreExternalLoadingPageLogic::~DtVreExternalLoadingPageLogic ( )
overridevirtual

Destructor.

Cleans up resources, including shutting down the TCP server and terminating the external process if they are still running.

Member Function Documentation

◆ initializeServer()

virtual void makVre::DtVreExternalLoadingPageLogic::initializeServer ( unsigned short int port = 0)
virtual

Initializes the TCP server for loading screen communication.

Parameters
portSpecific port to use for the server, or 0 to use process ID

Sets up the TCP server that will communicate with the external loading screen process. If port is 0, the server will use the current process ID as the port number to avoid conflicts with other instances.

◆ initializeProcess()

virtual void makVre::DtVreExternalLoadingPageLogic::initializeProcess ( int timeoutTime,
int currentTime,
int seed,
const QString & initialMessage = "Loading..." )
virtual

Starts the external loading page process.

Parameters
timeoutTimeMaximum expected loading time in milliseconds
currentTimeCurrent loading progress in milliseconds
seedRandom seed for loading screen visuals
initialMessageInitial status message to display

Launches the external loading screen process with initial parameters. The process will display a progress bar based on the current and maximum times, along with the provided status message. The seed parameter can be used to generate consistent random visuals across multiple launches.

◆ shutdown()

virtual void makVre::DtVreExternalLoadingPageLogic::shutdown ( )
virtual

Shuts down the external process and TCP server.

Terminates the external loading screen process if it's running and stops the TCP server. This should be called when loading is complete or if the loading operation is canceled.

◆ sendStatus()

virtual void makVre::DtVreExternalLoadingPageLogic::sendStatus ( const QString & msg)
virtual

Sends a status message to the loading screen.

Parameters
msgText message to display on the loading screen

Updates the status text displayed on the loading screen. This is typically used to indicate the current operation being performed, such as "Loading terrain..." or "Initializing entities...".

◆ sendCurrentTime()

virtual void makVre::DtVreExternalLoadingPageLogic::sendCurrentTime ( int ms)
virtual

Updates the current progress time.

Parameters
msCurrent progress time in milliseconds

Updates the current progress value displayed on the loading screen. This affects the position of the progress bar indicator and any numerical progress display. The value should be between 0 and the maximum time set with sendMaximumTime().

◆ sendMaximumTime()

virtual void makVre::DtVreExternalLoadingPageLogic::sendMaximumTime ( int ms)
virtual

Sets the maximum expected loading time.

Parameters
msMaximum loading time in milliseconds

Updates the maximum expected loading time for the progress bar. This affects the scale of the progress bar, allowing it to provide an accurate visual representation of progress. The current time sent with sendCurrentTime() will be shown as a proportion of this maximum.

◆ isLoadingScreenReady()

virtual bool makVre::DtVreExternalLoadingPageLogic::isLoadingScreenReady ( )
virtual

Checks if the loading screen is ready.

Returns
True if the loading screen is connected and ready, false otherwise

Determines whether the external loading screen process has connected to the TCP server and is ready to receive updates. This can be used to ensure the loading screen is functioning before attempting to send status or progress updates.

◆ newConnection

virtual void makVre::DtVreExternalLoadingPageLogic::newConnection ( )
virtualslot

Handles new client connections to the TCP server.

Slot called when a new client (the loading screen process) connects to the TCP server. Sets up the connection and updates the internal state to reflect the connection.

◆ gotDisconnection

void makVre::DtVreExternalLoadingPageLogic::gotDisconnection ( )
slot

Handles client disconnections.

Slot called when a client disconnects from the TCP server. Updates the internal state and emits the smbDisconnected signal.

◆ readClient

void makVre::DtVreExternalLoadingPageLogic::readClient ( )
slot

Processes data received from clients.

Slot called when data is received from a connected client. Parses and processes the messages sent by the loading screen process.

◆ smbDisconnected

void makVre::DtVreExternalLoadingPageLogic::smbDisconnected ( )
signal

Signal emitted when a client disconnects.

This signal is emitted when the loading screen process disconnects from the TCP server. It can be used by the application to respond to unexpected disconnections.

◆ sendData()

virtual void makVre::DtVreExternalLoadingPageLogic::sendData ( const QString & msg)
protectedvirtual

Sends data to all connected clients.

Parameters
msgMessage to send to clients

Internal method that handles the low-level details of sending messages to all connected clients. This is used by the public methods to communicate with the loading screen process.

Member Data Documentation

◆ myClients

QList<QTcpSocket*> makVre::DtVreExternalLoadingPageLogic::myClients
protected

List of connected client sockets.

Contains pointers to all TCP socket connections to clients. Typically there will be only one client (the loading screen process).

◆ myTCPServer

std::shared_ptr<QTcpServer> makVre::DtVreExternalLoadingPageLogic::myTCPServer
protected

TCP server for communicating with the loading screen.

Manages the TCP server that listens for connections from the external loading screen process.

◆ myNextBlockSize

quint16 makVre::DtVreExternalLoadingPageLogic::myNextBlockSize
protected

Size of the next block to read.

Used during message parsing to determine the size of the next block of data to read from the socket.

◆ myProcess

QProcess makVre::DtVreExternalLoadingPageLogic::myProcess
protected

External process for the loading screen.

Manages the external process that displays the loading screen.

◆ myScreenReady

bool makVre::DtVreExternalLoadingPageLogic::myScreenReady
protected

Flag indicating whether the loading screen is ready.

When true, indicates that the loading screen process has connected to the TCP server and is ready to receive updates.


The documentation for this class was generated from the following file: