diff scn2k/scn2k.h @ 52:15a18fbe6f21

* Known bugs added to the README * Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author thib
date Sat, 18 Apr 2009 18:35:39 +0000
parents f1fbe5b37a1e
children ddbcbd000206
line wrap: on
line diff
--- a/scn2k/scn2k.h
+++ b/scn2k/scn2k.h
@@ -28,10 +28,10 @@
 #ifndef __SCN2k_H__
 #define __SCN2k_H__
 
-#include<vector>
-#include<string>
-#include<map>
-#include<set>
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
 
 /*
 namespace Widget {
@@ -43,15 +43,17 @@ namespace Widget {
 	class AnmTime;
 }
 */
-	class WidText;
-	class WidButton;
-	class WidTextButton;
-	class WidLabel;
-	class WidDialog;
-	class WidAnmTime;
+class WidText;
+class WidButton;
+class WidTextButton;
+class WidLabel;
+class WidDialog;
+class WidAnmTime;
+
 namespace Event {
 	class Container;
 }
+
 class PicBase;
 class PicContainer;
 class AyuSysConfig;
@@ -93,35 +95,36 @@ class Flags {
 **  type 78-84, 103 : 4-bit access to 0-6, 25
 **  type 104-110, 129 : 8-bit access to 0-6, 25
 */
-	typedef unsigned int uint;
-	int sys;
-	int var[TYPE_VARMAX+1][2000];
-	std::string str[2000];
-	std::string sys_str[2000];
-	std::string loc_str[3];
-public:
-	Flags(void);
-	int operator () () const;
-	int operator () (VarInfo info) const;
-	void Str(int type, unsigned int number, char* buf, int sz) const;
-	std::string Str(int type, unsigned int number) const;
-	std::set<int> cgm_data;
+	private:
+		typedef unsigned int uint;
+		int sys;
+		int var[TYPE_VARMAX+1][2000];
+		std::string str[2000];
+		std::string sys_str[2000];
+		std::string loc_str[3];
+	public:
+		Flags(void);
+		int operator () () const;
+		int operator () (VarInfo info) const;
+		void Str(int type, unsigned int number, char* buf, int sz) const;
+		std::string Str(int type, unsigned int number) const;
+		std::set<int> cgm_data;
 
-	bool IsInt(int type) const;
-	int MaxIndex(int type) const;
+		bool IsInt(int type) const;
+		int MaxIndex(int type) const;
 
-	void Set(VarInfo info, int value);
-	int Get(int type, int number) const;
-	void SetSys(int value);
-	void SetStr(VarInfo info, std::string val);
+		void Set(VarInfo info, int value);
+		int Get(int type, int number) const;
+		void SetSys(int value);
+		void SetStr(VarInfo info, std::string val);
 
-	bool Exec(class Cmd& cmd);
+		bool Exec(class Cmd& cmd);
 
-	void Save(std::string& str);
-	void Load(const char* str);
+		void Save(std::string& str);
+		void Load(const char* str);
 
-	void SaveSys(std::string& str);
-	void LoadSys(const char* str);
+		void SaveSys(std::string& str);
+		void LoadSys(const char* str);
 };
 
 /* commands */
@@ -135,6 +138,7 @@ enum Cmdtype {
 	CMD_MENUREQ,
 	CMD_BACKLOGREQ, CMD_BACKLOGREQ_FWD,
 	CMD_END};
