|
1 | 1 | #include "../config.hpp" |
2 | 2 | #include "ObjectWorkshop.hpp" |
3 | 3 | #include "Geode/ui/Scrollbar.hpp" |
| 4 | +#include "popups/ObjUploadPopup.hpp" |
4 | 5 | #include "popups/WarningPopup.hpp" |
5 | 6 | #include "popups/includes.h" |
6 | 7 | #include "admin/AdminPopup.hpp" |
@@ -279,6 +280,9 @@ bool ObjectWorkshop::init(bool authenticated) { |
279 | 280 | } |
280 | 281 | } |
281 | 282 | ); |
| 283 | + Build<CCSprite>::createSpriteName("GJ_shareBtn_001.png").scale(0.5f).intoMenuItem([this]() { |
| 284 | + ObjUploadPopup::create(m_user)->show(); |
| 285 | + }).parentAtPos(m_buttonMenu, Anchor::BottomRight, {22, 20}); |
282 | 286 | } |
283 | 287 | Build<CCSprite>::createSpriteName("GJ_arrow_01_001.png").scale(0.8f).intoMenuItem([this]() { |
284 | 288 | if (m_currentPage > 1) { |
@@ -1100,197 +1104,7 @@ T* clonePointer(const T* original) { |
1100 | 1104 | } |
1101 | 1105 |
|
1102 | 1106 | void ObjectWorkshop::onUploadBtn(CCObject*) { |
1103 | | - if (!m_inEditor) { |
1104 | | - FLAlertLayer::create("Error", "You cannot <cy>upload objects</c> if you aren't in the <cl>Editor</c>!", "OK")->show(); |
1105 | | - return; |
1106 | | - } |
1107 | | - m_filterTags.clear(); |
1108 | | - m_currentMenu = 1; |
1109 | | - rightBg->setVisible(false); |
1110 | | - m_pageLabel->setVisible(false); |
1111 | | - obj_backBtn->setVisible(true); |
1112 | | - |
1113 | | - auto middleBg = CCScale9Sprite::create("square02_small.png"); |
1114 | | - middleBg->setOpacity(25); |
1115 | | - middleBg->setContentSize({360, 238}); |
1116 | | - objectInfoNode->addChildAtPosition(middleBg, Anchor::Center, {0, 5}); |
1117 | | - |
1118 | | - auto previewBG = CCScale9Sprite::create("square02_small.png"); |
1119 | | - previewBG->setOpacity(60); |
1120 | | - previewBG->setContentSize({ 360.F - 20.F, 82.F }); |
1121 | | - auto previewLabel = CCLabelBMFont::create("Select an Object", "goldFont.fnt"); |
1122 | | - previewLabel->setScale(0.425F); |
1123 | | - previewBG->addChildAtPosition(previewLabel, Anchor::Top, {0,-8}); |
1124 | | - middleBg->addChildAtPosition(previewBG, Anchor::Top, {0, -50}); |
1125 | | - |
1126 | | - auto bottomBg = CCScale9Sprite::create("square02_small.png"); |
1127 | | - bottomBg->setOpacity(25); |
1128 | | - bottomBg->setContentSize({275, 120}); |
1129 | | - middleBg->addChildAtPosition(bottomBg, Anchor::Center, {0, -45}); |
1130 | | - |
1131 | | - m_objName = TextInput::create(300.0F, "Object Name", "bigFont.fnt"); |
1132 | | - m_objName->setScale(0.8); |
1133 | | - m_objName->setMaxCharCount(64); |
1134 | | - m_objName->setCommonFilter(CommonFilter::Any); |
1135 | | - bottomBg->addChildAtPosition(m_objName, Anchor::Top, {0, -20}); |
1136 | | - |
1137 | | - /* |
1138 | | - m_objDesc = TextInputNode::create("Description [Optional]", 300, {270, 60}, 90);//{270.F, 30.F}, 90); |
1139 | | - m_objDesc->getInput()->setScale(0.5F); |
1140 | | - bottomBg->addChildAtPosition(m_objDesc, Anchor::Center, {-1, -3}); |
1141 | | - m_objDesc->addChildAtPosition(m_objDesc->getInput(), Anchor::Center); |
1142 | | - m_objDesc->setUpdateCallback([this](std::string text) { |
1143 | | - m_objDesc->getInput()->m_textArea->m_width = 300.0F / Utils::calculateScale(text, 50, 300, 1.0F, 0.5F); |
1144 | | - m_objDesc->getInput()->setScale(Utils::calculateScale(text, 50, 300, 0.75F, 0.45F)); |
1145 | | - m_objDesc->getInput()->setPosition({ |
1146 | | - Utils::calculateScale(text, 50, 300, 100, 60), |
1147 | | - Utils::calculateScale(text, 50, 300, 25, 20) |
1148 | | - }); |
1149 | | - }); |
1150 | | - //m_objDesc->getBackground()->setScale(0.5F); |
1151 | | - /\*m_objDesc->getBackground()->setContentSize({ |
1152 | | - (m_objDesc->getSize().width - 20.F) * 2.F, |
1153 | | - (m_objDesc->getSize().height + 20.F) * 2.F |
1154 | | - });*\/ |
1155 | | - /\*m_objDesc->getBackground()->setContentSize({ |
1156 | | - 520, 100 |
1157 | | - });*/ |
1158 | | - |
1159 | | -#ifndef GEODE_IS_ANDROID32 |
1160 | | - auto textArea = TextArea::create("", "chatFont.fnt", 1.0F, 270.0F, {0.5, 0.5}, 20.0F, true); |
1161 | | - // TextArea::create(&local_64,"chatFont.fnt",,0x439d8000,this_03,0x41a00000,1); |
1162 | | -#endif |
1163 | | - m_objDesc = TextInput::create(270.0F, "Description [Optional]", "chatFont.fnt"); |
1164 | | -#ifndef GEODE_IS_ANDROID32 |
1165 | | - m_objDesc->getInputNode()->addTextArea(textArea); |
1166 | | - m_objDesc->getInputNode()->m_cursor->setOpacity(0); |
1167 | | -#endif |
1168 | | - m_objDesc->getBGSprite()->setContentSize({520.0F, 100.0F}); |
1169 | | - m_objDesc->setMaxCharCount(300); |
1170 | | - m_objDesc->setCommonFilter(CommonFilter::Any); |
1171 | | - bottomBg->addChildAtPosition(m_objDesc, Anchor::Center, {0, -3}); |
1172 | | -#ifndef GEODE_IS_ANDROID32 |
1173 | | - m_objDesc->setCallback( |
1174 | | - [this, textArea](std::string p0) { |
1175 | | - m_objDesc->getInputNode()->m_textLabel->setOpacity((p0.empty()) ? 255 : 0); |
1176 | | - textArea->setScale(Utils::calculateScale(p0, 50, 300, 0.9F, 0.35F)); |
1177 | | - textArea->m_width = 220.0F / Utils::calculateScale(p0, 50, 300, 1.0F, 0.32F); |
1178 | | - textArea->setString(m_objDesc->getInputNode()->getString()); |
1179 | | - //textArea->setString(p0.data()); |
1180 | | - } |
1181 | | - ); |
1182 | | -#endif |
1183 | | - auto rulesSpr = ButtonSprite::create("Rules", "bigFont.fnt", "GJ_button_03.png"); |
1184 | | - rulesSpr->setScale(0.8F); |
1185 | | - auto uploadSpr = ButtonSprite::create("Upload", "bigFont.fnt", "GJ_button_01.png"); |
1186 | | - uploadSpr->setScale(0.8F); |
1187 | | - auto uploadBtn = CCMenuItemSpriteExtra::create( |
1188 | | - uploadSpr, |
1189 | | - this, |
1190 | | - menu_selector(ObjectWorkshop::onUpload) |
1191 | | - ); |
1192 | | - auto rulesBtn = CCMenuItemSpriteExtra::create( |
1193 | | - rulesSpr, |
1194 | | - this, |
1195 | | - menu_selector(ObjectWorkshop::onRulesBtn) |
1196 | | - ); |
1197 | | - uploadBtn->setID("uploadbtn"_spr); |
1198 | | - rulesBtn->setID("rulesbtn"_spr); |
1199 | | - auto filterSpr = ButtonSprite::create( |
1200 | | - CCSprite::createWithSpriteFrameName("GJ_filterIcon_001.png"), |
1201 | | - 30, |
1202 | | - 0, |
1203 | | - .0F, |
1204 | | - 1.0F, |
1205 | | - false, |
1206 | | - "GJ_button_04.png", |
1207 | | - false |
1208 | | - ); |
1209 | | - filterSpr->setScale(0.75F); |
1210 | | - auto filterBtn = CCMenuItemSpriteExtra::create( |
1211 | | - filterSpr, |
1212 | | - this, |
1213 | | - menu_selector(ObjectWorkshop::onUploadFilterBtn) |
1214 | | - ); |
1215 | | - filterBtn->setID("tagbtn"_spr); |
1216 | | - |
1217 | | - m_buttonMenu->addChildAtPosition(filterBtn, Anchor::Bottom, {-60, 57}); |
1218 | | - m_buttonMenu->addChildAtPosition(uploadBtn, Anchor::BottomRight, {-85, 57}); |
1219 | | - m_buttonMenu->addChildAtPosition(rulesBtn, Anchor::BottomRight, {-195, 57}); |
1220 | | - //bottomBg->addChildAtPosition(textArea, Anchor::Center, {0, -20}); |
1221 | | - if (auto editor = CustomObjects::get()) { |
1222 | | - auto scrollLayer = ScrollLayerExt::create({ 0, 0, 275.0F, 280.0F }, true); |
1223 | | - scrollLayer->setContentSize({275.0F, 60.0F}); |
1224 | | - scrollLayer->setAnchorPoint({0.5, 1.0}); |
1225 | | - auto content = CCMenu::create(); |
1226 | | - content->setScale(0.675F); |
1227 | | - content->setZOrder(2); |
1228 | | - content->setPositionX(20); |
1229 | | - content->registerWithTouchDispatcher(); |
1230 | | - |
1231 | | - scrollLayer->m_contentLayer->addChild(content); |
1232 | | - scrollLayer->setTouchEnabled(true); |
1233 | | - |
1234 | | - if (m_oldCustomObjectButtonArray == nullptr) { |
1235 | | - m_oldCustomObjectButtonArray = editor->m_customObjectButtonArray; |
1236 | | - } |
1237 | | - CCArrayExt<CreateMenuItem*> customItems = editor->createCustomItems(); |
1238 | | - int size = customItems.size() - 4; |
1239 | | - for (int i = 0; i < size; i++) { |
1240 | | - customItems[i]->setID(fmt::format("{}", i)); |
1241 | | - if (i > 17) { |
1242 | | - customItems[i]->setEnabled(false); |
1243 | | - } |
1244 | | - content->addChild(customItems[i]); |
1245 | | - } |
1246 | | - previewBG->addChild(scrollLayer); |
1247 | | - content->setLayout( |
1248 | | - RowLayout::create() |
1249 | | - ->setAxisAlignment(AxisAlignment::Start) |
1250 | | - ->setCrossAxisAlignment(AxisAlignment::End) |
1251 | | - ->setAutoScale(true) |
1252 | | - ->setCrossAxisOverflow(false) |
1253 | | - ->setGap(5) |
1254 | | - ->setGrowCrossAxis(true) |
1255 | | - ); |
1256 | | - content->setContentSize({400.0F, 400.0F}); |
1257 | | - content->setAnchorPoint({0.5, 1.0}); |
1258 | | - content->setPosition({137, 280}); |
1259 | | - //content->setContentSize({265.0F, 230.0F}); |
1260 | | - content->updateLayout(); |
1261 | | - scrollLayer->moveToTop(); |
1262 | | - scrollLayer->fixTouchPrio(); |
1263 | | - scrollLayer->setCallbackMove([size, content]() { |
1264 | | - if (content == nullptr) return; |
1265 | | - for (int i = 0; i < size; i++) { |
1266 | | - if (auto child = typeinfo_cast<CreateMenuItem*>(content->getChildByID(fmt::format("{}", i)))) { |
1267 | | - child->setEnabled(false); |
1268 | | - } |
1269 | | - } |
1270 | | - }); |
1271 | | - scrollLayer->setCallbackEnd([size, content, scrollLayer]() { |
1272 | | - if (content == nullptr) return; |
1273 | | - for (int i = 0; i < size; i++) { |
1274 | | - if (auto child = typeinfo_cast<CreateMenuItem*>(content->getChildByID(fmt::format("{}", i)))) { |
1275 | | - float contentYPos = scrollLayer->m_contentLayer->getPositionY(); |
1276 | | - float childYPos = (child->getPositionY()); |
1277 | | - |
1278 | | - child->setEnabled(!Utils::isInScrollSnapRange(contentYPos, childYPos)); |
1279 | | - |
1280 | | - //float index = -(contentYPos + 220) / 30.F; |
1281 | | - //float lower_bound = 380.F + index * 35.F; |
1282 | | - //float upper_bound = lower_bound - 35; |
1283 | | - |
1284 | | - //child->setEnabled(upper_bound <= childYPos <= lower_bound); |
1285 | 1107 |
|
1286 | | - // 60 |
1287 | | - } |
1288 | | - } |
1289 | | - if (scrollLayer->m_contentLayer->getPositionY() > -220.F) { |
1290 | | - scrollLayer->m_contentLayer->setPositionY(Utils::getSnappedYPosition(scrollLayer->m_contentLayer->getPositionY(), 300)); // or 290 |
1291 | | - } |
1292 | | - }); |
1293 | | - } |
1294 | 1108 | } |
1295 | 1109 |
|
1296 | 1110 | void ObjectWorkshop::onSearchBtn(CCObject*) { |
|
0 commit comments