-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring & Cleanup of ViewController References
- Loading branch information
Showing
10 changed files
with
118 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "beatsaber-hook/shared/utils/typedefs-wrappers.hpp" | ||
|
||
#include "GlobalNamespace/LevelCollectionNavigationController.hpp" | ||
#include "GlobalNamespace/LevelSelectionNavigationController.hpp" | ||
#include "GlobalNamespace/LevelFilteringNavigationController.hpp" | ||
#include "GlobalNamespace/AnnotatedBeatmapLevelCollectionsViewController.hpp" | ||
#include "GlobalNamespace/IBeatmapLevelCollection.hpp" | ||
#include "GlobalNamespace/IBeatmapLevelPack.hpp" | ||
#include "GlobalNamespace/IPreviewBeatmapLevel.hpp" | ||
#include "GlobalNamespace/IAnnotatedBeatmapLevelCollection.hpp" | ||
#include "GlobalNamespace/LevelSearchViewController.hpp" | ||
#include "GlobalNamespace/LevelSearchViewController_BeatmapLevelPackCollection.hpp" | ||
|
||
#include "logger.hpp" | ||
|
||
namespace RandomSongImpl { | ||
|
||
extern SafePtr<GlobalNamespace::LevelCollectionNavigationController> levelCollectionNavigationController; | ||
extern SafePtr<GlobalNamespace::LevelFilteringNavigationController> filteringNavigationController; | ||
|
||
void selectRandomSong(); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
#pragma once | ||
|
||
#include "HMUI/ViewController.hpp" | ||
#include "questui/shared/BeatSaberUI.hpp" | ||
#include "HMUI/Touchable.hpp" | ||
|
||
#include "Settings/config.hpp" | ||
#include "logger.hpp" | ||
|
||
void DidActivate(HMUI::ViewController* self, bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "beatsaber-hook/shared/utils/logging.hpp" | ||
#include "beatsaber-hook/shared/config/config-utils.hpp" | ||
|
||
// Include the modloader header, which allows us to tell the modloader which mod this is, and the version etc. | ||
#include "modloader/shared/modloader.hpp" | ||
|
||
// Static Variables | ||
extern ModInfo modInfo; // Stores the ID and version of our mod, and is sent to the modloader upon startup | ||
|
||
// Define these functions here so that we can easily read configuration and log information from other files | ||
Configuration& getConfig(); | ||
Logger& getLogger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "Impl/RandomSongImpl.hpp" | ||
|
||
namespace RandomSongImpl { | ||
|
||
SafePtr<GlobalNamespace::LevelCollectionNavigationController> levelCollectionNavigationController; | ||
SafePtr<GlobalNamespace::LevelFilteringNavigationController> filteringNavigationController; | ||
|
||
void selectRandomSong() | ||
{ | ||
// Only do Things, if we also have the necessary References | ||
if (levelCollectionNavigationController && filteringNavigationController) | ||
{ | ||
// Get Array of all beatmaps that the user currently sees | ||
ArrayW<GlobalNamespace::IPreviewBeatmapLevel *> allmapsArray; | ||
|
||
auto *levelPack = levelCollectionNavigationController->levelPack; | ||
if (levelPack) | ||
{ | ||
allmapsArray = il2cpp_utils::cast<GlobalNamespace::IAnnotatedBeatmapLevelCollection>(levelPack)->get_beatmapLevelCollection()->get_beatmapLevels(); | ||
getLogger().info("Acquired Maps using CollectionNavigationView"); | ||
} | ||
else | ||
{ | ||
allmapsArray = filteringNavigationController->levelSearchViewController->beatmapLevelPackCollection->get_beatmapLevelCollection()->get_beatmapLevels(); | ||
getLogger().info("Acquired Maps using SearchView"); | ||
} | ||
|
||
// Calculate Upper Bound for rand | ||
int max = allmapsArray->Length(); | ||
getLogger().info("Acquired BeatMapCount"); | ||
|
||
if (max > 0) | ||
{ | ||
// Select a random level from 0 to max (exclusive) | ||
levelCollectionNavigationController->SelectLevel(allmapsArray->get(rand() % max)); | ||
getLogger().info("Selected level"); | ||
} | ||
else | ||
{ | ||
getLogger().info("No level found to select"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "logger.hpp" | ||
|
||
ModInfo modInfo; | ||
|
||
// Loads the config from disk using our modInfo, then returns it for use | ||
Configuration &getConfig() | ||
{ | ||
static Configuration config(modInfo); | ||
config.Load(); | ||
return config; | ||
} | ||
|
||
// Returns a logger, useful for printing debug messages | ||
Logger &getLogger() | ||
{ | ||
static Logger *logger = new Logger(modInfo); | ||
return *logger; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters