示例#1
0
//----------------------------------------------------------------------------//
void GridLayoutContainer::layout()
{
    std::vector<UDim> colSizes(d_gridWidth, UDim(0, 0));
    std::vector<UDim> rowSizes(d_gridHeight, UDim(0, 0));

    // used to compare UDims
    const float absWidth = getChildContentArea().get().getWidth();
    const float absHeight = getChildContentArea().get().getHeight();

    // first, we need to determine rowSizes and colSizes, this is needed before
    // any layouting work takes place
    for (size_t y = 0; y < d_gridHeight; ++y)
    {
        for (size_t x = 0; x < d_gridWidth; ++x)
        {
            // x and y is the position of window in the grid
            const size_t childIdx =
                mapFromGridToIdx(x, y, d_gridWidth, d_gridHeight);

            Window* window = getChildAtIdx(childIdx);
            const UVector2 size = getBoundingSizeForWindow(window);

            if (CoordConverter::asAbsolute(colSizes[x], absWidth) <
                CoordConverter::asAbsolute(size.d_x, absWidth))
            {
                colSizes[x] = size.d_x;
            }

            if (CoordConverter::asAbsolute(rowSizes[y], absHeight) <
                CoordConverter::asAbsolute(size.d_y, absHeight))
            {
                rowSizes[y] = size.d_y;
            }
        }
    }

    // OK, now in rowSizes[y] is the height of y-th row
    //         in colSizes[x] is the width of x-th column

    // second layouting phase starts now
    for (size_t y = 0; y < d_gridHeight; ++y)
    {
        for (size_t x = 0; x < d_gridWidth; ++x)
        {
            // x and y is the position of window in the grid
            const size_t childIdx = mapFromGridToIdx(x, y,
                                                     d_gridWidth, d_gridHeight);
            Window* window = getChildAtIdx(childIdx);
            const UVector2 offset = getOffsetForWindow(window);
            const UVector2 gridCellOffset = getGridCellOffset(colSizes,
                                                              rowSizes,
                                                              x, y);

            window->setPosition(gridCellOffset + offset);
        }
    }

    // now we just need to determine the total width and height and set it
    setSize(getGridSize(colSizes, rowSizes));
}
示例#2
0
//------------------------------------------------------------------------------//
bool InventoryReceiver::addItemAtLocation(InventoryItem& item, int x, int y)
{
    if (itemWillFitAtLocation(item, x, y))
    {
        InventoryReceiver* old_receiver =
            dynamic_cast<InventoryReceiver*>(item.getParent());

        if (old_receiver)
            old_receiver->removeItem(item);

        item.setLocationOnReceiver(x, y);
        writeItemToContentMap(item);
        addChild(&item);

        // set position and size.  This ensures the items visually match the
        // logical content map.


        item.setPosition(UVector2(UDim(static_cast<float>(x) / contentWidth(), 0),
                                  UDim(static_cast<float>(y) / contentHeight(), 0)));
        item.setSize(USize(
            UDim(static_cast<float>(item.contentWidth()) / contentWidth(), 0),
            UDim(static_cast<float>(item.contentHeight()) / contentHeight(), 0)));

        return true;
    }

    return false;
}
    bool CharacterSelectionWindow::update()
    {
        Party party = PartyManager::getSingleton().getCharacters();
        
        while (party.size() > mCharacterWindows.size())
        {
            Element* elem = new Element(this);
            mCharacterWindow->addChildWindow(elem->getWindow());
            CEGUI::Size size = elem->getWindow()->getPixelSize();
            size_t windowNum = mCharacterWindows.size();
			elem->getWindow()->setPosition(UVector2(UDim(0, 0), UDim(0, windowNum * size.d_height)));
            elem->setVisible(true);
            elem->getWindow()->subscribeEvent(
                 Window::EventMouseClick,
                 boost::bind(&CharacterSelectionWindow::handleClickOnCharacter, this, windowNum));
            
            mCharacterWindows.push_back(elem);
        }
        
        while (party.size() < mCharacterWindows.size())
        {
            Element* elem = mCharacterWindows.back();
            mCharacterWindows.pop_back();
            mCharacterWindow->removeChildWindow(elem->getWindow());
            delete elem;
        }
        
        for (unsigned int i = 0; i < party.size(); ++i)
        {
            mCharacterWindows[i]->setCreature(party[i]);
        }
        
        return true;
    }
