mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-23 21:46:17 +01:00
[Palette Extract] Improve performance
This commit is contained in:
parent
38940de773
commit
4277f0998b
9 changed files with 257 additions and 52 deletions
|
@ -31,6 +31,7 @@
|
|||
{"name":"dynamic_surface","order":8,"path":"folders/functions/surface/dynamic_surface.yy",},
|
||||
{"name":"svg","order":47,"path":"folders/functions/svg.yy",},
|
||||
{"name":"main","order":147,"path":"folders/main.yy",},
|
||||
{"name":"binder","order":2,"path":"folders/main/binder.yy",},
|
||||
{"name":"misc","order":148,"path":"folders/misc.yy",},
|
||||
{"name":"nodes","order":149,"path":"folders/nodes.yy",},
|
||||
{"name":"__base__","order":2,"path":"folders/nodes/__base__.yy",},
|
||||
|
|
|
@ -115,6 +115,7 @@
|
|||
{"$GMFolder":"","%Name":"window","folderPath":"folders/functions/window.yy","name":"window","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"main","folderPath":"folders/main.yy","name":"main","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"components","folderPath":"folders/main/components.yy","name":"components","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"binder","folderPath":"folders/main/binder.yy","name":"binder","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"misc","folderPath":"folders/misc.yy","name":"misc","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"fx","folderPath":"folders/misc/fx.yy","name":"fx","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
{"$GMFolder":"","%Name":"nodes","folderPath":"folders/nodes.yy","name":"nodes","resourceType":"GMFolder","resourceVersion":"2.0",},
|
||||
|
@ -409,6 +410,7 @@
|
|||
{"$GMIncludedFile":"","%Name":"nodes.json","CopyToMask":-1,"filePath":"datafiles/data","name":"nodes.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Nodes.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Nodes.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"related_node.json","CopyToMask":-1,"filePath":"datafiles/data","name":"related_node.json","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"tileset_gamemaker2_room.yy","CopyToMask":-1,"filePath":"datafiles/data/TemplateStrings","name":"tileset_gamemaker2_room.yy","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Theme.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Theme.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Tooltip.zip","CopyToMask":-1,"filePath":"datafiles/data","name":"Tooltip.zip","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
{"$GMIncludedFile":"","%Name":"Node_2D_light.png","CopyToMask":-1,"filePath":"datafiles/data/Tooltip","name":"Node_2D_light.png","resourceType":"GMIncludedFile","resourceVersion":"2.0",},
|
||||
|
@ -941,6 +943,7 @@
|
|||
{"id":{"name":"BBMOD_Vec3","path":"scripts/BBMOD_Vec3/BBMOD_Vec3.yy",},},
|
||||
{"id":{"name":"BBMOD_Vec4","path":"scripts/BBMOD_Vec4/BBMOD_Vec4.yy",},},
|
||||
{"id":{"name":"bin_function","path":"scripts/bin_function/bin_function.yy",},},
|
||||
{"id":{"name":"binder_gamemaker","path":"scripts/binder_gamemaker/binder_gamemaker.yy",},},
|
||||
{"id":{"name":"biterator","path":"scripts/biterator/biterator.yy",},},
|
||||
{"id":{"name":"blurSurface","path":"scripts/blurSurface/blurSurface.yy",},},
|
||||
{"id":{"name":"boneObject","path":"scripts/boneObject/boneObject.yy",},},
|
||||
|
|
76
datafiles/data/TemplateStrings/tileset_gamemaker2_room.yy
Normal file
76
datafiles/data/TemplateStrings/tileset_gamemaker2_room.yy
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"isDnd": false,
|
||||
"volume": 1.0,
|
||||
"parentRoom": null,
|
||||
"views": [
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
{"inherit":false,"visible":false,"xview":0,"yview":0,"wview":1366,"hview":768,"xport":0,"yport":0,"wport":1366,"hport":768,"hborder":32,"vborder":32,"hspeed":-1,"vspeed":-1,"objectId":null,},
|
||||
],
|
||||
"layers": [
|
||||
{
|
||||
"tilesetId": {
|
||||
"name": "{{name}}",
|
||||
"path": "tilesets/{{name}}/{{name}}.yy",
|
||||
},
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"tiles": {
|
||||
"SerialiseWidth": 1,
|
||||
"SerialiseHeight": 1,
|
||||
"TileSerialiseData": null,
|
||||
},
|
||||
"visible": true,
|
||||
"depth": 0,
|
||||
"userdefinedDepth": false,
|
||||
"inheritLayerDepth": false,
|
||||
"inheritLayerSettings": false,
|
||||
"gridX": 0,
|
||||
"gridY": 0,
|
||||
"layers": [],
|
||||
"hierarchyFrozen": false,
|
||||
"resourceVersion": "1.0",
|
||||
"name": "{{tileName}}",
|
||||
"tags": [],
|
||||
"resourceType": "GMRTileLayer",
|
||||
},
|
||||
],
|
||||
"inheritLayers": false,
|
||||
"creationCodeFile": "",
|
||||
"inheritCode": false,
|
||||
"instanceCreationOrder": [],
|
||||
"inheritCreationOrder": false,
|
||||
"sequenceId": null,
|
||||
"roomSettings": {
|
||||
"inheritRoomSettings": false,
|
||||
"Width": 480,
|
||||
"Height": 320,
|
||||
"persistent": false,
|
||||
},
|
||||
"viewSettings": {
|
||||
"inheritViewSettings": false,
|
||||
"enableViews": false,
|
||||
"clearViewBackground": false,
|
||||
"clearDisplayBuffer": true,
|
||||
},
|
||||
"physicsSettings": {
|
||||
"inheritPhysicsSettings": false,
|
||||
"PhysicsWorld": false,
|
||||
"PhysicsWorldGravityX": 0.0,
|
||||
"PhysicsWorldGravityY": 10.0,
|
||||
"PhysicsWorldPixToMetres": 0.1,
|
||||
},
|
||||
"parent": {
|
||||
"name": "{{roomname}}",
|
||||
"path": "folders/{{roomname}}.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "gamemaker2",
|
||||
"tags": [],
|
||||
"resourceType": "GMRoom",
|
||||
}
|
3
scripts/binder_gamemaker/binder_gamemaker.gml
Normal file
3
scripts/binder_gamemaker/binder_gamemaker.gml
Normal file
|
@ -0,0 +1,3 @@
|
|||
function __Binder_Gamemaker(path) constructor {
|
||||
|
||||
}
|
13
scripts/binder_gamemaker/binder_gamemaker.yy
Normal file
13
scripts/binder_gamemaker/binder_gamemaker.yy
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$GMScript":"v1",
|
||||
"%Name":"binder_gamemaker",
|
||||
"isCompatibility":false,
|
||||
"isDnD":false,
|
||||
"name":"binder_gamemaker",
|
||||
"parent":{
|
||||
"name":"binder",
|
||||
"path":"folders/main/binder.yy",
|
||||
},
|
||||
"resourceType":"GMScript",
|
||||
"resourceVersion":"2.0",
|
||||
}
|
|
@ -8,12 +8,12 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
|
|||
expanded = false;
|
||||
edit_color_index = -1;
|
||||
|
||||
function apply(value) { #region
|
||||
function apply(value) {
|
||||
if(!interactable) return;
|
||||
onApply(value);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static trigger = function() { #region
|
||||
static trigger = function() {
|
||||
var dialog = dialogCall(o_dialog_palette, WIN_W / 2, WIN_H / 2);
|
||||
dialog.setDefault(current_palette);
|
||||
dialog.onApply = apply;
|
||||
|
@ -22,9 +22,9 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
|
|||
|
||||
if(parentDialog)
|
||||
parentDialog.addChildren(dialog);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static triggerSingle = function(_index) { #region
|
||||
static triggerSingle = function(_index) {
|
||||
edit_color_index = _index;
|
||||
current_palette = array_clone(current_palette);
|
||||
|
||||
|
@ -33,17 +33,17 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
|
|||
dialog.selector.onApply = editColor;
|
||||
dialog.onApply = editColor;
|
||||
dialog.interactable = interactable;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function editColor(col) { #region
|
||||
function editColor(col) {
|
||||
if(edit_color_index == -1) return;
|
||||
current_palette[edit_color_index] = col;
|
||||
apply(current_palette);
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static drawParam = function(params) { return draw(params.x, params.y, params.w, params.h, params.data, params.m); }
|
||||
|
||||
static draw = function(_x, _y, _w, _h, _color, _m) { #region
|
||||
static draw = function(_x, _y, _w, _h, _color, _m) {
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
|
@ -183,39 +183,43 @@ function buttonPalette(_onApply, dialog = noone) : widget() constructor {
|
|||
resetFocus();
|
||||
|
||||
return h;
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static clone = function() { #region
|
||||
static clone = function() {
|
||||
var cln = new buttonPalette(onApply, parentDialog);
|
||||
return cln;
|
||||
} #endregion
|
||||
}
|
||||
}
|
||||
|
||||
function drawPalette(_pal, _x, _y, _w, _h, _a = 1) { #region
|
||||
var aa = array_length(_pal);
|
||||
function drawPalette(_pal, _x, _y, _w, _h, _a = 1) {
|
||||
var am = array_length(_pal);
|
||||
|
||||
if(aa == 1) {
|
||||
if(am == 1) {
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, 1, _x, _y, _w, _h, _pal[0], _a);
|
||||
return;
|
||||
}
|
||||
|
||||
var aa = min(am, 64);
|
||||
var st = am / aa;
|
||||
|
||||
var ww = _w / aa;
|
||||
var _x0 = _x;
|
||||
var _in;
|
||||
|
||||
for(var i = 0; i < aa; i++) {
|
||||
if(!is_numeric(_pal[i])) continue;
|
||||
for(var i = 0; i < am; i += st) {
|
||||
var _p = _pal[floor(i)];
|
||||
if(!is_numeric(_p)) continue;
|
||||
|
||||
if(i == 0) _in = 2;
|
||||
else if(i == aa - 1) _in = 3;
|
||||
else _in = 0;
|
||||
|
||||
var _ca = _color_get_alpha(_pal[i]);
|
||||
var _ca = _color_get_alpha(_p);
|
||||
|
||||
if(_ca == 1) {
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, _in, floor(_x0), _y, ceil(ww), _h, _pal[i], _a);
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, _in, floor(_x0), _y, ceil(ww), _h, _p, _a);
|
||||
} else {
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, _in, floor(_x0), _y, ceil(ww), _h - ui(8), _pal[i], _a);
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, _in, floor(_x0), _y, ceil(ww), _h - ui(8), _p, _a);
|
||||
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, 1, floor(_x0), _y + _h - ui(6), ceil(ww), ui(6), c_black, _a);
|
||||
draw_sprite_stretched_ext(THEME.palette_mask, 1, floor(_x0), _y + _h - ui(6), ceil(ww) * _ca, ui(6), c_white, _a);
|
||||
|
@ -223,9 +227,9 @@ function drawPalette(_pal, _x, _y, _w, _h, _a = 1) { #region
|
|||
|
||||
_x0 += ww;
|
||||
}
|
||||
} #endregion
|
||||
}
|
||||
|
||||
function drawPaletteGrid(_pal, _x, _y, _w, _gs = 24, params = {}) { #region
|
||||
function drawPaletteGrid(_pal, _x, _y, _w, _gs = 24, params = {}) {
|
||||
var c_color = struct_try_get(params, "color", -1);
|
||||
var _stretch = struct_try_get(params, "stretch", true);
|
||||
var _mx = struct_try_get(params, "mx", -1);
|
||||
|
@ -301,4 +305,4 @@ function drawPaletteGrid(_pal, _x, _y, _w, _gs = 24, params = {}) { #region
|
|||
hoverColor: _hcc,
|
||||
hoverBBOX: [ hvx, hvy, hvw, hvh ],
|
||||
};
|
||||
} #endregion
|
||||
}
|
|
@ -28,7 +28,11 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
]
|
||||
|
||||
current_palette = [];
|
||||
current_color = 0;
|
||||
current_color = 0;
|
||||
|
||||
extraction_step = 0;
|
||||
extraction_total = 0;
|
||||
extraction_current = 0;
|
||||
|
||||
attribute_surface_depth();
|
||||
|
||||
|
@ -73,8 +77,8 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
draw_surface_stretched_safe(_surfFull, 0, 0, ww, hh);
|
||||
surface_reset_shader();
|
||||
|
||||
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 2);
|
||||
var colors = [];
|
||||
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 4);
|
||||
var colors = array_create(ww * hh), ind = 0;
|
||||
|
||||
buffer_get_surface(c_buffer, _surf, 0);
|
||||
buffer_seek(c_buffer, buffer_seek_start, 0);
|
||||
|
@ -95,17 +99,18 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
case 2 : col = [ _color_get_hue(c), _color_get_saturation(c), _color_get_value(c), 0 ]; break;
|
||||
}
|
||||
|
||||
array_push(colors, col);
|
||||
colors[ind++] = col;
|
||||
|
||||
_min[0] = min(_min[0], col[0]); _max[0] = max(_max[0], col[0]);
|
||||
_min[1] = min(_min[1], col[1]); _max[1] = max(_max[1], col[1]);
|
||||
_min[2] = min(_min[2], col[2]); _max[2] = max(_max[2], col[2]);
|
||||
}
|
||||
|
||||
|
||||
array_resize(colors, ind);
|
||||
buffer_delete(c_buffer);
|
||||
|
||||
random_set_seed(_seed);
|
||||
cnt = array_create_ext(_size, function() /*=>*/ {return [ random(1), random(1), random(1), 0 ]});
|
||||
var cnt = array_create_ext(_size, function() /*=>*/ {return [ random(1), random(1), random(1), 0 ]});
|
||||
|
||||
repeat(8) {
|
||||
// var _cnt = array_create_ext(_size, (i) => [ cnt[i][0], cnt[i][1], cnt[i][2], 0 ]);
|
||||
|
@ -152,7 +157,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
// if(del < 0.001) break;
|
||||
}
|
||||
|
||||
var palette = [];
|
||||
var palette = array_create(_size), ind = 0;
|
||||
var clr;
|
||||
|
||||
for( var i = 0; i < _size; i++ ) {
|
||||
|
@ -178,10 +183,13 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
case 2 : clr = make_color_hsva(_cc[0] * 255, _cc[1] * 255, _cc[2] * 255, 255); break;
|
||||
}
|
||||
|
||||
array_push_unique(palette, clr);
|
||||
palette[ind++] = clr;
|
||||
}
|
||||
|
||||
surface_free(_surf);
|
||||
|
||||
var palLen = array_unique_ext(palette, 0, ind);
|
||||
array_resize(palette, palLen);
|
||||
sortPalette(palette);
|
||||
|
||||
return palette;
|
||||
|
@ -191,25 +199,25 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
var ww = surface_get_width_safe(_surfFull);
|
||||
var hh = surface_get_height_safe(_surfFull);
|
||||
|
||||
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 2);
|
||||
var c_buffer = buffer_create(ww * hh * 4, buffer_fixed, 4);
|
||||
|
||||
buffer_get_surface(c_buffer, _surfFull, 0);
|
||||
buffer_seek(c_buffer, buffer_seek_start, 0);
|
||||
|
||||
var palette = [];
|
||||
var amo = ww * hh;
|
||||
var palette = array_create(amo), ind = 0;
|
||||
var bm = 0b11111111 << 24;
|
||||
|
||||
for( var i = 0; i < ww * hh; i++ ) {
|
||||
var b = buffer_read(c_buffer, buffer_u32);
|
||||
var c = b;
|
||||
var a = b & (0b11111111 << 24);
|
||||
if(a == 0) continue;
|
||||
|
||||
c = make_color_rgba(color_get_red(c), color_get_green(c), color_get_blue(c), color_get_alpha(c));
|
||||
if(!array_exists(palette, c))
|
||||
array_push(palette, c);
|
||||
for( var i = 0; i < amo; i++ ) {
|
||||
var c = buffer_read(c_buffer, buffer_u32);
|
||||
if(c & bm == 0) continue;
|
||||
palette[ind++] = c;
|
||||
}
|
||||
|
||||
buffer_delete(c_buffer);
|
||||
|
||||
var palLen = array_unique_ext(palette, 0, ind);
|
||||
array_resize(palette, palLen);
|
||||
return palette;
|
||||
}
|
||||
|
||||
|
@ -261,7 +269,7 @@ function Node_Palette_Extract(_x, _y, _group = noone) : Node_Processor(_x, _y, _
|
|||
var amo = min(_size, ds_priority_size(pr));
|
||||
var pal = array_create(amo), ind = 0;
|
||||
repeat(amo) { pal[ind++] = ds_priority_delete_max(pr); }
|
||||
|
||||
|
||||
ds_priority_destroy(pr);
|
||||
ds_map_destroy(clrs);
|
||||
|
||||
|
|
|
@ -7,21 +7,44 @@ function Node_Tile_Tilemap_Export(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
.setDisplay(VALUE_DISPLAY.path_save, { filter: "" })
|
||||
.setVisible(true);
|
||||
|
||||
export_format = [ "CSV", "JSON" ];
|
||||
export_format = [ "CSV", "GameMaker" ];
|
||||
newInput( 2, nodeValue_Enum_Scroll("Format", self, 0, export_format));
|
||||
|
||||
newInput( 3, nodeValue_Enum_Scroll("GM Export Type", self, 0, [ "Room" ]));
|
||||
|
||||
newInput( 4, nodeValue_Path("GM Room", self, ""))
|
||||
.setDisplay(VALUE_DISPLAY.path_load, { filter: "GameMaker room|*.yy" })
|
||||
.setVisible(false, false);
|
||||
|
||||
newInput( 5, nodeValue_Text("GM Room Name", self, "rmRoom"));
|
||||
|
||||
newInput( 6, nodeValue_Text("GM Layer Name", self, "Tiles_1"));
|
||||
|
||||
newInput( 7, nodeValue_Tileset("Tileset", self, noone))
|
||||
.setVisible(true, true);
|
||||
|
||||
newInput( 8, nodeValue_Path("GD Scene", self, ""))
|
||||
.setDisplay(VALUE_DISPLAY.path_load, { filter: "Godot scene|*.tscn" })
|
||||
.setVisible(false, false);
|
||||
|
||||
input_display_list = [ 7, 0,
|
||||
["Output", false], 1, 2,
|
||||
["GameMaker", true], 3, 4, 5, 6,
|
||||
["Godot", true], 8,
|
||||
];
|
||||
|
||||
insp1UpdateTooltip = "Export";
|
||||
insp1UpdateIcon = [ THEME.sequence_control, 1, COLORS._main_value_positive ];
|
||||
|
||||
static onInspector1Update = function(_fromValue = false) {
|
||||
export();
|
||||
}
|
||||
static onInspector1Update = function(_fromValue = false) { export(); }
|
||||
|
||||
static export = function() {
|
||||
var tilemap = inputs[0].getValue();
|
||||
var path = inputs[1].getValue();
|
||||
var format = inputs[2].getValue();
|
||||
var tileset = inputs[7].getValue();
|
||||
|
||||
if(tileset == noone) return;
|
||||
if(!is_surface(tilemap)) return;
|
||||
|
||||
var _form = surface_get_format(tilemap);
|
||||
|
@ -30,6 +53,9 @@ function Node_Tile_Tilemap_Export(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
return;
|
||||
}
|
||||
|
||||
var tileSize = tileset.tileSize;
|
||||
var tileName = tileset.getDisplayName();
|
||||
|
||||
var _dim = surface_get_dimension(tilemap);
|
||||
var _buff = buffer_from_surface(tilemap, false); buffer_to_start(_buff);
|
||||
var _data = array_create(_dim[1]);
|
||||
|
@ -72,11 +98,69 @@ function Node_Tile_Tilemap_Export(_x, _y, _group = noone) : Node(_x, _y, _group)
|
|||
noti.path = filename_dir(path);
|
||||
noti.setOnClick(function() /*=>*/ { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case "GameMaker":
|
||||
var gmType = inputs[3].getValue();
|
||||
var gmRoom = inputs[4].getValue();
|
||||
var gmRname = inputs[5].getValue();
|
||||
var gmLname = inputs[6].getValue();
|
||||
|
||||
// inputs[5].setVisible(gmType == 0);
|
||||
// inputs[6].setVisible(gmType == 1);
|
||||
|
||||
var _tile_arr = array_create(_dim[0] * _dim[1]), ind = 0;
|
||||
|
||||
for( var i = 0; i < _dim[0]; i++ )
|
||||
for( var j = 0; j < _dim[1]; j++ ) {
|
||||
_tile_arr[ind++] = _data[i][j];
|
||||
}
|
||||
|
||||
var _templateDir = filepath_resolve("%APP%/data/TemplateStrings/");
|
||||
|
||||
if(gmType == 0) {
|
||||
var _template_str = file_read_all(_templateDir + "tileset_gamemaker2_room.yy");
|
||||
var _template_map = json_try_parse(_template_str);
|
||||
|
||||
if(_template_map == -1) return;
|
||||
|
||||
_template_map.parent.name = gmRname;
|
||||
_template_map.parent.path = $"folders/{gmRname}.yy";
|
||||
|
||||
var _layer = _template_map.layers[0];
|
||||
|
||||
_layer.name = gmLname;
|
||||
_layer.gridX = tileSize[0] / 2;
|
||||
_layer.gridY = tileSize[1] / 2;
|
||||
_layer.tilesetId.name = tileName;
|
||||
_layer.tilesetId.path = $"tilesets/{tileName}/{tileName}.yy";
|
||||
|
||||
_layer.tiles.SerialiseWidth = _dim[0];
|
||||
_layer.tiles.SerialiseHeight = _dim[1];
|
||||
_layer.tiles.TileSerialiseData = _tile_arr;
|
||||
|
||||
path = filename_change_ext(path, ".yy");
|
||||
if(file_exists_empty(path)) file_delete(path);
|
||||
|
||||
file_text_write_all(path, json_stringify(_template_map, true));
|
||||
|
||||
var _txt = $"Export GameMaker room complete.";
|
||||
logNode(_txt);
|
||||
|
||||
var noti = log_message("EXPORT", _txt, THEME.noti_icon_tick, COLORS._main_value_positive, false);
|
||||
noti.path = filename_dir(path);
|
||||
noti.setOnClick(function() /*=>*/ { shellOpenExplorer(self.path); }, "Open in explorer", THEME.explorer);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Godot":
|
||||
var gdScene = inputs[8].getValue();
|
||||
if(!file_exists_empty(gdScene)) return;
|
||||
|
||||
var _gdData = file_read_all(gdScene);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,9 +36,8 @@
|
|||
globalNode = new Node_Global();
|
||||
nodeController = new __Node_Controller(self);
|
||||
|
||||
load_layout = false;
|
||||
|
||||
previewNode = "";
|
||||
load_layout = false;
|
||||
previewNode = "";
|
||||
inspectingNode = "";
|
||||
|
||||
previewGrid = {
|
||||
|
@ -89,6 +88,14 @@
|
|||
tunnels_in_map = ds_map_create();
|
||||
tunnels_out = ds_map_create();
|
||||
|
||||
#region ===================== BINDERS ====================
|
||||
bind_gamemaker_path = "";
|
||||
bind_godot_path = "";
|
||||
|
||||
bind_gamemaker = noone;
|
||||
bind_godot = noone;
|
||||
#endregion
|
||||
|
||||
#region =================== ATTRIBUTES ===================
|
||||
attributes = variable_clone(PROJECT_ATTRIBUTES);
|
||||
|
||||
|
@ -259,6 +266,9 @@
|
|||
}
|
||||
_map.addon = _addon;
|
||||
|
||||
_map.bind_gamemaker_path = bind_gamemaker_path;
|
||||
_map.bind_godot_path = bind_godot_path;
|
||||
|
||||
return _map;
|
||||
}
|
||||
|
||||
|
@ -313,6 +323,9 @@
|
|||
var _node = nodeMap[? inspectingNode];
|
||||
if(_node) PANEL_INSPECTOR.setInspecting(_node);
|
||||
}
|
||||
|
||||
if(struct_has(_map, "bind_gamemaker_path")) bind_gamemaker_path = _map.bind_gamemaker_path;
|
||||
if(struct_has(_map, "bind_godot_path")) bind_godot_path = _map.bind_godot_path;
|
||||
}
|
||||
|
||||
static postDeserialize = function() {
|
||||
|
|
Loading…
Reference in a new issue