From 8cce374cc8184c3a27e48df9da1eb48e8c84e4c6 Mon Sep 17 00:00:00 2001 From: Insektaure <41437620+Insektaure@users.noreply.github.com> Date: Mon, 3 Jun 2024 18:35:39 +0200 Subject: [PATCH] feat: add empty monotype (Salty) model & dynamic recipe view --- source/models/monotypeSalty.hpp | 253 ++++++++++++++++++++++++++++++ source/views/recipe-view.hpp | 27 ++-- source/views/sv/monotype-view.hpp | 39 ++--- 3 files changed, 289 insertions(+), 30 deletions(-) create mode 100644 source/models/monotypeSalty.hpp diff --git a/source/models/monotypeSalty.hpp b/source/models/monotypeSalty.hpp new file mode 100644 index 0000000..df2eed3 --- /dev/null +++ b/source/models/monotypeSalty.hpp @@ -0,0 +1,253 @@ +#pragma once + +#include +#include + +struct RecipeItems { + std::string name; + int quantity; +}; + +struct RecipeBonus { + std::string name; + int level; +}; + +struct Recipe { + std::vector items; + std::vector bonuses; +}; + +Recipe Normal = { + { + {"Tofu", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Fire = { + { + {"Red Pepper", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Water = { + { + {"Cucumber", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Electric = { + { + {"Yellow Pepper", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Grass = { + { + {"Lettuce", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Ice = { + { + {"Klawf Stick", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Fighting = { + { + {"Pickle", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Poison = { + { + {"Green Pepper", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Ground = { + { + {"Ham", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Flying = { + { + {"Prosciutto", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Psychic = { + { + {"Onion", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Bug = { + { + {"Cherry Tomato", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Rock = { + { + {"Bacon", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Ghost = { + { + {"Red Onion", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Dragon = { + { + {"Avocado", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Dark = { + { + {"Smoked Fillet", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Steel = { + { + {"Hamburger", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; + +Recipe Fairy = { + { + {"Tomato", 1}, + {"Salty Herba Mystica", 1}, + {"Sweet Herba Mystica", 1} + }, + { + {"Sparkling Power", 3}, + {"Title Power", 3}, + {"Encounter Power", 3} + } +}; \ No newline at end of file diff --git a/source/views/recipe-view.hpp b/source/views/recipe-view.hpp index ef050f3..a5b7910 100644 --- a/source/views/recipe-view.hpp +++ b/source/views/recipe-view.hpp @@ -1,26 +1,30 @@ #pragma once #include "../components/button.hpp" +#include "../models/monotypeSalty.hpp" #include #include class RecipeView : public tsl::Gui { - public: - RecipeView(const std::string &type) : type(type) { } + RecipeView(const std::string &type, const Recipe& recipe) : type(type), recipe(recipe) { } ~RecipeView() {}; virtual tsl::elm::Element *createUI() override { auto frame = new tsl::elm::OverlayFrame("Recipe", type); auto list = new tsl::elm::List(); - + // Display RecipeItems list->addItem(new tsl::elm::CategoryHeader("Ingredients")); + for (RecipeItems& item : recipe.items) { + list->addItem(new tsl::elm::ListItem(std::to_string(item.quantity) + "x " + item.name)); + } - /*for (Ingredient& ingredient : serving.ingredients) { - list->addItem(new tsl::elm::ListItem(std::to_string(ingredient.quantity.quantity) + "x " + ingredient.name)); - //std::cout << "Ingredient: " << ingredient.name << ", Quantity: " << ingredient.quantity.quantity << std::endl; - }*/ + // Display RecipeBonus + list->addItem(new tsl::elm::CategoryHeader("Bonuses")); + for (RecipeBonus& bonus : recipe.bonuses) { + list->addItem(new tsl::elm::ListItem(bonus.name + " Lvl " + std::to_string(bonus.level))); + } frame->setContent(list); @@ -29,16 +33,17 @@ class RecipeView : public tsl::Gui { private: std::string type; + Recipe recipe; }; - class RecipeViewButton : public Button { public: - RecipeViewButton(const std::string &text, const std::string &type) - : Button(text), type(type) { - this->onClick([this]() { tsl::changeTo(this->type); }); + RecipeViewButton(const std::string &text, const std::string &type, const Recipe& recipe) + : Button(text), type(type), recipe(recipe) { + this->onClick([this]() { tsl::changeTo(this->type, this->recipe); }); } private: std::string type; + Recipe recipe; }; \ No newline at end of file diff --git a/source/views/sv/monotype-view.hpp b/source/views/sv/monotype-view.hpp index 4587f03..b16ddef 100644 --- a/source/views/sv/monotype-view.hpp +++ b/source/views/sv/monotype-view.hpp @@ -1,6 +1,7 @@ #pragma once #include "../../components/button.hpp" +#include "../../models/monotypeSalty.hpp" #include "../recipe-view.hpp" #include @@ -9,28 +10,28 @@ class MonotypeView : public tsl::Gui { MonotypeView() { } virtual tsl::elm::Element *createUI() override { - auto frame = new tsl::elm::OverlayFrame("Monotype (Salty HM)", " "); + auto frame = new tsl::elm::OverlayFrame("Monotype (Salty)", " "); auto list = new tsl::elm::List(); list->addItem(new tsl::elm::CategoryHeader("Type")); - list->addItem(new RecipeViewButton("Bug", "Bug")); - list->addItem(new RecipeViewButton("Dark", "Dark")); - list->addItem(new RecipeViewButton("Dragon", "Dragon")); - list->addItem(new RecipeViewButton("Electric", "Electric")); - list->addItem(new RecipeViewButton("Fairy", "Fairy")); - list->addItem(new RecipeViewButton("Fighting", "Fighting")); - list->addItem(new RecipeViewButton("Fire", "Fire")); - list->addItem(new RecipeViewButton("Flying", "Flying")); - list->addItem(new RecipeViewButton("Ghost", "Ghost")); - list->addItem(new RecipeViewButton("Grass", "Grass")); - list->addItem(new RecipeViewButton("Ground", "Ground")); - list->addItem(new RecipeViewButton("Ice", "Ice")); - list->addItem(new RecipeViewButton("Normal", "Normal")); - list->addItem(new RecipeViewButton("Psychic", "Psychic")); - list->addItem(new RecipeViewButton("Rock", "Rock")); - list->addItem(new RecipeViewButton("Steel", "Steel")); - list->addItem(new RecipeViewButton("Water", "Water")); + list->addItem(new RecipeViewButton("Bug", "Bug", Bug)); + list->addItem(new RecipeViewButton("Dark", "Dark", Dark)); + list->addItem(new RecipeViewButton("Dragon", "Dragon", Dragon)); + list->addItem(new RecipeViewButton("Electric", "Electric", Electric)); + list->addItem(new RecipeViewButton("Fairy", "Fairy", Fairy)); + list->addItem(new RecipeViewButton("Fighting", "Fighting", Fighting)); + list->addItem(new RecipeViewButton("Fire", "Fire", Fire)); + list->addItem(new RecipeViewButton("Flying", "Flying", Flying)); + list->addItem(new RecipeViewButton("Ghost", "Ghost", Ghost)); + list->addItem(new RecipeViewButton("Grass", "Grass", Grass)); + list->addItem(new RecipeViewButton("Ground", "Ground", Ground)); + list->addItem(new RecipeViewButton("Ice", "Ice", Ice)); + list->addItem(new RecipeViewButton("Normal", "Normal", Normal)); + list->addItem(new RecipeViewButton("Psychic", "Psychic", Psychic)); + list->addItem(new RecipeViewButton("Rock", "Rock", Rock)); + list->addItem(new RecipeViewButton("Steel", "Steel", Steel)); + list->addItem(new RecipeViewButton("Water", "Water", Water)); frame->setContent(list); @@ -41,5 +42,5 @@ class MonotypeView : public tsl::Gui { class MonotypeViewButton : public Button { public: - MonotypeViewButton() : Button("Monotype (Salty HM)") { this->onClick(tsl::changeTo); } + MonotypeViewButton() : Button("Monotype (Salty)") { this->onClick(tsl::changeTo); } }; \ No newline at end of file