Playnite Forums
  • Playnite Web
  • Rules
  • Members
  • Team
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Playnite Forums Development Themes Conditional Statements to Display Fields

Conditional Statements to Display Fields
CriticalComposer
Offline

#1
11-16-2020, 08:43 PM
When adding data entries to a game's Details page -- such as Genre, or Source, or Platform, or Time Played -- is there a way to use a conditional to assign two sets of text to a TextBlock depending on a variable? My idea is to display the game's Time Played but if a game hasn't been played yet then I'd like to display the Average Time to Beat (I've been using a workaround to assign this info to each game). Something like:


if (CompletionStatus == NotPlayed)
    Text="{Binding Playtime, Converter={StaticResource LongToTimePlayedConverter}}"
else
    Text="{Binding [OtherDataPoint], Converter=blahblahblah}"


and I would do something similar to the DynamicResource to make sure the labels properly reflected the data being displayed.
joyrider3774
Offline

#2
11-16-2020, 09:28 PM
i have not tried it but wouldn't a datatrigger work for this ?
Crow
Offline

Administrator
#3
11-17-2020, 07:33 AM
"I've been using a workaround to assign this info to each game"

I immediately don't wont to look more into this because of this message Smile However, I think you should be able to do this with some combination of data triggers, but since I have no idea where you are getting the other data from, it might not be possible.
LuigiVs
Offline

#4
11-17-2020, 04:07 PM
Would this be for importing metadata for games?

Like say you import Age Rating as "ESRB E10", it would then be changed into "E10+" specifically.

I've been sorting a lot of my library recently, so this would be useful to merge entries together easily.
Crow
Offline

Administrator
#5
11-17-2020, 06:18 PM
No, this thread has nothing to do with metadata downloads. What you are asking for is this: https://github.com/JosefNemec/Playnite/issues/1902
CriticalComposer
Offline

#6
11-17-2020, 09:29 PM
I have zero experience with DataTriggers so if anyone could help out a bit with that it would be much appreciated -- otherwise I'll just do my typical "read docs, try stuff, fail repeatedly" method until I stumble on the right code Smile

As for the time to beat -- I store that info in the Age Rating metadata slot. The only thing I need to change is rather pulling the AgeRating DynamicResource I just use a "Time to Beat" string. Of course I'd like a unique entry point for this but I doubt very many people would use it, opting more for keeping that data in tags like with the the HowLongToBeat extension by Lacro59. Since I don't have any intentions of using the Age Rating entry I have no problem with this little workaround.
darklinkpower
Offline

Super Moderator
#7
11-21-2020, 08:13 AM
You need to reference `AgeRating`with a Binding https://playnite.link/docs/tutorials/the...n-to-views
CriticalComposer
Offline

#8
11-21-2020, 02:41 PM
(11-21-2020, 08:13 AM)darklinkpower Wrote: You need to reference `AgeRating`with a Binding https://playnite.link/docs/tutorials/the...n-to-views
Yup, that's what I've been doing. But I need a bit of help with the DataTrigger to change whether the AgeRating is displayed or the TimePlayed.
darklinkpower
Offline

Super Moderator
#9
11-21-2020, 02:59 PM
I see. Full file example: https://pastebin.com/bcP4mYtm
Check lines 62-66 and 103-105. In this way, you replace the text content in the same TextBlock.

I suggest checking the resources listed in the Playnite docs to learn how to do things like this and others, it will make it easier in the long run: https://playnite.link/docs/tutorials/the...-resources
https://www.tutorialspoint.com/wpf/wpf_triggers.htm
CriticalComposer
Offline

#10
11-25-2020, 01:51 AM
(11-21-2020, 02:59 PM)darklinkpower Wrote: I see. Full file example: https://pastebin.com/bcP4mYtm
Check lines 62-66 and 103-105. In this way, you replace the text content in the same TextBlock.

I suggest checking the resources listed in the Playnite docs to learn how to do things like this and others, it will make it easier in the long run: https://playnite.link/docs/tutorials/the...-resources
https://www.tutorialspoint.com/wpf/wpf_triggers.htm
Thanks so much for this. I've been tweaking themes by text and learning as I go but I assume, as you stated, that eventually I should just sit down with the resource and actually learn what I'm doing. The example helped a lot but I've also bookmarked the two docs for further reading.
darklinkpower
Offline

Super Moderator
#11
11-25-2020, 11:26 AM
I highly recommend using Blend for editing, I can't imagine how much more difficult editing in a simple text editor is. Using Blend will give you syntax highlighting, previews, auto completion, check for errors, etc. and doesn't take more than a few minutes to set up.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode