예제 #1
0
		public override bool Convert(ConvertOperation convert)
		{
			List<object> results = new List<object>();
			List<Font> availData = convert.Perform<Font>().ToList();

			// Generate objects
			foreach (Font font in availData)
			{
				if (convert.IsObjectHandled(font)) continue;

				GameObject gameobj = convert.Result.OfType<GameObject>().FirstOrDefault();
				TextRenderer renderer = convert.Result.OfType<TextRenderer>().FirstOrDefault();
				if (renderer == null && gameobj != null) renderer = gameobj.GetComponent<TextRenderer>();
				if (renderer == null) renderer = new TextRenderer();
				convert.SuggestResultName(renderer, font.Name);
					
				if (!renderer.Text.Fonts.Contains(font))
				{
					var fonts = renderer.Text.Fonts.ToList();
					if (fonts[0] == Font.GenericMonospace10) fonts.RemoveAt(0);
					fonts.Add(font);
					renderer.Text.Fonts = fonts.ToArray();
					renderer.Text.ApplySource();
				}

				results.Add(renderer);
				convert.MarkObjectHandled(font);
			}

			convert.AddResult(results);
			return false;
		}
예제 #2
0
		void ICmpUpdatable.OnUpdate()
		{
			if (this.volumeText == null)
			{
				// still don't have it.. grab the TextRenderer
				this.volumeText = this.GameObj.GetComponent<TextRenderer>();
			}

			// update the volume value
			volumeText.Text.SourceText = String.Format("Volume {0:0.0}", DualityApp.UserData.SfxMasterVol);
		}
예제 #3
0
		public static void Init(TextRenderer targetText)
		{
			CommentGuy.targetText = targetText;
			CommentGuy.schedule = new List<Comment>();

			// Load permanent data, if existing
			if (permanentMind == null)
			{
				string mindPath = Path.Combine(Path.GetDirectoryName(DualityApp.UserDataPath), "mind.dat");
				if (File.Exists(mindPath))
				{
					try
					{
						using (FileStream stream = File.OpenRead(mindPath))
						{
							using (Formatter formatter = Formatter.Create(stream))
							{
								permanentMind = formatter.ReadObject() as PermanentData;
							}
						}
					}
					catch (Exception e)
					{
						Log.Game.WriteError("Error loading permanent data: {0}", Log.Exception(e));
					}
				}
			}

			// Create new permanent data, if not
			if (permanentMind == null) permanentMind = new PermanentData();
			if (temporaryMind == null) temporaryMind = new TemporaryData();
			
			// Only do once what is behind this line.
			if (initialized) return;
			initialized = true;

			DualityApp.Terminating += (s, e) => Terminate();
			temporaryMind.TimeSinceLastMet = DateTime.Now - permanentMind.TimeShutdown;
		}