Support trade viewscreens in Items::getSelectedItem.

develop
Alexander Gavrilov 2012-05-18 17:54:05 +04:00
parent 51ad697bf5
commit 3c44e22760
3 changed files with 33 additions and 1 deletions

@ -31,6 +31,8 @@ distribution.
#include <string> #include <string>
#include <vector> #include <vector>
#include "Core.h"
#include "RemoteClient.h" #include "RemoteClient.h"
typedef struct lua_State lua_State; typedef struct lua_State lua_State;

@ -54,7 +54,9 @@ using namespace DFHack;
#include "df/viewscreen_layer_workshop_profilest.h" #include "df/viewscreen_layer_workshop_profilest.h"
#include "df/viewscreen_layer_noblelistst.h" #include "df/viewscreen_layer_noblelistst.h"
#include "df/viewscreen_layer_overall_healthst.h" #include "df/viewscreen_layer_overall_healthst.h"
#include "df/viewscreen_layer_assigntradest.h"
#include "df/viewscreen_petst.h" #include "df/viewscreen_petst.h"
#include "df/viewscreen_tradegoodsst.h"
#include "df/ui_unit_view_mode.h" #include "df/ui_unit_view_mode.h"
#include "df/ui_sidebar_menus.h" #include "df/ui_sidebar_menus.h"
#include "df/ui_look_list.h" #include "df/ui_look_list.h"
@ -69,6 +71,7 @@ using namespace DFHack;
#include "df/interfacest.h" #include "df/interfacest.h"
#include "df/graphic.h" #include "df/graphic.h"
#include "df/layer_object_listst.h" #include "df/layer_object_listst.h"
#include "df/assign_trade_status.h"
using namespace df::enums; using namespace df::enums;
using df::global::gview; using df::global::gview;
@ -420,6 +423,33 @@ static df::item *getAnyItem(df::viewscreen *top)
return ref ? ref->getItem() : NULL; return ref ? ref->getItem() : NULL;
} }
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_layer_assigntradest, top))
{
auto list1 = getLayerList(screen, 0);
auto list2 = getLayerList(screen, 1);
if (!list1 || !list2 || !list2->bright)
return NULL;
int list_idx = vector_get(screen->visible_lists, list1->cursor, (int16_t)-1);
unsigned num_lists = sizeof(screen->lists)/sizeof(std::vector<int32_t>);
if (unsigned(list_idx) >= num_lists)
return NULL;
int idx = vector_get(screen->lists[list_idx], list2->cursor, -1);
if (auto info = vector_get(screen->info, idx))
return info->item;
return NULL;
}
if (VIRTUAL_CAST_VAR(screen, df::viewscreen_tradegoodsst, top))
{
if (screen->in_right_pane)
return vector_get(screen->broker_items, screen->broker_cursor);
else
return vector_get(screen->trader_items, screen->trader_cursor);
}
if (!Gui::dwarfmode_hotkey(top)) if (!Gui::dwarfmode_hotkey(top))
return NULL; return NULL;

@ -1 +1 @@
Subproject commit 3c8269225b1a68fd8803b7b7160d547247449789 Subproject commit f004804fd655efcb4bf9ea31bd95ae4f759937b4