MCPcopy Create free account
hub / github.com/DFHack/dfhack / ui_setup

Function ui_setup

plugins/embark-assistant/finder_ui.cpp:330–1348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328 //==========================================================================================================
329
330 void ui_setup(embark_assist::defs::find_callbacks find_callback, uint16_t max_inorganic) {
331// color_ostream_proxy out(Core::getInstance().getConsole());
332 if (!embark_assist::finder_ui::state) {
333 state = new(states);
334 state->finder_list_focus = 0;
335 state->finder_list_active = true;
336 state->find_callback = find_callback;
337 state->max_inorganic = max_inorganic;
338 }
339
340 fields i = first_fields;
341 ui_lists *element;
342 int16_t controllable_civs = 0;
343 int16_t max_civs;
344
345 for (int16_t i = 0; i < (int16_t)world->raws.entities.size(); i++) {
346 if (world->raws.entities[i]->flags.is_set(df::entity_raw_flags::CIV_CONTROLLABLE)) controllable_civs++;
347 }
348
349 for (int16_t i = 0; i < (int16_t)world->raws.entities.size(); i++) {
350 if (!world->raws.entities[i]->flags.is_set(df::entity_raw_flags::LAYER_LINKED) && // Animal people
351 !world->raws.entities[i]->flags.is_set(df::entity_raw_flags::GENERATED) && // Vault guardians
352 (controllable_civs > 1 || // Suppress the playable civ when only 1
353 !world->raws.entities[i]->flags.is_set(df::entity_raw_flags::CIV_CONTROLLABLE))) { // Too much work to change dynamically for modded worlds.
354 if (world->raws.entities[i]->translation == "") {
355 state->civs.push_back({ i, world->raws.entities[i]->code }); // Kobolds don't have a translation...
356 }
357 else {
358 state->civs.push_back({ i, world->raws.entities[i]->translation });
359 }
360 }
361 }
362
363 max_civs = state->civs.size();
364
365 if (controllable_civs > 1) max_civs = max_civs - 1;
366
367 while (true) {
368 element = new ui_lists;
369 element->current_display_value = 0;
370 element->current_index = 0;
371 element->focus = 0;
372
373 switch (i) {
374 case fields::x_dim:
375 for (int16_t k = 1; k <= 16; k++) {
376 element->list.push_back({ std::to_string(k), k });
377 }
378
379 break;
380
381 case fields::y_dim:
382 for (int16_t k = 1; k <= 16; k++) {
383 element->list.push_back({ std::to_string(k), k });
384 }
385
386 break;
387

Callers 1

initMethod · 0.85

Calls 7

appendFunction · 0.85
is_setMethod · 0.80
sortMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected