Client Systems & Python UI
Metin2 inventory sidebar: fix buttons opening the last action
M2City Client · Editorial · Published 2026-11-05 · Branch-specific details should be checked against your own source.
In the supplied inventory sidebar, every button can execute the last action in SIDEBAR_BUTTON. CreateButtons registers a lambda inside a loop; the callback reads the loop variable after the loop has finished. In the included two-button example, clicking the Dragon Soul button therefore runs the Mall action.
M2City r1 changes
Each button now receives ui.__mem_func__(item['function']) at creation. The callback is selected immediately and wrapped using the normal weak method adapter. Destroy also clears SIDEBAR_BUTTON so its stored bound methods release the inventory owner. The original instructions are included separately, and the upstream source encoding is preserved.
Who this is for and how to integrate it
This is a legacy Python-root UI integration for private Metin2 administrators, not a complete uiinventory.py replacement. Merge the supplied SidebarWindow class and the InventoryWindow hooks already listed in the instructions: initialize/create wndSideBar, show/hide it with inventory, reposition/raise it on movement and OnTop, and destroy/reset it during inventory cleanup.
The sidebar is owned by InventoryWindow. Keep the existing interfacemodule inventory construction and Destroy calls; do not create a second sidebar there. Verify that your own ui.py provides ui.__mem_func__. No extra SetEvent arguments or unsupported engine bindings are introduced.
The Button1/Button2 strings and slot_base.sub visuals are upstream placeholders. Choose your own localized labels, confirmed asset paths and existing inventory handlers. Fork-specific WindowDestroy conventions must be checked against your real UI framework; no new decorator was guessed for this unspecified branch.
Validation
The packaged test executes only the reviewed sidebar class against a fake UI engine. Five assertions reproduce the original wrong-action result, check both corrected actions, verify cleanup state and verify that the inventory owner is released after Destroy. These tests pass on Python 3.13. They do not validate native window picking, texture loading, the legacy embedded interpreter or in-game appearance. Test opening/closing, both actions, dragging inventory and character relogging in a disposable client.
Attribution
The supplied archive was labelled iBeast Sidebar cyn3. The public release discussion credits CYN3 for the recode and refers to iBeast as the original feature/design reference. M2City claims the binding/cleanup adjustments and new regression harness; no original author identity or runtime result has been invented.
Editorial resource — M2City
Version: Supplied CYN3 legacy sidebar variant + M2City r1 (2026-11-04)
Rights: Public redistribution confirmed by supplying owner; upstream credits retained. M2City test harness licence applies only to its new test code.
Validation: Archive/source review; five Python 3.13 fake-engine assertions, including reproduction of the original failure. No actual client or legacy interpreter run.
Source: CYN3 / LTGT public recode discussion
SHA-256: 021bb630654b7375c52c13de7f5d4ceced55b8ec0be8e4e4bebd41702dcf0607
Download package
3 download options · Sign in to download
metin2-inventory-sidebar-m2city-r1.zipM2City downloadmetin2-inventory-sidebar-m2city-r1.zipGoogle Drive mirrormetin2-inventory-sidebar-m2city-r1.zipMEGA mirrorMAKE THE NEXT ANSWER BETTER
What happened on your build?
Share a small example, the exact error and how you verified your fix. The discussion is open on the forum.
Need a scoped quest, UI or proto fix? · Explore more development guides · Check your proto files free