Skip to content

Commit 07a796a

Browse files
authored
Merge pull request #7 from CraftySalamander/build_order_overlay
Build order overlay from age4builder
2 parents a9847ec + 0b45a69 commit 07a796a

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ API calls are done through [AoE4World.com](https://aoe4world.com/). For build or
3333
* Add or remove build orders with **Add/Remove build order** (write the content on the left panel, and the title on the top of the right panel).
3434
* Write anything for the *Simple TXT format*.
3535
* For the *Illustrated format*, you need to have a JSON format compatible with the [RTS_Overlay](https://github.com/CraftySalamander/RTS_Overlay) from CraftySalamander (see examples [here](https://github.com/CraftySalamander/RTS_Overlay/tree/master/build_orders/aoe4)).
36-
* Many build orders can be downloaded from https://age4builder.com (currently only for *Simple TXT format*, but soon available for both formats).
36+
* Many build orders can be downloaded from https://age4builder.com.
37+
* To get the *Simple TXT format*, click on **Simple TXT Build Order to clipboard** on the top of any open build order (`M` icon).
38+
* To get the *Illustrated format*, click on **Illustrated Build Order to clipboard** on the top of any open build order (**salamander** icon).
3739
* Change their order using **Move build order up/down**.
3840
* Set up hotkeys (with **Hotkey for/to...**) for showing/hiding overlay, cycling between build orders and selecting the previous/next step of a build order (only available for the *Illustrated format*).
3941
* Use the corresponding hotkeys to show/hide/cycle build orders and steps.

src/overlay/build_order_tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ def set_qlabel_settings(self, label: QLabel, settings: QLabelSettings = None):
420420
elif text_alignment == 'right':
421421
label.setAlignment(Qt.AlignRight)
422422

423-
def add_row_from_picture_line(self, parent, line: str, labels_settings: list = None):
423+
def add_row_from_picture_line(self, parent, line: str, labels_settings: list = None,
424+
use_pictures: bool = True):
424425
"""Add a row of labels based on a line mixing text and images.
425426
426427
Parameters
@@ -429,11 +430,13 @@ def add_row_from_picture_line(self, parent, line: str, labels_settings: list = N
429430
line string text line with images between @ markers (e.g. 'text @image@ text')
430431
labels_settings settings for the QLabel elements, must be the same size as the line after splitting,
431432
see 'split_multi_label_line' function (None for default settings).
433+
use_pictures True to use pictures (if available), False to display line as it is.
432434
"""
433435
if len(line) == 0:
434436
return
435437

436-
if (self.game_pictures_folder is None) and (self.common_pictures_folder is None): # no picture
438+
# no picture
439+
if (not use_pictures) or ((self.game_pictures_folder is None) and (self.common_pictures_folder is None)):
437440
label = QLabel('', parent)
438441
label.setFont(QFont(self.font_police, self.font_size))
439442
label.setText(line)

src/overlay/tab_build_orders.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ def update_build_order_display(self, title: str, data: dict, flag_picture: str =
138138
str(target_gold) if (target_gold >= 0) else ' ')
139139
resources_line += spacing + '@' + settings.image_stone + '@ ' + (
140140
str(target_stone) if (target_stone >= 0) else ' ')
141-
resources_line += spacing + '@' + settings.image_villager + '@ ' + (
142-
str(target_villager) if (target_villager >= 0) else ' ')
143-
resources_line += spacing + '@' + settings.image_population + '@ ' + (
144-
str(target_population) if (target_population >= 0) else ' ')
145-
resources_line += spacing + '@' + get_age_image(target_age)
141+
if target_villager >= 0:
142+
resources_line += spacing + '@' + settings.image_villager + '@ ' + str(target_villager)
143+
if target_population >= 0:
144+
resources_line += spacing + '@' + settings.image_population + '@ ' + str(target_population)
145+
if 1 <= target_age <= 4:
146+
resources_line += spacing + '@' + get_age_image(target_age)
146147
if 'time' in data: # add time if indicated
147148
resources_line += '@' + spacing + '@' + settings.image_time + '@' + data['time']
148149

@@ -151,7 +152,7 @@ def update_build_order_display(self, title: str, data: dict, flag_picture: str =
151152
for note in notes:
152153
self.build_order_notes.add_row_from_picture_line(parent=self, line=note)
153154
elif 'txt' in data: # simple TXT file for build order:
154-
self.build_order_notes.add_row_from_picture_line(parent=self, line=str(data['txt']))
155+
self.build_order_notes.add_row_from_picture_line(parent=self, line=str(data['txt']), use_pictures=False)
155156
else:
156157
logger.info('Invalid data for build order.')
157158

0 commit comments

Comments
 (0)