annotate scn2k/scn2k_grp.cc @ 48:ed6c21dde840

* use correct format (%p) for pointers
author thib
date Wed, 15 Apr 2009 20:28:19 +0000
parents 01aa5ddf7dc8
children 35ce1a30f3f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
6 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
7 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
14 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
15 *
223b71206888 Initial import
thib
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28 #include"scn2k.h"
223b71206888 Initial import
thib
parents:
diff changeset
29 #include"window/widget.h"
223b71206888 Initial import
thib
parents:
diff changeset
30 #include"system/file.h"
223b71206888 Initial import
thib
parents:
diff changeset
31 #include"system/system_config.h"
223b71206888 Initial import
thib
parents:
diff changeset
32 #include"font/text.h"
223b71206888 Initial import
thib
parents:
diff changeset
33 #include<set>
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 using namespace std;
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 extern void DSurfaceFill(Surface* dest, const Rect& rect, int r, int g, int b, int a=0xff);
223b71206888 Initial import
thib
parents:
diff changeset
38 extern void DSurfaceMove(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstpos);
223b71206888 Initial import
thib
parents:
diff changeset
39 extern Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect,
223b71206888 Initial import
thib
parents:
diff changeset
40 Surface* dst, const Rect& dstrect);
223b71206888 Initial import
thib
parents:
diff changeset
41 extern XKFont::HorizLayout* DefaultLayout(int text_size);
223b71206888 Initial import
thib
parents:
diff changeset
42
223b71206888 Initial import
thib
parents:
diff changeset
43 /*******************************************************************
223b71206888 Initial import
thib
parents:
diff changeset
44 ** GrpObj(interface)
223b71206888 Initial import
thib
parents:
diff changeset
45 */
223b71206888 Initial import
thib
parents:
diff changeset
46
223b71206888 Initial import
thib
parents:
diff changeset
47 struct SEL {
223b71206888 Initial import
thib
parents:
diff changeset
48 Rect from;
223b71206888 Initial import
thib
parents:
diff changeset
49 Rect to;
223b71206888 Initial import
thib
parents:
diff changeset
50 int time;
223b71206888 Initial import
thib
parents:
diff changeset
51 int sel_no;
223b71206888 Initial import
thib
parents:
diff changeset
52 int args[8];
223b71206888 Initial import
thib
parents:
diff changeset
53 SEL() : from(0,0), to(0,0) {}
223b71206888 Initial import
thib
parents:
diff changeset
54 };
223b71206888 Initial import
thib
parents:
diff changeset
55
223b71206888 Initial import
thib
parents:
diff changeset
56 struct GrpObj {
223b71206888 Initial import
thib
parents:
diff changeset
57 string name;
223b71206888 Initial import
thib
parents:
diff changeset
58 string gan_name;
223b71206888 Initial import
thib
parents:
diff changeset
59 PicContainer* pic_parent;
223b71206888 Initial import
thib
parents:
diff changeset
60 PicBase* picture;
223b71206888 Initial import
thib
parents:
diff changeset
61 WidAnmTime* anm;
223b71206888 Initial import
thib
parents:
diff changeset
62 int _posx, _posy;
223b71206888 Initial import
thib
parents:
diff changeset
63 int posx[9],posy[9];
223b71206888 Initial import
thib
parents:
diff changeset
64 Rect clip_area;
223b71206888 Initial import
thib
parents:
diff changeset
65 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
66 int order;
223b71206888 Initial import
thib
parents:
diff changeset
67 int surface_num;
223b71206888 Initial import
thib
parents:
diff changeset
68
223b71206888 Initial import
thib
parents:
diff changeset
69 string print_moji;
223b71206888 Initial import
thib
parents:
diff changeset
70 int print_size, print_r, print_b, print_g;
223b71206888 Initial import
thib
parents:
diff changeset
71
223b71206888 Initial import
thib
parents:
diff changeset
72 int dig_number, dig_digit;
223b71206888 Initial import
thib
parents:
diff changeset
73
223b71206888 Initial import
thib
parents:
diff changeset
74 // zoom / rotate 関係
223b71206888 Initial import
thib
parents:
diff changeset
75 int zoom; // 256 で 1 倍
223b71206888 Initial import
thib
parents:
diff changeset
76 int rotate; // 0-360度
223b71206888 Initial import
thib
parents:
diff changeset
77
223b71206888 Initial import
thib
parents:
diff changeset
78 vector<Rect> src_pos;
223b71206888 Initial import
thib
parents:
diff changeset
79 enum GrpType { FILLRECT = 1, FILE = 2, GAN = 3, MOJI = 4, DIGIT = 5} gtype;
223b71206888 Initial import
thib
parents:
diff changeset
80 enum Attribute { NONE=0, WIPEON=1, SATURATE=2, HIDDEN=4, HIDDEN_GROUP=8,
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
81 UPDATE_PICTURE = 16, UPDATE_POS = 32, UPDATE_ALPHA = 64, UPDATE_SNUM = 128, UPDATE_CLIP = 256, UPDATE_VISIBLE = 512,
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
82 UPDATE_ALL = (16|32|64|128|256|512),
0
223b71206888 Initial import
thib
parents:
diff changeset
83 ANM_PLAYSTART = 0x8000, ANM_PLAYING = 0x10000,
223b71206888 Initial import
thib
parents:
diff changeset
84 DIG_ZERO = 0x10000*2, DIG_SIGN = 0x10000*4, DIG_PACK=0x10000*8,DIG_SPACE=0x10000*16
223b71206888 Initial import
thib
parents:
diff changeset
85 };
223b71206888 Initial import
thib
parents:
diff changeset
86 Attribute attr;
223b71206888 Initial import
thib
parents:
diff changeset
87
223b71206888 Initial import
thib
parents:
diff changeset
88 GrpImpl* parent_pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
89
223b71206888 Initial import
thib
parents:
diff changeset
90 GrpObj(void);
223b71206888 Initial import
thib
parents:
diff changeset
91 ~GrpObj(void);
223b71206888 Initial import
thib
parents:
diff changeset
92
223b71206888 Initial import
thib
parents:
diff changeset
93 void SetPos(int index, int x, int y);
223b71206888 Initial import
thib
parents:
diff changeset
94 void GetPos(int index, int& x, int& y);
223b71206888 Initial import
thib
parents:
diff changeset
95 int PosX(void);
223b71206888 Initial import
thib
parents:
diff changeset
96 int PosY(void);
223b71206888 Initial import
thib
parents:
diff changeset
97 void SetAlpha(void);
223b71206888 Initial import
thib
parents:
diff changeset
98 void SetAlpha(int alpha);
223b71206888 Initial import
thib
parents:
diff changeset
99 void SetSurfaceNum(int num = -1);
223b71206888 Initial import
thib
parents:
diff changeset
100 void SetZoomRotate(int zoom=-1, int rotate=-1);
223b71206888 Initial import
thib
parents:
diff changeset
101 void SetClipArea(int x, int y, int width, int height);
223b71206888 Initial import
thib
parents:
diff changeset
102 void GetSrcGeom(int& width, int& height);
223b71206888 Initial import
thib
parents:
diff changeset
103 void SetUpdate(void);
223b71206888 Initial import
thib
parents:
diff changeset
104 TextStream ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size);
223b71206888 Initial import
thib
parents:
diff changeset
105 void UpdateMoji(void);
223b71206888 Initial import
thib
parents:
diff changeset
106 void UpdateDigit(void);
223b71206888 Initial import
thib
parents:
diff changeset
107 void UpdateSurface(void);
223b71206888 Initial import
thib
parents:
diff changeset
108 void ZoomRotate(void);
223b71206888 Initial import
thib
parents:
diff changeset
109 void Update(void);
223b71206888 Initial import
thib
parents:
diff changeset
110 void CreateSurface(PicContainer* parent);
223b71206888 Initial import
thib
parents:
diff changeset
111 void CreateGan(Event::Container& event, int event_number);
223b71206888 Initial import
thib
parents:
diff changeset
112 void CreateGanSpecial(Event::Container& event, int event_number, int time);
223b71206888 Initial import
thib
parents:
diff changeset
113 PicBase* DeletePic(void);
223b71206888 Initial import
thib
parents:
diff changeset
114 };
223b71206888 Initial import
thib
parents:
diff changeset
115
223b71206888 Initial import
thib
parents:
diff changeset
116 /*******************************************************************
223b71206888 Initial import
thib
parents:
diff changeset
117 ** GrpObj(interface)
223b71206888 Initial import
thib
parents:
diff changeset
118 */
223b71206888 Initial import
thib
parents:
diff changeset
119
223b71206888 Initial import
thib
parents:
diff changeset
120
223b71206888 Initial import
thib
parents:
diff changeset
121 struct GrpObjMap : std::map<int, GrpObj> {
223b71206888 Initial import
thib
parents:
diff changeset
122 typedef pair<const int, GrpObj> value_type;
223b71206888 Initial import
thib
parents:
diff changeset
123 class GrpImpl* parent;
223b71206888 Initial import
thib
parents:
diff changeset
124 GrpObj& operator[](const int& k) {
223b71206888 Initial import
thib
parents:
diff changeset
125 iterator it = lower_bound(k);
223b71206888 Initial import
thib
parents:
diff changeset
126 if (it == end() || it->first != k) {
223b71206888 Initial import
thib
parents:
diff changeset
127 GrpObj obj;
223b71206888 Initial import
thib
parents:
diff changeset
128 obj.parent_pimpl = parent;
223b71206888 Initial import
thib
parents:
diff changeset
129 it = insert(it, value_type(k, obj));
223b71206888 Initial import
thib
parents:
diff changeset
130 }
223b71206888 Initial import
thib
parents:
diff changeset
131 return it->second;
223b71206888 Initial import
thib
parents:
diff changeset
132 }
223b71206888 Initial import
thib
parents:
diff changeset
133 GrpObjMap(class GrpImpl* p) {
223b71206888 Initial import
thib
parents:
diff changeset
134 parent = p;
223b71206888 Initial import
thib
parents:
diff changeset
135 }
223b71206888 Initial import
thib
parents:
diff changeset
136 };
223b71206888 Initial import
thib
parents:
diff changeset
137
223b71206888 Initial import
thib
parents:
diff changeset
138 class GrpImpl {
223b71206888 Initial import
thib
parents:
diff changeset
139 #define MAXPDT 256
223b71206888 Initial import
thib
parents:
diff changeset
140 #define WORKPDT 255
223b71206888 Initial import
thib
parents:
diff changeset
141 Event::Container& event;
223b71206888 Initial import
thib
parents:
diff changeset
142 const Flags& flags;
223b71206888 Initial import
thib
parents:
diff changeset
143 PicBase* screen;
223b71206888 Initial import
thib
parents:
diff changeset
144 PicBase* screen_front;
223b71206888 Initial import
thib
parents:
diff changeset
145 Surface* surface, *surface_update;
223b71206888 Initial import
thib
parents:
diff changeset
146
223b71206888 Initial import
thib
parents:
diff changeset
147 Surface* dsurface[MAXPDT]; // 書き込み可能な Surface
223b71206888 Initial import
thib
parents:
diff changeset
148 Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface
223b71206888 Initial import
thib
parents:
diff changeset
149 PicContainer& parent;
223b71206888 Initial import
thib
parents:
diff changeset
150
223b71206888 Initial import
thib
parents:
diff changeset
151 // 画像効果の保存用
223b71206888 Initial import
thib
parents:
diff changeset
152 WidAnmTime* anm1, *anm2;
223b71206888 Initial import
thib
parents:
diff changeset
153 typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status;
223b71206888 Initial import
thib
parents:
diff changeset
154 Status status;
223b71206888 Initial import
thib
parents:
diff changeset
155 SkipMode skip_mode;
223b71206888 Initial import
thib
parents:
diff changeset
156
223b71206888 Initial import
thib
parents:
diff changeset
157 std::string bg_name;
223b71206888 Initial import
thib
parents:
diff changeset
158 std::map<int, SEL> anmtype;
223b71206888 Initial import
thib
parents:
diff changeset
159 GrpObjMap grpobj;
223b71206888 Initial import
thib
parents:
diff changeset
160 GrpObjMap bs_obj;
223b71206888 Initial import
thib
parents:
diff changeset
161 void CreateObj(int number);
223b71206888 Initial import
thib
parents:
diff changeset
162 void ZMoveObj(int number);
223b71206888 Initial import
thib
parents:
diff changeset
163 void SetObjChanged(int number);
223b71206888 Initial import
thib
parents:
diff changeset
164 void SetObjChangedGroup(int number);
223b71206888 Initial import
thib
parents:
diff changeset
165 void SwapObj(int a1, int a2);
223b71206888 Initial import
thib
parents:
diff changeset
166 void DeleteObjPic(int num);// object の surface のみ削除
223b71206888 Initial import
thib
parents:
diff changeset
167 void DeleteObj(int num);
223b71206888 Initial import
thib
parents:
diff changeset
168 void DeleteObjRange(int num_b, int num_e);
223b71206888 Initial import
thib
parents:
diff changeset
169
223b71206888 Initial import
thib
parents:
diff changeset
170 std::set<int> changed_obj;
223b71206888 Initial import
thib
parents:
diff changeset
171 string reserved_load_surface0;
223b71206888 Initial import
thib
parents:
diff changeset
172 vector<PicBase*> deleted_pic;
223b71206888 Initial import
thib
parents:
diff changeset
173 void RefreshObj(void);
223b71206888 Initial import
thib
parents:
diff changeset
174
223b71206888 Initial import
thib
parents:
diff changeset
175 Surface* Dsurface(int pdt);
223b71206888 Initial import
thib
parents:
diff changeset
176 Surface* Ssurface(int pdt);
223b71206888 Initial import
thib
parents:
diff changeset
177
223b71206888 Initial import
thib
parents:
diff changeset
178 // cgmode 用画像処理関連
223b71206888 Initial import
thib
parents:
diff changeset
179 void LoadCgm(AyuSysConfig& config);
223b71206888 Initial import
thib
parents:
diff changeset
180 std::map<std::string, int> cgm_info;
223b71206888 Initial import
thib
parents:
diff changeset
181 set<int>& cgm_data;
20
824b89018ea8 * CG completion percentage (maybe not working properly?)
thib
parents: 18
diff changeset
182 int cgm_size;
0
223b71206888 Initial import
thib
parents:
diff changeset
183
223b71206888 Initial import
thib
parents:
diff changeset
184 class MuSys& music;
223b71206888 Initial import
thib
parents:
diff changeset
185
223b71206888 Initial import
thib
parents:
diff changeset
186 public:
223b71206888 Initial import
thib
parents:
diff changeset
187 AyuSysConfig& config;
223b71206888 Initial import
thib
parents:
diff changeset
188 void LoadSurface(const char* str, int pdt);
223b71206888 Initial import
thib
parents:
diff changeset
189 private:
223b71206888 Initial import
thib
parents:
diff changeset
190 void LoadSurface(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
191 void LoadSurface(void);
223b71206888 Initial import
thib
parents:
diff changeset
192 void AddSurface(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
193
223b71206888 Initial import
thib
parents:
diff changeset
194 void StartAnm(int type);
223b71206888 Initial import
thib
parents:
diff changeset
195 void StartShake(int total, const int* pattern);
223b71206888 Initial import
thib
parents:
diff changeset
196 void AbortAnm(void);
223b71206888 Initial import
thib
parents:
diff changeset
197 static bool Pressed(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
198 public:
223b71206888 Initial import
thib
parents:
diff changeset
199 GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config);
223b71206888 Initial import
thib
parents:
diff changeset
200 ~GrpImpl();
223b71206888 Initial import
thib
parents:
diff changeset
201 bool Wait(unsigned int current_time, Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
202 void Exec(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
203 void InitSel(AyuSysConfig& config);
223b71206888 Initial import
thib
parents:
diff changeset
204 void Save(std::string& str);
223b71206888 Initial import
thib
parents:
diff changeset
205 void Load(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
206 void SaveSys(std::string& str);
223b71206888 Initial import
thib
parents:
diff changeset
207 void LoadSys(const char* str);
223b71206888 Initial import
thib
parents:
diff changeset
208 void SetSkipMode(SkipMode _mode);
223b71206888 Initial import
thib
parents:
diff changeset
209 };
223b71206888 Initial import
thib
parents:
diff changeset
210 /*******************************************************************
223b71206888 Initial import
thib
parents:
diff changeset
211 ** GrpObj(implementation)
223b71206888 Initial import
thib
parents:
diff changeset
212 */
223b71206888 Initial import
thib
parents:
diff changeset
213
223b71206888 Initial import
thib
parents:
diff changeset
214 GrpObj::GrpObj(void) :
223b71206888 Initial import
thib
parents:
diff changeset
215 name(""), gan_name(""), pic_parent(0), picture(0), anm(0),
223b71206888 Initial import
thib
parents:
diff changeset
216 _posx(0), _posy(0), clip_area(0,0,0,0),
223b71206888 Initial import
thib
parents:
diff changeset
217 alpha(255), order(0), surface_num(0), print_moji(""), print_size(0), print_r(-1),print_g(-1),print_b(-1),
223b71206888 Initial import
thib
parents:
diff changeset
218 dig_number(0), dig_digit(0),
223b71206888 Initial import
thib
parents:
diff changeset
219 zoom(-1), rotate(-1), attr(GrpObj::HIDDEN), parent_pimpl(0) {
223b71206888 Initial import
thib
parents:
diff changeset
220 int i;
223b71206888 Initial import
thib
parents:
diff changeset
221 for (i=0; i<9; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
222 posx[i] = posy[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
223 }
223b71206888 Initial import
thib
parents:
diff changeset
224 }
223b71206888 Initial import
thib
parents:
diff changeset
225 GrpObj::~GrpObj() {
223b71206888 Initial import
thib
parents:
diff changeset
226 if (picture) delete picture;
223b71206888 Initial import
thib
parents:
diff changeset
227 if (parent_pimpl == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
228 fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n");
223b71206888 Initial import
thib
parents:
diff changeset
229 }
223b71206888 Initial import
thib
parents:
diff changeset
230 }
223b71206888 Initial import
thib
parents:
diff changeset
231 int GrpObj::PosX() {
223b71206888 Initial import
thib
parents:
diff changeset
232 return _posx;
223b71206888 Initial import
thib
parents:
diff changeset
233 }
223b71206888 Initial import
thib
parents:
diff changeset
234 int GrpObj::PosY() {
223b71206888 Initial import
thib
parents:
diff changeset
235 return _posy;
223b71206888 Initial import
thib
parents:
diff changeset
236 }
223b71206888 Initial import
thib
parents:
diff changeset
237 void GrpObj::SetUpdate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
238 attr = Attribute (attr | UPDATE_PICTURE);
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
239 //Update(); //FIXME
0
223b71206888 Initial import
thib
parents:
diff changeset
240 }
223b71206888 Initial import
thib
parents:
diff changeset
241 void GrpObj::SetPos(int index, int x,int y) {
223b71206888 Initial import
thib
parents:
diff changeset
242 if (index < 0 || index > 8) {
223b71206888 Initial import
thib
parents:
diff changeset
243 fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y);
223b71206888 Initial import
thib
parents:
diff changeset
244 return;
223b71206888 Initial import
thib
parents:
diff changeset
245 }
223b71206888 Initial import
thib
parents:
diff changeset
246 if (x == posx[index] && y == posy[index]) return;
223b71206888 Initial import
thib
parents:
diff changeset
247 attr = Attribute(attr | UPDATE_POS);
223b71206888 Initial import
thib
parents:
diff changeset
248 _posx += x-posx[index];
223b71206888 Initial import
thib
parents:
diff changeset
249 _posy += y-posy[index];
223b71206888 Initial import
thib
parents:
diff changeset
250 posx[index] = x;
223b71206888 Initial import
thib
parents:
diff changeset
251 posy[index] = y;
223b71206888 Initial import
thib
parents:
diff changeset
252 }
223b71206888 Initial import
thib
parents:
diff changeset
253 void GrpObj::GetPos(int index, int& x, int& y) {
223b71206888 Initial import
thib
parents:
diff changeset
254 if (index < 0 || index > 8) {
223b71206888 Initial import
thib
parents:
diff changeset
255 fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index);
223b71206888 Initial import
thib
parents:
diff changeset
256 x = 0; y = 0;
223b71206888 Initial import
thib
parents:
diff changeset
257 return;
223b71206888 Initial import
thib
parents:
diff changeset
258 }
223b71206888 Initial import
thib
parents:
diff changeset
259 x = posx[index];
223b71206888 Initial import
thib
parents:
diff changeset
260 y = posy[index];
223b71206888 Initial import
thib
parents:
diff changeset
261 return;
223b71206888 Initial import
thib
parents:
diff changeset
262 }
223b71206888 Initial import
thib
parents:
diff changeset
263 void GrpObj::SetAlpha(int new_alpha) {
223b71206888 Initial import
thib
parents:
diff changeset
264 if (alpha == new_alpha) return;
223b71206888 Initial import
thib
parents:
diff changeset
265 alpha = new_alpha;
223b71206888 Initial import
thib
parents:
diff changeset
266 attr = Attribute(attr | UPDATE_ALPHA);
223b71206888 Initial import
thib
parents:
diff changeset
267 return;
223b71206888 Initial import
thib
parents:
diff changeset
268 }
223b71206888 Initial import
thib
parents:
diff changeset
269 void GrpObj::SetSurfaceNum(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
270 if (num != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
271 if (surface_num == num) return;
223b71206888 Initial import
thib
parents:
diff changeset
272 surface_num = num;
223b71206888 Initial import
thib
parents:
diff changeset
273 }
223b71206888 Initial import
thib
parents:
diff changeset
274 attr = Attribute(attr | UPDATE_SNUM);
223b71206888 Initial import
thib
parents:
diff changeset
275 return;
223b71206888 Initial import
thib
parents:
diff changeset
276 }
223b71206888 Initial import
thib
parents:
diff changeset
277
223b71206888 Initial import
thib
parents:
diff changeset
278 void GrpObj::SetClipArea(int x, int y, int w, int h) {
223b71206888 Initial import
thib
parents:
diff changeset
279 Rect new_clip(x,y,x+w,y+h);
223b71206888 Initial import
thib
parents:
diff changeset
280 if (clip_area == new_clip) return;
223b71206888 Initial import
thib
parents:
diff changeset
281 clip_area = new_clip;
223b71206888 Initial import
thib
parents:
diff changeset
282 attr = Attribute(attr | UPDATE_CLIP);
223b71206888 Initial import
thib
parents:
diff changeset
283 return;
223b71206888 Initial import
thib
parents:
diff changeset
284 }
223b71206888 Initial import
thib
parents:
diff changeset
285 PicBase* GrpObj::DeletePic(void) {
223b71206888 Initial import
thib
parents:
diff changeset
286 PicBase* p = picture;
223b71206888 Initial import
thib
parents:
diff changeset
287 anm = 0;
223b71206888 Initial import
thib
parents:
diff changeset
288 picture = 0;
223b71206888 Initial import
thib
parents:
diff changeset
289 src_pos.clear();
223b71206888 Initial import
thib
parents:
diff changeset
290 attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP));
223b71206888 Initial import
thib
parents:
diff changeset
291 return p;
223b71206888 Initial import
thib
parents:
diff changeset
292 }
223b71206888 Initial import
thib
parents:
diff changeset
293 void GrpObj::GetSrcGeom(int& width, int& height) {
223b71206888 Initial import
thib
parents:
diff changeset
294 if (src_pos.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
295 width = 0; height = 0;
223b71206888 Initial import
thib
parents:
diff changeset
296 if (name.length() == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
297 return;
223b71206888 Initial import
thib
parents:
diff changeset
298 }
223b71206888 Initial import
thib
parents:
diff changeset
299 /* ボタンの位置情報を求める */
223b71206888 Initial import
thib
parents:
diff changeset
300 /* g00 ファイルのヘッダ部分に位置情報は入っている */
223b71206888 Initial import
thib
parents:
diff changeset
301 string path(name);
223b71206888 Initial import
thib
parents:
diff changeset
302 path += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
303 ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00");
223b71206888 Initial import
thib
parents:
diff changeset
304 if (info == 0) { // ファイルが見つからない
223b71206888 Initial import
thib
parents:
diff changeset
305 fprintf(stderr,"GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
306 return;
223b71206888 Initial import
thib
parents:
diff changeset
307 }
223b71206888 Initial import
thib
parents:
diff changeset
308 const char* data = info->Read();
223b71206888 Initial import
thib
parents:
diff changeset
309 if (data && *data == 2) { // 画像ファイル内にボタン情報が存在する
223b71206888 Initial import
thib
parents:
diff changeset
310 int srclen = read_little_endian_int(data+5);
223b71206888 Initial import
thib
parents:
diff changeset
311 int i;
223b71206888 Initial import
thib
parents:
diff changeset
312 for (i=0; i<srclen; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
313 int x1 = read_little_endian_int(data+9+i*24+0);
223b71206888 Initial import
thib
parents:
diff changeset
314 int y1 = read_little_endian_int(data+9+i*24+4);
223b71206888 Initial import
thib
parents:
diff changeset
315 int x2 = read_little_endian_int(data+9+i*24+8);
223b71206888 Initial import
thib
parents:
diff changeset
316 int y2 = read_little_endian_int(data+9+i*24+12);
223b71206888 Initial import
thib
parents:
diff changeset
317 src_pos.push_back(Rect(x1, y1, x2+1, y2+1));
223b71206888 Initial import
thib
parents:
diff changeset
318 if (width < src_pos.back().width()) width = src_pos.back().width();
223b71206888 Initial import
thib
parents:
diff changeset
319 if (height < src_pos.back().height()) height = src_pos.back().height();
223b71206888 Initial import
thib
parents:
diff changeset
320 }
223b71206888 Initial import
thib
parents:
diff changeset
321 } else { // 画像ファイルから大きさ取得
223b71206888 Initial import
thib
parents:
diff changeset
322 width = read_little_endian_short(data+1);
223b71206888 Initial import
thib
parents:
diff changeset
323 height = read_little_endian_short(data+3);
223b71206888 Initial import
thib
parents:
diff changeset
324 src_pos.push_back(Rect(0,0,width,height));
223b71206888 Initial import
thib
parents:
diff changeset
325 }
223b71206888 Initial import
thib
parents:
diff changeset
326 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
327 }
223b71206888 Initial import
thib
parents:
diff changeset
328 int sn = surface_num;
223b71206888 Initial import
thib
parents:
diff changeset
329 if (sn < 0 || sn > src_pos.size()) sn = 0;
223b71206888 Initial import
thib
parents:
diff changeset
330 width = src_pos[sn].width();
223b71206888 Initial import
thib
parents:
diff changeset
331 height = src_pos[sn].height();
223b71206888 Initial import
thib
parents:
diff changeset
332 return;
223b71206888 Initial import
thib
parents:
diff changeset
333 }
223b71206888 Initial import
thib
parents:
diff changeset
334 void GrpObj::Update(void) {
223b71206888 Initial import
thib
parents:
diff changeset
335 if (attr & UPDATE_PICTURE) {
223b71206888 Initial import
thib
parents:
diff changeset
336 UpdateSurface();
223b71206888 Initial import
thib
parents:
diff changeset
337 attr = Attribute( (attr | UPDATE_ALL) & (~UPDATE_PICTURE));
223b71206888 Initial import
thib
parents:
diff changeset
338 }
223b71206888 Initial import
thib
parents:
diff changeset
339 if (picture == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
340 if (attr & UPDATE_POS) {
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
341 if ( (attr & SATURATE) || zoom != -1) {
0
223b71206888 Initial import
thib
parents:
diff changeset
342 int w=0, h=0;
223b71206888 Initial import
thib
parents:
diff changeset
343 GetSrcGeom(w,h);
223b71206888 Initial import
thib
parents:
diff changeset
344 picture->Move(_posx-w/2, _posy-h/2);
223b71206888 Initial import
thib
parents:
diff changeset
345 } else {
223b71206888 Initial import
thib
parents:
diff changeset
346 picture->Move(_posx, _posy);
223b71206888 Initial import
thib
parents:
diff changeset
347 }
223b71206888 Initial import
thib
parents:
diff changeset
348 }
223b71206888 Initial import
thib
parents:
diff changeset
349 if (attr & UPDATE_ALPHA) {
223b71206888 Initial import
thib
parents:
diff changeset
350 if (alpha <= 0) {
223b71206888 Initial import
thib
parents:
diff changeset
351 picture->SetSurfaceAlpha(0, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
352 picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
353 } else if (alpha >= ALPHA_MAX) {
223b71206888 Initial import
thib
parents:
diff changeset
354 picture->SetSurfaceAlpha(0, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
355 if (attr & HIDDEN) picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
356 else picture->show();
223b71206888 Initial import
thib
parents:
diff changeset
357 } else {
223b71206888 Initial import
thib
parents:
diff changeset
358 picture->SetSurfaceAlpha(&alpha, Rect(0,0,1,1));
223b71206888 Initial import
thib
parents:
diff changeset
359 if (attr & HIDDEN) picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
360 else picture->show();
223b71206888 Initial import
thib
parents:
diff changeset
361 }
223b71206888 Initial import
thib
parents:
diff changeset
362 }
223b71206888 Initial import
thib
parents:
diff changeset
363 if ( (attr & UPDATE_SNUM) && (!src_pos.empty())) {
223b71206888 Initial import
thib
parents:
diff changeset
364 if (surface_num < 0 || surface_num >= src_pos.size()) surface_num = 0;
223b71206888 Initial import
thib
parents:
diff changeset
365 picture->SetSurfacePos(src_pos[surface_num].lx, src_pos[surface_num].ty);
223b71206888 Initial import
thib
parents:
diff changeset
366 }
223b71206888 Initial import
thib
parents:
diff changeset
367 if (attr & UPDATE_CLIP) {
223b71206888 Initial import
thib
parents:
diff changeset
368 picture->SetClipArea(clip_area);
223b71206888 Initial import
thib
parents:
diff changeset
369 }
223b71206888 Initial import
thib
parents:
diff changeset
370 attr = Attribute(attr & (~UPDATE_ALL));
223b71206888 Initial import
thib
parents:
diff changeset
371 if (attr & ANM_PLAYSTART) {
223b71206888 Initial import
thib
parents:
diff changeset
372 if (anm) {
223b71206888 Initial import
thib
parents:
diff changeset
373 anm->Play();
223b71206888 Initial import
thib
parents:
diff changeset
374 attr = Attribute(attr | ANM_PLAYING);
223b71206888 Initial import
thib
parents:
diff changeset
375 }
223b71206888 Initial import
thib
parents:
diff changeset
376 attr = Attribute(attr & (~ANM_PLAYSTART));
223b71206888 Initial import
thib
parents:
diff changeset
377 }
223b71206888 Initial import
thib
parents:
diff changeset
378 }
223b71206888 Initial import
thib
parents:
diff changeset
379 void GrpObj::CreateSurface(PicContainer* parent) {
223b71206888 Initial import
thib
parents:
diff changeset
380 if (picture) {
223b71206888 Initial import
thib
parents:
diff changeset
381 PicBase* p = DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
382 delete p;
223b71206888 Initial import
thib
parents:
diff changeset
383 }
223b71206888 Initial import
thib
parents:
diff changeset
384 src_pos.clear();
223b71206888 Initial import
thib
parents:
diff changeset
385 // picture を作成
223b71206888 Initial import
thib
parents:
diff changeset
386 pic_parent = parent;
223b71206888 Initial import
thib
parents:
diff changeset
387 picture = parent->create_leaf(Rect(_posx,_posy,_posx+1,_posy+1), 0);
223b71206888 Initial import
thib
parents:
diff changeset
388 picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
389 UpdateSurface();
223b71206888 Initial import
thib
parents:
diff changeset
390 }
223b71206888 Initial import
thib
parents:
diff changeset
391
223b71206888 Initial import
thib
parents:
diff changeset
392 void GrpObj::UpdateSurface(void) {
223b71206888 Initial import
thib
parents:
diff changeset
393 if (pic_parent == 0 || picture == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
394 int width = 0, height = 0;
223b71206888 Initial import
thib
parents:
diff changeset
395 if (gtype == FILE || gtype == GAN) {
223b71206888 Initial import
thib
parents:
diff changeset
396 if (name.length() == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
397 // ファイル名が存在する場合、ファイルを読み込み
223b71206888 Initial import
thib
parents:
diff changeset
398 GetSrcGeom(width, height);
223b71206888 Initial import
thib
parents:
diff changeset
399 if (width <= 0 || height <= 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
400 // surface の設定
223b71206888 Initial import
thib
parents:
diff changeset
401 if (surface_num == 0 && ( (zoom > 0 && zoom != 256) || rotate > 0)) {
223b71206888 Initial import
thib
parents:
diff changeset
402 ZoomRotate();
223b71206888 Initial import
thib
parents:
diff changeset
403 } else {
223b71206888 Initial import
thib
parents:
diff changeset
404 // 普通に surface を設定
223b71206888 Initial import
thib
parents:
diff changeset
405 string path(name);
223b71206888 Initial import
thib
parents:
diff changeset
406 path += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
407 picture->SetSurface(path.c_str(), 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
408 picture->SetSurfaceRect(Rect(0,0,width,height));
223b71206888 Initial import
thib
parents:
diff changeset
409 }
223b71206888 Initial import
thib
parents:
diff changeset
410 if (attr & SATURATE)
223b71206888 Initial import
thib
parents:
diff changeset
411 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE);
223b71206888 Initial import
thib
parents:
diff changeset
412 } else if (gtype == MOJI) { // テキスト描画
223b71206888 Initial import
thib
parents:
diff changeset
413 if (print_moji.length() == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
414 UpdateMoji();
223b71206888 Initial import
thib
parents:
diff changeset
415 } else if (gtype == DIGIT) { // 数値を画像表示
223b71206888 Initial import
thib
parents:
diff changeset
416 UpdateDigit();
223b71206888 Initial import
thib
parents:
diff changeset
417 }
223b71206888 Initial import
thib
parents:
diff changeset
418 }
223b71206888 Initial import
thib
parents:
diff changeset
419 void GrpObj::ZoomRotate(void) {
223b71206888 Initial import
thib
parents:
diff changeset
420 picture->SetSurface( (Surface*)0,0,0);
223b71206888 Initial import
thib
parents:
diff changeset
421
223b71206888 Initial import
thib
parents:
diff changeset
422 // 回転、縮小拡大は座標原点が画像の中心になる
223b71206888 Initial import
thib
parents:
diff changeset
423 string path(name);
223b71206888 Initial import
thib
parents:
diff changeset
424 path += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
425 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
426 if (surface_orig == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
427
223b71206888 Initial import
thib
parents:
diff changeset
428 Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate);
223b71206888 Initial import
thib
parents:
diff changeset
429 Rect zoom_r (*zoom_surface);
223b71206888 Initial import
thib
parents:
diff changeset
430 picture->SetSurface(zoom_surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
431 picture->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
432 //picture->Move(PosX() + - zoom_r.width()/2, PosY() + - zoom_r.height()/2);
223b71206888 Initial import
thib
parents:
diff changeset
433 // 中心座標がわからん・・・
223b71206888 Initial import
thib
parents:
diff changeset
434 picture->Move(320 - zoom_r.width()/2, 240 - zoom_r.height()/2);
223b71206888 Initial import
thib
parents:
diff changeset
435 picture->SetSurfaceRect(Rect(0, 0, zoom_r.width(), zoom_r.height()));
223b71206888 Initial import
thib
parents:
diff changeset
436
223b71206888 Initial import
thib
parents:
diff changeset
437 pic_parent->Root().DeleteSurface(surface_orig);
223b71206888 Initial import
thib
parents:
diff changeset
438 }
223b71206888 Initial import
thib
parents:
diff changeset
439
223b71206888 Initial import
thib
parents:
diff changeset
440 static char* wstrchr(const char* s, unsigned int chr) {
223b71206888 Initial import
thib
parents:
diff changeset
441 int ws, wc;
223b71206888 Initial import
thib
parents:
diff changeset
442 while(*s != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
443 if (*s < 0 && s[1] != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
444 wc = int((unsigned char)(s[0]))*0x100 + int((unsigned char)(s[1]));
223b71206888 Initial import
thib
parents:
diff changeset
445 ws = 2;
223b71206888 Initial import
thib
parents:
diff changeset
446 } else {
223b71206888 Initial import
thib
parents:
diff changeset
447 wc = (unsigned char)(s[0]);
223b71206888 Initial import
thib
parents:
diff changeset
448 ws = 1;
223b71206888 Initial import
thib
parents:
diff changeset
449 }
223b71206888 Initial import
thib
parents:
diff changeset
450 if (wc == chr) return (char*)s;
223b71206888 Initial import
thib
parents:
diff changeset
451 s += ws;
223b71206888 Initial import
thib
parents:
diff changeset
452 }
223b71206888 Initial import
thib
parents:
diff changeset
453 return 0;
223b71206888 Initial import
thib
parents:
diff changeset
454 }
223b71206888 Initial import
thib
parents:
diff changeset
455 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse
223b71206888 Initial import
thib
parents:
diff changeset
456 TextStream ts;
223b71206888 Initial import
thib
parents:
diff changeset
457 ts.kanji_type = TextStream::sjis;
223b71206888 Initial import
thib
parents:
diff changeset
458 ts.SetColor(def_r, def_g, def_b);
223b71206888 Initial import
thib
parents:
diff changeset
459 char* copy_str = new char[strlen(str)+1];
223b71206888 Initial import
thib
parents:
diff changeset
460 char* next_str;
223b71206888 Initial import
thib
parents:
diff changeset
461 char* retptr;
223b71206888 Initial import
thib
parents:
diff changeset
462 int var;
223b71206888 Initial import
thib
parents:
diff changeset
463
223b71206888 Initial import
thib
parents:
diff changeset
464 while( (next_str = wstrchr(str, '#')) != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
465 int len = next_str - str;
223b71206888 Initial import
thib
parents:
diff changeset
466 strncpy(copy_str, str, len);
223b71206888 Initial import
thib
parents:
diff changeset
467 copy_str[len] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
468 ts.Add(copy_str);
223b71206888 Initial import
thib
parents:
diff changeset
469 str = next_str + 1;
223b71206888 Initial import
thib
parents:
diff changeset
470
223b71206888 Initial import
thib
parents:
diff changeset
471 switch(str[0]) {
223b71206888 Initial import
thib
parents:
diff changeset
472 case '#': // separator
223b71206888 Initial import
thib
parents:
diff changeset
473 str += 1;
223b71206888 Initial import
thib
parents:
diff changeset
474 break;
223b71206888 Initial import
thib
parents:
diff changeset
475 case 'D': case 'd': // return
223b71206888 Initial import
thib
parents:
diff changeset
476 ts.AddReturn();
223b71206888 Initial import
thib
parents:
diff changeset
477 str += 1;
223b71206888 Initial import
thib
parents:
diff changeset
478 break;
223b71206888 Initial import
thib
parents:
diff changeset
479 case 'C': case 'c': // color
223b71206888 Initial import
thib
parents:
diff changeset
480 str += 1;
223b71206888 Initial import
thib
parents:
diff changeset
481 var = strtol(str, &next_str,10);
223b71206888 Initial import
thib
parents:
diff changeset
482 if (var == 0 && str == next_str) { // no parameter
223b71206888 Initial import
thib
parents:
diff changeset
483 ts.SetColor(def_r, def_g, def_b);
223b71206888 Initial import
thib
parents:
diff changeset
484 } else {
223b71206888 Initial import
thib
parents:
diff changeset
485 int r,g,b; char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
486 sprintf(key, "#COLOR_TABLE.%03d", var);
223b71206888 Initial import
thib
parents:
diff changeset
487 if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found
223b71206888 Initial import
thib
parents:
diff changeset
488 r = g = b = 0;
223b71206888 Initial import
thib
parents:
diff changeset
489 }
223b71206888 Initial import
thib
parents:
diff changeset
490 ts.SetColor(r,g,b);
223b71206888 Initial import
thib
parents:
diff changeset
491 str = next_str;
223b71206888 Initial import
thib
parents:
diff changeset
492 }
223b71206888 Initial import
thib
parents:
diff changeset
493 break;
223b71206888 Initial import
thib
parents:
diff changeset
494 case 'S': case 's': // size
223b71206888 Initial import
thib
parents:
diff changeset
495 str += 1;
223b71206888 Initial import
thib
parents:
diff changeset
496 var = strtol(str, &next_str, 10);
223b71206888 Initial import
thib
parents:
diff changeset
497 if (var == 0 && str == next_str) { // no parameter
223b71206888 Initial import
thib
parents:
diff changeset
498 ts.SetSize(1);
223b71206888 Initial import
thib
parents:
diff changeset
499 } else {
223b71206888 Initial import
thib
parents:
diff changeset
500 if (def_size == 0) def_size = 20;
223b71206888 Initial import
thib
parents:
diff changeset
501 if (var <= 0) var = 1;
223b71206888 Initial import
thib
parents:
diff changeset
502 ts.SetSize(double(var)/def_size);
223b71206888 Initial import
thib
parents:
diff changeset
503 }
223b71206888 Initial import
thib
parents:
diff changeset
504 break;
223b71206888 Initial import
thib
parents:
diff changeset
505 case 'X': case 'x': // xpos : not supported
223b71206888 Initial import
thib
parents:
diff changeset
506 case 'Y': case 'y': // ypos : not supported
223b71206888 Initial import
thib
parents:
diff changeset
507 default:
223b71206888 Initial import
thib
parents:
diff changeset
508 ts.Add("#");
223b71206888 Initial import
thib
parents:
diff changeset
509 break;
223b71206888 Initial import
thib
parents:
diff changeset
510 }
223b71206888 Initial import
thib
parents:
diff changeset
511 }
223b71206888 Initial import
thib
parents:
diff changeset
512 ts.Add(str);
223b71206888 Initial import
thib
parents:
diff changeset
513 return ts;
223b71206888 Initial import
thib
parents:
diff changeset
514 }
223b71206888 Initial import
thib
parents:
diff changeset
515 void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更
14
8da1d92ac8f8 Don't create fonts faces for size <= 0, and update objects when their font size is set
thib
parents: 11
diff changeset
516 if (print_moji.length() == 0 || print_size <= 2) return;
0
223b71206888 Initial import
thib
parents:
diff changeset
517 if (pic_parent == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
518 /* テキストの大きさを得る */
223b71206888 Initial import
thib
parents:
diff changeset
519 int r, g, b;
223b71206888 Initial import
thib
parents:
diff changeset
520 if (print_r == -1 || print_g == -1 || print_b == -1) {// 色設定なし
223b71206888 Initial import
thib
parents:
diff changeset
521 r = g = b = 0; // とりあえず黒(clannad のSave/Loadメニュー用)
223b71206888 Initial import
thib
parents:
diff changeset
522 } else {
223b71206888 Initial import
thib
parents:
diff changeset
523 r = print_r;
223b71206888 Initial import
thib
parents:
diff changeset
524 g = print_g;
223b71206888 Initial import
thib
parents:
diff changeset
525 b = print_b;
223b71206888 Initial import
thib
parents:
diff changeset
526 }
223b71206888 Initial import
thib
parents:
diff changeset
527 TextStream ts = ParseMoji(print_moji.c_str(), r, g, b, print_size);
223b71206888 Initial import
thib
parents:
diff changeset
528 TextGlyphStream gs;
223b71206888 Initial import
thib
parents:
diff changeset
529 vector<int> lh;
223b71206888 Initial import
thib
parents:
diff changeset
530 // とりあえず drawable width は充分に大きく(2048)取る
223b71206888 Initial import
thib
parents:
diff changeset
531 DefaultLayout(print_size-2)->Layout(ts, gs, lh, 2048); // print_size そのままだと弱干大きすぎるので -2
223b71206888 Initial import
thib
parents:
diff changeset
532 int width = gs.width();
223b71206888 Initial import
thib
parents:
diff changeset
533 int height = gs.height();
223b71206888 Initial import
thib
parents:
diff changeset
534 Surface* surface = pic_parent->Root().NewSurface(width, height, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
535 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
536 DSurfaceRenderText(gs.begin(), gs.end(), Rect(0, 0, width, height), surface, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
537 picture->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
538 picture->SetSurfaceRect(Rect(0,0,width,height));
223b71206888 Initial import
thib
parents:
diff changeset
539 picture->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
540 }
223b71206888 Initial import
thib
parents:
diff changeset
541 void GrpObj::UpdateDigit(void) {
223b71206888 Initial import
thib
parents:
diff changeset
542 // 画像表示の数値文字列を表示する
223b71206888 Initial import
thib
parents:
diff changeset
543 if (name.length() == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
544 // ファイル名が存在する場合、ファイルを読み込み
223b71206888 Initial import
thib
parents:
diff changeset
545 string path(name);
223b71206888 Initial import
thib
parents:
diff changeset
546 path += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
547 Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
548 if (surface_orig == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
549
223b71206888 Initial import
thib
parents:
diff changeset
550 int width, height;
223b71206888 Initial import
thib
parents:
diff changeset
551 int i;
223b71206888 Initial import
thib
parents:
diff changeset
552 GetSrcGeom(width, height);
223b71206888 Initial import
thib
parents:
diff changeset
553 if (width <= 0 || height <= 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
554 if (src_pos.size() < 14) {
223b71206888 Initial import
thib
parents:
diff changeset
555 // 必要な数の object がない
223b71206888 Initial import
thib
parents:
diff changeset
556 // 表示できない分の空の rect を追加しておく
223b71206888 Initial import
thib
parents:
diff changeset
557 for (i=src_pos.size(); i<14; i++)
223b71206888 Initial import
thib
parents:
diff changeset
558 src_pos.push_back(Rect(0,0,0,0));
223b71206888 Initial import
thib
parents:
diff changeset
559 pic_parent->Root().DeleteSurface(surface_orig);
223b71206888 Initial import
thib
parents:
diff changeset
560 return;
223b71206888 Initial import
thib
parents:
diff changeset
561 }
223b71206888 Initial import
thib
parents:
diff changeset
562 // 桁数の計算
223b71206888 Initial import
thib
parents:
diff changeset
563 char num_str[20];
223b71206888 Initial import
thib
parents:
diff changeset
564 if (dig_number < 0) sprintf(num_str, "%d", -dig_number);
223b71206888 Initial import
thib
parents:
diff changeset
565 else sprintf(num_str, "%d", dig_number);
223b71206888 Initial import
thib
parents:
diff changeset
566 int sign_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
567 int space_count = 0;
223b71206888 Initial import
thib
parents:
diff changeset
568 int total_count;
223b71206888 Initial import
thib
parents:
diff changeset
569 int dig_count = strlen(num_str);
223b71206888 Initial import
thib
parents:
diff changeset
570 if (dig_number < 0 && (attr&DIG_SIGN) == 0) dig_count++;
223b71206888 Initial import
thib
parents:
diff changeset
571 if (dig_count < dig_digit) space_count = dig_digit - dig_count;
223b71206888 Initial import
thib
parents:
diff changeset
572 if (attr & DIG_SIGN) sign_count = 1;
223b71206888 Initial import
thib
parents:
diff changeset
573 total_count = dig_count + space_count + sign_count;
223b71206888 Initial import
thib
parents:
diff changeset
574
223b71206888 Initial import
thib
parents:
diff changeset
575 Surface* surface = pic_parent->Root().NewSurface(width*total_count, height, ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
576 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
577
223b71206888 Initial import
thib
parents:
diff changeset
578 /* surface にコピーする */
223b71206888 Initial import
thib
parents:
diff changeset
579 int cur_x = 0;
223b71206888 Initial import
thib
parents:
diff changeset
580 if ( (attr & DIG_PACK) && !(attr & DIG_ZERO)) { // 始めに空白を挿入
223b71206888 Initial import
thib
parents:
diff changeset
581 cur_x += space_count * width;
223b71206888 Initial import
thib
parents:
diff changeset
582 }
223b71206888 Initial import
thib
parents:
diff changeset
583 int plus = 10, minus = 11, plusminus = 12;
223b71206888 Initial import
thib
parents:
diff changeset
584 if (dig_number < 0) {
223b71206888 Initial import
thib
parents:
diff changeset
585 DSurfaceMove(surface, src_pos[minus], surface, Rect(cur_x,0));
223b71206888 Initial import
thib
parents:
diff changeset
586 cur_x += width;
223b71206888 Initial import
thib
parents:
diff changeset
587 } else if (attr & DIG_SIGN) {
223b71206888 Initial import
thib
parents:
diff changeset
588 if (dig_number == 0)
223b71206888 Initial import
thib
parents:
diff changeset
589 DSurfaceMove(surface, src_pos[plusminus], surface, Rect(cur_x,0));
223b71206888 Initial import
thib
parents:
diff changeset
590 else
223b71206888 Initial import
thib
parents:
diff changeset
591 DSurfaceMove(surface, src_pos[plus], surface, Rect(cur_x,0));
223b71206888 Initial import
thib
parents:
diff changeset
592 cur_x += width;
223b71206888 Initial import
thib
parents:
diff changeset
593 }
223b71206888 Initial import
thib
parents:
diff changeset
594 if (attr & DIG_ZERO) { // ゼロ・パディング
223b71206888 Initial import
thib
parents:
diff changeset
595 for (i=0; i<space_count; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
596 DSurfaceMove(surface, src_pos[0], surface, Rect(cur_x, 0));
223b71206888 Initial import
thib
parents:
diff changeset
597 cur_x += width;;
223b71206888 Initial import
thib
parents:
diff changeset
598 }
223b71206888 Initial import
thib
parents:
diff changeset
599 } else if (!(attr & DIG_PACK)) { // PACK オプションなし
223b71206888 Initial import
thib
parents:
diff changeset
600 cur_x += space_count * width;
223b71206888 Initial import
thib
parents:
diff changeset
601 }
223b71206888 Initial import
thib
parents:
diff changeset
602 for (i=0; num_str[i] != 0; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
603 DSurfaceMove(surface_orig, src_pos[num_str[i]-'0'], surface, Rect(cur_x, 0));
223b71206888 Initial import
thib
parents:
diff changeset
604 cur_x += width;
223b71206888 Initial import
thib
parents:
diff changeset
605 }
223b71206888 Initial import
thib
parents:
diff changeset
606
223b71206888 Initial import
thib
parents:
diff changeset
607 /* picture に設定 */
223b71206888 Initial import
thib
parents:
diff changeset
608 picture->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
609 picture->SetSurfaceRect(Rect(0,0,width*total_count,height));
223b71206888 Initial import
thib
parents:
diff changeset
610 picture->SetSurfaceFreeFlag();
223b71206888 Initial import
thib
parents:
diff changeset
611
223b71206888 Initial import
thib
parents:
diff changeset
612 pic_parent->Root().DeleteSurface(surface_orig);
223b71206888 Initial import
thib
parents:
diff changeset
613 }
223b71206888 Initial import
thib
parents:
diff changeset
614 void GrpObj::CreateGan(Event::Container& event, int event_number) {
223b71206888 Initial import
thib
parents:
diff changeset
615 if (picture == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
616 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n");
223b71206888 Initial import
thib
parents:
diff changeset
617 return;
223b71206888 Initial import
thib
parents:
diff changeset
618 }
223b71206888 Initial import
thib
parents:
diff changeset
619 if (anm) {
223b71206888 Initial import
thib
parents:
diff changeset
620 anm->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
621 delete anm;
223b71206888 Initial import
thib
parents:
diff changeset
622 }
223b71206888 Initial import
thib
parents:
diff changeset
623 if (gan_name.empty()) return;
223b71206888 Initial import
thib
parents:
diff changeset
624 /* アニーメション情報 (.GAN ファイル)を求める */
223b71206888 Initial import
thib
parents:
diff changeset
625 string path(gan_name);
223b71206888 Initial import
thib
parents:
diff changeset
626 path += ".gan";
223b71206888 Initial import
thib
parents:
diff changeset
627 ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan");
223b71206888 Initial import
thib
parents:
diff changeset
628 if (info == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
629 fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
630 return;
223b71206888 Initial import
thib
parents:
diff changeset
631 }
223b71206888 Initial import
thib
parents:
diff changeset
632 const char* data = info->Read();
223b71206888 Initial import
thib
parents:
diff changeset
633 if (read_little_endian_int(data) != 10000 || read_little_endian_int(data+4) != 10000) {
223b71206888 Initial import
thib
parents:
diff changeset
634 fprintf(stderr,"GrpObj::CreateGan: Invalid'GAN' file %s\n", path.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
635 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
636 return;
223b71206888 Initial import
thib
parents:
diff changeset
637 }
223b71206888 Initial import
thib
parents:
diff changeset
638
223b71206888 Initial import
thib
parents:
diff changeset
639 picture->SetSurfaceAttribute(PicBase::BLIT_SATURATE);
223b71206888 Initial import
thib
parents:
diff changeset
640 attr = Attribute(attr | UPDATE_POS | SATURATE);
223b71206888 Initial import
thib
parents:
diff changeset
641
223b71206888 Initial import
thib
parents:
diff changeset
642 const char* buf = data + 16;
223b71206888 Initial import
thib
parents:
diff changeset
643 buf += strlen(buf) + 1; // 画像ファイル名が入っている
223b71206888 Initial import
thib
parents:
diff changeset
644 buf += 4; // 定数 20000
223b71206888 Initial import
thib
parents:
diff changeset
645 int pics = read_little_endian_int(buf); buf += 4; // 複数のアニメーション情報が入っている場合、情報数
223b71206888 Initial import
thib
parents:
diff changeset
646 // 以下、pics 回繰り返し
223b71206888 Initial import
thib
parents:
diff changeset
647 // アニメーションを行う実体を作成
223b71206888 Initial import
thib
parents:
diff changeset
648 AnmAlphaMove* wid = new AnmAlphaMove(event, picture);
223b71206888 Initial import
thib
parents:
diff changeset
649
223b71206888 Initial import
thib
parents:
diff changeset
650 if (event_number && event_number < pics) { // 複数のアニメーション情報がある場合、先の情報を読み飛ばす */
223b71206888 Initial import
thib
parents:
diff changeset
651 int i; for (i=0; i<event_number; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
652 buf += 4; // 定数 30000
223b71206888 Initial import
thib
parents:
diff changeset
653 int ptns = read_little_endian_int(buf); buf += 4;
223b71206888 Initial import
thib
parents:
diff changeset
654 buf += ptns*52;
223b71206888 Initial import
thib
parents:
diff changeset
655 }
223b71206888 Initial import
thib
parents:
diff changeset
656 }
223b71206888 Initial import
thib
parents:
diff changeset
657 buf += 4; // 定数 30000
223b71206888 Initial import
thib
parents:
diff changeset
658 int ptns = read_little_endian_int(buf); buf += 4;
223b71206888 Initial import
thib
parents:
diff changeset
659 int total_time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
660 int i;
223b71206888 Initial import
thib
parents:
diff changeset
661 for (i=0; i<ptns; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
662 int p = read_little_endian_int(buf+i*52+0*8+4);
223b71206888 Initial import
thib
parents:
diff changeset
663 int x = read_little_endian_int(buf+i*52+1*8+4);
223b71206888 Initial import
thib
parents:
diff changeset
664 int y = read_little_endian_int(buf+i*52+2*8+4);
223b71206888 Initial import
thib
parents:
diff changeset
665 int t = read_little_endian_int(buf+i*52+3*8+4);
223b71206888 Initial import
thib
parents:
diff changeset
666 int a = read_little_endian_int(buf+i*52+4*8+4);
223b71206888 Initial import
thib
parents:
diff changeset
667 x += PosX();
223b71206888 Initial import
thib
parents:
diff changeset
668 y += PosY();
223b71206888 Initial import
thib
parents:
diff changeset
669 if (p == -1) { a = 0; p = 0; } // p == -1 ならなにも表示しない
223b71206888 Initial import
thib
parents:
diff changeset
670 if (p >= src_pos.size()) {
223b71206888 Initial import
thib
parents:
diff changeset
671 fprintf(stderr,"Reading GAN file %s (G00 %s) : not enough pictures in .G00 file\n", path.c_str(), name.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
672 a = 0; p = 0;
223b71206888 Initial import
thib
parents:
diff changeset
673 }
223b71206888 Initial import
thib
parents:
diff changeset
674 total_time += t;
223b71206888 Initial import
thib
parents:
diff changeset
675 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), src_pos[p], a, total_time));
223b71206888 Initial import
thib
parents:
diff changeset
676 }
223b71206888 Initial import
thib
parents:
diff changeset
677 wid->SetPtn(); // パターン登録終了
223b71206888 Initial import
thib
parents:
diff changeset
678 attr = Attribute(attr | ANM_PLAYSTART);
223b71206888 Initial import
thib
parents:
diff changeset
679 anm = wid;
223b71206888 Initial import
thib
parents:
diff changeset
680 };
223b71206888 Initial import
thib
parents:
diff changeset
681 void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) {
223b71206888 Initial import
thib
parents:
diff changeset
682 if (picture == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
683 fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n");
223b71206888 Initial import
thib
parents:
diff changeset
684 return;
223b71206888 Initial import
thib
parents:
diff changeset
685 }
223b71206888 Initial import
thib
parents:
diff changeset
686 if (anm) {
223b71206888 Initial import
thib
parents:
diff changeset
687 anm->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
688 delete anm;
223b71206888 Initial import
thib
parents:
diff changeset
689 }
223b71206888 Initial import
thib
parents:
diff changeset
690
223b71206888 Initial import
thib
parents:
diff changeset
691 // アニメーションを行う実体を作成
223b71206888 Initial import
thib
parents:
diff changeset
692 AnmAlphaMove* wid = new AnmAlphaMove(event, picture);
223b71206888 Initial import
thib
parents:
diff changeset
693
223b71206888 Initial import
thib
parents:
diff changeset
694 int i;
223b71206888 Initial import
thib
parents:
diff changeset
695 switch(event_number) {
223b71206888 Initial import
thib
parents:
diff changeset
696 case 0: // pattern を 0 から最後まで変化させる
223b71206888 Initial import
thib
parents:
diff changeset
697 for (i=0; i<src_pos.size(); i++) {
223b71206888 Initial import
thib
parents:
diff changeset
698 wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i));
223b71206888 Initial import
thib
parents:
diff changeset
699 }
223b71206888 Initial import
thib
parents:
diff changeset
700 wid->SetPtn(); // パターン登録終了
223b71206888 Initial import
thib
parents:
diff changeset
701 anm = wid;
223b71206888 Initial import
thib
parents:
diff changeset
702 attr = Attribute(attr | ANM_PLAYSTART);
223b71206888 Initial import
thib
parents:
diff changeset
703 break;
223b71206888 Initial import
thib
parents:
diff changeset
704 default:
223b71206888 Initial import
thib
parents:
diff changeset
705 break;
223b71206888 Initial import
thib
parents:
diff changeset
706 }
223b71206888 Initial import
thib
parents:
diff changeset
707 return;
223b71206888 Initial import
thib
parents:
diff changeset
708 };
223b71206888 Initial import
thib
parents:
diff changeset
709
223b71206888 Initial import
thib
parents:
diff changeset
710 void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) {
223b71206888 Initial import
thib
parents:
diff changeset
711 if (zoom == new_zoom && rotate == new_rotate) return;
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
712 if ( zoom == -1 || new_zoom == -1) {
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
713 attr = Attribute(attr | UPDATE_POS); // centering する
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
714 }
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
715 zoom = new_zoom;
0
223b71206888 Initial import
thib
parents:
diff changeset
716 if (new_rotate != -1) rotate = new_rotate;
223b71206888 Initial import
thib
parents:
diff changeset
717 if (zoom < 0) zoom = 256;
223b71206888 Initial import
thib
parents:
diff changeset
718 if (rotate < 0) rotate = 0;
223b71206888 Initial import
thib
parents:
diff changeset
719 else if (rotate > 360) rotate %= 360;
223b71206888 Initial import
thib
parents:
diff changeset
720
223b71206888 Initial import
thib
parents:
diff changeset
721 attr = Attribute(attr | UPDATE_PICTURE);
223b71206888 Initial import
thib
parents:
diff changeset
722 return;
223b71206888 Initial import
thib
parents:
diff changeset
723 }
223b71206888 Initial import
thib
parents:
diff changeset
724 /******************************************************************
223b71206888 Initial import
thib
parents:
diff changeset
725 **
223b71206888 Initial import
thib
parents:
diff changeset
726 ** class ScnGrp*
223b71206888 Initial import
thib
parents:
diff changeset
727 */
223b71206888 Initial import
thib
parents:
diff changeset
728 /* Princess Bride: 背景画の一部のみ移動、の実装 */
223b71206888 Initial import
thib
parents:
diff changeset
729 struct ScnGrpMove : public WidAnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
730 Surface* dest;
223b71206888 Initial import
thib
parents:
diff changeset
731 Surface* src;
223b71206888 Initial import
thib
parents:
diff changeset
732 PicRoot& root;
223b71206888 Initial import
thib
parents:
diff changeset
733 Rect dest_r, from, to;
223b71206888 Initial import
thib
parents:
diff changeset
734 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);
223b71206888 Initial import
thib
parents:
diff changeset
735 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
736 };
223b71206888 Initial import
thib
parents:
diff changeset
737 ScnGrpMove::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) :
223b71206888 Initial import
thib
parents:
diff changeset
738 WidAnmTime(container, _pic, total_time),
223b71206888 Initial import
thib
parents:
diff changeset
739 dest(_dest), src(_src), root(_root),dest_r(_dest_r), from(_from), to(_to) {
223b71206888 Initial import
thib
parents:
diff changeset
740 int dx = to.lx - from.lx;
223b71206888 Initial import
thib
parents:
diff changeset
741 int dy = to.ty - from.ty;
223b71206888 Initial import
thib
parents:
diff changeset
742 if (dx < 0) dx = -dx;
223b71206888 Initial import
thib
parents:
diff changeset
743 if (dy < 0) dy = -dy;
223b71206888 Initial import
thib
parents:
diff changeset
744 if (dx < dy) dx = dy;
223b71206888 Initial import
thib
parents:
diff changeset
745 if (dx == 0) dx = 1;
223b71206888 Initial import
thib
parents:
diff changeset
746 SetAllCount(dx);
223b71206888 Initial import
thib
parents:
diff changeset
747 }
223b71206888 Initial import
thib
parents:
diff changeset
748 void ScnGrpMove::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
749 Rect r(0,0,dest_r.width(),dest_r.height());
223b71206888 Initial import
thib
parents:
diff changeset
750 int dx = to.lx - from.lx;
223b71206888 Initial import
thib
parents:
diff changeset
751 int dy = to.ty - from.ty;
223b71206888 Initial import
thib
parents:
diff changeset
752 int x = dx*count/all_count + from.lx;
223b71206888 Initial import
thib
parents:
diff changeset
753 int y = dy*count/all_count + from.ty;
223b71206888 Initial import
thib
parents:
diff changeset
754 r.rmove(x, y);
223b71206888 Initial import
thib
parents:
diff changeset
755 root.BlitSurface(src, r, dest, dest_r);
223b71206888 Initial import
thib
parents:
diff changeset
756 iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
757 for (it=pic.begin(); it!=pic.end(); it++)
223b71206888 Initial import
thib
parents:
diff changeset
758 (*it)->SetSurface(dest, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
759 }
223b71206888 Initial import
thib
parents:
diff changeset
760
223b71206888 Initial import
thib
parents:
diff changeset
761 /* Princess Bride: カードがおちるアニメーション */
223b71206888 Initial import
thib
parents:
diff changeset
762
223b71206888 Initial import
thib
parents:
diff changeset
763 struct ScnGrpAnmAtom {
223b71206888 Initial import
thib
parents:
diff changeset
764 string name;
223b71206888 Initial import
thib
parents:
diff changeset
765 int time;
223b71206888 Initial import
thib
parents:
diff changeset
766 ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {}
223b71206888 Initial import
thib
parents:
diff changeset
767 };
223b71206888 Initial import
thib
parents:
diff changeset
768 struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> {
223b71206888 Initial import
thib
parents:
diff changeset
769 GrpImpl& owner;
223b71206888 Initial import
thib
parents:
diff changeset
770 ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) :
223b71206888 Initial import
thib
parents:
diff changeset
771 WidAnmTime(container, _pic, 0), owner(_owner) {
223b71206888 Initial import
thib
parents:
diff changeset
772 }
223b71206888 Initial import
thib
parents:
diff changeset
773 void CalcTotal(void);
223b71206888 Initial import
thib
parents:
diff changeset
774 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
775 };
223b71206888 Initial import
thib
parents:
diff changeset
776 void ScnGrpAnm::CalcTotal(void) {
223b71206888 Initial import
thib
parents:
diff changeset
777 /* total time を計算 */
223b71206888 Initial import
thib
parents:
diff changeset
778 if (empty()) return;
223b71206888 Initial import
thib
parents:
diff changeset
779 int tm = 0;
223b71206888 Initial import
thib
parents:
diff changeset
780 vector<ScnGrpAnmAtom>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
781 for (it=begin(); it != end(); it++) tm += it->time;
223b71206888 Initial import
thib
parents:
diff changeset
782 total_time = tm;
223b71206888 Initial import
thib
parents:
diff changeset
783 SetAllCount(tm);
223b71206888 Initial import
thib
parents:
diff changeset
784 }
223b71206888 Initial import
thib
parents:
diff changeset
785 void ScnGrpAnm::Exec(int count) {
223b71206888 Initial import
thib
parents:
diff changeset
786 int tm = 0; vector<ScnGrpAnmAtom>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
787 for (it=begin(); it != end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
788 tm += it->time;
223b71206888 Initial import
thib
parents:
diff changeset
789 if (count < tm) break;
223b71206888 Initial import
thib
parents:
diff changeset
790 }
223b71206888 Initial import
thib
parents:
diff changeset
791 if (it == end()) it--;
223b71206888 Initial import
thib
parents:
diff changeset
792 owner.LoadSurface(it->name.c_str(), 0);
223b71206888 Initial import
thib
parents:
diff changeset
793 }
223b71206888 Initial import
thib
parents:
diff changeset
794
223b71206888 Initial import
thib
parents:
diff changeset
795
223b71206888 Initial import
thib
parents:
diff changeset
796 /*****************************************************
223b71206888 Initial import
thib
parents:
diff changeset
797 *
223b71206888 Initial import
thib
parents:
diff changeset
798 * GrpImpl(implementation) : 定義
223b71206888 Initial import
thib
parents:
diff changeset
799 *
223b71206888 Initial import
thib
parents:
diff changeset
800 */
223b71206888 Initial import
thib
parents:
diff changeset
801
223b71206888 Initial import
thib
parents:
diff changeset
802 #include"music2/music.h"
223b71206888 Initial import
thib
parents:
diff changeset
803
223b71206888 Initial import
thib
parents:
diff changeset
804 GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) :
223b71206888 Initial import
thib
parents:
diff changeset
805 event(_event),
223b71206888 Initial import
thib
parents:
diff changeset
806 flags(f),
223b71206888 Initial import
thib
parents:
diff changeset
807 parent(_parent),
223b71206888 Initial import
thib
parents:
diff changeset
808 status(NORMAL),
223b71206888 Initial import
thib
parents:
diff changeset
809 skip_mode(SKIP_NO),
223b71206888 Initial import
thib
parents:
diff changeset
810 music(_mu),
223b71206888 Initial import
thib
parents:
diff changeset
811 cgm_data(_cgm_data),
223b71206888 Initial import
thib
parents:
diff changeset
812 grpobj(this),
223b71206888 Initial import
thib
parents:
diff changeset
813 bs_obj(this),
223b71206888 Initial import
thib
parents:
diff changeset
814 config(_config)
223b71206888 Initial import
thib
parents:
diff changeset
815 {
223b71206888 Initial import
thib
parents:
diff changeset
816 int i;
223b71206888 Initial import
thib
parents:
diff changeset
817 for (i=0; i<MAXPDT; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
818 ssurface[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
819 dsurface[i] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
820 }
223b71206888 Initial import
thib
parents:
diff changeset
821 screen = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0);
223b71206888 Initial import
thib
parents:
diff changeset
822 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0);
223b71206888 Initial import
thib
parents:
diff changeset
823 surface = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
824 surface_update = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
825 DSurfaceFill(surface, Rect(*surface), 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
826 DSurfaceFill(surface_update, Rect(*surface), 0, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
827 screen->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
828 screen->show();
223b71206888 Initial import
thib
parents:
diff changeset
829 screen_front->hide();
223b71206888 Initial import
thib
parents:
diff changeset
830 screen_front->ZMove(screen);
223b71206888 Initial import
thib
parents:
diff changeset
831
223b71206888 Initial import
thib
parents:
diff changeset
832 LoadCgm(config);
223b71206888 Initial import
thib
parents:
diff changeset
833
223b71206888 Initial import
thib
parents:
diff changeset
834 anm1 = 0; anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
835 }
223b71206888 Initial import
thib
parents:
diff changeset
836
223b71206888 Initial import
thib
parents:
diff changeset
837 GrpImpl::~GrpImpl() {
223b71206888 Initial import
thib
parents:
diff changeset
838
223b71206888 Initial import
thib
parents:
diff changeset
839 map<int,GrpObj>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
840 for (it=grpobj.begin(); it!=grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
841 PicBase* p = it->second.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
842 delete p;
223b71206888 Initial import
thib
parents:
diff changeset
843 }
223b71206888 Initial import
thib
parents:
diff changeset
844
223b71206888 Initial import
thib
parents:
diff changeset
845 delete screen;
223b71206888 Initial import
thib
parents:
diff changeset
846 delete screen_front;
223b71206888 Initial import
thib
parents:
diff changeset
847 parent.Root().DeleteSurface(surface);
223b71206888 Initial import
thib
parents:
diff changeset
848 int i;
223b71206888 Initial import
thib
parents:
diff changeset
849 for (i=0; i<MAXPDT; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
850 if (ssurface[i]) parent.Root().DeleteSurface(ssurface[i]);
223b71206888 Initial import
thib
parents:
diff changeset
851 if (dsurface[i]) parent.Root().DeleteSurface(dsurface[i]);
223b71206888 Initial import
thib
parents:
diff changeset
852 }
223b71206888 Initial import
thib
parents:
diff changeset
853 }
223b71206888 Initial import
thib
parents:
diff changeset
854
223b71206888 Initial import
thib
parents:
diff changeset
855 Surface* GrpImpl::Dsurface(int pdt) {
223b71206888 Initial import
thib
parents:
diff changeset
856 if (pdt == 0) return surface;
223b71206888 Initial import
thib
parents:
diff changeset
857 if (dsurface[pdt] == 0) { // とりあえず画面の大きさということにする
223b71206888 Initial import
thib
parents:
diff changeset
858 if (pdt == WORKPDT)
223b71206888 Initial import
thib
parents:
diff changeset
859 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), ALPHA_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
860 else
223b71206888 Initial import
thib
parents:
diff changeset
861 dsurface[pdt] = parent.Root().NewSurface(parent.Width(), parent.Height(), NO_MASK);
223b71206888 Initial import
thib
parents:
diff changeset
862 }
223b71206888 Initial import
thib
parents:
diff changeset
863 if (ssurface[pdt]) { // ssurface が存在すれば、dsurface にコピーして返す
223b71206888 Initial import
thib
parents:
diff changeset
864 DSurfaceMove(ssurface[pdt], Rect(*ssurface[pdt]), dsurface[pdt], Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
865 parent.Root().DeleteSurface(ssurface[pdt]);
223b71206888 Initial import
thib
parents:
diff changeset
866 ssurface[pdt] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
867 }
223b71206888 Initial import
thib
parents:
diff changeset
868 return dsurface[pdt];
223b71206888 Initial import
thib
parents:
diff changeset
869 }
223b71206888 Initial import
thib
parents:
diff changeset
870 #include<SDL.h>
223b71206888 Initial import
thib
parents:
diff changeset
871 Surface* GrpImpl::Ssurface(int pdt) {
223b71206888 Initial import
thib
parents:
diff changeset
872 if (pdt == 0) return surface;
223b71206888 Initial import
thib
parents:
diff changeset
873 if (ssurface[pdt]) {
223b71206888 Initial import
thib
parents:
diff changeset
874 return ssurface[pdt];
223b71206888 Initial import
thib
parents:
diff changeset
875 }
223b71206888 Initial import
thib
parents:
diff changeset
876 return Dsurface(pdt);
223b71206888 Initial import
thib
parents:
diff changeset
877 }
223b71206888 Initial import
thib
parents:
diff changeset
878
223b71206888 Initial import
thib
parents:
diff changeset
879 void GrpImpl::LoadSurface(const char* str, int pdt) {
223b71206888 Initial import
thib
parents:
diff changeset
880 string s = str;
223b71206888 Initial import
thib
parents:
diff changeset
881 if (cgm_info.find(s) != cgm_info.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
882 cgm_data.insert(cgm_info[s]);
223b71206888 Initial import
thib
parents:
diff changeset
883 }
223b71206888 Initial import
thib
parents:
diff changeset
884 Surface* bg = parent.Root().NewSurface(s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
885 if (bg == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
886 s += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
887 bg = parent.Root().NewSurface(s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
888 }
223b71206888 Initial import
thib
parents:
diff changeset
889 if (bg) {
223b71206888 Initial import
thib
parents:
diff changeset
890 if (ssurface[pdt]) parent.Root().DeleteSurface(ssurface[pdt]);
223b71206888 Initial import
thib
parents:
diff changeset
891 ssurface[pdt] = bg;
223b71206888 Initial import
thib
parents:
diff changeset
892 if (pdt == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
893 /* とりあえず Princess Bride のアニメーション効果専用 */
223b71206888 Initial import
thib
parents:
diff changeset
894 Rect r(*ssurface[0]);
223b71206888 Initial import
thib
parents:
diff changeset
895 Rect dr(*surface);
223b71206888 Initial import
thib
parents:
diff changeset
896 int x = (dr.width()-r.width())/2;
223b71206888 Initial import
thib
parents:
diff changeset
897 int y = (dr.height()-r.height())/2;
223b71206888 Initial import
thib
parents:
diff changeset
898 DSurfaceMove(ssurface[0], r, surface, Rect(x,y));
223b71206888 Initial import
thib
parents:
diff changeset
899 parent.Root().DeleteSurface(ssurface[0]);
223b71206888 Initial import
thib
parents:
diff changeset
900 ssurface[0] = 0;
223b71206888 Initial import
thib
parents:
diff changeset
901 screen->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
902 }
223b71206888 Initial import
thib
parents:
diff changeset
903 } else {
223b71206888 Initial import
thib
parents:
diff changeset
904 if (str[0] != 0)
223b71206888 Initial import
thib
parents:
diff changeset
905 fprintf(stderr,"Cannot find surface %d <- '%s'\n",pdt,str);
223b71206888 Initial import
thib
parents:
diff changeset
906 }
223b71206888 Initial import
thib
parents:
diff changeset
907 return;
223b71206888 Initial import
thib
parents:
diff changeset
908 }
223b71206888 Initial import
thib
parents:
diff changeset
909 void GrpImpl::InitSel(AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
910 int i; int args[16]; char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
911 for (i=0; i<999; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
912 sprintf(key, "#SEL.%03d",i);
223b71206888 Initial import
thib
parents:
diff changeset
913 if (config.GetParam(key, 15, &args[0], &args[1],
223b71206888 Initial import
thib
parents:
diff changeset
914 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7],
223b71206888 Initial import
thib
parents:
diff changeset
915 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13],
223b71206888 Initial import
thib
parents:
diff changeset
916 &args[14])) {
223b71206888 Initial import
thib
parents:
diff changeset
917
223b71206888 Initial import
thib
parents:
diff changeset
918 sprintf(key, "#SELR.%03d", i);
223b71206888 Initial import
thib
parents:
diff changeset
919 if (config.GetParam(key, 16, &args[0], &args[1],
223b71206888 Initial import
thib
parents:
diff changeset
920 &args[2], &args[3], &args[4], &args[5], &args[6], &args[7],
223b71206888 Initial import
thib
parents:
diff changeset
921 &args[8], &args[9], &args[10], &args[11], &args[12], &args[13],
223b71206888 Initial import
thib
parents:
diff changeset
922 &args[14], &args[15])) continue;
223b71206888 Initial import
thib
parents:
diff changeset
923 }
223b71206888 Initial import
thib
parents:
diff changeset
924 SEL& s = anmtype[i];
223b71206888 Initial import
thib
parents:
diff changeset
925 s.from = Rect(args[0], args[1], args[2]+1, args[3]+1);
223b71206888 Initial import
thib
parents:
diff changeset
926 s.to = Rect(args[4], args[5]);
223b71206888 Initial import
thib
parents:
diff changeset
927 s.time = args[6];
223b71206888 Initial import
thib
parents:
diff changeset
928 s.sel_no = args[7];
223b71206888 Initial import
thib
parents:
diff changeset
929 int j; for (j=0; j<8; j++) s.args[j] = args[8+j];
223b71206888 Initial import
thib
parents:
diff changeset
930 }
223b71206888 Initial import
thib
parents:
diff changeset
931 return;
223b71206888 Initial import
thib
parents:
diff changeset
932 }
223b71206888 Initial import
thib
parents:
diff changeset
933 void GrpImpl::SetSkipMode(SkipMode _mode) {
223b71206888 Initial import
thib
parents:
diff changeset
934 if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
935 RefreshObj();
223b71206888 Initial import
thib
parents:
diff changeset
936 } else if ( (skip_mode & SKIP_IN_MENU) == 0 && (_mode & SKIP_IN_MENU) ) {
223b71206888 Initial import
thib
parents:
diff changeset
937 }
223b71206888 Initial import
thib
parents:
diff changeset
938 skip_mode = _mode;
223b71206888 Initial import
thib
parents:
diff changeset
939 }
223b71206888 Initial import
thib
parents:
diff changeset
940 void GrpImpl::SetObjChanged(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
941 changed_obj.insert(num);
223b71206888 Initial import
thib
parents:
diff changeset
942 }
223b71206888 Initial import
thib
parents:
diff changeset
943 void GrpImpl::SetObjChangedGroup(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
944 if (num % 1000 != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
945 SetObjChanged(num);
223b71206888 Initial import
thib
parents:
diff changeset
946 return;
223b71206888 Initial import
thib
parents:
diff changeset
947 }
223b71206888 Initial import
thib
parents:
diff changeset
948 std::map<int, GrpObj>::iterator begin,end,it;
223b71206888 Initial import
thib
parents:
diff changeset
949 begin = grpobj.lower_bound(num);
223b71206888 Initial import
thib
parents:
diff changeset
950 end = grpobj.lower_bound(num+1000);
223b71206888 Initial import
thib
parents:
diff changeset
951 for (it=begin;it!=end;it++) {
223b71206888 Initial import
thib
parents:
diff changeset
952 changed_obj.insert(it->first);
223b71206888 Initial import
thib
parents:
diff changeset
953 }
223b71206888 Initial import
thib
parents:
diff changeset
954 }
223b71206888 Initial import
thib
parents:
diff changeset
955 void GrpImpl::RefreshObj(void) {
223b71206888 Initial import
thib
parents:
diff changeset
956 if (!deleted_pic.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
957 vector<PicBase*>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
958 for (it=deleted_pic.begin(); it!=deleted_pic.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
959 if (*it) delete *it;
223b71206888 Initial import
thib
parents:
diff changeset
960 }
223b71206888 Initial import
thib
parents:
diff changeset
961 deleted_pic.clear();
223b71206888 Initial import
thib
parents:
diff changeset
962 }
223b71206888 Initial import
thib
parents:
diff changeset
963 if (!changed_obj.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
964 set<int>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
965 for (it=changed_obj.begin(); it != changed_obj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
966 if (grpobj.find(*it) == grpobj.end()) continue;
223b71206888 Initial import
thib
parents:
diff changeset
967 GrpObj& obj = grpobj[*it];
223b71206888 Initial import
thib
parents:
diff changeset
968 GrpObj& parent_obj = grpobj[ ((*it)/1000) * 1000];
223b71206888 Initial import
thib
parents:
diff changeset
969 if (obj.picture == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
970 if (obj.alpha == 0 || (obj.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) {
223b71206888 Initial import
thib
parents:
diff changeset
971 if (obj.attr & GrpObj::ANM_PLAYING) {
223b71206888 Initial import
thib
parents:
diff changeset
972 obj.attr = GrpObj::Attribute(obj.attr & ~(GrpObj::ANM_PLAYING));
223b71206888 Initial import
thib
parents:
diff changeset
973 if (obj.anm) obj.anm->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
974 }
223b71206888 Initial import
thib
parents:
diff changeset
975 obj.picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
976 } else {
223b71206888 Initial import
thib
parents:
diff changeset
977 obj.Update();
223b71206888 Initial import
thib
parents:
diff changeset
978 obj.picture->show();
223b71206888 Initial import
thib
parents:
diff changeset
979 }
223b71206888 Initial import
thib
parents:
diff changeset
980 }
223b71206888 Initial import
thib
parents:
diff changeset
981 changed_obj.clear();
223b71206888 Initial import
thib
parents:
diff changeset
982 }
223b71206888 Initial import
thib
parents:
diff changeset
983 if (reserved_load_surface0.length() != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
984 LoadSurface(reserved_load_surface0.c_str(), 0);
223b71206888 Initial import
thib
parents:
diff changeset
985 reserved_load_surface0 = "";
223b71206888 Initial import
thib
parents:
diff changeset
986 }
223b71206888 Initial import
thib
parents:
diff changeset
987 screen->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
988 }
223b71206888 Initial import
thib
parents:
diff changeset
989
223b71206888 Initial import
thib
parents:
diff changeset
990
223b71206888 Initial import
thib
parents:
diff changeset
991 #include<SDL.h>
223b71206888 Initial import
thib
parents:
diff changeset
992 void GrpImpl::StartAnm(int type) {
223b71206888 Initial import
thib
parents:
diff changeset
993 SEL sel;
223b71206888 Initial import
thib
parents:
diff changeset
994
223b71206888 Initial import
thib
parents:
diff changeset
995 if (anmtype.find(type) == anmtype.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
996 if (anmtype.find(0) == anmtype.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
997 sel.sel_no = 1;
223b71206888 Initial import
thib
parents:
diff changeset
998 sel.from = Rect(*surface);
223b71206888 Initial import
thib
parents:
diff changeset
999 sel.to = Rect(0,0);
223b71206888 Initial import
thib
parents:
diff changeset
1000 sel.time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1001 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1002 sel = anmtype[0];
223b71206888 Initial import
thib
parents:
diff changeset
1003 }
223b71206888 Initial import
thib
parents:
diff changeset
1004 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1005 sel = anmtype[type];
223b71206888 Initial import
thib
parents:
diff changeset
1006 }
223b71206888 Initial import
thib
parents:
diff changeset
1007 if (anm1) {
223b71206888 Initial import
thib
parents:
diff changeset
1008 fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n");
223b71206888 Initial import
thib
parents:
diff changeset
1009 anm1->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1010 delete anm1;
223b71206888 Initial import
thib
parents:
diff changeset
1011 anm1 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1012 }
223b71206888 Initial import
thib
parents:
diff changeset
1013 map<int,GrpObj>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1014 // 現在表示中のobjectを消去
223b71206888 Initial import
thib
parents:
diff changeset
1015 deleted_pic.push_back(screen);
223b71206888 Initial import
thib
parents:
diff changeset
1016 for (it=grpobj.begin(); it!=grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1017 if (! (it->second.attr & GrpObj::WIPEON)) { // 画像切り替え時に object 削除
223b71206888 Initial import
thib
parents:
diff changeset
1018 deleted_pic.push_back(it->second.DeletePic());
223b71206888 Initial import
thib
parents:
diff changeset
1019 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1020 GrpObj& new_obj = bs_obj[it->first];
223b71206888 Initial import
thib
parents:
diff changeset
1021 if (new_obj.name.empty()) { // 新しい object が存在しなければ内容を引き継ぐ
223b71206888 Initial import
thib
parents:
diff changeset
1022 new_obj = it->second;
223b71206888 Initial import
thib
parents:
diff changeset
1023 it->second.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1024 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1025 new_obj.attr = GrpObj::Attribute(new_obj.attr | GrpObj::WIPEON);
223b71206888 Initial import
thib
parents:
diff changeset
1026 deleted_pic.push_back(it->second.DeletePic());
223b71206888 Initial import
thib
parents:
diff changeset
1027 }
223b71206888 Initial import
thib
parents:
diff changeset
1028 }
223b71206888 Initial import
thib
parents:
diff changeset
1029 }
223b71206888 Initial import
thib
parents:
diff changeset
1030 grpobj.clear(); // 全オブジェクト削除
223b71206888 Initial import
thib
parents:
diff changeset
1031
223b71206888 Initial import
thib
parents:
diff changeset
1032 // 全画像オブジェクトの前にscreen 移動
223b71206888 Initial import
thib
parents:
diff changeset
1033 // 新しい screen_front を作成しておく
223b71206888 Initial import
thib
parents:
diff changeset
1034 screen = screen_front;
223b71206888 Initial import
thib
parents:
diff changeset
1035 screen->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1036 screen->SetSurface(surface_update, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1037 parent.Root().BlitSurface(Dsurface(1), Rect(*surface_update), surface_update, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
1038
223b71206888 Initial import
thib
parents:
diff changeset
1039 screen_front = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0);
223b71206888 Initial import
thib
parents:
diff changeset
1040 screen_front->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1041 screen_front->ZMove(screen);
223b71206888 Initial import
thib
parents:
diff changeset
1042
223b71206888 Initial import
thib
parents:
diff changeset
1043 // 新しい object へ更新、surface_update へ新しい object を表示
223b71206888 Initial import
thib
parents:
diff changeset
1044 // (object 作成時は picture は hide されている)
223b71206888 Initial import
thib
parents:
diff changeset
1045 for (it=bs_obj.begin(); it!=bs_obj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1046 grpobj[it->first] = it->second;
223b71206888 Initial import
thib
parents:
diff changeset
1047 it->second.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1048 CreateObj(it->first);
223b71206888 Initial import
thib
parents:
diff changeset
1049 GrpObj& g = grpobj[it->first];
223b71206888 Initial import
thib
parents:
diff changeset
1050 GrpObj& parent_obj = grpobj[ (it->first/1000) * 1000];
223b71206888 Initial import
thib
parents:
diff changeset
1051 if (g.picture) {
223b71206888 Initial import
thib
parents:
diff changeset
1052 g.Update();
223b71206888 Initial import
thib
parents:
diff changeset
1053 if (g.alpha == 0 || (g.attr & GrpObj::HIDDEN) || (parent_obj.attr & GrpObj::HIDDEN_GROUP) ) ;
223b71206888 Initial import
thib
parents:
diff changeset
1054 else g.picture->SimpleBlit(surface_update);
223b71206888 Initial import
thib
parents:
diff changeset
1055 g.picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1056 }
223b71206888 Initial import
thib
parents:
diff changeset
1057 }
223b71206888 Initial import
thib
parents:
diff changeset
1058 bs_obj.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1059 // 画像効果開始
223b71206888 Initial import
thib
parents:
diff changeset
1060 switch(sel.sel_no) {
223b71206888 Initial import
thib
parents:
diff changeset
1061 default:
223b71206888 Initial import
thib
parents:
diff changeset
1062 case 0: case 50: // 0 と 50 の違いが良くわからない
223b71206888 Initial import
thib
parents:
diff changeset
1063 if (skip_mode & SKIP_GRP_NOEFFEC)
223b71206888 Initial import
thib
parents:
diff changeset
1064 anm1 = new WidAnmAlpha(event, screen, ALPHA_MAX, ALPHA_MAX, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1065 else if (skip_mode & SKIP_GRP_FAST)
223b71206888 Initial import
thib
parents:
diff changeset
1066 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time/4);
223b71206888 Initial import
thib
parents:
diff changeset
1067 else
223b71206888 Initial import
thib
parents:
diff changeset
1068 anm1 = new WidAnmAlpha(event, screen, 0, ALPHA_MAX, sel.time);
223b71206888 Initial import
thib
parents:
diff changeset
1069 break;
223b71206888 Initial import
thib
parents:
diff changeset
1070 }
223b71206888 Initial import
thib
parents:
diff changeset
1071 if (anm1) anm1->Play();
223b71206888 Initial import
thib
parents:
diff changeset
1072 if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm();
223b71206888 Initial import
thib
parents:
diff changeset
1073 }
223b71206888 Initial import
thib
parents:
diff changeset
1074 void GrpImpl::StartShake(int total, const int* pattern) {
223b71206888 Initial import
thib
parents:
diff changeset
1075 if (anm2) {
223b71206888 Initial import
thib
parents:
diff changeset
1076 fprintf(stderr,"Warning: StartShake() called before another animation finished\n");
223b71206888 Initial import
thib
parents:
diff changeset
1077 anm2->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1078 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1079 anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1080 }
223b71206888 Initial import
thib
parents:
diff changeset
1081 if (skip_mode & SKIP_GRP_NOEFFEC) return;
223b71206888 Initial import
thib
parents:
diff changeset
1082 AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす
223b71206888 Initial import
thib
parents:
diff changeset
1083 int i; int tm = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1084 for (i=0; i<total; i+=3) {
223b71206888 Initial import
thib
parents:
diff changeset
1085 int x = pattern[i];
223b71206888 Initial import
thib
parents:
diff changeset
1086 int y = pattern[i+1];
223b71206888 Initial import
thib
parents:
diff changeset
1087 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(x,y), Rect(0,0), 255, tm));
223b71206888 Initial import
thib
parents:
diff changeset
1088 tm += pattern[i+2];
223b71206888 Initial import
thib
parents:
diff changeset
1089 }
223b71206888 Initial import
thib
parents:
diff changeset
1090 new_anm->ptns.push_back(AnmAlphaMove::Ptn(Rect(0,0), Rect(0,0), 255, tm));
223b71206888 Initial import
thib
parents:
diff changeset
1091 new_anm->SetPtn(); // パターン登録終了
223b71206888 Initial import
thib
parents:
diff changeset
1092 new_anm->Play();
223b71206888 Initial import
thib
parents:
diff changeset
1093 anm2 = new_anm;
223b71206888 Initial import
thib
parents:
diff changeset
1094 }
223b71206888 Initial import
thib
parents:
diff changeset
1095 void GrpImpl::AbortAnm(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1096 if (anm1 == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1097 anm1->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1098 delete anm1;
223b71206888 Initial import
thib
parents:
diff changeset
1099 anm1 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1100 /* 画像効果終了 */
223b71206888 Initial import
thib
parents:
diff changeset
1101 /* 古い画面への画像効果があれば消去 */
223b71206888 Initial import
thib
parents:
diff changeset
1102 if (anm2 && anm2->pic[0] != screen) {
223b71206888 Initial import
thib
parents:
diff changeset
1103 anm2->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1104 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1105 anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1106 }
223b71206888 Initial import
thib
parents:
diff changeset
1107 /* pdt1 -> pdt0 へコピー */
223b71206888 Initial import
thib
parents:
diff changeset
1108 DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
1109 screen->SetSurface(surface, 0, 0);
223b71206888 Initial import
thib
parents:
diff changeset
1110 // 画像効果開始時に存在したobjectを消去
223b71206888 Initial import
thib
parents:
diff changeset
1111 // 新しい object 表示
223b71206888 Initial import
thib
parents:
diff changeset
1112 RefreshObj();
223b71206888 Initial import
thib
parents:
diff changeset
1113 return;
223b71206888 Initial import
thib
parents:
diff changeset
1114 }
223b71206888 Initial import
thib
parents:
diff changeset
1115 void GrpImpl::LoadSurface(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
1116 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了
223b71206888 Initial import
thib
parents:
diff changeset
1117 LoadSurface(str, 1);
223b71206888 Initial import
thib
parents:
diff changeset
1118 bg_name = str;
223b71206888 Initial import
thib
parents:
diff changeset
1119 }
223b71206888 Initial import
thib
parents:
diff changeset
1120 void GrpImpl::LoadSurface(void) {
223b71206888 Initial import
thib
parents:
diff changeset
1121 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了
223b71206888 Initial import
thib
parents:
diff changeset
1122 LoadSurface(bg_name.c_str(), 1);
223b71206888 Initial import
thib
parents:
diff changeset
1123 }
223b71206888 Initial import
thib
parents:
diff changeset
1124 void GrpImpl::AddSurface(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
1125 if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了
223b71206888 Initial import
thib
parents:
diff changeset
1126 LoadSurface(bg_name.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1127
223b71206888 Initial import
thib
parents:
diff changeset
1128 string s = str;
223b71206888 Initial import
thib
parents:
diff changeset
1129 Surface* front = parent.Root().NewSurface(s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1130 if (front == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1131 s += ".g00";
223b71206888 Initial import
thib
parents:
diff changeset
1132 front = parent.Root().NewSurface(s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1133 }
223b71206888 Initial import
thib
parents:
diff changeset
1134 if (front) {
223b71206888 Initial import
thib
parents:
diff changeset
1135 parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0));
223b71206888 Initial import
thib
parents:
diff changeset
1136 parent.Root().DeleteSurface(front);
223b71206888 Initial import
thib
parents:
diff changeset
1137 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1138 fprintf(stderr,"Cannot find surface %s\n",str);
223b71206888 Initial import
thib
parents:
diff changeset
1139 }
223b71206888 Initial import
thib
parents:
diff changeset
1140 }
223b71206888 Initial import
thib
parents:
diff changeset
1141
223b71206888 Initial import
thib
parents:
diff changeset
1142 void GrpImpl::CreateObj(int index) {
223b71206888 Initial import
thib
parents:
diff changeset
1143 std::map<int, GrpObj>::iterator cur = grpobj.find(index);
223b71206888 Initial import
thib
parents:
diff changeset
1144 if (cur == grpobj.end()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1145 GrpObj& g = grpobj[index];
223b71206888 Initial import
thib
parents:
diff changeset
1146 g.CreateSurface(&parent);
223b71206888 Initial import
thib
parents:
diff changeset
1147 g.order = index;
223b71206888 Initial import
thib
parents:
diff changeset
1148 if (g.picture == 0) return; // エラー:surface が存在しない
223b71206888 Initial import
thib
parents:
diff changeset
1149 g.picture->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1150 SetObjChanged(index);
223b71206888 Initial import
thib
parents:
diff changeset
1151 ZMoveObj(index);
223b71206888 Initial import
thib
parents:
diff changeset
1152 return;
223b71206888 Initial import
thib
parents:
diff changeset
1153 }
223b71206888 Initial import
thib
parents:
diff changeset
1154 void GrpImpl::ZMoveObj(int index) {
223b71206888 Initial import
thib
parents:
diff changeset
1155 std::map<int, GrpObj>::iterator cur = grpobj.find(index);
223b71206888 Initial import
thib
parents:
diff changeset
1156 if (cur == grpobj.end()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1157 GrpObj& g = grpobj[index];
223b71206888 Initial import
thib
parents:
diff changeset
1158 if (g.picture == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1159 // 自分より前に object があれば、その前に表示
223b71206888 Initial import
thib
parents:
diff changeset
1160 // そうでなければ screen の前に表示
223b71206888 Initial import
thib
parents:
diff changeset
1161 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end();
223b71206888 Initial import
thib
parents:
diff changeset
1162 std::map<int, GrpObj>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1163 for (it = grpobj.begin(); it != grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1164 if (it == cur) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1165 if (it->second.picture == 0) continue;
223b71206888 Initial import
thib
parents:
diff changeset
1166 if (it->second.order < g.order) {
223b71206888 Initial import
thib
parents:
diff changeset
1167 if (cur_backobj == grpobj.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1168 cur_backobj = it;
223b71206888 Initial import
thib
parents:
diff changeset
1169 } else if (cur_backobj->second.order < it->second.order) {
223b71206888 Initial import
thib
parents:
diff changeset
1170 cur_backobj = it;
223b71206888 Initial import
thib
parents:
diff changeset
1171 }
223b71206888 Initial import
thib
parents:
diff changeset
1172 }
223b71206888 Initial import
thib
parents:
diff changeset
1173 }
223b71206888 Initial import
thib
parents:
diff changeset
1174 if (cur_backobj == grpobj.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1175 g.picture->ZMove(screen);
223b71206888 Initial import
thib
parents:
diff changeset
1176 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1177 g.picture->ZMove(cur_backobj->second.picture);
223b71206888 Initial import
thib
parents:
diff changeset
1178 }
223b71206888 Initial import
thib
parents:
diff changeset
1179 return;
223b71206888 Initial import
thib
parents:
diff changeset
1180 }
223b71206888 Initial import
thib
parents:
diff changeset
1181 void GrpImpl::SwapObj(int index1, int index2) {
223b71206888 Initial import
thib
parents:
diff changeset
1182 // デフォルト値から order が変更されていた場合のみ、order は保存される
223b71206888 Initial import
thib
parents:
diff changeset
1183 // まずは両方のobjectをswap
223b71206888 Initial import
thib
parents:
diff changeset
1184 if (grpobj.find(index1) == grpobj.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1185 if (grpobj.find(index2) == grpobj.end()) return; // どちらの object も存在しない
223b71206888 Initial import
thib
parents:
diff changeset
1186 grpobj[index1] = grpobj[index2];
223b71206888 Initial import
thib
parents:
diff changeset
1187 if (grpobj[index1].order == index2)
223b71206888 Initial import
thib
parents:
diff changeset
1188 grpobj[index1].order = index1;
223b71206888 Initial import
thib
parents:
diff changeset
1189 grpobj[index2].DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1190 grpobj.erase(index2);
223b71206888 Initial import
thib
parents:
diff changeset
1191 ZMoveObj(index1);
223b71206888 Initial import
thib
parents:
diff changeset
1192 return;
223b71206888 Initial import
thib
parents:
diff changeset
1193 } else if (grpobj.find(index2) == grpobj.end()) { // index2 が存在しない場合
223b71206888 Initial import
thib
parents:
diff changeset
1194 grpobj[index2] = grpobj[index1];
223b71206888 Initial import
thib
parents:
diff changeset
1195 if (grpobj[index2].order == index1)
223b71206888 Initial import
thib
parents:
diff changeset
1196 grpobj[index2].order = index2;
223b71206888 Initial import
thib
parents:
diff changeset
1197 grpobj[index1].DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1198 grpobj.erase(index1);
223b71206888 Initial import
thib
parents:
diff changeset
1199 ZMoveObj(index2);
223b71206888 Initial import
thib
parents:
diff changeset
1200 return;
223b71206888 Initial import
thib
parents:
diff changeset
1201 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1202 GrpObj obj = grpobj[index1];
223b71206888 Initial import
thib
parents:
diff changeset
1203 grpobj[index1] = grpobj[index2];
223b71206888 Initial import
thib
parents:
diff changeset
1204 grpobj[index2].DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1205 if (grpobj[index1].order == index2)
223b71206888 Initial import
thib
parents:
diff changeset
1206 grpobj[index1].order = index1;
223b71206888 Initial import
thib
parents:
diff changeset
1207 ZMoveObj(index1);
223b71206888 Initial import
thib
parents:
diff changeset
1208 grpobj[index2] = obj;
223b71206888 Initial import
thib
parents:
diff changeset
1209 if (grpobj[index2].order == index1)
223b71206888 Initial import
thib
parents:
diff changeset
1210 grpobj[index2].order = index2;
223b71206888 Initial import
thib
parents:
diff changeset
1211 ZMoveObj(index2);
223b71206888 Initial import
thib
parents:
diff changeset
1212 obj.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1213 }
223b71206888 Initial import
thib
parents:
diff changeset
1214 }
223b71206888 Initial import
thib
parents:
diff changeset
1215
223b71206888 Initial import
thib
parents:
diff changeset
1216 bool GrpImpl::Pressed(int x, int y, void* pointer) { // マウスクリックでキャンセル
223b71206888 Initial import
thib
parents:
diff changeset
1217 GrpImpl* g = (GrpImpl*)pointer;
223b71206888 Initial import
thib
parents:
diff changeset
1218 if (g->status == WAIT_MOVIE)
223b71206888 Initial import
thib
parents:
diff changeset
1219 g->music.StopMovie();
223b71206888 Initial import
thib
parents:
diff changeset
1220 if (g->status == WAIT_ANM)
223b71206888 Initial import
thib
parents:
diff changeset
1221 g->AbortAnm();
223b71206888 Initial import
thib
parents:
diff changeset
1222 if (g->status == WAIT_SHAKE && g->anm2 != 0) {
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
1223 g->anm2->Abort();
0
223b71206888 Initial import
thib
parents:
diff changeset
1224 delete g->anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1225 g->anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1226 }
223b71206888 Initial import
thib
parents:
diff changeset
1227 return false; // event deleted
223b71206888 Initial import
thib
parents:
diff changeset
1228 }
223b71206888 Initial import
thib
parents:
diff changeset
1229
223b71206888 Initial import
thib
parents:
diff changeset
1230 /* mode.cgm の decode 用 */
223b71206888 Initial import
thib
parents:
diff changeset
1231 static unsigned char decode_char[256] = {
223b71206888 Initial import
thib
parents:
diff changeset
1232 0x8b, 0xe5, 0x5d, 0xc3, 0xa1, 0xe0, 0x30, 0x44,
223b71206888 Initial import
thib
parents:
diff changeset
1233 0x00, 0x85, 0xc0, 0x74, 0x09, 0x5f, 0x5e, 0x33,
223b71206888 Initial import
thib
parents:
diff changeset
1234 0xc0, 0x5b, 0x8b, 0xe5, 0x5d, 0xc3, 0x8b, 0x45,
223b71206888 Initial import
thib
parents:
diff changeset
1235 0x0c, 0x85, 0xc0, 0x75, 0x14, 0x8b, 0x55, 0xec,
223b71206888 Initial import
thib
parents:
diff changeset
1236 0x83, 0xc2, 0x20, 0x52, 0x6a, 0x00, 0xe8, 0xf5,
223b71206888 Initial import
thib
parents:
diff changeset
1237 0x28, 0x01, 0x00, 0x83, 0xc4, 0x08, 0x89, 0x45,
223b71206888 Initial import
thib
parents:
diff changeset
1238 0x0c, 0x8b, 0x45, 0xe4, 0x6a, 0x00, 0x6a, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1239 0x50, 0x53, 0xff, 0x15, 0x34, 0xb1, 0x43, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1240 0x8b, 0x45, 0x10, 0x85, 0xc0, 0x74, 0x05, 0x8b,
223b71206888 Initial import
thib
parents:
diff changeset
1241 0x4d, 0xec, 0x89, 0x08, 0x8a, 0x45, 0xf0, 0x84,
223b71206888 Initial import
thib
parents:
diff changeset
1242 0xc0, 0x75, 0x78, 0xa1, 0xe0, 0x30, 0x44, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1243 0x8b, 0x7d, 0xe8, 0x8b, 0x75, 0x0c, 0x85, 0xc0,
223b71206888 Initial import
thib
parents:
diff changeset
1244 0x75, 0x44, 0x8b, 0x1d, 0xd0, 0xb0, 0x43, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1245 0x85, 0xff, 0x76, 0x37, 0x81, 0xff, 0x00, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1246 0x04, 0x00, 0x6a, 0x00, 0x76, 0x43, 0x8b, 0x45,
223b71206888 Initial import
thib
parents:
diff changeset
1247 0xf8, 0x8d, 0x55, 0xfc, 0x52, 0x68, 0x00, 0x00,
223b71206888 Initial import
thib
parents:
diff changeset
1248 0x04, 0x00, 0x56, 0x50, 0xff, 0x15, 0x2c, 0xb1,
223b71206888 Initial import
thib
parents:
diff changeset
1249 0x43, 0x00, 0x6a, 0x05, 0xff, 0xd3, 0xa1, 0xe0,
223b71206888 Initial import
thib
parents:
diff changeset
1250 0x30, 0x44, 0x00, 0x81, 0xef, 0x00, 0x00, 0x04,
223b71206888 Initial import
thib
parents:
diff changeset
1251 0x00, 0x81, 0xc6, 0x00, 0x00, 0x04, 0x00, 0x85,
223b71206888 Initial import
thib
parents:
diff changeset
1252 0xc0, 0x74, 0xc5, 0x8b, 0x5d, 0xf8, 0x53, 0xe8,
223b71206888 Initial import
thib
parents:
diff changeset
1253 0xf4, 0xfb, 0xff, 0xff, 0x8b, 0x45, 0x0c, 0x83,
223b71206888 Initial import
thib
parents:
diff changeset
1254 0xc4, 0x04, 0x5f, 0x5e, 0x5b, 0x8b, 0xe5, 0x5d,
223b71206888 Initial import
thib
parents:
diff changeset
1255 0xc3, 0x8b, 0x55, 0xf8, 0x8d, 0x4d, 0xfc, 0x51,
223b71206888 Initial import
thib
parents:
diff changeset
1256 0x57, 0x56, 0x52, 0xff, 0x15, 0x2c, 0xb1, 0x43,
223b71206888 Initial import
thib
parents:
diff changeset
1257 0x00, 0xeb, 0xd8, 0x8b, 0x45, 0xe8, 0x83, 0xc0,
223b71206888 Initial import
thib
parents:
diff changeset
1258 0x20, 0x50, 0x6a, 0x00, 0xe8, 0x47, 0x28, 0x01,
223b71206888 Initial import
thib
parents:
diff changeset
1259 0x00, 0x8b, 0x7d, 0xe8, 0x89, 0x45, 0xf4, 0x8b,
223b71206888 Initial import
thib
parents:
diff changeset
1260 0xf0, 0xa1, 0xe0, 0x30, 0x44, 0x00, 0x83, 0xc4,
223b71206888 Initial import
thib
parents:
diff changeset
1261 0x08, 0x85, 0xc0, 0x75, 0x56, 0x8b, 0x1d, 0xd0,
223b71206888 Initial import
thib
parents:
diff changeset
1262 0xb0, 0x43, 0x00, 0x85, 0xff, 0x76, 0x49, 0x81,
223b71206888 Initial import
thib
parents:
diff changeset
1263 0xff, 0x00, 0x00, 0x04, 0x00, 0x6a, 0x00, 0x76
223b71206888 Initial import
thib
parents:
diff changeset
1264 };
223b71206888 Initial import
thib
parents:
diff changeset
1265
223b71206888 Initial import
thib
parents:
diff changeset
1266 void GrpImpl::LoadCgm(AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
1267 /* cgm ファイル読み込み */
223b71206888 Initial import
thib
parents:
diff changeset
1268 const char* fname = config.GetParaStr("#CGTABLE_FILE");
223b71206888 Initial import
thib
parents:
diff changeset
1269 if (fname == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1270 ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, "");
223b71206888 Initial import
thib
parents:
diff changeset
1271 if (info == 0) return;
223b71206888 Initial import
thib
parents:
diff changeset
1272 char* data = info->CopyRead();
223b71206888 Initial import
thib
parents:
diff changeset
1273 int sz = info->Size();
223b71206888 Initial import
thib
parents:
diff changeset
1274 delete info;
223b71206888 Initial import
thib
parents:
diff changeset
1275
223b71206888 Initial import
thib
parents:
diff changeset
1276
8
55b577e5f5b5 Some memory leaks fixed
thib
parents: 5
diff changeset
1277 if ( strncmp(data, "CGTABLE", 7) != 0) {
55b577e5f5b5 Some memory leaks fixed
thib
parents: 5
diff changeset
1278 delete[] data;
55b577e5f5b5 Some memory leaks fixed
thib
parents: 5
diff changeset
1279 return;
55b577e5f5b5 Some memory leaks fixed
thib
parents: 5
diff changeset
1280 }
20
824b89018ea8 * CG completion percentage (maybe not working properly?)
thib
parents: 18
diff changeset
1281 cgm_size = read_little_endian_int(data+0x10);
0
223b71206888 Initial import
thib
parents:
diff changeset
1282
223b71206888 Initial import
thib
parents:
diff changeset
1283 int i,j;
223b71206888 Initial import
thib
parents:
diff changeset
1284 // xor 解除
223b71206888 Initial import
thib
parents:
diff changeset
1285 for (i=0;i<sz-0x20; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1286 data[i+0x20]^=decode_char[i&0xff];
223b71206888 Initial import
thib
parents:
diff changeset
1287 }
223b71206888 Initial import
thib
parents:
diff changeset
1288 // 展開
223b71206888 Initial import
thib
parents:
diff changeset
1289 int dest_size = cgm_size * 36;
223b71206888 Initial import
thib
parents:
diff changeset
1290 char* dest = new char[dest_size+1024];
223b71206888 Initial import
thib
parents:
diff changeset
1291 char* src = data + 0x28;
223b71206888 Initial import
thib
parents:
diff changeset
1292 char* dest_orig = dest;
223b71206888 Initial import
thib
parents:
diff changeset
1293 ARCINFO::Extract2k(dest,src,dest+dest_size,data+sz);
223b71206888 Initial import
thib
parents:
diff changeset
1294 dest = dest_orig;
223b71206888 Initial import
thib
parents:
diff changeset
1295 for (i=0; i<cgm_size; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1296 char* s = dest + i * 36;
223b71206888 Initial import
thib
parents:
diff changeset
1297 int n = read_little_endian_int(dest + i * 36 + 32);
223b71206888 Initial import
thib
parents:
diff changeset
1298 cgm_info[s] = n;
223b71206888 Initial import
thib
parents:
diff changeset
1299 }
8
55b577e5f5b5 Some memory leaks fixed
thib
parents: 5
diff changeset
1300 delete[] data;
0
223b71206888 Initial import
thib
parents:
diff changeset
1301 delete[] dest_orig;
223b71206888 Initial import
thib
parents:
diff changeset
1302 }
223b71206888 Initial import
thib
parents:
diff changeset
1303
223b71206888 Initial import
thib
parents:
diff changeset
1304 /*****************************************************
223b71206888 Initial import
thib
parents:
diff changeset
1305 *
223b71206888 Initial import
thib
parents:
diff changeset
1306 * GrpImpl :: Save, Load : セーブファイル処理
223b71206888 Initial import
thib
parents:
diff changeset
1307 *
223b71206888 Initial import
thib
parents:
diff changeset
1308 */
223b71206888 Initial import
thib
parents:
diff changeset
1309 void GrpImpl::Save(std::string& str) {
223b71206888 Initial import
thib
parents:
diff changeset
1310 }
223b71206888 Initial import
thib
parents:
diff changeset
1311 void GrpImpl::Load(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
1312 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1313 if (anm1) {
223b71206888 Initial import
thib
parents:
diff changeset
1314 AbortAnm();
223b71206888 Initial import
thib
parents:
diff changeset
1315 }
223b71206888 Initial import
thib
parents:
diff changeset
1316 if (anm2) {
223b71206888 Initial import
thib
parents:
diff changeset
1317 anm2->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1318 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1319 anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1320 }
223b71206888 Initial import
thib
parents:
diff changeset
1321 map<int,GrpObj>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1322 for (it=grpobj.begin(); it!=grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1323 PicBase* p = it->second.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1324 delete p;
223b71206888 Initial import
thib
parents:
diff changeset
1325 }
223b71206888 Initial import
thib
parents:
diff changeset
1326 grpobj.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1327
223b71206888 Initial import
thib
parents:
diff changeset
1328 bg_name = "";
223b71206888 Initial import
thib
parents:
diff changeset
1329 music.StopCDROM(100);
223b71206888 Initial import
thib
parents:
diff changeset
1330 }
223b71206888 Initial import
thib
parents:
diff changeset
1331 void GrpImpl::SaveSys(string& save) {
223b71206888 Initial import
thib
parents:
diff changeset
1332 char buf[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1333 save = "\n[Graphics]\n";
223b71206888 Initial import
thib
parents:
diff changeset
1334 save += "CGM_CG=";
223b71206888 Initial import
thib
parents:
diff changeset
1335
223b71206888 Initial import
thib
parents:
diff changeset
1336 set<int>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1337 for (it=cgm_data.begin(); it != cgm_data.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1338 sprintf(buf,"%d,",*it);
223b71206888 Initial import
thib
parents:
diff changeset
1339 save += buf;
223b71206888 Initial import
thib
parents:
diff changeset
1340 }
223b71206888 Initial import
thib
parents:
diff changeset
1341 save += "\n";
223b71206888 Initial import
thib
parents:
diff changeset
1342 }
223b71206888 Initial import
thib
parents:
diff changeset
1343 void GrpImpl::LoadSys(const char* save) {
223b71206888 Initial import
thib
parents:
diff changeset
1344 cgm_data.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1345 save = strstr(save, "\n[Graphics]\n");
223b71206888 Initial import
thib
parents:
diff changeset
1346
223b71206888 Initial import
thib
parents:
diff changeset
1347 if (save) {
223b71206888 Initial import
thib
parents:
diff changeset
1348 save += strlen("\n[Graphics]\n");
223b71206888 Initial import
thib
parents:
diff changeset
1349 do {
223b71206888 Initial import
thib
parents:
diff changeset
1350 if (save[0] == '[') break; // next section
223b71206888 Initial import
thib
parents:
diff changeset
1351 if (strncmp(save, "CGM_CG=",7) == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1352 save += 7;
223b71206888 Initial import
thib
parents:
diff changeset
1353 while(isdigit(*save)) {
223b71206888 Initial import
thib
parents:
diff changeset
1354 int n = atoi(save);
223b71206888 Initial import
thib
parents:
diff changeset
1355 cgm_data.insert(n);
223b71206888 Initial import
thib
parents:
diff changeset
1356 save = strchr(save, ',');
223b71206888 Initial import
thib
parents:
diff changeset
1357 if (save) save++;
223b71206888 Initial import
thib
parents:
diff changeset
1358 }
223b71206888 Initial import
thib
parents:
diff changeset
1359 }
223b71206888 Initial import
thib
parents:
diff changeset
1360 save = strchr(save, '\n');
223b71206888 Initial import
thib
parents:
diff changeset
1361 if (save) save++;
223b71206888 Initial import
thib
parents:
diff changeset
1362 } while (save);
223b71206888 Initial import
thib
parents:
diff changeset
1363 }
223b71206888 Initial import
thib
parents:
diff changeset
1364 return;
223b71206888 Initial import
thib
parents:
diff changeset
1365 }
223b71206888 Initial import
thib
parents:
diff changeset
1366
223b71206888 Initial import
thib
parents:
diff changeset
1367
223b71206888 Initial import
thib
parents:
diff changeset
1368 /*****************************************************
223b71206888 Initial import
thib
parents:
diff changeset
1369 *
223b71206888 Initial import
thib
parents:
diff changeset
1370 * GrpImpl :: Wait , Exec : コマンド実行部
223b71206888 Initial import
thib
parents:
diff changeset
1371 *
223b71206888 Initial import
thib
parents:
diff changeset
1372 */
223b71206888 Initial import
thib
parents:
diff changeset
1373 static vector<int> drawn_images;
223b71206888 Initial import
thib
parents:
diff changeset
1374 static int draw_n = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1375 extern bool grpdump_req;
223b71206888 Initial import
thib
parents:
diff changeset
1376 bool GrpImpl::Wait(unsigned int current_time, Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1377 if (grpdump_req) {
223b71206888 Initial import
thib
parents:
diff changeset
1378 grpdump_req = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1379 std::map<int,GrpObj>::iterator it;
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 43
diff changeset
1380 fprintf(stderr,"front %p(%d) / %p(%d)\n",screen,screen->IsHidden(),screen_front,screen_front->IsHidden());
0
223b71206888 Initial import
thib
parents:
diff changeset
1381 for (it=grpobj.begin(); it != grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1382 GrpObj& obj = it->second;
223b71206888 Initial import
thib
parents:
diff changeset
1383 GrpObj& parent_obj = grpobj[ ((it->first)/1000) * 1000];
223b71206888 Initial import
thib
parents:
diff changeset
1384 if (obj.picture) {
223b71206888 Initial import
thib
parents:
diff changeset
1385 if (!obj.name.empty()) {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 43
diff changeset
1386 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
0
223b71206888 Initial import
thib
parents:
diff changeset
1387 it->first,obj.picture,obj.name.c_str(),
223b71206888 Initial import
thib
parents:
diff changeset
1388 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden());
223b71206888 Initial import
thib
parents:
diff changeset
1389 } else if (!obj.print_moji.empty()) {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 43
diff changeset
1390 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
0
223b71206888 Initial import
thib
parents:
diff changeset
1391 it->first,obj.picture,obj.print_moji.c_str(),
223b71206888 Initial import
thib
parents:
diff changeset
1392 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden());
223b71206888 Initial import
thib
parents:
diff changeset
1393 } else {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 43
diff changeset
1394 fprintf(stderr,"obj %06d(%p): name %10s pos %d,%d alpha %d (%d/%d/%d)\n",
0
223b71206888 Initial import
thib
parents:
diff changeset
1395 it->first,obj.picture,"<EMPTY>",
223b71206888 Initial import
thib
parents:
diff changeset
1396 obj.PosX(),obj.PosY(),obj.alpha,obj.attr&GrpObj::HIDDEN ? 1 : 0,parent_obj.attr&GrpObj::HIDDEN_GROUP ? 1 : 0,obj.picture->IsHidden());
223b71206888 Initial import
thib
parents:
diff changeset
1397 }
223b71206888 Initial import
thib
parents:
diff changeset
1398 }
223b71206888 Initial import
thib
parents:
diff changeset
1399 }
223b71206888 Initial import
thib
parents:
diff changeset
1400 std::list<PicBase*>::iterator it2;
223b71206888 Initial import
thib
parents:
diff changeset
1401 for (it2=parent.children.begin(); it2!=parent.children.end();it2++) {
48
ed6c21dde840 * use correct format (%p) for pointers
thib
parents: 43
diff changeset
1402 fprintf(stderr,"%p(%d)\n",*it2,(*it2)->IsHidden());
0
223b71206888 Initial import
thib
parents:
diff changeset
1403 }
223b71206888 Initial import
thib
parents:
diff changeset
1404 RefreshObj();
223b71206888 Initial import
thib
parents:
diff changeset
1405
223b71206888 Initial import
thib
parents:
diff changeset
1406 }
223b71206888 Initial import
thib
parents:
diff changeset
1407 #if 0
223b71206888 Initial import
thib
parents:
diff changeset
1408 if (event.presscount(MOUSE_UP)) {
223b71206888 Initial import
thib
parents:
diff changeset
1409 std::list<PicBase*>::iterator lit;
223b71206888 Initial import
thib
parents:
diff changeset
1410 draw_n++; int i=0;
223b71206888 Initial import
thib
parents:
diff changeset
1411 for (lit=parent.children.end(); lit!=parent.children.begin(); ) {
223b71206888 Initial import
thib
parents:
diff changeset
1412 lit--;
223b71206888 Initial import
thib
parents:
diff changeset
1413 (*lit)->hide();
223b71206888 Initial import
thib
parents:
diff changeset
1414 i++;
223b71206888 Initial import
thib
parents:
diff changeset
1415 if (i >= draw_n) break;
223b71206888 Initial import
thib
parents:
diff changeset
1416 }
223b71206888 Initial import
thib
parents:
diff changeset
1417 if (drawn_images.empty()) {
223b71206888 Initial import
thib
parents:
diff changeset
1418 map<int, GrpObj>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1419 for (it=grpobj.begin(); it!=grpobj.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1420 if (it->second.picture) {
223b71206888 Initial import
thib
parents:
diff changeset
1421 drawn_images.push_back(it->first);
223b71206888 Initial import
thib
parents:
diff changeset
1422 PicBase* p = it->second.DeletePic();
223b71206888 Initial import
thib
parents:
diff changeset
1423 delete p;
223b71206888 Initial import
thib
parents:
diff changeset
1424 }
223b71206888 Initial import
thib
parents:
diff changeset
1425 }
223b71206888 Initial import
thib
parents:
diff changeset
1426 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1427 vector<int>::iterator it;
223b71206888 Initial import
thib
parents:
diff changeset
1428 for (it=drawn_images.begin(); it!=drawn_images.end(); it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1429 CreateObj(*it);
223b71206888 Initial import
thib
parents:
diff changeset
1430 }
223b71206888 Initial import
thib
parents:
diff changeset
1431 drawn_images.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1432 }
223b71206888 Initial import
thib
parents:
diff changeset
1433 }
223b71206888 Initial import
thib
parents:
diff changeset
1434 #endif
223b71206888 Initial import
thib
parents:
diff changeset
1435 if (status == WAIT_ANM) {
223b71206888 Initial import
thib
parents:
diff changeset
1436 if (anm1) {
223b71206888 Initial import
thib
parents:
diff changeset
1437 if (!anm1->IsEnd()) return true;
223b71206888 Initial import
thib
parents:
diff changeset
1438 AbortAnm();
223b71206888 Initial import
thib
parents:
diff changeset
1439 }
223b71206888 Initial import
thib
parents:
diff changeset
1440 } else if (status == WAIT_SHAKE) {
223b71206888 Initial import
thib
parents:
diff changeset
1441 if (anm2) {
223b71206888 Initial import
thib
parents:
diff changeset
1442 if (!anm2->IsEnd()) return true;
223b71206888 Initial import
thib
parents:
diff changeset
1443 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1444 anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1445 }
223b71206888 Initial import
thib
parents:
diff changeset
1446 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1447 } else if (status == WAIT_SE) {
223b71206888 Initial import
thib
parents:
diff changeset
1448 if (music.IsStopSE()) status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1449 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1450 } else if (status == WAIT_MOVIE) {
223b71206888 Initial import
thib
parents:
diff changeset
1451 if (music.IsStopMovie()) {
223b71206888 Initial import
thib
parents:
diff changeset
1452 music.StopMovie();
223b71206888 Initial import
thib
parents:
diff changeset
1453 status = NORMAL;
223b71206888 Initial import
thib
parents:
diff changeset
1454 screen->ReBlit();
223b71206888 Initial import
thib
parents:
diff changeset
1455 }
223b71206888 Initial import
thib
parents:
diff changeset
1456 return true;
223b71206888 Initial import
thib
parents:
diff changeset
1457 }
223b71206888 Initial import
thib
parents:
diff changeset
1458 if (anm2) {
223b71206888 Initial import
thib
parents:
diff changeset
1459 if (anm2->IsEnd()) {
223b71206888 Initial import
thib
parents:
diff changeset
1460 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1461 anm2 = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1462 }
223b71206888 Initial import
thib
parents:
diff changeset
1463 }
223b71206888 Initial import
thib
parents:
diff changeset
1464 return false;
223b71206888 Initial import
thib
parents:
diff changeset
1465 }
223b71206888 Initial import
thib
parents:
diff changeset
1466
223b71206888 Initial import
thib
parents:
diff changeset
1467 void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除
223b71206888 Initial import
thib
parents:
diff changeset
1468 if (grpobj.find(num) == grpobj.end()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1469 deleted_pic.push_back(grpobj[num].DeletePic());
223b71206888 Initial import
thib
parents:
diff changeset
1470 }
223b71206888 Initial import
thib
parents:
diff changeset
1471 void GrpImpl::DeleteObj(int num) {
223b71206888 Initial import
thib
parents:
diff changeset
1472 if (grpobj.find(num) == grpobj.end()) return;
223b71206888 Initial import
thib
parents:
diff changeset
1473 deleted_pic.push_back(grpobj[num].DeletePic());
223b71206888 Initial import
thib
parents:
diff changeset
1474 grpobj.erase(num);
223b71206888 Initial import
thib
parents:
diff changeset
1475 }
223b71206888 Initial import
thib
parents:
diff changeset
1476 void GrpImpl::DeleteObjRange(int num_first, int num_end) {
223b71206888 Initial import
thib
parents:
diff changeset
1477 std::map<int, GrpObj>::iterator begin,end,it;
223b71206888 Initial import
thib
parents:
diff changeset
1478 begin = grpobj.lower_bound(num_first);
223b71206888 Initial import
thib
parents:
diff changeset
1479 end = grpobj.lower_bound(num_end);
223b71206888 Initial import
thib
parents:
diff changeset
1480 for (it=begin;it!=end;it++) {
223b71206888 Initial import
thib
parents:
diff changeset
1481 deleted_pic.push_back(it->second.DeletePic());
223b71206888 Initial import
thib
parents:
diff changeset
1482 }
223b71206888 Initial import
thib
parents:
diff changeset
1483 grpobj.erase(begin, end);
223b71206888 Initial import
thib
parents:
diff changeset
1484 }
223b71206888 Initial import
thib
parents:
diff changeset
1485 void GrpImpl::Exec(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
1486 if (cmd.cmd_type == CMD_TEXTEND) {
223b71206888 Initial import
thib
parents:
diff changeset
1487 music.StopKoe(500); // テキスト終了で声を止める
223b71206888 Initial import
thib
parents:
diff changeset
1488 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1489 return;
223b71206888 Initial import
thib
parents:
diff changeset
1490 }
223b71206888 Initial import
thib
parents:
diff changeset
1491 if (cmd.cmd_type == CMD_WAITFRAMEUPDATE) {
223b71206888 Initial import
thib
parents:
diff changeset
1492 // wait する場合は RefreshObj() しておく
223b71206888 Initial import
thib
parents:
diff changeset
1493 RefreshObj();
223b71206888 Initial import
thib
parents:
diff changeset
1494 }
223b71206888 Initial import
thib
parents:
diff changeset
1495 if (cmd.cmd_type != CMD_OTHER) return;
223b71206888 Initial import
thib
parents:
diff changeset
1496 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1e && cmd.cmd3 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1497 cmd.cmd_type = CMD_SAVECMDGRP_START; // grp stack clear
223b71206888 Initial import
thib
parents:
diff changeset
1498 }
223b71206888 Initial import
thib
parents:
diff changeset
1499 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x21) {
223b71206888 Initial import
thib
parents:
diff changeset
1500 if (cmd.cmd3 == 0x46) {
223b71206888 Initial import
thib
parents:
diff changeset
1501 const char* name = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
1502 int pdt = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1503 eprintf("load surface %s pdt %d\n",name, pdt);
223b71206888 Initial import
thib
parents:
diff changeset
1504 if (pdt == 0)
223b71206888 Initial import
thib
parents:
diff changeset
1505 reserved_load_surface0 = name; // 画像読み込みは 01-1f:0000 まで待つ
223b71206888 Initial import
thib
parents:
diff changeset
1506 else if (pdt == 1)
223b71206888 Initial import
thib
parents:
diff changeset
1507 LoadSurface(name); // 背景絵読み込み?
223b71206888 Initial import
thib
parents:
diff changeset
1508 else
223b71206888 Initial import
thib
parents:
diff changeset
1509 LoadSurface(name, pdt);
223b71206888 Initial import
thib
parents:
diff changeset
1510 cmd.cmd_type = CMD_SAVECMDGRP;
223b71206888 Initial import
thib
parents:
diff changeset
1511 } else if (cmd.cmd3 == 0x49) {
223b71206888 Initial import
thib
parents:
diff changeset
1512 const char* name = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
1513 int sel = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1514 eprintf("set background %s sel %d\n",name, sel);
223b71206888 Initial import
thib
parents:
diff changeset
1515 if (name[0] == '?') {
223b71206888 Initial import
thib
parents:
diff changeset
1516 LoadSurface();
223b71206888 Initial import
thib
parents:
diff changeset
1517 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1518 LoadSurface(name);
223b71206888 Initial import
thib
parents:
diff changeset
1519 }
223b71206888 Initial import
thib
parents:
diff changeset
1520 StartAnm(sel);
223b71206888 Initial import
thib
parents:
diff changeset
1521 status = WAIT_ANM;
223b71206888 Initial import
thib
parents:
diff changeset
1522 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
1523 if (name[0] == '?')
223b71206888 Initial import
thib
parents:
diff changeset
1524 cmd.cmd_type = CMD_SAVECMDGRP_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
1525 else
223b71206888 Initial import
thib
parents:
diff changeset
1526 cmd.cmd_type = CMD_SAVECMDGRP_START;
223b71206888 Initial import
thib
parents:
diff changeset
1527 } else if (cmd.cmd3 == 0x4b) {
223b71206888 Initial import
thib
parents:
diff changeset
1528 int pos = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1529 const char* name = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1530 int sel = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1531 eprintf("set foreground %s sel %d pos %d\n",name, sel, pos);
223b71206888 Initial import
thib
parents:
diff changeset
1532 AddSurface(name);
223b71206888 Initial import
thib
parents:
diff changeset
1533 StartAnm(sel);
223b71206888 Initial import
thib
parents:
diff changeset
1534 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
1535 status = WAIT_ANM;
223b71206888 Initial import
thib
parents:
diff changeset
1536 cmd.cmd_type = CMD_SAVECMDGRP_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
1537 } else if (cmd.cmd3 == 0x4c) {
223b71206888 Initial import
thib
parents:
diff changeset
1538 /* 0x46 との違いがわからない */
223b71206888 Initial import
thib
parents:
diff changeset
1539 /* とりあえず bg として登録しないでみる */
223b71206888 Initial import
thib
parents:
diff changeset
1540 /* 735 / 19438 : unsupported command; 0x23 - cmd 01-21:004c:00[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
1541 ** "?",0
223b71206888 Initial import
thib
parents:
diff changeset
1542 */
223b71206888 Initial import
thib
parents:
diff changeset
1543 /* arg1 = "?" arg2 = 0 */
223b71206888 Initial import
thib
parents:
diff changeset
1544 const char* name = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
1545 int sel = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1546 if (name[0] == '?') {
223b71206888 Initial import
thib
parents:
diff changeset
1547 LoadSurface();
223b71206888 Initial import
thib
parents:
diff changeset
1548 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1549 LoadSurface(name, 1);
223b71206888 Initial import
thib
parents:
diff changeset
1550 }
223b71206888 Initial import
thib
parents:
diff changeset
1551 StartAnm(sel);
223b71206888 Initial import
thib
parents:
diff changeset
1552 status = WAIT_ANM;
223b71206888 Initial import
thib
parents:
diff changeset
1553 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
1554 if (name[0] == '?')
223b71206888 Initial import
thib
parents:
diff changeset
1555 cmd.cmd_type = CMD_SAVECMDGRP_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
1556 else
223b71206888 Initial import
thib
parents:
diff changeset
1557 cmd.cmd_type = CMD_SAVECMDGRP_START;
223b71206888 Initial import
thib
parents:
diff changeset
1558 } else if (cmd.cmd3 == 0x20) {
223b71206888 Initial import
thib
parents:
diff changeset
1559 // shake screen
223b71206888 Initial import
thib
parents:
diff changeset
1560 char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
1561 sprintf(key, "#SHAKE.%03d", cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1562 if (config.SearchParam(key) != 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1563 fprintf(stderr,"Cannot find shake pattern %d; use default pattern\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1564 strcpy(key, "#SHAKE.000"); // default key
223b71206888 Initial import
thib
parents:
diff changeset
1565 }
223b71206888 Initial import
thib
parents:
diff changeset
1566 int num; const int* pattern;
223b71206888 Initial import
thib
parents:
diff changeset
1567 pattern = config.GetParamArray(key, num);
223b71206888 Initial import
thib
parents:
diff changeset
1568 if (pattern) {
223b71206888 Initial import
thib
parents:
diff changeset
1569 StartShake(num, pattern);
223b71206888 Initial import
thib
parents:
diff changeset
1570 status = WAIT_SHAKE;
223b71206888 Initial import
thib
parents:
diff changeset
1571 }
223b71206888 Initial import
thib
parents:
diff changeset
1572 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1573 } else if (cmd.cmd3 == 0x64 && cmd.cmd4 == 2) { // copy (KANOGI)
223b71206888 Initial import
thib
parents:
diff changeset
1574 int sx = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1575 int sy = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1576 int w = cmd.args[2].value - sx;
223b71206888 Initial import
thib
parents:
diff changeset
1577 int h = cmd.args[3].value - sy;
223b71206888 Initial import
thib
parents:
diff changeset
1578 Rect rect(sx, sy, sx+w, sy+h);
223b71206888 Initial import
thib
parents:
diff changeset
1579 int src = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1580 int dx = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1581 int dy = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1582 int dest = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1583 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
1584 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
223b71206888 Initial import
thib
parents:
diff changeset
1585 printf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
223b71206888 Initial import
thib
parents:
diff changeset
1586 if (src == dest) {
223b71206888 Initial import
thib
parents:
diff changeset
1587 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect);
223b71206888 Initial import
thib
parents:
diff changeset
1588 src = WORKPDT;
223b71206888 Initial import
thib
parents:
diff changeset
1589 }
223b71206888 Initial import
thib
parents:
diff changeset
1590 parent.Root().BlitSurface(Ssurface(src), rect, Dsurface(dest), Rect(dx,dy));
223b71206888 Initial import
thib
parents:
diff changeset
1591 if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h));
223b71206888 Initial import
thib
parents:
diff changeset
1592 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1593 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1594 int x = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1595 int y = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1596 int w = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1597 int h = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1598 Rect rect(x,y,x+w,y+w);
223b71206888 Initial import
thib
parents:
diff changeset
1599 int pdt = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1600 int r = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1601 int g = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1602 int b = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1603 eprintf("clear %d:(%d,%d) size (%d,%d) r %d g %d b %d\n",pdt,x,y,w,h,r,g,b);
223b71206888 Initial import
thib
parents:
diff changeset
1604 DSurfaceFill(Dsurface(pdt), rect, r, g, b, 0xff);
223b71206888 Initial import
thib
parents:
diff changeset
1605 // if (pdt == 0) screen->ReBlit(rect);
223b71206888 Initial import
thib
parents:
diff changeset
1606 cmd.cmd_type = CMD_SAVECMDGRP;
223b71206888 Initial import
thib
parents:
diff changeset
1607 } else if (cmd.cmd3 == 0x4b1 && cmd.cmd4 == 3) { // alpha つきfill
223b71206888 Initial import
thib
parents:
diff changeset
1608 int x = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1609 int y = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1610 int w = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1611 int h = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1612 Rect rect(x,y,x+w,y+h);
223b71206888 Initial import
thib
parents:
diff changeset
1613 int pdt = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1614 int r = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1615 int g = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1616 int b = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1617 int a = cmd.args[8].value;
223b71206888 Initial import
thib
parents:
diff changeset
1618 eprintf("alpha-clear %d:(%d,%d) size (%d,%d) r %d g %d b %d a %d\n",pdt,x,y,w,h,r,g,b,a);
223b71206888 Initial import
thib
parents:
diff changeset
1619 if (a <= 0) ;
223b71206888 Initial import
thib
parents:
diff changeset
1620 else if (a >= 255) DSurfaceFill(Dsurface(pdt), rect, r, g, b);
223b71206888 Initial import
thib
parents:
diff changeset
1621 else {
223b71206888 Initial import
thib
parents:
diff changeset
1622 DSurfaceFill(Dsurface(WORKPDT), rect, r, g, b, a);
223b71206888 Initial import
thib
parents:
diff changeset
1623 parent.Root().BlitSurface(Dsurface(WORKPDT), rect, Dsurface(pdt), rect);
223b71206888 Initial import
thib
parents:
diff changeset
1624 }
223b71206888 Initial import
thib
parents:
diff changeset
1625 // if (pdt == 0) screen->ReBlit(rect);
223b71206888 Initial import
thib
parents:
diff changeset
1626 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1627 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1628 int sx = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1629 int sy = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1630 int w = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1631 int h = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1632 int src = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1633 int dx = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1634 int dy = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1635 int dest = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1636 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
223b71206888 Initial import
thib
parents:
diff changeset
1637 parent.Root().BlitSurface(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy));
223b71206888 Initial import
thib
parents:
diff changeset
1638 //DSurfaceMove(Ssurface(src), Rect(sx,sy,sx+w,sy+h), Dsurface(dest), Rect(dx,dy));
223b71206888 Initial import
thib
parents:
diff changeset
1639 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h));
223b71206888 Initial import
thib
parents:
diff changeset
1640 cmd.cmd_type = CMD_SAVECMDGRP;
223b71206888 Initial import
thib
parents:
diff changeset
1641 } else if (cmd.cmd3 == 0x44c && cmd.cmd4 == 3) { // alpha つきcopy
223b71206888 Initial import
thib
parents:
diff changeset
1642 int sx = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1643 int sy = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1644 int w = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1645 int h = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1646 Rect rect(sx, sy, sx+w, sy+h);
223b71206888 Initial import
thib
parents:
diff changeset
1647 int src = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1648 int dx = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1649 int dy = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1650 int dest = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1651 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
1652 if (cmd.args[8].value < 0) alpha = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1653 else if (cmd.args[8].value > 255) alpha = 255;
223b71206888 Initial import
thib
parents:
diff changeset
1654 else alpha = cmd.args[8].value;
223b71206888 Initial import
thib
parents:
diff changeset
1655 eprintf("copy surface %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
223b71206888 Initial import
thib
parents:
diff changeset
1656 if (src == dest) {
223b71206888 Initial import
thib
parents:
diff changeset
1657 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect);
223b71206888 Initial import
thib
parents:
diff changeset
1658 src = WORKPDT;
223b71206888 Initial import
thib
parents:
diff changeset
1659 }
223b71206888 Initial import
thib
parents:
diff changeset
1660 if (alpha != 0)
223b71206888 Initial import
thib
parents:
diff changeset
1661 parent.Root().BlitSurface(Ssurface(src), rect, &alpha, Rect(0,0,1,1), Dsurface(dest), Rect(dx,dy), 0);
223b71206888 Initial import
thib
parents:
diff changeset
1662 // if (dest == 0) screen->ReBlit(Rect(dx,dy,dx+w,dy+h));
223b71206888 Initial import
thib
parents:
diff changeset
1663 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1664 } else if (cmd.cmd3 == 0x640 && cmd.cmd4 == 3) { // saturate mode で alpha 付き copy
223b71206888 Initial import
thib
parents:
diff changeset
1665 int sx = cmd.args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
1666 int sy = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1667 int w = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1668 int h = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1669 Rect rect(sx, sy, sx+w, sy+h);
223b71206888 Initial import
thib
parents:
diff changeset
1670 int src = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1671 int dx = cmd.args[5].value;
223b71206888 Initial import
thib
parents:
diff changeset
1672 int dy = cmd.args[6].value;
223b71206888 Initial import
thib
parents:
diff changeset
1673 int dest = cmd.args[7].value;
223b71206888 Initial import
thib
parents:
diff changeset
1674 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
1675 if (cmd.args[8].value < 0) alpha = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1676 else if (cmd.args[8].value > 255) alpha = 255;
223b71206888 Initial import
thib
parents:
diff changeset
1677 else alpha = cmd.args[8].value;
223b71206888 Initial import
thib
parents:
diff changeset
1678 eprintf("copy surface w/ saturate %d:(%d,%d) size(%d,%d) -> %d:(%d,%d)\n",src,sx,sy,w,h,dest,dx,dy);
223b71206888 Initial import
thib
parents:
diff changeset
1679 if (src == dest) {
223b71206888 Initial import
thib
parents:
diff changeset
1680 DSurfaceMove(Ssurface(src), rect, Dsurface(WORKPDT), rect);
223b71206888 Initial import
thib
parents:
diff changeset
1681 src = WORKPDT;
223b71206888 Initial import
thib
parents:
diff changeset
1682 }
223b71206888 Initial import
thib
parents:
diff changeset
1683 if (alpha != 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1684 // saturate mode : screen (picture) を一時的に作成
223b71206888 Initial import
thib
parents:
diff changeset
1685 PicBase* screen_tmp = parent.create_leaf(Rect(0, 0, parent.Width(), parent.Height()), 0);
223b71206888 Initial import
thib
parents:
diff changeset
1686 screen_tmp->SetSurface(Ssurface(src), 0, 0, PicBase::BLIT_SATURATE);
223b71206888 Initial import
thib
parents:
diff changeset
1687 screen_tmp->SetSurfaceRect(rect);
223b71206888 Initial import
thib
parents:
diff changeset
1688 screen_tmp->Move(dx, dy);
223b71206888 Initial import
thib
parents:
diff changeset
1689 screen_tmp->SetSurfaceAlpha(&alpha, Rect(0,0,1,1));
223b71206888 Initial import
thib
parents:
diff changeset
1690 screen_tmp->SimpleBlit(Dsurface(dest));
223b71206888 Initial import
thib
parents:
diff changeset
1691 delete screen_tmp;
223b71206888 Initial import
thib
parents:
diff changeset
1692 }
223b71206888 Initial import
thib
parents:
diff changeset
1693 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1694 } else if (cmd.cmd3 == 0x196 && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1695 Rect r_from(cmd.args[0].value, cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1696 Rect r_to(cmd.args[2].value, cmd.args[3].value);
223b71206888 Initial import
thib
parents:
diff changeset
1697 int src_pdt = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
1698 Rect r(cmd.args[5].value,cmd.args[6].value,cmd.args[7].value+1,cmd.args[8].value+1);
223b71206888 Initial import
thib
parents:
diff changeset
1699 int tm = cmd.args[9].value;
223b71206888 Initial import
thib
parents:
diff changeset
1700 fprintf(stderr,"??? cmd time %d\n",tm);
223b71206888 Initial import
thib
parents:
diff changeset
1701 // anm1 = new ScnGrpMove(event, screen, parent.Root(), surface, r, Ssurface(2), r_from, r_to, tm);
223b71206888 Initial import
thib
parents:
diff changeset
1702 // status = WAIT_ANM;
223b71206888 Initial import
thib
parents:
diff changeset
1703 }
223b71206888 Initial import
thib
parents:
diff changeset
1704 }
223b71206888 Initial import
thib
parents:
diff changeset
1705 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x22) {
223b71206888 Initial import
thib
parents:
diff changeset
1706 if (cmd.cmd3 == 0x0c30 && cmd.cmd4 == 0) { // スクロールする画像効果(Princess Bride)
223b71206888 Initial import
thib
parents:
diff changeset
1707 if (anm2) {
223b71206888 Initial import
thib
parents:
diff changeset
1708 anm2->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1709 delete anm2;
223b71206888 Initial import
thib
parents:
diff changeset
1710 }
223b71206888 Initial import
thib
parents:
diff changeset
1711 PicBase* pic; Surface* s;
223b71206888 Initial import
thib
parents:
diff changeset
1712 Rect r(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value+1, cmd.args[4].value+1);
223b71206888 Initial import
thib
parents:
diff changeset
1713 const char* name = cmd.Str(cmd.args[5]);
223b71206888 Initial import
thib
parents:
diff changeset
1714 Rect sr_start(cmd.args[6].value,cmd.args[7].value);
223b71206888 Initial import
thib
parents:
diff changeset
1715 Rect sr_end(cmd.args[8].value,cmd.args[9].value);
223b71206888 Initial import
thib
parents:
diff changeset
1716 int tm = cmd.args[10].value;
223b71206888 Initial import
thib
parents:
diff changeset
1717 LoadSurface(name, 2); /* PDT2 に読み込み、と決め打ち */
223b71206888 Initial import
thib
parents:
diff changeset
1718
223b71206888 Initial import
thib
parents:
diff changeset
1719 anm2 = new ScnGrpMove(event, screen, parent.Root(), Dsurface(1), r, Ssurface(2), sr_start, sr_end, tm);
223b71206888 Initial import
thib
parents:
diff changeset
1720 cmd.cmd_type = CMD_SAVECMDGRP;
223b71206888 Initial import
thib
parents:
diff changeset
1721 }
223b71206888 Initial import
thib
parents:
diff changeset
1722 if ( (cmd.cmd3 == 0xc1c && cmd.cmd4 == 0) || (cmd.cmd3 == 0x835 && cmd.cmd4 == 0) ) {
223b71206888 Initial import
thib
parents:
diff changeset
1723 // カードが落ちるアニメーション
223b71206888 Initial import
thib
parents:
diff changeset
1724 int i;
223b71206888 Initial import
thib
parents:
diff changeset
1725 ScnGrpAnm* new_anm = new ScnGrpAnm(event, screen, *this);
223b71206888 Initial import
thib
parents:
diff changeset
1726 if (cmd.cmd3 == 0x835) {
223b71206888 Initial import
thib
parents:
diff changeset
1727 AbortAnm();
223b71206888 Initial import
thib
parents:
diff changeset
1728 anm1 = new_anm;
223b71206888 Initial import
thib
parents:
diff changeset
1729 status = WAIT_ANM;
223b71206888 Initial import
thib
parents:
diff changeset
1730 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
1731 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1732 anm2 = new_anm;
223b71206888 Initial import
thib
parents:
diff changeset
1733 }
223b71206888 Initial import
thib
parents:
diff changeset
1734 for (i=0; i<cmd.argc; i++) {
223b71206888 Initial import
thib
parents:
diff changeset
1735 const char* name = cmd.Str(cmd.args[i*3+1]);
223b71206888 Initial import
thib
parents:
diff changeset
1736 int tm = cmd.args[i*3+2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1737 new_anm->push_back(ScnGrpAnmAtom(name,tm));
223b71206888 Initial import
thib
parents:
diff changeset
1738 }
223b71206888 Initial import
thib
parents:
diff changeset
1739 new_anm->CalcTotal();
223b71206888 Initial import
thib
parents:
diff changeset
1740 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1741 }
223b71206888 Initial import
thib
parents:
diff changeset
1742 }
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1743 if (cmd.cmd1 == 1 && cmd.cmd2 == 4) {
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1744 if (cmd.cmd3 == 0x5dc) // Total number of CG
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1745 cmd.SetSysvar(cgm_size);
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1746 if (cmd.cmd3 == 0x5dd) // Number of CG viewed
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1747 cmd.SetSysvar(cgm_data.size());
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1748 if (cmd.cmd3 == 0x5de) // Percentage of CG viewed
20
824b89018ea8 * CG completion percentage (maybe not working properly?)
thib
parents: 18
diff changeset
1749 cmd.SetSysvar(cgm_data.size() * 100 / cgm_size);
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1750
0
223b71206888 Initial import
thib
parents:
diff changeset
1751 if (cmd.cmd3 == 0xd8 || cmd.cmd3 == 0xd3 || cmd.cmd3 == 0xd2 || cmd.cmd3 == 0xd7) {
223b71206888 Initial import
thib
parents:
diff changeset
1752 cmd.clear(); // いつも 0xd8 / 0xd7 と組で出てくる
223b71206888 Initial import
thib
parents:
diff changeset
1753 }
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1754
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1755 // CG Status
0
223b71206888 Initial import
thib
parents:
diff changeset
1756 if (cmd.cmd3 == 0x5e0) { // 画像既視フラグを得る
223b71206888 Initial import
thib
parents:
diff changeset
1757 string s = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
1758 if (cgm_info.find(s) == cgm_info.end()) {
223b71206888 Initial import
thib
parents:
diff changeset
1759 fprintf(stderr,"cmd 01-04:05e0 : cannot find cgm-info of '%s'\n",s.c_str());
223b71206888 Initial import
thib
parents:
diff changeset
1760 return;
223b71206888 Initial import
thib
parents:
diff changeset
1761 }
223b71206888 Initial import
thib
parents:
diff changeset
1762 int n = cgm_info[s];
223b71206888 Initial import
thib
parents:
diff changeset
1763 if (cgm_data.find(n) == cgm_data.end()) cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1764 else cmd.SetSysvar(1);
223b71206888 Initial import
thib
parents:
diff changeset
1765 }
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1766
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1767 if (cmd.cmd3 == 0x6a4) { // CreateInput (index, x, y, width, height, fontsize, br, bg, bb, fr, fg, fb)
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1768 int index = cmd.args[0].value;
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1769 int x = cmd.args[1].value;
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1770 int y = cmd.args[2].value;
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1771 //TODO
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1772 }
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1773 if (cmd.cmd3 == 0x6ae) { // SetInput (index, text)
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1774 //TODO
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
1775 }
0
223b71206888 Initial import
thib
parents:
diff changeset
1776 }
223b71206888 Initial import
thib
parents:
diff changeset
1777 #if 1
223b71206888 Initial import
thib
parents:
diff changeset
1778 /* object 操作 */
223b71206888 Initial import
thib
parents:
diff changeset
1779 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x3d || cmd.cmd2 == 0x3e) && (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b || cmd.cmd3 == 0x0e)) { // clear object
223b71206888 Initial import
thib
parents:
diff changeset
1780 if (cmd.cmd3 == 0x0a || cmd.cmd3 == 0x0b) {
223b71206888 Initial import
thib
parents:
diff changeset
1781 if (cmd.cmd1 == 2 && cmd.args.size() == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1782 int num = cmd.args[0].value*1000 + cmd.args[1].value + 500;
223b71206888 Initial import
thib
parents:
diff changeset
1783 DeleteObj(num);
223b71206888 Initial import
thib
parents:
diff changeset
1784 } else if (cmd.args.size() == 1) { // group ごと消去
223b71206888 Initial import
thib
parents:
diff changeset
1785 int num_first = cmd.args[0].value * 1000;
223b71206888 Initial import
thib
parents:
diff changeset
1786 int num_end = num_first+1000;
223b71206888 Initial import
thib
parents:
diff changeset
1787 DeleteObjRange(num_first, num_end);
223b71206888 Initial import
thib
parents:
diff changeset
1788 }
223b71206888 Initial import
thib
parents:
diff changeset
1789 } else { // 0x0e
223b71206888 Initial import
thib
parents:
diff changeset
1790 if (cmd.cmd1 == 1 && cmd.args.size() == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1791 SwapObj(cmd.args[0].value * 1000, cmd.args[1].value * 1000);
223b71206888 Initial import
thib
parents:
diff changeset
1792 } else if (cmd.cmd1 == 2 && cmd.args.size() == 3) {
223b71206888 Initial import
thib
parents:
diff changeset
1793 int v1 = cmd.args[0].value*1000 + cmd.args[1].value + 500;
223b71206888 Initial import
thib
parents:
diff changeset
1794 int v2 = cmd.args[0].value*1000 + cmd.args[2].value + 500;
223b71206888 Initial import
thib
parents:
diff changeset
1795 SwapObj(v1, v2);
223b71206888 Initial import
thib
parents:
diff changeset
1796 }
223b71206888 Initial import
thib
parents:
diff changeset
1797 }
223b71206888 Initial import
thib
parents:
diff changeset
1798 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1799 }
223b71206888 Initial import
thib
parents:
diff changeset
1800 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0x01) { // ??? : CLANNAD
223b71206888 Initial import
thib
parents:
diff changeset
1801 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1802 }
223b71206888 Initial import
thib
parents:
diff changeset
1803 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x3c && cmd.cmd3 == 0) { // ??? : KANOGI : 画像オブジェクトの削除?
223b71206888 Initial import
thib
parents:
diff changeset
1804 DeleteObjPic(cmd.args[0].value * 1000); // 旧ファイル名のsurfaceを削除
223b71206888 Initial import
thib
parents:
diff changeset
1805 GrpObj& g = grpobj[cmd.args[0].value * 1000];
223b71206888 Initial import
thib
parents:
diff changeset
1806 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
223b71206888 Initial import
thib
parents:
diff changeset
1807 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1808 }
223b71206888 Initial import
thib
parents:
diff changeset
1809 if ( (cmd.cmd1 == 1 || cmd.cmd1 == 2) && (cmd.cmd2 == 0x47 || cmd.cmd2 == 0x48|| cmd.cmd2 == 0x49 || cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52 || cmd.cmd2 == 0x54)) {
223b71206888 Initial import
thib
parents:
diff changeset
1810 if (cmd.cmd1 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
1811 if (cmd.args.size() >= 1) cmd.args[0].value *= 1000; // とりあえず 1000倍しておく
223b71206888 Initial import
thib
parents:
diff changeset
1812 } else { // cmd.cmd2 == 2
223b71206888 Initial import
thib
parents:
diff changeset
1813 // オブジェクト番号を指定するコマンド引数が一つ増えているのを消去
223b71206888 Initial import
thib
parents:
diff changeset
1814 vector<VarInfo> args = cmd.args;
223b71206888 Initial import
thib
parents:
diff changeset
1815 cmd.args.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1816 if (args.size() >= 2) {
223b71206888 Initial import
thib
parents:
diff changeset
1817 cmd.args.push_back(args[0].value*1000 + args[1].value + 500);
223b71206888 Initial import
thib
parents:
diff changeset
1818 cmd.args.insert(cmd.args.end(), args.begin()+2, args.end());
223b71206888 Initial import
thib
parents:
diff changeset
1819 }
223b71206888 Initial import
thib
parents:
diff changeset
1820 }
223b71206888 Initial import
thib
parents:
diff changeset
1821 if (cmd.cmd2 == 0x47) {
223b71206888 Initial import
thib
parents:
diff changeset
1822 /**************:
223b71206888 Initial import
thib
parents:
diff changeset
1823 0x47 : オブジェクト内容の設定
223b71206888 Initial import
thib
parents:
diff changeset
1824 0x3e8: G00 ファイル
223b71206888 Initial import
thib
parents:
diff changeset
1825 0x3eb: GAN ファイル
223b71206888 Initial import
thib
parents:
diff changeset
1826 0x44c: 矩形領域
223b71206888 Initial import
thib
parents:
diff changeset
1827 0x4b0: 文字列
223b71206888 Initial import
thib
parents:
diff changeset
1828 0x514: 天候効果
223b71206888 Initial import
thib
parents:
diff changeset
1829 0x578: 数字の画像表示
223b71206888 Initial import
thib
parents:
diff changeset
1830 */
223b71206888 Initial import
thib
parents:
diff changeset
1831 int base_argc = 0;
223b71206888 Initial import
thib
parents:
diff changeset
1832 DeleteObjPic(cmd.args[0].value); // 旧ファイル名のsurfaceを削除
223b71206888 Initial import
thib
parents:
diff changeset
1833 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1834 if (cmd.cmd3 == 0x3e8) { /* ファイル名設定 */
223b71206888 Initial import
thib
parents:
diff changeset
1835 g.gtype = GrpObj::FILE;
223b71206888 Initial import
thib
parents:
diff changeset
1836 string name = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1837 if (name.find('?') != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1838 name.erase(name.find('?')); // '?' 以降の意味がわからない
223b71206888 Initial import
thib
parents:
diff changeset
1839 }
223b71206888 Initial import
thib
parents:
diff changeset
1840 g.name = name;
223b71206888 Initial import
thib
parents:
diff changeset
1841 } else if (cmd.cmd3 == 0x3eb) { /* ファイル名設定(GAN含む) */
223b71206888 Initial import
thib
parents:
diff changeset
1842 g.gtype = GrpObj::GAN;
223b71206888 Initial import
thib
parents:
diff changeset
1843 if (cmd.Str(cmd.args[1]) == string("???"))
223b71206888 Initial import
thib
parents:
diff changeset
1844 g.name = cmd.Str(cmd.args[2]);
223b71206888 Initial import
thib
parents:
diff changeset
1845 else
223b71206888 Initial import
thib
parents:
diff changeset
1846 g.name = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1847 g.gan_name = cmd.Str(cmd.args[2]);
5
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1848
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1849 if (cmd.cmd4 >= 1 && cmd.args[3].value == 0)
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1850 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1851 else
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1852 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN));
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1853
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1854 if (cmd.argc >= 5)
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1855 g.SetPos(1, cmd.args[4].value, -cmd.args[5].value);
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1856
aa0577c1a494 Support for animated things like Botan
thib
parents: 4
diff changeset
1857 if (g.name.find('?') != -1) {
4
9fb4609a5372 Partially fixed Botan's bug
thib
parents: 0
diff changeset
1858 g.name.erase(g.name.find('?'));
9fb4609a5372 Partially fixed Botan's bug
thib
parents: 0
diff changeset
1859 g.gan_name = cmd.Str(cmd.args[2]);
9fb4609a5372 Partially fixed Botan's bug
thib
parents: 0
diff changeset
1860 }
0
223b71206888 Initial import
thib
parents:
diff changeset
1861 } else if (cmd.cmd3 == 0x4b0) { // 画像を文字列として指定
223b71206888 Initial import
thib
parents:
diff changeset
1862 g.gtype = GrpObj::MOJI;
223b71206888 Initial import
thib
parents:
diff changeset
1863 g.print_moji = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1864 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN)); // 常に表示がデフォルト?
223b71206888 Initial import
thib
parents:
diff changeset
1865 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1866 } else if (cmd.cmd3 == 0x578) { // 数値を画像として表示
223b71206888 Initial import
thib
parents:
diff changeset
1867 g.gtype = GrpObj::DIGIT;
223b71206888 Initial import
thib
parents:
diff changeset
1868 g.name = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1869 }
223b71206888 Initial import
thib
parents:
diff changeset
1870 CreateObj(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1871 if (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb || cmd.cmd3 == 0x4b0 || cmd.cmd3 == 0x578) {
223b71206888 Initial import
thib
parents:
diff changeset
1872 // FILE, GAN, MOJI, DIGIT ならば座標等の設定を行う
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
1873 if (cmd.cmd4 >= 1) {
0
223b71206888 Initial import
thib
parents:
diff changeset
1874 if (cmd.args[2+base_argc].value == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
1875 if (cmd.cmd1 == 1)
223b71206888 Initial import
thib
parents:
diff changeset
1876 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP);
223b71206888 Initial import
thib
parents:
diff changeset
1877 else
223b71206888 Initial import
thib
parents:
diff changeset
1878 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
223b71206888 Initial import
thib
parents:
diff changeset
1879 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1880 if (cmd.cmd1 == 1)
223b71206888 Initial import
thib
parents:
diff changeset
1881 g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP)));
223b71206888 Initial import
thib
parents:
diff changeset
1882 else
223b71206888 Initial import
thib
parents:
diff changeset
1883 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
223b71206888 Initial import
thib
parents:
diff changeset
1884 }
223b71206888 Initial import
thib
parents:
diff changeset
1885 if (cmd.cmd1 == 1)
223b71206888 Initial import
thib
parents:
diff changeset
1886 SetObjChangedGroup(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1887 }
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
1888 if (cmd.cmd4 >= 2) { // 座標等も設定
0
223b71206888 Initial import
thib
parents:
diff changeset
1889 g.SetPos(0,cmd.args[3+base_argc].value, cmd.args[4+base_argc].value);
223b71206888 Initial import
thib
parents:
diff changeset
1890 }
18
4d7486cb20a9 Sync with upstream
thib
parents: 14
diff changeset
1891 if ( (cmd.cmd3 == 0x3e8 || cmd.cmd3 == 0x3eb) && cmd.cmd4 >= 3) { // pattern 番号も設定
0
223b71206888 Initial import
thib
parents:
diff changeset
1892 g.SetSurfaceNum(cmd.args[5+base_argc].value);
223b71206888 Initial import
thib
parents:
diff changeset
1893 base_argc++; // 0x3e8 (FILE) / 0x3eb (GAN) の場合のみこのオプションは存在する
223b71206888 Initial import
thib
parents:
diff changeset
1894 }
223b71206888 Initial import
thib
parents:
diff changeset
1895 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1896 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1897 fprintf(stderr,"CreateObj : cmd.cmd3 = %04x ; not supported!\n",cmd.cmd3);
223b71206888 Initial import
thib
parents:
diff changeset
1898 }
223b71206888 Initial import
thib
parents:
diff changeset
1899 } else if (cmd.cmd2 == 0x48) {
223b71206888 Initial import
thib
parents:
diff changeset
1900 // 画面切り替え後の object (back screen object) 設定
223b71206888 Initial import
thib
parents:
diff changeset
1901 if (cmd.cmd3 == 0x3e8) {
223b71206888 Initial import
thib
parents:
diff changeset
1902 // cmd.cmd4 == 0 : args = 2, CLANNAD : cg mode
223b71206888 Initial import
thib
parents:
diff changeset
1903 // cmd.cmd4 == 1 : args = 3, CLANNAD : 春原回想?のところで画面が黒くなってしまうので、とりあえず。
223b71206888 Initial import
thib
parents:
diff changeset
1904 // cmd.cmd4 == 2 : args = 5, KANOGI : Fore Graphics
223b71206888 Initial import
thib
parents:
diff changeset
1905 // cmd.cmd4 == 3 : args = 6, KANOGI : CG mode
223b71206888 Initial import
thib
parents:
diff changeset
1906 GrpObj& g = bs_obj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1907 string name = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
1908 if (name.find('?') != -1) {
223b71206888 Initial import
thib
parents:
diff changeset
1909 name.erase(name.find('?')); // '?' 以降の意味がわからない
223b71206888 Initial import
thib
parents:
diff changeset
1910 }
223b71206888 Initial import
thib
parents:
diff changeset
1911 g.gtype = GrpObj::FILE;
223b71206888 Initial import
thib
parents:
diff changeset
1912 g.name = name;
223b71206888 Initial import
thib
parents:
diff changeset
1913 if (cmd.cmd4 >= 1 && cmd.args[2].value == 0)
223b71206888 Initial import
thib
parents:
diff changeset
1914 g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
223b71206888 Initial import
thib
parents:
diff changeset
1915 else
223b71206888 Initial import
thib
parents:
diff changeset
1916 g.attr = GrpObj::Attribute(g.attr & ~(GrpObj::HIDDEN));
223b71206888 Initial import
thib
parents:
diff changeset
1917 if (cmd.cmd4 >= 2)
223b71206888 Initial import
thib
parents:
diff changeset
1918 g.SetPos(0,cmd.args[3].value, cmd.args[4].value);
223b71206888 Initial import
thib
parents:
diff changeset
1919 if (cmd.cmd4 >= 3)
223b71206888 Initial import
thib
parents:
diff changeset
1920 g.SetSurfaceNum(cmd.args[5].value);
223b71206888 Initial import
thib
parents:
diff changeset
1921 if (cmd.cmd4 <= 3)
223b71206888 Initial import
thib
parents:
diff changeset
1922 cmd.cmd_type = CMD_SAVECMDGRP;
223b71206888 Initial import
thib
parents:
diff changeset
1923 }
223b71206888 Initial import
thib
parents:
diff changeset
1924 } else if (cmd.cmd2 == 0x49) {
223b71206888 Initial import
thib
parents:
diff changeset
1925 if (cmd.cmd3 == 0) { // アニメーションを強制終了
223b71206888 Initial import
thib
parents:
diff changeset
1926 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1927 if (g.anm == 0 || g.anm->IsEnd()) ;
223b71206888 Initial import
thib
parents:
diff changeset
1928 else g.anm->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1929 } else if (cmd.cmd3 == 3) { // アニメーション中か?
223b71206888 Initial import
thib
parents:
diff changeset
1930 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1931 if (g.anm == 0 || g.anm->IsEnd()) {
223b71206888 Initial import
thib
parents:
diff changeset
1932 cmd.SetSysvar(0);
223b71206888 Initial import
thib
parents:
diff changeset
1933 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1934 cmd.SetSysvar(1);
223b71206888 Initial import
thib
parents:
diff changeset
1935 }
223b71206888 Initial import
thib
parents:
diff changeset
1936 } else if (cmd.cmd3 == 1000) {
223b71206888 Initial import
thib
parents:
diff changeset
1937 // アニメーションを途中で停止した状態にする
223b71206888 Initial import
thib
parents:
diff changeset
1938 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1939 if (g.anm == 0 || g.anm->IsEnd()) {
223b71206888 Initial import
thib
parents:
diff changeset
1940 // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1941 g.SetSurfaceNum(cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1942 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1943 g.anm->Abort();
223b71206888 Initial import
thib
parents:
diff changeset
1944 g.SetSurfaceNum(cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1945 }
223b71206888 Initial import
thib
parents:
diff changeset
1946 SetObjChanged(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1947 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1948 } else if (cmd.cmd3 == 0x7d3) { // surface を増加させる画像効果
223b71206888 Initial import
thib
parents:
diff changeset
1949 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1950 g.CreateGanSpecial(event, 0, cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1951 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
223b71206888 Initial import
thib
parents:
diff changeset
1952 SetObjChanged(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1953 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1954 } else if (cmd.cmd3 == 0xbbd || cmd.cmd3 == 0xbbb || cmd.cmd3 == 0xbb9) { // アニメーション開始
223b71206888 Initial import
thib
parents:
diff changeset
1955 GrpObj& g = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1956 g.CreateGan(event, cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1957 // g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
223b71206888 Initial import
thib
parents:
diff changeset
1958 SetObjChanged(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1959 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1960 }
223b71206888 Initial import
thib
parents:
diff changeset
1961 } else if (cmd.cmd2 == 0x51 || cmd.cmd2 == 0x52) {
223b71206888 Initial import
thib
parents:
diff changeset
1962 GrpObj& g = (cmd.cmd2 == 0x51) ?
223b71206888 Initial import
thib
parents:
diff changeset
1963 grpobj[cmd.args[0].value] :
223b71206888 Initial import
thib
parents:
diff changeset
1964 bs_obj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
1965 if (cmd.cmd3 == 0x3e8) { /* 座標設定 */
223b71206888 Initial import
thib
parents:
diff changeset
1966 g.SetPos(0,cmd.args[1].value, cmd.args[2].value);
223b71206888 Initial import
thib
parents:
diff changeset
1967 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1968 } else if (cmd.cmd3 == 0x3e9 || cmd.cmd3 == 0x3ea) { /* x / y 座標のみ設定 */
223b71206888 Initial import
thib
parents:
diff changeset
1969 int x0, y0;
223b71206888 Initial import
thib
parents:
diff changeset
1970 g.GetPos(0, x0, y0);
223b71206888 Initial import
thib
parents:
diff changeset
1971 if (cmd.cmd3 == 0x3e9)
223b71206888 Initial import
thib
parents:
diff changeset
1972 g.SetPos(0,cmd.args[1].value, y0);
223b71206888 Initial import
thib
parents:
diff changeset
1973 else
223b71206888 Initial import
thib
parents:
diff changeset
1974 g.SetPos(0,x0, cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1975 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1976 } else if (cmd.cmd3 == 0x3eb) { /* alpha */
223b71206888 Initial import
thib
parents:
diff changeset
1977 g.SetAlpha(cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
1978 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1979 } else if (cmd.cmd3 == 0x3ec) { /* visible flag */
223b71206888 Initial import
thib
parents:
diff changeset
1980 if (cmd.cmd1 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
1981 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~(GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP)));
223b71206888 Initial import
thib
parents:
diff changeset
1982 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN | GrpObj::HIDDEN_GROUP);
223b71206888 Initial import
thib
parents:
diff changeset
1983 } else {
223b71206888 Initial import
thib
parents:
diff changeset
1984 if (cmd.args[1].value) g.attr = GrpObj::Attribute(g.attr & (~GrpObj::HIDDEN));
223b71206888 Initial import
thib
parents:
diff changeset
1985 else g.attr = GrpObj::Attribute(g.attr | GrpObj::HIDDEN);
223b71206888 Initial import
thib
parents:
diff changeset
1986 }
223b71206888 Initial import
thib
parents:
diff changeset
1987 g.attr = GrpObj::Attribute(g.attr | GrpObj::UPDATE_VISIBLE);
223b71206888 Initial import
thib
parents:
diff changeset
1988 // グループ単位で次の RefreshObj で表示・消去
223b71206888 Initial import
thib
parents:
diff changeset
1989 if (cmd.cmd2 == 0x51 && cmd.cmd1 == 1)
223b71206888 Initial import
thib
parents:
diff changeset
1990 SetObjChangedGroup(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
1991 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1992 } else if (cmd.cmd3 == 0x3ee || cmd.cmd3 == 0x7d6) { /* 座標設定その2? */
223b71206888 Initial import
thib
parents:
diff changeset
1993 /* 0x7d6 : 画像側の基準座標を args[4,5] に入れているのかもしれない */
223b71206888 Initial import
thib
parents:
diff changeset
1994 int index = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
1995 int x = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
1996 int y = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
1997 g.SetPos(index+1, x, y);
223b71206888 Initial import
thib
parents:
diff changeset
1998 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
1999 } else if (cmd.cmd3 == 0x3f8) { // 画像を文字列として設定:色の設定
223b71206888 Initial import
thib
parents:
diff changeset
2000 g.print_r = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2001 g.print_g = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
2002 g.print_b = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
2003 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2004 // grpobj[cmd.args[0].value].print_a = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
2005 /* args:229,18,minus-1,0,99,255,-1 */
223b71206888 Initial import
thib
parents:
diff changeset
2006 /* args:102,26,minus-1,0,99,0,255 */
223b71206888 Initial import
thib
parents:
diff changeset
2007 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2008 } else if (cmd.cmd3 == 0x3fd) { // centering mode などを設定?
223b71206888 Initial import
thib
parents:
diff changeset
2009 if (cmd.args[1].value == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
2010 g.attr = GrpObj::Attribute(g.attr | GrpObj::SATURATE);
223b71206888 Initial import
thib
parents:
diff changeset
2011 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2012 } else if (cmd.args[1].value == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2013 g.attr = GrpObj::Attribute(g.attr & (~GrpObj::SATURATE));
223b71206888 Initial import
thib
parents:
diff changeset
2014 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2015 }
223b71206888 Initial import
thib
parents:
diff changeset
2016 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2017 /* cmd3 == 0x41c : ゲームの進行とともに
223b71206888 Initial import
thib
parents:
diff changeset
2018 args:10,105
223b71206888 Initial import
thib
parents:
diff changeset
2019 args:10,133
223b71206888 Initial import
thib
parents:
diff changeset
2020 args:10,144
223b71206888 Initial import
thib
parents:
diff changeset
2021 args:10,144
223b71206888 Initial import
thib
parents:
diff changeset
2022 と変化
223b71206888 Initial import
thib
parents:
diff changeset
2023
223b71206888 Initial import
thib
parents:
diff changeset
2024 cmd3 == 0x418 :
223b71206888 Initial import
thib
parents:
diff changeset
2025 args: 10, 400 -> 100
223b71206888 Initial import
thib
parents:
diff changeset
2026 と、alpha の増加とともに変化
223b71206888 Initial import
thib
parents:
diff changeset
2027 */
223b71206888 Initial import
thib
parents:
diff changeset
2028 /*
223b71206888 Initial import
thib
parents:
diff changeset
2029 487 / 8047 : unsupported command; 0x23 - cmd 01-51:0419:00[ 2]
223b71206888 Initial import
thib
parents:
diff changeset
2030 81,-40,
223b71206888 Initial import
thib
parents:
diff changeset
2031 第二引数の 1/10 がオブジェクトの回転角
223b71206888 Initial import
thib
parents:
diff changeset
2032 */
223b71206888 Initial import
thib
parents:
diff changeset
2033 } else if (cmd.cmd3 == 0x400) { // 画像を文字列として指定
223b71206888 Initial import
thib
parents:
diff changeset
2034 g.print_moji = cmd.Str(cmd.args[1]);
223b71206888 Initial import
thib
parents:
diff changeset
2035 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2036 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2037 } else if (cmd.cmd3 == 0x401) { // 画像を文字列として設定:文字の大きさなど
223b71206888 Initial import
thib
parents:
diff changeset
2038 /* args: size, xspace, yspace, vertical, color, shadow */
223b71206888 Initial import
thib
parents:
diff changeset
2039 /*
223b71206888 Initial import
thib
parents:
diff changeset
2040 args:17, 0,0,-1, 0,-1 DT in Tomoyo
223b71206888 Initial import
thib
parents:
diff changeset
2041 args:17, 0,0,-1,200,-1 Save/Load in Tomoyo
223b71206888 Initial import
thib
parents:
diff changeset
2042 args:20, 0,0, 0,255,-1 "──ありがとう…。" (勝平Ed付近)
223b71206888 Initial import
thib
parents:
diff changeset
2043 args:16,-1,0,99,255,-1 "やあ、久しぶり──…。" (同上,Save/Load Menu)
223b71206888 Initial import
thib
parents:
diff changeset
2044 args:26,-1,0,99, 0,255 Kuma in CLANNAD
223b71206888 Initial import
thib
parents:
diff changeset
2045 */
223b71206888 Initial import
thib
parents:
diff changeset
2046 g.print_size = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2047 /* 前景色を得る */
223b71206888 Initial import
thib
parents:
diff changeset
2048 int cr,cg,cb; char key[1024];
223b71206888 Initial import
thib
parents:
diff changeset
2049 sprintf(key, "#COLOR_TABLE.%03d", cmd.args[5].value);
223b71206888 Initial import
thib
parents:
diff changeset
2050 if (config.GetParam(key, 3, &cr, &cg, &cb)) { // color not found
223b71206888 Initial import
thib
parents:
diff changeset
2051 cr = cg = cb = 0;
223b71206888 Initial import
thib
parents:
diff changeset
2052 }
223b71206888 Initial import
thib
parents:
diff changeset
2053 g.print_r = cr;
223b71206888 Initial import
thib
parents:
diff changeset
2054 g.print_g = cg;
223b71206888 Initial import
thib
parents:
diff changeset
2055 g.print_b = cb;
223b71206888 Initial import
thib
parents:
diff changeset
2056 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2057 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2058 } else if (cmd.cmd3 == 0x408) { // set order
223b71206888 Initial import
thib
parents:
diff changeset
2059 int order = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2060 if (cmd.cmd1 == 1) order *= 1000; // order も 1000 倍する必要がある?
223b71206888 Initial import
thib
parents:
diff changeset
2061 g.order = order;
223b71206888 Initial import
thib
parents:
diff changeset
2062 ZMoveObj(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2063 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2064 } else if (cmd.cmd3 == 0x40a && cmd.cmd4 == 1) { // set surface geometry?
223b71206888 Initial import
thib
parents:
diff changeset
2065 // オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定
223b71206888 Initial import
thib
parents:
diff changeset
2066 int rx = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2067 int ry = cmd.args[2].value;
43
01aa5ddf7dc8 A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents: 26
diff changeset
2068 int x2 = cmd.args[3].value;
01aa5ddf7dc8 A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents: 26
diff changeset
2069 int y2 = cmd.args[4].value;
01aa5ddf7dc8 A lot of very minor improvements (deleted some unused variables, and other things like that...)
thib
parents: 26
diff changeset
2070 g.SetClipArea(rx, ry, x2, y2); //TODO: case when cmd.args.size() == 1
0
223b71206888 Initial import
thib
parents:
diff changeset
2071 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2072 } else if (cmd.cmd3 == 0x40d) { // set digit number
223b71206888 Initial import
thib
parents:
diff changeset
2073 g.dig_number = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2074 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2075 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2076 } else if (cmd.cmd3 == 0x40e) { // set digit option
223b71206888 Initial import
thib
parents:
diff changeset
2077 g.dig_digit = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2078 int attr = g.attr;
223b71206888 Initial import
thib
parents:
diff changeset
2079 attr &= ~(GrpObj::DIG_ZERO | GrpObj::DIG_SIGN | GrpObj::DIG_PACK);
223b71206888 Initial import
thib
parents:
diff changeset
2080 if (cmd.args[2].value) attr |= GrpObj::DIG_ZERO;
223b71206888 Initial import
thib
parents:
diff changeset
2081 if (cmd.args[3].value) attr |= GrpObj::DIG_SIGN;
223b71206888 Initial import
thib
parents:
diff changeset
2082 if (cmd.args[4].value) attr |= GrpObj::DIG_PACK;
223b71206888 Initial import
thib
parents:
diff changeset
2083 g.attr = GrpObj::Attribute(attr);
223b71206888 Initial import
thib
parents:
diff changeset
2084 g.SetUpdate();
223b71206888 Initial import
thib
parents:
diff changeset
2085 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2086 } else if (cmd.cmd3 == 0x40f) { /* set surface number */
223b71206888 Initial import
thib
parents:
diff changeset
2087 g.SetSurfaceNum(cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
2088 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2089 } else if (cmd.cmd3 == 0x416) { // オブジェクトの拡大率設定
223b71206888 Initial import
thib
parents:
diff changeset
2090 int zoom = (cmd.args[1].value + cmd.args[2].value)/2; // x,y 別に設定できるらしい
223b71206888 Initial import
thib
parents:
diff changeset
2091 zoom = zoom*256/100;
223b71206888 Initial import
thib
parents:
diff changeset
2092 g.SetZoomRotate(zoom, -1);
223b71206888 Initial import
thib
parents:
diff changeset
2093 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2094 } else if (cmd.cmd3 == 0x419) { // オブジェクトの回転設定
223b71206888 Initial import
thib
parents:
diff changeset
2095 int angle = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2096 angle /= 10;
223b71206888 Initial import
thib
parents:
diff changeset
2097 if (angle < 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2098 angle %= 360;
223b71206888 Initial import
thib
parents:
diff changeset
2099 angle += 360;
223b71206888 Initial import
thib
parents:
diff changeset
2100 }
223b71206888 Initial import
thib
parents:
diff changeset
2101 angle %= 360;
223b71206888 Initial import
thib
parents:
diff changeset
2102 g.SetZoomRotate(-1, angle);
223b71206888 Initial import
thib
parents:
diff changeset
2103 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2104 }
223b71206888 Initial import
thib
parents:
diff changeset
2105 if (cmd.cmd2 == 0x51 && (g.attr & GrpObj::UPDATE_ALL)) {
223b71206888 Initial import
thib
parents:
diff changeset
2106 SetObjChanged(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2107 }
223b71206888 Initial import
thib
parents:
diff changeset
2108 } else if (cmd.cmd2 == 0x54) {
223b71206888 Initial import
thib
parents:
diff changeset
2109 /* 座標取得 */
223b71206888 Initial import
thib
parents:
diff changeset
2110 if (cmd.cmd3 == 0x3e8) {
223b71206888 Initial import
thib
parents:
diff changeset
2111 GrpObj& obj = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
2112 VarInfo arg1 = cmd.args[1];
223b71206888 Initial import
thib
parents:
diff changeset
2113 VarInfo arg2 = cmd.args[2];
223b71206888 Initial import
thib
parents:
diff changeset
2114 int x0, y0;
223b71206888 Initial import
thib
parents:
diff changeset
2115 obj.GetPos(0,x0, y0);
223b71206888 Initial import
thib
parents:
diff changeset
2116 cmd.SetFlagvar(arg1, x0);
223b71206888 Initial import
thib
parents:
diff changeset
2117 cmd.SetFlagvar(arg2, y0);
223b71206888 Initial import
thib
parents:
diff changeset
2118 } else if (cmd.cmd3 == 0x44c) {
223b71206888 Initial import
thib
parents:
diff changeset
2119 int w, h;
223b71206888 Initial import
thib
parents:
diff changeset
2120 GrpObj& obj = grpobj[cmd.args[0].value];
223b71206888 Initial import
thib
parents:
diff changeset
2121 obj.GetSrcGeom(w, h);
223b71206888 Initial import
thib
parents:
diff changeset
2122 VarInfo arg1 = cmd.args[1];
223b71206888 Initial import
thib
parents:
diff changeset
2123 VarInfo arg2 = cmd.args[2];
223b71206888 Initial import
thib
parents:
diff changeset
2124 cmd.SetFlagvar(arg1, w);
223b71206888 Initial import
thib
parents:
diff changeset
2125 cmd.SetFlagvar(arg2, h);
223b71206888 Initial import
thib
parents:
diff changeset
2126 }
223b71206888 Initial import
thib
parents:
diff changeset
2127 }
223b71206888 Initial import
thib
parents:
diff changeset
2128 // セーブ用にコマンドを元に戻す
223b71206888 Initial import
thib
parents:
diff changeset
2129 if (cmd.args.size() != 0 && (cmd.cmd_type == CMD_SAVECMDGRP || cmd.cmd_type == CMD_SAVECMDGRP_ONCE)) {
223b71206888 Initial import
thib
parents:
diff changeset
2130 if (cmd.cmd1 == 1) cmd.args[0].value /= 1000;
223b71206888 Initial import
thib
parents:
diff changeset
2131 else if (cmd.cmd1 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
2132 vector<VarInfo> args = cmd.args;
223b71206888 Initial import
thib
parents:
diff changeset
2133 int value = args[0].value;
223b71206888 Initial import
thib
parents:
diff changeset
2134 cmd.args.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2135 args[0].value = value / 1000;
223b71206888 Initial import
thib
parents:
diff changeset
2136 cmd.args.push_back(args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
2137 args[0].value = value % 1000 - 500;
223b71206888 Initial import
thib
parents:
diff changeset
2138 cmd.args.push_back(args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
2139 cmd.args.insert(cmd.args.end(), args.begin()+1, args.end());
223b71206888 Initial import
thib
parents:
diff changeset
2140 }
223b71206888 Initial import
thib
parents:
diff changeset
2141 }
223b71206888 Initial import
thib
parents:
diff changeset
2142 }
223b71206888 Initial import
thib
parents:
diff changeset
2143 #endif
223b71206888 Initial import
thib
parents:
diff changeset
2144 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1f) { // 本来は grpstack clear らしい
223b71206888 Initial import
thib
parents:
diff changeset
2145 RefreshObj();
223b71206888 Initial import
thib
parents:
diff changeset
2146 // Princess Bride の中途 Staff roll
223b71206888 Initial import
thib
parents:
diff changeset
2147 // このタイミングで描画するのが都合がいいので、
223b71206888 Initial import
thib
parents:
diff changeset
2148 //シナリオループを抜けて描画を起動
223b71206888 Initial import
thib
parents:
diff changeset
2149 cmd.cmd_type = CMD_WAITFRAMEUPDATE;
223b71206888 Initial import
thib
parents:
diff changeset
2150 }
223b71206888 Initial import
thib
parents:
diff changeset
2151
223b71206888 Initial import
thib
parents:
diff changeset
2152 /* XXX : GiGiGi */
223b71206888 Initial import
thib
parents:
diff changeset
2153 /* 122 : 0x23 - cmd 01-04:0924:00[ 0] : V<sys> にBGM再生モードを返す (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2154 ** 256 : 0x23 - cmd 01-04:091a:00[ 0] : V<sys> にBGM音量を返す (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2155 ** 278 : 0x23 - cmd 01-04:0926:00[ 0] : V<sys> にEff再生モードを返す (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2156 ** 412 : 0x23 - cmd 01-04:091c:00[ 0] : V<sys> にEff音量を返す (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2157 ** 434 : 0x23 - cmd 01-04:0927:00[ 0] : V<sys> にSE 再生モードを返す (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2158 ** 568 : 0x23 - cmd 01-04:091d:00[ 0] : V<sys> にSE 音量を返す (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2159
223b71206888 Initial import
thib
parents:
diff changeset
2160 ** 122 : 0x23 - cmd 01-04:08c0:00[ 0] : V<sys> にBGM再生モードを設定 (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2161 ** 256 : 0x23 - cmd 01-04:08b6:00[ 0] : V<sys> にBGM音量を設定 (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2162 ** 278 : 0x23 - cmd 01-04:08c2:00[ 0] : V<sys> にEff再生モードを設定 (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2163 ** 412 : 0x23 - cmd 01-04:08b8:00[ 0] : V<sys> にEff音量を設定 (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2164 ** 434 : 0x23 - cmd 01-04:08c3:00[ 0] : V<sys> にSE 再生モードを設定 (0/1)
223b71206888 Initial import
thib
parents:
diff changeset
2165 ** 568 : 0x23 - cmd 01-04:08b9:00[ 0] : V<sys> にSE 音量を設定 (0-255?)
223b71206888 Initial import
thib
parents:
diff changeset
2166 */
223b71206888 Initial import
thib
parents:
diff changeset
2167 // 本来は音楽関連のコマンド
223b71206888 Initial import
thib
parents:
diff changeset
2168 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x14) {
223b71206888 Initial import
thib
parents:
diff changeset
2169 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2170 eprintf("play bgm %s\n",cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
2171 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000);
223b71206888 Initial import
thib
parents:
diff changeset
2172 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2173 }
223b71206888 Initial import
thib
parents:
diff changeset
2174 if (cmd.cmd3 == 2 && (cmd.cmd4 == 2 || cmd.cmd4 == 0) ) { /* ??? : ことみシナリオラストの音楽再生 */
223b71206888 Initial import
thib
parents:
diff changeset
2175 eprintf("play bgm %s\n",cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
2176 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 1);
223b71206888 Initial import
thib
parents:
diff changeset
2177 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2178 }
223b71206888 Initial import
thib
parents:
diff changeset
2179 if (cmd.cmd3 == 0 && cmd.cmd4 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
2180 eprintf("fade bgm %d? and play bgm %s; %d\n",cmd.args[1].value, cmd.Str(cmd.args[0]), cmd.args[2].value);
223b71206888 Initial import
thib
parents:
diff changeset
2181 // music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000, cmd.args[2].value);
223b71206888 Initial import
thib
parents:
diff changeset
2182 music.PlayCDROM( (char*)cmd.Str(cmd.args[0]), 10000);
223b71206888 Initial import
thib
parents:
diff changeset
2183 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2184 }
223b71206888 Initial import
thib
parents:
diff changeset
2185 if ( (cmd.cmd3 == 5 || cmd.cmd3 == 0x69) && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2186 if (cmd.cmd3 == 5) {
223b71206888 Initial import
thib
parents:
diff changeset
2187 music.StopCDROM(0);
223b71206888 Initial import
thib
parents:
diff changeset
2188 eprintf("stop bgm\n");
223b71206888 Initial import
thib
parents:
diff changeset
2189 } else {
223b71206888 Initial import
thib
parents:
diff changeset
2190 music.StopCDROM(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2191 eprintf("fade bgm %d\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2192 }
223b71206888 Initial import
thib
parents:
diff changeset
2193 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2194 }
223b71206888 Initial import
thib
parents:
diff changeset
2195 }
223b71206888 Initial import
thib
parents:
diff changeset
2196 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x15) {
10
dac3a35aeff6 Plays more Sound Effects
thib
parents: 8
diff changeset
2197 if ((cmd.cmd3 == 2) || (cmd.cmd3 == 0 && (cmd.cmd4 == 1 || cmd.cmd4 == 2)) || (cmd.cmd3 == 0 && cmd.cmd4 == 0)) {
11
28a4f6bde8c8 Oops...
thib
parents: 10
diff changeset
2198 eprintf("play SE %s\n",cmd.Str(cmd.args[0]));
0
223b71206888 Initial import
thib
parents:
diff changeset
2199 if (cmd.cmd3 == 2) {
223b71206888 Initial import
thib
parents:
diff changeset
2200 music.PlaySE(cmd.Str(cmd.args[0]),1);
223b71206888 Initial import
thib
parents:
diff changeset
2201 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2202 } else {
223b71206888 Initial import
thib
parents:
diff changeset
2203 music.PlaySE(cmd.Str(cmd.args[0]));
223b71206888 Initial import
thib
parents:
diff changeset
2204 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2205 }
223b71206888 Initial import
thib
parents:
diff changeset
2206 } else if (cmd.cmd3 == 5) {
223b71206888 Initial import
thib
parents:
diff changeset
2207 eprintf("Stop SE\n");
223b71206888 Initial import
thib
parents:
diff changeset
2208 music.StopSE();
223b71206888 Initial import
thib
parents:
diff changeset
2209 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2210 } else if (cmd.cmd3 == 0x69) {
223b71206888 Initial import
thib
parents:
diff changeset
2211 eprintf("Stop SE with fade %d\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2212 music.StopSE(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2213 cmd.cmd_type = CMD_SAVECMD_ONCE;
223b71206888 Initial import
thib
parents:
diff changeset
2214 }
223b71206888 Initial import
thib
parents:
diff changeset
2215 }
223b71206888 Initial import
thib
parents:
diff changeset
2216 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && (cmd.cmd3 == 0x4bb || cmd.cmd3 == 0x4bc) ) {
223b71206888 Initial import
thib
parents:
diff changeset
2217 // 音楽を待ってみる(絶対に違うが)。本来、04-803 に対応してなにかの終わりをwaitするっぽい(風子/智代Ed付近)
223b71206888 Initial import
thib
parents:
diff changeset
2218 // EnableSyscom らしいが、よくわからない (rldev)
223b71206888 Initial import
thib
parents:
diff changeset
2219 // if (!music.IsStopSE()) status = WAIT_SE;
223b71206888 Initial import
thib
parents:
diff changeset
2220 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2221 }
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2222
0
223b71206888 Initial import
thib
parents:
diff changeset
2223 // 音楽モードで音量を上げるためのコマンド (SetBgmVolume)
223b71206888 Initial import
thib
parents:
diff changeset
2224 // とりあえず未実装
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2225 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && cmd.cmd3 >= 0x8b6 && cmd.cmd3 <= 0x8b9) { // Set{Bgm,Koe,PCM,Se}VolMod
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2226 music.volmod[cmd.cmd3-0x8b6] = cmd.args[0].value;
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2227 config.SetParam("#VOLMOD", 4, music.volmod[0], music.volmod[1], music.volmod[2], music.volmod[3]);
0
223b71206888 Initial import
thib
parents:
diff changeset
2228 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2229 }
26
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2230 if (cmd.cmd1 == 1 && cmd.cmd2 == 4 && cmd.cmd3 >= 0x91a && cmd.cmd3 <= 0x91d) { // Get{Bgm,Koe,PCM,Se}VolMod
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2231 cmd.SetSysvar(music.volmod[cmd.cmd3-0x91a]);
f45da03ca631 * Corrected --disable-vorbis in configure.ac
thib
parents: 20
diff changeset
2232 }
0
223b71206888 Initial import
thib
parents:
diff changeset
2233
223b71206888 Initial import
thib
parents:
diff changeset
2234 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x16) {
223b71206888 Initial import
thib
parents:
diff changeset
2235 if (cmd.cmd3 == 0 && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2236 eprintf("play SE %d\n",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2237 music.PlaySE(cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2238 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2239 }
223b71206888 Initial import
thib
parents:
diff changeset
2240 }
223b71206888 Initial import
thib
parents:
diff changeset
2241 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x17) {
223b71206888 Initial import
thib
parents:
diff changeset
2242 if (cmd.cmd3 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2243 eprintf("play koe %d",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2244 if (cmd.cmd4 == 1) {
223b71206888 Initial import
thib
parents:
diff changeset
2245 eprintf(", para? %d",cmd.args[1].value);
223b71206888 Initial import
thib
parents:
diff changeset
2246 }
223b71206888 Initial import
thib
parents:
diff changeset
2247 eprintf("\n");
223b71206888 Initial import
thib
parents:
diff changeset
2248 char buf[1024]; sprintf(buf, "%d",cmd.args[0].value);
223b71206888 Initial import
thib
parents:
diff changeset
2249 if ( !(skip_mode & SKIP_TEXT)) music.PlayKoe(buf);
223b71206888 Initial import
thib
parents:
diff changeset
2250 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2251 }
223b71206888 Initial import
thib
parents:
diff changeset
2252 }
223b71206888 Initial import
thib
parents:
diff changeset
2253 if (cmd.cmd1 == 1 && cmd.cmd2 == 0x1a) {
223b71206888 Initial import
thib
parents:
diff changeset
2254 if ( (cmd.cmd3 == 0x14 || cmd.cmd3 == 1) && cmd.cmd4 == 0) {
223b71206888 Initial import
thib
parents:
diff changeset
2255 const char* str = cmd.Str(cmd.args[0]);
223b71206888 Initial import
thib
parents:
diff changeset
2256 int x = cmd.args[1].value;
223b71206888 Initial import
thib
parents:
diff changeset
2257 int y = cmd.args[2].value;
223b71206888 Initial import
thib
parents:
diff changeset
2258 int x2 = cmd.args[3].value;
223b71206888 Initial import
thib
parents:
diff changeset
2259 int y2 = cmd.args[4].value;
223b71206888 Initial import
thib
parents:
diff changeset
2260 eprintf("play movie ; name %s pos %d,%d - %d,%d\n",str,x,y,x2,y2);
223b71206888 Initial import
thib
parents:
diff changeset
2261 music.PlayMovie(str, x, y, x2, y2,1);
223b71206888 Initial import
thib
parents:
diff changeset
2262 status = WAIT_MOVIE;
223b71206888 Initial import
thib
parents:
diff changeset
2263 event.RegisterGlobalPressFunc(&Pressed, (void*)this);
223b71206888 Initial import
thib
parents:
diff changeset
2264 cmd.clear();
223b71206888 Initial import
thib
parents:
diff changeset
2265 }
223b71206888 Initial import
thib
parents:
diff changeset
2266 }
223b71206888 Initial import
thib
parents:
diff changeset
2267 return;
223b71206888 Initial import
thib
parents:
diff changeset
2268 }
223b71206888 Initial import
thib
parents:
diff changeset
2269
223b71206888 Initial import
thib
parents:
diff changeset
2270
223b71206888 Initial import
thib
parents:
diff changeset
2271 /********************************************************
223b71206888 Initial import
thib
parents:
diff changeset
2272 **
223b71206888 Initial import
thib
parents:
diff changeset
2273 ** class Grp
223b71206888 Initial import
thib
parents:
diff changeset
2274 */
223b71206888 Initial import
thib
parents:
diff changeset
2275
223b71206888 Initial import
thib
parents:
diff changeset
2276 Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
2277 pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config);
223b71206888 Initial import
thib
parents:
diff changeset
2278 };
223b71206888 Initial import
thib
parents:
diff changeset
2279 Grp::~Grp() {
223b71206888 Initial import
thib
parents:
diff changeset
2280 delete pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
2281 }
223b71206888 Initial import
thib
parents:
diff changeset
2282
223b71206888 Initial import
thib
parents:
diff changeset
2283 bool Grp::Wait(unsigned int current_time, Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
2284 return pimpl->Wait(current_time, cmd);
223b71206888 Initial import
thib
parents:
diff changeset
2285 }
223b71206888 Initial import
thib
parents:
diff changeset
2286 void Grp::Exec(Cmd& cmd) {
223b71206888 Initial import
thib
parents:
diff changeset
2287 pimpl->Exec(cmd);
223b71206888 Initial import
thib
parents:
diff changeset
2288 }
223b71206888 Initial import
thib
parents:
diff changeset
2289 void Grp::SetSkipMode(SkipMode mode) {
223b71206888 Initial import
thib
parents:
diff changeset
2290 pimpl->SetSkipMode(mode);
223b71206888 Initial import
thib
parents:
diff changeset
2291 }
223b71206888 Initial import
thib
parents:
diff changeset
2292 void Grp::InitSel(AyuSysConfig& config) {
223b71206888 Initial import
thib
parents:
diff changeset
2293 pimpl->InitSel(config);
223b71206888 Initial import
thib
parents:
diff changeset
2294 }
223b71206888 Initial import
thib
parents:
diff changeset
2295 void Grp::Save(std::string& str) {
223b71206888 Initial import
thib
parents:
diff changeset
2296 pimpl->Save(str);
223b71206888 Initial import
thib
parents:
diff changeset
2297 }
223b71206888 Initial import
thib
parents:
diff changeset
2298
223b71206888 Initial import
thib
parents:
diff changeset
2299 void Grp::Load(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
2300 pimpl->Load(str);
223b71206888 Initial import
thib
parents:
diff changeset
2301 }
223b71206888 Initial import
thib
parents:
diff changeset
2302 void Grp::SaveSys(std::string& str) {
223b71206888 Initial import
thib
parents:
diff changeset
2303 pimpl->SaveSys(str);
223b71206888 Initial import
thib
parents:
diff changeset
2304 }
223b71206888 Initial import
thib
parents:
diff changeset
2305
223b71206888 Initial import
thib
parents:
diff changeset
2306 void Grp::LoadSys(const char* str) {
223b71206888 Initial import
thib
parents:
diff changeset
2307 pimpl->LoadSys(str);
223b71206888 Initial import
thib
parents:
diff changeset
2308 }