青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

更進(jìn)一步

CEGUI

在這篇文章中,我們將把CEGUI集成到應(yīng)用程序中。

Rendering The UI

CEGUI 將它的 UI elements 畫成四方形的Mesh形式畫到"screen space". CEGUI 通過(guò)"OgreGUIRenderer"Ogre進(jìn)行交互。

CEGUI Data Files

CEGUI中的文件有如下幾個(gè):

  • Scheme. Definition of the different UI elements that are valid in a particular "scheme", for example buttons, listboxes, and so on. Found in .scheme files.
  • Look-And-Feel. Definition of the way that each UI element is presented on the display, including its behaviors and the textures used to render it. Found in .looknfeel files.
  • Layout. Defines the position, size, parenting hierarchy and other properties used to display actual UI elements in a single unit: the UI "sheet". Found in .layout files.
  • Imageset. Defines the textures used in a scheme, and the UV coordinates that are actually mapped to UI element quads on your screen. Found in .imageset files.
  • Font. Should be obvious; CEGUI needs to know where to find the fonts you intend to use for your text, including the glyph definitions and the font texture to use. Found in .font files.

In the gui.zip resource data file accompanying the source for this article, you will find many examples of all of these types of files. Look through each type of file and see what they contain -- they are all just text XML files. This article uses the "TaharezLookSkin" scheme.

Falagard Skinning System

There is also another part of CEGUI that works behind the scenes, but starting with CEGUI 0.5.x (the version used in this article), is core to its operation. The "Falagard" skinning system was devised as a way to remove the need to create a separate code module (DLL) that was used actually to assemble and render each different scheme and look-and-feel. As you might expect (if you are a regular in the Ogre forums) the person (at least mostly) responsible for its creation was Falagard (unless my information is incorrect, of course). This method of UI skinning is a generalized, data-driven way to render the UI elements without having to author special code to do it. It relies on all of that data found in the look-and-feel and scheme files for its operation -- verbosity of data is one of the prices you pay for flexibility. ;)

The Code

先介紹到這里,下面讓我們看一下代碼。在這個(gè)版本中,原來(lái)的初始版本將顯示我們這里創(chuàng)建的layout.

And Then, Now The Code

對(duì)于添加CEGUI需要的修改,會(huì)指出。首先在main.cpp添加附加的頭文件

// needed to be able to create the CEGUI renderer interface
#include "OgreCEGUIRenderer.h"
 
// CEGUI includes
#include "CEGUISystem.h"
#include "CEGUIInputEvent.h"
#include "CEGUIWindow.h"
#include "CEGUIWindowManager.h"
#include "CEGUISchemeManager.h"
#include "CEGUIFontManager.h"
#include "elements/CEGUIFrameWindow.h"

Initializing CEGUI

main.cpp

        // with a scene manager and window, we can create a the GUI renderer
        CEGUI::OgreCEGUIRenderer* pGUIRenderer = new CEGUI::OgreCEGUIRenderer(
               window,                               // the render window created earlier; CEGUI renders to this
               Ogre::RENDER_QUEUE_OVERLAY,           // CEGUI should render in this render queue
               false,                                // put everything in the above render queue first, not last
               3000,                                 // this is actually unnecessary now in CEGUI -- max quads for the UI
               sceneMgr                              // use this scene manager to manage the UI
        );
 
        // create the root CEGUI class
        CEGUI::System* pSystem = new CEGUI::System(pGUIRenderer);
 
        // tell us a lot about what is going on (see CEGUI.log in the working directory)
        CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
 
        // use this CEGUI scheme definition (see CEGUI docs for more)
        CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme", (CEGUI::utf8*)"GUI");
 
        // show the CEGUI mouse cursor (defined in the look-n-feel)
        pSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
 
        // use this font for text in the UI
        CEGUI::FontManager::getSingleton().createFont("Tahoma-8.font", (CEGUI::utf8*)"GUI");
        pSystem->setDefaultFont((CEGUI::utf8*)"Tahoma-8");
 
        // load a layout from the XML layout file (you'll find this in resources/gui.zip), and 
        // put it in the GUI resource group
        CEGUI::Window* pLayout = CEGUI::WindowManager::getSingleton().loadWindowLayout("katana.layout", "", "GUI");
 
        // you need to tell CEGUI which layout to display. You can call this at any time to change the layout to
        // another loaded layout (i.e. moving from screen to screen or to load your HUD layout). Note that this takes
        // a CEGUI::Window instance -- you can use anything (any widget) that serves as a root window.
        pSystem->setGUISheet(pLayout);

