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

A Complete Builder Toggle API #3943

Merged
merged 11 commits into from
Feb 15, 2024

Conversation

Cyrillya
Copy link
Contributor

@Cyrillya Cyrillya commented Nov 25, 2023

What is the new feature?

A Complete Builder Toggle API
Closes #3857

Why should this be part of tModLoader?

The current Builder Toggle API in tModLoader is incomplete and missing features. This pr allows mod builder toggles to:

  • Have custom ordering
  • Have custom left click & left click functionality (with ability to play custom sound when clicked)
  • Allow custom drawing to make cooler vfxs on them
  • Customize frame rectangle based on state (By custom drawing)

Some issues to point out

  1. There is already a DisplayColorTexture hook for customizing the color. But the new custom drawing ability fully covers that use. Should we remove this hook to avoid confusion, or keep it for backwards compatibility?
  2. Should we implement GlobalBuilderToggle? I don't have a proper way to correctly handle states with multiple mods for now without changing the structure.

Are there alternative designs?

Make builder toggle state into a seperate class like BuilderToggleState. BuilderToggleState is registered to BuilderToggle. Make hooks such as left-click/right-click functionality and custom drawing into BuilderToggleState

This can be a proper way to handle states added to one vanilla builder toggle by multiple mods. But requires an overhaul of the current system

ExampleMod updates

  • ExampleBuilderToggle
    • Ability to cycle through states backwards via right clicking
  • FreeBaitBuilderToggle
    • A complete showcase of all BuilderToggle hooks implemented currently
    • More likely a "button" instead of "toggle", which left clicking allows you to select bait type, while right clicking gives you free baits of the selected type.
    • Custom drawing is contained to handle frame changes.

@JavidPack JavidPack self-assigned this Jan 11, 2024
@JavidPack
Copy link
Collaborator

I can take care of the feedback items mentioned when I review and merge.

@JavidPack JavidPack merged commit f4e6cf8 into tModLoader:1.4.4 Feb 15, 2024
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.

A More "Complete" Builder Toggle API
4 participants