Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the way event skip button works to spawn them on any scene #97

Closed
Turtyo opened this issue Apr 25, 2024 · 11 comments · Fixed by #147
Closed

Change the way event skip button works to spawn them on any scene #97

Turtyo opened this issue Apr 25, 2024 · 11 comments · Fixed by #147
Assignees
Labels
confirmed Has been approved to make code based on this enhancement Ask for changes to an existing feature

Comments

@Turtyo
Copy link
Collaborator

Turtyo commented Apr 25, 2024

Is your amelioration related to a problem? Please describe.

The skip button just exists in placeholder scenes, but we could imagine wanting to skip real scenes for testing purpose. This behaviour is already partially controlled by the DEBUG_VAR named DEBUG_SKIP_EVENT

Describe the solution you'd like

Instead of enabling and disabling a button in some scenes, a solution would be to instantiate through code a button in all the scenes if the skip event debug var is set. It doesn't auto-skip the scene, but you can do it if you want. That way we can skip any scene without needing to update all the different scene files we have

Scenes that don't have a clear end condition yet should have the skip button on by default. I'm not sure how we would do that, as it would mean we need to have a way to say if a certain scene has a proper end condition. Any idea is welcome for this.

Additional context

This needs to be done after #87

@Turtyo Turtyo added the enhancement Ask for changes to an existing feature label Apr 25, 2024
@TripleCubes
Copy link
Contributor

We can make all events's top node be a Event node, which is a custom node that auto initialize the skip button if debug enabled

Altho this also mean you cant assign script to top event node anymore (right? it is been a while since I use godot)

Which mean the event's script will need to be in a child node

@Turtyo
Copy link
Collaborator Author

Turtyo commented Jun 5, 2024

You can put a script on the top node. All events are already child of EventBase, maybe we can put the check for the debug variable inside EventBase ? With an eventual override per event (ie mob, dialogue, heal and shop) if we want to customize the position.
I never tried spawning a button directly with code, but that might be doable, we'll need to check

@TripleCubes
Copy link
Contributor

I dont see how any event is related to EventBase. I checked the #Event folder, all events there have top node be a Control, there is no EventBase there

Spawning nodes from code is like one of the most basic thing to do in Godot. I dont 100% remeber the syntax but it literally just

const btn_scene = preload("PATH TO BTN SCENE")

func _ready():
    var btn: Btn = btn_scene.instantiate()
    self.append(btn)
end

@TripleCubes
Copy link
Contributor

Relevant link:
https://docs.godotengine.org/en/stable/tutorials/scripting/nodes_and_scene_instances.html#instancing-scenes

As for the checking if event have a proper end, we can just give the event a self.dont_have_proper_end variable, and then we check if this variable exist and is it true, and after than create the skip button?

@TripleCubes
Copy link
Contributor

This also mean you have to check if the variable exist every time you want to access the variable tho, which you might not want to do. We can also add the have_proper_end variable to BaseEvent (I realized we should name it have_proper_end instead of dont_have_proper_end because dealing with negative bool is annoying) and set it to true by default, and events that dont have proper end can set it to false

Sorry for multiple messages

@Turtyo
Copy link
Collaborator Author

Turtyo commented Jun 6, 2024

I don't know where you looked, but all events in Event/ have EventBase as their parent. Ah yeah nvm I already did that, I just didn't remember 🤦
What do you mean by "proper end" ?

@TripleCubes
Copy link
Contributor

The scenes that dont have clear end conditions

@Turtyo
Copy link
Collaborator Author

Turtyo commented Jun 6, 2024

Oh so the heal and shop. Shop by default the clear condition will be that there is none and you can leave directly. Heal there will be a clear condition. So we don't actually need to have a has_proper_end variable.
By default for now we can make it so that the events heal and shop that are still WIP spawn that button by default (replace the check of if DEBUG_VAR_SKIP_EVENT by if true or DEBUG_VAR_SKIP_EVENT, and we'll only need to remove the true or whenever the events are working correctly)

I'm also not sure what you mean by "This also mean you have to check if the variable exist every time you want to access the variable", which variable are you talking about ? the self.dont_have_proper_end ? Since this is not required it's not a problem. Even if it was required, using a boolean with true or false doesn't require you to check if the variable exists.

I think a solution is to have add a _spawn_skip_button() button which takes a position as a parameter, and spawns the button at that position. Also define the class variable skip_button_position, which can be overridden by child class. So it would be something like that in EventBase:

@export button_position: Position = (100,100) # just to put a default

func _ready():
    if DEBUG_VAR.DEBUG_VAR_SKIP_BUTTON:
        _spawn_skip_button(button_position)

func _spawn_skip_button():
    # instantiate the button

And then child Event class can override button_position if they want to put it somewhere else

@TripleCubes
Copy link
Contributor

yeah that works

@Turtyo
Copy link
Collaborator Author

Turtyo commented Jun 6, 2024

You can take this issue if you want, since I see you assigned and de-assigned yourself.
There is probably some work to be done to properly clear the events when pressing the skip button though (to not keep stuff from a previous fight for example, which is usually cleaned up on event win for example). i don't remember how the skip button is done, so you'll have to check that i think

@TripleCubes TripleCubes self-assigned this Jun 6, 2024
@TripleCubes TripleCubes added the confirmed Has been approved to make code based on this label Jun 6, 2024
@Turtyo Turtyo linked a pull request Jun 15, 2024 that will close this issue
@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 29, 2024

This is not needed anymore after #147 is merged, as all events will have an UI and no skip buttons anymore

@Turtyo Turtyo linked a pull request Dec 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Has been approved to make code based on this enhancement Ask for changes to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants