1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-22 08:49:46 +01:00

Unindent scriptclass::loadcustom() from previous commit

The actual unindent is done in a separate commit to minimize noise,
because diffs are terrible at clearly conveying unindents (it should put
all the minus lines together and all the plus lines together, too).
This commit is contained in:
Misa 2020-06-11 17:38:43 -07:00 committed by Ethan Lee
parent 6e0119d753
commit 7150c9ef2d

View file

@ -3568,263 +3568,263 @@ void scriptclass::loadcustom(std::string t)
return; return;
} }
std::vector<std::string>& lines = *contents; std::vector<std::string>& lines = *contents;
//Ok, we've got the relavent script segment, we do a pass to assess it, then run it! //Ok, we've got the relavent script segment, we do a pass to assess it, then run it!
int customcutscenemode=0; int customcutscenemode=0;
for(size_t i=0; i<lines.size(); i++){ for(size_t i=0; i<lines.size(); i++){
tokenize(lines[i]); tokenize(lines[i]);
if(words[0] == "say"){ if(words[0] == "say"){
customcutscenemode=1; customcutscenemode=1;
}else if(words[0] == "reply"){ }else if(words[0] == "reply"){
customcutscenemode=1; customcutscenemode=1;
}
}
if(customcutscenemode==1){
add("cutscene()");
add("untilbars()");
}
int customtextmode=0;
int speakermode=0; //0, terminal, numbers for crew
int squeakmode=0;//default on
//Now run the script
for(size_t i=0; i<lines.size(); i++){
words[0]="nothing"; //Default!
words[1]="1"; //Default!
tokenize(lines[i]);
std::transform(words[0].begin(), words[0].end(), words[0].begin(), ::tolower);
if(words[0] == "music"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(words[1]=="0"){
tstring="stopmusic()";
}else{
if(words[1]=="11"){ tstring="play(14)";
}else if(words[1]=="10"){ tstring="play(13)";
}else if(words[1]=="9"){ tstring="play(12)";
}else if(words[1]=="8"){ tstring="play(11)";
}else if(words[1]=="7"){ tstring="play(10)";
}else if(words[1]=="6"){ tstring="play(8)";
}else if(words[1]=="5"){ tstring="play(6)";
}else { tstring="play("+words[1]+")"; }
} }
} add(tstring);
}else if(words[0] == "playremix"){
if(customcutscenemode==1){ add("play(15)");
add("cutscene()"); }else if(words[0] == "flash"){
add("untilbars()"); if(customtextmode==1){ add("endtext"); customtextmode=0;}
} add("flash(5)");
int customtextmode=0; add("shake(20)");
int speakermode=0; //0, terminal, numbers for crew add("playef(9)");
int squeakmode=0;//default on }else if(words[0] == "sad" || words[0] == "cry"){
//Now run the script if(customtextmode==1){ add("endtext"); customtextmode=0;}
for(size_t i=0; i<lines.size(); i++){ if(words[1]=="player"){
words[0]="nothing"; //Default! add("changemood(player,1)");
words[1]="1"; //Default! }else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){
tokenize(lines[i]); add("changecustommood(customcyan,1)");
std::transform(words[0].begin(), words[0].end(), words[0].begin(), ::tolower); }else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){
if(words[0] == "music"){ add("changecustommood(purple,1)");
if(customtextmode==1){ add("endtext"); customtextmode=0;} }else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){
if(words[1]=="0"){ add("changecustommood(yellow,1)");
tstring="stopmusic()"; }else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){
}else{ add("changecustommood(red,1)");
if(words[1]=="11"){ tstring="play(14)"; }else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){
}else if(words[1]=="10"){ tstring="play(13)"; add("changecustommood(green,1)");
}else if(words[1]=="9"){ tstring="play(12)"; }else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){
}else if(words[1]=="8"){ tstring="play(11)"; add("changecustommood(blue,1)");
}else if(words[1]=="7"){ tstring="play(10)"; }else if(words[1]=="all" || words[1]=="everybody" || words[1]=="everyone"){
}else if(words[1]=="6"){ tstring="play(8)"; add("changemood(player,1)");
}else if(words[1]=="5"){ tstring="play(6)"; add("changecustommood(customcyan,1)");
}else { tstring="play("+words[1]+")"; } add("changecustommood(purple,1)");
} add("changecustommood(yellow,1)");
add(tstring); add("changecustommood(red,1)");
}else if(words[0] == "playremix"){ add("changecustommood(green,1)");
add("play(15)"); add("changecustommood(blue,1)");
}else if(words[0] == "flash"){ }else{
if(customtextmode==1){ add("endtext"); customtextmode=0;} add("changemood(player,1)");
add("flash(5)"); }
add("shake(20)"); if(squeakmode==0) add("squeak(cry)");
add("playef(9)"); }else if(words[0] == "happy"){
}else if(words[0] == "sad" || words[0] == "cry"){ if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(customtextmode==1){ add("endtext"); customtextmode=0;} if(words[1]=="player"){
if(words[1]=="player"){ add("changemood(player,0)");
add("changemood(player,1)"); if(squeakmode==0) add("squeak(player)");
}else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){ }else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){
add("changecustommood(customcyan,1)"); add("changecustommood(customcyan,0)");
}else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){ if(squeakmode==0) add("squeak(player)");
add("changecustommood(purple,1)"); }else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){
}else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){ add("changecustommood(purple,0)");
add("changecustommood(yellow,1)"); if(squeakmode==0) add("squeak(purple)");
}else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){ }else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){
add("changecustommood(red,1)"); add("changecustommood(yellow,0)");
}else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){ if(squeakmode==0) add("squeak(yellow)");
add("changecustommood(green,1)"); }else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){
}else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){ add("changecustommood(red,0)");
add("changecustommood(blue,1)"); if(squeakmode==0) add("squeak(red)");
}else if(words[1]=="all" || words[1]=="everybody" || words[1]=="everyone"){ }else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){
add("changemood(player,1)"); add("changecustommood(green,0)");
add("changecustommood(customcyan,1)"); if(squeakmode==0) add("squeak(green)");
add("changecustommood(purple,1)"); }else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){
add("changecustommood(yellow,1)"); add("changecustommood(blue,0)");
add("changecustommood(red,1)"); if(squeakmode==0) add("squeak(blue)");
add("changecustommood(green,1)"); }else if(words[1]=="all" || words[1]=="everybody" || words[1]=="everyone"){
add("changecustommood(blue,1)"); add("changemood(player,0)");
}else{ add("changecustommood(customcyan,0)");
add("changemood(player,1)"); add("changecustommood(purple,0)");
} add("changecustommood(yellow,0)");
if(squeakmode==0) add("squeak(cry)"); add("changecustommood(red,0)");
}else if(words[0] == "happy"){ add("changecustommood(green,0)");
if(customtextmode==1){ add("endtext"); customtextmode=0;} add("changecustommood(blue,0)");
if(words[1]=="player"){ }else{
add("changemood(player,0)"); add("changemood(player,0)");
if(squeakmode==0) add("squeak(player)");
}else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){
add("changecustommood(customcyan,0)");
if(squeakmode==0) add("squeak(player)");
}else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){
add("changecustommood(purple,0)");
if(squeakmode==0) add("squeak(purple)");
}else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){
add("changecustommood(yellow,0)");
if(squeakmode==0) add("squeak(yellow)");
}else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){
add("changecustommood(red,0)");
if(squeakmode==0) add("squeak(red)");
}else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){
add("changecustommood(green,0)");
if(squeakmode==0) add("squeak(green)");
}else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){
add("changecustommood(blue,0)");
if(squeakmode==0) add("squeak(blue)");
}else if(words[1]=="all" || words[1]=="everybody" || words[1]=="everyone"){
add("changemood(player,0)");
add("changecustommood(customcyan,0)");
add("changecustommood(purple,0)");
add("changecustommood(yellow,0)");
add("changecustommood(red,0)");
add("changecustommood(green,0)");
add("changecustommood(blue,0)");
}else{
add("changemood(player,0)");
if(squeakmode==0) add("squeak(player)");
}
}else if(words[0] == "squeak"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(words[1]=="player"){
add("squeak(player)");
}else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){
add("squeak(player)");
}else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){
add("squeak(purple)");
}else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){
add("squeak(yellow)");
}else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){
add("squeak(red)");
}else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){
add("squeak(green)");
}else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){
add("squeak(blue)");
}else if(words[1]=="cry" || words[1]=="sad"){
add("squeak(cry)");
}else if(words[1]=="on"){
squeakmode=0;
}else if(words[1]=="off"){
squeakmode=1;
}
}else if(words[0] == "delay"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "flag"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "map"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "warpdir"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "ifwarp"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "iftrinkets"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "ifflag"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "iftrinketsless"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "destroy"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(words[1]=="gravitylines"){
add("destroy(gravitylines)");
}else if(words[1]=="warptokens"){
add("destroy(warptokens)");
}else if(words[1]=="platforms"){
add("destroy(platforms)");
}
}else if(words[0] == "speaker"){
speakermode=0;
if(words[1]=="gray" || words[1]=="grey" || words[1]=="terminal" || words[1]=="0") speakermode=0;
if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="player" || words[1]=="1") speakermode=1;
if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2") speakermode=2;
if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3") speakermode=3;
if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4") speakermode=4;
if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5") speakermode=5;
if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6") speakermode=6;
}else if(words[0] == "say"){
//Speakers!
if(words[2]=="terminal" || words[2]=="gray" || words[2]=="grey" || words[2]=="0") speakermode=0;
if(words[2]=="cyan" || words[2]=="viridian" || words[2]=="player" || words[2]=="1") speakermode=1;
if(words[2]=="purple" || words[2]=="violet" || words[2]=="pink" || words[2]=="2") speakermode=2;
if(words[2]=="yellow" || words[2]=="vitellary" || words[2]=="3") speakermode=3;
if(words[2]=="red" || words[2]=="vermilion" || words[2]=="4") speakermode=4;
if(words[2]=="green" || words[2]=="verdigris" || words[2]=="5") speakermode=5;
if(words[2]=="blue" || words[2]=="victoria" || words[2]=="6") speakermode=6;
switch(speakermode){
case 0:
if(squeakmode==0) add("squeak(terminal)");
add("text(gray,0,114,"+words[1]+")");
break;
case 1: //NOT THE PLAYER
if(squeakmode==0) add("squeak(cyan)");
add("text(cyan,0,0,"+words[1]+")");
break;
case 2:
if(squeakmode==0) add("squeak(purple)");
add("text(purple,0,0,"+words[1]+")");
break;
case 3:
if(squeakmode==0) add("squeak(yellow)");
add("text(yellow,0,0,"+words[1]+")");
break;
case 4:
if(squeakmode==0) add("squeak(red)");
add("text(red,0,0,"+words[1]+")");
break;
case 5:
if(squeakmode==0) add("squeak(green)");
add("text(green,0,0,"+words[1]+")");
break;
case 6:
if(squeakmode==0) add("squeak(blue)");
add("text(blue,0,0,"+words[1]+")");
break;
}
int ti=atoi(words[1].c_str());
int nti = ti>=0 && ti<=50 ? ti : 1;
for(int ti2=0; ti2<nti; ti2++){
i++;
if(i < lines.size()){
add(lines[i]);
}
}
switch(speakermode){
case 0: add("customposition(center)"); break;
case 1: add("customposition(cyan,above)"); break;
case 2: add("customposition(purple,above)"); break;
case 3: add("customposition(yellow,above)"); break;
case 4: add("customposition(red,above)"); break;
case 5: add("customposition(green,above)"); break;
case 6: add("customposition(blue,above)"); break;
}
add("speak_active");
customtextmode=1;
}else if(words[0] == "reply"){
//For this version, terminal only
if(squeakmode==0) add("squeak(player)"); if(squeakmode==0) add("squeak(player)");
add("text(cyan,0,0,"+words[1]+")");
int ti=atoi(words[1].c_str());
int nti = ti>=0 && ti<=50 ? ti : 1;
for(int ti2=0; ti2<nti; ti2++){
i++;
if(i < lines.size()){
add(lines[i]);
}
}
add("position(player,above)");
add("speak_active");
customtextmode=1;
} }
} }else if(words[0] == "squeak"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(words[1]=="player"){
add("squeak(player)");
}else if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="1"){
add("squeak(player)");
}else if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2"){
add("squeak(purple)");
}else if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3"){
add("squeak(yellow)");
}else if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4"){
add("squeak(red)");
}else if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5"){
add("squeak(green)");
}else if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6"){
add("squeak(blue)");
}else if(words[1]=="cry" || words[1]=="sad"){
add("squeak(cry)");
}else if(words[1]=="on"){
squeakmode=0;
}else if(words[1]=="off"){
squeakmode=1;
}
}else if(words[0] == "delay"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "flag"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "map"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "warpdir"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "ifwarp"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add(lines[i]);
}else if(words[0] == "iftrinkets"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "ifflag"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "iftrinketsless"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
add("custom"+lines[i]);
}else if(words[0] == "destroy"){
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(words[1]=="gravitylines"){
add("destroy(gravitylines)");
}else if(words[1]=="warptokens"){
add("destroy(warptokens)");
}else if(words[1]=="platforms"){
add("destroy(platforms)");
}
}else if(words[0] == "speaker"){
speakermode=0;
if(words[1]=="gray" || words[1]=="grey" || words[1]=="terminal" || words[1]=="0") speakermode=0;
if(words[1]=="cyan" || words[1]=="viridian" || words[1]=="player" || words[1]=="1") speakermode=1;
if(words[1]=="purple" || words[1]=="violet" || words[1]=="pink" || words[1]=="2") speakermode=2;
if(words[1]=="yellow" || words[1]=="vitellary" || words[1]=="3") speakermode=3;
if(words[1]=="red" || words[1]=="vermilion" || words[1]=="4") speakermode=4;
if(words[1]=="green" || words[1]=="verdigris" || words[1]=="5") speakermode=5;
if(words[1]=="blue" || words[1]=="victoria" || words[1]=="6") speakermode=6;
}else if(words[0] == "say"){
//Speakers!
if(words[2]=="terminal" || words[2]=="gray" || words[2]=="grey" || words[2]=="0") speakermode=0;
if(words[2]=="cyan" || words[2]=="viridian" || words[2]=="player" || words[2]=="1") speakermode=1;
if(words[2]=="purple" || words[2]=="violet" || words[2]=="pink" || words[2]=="2") speakermode=2;
if(words[2]=="yellow" || words[2]=="vitellary" || words[2]=="3") speakermode=3;
if(words[2]=="red" || words[2]=="vermilion" || words[2]=="4") speakermode=4;
if(words[2]=="green" || words[2]=="verdigris" || words[2]=="5") speakermode=5;
if(words[2]=="blue" || words[2]=="victoria" || words[2]=="6") speakermode=6;
switch(speakermode){
case 0:
if(squeakmode==0) add("squeak(terminal)");
add("text(gray,0,114,"+words[1]+")");
break;
case 1: //NOT THE PLAYER
if(squeakmode==0) add("squeak(cyan)");
add("text(cyan,0,0,"+words[1]+")");
break;
case 2:
if(squeakmode==0) add("squeak(purple)");
add("text(purple,0,0,"+words[1]+")");
break;
case 3:
if(squeakmode==0) add("squeak(yellow)");
add("text(yellow,0,0,"+words[1]+")");
break;
case 4:
if(squeakmode==0) add("squeak(red)");
add("text(red,0,0,"+words[1]+")");
break;
case 5:
if(squeakmode==0) add("squeak(green)");
add("text(green,0,0,"+words[1]+")");
break;
case 6:
if(squeakmode==0) add("squeak(blue)");
add("text(blue,0,0,"+words[1]+")");
break;
}
int ti=atoi(words[1].c_str());
int nti = ti>=0 && ti<=50 ? ti : 1;
for(int ti2=0; ti2<nti; ti2++){
i++;
if(i < lines.size()){
add(lines[i]);
}
}
if(customtextmode==1){ add("endtext"); customtextmode=0;} switch(speakermode){
if(customcutscenemode==1){ case 0: add("customposition(center)"); break;
add("endcutscene()"); case 1: add("customposition(cyan,above)"); break;
add("untilbars()"); case 2: add("customposition(purple,above)"); break;
case 3: add("customposition(yellow,above)"); break;
case 4: add("customposition(red,above)"); break;
case 5: add("customposition(green,above)"); break;
case 6: add("customposition(blue,above)"); break;
}
add("speak_active");
customtextmode=1;
}else if(words[0] == "reply"){
//For this version, terminal only
if(squeakmode==0) add("squeak(player)");
add("text(cyan,0,0,"+words[1]+")");
int ti=atoi(words[1].c_str());
int nti = ti>=0 && ti<=50 ? ti : 1;
for(int ti2=0; ti2<nti; ti2++){
i++;
if(i < lines.size()){
add(lines[i]);
}
}
add("position(player,above)");
add("speak_active");
customtextmode=1;
} }
}
if(customtextmode==1){ add("endtext"); customtextmode=0;}
if(customcutscenemode==1){
add("endcutscene()");
add("untilbars()");
}
} }