Skip to content

Commit

Permalink
Merge remote-tracking branch 'PatrikLundell/embark-assistant' into de…
Browse files Browse the repository at this point in the history
…velop
  • Loading branch information
lethosor committed Jul 13, 2018
2 parents 14725bc + baef5ca commit 2105105
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 35 deletions.
2 changes: 1 addition & 1 deletion docs/Plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ This plugin provides embark site selection help. It has to be run with the
extended (and correct(?)) resource information for the embark rectangle as well
as normally undisplayed sites in the current embark region. It also has a site
selection tool with more options than DF's vanilla search tool. For detailed
help invoke the in game info screen. Requires 46 lines to display properly.
help invoke the in game info screen.

.. _embark-tools:

Expand Down
5 changes: 4 additions & 1 deletion docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:

## Misc Improvements
- Reduced time for designation jobs from tools like `digv` to be assigned workers
- `embark-assistant`: switched to standard scrolling keys, improved spacing slightly
- `embark-assistant`:
- Switched to standard scrolling keys, improved spacing slightly
- Introduced scrolling of Finder search criteria, removing requirement for 46 lines to work properly (Help/Info still formatted for 46 lines).
- Added Freezing search criterion, allowing searches for NA/Frozen/At_Least_Partial/Partial/At_Most_Partial/Never Freezing embarks.
- `rejuvenate`:
- Added ``-all`` argument to apply to all citizens
- Added ``-force`` to include units under 20 years old
Expand Down
18 changes: 9 additions & 9 deletions plugins/embark-assistant/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace embark_assist {
int16_t biome_index[10]; // Indexed through biome_offset; -1 = null, Index of region, [0] not used
int16_t biome[10]; // Indexed through biome_offset; -1 = null, df::biome_type, [0] not used
uint8_t biome_count;
int16_t min_temperature[10]; // Indexed through biome_offset; -30000 = null, Urists - 10000, [0] not used
int16_t max_temperature[10]; // Indexed through biome_offset; -30000 = null, Urists - 10000, [0] not used
bool blood_rain[10];
bool blood_rain_possible;
bool blood_rain_full;
Expand Down Expand Up @@ -229,16 +231,14 @@ namespace embark_assist {
None
};

/* // Future possible enhancement
enum class freezing_ranges : int8_t {
NA = -1,
Permanent,
At_Least_Partial,
Partial,
At_Most_Partial,
Never
NA = -1,
Permanent,
At_Least_Partial,
Partial,
At_Most_Partial,
Never
};
*/

struct finders {
uint16_t x_dim;
Expand All @@ -256,7 +256,7 @@ namespace embark_assist {
soil_ranges soil_min;
all_present_ranges soil_min_everywhere;
soil_ranges soil_max;
/*freezing_ranges freezing;*/
freezing_ranges freezing;
yes_no_ranges blood_rain; // Will probably blow up with the magic release arcs...
syndrome_rain_ranges syndrome_rain;
reanimation_ranges reanimation;
Expand Down
106 changes: 90 additions & 16 deletions plugins/embark-assistant/finder_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "df/material_flags.h"
#include "df/viewscreen_choose_start_sitest.h"
#include "df/world.h"
#include "df/world_data.h"
#include "df/world_region_type.h"
#include "df/world_raws.h"

Expand Down Expand Up @@ -46,6 +47,7 @@ namespace embark_assist {
soil_min,
soil_min_everywhere,
soil_max,
freezing,
blood_rain,
syndrome_rain,
reanimation,
Expand Down Expand Up @@ -574,6 +576,52 @@ namespace embark_assist {

break;

case fields::freezing:
{
embark_assist::defs::freezing_ranges k = embark_assist::defs::freezing_ranges::NA;
while (true) {
switch (k) {
case embark_assist::defs::freezing_ranges::NA:
element->list.push_back({ "N/A", static_cast<int8_t>(k) });
break;

case embark_assist::defs::freezing_ranges::Permanent:
element->list.push_back({ "Permanent", static_cast<int8_t>(k) });
break;

case embark_assist::defs::freezing_ranges::At_Least_Partial:
element->list.push_back({ "At Least Partially Frozen", static_cast<int8_t>(k) });
break;

case embark_assist::defs::freezing_ranges::Partial:
element->list.push_back({ "Partially Frozen", static_cast<int8_t>(k) });
break;

case embark_assist::defs::freezing_ranges::At_Most_Partial:
element->list.push_back({ "At Most Partially Frozen", static_cast<int8_t>(k) });
break;

case embark_assist::defs::freezing_ranges::Never:
element->list.push_back({ "Never Frozen", static_cast<int8_t>(k) });
break;

}

if (k == embark_assist::defs::freezing_ranges::Never ||
(world->world_data->world_height != 17 && // Can't handle temperature in non standard height worlds.
world->world_data->world_height != 33 &&
world->world_data->world_height != 65 &&
world->world_data->world_height != 129 &&
world->world_data->world_height != 257)) {
break;
}

k = static_cast <embark_assist::defs::freezing_ranges>(static_cast<int8_t>(k) + 1);
}
}

break;

case fields::syndrome_rain:
{
embark_assist::defs::syndrome_rain_ranges k = embark_assist::defs::syndrome_rain_ranges::NA;
Expand Down Expand Up @@ -917,6 +965,10 @@ namespace embark_assist {
state->finder_list.push_back({ "Min Soil Everywhere", static_cast<int8_t>(i) });
break;

case fields::freezing:
state->finder_list.push_back({ "Freezing", static_cast<int8_t>(i) });
break;

case fields::blood_rain:
state->finder_list.push_back({ "Blood Rain", static_cast<int8_t>(i) });
break;
Expand Down Expand Up @@ -1141,6 +1193,11 @@ namespace embark_assist {
static_cast<embark_assist::defs::all_present_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
break;

case fields::freezing:
finder.freezing =
static_cast<embark_assist::defs::freezing_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
break;

case fields::blood_rain:
finder.blood_rain =
static_cast<embark_assist::defs::yes_no_ranges>(state->ui[static_cast<uint8_t>(i)]->current_value);
Expand Down Expand Up @@ -1366,7 +1423,8 @@ namespace embark_assist {
void ViewscreenFindUi::render() {
// color_ostream_proxy out(Core::getInstance().getConsole());
auto screen_size = DFHack::Screen::getWindowSize();
const int list_column = 53;
uint16_t top_row = 2;
uint16_t list_column = 53;
uint16_t offset = 0;

Screen::clear();
Expand All @@ -1391,57 +1449,73 @@ namespace embark_assist {
embark_assist::screen::paintString(lr_pen, 60, 1, DFHack::Screen::getKeyDisplay(df::interface_key::CUSTOM_L).c_str());
embark_assist::screen::paintString(white_pen, 61, 1, ": Load");

for (uint16_t i = 0; i < state->finder_list.size(); i++) {
// Implement scrolling lists if they don't fit on the screen.
if (int32_t(state->finder_list.size()) > screen_size.y - top_row - 1) {
offset = (screen_size.y - top_row - 1) / 2;
if (state->finder_list_focus < offset) {
offset = 0;
}
else {
offset = state->finder_list_focus - offset;
}

if (int32_t(state->finder_list.size() - offset) < screen_size.y - top_row - 1) {
offset = static_cast<uint16_t>(state->finder_list.size()) - (screen_size.y - top_row - 1);
}
}

for (uint16_t i = offset; i < state->finder_list.size(); i++) {
if (i == state->finder_list_focus) {
if (state->finder_list_active) {
embark_assist::screen::paintString(active_pen, 1, 2 + i, state->finder_list[i].text);
embark_assist::screen::paintString(active_pen, 1, top_row + i - offset, state->finder_list[i].text);
}
else {
embark_assist::screen::paintString(passive_pen, 1, 2 + i, state->finder_list[i].text);
embark_assist::screen::paintString(passive_pen, 1, top_row + i - offset, state->finder_list[i].text);
}

embark_assist::screen::paintString(active_pen,
21,
2 + i,
top_row + i - offset,
state->ui[i]->list[state->ui[i]->current_display_value].text);
}
else {
embark_assist::screen::paintString(normal_pen, 1, 2 + i, state->finder_list[i].text);
embark_assist::screen::paintString(normal_pen, 1, top_row + i - offset, state->finder_list[i].text);

embark_assist::screen::paintString(white_pen,
21,
2 + i,
top_row + i - offset,
state->ui[i]->list[state->ui[i]->current_display_value].text);
}

}

// Implement scrolling lists if they don't fit on the screen.
if (int32_t(state->ui[state->finder_list_focus]->list.size()) > screen_size.y - 3) {
offset = (screen_size.y - 3) / 2;
offset = 0;

if (int32_t(state->ui[state->finder_list_focus]->list.size()) > screen_size.y - top_row - 1) {
offset = (screen_size.y - top_row - 1) / 2;
if (state->ui[state->finder_list_focus]->current_index < offset) {
offset = 0;
}
else {
offset = state->ui[state->finder_list_focus]->current_index - offset;
}

if (int32_t(state->ui[state->finder_list_focus]->list.size() - offset) < screen_size.y - 3) {
offset = static_cast<uint16_t>(state->ui[state->finder_list_focus]->list.size()) - (screen_size.y - 3);
if (int32_t(state->ui[state->finder_list_focus]->list.size() - offset) < screen_size.y - top_row - 1) {
offset = static_cast<uint16_t>(state->ui[state->finder_list_focus]->list.size()) - (screen_size.y - top_row - 1);
}
}

for (uint16_t i = 0; i < state->ui[state->finder_list_focus]->list.size(); i++) {
for (uint16_t i = offset; i < state->ui[state->finder_list_focus]->list.size(); i++) {
if (i == state->ui[state->finder_list_focus]->current_index) {
if (!state->finder_list_active) { // Negated expression to get the display lines in the same order as above.
embark_assist::screen::paintString(active_pen, list_column, 2 + i - offset, state->ui[state->finder_list_focus]->list[i].text);
embark_assist::screen::paintString(active_pen, list_column, top_row + i - offset, state->ui[state->finder_list_focus]->list[i].text);
}
else {
embark_assist::screen::paintString(passive_pen, list_column, 2 + i - offset, state->ui[state->finder_list_focus]->list[i].text);
embark_assist::screen::paintString(passive_pen, list_column, top_row + i - offset, state->ui[state->finder_list_focus]->list[i].text);
}
}
else {
embark_assist::screen::paintString(normal_pen, list_column, 2 + i - offset, state->ui[state->finder_list_focus]->list[i].text);
embark_assist::screen::paintString(normal_pen, list_column, top_row + i - offset, state->ui[state->finder_list_focus]->list[i].text);
}
}

Expand Down
13 changes: 8 additions & 5 deletions plugins/embark-assistant/help_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ namespace embark_assist{
help_text.push_back("- Site find search. Richer set of selection criteria than the vanilla");
help_text.push_back(" DF Find that Embark Assistant suppresses (by using the same key).");
help_text.push_back("");
help_text.push_back("The functionality requires a screen height of at least 46 lines to display");
help_text.push_back("correctly (that's the height of the Finder screen), as fitting everything");
help_text.push_back("onto a standard 80*25 screen would be too challenging. The help is adjusted");
help_text.push_back("to fit into onto an 80*46 screen as well.");
help_text.push_back("The functionality requires a screen height larger than the default 80*25,");
help_text.push_back("and while the Finder screen provides for scrolling, the embark resources");
help_text.push_back("list will spill over the bottom if many resources are present and the");
help_text.push_back("screen isn't deep enough. This help info is adapted to fit onto 80*46.");
help_text.push_back("This help/info is split over several screens, and you can move between them");
help_text.push_back("using the TAB/Shift-TAB keys, and leave the help from any screen using ESC.");
help_text.push_back("");
Expand Down Expand Up @@ -209,6 +209,9 @@ namespace embark_assist{
help_text.push_back("Min/Max soil uses the same terminology as DF for 1-4. The Min Soil");
help_text.push_back("Everywhere toggles the Min Soil parameter between acting as All and");
help_text.push_back("and Present.");
help_text.push_back("Freezing allows you to select embarks to select/avoid various freezing");
help_text.push_back("conditions. Note that the minimum temperature is held for only 10 ticks");
help_text.push_back("in many embarks.");
help_text.push_back("Syndrome Rain allows you to search for Permanent and Temporary syndromes,");
help_text.push_back("where Permanent allows for Temporary ones as well, but not the reverse, as");
help_text.push_back("Not Permanent matches everything except Permanent syndromes.");
Expand Down Expand Up @@ -261,7 +264,7 @@ namespace embark_assist{
help_text.push_back(" reaching caverns that have been removed at world gen to fail to be");
help_text.push_back(" generated at all. It's likely this bug also affects magma pools.");
help_text.push_back(" This plugin does not address this but scripts can correct it.");
help_text.push_back("Version 0.4 2018-06-21");
help_text.push_back("Version 0.5 2018-07-13");

break;
}
Expand Down
Loading

0 comments on commit 2105105

Please sign in to comment.