protected override void Initialize() { string variables; bool variants; LocalizableString localizable_question, localizable_rationale; xml_drawing.CreateDrawingObjects(game.DrawingObjects); // Draw objects shared by all variants if (game.Variants.Count > 0) { xml_drawing.CreateDrawingObjects(game.Variants[current.Variant].DrawingObjects); // Draw variant specific objects } compiler = ServiceLocator.Instance.GetService <ICSharpCompiler> (); variants = game.Variants.Count > 0; SetCheckAttributes(); if (variants && game.Variants[current.Variant].Variables != null) { variables = game.Variants[current.Variant].Variables; } else { variables = game.Variables; } if (variants && game.Variants[current.Variant].Question != null) { localizable_question = game.Variants[current.Variant].Question; } else { localizable_question = game.Question; } if (variants && game.Variants[current.Variant].Rationale != null) { localizable_rationale = game.Variants[current.Variant].Rationale; } else { localizable_rationale = game.Rationale; } if (String.IsNullOrEmpty(variables) == false) { compiler.EvaluateCode(variables); try { if (String.IsNullOrEmpty(localizable_question.Value) == false) { localizable_question.ValueComputed = Int32.Parse(ReplaceVariables(localizable_question.Value)); } if (localizable_rationale != null && String.IsNullOrEmpty(localizable_rationale.Value) == false) { localizable_rationale.ValueComputed = Int32.Parse(ReplaceVariables(localizable_rationale.Value)); } } catch (Exception e) { Console.WriteLine("GameXml.Initialize. Error {0}", e); } } if (variants && game.Variants[current.Variant].Question != null) { question = CatalogGetString(game.Variants[current.Variant].Question); } else { question = CatalogGetString(game.Question); } if (variants && game.Variants[current.Variant].AnswerText != null) { answer = CatalogGetString(game.Variants[current.Variant].AnswerText); } else { answer = CatalogGetString(game.AnswerText); } if (variants && game.Variants[current.Variant].Rationale != null) { rationale = CatalogGetString(game.Variants[current.Variant].Rationale); } else { rationale = CatalogGetString(game.Rationale); } if (variants && game.Variants[current.Variant].AnswerShow != null) { answer_show = CatalogGetString(game.Variants[current.Variant].AnswerShow); } else { answer_show = CatalogGetString(game.AnswerShow); } if (String.IsNullOrEmpty(variables) == false) { question = ReplaceVariables(question); rationale = ReplaceVariables(rationale); answer = ReplaceVariables(answer); answer_show = ReplaceVariables(answer_show); } int option_answer = xml_drawing.GetOptionCorrectAnswerIndex(); if (option_answer != -1) { Answer.SetMultiOptionAnswer(option_answer, answer); // Translators {0}: list of options (A, B, C) string answers = String.Format(Translations.GetString("Answer {0}."), Answer.GetMultiOptionsPossibleAnswers(xml_drawing.Options.Count)); question = question.Replace(option_answers, answers); } else { Answer.Correct = answer; } SetCheckExpression(); SetAnswerCorrectShow(); }