- import std.string;
- import std.conv;

- import ddbc;

- import database;
- import room;
- import item;

doctype html
html
	head
		title RPG Browser Server
		link(rel="shortcut icon", href="favicon.png")
		link(rel="stylesheet",type="text/css",href="style.css")
	body
		div#gamecanvas
			h2 RPG Browser Server
			p This page is a static form which lets you configure the running RPG Server.
			form(action="delete_db", method="POST", onsubmit="return confirm('This deletes ALL data. Continue?');" )
				input(type="submit", value="Delete Database")
				
			h2 All Rooms
			- foreach(r; dbconn.get!Room())
				form.room(action="edit_room", method="POST")
					input(type="hidden", name="room_uuid", value="#{r.uuid}")
					
					img(src="add_room_thumbnail")
					h3 #{r.uuid}
					p #{r.description}
					input(type="submit", value="Edit Room")
			
			form.new_place(action="new_room", method="POST")
				input(type="submit", value="New Room")
			
			h2 All Item Placements
			- foreach(ip; dbconn.get!ItemPlacement())
				- Item i = dbconn.get!Item(ip.item_uuid);
				form.item_place(action="edit_item_place", method="POST")
					input(type="hidden", name="item_place_uuid", value="#{ip.uuid}")
					
					img(src="#{i.background_url}")
					h3 #{ip.uuid}
					p #{"Location: ("~to!string(ip.x)~", "~to!string(ip.y)~")"}
					p #{"Points to item "~ip.item_uuid}
					input(type="submit", value="Edit")
				
			form.new_place(action="new_item_place", method="POST")
				input(type="submit", value="New Place")
				
			h2 All Items
			- foreach(i; dbconn.get!Item())
				form.item(action="edit_item", method="POST")
					input(type="hidden", name="item_uuid", value="#{i.uuid}")
					
					img(src="#{i.background_url}")
					h3 #{i.uuid}
					p.greentext #{i.greentext}
					p.oncollide #{i.on_player_collide}
					input(type="submit", value="Edit")
					
			form.new_item(action="new_item", method="POST")
				input(type="submit", value="New Item")