Asset-Frameworker/ProjectNotes/GUI_Overhaul_Plan_Unified_View.md
Rusfort 6971b8189f Data Flow Overhaul
Known regressions in current commit:
- No "extra" files
- GLOSS map does not look corrected
- "override" flag is not respected
2025-05-01 09:13:20 +02:00

5.7 KiB

GUI Overhaul Plan: Unified Hierarchical View

Task: Implement a UI overhaul for the Asset Processor Tool GUI to address usability issues and streamline the workflow for viewing and editing processing rules.

Context:

  • A hierarchical rule system (SourceRule, AssetRule, FileRule in rule_structure.py) is used by the core engine (asset_processor.py).
  • The current GUI (gui/main_window.py, gui/rule_hierarchy_model.py, gui/rule_editor_widget.py) uses a QTreeView for hierarchy, a separate RuleEditorWidget for editing selected items, and a QTableView (PreviewTableModel) for previewing file classifications.
  • Relevant files analyzed: gui/main_window.py, gui/rule_editor_widget.py, gui/rule_hierarchy_model.py.

Identified Issues with Current UI:

  1. Window Resizing: Selecting Source/Asset items causes window expansion because RuleEditorWidget displays large child lists (assets, files) as simple labels.
  2. GUI Not Updating on Add: Potential regression where adding new inputs doesn't reliably update the preview/hierarchy.
  3. Incorrect Source Display: Tree view shows "Source: None" instead of the input path (likely SourceRule.input_path is None when model receives it).
  4. Preview Table Stale: Changes made in RuleEditorWidget (e.g., overrides) are not reflected in the PreviewTableModel because the _on_rule_updated slot in main_window.py doesn't trigger a refresh.

Agreed-Upon Overhaul Plan:

The goal is to create a more unified and streamlined experience by merging the hierarchy, editing overrides, and preview aspects into a single view, reducing redundancy.

  1. UI Structure Redesign:

    • Left Panel: Retain the existing Preset Editor panel (main_window.py's editor_panel) for managing preset files (.json) and their complex rules (naming patterns, map type mappings, archetype rules, etc.).
    • Right Panel: Replace the current three-part splitter (Hierarchy Tree, Rule Editor, Preview Table) with a single Unified Hierarchical View.
      • Implementation: Use a QTreeView with a custom QAbstractItemModel and custom QStyledItemDelegates for inline editing.
      • Hierarchy Display: Show Input Source(s) -> Assets -> Files.
      • Visual Cues: Use distinct background colors for rows representing Inputs, Assets, and Files.
  2. Unified View Columns & Functionality:

    • Column 1: Name/Hierarchy: Displays input path, asset name, or file name with indentation.
    • Column 2+: Editable Attributes (Context-Dependent): Implement inline editors using delegates:
      • Input Row: Optional editable field for Supplier override.
      • Asset Row: QComboBox delegate for Asset-Type override (e.g., GENERIC, DECAL, MODEL).
      • File Row:
        • QLineEdit delegate for Target Asset Name override.
        • QComboBox delegate for Item-Type override (e.g., MAP-COL, MAP-NRM, EXTRA, MODEL_FILE).
    • Column X: Status (Optional, Post-Processing): Non-editable column showing processing status icon/text (Pending, Success, Warning, Error).
    • Column Y: Output Path (Optional, Post-Processing): Non-editable column showing the final output path after successful processing.
  3. Data Flow and Initialization:

    • When inputs are added and a preset selected, PredictionHandler runs.
    • PredictionHandler generates the SourceRule hierarchy and predicts initial Asset-Type, Item-Type, and Target Asset Name.
    • The Unified View's model is populated with this SourceRule.
    • Initial values in inline editors are set based on these predicted values.
    • User edits in the Unified View directly modify attributes on the SourceRule, AssetRule, or FileRule objects held by the model.
  4. Dropdown Options Source:

    • Available options in dropdowns (Asset-Type, Item-Type) should be sourced from globally defined lists or Enums (e.g., in rule_structure.py or config.py).
  5. Addressing Original Issues (How the Plan Fixes Them):

    • Window Resizing: Resolved by removing RuleEditorWidget.
    • GUI Not Updating on Add: Fix requires ensuring add_input_paths triggers PredictionHandler and updates the new Unified View model correctly.
    • Incorrect Source Display: Fix requires ensuring PredictionHandler correctly populates SourceRule.input_path.
    • Preview Table Stale: Resolved by merging preview/editing; edits are live in the main view.

Implementation Tasks:

  • Modify gui/main_window.py: Remove the right-side splitter, RuleEditorWidget, PreviewTableModel/View. Instantiate the new Unified View. Adapt add_input_paths, start_processing, _on_rule_hierarchy_ready, etc., to interact with the new view/model.
  • Create/Modify Model (gui/rule_hierarchy_model.py or new file): Implement a QAbstractItemModel supporting multiple columns, hierarchical data, and providing data/flags for inline editing.
  • Create Delegates (gui/delegates.py?): Implement QStyledItemDelegate subclasses for QComboBox and QLineEdit editors in the tree view.
  • Modify gui/prediction_handler.py: Ensure it predicts initial override values (Asset-Type, Item-Type, Target Asset Name) and includes them in the data passed back to the main window (likely within the SourceRule structure or alongside it). Ensure SourceRule.input_path is correctly set.
  • Modify gui/processing_handler.py: Update it to potentially signal back status/output path updates that can be reflected in the new Unified View model's optional columns.
  • Define Dropdown Sources: Add necessary Enums or lists to rule_structure.py or config.py.

This plan provides a clear path forward for implementing the UI overhaul.