Click Buttons On Mouse Down
This commit is contained in:
parent
cbca78ec16
commit
9bdde40f3f
@ -45,6 +45,7 @@
|
||||
* `Use Updated Title` (Enabled By Default)
|
||||
* `Hide Block Outline When GUI Is Hidden` (Enabled By Default)
|
||||
* `Fix Crash When Generating Certain Seed` (Enabled By Default)
|
||||
* `Click Buttons On Mouse Down` (Enabled By Default)
|
||||
* Existing Functionality (All Enabled By Default)
|
||||
* `Fix Screen Rendering When Hiding HUD`
|
||||
* `Sanitize Usernames`
|
||||
|
@ -107,4 +107,5 @@ TRUE Allow High-Resolution Title
|
||||
TRUE Improved Classic Title Positioning
|
||||
TRUE Use Updated Title
|
||||
TRUE Hide Block Outline When GUI Is Hidden
|
||||
TRUE Fix Crash When Generating Certain Seed
|
||||
TRUE Fix Crash When Generating Certain Seed
|
||||
TRUE Click Buttons On Mouse Down
|
@ -199,6 +199,41 @@ static void PauseScreen_init_injection(PauseScreen_init_t original, PauseScreen
|
||||
}
|
||||
}
|
||||
|
||||
// Click Buttons On Mouse Down
|
||||
static void Screen_mouseClicked_injection(__attribute__((unused)) Screen_mouseClicked_t original, Screen *self, int x, int y, const int param_1) {
|
||||
if (param_1 == 1) {
|
||||
for (Button *button : self->rendered_buttons) {
|
||||
if (button->clicked(self->minecraft, x, y)) {
|
||||
// Click
|
||||
button->setPressed();
|
||||
self->clicked_button = button;
|
||||
self->buttonClicked(button);
|
||||
// Play Sound
|
||||
self->minecraft->sound_engine->playUI("random.click", 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void Screen_mouseReleased_injection(__attribute__((unused)) Screen_mouseReleased_t original, Screen *self, int x, int y, const int param_1) {
|
||||
if (param_1 == 1 && self->clicked_button) {
|
||||
self->clicked_button->released(x, y);
|
||||
self->clicked_button = nullptr;
|
||||
}
|
||||
}
|
||||
// Fix Exiting Pause Screen
|
||||
static void Minecraft_grabMouse_injection(Minecraft_grabMouse_t original, Minecraft *self) {
|
||||
original(self);
|
||||
self->miss_time = 10000;
|
||||
}
|
||||
static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *self, int param_1, bool can_destroy) {
|
||||
// Call Original Method
|
||||
original(self, param_1, can_destroy);
|
||||
// Reset Miss Time
|
||||
if (!can_destroy) {
|
||||
self->miss_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Init
|
||||
void _init_misc_ui() {
|
||||
// Food Overlay
|
||||
@ -288,4 +323,12 @@ void _init_misc_ui() {
|
||||
uchar set_true_patch[] = {0x01, 0x30, 0xa0, 0x03}; // "moveq r3, #0x1"
|
||||
patch((void *) 0x4b93c, set_true_patch);
|
||||
}
|
||||
|
||||
// Click Buttons On Mouse Down
|
||||
if (feature_has("Click Buttons On Mouse Down", server_disabled)) {
|
||||
overwrite_calls(Screen_mouseClicked, Screen_mouseClicked_injection);
|
||||
overwrite_calls(Screen_mouseReleased, Screen_mouseReleased_injection);
|
||||
overwrite_calls(Minecraft_grabMouse, Minecraft_grabMouse_injection);
|
||||
overwrite_calls(Minecraft_handleMouseDown, Minecraft_handleMouseDown_injection);
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ virtual-method void selectLevel(const std::string &level_dir, const std::string
|
||||
property int screen_width = 0x20;
|
||||
property int screen_height = 0x24;
|
||||
property Options options = 0x3c;
|
||||
property LevelRenderer *levelrenderer = 0x150;
|
||||
property GameRenderer *gamerenderer = 0x154;
|
||||
property LevelRenderer *level_renderer = 0x150;
|
||||
property GameRenderer *game_renderer = 0x154;
|
||||
property GameMode *game_mode = 0x160;
|
||||
property Textures *textures = 0x164;
|
||||
property ScreenChooser screen_chooser = 0x168;
|
||||
@ -45,6 +45,8 @@ property int ticks_per_update = 0xc70;
|
||||
property bool is_creative_mode = 0xcb5;
|
||||
property PerfRenderer *perf_renderer = 0xcbc;
|
||||
property CommandServer *command_server = 0xcc0;
|
||||
property SoundEngine *sound_engine = 0x15c;
|
||||
property int miss_time = 0xca0;
|
||||
|
||||
// Smooth Lighting
|
||||
static-property bool useAmbientOcclusion = 0x136b90;
|
||||
|
@ -5,6 +5,10 @@ constructor (int id, const std::string &text) = 0x1bc54;
|
||||
|
||||
method int hovered(Minecraft *minecraft, int click_x, int click_y) = 0x1be2c;
|
||||
|
||||
virtual-method bool clicked(Minecraft *minecraft, int click_x, int click_y) = 0x20;
|
||||
virtual-method void setPressed() = 0x28;
|
||||
virtual-method bool released(int click_x, int click_y) = 0x24;
|
||||
|
||||
property int width = 0x14;
|
||||
property int height = 0x18;
|
||||
property int x = 0xc;
|
||||
|
@ -16,6 +16,7 @@ virtual-method void removed() = 0x2c;
|
||||
virtual-method void renderBackground() = 0x30;
|
||||
virtual-method void buttonClicked(Button *button) = 0x60;
|
||||
virtual-method void mouseClicked(int x, int y, int param_1) = 0x64;
|
||||
virtual-method void mouseReleased(int x, int y, int param_1) = 0x68;
|
||||
virtual-method void keyPressed(int key) = 0x6c;
|
||||
virtual-method void keyboardNewChar(char key) = 0x70;
|
||||
|
||||
@ -26,3 +27,4 @@ property Minecraft *minecraft = 0x14;
|
||||
property std::vector<Button *> rendered_buttons = 0x18;
|
||||
property std::vector<Button *> selectable_buttons = 0x30;
|
||||
property Font *font = 0x40;
|
||||
property Button *clicked_button = 0x44;
|
Loading…
Reference in New Issue
Block a user