forked from apoguita/Py4GW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeroAI_UI.py
More file actions
1524 lines (1309 loc) · 74.8 KB
/
Copy pathHeroAI_UI.py
File metadata and controls
1524 lines (1309 loc) · 74.8 KB
1
2
3
4
5
6
7
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import math
from typing import Optional
import PyImGui
from HeroAI.cache_data import CacheData, INI_DIR
from HeroAI.utils import IsHeroFlagged
from HeroAI.constants import NUMBER_OF_SKILLS
from HeroAI.commands import HeroAICommands
from Py4GWCoreLib import Py4GW
from Py4GWCoreLib import Agent, Color, GLOBAL_CACHE, ConsoleLog, ManagedWindowSpec, Player, SharedCommandType, Utils, WindowFactory, WindowVarSpec
from Py4GWCoreLib.Map import Map
from Py4GWCoreLib.ImGui import ImGui
from Py4GWCoreLib.ImGui_src.IconsFontAwesome5 import IconsFontAwesome5
from Py4GWCoreLib.ImGui_src.Textures import TextureState, ThemeTexture, ThemeTextures
from Py4GWCoreLib.ImGui_src.types import ImGuiStyleVar, StyleTheme
from Py4GWCoreLib.IniManager import IniManager
from Py4GWCoreLib.enums import ImguiFonts
from Py4GWCoreLib.enums_src.GameData_enums import Allegiance, Profession, ProfessionShort, Range
from Py4GWCoreLib.py4gwcorelib_src.Timer import Timer
from dataclasses import dataclass
PANEL_BASE_WIDTH = 200
PANEL_BASE_HEIGHT = 90
PANEL_MIN_SCALE = 0.65
PANEL_MAX_SCALE = 4.0
RICH_PANEL_WIDTH = 319
RICH_BAR_HEIGHT = 28
MODULE_NAME = "HeroAI"
MODULE_ICON = "Textures/Module_Icons/HeroAI.png"
@dataclass
class HeroAIFloatingIcon:
MODULE_NAME: str = MODULE_NAME
INI_PATH: str = f"{INI_DIR}/"
MAIN_INI_FILENAME: str = "heroai_ui_window.ini"
FLOATING_INI_FILENAME: str = "heroai_ui_floating.ini"
CONFIG_INI_FILENAME: str = "heroai_ui_config_window.ini"
MAIN_INI_KEY: str = ""
FLOATING_INI_KEY: str = ""
CONFIG_INI_KEY: str = ""
INI_INIT: bool = False
ICON_PATH: str = os.path.join(Py4GW.Console.get_projects_path(), "Textures", "Module_Icons", "HeroAI.png")
window_factory = WindowFactory(HeroAIFloatingIcon.INI_PATH)
window_factory.register_window(
ManagedWindowSpec(
identifier="main",
filename=HeroAIFloatingIcon.MAIN_INI_FILENAME,
title=HeroAIFloatingIcon.MODULE_NAME,
flags=PyImGui.WindowFlags.AlwaysAutoResize,
)
)
window_factory.register_window(
ManagedWindowSpec(
identifier="floating",
filename=HeroAIFloatingIcon.FLOATING_INI_FILENAME,
title="HeroAI Floating",
open_var_name="show_main_window",
open_default=True,
)
)
window_factory.register_window(
ManagedWindowSpec(
identifier="appearance",
filename=HeroAIFloatingIcon.CONFIG_INI_FILENAME,
title="HeroAI Appearance Settings",
flags=PyImGui.WindowFlags.AlwaysAutoResize,
open_var_name="show_appearance_window",
open_default=False,
vars=[
WindowVarSpec("float", "panel_table_scale", "Appearance", "panel_table_scale", 1.0),
WindowVarSpec("bool", "show_main_skill_toggles", "Appearance", "show_main_skill_toggles", True),
WindowVarSpec("bool", "show_players", "Appearance", "show_players", True),
WindowVarSpec("bool", "show_player_skill_toggles", "Appearance", "show_player_skill_toggles", True),
WindowVarSpec("bool", "use_rich_player_panels", "Appearance", "use_rich_player_panels", False),
WindowVarSpec("bool", "show_players_in_individual_windows", "Appearance", "show_players_in_individual_windows", False),
WindowVarSpec("bool", "obfuscate_player_names", "Appearance", "obfuscate_player_names", False),
],
)
)
window_factory.register_window(
ManagedWindowSpec(
identifier="players",
filename="heroai_ui_players_window.ini",
title="HeroAI Players",
flags=PyImGui.WindowFlags.AlwaysAutoResize,
open_var_name="show_player_window",
open_default=True,
)
)
def get_panel_dimensions(scale: float) -> tuple[int, int]:
return int(round(PANEL_BASE_WIDTH * scale)), int(round(PANEL_BASE_HEIGHT * scale))
def is_account_outside_compass_range(account) -> bool:
player_pos = Player.GetXY()
account_pos = (account.AgentData.Pos.x, account.AgentData.Pos.y)
return Utils.Distance(player_pos, account_pos) > Range.Compass.value + 10
def push_out_of_range_header_colors(style) -> None:
style.Header.push_color((255, 0, 0, 170))
style.HeaderHovered.push_color((255, 0, 0, 210))
style.HeaderActive.push_color((255, 0, 0, 255))
def pop_out_of_range_header_colors(style) -> None:
style.HeaderActive.pop_color()
style.HeaderHovered.pop_color()
style.Header.pop_color()
def push_out_of_range_window_style(style) -> None:
style.WindowBg.push_color((90, 0, 10, 120))
style.Border.push_color((90, 0, 10, 255))
style.TitleBg.push_color((130, 0, 0, 255))
style.TitleBgActive.push_color((200, 0, 0, 255))
style.TitleBgCollapsed.push_color((130, 0, 0, 255))
style.WindowBorderSize.push_style_var(3)
def pop_out_of_range_window_style(style) -> None:
style.WindowBorderSize.pop_style_var()
style.TitleBgCollapsed.pop_color()
style.TitleBgActive.pop_color()
style.TitleBg.pop_color()
style.Border.pop_color()
style.WindowBg.pop_color()
def push_compact_player_window_spacing(style) -> None:
style.WindowPadding.push_style_var(2, 2)
style.ItemSpacing.push_style_var(0, 0)
style.ItemInnerSpacing.push_style_var(0, 0)
def pop_compact_player_window_spacing(style) -> None:
style.ItemInnerSpacing.pop_style_var()
style.ItemSpacing.pop_style_var()
style.WindowPadding.pop_style_var()
class CachedSkillInfo:
def __init__(self, skill_id: int):
self.skill_id = skill_id
self.name = GLOBAL_CACHE.Skill.GetNameFromWiki(skill_id) or GLOBAL_CACHE.Skill.GetName(skill_id) or str(skill_id)
self.description = GLOBAL_CACHE.Skill.GetDescription(skill_id) or ""
self.texture_path = GLOBAL_CACHE.Skill.ExtraData.GetTexturePath(skill_id)
if not self.texture_path or not os.path.exists(self.texture_path):
self.texture_path = ThemeTexture.PlaceHolderTexture.texture if skill_id != 0 else ""
self.is_elite = GLOBAL_CACHE.Skill.Flags.IsElite(skill_id)
self.is_hex = GLOBAL_CACHE.Skill.Flags.IsHex(skill_id)
self.is_title = GLOBAL_CACHE.Skill.Flags.IsTitle(skill_id)
self.is_enchantment = GLOBAL_CACHE.Skill.Flags.IsEnchantment(skill_id)
self.is_shout = GLOBAL_CACHE.Skill.Flags.IsShout(skill_id)
self.is_skill = GLOBAL_CACHE.Skill.Flags.IsSkill(skill_id)
self.is_condition = GLOBAL_CACHE.Skill.Flags.IsCondition(skill_id)
self.adrenaline_cost = GLOBAL_CACHE.Skill.Data.GetAdrenaline(skill_id)
self.recharge_time = GLOBAL_CACHE.Skill.Data.GetRecharge(skill_id)
self.frame_texture, self.texture_state, self.progress_color = get_frame_texture_for_effect(skill_id)
class HealthState:
Normal = Color(204, 0, 0, 255)
Poisoned = Color(116, 116, 48, 255)
Bleeding = Color(224, 119, 119, 255)
DegenHexed = Color(196, 56, 150, 255)
Disconnected = Color(54, 54, 54, 255)
def get_frame_texture_for_effect(skill_id: int):
is_elite = GLOBAL_CACHE.Skill.Flags.IsElite(skill_id)
texture_state = TextureState.Normal if not is_elite else TextureState.Active
theme = ImGui.get_style().Theme if ImGui.get_style().Theme in ImGui.Textured_Themes else StyleTheme.Guild_Wars
if GLOBAL_CACHE.Skill.Flags.IsHex(skill_id):
frame_texture = ThemeTextures.Effect_Frame_Hex.value.get_texture(theme)
progress_color = Color(215, 31, 158, 255).color_int
elif GLOBAL_CACHE.Skill.Flags.IsTitle(skill_id):
frame_texture = ThemeTextures.Effect_Frame_Skill.value.get_texture(theme)
progress_color = Color(75, 139, 69, 255).color_int
elif GLOBAL_CACHE.Skill.Flags.IsEnchantment(skill_id):
frame_texture = ThemeTextures.Effect_Frame_Enchantment.value.get_texture(theme)
progress_color = Color(178, 225, 47, 255).color_int
profession, _ = GLOBAL_CACHE.Skill.GetProfession(skill_id)
if profession == Profession.Dervish:
frame_texture = ThemeTextures.Effect_Frame_Blue.value.get_texture()
progress_color = Color(74, 163, 193, 255).color_int
elif GLOBAL_CACHE.Skill.Flags.IsCondition(skill_id):
frame_texture = ThemeTextures.Effect_Frame_Condition.value.get_texture(theme)
progress_color = Color(221, 175, 52, 255).color_int
else:
frame_texture = ThemeTextures.Effect_Frame_Skill.value.get_texture(theme)
progress_color = Color(75, 139, 69, 255).color_int
return frame_texture, texture_state, progress_color
class HeroAI_PlayerPanelRenderer:
male_aliases = [
"Garrick Stonefaceplant",
"Rurik Returned",
"Talon Crittingham",
"Brom Shieldslapper",
"Dorian Interrupticus",
"Kestrel Longrecharge",
"Magnus Aftercastius",
"Devlin Overpuller",
"Harlan Aggrosworth",
"Fenric Lineofsighter",
"Alden Bodyblockson",
"Torvin Energyless",
"Cassian MissedAgain",
"Perrin StillCasting",
"Jarek WrongTarget",
"Ulric Laghammer",
"Bran OopsAllWipes",
"Merek TooCloseToDoor",
"Darion RezPlz",
"Valric PullRangeTester",
]
female_aliases = [
"Lyessa Hexington",
"Merali Spiritspammer",
"Kaelira Wanderson",
"Virelle Overaggra",
"Elowyn TooSquishy",
"Sarielle EnergyCrisis",
"Nymera Castbarlong",
"Tahlira Backlinerun",
"Mireya Interruptia",
"Kelindra PingTooHigh",
"Vaelene LostCompass",
"Ariselle Minionmancer",
"Liorra WrongBuild",
"Serethia StillLoading",
"Ismara PetStuck",
"Velina SpiritWall",
"Caelyra Aftershockia",
"Nyssara Overenchanted",
"Talindra ShadowStepOops",
"Melira FlagRunnerLost",
]
def __init__(self, appearance_window: "HeroAI_AppearanceWindow") -> None:
self.appearance_window = appearance_window
self.rich_renderer = HeroAI_RichPlayerPanelRenderer(appearance_window)
def get_display_name(self, account) -> str:
name = account.AgentData.CharacterName
if not self.appearance_window.get_obfuscate_player_names():
return name
aliases = self.female_aliases if Agent.IsFemale(account.AgentData.AgentID) else self.male_aliases
score_source = f"{name}|{account.AccountEmail}".encode("utf-8", errors="ignore")
score = sum(score_source)
return aliases[score % len(aliases)]
def get_window_title(self, account) -> str:
display_name = self.get_display_name(account)
primary_prof = ProfessionShort(account.AgentData.Profession[0]).name if account.AgentData.Profession[0] != 0 else ""
secondary_prof = ProfessionShort(account.AgentData.Profession[1]).name if account.AgentData.Profession[1] != 0 else ""
return f"{primary_prof}{('/' if secondary_prof else '')}{secondary_prof}{account.AgentData.Level} {display_name}"
def draw_simple_panel(self, identifier: str, game_option) -> None:
if game_option is None:
return
style = ImGui.get_style()
table_width, _ = get_panel_dimensions(self.appearance_window.get_panel_scale())
btn_size = (table_width / 5) - 4
skill_size = (table_width / NUMBER_OF_SKILLS) - 8
style.ItemSpacing.push_style_var(0, 0)
style.CellPadding.push_style_var(2, 2)
if PyImGui.begin_table(f"FollowerGameOptionTable##{identifier}", 3, 0, 0, btn_size + 2):
PyImGui.table_next_row()
PyImGui.table_next_column()
following = ImGui.toggle_button(IconsFontAwesome5.ICON_RUNNING + f"##Following{identifier}", game_option.Following, btn_size * 1.45, btn_size)
if following != game_option.Following:
game_option.Following = following
ImGui.show_tooltip("Follow / Avoidance")
PyImGui.table_next_column()
looting = ImGui.toggle_button(IconsFontAwesome5.ICON_COINS + f"##Looting{identifier}", game_option.Looting, btn_size * 1.45, btn_size)
if looting != game_option.Looting:
game_option.Looting = looting
ImGui.show_tooltip("Looting")
PyImGui.table_next_column()
combat = ImGui.toggle_button(IconsFontAwesome5.ICON_SKULL_CROSSBONES + f"##Combat{identifier}", game_option.Combat, btn_size * 1.45, btn_size)
if combat != game_option.Combat:
game_option.Combat = combat
ImGui.show_tooltip("Combat")
PyImGui.end_table()
if self.appearance_window.get_show_player_skill_toggles():
style.ButtonPadding.push_style_var(5 if style.Theme not in ImGui.Textured_Themes else 0, 3 if style.Theme not in ImGui.Textured_Themes else 2)
if PyImGui.begin_table(f"FollowerSkillsTable##{identifier}", NUMBER_OF_SKILLS, 0, 0, (btn_size / 3)):
PyImGui.table_next_row()
for i in range(NUMBER_OF_SKILLS):
PyImGui.table_next_column()
skill_active = ImGui.toggle_button(f"{i + 1}##Skill{i}{identifier}", game_option.Skills[i], skill_size, skill_size)
if skill_active != game_option.Skills[i]:
game_option.Skills[i] = skill_active
ImGui.show_tooltip(f"Skill {i + 1}")
PyImGui.end_table()
style.ButtonPadding.pop_style_var()
style.ItemSpacing.pop_style_var()
style.CellPadding.pop_style_var()
def draw_rich_panel(self, account, cached_data: CacheData, messages: list) -> None:
self.rich_renderer.draw_panel(account, cached_data, messages)
class HeroAI_RichPlayerPanelRenderer:
skill_cache: dict[int, CachedSkillInfo] = {}
message_cache: dict[str, dict[SharedCommandType, dict[int, tuple]]] = {}
template_popup_open: bool = False
template_account: str = ""
template_code: str = ""
casting_animation_timer = Timer()
commands = HeroAICommands()
def __init__(self, appearance_window: "HeroAI_AppearanceWindow") -> None:
self.appearance_window = appearance_window
if not self.casting_animation_timer.IsRunning():
self.casting_animation_timer.Start()
def _scale(self, value: float) -> float:
return value * self.appearance_window.get_panel_scale()
def _bar_font_scale(self, height: float) -> float:
return max(height / 13.0, 1.0)
def _get_conditioned(self, account) -> tuple[Color, bool, bool, bool, bool, bool]:
buff_ids = [buff.SkillId for buff in account.AgentData.Buffs.Buffs]
same_map = Map.GetMapID() == account.AgentData.Map.MapID and Map.GetRegion()[0] == account.AgentData.Map.Region and Map.GetDistrict() == account.AgentData.Map.District
deep_wounded = 482 in buff_ids
poisoned = 484 in buff_ids or 483 in buff_ids
enchanted = Agent.IsEnchanted(account.AgentData.AgentID) if same_map else False
conditioned = Agent.IsConditioned(account.AgentData.AgentID) if same_map else False
hexed = Agent.IsHexed(account.AgentData.AgentID) if same_map else False
has_weaponspell = Agent.IsWeaponSpelled(account.AgentData.AgentID) if same_map else False
if poisoned:
return HealthState.Poisoned, deep_wounded, enchanted, conditioned, hexed, has_weaponspell
bleeding = 478 in buff_ids
if bleeding:
return HealthState.Bleeding, deep_wounded, enchanted, conditioned, hexed, has_weaponspell
if Agent.IsDegenHexed(account.AgentData.AgentID) if same_map else False:
return HealthState.DegenHexed, deep_wounded, enchanted, conditioned, hexed, has_weaponspell
return HealthState.Normal, deep_wounded, enchanted, conditioned, hexed, has_weaponspell
def _draw_health_bar_local(
self,
width: float,
height: float,
max_health: float,
current_health: float,
regen: float,
state,
deep_wound: bool = False,
enchanted: bool = False,
conditioned: bool = False,
hexed: bool = False,
has_weaponspell: bool = False,
) -> bool:
style = ImGui.get_style()
draw_textures = style.Theme in ImGui.Textured_Themes
pips = Utils.calculate_health_pips(max_health, regen)
if not draw_textures:
xpos, ypos = PyImGui.get_cursor_pos()
style.PlotHistogram.push_color(state.rgb_tuple)
style.FrameRounding.push_style_var(0)
ImGui.progress_bar(current_health, width, height)
style.FrameRounding.pop_style_var()
style.PlotHistogram.pop_color()
PyImGui.set_cursor_pos(xpos, ypos)
ImGui.dummy(width, height)
fraction = (max(0.0, min(1.0, current_health)) if max_health > 0 else 0.0)
item_rect_min, item_rect_max, item_rect_size = ImGui.get_item_rect()
width = item_rect_max[0] - item_rect_min[0]
height = item_rect_max[1] - item_rect_min[1]
item_rect = (item_rect_min[0] + 1, item_rect_min[1], width - 2, height)
width = item_rect[2]
progress_rect = (item_rect[0] + 1, item_rect[1] + 1, (width - 2) * fraction, height - 2)
background_rect = (item_rect[0] + 1, item_rect[1] + 1, width - 2, height - 2)
cursor_rect = (item_rect[0] - 2 + (width - 2) * fraction, item_rect[1] + 1, 4, height - 2) if fraction > 0 else (item_rect[0] + (width - 2) * fraction, item_rect[1] + 1, 4, height - 2)
if draw_textures:
match state:
case HealthState.Poisoned:
empty_texture = ThemeTextures.HealthBarPoisonedEmpty
fill_texture = ThemeTextures.HealthBarPoisonedFill
cursor_texture = ThemeTextures.HealthBarPoisonedCursor
case HealthState.Bleeding:
empty_texture = ThemeTextures.HealthBarBleedingEmpty
fill_texture = ThemeTextures.HealthBarBleedingFill
cursor_texture = ThemeTextures.HealthBarBleedingCursor
case HealthState.DegenHexed:
empty_texture = ThemeTextures.HealthBarHexedEmpty
fill_texture = ThemeTextures.HealthBarHexedFill
cursor_texture = ThemeTextures.HealthBarHexedCursor
case HealthState.Disconnected:
empty_texture = ThemeTextures.HealthBarDisconnectedEmpty
fill_texture = ThemeTextures.HealthBarDisconnectedFill
cursor_texture = ThemeTextures.HealthBarDisconnectedCursor
case _:
empty_texture = ThemeTextures.HealthBarEmpty
fill_texture = ThemeTextures.HealthBarFill
cursor_texture = ThemeTextures.HealthBarCursor
empty_texture.value.get_texture().draw_in_drawlist(background_rect[:2], background_rect[2:])
fill_texture.value.get_texture().draw_in_drawlist(progress_rect[:2], progress_rect[2:])
if current_health * max_health != max_health:
cursor_texture.value.get_texture().draw_in_drawlist(cursor_rect[:2], cursor_rect[2:])
if deep_wound:
deep_wound_rect = (item_rect[0] + (width * 0.8), item_rect[1] + 1, (width * 0.2) + 1, height - 2)
ThemeTextures.HealthBarDeepWound.value.get_texture().draw_in_drawlist(deep_wound_rect[:2], deep_wound_rect[2:])
ThemeTextures.HealthBarDeepWoundCursor.value.get_texture().draw_in_drawlist(deep_wound_rect[:2], (2, deep_wound_rect[3]))
indicators = (enchanted, conditioned, hexed, has_weaponspell)
if any(indicators) and draw_textures:
x_offset = height + 2
for i, indicator in enumerate(indicators):
if indicator:
indicator_texture = None
match i:
case 0:
indicator_texture = ThemeTextures.HealthIdenticator_Enchanted
case 1:
indicator_texture = ThemeTextures.HealthIdenticator_Conditioned
case 2:
indicator_texture = ThemeTextures.HealthIdenticator_Hexed
case 3:
indicator_texture = ThemeTextures.HealthIdenticator_WeaponSpell
if indicator_texture:
indicator_texture.value.get_texture().draw_in_drawlist((item_rect[0] + item_rect[2] - x_offset, item_rect[1]), (height, height))
x_offset += height + 2
display_label = str(int(current_health * max_health))
bar_font_scale = self._bar_font_scale(height)
PyImGui.push_font_scaled(ImguiFonts.Regular_14.value, bar_font_scale)
textsize = PyImGui.calc_text_size(display_label)
text_rect = (item_rect[0] + ((width - textsize[0]) / 2), item_rect[1] + ((height - textsize[1]) / 2) + self._scale(3), textsize[0], textsize[1])
PyImGui.draw_list_add_text(
text_rect[0],
text_rect[1],
style.Text.color_int,
display_label,
)
PyImGui.pop_font_scaled()
if draw_textures:
pip_texture = ThemeTextures.Pip_Regen if pips > 0 else ThemeTextures.Pip_Degen
pip_size = (10 * (height / 16), height)
pip_y = item_rect[1] + ((height - pip_size[1]) / 2)
pip_step = 8 * (height / 16)
if pips > 0:
pip_pos = text_rect[0] + text_rect[2] + 5
for i in range(int(pips)):
pip_texture.value.get_texture().draw_in_drawlist((pip_pos + (i * pip_step), pip_y), pip_size)
elif pips < 0:
pip_pos = text_rect[0] - 5 - pip_size[0]
for i in range(abs(int(pips))):
pip_texture.value.get_texture().draw_in_drawlist((pip_pos - (i * pip_step), pip_y), pip_size)
PyImGui.draw_list_add_rect(item_rect_min[0], item_rect_min[1], item_rect_min[0] + item_rect_size[0], item_rect_min[1] + item_rect_size[1], style.Border.color_int, 0, 0, 1)
else:
pip_char = IconsFontAwesome5.ICON_ANGLE_RIGHT if pips > 0 else IconsFontAwesome5.ICON_ANGLE_LEFT
pip_string = "".join([pip_char for _ in range(abs(int(pips)))])
PyImGui.push_font_scaled(ImguiFonts.Regular_14.value, max((8.0 / 14.0) * bar_font_scale, 8.0 / 14.0))
pip_text_size = PyImGui.calc_text_size(pip_string)
pip_y = item_rect[1] + ((height - pip_text_size[1]) / 2)
if pips > 0:
PyImGui.draw_list_add_text(text_rect[0] + text_rect[2] + 5, pip_y, style.Text.color_int, pip_string)
elif pips < 0:
PyImGui.draw_list_add_text(text_rect[0] - 5 - pip_text_size[0], pip_y, style.Text.color_int, pip_string)
PyImGui.pop_font_scaled()
return PyImGui.is_item_clicked(0)
def _draw_energy_bar_local(
self,
width: float,
height: float,
max_energy: float,
current_energy: float,
regen: float,
) -> bool:
style = ImGui.get_style()
pips = Utils.calculate_energy_pips(max_energy, regen)
draw_textures = style.Theme in ImGui.Textured_Themes
if not draw_textures:
xpos, ypos = PyImGui.get_cursor_pos()
style.PlotHistogram.push_color((30, 94, 153, 255))
style.FrameRounding.push_style_var(0)
ImGui.progress_bar(current_energy, width, height)
style.FrameRounding.pop_style_var()
style.PlotHistogram.pop_color()
PyImGui.set_cursor_pos(xpos, ypos)
ImGui.dummy(width, height)
fraction = (max(0.0, min(1.0, current_energy)) if max_energy > 0 else 0.0)
item_rect_min, item_rect_max, item_rect_size = ImGui.get_item_rect()
width = item_rect_max[0] - item_rect_min[0]
height = item_rect_max[1] - item_rect_min[1]
item_rect = (item_rect_min[0], item_rect_min[1], width, height)
progress_rect = (item_rect[0] + 1, item_rect[1] + 1, (width - 2) * fraction, height - 2)
background_rect = (item_rect[0] + 1, item_rect[1] + 1, width - 2, height - 2)
cursor_rect = (item_rect[0] - 2 + (width - 2) * fraction, item_rect[1] + 1, 4, height - 2) if fraction > 0 else (item_rect[0] + (width - 2) * fraction, item_rect[1] + 1, 4, height - 2)
if draw_textures:
ThemeTextures.EnergyBarEmpty.value.get_texture().draw_in_drawlist(background_rect[:2], background_rect[2:])
ThemeTextures.EnergyBarFill.value.get_texture().draw_in_drawlist(progress_rect[:2], progress_rect[2:])
if current_energy * max_energy != max_energy:
ThemeTextures.EnergyBarCursor.value.get_texture().draw_in_drawlist(cursor_rect[:2], cursor_rect[2:])
display_label = str(int(current_energy * max_energy))
bar_font_scale = self._bar_font_scale(height)
PyImGui.push_font_scaled(ImguiFonts.Regular_14.value, bar_font_scale)
text_size = PyImGui.calc_text_size(display_label)
text_rect = (item_rect[0] + ((width - text_size[0]) / 2), item_rect[1] + ((height - text_size[1]) / 2) + self._scale(3), text_size[0], text_size[1])
PyImGui.draw_list_add_text(
text_rect[0],
text_rect[1],
style.Text.color_int,
display_label,
)
PyImGui.pop_font_scaled()
if draw_textures:
pip_texture = ThemeTextures.Pip_Regen if pips > 0 else ThemeTextures.Pip_Degen
pip_size = (10 * (height / 16), height)
pip_y = item_rect[1] + ((height - pip_size[1]) / 2)
pip_step = 8 * (height / 16)
if pips > 0:
pip_pos = text_rect[0] + text_rect[2] + 5
for i in range(int(pips)):
pip_texture.value.get_texture().draw_in_drawlist((pip_pos + (i * pip_step), pip_y), pip_size)
elif pips < 0:
pip_pos = text_rect[0] - 5 - pip_size[0]
for i in range(abs(int(pips))):
pip_texture.value.get_texture().draw_in_drawlist((pip_pos - (i * pip_step), pip_y), pip_size)
PyImGui.draw_list_add_rect(item_rect_min[0], item_rect_min[1], item_rect_min[0] + item_rect_size[0], item_rect_min[1] + item_rect_size[1], style.Border.color_int, 0, 0, 1)
else:
pip_char = IconsFontAwesome5.ICON_ANGLE_RIGHT if pips > 0 else IconsFontAwesome5.ICON_ANGLE_LEFT
pip_string = "".join([pip_char for _ in range(abs(int(pips)))])
PyImGui.push_font_scaled(ImguiFonts.Regular_14.value, max((8.0 / 14.0) * bar_font_scale, 8.0 / 14.0))
pip_text_size = PyImGui.calc_text_size(pip_string)
pip_y = item_rect[1] + ((height - pip_text_size[1]) / 2)
if pips > 0:
PyImGui.draw_list_add_text(text_rect[0] + text_rect[2] + 5, pip_y, style.Text.color_int, pip_string)
elif pips < 0:
PyImGui.draw_list_add_text(text_rect[0] - 5 - pip_text_size[0], pip_y, style.Text.color_int, pip_string)
PyImGui.pop_font_scaled()
return PyImGui.is_item_clicked(0)
def _draw_square_cooldown_ex(self, button_pos, button_size, progress, tint=0.1):
if isinstance(button_size, (int, float)):
button_size = (button_size, button_size)
if progress <= 0 or progress >= 1.0:
return
center_x = button_pos[0] + button_size[0] / 2.0
center_y = button_pos[1] + button_size[1] / 2.0
half_w = button_size[0] / 2.0
half_h = button_size[1] / 2.0
color = (int(255 * tint) << 24)
start_angle = -math.pi / 2.0
end_angle = start_angle - 2.0 * math.pi * progress
segments = max(32, min(64, int(64 + 128 * (1 - progress))))
points = [(center_x, center_y)]
def intersection(angle):
dx, dy = math.cos(angle), math.sin(angle)
tx = half_w / abs(dx) if dx != 0 else float("inf")
ty = half_h / abs(dy) if dy != 0 else float("inf")
t = min(tx, ty)
return (center_x + dx * t, center_y + dy * t)
corner_angles = [-math.pi / 4, -3 * math.pi / 4, -5 * math.pi / 4, -7 * math.pi / 4, -math.pi / 4 - 2 * math.pi]
a = start_angle
for corner in corner_angles:
if end_angle < corner < a or end_angle >= corner >= a:
points.append(intersection(corner))
for i in range(segments + 1):
angle = start_angle + (end_angle - start_angle) * (i / segments)
points.append(intersection(angle))
unique_points = []
for p in points:
if not unique_points or (abs(unique_points[-1][0] - p[0]) > 0.1 or abs(unique_points[-1][1] - p[1]) > 0.1):
unique_points.append(p)
for i in range(1, len(unique_points) - 1):
x1, y1 = unique_points[0]
x2, y2 = unique_points[i]
x3, y3 = unique_points[i + 1]
PyImGui.draw_list_add_triangle_filled(x1, y1, x2, y2, x3, y3, color)
def _draw_casting_animation(self, pos: tuple[float, float], size: tuple[float, float], min_alpha: int = 40):
t = self.casting_animation_timer.GetElapsedTime() / 1000.0
num_circles = 3
cycle_duration = 1.25
max_radius = max(size) * 0.75
min_radius = max(size) * 0.05
center_x = pos[0] + size[0] / 2
center_y = pos[1] + size[1] / 2
min_alpha = max(0, min(255, min_alpha))
for i in range(num_circles):
offset = i / num_circles
progress = (t / cycle_duration + offset) % 1.0
radius = max_radius - (max_radius - min_radius) * progress
alpha = int(min_alpha + (255 - min_alpha) * (1.0 - progress) ** 1.5)
alpha = max(0, min(255, alpha))
swirl_angle = math.sin((t + i) * 2.0) * 0.1
cx = center_x + math.cos(swirl_angle) * 0.0
cy = center_y + math.sin(swirl_angle) * 0.0
color = Color.from_tuple((0, 0, 0, alpha / 255.0))
PyImGui.push_clip_rect(pos[0], pos[1], pos[0] + size[0], pos[1] + size[1], True)
PyImGui.draw_list_add_circle(cx, cy, radius, color.color_int, 36, 6.0)
PyImGui.pop_clip_rect()
def _get_skill_texture(self, skill_id: int) -> str:
texture = GLOBAL_CACHE.Skill.ExtraData.GetTexturePath(skill_id)
return texture if texture and os.path.exists(texture) else ""
def _show_skill_tooltip(self, skill: CachedSkillInfo, show_usage=True) -> None:
if not skill or not skill.skill_id:
return
PyImGui.set_next_window_size((300, 0), PyImGui.ImGuiCond.Always)
if ImGui.begin_tooltip():
ImGui.push_font("Regular", 14)
ImGui.text_colored(f"{skill.name} (ID: {skill.skill_id})", Color(227, 211, 165, 255).color_tuple)
ImGui.pop_font()
ImGui.separator()
if skill.description:
ImGui.text_wrapped(skill.description)
if show_usage:
PyImGui.spacing()
gray_color = Color(150, 150, 150, 255)
ImGui.push_font("Regular", 12)
ImGui.text_colored("Click to use on current target", gray_color.color_tuple)
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - 2)
ImGui.text_colored("Ctrl + Click to use on self", gray_color.color_tuple)
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - 2)
ImGui.text_colored("Shift + Click to toggle active/inactive", gray_color.color_tuple)
ImGui.pop_font()
ImGui.end_tooltip()
def _get_skill_target(self, account, cached_skill: CachedSkillInfo) -> int | None:
if not cached_skill or cached_skill.skill_id == 0:
return None
target_id = Player.GetTargetID()
is_gadget = Agent.IsGadget(target_id)
is_item = Agent.IsItem(target_id)
if cached_skill.is_enchantment or cached_skill.is_shout:
allegiance, _ = Agent.GetAllegiance(target_id) if target_id != 0 else (Allegiance.Neutral, None)
if allegiance in [Allegiance.Ally, Allegiance.Minion, Allegiance.SpiritPet]:
return target_id
return Player.GetAgentID() if PyImGui.get_io().key_ctrl else account.AgentData.AgentID
return Player.GetAgentID() if PyImGui.get_io().key_ctrl else target_id if not is_item and not is_gadget and target_id else account.AgentData.AgentID
def _draw_rich_skill_bar(self, account, options) -> None:
skill_size = self._scale(float(RICH_BAR_HEIGHT))
style = ImGui.get_style()
draw_textures = style.Theme in ImGui.Textured_Themes
texture_theme = style.Theme if draw_textures else StyleTheme.Guild_Wars
for slot, skill_info in enumerate(account.AgentData.Skillbar.Skills):
skill_id = int(skill_info.Id)
if skill_id not in self.skill_cache:
self.skill_cache[skill_id] = CachedSkillInfo(skill_id)
skill = self.skill_cache[skill_id]
if skill.texture_path:
ImGui.image(skill.texture_path, (skill_size, skill_size), uv0=(0.0625, 0.0625) if draw_textures else (0, 0), uv1=(0.9375, 0.9375) if draw_textures else (1, 1))
if PyImGui.is_item_hovered():
self._show_skill_tooltip(skill)
else:
ImGui.dummy(skill_size, skill_size)
item_rect_min = PyImGui.get_item_rect_min()
PyImGui.draw_list_add_rect(item_rect_min[0], item_rect_min[1], item_rect_min[0] + skill_size, item_rect_min[1] + skill_size, Color(50, 50, 50, 255).color_int, 0, 0, 2)
if slot < NUMBER_OF_SKILLS - 1:
PyImGui.same_line(0, 0)
continue
item_rect_min = PyImGui.get_item_rect_min()
skill_recharge = int(skill_info.Recharge)
adrenaline = int(skill_info.Adrenaline)
enough_adrenaline = adrenaline >= skill.adrenaline_cost
casting_skill = account.AgentData.Skillbar.CastingSkillID
if skill_recharge > 0 and skill.recharge_time > 0:
self._draw_square_cooldown_ex((item_rect_min[0], item_rect_min[1]), skill_size, skill_recharge / (skill.recharge_time * 1000.0), tint=0.6)
recharge_seconds = f"{int(skill_recharge / 1000)}"
text_size = PyImGui.calc_text_size(recharge_seconds)
PyImGui.draw_list_add_text(
item_rect_min[0] + ((skill_size - text_size[0]) / 2),
item_rect_min[1] + ((skill_size - text_size[1]) / 2),
ImGui.get_style().Text.color_int,
recharge_seconds,
)
elif casting_skill == skill.skill_id:
self._draw_casting_animation(item_rect_min, (skill_size, skill_size))
if not enough_adrenaline:
adrenaline_fraction = adrenaline / skill.adrenaline_cost if skill.adrenaline_cost > 0 else 0.0
adrenaline_fraction = max(0.0, min(adrenaline_fraction, 1.0))
fill_rect = (item_rect_min[0], item_rect_min[1], skill_size, skill_size - (skill_size * adrenaline_fraction))
PyImGui.draw_list_add_rect_filled(fill_rect[0], fill_rect[1], fill_rect[0] + fill_rect[2], fill_rect[1] + fill_rect[3], Color(0, 0, 0, 150).color_int, 0, 0)
PyImGui.draw_list_add_line(fill_rect[0], fill_rect[1] + fill_rect[3], fill_rect[0] + fill_rect[2], fill_rect[1] + fill_rect[3], Color(0, 0, 0, 255).color_int, 1)
if not options.Skills[slot]:
if draw_textures:
hovered = PyImGui.is_item_hovered()
ThemeTextures.Cancel.value.get_texture(texture_theme).draw_in_drawlist(PyImGui.get_item_rect_min(), (skill_size, skill_size), state=TextureState.Hovered if hovered else TextureState.Normal)
else:
PyImGui.draw_list_add_rect_filled(item_rect_min[0], item_rect_min[1], item_rect_min[0] + skill_size, item_rect_min[1] + skill_size, Color(89, 0, 0, 120).color_int, 0, 0)
account_email = Player.GetAccountEmail()
queued_skill_messages = self.message_cache.get(account_email, {}).get(SharedCommandType.UseSkill, {})
if queued_skill_messages:
queued_skill_usage = {
index: msg for index, msg in GLOBAL_CACHE.ShMem.GetAllMessages()
if msg.Command == SharedCommandType.UseSkill and msg.ReceiverEmail == account_email and msg.Params[1] == float(skill.skill_id) and index in queued_skill_messages
}
if queued_skill_usage and draw_textures:
hovered = PyImGui.is_item_hovered()
ThemeTextures.Check.value.get_texture(texture_theme).draw_in_drawlist(PyImGui.get_item_rect_min(), (skill_size, skill_size), state=TextureState.Hovered if hovered else TextureState.Normal)
else:
indices_to_delete = [index for index, msg in queued_skill_messages.items() if msg[1] == skill.skill_id]
for index in indices_to_delete:
del queued_skill_messages[index]
if PyImGui.is_item_clicked(0) and enough_adrenaline:
if PyImGui.get_io().key_shift:
if options:
options.Skills[slot] = not options.Skills[slot]
else:
target_id = self._get_skill_target(account, skill)
if target_id is not None and skill_id != 0:
message_index = GLOBAL_CACHE.ShMem.SendMessage(Player.GetAccountEmail(), account.AccountEmail, SharedCommandType.UseSkill, (target_id, skill_id))
if account.AccountEmail not in self.message_cache:
self.message_cache[account.AccountEmail] = {}
if SharedCommandType.UseSkill not in self.message_cache[account.AccountEmail]:
self.message_cache[account.AccountEmail][SharedCommandType.UseSkill] = {}
self.message_cache[account.AccountEmail][SharedCommandType.UseSkill][message_index] = (target_id, skill.skill_id)
if draw_textures:
texture_state = TextureState.Normal if not skill.is_elite else TextureState.Active
ThemeTextures.Skill_Frame.value.get_texture(texture_theme).draw_in_drawlist(item_rect_min[:2], (skill_size, skill_size), state=texture_state)
if slot < NUMBER_OF_SKILLS - 1:
PyImGui.same_line(0, 0)
def _enter_skill_template_code(self, account) -> None:
if not self.template_popup_open:
return
PyImGui.open_popup("Enter Skill Template Code")
PyImGui.set_window_pos(500, 100, PyImGui.ImGuiCond.Always)
if PyImGui.begin_popup("Enter Skill Template Code"):
self.template_code = ImGui.input_text("##template_code", self.template_code)
if ImGui.button("Load"):
GLOBAL_CACHE.ShMem.SendMessage(Player.GetAccountEmail(), account.AccountEmail, SharedCommandType.LoadSkillTemplate, ExtraData=(self.template_code, 0, 0, 0))
self.template_popup_open = False
PyImGui.close_current_popup()
PyImGui.same_line(0, 10)
if ImGui.button("Cancel"):
PyImGui.close_current_popup()
self.template_popup_open = False
if PyImGui.is_mouse_clicked(0) and not PyImGui.is_any_item_hovered():
PyImGui.close_current_popup()
self.template_popup_open = False
PyImGui.end_popup()
def _draw_buffs_and_upkeeps(self, account, skill_size: float = 28):
style = ImGui.get_style()
hard_mode_effect_id = 1912
effects = [effect for effect in account.AgentData.Buffs.Buffs if effect.Type == 2]
upkeeps = [effect for effect in account.AgentData.Buffs.Buffs if effect.Type == 1]
def draw_buff(effect: CachedSkillInfo, duration: float, remaining: float, draw_effect_frame: bool = True, size: float = skill_size):
if not effect.texture_path:
ImGui.dummy(size, size)
else:
ImGui.image(effect.texture_path, (size, size), uv0=(0.125, 0.125) if not draw_effect_frame else (0.0625, 0.0625), uv1=(0.875, 0.875) if not draw_effect_frame else (0.9375, 0.9375))
item_rect_min = PyImGui.get_item_rect_min()
item_rect_max = PyImGui.get_item_rect_max()
if draw_effect_frame:
effect.frame_texture.draw_in_drawlist(item_rect_min[:2], (size, size), state=effect.texture_state)
if duration > 0 and remaining:
progress_background_rect = (item_rect_min[0] + 2, item_rect_max[1] - 4, item_rect_max[0] - 2, item_rect_max[1] - 1)
PyImGui.draw_list_add_rect_filled(progress_background_rect[0], progress_background_rect[1], progress_background_rect[2], progress_background_rect[3], Color(0, 0, 0, 255).color_int, 0, 0)
progress_rect = (progress_background_rect[0] + 1, progress_background_rect[1] + 1, progress_background_rect[2] - 2, progress_background_rect[3] - 1)
fraction = remaining / (duration * 1000.0)
progress_width = (progress_rect[2] - progress_rect[0]) * fraction
PyImGui.draw_list_add_rect_filled(progress_rect[0], progress_rect[1], progress_rect[0] + progress_width, progress_rect[3], effect.progress_color, 0, 0)
remaining_text = f"{remaining/1000:.0f}" if remaining >= 1000 else f"{remaining/1000:.1f}".lstrip("0")
text_size = PyImGui.calc_text_size(remaining_text)
offset_x = (size - text_size[0]) / 2
offset_y = (size - text_size[1]) / 2
PyImGui.draw_list_add_rect_filled(item_rect_min[0] + offset_x - 1, item_rect_min[1] + offset_y - 1, item_rect_min[0] + offset_x + text_size[0] + 1, item_rect_min[1] + offset_y + text_size[1] + 1, Color(0, 0, 0, 150).color_int, 2, 0)
PyImGui.draw_list_add_text(item_rect_min[0] + offset_x, item_rect_min[1] + offset_y, style.Text.color_int, remaining_text)
if PyImGui.is_item_hovered():
self._show_skill_tooltip(effect, show_usage=False)
def draw_morale(morale: int, size: float = skill_size):
morale_display = f"{('+' if morale > 100 else '-')}{abs(100 - morale)}%"
texture = ThemeTextures.DeathPenalty.value.get_texture() if morale < 100 else ThemeTextures.MoraleBoost.value.get_texture()
ImGui.push_font("Regular", 11)
ImGui.dummy(size, size)
item_rect_min = PyImGui.get_item_rect_min()
item_rect_max = PyImGui.get_item_rect_max()
item_rect = (item_rect_min[0], item_rect_min[1], item_rect_max[0] - item_rect_min[0], item_rect_max[1] - item_rect_min[1])
texture.draw_in_drawlist(item_rect[:2], (size, size))
text_size = PyImGui.calc_text_size(morale_display)
offset_x = (size - text_size[0]) / 2
offset_y = (size - text_size[1])
PyImGui.draw_list_add_text(item_rect[0] + offset_x, item_rect[1] + offset_y, Color(201, 188, 145, 255).color_int, morale_display)
ImGui.pop_font()
PyImGui.table_next_column()
def draw_hardmode():
if any(effect.SkillId == hard_mode_effect_id for effect in effects):
to_kill = Map.GetFoesToKill()
texture = ThemeTextures.HardMode.value.get_texture(StyleTheme.Guild_Wars) if to_kill > 0 else ThemeTextures.HardModeCompleted.value.get_texture(StyleTheme.Guild_Wars)
ImGui.dummy(skill_size + 1, skill_size + 1)
item_rect_min, _item_rect_max, _item_rect_size = ImGui.get_item_rect()
texture.draw_in_drawlist(item_rect_min[:2], (skill_size + 1, skill_size + 1))
PyImGui.table_next_column()
if any(upkeeps):
upkeep_size = self._scale(24)
ImGui.dummy(0, upkeep_size)
PyImGui.same_line(0, 0)
for upkeep in upkeeps:
if upkeep.SkillId == 0:
continue
if upkeep.SkillId not in self.skill_cache:
self.skill_cache[upkeep.SkillId] = CachedSkillInfo(upkeep.SkillId)
effect = self.skill_cache[upkeep.SkillId]
draw_buff(effect, upkeep.Duration, upkeep.Remaining, False, upkeep_size)
if any(effects):
PyImGui.new_line()
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - self._scale(4))
avail = PyImGui.get_content_region_avail()[0]
style.CellPadding.push_style_var(0, 0)
if ImGui.begin_table("##effects_table" + account.AccountEmail, max(1, round(avail / skill_size)), PyImGui.TableFlags.SizingFixedFit):
PyImGui.table_next_row()
PyImGui.table_next_column()
if account.AgentData.Morale not in [0, 100]:
draw_morale(account.AgentData.Morale, skill_size)
draw_hardmode()
player_effects = {}
for effect in effects:
remaining = effect.Remaining
duration = effect.Duration
effect_id = effect.SkillId
if not effect_id or effect_id == hard_mode_effect_id:
continue
if effect_id not in self.skill_cache:
self.skill_cache[effect_id] = CachedSkillInfo(effect_id)
if effect_id not in player_effects or remaining > player_effects[effect_id][1]:
player_effects[effect_id] = (self.skill_cache[effect_id], remaining, duration)
for _effect_id, (effect, remaining, duration) in player_effects.items():
draw_buff(effect, duration, remaining, True, 28)
PyImGui.table_next_column()
ImGui.end_table()
style.CellPadding.pop_style_var()
PyImGui.new_line()
def _draw_buffs_bar(self, account):
style = ImGui.get_style()
PyImGui.push_style_var(ImGuiStyleVar.WindowRounding, 0.0)
PyImGui.push_style_var(ImGuiStyleVar.WindowPadding, 0.0)
PyImGui.push_style_var(ImGuiStyleVar.WindowBorderSize, 0.0)
PyImGui.push_style_var2(ImGuiStyleVar.WindowPadding, 0.0, 0.0)
flags = (
PyImGui.WindowFlags.NoCollapse |
PyImGui.WindowFlags.NoTitleBar |
PyImGui.WindowFlags.NoScrollbar |
PyImGui.WindowFlags.AlwaysAutoResize |
PyImGui.WindowFlags.NoScrollWithMouse |
PyImGui.WindowFlags.NoBringToFrontOnFocus |
PyImGui.WindowFlags.NoResize |
PyImGui.WindowFlags.NoBackground
)
win_pos = PyImGui.get_window_pos()
win_size = PyImGui.get_window_size()
PyImGui.set_next_window_pos((win_pos[0], win_pos[1] + win_size[1] + (13 if style.Theme == StyleTheme.Guild_Wars else 4)), PyImGui.ImGuiCond.Always)
PyImGui.set_next_window_size((win_size[0], 0), PyImGui.ImGuiCond.Always)
opened = PyImGui.begin("##Buffs Bar" + account.AccountEmail, True, flags)
PyImGui.pop_style_var(4)
if opened:
self._draw_buffs_and_upkeeps(account, self._scale(28))
PyImGui.end()
def draw_panel(self, account, cached_data: CacheData, messages: list) -> None:
options = cached_data.party.options.get(account.AgentData.AgentID)
if options is None:
return
panel_width = self._scale(225)
bar_height = self._scale(13)
row_overlap = self._scale(4)
skill_bar_height = self._scale(RICH_BAR_HEIGHT)
height = self._scale(28)
height += skill_bar_height if self.appearance_window.get_show_player_skill_toggles() else 0
height += row_overlap if self.appearance_window.get_show_player_skill_toggles() else 0
control_height = self._scale(20)
if height > 0:
if ImGui.begin_child("##bars" + account.AccountEmail, (panel_width, height)):
curr_avail = PyImGui.get_content_region_avail()
health_state, deep_wounded, enchanted, conditioned, hexed, has_weaponspell = self._get_conditioned(account)
health_clicked = self._draw_health_bar_local(
curr_avail[0],
bar_height,
account.AgentData.Health.Max,
account.AgentData.Health.Current,
account.AgentData.Health.Regen,
health_state,
deep_wounded,
enchanted,
conditioned,
hexed,
has_weaponspell,
)
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - row_overlap)
energy_clicked = self._draw_energy_bar_local(
curr_avail[0],
bar_height,
account.AgentData.Energy.Max,
account.AgentData.Energy.Current,
account.AgentData.Energy.Regen,
)
if health_clicked or energy_clicked:
if Map.GetMapID() == account.AgentData.Map.MapID:
Player.ChangeTarget(account.AgentData.AgentID)
if self.appearance_window.get_show_player_skill_toggles():
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - row_overlap)
self._draw_rich_skill_bar(account, options)
ImGui.end_child()
opt_dict = {
"Following": options.Following,
"Looting": options.Looting,
"Combat": options.Combat,
}
PyImGui.set_cursor_pos_y(PyImGui.get_cursor_pos_y() - self._scale(2))
control_row_width = panel_width
for name, value in opt_dict.items():
ImGui.push_font("Regular", 10)
active = ImGui.toggle_button(name + f"##{account.AccountEmail}", value, control_row_width / len(opt_dict) - self._scale(3), control_height)
ImGui.pop_font()
if active != value:
setattr(options, name, active)
PyImGui.same_line(0, 2)
self._draw_buffs_bar(account)
class HeroAI_AppearanceWindow:
def is_open(self) -> bool:
return window_factory.is_open("appearance")
def set_open(self, value: bool) -> None:
window_factory.set_open("appearance", value)
def get_panel_scale(self) -> float:
scale = IniManager().getFloat(window_factory.key("appearance"), "panel_table_scale", 1.0, section="Appearance")
return max(PANEL_MIN_SCALE, min(PANEL_MAX_SCALE, scale))
def set_panel_scale(self, scale: float) -> None:
clamped_scale = max(PANEL_MIN_SCALE, min(PANEL_MAX_SCALE, scale))
IniManager().set(window_factory.key("appearance"), "panel_table_scale", float(clamped_scale), section="Appearance")
IniManager().set(window_factory.key("appearance"), "panel_table_width", int(round(PANEL_BASE_WIDTH * clamped_scale)), section="Appearance")
IniManager().set(window_factory.key("appearance"), "panel_table_height", int(round(PANEL_BASE_HEIGHT * clamped_scale)), section="Appearance")