Skip to content

Commit

Permalink
Implement branching
Browse files Browse the repository at this point in the history
  • Loading branch information
KR155E committed Jul 12, 2023
1 parent 1db3d11 commit e2b0b44
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene1 = {
"Das Geräusch des Motors hallt in der \nDunkelheit wider. Wegen einer kleinen Panne\nvorhin ist es so spät geworden.",
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene2Entities[] =
Expand All @@ -85,6 +86,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene2 = {
"Ich bin Harry Mason.\nEin Allerweltsschriftsteller.",
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene3Entities[] =
Expand Down Expand Up @@ -114,6 +116,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene3 = {
"unersetzlich geworden. \nCheryl hatte sich sehr auf diese Reise \ngefreut.",
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene4Entities[] =
Expand All @@ -137,6 +140,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene4 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene5Entities[] =
Expand All @@ -162,6 +166,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene5 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene6Entities[] =
Expand All @@ -185,6 +190,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene6 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene7Entities[] =
Expand All @@ -209,6 +215,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene7 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene8Entities[] =
Expand All @@ -234,6 +241,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene8 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene9Entities[] =
Expand All @@ -258,6 +266,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene9 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene10Entities[] =
Expand All @@ -282,6 +291,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene10 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene11Entities[] =
Expand Down Expand Up @@ -309,6 +319,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene11 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene12Entities[] =
Expand All @@ -331,6 +342,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene12 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct0Chapter1Sub1Scene13Entities[] =
Expand All @@ -354,6 +366,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene13 = {
{
}
},
NULL,
};

const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene14 = {
Expand All @@ -371,6 +384,7 @@ const struct Scene PlayNovelScenarioHarryAct0Chapter1Sub1Scene14 = {
""
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct0Chapter1Sub1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter1Sub1Scene1 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter1Sub1 = {
Expand Down Expand Up @@ -92,6 +93,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter1Sub2Scene1 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter1Sub2Scene2Entities[] =
Expand All @@ -114,6 +116,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter1Sub2Scene2 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter1Sub2 = {
Expand Down Expand Up @@ -154,6 +157,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter1Sub3Scene1 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter1Sub3Scene2Entities[] =
Expand All @@ -177,6 +181,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter1Sub3Scene2 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter1Sub3 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter2Sub1Scene1 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter2Sub1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter3Sub1Scene1 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter3Sub1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter4Sub1Scene1 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter4Sub1Scene2Entities[] =
Expand Down Expand Up @@ -79,6 +80,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter4Sub1Scene2 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter4Sub1Scene3Entities[] =
Expand All @@ -104,6 +106,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter4Sub1Scene3 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter4Sub1Scene4Entities[] =
Expand All @@ -128,6 +131,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter4Sub1Scene4 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter4Sub1Scene5Entities[] =
Expand All @@ -151,6 +155,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter4Sub1Scene5 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter4Sub1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter5Sub1Scene1 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter5Sub1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter6Sub1Scene1 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter6Sub1Scene2Entities[] =
Expand All @@ -60,42 +61,33 @@ PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter6Sub1Scene2Entities[] =
{NULL, {0,0,0,0}, 0, NULL, NULL, NULL, false},
};

const struct Scene PlayNovelScenarioHarryAct1Chapter6Sub1Scene2 = {
kFadeTypeNormal,
kFadeTypeNormal,
kSoundWrapperPlaybackNormal,
NULL,
(PositionedEntity*)PlayNovelScenarioHarryAct1Chapter6Sub1Scene2Entities,
NULL,
const struct BranchingTargets PlayNovelScenarioHarryAct1Chapter6Sub1Scene2BranchingTargets =
{
{
{
"\"Ah...\"",
"And then my vitality is sucked away by these \nstrangely shaped monsters until I finally \nlose consciousness..."
},
{
{
1, 6, 0, 2,
},
}
},
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter6Sub1Scene3Entities[] =
{
{NULL, {0,0,0,0}, 0, NULL, NULL, NULL, false},
}
};

const struct Scene PlayNovelScenarioHarryAct1Chapter6Sub1Scene3 = {
const struct Scene PlayNovelScenarioHarryAct1Chapter6Sub1Scene2 = {
kFadeTypeNormal,
kFadeTypeNormal,
kSoundWrapperPlaybackNormal,
&MonsterSoundSound,
(PositionedEntity*)PlayNovelScenarioHarryAct1Chapter6Sub1Scene3Entities,
NULL,
(PositionedEntity*)PlayNovelScenarioHarryAct1Chapter6Sub1Scene2Entities,
NULL,
{
{
"You have reached the end of this demo.",
"\"Ah...\"",
"And then my vitality is sucked away by these \nstrangely shaped monsters until I finally \nlose consciousness..."
},
{
}
},
&PlayNovelScenarioHarryAct1Chapter6Sub1Scene2BranchingTargets,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter6Sub1 = {
Expand All @@ -106,7 +98,6 @@ const struct SubChapter PlayNovelScenarioHarryAct1Chapter6Sub1 = {
{
&PlayNovelScenarioHarryAct1Chapter6Sub1Scene1,
&PlayNovelScenarioHarryAct1Chapter6Sub1Scene2,
&PlayNovelScenarioHarryAct1Chapter6Sub1Scene3,
NULL,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter7Sub1Scene1 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter7Sub1Scene2Entities[] =
Expand All @@ -79,6 +80,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter7Sub1Scene2 = {
{
}
},
NULL,
};

PositionedEntityROMSpec PlayNovelScenarioHarryAct1Chapter7Sub1Scene3Entities[] =
Expand All @@ -100,6 +102,7 @@ const struct Scene PlayNovelScenarioHarryAct1Chapter7Sub1Scene3 = {
{
}
},
NULL,
};

const struct SubChapter PlayNovelScenarioHarryAct1Chapter7Sub1 = {
Expand Down
25 changes: 23 additions & 2 deletions source/states/VisualNovelState/VisualNovelState.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ bool VisualNovelState::handleMessage(Telegram telegram)

void VisualNovelState::nextPage()
{
const struct BranchingTargets *branchingTargets = PlayNovelScenarios.scenarios[this->progress.scenario]
->acts[this->progress.act]->chapters[this->progress.chapter]
->subChapters[this->progress.subChapter]
->scenes[this->progress.scene]
->branchingTargets;

if (this->choicesMenuOptionCount > 0) {
const struct Choices *choices = PlayNovelScenarios.scenarios[this->progress.scenario]
->acts[this->progress.act]->chapters[this->progress.chapter]
Expand Down Expand Up @@ -174,8 +180,23 @@ void VisualNovelState::nextPage()
->scenes[this->progress.scene]
->text[this->language][this->progress.page] == NULL)
{
this->progress.page = 0;
VisualNovelState::nextScene(this);
if (branchingTargets != NULL)
{
// TODO: iterate and check conditions
this->progress.act = branchingTargets->branchingTargets[0].target.act;
this->progress.chapter = branchingTargets->branchingTargets[0].target.chapter;
this->progress.subChapter = branchingTargets->branchingTargets[0].target.subChapter;
this->progress.scene = branchingTargets->branchingTargets[0].target.scene;
this->progress.page = 0;

VisualNovelState::setUpScene(this);
VisualNovelState::saveProgress(this);
}
else
{
this->progress.page = 0;
VisualNovelState::nextScene(this);
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions source/states/VisualNovelState/VisualNovelState.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define CHARACTER_DELAY 1
#define NUMBER_OF_LANGUAGES 2
#define MAX_CHOICES 3
#define MAX_BRANCHING_TARGETS 3


//---------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -62,6 +63,17 @@ typedef struct TargetPage
uint16 scene;
} TargetPage;

typedef struct BranchingTarget
{
TargetPage target;
//TODO: conditions
} BranchingTarget;

typedef struct BranchingTargets
{
BranchingTarget branchingTargets[MAX_BRANCHING_TARGETS];
} BranchingTargets;

typedef struct Choice
{
char* text[NUMBER_OF_LANGUAGES];
Expand All @@ -82,6 +94,7 @@ typedef struct Scene
const PositionedEntity* positionedEntities;
const Choices* choices;
char* text[NUMBER_OF_LANGUAGES][MAX_TEXT_PER_SCENE];
const BranchingTargets* branchingTargets;
} Scene;

typedef struct SubChapter
Expand Down

0 comments on commit e2b0b44

Please sign in to comment.