From 02e486be885ebeecc90b63bf7a5fb949aaedc833 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 20 Feb 2012 17:53:39 +0400 Subject: [PATCH] Support the new unitlist screen; it's same as joblist, but with pages. --- library/modules/Gui.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 5935dd32e..30ef16d96 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -46,6 +46,7 @@ using namespace DFHack; #include "df/global_objects.h" #include "df/viewscreen_dwarfmodest.h" #include "df/viewscreen_joblistst.h" +#include "df/viewscreen_unitlistst.h" #include "df/viewscreen_itemst.h" #include "df/ui_unit_view_mode.h" #include "df/ui_sidebar_menus.h" @@ -83,11 +84,11 @@ bool DFHack::dwarfmode_hotkey(Core *, df::viewscreen *top) return !!strict_virtual_cast(top); } -//FIXME: this class has a second part (split off in 31.xx)! bool DFHack::unitjobs_hotkey(Core *, df::viewscreen *top) { - // Require the main dwarf mode screen - return !!strict_virtual_cast(top); + // Require the unit or jobs list + return !!strict_virtual_cast(top) || + !!strict_virtual_cast(top); } bool DFHack::item_details_hotkey(Core *, df::viewscreen *top) @@ -230,6 +231,9 @@ bool DFHack::any_job_hotkey(Core *c, df::viewscreen *top) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top)) return vector_get(screen->jobs, screen->cursor_pos) != NULL; + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top)) + return vector_get(screen->jobs[screen->page], screen->cursor_pos[screen->page]) != NULL; + return workshop_job_hotkey(c,top); } @@ -246,6 +250,16 @@ df::job *DFHack::getSelectedJob(Core *c, bool quiet) return job; } + else if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top)) + { + int page = screen->page; + df::job *job = vector_get(screen->jobs[page], screen->cursor_pos[page]); + + if (!job && !quiet) + c->con.printerr("Selected unit has no job\n"); + + return job; + } else return getSelectedWorkshopJob(c, quiet); } @@ -262,6 +276,9 @@ static df::unit *getAnyUnit(Core *c, df::viewscreen *top) if (VIRTUAL_CAST_VAR(screen, df::viewscreen_joblistst, top)) return vector_get(screen->units, screen->cursor_pos); + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_unitlistst, top)) + return vector_get(screen->units[screen->page], screen->cursor_pos[screen->page]); + if (VIRTUAL_CAST_VAR(screen, df::viewscreen_itemst, top)) { df::general_ref *ref = vector_get(screen->entry_ref, screen->cursor_pos);