Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/FormatChangeUI.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

203 lines
6.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Cute;
using UnityEngine;
namespace Wizard;
public class FormatChangeUI : MonoBehaviour
{
public enum FormatCategory
{
Invalid,
Rotation,
Unlimited,
PreRotation,
Crossover,
Hof,
Windfall,
MyRotation,
Avatar,
Other
}
private const string UNLIMITED_CENTER_SPRITE_OFF = "btn_unlimited_center_off";
private const string UNLIMITED_CENTER_SPRITE_ON = "btn_unlimited_center_on";
private const string UNLIMITED_RIGHT_SPRITE_OFF = "btn_gacha_unlimited_off";
private const string UNLIMITED_RIGHT_SPRITE_ON = "btn_gacha_unlimited_on";
private const string OLD_ROTATION_SPRITE_ON = "btn_gacha_rotation_on";
private const string OLD_ROTATION_SPRITE_OFF = "btn_gacha_rotation_off";
private static readonly Dictionary<FormatCategory, (string ON, string OFF)> ANOTHER_BTN_SPRITES = new Dictionary<FormatCategory, (string, string)>
{
{
FormatCategory.Other,
("btn_gacha_other_on", "btn_gacha_other_off")
},
{
FormatCategory.PreRotation,
("btn_prerotation_on", "btn_prerotation_off")
},
{
FormatCategory.Crossover,
("btn_gacha_crossover_on", "btn_gacha_crossover_off")
},
{
FormatCategory.MyRotation,
("btn_gacha_myrotation_on", "btn_gacha_myrotation_off")
}
};
[SerializeField]
private UIButton _btnRotation;
[SerializeField]
private UIButton _btnUnlimited;
[SerializeField]
private UIButton _btnAnother;
private FormatCategory _currentFormatCategory = FormatCategory.Rotation;
private Action<FormatCategory> _onChangeFormat;
public static FormatChangeUI Create(FormatCategory defaultFormatCategory, FormatCategory anotherFormatCategory, Action<FormatCategory> onChangeFormat)
{
FormatChangeUI component = (UnityEngine.Object.Instantiate(Resources.Load("UI/layoutParts/Guild/FormatChangeUI")) as GameObject).GetComponent<FormatChangeUI>();
component.gameObject.SetActive(value: true);
component.Initialize(defaultFormatCategory, anotherFormatCategory, onChangeFormat);
return component;
}
public void ShowOldRotationIcon()
{
_btnRotation.normalSprite = "btn_gacha_rotation_on";
_btnRotation.pressedSprite = "btn_gacha_rotation_off";
}
public void ChangeFormat(FormatCategory inFormatCategory)
{
_currentFormatCategory = inFormatCategory;
UpdateFormatBtnSprite(inFormatCategory);
}
public void SetEnableFormatButton(FormatCategory formatCategory, bool isEnable)
{
switch (formatCategory)
{
case FormatCategory.Rotation:
UIManager.SetObjectToGrey(_btnRotation.gameObject, !isEnable);
return;
case FormatCategory.Unlimited:
UIManager.SetObjectToGrey(_btnUnlimited.gameObject, !isEnable);
return;
}
if (ANOTHER_BTN_SPRITES.ContainsKey(formatCategory))
{
UIManager.SetObjectToGrey(_btnAnother.gameObject, !isEnable);
}
}
public void UpdateAnotherFormatButton(FormatCategory anotherFormatCategory)
{
bool flag = anotherFormatCategory != FormatCategory.Invalid;
_btnAnother.gameObject.SetActive(flag);
_btnUnlimited.normalSprite = (flag ? "btn_unlimited_center_off" : "btn_gacha_unlimited_off");
_btnUnlimited.pressedSprite = (flag ? "btn_unlimited_center_on" : "btn_gacha_unlimited_on");
if (flag)
{
_btnAnother.onClick.Add(new EventDelegate(delegate
{
OnClickChangeFormatBtn(anotherFormatCategory);
}));
_btnAnother.normalSprite = ANOTHER_BTN_SPRITES[anotherFormatCategory].OFF;
_btnAnother.pressedSprite = ANOTHER_BTN_SPRITES[anotherFormatCategory].ON;
}
else
{
_btnAnother.onClick.Clear();
}
}
private void Initialize(FormatCategory defaultFormatCategory, FormatCategory anotherFormatCategory, Action<FormatCategory> onChangeFormat)
{
InitializeFormatCategoryButtons(anotherFormatCategory);
_onChangeFormat = onChangeFormat;
ChangeFormat(defaultFormatCategory);
}
private void InitializeFormatCategoryButtons(FormatCategory anotherFormatCategory)
{
_btnRotation.onClick.Add(new EventDelegate(delegate
{
OnClickChangeFormatBtn(FormatCategory.Rotation);
}));
_btnUnlimited.onClick.Add(new EventDelegate(delegate
{
OnClickChangeFormatBtn(FormatCategory.Unlimited);
}));
UpdateAnotherFormatButton(anotherFormatCategory);
}
private void OnClickChangeFormatBtn(FormatCategory formatCategory)
{
if (_currentFormatCategory != formatCategory)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
ChangeFormat(formatCategory);
_onChangeFormat.Call(formatCategory);
StartCoroutine(WaitForCanClickFormatBtns());
}
}
private IEnumerator WaitForCanClickFormatBtns()
{
SetEnableAllBtns(isEnable: false);
yield return new WaitForSeconds(0.4f);
SetEnableAllBtns(isEnable: true);
}
private void SetEnableAllBtns(bool isEnable)
{
_btnRotation.isEnabled = isEnable;
_btnUnlimited.isEnabled = isEnable;
_btnAnother.isEnabled = isEnable;
}
private string RenameSpriteString(string str, bool isEnable)
{
string oldValue = (isEnable ? "_off" : "_on");
string newValue = (isEnable ? "_on" : "_off");
return str.Replace(oldValue, newValue);
}
private void UpdateFormatBtnSprite(FormatCategory inFormatCategory)
{
switch (inFormatCategory)
{
case FormatCategory.Rotation:
_btnRotation.normalSprite = RenameSpriteString(_btnRotation.normalSprite, isEnable: true);
_btnUnlimited.normalSprite = RenameSpriteString(_btnUnlimited.normalSprite, isEnable: false);
_btnAnother.normalSprite = RenameSpriteString(_btnAnother.normalSprite, isEnable: false);
return;
case FormatCategory.Unlimited:
_btnRotation.normalSprite = RenameSpriteString(_btnRotation.normalSprite, isEnable: false);
_btnUnlimited.normalSprite = RenameSpriteString(_btnUnlimited.normalSprite, isEnable: true);
_btnAnother.normalSprite = RenameSpriteString(_btnAnother.normalSprite, isEnable: false);
return;
}
if (ANOTHER_BTN_SPRITES.ContainsKey(inFormatCategory))
{
_btnRotation.normalSprite = RenameSpriteString(_btnRotation.normalSprite, isEnable: false);
_btnUnlimited.normalSprite = RenameSpriteString(_btnUnlimited.normalSprite, isEnable: false);
_btnAnother.normalSprite = RenameSpriteString(_btnAnother.normalSprite, isEnable: true);
}
}
}