Mercurial > otakunoraifu
diff scn2k/scn2k_grp.cc @ 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 | 35ce1a30f3f9 |
children | ddbcbd000206 |
line wrap: on
line diff
--- a/scn2k/scn2k_grp.cc +++ b/scn2k/scn2k_grp.cc @@ -25,12 +25,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include"scn2k.h" -#include"window/widget.h" -#include"system/file.h" -#include"system/system_config.h" -#include"font/text.h" -#include<set> +#include "scn2k.h" +#include "window/widget.h" +#include "system/file.h" +#include "system/system_config.h" +#include "font/text.h" +#include <set> using namespace std; @@ -60,7 +60,7 @@ struct GrpObj { PicBase* picture; WidAnmTime* anm; int _posx, _posy; - int posx[9],posy[9]; + int posx[9], posy[9]; Rect clip_area; unsigned char alpha; int order; @@ -138,74 +138,77 @@ struct GrpObjMap : std::map<int, GrpObj> class GrpImpl { #define MAXPDT 256 #define WORKPDT 255 - Event::Container& event; - const Flags& flags; - PicBase* screen; - PicBase* screen_front; - Surface* surface, *surface_update; + private: + Event::Container& event; + const Flags& flags; + PicBase* screen; + PicBase* screen_front; + Surface* surface, *surface_update; - Surface* dsurface[MAXPDT]; // 書き込み可能な Surface - Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface - PicContainer& parent; + Surface* dsurface[MAXPDT]; // 書き込み可能な Surface + Surface* ssurface[MAXPDT]; // ファイルの内容等、読み込みのみ可能な状態の Surface + PicContainer& parent; - // 画像効果の保存用 - WidAnmTime* anm1, *anm2; - typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; - Status status; - SkipMode skip_mode; + // 画像効果の保存用 + WidAnmTime* anm1, *anm2; + typedef enum { NORMAL, WAIT_ANM, WAIT_SHAKE, WAIT_SE, WAIT_MOVIE} Status; + Status status; + SkipMode skip_mode; - std::string bg_name; - std::map<int, SEL> anmtype; - GrpObjMap grpobj; - GrpObjMap bs_obj; - void CreateObj(int number); - void ZMoveObj(int number); - void SetObjChanged(int number); - void SetObjChangedGroup(int number); - void SwapObj(int a1, int a2); - void DeleteObjPic(int num);// object の surface のみ削除 - void DeleteObj(int num); - void DeleteObjRange(int num_b, int num_e); + std::string bg_name; + std::map<int, SEL> anmtype; + GrpObjMap grpobj; + GrpObjMap bs_obj; + void CreateObj(int number); + void ZMoveObj(int number); + void SetObjChanged(int number); + void SetObjChangedGroup(int number); + void SwapObj(int a1, int a2); + void DeleteObjPic(int num);// object の surface のみ削除 + void DeleteObj(int num); + void DeleteObjRange(int num_b, int num_e); - std::set<int> changed_obj; - string reserved_load_surface0; - vector<PicBase*> deleted_pic; - void RefreshObj(void); + std::set<int> changed_obj; + string reserved_load_surface0; + vector<PicBase*> deleted_pic; + void RefreshObj(void); - Surface* Dsurface(int pdt); - Surface* Ssurface(int pdt); + Surface* Dsurface(int pdt); + Surface* Ssurface(int pdt); - // cgmode 用画像処理関連 - void LoadCgm(AyuSysConfig& config); - std::map<std::string, int> cgm_info; - set<int>& cgm_data; - int cgm_size; - - class MuSys& music; + // cgmode 用画像処理関連 + void LoadCgm(AyuSysConfig& config); + std::map<std::string, int> cgm_info; + set<int>& cgm_data; + int cgm_size; + + class MuSys& music; + + public: + AyuSysConfig& config; + void LoadSurface(const char* str, int pdt); -public: - AyuSysConfig& config; - void LoadSurface(const char* str, int pdt); -private: - void LoadSurface(const char* str); - void LoadSurface(void); - void AddSurface(const char* str); + private: + void LoadSurface(const char* str); + void LoadSurface(void); + void AddSurface(const char* str); + + void StartAnm(int type); + void StartShake(int total, const int* pattern); + void AbortAnm(void); + static bool Pressed(int x, int y, void* pointer); - void StartAnm(int type); - void StartShake(int total, const int* pattern); - void AbortAnm(void); - static bool Pressed(int x, int y, void* pointer); -public: - GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); - ~GrpImpl(); - bool Wait(unsigned int current_time, Cmd& cmd); - void Exec(Cmd& cmd); - 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 SetSkipMode(SkipMode _mode); + public: + GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& _flag, set<int>& _cgm_data, class MuSys& mu, AyuSysConfig& config); + ~GrpImpl(); + bool Wait(unsigned int current_time, Cmd& cmd); + void Exec(Cmd& cmd); + 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 SetSkipMode(SkipMode _mode); }; /******************************************************************* ** GrpObj(implementation) @@ -222,22 +225,27 @@ GrpObj::GrpObj(void) : posx[i] = posy[i] = 0; } } + GrpObj::~GrpObj() { if (picture) delete picture; if (parent_pimpl == 0) { fprintf(stderr,"\n**************\nFATAL : UNINITIALIZED GrpObj IS FOUND!!! \n**************\n"); } } + int GrpObj::PosX() { return _posx; } + int GrpObj::PosY() { return _posy; } + void GrpObj::SetUpdate(void) { attr = Attribute (attr | UPDATE_PICTURE); //Update(); //FIXME } + void GrpObj::SetPos(int index, int x,int y) { if (index < 0 || index > 8) { fprintf(stderr,"GrpObj::SetPos: Invalid index %d <- %d,%d\n",index,x,y); @@ -250,6 +258,7 @@ void GrpObj::SetPos(int index, int x,int posx[index] = x; posy[index] = y; } + void GrpObj::GetPos(int index, int& x, int& y) { if (index < 0 || index > 8) { fprintf(stderr,"GrpObj::GetPos: Invalid index %d\n",index); @@ -260,12 +269,14 @@ void GrpObj::GetPos(int index, int& x, i y = posy[index]; return; } + void GrpObj::SetAlpha(int new_alpha) { if (alpha == new_alpha) return; alpha = new_alpha; attr = Attribute(attr | UPDATE_ALPHA); return; } + void GrpObj::SetSurfaceNum(int num) { if (num != -1) { if (surface_num == num) return; @@ -282,6 +293,7 @@ void GrpObj::SetClipArea(int x, int y, i attr = Attribute(attr | UPDATE_CLIP); return; } + PicBase* GrpObj::DeletePic(void) { PicBase* p = picture; anm = 0; @@ -290,6 +302,7 @@ PicBase* GrpObj::DeletePic(void) { attr = Attribute(attr & (HIDDEN | HIDDEN_GROUP)); return p; } + void GrpObj::GetSrcGeom(int& width, int& height) { if (src_pos.empty()) { width = 0; height = 0; @@ -301,12 +314,12 @@ void GrpObj::GetSrcGeom(int& width, int& string path(name); path += ".g00"; ARCINFO* info = file_searcher.Find(FILESEARCH::PDT, path.c_str(), "g00"); - if (info == 0) { // ファイルが見つからない - fprintf(stderr,"GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); + if (info == NULL) { // ファイルが見つからない + fprintf(stderr, "GrpObj::GetSrcGeom : Cannot find file %s\n", path.c_str()); return; } const char* data = info->Read(); - if (data && *data == 2) { // 画像ファイル内にボタン情報が存在する + if (data != NULL && *data == 2) { // 画像ファイル内にボタン情報が存在する int srclen = read_little_endian_int(data+5); int i; for (i=0; i<srclen; i++) { @@ -331,6 +344,7 @@ void GrpObj::GetSrcGeom(int& width, int& height = src_pos[sn].height(); return; } + void GrpObj::Update(void) { if (attr & UPDATE_PICTURE) { UpdateSurface(); @@ -376,8 +390,9 @@ void GrpObj::Update(void) { attr = Attribute(attr & (~ANM_PLAYSTART)); } } + void GrpObj::CreateSurface(PicContainer* parent) { - if (picture) { + if (picture != NULL) { PicBase* p = DeletePic(); delete p; } @@ -390,7 +405,7 @@ void GrpObj::CreateSurface(PicContainer* } void GrpObj::UpdateSurface(void) { - if (pic_parent == 0 || picture == 0) return; + if (pic_parent == NULL || picture == NULL) return; int width = 0, height = 0; if (gtype == FILE || gtype == GAN) { if (name.length() == 0) return; @@ -416,14 +431,15 @@ void GrpObj::UpdateSurface(void) { UpdateDigit(); } } + void GrpObj::ZoomRotate(void) { - picture->SetSurface( (Surface*)0,0,0); + picture->SetSurface( (Surface*)0, 0, 0); // 回転、縮小拡大は座標原点が画像の中心になる string path(name); path += ".g00"; Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); - if (surface_orig == 0) return; + if (surface_orig == NULL) return; Surface* zoom_surface = pic_parent->Root().RotZoomSurface(surface_orig, double(zoom)/256.0, rotate); Rect zoom_r (*zoom_surface); @@ -450,8 +466,10 @@ static char* wstrchr(const char* s, unsi if (wc == chr) return (char*)s; s += ws; } - return 0; + return NULL; } + +//TODO: See why it does nothing with font/text_stream.cc:98 TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse TextStream ts; ts.kanji_type = TextStream::sjis; @@ -461,7 +479,7 @@ TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse char* retptr; int var; - while( (next_str = wstrchr(str, '#')) != 0) { + while( (next_str = wstrchr(str, '#')) != NULL) { int len = next_str - str; strncpy(copy_str, str, len); copy_str[len] = 0; @@ -487,7 +505,7 @@ TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse if (parent_pimpl->config.GetParam(key, 3, &r, &g, &b)) { // color not found r = g = b = 0; } - ts.SetColor(r,g,b); + ts.SetColor(r, g, b); str = next_str; } break; @@ -513,6 +531,7 @@ TextStream GrpObj::ParseMoji(const char* str, int def_r ,int def_g, int def_b, int def_size) { // 制御シーケンス付き文字列をparse delete[] copy_str; return ts; } + void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 if (print_moji.length() == 0 || print_size <= 2) return; if (pic_parent == 0) return; @@ -539,6 +558,7 @@ void GrpObj::UpdateMoji(void) { // 文字の大きさ、色などを変更 picture->SetSurfaceRect(Rect(0,0,width,height)); picture->SetSurfaceFreeFlag(); } + void GrpObj::UpdateDigit(void) { // 画像表示の数値文字列を表示する if (name.length() == 0) return; @@ -546,7 +566,7 @@ void GrpObj::UpdateDigit(void) { string path(name); path += ".g00"; Surface* surface_orig = pic_parent->Root().NewSurface(path.c_str()); - if (surface_orig == 0) return; + if (surface_orig == NULL) return; int width, height; int i; @@ -612,8 +632,9 @@ void GrpObj::UpdateDigit(void) { pic_parent->Root().DeleteSurface(surface_orig); } + void GrpObj::CreateGan(Event::Container& event, int event_number) { - if (picture == 0) { + if (picture == NULL) { fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); return; } @@ -626,7 +647,7 @@ void GrpObj::CreateGan(Event::Container& string path(gan_name); path += ".gan"; ARCINFO* info = file_searcher.Find(FILESEARCH::GAN, path.c_str(), "gan"); - if (info == 0) { + if (info == NULL) { fprintf(stderr,"GrpObj::CreateGan: Cannot Find 'GAN' file %s\n", path.c_str()); return; } @@ -678,9 +699,10 @@ void GrpObj::CreateGan(Event::Container& wid->SetPtn(); // パターン登録終了 attr = Attribute(attr | ANM_PLAYSTART); anm = wid; -}; +} + void GrpObj::CreateGanSpecial(Event::Container& event, int event_number, int time) { - if (picture == 0) { + if (picture == NULL) { fprintf(stderr,"GrpObj::CreateGan() is called before Create()\n"); return; } @@ -694,19 +716,18 @@ void GrpObj::CreateGanSpecial(Event::Con int i; switch(event_number) { - case 0: // pattern を 0 から最後まで変化させる - for (i=0; i<src_pos.size(); i++) { - wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); - } - wid->SetPtn(); // パターン登録終了 - anm = wid; - attr = Attribute(attr | ANM_PLAYSTART); - break; - default: - break; + case 0: // pattern を 0 から最後まで変化させる + for (i=0; i<src_pos.size(); i++) { + wid->ptns.push_back(AnmAlphaMove::Ptn(Rect(PosX(), PosY()), src_pos[i], 255, time*i)); + } + wid->SetPtn(); // パターン登録終了 + anm = wid; + attr = Attribute(attr | ANM_PLAYSTART); + break; + default: + break; } - return; -}; +} void GrpObj::SetZoomRotate(int new_zoom, int new_rotate) { if (zoom == new_zoom && rotate == new_rotate) return; @@ -720,7 +741,6 @@ void GrpObj::SetZoomRotate(int new_zoom, else if (rotate > 360) rotate %= 360; attr = Attribute(attr | UPDATE_PICTURE); - return; } /****************************************************************** ** @@ -746,6 +766,7 @@ ScnGrpMove::ScnGrpMove(Event::Container& if (dx == 0) dx = 1; SetAllCount(dx); } + void ScnGrpMove::Exec(int count) { Rect r(0,0,dest_r.width(),dest_r.height()); int dx = to.lx - from.lx; @@ -766,6 +787,7 @@ struct ScnGrpAnmAtom { int time; ScnGrpAnmAtom(const char* _n, int _t) : name(_n), time(_t) {} }; + struct ScnGrpAnm : public WidAnmTime, vector<ScnGrpAnmAtom> { GrpImpl& owner; ScnGrpAnm(Event::Container& container, PicBase* _pic, GrpImpl& _owner) : @@ -774,6 +796,7 @@ struct ScnGrpAnm : public WidAnmTime, ve void CalcTotal(void); void Exec(int count); }; + void ScnGrpAnm::CalcTotal(void) { /* total time を計算 */ if (empty()) return; @@ -783,6 +806,7 @@ void ScnGrpAnm::CalcTotal(void) { total_time = tm; SetAllCount(tm); } + void ScnGrpAnm::Exec(int count) { int tm = 0; vector<ScnGrpAnmAtom>::iterator it; for (it=begin(); it != end(); it++) { @@ -800,7 +824,7 @@ void ScnGrpAnm::Exec(int count) { * */ -#include"music2/music.h" +#include "music2/music.h" GrpImpl::GrpImpl(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm_data, class MuSys& _mu, AyuSysConfig& _config) : event(_event), @@ -869,7 +893,8 @@ Surface* GrpImpl::Dsurface(int pdt) { } return dsurface[pdt]; } -#include<SDL.h> + +#include <SDL.h> Surface* GrpImpl::Ssurface(int pdt) { if (pdt == 0) return surface; if (ssurface[pdt]) { @@ -884,7 +909,7 @@ void GrpImpl::LoadSurface(const char* st cgm_data.insert(cgm_info[s]); } Surface* bg = parent.Root().NewSurface(s.c_str()); - if (bg == 0) { + if (bg == NULL) { s += ".g00"; bg = parent.Root().NewSurface(s.c_str()); } @@ -899,7 +924,7 @@ void GrpImpl::LoadSurface(const char* st int y = (dr.height()-r.height())/2; DSurfaceMove(ssurface[0], r, surface, Rect(x,y)); parent.Root().DeleteSurface(ssurface[0]); - ssurface[0] = 0; + ssurface[0] = NULL; screen->SetSurface(surface, 0, 0); } } else { @@ -908,8 +933,11 @@ void GrpImpl::LoadSurface(const char* st } return; } + void GrpImpl::InitSel(AyuSysConfig& config) { - int i; int args[16]; char key[1024]; + int i; + int args[16]; + char key[1024]; for (i=0; i<999; i++) { sprintf(key, "#SEL.%03d",i); if (config.GetParam(key, 15, &args[0], &args[1], @@ -930,8 +958,8 @@ void GrpImpl::InitSel(AyuSysConfig& conf s.sel_no = args[7]; int j; for (j=0; j<8; j++) s.args[j] = args[8+j]; } - return; } + void GrpImpl::SetSkipMode(SkipMode _mode) { if ( (skip_mode & SKIP_IN_MENU) && (_mode & SKIP_IN_MENU) == 0) { RefreshObj(); @@ -939,9 +967,11 @@ void GrpImpl::SetSkipMode(SkipMode _mode } skip_mode = _mode; } + void GrpImpl::SetObjChanged(int num) { changed_obj.insert(num); } + void GrpImpl::SetObjChangedGroup(int num) { if (num % 1000 != 0) { SetObjChanged(num); @@ -954,6 +984,7 @@ void GrpImpl::SetObjChangedGroup(int num changed_obj.insert(it->first); } } + void GrpImpl::RefreshObj(void) { if (!deleted_pic.empty()) { vector<PicBase*>::iterator it; @@ -990,7 +1021,7 @@ void GrpImpl::RefreshObj(void) { } -#include<SDL.h> +#include <SDL.h> void GrpImpl::StartAnm(int type) { SEL sel; @@ -1006,11 +1037,11 @@ void GrpImpl::StartAnm(int type) { } else { sel = anmtype[type]; } - if (anm1) { + if (anm1 != NULL) { fprintf(stderr,"Warning: StartAnm() called before anm1 finished\n"); anm1->Abort(); delete anm1; - anm1 = 0; + anm1 = NULL; } map<int,GrpObj>::iterator it; // 現在表示中のobjectを消去 @@ -1073,16 +1104,18 @@ void GrpImpl::StartAnm(int type) { if (anm1) anm1->Play(); if (skip_mode & SKIP_GRP_NOEFFEC) AbortAnm(); } + void GrpImpl::StartShake(int total, const int* pattern) { if (anm2) { fprintf(stderr,"Warning: StartShake() called before another animation finished\n"); anm2->Abort(); delete anm2; - anm2 = 0; + anm2 = NULL; } if (skip_mode & SKIP_GRP_NOEFFEC) return; AnmAlphaMove* new_anm = new AnmAlphaMove(event, &parent); // shake screen では元画面の座標を揺らす - int i; int tm = 0; + int i; + int tm = 0; for (i=0; i<total; i+=3) { int x = pattern[i]; int y = pattern[i+1]; @@ -1094,17 +1127,18 @@ void GrpImpl::StartShake(int total, cons new_anm->Play(); anm2 = new_anm; } + void GrpImpl::AbortAnm(void) { - if (anm1 == 0) return; + if (anm1 == NULL) return; anm1->Abort(); delete anm1; - anm1 = 0; + anm1 = NULL; /* 画像効果終了 */ /* 古い画面への画像効果があれば消去 */ if (anm2 && anm2->pic[0] != screen) { anm2->Abort(); delete anm2; - anm2 = 0; + anm2 = NULL; } /* pdt1 -> pdt0 へコピー */ DSurfaceMove(dsurface[1], Rect(*dsurface[1]), surface, Rect(0,0)); @@ -1114,26 +1148,29 @@ void GrpImpl::AbortAnm(void) { RefreshObj(); return; } + void GrpImpl::LoadSurface(const char* str) { if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 LoadSurface(str, 1); bg_name = str; } + void GrpImpl::LoadSurface(void) { if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 LoadSurface(bg_name.c_str(), 1); } + void GrpImpl::AddSurface(const char* str) { if (anm1) AbortAnm(); // 前の描画が終わってなければ強制終了 LoadSurface(bg_name.c_str()); string s = str; Surface* front = parent.Root().NewSurface(s.c_str()); - if (front == 0) { + if (front == NULL) { s += ".g00"; front = parent.Root().NewSurface(s.c_str()); } - if (front) { + if (front != NULL) { parent.Root().BlitSurface(front, Rect(*front), Dsurface(1), Rect(0,0)); parent.Root().DeleteSurface(front); } else { @@ -1147,24 +1184,24 @@ void GrpImpl::CreateObj(int index) { GrpObj& g = grpobj[index]; g.CreateSurface(&parent); g.order = index; - if (g.picture == 0) return; // エラー:surface が存在しない + if (g.picture == NULL) return; // エラー:surface が存在しない g.picture->hide(); SetObjChanged(index); ZMoveObj(index); - return; } + void GrpImpl::ZMoveObj(int index) { std::map<int, GrpObj>::iterator cur = grpobj.find(index); if (cur == grpobj.end()) return; GrpObj& g = grpobj[index]; - if (g.picture == 0) return; + if (g.picture == NULL) return; // 自分より前に object があれば、その前に表示 // そうでなければ screen の前に表示 std::map<int, GrpObj>::iterator cur_backobj = grpobj.end(); std::map<int, GrpObj>::iterator it; for (it = grpobj.begin(); it != grpobj.end(); it++) { if (it == cur) continue; - if (it->second.picture == 0) continue; + if (it->second.picture == NULL) continue; if (it->second.order < g.order) { if (cur_backobj == grpobj.end()) { cur_backobj = it; @@ -1178,8 +1215,8 @@ void GrpImpl::ZMoveObj(int index) { } else { g.picture->ZMove(cur_backobj->second.picture); } - return; } + void GrpImpl::SwapObj(int index1, int index2) { // デフォルト値から order が変更されていた場合のみ、order は保存される // まずは両方のobjectをswap @@ -1221,10 +1258,10 @@ bool GrpImpl::Pressed(int x, int y, void* pointer) { // マウスクリックでキャンセル g->music.StopMovie(); if (g->status == WAIT_ANM) g->AbortAnm(); - if (g->status == WAIT_SHAKE && g->anm2 != 0) { + if (g->status == WAIT_SHAKE && g->anm2 != NULL) { g->anm2->Abort(); delete g->anm2; - g->anm2 = 0; + g->anm2 = NULL; } return false; // event deleted } @@ -1268,9 +1305,9 @@ static unsigned char decode_char[256] = void GrpImpl::LoadCgm(AyuSysConfig& config) { /* cgm ファイル読み込み */ const char* fname = config.GetParaStr("#CGTABLE_FILE"); - if (fname == 0) return; + if (fname == NULL) return; ARCINFO* info = file_searcher.Find(FILESEARCH::ALL, fname, ""); - if (info == 0) return; + if (info == NULL) return; char* data = info->CopyRead(); int sz = info->Size(); delete info; @@ -1282,9 +1319,9 @@ void GrpImpl::LoadCgm(AyuSysConfig& conf } cgm_size = read_little_endian_int(data+0x10); - int i,j; + int i, j; // xor 解除 - for (i=0;i<sz-0x20; i++) { + for (i=0; i < sz-0x20; i++) { data[i+0x20]^=decode_char[i&0xff]; } // 展開 @@ -1310,15 +1347,16 @@ void GrpImpl::LoadCgm(AyuSysConfig& conf */ void GrpImpl::Save(std::string& str) { } + void GrpImpl::Load(const char* str) { status = NORMAL; - if (anm1) { + if (anm1 != NULL) { AbortAnm(); } - if (anm2) { + if (anm2 != NULL) { anm2->Abort(); delete anm2; - anm2 = 0; + anm2 = NULL; } map<int,GrpObj>::iterator it; for (it=grpobj.begin(); it!=grpobj.end(); it++) { @@ -1330,6 +1368,7 @@ void GrpImpl::Load(const char* str) { bg_name = ""; music.StopCDROM(100); } + void GrpImpl::SaveSys(string& save) { char buf[1024]; save = "\n[Graphics]\n"; @@ -1342,6 +1381,7 @@ void GrpImpl::SaveSys(string& save) { } save += "\n"; } + void GrpImpl::LoadSys(const char* save) { cgm_data.clear(); save = strstr(save, "\n[Graphics]\n"); @@ -1435,15 +1475,15 @@ bool GrpImpl::Wait(unsigned int current_ } #endif if (status == WAIT_ANM) { - if (anm1) { + if (anm1 != NULL) { if (!anm1->IsEnd()) return true; AbortAnm(); } } else if (status == WAIT_SHAKE) { - if (anm2) { + if (anm2 != NULL) { if (!anm2->IsEnd()) return true; delete anm2; - anm2 = 0; + anm2 = NULL; } status = NORMAL; } else if (status == WAIT_SE) { @@ -1457,10 +1497,10 @@ bool GrpImpl::Wait(unsigned int current_ } return true; } - if (anm2) { + if (anm2 != NULL) { if (anm2->IsEnd()) { delete anm2; - anm2 = 0; + anm2 = NULL; } } return false; @@ -1470,11 +1510,13 @@ void GrpImpl::DeleteObjPic(int num) { // object の surface のみ削除 if (grpobj.find(num) == grpobj.end()) return; deleted_pic.push_back(grpobj[num].DeletePic()); } + void GrpImpl::DeleteObj(int num) { if (grpobj.find(num) == grpobj.end()) return; deleted_pic.push_back(grpobj[num].DeletePic()); grpobj.erase(num); } + void GrpImpl::DeleteObjRange(int num_first, int num_end) { std::map<int, GrpObj>::iterator begin,end,it; begin = grpobj.lower_bound(num_first); @@ -1484,6 +1526,7 @@ void GrpImpl::DeleteObjRange(int num_fir } grpobj.erase(begin, end); } + void GrpImpl::Exec(Cmd& cmd) { if (cmd.cmd_type == CMD_TEXTEND) { music.StopKoe(500); // テキスト終了で声を止める @@ -1926,11 +1969,11 @@ void GrpImpl::Exec(Cmd& cmd) { } else if (cmd.cmd2 == 0x49) { if (cmd.cmd3 == 0) { // アニメーションを強制終了 GrpObj& g = grpobj[cmd.args[0].value]; - if (g.anm == 0 || g.anm->IsEnd()) ; + if (g.anm == NULL || g.anm->IsEnd()) ; else g.anm->Abort(); } else if (cmd.cmd3 == 3) { // アニメーション中か? GrpObj& g = grpobj[cmd.args[0].value]; - if (g.anm == 0 || g.anm->IsEnd()) { + if (g.anm == NULL || g.anm->IsEnd()) { cmd.SetSysvar(0); } else { cmd.SetSysvar(1); @@ -1938,7 +1981,7 @@ void GrpImpl::Exec(Cmd& cmd) { } else if (cmd.cmd3 == 1000) { // アニメーションを途中で停止した状態にする GrpObj& g = grpobj[cmd.args[0].value]; - if (g.anm == 0 || g.anm->IsEnd()) { + if (g.anm == NULL || g.anm->IsEnd()) { // fprintf(stderr,"AnimPause : no animation in %d (%d)\n",cmd.args[0].value, cmd.args[1].value); g.SetSurfaceNum(cmd.args[1].value); } else { @@ -2277,7 +2320,8 @@ 487 / 8047 : unsupported command; 0x23 - Grp::Grp(Event::Container& _event, PicContainer& _parent, const Flags& f, set<int>& _cgm,class MuSys& mu, AyuSysConfig& config) { pimpl = new GrpImpl(_event, _parent, f, _cgm, mu, config); -}; +} + Grp::~Grp() { delete pimpl; } @@ -2285,15 +2329,19 @@ Grp::~Grp() { bool Grp::Wait(unsigned int current_time, Cmd& cmd) { return pimpl->Wait(current_time, cmd); } + void Grp::Exec(Cmd& cmd) { pimpl->Exec(cmd); } + void Grp::SetSkipMode(SkipMode mode) { pimpl->SetSkipMode(mode); } + void Grp::InitSel(AyuSysConfig& config) { pimpl->InitSel(config); } + void Grp::Save(std::string& str) { pimpl->Save(str); }