Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
JujuAdams committed Jul 3, 2022
2 parents e136ba2 + 1fba6ae commit 7475f73
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 20 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">2.5.1</h1>
<h1 align="center">2.6.0</h1>

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

Expand Down
2 changes: 2 additions & 0 deletions chatterbox.yyp

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

14 changes: 14 additions & 0 deletions datafiles/testcase_fast_forward.yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: Start
---
A
B
C
D
E
F
<<forcewait>>
G
H
I
J
===
3 changes: 3 additions & 0 deletions objects/oTestCaseFastForward/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ChatterboxLoadFromFile("testcase_fast_forward.yarn");
box = ChatterboxCreate();
ChatterboxJump(box, "Start");
55 changes: 55 additions & 0 deletions objects/oTestCaseFastForward/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
draw_set_font(fntDefault);

//Iterate over all text and draw it
var _x = 10;
var _y = 10;

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 _string = ChatterboxGetContent(box, _i);
draw_text(_x, _y, _string);
_y += string_height(_string);
++_i;
}

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

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);

if (ChatterboxGetOptionConditionBool(box, _i))
{
draw_text(_x, _y, string(_i+1) + ") " + _string);
}
else
{
draw_set_colour(c_grey);
draw_text(_x, _y, string(_i+1) + ") " + _string);
draw_set_colour(c_white);
}

_y += string_height(_string);
++_i;
}
}
}
24 changes: 24 additions & 0 deletions objects/oTestCaseFastForward/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
if (ChatterboxIsStopped(box))
{
//Do nothing!
}
else if (ChatterboxIsWaiting(box))
{
if (keyboard_check_released(vk_space))
{
ChatterboxContinue(box);
}
else if (keyboard_check_released(ord("F")))
{
ChatterboxFastForward(box);
}
}
else
{
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 (_index != undefined) ChatterboxSelect(box, _index);
}
35 changes: 35 additions & 0 deletions objects/oTestCaseFastForward/oTestCaseFastForward.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.

4 changes: 2 additions & 2 deletions rooms/rmTest/rmTest.yy

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

1 change: 1 addition & 0 deletions scripts/ChatterboxAddFunction/ChatterboxAddFunction.gml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function ChatterboxAddFunction(_name, _in_function)
case "jump":
case "stop":
case "wait":
case "forcewait":
case "visited":
__ChatterboxError("Function name \"", _name, "\" is reserved for internal Chatterbox use.\nPlease choose another action name.");
return false;
Expand Down
12 changes: 8 additions & 4 deletions scripts/ChatterboxCreate/ChatterboxCreate.gml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function __ChatterboxClass(_filename, _singleton, _local_scope) constructor
current_instruction = undefined;
stopped = true;
waiting = false;
forced_waiting = false;
loaded = true;
wait_instruction = undefined;

Expand Down Expand Up @@ -193,12 +194,14 @@ function __ChatterboxClass(_filename, _singleton, _local_scope) constructor
{
//If we *are* processing this chatterbox then set this particular global to <true>
//We pick this global up at the bottom of the VM
global.__chatterboxVMWait = true;
global.__chatterboxVMForceWait = true;
}
else
{
//Otherwise set up a waiting state
waiting = true;
waiting = true;
forced_waiting = true;
wait_instruction = current_instruction;
}
}
Expand Down Expand Up @@ -230,15 +233,15 @@ function __ChatterboxClass(_filename, _singleton, _local_scope) constructor
return undefined;
}

if (ChatterboxGetOptionCount(_chatterbox) > 0)
if (GetOptionCount() > 0)
{
__ChatterboxTrace("Error! Player is being prompted to make a choice, cannot fast forward");
return undefined;
}

while ((ChatterboxGetOptionCount(_chatterbox) <= 0) && ChatterboxIsWaiting(_chatterbox) && !ChatterboxIsStopped(_chatterbox))
while ((GetOptionCount() <= 0) && IsWaiting() && !IsStopped() && !forced_waiting)
{
ChatterboxContinue(_chatterbox);
Continue();
}
}

Expand Down Expand Up @@ -355,6 +358,7 @@ function __ChatterboxClass(_filename, _singleton, _local_scope) constructor
current_instruction = undefined;
stopped = true;
waiting = false;
forced_waiting = false;
}

loaded = false;
Expand Down
3 changes: 2 additions & 1 deletion scripts/__ChatterboxClassNode/__ChatterboxClassNode.gml
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ function __ChatterboxCompile(_in_substring_array, _root_instruction)
break;

