Ejemplo n.º 1
0
/**
* Performs the stage move when the user has dragged and dropped a stage.
*/
void StageView::DropItemOnList() {
	CListCtrl& list = GetListCtrl();

	int toStage;

	//Get and adjust the drop index based on the direction of the move
	dropIndex = list.HitTest(dropPoint);
	if(dropIndex < 0) dropIndex = list.GetItemCount()-1;

	//Ignore the drop if the index is the same or they are droping on the material
	if(dropIndex == dragIndex || dropIndex == 0)
		return;

	//Move the stage data
	MaterialDoc* material = materialDocManager->GetCurrentMaterialDoc();

	internalChange = true;
	toStage = dropIndex-1;
	material->MoveStage(dragIndex-1, dropIndex-1);
	internalChange = false;

	if(dragIndex < dropIndex) {
		dropIndex++;
	}

	//Get the item
	char szLabel[256];
	LV_ITEM lvi;
	ZeroMemory(&lvi, sizeof(LV_ITEM));
	lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
	lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
	lvi.pszText = szLabel;
	lvi.iItem = dragIndex;
	lvi.cchTextMax = 255;
	list.GetItem(&lvi);

	//Insert the item
	lvi.iItem = dropIndex;
	list.InsertItem(&lvi);

	//Adjust the drag index if the move was up in the list
	if(dragIndex > dropIndex) {
		dragIndex++;
	}

	//Delete the original item
	list.DeleteItem(dragIndex);

	int type = -1;
	int stageType = currentMaterial->GetAttributeInt(toStage, "stagetype");
	switch(stageType) {
		case MaterialDoc::STAGE_TYPE_NORMAL:
			type = MaterialDefManager::MATERIAL_DEF_STAGE;
			break;
		case MaterialDoc::STAGE_TYPE_SPECIALMAP:
			type = MaterialDefManager::MATERIAL_DEF_SPECIAL_STAGE;
			break;
	}
	m_propView->SetPropertyListType(type, toStage);
}
/**
* Performs a redo operation of a moved stage.
*/
void StageMoveModifier::Redo()
{
	MaterialDoc *material = manager->CreateMaterialDoc(materialName);
	material->MoveStage(from, to, false);
}