Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assembly-CSharp/Global/Booster/BoosterSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void SetBoosterState(Int32 currentCharacterStateIndex)
}
}

public void ShowWaringDialog(BoosterType type, Action callback = null)
public void ShowWarningDialog(BoosterType type, Action callback = null)
{
if (this.needComfirmType == BoosterType.None
&& (PersistenSingleton<UIManager>.Instance.IsPlayerControlEnable || PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.Config)
Expand Down
170 changes: 165 additions & 5 deletions Assembly-CSharp/Global/Config/ConfigUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public enum Configurator
MovieVolume,
VoiceVolume,
ATBMode,
AutoText
AutoText,
ControllerBind
}

public enum ATBMode
Expand Down Expand Up @@ -220,6 +221,11 @@ public enum ATBMode

private Boolean helpEnable;

private Boolean isBindingMode = false;
private Int32 bindingStage = 0;
private Single bindingTimer = 0f;
private Dialog bindingDialog;

[NonSerialized]
private Int32 fieldMessageConfigIndex = (Int32)Configurator.FieldMessage;
public GameObject SliderMenuTemplate => ConfigList.GetChild(1).GetChild(0).GetChild(fieldMessageConfigIndex);
Expand Down Expand Up @@ -733,6 +739,12 @@ public override Boolean OnKeyConfirm(GameObject go)
ButtonGroupState.HoldActiveStateOnGroup(ConfigGroupButton);
});
}
if (config?.Configurator == Configurator.ControllerBind)
{
FF9Sfx.FF9SFX_Play(103);
StartBindingSequence();
return true;
}
else if (config?.Configurator == Configurator.CombatTutorial)
{
if (PersistenSingleton<UIManager>.Instance.UnityScene == UIManager.Scene.Battle)
Expand Down Expand Up @@ -813,7 +825,7 @@ private void OnBoosterPanelKeyConfirm(GameObject go)
if (Configuration.Cheats.MasterSkill)
{
FF9Sfx.FF9SFX_Play(103);
PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.MasterSkill, AfterBoosterFinish);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.MasterSkill, AfterBoosterFinish);
hitpointScreenButton.KeyCommand = Control.None;
WarningDialogHitPoint.SetActive(true);
}
Expand All @@ -836,7 +848,7 @@ private void OnBoosterPanelKeyConfirm(GameObject go)
if (Configuration.Cheats.LvMax)
{
FF9Sfx.FF9SFX_Play(103);
PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.LvMax, AfterBoosterFinish);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.LvMax, AfterBoosterFinish);
hitpointScreenButton.KeyCommand = Control.None;
WarningDialogHitPoint.SetActive(true);
}
Expand All @@ -851,7 +863,7 @@ private void OnBoosterPanelKeyConfirm(GameObject go)
if (Configuration.Cheats.GilMax)
{
FF9Sfx.FF9SFX_Play(103);
PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.GilMax, AfterBoosterFinish);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.GilMax, AfterBoosterFinish);
hitpointScreenButton.KeyCommand = Control.None;
WarningDialogHitPoint.SetActive(true);
}
Expand Down Expand Up @@ -1298,7 +1310,7 @@ private void setConfigValue(GameObject configGameObject, Single value, Boolean i
if (configField.Value == previousValue)
playSound = false;
}
else if (configField.Configurator != Configurator.Title && configField.Configurator != Configurator.QuitGame && configField.Configurator != Configurator.ControlTutorial && configField.Configurator != Configurator.CombatTutorial)
else if (configField.Configurator != Configurator.Title && configField.Configurator != Configurator.QuitGame && configField.Configurator != Configurator.ControlTutorial && configField.Configurator != Configurator.CombatTutorial && configField.Configurator != Configurator.ControllerBind)
{
GameObject child = configField.ConfigChoice[0].GetChild(0);
GameObject child2 = configField.ConfigChoice[1].GetChild(0);
Expand Down Expand Up @@ -1421,6 +1433,11 @@ private void Update()
vib.VIB_actuatorReset(0);
vib.VIB_actuatorReset(1);
}
if (isBindingMode)
{
UpdateBindingLogic();
return;
}
}

private GameObject CreateChoice(GameObject template, Configurator id, String choice1, String choice2, int siblingIndex)
Expand Down Expand Up @@ -1508,6 +1525,139 @@ private void CreateATBModeSlider(GameObject template, Configurator id, int sibli
slider.value = 0f;
}

private void StartBindingSequence()
{
PersistenSingleton<HonoInputManager>.Instance.IsBindingInput = true;
isBindingMode = true;
bindingStage = 1;
bindingTimer = Time.realtimeSinceStartup + 0.5f;

string text = Localization.Get("ConfigBindL3"); // Don't refresh the text with dual language.
UpdateBindingDialogText(text);

ButtonGroupState.DisableAllGroup(true);
}

private void UpdateBindingDialogText(string newText)
{
if (bindingDialog != null)
Singleton<DialogManager>.Instance.Close(bindingDialog.Id);

bindingDialog = Singleton<DialogManager>.Instance.AttachDialog(
newText,
0,
0,
Dialog.TailPosition.Center,
Dialog.WindowStyle.WindowStylePlain,
Vector2.zero,
Dialog.CaptionType.None
);
}

private void UpdateBindingLogic()
{
if (!isBindingMode || Time.realtimeSinceStartup < bindingTimer) return;

if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.5f || Input.GetKey(KeyCode.Escape))
{
FF9Sfx.FF9SFX_Play(102);

if (bindingStage == 1) // L3
{
Configuration.Control.SaveLeftStick(-1);
UpdateBindingDialogText(Localization.Get("ConfigBindL3DisabledThenR3")); // Don't refresh the text with dual language.
bindingStage = 2;
bindingTimer = Time.realtimeSinceStartup + 0.5f;
}
else if (bindingStage == 2) // R3
{
Configuration.Control.SaveRightStick(-1);
EndBindingSequence();
}
return;
}

for (int i = 0; i < 20; i++)
{
KeyCode key = (KeyCode)((int)KeyCode.JoystickButton0 + i);
if (Input.GetKeyDown(key))
{
FF9Sfx.FF9SFX_Play(1044);
int rawID = (int)key;

if (bindingStage == 1) // L3
{
Configuration.Control.SaveLeftStick(rawID);
UpdateBindingDialogText(Localization.Get("ConfigBindR3")); // Don't refresh the text with dual language.
bindingStage = 2;
bindingTimer = Time.realtimeSinceStartup + 0.5f;
}
else if (bindingStage == 2)
{
Configuration.Control.SaveRightStick(rawID);
EndBindingSequence();
}
return;
}
}
}

private void EndBindingSequence()
{
isBindingMode = false;
bindingStage = 0;
PersistenSingleton<HonoInputManager>.Instance.IsBindingInput = false;

if (bindingDialog != null)
{
Singleton<DialogManager>.Instance.Close(bindingDialog.Id);
bindingDialog = null;
}

ButtonGroupState.DisableAllGroup(false);
ButtonGroupState.ActiveGroup = ConfigGroupButton;
}

private void CreateButtonFromExisting(Transform listParent, Configurator newId, String keyName, Configurator templateId, Configurator placeAfterId)
{
GameObject template = null;
int targetIndex = -1;

for (int i = 0; i < listParent.childCount; i++)
{
var nav = listParent.GetChild(i).GetComponent<ScrollItemKeyNavigation>();
if (nav == null) continue;

if (nav.ID == (int)templateId)
template = listParent.GetChild(i).gameObject;

if (nav.ID == (int)placeAfterId)
targetIndex = i + 1;
}

if (template != null && targetIndex != -1)
{
GameObject go = Instantiate(template);
go.name = $"{newId} Panel - Button";
go.transform.SetParent(listParent, false);
go.transform.SetSiblingIndex(targetIndex);

go.GetComponent<ScrollItemKeyNavigation>().ID = (int)newId;

UILabel lbl = go.GetComponentInChildren<UILabel>();
if (lbl != null)
{
UILocalize loc = lbl.GetComponent<UILocalize>();
if (loc == null) loc = lbl.gameObject.AddComponent<UILocalize>();
loc.key = keyName;
}
}
else
{
Log.Error("[ConfigUI] Impossible de trouver le template ou l'index cible.");
}
}

