ScummVM API documentation
object.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22//=============================================================================
23//
24//
25// [IKM] 2012-06-25: This bugs me that type is called 'Object'; in modern
26// world of programming 'object' is usually a base class; should not we
27// rename this to RoomObject one day?
28//=============================================================================
29
30#ifndef AGS_ENGINE_AC_OBJECT_H
31#define AGS_ENGINE_AC_OBJECT_H
32
33#include "ags/shared/ac/common_defines.h"
34#include "ags/engine/ac/dynobj/script_object.h"
35
36namespace AGS3 {
37
38namespace AGS {
39namespace Shared {
40class Bitmap;
41} // namespace Shared
42} // namespace AGS
43
44using namespace AGS; // FIXME later
45
46extern bool is_valid_object(int obj_id);
47// Asserts the object ID is valid in the current room,
48// if not then prints a warning to the log; returns assertion result
49bool AssertObject(const char *apiname, int obj_id);
50int Object_IsCollidingWithObject(ScriptObject *objj, ScriptObject *obj2);
51ScriptObject *GetObjectAtScreen(int xx, int yy);
52ScriptObject *GetObjectAtRoom(int x, int y);
53void Object_Tint(ScriptObject *objj, int red, int green, int blue, int saturation, int luminance);
54void Object_RemoveTint(ScriptObject *objj);
55void Object_SetView(ScriptObject *objj, int view, int loop, int frame);
56void Object_SetTransparency(ScriptObject *objj, int trans);
57int Object_GetTransparency(ScriptObject *objj);
58void Object_SetBaseline(ScriptObject *objj, int basel);
59int Object_GetBaseline(ScriptObject *objj);
60void Object_Animate(ScriptObject *objj, int loop, int delay, int repeat, int blocking, int direction, int sframe = 0, int volume = 100);
61void Object_StopAnimating(ScriptObject *objj);
62void Object_MergeIntoBackground(ScriptObject *objj);
63void Object_StopMoving(ScriptObject *objj);
64void Object_SetVisible(ScriptObject *objj, int onoroff);
65int Object_GetView(ScriptObject *objj);
66int Object_GetLoop(ScriptObject *objj);
67int Object_GetFrame(ScriptObject *objj);
68int Object_GetVisible(ScriptObject *objj);
69void Object_SetGraphic(ScriptObject *objj, int slott);
70int Object_GetGraphic(ScriptObject *objj);
71int Object_GetX(ScriptObject *objj);
72int Object_GetY(ScriptObject *objj);
73int Object_GetAnimating(ScriptObject *objj);
74int Object_GetMoving(ScriptObject *objj);
75void Object_SetPosition(ScriptObject *objj, int xx, int yy);
76void Object_SetX(ScriptObject *objj, int xx);
77void Object_SetY(ScriptObject *objj, int yy);
78void Object_GetName(ScriptObject *objj, char *buffer);
79const char *Object_GetName_New(ScriptObject *objj);
80bool Object_IsInteractionAvailable(ScriptObject *oobj, int mood);
81void Object_Move(ScriptObject *objj, int x, int y, int speed, int blocking, int direct);
82void Object_SetClickable(ScriptObject *objj, int clik);
83int Object_GetClickable(ScriptObject *objj);
84void Object_SetIgnoreScaling(ScriptObject *objj, int newval);
85int Object_GetIgnoreScaling(ScriptObject *objj);
86void Object_SetSolid(ScriptObject *objj, int solid);
87int Object_GetSolid(ScriptObject *objj);
88void Object_SetBlockingWidth(ScriptObject *objj, int bwid);
89int Object_GetBlockingWidth(ScriptObject *objj);
90void Object_SetBlockingHeight(ScriptObject *objj, int bhit);
91int Object_GetBlockingHeight(ScriptObject *objj);
92int Object_GetID(ScriptObject *objj);
93void Object_SetIgnoreWalkbehinds(ScriptObject *chaa, int clik);
94int Object_GetIgnoreWalkbehinds(ScriptObject *chaa);
95void Object_RunInteraction(ScriptObject *objj, int mode);
96
97int Object_GetProperty(ScriptObject *objj, const char *property);
98void Object_GetPropertyText(ScriptObject *objj, const char *property, char *bufer);
99const char *Object_GetTextProperty(ScriptObject *objj, const char *property);
100bool Object_SetProperty(ScriptObject *objj, const char *property, int value);
101bool Object_SetTextProperty(ScriptObject *objj, const char *property, const char *value);
102
103// Deduces room object's scale, accounting for both manual scaling and the room region effects;
104// calculates resulting sprite size.
105void update_object_scale(int objid);
106// Deduces arbitrary object's scale, accounting for both manual scaling and the room region effects
107void update_object_scale(int &res_zoom, int &res_width, int &res_height,
108 int objx, int objy, int sprnum, int own_zoom, bool use_region_scaling);
109void move_object(int objj, int tox, int toy, int spee, int ignwal);
110void get_object_blocking_rect(int objid, int *x1, int *y1, int *width, int *y2);
111int isposinbox(int mmx, int mmy, int lf, int tp, int rt, int bt);
112// xx,yy is the position in room co-ordinates that we are checking
113// arx,ary,spww,sphh are the sprite's bounding box (including sprite scaling);
114// bitmap_original tells whether bitmap is an original sprite, or transformed version
115int is_pos_in_sprite(int xx, int yy, int arx, int ary, Shared::Bitmap *sprit, int spww, int sphh, int flipped, bool bitmap_original);
116// X and Y co-ordinates must be in native format
117// X and Y are ROOM coordinates
118int check_click_on_object(int roomx, int roomy, int mood);
119
120// Shared functions that prepare or advance the view animation;
121// used by characters, room objects and buttons.
122// TODO: pick out some kind of "animation" struct
123// Tests if the standard animate parameters are in valid range, if not then clamps them and
124// reports a script warning.
125void ValidateViewAnimParams(const char *apiname, int &repeat, int &blocking, int &direction);
126// Tests if the view, loop, frame animate params are in valid range,
127// errors in case of out-of-range view or loop, but clamps a frame to a range.
128// NOTE: assumes view is already in an internal 0-based range.
129void ValidateViewAnimVLF(const char *apiname, int view, int loop, int &sframe);
130// Calculates the first shown frame for a view animation, depending on parameters.
131int SetFirstAnimFrame(int view, int loop, int sframe, int direction);
132// General view animation algorithm: find next loop and frame, depending on anim settings;
133// loop and frame values are passed by reference and will be updated;
134// returns whether the animation should continue.
135bool CycleViewAnim(int view, uint16_t &loop, uint16_t &frame, bool forwards, int repeat);
136void CheckViewFrameForObject(RoomObject *obj);
137
138} // namespace AGS3
139
140#endif