//----------------------------------------------------------------------------//
void RenderedStringWidgetComponent::draw(GeometryBuffer& /*buffer*/,
                                         const Vector2& position,
                                         const CEGUI::ColourRect* /*mod_colours*/,
                                         const Rect* /*clip_rect*/,
                                         const float vertical_space,
                                         const float /*space_extra*/) const
{
    if (!d_window)
        return;

    // HACK: re-adjust for inner-rect of parent
    float x_adj = 0, y_adj = 0;
    Window* parent = d_window->getParent();
    
    if (parent)
    {
        const CEGUI::Rect outer(parent->getUnclippedOuterRect());
        const CEGUI::Rect inner(parent->getUnclippedInnerRect());
        x_adj = inner.d_left - outer.d_left;
        y_adj = inner.d_top - outer.d_top;
    }
    // HACK: re-adjust for inner-rect of parent (Ends)

    Vector2 final_pos(position);
    // handle formatting options
    switch (d_verticalFormatting)
    {
    case VF_BOTTOM_ALIGNED:
        final_pos.d_y += vertical_space - getPixelSize().d_height;
        break;

    case VF_STRETCHED:
        Logger::getSingleton().logEvent("RenderedStringWidgetComponent::draw: "
            "VF_STRETCHED specified but is unsupported for Widget types; "
            "defaulting to VF_CENTRE_ALIGNED instead.");
        
        // intentional fall-through.
        
    case VF_CENTRE_ALIGNED:
        final_pos.d_y += (vertical_space - getPixelSize().d_height) / 2 ;
        break;


    case VF_TOP_ALIGNED:
        // nothing additional to do for this formatting option.
        break;

    default:
        CEGUI_THROW(InvalidRequestException("RenderedStringTextComponent::draw: "
                "unknown VerticalFormatting option specified."));
    }

    // we do not actually draw the widget, we just move it into position.
    const UVector2 wpos(UDim(0, final_pos.d_x + d_padding.d_left - x_adj),
                        UDim(0, final_pos.d_y + d_padding.d_top - y_adj));

    d_window->setPosition(wpos);
}
示例#5
0
PropertyHelper<UBox>::return_type
PropertyHelper<UBox>::fromString(const String& str)
{
    UBox ret(UDim(0.0f, 0.0f), UDim(0.0f, 0.0f), UDim(0.0f, 0.0f), UDim(0.0f, 0.0f));

    if (str.empty())
        return ret;

    std::stringstream& sstream = SharedStringstream::GetPreparedStream(str);
    sstream >> ret;
    if (sstream.fail())
        throwParsingException(getDataTypeName(), str);

    return ret;
}
示例#6
0
PropertyHelper<URect>::return_type
PropertyHelper<URect>::fromString(const String& str)
{
    URect ur(UVector2(UDim(0.0f, 0.0f), UDim(0.0f, 0.0f)), UVector2(UDim(0.0f, 0.0f), UDim(0.0f, 0.0f)));

    if (str.empty())
        return ur;

    std::stringstream& sstream = SharedStringstream::GetPreparedStream(str);
    sstream >> ur;
    if (sstream.fail())
        throwParsingException(getDataTypeName(), str);

    return ur;
}
示例#7
0
Window *DFMenuBase::getItem(const string &parentId)
{
    createMyId(parentId);

    WindowManager &wmgr = WindowManager::getSingleton();
    auto button = static_cast<PushButton *>(wmgr.createWindow(
        InterfaceConfig::schemeButtonMenus + "/Button", id));
    button->setText(label);
    Font &font = FontManager::getSingleton().get(InterfaceConfig::menuButtonFont);
    button->setFont(&font);
    button->setSize(UVector2(UDim(0, InterfaceConfig::menuButtonWidth), UDim(0, InterfaceConfig::menuButtonHeight)));
    button->setMargin(UBox(UDim(0, InterfaceConfig::menuButtonMargin)));

    return button;
}
示例#8
0
//----------------------------------------------------------------------------//
Window* GridLayoutContainer::createDummy()
{
    char i_buff[32];
    sprintf(i_buff, "%lu", d_nextDummyIdx);
    ++d_nextDummyIdx;

    Window* dummy = WindowManager::getSingleton().createWindow("DefaultWindow",
                    DummyName + String(i_buff));

    dummy->setAutoWindow(true);
    dummy->setVisible(false);
    dummy->setSize(USize(UDim(0, 0), UDim(0, 0)));
    dummy->setDestroyedByParent(true);

    return dummy;
}
//----------------------------------------------------------------------------//
void HorizontalLayoutContainer::layout()
{
    // used to compare UDims
    const float absHeight = getChildContentArea().get().getHeight();

    // this is where we store the left offset
    // we continually increase this number as we go through the windows
    UDim leftOffset(0, 0);
    UDim layoutHeight(0, 0);

    for (ChildList::iterator it = d_children.begin(); it != d_children.end(); ++it)
    {
        Window* window = static_cast<Window*>(*it);

        const UVector2 offset = getOffsetForWindow(window);
        const UVector2 boundingSize = getBoundingSizeForWindow(window);

        // full child window width, including margins
        const UDim& childHeight = boundingSize.d_y;

        if (CoordConverter::asAbsolute(layoutHeight, absHeight) <
            CoordConverter::asAbsolute(childHeight, absHeight))
        {
            layoutHeight = childHeight;
        }

        window->setPosition(offset + UVector2(leftOffset, UDim(0, 0)));
        leftOffset += boundingSize.d_x;
    }

    setSize(USize(leftOffset, layoutHeight));
}
/*************************************************************************
	Processing for drag-sizing the segment
*************************************************************************/
void ListHeaderSegment::doDragSizing(const Point& local_mouse)
{
    float delta = local_mouse.d_x - d_dragPoint.d_x;

    // store this so we can work out how much size actually changed
    float orgWidth = d_pixelSize.d_width;

    // ensure that we only size to the set constraints.
    //
    // NB: We are required to do this here due to our virtually unique sizing nature; the
    // normal system for limiting the window size is unable to supply the information we
    // require for updating our internal state used to manage the dragging, etc.
    float maxWidth(d_maxSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getDisplaySize().d_width));
    float minWidth(d_minSize.d_x.asAbsolute(System::getSingleton().getRenderer()->getDisplaySize().d_width));
    float newWidth = orgWidth + delta;

    if (newWidth > maxWidth)
        delta = maxWidth - orgWidth;
    else if (newWidth < minWidth)
        delta = minWidth - orgWidth;
    
    // update segment area rect
    URect area(d_area.d_min.d_x, d_area.d_min.d_y, d_area.d_max.d_x + UDim(0,PixelAligned(delta)), d_area.d_max.d_y);
    setArea_impl(area.d_min, area.getSize());

    // move the dragging point so mouse remains 'attached' to edge of segment
    d_dragPoint.d_x += d_pixelSize.d_width - orgWidth;

    WindowEventArgs args(this);
    onSegmentSized(args);
}
示例#11
0
//----------------------------------------------------------------------------//
USize GridLayoutContainer::getGridSize(const std::vector<UDim>& colSizes,
        const std::vector<UDim>& rowSizes) const
{
    USize ret(UDim(0, 0), UDim(0, 0));

    for (size_t i = 0; i < colSizes.size(); ++i)
    {
        ret.d_width += colSizes[i];
    }

    for (size_t i = 0; i < rowSizes.size(); ++i)
    {
        ret.d_height += rowSizes[i];
    }

    return ret;
}
 DragContainer::DragContainer(const String& type, const String& name) :
     Window(type, name),
     d_draggingEnabled(true),
     d_leftMouseDown(false),
     d_dragging(false),
     d_dragThreshold(8.0f),
     d_dragAlpha(0.5f),
     d_dropTarget(0),
     d_dragCursorImage((const Image*)DefaultMouseCursor),
     d_dropflag(false),
     d_stickyMode(false),
     d_pickedUp(false),
     d_usingFixedDragOffset(false),
     d_fixedDragOffset(UDim(0, 0), UDim(0, 0))
 {
     addDragContainerProperties();
 }
//----------------------------------------------------------------------------//
UVector2 LayoutContainer::getBoundingSizeForWindow(Window* window) const
{
    const Sizef& pixelSize = window->getPixelSize();

    // we rely on pixelSize rather than mixed absolute and relative getSize
    // this seems to solve problems when windows overlap because their size
    // is constrained by min size
    const UVector2 size(UDim(0, pixelSize.d_width), UDim(0, pixelSize.d_height));
    // todo: we still do mixed absolute/relative margin, should we convert the
    //       value to absolute?
    const UBox& margin = window->getMargin();

    return UVector2(
               margin.d_left + size.d_x + margin.d_right,
               margin.d_top + size.d_y + margin.d_bottom
           );
}
示例#14
0
void IconBar::repositionIcons()
{
    float accumulatedWidth(0);
    float maxHeight(0);

    for(IconBaseStore::iterator I(mIconBases.begin()); I != mIconBases.end(); ++I) {
        IconBase* icon = (*I);
        const UVector2& size = icon->getContainer()->getSize();
        float absHeight = size.d_y.asAbsolute(0);
        float absWidth = size.d_x.asAbsolute(0);
        maxHeight = std::max<float>(maxHeight, absHeight);

        icon->getContainer()->setPosition(UVector2(UDim(0, accumulatedWidth), UDim(0,0)));

        accumulatedWidth += absWidth + mIconPadding;
    }
    accumulatedWidth -= mIconPadding;
    mWindow->setSize(UVector2(UDim(0, accumulatedWidth), UDim(0,maxHeight)));
    //We need to call this to guarantee that cegui correctly renders any newly added icons.
    mWindow->notifyScreenAreaChanged();
}
示例#15
0
//----------------------------------------------------------------------------//
UVector2 GridLayoutContainer::getGridCellOffset(
        const std::vector<UDim>& colSizes,
        const std::vector<UDim>& rowSizes,
        size_t gridX, size_t gridY) const
{
    assert(gridX < d_gridWidth);
    assert(gridY < d_gridHeight);

    UVector2 ret(UDim(0, 0), UDim(0, 0));

    for (size_t i = 0; i < gridX; ++i)
    {
        ret.d_x += colSizes[i];
    }

    for (size_t i = 0; i < gridY; ++i)
    {
        ret.d_y += rowSizes[i];
    }

    return ret;
}
示例#16
0
void GuiConfig::Build(ZProtoGUI *pGUI)
{
	mGUI = (ZProtoGUI*)pGUI;
	root = mGUI->root;
	mFontArial8 = mGUI->mFontArial8;
	mFontArial24 = mGUI->mFontArial24;


	// Create a FrameWindow in the TaharezLook style, and name it 'Demo Window'
	mCondigWindow = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Config Window");
	mCondigWindow->setTitleBarEnabled(false);
	mCondigWindow->setCloseButtonEnabled(false);
	mCondigWindow->setSizingEnabled(false);
	root->addChildWindow(mCondigWindow);
	mCondigWindow->setAlpha(0.6f);
	mCondigWindow ->hide();
	mCondigWindow->setSizingEnabled(false);


	FrameWindow* wnd1 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage0");
	wnd1->setTitleBarEnabled(false);
	wnd1->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd1->setCloseButtonEnabled(false);
	wnd1->setText(GLoc->GetString("PLAYER").c_str());


	FrameWindow* wnd2 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage1");
	wnd2->setTitleBarEnabled(false);
	wnd2->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd2->setCloseButtonEnabled(false);
	wnd2->setText(GLoc->GetString("Controls").c_str());


	FrameWindow* wnd3 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage2");
	wnd3->setTitleBarEnabled(false);
	wnd3->setCloseButtonEnabled(false);
	wnd3->setText(GLoc->GetString("Graphics").c_str());
	wnd3->setFrameEnabled(false);//

	FrameWindow* wnd4 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage3");
	wnd4->setTitleBarEnabled(false);
	wnd4->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd4->setCloseButtonEnabled(false);
	wnd4->setText(GLoc->GetString("SOUND").c_str());
	//wnd->addChildWindow (winMgr.loadWindowLayout ("TabControlDemo.layout", "TabControlDemo/"));

	TabControl *tc = (TabControl *)winMgr.createWindow("TaharezLook/TabControl", "Config/Tabs");

	mCondigWindow->setPosition(UVector2(cegui_reldim(0.f), cegui_reldim( 0.f)));
	mCondigWindow->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 0.9f)));
	tc->setArea(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.05f)), UVector2(cegui_reldim(0.9f), cegui_reldim( 0.85f)) );



	// Add some pages to tab control
	tc->addTab (wnd1);
	tc->addTab (wnd2);
	tc->addTab (wnd3);
	tc->addTab (wnd4);

	tc->setTabHeight(UDim (0.06f, 0.13f));
	tc->setTabTextPadding(UDim (0.06f, 0.1f));


	mCondigWindow->addChildWindow(tc);

	mCondigWindow->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0.15f)));
	mCondigWindow->setSize(UVector2(cegui_reldim(1.1f), cegui_reldim( 0.70f)));
	mCondigWindow->setAlpha(0.88f);


	wnd1->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd1->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd2->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd2->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd3->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd3->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd4->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd4->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	// controls


	for (int allCtrl = 0;allCtrl<sizeof(aCtrlList)/sizeof(CTRLEntry); allCtrl++)
	{
		static const float interligne = 0.06f*1.6f;
		static const float intersize = 0.05f*1.4f;
		tstring numb;
		numb.Printf("%d", allCtrl);

		Window* txtlib = winMgr.createWindow("TaharezLook/StaticText", String(aCtrlList[allCtrl].mName)+String("CtrlLib")+String(numb.c_str()));

		txtlib->setText(GLoc->GetString(aCtrlList[allCtrl].mName).c_str());
		txtlib->setProperty("FrameEnabled", "false");
		txtlib->setProperty("BackgroundEnabled", "false");
		//txtlib->setHorizontalAlignment(HA_CENTRE);
		txtlib->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.01f + interligne*allCtrl)));
		txtlib->setSize(UVector2(cegui_reldim(0.19f), cegui_reldim( intersize )));

		wnd2->addChildWindow(txtlib);



		PushButton* txtBut = (PushButton*)winMgr.createWindow("TaharezLook/Button", String(aCtrlList[allCtrl].mName)+String("CtrlBut")+String(numb.c_str()));
		txtBut->setPosition(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.01f + interligne*allCtrl)));
		txtBut->setSize(UVector2(cegui_reldim(0.50f), cegui_reldim( intersize )));

		SetBindedControlString(allCtrl, txtBut);


		//txtBut->setText("A or PAD Button 1");
		txtBut->setHorizontalAlignment(HA_CENTRE);

		wnd2->addChildWindow(txtBut);

		txtBut->subscribeEvent ( PushButton::EventClicked,
			Event::Subscriber (&GuiConfig::handleConfigControlsBut, this));

		txtBut->setID(allCtrl);
		aCtrlList[allCtrl].mWindow = (Window*)txtBut;

	}
	// -- PLAYER

	Editbox* playerName = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "CONFIGPLAYERNAME"));
	wnd1->addChildWindow(playerName);
	playerName->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
	playerName->setSize(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.08f)));
	//playerName->setValidationString("*");
	playerName->setText(GConfig->GetPlayerName());

	Window* txtlib = winMgr.createWindow("TaharezLook/StaticText", "CONFIGPLAYERNAMESTATIC");

	txtlib->setText(GLoc->GetString("PLAYERNAME").c_str());
	txtlib->setProperty("FrameEnabled", "false");
	txtlib->setProperty("BackgroundEnabled", "false");
	txtlib->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtlib->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));

	wnd1->addChildWindow(txtlib);



	// --

	// -- SOUND

	Scrollbar* sfxslider = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "SFXVOLUME"));
	sfxslider->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
	sfxslider->setSize(UVector2(cegui_reldim(0.6f), cegui_reldim( 0.08f)));
	sfxslider->setDocumentSize (100);
	sfxslider->subscribeEvent ( Scrollbar::EventScrollPositionChanged, Event::Subscriber (&GuiConfig::handleSFXVolChanged, this));
	sfxslider->setScrollPosition(float(GConfig->GetQuality("SFXVOLUME")));
	wnd4->addChildWindow(sfxslider);


	Window* txtlibsfx = winMgr.createWindow("TaharezLook/StaticText", "SFXVOLUMESTATIC");
	txtlibsfx->setText(GLoc->GetString("SFXVOLUME").c_str());
	txtlibsfx->setProperty("FrameEnabled", "false");
	txtlibsfx->setProperty("BackgroundEnabled", "false");
	txtlibsfx->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtlibsfx->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd4->addChildWindow(txtlibsfx);



	Scrollbar* musicslider = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "MUSICVOLUME"));
	musicslider->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.15f)));
	musicslider->setSize(UVector2(cegui_reldim(0.6f), cegui_reldim( 0.08f)));
	musicslider->setDocumentSize (100);
	musicslider->subscribeEvent ( Scrollbar::EventScrollPositionChanged, Event::Subscriber (&GuiConfig::handleMusicVolChanged, this));
	musicslider->setScrollPosition(float(GConfig->GetQuality("MUSICVOLUME")));
	wnd4->addChildWindow(musicslider);


	Window* txtlibmusic = winMgr.createWindow("TaharezLook/StaticText", "MUSICVOLUMESTATIC");
	txtlibmusic->setText(GLoc->GetString("MUSICVOLUME").c_str());
	txtlibmusic->setProperty("FrameEnabled", "false");
	txtlibmusic->setProperty("BackgroundEnabled", "false");
	txtlibmusic->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.15f)));
	txtlibmusic->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd4->addChildWindow(txtlibmusic);


    Checkbox* checkMusic = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKMUSIC"));
    wnd4->addChildWindow(checkMusic);
	checkMusic->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.25f)));
	checkMusic->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkMusic->setText(GLoc->GetString("CHKMUSIC").c_str());
	checkMusic->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleChkMusicChanged, this));
	checkMusic->setSelected (GConfig->IsEnable("CHKMUSIC"));

	// --

	// -- VIDEO


    Combobox* cbresolution = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "RESOLUTION"));
    wnd3->addChildWindow(cbresolution);
    cbresolution->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
    cbresolution->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.75f)));
	cbresolution->setReadOnly(true);

	Window* txtres = winMgr.createWindow("TaharezLook/StaticText", "RESOLUTIONTXT");
	txtres->setText(GLoc->GetString("RESOLUTION").c_str());
	txtres->setProperty("FrameEnabled", "false");
	txtres->setProperty("BackgroundEnabled", "false");
	txtres->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtres->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtres);


	int optWidth = GConfig->GetQuality("Width");
	int optHeight = GConfig->GetQuality("Height");

	int awidth = -1, aheight = -1;
	int avresolutions = 0;
	for (unsigned int rs = 0;rs<GDD->GetNbPossibleResolutions(); rs++)
	{
		char tmps[512];
		int width, height;
		GDD->GetResolution(rs, width, height);
		if ((awidth != width) || (aheight != height))
		{
			awidth = width;
			aheight = height;

			mResolutions.push_back(resval_t(width, height));
			snprintf(tmps, 512, "%d x %d", width, height);
			cbresolution->addItem (new ListboxTextItem(tmps));

			if ((width == optWidth)&&(height == optHeight))
				CEGUICBSel(cbresolution, avresolutions);

			avresolutions++;
		}
	}



	// --

    Checkbox* checkFS = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKBFS"));
    wnd3->addChildWindow(checkFS);
	checkFS->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.15f)));
	checkFS->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkFS->setText(GLoc->GetString("FULLSCREEN").c_str());
	//checkFS->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleFSChanged, this));
	checkFS->setSelected (GConfig->IsEnable("CHKBFS"));


    Checkbox* checkVSync = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKBVSYNC"));
    wnd3->addChildWindow(checkVSync);
	checkVSync->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.75f)));
	checkVSync->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkVSync->setText(GLoc->GetString("VSYNC").c_str());
	//checkVSync->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleVSYNCChanged, this));
	checkVSync->setSelected (GConfig->IsEnable("CHKBVSYNC"));

	// --

    Combobox* cbshad = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "SHADOWQUALITY"));
    wnd3->addChildWindow(cbshad);
    cbshad->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.25f)));
    cbshad->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbshad->setReadOnly(true);

	Window* txtshad = winMgr.createWindow("TaharezLook/StaticText", "SHADOWQUALITYTXT");
	txtshad->setText(GLoc->GetString("SHADOWQUALITY").c_str());
	txtshad->setProperty("FrameEnabled", "false");
	txtshad->setProperty("BackgroundEnabled", "false");
	txtshad->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.25f)));
	txtshad->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtshad);

	cbshad->addItem (new ListboxTextItem(GLoc->GetString("DISABLED").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));

	cbshad->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleShadowQualityChanged, this));
	CEGUICBSel(cbshad, GConfig->GetQuality("SHADOWQUALITY"));
	// --

    Combobox* cbrefl = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "REFLECTIONQUALITY"));
    wnd3->addChildWindow(cbrefl);
    cbrefl->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.35f)));
    cbrefl->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbrefl->setReadOnly(true);

	Window* txtrefl = winMgr.createWindow("TaharezLook/StaticText", "REFLECTIONQUALITYTXT");
	txtrefl->setText(GLoc->GetString("REFLECTIONQUALITY").c_str());
	txtrefl->setProperty("FrameEnabled", "false");
	txtrefl->setProperty("BackgroundEnabled", "false");
	txtrefl->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.35f)));
	txtrefl->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtrefl);

	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("DISABLED").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));
	cbrefl->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleReflectionQualityChanged, this));
	CEGUICBSel(cbrefl, GConfig->GetQuality("REFLECTIONQUALITY"));
	// --
    Combobox* cbwater = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "WATERQUALITY"));
    wnd3->addChildWindow(cbwater);
    cbwater->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.45f)));
    cbwater->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbwater->setReadOnly(true);

	Window* txtwater = winMgr.createWindow("TaharezLook/StaticText", "WATERQUALITYTXT");
	txtwater->setText(GLoc->GetString("WATERQUALITY").c_str());
	txtwater->setProperty("FrameEnabled", "false");
	txtwater->setProperty("BackgroundEnabled", "false");
	txtwater->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.45f)));
	txtwater->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtwater);

	cbwater->addItem (new ListboxTextItem(GLoc->GetString("LOW").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));
	cbwater->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleWaterQualityChanged, this));
	CEGUICBSel(cbwater, GConfig->GetQuality("WATERQUALITY"));
	// --

    Checkbox* checkDOF = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKDOF"));
    wnd3->addChildWindow(checkDOF);
	checkDOF->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.55f)));
	checkDOF->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkDOF->setText(GLoc->GetString("DEPTHOFFIELD").c_str());
	checkDOF->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleDOFChanged, this));
	checkDOF->setSelected (GConfig->IsEnable("CHKDOF"));

    Checkbox* checkMBLUR = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKMBLUR"));
    wnd3->addChildWindow(checkMBLUR);
	checkMBLUR->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.65f)));
	checkMBLUR->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkMBLUR->setText(GLoc->GetString("MOTIONBLUR").c_str());
	checkMBLUR->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleMBLURChanged, this));
	checkMBLUR->setSelected (GConfig->IsEnable("CHKMBLUR"));
