Skip to content

Commit f7df515

Browse files
committed
More focus strings, correct docs
1 parent a5de0fb commit f7df515

2 files changed

Lines changed: 126 additions & 55 deletions

File tree

docs/dev/Lua API.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ Screens
955955
Returns a table of string representations of the current UI focuses.
956956
The strings have a "screen/foo/bar/baz..." format e.g..::
957957

958-
[1] = "dwarfmode/Info/CREATURES"
958+
[1] = "dwarfmode/Info/CREATURES/CITIZEN"
959959
[2] = "dwardmode/Squads"
960960

961961
* ``dfhack.gui.matchFocusString(focus_string)``

library/modules/Gui.cpp

Lines changed: 125 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,34 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
146146
{
147147
std::string newFocusString;
148148

149+
if(game->main_interface.main_designation_selected != -1) {
150+
newFocusString = baseFocus;
151+
newFocusString += "/Designate/" + enum_item_key(game->main_interface.main_designation_selected);
152+
focusStrings.push_back(newFocusString);
153+
}
149154
if (game->main_interface.info.open) {
150155
newFocusString = baseFocus;
151156
newFocusString += "/Info";
152157
newFocusString += "/" + enum_item_key(game->main_interface.info.current_mode);
158+
159+
switch(game->main_interface.info.current_mode) {
160+
case df::enums::info_interface_mode_type::CREATURES:
161+
newFocusString += "/" + enum_item_key(game->main_interface.info.creatures.current_mode);
162+
break;
163+
case df::enums::info_interface_mode_type::BUILDINGS:
164+
newFocusString += "/" + enum_item_key(game->main_interface.info.buildings.mode);
165+
break;
166+
case df::enums::info_interface_mode_type::LABOR:
167+
newFocusString += "/" + enum_item_key(game->main_interface.info.labor.mode);
168+
break;
169+
case df::enums::info_interface_mode_type::ARTIFACTS:
170+
newFocusString += "/" + enum_item_key(game->main_interface.info.artifacts.mode);
171+
break;
172+
case df::enums::info_interface_mode_type::JUSTICE:
173+
newFocusString += "/" + enum_item_key(game->main_interface.info.justice.current_mode);
174+
break;
175+
}
176+
153177
focusStrings.push_back(newFocusString);
154178
}
155179
if (game->main_interface.view_sheets.open) {
@@ -158,64 +182,111 @@ DEFINE_GET_FOCUS_STRING_HANDLER(dwarfmode)
158182
newFocusString += "/" + enum_item_key(game->main_interface.view_sheets.active_sheet);
159183
focusStrings.push_back(newFocusString);
160184
}
161-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::STOCKPILE) {
162-
newFocusString = baseFocus;
163-
// TODO: learn more about where /Some was used previously to ensure proper/consistent usage
164-
if (game->main_interface.stockpile.cur_bld) {
165-
newFocusString += "/Some";
166-
}
167-
newFocusString += "/Stockpile";
168-
focusStrings.push_back(newFocusString);
169-
}
170-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::STOCKPILE_PAINT) {
171-
newFocusString = baseFocus;
172-
newFocusString += "/Stockpile/Paint";
173-
focusStrings.push_back(newFocusString);
174-
}
175-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::HAULING) {
176-
newFocusString = baseFocus;
177-
newFocusString += "/Hauling";
178-
focusStrings.push_back(newFocusString);
179-
}
180-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::ZONE) {
185+
186+
if(game->main_interface.bottom_mode_selected != -1) {
181187
newFocusString = baseFocus;
182-
newFocusString += "/Zone";
183-
if (game->main_interface.civzone.cur_bld) {
184-
newFocusString += "/Some";
185-
newFocusString += "/" + enum_item_key(game->main_interface.civzone.cur_bld->type);
188+
189+
switch(game->main_interface.bottom_mode_selected) {
190+
case df::enums::main_bottom_mode_type::STOCKPILE:
191+
if (game->main_interface.stockpile.cur_bld) {
192+
newFocusString += "/Some";
193+
}
194+
newFocusString += "/Stockpile";
195+
break;
196+
case df::enums::main_bottom_mode_type::STOCKPILE_PAINT:
197+
newFocusString += "/Stockpile/Paint";
198+
break;
199+
case df::enums::main_bottom_mode_type::HAULING:
200+
newFocusString += "/Hauling";
201+
break;
202+
case df::enums::main_bottom_mode_type::ZONE:
203+
newFocusString += "/Zone";
204+
if (game->main_interface.civzone.cur_bld) {
205+
newFocusString += "/Some";
206+
newFocusString += "/" + enum_item_key(game->main_interface.civzone.cur_bld->type);
207+
}
208+
break;
209+
case df::enums::main_bottom_mode_type::ZONE_PAINT:
210+
newFocusString += "/Zone/Paint";
211+
212+
// TODO: figure out why enum_item_key doesn't work on this?
213+
switch(game->main_interface.civzone.adding_new_type) {
214+
case df::enums::civzone_type::MeetingHall:
215+
newFocusString += "/MeetingHall";
216+
break;
217+
case df::enums::civzone_type::Bedroom:
218+
newFocusString += "/Bedroom";
219+
break;
220+
case df::enums::civzone_type::DiningHall:
221+
newFocusString += "/DiningHall";
222+
break;
223+
case df::enums::civzone_type::Pen:
224+
newFocusString += "/Pen";
225+
break;
226+
case df::enums::civzone_type::Pond:
227+
newFocusString += "/Pond";
228+
break;
229+
case df::enums::civzone_type::WaterSource:
230+
newFocusString += "/WaterSource";
231+
break;
232+
case df::enums::civzone_type::Dungeon:
233+
newFocusString += "/Dungeon";
234+
break;
235+
case df::enums::civzone_type::FishingArea:
236+
newFocusString += "/FishingArea";
237+
break;
238+
case df::enums::civzone_type::SandCollection:
239+
newFocusString += "/SandCollection";
240+
break;
241+
case df::enums::civzone_type::Office:
242+
newFocusString += "/Office";
243+
break;
244+
case df::enums::civzone_type::Dormitory:
245+
newFocusString += "/Dormitory";
246+
break;
247+
case df::enums::civzone_type::Barracks:
248+
newFocusString += "/Barracks";
249+
break;
250+
case df::enums::civzone_type::ArcheryRange:
251+
newFocusString += "/ArcheryRange";
252+
break;
253+
case df::enums::civzone_type::Dump:
254+
newFocusString += "/Dump";
255+
break;
256+
case df::enums::civzone_type::AnimalTraining:
257+
newFocusString += "/AnimalTraining";
258+
break;
259+
case df::enums::civzone_type::Tomb:
260+
newFocusString += "/Tomb";
261+
break;
262+
case df::enums::civzone_type::PlantGathering:
263+
newFocusString += "/PlantGathering";
264+
break;
265+
case df::enums::civzone_type::ClayCollection:
266+
newFocusString += "/ClayCollection";
267+
break;
268+
}
269+
break;
270+
case df::enums::main_bottom_mode_type::BURROW:
271+
newFocusString += "/Burrow";
272+
break;
273+
case df::enums::main_bottom_mode_type::BURROW_PAINT:
274+
newFocusString += "/Burrow/Paint";
275+
break;
276+
case df::enums::main_bottom_mode_type::BUILDING:
277+
newFocusString += "/Building";
278+
break;
279+
case df::enums::main_bottom_mode_type::BUILDING_PLACEMENT:
280+
newFocusString += "/Building/Placement";
281+
break;
282+
case df::enums::main_bottom_mode_type::BUILDING_PICK_MATERIALS:
283+
newFocusString += "/Building/PickMaterials";
284+
break;
186285
}
286+
187287
focusStrings.push_back(newFocusString);
188288
}
189-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::ZONE_PAINT) {
190-
newFocusString = baseFocus;
191-
newFocusString += "/Zone/Paint";
192-
focusStrings.push_back(newFocusString);
193-
}
194-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::BURROW) {
195-
newFocusString = baseFocus;
196-
newFocusString += "/Burrow";
197-
focusStrings.push_back(newFocusString);
198-
}
199-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::BURROW_PAINT) {
200-
newFocusString = baseFocus;
201-
newFocusString += "/Burrow/Paint";
202-
focusStrings.push_back(newFocusString);
203-
}
204-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::BUILDING) {
205-
newFocusString = baseFocus;
206-
newFocusString += "/Building";
207-
focusStrings.push_back(newFocusString);
208-
}
209-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::BUILDING_PLACEMENT) {
210-
newFocusString = baseFocus;
211-
newFocusString += "/Building/Placement";
212-
focusStrings.push_back(newFocusString);
213-
}
214-
if (game->main_interface.bottom_mode_selected == df::enums::main_bottom_mode_type::BUILDING_PICK_MATERIALS) {
215-
newFocusString = baseFocus;
216-
newFocusString += "/Building/PickMaterials";
217-
focusStrings.push_back(newFocusString);
218-
}
289+
219290
if (game->main_interface.trade.open) {
220291
newFocusString = baseFocus;
221292
newFocusString += "/Trade";

0 commit comments

Comments
 (0)