Skip to content

ButtonLocation

Bases: _DataSetIntEnums

This enum class provides the integer values used to reference the button locations in the game. These button locations are what determines where a unit's train button or a research's research button appears in a building's UI

Examples

25

'row_3_col_1'

Source code in AoE2ScenarioParser/datasets/trigger_lists/button_location.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class ButtonLocation(_DataSetIntEnums):
    """
    This enum class provides the integer values used to reference the button locations in the game. These button
    locations are what determines where a unit's train button or a research's research button appears in a building's
    UI

    **Examples**




    25

    'row_3_col_1'
    """
    _r1c1 = 0
    r1c1 = 1
    r1c2 = 2
    r1c3 = 3
    r1c4 = 4
    r1c5 = 5
    r2c1 = 6
    r2c2 = 7
    r2c3 = 8
    r2c4 = 9
    r2c5 = 10
    r3c1 = 11
    r3c2 = 12
    r3c3 = 13
    r3c4 = 14
    r3c5 = 15

    def attribute_presentation(self):
        val = self.value or 1  # Change VAL 0 to 1
        row = math.ceil(val / 5)
        col = val - (row - 1) * 5
        return f"row_{row}_col_{col}"

    @property
    def dock_page2(self):
        """
        Returns the button location for the second page.
        Used as a suffix to the usual button selection: ``ButtonLocation.r1c1.dock_page2``

        Returns:
            The value representing the button location for the second page
        """
        return self.value + 20

    @classmethod
    def row_col(cls, row: int, col: int) -> int:
        """
        Get the button location ID of the row, column specified

        Args:
            row: The number of the row starting from the top (1-5)
            col: The number of the column starting from the left (1-3)

        Returns:
            The button location ID of the (row, column) location specified
        """
        return cls((row - 1) * 5 + col)

Attributes

r1c1 = 1 class-attribute instance-attribute

Value: 1

r1c2 = 2 class-attribute instance-attribute

Value: 2

r1c3 = 3 class-attribute instance-attribute

Value: 3

r1c4 = 4 class-attribute instance-attribute

Value: 4

r1c5 = 5 class-attribute instance-attribute

Value: 5

r2c1 = 6 class-attribute instance-attribute

Value: 6

r2c2 = 7 class-attribute instance-attribute

Value: 7

r2c3 = 8 class-attribute instance-attribute

Value: 8

r2c4 = 9 class-attribute instance-attribute

Value: 9

r2c5 = 10 class-attribute instance-attribute

Value: 10

r3c1 = 11 class-attribute instance-attribute

Value: 11

r3c2 = 12 class-attribute instance-attribute

Value: 12

r3c3 = 13 class-attribute instance-attribute

Value: 13

r3c4 = 14 class-attribute instance-attribute

Value: 14

r3c5 = 15 class-attribute instance-attribute

Value: 15

dock_page2 property

Returns the button location for the second page. Used as a suffix to the usual button selection: ButtonLocation.r1c1.dock_page2

Returns:

Type Description

The value representing the button location for the second page

Functions


def attribute_presentation(...)

Source code in AoE2ScenarioParser/datasets/trigger_lists/button_location.py
40
41
42
43
44
def attribute_presentation(self):
    val = self.value or 1  # Change VAL 0 to 1
    row = math.ceil(val / 5)
    col = val - (row - 1) * 5
    return f"row_{row}_col_{col}"

def row_col(...) classmethod

Get the button location ID of the row, column specified

Parameters:

Name Type Description Default
row int

The number of the row starting from the top (1-5)

required
col int

The number of the column starting from the left (1-3)

required

Returns:

Type Description
int

The button location ID of the (row, column) location specified

Source code in AoE2ScenarioParser/datasets/trigger_lists/button_location.py
57
58
59
60
61
62
63
64
65
66
67
68
69
@classmethod
def row_col(cls, row: int, col: int) -> int:
    """
    Get the button location ID of the row, column specified

    Args:
        row: The number of the row starting from the top (1-5)
        col: The number of the column starting from the left (1-3)

    Returns:
        The button location ID of the (row, column) location specified
    """
    return cls((row - 1) * 5 + col)