-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,6 @@ | ||
/// Loads a Yarn file (either .yarn or .json) for use with Chatterbox | ||
/// | ||
/// To find out more about Chatterbox's scripting language, "Yarn", please read the __chatterbox_syntax() | ||
/// | ||
/// @param filename Name of the file to add | ||
|
||
function chatterbox_load(_filename) | ||
{ | ||
if (!is_string(_filename)) | ||
{ | ||
__chatterbox_error("Files should be loaded using their filename as a string.\n(Input was an invalid datatype)"); | ||
return undefined; | ||
} | ||
__chatterbox_error("chatterbox_load() has been deprecated. Please use chatterbox_load_from_file() instead"); | ||
|
||
//Fix the font directory name if it's weird | ||
var _font_directory = CHATTERBOX_SOURCE_DIRECTORY; | ||
var _char = string_char_at(_font_directory , string_length(_font_directory )); | ||
if (_char != "\\") && (_char != "/") _font_directory += "\\"; | ||
|
||
if (!file_exists(_font_directory + _filename)) | ||
{ | ||
__chatterbox_error("\"", _filename, "\" could not be found"); | ||
return undefined; | ||
} | ||
|
||
if (os_browser == browser_not_a_browser) | ||
{ | ||
var _buffer = buffer_load(_font_directory + _filename); | ||
} | ||
else | ||
{ | ||
__chatterbox_trace("Using legacy file loading method on HTML5"); | ||
|
||
var _file = file_text_open_read(_font_directory + _filename); | ||
|
||
var _string = ""; | ||
while(!file_text_eof(_file)) _string += file_text_readln(_file); | ||
file_text_close(_file); | ||
|
||
var _buffer = buffer_create(string_byte_length(_string), buffer_fixed, 1); | ||
buffer_write(_buffer, buffer_text, _string); | ||
buffer_seek(_buffer, buffer_seek_start, 0); | ||
|
||
show_debug_message(_string); | ||
} | ||
|
||
return chatterbox_load_from_buffer(_filename, _buffer); | ||
return chatterbox_load_from_file(_filename); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/// Loads a Yarn file (either .yarn or .json) for use with Chatterbox | ||
/// | ||
/// To find out more about Chatterbox's scripting language, "Yarn", please read the __chatterbox_syntax() | ||
/// | ||
/// @param filename Name of the file to add | ||
|
||
function chatterbox_load_from_file(_filename) | ||
{ | ||
if (!is_string(_filename)) | ||
{ | ||
__chatterbox_error("Files should be loaded using their filename as a string.\n(Input was an invalid datatype)"); | ||
return undefined; | ||
} | ||
|
||
//Fix the font directory name if it's weird | ||
var _font_directory = CHATTERBOX_SOURCE_DIRECTORY; | ||
var _char = string_char_at(_font_directory , string_length(_font_directory )); | ||
if (_char != "\\") && (_char != "/") _font_directory += "\\"; | ||
|
||
if (!file_exists(_font_directory + _filename)) | ||
{ | ||
__chatterbox_error("\"", _filename, "\" could not be found"); | ||
return undefined; | ||
} | ||
|
||
if (os_browser == browser_not_a_browser) | ||
{ | ||
var _buffer = buffer_load(_font_directory + _filename); | ||
} | ||
else | ||
{ | ||
__chatterbox_trace("Using legacy file loading method on HTML5"); | ||
|
||
var _file = file_text_open_read(_font_directory + _filename); | ||
|
||
var _string = ""; | ||
while(!file_text_eof(_file)) _string += file_text_readln(_file); | ||
file_text_close(_file); | ||
|
||
var _buffer = buffer_create(string_byte_length(_string), buffer_fixed, 1); | ||
buffer_write(_buffer, buffer_text, _string); | ||
buffer_seek(_buffer, buffer_seek_start, 0); | ||
|
||
show_debug_message(_string); | ||
} | ||
|
||
return chatterbox_load_from_buffer(_filename, _buffer); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/// Loads a Yarn source for use with Chatterbox directly from a string | ||
/// | ||
/// To find out more about Chatterbox's scripting language, "Yarn", please read the __chatterbox_syntax() | ||
/// | ||
/// @param filename Filename to use for this buffer | ||
/// @param string String to read | ||
|
||
function chatterbox_load_from_string(_filename, _string) | ||
{ | ||
if (!is_string(_filename)) | ||
{ | ||
__chatterbox_error("Buffers should have a filename specified as a string.\n(Input was an invalid datatype)"); | ||
return undefined; | ||
} | ||
|
||
if (chatterbox_is_loaded(_filename)) | ||
{ | ||
//Unload what we have already if needed | ||
//This will invalidate any chatterboxes that currently exist and are using the file | ||
chatterbox_unload(_filename); | ||
} | ||
|
||
//Set our default file if we don't already have one | ||
if (global.__chatterbox_default_file == "") global.__chatterbox_default_file = _filename; | ||
|
||
//Create a struct that represents this source | ||
var _source = new __chatterbox_class_source(_filename, _string); | ||
|
||
//If we successfully decoded a buffer add it to our collection of chatterboxes | ||
if ((instanceof(_source) == "__chatterbox_class_source") && !is_undefined(_source.format)) | ||
{ | ||
global.chatterbox_files[? _filename] = _source; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.