Exemple #1
0
        public void Initialize(ContentManager content, string searchCode)
        {
            SectionCombiner combiner = new SectionCombiner();
            GameClient      session  = RetroEnvironment.GetGame().GetClientManager().GetClientByUserID(GameScreenManager.Instance.ClientID);

            identifyers = session.GetCategorysByIdentifyer(searchCode).ToArray();

            navSections   = new NavRoomSection[identifyers.Length];
            this.sections = navSections.ToList();

            Vector2i offset = new Vector2i();

            for (int i = 0; i < identifyers.Length; i++)
            {
                int bodySize = 0;
                navSections[i] = new NavRoomSection(content, identifyers[i], offset, new Vector2i(view.GetViewSize().X, 29), out bodySize);
                offset        += new Vector2i(0, navSections[i].GetSize().Y + 5);
                if (!identifyers[i].isCollapsed)
                {
                    offset += new Vector2i(0, bodySize);
                }
            }

            view.SetContent(combiner.AddSections(navSections).GetImages());
            view.SetText(combiner.AddSections(navSections).GetFonts());
            isInitialized = true;
        }
        internal void UploadFurniture(Dictionary <IInventoryItem, int> items)
        {
            invItemSections.Clear();
            itemDisplay.CleanUp();
            Logger.Debug("Loading inventory items (" + items.Count() + ")");
            SectionCombiner combiner = new SectionCombiner();

            int      cell          = 0;
            int      row           = 0;
            Vector2i specialOffset = new Vector2i(0, 0);

            foreach (KeyValuePair <IInventoryItem, int> itemD in items)
            {
                IInventoryItem item   = itemD.Key;
                int            amount = itemD.Value;

                int bodySize = 0;
                invItemSections.Add(new InventoryItemSection(GameScreenManager.Instance.GetContentManager(), amount, item, specialOffset, new Vector2i(42, 42), out bodySize));

                specialOffset += new Vector2i(2 + 42, 0);
                if (cell++ >= 6)
                {
                    cell = 0;
                    row++;
                    specialOffset = new Vector2i(0, (row * (bodySize + 2)) - 2);
                }
            }

            itemDisplay.SetContent(combiner.AddSections(invItemSections.ToArray()).GetImages());
            itemDisplay.SetText(combiner.AddSections(invItemSections.ToArray()).GetFonts());
            itemDisplay.texturesChanged = true;
        }
