Exemple #1
0
void testApp::doBoxGrid()
{

	clearBoxes();
	int w = imageWidth;
	int h = imageHeight;

	cvColorImage.setFromPixels(getKinectRGBPixels(), w, h);
	
	for(int i=0; i<w; i+=boxGridStep)
	{
		for(int j=0; j<h; j+=boxGridStep)
		{
			ImageBox rect;
			float boxSize = kinect.getDistanceAt(i, j);
			boxSize = ofMap(boxSize, 0, 600, 30, 2, true);
			//rect.setPhysics(3.0, 0.53, 0.1);
			rect.setPhysics(boxMass, boxBounce, boxFriction);
			cvColorImage.setROI(ofRectangle(i, j, boxSize, boxSize));
			ofImage boxImage;
			boxImage.setFromPixels(cvColorImage.getRoiPixels(), boxSize, boxSize, OF_IMAGE_COLOR, true);
			rect.setTexture(boxImage);
			cvColorImage.resetROI();
			rect.setup(myWorld, i, j, boxSize, boxSize);
			boxes.push_back(rect);
			

		}
	}
}
Exemple #2
0
    void InventoryWindow::pickUpObject (MWWorld::Ptr object)
    {
        /// \todo scripts

        // make sure the object is of a type that can be picked up
        std::string type = object.getTypeName();
        if ( (type != typeid(ESM::Apparatus).name())
            && (type != typeid(ESM::Armor).name())
            && (type != typeid(ESM::Book).name())
            && (type != typeid(ESM::Clothing).name())
            && (type != typeid(ESM::Ingredient).name())
            && (type != typeid(ESM::Light).name())
            && (type != typeid(ESM::Miscellaneous).name())
            && (type != typeid(ESM::Tool).name())
            && (type != typeid(ESM::Probe).name())
            && (type != typeid(ESM::Repair).name())
            && (type != typeid(ESM::Weapon).name())
            && (type != typeid(ESM::Potion).name()))
            return;

        // sound
        std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
        MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);

        int count = object.getRefData().getCount();

        // add to player inventory
        // can't use ActionTake here because we need an MWWorld::Ptr to the newly inserted object
        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
        MWWorld::Ptr newObject = *MWWorld::Class::get (player).getContainerStore (player).add (object);
        // remove from world
        MWBase::Environment::get().getWorld()->deleteObject (object);

        mDragAndDrop->mIsOnDragAndDrop = true;
        mDragAndDrop->mDraggedCount = count;

        std::string path = std::string("icons\\");
        path += MWWorld::Class::get(newObject).getInventoryIcon(newObject);
        MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
        baseWidget->detachFromWidget();
        baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
        baseWidget->setUserData(newObject);
        mDragAndDrop->mDraggedWidget = baseWidget;
        ImageBox* image = baseWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
        int pos = path.rfind(".");
        path.erase(pos);
        path.append(".dds");
        image->setImageTexture(path);
        image->setNeedMouseFocus(false);

        // text widget that shows item count
        MyGUI::TextBox* text = image->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 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(count));
        mDragAndDrop->mDraggedFrom = this;
    }
