Skip to content

Commit

Permalink
- fixing 10fps cap in console mode
Browse files Browse the repository at this point in the history
- fixing tid display
  • Loading branch information
nadrino committed May 7, 2023
1 parent 91d5931 commit dd7d4ec
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
#include "thread"


// test
struct FpsCap{
explicit FpsCap(double fps_) : createDate(std::chrono::system_clock::now()), fpsMax(1/fps_) {}
~FpsCap(){
auto timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - createDate);
std::this_thread::sleep_for(fpsMax - timeDiff);
}

std::chrono::system_clock::time_point createDate;
std::chrono::duration<double> fpsMax;
};


// MAIN
int main( int argc, char **argv ){
consoleInit(nullptr);
Expand Down
15 changes: 13 additions & 2 deletions src/ModManagerCore/include/ConsoleHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@

namespace ConsoleHandler{

struct FpsCap{
explicit FpsCap(double fps_) : createDate(std::chrono::system_clock::now()), fpsMax(1/fps_) {}
~FpsCap(){
auto timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now() - createDate);
std::this_thread::sleep_for(fpsMax - timeDiff);
}

std::chrono::system_clock::time_point createDate;
std::chrono::duration<double> fpsMax;
};

void upgradeFrom150(){
std::string oldPath = GenericToolbox::getCurrentWorkingDirectory() + "/parameters.ini"; // before 1.5.0
if(GenericToolbox::doesPathIsFile(oldPath)){
Expand Down Expand Up @@ -73,7 +84,7 @@ namespace ConsoleHandler{
// Main loop
u64 kDown, kHeld;
while( appletMainLoop() ) {
// FpsCap fpsGuard(120);
FpsCap fpsGuard(30);

//Scan all the inputs. This should be done once for each frame
padUpdate( &pad );
Expand All @@ -99,7 +110,7 @@ namespace ConsoleHandler{
gameBrowser.printTerminal();
std::cout << std::flush;

std::this_thread::sleep_for(std::chrono::milliseconds(100));
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
} // while
}

Expand Down
26 changes: 0 additions & 26 deletions src/ModManagerGui/CoreExtension/include/GuiUtils.h

This file was deleted.

10 changes: 5 additions & 5 deletions src/ModManagerGui/FrameGameBrowser/src/TabGames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <GlobalObjects.h>
#include <FrameModBrowser.h>
#include "FrameRoot.h"
#include "GuiUtils.h"

#include "Logger.h"
#include "GenericToolbox.Switch.h"
Expand Down Expand Up @@ -48,14 +47,15 @@ TabGames::TabGames(FrameRoot* owner_) : _owner_(owner_) {
LogScopeIndent;
LogInfo << "Adding game folder: \"" << gameEntry.title << "\"" << std::endl;

int nMods = int( GenericToolbox::getListOfSubFoldersInFolder(
this->getConfig().baseFolder + "/" + gameEntry.title
).size() );
std::string gamePath{GenericToolbox::joinPath(this->getConfig().baseFolder, gameEntry.title)};
int nMods = int( GenericToolbox::getListOfSubFoldersInFolder(gamePath).size() );

// memory allocation
auto* item = new brls::ListItem(gameEntry.title, "", std::to_string(nMods) + " mod(s) available.");

auto* icon = ModManagerUtils::getFolderIcon( this->getConfig().baseFolder + "/" + gameEntry.title );
// looking for tid is quite slow... Slows down the boot up
std::string _titleId_{ GenericToolbox::Switch::Utils::lookForTidInSubFolders(gamePath) };
auto* icon = GenericToolbox::Switch::Utils::getIconFromTitleId(_titleId_);
if(icon != nullptr){ item->setThumbnail(icon, 0x20000); }
item->getClickEvent()->subscribe([&, gameEntry](View* view) {
LogWarning << "Opening \"" << gameEntry.title << "\"" << std::endl;
Expand Down
7 changes: 2 additions & 5 deletions src/ModManagerGui/FrameModBrowser/src/FrameModBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <TabModPresets.h>
#include <TabModOptions.h>

#include "GuiUtils.h"

#include "GenericToolbox.Switch.h"
#include "Logger.h"

Expand All @@ -27,9 +25,8 @@ FrameModBrowser::FrameModBrowser(GuiModManager* guiModManagerPtr_) : _guiModMana

std::string gamePath = getGameBrowser().getModManager().getGameFolderPath();


_titleId_ = GenericToolbox::Switch::Utils::lookForTidInSubFolders( gamePath );
_icon_ = ModManagerUtils::getFolderIcon( getGameBrowser().getModManager().getGameFolderPath() );
_titleId_ = GenericToolbox::Switch::Utils::lookForTidInSubFolders( gamePath, 5);
_icon_ = GenericToolbox::Switch::Utils::getIconFromTitleId( _titleId_ );
if(_icon_ != nullptr){ this->setIcon(_icon_, 0x20000); }
else{ this->setIcon("romfs:/images/icon_corner.png"); }

Expand Down
10 changes: 7 additions & 3 deletions src/ModManagerGui/FrameModBrowser/src/TabModOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,19 @@ void TabModOptions::buildGameIdentificationItem(){
_itemGameIdentification_ = new brls::ListItem(
"Associated TitleID",
"",
"Current value :"
"Current value: "
);

if( _owner_->getIcon() != nullptr ){
_itemGameIdentification_->setValue( _owner_->getTitleId() );
_itemGameIdentification_->setThumbnail( _owner_->getIcon(), 0x20000 );
_itemGameIdentification_->setSubLabel(
_itemGameIdentification_->getSubLabel() + _owner_->getTitleId()
);
}
else{
_itemGameIdentification_->setValue("No TitleID candidate");
_itemGameIdentification_->setSubLabel(
_itemGameIdentification_->getSubLabel() + "Not found."
);
}

}
Expand Down
2 changes: 1 addition & 1 deletion submodules/cpp-generic-toolbox

0 comments on commit dd7d4ec

Please sign in to comment.