Ejemplo n.º 1
0
	MyGUI::IntCoord WidgetCreatorManager::getCoordNewWidget(const MyGUI::IntPoint& _point)
	{
		MyGUI::IntPoint point = _point;
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			point.left += mGridStep / 2;
			point.top += mGridStep / 2;
		}

		MyGUI::Widget* parent = mNewWidget->getParent();
		if (parent != nullptr && !mNewWidget->isRootWidget())
			point -= parent->getAbsolutePosition();

		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			point.left = toGrid(point.left);
			point.top = toGrid(point.top);
		}

		MyGUI::IntCoord coord = MyGUI::IntCoord(
			std::min(mStartPoint.left, point.left),
			std::min(mStartPoint.top, point.top),
			abs(point.left - mStartPoint.left),
			abs(point.top - mStartPoint.top));

		return coord;
	}
Ejemplo n.º 2
0
	void step_change_skin()
	{
		MyGUI::Widget* widget = get_random(all_widgets);
		if (!widget) return;
		widget->changeWidgetSkin(get_skin());
		test_widgets();
	}
Ejemplo n.º 3
0
    void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
    {
        int current = std::max(0, static_cast<int>(value.getCurrent()));
        int modified = static_cast<int>(value.getModified());

        MyGUI::Widget* w;
        std::string valStr = MyGUI::utility::toString(current) + "/" + MyGUI::utility::toString(modified);
        if (id == "HBar")
        {
            mHealth->setProgressRange(modified);
            mHealth->setProgressPosition(current);
            getWidget(w, "HealthFrame");
            w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
        }
        else if (id == "MBar")
        {
            mMagicka->setProgressRange (modified);
            mMagicka->setProgressPosition (current);
            getWidget(w, "MagickaFrame");
            w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
        }
        else if (id == "FBar")
        {
            mStamina->setProgressRange (modified);
            mStamina->setProgressPosition (current);
            getWidget(w, "FatigueFrame");
            w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
        }
    }
Ejemplo n.º 4
0
	void step_change_type()
	{
		MyGUI::Widget* widget = get_random(all_widgets);
		if (!widget) return;
		widget->setWidgetStyle(get_type());
		test_widgets();
	}
Ejemplo n.º 5
0
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
{
    static const char *ids[] =
    {
        "HBar", "MBar", "FBar", 0
    };

    for (int i=0; ids[i]; ++i)
        if (ids[i]==id)
        {
            MyGUI::Widget* w;
            std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
            switch (i)
            {
                case 0:
                    mHealth->setProgressRange (value.getModified());
                    mHealth->setProgressPosition (value.getCurrent());
                    getWidget(w, "HealthFrame");
                    w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
                    break;
                case 1:
                    mMagicka->setProgressRange (value.getModified());
                    mMagicka->setProgressPosition (value.getCurrent());
                    getWidget(w, "MagickaFrame");
                    w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
                    break;
                case 2:
                    mStamina->setProgressRange (value.getModified());
                    mStamina->setProgressPosition (value.getCurrent());
                    getWidget(w, "FatigueFrame");
                    w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
                    break;
            }
        }
}
Ejemplo n.º 6
0
	void step_detach_widget()
	{
		MyGUI::Widget* widget = get_random(all_widgets);
		if (!widget) return;
		widget->detachFromWidget(get_layer());
		test_widgets();
	}
Ejemplo n.º 7
0
    void BookWindow::open (MWWorld::Ptr book)
    {
        mBook = book;

        clearPages();
        mCurrentPage = 0;

        MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0);

        MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>();

        BookTextParser parser;
        std::vector<std::string> results = parser.split(ref->mBase->mText, mLeftPage->getSize().width, mLeftPage->getSize().height);

        int i=0;
        for (std::vector<std::string>::iterator it=results.begin();
            it!=results.end(); ++it)
        {
            MyGUI::Widget* parent;
            if (i%2 == 0)
                parent = mLeftPage;
            else
                parent = mRightPage;

            MyGUI::Widget* pageWidget = parent->createWidgetReal<MyGUI::Widget>("", MyGUI::FloatCoord(0.0,0.0,1.0,1.0), MyGUI::Align::Default, "BookPage" + boost::lexical_cast<std::string>(i));
            pageWidget->setNeedMouseFocus(false);
            parser.parsePage(*it, pageWidget, mLeftPage->getSize().width);
            mPages.push_back(pageWidget);
            ++i;
        }

        updatePages();

        setTakeButtonShow(true);
    }
