Skip to content

Commit

Permalink
Add Android support
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Oct 1, 2023
1 parent f0a5193 commit 006c6d6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/layers/DailyViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool DailyViewLayer::init(bool isWeekly) {
auto GLM = GameLevelManager::sharedState();
auto winSize = CCDirector::sharedDirector()->getWinSize();
auto backgroundSprite = CCSprite::create("game_bg_14_001.png");
bool controllerConnected = CCApplication::sharedApplication()->getControllerConnected();
bool controllerConnected = BetterInfo::controllerConnected();

backgroundSprite->setScale(winSize.width / backgroundSprite->getContentSize().width);
backgroundSprite->setAnchorPoint({0, 0});
Expand Down
3 changes: 2 additions & 1 deletion src/layers/LeaderboardViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "JumpToPageLayer.h"
//#include "../managers/CvoltonManager.h"
#include "../managers/BetterInfoOnline.h"
#include "../utils.hpp"

LeaderboardViewLayer* LeaderboardViewLayer::create(int accountID) {
auto ret = new LeaderboardViewLayer();
Expand All @@ -24,7 +25,7 @@ bool LeaderboardViewLayer::init(int accountID) {
auto GLM = GameLevelManager::sharedState();
auto winSize = CCDirector::sharedDirector()->getWinSize();
auto backgroundSprite = CCSprite::create("game_bg_14_001.png");
bool controllerConnected = CCApplication::sharedApplication()->getControllerConnected();
bool controllerConnected = BetterInfo::controllerConnected();

backgroundSprite->setScale(winSize.width / backgroundSprite->getContentSize().width);
backgroundSprite->setAnchorPoint({0, 0});
Expand Down
2 changes: 1 addition & 1 deletion src/layers/LevelSearchViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool LevelSearchViewLayer::init(BISearchObject searchObj) {
auto GLM = GameLevelManager::sharedState();
auto winSize = CCDirector::sharedDirector()->getWinSize();
auto backgroundSprite = CCSprite::create("game_bg_14_001.png");
bool controllerConnected = CCApplication::sharedApplication()->getControllerConnected();
bool controllerConnected = BetterInfo::controllerConnected();

backgroundSprite->setScale(winSize.width / backgroundSprite->getContentSize().width);
backgroundSprite->setAnchorPoint({0, 0});
Expand Down
2 changes: 1 addition & 1 deletion src/layers/RewardViewLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool RewardViewLayer::init(CCDictionary* chests, const char* title) {
auto GSM = GameStatsManager::sharedState();
auto winSize = CCDirector::sharedDirector()->getWinSize();
auto backgroundSprite = CCSprite::create("game_bg_14_001.png");
bool controllerConnected = CCApplication::sharedApplication()->getControllerConnected();
bool controllerConnected = BetterInfo::controllerConnected();

backgroundSprite->setScale(winSize.width / backgroundSprite->getContentSize().width);
backgroundSprite->setAnchorPoint({0, 0});
Expand Down
6 changes: 5 additions & 1 deletion src/managers/BetterInfoStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ bool BetterInfoStats::init(){
if(!init) return false;

this->m_fileName = fmt::format("geode/mods/{}/CCBetterInfoStats.dat", Mod::get()->getID());
this->migrateSaveData();
#ifdef GEODE_IS_ANDROID
this->m_fileName = "CCBetterInfoStats.dat";
#else
this->migrateSaveData();
#endif

auto FU = CCFileUtils::sharedFileUtils();

Expand Down
9 changes: 9 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ std::string BetterInfo::isoTimeToString(const std::string& input) {
}

void BetterInfo::copyToClipboard(const char* text){
#ifndef GEODE_IS_ANDROID
clipboard::write(text);
#endif
}

void BetterInfo::copyToClipboard(const char* text, CCLayer* parent){
Expand Down Expand Up @@ -585,5 +587,12 @@ float BetterInfo::timeForLevelString(const std::string& levelString) {
log::error("An exception has occured while calculating time for levelString: {}", e.what());
return 0;
}
}

bool BetterInfo::controllerConnected() {
#ifdef GEODE_IS_ANDROID
return false;
#else
return CCApplication::sharedApplication()->getControllerConnected();
#endif
}
2 changes: 2 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ namespace BetterInfo {
void reloadUsernames(LevelBrowserLayer* levelBrowserLayer);

float timeForLevelString(const std::string& levelString);

bool controllerConnected();
}

0 comments on commit 006c6d6

Please sign in to comment.