private void RefreshPrevious() { if (DataManager.Evaluation.Data == null || DataManager.Plan.Data == null) { return; } SetActiveView(mPreviousView); // Create an array of all represented months in our data DateTime[] months = CreateCompletedMonthList(); for (int i = 0; i < months.Length; i++) { DateTime currentMonth = months[i]; // Add month header string formatedMonth = currentMonth.ToString("MMMM yyyy", mLanguageInfo).ToUpper(); string monthBarTitle = TextManager.Get(mCompletedTag) + " " + formatedMonth; Add(mHeaderPreviousPrefab).SetTitle(monthBarTitle); // Find the evaluation for this month and add it for (int j = 0; j < DataManager.Evaluation.Done.Length; j++) { DataEvaluation evaluation = DataManager.Evaluation.Done[j]; DateTime date = evaluation.CreatedAt.Value; if (date.Year == currentMonth.Year && date.Month == currentMonth.Month) { Add(mCheckPrefab).SetData(evaluation, mLanguageInfo); } } // Find the goals for this month and add them for (int j = 0; j < DataManager.Plan.CompletedGoals.Length; j++) { DataGoal goal = DataManager.Plan.CompletedGoals[j]; DateTime date = goal.FinishedAt.Value; if (date.Year == currentMonth.Year && date.Month == currentMonth.Month) { MonthlyGoal created = Add(mGoalPrefab); created.SetData(goal); if (mToFocus != null && goal.ID == mToFocus.ID) { mFocusGoal = created; mFocusIsOngoing = false; } } } } }
public void SetData(DataGoal data) { mTitle.text = data.Name; string bodyText = data.Description; if (data.EndAt.HasValue) { bodyText = "<b>Måldatum: " + data.EndAt.Value.ToString("yyyy-MM-dd") + "</b>\n" + bodyText; } mBody.text = bodyText; }
public override void RefreshUI() { mEnteredWithFocus = mToFocus != null; if (!mEnteredWithFocus) { UIHeader.Show(mHeaderTag); } else { UIHeader.Show(mHeaderTag, () => UIManager.Open(UILocation.Progress)); } RefreshContent(); if (mEnteredWithFocus) { mNavigation.SetPage(mFocusIsOngoing ? 0 : 1); if (mFocusIsOngoing) { LayoutRebuilder.ForceRebuildLayoutImmediate(mCurrentView); Vector2 position = mCurrentView.anchoredPosition; position.y = -mFocusGoal.GetComponent <RectTransform>().anchoredPosition.y; mCurrentView.anchoredPosition = position; } else { LayoutRebuilder.ForceRebuildLayoutImmediate(mPreviousView); Vector2 position = mPreviousView.anchoredPosition; position.y = -mFocusGoal.GetComponent <RectTransform>().anchoredPosition.y; mPreviousView.anchoredPosition = position; //Debug.Log("Move to wanted position. " + position.y); } mFocusGoal.Flash(); mFocusGoal = null; mToFocus = null; } }
public void Initialize(DataGoal goal) { Goal = goal; if (mNotDoneMesh != null && mDoneMesh != null) { mMeshFilter.sharedMesh = Goal.IsDone ? mDoneMesh : mNotDoneMesh; mOutlineMeshFilter.sharedMesh = mMeshFilter.sharedMesh; } SetParticles(Goal.IsDone); mOutlineMaterials = mOutline.materials; mOutlineValue = 0; UpdateColor(0); mOutline.enabled = false; mYPosition = transform.position.y; mPulseOffset = UnityEngine.Random.value; }
private void HandleGoalClick(DataGoal goal) { if (goal is DataAssignment) { DataAssignment assignment = goal as DataAssignment; if (assignment.IsSubmitted) { ScreenInspectAssignmentDone.Open(assignment, true); } else { ScreenInspectAssignment.Open(assignment, true); } } else { ScreenMonthlyCheck.Open(goal); } }
protected override void HandleData() { List <DataGoal> ongoing = new List <DataGoal>(); List <DataGoal> completed = new List <DataGoal>(); for (int i = 0; i < Data[0].Goals.Length; i++) { DataGoal goal = Data[0].Goals[i]; if (goal.IsDone) { completed.Add(goal); } else { ongoing.Add(goal); } } OngoingGoals = ongoing.ToArray(); CompletedGoals = completed.ToArray(); }
private void RefreshCurrent() { if (DataManager.Evaluation.Data == null || DataManager.Plan.Data == null) { return; } SetActiveView(mCurrentView); Add(mHeaderCurrentPrefab).SetTitle(TextManager.Get(mLatestCheckTag)); if (DataManager.Evaluation.Done.Length > 0) { Add(mCheckPrefab).SetData(DataManager.Evaluation.Done[0], mLanguageInfo); } int remainingGoalCount = DataManager.Plan.OngoingGoals.Length; if (remainingGoalCount > 0) { Add(mHeaderCurrentPrefab).SetTitle(TextManager.Get(mRemainingGoalsTag) + " (" + remainingGoalCount + ")"); for (int i = 0; i < DataManager.Plan.OngoingGoals.Length; i++) { DataGoal goal = DataManager.Plan.OngoingGoals[i]; MonthlyGoal created = Add(mGoalPrefab); created.SetData(goal); if (mToFocus != null && goal.ID == mToFocus.ID) { mFocusGoal = created; mFocusIsOngoing = true; } } } }
private void FillPlant() { mParts.Clear(); // Create a list with all assignments and goals List <DataGoal> entryData = new List <DataGoal>(DataManager.Assignment.Data); // Only show goals which are completed or which have an end date less than a week away TimeSpan showGoalRange = TimeSpan.FromDays(7); for (int i = 0; i < DataManager.Plan.Data[0].Goals.Length; i++) { DataGoal goal = DataManager.Plan.Data[0].Goals[i]; if (goal.IsDone || goal.EndAt.Value - DateTime.Now < showGoalRange) { entryData.Add(goal); } } //entryData.AddRange(DataManager.Plan.Data[0].Goals); // Sort based on creation date for assignments and projected end dates for goals entryData.Sort((a, b) => { DateTime aDate = (a is DataAssignment) ? a.CreatedAt.Value : a.EndAt.Value; DateTime bDate = (b is DataAssignment) ? b.CreatedAt.Value : b.EndAt.Value; return(aDate.CompareTo(bDate)); }); // Create a plant component for each entry for (int i = 0; i < entryData.Count; i++) { if (!mCurrentStem.HasOpenPoints) { CreateStem(); } Transform chosenPoint = mCurrentStem.GetPoint(mRandom.Next()); PlantClickable prefab; int random = mRandom.Next(); if (entryData[i] is DataAssignment) { // Assignment if (entryData[i].IsPastDeadline) { prefab = mWitheredLeafPrefab; } else if (entryData[i].IsDone) { prefab = mLeafPrefabs[random % mLeafPrefabs.Length]; } else { prefab = mBudPrefab; } } else { // Goal prefab = mFlowerPrefabs[Mathf.Clamp(entryData[i].Category.ID - 1, 0, mFlowerPrefabs.Length)]; } PlantClickable clickable = Instantiate(prefab, chosenPoint); Transform createdTransform = clickable.transform; createdTransform.localPosition = Vector3.zero; createdTransform.localRotation = Quaternion.Euler(0, 90f, 0); clickable.Initialize(entryData[i]); //created.localScale = Vector3.one; mParts.Add(clickable); } }
public static void Open(DataGoal toFocus) { mToFocus = toFocus; UIManager.Open(UILocation.MonthlyCheck); }