void Gui::regenWeaponsMenu() { if (_engine->_world->_weaponMenuDisabled) return; _menu->clearSubMenu(_weaponsMenuId); Chr *player = _engine->_world->_player; ObjArray *weapons = player->getWeapons(true); bool empty = true; for (uint i = 0; i < weapons->size(); i++) { Obj *obj = (*weapons)[i]; if (obj->_type == Obj::REGULAR_WEAPON || obj->_type == Obj::THROW_WEAPON || obj->_type == Obj::MAGICAL_OBJECT) { Common::String command(obj->_operativeVerb); command += " "; command += obj->_name; _menu->addMenuSubItem(_weaponsMenuId, command.c_str(), kMenuActionCommand, 0, 0, true); empty = false; } } delete weapons; if (empty) _menu->addMenuSubItem(_weaponsMenuId, "You have no weapons", 0, 0, 0, false); }
Chr* ChrsGrid::createAChr(int x, int y) { //1.根据布局坐标创建一个汉字元素,汉字内容根据汉字集合随机获得 //2.设置该汉字元素的世界坐标 //3.将该汉字加入渲染节点 Chr* chr = nullptr; int i = random(0, (int)m_Chrs.size()-1); auto s = m_Chrs.at(i); chr = Chr::createWithString(s, x, y); chr->setPosition(x * GRID_WIDTH + CHR_WITDH / 2 + 5, y * GRID_WIDTH + CHR_WITDH / 2 + 5); addChild(chr); //log("add a chr!---content:%s---x:%d---y:%d", chr->getString().getCString(), x, y); return chr; }
void Menu::createWeaponsMenu(MenuItem *menu) { Chr *player = _gui->_engine->_world->_player; ObjArray *weapons = player->getWeapons(true); for (uint i = 0; i < weapons->size(); i++) { Obj *obj = (*weapons)[i]; if (obj->_type == Obj::REGULAR_WEAPON || obj->_type == Obj::THROW_WEAPON || obj->_type == Obj::MAGICAL_OBJECT) { Common::String command(obj->_operativeVerb); command += " "; command += obj->_name; menu->subitems.push_back(new MenuSubItem(command.c_str(), kMenuActionCommand, 0, 0, true)); } } delete weapons; if (menu->subitems.empty()) menu->subitems.push_back(new MenuSubItem("You have no weapons", 0, 0, 0, false)); }