Skip to content

Commit e8e33dc

Browse files
committed
PropTool: Add lock feature
1 parent a2aa2f8 commit e8e33dc

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

ed/adv_tools/main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class AdvToolScript
166166
editor.hide_layers_gui(hide_layers_gui);
167167

168168
store_layer_values();
169-
puts('X');
170169
}
171170

172171
void editor_unloaded()

ed/adv_tools/tools/prop_tool/PropTool.cpp

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class PropTool : Tool
7474

7575
float origin_align_x, origin_align_y;
7676

77+
dictionary locked_props;
78+
int num_locked_props;
79+
7780
private bool has_custom_anchor;
7881
private int custom_anchor_layer = 19;
7982
private float custom_anchor_x, custom_anchor_y;
@@ -413,6 +416,14 @@ class PropTool : Tool
413416

414417
if(script.scene_focus)
415418
{
419+
if(script.editor.key_check_pressed_vk(VK::L))
420+
{
421+
if(script.alt)
422+
unlock_all();
423+
else
424+
lock_selected();
425+
}
426+
416427
if(script.key_repeat_gvb(GVB::LeftArrow))
417428
{
418429
shift_props(script.ctrl ? -20 : script.shift ? -10 : -1, 0);
@@ -921,6 +932,9 @@ class PropTool : Tool
921932
if(!script.editor.check_layer_filter(p.layer()))
922933
continue;
923934

935+
if(locked_props.exists(p.id() + ''))
936+
continue;
937+
924938
const array<array<float>>@ outline = @PROP_OUTLINES[p.prop_set() - 1][p.prop_group()][p.prop_index() - 1];
925939
PropData@ prop_data = highlight_prop(p, outline);
926940

@@ -1463,7 +1477,44 @@ class PropTool : Tool
14631477
update_alignments_from_origin();
14641478
}
14651479

1466-
// Highligts
1480+
private void lock_selected()
1481+
{
1482+
if(selected_props_count == 0)
1483+
return;
1484+
1485+
for(int i = selected_props_count - 1; i >= 0; i--)
1486+
{
1487+
const string key = selected_props[i].prop.id() + '';
1488+
1489+
if(locked_props.exists(key))
1490+
continue;
1491+
1492+
locked_props[key] = true;
1493+
num_locked_props++;
1494+
}
1495+
1496+
script.info_overlay.show(
1497+
selection_x + selection_x1, selection_y + selection_y1,
1498+
selection_x + selection_x2, selection_y + selection_y2,
1499+
selected_props_count + ' props locked.', 0.75);
1500+
1501+
select_none();
1502+
}
1503+
1504+
private void unlock_all()
1505+
{
1506+
if(num_locked_props == 0)
1507+
return;
1508+
1509+
script.info_overlay.show(
1510+
script.mouse,
1511+
num_locked_props + ' props unlocked.', 0.75);
1512+
1513+
locked_props.deleteAll();
1514+
num_locked_props = 0;
1515+
}
1516+
1517+
// Highlights
14671518

14681519
private PropData@ is_prop_highlighted(prop@ prop)
14691520
{
@@ -1563,6 +1614,9 @@ class PropTool : Tool
15631614
if(!script.editor.check_layer_filter(p.layer()))
15641615
continue;
15651616

1617+
if(locked_props.exists(p.id() + ''))
1618+
continue;
1619+
15661620
const float prop_x = p.x();
15671621
const float prop_y = p.y();
15681622
const float rotation = p.rotation() * DEG2RAD * (p.scale_x() >= 0 ? 1.0 : -1.0) * (p.scale_y() >= 0 ? 1.0 : -1.0);

0 commit comments

Comments
 (0)