Skip to content

Commit

Permalink
Merge pull request #8 from APT37/main
Browse files Browse the repository at this point in the history
A Space Odyssey
  • Loading branch information
msx80 authored Aug 19, 2024
2 parents 8d41c1c + 64aa781 commit e9696fa
Show file tree
Hide file tree
Showing 30 changed files with 1,416 additions and 1,561 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ public Action(Richtext label, Runnable callback) {
public String toString() {
return label.toString() ;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ public class ButtonWidget extends Widget<Action> {
private static final int BUTTON_Y = 14;
private List<Action> pulsanti = new ArrayList<>();
PrintUtils p;

public ButtonWidget(PrintUtils p, int x, int y, int w, int h) {
super(p.sys, x, y, w, h, BUTTON_Y);
this.p = p;
}


public void set(List<Action> pulsanti)
{
public void set(List<Action> pulsanti) {
this.pulsanti = pulsanti;
invalidateAndReload();
}



@Override
protected List<Action> lines() {
return pulsanti;
Expand All @@ -33,9 +30,7 @@ public void drawBackground(int x, int y) {
}

@Override
public void drawForeground(int x, int y) {

}
public void drawForeground(int x, int y) {}

@Override
protected boolean selected(int idx, Action line) {
Expand All @@ -50,12 +45,7 @@ protected boolean clickedOutside(int x, int y) {

@Override
public void drawItem(int ax, int ay, int idx, Action a) {

p.drawBtn(ax,ay,70,13);
p.richPrint(ax+2,ay+4,a.label.tokens);

p.drawBtn(ax, ay, 70, 13);
p.richPrint(ax + 2, ay + 4, a.label.tokens);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,62 @@ public class ConfirmWidget extends Widget<Action> {
private String question;
private Runnable onYes;
private Runnable onNo;

public ConfirmWidget(GameInterface g, PrintUtils p, String question, Runnable onYes, Runnable onNo) {
super(p.sys, 120-35, 40, 70, ITEM_HEIGHT*2+1, ITEM_HEIGHT);
super(p.sys, 120 - 35, 40, 70, ITEM_HEIGHT * 2 + 1, ITEM_HEIGHT);

this.question = question;
this.onYes = onYes;
this.onNo = onNo;
this.p = p;
this.g = g;

}

/* local s = {-1, CRAFTS[i].output.spr, 15, " = "}
/*
local s = {-1, CRAFTS[i].output.spr, 15, " = "}
for k,v in pairs(CRAFTS[i].ingredients) do
table.insert(s, -1)
for k,v in pairs(CRAFTS[i].ingredients) do
table.insert(s, -1)
table.insert(s, k.spr)
table.insert(s, 15)
table.insert(s, 15)
table.insert(s, " "..v.." ")
*/
*/

@Override
protected List<Action> lines() {

return Arrays.asList(
new Action(Richtext.of("Yes"), onYes),
new Action(Richtext.of("No"), onNo)
);
new Action(Richtext.of("Yes"), onYes),
new Action(Richtext.of("No"), onNo)
);
}

@Override
public void drawBackground(int x, int y) {
p.sys.fill(0, x-3, y-11, w+6, h+12, Tic80.BLACK);

ShapeDrawer.outline(sys, x-2, y-10, w+4, h+10, 0, Tic80.BROWN);
p.richPrint(x, y-8, 14, question);
p.sys.fill(0, x - 3, y - 11, w + 6, h + 12, Tic80.BLACK);


ShapeDrawer.outline(sys, x - 2, y - 10, w + 4, h + 10, 0, Tic80.BROWN);
p.richPrint(x, y - 8, 14, question);
}


@Override
protected boolean selected(int idx, Action line) {

line.callback.run();
return false;

}

@Override
protected boolean clickedOutside(int x, int y) {

return false;
}

@Override
public void drawForeground(int x, int y) {
// TODO Auto-generated method stub

}

@Override
public void drawItem(int ax, int ay, int idx, Action a) {
p.drawBtn(ax,ay,70,13);
p.richPrint(ax+2,ay+4,a.label.tokens);
p.drawBtn(ax, ay, 70, 13);
p.richPrint(ax + 2, ay + 4, a.label.tokens);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,54 @@
public class CraftWidget extends RichWidget {

GameInterface g;

public CraftWidget(GameInterface g, PrintUtils p, int x, int y, int w, int h) {
super(p, x, y, w, h);
this.g = g;

}

/* local s = {-1, CRAFTS[i].output.spr, 15, " = "}
/*
local s = {-1, CRAFTS[i].output.spr, 15, " = "}
for k,v in pairs(CRAFTS[i].ingredients) do
table.insert(s, -1)
for k,v in pairs(CRAFTS[i].ingredients) do
table.insert(s, -1)
table.insert(s, k.spr)
table.insert(s, 15)
table.insert(s, 15)
table.insert(s, " "..v.." ")
*/
*/

@Override
protected List<Richtext> lines() {

return Craft
.visible(g.getRun().pg)
//.ALL
.stream().map(

.visible(g.getRun().pg)
//.ALL
.stream().map(
c -> c.toRichtext()

).collect(Collectors.toList());
).collect(Collectors.toList());
}

@Override
public void drawBackground(int x, int y) {
p.sys.fill(0, x-4, y-10, w+6, h+12, Tic80.BLACK);


p.sys.fill(0, x - 4, y - 10, w + 6, h + 12, Tic80.BLACK);
}

@Override
public void drawForeground(int x, int y) {
p.sys.fill(0, x-4, y-11, w+6, 9, Tic80.DARK_RED);
p.print("Craft what?", x+12, y-9, 15, Align.LEFT);


p.rectb(x-4, y-11, w+6, h+13, 14);
p.sys.fill(0, x - 4, y - 11, w + 6, 9, Tic80.DARK_RED);
p.print("Craft what?", x + 12, y - 9, 15, Align.LEFT);
p.rectb(x - 4, y - 11, w + 6, h + 13, 14);
}

@Override
protected boolean selected(int idx, Richtext line) {
g.doSound(13, 1f, 1f);
Craft c = (Craft) line.userdata;

for (Item i : c.getIngredients().keySet()) {
int required = c.getIngredients().get(i);
g.getRun().pg.inventoryAdd(i, -required);
}

g.getRun().pg.inventoryAdd(c.getOutput(), 1);
g.getLog().add(15, "You obtain ", /*-1, c.getOutput().sprite, */ 14, c.getOutput().name, 15, "!");
g.refreshCommands();
Expand All @@ -76,5 +71,4 @@ protected boolean clickedOutside(int x, int y) {
g.doSound(18, 1f, 1f);
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,64 @@ public CreditsWidget(GameInterface g, PrintUtils p, int x, int y, int w, int h)
super(p, x, y, w, h);
itemsHeight = 7;
this.g = g;

}

@Override
protected List<Richtext> lines() {

return Arrays.asList(
Richtext.of(12, "Doors Of Doom", 15, " - (c) 2019"),
Richtext.of(""),
Richtext.of(15, "A game by ", 14, "MSX"),
Richtext.with("https://livellosegreto.it/@msx", 13, "https://livellosegreto.it/@msx"),
Richtext.of(""),
Richtext.of(9, "Over 27 monsters!"),
Richtext.of(12, "Over 64 items!"),
Richtext.of(9, "Find the sweetest loot!"),
Richtext.of(12, "Adventure into the"),
Richtext.of(9, "Dungeon of Infinite Doors!"),
Richtext.of(""),
Richtext.of("Ported from a TIC-80 game by MSX"),
Richtext.of(""),
Richtext.of("Sounds by: Juhani Junkala"),
Richtext.with("https://juhanijunkala.com/", 13, "https://juhanijunkala.com/"),
Richtext.of(""),
Richtext.of("Music by: RandomMind"),
Richtext.with("https://youtube.com/channel/UCvjkkwGL7g092E1oV7IMffw", 13, "https://youtube.com/channel/UCvjkkwGL7g092E1oV7IMffw"),
Richtext.of(""),
Richtext.of("Beta Testing: ceonello, carlessa"),
Richtext.of(""),
Richtext.of("Powered by: OMICRON game engine"),
Richtext.with("https://github.com/msx80/Omicron", 13, "https://github.com/msx80/Omicron"),
Richtext.of(""),
Richtext.of("Powered by: LIBGDX"),
Richtext.with("https://libgdx.badlogicgames.com/", 13, "https://libgdx.badlogicgames.com/"),
Richtext.of(""),
Richtext.of("Camel Heads lives on!"),
Richtext.of(""),
Richtext.of("Dedicato ai miei Stroppoletti")
/*,
Richtext.of("Over 27 monsters!"),
Richtext.of("Over 64 items!"),
Richtext.of("Find the sweetest loot!"),
Richtext.of("Adventure into the"),
Richtext.of("Dungeon of Infinite Doors!")
*/
);
Richtext.of(12, "Doors Of Doom", 15, " - (c) 2024"),
Richtext.of(""),
Richtext.of(15, "A game by ", 14, "MSX"),
Richtext.with("https://livellosegreto.it/@msx", 13, "https://livellosegreto.it/@msx"),
Richtext.of(""),
Richtext.of(9, "Over 27 monsters!"),
Richtext.of(12, "Over 64 items!"),
Richtext.of(9, "Find the sweetest loot!"),
Richtext.of(12, "Adventure into the"),
Richtext.of(9, "Dungeon of Infinite Doors!"),
Richtext.of(""),
Richtext.of("Ported from a TIC-80 game by MSX"),
Richtext.of(""),
Richtext.of("Sounds by: Juhani Junkala"),
Richtext.with("https://juhanijunkala.com/", 13, "https://juhanijunkala.com/"),
Richtext.of(""),
Richtext.of("Music by: RandomMind"),
Richtext.with("https://youtube.com/channel/UCvjkkwGL7g092E1oV7IMffw", 13, "https://youtube.com/channel/UCvjkkwGL7g092E1oV7IMffw"),
Richtext.of(""),
Richtext.of("Beta Testing: ceonello, carlessa"),
Richtext.of(""),
Richtext.of("Powered by: OMICRON game engine"),
Richtext.with("https://github.com/msx80/Omicron", 13, "https://github.com/msx80/Omicron"),
Richtext.of(""),
Richtext.of("Powered by: LIBGDX"),
Richtext.with("https://libgdx.badlogicgames.com/", 13, "https://libgdx.badlogicgames.com/"),
Richtext.of(""),
Richtext.of("Camel Heads lives on!"),
Richtext.of(""),
Richtext.of("Dedicato ai miei Stroppoletti")
/*,
Richtext.of("Over 27 monsters!"),
Richtext.of("Over 64 items!"),
Richtext.of("Find the sweetest loot!"),
Richtext.of("Adventure into the"),
Richtext.of("Dungeon of Infinite Doors!")
*/
);
}

@Override
public void drawBackground(int x, int y) {
p.sys.fill(0, x-4, y-4, w+8, h+5, Tic80.BLACK);


p.sys.fill(0, x - 4, y - 4, w + 8, h + 5, Tic80.BLACK);
}

@Override
public void drawForeground(int x, int y) {
p.rectb(x-4, y-4, w+8, h+5, 14);
p.rectb(x - 4, y - 4, w + 8, h + 5, 14);
}

@Override
protected boolean selected(int idx, Richtext line) {
if(line.userdata != null)
{
if (line.userdata != null) {
g.getLog().add(15, "Opening url...");
String res = (String)p.sys.hardware("URL_OPENER", "OPEN", (String) line.userdata);
g.getLog().add(15, res);
Expand All @@ -89,5 +84,4 @@ protected boolean clickedOutside(int x, int y) {
g.doSound(18, 1f, 1f);
return false;
}

}
Loading

0 comments on commit e9696fa

Please sign in to comment.