more minor ui
parent
b7991cdb74
commit
97d6412ea7
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import xyz.valnet.engine.App;
|
||||
import xyz.valnet.engine.graphics.Drawing;
|
||||
import xyz.valnet.engine.graphics.Sprite;
|
||||
import xyz.valnet.engine.graphics.Tile9;
|
||||
import xyz.valnet.engine.math.Vector2f;
|
||||
import xyz.valnet.engine.math.Vector2i;
|
||||
import xyz.valnet.engine.math.Vector4f;
|
||||
|
|
@ -83,6 +84,7 @@ public class Camera extends GameObject implements ITransient, IMouseCaptureArea
|
|||
return screen2world(pos.x, pos.y);
|
||||
}
|
||||
|
||||
// !! this takes an AABB and returns and AABB
|
||||
public Vector4f world2screen(Vector4f input) {
|
||||
return new Vector4f(
|
||||
input.x * tileWidth + screenWidth / 2 - focus.x * tileWidth,
|
||||
|
|
@ -122,6 +124,12 @@ public class Camera extends GameObject implements ITransient, IMouseCaptureArea
|
|||
Drawing.drawSprite(sprite, (int)(screenPos.x), (int)(screenPos.y), (int)(tileWidth * w), (int)(tileWidth * h));
|
||||
}
|
||||
|
||||
public void draw(float layer, Tile9 sprite, float x, float y, float w, float h) {
|
||||
Vector2i screenPos = world2screen(x, y);
|
||||
Drawing.setLayer(layer + (((y + h) - minY) / (maxY - minY)));
|
||||
sprite.draw((int)(screenPos.x), (int)(screenPos.y), (int)(tileWidth * w), (int)(tileWidth * h));
|
||||
}
|
||||
|
||||
public void drawProgressBar(float progress, Vector4f worldBox) {
|
||||
int h = 6;
|
||||
Vector4i box = world2screen(worldBox).toXYWH().asInt();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import xyz.valnet.hadean.HadeanGame;
|
|||
import xyz.valnet.hadean.gameobjects.BottomBar;
|
||||
import xyz.valnet.hadean.gameobjects.Camera;
|
||||
import xyz.valnet.hadean.gameobjects.Tile;
|
||||
import xyz.valnet.hadean.gameobjects.inputlayer.SelectionLayer;
|
||||
import xyz.valnet.hadean.gameobjects.worldobjects.WorldObject;
|
||||
import xyz.valnet.hadean.util.Assets;
|
||||
import xyz.valnet.hadean.util.Layers;
|
||||
|
|
@ -21,12 +22,20 @@ public class HoverQuery extends GameObject implements ITransient {
|
|||
|
||||
private Camera camera;
|
||||
|
||||
private boolean visible = true;
|
||||
|
||||
@Override
|
||||
protected void connect() {
|
||||
super.connect();
|
||||
camera = get(Camera.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
get(SelectionLayer.class).subscribe((selected) -> {
|
||||
visible = selected.size() == 0;
|
||||
});
|
||||
}
|
||||
private List<String> thingStrings = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
|
|
@ -53,12 +62,13 @@ public class HoverQuery extends GameObject implements ITransient {
|
|||
|
||||
@Override
|
||||
public void render() {
|
||||
if(!visible) return;
|
||||
Drawing.setLayer(Layers.LOW_PRIORITY_UI);
|
||||
int i = 576 - BottomBar.bottomBarHeight - 32;
|
||||
int i = 576 - BottomBar.bottomBarHeight - 24;
|
||||
for(String thingString : thingStrings) {
|
||||
for(String str : thingString.split("\n")) {
|
||||
Assets.font.drawString(str, 16, i);
|
||||
i -= 14;
|
||||
Assets.font.drawStringOutlined(str, 8, i);
|
||||
i -= 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,9 @@ public class BuildTab extends Tab implements ISelectionChangeListener, IMouseCap
|
|||
Assets.flat.pushColor(new Vector4f(1f, 1f, 1f, 1.0f));
|
||||
Vector2i topLeft = camera.world2screen(x, y);
|
||||
Assets.font.drawString(selectedBuildable.name, topLeft.x, topLeft.y - 20);
|
||||
Assets.flat.swapColor(new Vector4f(1f, 1f, 1f, 0.5f));
|
||||
Assets.flat.swapColor(new Vector4f(1f, 1f, 1f, 0.6f));
|
||||
camera.draw(Layers.BUILD_INTERACTABLE, Assets.selectionFrame, x, y, w, h);
|
||||
Assets.flat.swapColor(new Vector4f(1f, 1f, 1f, 0.35f));
|
||||
for(int i = 0; i < w; i ++) for(int j = 0; j < h; j ++) {{
|
||||
camera.draw(Layers.BUILD_INTERACTABLE, Assets.checkerBoard, x + i, y + j);
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package xyz.valnet.hadean.interfaces;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public interface ISelectionChangeListener {
|
||||
@FunctionalInterface
|
||||
public interface ISelectionChangeListener extends Serializable {
|
||||
public void selectionChanged(List<ISelectable> selected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue