-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
132 changed files
with
8,302 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
MTG-Generator/scripts/Snap2DArrayToStructArray/Snap2DArrayToStructArray.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/// Config struct should be in this format: | ||
/// | ||
/// { | ||
/// columnTitle: { | ||
/// ignore: <true> or <false>, | ||
/// numeric: <true> or <false>, | ||
/// }, | ||
/// ... | ||
/// } | ||
/// | ||
/// @param inputArray 2D array to convert. Array should be row-major | ||
/// @param [configStruct] See above | ||
/// | ||
/// @jujuadams 2022-10-30 | ||
|
||
function Snap2DArrayToStructArray(_inputArray, _configStruct = {}) | ||
{ | ||
var _outputArray = array_create(array_length(_inputArray)-1); | ||
var _headerArray = _inputArray[0]; | ||
|
||
var _ignore = false; | ||
var _numeric = false; | ||
|
||
var _i = 1; | ||
repeat(array_length(_inputArray)-1) | ||
{ | ||
var _struct = {}; | ||
_outputArray[@ _i-1] = _struct; | ||
|
||
var _subArray = _inputArray[_i]; | ||
var _j = 0; | ||
repeat(array_length(_subArray)) | ||
{ | ||
var _value = _subArray[_j]; | ||
var _variableName = _headerArray[_j]; | ||
|
||
var _config = _configStruct[$ _variableName]; | ||
if (is_struct(_config)) | ||
{ | ||
_ignore = _config[$ "ignore" ] ?? false; | ||
_numeric = _config[$ "numeric"] ?? false; | ||
} | ||
|
||
if (_numeric) | ||
{ | ||
_numeric = false; | ||
try { _value = real(_value); } catch(_error) {} | ||
} | ||
|
||
if (_ignore) | ||
{ | ||
_ignore = false; | ||
} | ||
else | ||
{ | ||
_struct[$ _variableName] = _value; | ||
} | ||
|
||
++_j; | ||
} | ||
|
||
++_i; | ||
} | ||
|
||
return _outputArray; | ||
} |
11 changes: 11 additions & 0 deletions
11
MTG-Generator/scripts/Snap2DArrayToStructArray/Snap2DArrayToStructArray.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
MTG-Generator/scripts/SnapBufferRead2DArray/SnapBufferRead2DArray.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// @param buffer | ||
/// @param offset | ||
/// | ||
/// @jujuadams 2022-10-30 | ||
|
||
function SnapBufferRead2DArray(_buffer, _inOffset) | ||
{ | ||
if (_inOffset != undefined) | ||
{ | ||
var _oldOffset = buffer_tell(_buffer); | ||
buffer_seek(_buffer, buffer_seek_start, _inOffset); | ||
} | ||
|
||
var _datatype = buffer_read(_buffer, buffer_u8); | ||
var _width = buffer_read(_buffer, buffer_u32); | ||
var _height = buffer_read(_buffer, buffer_u32); | ||
|
||
var _array = array_create(_width); | ||
|
||
var _x = 0; | ||
repeat(_width) | ||
{ | ||
var _sub_array = array_create(_height); | ||
_array[@ _x] = _sub_array; | ||
|
||
var _y = 0; | ||
repeat(_height) | ||
{ | ||
_sub_array[@ _y] = buffer_read(_buffer, _datatype); | ||
++_y; | ||
} | ||
|
||
++_x; | ||
} | ||
|
||
if (_inOffset != undefined) buffer_seek(_buffer, buffer_seek_start, _oldOffset); | ||
|
||
return _array; | ||
} |
11 changes: 11 additions & 0 deletions
11
MTG-Generator/scripts/SnapBufferRead2DArray/SnapBufferRead2DArray.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
MTG-Generator/scripts/SnapBufferRead2DArray/snap_to_grid.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
MTG-Generator/scripts/SnapBufferReadBOM/SnapBufferReadBOM.gml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// Attempts to read a UTF-8 byte order mark from a buffer, and returns <true> if a BOM is found | ||
/// | ||
/// @param buffer Buffer to try to read the byte order mark from | ||
/// | ||
/// @jujuadams 2022-10-30 | ||
|
||
function SnapBufferReadBOM(_buffer) | ||
{ | ||
var _tell = buffer_tell(_buffer); | ||
if ((buffer_get_size(_buffer) >= 3) | ||
&& (buffer_peek(_buffer, _tell, buffer_u8) == 0xEF) | ||
&& (buffer_peek(_buffer, _tell+1, buffer_u8) == 0xBB) | ||
&& (buffer_peek(_buffer, _tell+2, buffer_u8) == 0xBF)) | ||
{ | ||
buffer_seek(_buffer, buffer_seek_relative, 3); | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
11 changes: 11 additions & 0 deletions
11
MTG-Generator/scripts/SnapBufferReadBOM/SnapBufferReadBOM.yy
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.