mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
minor cleanup
This commit is contained in:
parent
e6384d0100
commit
538a0c1f35
@ -388,7 +388,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
public override bool HandlesKeyUp(Key key) {
|
public override bool HandlesKeyUp(Key key) {
|
||||||
if (!HandlesAllInput) return false;
|
if (!HandlesAllInput) return false;
|
||||||
|
|
||||||
if (game.Server.SupportsFullCP437 && key == game.Input.Keys[KeyBind.ExtInput]) {
|
if (game.Server.SupportsFullCP437 && key == game.Mapping(KeyBind.ExtInput)) {
|
||||||
if (game.window.Focused) altText.SetActive(!altText.Active);
|
if (game.window.Focused) altText.SetActive(!altText.Active);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,7 +55,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags);
|
string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags);
|
||||||
if (curHotkey.Text == null) curHotkey.Text = "";
|
if (curHotkey.Text == null) curHotkey.Text = "";
|
||||||
string staysOpen = curHotkey.StaysOpen ? "ON" : "OFF";
|
string staysOpen = curHotkey.StaysOpen ? "ON" : "OFF";
|
||||||
bool existed = origHotkey.BaseKey != Key.None;
|
bool existed = origHotkey.Trigger != Key.None;
|
||||||
|
|
||||||
InputWidget input;
|
InputWidget input;
|
||||||
input = MenuInputWidget.Create(game, 500, 30, curHotkey.Text, textFont, new StringValidator())
|
input = MenuInputWidget.Create(game, 500, 30, curHotkey.Text, textFont, new StringValidator())
|
||||||
@ -63,7 +63,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
input.ShowCaret = true;
|
input.ShowCaret = true;
|
||||||
|
|
||||||
widgets = new Widget[] {
|
widgets = new Widget[] {
|
||||||
Make(0, -150, "Key: " + curHotkey.BaseKey, BaseKeyClick),
|
Make(0, -150, "Key: " + curHotkey.Trigger, BaseKeyClick),
|
||||||
Make(0, -100, "Modifiers:" + flags, ModifiersClick),
|
Make(0, -100, "Modifiers:" + flags, ModifiersClick),
|
||||||
input,
|
input,
|
||||||
Make(-100, 10, "Input stays open: " + staysOpen, LeaveOpenClick),
|
Make(-100, 10, "Input stays open: " + staysOpen, LeaveOpenClick),
|
||||||
@ -94,25 +94,25 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SaveChangesClick(Game game, Widget widget) {
|
void SaveChangesClick(Game game, Widget widget) {
|
||||||
if (origHotkey.BaseKey != Key.None) {
|
if (origHotkey.Trigger != Key.None) {
|
||||||
HotkeyList.Remove(origHotkey.BaseKey, origHotkey.Flags);
|
HotkeyList.Remove(origHotkey.Trigger, origHotkey.Flags);
|
||||||
HotkeyList.UserRemovedHotkey(origHotkey.BaseKey, origHotkey.Flags);
|
HotkeyList.UserRemovedHotkey(origHotkey.Trigger, origHotkey.Flags);
|
||||||
}
|
}
|
||||||
MenuInputWidget input = (MenuInputWidget)widgets[actionI];
|
MenuInputWidget input = (MenuInputWidget)widgets[actionI];
|
||||||
|
|
||||||
if (curHotkey.BaseKey != Key.None) {
|
if (curHotkey.Trigger != Key.None) {
|
||||||
HotkeyList.Add(curHotkey.BaseKey, curHotkey.Flags,
|
HotkeyList.Add(curHotkey.Trigger, curHotkey.Flags,
|
||||||
input.Text.ToString(), curHotkey.StaysOpen);
|
input.Text.ToString(), curHotkey.StaysOpen);
|
||||||
HotkeyList.UserAddedHotkey(curHotkey.BaseKey, curHotkey.Flags,
|
HotkeyList.UserAddedHotkey(curHotkey.Trigger, curHotkey.Flags,
|
||||||
curHotkey.StaysOpen, input.Text.ToString());
|
curHotkey.StaysOpen, input.Text.ToString());
|
||||||
}
|
}
|
||||||
game.Gui.SetNewScreen(new HotkeyListScreen(game));
|
game.Gui.SetNewScreen(new HotkeyListScreen(game));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveHotkeyClick(Game game, Widget widget) {
|
void RemoveHotkeyClick(Game game, Widget widget) {
|
||||||
if (origHotkey.BaseKey != Key.None) {
|
if (origHotkey.Trigger != Key.None) {
|
||||||
HotkeyList.Remove(origHotkey.BaseKey, origHotkey.Flags);
|
HotkeyList.Remove(origHotkey.Trigger, origHotkey.Flags);
|
||||||
HotkeyList.UserRemovedHotkey(origHotkey.BaseKey, origHotkey.Flags);
|
HotkeyList.UserRemovedHotkey(origHotkey.Trigger, origHotkey.Flags);
|
||||||
}
|
}
|
||||||
game.Gui.SetNewScreen(new HotkeyListScreen(game));
|
game.Gui.SetNewScreen(new HotkeyListScreen(game));
|
||||||
}
|
}
|
||||||
@ -131,8 +131,8 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
void FocusKeyDown(Key key) {
|
void FocusKeyDown(Key key) {
|
||||||
if (selectedI == keyI) {
|
if (selectedI == keyI) {
|
||||||
curHotkey.BaseKey = key;
|
curHotkey.Trigger = key;
|
||||||
SetButton(keyI, "Key: " + curHotkey.BaseKey);
|
SetButton(keyI, "Key: " + curHotkey.Trigger);
|
||||||
supressNextPress = true;
|
supressNextPress = true;
|
||||||
} else if (selectedI == modifyI) {
|
} else if (selectedI == modifyI) {
|
||||||
if (key == Key.ControlLeft || key == Key.ControlRight) curHotkey.Flags |= 1;
|
if (key == Key.ControlLeft || key == Key.ControlRight) curHotkey.Flags |= 1;
|
||||||
@ -151,7 +151,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
if (selectedI == -1) return;
|
if (selectedI == -1) return;
|
||||||
|
|
||||||
if (selectedI == keyI) {
|
if (selectedI == keyI) {
|
||||||
SetButton(keyI, "Key: " + curHotkey.BaseKey);
|
SetButton(keyI, "Key: " + curHotkey.Trigger);
|
||||||
} else if (selectedI == modifyI) {
|
} else if (selectedI == modifyI) {
|
||||||
string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags);
|
string flags = HotkeyListScreen.MakeFlagsString(curHotkey.Flags);
|
||||||
SetButton(modifyI, "Modifiers:" + flags);
|
SetButton(modifyI, "Modifiers:" + flags);
|
||||||
|
@ -17,7 +17,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Hotkey hKey = HotkeyList.Hotkeys[i];
|
Hotkey hKey = HotkeyList.Hotkeys[i];
|
||||||
entries[i] = hKey.BaseKey + " |" + MakeFlagsString(hKey.Flags);
|
entries[i] = hKey.Trigger + " |" + MakeFlagsString(hKey.Flags);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < items; i++)
|
for (int i = 0; i < items; i++)
|
||||||
entries[count + i] = empty;
|
entries[count + i] = empty;
|
||||||
@ -51,7 +51,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
Key baseKey = (Key)Enum.Parse(typeof(Key), key);
|
Key baseKey = (Key)Enum.Parse(typeof(Key), key);
|
||||||
for (int i = 0; i < HotkeyList.Hotkeys.Count; i++) {
|
for (int i = 0; i < HotkeyList.Hotkeys.Count; i++) {
|
||||||
Hotkey h = HotkeyList.Hotkeys[i];
|
Hotkey h = HotkeyList.Hotkeys[i];
|
||||||
if (h.BaseKey == baseKey && h.Flags == flags) return h;
|
if (h.Trigger == baseKey && h.Flags == flags) return h;
|
||||||
}
|
}
|
||||||
return default(Hotkey);
|
return default(Hotkey);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
|
|
||||||
string ButtonText(int i) {
|
string ButtonText(int i) {
|
||||||
if (keyNames == null) keyNames = Enum.GetNames(typeof(Key));
|
if (keyNames == null) keyNames = Enum.GetNames(typeof(Key));
|
||||||
Key key = game.Input.Keys[binds[i]];
|
Key key = game.Mapping(binds[i]);
|
||||||
return desc[i] + ": " + keyNames[(int)key];
|
return desc[i] + ": " + keyNames[(int)key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace ClassicalSharp.Gui.Screens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override bool HandlesKeyDown(Key key) {
|
public override bool HandlesKeyDown(Key key) {
|
||||||
if (key == game.Input.Keys[KeyBind.IDOverlay] || key == game.Input.Keys[KeyBind.PauseOrExit]) {
|
if (key == game.Mapping(KeyBind.IDOverlay) || key == game.Mapping(KeyBind.PauseOrExit)) {
|
||||||
game.Gui.DisposeOverlay(this);
|
game.Gui.DisposeOverlay(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ namespace ClassicalSharp.Gui.Widgets {
|
|||||||
// a) user presses alt then number
|
// a) user presses alt then number
|
||||||
// b) user presses alt
|
// b) user presses alt
|
||||||
// thus we only do case b) if case a) did not happen
|
// thus we only do case b) if case a) did not happen
|
||||||
if (key != game.Input.Keys[KeyBind.HotbarSwitching]) return false;
|
if (key != game.Mapping(KeyBind.HotbarSwitching)) return false;
|
||||||
if (altHandled) { altHandled = false; return true; } // handled already
|
if (altHandled) { altHandled = false; return true; } // handled already
|
||||||
|
|
||||||
// Don't switch hotbar when alt+tab
|
// Don't switch hotbar when alt+tab
|
||||||
|
@ -197,22 +197,21 @@ namespace ClassicalSharp.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool HandlesKey(Key key) {
|
public bool HandlesKey(Key key) {
|
||||||
KeyMap keys = game.Input.Keys;
|
if (key == game.Mapping(KeyBind.Respawn) && Hacks.CanRespawn) {
|
||||||
if (key == keys[KeyBind.Respawn] && Hacks.CanRespawn) {
|
|
||||||
DoRespawn();
|
DoRespawn();
|
||||||
} else if (key == keys[KeyBind.SetSpawn] && Hacks.CanRespawn) {
|
} else if (key == game.Mapping(KeyBind.SetSpawn) && Hacks.CanRespawn) {
|
||||||
Spawn = Position;
|
Spawn = Position;
|
||||||
Spawn.X = Utils.Floor(Spawn.X) + 0.5f;
|
Spawn.X = Utils.Floor(Spawn.X) + 0.5f;
|
||||||
Spawn.Z = Utils.Floor(Spawn.Z) + 0.5f;
|
Spawn.Z = Utils.Floor(Spawn.Z) + 0.5f;
|
||||||
SpawnRotY = RotY;
|
SpawnRotY = RotY;
|
||||||
SpawnHeadX = HeadX;
|
SpawnHeadX = HeadX;
|
||||||
DoRespawn();
|
DoRespawn();
|
||||||
} else if (key == keys[KeyBind.Fly] && Hacks.CanFly && Hacks.Enabled) {
|
} else if (key == game.Mapping(KeyBind.Fly) && Hacks.CanFly && Hacks.Enabled) {
|
||||||
Hacks.Flying = !Hacks.Flying;
|
Hacks.Flying = !Hacks.Flying;
|
||||||
} else if (key == keys[KeyBind.NoClip] && Hacks.CanNoclip && Hacks.Enabled && !Hacks.WOMStyleHacks) {
|
} else if (key == game.Mapping(KeyBind.NoClip) && Hacks.CanNoclip && Hacks.Enabled && !Hacks.WOMStyleHacks) {
|
||||||
if (Hacks.Noclip) Velocity.Y = 0;
|
if (Hacks.Noclip) Velocity.Y = 0;
|
||||||
Hacks.Noclip = !Hacks.Noclip;
|
Hacks.Noclip = !Hacks.Noclip;
|
||||||
} else if (key == keys[KeyBind.Jump] && !onGround && !(Hacks.Flying || Hacks.Noclip)) {
|
} else if (key == game.Mapping(KeyBind.Jump) && !onGround && !(Hacks.Flying || Hacks.Noclip)) {
|
||||||
int maxJumps = Hacks.CanDoubleJump && Hacks.WOMStyleHacks ? 2 : 0;
|
int maxJumps = Hacks.CanDoubleJump && Hacks.WOMStyleHacks ? 2 : 0;
|
||||||
maxJumps = Math.Max(maxJumps, Hacks.MaxJumps - 1);
|
maxJumps = Math.Max(maxJumps, Hacks.MaxJumps - 1);
|
||||||
|
|
||||||
|
@ -124,18 +124,15 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public void Render(double delta) {
|
public void Render(double delta) {
|
||||||
game.Graphics.Mode2D(game.Width, game.Height);
|
game.Graphics.Mode2D(game.Width, game.Height);
|
||||||
bool showHUD = activeScreen == null || !activeScreen.HidesHud;
|
bool showHUD = activeScreen == null || !activeScreen.HidesHud;
|
||||||
|
bool hudBefore = activeScreen == null || !activeScreen.RenderHudOver;
|
||||||
if (showHUD) statusScreen.Render(delta);
|
if (showHUD) statusScreen.Render(delta);
|
||||||
|
|
||||||
if (showHUD && !activeScreen.RenderHudOver)
|
if (showHUD && hudBefore) hudScreen.Render(delta);
|
||||||
hudScreen.Render(delta);
|
if (activeScreen != null) activeScreen.Render(delta);
|
||||||
if (activeScreen != null)
|
if (showHUD && !hudBefore) hudScreen.Render(delta);
|
||||||
activeScreen.Render(delta);
|
|
||||||
if (showHUD && activeScreen.RenderHudOver)
|
|
||||||
hudScreen.Render(delta);
|
|
||||||
|
|
||||||
if (overlays.Count > 0)
|
if (overlays.Count > 0) { overlays[0].Render(delta); }
|
||||||
overlays[0].Render(delta);
|
|
||||||
game.Graphics.Mode3D();
|
game.Graphics.Mode3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,16 +20,12 @@ namespace ClassicalSharp {
|
|||||||
/// <summary> Maps a key binding to its actual key on the keyboard. </summary>
|
/// <summary> Maps a key binding to its actual key on the keyboard. </summary>
|
||||||
public class KeyMap {
|
public class KeyMap {
|
||||||
|
|
||||||
/// <summary> Gets the actual key on the keyboard that maps to the given key binding. </summary>
|
|
||||||
public Key this[KeyBind key] {
|
public Key this[KeyBind key] {
|
||||||
get { return keys[(int)key]; }
|
get { return keys[(int)key]; }
|
||||||
set { keys[(int)key] = value; SaveKeyBindings(); }
|
set { keys[(int)key] = value; SaveKeyBindings(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Gets the default key on the keyboard that maps to the given key binding. </summary>
|
public Key GetDefault(KeyBind key) { return defaultKeys[(int)key]; }
|
||||||
public Key GetDefault(KeyBind key) {
|
|
||||||
return defaultKeys[(int)key];
|
|
||||||
}
|
|
||||||
|
|
||||||
Key[] keys, defaultKeys;
|
Key[] keys, defaultKeys;
|
||||||
|
|
||||||
|
@ -11,19 +11,15 @@ namespace ClassicalSharp.Hotkeys {
|
|||||||
|
|
||||||
public static List<Hotkey> Hotkeys = new List<Hotkey>();
|
public static List<Hotkey> Hotkeys = new List<Hotkey>();
|
||||||
|
|
||||||
/// <summary> Creates or updates an existing hotkey with the given baseKey and modifier flags. </summary>
|
public static void Add(Key trigger, byte flags, string text, bool more) {
|
||||||
public static void Add(Key baseKey, byte flags, string text, bool more) {
|
if (!UpdateExistingHotkey(trigger, flags, text, more))
|
||||||
if (!UpdateExistingHotkey(baseKey, flags, text, more))
|
AddNewHotkey(trigger, flags, text, more);
|
||||||
AddNewHotkey(baseKey, flags, text, more);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Removes an existing hotkey with the given baseKey and modifier flags. </summary>
|
public static bool Remove(Key trigger, byte flags) {
|
||||||
/// <returns> Whether a hotkey with the given baseKey and modifier flags was found
|
|
||||||
/// and subsequently removed. </returns>
|
|
||||||
public static bool Remove(Key baseKey, byte flags) {
|
|
||||||
for (int i = 0; i < Hotkeys.Count; i++) {
|
for (int i = 0; i < Hotkeys.Count; i++) {
|
||||||
Hotkey hKey = Hotkeys[i];
|
Hotkey hKey = Hotkeys[i];
|
||||||
if (hKey.BaseKey == baseKey && hKey.Flags == flags) {
|
if (hKey.Trigger == trigger && hKey.Flags == flags) {
|
||||||
Hotkeys.RemoveAt(i);
|
Hotkeys.RemoveAt(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -31,10 +27,10 @@ namespace ClassicalSharp.Hotkeys {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool UpdateExistingHotkey(Key baseKey, byte flags, string text, bool more) {
|
static bool UpdateExistingHotkey(Key trigger, byte flags, string text, bool more) {
|
||||||
for (int i = 0; i < Hotkeys.Count; i++) {
|
for (int i = 0; i < Hotkeys.Count; i++) {
|
||||||
Hotkey hKey = Hotkeys[i];
|
Hotkey hKey = Hotkeys[i];
|
||||||
if (hKey.BaseKey == baseKey && hKey.Flags == flags) {
|
if (hKey.Trigger == trigger && hKey.Flags == flags) {
|
||||||
hKey.Text = text;
|
hKey.Text = text;
|
||||||
hKey.StaysOpen = more;
|
hKey.StaysOpen = more;
|
||||||
Hotkeys[i] = hKey;
|
Hotkeys[i] = hKey;
|
||||||
@ -44,9 +40,9 @@ namespace ClassicalSharp.Hotkeys {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AddNewHotkey(Key baseKey, byte flags, string text, bool more) {
|
static void AddNewHotkey(Key trigger, byte flags, string text, bool more) {
|
||||||
Hotkey hotkey;
|
Hotkey hotkey;
|
||||||
hotkey.BaseKey = baseKey;
|
hotkey.Trigger = trigger;
|
||||||
hotkey.Flags = flags;
|
hotkey.Flags = flags;
|
||||||
hotkey.Text = text;
|
hotkey.Text = text;
|
||||||
hotkey.StaysOpen = more;
|
hotkey.StaysOpen = more;
|
||||||
@ -68,7 +64,7 @@ namespace ClassicalSharp.Hotkeys {
|
|||||||
|
|
||||||
for (int i = 0; i < Hotkeys.Count; i++) {
|
for (int i = 0; i < Hotkeys.Count; i++) {
|
||||||
Hotkey hKey = Hotkeys[i];
|
Hotkey hKey = Hotkeys[i];
|
||||||
if ((hKey.Flags & flags) == hKey.Flags && hKey.BaseKey == key) {
|
if ((hKey.Flags & flags) == hKey.Flags && hKey.Trigger == key) {
|
||||||
text = hKey.Text;
|
text = hKey.Text;
|
||||||
moreInput = hKey.StaysOpen;
|
moreInput = hKey.StaysOpen;
|
||||||
return true;
|
return true;
|
||||||
@ -111,20 +107,20 @@ namespace ClassicalSharp.Hotkeys {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UserRemovedHotkey(Key baseKey, byte flags) {
|
public static void UserRemovedHotkey(Key trigger, byte flags) {
|
||||||
string key = "hotkey-" + baseKey + "&" + flags;
|
string key = "hotkey-" + trigger + "&" + flags;
|
||||||
Options.Set(key, null);
|
Options.Set(key, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UserAddedHotkey(Key baseKey, byte flags, bool moreInput, string text) {
|
public static void UserAddedHotkey(Key trigger, byte flags, bool moreInput, string text) {
|
||||||
string key = "hotkey-" + baseKey + "&" + flags;
|
string key = "hotkey-" + trigger + "&" + flags;
|
||||||
string value = moreInput + "&" + text;
|
string value = moreInput + "&" + text;
|
||||||
Options.Set(key, value);
|
Options.Set(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Hotkey {
|
public struct Hotkey {
|
||||||
public Key BaseKey;
|
public Key Trigger;
|
||||||
public byte Flags; // ctrl 1, shift 2, alt 4
|
public byte Flags; // ctrl 1, shift 2, alt 4
|
||||||
public bool StaysOpen; // whether the user is able to enter further input
|
public bool StaysOpen; // whether the user is able to enter further input
|
||||||
public string Text; // contents to copy directly into the input bar
|
public string Text; // contents to copy directly into the input bar
|
||||||
|
@ -13,10 +13,10 @@ namespace ClassicalSharp.Mode {
|
|||||||
Game game;
|
Game game;
|
||||||
|
|
||||||
public bool HandlesKeyDown(Key key) {
|
public bool HandlesKeyDown(Key key) {
|
||||||
if (key == game.Input.Keys[KeyBind.Inventory] && game.Gui.ActiveScreen == game.Gui.hudScreen) {
|
if (key == game.Mapping(KeyBind.Inventory) && game.Gui.ActiveScreen == game.Gui.hudScreen) {
|
||||||
game.Gui.SetNewScreen(new InventoryScreen(game));
|
game.Gui.SetNewScreen(new InventoryScreen(game));
|
||||||
return true;
|
return true;
|
||||||
} else if (key == game.Input.Keys[KeyBind.DropBlock] && !game.ClassicMode) {
|
} else if (key == game.Mapping(KeyBind.DropBlock) && !game.ClassicMode) {
|
||||||
Inventory inv = game.Inventory;
|
Inventory inv = game.Inventory;
|
||||||
if (inv.CanChangeSelected() && inv.Selected != Block.Air) {
|
if (inv.CanChangeSelected() && inv.Selected != Block.Air) {
|
||||||
// Don't assign Selected directly, because we don't want held block
|
// Don't assign Selected directly, because we don't want held block
|
||||||
|
@ -153,7 +153,7 @@ enum INFLATE_STATE_ {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Insert this byte into the bit buffer */
|
/* Insert this byte into the bit buffer */
|
||||||
#define Inflate_GetByte(state) state->AvailIn--; state->Bits |= (UInt32)(*state->NextIn) << state->NumBits; state->NextIn++; state->NumBits += 8;
|
#define Inflate_GetByte(state) state->AvailIn--; state->Bits |= (UInt32)(*state->NextIn++) << state->NumBits; state->NumBits += 8;
|
||||||
/* Retrieves bits from the bit buffer */
|
/* Retrieves bits from the bit buffer */
|
||||||
#define Inflate_PeekBits(state, bits) (state->Bits & ((1UL << (bits)) - 1UL))
|
#define Inflate_PeekBits(state, bits) (state->Bits & ((1UL << (bits)) - 1UL))
|
||||||
/* Consumes/eats up bits from the bit buffer */
|
/* Consumes/eats up bits from the bit buffer */
|
||||||
|
@ -210,21 +210,14 @@ void Gui_FreeOverlay(struct Screen* overlay) {
|
|||||||
void Gui_RenderGui(Real64 delta) {
|
void Gui_RenderGui(Real64 delta) {
|
||||||
GfxCommon_Mode2D(Game_Width, Game_Height);
|
GfxCommon_Mode2D(Game_Width, Game_Height);
|
||||||
bool showHUD = Gui_Active == NULL || !Gui_Active->HidesHUD;
|
bool showHUD = Gui_Active == NULL || !Gui_Active->HidesHUD;
|
||||||
|
bool hudBefore = Gui_Active == NULL || !Gui_Active->RenderHUDOver;
|
||||||
if (showHUD) { Elem_Render(Gui_Status, delta); }
|
if (showHUD) { Elem_Render(Gui_Status, delta); }
|
||||||
|
|
||||||
if (showHUD && !Gui_Active->RenderHUDOver) {
|
if (showHUD && hudBefore) { Elem_Render(Gui_HUD, delta); }
|
||||||
Elem_Render(Gui_HUD, delta);
|
if (Gui_Active) { Elem_Render(Gui_Active, delta); }
|
||||||
}
|
if (showHUD && !hudBefore) { Elem_Render(Gui_HUD, delta); }
|
||||||
if (Gui_Active) {
|
|
||||||
Elem_Render(Gui_Active, delta);
|
|
||||||
}
|
|
||||||
if (showHUD && Gui_Active->RenderHUDOver) {
|
|
||||||
Elem_Render(Gui_HUD, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Gui_OverlaysCount > 0) {
|
if (Gui_OverlaysCount > 0) { Elem_Render(Gui_Overlays[0], delta); }
|
||||||
Elem_Render(Gui_Overlays[0], delta);
|
|
||||||
}
|
|
||||||
GfxCommon_Mode3D();
|
GfxCommon_Mode3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,9 +214,9 @@ static void Hotkeys_QuickSort(Int32 left, Int32 right) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_AddNewHotkey(Key baseKey, UInt8 flags, STRING_PURE String* text, bool more) {
|
void Hotkeys_AddNewHotkey(Key trigger, UInt8 flags, STRING_PURE String* text, bool more) {
|
||||||
struct HotkeyData hKey;
|
struct HotkeyData hKey;
|
||||||
hKey.BaseKey = baseKey;
|
hKey.Trigger = trigger;
|
||||||
hKey.Flags = flags;
|
hKey.Flags = flags;
|
||||||
hKey.TextIndex = HotkeysText.Count;
|
hKey.TextIndex = HotkeysText.Count;
|
||||||
hKey.StaysOpen = more;
|
hKey.StaysOpen = more;
|
||||||
@ -231,11 +231,11 @@ void Hotkeys_AddNewHotkey(Key baseKey, UInt8 flags, STRING_PURE String* text, bo
|
|||||||
Hotkeys_QuickSort(0, HotkeysText.Count - 1);
|
Hotkeys_QuickSort(0, HotkeysText.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_Add(Key baseKey, UInt8 flags, STRING_PURE String* text, bool more) {
|
void Hotkeys_Add(Key trigger, UInt8 flags, STRING_PURE String* text, bool more) {
|
||||||
UInt32 i;
|
UInt32 i;
|
||||||
for (i = 0; i < HotkeysText.Count; i++) {
|
for (i = 0; i < HotkeysText.Count; i++) {
|
||||||
struct HotkeyData hKey = HotkeysList[i];
|
struct HotkeyData hKey = HotkeysList[i];
|
||||||
if (hKey.BaseKey == baseKey && hKey.Flags == flags) {
|
if (hKey.Trigger == trigger && hKey.Flags == flags) {
|
||||||
StringsBuffer_Remove(&HotkeysText, hKey.TextIndex);
|
StringsBuffer_Remove(&HotkeysText, hKey.TextIndex);
|
||||||
HotkeysList[i].StaysOpen = more;
|
HotkeysList[i].StaysOpen = more;
|
||||||
HotkeysList[i].TextIndex = HotkeysText.Count;
|
HotkeysList[i].TextIndex = HotkeysText.Count;
|
||||||
@ -243,14 +243,14 @@ void Hotkeys_Add(Key baseKey, UInt8 flags, STRING_PURE String* text, bool more)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Hotkeys_AddNewHotkey(baseKey, flags, text, more);
|
Hotkeys_AddNewHotkey(trigger, flags, text, more);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hotkeys_Remove(Key baseKey, UInt8 flags) {
|
bool Hotkeys_Remove(Key trigger, UInt8 flags) {
|
||||||
UInt32 i, j;
|
UInt32 i, j;
|
||||||
for (i = 0; i < HotkeysText.Count; i++) {
|
for (i = 0; i < HotkeysText.Count; i++) {
|
||||||
struct HotkeyData hKey = HotkeysList[i];
|
struct HotkeyData hKey = HotkeysList[i];
|
||||||
if (hKey.BaseKey == baseKey && hKey.Flags == flags) {
|
if (hKey.Trigger == trigger && hKey.Flags == flags) {
|
||||||
for (j = i + 1; j < HotkeysText.Count; j++) { HotkeysList[j - 1] = HotkeysList[j]; }
|
for (j = i + 1; j < HotkeysText.Count; j++) { HotkeysList[j - 1] = HotkeysList[j]; }
|
||||||
StringsBuffer_Remove(&HotkeysText, hKey.TextIndex);
|
StringsBuffer_Remove(&HotkeysText, hKey.TextIndex);
|
||||||
HotkeysList[i].TextIndex = UInt32_MaxValue;
|
HotkeysList[i].TextIndex = UInt32_MaxValue;
|
||||||
@ -272,7 +272,7 @@ bool Hotkeys_IsHotkey(Key key, STRING_TRANSIENT String* text, bool* moreInput) {
|
|||||||
UInt32 i;
|
UInt32 i;
|
||||||
for (i = 0; i < HotkeysText.Count; i++) {
|
for (i = 0; i < HotkeysText.Count; i++) {
|
||||||
struct HotkeyData hKey = HotkeysList[i];
|
struct HotkeyData hKey = HotkeysList[i];
|
||||||
if ((hKey.Flags & flags) == hKey.Flags && hKey.BaseKey == key) {
|
if ((hKey.Flags & flags) == hKey.Flags && hKey.Trigger == key) {
|
||||||
String hkeyText = StringsBuffer_UNSAFE_Get(&HotkeysText, hKey.TextIndex);
|
String hkeyText = StringsBuffer_UNSAFE_Get(&HotkeysText, hKey.TextIndex);
|
||||||
String_AppendString(text, &hkeyText);
|
String_AppendString(text, &hkeyText);
|
||||||
*moreInput = hKey.StaysOpen;
|
*moreInput = hKey.StaysOpen;
|
||||||
@ -312,21 +312,21 @@ void Hotkeys_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_UserRemovedHotkey(Key baseKey, UInt8 flags) {
|
void Hotkeys_UserRemovedHotkey(Key trigger, UInt8 flags) {
|
||||||
UChar keyBuffer[String_BufferSize(STRING_SIZE)];
|
UChar keyBuffer[String_BufferSize(STRING_SIZE)];
|
||||||
String key = String_InitAndClearArray(keyBuffer);
|
String key = String_InitAndClearArray(keyBuffer);
|
||||||
|
|
||||||
String_Format2(&key, "hotkey-%c&%b", Key_Names[baseKey], &flags);
|
String_Format2(&key, "hotkey-%c&%b", Key_Names[trigger], &flags);
|
||||||
Options_Set(key.buffer, NULL);
|
Options_Set(key.buffer, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_UserAddedHotkey(Key baseKey, UInt8 flags, bool moreInput, STRING_PURE String* text) {
|
void Hotkeys_UserAddedHotkey(Key trigger, UInt8 flags, bool moreInput, STRING_PURE String* text) {
|
||||||
UChar keyBuffer[String_BufferSize(STRING_SIZE)];
|
UChar keyBuffer[String_BufferSize(STRING_SIZE)];
|
||||||
String key = String_InitAndClearArray(keyBuffer);
|
String key = String_InitAndClearArray(keyBuffer);
|
||||||
UChar valueBuffer[String_BufferSize(STRING_SIZE * 2)];
|
UChar valueBuffer[String_BufferSize(STRING_SIZE * 2)];
|
||||||
String value = String_InitAndClearArray(valueBuffer);
|
String value = String_InitAndClearArray(valueBuffer);
|
||||||
|
|
||||||
String_Format2(&key, "hotkey-%c&%b", Key_Names[baseKey], &flags);
|
String_Format2(&key, "hotkey-%c&%b", Key_Names[trigger], &flags);
|
||||||
String_Format2(&value, "%t&%s", &moreInput, text);
|
String_Format2(&value, "%t&%s", &moreInput, text);
|
||||||
Options_Set(key.buffer, &value);
|
Options_Set(key.buffer, &value);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ void KeyBind_Init(void);
|
|||||||
extern UInt8 Hotkeys_LWJGL[256];
|
extern UInt8 Hotkeys_LWJGL[256];
|
||||||
struct HotkeyData {
|
struct HotkeyData {
|
||||||
UInt32 TextIndex; /* contents to copy directly into the input bar */
|
UInt32 TextIndex; /* contents to copy directly into the input bar */
|
||||||
UInt8 BaseKey; /* Member of Key enumeration */
|
UInt8 Trigger; /* Member of Key enumeration */
|
||||||
UInt8 Flags; /* ctrl 1, shift 2, alt 4 */
|
UInt8 Flags; /* ctrl 1, shift 2, alt 4 */
|
||||||
bool StaysOpen; /* whether the user is able to enter further input */
|
bool StaysOpen; /* whether the user is able to enter further input */
|
||||||
};
|
};
|
||||||
@ -132,10 +132,10 @@ StringsBuffer HotkeysText;
|
|||||||
#define HOTKEYS_FLAG_SHIFT 2
|
#define HOTKEYS_FLAG_SHIFT 2
|
||||||
#define HOTKEYS_FLAG_ALT 4
|
#define HOTKEYS_FLAG_ALT 4
|
||||||
|
|
||||||
void Hotkeys_Add(Key baseKey, UInt8 flags, STRING_PURE String* text, bool more);
|
void Hotkeys_Add(Key trigger, UInt8 flags, STRING_PURE String* text, bool more);
|
||||||
bool Hotkeys_Remove(Key baseKey, UInt8 flags);
|
bool Hotkeys_Remove(Key trigger, UInt8 flags);
|
||||||
bool Hotkeys_IsHotkey(Key key, STRING_TRANSIENT String* text, bool* moreInput);
|
bool Hotkeys_IsHotkey(Key key, STRING_TRANSIENT String* text, bool* moreInput);
|
||||||
void Hotkeys_Init(void);
|
void Hotkeys_Init(void);
|
||||||
void Hotkeys_UserRemovedHotkey(Key baseKey, UInt8 flags);
|
void Hotkeys_UserRemovedHotkey(Key trigger, UInt8 flags);
|
||||||
void Hotkeys_UserAddedHotkey(Key baseKey, UInt8 flags, bool moreInput, STRING_PURE String* text);
|
void Hotkeys_UserAddedHotkey(Key trigger, UInt8 flags, bool moreInput, STRING_PURE String* text);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef CC_INPUTHANDLER_H
|
#ifndef CC_INPUTHANDLER_H
|
||||||
#define CC_INPUTHANDLER_H
|
#define CC_INPUTHANDLER_H
|
||||||
#include "Typedefs.h"
|
#include "Input.h"
|
||||||
/* Implements base handlers for mouse and keyboard input.
|
/* Implements base handlers for mouse and keyboard input.
|
||||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
|
@ -504,83 +504,83 @@ void NotchyGen_Generate(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------Noise generation------------------------------------------------------*
|
*---------------------------------------------------Noise generation------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void ImprovedNoise_Init(UInt8* p, Random* rnd) {
|
void ImprovedNoise_Init(UInt8* p, Random* rnd) {
|
||||||
/* shuffle randomly using fisher-yates */
|
/* shuffle randomly using fisher-yates */
|
||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < 256; i++) { p[i] = i; }
|
for (i = 0; i < 256; i++) { p[i] = i; }
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
Int32 j = Random_Range(rnd, i, 256);
|
Int32 j = Random_Range(rnd, i, 256);
|
||||||
UInt8 temp = p[i]; p[i] = p[j]; p[j] = temp;
|
UInt8 temp = p[i]; p[i] = p[j]; p[j] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
p[i + 256] = p[i];
|
p[i + 256] = p[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Real32 ImprovedNoise_Calc(UInt8* p, Real32 x, Real32 y) {
|
Real32 ImprovedNoise_Calc(UInt8* p, Real32 x, Real32 y) {
|
||||||
Int32 xFloor = x >= 0 ? (Int32)x : (Int32)x - 1;
|
Int32 xFloor = x >= 0 ? (Int32)x : (Int32)x - 1;
|
||||||
Int32 yFloor = y >= 0 ? (Int32)y : (Int32)y - 1;
|
Int32 yFloor = y >= 0 ? (Int32)y : (Int32)y - 1;
|
||||||
Int32 X = xFloor & 0xFF, Y = yFloor & 0xFF;
|
Int32 X = xFloor & 0xFF, Y = yFloor & 0xFF;
|
||||||
x -= xFloor; y -= yFloor;
|
x -= xFloor; y -= yFloor;
|
||||||
|
|
||||||
Real32 u = x * x * x * (x * (x * 6 - 15) + 10); /* Fade(x) */
|
Real32 u = x * x * x * (x * (x * 6 - 15) + 10); /* Fade(x) */
|
||||||
Real32 v = y * y * y * (y * (y * 6 - 15) + 10); /* Fade(y) */
|
Real32 v = y * y * y * (y * (y * 6 - 15) + 10); /* Fade(y) */
|
||||||
Int32 A = p[X] + Y, B = p[X + 1] + Y;
|
Int32 A = p[X] + Y, B = p[X + 1] + Y;
|
||||||
|
|
||||||
/* Normally, calculating Grad involves a function call. However, we can directly pack this table
|
/* Normally, calculating Grad involves a function call. However, we can directly pack this table
|
||||||
(since each value indicates either -1, 0 1) into a set of bit flags. This way we avoid needing
|
(since each value indicates either -1, 0 1) into a set of bit flags. This way we avoid needing
|
||||||
to call another function that performs branching */
|
to call another function that performs branching */
|
||||||
#define xFlags 0x46552222
|
#define xFlags 0x46552222
|
||||||
#define yFlags 0x2222550A
|
#define yFlags 0x2222550A
|
||||||
|
|
||||||
Int32 hash = (p[p[A]] & 0xF) << 1;
|
Int32 hash = (p[p[A]] & 0xF) << 1;
|
||||||
Real32 g22 = (((xFlags >> hash) & 3) - 1) * x + (((yFlags >> hash) & 3) - 1) * y; /* Grad(p[p[A], x, y) */
|
Real32 g22 = (((xFlags >> hash) & 3) - 1) * x + (((yFlags >> hash) & 3) - 1) * y; /* Grad(p[p[A], x, y) */
|
||||||
hash = (p[p[B]] & 0xF) << 1;
|
hash = (p[p[B]] & 0xF) << 1;
|
||||||
Real32 g12 = (((xFlags >> hash) & 3) - 1) * (x - 1) + (((yFlags >> hash) & 3) - 1) * y; /* Grad(p[p[B], x - 1, y) */
|
Real32 g12 = (((xFlags >> hash) & 3) - 1) * (x - 1) + (((yFlags >> hash) & 3) - 1) * y; /* Grad(p[p[B], x - 1, y) */
|
||||||
Real32 c1 = g22 + u * (g12 - g22);
|
Real32 c1 = g22 + u * (g12 - g22);
|
||||||
|
|
||||||
hash = (p[p[A + 1]] & 0xF) << 1;
|
hash = (p[p[A + 1]] & 0xF) << 1;
|
||||||
Real32 g21 = (((xFlags >> hash) & 3) - 1) * x + (((yFlags >> hash) & 3) - 1) * (y - 1); /* Grad(p[p[A + 1], x, y - 1) */
|
Real32 g21 = (((xFlags >> hash) & 3) - 1) * x + (((yFlags >> hash) & 3) - 1) * (y - 1); /* Grad(p[p[A + 1], x, y - 1) */
|
||||||
hash = (p[p[B + 1]] & 0xF) << 1;
|
hash = (p[p[B + 1]] & 0xF) << 1;
|
||||||
Real32 g11 = (((xFlags >> hash) & 3) - 1) * (x - 1) + (((yFlags >> hash) & 3) - 1) * (y - 1); /* Grad(p[p[B + 1], x - 1, y - 1) */
|
Real32 g11 = (((xFlags >> hash) & 3) - 1) * (x - 1) + (((yFlags >> hash) & 3) - 1) * (y - 1); /* Grad(p[p[B + 1], x - 1, y - 1) */
|
||||||
Real32 c2 = g21 + u * (g11 - g21);
|
Real32 c2 = g21 + u * (g11 - g21);
|
||||||
|
|
||||||
return c1 + v * (c2 - c1);
|
return c1 + v * (c2 - c1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OctaveNoise_Init(struct OctaveNoise* n, Random* rnd, Int32 octaves) {
|
void OctaveNoise_Init(struct OctaveNoise* n, Random* rnd, Int32 octaves) {
|
||||||
n->octaves = octaves;
|
n->octaves = octaves;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < octaves; i++) {
|
for (i = 0; i < octaves; i++) {
|
||||||
ImprovedNoise_Init(n->p[i], rnd);
|
ImprovedNoise_Init(n->p[i], rnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Real32 OctaveNoise_Calc(struct OctaveNoise* n, Real32 x, Real32 y) {
|
Real32 OctaveNoise_Calc(struct OctaveNoise* n, Real32 x, Real32 y) {
|
||||||
Real32 amplitude = 1, freq = 1;
|
Real32 amplitude = 1, freq = 1;
|
||||||
Real32 sum = 0;
|
Real32 sum = 0;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
|
|
||||||
for (i = 0; i < n->octaves; i++) {
|
for (i = 0; i < n->octaves; i++) {
|
||||||
sum += ImprovedNoise_Calc(n->p[i], x * freq, y * freq) * amplitude;
|
sum += ImprovedNoise_Calc(n->p[i], x * freq, y * freq) * amplitude;
|
||||||
amplitude *= 2.0f;
|
amplitude *= 2.0f;
|
||||||
freq *= 0.5f;
|
freq *= 0.5f;
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CombinedNoise_Init(struct CombinedNoise* n, Random* rnd, Int32 octaves1, Int32 octaves2) {
|
void CombinedNoise_Init(struct CombinedNoise* n, Random* rnd, Int32 octaves1, Int32 octaves2) {
|
||||||
OctaveNoise_Init(&n->noise1, rnd, octaves1);
|
OctaveNoise_Init(&n->noise1, rnd, octaves1);
|
||||||
OctaveNoise_Init(&n->noise2, rnd, octaves2);
|
OctaveNoise_Init(&n->noise2, rnd, octaves2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Real32 CombinedNoise_Calc(struct CombinedNoise* n, Real32 x, Real32 y) {
|
Real32 CombinedNoise_Calc(struct CombinedNoise* n, Real32 x, Real32 y) {
|
||||||
Real32 offset = OctaveNoise_Calc(&n->noise2, x, y);
|
Real32 offset = OctaveNoise_Calc(&n->noise2, x, y);
|
||||||
return OctaveNoise_Calc(&n->noise1, x + offset, y);
|
return OctaveNoise_Calc(&n->noise1, x + offset, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -874,7 +874,7 @@ static void EditHotkeyScreen_MakeBaseKey(struct EditHotkeyScreen* screen, Widget
|
|||||||
String text = String_InitAndClearArray(textBuffer);
|
String text = String_InitAndClearArray(textBuffer);
|
||||||
|
|
||||||
String_AppendConst(&text, "Key: ");
|
String_AppendConst(&text, "Key: ");
|
||||||
String_AppendConst(&text, Key_Names[screen->CurHotkey.BaseKey]);
|
String_AppendConst(&text, Key_Names[screen->CurHotkey.Trigger]);
|
||||||
EditHotkeyScreen_Make(screen, 0, 0, -150, &text, onClick);
|
EditHotkeyScreen_Make(screen, 0, 0, -150, &text, onClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,16 +931,16 @@ static void EditHotkeyScreen_LeaveOpen(struct GuiElem* elem, struct GuiElem* wid
|
|||||||
static void EditHotkeyScreen_SaveChanges(struct GuiElem* elem, struct GuiElem* widget) {
|
static void EditHotkeyScreen_SaveChanges(struct GuiElem* elem, struct GuiElem* widget) {
|
||||||
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
||||||
struct HotkeyData hotkey = screen->OrigHotkey;
|
struct HotkeyData hotkey = screen->OrigHotkey;
|
||||||
if (hotkey.BaseKey != Key_None) {
|
if (hotkey.Trigger != Key_None) {
|
||||||
Hotkeys_Remove(hotkey.BaseKey, hotkey.Flags);
|
Hotkeys_Remove(hotkey.Trigger, hotkey.Flags);
|
||||||
Hotkeys_UserRemovedHotkey(hotkey.BaseKey, hotkey.Flags);
|
Hotkeys_UserRemovedHotkey(hotkey.Trigger, hotkey.Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
hotkey = screen->CurHotkey;
|
hotkey = screen->CurHotkey;
|
||||||
if (hotkey.BaseKey != Key_None) {
|
if (hotkey.Trigger != Key_None) {
|
||||||
String text = screen->Input.Base.Text;
|
String text = screen->Input.Base.Text;
|
||||||
Hotkeys_Add(hotkey.BaseKey, hotkey.Flags, &text, hotkey.StaysOpen);
|
Hotkeys_Add(hotkey.Trigger, hotkey.Flags, &text, hotkey.StaysOpen);
|
||||||
Hotkeys_UserAddedHotkey(hotkey.BaseKey, hotkey.Flags, hotkey.StaysOpen, &text);
|
Hotkeys_UserAddedHotkey(hotkey.Trigger, hotkey.Flags, hotkey.StaysOpen, &text);
|
||||||
}
|
}
|
||||||
Gui_ReplaceActive(HotkeyListScreen_MakeInstance());
|
Gui_ReplaceActive(HotkeyListScreen_MakeInstance());
|
||||||
}
|
}
|
||||||
@ -948,9 +948,9 @@ static void EditHotkeyScreen_SaveChanges(struct GuiElem* elem, struct GuiElem* w
|
|||||||
static void EditHotkeyScreen_RemoveHotkey(struct GuiElem* elem, struct GuiElem* widget) {
|
static void EditHotkeyScreen_RemoveHotkey(struct GuiElem* elem, struct GuiElem* widget) {
|
||||||
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
||||||
struct HotkeyData hotkey = screen->OrigHotkey;
|
struct HotkeyData hotkey = screen->OrigHotkey;
|
||||||
if (hotkey.BaseKey != Key_None) {
|
if (hotkey.Trigger != Key_None) {
|
||||||
Hotkeys_Remove(hotkey.BaseKey, hotkey.Flags);
|
Hotkeys_Remove(hotkey.Trigger, hotkey.Flags);
|
||||||
Hotkeys_UserRemovedHotkey(hotkey.BaseKey, hotkey.Flags);
|
Hotkeys_UserRemovedHotkey(hotkey.Trigger, hotkey.Flags);
|
||||||
}
|
}
|
||||||
Gui_ReplaceActive(HotkeyListScreen_MakeInstance());
|
Gui_ReplaceActive(HotkeyListScreen_MakeInstance());
|
||||||
}
|
}
|
||||||
@ -990,7 +990,7 @@ static bool EditHotkeyScreen_HandlesKeyDown(struct GuiElem* elem, Key key) {
|
|||||||
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
struct EditHotkeyScreen* screen = (struct EditHotkeyScreen*)elem;
|
||||||
if (screen->SelectedI >= 0) {
|
if (screen->SelectedI >= 0) {
|
||||||
if (screen->SelectedI == 0) {
|
if (screen->SelectedI == 0) {
|
||||||
screen->CurHotkey.BaseKey = key;
|
screen->CurHotkey.Trigger = key;
|
||||||
EditHotkeyScreen_MakeBaseKey(screen, EditHotkeyScreen_BaseKey);
|
EditHotkeyScreen_MakeBaseKey(screen, EditHotkeyScreen_BaseKey);
|
||||||
} else if (screen->SelectedI == 1) {
|
} else if (screen->SelectedI == 1) {
|
||||||
if (key == Key_ControlLeft || key == Key_ControlRight) screen->CurHotkey.Flags |= HOTKEYS_FLAG_CTRL;
|
if (key == Key_ControlLeft || key == Key_ControlRight) screen->CurHotkey.Flags |= HOTKEYS_FLAG_CTRL;
|
||||||
@ -1018,7 +1018,7 @@ static void EditHotkeyScreen_ContextRecreated(void* obj) {
|
|||||||
struct MenuInputValidator validator = MenuInputValidator_String();
|
struct MenuInputValidator validator = MenuInputValidator_String();
|
||||||
String text = String_MakeNull();
|
String text = String_MakeNull();
|
||||||
|
|
||||||
bool existed = screen->OrigHotkey.BaseKey != Key_None;
|
bool existed = screen->OrigHotkey.Trigger != Key_None;
|
||||||
if (existed) {
|
if (existed) {
|
||||||
text = StringsBuffer_UNSAFE_Get(&HotkeysText, screen->OrigHotkey.TextIndex);
|
text = StringsBuffer_UNSAFE_Get(&HotkeysText, screen->OrigHotkey.TextIndex);
|
||||||
}
|
}
|
||||||
@ -1540,7 +1540,7 @@ static void HotkeyListScreen_EntryClick(struct GuiElem* elem, struct GuiElem* w)
|
|||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < HotkeysText.Count; i++) {
|
for (i = 0; i < HotkeysText.Count; i++) {
|
||||||
struct HotkeyData h = HotkeysList[i];
|
struct HotkeyData h = HotkeysList[i];
|
||||||
if (h.BaseKey == baseKey && h.Flags == flags) { original = h; break; }
|
if (h.Trigger == baseKey && h.Flags == flags) { original = h; break; }
|
||||||
}
|
}
|
||||||
Gui_ReplaceActive(EditHotkeyScreen_MakeInstance(original));
|
Gui_ReplaceActive(EditHotkeyScreen_MakeInstance(original));
|
||||||
}
|
}
|
||||||
@ -1558,7 +1558,7 @@ struct Screen* HotkeyListScreen_MakeInstance(void) {
|
|||||||
struct HotkeyData hKey = HotkeysList[i];
|
struct HotkeyData hKey = HotkeysList[i];
|
||||||
String_Clear(&text);
|
String_Clear(&text);
|
||||||
|
|
||||||
String_AppendConst(&text, Key_Names[hKey.BaseKey]);
|
String_AppendConst(&text, Key_Names[hKey.Trigger]);
|
||||||
String_AppendConst(&text, " |");
|
String_AppendConst(&text, " |");
|
||||||
EditHotkeyScreen_MakeFlags(hKey.Flags, &text);
|
EditHotkeyScreen_MakeFlags(hKey.Flags, &text);
|
||||||
StringsBuffer_Add(&screen->Entries, &text);
|
StringsBuffer_Add(&screen->Entries, &text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user