Example #1
0
        public DisplayLabel()
        {
            FocusVisualStyle = null;
            Margin           = new Thickness(-4, -4, 0, -4);
            Padding          = new Thickness(0);

            FontSize = 12;

            MouseEnter += delegate {
                if (_dbSource != null)
                {
                    if (FtpHelper.HasBeenMapped())
                    {
                        ToolTip = DbPathLocator.DetectPath(_dbSource);
                    }
                    else
                    {
                        ToolTip = "Directory has not been mapped yet. Load the database first.";
                    }
                }

                if (ToolTip == null)
                {
                    ToolTip = "File not found. This database will be disabled.";
                }
            };

            SizeChanged += delegate {
                if (!_isLoaded)
                {
                    Grid    presenter = WpfUtilities.FindParentControl <Grid>(this);
                    TextBox box       = (TextBox)presenter.Children[2];

                    if (box.Text == "Visible")
                    {
                        Foreground = _stateBrush;
                    }
                    else
                    {
                        Foreground = _stateInactiveBrush;
                    }

                    box.TextChanged += delegate {
                        if (box.Text == "Visible")
                        {
                            Foreground = _stateBrush;
                        }
                        else
                        {
                            Foreground = _stateInactiveBrush;
                        }
                    };

                    _isLoaded = true;
                }
            };
        }
Example #2
0
        public static bool IsTabEnabled(GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb)
        {
            if (DbPathLocator.DetectPath(settings.DbData) == null)
            {
                return(false);
            }

            if (!gdb.IsEnabled)
            {
                return(false);
            }

            if (!Boolean.Parse(ProjectConfiguration.ConfigAsker["[Server database editor - Enabled state - " + settings.DbData.DisplayName + "]", true.ToString()]))
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        public static void DbSqlMobs(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            DbSqlWriter writer = new DbSqlWriter();

            writer.Init(debug);

            if (DbPathLocator.DetectPath(debug.DbSource).EndsWith(".conf"))
            {
                object value = db.Attached["EntireRewrite"];
                db.Attached["EntireRewrite"] = true;
                DbIOMethods.DbWriterComma(debug, db);
                db.Attached["EntireRewrite"] = value;
            }
            else
            {
                DbIOMethods.DbWriterComma(debug, db);
            }

            if (debug.DestinationServer == ServerType.RAthena)
            {
                writer.AppendHeader(ResourceString.Get("RAthenaMobDbSqlHeader"));
            }
            else if (debug.DestinationServer == ServerType.Hercules)
            {
                writer.AppendHeader(ResourceString.Get("HerculesMobDbSqlHeader"), writer.TableName.Replace("_re", ""));
                writer.TableName = "mob_db";
            }

            foreach (string line in writer.Read())
            {
                string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t'));
                if (!_getMob(writer.IsHercules, writer.TableName, writer.Builder, elements))
                {
                    writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "--" + (writer.NumberOfLinesProcessed > 1 ? " " : "")) : line.ReplaceFirst("//", "#"));
                }
                else
                {
                    writer.NumberOfLinesProcessed++;
                }
            }

            writer.Write();
        }
