Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Mar 14, 2023
2 parents afe5585 + 8a7442a commit e400afc
Show file tree
Hide file tree
Showing 42 changed files with 878 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center"><img src="https://raw.githubusercontent.com/JujuAdams/Chatterbox/master/LOGO.png" style="display:block; margin:auto; width:400px"></p>
<h1 align="center">Chatterbox 2.10.3</h1>
<h1 align="center">Chatterbox 2.10.4</h1>

<p align="center">Narrative engine for GameMaker 2022 LTS by <b>@jujuadams</b></p>

Expand Down
22 changes: 18 additions & 4 deletions chatterbox.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions datafiles/example_speakerdata_sprite.yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Start
---
This is the example project for displaying sprites from speakerdata.
Apple[Happy]: Hi! I'm Apple. I'm here as an example of how Chatterbox can display sprites!
Apple[Amazed]: Isn't that so cool!?
Elppa[Happy]: A bit of an overreaction, don't you think?
Apple[Ashamed]: Ahem. Anyways, that's how it works, pretty neat, right?
Elppa[Crying]: This is an example of it using a fallback sprite when the requested sprite can't be found.
Allpe: This is an example of it using the fallback character for a character not defined in the actors list.
===
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions objects/oExampleSpeakerDataSprite/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//A struct that contains the speaker names, and their possible sprites, with a fallback.
//Written by Scott

actorsList = {
"Apple": {
sprites: {
"Amazed" : sAppleAmazed,
"Ashamed" : sAppleAshamed,
"Happy" : sAppleHappy,
"Fallback" : sAppleBase,
}
},
"Elppa": {
sprites: {
"Amazed" : sElppaAmazed,
"Ashamed" : sElppaAshamed,
"Happy" : sElppaHappy,
"Fallback" : sElppaBase,
}
},
"Fallback" : {
sprites : {
"Fallback": sBlank,
}
}
};


//Load in some source files
ChatterboxLoadFromFile("example_speakerdata_sprite.yarn");

//Create a chatterbox
box = ChatterboxCreate("example_speakerdata_sprite.yarn");

//Tell the chatterbox to jump to a node
ChatterboxJump(box, "Start");
54 changes: 54 additions & 0 deletions objects/oExampleSpeakerDataSprite/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
draw_set_font(fntDefault);
draw_set_halign(fa_center);

//Iterate over all text and draw it
var _x = room_width/2;
var _y = room_height/2 + 200;

if (ChatterboxIsStopped(box))
{
//If we're stopped then show that
draw_text(_x, _y, "(Chatterbox stopped)");
}
else
{
//All the spoken text
var _i = 0;
repeat(ChatterboxGetContentCount(box))
{
var _speaker = ChatterboxGetContentSpeaker(box, _i); //Returns Name ex: NPC[Happy]: Returns NPC:
var _speakerData = ChatterboxGetContentSpeakerData(box, _i); // Returns Data After name ex NPC[Happy]: returns Happy
var _currentActor = actorsList[$ _speaker] ?? actorsList[$ "Fallback"]; //Returns the Actor struct for the specified speaker, with the Fallback.
var _speakerSprite = _currentActor.sprites[$ _speakerData]; //Gets the sprite from the Actor struct.
if (_speakerSprite == undefined) _speakerSprite = _currentActor.sprites.Fallback; //Use the fallback sprite if needed.
var _currentSprite = _speakerSprite; // References the current actor then references which sprite should be used
var _string = ChatterboxGetContentSpeech(box, _i);
draw_text(_x, _y, _speaker);
_y += 40;
draw_text(_x, _y, _string);
draw_sprite(_currentSprite, 0, room_width/2, room_height/2);
_y += string_height(_string);
++_i;
}

//Bit of spacing...
_y += 40;

if (ChatterboxIsWaiting(box))
{
//If we're in a "waiting" state then prompt the user for basic input
draw_text(_x, _y, "(Press Space)");
}
else
{
//All the options
var _i = 0;
repeat(ChatterboxGetOptionCount(box))
{
var _string = ChatterboxGetOption(box, _i);
draw_text(_x, _y, string(_i+1) + ") " + _string);
_y += string_height(_string);
++_i;
}
}
}
31 changes: 31 additions & 0 deletions objects/oExampleSpeakerDataSprite/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
if (ChatterboxIsStopped(box))
{
//If we're stopped then don't respond to user input
}
else if (ChatterboxIsWaiting(box))
{
//If we're in a "waiting" state then let the user press <space> to advance dialogue
if (keyboard_check_released(vk_space))
{
ChatterboxContinue(box);
}
else if (keyboard_check_pressed(ord("F")))
{
//The user can also press F to fast forward through text until they hit a choice
ChatterboxFastForward(box);
}
}
else
{
//If we're not waiting then we have some options!

//Check for any keyboard input
var _index = undefined;
if (keyboard_check_released(ord("1"))) _index = 0;
if (keyboard_check_released(ord("2"))) _index = 1;
if (keyboard_check_released(ord("3"))) _index = 2;
if (keyboard_check_released(ord("4"))) _index = 3;

//If we've pressed a button, select that option
if (_index != undefined) ChatterboxSelect(box, _index);
}
35 changes: 35 additions & 0 deletions objects/oExampleSpeakerDataSprite/oExampleSpeakerDataSprite.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion options/windows/options_windows.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e400afc

Please sign in to comment.