+
 struct CmdSimplified { // Cmd 保存用
 	int type, cmd1, cmd2, cmd3, cmd4, argc;
 	char* args;
@@ -142,73 +146,66 @@ struct CmdSimplified { // Cmd 保存用
 	void Load(const char* save, char*& args_buffer);
 	void copy(const CmdSimplified& from, char*& args_buffer);
 };
+
 class Cmd {
-public:
-	Cmdtype cmd_type;
-	int cmd1, cmd2, cmd3, cmd4;
-	int argc;
-	int pos, scn;
-	const char* rawdata;
-	char cmdstr[1024];
-	std::vector<VarInfo> args;
+	public:
+		Cmdtype cmd_type;
+		int cmd1, cmd2, cmd3, cmd4;
+		int argc;
+		int pos, scn;
+		const char* rawdata;
+		char cmdstr[1024];
+		std::vector<VarInfo> args;
 
-private:
-	const Flags& flags;
-	bool errorflag;
-	int system_version;
+	private:
+		const Flags& flags;
+		bool errorflag;
+		int system_version;
 
-	int GetArgs(const char*& d);
-	int GetArgsSpecial(int normal_args,const char*& d);
-	void GetSelection(const char*& d);
-	int GetSwitch(const char*& d);
-	int GetSimpleSwitch(const char*& d);
-	int GetExpression(const char*& d, struct VarInfo* info = 0);
-	int GetExpressionCond(const char*& d);
-	int GetLeftToken(const char*& d, struct VarInfo& info);
-	int GetString(const char*& d);
-	int CopyString(const char* d);
-	int StrVar(int type, int number);
-	static char strtype[256];
-	static int StrType(const char* d) { return strtype[*(unsigned const char*)d];}
-public:
-	const char* Str(const VarInfo& info) const {
-		if (info.type != TYPE_STR && info.type != TYPE_VARSTR && info.type != TYPE_VARLOCSTR && info.type != TYPE_VARSYSSTR) return "";
-		int pt = info.value;
-		if (pt < 0 || pt >= STRHEAP_SIZE) return "";
-		return strheap + pt;
-	}
-	int AddStr(char* s) {
-		// 1-0a-0064 はこういうものが必要らしい
-		int start = strend;
-		while (*s) strheap[strend++] = *s++;
-		strheap[strend++] = 0;
-		return start;
-	}
-private:
-	char strheap[STRHEAP_SIZE];
-	int strend;
-	void SetError(void) { errorflag = true;}
-	void ResetString(void) {
-		strend = 0;
-	}
-public:
-	void GetCmd(Flags& f, const char*& d);
-	void SetSysvar(int n, int v);
-	void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); }
-	void SetFlagvar(VarInfo info, int v);
-	void SetStrvar(VarInfo info, const std::string& s);
-	bool IsError() { return errorflag;}
-	void clear(void);
-	virtual const char * CmdDescr(int, int, int, int) { return "Not supported"; }
-	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;}
-	void read(const CmdSimplified& cmd);
-	void write(CmdSimplified& cmd, char*& args_buffer) const;
+		int GetArgs(const char*& d);
+		int GetArgsSpecial(int normal_args,const char*& d);
+		void GetSelection(const char*& d);
+		int GetSwitch(const char*& d);
+		int GetSimpleSwitch(const char*& d);
+		int GetExpression(const char*& d, struct VarInfo* info = 0);
+		int GetExpressionCond(const char*& d);
+		int GetLeftToken(const char*& d, struct VarInfo& info);
+		int GetString(const char*& d);
+		int CopyString(const char* d);
+		int StrVar(int type, int number);
+		static char strtype[256];
+		static int StrType(const char* d) { return strtype[*(unsigned const char*)d];}
+
+	public:
+		const char* Str(const VarInfo& info) const;
+		int AddStr(char* s);
+	private:
+		char strheap[STRHEAP_SIZE];
+		int strend;
+		void SetError(void) { errorflag = true;}
+		void ResetString(void) {
+			strend = 0;
+		}
+	public:
+		void GetCmd(Flags& f, const char*& d);
+		void SetSysvar(int n, int v);
+		void SetSysvar(int v) { SetSysvar(TYPE_SYS_SYS, v); }
+		void SetFlagvar(VarInfo info, int v);
+		void SetStrvar(VarInfo info, const std::string& s);
+		bool IsError() { return errorflag;}
+		void clear(void);
+		virtual const char * CmdDescr(int, int, int, int) { return "Not supported"; }
+		Cmd(const Flags& f, int _sys_ver);
+		void read(const CmdSimplified& cmd);
+		void write(CmdSimplified& cmd, char*& args_buffer) const;
 };
 
-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,
-	SKIP_IN_MENU=1024};
+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, SKIP_IN_MENU=1024
+};
 
-#include"font/text.h"
+#include "font/text.h"
 
 struct BacklogItem {
 	enum {SaveSelect = -2};
@@ -223,40 +220,43 @@ struct BacklogItem {
 	void SetSavepos(int pos);
 	BacklogItem& operator =(const BacklogItem&);
 };
+
 class Text {
-	class TextImpl* pimpl;
-public:
-	std::vector<BacklogItem> backlog;
-	BacklogItem backlog_item;
-	Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config);
-	~Text();
-	void InitWindow(void);
-	void Exec(Cmd& cmd);
-	bool Wait(unsigned int current_time, Cmd& cmd);
-	void SetSkipMode(SkipMode mode);
-	void hide(void);
-	void show(void);
-	void show(int num);
-	void Save(std::string& str, bool rollback_save);
-	void Load(const char* str);
-	void DrawBacklog(BacklogItem& item, Cmd& cmd);
+	private:
+		class TextImpl* pimpl;
+	public:
+		std::vector<BacklogItem> backlog;
+		BacklogItem backlog_item;
+		Text(Event::Container& _event, PicContainer& _parent, AyuSysConfig& config);
+		~Text();
+		void InitWindow(void);
+		void Exec(Cmd& cmd);
+		bool Wait(unsigned int current_time, Cmd& cmd);
+		void SetSkipMode(SkipMode mode);
+		void hide(void);
+		void show(void);
+		void show(int num);
+		void Save(std::string& str, bool rollback_save);
+		void Load(const char* str);
+		void DrawBacklog(BacklogItem& item, Cmd& cmd);
 };
 
-#include"../window/rect.h"
+#include "../window/rect.h"
 
 class Grp {
-	class GrpImpl* pimpl;
-public:
-	Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config);
-	~Grp();
-	bool Wait(unsigned int current_time, Cmd& cmd);
-	void Exec(Cmd& cmd);
-	void SetSkipMode(SkipMode mode);
-	void InitSel(AyuSysConfig& config);
-	void Save(std::string& str);
-	void Load(const char* str);
-	void SaveSys(std::string& str);
-	void LoadSys(const char* str);
+	private:
+		class GrpImpl* pimpl;
+	public:
+		Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, std::set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config);
+		~Grp();
+		bool Wait(unsigned int current_time, Cmd& cmd);
+		void Exec(Cmd& cmd);
+		void SetSkipMode(SkipMode mode);
+		void InitSel(AyuSysConfig& config);
+		void Save(std::string& str);
+		void Load(const char* str);
+		void SaveSys(std::string& str);
+		void LoadSys(const char* str);
 };
 
 void dprintf(const char* fmt, ...); // debug 用