Skip to content

mrsalimi01/Splash

Β 
Β 

Repository files navigation

Splash Screen System for Delphi

A sophisticated dual-process splash screen system for Delphi applications featuring automatic progress calculation through adaptive learning algorithms.

Delphi Platform License

Features

  • πŸš€ Dual-Process Architecture: Splash screen runs in a separate process, ensuring smooth 60 FPS animations even during blocking operations
  • 🧠 Adaptive Learning: Automatically learns loading patterns and calculates progress percentages from timing data
  • ✨ Modern UI: Skia-powered graphics with gradients, shadows, and smooth animations
  • πŸ“Š Zero Configuration: Works out-of-the-box without predefined progress values
  • πŸ”„ Self-Improving: Becomes more accurate with each application run
  • πŸ’Ύ Persistent Learning: Stores learning data between sessions for consistent user experience
  • πŸ›‘οΈ Robust IPC: Inter-process communication using memory-mapped files with mutex synchronization
  • 🎯 Auto-Termination: Splash screen automatically closes if parent process dies unexpectedly

Screenshots

The splash screen features a modern design with:

  • Gradient logo and text
  • Smooth progress bar animations
  • Dynamic status messages
  • Optional beta badge

Requirements

  • RAD Studio 12 (Delphi 29.0) or later
  • Windows 7 or later
  • Skia for Delphi (for graphics rendering)

Installation

  1. Clone the repository:
git clone https://github.com/JavierusTk/splash-screen-delphi.git
cd splash-screen-delphi
  1. Open SplashGroup.groupproj in RAD Studio

  2. Install Skia for Delphi from GetIt Package Manager if not already installed

  3. Build both projects:

    • First build SplashScreen.dproj (the splash screen executable)
    • Then build Test.dproj or TestAuto.dproj (the main applications)

Usage

Method 1: Auto-Start (Simplest) πŸš€

Just add AutoSplash to your uses clause and the splash screen starts automatically:

program MyApp;

uses
  AutoSplash,  // ← Just add this! Splash starts automatically
  Forms,
  MainForm;

begin
  Application.Initialize;
  
  // Update splash status anywhere in your code
  Splash.UpdateStatus('Loading database...');
  // ... your initialization code ...
  
  Application.CreateForm(TMainForm, MainForm);
  Application.Run;
  // Splash closes automatically
end.

With Configuration

Create a configuration unit (e.g., MyAppConfig.pas):

unit MyAppConfig;
interface
implementation
uses AutoSplashConfig;
initialization
  Config.AppName := 'My Application';
  Config.Version := '2.0';
  Config.ShowBeta := False;
end.

Then in your main program:

uses
  MyAppConfig,  // Your config (must be first!)
  AutoSplash,   // Reads Config during initialization
  Forms;

Note: Config changes in the main program have no effect since AutoSplash reads the configuration during unit initialization.

Method 2: Manual Control (Traditional)

  1. Copy the src/IPCShared.pas unit to your project
  2. Add IPC manager initialization to your main application:
uses
  IPCShared;

var
  IPCManager: TIPCManager;

begin
  // Create IPC manager and launch splash screen
  IPCManager := TIPCManager.Create;
  try
    IPCManager.LaunchSplashScreen;
    
    // Your initialization code here
    IPCManager.UpdateStatus('Loading configuration');
    // ... more initialization ...
    
    IPCManager.UpdateStatus('Loading modules');
    // ... more initialization ...
    
    // Close splash when ready
    IPCManager.CloseSplash;
    
    // Start your main application
    Application.Run;
  finally
    IPCManager.Free;
  end;
end.

Command Line Parameters

The splash screen executable supports several command line parameters:

SplashScreen.exe /pid:1234 [options]

Required:

  • /pid:xxxxx - Parent process ID (required for auto-termination)

Optional:

  • /APP:name - Application name (default: exe filename without extension)
  • /VER:version - Version string (default: "1.0")
  • /LOAD:text - Loading caption (default: "Loading")
  • /START:text - Starting status message
  • /BETA - Show beta badge
  • /LOGO:path - Path to custom logo file
  • /DEBUG - Enable debug logging to progress_debug.log
  • /DEBUG:filepath - Enable debug logging to custom file

Advanced Features

Status Updates Only (Recommended)