Example #4
0
        private void _miSelectInNotepad_Click(object sender, RoutedEventArgs e)
        {
            try {
                TValue item = _listView.SelectedItem as TValue;

                if (item != null)
                {
                    string displayId = item.GetValue <string>(Settings.AttId);
                    string path;

                    //if (Settings.DbData == ServerDbs.ItemGroups) {
                    //	displayId = item.GetValue<string>(ServerItemGroupAttributes.Display);
                    //}

                    if ((path = DbPathLocator.DetectPath(Settings.DbData)) != null)
                    {
                        if (!IOHelper.IsSystemFile(path))
                        {
                            ErrorHandler.HandleException("The file cannot be opened because it is not stored locally.");
                            return;
                        }

                        string[] lines = File.ReadAllLines(path);

                        string line = lines.FirstOrDefault(p => p.StartsWith(displayId + ","));

                        if (line == null)
                        {
                            line = lines.FirstOrDefault(p => p.StartsWith(displayId + "\t"));
                        }

                        if (line == null)
                        {
                            line = lines.FirstOrDefault(p => p.Contains("Id: " + displayId));
                        }

                        if (line == null)
                        {
                            line = lines.FirstOrDefault(p => p.Contains("id: " + displayId));
                        }

                        if (line == null)
                        {
                            line = lines.FirstOrDefault(p => p.Contains("[" + displayId + "] ="));
                        }

                        if (line == null)
                        {
                            line = lines.FirstOrDefault(p => p.StartsWith(displayId));
                        }

                        if (line == null)
                        {
                            int ival;
                            if (!Int32.TryParse(displayId, out ival))
                            {
                                line = lines.FirstOrDefault(p => p.Contains(displayId + ":"));
                            }
                        }

                        if (line != null)
                        {
                            GTabsMaker.SelectInNotepadpp(path, (lines.ToList().IndexOf(line) + 1).ToString(CultureInfo.InvariantCulture));
                        }
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Example #5
0
        public static void DbItemsWriterSub <TKey>(StringBuilder builder, AbstractDb <TKey> db, IEnumerable <ReadableTuple <TKey> > tuples, ServerType to)
        {
            if (to == ServerType.RAthena)
            {
                bool fromTxtDb = DbPathLocator.DetectPath(db.DbSource).IsExtension(".txt");

                foreach (ReadableTuple <TKey> tuple in tuples)
                {
                    List <string> rawElements = tuple.GetRawElements().Take(22).Select(p => p.ToString()).ToList();

                    if (tuple.Normal && fromTxtDb && tuple.GetValue <int>(ServerItemAttributes.Matk) == 0)
                    {
                        builder.AppendLine(String.Join(",", rawElements.ToArray()));
                        continue;
                    }

                    string script1 = tuple.GetValue <string>(19);
                    string script2 = tuple.GetValue <string>(20);
                    string script3 = tuple.GetValue <string>(21);
                    string refine  = tuple.GetValue <string>(17);

                    if (refine == "")
                    {
                    }
                    else if (refine == "true" || refine == "1")
                    {
                        refine = "1";
                    }
                    else
                    {
                        refine = "0";
                    }

                    string atk = DbIOFormatting.ZeroDefault(rawElements[7]);

                    if (db.ProjectDatabase.IsRenewal)
                    {
                        string matk = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? "";

                        if (matk != "" && matk != "0")
                        {
                            atk = (atk == "" ? "0" : atk) + ":" + matk;
                        }
                    }

                    builder.AppendLine(String.Join(",",
                                                   new string[] {
                        rawElements[0],                                              // ID
                        rawElements[1],                                              // AegisName
                        rawElements[2],                                              // Name
                        DbIOFormatting.OutputInteger(rawElements[3]),                // Type
                        DbIOFormatting.ZeroDefault(rawElements[4]),                  // Buy
                        DbIOFormatting.ZeroDefault(rawElements[5]),                  // Sell
                        String.IsNullOrEmpty(rawElements[6]) ? "0" : rawElements[6], // Weight
                        atk,                                                         // ATK + matk
                        DbIOFormatting.ZeroDefault(rawElements[8]),
                        DbIOFormatting.ZeroDefault(rawElements[9]),
                        DbIOFormatting.ZeroDefault(rawElements[10]),                              // Slots
                        String.IsNullOrEmpty(rawElements[11]) ? "0xFFFFFFFF" : !rawElements[11].StartsWith("0x") ? "0x" + Int32.Parse(rawElements[11]).ToString("X8") : rawElements[11],
                        DbIOFormatting.HexToInt(rawElements[12]),                                 // Upper
                        DbIOFormatting.ZeroDefault(rawElements[13]),
                        DbIOFormatting.ZeroDefault(DbIOFormatting.HexToInt(rawElements[14])),
                        DbIOFormatting.ZeroDefault(rawElements[15]),
                        DbIOFormatting.ZeroDefault(rawElements[16]),
                        refine,
                        DbIOFormatting.ZeroDefault(rawElements[18]),
                        String.IsNullOrEmpty(script1) ? "{}" : "{ " + script1 + " }",
                        String.IsNullOrEmpty(script2) ? "{}" : "{ " + script2 + " }",
                        String.IsNullOrEmpty(script3) ? "{}" : "{ " + script3 + " }"
                    }));
                }
            }
            else if (to == ServerType.Hercules)
            {
                foreach (var tuple in tuples.OrderBy(p => p.GetKey <int>()).OfType <ReadableTuple <int> >())
                {
                    WriteEntry(db, builder, tuple);
                    builder.AppendLine();
                }
            }
        }