Coder Social home page Coder Social logo

Comments (5)

ShadowApex avatar ShadowApex commented on June 8, 2024

I think this is a great idea. To let you know, I've previously done work on trying to refactor the menu system to make it easier to use in the "menu_refactor" branch. It's been a while since I've worked on it, so merging it to development might be painful, but I'd like to incorporate some of its functionality into the menus.

You can take a look at the refactored menu I've been working on here: https://github.com/Tuxemon/Tuxemon/blob/menu_refactor/tuxemon/core/components/menu/__init__.py#L50

from tuxemon.

bitcraft avatar bitcraft commented on June 8, 2024

I can merge that into my branch. Looks like there was a lot of effort put
into it. It would help me if you could make a small list of the overall
changes that need to be migrated. From just a quick look, it seems that the
complicated parts have been broken down functions. Thanks!

Overall, my goal for the menu refactor has been to break down some parts
to make them fit the State API. I don't want to re implement them, just
move enough code around that it works.

On Wed, Dec 30, 2015 at 12:14 AM William Edwards [email protected]
wrote:

I think this is a great idea. To let you know, I've previously done work
on trying to refactor the menu system to make it easier to use in the
"menu_refactor" branch. It's been a while since I've worked on it, so
merging it to development might be painful, but I'd like to incorporate
some of its functionality into the menus.

You can take a look at the refactored menu I've been working on here:
https://github.com/Tuxemon/Tuxemon/blob/menu_refactor/tuxemon/core/components/menu/__init__.py#L50


Reply to this email directly or view it on GitHub
#85 (comment).

from tuxemon.

ShadowApex avatar ShadowApex commented on June 8, 2024

Yeah, the refactor removed a lot of unnecessary legacy bits and added a lot of helper methods to remove a lot of the code duplication seen throughout the codebase.

Here's a quick summary of the things I had done:

  • Removed unnecessary parameters like screen, resolution, etc.
  • Added init params to construct menus with their size and position upon creation.
  • Made the menu inherit from the UserInterface class to provide functionality like moving over time and playing background and menu border animations.
  • Added next, previous, and done to make menus more state-like. These will probably be deprecated with your changes.
  • Broke up some methods into smaller functions for easier reuse and readability.
  • Added helper methods like menu_select_next, menu_select_prev, set_size, and set_position.
  • Made drawing dependent on the self.visible property.
  • Made input handling dependent on the self.interactable property.
  • Replaced methods like draw, draw_text, and draw_textItem with a single draw() method.
  • Text drawing is done automatically in draw after you call set_text once instead of needing to pass the text to draw every frame.

from tuxemon.

bitcraft avatar bitcraft commented on June 8, 2024

Thanks for the write up. Details like how text drawing will help make sure there are no regressions.

from tuxemon.

bitcraft avatar bitcraft commented on June 8, 2024

I'm going to close this. My current branch has changes the "pos_x", "size_x", etc variables into pygame Rects. Updates to the states/menu refactor will be in #72.

from tuxemon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.