Exemplo n.º 1
0
        private void _menuItemExportTradeRestrictions_Click(object sender, RoutedEventArgs e)
        {
            try {
                string file = PathRequest.SaveFileCde("fileName", "itemmoveinfov5.txt");

                if (file != null)
                {
                    StringBuilder b = new StringBuilder();

                    b.AppendLine("// Warning: Leave blank space at the end of line!");
                    b.AppendLine("// ItemID | Drop | Trade | Storage | Cart | SelltoNPC | Mail | Auction | Guild Storage");

                    var itemDb = Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    foreach (var item in itemDb.OrderBy(p => p.Key))
                    {
                        int flag = item.GetValue <int>(ServerItemAttributes.TradeFlag);

                        if (flag != 0)
                        {
                            int drop      = (flag & 1) == 1 ? 1 : 0;
                            int trade     = (flag & 2) == 2 ? 1 : 0;
                            int storage   = (flag & 32) == 32 ? 1 : 0;
                            int cart      = (flag & 16) == 16 ? 1 : 0;
                            int sellToNpc = (flag & 8) == 8 ? 1 : 0;
                            int mail      = (flag & 128) == 128 ? 1 : 0;
                            int auction   = (flag & 256) == 256 ? 1 : 0;
                            int gstorage  = (flag & 64) == 64 ? 1 : 0;

                            b.Append(item.Key);
                            b.Append("\t");
                            b.Append(drop);
                            b.Append("\t");
                            b.Append(trade);
                            b.Append("\t");
                            b.Append(storage);
                            b.Append("\t");
                            b.Append(cart);
                            b.Append("\t");
                            b.Append(sellToNpc);
                            b.Append("\t");
                            b.Append(mail);
                            b.Append("\t");
                            b.Append(auction);
                            b.Append("\t");
                            b.Append(gstorage);
                            b.Append("\t// ");

                            b.AppendLine(item.GetValue <string>(ServerItemAttributes.Name));
                        }
                    }

                    File.WriteAllText(file, b.ToString());
                    OpeningService.FileOrFolder(file);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Exemplo n.º 2
0
        private void _menuItemProjectSaveAs_Click(object sender, RoutedEventArgs e)
        {
            try {
                string file = PathRequest.SaveFileCde(
                    "filter", FileFormat.MergeFilters(Format.Sde),
                    "fileName", Path.GetFileName(ProjectConfiguration.ConfigAsker.ConfigFile));

                if (file != null)
                {
                    if (file == ProjectConfiguration.ConfigAsker.ConfigFile)
                    {
                    }
                    else
                    {
                        try {
                            GrfPath.Delete(file);
                            File.Copy(ProjectConfiguration.ConfigAsker.ConfigFile, file);
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                            return;
                        }

                        _recentFilesManager.AddRecentFile(file);
                        ReloadSettings(file);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err.Message, ErrorLevel.Warning);
            }
        }
Exemplo n.º 3
0
        private void _buttonSave_Click(object sender, RoutedEventArgs e)
        {
            try {
                string path = PathRequest.SaveFileCde("filter", "Python Files|*.py");

                if (path != null)
                {
                    File.WriteAllText(path, _textEditor.Text);
                    _rcm.AddRecentFile(path);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Exemplo n.º 4
0
        private void _menuItemQuestExport_Click(object sender, RoutedEventArgs e)
        {
            try {
                string file = PathRequest.SaveFileCde("fileName", "OngoingQuestInfoList_Sakray.lub");

                if (file != null)
                {
                    StringBuilder b = new StringBuilder();

                    b.AppendLine("QuestInfoList = {}");
                    b.AppendLine("QuestInfoList = {");

                    var itemDb = Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.CQuests);

                    foreach (var item in itemDb.OrderBy(p => p.Key))
                    {
                        b.Append("	[");
                        b.Append(item.Key);
                        b.AppendLine("] = {");

                        b.Append("		Title = \"");
                        b.Append((item.GetValue <string>(ClientQuestsAttributes.Name) ?? "").Escape(EscapeMode.Normal));
                        b.AppendLine("\",");

                        b.Append("		Description = { \"");
                        b.Append((item.GetValue <string>(ClientQuestsAttributes.FullDesc) ?? "").Escape(EscapeMode.Normal));
                        b.AppendLine("\" },");

                        string summary = (item.GetValue <string>(ClientQuestsAttributes.ShortDesc) ?? "").Escape(EscapeMode.Normal);
                        summary = summary.Replace("<ITEM>", "").Replace("</ITEM>", "");

                        if (summary.Contains("<INFO"))
                        {
                            int idx = 0;

                            while ((idx = summary.IndexOf("<INFO", idx, System.StringComparison.Ordinal)) > -1)
                            {
                                int endIdx = summary.IndexOf("</INFO>", idx + 5, System.StringComparison.Ordinal);
                                int oldLen = summary.Length;

                                summary = summary.Substring(0, idx) + summary.Substring(endIdx + "</INFO>".Length);
                                idx     = endIdx + 5 - (oldLen - summary.Length);
                            }
                        }

                        b.Append("		Summary = \"");
                        b.Append(summary);
                        b.AppendLine("\"");

                        b.AppendLine("	},");
                    }

                    b.AppendLine("}");
                    File.WriteAllText(file, b.ToString());
                    OpeningService.FileOrFolder(file);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }