Compare commits
3 Commits
master
...
fix/renderer
| Author | SHA1 | Date | |
|---|---|---|---|
| b1942e675a | |||
| e2455be738 | |||
| ef9c040204 |
@@ -273,6 +273,8 @@ class Game
|
|||||||
$v->save($this->getEntityManager());
|
$v->save($this->getEntityManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$v->setTwigSceneRenderer($this->getSceneRenderer());
|
||||||
|
|
||||||
return $v;
|
return $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ use Doctrine\ORM\Mapping\JoinColumn;
|
|||||||
use Doctrine\ORM\Mapping\ManyToOne;
|
use Doctrine\ORM\Mapping\ManyToOne;
|
||||||
use Doctrine\ORM\Mapping\OneToOne;
|
use Doctrine\ORM\Mapping\OneToOne;
|
||||||
use Doctrine\ORM\Mapping\Table;
|
use Doctrine\ORM\Mapping\Table;
|
||||||
|
use Doctrine\ORM\Mapping\PostLoad;
|
||||||
|
use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
|
||||||
|
|
||||||
use LotGD\Core\Action;
|
use LotGD\Core\Action;
|
||||||
use LotGD\Core\ActionGroup;
|
use LotGD\Core\ActionGroup;
|
||||||
@@ -28,6 +30,7 @@ use LotGD\Core\Tools\SceneDescription;
|
|||||||
* all changes from modules included.
|
* all changes from modules included.
|
||||||
* @Entity
|
* @Entity
|
||||||
* @Table(name="viewpoints")
|
* @Table(name="viewpoints")
|
||||||
|
* @HasLifecycleCallbacks
|
||||||
*/
|
*/
|
||||||
class Viewpoint implements CreateableInterface
|
class Viewpoint implements CreateableInterface
|
||||||
{
|
{
|
||||||
@@ -69,6 +72,16 @@ class Viewpoint implements CreateableInterface
|
|||||||
"owner",
|
"owner",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @PostLoad
|
||||||
|
*/
|
||||||
|
public function onLoad()
|
||||||
|
{
|
||||||
|
foreach ($this->actionGroups as $actionGroup) {
|
||||||
|
$actionGroup->setViewpoint($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the owner.
|
* Returns the owner.
|
||||||
* @return Character
|
* @return Character
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace LotGD\Core\Services;
|
namespace LotGD\Core\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Exception as DBALException;
|
||||||
use LotGD\Core\Action;
|
use LotGD\Core\Action;
|
||||||
use LotGD\Core\Events\EventContextData;
|
use LotGD\Core\Events\EventContextData;
|
||||||
use LotGD\Core\Exceptions\CharacterNotFoundException;
|
use LotGD\Core\Exceptions\CharacterNotFoundException;
|
||||||
@@ -35,8 +36,14 @@ class TwigSceneRenderer
|
|||||||
// the viewpoint itself.
|
// the viewpoint itself.
|
||||||
$eventManager = $this->game->getEventManager();
|
$eventManager = $this->game->getEventManager();
|
||||||
$contextData = EventContextData::create(["templateValues" => []]);
|
$contextData = EventContextData::create(["templateValues" => []]);
|
||||||
$newContextData = $eventManager->publish("h/lotgd/core/scene-renderer/templateValues", $contextData);
|
|
||||||
$this->templateValues = $newContextData->get("templateValues") ?? [];
|
// Use try-catch here in case no database has yet been created. See #162
|
||||||
|
try {
|
||||||
|
$newContextData = $eventManager->publish("h/lotgd/core/scene-renderer/templateValues", $contextData);
|
||||||
|
$this->templateValues = $newContextData->get("templateValues") ?? [];
|
||||||
|
} catch (DBALException) {
|
||||||
|
$this->templateValues = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Add Sandbox extension
|
// Add Sandbox extension
|
||||||
$securityPolicy = $this->getSecurityPolicy();
|
$securityPolicy = $this->getSecurityPolicy();
|
||||||
@@ -125,7 +132,13 @@ class TwigSceneRenderer
|
|||||||
"methods" => $methods,
|
"methods" => $methods,
|
||||||
"properties" => $properties,
|
"properties" => $properties,
|
||||||
]);
|
]);
|
||||||
$newContextData = $eventManager->publish("h/lotgd/core/scene-renderer/securityPolicy", $contextData);
|
|
||||||
|
// Use try-catch here in case no database has yet been created. See #162
|
||||||
|
try {
|
||||||
|
$newContextData = $eventManager->publish("h/lotgd/core/scene-renderer/securityPolicy", $contextData);
|
||||||
|
} catch (DBALException) {
|
||||||
|
$this->templateValues = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Set changed values from the event.
|
// Set changed values from the event.
|
||||||
$tags = $newContextData->get("tags");
|
$tags = $newContextData->get("tags");
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ class ViewpointTest extends CoreModelTestCase
|
|||||||
$this->assertSame($should->getTitle(), $is->getTitle());
|
$this->assertSame($should->getTitle(), $is->getTitle());
|
||||||
$this->assertSame($should->getSortKey(), $is->getSortKey());
|
$this->assertSame($should->getSortKey(), $is->getSortKey());
|
||||||
$this->assertSame(count($should->getActions()), count($is->getActions()));
|
$this->assertSame(count($should->getActions()), count($is->getActions()));
|
||||||
|
|
||||||
|
$this->assertSame($output, $is->getViewpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($ag2->getTitle(), $input->findActionGroupById('id2')->getTitle());
|
$this->assertEquals($ag2->getTitle(), $input->findActionGroupById('id2')->getTitle());
|
||||||
|
|||||||
Reference in New Issue
Block a user