Primpy
Primpy
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
Oh, I think I could do that. And that usage of "nameof" gave me yet another idea on how I could implement this. Thanks!
20 replies
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
I'm aware... Either way, unfortunate for me that I can't hold references like that. Thanks for the help, I'll see what I can do about it.
20 replies
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
I'm aware, it's a patchwork solution for a project with a deadline that is pretty close...
20 replies
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
To clarify, AddLocalizedText is called with the parameter LanguageStrings.StartGameButtonString, which is a string declared in the body of my class. The desired result is for the Item2 of LocalizedText to update by itself whenever the value of StartGameButtonString is modified. Sorry if I worded this poorly.
20 replies
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
My goal was to have Item2 have a reference to the string so it would automatically update. Is that possible?
20 replies
CC#
Created by Primpy on 6/15/2023 in #help
❔ How to make a list of tuples that hold references?
It's part of a larger project. The relevant code looks something like this:
public static List<(Text, string)> LocalizedText { get; set; } = new();

public static void SetEnglish()
{
StartGameButtonString = "START GAME";
...
}

public static void SetRomanian()
{
StartGameButtonString = "INCEPE JOCUL";
...
}

public static void AddLocalizedText(Text text, string str) { LocalizedText.Add((text, str)); }

public static void Update()
{
Initialize();
foreach (var localizedText in LocalizedText)
{
localizedText.Item1.DisplayedString = localizedText.Item2;
}
}
public static List<(Text, string)> LocalizedText { get; set; } = new();

public static void SetEnglish()
{
StartGameButtonString = "START GAME";
...
}

public static void SetRomanian()
{
StartGameButtonString = "INCEPE JOCUL";
...
}

public static void AddLocalizedText(Text text, string str) { LocalizedText.Add((text, str)); }

public static void Update()
{
Initialize();
foreach (var localizedText in LocalizedText)
{
localizedText.Item1.DisplayedString = localizedText.Item2;
}
}
I noticed the problem when placing a breakpoint inside the Update() function. Even though the contents of StartGameButtonString were updated, the string inside localizedText.Item2 was not. Is the problem here or should I look somewhere else?
20 replies
CC#
Created by Primpy on 6/3/2023 in #help
❔ JsonSerializer serializes list as if its entries were empty
I see, thanks :)
5 replies