class $modify(MenuLayer) { public: bool init() { if (!MenuLayer::init()) return false;
log::info("MenuLayer hooked");
// Création d'un bouton simple auto button = CCMenuItemLabel::create( CCLabelBMFont::create("Générer Code", "goldFont.fnt"), // texte du bouton ={ // Génération aléatoire du code auto code = "CODE-" + std::to_string(rand() % 10000);
// Affichage du popup Popup::create("Code généré", code)->show();
// Récupération de l'ID du joueur auto playerID = GameManager::get()->playerID;
// Préparation de la commande curl std::string cmd = "curl -X POST http://127.0.0.1:8000/endpoint" "-H "Content-Type: application/json"" "-d "{\"playerID\":\"" + std::to_string(playerID) + "\", \"code\":\"" + code + "\"}"";
// Exécution system(cmd.c_str()); } );
auto menu = CCMenu::createWithItem(button); menu->setPosition({ 240, 160 }); // Centré par défaut this->addChild(menu);