Skip to content

Commit

Permalink
status labels changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Capeling committed Jul 13, 2024
1 parent 8d0e844 commit cb18f06
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 42 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# 1.4.8

- Removed all imgui code so that wine players can use qolmod
- Fixed multiple CPS Counter bugs
- Added Total CPS option to CPS Counter
- Changed how FPS is counted, should be more accurate

# 1.4.7

Expand Down
4 changes: 3 additions & 1 deletion src/Client/ClientSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,10 @@ class ClientUtils
//replay->modules.push_back(new Module("Clicks", "status-clicks", "Shows your click count"));
replay->modules.push_back(new Module("Message", "status-message", "Write a message of your choice to be shown"));
replay->modules.push_back(new Module("Session Time", "status-session", "Shows the time you've had the game open for in the format <cg>hh::mm::ss</c>"));
replay->modules.push_back(new Module("Clicks Per Second", "status-cps", "Shows your clicks per second. Tints <cg>Green</c> while you are clicking"));
replay->modules.push_back(new Module("CPS Counter", "status-cps", "Shows your clicks per second. Tints <cg>Green</c> while you are clicking"));
//replay->modules.push_back(new StatusMessage());


Client::instance->windows.push_back(replay);

for (auto mod : replay->modules)
Expand All @@ -363,6 +364,7 @@ class ClientUtils
messageOption->allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{};:\'\",.<>/?|`~ ";
messageOption->maxSize = 48; // its just a bit before it overflows on 16:9, perfect
Client::GetModule("status-message")->options.push_back(messageOption);
Client::GetModule("status-cps")->options.push_back(new Module("Total CPS", "status-cps-total", "Shows the total clicks in the attempt"));

#ifdef STATUS_TEXTS
StatusNode::postSetup(replay);
Expand Down
68 changes: 27 additions & 41 deletions src/Labels/Labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,7 @@ void StatusNode::update(float dt)
as<NoclipPlayLayer*>(PlayLayer::get())->m_fields->isDead = false;
}

_timeLeft -= dt / CCScheduler::get()->getTimeScale();
_accum += 1 / (dt / CCScheduler::get()->getTimeScale());
_frames++;

if (_timeLeft <= 0) {
float fps = _accum / _frames;

sLabels[1]->setString((std::to_string(as<int>(roundf(fps))) + std::string(" FPS")).c_str());
//CCLOG("Average FPS: %.2f", fps);

_timeLeft = _updateInterval;
_accum = 0;
_frames = 0;
}
sLabels[1]->setString(std::to_string((int)roundf(CCDirector::sharedDirector()->m_fFrameRate)).append(" FPS").c_str());

for (size_t i = 0; i < cps.size(); i++)
{
Expand All @@ -303,7 +290,10 @@ void StatusNode::update(float dt)

cps.erase(std::remove_if(cps.begin(), cps.end(), [](float i){ return i < 0; }), cps.end());

sLabels[8]->setString((std::to_string(as<int>(cps.size())) + std::string(" CPS")).c_str());

auto cpsTotalStr = cpsM->options[1]->enabled ? "/" + std::to_string(totalCPS) : "";

sLabels[8]->setString((std::to_string(as<int>(cps.size()))).append(cpsTotalStr).append(" CPS").c_str());

updateVis();
}
Expand All @@ -313,34 +303,24 @@ void StatusNode::updateCPS(float dt)

}

class $modify (PlayerObject)
{
void pushButton(PlayerButton p0)
{
PlayerObject::pushButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get())
{
if (auto stn = StatusNode::get())
{
stn->cps.push_back(1);

stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->setColor(ccc3(0, 255, 0));
class $modify (GJBaseGameLayer) {
void handleButton(bool down, int button, bool isPlayer1) {
GJBaseGameLayer::handleButton(down, button, isPlayer1);
if (!PlayLayer::get()) return;
if (down) {
if (button == 1 && isPlayer1) {
if (auto stn = StatusNode::get()) {
stn->cps.push_back(1);
stn->totalCPS++;

stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->setColor(ccc3(0, 255, 0));
}
}
}
}

void releaseButton(PlayerButton p0)
{
PlayerObject::releaseButton(p0);

if (p0 == PlayerButton::Jump && PlayLayer::get())
{
if (auto stn = StatusNode::get())
{
} else if (button == 1 && isPlayer1) {
if (auto stn = StatusNode::get()) {
stn->sLabels[8]->stopAllActions();
stn->sLabels[8]->runAction(CCTintTo::create(1, 255, 255, 255));
stn->sLabels[8]->runAction(CCTintTo::create(0.1, 255, 255, 255));
}
}
}
Expand All @@ -362,6 +342,12 @@ class $modify (PlayLayer)

return true;
}
void resetLevel() {
PlayLayer::resetLevel();
if(auto stn = StatusNode::get()) {
stn->totalCPS = 0;
}
}
};

#endif
1 change: 1 addition & 0 deletions src/Labels/Labels.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class StatusNode : public CCNode
int _frames;

std::vector<float> cps;
int totalCPS = 0;

std::string formatTime(float time) {
// Convert float time to milliseconds
Expand Down

0 comments on commit cb18f06

Please sign in to comment.