예제 #1
0
        /** Constructor
         *  @param
         *      name The name to be given to the widget (must be unique).
         *  @note
         *      If you want a transparent background, pass "" as the material.
         */
        public Sheet(string name, string material)
            : base(name, new Vector4(0, 0, 1, 1), QGuiMetricsMode.QGUI_GMM_RELATIVE, QGuiMetricsMode.QGUI_GMM_RELATIVE, material, null, null)
        {
            mDefaultCharacterHeight = 1;
            mDefaultTextColor       = ColourValue.White;
            mDefaultSkin            = "qgui";
            mAutoNameWindowCounter  = 0;
            mMenuOverlayZOrder      = 600;

            mVerticalAlignment = GuiVerticalAlignment.GVA_BOTTOM;

            mWidgetType = Widget.WidgetType.QGUI_TYPE_SHEET;
            mWindows.Clear();
            // Sheets are always at zOrder 0.
            mOverlay        = OverlayManager.Singleton.Create(mInstanceName + ".Overlay");
            mOverlay.ZOrder = 0;
            mOverlay.Show();
            mOverlay.Add2D(mOverlayContainer);

            FontManager fm = FontManager.Singleton;

            ResourceManager.ResourceMapIterator rmi = fm.GetResourceIterator();
            if (rmi.MoveNext())
            {
                mDefaultFont = rmi.Current.Name;
            }
            else
            {
                mDefaultFont = string.Empty;
            }

            // Create menu overlay and container
            mMenuOverlay = OverlayManager.Singleton.Create(mInstanceName + ".MenuOverlay");
            mMenuOverlay.Show();
            mMenuContainer = createOverlayContainer(mInstanceName + ".MenuContainer", "");
            mMenuOverlay.Add2D(mMenuContainer);
            mMenuContainer.Show();

            // Set zOrder very high, but leave room for containers and mouse cursor to show up correctly.
            mMenuOverlay.ZOrder = (ushort)mMenuOverlayZOrder;
        }
예제 #2
0
        public static MaterialPtr BuildPreloaderMaterial(int maxTextures)
        {
            Pass        pass = null;
            Technique   t;
            string      name = "PreloaderMaterial";
            MaterialPtr mptr;

            if (MaterialManager.Singleton.ResourceExists(name))
            {
                mptr = (MaterialPtr)MaterialManager.Singleton.Load(name, MaterialManager.DEFAULT_SCHEME_NAME);
                if (mptr.GetBestTechnique().NumPasses > 1)
                {
                    // material jest juz gotowy
                    return(mptr);
                }
            }
            else
            {
                return(null);
            }

            int freeMB = ((int)TextureManager.Singleton.MemoryUsage / (1024 * 1024));

            LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Building hardware preloader material. Free system memory: " + freeMB);

            t = mptr.GetBestTechnique();
            ResourceManager.ResourceMapIterator i = TextureManager.Singleton.GetResourceIterator();
            int j     = 0;
            int k     = 0;
            int total = 0;

            while (i.MoveNext())
            {
                if (j < System.Math.Ceiling(maxTextures / 2.0f))
                {
                    j++;

                    TexturePtr texture = (TexturePtr)(i.Current);
                    if (!texture.Name.Contains(AdManager.C_ADS_DIR))
                    {
                        pass = t.CreatePass();
                        pass.CreateTextureUnitState(texture.Name);
                        pass.SetSceneBlending(SceneBlendFactor.SBF_ZERO, SceneBlendFactor.SBF_ONE);
                        LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Material will be preloaded (" + k + ") - " + texture.Name);
                    }
                    else
                    {
                    }

                    k++;
                    if (i.MoveNext())
                    {
                        if (!texture.Name.Contains(AdManager.C_ADS_DIR))
                        {
                            texture = (TexturePtr)(i.Current);
                            if (pass == null)
                            {
                                pass = t.CreatePass();
                            }
                            pass.CreateTextureUnitState(texture.Name);
                            LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL,
                                                            "Material will be preloaded (" + k + ") - " + texture.Name);
                        }
                        k++; total++;
                    }
                    pass = null;
                }
                total++;
            }

            LogManager.Singleton.LogMessage(LogMessageLevel.LML_CRITICAL, "Total materials to be hardware preloaded: " + k + "/" + total);

            mptr.Load();
            mptr.Compile();
            return(mptr);
        }