void VehicleSelectScreen::buildUI()
{
	m_logger->logMessage("VehicleSelectScreen::buildUI()");

	m_guiLayout = LayoutManager::getInstance().loadLayout(m_uiFileName);

	ImageBox* parentBG = Gui::getInstance().findWidget<ImageBox>("backImg");
	parentBG->setSize(RenderManager::getInstance().getViewSize());
	parentBG->setImageTexture("blue_back.jpg");

	m_vehiclePreview = Gui::getInstance().findWidget<ImageBox>("vehicleModel");

	m_enginePowerProgress = Gui::getInstance().findWidget<ProgressBar>("enginePowerProgress");
	m_maxSpeedProgress = Gui::getInstance().findWidget<ProgressBar>("maxSpeedProgress");
	m_tractionProgress = Gui::getInstance().findWidget<ProgressBar>("tractionProgress");
	m_accelProgress = Gui::getInstance().findWidget<ProgressBar>("accelProgress");

	m_enginePowerProgress->setProgressRange(100);
	m_maxSpeedProgress->setProgressRange(100);
	m_tractionProgress->setProgressRange(100);
	m_accelProgress->setProgressRange(100);

	m_vehicleNameLabel = Gui::getInstance().findWidget<TextBox>("vehicleNameLabel");
	m_infoLabel = Gui::getInstance().findWidget<TextBox>("infoLabel");

	m_bgMusic = AudioManager::getSingleton().createMusic("menu.ogg", AudioType::SOUND_2D_LOOPING);
	m_bgMusic->play();
	m_bgMusic->setVolume(0.5);

	m_backBtn = Gui::getInstance().findWidget<Button>("backBtn");
	m_selectBtn = Gui::getInstance().findWidget<Button>("selectBtn");
	m_prevBtn = Gui::getInstance().findWidget<ImageBox>("prevBtn");
	m_nextBtn = Gui::getInstance().findWidget<ImageBox>("nextBtn");
	
	m_selectBtn->eventMouseButtonClick += newDelegate(this, &VehicleSelectScreen::buttonClicked);
	m_prevBtn->eventMouseButtonClick += newDelegate(this, &VehicleSelectScreen::buttonClicked);
	m_backBtn->eventMouseButtonClick += newDelegate(this, &VehicleSelectScreen::buttonClicked);
	m_nextBtn->eventMouseButtonClick += newDelegate(this, &VehicleSelectScreen::buttonClicked);

	m_selectBtn->eventMouseSetFocus += newDelegate(this, &VehicleSelectScreen::buttonHovered);
	m_prevBtn->eventMouseSetFocus += newDelegate(this, &VehicleSelectScreen::buttonHovered);
	m_backBtn->eventMouseSetFocus += newDelegate(this, &VehicleSelectScreen::buttonHovered);
	m_nextBtn->eventMouseSetFocus += newDelegate(this, &VehicleSelectScreen::buttonHovered);

	inflateVehicleInfo();
}
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    ImageBox window;
    window.resize(600, 600);
    window.setWindowTitle("Hello, QT!");
    window.show();

    // output message to stdout
    QTextStream out(stdout);
    out.setCodec("UTF-8");
    out << "The first QT program startup, hello, QT!\n";

    testQfile();
    testQlist();
    testQdir();
    return app.exec();
}
		TileImage* TileScrollerX::_getParentsTileImage() const
		{
			hstr parentName = (this->parent != NULL ? this->parent->getName() : "NULL");
			ImageBox* imageBox = dynamic_cast<ImageBox*>(this->parent);
			if (imageBox == NULL)
			{
				hlog::errorf(logTag, "Animators::TileScrollerX: parent object '%s' not a subclass of Objects::ImageBox!", parentName.cStr());
				return NULL;
			}
			hstr imageName = imageBox->getImageName();
			TileImage* image = dynamic_cast<TileImage*>(imageBox->getImage());
			if (image == NULL)
			{
				hlog::errorf(logTag, "Animators::TileScrollerX: Image '%s' in ImageBox '%s' not a subclass of TileImage!", imageName.cStr(), parentName.cStr());
				return NULL;
			}
			return image;
		}
Exemple #6
0
		void initFrom(const ImageBox& box) {
			m_width = box.getWidth();
			m_height = box.getHeight();
			m_bound = box.getBound();
			m_x1 = box.getX1();
			m_y1 = box.getY1();
			m_x2 = box.getX2();
			m_y2 = box.getY2();
		}
