From 390974ba0fc0297eb3e1e8cb32889e4d0f6fc1db Mon Sep 17 00:00:00 2001 From: Khopa Date: Wed, 31 Oct 2018 00:20:29 +0100 Subject: [PATCH] Icons for all kind of targets --- resources/ui/ammo.png | Bin 0 -> 197 bytes resources/ui/comms.png | Bin 0 -> 196 bytes resources/ui/factory.png | Bin 0 -> 220 bytes resources/ui/farp.png | Bin 0 -> 253 bytes resources/ui/fob.png | Bin 0 -> 213 bytes resources/ui/fuel.png | Bin 0 -> 224 bytes resources/ui/oilp.png | Bin 0 -> 227 bytes resources/ui/power.png | Bin 0 -> 235 bytes resources/ui/ware.png | Bin 0 -> 232 bytes ui/overviewcanvas.py | 60 ++++++++++++++++++++++++++++++--------- 10 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 resources/ui/ammo.png create mode 100644 resources/ui/comms.png create mode 100644 resources/ui/factory.png create mode 100644 resources/ui/farp.png create mode 100644 resources/ui/fob.png create mode 100644 resources/ui/fuel.png create mode 100644 resources/ui/oilp.png create mode 100644 resources/ui/power.png create mode 100644 resources/ui/ware.png diff --git a/resources/ui/ammo.png b/resources/ui/ammo.png new file mode 100644 index 0000000000000000000000000000000000000000..c2e6ffc089e10b2101a74e992f1bcc9a241a2636 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DkxL735kHCP2GC{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QJXPB%t#~Y}|+0(@_ z#KJ%M$9V@SreO7ap>B=K7c$wLe%$2Xbr4cw6g+rpS%h<(9EYRJhE49K3f>Qrk}onm lOj6R3>Tn6*J)+FU#;`7X$*eT!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qc&oEhQjyF(^lc$Sg zh=qUhkMj;vOu_2;Lfs!S4`|sLnJhTT*TL4oVdOORsL~gEef}=1vmMtMLcFH1afk~m kYC1d>b_w7;qRhs|a6y;T?P|D=63{dTPgg&ebxsLQ02*L4qyPW_ literal 0 HcmV?d00001 diff --git a/resources/ui/factory.png b/resources/ui/factory.png new file mode 100644 index 0000000000000000000000000000000000000000..0d9f3b2d8965d4428efd0e7ba68ac684fbbb8b64 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qc&oEhQjyF(El&6bh zh=qUhkMj;vOu_2;Lfsu#8N%JxwC&lma53XKw=@R9GF}I_<&sv+D?~aPVmgdk*gBLt zJPX)jOv`u$GJRZZc^v|Gm~0B-IJBry!RexdN>i4CoS^{&L&KWeEoGlhJO|WtKn?%^ literal 0 HcmV?d00001 diff --git a/resources/ui/farp.png b/resources/ui/farp.png new file mode 100644 index 0000000000000000000000000000000000000000..62fef986fd8e11d05c76d2579dddca7754844fd7 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DkxL735kHCP2GC{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QJXPB%t#~Y}o+SA1` z#KM1X|7pPn1s<2+S)xx9*uxS+H)F51 tN9RO=koWr&F8%$&ZJszmr^mU3QNQc0-|w^9*MZJp@O1TaS?83{1OTb8QOE!Q literal 0 HcmV?d00001 diff --git a/resources/ui/fob.png b/resources/ui/fob.png new file mode 100644 index 0000000000000000000000000000000000000000..27b0ab3345baa69e5680dc1f440b74cccfc2a25f GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DkxL735kHCP2GC{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QJXPB%t#~Y|7*we)^ z#KJ%M$9V@SreO7aq3(?2cu25oqGbZqRO3V3K<9>Vm)| zCKbCFDQ&0g4AU8u78pO^h@5jys>3CK_lPnZ8-us#jVX&2Urz-Z&*16m=d#Wzp$PyC CZ#oVD literal 0 HcmV?d00001 diff --git a/resources/ui/fuel.png b/resources/ui/fuel.png new file mode 100644 index 0000000000000000000000000000000000000000..1324adcbd91b9bc0c49e2dc439aa4fac450f3934 GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+L6~vJ#O${~L5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt3(J;P+JIo?1uah@)Y zAr}5~`x-e97;v!6J+*O@yZdX7xoTSl_v!vv(Wor=^YK(o+iT@

<8?dmIcxo=fnz z@4F$ysMWCQLI#JUg8fMk7W>7DEea0O`)oTOC~|xYI+*UJ5OPEGRmYu3m+RARJEYzP P+Qi`L>gTe~DWM4f50*&~ literal 0 HcmV?d00001 diff --git a/resources/ui/oilp.png b/resources/ui/oilp.png new file mode 100644 index 0000000000000000000000000000000000000000..548cdbab160fb4cece27c36bac2d90517e0edd27 GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P@=>&q9iy!t)x7$D3zfgF*C13FE6!3!9>qc&oEhQjyF(EqNj^v zh=u>sUPitK1s>+_N&j97*YxU{tz617b5_g(hx{Xg?{{p=T^}U0WrNs!lvI6;>1s;*b z3=DkxL735kHCP2GC{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QJXPB%t#~Y|7)6>N< z#KM1Se>Z1?0S~Kj;r9}j!lvI6;>1s;*b z3=DkxL735kHCP2GC{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QJXPB%t#~Y|7&C|s( z#KQk*??v7Q0}hv&r#9|tUu@ZQIpT|s<%EboMwOZR1^Oox@9)@`yZ%#m1Lx!IbxSH^ zmG(I}-D0~UdB|J3M~X9e68GA<5eY($%l+M%i}WPI9?7ukd|=|3w%Fh(r)%EAJ`eVn XE(i1;C7a9z+Q{JP>gTe~DWM4fy4y+s literal 0 HcmV?d00001 diff --git a/ui/overviewcanvas.py b/ui/overviewcanvas.py index 7e726a6e..5fe32262 100644 --- a/ui/overviewcanvas.py +++ b/ui/overviewcanvas.py @@ -71,6 +71,12 @@ class OverviewCanvas: self.init_sdl_thread() def build_map_options_panel(self): + + def force_redraw(): + if self.screen: + self.redraw_required = True + self.draw() + col = 0 Label(self.options, text="Ground targets", **STYLES["widget"]).grid(row=0, column=col, sticky=W) Checkbutton(self.options, variable=self.display_ground_targets, **STYLES["radiobutton"]).grid(row=0, @@ -113,7 +119,16 @@ class OverviewCanvas: self.icon_tg = pygame.image.load(os.path.join("resources", "ui", "target.png")) self.icon_sam = pygame.image.load(os.path.join("resources", "ui", "sam.png")) + self.icon_farp = pygame.image.load(os.path.join("resources", "ui", "farp.png")) + self.icon_oilp = pygame.image.load(os.path.join("resources", "ui", "oilp.png")) + self.icon_ware = pygame.image.load(os.path.join("resources", "ui", "ware.png")) self.icon_clr = pygame.image.load(os.path.join("resources", "ui", "cleared.png")) + self.icon_fuel = pygame.image.load(os.path.join("resources", "ui", "fuel.png")) + self.icon_comms = pygame.image.load(os.path.join("resources", "ui", "comms.png")) + self.icon_fob = pygame.image.load(os.path.join("resources", "ui", "fob.png")) + self.icon_power = pygame.image.load(os.path.join("resources", "ui", "power.png")) + self.icon_ammo = pygame.image.load(os.path.join("resources", "ui", "ammo.png")) + self.icon_factory = pygame.image.load(os.path.join("resources", "ui", "factory.png")) self.map = pygame.image.load(os.path.join("resources", self.game.theater.overview_image)).convert() pygame.draw.rect(self.map, self.BLACK, (0, 0, self.map.get_width(), self.map.get_height()), 10) @@ -139,6 +154,8 @@ class OverviewCanvas: self.frontline_vector_cache = {} i = 300 + + def draw(self): try: @@ -208,16 +225,20 @@ class OverviewCanvas: for cp in self.game.theater.controlpoints: + coords = self.transform_point(cp.position) + if self.display_ground_targets.get(): if cp.captured: color = self._player_color() else: color = self._enemy_color() for ground_object in cp.ground_objects: + x, y = self.transform_point(ground_object.position) + pygame.draw.line(surface, color, coords, (x+8,y+8), 1) self.draw_ground_object(ground_object, surface, color, mouse_pos) if self.display_road.get(): - coords = self.transform_point(cp.position) + for connected_cp in cp.connected_points: connected_coords = self.transform_point(connected_cp.position) if connected_cp.captured != cp.captured: @@ -231,14 +252,13 @@ class OverviewCanvas: if cp.captured and not connected_cp.captured and Conflict.has_frontline_between(cp, connected_cp): - # Cache mechanism to avoid performing frontline vector computation on every loop - frontline = None - hash = str(cp.id) + "_" + str(connected_cp.id) - if hash in self.frontline_vector_cache: - frontline = self.frontline_vector_cache[hash] + # Cache mechanism to avoid performing frontline vector computation on every frame + key = str(cp.id) + "_" + str(connected_cp.id) + if key in self.frontline_vector_cache: + frontline = self.frontline_vector_cache[key] else: frontline = Conflict.frontline_vector(cp, connected_cp, self.game.theater) - self.frontline_vector_cache[hash] = frontline + self.frontline_vector_cache[key] = frontline if not frontline: continue @@ -297,20 +317,34 @@ class OverviewCanvas: if ground_object.is_dead: surface.blit(self.icon_clr, (x, y)) else: - if ground_object.name_abbrev == "AA": + if ground_object.category == "aa": surface.blit(self.icon_sam, (x, y)) + elif ground_object.category == "oil": + surface.blit(self.icon_oilp, (x, y)) + elif ground_object.category == "warehouse": + surface.blit(self.icon_ware, (x, y)) + elif ground_object.category == "farp": + surface.blit(self.icon_farp, (x, y)) + elif ground_object.category == "fuel": + surface.blit(self.icon_fuel, (x, y)) + elif ground_object.category == "ammo": + surface.blit(self.icon_ammo, (x, y)) + elif ground_object.category == "fob": + surface.blit(self.icon_fob, (x, y)) + elif ground_object.category == "power": + surface.blit(self.icon_power, (x, y)) + elif ground_object.category == "comms": + surface.blit(self.icon_comms, (x, y)) + elif ground_object.category == "factory": + surface.blit(self.icon_factory, (x, y)) else: surface.blit(self.icon_tg, (x, y)) if rect.collidepoint(mouse_pos): self.draw_ground_object_info(ground_object, (x, y), color, surface); - def render_roads(self): - # Note : This is really slow. Viewport is much smoother when not rendering line. - pass - def draw_ground_object_info(self, ground_object: TheaterGroundObject, pos, color, surface: pygame.Surface): - lb = self.font.render("Type : " + ground_object.name_abbrev, self.ANTIALIASING, color, self.BLACK); + lb = self.font.render(str(ground_object), self.ANTIALIASING, color, self.BLACK); surface.blit(lb, (pos[0] + 18, pos[1])) def transform_point(self, p: Point, treshold=30) -> (int, int):