ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
36 namespace AGS3 {
37 
38 namespace AGS {
39 namespace Shared {
40 class Bitmap;
41 } // namespace Shared
42 } // namespace AGS
43 
44 using namespace AGS; // FIXME later
45 
46 extern 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
49 bool AssertObject(const char *apiname, int obj_id);
50 int Object_IsCollidingWithObject(ScriptObject *objj, ScriptObject *obj2);
51 ScriptObject *GetObjectAtScreen(int xx, int yy);
52 ScriptObject *GetObjectAtRoom(int x, int y);
53 void Object_Tint(ScriptObject *objj, int red, int green, int blue, int saturation, int luminance);
54 void Object_RemoveTint(ScriptObject *objj);
55 void Object_SetView(ScriptObject *objj, int view, int loop, int frame);
56 void Object_SetTransparency(ScriptObject *objj, int trans);
57 int Object_GetTransparency(ScriptObject *objj);
58 void Object_SetBaseline(ScriptObject *objj, int basel);
59 int Object_GetBaseline(ScriptObject *objj);
60 void Object_Animate(ScriptObject *objj, int loop, int delay, int repeat, int blocking, int direction, int sframe = 0, int volume = 100);
61 void Object_StopAnimating(ScriptObject *objj);
62 void Object_MergeIntoBackground(ScriptObject *objj);
63 void Object_StopMoving(ScriptObject *objj);
64 void Object_SetVisible(ScriptObject *objj, int onoroff);
65 int Object_GetView(ScriptObject *objj);
66 int Object_GetLoop(ScriptObject *objj);
67 int Object_GetFrame(ScriptObject *objj);
68 int Object_GetVisible(ScriptObject *objj);
69 void Object_SetGraphic(ScriptObject *objj, int slott);
70 int Object_GetGraphic(ScriptObject *objj);
71 int Object_GetX(ScriptObject *objj);
72 int Object_GetY(ScriptObject *objj);
73 int Object_GetAnimating(ScriptObject *objj);
74 int Object_GetMoving(ScriptObject *objj);
75 void Object_SetPosition(ScriptObject *objj, int xx, int yy);
76 void Object_SetX(ScriptObject *objj, int xx);
77 void Object_SetY(ScriptObject *objj, int yy);
78 void Object_GetName(ScriptObject *objj, char *buffer);
79 const char *Object_GetName_New(ScriptObject *objj);
80 bool Object_IsInteractionAvailable(ScriptObject *oobj, int mood);
81 void Object_Move(ScriptObject *objj, int x, int y, int speed, int blocking, int direct);
82 void Object_SetClickable(ScriptObject *objj, int clik);
83 int Object_GetClickable(ScriptObject *objj);
84 void Object_SetIgnoreScaling(ScriptObject *objj, int newval);
85 int Object_GetIgnoreScaling(ScriptObject *objj);
86 void Object_SetSolid(ScriptObject *objj, int solid);
87 int Object_GetSolid(ScriptObject *objj);
88 void Object_SetBlockingWidth(ScriptObject *objj, int bwid);
89 int Object_GetBlockingWidth(ScriptObject *objj);
90 void Object_SetBlockingHeight(ScriptObject *objj, int bhit);
91 int Object_GetBlockingHeight(ScriptObject *objj);
92 int Object_GetID(ScriptObject *objj);
93 void Object_SetIgnoreWalkbehinds(ScriptObject *chaa, int clik);
94 int Object_GetIgnoreWalkbehinds(ScriptObject *chaa);
95 void Object_RunInteraction(ScriptObject *objj, int mode);
96 
97 int Object_GetProperty(ScriptObject *objj, const char *property);
98 void Object_GetPropertyText(ScriptObject *objj, const char *property, char *bufer);
99 const char *Object_GetTextProperty(ScriptObject *objj, const char *property);
100 bool Object_SetProperty(ScriptObject *objj, const char *property, int value);
101 bool 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.
105 void update_object_scale(int objid);
106 // Deduces arbitrary object's scale, accounting for both manual scaling and the room region effects
107 void 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);
109 void move_object(int objj, int tox, int toy, int spee, int ignwal);
110 void get_object_blocking_rect(int objid, int *x1, int *y1, int *width, int *y2);
111 int 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
115 int 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
118 int 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.
125 void 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.
129 void ValidateViewAnimVLF(const char *apiname, int view, int loop, int &sframe);
130 // Calculates the first shown frame for a view animation, depending on parameters.
131 int 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.
135 bool CycleViewAnim(int view, uint16_t &loop, uint16_t &frame, bool forwards, int repeat);
136 void CheckViewFrameForObject(RoomObject *obj);
137 
138 } // namespace AGS3
139 
140 #endif
Definition: achievements_tables.h:27
Definition: ags.h:40