Skip to content

Commit

Permalink
make extra object info toggleable
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Oct 10, 2023
1 parent ff9faa5 commit 3d4608a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@
"name": "Show dash orb trajectory",
"description": "When enabled, dash orb trajectories will be shown in the editor"
},
"extra-object-info": {
"type": "bool",
"default": true,
"name": "Extra Object Info",
"description": "When enabled, will show additional object info when selected (needs \"Show Object Info\" to be enabled)"
},
"dynamic-object-info": {
"type": "bool",
"default": true,
"name": "Dynamic Object Info",
"description": "When enabled, will dynamically update shown object info when moving, scaling and rotating. \"Extra Object Info\" needs to enabled for this to work. (<cr>Might cause lag</c>)"
},
"enable-global-clipboard": {
"type": "bool",
"default": true,
Expand Down
34 changes: 34 additions & 0 deletions src/features/ExtraObjInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,19 @@ std::string objectTypeToString(GameObjectType type) {
}

class $modify(EditorUI) {
CCPoint defaultObjectInfoPos;
CCPoint modifiedObjectInfoPos;
bool init(LevelEditorLayer* lel) {
if (!EditorUI::init(lel)) {
return false;
}
if (!Mod::get()->getSettingValue<bool>("extra-object-info")) {
return true;
}
m_fields->defaultObjectInfoPos = m_objectInfoLabel->getPosition();
m_objectInfoLabel->setPositionY(m_objectInfoLabel->getPositionY() + 5.f);
m_objectInfoLabel->setPositionX(90.0f);
m_fields->modifiedObjectInfoPos = m_objectInfoLabel->getPosition();
return true;
}

Expand All @@ -143,20 +150,38 @@ class $modify(EditorUI) {

void moveObject(GameObject* g, CCPoint pos) {
EditorUI::moveObject(g, pos);
if (
!Mod::get()->getSettingValue<bool>("extra-object-info") ||
!Mod::get()->getSettingValue<bool>("dynamic-object-info")
) {
return;
}
if (!m_editorLayer->m_editorInitialising) {
this->updateObjectInfoLabel();
}
}

void ccTouchEnded(CCTouch* touch, CCEvent* event) {
EditorUI::ccTouchEnded(touch, event);
if (
!Mod::get()->getSettingValue<bool>("extra-object-info") ||
!Mod::get()->getSettingValue<bool>("dynamic-object-info")
) {
return;
}
if (m_selectedObject) {
this->updateObjectInfoLabel();
}
}

void ccTouchMoved(CCTouch* touch, CCEvent* event) {
EditorUI::ccTouchMoved(touch, event);
if (
!Mod::get()->getSettingValue<bool>("extra-object-info") ||
!Mod::get()->getSettingValue<bool>("dynamic-object-info")
) {
return;
}
if (m_selectedObject) {
this->updateObjectInfoLabel();
}
Expand All @@ -174,6 +199,15 @@ class $modify(EditorUI) {
return;
}

if (!Mod::get()->getSettingValue<bool>("extra-object-info")) {
m_objectInfoLabel->setPosition(m_fields->defaultObjectInfoPos);
EditorUI::updateObjectInfoLabel();
return;
}
if (m_objectInfoLabel->getPosition() != m_fields->modifiedObjectInfoPos) {
m_objectInfoLabel->setPosition(m_fields->modifiedObjectInfoPos);
}

std::stringstream ss;
if (m_selectedObject->m_baseColor && m_selectedObject->m_detailColor) {
ss << "C1: " << getColorID(m_selectedObject->m_baseColor) << "\n";
Expand Down

0 comments on commit 3d4608a

Please sign in to comment.