Support the new unitlist screen; it's same as joblist, but with pages.

develop
Alexander Gavrilov 2012-02-20 17:53:39 +04:00
parent 80cedd2ff8
commit 02e486be88
1 changed files with 20 additions and 3 deletions

@ -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<df::viewscreen_dwarfmodest>(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<df::viewscreen_joblistst>(top);
// Require the unit or jobs list
return !!strict_virtual_cast<df::viewscreen_joblistst>(top) ||
!!strict_virtual_cast<df::viewscreen_unitlistst>(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);