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 };
|
|
85 class Flags {
|
|
86 /* flag:
|
|
87 ** type 0-5 : ローカル整数、各2000個
|
|
88 ** type 6, 25 : グローバル整数、2000個
|
|
89 ** type 10,11: ローカル整数??、各2000個
|
|
90 ** type 12 : グローバル文字列、2000個 (今は無視しても良いが)
|
|
91 ** type 18 : ローカル文字列、2000個
|
|
92 ** type 25: システム変数(マウス座標など?) 1000 個?
|
|
93 ** type 26-32, 51 : 1-bit access to 0-6, 25
|
|
94 ** type 52-58, 77 : 2-bit access to 0-6, 25
|
|
95 ** type 78-84, 103 : 4-bit access to 0-6, 25
|
|
96 ** type 104-110, 129 : 8-bit access to 0-6, 25
|
|
97 */
|
52
|
98 private:
|
|
99 typedef unsigned int uint;
|
|
100 int sys;
|
|
101 int var[TYPE_VARMAX+1][2000];
|
|
102 std::string str[2000];
|
|
103 std::string sys_str[2000];
|
|
104 std::string loc_str[3];
|
|
105 public:
|
|
106 Flags(void);
|
|
107 int operator () () const;
|
|
108 int operator () (VarInfo info) const;
|
|
109 void Str(int type, unsigned int number, char* buf, int sz) const;
|
|
110 std::string Str(int type, unsigned int number) const;
|
|
111 std::set<int> cgm_data;
|
0
|
112
|
52
|
113 bool IsInt(int type) const;
|
|
114 int MaxIndex(int type) const;
|
0
|
115
|
52
|
116 void Set(VarInfo info, int value);
|
|
117 int Get(int type, int number) const;
|
|
118 void SetSys(int value);
|
|
119 void SetStr(VarInfo info, std::string val);
|
0
|
120
|
52
|
121 bool Exec(class Cmd& cmd);
|
0
|
122
|
52
|
123 void Save(std::string& str);
|
|
124 void Load(const char* str);
|
0
|
125
|
52
|
126 void SaveSys(std::string& str);
|
|
127 void LoadSys(const char* str);
|
0
|
128 };
|
|
129
|
|
130 /* commands */
|
|
131 #define STRHEAP_SIZE 10000
|
|
132 enum Cmdtype {
|
|
133 CMD_NOP, CMD_FLAGS, CMD_JMP, CMD_TEXT, CMD_OTHER, CMD_SYSVAR,
|
|
134 CMD_TEXTEND,
|
|
135 CMD_SAVECMDGRP, CMD_SAVECMDGRP_START, CMD_SAVECMDGRP_ONCE, CMD_SAVECMD_ONCE, CMD_WAITFRAMEUPDATE,CMD_SAVEPOINT, CMD_ROLLBACKPOINT,
|
|
136 CMD_SAVEREQ, CMD_SAVE,
|
|
137 CMD_LOADREQ, CMD_LOAD,
|
|
138 CMD_MENUREQ,
|
|
139 CMD_BACKLOGREQ, CMD_BACKLOGREQ_FWD,
|
|
140 CMD_END};
|
52
|
141
|
0
|
142 struct CmdSimplified { // Cmd 保存用
|
|
143 int type, cmd1, cmd2, cmd3, cmd4, argc;
|
|
144 char* args;
|
|
145 void Save(std::string& save);
|
|
146 void Load(const char* save, char*& args_buffer);
|
|
147 void copy(const CmdSimplified& from, char*& args_buffer);
|
|
148 };
|
52
|
149
|
0
|
150 class Cmd {
|
52
|
151 public:
|
|
152 Cmdtype cmd_type;
|
|
153 int cmd1, cmd2, cmd3, cmd4;
|
|
154 int argc;
|
|
155 int pos, scn;
|
|
156 const char* rawdata;
|
|
157 char cmdstr[1024];
|
|
158 std::vector<VarInfo> args;
|
0
|
159
|
52
|
160 private:
|
|
161 const Flags& flags;
|
|
162 bool errorflag;
|
|
163 int system_version;
|
0
|
164
|
52
|
165 int GetArgs(const char*& d);
|
|
166 int GetArgsSpecial(int normal_args,const char*& d);
|
|
167 void GetSelection(const char*& d);
|
|
168 int GetSwitch(const char*& d);
|
|
169 int GetSimpleSwitch(const char*& d);
|
|
170 int GetExpression(const char*& d, struct VarInfo* info = 0);
|
|
171 int GetExpressionCond(const char*& d);
|
|
172 int GetLeftToken(const char*& d, struct VarInfo& info);
|
|
173 int GetString(const char*& d);
|
|
174 int CopyString(const char* d);
|
|
175 int StrVar(int type, int number);
|
|
176 static char strtype[256];
|
|
177 static int StrType(const char* d) { return strtype[*(unsigned const char*)d];}
|
|
178
|
|
179 public:
|
|
180 const char* Str(const VarInfo& info) const;
|
|
181 int AddStr(char* s);
|
|
182 private:
|
|
183 char strheap[STRHEAP_SIZE];
|
|
184 int strend;
|
|
185 void SetError(void) { errorflag = true;}
|
|
186 void ResetString(void) {
|
|
187 strend = 0;
|
|
188 }
|
|
189 public:
|
|
190 void GetCmd(Flags& f, const char*& d);
|
|
191 void SetSysvar(int n, int v);
|
|
192 void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); }
|
|
193 void SetFlagvar(VarInfo info, int v);
|
|
194 void SetStrvar(VarInfo info, const std::string& s);
|
|
195 bool IsError() { return errorflag;}
|
|
196 void clear(void);
|
|
197 virtual const char * CmdDescr(int, int, int, int) { return "Not supported"; }
|
|
198 Cmd(const Flags& f, int _sys_ver);
|
|
199 void read(const CmdSimplified& cmd);
|
|
200 void write(CmdSimplified& cmd, char*& args_buffer) const;
|
0
|
201 };
|
|
202
|
52
|
203 enum SkipMode {
|
|
204 SKIP_NO=0, SKIP_TEXT=1, SKIP_GRP_FAST=16, SKIP_GRP_NOEFFEC=32,
|
|
205 SKIP_GRP_NODRAW=64, SKIPEND_TEXT=256, SKIPEND_KEY=512, SKIP_IN_MENU=1024
|
|
206 };
|
0
|
207
|
52
|
208 #include "font/text.h"
|
0
|
209
|
|
210 struct BacklogItem {
|
|
211 enum {SaveSelect = -2};
|
|
212 int scn, pos;
|
|
213 int koe;
|
|
214 std::string face;
|
|
215 struct TextStream text;
|
|
216 BacklogItem(void);
|
|
217 void Clear(void);
|
|
218 void AddTextPos(Cmd&);
|
|
219 void DeleteTextPos();
|
|
220 void SetSavepos(int pos);
|
|
221 BacklogItem& operator =(const BacklogItem&);
|
|
222 };
|
52
|
223
|
0
|
224 class Text {
|
52
|
225 private:
|
|
226 class TextImpl* pimpl;
|
|
227 public:
|
|
228 std::vector<BacklogItem> backlog;
|
|
229 BacklogItem backlog_item;
|
|
230 Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config);
|
|
231 ~Text();
|
|
232 void InitWindow(void);
|
|
233 void Exec(Cmd& cmd);
|
|
234 bool Wait(unsigned int current_time, Cmd& cmd);
|
|
235 void SetSkipMode(SkipMode mode);
|
|
236 void hide(void);
|
|
237 void show(void);
|
|
238 void show(int num);
|
|
239 void Save(std::string& str, bool rollback_save);
|
|
240 void Load(const char* str);
|
|
241 void DrawBacklog(BacklogItem& item, Cmd& cmd);
|
0
|
242 };
|
|
243
|
52
|
244 #include "../window/rect.h"
|
0
|
245
|
|
246 class Grp {
|
52
|
247 private:
|
|
248 class GrpImpl* pimpl;
|
|
249 public:
|
|
250 Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config);
|
|
251 ~Grp();
|
|
252 bool Wait(unsigned int current_time, Cmd& cmd);
|
|
253 void Exec(Cmd& cmd);
|
|
254 void SetSkipMode(SkipMode mode);
|
|
255 void InitSel(AyuSysConfig& config);
|
|
256 void Save(std::string& str);
|
|
257 void Load(const char* str);
|
|
258 void SaveSys(std::string& str);
|
|
259 void LoadSys(const char* str);
|
0
|
260 };
|
|
261
|
|
262 void dprintf(const char* fmt, ...); // debug 用
|
|
263 void eprintf(const char* fmt, ...); // コマンド実行(XXXexec)追跡用
|
|
264 #endif
|