示例#1
0
  CEditBoxExit(int id,
	       CEGUI::Window *pParent,
	       float fButtonSize,
	       const CEGUI::String &sTitle,
	       CExit &exit) 
    : CEditBoxBase(id, pParent, fButtonSize, sTitle),
      m_Exit(exit),
      m_BackupExit(exit) {

    using namespace CEGUI;
    Combobox *pComboBox = dynamic_cast<Combobox*>(m_pWindow->createChild("OgreTray/Combobox", "ExitSelect"));
    m_pCombobox = pComboBox;
    pComboBox->setPosition(UVector2(UDim(0, 0), UDim(0, 0)));
    pComboBox->setSize(USize(UDim(1, 0), UDim(0, 3 * fButtonSize)));
    pComboBox->addItem(new ListboxTextItem("Region"));
    pComboBox->addItem(new ListboxTextItem("Enemy death"));
    pComboBox->setAutoSizeListHeightToContent(true);
    pComboBox->setReadOnly(true);
    pComboBox->subscribeEvent(Combobox::EventListSelectionAccepted,
			      Event::Subscriber(&CEditBoxExit::onListSelectionChanged, this));

    // id
    m_pContentId = m_pWindow->createChild("DefaultWindow", "id");
    m_pContentId->setPosition(UVector2(UDim(0, 0), UDim(0, fButtonSize)));
    m_pContentId->setSize(USize(UDim(1, 0), UDim(0, 2 * fButtonSize)));

    Window *pLabel = m_pContentId->createChild("OgreTray/Label", "Exitidlabel");
    pLabel->setPosition(UVector2(UDim(0, 0), UDim(0, 0)));
    pLabel->setSize(USize(UDim(0, fButtonSize), UDim(0, fButtonSize)));
    pLabel->setText("id");

    Window *pEditBox = m_pContentId->createChild("OgreTray/Editbox", "Exitid");
    pEditBox->setPosition(UVector2(UDim(0, fButtonSize), UDim(0, 0)));
    pEditBox->setSize(USize(UDim(1, -fButtonSize), UDim(0, fButtonSize)));
    pEditBox->setText(m_Exit.getID());
    
    m_pContentId->setVisible(m_Exit.getExitType() == EXIT_ENEMY_DEATH);

    // region
    m_pContentRegion = m_pWindow->createChild("DefaultWindow", "region");
    m_pContentRegion->setPosition(UVector2(UDim(0, 0), UDim(0, fButtonSize)));
    m_pContentRegion->setSize(USize(UDim(1, 0), UDim(0, 2 * fButtonSize)));

    createVector(m_pContentRegion, "pos", m_Exit.getBoundingBox().getPosition().x, m_Exit.getBoundingBox().getPosition().y, fButtonSize, 0);
    createVector(m_pContentRegion, "size", m_Exit.getBoundingBox().getSize().x, m_Exit.getBoundingBox().getSize().y, fButtonSize, fButtonSize);

    m_pContentRegion->setVisible(m_Exit.getExitType() == EXIT_REGION);
    

    // default selected exit type
    m_pCombobox->setItemSelectState(m_Exit.getExitType(), true);
  }
示例#2
0
//----------------------------------------------------------------------------//
int main(int argc, char* argv[])
{
    // Create X11 window.
    Display* dpy = XOpenDisplay(0);
    int scn = DefaultScreen(dpy);
    Window wnd = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
                                     50, 50, 480, 320, 1,
                                     BlackPixel(dpy, scn),
                                     WhitePixel(dpy, scn));

    XSelectInput(dpy, wnd, StructureNotifyMask |
                           PointerMotionMask |
                           ButtonPressMask | ButtonReleaseMask |
                           KeyPressMask | KeyReleaseMask);
    XMapWindow(dpy, wnd);

    XEvent evt;
    while (true)
    {
        XNextEvent(dpy, &evt);
        if (evt.type == MapNotify)
            break;
    }

    // EGL setup
    EGLDisplay egldpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    EGLint majVer, minVer;
    eglInitialize(egldpy, &majVer, &minVer);

    EGLint attrs[] =
    {
        EGL_RED_SIZE,           8,
        EGL_GREEN_SIZE,         8,
        EGL_BLUE_SIZE,          8,
        EGL_RENDERABLE_TYPE,    EGL_OPENGL_ES_BIT,
        EGL_SURFACE_TYPE,       EGL_WINDOW_BIT,
        EGL_NONE
    };

    EGLConfig config;
    EGLint numconfigs;
    eglChooseConfig(egldpy, attrs, &config, 1, &numconfigs);

    EGLSurface surface =
        eglCreateWindowSurface(egldpy, config, (NativeWindowType)wnd, 0);

    EGLContext ctx = eglCreateContext(egldpy, config, 0, 0);
    eglMakeCurrent(egldpy, surface, surface, ctx);

    eglBindAPI(EGL_OPENGL_ES_API);

    // basic gl state setup;
    glViewport(0, 0, 480, 320);
    glClearColor(0.2, 0.2, 0.2, 1);

    // CEGUI setup
    CEGUI::OpenGLESRenderer::bootstrapSystem();
    initialiseResourceGroupDirectories();
    initialiseDefaultResourceGroups();

    CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
    CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
    CEGUI::WindowManager& winMgr(CEGUI::WindowManager::getSingleton());
    CEGUI::Window* root = winMgr.createWindow("DefaultWindow", "root");
    CEGUI::Window* fw = root->createChild("TaharezLook/FrameWindow");
    fw->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25, 0), CEGUI::UDim(0.25, 0)));
    fw->setSize(CEGUI::USize(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.5, 0)));
    fw->setText("OpenGL ES 1 Test");

    CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(root);

    // Main looop
    bool running = true;
    while (running)
    {
        while (XPending(dpy))
        {
            XNextEvent(dpy, &evt);

            switch (evt.type)
            {
            case KeyPress:
            {
                int kspkcr;
                KeySym* ks = XGetKeyboardMapping(dpy, evt.xkey.keycode, 1, &kspkcr);

                if (ks[0] == XK_Escape)
                    running = false;

                break;
            }

            case MotionNotify:
                CEGUI::System::getSingleton().getDefaultGUIContext().injectMousePosition(evt.xmotion.x, evt.xmotion.y);
                break;

            case ButtonPress:
            {
                CEGUI::MouseButton btn;
                if (evt.xbutton.button == Button1)
                    btn = CEGUI::LeftButton;
                else if (evt.xbutton.button == Button2)
                    btn = CEGUI::RightButton;
                else
                    break;

                CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseButtonDown(btn);
                break;
            }
                
            case ButtonRelease:
            {
                CEGUI::MouseButton btn;
                if (evt.xbutton.button == Button1)
                    btn = CEGUI::LeftButton;
                else if (evt.xbutton.button == Button2)
                    btn = CEGUI::RightButton;
                else
                    break;

                CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseButtonUp(btn);
                break;
            }
                
            }
        }

        glClear(GL_COLOR_BUFFER_BIT);

        CEGUI::System::getSingleton().renderAllGUIContexts();

        eglSwapBuffers(egldpy, surface);
    }

    // cleanup
    CEGUI::OpenGLESRenderer::destroySystem();

    eglMakeCurrent(egldpy, 0, 0, 0);
    eglDestroyContext(egldpy, ctx);
    eglDestroySurface(egldpy, surface);
    eglTerminate(dpy);
    eglReleaseThread();

    XCloseDisplay(dpy);

    return 0;
}
示例#3
0
文件: HUD.cpp 项目: ChWick/Mencus
CHUD::CHUD(CEGUI::Window *pGUIRoot, CGUIToolsMenu *pGUIToolsMenu)
    : m_bShotToolIndicators(pGUIToolsMenu == NULL),
      m_pGUIToolsMenu(pGUIToolsMenu),
      m_fTimer(0),
      m_fHP(1),
      m_fMP(1)
{
    m_pHudRoot = pGUIRoot->createChild("DefaultWindow", "HudRoot");
    m_pHudRoot->setInheritsAlpha(false);
    m_pHudRoot->setAlpha(1);
    m_pHudRoot->setRiseOnClickEnabled(false);
    CEGUI::ImageManager::getSingleton().loadImageset("hud.imageset");
    ImageManager::getSingleton().loadImageset("white.imageset");
    ImageManager::getSingleton().loadImageset("hud_weapons.imageset");

    CEGUI::Window *pMain = m_pHudRoot->createChild("OgreTray/StaticText", "main");
    pMain->setRiseOnClickEnabled(false);
    pMain->setProperty("BackgroundEnabled", "false");
    pMain->setProperty("FrameEnabled", "false");
    pMain->setPosition(UVector2(UDim(0, 0), UDim(0, 0)));
    pMain->setSize(USize(UDim(1, 0), UDim(1, 0)));
    //pMain->setText("test");
    //pMain->setAlpha(0.5);

    CEGUI::Window *pTopBar = pMain->createChild("OgreTray/StaticImage", "top_bar");
    pTopBar->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
    pTopBar->setSize(CEGUI::USize(CEGUI::UDim(1, 0), CEGUI::UDim(0.1667f, 0)));
    pTopBar->setProperty("Image", "hud/top_bar");
    pTopBar->setProperty("FrameEnabled","False");
    pTopBar->setProperty("BackgroundEnabled","False");
    pTopBar->setRiseOnClickEnabled(false);

    Window *pBottomBar = pMain->createChild("OgreTray/StaticImage", "bottom_bar");
    pBottomBar->setSize(USize(UDim(0.28125, 0), UDim(0.05859375, 0)));
    pBottomBar->setPosition(UVector2(UDim(0.359375, 0), UDim(0.94140625, 0)));
    pBottomBar->setProperty("Image", "hud/bottom_bar");
    pBottomBar->setProperty("FrameEnabled","False");
    pBottomBar->setProperty("BackgroundEnabled","False");
    pBottomBar->setRiseOnClickEnabled(false);

    m_pFpsText = pBottomBar->createChild("OgreTray/StaticText", "fpstext");
    m_pFpsText->setProperty("TextColours", "FFFFFFFF");
    m_pFpsText->setProperty("FrameEnabled","False");
    m_pFpsText->setProperty("BackgroundEnabled","False");
    m_pFpsText->setSize(USize(UDim(0.2, 0), UDim(0.3, 0)));
    m_pFpsText->setPosition(UVector2(UDim(0.605, 0), UDim(0.66, 0)));
    m_pFpsText->setText("00");
    m_pFpsText->setFont("dejavusans8");
    m_pFpsText->setRiseOnClickEnabled(false);

    m_pTimeText = pBottomBar->createChild("OgreTray/StaticText", "timetext");
    m_pTimeText->setProperty("TextColours", "FFFFFFFF");
    m_pTimeText->setProperty("FrameEnabled","False");
    m_pTimeText->setProperty("BackgroundEnabled","False");
    m_pTimeText->setSize(USize(UDim(0.3, 0), UDim(0.3, 0)));
    m_pTimeText->setPosition(UVector2(UDim(0.22, 0), UDim(0.66, 0)));
    m_pTimeText->setText("0:00:00");
    m_pTimeText->setFont("dejavusans8");
    m_pTimeText->setRiseOnClickEnabled(false);

    m_pHealthBar = pMain->createChild("OgreTray/StaticImage", "healthbar");
    m_pHealthBar->setProperty("ImageColours", "FFFF00FF");
    m_pHealthBar->setProperty("Image", "white/full_image");
    m_pHealthBar->setProperty("FrameEnabled","False");
    m_pHealthBar->setProperty("BackgroundEnabled","True");
    m_pHealthBar->setPosition(UVector2(UDim(0.051757813, 0), UDim(0.026041667, 0)));
    m_pHealthBar->setRiseOnClickEnabled(false);

    m_pManaBar = pMain->createChild("OgreTray/StaticImage", "manabar");
    m_pManaBar->setProperty("ImageColours", "FFFF00FF");
    m_pManaBar->setProperty("Image", "white/full_image");
    m_pManaBar->setProperty("FrameEnabled", "False");
    m_pManaBar->setProperty("BackgroundEnabled", "True");
    m_pManaBar->setPosition(UVector2(UDim(0.772460938, 0), UDim(0.026041667, 0)));
    m_pManaBar->setRiseOnClickEnabled(false);

#if ENABLE_INPUT_TOUCH != 1
    Window *pWeaponContainer = pMain->createChild("OgreTray/StaticImage", "weaponContainer");
    pWeaponContainer->setProperty("FrameEnabled", "False");
    pWeaponContainer->setProperty("BackgroundEnabled", "False");
    pWeaponContainer->setProperty("Image", "hud/weapon_indicator");
    pWeaponContainer->setPosition(UVector2(UDim(0, 0), UDim(0.908854, 0)));
    pWeaponContainer->setSize(USize(UDim(0.0683594, 0), UDim(0.091145833, 0)));

    m_pWeapon = pMain->createChild("OgreTray/StaticImage", "weapon");
    m_pWeapon->setProperty("FrameEnabled", "False");
    m_pWeapon->setProperty("BackgroundEnabled", "True");
    m_pWeapon->setPosition(UVector2(UDim(0.020507813, 0), UDim(0.936197917, 0)));
    m_pWeapon->setSize(USize(UDim(0.028320313, 0), UDim(0.037760417, 0)));
#endif

    if (m_bShotToolIndicators) {
        Window *pImg = pMain->createChild("OgreTray/StaticImage", "HPImg");
        pImg->setProperty("FrameEnabled","False");
        pImg->setProperty("BackgroundEnabled","False");
        pImg->setSize(CEGUI::USize(UDim(0, 32), UDim(0, 32)));
        pImg->setPosition(CEGUI::UVector2(CEGUI::UDim(0.8, -16), CEGUI::UDim(0.98, -24)));
        pImg->setProperty("Image", "hud_weapons/health_potion");

        m_pHealthPotionsCount = pMain->createChild("OgreTray/StaticText", "HPCount");
        m_pHealthPotionsCount->setProperty("TextColours", "FFFFFFFF");
        m_pHealthPotionsCount->setProperty("FrameEnabled","False");
        m_pHealthPotionsCount->setProperty("BackgroundEnabled","False");
        m_pHealthPotionsCount->setFont("dejavusans8");
        m_pHealthPotionsCount->setSize(CEGUI::USize(UDim(0.1, 0), UDim(0.02,0)));
        m_pHealthPotionsCount->setPosition(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.98, -8)));
        m_pHealthPotionsCount->setText("0");

        pImg = pMain->createChild("OgreTray/StaticImage", "MPImg");
        pImg->setProperty("FrameEnabled","False");
        pImg->setProperty("BackgroundEnabled","False");
        pImg->setSize(CEGUI::USize(UDim(0, 32), UDim(0, 32)));
        pImg->setPosition(CEGUI::UVector2(CEGUI::UDim(0.84, -16), CEGUI::UDim(0.98, -24)));
        pImg->setProperty("Image", "hud_weapons/mana_potion");

        m_pManaPotionsCount = pMain->createChild("OgreTray/StaticText", "MPCount");
        m_pManaPotionsCount->setProperty("TextColours", "FFFFFFFF");
        m_pManaPotionsCount->setProperty("FrameEnabled","False");
        m_pManaPotionsCount->setProperty("BackgroundEnabled","False");
        m_pManaPotionsCount->setFont("dejavusans8");
        m_pManaPotionsCount->setSize(CEGUI::USize(UDim(0.1, 0), UDim(0.02,0)));
        m_pManaPotionsCount->setPosition(CEGUI::UVector2(CEGUI::UDim(0.84, 0), CEGUI::UDim(0.98, -8)));
        m_pManaPotionsCount->setText("0");

        pImg = pMain->createChild("OgreTray/StaticImage", "KeyImg");
        pImg->setProperty("FrameEnabled","False");
        pImg->setProperty("BackgroundEnabled","False");
        pImg->setSize(CEGUI::USize(UDim(0, 32), UDim(0, 32)));
        pImg->setPosition(CEGUI::UVector2(CEGUI::UDim(0.88, -16), CEGUI::UDim(0.98, -20)));
        pImg->setProperty("Image", "hud_weapons/keys");

        m_pKeyCount = pMain->createChild("OgreTray/StaticText", "KeyCount");
        m_pKeyCount->setProperty("TextColours", "FFFFFFFF");
        m_pKeyCount->setProperty("FrameEnabled","False");
        m_pKeyCount->setProperty("BackgroundEnabled","False");
        m_pKeyCount->setFont("dejavusans8");
        m_pKeyCount->setSize(CEGUI::USize(UDim(0.1, 0), UDim(0.02,0)));
        m_pKeyCount->setPosition(CEGUI::UVector2(CEGUI::UDim(0.88, 0), CEGUI::UDim(0.98, -8)));
        m_pKeyCount->setText("0");

        pImg = pMain->createChild("OgreTray/StaticImage", "BombImg");
        pImg->setProperty("FrameEnabled","False");
        pImg->setProperty("BackgroundEnabled","False");
        pImg->setSize(CEGUI::USize(UDim(0, 32), UDim(0, 32)));
        pImg->setPosition(CEGUI::UVector2(CEGUI::UDim(0.92, -16), CEGUI::UDim(0.98, -24)));
        pImg->setProperty("Image", "hud_weapons/bomb");

        m_pBombCount = pMain->createChild("OgreTray/StaticText", "BombCount");
        m_pBombCount->setProperty("TextColours", "FFFFFFFF");
        m_pBombCount->setProperty("FrameEnabled","False");
        m_pBombCount->setProperty("BackgroundEnabled","False");
        m_pBombCount->setFont("dejavusans8");
        m_pBombCount->setSize(CEGUI::USize(UDim(0.1, 0), UDim(0.02,0)));
        m_pBombCount->setPosition(CEGUI::UVector2(CEGUI::UDim(0.92, 0), CEGUI::UDim(0.98, -8)));
        m_pBombCount->setText("0");
    }

    // initialise hp, mp
    setHP(m_fHP);
    setMP(m_fMP);
    setCurrentWeapon(Weapon::W_BOLT);

    hide();
}
示例#4
0
CGUIStatistics::CGUIStatistics(Window *pRoot)
  : m_iSelectedSlot(0) {
  CInputListenerManager::getSingleton().addInputListener(this);
  // create cegui windows/buttons
  Window *pStatisticsRoot = pRoot->createChild("DefaultWindow", "GUIStatisticsRoot");
  pStatisticsRoot->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
  pStatisticsRoot->setSize(CEGUI::USize(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
  pStatisticsRoot->setInheritsAlpha(false);
  pStatisticsRoot->setAlpha(1);
  pStatisticsRoot->setRiseOnClickEnabled(false);
  pStatisticsRoot->moveToBack();
  m_pStatisticsRoot = pStatisticsRoot;

  CEGUI::Window *pBackground = pStatisticsRoot->
    createChild("OgreTray/StaticImage", "Background");
  pBackground->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
  pBackground->setSize(CEGUI::USize(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
  pBackground->setInheritsAlpha(false);
  pBackground->setAlpha(1);
  pBackground->setProperty("Image", "main_menu_background/full");
  pBackground->setProperty("FrameEnabled", "False");
  pBackground->setProperty("BackgroundEnabled", "True");
  pBackground->setRiseOnClickEnabled(false);

  CEGUI::Window *pButtonContainer = pStatisticsRoot->createChild("DefaultWindow", "ButtonContainer");
  pButtonContainer->setPosition(UVector2(UDim(0, 0), UDim(0, 0)));
  pButtonContainer->setSize(USize(UDim(1, 0), UDim(1, 0)));

  CEGUI::Window *pFinishedText = pButtonContainer->createChild("OgreTray/Titlebar", "text");
  pFinishedText->setFont("dejavusans20");
  pFinishedText->setText("unset");
  pFinishedText->setPosition(UVector2(UDim(0.05,0), UDim(0.05,0)));
  pFinishedText->setSize(USize(UDim(0.9, 0), UDim(0.1, 0)));

  CEGUI::Window *pStatisticsGroup = pButtonContainer->createChild("OgreTray/Group", "statisticsgroup");
  pStatisticsGroup->setFont("dejavusans16");
  pStatisticsGroup->setText(XMLResources::GLOBAL.getCEGUIString("Statistics"));
  pStatisticsGroup->setPosition(UVector2(UDim(0.1, 0), UDim(0.2, 0)));
  pStatisticsGroup->setSize(USize(UDim(0.8, 0), UDim(0.5, 0)));

  CEGUI::Window *pRetryButton = pButtonContainer->createChild("OgreTray/Button", "Retry");
  pRetryButton->setPosition(UVector2(UDim(0.1, 0), UDim(0.8, 0)));
  pRetryButton->setSize(USize(UDim(0.3, 0), UDim(0.15, 0)));
  pRetryButton->setFont("dejavusans16");
  pRetryButton->setText(XMLResources::GLOBAL.getCEGUIString("Retry"));
  m_pButtons[BT_RETRY] = pRetryButton;
  pRetryButton->subscribeEvent(
			       CEGUI::PushButton::EventClicked,
			       CEGUI::Event::Subscriber(&CGUIStatistics::onRetryClicked, this));


  CEGUI::Window *pToMenuButton = pButtonContainer->createChild("OgreTray/Button", "ToMenu");
  pToMenuButton->setPosition(UVector2(UDim(0.6, 0), UDim(0.8, 0)));
  pToMenuButton->setSize(USize(UDim(0.3, 0), UDim(0.15, 0)));
  pToMenuButton->setFont("dejavusans16");
  pToMenuButton->setText(XMLResources::GLOBAL.getCEGUIString("To level selection"));
  pToMenuButton->subscribeEvent(
				CEGUI::PushButton::EventClicked,
				CEGUI::Event::Subscriber(&CGUIStatistics::onToMenuClicked, this));
  m_pButtons[BT_TO_MENU] = pToMenuButton;

  for (int i = 0; i < L_COUNT; i++) {
    createLabel(i, pStatisticsGroup, false);
    createLabel(i, pStatisticsGroup, true);
  }

  hide();
}