KBOOL Kylin::Kitbag::AddItem( ItemCell* pItem ) { if (m_kItemArray.size() >= m_uUpperLimit) { SAFE_DEL(pItem); return false; } if (pItem->GetStorageType() == ItemCell::ST_ALONE) m_kItemArray.push_back(pItem); else { KINT n = HasItem(pItem->GetGID()); if (n != -1) { m_kItemArray[n]->m_nCount++; } else { m_kItemArray.push_back(pItem); } } return true; }
void CodeBrowser::Load() { String find = ToUpper((String)~search); String match = ToUpper((String)~search_scope); String pm = GetPm(); Vector<String> txt; Vector<Value> ndx; Index<int> fi; Index<String> fs; for(int i = 0; i < CodeBase().GetCount(); i++) { String s = CodeBase().GetKey(i); const Array<CppItem>& n = CodeBase()[i]; if(s.GetCount()) if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find)) && MatchPm(n, pm)) { txt.Add(s); ndx.Add(s); } for(int i = 0; i < n.GetCount(); i++) { int f = n[i].file; if(fi.Find(f) < 0) { String s = GetFileText(GetSourceFilePath(f)); if(s.StartsWith(pm) && MatchCib(s, match) && (IsNull(find) || MatchCib(s, find) || n[i].uname.StartsWith(find))) { txt.Add(s); ndx.Add(f); fs.Add(s); fi.Add(f); } } } } const Workspace& wspc = GetIdeWorkspace(); for(int i = 0; i < wspc.GetCount(); i++) { String pn = wspc[i]; const Package& p = wspc.GetPackage(i); String pp = PackageDirectory(pn); for(int j = 0; j < p.GetCount(); j++) if(!p[j].separator) { String fn = AppendFileName(pp, p[j]); String s = GetFileText(AppendFileName(pn, p[j])); if(fs.Find(s) < 0 && (IsNull(find) || MatchCib(s, find)) && MatchCib(s, match) && MatchPm(fn, pm)) { int f = GetSourceFileIndex(SourcePath(pn, p[j])); txt.Add(s); ndx.Add(f); fs.Add(s); } } } IndexSort(txt, ndx, ScopeLess()); Value key = scope.GetKey(); int sc = scope.GetCursorSc(); scope.Clear(); for(int i = 0; i < txt.GetCount(); i++) scope.Add(IsString(ndx[i]) ? ndx[i] : Null, txt[i], ndx[i]); if(scope.FindSetCursor(key)) scope.ScCursor(sc); // clear.Enable(IsSearch()); }
void MainWindow::AddItem(RosterItem* item) { // Don't add offline items and avoid duplicates if ((item->Status() == CAYA_OFFLINE) && CayaPreferences::Item()->HideOffline) return; if (HasItem(item)) return; // Add item and sort fListView->AddItem(item); fListView->Sort(); }
IUnknown* CHXRingBuffer::RemoveAt(UINT32 pos) { HX_ASSERT_VALID_PTR(this); HX_ASSERT(m_ppunkData != NULL && m_ulCount > 0 && HasItem(pos)); if (!m_ulCount) { return NULL; } IUnknown* punkItem = m_ppunkData[pos]; // Optimized for LIFO and FIFO if (pos == m_ulHead) { m_ppunkData[m_ulHead] = NULL; m_ulHead = (m_ulHead + 1 == m_ulAlloc) ? 0 : m_ulHead+1; m_ulCount--; } else { UINT32 ulNewTail = m_ulTail ? m_ulTail-1 : m_ulAlloc - 1; if (pos < ulNewTail) { memmove(m_ppunkData+(pos), m_ppunkData+(pos+1), (ulNewTail-pos) * sizeof(IUnknown*)); } else if (pos != ulNewTail) { memmove(m_ppunkData+(pos), m_ppunkData+(pos+1), (m_ulAlloc-pos-1) * sizeof(IUnknown*)); m_ppunkData[m_ulAlloc-1] = m_ppunkData[0]; memmove(m_ppunkData, m_ppunkData+1, (ulNewTail) * sizeof(IUnknown*)); } m_ulTail = ulNewTail; m_ppunkData[m_ulTail] = NULL; m_ulCount--; } return punkItem; }
static void Say_Team_Best_Weapons( edict_t *who, char *buf, int buflen, const char *current_color ) { char weapon_strings[2][20]; int weap, printed = 0; for( weap = WEAP_TOTAL-1; weap > WEAP_GUNBLADE; weap-- ) { // evil hack to make RL more important than PG if( weap == WEAP_PLASMAGUN ) weap = WEAP_ROCKETLAUNCHER; else if( weap == WEAP_ROCKETLAUNCHER ) weap = WEAP_PLASMAGUN; if( HasItem( who, weap ) ) { WeaponString( who, weap, weapon_strings[printed], sizeof( weapon_strings[printed] ), current_color ); if( ++printed == 2 ) break; } if( weap == WEAP_PLASMAGUN ) weap = WEAP_ROCKETLAUNCHER; else if( weap == WEAP_ROCKETLAUNCHER ) weap = WEAP_PLASMAGUN; } if( printed == 2 ) { Q_snprintfz( buf, buflen, "%s%s %s%s", weapon_strings[1], current_color, weapon_strings[0], current_color ); } else if( printed == 1 ) { Q_snprintfz( buf, buflen, "%s%s", weapon_strings[0], current_color ); } else { WeaponString( who, WEAP_GUNBLADE, buf, buflen, current_color ); Q_strncatz( buf, current_color, buflen ); } }
void VisGenDlg::Refresh() { String s; int q = ~type; bool b = q >= 3 && q <= 4; pars.Enable(b); brackets.Enable(b); label1.Enable(b); toupper1.Enable(b); tolower1.Enable(b); initcaps1.Enable(b); name1.Enable(b); dname1.Enable(b); quotes1.Enable(b && !label1); b = q == 4; label2.Enable(b); toupper2.Enable(b); tolower2.Enable(b); initcaps2.Enable(b); name2.Enable(b); dname2.Enable(b); quotes2.Enable(b && !label2); String oce = "\tCtrlLayout"; bool ok = false; if(HasItem("ok")) { ok = true; oce << "OK"; } if(HasItem("cancel")) oce << "Cancel"; if(HasItem("exit")) oce << "Exit"; String n = ~name; if(IsNull(n)) n = GetName(); String b1, b2, b3; if(buttons) { for(int i = 0; i < layout.item.GetCount(); i++) { String bn = layout.item[i].variable; if(layout.item[i].type == "Button" && findarg(bn, "cancel", "ok", "exit") < 0) { String mn = IdInitCaps(bn); mn.Replace("_", ""); if(b1.GetCount() == 0) b1 = b2 = "\n"; b1 << '\t' << "void " << mn << "();\n"; b2 << '\t' << bn << " << [=] { " << mn << "};\n"; b3 << '\n' << "void " << n << "::" << mn << "()\n{\n}\n"; } } } if(q == 0) { s << "class " << n << " : public With" << layout.name << "<TopWindow> {\n" << "\ttypedef " << n << " CLASSNAME;\n" << b1 << "\n" << "public:\n" << "\t" << n << "();\n" << "};\n" << "\n" << n << "::" << n << "()\n" << "{\n" << oce << "(*this, \"\");\n" << b2 << "}\n" << b3; } else if(q == 1) { s << "struct " << n << " : With" << layout.name << "<TopWindow> {\n" << "\ttypedef " << n << " CLASSNAME;\n" << b1 << "\t" << n << "();\n" << "};\n" << "\n" << n << "::" << n << "()\n" << "{\n" << oce << "(*this, \"\");\n" << b2 << "}\n" << b3; } else if(q == 2) { String n = ~name; if(IsNull(n)) n = "dlg"; s << "\tWith" << layout.name << "<TopWindow> " << n << ";\n" << oce << '(' << n << ", \"\");\n"; if(ok) s << "\tif(" << n << ".Execute() != IDOK)\n\t\treturn;\n"; else s << '\t' << n << ".Execute();\n"; } else for(int i = 0; i < sel.GetCount(); i++) { String id1 = layout.item[sel[i]].variable; String id2 = id1; int w = layout.item[sel[i]].FindProperty("SetLabel"); String lbl; if(w >= 0 && IsString(~layout.item[sel[i]].property[w])) lbl = AsCString(ToUtf8((WString)~layout.item[sel[i]].property[w])); if(q <= 4) { if(label1) id1 = lbl; if(label2) id2 = lbl; } if(IsNull(id1) && (q != 4 || IsNull(id2))) continue; if(q == 5) s << "\t" << id1 << " << [=] { };\n"; else if(q == 6) s << "\t" << IdInitCaps(id1) << "();\n"; else if(q == 7) s << "\t" << id1 << " << [=] { " << IdInitCaps(id1) << "(); };\n"; else { if((pars || brackets) && !(name1 || name2 || dname1 || dname2)) s << ~name; if(pars) s << '('; String ss; if(name1 && !IsNull(~name)) s << ~name << '.'; if(toupper1) ss << ToUpper(id1); else if(tolower1) ss << ToLower(id1); else if(initcaps1) ss << IdInitCaps(id1); else ss << id1; if(quotes1 && !label1) ss = AsCString(ss); if(dname1 && !IsNull(~name)) ss << '.' << ~name; if(brackets) s << '['; s << ss; if(brackets) s << ']'; if(q == 4) { s << ", "; String ss; if(name2 && !IsNull(~name)) ss << ~name << '.'; if(toupper2) ss << ToUpper(id2); if(tolower2) ss << ToLower(id2); else if(initcaps2) ss << IdInitCaps(id2); else ss << id2; if(quotes2 && !label2) ss = AsCString(ss); if(dname2 && !IsNull(~name)) ss << '.' << ~name; if(brackets) s << '['; s << ss; if(brackets) s << ']'; } if(pars) s << ')'; s << '\n'; } } view <<= s; }
void VisGenDlg::Refresh() { String s; int q = ~type; pars.Enable(q >= 2); toupper1.Enable(q >= 2); name1.Enable(q >= 2); quotes1.Enable(q >= 2); toupper2.Enable(q >= 3); name2.Enable(q >= 3); quotes2.Enable(q >= 3); String oce = "\tCtrlLayout"; bool ok = false; if(HasItem("ok")) { ok = true; oce << "OK"; } if(HasItem("cancel")) oce << "Cancel"; if(HasItem("exit")) oce << "Exit"; String n = ~name; if(IsNull(n)) n = GetName(); if(q == 0) { s << "class " << n << " : public With" << layout.name << "<TopWindow> {\n" << "\ttypedef " << n << " CLASSNAME;\n" << "\n" << "public:\n" << "\t" << n << "();\n" << "};\n" << "\n" << n << "::" << n << "()\n" << "{\n" << oce; s << "(*this, \"\");\n"; s << "}\n"; } else if(q == 1) { s << "struct " << n << " : With" << layout.name << "<TopWindow> {\n" << "\ttypedef " << n << " CLASSNAME;\n" << "\t" << n << "();\n" << "};\n" << "\n" << n << "::" << n << "()\n" << "{\n" << oce; s << "(*this, \"\");\n"; s << "}\n"; } else if(q == 2) { String n = ~name; if(IsNull(n)) n = "dlg"; s << "\tWith" << layout.name << "<TopWindow> " << n << ";\n" << oce << '(' << n << ", \"\");\n"; if(ok) s << "\tif(" << n << ".Execute() != IDOK)\n\t\treturn;\n"; else s << '\t' << n << ".Execute();\n"; } else for(int i = 0; i < sel.GetCount(); i++) { String id = layout.item[sel[i]].variable; if(!IsNull(id)) { if(pars) s << '('; String ss; if(name1 && !IsNull(~name)) ss << ~name << '.'; if(toupper1) ss << ToUpper(id); else ss << id; if(quotes1) ss = AsCString(ss); s << ss; if(q == 4) { s << ", "; String ss; if(name2 && !IsNull(~name)) ss << ~name << '.'; if(toupper2) ss << ToUpper(id); else ss << id; if(quotes2) ss = AsCString(ss); s << ss; } if(pars) s << ')'; s << '\n'; } } view <<= s; }
MenuScreen::ScreenType MenuScreen::Run(const ScreenType &OldScreen) { ItemSelected = 0; bool Paused = OldScreen == AirTrafficType; if (Paused && !HasItem("Continue")) { AddItemStart("Continue"); } sf::Texture PauseTex; if (Paused) { PauseTex.create(App.getSize().x, App.getSize().y); PauseTex.update(App); } sf::Sprite PauseSpr(PauseTex); while (1) { bool ItemPicked = false; sf::Event Event; while (App.pollEvent(Event)) { if (Event.type == sf::Event::Closed) { return ExitType; } else if (Event.type == sf::Event::KeyPressed) { if (Input) { switch (Event.key.code) { case sf::Keyboard::Return: { Input = false; if (ATS->SetupClient(UserText.getString())) { AddItemBefore("Disconnect", "Join game"); RemoveItem("Join game"); RemoveItem("Host server"); RemoveItem("New game"); return AirTrafficType; } break; } case sf::Keyboard::Escape: Input = false; break; case sf::Keyboard::BackSpace: { if (UserTypePos > 0) { sf::String Str = UserText.getString(); Str.erase(UserTypePos - 1); UserText.setString(Str); UserTypePos--; } break; } case sf::Keyboard::Left: if (UserTypePos > 0) { UserTypePos--; } break; case sf::Keyboard::Right: if (UserTypePos < UserText.getString().getSize()) { UserTypePos++; } default: break; } } else { switch (Event.key.code) { case sf::Keyboard::Return: { ItemPicked = true; break; } case sf::Keyboard::Escape: if (Paused) { return AirTrafficType; } break; case sf::Keyboard::Up: ItemSelected = (ItemSelected == 0 ? Items.size() : ItemSelected) - 1; break; case sf::Keyboard::Down: ++ItemSelected %= Items.size(); // magic break; default: break; } } } else if (Input && Event.type == sf::Event::TextEntered && iswprint(Event.text.unicode)) { sf::String Str = UserText.getString(); Str.insert(UserTypePos, Event.text.unicode); UserText.setString(Str); UserTypePos++; } else if (Event.type == sf::Event::MouseMoved || Event.type == sf::Event::MouseButtonPressed) { for (unsigned int i = 0; i < Items.size(); i++) { ItemText.setPosition(100.f, 220.f + i * 70.f); ItemText.setString(Items[i]); sf::Vector2f MousePos; if (Event.type == sf::Event::MouseMoved) { MousePos = sf::Vector2f(Event.mouseMove.x, Event.mouseMove.y); } else if (Event.type == sf::Event::MouseButtonPressed) { MousePos = sf::Vector2f(Event.mouseButton.x, Event.mouseButton.y); } if (ItemText.getGlobalBounds().contains(MousePos)) { ItemSelected = i; if (Event.type == sf::Event::MouseButtonPressed) { ItemPicked = true; } break; } } } } if (!ATS->IsNetActive() && HasItem("Disconnect")) { ItemPicked = true; ItemSelected = find(Items.begin(), Items.end(), "Disconnect") - Items.begin(); } if (ItemPicked) { string Selected = Items[ItemSelected]; if (Selected == "Continue") { return AirTrafficType; } else if (Selected == "New game") { ATS->Reset(); return AirTrafficType; } else if (Selected == "Join game") { Input = true; QuestionText.setString("Host: "); UserText.setString(""); UserTypePos = 0; } else if (Selected == "Host server") { if (ATS->SetupServer()) { AddItemBefore("Disconnect", "Join game"); RemoveItem("Join game"); RemoveItem("Host server"); return AirTrafficType; } } else if (Selected == "Disconnect") { if (!HasItem("New game")) AddItemAfter("New game", "Continue"); AddItemAfter("Join game", "Disconnect"); AddItemAfter("Host server", "Join game"); RemoveItem("Disconnect"); ItemSelected = 0; ATS->KillNet(); } else if (Selected == "Exit") { return ExitType; } } ATS->StepNet(); App.clear(); if (Paused) { ATS->Draw(); } else { for (unsigned int y = 0; y < App.getSize().y; y += GrassTex.getSize().y) { for (unsigned int x = 0; x < App.getSize().x; x += GrassTex.getSize().x) { GrassSpr.setPosition(x, y); App.draw(GrassSpr); } } } App.draw(FadeSpr); App.draw(TitleText); if (Input) { App.draw(QuestionText); App.draw(UserText); CaretText.setPosition(UserText.findCharacterPos(UserTypePos) + sf::Vector2f(-8.f, 2.f)); App.draw(CaretText); } else { for (unsigned int i = 0; i < Items.size(); i++) { ItemText.setPosition(100.f, 220.f + i * 70.f); ItemText.setString(Items[i]); ItemText.setColor(i == ItemSelected ? SelectionColor : sf::Color::White); App.draw(ItemText); } Cursor.setPosition(65.f, 220.f + ItemSelected * 70.f); App.draw(Cursor); } App.display(); } }
bool CProject::HasItem(int group_type, const char* item) const { return HasItem(GetGroupDirectory(group_type), item); }
bool CLoot::HasItemByName(const char *pName) { int pEntity = g_pInGameRules->Inventory_GetItemID(pName); return HasItem(pEntity); }
void MainWindow::ImMessage(BMessage* msg) { int32 im_what = msg->FindInt32("im_what"); switch (im_what) { case IM_OWN_CONTACT_INFO: fStatusView->SetName(msg->FindString("name")); break; case IM_OWN_AVATAR_SET: { entry_ref ref; if (msg->FindRef("ref", &ref) == B_OK) { BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref); fStatusView->SetAvatarIcon(bitmap); } break; } case IM_STATUS_SET: { int32 status; if (msg->FindInt32("status", &status) != B_OK) return; RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id")); if (rosterItem) { UpdateListItem(rosterItem); // Add or remove item switch (status) { /*case CAYA_OFFLINE: // By default offline contacts are hidden if (!CayaPreferences::Item()->HideOffline) break; if (HasItem(rosterItem)) RemoveItem(rosterItem); return;*/ default: // Add item because it has a non-offline status if (!HasItem(rosterItem)) AddItem(rosterItem); break; } UpdateListItem(rosterItem); // Sort list view again fListView->Sort(); // Check if the user want the notification if (!CayaPreferences::Item()->NotifyContactStatus) break; switch (status) { case CAYA_ONLINE: case CAYA_OFFLINE: // Notify when contact is online or offline if (status == CAYA_ONLINE) { BString message; message << rosterItem->GetContactLinker()->GetName(); if (status == CAYA_ONLINE) message << " is available!"; else message << " is offline!"; BNotification notification(B_INFORMATION_NOTIFICATION); notification.SetGroup(BString("Caya")); notification.SetTitle(BString("Presence")); notification.SetIcon(rosterItem->Bitmap()); notification.SetContent(message); notification.Send(); } break; default: break; } } break; } case IM_AVATAR_SET: case IM_CONTACT_INFO: case IM_EXTENDED_CONTACT_INFO: { RosterItem* rosterItem = fServer->RosterItemForId(msg->FindString("id")); if (rosterItem) UpdateListItem(rosterItem); break; } } }
bool ColumnListView::AddItemPrivate(CLVListItem* item, int32 fullListIndex) { item->_selectedColumn = _selectedColumn; if(fHierarchical) { uint32 ItemLevel = item->OutlineLevel(); //Figure out whether it is visible (should it be added to visible list) bool Visible = true; //Find the item that contains it in the full list int32 SuperItemPos; if(ItemLevel == 0) SuperItemPos = -1; else SuperItemPos = fullListIndex - 1; CLVListItem* SuperItem; while(SuperItemPos >= 0) { SuperItem = (CLVListItem*)fFullItemList.ItemAt(SuperItemPos); if(SuperItem) { if(SuperItem->fOutlineLevel >= ItemLevel) SuperItemPos--; else break; } else return false; } if(SuperItemPos >= 0 && SuperItem) { if(!SuperItem->IsExpanded()) //SuperItem's contents aren't visible Visible = false; if(!HasItem(SuperItem)) //SuperItem itself isn't showing Visible = false; } //Add the item to the full list if(!fFullItemList.AddItem(item,fullListIndex)) return false; else { //Add the item to the display list if(Visible) { //Find the previous item, or -1 if the item I'm adding will be the first one int32 PreviousItemPos = fullListIndex - 1; CLVListItem* PreviousItem; while(PreviousItemPos >= 0) { PreviousItem = (CLVListItem*)fFullItemList.ItemAt(PreviousItemPos); if(PreviousItem && HasItem(PreviousItem)) break; else PreviousItemPos--; } //Add the item after the previous item, or first on the list bool Result; if(PreviousItemPos >= 0) Result = BListView::AddItem((BListItem*)item,IndexOf(PreviousItem)+1); else Result = BListView::AddItem((BListItem*)item,0); if(Result == false) fFullItemList.RemoveItem(item); return Result; } return true; } } else return BListView::AddItem(item,fullListIndex); }
BOOL DynamicObject::HasOwnItem(uint32 index) { return HasItem(index); }