diff --git a/docs/extended_format.md b/docs/extended_format.md
index 746273a..67b555e 100644
--- a/docs/extended_format.md
+++ b/docs/extended_format.md
@@ -30,8 +30,8 @@ A Rebirth document is different: it saves the game's copy, followed by the exten
…
-
-
+
+
…
@@ -60,11 +60,6 @@ A Rebirth document is different: it saves the game's copy, followed by the exten
- **Instance name:** the layer's `Name` is the name code should use for the instance.
- **No self-nesting:** an animation never plays inside itself, even through other animations. That draw is skipped.
-**Events**
-- Event names are free, but `stop` and `done` are built in.
-- The editor offers them and locks them from renaming. It gives them no behaviour of its own; what they do is up to the runtime.
-- The game's copy of a Rebirth document leaves them out of triggers.
-
## Animations
```xml
@@ -79,8 +74,8 @@ A Rebirth document is different: it saves the game's copy, followed by the exten
…
-
-
+
+
@@ -162,6 +157,6 @@ world = Root · GroupRoot · ( position + Flip · Rotate · Skew · |scale| · (
A Rebirth document's game copy keeps only what the game reads:
- **Animation layers** are flattened into plain layers, one per layer the child draws, named `layer/childLayer`. Their frames are baked one per frame and skew is dropped. A library's spritesheets are added with paths relative to the document.
- **Children's trigger events** join the animation's triggers, matched by name.
-- **Triggers** keep one event each: the first that isn't built in.
+- **Triggers** keep one event each: the first.
- **Dropped attributes:** markers, depth, skew, alpha offset, blur, shaders, extra events, trigger sounds and libraries.
- **SVG spritesheets** are offered for conversion to PNGs before saving.
diff --git a/src/document.cpp b/src/document.cpp
index 68ae592..eafeab3 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -903,17 +903,7 @@ namespace anm2ed
if (kind == SelectionKind::SPRITESHEETS) add(content.spritesheets, path_label_get(FORMAT_SPRITESHEET));
if (kind == SelectionKind::SOUNDS) add(content.sounds, path_label_get(FORMAT_SOUND));
if (kind == SelectionKind::LIBRARIES) add(content.libraries, path_label_get(FORMAT_SOUND));
- if (kind == SelectionKind::EVENTS)
- {
- add(content.events, name_get);
- // An extended document offers the built-in events it doesn't have yet.
- for (int i = 0; model.isExtendedFormat && i < (int)std::size(model::EVENT_BUILT_INS); ++i)
- if (std::ranges::find(content.events, model::EVENT_BUILT_INS[i], &model::Event::name) == content.events.end())
- {
- choices.ids.push_back(model::EVENT_BUILT_IN_ID_FIRST - i);
- choices.labels.emplace_back(model::EVENT_BUILT_INS[i]);
- }
- }
+ if (kind == SelectionKind::EVENTS) add(content.events, name_get);
if (kind == SelectionKind::SHADERS) add(content.shaders, name_get);
if (kind == SelectionKind::REGIONS)
if (auto spritesheet = model.layer_spritesheet_get(layerId)) add(spritesheet->regions, name_get);
diff --git a/src/edit/content.cpp b/src/edit/content.cpp
index a396157..13255cc 100644
--- a/src/edit/content.cpp
+++ b/src/edit/content.cpp
@@ -22,18 +22,6 @@ namespace anm2ed::edit
}
}
- // An event id from a choice: a built-in event not yet in the file is added (or found by name) first.
- int event_id_resolve(Model& model, int id)
- {
- auto index = EVENT_BUILT_IN_ID_FIRST - id;
- if (index < 0 || index >= (int)std::size(EVENT_BUILT_INS)) return id;
- auto& events = model.content.events;
- std::string name(EVENT_BUILT_INS[index]);
- auto event = std::ranges::find(events, name, &Event::name);
- if (event != events.end()) return event->id;
- return events.emplace_back(Event{.id = item_next_id_get(events), .name = name}).id;
- }
-
bool is_region_matched(const Region& region, const Frame& frame)
{
return glm::ivec2(region.crop) == glm::ivec2(frame.crop) && glm::ivec2(region.size) == glm::ivec2(frame.size) &&
diff --git a/src/edit/edit.hpp b/src/edit/edit.hpp
index 1a7517c..b65166f 100644
--- a/src/edit/edit.hpp
+++ b/src/edit/edit.hpp
@@ -137,7 +137,6 @@ namespace anm2ed::edit
std::optional spritesheet_pack(model::Model&, int, const resource::Image&, int);
std::optional spritesheets_merge(model::Model&, const std::set&, const ImageGet&, bool, bool,
bool, Origin);
- int event_id_resolve(model::Model&, int);
// Where a spritesheet path of a document (this one, or a library) points, from this document.
using SpritesheetPathGet = std::function;
diff --git a/src/imgui/window/frame_properties.cpp b/src/imgui/window/frame_properties.cpp
index b0f4abc..e76899a 100644
--- a/src/imgui/window/frame_properties.cpp
+++ b/src/imgui/window/frame_properties.cpp
@@ -161,14 +161,10 @@ namespace anm2ed::imgui
ImGui::PushID(i);
if (combo_id_mapped("##Choice", &id, choices.ids, choices.labels) && frame)
frame_edit(edit_state::COMPLETE, setEdit,
- [index = (std::size_t)i, id, member](Document& document, model::Frame& frame,
- model::Track*, const Reference&)
+ [index = (std::size_t)i, id, member](Document&, model::Frame& frame, model::Track*,
+ const Reference&)
{
- auto& ids = frame.*member;
- if (index >= ids.size()) return;
- ids[index] = member == &model::Frame::eventIds
- ? edit::event_id_resolve(document.model, id)
- : id;
+ if (index < (frame.*member).size()) (frame.*member)[index] = id;
});
ImGui::SetItemTooltip("%s", localize.get(tooltip));
ImGui::PopID();
diff --git a/src/imgui/window/items.cpp b/src/imgui/window/items.cpp
index 09b8486..3d53f3c 100644
--- a/src/imgui/window/items.cpp
+++ b/src/imgui/window/items.cpp
@@ -6,7 +6,6 @@
#include "util/imgui/input.hpp"
#include "util/imgui/layout.hpp"
-using namespace anm2ed::resource;
using namespace anm2ed::types;
namespace anm2ed::imgui
@@ -250,10 +249,9 @@ namespace anm2ed::imgui
if (ImGui::Begin(localize.get(LABEL_EVENTS_WINDOW), &settings.windowIsEvents))
{
auto selection = document.selected_ids_get(SelectionKind::EVENTS);
- auto is_built_in = [&](int id) { return model::is_event_built_in(model::item_get(events, id)->name); };
Actions actions{};
actions.add(
- ACTION_RENAME, [=]() { return selection.size() == 1 && !is_built_in(*selection.begin()); },
+ ACTION_RENAME, [selection]() { return selection.size() == 1; },
[&state, selection]() { state.newId = *selection.begin(); });
actions.add(
ACTION_ADD, {},
@@ -299,31 +297,10 @@ namespace anm2ed::imgui
});
});
},
- .is_locked = is_built_in,
- .font_get = [&](int id) { return is_built_in(id) ? font::ITALICS : font::REGULAR; },
- .tooltip_draw =
- [&](int id)
- {
- item_tooltip_draw(resources, model::item_get(events, id)->name, id);
- if (is_built_in(id)) ImGui::TextUnformatted(localize.get(TOOLTIP_EVENT_BUILT_IN));
- }};
- // Built-in events come first; an extended document lists the ones it doesn't have yet above them.
- auto ids = item_ids_get(events);
- std::ranges::stable_partition(ids, is_built_in);
+ .tooltip_draw = [&](int id)
+ { item_tooltip_draw(resources, model::item_get(events, id)->name, id); }};
list_panel_draw(panel, actions, {{ACTION_ADD, ACTION_REMOVE_UNUSED}},
- [&]()
- {
- ImGui::PushFont(resources.fonts[font::ITALICS].get(), font::SIZE);
- for (auto name : model::EVENT_BUILT_INS)
- if (document.model.isExtendedFormat &&
- std::ranges::find(events, name, &model::Event::name) == events.end())
- {
- ImGui::TextDisabled("%s", std::string(name).c_str());
- ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_EVENT_BUILT_IN));
- }
- ImGui::PopFont();
- content_list_draw(panel, SelectionKind::EVENTS, ids, rows);
- });
+ [&]() { content_list_draw(panel, SelectionKind::EVENTS, item_ids_get(events), rows); });
}
ImGui::End();
}
diff --git a/src/imgui/window/panel.cpp b/src/imgui/window/panel.cpp
index a29a980..29f20f9 100644
--- a/src/imgui/window/panel.cpp
+++ b/src/imgui/window/panel.cpp
@@ -130,7 +130,7 @@ namespace anm2ed::imgui
if (arrowKey == key) ImGui::SetKeyboardFocusHere();
bool isActivated{};
- if (rows.rename && !(rows.is_locked && rows.is_locked(key)))
+ if (rows.rename)
{
if (state.newId == key)
{
diff --git a/src/imgui/window/panel.hpp b/src/imgui/window/panel.hpp
index 5abe337..676712f 100644
--- a/src/imgui/window/panel.hpp
+++ b/src/imgui/window/panel.hpp
@@ -71,7 +71,6 @@ namespace anm2ed::imgui
std::function label_get{};
std::function name_get{};
std::function rename{};
- std::function is_locked{};
std::function is_invalid{};
std::function font_get{};
std::function tooltip_draw{};
diff --git a/src/model/model.hpp b/src/model/model.hpp
index e13b150..e476ba2 100644
--- a/src/model/model.hpp
+++ b/src/model/model.hpp
@@ -291,13 +291,6 @@ namespace anm2ed::model
bool operator==(const Animations&) const = default;
};
- // Events the editor knows by name: shown locked in Events, and added to a file when a trigger first uses one. A
- // choice of one not yet in the file has id EVENT_BUILT_IN_ID_FIRST - its index.
- inline constexpr std::string_view EVENT_BUILT_INS[] = {"stop", "done"};
- inline constexpr int EVENT_BUILT_IN_ID_FIRST = -2;
-
- inline bool is_event_built_in(std::string_view name) { return std::ranges::contains(EVENT_BUILT_INS, name); }
-
// Content item lookup by file id (layers, nulls, events, sounds, spritesheets, shaders, regions).
template auto item_get(Items& items, int id) -> decltype(&items.front())
{
diff --git a/src/model/xml.cpp b/src/model/xml.cpp
index 7241a8e..922d131 100644
--- a/src/model/xml.cpp
+++ b/src/model/xml.cpp
@@ -1124,21 +1124,12 @@ namespace anm2ed::model
if (type == ItemType::TRIGGER)
{
sink.open(tag_get(ElementType::TRIGGER));
- // The game's copy (one event per trigger) keeps the first event that isn't built in.
- auto eventIds = frame.eventIds;
- if (!writer.is(SERIALIZE_EXTENSIONS) && writer.model)
- std::erase_if(eventIds,
- [&](int id)
- {
- auto event = item_get(writer.model->content.events, id);
- return event && is_event_built_in(event->name);
- });
- if (!eventIds.empty()) sink.attribute("EventId", eventIds.front());
+ if (!frame.eventIds.empty()) sink.attribute("EventId", frame.eventIds.front());
sink.attribute("AtFrame", frame.atFrame);
extras_write(sink, frame.extras);
Children children{sink, frame.extras};
if (writer.is(SERIALIZE_EXTENSIONS))
- for (auto eventId : eventIds | std::views::drop(1))
+ for (auto eventId : frame.eventIds | std::views::drop(1))
{
children.add();
sink.open(tag_get(ElementType::EVENT_ELEMENT));
@@ -1403,14 +1394,7 @@ namespace anm2ed::model
issues.depthFrames += track.type == ItemType::LAYER && frame.depth != 0;
issues.alphaOffsetFrames += math::float_to_uint8(frame.colorOffset.a) != 0;
issues.blurFrames += track.type == ItemType::LAYER && frame.blur != 0.0f;
- // Built-in events are left out of the game's copy on purpose; only further custom ones are lost.
- auto customEvents = std::ranges::count_if(frame.eventIds,
- [&](int id)
- {
- auto event = item_get(model.content.events, id);
- return !event || !is_event_built_in(event->name);
- });
- issues.extraEvents += track.type == ItemType::TRIGGER ? std::max((int)customEvents - 1, 0) : 0;
+ issues.extraEvents += track.type == ItemType::TRIGGER ? std::max((int)frame.eventIds.size() - 1, 0) : 0;
issues.triggerSounds += track.type == ItemType::TRIGGER &&
std::ranges::any_of(frame.soundIds, [](int id) { return id != -1; });
}
diff --git a/src/resource/strings.hpp b/src/resource/strings.hpp
index 58276fb..30a4506 100644
--- a/src/resource/strings.hpp
+++ b/src/resource/strings.hpp
@@ -587,7 +587,6 @@ namespace anm2ed
X(TOOLTIP_DEPTH, "Draw this layer this many layers above (or, negative, below) its place in the timeline, for this frame.\n(Editor only; the game always uses the timeline's order.)", "Dibuja esta capa tantas capas por encima (o, en negativo, por debajo) de su lugar en la línea de tiempo, durante este Frame.\n(Solo en el editor; el juego siempre usa el orden de la línea de tiempo.)", "Рисовать этот слой на столько слоёв выше (или, если отрицательно, ниже) его места на таймлайне в этом кадре.\n(Только в редакторе; игра всегда использует порядок таймлайна.)", "在此帧中,将此图层绘制在其时间轴位置之上(负数则之下)若干层。\n(仅限编辑器;游戏始终使用时间轴顺序。)", "이 프레임 동안 이 레이어를 타임라인 위치보다 지정한 수만큼 위(음수면 아래)에 그립니다.\n(편집기 전용이며, 게임은 항상 타임라인 순서를 사용합니다.)") \
X(TOOLTIP_DETACHABLE_WINDOWS, "Windows can be dragged outside the main window into their own windows.\n(Not available on Wayland.)", "Las ventanas pueden arrastrarse fuera de la ventana principal a sus propias ventanas.\n(No disponible en Wayland.)", "Окна можно вытаскивать за пределы главного окна в отдельные окна.\n(Недоступно в Wayland.)", "可以将窗口拖出主窗口,成为独立的窗口。\n(Wayland 下不可用。)", "창을 메인 창 밖으로 끌어내 별도의 창으로 만들 수 있습니다.\n(Wayland에서는 사용할 수 없습니다.)") \
X(TOOLTIP_DOCUMENT_EXTENDED_FORMAT, "Save this document in the extended Anm2Ed format alone, instead of as a Rebirth document with the editor's copy inside.\nThe extended format is NOT compatible with The Binding of Isaac: Rebirth!", "Guarda este documento solo en el formato extendido de Anm2Ed, en vez de como documento de Rebirth con la copia del editor dentro.\n¡El formato extendido NO es compatible con The Binding of Isaac: Rebirth!", "Сохранять этот документ только в расширенном формате Anm2Ed, а не как документ Rebirth с копией редактора внутри.\nРасширенный формат НЕ совместим с The Binding of Isaac: Rebirth!", "仅以 Anm2Ed 扩展格式保存此文档,而不是保存为内含编辑器副本的 Rebirth 文档。\n扩展格式与 The Binding of Isaac: Rebirth 不兼容!", "이 문서를 편집기 사본이 들어 있는 Rebirth 문서 대신 Anm2Ed 확장 형식으로만 저장합니다.\n확장 형식은 The Binding of Isaac: Rebirth와 호환되지 않습니다!") \
- X(TOOLTIP_EVENT_BUILT_IN, "A built-in event: it can't be renamed, and is added to the file when a trigger first uses it.", "Un evento integrado: no se puede renombrar y se añade al archivo cuando un trigger lo usa por primera vez.", "Встроенное событие: его нельзя переименовать; оно добавляется в файл, когда триггер впервые его использует.", "内置事件:不能重命名,当触发器首次使用时添加到文件中。", "내장 이벤트: 이름을 바꿀 수 없으며 트리거가 처음 사용할 때 파일에 추가됩니다.") \
X(TOOLTIP_ISAAC_COMPATIBILITY_WARNING, "Before saving, list anything the game doesn't support and what will happen to it.", "Antes de guardar, muestra lo que el juego no soporta y lo que pasará con ello.", "Перед сохранением показывать всё, что игра не поддерживает, и что с этим произойдёт.", "保存前列出游戏不支持的内容及其处理方式。", "저장하기 전에 게임이 지원하지 않는 항목과 그 처리 방식을 알려줍니다.") \
X(TOOLTIP_LAYER_ANIMATION, "The animation this layer plays.", "La animación que reproduce esta capa.", "Анимация, которую проигрывает этот слой.", "此图层播放的动画。", "이 레이어가 재생하는 애니메이션.") \
X(TOOLTIP_LAYER_ANIMATION_MISSING, "This layer's animation isn't in its file; it draws nothing.", "La animación de esta capa no está en su archivo; no dibuja nada.", "Анимации этого слоя нет в её файле; слой ничего не рисует.", "此图层的动画不在其文件中;它不会绘制任何内容。", "이 레이어의 애니메이션이 파일에 없어 아무것도 그리지 않습니다.") \
diff --git a/tests/operations.cpp b/tests/operations.cpp
index 6701f83..16e390a 100644
--- a/tests/operations.cpp
+++ b/tests/operations.cpp
@@ -438,25 +438,14 @@ TEST_CASE("skew reads from the old Shear attributes too")
CHECK(frames[0].extras.attributes.empty());
}
-TEST_CASE("a trigger fires several events; built-in events join a file when first used")
+TEST_CASE("a trigger fires several events; the game's copy keeps the first")
{
auto model = fixture_load("02_items.anm2");
- auto stopId = edit::event_id_resolve(model, model::EVENT_BUILT_IN_ID_FIRST);
- CHECK(model::item_get(model.content.events, stopId)->name == "stop");
- CHECK(edit::event_id_resolve(model, model::EVENT_BUILT_IN_ID_FIRST) == stopId);
- CHECK(edit::event_id_resolve(model, 1) == 1);
-
- model.frame_edit({0, TRIGGER, -1, 0})->eventIds = {0, stopId, 1};
+ model.frame_edit({0, TRIGGER, -1, 0})->eventIds = {1, 0};
auto text = model::model_to_string(model);
- CHECK(model_load(text).frame_get({0, TRIGGER, -1, 0})->eventIds == std::vector{0, stopId, 1});
- CHECK(model_load(game_document_get(text)).frame_get({0, TRIGGER, -1, 0})->eventIds == std::vector{0});
+ CHECK(model_load(text).frame_get({0, TRIGGER, -1, 0})->eventIds == std::vector{1, 0});
+ CHECK(model_load(game_document_get(text)).frame_get({0, TRIGGER, -1, 0})->eventIds == std::vector{1});
CHECK(model::isaac_issues_get(model).extraEvents == 1);
-
- // The game's copy skips built-in events for the first custom one.
- model.frame_edit({0, TRIGGER, -1, 0})->eventIds = {stopId, 1};
- CHECK(model_load(game_document_get(model::model_to_string(model))).frame_get({0, TRIGGER, -1, 0})->eventIds ==
- std::vector{1});
- CHECK(model::isaac_issues_get(model).extraEvents == 0);
}
TEST_CASE("SVG spritesheets pack and merge into SVGs")