Ejemplo n.º 8
0
	void StashPanel::setHoverSlotsColor(Game::InventorySlot* _slot, Game::InventorySize* _size, MyGUI::Colour color)
	{
		bool set_all_red = false;
		for (int r = _slot->R; r < (_slot->R +_size->Height); r++)
		{
			for (int c = _slot->C; c < (_slot->C + _size->Width); c++)
			{
				Game::InventorySlot temp_slot(r,c);
				MyGUI::Widget* wg = this->getWidgetSlotByRC(r,c);
				if (wg != 0)
					wg->setColour(color);
				else
					set_all_red = true;
			}
		}

		if (set_all_red)
		{
			for (int r = _slot->R; r < (_slot->R +_size->Height); r++)
			{
				for (int c = _slot->C; c < (_slot->C + _size->Width); c++)
				{
					MyGUI::Widget* wg = this->getWidgetSlotByRC(r,c);
					if (wg != 0)
						wg->setColour(MyGUI::Colour::Red);
				}
			}
		}
	}
Ejemplo n.º 9
0
	void DemoKeeper::createScene()
	{
		base::BaseDemoManager::createScene();
		MyGUI::ResourceManager::getInstance().load("SplineSkin.xml");

		const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout");
		root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("PolygonalSkin usage. Drag white rectangles to move points for bezier curve.");

		MyGUI::VectorWidgetPtr widgets = MyGUI::LayoutManager::getInstance().loadLayout("SplineWindow.layout");
		mQualityText = widgets.at(0)->findWidget("SplineText")->castType<MyGUI::TextBox>();
		MyGUI::ScrollBar* qualityScroll = widgets.at(0)->findWidget("SplineQuality")->castType<MyGUI::ScrollBar>();
		qualityScroll->eventScrollChangePosition += MyGUI::newDelegate(this, &DemoKeeper::notifyChangeQuality);
		mClient = widgets.at(0)->findWidget("SplineClient");

		// create widget with skin that contain specific sub skin - PolygonalSkin
		MyGUI::Widget* widget = mClient->createWidget<MyGUI::Widget>("PolygonalSkin", MyGUI::IntCoord(MyGUI::IntPoint(), mClient->getSize()), MyGUI::Align::Stretch);
		widget->setColour(MyGUI::Colour::Red);
		// get main subskin
		MyGUI::ISubWidget* main = widget->getSubWidgetMain();
		mPolygonalSkin = main->castType<MyGUI::PolygonalSkin>();

		// set PolygonalSkin properties and points
		mPolygonalSkin->setWidth(8.0f);

		for (int i = 0; i < PointsCount; ++i)
		{
			point[i] = mClient->createWidget<MyGUI::Button>("Button", MyGUI::IntCoord(10 + (i + i % 2 * 3) * 40, 10 + (i + i / 2 * 3) * 40, 16, 16), MyGUI::Align::Default);
			point[i]->eventMouseDrag += newDelegate(this, &DemoKeeper::notifyPointMove);
			point[i]->eventMouseButtonPressed += newDelegate(this, &DemoKeeper::notifyPointPressed);
		}

		notifyChangeQuality(qualityScroll, 12);
		updateSpline();
	}
