1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "ags/engine/ac/inv_window.h"
24 #include "ags/shared/ac/common.h"
25 #include "ags/engine/ac/character_extras.h"
26 #include "ags/shared/ac/character_info.h"
27 #include "ags/engine/ac/draw.h"
28 #include "ags/engine/ac/event.h"
29 #include "ags/engine/ac/game_state.h"
30 #include "ags/shared/ac/game_setup_struct.h"
31 #include "ags/engine/ac/global_character.h"
32 #include "ags/engine/ac/global_display.h"
33 #include "ags/engine/ac/global_room.h"
34 #include "ags/engine/ac/mouse.h"
35 #include "ags/engine/ac/sys_events.h"
36 #include "ags/engine/debugging/debug_log.h"
37 #include "ags/engine/gui/gui_dialog.h"
38 #include "ags/shared/gui/gui_main.h"
39 #include "ags/engine/main/game_run.h"
40 #include "ags/engine/platform/base/ags_platform_driver.h"
41 #include "ags/shared/ac/sprite_cache.h"
42 #include "ags/engine/script/runtime_script_value.h"
43 #include "ags/engine/ac/dynobj/cc_character.h"
44 #include "ags/engine/ac/dynobj/cc_inventory.h"
45 #include "ags/shared/util/math.h"
46 #include "ags/engine/media/audio/audio_system.h"
47 #include "ags/engine/ac/timer.h"
48 #include "ags/shared/util/wgt2_allg.h"
49 #include "ags/shared/debugging/out.h"
50 #include "ags/engine/script/script_api.h"
51 #include "ags/engine/script/script_runtime.h"
52 #include "ags/globals.h"
53
54 namespace AGS3 {
55
56 using namespace AGS::Shared;
57
58 // *** INV WINDOW FUNCTIONS
59
InvWindow_SetCharacterToUse(GUIInvWindow * guii,CharacterInfo * chaa)60 void InvWindow_SetCharacterToUse(GUIInvWindow *guii, CharacterInfo *chaa) {
61 if (chaa == nullptr)
62 guii->CharId = -1;
63 else
64 guii->CharId = chaa->index_id;
65 // reset to top of list
66 guii->TopItem = 0;
67
68 guii->NotifyParentChanged();
69 }
70
InvWindow_GetCharacterToUse(GUIInvWindow * guii)71 CharacterInfo *InvWindow_GetCharacterToUse(GUIInvWindow *guii) {
72 if (guii->CharId < 0)
73 return nullptr;
74
75 return &_GP(game).chars[guii->CharId];
76 }
77
InvWindow_SetItemWidth(GUIInvWindow * guii,int newwidth)78 void InvWindow_SetItemWidth(GUIInvWindow *guii, int newwidth) {
79 guii->ItemWidth = newwidth;
80 guii->OnResized();
81 }
82
InvWindow_GetItemWidth(GUIInvWindow * guii)83 int InvWindow_GetItemWidth(GUIInvWindow *guii) {
84 return guii->ItemWidth;
85 }
86
InvWindow_SetItemHeight(GUIInvWindow * guii,int newhit)87 void InvWindow_SetItemHeight(GUIInvWindow *guii, int newhit) {
88 guii->ItemHeight = newhit;
89 guii->OnResized();
90 }
91
InvWindow_GetItemHeight(GUIInvWindow * guii)92 int InvWindow_GetItemHeight(GUIInvWindow *guii) {
93 return guii->ItemHeight;
94 }
95
InvWindow_SetTopItem(GUIInvWindow * guii,int topitem)96 void InvWindow_SetTopItem(GUIInvWindow *guii, int topitem) {
97 if (guii->TopItem != topitem) {
98 guii->TopItem = topitem;
99 guii->NotifyParentChanged();
100 }
101 }
102
InvWindow_GetTopItem(GUIInvWindow * guii)103 int InvWindow_GetTopItem(GUIInvWindow *guii) {
104 return guii->TopItem;
105 }
106
InvWindow_GetItemsPerRow(GUIInvWindow * guii)107 int InvWindow_GetItemsPerRow(GUIInvWindow *guii) {
108 return guii->ColCount;
109 }
110
InvWindow_GetItemCount(GUIInvWindow * guii)111 int InvWindow_GetItemCount(GUIInvWindow *guii) {
112 return _G(charextra)[guii->GetCharacterId()].invorder_count;
113 }
114
InvWindow_GetRowCount(GUIInvWindow * guii)115 int InvWindow_GetRowCount(GUIInvWindow *guii) {
116 return guii->RowCount;
117 }
118
InvWindow_ScrollDown(GUIInvWindow * guii)119 void InvWindow_ScrollDown(GUIInvWindow *guii) {
120 if ((_G(charextra)[guii->GetCharacterId()].invorder_count) >
121 (guii->TopItem + (guii->ColCount * guii->RowCount))) {
122 guii->TopItem += guii->ColCount;
123 guii->NotifyParentChanged();
124 }
125 }
126
InvWindow_ScrollUp(GUIInvWindow * guii)127 void InvWindow_ScrollUp(GUIInvWindow *guii) {
128 if (guii->TopItem > 0) {
129 guii->TopItem -= guii->ColCount;
130 if (guii->TopItem < 0)
131 guii->TopItem = 0;
132
133 guii->NotifyParentChanged();
134 }
135 }
136
InvWindow_GetItemAtIndex(GUIInvWindow * guii,int index)137 ScriptInvItem *InvWindow_GetItemAtIndex(GUIInvWindow *guii, int index) {
138 if ((index < 0) || (index >= _G(charextra)[guii->GetCharacterId()].invorder_count))
139 return nullptr;
140 return &_G(scrInv)[_G(charextra)[guii->GetCharacterId()].invorder[index]];
141 }
142
143 //=============================================================================
144
offset_over_inv(GUIInvWindow * inv)145 int offset_over_inv(GUIInvWindow *inv) {
146 if (inv->ItemWidth <= 0 || inv->ItemHeight <= 0)
147 return -1;
148 int mover = _G(mouse_ifacebut_xoffs) / data_to_game_coord(inv->ItemWidth);
149 // if it's off the edge of the visible items, ignore
150 if (mover >= inv->ColCount)
151 return -1;
152 mover += (_G(mouse_ifacebut_yoffs) / data_to_game_coord(inv->ItemHeight)) * inv->ColCount;
153 if (mover >= inv->ColCount * inv->RowCount)
154 return -1;
155
156 mover += inv->TopItem;
157 if ((mover < 0) || (mover >= _G(charextra)[inv->GetCharacterId()].invorder_count))
158 return -1;
159
160 return _G(charextra)[inv->GetCharacterId()].invorder[mover];
161 }
162
163 //
164 // NOTE: This is an old default inventory screen implementation,
165 // which became completely obsolete after AGS 2.72.
166 //
167
168 #define ICONSPERLINE 4
169
170 struct DisplayInvItem {
171 int num;
172 int sprnum;
173 };
174
175 struct InventoryScreen {
176 static const int ARROWBUTTONWID = 11;
177
178 int BUTTONAREAHEIGHT;
179 int cmode;
180 int toret;
181 int top_item;
182 int num_visible_items;
183 int MAX_ITEMAREA_HEIGHT;
184 int wasonitem;
185 int bartop;
186 int barxp;
187 int numitems;
188 int widest;
189 int highest;
190 int windowwid;
191 int windowhit;
192 int windowxp;
193 int windowyp;
194 int buttonyp;
195 DisplayInvItem dii[MAX_INV];
196 int btn_look_sprite;
197 int btn_select_sprite;
198 int btn_ok_sprite;
199
200 int break_code;
201
202 void Prepare();
203 int Redraw();
204 void Draw(Bitmap *ds);
205 void RedrawOverItem(Bitmap *ds, int isonitem);
206 bool Run();
207 void Close();
208 };
209
210 InventoryScreen InvScr;
211
Prepare()212 void InventoryScreen::Prepare() {
213 BUTTONAREAHEIGHT = get_fixed_pixel_size(30);
214 cmode = CURS_ARROW;
215 toret = -1;
216 top_item = 0;
217 num_visible_items = 0;
218 MAX_ITEMAREA_HEIGHT = ((_GP(play).GetUIViewport().GetHeight() - BUTTONAREAHEIGHT) - get_fixed_pixel_size(20));
219 _G(in_inv_screen)++;
220 _G(inv_screen_newroom) = -1;
221
222 // Sprites 2041, 2042 and 2043 were hardcoded in the older versions of
223 // the engine to be used in the built-in inventory window.
224 // If they did not exist engine first fell back to sprites 0, 1, 2 instead.
225 // Fun fact: this fallback does not seem to be intentional, and was a
226 // coincidental result of SpriteCache incorrectly remembering "last seeked
227 // sprite" as 2041/2042/2043 while in fact stream was after sprite 0.
228 if (_GP(spriteset)[2041] == nullptr || _GP(spriteset)[2042] == nullptr || _GP(spriteset)[2043] == nullptr)
229 debug_script_warn("InventoryScreen: one or more of the inventory screen graphics (sprites 2041, 2042, 2043) does not exist, fallback to sprites 0, 1, 2 instead");
230 btn_look_sprite = _GP(spriteset)[2041] != nullptr ? 2041 : 0;
231 btn_select_sprite = _GP(spriteset)[2042] != nullptr ? 2042 : (_GP(spriteset)[1] != nullptr ? 1 : 0);
232 btn_ok_sprite = _GP(spriteset)[2043] != nullptr ? 2043 : (_GP(spriteset)[2] != nullptr ? 2 : 0);
233
234 break_code = 0;
235 }
236
Redraw()237 int InventoryScreen::Redraw() {
238 numitems = 0;
239 widest = 0;
240 highest = 0;
241 if (_G(charextra)[_GP(game).playercharacter].invorder_count < 0)
242 update_invorder();
243 if (_G(charextra)[_GP(game).playercharacter].invorder_count == 0) {
244 DisplayMessage(996);
245 _G(in_inv_screen)--;
246 return -1;
247 }
248
249 if (_G(inv_screen_newroom) >= 0) {
250 _G(in_inv_screen)--;
251 NewRoom(_G(inv_screen_newroom));
252 return -1;
253 }
254
255 for (int i = 0; i < _G(charextra)[_GP(game).playercharacter].invorder_count; ++i) {
256 if (_GP(game).invinfo[_G(charextra)[_GP(game).playercharacter].invorder[i]].name[0] != 0) {
257 dii[numitems].num = _G(charextra)[_GP(game).playercharacter].invorder[i];
258 dii[numitems].sprnum = _GP(game).invinfo[_G(charextra)[_GP(game).playercharacter].invorder[i]].pic;
259 int snn = dii[numitems].sprnum;
260 if (_GP(game).SpriteInfos[snn].Width > widest) widest = _GP(game).SpriteInfos[snn].Width;
261 if (_GP(game).SpriteInfos[snn].Height > highest) highest = _GP(game).SpriteInfos[snn].Height;
262 numitems++;
263 }
264 }
265 if (numitems != _G(charextra)[_GP(game).playercharacter].invorder_count)
266 quit("inconsistent inventory calculations");
267
268 widest += get_fixed_pixel_size(4);
269 highest += get_fixed_pixel_size(4);
270 num_visible_items = (MAX_ITEMAREA_HEIGHT / highest) * ICONSPERLINE;
271
272 windowhit = highest * (numitems / ICONSPERLINE) + get_fixed_pixel_size(4);
273 if ((numitems % ICONSPERLINE) != 0) windowhit += highest;
274 if (windowhit > MAX_ITEMAREA_HEIGHT) {
275 windowhit = (MAX_ITEMAREA_HEIGHT / highest) * highest + get_fixed_pixel_size(4);
276 }
277 windowhit += BUTTONAREAHEIGHT;
278
279 windowwid = widest * ICONSPERLINE + get_fixed_pixel_size(4);
280 if (windowwid < get_fixed_pixel_size(105)) windowwid = get_fixed_pixel_size(105);
281 windowxp = _GP(play).GetUIViewport().GetWidth() / 2 - windowwid / 2;
282 windowyp = _GP(play).GetUIViewport().GetHeight() / 2 - windowhit / 2;
283 buttonyp = windowhit - BUTTONAREAHEIGHT;
284 bartop = get_fixed_pixel_size(2);
285 barxp = get_fixed_pixel_size(2);
286
287 Bitmap *ds = prepare_gui_screen(windowxp, windowyp, windowwid, windowhit, true);
288 Draw(ds);
289 //ags_domouse(DOMOUSE_ENABLE);
290 set_mouse_cursor(cmode);
291 wasonitem = -1;
292 return 0;
293 }
294
Draw(Bitmap * ds)295 void InventoryScreen::Draw(Bitmap *ds) {
296 color_t draw_color = ds->GetCompatibleColor(_GP(play).sierra_inv_color);
297 ds->FillRect(Rect(0, 0, windowwid, windowhit), draw_color);
298 draw_color = ds->GetCompatibleColor(0);
299 ds->FillRect(Rect(barxp, bartop, windowwid - get_fixed_pixel_size(2), buttonyp - 1), draw_color);
300 for (int i = top_item; i < numitems; ++i) {
301 if (i >= top_item + num_visible_items)
302 break;
303 Bitmap *spof = _GP(spriteset)[dii[i].sprnum];
304 wputblock(ds, barxp + 1 + ((i - top_item) % 4) * widest + widest / 2 - spof->GetWidth() / 2,
305 bartop + 1 + ((i - top_item) / 4) * highest + highest / 2 - spof->GetHeight() / 2, spof, 1);
306 }
307 #define BUTTONWID Math::Max(1, _GP(game).SpriteInfos[btn_select_sprite].Width)
308 // Draw select, look and OK buttons
309 wputblock(ds, 2, buttonyp + get_fixed_pixel_size(2), _GP(spriteset)[btn_look_sprite], 1);
310 wputblock(ds, 3 + BUTTONWID, buttonyp + get_fixed_pixel_size(2), _GP(spriteset)[btn_select_sprite], 1);
311 wputblock(ds, 4 + BUTTONWID * 2, buttonyp + get_fixed_pixel_size(2), _GP(spriteset)[btn_ok_sprite], 1);
312
313 // Draw Up and Down buttons if required
314 Bitmap *arrowblock = BitmapHelper::CreateTransparentBitmap(ARROWBUTTONWID, ARROWBUTTONWID);
315 draw_color = arrowblock->GetCompatibleColor(0);
316 if (_GP(play).sierra_inv_color == 0)
317 draw_color = ds->GetCompatibleColor(14);
318
319 arrowblock->DrawLine(Line(ARROWBUTTONWID / 2, 2, ARROWBUTTONWID - 2, 9), draw_color);
320 arrowblock->DrawLine(Line(ARROWBUTTONWID / 2, 2, 2, 9), draw_color);
321 arrowblock->DrawLine(Line(2, 9, ARROWBUTTONWID - 2, 9), draw_color);
322 arrowblock->FloodFill(ARROWBUTTONWID / 2, 4, draw_color);
323
324 if (top_item > 0)
325 wputblock(ds, windowwid - ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(2), arrowblock, 1);
326 if (top_item + num_visible_items < numitems)
327 arrowblock->FlipBlt(arrowblock, windowwid - ARROWBUTTONWID, buttonyp + get_fixed_pixel_size(4) + ARROWBUTTONWID, Shared::kBitmap_VFlip);
328 delete arrowblock;
329 }
330
RedrawOverItem(Bitmap * ds,int isonitem)331 void InventoryScreen::RedrawOverItem(Bitmap *ds, int isonitem) {
332 int rectxp = barxp + 1 + (wasonitem % 4) * widest;
333 int rectyp = bartop + 1 + ((wasonitem - top_item) / 4) * highest;
334 if (wasonitem >= 0) {
335 color_t draw_color = ds->GetCompatibleColor(0);
336 ds->DrawRect(Rect(rectxp, rectyp, rectxp + widest - 1, rectyp + highest - 1), draw_color);
337 }
338 if (isonitem >= 0) {
339 color_t draw_color = ds->GetCompatibleColor(14);//opts.invrectcol);
340 rectxp = barxp + 1 + (isonitem % 4) * widest;
341 rectyp = bartop + 1 + ((isonitem - top_item) / 4) * highest;
342 ds->DrawRect(Rect(rectxp, rectyp, rectxp + widest - 1, rectyp + highest - 1), draw_color);
343 }
344 }
345
Run()346 bool InventoryScreen::Run() {
347 // Run() can be called in a loop, so keep events going.
348 sys_evt_process_pending();
349
350 KeyInput kgn;
351 if (run_service_key_controls(kgn) && !_GP(play).IsIgnoringInput()) {
352 return false; // end inventory screen loop
353 }
354
355 update_audio_system_on_game_loop();
356 refresh_gui_screen();
357
358 // NOTE: this is because old code was working with full game screen
359 const int mousex = _G(mousex) - windowxp;
360 const int mousey = _G(mousey) - windowyp;
361
362 int isonitem = ((mousey - bartop) / highest) * ICONSPERLINE + (mousex - barxp) / widest;
363 if (mousey <= bartop) isonitem = -1;
364 else if (isonitem >= 0) isonitem += top_item;
365 if ((isonitem < 0) | (isonitem >= numitems) | (isonitem >= top_item + num_visible_items))
366 isonitem = -1;
367
368 int mclick, mwheelz;
369 if (!run_service_mb_controls(mclick, mwheelz) || _GP(play).IsIgnoringInput()) {
370 mclick = MouseNone;
371 }
372
373 if (mclick == MouseLeft) {
374 if ((mousey < 0) | (mousey > windowhit) | (mousex < 0) | (mousex > windowwid))
375 return true; // continue inventory screen loop
376 if (mousey < buttonyp) {
377 int clickedon = isonitem;
378 if (clickedon < 0) return true; // continue inventory screen loop
379 _G(evblocknum) = dii[clickedon].num;
380 _GP(play).used_inv_on = dii[clickedon].num;
381
382 if (cmode == MODE_LOOK) {
383 //ags_domouse(DOMOUSE_DISABLE);
384 run_event_block_inv(dii[clickedon].num, 0);
385 // in case the script did anything to the screen, redraw it
386 UpdateGameOnce();
387
388 break_code = Redraw();
389 return break_code == 0;
390 } else if (cmode == MODE_USE) {
391 // use objects on each other
392 _GP(play).usedinv = toret;
393
394 // set the activeinv so the script can check it
395 int activeinvwas = _G(playerchar)->activeinv;
396 _G(playerchar)->activeinv = toret;
397
398 //ags_domouse(DOMOUSE_DISABLE);
399 run_event_block_inv(dii[clickedon].num, 3);
400
401 // if the script didn't change it, then put it back
402 if (_G(playerchar)->activeinv == toret)
403 _G(playerchar)->activeinv = activeinvwas;
404
405 // in case the script did anything to the screen, redraw it
406 UpdateGameOnce();
407
408 // They used the active item and lost it
409 if (_G(playerchar)->inv[toret] < 1) {
410 cmode = CURS_ARROW;
411 set_mouse_cursor(cmode);
412 toret = -1;
413 }
414
415 break_code = Redraw();
416 return break_code == 0;
417 }
418 toret = dii[clickedon].num;
419 // int plusng=_GP(play).using; _GP(play).using=toret;
420 update_inv_cursor(toret);
421 set_mouse_cursor(MODE_USE);
422 cmode = MODE_USE;
423 // _GP(play).using=plusng;
424 // break;
425 return true; // continue inventory screen loop
426 } else {
427 if (mousex >= windowwid - ARROWBUTTONWID) {
428 if (mousey < buttonyp + get_fixed_pixel_size(2) + ARROWBUTTONWID) {
429 if (top_item > 0) {
430 top_item -= ICONSPERLINE;
431 //ags_domouse(DOMOUSE_DISABLE);
432
433 break_code = Redraw();
434 return break_code == 0;
435 }
436 } else if ((mousey < buttonyp + get_fixed_pixel_size(4) + ARROWBUTTONWID * 2) && (top_item + num_visible_items < numitems)) {
437 top_item += ICONSPERLINE;
438 //ags_domouse(DOMOUSE_DISABLE);
439
440 break_code = Redraw();
441 return break_code == 0;
442 }
443 return true; // continue inventory screen loop
444 }
445
446 int buton = mousex - 2;
447 if (buton < 0) return true; // continue inventory screen loop
448 buton /= BUTTONWID;
449 if (buton >= 3) return true; // continue inventory screen loop
450 if (buton == 0) {
451 toret = -1;
452 cmode = MODE_LOOK;
453 } else if (buton == 1) {
454 cmode = CURS_ARROW;
455 toret = -1;
456 } else {
457 return false; // end inventory screen loop
458 }
459 set_mouse_cursor(cmode);
460 }
461 } else if (mclick == MouseRight) {
462 if (cmode == CURS_ARROW)
463 cmode = MODE_LOOK;
464 else
465 cmode = CURS_ARROW;
466 toret = -1;
467 set_mouse_cursor(cmode);
468 } else if (isonitem != wasonitem) {
469 //ags_domouse(DOMOUSE_DISABLE);
470 RedrawOverItem(get_gui_screen(), isonitem);
471 //ags_domouse(DOMOUSE_ENABLE);
472 }
473 wasonitem = isonitem;
474
475 update_polled_stuff_if_runtime();
476
477 WaitForNextFrame();
478
479 return true; // continue inventory screen loop
480 }
481
Close()482 void InventoryScreen::Close() {
483 clear_gui_screen();
484 set_default_cursor();
485 invalidate_screen();
486 _G(in_inv_screen)--;
487 }
488
__actual_invscreen()489 int __actual_invscreen() {
490 InvScr.Prepare();
491 InvScr.break_code = InvScr.Redraw();
492 if (InvScr.break_code != 0) {
493 return InvScr.break_code;
494 }
495
496 while (InvScr.Run());
497
498 if (InvScr.break_code != 0) {
499 return InvScr.break_code;
500 }
501
502 ags_clear_input_buffer();
503
504 InvScr.Close();
505 return InvScr.toret;
506 }
507
invscreen()508 int invscreen() {
509 int selt = __actual_invscreen();
510 if (selt < 0) return -1;
511 _G(playerchar)->activeinv = selt;
512 GUI::MarkInventoryForUpdate(_G(playerchar)->index_id, true);
513 set_cursor_mode(MODE_USE);
514 return selt;
515 }
516
517 //=============================================================================
518 //
519 // Script API Functions
520 //
521 //=============================================================================
522
523 // void (GUIInvWindow *guii)
Sc_InvWindow_ScrollDown(void * self,const RuntimeScriptValue * params,int32_t param_count)524 RuntimeScriptValue Sc_InvWindow_ScrollDown(void *self, const RuntimeScriptValue *params, int32_t param_count) {
525 API_OBJCALL_VOID(GUIInvWindow, InvWindow_ScrollDown);
526 }
527
528 // void (GUIInvWindow *guii)
Sc_InvWindow_ScrollUp(void * self,const RuntimeScriptValue * params,int32_t param_count)529 RuntimeScriptValue Sc_InvWindow_ScrollUp(void *self, const RuntimeScriptValue *params, int32_t param_count) {
530 API_OBJCALL_VOID(GUIInvWindow, InvWindow_ScrollUp);
531 }
532
533 // CharacterInfo* (GUIInvWindow *guii)
Sc_InvWindow_GetCharacterToUse(void * self,const RuntimeScriptValue * params,int32_t param_count)534 RuntimeScriptValue Sc_InvWindow_GetCharacterToUse(void *self, const RuntimeScriptValue *params, int32_t param_count) {
535 API_OBJCALL_OBJ(GUIInvWindow, CharacterInfo, _GP(ccDynamicCharacter), InvWindow_GetCharacterToUse);
536 }
537
538 // void (GUIInvWindow *guii, CharacterInfo *chaa)
Sc_InvWindow_SetCharacterToUse(void * self,const RuntimeScriptValue * params,int32_t param_count)539 RuntimeScriptValue Sc_InvWindow_SetCharacterToUse(void *self, const RuntimeScriptValue *params, int32_t param_count) {
540 API_OBJCALL_VOID_POBJ(GUIInvWindow, InvWindow_SetCharacterToUse, CharacterInfo);
541 }
542
543 // ScriptInvItem* (GUIInvWindow *guii, int index)
Sc_InvWindow_GetItemAtIndex(void * self,const RuntimeScriptValue * params,int32_t param_count)544 RuntimeScriptValue Sc_InvWindow_GetItemAtIndex(void *self, const RuntimeScriptValue *params, int32_t param_count) {
545 API_OBJCALL_OBJ_PINT(GUIInvWindow, ScriptInvItem, _GP(ccDynamicInv), InvWindow_GetItemAtIndex);
546 }
547
548 // int (GUIInvWindow *guii)
Sc_InvWindow_GetItemCount(void * self,const RuntimeScriptValue * params,int32_t param_count)549 RuntimeScriptValue Sc_InvWindow_GetItemCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
550 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemCount);
551 }
552
553 // int (GUIInvWindow *guii)
Sc_InvWindow_GetItemHeight(void * self,const RuntimeScriptValue * params,int32_t param_count)554 RuntimeScriptValue Sc_InvWindow_GetItemHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
555 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemHeight);
556 }
557
558 // void (GUIInvWindow *guii, int newhit)
Sc_InvWindow_SetItemHeight(void * self,const RuntimeScriptValue * params,int32_t param_count)559 RuntimeScriptValue Sc_InvWindow_SetItemHeight(void *self, const RuntimeScriptValue *params, int32_t param_count) {
560 API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetItemHeight);
561 }
562
563 // int (GUIInvWindow *guii)
Sc_InvWindow_GetItemWidth(void * self,const RuntimeScriptValue * params,int32_t param_count)564 RuntimeScriptValue Sc_InvWindow_GetItemWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
565 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemWidth);
566 }
567
568 // void (GUIInvWindow *guii, int newwidth)
Sc_InvWindow_SetItemWidth(void * self,const RuntimeScriptValue * params,int32_t param_count)569 RuntimeScriptValue Sc_InvWindow_SetItemWidth(void *self, const RuntimeScriptValue *params, int32_t param_count) {
570 API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetItemWidth);
571 }
572
573 // int (GUIInvWindow *guii)
Sc_InvWindow_GetItemsPerRow(void * self,const RuntimeScriptValue * params,int32_t param_count)574 RuntimeScriptValue Sc_InvWindow_GetItemsPerRow(void *self, const RuntimeScriptValue *params, int32_t param_count) {
575 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetItemsPerRow);
576 }
577
578 // int (GUIInvWindow *guii)
Sc_InvWindow_GetRowCount(void * self,const RuntimeScriptValue * params,int32_t param_count)579 RuntimeScriptValue Sc_InvWindow_GetRowCount(void *self, const RuntimeScriptValue *params, int32_t param_count) {
580 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetRowCount);
581 }
582
583 // int (GUIInvWindow *guii)
Sc_InvWindow_GetTopItem(void * self,const RuntimeScriptValue * params,int32_t param_count)584 RuntimeScriptValue Sc_InvWindow_GetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
585 API_OBJCALL_INT(GUIInvWindow, InvWindow_GetTopItem);
586 }
587
588 // void (GUIInvWindow *guii, int topitem)
Sc_InvWindow_SetTopItem(void * self,const RuntimeScriptValue * params,int32_t param_count)589 RuntimeScriptValue Sc_InvWindow_SetTopItem(void *self, const RuntimeScriptValue *params, int32_t param_count) {
590 API_OBJCALL_VOID_PINT(GUIInvWindow, InvWindow_SetTopItem);
591 }
592
593
594
RegisterInventoryWindowAPI()595 void RegisterInventoryWindowAPI() {
596 ccAddExternalObjectFunction("InvWindow::ScrollDown^0", Sc_InvWindow_ScrollDown);
597 ccAddExternalObjectFunction("InvWindow::ScrollUp^0", Sc_InvWindow_ScrollUp);
598 ccAddExternalObjectFunction("InvWindow::get_CharacterToUse", Sc_InvWindow_GetCharacterToUse);
599 ccAddExternalObjectFunction("InvWindow::set_CharacterToUse", Sc_InvWindow_SetCharacterToUse);
600 ccAddExternalObjectFunction("InvWindow::geti_ItemAtIndex", Sc_InvWindow_GetItemAtIndex);
601 ccAddExternalObjectFunction("InvWindow::get_ItemCount", Sc_InvWindow_GetItemCount);
602 ccAddExternalObjectFunction("InvWindow::get_ItemHeight", Sc_InvWindow_GetItemHeight);
603 ccAddExternalObjectFunction("InvWindow::set_ItemHeight", Sc_InvWindow_SetItemHeight);
604 ccAddExternalObjectFunction("InvWindow::get_ItemWidth", Sc_InvWindow_GetItemWidth);
605 ccAddExternalObjectFunction("InvWindow::set_ItemWidth", Sc_InvWindow_SetItemWidth);
606 ccAddExternalObjectFunction("InvWindow::get_ItemsPerRow", Sc_InvWindow_GetItemsPerRow);
607 ccAddExternalObjectFunction("InvWindow::get_RowCount", Sc_InvWindow_GetRowCount);
608 ccAddExternalObjectFunction("InvWindow::get_TopItem", Sc_InvWindow_GetTopItem);
609 ccAddExternalObjectFunction("InvWindow::set_TopItem", Sc_InvWindow_SetTopItem);
610 }
611
612 } // namespace AGS3
613