Mercurial > otakunoraifu
diff scn2k/scn2k.h @ 54:d7cde171a1de
* scn2k_grp.cc now handles commands in a cleanier way \o/
* some cleaning
author | thib |
---|---|
date | Mon, 20 Apr 2009 16:18:55 +0000 |
parents | ddbcbd000206 |
children | f1a27ee7e03c |
line wrap: on
line diff
--- a/scn2k/scn2k.h +++ b/scn2k/scn2k.h @@ -82,6 +82,8 @@ struct VarInfo { VarInfo(int n) { type = TYPE_VAL; value = n;} VarInfo(const VarInfo& i) { type = i.type; number = i.number; value = i.value;} }; + + class Flags { /* flag: ** type 0-5 : ローカル整数、各2000個 @@ -147,10 +149,22 @@ struct CmdSimplified { // Cmd 保存用 void copy(const CmdSimplified& from, char*& args_buffer); }; -class Cmd { +class SimpleCmd { + public: + SimpleCmd(int a, int b, int c); + SimpleCmd(); + + bool operator==(const SimpleCmd& cmd) const; + bool operator<(const SimpleCmd& cmd) const; + + public: + int cmd1, cmd2, cmd3; +}; + +class Cmd : public SimpleCmd{ public: Cmdtype cmd_type; - int cmd1, cmd2, cmd3, cmd4; + int cmd4; int argc; int pos, scn; const char* rawdata; @@ -179,6 +193,7 @@ class Cmd { public: const char* Str(const VarInfo& info) const; int AddStr(char* s); + private: char strheap[STRHEAP_SIZE]; int strend; @@ -186,6 +201,7 @@ class Cmd { void ResetString(void) { strend = 0; } + public: void GetCmd(Flags& f, const char*& d); void SetSysvar(int n, int v); @@ -200,6 +216,21 @@ class Cmd { void write(CmdSimplified& cmd, char*& args_buffer) const; }; +class CommandHandler { + public: + typedef void (CommandHandler::*CmdImpl)(Cmd& cmd); + typedef struct { + const char* descr; + CmdImpl function; + } CommandInfo; + void RegisterCommand(int cmd1, int cmd2, int cmd3, const char* descr, CmdImpl func); + bool Exec(Cmd& cmd); + + private: + typedef std::map<SimpleCmd, CommandInfo> CommandMap; + CommandMap command_map; +}; + 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