[Dialog] Dialog resize now works on top and left direction.

This commit is contained in:
Tanasart 2024-12-15 07:47:22 +07:00
parent 64390ed315
commit efc09945a6
27 changed files with 699 additions and 217 deletions

View file

@ -22,12 +22,50 @@
{"name":"gizmo","order":8,"path":"folders/functions/3d/gizmo.yy",},
{"name":"light","order":9,"path":"folders/functions/3d/light.yy",},
{"name":"util","order":11,"path":"folders/functions/3d/util.yy",},
{"name":"action","order":1,"path":"folders/functions/action.yy",},
{"name":"animation","order":2,"path":"folders/functions/animation.yy",},
{"name":"async","order":3,"path":"folders/functions/async.yy",},
{"name":"audio","order":4,"path":"folders/functions/audio.yy",},
{"name":"bones","order":5,"path":"folders/functions/bones.yy",},
{"name":"buffer","order":6,"path":"folders/functions/buffer.yy",},
{"name":"compat","order":7,"path":"folders/functions/compat.yy",},
{"name":"connection","order":8,"path":"folders/functions/connection.yy",},
{"name":"control","order":9,"path":"folders/functions/control.yy",},
{"name":"curve","order":10,"path":"folders/functions/curve.yy",},
{"name":"debug","order":11,"path":"folders/functions/debug.yy",},
{"name":"delaunay","order":12,"path":"folders/functions/delaunay.yy",},
{"name":"draw","order":13,"path":"folders/functions/draw.yy",},
{"name":"dynaSurf","order":20,"path":"folders/functions/draw/dynaSurf.yy",},
{"name":"ds","order":14,"path":"folders/functions/ds.yy",},
{"name":"files","order":15,"path":"folders/functions/files.yy",},
{"name":"gamemaker","order":17,"path":"folders/functions/gamemaker.yy",},
{"name":"geometry","order":16,"path":"folders/functions/geometry.yy",},
{"name":"GLSL","order":18,"path":"folders/functions/GLSL.yy",},
{"name":"importers","order":19,"path":"folders/functions/importers.yy",},
{"name":"inputs","order":20,"path":"folders/functions/inputs.yy",},
{"name":"lua","order":21,"path":"folders/functions/lua.yy",},
{"name":"math","order":22,"path":"folders/functions/math.yy",},
{"name":"nodes","order":23,"path":"folders/functions/nodes.yy",},
{"name":"packing","order":24,"path":"folders/functions/packing.yy",},
{"name":"PCX","order":25,"path":"folders/functions/PCX.yy",},
{"name":"pen_input","order":26,"path":"folders/functions/pen_input.yy",},
{"name":"physics","order":27,"path":"folders/functions/physics.yy",},
{"name":"project","order":28,"path":"folders/functions/project.yy",},
{"name":"shader","order":29,"path":"folders/functions/shader.yy",},
{"name":"sprite","order":30,"path":"folders/functions/sprite.yy",},
{"name":"string","order":31,"path":"folders/functions/string.yy",},
{"name":"surface","order":32,"path":"folders/functions/surface.yy",},
{"name":"dynamic_surface","order":8,"path":"folders/functions/surface/dynamic_surface.yy",},
{"name":"svg","order":47,"path":"folders/functions/svg.yy",},
{"name":"svg","order":46,"path":"folders/functions/svg.yy",},
{"name":"test","order":33,"path":"folders/functions/test.yy",},
{"name":"tooltip","order":34,"path":"folders/functions/tooltip.yy",},
{"name":"tween","order":35,"path":"folders/functions/tween.yy",},
{"name":"value","order":36,"path":"folders/functions/value.yy",},
{"name":"variables","order":37,"path":"folders/functions/variables.yy",},
{"name":"vector","order":38,"path":"folders/functions/vector.yy",},
{"name":"window","order":39,"path":"folders/functions/window.yy",},
{"name":"main","order":328,"path":"folders/main.yy",},
{"name":"binder","order":3,"path":"folders/main/binder.yy",},
{"name":"components","order":2,"path":"folders/main/components.yy",},
{"name":"components","order":3,"path":"folders/main/components.yy",},
{"name":"misc","order":337,"path":"folders/misc.yy",},
{"name":"animation_curve","order":1,"path":"folders/misc/animation_curve.yy",},
{"name":"nodes","order":330,"path":"folders/nodes.yy",},
@ -532,12 +570,12 @@
{"name":"d3d_uvsphere","order":4,"path":"scripts/d3d_uvsphere/d3d_uvsphere.yy",},
{"name":"d3d_vertex","order":10,"path":"scripts/d3d_vertex/d3d_vertex.yy",},
{"name":"d3d_wall_builder","order":1,"path":"scripts/d3d_wall_builder/d3d_wall_builder.yy",},
{"name":"debug","order":10,"path":"scripts/debug/debug.yy",},
{"name":"debug","order":40,"path":"scripts/debug/debug.yy",},
{"name":"delaunay","order":1,"path":"scripts/delaunay/delaunay.yy",},
{"name":"dialog_management","order":2,"path":"scripts/dialog_management/dialog_management.yy",},
{"name":"directory_functions","order":9,"path":"scripts/directory_functions/directory_functions.yy",},
{"name":"directory_object","order":3,"path":"scripts/directory_object/directory_object.yy",},
{"name":"display_refresh","order":17,"path":"scripts/display_refresh/display_refresh.yy",},
{"name":"display_refresh","order":41,"path":"scripts/display_refresh/display_refresh.yy",},
{"name":"distribution_function","order":12,"path":"scripts/distribution_function/distribution_function.yy",},
{"name":"draw_arc","order":16,"path":"scripts/draw_arc/draw_arc.yy",},
{"name":"draw_circle_functions","order":3,"path":"scripts/draw_circle_functions/draw_circle_functions.yy",},
@ -1303,7 +1341,7 @@
{"name":"preview_overlay_rotation","order":1,"path":"scripts/preview_overlay_rotation/preview_overlay_rotation.yy",},
{"name":"preview_overlay_vector","order":2,"path":"scripts/preview_overlay_vector/preview_overlay_vector.yy",},
{"name":"printer","order":2,"path":"scripts/printer/printer.yy",},
{"name":"process_functions","order":36,"path":"scripts/process_functions/process_functions.yy",},
{"name":"process_functions","order":44,"path":"scripts/process_functions/process_functions.yy",},
{"name":"project_data","order":17,"path":"scripts/project_data/project_data.yy",},
{"name":"project_function","order":2,"path":"scripts/project_function/project_function.yy",},
{"name":"pseudo_regex","order":7,"path":"scripts/pseudo_regex/pseudo_regex.yy",},
@ -1318,7 +1356,7 @@
{"name":"save_function","order":1,"path":"scripts/save_function/save_function.yy",},
{"name":"scrollBox","order":2,"path":"scripts/scrollBox/scrollBox.yy",},
{"name":"scrollPane","order":3,"path":"scripts/scrollPane/scrollPane.yy",},
{"name":"shell_functions","order":20,"path":"scripts/shell_functions/shell_functions.yy",},
{"name":"shell_functions","order":42,"path":"scripts/shell_functions/shell_functions.yy",},
{"name":"sliderRange","order":2,"path":"scripts/sliderRange/sliderRange.yy",},
{"name":"SnapBufferWriteXML","order":1,"path":"scripts/SnapBufferWriteXML/SnapBufferWriteXML.yy",},
{"name":"SnapFromXML","order":2,"path":"scripts/SnapFromXML/SnapFromXML.yy",},
@ -1350,7 +1388,7 @@
{"name":"tiler_tool_selection_shape","order":6,"path":"scripts/tiler_tool_selection_shape/tiler_tool_selection_shape.yy",},
{"name":"tiler_tool_selection","order":5,"path":"scripts/tiler_tool_selection/tiler_tool_selection.yy",},
{"name":"tilesetBox","order":1,"path":"scripts/tilesetBox/tilesetBox.yy",},
{"name":"time_source","order":25,"path":"scripts/time_source/time_source.yy",},
{"name":"time_source","order":43,"path":"scripts/time_source/time_source.yy",},
{"name":"timeline_data","order":18,"path":"scripts/timeline_data/timeline_data.yy",},
{"name":"toggleGroup","order":7,"path":"scripts/toggleGroup/toggleGroup.yy",},
{"name":"tooltip_hotkey","order":2,"path":"scripts/tooltip_hotkey/tooltip_hotkey.yy",},

