From 69e8fcce915630b1e861544eca9701cc7a2029c5 Mon Sep 17 00:00:00 2001 From: Quietust Date: Tue, 18 Sep 2012 13:57:06 -0500 Subject: [PATCH 1/6] Add mouse input to Manipulator, along with column labels --- plugins/manipulator.cpp | 104 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index f40969655..1ad46ab28 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -528,6 +528,105 @@ void viewscreen_unitlaborsst::feed(set *events) if (first_column < sel_column - col_widths[DISP_COLUMN_LABORS] + 1) first_column = sel_column - col_widths[DISP_COLUMN_LABORS] + 1; + // handle mouse input + if (enabler->tracking_on && gps->mouse_x != -1 && gps->mouse_y != -1) + { + int click_header = DISP_COLUMN_MAX; // group ID of the column header clicked + int click_body = DISP_COLUMN_MAX; // group ID of the column body clicked + + int click_unit = -1; // Index into units[] (-1 if out of range) + int click_labor = -1; // Index into columns[] (-1 if out of range) + + for (int i = 0; i < DISP_COLUMN_MAX; i++) + { + if ((gps->mouse_x >= col_offsets[i]) && + (gps->mouse_x < col_offsets[i] + col_widths[i])) + { + if ((gps->mouse_y >= 1) && (gps->mouse_y <= 2)) + click_header = i; + if ((gps->mouse_y >= 4) && (gps->mouse_y <= 4 + num_rows)) + click_body = i; + } + } + + if ((gps->mouse_x >= col_offsets[DISP_COLUMN_LABORS]) && + (gps->mouse_x < col_offsets[DISP_COLUMN_LABORS] + col_widths[DISP_COLUMN_LABORS])) + click_labor = gps->mouse_x - col_offsets[DISP_COLUMN_LABORS] + first_column; + if ((gps->mouse_y >= 4) && (gps->mouse_y <= 4 + num_rows)) + click_unit = gps->mouse_y - 4 + first_row; + + switch (click_header) + { + case DISP_COLUMN_HAPPINESS: + if (enabler->mouse_lbut || enabler->mouse_rbut) + { + descending = enabler->mouse_lbut; + std::sort(units.begin(), units.end(), sortByHappiness); + } + break; + + case DISP_COLUMN_NAME: + if (enabler->mouse_lbut || enabler->mouse_rbut) + { + descending = enabler->mouse_rbut; + std::sort(units.begin(), units.end(), sortByName); + } + break; + + case DISP_COLUMN_PROFESSION: + if (enabler->mouse_lbut || enabler->mouse_rbut) + { + descending = enabler->mouse_rbut; + std::sort(units.begin(), units.end(), sortByProfession); + } + break; + + case DISP_COLUMN_LABORS: + if (enabler->mouse_lbut || enabler->mouse_rbut) + { + descending = enabler->mouse_lbut; + sort_skill = columns[click_labor].skill; + sort_labor = columns[click_labor].labor; + std::sort(units.begin(), units.end(), sortBySkill); + } + break; + } + + switch (click_body) + { + case DISP_COLUMN_HAPPINESS: + // do nothing + break; + + case DISP_COLUMN_NAME: + case DISP_COLUMN_PROFESSION: + // left-click to view, right-click to zoom + if (enabler->mouse_lbut) + { + sel_row = click_unit; + events->insert(interface_key::UNITJOB_VIEW); + } + if (enabler->mouse_rbut) + { + sel_row = click_unit; + events->insert(interface_key::UNITJOB_ZOOM_CRE); + } + break; + + case DISP_COLUMN_LABORS: + // left-click to toggle, right-click to just highlight + if (enabler->mouse_lbut || enabler->mouse_rbut) + { + sel_row = click_unit; + sel_column = click_labor; + if (enabler->mouse_lbut) + events->insert(interface_key::SELECT); + } + break; + } + enabler->mouse_lbut = enabler->mouse_rbut = 0; + } + UnitInfo *cur = units[sel_row]; if (events->count(interface_key::SELECT) && (cur->allowEdit) && (columns[sel_column].labor != unit_labor::NONE)) { @@ -647,6 +746,11 @@ void viewscreen_unitlaborsst::render() Screen::clear(); Screen::drawBorder(" Dwarf Manipulator - Manage Labors "); + + Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_HAPPINESS], 2, "Hap."); + Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_NAME], 2, "Name"); + Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_PROFESSION], 2, "Profession"); + for (int col = 0; col < col_widths[DISP_COLUMN_LABORS]; col++) { int col_offset = col + first_column; From 65a382a2d7b4c910fe498112687c9c584d5408cb Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 19 Sep 2012 15:55:08 +0400 Subject: [PATCH 2/6] Document some of the new stuff in the readme. --- README.rst | 247 ++++++++- Readme.html | 850 +++++++++++++++++++++---------- plugins/raw/entity_default.diff | 4 +- plugins/raw/reaction_spatter.txt | 10 + 4 files changed, 818 insertions(+), 293 deletions(-) diff --git a/README.rst b/README.rst index 6c463911a..8b6974abf 100644 --- a/README.rst +++ b/README.rst @@ -707,6 +707,8 @@ Options interface. :rename unit-profession "custom profession": Change proffession name of the highlighted unit/creature. +:rename building "name": Set a custom name for the selected building. + The building must be one of stockpile, workshop, furnace, trap or siege engine. reveal ====== @@ -907,6 +909,23 @@ Options and are not flagged as tame), but you are allowed to mark them for slaughter. Grabbing wagons results in some funny spam, then they are scuttled. +:stable-cursor: Saves the exact cursor position between t/q/k/d/etc menus of dwarfmode. +:patrol-duty: Makes Train orders not count as patrol duty to stop unhappy thoughts. + Does NOT fix the problem when soldiers go off-duty (i.e. civilian). +:readable-build-plate: Fixes rendering of creature weight limits in pressure plate build menu. +:stable-temp: Fixes performance bug 6012 by squashing jitter in temperature updates. + In very item-heavy forts with big stockpiles this can improve FPS by 50-100% +:fast-heat: Further improves temperature update performance by ensuring that 1 degree + of item temperature is crossed in no more than specified number of frames + when updating from the environment temperature. This reduces the time it + takes for stable-temp to stop updates again when equilibrium is disturbed. +:fix-dimensions: Fixes subtracting small amount of thread/cloth/liquid from a stack + by splitting the stack and subtracting from the remaining single item. + This is a necessary addition to the binary patch in bug 808. +:advmode-contained: Works around bug 6202, i.e. custom reactions with container inputs + in advmode. The issue is that the screen tries to force you to select + the contents separately from the container. This forcefully skips child + reagents. tubefill ======== @@ -1414,16 +1433,16 @@ using this mode for birds is not recommanded.) Will target any unit on a revealed tile of the map, including ambushers. -Ex: -:: +Ex:: + slayrace gob -To kill a single creature, select the unit with the 'v' cursor and: -:: +To kill a single creature, select the unit with the 'v' cursor and:: + slayrace him -To purify all elves on the map with fire (may have side-effects): -:: +To purify all elves on the map with fire (may have side-effects):: + slayrace elve magma @@ -1435,8 +1454,8 @@ This script registers a map tile as a magma source, and every 12 game ticks that tile receives 1 new unit of flowing magma. Place the game cursor where you want to create the source (must be a -flow-passable tile, and not too high in the sky) and call -:: +flow-passable tile, and not too high in the sky) and call:: + magmasource here To add more than 1 unit everytime, call the command again. @@ -1446,3 +1465,215 @@ To remove all placed sources, call ``magmasource stop``. With no argument, this command shows an help message and list existing sources. + +======================= +In-game interface tools +======================= + +These tools work by displaying dialogs or overlays in the game window, and +are mostly implemented by lua scripts. + + +Dwarf Manipulator +================= + +Implemented by the manipulator plugin. To activate, open the unit screen and press 'l'. + +This tool implements a Dwarf Therapist-like interface within the game ui. + + +Liquids +======= + +Implemented by the gui/liquids script. To use, bind to a key and activate in the 'k' mode. + +While active, use the suggested keys to switch the usual liquids parameters, and Enter +to select the target area and apply changes. + + +Mechanisms +========== + +Implemented by the gui/mechanims script. To use, bind to a key and activate in the 'q' mode. + +Lists mechanisms connected to the building, and their links. Navigating the list centers +the view on the relevant linked buildings. + +To exit, press ESC or Enter; ESC recenters on the original building, while Enter leaves +focus on the current one. Shift-Enter has an effect equivalent to pressing Enter, and then +re-entering the mechanisms ui. + + +Power Meter +=========== + +Front-end to the power-meter plugin implemented by the gui/power-meter script. Bind to a +key and activate after selecting Pressure Plate in the build menu. + +The script follows the general look and feel of the regular pressure plate build +configuration page, but configures parameters relevant to the modded power meter building. + + +Rename +====== + +Backed by the rename plugin, the gui/rename script allows entering the desired name +via a simple dialog in the game ui. + +* ``gui/rename [building]`` in 'q' mode changes the name of a building. + + The selected building must be one of stockpile, workshop, furnace, trap or siege engine. + +* ``gui/rename [unit]`` with a unit selected changes the nickname. + +* ``gui/rename unit-profession`` changes the selected unit's custom profession name. + +The ``building`` or ``unit`` are automatically assumed when in relevant ui state. + + +Room List +========= + +Implemented by the gui/room-list script. To use, bind to a key and activate in the 'q' mode, +either immediately or after opening the assign owner page. + +The script lists other rooms owned by the same owner, or by the unit selected in the assign +list, and allows unassigning them. + + +Siege Engine +============ + +Front-end to the siege-engine plugin implemented by the gui/siege-engine script. Bind to a +key and activate after selecting a siege engine in 'q' mode. + +The main mode displays the current target, selected ammo item type, linked stockpiles and +the allowed operator skill range. The map tile color is changed to reflect if it can be +hit by the selected engine. + +Pressing 'r' changes into the target selection mode, which works by highlighting two points +with Enter like all designations. When a target area is set, the engine projectiles are +aimed at that area, or units within it, instead of the vanilla four directions. + +Pressing 't' switches to stockpile selection. + +Exiting from the siege engine script via ESC reverts the view to the state prior to starting +the script. Shift-ESC retains the current viewport, and also exits from the 'q' mode to main +menu. + +**DISCLAIMER**: Siege engines are a very interesting feature, but currently nearly useless +because they haven't been updated since 2D and can only aim in four directions. This is an +attempt to bring them more up to date until Toady has time to work on it. Actual improvements, +e.g. like making siegers bring their own, are something only Toady can do. + + +========= +RAW hacks +========= + +These plugins detect certain structures in RAWs, and enhance them in various ways. + + +Steam Engine +============ + +The steam-engine plugin detects custom workshops with STEAM_ENGINE in +their token, and turns them into real steam engines. + +Rationale +--------- + +The vanilla game contains only water wheels and windmills as sources of +power, but windmills give relatively little power, and water wheels require +flowing water, which must either be a real river and thus immovable and +limited in supply, or actually flowing and thus laggy. + +Steam engines are an alternative to water reactors that actually makes +sense, and hopefully doesn't lag. Also, unlike e.g. animal treadmills, +it can be done just by combining existing features of the game engine +in a new way with some glue code and a bit of custom logic. + +Construction +------------ + +The workshop needs water as its input, which it takes via a +passable floor tile below it, like usual magma workshops do. +The magma version also needs magma. + +**ISSUE**: Since this building is a machine, and machine collapse +code cannot be modified, it would collapse over true open space. +As a loophole, down stair provides support to machines, while +being passable, so use them. + +After constructing the building itself, machines can be connected +to the edge tiles that look like gear boxes. Their exact position +is extracted from the workshop raws. + +**ISSUE**: Like with collapse above, part of the code involved in +machine connection cannot be modified. As a result, the workshop +can only immediately connect to machine components built AFTER it. +This also means that engines cannot be chained without intermediate +short axles that can be built later. + +Operation +--------- + +In order to operate the engine, queue the Stoke Boiler job (optionally +on repeat). A furnace operator will come, possibly bringing a bar of fuel, +and perform it. As a result, a "boiling water" item will appear +in the 't' view of the workshop. + +**NOTE**: The completion of the job will actually consume one unit +of the appropriate liquids from below the workshop. + +Every such item gives 100 power, up to a limit of 300 for coal, +and 500 for a magma engine. The building can host twice that +amount of items to provide longer autonomous running. When the +boiler gets filled to capacity, all queued jobs are suspended; +once it drops back to 3+1 or 5+1 items, they are re-enabled. + +While the engine is providing power, steam is being consumed. +The consumption speed includes a fixed 10% waste rate, and +the remaining 90% are applied proportionally to the actual +load in the machine. With the engine at nominal 300 power with +150 load in the system, it will consume steam for actual +300*(10% + 90%*150/300) = 165 power. + +Masterpiece mechanism and chain will decrease the mechanical +power drawn by the engine itself from 10 to 5. Masterpiece +barrel decreases waste rate by 4%. Masterpiece piston and pipe +decrease it by further 4%, and also decrease the whole steam +use rate by 10%. + +Explosions +---------- + +The engine must be constructed using barrel, pipe and piston +from fire-safe, or in the magma version magma-safe metals. + +During operation weak parts get gradually worn out, and +eventually the engine explodes. It should also explode if +toppled during operation by a building destroyer, or a +tantruming dwarf. + +Save files +---------- + +It should be safe to load and view engine-using fortresses +from a DF version without DFHack installed, except that in such +case the engines won't work. However actually making modifications +to them, or machines they connect to (including by pulling levers), +can easily result in inconsistent state once this plugin is +available again. The effects may be as weird as negative power +being generated. + + +Add Spatter +=========== + +This plugin makes reactions with names starting with ``SPATTER_ADD_`` +produce contaminants on the items instead of improvements. + +Intended to give some use to all those poisons that can be bought from caravans. + +To be really useful this needs patches from bug 808 and ``tweak fix-dimensions``. diff --git a/Readme.html b/Readme.html index 50ceae999..001e89b1f 100644 --- a/Readme.html +++ b/Readme.html @@ -3,7 +3,7 @@ - +