How compumaxx/gba-background-studio works
1. What this repository is
- A desktop editor/converter for Game Boy Advance background assets.
- The core architectural flow is: import image → convert to GBA-ready tiles/palettes/tilemap → edit visually → preview → export assets.
2. Primary runtime and UI stack
- The app is written in Python and uses Qt via PySide6 or PySide2 depending on Python version.
- ui/qt_compat.py is the compatibility boundary that lets the same UI code run on modern and legacy Python/Qt combinations.
- Image and color processing relies on native Python scientific/image libraries listed in requirements.txt and reflected in the core modules.
3. Application entry points
- main.py is the top-level launch point.
- core/main.py likely contains the central application/bootstrap logic used by the GUI.
- GBA_Studio_Wizard.bat is a separate CLI/batch conversion path for legacy or non-GUI usage on Windows, using the same translation language set.
4. Core conversion engine
- The core/ package is the processing pipeline that turns source images into GBA-compatible output.
- Key responsibilities are split by concern:
- image_utils.py for image handling/preprocessing
- quantization.py for palette reduction/color quantization
- palette_utils.py for palette creation/manipulation
- tile_utils.py and tile_optimizer.py for tile slicing and reuse/optimization
- final_assets.py for packaging the final exportable results
- This is the main boundary between editor UI and asset generation logic.
5. Conversion workflow and parameter collection
- The conversion dialog subsystem in ui/dialogs/ gathers user intent before invoking the core pipeline.
- conversion_dialog_ui.py, conversion_dialog_logic.py, conversion_dialog_config.py, and conversion_params.py separate presentation, validation, orchestration, and parameter state.
- Supporting dialogs such as convert_bpp_dialogs.py and gba_compatibility_dialog.py expose constraints around GBA formats and compatibility.
6. Main window as the orchestration layer
- ui/main_window/ is the central UI coordinator.
- It is split into focused modules:
- main.py for window lifecycle/state
- file_ops.py for open/save/export actions
- tab_ops.py for tab switching and tab-specific actions
- toolbar.py and menu_bar.py for command surfaces
- view_ops.py and utils.py for shared window behavior
- This layer connects user actions to conversion, editing, and export flows.
7. Tab-based editing model
- The editor is organized around three main work surfaces:
- ui/preview_tab.py for GBA-like rendering of the current result
- ui/edit_tiles_tab.py for tilemap/tile editing
- ui/edit_palettes_tab.py for palette editing
- The tabs operate on the same underlying asset state, so changes in one tab propagate to the others.
8. Tilemap and drawing interaction subsystem
- Editing behavior is driven by shared interaction helpers:
- ui/tilemap_utils.py for tilemap-specific manipulation
- ui/grid_manager.py for grid overlays and cell geometry
- ui/hover_manager.py for hover/highlight feedback
- ui/shared_utils.py for reusable UI helpers
- ui/palette_grid_view.py and ui/color_editor.py support direct palette manipulation.
- The interaction model is selection/draw/transform oriented rather than a generic document editor.
9. Undo/redo and state history
- ui/history_manager.py captures editing operations for undo/redo.
- This is a key architectural boundary because tile edits, palette changes, and tilemap operations are treated as reversible state transitions.
- The history layer sits between the editing widgets and the shared asset model.
10. Configuration and persistence
- core/config.py, core/config_manager.py, and ui/main_window/config.py handle persistent settings such as language, zoom, and last-session behavior.
- Config is loaded at startup and then used to initialize the window, dialogs, and translation state.
- ui/main_window/file_ops.py also suggests persistent file/session interaction is part of the main window boundary.
11. Localization system
- utils/translator.py is the runtime translation layer.
- Language files live in lang/*.ini, with matching translated docs in docs/.
- The translation system is not just documentation—it is a runtime UI concern affecting menus, dialogs, status text, and the CLI wizard.
12. Assets, library loading, and export outputs
- core/library_loader.py and core/final_assets.py suggest a separation between loading reusable asset/library data and assembling the final export bundle.
- The app’s output is oriented toward GBA toolchains: tilesets, tilemaps, and palettes rather than a single flattened image.
- The assets/ directory holds UI resources like icons, toolbar art, and README screenshots.
13. Platform/support boundaries
- The repo explicitly supports both modern and legacy Windows environments through backend selection and a batch wizard path.
- The architecture therefore has two user-facing modes:
- full Qt GUI
- command-line/batch conversion via .bat
- This dual path is important when drawing the system boundary: the core conversion engine is shared, while the UI surface differs.
14. How to think about the data flow
- Source image enters through file/open or conversion dialog.
- Conversion parameters are collected in the UI and passed to the core pipeline.
- Core modules produce tiles, palettes, and tilemaps.
- The editing tabs mutate that shared asset state with history tracking.
- Preview renders the current state in a GBA-like view.
- Export/file operations package the final assets for external GBA development tools.
Main entry points: main_window/main.py Main window · core/main.py Core main · final_assets.py Final assets · tab_ops.py Tab ops
Components 25
Core engine
Image conversion, tile/palette processing, and export assembly.
- Core main · Application bootstrap and central runtime wiring.
core/main.py - Image utils · Source image handling and preprocessing.
core/image_utils.py - Quantization · Color quantization and palette reduction logic.
core/quantization.py - Palette utils · Palette creation and manipulation helpers.
core/palette_utils.py - Tile utils · Tile slicing and tilemap-oriented helpers.
core/tile_utils.py - Tile optimizer · Tile deduplication and optimization for GBA output.
core/tile_optimizer.py - Final assets · Assembles exportable tiles, palettes, and tilemaps.
core/final_assets.py - Library loader · Loads reusable library or preset asset data.
core/library_loader.py
Qt UI
Main window, dialogs, tabs, and editing interactions.
- Main window · Window lifecycle and top-level UI coordination.
ui/main_window/main.py - File ops · File actions and session-level persistence from the main window.
ui/main_window/file_ops.py - Tab ops · Tab switching and tab-specific action routing.
ui/main_window/tab_ops.py - Preview tab · GBA-like preview of current assets.
ui/preview_tab.py - Tiles tab · Tilemap and tile editing workspace.
ui/edit_tiles_tab.py - Palettes tab · Palette editing workspace.
ui/edit_palettes_tab.py - Dialogs · Conversion dialog orchestration and validation.
ui/dialogs/conversion_dialog.py - Conversion logic · Dialog-side orchestration, validation, and parameter flow.
ui/dialogs/conversion_dialog_logic.py - Conv params · Conversion parameter state passed into the core pipeline.
ui/dialogs/conversion_params.py - Grid tools · Grid geometry, hover feedback, and shared editing helpers.
ui/grid_manager.py - History · Reversible editing state transitions.
ui/history_manager.py
Support systems
Compatibility, configuration, and localization boundaries.
- Qt compat · PySide6/PySide2 compatibility boundary.
ui/qt_compat.py - Core config · Persistent application configuration.
core/config.py - Config manager · Configuration lifecycle and persistence orchestration.
core/config_manager.py - Translator · Runtime translation layer for UI and wizard text.
utils/translator.py
Entry points
Desktop and batch launch surfaces.
- main.py · Top-level GUI entry point.
main.py - Wizard batch · Windows batch conversion path for legacy or non-GUI use.
GBA_Studio_Wizard.bat
Connections 31
- main.py → Main window: launches · Starts the Qt desktop application.
- Wizard batch → Core main: uses · Batch path invokes the shared conversion runtime.
- Main window → Qt compat: depends on · Window code runs through the Qt backend compatibility boundary.
- Main window → Config manager: loads · Initializes window state from persisted settings.
- Main window → Translator: localizes · Applies runtime language text to UI surfaces.
- Config manager → Core config: persists · Loads and saves app settings.
- Core main → Image utils: orchestrates · Bootstraps the asset conversion pipeline.
- Core main → Quantization: orchestrates · Coordinates palette reduction.
- Core main → Tile utils: orchestrates · Coordinates tile slicing and tilemap generation.
- Core main → Final assets: produces · Collects the finished export bundle.
- Image utils → Quantization: feeds · Preprocessed image data enters quantization.
- Quantization → Palette utils: uses · Builds and adjusts palettes from quantized colors.
- Tile utils → Tile optimizer: feeds · Tile extraction is refined by reuse optimization.
- Tile optimizer → Final assets: packages · Optimized tiles are assembled into exportable assets.
- Library loader → Final assets: augments · Reusable library data can be folded into the final output.
- Dialogs → Conversion logic: delegates · UI dialogs hand off workflow orchestration and validation.
- Conversion logic → Conv params: populates · Collects user intent into parameter state.
- Conv params → Core main: invokes · Parameters are passed into the shared conversion engine.
- Main window → File ops: routes · Window actions are routed through file/session operations.
- Main window → Tab ops: routes · Window actions are routed through tab orchestration.
- Tab ops → Preview tab: switches · Coordinates the preview surface.
- Tab ops → Tiles tab: switches · Coordinates the tile editing surface.
- Tab ops → Palettes tab: switches · Coordinates the palette editing surface.
- Tiles tab → Grid tools: uses · Tile editing relies on shared grid and hover helpers.
- Palettes tab → Grid tools: uses · Palette editing uses the shared interaction helpers.
- Tiles tab → History: records · Tile edits are tracked for undo/redo.
- Palettes tab → History: records · Palette edits are tracked for undo/redo.
- Preview tab → Final assets: renders · Preview reflects the current assembled asset state.
- File ops → Final assets: exports · File operations package the final GBA-ready outputs.
- Translator → Dialogs: drives text · Translation strings affect dialog content.
- Translator → Wizard batch: drives text · Localization also affects batch/wizard messaging.