int VMenu2::AddItem(const MenuItemEx& NewItem, int PosAdd) { // BUGBUG int n=GetItemCount(); if(PosAdd<0) PosAdd=0; if(PosAdd>n) PosAdd=n; FarListItem fi={NewItem.Flags, NewItem.strName.data()}; FarListInsert fli={sizeof(FarListInsert), PosAdd, fi}; if(SendMessage(DM_LISTINSERT, 0, &fli)<0) return -1; FarListItemData flid={sizeof(FarListItemData), PosAdd, NewItem.UserDataSize, NewItem.UserData}; SendMessage(DM_LISTSETDATA, 0, &flid); GetItemPtr(PosAdd)->AccelKey=NewItem.AccelKey; GetItemPtr(PosAdd)->Annotations=NewItem.Annotations; Resize(); return n; }
/** \param data_type If this parameter is not equal to \e DataType_Invalid , this function will check to ensure that any instruction context item field located has the same data type. */ const InsItem *InsContext::GetItemPtr(const std::string &template_name, unsigned int auxiliary_id, const std::string &field_name, DataType data_type, bool is_required) const { return(GetItemPtr(ins_item_list_[GetTemplateIndex(template_name)], auxiliary_id, field_name, data_type, is_required)); }
/** \param data_type If this parameter is not equal to \e DataType_Invalid , this function will check to ensure that any instruction context item field located has the same data type. */ unsigned int InsContext::GetItemIndex(unsigned int template_id, unsigned int auxiliary_id, const std::string &field_name, DataType data_type, bool is_required) const { const InsItem *item_ptr = GetItemPtr(template_id, auxiliary_id, field_name, data_type, is_required); return((item_ptr != NULL) ? item_ptr->item_index_ : 0); }
ThingyRef& CThingyList::FetchThingyRefAt(ArrayIndexT inAtIndex) const { ThingyRef* resultP = NULL; if (!ValidIndex(inAtIndex)) { DEBUG_OUT("Throwing: ThingyList index out of range: "<<inAtIndex, DEBUG_ERROR | DEBUG_CONTAINMENT ); Throw_(invalidIndexErr); } else { resultP = (ThingyRef*) GetItemPtr(inAtIndex); } return *resultP; }
void CThingyList::WriteStream(LStream& inOutputStream) { ValidateList(); UInt16 numThingys = GetCount(); inOutputStream << numThingys; // write the object count for (long i = 1; i <= numThingys; i++) { // now write that many objects ThingyRef* aRefP = (ThingyRef*) GetItemPtr(i); DEBUG_OUT(" |-- "<<(*aRefP), DEBUG_TRIVIA | DEBUG_CONTAINMENT ); inOutputStream << (*aRefP); } }
AGalacticThingy* CThingyList::FetchThingyAt(ArrayIndexT inAtIndex) const { if (!ValidIndex(inAtIndex)) { DEBUG_OUT("WARNING: ThingyList index out of range: "<<inAtIndex, DEBUG_IMPORTANT | DEBUG_CONTAINMENT ); return NULL; } ThingyRef* aRefP = (ThingyRef*) GetItemPtr(inAtIndex); AGalacticThingy* aThingy = aRefP->GetThingy(); aThingy = ValidateThingy(aThingy); #ifdef DEBUG if (aThingy == NULL) { DEBUG_OUT("ThingyList has invalid reference at index "<<inAtIndex << " to id "<<aRefP->GetThingyID()<<"; Not Removed", DEBUG_ERROR | DEBUG_CONTAINMENT ); } #endif return aThingy; }
void CThingyList::ValidateList() { UInt32 numThingys = GetCount(); for (int i = numThingys; i > 0; i--) { // start at the end so we can safely remove items ThingyRef* aRefP = (ThingyRef*) GetItemPtr(i); AGalacticThingy* aThingy = aRefP->GetThingy(); aThingy = ValidateThingy(aThingy); if (aThingy == NULL) { DEBUG_OUT("ThingyList has invalid reference at index "<<i << " to id "<<aRefP->GetThingyID()<<"; Removed", DEBUG_ERROR | DEBUG_CONTAINMENT ); RemoveItemsAt(1, i); } else if (mIsShipsOnly) { if ( ! ValidateShip(aThingy) ) { DEBUG_OUT("Ship Only ThingyList has reference at index "<<i << " to non-ship item "<<aThingy<<"; Removed", DEBUG_ERROR | DEBUG_CONTAINMENT ); RemoveItemsAt(1, i); } } } }
/** \param data_type If this parameter is not equal to \e DataType_Invalid , this function will check to ensure that any instruction context item field located has the same data type. */ const InsItem &InsContext::GetItemRef(const InsItem &parent_ref, unsigned int auxiliary_id, const std::string &field_name, DataType data_type) const { return(*GetItemPtr(parent_ref, auxiliary_id, field_name, data_type, true)); }
// //////////////////////////////////////////////////////////////////////////// const InsItem *InsContext::GetItemPtr(const std::string &template_name, const std::string &field_name) const { return(GetItemPtr(ins_item_list_[GetTemplateIndex(template_name)], field_name)); }
// //////////////////////////////////////////////////////////////////////////// const InsItem *InsContext::GetItemPtr(unsigned int template_id, const std::string &field_name) const { return(GetItemPtr(ins_item_list_[GetTemplateIndex(template_id)], field_name)); }
// //////////////////////////////////////////////////////////////////////////// const InsItem *InsContext::GetItemPtr(const std::string &template_name, unsigned int auxiliary_id) const { return(GetItemPtr(ins_item_list_[GetTemplateIndex(template_name)], auxiliary_id)); }
// //////////////////////////////////////////////////////////////////////////// const InsItem *InsContext::GetItemPtr(unsigned int template_id, unsigned int auxiliary_id) const { return(GetItemPtr(ins_item_list_[GetTemplateIndex(template_id)], auxiliary_id)); }