示例#1
0
        //---------------------------------------------------------------------------

        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;
                }
            }
        }
示例#2
0
        //---------------------------------------------------------------------------

        // Lade Spielerdaten
        public bool Load(CXml pXml = null)
        {
            // Laden
            bool   bReturn = false;
            String strTemp;
            String strAllErrors;
            int    iErrCnt = 0;
            int    iTemp;
            CXml   pBase = pXml;

            try
            {
                // Falls NULL, wird aus einem eigenen File geladen...
                if (pBase == null)
                {
                    pBase = new CXml();
                    if (pBase == null)
                    {
                        Utils.DebugPrint("CPlayerWeights::Load = 'pBase = new CXml();' failed, got NULL-Pointer.");
                        return(false);
                    }
                    String Ext = Path.GetExtension(strFileName);
                    SetAllWeights(100);
                    if (Ext.Equals(".wgt", StringComparison.CurrentCultureIgnoreCase))
                    {
                        strAllErrors = string.Format(_("Datei: %s\n\n").Replace("%s", "{0}"), pBase.FileName);
                        bReturn      = pBase.OpenXml(strFileName);
                        while (bReturn)
                        {
                            if (pBase.isTag("weights"))
                            {
                                int cid = Unit.xml_config.GetClassId(pBase.AttributeValue["class"]);
                                if (cid >= 0)
                                {
                                    SetClass(cid);
                                }
                                else
                                {
                                    SetClass(0);
                                }

                                SetName(pBase.AttributeValue["name"]);
                            }
                            else if (pBase.isTag("weight"))
                            {
                                int aid = Unit.xml_config.GetAttributeId(pBase.AttributeValue["attribute"]);
                                if (aid >= 0)   // aid ist nur gültig, wenn sie in der aktuellen config gefunden wird
                                {
                                    SetWeight(aid, pBase.Content.ToIntDef(0));
                                }
                                else
                                {       // Warnmeldung ausgeben
                                    String strErr;
                                    iErrCnt++;
                                    strErr        = string.Format(_("Attribut '%s' ist nicht mehr gültig.\n").Replace("%s", "{0}"), pBase.AttributeValue["attribute"]);
                                    strAllErrors += strErr;
                                }
                            }
                            bReturn = pBase.NextTag();
                        }
                        pBase.CloseXml();
                        if (iErrCnt > 0)
                        {
                            strAllErrors += _("\nBitte Wichtungen überprüfen.");
                            Utils.MorasInfoMessage(strAllErrors.Replace("\n", Environment.NewLine), _("Unbekannte Wichtung"));
                        }
                    }
                    else
                    {
                        // Warnmeldung ausgeben
                        String strErr;
                        strErr = string.Format(_("Fehler beim Laden einer Wichtungsdatei. Dateiendung '.wgt' erwartet!"));
                        Utils.MorasErrorMessage(strErr, _("Ungültige Dateiendung"));
                    }
                    bModified = false;
                }
                else
                {
                    if (pBase.isTag("weights"))
                    {
                        int cid = Unit.xml_config.GetClassId(pBase.AttributeValue["class"]);
                        if (cid >= 0)
                        {
                            SetClass(cid);
                        }
                        else
                        {
                            SetClass(0);
                        }

                        SetName(pBase.AttributeValue["name"]);
                    }
                    else if (pBase.isTag("weight"))
                    {
                        int aid = Unit.xml_config.GetAttributeId(pBase.AttributeValue["attribute"]);
                        if (aid >= 0)   // aid ist nur gültig, wenn sie in der aktuellen config gefunden wird
                        {
                            SetWeight(aid, pBase.Content.ToIntDef(0));
                        }
                        else
                        {       // Warnmeldung ausgeben
                            String strErr;

                            if (strLoadMessages.Length == 0)
                            {
                                strLoadMessages = string.Format(_("Datei: %s\n\n").Replace("%s", "{0}"), pBase.FileName);
                            }
                            strErr           = string.Format(_("Attribut '%s' ist nicht mehr gültig.\n").Replace("%s", "{0}"), pBase.AttributeValue["attribute"]);
                            strLoadMessages += strErr;
                        }
                    }
                    bModified = false;
                }
            }
            catch
            {
                Utils.DebugPrint("Es ist ein Fehler in CPlayerWeights::Load aufgetreten!");
                bReturn = false;
            }
            return(bReturn);
        }