OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
cl_inv.h
1/*
2===========================================================================
3Copyright (C) 2023 the OpenMoHAA team
4
5This file is part of OpenMoHAA source code.
6
7OpenMoHAA source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12OpenMoHAA source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with OpenMoHAA source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23#pragma once
24
25typedef enum {
26 INV_MOVE_NONE,
27 INV_MOVE_BOB,
28 INV_MOVE_SPIN
29} inv_move_type;
30
31typedef enum {
32 INV_ALIGN_NONE,
33 INV_ALIGN_LEFT,
34 INV_ALIGN_RIGHT
35} inv_align_type;
36
37typedef enum {
38 INV_CASCADE_LEFT,
39 INV_CASCADE_RIGHT
40} inv_cascade_type;
41
42typedef enum {
43 INV_HUDANGLES_BASE,
44 INV_HUDANGLES_COMPASS,
45 INV_HUDANGLES_COMPASS_NEEDLE
46} inv_hudangles_type;
47
48class item_properties_t : public Class
49{
50public:
51 float scale;
52 Vector angles;
53 Vector angledeltas;
54 Vector rotateoffset;
55 Vector offset;
56 inv_move_type move;
57 str model;
58 str anim;
59};
60
61class inventory_item_t : public Class
62{
63public:
64 str name;
65 str ammoname;
66 int equip;
67 int width;
68 int height;
69 int barwidth;
70 int barheight;
71 int baroffsetY;
72 int baroffsetX;
73 float modelWindowX;
74 float modelWindowY;
75 float modelWindowWidth;
76 float modelWindowHeight;
77 bool selShaderOnTop;
78 bool checkammo;
79 str command;
80 inv_hudangles_type anglesType;
81 item_properties_t hudprops;
82 item_properties_t invprops;
83 UIReggedMaterial *bgshader;
84 UIReggedMaterial *barshader;
85 UIReggedMaterial *selshader;
86};
87
89{
90public:
91 str name;
92 bool bg_tile;
93 UIReggedMaterial *texture;
95 UIReggedMaterial *hoverTexture;
96 UIReggedMaterial *selTexture;
98
99 int IndexOfItemPtr(inventory_item_t *item);
100};
101
102inline int inventory_type_t::IndexOfItemPtr(inventory_item_t *item)
103{
104 for (int i = items.NumObjects(); i > 0; i--) {
105 if (items.ObjectAt(i) == item) {
106 return i;
107 }
108 }
109
110 return 0;
111}
112
113class inventory_t
114{
115public:
116 int typewidth;
117 int typeheight;
118 int horizoffset;
119 int vertoffset;
120 inv_align_type align;
121 inv_cascade_type cascade;
122 str selectsound;
123 str rejectsound;
124 str changesound;
126
127public:
128 inventory_t();
129 ~inventory_t();
130 inventory_t(const inventory_t& other);
131 inventory_t& operator=(const inventory_t& other);
132 void Clear();
133};
134
135class invlistener : public Listener
136{
137protected:
138 inventory_t *inv;
139 inventory_type_t *curtype;
140 inventory_item_t *curitem;
141 int defaultWidth;
142 int defaultHeight;
143 int defaultBarWidth;
144 int defaultBarHeight;
145 int defaultBarOffsetX;
146 int defaultBarOffsetY;
147
148public:
149 CLASS_PROTOTYPE(invlistener);
150
151protected:
152 void verify_curitem(void);
153 void verify_curtype(void);
154 void verify_one_arg(Event *ev);
155
156public:
157 invlistener(inventory_t *i);
158 invlistener();
159
160 bool Load(Script& script);
161 void InvSelectSound(Event *ev);
162 void InvRejectSound(Event *ev);
163 void InvChangeSound(Event *ev);
164 void InvWidth(Event *ev);
165 void InvHeight(Event *ev);
166 void InvHorizOffset(Event *ev);
167 void InvVertOffset(Event *ev);
168 void InvAlign(Event *ev);
169 void InvCascade(Event *ev);
170 void Typedef(Event *ev);
171 void OpenBrace(Event *ev);
172 void CloseBrace(Event *ev);
173 void ButtonShader(Event *ev);
174 void HoverShader(Event *ev);
175 void SelShader(Event *ev);
176 void Background(Event *ev);
177 void BackgroundTile(Event *ev);
178 void Width(Event *ev);
179 void Height(Event *ev);
180 void BarWidth(Event *ev);
181 void BarHeight(Event *ev);
182 void BarOffsetX(Event *ev);
183 void BarOffsetY(Event *ev);
184 void Item(Event *ev);
185 void Ammo(Event *ev);
186 void Equip(Event *ev);
187 void CheckAmmo(Event *ev);
188 void Command(Event *ev);
189 void BGShader(Event *ev);
190 void BarShader(Event *ev);
191 void SelItemShader(Event *ev);
192 void SelItemShaderOnTop(Event *ev);
193 void RotateOffset(Event *ev);
194 void Offset(Event *ev);
195 void Model(Event *ev);
196 void Anim(Event *ev);
197 void Scale(Event *ev);
198 void Angles(Event *ev);
199 void AngleDeltas(Event *ev);
200 void Move(Event *ev);
201 void ModelWindow(Event *ev);
202 void HudRotateOffset(Event *ev);
203 void HudOffset(Event *ev);
204 void HudModel(Event *ev);
205 void HudAnim(Event *ev);
206 void HudScale(Event *ev);
207 void HudAngles(Event *ev);
208 void HudAngleDeltas(Event *ev);
209 void HudMove(Event *ev);
210 void HudCompassAngles(Event *ev);
211 void HudCompassNeedleAngles(Event *ev);
212};
213
214bool CL_LoadInventory(const char *filename, inventory_t *inv);
215inventory_item_t *CL_GetInvItemByName(inventory_t *inv, const char *name);
216qboolean CL_HasInventoryItem(const char *name);
217void CL_AmmoCount(const char *name, int *ammo_count, int *max_ammo_count);
Definition container.h:85
Definition listener.h:246
Definition script.h:60
Definition uiwidget.h:35
Definition vector.h:61
Definition cl_inv.h:62
Definition cl_inv.h:114
Definition cl_inv.h:89
Definition cl_inv.h:49
Definition uiconsole.h:27
Definition str.h:77