diff --git a/dfdesigner.js b/dfdesigner.js
index 5ae4762..4d7965e 100644
--- a/dfdesigner.js
+++ b/dfdesigner.js
@@ -1,9 +1,6 @@
// DFDesigner - 2013
// Jos van Egmond / info@josvanegmond.nl / @manadar
-// Todo's:
-// - Small indicator of size of selection: Format: XxY. Eg: 7x6
-
// map is a 3d array which can be accessed in this way: map[z][x][y]
// z = elevation, top to bottom (0 = top, map_size_z = bottom)
// x = west to east (0 = west, map_size_x = east)
@@ -765,7 +762,19 @@ function enableDesigner() {
return false;
});
- // TODO: Functionality for scroll wheel. What makes sense? Menu item switch or z-level change or ...?
+ container_element.addEventListener('wheel', function(evt) {
+ if (evt.deltaY < 0) {
+ moveCursor(camera_z + 1, cursor_x, cursor_y);
+ } else if (evt.deltaY > 0) {
+ moveCursor(camera_z - 1, cursor_x, cursor_y);
+ }
+
+ requestDrawZlevel = true;
+ requestDrawMenu = true;
+
+ evt.preventDefault();
+ return false;
+ });
}
function handle_onMouseDown(x, y) {
@@ -775,11 +784,9 @@ function handle_onMouseDown(x, y) {
if (x > menu_border) { return; }
- // TODO: Make function out of this
- var tile_x = Math.floor(x / tile_size) - 1; // minus 1 because of the chrome
- var tile_y = Math.floor(y / tile_size) - 1;
+ var tile = pixelToTile(x, y);
- moveCursor(camera_z, tile_x + camera_x, tile_y + camera_y);
+ moveCursor(camera_z, tile.x + camera_x, tile.y + camera_y);
if (cursor_tool.type & tool_type_area_square) {
cursor_start_x = cursor_x;
@@ -859,8 +866,9 @@ function handle_onMouseMove(x, y) {
cursor_in_menu = false;
}
- var tile_x = camera_x + Math.floor(x / tile_size) - 1; // minus 1 because of the chrome
- var tile_y = camera_y + Math.floor(y / tile_size) - 1;
+ var tile = pixelToTile(x, y);
+ var tile_x = camera_x + tile.x;
+ var tile_y = camera_y + tile.y;
// move the cursor, but dont follow the camera immediately
var moved = moveCursor(camera_z, tile_x, tile_y, true);
@@ -881,8 +889,9 @@ function handle_onMouseMove(x, y) {
moveCameraToCursor();
// and repeat the process in order to keep the camera moving
- tile_x = camera_x + Math.floor(x / tile_size) - 1; // minus 1 because of the chrome
- tile_y = camera_y + Math.floor(y / tile_size) - 1;
+ var newTile = pixelToTile(x, y);
+ tile_x = camera_x + newTile.x;
+ tile_y = camera_y + newTile.y;
moved = moveCursor(camera_z, tile_x, tile_y, true);
setTimeout(moveCameraLater, 300);
@@ -892,6 +901,14 @@ function handle_onMouseMove(x, y) {
setTimeout(moveCameraLater, 300);
}
+// Convert pixel coordinates to tile coordinates, accounting for chrome offset
+function pixelToTile(px, py) {
+ return {
+ x: Math.floor(px / tile_size) - 1,
+ y: Math.floor(py / tile_size) - 1
+ };
+}
+
// move the cursor, with a flag to indicate if the camera should follow the cursor.
// returns whether or not the cursor has moved
function moveCursor(z, x, y, dont_move_camera) {
@@ -1142,6 +1159,21 @@ function draw() {
// render cursor
viewport_cursor_drawcontext.drawImage(images.cursor, (cursor_x - camera_x + 1) * 16, (cursor_y - camera_y + 1) * 16, tile_size, tile_size);
+ // render selection size indicator when making an area selection
+ if (cursor_down) {
+ var sel_w = Math.abs(cursor_x - cursor_start_x) + 1;
+ var sel_h = Math.abs(cursor_y - cursor_start_y) + 1;
+ var size_text = sel_w + "x" + sel_h;
+ var text_x = (cursor_x - camera_x + 2) * tile_size;
+ var text_y = (cursor_y - camera_y + 1) * tile_size;
+ viewport_cursor_drawcontext.font = "bold 11px sans-serif";
+ viewport_cursor_drawcontext.fillStyle = "white";
+ viewport_cursor_drawcontext.strokeStyle = "black";
+ viewport_cursor_drawcontext.lineWidth = 2;
+ viewport_cursor_drawcontext.strokeText(size_text, text_x, text_y);
+ viewport_cursor_drawcontext.fillText(size_text, text_x, text_y);
+ }
+
drawMenu();
drawChrome();
diff --git a/instructions.html b/instructions.html
index 0d16a3f..e70bc49 100644
--- a/instructions.html
+++ b/instructions.html
@@ -1,3 +1,106 @@
-Full instructions.
+
+
+
+
+
+
+
+DFPlanner Instructions
+
+Back to Planner
+
+DFPlanner is a web-based fortress designation tool for Dwarf Fortress. Design your fortress blueprint in the browser, then export it as a CSV file for import into your game using QuickFort.
+
+Designation Tools
+
+
+ | Key | Tool | Description |
+ | D | Dig | Designate an area for digging |
+ | H | Channel | Designate an area for channeling |
+ | U | Upward Stairway | Designate upward staircases |
+ | J | Downward Stairway | Designate downward staircases |
+ | I | Up/Down Stairway | Designate bidirectional staircases |
+ | R | Upward Ramp | Designate upward ramps |
+
+
+Utility Tools
+
+
+ | Key | Tool | Description |
+ | V | Invert Designation | Swap designated and undesignated tiles in an area |
+ | X | Remove Designation | Clear designations from an area |
+ | Q | Export to QuickFort | Select an area and export it as a QuickFort CSV |
+ | B | Switch Tool Shape | Toggle between square and circle selection shapes |
+
+
+Navigation
+
+
+ | Key | Action |
+ | Arrow Keys | Move cursor |
+ | Shift + Arrow Keys | Move cursor by 10 tiles |
+ | Ctrl + Arrow Keys | Move cursor by 2 tiles |
+ | Page Up / , | Go up one z-level |
+ | Page Down / . | Go down one z-level |
+ | Scroll Wheel | Change z-level up/down |
+ | Move mouse to screen edge | Pan camera |
+
+
+Selection
+
+
+ | Input | Action |
+ | Enter | Start/finish area selection (keyboard mode) |
+ | Click and drag | Select area (mouse mode) |
+ | Esc | Cancel current selection |
+
+
+How to Use Your Blueprint
+
+
+ - Design your fortress using the tools above.
+ - Press Q to export, then select the area to export.
+ - Copy the CSV output and save it as a
.csv file.
+ - Use QuickFort to import the blueprint into Dwarf Fortress.
+
+
+
+