void lapi_data_create_item(const LuaStackValue& table) { ItemEntry* entry = new ItemEntry; entry->init(game_item_data.size(), table); table["__method"] = "item_create"; game_item_data.new_entry(entry->name, entry, table); }
/************************************************************************* Remove all items from the list. *************************************************************************/ bool ItemListBase::resetList_impl(void) { // just return false if the list is already empty if (d_listItems.empty()) { return false; } // we have items to be removed and possible deleted else { // delete any items we are supposed to while (!d_listItems.empty()) { ItemEntry* item = d_listItems[0]; d_pane->removeChildWindow(item); if (item->isDestroyedByParent()) { WindowManager::getSingleton().destroyWindow(item); } } // list is cleared by the removeChild calls return true; } }
/************************************************************************* Query item selection state *************************************************************************/ bool ItemListbox::isItemSelected(size_t index) const { if (index >= d_listItems.size()) { CEGUI_THROW(InvalidRequestException( "The index given is out of range for this ItemListbox")); } ItemEntry *li = d_listItems[index]; return li->isSelected(); }
/************************************************************************ Get a pointer to the first selected item starting from the given index ************************************************************************/ ItemEntry* ItemListbox::findSelectedItem(size_t start_index) const { const size_t max = d_listItems.size(); for (size_t i = start_index; i < max; ++i) { ItemEntry* li = d_listItems[i]; if (li->isSelected()) { d_nextSelectionIndex = i + 1; return li; } } return 0; }
//----------------------------------------------------------------------------// void ScrolledItemListBase::ensureItemIsVisibleHorz(const ItemEntry& item) { const Rect render_area = getItemRenderArea(); Scrollbar* const h = getHorzScrollbar(); const float currPos = h->getScrollPosition(); const float left = item.getXPosition().asAbsolute(this->getPixelSize().d_width) - currPos; const float right = left + item.getItemPixelSize().d_width; // if left is left of the view area, or if item too big, scroll item to left if ((left < render_area.d_left) || ((right - left) > render_area.getWidth())) h->setScrollPosition(currPos + left); // if right is right of the view area, scroll item to right of list else if (right >= render_area.d_right) h->setScrollPosition(currPos + right - render_area.getWidth()); }
//----------------------------------------------------------------------------// void ScrolledItemListBase::ensureItemIsVisibleVert(const ItemEntry& item) { const Rect render_area = getItemRenderArea(); Scrollbar* const v = getVertScrollbar(); const float currPos = v->getScrollPosition(); const float top = item.getYPosition().asAbsolute(this->getPixelSize().d_height) - currPos; const float bottom = top + item.getItemPixelSize().d_height; // if top is above the view area, or if item is too big, scroll item to top if ((top < render_area.d_top) || ((bottom - top) > render_area.getHeight())) v->setScrollPosition(currPos + top); // if bottom is below the view area, scroll item to bottom of list else if (bottom >= render_area.d_bottom) v->setScrollPosition(currPos + bottom - render_area.getHeight()); }
static void item_do_lua_action(lua_State* L, ItemEntry& type, GameInst* user, const Pos& p, int amnt) { LuaValue& usefunc = type.inventory_use_func().get(L); usefunc.push(); luayaml_push_item(L, type.name.c_str()); luawrap::push(L, user); lua_pushnumber(L, p.x); lua_pushnumber(L, p.y); lua_pushnumber(L, amnt); lua_call(L, 5, 0); }
bool MainMenuWindow::handleChooseModule(MenuItem* it, ContentModule* module) { MenuBase* modulesMenu = getMenu("MainMenu/Modules/Menu"); ItemEntry* itOld = NULL; for (size_t i=0; i<modulesMenu->getItemCount(); i++) { ItemEntry* curr = modulesMenu->getItemFromIndex(i); if (curr->getText().compare(mActiveModule->getName()+" *") == 0) { itOld = curr; break; } } itOld->setText(mActiveModule->getName()); mActiveModule = module; it->setText(module->getName()+" *"); return true; }
/************************************************************************ 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; }
static bool item_check_lua_prereq(lua_State* L, ItemEntry& type, GameInst* user) { LuaValue& prereq = type.inventory_use_prereq_func().get(L); if (prereq.empty()) return true; prereq.push(); luayaml_push_item(L, type.name.c_str()); luawrap::push(L, user); lua_call(L, 2, 1); bool ret = lua_toboolean(L, lua_gettop(L)); lua_pop(L, 1); return ret; }
void FalagardItemEntry::render() { ItemEntry* item = static_cast<ItemEntry*>(d_window); // get WidgetLookFeel for the assigned look. const WidgetLookFeel& wlf = getLookNFeel(); const StateImagery* imagery; // render basic imagery String state = item->isDisabled() ? "Disabled" : "Enabled"; if (item->isSelectable() && item->isSelected()) { imagery = &wlf.getStateImagery(item->isDisabled()?"SelectedDisabled":"SelectedEnabled"); } else { imagery = &wlf.getStateImagery(item->isDisabled()?"Disabled":"Enabled"); } imagery->render(*d_window); }