Beispiel #1
0
void  UInventoryComponent::detachWeaponAttachment(UWeaponAttachmentWidget* slot, UItemBase* base, UItemScrollBoxWidget* sender)
{
	if (!base) return;
	if (sender == mainInventory->sellItemBoxWidget)
	{
		sellItem(base);
		slot->itemBase = base;
		slot->loadVisuals();

	}
	if (sender == mainInventory->ItemBoxWidget)
	{
		addItem(base);
	}
	if (sender == mainInventory->otherItemBoxWidget)
	{

		if (state == InventoryState::TRANSFER)
		{
			otherInventoryForTransfering->addItem(base);
		}

	}
	UWeaponItem* x = equipment->getItem<UWeaponItem>(EquipmentInformation::WEAPON1);
	if (x)
		x->generatedWeapon->detachAttachment(slot->weaponAttachmentSlot);
}
Beispiel #2
0
    void TradeWindow::onItemSelected (int index)
    {
        const ItemStack& item = mSortModel->getItem(index);

        MWWorld::Ptr object = item.mBase;
        int count = item.mCount;
        bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
        if (MyGUI::InputManager::getInstance().isControlPressed())
            count = 1;

        if (count > 1 && !shift)
        {
            CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
            std::string message = "#{sQuanityMenuMessage02}";
            dialog->open(MWWorld::Class::get(object).getName(object), message, count);
            dialog->eventOkClicked.clear();
            dialog->eventOkClicked += MyGUI::newDelegate(this, &TradeWindow::sellItem);
            mItemToSell = mSortModel->mapToSource(index);
        }
        else
        {
            mItemToSell = mSortModel->mapToSource(index);
            sellItem (NULL, count);
        }
    }
Beispiel #3
0
void UInventoryComponent::unEquip(UEquippedItemWidget* slot, UItemBase* base, UItemScrollBoxWidget* sender)
{
	UE_LOG(LogTemp, Warning, TEXT("unEQUIP"));
	if (slot->allowedType != base->type && slot->allowedType != ItemCategory::ALL) return;
	if (sender == mainInventory->sellItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->ItemBoxWidget) return;
			sellItem(base);
		}
	}
	if (sender == mainInventory->ItemBoxWidget)
	{

		addItem(base);
	
	}
	if (sender == mainInventory->otherItemBoxWidget)
	{
		if (state == InventoryState::TRANSFER)
		{

			
			otherInventoryForTransfering->addItem(base);
		}

	}
	if (sender == mainInventory->buyItemBoxWidget)
	{

	}
	equipment->unequipItem(slot->equipmentSlot);
	refresh();
}
Beispiel #4
0
    void InventoryWindow::onItemSelectedFromSourceModel (int index)
    {
        if (mDragAndDrop->mIsOnDragAndDrop)
        {
            mDragAndDrop->drop(mTradeModel, mItemView);
            return;
        }

        const ItemStack& item = mTradeModel->getItem(index);
        std::string sound = item.mBase.getClass().getDownSoundId(item.mBase);

        MWWorld::Ptr object = item.mBase;
        int count = item.mCount;

        bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
        if (MyGUI::InputManager::getInstance().isControlPressed())
            count = 1;

        if (mTrading)
        {
            // Can't give conjured items to a merchant
            if (item.mFlags & ItemStack::Flag_Bound)
            {
                MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
                MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog9}");
                return;
            }

            // check if merchant accepts item
            int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices();
            if (!object.getClass().canSell(object, services))
            {
                MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0);
                MWBase::Environment::get().getWindowManager()->
                        messageBox("#{sBarterDialog4}");
                return;
            }
        }

        if (count > 1 && !shift)
        {
            CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
            std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
            dialog->open(object.getClass().getName(object), message, count);
            dialog->eventOkClicked.clear();
            if (mTrading)
                dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::sellItem);
            else
                dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::dragItem);
            mSelectedItem = index;
        }
        else
        {
            mSelectedItem = index;
            if (mTrading)
                sellItem (NULL, count);
            else
                dragItem (NULL, count);
        }
    }
