Skip to content

Commit

Permalink
Fix some stuff for android support
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Feb 4, 2024
1 parent 31ae636 commit ab263f1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/layers/PlayLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class $modify(PlayLayerPause, PlayLayer)
!this->m_isPracticeMode &&
percentage >= RouletteManager.levelPercentageGoal
) {
if (delta > .2f && !this->m_player1->m_isDead)
if (delta > .2f/* && !this->m_player1->m_isDead*/)
{
RouletteManager.hasFinishedPreviousLevel = true;
RouletteManager.lastLevelPercentage = percentage;
Expand Down
8 changes: 4 additions & 4 deletions src/listfetcher/ListFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <matjson.hpp>

#include <random>
#include <format>
#include "ListFetcher.hpp"
#include "../utils.hpp"

Expand All @@ -22,8 +21,9 @@ void ListFetcher::getRandomNormalListLevel(int stars, matjson::Value& json)

isFetching = true;

std::string link = std::format(
"https://gdbrowser.com/api/search/*?diff={}&starred&page={}", stars, roulette::utils::randomInt(1, m_normalListMaxPage[stars - 1])
std::string link = fmt::format(
"https://gdbrowser.com/api/search/*?diff={}&starred&page={}",
stars, roulette::utils::randomInt(1, m_normalListMaxPage[stars - 1])
);

web::AsyncWebRequest()
Expand Down Expand Up @@ -125,7 +125,7 @@ void ListFetcher::getRandomChallengeListLevel(matjson::Value& json)

void ListFetcher::getLevelInfo(int levelID, matjson::Value& json)
{
std::string link = std::format("https://gdbrowser.com/api/search/{}", levelID);
std::string link = fmt::format("https://gdbrowser.com/api/search/{}", levelID);

web::AsyncWebRequest()
.get(link)
Expand Down
4 changes: 2 additions & 2 deletions src/roulette/layers/RouletteLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void RouletteLayer::onLevelInfo(CCObject* sender)
break;
}

roulette::utils::setClipboardText(text.c_str());
clipboard::write(text);
// this->addChild(TextAlertPopup::create("Copied to Clipboard", .5f, .6f, 1, "bigFont.fnt"));
Notification::create("Copied to Clipboard", NotificationIcon::Success)->show();
}
Expand Down Expand Up @@ -591,7 +591,7 @@ void RouletteLayer::onNextButton(CCObject*)
// ), 1.2f, .8f, 1, "bigFont.fnt"
// ));
Notification::create(
std::format(
fmt::format(
"You need to get at least {}%!", static_cast<int>(RouletteManager.levelPercentageGoal)
),
NotificationIcon::Error
Expand Down
24 changes: 0 additions & 24 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ namespace roulette::utils
return distribution(generator);
}

inline void setClipboardText(std::string text)
{
if (OpenClipboard(0))
{
HGLOBAL clipbuffer;
char* buffer;
EmptyClipboard();

clipbuffer = GlobalAlloc(GMEM_DDESHARE, text.size() + 1);
if (clipbuffer)
{
buffer = static_cast<char*>(GlobalLock(clipbuffer));
if (buffer)
{
strcpy(buffer, text.c_str());
GlobalUnlock(clipbuffer);
SetClipboardData(CF_TEXT, clipbuffer);
}
}

CloseClipboard();
}
}

template<typename T>
inline std::ptrdiff_t getIndexOf(const std::vector<matjson::Value>& vec, T to_find)
{
Expand Down

0 comments on commit ab263f1

Please sign in to comment.