annotate scn2k/scn2k.h @ 11:28a4f6bde8c8

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