Skip to content

Commit

Permalink
Update source code (Screen)
Browse files Browse the repository at this point in the history
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 :)
  • Loading branch information
TheBigEye authored Oct 23, 2020
1 parent 7bd8dff commit 928042b
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/minicraft/screen/BookData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 28 additions & 12 deletions src/minicraft/screen/MapData.java
Original file line number Diff line number Diff line change
@@ -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),
Expand All @@ -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)),
Expand All @@ -56,14 +59,27 @@ public enum MapData {
CLOUD(Tiles.get("cloud").id, Color.WHITE),
CLOUD_CACTUS(Tiles.get("Cloud Cactus").id, Color.GREEN);

private static final Map<Integer, MapData> BY_ID = new HashMap<Integer, MapData>();

static {
for (MapData mapData : MapData.values()) {
MapData.BY_ID.put(mapData.tileID, mapData);
}
}


public int tileID;
public int color;

MapData(int id, int color) {
tileID = id;
this.color = color;
}

public static MapData getById(int id){
return MapData.BY_ID.get(id);

}

}

9 changes: 4 additions & 5 deletions src/minicraft/screen/MapDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 16 additions & 1 deletion src/minicraft/screen/OptionsDisplay.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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()
Expand Down
103 changes: 92 additions & 11 deletions src/minicraft/screen/TitleDisplay.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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));
Expand Down Expand Up @@ -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!",
Expand All @@ -187,52 +233,86 @@ 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!",
"Kill Slime, get Slime!",
"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",
Expand Down Expand Up @@ -281,5 +361,6 @@ public void render(Screen screen) {
"001100010011000000110001!",
"011010000110110101101101?",
"...zzz...",
"The cake is a lie!",
};
}

0 comments on commit 928042b

Please sign in to comment.