Skip to content

Commit cc768bb

Browse files
committed
bug fix update!
1 parent dad5b6a commit cc768bb

File tree

12 files changed

+88
-23
lines changed

12 files changed

+88
-23
lines changed

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.4.5
2+
- Fixed bug with comments showing another players icon sometimes
3+
- Fixed bug with the game crashing if you press enter while in the menu or on a profile
4+
- Fixed cases not showing properly
5+
- Fixed bug with going to user profiles bugging out if you aren't authenticated
6+
- Fixed other miscellaneous bugs
17
# v1.4.4
28
- Fixed issue with opening and closing ProfilePage randomly causing crashes
39
- Don't allow opening Object Workshop in ProfilePage while in a level (not sure why you would do that...)

mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.0.1",
2+
"geode": "4.2.0",
33
"gd": {
44
"win": "2.2074",
55
"android": "2.2074",
@@ -8,7 +8,7 @@
88
},
99
"id": "firee.object-workshop",
1010
"name": "Object Workshop",
11-
"version": "v1.4.4",
11+
"version": "v1.4.5",
1212
"developer": "Firee",
1313
"description": "Download, upload, or find custom objects made by other creators!",
1414
"resources": {
@@ -24,7 +24,7 @@
2424
"settings": {
2525
"token": {
2626
"name": "Auth Token",
27-
"description": "Authentication Token (DO NOT CHANGE)",
27+
"description": "Authentication Token (DO NOT SHARE)",
2828
"type": "string",
2929
"default": ""
3030
},

server/src/controllers/staff.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function banToRole(type: number): number {
1313
default: return 0;
1414
case 1:
1515
case 4:
16-
return -2;
16+
return -1;
1717
case 2:
1818
case 5:
19-
return -1;
19+
return -2;
2020
case 3:
2121
case 6:
2222
return -3;
@@ -68,7 +68,7 @@ sRouter.post("/case/create",
6868
if (requiresExp) values.push(expiration);
6969
await pool.query(query, values);
7070
if (caseType > 0) {
71-
await pool.query('UPDATE users SET role = $1 WHERE account_id = $2', [banToRole(caseType), userID]);
71+
await pool.query('UPDATE users SET role = $1, ban_reason = $2 WHERE account_id = $3', [banToRole(caseType), reason, userID]);
7272
}
7373
res.status(200).json({ message: "Case submitted." })
7474
}

server/src/controllers/user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function banCheck(res: Response, user: UserData, type: number): boolean {
5454
return true;
5555
}
5656
if (user.role == -3) {
57-
res.status(403).json({error: "You are banned from uploading! Reason: " + user.ban_reason});
57+
res.status(403).json({error: "You are banned! Reason: " + user.ban_reason});
5858
return true;
5959
}
6060
return false;

src/main.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ bool CustomObjects::init(LevelEditorLayer* editorLayer) {
184184
return;
185185
}
186186
auto jsonRes = value->json().unwrapOrDefault();
187-
if (Utils::notifError(jsonRes)) return;
187+
if (!jsonRes.isObject()) return log::error("Response isn't object.");
188+
auto isError = jsonRes.get("error");
189+
if (isError.isOk()) return;
188190
auto uploadRes = jsonRes.get("uploads");
189191

190192
if (uploadRes.isOk()) {
@@ -289,11 +291,13 @@ class $modify(ProfilePage) {
289291
return;
290292
}
291293
if (value->code() != 200) {
292-
log::error("Couldn't get user: {}", value->json().unwrapOrDefault().dump());
294+
//log::error("Couldn't get user: {}", value->json().unwrapOrDefault().dump());
293295
return;
294296
}
295297
auto jsonRes = value->json().unwrapOrDefault();
296-
if (Utils::notifError(jsonRes)) return;
298+
if (!jsonRes.isObject()) return log::error("Response isn't object.");
299+
auto isError = jsonRes.get("error");
300+
if (isError.isOk()) return;
297301
if (m_fields->customObjsBtn == nullptr) {
298302
if (auto menu = typeinfo_cast<CCMenu*>(m_mainLayer->getChildByID("socials-menu"))) {
299303
m_fields->customObjsBtn = CCMenuItemExt::createSpriteExtraWithFilename("profileObjBtn.png"_spr, 0.75F,
@@ -400,3 +404,13 @@ class $modify(ProfilePage) {
400404
}
401405
}
402406
};
407+
408+
#include <Geode/modify/EditorUI.hpp>
409+
class $modify(EditorUI) {
410+
void keyDown(enumKeyCodes key) {
411+
if (auto scene = CCScene::get()) {
412+
if (typeinfo_cast<ObjectWorkshop*>(scene->getChildByID("objectworkshop"_spr))) return;
413+
}
414+
EditorUI::keyDown(key);
415+
}
416+
};

src/nodes/CategoryButton.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ class CategoryButton : public CCScale9Sprite {
1111
CCScale9Sprite* activeSideIndicator;
1212
CCScale9Sprite* inactiveSideIndicator;
1313
public:
14+
void setDisabled(bool disabled) {
15+
ccColor3B bgSprCol = {86, 48, 29};
16+
ccColor3B bgSprBehindCol = {62, 35, 20};
17+
if (disabled) {
18+
bgSprCol.r -= 20;
19+
bgSprCol.g -= 20;
20+
bgSprCol.b -= 20;
21+
bgSprBehindCol.r -= 20;
22+
bgSprBehindCol.g -= 20;
23+
bgSprBehindCol.b -= 20;
24+
}
25+
bgSpr->setColor(bgSprCol);
26+
bgSprBehind->setColor(bgSprBehindCol);
27+
}
1428
void setIndicatorState(bool enabled);
1529
static CategoryButton* create(const char* string);
1630
};

src/nodes/CommentCell.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ bool OWCommentCell::init(CommentData data, ObjectData obj, UserData user, std::f
6161
// icon,playerColor,playerColor2,playerColorGlow,glow
6262
if (auto gm = GameManager::sharedState()) {
6363
SimplePlayer* pIcon;
64-
if (m_data.icon.size() != 5) {
65-
pIcon = SimplePlayer::create(1);
64+
if (m_data.icon.size() != 5 || m_data.icon.empty()) {
65+
pIcon = SimplePlayer::create(2);
6666
} else {
6767
pIcon = SimplePlayer::create(m_data.icon[0]);
6868
pIcon->setColor(gm->colorForIdx(m_data.icon[1]));

src/nodes/ScrollLayerExt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ ScrollLayerExt* ScrollLayerExt::create(CCSize const& size, bool scroll, bool ver
170170

171171
void ScrollLayerExt::fixTouchPrio() {
172172
auto oldThis = this;
173+
//this->retain();
173174
if (auto delegate = typeinfo_cast<CCTouchDelegate*>(this)) {
174175
if (auto handler = CCTouchDispatcher::get()->findHandler(delegate)) {
175176
Loader::get()->queueInMainThread([this, handler, delegate, oldThis]() {

src/ui/ObjectWorkshop.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ bool ObjectWorkshop::setup(bool authenticated) {
9494
leftTopBar->addChildAtPosition(profileLabel, Anchor::Center, {-25, 10});
9595

9696
leftBar->addChildAtPosition(leftTopBar, Anchor::Top, {3, -7});
97-
createCategoryBtn("My Objects", 0);
98-
createCategoryBtn("Favorites", 1);
97+
createCategoryBtn("My Objects", 0, !authenticated);
98+
createCategoryBtn("Favorites", 1, !authenticated);
9999
auto vLine = CCSprite::createWithSpriteFrameName("edit_vLine_001.png");
100100
vLine->setRotation(90);
101101
leftBar->addChildAtPosition(vLine, Anchor::Center, {0, 40});
@@ -491,6 +491,7 @@ void ObjectWorkshop::RegenCategory() {
491491
cocos::handleTouchPriority(m_buttonMenu);
492492
load();
493493
});
494+
setKeyboardEnabled(true);
494495
}
495496

496497
void ObjectWorkshop::onRetryBtn(CCObject*) {
@@ -583,7 +584,7 @@ void ObjectWorkshop::load() {
583584
m_buttonMenu->addChildAtPosition(bottomPageLabel, Anchor::Bottom, {55, 17});
584585
m_scrollLayer->setTouchEnabled(true);
585586
m_amountItems = array.size();
586-
if (!m_user.authenticated || (currentMenuIndexGD != 0 && currentMenuIndexGD != -1)) {
587+
if ((currentMenuIndexGD != 0 && currentMenuIndexGD != -1)) {
587588
if (m_amountItems > 6) {
588589
categoryItems->setContentSize({
589590
categoryItems->getContentWidth(),
@@ -953,7 +954,7 @@ void ObjectWorkshop::load() {
953954
return;
954955
}
955956
if (currentMenuIndexGD < 2 || currentMenuIndexGD > 6) {
956-
if (m_user.authenticated) {
957+
if (m_user.authenticated || currentMenuIndexGD == -1) {
957958
if (currentMenuIndexGD != -1) {
958959
auto myjson = matjson::Value();
959960
myjson.set("token", m_token);
@@ -1033,6 +1034,31 @@ void ObjectWorkshop::createCategoryBtn(const char* string, int menuIndex) {
10331034
}
10341035
}
10351036

1037+
void ObjectWorkshop::createCategoryBtn(const char* string, int menuIndex, bool disabled) {
1038+
if (!disabled) return createCategoryBtn(string, menuIndex);
1039+
auto label = CCLabelBMFont::create(string, "bigFont.fnt");
1040+
label->limitLabelWidth(160.0F, 0.75F, 0.2F);
1041+
1042+
auto bgNode = CategoryButton::create(string);
1043+
bgNode->setDisabled(true);
1044+
auto btn = CCMenuItemSpriteExtra::create(
1045+
bgNode,
1046+
this,
1047+
nullptr
1048+
);
1049+
btn->setID(fmt::format("category-{}"_spr, menuIndex));
1050+
if (menuIndex < 2) {
1051+
m_buttonMenu->addChildAtPosition(
1052+
btn,
1053+
Anchor::TopLeft,
1054+
{55, (-60.F) + (-25 * menuIndex)}
1055+
);
1056+
} else {
1057+
m_categoryButtons->addChild(btn);
1058+
m_categoryButtons->updateLayout();
1059+
}
1060+
}
1061+
10361062
void ObjectWorkshop::onProfileSelf(CCObject*) {
10371063
if (!m_user.authenticated) return FLAlertLayer::create("Error", "You cannot view your profile as you are <cy>not authenticated!</c>", "OK")->show();
10381064
onClickUser(m_user.account_id);
@@ -1817,13 +1843,13 @@ void ObjectWorkshop::onClose(CCObject* sender) {
18171843
this->setKeypadEnabled(false);
18181844
this->setTouchEnabled(false);
18191845
if (!m_inEditor) {
1820-
log::debug("delete LEL!");
18211846
if (auto gameManager = GameManager::sharedState()) {
18221847
if (gameManager->m_levelEditorLayer != nullptr) {
18231848
gameManager->m_levelEditorLayer->release();
18241849
gameManager->m_levelEditorLayer = nullptr; // i LOVE dangling pointres, anyways i cant do `delete` because apparently game crashes if i close
18251850
}
18261851
gameManager->m_editorEnabled = false;
1852+
log::debug("delete LEL!");
18271853
}
18281854
}
18291855
this->removeFromParentAndCleanup(true);
@@ -1850,7 +1876,8 @@ void ObjectWorkshop::keyDown(cocos2d::enumKeyCodes key) {
18501876
return;
18511877
}
18521878
if (key == cocos2d::enumKeyCodes::KEY_Space) return;
1853-
return FLAlertLayer::keyDown(key);
1879+
//log::info("they really tried");
1880+
//return FLAlertLayer::keyDown(key);
18541881
}
18551882

18561883
void ObjectWorkshop::keyBackClicked() {

src/ui/ObjectWorkshop.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class ObjectWorkshop : public geode::Popup<bool>, public TextInputDelegate {
145145
void onReloadBtn(CCObject*);
146146
void onPendingBtn(CCObject*);
147147
void createCategoryBtn(const char* string, int menuIndex);
148+
void createCategoryBtn(const char* string, int menuIndex, bool disabled);
148149
void onSideButton(CCObject*);
149150
void showProfile(int userID, bool self);
150151
void load();

0 commit comments

Comments
 (0)