/*
	Resolution

	Enable FullScreen

	shadows quality (disabled, medium, high, ultrahigh)
	0, 1024, 2048, 4096
	reflection quality (disabled, low, medium, high)
	0, 256, 512, 1024
	water quality (low, medium, high, ultra high)

	enable Depth of field
	enable motion blur

	*/

	// --
	PushButton* btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "configOK"));
	mCondigWindow->addChildWindow(btn);
	btn->setPosition(UVector2(cegui_reldim(0.77f), cegui_reldim( 0.90f)));
	btn->setSize(UVector2(cegui_reldim(0.20f), cegui_reldim( 0.065f)));
	btn->setText("OK");
	btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&GuiConfig::HandleConfigOK, this));

}
示例#17
0
//----------------------------------------------------------------------------//
void Element::addElementProperties()
{
    const String propertyOrigin("Element");

    CEGUI_DEFINE_PROPERTY(Element, URect,
        "Area", "Property to get/set the unified area rectangle. Value is a \"URect\".",
        &Element::setArea, &Element::getArea, URect(UDim(0, 0), UDim(0, 0), UDim(0, 0), UDim(0, 0))
    );

    CEGUI_DEFINE_PROPERTY_NO_XML(Element, UVector2,
        "Position", "Property to get/set the unified position. Value is a \"UVector2\".",
        &Element::setPosition, &Element::getPosition, UVector2(UDim(0, 0), UDim(0, 0))
    );

    CEGUI_DEFINE_PROPERTY(Element, VerticalAlignment,
        "VerticalAlignment", "Property to get/set the vertical alignment.  Value is one of \"Top\", \"Centre\" or \"Bottom\".",
        &Element::setVerticalAlignment, &Element::getVerticalAlignment, VA_TOP
    );

    CEGUI_DEFINE_PROPERTY(Element, HorizontalAlignment,
        "HorizontalAlignment", "Property to get/set the horizontal alignment.  Value is one of \"Left\", \"Centre\" or \"Right\".",
        &Element::setHorizontalAlignment, &Element::getHorizontalAlignment, HA_LEFT
    );

    CEGUI_DEFINE_PROPERTY_NO_XML(Element, USize,
        "Size", "Property to get/set the unified size. Value is a \"USize\".",
        &Element::setSize, &Element::getSize, USize(UDim(0, 0), UDim(0, 0))
    );

    CEGUI_DEFINE_PROPERTY(Element, USize,
        "MinSize", "Property to get/set the unified minimum size. Value is a \"USize\".",
        &Element::setMinSize, &Element::getMinSize, USize(UDim(0, 0), UDim(0, 0))
    );

    CEGUI_DEFINE_PROPERTY(Element, USize, "MaxSize",
        "Property to get/set the unified maximum size. Value is a \"USize\". "
        "Note that zero means no maximum size.",
        &Element::setMaxSize, &Element::getMaxSize, USize(UDim(0, 0), UDim(0, 0))
    );

    CEGUI_DEFINE_PROPERTY(Element, AspectMode,
        "AspectMode", "Property to get/set the 'aspect mode' setting. Value is either \"Ignore\", \"Shrink\" or \"Expand\".",
        &Element::setAspectMode, &Element::getAspectMode, AM_IGNORE
    );

    CEGUI_DEFINE_PROPERTY(Element, float,
        "AspectRatio", "Property to get/set the aspect ratio. Only applies when aspect mode is not \"Ignore\".",
        &Element::setAspectRatio, &Element::getAspectRatio, 1.0 / 1.0
    );

    CEGUI_DEFINE_PROPERTY(Element, bool,
        "PixelAligned", "Property to get/set whether the Element's size and position should be pixel aligned. "
        "Value is either \"True\" or \"False\".",
        &Element::setPixelAligned, &Element::isPixelAligned, true
    );

    CEGUI_DEFINE_PROPERTY(Element, Quaternion,
        "Rotation", "Property to get/set the Element's rotation. Value is a quaternion: "
        "\"w:[w_float] x:[x_float] y:[y_float] z:[z_float]\""
        "or \"x:[x_float] y:[y_float] z:[z_float]\" to convert from Euler angles (in degrees).",
        &Element::setRotation, &Element::getRotation, Quaternion(1.0,0.0,0.0,0.0)
    );

    CEGUI_DEFINE_PROPERTY(Element, bool,
        "NonClient", "Property to get/set whether the Element is 'non-client'. "
        "Value is either \"True\" or \"False\".",
        &Element::setNonClient, &Element::isNonClient, false
    );
}
示例#18
0
//----------------------------------------------------------------------------//
ComponentArea::ComponentArea() :
    d_left(AbsoluteDim(0.0f), DT_LEFT_EDGE),
    d_top(AbsoluteDim(0.0f), DT_TOP_EDGE),
    d_right_or_width(UnifiedDim(UDim(1.0f, 0.0f), DT_WIDTH), DT_RIGHT_EDGE),
    d_bottom_or_height(UnifiedDim(UDim(1.0f, 0.0f), DT_HEIGHT), DT_BOTTOM_EDGE)
{}
//----------------------------------------------------------------------------//
void RenderedStringWidgetComponent::draw(const Window* ref_wnd,
                                         GeometryBuffer& buffer,
                                         const Vector2f& position,
                                         const CEGUI::ColourRect* /*mod_colours*/,
                                         const Rectf* clip_rect,
                                         const float vertical_space,
                                         const float /*space_extra*/) const
{
    Window* const window = getEffectiveWindow(ref_wnd);

    if (!window)
        return;

    // HACK: re-adjust for inner-rect of parent
    float x_adj = 0, y_adj = 0;
    Window* parent = window->getParent();
    
    if (parent)
    {
        const Rectf& outer(parent->getUnclippedOuterRect().get());
        const Rectf& inner(parent->getUnclippedInnerRect().get());
        x_adj = inner.d_min.d_x - outer.d_min.d_x;
        y_adj = inner.d_min.d_y - outer.d_min.d_y;
    }
    // HACK: re-adjust for inner-rect of parent (Ends)

    Vector2f final_pos(position);
    // handle formatting options
    switch (d_verticalFormatting)
    {
    case VF_BOTTOM_ALIGNED:
        final_pos.d_y += vertical_space - getPixelSize(ref_wnd).d_height;
        break;

    case VF_STRETCHED:
        Logger::getSingleton().logEvent("RenderedStringWidgetComponent::draw: "
            "VF_STRETCHED specified but is unsupported for Widget types; "
            "defaulting to VF_CENTRE_ALIGNED instead.");
        
        // intentional fall-through.
        
    case VF_CENTRE_ALIGNED:
        final_pos.d_y += (vertical_space - getPixelSize(ref_wnd).d_height) / 2 ;
        break;


    case VF_TOP_ALIGNED:
        // nothing additional to do for this formatting option.
        break;

    default:
        CEGUI_THROW(InvalidRequestException(
                "unknown VerticalFormatting option specified."));
    }

    // render the selection if needed
    if (d_selectionImage && d_selected)
    {
        const Rectf select_area(position, getPixelSize(ref_wnd));
        d_selectionImage->render(buffer, select_area, clip_rect, ColourRect(0xFF002FFF));
    }

    // we do not actually draw the widget, we just move it into position.
    const UVector2 wpos(UDim(0, final_pos.d_x + d_padding.d_min.d_x - x_adj),
                        UDim(0, final_pos.d_y + d_padding.d_min.d_y - y_adj));

    window->setPosition(wpos);
}