mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- some preparations of the Strife dialogue data to make it usable for ZScript, most importantly this means to replace all const char * with FString.
This commit is contained in:
parent
2440951811
commit
b1a7941414
3 changed files with 35 additions and 38 deletions
|
@ -347,7 +347,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeaker
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the rest of the data to our own internal format.
|
// Convert the rest of the data to our own internal format.
|
||||||
node->Dialogue = ncopystring (speech.Dialogue);
|
node->Dialogue = speech.Dialogue;
|
||||||
|
|
||||||
// The speaker's portrait, if any.
|
// The speaker's portrait, if any.
|
||||||
speech.Dialogue[0] = 0; //speech.Backdrop[8] = 0;
|
speech.Dialogue[0] = 0; //speech.Backdrop[8] = 0;
|
||||||
|
@ -360,7 +360,7 @@ static FStrifeDialogueNode *ReadRetailNode (FileReader *lump, DWORD &prevSpeaker
|
||||||
|
|
||||||
// The speaker's name, if any.
|
// The speaker's name, if any.
|
||||||
speech.Sound[0] = 0; //speech.Name[16] = 0;
|
speech.Sound[0] = 0; //speech.Name[16] = 0;
|
||||||
node->SpeakerName = ncopystring(speech.Name);
|
node->SpeakerName = speech.Name;
|
||||||
|
|
||||||
// The item the speaker should drop when killed.
|
// The item the speaker should drop when killed.
|
||||||
node->DropType = dyn_cast<PClassActor>(GetStrifeType(speech.DropType));
|
node->DropType = dyn_cast<PClassActor>(GetStrifeType(speech.DropType));
|
||||||
|
@ -422,7 +422,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeaker
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert the rest of the data to our own internal format.
|
// Convert the rest of the data to our own internal format.
|
||||||
node->Dialogue = ncopystring (speech.Dialogue);
|
node->Dialogue = speech.Dialogue;
|
||||||
|
|
||||||
// The Teaser version doesn't have portraits.
|
// The Teaser version doesn't have portraits.
|
||||||
node->Backdrop.SetInvalid();
|
node->Backdrop.SetInvalid();
|
||||||
|
@ -440,7 +440,7 @@ static FStrifeDialogueNode *ReadTeaserNode (FileReader *lump, DWORD &prevSpeaker
|
||||||
|
|
||||||
// The speaker's name, if any.
|
// The speaker's name, if any.
|
||||||
speech.Dialogue[0] = 0; //speech.Name[16] = 0;
|
speech.Dialogue[0] = 0; //speech.Name[16] = 0;
|
||||||
node->SpeakerName = ncopystring (speech.Name);
|
node->SpeakerName = speech.Name;
|
||||||
|
|
||||||
// The item the speaker should drop when killed.
|
// The item the speaker should drop when killed.
|
||||||
node->DropType = dyn_cast<PClassActor>(GetStrifeType (speech.DropType));
|
node->DropType = dyn_cast<PClassActor>(GetStrifeType (speech.DropType));
|
||||||
|
@ -505,7 +505,7 @@ static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses)
|
||||||
|
|
||||||
// The message to record in the log for this reply.
|
// The message to record in the log for this reply.
|
||||||
reply->LogNumber = rsp->Log;
|
reply->LogNumber = rsp->Log;
|
||||||
reply->LogString = NULL;
|
reply->LogString = "";
|
||||||
|
|
||||||
// The item to receive when this reply is used.
|
// The item to receive when this reply is used.
|
||||||
reply->GiveType = dyn_cast<PClassActor>(GetStrifeType (rsp->GiveType));
|
reply->GiveType = dyn_cast<PClassActor>(GetStrifeType (rsp->GiveType));
|
||||||
|
@ -520,31 +520,32 @@ static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses)
|
||||||
reply->ItemCheck[k].Item = inv;
|
reply->ItemCheck[k].Item = inv;
|
||||||
reply->ItemCheck[k].Amount = rsp->Count[k];
|
reply->ItemCheck[k].Amount = rsp->Count[k];
|
||||||
}
|
}
|
||||||
|
reply->PrintAmount = reply->ItemCheck[0].Amount;
|
||||||
reply->ItemCheckRequire.Clear();
|
reply->ItemCheckRequire.Clear();
|
||||||
reply->ItemCheckExclude.Clear();
|
reply->ItemCheckExclude.Clear();
|
||||||
|
|
||||||
// If the first item check has a positive amount required, then
|
// If the first item check has a positive amount required, then
|
||||||
// add that to the reply string. Otherwise, use the reply as-is.
|
// add that to the reply string. Otherwise, use the reply as-is.
|
||||||
reply->Reply = copystring (rsp->Reply);
|
reply->Reply = rsp->Reply;
|
||||||
reply->NeedsGold = (rsp->Count[0] > 0);
|
reply->NeedsGold = (rsp->Count[0] > 0);
|
||||||
|
|
||||||
// QuickYes messages are shown when you meet the item checks.
|
// QuickYes messages are shown when you meet the item checks.
|
||||||
// QuickNo messages are shown when you don't.
|
// QuickNo messages are shown when you don't.
|
||||||
if (rsp->Yes[0] == '_' && rsp->Yes[1] == 0)
|
if (rsp->Yes[0] == '_' && rsp->Yes[1] == 0)
|
||||||
{
|
{
|
||||||
reply->QuickYes = NULL;
|
reply->QuickYes = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reply->QuickYes = ncopystring (rsp->Yes);
|
reply->QuickYes = rsp->Yes;
|
||||||
}
|
}
|
||||||
if (reply->ItemCheck[0].Item != 0)
|
if (reply->ItemCheck[0].Item != 0)
|
||||||
{
|
{
|
||||||
reply->QuickNo = ncopystring (rsp->No);
|
reply->QuickNo = rsp->No;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reply->QuickNo = NULL;
|
reply->QuickNo = "";
|
||||||
}
|
}
|
||||||
reply->Next = *replyptr;
|
reply->Next = *replyptr;
|
||||||
*replyptr = reply;
|
*replyptr = reply;
|
||||||
|
@ -560,9 +561,6 @@ static void ParseReplies (FStrifeDialogueReply **replyptr, Response *responses)
|
||||||
|
|
||||||
FStrifeDialogueNode::~FStrifeDialogueNode ()
|
FStrifeDialogueNode::~FStrifeDialogueNode ()
|
||||||
{
|
{
|
||||||
if (SpeakerName != NULL) delete[] SpeakerName;
|
|
||||||
if (Dialogue != NULL) delete[] Dialogue;
|
|
||||||
if (Goodbye != nullptr) delete[] Goodbye;
|
|
||||||
FStrifeDialogueReply *tokill = Children;
|
FStrifeDialogueReply *tokill = Children;
|
||||||
while (tokill != NULL)
|
while (tokill != NULL)
|
||||||
{
|
{
|
||||||
|
@ -580,9 +578,6 @@ FStrifeDialogueNode::~FStrifeDialogueNode ()
|
||||||
|
|
||||||
FStrifeDialogueReply::~FStrifeDialogueReply ()
|
FStrifeDialogueReply::~FStrifeDialogueReply ()
|
||||||
{
|
{
|
||||||
if (Reply != NULL) delete[] Reply;
|
|
||||||
if (QuickYes != NULL) delete[] QuickYes;
|
|
||||||
if (QuickNo != NULL) delete[] QuickNo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -672,7 +667,7 @@ CUSTOM_CVAR(Float, dlg_musicvolume, 1.0f, CVAR_ARCHIVE)
|
||||||
|
|
||||||
static bool ShouldSkipReply(FStrifeDialogueReply *reply, player_t *player)
|
static bool ShouldSkipReply(FStrifeDialogueReply *reply, player_t *player)
|
||||||
{
|
{
|
||||||
if (reply->Reply == nullptr)
|
if (reply->Reply.IsEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -772,7 +767,7 @@ public:
|
||||||
ReplyText = GStrings(ReplyText + 1);
|
ReplyText = GStrings(ReplyText + 1);
|
||||||
}
|
}
|
||||||
FString ReplyString = ReplyText;
|
FString ReplyString = ReplyText;
|
||||||
if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->ItemCheck[0].Amount);
|
if (reply->NeedsGold) ReplyString.AppendFormat(" for %u", reply->PrintAmount);
|
||||||
|
|
||||||
FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyString);
|
FBrokenLines *ReplyLines = V_BreakLines (SmallFont, 320-50-10, ReplyString);
|
||||||
|
|
||||||
|
@ -785,7 +780,7 @@ public:
|
||||||
V_FreeBrokenLines (ReplyLines);
|
V_FreeBrokenLines (ReplyLines);
|
||||||
}
|
}
|
||||||
const char *goodbyestr = CurNode->Goodbye;
|
const char *goodbyestr = CurNode->Goodbye;
|
||||||
if (goodbyestr == nullptr)
|
if (*goodbyestr == 0)
|
||||||
{
|
{
|
||||||
char goodbye[25];
|
char goodbye[25];
|
||||||
mysnprintf(goodbye, countof(goodbye), "TXT_RANDOMGOODBYE_%d", 1 + (pr_randomspeech() % NUM_RANDOM_GOODBYES));
|
mysnprintf(goodbye, countof(goodbye), "TXT_RANDOMGOODBYE_%d", 1 + (pr_randomspeech() % NUM_RANDOM_GOODBYES));
|
||||||
|
@ -1012,7 +1007,7 @@ public:
|
||||||
linesize = 10 * CleanYfac;
|
linesize = 10 * CleanYfac;
|
||||||
|
|
||||||
// Who is talking to you?
|
// Who is talking to you?
|
||||||
if (CurNode->SpeakerName != NULL)
|
if (CurNode->SpeakerName.IsNotEmpty())
|
||||||
{
|
{
|
||||||
speakerName = CurNode->SpeakerName;
|
speakerName = CurNode->SpeakerName;
|
||||||
if (speakerName[0] == '$') speakerName = GStrings(speakerName+1);
|
if (speakerName[0] == '$') speakerName = GStrings(speakerName+1);
|
||||||
|
@ -1315,7 +1310,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
|
||||||
if (!CheckStrifeItem(player, reply->ItemCheck[i].Item, reply->ItemCheck[i].Amount))
|
if (!CheckStrifeItem(player, reply->ItemCheck[i].Item, reply->ItemCheck[i].Amount))
|
||||||
{
|
{
|
||||||
// No, you don't. Say so and let the NPC animate negatively.
|
// No, you don't. Say so and let the NPC animate negatively.
|
||||||
if (reply->QuickNo && isconsole)
|
if (reply->QuickNo.IsNotEmpty() && isconsole)
|
||||||
{
|
{
|
||||||
TerminalResponse(reply->QuickNo);
|
TerminalResponse(reply->QuickNo);
|
||||||
}
|
}
|
||||||
|
@ -1396,7 +1391,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the quest log, if needed.
|
// Update the quest log, if needed.
|
||||||
if (reply->LogString != NULL)
|
if (reply->LogString.IsNotEmpty())
|
||||||
{
|
{
|
||||||
const char *log = reply->LogString;
|
const char *log = reply->LogString;
|
||||||
if (log[0] == '$')
|
if (log[0] == '$')
|
||||||
|
|
|
@ -26,11 +26,11 @@ struct FStrifeDialogueNode
|
||||||
int ItemCheckNode; // index into StrifeDialogues
|
int ItemCheckNode; // index into StrifeDialogues
|
||||||
|
|
||||||
PClassActor *SpeakerType;
|
PClassActor *SpeakerType;
|
||||||
char *SpeakerName;
|
FString SpeakerName;
|
||||||
FSoundID SpeakerVoice;
|
FSoundID SpeakerVoice;
|
||||||
FTextureID Backdrop;
|
FTextureID Backdrop;
|
||||||
char *Dialogue;
|
FString Dialogue;
|
||||||
char *Goodbye = nullptr; // must init to null for binary scripts to work as intended
|
FString Goodbye; // must init to null for binary scripts to work as intended
|
||||||
|
|
||||||
FStrifeDialogueReply *Children;
|
FStrifeDialogueReply *Children;
|
||||||
};
|
};
|
||||||
|
@ -44,15 +44,16 @@ struct FStrifeDialogueReply
|
||||||
PClassActor *GiveType;
|
PClassActor *GiveType;
|
||||||
int ActionSpecial;
|
int ActionSpecial;
|
||||||
int Args[5];
|
int Args[5];
|
||||||
|
int PrintAmount;
|
||||||
TArray<FStrifeDialogueItemCheck> ItemCheck;
|
TArray<FStrifeDialogueItemCheck> ItemCheck;
|
||||||
TArray<FStrifeDialogueItemCheck> ItemCheckRequire;
|
TArray<FStrifeDialogueItemCheck> ItemCheckRequire;
|
||||||
TArray<FStrifeDialogueItemCheck> ItemCheckExclude;
|
TArray<FStrifeDialogueItemCheck> ItemCheckExclude;
|
||||||
char *Reply;
|
FString Reply;
|
||||||
char *QuickYes;
|
FString QuickYes;
|
||||||
|
FString QuickNo;
|
||||||
|
FString LogString;
|
||||||
int NextNode; // index into StrifeDialogues
|
int NextNode; // index into StrifeDialogues
|
||||||
int LogNumber;
|
int LogNumber;
|
||||||
char *LogString;
|
|
||||||
char *QuickNo;
|
|
||||||
bool NeedsGold;
|
bool NeedsGold;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -232,20 +232,21 @@ class USDFParser : public UDMFParserBase
|
||||||
// Todo: Finalize
|
// Todo: Finalize
|
||||||
if (reply->ItemCheck.Size() > 0)
|
if (reply->ItemCheck.Size() > 0)
|
||||||
{
|
{
|
||||||
if (reply->ItemCheck[0].Amount <= 0) reply->NeedsGold = false;
|
reply->PrintAmount = reply->ItemCheck[0].Amount;
|
||||||
|
if (reply->PrintAmount <= 0) reply->NeedsGold = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply->Reply = ncopystring(ReplyString);
|
reply->Reply = ReplyString;
|
||||||
reply->QuickYes = ncopystring(QuickYes);
|
reply->QuickYes = QuickYes;
|
||||||
if (reply->ItemCheck.Size() > 0 && reply->ItemCheck[0].Item != NULL)
|
if (reply->ItemCheck.Size() > 0 && reply->ItemCheck[0].Item != NULL)
|
||||||
{
|
{
|
||||||
reply->QuickNo = ncopystring(QuickNo);
|
reply->QuickNo = QuickNo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reply->QuickNo = NULL;
|
reply->QuickNo = "";
|
||||||
}
|
}
|
||||||
reply->LogString = ncopystring(LogString);
|
reply->LogString = LogString;
|
||||||
if(!closeDialog) reply->NextNode *= -1;
|
if(!closeDialog) reply->NextNode *= -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -373,9 +374,9 @@ class USDFParser : public UDMFParserBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node->SpeakerName = ncopystring(SpeakerName);
|
node->SpeakerName = SpeakerName;
|
||||||
node->Dialogue = ncopystring(Dialogue);
|
node->Dialogue = Dialogue;
|
||||||
node->Goodbye = ncopystring(Goodbye);
|
node->Goodbye = Goodbye;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue