Skip to content

Commit e21637a

Browse files
author
TheSillyDoggo
committed
asdcf
1 parent ceb79e8 commit e21637a

File tree

9 files changed

+119
-24
lines changed

9 files changed

+119
-24
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.7.2
2+
3+
- Fixed memory leak while playing a level
4+
15
# 1.7.1
26

37
- Fixed not being able to type decimals in label inputs

mod.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"geode": "3.8.1",
3-
"version": "v1.7.1",
3+
"version": "v1.7.2",
44
"gd": {
55
"win": "2.206",
66
"android": "2.206",
@@ -22,7 +22,8 @@
2222
"resources/*.png",
2323
"resources/*.glsl",
2424
"resources/*.hlsl",
25-
"resources/*.wav"
25+
"resources/*.wav",
26+
"resources/*.md"
2627
],
2728
"sprites": [
2829
"resources/sprites/*.png"

resources/label-help.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Variables
2+
Variables are special values that you can put in the format of your label.
3+
These are all the variables provided by QOLMod and what they do:
4+
5+
**isLevel** | If you are in the level (not the editor)
6+
**isEditor** | If you are playtesting from the editor
7+
8+
**attempt** | Current Attempt
9+
**fps** | Average Frames Per Second for the last second
10+
11+
**player1_cps** | Clicks Per Second of Player 1
12+
**player2_cps** | Clicks Per Second of Player 2
13+
**total_cps** | Both of these numbers added together
14+
15+
**player1_clicks** | Total clicks of Player 1
16+
**player2_clicks** | Total clicks of Player 2
17+
**total_clicks** | Both of these numbers added together
18+
19+
**noclip_deaths** | How many times you've died in noclip
20+
**noclip_accuracy** | How much time you've spent dead with noclip on
21+
22+
## Level Only (Shows as **null** in editor)
23+
24+
**bestRun_from** | The percentage that your best run was from
25+
**bestRun_to** | The percentage that your best run was to

src/Labels/LabelNode.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ bool LabelNode::init(LabelModule* mod)
1616

1717
std::string LabelNode::getFormatString()
1818
{
19+
return mod->format;
20+
1921
if (mod->presetType == 1)
2022
return ".";
2123

@@ -48,8 +50,21 @@ void LabelNode::update(float dt)
4850

4951
if (!script)
5052
{
53+
CC_SAFE_DELETE(script);
54+
5155
return this->setString(fmt::format("Error Compiling Script: {}", res.getMessage()).c_str());
5256
}
57+
58+
std::chrono::milliseconds duration(static_cast<long long>(ColourUtility::totalSessionTime * 1000));
59+
60+
auto hours = std::chrono::duration_cast<std::chrono::hours>(duration);
61+
duration -= hours;
62+
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(duration);
63+
duration -= minutes;
64+
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration);
65+
66+
std::time_t currentTime = std::time(nullptr);
67+
std::tm* localTime = std::localtime(&currentTime);
5368

5469
script->setVariable("attempt", rift::Value::integer(LabelLayer::get()->getAttempts()));
5570
script->setVariable("fps", rift::Value::floating(LabelLayer::get()->getFPS()));
@@ -62,21 +77,10 @@ void LabelNode::update(float dt)
6277
script->setVariable("player2_clicks", rift::Value::integer(LabelLayer::get()->getClicks(true)));
6378
script->setVariable("total_clicks", rift::Value::integer(LabelLayer::get()->getTotalClicks()));
6479

65-
std::chrono::milliseconds duration(static_cast<long long>(ColourUtility::totalSessionTime * 1000));
66-
67-
auto hours = std::chrono::duration_cast<std::chrono::hours>(duration);
68-
duration -= hours;
69-
auto minutes = std::chrono::duration_cast<std::chrono::minutes>(duration);
70-
duration -= minutes;
71-
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration);
72-
7380
script->setVariable("session_seconds", rift::Value::integer(seconds.count()));
7481
script->setVariable("session_minutes", rift::Value::integer(minutes.count()));
7582
script->setVariable("session_hours", rift::Value::integer(hours.count()));
7683

77-
std::time_t currentTime = std::time(nullptr);
78-
std::tm* localTime = std::localtime(&currentTime);
79-
8084
script->setVariable("clock_seconds", rift::Value::integer(localTime->tm_sec));
8185
script->setVariable("clock_minutes", rift::Value::integer(localTime->tm_min));
8286
script->setVariable("clock_hours", rift::Value::integer(localTime->tm_hour));
@@ -110,6 +114,8 @@ void LabelNode::update(float dt)
110114
as<CCNode*>(this->getChildren()->objectAtIndex(0))->setScale(2.25f);
111115
as<CCNode*>(this->getChildren()->objectAtIndex(0))->setAnchorPoint(ccp(0.2f, 0.35f));
112116
}
117+
118+
CC_SAFE_DELETE(script);
113119
}
114120

