| 1084 | } |
| 1085 | |
| 1086 | df::job *Gui::getAnyJob(df::viewscreen *top) { |
| 1087 | if (auto dfscreen = dfhack_viewscreen::try_cast(top)) |
| 1088 | return dfscreen->getSelectedJob(); |
| 1089 | |
| 1090 | if (matchFocusString("dwarfmode/Info/JOBS")) { |
| 1091 | auto &cri_job = game->main_interface.info.jobs.cri_job; |
| 1092 | // no way to select specific jobs; just get the first one |
| 1093 | return cri_job.size() ? cri_job[0]->jb : NULL; |
| 1094 | } |
| 1095 | |
| 1096 | if (auto unit = getAnyUnit(top)) |
| 1097 | return unit->job.current_job; |
| 1098 | |
| 1099 | if (auto job = getAnyWorkshopJob(top)) |
| 1100 | return job; |
| 1101 | |
| 1102 | if (auto cursor = getCursorPos(); cursor.isValid()) { |
| 1103 | for (auto *link = world->jobs.list.next; link; link = link->next) { |
| 1104 | df::job *job = link->item; |
| 1105 | if (!job) |
| 1106 | continue; |
| 1107 | if (job->pos == cursor) |
| 1108 | return job; |
| 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | return NULL; |
| 1113 | } |
| 1114 | |
| 1115 | df::job *Gui::getSelectedJob(color_ostream &out, bool quiet) |
| 1116 | { |
nothing calls this directly
no test coverage detected