From: <geo...@us...> - 2004-01-04 22:07:03
|
Update of /cvsroot/timewarp/source/gamex/edit In directory sc8-pr-cvs1:/tmp/cvs-serv31200/gamex/edit Modified Files: edit_dialogue.cpp edit_dialogue.h Log Message: full-game source update Index: edit_dialogue.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/edit/edit_dialogue.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** edit_dialogue.cpp 14 Dec 2003 22:19:56 -0000 1.4 --- edit_dialogue.cpp 4 Jan 2004 22:07:00 -0000 1.5 *************** *** 12,15 **** --- 12,18 ---- + + static int current_dialog_version = 0; + // create a dialogue structure *************** *** 19,26 **** --- 22,32 ---- Ntriggers = 0; mother = 0; + id[0] = 0; } Dialo::~Dialo() { + // if you delete this thing, you also need to delete all the nodes following it. + discard_branches(); } *************** *** 47,50 **** --- 53,63 ---- fs->read(&version); + // depending on the version, you can tweak the stuff below, in case you're + // dealing with an important old dialog ... + if (version != current_dialog_version) + { + tw_error("version conversion is not yet supported"); + } + fs->read(&state); *************** *** 57,60 **** --- 70,75 ---- fs->initstring(racepic, sizeof(racepic)); + fs->initstring(id, sizeof(id)); + // also, read all the branches. int i; *************** *** 70,73 **** --- 85,90 ---- void Dialo::write(FileStore *fs) { + // write the new version. + version = current_dialog_version; fs->write(version); *************** *** 82,85 **** --- 99,104 ---- fs->writestring(racepic); + fs->writestring(id); + // also, write all the branches. int i; *************** *** 117,120 **** --- 136,140 ---- + // remove a branch, and all the branches following it... void Dialo::rembranch(int index) { *************** *** 138,143 **** ! Dialo dialo; --- 158,173 ---- + // discards all subnodes. + void Dialo::discard_branches() + { + int i; + for (i = 0; i < Nbranches; ++i) + { + delete branch[i]; + } + } + ! //Dialo dialo; *************** *** 149,165 **** void GameDialogue::init() { int i; scare_mouse(); GameBare::init(); ! double H = 2000; ! size = Vector2(H, H); prepare(); - // find somewhere a list of all the available race-dialogue bitmaps --- 179,235 ---- + void GameDialogue::init_dialog(char *fname) + { + if (fs) + delete fs; + + fs = new FileStore(fname); + + if (firstdialo) + delete firstdialo; + + firstdialo = new Dialo(); + + firstdialo->read(fs); + + dialo = firstdialo; + + // initialize the interface so that you can edit and navigate the dialog tree + initeditor(dialo); + } + + + void GameDialogue::save_dialog() + { + fs->seek(0); // you've to rewind the file first ... + firstdialo->write(fs); + } + + void GameDialogue::init() { + fs = 0; + dialo = 0; + firstdialo = 0; + int i; + if (!window) { + window = new VideoWindow(); + window->preinit(); + } + change_view("Hero"); + + wininfo.init( Vector2(800,800), 800.0, view->frame ); + wininfo.zoomlimit(size.x); + wininfo.scaletowidth(size.x); // zoom out to this width. + scare_mouse(); GameBare::init(); ! size = Vector2(100,100); prepare(); // find somewhere a list of all the available race-dialogue bitmaps *************** *** 188,201 **** Blist[i] = new char [32]; - // initialize dialogue data: - // question - - firstdialo = new Dialo(); - - fs = new FileStore("gamex/dialogue/test.dialogue2"); - firstdialo->read(fs); - - dialo = firstdialo; - // initialize menu system. --- 258,261 ---- *************** *** 219,227 **** - - - - - --- 279,282 ---- *************** *** 229,234 **** int tcol = makecol(255,255,128); ! //strcpy(Qtext, "a\n b\n c\n d\n e\n f\n g\n h\n i"); ! Tedit = new TextEditBox(T, "text/", usefont, dialo->T, 256); Tedit->set_textcolor(tcol); --- 284,288 ---- int tcol = makecol(255,255,128); ! Tedit = new TextEditBox(T, "text/", usefont, 0, 0); Tedit->set_textcolor(tcol); *************** *** 237,247 **** ! refresh = new Button(T, "refresh_", 0); Bplus = new Button(T, "addbranch_", 0); - // Bmin = new Button(R, "Bmin", 0); bprev = new Button(T, "prevbranch_", 0); - // bnext = new Button(R, "next", 0); dialostatus = new SwitchButton(T, "state_", 0); --- 291,301 ---- ! bload = new Button(T, "load_", 0); ! ! bsave = new Button(T, "save_", 0); Bplus = new Button(T, "addbranch_", 0); bprev = new Button(T, "prevbranch_", 0); dialostatus = new SwitchButton(T, "state_", 0); *************** *** 250,270 **** raceselect = new TextButton(T, "race_", usefont); - raceselect->set_text(dialo->racepic, makecol(255,255,0)); raceselect->passive = false; popupraceselect = new PopupList(raceselect, "gamex/interface/dialogeditor/raceselect", "text/", -20, -20, usefont, 0); popupraceselect->tbl->set_optionlist(racepiclist, Nracepiclist, makecol(255,255,128)); popupraceselect->hide(); ! //popupraceselect->setscreen(T->drawarea); - // winman = new WindowManager; - // winman->add(R); T->add(popupraceselect); T->tree_doneinit(); ! initeditor(dialo); // no need for tic-info. --- 304,339 ---- raceselect = new TextButton(T, "race_", usefont); raceselect->passive = false; + nodeid = new TextEditBox(T, "nodeid_", usefont, 0, 0); + nodeid->set_textcolor(tcol); + popupraceselect = new PopupList(raceselect, "gamex/interface/dialogeditor/raceselect", "text/", -20, -20, usefont, 0); popupraceselect->tbl->set_optionlist(racepiclist, Nracepiclist, makecol(255,255,128)); popupraceselect->hide(); ! ! fb = new FileBrowser(bload, "gamex/interface/filebrowser", 0, 0, usefont); ! fb->tbl->text_color = makecol(255,255,0); ! fb->set_dir("gamex/gamedata/races"); ! fb->set_ext("dialog"); T->add(popupraceselect); + T->add(fb); T->tree_doneinit(); ! ! // initialize dialogue data ! ! char fname[128]; ! strcpy(fname, "gamex/gamedata/races/"); ! strcat(fname, "earthling"); // the race name ! strcat(fname, "/"); ! strcat(fname, "test.dialog"); // the dialog name ! ! init_dialog(fname); ! // no need for tic-info. *************** *** 275,283 **** void GameDialogue::quit() { ! // update the changes in memory ! fs->seek(0); // you've to rewind the file first ... ! dialo->write(fs); ! delete fs; int i; --- 344,355 ---- void GameDialogue::quit() { ! // disable auto-save ? Cause you got a save-button for that... ! // save_dialog(); ! if (fs) ! delete fs; ! ! if (firstdialo) ! delete firstdialo; int i; *************** *** 293,299 **** set_mouse_sprite(0); // the default mouse sprite. show_mouse(screen); // ???????? - //show_mouse(); - GameBare::quit(); } --- 365,370 ---- set_mouse_sprite(0); // the default mouse sprite. show_mouse(screen); // ???????? + GameBare::quit(); } *************** *** 310,314 **** for ( i = 0; i < dialo->Nbranches; ++i ) { - //d.read(dialo.branch[i], &dstore); d = dialo->branch[i]; --- 381,384 ---- *************** *** 325,331 **** dialostatus->state = dialo->state; ! Tedit->text_reset(dialo->T); raceselect->set_text(dialo->racepic, makecol(255,255,0)); } --- 395,403 ---- dialostatus->state = dialo->state; ! Tedit->text_reset(dialo->T, Ntext); raceselect->set_text(dialo->racepic, makecol(255,255,0)); + + nodeid->text_reset(dialo->id, sizeof(dialo->id)); } *************** *** 336,358 **** return; ! GameBare::calculate(); ! ! ! //FULL_REDRAW = true; ! //R->tree_calculate(); ! ! ! /* ! // well... save the dialogue when needed (not to disk, but in memory). ! ! if (refresh->flag.left_mouse_press) ! { ! //dialo.write(); ! dialo.refresh(&dstore); ! ! initeditor(dialo); ! } ! */ --- 408,414 ---- return; ! wininfo.center(0.5*size); ! GameBare::calculate(); *************** *** 361,365 **** if (Bplus->flag.left_mouse_press) { - //dialo.write(&dstore); Dialo *d = new Dialo(); --- 417,420 ---- *************** *** 373,377 **** strcpy(d->racepic, dialo->racepic); // inherit info // well, this creates a new dialogue thingy :) - //d.write(&dstore); dialo->addbranch(d); --- 428,431 ---- *************** *** 391,399 **** // load the data from the mother branch (if it's has a mother). if (dialo->mother) ! { ! //dialo->write(&dstore); ! ! //dialo->read(dialo.mother, &dstore); ! dialo = dialo->mother; initeditor(dialo); --- 445,449 ---- // load the data from the mother branch (if it's has a mother). if (dialo->mother) ! { dialo = dialo->mother; initeditor(dialo); *************** *** 405,409 **** // go forth to the currently selected branch - //if (bnext->flag.left_mouse_press) if (Tlist->flag.left_mouse_press) { --- 455,458 ---- *************** *** 415,425 **** if (i >= 0 && i < dialo->Nbranches) // shouldn't be necessary ?! { - // write the current data. - //dialo.write(&dstore); - dialo = dialo->branch[i]; - - //dialo.read(k, &dstore); - initeditor(dialo); } --- 464,468 ---- *************** *** 447,450 **** --- 490,505 ---- + // check if a new file is selected + // then you load a existing file ... + if (fb->ready()) + { + init_dialog(fb->fname); + } + + if (bsave->flag.left_mouse_press) + { + save_dialog(); + } + } *************** *** 456,466 **** GameBare::animate(frame); - - - //show_mouse(frame->surface); - //T->tree_setscreen(view->frame->surface); - //T->tree_animate(); - //show_mouse(view->frame->surface); - //scare_mouse(); } --- 511,514 ---- Index: edit_dialogue.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/edit/edit_dialogue.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** edit_dialogue.h 14 Dec 2003 22:19:56 -0000 1.3 --- edit_dialogue.h 4 Jan 2004 22:07:00 -0000 1.4 *************** *** 43,46 **** --- 43,48 ---- char T[Ntext]; // text + char id[64]; + // text can also activate triggers ... but that's not supported yet ... *************** *** 54,57 **** --- 56,61 ---- Dialo *branch[maxbranches]; Dialo *mother; // the mother + + void discard_branches(); }; *************** *** 67,70 **** --- 71,76 ---- char *Blist[maxbranches]; + FileBrowser *fb; + virtual void init(); virtual void quit(); *************** *** 77,80 **** --- 83,88 ---- void initeditor(Dialo *dialo); + void init_dialog(char *fname); + void save_dialog(); int Nracepiclist; *************** *** 82,89 **** ! TextEditBox *Tedit; TextList *Tlist; ! Button *refresh, *Bplus, *bprev; SwitchButton *dialostatus; --- 90,97 ---- ! TextEditBox *Tedit, *nodeid; TextList *Tlist; ! Button *bload, *bsave, *Bplus, *bprev; SwitchButton *dialostatus; |