From ec3e2abc65bdc73060cb5d7a01ee55ee2f18cb2f Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 5 Jan 2021 01:03:25 -0500 Subject: [PATCH] Wired up skill UI to check for prerequisites being met and sufficient skill points. available SP check in general HUD, more skill icons Trimmed 2000 lines from a file. UI tweaks --- .../element/buttons/arrow_down_gold.png | Bin 0 -> 2057 bytes .../element/icons/skilltree/leap_cost.png | Bin 0 -> 809 bytes .../element/icons/skilltree/leap_damage.png | Bin 0 -> 799 bytes .../element/icons/skilltree/leap_distance.png | Bin 0 -> 433 bytes .../icons/skilltree/leap_knockback.png | Bin 0 -> 425 bytes .../element/icons/skilltree/leap_radius.png | Bin 0 -> 451 bytes .../element/icons/skilltree/spin_amount.png | Bin 0 -> 371 bytes .../element/icons/skilltree/spin_cost.png | Bin 0 -> 358 bytes .../element/icons/skilltree/spin_damage.png | Bin 0 -> 355 bytes .../icons/skilltree/spin_helicopter.png | Bin 0 -> 359 bytes .../element/icons/skilltree/spin_infinite.png | Bin 0 -> 360 bytes .../element/icons/skilltree/spin_speed.png | Bin 0 -> 354 bytes .../element/icons/skilltree/unlock_bow.png | Bin 367 -> 1580 bytes assets/voxygen/i18n/en.ron | 8 +- assets/voxygen/i18n/en/hud/misc.ron | 3 + common/src/comp/skills.rs | 59 +- voxygen/src/hud/buttons.rs | 78 +- voxygen/src/hud/diary.rs | 3739 ++++++++--------- voxygen/src/hud/hotbar.rs | 52 +- voxygen/src/hud/img_ids.rs | 2 + voxygen/src/hud/mod.rs | 1 + voxygen/src/menu/char_selection/ui/mod.rs | 4 +- 22 files changed, 1806 insertions(+), 2140 deletions(-) create mode 100644 assets/voxygen/element/buttons/arrow_down_gold.png create mode 100644 assets/voxygen/element/icons/skilltree/leap_cost.png create mode 100644 assets/voxygen/element/icons/skilltree/leap_damage.png create mode 100644 assets/voxygen/element/icons/skilltree/leap_distance.png create mode 100644 assets/voxygen/element/icons/skilltree/leap_knockback.png create mode 100644 assets/voxygen/element/icons/skilltree/leap_radius.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_amount.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_cost.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_damage.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_helicopter.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_infinite.png create mode 100644 assets/voxygen/element/icons/skilltree/spin_speed.png diff --git a/assets/voxygen/element/buttons/arrow_down_gold.png b/assets/voxygen/element/buttons/arrow_down_gold.png new file mode 100644 index 0000000000000000000000000000000000000000..44a8370b058e7d0dc38285d2a0b6d8f2f59d349d GIT binary patch literal 2057 zcmcIl&1)n@6dyr%lXZiNvWk~&Iv!TErmOlZ-AyKIGLw&ibPUPBX2FBiRn;?XX1dz$ zPG*ve;%)clO&1aIqLMOMkc)kGtrzbAJ{k_S%Rd`G$D>pOPd%pNTQM&WVOQq7qx1z>Y zzU8laOm@nY%RrQSodl#yrP=GfgtBdsD}iW6aYcRj-S?^z@rruG^0A*(MJrm_PsQf` zT7&IxGncE^=aku=2LK(BQ>E8w$C=lwsC`@y*2T7_Dt(cByQ0n)29+&;U8%}cD0Uem zhOwc{xMgCSmOk^kqGKIv1TG7a8P9Y)Lsy1B6|AK^^fqcsLtF4xQCoSQc$(JjcFSF( zEYqe&T-VjGuIV}g36$-{Iqji1n;s$5M8?u6$s-vn1tJaPPF_)g>A;0fGKP(_VVEFb zT8}0gDdWPWk)ZFNE!ydfrL%l-7px5Vo(P;Z_7b6Oh)nLJOf2q-IG-LF<7}*(?4<3! zr<`e`Ejl2U0WmT*m9%6ovz9!?kMZZRH;GqG1xPvAL@Y9oQ{PF!f;s)NU=pc!}^D?T#CSn2CC=q5`RM6midH4kIqL5w;mdfnx@UhC)XK+c>lw;+U4`^8)>vWIILp z3jIOZa>)Q=93jsn){H}Jfeg%NkZqX^(c%_j($UmD zwGZze{xnrmCQ9>vJ-qeX`s6c<-#+l)xXRz3yIA>K`Qz7#rO)oaW8C|B>zgm{T{*b@ z>A}?D=T~;0oPO}*>Msk^hfi5|eppDBjE{c*LjCyQ!n3d3UViTKi>t-3t}m|DzFK(u FgGbLzg~9*; literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/leap_cost.png b/assets/voxygen/element/icons/skilltree/leap_cost.png new file mode 100644 index 0000000000000000000000000000000000000000..6e05cde5bffa0803865278bea2342ffca9db9e15 GIT binary patch literal 809 zcmV+^1J?YBP)EX>4Tx04R}tkv&MmKpe$iQ;Sln4i*t{$WWau6cusQDionYs1;guFu8t0lZGV4 z#ZhoAIQX$xb#QUk)xlK|1V2EW9Gw(hq{ROvg%&X$9QWhhy~o`z@3Dp}e-T%ypV0NMI35kRU=q4P{hdAxf)8iis5M$36VRj$a~|Las6x zITlcb3fb|4|H1EW&BEk_n-q!zffw8U7zMg_fo9#dzmILZc>?&Kfh(=;uQq_0Ptxmc zEpi0(Zvz+CZB5w&E_Z;TCtWsVNAlAY3I*W(jJ_!g4BP_2HMh6cK29HiGV}#?0%>Ac z8i;O9*vJJMyg`$)H1Pu7!z-}p!UNz^_9Wf{NeCz;$cDvpfm5cXw1WPt$$S6&^Szl? z0W5<+0NzF;PSH)f4L~J|lr~}ip=A(=F8Ti6NvF^Olzbm;7Jrq=&~6we3dc|yui5K{ zA$s2EVnY8y=7u5jMt3`My7?Q*LmmxaQ&ys=Ff?n_d84}vG&=9~62?3o^61QJilnHP z8K{&(WcQ8dQQE!qgF1_|FRB|iQ8c3iEQ28aCDU{!%-kP)*6Yx^j#%_bs}7`I5~{_HRS=Se;R zcG7@uz-sXUz~m>#F^0)>#)Vhk+mNR?Y&wf;jwfrTs+?#%++M}zBH3Y{ ntWf~>mt_Is;A7><+AQ@qs4IW<91BQk00000NkvXXu0mjfBH?qn literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/leap_damage.png b/assets/voxygen/element/icons/skilltree/leap_damage.png new file mode 100644 index 0000000000000000000000000000000000000000..e2041ab4b6dcc3668748bbd321f00878c4efae5c GIT binary patch literal 799 zcmV+)1K|9LP)EX>4Tx04R}tkv&MmKpe$iQ;Sln4i*t{$WWau6cusQDionYs1;guFu8t0lZGV4 z#ZhoAIQX$xb#QUk)xlK|1V2EW9Gw(hq{ROvg%&X$9QWhhy~o`z@3Dp}e-T%ypV0NMI35kRU=q4P{hdAxf)8iis5M$36VRj$a~|Las6x zITlcb3fb|4|H1EW&BEk_n-q!zffw8U7zMg_fo9#dzmILZc>?&Kfh(=;uQq_0Ptxmc zEpi0(Zvz+CZB5w&E_Z;TCtWsVNAlAY3I*W(jJ_!g4BP_2HMh6cK29HiGPx$Ye_^wR5*>Tlrc}jKp2LfJL*DBBw}0`wZz$k1sBJrF3wH5n)n0se>k~!V0L1K z$%Vw(7*}FKKp;UDhtGjrZI2cZe5c-b@4esi-6d53(=Zf(mtK!;blzwHaL{TgZNmOT z(=ZfW^8KYw+t2}&d>?H-c9qG{ZWLt-f1xy9bJmR_^r#kKLU$o^qli&0Sd46MZbDh) z(Ew@6O+xcV9o2&0z@jl$smPNXXp^j~0!UgwZfzFFOLY+uljA(dn5Xw)LS<;~f@WqdB8W(`zQ4LyP)|Mq_>eIG zjy>9K^Njth@*s;t}05>OP0T`%q?xnAj bfdcdoA)~gRj@xx<00000NkvXXu0mjf#elph literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/leap_knockback.png b/assets/voxygen/element/icons/skilltree/leap_knockback.png new file mode 100644 index 0000000000000000000000000000000000000000..15bc23571cb6c0baf8ced2370a59eaf4b4e137ca GIT binary patch literal 425 zcmV;a0apHrP)Px$V@X6oR5*>Tkv&VpP!xuro5rOnD5Ml5V{LF2ved~f#Kk#~j0Jyy{uO^fp|ev~ zJGm5`g}MfzG}3}~akviUw)yO*FNEBjy!W~9IadJ8eP05+jYb@zE5`xgbTAN_g8hf) zzAv?!>lRKrBppD_blSQV` z2t%ZlndfFaE={LkYJLFv*{_i?NhuLRAf+tS=8m&J0^GmD1_VI6@!V z_A13TRi!iI2!Nq&Z@%SCQu9m00L0xzQ$Bx8OE;xc=ST2(dkw(%>Px$eMv+?R5*>Tk}*yKK@>pW4A`(Hnm{O|R5$<$jaGDsjrAr==?(M}+=7DIYAvOr zA@Ks(f(Ze#o2)bzV?kz_9fpA5Pd3@i%zyvQ|04im-&X)1qY=kMz0m;RqTd%%!~P>; z-&Zo%YHd|I#ttCYY9aN{si7It3xdqTUo7=mo$Cbwa#3lcp{JO6LBOKYUSHYXJj8O> z83|xo9s+e;bx~;pkOwGD-#~~=QtbOQ$Kx&7d$pQ@ISm1nQYf{4l1ZO002ovPDHLkV1hBwzTyA? literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/spin_amount.png b/assets/voxygen/element/icons/skilltree/spin_amount.png new file mode 100644 index 0000000000000000000000000000000000000000..ce738a63894f5310fb62f86489aefb21f8c11f66 GIT binary patch literal 371 zcmV-(0gV2MP)Px$ElET{R5*>DlRJ*WFc60Sf$ess6rrQ`1yuq-P-f#;eZs^^$q~Ay8IB$k#T@e-q$1P z;=eK}kt|ZBq%sO!1Hi{S!s~h$l*mkz!l5jY_q7v{Y5@=^`Q9`^>0D;@kfl@NysyJ0 ze;tqbJ)K5U4g%cL`QA{L2<~B4RRA!OO60Qh#{h3AECK*y42UQyl@f^+W>p1ajPr0x z>T_?J$50Bbt&E63MD~2!??;o5$(#&X&?<#OYb)b6+@9~qUsH;h=wh>s%Z>?rf_vC1 zg>%;>17kQD`q}tHn&RAbuRWB5k#JuDcUOIpeV>Ia^Px$AW1|)R5*>Dls|65FcgQsN7*`bNH=C*pb`hjhByKer;Ef9sJ9%zQZC>*-53}c zBX^*-oM0Q%pA;#1@%!?7e-r`em2v=I+bv#iyIr_{KOQORve^Uh`SUGO1M>+>HRJgK zy816HhQwNxN+~%?Jp-&?0bVxyBqVlP1m3!iW<1XlN-cmy$&=PeXssTAAE#5+=`(OM zp64Zd*rfGr+8*kYU|zb9-Ma1$9E_Q*P7ay^$1#Ag*sZlV=MWLDheJ4!f|it=a@@!3 z3(!gH`%t_)0Owq|;)6A?tiw{m((UqN0VpCNnCfM%+ciM1R0y=z)|yT#`Ew8vdZieQ zVKAl|HW*XaLl0f<>he8gh7z|Rmzb0M0o=2LHEOMuU!eSu#%9uV-~a#s07*qoM6N<$ Ef`+=7FaQ7m literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/spin_damage.png b/assets/voxygen/element/icons/skilltree/spin_damage.png new file mode 100644 index 0000000000000000000000000000000000000000..254168c8ff7840eb38b04111f7145041bfe7fae6 GIT binary patch literal 355 zcmV-p0i6DcP)Px$9Z5t%R5*>Ll|OF6FcgQsN4vEWL%K2h0+l#GHpCH-;Bt|2gw$IO5Qz(TPB(@Q zjFCGz*v2@f{g(W3{Q3RtCq)2yr7Xbbc8lX>x0~ z)n8@4#AlU@lB+274DkAl@Uqz_C4Qw@;k9X~#x9tU+X6^Lp0rL%ODWnzCtVU(W0#IR zX&s!lle$R|MtAS7O+&H|9kJBMZ+5pBkQXjVQ_OpK9)`QYb=&fOIu*+%t;0j{rR%oE zT04JOA_Fh7Pi+j=T114O!yy=pw;*0jdZlb_3;?}SSy>5l+c=54_DVf1n=6DcW-NQu z0Ws%cxJ53h@R8U*%sH}?h)A}AB?NB2fd5h(BfrQLme%H^5>NmD002ovPDHLkV1nhF Bl{^3d literal 0 HcmV?d00001 diff --git a/assets/voxygen/element/icons/skilltree/spin_helicopter.png b/assets/voxygen/element/icons/skilltree/spin_helicopter.png new file mode 100644 index 0000000000000000000000000000000000000000..04664fad59981f3b390d5d115c989bdc076d0201 GIT binary patch literal 359 zcmV-t0hs=YP)Px$AxT6*R5*>Ll`(F@FcgNrN7*_sq#Ls@P>BPuA&!8=<%pCcq}g%+q+Y;tx-lS? z5xGNU_t|mW(0)^5*XO`FInVBl8PVs-Yc8 z7k`y$iDpqMrIaXl53qbhcv z#wD+s2Im|i!sqEUlKMpum+r@Ibxk;jTWfL7g-JQ7Mjv+nFyLFbwKfd+gr1T#M@Xns ziU`-kAxzSTy~Mri#!d0*baT?qPsyT$zU*`#b<$kg^kHESwJ1%TN=rQSF3({J&>ItV zR?{0ZTlRiFPj@*d(x16h6eZM5B~2GjA@K7H_%B;)Px$B1uF+R5*>DlD%!iFc3!HIqnibh0?j!0s%aLJHsOgu$L3S5fpYFK!6uet#mF_ zxD=Gap>U!Yipf`zhvVaSKLT(qiV@&rzsKq2c%06!=QApljf~tHUJ^ z*3PEwpzaaOOLwtHRT11nCm*V%m)(5^#DQzjkft8qnkJaw4=JX>+WAm2W5|rbkG)+k zNia}*cxYS3aRfj_=*yDKm_^KQfnUK^!$bsNI)`HYiqpj&UW;M|>&tSr+=W9e?N&QX z(XDBoKPx$97#k$R5*>Dl0A;XFc5{`uyhm@*^W9FScwDBA&wA<(?!Y=vhFxQBrcFTbQBbn zktx_QV`rF{eN~>F`80#AX@a+)nnDlPO%q+PPlse_bnXT8 z-bYaBbD;cBG!*YWh-l((RTTo#7Nn0&rfflTvYqUqgt3s}>W zuyfY|(05hd1EPm%CR%1P@SW%{*w6l%p5_EGsJp6-SeZbbW8WlJV_#!C zOIqH5A!V?E(4J7F^#O^8X=s%gY=UX)OZT!#eVBNdK!OJ(5JEga3kWoEoIiCim{@cj zU*G%P@0{=4b53ny{6Np9$2Ktx)00UjC*j>6JY5gM|H;}DJ@9(SNx$eZ%;vt}*}%MC zf0SW1ZZosf{t z-@&3-sZ@kYNT6;(lwz@%h-6Wgc|h>qob78>-u8C38Ir`)UDNSRYO?{OmZN1q&Vi>* z36|5LwY^rDAYfuub3{o%fush|&^tJ%?3NnF4P7K9ViDW-04sH{PLcZ5E7E_V?rh&- z079#(9UFJ`#j-jkJU?{|WV8ZuSG1R%bBH)eJX&^jk~#)%?hMp8IN=h_r*4+gQv0GN z+Ag!QEJ*C`!=`P}iZ`(C07+^-iF0sk5|3bnvyy^gAbBs6FhWhJN)0nV_fKdPBN)mZ zP)Hd=^R;_|4ISsHYiS_Zw6p>d9lOA>oiO4AEm0Q?gLk3z>zPDi!lik$1RLJuf&FYI zl~AOZqVS-x;jXIUjP3cFt&>bL&OvYl(=_m4&OnN+MR_Tzhj_^tjPW@MAzsnLVMU7& z5;K}|;e3+nx#P# zhmH|UJFN;nI?ayQ(BWKYWvlG1Q_u!K&m>2((UUiBF7`Yib#Gi5Tk7iXKb`*NyCZm1 z>t0((ZU1`yg^MqrdiMFzGxS>5hfD9B-F0a3+y|$hvVXny__x2+cU@k&P@ehyP3hxO zq;`Jc;pLT8qwky5w>R%uULl`Kwe$5FdgJ2FBWDM``f|(S&rZGfk8|H|%?;Jx+3^YL zUiOP8E{_O((o6dFAFgb;FtdH^x#cZ?ZuORSj9vZWM|ryMdQL@eT{_ykZ4JGCeCqa- l@6H_TeR|>ctrKfGarnl7z3-9ZuLk`*lNwKcwEyU9e*roe0@VNj delta 340 zcmV-a0jvJ34DSMvB!2;OQb$4nuFf3k0003gNklyFTZm+QIYXmpj`^2mn65 ze%#BG1^~Rj&T$*N{Sg3gIN4~;kL`L%#27M#G9RhJTteF5)$Y`%uLgL+9Tt zDr(ABge6q%_D4A9yir>iV^CGqwaNmu&H^}vDo*(05K)J6o`?Vo6wf(Ui&+v?(p$J= zV@&s;4;RR>TD*y(i!A(9?icw$+4KDvwFok|LoBKfty*-qNsh||!w(aidzkq&B9vO(o=I#zB m3j!{`fO}y6I5W0gFX<0hVDc?L>AL*@0000>); @@ -338,8 +338,8 @@ impl SkillSet { } else { skill.get_max_level().map(|_| 1) }; - let prerequisites_met = self.prerequisites_met(skill, next_level); - if !matches!(self.skills.get(&skill), Some(&None)) { + let prerequisites_met = self.prerequisites_met(skill); + if !matches!(self.skills.get(&skill), Some(level) if *level == skill.get_max_level()) { if let Some(mut skill_group) = self .skill_groups .iter_mut() @@ -359,16 +359,16 @@ impl SkillSet { } self.skills.insert(skill, next_level); } else { - warn!("Tried to unlock skill for skill group with insufficient SP"); + trace!("Tried to unlock skill for skill group with insufficient SP"); } } else { - warn!("Tried to unlock skill without meeting prerequisite skills"); + trace!("Tried to unlock skill without meeting prerequisite skills"); } } else { - warn!("Tried to unlock skill for a skill group that player does not have"); + trace!("Tried to unlock skill for a skill group that player does not have"); } } else { - warn!("Tried to unlock skill the player already has") + trace!("Tried to unlock skill the player already has") } } else { warn!( @@ -488,8 +488,13 @@ impl SkillSet { /// Checks that the skill set contains all prerequisite skills for a /// particular skill - pub fn prerequisites_met(&self, skill: Skill, level: Level) -> bool { - skill.prerequisite_skills(level).iter().all(|(s, l)| { + pub fn prerequisites_met(&self, skill: Skill) -> bool { + let next_level = if self.skills.contains_key(&skill) { + self.skills.get(&skill).copied().flatten().map(|l| l + 1) + } else { + skill.get_max_level().map(|_| 1) + }; + skill.prerequisite_skills(next_level).iter().all(|(s, l)| { self.skills.contains_key(s) && self.skills.get(s).map_or(false, |l_b| l_b >= l) }) } @@ -520,6 +525,37 @@ impl SkillSet { .filter(|s_g| s_g.skill_group_type == skill_group); skill_groups.next().map_or(0, |s_g| s_g.exp) } + + /// Checks if player has sufficient skill points to purchase a skill + pub fn sufficient_skill_points(&self, skill: Skill) -> bool { + if let Some(skill_group_type) = SkillSet::get_skill_group_type_for_skill(&skill) { + if let Some(skill_group) = self + .skill_groups + .iter() + .find(|x| x.skill_group_type == skill_group_type) + { + let next_level = if self.skills.contains_key(&skill) { + self.skills.get(&skill).copied().flatten().map(|l| l + 1) + } else { + skill.get_max_level().map(|_| 1) + }; + let needed_sp = skill.skill_cost(next_level); + skill_group.available_sp > needed_sp + } else { + false + } + } else { + false + } + } + + /// Checks if the player has available SP to spend + pub fn has_available_sp(&self) -> bool { + self.skill_groups.iter().any(|sg| { + sg.available_sp > 0 + && (sg.earned_sp - sg.available_sp) < sg.skill_group_type.get_max_skill_points() + }) + } } impl Skill { @@ -528,10 +564,7 @@ impl Skill { pub fn prerequisite_skills(self, level: Level) -> HashMap { let mut prerequisites = HashMap::new(); if let Some(level) = level { - if level > self.get_max_level().unwrap_or(0) { - // Sets a prerequisite of itself for skills beyond the max level - prerequisites.insert(self, Some(level)); - } else if level > 1 { + if level > 1 { // For skills above level 1, sets prerequisite of skill of lower level prerequisites.insert(self, Some(level - 1)); } diff --git a/voxygen/src/hud/buttons.rs b/voxygen/src/hud/buttons.rs index c2b6795dee..2fa94cfd9f 100644 --- a/voxygen/src/hud/buttons.rs +++ b/voxygen/src/hud/buttons.rs @@ -1,6 +1,6 @@ use super::{ img_ids::{Imgs, ImgsRot}, - BLACK, CRITICAL_HP_COLOR, LOW_HP_COLOR, TEXT_COLOR, + BLACK, CRITICAL_HP_COLOR, LOW_HP_COLOR, QUALITY_LEGENDARY, TEXT_COLOR, }; use crate::{ i18n::Localization, @@ -11,10 +11,10 @@ use crate::{ use client::Client; use common::comp::Stats; use conrod_core::{ - widget::{self, Button, Text}, + widget::{self, Button, Image, Text}, widget_ids, Color, Colorable, Positionable, Sizeable, Widget, WidgetCommon, }; - +use inline_tweak::*; widget_ids! { struct Ids { bag, @@ -42,6 +42,9 @@ widget_ids! { crafting_text, crafting_text_bg, group_button, + sp_arrow, + sp_arrow_txt_bg, + sp_arrow_txt, } } #[derive(WidgetCommon)] @@ -57,6 +60,7 @@ pub struct Buttons<'a> { tooltip_manager: &'a mut TooltipManager, localized_strings: &'a Localization, stats: &'a Stats, + pulse: f32, } impl<'a> Buttons<'a> { @@ -71,6 +75,7 @@ impl<'a> Buttons<'a> { tooltip_manager: &'a mut TooltipManager, localized_strings: &'a Localization, stats: &'a Stats, + pulse: f32, ) -> Self { Self { client, @@ -83,6 +88,7 @@ impl<'a> Buttons<'a> { tooltip_manager, localized_strings, stats, + pulse, } } } @@ -122,6 +128,9 @@ impl<'a> Widget for Buttons<'a> { None => return None, }; let localized_strings = self.localized_strings; + let arrow_ani = + (self.pulse * tweak!(4.0)/* speed factor */).cos() * tweak!(0.5) + tweak!(0.8); //Animation timer + let button_tooltip = Tooltip::new({ // Edge images [t, b, r, l] // Corner images [tr, tl, br, bl] @@ -326,22 +335,26 @@ impl<'a> Widget for Buttons<'a> { .color(TEXT_COLOR) .set(state.ids.map_text, ui); } - - // Spellbook - if Button::image(self.imgs.spellbook_button) - .w_h(28.0, 25.0) - .left_from(state.ids.map_button, 10.0) - .hover_image(self.imgs.spellbook_hover) - .press_image(self.imgs.spellbook_press) - .with_tooltip( - self.tooltip_manager, - &localized_strings.get("hud.diary"), - "", - &button_tooltip, - TEXT_COLOR, - ) - .set(state.ids.spellbook_button, ui) - .was_clicked() + // Diary + let unspent_sp = self.stats.skill_set.has_available_sp(); + if Button::image(if !unspent_sp { + self.imgs.spellbook_button + } else { + self.imgs.spellbook_hover + }) + .w_h(28.0, 25.0) + .left_from(state.ids.map_button, 10.0) + .hover_image(self.imgs.spellbook_hover) + .press_image(self.imgs.spellbook_press) + .with_tooltip( + self.tooltip_manager, + &localized_strings.get("hud.diary"), + "", + &button_tooltip, + TEXT_COLOR, + ) + .set(state.ids.spellbook_button, ui) + .was_clicked() { return Some(Event::ToggleSpell); } @@ -364,7 +377,32 @@ impl<'a> Widget for Buttons<'a> { .color(TEXT_COLOR) .set(state.ids.spellbook_text, ui); } - + // Unspent SP indicator + if unspent_sp { + Image::new(self.imgs.sp_indicator_arrow) + .w_h(20.0, 11.0) + .graphics_for(state.ids.spellbook_button) + .mid_top_with_margin_on( + state.ids.spellbook_button, + tweak!(-12.0) + arrow_ani as f64, + ) + .color(Some(QUALITY_LEGENDARY)) + .set(state.ids.sp_arrow, ui); + Text::new(&localized_strings.get("hud.sp_arrow_txt")) + .mid_top_with_margin_on(state.ids.sp_arrow, tweak!(-18.0)) + .graphics_for(state.ids.spellbook_button) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(tweak!(14))) + .color(BLACK) + .set(state.ids.sp_arrow_txt_bg, ui); + Text::new(&localized_strings.get("hud.sp_arrow_txt")) + .graphics_for(state.ids.spellbook_button) + .bottom_right_with_margins_on(state.ids.sp_arrow_txt_bg, 1.0, 1.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(tweak!(14))) + .color(QUALITY_LEGENDARY) + .set(state.ids.sp_arrow_txt, ui); + } // Crafting if Button::image(self.imgs.crafting_icon) .w_h(25.0, 25.0) diff --git a/voxygen/src/hud/diary.rs b/voxygen/src/hud/diary.rs index d4a1be2397..aa1f1d2a2b 100644 --- a/voxygen/src/hud/diary.rs +++ b/voxygen/src/hud/diary.rs @@ -9,7 +9,8 @@ use crate::{ }; use conrod_core::{ color, - widget::{self, Button, Image, Rectangle, Text}, + image::Id, + widget::{self, button, Button, Image, Rectangle, Text}, widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; @@ -368,8 +369,16 @@ impl<'a> Widget for Diary<'a> { } // Weapon icons let available_pts = skill_tree_from_str(i.1) - .map_or(false, |st| self.stats.skill_set.get_available_sp(st) > 0); - self.stats.skill_set.get_available_sp(*sel_tab); + .map(|st| { + ( + st, + self.stats.skill_set.get_available_sp(st), + self.stats.skill_set.get_earned_sp(st), + ) + }) + .map_or(false, |(st, a_pts, e_pts)| { + a_pts > 0 && (e_pts - a_pts) < st.get_max_skill_points() + }); if Button::image( if skill_tree_from_str(i.1).map_or(false, |st| st == *sel_tab || available_pts) { self.imgs.wpn_icon_border_pressed @@ -632,7 +641,6 @@ impl<'a> Widget for Diary<'a> { // Skill-Icons and Functionality // Art dimensions let art_size = [tweak!(320.0), tweak!(320.0)]; - let skills = &self.stats.skill_set.skills; match sel_tab { SelectedSkillTree::General => { use skills::{GeneralSkill::*, RollSkill::*, SkillGroupType::*}; @@ -659,316 +667,256 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::General(HealthIncrease); - if Button::image(self.imgs.health_plus_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Increase Health", - "Increases health", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_stat_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.health_plus_skill, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Increase Health", + "Increases health", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_stat_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::General(EnergyIncrease); - if Button::image(self.imgs.stamina_plus_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Increase Energy", - "Increases energy", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_stat_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.stamina_plus_skill, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Increase Energy", + "Increases energy", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_stat_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::UnlockGroup(Weapon(Sword)); - if Button::image(self.imgs.unlock_sword_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Sword", - "Unlocks sword skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_sword_skill, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Sword", + "Unlocks sword skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::UnlockGroup(Weapon(Axe)); - if Button::image(self.imgs.unlock_axe_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Axe", - "Unlocks axe skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_axe_skill, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Axe", + "Unlocks axe skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::UnlockGroup(Weapon(Hammer)); - if Button::image(self.imgs.unlock_hammer_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Hammer", - "Unlocks hammer skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_hammer_skill, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Hammer", + "Unlocks hammer skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::UnlockGroup(Weapon(Bow)); - if Button::image(self.imgs.unlock_bow_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Bow", - "Unlocks bow skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_bow_skill, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Bow", + "Unlocks bow skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::UnlockGroup(Weapon(Staff)); - if Button::image(self.imgs.unlock_staff_skill0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Staff", - "Unlocks staff skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_staff_skill0, + state.skills_top_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Staff", + "Unlocks staff skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::UnlockGroup(Weapon(Sceptre)); - if Button::image(self.imgs.unlock_sceptre_skill) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[5]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Sceptre", - "Unlocks sceptre skill tree", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_tree_5, ui) - .was_clicked() + if create_skill_button( + self.imgs.unlock_sceptre_skill, + state.skills_top_r[5], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Sceptre", + "Unlocks sceptre skill tree", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_tree_5, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Roll(ImmuneMelee); - if Button::image(self.imgs.swords_crossed) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dodge", - "Ground-yeeting dodges melee attacks", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_roll_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.swords_crossed, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dodge", + "Ground-yeeting dodges melee attacks", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_roll_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Roll(Cost); - if Button::image(self.imgs.swords_crossed) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Cost", - "Decreases cost of ground-yeeting yourself", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_roll_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.swords_crossed, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Cost", + "Decreases cost of ground-yeeting yourself", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_roll_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Roll(Strength); - if Button::image(self.imgs.swords_crossed) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Strength", - "Increases how far you ground-yeet yourself", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_roll_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.swords_crossed, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Strength", + "Increases how far you ground-yeet yourself", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_roll_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Roll(Duration); - if Button::image(self.imgs.swords_crossed) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Duration", - "Increases for how long you ground-yeet yourself", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_general_roll_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.swords_crossed, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Duration", + "Increases for how long you ground-yeet yourself", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_general_roll_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -989,433 +937,341 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Sword(TsCombo); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Triple Strike Combo", - "Unlocks combo scaling on triple strike", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_combo_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Triple Strike Combo", + "Unlocks combo scaling on triple strike", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_combo_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(TsDamage); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Triple Strike Damage", - "Increases damage scaling on triple strike", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_combo_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Triple Strike Damage", + "Increases damage scaling on triple strike", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_combo_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(TsSpeed); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Triple Strike Speed", - "Increases attack speed scaling on triple strike", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_combo_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Triple Strike Speed", + "Increases attack speed scaling on triple strike", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_combo_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(TsRegen); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Triple Strike Regen", - "Increases enery regen scaling on triple strike", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_combo_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Triple Strike Regen", + "Increases enery regen scaling on triple strike", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_combo_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Sword(DDamage); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dash Damage", - "Increases initial damage of the dash", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Damage", + "Increases initial damage of the dash", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(DDrain); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dash Drain", - "Decreases the rate energy is drained while dashing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Drain", + "Decreases the rate energy is drained while dashing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(DCost); - let prereqs_met = tweak!(true); - let suff_pts = tweak!(false); - let label_txt = &format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - ); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(if prereqs_met { &label_txt } else { "" }) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(if suff_pts { - HP_COLOR - } else { - CRITICAL_HP_COLOR - }) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .image_color(if prereqs_met { - TEXT_COLOR - } else { - Color::Rgba(0.41, 0.41, 0.41, tweak!(0.7)) - }) - .with_tooltip( - self.tooltip_manager, - "Dash Cost", - "Decreases the initial cost of the dash", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Cost", + "Decreases the initial cost of the dash", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(DSpeed); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dash Speed", - "Increases how fast you go while dashing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Speed", + "Increases how fast you go while dashing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(DInfinite); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dash Infinite", - "Allows you to dash for as long as you have energy", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Infinite", + "Allows you to dash for as long as you have energy", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(DScaling); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[5]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Dash Scaling", - "Increases how much the damage scales by over the course of the dash", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_dash_5, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_top_r[5], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Dash Scaling", + "Increases how much the damage scales by over the course of the dash", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_dash_5, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Sword(SUnlockSpin); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Unlock", - "Unlocks the sword spin", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_spin_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Unlock", + "Unlocks the sword spin", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_spin_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(SDamage); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Damage", - "Increases the damage done", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_spin_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Damage", + "Increases the damage done", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_spin_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(SSpeed); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Speed", - "Increase the speed at which you spin", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_spin_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Speed", + "Increase the speed at which you spin", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_spin_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(SCost); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Cost", - "Decreases the energy cost of each spin", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_spin_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Cost", + "Decreases the energy cost of each spin", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_spin_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sword(SSpins); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Spins", - "Increases the number of times you can spin", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_spin_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Spins", + "Increases the number of times you can spin", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_spin_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom right skills let skill = Skill::Sword(InterruptingAttacks); - if Button::image(self.imgs.sword_whirlwind) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Interrupting Attacks", - "Allows you to immediately cancel an attack with another attack", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sword_passive_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.sword_whirlwind, + state.skills_bot_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Interrupting Attacks", + "Allows you to immediately cancel an attack with another attack", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sword_passive_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -1436,368 +1292,298 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Axe(DsCombo); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Double Strike Combo", - "Unlocks a second strike", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_combo_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Double Strike Combo", + "Unlocks a second strike", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_combo_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(DsDamage); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Double Strike Damage", - "Increases damage scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_combo_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Double Strike Damage", + "Increases damage scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_combo_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(DsSpeed); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Double Strike Speed", - "Increases speed scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_combo_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Double Strike Speed", + "Increases speed scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_combo_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(DsRegen); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Double Strike Regen", - "Increases energy regen scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_combo_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Double Strike Regen", + "Increases energy regen scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_combo_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Axe(SInfinite); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Infinite Axe Spin", - "Spin for as long as you have energy", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_spin_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Infinite Axe Spin", + "Spin for as long as you have energy", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_spin_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(SDamage); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Damage", - "Increases the daamge each spin does", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_spin_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Damage", + "Increases the daamge each spin does", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_spin_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(SHelicopter); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Helicopter", - "You fall a little slower while spinning", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_spin_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Helicopter", + "You fall a little slower while spinning", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_spin_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(SSpeed); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Speed", - "Increases your spins per minute", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_spin_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Speed", + "Increases your spins per minute", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_spin_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(SCost); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Spin Cost", - "Increases your spin per energy efficiency", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_spin_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_top_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Spin Cost", + "Increases your spin per energy efficiency", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_spin_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Axe(LUnlockLeap); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Leap", - "Unlocks a leap spin", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_leap_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Leap", + "Unlocks a leap spin", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_leap_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(LDamage); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Damage", - "Increases damage of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_leap_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Damage", + "Increases damage of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_leap_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(LKnockback); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Knockback", - "Increases knockback from leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_leap_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Knockback", + "Increases knockback from leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_leap_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(LCost); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Cost", - "Decreases cost of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_leap_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Cost", + "Decreases cost of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_leap_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Axe(LDistance); - if Button::image(self.imgs.axespin) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Distance", - "Increases distance of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_axe_leap_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.axespin, + state.skills_bot_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Distance", + "Increases distance of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_axe_leap_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -1818,368 +1604,298 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Hammer(SsKnockback); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Single Strike Knockback", - "Increaes yeet potential of swings", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_combo_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Single Strike Knockback", + "Increaes yeet potential of swings", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_combo_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(SsDamage); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Single Strike Damage", - "Increases damage scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_combo_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Single Strike Damage", + "Increases damage scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_combo_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(SsSpeed); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Single Strike Speed", - "Increases speed scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_combo_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Single Strike Speed", + "Increases speed scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_combo_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(SsRegen); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Single Strike Regen", - "Increases energy regen scaling in combo", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_combo_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Single Strike Regen", + "Increases energy regen scaling in combo", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_combo_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Hammer(CKnockback); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Melee Knockback", - "Massively increases yeet potential of swing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_charged_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Melee Knockback", + "Massively increases yeet potential of swing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_charged_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(CDamage); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Melee Damage", - "Increases the daamge of the charged swing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_charged_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Melee Damage", + "Increases the daamge of the charged swing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_charged_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(CDrain); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Melee Energy Drain", - "Decreases the rate energy drains when charging", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_charged_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Melee Energy Drain", + "Decreases the rate energy drains when charging", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_charged_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(CSpeed); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charge Rate", - "Increases the rate that you charge the swing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_charged_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charge Rate", + "Increases the rate that you charge the swing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_charged_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Hammer(LUnlockLeap); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Unlock Leap", - "Unlocks a leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Unlock Leap", + "Unlocks a leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(LDamage); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Damage", - "Increases damage of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Damage", + "Increases damage of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(LKnockback); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Knockback", - "Increases knockback from leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Knockback", + "Increases knockback from leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(LCost); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Cost", - "Decreases cost of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Cost", + "Decreases cost of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(LDistance); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Distance", - "Increases distance of leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Distance", + "Increases distance of leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Hammer(LRange); - if Button::image(self.imgs.hammergolf) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[5]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Leap Radius", - "Increases attack radius on ground slam", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_hammer_leap_5, ui) - .was_clicked() + if create_skill_button( + self.imgs.hammergolf, + state.skills_bot_l[5], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Leap Radius", + "Increases attack radius on ground slam", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_hammer_leap_5, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -2199,369 +1915,299 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Bow(BDamage); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Damage", - "Increases damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_basic_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Damage", + "Increases damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_basic_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(BRegen); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Energy Regen", - "Increases energy regen", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_basic_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Energy Regen", + "Increases energy regen", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_basic_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Bow(CDamage); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Damage", - "Increases how much damage scales by as it is charged", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Damage", + "Increases how much damage scales by as it is charged", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(CDrain); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Drain", - "Decreases the rate energy is drained while charging", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Drain", + "Decreases the rate energy is drained while charging", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(CProjSpeed); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Projectile Speed", - "Increases yeet potential applied to arrow while charging", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Projectile Speed", + "Increases yeet potential applied to arrow while charging", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(CSpeed); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Speed", - "Increases the rate that you charge the attack", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Speed", + "Increases the rate that you charge the attack", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(CMove); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Move Speed", - "Increases how fast you can shuffle while charging the attack", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Move Speed", + "Increases how fast you can shuffle while charging the attack", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(CKnockback); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[5]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Charged Knockback", - "Yeet enemies further", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_charged_5, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_top_r[5], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Charged Knockback", + "Yeet enemies further", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_charged_5, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Bow(UnlockRepeater); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Repeater Unlock", - "Unlocks the ability to leap in the arrow", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_repeater_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Repeater Unlock", + "Unlocks the ability to leap in the arrow", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_repeater_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(RDamage); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Repeater Damage", - "Increases the damage done", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_repeater_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Repeater Damage", + "Increases the damage done", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_repeater_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(RGlide); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Repeater Glide", - "Glide further while repeatering", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_repeater_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Repeater Glide", + "Glide further while repeatering", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_repeater_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(RCost); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Repeater Cost", - "Decreases the energy cost to become a gliding repeater", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_repeater_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Repeater Cost", + "Decreases the energy cost to become a gliding repeater", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_repeater_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Bow(RArrows); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Arrow Count", - "Yeet more arrows when you leap", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_repeater_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Arrow Count", + "Yeet more arrows when you leap", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_repeater_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom right skills let skill = Skill::Bow(ProjSpeed); - if Button::image(self.imgs.bow_m1) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Projectile Speed", - "Allows you to yeet arrows further, faster", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_bow_passive_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.bow_m1, + state.skills_bot_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Projectile Speed", + "Allows you to yeet arrows further, faster", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_bow_passive_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -2582,342 +2228,277 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Staff(BExplosion); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Explosion", - "When fire just isn't enough", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_basic_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Explosion", + "When fire just isn't enough", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_basic_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(BDamage); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Damage", - "Increases damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_basic_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Damage", + "Increases damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_basic_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(BRegen); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Energy Regen", - "Increases energy regen", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_basic_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Energy Regen", + "Increases energy regen", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_basic_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(BRadius); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Explosion Radius", - "Bigger is better", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_basic_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Explosion Radius", + "Bigger is better", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_basic_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Staff(FDamage); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Flamethrower Damage", - "Increases damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_beam_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Flamethrower Damage", + "Increases damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_beam_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(FDrain); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Energy Drain", - "Decreases the rate energy is drained", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_beam_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Energy Drain", + "Decreases the rate energy is drained", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_beam_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(FRange); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Flamethrower Range", - "For when the flames just won't reach", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_beam_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Flamethrower Range", + "For when the flames just won't reach", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_beam_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(FVelocity); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Flame Velocity", - "Gets the fire there faster", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_beam_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Flame Velocity", + "Gets the fire there faster", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_beam_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Bottom left skills let skill = Skill::Staff(UnlockShockwave); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Shockwave Unlock", - "Unlocks the ability to yeet enemies away using fire", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_shockwave_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_bot_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Shockwave Unlock", + "Unlocks the ability to yeet enemies away using fire", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_shockwave_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(SDamage); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Shockwave Damage", - "Increases the damage done", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_shockwave_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_bot_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Shockwave Damage", + "Increases the damage done", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_shockwave_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(SKnockback); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Shockwave Knockback", - "Increases yeet potential", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_shockwave_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_bot_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Shockwave Knockback", + "Increases yeet potential", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_shockwave_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(SCost); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Shockwave Cost", - "Decreases the energy cost to yeet helpless villagers", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_shockwave_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_bot_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Shockwave Cost", + "Decreases the energy cost to yeet helpless villagers", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_shockwave_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Staff(SRange); - if Button::image(self.imgs.fireball) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_bot_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Shockwave Range", - "Yeet things that used to be out of reach", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_staff_shockwave_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.fireball, + state.skills_bot_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Shockwave Range", + "Yeet things that used to be out of reach", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_staff_shockwave_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -2938,289 +2519,234 @@ impl<'a> Widget for Diary<'a> { // 3 0 4 // 8 2 7 let skill = Skill::Sceptre(BHeal); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Beam Heal", - "Increased healing from the beam", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Beam Heal", + "Increased healing from the beam", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(BDamage); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Damage", - "Increases damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Damage", + "Increases damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(BRegen); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Energy Regen", - "Increases energy regen from damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Energy Regen", + "Increases energy regen from damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(BRange); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Range", - "Longer beam", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Range", + "Longer beam", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(BLifesteal); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Lifesteal Efficiency", - "Thieve more health", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Lifesteal Efficiency", + "Thieve more health", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(BCost); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_l[5]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Heal Cost", - "Use less energy when healing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_beam_5, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_l[5], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Heal Cost", + "Use less energy when healing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_beam_5, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; // Top right skills let skill = Skill::Sceptre(PHeal); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[0]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Heal", - "Increases healing", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_bomb_0, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_r[0], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Heal", + "Increases healing", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_bomb_0, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(PDamage); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[1]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Damage", - "Increases damage", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_bomb_1, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_r[1], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Damage", + "Increases damage", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_bomb_1, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(PRadius); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[2]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Radius", - "Increases radius", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_bomb_2, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_r[2], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Radius", + "Increases radius", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_bomb_2, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(PCost); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[3]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Energy Cost", - "Decreases energy cost of bomb", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_bomb_3, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_r[3], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Energy Cost", + "Decreases energy cost of bomb", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_bomb_3, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; let skill = Skill::Sceptre(PProjSpeed); - if Button::image(self.imgs.heal_0) - .w_h(tweak!(74.0), tweak!(74.0)) - .middle_of(state.skills_top_r[4]) - .label(&format!( - "{}/{}", - skills.get(&skill).copied().map_or(0, |l| l.unwrap_or(1)), - skill.get_max_level().unwrap_or(1) - )) - .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) - .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) - .label_color(TEXT_COLOR) - .label_font_size(self.fonts.cyri.scale(tweak!(16))) - .label_font_id(self.fonts.cyri.conrod_id) - .with_tooltip( - self.tooltip_manager, - "Projectile Speed", - "Yeets it faster", - &diary_tooltip, - TEXT_COLOR, - ) - .set(state.skill_sceptre_bomb_4, ui) - .was_clicked() + if create_skill_button( + self.imgs.heal_0, + state.skills_top_r[4], + &self.stats.skill_set, + skill, + self.fonts, + &get_skill_label(skill, &self.stats.skill_set), + ) + .with_tooltip( + self.tooltip_manager, + "Projectile Speed", + "Yeets it faster", + &diary_tooltip, + TEXT_COLOR, + ) + .set(state.skill_sceptre_bomb_4, ui) + .was_clicked() { events.push(Event::UnlockSkill(skill)); }; @@ -3232,6 +2758,51 @@ impl<'a> Widget for Diary<'a> { } } +fn create_skill_button<'a>( + image: Id, + state: widget::Id, + skill_set: &'a skills::SkillSet, + skill: Skill, + fonts: &'a Fonts, + label: &'a str, +) -> Button<'a, button::Image> { + Button::image(image) + .w_h(tweak!(74.0), tweak!(74.0)) + .middle_of(state) + .label(label) + .label_y(conrod_core::position::Relative::Scalar(tweak!(-28.0))) + .label_x(conrod_core::position::Relative::Scalar(tweak!(32.0))) + .label_color(if skill_set.sufficient_skill_points(skill) { + HP_COLOR + } else { + CRITICAL_HP_COLOR + }) + .label_color(TEXT_COLOR) + .label_font_size(fonts.cyri.scale(tweak!(16))) + .label_font_id(fonts.cyri.conrod_id) + .image_color(if skill_set.prerequisites_met(skill) { + TEXT_COLOR + } else { + Color::Rgba(0.41, 0.41, 0.41, tweak!(0.7)) + }) +} + +fn get_skill_label(skill: Skill, skill_set: &skills::SkillSet) -> String { + if skill_set.prerequisites_met(skill) { + format!( + "{}/{}", + skill_set + .skills + .get(&skill) + .copied() + .map_or(0, |l| l.unwrap_or(1)), + skill.get_max_level().unwrap_or(1) + ) + } else { + "".to_string() + } +} + fn skill_tree_from_str(string: &str) -> Option { match string { "General Combat" => Some(SelectedSkillTree::General), diff --git a/voxygen/src/hud/hotbar.rs b/voxygen/src/hud/hotbar.rs index 1e29e25559..9f3f61a2ca 100644 --- a/voxygen/src/hud/hotbar.rs +++ b/voxygen/src/hud/hotbar.rs @@ -71,27 +71,47 @@ impl State { use specs::WorldExt; let inventories = client.state().ecs().read_storage::(); let inventory = inventories.get(client.entity()); - let should_be_present = if let Some(inventory) = inventory { + let stats = client.state().ecs().read_storage::(); + let stat = stats.get(client.entity()); + let should_be_present = if let (Some(inventory), Some(stat)) = (inventory, stat) { inventory .equipped(EquipSlot::Mainhand) .map(|i| i.kind()) .filter(|kind| { - use common::comp::item::{ - tool::{ToolKind, UniqueKind}, - ItemKind, + use common::comp::{ + item::{ + tool::{ToolKind, UniqueKind}, + ItemKind, + }, + skills::{self, Skill}, }; - if let ItemKind::Tool(kind) = kind { - matches!( - &kind.kind, - ToolKind::Staff - | ToolKind::Debug - | ToolKind::Sword - | ToolKind::Hammer - | ToolKind::Axe - | ToolKind::Bow - | ToolKind::Unique(UniqueKind::QuadMedQuick) - | ToolKind::Unique(UniqueKind::QuadLowBreathe) - ) + if let ItemKind::Tool(tool) = kind { + match tool.kind { + ToolKind::Sword => stat + .skill_set + .skills + .contains_key(&Skill::Sword(skills::SwordSkill::SUnlockSpin)), + ToolKind::Axe => stat + .skill_set + .skills + .contains_key(&Skill::Axe(skills::AxeSkill::LUnlockLeap)), + ToolKind::Hammer => stat + .skill_set + .skills + .contains_key(&Skill::Hammer(skills::HammerSkill::LUnlockLeap)), + ToolKind::Bow => stat + .skill_set + .skills + .contains_key(&Skill::Bow(skills::BowSkill::UnlockRepeater)), + ToolKind::Staff => stat + .skill_set + .skills + .contains_key(&Skill::Staff(skills::StaffSkill::UnlockShockwave)), + ToolKind::Debug + | ToolKind::Unique(UniqueKind::QuadMedQuick) + | ToolKind::Unique(UniqueKind::QuadLowBreathe) => true, + _ => false, + } } else { false } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 0dc0070fb6..1ceae3c14f 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -147,6 +147,8 @@ image_ids! { group_icon_hover: "voxygen.element.buttons.group_hover", group_icon_press: "voxygen.element.buttons.group_press", + sp_indicator_arrow: "voxygen.element.buttons.arrow_down_gold", + // Skill Icons twohsword_m1: "voxygen.element.icons.2hsword_m1", twohsword_m2: "voxygen.element.icons.2hsword_m2", diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 6d17cca5f2..f27f8d51c4 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1895,6 +1895,7 @@ impl Hud { tooltip_manager, i18n, &player_stats, + self.pulse, ) .set(self.ids.buttons, ui_widgets) { diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index b0e4a0d575..6871785bde 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -37,6 +37,8 @@ use iced::{ }; use vek::Rgba; +use inline_tweak::*; + pub const TEXT_COLOR: iced::Color = iced::Color::from_rgb(1.0, 1.0, 1.0); pub const DISABLED_TEXT_COLOR: iced::Color = iced::Color::from_rgba(1.0, 1.0, 1.0, 0.2); pub const TOOLTIP_BACK_COLOR: Rgba = Rgba::new(20, 18, 10, 255); @@ -444,7 +446,7 @@ impl Controls { select_button, Column::with_children(vec![ Text::new(&character.character.alias) - .size(fonts.cyri.scale(30)) + .size(fonts.cyri.scale(tweak!(26))) .into(), // TODO: only construct string once when characters // are