Ejemplo n.º 10
0
void NoDrop::onFrame(float dt)
{
    if (!mWidget)
        return;

    MyGUI::IntPoint mousePos = MyGUI::InputManager::getInstance().getMousePosition();

    if (mDrag->mIsOnDragAndDrop)
    {
        MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getMouseFocusWidget();
        while (focus && focus != mWidget)
            focus = focus->getParent();

        if (focus == mWidget)
            mTransparent = true;
    }
    if (!mWidget->getAbsoluteCoord().inside(mousePos))
        mTransparent = false;

    if (mTransparent)
    {
        mWidget->setNeedMouseFocus(false); // Allow click-through
        setAlpha(std::max(0.13f, mWidget->getAlpha() - dt*5));
    }
    else
    {
        mWidget->setNeedMouseFocus(true);
        setAlpha(std::min(1.0f, mWidget->getAlpha() + dt*5));
    }
}
Ejemplo n.º 11
0
	CurveEditor::CurveEditor(MyGUI::Widget* _parent)
	{
        initialiseByAttributes(this, _parent);

        mEditTimeEditBox->setEditReadOnly(true);
        mEditValueEditBox->setEditReadOnly(true);

        mRangeMinEditBox->eventKeyLostFocus     += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeLostFocus);
        mRangeMinEditBox->eventEditSelectAccept += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeEditAccept);
        mRangeMaxEditBox->eventKeyLostFocus     += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeLostFocus);
        mRangeMaxEditBox->eventEditSelectAccept += MyGUI::newDelegate(this, &CurveEditor::NotifyRangeEditAccept);

        MyGUI::PolygonalSkin::CreateLineSets = false;
        MyGUI::Widget* widget = mCurveCanvasWidget->createWidget<MyGUI::Widget>("PolygonalSkin",
            MyGUI::IntCoord(MyGUI::IntPoint(), mCurveCanvasWidget->getSize()), MyGUI::Align::Stretch);
        widget->setColour(MyGUI::Colour::Red);
        MyGUI::ISubWidget* main = widget->getSubWidgetMain();
        mCurveLines = main->castType<MyGUI::PolygonalSkin>();

        MyGUI::PolygonalSkin::CreateLineSets = true;
        widget = mCurveCanvasWidget->createWidget<MyGUI::Widget>("PolygonalSkin",
            MyGUI::IntCoord(MyGUI::IntPoint(), mCurveCanvasWidget->getSize()), MyGUI::Align::Stretch);
        widget->setColour(MyGUI::Colour::Red);
        main = widget->getSubWidgetMain();
        mCurveCanvas = main->castType<MyGUI::PolygonalSkin>();
        widget->eventMouseButtonPressed += MyGUI::newDelegate(this, &CurveEditor::NotifyMousePressed);
        MyGUI::PolygonalSkin::CreateLineSets = false;
        mCanvasWidget = widget;

        mCurveCanvas->setWidth(5.0f);
        std::vector<MyGUI::FloatPoint> mLinePoints;
        mLinePoints.push_back(MyGUI::FloatPoint(0, 0));
        mLinePoints.push_back(MyGUI::FloatPoint(0, 1));
        mCurveCanvas->setPoints(mLinePoints);
        mLinePoints.clear();
        mCurveCanvas->setPoints(mLinePoints); // todo fix it 

        mCurveLines->_setColour(MyGUI::Colour(0.2f, 0.2f, 0.2f));

        // default range
        mValueRange.x = 0;
        mValueRange.y = 10;
        mRangeMinEditBox->setCaption("0");
        mRangeMaxEditBox->setCaption("10");

        InitGrid();

        RefreshNumbers();

        MyGUI::Window* window = mMainWidget->castType<MyGUI::Window>(false);
        if (window != nullptr) 
            window->eventWindowButtonPressed += newDelegate(this, &CurveEditor::NotifyWindowButtonPressed);

        mSplineButton = mMainWidget->createWidget<MyGUI::Button>("CheckBox",
            MyGUI::IntCoord(15, 10, 95, 25),
            MyGUI::Align::Left | MyGUI::Align::Top);
        mSplineButton->setCaption("Use Spline");
        mSplineButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CurveEditor::NotifySplineChecked);
    }
