I am attempting to add the option to return directly to the character select screen after a match in addition to the default return to main menu option. I was able to reverse engineer enough of how the default text was set up to get the text for it to display and found already made callbacks that seemed to be for returning to character select.
However, I can’t figure out where to look in the code for how to properly add it to the menu. The text displays but cannot be selected since the menu itself still only looks for two options (0 through 1), and there isn’t anything connecting the text to the return to css function yet either.
Just to be safe and potentially catch issues in advance, here is the relevant code I have so far. This is in CMenu-PostBattle-Player-Default.gd
func UpdateDisplay():
var t = "You win!" if _isWinner else "You lose..."
t += "\n\n\n"
if(wantsRematch):
t += "[Rematch]"
elif(chosenOption == 0):
t += "> [Rematch] <"
else:
t += "Rematch"
t += "\n"
t += "> [Return to Menu] <" if chosenOption == 1 else "Return to Menu"
t += "\n"
t += "> [Return to Character Select] <" if chosenOption == 2 else "Return to Character Select"
$Text.set_text(t)
And this isn’t relevant yet for but for when the option can be selected. I have this in CMenu-PostBattle.gd
Seems like it’s not super exposed, but it’s in the Post Battle Player scene. The script is res://castagne/helpers/menus/helpers/postbattle/CMenu-PostBattle-Player.gd.
Seems like it’s hardcoded in those scripts, but you can change the paths from the config menu. Might have to copy the whole post battle scene (which you probably should do anyway for cool menus)
Weirdly “res://castagne/helpers/menus/helpers/postbattle/CMenu-PostBattle-Player.gd” didn’t show in the godot editor even after doing a search for it, but when I searched the files manually I found it so then I was able to open it. Odd quirk on godot’s side.
Anyway after finding that script I was able to modify one of its functions into the following, which has the menu working as intended. Also created a chosenOptionMax var to make it easy to update in the future just in case.
And now that I’m over that hurdle it turns out that the GoToCSS function is crashing, which isn’t terribly surprising. Since the godot editor flagged it I’m sure the solution is somewhere in this func in CastagneMenus.gd, but it’s a little over my head right now.
func MCB_StartMatchFromCSS(args):
var bid = args["ConfigData"].GetModuleSlot(Castagne.MODULE_SLOTS_BASE.FLOW).GetBattleInitDataFromCSS(args)
bid["mode"] = args["CallbackParams"]["Mode"]
if(bid["exitcallback"] == null):
bid["exitcallback"] = funcref(self, "MatchExitCallback_ToPostBattle")
var e = Castagne.InstanceCastagneEngine(bid, args["ConfigData"])
get_tree().get_root().add_child(e)