Allow binding controls to 1-9, fix can't activate texture ID overlay while in a UI menu

This commit is contained in:
UnknownShadow200 2024-07-20 10:44:41 +10:00
parent 0f5c74fb53
commit 97c3dd8374
3 changed files with 57 additions and 17 deletions

View File

@ -848,6 +848,8 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return false;
if (p->Hacks.CanRespawn) {
LocalPlayer_DoRespawn(p);
return true;
@ -860,6 +862,8 @@ static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return false;
if (p->Hacks.CanRespawn) {
if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
@ -886,6 +890,7 @@ static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_HandleFly(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return false;
if (p->Hacks.CanFly && p->Hacks.Enabled) {
HacksComp_SetFlying(&p->Hacks, !p->Hacks.Flying);
@ -900,6 +905,7 @@ static cc_bool LocalPlayer_HandleFly(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_HandleNoclip(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
p->Hacks._noclipping = true;
if (Gui.InputGrab) return false;
if (p->Hacks.CanNoclip && p->Hacks.Enabled) {
if (p->Hacks.WOMStyleHacks) return true; /* don't handle this here */
@ -919,6 +925,7 @@ static cc_bool LocalPlayer_HandleJump(int key, struct InputDevice* device) {
struct HacksComp* hacks = &p->Hacks;
struct PhysicsComp* physics = &p->Physics;
int maxJumps;
if (Gui.InputGrab) return false;
physics->Jumping = true;
if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) {
@ -938,6 +945,7 @@ static cc_bool LocalPlayer_HandleJump(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
if (Gui.InputGrab) return false;
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
return true;
@ -946,6 +954,7 @@ static cc_bool LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device)
static cc_bool LocalPlayer_TriggerSpeed(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
if (Gui.InputGrab) return false;
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
return true;
@ -964,12 +973,16 @@ static void LocalPlayer_ReleaseSpeed(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_TriggerFlyUp(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
if (Gui.InputGrab) return false;
hacks->FlyingUp = true;
return hacks->CanFly && hacks->Enabled;
}
static cc_bool LocalPlayer_TriggerFlyDown(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
if (Gui.InputGrab) return false;
hacks->FlyingDown = true;
return hacks->CanFly && hacks->Enabled;
}

View File

@ -597,18 +597,24 @@ static void InputHandler_CheckZoomFov(void* obj) {
static cc_bool BindTriggered_DeleteBlock(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
MouseStatePress(MOUSE_LEFT);
InputHandler_DeleteBlock();
return true;
}
static cc_bool BindTriggered_PlaceBlock(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
MouseStatePress(MOUSE_RIGHT);
InputHandler_PlaceBlock();
return true;
}
static cc_bool BindTriggered_PickBlock(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
MouseStatePress(MOUSE_MIDDLE);
InputHandler_PickBlock();
return true;
@ -628,27 +634,37 @@ static void BindReleased_PickBlock(int key, struct InputDevice* device) {
static cc_bool BindTriggered_HideFPS(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
Gui.ShowFPS = !Gui.ShowFPS;
return true;
}
static cc_bool BindTriggered_Fullscreen(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
Game_ToggleFullscreen();
return true;
}
static cc_bool BindTriggered_Fog(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
Game_CycleViewDistance();
return true;
}
static cc_bool BindTriggered_HideGUI(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
Game_HideGui = !Game_HideGui;
return true;
}
static cc_bool BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
InputHandler_Toggle(key, &Camera.Smooth,
" &eSmooth camera is &aenabled",
" &eSmooth camera is &cdisabled");
@ -656,6 +672,8 @@ static cc_bool BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
}
static cc_bool BindTriggered_AxisLines(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
InputHandler_Toggle(key, &AxisLinesRenderer_Enabled,
" &eAxis lines (&4X&e, &2Y&e, &1Z&e) now show",
" &eAxis lines no longer show");
@ -663,6 +681,8 @@ static cc_bool BindTriggered_AxisLines(int key, struct InputDevice* device) {
}
static cc_bool BindTriggered_AutoRotate(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
InputHandler_Toggle(key, &AutoRotate_Enabled,
" &eAuto rotate is &aenabled",
" &eAuto rotate is &cdisabled");
@ -670,11 +690,15 @@ static cc_bool BindTriggered_AutoRotate(int key, struct InputDevice* device) {
}
static cc_bool BindTriggered_ThirdPerson(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
Camera_CycleActive();
return true;
}
static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
if (Inventory_CheckChangeSelected() && Inventory_SelectedBlock != BLOCK_AIR) {
/* Don't assign SelectedIndex directly, because we don't want held block
switching positions if they already have air in their inventory hotbar. */
@ -685,11 +709,18 @@ static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
}
static cc_bool BindTriggered_IDOverlay(int key, struct InputDevice* device) {
TexIdsOverlay_Show();
struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS);
if (s) {
Gui_Remove(s);
} else {
TexIdsOverlay_Show();
}
return true;
}
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
if (Gui.InputGrab) return false;
InputHandler_Toggle(key, &Game_BreakableLiquids,
" &eBreakable liquids is &aenabled",
" &eBreakable liquids is &cdisabled");
@ -822,6 +853,16 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
Game_ScreenshotRequested = true; return;
}
triggered = false;
for (i = 0; !was && i < BIND_COUNT; i++)
{
if (!InputBind_Claims(i, key, device)) continue;
Bind_IsTriggered[i] |= device->type;
if (!Bind_OnTriggered[i]) continue;
triggered |= Bind_OnTriggered[i](key, device);
}
for (i = 0; i < Gui.ScreensCount; i++)
{
s = Gui_Screens[i];
@ -842,18 +883,8 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
Gui_ShowPauseMenu(); return;
}
/* These should not be triggered multiple times when holding down */
/* Hotkeys should not be triggered multiple times when holding down */
if (was) return;
triggered = false;
for (i = 0; i < BIND_COUNT; i++)
{
if (!InputBind_Claims(i, key, device)) continue;
Bind_IsTriggered[i] |= device->type;
if (!Bind_OnTriggered[i]) continue;
triggered |= Bind_OnTriggered[i](key, device);
}
if (triggered) {
} else if (key == CCKEY_F5 && Game_ClassicMode) {

View File

@ -2598,11 +2598,7 @@ static void TexIdsOverlay_Render(void* screen, float delta) {
}
static int TexIdsOverlay_KeyDown(void* screen, int key, struct InputDevice* device) {
struct Screen* s = (struct Screen*)screen;
if (!InputBind_Claims(BIND_IDOVERLAY, key, device)) return false;
Gui_Remove(s);
return true;
return false;
}
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {