static void DrawItemPrice(float scale) { Entity * temp = SecondaryInventory->io; if(temp->ioflags & IO_SHOP) { Vec2f pos = Vec2f(DANAEMouse); pos += Vec2f(60, -10) * scale; if(g_secondaryInventoryHud.containsPos(DANAEMouse)) { long amount = ARX_INTERACTIVE_GetPrice(FlyingOverIO, temp); // achat float famount = amount - amount * player.m_skillFull.intuition * 0.005f; // check should always be OK because amount is supposed positive amount = checked_range_cast<long>(famount); Color color = (amount <= player.gold) ? Color::green : Color::red; ARX_INTERFACE_DrawNumber(pos, amount, color, scale); } else if(g_playerInventoryHud.containsPos(DANAEMouse)) { long amount = ARX_INTERACTIVE_GetSellValue(FlyingOverIO, temp); if(amount) { Color color = Color::red; if(temp->shop_category.empty() || FlyingOverIO->groups.find(temp->shop_category) != FlyingOverIO->groups.end()) { color = Color::green; } ARX_INTERFACE_DrawNumber(pos, amount, color, scale); } } } }
bool SecondaryInventoryHud::dragEntity(Entity * io, const Vec2s & pos) { if(SecondaryInventory != NULL) { if(g_secondaryInventoryHud.containsPos(pos) && (io->ioflags & IO_ITEM)) { Entity * ioo = SecondaryInventory->io; if(ioo->ioflags & IO_SHOP) { long cos = ARX_INTERACTIVE_GetPrice(io, ioo); float fcos = cos - cos * player.m_skillFull.intuition * 0.005f; cos = checked_range_cast<long>(fcos); if(player.gold < cos) { return false; } ARX_SOUND_PlayInterface(SND_GOLD); player.gold -= cos; if(io->_itemdata->count > 1) { Entity * ioo = CloneIOItem(io); ioo->show = SHOW_FLAG_NOT_DRAWN; ioo->scriptload = 1; ioo->_itemdata->count = 1; io->_itemdata->count--; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(ioo); return true; } } else if(io->_itemdata->count > 1) { if(!GInput->actionPressed(CONTROLS_CUST_STEALTHMODE)) { Entity * ioo = CloneIOItem(io); ioo->show = SHOW_FLAG_NOT_DRAWN; ioo->scriptload = 1; ioo->_itemdata->count = 1; io->_itemdata->count--; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(ioo); sInventory = 2; Vec2f calc; calc.x = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale); calc.y = (pos.y - (13 * m_scale)) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(calc.x); sInventoryPos.y = checked_range_cast<short>(calc.y); //ARX_INVENTORY_Object_Out(SecondaryInventory->io, ioo); ARX_INVENTORY_IdentifyIO(ioo); return true; } } } for(long j = 0; j < SecondaryInventory->m_size.y; j++) for(long i = 0; i < SecondaryInventory->m_size.x; i++) { INVENTORY_SLOT & slot = SecondaryInventory->slot[i][j]; if(slot.io != io) continue; slot.io = NULL; slot.show = true; sInventory = 2; float fCalcX = (pos.x + m_fadePosition - (2 * m_scale)) / (32 * m_scale); float fCalcY = (pos.y - (13 * m_scale)) / (32 * m_scale); sInventoryPos.x = checked_range_cast<short>(fCalcX); sInventoryPos.y = checked_range_cast<short>(fCalcY); } } Set_DragInter(io); RemoveFromAllInventories(io); ARX_INVENTORY_IdentifyIO(io); return true; }
void SecondaryInventoryHud::dropEntity() { // First Look for Identical Item... if(SecondaryInventory && g_secondaryInventoryHud.containsPos(DANAEMouse)) { Entity * io = SecondaryInventory->io; float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; //>>1; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); // SHOP if(io->ioflags & IO_SHOP) { if(!io->shop_category.empty() && DRAGINTER->groups.find(io->shop_category) == DRAGINTER->groups.end()) return; if(price <= 0) return; // Check shop group for(long j = 0; j < SecondaryInventory->m_size.y; j++) { for(long i = 0; i < SecondaryInventory->m_size.x; i++) { Entity * ioo = SecondaryInventory->slot[i][j].io; if(!ioo || !IsSameObject(DRAGINTER, ioo)) continue; ioo->_itemdata->count += DRAGINTER->_itemdata->count; ioo->scale = 1.f; DRAGINTER->destroy(); ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); ARX_SOUND_PlayInterface(SND_INVSTD); return; } } } Vec2s t = Vec2s_ZERO; t.x = DANAEMouse.x + static_cast<short>(m_fadePosition) - (2 * m_scale); t.y = DANAEMouse.y - (13 * m_scale); t.x = t.x / (32 * m_scale); t.y = t.y / (32 * m_scale); Vec2s s = DRAGINTER->m_inventorySize; if(t.x <= SecondaryInventory->m_size.x - s.x && t.y <= SecondaryInventory->m_size.y - s.y) { float fprice = ARX_INTERACTIVE_GetPrice(DRAGINTER, io) / 3.0f; long price = checked_range_cast<long>(fprice); price *= DRAGINTER->_itemdata->count; fprice = price + price * player.m_skillFull.intuition * 0.005f; price = checked_range_cast<long>(fprice); for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { Entity * ioo = SecondaryInventory->slot[t.x+i][t.y+j].io; if(!ioo) continue; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; if( ioo->_itemdata->playerstacksize > 1 && IsSameObject(DRAGINTER, ioo) && ioo->_itemdata->count < ioo->_itemdata->playerstacksize ) { ioo->_itemdata->count += DRAGINTER->_itemdata->count; if(ioo->_itemdata->count > ioo->_itemdata->playerstacksize) { DRAGINTER->_itemdata->count = ioo->_itemdata->count - ioo->_itemdata->playerstacksize; ioo->_itemdata->count = ioo->_itemdata->playerstacksize; } else { DRAGINTER->_itemdata->count = 0; } } if(DRAGINTER->_itemdata->count) { if(CanBePutInSecondaryInventory(SecondaryInventory, DRAGINTER)) { // SHOP if(io->ioflags & IO_SHOP) { ARX_PLAYER_AddGold(price); ARX_SOUND_PlayInterface(SND_GOLD); } } else { return; } } ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } if(DRAGINTER->ioflags & IO_GOLD) { ARX_PLAYER_AddGold(DRAGINTER); Set_DragInter(NULL); return; } for(long j = 0; j < s.y; j++) { for(long i = 0; i < s.x; i++) { SecondaryInventory->slot[t.x+i][t.y+j].io = DRAGINTER; SecondaryInventory->slot[t.x+i][t.y+j].show = false; } } // SHOP if(io->ioflags & IO_SHOP) { player.gold += price; ARX_SOUND_PlayInterface(SND_GOLD); } SecondaryInventory->slot[t.x][t.y].show = true; DRAGINTER->show = SHOW_FLAG_IN_INVENTORY; ARX_SOUND_PlayInterface(SND_INVSTD); Set_DragInter(NULL); return; } } }