View file

@ -76,6 +76,7 @@
{"$GMFolder":"","%Name":"dynaSurf","folderPath":"folders/functions/draw/dynaSurf.yy","name":"dynaSurf","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"ds","folderPath":"folders/functions/ds.yy","name":"ds","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"files","folderPath":"folders/functions/files.yy","name":"files","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"gamemaker","folderPath":"folders/functions/gamemaker.yy","name":"gamemaker","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"geometry","folderPath":"folders/functions/geometry.yy","name":"geometry","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"GLSL","folderPath":"folders/functions/GLSL.yy","name":"GLSL","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"importers","folderPath":"folders/functions/importers.yy","name":"importers","resourceType":"GMFolder","resourceVersion":"2.0",},
@ -102,7 +103,6 @@
{"$GMFolder":"","%Name":"vector","folderPath":"folders/functions/vector.yy","name":"vector","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$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":"binder","folderPath":"folders/main/binder.yy","name":"binder","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"components","folderPath":"folders/main/components.yy","name":"components","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"misc","folderPath":"folders/misc.yy","name":"misc","resourceType":"GMFolder","resourceVersion":"2.0",},
{"$GMFolder":"","%Name":"animation_curve","folderPath":"folders/misc/animation_curve.yy","name":"animation_curve","resourceType":"GMFolder","resourceVersion":"2.0",},

View file

