Browse Source

updated readme

changed currently_hovered_region to *label to make more sense
master
Christian Voigt 1 year ago
parent
commit
cd3eb4d1b1
  1. 5
      README.md
  2. 30
      world_regions_widget/__init__.py
  3. 2
      world_regions_widget/region_label_collection.py

5
README.md

@ -11,7 +11,8 @@ the whole project needs to be defined
That's about it for now
#### Core Functions
Loading of 7dtd RAW map files (dtm.raw, any RAW 16bit grayscale that's stored in order) (CTRL+O)
*proper* Zooming in and out and navigate in a loaded map (Wheel, rightMouseDrag)
Loading of 7dtd RAW map files (dtm.raw, any RAW 16bit grayscale that's stored in order) (CTRL+O)
Saving of any loaded map. It's of no use due to the fact that we can't change anything yet :) (CTRL+S)
*proper* Zooming in and out and navigating in a loaded map (Wheel, rightMouseDrag)
Visually marking and unmarking regions of a loaded 7dtd map file (CTRL+leftMouse)
Identifying region strings (Statusbar on Hover)

30
world_regions_widget/__init__.py

@ -37,7 +37,7 @@ class WorldRegionsWidget(QScrollArea):
world_regions_image = QImage
world_regions_image_raw_data = np.array
currently_hovered_region = object
currently_hovered_label = object
cursor_add_region = QCursor
cursor_remove_region = QCursor
@ -110,8 +110,8 @@ class WorldRegionsWidget(QScrollArea):
self.setCursor(self.cursor_hover_region)
def set_currently_hovered_region(self, label):
self.currently_hovered_region = label
def set_currently_hovered_label(self, label):
self.currently_hovered_label = label
def get_zoom_adjusted_label_size(self):
return self.world_label_zoom_factor * self.world_label_region_size
@ -141,10 +141,10 @@ class WorldRegionsWidget(QScrollArea):
self.adjust_mouse_position()
def adjust_scrollbar_positions(self):
size = (self.currently_hovered_region.width())
size = (self.currently_hovered_label.width())
widget_index_x = int(self.currently_hovered_region.region_string.split(".")[1]) + 17
widget_index_y = int((int(self.currently_hovered_region.region_string.split(".")[2]) * -1)) + 16
widget_index_x = int(self.currently_hovered_label.region_string.split(".")[1]) + 17
widget_index_y = int((int(self.currently_hovered_label.region_string.split(".")[2]) * -1)) + 16
widget_position_x = int(widget_index_x * size)
widget_position_y = int(widget_index_y * size)
@ -157,16 +157,16 @@ class WorldRegionsWidget(QScrollArea):
)
def adjust_mouse_position(self):
QCursor.setPos(self.currently_hovered_region.mapToGlobal(QPoint(
int(self.currently_hovered_region.width() / 2),
int(self.currently_hovered_region.height() / 2)
QCursor.setPos(self.currently_hovered_label.mapToGlobal(QPoint(
int(self.currently_hovered_label.width() / 2),
int(self.currently_hovered_label.height() / 2)
)))
def trigger_cursor_change(self, event=None):
modifiers = QApplication.keyboardModifiers()
if modifiers == Qt.ControlModifier or (event is not None and event.key() in (16777249, 16777250)):
try:
currently_hovered_region_is_marked = self.currently_hovered_region.is_marked
currently_hovered_region_is_marked = self.currently_hovered_label.is_marked
except AttributeError:
currently_hovered_region_is_marked = None
@ -176,11 +176,11 @@ class WorldRegionsWidget(QScrollArea):
self.setCursor(self.cursor_add_region)
elif modifiers == Qt.ShiftModifier or (event is not None and event.key() == 16777248):
try:
currently_hovered_region_is_loaded = self.currently_hovered_region.is_region
currently_hovered_region_is_region = self.currently_hovered_label.is_region
except AttributeError:
currently_hovered_region_is_loaded = None
currently_hovered_region_is_region = None
if currently_hovered_region_is_loaded:
if currently_hovered_region_is_region:
self.setCursor(self.cursor_plot_region)
else:
self.setCursor(self.cursor_hover_region)
@ -192,7 +192,7 @@ class WorldRegionsWidget(QScrollArea):
if event.button() == Qt.LeftButton:
self.trigger_cursor_change()
modifiers = QApplication.keyboardModifiers()
if modifiers == Qt.ShiftModifier and self.currently_hovered_region.is_region:
if modifiers == Qt.ShiftModifier and self.currently_hovered_label.is_region:
pass
if event.button() == Qt.RightButton:
@ -269,7 +269,7 @@ class WorldRegionsWidget(QScrollArea):
self.region_label_collection.update_label_collection_with_raw_map_data(
raw_data_array, length, offset=offset
)
def save_world_file_dialogue(self):
options = QFileDialog.Options()
file_name, _ = QFileDialog.getSaveFileName(

2
world_regions_widget/region_label_collection.py

@ -19,7 +19,7 @@ class RegionLabelCollection(QGridLayout):
self.create_label_collection(size)
def set_currently_hovered_label(self, region_label):
self.world_regions.set_currently_hovered_region(region_label)
self.world_regions.set_currently_hovered_label(region_label)
for index, label in self.label_collection.items():
if region_label is not label:
label.is_selected = False

Loading…
Cancel
Save