Exemple #3
0
        public override void Update(GameTime gameTime)
        {
            if (isInitialized && isOpen())
            {
                base.Update(gameTime);
                backdrop.resize(size.X - 6, size.Y - headerHeight - 33 - edgeBottom.dimensions.Y);
                backdrop.Update(gameTime);

                hiddenLine.resize(size.X - 6, hiddenLine.dimensions.Y);
                hiddenLine.Update(gameTime);

                foreach (InMenuButton menuButton in menuButtons)
                {
                    menuButton.Update(gameTime);
                }

                dropdown.SetPosition(position + offset + new Vector2i(14, 43 + headerHeight));
                dropdown.Update(gameTime);

                view.Update(gameTime, position + new Vector2i(14, headerHeight + 75));

                try
                {
                    foreach (NavRoomSection section in navSections)
                    {
                        section.Update(gameTime, view.GetPosition() - view.GetScrolled(), ref view);
                    }
                }catch
                {
                    Logger.Warn("Can not render a Navigator Body!! Soo loading???!");
                }

                if (view.texturesChanged)
                {
                    Vector2i offset = new Vector2i();
                    for (int i = 0; i < navSections.Length; i++)
                    {
                        int            bodySize = 0;
                        NavRoomSection section  = navSections[i];
                        section.UpdatePosition(offset, out bodySize);
                        offset += new Vector2i(0, navSections[i].GetSize().Y + 5);
                        if (!identifyers[i].isCollapsed)
                        {
                            offset += new Vector2i(0, bodySize);
                        }
                    }
                    SectionCombiner combiner = new SectionCombiner();
                    view.SetContent(combiner.AddSections(navSections).GetImages());
                    view.SetText(combiner.AddSections(navSections).GetFonts());
                    view.texturesChanged = false;
                }
            }
        }
        public void UpdateItems(GameTime gameTime)
        {
            itemDisplay.Update(gameTime, position + new Vector2i(12, headerHeight + rootContainer.GetHeight() + 30));

            try
            {
                foreach (InventoryItemSection section in invItemSections)
                {
                    section.Update(gameTime, itemDisplay.GetPosition() - itemDisplay.GetScrolled(), ref itemDisplay);
                }
            } catch
            {
                Logger.Warn("Can not render a Inventory Body!! Soo loading???!");
            }

            if (itemDisplay.texturesChanged)
            {
                int cell = 0;
                int row  = 0;

                Vector2i offset = new Vector2i(0, 0);
                for (int i = 0; i < invItemSections.Count(); i++)
                {
                    int bodySize = 0;
                    InventoryItemSection section = invItemSections[i];
                    section.UpdatePosition(offset, out bodySize);
                    offset += new Vector2i(2 + 42, 0);

                    if (cell++ >= 6)
                    {
                        cell = 0;
                        row++;
                        offset = new Vector2i(0, (row * (42 + 2)) - 2);
                    }
                }
                SectionCombiner combiner = new SectionCombiner();
                itemDisplay.SetContent(combiner.AddSections(invItemSections.ToArray()).GetImages());
                itemDisplay.SetText(combiner.AddSections(invItemSections.ToArray()).GetFonts());
                itemDisplay.texturesChanged = false;
            }
        }
        internal void LoadNewTree(int parentId, ref Dictionary <CatalogusPage, int> pages)
        {
            cataPageSections.Clear();
            Logger.Debug("Loading a new root tree for catalogus!");
            SectionCombiner combiner = new SectionCombiner();

            IEnumerable <CatalogusPage> pagesToAdd = (from page in pages where page.Value == parentId select page.Key);

            if (pagesToAdd.Count() > 0)
            {
                Vector2i specialOffset = new Vector2i(0, 0);
                foreach (CatalogusPage page in pagesToAdd)
                {
                    if (page.visible)
                    {
                        IEnumerable <CatalogusPage> subPages = (from subPage in pages where subPage.Key.parentId == page.pageId select subPage.Key);
                        int bodySize = 0;
                        cataPageSections.Add(new CataPageSection(
                                                 GameScreenManager.Instance.GetContentManager(),
                                                 page,
                                                 specialOffset,
                                                 new Vector2i(177, 20),
                                                 out bodySize,
                                                 subPages));
                        specialOffset += new Vector2i(0, bodySize);
                    }
                    else
                    {
                        Logger.Debug(page.caption, "is not visible.");
                    }
                }
            }

            foreach (CataPageSection section in cataPageSections)
            {
                section.UploadTextures();
            }
            pageTree.SetContent(combiner.AddSections(cataPageSections.ToArray()).GetImages());
            pageTree.SetText(combiner.AddSections(cataPageSections.ToArray()).GetFonts());
            pageTree.texturesChanged = true;
        }
        internal void LoadNewPageItems(CatalogusPage page)
        {
            cataItemSections.Clear();
            pageItems.CleanUp();
            Logger.Debug("Loading page items (" + page.items.Count() + ")", cataItemSections.Count());
            SectionCombiner combiner = new SectionCombiner();

            int      cell          = 0;
            int      row           = 0;
            Vector2i specialOffset = new Vector2i(0, 0);

            foreach (IPageItem item in page.items)
            {
                int maxBody = 0;
                int height  = 62;
                if (item.IsDubbelPriced())
                {
                    height = 74;
                }

                int bodySize = 0;
                cataItemSections.Add(new CataItemSection(GameScreenManager.Instance.GetContentManager(), page.pageId, item, specialOffset, new Vector2i(53, height), out bodySize));
                if (maxBody < bodySize)
                {
                    maxBody = bodySize;
                }

                specialOffset += new Vector2i(3 + 53, 0);
                if (cell++ >= 6)
                {
                    cell = 0;
                    row++;
                    specialOffset = new Vector2i(0, row * maxBody);
                }
            }

            //foreach (CataItemSection section in cataItemSection) section.UploadTextures();
            pageItems.SetContent(combiner.AddSections(cataItemSections.ToArray()).GetImages());
            pageItems.SetText(combiner.AddSections(cataItemSections.ToArray()).GetFonts());
            pageItems.texturesChanged = true;
        }
        public void Update(GameTime gameTime, int parentId, ref Dictionary <CatalogusPage, int> pages)
        {
            if (isOpen())
            {
                base.Update(gameTime);
                rootContainer.Update(gameTime, size, headerHeight, edgeBottom.dimensions.Y);

                tree.Update(gameTime);
                items.Update(gameTime);
                selectItem.Update(gameTime);

                selectItemText.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(selectItemText.GetOriginalText()));
                selectItemText.Update(gameTime);

                imgBannerLayer.Update(gameTime);
                if (imgBanner != null)
                {
                    imgBanner.Scale = 2f;
                    imgBanner.Update(gameTime);
                    imgBanner.resizeCenter(size.X - 2, 90);
                }

                pageTree.Update(gameTime, position + new Vector2i(12, headerHeight + rootContainer.GetHeight() + 95 + 38));
                pageItems.Update(gameTime, position + new Vector2i(202 + 4, headerHeight + rootContainer.GetHeight() + 95 + 251 + 3));

                try
                {
                    foreach (CataPageSection section in cataPageSections)
                    {
                        section.Update(gameTime, pageTree.GetPosition() - pageTree.GetScrolled(), ref pageTree);
                    }

                    foreach (CataItemSection section in cataItemSections)
                    {
                        section.Update(gameTime, pageItems.GetPosition() - pageItems.GetScrolled(), ref pageItems);
                    }
                }
                catch
                {
                    Logger.Warn("Can not render a Catalogus Body!! Soo loading???!");
                }

                if (pageTree.texturesChanged)
                {
                    Vector2i offset = new Vector2i();
                    for (int i = 0; i < cataPageSections.Count(); i++)
                    {
                        int             bodySize = 0;
                        CataPageSection section  = cataPageSections[i];
                        section.UpdatePosition(offset, out bodySize);
                        offset += new Vector2i(0, cataPageSections[i].GetSize().Y + 5);
                        if (!cataPageSections[i].page.isCollapsed)
                        {
                            offset += new Vector2i(0, bodySize);
                        }
                    }
                    SectionCombiner combiner = new SectionCombiner();
                    pageTree.SetContent(combiner.AddSections(cataPageSections.ToArray()).GetImages());
                    pageTree.SetText(combiner.AddSections(cataPageSections.ToArray()).GetFonts());
                    pageTree.texturesChanged = false;
                }
                if (pageItems.texturesChanged)
                {
                    int      cell    = 0;
                    int      row     = 0;
                    int      maxBody = 0;
                    Vector2i offset  = new Vector2i(0, 0);
                    for (int i = 0; i < cataItemSections.Count(); i++)
                    {
                        int             bodySize = 0;
                        CataItemSection section  = cataItemSections[i];
                        section.UpdatePosition(offset, out bodySize);
                        offset += new Vector2i(3 + 53, 0);
                        if (maxBody < bodySize)
                        {
                            maxBody = bodySize;
                        }

                        if (cell++ >= 6)
                        {
                            cell = 0;
                            row++;
                            offset = new Vector2i(0, row * maxBody);
                        }
                    }
                    SectionCombiner combiner = new SectionCombiner();
                    pageItems.SetContent(combiner.AddSections(cataItemSections.ToArray()).GetImages());
                    pageItems.SetText(combiner.AddSections(cataItemSections.ToArray()).GetFonts());
                    pageItems.texturesChanged = false;
                }
            }
        }