-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
it's not very good but i think it works?
- Loading branch information
Showing
98 changed files
with
25,611 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
using System; | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class AddPchButton : MonoBehaviour | ||
{ | ||
public static string selectedPatch; | ||
public static Button lastBtn; | ||
public GameObject patchAddPopup; | ||
public TMP_InputField patchName; | ||
public Button confirmPch; | ||
public Button addPchBtn; | ||
public GameObject templateCard; | ||
public TMP_InputField patchData; | ||
public SavePatchBtn sav; | ||
public TMP_Text selLabel; | ||
public Toggle defOn; | ||
public TMP_Dropdown groupSel; | ||
public GameObject paneA, paneB, paneC, paneD, paneE, paneF; | ||
public ScrollRect pane; | ||
private GameObject instParent; | ||
|
||
private void Start() | ||
{ | ||
try | ||
{ | ||
addPchBtn.onClick.AddListener(() => | ||
{ | ||
patchAddPopup.SetActive(true); | ||
addPchBtn.interactable = false; | ||
}); | ||
} | ||
catch (Exception ignored) | ||
{ | ||
//this works | ||
} | ||
|
||
try | ||
{ | ||
confirmPch.onClick.AddListener(() => | ||
{ | ||
patchAddPopup.SetActive(false); | ||
addPchBtn.enabled = true; | ||
instParent = groupSel.value switch | ||
{ | ||
0 => paneA, | ||
1 => paneB, | ||
2 => paneC, | ||
3 => paneD, | ||
4 => paneE, | ||
5 => paneF, | ||
_ => instParent | ||
}; | ||
var c = Instantiate(templateCard, instParent.transform, false); | ||
c.transform.GetChild(1).GetChild(0).GetComponent<TMP_Text>().text = patchName.text; | ||
var cName = patchName.text; | ||
CommWithGame.groupOfPatch[cName] = groupSel.value; | ||
c.transform.GetChild(1).GetComponent<Button>().onClick.AddListener(() => | ||
{ | ||
if (CommWithGame.patchTextRaw.ContainsKey(cName)) | ||
patchData.text = CommWithGame.patchTextRaw[cName]; | ||
else | ||
patchData.text = "//placeholder"; | ||
selectedPatch = cName; | ||
selLabel.text = "Selected: " + cName; | ||
defOn.isOn = CommWithGame.defaultOnCheats.Contains(cName); | ||
}); | ||
var toggleOn = c.transform.GetChild(0).GetComponent<Button>(); | ||
lastBtn = toggleOn; | ||
toggleOn.onClick.AddListener(() => | ||
{ | ||
var label = c.transform.GetChild(0).GetChild(0).GetComponent<TMP_Text>(); | ||
if (label.text == "OFF") | ||
{ | ||
foreach (var line in CommWithGame.patchCode[cName]) | ||
{ | ||
CommWithGame.sendStr("pokeMain " + line[0] + " " + line[1]); | ||
if (!line[1].StartsWith("0x")) | ||
CommWithGame.sendStr("pokeMain " + (int.Parse(line[0]) + line[1].Length) + " 0x0"); | ||
} | ||
|
||
CommWithGame.patchesOn.Add(cName); | ||
label.text = "ON"; | ||
} | ||
else | ||
{ | ||
foreach (var line in CommWithGame.oldCode[cName]) | ||
CommWithGame.sendStr("pokeMain " + line[0] + " 0x" + line[1]); | ||
CommWithGame.patchesOn.Remove(cName); | ||
label.text = "OFF"; | ||
} | ||
}); | ||
c.transform.GetChild(2).GetComponent<Button>().onClick.AddListener(() => | ||
{ | ||
var label2 = c.transform.GetChild(0).GetChild(0).GetComponent<TMP_Text>(); | ||
if (label2.text == "ON") | ||
{ | ||
StartCoroutine(sav.showError("Can't delete: Patch is still on.")); | ||
return; | ||
} | ||
|
||
var label = c.transform.GetChild(1).GetChild(0).GetComponent<TMP_Text>(); | ||
try | ||
{ | ||
CommWithGame.patchCode.Remove(label.text); | ||
CommWithGame.oldCode.Remove(label.text); | ||
CommWithGame.patchTextRaw.Remove(label.text); | ||
CommWithGame.defaultOnCheats.Remove(label.text); | ||
} | ||
catch (Exception e) | ||
{ | ||
//its ok bro | ||
} | ||
|
||
if (label.text == selectedPatch) | ||
{ | ||
selectedPatch = null; | ||
patchData.text = "//select a patch :)"; | ||
selLabel.text = "Selected: none"; | ||
} | ||
|
||
SavePatchBtn.saveToDisk(); | ||
Destroy(c.gameObject); | ||
}); | ||
c.transform.GetChild(1).GetComponent<Button>().onClick.Invoke(); | ||
addPchBtn.interactable = true; | ||
}); | ||
} | ||
catch (Exception ignored) | ||
{ | ||
//this also works | ||
} | ||
} | ||
|
||
// Update is called once per frame | ||
private void Update() | ||
{ | ||
} | ||
|
||
public void changeShownGroup(int val) | ||
{ | ||
var view = val switch | ||
{ | ||
0 => paneA, | ||
1 => paneB, | ||
2 => paneC, | ||
3 => paneD, | ||
4 => paneE, | ||
5 => paneF, | ||
_ => null | ||
}; | ||
paneA.SetActive(false); | ||
paneB.SetActive(false); | ||
paneC.SetActive(false); | ||
paneD.SetActive(false); | ||
paneE.SetActive(false); | ||
paneF.SetActive(false); | ||
view.SetActive(true); | ||
pane.content = view.GetComponent<RectTransform>(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
public class ClickPatchButton : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
private void Start() | ||
{ | ||
var cheatToggle = transform.GetChild(0).GetComponent<Button>(); | ||
var cheatName = transform.GetChild(1).GetComponent<Button>(); | ||
} | ||
|
||
// Update is called once per frame | ||
private void Update() | ||
{ | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.