forked from OpenLoco/OpenLoco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextInput.h
36 lines (30 loc) · 949 Bytes
/
TextInput.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "Graphics/Gfx.h"
#include <cstdint>
#include <string>
namespace OpenLoco::Ui::TextInput
{
constexpr int16_t textboxPadding = 4;
struct InputSession
{
std::string buffer; // 0x011369A0
size_t cursorPosition; // 0x01136FA2
int16_t xOffset; // 0x01136FA4
uint8_t cursorFrame; // 0x011370A9
uint32_t inputLenLimit;
InputSession() = default;
InputSession(const std::string initialString, uint32_t inputSize)
{
buffer = initialString;
cursorPosition = buffer.length();
cursorFrame = 0;
xOffset = 0;
inputLenLimit = inputSize;
};
bool handleInput(uint32_t charCode, uint32_t keyCode);
bool needsReoffsetting(int16_t containerWidth);
void calculateTextOffset(int16_t containerWidth);
void clearInput();
void sanitizeInput();
};
}