コード例 #1
0
		public ScreenMap(ScreenController ctrl, UIObject obj)
		{
			this.ctrl = ctrl;
			this.activeObject = obj;
			if (this.activeObject != null) {
				this.activeObject.PropertyChanged += OnPropertyChanged;
			}
		}
コード例 #2
0
		public GameDetailScreen(GameController ctrl, UIObject obj)
		{
			this.ctrl = ctrl;
			this.activeObject = obj;
			if (this.activeObject != null) {
				this.activeObject.PropertyChanged += OnPropertyChanged;
			}

			_refresh = new CallDelayer(100, 500, (o) => Refresh(o));
		}
コード例 #3
0
		public ScreenDetail (ScreenController ctrl, UIObject obj) : base ()
		{
			this.ctrl = ctrl;
			this.activeObject = obj;

			// OS specific details
			if (new Version (UIDevice.CurrentDevice.SystemVersion) >= new Version(7,0)) 
			{
				// Code that uses features from Xamarin.iOS 7.0
				this.EdgesForExtendedLayout = UIRectEdge.None;
			}
		}
コード例 #4
0
ファイル: GameModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.DisplayChangedEventArgs"/> class.
		/// </summary>
		/// <param name="what">What changed.</param>
		/// <param name="obj">Object which changed.</param>
		/// <param name="property">Property which changed.</param>
		public DisplayChangedEventArgs(string what = null, UIObject obj = null, string property = null)
		{
			What = what;
			UIObject = obj;
			PropertyName = property;
		}
コード例 #5
0
ファイル: GameModel.cs プロジェクト: Surfoo/WF.Player
		/// <summary>
		/// Raises the display changed.
		/// </summary>
		/// <param name="what">What changed.</param>
		/// <param name="obj">Object that changed.</param>
		/// <param name="property">Property that changed.</param>
		private void RaiseDisplayChanged(string what, UIObject obj = null, string property = null)
		{
			if (this.engine == null || this.engine.GameState != EngineGameState.Playing)
			{
				return;
			}

			var handler = this.DisplayChanged;
			if (handler != null)
			{
				handler(this, new DisplayChangedEventArgs(what, obj, property));
			}
		}
コード例 #6
0
 /// <summary>
 /// Makes the app show the details of a thing.
 /// </summary>
 /// <param name="t"></param>
 private void ShowDetails(UIObject t)
 {
     // Navigates to the appropriate view.
     App.Current.ViewModel.NavigationManager.NavigateToView(t);
 }
コード例 #7
0
		/// <summary>
		/// Shows the screen.
		/// </summary>
		/// <param name="screen">Screen to show.</param>
		/// <param name="obj">Object to show if screen is ScreenType.Details.</param>
		public void ShowScreen(ScreenTypes screen, UIObject obj)
		{
			bool showBackButton = true;
			var bar = SupportActionBar;
			var ft = this.SupportFragmentManager.BeginTransaction ();
			var activeFragment = this.SupportFragmentManager.FindFragmentByTag("active");

			// If there is an active remove timer, stop it, because we bring the next screen onto the device
			if (removeTimer != null) {
				removeTimer.Stop();
				removeTimer = null;
			}

			// A new screen replaces a dialog screen, if there is one
			if (screenStack.Count > 0 && screenStack.Peek() is GameDialogScreen)
				screenStack.Pop();

			// A new screen replaces a screen of same type, if there is one
			if (screenStack.Count > 0 && ((screenStack.Peek() is GameDetailScreen && screen == ScreenTypes.Details) || ((screenStack.Peek() is GameMapScreen && screen == ScreenTypes.Map))))
				screenStack.Pop();

			switch (screen) 
			{
			case ScreenTypes.Main:
				// Clear stack, because main screen is always the first
				screenStack.Clear();
				// Push new main screen onto stack
				screenStack.Push(new GameMainScreen (engine));
				// Don't show back button on main screen
				showBackButton = false;
				// Set title for activity
				ft.SetBreadCrumbTitle (cartridge.Name);
				break;
			case ScreenTypes.Locations:
			case ScreenTypes.Items:
			case ScreenTypes.Inventory:
			case ScreenTypes.Tasks:
				// Clear stack, except main screen, which is always the first
				while(screenStack.Count > 1)
					screenStack.Pop();
				screenStack.Push(new GameListScreen (engine, screen));
				break;
			case ScreenTypes.Details:
				// Only push a new one, if it isn't the same
				if (!(screenStack.Peek() is GameDetailScreen) || !((GameDetailScreen)screenStack.Peek()).ActiveObject.Equals(obj))
					screenStack.Push(new GameDetailScreen (this, obj));
				break;
			case ScreenTypes.Map:
				// Only push a new one, if it isn't the same
				if (!(screenStack.Peek() is GameMapScreen) || !((GameMapScreen)screenStack.Peek()).ActiveObject.Equals(obj))
					screenStack.Push(new GameMapScreen (this, obj));
				break;
			}

			// Show icon as back button
			bar.SetDisplayHomeAsUpEnabled (showBackButton);

			// Bring topmost fragment to screen
			ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
			ft.Replace (Resource.Id.fragment, screenStack.Peek(), "active");
			ft.Commit ();

			// Save actuall values for later use
			if (screen != ScreenTypes.Dialog && screen != ScreenTypes.Map) {
				activeScreen = screen;
				activeObject = obj;
			}
		}
