-
Notifications
You must be signed in to change notification settings - Fork 285
/
Copy pathadvanced_inv.h
189 lines (165 loc) · 6.76 KB
/
advanced_inv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#pragma once
#ifndef CATA_SRC_ADVANCED_INV_H
#define CATA_SRC_ADVANCED_INV_H
#include <array>
#include <cctype>
#include <functional>
#include <string>
#include "advanced_inv_area.h"
#include "advanced_inv_listitem.h"
#include "advanced_inv_pane.h"
#include "cursesdef.h"
class input_context;
class item;
struct advanced_inv_save_state;
void create_advanced_inv();
/**
* Cancels ongoing move all action.
* TODO: Make this not needed.
*/
void cancel_aim_processing();
class advanced_inventory
{
public:
advanced_inventory();
~advanced_inventory();
void display();
/**
* Converts from screen relative location to game-space relative location
* for control rotation in isometric mode.
*/
aim_location screen_relative_location( aim_location area );
std::string get_location_key( aim_location area );
advanced_inv_area &get_one_square( const aim_location &loc ) {
return squares[loc];
}
private:
/**
* Refers to the two panes, used as index into @ref panes.
*/
enum side {
left = 0,
right = 1,
NUM_PANES = 2
};
static constexpr int head_height = 5;
// swap the panes and windows via std::swap()
void swap_panes();
// minimap that displays things around character
catacurses::window minimap;
catacurses::window mm_border;
const int minimap_width = 3;
const int minimap_height = 3;
void draw_minimap();
void refresh_minimap();
char get_minimap_sym( side p ) const;
bool inCategoryMode = false;
int itemsPerPage = 0;
int w_height = 0;
int w_width = 0;
int headstart = 0;
int colstart = 0;
bool recalc = false;
/**
* Which panels is active (item moved from there).
*/
side src;
/**
* Which panel is the destination (items want to go to there).
*/
side dest;
/**
* True if (and only if) the filter of the active panel is currently
* being edited.
*/
bool filter_edit = false;
/**
* Two panels (left and right) showing the items, use a value of @ref side
* as index.
*/
std::array<advanced_inventory_pane, NUM_PANES> panes;
static const advanced_inventory_pane null_pane;
std::array<advanced_inv_area, NUM_AIM_LOCATIONS> squares;
catacurses::window head;
bool exit = false;
advanced_inv_save_state *save_state;
/**
* registers all the ctxt for display()
*/
input_context register_ctxt() const;
/**
* a smaller chunk of display()
*/
void start_activity( aim_location destarea, advanced_inv_listitem *sitem, int &amount_to_move,
bool from_vehicle, bool to_vehicle ) const;
/**
* returns whether the display loop exits or not
*/
bool action_move_item( advanced_inv_listitem *sitem,
advanced_inventory_pane &dpane, const advanced_inventory_pane &spane,
const std::string &action );
void action_examine( advanced_inv_listitem *sitem, advanced_inventory_pane &spane );
// store/load settings (such as index, filter, etc)
void save_settings( bool only_panes );
void load_settings();
// used to return back to AIM when other activities queued are finished
void do_return_entry();
// returns true if currently processing a routine
// (such as `MOVE_ALL_ITEMS' with `AIM_ALL' source)
bool is_processing() const;
static std::string get_sortname( advanced_inv_sortby sortby );
bool move_all_items( bool nested_call = false );
void print_items( const advanced_inventory_pane &pane, bool active );
void recalc_pane( side p );
void redraw_pane( side p );
void redraw_sidebar();
// Returns the x coordinate where the header started. The header is
// displayed right of it, everything left of it is till free.
int print_header( advanced_inventory_pane &pane, aim_location sel );
void init();
/**
* Translate an action ident from the input context to an aim_location.
* @param action Action ident to translate
* @param ret If the action ident referred to a location, its id is stored
* here. Only valid when the function returns true.
* @return true if the action did refer to an location (which has been
* stored in ret), false otherwise.
*/
bool get_square( const std::string &action, aim_location &ret );
void change_square( aim_location changeSquare, advanced_inventory_pane &dpane,
advanced_inventory_pane &spane );
/**
* Show the sort-by menu and change the sorting of this pane accordingly.
* @return whether the sort order was actually changed.
*/
bool show_sort_menu( advanced_inventory_pane &pane );
/**
* Checks whether one can put items into the supplied location.
* If the supplied location is AIM_ALL, query for the actual location
* (stores the result in def) and check that destination.
* @return false if one can not put items in the destination, true otherwise.
* The result true also indicates the def is not AIM_ALL (because the
* actual location has been queried).
*/
bool query_destination( aim_location &def );
/**
* Move content of source container into destination container (destination pane = AIM_CONTAINER)
* @param src_container Source container
* @param dest_container Destination container
*/
bool move_content( item &src_container, item &dest_container );
/**
* Setup how many items/charges (if counted by charges) should be moved.
* @param destarea Where to move to. This must not be AIM_ALL.
* @param sitem The source item, it must contain a valid reference to an item!
* @param action The action we are querying
* @param amount The input value is ignored, contains the amount that should
* be moved. Only valid if this returns true.
* @return false if nothing should/can be moved. True only if there can and
* should be moved. A return value of true indicates that amount now contains
* a valid item count to be moved.
*/
bool query_charges( aim_location destarea, const advanced_inv_listitem &sitem,
const std::string &action, int &amount );
};
#endif // CATA_SRC_ADVANCED_INV_H