mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Allow binding controls to 1-9, fix can't activate texture ID overlay while in a UI menu
This commit is contained in:
parent
0f5c74fb53
commit
97c3dd8374
13
src/Entity.c
13
src/Entity.c
@ -848,6 +848,8 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
|
|||||||
|
|
||||||
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
|
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
if (p->Hacks.CanRespawn) {
|
if (p->Hacks.CanRespawn) {
|
||||||
LocalPlayer_DoRespawn(p);
|
LocalPlayer_DoRespawn(p);
|
||||||
return true;
|
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) {
|
static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
if (p->Hacks.CanRespawn) {
|
if (p->Hacks.CanRespawn) {
|
||||||
|
|
||||||
if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
|
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) {
|
static cc_bool LocalPlayer_HandleFly(int key, struct InputDevice* device) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
if (p->Hacks.CanFly && p->Hacks.Enabled) {
|
if (p->Hacks.CanFly && p->Hacks.Enabled) {
|
||||||
HacksComp_SetFlying(&p->Hacks, !p->Hacks.Flying);
|
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) {
|
static cc_bool LocalPlayer_HandleNoclip(int key, struct InputDevice* device) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
||||||
p->Hacks._noclipping = true;
|
p->Hacks._noclipping = true;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
if (p->Hacks.CanNoclip && p->Hacks.Enabled) {
|
if (p->Hacks.CanNoclip && p->Hacks.Enabled) {
|
||||||
if (p->Hacks.WOMStyleHacks) return true; /* don't handle this here */
|
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 HacksComp* hacks = &p->Hacks;
|
||||||
struct PhysicsComp* physics = &p->Physics;
|
struct PhysicsComp* physics = &p->Physics;
|
||||||
int maxJumps;
|
int maxJumps;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
physics->Jumping = true;
|
physics->Jumping = true;
|
||||||
|
|
||||||
if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) {
|
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) {
|
static cc_bool LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device) {
|
||||||
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
||||||
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
|
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
|
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
|
||||||
return true;
|
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) {
|
static cc_bool LocalPlayer_TriggerSpeed(int key, struct InputDevice* device) {
|
||||||
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
||||||
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
|
cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
|
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
|
||||||
return true;
|
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) {
|
static cc_bool LocalPlayer_TriggerFlyUp(int key, struct InputDevice* device) {
|
||||||
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
hacks->FlyingUp = true;
|
hacks->FlyingUp = true;
|
||||||
return hacks->CanFly && hacks->Enabled;
|
return hacks->CanFly && hacks->Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_TriggerFlyDown(int key, struct InputDevice* device) {
|
static cc_bool LocalPlayer_TriggerFlyDown(int key, struct InputDevice* device) {
|
||||||
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
hacks->FlyingDown = true;
|
hacks->FlyingDown = true;
|
||||||
return hacks->CanFly && hacks->Enabled;
|
return hacks->CanFly && hacks->Enabled;
|
||||||
}
|
}
|
||||||
|
@ -597,18 +597,24 @@ static void InputHandler_CheckZoomFov(void* obj) {
|
|||||||
|
|
||||||
|
|
||||||
static cc_bool BindTriggered_DeleteBlock(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_DeleteBlock(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
MouseStatePress(MOUSE_LEFT);
|
MouseStatePress(MOUSE_LEFT);
|
||||||
InputHandler_DeleteBlock();
|
InputHandler_DeleteBlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_PlaceBlock(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_PlaceBlock(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
MouseStatePress(MOUSE_RIGHT);
|
MouseStatePress(MOUSE_RIGHT);
|
||||||
InputHandler_PlaceBlock();
|
InputHandler_PlaceBlock();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_PickBlock(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_PickBlock(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
MouseStatePress(MOUSE_MIDDLE);
|
MouseStatePress(MOUSE_MIDDLE);
|
||||||
InputHandler_PickBlock();
|
InputHandler_PickBlock();
|
||||||
return true;
|
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) {
|
static cc_bool BindTriggered_HideFPS(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
Gui.ShowFPS = !Gui.ShowFPS;
|
Gui.ShowFPS = !Gui.ShowFPS;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_Fullscreen(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_Fullscreen(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
Game_ToggleFullscreen();
|
Game_ToggleFullscreen();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_Fog(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_Fog(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
Game_CycleViewDistance();
|
Game_CycleViewDistance();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cc_bool BindTriggered_HideGUI(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_HideGUI(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
Game_HideGui = !Game_HideGui;
|
Game_HideGui = !Game_HideGui;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
InputHandler_Toggle(key, &Camera.Smooth,
|
InputHandler_Toggle(key, &Camera.Smooth,
|
||||||
" &eSmooth camera is &aenabled",
|
" &eSmooth camera is &aenabled",
|
||||||
" &eSmooth camera is &cdisabled");
|
" &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) {
|
static cc_bool BindTriggered_AxisLines(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
InputHandler_Toggle(key, &AxisLinesRenderer_Enabled,
|
InputHandler_Toggle(key, &AxisLinesRenderer_Enabled,
|
||||||
" &eAxis lines (&4X&e, &2Y&e, &1Z&e) now show",
|
" &eAxis lines (&4X&e, &2Y&e, &1Z&e) now show",
|
||||||
" &eAxis lines no longer 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) {
|
static cc_bool BindTriggered_AutoRotate(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
InputHandler_Toggle(key, &AutoRotate_Enabled,
|
InputHandler_Toggle(key, &AutoRotate_Enabled,
|
||||||
" &eAuto rotate is &aenabled",
|
" &eAuto rotate is &aenabled",
|
||||||
" &eAuto rotate is &cdisabled");
|
" &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) {
|
static cc_bool BindTriggered_ThirdPerson(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
Camera_CycleActive();
|
Camera_CycleActive();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
if (Inventory_CheckChangeSelected() && Inventory_SelectedBlock != BLOCK_AIR) {
|
if (Inventory_CheckChangeSelected() && Inventory_SelectedBlock != BLOCK_AIR) {
|
||||||
/* Don't assign SelectedIndex directly, because we don't want held block
|
/* Don't assign SelectedIndex directly, because we don't want held block
|
||||||
switching positions if they already have air in their inventory hotbar. */
|
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) {
|
static cc_bool BindTriggered_IDOverlay(int key, struct InputDevice* device) {
|
||||||
|
struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS);
|
||||||
|
if (s) {
|
||||||
|
Gui_Remove(s);
|
||||||
|
} else {
|
||||||
TexIdsOverlay_Show();
|
TexIdsOverlay_Show();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
|
||||||
|
if (Gui.InputGrab) return false;
|
||||||
|
|
||||||
InputHandler_Toggle(key, &Game_BreakableLiquids,
|
InputHandler_Toggle(key, &Game_BreakableLiquids,
|
||||||
" &eBreakable liquids is &aenabled",
|
" &eBreakable liquids is &aenabled",
|
||||||
" &eBreakable liquids is &cdisabled");
|
" &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;
|
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++)
|
for (i = 0; i < Gui.ScreensCount; i++)
|
||||||
{
|
{
|
||||||
s = Gui_Screens[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;
|
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;
|
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) {
|
if (triggered) {
|
||||||
} else if (key == CCKEY_F5 && Game_ClassicMode) {
|
} else if (key == CCKEY_F5 && Game_ClassicMode) {
|
||||||
|
@ -2598,11 +2598,7 @@ static void TexIdsOverlay_Render(void* screen, float delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int TexIdsOverlay_KeyDown(void* screen, int key, struct InputDevice* device) {
|
static int TexIdsOverlay_KeyDown(void* screen, int key, struct InputDevice* device) {
|
||||||
struct Screen* s = (struct Screen*)screen;
|
return false;
|
||||||
if (!InputBind_Claims(BIND_IDOVERLAY, key, device)) return false;
|
|
||||||
|
|
||||||
Gui_Remove(s);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user