Skip to content

Commit

Permalink
Bugfix ability hotkeys, activation on rebind pause
Browse files Browse the repository at this point in the history
  • Loading branch information
rudderbucky committed Apr 9, 2021
1 parent a4c7473 commit d86ae38
Show file tree
Hide file tree
Showing 13 changed files with 233 additions and 62 deletions.
213 changes: 173 additions & 40 deletions Assets/Prefabs/HUD Prefabs/Settings.prefab

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Init(Ability ability, string hotkeyText, Entity entity, KeyName keyc
ReflectName(ability);
ReflectDescription(ability);
ReflectTier(ability);
ReflectHotkey(GetPrettyStringFromKeycode(InputManager.keys[keycode].overrideKey));
ReflectHotkey(keycode);

this.keycode = keycode;

Expand All @@ -55,13 +55,14 @@ public void Init(Ability ability, string hotkeyText, Entity entity, KeyName keyc
gleamed = ability is PassiveAbility;
}

public void ReflectHotkey(string hotkeyText)
public void ReflectHotkey(KeyName keycode)
{
this.keycode = keycode;
// set up hotkey display
if(hotkeyText != null)
{
this.hotkeyText.transform.parent.gameObject.SetActive(true);
this.hotkeyText.text = hotkeyText;
this.hotkeyText.text = GetPrettyStringFromKeycode(InputManager.keys[keycode].overrideKey);
}
else this.hotkeyText.transform.parent.gameObject.SetActive(false);
}
Expand Down Expand Up @@ -189,7 +190,7 @@ private void Update()

if(!entity.GetIsDead())
{
bool hotkeyAccepted = (InputManager.GetKeyDown(keycode) && !InputManager.GetKey(KeyName.TurretQuickPurchase));
bool hotkeyAccepted = (InputManager.GetKeyDown(keycode) && !InputManager.GetKey(KeyName.TurretQuickPurchase)) && !PlayerViewScript.paused;
if(abilities[0] is WeaponAbility)
{
foreach(var ab in abilities)
Expand Down
23 changes: 14 additions & 9 deletions Assets/Scripts/Functional Definitions/Abilities/AbilityHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum AbilityTypes {
Ability[] displayAbs;
public static string[] keybindList; // list of keys for ability binds
public static AbilityHandler instance;
public float tileSpacing;
public static float tileSpacing;

public void SetCurrentVisible(AbilityTypes type) {
if(currentVisibles != type) {
Expand Down Expand Up @@ -159,7 +159,7 @@ private static string GetAHSpawnData(string data)

public static float GetAbilityPos(int index)
{
return instance.tileSpacing * (0.8F*index+0.5F);
return tileSpacing * (0.8F*index+0.5F);
}

public static void RearrangeID(float xPos, AbilityID id, string droneData)
Expand All @@ -184,7 +184,7 @@ public static void RearrangeID(float xPos, AbilityID id, string droneData)

private static int GetAbilityPosInverse(float xPos)
{
return Mathf.Min(Mathf.Max(0, Mathf.RoundToInt(((xPos / instance.tileSpacing) - 0.5F) / 0.8F)), instance.betterBGboxArray.Count - 1);
return Mathf.Min(Mathf.Max(0, Mathf.RoundToInt(((xPos / tileSpacing) - 0.5F) / 0.8F)), instance.betterBGboxArray.Count - 1);
}

private void Rearrange()
Expand Down Expand Up @@ -226,15 +226,20 @@ private void Rearrange()
}
}


for(i = 0; i < list.Count; i++)
ReorientAbilityBoxes();
}

public void ReorientAbilityBoxes()
{
var list = visibleAbilityOrder.GetList((int)currentVisibles);
for(int i = 0; i < list.Count; i++)
{
instance.betterBGboxArray[ConvertObjectToString(list, i)].transform.position = new Vector3(GetAbilityPos(i),
tileSpacing*0.8F, this.transform.position.z);
// instance.betterBGboxArray[ConvertObjectToString(list, i)].ReflectHotkey(currentVisibles != AbilityTypes.Passive && i < 9? keybindList[i] : null);
betterBGboxArray[ConvertObjectToString(list, i)].transform.position = new Vector3(GetAbilityPos(i),
tileSpacing*0.8F, transform.position.z);
betterBGboxArray[ConvertObjectToString(list, i)].ReflectHotkey(KeyName.Ability0 + i);
}
}

public string ConvertObjectToString(IList list, int i)
{
var idList = visibleAbilityOrder.GetList((int)currentVisibles) as List<AbilityID>;
Expand Down
14 changes: 10 additions & 4 deletions Assets/Scripts/HUD Scripts/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public static void SaveControls()
{
PlayerPrefs.SetString("Controls", JsonUtility.ToJson(keys));
PlayerPrefs.Save();
AbilityHandler.instance.Deinitialize();
AbilityHandler.instance.Initialize(PlayerCore.Instance);
}

public static void LoadControls()
Expand Down Expand Up @@ -155,11 +153,19 @@ private void Update()
if (Input.GetKeyDown((KeyCode)key))
{
SetControl(inputToChange.Value, (KeyCode)key);
Debug.Log("Set binding for " + inputToChange.Value + " to " + (KeyCode)key);
inputToChange = null;

keyText.text = ((KeyCode)key).ToString();
keyText.color = Color.white;
keyText = null;

if(inputToChange.Value >= KeyName.Ability0 && inputToChange.Value <= KeyName.Ability9)
{
AbilityHandler.instance.ReorientAbilityBoxes();
}

Debug.Log("Set binding for " + inputToChange.Value + " to " + (KeyCode)key);
inputToChange = null;

break;
}
}
Expand Down
5 changes: 0 additions & 5 deletions Assets/Scripts/HUD Scripts/SettingsScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public void SaveSettings()
//}
}

public void ChangeAbilityKeybind(int index, string val)
{
AbilityHandler.ChangeKeybind(index, val);
}

public void ChangeMasterVolume(float newVol)
{
if (AudioManager.instance)
Expand Down
10 changes: 10 additions & 0 deletions Logs/ApiUpdaterCheck.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[api-updater (non-obsolete-error-filter)] 4/8/2021 8:09:11 PM : Starting C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/Tools/ScriptUpdater/APIUpdater.NonObsoleteApiUpdaterDetector.exe
[api-updater (non-obsolete-error-filter)]
----------------------------------
jit/startup time : 792.0445ms
moved types parse time: 68ms
candidates parse time : 2ms
C# parse time : 458ms
candidates check time : 64ms
console write time : 0ms

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe1.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe2.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe3.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe4.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe5.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe6.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

3 changes: 3 additions & 0 deletions Logs/shadercompiler-UnityShaderCompiler.exe7.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base path: 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2020.3.0f1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler

0 comments on commit d86ae38

Please sign in to comment.