fixed bug in console

v5stable
Ondřej Hruška 11 years ago
parent 2525eda1bf
commit 8509794eeb
  1. 2
      src/mightypork/gamecore/app/MainLoop.java
  2. 4
      src/mightypork/rogue/Const.java
  3. 3
      src/mightypork/rogue/screens/game/ScreenGame.java
  4. 32
      src/mightypork/rogue/screens/game/WorldConsoleRenderer.java
  5. 15
      src/mightypork/rogue/world/World.java
  6. 9
      src/mightypork/rogue/world/WorldConsole.java
  7. 2
      src/mightypork/rogue/world/gui/MapView.java

@ -55,7 +55,7 @@ public abstract class MainLoop extends AppModule implements MainLoopRequestListe
while (running) {
getDisplay().beginFrame();
getEventBus().send(new UpdateEvent(timer.getDelta()));
getEventBus().sendDirect(new UpdateEvent(timer.getDelta()));
Runnable r;
while ((r = taskQueue.poll()) != null) {

@ -18,6 +18,6 @@ public final class Const {
public static final int FPS_RENDER = 120; // max
// INITIAL WINDOW SIZE
public static final int WINDOW_W = 800;
public static final int WINDOW_H = 600;
public static final int WINDOW_W = 1024;
public static final int WINDOW_H = 768;
}

@ -92,9 +92,6 @@ public class ScreenGame extends LayeredScreen {
{
if (this.state == nstate) return;
System.out.println("Goto: "+nstate);
if (nstate != GScrState.WORLD) { // leaving world.
getEventBus().send(new WorldPauseRequest(PauseAction.PAUSE));

@ -2,9 +2,13 @@ package mightypork.rogue.screens.game;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.LinkedList;
import java.util.List;
import mightypork.gamecore.gui.AlignX;
import mightypork.gamecore.gui.components.BaseComponent;
import mightypork.gamecore.logging.Log;
import mightypork.gamecore.resources.fonts.FontRenderer;
import mightypork.gamecore.util.math.color.Color;
import mightypork.gamecore.util.math.color.pal.RGB;
@ -23,7 +27,8 @@ public class WorldConsoleRenderer extends BaseComponent {
private final FontRenderer fr;
public WorldConsoleRenderer(Num rowHeight) {
public WorldConsoleRenderer(Num rowHeight)
{
this.rowHeight = rowHeight;
this.fr = new FontRenderer(Res.getFont("tiny"));
}
@ -36,23 +41,30 @@ public class WorldConsoleRenderer extends BaseComponent {
Rect lowRow = bottomEdge().growUp(rowHeight);
Collection<Entry> entries = WorldProvider.get().getWorld().getConsole().getEntries();
Collection<WorldConsole.Entry> entries = WorldProvider.get().getWorld().getConsole().getEntries();
int cnt = 0;
NumVar alph = Num.makeVar();
Color.pushAlpha(alph);
for (WorldConsole.Entry entry : entries) {
alph.setTo(entry.getAlpha());
Rect rrr = lowRow.moveY(-rh * cnt);
try {
fr.draw(entry.getMessage(), rrr.move(rh / 12, rh / 12), AlignX.LEFT, RGB.BLACK_60);
fr.draw(entry.getMessage(), rrr, AlignX.LEFT, RGB.WHITE);
for (WorldConsole.Entry entry : entries) {
alph.setTo(entry.getAlpha());
Rect rrr = lowRow.moveY(-rh * cnt);
fr.draw(entry.getMessage(), rrr.move(rh / 12, rh / 12), AlignX.LEFT, RGB.BLACK_60);
fr.draw(entry.getMessage(), rrr, AlignX.LEFT, RGB.WHITE);
cnt++;
}
cnt++;
} catch (ConcurrentModificationException e) {
Log.e(e); // this should not happen anymore
}
Color.popAlpha();

@ -254,7 +254,11 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea
}
}
msgNoMoreFood();
if(getHealth()<getHealthMax()) {
msgNoMoreFood();
} else {
msgNotHungry();
}
}
@ -577,13 +581,18 @@ public class World implements DelegatingClient, BusAccess, IonObjBundled, Pausea
public void msgNoMoreFood()
{
console.addMessage("You have no more food!");
console.addMessage("You don't have any food!");
}
public void msgNotHungry()
{
console.addMessage("You are not hungry.");
}
public void msgCannotPick()
{
console.addMessage("Inventory is full.");
console.addMessage("Can't pick items, inventory is full.");
}

@ -1,10 +1,9 @@
package mightypork.rogue.world;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import mightypork.gamecore.eventbus.events.Updateable;
import mightypork.gamecore.util.math.Easing;
@ -71,7 +70,7 @@ public class WorldConsole implements Updateable {
}
}
private final Deque<Entry> entries = new LinkedList<>();
private final Deque<Entry> entries = new LinkedBlockingDeque<>();
@Override

@ -94,7 +94,7 @@ public class MapView extends InputComponent implements DelegatingClient, MouseBu
public MapView()
{
this.tileSize = height().min(width()).div(10).max(32).mul(Num.make(1).sub(zoom.mul(0.5)));
this.tileSize = height().min(width()).div(9).max(32).mul(Num.make(1).sub(zoom.mul(0.5)));
this.worldRenderer = new WorldRenderer(this, tileSize);
plc = WorldProvider.get().getPlayerControl();

Loading…
Cancel
Save