X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FConsoleCmds.cpp;h=a4cbfb52865cf050d5eb482ede321075fee7b721;hb=cc92cb7b7f9b87cb791c504bf930d622d74db368;hp=698c73bf2cc553ab052a636c8e810f75e38b5579;hpb=dcfcaa86f46665886448d5aa6766b39c9e1c01b8;p=lugaru.git diff --git a/Source/ConsoleCmds.cpp b/Source/ConsoleCmds.cpp index 698c73b..a4cbfb5 100644 --- a/Source/ConsoleCmds.cpp +++ b/Source/ConsoleCmds.cpp @@ -20,6 +20,7 @@ along with Lugaru. If not, see . #include "ConsoleCmds.h" #include "Game.h" +#include "Dialog.h" const char *cmd_names[cmd_count] = { #define DECLARE_COMMAND(cmd) #cmd, @@ -70,6 +71,8 @@ extern float viewdistance; extern int whichlevel; +float tintr = 1, tintg = 1, tintb = 1; + /* Helpers used in console commands */ /* Return true if PFX is a prefix of STR (case-insensitive). */ @@ -141,15 +144,17 @@ static void set_clothes(int pnum, const char *args) char buf[64]; snprintf(buf, 63, ":Data:Textures:%s.png", args); - if (!AddClothes(buf, &Person::players[pnum]->skeleton.skinText[0])) + int id = Person::players[pnum]->numclothes; + strcpy(Person::players[pnum]->clothes[id], buf); + Person::players[pnum]->clothestintr[id] = tintr; + Person::players[pnum]->clothestintg[id] = tintg; + Person::players[pnum]->clothestintb[id] = tintb; + Person::players[pnum]->numclothes++; + + if (!Person::players[pnum]->addClothes(id)) return; Person::players[pnum]->DoMipmaps(); - strcpy(Person::players[pnum]->clothes[Person::players[pnum]->numclothes], buf); - Person::players[pnum]->clothestintr[Person::players[pnum]->numclothes] = tintr; - Person::players[pnum]->clothestintg[Person::players[pnum]->numclothes] = tintg; - Person::players[pnum]->clothestintb[Person::players[pnum]->numclothes] = tintb; - Person::players[pnum]->numclothes++; } /* Console commands themselves */ @@ -196,48 +201,7 @@ void ch_save(const char *args) fpackf(tfile, "Bi Bi", Person::players[0]->whichskin, Person::players[0]->creature); - fpackf(tfile, "Bi", numdialogues); - - for (int k = 0; k < numdialogues; k++) { - fpackf(tfile, "Bi", numdialogueboxes[k]); - fpackf(tfile, "Bi", dialoguetype[k]); - for (int l = 0; l < 10; l++) { - fpackf(tfile, "Bf Bf Bf", participantlocation[k][l].x, participantlocation[k][l].y, participantlocation[k][l].z); - fpackf(tfile, "Bf", participantyaw[k][l]); - } - for (int l = 0; l < numdialogueboxes[k]; l++) { - fpackf(tfile, "Bi", dialogueboxlocation[k][l]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][0]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][1]); - fpackf(tfile, "Bf", dialogueboxcolor[k][l][2]); - fpackf(tfile, "Bi", dialogueboxsound[k][l]); - - int templength = strlen(dialoguetext[k][l]); - fpackf(tfile, "Bi", (templength)); - for (int m = 0; m < templength; m++) { - fpackf(tfile, "Bb", dialoguetext[k][l][m]); - if (dialoguetext[k][l][m] == '\0') - break; - } - - templength = strlen(dialoguename[k][l]); - fpackf(tfile, "Bi", templength); - for (int m = 0; m < templength; m++) { - fpackf(tfile, "Bb", dialoguename[k][l][m]); - if (dialoguename[k][l][m] == '\0') - break; - } - - fpackf(tfile, "Bf Bf Bf", dialoguecamera[k][l].x, dialoguecamera[k][l].y, dialoguecamera[k][l].z); - fpackf(tfile, "Bi", participantfocus[k][l]); - fpackf(tfile, "Bi", participantaction[k][l]); - - for (int m = 0; m < 10; m++) - fpackf(tfile, "Bf Bf Bf", participantfacing[k][l][m].x, participantfacing[k][l][m].y, participantfacing[k][l][m].z); - - fpackf(tfile, "Bf Bf", dialoguecamerayaw[k][l], dialoguecamerapitch[k][l]); - } - } + Dialog::saveDialogs(tfile); for (int k = 0; k < Person::players[0]->numclothes; k++) { int templength = strlen(Person::players[0]->clothes[k]); @@ -604,111 +568,46 @@ void ch_hs(const char *args) void ch_dialogue(const char *args) { - int dlg; - char buf1[32], buf2[64]; - - sscanf(args, "%d %31s", &dlg, buf1); - snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1); - - dialoguetype[numdialogues] = dlg; - - memset(dialoguetext[numdialogues], 0, sizeof(dialoguetext[numdialogues])); - memset(dialoguename[numdialogues], 0, sizeof(dialoguename[numdialogues])); - - ifstream ipstream(ConvertFileName(buf2)); - ipstream.ignore(256, ':'); - ipstream >> numdialogueboxes[numdialogues]; - for (int i = 0; i < numdialogueboxes[numdialogues]; i++) { - ipstream.ignore(256, ':'); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream >> dialogueboxlocation[numdialogues][i]; - ipstream.ignore(256, ':'); - ipstream >> dialogueboxcolor[numdialogues][i][0]; - ipstream >> dialogueboxcolor[numdialogues][i][1]; - ipstream >> dialogueboxcolor[numdialogues][i][2]; - ipstream.ignore(256, ':'); - ipstream.getline(dialoguename[numdialogues][i], 64); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream.getline(dialoguetext[numdialogues][i], 128); - for (int j = 0; j < 128; j++) { - if (dialoguetext[numdialogues][i][j] == '\\') - dialoguetext[numdialogues][i][j] = '\n'; - } - ipstream.ignore(256, ':'); - ipstream >> dialogueboxsound[numdialogues][i]; - } + int type; + char buf1[32], filename[64]; - for (int i = 0; i < numdialogueboxes[numdialogues]; i++) { - for (unsigned j = 0; j < Person::players.size(); j++) { - participantfacing[numdialogues][i][j] = Person::players[j]->facing; - } - } - ipstream.close(); + sscanf(args, "%d %31s", &type, buf1); + snprintf(filename, 63, ":Data:Dialogues:%s.txt", buf1); - directing = 1; - indialogue = 0; - whichdialogue = numdialogues; + Dialog::dialogs.push_back(Dialog(type, filename)); - numdialogues++; + Dialog::directing = true; + Dialog::indialogue = 0; + Dialog::whichdialogue = Dialog::dialogs.size(); } void ch_fixdialogue(const char *args) { - char buf1[32], buf2[64]; + char buf1[32], filename[64]; int whichdi; sscanf(args, "%d %31s", &whichdi, buf1); - snprintf(buf2, 63, ":Data:Dialogues:%s.txt", buf1); - - memset(dialoguetext[whichdi], 0, sizeof(dialoguetext[whichdi])); - memset(dialoguename[whichdi], 0, sizeof(dialoguename[whichdi])); - - ifstream ipstream(ConvertFileName(buf2)); - ipstream.ignore(256, ':'); - ipstream >> numdialogueboxes[whichdi]; - for (int i = 0; i < numdialogueboxes[whichdi]; i++) { - ipstream.ignore(256, ':'); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream >> dialogueboxlocation[whichdi][i]; - ipstream.ignore(256, ':'); - ipstream >> dialogueboxcolor[whichdi][i][0]; - ipstream >> dialogueboxcolor[whichdi][i][1]; - ipstream >> dialogueboxcolor[whichdi][i][2]; - ipstream.ignore(256, ':'); - ipstream.getline(dialoguename[whichdi][i], 64); - ipstream.ignore(256, ':'); - ipstream.ignore(256, ' '); - ipstream.getline(dialoguetext[whichdi][i], 128); - for (int j = 0; j < 128; j++) { - if (dialoguetext[whichdi][i][j] == '\\') - dialoguetext[whichdi][i][j] = '\n'; - } - ipstream.ignore(256, ':'); - ipstream >> dialogueboxsound[whichdi][i]; - } + snprintf(filename, 63, ":Data:Dialogues:%s.txt", buf1); - ipstream.close(); + Dialog::dialogs[whichdi] = Dialog(Dialog::dialogs[whichdi].type, filename); } void ch_fixtype(const char *args) { int dlg; sscanf(args, "%d", &dlg); - dialoguetype[0] = dlg; + Dialog::dialogs[0].type = dlg; } void ch_fixrotation(const char *args) { - participantyaw[whichdialogue][participantfocus[whichdialogue][indialogue]] = Person::players[participantfocus[whichdialogue][indialogue]]->yaw; + int playerId = Dialog::currentScene().participantfocus; + Dialog::currentDialog().participantyaw[playerId] = Person::players[playerId]->yaw; } void ch_ddialogue(const char *args) { - if (numdialogues) - numdialogues--; + Dialog::dialogs.pop_back(); } void ch_dhs(const char *args) @@ -774,24 +673,13 @@ void ch_play(const char *args) { int dlg; sscanf(args, "%d", &dlg); - whichdialogue = dlg; + Dialog::whichdialogue = dlg; - if (whichdialogue >= numdialogues) + if (Dialog::whichdialogue >= Dialog::dialogs.size()) { return; - - for (int i = 0; i < numdialogueboxes[whichdialogue]; i++) { - Person::players[participantfocus[whichdialogue][i]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][i]]; - Person::players[participantfocus[whichdialogue][i]]->velocity = 0; - Person::players[participantfocus[whichdialogue][i]]->animTarget = Person::players[participantfocus[whichdialogue][i]]->getIdle(); - Person::players[participantfocus[whichdialogue][i]]->frameTarget = 0; } - directing = 0; - indialogue = 0; - - playdialogueboxsound(); + Dialog::currentDialog().play(); } void ch_mapkilleveryone(const char *args)