From 58d350bd055f241f950e5c6d25cd838103119733 Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Sat, 13 Sep 2025 07:22:04 -0600 Subject: [PATCH] Add control to change the missing tile color This control allows a user to set the missing tile color to any color they want. The current default missing tile color is a dark gray, which makes it hard to see, which is fairly acceptable during normal operation since it makes missing tiles less noticable. But if one is tuning the maxwait setting, they might want to see more easily any missing tiles. This can help them distinguish between actual missing tiles and "popping" caused by differences in textures between ZLs. --- autoortho/aoconfig.py | 2 ++ autoortho/config_ui_qt.py | 76 +++++++++++++++++++++++++++++++++++++-- autoortho/getortho.py | 10 +++++- 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/autoortho/aoconfig.py b/autoortho/aoconfig.py index 6983c8a8..cc47a9b1 100644 --- a/autoortho/aoconfig.py +++ b/autoortho/aoconfig.py @@ -92,6 +92,8 @@ class AOConfig(object): simheaven_compat = False # Using custom generated Ortho4XP tiles along with AutoOrtho. using_custom_tiles = False +# Color used for missing textures. +missing_color = [66, 77, 55] [pydds] # ISPC or STB for dds file compression diff --git a/autoortho/config_ui_qt.py b/autoortho/config_ui_qt.py index 95fe3486..16410e62 100644 --- a/autoortho/config_ui_qt.py +++ b/autoortho/config_ui_qt.py @@ -22,13 +22,14 @@ QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QTabWidget, QPushButton, QLabel, QLineEdit, QCheckBox, QComboBox, QSlider, QTextEdit, QFileDialog, QMessageBox, QScrollArea, - QSplashScreen, QGroupBox, QProgressBar, QStatusBar, QFrame, QSpinBox + QSplashScreen, QGroupBox, QProgressBar, QStatusBar, QFrame, QSpinBox, + QColorDialog ) from PySide6.QtCore import ( Qt, QThread, Signal, QTimer, QSize ) from PySide6.QtGui import ( - QPixmap, QIcon + QPixmap, QIcon, QColor ) import downloader @@ -995,6 +996,35 @@ def refresh_settings_tab(self): threads_layout.addStretch() autoortho_layout.addLayout(threads_layout) + missing_color_layout = QHBoxLayout() + missing_color_layout.setSpacing(10) + missing_color_label = QLabel("Missing Tile Color:") + missing_color_label.setToolTip( + "This is the solid color used to fill a texture when\n" + "scenery data cannot be fetched. It can be useful to\n" + "set this to a more visible color when tuning the maxwait\n" + "setting to make it easier to see missing textures." + ) + self.missing_color_button = StyledButton("Select") + self.missing_color = QColor( + self.cfg.autoortho.missing_color[0], + self.cfg.autoortho.missing_color[1], + self.cfg.autoortho.missing_color[2], + ) + self.update_missing_color_button() + self.missing_color_button.clicked.connect(self.show_missing_color_dialog) + + self.reset_color_button = StyledButton("Reset") + self.reset_color_button.setToolTip( + "Reset the missing texture color to the default gray." + ) + self.reset_color_button.clicked.connect(self.reset_missing_color) + missing_color_layout.addWidget(missing_color_label) + missing_color_layout.addWidget(self.missing_color_button) + missing_color_layout.addWidget(self.reset_color_button) + missing_color_layout.addStretch() + autoortho_layout.addLayout(missing_color_layout) + if self.cfg.autoortho.using_custom_tiles: self.info_label = QLabel( "Note: You are using custom tiles. Max zoom near airports setting is incompatible with custom tiles, all tiles will be capped to the general max zoom level you set.\n\n" @@ -1203,6 +1233,45 @@ def refresh_settings_tab(self): self.settings_layout.addStretch() + def show_missing_color_dialog(self): + color = QColorDialog.getColor( + self.missing_color, self, "Select missing tile color" + ) + if color.isValid(): + self.missing_color = color + self.update_missing_color_button() + + def _get_missing_color_style(self): + return f""" + QPushButton {{ + background-color: {self.missing_color.name()}; + color: white; + border: 1px solid #555; + padding: 6px 12px; + border-radius: 4px; + font-size: 13px; + }} + QPushButton:hover {{ + background-color: #4A4A4A; + border-color: #1d71d1; + }} + QPushButton:pressed {{ + background-color: #2A2A2A; + }} + QPushButton:disabled {{ + background-color: #2A2A2A; + color: #666; + border-color: #333; + }} + """ + + def update_missing_color_button(self): + self.missing_color_button.setStyleSheet(self._get_missing_color_style()) + + def reset_missing_color(self): + self.missing_color = QColor(66, 77, 55) + self.update_missing_color_button() + def refresh_scenery_list(self): """Refresh the scenery list display""" # Clear existing widgets @@ -1740,6 +1809,9 @@ def save_config(self): self.cfg.autoortho.fetch_threads = str( self.fetch_threads_spinbox.value() ) + self.cfg.autoortho.missing_color = [self.missing_color.red(), + self.missing_color.green(), + self.missing_color.blue()] # DDS settings if not self.system == "darwin": diff --git a/autoortho/getortho.py b/autoortho/getortho.py index 3e92c18a..bebcd03b 100644 --- a/autoortho/getortho.py +++ b/autoortho/getortho.py @@ -903,7 +903,15 @@ def get_img(self, mipmap, startrow=0, endrow=None, maxwait=5, min_zoom=None): log.debug(f"GET_IMG: Create new image: Zoom: {zoom} | {(img_width, img_height)}") - new_im = AoImage.new('RGBA', (img_width, img_height), (66,77,55)) + new_im = AoImage.new( + "RGBA", + (img_width, img_height), + ( + CFG.autoortho.missing_color[0], + CFG.autoortho.missing_color[1], + CFG.autoortho.missing_color[2], + ), + ) log.debug(f"GET_IMG: Will use image {new_im}")