Input Support For CEGUI

需要修改 InputHandler類以處理一個(gè)新增的參數(shù):一個(gè)指向main.cpp中創(chuàng)建的CEGUI::System的指針:

input.cpp

// MouseListener
bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
        m_pSystem->injectMouseWheelChange(evt.state.Z.rel);
        return m_pSystem->injectMouseMove(evt.state.X.rel, evt.state.Y.rel);
}
 
bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
        CEGUI::MouseButton button = CEGUI::NoButton;
        if (btn == OIS::MB_Left)
               button = CEGUI::LeftButton;
        if (btn == OIS::MB_Middle)
               button = CEGUI::MiddleButton;
        if (btn == OIS::MB_Right)
               button = CEGUI::RightButton;
        return m_pSystem->injectMouseButtonDown(button);
}
 
bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
        CEGUI::MouseButton button = CEGUI::NoButton;
        if (btn == OIS::MB_Left)
               button = CEGUI::LeftButton;    
        if (btn == OIS::MB_Middle)
               button = CEGUI::MiddleButton;  
        if (btn == OIS::MB_Right)
               button = CEGUI::RightButton;   
        return m_pSystem->injectMouseButtonUp(button);
}
 
               
// KeyListener
bool InputHandler::keyPressed(const OIS::KeyEvent &evt) {
        unsigned int ch = evt.text;
        m_pSystem->injectKeyDown(evt.key);
        return m_pSystem->injectChar(ch);
}
 
bool InputHandler::keyReleased(const OIS::KeyEvent &evt) {
        if (evt.key == OIS::KC_ESCAPE)
               m_simulation->requestStateChange(SHUTDOWN);
        return m_pSystem->injectKeyUp(evt.key);
}
 

很顯然的,輸入系統(tǒng)通過(guò)inject…等命令,將自己掛進(jìn)CEGUI.

main.cpp

        // since the input handler deals with pushing input to CEGUI, we need to give it a pointer
        // to the CEGUI System instance to use
        InputHandler *handler = new InputHandler(pSystem, sim, hWnd);
 
        // put us into our "main menu" state
        sim->requestStateChange(GUI);

同時(shí),需要將狀態(tài)轉(zhuǎn)成GUI,如前面所述。在一個(gè)正常的應(yīng)用程序中,你通常是先進(jìn)入“主菜單”,而不是直接進(jìn)入游戲。你還需要建立一個(gè)類來(lái)處理UI的動(dòng)作,為簡(jiǎn)單起見,我們?cè)?span lang="EN-US">main.cpp來(lái)處理:

        // make an instance of our GUI sheet handler class
        MainMenuDlg* pDlg = new MainMenuDlg(pSystem, pLayout, sim);

其定義見文件MainMenuDlg.h and .cpp:

MainMenuDlg.h

#pragma once
 
#include "CEGUIWindow.h"
 
namespace CEGUI
{
        class System;
        class Window;
}
 
class Simulation;
 
class MainMenuDlg
{
public:
        MainMenuDlg(CEGUI::System* pSystem, CEGUI::Window* pSheet, Simulation* pSimulation);
        ~MainMenuDlg();
 
        // CEGUI event handlers. You can name these whatever you like, so long as they have the proper 
        // signature: bool <method name>(const CEGUI::EventArgs &args)
        bool Quit_OnClick(const CEGUI::EventArgs &args);
        bool Options_OnClick(const CEGUI::EventArgs &args);
        bool Launch_OnClick(const CEGUI::EventArgs &args);
 
private:
        CEGUI::System* m_pSystem;      // pointer to the CEGUI System instance
        CEGUI::Window* m_pWindow;      // pointer to the layout sheet window
        Simulation* m_pSimulation;     // pointer to the Simulation controller 
};

