Fix history editing bug
- Use the `get_<var>` pattern for chat's `history`. - Make the Biome_map comment clearer
This commit is contained in:
parent
3ff24c2a92
commit
a6e0cd8f13
@ -10,7 +10,10 @@
|
|||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
#include <mods/touch/touch.h>
|
#include <mods/touch/touch.h>
|
||||||
|
|
||||||
std::vector<std::string> history;
|
static std::vector<std::string> &get_history() {
|
||||||
|
static std::vector<std::string> history = {};
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
// Structure
|
// Structure
|
||||||
struct ChatScreen {
|
struct ChatScreen {
|
||||||
@ -26,7 +29,7 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
|||||||
original_init(super);
|
original_init(super);
|
||||||
ChatScreen *self = (ChatScreen *) super;
|
ChatScreen *self = (ChatScreen *) super;
|
||||||
// Text Input
|
// Text Input
|
||||||
self->chat = TextInputBox::create("", "", &history);
|
self->chat = TextInputBox::create("", "", &get_history());
|
||||||
self->super.m_textInputs->push_back(self->chat);
|
self->super.m_textInputs->push_back(self->chat);
|
||||||
self->chat->init(super->font);
|
self->chat->init(super->font);
|
||||||
self->chat->setFocused(true);
|
self->chat->setFocused(true);
|
||||||
@ -81,7 +84,8 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
|||||||
if (key == 0x0d && self->chat->isFocused()) {
|
if (key == 0x0d && self->chat->isFocused()) {
|
||||||
if (self->chat->getText().length() > 0) {
|
if (self->chat->getText().length() > 0) {
|
||||||
std::string text = self->chat->getText();
|
std::string text = self->chat->getText();
|
||||||
if (self->chat->history_pos != int(history.size() - 1)) {
|
std::vector<std::string> &history = get_history();
|
||||||
|
if (history.size() == 0 || text != history.back()) {
|
||||||
history.push_back(text);
|
history.push_back(text);
|
||||||
}
|
}
|
||||||
_chat_queue_message(text.c_str());
|
_chat_queue_message(text.c_str());
|
||||||
@ -119,7 +123,6 @@ static Screen *create_chat_screen() {
|
|||||||
|
|
||||||
// Init
|
// Init
|
||||||
void _init_chat_ui() {
|
void _init_chat_ui() {
|
||||||
history = {};
|
|
||||||
misc_run_on_game_key_press([](Minecraft *minecraft, int key) {
|
misc_run_on_game_key_press([](Minecraft *minecraft, int key) {
|
||||||
if (key == 0x54) {
|
if (key == 0x54) {
|
||||||
if (Minecraft_isLevelGenerated(minecraft) && minecraft->screen == NULL) {
|
if (Minecraft_isLevelGenerated(minecraft) && minecraft->screen == NULL) {
|
||||||
|
@ -5,3 +5,5 @@ property Minecraft *mc = 0x18;
|
|||||||
|
|
||||||
method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824;
|
method void renderItem(Mob *mob, ItemInstance *item) = 0x4b824;
|
||||||
method void render(float param_1) = 0x4bfcc;
|
method void render(float param_1) = 0x4bfcc;
|
||||||
|
|
||||||
|
static-property ItemInHandRenderer *instance = 0x137bc0;
|
@ -16,5 +16,5 @@ virtual-method float getCreatureProbability() = 0x20;
|
|||||||
property int color = 0x2c;
|
property int color = 0x2c;
|
||||||
property int leaf_color = 0x34;
|
property int leaf_color = 0x34;
|
||||||
|
|
||||||
// 64x64, Temp x humidity
|
// This is a Biome*[64x64], temp x humidity
|
||||||
static-property-array Biome *map = 0x17c970;
|
static-property-array Biome *map = 0x17c970;
|
||||||
|
Loading…
Reference in New Issue
Block a user