0
|
1 #ifndef __SCN2k_H__
|
|
2 #define __SCN2k_H__
|
|
3
|
|
4 #include<vector>
|
|
5 #include<string>
|
|
6 #include<map>
|
|
7 #include<set>
|
|
8
|
|
9 /*
|
|
10 namespace Widget {
|
|
11 class Text;
|
|
12 class Button;
|
|
13 class TextButton;
|
|
14 class Label;
|
|
15 class Dialog;
|
|
16 class AnmTime;
|
|
17 }
|
|
18 */
|
|
19 class WidText;
|
|
20 class WidButton;
|
|
21 class WidTextButton;
|
|
22 class WidLabel;
|
|
23 class WidDialog;
|
|
24 class WidAnmTime;
|
|
25 namespace Event {
|
|
26 class Container;
|
|
27 }
|
|
28 class PicBase;
|
|
29 class PicContainer;
|
|
30 class AyuSysConfig;
|
|
31 class Surface;
|
|
32
|
|
33 void dprintf(const char* fmt, ...);
|
|
34 void eprintf(const char* fmt, ...);
|
|
35
|
|
36 struct VarInfo {
|
|
37 #define TYPE_NONSYSVARMAX 5
|
|
38 #define TYPE_VARMAX 9
|
|
39 #define TYPE_VARLOCSTR 10
|
|
40 #define TYPE_VARSYSSTR 12
|
|
41 #define TYPE_VARSTR 18
|
|
42 #define TYPE_STR 58
|
|
43 #define TYPE_VAL 68
|
|
44 #define TYPE_SYS 0xc8
|
|
45 #define TYPE_END 0x7f
|
|
46
|
|
47 #define TYPE_SYS_SYS 0
|
|
48 #define TYPE_SYS_SKIPMODE 1
|
|
49 int type;
|
|
50 int number;
|
|
51 int value;
|
|
52 VarInfo() { type = TYPE_VAL; value = 0;}
|
|
53 VarInfo(int n) { type = TYPE_VAL; value = n;}
|
|
54 VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;}
|
|
55 };
|
|
56 class Flags {
|
|
57 /* flag:
|
|
58 ** type 0-5 : ローカル整数、各2000個
|
|
59 ** type 6, 25 : グローバル整数、2000個
|
|
60 ** type 10,11: ローカル整数??、各2000個
|
|
61 ** type 12 : グローバル文字列、2000個 (今は無視しても良いが)
|
|
62 ** type 18 : ローカル文字列、2000個
|
|
63 ** type 25: システム変数(マウス座標など?) 1000 個?
|
|
64 ** type 26-32, 51 : 1-bit access to 0-6, 25
|
|
65 ** type 52-58, 77 : 2-bit access to 0-6, 25
|
|
66 ** type 78-84, 103 : 4-bit access to 0-6, 25
|
|
67 ** type 104-110, 129 : 8-bit access to 0-6, 25
|
|
68 */
|
|
69 typedef unsigned int uint;
|
|
70 int sys;
|
|
71 int var[TYPE_VARMAX+1][2000];
|
|
72 std::string str[2000];
|
|
73 std::string sys_str[2000];
|
|
74 std::string loc_str[3];
|
|
75 public:
|
|
76 Flags(void);
|
|
77 int operator () () const;
|
|
78 int operator () (VarInfo info) const;
|
|
79 void Str(int type, unsigned int number, char* buf, int sz) const;
|
|
80 std::string Str(int type, unsigned int number) const;
|
|
81 std::set<int> cgm_data;
|
|
82
|
|
83 bool IsInt(int type) const;
|
|
84 int MaxIndex(int type) const;
|
|
85
|
|
86 void Set(VarInfo info, int value);
|
|
87 int Get(int type, int number) const;
|
|
88 void SetSys(int value);
|
|
89 void SetStr(VarInfo info, std::string val);
|
|
90
|
|
91 bool Exec(class Cmd& cmd);
|
|
92
|
|
93 void Save(std::string& str);
|
|
94 void Load(const char* str);
|
|
95
|
|
96 void SaveSys(std::string& str);
|
|
97 void LoadSys(const char* str);
|
|
98 };
|
|
99
|
|
100 /* commands */
|
|
101 #define STRHEAP_SIZE 10000
|
|
102 enum Cmdtype {
|
|
103 CMD_NOP, CMD_FLAGS, CMD_JMP, CMD_TEXT, CMD_OTHER, CMD_SYSVAR,
|
|
104 CMD_TEXTEND,
|
|
105 CMD_SAVECMDGRP, CMD_SAVECMDGRP_START, CMD_SAVECMDGRP_ONCE, CMD_SAVECMD_ONCE, CMD_WAITFRAMEUPDATE,CMD_SAVEPOINT, CMD_ROLLBACKPOINT,
|
|
106 CMD_SAVEREQ, CMD_SAVE,
|
|
107 CMD_LOADREQ, CMD_LOAD,
|
|
108 CMD_MENUREQ,
|
|
109 CMD_BACKLOGREQ, CMD_BACKLOGREQ_FWD,
|
|
110 CMD_END};
|
|
111 struct CmdSimplified { // Cmd 保存用
|
|
112 int type, cmd1, cmd2, cmd3, cmd4, argc;
|
|
113 char* args;
|
|
114 void Save(std::string& save);
|
|
115 void Load(const char* save, char*& args_buffer);
|
|
116 void copy(const CmdSimplified& from, char*& args_buffer);
|
|
117 };
|
|
118 class Cmd {
|
|
119 public:
|
|
120 Cmdtype cmd_type;
|
|
121 int cmd1, cmd2, cmd3, cmd4;
|
|
122 int argc;
|
|
123 int pos, scn;
|
|
124 const char* rawdata;
|
|
125 char cmdstr[1024];
|
|
126 std::vector<VarInfo> args;
|
|
127
|
|
128 private:
|
|
129 const Flags& flags;
|
|
130 bool errorflag;
|
|
131 int system_version;
|
|
132
|
|
133 int GetArgs(const char*& d);
|
|
134 int GetArgsSpecial(int normal_args,const char*& d);
|
|
135 void GetSelection(const char*& d);
|
|
136 int GetSwitch(const char*& d);
|
|
137 int GetSimpleSwitch(const char*& d);
|
|
138 int GetExpression(const char*& d, struct VarInfo* info = 0);
|
|
139 int GetExpressionCond(const char*& d);
|
|
140 int GetLeftToken(const char*& d, struct VarInfo& info);
|
|
141 int GetString(const char*& d);
|
|
142 int CopyString(const char* d);
|
|
143 int StrVar(int type, int number);
|
|
144 static char strtype[256];
|
|
145 static int StrType(const char* d) { return strtype[*(unsigned const char*)d];}
|
|
146 public:
|
|
147 const char* Str(const VarInfo& info) const {
|
|
148 if (info.type != TYPE_STR && info.type != TYPE_VARSTR && info.type != TYPE_VARLOCSTR && info.type != TYPE_VARSYSSTR) return "";
|
|
149 int pt = info.value;
|
|
150 if (pt < 0 || pt >= STRHEAP_SIZE) return "";
|
|
151 return strheap + pt;
|
|
152 }
|
|
153 int AddStr(char* s) {
|
|
154 // 1-0a-0064 はこういうものが必要らしい
|
|
155 int start = strend;
|
|
156 while (*s) strheap[strend++] = *s++;
|
|
157 strheap[strend++] = 0;
|
|
158 return start;
|
|
159 }
|
|
160 private:
|
|
161 char strheap[STRHEAP_SIZE];
|
|
162 int strend;
|
|
163 void SetError(void) { errorflag = true;}
|
|
164 void ResetString(void) {
|
|
165 strend = 0;
|
|
166 }
|
|
167 public:
|
|
168 void GetCmd(Flags& f, const char*& d);
|
|
169 void SetSysvar(int n, int v);
|
|
170 void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); }
|
|
171 void SetFlagvar(VarInfo info, int v);
|
|
172 void SetStrvar(VarInfo info, const std::string& s);
|
|
173 bool IsError() { return errorflag;}
|
|
174 void clear(void);
|
|
175 Cmd(const Flags& f, int _sys_ver) : flags(f), system_version(_sys_ver) { cmd_type = CMD_NOP; argc = 0; errorflag = false; cmdstr[0] = 0; strend = 0; pos = -1;}
|
|
176 void read(const CmdSimplified& cmd);
|
|
177 void write(CmdSimplified& cmd, char*& args_buffer) const;
|
|
178 };
|
|
179
|
|
180 enum SkipMode {SKIP_NO=0, SKIP_TEXT=1, SKIP_GRP_FAST=16, SKIP_GRP_NOEFFEC=32, SKIP_GRP_NODRAW=64, SKIPEND_TEXT=256, SKIPEND_KEY=512,
|
|
181 SKIP_IN_MENU=1024};
|
|
182
|
|
183 #include"font/text.h"
|
|
184
|
|
185 struct BacklogItem {
|
|
186 enum {SaveSelect = -2};
|
|
187 int scn, pos;
|
|
188 int koe;
|
|
189 std::string face;
|
|
190 struct TextStream text;
|
|
191 BacklogItem(void);
|
|
192 void Clear(void);
|
|
193 void AddTextPos(Cmd&);
|
|
194 void DeleteTextPos();
|
|
195 void SetSavepos(int pos);
|
|
196 BacklogItem& operator =(const BacklogItem&);
|
|
197 };
|
|
198 class Text {
|
|
199 class TextImpl* pimpl;
|
|
200 public:
|
|
201 std::vector<BacklogItem> backlog;
|
|
202 BacklogItem backlog_item;
|
|
203 Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config);
|
|
204 ~Text();
|
|
205 void InitWindow(void);
|
|
206 void Exec(Cmd& cmd);
|
|
207 bool Wait(unsigned int current_time, Cmd& cmd);
|
|
208 void SetSkipMode(SkipMode mode);
|
|
209 void hide(void);
|
|
210 void show(void);
|
|
211 void show(int num);
|
|
212 void Save(std::string& str, bool rollback_save);
|
|
213 void Load(const char* str);
|
|
214 void DrawBacklog(BacklogItem& item, Cmd& cmd);
|
|
215 };
|
|
216
|
|
217 #include"../window/rect.h"
|
|
218
|
|
219 class Grp {
|
|
220 class GrpImpl* pimpl;
|
|
221 public:
|
|
222 Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config);
|
|
223 ~Grp();
|
|
224 bool Wait(unsigned int current_time, Cmd& cmd);
|
|
225 void Exec(Cmd& cmd);
|
|
226 void SetSkipMode(SkipMode mode);
|
|
227 void InitSel(AyuSysConfig& config);
|
|
228 void Save(std::string& str);
|
|
229 void Load(const char* str);
|
|
230 void SaveSys(std::string& str);
|
|
231 void LoadSys(const char* str);
|
|
232 };
|
|
233
|
|
234 void dprintf(const char* fmt, ...); // debug 用
|
|
235 void eprintf(const char* fmt, ...); // コマンド実行(XXXexec)追跡用
|
|
236 #endif
|