void dWMShop_c::executeState_Wait() { if (timer < 90) { scaleEase = -((cos(timer * 3.14 /20)-0.9)/timer*10)+1; timer++; return; } int nowPressed = Remocon_GetPressed(GetActiveRemocon()); int newSelection = -1; if (nowPressed & WPAD_ONE) { // Hide the thing state.setState(&StateID_HideWait); } else if (nowPressed & WPAD_UP) { // Move up if (selected == 4) newSelection = lastTopRowChoice; else if (selected == 5) newSelection = 4; } else if (nowPressed & WPAD_DOWN) { // Move down if (selected <= 3) newSelection = 4; else if (selected == 4) newSelection = 5; } else if (nowPressed & WPAD_LEFT) { // Just use the previous choice if (selected > 0) newSelection = selected - 1; } else if (nowPressed & WPAD_RIGHT) { // Just use the next choice if (selected < 5) newSelection = selected + 1; } else if (nowPressed & WPAD_TWO) { if (!lakituModel->playingNotEnough) buyItem(selected); else OSReport("Not Enough is still playing!\n"); } if (newSelection > -1) { MapSoundPlayer(SoundRelatedClass, SE_SYS_CURSOR, 1); layout.enableNonLoopAnim(DEACTIVATE_BUTTON+selected); layout.enableNonLoopAnim(ACTIVATE_BUTTON+newSelection); selected = newSelection; if (newSelection <= 3) lastTopRowChoice = newSelection; showSelectCursor(); } }
//***** Quantity should be checked when inputing it void transaction(unsigned char type,unsigned char msg[]){ int status; int quantity; item msg_item; // A-upc,name,price,stock,description,imagelink,category if (type == 'A'){ status = checkItem(msg,-1); if (status == 0){ msg_item = getItemFromMsg(msg); sendMsg(concat("A,",msg)); //status = receiveMsg(0); status = 1; if (status == 1){ addItem(msg_item); updateDatabase(); } else{ printMsg("Transaction failed!",0,30); printf("Transaction failed!\n\n"); } } else{ printMsg("Cannot add the item!",0,30); printf("Cannot add the item!\n\n"); } wait(30000000); } // B-upc,quantity else if (type == 'B'){ quantity = getQuantityFromMsg(msg); status = checkItem(msg,quantity); if (status == 1){ sendMsg(concat("B,",msg)); //status = receiveMsg(0); status = 1; if (status == 1){ buyItem(msg_item,quantity); updateDatabase(); } else{ printMsg("Transaction failed!",0,30); printf("Transaction failed!\n\n"); } } else{ printMsg("Cannot buy the item!",0,30); printf("Cannot buy the item!\n\n"); } wait(30000000); } // C-upc,name,price,stock,description,imagelink else if (type == 'C'){ status = checkItem(msg,-1); if (status == 1){ msg_item = getItemFromMsg(msg); sendMsg(concat("C,",msg)); //status = receiveMsg(0); status = 1; if (status == 1){ changeItem(msg_item); msg_item = scan(msg_item.upc); printf("Price after:%.2f\n",msg_item.price); updateDatabase(); } else{ printMsg("Transaction failed!",0,30); printf("Transaction failed!\n\n"); } } else{ printMsg("Cannot change the item's information!",0,30); printf("Cannot change the item's information!\n\n"); } wait(30000000); } }
void ItemManager::buyItem(int id) { auto item = getItemById(id); buyItem(item); }
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(); }