Esempio n. 1
0
void PropertiesWindow::saveAttributesPanel()
{
	edit_item->clearAllAttributes();
	for(int32_t rowIndex = 0; rowIndex < attributesGrid->GetNumberRows(); ++rowIndex) {
		ItemAttribute attr;
		wxString type = attributesGrid->GetCellValue(rowIndex, 1);
		if(type == "String") {
			attr.set(nstr(attributesGrid->GetCellValue(rowIndex, 2)));
		} else if(type == "Float") {
			double value;
			if(attributesGrid->GetCellValue(rowIndex, 2).ToDouble(&value)) {
				attr.set(value);
			}
		} else if(type == "Number") {
			long value;
			if(attributesGrid->GetCellValue(rowIndex, 2).ToLong(&value)) {
				attr.set(static_cast<int32_t>(value));
			}
		} else if(type == "Boolean") {
			attr.set(attributesGrid->GetCellValue(rowIndex, 2) == "1");
		} else {
			continue;
		}
		edit_item->setAttribute(nstr(attributesGrid->GetCellValue(rowIndex, 0)), attr);
	}
}
Esempio n. 2
0
void PropertiesWindow::OnGridValueChanged(wxGridEvent& event)
{
	if(event.GetCol() == 1) {
		wxString newType = attributesGrid->GetCellValue(event.GetRow(), 1);
		if(newType == event.GetString()) {
			return;
		}

		ItemAttribute attr;
		if(newType == "String") {
			attr.set("");
		} else if(newType == "Float") {
			attr.set(0.0f);
		} else if(newType == "Number") {
			attr.set(0);
		} else if(newType == "Boolean") {
			attr.set(false);
		}
		SetGridValue(attributesGrid, event.GetRow(), nstr(attributesGrid->GetCellValue(event.GetRow(), 0)), attr);
	}
}