private void Awake()
{
FadingComponent = ScreenFadeGameObject.GetComponent<HonoFading>();
Expand All @@ -1528,6 +1678,12 @@ private void Awake()

CreateATBModeSlider(sliderTemplate, Configurator.ATBMode, 9);

if (PersistenSingleton<HonoInputManager>.Instance.IsControllerConnect)
{
Transform listParent = ConfigList.GetChild(1).GetChild(0).transform;
CreateButtonFromExisting(listParent, Configurator.ControllerBind, "MenuBoutonL3R3", Configurator.ControlTutorial, Configurator.Vibration);
}

foreach (Transform trans in ConfigList.GetChild(1).GetChild(0).transform)
{
ConfigField configField = new ConfigField();
Expand Down Expand Up @@ -1573,6 +1729,10 @@ private void Awake()
combatTutorialGameObject = configTopObj;
UIEventListener.Get(configTopObj).onClick += onClick;
}
else if (configField.Configurator == Configurator.ControllerBind)
{
UIEventListener.Get(configTopObj).onClick += onClick;
}
else if (configField.Configurator == Configurator.QuitGame)
{
quitGameGameObject = configTopObj;
Expand Down
2 changes: 2 additions & 0 deletions Assembly-CSharp/Global/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// Then pressing the button Triangle triggers both the event script checks "IsButton(4096)" and "IsButton(131072)", which respectively check for the physical button "Triangle" and the logical button "Confirm"
// The keyboard key's associated physical button also depends on the joystick configuration: pressing "A" triggers the same checks "IsButton(4096)" and "IsButton(131072)"

// [DV] L3 and R3 can be called with KeyCode.JoystickButton10 and KeyCode.JoystickButton11 (eg. Input.GetKeyDown(KeyCode.JoystickButton10) )

public enum Control
{
Confirm,
Expand Down
53 changes: 53 additions & 0 deletions Assembly-CSharp/Global/Hono/HonoInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,59 @@ private Single GetRightAnalogVerticalNavigation()
{
return UnityXInput.Input.GetAxis(this.SpecificPlatformRightAnlogVerticalKey);
}
public bool IsBindingInput { get; set; } = false;
public bool IsL3Pressed()
{
if (IsBindingInput || Configuration.Control.LeftStick == -1) return false;

if (Input.GetKeyDown((KeyCode)Configuration.Control.LeftStick))
return true;

return false;
}

public bool IsR3Pressed()
{
if (IsBindingInput || Configuration.Control.RightStick == -1) return false;

if (Input.GetKeyDown((KeyCode)Configuration.Control.RightStick))
return true;

return false;
}

private void DebugControllerInput() // Debug to check input from joystick
{
for (int i = 0; i < 20; i++)
{
KeyCode key = KeyCode.JoystickButton0 + i;
if (UnityEngine.Input.GetKey(key))
{
Log.Message("[DEBUG INPUT] Unity Key Pressed: " + key.ToString() + " (ID: " + (int)key + ")");
}
}

float triggerLeft = UnityEngine.Input.GetAxis("LeftTrigger");
if (triggerLeft > 0.1f)
{
Log.Message("[DEBUG INPUT] Unity Axis LeftTrigger: " + triggerLeft);
}

try
{
GamePadState state = XInputDotNetPure.GamePad.GetState(PlayerIndex.One);

if (state.Buttons.LeftStick == ButtonState.Pressed)
Log.Message("[DEBUG INPUT] XInput: LeftStick (L3) PRESSED");

if (state.Buttons.RightStick == ButtonState.Pressed)
Log.Message("[DEBUG INPUT] XInput: RightStick (R3) PRESSED");

if (state.Triggers.Left > 0.0f)
Log.Message("[DEBUG INPUT] XInput: LeftTrigger (L2) Value: " + state.Triggers.Left);
}
catch { }
}

public const Single TriggerThreshold = 0.19f;
private const Single DownThreshold = 0.01f;
Expand Down
10 changes: 5 additions & 5 deletions Assembly-CSharp/Global/UI/UIKey/UIKeyTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void HandleBoosterButton(BoosterType triggerType = BoosterType.None)
return;
if (PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.Title || PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.PreEnding || (PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.Ending || !MBG.IsNull && !MBG.Instance.IsFinishedForDisableBooster()))
return;
if (UnityXInput.Input.GetKeyDown(KeyCode.F1) || triggerType == BoosterType.HighSpeedMode)
if (UnityXInput.Input.GetKeyDown(KeyCode.F1) || triggerType == BoosterType.HighSpeedMode || HonoInputManager.Instance.IsL3Pressed())
{
if (!Configuration.Cheats.SpeedMode)
{
Expand Down Expand Up @@ -267,7 +267,7 @@ public void HandleBoosterButton(BoosterType triggerType = BoosterType.None)

if (!FF9StateSystem.Settings.IsMasterSkill)
{
PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.MasterSkill);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.MasterSkill);
}
else
{
Expand All @@ -284,7 +284,7 @@ public void HandleBoosterButton(BoosterType triggerType = BoosterType.None)
return;
}

PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.LvMax);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.LvMax);
}
if (UnityXInput.Input.GetKeyDown(KeyCode.F7) && (PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.FieldHUD || PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.WorldHUD || PersistenSingleton<UIManager>.Instance.State == UIManager.UIState.Pause))
{
Expand All @@ -295,7 +295,7 @@ public void HandleBoosterButton(BoosterType triggerType = BoosterType.None)
return;
}

