Add chat history
- More symbols too - Made CUSTOM_VTABLE not static, for modders
This commit is contained in:
parent
d74d1501ce
commit
3ff24c2a92
@ -52,7 +52,7 @@ int reborn_is_server();
|
|||||||
|
|
||||||
// Customize VTable
|
// Customize VTable
|
||||||
#define CUSTOM_VTABLE(name, parent) \
|
#define CUSTOM_VTABLE(name, parent) \
|
||||||
static void _setup_##name##_vtable(parent##_vtable *vtable); \
|
void _setup_##name##_vtable(parent##_vtable *vtable); \
|
||||||
static parent##_vtable *get_##name##_vtable() { \
|
static parent##_vtable *get_##name##_vtable() { \
|
||||||
static parent##_vtable *vtable = NULL; \
|
static parent##_vtable *vtable = NULL; \
|
||||||
/* Allocate VTable */ \
|
/* Allocate VTable */ \
|
||||||
@ -67,7 +67,7 @@ int reborn_is_server();
|
|||||||
return vtable; \
|
return vtable; \
|
||||||
} \
|
} \
|
||||||
/* User-Defined Setup Code */ \
|
/* User-Defined Setup Code */ \
|
||||||
static void _setup_##name##_vtable(parent##_vtable *vtable)
|
void _setup_##name##_vtable(parent##_vtable *vtable)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
struct TextInputBox {
|
struct TextInputBox {
|
||||||
static TextInputBox *create(const std::string &placeholder = "", const std::string &text = "");
|
static TextInputBox *create(const std::string &placeholder = "", const std::string &text = "", const std::vector<std::string> *history = NULL);
|
||||||
|
|
||||||
GuiComponent super;
|
GuiComponent super;
|
||||||
|
|
||||||
@ -21,6 +21,8 @@ struct TextInputBox {
|
|||||||
bool isFocused();
|
bool isFocused();
|
||||||
void setMaxLength(int max_length);
|
void setMaxLength(int max_length);
|
||||||
|
|
||||||
|
int history_pos;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void recalculateScroll();
|
void recalculateScroll();
|
||||||
|
|
||||||
@ -38,4 +40,5 @@ private:
|
|||||||
Font *m_pFont;
|
Font *m_pFont;
|
||||||
int m_maxLength;
|
int m_maxLength;
|
||||||
int m_scrollPos;
|
int m_scrollPos;
|
||||||
|
const std::vector<std::string> *history;
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#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;
|
||||||
|
|
||||||
// Structure
|
// Structure
|
||||||
struct ChatScreen {
|
struct ChatScreen {
|
||||||
TextInputScreen super;
|
TextInputScreen super;
|
||||||
@ -24,7 +26,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();
|
self->chat = TextInputBox::create("", "", &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);
|
||||||
@ -78,7 +80,11 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
|||||||
ChatScreen *self = (ChatScreen *) super;
|
ChatScreen *self = (ChatScreen *) super;
|
||||||
if (key == 0x0d && self->chat->isFocused()) {
|
if (key == 0x0d && self->chat->isFocused()) {
|
||||||
if (self->chat->getText().length() > 0) {
|
if (self->chat->getText().length() > 0) {
|
||||||
_chat_queue_message(self->chat->getText().c_str());
|
std::string text = self->chat->getText();
|
||||||
|
if (self->chat->history_pos != int(history.size() - 1)) {
|
||||||
|
history.push_back(text);
|
||||||
|
}
|
||||||
|
_chat_queue_message(text.c_str());
|
||||||
}
|
}
|
||||||
Minecraft_setScreen(super->minecraft, NULL);
|
Minecraft_setScreen(super->minecraft, NULL);
|
||||||
}
|
}
|
||||||
@ -113,6 +119,7 @@ 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) {
|
||||||
|
@ -2,7 +2,16 @@
|
|||||||
|
|
||||||
#include <mods/text-input-box/TextInputBox.h>
|
#include <mods/text-input-box/TextInputBox.h>
|
||||||
|
|
||||||
TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text) {
|
static int get_vec_size(const std::vector<std::string> *vec) {
|
||||||
|
return vec ? vec->size() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string index_vec(const std::vector<std::string> *vec, int pos) {
|
||||||
|
if (vec == NULL || pos == get_vec_size(vec)) return "";
|
||||||
|
return vec->at(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text, const std::vector<std::string> *history) {
|
||||||
// Construct
|
// Construct
|
||||||
TextInputBox *self = new TextInputBox;
|
TextInputBox *self = new TextInputBox;
|
||||||
GuiComponent_constructor(&self->super);
|
GuiComponent_constructor(&self->super);
|
||||||
@ -22,6 +31,8 @@ TextInputBox *TextInputBox::create(const std::string &placeholder, const std::st
|
|||||||
self->m_pFont = nullptr;
|
self->m_pFont = nullptr;
|
||||||
self->m_maxLength = -1;
|
self->m_maxLength = -1;
|
||||||
self->m_scrollPos = 0;
|
self->m_scrollPos = 0;
|
||||||
|
self->history = history;
|
||||||
|
self->history_pos = get_vec_size(history);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return self;
|
return self;
|
||||||
@ -88,6 +99,16 @@ void TextInputBox::keyPressed(int key) {
|
|||||||
recalculateScroll();
|
recalculateScroll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0x26: {
|
||||||
|
// Up
|
||||||
|
int old_pos = history_pos;
|
||||||
|
history_pos -= 1;
|
||||||
|
if (history_pos < 0) history_pos = get_vec_size(history);
|
||||||
|
if (old_pos == history_pos) break;
|
||||||
|
m_text = index_vec(history, history_pos);
|
||||||
|
m_insertHead = int(m_text.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 0x27: {
|
case 0x27: {
|
||||||
// Right
|
// Right
|
||||||
m_insertHead++;
|
m_insertHead++;
|
||||||
@ -101,6 +122,16 @@ void TextInputBox::keyPressed(int key) {
|
|||||||
recalculateScroll();
|
recalculateScroll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 0x28: {
|
||||||
|
// Down
|
||||||
|
int old_pos = history_pos;
|
||||||
|
history_pos += 1;
|
||||||
|
if (history_pos > get_vec_size(history)) history_pos = 0;
|
||||||
|
if (old_pos == history_pos) break;
|
||||||
|
m_text = index_vec(history, history_pos);
|
||||||
|
m_insertHead = int(m_text.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 0x0d: {
|
case 0x0d: {
|
||||||
// Enter
|
// Enter
|
||||||
m_bFocused = false;
|
m_bFocused = false;
|
||||||
|
@ -66,6 +66,7 @@ set(SRC
|
|||||||
src/level/container/Container.def
|
src/level/container/Container.def
|
||||||
src/level/container/ContainerMenu.def
|
src/level/container/ContainerMenu.def
|
||||||
src/level/container/Inventory.def
|
src/level/container/Inventory.def
|
||||||
|
src/level/feature/Feature.def
|
||||||
src/level/feature/LargeFeature.def
|
src/level/feature/LargeFeature.def
|
||||||
src/level/feature/LargeCaveFeature.def
|
src/level/feature/LargeCaveFeature.def
|
||||||
src/level/Material.def
|
src/level/Material.def
|
||||||
@ -97,6 +98,7 @@ set(SRC
|
|||||||
src/item/ArmorItem.def
|
src/item/ArmorItem.def
|
||||||
src/item/TileItem.def
|
src/item/TileItem.def
|
||||||
src/item/FoodItem.def
|
src/item/FoodItem.def
|
||||||
|
src/item/DiggerItem.def
|
||||||
src/api/OffsetPosTranslator.def
|
src/api/OffsetPosTranslator.def
|
||||||
src/api/CommandServer.def
|
src/api/CommandServer.def
|
||||||
src/api/ConnectedClient.def
|
src/api/ConnectedClient.def
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
virtual-method void remove() = 0x10;
|
virtual-method void remove() = 0x10;
|
||||||
virtual-method void tick() = 0x34;
|
virtual-method void tick() = 0x34;
|
||||||
|
virtual-method float getBrightness(float param_1) = 0x64;
|
||||||
virtual-method bool interact(Player *with) = 0x6c;
|
virtual-method bool interact(Player *with) = 0x6c;
|
||||||
virtual-method void playerTouch(Player *player) = 0x70;
|
virtual-method void playerTouch(Player *player) = 0x70;
|
||||||
virtual-method bool isPlayer() = 0x94;
|
virtual-method bool isPlayer() = 0x94;
|
||||||
@ -37,3 +38,4 @@ property int fire_timer = 0xa0;
|
|||||||
property int renderer_id = 0xa8;
|
property int renderer_id = 0xa8;
|
||||||
property bool on_ground = 0xb2;
|
property bool on_ground = 0xb2;
|
||||||
property bool freeze_physics = 0xb9;
|
property bool freeze_physics = 0xb9;
|
||||||
|
property float fall_distance = 0xac;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
method void tick(int tick, int max_ticks) = 0x495bc;
|
||||||
method void render(float param_1) = 0x4a338;
|
method void render(float param_1) = 0x4a338;
|
||||||
method void setupCamera(float param_1, int param_2) = 0x489f8;
|
method void setupCamera(float param_1, int param_2) = 0x489f8;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ method void tickInput() = 0x15ffc;
|
|||||||
method void setIsCreativeMode(int is_creative) = 0x16ec4;
|
method void setIsCreativeMode(int is_creative) = 0x16ec4;
|
||||||
method int isTouchscreen() = 0x1639c;
|
method int isTouchscreen() = 0x1639c;
|
||||||
method void setScreen(Screen *screen) = 0x15d6c;
|
method void setScreen(Screen *screen) = 0x15d6c;
|
||||||
method void tick(int param_1, int param_2) = 0x16934;
|
method void tick(int tick, int max_ticks) = 0x16934;
|
||||||
method void hostMultiplayer(int port) = 0x16664;
|
method void hostMultiplayer(int port) = 0x16664;
|
||||||
method char *getProgressMessage() = 0x16e58;
|
method char *getProgressMessage() = 0x16e58;
|
||||||
method uint isLevelGenerated() = 0x16e6c;
|
method uint isLevelGenerated() = 0x16e6c;
|
||||||
@ -27,21 +27,24 @@ property int screen_width = 0x20;
|
|||||||
property int screen_height = 0x24;
|
property int screen_height = 0x24;
|
||||||
property Options options = 0x3c;
|
property Options options = 0x3c;
|
||||||
property LevelRenderer *levelrenderer = 0x150;
|
property LevelRenderer *levelrenderer = 0x150;
|
||||||
|
property GameRenderer *gamerenderer = 0x154;
|
||||||
property GameMode *game_mode = 0x160;
|
property GameMode *game_mode = 0x160;
|
||||||
property Textures *textures = 0x164;
|
property Textures *textures = 0x164;
|
||||||
|
property ScreenChooser screen_chooser = 0x168;
|
||||||
|
property Font *font = 0x16c;
|
||||||
property RakNetInstance *rak_net_instance = 0x170;
|
property RakNetInstance *rak_net_instance = 0x170;
|
||||||
property NetEventCallback *network_handler = 0x174;
|
property NetEventCallback *network_handler = 0x174;
|
||||||
property Level *level = 0x188;
|
property Level *level = 0x188;
|
||||||
|
property LocalPlayer *player = 0x18c;
|
||||||
property Mob *camera = 0x194;
|
property Mob *camera = 0x194;
|
||||||
property Gui gui = 0x198;
|
property Gui gui = 0x198;
|
||||||
property LocalPlayer *player = 0x18c;
|
|
||||||
property Screen *screen = 0xc10;
|
property Screen *screen = 0xc10;
|
||||||
property HitResult hit_result = 0xc38;
|
property HitResult hit_result = 0xc38;
|
||||||
property int progress = 0xc60;
|
property int progress = 0xc60;
|
||||||
|
property int ticks_per_update = 0xc70;
|
||||||
|
property bool is_creative_mode = 0xcb5;
|
||||||
property PerfRenderer *perf_renderer = 0xcbc;
|
property PerfRenderer *perf_renderer = 0xcbc;
|
||||||
property CommandServer *command_server = 0xcc0;
|
property CommandServer *command_server = 0xcc0;
|
||||||
property Font *font = 0x16c;
|
|
||||||
property ScreenChooser screen_chooser = 0x168;
|
|
||||||
|
|
||||||
// Smooth Lighting
|
// Smooth Lighting
|
||||||
static-property bool useAmbientOcclusion = 0x136b90;
|
static-property bool useAmbientOcclusion = 0x136b90;
|
||||||
|
3
symbols/src/item/DiggerItem.def
Normal file
3
symbols/src/item/DiggerItem.def
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
extends Item;
|
||||||
|
|
||||||
|
property float speed = 0x24;
|
@ -1,2 +1,20 @@
|
|||||||
|
vtable 0x110180;
|
||||||
|
vtable-size 0x24;
|
||||||
|
|
||||||
|
static-method void initBiomes() = 0xae320;
|
||||||
|
static-method void recalc() = 0xae010;
|
||||||
|
static-method Biome *_getBiome(float temp, float humidity) = 0xadf04;
|
||||||
|
|
||||||
|
virtual-method Feature *getTreeFeature(Random *random) = 0x8;
|
||||||
|
virtual-method Feature *getGrassFeature(Random *random) = 0xc;
|
||||||
|
virtual-method float adjustScale(float scale) = 0x10;
|
||||||
|
virtual-method float adjustDepth(float depth) = 0x14;
|
||||||
|
virtual-method uint getSkyColor(float temp) = 0x18;
|
||||||
|
//virtual-method ??? *getMobs(MobCategory *category) = 0x1c;
|
||||||
|
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
|
||||||
|
static-property-array Biome *map = 0x17c970;
|
||||||
|
@ -11,17 +11,21 @@ method Entity *getEntity(int id) = 0xa45a4;
|
|||||||
method bool addEntity(Entity *entity) = 0xa7cbc;
|
method bool addEntity(Entity *entity) = 0xa7cbc;
|
||||||
method int getBrightness2(LightLayer *layer, int x, int y, int z) = 0xa3c70;
|
method int getBrightness2(LightLayer *layer, int x, int y, int z) = 0xa3c70;
|
||||||
method void playSound(Entity *entity, std::string *name, float volume, float pitch) = 0xa42a8;
|
method void playSound(Entity *entity, std::string *name, float volume, float pitch) = 0xa42a8;
|
||||||
|
// Searches aabb for entities, ignores the entity "ignore", overwrites the same vector each time
|
||||||
|
method std::vector<Entity*> *getEntities(Entity *ignore, AABB *aabb) = 0xa5a4c;
|
||||||
// Searches aabb for entities of type type_id, adds then to buff, returns the number of entities added
|
// Searches aabb for entities of type type_id, adds then to buff, returns the number of entities added
|
||||||
method int getEntitiesOfType(int type_id, AABB *aabb, std::vector<Entity*> *buff) = 0xa612c;
|
method int getEntitiesOfType(int type_id, AABB *aabb, std::vector<Entity*> *buff) = 0xa612c;
|
||||||
// Searches aabb for entities of base type base_type, adds then to buff, returns the number of entities added
|
// Searches aabb for entities of base type base_type, adds then to buff, returns the number of entities added
|
||||||
method int getEntitiesOfClass(int base_type, AABB *aabb, std::vector<Entity*> *buff) = 0xa6240;
|
method int getEntitiesOfClass(int base_type, AABB *aabb, std::vector<Entity*> *buff) = 0xa6240;
|
||||||
// This will implicitly make the tile entity if the tile at x, y, z doesn't have one and is an EntityTile
|
// This will implicitly make the tile entity if the tile at x, y, z doesn't have one and is an EntityTile
|
||||||
method TileEntity *getTileEntity(int x, int y, int z) = 0xa55d4;
|
method TileEntity *getTileEntity(int x, int y, int z) = 0xa55d4;
|
||||||
|
method void animateTick(int x, int y, int z) = 0xa5920;
|
||||||
|
|
||||||
virtual-method void tick() = 0x28;
|
virtual-method void tick() = 0x28;
|
||||||
virtual-method void updateSleepingPlayerList() = 0x2c;
|
virtual-method void updateSleepingPlayerList() = 0x2c;
|
||||||
virtual-method ChunkCache *createChunkSource() = 0x30;
|
virtual-method ChunkCache *createChunkSource() = 0x30;
|
||||||
|
|
||||||
|
property bool done_generating = 0x12;
|
||||||
property std::vector<Entity *> entities = 0x20;
|
property std::vector<Entity *> entities = 0x20;
|
||||||
property std::vector<TileEntity *> tileentities = 0x50;
|
property std::vector<TileEntity *> tileentities = 0x50;
|
||||||
property std::vector<Player *> players = 0x60;
|
property std::vector<Player *> players = 0x60;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
method void tick() = 0x4da1c;
|
||||||
method void render(Mob *mob, int param_1, float delta) = 0x4f710;
|
method void render(Mob *mob, int param_1, float delta) = 0x4f710;
|
||||||
method void renderDebug(AABB *aabb, float delta) = 0x4d310;
|
method void renderDebug(AABB *aabb, float delta) = 0x4d310;
|
||||||
method void generateSky() = 0x4d0d4;
|
method void generateSky() = 0x4d0d4;
|
||||||
|
@ -5,4 +5,5 @@ vtable 0x110598;
|
|||||||
method void buildSurface(int chunk_x, int chunk_y, uchar *chunk_data, Biome **biomes) = 0xb32ec;
|
method void buildSurface(int chunk_x, int chunk_y, uchar *chunk_data, Biome **biomes) = 0xb32ec;
|
||||||
|
|
||||||
property LargeCaveFeature cave_feature = 0x8;
|
property LargeCaveFeature cave_feature = 0x8;
|
||||||
|
property Random random = 0x19f8;
|
||||||
property Level *level = 0x72c8;
|
property Level *level = 0x72c8;
|
||||||
|
@ -6,5 +6,7 @@ method ItemInstance *getSelected() = 0x8d134;
|
|||||||
// It's just FillingContainer_linkSlot with selectedSlot as linked_slot
|
// It's just FillingContainer_linkSlot with selectedSlot as linked_slot
|
||||||
method bool moveToSelectedSlot(int unlinked_slot, bool push_aside) = 0x8d148;
|
method bool moveToSelectedSlot(int unlinked_slot, bool push_aside) = 0x8d148;
|
||||||
method void setupDefault() = 0x8d164;
|
method void setupDefault() = 0x8d164;
|
||||||
|
method void clearInventoryWithDefault() = 0x8e7c8;
|
||||||
|
method void clearInventory() = 0x92b84;
|
||||||
|
|
||||||
property int selectedSlot = 0x28;
|
property int selectedSlot = 0x28;
|
||||||
|
7
symbols/src/level/feature/Feature.def
Normal file
7
symbols/src/level/feature/Feature.def
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
vtable 0x10e530;
|
||||||
|
vtable-size 0x10;
|
||||||
|
|
||||||
|
// Pure virtual
|
||||||
|
virtual-method bool place(Level *level, Random *random, int x, int y, int z) = 0x8;
|
||||||
|
// Not sure about args, it doesn't seem to be used at all
|
||||||
|
virtual-method void init(float x, float y, float z) = 0xc;
|
@ -5,3 +5,4 @@ static-method float sin(float x) = 0x7775c;
|
|||||||
static-method float cos(float x) = 0x77728;
|
static-method float cos(float x) = 0x77728;
|
||||||
static-method float abs(float x) = 0x7781c;
|
static-method float abs(float x) = 0x7781c;
|
||||||
static-method float min(float a, float b) = 0x7782c;
|
static-method float min(float a, float b) = 0x7782c;
|
||||||
|
static-method float invSqrt(float a) = 0x776d4;
|
@ -73,3 +73,4 @@ static-property Tile *grass_carried = 0x181dd4;
|
|||||||
|
|
||||||
// Sounds
|
// Sounds
|
||||||
static-property Tile_SoundType SOUND_STONE = 0x181c80;
|
static-property Tile_SoundType SOUND_STONE = 0x181c80;
|
||||||
|
static-property Tile_SoundType SOUND_WOOD = 0x181cb4;
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
size 0xb8;
|
||||||
|
|
||||||
|
constructor (Minecraft *minecraft, LevelSource *level) = 0x53e58;
|
||||||
|
|
||||||
method bool tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30;
|
method bool tesselateBlockInWorld(Tile *tile, int x, int y, int z) = 0x59e30;
|
||||||
method bool tesselateInWorld(Tile *tile, int x, int y, int z) = 0x5e80c;
|
method bool tesselateInWorld(Tile *tile, int x, int y, int z) = 0x5e80c;
|
||||||
|
|
||||||
property Level *level = 0x0;
|
property LevelSource *level = 0x0;
|
||||||
|
Loading…
Reference in New Issue
Block a user