| 595 | } |
| 596 | |
| 597 | void ProjectControl::saveItemToProject() |
| 598 | { |
| 599 | MyGUI::UString name = EditorWidgets::getInstance().getCurrentFileName(); |
| 600 | |
| 601 | size_t index = name.find_last_of("\\/"); |
| 602 | name = (index == MyGUI::UString::npos) ? name : name.substr(index + 1); |
| 603 | |
| 604 | MyGUI::UString endName = ".layout"; |
| 605 | index = name.find(endName); |
| 606 | if (index != MyGUI::UString::npos && (index + endName.size()) == name.size()) |
| 607 | { |
| 608 | name = name.substr(0, index); |
| 609 | } |
| 610 | else |
| 611 | { |
| 612 | name = EditorWidgets::getInstance().getCurrentItemName(); |
| 613 | if (name.empty()) |
| 614 | name = "unnamed"; |
| 615 | } |
| 616 | |
| 617 | size_t indexItem = MyGUI::ITEM_NONE; |
| 618 | addItemToProject(name, indexItem); |
| 619 | |
| 620 | if (indexItem != MyGUI::ITEM_NONE) |
| 621 | { |
| 622 | MyGUI::UString fileName = MyGUI::utility::toString( |
| 623 | MyGUI::UString(common::concatenatePath(mProjectPath, mProjectName)), |
| 624 | "|", |
| 625 | indexItem); |
| 626 | CommandManager::getInstance().setCommandData(fileName); |
| 627 | CommandManager::getInstance().executeCommand("Command_SaveItemAs"); |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | bool ProjectControl::addItemToProject(const MyGUI::UString& _name, size_t& _index) |
| 632 | { |
nothing calls this directly
no test coverage detected