Created
December 22, 2021 14:37
-
-
Save DatZach/b9ad2ef00ef36c6ce51e4a625c025f4d to your computer and use it in GitHub Desktop.
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
function texturegroup_get_names() { | |
var _result = global.__texturegroup_names; | |
if (array_length(_result) > 0) | |
return _result; | |
var _dataPath = undefined; | |
for(var i = 1; i < parameter_count(); i++) { | |
var _paramString = parameter_string(i); | |
if (filename_ext(_paramString) == ".win") { | |
_dataPath = _paramString; | |
break; | |
} | |
} | |
if (_dataPath == undefined) { | |
var _mask; | |
if (os_type == os_windows) { | |
_mask = "*.win"; | |
_dataPath = file_find_first(_mask, 0); | |
file_find_close(); | |
} else if (os_type == os_android) { | |
_mask = "*.droid"; | |
_dataPath = file_find_first(_mask, 0); | |
file_find_close(); | |
} else if (os_type == os_switch) | |
_dataPath = "rom:/game.win"; | |
else if (os_type == os_xboxone) | |
_dataPath = "game.win"; | |
else if (os_type == os_ps4) | |
_dataPath = "game.win"; | |
else | |
show_error("Unsupported platform", true); | |
} | |
if (_dataPath == undefined) | |
show_error("Unable to find game data", true); | |
var _handle = buffer_load(_dataPath); | |
buffer_seek(_handle, buffer_seek_start, 8); | |
while (buffer_tell(_handle) < buffer_get_size(_handle)) { | |
var _chunkName = buffer_read(_handle, buffer_u32); | |
var _chunkSize = buffer_read(_handle, buffer_s32); | |
if (_chunkName == $4E494754) { // TGIN | |
buffer_read(_handle, buffer_u32); | |
var _count = buffer_read(_handle, buffer_u32); | |
var _offset = buffer_tell(_handle); | |
for (var i = 0; i < _count; ++i) { | |
buffer_seek(_handle, buffer_seek_start, _offset + i*4); | |
var _entryOffset = buffer_read(_handle, buffer_u32); | |
if (_entryOffset == 0) | |
continue; | |
buffer_seek(_handle, buffer_seek_start, _entryOffset); | |
var _strOffset = buffer_read(_handle, buffer_u32); | |
if (_strOffset == 0) | |
continue; | |
buffer_seek(_handle, buffer_seek_start, _strOffset); | |
var _string = buffer_read(_handle, buffer_string); | |
_result[@ array_length(_result)] = _string; | |
} | |
break; | |
} | |
buffer_seek(_handle, buffer_seek_relative, _chunkSize); | |
} | |
buffer_delete(_handle); | |
return _result; | |
} | |
global.__texturegroup_names = []; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment