annotate scn2k/scn2k_impl.h @ 7:fa8511a21d05

Fixes somes memory leaks
author thib
date Tue, 05 Aug 2008 10:06:04 +0000
parents 223b71206888
children 5ae5533b3a9a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 #ifndef __SCN2k_IMPL_H__
223b71206888 Initial import
thib
parents:
diff changeset
2 #define __SCN2k_IMPL_H__
223b71206888 Initial import
thib
parents:
diff changeset
3
223b71206888 Initial import
thib
parents:
diff changeset
4 #include"scn2k.h"
223b71206888 Initial import
thib
parents:
diff changeset
5 #include"window/widget.h"
223b71206888 Initial import
thib
parents:
diff changeset
6 #include"window/event.h"
223b71206888 Initial import
thib
parents:
diff changeset
7 #include<vector>
223b71206888 Initial import
thib
parents:
diff changeset
8 #include<string>
223b71206888 Initial import
thib
parents:
diff changeset
9 #include<map>
223b71206888 Initial import
thib
parents:
diff changeset
10 #include<set>
223b71206888 Initial import
thib
parents:
diff changeset
11
223b71206888 Initial import
thib
parents:
diff changeset
12 struct StackItem {
223b71206888 Initial import
thib
parents:
diff changeset
13 int scn_number;
223b71206888 Initial import
thib
parents:
diff changeset
14 int scn_pt;
223b71206888 Initial import
thib
parents:
diff changeset
15 StackItem(int number, int pt) : scn_number(number), scn_pt(pt) {}
223b71206888 Initial import
thib
parents:
diff changeset
16 };
223b71206888 Initial import
thib
parents:
diff changeset
17
223b71206888 Initial import
thib
parents:
diff changeset
18 struct SaveTitle {
223b71206888 Initial import
thib
parents:
diff changeset
19 virtual std::string operator()(int number) const = 0;
223b71206888 Initial import
thib
parents:
diff changeset
20 };
223b71206888 Initial import
thib
parents:
diff changeset
21
223b71206888 Initial import
thib
parents:
diff changeset
22 struct Scn2kMenu {
223b71206888 Initial import
thib
parents:
diff changeset
23 Cmd cmd;
223b71206888 Initial import
thib
parents:
diff changeset
24 class Scn2kMenuImpl* pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
25 enum MenuType { MENU_LOAD, MENU_SAVE, MENU_CONFIG, MENU_BACKLOG, MENU_BACKLOG2};
223b71206888 Initial import
thib
parents:
diff changeset
26 MenuType type;
223b71206888 Initial import
thib
parents:
diff changeset
27 enum MenuStatus { MENU_CONTINUE=0, MENU_CMD=1, MENU_DELETE=2};
223b71206888 Initial import
thib
parents:
diff changeset
28 MenuStatus status;
223b71206888 Initial import
thib
parents:
diff changeset
29 void InitPanel(Event::Container& event, PicContainer& parent);
223b71206888 Initial import
thib
parents:
diff changeset
30 void InitTitle(const SaveTitle&);
223b71206888 Initial import
thib
parents:
diff changeset
31 void Cancel(void);
223b71206888 Initial import
thib
parents:
diff changeset
32 void Exec(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
33 void activate(void);
223b71206888 Initial import
thib
parents:
diff changeset
34 void deactivate(void);
223b71206888 Initial import
thib
parents:
diff changeset
35 Scn2kMenu(MenuType type, class Scn2k& scn_impl, const Flags& flags, Text& text, int system_version);
223b71206888 Initial import
thib
parents:
diff changeset
36 ~Scn2kMenu();
223b71206888 Initial import
thib
parents:
diff changeset
37 };
223b71206888 Initial import
thib
parents:
diff changeset
38
223b71206888 Initial import
thib
parents:
diff changeset
39 struct Scn2kSaveTitle : SaveTitle {
223b71206888 Initial import
thib
parents:
diff changeset
40 const class Scn2k& impl;
223b71206888 Initial import
thib
parents:
diff changeset
41 std::string operator() (int number) const;
223b71206888 Initial import
thib
parents:
diff changeset
42 Scn2kSaveTitle(const Scn2k& _impl) : impl(_impl) {}
223b71206888 Initial import
thib
parents:
diff changeset
43 };
223b71206888 Initial import
thib
parents:
diff changeset
44
223b71206888 Initial import
thib
parents:
diff changeset
45 class Scn2k : Event::Time {
223b71206888 Initial import
thib
parents:
diff changeset
46 Event::Container& event;
223b71206888 Initial import
thib
parents:
diff changeset
47 PicContainer& parent;
223b71206888 Initial import
thib
parents:
diff changeset
48 AyuSysConfig& config;
223b71206888 Initial import
thib
parents:
diff changeset
49 WidMouseCursor* mcursor;
223b71206888 Initial import
thib
parents:
diff changeset
50 Flags flag;
223b71206888 Initial import
thib
parents:
diff changeset
51 Text text_exec;
223b71206888 Initial import
thib
parents:
diff changeset
52 Grp grp_exec;
223b71206888 Initial import
thib
parents:
diff changeset
53 int system_version;
223b71206888 Initial import
thib
parents:
diff changeset
54 SkipMode skip_mode;
223b71206888 Initial import
thib
parents:
diff changeset
55 int scn_number;
223b71206888 Initial import
thib
parents:
diff changeset
56 int scn_point;
223b71206888 Initial import
thib
parents:
diff changeset
57 enum {SCN_INFO=999999, SCN_INFO_MENU=10000001, SCN_INFO_LOCALS = 10000100, SCN_INFO_LOCALSTR = 10000200, SCN_INFO_RETSTR = 10000300}; // stack に積まれる特殊な番号
223b71206888 Initial import
thib
parents:
diff changeset
58
223b71206888 Initial import
thib
parents:
diff changeset
59 int save_scn, save_point;
223b71206888 Initial import
thib
parents:
diff changeset
60
223b71206888 Initial import
thib
parents:
diff changeset
61 char* script_start;
223b71206888 Initial import
thib
parents:
diff changeset
62 char* script_end;
223b71206888 Initial import
thib
parents:
diff changeset
63 const char* script;
223b71206888 Initial import
thib
parents:
diff changeset
64
223b71206888 Initial import
thib
parents:
diff changeset
65 int backlog_script_scn;
223b71206888 Initial import
thib
parents:
diff changeset
66 char* backlog_script_start;
223b71206888 Initial import
thib
parents:
diff changeset
67 char* backlog_script_end;
223b71206888 Initial import
thib
parents:
diff changeset
68
223b71206888 Initial import
thib
parents:
diff changeset
69 std::string window_title;
223b71206888 Initial import
thib
parents:
diff changeset
70 std::vector<StackItem> stack;
223b71206888 Initial import
thib
parents:
diff changeset
71 std::vector<std::string> stack_strbuffer;
223b71206888 Initial import
thib
parents:
diff changeset
72 std::vector<CmdSimplified> cmd_stack;
223b71206888 Initial import
thib
parents:
diff changeset
73 std::vector<std::string> rollback_save;
223b71206888 Initial import
thib
parents:
diff changeset
74 std::string new_rollback_save;
223b71206888 Initial import
thib
parents:
diff changeset
75 std::map<int, std::set<int> > text_readflag;
223b71206888 Initial import
thib
parents:
diff changeset
76 char* cmd_stack_str;
223b71206888 Initial import
thib
parents:
diff changeset
77 char cmd_stack_str_orig[32768];
223b71206888 Initial import
thib
parents:
diff changeset
78
223b71206888 Initial import
thib
parents:
diff changeset
79 Cmdtype dialog_type;
223b71206888 Initial import
thib
parents:
diff changeset
80 class WidDialog* dialog;
223b71206888 Initial import
thib
parents:
diff changeset
81 Scn2kMenu* menu;
223b71206888 Initial import
thib
parents:
diff changeset
82 bool menu_mouseshown;
223b71206888 Initial import
thib
parents:
diff changeset
83
223b71206888 Initial import
thib
parents:
diff changeset
84 Surface* mouse_surface;
223b71206888 Initial import
thib
parents:
diff changeset
85 int mouse_type;
223b71206888 Initial import
thib
parents:
diff changeset
86 int mouse_pressed;
223b71206888 Initial import
thib
parents:
diff changeset
87 void ShowCursor();
223b71206888 Initial import
thib
parents:
diff changeset
88 void HideCursor();
223b71206888 Initial import
thib
parents:
diff changeset
89
223b71206888 Initial import
thib
parents:
diff changeset
90 void SetSkipMode(SkipMode mode);
223b71206888 Initial import
thib
parents:
diff changeset
91
223b71206888 Initial import
thib
parents:
diff changeset
92 virtual void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
93
223b71206888 Initial import
thib
parents:
diff changeset
94 // セーブ関連
223b71206888 Initial import
thib
parents:
diff changeset
95 std::string MakeSaveFile(void) const;
223b71206888 Initial import
thib
parents:
diff changeset
96 bool StatSaveFile(int num, int& year, int& month, int& day, int& wday, int& hour,int& min, int& sec, int& msec, std::string& title) const;
223b71206888 Initial import
thib
parents:
diff changeset
97 void SaveImpl(std::string& s);
223b71206888 Initial import
thib
parents:
diff changeset
98 void LoadImpl(const char* s);
223b71206888 Initial import
thib
parents:
diff changeset
99 void Save(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
100 void Load(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
101 void SaveRollback(void);
223b71206888 Initial import
thib
parents:
diff changeset
102 void LoadRollback(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
103 void SaveSys(void);
223b71206888 Initial import
thib
parents:
diff changeset
104 void LoadSys(void);
223b71206888 Initial import
thib
parents:
diff changeset
105 public:
223b71206888 Initial import
thib
parents:
diff changeset
106 Scn2k(Event::Container& _event, PicContainer& _parent, class MuSys& mu, AyuSysConfig& config);
223b71206888 Initial import
thib
parents:
diff changeset
107 ~Scn2k();
223b71206888 Initial import
thib
parents:
diff changeset
108 static char* OpenScript(int scn_number, char*& end, int* call_vec, int& system_version);
223b71206888 Initial import
thib
parents:
diff changeset
109 bool ChangeScript(int scn_number, int call_no);
223b71206888 Initial import
thib
parents:
diff changeset
110 bool ReadCmdAt(Cmd& cmd, int scn, int pt);
223b71206888 Initial import
thib
parents:
diff changeset
111 void show_textwindow(int type);
223b71206888 Initial import
thib
parents:
diff changeset
112 void hide_textwindow(void);
223b71206888 Initial import
thib
parents:
diff changeset
113 void SysExec(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
114 bool SysWait(Cmd& cmd);
223b71206888 Initial import
thib
parents:
diff changeset
115
223b71206888 Initial import
thib
parents:
diff changeset
116 friend struct Scn2kSaveTitle;
223b71206888 Initial import
thib
parents:
diff changeset
117 };
223b71206888 Initial import
thib
parents:
diff changeset
118 #endif