Skip to content

Commit 1474b16

Browse files
committed
contained namespaces
1 parent 1693dbb commit 1474b16

59 files changed

Lines changed: 367 additions & 238 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Keybinds.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
#if !defined(GEODE_IS_IOS)
1+
#ifndef GEODE_IS_IOS
22
#include <Utils.hpp>
33

4+
#include <Geode/Geode.hpp>
5+
46
#include <geode.custom-keybinds/include/Keybinds.hpp>
57

6-
using namespace horrible;
8+
using namespace geode::prelude;
9+
using namespace horrible::prelude;
710
using namespace keybinds;
811

912
$execute{
@@ -13,10 +16,10 @@ using namespace keybinds;
1316
"Show Menu",
1417
"Open the Horrible Ideas option menu.",
1518
{
16-
Keybind::create(KEY_Backslash, Modifier::None)
19+
Keybind::create(KEY_Backslash, Modifier::None),
1720
},
18-
"Horrible Ideas"
19-
});
21+
"Horrible Ideas",
22+
});
2023

2124
new EventListener([=](InvokeBindEvent* event) {
2225
if (event->isDown()) menu::open();

src/Utils.hpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
#include <fmt/core.h>
66

7-
#include <Geode/Geode.hpp>
7+
#include <cocos2d.h>
88

99
#include <Geode/loader/SettingV3.hpp>
1010

11-
#include <classes/Colors.hpp>
11+
#include <Geode/binding/FMODAudioEngine.hpp>
12+
1213
#include <classes/Jumpscares.hpp>
1314
#include <classes/Menu.hpp>
1415
#include <classes/Options.hpp>
@@ -18,12 +19,10 @@
1819
#include <classes/ui/RandomAd.hpp>
1920
#include <classes/ui/SpamChallenge.hpp>
2021

21-
using namespace geode::prelude;
22-
2322
// Additional utility methods for Horrible Ideas
2423
namespace horrible {
2524
// Pointer reference to this Geode mod
26-
inline Mod* horribleMod = Mod::get();
25+
inline Mod* horribleMod = geode::Mod::get();
2726

2827
/**
2928
* Convert a chance setting number to a cooldown percentage decimal
@@ -46,7 +45,7 @@ namespace horrible {
4645
if (auto fmod = FMODAudioEngine::sharedEngine()) fmod->playEffectAsync(file);
4746
};
4847

49-
namespace str = utils::string; // Shortcut for geode::utils::string
48+
namespace str = geode::utils::string; // Shortcut for geode::utils::string
5049

5150
// Default horrible categories
5251
namespace category {
@@ -57,4 +56,21 @@ namespace horrible {
5756
inline constexpr const char* obstructive = "Obstructive";
5857
inline constexpr const char* misc = "Misc";
5958
};
59+
60+
// Fast color object references ^w^
61+
namespace colors {
62+
inline constexpr cocos2d::ccColor3B white = { 255, 255, 255 };
63+
inline constexpr cocos2d::ccColor3B gray = { 150, 150, 150 };
64+
inline constexpr cocos2d::ccColor3B red = { 225, 75, 75 };
65+
inline constexpr cocos2d::ccColor3B yellow = { 250, 250, 25 };
66+
inline constexpr cocos2d::ccColor3B green = { 100, 255, 100 };
67+
inline constexpr cocos2d::ccColor3B cyan = { 10, 175, 255 };
68+
inline constexpr cocos2d::ccColor3B black = { 0, 0, 0 };
69+
};
70+
71+
namespace prelude {
72+
using namespace ::horrible;
73+
using namespace ::horrible::ui;
74+
using namespace ::horrible::util;
75+
};
6076
};

src/classes/Colors.hpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/classes/Jumpscares.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#pragma once
22

33
namespace horrible {
4-
// Jumpscare level manager
5-
namespace jumpscares {
6-
void downloadGrief(); // Download Grief
7-
void downloadCongregation(); // Download Congregation
4+
namespace util {
5+
// Jumpscare level manager
6+
namespace jumpscares {
7+
void downloadGrief(); // Download Grief
8+
void downloadCongregation(); // Download Congregation
9+
};
810
};
911
};

src/classes/Menu.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22

33
namespace horrible {
4-
// Menu-related utilities
5-
namespace menu {
6-
void open(); // Open the Horrible Ideas mod option menu
4+
namespace util {
5+
// Menu-related utilities
6+
namespace menu {
7+
void open(); // Open the Horrible Ideas mod option menu
8+
};
79
};
810
};

src/classes/Options.hpp

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,58 @@
22

33
#include <Utils.hpp>
44

5-
using namespace horrible;
6-
75
namespace horrible {
8-
// Horrible options utilities
9-
namespace options {
10-
/**
11-
* Returns the array of all registered options
12-
*
13-
* @returns An array of every registered option, main and external
14-
*/
15-
std::vector<Option> const& getAll();
16-
17-
/**
18-
* Returns the toggle state of an option
19-
*
20-
* @param id The ID of the option to check
21-
*
22-
* @returns Boolean of the current value
23-
*/
24-
bool get(std::string_view id);
25-
26-
/**
27-
* Returns the chance value for an option
28-
*
29-
* @param id The ID of the option to check
30-
*
31-
* @returns Integer of the chance value
32-
*/
33-
int getChance(std::string_view id);
34-
35-
/**
36-
* Set the toggle state of an option
37-
*
38-
* @param id The ID of the option to toggle
39-
* @param enable Boolean to toggle to
40-
*
41-
* @returns Boolean of the old value
42-
*/
43-
bool set(std::string_view id, bool enable);
44-
45-
/**
46-
* Returns the array of all registered option categories
47-
*
48-
* @returns An array of every registered option category, main and external
49-
*/
50-
std::vector<std::string> const& getAllCategories();
51-
52-
/**
53-
* Returns if a category exists or not
54-
*
55-
* @param category The exact name of the category to check
56-
*/
57-
bool doesCategoryExist(std::string_view category);
6+
namespace util {
7+
// Horrible options utilities
8+
namespace options {
9+
/**
10+
* Returns the array of all registered options
11+
*
12+
* @returns An array of every registered option, main and external
13+
*/
14+
std::vector<horrible::Option> const& getAll();
15+
16+
/**
17+
* Returns the toggle state of an option
18+
*
19+
* @param id The ID of the option to check
20+
*
21+
* @returns Boolean of the current value
22+
*/
23+
bool get(std::string_view id);
24+
25+
/**
26+
* Returns the chance value for an option
27+
*
28+
* @param id The ID of the option to check
29+
*
30+
* @returns Integer of the chance value
31+
*/
32+
int getChance(std::string_view id);
33+
34+
/**
35+
* Set the toggle state of an option
36+
*
37+
* @param id The ID of the option to toggle
38+
* @param enable Boolean to toggle to
39+
*
40+
* @returns Boolean of the old value
41+
*/
42+
bool set(std::string_view id, bool enable);
43+
44+
/**
45+
* Returns the array of all registered option categories
46+
*
47+
* @returns An array of every registered option category, main and external
48+
*/
49+
std::vector<std::string> const& getAllCategories();
50+
51+
/**
52+
* Returns if a category exists or not
53+
*
54+
* @param category The exact name of the category to check
55+
*/
56+
bool doesCategoryExist(std::string_view category);
57+
};
5858
};
5959
};

src/classes/Randng.hpp

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,54 @@
11
#pragma once
22

3+
#include <Geode/utils/random.hpp>
4+
35
namespace horrible {
4-
// Random number generator utilities
5-
namespace randng {
6-
/**
7-
* Get a random number between `min` and `max`
8-
*
9-
* @param max The maximum number to get
10-
* @param min The minimum number to get
11-
*/
12-
template <
13-
typename T = int,
14-
typename = std::enable_if_t<std::is_arithmetic_v<T>>
15-
>
16-
inline T get(T max, T min = static_cast<T>(0)) {
17-
return utils::random::generate<T>(min, max + static_cast<T>(1));
18-
};
6+
namespace util {
7+
// Random number generator utilities
8+
namespace randng {
9+
/**
10+
* Get a random number between `min` and `max`
11+
*
12+
* @param max The maximum number to get
13+
* @param min The minimum number to get
14+
*/
15+
template <
16+
typename T = int,
17+
typename = std::enable_if_t<std::is_arithmetic_v<T>>
18+
>
19+
inline T get(T max, T min = static_cast<T>(0)) {
20+
return geode::utils::random::generate<T>(min, max + static_cast<T>(1));
21+
};
1922

20-
/**
21-
* Get any number between 0 and 3000
22-
* @note Recommended to balance chances when calling every frame
23-
*/
24-
template <
25-
typename T = int,
26-
typename = std::enable_if_t<std::is_integral_v<T>>
27-
>
28-
inline T tiny() {
29-
return get<T>(static_cast<T>(3000), static_cast<T>(0));
30-
};
23+
/**
24+
* Get any number between 0 and 3000
25+
* @note Recommended to balance chances when calling every frame
26+
*/
27+
template <
28+
typename T = int,
29+
typename = std::enable_if_t<std::is_integral_v<T>>
30+
>
31+
inline T tiny() {
32+
return get<T>(static_cast<T>(3000), static_cast<T>(0));
33+
};
3134

32-
// Get any number between 0 and 100
33-
template <
34-
typename T = int,
35-
typename = std::enable_if_t<std::is_integral_v<T>>
36-
>
37-
inline T fast() {
38-
return get<T>(static_cast<T>(100), static_cast<T>(0));
39-
};
35+
// Get any number between 0 and 100
36+
template <
37+
typename T = int,
38+
typename = std::enable_if_t<std::is_integral_v<T>>
39+
>
40+
inline T fast() {
41+
return get<T>(static_cast<T>(100), static_cast<T>(0));
42+
};
4043

41-
// Get any percent decimal between 0 and 1
42-
template <
43-
typename F = float,
44-
typename = std::enable_if_t<std::is_floating_point_v<F>>
45-
>
46-
inline F pc() {
47-
return static_cast<F>(fast<int>()) / static_cast<F>(100);
44+
// Get any percent decimal between 0 and 1
45+
template <
46+
typename F = float,
47+
typename = std::enable_if_t<std::is_floating_point_v<F>>
48+
>
49+
inline F pc() {
50+
return static_cast<F>(fast<int>()) / static_cast<F>(100);
51+
};
4852
};
4953
};
5054
};

src/classes/src/Jumpscares.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
#include <Utils.hpp>
44

5-
using namespace horrible;
5+
#include <Geode/Geode.hpp>
6+
7+
using namespace geode::prelude;
8+
using namespace horrible::util;
69

710
void jumpscares::downloadGrief() {
811
if (auto glm = GameLevelManager::get()) {

src/classes/src/Menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <Utils.hpp>
66

7-
using namespace horrible;
7+
using namespace horrible::util;
88

99
void menu::open() {
1010
if (auto old = HorribleMenuPopup::get()) {

src/classes/src/Options.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <Utils.hpp>
44

55
using namespace horrible;
6+
using namespace horrible::util;
67

78
std::vector<Option> const& options::getAll() {
89
if (auto om = OptionManager::get()) return om->getOptions();

0 commit comments

Comments
 (0)