Ejemplo n.º 12
0
    bool PropertyGridManager::buildNewControl(PropertyGridProperty *const property, int &height)
    {
        if(nullptr == mContainerWidget)
        {
            Debug::error(STEEL_METH_INTRO, "no container for controls. Aborting.").endl();
            return false;
        }

        // build the control matching the property value type
        Ogre::String const skin = "PanelEmpty";
        Ogre::String const controlName = "PropertyGridManager_Control_" + property->id();

        // original control size is set here, but the method that build the control can totally resize it.
        MyGUI::IntCoord coords(0, height, mContainerWidget->getClientWidget()->getWidth(), 20);
        MyGUI::Widget *control = mContainerWidget->createWidget<MyGUI::Widget>(skin, coords, MyGUI::Align::HCenter | MyGUI::Align::Top, controlName);

        if(nullptr == control)
        {
            Debug::error(STEEL_METH_INTRO, "could not build control for property: ", *property, ". Skipping.").endl();
            return false;
        }

        switch(property->valueType())
        {
            case PropertyGridPropertyValueType::Bool:
                buildBoolControl(control, property);
                break;

            case PropertyGridPropertyValueType::String:
                buildStringControl(control, property);
                break;

            case PropertyGridPropertyValueType::Range:
                buildRangeControl(control, property);
                break;

            case PropertyGridPropertyValueType::StringVectorSelection:
                buildStringVectorSelectionControl(control, property);
                break;

            case PropertyGridPropertyValueType::None:
            default:
                buildDummyControl(control, property);
        }

        height = control->getBottom();
        mControlsMap.insert(std::make_pair(property->id(), control));

        // subscribe to property changes
        Signal propertyChanged = property->getSignal(PropertyGridProperty::PublicSignal::changed);
        registerSignal(propertyChanged);
        mSignals.propertyChanged.insert(propertyChanged);

        // update control value
        updateControlValue(control, property);

        return true;
    }
Ejemplo n.º 13
0
	void StashPanel::setAllSlotsColor(MyGUI::Colour color)
	{
		int slot_count = this->mslot_container_panelWidget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
			widget->setColour(color);
		}
	}
Ejemplo n.º 14
0
	bool InventoryPanel::hitTestSlots(const MyGUI::types::TRect<int>&  _value)
	{
		int slot_count = this->mslot_container_panel_2_Widget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panel_2_Widget->getChildAt(i);
			if (widget->getAbsoluteRect().intersect(_value))
				return true;
		}
		return false;
	}
Ejemplo n.º 15
0
	void step_attach_layer()
	{
		MyGUI::Widget* widget = get_random(all_widgets);
		if (!widget) return;
		if (widget->isRootWidget())
		{
			std::string layername = get_layer();
			if (!layername.empty())
				MyGUI::LayerManager::getInstance().attachToLayerNode(layername, widget);
		}
		test_widgets();
	}
