@@ -29,6 +29,36 @@ local function get_atlas(opts)
29
29
end
30
30
31
31
32
+ local dialog = editor.ui.component(function(props)
33
+ local name, set_name = editor.ui.use_state("")
34
+
35
+ return editor.ui.dialog({
36
+ title= props.title,
37
+ content = editor.ui.vertical({
38
+ padding = editor.ui.PADDING_LARGE,
39
+ children = {
40
+ editor.ui.string_field({
41
+ value = name,
42
+ on_value_changed = set_name
43
+ })
44
+ }
45
+ }),
46
+ buttons = {
47
+ editor.ui.dialog_button({
48
+ text = "Cancel",
49
+ cancel = true
50
+ }),
51
+ editor.ui.dialog_button({
52
+ text = "Add",
53
+ enabled = name ~= "",
54
+ defualt = true,
55
+ result = name
56
+ }),
57
+ }
58
+ })
59
+ end)
60
+
61
+
32
62
local function update_atlas(atlas, new_images_string)
33
63
-- Get the old atlas text then add our new string to the beginning.
34
64
-- While the editor would add them to the end, it's a lot easier for
97
127
98
128
99
129
local function add_images_as_animation(opts)
100
- local animation_start_string = "animations {\ id: \"" .. "anim_" .. os.date("%Y%m%d%H%M%S") .. "\"\n"
130
+ local animation_name = editor.ui.show_dialog(dialog({ title = "Add images as animation" }))
131
+ if animation_name == nil then
132
+ return
133
+ end
134
+
135
+ local animation_start_string = "animations {\ id: \"" .. animation_name .. "\"\n"
101
136
local animation_end_string = " playback: PLAYBACK_LOOP_FORWARD\n fps: 60\n flip_horizontal: 0 \nflip_vertical: 0\n}\n"
102
137
local images = image_strings(opts, 4)
103
138
117
152
118
153
119
154
local function add_images_to_new_atlas(opts)
155
+ local atlas_name = editor.ui.show_dialog(dialog({ title = "Create a new atlas" }))
156
+ if atlas_name == nil then
157
+ return
158
+ end
159
+
120
160
local base_path = path_segments(editor.get(opts.selection[1], "path"))
121
- local atlas = base_path .. "ATLAS" .. os.date("%Y%m%d%H%M%S") .. ".atlas"
161
+ local atlas = base_path .. atlas_name .. ".atlas"
122
162
local atlas_string = ""
123
163
for _, id in pairs(opts.selection) do
124
164
local path = editor.get(id, "path")
0 commit comments