package com.danitheskunk.skunkworks;

import com.danitheskunk.skunkworks.gfx.Color;
import com.danitheskunk.skunkworks.gfx.IRenderContext;
import com.danitheskunk.skunkworks.gfx.vt.Terminal;

public class Test extends BaseGame {
	private Terminal term;

	public Test() {
		super(new Vec2i(40 * 12, 22 * 12), "Skunkworks");
	}

	public static void main(String[] args) {
		new Test().run();
	}

	@Override
	protected void init() {
		var path = "C:\\Program Files (x86)" +
			"\\Steam\\steamapps\\common\\Unreal " +
			"Tournament\\System\\UnrealTournament.ini";
		var data = engine.loadDataWatched(path);
		data.onReload(() -> System.out.println(data.get("URL", "Host")));

		var fontThin = window.loadFontTileset("fonts\\thin-6x12.png");
		var fontThin2 = window.loadFontTileset("fonts\\thin-12x12.png");
		term = new Terminal(new Vec2i(40, 22), fontThin2, fontThin);

		window.setStretchMode(WindowStretchMode.INTEGER);
		var c1 = Color.GREEN;
		var c2 = new Color(0, 128, 0);

		term.drawHorizontalSingleLine(new Vec2i(0, 0), 20, c2);
		term.drawHalfString(new Vec2i(6, 0), " Upgrades ");

		term.drawHalfString(new Vec2i(0, 1), " a", c1);
		term.drawHalfString(new Vec2i(1, 1), " - [", c2);
		term.drawHalfString(new Vec2i(3, 1), " Upgraded Skeleton", c1);
		term.drawHalfString(new Vec2i(12, 1), " ]", c2);
		term.drawHalfString(new Vec2i(16, 1), "10,000$", c1);

		term.drawHalfString(new Vec2i(0, 2), " b", c1);
		term.drawHalfString(new Vec2i(1, 2), " - [", c2);
		term.drawHalfString(new Vec2i(3, 2), " Upgraded Eyes", c1);
		term.drawHalfString(new Vec2i(10, 2), " ]", c2);
		term.drawHalfString(new Vec2i(16, 2), " 7,000$", c1);

		term.drawHalfString(new Vec2i(0, 3), " c", c1);
		term.drawHalfString(new Vec2i(1, 3), " - [", c2);
		term.drawHalfString(new Vec2i(3, 3), " Upgraded Senses", c1);
		term.drawHalfString(new Vec2i(11, 3), " ]", c2);
		term.drawHalfString(new Vec2i(16, 3), " 6,000$", c1);

		term.drawHalfString(new Vec2i(0, 4), " d", c1);
		term.drawHalfString(new Vec2i(1, 4), " - [", c2);
		term.drawHalfString(new Vec2i(3, 4), " Upgraded Legs", c1);
		term.drawHalfString(new Vec2i(10, 4), " ]", c2);
		term.drawHalfString(new Vec2i(16, 4), " 4,500$", c1);

	}

	@Override
	protected void render(IRenderContext rc) {
		rc.drawTerminal(term);
	}

	@Override
	protected void update(double delta) {
		var mouse = window.getMousePos();
		term.clear(Color.TRANS_BLACK);
		var col = window.isMouseDown(0) ? Color.RED : Color.GREEN;
		term.setBackgroundColor(Vec2i.div(mouse, term.getFullCharSize()), col);
		if(window.isMouseClicked(1)) {
			System.out.println("right click");
		}
	}
}
