Ejemplo 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);
            }
        }
Ejemplo n.º 2
0
        private void _menuItemSelect_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (_cache.LoadedPath == null)
                {
                    throw new Exception("No file has been loaded.");
                }

                OpeningService.FileOrFolder(_cache.LoadedPath);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Ejemplo n.º 3
0
        private void _clientDbExport(FileType fileType)
        {
            try {
                if (_isClientSyncConvert())
                {
                    if (_delayedReloadDatabase)
                    {
                        if (!ReloadDatabase())
                        {
                            return;
                        }
                        _asyncOperation.WaitUntilFinished();
                    }

                    string path = this.Dispatch(p => PathRequest.FolderExtractDb());

                    if (path == null)
                    {
                        return;
                    }

                    Progress = -1;
                    this.Dispatch(p => p._mainTabControl.IsEnabled = false);
                    var db = _clientDatabase.GetDb <int>(ServerDbs.CItems);
                    DbIOClientItems.WriterSub(null, db, path, fileType);
                    OpeningService.FileOrFolder(path);
                }
                else
                {
                    ErrorHandler.HandleException("You must synchronize the client databases first. Go in the settings page.");
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
            finally {
                Progress = 100;
                this.Dispatch(p => p._mainTabControl.IsEnabled = true);
            }
        }
Ejemplo 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);
            }
        }