PersistenSingleton<UIManager>.Instance.Booster.ShowWaringDialog(BoosterType.GilMax);
PersistenSingleton<UIManager>.Instance.Booster.ShowWarningDialog(BoosterType.GilMax);
}
if (Configuration.Control.SoftReset && ((UnityXInput.Input.GetKeyDown(KeyCode.F8) && PersistenSingleton<UIManager>.Instance.IsPause) || SoftResetKeyPSXDown))
{ // Soft Reset
Expand Down Expand Up @@ -351,7 +351,7 @@ public void HandleBoosterButton(BoosterType triggerType = BoosterType.None)
SceneDirector.Replace("Title", SceneTransition.FadeOutToBlack_FadeIn, true);
return;
}
if (UnityXInput.Input.GetKeyDown(KeyCode.F9) && Configuration.Control.TurboDialog)
if ((UnityXInput.Input.GetKeyDown(KeyCode.F9) || HonoInputManager.Instance.IsR3Pressed()) && Configuration.Control.TurboDialog)
{
if (TurboKey)
TurboKey = false;
Expand Down
13 changes: 13 additions & 0 deletions Assembly-CSharp/Memoria/Configuration/Access/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ The PSX movement algorithm is different than the remaster's movement algorithm
public static Boolean PSXMovementMethod => Instance._control.PSXMovementMethod;
public static Boolean AlwaysCaptureGamepad => Instance._control.AlwaysCaptureGamepad;
public static Boolean SwapConfirmCancel => Instance._control.SwapConfirmCancel;
public static Int32 LeftStick => Instance._control.KeyCodeLeftStick;
public static Int32 RightStick => Instance._control.KeyCodeRightStick;
public static void SaveLeftStick(Int32 id)
{
Instance._control.KeyCodeLeftStick.Value = id;
Configuration.SaveValue("Control", Instance._control.KeyCodeLeftStick);
}

public static void SaveRightStick(Int32 id)
{
Instance._control.KeyCodeRightStick.Value = id;
Configuration.SaveValue("Control", Instance._control.KeyCodeRightStick);
}
}
}
}
2 changes: 2 additions & 0 deletions Assembly-CSharp/Memoria/Configuration/Memoria.ini
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ PSXScrollingMethod = 1
PSXMovementMethod = 1
AlwaysCaptureGamepad = 1
SwapConfirmCancel = 0
KeyCodeLeftStick = -1
KeyCodeRightStick = -1

[AnalogControl]
; StickThreshold (default 10) 0->100, threshold under which there is no movement
Expand Down
Loading