/
yaseeeeechka
/
CenterControl
Обзор
Документация
Войти
/
yaseeeeechka
/
CenterControl
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CenterControl_TCP/include/client/InputForm.h
46 строк
1 KB
Yaroslava
New structure of Repo. TCP impl
11 дек 2025, 21:12
11 дек 2025, 21:12
6fdf9d7
Код
Авторство
О чём код?
#ifndef INPUTFORM_H #define INPUTFORM_H #include <SFML/Graphics.hpp> #include "TextBox.h" class InputForm { public: InputForm(const sf::Font &font) : font_(font) { } void AddField(const std::string &name, float x, float y) { labels_.emplace_back(font_, name + ":", 18); labels_.back().setPosition({x, y}); boxes_.emplace_back(std::make_unique<TextBox>(x + 120, y - 5, 200, 30, font_)); names_.push_back(name); } void HandleEvent(const sf::Event &e, const sf::Window &w) { for (auto &b: boxes_) b->HandleEvent(e, w); } void Draw(sf::RenderTarget &t) { for (size_t i = 0; i < labels_.size(); ++i) { t.draw(labels_[i]); boxes_[i]->Draw(t); } } std::string GetFieldValue(const std::string &name) { for (size_t i = 0; i < names_.size(); ++i) if (names_[i] == name) return boxes_[i]->GetText(); return ""; } private: sf::Font font_; std::vector<std::string> names_; std::vector<sf::Text> labels_; std::vector<std::unique_ptr<TextBox> > boxes_; }; #endif //INPUTFORM_H