From 928042b8633b751d4266880387ee8b22d86dfbd8 Mon Sep 17 00:00:00 2001 From: TheBigEye Date: Fri, 23 Oct 2020 20:08:47 -0300 Subject: [PATCH] Update source code (Screen) The design of the Main Menu was updated, new splashes that are activated in special events were added .. and correction of the overlay updater bug... Important: option was added to open the game folder :) --- src/minicraft/screen/BookData.java | 1 + src/minicraft/screen/MapData.java | 40 ++++++--- src/minicraft/screen/MapDisplay.java | 9 +- src/minicraft/screen/OptionsDisplay.java | 17 +++- src/minicraft/screen/TitleDisplay.java | 103 ++++++++++++++++++++--- 5 files changed, 141 insertions(+), 29 deletions(-) diff --git a/src/minicraft/screen/BookData.java b/src/minicraft/screen/BookData.java index fc26ecd..ea9c391 100644 --- a/src/minicraft/screen/BookData.java +++ b/src/minicraft/screen/BookData.java @@ -14,6 +14,7 @@ public class BookData { public static final String antVenomBook = loadBook("antidous"); public static final String storylineGuide = loadBook("story_guide"); + public static final String NecroBook = loadBook("necronomicon"); private static final String loadBook(String bookTitle) { String book; diff --git a/src/minicraft/screen/MapData.java b/src/minicraft/screen/MapData.java index f35068d..6dd61e8 100644 --- a/src/minicraft/screen/MapData.java +++ b/src/minicraft/screen/MapData.java @@ -1,27 +1,30 @@ package minicraft.screen; +import java.util.HashMap; +import java.util.Map; + import minicraft.gfx.Color; import minicraft.level.tile.Tiles; public enum MapData { GRASS(Tiles.get("Grass").id, Color.get(1, 58, 198, 30)), - MYCELIUM(Tiles.get("Mycelium").id, Color.get(1, 89, 86, 86)), + MYCELIUM(Tiles.get("Mycelium").id, Color.get(1, 58, 198, 30)), LAWN(Tiles.get("Lawn").id, Color.get(1, 57, 191, 30)), - DIRT(Tiles.get("Dirt").id, Color.get(1, 132, 116, 0)), + DIRT(Tiles.get("Dirt").id, Color.get(1, 157, 91, 41)), FLOWER(Tiles.get("Flower").id, Color.YELLOW), HOLE(Tiles.get("Hole").id, Color.get(1, 61, 47, 8)), - WATER(Tiles.get("Water").id, Color.get(1, 0, 178, 240)), + WATER(Tiles.get("Water").id, Color.get(1, 63, 63, 245)), LAVA(Tiles.get("Lava").id, Color.RED), ROCK(Tiles.get("Rock").id, Color.get(1, 145, 143, 122)), HARD_ROCK(Tiles.get("Hard Rock").id, Color.get(1, 127, 126, 107)), - CACTUS(Tiles.get("Cactus").id, Color.GREEN), + CACTUS(Tiles.get("Cactus").id, Color.get(1, 0,85, 0)), TREE(Tiles.get("Tree").id, Color.get(1, 0, 113, 0)), FIR_TREE(Tiles.get("Fir Tree").id, Color.get(1, 19, 139, 98)), PINE_TREE(Tiles.get("Pine Tree").id, Color.get(1, 17, 127, 89)), - //GIANT_RED_MUSHROOM(Tiles.get("Giant Red Mushroom").id, Color.get(1, 209, 20, 10)), - //GIANT_BROWN_MUSHROOM(Tiles.get("Giant Brown Mushroom").id, Color.get(1, 175, 122, 96)), - SAND(Tiles.get("Sand").id, Color.get(1, 232, 201, 0)), + GIANT_RED_MUSHROOM(Tiles.get("Giant Red Mushroom").id, Color.get(1, 57, 191, 30)), + //GIANT_BROWN_MUSHROOM(Tiles.get("Giant Brown Mushroom").id, Color.get(1, 175, 122, 96)), //Blocked for errors + SAND(Tiles.get("Sand").id, Color.get(1, 247, 233, 163)), SNOW(Tiles.get("Snow").id, Color.get(1, 240, 240, 240)), STAIRS_UP(Tiles.get("Stairs Up").id, 0xffffff), STAIRS_DOWN(Tiles.get("Stairs Down").id, 0xffffff), @@ -35,19 +38,19 @@ public enum MapData { OBSIDIAN_WALL(Tiles.get("Obsidian Wall").id, Color.get(1, 46, 24, 118)), OBSIDIAN_DOOR(Tiles.get("Obsidian Door").id, Color.get(1, 44, 21, 67)), - WOOL(Tiles.get("Wool").id, Color.get(1, 239, 239, 236)), - BLACK_WOOL(Tiles.get("Black Wool").id, Color.get(1, 23, 19, 18)), - YELLOW_WOOL(Tiles.get("Yellow Wool").id, Color.get(1, 186, 175, 49)), + WOOL(Tiles.get("Wool").id, Color.get(1, 220, 220, 220)), + BLACK_WOOL(Tiles.get("Black Wool").id, Color.get(1, 21, 21, 21)), + YELLOW_WOOL(Tiles.get("Yellow Wool").id, Color.get(1, 197, 197, 44)), GREEN_WOOL(Tiles.get("Green Wool").id, Color.get(1, 71, 178, 59)), BLUE_WOOL(Tiles.get("Blue Wool").id, Color.get(1, 51, 75, 160)), - RED_WOOL(Tiles.get("Red Wool").id, Color.get(1, 146, 48, 47)), + RED_WOOL(Tiles.get("Red Wool").id, Color.get(1, 132, 44, 44)), PURPLE_WOOL(Tiles.get("Purple Wool").id, Color.get(1, 127, 63, 180)), PINK_WOOL(Tiles.get("Pink Wool").id, Color.get(1, 224, 175, 198)), DARK_GREEN_WOOL(Tiles.get("Dark Green Wool").id, Color.get(1, 53, 70, 29)), BROWN_WOOL(Tiles.get("Brown Wool").id, Color.get(1, 91, 56, 36)), MAGENTA_WOOL(Tiles.get("Magenta Wool").id, Color.get(1, 184, 87, 194)), LIGHT_BLUE_WOOL(Tiles.get("Light Blue Wool").id, Color.get(1, 111, 155, 220)), - CYAN_WOOL(Tiles.get("Cyan Wool").id, Color.get(1, 48, 114, 138)), + CYAN_WOOL(Tiles.get("Cyan Wool").id, Color.get(1, 65, 109, 132)), ORANGE_WOOL(Tiles.get("Orange Wool").id, Color.get(1, 229, 110, 71)), FARMLAND(Tiles.get("Farmland").id, Color.get(1, 145, 75, 75)), @@ -56,7 +59,15 @@ public enum MapData { CLOUD(Tiles.get("cloud").id, Color.WHITE), CLOUD_CACTUS(Tiles.get("Cloud Cactus").id, Color.GREEN); + private static final Map BY_ID = new HashMap(); + + static { + for (MapData mapData : MapData.values()) { + MapData.BY_ID.put(mapData.tileID, mapData); + } + } + public int tileID; public int color; @@ -64,6 +75,11 @@ public enum MapData { tileID = id; this.color = color; } + + public static MapData getById(int id){ + return MapData.BY_ID.get(id); + + } } diff --git a/src/minicraft/screen/MapDisplay.java b/src/minicraft/screen/MapDisplay.java index a7f85f8..5031088 100644 --- a/src/minicraft/screen/MapDisplay.java +++ b/src/minicraft/screen/MapDisplay.java @@ -102,11 +102,10 @@ public void render(Screen screen) { for (int c = 1; c < 128; c++) { int color = 1; Tile tile = level.getTile(i + (offset[0] * 128), c + (offset[1] * 128)); - for (int e = 1; e < MapData.values().length; e++) { - if (MapData.values()[e].tileID == tile.id) { - color = MapData.values()[e].color; - break; - } + + MapData mapData = MapData.getById(tile.id); + if (mapData != null) { + color = mapData.color; } // by drawing with only one pixel at a time we can draw with much more precision screen.setPixel(i + menuBounds.getLeft() + 6, c + menuBounds.getTop() + 6, color); diff --git a/src/minicraft/screen/OptionsDisplay.java b/src/minicraft/screen/OptionsDisplay.java index a8ba228..ecb4eab 100644 --- a/src/minicraft/screen/OptionsDisplay.java +++ b/src/minicraft/screen/OptionsDisplay.java @@ -1,9 +1,15 @@ package minicraft.screen; + +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; + import minicraft.core.Game; import minicraft.core.io.Localization; import minicraft.core.io.Settings; import minicraft.saveload.Save; +import minicraft.screen.entry.BlankEntry; import minicraft.screen.entry.SelectEntry; public class OptionsDisplay extends Display { @@ -17,7 +23,16 @@ public OptionsDisplay() { Settings.getEntry("skinon"), new SelectEntry("Change Key Bindings", () -> Game.setMenu(new KeyInputDisplay())), Settings.getEntry("language"), - Settings.getEntry("textures") + Settings.getEntry("textures"), + new BlankEntry(), + new SelectEntry("Open Game Folder", () -> { + try { + Desktop.getDesktop().open(new File(Game.gameDir)); + } catch (IOException e) { + e.printStackTrace(); + } + }) + ) .setTitle("Options") .createMenu() diff --git a/src/minicraft/screen/TitleDisplay.java b/src/minicraft/screen/TitleDisplay.java index e063006..19cd563 100644 --- a/src/minicraft/screen/TitleDisplay.java +++ b/src/minicraft/screen/TitleDisplay.java @@ -1,5 +1,8 @@ package minicraft.screen; +import java.awt.Desktop; +import java.io.File; +import java.io.IOException; import java.time.LocalDateTime; import java.time.Month; import java.util.Random; @@ -34,9 +37,8 @@ public class TitleDisplay extends Display { private Object timer; public TitleDisplay() { - super(true, false, new Menu.Builder(false, 2, RelPos.CENTER, - new BlankEntry(), - new BlankEntry(), + super(true, false, new Menu.Builder(false, 2, RelPos.CENTER, + new StringEntry(""), new SelectEntry("Singleplayer", () -> { if(WorldSelectDisplay.getWorldNames().size() > 0) Game.setMenu(new Display(true, new Menu.Builder(false, 2, RelPos.CENTER, @@ -84,14 +86,47 @@ public void init(Display parent) { } Game.ISONLINE = false; + + //events LocalDateTime time = LocalDateTime.now(); if (time.getMonth() == Month.DECEMBER) { if (time.getDayOfMonth() == 19) rand = 1; if (time.getDayOfMonth() == 25) rand = 2; } else { rand = random.nextInt(splashes.length - 3) + 3; + + } + + if (time.getMonth() == Month.FEBRUARY) { + if (time.getDayOfMonth() == 14) rand = 0; + if (time.getDayOfMonth() == 15) rand = 0; + if (time.getDayOfMonth() == 16) rand = 0; + } else { + rand = random.nextInt(splashes.length - 3) + 3; + } + if (time.getMonth() == Month.JULY) { + if (time.getDayOfMonth() == 6) rand = 3; + } else { + rand = random.nextInt(splashes.length - 3) + 3; + + } + if (time.getMonth() == Month.SEPTEMBER) { + if (time.getDayOfMonth() == 18) rand = 4; + } else { + rand = random.nextInt(splashes.length - 3) + 3; + + } + if (time.getMonth() == Month.AUGUST) { + if (time.getDayOfMonth() == 29) rand = 5; + if (time.getDayOfMonth() == 10) rand = 6; + } else { + rand = random.nextInt(splashes.length - 3) + 3; + + } + + World.levels = new Level[World.levels.length]; if(Game.player == null || Game.player instanceof RemotePlayer) @@ -108,7 +143,7 @@ private void checkVersion() { if(Game.debug) System.out.println("latest version = "+latestVersion.version); if(latestVersion.version.compareTo(Game.VERSION) > 0) { // link new version menus[0].updateEntry(0, new StringEntry("New: "+latestVersion.releaseName, Color.GREEN)); - menus[0].updateEntry(1, new LinkEntry(Color.CYAN, "--Select here to Download--", latestVersion.releaseUrl, "Direct link to latest version: " + latestVersion.releaseUrl + "\nCan also be found here with change log: https://www.github.com/chrisj42/minicraft-plus-revived/releases")); + menus[0].updateEntry(1, new LinkEntry(Color.GREEN, "--Select here to Download--", latestVersion.releaseUrl, "Direct link to latest version: " + latestVersion.releaseUrl + "\nCan also be found here with change log: https://www.github.com/TheBigEye/Cthulhucraft/releases")); } else if(latestVersion.releaseName.length() > 0) menus[0].updateEntry(0, new StringEntry("You have the latest version.", Color.DARK_GRAY)); @@ -161,22 +196,33 @@ public void render(Screen screen) { int splashColor = isblue ? Color.BLUE : isRed ? Color.RED : isGreen ? Color.GREEN : Color.get(1, bcol*51, bcol*51, bcol*25); - Font.drawCentered(splashes[rand], screen, 74, splashColor); + Font.drawCentered(splashes[rand], screen, 70, splashColor); + + //Font.draw("Version " + Game.BUILD, screen, 1, 1, Color.get(1, 51)); + Font.draw(Game.BUILD, screen, 1, 1, Color.get(1, 51)); - Font.draw("Version " + Game.BUILD, screen, 1, 1, Color.get(1, 51)); + Font.drawCentered("Mod by TheBigEye", screen, Screen.h - 12, Color.get(1, 51)); } private static final String[] splashes = { - "Secret Splash!", + "I love A.", "Happy birthday Minicraft!", "Happy XMAS!", - "Multiplayer Now Included!", + "Happy birthday BigEye :)", + "Happy birthday Zaq :)", + "Happy birthday A.L.I.C.E :)", + + "Bye ben :(", + + //Also play "Also play InfinityTale!", "Also play Minicraft Deluxe!", "Also play Alecraft!", "Also play Hackcraft!", "Also play MiniCrate!", "Also play MiniCraft Mob Overload!", + + "Now with better fishing!", "Now with better tools!", "Now with better chests!", @@ -187,17 +233,22 @@ public void render(Screen screen) { "MinicraftPlus on Youtube", "Join the Forums!", "The Wiki is weak! Help it!", + "Notch is Awesome!", "Dillyg10 is cool as Ice!", "Shylor is the man!", "Chris J is great with portals!", "AntVenom loves cows! Honest!", + "TheBigEye.... Cake rain!", + "You should read Antidious Venomi!", "Oh Hi Mark", "Use the force!", "Keep calm!", "Get him, Steve!", "Forty-Two!", + + //kill "Kill Creeper, get Gunpowder!", "Kill Cow, get Beef!", "Kill Zombie, get Cloth!", @@ -205,34 +256,63 @@ public void render(Screen screen) { "Kill Skeleton, get Bones!", "Kill Sheep, get Wool!", "Kill Pig, get Porkchop!", + "Kill Chicken, get Feathers!", + + //mineral levels "Gold > Iron", "Gem > Gold", + "Test == InDev!", "Story? Uhh...", + + //What's that? "Infinite terrain? What's that?", "Redstone? What's that?", "Minecarts? What are those?", "Windows? I prefer Doors!", "2.5D FTW!", - "3rd dimension not included!", + "Grab your friends!", + + //Not Included "Null not included", + "Herobine not included", "Mouse not included!", "No spiders included!", "No Endermen included!", - "No chickens included!", - "Grab your friends!", + "3rd dimension not included!", + + //Included + "Villagers included!", "Creepers included!", "Skeletons included!", "Knights included!", "Snakes included!", "Cows included!", "Sheep included!", + "Chickens included!", "Pigs included!", + "Cthulhu included!", + "Enchantments Now Included!", + "Multiplayer Now Included!", + "Carrots Now Included!", + "Boats Now Included!", + "Maps Now Included!", + //"Nether Now Included?", + + //Worlds "Bigger Worlds!", "World types!", "World themes!", + "Mushroom Biome!", + "Desert Biome!", + "Forest Biome!", + "Snow Biome!", + + //Ideas "Sugarcane is a Idea!", "Milk is an idea!", + "Cakes is an idea!", + "Creeper, aw man", "So we back in the mine,", "pickaxe swinging from side to side", @@ -281,5 +361,6 @@ public void render(Screen screen) { "001100010011000000110001!", "011010000110110101101101?", "...zzz...", + "The cake is a lie!", }; }