void LuckyCrafting::initRecipes(Recipes* instance) { _Instance = instance; pushIngredient(41, 0, 'g'); pushIngredient(158, 0, 'd'); addRecipe(LuckyBlocks::luckyBlock->blockId, 1, {"ggg", "gdg", "ggg"}); pushIngredient(4, 0, 's'); pushIngredient(331, 0, 'r'); addRecipe(158, 1, {"sss", "s s", "srs"}); }
ShoppingListDialog::ShoppingListDialog( QWidget *parent, RecipeDB *db ) : QWidget( parent ) { // Store pointer to database database = db; // Design dialog layout = new QGridLayout( this ); layout->cellRect( 2, 2 ); m_sourceListWidget = new KreRecipesListWidget( this, database ); m_sourceListWidget->setListTitle( i18nc( "@title", "Full recipe list" ) ); layout->addWidget( m_sourceListWidget, 0, 0 ); QVBoxLayout* vboxl = new QVBoxLayout(); vboxl->addStretch(); addRecipeButton = new KPushButton( this ); addRecipeButton->setIcon( KIcon( "arrow-right" ) ); vboxl->addWidget( addRecipeButton ); removeRecipeButton = new KPushButton( this ); removeRecipeButton->setIcon( KIcon( "arrow-left" ) ); vboxl->addWidget( removeRecipeButton ); vboxl->addStretch(); layout->addLayout( vboxl, 0, 1 ); m_destListwidget = new KreSearchResultListWidget( this, database ); m_destListwidget->setListTitle( i18nc("@title", "Shopping List") ); layout->addWidget( m_destListwidget, 0, 2 ); buttonBar = new KHBox( this ); layout->addWidget( buttonBar, 1, 1, 1, 2, 0 ); layout->setColumnStretch( 0, 1 ); layout->setColumnStretch( 1, 0 ); layout->setColumnStretch( 2, 1 ); okButton = new KPushButton( buttonBar ); okButton->setObjectName( "okButton" ); okButton->setText( i18nc( "@action:button", "&OK" ) ); okButton->setIcon( KIcon( "dialog-ok" ) ); //buttonBar->layout()->addItem( new QSpacerItem( 10,10, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); clearButton = new KPushButton( buttonBar ); clearButton->setObjectName( "clearButton" ); clearButton->setText( i18nc( "@action:button Clear list", "Clear" ) ); clearButton->setIcon( KIcon( "edit-clear" ) ); // Connect signals & slots connect( addRecipeButton, SIGNAL( clicked() ), this, SLOT( addRecipe() ) ); connect( removeRecipeButton, SIGNAL( clicked() ), this, SLOT( removeRecipe() ) ); connect( okButton, SIGNAL( clicked() ), this, SLOT( showShoppingList() ) ); connect( clearButton, SIGNAL( clicked() ), this, SLOT( clear() ) ); }
void UCraftingSystemComponent::BeginPlay() { TArray<FCraftingTableRow*> rows; static const FString ContextString(TEXT("GENERAL")); if (!recipeList) return; recipeList->GetAllRows<FCraftingTableRow>(ContextString,rows); for (int32 i = 0; i < recipes.Num(); i++) { URecipe* newRecipe = NewObject<URecipe>(NULL, URecipe::StaticClass()); newRecipe->displayName = rows[i]->displayName; newRecipe->identifierName = rows[i]->identifierName; newRecipe->requiredItems = rows[i]->requiredItems; newRecipe->finalProduct = rows[i]->finalProduct; newRecipe->ammount = rows[i]->ammount; addRecipe(newRecipe); } }
category_t *sortRecipe(category_t *category, int size) { int i; recipe_t *current = category->head, *temp = current; if(size < 1) return category; for(i = 0; i < size; i++) { if(strcmp(current->title, temp->title) > 0) temp = current; if(current->next != NULL) current = current->next; } if(strcmp(current->title, temp->title) > 0) temp = current; if(strcmp(temp->title, current->title) != 0) { temp = removeRecipe(category, temp->title); addRecipe(current, temp); } return sortRecipe(category, size-1); }
bool Inventory::readRecipe(std::string recipeFile) { std::ifstream ifs(recipeFile.c_str()); if (ifs.fail()) { LOG(WARNING, "Inventory", "Could not find: " + recipeFile); ifs.close(); return false; } //LOG(INFO, "Inventory", "Reading: " + recipeFile); std::string temp; int height = 0, width = 0, outCount = 0; int16_t outType = 0, outHealth = 0; // Reading row at a time int del; bool readingRecipe = false; std::vector<std::string> line; std::vector<int16_t> recipetable; std::string text; while(getline(ifs, temp)) { //If empty line if(temp.size() == 0) continue; // If commentline -> skip to next if(temp[0] == COMMENTPREFIX) continue; // Init vars del = 0; line.clear(); // Process line while(temp.length() > 0) { // Remove white spaces while(temp[0] == ' ') temp = temp.substr(1); // Split words del = temp.find(' '); if(del > -1) { line.push_back(temp.substr(0, del)); temp = temp.substr(del+1); } else { line.push_back(temp); break; } } // Begin recipe if(line.size() == 1 && line[0] == "<-") { readingRecipe = true; continue; } // Begin recipe if(line.size() == 1 && line[0] == "->") { readingRecipe = false; continue; } if(readingRecipe) { for(unsigned int i = 0; i < line.size(); i++) { recipetable.push_back(atoi(line[i].c_str())); } continue; } else { // Keywords if (line[0] == "width") { width = atoi(line[1].c_str()); } if (line[0] == "height") { height = atoi(line[1].c_str()); } if (line[0] == "outputcount") { outCount = atoi(line[1].c_str()); } if (line[0] == "outputtype") { outType = atoi(line[1].c_str()); } if (line[0] == "outputhealth") { outHealth = atoi(line[1].c_str()); } } } ifs.close(); int16_t* inrecipe = new int16_t[height*width]; for (unsigned int i = 0; i < recipetable.size(); i++) { inrecipe[i] = recipetable[i]; } addRecipe(width, height, inrecipe, outCount, outType, outHealth); delete [] inrecipe; return true; }
bool Inventory::readRecipe(const std::string& recipeFile) { std::ifstream ifs(recipeFile.c_str()); if (ifs.fail()) { LOG2(ERROR, "Could not find: " + recipeFile); ifs.close(); return false; } //LOG(INFO, "Inventory", "Reading: " + recipeFile); std::string temp; int height = 0, width = 0, outCount = 0; int16_t outType = 0, outHealth = 0; // Reading row at a time int del; bool readingRecipe = false; std::vector<std::string> line; std::vector<ItemPtr> recipetable; std::string text; while (getline(ifs, temp)) { //If empty line if (temp.empty()) { continue; } // If commentline -> skip to next if (temp[0] == COMMENTPREFIX) { continue; } // Init vars del = 0; line.clear(); // Process line while (!temp.empty()) { // Remove white spaces while (temp[0] == ' ') { temp = temp.substr(1); } // Split words del = temp.find(' '); if (del > -1) { line.push_back(temp.substr(0, del)); temp = temp.substr(del + 1); } else { line.push_back(temp); break; } } // Begin recipe if (line.size() == 1 && line[0] == "<-") { readingRecipe = true; continue; } // Begin recipe if (line.size() == 1 && line[0] == "->") { readingRecipe = false; continue; } if (readingRecipe) { for (unsigned int i = 0; i < line.size(); i++) { std::string data(line[i]); ItemPtr item(new Item); item->setCount(1); item->setHealth(-1); int location = data.find("x"); if (location > -1) { // Quantity before ID item->setCount(atoi(data.substr(0, location).c_str())); data = data.substr(location + 1, std::string::npos); } location = data.find(":"); if (location > -1) { // Meta after ID item->setHealth(atoi(data.substr(location + 1, std::string::npos).c_str())); data = data.substr(0, location); } item->setType(atoi(data.c_str())); recipetable.push_back(item); } continue; } else { // Keywords if (line[0] == "width") { width = atoi(line[1].c_str()); } if (line[0] == "height") { height = atoi(line[1].c_str()); } if (line[0] == "outputcount") { outCount = atoi(line[1].c_str()); } if (line[0] == "outputtype") { outType = atoi(line[1].c_str()); } if (line[0] == "outputhealth") { outHealth = atoi(line[1].c_str()); } } } ifs.close(); addRecipe(width, height, recipetable, outCount, outType, outHealth); return true; }