Ejemplo n.º 16
0
	void WidgetCreatorManager::moveNewWidget(const MyGUI::IntPoint& _point)
	{
		if (mNewWidget == nullptr)
		{
			// тип виджета может отсутсвовать
			if (!MyGUI::WidgetManager::getInstance().isFactoryExist(mWidgetType))
				return;

			// выделяем верний виджет
			if (!mPopupMode)
				WidgetSelectorManager::getInstance().selectWidget(mStartPoint);

			MyGUI::Widget* parent = WidgetSelectorManager::getInstance().getSelectedWidget();

			// пока не найдем ближайшего над нами способного быть родителем
			while (parent != nullptr && !WidgetTypes::getInstance().findWidgetStyle(parent->getTypeName())->parent)
				parent = parent->getParent();

			if (!WidgetTypes::getInstance().findWidgetStyle(mWidgetType)->child)
				parent = nullptr;

			if (parent != nullptr)
				mNewWidget = parent->createWidgetT(
					mPopupMode ? MyGUI::WidgetStyle::Popup : MyGUI::WidgetStyle::Child,
					mWidgetType,
					EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
					MyGUI::IntCoord(),
					MyGUI::Align::Default,
					DEFAULT_EDITOR_LAYER);
			else
				mNewWidget = MyGUI::Gui::getInstance().createWidgetT(
					mWidgetType,
					EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
					MyGUI::IntCoord(),
					MyGUI::Align::Default,
					DEFAULT_EDITOR_LAYER);

			// переводим старт поинт в координаты отца
			if (parent != nullptr && !mNewWidget->isRootWidget())
				mStartPoint -= parent->getAbsolutePosition();

			if (!MyGUI::InputManager::getInstance().isShiftPressed())
			{
				mStartPoint.left = toGrid(mStartPoint.left);
				mStartPoint.top = toGrid(mStartPoint.top);
			}
		}

		MyGUI::IntCoord coord = getCoordNewWidget(_point);
		mNewWidget->setCoord(coord);

		eventChangeSelector(true, mNewWidget->getAbsoluteCoord());
	}
Ejemplo n.º 17
0
	void WorkspaceControl::updateSelectionFromValue()
	{
		// саму рамку отображаем в глобальных
		if (mCurrentWidget != nullptr)
		{
			MyGUI::Widget* parent = mCurrentWidget->getParent();
			if (parent != nullptr && !mCurrentWidget->isRootWidget())
				mAreaSelectorControl->setCoord(mCoordValue + parent->getAbsolutePosition());
			else
				mAreaSelectorControl->setCoord(mCoordValue);
		}
	}
Ejemplo n.º 18
0
void HotkeyManager::injectKeyPress(MyGUI::KeyCode _key, MyGUI::Char _text)
{
	/*
		被翻译成下面的字符串,不区分大小写
		Shift+Ctrl+Alt+X,不区分左右Shift和Ctrl,Alt
	*/
	Game* g = Game::getSingletonPtr();
	if( g )
	{
		string hotkey;

		//_key不能是Shift,Ctrl,Alt其中之一
		if( _key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightShift) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftShift) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightControl) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftControl) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightAlt) ||
			_key == MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftAlt) )
			return;

		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightShift)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftShift))
			)
		{
			hotkey += "shift+";
		}
		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightControl)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftControl))
			)
		{
			hotkey += "ctrl+";
		}
		if( g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::RightAlt)) ||
			g->getKeyState(MyGUI::KeyCode::Enum(MyGUI::KeyCode::LeftAlt))
			)
		{
			hotkey += "alt+";
		}
		//注意:正确的话,ScanCodeToText返回小写字传串
		hotkey += ScanCodeToText(_key.getValue());

		for( HotkeyTable::iterator it = mHotkeys.begin();it!=mHotkeys.end();++it )
		{
			if( it->mSHotkey == hotkey )
			{
				MyGUI::Widget* p = MyGUI::Gui::getInstance().findWidget<MyGUI::Widget>(it->mName,false);
				if( p )
					p->eventMouseButtonClick( p );
			}
		}
	}
}
Ejemplo n.º 19
0
void HotkeyManager::setWidgetHotkey( const string name,const string key )
{
	MyGUI::Gui& gui = MyGUI::Gui::getInstance();
	MyGUI::Widget* p = gui.findWidget<MyGUI::Widget>( name,false );
	if( p && (p->isType<MyGUI::Button>() || p->isType<MyGUI::MenuItem>() ) )
	{
		MyGUI::MenuItem* menuitem = p->castType<MyGUI::MenuItem>(false);
		if( menuitem )
			menuitem->setUserString( "hotkey",key );
		else
			p->setUserString( "hotkey",key );
	}
}
Ejemplo n.º 20
0
	void WidgetSelectorManager::selectWidget(const MyGUI::IntPoint& _mousePosition)
	{
		if (mLastClickPoint != _mousePosition)
		{
			mSelectDepth = 0;
			mLastClickPoint = _mousePosition;
		}

		// здесь кликать вглубь
		MyGUI::Widget* item = getTopWidget(_mousePosition);
		if (nullptr != item)
		{
			// find widget registered as container
			while ((nullptr == EditorWidgets::getInstance().find(item)) && (nullptr != item))
				item = item->getParent();
			MyGUI::Widget* oldItem = item;

			// try to selectin depth
			size_t depth = mSelectDepth;
			while (depth && (nullptr != item))
			{
				item = item->getParent();
				while ((nullptr == EditorWidgets::getInstance().find(item)) && (nullptr != item))
					item = item->getParent();
				MYGUI_ASSERT(depth != 0, "depth != 0");
				depth--;
			}

			if (nullptr == item)
			{
				item = oldItem;
				mSelectDepth = 0;
			}

			// found widget
			if (nullptr != item)
			{
				depth =  mSelectDepth;
				WidgetSelectorManager::getInstance().setSelectedWidget(item);
				mSelectDepth = depth + 1;
			}
			else
			{
				WidgetSelectorManager::getInstance().setSelectedWidget(nullptr);
			}
		}
		else
		{
			WidgetSelectorManager::getInstance().setSelectedWidget(nullptr);
		}
	}
Ejemplo n.º 21
0
    void EffectEditorBase::startEditing ()
    {
        // get the list of magic effects that are known to the player

        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player);
        MWMechanics::Spells& spells = stats.getSpells();

        std::vector<short> knownEffects;

        for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it)
        {
            const ESM::Spell* spell =
                MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*it);

            // only normal spells count
            if (spell->mData.mType != ESM::Spell::ST_Spell)
                continue;

            const std::vector<ESM::ENAMstruct>& list = spell->mEffects.mList;
            for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2)
            {
                if (std::find(knownEffects.begin(), knownEffects.end(), it2->mEffectID) == knownEffects.end())
                    knownEffects.push_back(it2->mEffectID);
            }
        }

        std::sort(knownEffects.begin(), knownEffects.end(), sortMagicEffects);

        mAvailableEffectsList->clear ();

        for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
        {
            mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
                                               ESM::MagicEffect::effectIdToString  (*it))->getString());
        }
        mAvailableEffectsList->adjustSize ();

        for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it)
        {
            std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
                                               ESM::MagicEffect::effectIdToString  (*it))->getString();
            MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
            w->setUserData(*it);

            ToolTips::createMagicEffectToolTip (w, *it);
        }

        mEffects.clear();
        updateEffectsView ();
    }
Ejemplo n.º 22
0
	MyGUI::Widget* StashPanel::getWidgetSlotByScreenPosition(const MyGUI::types::TPoint<int>&  _value)
	{
		int slot_count = this->mslot_container_panelWidget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
			if (widget->getAbsoluteRect().inside(_value))
			{
				MyGUI::types::TRect<int> big_rect = widget->getAbsoluteRect();
				return widget;
			}
		}
		return 0;
	}
	void SettingsUpdateResourcesControl::notifyClickAdd(MyGUI::Widget* _sender)
	{
		mResources->addItem("");
		mResources->beginToItemAt(mResources->getItemCount() - 1);

		mTextFieldControl->setCaption(replaceTags("CaptionAddResource"));
		mTextFieldControl->setTextField("");

		MyGUI::Widget* widget = mResources->getWidgetByIndex(mResources->getItemCount() - 1);
		if (widget != nullptr)
			mTextFieldControl->setCoord(MyGUI::IntCoord(widget->getAbsoluteLeft(), widget->getAbsoluteTop(), widget->getWidth(), widget->getHeight()));

		mTextFieldControl->doModal();
	}
Ejemplo n.º 24
0
Archivo: hud.cpp Proyecto: ace13/openmw
    void HUD::setFpsVisible(const bool visible)
    {
        mFpsCounter = 0;

        MyGUI::Widget* fps;
        getWidget(fps, "FPSBox");
        fps->setVisible(false);

        if (visible)
        {
            getWidget(mFpsBox, "FPSBox");
            //mFpsBox->setVisible(true);
            getWidget(mFpsCounter, "FPSCounter");
        }
    }
Ejemplo n.º 25
0
/*重新布局窗口
*/
void Grid::reLayout(){
	assert(parent && column > 0 );
	int i,x,y,width,height;
	MyGUI::IntSize size;
	vector<int> mh((int)(parent->getChildCount()/column)+1),mv(column);
	MyGUI::ScrollView *psw = parent->castType<MyGUI::ScrollView>(false);

	fill(mh.begin(),mh.end(),0);
	fill(mv.begin(),mv.end(),0);
	for( i = 0;i<(int)parent->getChildCount();++i ){
		MyGUI::Widget* pchild = parent->getChildAt(i);
		MyGUI::IntSize size = pchild->getSize();
		//如果没有设置这里自动计算
		if( size.width==0 ){
			size.width = CalcWidgetSize(pchild).width;
		}
		if( size.height==0 ){
			size.height = CalcWidgetSize(pchild).height;
		}
		if( size.width>mv[i%column] )
			mv[i%column] = size.width;
		if( size.height>mh[(int)(i/column)] )
			mh[(int)(i/column)] = size.height;
	}
	width = sum(mv,mv.size())+(column-1)*space;
	height = sum(mh,mh.size());
	size = parent->getSize();
	//对于ScrollView可能有Bug,这里减去24感觉正好
	if( psw ){
		size.width -= 24;
		size.height -= 24;
	}
	//不要小于0
	x = max((int)((size.width-width)/2),0);
	y = max((int)((size.height-height)/2),0);
	for( i = 0;i<(int)parent->getChildCount();++i ){
		int col,row;
		MyGUI::Widget* pchild = parent->getChildAt(i);
		//这里使用中心对齐
		col = i%column;
		row = (int)(i/column);
		pchild->setPosition(MyGUI::IntPoint(x+col*space+sum(mv,col),y+sum(mh,row)));
		pchild->setSize(MyGUI::IntSize(mv[col],mh[row]));
	}
	//如果父窗口是ScrollView
	
	if( psw )psw->setCanvasSize( max(size.width,width),max(size.height,height) );
}
Ejemplo n.º 26
0
//-------------------------------------------------------------------------------
void MaterialViewer::onClickApply(MyGUI::WidgetPtr)
{
    //Update properties.
    MyGUI::EnumeratorWidgetPtr iter = mWindow->getEnumerator();
    while (iter.next())
    {
        MyGUI::Widget *widget = iter.current();
        if (widget->getUserString("type") == "MaterialProperty") 
            mMaterialSettings[widget->getUserString("property")] = dynamic_cast<MyGUI::Edit*>(widget)->getOnlyText();
    }
    MyGUI::ComboBoxPtr list = GlbVar.gui->findWidget<MyGUI::ComboBox>("cmb_materialType");
    mMaterialType = list->getItemNameAt(list->getIndexSelected());
    
    //Compile.
    compileMaterial();
}
Ejemplo n.º 27
0
	void WorkspaceControl::notifyPropertyChangeCoord(MyGUI::Widget* _widget, const MyGUI::IntCoord& _coordValue, const std::string& _owner)
	{
		if (_owner == "WorkspaceControl" || _widget != mCurrentWidget)
			return;

		// тут приходит в абсолютных, конвертим в локальные
		mCoordValue = _coordValue;
		if (mCurrentWidget != nullptr)
		{
			MyGUI::Widget* parent = mCurrentWidget->getParent();
			if (parent != nullptr && !mCurrentWidget->isRootWidget())
				mCoordValue = mCoordValue - parent->getAbsolutePosition();
		}

		updateSelectionFromValue();
	}
