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

I guess we're doing UI again #345

Merged
merged 32 commits into from
Oct 14, 2023
Merged

I guess we're doing UI again #345

merged 32 commits into from
Oct 14, 2023

Conversation

Dregu
Copy link
Collaborator

@Dregu Dregu commented Oct 8, 2023

  • UI: Add level gen flags to game props
  • UI: Add warp buttons for other types of game screens
  • UI: Add option to disable death screen popping up
  • UI: Add button/hotkey to respawn dead players
  • UI: Add monster/trap/room/generic procedural chances to game props
  • API: Add create_level/layer(), initialize layers back, create an empty level after you've destroyed it
  • API: Add destroy_level/layer(), wipes all entities and unloads the layer(s)
  • API: Add set_level_logic_enabled(), disable all usual death screens from popping up, including when playing with 0 players
  • API: Add Movable:clear_cutscene() to stop intro, transition etc cutscenes
  • API: Add helpers to convert between INPUTS and (x, y, BUTTON)
  • API: Add ON.PRE/POST_LAYER/LEVEL_CREATION, called before/after any screen creates layers
  • API: Add ON.PRE/POST_LAYER/LEVEL_DESTRUCTION, called before/after any screen unloads a layer or both layers
  • API: Make ON.PRE_LEVEL_GENERATION cancelable
  • API: Make ON.*_LEVEL_GENERATION run in transitions, since it runs in almost every other screen anyway
-- convert the current level to an empty void with just the player
destroy_level()
create_level()
state.current_theme:spawn_players()

-- same sort of thing with the level gen hook
set_callback(function()
  state.illumination = create_illumination(Color:white(), 20000, 172, 252)
  state.current_theme:spawn_players()
  return true
end, ON.PRE_LEVEL_GENERATION)

@Dregu
Copy link
Collaborator Author

Dregu commented Oct 13, 2023

I hope the cutscene allocation works like I think, even if the CustomCutscene alloc is bigger than the vanilla, and vanilla does the destroying. At least using game_allocator stopped it from crashing on dtor.

@Mr-Auto
Copy link
Contributor

Mr-Auto commented Oct 13, 2023

I hope the cutscene allocation works like I think, even if the CustomCutscene alloc is bigger than the vanilla, and vanilla does the destroying. At least using game_allocator stopped it from crashing on dtor.

There are like 3 cutscenes in the game, we can probably map all of them if you want. The question is, do we really need this? it's nothing special, just a function that is called every frame, and it disables the entity logic (probably just skips calling some virtuals like process input). We can add function to clear it, as it should be safe to just
delete cutscene_behavior; cutscene_behavior = nullptr;

@Dregu
Copy link
Collaborator Author

Dregu commented Oct 13, 2023

Well I'm sure we don't need it, there are ton of places to hook for similar results. My question is really is there anything wrong with it, now that it's already done? Or can you show me a simpler way to replicate the functionality with existing methods?

src/game_api/spawn_api.hpp Outdated Show resolved Hide resolved
src/game_api/search.cpp Outdated Show resolved Hide resolved
src/game_api/spawn_api.cpp Outdated Show resolved Hide resolved
src/game_api/search.cpp Outdated Show resolved Hide resolved
Comment on lines +117 to +119
movable_vtable.unhook(ent, callback_id);
floor_vtable.unhook(ent, callback_id);
door_vtable.unhook(ent, callback_id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this template jungle, but clear_callback didn't work and this fixed it.

@Dregu
Copy link
Collaborator Author

Dregu commented Oct 14, 2023

Ok I'm done with this pr, it's getting pretty hefty.

lua["create_layer"] = create_layer;

/// Setting to false disables the death screen from popping up for any usual reason, can still load manually
lua["set_death_enabled"] = set_death_enabled;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so this also disables some small things like shop zoom, but do we care? I made it just for overlunking, but it's nice to have debugging tools in the api too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also just nice to not need a player in a level at all

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for cutscenes or weird game modes in mods too I suppose. I'll change the name to something more descriptive, any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, also going back to the patterns, we could just get the address from vtable of state.screen_level, and for the theme stuff from level_gen
since they never gets destroyed and stuff

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to redo the hooks for a fourth time, but you can suggest your fix in pr format and this works for now.

@Dregu Dregu merged commit 0b3001d into main Oct 14, 2023
9 checks passed
@Dregu Dregu deleted the UI branch October 14, 2023 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants