mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Merge 164a6552bfbc53ef01f9225878fc9d32eb9b0b36 into 7c326bb2a24ada5ab57662a1719669730e4fc9a8
This commit is contained in:
commit
fea1967269
52
src/Entity.c
52
src/Entity.c
@ -853,29 +853,29 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
|
|||||||
p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide);
|
p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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 (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
if (p->Hacks.CanRespawn) {
|
if (p->Hacks.CanRespawn) {
|
||||||
LocalPlayer_DoRespawn(p);
|
LocalPlayer_DoRespawn(p);
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
} else if (!p->_warnedRespawn) {
|
} else if (!p->_warnedRespawn) {
|
||||||
p->_warnedRespawn = true;
|
p->_warnedRespawn = true;
|
||||||
if (hackPermMsgs) Chat_AddRaw("&cRespawning is currently disabled");
|
if (hackPermMsgs) Chat_AddRaw("&cRespawning is currently disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return IPT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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 (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
if (p->Hacks.CanRespawn) {
|
if (p->Hacks.CanRespawn) {
|
||||||
|
|
||||||
if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
|
if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
|
||||||
Chat_AddRaw("&cCannot set spawn midair when noclip is disabled");
|
Chat_AddRaw("&cCannot set spawn midair when noclip is disabled");
|
||||||
return false;
|
return IPT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn is normally centered to match vanilla Minecraft classic */
|
/* Spawn is normally centered to match vanilla Minecraft classic */
|
||||||
@ -897,44 +897,44 @@ static cc_bool LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
|
|||||||
return LocalPlayer_HandleRespawn(key, device);
|
return LocalPlayer_HandleRespawn(key, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_HandleFly(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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 (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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);
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
} else if (!p->_warnedFly) {
|
} else if (!p->_warnedFly) {
|
||||||
p->_warnedFly = true;
|
p->_warnedFly = true;
|
||||||
if (hackPermMsgs) Chat_AddRaw("&cFlying is currently disabled");
|
if (hackPermMsgs) Chat_AddRaw("&cFlying is currently disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return IPT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_HandleNoclip(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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 (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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 IPT_HANDLED; /* don't handle this here */
|
||||||
if (p->Hacks.Noclip) p->Base.Velocity.y = 0;
|
if (p->Hacks.Noclip) p->Base.Velocity.y = 0;
|
||||||
|
|
||||||
HacksComp_SetNoclip(&p->Hacks, !p->Hacks.Noclip);
|
HacksComp_SetNoclip(&p->Hacks, !p->Hacks.Noclip);
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
} else if (!p->_warnedNoclip) {
|
} else if (!p->_warnedNoclip) {
|
||||||
p->_warnedNoclip = true;
|
p->_warnedNoclip = true;
|
||||||
if (hackPermMsgs) Chat_AddRaw("&cNoclip is currently disabled");
|
if (hackPermMsgs) Chat_AddRaw("&cNoclip is currently disabled");
|
||||||
}
|
}
|
||||||
return false;
|
return IPT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_HandleJump(int key, struct InputDevice* device) {
|
static cc_ipt_flags LocalPlayer_HandleJump(int key, struct InputDevice* device) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
|
||||||
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;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
physics->Jumping = true;
|
physics->Jumping = true;
|
||||||
|
|
||||||
if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) {
|
if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) {
|
||||||
@ -945,28 +945,28 @@ static cc_bool LocalPlayer_HandleJump(int key, struct InputDevice* device) {
|
|||||||
PhysicsComp_DoNormalJump(physics);
|
PhysicsComp_DoNormalJump(physics);
|
||||||
physics->MultiJumps++;
|
physics->MultiJumps++;
|
||||||
}
|
}
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
return false;
|
return IPT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cc_bool LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
|
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool LocalPlayer_TriggerSpeed(int key, struct InputDevice* device) {
|
static cc_ipt_flags 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;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
|
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LocalPlayer_ReleaseHalfSpeed(int key, struct InputDevice* device) {
|
static void LocalPlayer_ReleaseHalfSpeed(int key, struct InputDevice* device) {
|
||||||
|
@ -632,71 +632,69 @@ static void BindReleased_PickBlock(int key, struct InputDevice* device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cc_bool BindTriggered_HideFPS(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_HideFPS(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
Gui.ShowFPS = !Gui.ShowFPS;
|
Gui.ShowFPS = !Gui.ShowFPS;
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_Fullscreen(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_Fullscreen(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
Game_ToggleFullscreen();
|
||||||
|
return IPT_HANDLED | IPT_SUPPRESS_UI;
|
||||||
Game_ToggleFullscreen();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_Fog(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_Fog(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
Game_CycleViewDistance();
|
Game_CycleViewDistance();
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static cc_bool BindTriggered_HideGUI(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_HideGUI(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
Game_HideGui = !Game_HideGui;
|
Game_HideGui = !Game_HideGui;
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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");
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_AxisLines(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_AxisLines(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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");
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_AutoRotate(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_AutoRotate(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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");
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_ThirdPerson(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_ThirdPerson(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
Camera_CycleActive();
|
Camera_CycleActive();
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_DropBlock(int key, struct InputDevice* device) {
|
||||||
if (Gui.InputGrab) return false;
|
if (Gui.InputGrab) return IPT_NONE;
|
||||||
|
|
||||||
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
|
||||||
@ -704,17 +702,17 @@ static cc_bool BindTriggered_DropBlock(int key, struct InputDevice* device) {
|
|||||||
Inventory_Set(Inventory.SelectedIndex, BLOCK_AIR);
|
Inventory_Set(Inventory.SelectedIndex, BLOCK_AIR);
|
||||||
Event_RaiseVoid(&UserEvents.HeldBlockChanged);
|
Event_RaiseVoid(&UserEvents.HeldBlockChanged);
|
||||||
}
|
}
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_IDOverlay(int key, struct InputDevice* device) {
|
static cc_ipt_flags BindTriggered_IDOverlay(int key, struct InputDevice* device) {
|
||||||
struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS);
|
struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS);
|
||||||
if (s) {
|
if (s) {
|
||||||
Gui_Remove(s);
|
Gui_Remove(s);
|
||||||
} else {
|
} else {
|
||||||
TexIdsOverlay_Show();
|
TexIdsOverlay_Show();
|
||||||
}
|
}
|
||||||
return true;
|
return IPT_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
|
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
|
||||||
@ -836,7 +834,7 @@ static void OnPointerUp(void* obj, int idx) {
|
|||||||
|
|
||||||
static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) {
|
static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) {
|
||||||
struct Screen* s;
|
struct Screen* s;
|
||||||
cc_bool triggered;
|
cc_ipt_flags triggered_flags;
|
||||||
int i;
|
int i;
|
||||||
if (Input.DownHook && Input.DownHook(key, device)) return;
|
if (Input.DownHook && Input.DownHook(key, device)) return;
|
||||||
|
|
||||||
@ -854,23 +852,24 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
|
|||||||
Game_ScreenshotRequested = true; return;
|
Game_ScreenshotRequested = true; return;
|
||||||
}
|
}
|
||||||
|
|
||||||
triggered = false;
|
triggered_flags = IPT_NONE;
|
||||||
for (i = 0; !was && i < BIND_COUNT; i++)
|
for (i = 0; !was && i < BIND_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (!InputBind_Claims(i, key, device)) continue;
|
if (!InputBind_Claims(i, key, device)) continue;
|
||||||
Bind_IsTriggered[i] |= device->type;
|
Bind_IsTriggered[i] |= device->type;
|
||||||
|
|
||||||
if (!Bind_OnTriggered[i]) continue;
|
if (!Bind_OnTriggered[i]) continue;
|
||||||
triggered |= Bind_OnTriggered[i](key, device);
|
triggered_flags |= Bind_OnTriggered[i](key, device);
|
||||||
}
|
}
|
||||||
|
if (!(triggered_flags & IPT_SUPPRESS_UI)) { //if key is supressing gui's key handling skip it
|
||||||
for (i = 0; i < Gui.ScreensCount; i++)
|
for (i = 0; i < Gui.ScreensCount; i++)
|
||||||
{
|
{
|
||||||
s = Gui_Screens[i];
|
s = Gui_Screens[i];
|
||||||
s->dirty = true;
|
s->dirty = true;
|
||||||
if (s->VTABLE->HandlesInputDown(s, key, device)) return;
|
if (s->VTABLE->HandlesInputDown(s, key, device)) return;
|
||||||
|
}
|
||||||
|
if (Gui.InputGrab) return;
|
||||||
}
|
}
|
||||||
if (Gui.InputGrab) return;
|
|
||||||
|
|
||||||
if (InputDevice_IsPause(key, device)) {
|
if (InputDevice_IsPause(key, device)) {
|
||||||
#ifdef CC_BUILD_WEB
|
#ifdef CC_BUILD_WEB
|
||||||
@ -887,7 +886,7 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
|
|||||||
/* Hotkeys 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;
|
||||||
|
|
||||||
if (triggered) {
|
if (triggered_flags & IPT_HANDLED) {
|
||||||
} else if (key == CCKEY_F5 && Game_ClassicMode) {
|
} else if (key == CCKEY_F5 && Game_ClassicMode) {
|
||||||
int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY;
|
int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY;
|
||||||
Env_SetWeather(weather);
|
Env_SetWeather(weather);
|
||||||
|
@ -53,8 +53,12 @@ cc_bool Input_HandleMouseWheel(float delta);
|
|||||||
void InputHandler_Tick(float delta);
|
void InputHandler_Tick(float delta);
|
||||||
void InputHandler_OnScreensChanged(void);
|
void InputHandler_OnScreensChanged(void);
|
||||||
|
|
||||||
|
typedef cc_uint8 cc_ipt_flags; /*dont know if this is the best place to put this*/
|
||||||
|
#define IPT_NONE 0x00 /* key havent been handled */
|
||||||
|
#define IPT_HANDLED 0x01 /* key has been handled */
|
||||||
|
#define IPT_SUPPRESS_UI 0x02 /* key supresses GUI's key processing*/
|
||||||
|
|
||||||
typedef cc_bool (*BindTriggered)(int key, struct InputDevice* device);
|
typedef cc_ipt_flags (*BindTriggered)(int key, struct InputDevice* device); /*changes this to use 'cc_key_flag' instead of bool*/
|
||||||
typedef void (*BindReleased)(int key, struct InputDevice* device);
|
typedef void (*BindReleased)(int key, struct InputDevice* device);
|
||||||
/* Gets whether the given input binding is currently being triggered */
|
/* Gets whether the given input binding is currently being triggered */
|
||||||
CC_API cc_bool KeyBind_IsPressed(InputBind binding);
|
CC_API cc_bool KeyBind_IsPressed(InputBind binding);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user