Ejemplo n.º 1
0
        protected void updateDebugRTTWindow()
        {
            // Clear listbox
            mDebugRTTListbox.resetList();
            // Clear imagesets
            mDebugRTTStaticImage.setImage(null);
            foreach (CeguiDotNet.Imageset imgset in mDebugRTTImageSets)
            {
                CeguiDotNet.ImagesetManager.getSingleton().destroyImageset(imgset);
            }
            mDebugRTTImageSets.Clear();
            // Add an entry for each render texture for all active compositors
            Viewport        vp    = mRenderWindow.GetViewport(0);
            CompositorChain chain = CompositorManager.Instance.getCompositorChain(vp);

            OgreDotNet.CompositorInstancesIteratorWrap it = chain.getCompositors();
            while (it.hasMoreElements())
            {
                CompositorInstance inst = it.getNext();
                if (inst.getEnabled())
                {
                    CTTextureDefinitionsIterator texIt =
                        inst.getTechnique().GetTextureDefinitionIterator();
                    while (texIt.hasMoreElements())
                    {
                        CTTextureDefinition texDef = texIt.getNext();

                        // Get instance name of texture
                        string instName = inst.getTextureInstanceName(texDef.getName());
                        // Create CEGUI texture from name of OGRE texture
                        CeguiDotNet.Texture tex = mGuiRenderer.createTexture(new CeguiDotNet.String(instName));
                        // Create imageset
                        CeguiDotNet.Imageset imgSet =
                            ImagesetManager.getSingleton().createImageset(instName, tex);
                        mDebugRTTImageSets.Add(imgSet);
                        imgSet.defineImage("RttImage",
                                           new CEGUIVector2(0.0f, 0.0f),
                                           new CeguiDotNet.Size(tex.getWidth(), tex.getHeight()),
                                           new CEGUIVector2(0.0f, 0.0f));

                        CeguiDotNet.ListboxTextItem item = new ListboxTextItem(texDef.getName(), 0, Imageset.getCPtr(imgSet).Handle);
                        item.setSelectionBrushImage("TaharezLook", "ListboxSelectionBrush");
                        item.setSelectionColours(new CeguiDotNet.colour(0.0f, 0.0f, 1.0f));
                        //the is so we dont have to keep track of the ListboxTextItem
                        //if we loose the reference to the DotNet object CeguiDotNet.ListboxTextItem(leaving scope of the while statement),
                        //The swig generated code will delete the c++ object, we dont want this.
                        //So calling the static function RemoveOwnership will stop the swig generated
                        // code from deleteing the c++ object and the dotnet object can delete normaly.
                        ListboxTextItem.RemoveOwnership(item);
                        //make sure the c++ object will be deleted with its parent
                        item.setAutoDeleted(true);
                        mDebugRTTListbox.addItem(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void CreateScene()
        {
            mLog = LogManager.Singleton.createLog("DemoCEGUI.log", false, true);
            mLog.LogMessage("My new Log. Hells yeah!");

            base.mSceneManager.AmbientLight = Color.FromArgb(125, 125, 125, 125);
            base.mSceneManager.SetSkyDome(true, "Examples/CloudySky", 5, 8);

            mGuiRenderer = new OgreCEGUIRenderer(base.mRenderWindow,
                                                 (byte)RenderQueueGroupID.RENDER_QUEUE_OVERLAY, false, 3000, mSceneManager);
            mGuiRenderer.Initialise();
            mGuiSystem = new GuiSystem(mGuiRenderer);
            //mGuiSystem = GuiSystem.CreateGuiSystemSpecial(mGuiRenderer);

            Logger.Instance.setLoggingLevel(LoggingLevel.Informative);

            SchemeManager.Instance.LoadScheme("TaharezLookSkin.scheme");
            mGuiSystem.SetDefaultMouseCursor("TaharezLook", "MouseArrow");
            mGuiSystem.DefaultFontName = "BlueHighway-12";

            mBackgroundWindow   = WindowManager.Instance.CreateWindow("DefaultWindow", "BackgroundWindow");
            mGuiSystem.GUISheet = mBackgroundWindow;

            mEditorWindow = WindowManager.Instance.CreateWindow("TaharezLook/FrameWindow", "TestWindow");
            mBackgroundWindow.AddChildWindow(mEditorWindow);
            mEditorWindow.SetSize(0.9f, 0.9f);
            mEditorWindow.SetPosition(0.05f, 0.05f);
            mEditorWindow.Text = "CeguiDotNet Demo";
            mEditorWindow.SubscribeEvents();

            mQuitButton      = WindowManager.Instance.CreatePushButton("TaharezLook/Button", "QuitButton");
            mQuitButton.Text = "Quit";
            mQuitButton.SetPosition(0.1f, 0.15f);
            mQuitButton.SetSize(0.8f, 0.15f);
            mQuitButton.SubscribeEvents();
            mQuitButton.Clicked += new WindowEventDelegate(QuitClicked);
            mEditorWindow.AddChildWindow(mQuitButton);

            mEditbox      = WindowManager.Instance.CreateEditbox("TaharezLook/Editbox", "Editbox");
            mEditbox.Text = "Editbox";
            mEditbox.SetPosition(0.1f, 0.32f);
            mEditbox.SetSize(0.8f, 0.15f);
            mEditbox.setReadOnly(false);
            mEditbox.SubscribeEvents();
            mEditbox.KeyDown += new CeguiDotNet.KeyEventDelegate(this.UsernameCharacterKey);
            mEditorWindow.AddChildWindow(mEditbox);

            mCombobox = WindowManager.Instance.CreateCombobox("TaharezLook/Combobox", "Combobox");
            mCombobox.SetPosition(0.1f, 0.49f);
            mCombobox.SetSize(0.8f, 0.25f);
            mCombobox.setReadOnly(false);
            mCombobox.SubscribeEvents();
            mCombobox.ListSelectionChanged += new WindowEventDelegate(this.combobox_SelectionChanged);
            mCombobox.TextAccepted         += new WindowEventDelegate(this.combobox_TextAccepted);
            mEditorWindow.AddChildWindow(mCombobox);

            mCboItem1 = new ListboxTextItem("Item 1", 0, IntPtr.Zero, false, true);
            mCboItem1.setAutoDeleted(false);
            mCombobox.addItem(mCboItem1);
            mCboItem2 = new ListboxTextItem("Item 2", 1, IntPtr.Zero, false, true);
            mCboItem2.setAutoDeleted(false);
            mCombobox.addItem(mCboItem2);
            mCboItem3 = new ListboxTextItem("Item 3", 2, IntPtr.Zero, false, true);
            mCboItem3.setAutoDeleted(false);
            mCombobox.addItem(mCboItem3);
            mCboItem4 = new ListboxTextItem("Item 4", 3, IntPtr.Zero, false, true);
            mCboItem4.setAutoDeleted(false);
            mCombobox.addItem(mCboItem4);

            mEditorWindow.Show();
        }