Skip to content

Commit

Permalink
add treasure room stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jan 5, 2024
1 parent 712d104 commit f0b6cb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 14 additions & 11 deletions src/layers/RewardHistory/RewardCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@ void RewardCell::loadFromData(CCObject* object) {

const char* chestTexture = "chest_01_02_001.png";
float chestSize = 0.35f;
const char* chestTitle = Mod::get()->getSavedValue<std::string>("reward-cell-title").c_str();
switch(reward->m_rewardType) {
default: break;
case GJRewardType::Small: chestTexture = "chest_01_02_001.png"; break;
case GJRewardType::Large: chestTexture = "chest_02_02_001.png"; chestSize = 0.275f; break;
case GJRewardType::SmallTreasure: chestTexture = "chest_03_02_001.png"; chestSize = 0.275f; break;
case GJRewardType::LargeTreasure: chestTexture = "chest_04_02_001.png"; chestSize = 0.275f; break;
case GJRewardType::SmallTreasure: chestTexture = "chest_03_02_001.png"; chestSize = 0.275f; chestTitle = "1 Key"; break;
case GJRewardType::LargeTreasure: chestTexture = "chest_04_02_001.png"; chestSize = 0.275f; chestTitle = "5 Key"; break;
case GJRewardType::Key10Treasure: chestTexture = "chest_05_02_001.png"; chestSize = 0.275f; chestTitle = "10 Key"; break;
case GJRewardType::Key25Treasure: chestTexture = "chest_06_02_001.png"; chestSize = 0.275f; chestTitle = "25 Key"; break;
case GJRewardType::Key50Treasure: chestTexture = "chest_07_02_001.png"; chestSize = 0.275f; chestTitle = "50 Key"; break;
case GJRewardType::Key100Treasure: chestTexture = "chest_08_02_001.png"; chestSize = 0.275f; chestTitle = "100 Key"; break;
}
CCSprite* chest = CCSprite::createWithSpriteFrameName(chestTexture);
chest->setPosition({25, 22});
chest->setScale(chestSize);
this->m_mainLayer->addChild(chest);

auto title = CCLabelBMFont::create(CCString::createWithFormat(reward->m_chestID != 0 ? "%s Chest %i" : "%s Chest", Mod::get()->getSavedValue<std::string>("reward-cell-title").c_str(), reward->m_chestID)->getCString(), "bigFont.fnt");
auto title = CCLabelBMFont::create(CCString::createWithFormat(reward->m_chestID != 0 ? "%s Chest %i" : "%s Chest", chestTitle, reward->m_chestID)->getCString(), "bigFont.fnt");
title->setAnchorPoint({ 0.0f, .5f });
title->setPosition(rowX, 31.5f);
title->limitLabelWidth(356-rowX, .65f, .4f);
Expand All @@ -45,13 +50,17 @@ void RewardCell::loadFromData(CCObject* object) {
case SpecialRewardItem::Orbs: textureName = "currencyOrbIcon_001.png"; scale = .7f; break;
case SpecialRewardItem::Diamonds: textureName = "diamond_small01_001.png"; break;
case SpecialRewardItem::CustomItem: textureName = "collaborationIcon_001.png"; scale = .5f; break;
case SpecialRewardItem::EarthShard: textureName = "shard0201ShardSmall_001.png"; break;
case SpecialRewardItem::BloodShard: textureName = "shard0202ShardSmall_001.png"; break;
case SpecialRewardItem::MetalShard: textureName = "shard0203ShardSmall_001.png"; break;
case SpecialRewardItem::LightShard: textureName = "shard0204ShardSmall_001.png"; break;
case SpecialRewardItem::SoulShard: textureName = "shard0205ShardSmall_001.png"; break;
default: scale = 0.7f;
}

lastSprite = CCSprite::createWithSpriteFrameName(textureName);
if(rewardObj->m_specialRewardItem == SpecialRewardItem::CustomItem) {
//TODO: reverse GJItemIcon
//lastSprite = GJItemIcon::createBrowserIcon(rewardObj->m_unlockType, rewardObj->m_itemID);
lastSprite = GJItemIcon::createBrowserItem(rewardObj->m_unlockType, rewardObj->m_itemID);
}
if(lastText == nullptr) lastSprite->setPosition({rowX + 1, rowY});
else lastSprite->setPosition({lastText->getPositionX() + (lastText->getContentSize().width * lastText->getScaleX()) + 11.f, rowY});
Expand All @@ -70,12 +79,6 @@ void RewardCell::loadFromData(CCObject* object) {
this->m_backgroundLayer->setOpacity(255);
}

void RewardCell::draw() {
// just call StatsCell::draw, no one will notice
// this is stolen from betteredit blame fod
reinterpret_cast<StatsCell*>(this)->StatsCell::draw();
}

RewardCell::RewardCell(const char* name, CCSize size) :
GenericListCell(name, size) {}

Expand Down
2 changes: 0 additions & 2 deletions src/layers/RewardHistory/RewardCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using namespace geode::prelude;

class RewardCell : public GenericListCell {
void draw();

public:
RewardCell(const char* name, cocos2d::CCSize size);
void loadFromData(CCObject* object);
Expand Down

0 comments on commit f0b6cb3

Please sign in to comment.