[nostalgia/core/studio] Cleanup TileSheetEditor commands
This commit is contained in:
		@@ -11,7 +11,7 @@ AddSubSheetCommand::AddSubSheetCommand(
 | 
				
			|||||||
		TileSheet::SubSheetIdx parentIdx) noexcept:
 | 
							TileSheet::SubSheetIdx parentIdx) noexcept:
 | 
				
			||||||
		m_img(img), m_parentIdx(std::move(parentIdx)) {
 | 
							m_img(img), m_parentIdx(std::move(parentIdx)) {
 | 
				
			||||||
	auto &parent = m_img.getSubSheet(m_parentIdx);
 | 
						auto &parent = m_img.getSubSheet(m_parentIdx);
 | 
				
			||||||
	if (parent.subsheets.size()) {
 | 
						if (!parent.subsheets.empty()) {
 | 
				
			||||||
		auto idx = m_parentIdx;
 | 
							auto idx = m_parentIdx;
 | 
				
			||||||
		idx.emplace_back(parent.subsheets.size());
 | 
							idx.emplace_back(parent.subsheets.size());
 | 
				
			||||||
		m_addedSheets.push_back(idx);
 | 
							m_addedSheets.push_back(idx);
 | 
				
			||||||
@@ -56,7 +56,7 @@ int AddSubSheetCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::AddSubSheet);
 | 
						return static_cast<int>(CommandId::AddSubSheet);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &AddSubSheetCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&AddSubSheetCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_parentIdx;
 | 
						return m_parentIdx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,7 +59,7 @@ int CutPasteCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(m_commandId);
 | 
						return static_cast<int>(m_commandId);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &CutPasteCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&CutPasteCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_subSheetIdx;
 | 
						return m_subSheetIdx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ int DeleteTilesCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::DeleteTile);
 | 
						return static_cast<int>(CommandId::DeleteTile);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &DeleteTilesCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&DeleteTilesCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_idx;
 | 
						return m_idx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,10 +12,10 @@ DrawCommand::DrawCommand(
 | 
				
			|||||||
		std::size_t idx,
 | 
							std::size_t idx,
 | 
				
			||||||
		int palIdx) noexcept:
 | 
							int palIdx) noexcept:
 | 
				
			||||||
		m_img(img),
 | 
							m_img(img),
 | 
				
			||||||
		m_subSheetIdx(std::move(subSheetIdx)) {
 | 
							m_subSheetIdx(std::move(subSheetIdx)),
 | 
				
			||||||
 | 
							m_palIdx(palIdx) {
 | 
				
			||||||
	auto &subsheet = m_img.getSubSheet(m_subSheetIdx);
 | 
						auto &subsheet = m_img.getSubSheet(m_subSheetIdx);
 | 
				
			||||||
	m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img.bpp, idx));
 | 
						m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img.bpp, idx));
 | 
				
			||||||
	m_palIdx = palIdx;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DrawCommand::DrawCommand(
 | 
					DrawCommand::DrawCommand(
 | 
				
			||||||
@@ -24,12 +24,12 @@ DrawCommand::DrawCommand(
 | 
				
			|||||||
		const ox::Vector<std::size_t> &idxList,
 | 
							const ox::Vector<std::size_t> &idxList,
 | 
				
			||||||
		int palIdx) noexcept:
 | 
							int palIdx) noexcept:
 | 
				
			||||||
		m_img(img),
 | 
							m_img(img),
 | 
				
			||||||
		m_subSheetIdx(std::move(subSheetIdx)) {
 | 
							m_subSheetIdx(std::move(subSheetIdx)),
 | 
				
			||||||
 | 
							m_palIdx(palIdx) {
 | 
				
			||||||
	auto &subsheet = m_img.getSubSheet(m_subSheetIdx);
 | 
						auto &subsheet = m_img.getSubSheet(m_subSheetIdx);
 | 
				
			||||||
	for (const auto idx : idxList) {
 | 
						for (const auto idx : idxList) {
 | 
				
			||||||
		m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img.bpp, idx));
 | 
							m_changes.emplace_back(static_cast<uint32_t>(idx), subsheet.getPixel(m_img.bpp, idx));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	m_palIdx = palIdx;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool DrawCommand::append(std::size_t idx) noexcept {
 | 
					bool DrawCommand::append(std::size_t idx) noexcept {
 | 
				
			||||||
@@ -74,7 +74,7 @@ int DrawCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::Draw);
 | 
						return static_cast<int>(CommandId::Draw);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &DrawCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&DrawCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_subSheetIdx;
 | 
						return m_subSheetIdx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -54,7 +54,7 @@ int InsertTilesCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::InsertTile);
 | 
						return static_cast<int>(CommandId::InsertTile);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &InsertTilesCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&InsertTilesCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_idx;
 | 
						return m_idx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,9 +11,9 @@ core::PaletteChangeCommand::PaletteChangeCommand(
 | 
				
			|||||||
		TileSheet &img,
 | 
							TileSheet &img,
 | 
				
			||||||
		ox::CRStringView newPalette) noexcept:
 | 
							ox::CRStringView newPalette) noexcept:
 | 
				
			||||||
		m_img(img),
 | 
							m_img(img),
 | 
				
			||||||
		m_idx(std::move(idx)) {
 | 
							m_idx(std::move(idx)),
 | 
				
			||||||
	m_oldPalette = m_img.defaultPalette;
 | 
							m_oldPalette(m_img.defaultPalette),
 | 
				
			||||||
	m_newPalette = ox::FileAddress(ox::sfmt<ox::BString<43>>("uuid://{}", newPalette));
 | 
							m_newPalette(ox::FileAddress(ox::sfmt<ox::BString<43>>("uuid://{}", newPalette))) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void PaletteChangeCommand::redo() noexcept {
 | 
					void PaletteChangeCommand::redo() noexcept {
 | 
				
			||||||
@@ -28,7 +28,7 @@ int PaletteChangeCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::PaletteChange);
 | 
						return static_cast<int>(CommandId::PaletteChange);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &PaletteChangeCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&PaletteChangeCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_idx;
 | 
						return m_idx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ int RmSubSheetCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::RmSubSheet);
 | 
						return static_cast<int>(CommandId::RmSubSheet);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &RmSubSheetCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&RmSubSheetCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_idx;
 | 
						return m_idx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,11 +13,11 @@ core::UpdateSubSheetCommand::UpdateSubSheetCommand(
 | 
				
			|||||||
		int cols,
 | 
							int cols,
 | 
				
			||||||
		int rows) noexcept:
 | 
							int rows) noexcept:
 | 
				
			||||||
		m_img(img),
 | 
							m_img(img),
 | 
				
			||||||
		m_idx(std::move(idx)) {
 | 
							m_idx(std::move(idx)),
 | 
				
			||||||
	m_sheet = m_img.getSubSheet(m_idx);
 | 
							m_sheet(m_img.getSubSheet(m_idx)),
 | 
				
			||||||
	m_newName = std::move(name);
 | 
							m_newName(std::move(name)),
 | 
				
			||||||
	m_newCols = cols;
 | 
							m_newCols(cols),
 | 
				
			||||||
	m_newRows = rows;
 | 
							m_newRows(rows) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void UpdateSubSheetCommand::redo() noexcept {
 | 
					void UpdateSubSheetCommand::redo() noexcept {
 | 
				
			||||||
@@ -37,7 +37,7 @@ int UpdateSubSheetCommand::commandId() const noexcept {
 | 
				
			|||||||
	return static_cast<int>(CommandId::UpdateSubSheet);
 | 
						return static_cast<int>(CommandId::UpdateSubSheet);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TileSheet::SubSheetIdx const &UpdateSubSheetCommand::subsheetIdx() const noexcept {
 | 
					TileSheet::SubSheetIdx const&UpdateSubSheetCommand::subsheetIdx() const noexcept {
 | 
				
			||||||
	return m_idx;
 | 
						return m_idx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user