Mercurial > otakunoraifu
comparison scn2k/scn2k_grp.h @ 56:c7bcc0ec2267
* replaced Grp and Text classes by the TextImpl and GrpImpl ones
* splitted scn2k.h into smaller header files
* moved some definitions from scn2k_*.cc to the header files
* moved opcode implementation to scn2k_*impl.cc
author | thib |
---|---|
date | Thu, 30 Apr 2009 19:05:09 +0000 |
parents | |
children | e16e13d8cd68 |
comparison
equal
deleted
inserted
replaced
55:f1a27ee7e03c | 56:c7bcc0ec2267 |
---|---|
1 /* | |
2 * Copyright (c) 2009 Thibaut GIRKA | |
3 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
4 * All rights reserved. | |
5 * | |
6 * Redistribution and use in source and binary forms, with or without | |
7 * modification, are permitted provided that the following conditions | |
8 * are met: | |
9 * 1. Redistributions of source code must retain the above copyright | |
10 * notice, this list of conditions and the following disclaimer. | |
11 * 2. Redistributions in binary form must reproduce the above copyright | |
12 * notice, this list of conditions and the following disclaimer in the | |
13 * documentation and/or other materials provided with the distribution. | |
14 * 3. The name of the author may not be used to endorse or promote products | |
15 * derived from this software without specific prior written permission. | |
16 * | |
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
27 */ | |
28 | |
29 #ifndef __SCN2K_GRP_H__ | |
30 #define __SCN2K_GRP_H__ | |
31 | |
32 #include <set> | |
33 | |
34 #include "scn2k_cmd.h" | |
35 #include "window/widget.h" | |
36 | |
37 using namespace std; | |
38 | |
39 void dprintf(const char* fmt, ...); //FIXME | |
40 void eprintf(const char* fmt, ...); //FIXME | |
41 | |
42 struct SEL { | |
43 Rect from; | |
44 Rect to; | |
45 int time; | |
46 int sel_no; | |
47 int args[8]; | |
48 SEL() : from(0,0), to(0,0) {} | |
49 }; | |
50 | |
51 struct GrpObj; | |
52 typedef std::map<int, GrpObj> GrpObjMap; | |
53 | |
54 /******************************************************************* | |
55 ** GrpObj(interface) | |
56 */ | |
57 | |
58 struct GrpObj { | |
59 string name; | |
60 string gan_name; | |
61 PicContainer* pic_parent; | |
62 PicBase* picture; | |
63 WidAnmTime* anm; | |
64 int _posx, _posy; | |
65 int posx[9], posy[9]; | |
66 Rect clip_area; | |
67 unsigned char alpha; | |
68 int order; | |
69 int surface_num; | |
70 | |
71 GrpObjMap children_obj; | |
72 | |
73 string print_moji; | |
74 int print_size, print_r, print_b, print_g; | |
75 | |
76 int dig_number, dig_digit; | |
77 | |
78 // zoom / rotate 関係 | |
79 int zoom; // 256 で 1 倍 | |
80 int rotate; // 0-360度 | |
81 | |
82 vector<Rect> src_pos; | |
83 enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype; | |
84 enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, | |
85 UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512, | |
86 UPDATE_ALL = (UPDATE_PICTURE | UPDATE_POS | UPDATE_ALPHA | UPDATE_SNUM | UPDATE_CLIP | UPDATE_VISIBLE), | |
87 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000, | |
88 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16 | |
89 }; | |
90 Attribute attr; | |
91 | |
92 GrpObj(void); | |
93 ~GrpObj(void); | |
94 | |
95 void SetPos(int index, int x, int y); | |
96 void GetPos(int index, int& x, int& y); | |
97 int PosX(void); | |
98 int PosY(void); | |
99 void SetAlpha(void); | |
100 void SetAlpha(int alpha); | |
101 void SetSurfaceNum(int num = -1); | |
102 void SetZoomRotate(int zoom=-1, int rotate=-1); | |
103 void SetClipArea(int x, int y, int width, int height); | |
104 void GetSrcGeom(int& width, int& height); | |
105 void SetUpdate(void); | |
106 void UpdateMoji(void); | |
107 void UpdateDigit(void); | |
108 void UpdateSurface(void); | |
109 void ZoomRotate(void); | |
110 void Refresh(GrpObj& parent_obj); | |
111 void _debug_Dump(int, int); | |
112 void Update(void); | |
113 void CreateSurface(PicContainer* parent); | |
114 void CreateGan(Event::Container& event, int event_number); | |
115 void CreateGanSpecial(Event::Container& event, int event_number, int time); | |
116 PicBase* DeletePic(void); | |
117 }; | |
118 | |
119 | |
120 /******************************************************************* | |
121 ** Grp | |
122 */ | |
123 | |
124 class Grp : public CommandHandler { | |
125 #define MAXPDT 256 | |
126 #define WORKPDT 255 | |
127 private: | |
128 void CreateObj(int number); | |
129 void CreateSubObj(int grp_num, int number); | |
130 void ZMoveObj(int number); | |
131 void SetObjChanged(int number); | |
132 void SwapObj(int a1, int a2); | |
133 void DeleteObjPic(int num);// object の surface のみ削除 | |
134 void DeleteSubObjPic(int grp_num, int num); | |
135 void DeleteObj(int num); | |
136 void DeleteSubObj(int grp_num, int num); | |
137 void RefreshObj(void); | |
138 | |
139 Surface* Dsurface(int pdt); | |
140 Surface* Ssurface(int pdt); | |
141 | |
142 // cgmode 用画像処理関連 | |
143 void LoadCgm(void); | |
144 | |
145 public: | |
146 Grp(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data); | |
147 ~Grp(); | |
148 bool Wait(unsigned int current_time, Cmd& cmd); | |
149 void Exec(Cmd& cmd); | |
150 void InitSel(void); | |
151 void Save(std::string& str); | |
152 void Load(const char* str); | |
153 void SaveSys(std::string& str); | |
154 void LoadSys(const char* str); | |
155 void SetSkipMode(SkipMode _mode); | |
156 void LoadSurface(const char* str, int pdt); | |
157 | |
158 private: | |
159 void LoadSurface(const char* str); | |
160 void LoadSurface(void); | |
161 void AddSurface(const char* str); | |
162 | |
163 void StartAnm(int type); | |
164 void StartShake(int total, const int* pattern); | |
165 void AbortAnm(void); | |
166 static bool Pressed(int x, int y, void* pointer); | |
167 | |
168 GrpObj* GetGraphicObj(int grp, bool fg=true); | |
169 GrpObj* GetGraphicObj(int grp, int index, bool fg=true); | |
170 GrpObj* GetGraphicObjVarMode(Cmd& cmd, int &base_arg, bool fg=true); | |
171 | |
172 // Opcode handling | |
173 void impl_stackClear(Cmd& cmd); | |
174 void impl_grpBuffer(Cmd& cmd); | |
175 void impl_grpMulti(Cmd &cmd); | |
176 void impl_grpOpen(Cmd &cmd); | |
177 void impl_shake(Cmd &cmd); | |
178 void impl_grpCopy(Cmd &cmd); | |
179 void impl_recFill(Cmd &cmd); | |
180 void impl_recCopy(Cmd &cmd); | |
181 void impl_recAdd(Cmd &cmd); | |
182 void impl_grpPan(Cmd &cmd); | |
183 void impl_snmPlay(Cmd &cmd); | |
184 void impl_snmBgScroll(Cmd &cmd); | |
185 void impl_cgGet(Cmd &cmd); | |
186 void impl_cgStatus(Cmd &cmd); | |
187 void impl_objClear(Cmd &cmd); | |
188 void impl_createObj(Cmd &cmd); | |
189 void impl_gan(Cmd &cmd); | |
190 void impl_objSetPos(Cmd &cmd); | |
191 void impl_objAlpha(Cmd &cmd); | |
192 void impl_objShow(Cmd &cmd); | |
193 void impl_objColour(Cmd &cmd); | |
194 void impl_objComposite(Cmd &cmd); | |
195 void impl_objSetText(Cmd &cmd); | |
196 void impl_objTextOpts(Cmd &cmd); | |
197 void impl_objOrder(Cmd &cmd); | |
198 void impl_objDispArea(Cmd &cmd); | |
199 void impl_objSetDigits(Cmd &cmd); | |
200 void impl_objNumOpts(Cmd &cmd); | |
201 void impl_objPattNo(Cmd &cmd); | |
202 void impl_objScale(Cmd &cmd); | |
203 void impl_objRotate(Cmd &cmd); | |
204 void impl_objPosDims(Cmd &cmd); | |
205 void impl_refresh(Cmd &cmd); | |
206 void impl_bgmLoop(Cmd &cmd); | |
207 void impl_bgmStop(Cmd &cmd); | |
208 void impl_playWav(Cmd &cmd); | |
209 void impl_playSE(Cmd &cmd); | |
210 void impl_stopWav(Cmd &cmd); | |
211 void impl_SetVolMod(Cmd &cmd); | |
212 void impl_GetVolMod(Cmd &cmd); | |
213 void impl_koePlay(Cmd &cmd); | |
214 void impl_movPlay(Cmd &cmd); | |
215 | |
216 public: | |
217 class AyuSysConfig *config; | |
218 | |
219 private: | |
220 Event::Container& event; | |
221 const Flags& flags; | |
222 PicBase* screen; | |
223 PicBase* screen_front; | |
224 Surface* surface, *surface_update; | |
225 | |
226 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface | |
227 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface | |
228 PicContainer& parent; | |
229 | |
230 // 画像効果の保存用 | |
231 WidAnmTime* anm1, *anm2; | |
232 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; | |
233 Status status; | |
234 SkipMode skip_mode; | |
235 | |
236 std::string bg_name; | |
237 std::map<int, SEL> anmtype; | |
238 GrpObjMap grpobj; | |
239 GrpObjMap bs_obj; | |
240 | |
241 std::map<std::string, int> cgm_info; | |
242 set<int>& cgm_data; | |
243 int cgm_size; | |
244 | |
245 class MuSys *music; | |
246 | |
247 std::set<int> changed_obj; | |
248 string reserved_load_surface0; | |
249 vector<PicBase*> deleted_pic; | |
250 }; | |
251 | |
252 | |
253 /****************************************************************** | |
254 ** | |
255 ** class ScnGrp* | |
256 */ | |
257 /* Princess Bride: 背景画の一部のみ移動、の実装 */ | |
258 | |
259 struct ScnGrpMove : public WidAnmTime { | |
260 Surface* dest; | |
261 Surface* src; | |
262 PicRoot& root; | |
263 Rect dest_r, from, to; | |
264 ScnGrpMove(Event::Container& container, PicBase* _pic, PicRoot& root, Surface* dest, const Rect& _dest_r, Surface* src, const Rect& from, const Rect& to, int total_time); | |
265 void Exec(int count); | |
266 }; | |
267 | |
268 /* Princess Bride: カードがおちるアニメーション */ | |
269 | |
270 struct ScnGrpAnmAtom { | |
271 string name; | |
272 int time; | |
273 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} | |
274 }; | |
275 | |
276 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { | |
277 Grp& owner; | |
278 ScnGrpAnm(Event::Container& container, PicBase* _pic, Grp& _owner) : | |
279 WidAnmTime(container, _pic, 0), owner(_owner) { | |
280 } | |
281 void CalcTotal(void); | |
282 void Exec(int count); | |
283 }; | |
284 | |
285 #endif |