Skip to content

Commit

Permalink
fix some playtest stuff and unwanted ccTouchEnded
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Oct 9, 2023
1 parent 682068d commit 4d92e14
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/features/StartPosSwitcher/StartPosSwitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@
using namespace geode::prelude;
using namespace editor_api;

struct RecalculateStartPosData {
CCPoint original;
CCPoint newPoint;
};
bool g_enteringLevel = false;

class $modify(PlayLayer) {
StartPosObject* activeStartPos = nullptr;
bool fromLevelStart = false;
void addObject(GameObject* obj) {
g_enteringLevel = false;
PlayLayer::addObject(obj);
if (obj->m_objectID != 31) {
return;
}
if (StartPosManager::get()->isDefault()) {
if (StartPosManager::get()->isDefault() && !m_fields->activeStartPos) {
return;
}
if (StartPosManager::get()->isLevelStart()) {
if (StartPosManager::get()->isLevelStart() && !m_fields->activeStartPos) {
m_startPos = nullptr;
m_playerStartPosition = CCPointZero;
return;
Expand Down Expand Up @@ -79,10 +77,12 @@ class $modify(StartPosSwitchLayer, LevelEditorLayer) {

void removeSpecial(GameObject* obj) {
LevelEditorLayer::removeSpecial(obj);

if (obj->m_objectID != 31) {
return;
}
if (g_enteringLevel) {
return;
}
PlaytestHerePopup::hide();
if (obj->m_objectID == 31) {
auto manager = StartPosManager::get();
Expand Down Expand Up @@ -157,6 +157,7 @@ class $modify(EditorPauseLayer) {

void onSaveAndPlay(CCObject* sender) {
StartPosManager::get()->setStartPositions(m_editorLayer->m_objects);
g_enteringLevel = true;
EditorPauseLayer::onSaveAndPlay(sender);
}

Expand Down Expand Up @@ -251,12 +252,14 @@ class $modify(MyEditorUI, EditorUI) {
// if we are free moving any startpos, update the manager and clear the map
void ccTouchEnded(CCTouch* touch, CCEvent* event) {
EditorUI::ccTouchEnded(touch, event);
for (const auto& kv : m_fields->startPosOriginals) {
StartPosManager::get()->replaceStartPos(kv.second, kv.first->getPosition());
if (m_fields->holding && !m_fields->startPosOriginals.empty()) {
for (const auto& kv : m_fields->startPosOriginals) {
StartPosManager::get()->replaceStartPos(kv.second, kv.first->getPosition());
}
m_fields->buttonBar->setStartPosCounters();
m_fields->startPosOriginals.clear();
m_fields->holding = false;
}
m_fields->buttonBar->setStartPosCounters();
m_fields->startPosOriginals.clear();
m_fields->holding = false;
}

void moveObjectCall(EditCommand cmd) {
Expand Down

0 comments on commit 4d92e14

Please sign in to comment.