Ejemplo n.º 28
0
void ItemView::update()
{
    while (mScrollView->getChildCount())
        MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));

    if (!mModel)
        return;

    mModel->update();

    MyGUI::Widget* dragArea = mScrollView->createWidget<MyGUI::Widget>("",0,0,mScrollView->getWidth(),mScrollView->getHeight(),
                                                                       MyGUI::Align::Stretch);
    dragArea->setNeedMouseFocus(true);
    dragArea->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedBackground);
    dragArea->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);

    for (ItemModel::ModelIndex i=0; i<static_cast<int>(mModel->getItemCount()); ++i)
    {
        const ItemStack& item = mModel->getItem(i);

        ItemWidget* itemWidget = dragArea->createWidget<ItemWidget>("MW_ItemIcon",
            MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
        itemWidget->setUserString("ToolTipType", "ItemModelIndex");
        itemWidget->setUserData(std::make_pair(i, mModel));
        ItemWidget::ItemState state = ItemWidget::None;
        if (item.mType == ItemStack::Type_Barter)
            state = ItemWidget::Barter;
        if (item.mType == ItemStack::Type_Equipped)
            state = ItemWidget::Equip;
        itemWidget->setItem(item.mBase, state);

        itemWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemView::onSelectedItem);
        itemWidget->eventMouseWheel += MyGUI::newDelegate(this, &ItemView::onMouseWheel);

        // text widget that shows item count
        // TODO: move to ItemWidget
        MyGUI::TextBox* text = itemWidget->createWidget<MyGUI::TextBox>("SandBrightText",
            MyGUI::IntCoord(5, 19, 32, 18), MyGUI::Align::Default, std::string("Label"));
        text->setTextAlign(MyGUI::Align::Right);
        text->setNeedMouseFocus(false);
        text->setTextShadow(true);
        text->setTextShadowColour(MyGUI::Colour(0,0,0));
        text->setCaption(getCountString(item.mCount));
    }

    layoutWidgets();
}
Ejemplo n.º 29
0
	void ColourPanel::notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
	{
		if (_id != MyGUI::MouseButton::Left)
			return;

		MyGUI::Widget* parent = mImageColourPicker->getParent();
		MyGUI::IntPoint point(_left - parent->getAbsoluteLeft(), _top - parent->getAbsoluteTop());

		if (point.left < 0) point.left = 0;
		if (point.top < 0) point.top = 0;
		if (point.left > mColourRect->getWidth()) point.left = mColourRect->getWidth();
		if (point.top > mColourRect->getHeight()) point.top = mColourRect->getHeight();

		mImageColourPicker->setPosition(point.left - (mImageColourPicker->getWidth() / 2), point.top - (mImageColourPicker->getHeight() / 2));

		updateFromPoint(point);
	}
Ejemplo n.º 30
0
	void StashPanel::setHoverSlotsColor(const MyGUI::types::TRect<int>&  _value , MyGUI::Colour color)
	{
		int slot_count = this->mslot_container_panelWidget->getChildCount();
		for (int i = 0; i < slot_count; i++)
		{
			MyGUI::Widget* widget = this->mslot_container_panelWidget->getChildAt(i);
			MyGUI::IntRect rectangle = widget->getAbsoluteRect();
			MyGUI::IntSize _size = widget->getSize();
			MyGUI::IntPoint center_rectangle = MyGUI::IntPoint(rectangle.left + (_size.width / 2), rectangle.top + (_size.height / 2));
			//((center_rectangle.left > _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top > _value.top) && (center_rectangle.top < _value.bottom));
			if (((center_rectangle.left >= _value.left) && (center_rectangle.left < _value.right) && (center_rectangle.top >= _value.top) && (center_rectangle.top < _value.bottom)))
			{
				//en el check de arriba, algunos son con igual y otros no porque sino se seleccionan mal, o 2 de 4 o 6 de 4 !
				widget->setColour(color);
			}
		}
	}