Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- auto ShowData = [this, &selected, &counter, &allFsm, &firstSelected, &endSelection, &lastSelected, /*&EntityListContextualMenu,*/ gameContext, &selectPrevious, &selectNext](
- ECS::Entity &ent, const std::string &name) {
- ImGui::PushID(counter);
- const bool isItemSelected = selected.find(ent.Index()) != selected.end();
- bool errorState = ent.HasComponent<ECS::Comp::TamChangeCorruption>();
- if (isItemSelected) {
- firstSelected = std::min(firstSelected, counter);
- lastSelected = counter;
- }
- // TODO: Esto será igual para las dos listas...
- if(ImGui::IsWindowFocused()) {
- if(ImGui::IsKeyPressed(Keyboard::TOP_ARROW, true)) {
- selectPrevious = true;
- }
- if(ImGui::IsKeyPressed(Keyboard::BOTTOM_ARROW, true)) {
- selectNext = true;
- }
- }
- if (ImGui::Selectable(name.c_str(), isItemSelected, ImGuiSelectableFlags_SpanAllColumns)) {
- if (ImGui::IsKeyDown(Key::LEFT_SHIFT)) {
- endSelection = counter;
- } else if (ImGui::IsKeyDown(Key::LEFT_CTRL)) {
- if (isItemSelected) {
- mSelectorSystem->RemoveSelected(ent);
- } else {
- mSelectorSystem->AddSelected(ent);
- }
- } else {
- mSelectorSystem->AddSelected(ent, true);
- }
- }
- struct EntityBatchDragAndDrop {
- ECS::Entity entities[1024];
- uint32_t entitiesCount = 0;
- };
- ImGui::SetItemAllowOverlap();
- if (ImGui::BeginDragDropTarget()) {
- if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload(ENTITY_BATCH_PAYLOAD)) {
- EntityBatchDragAndDrop acceptedPayload = *(EntityBatchDragAndDrop *) (payload->Data);
- if (acceptedPayload.entitiesCount > 0) {
- const auto destinationIndex = ent.Index();
- bool isMovementValid = true;
- for (auto idx = 0u; idx < acceptedPayload.entitiesCount; idx++) {
- auto &e = acceptedPayload.entities[idx];
- if (destinationIndex == e.Index()) {
- isMovementValid = false;
- }
- }
- if (isMovementValid) {
- if (ImGui::IsKeyDown(Key::LEFT_CTRL)) {
- for (auto idx = 0u; idx < acceptedPayload.entitiesCount; idx++) {
- auto &e = acceptedPayload.entities[idx];
- mSGSystem->MoveOver(::ECS::Index(e.Index()), destinationIndex);
- }
- } else {
- for (auto idx = acceptedPayload.entitiesCount; idx > 0; idx--) {
- auto &e = acceptedPayload.entities[idx - 1];
- mSGSystem->MoveUnder(::ECS::Index(e.Index()), destinationIndex);
- }
- }
- ent.GetComponentHandler<ECS::Comp::Transform>().ForceReplace();
- }
- }
- }
- ImGui::EndDragDropTarget();
- }
- ImGui::SetItemAllowOverlap();
- if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceAllowNullID)) {
- EntityBatchDragAndDrop ebdd;
- mSelectorSystem->ForEachSelected([&](size_t idx, ECS::Entity e) {
- if (ebdd.entitiesCount < 1002) {
- ebdd.entities[ebdd.entitiesCount++] = e;
- } else {
- std::cerr << "[ERR] more than 1000 items moving at same time!!" << std::endl;
- }
- });
- ImGui::SetDragDropPayload(ENTITY_BATCH_PAYLOAD, &ebdd, sizeof(ebdd), ImGuiCond_Always);
- if (ebdd.entitiesCount == 1) {
- ImGui::Text("Moving node....%s", name.c_str());
- } else {
- std::stringstream ss;
- ImGui::Text("Moving %d entities.", ebdd.entitiesCount);
- }
- ImGui::EndDragDropSource();
- }
- ImGui::SetItemAllowOverlap();
- if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(Mouse::CLICK)) {
- }
- if (ImGui::BeginPopupContextWindow()) {
- // EntityListContextualMenu(counter);
- componentTag.ShowContextualMenu(selected, selectedForRemove);
- ImGui::EndPopup();
- }
- ImGui::NextColumn();
- //ImGui::Text("%d", c.z); ImGui::NextColumn();
- //ImGui::Text("%d", c.cheatOrder); ImGui::NextColumn();
- bool keep_line = false;
- const auto pre = ImGui::GetCursorPos();
- const auto CHAR_SIZE = ImGui::CalcTextSize("A");
- auto item_signature = ent.GetSignature();
- // const auto add_component_tag = [&](const ECS::Signature &signature, ImColor color, std::string_view text) {
- // if (ECS::Match(item_signature, signature)) {
- // if (keep_line) {
- // ImGui::SameLine();
- // }
- // ImGui::TextColored(color, "+%s", text.data());
- // keep_line = true;
- // }
- // };
- componentTag.RotTag(ent);
- componentTag.RotRefTag(ent);
- componentTag.RotBaseTag(ent);
- componentTag.SpriteTag(ent);
- componentTag.AnimationTag(ent);
- componentTag.AnimationPlayingTag(ent);
- componentTag.FontTag(ent);
- componentTag.NativeReelTag(ent);
- componentTag.SoundTag(ent);
- componentTag.LayeredFontTag(ent);
- if (ent.HasComponent<ECS::Comp::Video>()) {
- if (keep_line) {
- ImGui::SameLine();
- }
- const std::string VIDEO_TAG = "Video"; // TODO: Ver como ponemos esto....
- ImGui::TextColored(EddieColors().COLOR_VIDEO, "+%s", VIDEO_TAG.c_str());
- keep_line = true;
- }
- auto add_fsm = componentTag.FsmTag(ent);
- if (add_fsm) {
- ImGui::SameLine();
- const auto post = ImGui::GetCursorPos();
- const auto spacing = ImVec2(post.x - pre.x, CHAR_SIZE.y);
- ImGui::SetCursorPos(pre);
- ImGui::Dummy(spacing);
- auto fsm_obj = ent.GetComponentHandler<ECS::Comp::Fsm>();
- if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(Mouse::CLICK)) {
- gContext->EmitEvent<ECS::DirectSelectFsm>(fsm_obj->fsmCode);
- }
- if (isItemSelected) {
- allFsm.emplace(fsm_obj->fsmCode);
- }
- }
- ImGui::NextColumn();
- if (!errorState) {
- const auto cursor = ImGui::GetCursorPos();
- ImVec2 size;
- if (ent.HasComponent<ECS::Comp::OnScene>()) {
- size = ImGui::CalcTextSize("- Visible");
- ImGui::TextColored(EddieColors().COLOR_VISIBLE, "- Visible");
- } else {
- size = ImGui::CalcTextSize("- Invisible");
- ImGui::TextColored(EddieColors().COLOR_INVISIBLE, "- Invisible");
- }
- ImGui::SetCursorPos(cursor);
- ImGui::Dummy(size);
- if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
- if (ent.HasComponent<ECS::Comp::OnScene>()) {
- ent.Remove<ECS::Comp::OnScene>();
- } else {
- ent.AddComponent<ECS::Comp::OnScene>();
- }
- }
- ImGui::SameLine();
- componentTag.HideOnEditorTag(ent);
- } else {
- ImGui::TextColored(EddieColors().COLOR_MISSING_DATA, "MISSING TAM DATA ");
- ImGui::SameLine();
- }
- ImGui::NextColumn();
- ImGui::PopID();
- counter++;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement