Skip to content

Commit 040e860

Browse files
committed
add 13.9.0 files
1 parent 1367931 commit 040e860

File tree

147 files changed

+10773
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+10773
-9
lines changed

generated/abilities.json

+1-1
Large diffs are not rendered by default.

generated/achievements.json

+1-1
Large diffs are not rendered by default.

generated/buildings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"4288117680": "RayTower", "4289166256": "RayTower", "4292311984": "RayTower", "4293360560": "RayTower", "4286020528": "RayTower", "4288641968": "AirBase", "4290739120": "AirBase", "4289690544": "AirBase", "4291787696": "AirBase", "4293884848": "AirBase", "4292836272": "AirBase", "4277435312": "Complex", "4292803504": "CoastalArtillery", "4269046704": "Complex", "4279532464": "Complex", "4290214832": "RayTower", "4282350512": "AirBase", "4270095280": "Complex", "4287232944": "Military", "4288281520": "Military", "4285135792": "Military", "4291263408": "RayTower", "4281990064": "Military", "4287593392": "AirBase", "4080303024": "Complex", "4082400176": "Complex", "4081351600": "Complex", "4286544816": "AirBase", "4271831984": "CoastalArtillery", "4292869040": "AntiAircraft", "4293917616": "AntiAircraft", "4190993328": "Fake", "4267539376": "Fake", "4290018224": "Complex", "4287921072": "Complex", "4286872496": "Complex", "4293163952": "Complex", "4291066800": "Complex", "4285823920": "Complex", "4284775344": "Complex", "4273241008": "Complex", "4272192432": "Complex", "4293491632": "SpaceStation", "4283923376": "RayTower", "4284447664": "AirBase", "4288969648": "Complex", "4292705200": "Fake", "4292279216": "SensorTower", "4287069104": "RayTower", "4283399088": "AirBase", "4284971952": "RayTower", "4284087216": "Military", "4283038640": "Military", "4278844336": "Military", "4287560624": "CoastalArtillery", "4271143856": "Complex", "4280941488": "Military", "4276386736": "Complex", "4278483888": "Complex", "4280581040": "Complex", "4281629616": "Complex", "4282678192": "Complex", "4283726768": "Complex", "4274289584": "Complex", "4275338160": "Complex", "4270783408": "CoastalArtillery", "4289330096": "Military", "4286184368": "Military", "4062837680": "Military", "4293327792": "SensorTower", "4291230640": "SensorTower", "4290182064": "SensorTower", "4285496240": "AirBase", "4288609200": "CoastalArtillery", "3247274928": "Fake", "4293852080": "CoastalArtillery", "4289657776": "CoastalArtillery", "4293721008": "Generator", "4279892912": "Military", "4267998128": "Complex"}
1+
{"4288117680": "RayTower", "4289166256": "RayTower", "4292311984": "RayTower", "4293360560": "RayTower", "4286020528": "RayTower", "4288641968": "AirBase", "4290739120": "AirBase", "4289690544": "AirBase", "4291787696": "AirBase", "4293884848": "AirBase", "4292836272": "AirBase", "4277435312": "Complex", "4292803504": "CoastalArtillery", "4269046704": "Complex", "4279532464": "Complex", "4290214832": "RayTower", "4282350512": "AirBase", "4270095280": "Complex", "4287232944": "Military", "4288281520": "Military", "4285135792": "Military", "4291263408": "RayTower", "4281990064": "Military", "4287593392": "AirBase", "4080303024": "Complex", "4082400176": "Complex", "4081351600": "Complex", "4286544816": "AirBase", "4271831984": "CoastalArtillery", "4292869040": "AntiAircraft", "4293917616": "AntiAircraft", "4190993328": "Fake", "4267539376": "Fake", "4290018224": "Complex", "4287921072": "Complex", "4286872496": "Complex", "4293163952": "Complex", "4291066800": "Complex", "4285823920": "Complex", "4284775344": "Complex", "4273241008": "Complex", "4272192432": "Complex", "4293491632": "SpaceStation", "4283923376": "RayTower", "4284447664": "AirBase", "4288969648": "Complex", "4292705200": "Fake", "4287069104": "RayTower", "4283399088": "AirBase", "4284971952": "RayTower", "4284087216": "Military", "4283038640": "Military", "4278844336": "Military", "4287560624": "CoastalArtillery", "4271143856": "Complex", "4280941488": "Military", "4276386736": "Complex", "4278483888": "Complex", "4280581040": "Complex", "4281629616": "Complex", "4282678192": "Complex", "4283726768": "Complex", "4274289584": "Complex", "4275338160": "Complex", "4270783408": "CoastalArtillery", "4289330096": "Military", "4286184368": "Military", "4062837680": "Military", "4293327792": "SensorTower", "4291230640": "SensorTower", "4292279216": "SensorTower", "4290182064": "SensorTower", "4285496240": "AirBase", "4288609200": "CoastalArtillery", "3247274928": "Fake", "4293852080": "CoastalArtillery", "4289657776": "CoastalArtillery", "4293721008": "Generator", "4279892912": "Military", "4267998128": "Complex"}

generated/exteriors.json

+1-1
Large diffs are not rendered by default.

generated/modernizations.json

+1-1
Large diffs are not rendered by default.

generated/planes.json

+1-1
Large diffs are not rendered by default.

generated/projectiles.json

+1-1
Large diffs are not rendered by default.

generated/ships.json

+1-1
Large diffs are not rendered by default.

generated/units.json

+1-1
Large diffs are not rendered by default.

replays/139.wowsreplay

3.1 MB
Binary file not shown.

resources/GameParams.data

103 KB
Binary file not shown.

resources/global.mo

14.7 KB
Binary file not shown.
Loading
1.71 KB
Loading
Loading
Loading
-40 Bytes
Loading
75 Bytes
Loading
Loading
2.12 KB
Loading
Loading
Loading
3.1 KB
Loading
Loading
Loading
1.84 KB
Loading
Loading
Loading
1.6 KB
Loading
Loading
Loading
2.74 KB
Loading
Loading
Loading

src/renderer/versions/13_9_0/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .capture import LayerCapture
2+
from .health import LayerHealthBase as LayerHealth
3+
from .markers import LayerMarkersBase as LayerMarkers
4+
from .ribbon import LayerRibbon
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
from typing import Optional
2+
from PIL import Image, ImageDraw
3+
from renderer.base import LayerBase
4+
from renderer.render import Renderer
5+
from renderer.const import COLORS_NORMAL, RELATION_NORMAL_STR
6+
from renderer.utils import replace_color
7+
from renderer.data import ReplayData
8+
from functools import lru_cache
9+
10+
11+
class LayerCapture(LayerBase):
12+
"""A class for handling/drawing capture points.
13+
14+
Args:
15+
LayerBase (_type_): _description_
16+
"""
17+
18+
def __init__(
19+
self, renderer: Renderer, replay_data: Optional[ReplayData] = None
20+
):
21+
"""Initiates this class.
22+
23+
Args:
24+
renderer (Renderer): The renderer.
25+
"""
26+
self._renderer = renderer
27+
self._replay_data = (
28+
replay_data if replay_data else self._renderer.replay_data
29+
)
30+
self._owner = self._replay_data.player_info[self._replay_data.owner_id]
31+
self._generated_caps: dict[
32+
int, tuple[Image.Image, tuple[int, int], int]
33+
] = {}
34+
35+
def draw(self, game_time: int, image: Image.Image):
36+
"""Draws the capture area on the minimap image.
37+
38+
Args:
39+
game_time (int): Game time. Used to sync. events.
40+
image (Image.Image): Image where the capture are will be pasted on.
41+
"""
42+
events = self._replay_data.events
43+
cps = events[game_time].evt_control.values()
44+
45+
for count, cp in enumerate(cps):
46+
if not cp.is_visible:
47+
continue
48+
49+
if count in self._generated_caps:
50+
cap_image, cap_pos, cap_hash = self._generated_caps[count]
51+
if hash(cp) == cap_hash:
52+
image.alpha_composite(cap_image, cap_pos)
53+
continue
54+
55+
x, y = self._renderer.get_scaled(cp.position)
56+
radius = self._renderer.get_scaled_r(cp.radius)
57+
w = h = round(radius * 2)
58+
cp_area = self._get_capture_area(cp.relation, (w, h))
59+
60+
if cp.control_point_type == 5:
61+
icon_name = "flag.png"
62+
else:
63+
icon_name = f"lettered_{count}.png"
64+
65+
relation_str = RELATION_NORMAL_STR[cp.relation]
66+
icon = self._renderer.resman.load_image(
67+
icon_name, path=f"cap_icons.{relation_str}"
68+
)
69+
70+
if cp.has_invaders and cp.invader_team != -1:
71+
if cp.invader_team == self._owner.team_id:
72+
from_color = COLORS_NORMAL[cp.relation]
73+
to_color = COLORS_NORMAL[0]
74+
else:
75+
from_color = COLORS_NORMAL[cp.relation]
76+
to_color = COLORS_NORMAL[1]
77+
progress = self._get_progress(
78+
from_color, to_color, cp.progress
79+
)
80+
else:
81+
normal = self._renderer.resman.load_image("cap_normal.png")
82+
from_color = "#000000"
83+
to_color = COLORS_NORMAL[cp.relation]
84+
progress = replace_color(normal, from_color, to_color)
85+
86+
px = round(cp_area.width / 2 - progress.width / 2) + 1
87+
py = round(cp_area.height / 2 - progress.height / 2) + 1
88+
89+
cp_area.alpha_composite(progress, (px, py))
90+
91+
ix = round(cp_area.width / 2 - icon.width / 2) + 1
92+
iy = round(cp_area.height / 2 - icon.height / 2) + 1
93+
94+
cp_area.alpha_composite(icon, (ix, iy))
95+
96+
cx = round(x - cp_area.width / 2)
97+
cy = round(y - cp_area.height / 2)
98+
99+
self._generated_caps[count] = (
100+
cp_area.copy(),
101+
(cx, cy),
102+
hash(cp)
103+
)
104+
105+
image.alpha_composite(cp_area, (cx, cy))
106+
107+
def _get_capture_area(self, relation: int, size: tuple) -> Image.Image:
108+
"""Loads the proper capture area image from the resources.
109+
110+
Args:
111+
relation (int): relation
112+
size (tuple): size of the image.
113+
114+
Returns:
115+
Image.Image: Image of the capture area, resized.
116+
"""
117+
relation_to_str = {-1: "neutral", 0: "ally", 1: "enemy"}
118+
filename = f"cap_{relation_to_str[relation]}.png"
119+
return self._renderer.resman.load_image(filename, size=size)
120+
121+
@lru_cache
122+
def _get_progress(self, from_color: str, to_color: str, percent: float):
123+
"""Gets the diamond progress `bar` from the resources and properly
124+
color it depending from the colors and percentage provided.
125+
126+
Args:
127+
from_color (str): From color.
128+
to_color (str): To color.
129+
percent (float): Percentage of the progress. 0.0 to 1.0
130+
131+
Returns:
132+
Image.Image: Diamond progress `bar` image.
133+
"""
134+
pd = self._renderer.resman.load_image("cap_invaded.png")
135+
136+
bg_diamond = replace_color(pd, "#000000", from_color)
137+
fg_diamond = replace_color(pd, "#000000", to_color)
138+
mask = Image.new("RGBA", pd.size)
139+
mask_draw = ImageDraw.Draw(mask, "RGBA")
140+
mask_draw.pieslice(
141+
(
142+
(0, 0),
143+
(pd.width - 1, pd.height - 1),
144+
),
145+
start=-90,
146+
end=(-90 + 360 * percent),
147+
fill="black",
148+
)
149+
bg_diamond.paste(fg_diamond, mask=mask)
150+
return bg_diamond

0 commit comments

Comments
 (0)