/** * Gets the quantity of the currently selected item * on the base. * @return Quantity of selected item on the base. */ int SellState::getQuantity() { int qty = 0; // Soldiers/crafts are individual switch(getType(_sel)) { case SELL_SOLDIER: case SELL_CRAFT: return 1; case SELL_SCIENTIST: return _base->getAvailableScientists(); case SELL_ENGINEER: return _base->getAvailableEngineers(); case SELL_ITEM: qty = _base->getItems()->getItem(_items[getItemIndex(_sel)]); if (Options::storageLimitsEnforced && _origin == OPT_BATTLESCAPE) { for (std::vector<Transfer*>::iterator j = _base->getTransfers()->begin(); j != _base->getTransfers()->end(); ++j) { if ((*j)->getItems() == _items[getItemIndex(_sel)]) { qty += (*j)->getQuantity(); } } for (std::vector<Craft*>::iterator j = _base->getCrafts()->begin(); j != _base->getCrafts()->end(); ++j) { qty += (*j)->getItems()->getItem(_items[getItemIndex(_sel)]); } } return qty; } return 0; }
/************************************************************************* Handler for when mouse button is pressed *************************************************************************/ void Listbox::onMouseButtonDown(MouseEventArgs& e) { // base class processing Window::onMouseButtonDown(e); if (e.button == LeftButton) { bool modified = false; // clear old selections if no control key is pressed or if multi-select is off if (!(e.sysKeys & Control) || !d_multiselect) { modified = clearAllSelections_impl(); } Point localPos(screenToWindow(e.position)); if (getMetricsMode() == Relative) { localPos = relativeToAbsolute(localPos); } ListboxItem* item = getItemAtPoint(localPos); if (item != NULL) { modified = true; // select range or item, depending upon keys and last selected item if (((e.sysKeys & Shift) && (d_lastSelected != NULL)) && d_multiselect) { selectRange(getItemIndex(item), getItemIndex(d_lastSelected)); } else { item->setSelected(item->isSelected() ^ true); } // update last selected item d_lastSelected = item->isSelected() ? item : NULL; } // fire event if needed if (modified) { WindowEventArgs args(this); onSelectionChanged(args); } e.handled = true; } }
/************************************************************************ Notify item clicked ************************************************************************/ void ItemListbox::notifyItemClicked(ItemEntry* li) { bool sel_state = !(li->isSelected() && d_multiSelect); bool skip = false; // multiselect enabled if (d_multiSelect) { uint syskeys = getGUIContext().getSystemKeys().get(); ItemEntry* last = d_lastSelected; // no Control? clear others if (!(syskeys & Control)) { clearAllSelections(); if (!sel_state) { sel_state=true; } } // select range if Shift if held, and we have a 'last selection' if (last && (syskeys & Shift)) { selectRange(getItemIndex(last),getItemIndex(li)); skip = true; } } else { clearAllSelections(); } if (!skip) { li->setSelected_impl(sel_state,false); if (sel_state) { d_lastSelected = li; } else if (d_lastSelected == li) { d_lastSelected = 0; } } WindowEventArgs e(this); onSelectionChanged(e); }
void HistoryDlg::getContextMenu(xpr_bool_t sRightClick) { HistoryDisp *sHistoryDisp = getCurHistoryDisp(); if (sHistoryDisp == XPR_NULL) return; CPoint sCursorPoint; GetCursorPos(&sCursorPoint); HTREEITEM sTreeItem = XPR_NULL; if (sRightClick == XPR_TRUE) { CPoint sHitTestPoint(sCursorPoint); mTreeCtrl.ScreenToClient(&sHitTestPoint); sTreeItem = mTreeCtrl.HitTest(sHitTestPoint); } else { sTreeItem = mTreeCtrl.GetSelectedItem(); CRect sRect; mTreeCtrl.GetItemRect(sTreeItem, sRect, XPR_TRUE); mTreeCtrl.ClientToScreen(&sRect); if (!(sRect.left < sCursorPoint.x && sCursorPoint.x < sRect.right) || !(sRect.top < sCursorPoint.y && sRect.bottom < sCursorPoint.y)) { sCursorPoint.x = sRect.left + (sRect.right-sRect.left)/2; sCursorPoint.y = sRect.bottom; } } if (sTreeItem == XPR_NULL) return; xpr_uint_t sIndex = getItemIndex(sTreeItem); if (FXFILE_STL_IS_INDEXABLE(sIndex, *sHistoryDisp->mHistoryDeque) == XPR_FALSE) return; HistoryDeque::const_reverse_iterator sReverseIterator = sHistoryDisp->mHistoryDeque->rbegin() + sIndex; if (sReverseIterator == sHistoryDisp->mHistoryDeque->rend()) return; LPITEMIDLIST sFullPidl = *sReverseIterator; if (sFullPidl == XPR_NULL) return; xpr_bool_t sResult; LPSHELLFOLDER sShellFolder = XPR_NULL; LPCITEMIDLIST sPidl = XPR_NULL; sResult = fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl); if (XPR_IS_TRUE(sResult) && sShellFolder != XPR_NULL && sPidl != XPR_NULL) { xpr_uint_t nFlags = TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON; ContextMenu::trackItemMenu(sShellFolder, &sPidl, 1, &sCursorPoint, nFlags, m_hWnd, CMF_EXPLORE); } COM_RELEASE(sShellFolder); }
void HistoryDlg::OnTvnSelchangedTree(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); *pResult = 0; HistoryDisp *sHistoryDisp = getCurHistoryDisp(); if (sHistoryDisp == XPR_NULL) return; xpr_tchar_t sPath[XPR_MAX_PATH * 2] = {0}; HTREEITEM sTreeItem = mTreeCtrl.GetSelectedItem(); if (sTreeItem != XPR_NULL) { xpr_uint_t sIndex = getItemIndex(sTreeItem); if (FXFILE_STL_IS_INDEXABLE(sIndex, *sHistoryDisp->mHistoryDeque)) { HistoryDeque::const_reverse_iterator sReverseIterator = sHistoryDisp->mHistoryDeque->rbegin() + sIndex; if (sReverseIterator != sHistoryDisp->mHistoryDeque->rend()) { LPITEMIDLIST sFullPidl = *sReverseIterator; if (sFullPidl != XPR_NULL) { if (IsFileSystem(sFullPidl)) GetName(sFullPidl, SHGDN_FORPARSING, sPath); else GetFullPath(sFullPidl, sPath); } } } } SetDlgItemText(IDC_HISTORY_STATUS, sPath); }
void TabControl::_notifyDeleteItem(TabItem* _sheet) { // общий шутдаун виджета if (mShutdown) return; size_t index = getItemIndex(_sheet); mWidthBar -= mItemsInfo[index].width; mItemsInfo.erase(mItemsInfo.begin() + index); if (0 == mItemsInfo.size()) mIndexSelect = ITEM_NONE; else { if (index < mIndexSelect) mIndexSelect --; else if (index == mIndexSelect) { if (mIndexSelect == mItemsInfo.size()) mIndexSelect --; mItemsInfo[mIndexSelect].item->setVisible(true); mItemsInfo[mIndexSelect].item->setAlpha(ALPHA_MAX); } } updateBar(); }
DWORD GetMoneyByItem( CHARLIST *ch ) { DWORD money=0; int type, num; CItem *t; for( int i=0; i<3; i++ ) for( int j=0; j<3; j++ ) for( int k=0; k<8; k++ ) { ItemAttr &item = ch->inv[i][j][k]; if( item.item_no ) { getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == IK_MONEY ) { if( item.item_no == IN_COIN && item.attr[IATTR_MUCH] > 5) // 동전 { item.item_no = IN_COINS; // 돈 더미로 바꿈 } else if( item.item_no == IN_COINS && item.attr[IATTR_MUCH] <= 5 ) // 동전 더미 { item.item_no = IN_COIN; } money += item.attr[IATTR_MUCH]; } } } if( ch->handheld.item_no ) // 핸드 부분에 있는 돈 계산 { ItemAttr &item = ch->handheld; getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == IK_MONEY ) { if( item.item_no == IN_COIN && item.attr[IATTR_MUCH] > 5) item.item_no = IN_COINS; else if( item.item_no == IN_COINS && item.attr[IATTR_MUCH] <= 5 ) item.item_no = IN_COIN; money += item.attr[IATTR_MUCH]; } } return money; }
int addConstant(str constName, str constValue){ if(getItemIndex(constName)>-1){return 1;} Constant* c=new Constant(constName, constValue); constantVector.push_back(c); return 0; //success }
str getItemValue(str constName){ int i=getItemIndex(constName); if(i==-1){ //if(ERR)printf("*******Nie znaleziono wartosci stalej %s\n", constName.c_str()); return NULL; } return constantVector.at(i)->value; }
void MenuControl::_notifyUpdateName(MenuItem* _item) { size_t index = getItemIndex(_item); mItemsInfo[index].name = _item->getCaption(); ISubWidgetText* text = _item->getSubWidgetText(); mItemsInfo[index].width = text ? (text->getTextSize().width + _item->getSize().width - text->getWidth()) : 0; update(); }
void HistoryDlg::OnOK(void) { HTREEITEM sTreeItem = mTreeCtrl.GetSelectedItem(); if (sTreeItem != XPR_NULL) { mIndex = getItemIndex(sTreeItem); } super::OnOK(); }
/////////////////////////////////////////////// // 장착 이미지를 가져온다 ///////////////////////////////////////////////// int GetItemView( int item_no, int is_man ) { CItem *t; int type, num; getItemIndex( item_no, type, num ); t = ItemUnit( type, num ); if( !t ) return 0; else return t->GetItemShow( is_man ); }
void ScrollDoubleLayer::_doEventMenuScrollItemClick(Node *node, WJTouchEvent *e, WJScrollLayer *scroll) { auto item = (ScrollMenuItem*)node; if (item->getItemIndex() == m_preSelectMenuIndex) return; // 选中状态的改变 setMenuItemSelected(item); playScrollLayerActionWhenClickMenuItem(item, e, scroll); }
// public void LLNameListCtrl::removeNameItem(const LLUUID& agent_id) { BOOL item_exists = selectByID( agent_id ); if(item_exists) { S32 index = getItemIndex(getFirstSelected()); if(index >= 0) { deleteSingleItem(index); } } }
void TreeModel::addItem(QString label, QVariantList data, QString path) { qDebug() << "Adding item" << label << path; if (data.count() != m_roles.count()) qDebug() << "Adding an item with a different number of roles" << data.count() << m_roles.count(); if (path.isEmpty()) { TreeModelItem *item = new TreeModelItem(label); QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership); item->setData(data); int addIndex = getItemIndex(label); beginInsertRows(QModelIndex(), addIndex, addIndex); m_items.insert(addIndex, item); endInsertRows(); } else { TreeModelItem *item = NULL; QStringList pathList = path.split("/"); if (m_itemsPathMap.contains(pathList.at(0))) { item = m_itemsPathMap[pathList.at(0)]; } else { item = new TreeModelItem(pathList.at(0)); item->setPath(pathList.at(0)); QQmlEngine::setObjectOwnership(item, QQmlEngine::CppOwnership); if (item->setChildrenColumns(m_roles) == true) { connect(item->children(), SIGNAL(singleSelection(TreeModelItem*)), this, SLOT(setSingleSelection(TreeModelItem*))); qDebug() << "Tree" << this << "connected to tree" << item->children(); } int addIndex = getFolderIndex(label); beginInsertRows(QModelIndex(), addIndex, addIndex); m_items.insert(addIndex, item); endInsertRows(); m_itemsPathMap[pathList.at(0)] = item; } if (pathList.count() == 1) { if (item->addChild(label, data, m_sorting) == true) { connect(item->children(), SIGNAL(singleSelection(TreeModelItem*)), this, SLOT(setSingleSelection(TreeModelItem*))); qDebug() << "Tree" << this << "connected to tree" << item->children(); } }
/** * Increases or decreases the quantity of the selected item to sell. * @param change How much we want to add or remove. * @param dir Direction to change, +1 to increase or -1 to decrease. */ void SellState::changeByValue(int change, int dir) { if (dir > 0) { if (0 >= change || getQuantity() <=_qtys[_sel]) return; change = std::min(getQuantity() - _qtys[_sel], change); } else { if (0 >= change || 0 >= _qtys[_sel]) return; change = std::min(_qtys[_sel], change); } _qtys[_sel] += dir * change; _total += dir * getPrice() * change; // Calculate the change in storage space. Craft *craft; RuleItem *armor, *item, *weapon, *ammo; double total = 0.0; switch (getType(_sel)) { case SELL_SOLDIER: if (_soldiers[_sel]->getArmor()->getStoreItem() != "STR_NONE") { armor = _game->getRuleset()->getItem(_soldiers[_sel]->getArmor()->getStoreItem()); _spaceChange += dir * armor->getSize(); } break; case SELL_CRAFT: craft = _crafts[getCraftIndex(_sel)]; for (std::vector<CraftWeapon*>::iterator w = craft->getWeapons()->begin(); w != craft->getWeapons()->end(); ++w) { if (*w) { weapon = _game->getRuleset()->getItem((*w)->getRules()->getLauncherItem()); total += weapon->getSize(); ammo = _game->getRuleset()->getItem((*w)->getRules()->getClipItem()); if (ammo) total += ammo->getSize() * (*w)->getClipsLoaded(_game->getRuleset()); } } _spaceChange += dir * total; break; case SELL_ITEM: item = _game->getRuleset()->getItem(_items[getItemIndex(_sel)]); _spaceChange -= dir * change * item->getSize(); break; default: break; } updateItemStrings(); }
CGameObject *CPetGlyphs::getObjectAt(const Point &pt) const { for (int idx = 0; idx < _numVisibleGlyphs; ++idx) { Rect glyphRect = getRect(idx); if (glyphRect.contains(pt)) { CPetGlyph *glyph = getGlyph(getItemIndex(idx)); if (glyph) return glyph->getObjectAt(); } } return nullptr; }
//virtual BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; S32 column_index = getColumnIndexFromOffset(x); LLNameListItem* hit_item = dynamic_cast<LLNameListItem*>(hitItem(x, y)); if (hit_item && column_index == mNameColumnIndex) { // ...this is the column with the avatar name LLUUID avatar_id = hit_item->getUUID(); if (avatar_id.notNull()) { // ...valid avatar id LLScrollListCell* hit_cell = hit_item->getColumn(column_index); if (hit_cell) { S32 row_index = getItemIndex(hit_item); LLRect cell_rect = getCellRect(row_index, column_index); // Convert rect local to screen coordinates LLRect sticky_rect; localRectToScreen(cell_rect, &sticky_rect); // Spawn at right side of cell LLPointer<LLUIImage> icon = LLUI::getUIImage("Info_Small"); LLCoordGL pos( sticky_rect.mRight - info_icon_size, sticky_rect.mTop - (sticky_rect.getHeight() - icon->getHeight())/2 ); // Should we show a group or an avatar inspector? bool is_group = hit_item->isGroup(); bool is_experience = hit_item->isExperience(); LLToolTip::Params params; params.background_visible( false ); params.click_callback( boost::bind(&LLNameListCtrl::showInspector, this, avatar_id, is_group, is_experience) ); params.delay_time(0.0f); // spawn instantly on hover params.image( icon ); params.message(""); params.padding(0); params.pos(pos); params.sticky_rect(sticky_rect); LLToolTipMgr::getInstance()->show(params); handled = TRUE; } } } if (!handled) { handled = LLScrollListCtrl::handleToolTip(x, y, mask); } return handled; }
void MenuControl::_notifyDeleteItem(MenuItem* _item) { // дитю меняем скин if (mChangeChildSkin) return; // общий шутдаун виджета if (mShutdown) return; size_t index = getItemIndex(_item); mItemsInfo.erase(mItemsInfo.begin() + index); update(); }
///////////////////////////////////////////////////////////////////////////////////// // // 아이템에 의한 매직 공격력... // // 파라메타 : 아이템 넘버로 매직 클레스 값을 가져오고 비교해서 // 리턴값 : 매직 공격력을 넘겨 준다. // ////////////////////////////////////////////////////////////////////////////////////// int MagicByItem( int item_no, int magic_class ) { int type, num; getItemIndex( item_no, type, num ); CItem *t = ItemUnit( type, num ); if( !t ) return 0; if( t->GetKindOfMagic() == magic_class ) { return t->GetIncrDamage(); } return 0; }
void DeleteItem( ItemAttr *item ) { int type, num; if( !item ) return; // NULL일 경우 getItemIndex( item->item_no, type, num ); CItem *t = ItemUnit( type, num ); if( !t ) return; //if( t->GetItemKind() == IK_BOX ) DeleteBoxItem_SQL( item->attr[IATTR_ID] ); t->ThisMapValue--; //if( !t->m_Much ) t->m_Much = 0; memset( item, 0, sizeof( ItemAttr ) ); return; }
void MenuControl::_wrapItemChild(MenuItem* _item, MenuControl* _widget) { // заменяем size_t index = getItemIndex(_item); if (mItemsInfo[index].submenu != nullptr) { WidgetManager::getInstance().destroyWidget(mItemsInfo[index].submenu); mItemsInfo[index].submenu = nullptr; } mItemsInfo[index].submenu = _widget; // скрываем менюшку mItemsInfo[index].submenu->setVisible(false); update(); }
int addVariable(str varName){ if(getItemIndex(varName)>-1){ if(ERR)printf("*******ZMIENNA JUZ ISTNIEJE"); return 1; // juz istnieje } if(constantManager.getItemIndex(varName)>-1){ if(ERR)printf("*******ISTNIEJE JUZ STALA O TAKIEJ NAZWIE"); return 2; // juz istnieje stala o takiej nazwie } variableVector.push_back(varName); return 0; // sukces }
bool CPetGlyphs::MouseButtonDownMsg(const Point &pt) { if (_scrollLeft.contains2(pt)) { scrollLeft(); return true; } if (_scrollRight.contains2(pt)) { scrollRight(); return true; } for (int idx = 0; idx < _numVisibleGlyphs; ++idx) { Rect glyphRect = getRect(idx); if (glyphRect.contains(pt)) { int index = getItemIndex(idx); CPetGlyph *glyph = getGlyph(index); if (glyph) { if (_highlightIndex == index) { glyph->selectGlyph(glyphRect, pt); glyph->updateTooltip(); } else { changeHighlight(index); makePetDirty(); } return true; } } } if (_highlightIndex != -1) { CPetGlyph *glyph = getGlyph(_highlightIndex); if (glyph) { if (glyph->MouseButtonDownMsg(pt)) return true; if (!(_flags & GFLAG_2)) { changeHighlight(-1); makePetDirty(); } } } return false; }
/** * Gets the price of the currently selected item. * @return Price of the selected item. */ int SellState::getPrice() { // Personnel/craft aren't worth anything switch(getType(_sel)) { case SELL_SOLDIER: case SELL_ENGINEER: case SELL_SCIENTIST: return 0; case SELL_ITEM: return _game->getRuleset()->getItem(_items[getItemIndex(_sel)])->getSellCost(); case SELL_CRAFT: Craft *craft = _crafts[getCraftIndex(_sel)]; return craft->getRules()->getSellCost(); } return 0; }
ItemAttr *SearchItemOfInvByKind( int kind, CHARLIST *ch ) { int type, num; CItem * t; for( int i=0; i<3; i++ ) for( int j=0; j<3; j++ ) for( int k=0; k<8; k++ ) { ItemAttr &item = ch->inv[i][j][k]; if( item.item_no ) { getItemIndex( item.item_no, type, num ); t = ItemUnit( type, num ); if( t && t->GetItemKind() == kind ) return &item; } } return NULL; }
int GetWeight( ItemAttr item ) { int type, num; getItemIndex( item.item_no, type, num ); CItem *t = ItemUnit( type, num ); if( !t ) return 0; int weight = t->GetWeight(); if( t->GetRbutton() == DIVIDE_ITEM ) { int dur = t->GetItemDuration(); if( dur > 0 ) weight *= item.attr[IATTR_MUCH] / dur; else weight *= item.attr[IATTR_MUCH]; } return weight; }
// public void LLNameListCtrl::removeNameItem(const LLUUID& agent_id) { // Find the item specified with agent_id. S32 idx = -1; for (item_list::iterator it = getItemList().begin(); it != getItemList().end(); it++) { LLScrollListItem* item = *it; if (item->getUUID() == agent_id) { idx = getItemIndex(item); break; } } // Remove it. if (idx >= 0) { selectNthItem(idx); // not sure whether this is needed, taken from previous implementation deleteSingleItem(idx); } }
void CPetGlyphs::draw(CScreenManager *screenManager) { if (_highlightIndex != -1) { int index = getHighlightedIndex(_highlightIndex); if (index != -1) { Point tempPoint; Point pt = getPosition(index); pt -= Point(12, 13); _selection.translate(pt.x, pt.y); _selection.draw(screenManager); _selection.translate(-pt.x, -pt.y); } } // Iterate through displaying glyphs on the screen int listSize = size(); for (int index = 0; index < _numVisibleGlyphs; ++index) { int itemIndex = getItemIndex(index); if (itemIndex >= 0 && itemIndex < listSize) { Point pt = getPosition(index); CPetGlyph *glyph = getGlyph(itemIndex); if (glyph) glyph->drawAt(screenManager, pt, index == _highlightIndex); } } // Draw scrolling arrows if more than a screen's worth of items are showing if (listSize > _numVisibleGlyphs || (_flags & GFLAG_16)) { _scrollLeft.draw(screenManager); _scrollRight.draw(screenManager); } // Handle secondary highlight if (_highlightIndex != -1) { CPetGlyph *glyph = getGlyph(_highlightIndex); if (glyph) glyph->draw2(screenManager); } }
/************************************************************************ Get a pointer to the next selected item after the given item ************************************************************************/ ItemEntry* ItemListbox::getNextSelectedItemAfter(const ItemEntry* start_item) const { if (start_item==0||!d_multiSelect) { return 0; } size_t max = d_listItems.size(); size_t i = getItemIndex(start_item); while (i<max) { ItemEntry* li = d_listItems[i]; if (li->isSelected()) { return li; } ++i; } return 0; }