case "wait":
case "forcewait":
case "stop":
_remainder = __ChatterboxCompilerRemoveWhitespace(_remainder, true);
if (_remainder != "")
{
__ChatterboxError("Cannot use arguments with <<wait>> or <<stop>>\n\Action was \"<<", _string, ">>\"");
__ChatterboxError("Cannot use arguments with <<wait>>, <<forcewait>>, or <<stop>>\n\Action was \"<<", _string, ">>\"");
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions scripts/__ChatterboxSystem/__ChatterboxSystem.gml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#region Internal Macro Definitions

#macro __CHATTERBOX_VERSION "2.5.1"
#macro __CHATTERBOX_DATE "2022-07-02"
#macro __CHATTERBOX_VERSION "2.6.0"
#macro __CHATTERBOX_DATE "2022-07-03"

#macro CHATTERBOX_CURRENT global.__chatterboxCurrent

Expand Down Expand Up @@ -83,6 +83,7 @@ global.__chatterboxIndentSize = 0;
global.__chatterboxFindReplaceOldString = ds_list_create();
global.__chatterboxFindReplaceNewString = ds_list_create();
global.__chatterboxVMInstanceStack = [];
global.__chatterboxVMWait = false;
global.__chatterboxVMForceWait = false;
global.__chatterboxCurrent = undefined;
if (!variable_global_exists("__chatterbox_functions")) global.__chatterboxFunctions = ds_map_create();
Expand Down
39 changes: 30 additions & 9 deletions scripts/__ChatterboxVM/__ChatterboxVM.gml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function __ChatterboxVM()

stopped = false;
waiting = false;
forced_waiting = false;
wait_instruction = undefined;
entered_option = false;
leaving_option = false;
Expand Down Expand Up @@ -112,6 +113,7 @@ function __ChatterboxVMInner(_instruction)
{
if (((_next.type != "option") || CHATTERBOX_SINGLETON_WAIT_BEFORE_OPTION)
&& (_next.type != "wait")
&& (_next.type != "forcewait")
&& (_next.type != "stop"))
{
waiting = true;
Expand All @@ -123,10 +125,16 @@ function __ChatterboxVMInner(_instruction)
break;

case "wait":
global.__chatterboxVMForceWait = true;
global.__chatterboxVMWait = true;
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<wait>>");
break;

case "forcewait":
global.__chatterboxVMWait = true;
global.__chatterboxVMForceWait = true;
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<forcewait>>");
break;

case "jump":
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "[goto ", _instruction.destination, "]");

Expand Down Expand Up @@ -173,7 +181,8 @@ function __ChatterboxVMInner(_instruction)
case "stop":
if (CHATTERBOX_WAIT_BEFORE_STOP && (array_length(content) > 0) && (array_length(option) <= 0))
{
waiting = true;
waiting = true;
forced_waiting = true;
wait_instruction = _instruction;
}
else
Expand Down Expand Up @@ -228,10 +237,19 @@ function __ChatterboxVMInner(_instruction)
break;
}

if (is_string(_result) && (_result == "<<wait>>"))
if (is_string(_result))
{
global.__chatterboxVMForceWait = true;
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<wait>> returned by function");
if (_result == "<<wait>>")
{
global.__chatterboxVMWait = true;
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<wait>> returned by function");
}
else if (_result == "<<forcewait>>")
{
global.__chatterboxVMWait = true;
global.__chatterboxVMForceWait = true;
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<forcewait>> returned by function");
}
}
break;

Expand Down Expand Up @@ -284,14 +302,17 @@ function __ChatterboxVMInner(_instruction)
}
}

if (global.__chatterboxVMForceWait)
if (global.__chatterboxVMWait)
{
global.__chatterboxVMForceWait = false;
__ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "<<wait>> (forced)");
if (__CHATTERBOX_DEBUG_VM) __ChatterboxTrace(__ChatterboxGenerateIndent(_instruction.indent), "Something insisted the VM wait");

waiting = true;
waiting = true;
forced_waiting = global.__chatterboxVMForceWait;
wait_instruction = _instruction.next;
_do_next = false;

global.__chatterboxVMWait = false;
global.__chatterboxVMForceWait = false;
}

if (_do_next)
Expand Down

0 comments on commit 7475f73

Please sign in to comment.