error label for 'no access' and info label for 'empty directory'

This commit is contained in:
steeffeen 2014-07-05 12:34:55 +02:00
parent 2cca641d2e
commit c506c7b0da

View File

@ -3,6 +3,7 @@
namespace ManiaControl\Maps;
use FML\Controls\Frame;
use FML\Controls\Label;
use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quads\Quad_BgsPlayerCard;
@ -154,6 +155,14 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$mapFiles = $this->scanMapFiles($folderPath);
if (is_array($mapFiles)) {
if (empty($mapFiles)) {
$emptyLabel = new Label();
$frame->add($emptyLabel);
$emptyLabel->setY(20)
->setTextColor('aaa')
->setText('No files found.')
->setTranslate(true);
} else {
foreach ($mapFiles as $filePath => $fileName) {
$shortFilePath = substr($filePath, strlen($folderPath));
@ -203,6 +212,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
->setSize(3, 3)
->setTextSize(2)
->setText('Add')
->setTranslate(true)
->setAction(self::ACTION_ADD_FILE);
}
@ -214,6 +224,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
->setSize(3, 3)
->setTextSize(2)
->setText('Erase')
->setTranslate(true)
->setAction(self::ACTION_ERASE_FILE);
}
}
@ -221,8 +232,14 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
$posY -= 4;
$index++;
}
}
} else {
// TODO: show error label
$errorLabel = new Label();
$frame->add($errorLabel);
$errorLabel->setY(20)
->setTextColor('f30')
->setText('No access to the directory.')
->setTranslate(true);
}
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, self::WIDGET_NAME);