31
|
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_IMPL_H__
|
|
29 #define __SCN2k_IMPL_H__
|
|
30
|
|
31 #include"scn2k.h"
|
|
32 #include"window/widget.h"
|
|
33 #include"window/event.h"
|
|
34 #include<vector>
|
|
35 #include<string>
|
|
36 #include<map>
|
|
37 #include<set>
|
|
38
|
|
39 struct StackItem {
|
|
40 int scn_number;
|
|
41 int scn_pt;
|
|
42 StackItem(int number, int pt) : scn_number(number), scn_pt(pt) {}
|
|
43 };
|
|
44
|
|
45 struct SaveTitle {
|
|
46 virtual std::string operator()(int number) const = 0;
|
|
47 };
|
|
48
|
|
49 struct Scn2kMenu {
|
|
50 Cmd cmd;
|
|
51 class Scn2kMenuImpl* pimpl;
|
|
52 enum MenuType { MENU_LOAD, MENU_SAVE, MENU_CONFIG, MENU_BACKLOG, MENU_BACKLOG2};
|
|
53 MenuType type;
|
|
54 enum MenuStatus { MENU_CONTINUE=0, MENU_CMD=1, MENU_DELETE=2};
|
|
55 MenuStatus status;
|
|
56 void InitPanel(Event::Container& event, PicContainer& parent);
|
|
57 void InitTitle(const SaveTitle&);
|
|
58 void Cancel(void);
|
|
59 void Exec(Cmd& cmd);
|
|
60 void activate(void);
|
|
61 void deactivate(void);
|
|
62 Scn2kMenu(MenuType type, class Scn2k& scn_impl, const Flags& flags, Text& text, int system_version);
|
|
63 ~Scn2kMenu();
|
|
64 };
|
|
65
|
|
66 struct Scn2kSaveTitle : SaveTitle {
|
|
67 const class Scn2k& impl;
|
|
68 std::string operator() (int number) const;
|
|
69 Scn2kSaveTitle(const Scn2k& _impl) : impl(_impl) {}
|
|
70 };
|
|
71
|
|
72 class Scn2k : Event::Time {
|
|
73 Event::Container& event;
|
|
74 PicContainer& parent;
|
|
75 AyuSysConfig& config;
|
|
76 WidMouseCursor* mcursor;
|
|
77 Flags flag;
|
|
78 Text text_exec;
|
|
79 Grp grp_exec;
|
|
80 int system_version;
|
|
81 SkipMode skip_mode;
|
|
82 int scn_number;
|
|
83 int scn_point;
|
|
84 enum {SCN_INFO=999999, SCN_INFO_MENU=10000001, SCN_INFO_LOCALS = 10000100, SCN_INFO_LOCALSTR = 10000200, SCN_INFO_RETSTR = 10000300}; // stack に積まれる特殊な番号
|
|
85
|
|
86 int save_scn, save_point;
|
|
87
|
|
88 char* script_start;
|
|
89 char* script_end;
|
|
90 const char* script;
|
|
91
|
|
92 int backlog_script_scn;
|
|
93 char* backlog_script_start;
|
|
94 char* backlog_script_end;
|
|
95
|
|
96 std::string window_title;
|
|
97 std::vector<StackItem> stack;
|
|
98 std::vector<std::string> stack_strbuffer;
|
|
99 std::vector<CmdSimplified> cmd_stack;
|
|
100 std::vector<std::string> rollback_save;
|
|
101 std::string new_rollback_save;
|
|
102 std::map<int, std::set<int> > text_readflag;
|
|
103 char* cmd_stack_str;
|
|
104 char cmd_stack_str_orig[32768];
|
|
105
|
|
106 Cmdtype dialog_type;
|
|
107 class WidDialog* dialog;
|
|
108 Scn2kMenu* menu;
|
|
109 bool menu_mouseshown;
|
|
110
|
|
111 Surface* mouse_surface;
|
|
112 int mouse_type;
|
|
113 int mouse_pressed;
|
|
114 void ShowCursor();
|
|
115 void HideCursor();
|
|
116
|
|
117 void SetSkipMode(SkipMode mode);
|
|
118
|
|
119 virtual void Elapsed(unsigned int current_time);
|
|
120
|
|
121 // セーブ関連
|
|
122 std::string MakeSaveFile(void) const;
|
|
123 bool StatSaveFile(int num, int& year, int& month, int& day, int& wday, int& hour,int& min, int& sec, int& msec, std::string& title) const;
|
|
124 void SaveImpl(std::string& s);
|
|
125 void LoadImpl(const char* s);
|
|
126 void Save(Cmd& cmd);
|
|
127 void Load(Cmd& cmd);
|
|
128 void SaveRollback(void);
|
|
129 void LoadRollback(Cmd& cmd);
|
|
130 void SaveSys(void);
|
|
131 void LoadSys(void);
|
|
132 public:
|
|
133 Scn2k(Event::Container& _event, PicContainer& _parent, class MuSys& mu, AyuSysConfig& config);
|
|
134 ~Scn2k();
|
|
135 static char* OpenScript(int scn_number, char*& end, int* call_vec, int& system_version);
|
|
136 bool ChangeScript(int scn_number, int call_no);
|
|
137 bool ReadCmdAt(Cmd& cmd, int scn, int pt);
|
|
138 void show_textwindow(int type);
|
|
139 void hide_textwindow(void);
|
|
140 void SysExec(Cmd& cmd);
|
|
141 bool SysWait(Cmd& cmd);
|
|
142
|
|
143 friend struct Scn2kSaveTitle;
|
|
144 };
|
|
145 #endif
|