Compare commits
	
		
			2 Commits
		
	
	
		
			ff666eda9b
			...
			e8a0ce88c5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e8a0ce88c5 | |||
| 82e2ea747f | 
@@ -21,7 +21,7 @@ void NewMenu::open() noexcept {
 | 
				
			|||||||
	m_selectedType = 0;
 | 
						m_selectedType = 0;
 | 
				
			||||||
	m_itemName = "";
 | 
						m_itemName = "";
 | 
				
			||||||
	m_typeName = "";
 | 
						m_typeName = "";
 | 
				
			||||||
	m_path = "";
 | 
						m_useDefaultPath = true;
 | 
				
			||||||
	m_explorer.setModel(buildFileTreeModel(
 | 
						m_explorer.setModel(buildFileTreeModel(
 | 
				
			||||||
		m_explorer,
 | 
							m_explorer,
 | 
				
			||||||
		[](ox::StringViewCR, ox::FileStat const&s) {
 | 
							[](ox::StringViewCR, ox::FileStat const&s) {
 | 
				
			||||||
@@ -29,9 +29,10 @@ void NewMenu::open() noexcept {
 | 
				
			|||||||
		}).or_value(ox::UPtr<FileTreeModel>{}));
 | 
							}).or_value(ox::UPtr<FileTreeModel>{}));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void NewMenu::openPath(ox::StringParam path) noexcept {
 | 
					void NewMenu::openPath(ox::StringViewCR path) noexcept {
 | 
				
			||||||
	open();
 | 
						open();
 | 
				
			||||||
	m_path = std::move(path);
 | 
						m_useDefaultPath = false;
 | 
				
			||||||
 | 
						std::ignore = m_explorer.setSelectedPath(path);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void NewMenu::close() noexcept {
 | 
					void NewMenu::close() noexcept {
 | 
				
			||||||
@@ -93,10 +94,9 @@ void NewMenu::drawNewItemType(StudioContext const&sctx) noexcept {
 | 
				
			|||||||
		drawFirstPageButtons(im.itemTemplates().size() == 1 ?
 | 
							drawFirstPageButtons(im.itemTemplates().size() == 1 ?
 | 
				
			||||||
			Stage::NewItemTransitioningToPath : Stage::NewItemTemplate);
 | 
								Stage::NewItemTransitioningToPath : Stage::NewItemTemplate);
 | 
				
			||||||
		if (m_stage == Stage::NewItemTransitioningToPath || m_stage == Stage::NewItemTemplate) {
 | 
							if (m_stage == Stage::NewItemTransitioningToPath || m_stage == Stage::NewItemTemplate) {
 | 
				
			||||||
			if (m_path.len() == 0) {
 | 
								if (m_useDefaultPath) {
 | 
				
			||||||
				m_path = im.defaultPath();
 | 
									std::ignore = m_explorer.setSelectedPath(im.defaultPath());
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			std::ignore = m_explorer.setSelectedPath(m_path);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -192,11 +192,9 @@ void NewMenu::finish(StudioContext &sctx) noexcept {
 | 
				
			|||||||
		oxLogError(ox::Error{1, "New file error: no file name"});
 | 
							oxLogError(ox::Error{1, "New file error: no file name"});
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	auto const&im = *m_types[m_selectedType];
 | 
						auto const &im = *m_types[m_selectedType];
 | 
				
			||||||
	if (auto p = m_explorer.selectedPath()) {
 | 
						auto const path = sfmt("{}/{}.{}",
 | 
				
			||||||
		m_path = std::move(*p);
 | 
							m_explorer.selectedPath().or_value(ox::String{}), m_itemName, im.fileExt());
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	auto const path = sfmt("{}/{}.{}", m_path, m_itemName, im.fileExt());
 | 
					 | 
				
			||||||
	if (sctx.project->exists(path)) {
 | 
						if (sctx.project->exists(path)) {
 | 
				
			||||||
		oxLogError(ox::Error{1, "New file error: file already exists"});
 | 
							oxLogError(ox::Error{1, "New file error: file already exists"});
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,7 @@ class NewMenu final: public Popup {
 | 
				
			|||||||
		keel::Context &m_kctx;
 | 
							keel::Context &m_kctx;
 | 
				
			||||||
		ox::String m_typeName;
 | 
							ox::String m_typeName;
 | 
				
			||||||
		ox::IString<255> m_itemName;
 | 
							ox::IString<255> m_itemName;
 | 
				
			||||||
		ox::String m_path;
 | 
							bool m_useDefaultPath{};
 | 
				
			||||||
		ox::Vector<ox::UPtr<ItemMaker>> m_types;
 | 
							ox::Vector<ox::UPtr<ItemMaker>> m_types;
 | 
				
			||||||
		FileExplorer m_explorer{m_kctx};
 | 
							FileExplorer m_explorer{m_kctx};
 | 
				
			||||||
		size_t m_selectedType = 0;
 | 
							size_t m_selectedType = 0;
 | 
				
			||||||
@@ -44,7 +44,7 @@ class NewMenu final: public Popup {
 | 
				
			|||||||
	public:
 | 
						public:
 | 
				
			||||||
		NewMenu(keel::Context &kctx) noexcept;
 | 
							NewMenu(keel::Context &kctx) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void openPath(ox::StringParam path) noexcept;
 | 
							void openPath(ox::StringViewCR path) noexcept;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void open() noexcept override;
 | 
							void open() noexcept override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user