Bearsampp 2026.3.26
API documentation
Loading...
Searching...
No Matches
class.splash.php
Go to the documentation of this file.
1<?php
2/*
3 * Copyright (c) 2021-2024 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
22 private $wbWindow;
23 private $wbImage;
26
27 private $currentImg;
28
34 public function __construct()
35 {
36 Util::logInitClass($this);
37 $this->currentImg = null;
38 }
39
47 public function init($title, $gauge, $text)
48 {
49 global $bearsamppCore, $bearsamppWinbinder;
50
51 $bearsamppWinbinder->reset();
52
53 $screenArea = explode(' ', $bearsamppWinbinder->getSystemInfo(WinBinder::SYSINFO_WORKAREA));
54 $screenWidth = intval($screenArea[2]);
55 $screenHeight = intval($screenArea[3]);
56 $xPos = $screenWidth - self::WINDOW_WIDTH;
57 $yPos = $screenHeight - self::WINDOW_HEIGHT - 5;
58
59 $this->wbWindow = $bearsamppWinbinder->createWindow(null, ToolDialog, $title, $xPos, $yPos, self::WINDOW_WIDTH, self::WINDOW_HEIGHT, WBC_TOP | WBC_READONLY, null);
60
61 // Check if window was created successfully
62 if ($this->wbWindow === false || $this->wbWindow === null) {
63 Util::logError('Failed to create splash window');
64 return;
65 }
66
67 // CRITICAL: wb_set_visible() must be called AFTER window creation in PHP 8.4
68 // The WS_VISIBLE flag during creation doesn't work
69 wb_set_visible($this->wbWindow, true);
70
71 $this->wbImage = $bearsamppWinbinder->drawImage($this->wbWindow, $bearsamppCore->getImagesPath() . '/bearsampp.bmp');
72 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, $gauge + 1, 42, 24, 390, 15);
73
74 $this->setTextLoading($text);
75 $this->incrProgressBar();
76 }
77
83 public function setTextLoading($caption)
84 {
85 global $bearsamppWinbinder;
86
87 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 42, self::WINDOW_HEIGHT);
88 $this->wbTextLoading = $bearsamppWinbinder->drawText($this->wbWindow, $caption, 42, 0, self::WINDOW_WIDTH - 44, 25);
89 }
90
96 public function incrProgressBar($nb = 1)
97 {
98 global $bearsamppCore, $bearsamppWinbinder;
99
100 for ($i = 0; $i < $nb; $i++) {
101 $bearsamppWinbinder->drawImage($this->wbWindow, $bearsamppCore->getImagesPath() . '/bearsampp.bmp', 4, 4, 32, 32);
102 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
103 }
104
105 $bearsamppWinbinder->wait();
106 $bearsamppWinbinder->wait($this->wbWindow);
107 }
108
114 public function getWbWindow()
115 {
116 return $this->wbWindow;
117 }
118}
global $bearsamppCore
setTextLoading($caption)
const WINDOW_HEIGHT
init($title, $gauge, $text)
const WINDOW_WIDTH
incrProgressBar($nb=1)
static logError($data, $file=null)
static logInitClass($classInstance)
const SYSINFO_WORKAREA