From dcca6a8e871b75b6ed5f3eee3c2526bd1a7d56fa Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 5 Oct 2018 19:26:33 -0400 Subject: [PATCH] v0.7.0: significant layout improvements to new alchemy guide --- .../shatteredpixeldungeon/ui/QuickRecipe.java | 18 ++++++ .../windows/WndJournal.java | 64 ++++++++++++++----- .../messages/journal/journal.properties | 16 ++--- 3 files changed, 74 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickRecipe.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickRecipe.java index 022c8c62b..a9f6c15d5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickRecipe.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickRecipe.java @@ -45,6 +45,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfAq import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfDragonsBlood; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfHoneyedHealing; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfIcyTouch; +import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfMight; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfRestoration; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfToxicEssence; import com.shatteredpixel.shatteredpixeldungeon.items.potions.elixirs.ElixirOfVitality; @@ -146,6 +147,9 @@ public class QuickRecipe extends Component { ShatteredPixelDungeon.scene().addToFront(new WndInfoItem(output)); } }; + if (!hasInputs){ + this.output.icon.alpha(0.3f); + } this.output.showParams(true, false, true); add(this.output); @@ -302,9 +306,12 @@ public class QuickRecipe extends Component { result.add(new QuickRecipe( new StewedMeat.twoMeat() )); result.add(new QuickRecipe( new StewedMeat.threeMeat() )); result.add(null); + result.add(null); result.add(new QuickRecipe( new Feast.Recipe(), new ArrayList(Arrays.asList(new Pasty(), new Food(), new MysteryMeat.PlaceHolder())), new Feast())); + result.add(null); + result.add(null); result.add(new QuickRecipe( new Blandfruit.CookFruit(), new ArrayList<>(Arrays.asList(new Blandfruit(), new Plant.Seed.PlaceHolder())), new Blandfruit(){ @@ -320,11 +327,17 @@ public class QuickRecipe extends Component { return result; case 6: r = new Bomb.EnhanceBomb(); + int i = 0; for (Class cls : Bomb.EnhanceBomb.validIngredients.keySet()){ try{ + if (i == 2){ + result.add(null); + i = 0; + } Item item = (Item) cls.newInstance(); ArrayList in = new ArrayList(Arrays.asList(new Bomb(), item)); result.add(new QuickRecipe( r, in, r.sampleOutput(in))); + i++; } catch (Exception e){ ShatteredPixelDungeon.reportException(e); } @@ -336,6 +349,7 @@ public class QuickRecipe extends Component { result.add(new QuickRecipe(new FrostfireBrew.Recipe())); result.add(new QuickRecipe(new CausticBrew.Recipe())); result.add(null); + result.add(null); result.add(new QuickRecipe(new InfernalBrew.Recipe())); result.add(new QuickRecipe(new BlizzardBrew.Recipe())); result.add(new QuickRecipe(new ShockingBrew.Recipe())); @@ -346,19 +360,23 @@ public class QuickRecipe extends Component { result.add(new QuickRecipe(new ElixirOfHoneyedHealing.Recipe())); result.add(new QuickRecipe(new ElixirOfAquaticRejuvenation.Recipe())); result.add(null); + result.add(null); result.add(new QuickRecipe(new ElixirOfDragonsBlood.Recipe())); result.add(new QuickRecipe(new ElixirOfIcyTouch.Recipe())); result.add(new QuickRecipe(new ElixirOfToxicEssence.Recipe())); + result.add(new QuickRecipe(new ElixirOfMight.Recipe())); return result; case 9: result.add(new QuickRecipe(new MagicalPorter.Recipe())); result.add(new QuickRecipe(new PhaseShift.Recipe())); result.add(new QuickRecipe(new BeaconOfReturning.Recipe())); result.add(null); + result.add(null); result.add(new QuickRecipe(new AquaBlast.Recipe())); result.add(new QuickRecipe(new FeatherFall.Recipe())); result.add(new QuickRecipe(new ReclaimTrap.Recipe())); result.add(null); + result.add(null); result.add(new QuickRecipe(new MagicalInfusion.Recipe())); result.add(new QuickRecipe(new CurseInfusion.Recipe())); result.add(new QuickRecipe(new Alchemize.Recipe())); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index 395353f0f..75c6d848b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -51,7 +51,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -//FIXME a lot of cleanup and improvements to do here public class WndJournal extends WndTabbed { private static final int WIDTH_P = 130; @@ -304,6 +303,7 @@ public class WndJournal extends WndTabbed { private IconTitle title; private RenderedTextMultiline body; + private ScrollPane list; private ArrayList recipes = new ArrayList<>(); @Override @@ -330,9 +330,11 @@ public class WndJournal extends WndTabbed { title = new IconTitle(); title.icon( new ItemSprite(ItemSpriteSheet.ALCH_PAGE)); title.visible = false; - add(title); + body = PixelScene.renderMultiline(6); - add(body); + + list = new ScrollPane(new Component()); + add(list); } @Override @@ -348,6 +350,9 @@ public class WndJournal extends WndTabbed { PixelScene.align(pageButtons[i]); } + list.setRect(0, pageButtons[NUM_BUTTONS-1].bottom() + 1, width, + height - pageButtons[NUM_BUTTONS-1].bottom() - 1); + updateList(); } @@ -365,14 +370,6 @@ public class WndJournal extends WndTabbed { return; } - title.visible = true; - title.label(Document.ALCHEMY_GUIDE.pageTitle(currentPageIdx)); - title.setRect(0, pageButtons[NUM_BUTTONS-1].bottom(), width(), 10); - - body.maxWidth((int)width()); - body.text(Document.ALCHEMY_GUIDE.pageBody(currentPageIdx)); - body.setPos(0, title.bottom()); - for (QuickRecipe r : recipes){ if (r != null) { r.killAndErase(); @@ -381,16 +378,30 @@ public class WndJournal extends WndTabbed { } recipes.clear(); + Component content = list.content(); + + content.clear(); + + title.visible = true; + title.label(Document.ALCHEMY_GUIDE.pageTitle(currentPageIdx)); + title.setRect(0, 0, width(), 10); + content.add(title); + + body.maxWidth((int)width()); + body.text(Document.ALCHEMY_GUIDE.pageBody(currentPageIdx)); + body.setPos(0, title.bottom()); + content.add(body); + ArrayList toAdd = QuickRecipe.getRecipes(currentPageIdx); float left; - float top = body.bottom() + 2; + float top = body.bottom(); int w; ArrayList toAddThisRow = new ArrayList<>(); while (!toAdd.isEmpty()){ - while (!toAdd.isEmpty() && toAdd.get(0) == null){ - top += 2; + if (toAdd.get(0) == null){ toAdd.remove(0); + top += 6; } w = 0; @@ -402,16 +413,37 @@ public class WndJournal extends WndTabbed { float spacing = (width() - w)/(toAddThisRow.size() + 1); left = spacing; - for (QuickRecipe r : toAddThisRow){ + while (!toAddThisRow.isEmpty()){ + QuickRecipe r = toAddThisRow.remove(0); r.setPos(left, top); left += r.width() + spacing; + if (!toAddThisRow.isEmpty()) { + ColorBlock spacer = new ColorBlock(1, 16, 0xFF222222); + spacer.y = top; + spacer.x = left - spacing / 2; + content.add(spacer); + } recipes.add(r); - add(r); + content.add(r); + } + + if (!toAdd.isEmpty() && toAdd.get(0) == null){ + toAdd.remove(0); + } + + if (!toAdd.isEmpty() && toAdd.get(0) != null) { + ColorBlock spacer = new ColorBlock(width(), 1, 0xFF222222); + spacer.y = top + 16; + spacer.x = 0; + content.add(spacer); } top += 17; toAddThisRow.clear(); } + content.setSize(width(), top); + list.setSize(list.width(), list.height()); + list.scrollTo(0, 0); } } diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/journal/journal.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/journal/journal.properties index c352aa2a6..5850b4911 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/journal/journal.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/journal/journal.properties @@ -22,21 +22,21 @@ journal.document.adventurers_guide.magic.body=Magical attacks cut right through journal.document.alchemy_guide.title=Alchemy Guide journal.document.alchemy_guide.potions.title=Creating Potions -journal.document.alchemy_guide.potions.body=Welcome to Practical Applications of Alchemy!\n\nThis book serves as a recipe reference for hobbyist alchemists and adventurers looking to get their hands dirty.\n\nWe will start with the most iconic alchemy recipe: Place any three seeds into an alchemy pot to brew a random potion!\n\nEvery seed has a potion counterpart. The potion you create may relate to one of the seeds used, and using multiple of the same seed will increase the chance for this to occur. +journal.document.alchemy_guide.potions.body=Welcome to Practical Applications of Alchemy!\n\nThis book serves as a recipe reference for hobbyist alchemists and adventurers looking to get their hands dirty.\n\nWe will start with the most iconic alchemy recipe: Place any three seeds into an alchemy pot to brew a random potion!\n\nEvery seed has a potion counterpart, and the potion you create may relate to one of the seeds used. Using multiple of the same seed will increase the chance for this to occur. journal.document.alchemy_guide.stones.title=Creating Runestones -journal.document.alchemy_guide.stones.body=Mixing a single scroll into an alchemy pot will imbue its magic into two or three rocks within the pot. This creates runestones that correspond to that scroll. +journal.document.alchemy_guide.stones.body=Mixing a scroll into an alchemy pot will imbue its magic into two or three rocks within the pot. This creates runestones! journal.document.alchemy_guide.darts.title=Tipping Darts -journal.document.alchemy_guide.darts.body=A single seed can be combined with one or two darts to tip them. Each type of seed produces its own type of tipped dart, with a unique single-use effect. +journal.document.alchemy_guide.darts.body=A seed can be combined with one or two darts to tip them. Each type of seed produces its own type of tipped dart, with a unique single-use effect. journal.document.alchemy_guide.exotic_potions.title=Exotic Potions -journal.document.alchemy_guide.exotic_potions.body=The power of a potion can be augmented with two seeds to create a new 'exotic' variant. They have more powerful effects, but are often useful in different ways as well. +journal.document.alchemy_guide.exotic_potions.body=Potions can be augmented with two seeds to create exotic potions. They have more powerful effects, but are often useful in different ways. journal.document.alchemy_guide.exotic_scrolls.title=Exotic Scrolls -journal.document.alchemy_guide.exotic_scrolls.body=Exotic scrolls can also be made with two runestones and a scroll. They're generally a bit stronger than exotic potions, but stones are also harder to come by. +journal.document.alchemy_guide.exotic_scrolls.body=Exotic scrolls can be made with two runestones and a scroll. They're a bit stronger than exotic potions, but stones are also harder to come by. journal.document.alchemy_guide.energy_food.title=Energy and Food -journal.document.alchemy_guide.energy_food.body=Some recipes require energy from the alchemy pot itself. Energy is used to make recipes that are more than the sum of their ingredients, but it's a limited resource.\n\nNot all energy recipes are especially mystical however. These recipes more resemble traditional cooking than alchemy. +journal.document.alchemy_guide.energy_food.body=Some recipes require energy from the alchemy pot itself. Energy is used in recipes that produce more than the sum of their ingredients.\n\nNot all energy recipes are especially mystical however. These recipes more resemble traditional cooking than alchemy. journal.document.alchemy_guide.bombs.title=Enhanced Bombs -journal.document.alchemy_guide.bombs.body=A standard black powder bomb can be mixed with a specific item to create an enhanced bomb. The amount of energy needed varies by the item used. +journal.document.alchemy_guide.bombs.body=A standard black powder bomb can be mixed with a specific item to create an enhanced bomb. journal.document.alchemy_guide.brews.title=Brews -journal.document.alchemy_guide.brews.body=Brews are made from potion-based recipes, and are centered around inflicting harmful effects on your enemies. +journal.document.alchemy_guide.brews.body=Brews are made from potion-based recipes, and focus on harming your enemies. journal.document.alchemy_guide.elixirs.title=Elixirs journal.document.alchemy_guide.elixirs.body=Elixirs are made from potion-based recipes, and focus on healing or boosting your abilities. journal.document.alchemy_guide.spells.title=Spells