nvh Posted September 6, 2021 Share Posted September 6, 2021 How to change stats color in item desc window. HP: Red MP: Blue Str: Yello Def: White ...... Code: https://github.com/AscensionGameDev/Intersect-Engine/blob/main/Intersect.Client/Interface/Game/ItemDescWindow.cs thanks Link to comment Share on other sites More sharing options...
0 boasfesta Posted September 7, 2021 Share Posted September 7, 2021 I guess that you just need to change the itemStats.RenderColor parameter under the AddText function at lines 152 (vitals) and 183 (stats). An easy way to do that is by creating a Color variable and a switch to set its value above the AddText command. An stat application example: Color renderStatColor = itemStats.RenderColor; switch (i) { case (int)Stats.Attack: renderStatColor = Color.Red; break; case (int)Stats.AbilityPower: renderStatColor = Color.Green; break; case (int)Stats.Defense: renderStatColor = Color.Orange; break; case (int)Stats.MagicResist: renderStatColor = Color.Pink; break; case (int)Stats.Speed: renderStatColor = Color.White; break; } And then change the itemStats.RenderColor parameter at AddText command to the variable (renderStatColor in that case). Example at line 183 where the stats are added: stats = Strings.ItemDesc.stats[i].ToString(bonus); itemStats.AddText( stats, renderStatColor, itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left, itemDescText.Font ); Just repeat those steps for line 152 and it should work for Vitals too. nvh 1 Link to comment Share on other sites More sharing options...
0 nvh Posted September 7, 2021 Author Share Posted September 7, 2021 1 hour ago, boasfesta said: I guess that you just need to change the itemStats.RenderColor parameter under the AddText function at lines 152 (vitals) and 183 (stats). An easy way to do that is by creating a Color variable and a switch to set its value above the AddText command. An stat application example: Color renderStatColor = itemStats.RenderColor; switch (i) { case (int)Stats.Attack: renderStatColor = Color.Red; break; case (int)Stats.AbilityPower: renderStatColor = Color.Green; break; case (int)Stats.Defense: renderStatColor = Color.Orange; break; case (int)Stats.MagicResist: renderStatColor = Color.Pink; break; case (int)Stats.Speed: renderStatColor = Color.White; break; } And then change the itemStats.RenderColor parameter at AddText command to the variable (renderStatColor in that case). Example at line 183 where the stats are added: stats = Strings.ItemDesc.stats[i].ToString(bonus); itemStats.AddText( stats, renderStatColor, itemStatsText.CurAlignments.Count > 0 ? itemStatsText.CurAlignments[0] : Alignments.Left, itemDescText.Font ); Just repeat those steps for line 152 and it should work for Vitals too. Oh your ... helpful for me. Thank you I'm thinking item name will animate 2 colors when item is Epic or Legend. is it possible? Link to comment Share on other sites More sharing options...
0 boasfesta Posted September 7, 2021 Share Posted September 7, 2021 2 hours ago, nvh said: Oh your ... helpful for me. Thank you I'm thinking item name will animate 2 colors when item is Epic or Legend. is it possible? Yup, probably the item name color is defined by the conditional structure between lines 76 and 87, so you only need to add an IF after that checking the rarity for Epic or Legend (Dont know the exact number), in positive case, use the code below to animate the item name color. if (System.Environment.TickCount % 1000 > 500) { itemType.TextColorOverride = Color.White; } else { itemType.TextColorOverride = Color.Red; } Didnt tested it but should work, hope it helps. nvh 1 Link to comment Share on other sites More sharing options...
0 nvh Posted September 7, 2021 Author Share Posted September 7, 2021 4 hours ago, boasfesta said: Yup, probably the item name color is defined by the conditional structure between lines 76 and 87, so you only need to add an IF after that checking the rarity for Epic or Legend (Dont know the exact number), in positive case, use the code below to animate the item name color. if (System.Environment.TickCount % 1000 > 500) { itemType.TextColorOverride = Color.White; } else { itemType.TextColorOverride = Color.Red; } Didnt tested it but should work, hope it helps. how to make it update continuously? when i change (add += statsgiven[]) the item's stats i need to log out to update s Link to comment Share on other sites More sharing options...
0 boasfesta Posted September 8, 2021 Share Posted September 8, 2021 14 hours ago, nvh said: how to make it update continuously? when i change (add += statsgiven[]) the item's stats i need to log out to update s Thats not so simple at all. Just noticed now that the ItemDescWindow only set the description color at the constructor so the flashing name would not work. To work with no-static elements you need to update them at running time, starting by creating a Update() function at ItemDescWindow and call it at every window Update function that uses a ItemDescWindow (Just like Inventory, Bank, Trade, Shop...). If you only want to flash the item name for Epic and Legendary rarity, jump to step 4. Then you need to reference the added label in ItemDescWindow, so change the public void AddText at RichLabel.cs from void to TextBlock so you can return the var block at the end of the function. After that, create a "public List<TextBlock> statListLabels = new List<TextBlock>()" at ItemDescWindow to hold stats (and another to hold vitals) and embrace itemStats.AddText at line 184 with statListLabels.Add(). Set colors with the previous codes at the ItemDescWindow Update function. Use itemType.TextColorOverride to flash the rarity color and statListLabels[stat].Color to change stats. Probably not so simple but it should work. Its a small generic system that can be useful for anyone, so maybe i can create a git patch and put on Itch.Io if you dont mind to share with the community. nvh 1 Link to comment Share on other sites More sharing options...
0 nvh Posted September 9, 2021 Author Share Posted September 9, 2021 12 hours ago, boasfesta said: Thats not so simple at all. Just noticed now that the ItemDescWindow only set the description color at the constructor so the flashing name would not work. To work with no-static elements you need to update them at running time, starting by creating a Update() function at ItemDescWindow and call it at every window Update function that uses a ItemDescWindow (Just like Inventory, Bank, Trade, Shop...). If you only want to flash the item name for Epic and Legendary rarity, jump to step 4. Then you need to reference the added label in ItemDescWindow, so change the public void AddText at RichLabel.cs from void to TextBlock so you can return the var block at the end of the function. After that, create a "public List<TextBlock> statListLabels = new List<TextBlock>()" at ItemDescWindow to hold stats (and another to hold vitals) and embrace itemStats.AddText at line 184 with statListLabels.Add(). Set colors with the previous codes at the ItemDescWindow Update function. Use itemType.TextColorOverride to flash the rarity color and statListLabels[stat].Color to change stats. Probably not so simple but it should work. Its a small generic system that can be useful for anyone, so maybe i can create a git patch and put on Itch.Io if you dont mind to share with the community. how to i call Update() function at ItemDescWindow in other file? Link to comment Share on other sites More sharing options...
0 boasfesta Posted September 9, 2021 Share Posted September 9, 2021 9 hours ago, nvh said: how to i call Update() function at ItemDescWindow in other file? There is a Example on InventoryItem.cs: if (mDescWindow != null) { mDescWindow.Dispose(); mDescWindow = null; } mDescWindow is an ItemDescWindow object (You can see this just by clicking F12 on it). So the only thing you need to do is to call mDescWindow Update function at InventoryItem Update(), right on the start: if (mDescWindow != null) { mDescWindow.Update(); } Do that for BankItem, TradeItem, EquipmentItem and ShopItem too. nvh 1 Link to comment Share on other sites More sharing options...
0 nvh Posted September 10, 2021 Author Share Posted September 10, 2021 On 9/8/2021 at 9:31 PM, boasfesta said: Thats not so simple at all. Just noticed now that the ItemDescWindow only set the description color at the constructor so the flashing name would not work. To work with no-static elements you need to update them at running time, starting by creating a Update() function at ItemDescWindow and call it at every window Update function that uses a ItemDescWindow (Just like Inventory, Bank, Trade, Shop...). If you only want to flash the item name for Epic and Legendary rarity, jump to step 4. Then you need to reference the added label in ItemDescWindow, so change the public void AddText at RichLabel.cs from void to TextBlock so you can return the var block at the end of the function. After that, create a "public List<TextBlock> statListLabels = new List<TextBlock>()" at ItemDescWindow to hold stats (and another to hold vitals) and embrace itemStats.AddText at line 184 with statListLabels.Add(). Set colors with the previous codes at the ItemDescWindow Update function. Use itemType.TextColorOverride to flash the rarity color and statListLabels[stat].Color to change stats. Probably not so simple but it should work. Its a small generic system that can be useful for anyone, so maybe i can create a git patch and put on Itch.Io if you dont mind to share with the community. thank for your god help. I tried but this way is too hard for me, I will try harder boasfesta 1 Link to comment Share on other sites More sharing options...
Question
nvh
How to change stats color in item desc window.
HP: Red
MP: Blue
Str: Yello
Def: White
......
Code: https://github.com/AscensionGameDev/Intersect-Engine/blob/main/Intersect.Client/Interface/Game/ItemDescWindow.cs
thanks
Link to comment
Share on other sites
8 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now