Mercurial > otakunoraifu
annotate scn2k/scn2k.h @ 55:f1a27ee7e03c
* started the same changes on scn2k_text.cc
* handle opcodes childObj*. In fact, it was handled (in a strange way, but it worked) before the previous changeset
author | thib |
---|---|
date | Wed, 22 Apr 2009 15:01:42 +0000 |
parents | d7cde171a1de |
children | c7bcc0ec2267 |
rev | line source |
---|---|
33 | 1 /* |
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno | |
3 * All rights reserved. | |
4 * | |
5 * Redistribution and use in source and binary forms, with or without | |
6 * modification, are permitted provided that the following conditions | |
7 * are met: | |
8 * 1. Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * 2. Redistributions in binary form must reproduce the above copyright | |
11 * notice, this list of conditions and the following disclaimer in the | |
12 * documentation and/or other materials provided with the distribution. | |
13 * 3. The name of the author may not be used to endorse or promote products | |
14 * derived from this software without specific prior written permission. | |
15 * | |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 */ | |
27 | |
0 | 28 #ifndef __SCN2k_H__ |
29 #define __SCN2k_H__ | |
30 | |
52 | 31 #include <vector> |
32 #include <string> | |
33 #include <map> | |
34 #include <set> | |
0 | 35 |
36 /* | |
37 namespace Widget { | |
38 class Text; | |
39 class Button; | |
40 class TextButton; | |
41 class Label; | |
42 class Dialog; | |
43 class AnmTime; | |
44 } | |
45 */ | |
52 | 46 class WidText; |
47 class WidButton; | |
48 class WidTextButton; | |
49 class WidLabel; | |
50 class WidDialog; | |
51 class WidAnmTime; | |
52 | |
0 | 53 namespace Event { |
54 class Container; | |
55 } | |
52 | 56 |
0 | 57 class PicBase; |
58 class PicContainer; | |
59 class AyuSysConfig; | |
60 class Surface; | |
61 | |
62 void dprintf(const char* fmt, ...); | |
63 void eprintf(const char* fmt, ...); | |
64 | |
65 struct VarInfo { | |
66 #define TYPE_NONSYSVARMAX 5 | |
67 #define TYPE_VARMAX 9 | |
68 #define TYPE_VARLOCSTR 10 | |
69 #define TYPE_VARSYSSTR 12 | |
70 #define TYPE_VARSTR 18 | |
71 #define TYPE_STR 58 | |
72 #define TYPE_VAL 68 | |
73 #define TYPE_SYS 0xc8 | |
74 #define TYPE_END 0x7f | |
75 | |
76 #define TYPE_SYS_SYS 0 | |
77 #define TYPE_SYS_SKIPMODE 1 | |
78 int type; | |
79 int number; | |
80 int value; | |
81 VarInfo() { type = TYPE_VAL; value = 0;} | |
82 VarInfo(int n) { type = TYPE_VAL; value = n;} | |
83 VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;} | |
84 }; | |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
85 |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
86 |
0 | 87 class Flags { |
88 /* flag: | |
89 ** type 0-5 : ローカル整数、各2000個 | |
90 ** type 6, 25 : グローバル整数、2000個 | |
91 ** type 10,11: ローカル整数??、各2000個 | |
92 ** type 12 : グローバル文字列、2000個 (今は無視しても良いが) | |
93 ** type 18 : ローカル文字列、2000個 | |
94 ** type 25: システム変数(マウス座標など?) 1000 個? | |
95 ** type 26-32, 51 : 1-bit access to 0-6, 25 | |
96 ** type 52-58, 77 : 2-bit access to 0-6, 25 | |
97 ** type 78-84, 103 : 4-bit access to 0-6, 25 | |
98 ** type 104-110, 129 : 8-bit access to 0-6, 25 | |
99 */ | |
52 | 100 private: |
101 typedef unsigned int uint; | |
102 int sys; | |
103 int var[TYPE_VARMAX+1][2000]; | |
104 std::string str[2000]; | |
105 std::string sys_str[2000]; | |
106 std::string loc_str[3]; | |
107 public: | |
108 Flags(void); | |
109 int operator () () const; | |
110 int operator () (VarInfo info) const; | |
111 void Str(int type, unsigned int number, char* buf, int sz) const; | |
112 std::string Str(int type, unsigned int number) const; | |
113 std::set<int> cgm_data; | |
0 | 114 |
52 | 115 bool IsInt(int type) const; |
116 int MaxIndex(int type) const; | |
0 | 117 |
52 | 118 void Set(VarInfo info, int value); |
119 int Get(int type, int number) const; | |
120 void SetSys(int value); | |
121 void SetStr(VarInfo info, std::string val); | |
0 | 122 |
52 | 123 bool Exec(class Cmd& cmd); |
0 | 124 |
52 | 125 void Save(std::string& str); |
126 void Load(const char* str); | |
0 | 127 |
52 | 128 void SaveSys(std::string& str); |
129 void LoadSys(const char* str); | |
0 | 130 }; |
131 | |
132 /* commands */ | |
133 #define STRHEAP_SIZE 10000 | |
134 enum Cmdtype { | |
135 CMD_NOP, CMD_FLAGS, CMD_JMP, CMD_TEXT, CMD_OTHER, CMD_SYSVAR, | |
136 CMD_TEXTEND, | |
137 CMD_SAVECMDGRP, CMD_SAVECMDGRP_START, CMD_SAVECMDGRP_ONCE, CMD_SAVECMD_ONCE, CMD_WAITFRAMEUPDATE,CMD_SAVEPOINT, CMD_ROLLBACKPOINT, | |
138 CMD_SAVEREQ, CMD_SAVE, | |
139 CMD_LOADREQ, CMD_LOAD, | |
140 CMD_MENUREQ, | |
141 CMD_BACKLOGREQ, CMD_BACKLOGREQ_FWD, | |
142 CMD_END}; | |
52 | 143 |
0 | 144 struct CmdSimplified { // Cmd 保存用 |
145 int type, cmd1, cmd2, cmd3, cmd4, argc; | |
146 char* args; | |
147 void Save(std::string& save); | |
148 void Load(const char* save, char*& args_buffer); | |
149 void copy(const CmdSimplified& from, char*& args_buffer); | |
150 }; | |
52 | 151 |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
152 class SimpleCmd { |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
153 public: |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
154 SimpleCmd(int a, int b, int c); |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
155 SimpleCmd(); |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
156 |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
157 bool operator==(const SimpleCmd& cmd) const; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
158 bool operator<(const SimpleCmd& cmd) const; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
159 |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
160 public: |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
161 int cmd1, cmd2, cmd3; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
162 }; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
163 |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
164 class Cmd : public SimpleCmd{ |
52 | 165 public: |
166 Cmdtype cmd_type; | |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
167 int cmd4; |
52 | 168 int argc; |
169 int pos, scn; | |
170 const char* rawdata; | |
171 char cmdstr[1024]; | |
172 std::vector<VarInfo> args; | |
0 | 173 |
52 | 174 private: |
175 const Flags& flags; | |
176 bool errorflag; | |
177 int system_version; | |
0 | 178 |
52 | 179 int GetArgs(const char*& d); |
180 int GetArgsSpecial(int normal_args,const char*& d); | |
181 void GetSelection(const char*& d); | |
182 int GetSwitch(const char*& d); | |
183 int GetSimpleSwitch(const char*& d); | |
184 int GetExpression(const char*& d, struct VarInfo* info = 0); | |
185 int GetExpressionCond(const char*& d); | |
186 int GetLeftToken(const char*& d, struct VarInfo& info); | |
187 int GetString(const char*& d); | |
188 int CopyString(const char* d); | |
189 int StrVar(int type, int number); | |
190 static char strtype[256]; | |
191 static int StrType(const char* d) { return strtype[*(unsigned const char*)d];} | |
192 | |
193 public: | |
194 const char* Str(const VarInfo& info) const; | |
195 int AddStr(char* s); | |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
196 |
52 | 197 private: |
198 char strheap[STRHEAP_SIZE]; | |
199 int strend; | |
200 void SetError(void) { errorflag = true;} | |
201 void ResetString(void) { | |
202 strend = 0; | |
203 } | |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
204 |
52 | 205 public: |
206 void GetCmd(Flags& f, const char*& d); | |
207 void SetSysvar(int n, int v); | |
208 void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); } | |
209 void SetFlagvar(VarInfo info, int v); | |
210 void SetStrvar(VarInfo info, const std::string& s); | |
211 bool IsError() { return errorflag;} | |
212 void clear(void); | |
213 virtual const char * CmdDescr(int, int, int, int) { return "Not supported"; } | |
214 Cmd(const Flags& f, int _sys_ver); | |
215 void read(const CmdSimplified& cmd); | |
216 void write(CmdSimplified& cmd, char*& args_buffer) const; | |
0 | 217 }; |
218 | |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
219 class CommandHandler { |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
220 public: |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
221 typedef void (CommandHandler::*CmdImpl)(Cmd& cmd); |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
222 typedef struct { |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
223 const char* descr; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
224 CmdImpl function; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
225 } CommandInfo; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
226 void RegisterCommand(int cmd1, int cmd2, int cmd3, const char* descr, CmdImpl func); |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
227 bool Exec(Cmd& cmd); |
55 | 228 void PrintCmd(Cmd& cmd); |
54
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
229 |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
230 private: |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
231 typedef std::map<SimpleCmd, CommandInfo> CommandMap; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
232 CommandMap command_map; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
233 }; |
d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
thib
parents:
53
diff
changeset
|
234 |
52 | 235 enum SkipMode { |
236 SKIP_NO=0, SKIP_TEXT=1, SKIP_GRP_FAST=16, SKIP_GRP_NOEFFEC=32, | |
237 SKIP_GRP_NODRAW=64, SKIPEND_TEXT=256, SKIPEND_KEY=512, SKIP_IN_MENU=1024 | |
238 }; | |
0 | 239 |
52 | 240 #include "font/text.h" |
0 | 241 |
242 struct BacklogItem { | |
243 enum {SaveSelect = -2}; | |
244 int scn, pos; | |
245 int koe; | |
246 std::string face; | |
247 struct TextStream text; | |
248 BacklogItem(void); | |
249 void Clear(void); | |
250 void AddTextPos(Cmd&); | |
251 void DeleteTextPos(); | |
252 void SetSavepos(int pos); | |
253 BacklogItem& operator =(const BacklogItem&); | |
254 }; | |
52 | 255 |
0 | 256 class Text { |
52 | 257 private: |
258 class TextImpl* pimpl; | |
259 public: | |
260 std::vector<BacklogItem> backlog; | |
261 BacklogItem backlog_item; | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
262 Text(Event::Container& _event, PicContainer& _parent); |
52 | 263 ~Text(); |
264 void InitWindow(void); | |
265 void Exec(Cmd& cmd); | |
266 bool Wait(unsigned int current_time, Cmd& cmd); | |
267 void SetSkipMode(SkipMode mode); | |
268 void hide(void); | |
269 void show(void); | |
270 void show(int num); | |
271 void Save(std::string& str, bool rollback_save); | |
272 void Load(const char* str); | |
273 void DrawBacklog(BacklogItem& item, Cmd& cmd); | |
0 | 274 }; |
275 | |
52 | 276 #include "../window/rect.h" |
0 | 277 |
278 class Grp { | |
52 | 279 private: |
280 class GrpImpl* pimpl; | |
281 public: | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
282 Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data); |
52 | 283 ~Grp(); |
284 bool Wait(unsigned int current_time, Cmd& cmd); | |
285 void Exec(Cmd& cmd); | |
286 void SetSkipMode(SkipMode mode); | |
53
ddbcbd000206
* MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents:
52
diff
changeset
|
287 void InitSel(void); |
52 | 288 void Save(std::string& str); |
289 void Load(const char* str); | |
290 void SaveSys(std::string& str); | |
291 void LoadSys(const char* str); | |
0 | 292 }; |
293 | |
294 void dprintf(const char* fmt, ...); // debug 用 | |
295 void eprintf(const char* fmt, ...); // コマンド実行(XXXexec)追跡用 | |
296 #endif |