48 Log::trace(
'ActionLoading constructor started - PID: ' . $currentPid);
50 $bearsamppWinbinder->reset();
54 Log::trace(
'Loading PID added to tracking file: ' . $currentPid);
59 $screenWidth = intval($screenArea[2]);
60 $screenHeight = intval($screenArea[3]);
61 $xPos = $screenWidth - self::WINDOW_WIDTH;
62 $yPos = $screenHeight - self::WINDOW_HEIGHT - 5;
63 Log::trace(
'Screen dimensions: ' . $screenWidth .
'x' . $screenHeight .
', Window position: (' . $xPos .
',' . $yPos .
')');
67 $this->wbWindow = $bearsamppWinbinder->createWindow(
null, ToolDialog,
null, $xPos, $yPos, self::WINDOW_WIDTH, self::WINDOW_HEIGHT, WBC_TOP,
null);
70 if ($this->wbWindow ===
false || $this->wbWindow ===
null) {
71 Log::error(
'CRITICAL: Failed to create loading window - window handle is: ' . var_export($this->wbWindow,
true));
72 Log::error(
'WinBinder extension loaded: ' . (extension_loaded(
'winbinder') ?
'YES' :
'NO'));
73 Log::error(
'wb_create_window function exists: ' . (function_exists(
'wb_create_window') ?
'YES' :
'NO'));
77 Log::trace(
'Loading window created successfully - handle: ' . $this->wbWindow);
81 Log::trace(
'Making window visible with wb_set_visible()');
82 wb_set_visible($this->wbWindow,
true);
86 $bearsamppWinbinder->drawImage($this->wbWindow,
$bearsamppCore->getImagesPath() .
'/bearsampp.bmp');
90 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE + 1, 42, 24, self::WINDOW_WIDTH - 62, 15);
91 Log::trace(
'Progress bar created: ' . var_export($this->wbProgressBar,
true));
94 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'', 42, 0, self::WINDOW_WIDTH - 64, 25);
95 Log::trace(
'Label created: ' . var_export($this->wbLabel,
true));
99 $bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processLoading', 10);
100 Log::trace(
'Handler set, starting main loop...');
101 $bearsamppWinbinder->mainLoop();
114 for ($i = 0; $i < $nb; $i++) {
115 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
116 $bearsamppWinbinder->drawImage($this->wbWindow,
$bearsamppCore->getImagesPath() .
'/bearsampp.bmp', 4, 2, 32, 32);
119 $bearsamppWinbinder->wait();
120 $bearsamppWinbinder->wait($this->wbWindow);
147 $startTime = microtime(
true);
148 $maxLoadingTime = 15;
150 while ($iterations < $maxIterations && (microtime(
true) - $startTime) < $maxLoadingTime) {
152 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
156 for ($i = 0; $i < self::GAUGE && (microtime(
true) - $startTime) < $maxLoadingTime; $i++) {
167 if ($allServicesStarted) {
168 Log::trace(
'All services started successfully');
173 Log::trace(
'Loading iteration ' . $iterations .
' completed, checking services again');
176 if ($iterations >= $maxIterations) {
177 Log::trace(
'Maximum iterations reached (' . $maxIterations .
'), some services may not have started properly');
180 if ((microtime(
true) - $startTime) >= $maxLoadingTime) {
181 Log::trace(
'Loading timeout reached (' . $maxLoadingTime .
' seconds), some services may not have started properly');
212 $statusFile =
$bearsamppCore->getTmpPath() .
'/loading_status.txt';
214 if (file_exists($statusFile)) {
215 $content = @file_get_contents($statusFile);
216 if ($content !==
false && !empty($content)) {
217 $status = @json_decode($content,
true);
218 if ($status && isset($status[
'text']) && !empty($status[
'text'])) {
220 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
221 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow, $status[
'text'], 42, 0, self::WINDOW_WIDTH - 64, 25);
227 if (empty($currentText)) {
228 $bearsamppWinbinder->drawRect($this->wbWindow, 42, 0, self::WINDOW_WIDTH - 52, 25);
229 $this->wbLabel = $bearsamppWinbinder->drawText($this->wbWindow,
'Processing...', 42, 0, self::WINDOW_WIDTH - 64, 25);