Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.splash.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2026 Bearsampp
4 * License: GNU General Public License version 3 or later; see LICENSE.txt
5 * Author: Bear
6 * Website: https://bearsampp.com
7 * Github: https://github.com/Bearsampp
8 */
9
16class Splash
17{
18 /* Set progress bar "loading" modal size. */
19 const WINDOW_WIDTH = 460;
20 const WINDOW_HEIGHT = 90;
21
23 private $wbWindow;
25 private $wbImage;
30
32 private $currentImg;
33
39 public function __construct()
40 {
41 Log::initClass($this);
42 $this->currentImg = null;
43 }
44
52 public function init($title, $gauge, $text)
53 {
54 global $bearsamppCore, $bearsamppWinbinder;
55
56 $bearsamppWinbinder->reset();
57
58 $screenArea = explode(' ', $bearsamppWinbinder->getSystemInfo(WinBinder::SYSINFO_WORKAREA));
59 $screenWidth = intval($screenArea[2]);
60 $screenHeight = intval($screenArea[3]);
61 $xPos = $screenWidth - self::WINDOW_WIDTH;
62 $yPos = $screenHeight - self::WINDOW_HEIGHT - 5;
63
64 $this->wbWindow = $bearsamppWinbinder->createWindow(null, ToolDialog, $title, $xPos, $yPos, self::WINDOW_WIDTH, self::WINDOW_HEIGHT, WBC_TOP | WBC_READONLY, null);
65
66 // Check if window was created successfully
67 if ($this->wbWindow === false || $this->wbWindow === null) {
68 Log::error('Failed to create splash window');
69
70 return;
71 }
72
73 // CRITICAL: wb_set_visible() must be called AFTER window creation in PHP 8.4
74 // The WS_VISIBLE flag during creation doesn't work
75 wb_set_visible($this->wbWindow, true);
76
77 $this->wbImage = $bearsamppWinbinder->drawImage($this->wbWindow, Path::getImagesPath() . '/bearsampp.bmp');
78 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, $gauge + 1, 42, 24, 390, 15);
79
80 $this->setTextLoading($text);
81 $this->incrProgressBar();
82 }
83
89 public function setTextLoading($caption)
90 {
91 global $bearsamppWinbinder;
92
93 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 42, self::WINDOW_HEIGHT);
94 $this->wbTextLoading = $bearsamppWinbinder->drawText($this->wbWindow, $caption, 42, 0, self::WINDOW_WIDTH - 44, 25);
95 }
96
102 public function incrProgressBar($nb = 1)
103 {
104 global $bearsamppCore, $bearsamppWinbinder;
105
106 for ($i = 0; $i < $nb; $i++) {
107 $bearsamppWinbinder->drawImage($this->wbWindow, Path::getImagesPath() . '/bearsampp.bmp', 4, 4, 32, 32);
108 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
109 }
110
111 $bearsamppWinbinder->wait();
112 $bearsamppWinbinder->wait($this->wbWindow);
113 }
114
120 public function getWbWindow()
121 {
122 return $this->wbWindow;
123 }
124}
global $bearsamppCore
static error($data, $file=null)
static initClass($classInstance)
static getImagesPath($aetrayPath=false)
setTextLoading($caption)
const WINDOW_HEIGHT
init($title, $gauge, $text)
const WINDOW_WIDTH
incrProgressBar($nb=1)
const SYSINFO_WORKAREA