mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
Fix hotbar switch + mouse scroll not working, when hotbar switch has been rebinded.
This commit is contained in:
parent
31b0cde8aa
commit
cde8d2cfd1
@ -142,7 +142,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
|
|
||||||
float deltaAcc;
|
float deltaAcc;
|
||||||
public override bool HandlesMouseScroll(float delta) {
|
public override bool HandlesMouseScroll(float delta) {
|
||||||
if (game.Input.AltDown) {
|
if (game.Input.IsKeyDown(KeyBind.HotbarSwitching)) {
|
||||||
int index = game.Inventory.Offset / Inventory.BlocksPerRow;
|
int index = game.Inventory.Offset / Inventory.BlocksPerRow;
|
||||||
game.Inventory.Offset = ScrolledIndex(delta, index, 1) * Inventory.BlocksPerRow;
|
game.Inventory.Offset = ScrolledIndex(delta, index, 1) * Inventory.BlocksPerRow;
|
||||||
altHandled = true;
|
altHandled = true;
|
||||||
|
@ -60,7 +60,7 @@ namespace ClassicalSharp.Map {
|
|||||||
/// <summary> Sets the block at the given world coordinates without bounds checking. </summary>
|
/// <summary> Sets the block at the given world coordinates without bounds checking. </summary>
|
||||||
public void SetBlock(int x, int y, int z, BlockID blockId) {
|
public void SetBlock(int x, int y, int z, BlockID blockId) {
|
||||||
int i = (y * Length + z) * Width + x;
|
int i = (y * Length + z) * Width + x;
|
||||||
blocks1[i] = (BlockRaw)blockId;
|
blocks1[i] = (BlockRaw)blockId;
|
||||||
if (blocks1 == blocks2) return;
|
if (blocks1 == blocks2) return;
|
||||||
blocks2[i] = (BlockRaw)(blockId >> 8);
|
blocks2[i] = (BlockRaw)(blockId >> 8);
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,10 @@ void ButtonWidget_Render(GuiElement* elem, Real64 delta) {
|
|||||||
Texture_RenderShaded(&widget->Texture, col);
|
Texture_RenderShaded(&widget->Texture, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ButtonWidget_HandlesMouseDown(GuiElement* elem, Int32 x, Int32 y, MouseButton btn) {
|
||||||
|
return ((ButtonWidget*)elem)->OnClick(x, y, btn);
|
||||||
|
}
|
||||||
|
|
||||||
GuiElementVTABLE ButtonWidget_VTABLE;
|
GuiElementVTABLE ButtonWidget_VTABLE;
|
||||||
void ButtonWidget_Create(ButtonWidget* widget, STRING_PURE String* text, Int32 minWidth, FontDesc* font, Gui_MouseHandler onClick) {
|
void ButtonWidget_Create(ButtonWidget* widget, STRING_PURE String* text, Int32 minWidth, FontDesc* font, Gui_MouseHandler onClick) {
|
||||||
widget->VTABLE = &ButtonWidget_VTABLE;
|
widget->VTABLE = &ButtonWidget_VTABLE;
|
||||||
@ -185,7 +189,8 @@ void ButtonWidget_Create(ButtonWidget* widget, STRING_PURE String* text, Int32 m
|
|||||||
Elem_Init(widget);
|
Elem_Init(widget);
|
||||||
widget->MinWidth = minWidth; widget->MinHeight = 40;
|
widget->MinWidth = minWidth; widget->MinHeight = 40;
|
||||||
ButtonWidget_SetText(widget, text);
|
ButtonWidget_SetText(widget, text);
|
||||||
widget->VTABLE->HandlesMouseDown = onClick;
|
widget->OnClick = onClick;
|
||||||
|
widget->VTABLE->HandlesMouseDown = ButtonWidget_HandlesMouseDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonWidget_SetText(ButtonWidget* widget, STRING_PURE String* text) {
|
void ButtonWidget_SetText(ButtonWidget* widget, STRING_PURE String* text) {
|
||||||
|
@ -38,9 +38,10 @@ typedef struct ButtonWidget_ {
|
|||||||
FontDesc Font;
|
FontDesc Font;
|
||||||
|
|
||||||
String OptName;
|
String OptName;
|
||||||
|
Gui_MouseHandler OnClick;
|
||||||
ButtonWidget_GetValue GetValue;
|
ButtonWidget_GetValue GetValue;
|
||||||
ButtonWidget_SetValue SetValue;
|
ButtonWidget_SetValue SetValue;
|
||||||
Int32 MinWidth, MinHeight, Metadata;
|
Int32 MinWidth, MinHeight;
|
||||||
} ButtonWidget;
|
} ButtonWidget;
|
||||||
|
|
||||||
void ButtonWidget_Create(ButtonWidget* widget, STRING_PURE String* text, Int32 minWidth, FontDesc* font, Gui_MouseHandler onClick);
|
void ButtonWidget_Create(ButtonWidget* widget, STRING_PURE String* text, Int32 minWidth, FontDesc* font, Gui_MouseHandler onClick);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user