@ -94,7 +94,7 @@
dialog_dragging = false;
}
if(mouse_draggable && point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + title_height)) {
if(mouse_draggable && !dialog_resizing && point_in_rectangle(mouse_mx, mouse_my, dialog_x, dialog_y, dialog_x + dialog_w, dialog_y + title_height)) {
mouse_active = false;
if(mouse_press(mb_left, sFOCUS)) {
dialog_dragging = true;
@ -137,58 +137,95 @@
dialog_resizable = false;
dialog_resizing = 0;
dialog_resiz_sx = 0;
dialog_resiz_sy = 0;
dialog_resiz_sw = 0;
dialog_resiz_sh = 0;
dialog_resiz_mx = 0;
dialog_resiz_my = 0;
dialog_w_min = 320;
dialog_h_min = 320;
dialog_w_max = WIN_W;
dialog_h_max = WIN_H;
onResize = -1;
dialog_w_min = 320;
dialog_h_min = 320;
dialog_w_max = WIN_W;
dialog_h_max = WIN_H;
onResize = -1;
function doResize() {
if(!active) return;
if(!dialog_resizable) return;
if(window == noone) {
if(dialog_resizing & 1 << 0 != 0) {
var ww = dialog_resiz_sw + (mouse_mx - dialog_resiz_mx);
ww = clamp(ww, dialog_w_min, dialog_w_max);
dialog_w = ww;
}
if(dialog_resizing & 1 << 1 != 0) {
var hh = dialog_resiz_sh + (mouse_my - dialog_resiz_my);
hh = clamp(hh, dialog_h_min, dialog_h_max);
dialog_h = hh;
if(dialog_resizing != 0) {
if(dialog_resizing & 0b0001) {
var ww = dialog_resiz_sw + (mouse_mx - dialog_resiz_mx);
ww = clamp(ww, dialog_w_min, dialog_w_max);
dialog_w = ww;
}
if(dialog_resizing & 0b0010) {
var hh = dialog_resiz_sh + (mouse_my - dialog_resiz_my);
hh = clamp(hh, dialog_h_min, dialog_h_max);
dialog_h = hh;
}
if(dialog_resizing & 0b0100) {
var ww = dialog_resiz_sw - (mouse_mx - dialog_resiz_mx);
ww = clamp(ww, dialog_w_min, dialog_w_max);
dialog_x = dialog_resiz_sx - (ww - dialog_resiz_sw);
dialog_w = ww;
}
if(dialog_resizing & 0b1000) {
var hh = dialog_resiz_sh - (mouse_my - dialog_resiz_my);
hh = clamp(hh, dialog_h_min, dialog_h_max);
dialog_y = dialog_resiz_sy - (hh - dialog_resiz_sh);
dialog_h = hh;
}
switch(dialog_resizing) {
case 0b0001 : case 0b0100 : CURSOR = cr_size_we; break;
case 0b0010 : case 0b1000 : CURSOR = cr_size_ns; break;
case 0b0011 : case 0b1100 : CURSOR = cr_size_nwse; break;
case 0b1001 : case 0b0110 : CURSOR = cr_size_nesw; break;
}
if(mouse_release(mb_left)) dialog_resizing = 0;
}
if(mouse_release(mb_left)) dialog_resizing = 0;
if(sHOVER && distance_to_line(mouse_mx, mouse_my, dialog_x + dialog_w, dialog_y, dialog_x + dialog_w, dialog_y + dialog_h) < 12) {
if(sHOVER) {
var _x0 = dialog_x;
var _y0 = dialog_y;
var _x1 = dialog_x + dialog_w;
var _y1 = dialog_y + dialog_h;
var _sel_mask = 0;
mouse_active = false;
CURSOR = cr_size_we;
if(mouse_press(mb_left, sFOCUS)) {
dialog_resizing |= 1 << 0;
dialog_resiz_sw = dialog_w;
dialog_resiz_mx = mouse_mx;
dialog_resiz_my = mouse_my;
if(point_in_rectangle(mouse_mx, mouse_my, _x0, _y0, _x1, _y1)) {
if(distance_to_line(mouse_mx, mouse_my, _x1, _y0, _x1, _y1) < DIALOG_PAD) _sel_mask |= 1 << 0;
if(distance_to_line(mouse_mx, mouse_my, _x0, _y1, _x1, _y1) < DIALOG_PAD) _sel_mask |= 1 << 1;
if(distance_to_line(mouse_mx, mouse_my, _x0, _y0, _x0, _y1) < DIALOG_PAD) _sel_mask |= 1 << 2;
if(distance_to_line(mouse_mx, mouse_my, _x0, _y0, _x1, _y0) < DIALOG_PAD) _sel_mask |= 1 << 3;
}
}
if(sHOVER && distance_to_line(mouse_mx, mouse_my, dialog_x, dialog_y + dialog_h, dialog_x + dialog_w, dialog_y + dialog_h) < 12) {
mouse_active = false;
if(CURSOR == cr_size_we) CURSOR = cr_size_nwse;
else CURSOR = cr_size_ns;
if(mouse_press(mb_left, sFOCUS)) {
dialog_resizing |= 1 << 1;
dialog_resiz_sh = dialog_h;
dialog_resiz_mx = mouse_mx;
dialog_resiz_my = mouse_my;
if(_sel_mask != 0) {
mouse_active = false;
switch(_sel_mask) {
case 0b0001 : case 0b0100 : CURSOR = cr_size_we; break;
case 0b0010 : case 0b1000 : CURSOR = cr_size_ns; break;
case 0b0011 : case 0b1100 : CURSOR = cr_size_nwse; break;
case 0b1001 : case 0b0110 : CURSOR = cr_size_nesw; break;
}
if(mouse_press(mb_left, sFOCUS)) {
dialog_resizing = _sel_mask;
dialog_resiz_sx = dialog_x;
dialog_resiz_sy = dialog_y;
dialog_resiz_sw = dialog_w;
dialog_resiz_sh = dialog_h;
dialog_resiz_mx = mouse_mx;
dialog_resiz_my = mouse_my;
}
}
}

View file

@ -2,4 +2,6 @@
depth = -9999;
selecting = noone;
onApply = noone;
onApply = noone;
palette = array_clone(DEF_PALETTE);

View file

@ -1,6 +1,6 @@
/// @description
var pal = DEF_PALETTE;
var pal = palette;
var col = min(array_length(pal), 8);
var row = ceil(array_length(pal) / col);

View file

@ -20,10 +20,10 @@ event_inherited();
if(struct_has(content, "title_height"))
title_height = content.title_height;
dialog_w = content.w + content.showHeader * padding * 2;
dialog_h = content.h + content.showHeader * (padding * 2 + title_height);
dialog_w_min = content.min_w;
dialog_h_min = content.min_h;
dialog_w = content.w + content.showHeader * padding * 2;
dialog_h = content.h + content.showHeader * (padding * 2 + title_height);
dialog_w_min = content.min_w;
dialog_h_min = content.min_h;
dialog_resizable = content.resizable;
content.panel = self;

View file

@ -18,7 +18,7 @@ if(winMan_isMinimized()) exit;
var type = TOOLTIP[1];
if(is_method(content)) content = content();
switch(type) {
case VALUE_TYPE.float :
@ -173,6 +173,10 @@ if(winMan_isMinimized()) exit;
}
break;
case "GMRoom" :
draw_sprite_ext(s_gmroom, 0, mx + ui(32), my + ui(32), 1, 1, 0, c_white, 1);
break;
default:
draw_set_alpha(0.5);
draw_set_text(f_h3, fa_center, fa_center, COLORS._main_text);

View file

@ -103,8 +103,8 @@ _FILE_DROPPED = false;
with(_p_dialog) checkFocus(); WINDOW_ACTIVE = noone;
with(_p_dialog) checkDepth(); WINDOW_ACTIVE = noone;
with(_p_dialog) doDrag(); WINDOW_ACTIVE = noone;
with(_p_dialog) doResize(); WINDOW_ACTIVE = noone;
with(_p_dialog) doDrag(); WINDOW_ACTIVE = noone;
#endregion
#region auto save

View file

@ -1,3 +1,10 @@
enum __GM_FILE_DATATYPE {
float,
integer,
bool,
string,
}
function Binder_Gamemaker(path) {
if(!file_exists_empty(path)) return noone;
if(filename_ext(path) != ".yyp") return noone;
@ -5,16 +12,74 @@ function Binder_Gamemaker(path) {
return new __Binder_Gamemaker(path);
}
function GMObject(_gm, _path, _info) constructor {
function GMObject(_gm, _rpth, _rawData) constructor {
serialize_keys = {};
gmBinder = _gm;
path = $"{_gm.dir}/{_path}";
key = _path;
raw = _info;
type = _info.resourceType;
path = $"{_gm.dir}/{_rpth}";
key = _rpth;
raw = _rawData;
type = _rawData.resourceType;
thumbnail = noone;
static formatPrimitive = function(key, val) {
if(is_undefined(val)) return "null";
var _type = key != "" && struct_has(serialize_keys, key)? serialize_keys[$ key] : (is_string(val)? __GM_FILE_DATATYPE.string : __GM_FILE_DATATYPE.float);
switch(_type) {
case __GM_FILE_DATATYPE.float : return string(val);
case __GM_FILE_DATATYPE.integer : return string_format(val, -1, 0);
case __GM_FILE_DATATYPE.bool : return bool(val)? "true" : "false";
case __GM_FILE_DATATYPE.string : return $"\"{val}\"";
}
return val;
}
static simple_serialize = function(s, _pad, _depth = 0, _nline = false) {
if(is_array(s)) {
if(array_empty(s)) return "[]";
var _d1 = _depth <= 1;
var _str = _d1? "[\n" : "[";
var _nl = _d1? ",\n" : ",";
var _padd = _d1? _pad + " " : "";
for( var i = 0, n = array_length(s); i < n; i++ )
_str += $"{_padd}{simple_serialize(s[i], _pad, _depth + 1)}{_nl}";
_str += _d1? _pad + "]" : "]";
return _str;
} else if(is_struct(s)) {
var _keys = struct_get_names(s);
array_sort(_keys, function(a, b) /*=>*/ {return string_compare(a, b)});
var _str = _nline? "{\n" : "{";
var _nl = _nline? ",\n" : ",";
var _padd = _nline? _pad + " " : "";
for( var i = 0, n = array_length(_keys); i < n; i++ ) {
var _k = _keys[i];
var _v = s[$ _k];
_str += _padd;
_str += $"\"{_k}\":{is_array(_v) || is_struct(_v)? simple_serialize(_v, _padd, _depth + 1) : formatPrimitive(_k, _v)}";
_str += _nl;
}
_str += _pad + "}"
return _str;
}
return formatPrimitive("", s);
}
static sync = function() { file_text_write_all(path, json_stringify(raw)); }
static link = function() {}
}
function GMSprite(_gm, _path, _info) : GMObject(_gm, _path, _info) constructor {
function GMSprite(_gm, _rpth, _rawData) : GMObject(_gm, _rpth, _rawData) constructor {
var _dirr = filename_dir(path);
var _frame = raw.frames;
var _layers = raw.layers;
@ -27,8 +92,12 @@ function GMSprite(_gm, _path, _info) : GMObject(_gm, _path, _info) constructor {
thumbnail = sprite_add(thumbnailPath, 0, 0, 0, 0, 0);
}
function GMTileset(_gm, _path, _info) : GMObject(_gm, _path, _info) constructor {
function GMTileset(_gm, _rpth, _rawData) : GMObject(_gm, _rpth, _rawData) constructor {
sprite = raw.spriteId.path;
static link = function() {
spriteObject = gmBinder.getResourceFromPath(sprite);
}
}
function __Binder_Gamemaker(path) constructor {
@ -39,27 +108,26 @@ function __Binder_Gamemaker(path) constructor {
resourcesRaw = [];
resourcesMap = {};
resourceList = [];
resources = [
{ name: "sprites", data : [], closed : false, },
{ name: "tileset", data : [], closed : false, },
{ name: "rooms", data : [], closed : false, },
];
static getResourceFromPath = function(path) { return struct_try_get(resourcesMap, path, noone); }
static readYY = function(path) {
var _res = file_read_all(path);
var _resMap = json_try_parse(_res, -1);
if(_resMap == -1) return noone;
return _resMap;
var _map = json_try_parse(_res, noone);
return _map;
}
static refreshResources = function() {
if(!file_exists(path)) return;
var _res = file_read_all(path);
var _resMap = json_try_parse(_res, -1);
if(_resMap == -1) return;
var _resMap = readYY(path);
if(_resMap == noone) return;
projectName = _resMap.name;
resourcesRaw = _resMap.resources;
@ -72,19 +140,25 @@ function __Binder_Gamemaker(path) constructor {
for( var i = 0, n = array_length(resourcesRaw); i < n; i++ ) {
var _res = resourcesRaw[i].id;
var _name = _res.name;
var _path = _res.path;
var _rpth = _res.path;
var _info = readYY($"{dir}/{_path}");
if(_info == noone) continue;
var _rawData = readYY($"{dir}/{_rpth}");
if(_rawData == noone) continue;
var _asset = noone;
switch(_info.resourceType) {
case "GMSprite": _asset = new GMSprite(self, _path, _info); array_push(sprites, _asset); break;
case "GMTileSet": _asset = new GMTileset(self, _path, _info); array_push(tileset, _asset); break;
case "GMRoom": _asset = new GMRoom(self, _path, _info); array_push(rooms, _asset); break;
switch(_rawData.resourceType) {
case "GMSprite": _asset = new GMSprite( self, _rpth, _rawData); array_push(sprites, _asset); break;
case "GMTileSet": _asset = new GMTileset(self, _rpth, _rawData); array_push(tileset, _asset); break;
case "GMRoom": _asset = new GMRoom( self, _rpth, _rawData); array_push(rooms, _asset); break;
}
resourcesMap[$ _path] = _asset;
resourcesMap[$ _rpth] = _asset;
array_push(resourceList, _asset);
}
for( var i = 0, n = array_length(resourceList); i < n; i++ ) {
resourceList[i].link();
}
resources[0].data = sprites;

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"binder_gamemaker",
"parent":{
"name":"binder",
"path":"folders/main/binder.yy",
"name":"gamemaker",
"path":"folders/functions/gamemaker.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -1,58 +1,152 @@
function GMRoom(_gm, _path, _info) : GMObject(_gm, _path, _info) constructor {
layers = GMRoom_create_layers(raw.layers);
function GMRoom(_gm, _rpth, _rawData) : GMObject(_gm, _rpth, _rawData) constructor {
struct_append(serialize_keys, {
effectEnabled: __GM_FILE_DATATYPE.bool,
inheritSubLayers: __GM_FILE_DATATYPE.bool,
inheritVisibility: __GM_FILE_DATATYPE.bool,
visible: __GM_FILE_DATATYPE.bool,
clearDisplayBuffer: __GM_FILE_DATATYPE.bool,
inheritCode: __GM_FILE_DATATYPE.bool,
inheritCreationOrder: __GM_FILE_DATATYPE.bool,
inheritLayers: __GM_FILE_DATATYPE.bool,
isDnd: __GM_FILE_DATATYPE.bool,
hierarchyFrozen: __GM_FILE_DATATYPE.bool,
inheritLayerDepth: __GM_FILE_DATATYPE.bool,
inheritLayerSettings: __GM_FILE_DATATYPE.bool,
userdefinedDepth: __GM_FILE_DATATYPE.bool,
htiled: __GM_FILE_DATATYPE.bool,
stretch: __GM_FILE_DATATYPE.bool,
userdefinedAnimFPS: __GM_FILE_DATATYPE.bool,
vtiled: __GM_FILE_DATATYPE.bool,
inheritPhysicsSettings: __GM_FILE_DATATYPE.bool,
PhysicsWorld: __GM_FILE_DATATYPE.bool,
inheritRoomSettings: __GM_FILE_DATATYPE.bool,
persistent: __GM_FILE_DATATYPE.bool,
inherit: __GM_FILE_DATATYPE.bool,
clearViewBackground: __GM_FILE_DATATYPE.bool,
enableViews: __GM_FILE_DATATYPE.bool,
inheritViewSettings: __GM_FILE_DATATYPE.bool,
})
layers = GMRoom_create_layers(self, gmBinder, raw.layers);
roomSettings = raw.roomSettings;
static link = function() { array_foreach(layers, function(l) /*=>*/ {return l.link()}); }
static getLayerFromName = function(_name) {
for( var i = 0, n = array_length(layers); i < n; i++ ) {
var _r = layers[i].getLayerFromName(_name);
if(_r != noone) return _r;
}
return noone;
}
static sync = function() {
var _keys = struct_get_names(raw);
array_sort(_keys, function(a, b) /*=>*/ {return string_compare(a, b)});
var _str = "{\n";
var _nl = ",\n";
var _padd = " ";
for( var i = 0, n = array_length(_keys); i < n; i++ ) {
var _k = _keys[i];
var _v = raw[$ _k];
var _snl = false;
switch(_k) {
case "parent" :
case "physicsSettings" :
case "roomSettings" :
case "viewSettings" :
_snl = true;
break;
}
_str += _padd;
if(is_array(_v) || is_struct(_v)) _str += $"\"{_k}\":{simple_serialize(_v, _padd, 0, _snl)}";
else _str += $"\"{_k}\":{formatPrimitive(_k, _v)}";
_str += _nl;
}
_str += "}"
file_text_write_all(path, _str);
}
}
function GMRoom_create_layers(layers) {
function GMRoom_create_layers(_room, _gm, layers) {
var _l = [];
for( var i = 0, n = array_length(layers); i < n; i++ ) {
var _dat = layers[i];
switch(_dat.resourceType) {
case "GMRBackgroundLayer" : _l[i] = new GMRoom_Background(_dat); break;
case "GMRTileLayer" : _l[i] = new GMRoom_Tile(_dat); break;
case "GMRInstanceLayer" : _l[i] = new GMRoom_Instance(_dat); break;
case "GMRPathLayer" : _l[i] = new GMRoom_Path(_dat); break;
case "GMRAssetLayer" : _l[i] = new GMRoom_Asset(_dat); break;
case "GMREffectLayer" : _l[i] = new GMRoom_Effect(_dat); break;
default : _l[i] = new GMRoom_Layer(_dat); break;
case "GMRBackgroundLayer" : _l[i] = new GMRoom_Background( _room, _gm, _dat); break;
case "GMRTileLayer" : _l[i] = new GMRoom_Tile( _room, _gm, _dat); break;
case "GMRInstanceLayer" : _l[i] = new GMRoom_Instance( _room, _gm, _dat); break;
case "GMRPathLayer" : _l[i] = new GMRoom_Path( _room, _gm, _dat); break;
case "GMRAssetLayer" : _l[i] = new GMRoom_Asset( _room, _gm, _dat); break;
case "GMREffectLayer" : _l[i] = new GMRoom_Effect( _room, _gm, _dat); break;
default : _l[i] = new GMRoom_Layer( _room, _gm, _dat); break;
}
}
return _l;
}
function GMRoom_Layer(_raw) constructor {
name = _raw.name;
visible = _raw.visible;
depth = _raw.depth;
layers = GMRoom_create_layers(_raw.layers);
function GMRoom_Layer(_room, _gm, _raw) constructor {
gmBinder = _gm;
room = _room;
raw = _raw;
name = _raw.name;
visible = _raw.visible;
depth = _raw.depth;
layers = GMRoom_create_layers(_gm, _raw.layers);
index = 6;
static link = function() { array_foreach(layers, function(l) /*=>*/ {return l.link()}); }
static getLayerFromName = function(_name) {
if(name == _name) return self;
for( var i = 0, n = array_length(layers); i < n; i++ ) {
var _r = layers[i].getLayerFromName(_name);
if(_r != noone) return _r;
}
return noone;
}
}
function GMRoom_Background(_raw) : GMRoom_Layer(_raw) constructor {
function GMRoom_Background(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor {
index = 0;
x = _raw.x;
x = raw.x;
y = raw.y;
y = _raw.y;
colour = _raw.colour;
colour = raw.colour;
}
function GMRoom_Tile(_raw) : GMRoom_Layer(_raw) constructor {
function GMRoom_Tile(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor {
index = 1;
x = _raw.x;
y = _raw.y;
x = raw.x;
y = raw.y;
tiles = _raw.tiles;
tilesetId = _raw.tilesetId;
tiles = raw.tiles;
tilesetId = raw.tilesetId;
tileset = noone;
amount_w = tiles.SerialiseWidth;
amount_h = tiles.SerialiseHeight;
static link = function() {
tileset = gmBinder.getResourceFromPath(struct_try_get(tilesetId, "path", ""));
array_foreach(layers, function(l) /*=>*/ {return l.link()});
}
}
function GMRoom_Instance(_raw) : GMRoom_Layer(_raw) constructor { index = 2; }
function GMRoom_Path(_raw) : GMRoom_Layer(_raw) constructor { index = 3; }
function GMRoom_Asset(_raw) : GMRoom_Layer(_raw) constructor { index = 4; }
function GMRoom_Effect(_raw) : GMRoom_Layer(_raw) constructor { index = 5; }
function GMRoom_Instance(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor { index = 2; }
function GMRoom_Path(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor { index = 3; }
function GMRoom_Asset(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor { index = 4; }
function GMRoom_Effect(_room, _gm, _raw) : GMRoom_Layer(_room, _gm, _raw) constructor { index = 5; }

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"binder_gamemaker_room",
"parent":{
"name":"binder",
"path":"folders/main/binder.yy",
"name":"gamemaker",
"path":"folders/functions/gamemaker.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -25,6 +25,7 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
b_quick_pick = button(function() {
var pick = instance_create(mouse_mx, mouse_my, o_dialog_color_quick_pick);
array_insert(pick.palette, 0, current_color);
pick.onApply = onApply;
});
b_quick_pick.activate_on_press = true;
@ -81,6 +82,7 @@ function buttonColor(_onApply, dialog = noone) : widget() constructor {
_cw -= ui(32);
b_picker.setFocusHover(active && !instance_exists(o_dialog_color_quick_pick), hover);
b_picker.draw(bx, _y + _h / 2 - _bs / 2, ui(32), _bs, _m, THEME.button_hide);
b_picker.icon_blend = c_white;
b_picker.icon_index = 0;

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"gamemakerPathBox",
"parent":{
"name":"binder",
"path":"folders/main/binder.yy",
"name":"gamemaker",
"path":"folders/functions/gamemaker.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -44,7 +44,7 @@
LATEST_VERSION = 1_18_00_0;
VERSION = 1_18_05_1;
SAVE_VERSION = 1_18_05_0;
VERSION_STRING = MAC? "1.18.003m" : "1.18.6.002";
VERSION_STRING = MAC? "1.18.003m" : "1.18.6.003";
BUILD_NUMBER = 1_18_05_1;
var _vsp = string_split(VERSION_STRING, ".");
@ -159,9 +159,14 @@
#endregion
#macro RETURN_ON_REST if(!PROJECT.animator.is_playing || !PROJECT.animator.frame_progress) return;
#macro PANEL_PAD THEME_VALUE.panel_padding
//!#mfunc returnNull {"args":["v"," a"],"order":[0,1,0,0]}
#macro returnNull_mf0 var
#macro returnNull_mf1 =
#macro returnNull_mf2 ; if(is_undefined(
#macro returnNull_mf3 ) ||
#macro returnNull_mf4 == noone) return;
#endregion
#region presets

View file

@ -5,8 +5,8 @@
"isDnD":false,
"name":"globals",
"parent":{
"name":"components",
"path":"folders/main/components.yy",
"name":"main",
"path":"folders/main.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",

View file

@ -342,7 +342,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc
wid.setFocusHover(_focus, _hover);
if(jun.connect_type == CONNECT_TYPE.input) {
wid.setInteract(!jun.hasJunctionFrom());
wid.setInteract(jun.editable && !jun.hasJunctionFrom());
if(_focus) wid.register(_scrollPane);
if(is_instanceof(jun, __NodeValue_Dimension)) {

View file

@ -79,7 +79,6 @@ function Node_Array(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
array_push(input_display_list, i);
}
inputs = _l;
getJunctionList();

View file

@ -123,6 +123,7 @@ function Node_Colors_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _g
_x2 -= ui(32 + 4);
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), _m, _focus, _hover,, THEME.color_wheel,, c_white) == 2) {
var pick = instance_create(mouse_mx, mouse_my, o_dialog_color_quick_pick);
array_insert(pick.palette, 0, to);
pick.onApply = setColor;
palette_select = [ i, i ];
}

View file

@ -1,15 +1,23 @@
function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "GMRoom";
color = COLORS.node_blend_input;
gmRoom = noone;
gmRoom = noone;
layers = [];
layerMap = {};
newInput( 0, nodeValue_Vec2("Room size", self, [ 16, 16 ]));
newInput( 1, nodeValue_Bool("Persistance", self, false));
attributes.exposed_layer = [];
layer_selecting = noone;
tb_depth = new textBox(TEXTBOX_INPUT.number, function(v) /*=>*/ {
if(layer_selecting == noone) return;
layer_selecting.raw.depth = round(v);
});
tb_depth.label = "Depth";
tb_depth.font = f_p3;
layers_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
if(gmRoom == noone) {
@ -47,35 +55,223 @@ function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
return _h;
});
layer_renderer_h = 0;
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
if(layer_selecting == noone) {
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, ui(28), COLORS.node_composite_bg_blend, 1);
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text_sub);
draw_text(_x + _w / 2, _y + ui(14), "No layer selected");
return ui(28);
}
var _h = ui(64);
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, _h, COLORS.node_composite_bg_blend, 1);
var _h = ui(40);
var _l = layer_selecting;
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _y, _w, layer_renderer_h, COLORS.node_composite_bg_blend, 1);
draw_sprite_ui_uniform(s_gmlayer, _l.index, _x + ui(8 + 16), _y + ui(8 + 16), 1, COLORS._main_icon);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text_add(_x + ui(8 + 32), _y + ui(8 + 16), layer_selecting.name);
var _wdw = ui(128);
var _wdx = _x + _w - _wdw - ui(8);
var _yy = _y + ui(8);
var _wdy = _yy;
var _wdh = ui(32);
var _wpr = new widgetParam(_wdx, _wdy, _wdw, _wdh, _l.raw.depth, {}, _m, layer_renderer.rx, layer_renderer.ry);
_wpr.color = COLORS._main_icon_light;
tb_depth.setFocusHover(_focus, _hover);
tb_depth.drawParam(_wpr);
_yy += _wdh + ui(8);
if(is(_l, GMRoom_Tile)) {
_wdx = _x + ui(128);
_wdy = _yy;
_wdw = _w - ui(128 + 8);
_wdh = ui(24);
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
draw_text_add(_x + ui(16), _wdy + _wdh / 2, "Tileset");
draw_sprite_stretched_ext(THEME.textbox, 3, _wdx, _wdy, _wdw, _wdh, COLORS._main_icon_light);
var _tset = _l.tilesetId;
var _tname = struct_try_get(_tset, "name", "");
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text);
draw_text_add(_wdx + ui(8 + 32), _wdy + _wdh / 2, _tname);
draw_sprite_stretched_ext(THEME.textbox, 3, _wdx, _wdy, ui(32), _wdh, c_white);
draw_sprite_ext(s_node_tileset, 0, _wdx + ui(32) / 2, _wdy + _wdh / 2, .25, .25);
_yy += _wdh + ui(8);
_h += _wdh + ui(8);
_wdy = _yy;
draw_set_text(f_p2, fa_left, fa_center, COLORS._main_text_sub);
draw_text_add(_x + ui(16), _wdy + _wdh / 2, "Tile count");
draw_sprite_stretched_ext(THEME.textbox, 3, _wdx, _wdy, _wdw / 2, _wdh, COLORS._main_icon_light);
draw_sprite_stretched_ext(THEME.textbox, 3, _wdx + _wdw / 2, _wdy, _wdw / 2, _wdh, COLORS._main_icon_light);
var _tw = _l.amount_w;
var _th = _l.amount_h;
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text);
draw_text_add(_wdx + _wdw / 4, _wdy + _wdh / 2, _tw);
draw_text_add(_wdx + _wdw / 2 + _wdw / 4, _wdy + _wdh / 2, _th);
_yy += _wdh + ui(8);
_h += _wdh + ui(8);
_wdx = _x + ui(8);
_wdy = _yy;
_wdw = _w - ui(16);
var _exposed = struct_has(inputMap, _l.name);
if(_exposed) {
_wdh = ui(24);
draw_sprite_stretched_ext(THEME.textbox, 3, _wdx, _wdy, _wdw, _wdh, COLORS._main_icon_light);
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text);
draw_text_add(_wdx + _wdw / 2, _wdy + _wdh / 2, "Tile Data Overrided");
} else {
_wdh = ui(48);
var _hov = _hover && point_in_rectangle(_m[0], _m[1], _wdx, _wdy, _wdx + _wdw, _wdy + _wdh);
var _ind = _hov;
if(mouse_click(mb_left, _focus && _hov)) _ind = 2;
if(mouse_press(mb_left, _focus && _hov)) exposeData(_l);
draw_sprite_stretched_ext(THEME.button_def, _ind, _wdx, _wdy, _wdw, _wdh);
draw_set_text(f_p2, fa_center, fa_center, COLORS._main_text);
draw_text_add(_wdx + _wdw / 2, _wdy + _wdh / 2, "Override Tile Data");
}
_yy += _wdh + ui(8);
_h += _wdh + ui(8);
}
layer_renderer_h = _h + ui(8);
return _h;
});
input_display_list = [
["Room settings", false], 0, 1,
["Layers", false],
layers_renderer,
new Inspector_Spacer(ui(4)),
layer_renderer,
["Data", true],
];
static exposeData = function(_layer) {
var _inp = createNewInput();
_inp.name = _layer.name;
if(is(_layer, GMRoom_Tile)) {
_inp.setType(VALUE_TYPE.integer);
var _tileset = nodeBuild("Node_Tile_Tileset", x - ui(320), y).skipDefault();
_tileset.bindTile(_layer.tileset);
var _tiler = nodeBuild("Node_Tile_Drawer", x - ui(160), y).skipDefault();
_tiler.bindTile(_layer);
_tiler.inputs[0].setFrom(_tileset.outputs[0]);
_inp.setFrom(_tiler.outputs[3]);
}
}
static createNewInput = function() {
var index = array_length(inputs);
var _jun = newInput(index, nodeValue("Data", self, CONNECT_TYPE.input, VALUE_TYPE.any, 0 ));
array_push(input_display_list, index);
return _jun;
}
setDynamicInput(1, false);
////- GM
static bindRoom = function(_gmRoom) {
gmRoom = _gmRoom;
layers = [];
layerMap = {};
if(_gmRoom == noone) return;
layers = gmRoom.layers;
for( var i = 0, n = array_length(layers); i < n; i++ )
layerMap[$ layers[i].name] = layers[i];
var _settings = gmRoom.roomSettings;
var _width = _settings.Width;
var _height = _settings.Height;
var _persistance = _settings.persistent;
inputs[0].setValue([_width, _height]);
inputs[1].setValue(_persistance);
}
////- Update
static step = function() {
}
static update = function() {
if(gmRoom == noone) return;
for( var i = input_fix_len, n = array_length(inputs); i < n; i++ ) {
var _in = inputs[i];
var _val = _in.getValue();
var _lay = layerMap[$ _in.name];
inputMap[$ _in.name] = _in;
if(is(_lay, GMRoom_Tile)) {
var _tw = _lay.amount_w;
var _th = _lay.amount_h;
var _tile = array_verify(_val, _tw * _th);
var _ctil = [];
var _type = _tile[0];
var _runn = 1;
for( var j = 1, m = array_length(_tile); j < m; j++ ) {
if(_tile[j] == _type) _runn++
else {
array_push(_ctil, -_runn, _type);
_type = _tile[j];
_runn = 1;
}
}
array_push(_ctil, -_runn, _type);
if(array_length(_ctil) < array_length(_tile)) {
_lay.raw.tiles.TileCompressedData = _ctil;
_lay.raw.tiles.TileDataFormat = 1;
} else {
_lay.raw.tiles.TileSerialiseData = _tile;
struct_remove(_lay.raw.tiles, "TileDataFormat");
}
}
}
gmRoom.sync();
}
////Serialize
////- Serialize
static attributeSerialize = function() {
var _attr = {
@ -86,61 +282,10 @@ function Node_GMRoom(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
}
static attributeDeserialize = function(attr) {
if(struct_has(attr, "gm_key")) {
var _key = attr.gm_key;
var _gm = project.bind_gamemaker;
if(struct_has(attr, "gm_key") && project.bind_gamemaker)
bindRoom(project.bind_gamemaker.getResourceFromPath(attr.gm_key));
if(_gm != noone) gmRoom = struct_try_get(_gm.resourcesMap, _ey, noone);
}
for( var i = input_fix_len, n = array_length(inputs); i < n; i++ )
inputMap[$ _in.name] = _in;
}
}

View file

@ -1,8 +1,9 @@
function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Tile Drawer";
name = "Tile Drawer";
bypass_grid = true;
tileset = noone;
tileset = noone;
gmTileLayer = noone;
newInput( 0, nodeValue_Tileset("Tileset", self, noone))
.setVisible(true, true);
@ -26,11 +27,13 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
newOutput(2, nodeValue_Output("Tileset", self, VALUE_TYPE.tileset, noone));
output_display_list = [ 2, 1, 0 ];
newOutput(3, nodeValue_Output("Tile Data", self, VALUE_TYPE.integer, 0));
output_display_list = [ 2, 1, 0, 3 ];
#region ++++ data ++++
canvas_surface = surface_create_empty(1, 1, surface_rgba16float);
canvas_buffer = buffer_create(1, buffer_grow, 4);
canvas_buffer = buffer_create(1, buffer_grow, 1);
drawing_surface = noone;
draw_stack = ds_list_create();
@ -257,6 +260,14 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
// draw_surface_ext(preview_draw_overlay, 432, 32, 8, 8, 0, c_white, 1);
}
////- Update
static preGetInputs = function() {
if(gmTileLayer == noone) return;
inputs[1].setValue([ gmTileLayer.amount_w, gmTileLayer.amount_h ]);
}
static processData = function(_outData, _data, _output_index, _array_index) {
tileset = _data[0];
_outData[2] = tileset;
@ -265,7 +276,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
input_display_list = [ 3, 1, 0 ];
return _outData;
}
input_display_list_tileset[3] = tileset.tile_selector.b_toggle;
input_display_list_autoterrains[3] = tileset.autoterrain_selector.b_toggle;
input_display_list_palette[3] = tileset.palette_viewer.b_toggle;
@ -280,11 +291,11 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
input_display_list_rule, tileset.rules,
]
var _tileSet = tileset.texture;
var _tileSiz = tileset.tileSize;
var _mapSize = _data[1];
var _animated = _data[2];
var _seed = _data[3];
var _tileSet = tileset.texture;
var _tileSiz = tileset.tileSize;
var _mapSize = _data[1];
var _animated = _data[2];
var _seed = _data[3];
update_on_frame = _animated;
if(!is_surface(canvas_surface) && buffer_exists(canvas_buffer)) {
@ -292,6 +303,7 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
buffer_set_surface(canvas_buffer, canvas_surface, 0);
} else
canvas_surface = surface_verify(canvas_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
drawing_surface = surface_verify(drawing_surface, _mapSize[0], _mapSize[1], surface_rgba16float);
temp_surface[0] = surface_verify(temp_surface[0], _mapSize[0], _mapSize[1], surface_rgba16float);
temp_surface[1] = surface_verify(temp_surface[1], _mapSize[0], _mapSize[1], surface_rgba16float);
@ -333,14 +345,62 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
draw_empty();
surface_reset_shader();
return [ _tileOut, _tileMap, tileset ];
var tileData = _outData[3];
var amo = _mapSize[0] * _mapSize[1];
if(gmTileLayer != noone) {
tileData = array_verify(tileData, amo);
var i = 0;
var b;
buffer_to_start(canvas_buffer);
repeat(amo) {
b = buffer_read(canvas_buffer, buffer_f16);
buffer_read(canvas_buffer, buffer_f16);
buffer_read(canvas_buffer, buffer_f16);
buffer_read(canvas_buffer, buffer_f16);
b = round(b);
switch(b) {
case 0 : tileData[i] = 0; break;
default : tileData[i] = b - 1; break;
}
i++;
}
}
return [ _tileOut, _tileMap, tileset, tileData ];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////- GM
static bindTile = function(_gmTile) {
gmTileLayer = _gmTile;
if(gmTileLayer == noone) {
inputs[0].editable = true;
inputs[1].editable = true;
inputs[2].editable = true;
return;
}
inputs[0].editable = false;
inputs[1].editable = false;
inputs[2].editable = false;
inputs[1].setValue([ gmTileLayer.amount_w, gmTileLayer.amount_h ]);
}
////- Serialzie
static attributeSerialize = function() {
var _attr = {
canvas : surface_encode(canvas_surface),
gm_key: gmTileLayer == noone? noone : gmTileLayer.room.key,
gm_name: gmTileLayer == noone? noone : gmTileLayer.name,
}
return _attr;
@ -357,5 +417,13 @@ function Node_Tile_Drawer(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
buffer_delete_safe(canvas_buffer);
canvas_buffer = buffer_from_surface(canvas_surface, false, buffer_grow);
}
if(struct_has(attr, "gm_key") && project.bind_gamemaker) {
var _room = project.bind_gamemaker.getResourceFromPath(attr.gm_key);
var _name = attr[$ "gm_name"];
if(_room != noone && !is_undefined(_name))
bindTile(_room.getLayerFromName(_name));
}
}
}

View file

@ -1,5 +1,5 @@
function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Tileset";
name = "Tileset";
bypass_grid = true;
preserve_height_for_preview = true;
@ -1529,6 +1529,8 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
shader_set_f("animatedTilesLength", aTilesLength);
}
////- Update
static update = function(frame = CURRENT_FRAME) {
texture = inputs[0].getValue();
tileSize = inputs[1].getValue();
@ -1539,7 +1541,7 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
if(gmTile != noone) {
inputs[0].setVisible(false, false);
var _spm = struct_try_get(gmTile.gmBinder.resourcesMap, gmTile.sprite, noone);
var _spm = gmTile.spriteObject;
var _spr = _spm == noone? noone : _spm.thumbnail;
if(_spr) {
@ -1561,9 +1563,23 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
outputs[0].setValue(self);
}
////- Draw
static getPreviewValues = function() { return texture; }
static getGraphPreviewSurface = function() { return texture; }
////- GM
static bindTile = function(_gmTile) {
gmTile = _gmTile;
if(gmTile == noone) {
return;
}
}
////- Serialize
static attributeSerialize = function() {
var _attr = {
autoterrain,
@ -1604,12 +1620,8 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr
brush_palette_buffer = buffer_from_surface(brush_palette, false, buffer_grow);
}
if(struct_has(attr, "gm_key")) {
var _key = attr.gm_key;
var _gm = project.bind_gamemaker;
if(_gm != noone) gmTile = struct_try_get(_gm.resourcesMap, _ey, noone);
}
if(struct_has(attr, "gm_key") && project.bind_gamemaker)
bindTile(project.bind_gamemaker.getResourceFromPath(attr.gm_key));
refreshAnimatedData();
}

View file

@ -46,6 +46,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
tooltip = _tooltip;
editWidget = noone;
editWidgetRaw = noone;
editable = true;
graphWidget = noone;
graphWidgetH = 0;
graphWidgetP = new widgetParam(0, 0, 0, 0, 0);

View file

@ -100,11 +100,10 @@ function Panel_GM_Explore(gmBinder) : PanelContent() constructor {
if(_hover && point_in_rectangle(_m[0], _m[1], _asx, _asy, _asx + _ths, _asy + _ths)) {
draw_sprite_stretched_ext(THEME.ui_panel, 1, _asx, _asy, _ths, _ths, COLORS._main_icon);
if(_thm) TOOLTIP = [ _thm, "sprite" ];
if(_thm && _ass.type != "GMRoom") TOOLTIP = [ _thm, "sprite" ];
if(mouse_press(mb_left, _focus)) {
if(mouse_press(mb_left, _focus))
DRAGGING = { type : _ass.type, data : _ass };
}
}
}

View file

@ -3324,12 +3324,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
case "GMTileSet" :
node = nodeBuild("Node_Tile_Tileset", mouse_grid_x, mouse_grid_y).skipDefault();
node.gmTile = DRAGGING.data;
node.bindTile(DRAGGING.data);
break;
case "GMRoom" :
node = nodeBuild("Node_GMRoom", mouse_grid_x, mouse_grid_y).skipDefault();
node.gmRoom = DRAGGING.data;
node.bindRoom(DRAGGING.data);
break;
}

View file

@ -65,21 +65,21 @@ function string_to_var2(context, name) { INLINE return string_to_var(context ==
function string_quote(str) { INLINE return $"\"{str}\""; }
function string_compare(s1, s2) {
s1 = string_lower(s1);
s2 = string_lower(s2);
var l1 = string_length(s1);
var l2 = string_length(s2);
var l = min(l1, l2);
var i = 1;
var c1, c2;
repeat(min(l1, l2)) {
c1 = string_lower(string_char_at(s1, i));
c2 = string_lower(string_char_at(s2, i));
if(c1 == c2) {
i++;
continue;
}
repeat(l) {
c1 = string_char_at(s1, i);
c2 = string_char_at(s2, i);
i++;
if(c1 == c2) continue;
return ord(c1) - ord(c2);
}

View file

@ -41,8 +41,8 @@ function tiler_flood_fill_scanline(_surf, _x, _y, brush, _corner = false) {
var _index = brush.brush_erase? -1 : brush.brush_indices[0][0];
var colorBase = surface_getpixel(_surf, _x, _y)[0];
// print($"Filling {_x}, {_y} = {_index} [base: {colorBase}]")
if(_index == colorBase) return; //Clicking on the same color as the fill color
if(is_array(_index)) return;
_ff_w = surface_get_width(_surf);
_ff_h = surface_get_height(_surf);