Hud-World classes design

From Post-Apocalyptic RPG wiki

Jump to: navigation, search

Class design.png This article covers outdated class design information!

Class design articles are stored at the wiki for legacy reasons. Most of them are outdated and they will not be updated in the future. Class design should rather be embedded into actual Code proposals.


Most of below is already implemented

Notes for Hud class design:

  • All gui widgets should be owned by Hud and (probably) never leaked outside.
  • Interaction between outside world and Gui widgets should happen via Hud method calls and customised event handlers.
  • Hud events that only lead to hiding/showing another Hud element (like "Inventory" or "Main menu" buttons click) should be processed inside Hud, although we (probably) should allow them to be overridden from outside just like any other event.


How hud and future hud's elements are currently used

  • world.py:72-83 -- Mapping the main/menu events.
    • Inventory button event should be processed by hud itself
    • One set of events is enough. It doesn't really matter where the event was triggered, be it Main menu, HUD buttons or elsewhere.
  • world.py:87-90 -- Inventory initialization.
    • Needs to move to hud class
    • In future Inventory needs to split into two classes: model and gui. For now model is fake and we only have gui. This is subject for next refactoring (Iteration 2).
  • world.py: 198-209 -- refreshReadyImages.
    • Iteration 1 -- move to hud class
    • Iteration 2 -- make both Inv gui and Hud gui update images from Inventory model. Make an optional parameter to only update single slot.
  • world.py: 95-96 -- Context Menu instantiation.
    • Not sure why it's even needed. We make a new context menu instance each time it's needed.
    • Move to HUD class as a showContextMenu(...) method.
    • Replace all references with either showContextMenu or hideContextMenu. Usage example -- world.py:315
  • world.py: 222-227 -- closeInventoryAndToggle
    • Move to HUD
    • Suggested rename to hideInventory. Trying to stick with show/hide convention unless another one is already in use.
  • world.py: 229-245 -- displayInventory
    • Move to HUD
    • Suggested rename to showInventory.

Other refactoring thoughts

  • hud class is better renamed to GUI, since it's no longer just hud (and never was in reality).
  • must look at gui manager in FIFE -- Nothing interesting, it seems
Personal tools