undo system

This commit is contained in:
Tanasart 2022-11-22 20:25:39 +07:00
parent 1e391d3c70
commit 3885784489
34 changed files with 284 additions and 175 deletions

View file

@ -171,6 +171,7 @@
{"id":{"name":"node_chromatic_aberration","path":"scripts/node_chromatic_aberration/node_chromatic_aberration.yy",},"order":45,},
{"id":{"name":"node_pin","path":"scripts/node_pin/node_pin.yy",},"order":2,},
{"id":{"name":"sh_bw","path":"shaders/sh_bw/sh_bw.yy",},"order":1,},
{"id":{"name":"real_comparison","path":"scripts/real_comparison/real_comparison.yy",},"order":1,},
{"id":{"name":"s_node_stripe","path":"sprites/s_node_stripe/s_node_stripe.yy",},"order":36,},
{"id":{"name":"sh_grey_alpha","path":"shaders/sh_grey_alpha/sh_grey_alpha.yy",},"order":11,},
{"id":{"name":"sh_normal","path":"shaders/sh_normal/sh_normal.yy",},"order":1,},
@ -521,7 +522,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"animation_curve","folderPath":"folders/animation_curve.yy","order":14,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"collection","folderPath":"folders/collection.yy","order":12,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"dialog","folderPath":"folders/dialog.yy","order":5,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"selector","folderPath":"folders/dialog/selector.yy","order":23,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"color selector","folderPath":"folders/dialog/color selector.yy","order":23,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Extensions","folderPath":"folders/Extensions.yy","order":11,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"font","folderPath":"folders/font.yy","order":8,},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"functions","folderPath":"folders/functions.yy","order":7,},
@ -833,6 +834,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_padding_link_strip2.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/icon",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"graphic.ai","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_ui_scroll_bar.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/UI",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ThemeDef.zip","CopyToMask":-1,"filePath":"datafiles/data/themes",},
],
"MetaData": {
"IDEVersion": "2022.9.0.49",

Binary file not shown.

View file

@ -26,7 +26,7 @@
"_main_text_title": "blue_ltgrey",
"_main_text_sub": "blue_grey",
"_main_icon": "blue_grey",
"_main_icon_dark": "blue_black",
"_main_icon_dark": "blue_mdblack",
"_main_value_positive": "lime",
"_main_value_negative": "red",

View file

@ -33,7 +33,7 @@
"properties": [],
"overriddenProperties": [],
"parent": {
"name": "selector",
"path": "folders/dialog/selector.yy",
"name": "color selector",
"path": "folders/dialog/color selector.yy",
},
}

View file

@ -43,8 +43,7 @@ draw_set_alpha(1);
bx0 -= bw + ui(12);
var b = buttonInstant(THEME.button, bx0, by0, bw, bh, mouse_ui, sFOCUS, sHOVER);
draw_text(bx0 + bw / 2, by0 + bh / 2, "Save");
if(b == 2) {
SAVE();
if(b == 2 && SAVE()) {
PREF_SAVE();
game_end();
}

View file

@ -33,7 +33,7 @@
"properties": [],
"overriddenProperties": [],
"parent": {
"name": "selector",
"path": "folders/dialog/selector.yy",
"name": "color selector",
"path": "folders/dialog/color selector.yy",
},
}

View file

