Skip to content

Latest commit

 

History

History
241 lines (191 loc) · 7.07 KB

File metadata and controls

241 lines (191 loc) · 7.07 KB

Modules Viewer Implementation Summary

Overview

Implemented a comprehensive module viewer for fleet carriers with expandable tree view, categorization, and grouping.

Features Implemented

1. Modules Button

  • Added "Modules" button next to "Ships" button in the Shipyard column
  • Button is disabled when no modules are cached for that carrier
  • Clicking opens the Stored Modules window

2. Module Categorization

Modules are organized into a hierarchical structure:

Main Categories:

  • Core Internal Modules (7 types)
  • Optional Internal Modules (20+ types)
  • Hardpoint Weapons (20+ types)
  • Utility Mounts (10+ types)
  • Other Modules (catch-all)

Subcategories: Each main category contains specific subcategories (e.g., "Thrusters", "Pulse Laser", "Shield Booster")

3. Module Grouping

Modules are grouped by exact match:

  • Same module name
  • Same size and class
  • Same engineering type, level, and quality

Example:

  • Two identical "Pulse Laser (Large, Fixed) - Weapon_Overcharged G5" → Shown as (×2)
  • Different engineering levels → Shown separately

4. Expandable Tree View

Hierarchy:

Main Category (count, engineered count)
  └─ Subcategory (count, engineered count)
      └─ Individual modules with details

Behavior:

  • All categories start collapsed
  • Click category name or arrow (▶/▼) to expand/collapse
  • Smooth, intuitive navigation

5. Module Display Format

Format:

Module Name (Size X, Class Y) - (Engineering GX) (×Count) Price CR

Examples:

  • Thrusters (Size 6, Class 5) - (Dirty G3) - 14,197,539 CR
  • AFM Unit (Size 4, Class 5) - (×2) 4,145,240 CR
  • Cargo Rack (Size 5, Class 1) - 97,900 CR

Engineering Display:

  • Shows cleaned-up engineering name (removes prefixes)
  • Shows grade level (G1-G5)
  • Only shown if module is engineered

6. Summary Statistics

Top of window displays:

  • Total Modules: Count of all modules
  • Total Value: Sum of all buy prices (formatted with commas)
  • Engineered: Count of engineered modules

Example:

Total Modules: 101  |  Total Value: 42,156,789 CR  |  Engineered: 19

7. Theme Awareness

  • All widgets use EDMC theme system
  • Scrollbars styled to match theme
  • Colors update when theme changes
  • Consistent with rest of GalaxyGPS UI

8. Sorting

Within subcategories:

  • Modules sorted alphabetically by name
  • Ensures consistent, predictable display

Categories:

  • Main categories sorted alphabetically
  • Subcategories sorted alphabetically

9. Localization

All user-facing strings are translatable:

  • Window title: "Stored Modules"
  • Error messages
  • German translations included

Files Modified/Created

Created:

  1. GalaxyGPS/modules_window.py (450+ lines)
    • Complete module viewer implementation
    • Categorization logic
    • Tree view creation
    • Module grouping and formatting

Modified:

  1. GalaxyGPS/windows.py

    • Added Modules button in Fleet Carrier window
    • Created shipyard_frame to hold Ships and Modules buttons
    • Added error handling for module window
  2. L10n/en.template

    • Added 4 new translation strings
  3. L10n/en.strings

    • Added 4 new translation strings
  4. L10n/de.strings

    • Added 4 German translations

Technical Details

Module Categorization Logic

Uses pattern matching on internal module names:

'powerplant' → ('Core Internal Modules', 'Power Plant')
'pulselaser' → ('Hardpoint Weapons', 'Pulse Laser')
'shieldbooster' → ('Utility Mounts', 'Shield Booster')

Module Information Extraction

Parses internal names to extract:

  • Size (from _sizeX_)
  • Class (from _classY_)
  • Engineering details (from StoredModulesManager)

Grouping Algorithm

Creates unique keys for exact matching:

key = (name, size, class, engineering_string)

All modules with identical keys are grouped and shown with (×count).

Tree View Implementation

  • Uses nested frames for hierarchy
  • Click handlers toggle expand/collapse
  • Visual indicators (▶/▼) show state
  • Proper indentation for readability

Usage

For Users:

  1. Open Fleet Carrier Details window (View All button)
  2. Find your carrier in the list
  3. Click "Modules" button in Shipyard column
  4. Explore modules by expanding categories

For Developers:

# Access module data
modules = plugin.modules_manager.get_modules_for_carrier(callsign)

# Get statistics
total_value = plugin.modules_manager.get_total_modules_value(callsign)
engineered_count = plugin.modules_manager.get_engineered_module_count(callsign)

Example Display

Total Modules: 101  |  Total Value: 42,156,789 CR  |  Engineered: 19

▶ Core Internal Modules (7, 2 Engineered)
▶ Optional Internal Modules (45, 3 Engineered)
▼ Hardpoint Weapons (35, 12 Engineered)
  ▼ Pulse Laser (3, 3 Engineered)
      Pulse Laser (Large, Fixed) - (Overcharged G5) - 68,640 CR
      Pulse Laser (Large, Fixed) - (Overcharged G3) - 68,640 CR
      Pulse Laser (Large, Fixed) - (Overcharged G1) - 68,640 CR
  ▼ Multi-Cannon (2, 1 Engineered)
      Multi-Cannon (Large, Gimbal) - (Overcharged G5) - 507,579 CR
      Multi-Cannon (Large, Gimbal) - 507,579 CR
  ▶ Fragment Cannon (4, 0 Engineered)
  ▶ Remote Flak Launcher (6, 4 Engineered)
▶ Utility Mounts (14, 2 Engineered)

Testing Checklist

✅ Button appears in Fleet Carrier window
✅ Button is disabled when no modules cached
✅ Button is enabled when modules exist
✅ Window opens with correct title
✅ Summary statistics display correctly
✅ Categories expand/collapse properly
✅ Modules group correctly (×count)
✅ Engineering details display correctly
✅ Sorting works (alphabetical)
✅ Theme awareness works
✅ Scrolling works for long lists
✅ Translations work (English/German)
✅ Error handling works (no crashes)

Performance

  • Fast categorization: O(n) where n = number of modules
  • Efficient grouping: Uses defaultdict for O(1) lookups
  • Lazy rendering: Tree nodes only created when expanded
  • Smooth scrolling: Canvas-based scrolling for any list size

Future Enhancements (Optional)

  1. Search/Filter: Add search box to filter modules
  2. Export: Export module list to CSV
  3. Value Sorting: Option to sort by value instead of name
  4. Engineering Filter: Show only engineered modules
  5. Slot Numbers: Display storage slot numbers
  6. Module Transfer: Track when modules move between carriers
  7. Comparison: Compare modules across multiple carriers

Deployment

python deploy.py

Restart EDMC and the Modules button will appear in the Fleet Carrier Details window!

Summary

Complete implementation with all requested features
Hierarchical tree view with expand/collapse
Smart grouping by exact match
Engineering details displayed clearly
Summary statistics at top
Theme-aware styling throughout
Localized for multiple languages
Error-safe with proper handling

The module viewer is production-ready and fully integrated! 🎉