@@ -55,6 +55,7 @@ void trade_prices_window::ui_draw_foreground() {
55
55
56
56
vec2i items_pos = ui[" items" ].pos ;
57
57
vec2i current_pos = items_pos;
58
+ const auto &item_button = ui[" item_button" ];
58
59
int start_i = 0 ;
59
60
for (int i = 1 ; (start_i + i) < RESOURCES_MAX; i++) {
60
61
int image_offset = i;
@@ -71,6 +72,10 @@ void trade_prices_window::ui_draw_foreground() {
71
72
}
72
73
73
74
ui.icon (current_pos, resource);
75
+ const auto &btn = ui.button (" " , current_pos + item_button.pos , item_button.size , fonts_vec{}, UiFlags_NoBody);
76
+ if (btn.hovered ) {
77
+ ui::set_tooltip ((pcstr)lang_get_string (23 , resource));
78
+ }
74
79
75
80
const int buy_price = trade_price_buy (i);
76
81
const int sell_price = trade_price_sell (i);
@@ -93,36 +98,13 @@ int trade_prices_window::ui_handle_mouse(const mouse *m) {
93
98
return autoconfig_window::ui_handle_mouse (m);
94
99
}
95
100
96
- static int get_tooltip_resource (tooltip_context* c) {
97
- int x_base = screen_dialog_offset_x () + 124 ;
98
- int y = screen_dialog_offset_y () + 192 ;
99
- int x_mouse = c->mpos .x ;
100
- int y_mouse = c->mpos .y ;
101
-
102
- for (int i = 1 ; i < 16 ; i++) {
103
- int x = x_base + 30 * i;
104
- if (x <= x_mouse && x + 24 > x_mouse && y <= y_mouse && y + 24 > y_mouse)
105
- return i;
106
- }
107
- return 0 ;
108
- }
109
-
110
- static void get_tooltip (tooltip_context* c) {
111
- int resource = get_tooltip_resource (c);
112
- if (!resource) {
113
- return ;
114
- }
115
-
116
- c->text = (pcstr)lang_get_string (0 , 131 + resource);
117
- }
118
-
119
101
void window_trade_prices_show (void ) {
120
102
static window_type window = {
121
103
WINDOW_TRADE_PRICES,
122
104
[] { trade_prices_w.draw_background (); },
123
105
[] { trade_prices_w.ui_draw_foreground (); },
124
106
[] (const mouse *m, const hotkeys *h) { trade_prices_w.ui_handle_mouse (m); },
125
- nullptr
107
+ [] (tooltip_context *) { trade_prices_w. get_tooltip_text (); }
126
108
};
127
109
128
110
window_show (&window);
0 commit comments