Commit Graph

3 Commits

Author SHA1 Message Date
John McCardle 167636ce8c Iterators, other Python C API improvements
closes #72
ref #69 - this resolves the "UICollection" (not "UIEntityCollection", perhaps renamed since the issue opened) and "UIEntityCollection" portion. The Grid point based iterators were not updated.
**RPATH updates**
Will this RPATH setting allow McRogueFace to execute using its included "lib" subdirectory after being unzipped on a new computer?

The change from "./lib" to "$ORIGIN/./lib" improves portability. The $ORIGIN token is a special Linux/Unix convention that refers to the directory containing the executable itself. This makes the path relative to the executable's location rather than the current working directory, which means McRogueFace will correctly find its libraries in the lib subdirectory regardless of where it's run from after being unzipped on a new computer.

**New standard object initialization**
PyColor, PyVector
  - Fixed all 15 PyTypeObject definitions to use proper designated initializer syntax
  - Replaced PyType_GenericAlloc usage in PyColor.cpp and PyVector.cpp
  - Updated PyObject_New usage in UIEntity.cpp
  - All object creation now uses module-based type lookups instead of static references
  - Created centralized utilities in PyObjectUtils.h

**RAII Wrappers**
automatic reference counting via C++ object lifecycle
  - Created PyRAII.h with PyObjectRef and PyTypeRef classes
  - These provide automatic reference counting management
  - Updated PyColor::from_arg() to demonstrate RAII usage
  - Prevents memory leaks and reference counting errors

**Python object base in type defs:**
`.ob_base = {.ob_base = {.ob_refcnt = 1, .ob_type = NULL}, .ob_size = 0}`
PyColor, PyTexture, PyVector, UICaption, UICollection, UIEntity, UIFrame, UIGrid

**convertDrawableToPython**
replace crazy macro to detect the correct Python type of a UIDrawable instance

  - Removed the problematic macro from UIDrawable.h
  - Created template-based functions in PyObjectUtils.h
  - Updated UICollection.cpp to use local helper function
  - The new approach is cleaner, more debuggable, and avoids static type references

**Iterator fixes**
tp_iter on UICollection, UIGrid, UIGridPoint, UISprite
UIGrid logic improved, standard

**List vs Vector usage analysis**
there are different use cases that weren't standardized:
  - UICollection (for Frame children) uses std::vector<std::shared_ptr<UIDrawable>>
  - UIEntityCollection (for Grid entities) uses std::list<std::shared_ptr<UIEntity>>

The rationale is currently connected to frequency of expected changes.
* A "UICollection" is likely either all visible or not; it's also likely to be created once and have a static set of contents. They should be contiguous in memory in hopes that this helps rendering speed.
* A "UIEntityCollection" is expected to be rendered as a subset within the visible rectangle of the UIGrid. Scrolling the grid or gameplay logic is likely to frequently create and destroy entities. In general I expect Entity collections to have a much higher common size than UICollections. For these reasons I've made them Lists in hopes that they never have to be reallocated or moved during a frame.
2025-05-31 09:11:51 -04:00
John McCardle a465a9861d Color parsing for UICaption __init__ - closes #58 2024-04-20 13:37:19 -04:00
John McCardle f82508b753 Squashed commit of the following: [standardize_color_handling]
closes #11

Check the abandoned feature branch for PyLinkedColor, a time-expensive but now abandoned feature to link a color value to a UIDrawable.

There are some TODOs left in the PyColor class, but that can go under cleanup. I'm way over time on this, so I'm taking a small victory :)

commit 572aa52605
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Mar 30 21:18:26 2024 -0400

    More color table updates

commit 01706bd59d
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Mar 30 21:13:31 2024 -0400

    Color wrapup... Cutting PyLinkedColor to simplify my cursedly mortal, finite existence

commit 3991ac13d6
Author: John McCardle <mccardle.john@gmail.com>
Date:   Thu Mar 28 23:50:50 2024 -0400

    Still having segfaults with LinkedColor and captions (specifically outline color, but that might not be the actual cause). PyColor shaping back up in simplified form.

commit 06e24a1b27
Author: John McCardle <mccardle.john@gmail.com>
Date:   Thu Mar 28 20:53:49 2024 -0400

    LinkedColor now reflecting changes to the linked color value. Needs set method + RGBA / color properties

commit 41509dfe96
Author: John McCardle <mccardle.john@gmail.com>
Date:   Wed Mar 27 21:10:03 2024 -0400

    Addressing issues with PyColor by splitting behavior off into PyLinkedColor

commit 13a4ddf41b
Author: John McCardle <mccardle.john@gmail.com>
Date:   Tue Mar 26 23:02:00 2024 -0400

    Build runs again. PyColor objects are being instantiated, with bugs and no test of color changing

commit 1601fc7fab
Author: John McCardle <mccardle.john@gmail.com>
Date:   Mon Mar 25 20:48:08 2024 -0400

    Still doesn't compile, but now the issue is in UI.h overcoupling. Progress!

commit 13672c8fdb
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sun Mar 24 21:19:37 2024 -0400

    Dabbling around this morning; still not building

commit 79090b553f
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sun Mar 24 08:36:06 2024 -0400

    Unsaved changes from last night

commit 2cac6f03c6
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Mar 23 23:07:10 2024 -0400

    untested PyColor base implementation

commit 3728e5fcc8
Author: John McCardle <mccardle.john@gmail.com>
Date:   Sat Mar 23 23:06:36 2024 -0400

    Color naming prototype
2024-03-30 21:20:40 -04:00