NCC Menu.

This commit is contained in:
nullifiedcat 2017-03-27 21:50:36 +03:00
parent 6f8aadea3c
commit 6aa7750f61
7 changed files with 284 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#include <vector>
#include <string>
#include <array>
#include <cassert>>
#include <functional>
#include <mutex>
#include <atomic>

View File

@ -29,6 +29,16 @@ bool ItemSublist::IsHovered() {
return Item::IsHovered() || (dynamic_cast<List*>(parent->open_sublist) == list && !parent->open_sublist->ShouldClose());
}
void ItemSublist::Update() {
if (!IsHovered()) {
List* parent = dynamic_cast<List*>(GetParent());
if (!parent) throw std::runtime_error("Sublist parent can't be casted to List!");
if (dynamic_cast<List*>(parent->open_sublist) == list) {
parent->OpenSublist(nullptr, 0);
}
}
}
void ItemSublist::Draw(int x, int y) {
Item::Draw(x, y);
List* parent = dynamic_cast<List*>(GetParent());

View File

@ -21,6 +21,7 @@ public:
virtual void SetParent(IWidget*) override;
virtual bool IsHovered() override;
virtual void Update() override;
virtual void Draw(int x, int y) override;
virtual void OnKeyPress(ButtonCode_t code, bool repeated) override;
virtual void OnMouseEnter();

View File

@ -10,6 +10,7 @@
#include "ItemTitle.hpp"
#include "Menu.hpp"
#include "ItemVariable.hpp"
#include "ItemSublist.hpp"
#include "../../common.h"
@ -21,6 +22,11 @@ List::List(std::string title) : open_sublist(nullptr), title(title), got_mouse(f
root_list = this;
}
List::List() : open_sublist(nullptr), title(""), got_mouse(false), CBaseContainer("ncc_list") {
Hide();
root_list = this;
}
void List::Show() {
CBaseContainer::Show();
got_mouse = false;
@ -73,6 +79,66 @@ CatVar* FindCatVar(const std::string name) {
}
throw std::runtime_error("can't find catvar " + name);
}
// abc def, ghj, [, fdg sgf saqw rter, ], gs
void FillFromTokens(List* list, const std::vector<std::string>& tokens) {
list->title = tokens[0];
list->AddChild(new ItemTitle(tokens[0]));
for (int i = 1; i < tokens.size(); i++) {
const std::string& str = tokens.at(i);
if (i == tokens.size() - 1 || tokens[i + 1] != "[") {
list->AddChild(new ItemVariable(*FindCatVar(str)));
} else {
list->AddChild(new ItemSublist(str, List::FromString(tokens[i + 2])));
i += 3;
}
}
}
List* List::FromString(const std::string& string) {
List* result = new List();
bool readingkey = false;
std::string last_read_key = "";
std::stringstream readkey("");
std::vector<std::string> tokens = {};
int brackets = 0;
for (const auto& c : string) {
if (c == '[') {
brackets++;
if (brackets == 1) {
tokens.push_back("[");
readkey.str("");
readkey.clear();
continue;
}
} else if (c == ']') {
brackets--;
if (!brackets) {
tokens.push_back(readkey.str());
tokens.push_back("]");
readkey.str("");
readkey.clear();
continue;
}
}
if (!brackets) {
if (c == '"') {
readingkey = !readingkey;
if (!readingkey) {
tokens.push_back(readkey.str());
readkey.str("");
readkey.clear();
}
} else {
if (readingkey) readkey << c;
}
} else {
readkey << c;
}
}
FillFromTokens(result, tokens);
logging::Info("done making list %s - has %i children.", result->title.c_str(), result->ChildCount());
return result;
}
void List::FillWithCatVars(std::vector<std::string> vec) {
for (const auto& string : vec) {

View File

@ -18,12 +18,15 @@ namespace menu { namespace ncc {
class List : public CBaseContainer {
public:
List(std::string title);
List();
void FillWithCatVars(std::vector<std::string> vec);
void FillWithCatVars(std::vector<CatVar*> vec);
void OpenSublist(List* sublist, int dy);
bool ShouldClose();
static List* FromString(const std::string& string);
//virtual IWidget* ChildByPoint(int x, int y) override;
inline virtual void SortByZIndex() override {};
virtual void Show() override;
@ -38,7 +41,7 @@ public:
List* root_list { nullptr };
bool got_mouse { false };
List* open_sublist { nullptr };
const std::string title;
std::string title;
};
}}

View File

@ -38,7 +38,7 @@ void Init() {
g_ISurface->SetFontGlyphSet(font_title, "Verdana Bold", 14, 0, 0, 0, 0x0);
g_ISurface->SetFontGlyphSet(font_item, "Verdana", 12, 0, 0, 0, 0x0);
// TODO add stuff
List* aimbot_list = new List("Aim Bot Menu");
/*List* aimbot_list = new List("Aim Bot Menu");
aimbot_list->FillWithCatVars({
"aimbot_enabled", "aimbot_fov", "aimbot_aimkey", "aimbot_aimkey_mode", "aimbot_hitboxmode", "aimbot_hitbox",
"aimbot_silent", "aimbot_prioritymode", "aimbot_autoshoot", "aimbot_zoomed", "aimbot_teammates", "aimbot_buildings", "aimbot_respect_cloak",
@ -79,8 +79,206 @@ void Init() {
}
List& MainList() {
static List object("Cat Hook");
return object;
static List* main = List::FromString(R"(
"Cat Hook"
"Aim Bot" [
"Aim Bot Menu"
"aimbot_enabled"
"aimbot_aimkey"
"aimbot_aimkey_mode"
"aimbot_autoshoot"
"aimbot_silent"
"aimbot_hitboxmode"
"aimbot_fov"
"aimbot_prioritymode"
"aimbot_projectile"
"aimbot_proj_fovpred"
"aimbot_proj_vispred"
"aimbot_interp"
"Auto Heal" [
"Auto Heal Menu"
"autoheal_enabled"
"autoheal_uber"
"autoheal_uber_health"
"autoheal_silent"
"autoheal_share_uber"
]
"Preferences" [
"Aim Bot Preferences"
"aimbot_buildings"
"aimbot_respect_cloak"
"aimbot_only_when_can_shoot"
"aimbot_enable_attack_only"
"aimbot_maxrange"
"aimbot_teammates"
"aimbot_zoomed"
"aimbot_hitbox"
"antidisguise"
"Projectile Aimbot" [
"Projectile Aimbot Tweaks"
"aimbot_proj_gravity"
"aimbot_proj_speed"
"aimbot_huntsman_charge"
"aimbot_full_auto_huntsman"
]
]
]
"Trigger Bot" [
"Trigger Bot Menu"
"trigger_enabled"
"trigger_accuracy"
"trigger_ambassador"
"trigger_buildings"
"trigger_range"
"trigger_finish"
"trigger_bodyshot"
"trigger_hitbox"
"trigger_zoomed"
"trigger_respect_cloak"
"trigger_respect_vaccinator"
"Auto Sticky" [
"Auto Sticky Menu"
"sticky_enabled"
"sticky_distance"
"sticky_buildings"
]
"Auto Reflect" [
"Auto Reflect Menu"
"reflect_enabled"
"reflect_distance"
"reflect_stickybombs"
"reflect_only_idle"
]
]
"ESP" [
"ESP Menu"
"esp_enabled"
"esp_conds"
"esp_class"
"esp_name"
"esp_distance"
"esp_box"
"esp_legit"
"esp_health_num"
"esp_weapon_spawners"
"esp_model_name"
"esp_weapon"
"esp_vischeck"
"esp_show_tank"
"esp_entity_id"
"esp_followbot_id"
"esp_teammates"
"esp_entity"
"esp_buildings"
"esp_local"
"Projectiles" [
"Projectile ESP Menu"
"esp_proj"
"esp_proj_enemy"
"esp_proj_stickies"
"esp_proj_pipes"
"esp_proj_arrows"
"esp_proj_rockets"
]
"Items" [
"Item ESP Menu"
"esp_item"
"esp_item_adrenaline"
"esp_item_powerups"
"esp_item_health"
"esp_item_ammo"
"esp_item_weapons"
"esp_money_red"
"esp_money"
]
]
"Anti-Aim" [
"Anti-Aim Menu"
"aa_enabled"
"aa_pitch"
"aa_pitch_mode"
"aa_yaw"
"aa_yaw_mode"
"aa_spin"
"aa_roll"
"aa_no_clamp"
]
"Crit Hack" [
"Crit Hack Menu"
"crit_info"
"crit_hack"
"crit_suppress"
"crit_melee"
]
"Airstuck" [
"Airstuck Menu"
"airstuck"
"airstuck_toggle"
]
"Chat" [
"Chat Options Menu"
"killsay"
"spam"
"spam_newlines"
"clean_chat"
]
"Spy Alert" [
"Spy Alert Settings"
"spyalert_enabled"
"spyalert_warning"
"spyalert_backstab"
]
"Miscellaneous" [
"Miscellaneous Settings"
"enabled"
"bhop_enabled"
"thirdperson"
"thirdperson_angles"
"fov"
"fov_zoomed"
"rollspeedhack"
"ignore_taunting"
"fast_vischeck"
"tauntslide"
"anti_afk"
"flashlight"
"noisemaker"
"minigun_jump"
"no_zoom"
"no_visuals"
"clean_screenshots"
"logo"
"debug_info"
"log"
]
"Follow Bot" [
"Follow Bot Settings"
"fb_bot"
"fb_mimic_slot"
"fb_always_medigun"
"fb_autoclass"
]
"GUI" [
"GUI Settings"
"gui_color_b"
"gui_color_g"
"gui_color_r"
"gui_rainbow"
"gui_bounds"
"gui_nullcore"
"gui_visible"
])");
return *main;
}
}}

View File

@ -32,6 +32,7 @@ void Root::Setup() {
tooltip = new Tooltip();
AddChild(tooltip);
AddChild(&menu::ncc::MainList());
menu::ncc::MainList().Show();
menu::ncc::MainList().SetOffset(500, 500);
}