46 using std::make_unique;
48 using std::unique_ptr;
120 if (fileName.empty() ==
true)
throw ExceptionBase(
"Could not save file. No filename known");
122 Tools::getPathName(fileName),
123 Tools::getFileName(fileName)
132 class OnDecalSave:
public virtual Action
135 void performAction()
override {
137 decalEditorTabController->view->saveFile(
138 decalEditorTabController->popUps->getFileDialogScreenController()->getPathName(),
139 decalEditorTabController->popUps->getFileDialogScreenController()->getFileName()
142 decalEditorTabController->showInfoPopUp(
"Warning",
string(exception.what()));
144 decalEditorTabController->popUps->getFileDialogScreenController()->close();
146 OnDecalSave(
DecalEditorTabController* decalEditorTabController): decalEditorTabController(decalEditorTabController) {
153 vector<string> extensions = {
157 fileName.empty() ==
false?Tools::getPathName(fileName):
string(),
160 Tools::getFileName(fileName),
162 new OnDecalSave(
this)
167 showInfoPopUp(
"Warning",
"This command is not supported yet");
175 if (StringTools::startsWith(payload,
"file:") ==
false) {
178 auto fileName = StringTools::substring(payload,
string(
"file:").size());
180 if (Tools::hasFileExtension(fileName, TextureReader::getTextureExtensions()) ==
false) {
181 showInfoPopUp(
"Warning",
"You can not drop this file here. Allowed file extensions are " + Tools::enumerateFileExtensions(TextureReader::getTextureExtensions()));
199 if (node->
getId() == applyDecalNode) {
205 if (node->
getId() ==
"selectbox_outliner") {
225 int tooltipLeft, tooltipTop;
243 if (node->
getId() ==
"decal_texture_open") {
245 class OnDecalTextureFileOpenAction:
public virtual Action
248 void performAction()
override {
249 decalEditorTabController->setDecalTexture(
250 decalEditorTabController->view->getPopUps()->getFileDialogScreenController()->getPathName() +
252 decalEditorTabController->view->getPopUps()->getFileDialogScreenController()->getFileName()
254 decalEditorTabController->view->getPopUps()->getFileDialogScreenController()->close();
261 OnDecalTextureFileOpenAction(
DecalEditorTabController* decalEditorTabController): decalEditorTabController(decalEditorTabController) {
269 if (prototype ==
nullptr)
return;
271 if (decal ==
nullptr)
return;
272 vector<string> extensions = TextureReader::getTextureExtensions();
274 decal->getTextureFileName().empty() ==
false?Tools::getPathName(decal->getTextureFileName()):
string(),
275 "Load decal texture from: ",
277 Tools::getFileName(decal->getTextureFileName()),
279 new OnDecalTextureFileOpenAction(
this)
282 if (node->
getId() ==
"decal_texture_remove") {
284 if (prototype ==
nullptr)
return;
286 if (decal ==
nullptr)
return;
288 prototype->setThumbnail(
string());
289 required_dynamic_cast<GUIImageNode*>(
screenNode->
getNodeById(
"decal_texture"))->setSource(prototype->getDecal()->getTextureFileName());
290 required_dynamic_cast<GUIImageNode*>(
screenNode->
getNodeById(
"decal_texture"))->setTooltip(prototype->getDecal()->getTextureFileName());
292 if (node->
getId() ==
"decal_texture_browseto") {
294 if (prototype ==
nullptr)
return;
296 if (decal !=
nullptr && decal->getTextureFileName().empty() ==
false) {
308 if (prototype ==
nullptr)
return;
310 auto decal = prototype !=
nullptr?prototype->
getDecal():
nullptr;
311 if (decal ==
nullptr)
return;
316 if (decal->getTexture() ==
nullptr) {
317 showInfoPopUp(
"Warning",
"Unsupported file format or corrupt file");
320 auto decalTextureThumbnail = TextureReader::scale(decal->getTexture(), 128, 128);
321 vector<uint8_t> pngData;
322 string base64PNGData;
323 PNGTextureWriter::write(decalTextureThumbnail, pngData,
false,
false);
324 Base64::encode(pngData, base64PNGData);
325 prototype->setThumbnail(base64PNGData);
326 decalTextureThumbnail->releaseReference();
329 physicsSubView->applyBoundingVolumeObb(
333 OrientedBoundingBox::AABB_AXIS_X,
334 OrientedBoundingBox::AABB_AXIS_Y,
335 OrientedBoundingBox::AABB_AXIS_Z,
337 0.5f * (
static_cast<float>(decal->getTexture()->getWidth()) /
static_cast<float>(decal->getTexture()->getHeight())),
342 physicsSubView->updateGizmo(prototype);
345 Console::println(
"OnDecalTextureFileOpenAction::performAction(): An error occurred: " +
string(exception.what()));
354 xml+=
"<selectbox-parent-option image=\"resources/engine/images/folder.png\" text=\"" + GUIParser::escape(
"Prototype") +
"\" value=\"" + GUIParser::escape(
"prototype") +
"\">\n";
356 if (prototype !=
nullptr) {
357 xml+=
"<selectbox-option text=\"" + GUIParser::escape(
"Decal") +
"\" value=\"" + GUIParser::escape(
"decal") +
"\" />\n";
362 xml+=
"</selectbox-parent-option>\n";
368 string(
"<dropdown-option text=\"Property\" value=\"property\" />\n") +
369 string(
"<dropdown-option text=\"BV\" value=\"boundingvolume\" />\n")
375 "<template id=\"details_decal\" src=\"resources/engine/gui/template_details_decal.xml\" />\n"
379 if (prototype ==
nullptr)
return;
381 if (decal ==
nullptr)
return;
385 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"details_decal"))->getActiveConditions().add(
"open");
386 required_dynamic_cast<GUIImageNode*>(
screenNode->
getNodeById(
"decal_texture"))->setSource(decal->getTextureFileName());
387 required_dynamic_cast<GUIImageNode*>(
screenNode->
getNodeById(
"decal_texture"))->setTooltip(decal->getTextureFileName());
388 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"decal_texture_horizontal_sprites"))->getController()->setValue(
MutableString(decal->getTextureHorizontalSprites()));
389 required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"decal_texture_vertical_sprites"))->getController()->setValue(
MutableString(decal->getTextureVerticalSprites()));
392 Console::println(
"DecalEditorTabController::setDecalDetails(): An error occurred: " +
string(exception.what()));
398 if (outlinerNode ==
"decal") {
412 if (prototype ==
nullptr)
return;
414 if (decal ==
nullptr)
return;
417 decal->setTextureVerticalSprites(Math::max(1, Integer::parse(required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"decal_texture_vertical_sprites"))->getController()->getValue().getString())));
418 decal->setTextureSpritesFPS(Float::parse(required_dynamic_cast<GUIElementNode*>(
screenNode->
getNodeById(
"decal_texture_fps"))->getController()->getValue().getString()));
PNG texture writer class.
Oriented bounding box physics primitive.
void setTextureHorizontalSprites(int textureHorizontalSprites)
Set texture horizontal number of sprites.
void setTextureFileName(const string &textureFileName, const string &transparencyTextureFileName=string())
Set texture file name with optional transparency texture.
const string & getFileName()
PrototypeDecal * getDecal()
GUI node controller base class.
const string & getToolTip()
GUI screen node that represents a screen that can be rendered via GUI system.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Base64 encoding/decoding class.
Mutable utf8 aware string class.
std::exception Exception
Exception base class.