コード例 #8
0
 /// <summary>
 /// Makes the app show the details of a thing.
 /// </summary>
 /// <param name="t"></param>
 private void ShowDetails(UIObject t)
 {
     if (t.HasOnClick)
     {
         // Runs the on-click command.
         t.CallOnClick();
     }
     else
     {
         // Navigates to the appropriate view.
         App.Current.ViewModel.NavigationManager.NavigateToView(t); 
     }
 }
コード例 #9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.GameDetailViewModel"/> class.
		/// </summary>
		public GameDetailViewModel(UIObject activeObject = null)
		{
			this.geoMathHelper = new GeoMathHelper();
			this.activeObject = activeObject;

			Position = App.GPS.LastKnownPosition;
		}
コード例 #10
0
		/// <summary>
		/// Navigates the app to the view that best fits a UIObject object.
		/// </summary>
		/// <param name="wherigoObj"></param>
		public void NavigateToView(UIObject wherigoObj)
		{
			if (wherigoObj is Thing)
			{
				NavigateToView((Thing)wherigoObj);
			}
			else if (wherigoObj is Task)
			{
				NavigateToView((Task)wherigoObj);
			}
		}
コード例 #11
0
		public GameMapScreen(GameController ctrl, UIObject obj)
		{
			this.ctrl = ctrl;
			this.activeObject = obj;
		}
コード例 #12
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.GameMainCellViewModel"/> class.
		/// </summary>
		/// <param name="name">Name of uiobject.</param>
		/// <param name="color">Color of text.</param>
		/// <param name="uiObject">User interface object.</param>
		public GameMainCellViewModel(string name, Color color, UIObject uiObject)
		{
			this.color = color;
			this.uiObject = uiObject;
			this.uiObject.PropertyChanged += HandlePropertyChanged;
		}
コード例 #13
0
		/// <summary>
		/// Shows the screen.
		/// </summary>
		/// <param name="screen">Screen to show.</param>
		/// <param name="obj">Object to show if screen is ScreenType.Details.</param>
		public void ShowScreen(ScreenType screen, UIObject obj)
		{
			var bar = SupportActionBar;
			var ft = this.SupportFragmentManager.BeginTransaction ();
			var activeFragment = this.SupportFragmentManager.FindFragmentByTag("active");

			switch (screen) 
			{
				case ScreenType.Main:
					ft.SetBreadCrumbTitle (cartridge.Name);
					ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
					ft.Replace (Resource.Id.fragment, new ScreenMain (engine), "active");
					ft.Commit ();
				//					SupportFragmentManager.Fragments [0] = new ScreenMain (engine);
					break;
				case ScreenType.Locations:
				case ScreenType.Items:
				case ScreenType.Inventory:
				case ScreenType.Tasks:
					bar.SetDisplayHomeAsUpEnabled (true);
					ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
					ft.Replace (Resource.Id.fragment, new ScreenList (engine, screen), "active");
					ft.Commit ();
				//					SupportFragmentManager.Fragments [0] = new ScreenList (engine, screen);
					break;
				case ScreenType.Details:
					bar.SetDisplayHomeAsUpEnabled (true);
					ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
					ft.Replace (Resource.Id.fragment, new ScreenDetail (this, obj), "active");
					ft.Commit ();
				//					SupportFragmentManager.Fragments [0] = new ScreenDetail (this, obj);
					break;
				case ScreenType.Map:
					bar.SetDisplayHomeAsUpEnabled (true);
					ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
					ft.Replace (Resource.Id.fragment, new ScreenMap (this, obj), "active");
					ft.Commit ();
				//					SupportFragmentManager.Fragments [0] = new ScreenMap (this, obj);
					break;
			}

			// Save actuall values for later use
			if (screen != ScreenType.Dialog && screen != ScreenType.Map) {
				activeScreen = screen;
				activeObject = obj;
			}
		}
コード例 #14
0
		/// <summary>
		/// Removes the active screen and show screen before.
		/// </summary>
		/// <param name="last">Last screen active.</param>
		public void RemoveScreen(ScreenType type)
		{
			bool remove = true;
			ScreenType activeType = ActiveScreenType();

			// Check if screen to remove is active screen, instead leave
			if (type != null) {
				if (SupportFragmentManager.Fragments [0] is ScreenList)
					remove &= ((ScreenList)SupportFragmentManager.Fragments [0]).Type == type;
				if (SupportFragmentManager.Fragments [0] is ScreenDetail)
					remove &= type == ScreenType.Details;
				if (SupportFragmentManager.Fragments [0] is ScreenDialog)
					remove &= type == ScreenType.Dialog;
				if (SupportFragmentManager.Fragments [0] is ScreenMap)
					remove &= type == ScreenType.Map;
			}

			if (!remove)
				return;

			switch (activeType) {
				case ScreenType.Main:
					// Don't remove the main screen
					break;
				case ScreenType.Locations:
					ShowScreen (ScreenType.Main, null);
					break;
				case ScreenType.Items:
					ShowScreen (ScreenType.Main, null);
					break;
				case ScreenType.Inventory:
					ShowScreen (ScreenType.Main, null);
					break;
				case ScreenType.Tasks:
					ShowScreen (ScreenType.Main, null);
					break;
				case ScreenType.Details:
					// Show correct list for this zone/item/character/task
					if (((ScreenDetail)SupportFragmentManager.Fragments [0]).ActiveObject != null) {
						// Select the correct list to show
						UIObject obj = ((ScreenDetail)SupportFragmentManager.Fragments [0]).ActiveObject;
						activeObject = null;
						if (obj is Zone)
							ShowScreen (ScreenType.Locations, null);
						if (obj is Task)
							ShowScreen (ScreenType.Tasks, null);
						if (obj is Item || obj is Character) {
							if (engine.VisibleInventory.Contains ((Thing)obj))
								ShowScreen (ScreenType.Inventory, null);
							else
								ShowScreen (ScreenType.Items, null);
						}
					} else
						ShowScreen (ScreenType.Main, null);
					break;
				case ScreenType.Dialog:
				case ScreenType.Map:
					if (activeScreen == ScreenType.Details && activeObject != null && !activeObject.Visible) {
						// Object for detail screen is no longer visible, so show correct list
						// Select the correct list to show
						UIObject obj = activeObject;
						activeObject = null;
						if (obj is Zone)
							ShowScreen (ScreenType.Locations, null);
						if (obj is Task)
							ShowScreen (ScreenType.Tasks, null);
						if (obj is Item || obj is Character) {
							if (engine.VisibleInventory.Contains ((Thing)obj))
								ShowScreen (ScreenType.Inventory, null);
							else
								ShowScreen (ScreenType.Items, null);
						}
					} else {
						ShowScreen (activeScreen, activeObject);
					}
					break;
				}
		}
