#ifndef INPUTBOX_H
#define INPUTBOX_H
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
// 前置声明
class Screen;
class InputBox {
public:
// 构造函数,接收屏幕对象指针
InputBox(Screen* screen);
~InputBox();
// 显示输入框并返回输入结果
std::string show(std::string title, std::string prompt);
private:
Screen* m_screen; // 关联的屏幕对象
SDL_Window* m_window; // 输入框窗口
SDL_Renderer* m_renderer; // 输入框渲染器
TTF_Font* m_font; // 字体
std::string m_inputText; // 输入的文本
bool m_quit; // 是否退出输入框
bool m_confirmed; // 是否确认输入
const int m_windowWidth = 300; // 窗口宽度
const int m_windowHeight = 180; // 窗口高度
// 初始化输入框窗口和渲染器
bool init(const std::string& title);
// 处理事件
void handleEvents();
// 渲染输入框界面
void render(const std::string& prompt);
// 释放资源
void cleanup();
};
#endif // INPUTBOX_H
-
- 2026 年 3 月
- 2026 年 2 月
- 2026 年 1 月
- 2025 年 12 月
- 2025 年 11 月
- 2025 年 10 月
- 2025 年 9 月
- 2025 年 6 月
- 2025 年 5 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2023 年 11 月
- 2023 年 9 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 2 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 8 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 5 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 7 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2018 年 3 月
- 2018 年 1 月
- 2017 年 9 月
- 2017 年 5 月
- 2017 年 1 月
