mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-15 22:44:42 -04:00
Mod cells now use layouts & disable macos console temporarily
This commit is contained in:
parent
3f8cdd994a
commit
114fa465a8
8 changed files with 252 additions and 174 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.3.0
|
||||
1.4.0
|
|
@ -54,6 +54,30 @@ public:
|
|||
size_t getGrow() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* A spacer node that updates the content size of its child to match its own
|
||||
* @note This is useful for making a spacer node that takes up the remaining
|
||||
* space in a layout
|
||||
*/
|
||||
class GEODE_DLL SpacerNodeChild : public SpacerNode {
|
||||
protected:
|
||||
CCNode* m_child = nullptr;
|
||||
|
||||
bool init(CCNode* child, size_t grow);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Create a new spacer node. When the layout is applied,
|
||||
* if there is space left over the remaining space is distributed among
|
||||
* all spacer nodes in proportion to the sum of all the spacers' grow
|
||||
* factors (akin to CSS flew grow)
|
||||
* @param grow The grow factor for this node. Default is 1
|
||||
*/
|
||||
static SpacerNodeChild* create(CCNode* child, size_t grow = 1);
|
||||
|
||||
void setContentSize(CCSize const& size) override;
|
||||
};
|
||||
|
||||
#pragma warning(pop)
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -177,7 +177,7 @@ struct AxisLayout::Row : public CCObject {
|
|||
this->autorelease();
|
||||
}
|
||||
|
||||
void accountSpacers(Axis axis, float availableLength) {
|
||||
void accountSpacers(Axis axis, float availableLength, float crossLength) {
|
||||
std::vector<SpacerNode*> spacers;
|
||||
for (auto& node : CCArrayExt<CCNode>(nodes)) {
|
||||
if (auto spacer = typeinfo_cast<SpacerNode*>(node)) {
|
||||
|
@ -193,10 +193,10 @@ struct AxisLayout::Row : public CCObject {
|
|||
for (auto& spacer : spacers) {
|
||||
auto size = unusedSpace * spacer->getGrow() / static_cast<float>(sum);
|
||||
if (axis == Axis::Row) {
|
||||
spacer->setContentSize({ size, this->crossLength });
|
||||
spacer->setContentSize({ size, crossLength });
|
||||
}
|
||||
else {
|
||||
spacer->setContentSize({ this->crossLength, size });
|
||||
spacer->setContentSize({ crossLength, size });
|
||||
}
|
||||
}
|
||||
this->axisLength = availableLength;
|
||||
|
@ -376,16 +376,16 @@ AxisLayout::Row* AxisLayout::fitInRow(
|
|||
}
|
||||
|
||||
// todo: make this calculation more smart to avoid so much unnecessary recursion
|
||||
auto scaleDownFactor = scale - .0125f;
|
||||
auto scaleDownFactor = scale - .002f;
|
||||
auto squishFactor = available.axisLength / (axisUnsquishedLength + .01f) * squish;
|
||||
|
||||
// calculate row scale, squish, and prio
|
||||
int tries = 1000;
|
||||
while (axisLength > available.axisLength) {
|
||||
if (this->canTryScalingDown(
|
||||
res, prio, scale, scale - .0125f, minMaxPrios
|
||||
res, prio, scale, scale - .002f, minMaxPrios
|
||||
)) {
|
||||
scale -= .0125f;
|
||||
scale -= .002f;
|
||||
}
|
||||
else {
|
||||
squish = available.axisLength / (axisUnsquishedLength + .01f) * squish;
|
||||
|
@ -643,7 +643,7 @@ void AxisLayout::tryFitLayout(
|
|||
float rowEvenSpace = available.crossLength / rows->count();
|
||||
|
||||
for (auto row : CCArrayExt<Row*>(rows)) {
|
||||
row->accountSpacers(m_axis, available.axisLength);
|
||||
row->accountSpacers(m_axis, available.axisLength, available.crossLength);
|
||||
|
||||
if (m_crossAlignment == AxisAlignment::Even) {
|
||||
rowCrossPos -= rowEvenSpace / 2 + row->crossLength / 2;
|
||||
|
@ -1053,3 +1053,34 @@ void SpacerNode::setGrow(size_t grow) {
|
|||
size_t SpacerNode::getGrow() const {
|
||||
return m_grow;
|
||||
}
|
||||
|
||||
bool SpacerNodeChild::init(CCNode* child, size_t grow) {
|
||||
if (!SpacerNode::init(grow))
|
||||
return false;
|
||||
|
||||
if (child) {
|
||||
this->addChild(child);
|
||||
m_child = child;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SpacerNodeChild* SpacerNodeChild::create(CCNode* child, size_t grow) {
|
||||
auto ret = new SpacerNodeChild;
|
||||
if (ret && ret->init(child, grow)) {
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SpacerNodeChild::setContentSize(CCSize const& size) {
|
||||
CCNode::setContentSize(size);
|
||||
if (m_child) {
|
||||
m_child->setPosition(CCPointZero);
|
||||
m_child->setContentSize(size);
|
||||
m_child->setAnchorPoint(CCPointZero);
|
||||
}
|
||||
}
|
|
@ -42,39 +42,39 @@ void Loader::Impl::logConsoleMessageWithSeverity(std::string const& msg, Severit
|
|||
void Loader::Impl::openPlatformConsole() {
|
||||
if (m_platformConsoleOpen) return;
|
||||
|
||||
std::string outFile = "/tmp/command_output_XXXXXX";
|
||||
int outFd = mkstemp(&outFile[0]);
|
||||
// std::string outFile = "/tmp/command_output_XXXXXX";
|
||||
// int outFd = mkstemp(&outFile[0]);
|
||||
|
||||
auto script = outFile + ".command";
|
||||
auto scriptContent = fmt::format(R"(
|
||||
#!/bin/sh
|
||||
echo -n -e "\033]0;Geode Console\007"
|
||||
tail -f {} &
|
||||
trap "" SIGINT
|
||||
while [ $(lsof -t {} 2>/dev/null | wc -l) -gt 1 ]; do :; done
|
||||
osascript -e 'tell application "Terminal"
|
||||
close (every window whose name contains "Geode Console")
|
||||
if (count windows) is 0 then quit
|
||||
end tell' &
|
||||
exit
|
||||
)", outFile, outFile);
|
||||
// auto script = outFile + ".command";
|
||||
// auto scriptContent = fmt::format(R"(
|
||||
// #!/bin/sh
|
||||
// echo -n -e "\033]0;Geode Console\007"
|
||||
// tail -f {} &
|
||||
// trap "" SIGINT
|
||||
// while [ $(lsof -t {} 2>/dev/null | wc -l) -gt 1 ]; do :; done
|
||||
// osascript -e 'tell application "Terminal"
|
||||
// close (every window whose name contains "Geode Console")
|
||||
// if (count windows) is 0 then quit
|
||||
// end tell' &
|
||||
// exit
|
||||
// )", outFile, outFile);
|
||||
|
||||
if (file::writeString(script, scriptContent)) {
|
||||
chmod(script.c_str(), 0777);
|
||||
dup2(outFd, 1);
|
||||
dup2(outFd, 2);
|
||||
// if (file::writeString(script, scriptContent)) {
|
||||
// chmod(script.c_str(), 0777);
|
||||
// dup2(outFd, 1);
|
||||
// dup2(outFd, 2);
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = @"/usr/bin/open";
|
||||
task.arguments = @[[NSString stringWithUTF8String:script.c_str()]];
|
||||
[task launch];
|
||||
// NSTask *task = [[NSTask alloc] init];
|
||||
// task.launchPath = @"/usr/bin/open";
|
||||
// task.arguments = @[[NSString stringWithUTF8String:script.c_str()]];
|
||||
// [task launch];
|
||||
|
||||
m_platformData = new MacConsoleData {
|
||||
outFile,
|
||||
script,
|
||||
outFd
|
||||
};
|
||||
}
|
||||
// m_platformData = new MacConsoleData {
|
||||
// outFile,
|
||||
// script,
|
||||
// outFd
|
||||
// };
|
||||
// }
|
||||
|
||||
m_platformConsoleOpen = true;
|
||||
|
||||
|
|
|
@ -79,7 +79,13 @@ CCNode* geode::createModLogo(Mod* mod, CCSize const& size) {
|
|||
if (!spr) spr = CCSprite::createWithSpriteFrameName("no-logo.png"_spr);
|
||||
if (!spr) spr = CCLabelBMFont::create("N/A", "goldFont.fnt");
|
||||
limitNodeSize(spr, size, 1.f, .1f);
|
||||
return spr;
|
||||
spr->setPosition(size/2);
|
||||
spr->setAnchorPoint({.5f, .5f});
|
||||
|
||||
auto node = CCNode::create();
|
||||
node->addChild(spr);
|
||||
node->setContentSize(size);
|
||||
return node;
|
||||
}
|
||||
|
||||
CCNode* geode::createIndexItemLogo(IndexItemHandle item, CCSize const& size) {
|
||||
|
@ -112,5 +118,11 @@ CCNode* geode::createIndexItemLogo(IndexItemHandle item, CCSize const& size) {
|
|||
else {
|
||||
limitNodeSize(spr, size, 1.f, .1f);
|
||||
}
|
||||
return spr;
|
||||
spr->setPosition(size/2);
|
||||
spr->setAnchorPoint({.5f, .5f});
|
||||
|
||||
auto node = CCNode::create();
|
||||
node->addChild(spr);
|
||||
node->setContentSize(size);
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -35,94 +35,95 @@ void ModListCell::setupInfo(
|
|||
bool inactive
|
||||
) {
|
||||
m_menu = CCMenu::create();
|
||||
m_menu->setPosition(m_width - 40.f, m_height / 2);
|
||||
m_menu->setPosition({m_width / 2, m_height / 2});
|
||||
m_menu->setContentSize({m_width - 20, m_height});
|
||||
m_menu->setAnchorPoint({.5f, .5f});
|
||||
m_menu->setLayout(
|
||||
RowLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoScale(false)
|
||||
->setCrossAxisOverflow(false)
|
||||
);
|
||||
|
||||
this->addChild(m_menu);
|
||||
|
||||
auto logoSize = this->getLogoSize();
|
||||
|
||||
auto logoSpr = this->createLogo({ logoSize, logoSize });
|
||||
logoSpr->setPosition({ logoSize / 2 + 12.f, m_height / 2 });
|
||||
auto logoSprColor = typeinfo_cast<CCRGBAProtocol*>(logoSpr);
|
||||
if (inactive && logoSprColor) {
|
||||
logoSprColor->setColor({ 163, 163, 163 });
|
||||
}
|
||||
this->addChild(logoSpr);
|
||||
m_menu->addChild(logoSpr);
|
||||
|
||||
m_columnMenu = CCMenu::create();
|
||||
m_columnMenu->setContentSize({m_width, m_height});
|
||||
m_columnMenu->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Center)
|
||||
->setCrossAxisLineAlignment(AxisAlignment::Start)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setGap(spaceForTags ? 3.f : 5.f)
|
||||
);
|
||||
m_menu->addChild(SpacerNodeChild::create(m_columnMenu));
|
||||
|
||||
m_labelMenu = CCMenu::create();
|
||||
m_labelMenu->setContentSize({m_width, m_height / 2});
|
||||
m_labelMenu->setLayout(
|
||||
RowLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoScale(false)
|
||||
);
|
||||
m_labelMenu->setLayoutOptions(
|
||||
AxisLayoutOptions::create()
|
||||
->setNextGap(spaceForTags ? -2.f : 0.f)
|
||||
->setPrevGap(0.f)
|
||||
);
|
||||
m_columnMenu->addChild(m_labelMenu);
|
||||
|
||||
bool hasDesc =
|
||||
display == ModListDisplay::Expanded &&
|
||||
metadata.getDescription().has_value();
|
||||
|
||||
auto titleLabel = CCLabelBMFont::create(metadata.getName().c_str(), "bigFont.fnt");
|
||||
titleLabel->setAnchorPoint({ .0f, .5f });
|
||||
titleLabel->setPositionX(m_height / 2 + logoSize / 2 + 13.f);
|
||||
if (hasDesc && spaceForTags) {
|
||||
titleLabel->setPositionY(m_height / 2 + 20.f);
|
||||
}
|
||||
else if (spaceForTags) {
|
||||
titleLabel->setPositionY(m_height / 2 + 12.f);
|
||||
}
|
||||
else if (hasDesc) {
|
||||
titleLabel->setPositionY(m_height / 2 + 15.f);
|
||||
}
|
||||
else {
|
||||
titleLabel->setPositionY(m_height / 2 + 7.f);
|
||||
}
|
||||
titleLabel->limitLabelWidth(m_width / 2 - 40.f, .5f, .1f);
|
||||
titleLabel->setLayoutOptions(
|
||||
AxisLayoutOptions::create()
|
||||
->setAutoScale(true)
|
||||
->setMaxScale(0.5f)
|
||||
->setMinScale(0.1f)
|
||||
);
|
||||
if (inactive) {
|
||||
titleLabel->setColor({ 163, 163, 163 });
|
||||
}
|
||||
this->addChild(titleLabel);
|
||||
m_labelMenu->addChild(titleLabel);
|
||||
|
||||
auto versionLabel = CCLabelBMFont::create(
|
||||
metadata.getVersion().toString(false).c_str(),
|
||||
"bigFont.fnt"
|
||||
);
|
||||
versionLabel->setAnchorPoint({ .0f, .5f });
|
||||
versionLabel->setScale(.3f);
|
||||
versionLabel->setPosition(
|
||||
titleLabel->getPositionX() + titleLabel->getScaledContentSize().width + 5.f,
|
||||
titleLabel->getPositionY() - 1.f
|
||||
);
|
||||
versionLabel->setColor({ 0, 255, 0 });
|
||||
if (inactive) {
|
||||
versionLabel->setColor({ 0, 163, 0 });
|
||||
}
|
||||
this->addChild(versionLabel);
|
||||
m_labelMenu->addChild(versionLabel);
|
||||
|
||||
TagNode* apiLabel = nullptr;
|
||||
if (metadata.isAPI()) {
|
||||
apiLabel = TagNode::create("API");
|
||||
apiLabel->setAnchorPoint({ .0f, .5f });
|
||||
apiLabel->setScale(.3f);
|
||||
apiLabel->setPosition(
|
||||
versionLabel->getPositionX() +
|
||||
versionLabel->getScaledContentSize().width + 5.f,
|
||||
versionLabel->getPositionY()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (auto tag = metadata.getVersion().getTag()) {
|
||||
auto tagLabel = TagNode::create(tag.value().toString().c_str());
|
||||
tagLabel->setAnchorPoint({ .0f, .5f });
|
||||
tagLabel->setScale(.3f);
|
||||
tagLabel->setPosition(
|
||||
versionLabel->getPositionX() +
|
||||
versionLabel->getScaledContentSize().width + 5.f,
|
||||
versionLabel->getPositionY()
|
||||
);
|
||||
this->addChild(tagLabel);
|
||||
|
||||
if (apiLabel) {
|
||||
apiLabel->setPosition(
|
||||
tagLabel->getPositionX() +
|
||||
tagLabel->getScaledContentSize().width + 5.f,
|
||||
tagLabel->getPositionY()
|
||||
);
|
||||
}
|
||||
m_labelMenu->addChild(tagLabel);
|
||||
}
|
||||
|
||||
if (apiLabel)
|
||||
this->addChild(apiLabel);
|
||||
if (metadata.isAPI()) {
|
||||
apiLabel = TagNode::create("API");
|
||||
apiLabel->setScale(.3f);
|
||||
m_labelMenu->addChild(apiLabel);
|
||||
}
|
||||
|
||||
auto creatorStr = "by " + metadata.getDeveloper();
|
||||
auto creatorLabel = CCLabelBMFont::create(creatorStr.c_str(), "goldFont.fnt");
|
||||
|
@ -134,47 +135,42 @@ void ModListCell::setupInfo(
|
|||
m_developerBtn = CCMenuItemSpriteExtra::create(
|
||||
creatorLabel, this, menu_selector(ModListCell::onViewDev)
|
||||
);
|
||||
m_developerBtn->setPositionX(
|
||||
m_height / 2 + logoSize / 2 + 13.f
|
||||
+ creatorLabel->getScaledContentSize().width / 2
|
||||
- m_menu->getPositionX()
|
||||
);
|
||||
if (hasDesc && spaceForTags) {
|
||||
m_developerBtn->setPositionY(+7.5f);
|
||||
}
|
||||
else if (hasDesc || spaceForTags) {
|
||||
m_developerBtn->setPositionY(0.f);
|
||||
}
|
||||
else {
|
||||
m_developerBtn->setPositionY(-7.f);
|
||||
}
|
||||
m_menu->addChild(m_developerBtn);
|
||||
m_columnMenu->addChild(m_developerBtn);
|
||||
|
||||
if (hasDesc) {
|
||||
auto descBG = CCScale9Sprite::create("square02b_001.png", {0.0f, 0.0f, 80.0f, 80.0f});
|
||||
descBG->setColor({0, 0, 0});
|
||||
descBG->setOpacity(90);
|
||||
descBG->setContentSize({m_width * 2, 60.f});
|
||||
descBG->setAnchorPoint({.0f, .5f});
|
||||
descBG->setPositionX(m_height / 2 + logoSize / 2 + 13.f);
|
||||
if (spaceForTags) {
|
||||
descBG->setPositionY(m_height / 2 - 7.5f);
|
||||
}
|
||||
else {
|
||||
descBG->setPositionY(m_height / 2 - 17.f);
|
||||
}
|
||||
descBG->setScale(.25f);
|
||||
this->addChild(descBG);
|
||||
m_columnMenu->addChild(descBG);
|
||||
|
||||
// limitLabelWidth defaults to 1.0 even though we give a bigger scale
|
||||
auto node = CCNode::create();
|
||||
node->setContentSize(descBG->getContentSize() / 4);
|
||||
node->setAnchorPoint({ .5f, .5f });
|
||||
node->setScale(4.f);
|
||||
node->setPosition(descBG->getContentSize() / 2);
|
||||
descBG->addChild(node);
|
||||
|
||||
m_description = CCLabelBMFont::create(metadata.getDescription().value().c_str(), "chatFont.fnt");
|
||||
m_description->setAnchorPoint({ .0f, .5f });
|
||||
m_description->setPosition(m_height / 2 + logoSize / 2 + 18.f, descBG->getPositionY());
|
||||
m_description->limitLabelWidth(m_width / 2 - 10.f, .5f, .1f);
|
||||
m_description->setAnchorPoint({ .5f, .5f });
|
||||
m_description->setPosition(node->getContentSize() / 2);
|
||||
m_description->limitLabelWidth(node->getContentSize().width - 5.f, 0.5f, .1f);
|
||||
if (inactive) {
|
||||
m_description->setColor({ 163, 163, 163 });
|
||||
}
|
||||
this->addChild(m_description);
|
||||
node->addChild(m_description);
|
||||
}
|
||||
|
||||
this->updateCellLayout();
|
||||
}
|
||||
|
||||
void ModListCell::updateCellLayout() {
|
||||
m_menu->updateLayout();
|
||||
m_labelMenu->setContentSize(m_columnMenu->getContentSize());
|
||||
m_labelMenu->updateLayout();
|
||||
m_columnMenu->updateLayout();
|
||||
}
|
||||
|
||||
void ModListCell::onViewDev(CCObject*) {
|
||||
|
@ -262,6 +258,8 @@ void ModCell::updateState() {
|
|||
break;
|
||||
}
|
||||
m_unresolvedExMark->setVisible(hasProblems);
|
||||
|
||||
this->updateCellLayout();
|
||||
}
|
||||
|
||||
bool ModCell::init(
|
||||
|
@ -276,15 +274,28 @@ bool ModCell::init(
|
|||
|
||||
this->setupInfo(mod->getMetadata(), false, display, mod->getRequestedAction() != ModRequestedAction::None);
|
||||
|
||||
auto exMark = CCSprite::createWithSpriteFrameName("exMark_001.png");
|
||||
exMark->setScale(.5f);
|
||||
|
||||
m_unresolvedExMark =
|
||||
CCMenuItemSpriteExtra::create(exMark, this, menu_selector(ModCell::onUnresolvedInfo));
|
||||
m_unresolvedExMark->setVisible(false);
|
||||
m_menu->addChild(m_unresolvedExMark);
|
||||
|
||||
if (mod->getRequestedAction() != ModRequestedAction::None) {
|
||||
auto restartSpr = ButtonSprite::create("Restart", "bigFont.fnt", "GJ_button_03.png", .8f);
|
||||
restartSpr->setScale(.65f);
|
||||
|
||||
auto restartBtn = CCMenuItemSpriteExtra::create(restartSpr, this, menu_selector(ModCell::onRestart));
|
||||
restartBtn->setPositionX(-16.f);
|
||||
m_menu->addChild(restartBtn);
|
||||
}
|
||||
else {
|
||||
if (m_mod->wasSuccessfullyLoaded() && m_mod->getMetadata().getID() != "geode.loader") {
|
||||
m_enableToggle =
|
||||
CCMenuItemToggler::createWithStandardSprites(this, menu_selector(ModCell::onEnable), .7f);
|
||||
m_menu->addChild(m_enableToggle);
|
||||
}
|
||||
|
||||
auto viewSpr = ButtonSprite::create("View", "bigFont.fnt", "GJ_button_01.png", .8f);
|
||||
viewSpr->setScale(.65f);
|
||||
|
||||
|
@ -306,33 +317,14 @@ bool ModCell::init(
|
|||
|
||||
if (latestIndexItem->getMetadata().getVersion().getMajor() > minorIndexItem->getMetadata().getVersion().getMajor()) {
|
||||
auto updateIcon = CCSprite::createWithSpriteFrameName("updates-available.png"_spr);
|
||||
updateIcon->setPosition(viewSpr->getContentSize() - CCSize { 2.f, 2.f });
|
||||
updateIcon->setZOrder(99);
|
||||
updateIcon->setScale(.5f);
|
||||
viewSpr->addChild(updateIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mod->wasSuccessfullyLoaded() && m_mod->getMetadata().getID() != "geode.loader") {
|
||||
m_enableToggle =
|
||||
CCMenuItemToggler::createWithStandardSprites(this, menu_selector(ModCell::onEnable), .7f);
|
||||
m_enableToggle->setPosition(-45.f, 0.f);
|
||||
m_menu->addChild(m_enableToggle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto exMark = CCSprite::createWithSpriteFrameName("exMark_001.png");
|
||||
exMark->setScale(.5f);
|
||||
|
||||
m_unresolvedExMark =
|
||||
CCMenuItemSpriteExtra::create(exMark, this, menu_selector(ModCell::onUnresolvedInfo));
|
||||
m_unresolvedExMark->setPosition(-80.f, 0.f);
|
||||
m_unresolvedExMark->setVisible(false);
|
||||
m_menu->addChild(m_unresolvedExMark);
|
||||
|
||||
this->updateState();
|
||||
|
||||
return true;
|
||||
|
@ -390,7 +382,6 @@ bool IndexItemCell::init(
|
|||
restartSpr->setScale(.65f);
|
||||
|
||||
auto restartBtn = CCMenuItemSpriteExtra::create(restartSpr, this, menu_selector(IndexItemCell::onRestart));
|
||||
restartBtn->setPositionX(-16.f);
|
||||
m_menu->addChild(restartBtn);
|
||||
}
|
||||
else {
|
||||
|
@ -403,22 +394,21 @@ bool IndexItemCell::init(
|
|||
}
|
||||
|
||||
if (item->getTags().size()) {
|
||||
float x = m_height / 2 + this->getLogoSize() / 2 + 13.f;
|
||||
auto tagRow = CCNode::create();
|
||||
tagRow->setContentSize({m_width, m_height});
|
||||
tagRow->setLayout(
|
||||
RowLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoScale(false)
|
||||
->setGap(3.f)
|
||||
);
|
||||
m_columnMenu->insertAfter(tagRow, m_developerBtn);
|
||||
for (auto& category : item->getTags()) {
|
||||
auto node = TagNode::create(category);
|
||||
node->setAnchorPoint({ .0f, .5f });
|
||||
node->setPositionX(x);
|
||||
node->setScale(.3f);
|
||||
if (m_description) {
|
||||
node->setPositionY(m_height / 2 - 23.f);
|
||||
}
|
||||
else {
|
||||
node->setPositionY(m_height / 2 - 12.f);
|
||||
}
|
||||
this->addChild(node);
|
||||
|
||||
x += node->getScaledContentSize().width + 5.f;
|
||||
tagRow->addChild(node);
|
||||
}
|
||||
tagRow->updateLayout();
|
||||
}
|
||||
|
||||
this->updateState();
|
||||
|
@ -426,7 +416,9 @@ bool IndexItemCell::init(
|
|||
return true;
|
||||
}
|
||||
|
||||
void IndexItemCell::updateState() {}
|
||||
void IndexItemCell::updateState() {
|
||||
this->updateCellLayout();
|
||||
}
|
||||
|
||||
std::string IndexItemCell::getDeveloper() const {
|
||||
return m_item->getMetadata().getDeveloper();
|
||||
|
@ -595,7 +587,15 @@ bool ProblemsCell::init(
|
|||
}
|
||||
|
||||
m_menu = CCMenu::create();
|
||||
m_menu->setPosition(m_width - 40.f, m_height / 2);
|
||||
m_menu->setPosition({m_width / 2, m_height / 2});
|
||||
m_menu->setContentSize({m_width - 20, m_height});
|
||||
m_menu->setAnchorPoint({.5f, .5f});
|
||||
m_menu->setLayout(
|
||||
RowLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
// ->setAutoScale(false)
|
||||
->setCrossAxisOverflow(false)
|
||||
);
|
||||
this->addChild(m_menu);
|
||||
|
||||
auto logoSize = this->getLogoSize();
|
||||
|
@ -603,15 +603,19 @@ bool ProblemsCell::init(
|
|||
if (!icon.empty()) {
|
||||
auto logoSpr = CCSprite::createWithSpriteFrameName(icon.c_str());
|
||||
limitNodeSize(logoSpr, size, 1.f, .1f);
|
||||
logoSpr->setPosition({logoSize / 2 + 12.f, m_height / 2});
|
||||
this->addChild(logoSpr);
|
||||
m_menu->addChild(logoSpr);
|
||||
}
|
||||
|
||||
auto titleLabel = CCLabelBMFont::create(title.c_str(), "bigFont.fnt");
|
||||
titleLabel->setAnchorPoint({ .0f, .5f });
|
||||
titleLabel->setPosition(m_height / 2 + logoSize / 2 + 13.f, m_height / 2);
|
||||
titleLabel->limitLabelWidth(m_width - 120.f, 1.f, .1f);
|
||||
this->addChild(titleLabel);
|
||||
titleLabel->setLayoutOptions(
|
||||
AxisLayoutOptions::create()
|
||||
->setScalePriority(1)
|
||||
->setMaxScale(1.f)
|
||||
->setMinScale(0.1f)
|
||||
);
|
||||
m_menu->addChild(titleLabel);
|
||||
|
||||
// m_menu->addChild(SpacerNode::create());
|
||||
|
||||
auto viewSpr = ButtonSprite::create("View", "bigFont.fnt", "GJ_button_01.png", .8f);
|
||||
viewSpr->setScale(.65f);
|
||||
|
@ -620,6 +624,8 @@ bool ProblemsCell::init(
|
|||
CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ProblemsCell::onInfo));
|
||||
m_menu->addChild(viewBtn);
|
||||
|
||||
m_menu->updateLayout();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@ protected:
|
|||
CCMenuItemToggler* m_enableToggle = nullptr;
|
||||
CCMenuItemSpriteExtra* m_unresolvedExMark;
|
||||
CCMenuItemSpriteExtra* m_developerBtn;
|
||||
SpacerNode* m_spacer = nullptr;
|
||||
CCMenu* m_columnMenu = nullptr;
|
||||
CCMenu* m_labelMenu = nullptr;
|
||||
|
||||
bool init(ModListLayer* list, CCSize const& size);
|
||||
void setupInfo(ModMetadata const& metadata, bool spaceForTags, ModListDisplay display, bool inactive);
|
||||
|
@ -32,6 +35,8 @@ protected:
|
|||
float getLogoSize() const;
|
||||
void onViewDev(CCObject*);
|
||||
|
||||
void updateCellLayout();
|
||||
|
||||
public:
|
||||
virtual void updateState() = 0;
|
||||
virtual CCNode* createLogo(CCSize const& size) = 0;
|
||||
|
|
|
@ -343,28 +343,28 @@ bool ModListLayer::init() {
|
|||
m_menu->addChild(m_featuredTabBtn);
|
||||
|
||||
// tabs gradient
|
||||
m_tabsGradientNode = CCClippingNode::create();
|
||||
m_tabsGradientNode->setContentSize(this->getContentSize());
|
||||
m_tabsGradientNode->setAnchorPoint({0.5f, 0.5f});
|
||||
m_tabsGradientNode->ignoreAnchorPointForPosition(true);
|
||||
m_tabsGradientNode->setZOrder(9);
|
||||
m_tabsGradientNode->setInverted(false);
|
||||
m_tabsGradientNode->setAlphaThreshold(0.f);
|
||||
// m_tabsGradientNode = CCClippingNode::create();
|
||||
// m_tabsGradientNode->setContentSize(this->getContentSize());
|
||||
// m_tabsGradientNode->setAnchorPoint({0.5f, 0.5f});
|
||||
// m_tabsGradientNode->ignoreAnchorPointForPosition(true);
|
||||
// m_tabsGradientNode->setZOrder(9);
|
||||
// m_tabsGradientNode->setInverted(false);
|
||||
// m_tabsGradientNode->setAlphaThreshold(0.f);
|
||||
|
||||
m_tabsGradientSprite = CCSprite::create("tab-gradient.png"_spr);
|
||||
m_tabsGradientNode->addChild(m_tabsGradientSprite);
|
||||
// m_tabsGradientSprite = CCSprite::create("tab-gradient.png"_spr);
|
||||
// m_tabsGradientNode->addChild(m_tabsGradientSprite);
|
||||
|
||||
m_tabsGradientStencil = CCSprite::create("tab-gradient-mask.png"_spr);
|
||||
m_tabsGradientStencil->setAnchorPoint({0.f, 0.f});
|
||||
m_tabsGradientNode->setStencil(m_tabsGradientStencil);
|
||||
// m_tabsGradientStencil = CCSprite::create("tab-gradient-mask.png"_spr);
|
||||
// m_tabsGradientStencil->setAnchorPoint({0.f, 0.f});
|
||||
// m_tabsGradientNode->setStencil(m_tabsGradientStencil);
|
||||
|
||||
// add menus
|
||||
m_menu->setZOrder(0);
|
||||
m_topMenu->setZOrder(10);
|
||||
|
||||
this->addChild(m_menu);
|
||||
this->addChild(m_tabsGradientNode);
|
||||
this->addChild(m_tabsGradientStencil);
|
||||
// this->addChild(m_tabsGradientNode);
|
||||
// this->addChild(m_tabsGradientStencil);
|
||||
this->addChild(m_topMenu);
|
||||
|
||||
// select first tab
|
||||
|
@ -646,7 +646,7 @@ void ModListLayer::onExpand(CCObject* sender) {
|
|||
m_display = static_cast<CCMenuItemToggler*>(sender)->isToggled() ?
|
||||
ModListDisplay::Concise :
|
||||
ModListDisplay::Expanded;
|
||||
this->reloadList();
|
||||
this->reloadList(false);
|
||||
}
|
||||
|
||||
void ModListLayer::onFilters(CCObject*) {
|
||||
|
|
Loading…
Add table
Reference in a new issue