Example #1
0
void HUDDemo::createScorePopup(const CEGUI::Vector2<float>& mousePos, int points)
{
    CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();

    CEGUI::Window* popupWindow = winMgr.createWindow("HUDDemo/PopupLabel");
    d_rootIngame->addChild(popupWindow);
    popupWindow->setPosition(CEGUI::UVector2(cegui_absdim(mousePos.d_x), cegui_absdim(mousePos.d_y)));
    popupWindow->setText(CEGUI::PropertyHelper<int>::toString(points));
    popupWindow->setRiseOnClickEnabled(false);
    popupWindow->subscribeEvent(AnimationInstance::EventAnimationEnded, Event::Subscriber(&HUDDemo::handleScorePopupAnimationEnded, this));
    popupWindow->setPixelAligned(false);
    popupWindow->setFont("DejaVuSans-14");

    popupWindow->setPosition(popupWindow->getPosition() + CEGUI::UVector2(cegui_reldim(0.03f), cegui_reldim(-0.02f)));

    if(points < 0)
        popupWindow->setProperty("NormalTextColour", "FF880000");
    else
    {
        popupWindow->setText( "+" + popupWindow->getText());
        popupWindow->setProperty("NormalTextColour", "FF006600");
    }

    CEGUI::EventArgs args;
    popupWindow->fireEvent("StartAnimation", args);
}
Example #2
0
CEGUI::Window* HUDDemo::spawnPlate()
{
    CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();

    CEGUI::Window* plateRoot = winMgr.createWindow("DefaultWindow");
    plateRoot->setSize(CEGUI::USize(cegui_absdim(0.0f), cegui_reldim(0.16f)));
    plateRoot->setAspectMode(CEGUI::AM_EXPAND);
    plateRoot->setAspectRatio(1.0f);
    plateRoot->setRiseOnClickEnabled(false);
    plateRoot->setPixelAligned(false);
    plateRoot->subscribeEvent(CEGUI::Window::EventMouseButtonDown, Event::Subscriber(&HUDDemo::handlePlateWindowClicked, this));
    d_rootIngame->addChild(plateRoot);

    CEGUI::Window* plateImgWnd = winMgr.createWindow("Generic/Image", "ImageWindowPlate");
    plateImgWnd->setProperty("Image", s_imageNamePlate);
    plateImgWnd->setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_absdim(0.0f)));
    plateImgWnd->setAspectRatio(3.308f);
    plateImgWnd->setAspectMode(CEGUI::AM_EXPAND);
    plateImgWnd->setVerticalAlignment(CEGUI::VA_BOTTOM);
    plateImgWnd->setMousePassThroughEnabled(true);
    plateImgWnd->setPixelAligned(false);
    plateRoot->addChild(plateImgWnd);

    CEGUI::String image = getRandomGameImage();

    CEGUI::Window* plateTopping = winMgr.createWindow("Generic/Image", "ImageWindowObject");
    plateTopping->setProperty("Image", image);
    plateTopping->setSize(CEGUI::USize(cegui_reldim(0.88f), cegui_absdim(0.0f)));
    plateTopping->setAspectRatio(1.0f);
    plateTopping->setAspectMode(CEGUI::AM_EXPAND);
    plateTopping->setHorizontalAlignment(CEGUI::HA_CENTRE);
    plateTopping->setMousePassThroughEnabled(true);
    plateTopping->setPixelAligned(false);
    plateRoot->addChild(plateTopping);


    int randumNumber = rand() % 10000;
    float posY = randumNumber / 10000.0f;

    plateRoot->setPosition(CEGUI::UVector2(cegui_absdim(0.0f), cegui_reldim(0.1f + 0.6f * posY)));

    return plateRoot;
}
Example #3
0
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();
}
Example #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();
}