Let the system automatically calculate progress:

IPCManager.UpdateStatus('Initializing database');
IPCManager.UpdateStatus('Loading user preferences');
IPCManager.UpdateStatus('Preparing interface');

Manual Progress Control

Optionally provide explicit progress values:

IPCManager.UpdateProgress(25, 'Loading configuration');
IPCManager.UpdateProgress(50, 'Connecting to database');
IPCManager.UpdateProgress(75, 'Loading modules');

Architecture

Clean Architecture (After Refactoring)

The system follows the Single Responsibility Principle with specialized managers:

  • TfrmModernSplash: Thin form coordinator (~250 lines)
  • SplashRenderingManager: All visual rendering logic
  • SplashStyleProvider: Colors, fonts, and visual constants
  • SplashLayoutCalculator: Element positioning and layout
  • SplashLifecycleManager: Process lifecycle management
  • SplashAnimationController: Animation timing and interpolation
  • SplashProgressManager: Progress tracking and learning coordination

How It Works

Adaptive Learning System

The splash screen implements two learning systems that work together:

  1. Timing-Based Learning (ProgressLearning.pas)

    • Records duration of each loading phase
    • Calculates average durations and standard deviations
    • Automatically assigns progress percentages based on time ratios
    • Formula: Progress% = (PhaseDuration / TotalDuration) Γ— 100
  2. Progress-Based Learning (AdaptiveLearning.pas)

    • Maps status messages to progress values
    • Learns typical sequences and transitions
    • Handles variations in loading order
    • Provides statistical confidence scoring

Data Persistence

Learning data is stored in JSON format. The storage location is automatically determined by the executable name:

  • %APPDATA%\[YourAppName]\splash_history.json - Timing history
  • %APPDATA%\[YourAppName]\splash_learning.json - Progress mappings

For example:

  • MyApp.exe stores data in %APPDATA%\MyApp\
  • Test.exe stores data in %APPDATA%\Test\

Animation System

The progress bar uses a two-stage animation system:

  1. Primary Stage (0-75% of phase time): Fast movement to reach target percentage
  2. Creep Stage (75-100% of phase time): Gentle movement for smooth transitions

This ensures each phase visually reaches its target while maintaining fluid transitions between phases.

Project Structure

splash-screen-delphi/
β”œβ”€β”€ src/                      # Source files
β”‚   β”œβ”€β”€ IPCShared.pas        # Inter-process communication
β”‚   β”œβ”€β”€ AutoSplash.pas       # Auto-start splash unit (NEW!)
β”‚   β”œβ”€β”€ AutoSplashConfig.pas # Auto-splash configuration (NEW!)
β”‚   β”œβ”€β”€ ModernSplashForm.pas # Splash screen UI
β”‚   β”œβ”€β”€ ProgressLearning.pas # Timing-based learning
β”‚   β”œβ”€β”€ AdaptiveLearning.pas # Progress-based learning
β”‚   β”œβ”€β”€ DebugManager.pas     # Debug logging system
β”‚   └── SplashConfig.pas     # Configuration management
β”œβ”€β”€ Test.dpr                 # Manual control example
β”œβ”€β”€ TestAuto.dpr             # Auto-start example (NEW!)
β”œβ”€β”€ SplashScreen.dpr         # Splash screen project
β”œβ”€β”€ SplashGroup.groupproj    # Group project file
β”œβ”€β”€ SPLASH_SYSTEM.md         # Detailed system documentation
β”œβ”€β”€ LEARNING_SYSTEM.md       # Learning system documentation
└── README.md                # This file

Debugging

Enable debug logging to troubleshoot issues:

  1. Run with debug flag: YourApp.exe (splash will inherit debug mode)
  2. Check progress_debug.log in the application directory
  3. Review learning data in %APPDATA%\[YourAppName]\*.json

To reset learning data (replace YourAppName with your exe name):

del "%APPDATA%\YourAppName\*.json"

Example for Test.exe:

del "%APPDATA%\Test\*.json"

Documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Skia for Delphi for modern graphics rendering
  • Inspired by modern application loading screens with intelligent progress tracking

Support

For issues, questions, or suggestions, please open an issue on GitHub.

About

Automated Splash screen that keeps alive and autolearns progressbar speed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Pascal 100.0%