115121
LabelNode* LabelNode::create(LabelModule* mod)

src/Layers/BetterMDPopup.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "BetterMDPopup.hpp"
2+
3+
bool BetterMDPopup::init(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale)
4+
{
5+
if (!FLAlertLayer::init(delegate, title, desc, btn1, btn2, width, scroll, height, textScale))
6+
return false;
7+
8+
desc = utils::string::replace(desc, "\n", "\n\n");
9+
10+
m_scrollingLayer->setVisible(false);
11+
12+
auto md = MDTextArea::create(desc, ccp(365, 175));
13+
md->setPosition(CCDirector::get()->getWinSize() / 2);
14+
15+
md->setTouchEnabled(true);
16+
17+
auto content = public_cast(md, m_content);
18+
19+
for (auto child : CCArrayExt<CCNode*>(content->getChildren()))
20+
{
21+
//child->setPositionX(child->getPositionX() + content->getContentWidth() / 2);
22+
}
23+
24+
m_mainLayer->addChild(md, 69);
25+
26+
handleTouchPriority(this);
27+
28+
return true;
29+
}
30+
31+
BetterMDPopup* BetterMDPopup::create(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale)
32+
{
33+
auto pRet = new BetterMDPopup();
34+
35+
if (pRet && pRet->init(delegate, title, desc, btn1, btn2, width, scroll, height, textScale))
36+
{
37+
pRet->autorelease();
38+
return pRet;
39+
}
40+
41+
CC_SAFE_DELETE(pRet);
42+
return nullptr;
43+
}

src/Layers/BetterMDPopup.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <Geode/Geode.hpp>
4+
5+
#include "SillyBaseLayer.h"
6+
7+
using namespace geode::prelude;
8+
9+
class BetterMDPopup : public FLAlertLayer
10+
{
11+
public:
12+
bool init(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale);
13+
14+
static BetterMDPopup* create(FLAlertLayerProtocol* delegate, char const* title, gd::string desc, char const* btn1, char const* btn2, float width, bool scroll, float height, float textScale);
15+
};

src/Layers/EditLabelPopup.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "../Client/AndroidUI.h"
33
#include "ChooseFontPopup.hpp"
44
#include "../UI/LabelEventCell.hpp"
5+
#include "BetterMDPopup.hpp"
56

67
// static ButtonSprite* create(char const* caption, int width, int p2, float scale, bool absolute, char const* font, char const* bg, float height);
78
#define ANCHOR_BTN(__anchor, __text) \
@@ -265,7 +266,8 @@ void EditLabelPopup::customSetup()
265266
infoMenu = CCMenu::create();
266267
infoMenu->setPosition(CCPointZero);
267268

268-
auto formatInfo = InfoAlertButton::create("Format Label Help", "This is the format help", 0.8f);
269+
auto formatInfo = CCMenuItemSpriteExtra::create(CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png"), this, menu_selector(EditLabelPopup::onFormatInfo));
270+
formatInfo->getNormalImage()->setScale(0.8f);
269271
formatInfo->setPosition(size + ccp(-16, -16));
270272

271273
infoMenu->addChild(formatInfo);
@@ -392,6 +394,14 @@ void EditLabelPopup::updateList()
392394
err->setVisible(scroll->m_contentLayer->getChildrenCount() == 0);
393395
}
394396

397+
void EditLabelPopup::onFormatInfo(CCObject* sender)
398+
{
399+
auto res = utils::file::readString(Mod::get()->getResourcesDir() / "label-help.md");
400+
auto text = res.unwrapOr(fmt::format("Error reading file: {}", res.unwrapErr()));
401+
402+
BetterMDPopup::create(nullptr, "Label Format Help", text, "OK", nullptr, 420, true, 69, 1.0f)->show();
403+
}
404+
395405
void EditLabelPopup::onAddEvent(CCObject* sender)
396406
{
397407
if (dropdown->getSelectedIndex() == 0)

src/Layers/EditLabelPopup.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class EditLabelPopup : public SillyBaseLayer
2929
void onChangeAnchor(CCObject* sender);
3030
void onClose(CCObject* sender);
3131
void onAddEvent(CCObject* sender);
32+
void onFormatInfo(CCObject* sender);
3233

3334
void updateList();
3435

src/main.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,6 @@ class $modify (MenuLayer)
135135
if (!MenuLayer::init())
136136
return false;
137137

138-
#ifdef __APPLE__
139-
#include <OpenGL/gl.h>
140-
141-
GLint sync = 0;
142-
CGLContextObj ctx = CGLGetCurrentContext();
143-
144-
CGLSetParameter(ctx, kCGLCPSwapInterval, &sync);
145-
#endif
146-
147-
148138
if (!v)
149139
{
150140
if (Client::get()->useImGuiUI())

0 commit comments

Comments
 (0)