@ -12,11 +12,14 @@
continue;
}
var _h = hght;
var label = menu[i][0];
var activated = string_char_at(label, 1) != "-";
if(!activated) label = string_copy(label, 2, string_length(label) - 1);
if(is_array(menu[i][1]))
_h += hght;
if(sHOVER && point_in_rectangle(mouse_mx, mouse_my, dialog_x, yy + 1, dialog_x + dialog_w, yy + _h - 1)) {
if(activated && sHOVER && point_in_rectangle(mouse_mx, mouse_my, dialog_x, yy + 1, dialog_x + dialog_w, yy + _h - 1)) {
draw_sprite_stretched_ext(THEME.textbox, 3, dialog_x, yy, dialog_w, _h, COLORS.dialog_menubox_highlight, 1);
if(!is_array(menu[i][1]) && sFOCUS && mouse_check_button_released(mb_left)) {
@ -30,7 +33,9 @@
if(is_array(menu[i][1])) {
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text_sub);
draw_text(dialog_x + dialog_w / 2, yy + hght / 2, menu[i][0]);
draw_set_alpha(activated * 0.5 + 0.5);
draw_text(dialog_x + dialog_w / 2, yy + hght / 2, label);
draw_set_alpha(1);
var amo = array_length(menu[i][1]);
var _w = (amo - 1) / 2 * (hght + ui(4));
@ -63,7 +68,9 @@
}
} else {
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_text(dialog_x + ui(16), yy + hght / 2, menu[i][0]);
draw_set_alpha(activated * 0.5 + 0.5);
draw_text(dialog_x + ui(16), yy + hght / 2, label);
draw_set_alpha(1);
}
if(array_length(menu[i]) > 2) {

View file

@ -33,7 +33,7 @@
"properties": [],
"overriddenProperties": [],
"parent": {
"name": "selector",
"path": "folders/dialog/selector.yy",
"name": "color selector",
"path": "folders/dialog/color selector.yy",
},
}

View file

@ -2,16 +2,23 @@
#region directory
globalvar DIRECTORY;
DIRECTORY = environment_get_variable("userprofile") + "\\AppData\\Local\\Pixels_Composer\\";
if(!directory_exists(DIRECTORY)) {
log_message("DIRECTORY", "Default user directory not exist");
DIRECTORY = "";
}
if(!directory_exists(DIRECTORY))
directory_create(DIRECTORY);
log_clear();
log_newline();
log_message("SESSION", "Begin");
log_message("DIRECTORY", DIRECTORY);
__init_theme();
__init_collection();
__initAssets();
PREF_LOAD();
loadFonts();
loadGraphic(PREF_MAP[? "theme"]);
loadColor(PREF_MAP[? "theme"]);
setPanel();
#endregion
#region parameter
@ -29,6 +36,4 @@
directory_set_current_working(DIRECTORY);
}
}
#endregion
PREF_LOAD();
#endregion

View file

@ -10,20 +10,20 @@
#region animation
if(ANIMATOR.is_playing) {
ANIMATOR.real_frame += ANIMATOR.framerate / game_get_speed(gamespeed_fps);
if(floor(ANIMATOR.real_frame) > ANIMATOR.frames_total) {
ANIMATOR.real_frame += ANIMATOR.framerate * (delta_time / 1000000);
if(round(ANIMATOR.real_frame) >= ANIMATOR.frames_total) {
switch(ANIMATOR.playback) {
case ANIMATOR_END.loop :
ANIMATOR.real_frame = 0;
break;
case ANIMATOR_END.stop :
ANIMATOR.real_frame = ANIMATOR.frames_total;
ANIMATOR.real_frame = ANIMATOR.frames_total - 1;
ANIMATOR.is_playing = false;
break;
}
}
} else {
ANIMATOR.real_frame = min(ANIMATOR.real_frame, ANIMATOR.frames_total);
ANIMATOR.real_frame = clamp(ANIMATOR.real_frame, 0, ANIMATOR.frames_total - 1);
}
ANIMATOR.frame_progress = false;

View file

@ -5,7 +5,7 @@
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "selector",
"path": "folders/dialog/selector.yy",
"name": "color selector",
"path": "folders/dialog/color selector.yy",
},
}

View file

