コード例 #1
0
        void HandleUpdateEntry(ImageImporter.ImageEntry entry)
        {
            var           tagString = entry.TagString;
            List <String> tags      = new List <string>(tagString.Split(" ".ToCharArray()));
            List <String> siteTags  = tags.FindAll((s) => s.StartsWith("known_on_") || s.StartsWith("not_on_"));

            tags.RemoveAll((s) => siteTags.Contains(s));

            siteTags.RemoveAll((s) => s.StartsWith("not_on_"));
            for (int i = 0; i < siteTags.Count; i++)
            {
                siteTags[i] = siteTags[i].Replace("known_on_", "");
            }

            string sites = string.Join(" ", siteTags);

            tagString = string.Join(" ", tags);

            string entryPath = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(entry.path)) + "/" + System.IO.Path.GetFileName(entry.path);

            //Gtk.Application.Invoke ((o,a) => {
            BooruApp.BooruApplication.TaskRunner.StartTaskMainThread("Import update entry", () => {
                lock (entries) {
                    if (entries.ContainsKey(entry))
                    {
                        var rowRef = entries[entry];
                        Gtk.TreeIter iter;
                        if (rowRef.Model.GetIter(out iter, entries[entry].Path))
                        {
                            entryStore.SetValues(iter,
                                                 entry.Preview,
                                                 entryPath,
                                                 entry.MD5,
                                                 entry.Status,
                                                 tagString,
                                                 entry.LastUpdated,
                                                 sites
                                                 );
                            scrollToPath = this.ImageEntryView.Model.GetPath(iter);
                        }
                        else
                        {
                            BooruApp.BooruApplication.Log.Log(BooruLog.Category.Application, BooruLog.Severity.Warning, "Could not update import entry " + entry.MD5 + ", row reference was invalid");
                        }
                        scrollToPath = this.ImageEntryView.Model.GetPath(iter);
                    }
                    else
                    {
                        var iter = entryStore.AppendValues(
                            entry.Preview,
                            entryPath,
                            entry.MD5,
                            entry.Status,
                            tagString,
                            entry.LastUpdated,
                            sites
                            );
                        entries [entry] = new Gtk.TreeRowReference(entryStore, entryStore.GetPath(iter));
                    }
                }
            });
        }
コード例 #2
0
    void ShowCharacterSheet(ECM.Character currentCharacter)
    {
        Console.WriteLine("****** Changing Character");

        // unhook models?
        trvAttributes.Model = null;

        trvSkills.FreezeChildNotify();
        trvCertificates.FreezeChildNotify();
        trvAssets.FreezeChildNotify();
        //trvStandings.FreezeChildNotify();

        charAttributeStore.Clear();

        lblCharName.Markup = string.Format("<b>{0}</b>", currentCharacter.Name);

        if (currentCharacter.Portrait != null)
            imgCharPortrait.Pixbuf = ECM.API.ImageApi.StreamToPixbuf(currentCharacter.Portrait).ScaleSimple(160, 160, Gdk.InterpType.Bilinear);
        else
            imgCharPortrait.Pixbuf = ECM.API.ImageApi.StreamToPixbuf(ECM.Core.NoPortraitJPG).ScaleSimple(160, 160, Gdk.InterpType.Bilinear);

        lblCurrentLocation.Markup = string.Format("<b>{0}</b>", currentCharacter.LastKnownLocation);
        lblBackground.Markup = string.Format("<b>{0}</b>", currentCharacter.Background);
        lblSkillpoints.Markup = string.Format("<b>{0}</b>", currentCharacter.SkillPoints.ToString("#0,0"));
        lblCone.Markup = string.Format("<b>{0} ({1:0,0})</b>", currentCharacter.CloneName, currentCharacter.CloneSkillPoints);
        lblDoB.Markup = string.Format("<b>{0}</b>", currentCharacter.Birthday.ToString("dd.MM.yyyy HH:mm:ss"));
        lblSecStatus.Markup = string.Format("<b>{0}</b>", currentCharacter.SecurityStatus.ToString("#0.00"));
        lblActiveShip.Markup = string.Format("<b>{0}\n({1})</b>", currentCharacter.ShipName, currentCharacter.ShipTypeName);

        if (string.IsNullOrEmpty(currentCharacter.Corporation))
        {
            lblCorporation.Text = string.Empty;
            lblAlliance.Text = string.Empty;
        }
        else
        {
            lblCorporation.Markup = string.Format("<b>{0}</b>", currentCharacter.Corporation);

            if (string.IsNullOrEmpty(currentCharacter.Alliance))
            {
                lblAlliance.Text = string.Empty;
            }
            else
            {
                lblAlliance.Markup = string.Format("<b>{0}</b>", currentCharacter.Alliance);
            }
        }

        lblCorporation.Visible = !string.IsNullOrEmpty(lblCorporation.Text);
        lblAlliance.Visible = !string.IsNullOrEmpty(lblAlliance.Text);

        lblAllianceTag.Visible = lblAlliance.Visible;
        lblCorporationTag.Visible = lblCorporation.Visible;

        // Load Attributes
        int charisma = currentCharacter.Attributes.Charisma + currentCharacter.Implants.Charisma.Amount;
        int intelligence = currentCharacter.Attributes.Intelligence + currentCharacter.Implants.Intelligence.Amount;
        int memory = currentCharacter.Attributes.Memory + currentCharacter.Implants.Memory.Amount;
        int perception = currentCharacter.Attributes.Perception + currentCharacter.Implants.Perception.Amount;
        int willpower = currentCharacter.Attributes.Willpower + currentCharacter.Implants.Willpower.Amount;

        charAttributeStore.AppendValues(new Gdk.Pixbuf(null, "ECMGTK.Resources.Icons.IntelligenceBrain"), string.Format("INTELLIGENCE\n{0} points", intelligence));
        charAttributeStore.AppendValues(new Gdk.Pixbuf(null, "ECMGTK.Resources.Icons.PerceptionBrain"), string.Format("PERCEPTION\n{0} points", perception));
        charAttributeStore.AppendValues(new Gdk.Pixbuf(null, "ECMGTK.Resources.Icons.CharismaBrain"), string.Format("CHARISMA\n{0} points", charisma));
        charAttributeStore.AppendValues(new Gdk.Pixbuf(null, "ECMGTK.Resources.Icons.WillpowerBrain"), string.Format("WILLPOWER\n{0} points", willpower));
        charAttributeStore.AppendValues(new Gdk.Pixbuf(null, "ECMGTK.Resources.Icons.MemoryBrain"), string.Format("MEMORY\n{0} points", memory));

        trvAttributes.Model = charAttributeStore;

        #region Update Skill Store
        // Traverse character skills tree and update the values
        TreeIter iter;
        charSkillStore.GetIterFirst(out iter);
        bool cont = true;

        while (cont)
        {
            // These are all the main categories
            if (charSkillStore.IterHasChild(iter))
            {
                charSkillStore.SetValue(iter, SkillLearntColumn, false);

                TreeIter child;
                charSkillStore.IterChildren(out child, iter);

                int numSkills = 0;
                int totalPoints = 0;
                bool showGroup = false;

                while (cont)
                {
                    long id = (long)charSkillStore.GetValue(child, SkillIdColumn);
                    ECM.EveSkill skill = ECM.ItemDatabase.Items[id] as ECM.EveSkill;
                    bool learnt = currentCharacter.Skills.ContainsKey(id);
                    int level = 0;
                    int points = 0;
                    double minsToNext = 0;

                    if (learnt)
                    {
                        level = currentCharacter.Skills[id].Level;
                        points = currentCharacter.Skills[id].Skillpoints;

                        showGroup = true;
                        numSkills++;
                    }

                    int pointsAtNext = skill.PointsAtLevel(level + 1);
                    int pointsAtCurr = skill.PointsAtLevel(level);

                    if (level < 5)
                    {
                        long diff = pointsAtNext - points;
                        double spPerMin = ECM.Core.CurrentCharacter.SkillpointsPerMinute(skill.PrimaryAttribute, skill.SecondaryAttribute);

                        minsToNext = diff / spPerMin;
                    }

                    charSkillStore.SetValue(child, SkillLevelColumn, level);
                    charSkillStore.SetValue(child, SkillTimeToNextColumn, minsToNext);

                    charSkillStore.SetValue(child, SkillLearntColumn, learnt);

                    charSkillStore.SetValue(child, SkillCurrSPColumn, points);
                    charSkillStore.SetValue(child, SkillNextSPColumn, pointsAtNext);
                    charSkillStore.SetValue(child, SkillLevlSPColumn, pointsAtCurr);

                    totalPoints += points;

                    cont = charSkillStore.IterNext(ref child);
                }

                charSkillStore.SetValue(iter, SkillLearntColumn, showGroup);
                charSkillStore.SetValue(iter, SkillCurrSPColumn, numSkills);
                charSkillStore.SetValue(iter, SkillNextSPColumn, totalPoints);
            }

            cont = charSkillStore.IterNext(ref iter);
        }
        #endregion

        #region Update Certificate Store
        certStore.GetIterFirst(out iter);
        cont = true;

        while (cont)
        {
            // These are all the main categories
            if (certStore.IterHasChild(iter))
            {
                TreeIter child;
                certStore.IterChildren(out child, iter);

                bool showGroup = false;

                while (cont)
                {
                    long id = (long)certStore.GetValue(child, 2);

                    bool learnt = false;

                    foreach (ECM.API.EVE.CharacterCertificates cert in currentCharacter.Certificates)
                    {
                        if (cert.ID == id) learnt = true;
                    }

                    if (learnt)
                    {
                        showGroup = true;

                        // Remove any prerequisite certificates
                        ECM.EveCertificate cert = ECM.ItemDatabase.Certificates[id];

                        foreach (ECM.EveCertificateRequirement req in cert.Requirements)
                        {
                            if(req.RequirementIsSkill == false)
                            {
                                ECM.EveCertificate reqCert = ECM.ItemDatabase.Certificates[req.RequirementID];
                                TreeIter reqIter;

                                if (certStore.GetIter(out reqIter, reqCert.TreeReference.Path))
                                {
                                    certStore.SetValue(reqIter, 4, false);
                                }
                            }
                        }
                    }

                    certStore.SetValue(child, 4, learnt);

                    cont = certStore.IterNext(ref child);
                }

                certStore.SetValue(iter, 4, showGroup);
            }

            cont = certStore.IterNext(ref iter);
        }
        #endregion

        #region Update Asset Store
        assetStore.Clear();

        foreach (long locationID in currentCharacter.Assets.Keys)
        {
            ECM.EveStation station = ECM.MapDatabase.Stations[locationID];
            List<ECM.API.EVE.AssetListInfo> locAssets = currentCharacter.Assets[locationID];
            string locHeader = string.Format("{0} - {1:#,0} items", station.Name, locAssets.Count);

            TreeIter locationNode = assetStore.AppendValues(locHeader, locationID, true, "");

            foreach (ECM.API.EVE.AssetListInfo info in locAssets)
            {
                AppendAssetToNode(locationNode, info);
            }
        }
        #endregion

        #region Update Standings Store
        standingsStore.Clear();

        if (currentCharacter.Standings != null)
        {
            TreeIter standingParent;

            standingParent = standingsStore.AppendValues("Factions", null, true, 3);

            foreach (ECM.API.EVE.StandingInfo standings in currentCharacter.Standings.Factions)
            {
                string text = string.Format("{0} ({1:0.00}) ({2})", standings.FromName, standings.Standing, standings.Status);

                ECM.API.ImageLoader icon = new ECM.API.ImageLoader(standings.FromID, ECM.API.ImageApi.ImageRequestSize.Size32x32, ECM.API.ImageApi.ImageRequestType.Alliance);

                TreeIter standingIter = standingsStore.AppendValues(standingParent, text, icon, false, standings.Standing);
                TreeRowReference iterRef = new Gtk.TreeRowReference(standingsStore, standingsStore.GetPath(standingIter));

                icon.OnImageUpdated += delegate
                {
                    Gdk.Rectangle rect = trvStandings.GetCellArea(iterRef.Path, trvStandings.GetColumn(0));
                    trvStandings.QueueDrawArea(rect.X, rect.Y, rect.Width, rect.Height);
                    //trvStandings.QueueDraw();
                };
            }

            standingParent = standingsStore.AppendValues("Corporations", null, true, 2);

            foreach (ECM.API.EVE.StandingInfo standings in currentCharacter.Standings.NPCCorporations)
            {
                string text = string.Format("{0} ({1:0.00}) ({2})", standings.FromName, standings.Standing, standings.Status);

                ECM.API.ImageLoader icon = new ECM.API.ImageLoader(standings.FromID, ECM.API.ImageApi.ImageRequestSize.Size32x32, ECM.API.ImageApi.ImageRequestType.Corporation);

                TreeIter standingIter = standingsStore.AppendValues(standingParent, text, icon, false, standings.Standing);
                TreeRowReference iterRef = new Gtk.TreeRowReference(standingsStore, standingsStore.GetPath(standingIter));

                icon.OnImageUpdated += delegate
                {
                    Gdk.Rectangle rect = trvStandings.GetCellArea(iterRef.Path, trvStandings.GetColumn(0));
                    trvStandings.QueueDrawArea(rect.X, rect.Y, rect.Width, rect.Height);
                    //trvStandings.QueueDraw();
                };
            }

            standingParent = standingsStore.AppendValues("Agents", null, true, 1);

            foreach (ECM.API.EVE.StandingInfo standings in currentCharacter.Standings.Agents)
            {
                string text = string.Format("{0} ({1:0.00}) ({2})", standings.FromName, standings.Standing, standings.Status);

                ECM.API.ImageLoader icon = new ECM.API.ImageLoader(standings.FromID, ECM.API.ImageApi.ImageRequestSize.Size32x32, ECM.API.ImageApi.ImageRequestType.Character);

                TreeIter standingIter = standingsStore.AppendValues(standingParent, text, icon, false, standings.Standing);
                TreeRowReference iterRef = new Gtk.TreeRowReference(standingsStore, standingsStore.GetPath(standingIter));

                icon.OnImageUpdated += delegate
                {
                    Gdk.Rectangle rect = trvStandings.GetCellArea(iterRef.Path, trvStandings.GetColumn(0));
                    trvStandings.QueueDrawArea(rect.X, rect.Y, rect.Width, rect.Height);
                    //trvStandings.QueueDraw();
                };
            }
        }
        #endregion

        skillsFilter.Refilter();
        certFilter.Refilter();
        assetFilter.Refilter();
        standingFilter.Refilter();

        trvSkills.ThawChildNotify();
        trvCertificates.ThawChildNotify();
        trvAssets.ThawChildNotify();
        //trvStandings.ThawChildNotify();

        trvStandings.ExpandAll();
    }