Add 'breakable liquids' key bind, Escape resets key bind, fix options in C client

This commit is contained in:
UnknownShadow200 2018-04-24 07:38:11 +10:00
parent fc1263c770
commit 7bca9016c5
22 changed files with 82 additions and 58 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ bld/
[sS]rc/Client/maps
[sS]rc/Client/texturecache
[sS]rc/Client/logs
[sS]rc/Client/options.txt
# Roslyn cache directories
*.ide/

View File

@ -55,7 +55,7 @@ namespace ClassicalSharp.Gui.Screens {
string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags);
if (curHotkey.Text == null) curHotkey.Text = "";
string staysOpen = curHotkey.StaysOpen ? "ON" : "OFF";
bool existed = origHotkey.BaseKey != Key.Unknown;
bool existed = origHotkey.BaseKey != Key.None;
InputWidget input;
input = MenuInputWidget.Create(game, 500, 30, curHotkey.Text, textFont, new StringValidator())
@ -94,13 +94,13 @@ namespace ClassicalSharp.Gui.Screens {
}
void SaveChangesClick(Game game, Widget widget) {
if (origHotkey.BaseKey != Key.Unknown) {
if (origHotkey.BaseKey != Key.None) {
HotkeyList.Remove(origHotkey.BaseKey, origHotkey.Flags);
HotkeyList.UserRemovedHotkey(origHotkey.BaseKey, origHotkey.Flags);
}
MenuInputWidget input = (MenuInputWidget)widgets[actionI];
if (curHotkey.BaseKey != Key.Unknown) {
if (curHotkey.BaseKey != Key.None) {
HotkeyList.Add(curHotkey.BaseKey, curHotkey.Flags,
input.Text.ToString(), curHotkey.StaysOpen);
HotkeyList.UserAddedHotkey(curHotkey.BaseKey, curHotkey.Flags,
@ -110,7 +110,7 @@ namespace ClassicalSharp.Gui.Screens {
}
void RemoveHotkeyClick(Game game, Widget widget) {
if (origHotkey.BaseKey != Key.Unknown) {
if (origHotkey.BaseKey != Key.None) {
HotkeyList.Remove(origHotkey.BaseKey, origHotkey.Flags);
HotkeyList.UserRemovedHotkey(origHotkey.BaseKey, origHotkey.Flags);
}

View File

@ -106,9 +106,9 @@ namespace ClassicalSharp.Gui.Screens {
g.LocalPlayer.Hacks.PushbackPlacing = SetBool(v, OptionsKey.PushbackPlacing);
}
static string GetLiquids(Game g) { return GetBool(g.ModifiableLiquids); }
static string GetLiquids(Game g) { return GetBool(g.BreakableLiquids); }
static void SetLiquids(Game g, string v) {
g.ModifiableLiquids = SetBool(v, OptionsKey.ModifiableLiquids);
g.BreakableLiquids = SetBool(v, OptionsKey.ModifiableLiquids);
}
static string GetSlide(Game g) { return GetBool(g.LocalPlayer.Hacks.NoclipSlide); }

View File

@ -74,8 +74,11 @@ namespace ClassicalSharp.Gui.Screens {
public override bool HandlesKeyDown(Key key) {
if (curI == -1) return base.HandlesKeyDown(key);
KeyBind bind = binds[curI];
if (key == Key.Escape) key = game.Input.Keys.GetDefault(bind);
game.Input.Keys[bind] = key;
game.Input.Keys[binds[curI]] = key;
ButtonWidget curButton = (ButtonWidget)widgets[curI];
curButton.SetText(ButtonText(curI));
curI = -1;

View File

@ -111,14 +111,15 @@ namespace ClassicalSharp.Gui.Screens {
public override void Init() {
base.Init();
binds = new KeyBind[11];
binds = new KeyBind[12];
binds[0] = KeyBind.ExtInput; binds[1] = KeyBind.HideFps; binds[2] = KeyBind.HideGui;
binds[3] = KeyBind.HotbarSwitching; binds[4] = KeyBind.DropBlock;
binds[5] = KeyBind.Screenshot; binds[6] = KeyBind.Fullscreen; binds[7] = KeyBind.AxisLines;
binds[8] = KeyBind.Autorotate; binds[9] = KeyBind.SmoothCamera; binds[10] = KeyBind.IDOverlay;
binds[11] = KeyBind.BreakableLiquids;
desc = new string[] { "Show ext input", "Hide FPS", "Hide gui", "Hotbar switching", "Drop block",
"Screenshot", "Fullscreen", "Show axis lines", "Auto-rotate", "Smooth camera", "ID overlay" };
"Screenshot", "Fullscreen", "Show axis lines", "Auto-rotate", "Smooth camera", "ID overlay", "Breakable liquids" };
leftPage = SwitchHacks;
rightPage = SwitchMouse;

View File

@ -191,7 +191,7 @@ namespace ClassicalSharp {
DefaultFov = Options.GetInt(OptionsKey.FieldOfView, 1, 150, 70);
Fov = DefaultFov;
ZoomFov = DefaultFov;
ModifiableLiquids = !ClassicMode && Options.GetBool(OptionsKey.ModifiableLiquids, false);
BreakableLiquids = !ClassicMode && Options.GetBool(OptionsKey.ModifiableLiquids, false);
CameraClipping = Options.GetBool(OptionsKey.CameraClipping, true);
MaxChunkUpdates = Options.GetInt(OptionsKey.MaxChunkUpdates, 4, 1024, 30);

View File

@ -190,7 +190,7 @@ namespace ClassicalSharp {
public bool ClickableChat, HideGui, ShowFPS;
internal float HotbarScale = 1, ChatScale = 1, InventoryScale = 1;
public bool ViewBobbing, ShowBlockInHand;
public bool ModifiableLiquids;
public bool BreakableLiquids;
public int SoundsVolume, MusicVolume;
public Vector3 CurrentCameraPos;

View File

@ -145,7 +145,7 @@ namespace ClassicalSharp {
if (BlockInfo.Draw[block] == DrawType.Sprite) return true;
if (BlockInfo.Collide[block] != CollideType.Liquid) return true;
return ModifiableLiquids && BlockInfo.CanPlace[block] && BlockInfo.CanDelete[block];
return BreakableLiquids && BlockInfo.CanPlace[block] && BlockInfo.CanDelete[block];
}

View File

@ -240,6 +240,10 @@ namespace ClassicalSharp {
} else if (key == Keys[KeyBind.IDOverlay]) {
if (game.Gui.overlays.Count > 0) return true;
game.Gui.ShowOverlay(new TexIdsOverlay(game), false);
} else if (key == Keys[KeyBind.BreakableLiquids]) {
Toggle(key, ref game.BreakableLiquids,
" &eBreakable liquids is &aenabled",
" &eBreakable liquids is &cdisabled");
} else {
return false;
}

View File

@ -13,6 +13,7 @@ namespace ClassicalSharp {
Screenshot, Fullscreen, ThirdPerson, HideGui, AxisLines,
ZoomScrolling, HalfSpeed, MouseLeft, MouseMiddle, MouseRight,
Autorotate, HotbarSwitching, SmoothCamera, DropBlock, IDOverlay,
BreakableLiquids,
#pragma warning restore 1591
}
@ -35,7 +36,7 @@ namespace ClassicalSharp {
public KeyMap() {
// We can't use enum array initaliser because this causes problems when building with mono
// and running on default .NET (https://bugzilla.xamarin.com/show_bug.cgi?id=572)
keys = new Key[35];
keys = new Key[36];
keys[0] = Key.W; keys[1] = Key.S; keys[2] = Key.A; keys[3] = Key.D;
keys[4] = Key.Space; keys[5] = Key.R; keys[6] = Key.Enter; keys[7] = Key.T;
keys[8] = Key.B; keys[9] = Key.F; keys[10] = Key.Enter;
@ -45,9 +46,9 @@ namespace ClassicalSharp {
keys[20] = Key.F12; keys[21] = Key.F11; keys[22] = Key.F5;
keys[23] = Key.F1; keys[24] = Key.F7; keys[25] = Key.C;
keys[26] = Key.ControlLeft;
keys[27] = Key.Unknown; keys[28] = Key.Unknown; keys[29] = Key.Unknown;
keys[27] = Key.None; keys[28] = Key.None; keys[29] = Key.None;
keys[30] = Key.F6; keys[31] = Key.AltLeft; keys[32] = Key.F8; keys[33] = Key.G;
keys[34] = Key.F10;
keys[34] = Key.F10; keys[35] = Key.None;
defaultKeys = new Key[keys.Length];
for (int i = 0; i < defaultKeys.Length; i++)
@ -61,9 +62,9 @@ namespace ClassicalSharp {
for (int i = 0; i < names.Length; i++) {
string key = "key-" + names[i];
Key mapping = Options.GetEnum(key, keys[i]);
if (mapping != Key.Escape)
keys[i] = mapping;
if (mapping != Key.Escape) keys[i] = mapping;
}
keys[11] = Key.Escape;
}
void SaveKeyBindings() {

View File

@ -100,7 +100,7 @@ namespace ClassicalSharp.Hotkeys {
// Then try to parse the key and value
Key hotkey; byte flags; bool moreInput;
if (!Utils.TryParseEnum(strKey, Key.Unknown, out hotkey) ||
if (!Utils.TryParseEnum(strKey, Key.None, out hotkey) ||
!Byte.TryParse(strFlags, out flags) ||
!Boolean.TryParse(strMoreInput, out moreInput) ||
strText.Length == 0) {

View File

@ -25,7 +25,7 @@ namespace ClassicalSharp.Hotkeys {
}
static LwjglToKey() {
Add(Key.Unknown); Add(Key.Escape);
Add(Key.None); Add(Key.Escape);
for (int i = 0; i < 9; i++)
Add((Key)(i + Key.Number1));
Add(Key.Number0); Add(Key.Minus);

View File

@ -101,7 +101,7 @@ namespace ClassicalSharp.Network.Protocols {
#if !ANDROID
if (keyCode < 0 || keyCode > 255) return;
Key key = LwjglToKey.Map[keyCode];
if (key == Key.Unknown) return;
if (key == Key.None) return;
Utils.LogDebug("CPE Hotkey added: " + key + "," + keyMods + " : " + action);
if (action == "") {

View File

@ -29,7 +29,7 @@ namespace OpenTK.Input {
/// <summary> The available keyboard keys. </summary>
public enum Key : int {
// Key outside the known keys
Unknown = 0,
None = 0,
// Modifiers
ShiftLeft, ShiftRight, ControlLeft, ControlRight,

View File

@ -206,7 +206,7 @@ bool Game_CanPick(BlockID block) {
if (Block_Draw[block] == DRAW_SPRITE) return true;
if (Block_Collide[block] != COLLIDE_LIQUID) return true;
return Game_ModifiableLiquids && Block_CanPlace[block] && Block_CanDelete[block];
return Game_BreakableLiquids && Block_CanPlace[block] && Block_CanDelete[block];
}
void Game_SetDefaultSkinType(Bitmap* bmp) {
@ -353,7 +353,7 @@ void Game_LoadOptions(void) {
Game_DefaultFov = Options_GetInt(OPT_FIELD_OF_VIEW, 1, 150, 70);
Game_Fov = Game_DefaultFov;
Game_ZoomFov = Game_DefaultFov;
Game_ModifiableLiquids = !Game_ClassicMode && Options_GetBool(OPT_MODIFIABLE_LIQUIDS, false);
Game_BreakableLiquids = !Game_ClassicMode && Options_GetBool(OPT_MODIFIABLE_LIQUIDS, false);
Game_CameraClipping = Options_GetBool(OPT_CAMERA_CLIPPING, true);
Game_MaxChunkUpdates = Options_GetInt(OPT_MAX_CHUNK_UPDATES, 4, 1024, 30);

View File

@ -64,7 +64,7 @@ bool Game_ViewBobbing;
bool Game_ShowBlockInHand;
Int32 Game_SoundsVolume;
Int32 Game_MusicVolume;
bool Game_ModifiableLiquids;
bool Game_BreakableLiquids;
Int32 Game_MaxChunkUpdates;
Vector3 Game_CurrentCameraPos;

View File

@ -16,7 +16,7 @@
"U", "V", "W", "X", "Y", "Z"
const UInt8* Key_Names[Key_Count] = {
"Unknown",
"None",
"ShiftLeft", "ShiftRight", "ControlLeft", "ControlRight",
"AltLeft", "AltRight", "WinLeft", "WinRight", "Menu",
Key_Function_Names,
@ -116,9 +116,9 @@ Key KeyBind_Defaults[KeyBind_Count] = {
Key_Tab, Key_ShiftLeft, Key_X, Key_Z,
Key_Q, Key_E, Key_AltLeft, Key_F3,
Key_F12, Key_F11, Key_F5, Key_F1,
Key_F7, Key_C, Key_ControlLeft, Key_Unknown,
Key_Unknown, Key_Unknown, Key_F6, Key_AltLeft,
Key_F8, Key_G, Key_F10,
Key_F7, Key_C, Key_ControlLeft, Key_None,
Key_None, Key_None, Key_F6, Key_AltLeft,
Key_F8, Key_G, Key_F10, Key_None,
};
const UInt8* KeyBind_Names[KeyBind_Count] = {
"Forward", "Back", "Left", "Right",
@ -129,7 +129,7 @@ const UInt8* KeyBind_Names[KeyBind_Count] = {
"Screenshot", "Fullscreen", "ThirdPerson", "HideGUI",
"AxisLines", "ZoomScrolling", "HalfSpeed", "MouseLeft",
"MouseMiddle", "MouseRight", "AutoRotate", "HotbarSwitching",
"SmoothCamera", "DropBlock", "IDOverlay",
"SmoothCamera", "DropBlock", "IDOverlay", "BreakableLiquids",
};
Key KeyBind_Get(KeyBind binding) { return KeyBind_Keys[binding]; }
@ -145,9 +145,10 @@ void KeyBind_Load(void) {
for (i = 0; i < KeyBind_Count; i++) {
KeyBind_MakeName(name);
Key mapping = Options_GetEnum(name.buffer, KeyBind_Keys[i], Key_Names, Key_Count);
Key mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], Key_Names, Key_Count);
if (mapping != Key_Escape) KeyBind_Keys[i] = mapping;
}
KeyBind_Keys[KeyBind_PauseOrExit] = Key_Escape;
}
void KeyBind_Save(void) {
@ -157,7 +158,7 @@ void KeyBind_Save(void) {
for (i = 0; i < KeyBind_Count; i++) {
KeyBind_MakeName(name);
String value = String_FromReadonly(Key_Names[i]);
String value = String_FromReadonly(Key_Names[KeyBind_Keys[i]]);
Options_Set(name.buffer, &value);
}
}
@ -302,9 +303,9 @@ void Hotkeys_Init(void) {
String strText = String_UNSAFE_SubstringAt(&value, valueSplit + 1);
/* Then try to parse the key and value */
Key hotkey = Utils_ParseEnum(&strKey, Key_Unknown, Key_Names, Array_Elems(Key_Names));
Key hotkey = Utils_ParseEnum(&strKey, Key_None, Key_Names, Array_Elems(Key_Names));
UInt8 flags; bool moreInput;
if (hotkey == Key_Unknown || strText.length == 0 || !Convert_TryParseUInt8(&strFlags, &flags)
if (hotkey == Key_None || strText.length == 0 || !Convert_TryParseUInt8(&strFlags, &flags)
|| !Convert_TryParseBool(&strMoreInput, &moreInput)) { continue; }
Hotkeys_Add(hotkey, flags, &strText, moreInput);

View File

@ -31,7 +31,7 @@
*/
typedef enum Key_ {
Key_Unknown, /* Key outside the known keys */
Key_None, /* Key outside the known keys */
Key_ShiftLeft, Key_ShiftRight, Key_ControlLeft, Key_ControlRight,
Key_AltLeft, Key_AltRight, Key_WinLeft, Key_WinRight, Key_Menu,
@ -104,7 +104,7 @@ typedef enum KeyBind_ {
KeyBind_Screenshot, KeyBind_Fullscreen, KeyBind_ThirdPerson, KeyBind_HideGui,
KeyBind_AxisLines, KeyBind_ZoomScrolling, KeyBind_HalfSpeed, KeyBind_MouseLeft,
KeyBind_MouseMiddle, KeyBind_MouseRight, KeyBind_Autorotate, KeyBind_HotbarSwitching,
KeyBind_SmoothCamera, KeyBind_DropBlock, KeyBind_IDOverlay,
KeyBind_SmoothCamera, KeyBind_DropBlock, KeyBind_IDOverlay, KeyBind_BreakableLiquids,
KeyBind_Count
} KeyBind;

View File

@ -181,6 +181,10 @@ bool InputHandler_HandleCoreKey(Key key) {
if (Gui_OverlaysCount > 0) return true;
Screen* overlay = TexIdsOverlay_MakeInstance();
Gui_ShowOverlay(overlay, false);
} else if (key == KeyBind_Get(KeyBind_BreakableLiquids)) {
InputHandler_Toggle(key, &Game_BreakableLiquids,
" &eBreakable liquids is &aenabled",
" &eBreakable liquids is &cdisabled");
} else {
return false;
}

View File

@ -103,7 +103,7 @@ typedef struct KeyBindingsScreen_ {
MenuScreen_Layout
Int32 CurI, BindsCount;
const UInt8** Descs;
KeyBind* Binds;
UInt8* Binds;
Widget_LeftClick LeftPage, RightPage;
ButtonWidget* Buttons;
TextWidget Title;
@ -902,13 +902,13 @@ void EditHotkeyScreen_LeaveOpen(GuiElement* elem, GuiElement* widget) {
void EditHotkeyScreen_SaveChanges(GuiElement* elem, GuiElement* widget) {
EditHotkeyScreen* screen = (EditHotkeyScreen*)elem;
HotkeyData hotkey = screen->OrigHotkey;
if (hotkey.BaseKey != Key_Unknown) {
if (hotkey.BaseKey != Key_None) {
Hotkeys_Remove(hotkey.BaseKey, hotkey.Flags);
Hotkeys_UserRemovedHotkey(hotkey.BaseKey, hotkey.Flags);
}
hotkey = screen->CurHotkey;
if (hotkey.BaseKey != Key_Unknown) {
if (hotkey.BaseKey != Key_None) {
String text = screen->Input.Base.Text;
Hotkeys_Add(hotkey.BaseKey, hotkey.Flags, &text, hotkey.StaysOpen);
Hotkeys_UserAddedHotkey(hotkey.BaseKey, hotkey.Flags, hotkey.StaysOpen, &text);
@ -919,7 +919,7 @@ void EditHotkeyScreen_SaveChanges(GuiElement* elem, GuiElement* widget) {
void EditHotkeyScreen_RemoveHotkey(GuiElement* elem, GuiElement* widget) {
EditHotkeyScreen* screen = (EditHotkeyScreen*)elem;
HotkeyData hotkey = screen->OrigHotkey;
if (hotkey.BaseKey != Key_Unknown) {
if (hotkey.BaseKey != Key_None) {
Hotkeys_Remove(hotkey.BaseKey, hotkey.Flags);
Hotkeys_UserRemovedHotkey(hotkey.BaseKey, hotkey.Flags);
}
@ -989,7 +989,7 @@ void EditHotkeyScreen_ContextRecreated(void* obj) {
MenuInputValidator validator = MenuInputValidator_String();
String text = String_MakeNull();
bool existed = screen->OrigHotkey.BaseKey != Key_Unknown;
bool existed = screen->OrigHotkey.BaseKey != Key_None;
if (existed) {
text = StringsBuffer_UNSAFE_Get(&HotkeysText, screen->OrigHotkey.TextIndex);
}
@ -1495,7 +1495,7 @@ void HotkeyListScreen_EntryClick(GuiElement* screenElem, GuiElement* w) {
if (String_ContainsString(&value, &shift)) flags |= HOTKEYS_FLAG_SHIFT;
if (String_ContainsString(&value, &alt)) flags |= HOTKEYS_FLAG_ALT;
Key baseKey = Utils_ParseEnum(&key, Key_Unknown, Key_Names, Key_Count);
Key baseKey = Utils_ParseEnum(&key, Key_None, Key_Names, Key_Count);
Int32 i;
for (i = 0; i < HotkeysText.Count; i++) {
HotkeyData h = HotkeysList[i];
@ -1690,7 +1690,10 @@ void KeyBindingsScreen_Init(GuiElement* elem) {
bool KeyBindingsScreen_HandlesKeyDown(GuiElement* elem, Key key) {
KeyBindingsScreen* screen = (KeyBindingsScreen*)elem;
if (screen->CurI == -1) return MenuScreen_HandlesKeyDown(elem, key);
KeyBind_Set(screen->Binds[screen->CurI], key);
KeyBind bind = screen->Binds[screen->CurI];
if (key == Key_Escape) key = KeyBind_GetDefault(bind);
KeyBind_Set(bind, key);
UInt8 textBuffer[String_BufferSize(STRING_SIZE)];
String text = String_InitAndClearArray(textBuffer);
@ -1719,7 +1722,7 @@ bool KeyBindingsScreen_HandlesMouseDown(GuiElement* elem, Int32 x, Int32 y, Mous
return true;
}
KeyBindingsScreen* KeyBindingsScreen_Make(Int32 bindsCount, KeyBind* binds, const UInt8** descs, ButtonWidget* buttons, Widget** widgets, Menu_ContextFunc contextRecreated) {
KeyBindingsScreen* KeyBindingsScreen_Make(Int32 bindsCount, UInt8* binds, const UInt8** descs, ButtonWidget* buttons, Widget** widgets, Menu_ContextFunc contextRecreated) {
KeyBindingsScreen* screen = &KeyBindingsScreen_Instance;
MenuScreen_MakeInstance((MenuScreen*)screen, widgets, bindsCount + 4, contextRecreated);
KeyBindingsScreen_VTABLE = *screen->VTABLE;
@ -1755,7 +1758,7 @@ void ClassicKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* ClassicKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[10] = { KeyBind_Forward, KeyBind_Back, KeyBind_Jump, KeyBind_Chat, KeyBind_SetSpawn, KeyBind_Left, KeyBind_Right, KeyBind_Inventory, KeyBind_ToggleFog, KeyBind_Respawn };
static UInt8 binds[10] = { KeyBind_Forward, KeyBind_Back, KeyBind_Jump, KeyBind_Chat, KeyBind_SetSpawn, KeyBind_Left, KeyBind_Right, KeyBind_Inventory, KeyBind_ToggleFog, KeyBind_Respawn };
static const UInt8* descs[10] = { "Forward", "Back", "Jump", "Chat", "Save loc", "Left", "Right", "Build", "Toggle fog", "Load loc" };
static ButtonWidget buttons[10];
static Widget* widgets[10 + 4];
@ -1775,7 +1778,7 @@ void ClassicHacksKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* ClassicHacksKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[6] = { KeyBind_Speed, KeyBind_NoClip, KeyBind_HalfSpeed, KeyBind_Fly, KeyBind_FlyUp, KeyBind_FlyDown };
static UInt8 binds[6] = { KeyBind_Speed, KeyBind_NoClip, KeyBind_HalfSpeed, KeyBind_Fly, KeyBind_FlyUp, KeyBind_FlyDown };
static const UInt8* descs[6] = { "Speed", "Noclip", "Half speed", "Fly", "Fly up", "Fly down" };
static ButtonWidget buttons[6];
static Widget* widgets[6 + 4];
@ -1795,7 +1798,7 @@ void NormalKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* NormalKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[12] = { KeyBind_Forward, KeyBind_Back, KeyBind_Jump, KeyBind_Chat, KeyBind_SetSpawn, KeyBind_PlayerList, KeyBind_Left, KeyBind_Right, KeyBind_Inventory, KeyBind_ToggleFog, KeyBind_Respawn, KeyBind_SendChat };
static UInt8 binds[12] = { KeyBind_Forward, KeyBind_Back, KeyBind_Jump, KeyBind_Chat, KeyBind_SetSpawn, KeyBind_PlayerList, KeyBind_Left, KeyBind_Right, KeyBind_Inventory, KeyBind_ToggleFog, KeyBind_Respawn, KeyBind_SendChat };
static const UInt8* descs[12] = { "Forward", "Back", "Jump", "Chat", "Set spawn", "Player list", "Left", "Right", "Inventory", "Toggle fog", "Respawn", "Send chat" };
static ButtonWidget buttons[12];
static Widget* widgets[12 + 4];
@ -1815,7 +1818,7 @@ void HacksKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* HacksKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[8] = { KeyBind_Speed, KeyBind_NoClip, KeyBind_HalfSpeed, KeyBind_ZoomScrolling, KeyBind_Fly, KeyBind_FlyUp, KeyBind_FlyDown, KeyBind_ThirdPerson };
static UInt8 binds[8] = { KeyBind_Speed, KeyBind_NoClip, KeyBind_HalfSpeed, KeyBind_ZoomScrolling, KeyBind_Fly, KeyBind_FlyUp, KeyBind_FlyDown, KeyBind_ThirdPerson };
static const UInt8* descs[8] = { "Speed", "Noclip", "Half speed", "Scroll zoom", "Fly", "Fly up", "Fly down", "Third person" };
static ButtonWidget buttons[8];
static Widget* widgets[8 + 4];
@ -1836,10 +1839,10 @@ void OtherKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* OtherKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[11] = { KeyBind_ExtInput, KeyBind_HideFps, KeyBind_HideGui, KeyBind_HotbarSwitching, KeyBind_DropBlock,KeyBind_Screenshot, KeyBind_Fullscreen, KeyBind_AxisLines, KeyBind_Autorotate, KeyBind_SmoothCamera, KeyBind_IDOverlay };
static const UInt8* descs[11] = { "Show ext input", "Hide FPS", "Hide gui", "Hotbar switching", "Drop block", "Screenshot", "Fullscreen", "Show axis lines", "Auto-rotate", "Smooth camera", "ID overlay" };
static ButtonWidget buttons[11];
static Widget* widgets[11 + 4];
static UInt8 binds[12] = { KeyBind_ExtInput, KeyBind_HideFps, KeyBind_HideGui, KeyBind_HotbarSwitching, KeyBind_DropBlock,KeyBind_Screenshot, KeyBind_Fullscreen, KeyBind_AxisLines, KeyBind_Autorotate, KeyBind_SmoothCamera, KeyBind_IDOverlay, KeyBind_BreakableLiquids };
static const UInt8* descs[12] = { "Show ext input", "Hide FPS", "Hide gui", "Hotbar switching", "Drop block", "Screenshot", "Fullscreen", "Show axis lines", "Auto-rotate", "Smooth camera", "ID overlay", "Breakable liquids" };
static ButtonWidget buttons[12];
static Widget* widgets[12 + 4];
KeyBindingsScreen* screen = KeyBindingsScreen_Make(Array_Elems(binds), binds, descs, buttons, widgets, OtherKeyBindingsScreen_ContextRecreated);
screen->LeftPage = Menu_SwitchKeysHacks;
@ -1863,7 +1866,7 @@ void MouseKeyBindingsScreen_ContextRecreated(void* obj) {
}
Screen* MouseKeyBindingsScreen_MakeInstance(void) {
static KeyBind binds[3] = { KeyBind_MouseLeft, KeyBind_MouseMiddle, KeyBind_MouseRight };
static UInt8 binds[3] = { KeyBind_MouseLeft, KeyBind_MouseMiddle, KeyBind_MouseRight };
static const UInt8* descs[3] = { "Left", "Middle", "Right" };
static ButtonWidget buttons[3];
static Widget* widgets[3 + 4 + 1];
@ -2646,9 +2649,9 @@ void HacksSettingsScreen_SetPushback(STRING_PURE String* v) {
LocalPlayer_Instance.Hacks.PushbackPlacing = Menu_SetBool(v, OPT_PUSHBACK_PLACING);
}
void HacksSettingsScreen_GetLiquids(STRING_TRANSIENT String* v) { Menu_GetBool(v, Game_ModifiableLiquids); }
void HacksSettingsScreen_GetLiquids(STRING_TRANSIENT String* v) { Menu_GetBool(v, Game_BreakableLiquids); }
void HacksSettingsScreen_SetLiquids(STRING_PURE String* v) {
Game_ModifiableLiquids = Menu_SetBool(v, OPT_MODIFIABLE_LIQUIDS);
Game_BreakableLiquids = Menu_SetBool(v, OPT_MODIFIABLE_LIQUIDS);
}
void HacksSettingsScreen_GetSlide(STRING_TRANSIENT String* v) { Menu_GetBool(v, LocalPlayer_Instance.Hacks.NoclipSlide); }
@ -2706,7 +2709,7 @@ void HacksSettingsScreen_ContextRecreated(void* obj) {
MenuOptionsScreen_Make(screen, 5, 1, -150, "Full block stepping", MenuOptionsScreen_Bool,
HacksSettingsScreen_GetFullStep, HacksSettingsScreen_SetFullStep);
MenuOptionsScreen_Make(screen, 6, 1, -100, "Modifiable liquids", MenuOptionsScreen_Bool,
MenuOptionsScreen_Make(screen, 6, 1, -100, "Breakable liquids", MenuOptionsScreen_Bool,
HacksSettingsScreen_GetLiquids, HacksSettingsScreen_SetLiquids);
MenuOptionsScreen_Make(screen, 7, 1, -50, "Pushback placing", MenuOptionsScreen_Bool,
HacksSettingsScreen_GetPushback, HacksSettingsScreen_SetPushback);
@ -2741,7 +2744,6 @@ Screen* HacksSettingsScreen_MakeInstance(void) {
static const UInt8* descs[Array_Elems(buttons)];
descs[2] = "&eIf &fON&e, then the third person cameras will limit%" "&etheir zoom distance if they hit a solid block.";
descs[3] = "&eSets how many blocks high you can jump up.%" "&eNote: You jump much higher when holding down the Speed key binding.";
descs[6] = "&eIf &fON&e, then water/lava can be placed and%" "&edeleted the same way as any other block.";
descs[7] = \
"&eIf &fON&e, placing blocks that intersect your own position cause%" \
"&ethe block to be placed, and you to be moved out of the way.%" \

View File

@ -672,8 +672,15 @@ void StringsBuffer_Remove(StringsBuffer* buffer, UInt32 index) {
for (i = start; i < end; i++) {
buffer->TextBuffer[i - len] = buffer->TextBuffer[i];
}
/* adjust text offset of elements after this element */
/* Elements may not be in order so most account for that */
UInt32 flagsLen = len << STRINGSBUFFER_LEN_SHIFT;
for (i = index; i < buffer->Count; i++) {
buffer->FlagsBuffer[i] = buffer->FlagsBuffer[i + 1];
if (buffer->FlagsBuffer[i] >= flags) {
buffer->FlagsBuffer[i] -= flagsLen;
}
}
buffer->Count--;

View File

@ -175,7 +175,7 @@ Key Window_MapKey(WPARAM key) {
case VK_LEFT: return Key_Left;
case VK_RIGHT: return Key_Right;
}
return Key_Unknown;
return Key_None;
}
LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
@ -378,7 +378,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
default:
mappedKey = Window_MapKey(wParam);
if (mappedKey != Key_Unknown) {
if (mappedKey != Key_None) {
Key_SetPressed(mappedKey, pressed);
}
return 0;