@ -129,31 +129,31 @@ function Action(_type, _object, _data) constructor {
var ss = "";
switch(type) {
case ACTION_TYPE.var_modify :
ss = "var mod: " + string(data[1]);
ss = "modify " + string(data[1]);
break;
case ACTION_TYPE.list_insert :
ss = "list insert: " + string(data[1]) + " in " + string(obj);
ss = "insert " + string(data[1]) + " to list " + string(obj);
break;
case ACTION_TYPE.list_modify :
ss = "list mod: " + string(data[1]) + " in " + string(obj);
ss = "modify " + string(data[1]) + " of list " + string(obj);
break;
case ACTION_TYPE.list_delete :
ss = "list del: " + string(data[1]) + " in " + string(obj);
ss = "delete " + string(data[1]) + " from list " + string(obj);
break;
case ACTION_TYPE.node_added :
ss = "node add: " + string(obj.name);
ss = "add " + string(obj.name) + " node";
break;
case ACTION_TYPE.node_delete :
ss = "node deleted: " + string(obj.name);
ss = "deleted " + string(obj.name) + " node";
break;
case ACTION_TYPE.junction_connect :
ss = "junction connect: " + string(obj.name);
ss = "connect " + string(obj.name) + " junction";
break;
case ACTION_TYPE.group_added :
ss = "group add: " + string(obj.name);
ss = "add " + string(obj.name) + " to group";
break;
case ACTION_TYPE.group_removed :
ss = "group remove: " + string(obj.name);
ss = "remove " + string(obj.name) + " from group";
break;
}
return ss;
@ -165,16 +165,20 @@ function recordAction(_type, _object, _data = -1) {
if(UNDO_HOLDING) return;
if(LOADING) return;
o_main.action_last_frame[array_length(o_main.action_last_frame)] = new Action(_type, _object, _data);
var act = new Action(_type, _object, _data);
array_push(o_main.action_last_frame, act);
return act;
}
function UNDO() {
if(ds_stack_empty(UNDO_STACK)) return;
if(instance_exists(_p_dialog)) return;
IS_UNDOING = true;
var actions = ds_stack_pop(UNDO_STACK);
for(var i = 0; i < array_length(actions); i++) {
//show_debug_message("UNDO " + actions[i].toString());
//print("UNDO " + actions[i].toString());
actions[i].undo();
}
IS_UNDOING = false;
@ -189,7 +193,7 @@ function REDO() {
IS_UNDOING = true;
var actions = ds_stack_pop(REDO_STACK);
for(var i = 0; i < array_length(actions); i++) {
//show_debug_message("REDO " + actions[i].toString());
//print("REDO " + actions[i].toString());
actions[i].redo();
}
IS_UNDOING = false;

View file

@ -3,7 +3,7 @@ globalvar FONT_LOADED, f_h3, f_h5, f_p0, f_p0b, f_p1, f_p2, f_p3;
FONT_LOADED = false;
function _font_path(rel) {
return "data/themes/" + PREF_MAP[? "theme"] + "/fonts/" + string_replace_all(rel, "./", "");
return DIRECTORY + "themes/" + PREF_MAP[? "theme"] + "/fonts/" + string_replace_all(rel, "./", "");
}
function _font_load_from_struct(str, def) {
@ -13,8 +13,7 @@ function _font_load_from_struct(str, def) {
return def;
}
var f = font_add(path, str.size * UI_SCALE, false, false, str.range[0], str.range[1]);
return f;
return font_add(path, str.size * UI_SCALE, false, false, str.range[0], str.range[1]);
}
function font_clear(font) { if(font_exists(font)) font_delete(font); }

View file

@ -1,12 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "load_palette",
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "selector",
"path": "folders/dialog/selector.yy",
"name": "color selector",
"path": "folders/dialog/color selector.yy",
},
"resourceVersion": "1.0",
"name": "load_palette",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -528,27 +528,25 @@ function Node(_x, _y) constructor {
static recoverCache = function() {
if(ANIMATOR.current_frame >= array_length(cached_output)) return false;
var _s = cached_output[ANIMATOR.current_frame];
if(is_surface(_s)) {
var _outSurf = outputs[| 0].getValue();
if(is_surface(_outSurf))
surface_copy_size(_outSurf, _s);
else {
_outSurf = surface_clone(_s);
outputs[| 0].setValue(_outSurf);
}
return true;
if(!is_surface(_s)) return false;
var _outSurf = outputs[| 0].getValue();
if(is_surface(_outSurf))
surface_copy_size(_outSurf, _s);
else {
_outSurf = surface_clone(_s);
outputs[| 0].setValue(_outSurf);
}
return false;
return true;
}
static clearCache = function() {
if(array_length(cached_output) != ANIMATOR.frames_total + 1)
array_resize(cached_output, ANIMATOR.frames_total + 1);
for(var i = 0; i < array_length(cached_output); i++) {
var _s = cached_output[i];
if(is_surface(_s)) {
if(is_surface(_s))
surface_free(_s);
}
cached_output[i] = 0;
}
}

View file

@ -185,12 +185,13 @@ function valueAnimator(_val, _prop) constructor {
MODIFIED = true;
if(!is_anim) {
if(_record) recordAction(ACTION_TYPE.var_modify, values[| 0], [ values[| 0].value, "value" ]);
if(values[| 0].value != _val) {
values[| 0].value = _val;
return true;
}
return false;
if(isEqual(values[| 0].value, _val))
return false;
if(_record)
recordAction(ACTION_TYPE.var_modify, values[| 0], [ values[| 0].value, "value" ]);
values[| 0].value = _val;
return true;
}
if(ds_list_size(values) == 0) {
@ -204,7 +205,8 @@ function valueAnimator(_val, _prop) constructor {
for(var i = 0; i < ds_list_size(values); i++) {
var _key = values[| i];
if(_key.time == _time) {
if(_record) recordAction(ACTION_TYPE.var_modify, _key, [ _key.value, "value" ]);
if(_record)
recordAction(ACTION_TYPE.var_modify, _key, [ _key.value, "value" ]);
if(_key.value != _val) {
_key.value = _val;
return true;

View file

@ -254,7 +254,7 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
inputs[| 21] = nodeValue(21, "Gravity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 );
inputs[| 22] = nodeValue(22, "Wiggle", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0 );
inputs[| 23] = nodeValue(23, "Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true );
inputs[| 23] = nodeValue(23, "Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
inputs[| 24] = nodeValue(24, "Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 )
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Normal", "Additive" ]);
@ -285,12 +285,13 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
["Rotation", true], 16, 9, 10,
["Scale", true], 11, 18, 12,
["Color", true], 13, 14, 15,
["Render", true], 24, 19, 23,
["Render", true], 24, 19, 23
];
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
seed = irandom(9999999);
seed_origin = irandom(9999999);
seed = seed_origin;
def_surface = -1;
parts = ds_list_create();
@ -300,7 +301,8 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
outputs[| 1] = nodeValue(1, "Particle data", self, JUNCTION_CONNECT.output, VALUE_TYPE.object, parts );
function spawn() {
randomize();
random_set_seed(seed++);
var _inSurf = inputs[| 0].getValue();
if(_inSurf == 0) {
@ -429,35 +431,36 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
parts[| i].kill();
}
render();
seed = seed_origin;
}
function updateParticle() {
var jun = outputs[| 1];
for(var j = 0; j < ds_list_size(jun.value_to); j++) {
if(jun.value_to[| j].value_from == jun) {
if(jun.value_to[| j].value_from == jun)
jun.value_to[| j].node.doUpdate();
}
}
render();
}
function resetPartPool() {
function checkPartPool() {
var _part_amo = PREF_MAP[? "part_max_amount"];
if(_part_amo > ds_list_size(parts)) {
repeat(_part_amo - ds_list_size(parts)) {
var _curr_amo = ds_list_size(parts);
if(_part_amo > _curr_amo) {
repeat(_part_amo - _curr_amo)
ds_list_add(parts, new __part());
}
} else if(_part_amo < ds_list_size(parts)) {
repeat(ds_list_size(parts) - _part_amo) {
} else if(_part_amo < _curr_amo) {
repeat(_curr_amo - _part_amo)
ds_list_delete(parts, 0);
}
}
}
static step = function() {
var _inSurf = inputs[| 0].getValue();
var _scatt = inputs[| 27].getValue();
var _loop = inputs[| 23].getValue();
inputs[| 25].setVisible(false);
inputs[| 26].setVisible(false);
@ -472,7 +475,7 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
}
}
resetPartPool();
checkPartPool();
var _spawn_type = inputs[| 17].getValue();
if(_spawn_type == 0)
inputs[| 2].name = "Spawn delay";
@ -484,24 +487,25 @@ function Node_Particle(_x, _y) : Node(_x, _y) constructor {
if(ANIMATOR.is_playing && ANIMATOR.frame_progress) {
if(ANIMATOR.current_frame == 0) reset();
if(_spawn_type == 0) {
if(safe_mod(ANIMATOR.current_frame, _spawn_delay) == 0)
spawn();
} else if(_spawn_type == 1) {
if(ANIMATOR.current_frame == _spawn_delay)
spawn();
switch(_spawn_type) {
case 0 :
if(safe_mod(ANIMATOR.current_frame, _spawn_delay) == 0)
spawn();
break;
case 1 :
if(ANIMATOR.current_frame == _spawn_delay)
spawn();
break;
}
for(var i = 0; i < PREF_MAP[? "part_max_amount"]; i++)
for(var i = 0; i < ds_list_size(parts); i++)
parts[| i].step();
updateParticle();
updateForward();
}
if(ANIMATOR.is_scrubing) {
if(ANIMATOR.is_scrubing)
recoverCache();
}
}
static drawOverlay = function(_active, _x, _y, _s, _mx, _my) {

View file

@ -15,10 +15,8 @@ function Node_Processor(_x, _y) : Node(_x, _y) constructor {
var len = 0;
for(var i = 0; i < ds_list_size(inputs); i++) {
var _in = inputs[| i].getValue();
if(is_array(_in)) {
if(inputs[| i].isArray())
len = max(len, array_length(_in));
}
if(inputs[| i].isArray() && is_array(_in))
len = max(len, array_length(_in));
}
for(var _oi = 0; _oi < ds_list_size(outputs); _oi++) {
@ -38,15 +36,15 @@ function Node_Processor(_x, _y) : Node(_x, _y) constructor {
var base_s = getData(0, i);
if(is_surface(base_s)) {
var ww = surface_get_width(base_s);
var hh = surface_get_height(base_s);
ww = surface_get_width(base_s);
hh = surface_get_height(base_s);
}
}
if(!is_surface(outSurfs[i]))
outSurfs[i] = surface_create_valid(ww, hh);
else
if(is_surface(outSurfs[i]))
surface_size_to(outSurfs[i], ww, hh)
else
outSurfs[i] = surface_create_valid(ww, hh);
var _data = getDataArray(i);
process_data(outSurfs[i], _data, _oi);
@ -75,11 +73,12 @@ function Node_Processor(_x, _y) : Node(_x, _y) constructor {
outputs[| _oi].setValue(outSurfs);
}
if(!is_surface(outSurfs)) {
if(is_surface(outSurfs)) {
surface_size_to(outSurfs, ww, hh);
} else {
outSurfs = surface_create_valid(ww, hh);
outputs[| _oi].setValue(outSurfs);
} else
surface_size_to(outSurfs, ww, hh);
}
var _data = getDataArray(0);
process_data(outSurfs, _data, _oi);

View file

@ -143,7 +143,8 @@ function Node_Render_Sprite_Sheet(_x, _y) : Node(_x, _y) constructor {
var skip = inputs[| 2].getValue();
if(is_array(inpt) && array_length(inpt) == 0) return;
if(!is_array(inpt)) inpt = [ inpt ];
var arr = is_array(inpt);
if(!arr) inpt = [ inpt ];
var _surf = [];
for(var i = 0; i < array_length(inpt); i++) {
@ -173,6 +174,8 @@ function Node_Render_Sprite_Sheet(_x, _y) : Node(_x, _y) constructor {
draw_clear_alpha(0, 0);
surface_reset_target();
}
if(!arr) _surf = _surf[0];
outputs[| 0].setValue(_surf);
} else {
if(is_array(inpt)) {

View file

@ -41,7 +41,7 @@ function Node_Time_Remap(_x, _y) : Node(_x, _y) constructor {
texture_set_stage(uniform_map, surface_get_texture(_map));
for(var i = 0; i <= _life; i++) {
var frame = clamp(ANIMATOR.current_frame - i, 0, ANIMATOR.frames_total);
var frame = clamp(ANIMATOR.current_frame - i, 0, ANIMATOR.frames_total - 1);
if(is_surface(cached_output[frame])) {
shader_set_uniform_f(uniform_min, i * ste);

View file

@ -11,7 +11,8 @@ function Node_Trail(_x, _y) : Node_Processor(_x, _y) constructor {
inputs[| 0] = nodeValue(0, "Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue(1, "Max life", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 3);
inputs[| 2] = nodeValue(2, "Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1);
inputs[| 3] = nodeValue(3, "Alpha decrease", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 3] = nodeValue(3, "Alpha decrease", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider, [0, 1, 0.01]);
inputs[| 4] = nodeValue(4, "Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, BLEND_TYPES );
@ -46,19 +47,20 @@ function Node_Trail(_x, _y) : Node_Processor(_x, _y) constructor {
var aa = 1;
var res_index = 0;
var st_frame = floor(ANIMATOR.current_frame / _step);
var frame_amo = min(_life, floor(ANIMATOR.current_frame / _step));
var st_frame = ANIMATOR.current_frame - frame_amo * _step;
for(var i = _life; i >= 0; i--) {
var frame = clamp(st_frame - i * _step, 0, ANIMATOR.frames_total);
for(var i = 0; i <= _life; i++) {
var frame_idx = clamp(st_frame + i * _step, 0, ANIMATOR.frames_total - 1);
var bg = i % 2;
var fg = (i + 1) % 2;
aa = max(aa - _alpha, 0);
var fg = !bg;
var aa = 1 - _alpha * (_life - i);
surface_set_target(temp_surf[bg]);
if(i == _life)
draw_surface_safe(_data[0], 0, 0);
else if(is_surface(cached_output[frame]))
draw_surface_blend(temp_surf[fg], cached_output[frame], _blend, aa);
else if(is_surface(cached_output[frame_idx]))
draw_surface_blend(temp_surf[fg], cached_output[frame_idx], _blend, aa);
surface_reset_target();
res_index = bg;

View file

@ -338,9 +338,9 @@ function Panel_Animation() : PanelContent() constructor {
if(i >= array_length(inspecting.cached_output))
break;
var x0 = (i + 1) * ui(timeline_scale) + timeline_shift;
var x1 = (i + 2) * ui(timeline_scale) + timeline_shift;
var x0 = (i + 0) * ui(timeline_scale) + timeline_shift;
var x1 = (i + 1) * ui(timeline_scale) + timeline_shift;
var sh = inspecting.cached_output[i];
draw_set_color(is_surface(sh)? c_lime : c_red);
draw_set_alpha(0.5);

View file

@ -3,7 +3,7 @@ function Panel_Menu() : PanelContent() constructor {
noti_flash = 0;
static menus = [
menus = [
["File", [
[ "New", function() {
NEW();
@ -77,6 +77,51 @@ function Panel_Menu() : PanelContent() constructor {
]],
]
function displayNewVersion() {
var xx = w - ui(88);
draw_set_text(f_p0b, fa_right, fa_center, COLORS._main_value_positive);
var txt = " Newer version available ";
var ww = string_width(txt);
if(pHOVER && point_in_rectangle(mx, my, xx - ww, 0, xx, h)) {
draw_sprite_stretched(THEME.menu_button, 0, xx - ww - ui(6), ui(6), ww + ui(12), h - ui(12));
if(pFOCUS && mouse_check_button_pressed(mb_left)) {
url_open("https://makham.itch.io/pixel-composer");
}
}
draw_text(xx, h / 2, txt);
}
function undoUpdate() {
var txt;
if(ds_stack_empty(UNDO_STACK)) {
txt = "-Undo";
} else {
var act = ds_stack_top(UNDO_STACK);
if(array_length(act) > 1)
txt = "Undo " + string(array_length(act)) + " actions";
else
txt = "Undo " + act[0].toString();
}
menus[1][1][0][0] = txt;
if(ds_stack_empty(REDO_STACK)) {
txt = "-Redo";
} else {
var act = ds_stack_top(REDO_STACK);
if(array_length(act) > 1)
txt = "Redo " + string(array_length(act)) + " actions";
else
txt = "Redo " + act[0].toString();
}
menus[1][1][1][0] = txt;
}
function drawContent(panel) {
draw_clear_alpha(COLORS.panel_bg_clear, 0);
draw_sprite_ui_uniform(THEME.icon_24, 0, h / 2, h / 2, 1, c_white);
@ -164,21 +209,9 @@ function Panel_Menu() : PanelContent() constructor {
}
draw_text(w - ui(16), h / 2, txt);
if(o_main.version_latest > VERSION) {
var xx = w - ui(88);
draw_set_text(f_p0b, fa_right, fa_center, COLORS._main_value_positive);
var txt = " Newer version available ";
var ww = string_width(txt);
if(o_main.version_latest > VERSION)
displayNewVersion();
if(pHOVER && point_in_rectangle(mx, my, xx - ww, 0, xx, h)) {
draw_sprite_stretched(THEME.menu_button, 0, xx - ww - ui(6), ui(6), ww + ui(12), h - ui(12));
if(pFOCUS && mouse_check_button_pressed(mb_left)) {
url_open("https://makham.itch.io/pixel-composer");
}
}
draw_text(xx, h / 2, txt);
}
undoUpdate();
}
}

View file

@ -411,7 +411,8 @@ function Panel_Preview() : PanelContent() constructor {
if(mouse_check_button_pressed(mb_left)) {
_node.preview_index = i;
_node.onValueUpdate(0);
do_fullView = true;
if(resetViewOnDoubleClick)
do_fullView = true;
}
draw_surface_ext_safe(prev, xx, yy, ss, ss, 0, c_white, 1);
} else {

View file

@ -1,8 +1,6 @@
#region data
globalvar PREF_MAP;
PREF_MAP = ds_map_create();
loadGraphic();
loadColor();
#endregion
#region pref map
@ -251,11 +249,6 @@
window_set_size(ww, hh);
window_set_position(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2);
game_set_speed(PREF_MAP[? "ui_framerate"], gamespeed_fps);
setPanel();
loadFonts();
loadGraphic(PREF_MAP[? "theme"]);
loadColor(PREF_MAP[? "theme"]);
}
function find_hotkey(_context, _name) {

View file

@ -0,0 +1,11 @@
function isEqual(val1, val2) {
if(!is_array(val1) && !is_array(val2)) return val1 == val2;
if(is_array(val1) ^ is_array(val2)) return false;
if(array_length(val1) != array_length(val2)) return false;
for( var i = 0; i < array_length(val1); i++ ) {
if(val1[i] != val2[i]) return false;
}
return true;
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "real_comparison",
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "eval",
"path": "folders/functions/eval.yy",
},
}

View file

@ -59,14 +59,13 @@ function SET_PATH(path) {
function SAVE() {
if(CURRENT_PATH == "" || READONLY)
SAVE_AS();
else
SAVE_AT(CURRENT_PATH);
return SAVE_AS();
return SAVE_AT(CURRENT_PATH);
}
function SAVE_AS() {
var path = get_save_filename(".pxc", "");
if(path == "") return;
if(path == "") return false;
if(filename_ext(path) != ".pxc")
path += ".pxc";
@ -75,6 +74,8 @@ function SAVE_AS() {
log_warning("SAVE", "Overrided file : " + path);
SAVE_AT(path);
SET_PATH(path);
return true;
}
function SAVE_AT(path) {
@ -88,6 +89,8 @@ function SAVE_AT(path) {
MODIFIED = false;
log_message("FILE", "save at " + path, THEME.noti_icon_file_save);
return true;
}
function SAVE_COLLECTIONS(_list, _path, save_surface = true) {

View file

@ -51,11 +51,13 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) constr
val = clamp(val, minn, maxx);
if(onModify != noone)
onModify(val);
UNDO_HOLDING = true;
if(mouse_check_button_released(mb_left)) {
dragging = false;
if(onRelease != noone)
onRelease(val);
UNDO_HOLDING = false;
}
} else {
if(hover && (point_in_rectangle(_m[0], _m[1], _x, _y, _x + sw, _y + _h) || point_in_rectangle(_m[0], _m[1], _kx - ui(10), _y, _kx + ui(10), _y + _h))) {

View file

@ -47,9 +47,12 @@ function sliderRange(_min, _max, _step, _onModify) constructor {
val = round(val / step) * step;
val = clamp(val, minn, maxx);
onModify(dragging, val);
UNDO_HOLDING = true;
if(mouse_check_button_released(mb_left))
if(mouse_check_button_released(mb_left)) {
UNDO_HOLDING = false;
dragging = -1;
}
} else {
if(hover) {
var _hover = -1;

View file

@ -1,5 +1,21 @@
function __init_theme() {
var root = DIRECTORY + "Themes";
if(!directory_exists(root))
directory_create(root);
var _l = root + "\\theme" + string(VERSION);
if(file_exists(_l)) return;
log_message("THEME", "unzipping default theme to DIRECTORY.");
var f = file_text_open_write(_l);
file_text_write_real(f, 0);
file_text_close(f);
zip_unzip("data/themes/ThemeDef.zip", root);
}
function _sprite_path(rel, theme) {
return "data/themes/" + theme + "/graphics/" + string_replace_all(rel, "./", "");
return DIRECTORY + "themes/" + theme + "/graphics/" + string_replace_all(rel, "./", "");
}
function _sprite_load_from_struct(str, theme, key) {

View file

@ -1,34 +1,39 @@
function draw_surface_safe(surface, _x, _y) {
if(is_surface(surface)) draw_surface(surface, _x, _y);
if(!is_surface(surface)) return;
draw_surface(surface, _x, _y);
}
function draw_surface_ext_safe(surface, _x, _y, _xs, _ys, _rot, _col, _alpha) {
if(is_surface(surface)) draw_surface_ext(surface, _x, _y, _xs, _ys, _rot, _col, _alpha);
function draw_surface_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
if(!is_surface(surface)) return;
draw_surface_ext(surface, _x, _y, _xs, _ys, _rot, _col, _alpha);
}
function draw_surface_tiled_ext_safe(surface, _x, _y, _xs, _ys, _col, _alpha) {
if(is_surface(surface)) draw_surface_tiled_ext(surface, _x, _y, _xs, _ys, _col, _alpha);
function draw_surface_tiled_ext_safe(surface, _x, _y, _xs = 1, _ys = 1, _col = c_white, _alpha = 1) {
if(!is_surface(surface)) return;
draw_surface_tiled_ext(surface, _x, _y, _xs, _ys, _col, _alpha);
}
function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _rot, _col, _alpha) {
if(is_surface(surface)) draw_surface_part_ext(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _col, _alpha);
function draw_surface_part_ext_safe(surface, _l, _t, _w, _h, _x, _y, _xs = 1, _ys = 1, _rot = 0, _col = c_white, _alpha = 1) {
if(!is_surface(surface)) return;
draw_surface_part_ext(surface, _l, _t, _w, _h, _x, _y, _xs, _ys, _col, _alpha);
}
function surface_size_to(surface, width, height) {
width = surface_valid(width);
height = surface_valid(height);
if(!surface_exists(surface)) return false;
if(width == 1 && height == 1) return false;
width = surface_valid_size(width);
height = surface_valid_size(height);
var ww = surface_get_width(surface);
var hh = surface_get_height(surface);
if(ww != width || hh != height) {
surface_resize(surface, width, height);
return true;
}
if(ww == width && hh == height) return false;
return false;
surface_resize(surface, width, height);
return true;
}
function surface_clone(surface) {
if(!surface_exists(surface)) return surface_create(1, 1);
var s = surface_create_valid(surface_get_width(surface), surface_get_height(surface));
surface_set_target(s);
draw_clear_alpha(0, 0);
@ -39,6 +44,9 @@ function surface_clone(surface) {
}
function surface_copy_size(dest, source) {
if(!is_surface(dest)) return;
if(!is_surface(source)) return;
surface_size_to(dest, surface_get_width(source), surface_get_height(source));
surface_set_target(dest);
draw_clear_alpha(0, 0);
@ -46,13 +54,13 @@ function surface_copy_size(dest, source) {
surface_copy(dest, 0, 0, source);
}
function surface_valid(s) {
function surface_valid_size(s) {
if(is_infinity(s)) return 1;
return max(1, s);
}
function surface_create_valid(w, h) {
return surface_create(surface_valid(w), surface_valid(h));
return surface_create(surface_valid_size(w), surface_valid_size(h));
}
function is_surface(s) {

View file

@ -29,8 +29,15 @@ function textArea(_input, _onModify) constructor {
click_block = 0;
static deselect = function() {
apply();
TEXTBOX_ACTIVE = noone;
UNDO_HOLDING = false;
}
static apply = function() {
if(onModify) onModify(_input_text);
UNDO_HOLDING = true;
}
static move_cursor = function(delta) {
@ -157,11 +164,9 @@ function textArea(_input, _onModify) constructor {
if(keyboard_check_pressed(vk_escape)) {
_input_text = _last_value;
cut_line();
apply();
TEXTBOX_ACTIVE = noone;
deselect();
} else if(keyboard_check_pressed(vk_enter)) {
apply();
TEXTBOX_ACTIVE = noone;
deselect();
}
}
@ -419,8 +424,7 @@ function textArea(_input, _onModify) constructor {
#endregion
if(!point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + hh) && mouse_check_button_pressed(mb_left)) {
apply();
TEXTBOX_ACTIVE = noone;
deselect();
}
} else {
if(hover && point_in_rectangle(_m[0], _m[1], _x, _y, _x + _w, _y + hh)) {

View file

@ -141,9 +141,6 @@ function textBox(_input, _onModify) constructor {
keyboard_string = "";
keyboard_lastkey = -1;
#endregion
if(auto_update && keyboard_check_pressed(vk_anykey))
apply();
if(keyboard_check_pressed(vk_escape)) {
_input_text = _last_value;
@ -152,6 +149,8 @@ function textBox(_input, _onModify) constructor {
} else if(keyboard_check_pressed(vk_enter)) {
apply();
TEXTBOX_ACTIVE = noone;
} else if(auto_update && keyboard_check_pressed(vk_anykey)) {
apply();
}
}
@ -278,8 +277,11 @@ function textBox(_input, _onModify) constructor {
break;
}
apply();
UNDO_HOLDING = true;
if(mouse_check_button_released(mb_left)) {
apply();
UNDO_HOLDING = false;
TEXTBOX_ACTIVE = noone;
}
}
@ -330,6 +332,7 @@ function textBox(_input, _onModify) constructor {
if(keyboard_check(vk_alt)) _input_text = string(toNumber(ktxt) / 2);
else _input_text = string(toNumber(ktxt) * 2);
}
apply();
}
}
@ -338,8 +341,6 @@ function textBox(_input, _onModify) constructor {
else
draw_text(_x + ui(8), _y + hh / 2, "x2");
draw_set_alpha(1);
apply();
}
#endregion