Beispiel #5
0
    void InventoryWindow::onItemSelectedFromSourceModel (int index)
    {
        if (mDragAndDrop->mIsOnDragAndDrop)
        {
            mDragAndDrop->drop(mTradeModel, mItemView);
            return;
        }

        const ItemStack& item = mTradeModel->getItem(index);

        MWWorld::Ptr object = item.mBase;
        int count = item.mCount;

        // Bound items may not be moved
        if (item.mBase.getCellRef().mRefID.size() > 6
                && item.mBase.getCellRef().mRefID.substr(0,6) == "bound_")
        {
            MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog12}");
            return;
        }

        if (item.mType == ItemStack::Type_Equipped)
        {
            MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
            MWWorld::Ptr newStack = *invStore.unequipItem(item.mBase, mPtr);

            // The unequipped item was re-stacked. We have to update the index
            // since the item pointed does not exist anymore.
            if (item.mBase != newStack)
            {
                // newIndex will store the index of the ItemStack the item was stacked on
                int newIndex = -1;
                for (size_t i=0; i < mTradeModel->getItemCount(); ++i)
                {
                    if (mTradeModel->getItem(i).mBase == newStack)
                    {
                        newIndex = i;
                        break;
                    }
                }

                if (newIndex == -1)
                    throw std::runtime_error("Can't find restacked item");

                index = newIndex;
                object = mTradeModel->getItem(index).mBase;
            }

        }

        bool shift = MyGUI::InputManager::getInstance().isShiftPressed();
        if (MyGUI::InputManager::getInstance().isControlPressed())
            count = 1;

        if (mTrading)
        {
            // check if merchant accepts item
            int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices();
            if (!MWWorld::Class::get(object).canSell(object, services))
            {
                MWBase::Environment::get().getWindowManager()->
                        messageBox("#{sBarterDialog4}");
                return;
            }
        }

        if (count > 1 && !shift)
        {
            CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
            std::string message = mTrading ? "#{sQuanityMenuMessage01}" : "#{sTake}";
            dialog->open(MWWorld::Class::get(object).getName(object), message, count);
            dialog->eventOkClicked.clear();
            if (mTrading)
                dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::sellItem);
            else
                dialog->eventOkClicked += MyGUI::newDelegate(this, &InventoryWindow::dragItem);
            mSelectedItem = index;
        }
        else
        {
            mSelectedItem = index;
            if (mTrading)
                sellItem (NULL, count);
            else
                dragItem (NULL, count);
        }

        // item might have been unequipped
        notifyContentChanged();
    }
Beispiel #6
0
void UInventoryComponent::moveItem(UItemWidget* slot, UItemBase* base, UItemScrollBoxWidget* sender)
{

	
	if (sender == mainInventory->sellItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->ItemBoxWidget) return;
			removeItem(base);
			sellItem(base);
		}
	}
	if (sender == mainInventory->ItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->sellItemBoxWidget) return;
			addItem(base);
			unsellItem(base);
		}
		if (state == InventoryState::TRANSFER)
		{
			if (!(base->itemParent == mainInventory->otherItemBoxWidget)) return;
			
			otherInventoryForTransfering->removeItem(base);
			addItem(base);
			
		
		}
	}
	if (sender == mainInventory->otherItemBoxWidget)
	{

		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->buyItemBoxWidget) return;
			otherInventoryForTransfering->addItem(base);
			unBuyItem(base);
		}
		if (state == InventoryState::TRANSFER)
		{

			base->itemParent->inventoryParent->removeItem(base);
			otherInventoryForTransfering->addItem(base);
		}

	}
	if (sender == mainInventory->buyItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->otherItemBoxWidget) return;
			otherInventoryForTransfering->removeItem(base);
			buyItem(base);
		}

	}
	refresh();
	
}
void main ()
{	
	startDay(sFile2);
	populateTextfile(sFile1);

	int i;

	do
	{
		printf("----------------------------------------------------\n");
		printf("Push 1 to sell item.\n");
		printf("Push 2 to return item.\n");
		printf("Push 3 to search stock on system.\n");
		printf("Push 4 to update stock.\n");
		printf("Push 5 to print all stock to screen.\n");
		printf("Push 6 to see cash in till for today only.\n");
		printf("Push 7 or higher to quit the program.\n");
		printf("?: ");
		scanf("%d", &i);

		switch (i)
		{
		case 1:
			printf("\n----------------------------------------------------\n");
			sellItem(sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 2:
			printf("\n----------------------------------------------------\n");
			returnBook (sFile1, sFile2);
			printf("----------------------------------------------------\n\n");
			break;
			
		case 3:
			printf("\n----------------------------------------------------\n");
			stockSwitch();
			printf("----------------------------------------------------\n\n");
			break;
			
		case 4:
			printf("\n----------------------------------------------------\n");
			updateStock();
			printf("----------------------------------------------------\n");
			break;
		
		case 5:
			printf("\n----------------------------------------------------\n");
			printItem(sFile1);
			printf("----------------------------------------------------\n\n");
			break;

		case 6:
			printf("\n----------------------------------------------------\n");
			cash(sFile2);
			printf("----------------------------------------------------\n\n");
			break;

		case 9:
			rofl();
			break;
		}
	}
	while (i<7 && i!=9);
	populateTextfile(sFile1);
	endStatement(sFile2);
}