ImageBox*
FormWindow::CreateImageBox(const char* lbl_text, int ax, int ay, int aw, int ah, DWORD aid, DWORD pid)
{
	ImageBox*      image  = 0;
	ActiveWindow*  parent = this;

	if (pid)
	parent = FindControl(pid);

	image = new(__FILE__,__LINE__) ImageBox(parent, ax, ay, aw, ah, aid);

	if (image) {
		image->SetForm(this);
		image->SetText(lbl_text);

		if (!shown)
		image->Hide();
	}

	return image;
}
void
FormWindow::CreateDefImage(CtrlDef& def)
{
	ImageBox* ctrl = CreateImageBox(def.GetText(),
	def.GetX(),
	def.GetY(),
	def.GetW(),
	def.GetH(),
	def.GetID(),
	def.GetParentID());

	ctrl->SetAltText(def.GetAltText());
	ctrl->SetBackColor(def.GetBackColor());
	ctrl->SetForeColor(def.GetForeColor());
	ctrl->SetStyle(def.GetStyle());
	ctrl->SetTextAlign(def.GetTextAlign());
	ctrl->SetSingleLine(def.GetSingleLine());
	ctrl->SetTransparent(def.GetTransparent());
	ctrl->SetHidePartial(def.GetHidePartial());

	ctrl->SetMargins(def.GetMargins());
	ctrl->SetTextInsets(def.GetTextInsets());
	ctrl->SetCellInsets(def.GetCellInsets());
	ctrl->SetCells(def.GetCells());
	ctrl->SetFixedWidth(def.GetFixedWidth());
	ctrl->SetFixedHeight(def.GetFixedHeight());

	if (def.GetPicture().length() > 0) {
		Bitmap picture;

		DataLoader* loader = DataLoader::GetLoader();
		loader->SetDataPath("Screens/");
		loader->LoadBitmap(def.GetPicture(), picture);
		loader->SetDataPath("");

		ctrl->SetPicture(picture);
	}

	Font* f = FontMgr::Find(def.GetFont());
	if (f) ctrl->SetFont(f);
}
Exemple #9
0
IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info)
{
    mDynamicToolTipBox->setVisible(true);

    std::string caption = info.caption;
    std::string image = info.icon;
    int imageSize = (image != "") ? 32 : 0;
    std::string text = info.text;

    // remove the first newline (easier this way)
    if (text.size() > 0 && text[0] == '\n')
        text.erase(0, 1);

    const ESM::Enchantment* enchant;
    const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
    if (info.enchant != "")
    {
        enchant = store.enchants.search(info.enchant);
        if (enchant->data.type == ESM::Enchantment::CastOnce)
            text += "\n" + store.gameSettings.search("sItemCastOnce")->str;
        else if (enchant->data.type == ESM::Enchantment::WhenStrikes)
            text += "\n" + store.gameSettings.search("sItemCastWhenStrikes")->str;
        else if (enchant->data.type == ESM::Enchantment::WhenUsed)
            text += "\n" + store.gameSettings.search("sItemCastWhenUsed")->str;
        else if (enchant->data.type == ESM::Enchantment::ConstantEffect)
            text += "\n" + store.gameSettings.search("sItemCastConstant")->str;
    }

    // this the maximum width of the tooltip before it starts word-wrapping
    setCoord(0, 0, 300, 300);

    const IntPoint padding(8, 8);

    const int imageCaptionHPadding = (caption != "" ? 8 : 0);
    const int imageCaptionVPadding = (caption != "" ? 4 : 0);

    std::string realImage = "icons\\" + image;
    findImageExtension(realImage);

    EditBox* captionWidget = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption");
    captionWidget->setProperty("Static", "true");
    captionWidget->setCaption(caption);
    IntSize captionSize = captionWidget->getTextSize();

    int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);

    EditBox* textWidget = mDynamicToolTipBox->createWidget<EditBox>("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText");
    textWidget->setProperty("Static", "true");
    textWidget->setProperty("MultiLine", "true");
    textWidget->setProperty("WordWrap", "true");
    textWidget->setCaption(text);
    textWidget->setTextAlign(Align::HCenter | Align::Top);
    IntSize textSize = textWidget->getTextSize();

    captionSize += IntSize(imageSize, 0); // adjust for image
    IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),
        ((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );

    if (!info.effects.empty())
    {
        Widget* effectArea = mDynamicToolTipBox->createWidget<Widget>("",
            IntCoord(0, totalSize.height, 300, 300-totalSize.height),
            Align::Stretch, "ToolTipEffectArea");

        IntCoord coord(0, 6, totalSize.width, 24);

        /**
         * \todo
         * the various potion effects should appear in the tooltip depending if the player 
         * has enough skill in alchemy to know about the effects of this potion.
         */

        Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList>
            ("MW_StatName", coord, Align::Default, "ToolTipEffectsWidget");
        effectsWidget->setWindowManager(mWindowManager);
        effectsWidget->setEffectList(info.effects);

        std::vector<MyGUI::WidgetPtr> effectItems;
        effectsWidget->createEffectWidgets(effectItems, effectArea, coord, true, Widgets::MWEffectList::EF_NoTarget);
        totalSize.height += coord.top-6;
        totalSize.width = std::max(totalSize.width, coord.width);
    }

    if (info.enchant != "")
    {
        Widget* enchantArea = mDynamicToolTipBox->createWidget<Widget>("",
            IntCoord(0, totalSize.height, 300, 300-totalSize.height),
            Align::Stretch, "ToolTipEnchantArea");

        IntCoord coord(0, 6, totalSize.width, 24);

        Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget<Widgets::MWEffectList>
            ("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget");
        enchantWidget->setWindowManager(mWindowManager);
        enchantWidget->setEffectList(Widgets::MWEffectList::effectListFromESM(&enchant->effects));

        std::vector<MyGUI::WidgetPtr> enchantEffectItems;
        int flag = (enchant->data.type == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0;
        enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag);
        totalSize.height += coord.top-6;
        totalSize.width = std::max(totalSize.width, coord.width);

        if (enchant->data.type == ESM::Enchantment::WhenStrikes
            || enchant->data.type == ESM::Enchantment::WhenUsed)
        {
            /// \todo store the current enchantment charge somewhere
            int charge = enchant->data.charge;

            const int chargeWidth = 204;

            TextBox* chargeText = enchantArea->createWidget<TextBox>("SandText", IntCoord(0, 0, 10, 18), Align::Default, "ToolTipEnchantChargeText");
            chargeText->setCaption(store.gameSettings.search("sCharges")->str);
            const int chargeTextWidth = chargeText->getTextSize().width + 5;

            const int chargeAndTextWidth = chargeWidth + chargeTextWidth;

            totalSize.width = std::max(totalSize.width, chargeAndTextWidth);

            chargeText->setCoord((totalSize.width - chargeAndTextWidth)/2, coord.top+6, chargeTextWidth, 18);

            IntCoord chargeCoord;
            if (totalSize.width < chargeWidth)
            {
                totalSize.width = chargeWidth;
                chargeCoord = IntCoord(0, coord.top+6, chargeWidth, 18);
            }
            else
            {
                chargeCoord = IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18);
            }
            Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget<Widgets::MWDynamicStat>
                ("MW_ChargeBar", chargeCoord, Align::Default, "ToolTipEnchantCharge");
            chargeWidget->setValue(charge, charge);
            totalSize.height += 24;
        }
    }

    captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize,
        (captionHeight-captionSize.height)/2,
        captionSize.width-imageSize,
        captionSize.height);

    captionWidget->setPosition (captionWidget->getPosition() + padding);
    textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter

    if (image != "")
    {
        ImageBox* imageWidget = mDynamicToolTipBox->createWidget<ImageBox>("ImageBox",
            IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize),
            Align::Left | Align::Top, "ToolTipImage");
        imageWidget->setImageTexture(realImage);
        imageWidget->setPosition (imageWidget->getPosition() + padding);
    }

    totalSize += IntSize(padding.left*2, padding.top*2);

    return totalSize;
}