MainMenuDlg.cpp

#include "MainMenuDlg.h"
#include "Simulation.h"
#include "CEGUISystem.h"
#include "CEGUIWindow.h"
#include "CEGUIWindowManager.h"
#include "elements/CEGUIPushButton.h"
 
MainMenuDlg::MainMenuDlg(CEGUI::System *pSystem, CEGUI::Window *pSheet, Simulation *pSimulation)
{
        m_pSystem = pSystem;
        m_pWindow = pSheet;
        m_pSimulation = pSimulation;
 
        // hook up the event handlers to the window elements
        CEGUI::PushButton* pQuitButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdQuit");
        pQuitButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Quit_OnClick, this));
 
        CEGUI::PushButton* pOptionsButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdOptions");
        pOptionsButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Options_OnClick, this));
 
        CEGUI::PushButton* pLaunchButton = (CEGUI::PushButton *)CEGUI::WindowManager::getSingleton().getWindow("cmdInstantAction");
        pLaunchButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&MainMenuDlg::Launch_OnClick, this));
}
 
MainMenuDlg::~MainMenuDlg()
{
}
 
bool MainMenuDlg::Quit_OnClick(const CEGUI::EventArgs &args)
{
        m_pSimulation->requestStateChange(SHUTDOWN);
        return true;
}
 
bool MainMenuDlg::Launch_OnClick(const CEGUI::EventArgs &args)
{
        return true;
}
 
bool MainMenuDlg::Options_OnClick(const CEGUI::EventArgs &args)
{
        return true;
}

兩個(gè)主要的事情是 (a) action handler methods 如何掛接 CEGUI events, and (b) “Quit”按鈕告訴程序狀態(tài)轉(zhuǎn)換到Shutdown.

Conclusion

Enjoy!

Link:  OIS: http://sourceforge.net/projects/wgois      


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


posts - 15, comments - 2, trackbacks - 0, articles - 29

Copyright © 美洲豹

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美中文字幕在线| 久久久久亚洲综合| 精品成人一区二区三区| 一区二区高清视频在线观看| 在线成人免费观看| 欧美一二三区精品| 亚洲男人影院| 欧美日韩一二三区| 亚洲精品国产无天堂网2021| 韩国av一区二区| 亚洲综合色噜噜狠狠| 一本色道久久88综合亚洲精品ⅰ| 欧美专区在线| 久久精品人人做人人综合| 国产精品久线观看视频| 一本不卡影院| 亚洲一区二区3| 欧美日韩视频第一区| 亚洲精品国精品久久99热| 最新日韩在线视频| 欧美a级理论片| 亚洲高清一区二| 亚洲看片免费| 欧美啪啪成人vr| 最新国产精品拍自在线播放| 亚洲精品一区中文| 欧美激情综合在线| 99v久久综合狠狠综合久久| 99视频日韩| 欧美性一二三区| 亚洲欧美日韩一区二区三区在线观看 | 在线视频欧美日韩精品| 一区二区三区产品免费精品久久75| 欧美成人免费在线| 亚洲精品国产精品乱码不99 | 一区二区久久久久| 欧美日韩高清在线播放| 一本久久青青| 久久精品国产69国产精品亚洲| 国产亚洲一级高清| 久久综合导航| 亚洲日本欧美| 久久成人精品一区二区三区| 韩日视频一区| 欧美国产精品va在线观看| 亚洲精品在线观看免费| 亚洲欧美在线免费观看| 国产一区二区中文| 欧美成人国产| 亚洲无人区一区| 久热成人在线视频| 日韩网站在线| 国产最新精品精品你懂的| 久久伊人一区二区| 一区二区三区久久网| 久久久噜噜噜久久| 一二三区精品| 激情综合色综合久久综合| 欧美精品网站| 欧美亚洲免费| 亚洲人成人一区二区三区| 销魂美女一区二区三区视频在线| 狠狠色综合网| 欧美日韩一区二区在线观看视频 | 久久久www成人免费精品| 亚洲国产成人精品久久| 国产精品成人久久久久| 巨乳诱惑日韩免费av| 国产精品99久久久久久白浆小说| 久久久亚洲成人| 亚洲视频精选在线| 亚洲福利视频一区| 国产日韩欧美高清| 欧美三级特黄| 欧美成人亚洲| 欧美在线观看视频一区二区三区| 亚洲人体影院| 免费视频久久| 久久精品视频在线看| 亚洲深夜福利在线| 亚洲国产精品一区| 国内外成人免费激情在线视频网站| 欧美激情综合在线| 美女成人午夜| 久久久久久久久久看片| 亚洲欧美激情视频| 一区二区三区免费在线观看| 亚洲电影免费观看高清完整版在线观看 | 在线播放视频一区| 国产老肥熟一区二区三区| 欧美久久一级| 欧美激情1区2区| 欧美aⅴ一区二区三区视频| 欧美在线国产| 欧美在线观看一区二区| 亚洲一区在线免费| 亚洲一区二区欧美日韩| 99香蕉国产精品偷在线观看| 亚洲国产另类久久久精品极度| 老牛影视一区二区三区| 久久人人超碰| 久久这里只有| 蜜桃久久精品乱码一区二区| 久久综合九色综合欧美狠狠| 久久国产精品免费一区| 欧美专区在线观看| 久久成人这里只有精品| 久久国产日韩| 久久综合五月| 欧美电影在线播放| 亚洲国产一区在线| 亚洲精品免费在线| 亚洲美女中文字幕| 夜夜精品视频一区二区| 亚洲国产日本| 在线视频亚洲| 免费不卡亚洲欧美| 亚洲精品一区二区三区不| 一区二区三区自拍| 亚洲黄色成人网| 99av国产精品欲麻豆| 中文日韩在线视频| 午夜日韩在线观看| 久久久久久伊人| 欧美激情亚洲另类| 亚洲免费精彩视频| 午夜精品一区二区三区在线| 久久激情综合网| 欧美黑人在线观看| 欧美午夜精品久久久久久孕妇 | 亚洲福利视频二区| 最近看过的日韩成人| 一区二区三区免费网站| 午夜日韩在线| 女人香蕉久久**毛片精品| 亚洲国产成人在线| 亚洲深夜福利视频| 久久男人资源视频| 欧美视频中文字幕| 精品成人在线视频| 亚洲桃色在线一区| 久久免费视频在线观看| 91久久夜色精品国产九色| 亚洲一区二三| 欧美风情在线观看| 国产伪娘ts一区 | 亚洲国产成人av在线| 亚洲午夜电影| 欧美大片91| 亚洲欧美日韩视频二区| 欧美成ee人免费视频| 国产美女精品视频| 亚洲精品一区二区三区四区高清| 欧美一级播放| 亚洲激情视频在线播放| 午夜亚洲影视| 欧美性猛交视频| 亚洲国产天堂网精品网站| 欧美一级大片在线观看| 亚洲高清在线观看| 久久黄色小说| 国产精品永久免费视频| 在线亚洲欧美| 亚洲欧洲精品一区二区三区不卡| 欧美中文字幕视频在线观看| 欧美视频一区二区在线观看| 亚洲国产欧美在线人成| 久久久久成人精品| 亚洲在线成人精品| 欧美日韩综合久久| 亚洲免费观看高清完整版在线观看熊 | 欧美承认网站| 国产精品美女黄网| 99热精品在线| 欧美黑人在线播放| 久久久人成影片一区二区三区观看 | 一区久久精品| 久久激五月天综合精品| 亚洲色图在线视频| 欧美日韩在线视频观看| 亚洲理论电影网| 欧美福利视频网站| 猛男gaygay欧美视频| 在线观看视频一区二区| 久久久久久一区二区三区| 亚洲欧美中文日韩在线| 国产精品久久九九| 亚洲免费视频中文字幕| 99ri日韩精品视频| 欧美日韩视频在线观看一区二区三区| 亚洲精品一区在线观看| 亚洲国产美女精品久久久久∴| 久久久欧美一区二区| 一区在线免费| 欧美承认网站| 欧美黄色片免费观看| 一区二区欧美国产| 亚洲少妇一区| 国产片一区二区| 久久人人爽人人爽|