コード例 #15
0
		public void ShowScreen (ScreenType screenId, object param = null)
		{
			switch (screenId) {
			case ScreenType.Main:
				ViewControllers = new UIViewController[] { screenMain };
				break;
			case ScreenType.Locations:
				ViewControllers = new UIViewController[] { screenListLocations };
				break;
			case ScreenType.Items:
				ViewControllers = new UIViewController[] { screenListItems };
				break;
			case ScreenType.Inventory:
				ViewControllers = new UIViewController[] { screenListInventory };
				break;
			case ScreenType.Tasks:
				ViewControllers = new UIViewController[] { screenListTasks };
				break;
			case ScreenType.Details:
					// Is active ViewController is ScreenDetail
				if (!(VisibleViewController is ScreenDetail))
						// Active ViewController isn't ScreenDetail, so create a new one
						ViewControllers = new UIViewController[] { new ScreenDetail (this, (UIObject)param) };
				else
					((ScreenDetail)ViewControllers [0]).ActiveObject = (UIObject)param;
				break;
			case ScreenType.Dialog:
				if (param is MessageBoxEventArgs) {
					ViewControllers = new UIViewController[] { new ScreenDialog (((MessageBoxEventArgs)param).Descriptor) };
				}
				if (param is Input) {
					ViewControllers = new UIViewController[] { new ScreenDialog ((Input)param) };
				}
				break;
			case ScreenType.Map:
				ViewControllers = new UIViewController[] { new ScreenMap(this, (Thing)param) };
				break;
			}

			if (screenId != ScreenType.Dialog && screenId != ScreenType.Map) {
				activeScreen = screenId;
				activeObject = (UIObject)param;
			}
		}
コード例 #16
0
		public void RefreshCell (ScreenList owner, ScreenType screenType, Engine engine, UIObject obj)
		{
			if (imageIcon != null) 
			{
				if (obj.Icon == null)
					imageIcon.Image = null;
				else
				{
					imageIcon.Image = UIImage.LoadFromData (NSData.FromArray (obj.Icon.Data));
					imageIcon.ContentMode = UIViewContentMode.ScaleAspectFit;
				}
			}

			string name = obj.Name == null ? "" : obj.Name;

			if (screenType == ScreenType.Tasks) 
			{
				// If a task, than show CorrectState by character in front of name
				textTitle.Text = (((Task)obj).Complete ? (((Task)obj).CorrectState == TaskCorrectness.NotCorrect ? Strings.TaskNotCorrect : Strings.TaskCorrect) + " " : "") + name;
			}
			else
				textTitle.Text = name;

			if (HasDirection)
			{
				if (screenType != ScreenType.Tasks && screenType != ScreenType.Inventory) {
					if (obj is Zone && ((Zone)obj).State == PlayerZoneState.Inside) {
						imageDirection.Hidden = false;
						imageDirection.Image = drawCenter ();
						textDistance.Hidden = false;
						textDistance.Text = Catalog.GetString("Inside");
					} else {
						if ((obj is Item || obj is Character) && obj.ObjectLocation != null) {
							imageDirection.Hidden = true;
							textDistance.Hidden = true;
						} else {
							if (((Thing)obj).VectorFromPlayer != null) {
								imageDirection.Hidden = false;
								imageDirection.Image = drawArrow ((((Thing)obj).VectorFromPlayer.Bearing.GetValueOrDefault () + owner.Ctrl.LocatitionManager.Heading.TrueHeading) % 360); // * 180.0 / Math.PI);
								textDistance.Hidden = false;
								textDistance.Text = ((Thing)obj).VectorFromPlayer.Distance.BestMeasureAs (DistanceUnit.Meters);
							} else {
								imageDirection.Hidden = true;
								textDistance.Hidden = true;
							}
						}
					}
				} else {
					imageDirection.Hidden = true;
					textDistance.Hidden = true;
				}
			}
		}