//--------------------------------------------------------------------------- // Speichere Wichtungsdaten unter den Dateinamen in FileName public bool Save(CXml pXml = null) { // Speichern bool iReturn = false; CXml pBase = pXml; try { // Falls NULL, erstelle neues File, ansonsten wird es in eine bereits offene XML gespeichert, z.B. Char-MOX if (pXml == null) { pBase = new CXml(); if (pBase == null) { Utils.DebugPrint("CPlayerWeights::Save = 'pBase = new CXml();' failed, got NULL-Pointer."); return(false); } iReturn = pBase.OpenSaveXml(strFileName); } else { iReturn = true; } if (iReturn) { // Weights-Tag öffnen, Class und Name ist ein MUSS => Attribut String att = "name=\"" + strName + "\""; if (pXml == null) { att += " class=\"" + Unit.xml_config.arClasses[iClass].id + "\""; } pBase.OpenTag("weights", "", att); // Die Wichtungen speichern // Nur Werte die ungleich 100 sind speichern for (int i = 0; i < arWeights.Length; i++) { if (arWeights[i].iWeight != 100) { pBase.OpenTag("weight", arWeights[i].iWeight.ToString(), "attribute=\"" + Unit.xml_config.arAttributes[i].id + "\""); pBase.CloseTag(); } } pBase.CloseTag(); // Weights-Tag schliessen if (pXml == null) { pBase.CloseXml(); // wgt-File schliessen } bModified = false; } } catch (Exception e) { Utils.DebugPrint("CPlayerWeights::Save = %s\niClass=%d", e.Message, iClass); iReturn = false; } return(iReturn); }
//--------------------------------------------------------------------------- private void bnExportClick(object sender, EventArgs e) { IEnumerator itmodel = vtItems.SelectedObjects.GetEnumerator(); if (itmodel != null && itmodel.MoveNext()) { if (SaveDialog.ShowDialog() == DialogResult.OK) { CXml xFile = new CXml(); if (xFile.OpenSaveXml(SaveDialog.FileName)) { xFile.OpenTag("daoc_items", "", ""); do { CItem pItem = ((SItemLink)itmodel.Current).Item; pItem.Save(xFile); }while (itmodel.MoveNext()); xFile.CloseTag(); xFile.CloseXml(); } vtItems.SelectedObjects = null; } } }