// Start is called before the first frame update void Start() { Application.targetFrameRate = 45; _gridScroll = GetComponent <GridScroll>(); int PageNum = (stageLevels.Length % 5) == 0 ? 0 : 1; for (int i = 0; i < (stageLevels.Length / 5) + PageNum; ++i) { GameObject stageObject = Instantiate(prefabStageUI); StageScrollItem stage = stageObject.GetComponentInChildren <StageScrollItem>(); stageObject.transform.parent = trStageParent; stageObject.transform.localPosition = new Vector3(0f, 0f, 0f); _gridScroll.AddStageRectTransform(stage.transform); int index = 0; for (int j = i * 5; j < (i * 5) + 5; ++j) { if (stageLevels.Length > j) { stage.SetStageItem(index, stageLevels[j], j + 1); index++; } } stage.SetStageText(i * 5 + 1, ((i * 5) + index)); stageItemList.AddRange(stage.myStageList); } #if UNITY_EDITOR #else SetClearStage(); #endif }
private void ColumnsGrid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { double prefScaleFactor = InternalScaleFactor; double scaleFactor = e.DeltaManipulation.Scale.Y; if (scaleFactor != 1.0) { InternalScaleFactor *= scaleFactor; //System.Diagnostics.Debug.WriteLine("scale changed by {0:0.0000} to {1:0.##}", scaleFactor, InternalScaleFactor); } double newScaleFactor = InternalScaleFactor; //System.Diagnostics.Debug.WriteLine("scale changed by {2} to {0}, trandlation changed to {1}", InternalScaleFactor, e.DeltaManipulation.Translation.Y,factor); var wpfMo = ColumnsGrid.PointFromScreen(new Point(0.0, e.ManipulationOrigin.Y));//as manipulation origin is in screen coods double mo = wpfMo.Y; double startOffset = GridScroll.VerticalOffset; double shift = -e.DeltaManipulation.Translation.Y; //double startOffsetInScreen = ColumnsGrid.PointToScreen(new Point(0.0, GridScroll.VerticalOffset)).Y; //double endOffsetInScreen = startOffset/prefScaleFactor + shi; double endOffsetInWPF = scaleFactor * (startOffset + shift); //double newOffset1 = (startOffset-mo+shift)*scaleFactor + mo; //System.Diagnostics.Debug.WriteLine("screen mo is {0}; offset {1}l wpf mo is {2}",mo,startOffset, wpfMo.Y); GridScroll.ScrollToVerticalOffset(endOffsetInWPF); e.Handled = true; }
public DataGrid() { RowSpacing = 0; RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); RowDefinitions.Add(new RowDefinition { Height = GridLength.Star }); // Head Grid (1) headGrid = new GridHead(this); SetRow(headGrid, 0); Children.Add(headGrid); // Stack list (3) stackList = new StackList(this); // Body Grid (2) bodyGrid = new GridBody(this, stackList); bodyGrid.VerticalOptions = LayoutOptions.Start; // Scroll (1) mainScroll = new GridScroll(); SetRow(mainScroll, 1); mainScroll.Content = bodyGrid; this.Children.Add(mainScroll); // Abs bottom line absoluteBottom = new BoxView(); absoluteBottom.SetBinding(Grid.BackgroundColorProperty, new Binding(nameof(BorderColor), source: this)); absoluteBottom.SetBinding(Grid.HeightRequestProperty, new Binding(nameof(BorderWidth), source: this)); absoluteBottom.VerticalOptions = LayoutOptions.EndAndExpand; absoluteBottom.HorizontalOptions = LayoutOptions.FillAndExpand; absoluteBottom.TranslationY = BorderWidth * 0.1; SetRow(absoluteBottom, 1); this.Children.Add(absoluteBottom); mainScroll.SizeChanged += CheckWrapperBottomVisible; stackList.SizeChanged += CheckWrapperBottomVisible; }
private void updateRouteWindow(string[] routeLines, string saveFile) { DisplayGrid.Children.Clear(); DisplayGrid.RowDefinitions.Clear(); DisplayGrid.ColumnDefinitions.Clear(); DisplayGrid.ShowGridLines = true; DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(210) }); DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40) }); StringBuilder builder = new StringBuilder(); //Collectibles start on the 2nd block; int saveFileSuffix = 2; string filename = saveFile + saveFileSuffix; while (File.Exists(filename)) { builder.Append(System.IO.File.ReadAllText(filename)); saveFileSuffix++; filename = saveFile + saveFileSuffix; } string uncompressedSaveFile = builder.ToString(); int lineCount = 1; int firstNotDone = -1; int numDone = 0; for (int index = 0; index < routeLines.Length; index++) { if (index == 0) { continue; } string line = routeLines[index]; string[] lineComponents = line.Split('\t'); DisplayGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(ROW_HEIGHT) }); TextBlock txt0 = new TextBlock(); txt0.Text = lineComponents[0]; txt0.TextWrapping = TextWrapping.Wrap; Grid.SetColumn(txt0, 0); Grid.SetRow(txt0, lineCount - 1); DisplayGrid.Children.Add(txt0); string saveFileKey = lineComponents[2].Trim(); string alternateSaveFileKey = lineComponents[3].Trim(); bool markedDone = false; if (!String.IsNullOrEmpty(saveFileKey) && hasMatch(saveFileKey, alternateSaveFileKey, uncompressedSaveFile)) { TextBlock txt1 = new TextBlock(); txt1.Text = "Done"; Grid.SetColumn(txt1, 1); Grid.SetRow(txt1, lineCount - 1); DisplayGrid.Children.Add(txt1); markedDone = true; numDone++; } if (firstNotDone == -1 && !markedDone) { firstNotDone = lineCount; } lineCount++; } if (firstNotDone > -1) { double numInViewport = GridScroll.Height / ROW_HEIGHT; int scrollHeight = (firstNotDone - 4) * (ROW_HEIGHT); GridScroll.ScrollToVerticalOffset(scrollHeight); } //lineCount - 2 because the last row is "Done" double percentDone = 100.0 * numDone / (lineCount - 2); ProgressCounter.Text = String.Format("{0:0.0}", percentDone) + "%"; string overallBlock = System.IO.File.ReadAllText(saveFile + "1"); Regex rx = new Regex(@"\b\d*\/400|\d*\/440\b"); Match match = rx.Match(overallBlock); RiddleCounter.Text = match.ToString(); }
private void updateGrid(string savepath, string saveindex) { DisplayGrid.Children.Clear(); DisplayGrid.RowDefinitions.Clear(); DisplayGrid.ColumnDefinitions.Clear(); DisplayGrid.ShowGridLines = true; DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(200) }); DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40) }); String saveFileText = System.IO.File.ReadAllText(GetSaveFileFullPath(savepath, saveindex)); int firstNotDoneIndex = -1; int secondNotDoneIndex = -1; bool isNewGamePlus = NGPlusBox.IsChecked.Value; bool is120 = OneTwentyBox.IsChecked.Value; int minRequiredMatches = isNewGamePlus ? 1 : 0; int lineCount = 1; for (int index = 0; index < routeLines.Length; index++) { if (index == 0) { continue; } string line = routeLines[index]; string[] lineComponents = line.Split('\t'); if (isNewGamePlus && (isRiddlerCollectible(lineComponents[1]) || isUpgrade(lineComponents[1]) || isCornerCase(lineComponents[0]))) { continue; } if (!is120 && isSeasonOfInfamy(lineComponents[1])) { continue; } DisplayGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(ROW_HEIGHT) }); TextBlock txt0 = new TextBlock(); txt0.Text = lineComponents[0]; txt0.TextWrapping = TextWrapping.Wrap; Grid.SetColumn(txt0, 0); Grid.SetRow(txt0, lineCount - 1); DisplayGrid.Children.Add(txt0); string saveFileKey = lineComponents[2].Trim(); Regex rx = new Regex(@"\b" + saveFileKey + @"\b"); MatchCollection matches = rx.Matches(saveFileText); if (!String.IsNullOrEmpty(saveFileKey) && matches.Count > minRequiredMatches) { TextBlock txt1 = new TextBlock(); txt1.Text = "Done"; Grid.SetColumn(txt1, 1); Grid.SetRow(txt1, lineCount - 1); DisplayGrid.Children.Add(txt1); } else if (firstNotDoneIndex < 0) { firstNotDoneIndex = lineCount; } else if (secondNotDoneIndex < 0) { secondNotDoneIndex = lineCount; } lineCount++; } if (firstNotDoneIndex > -1 && IgnoreFirst.IsChecked.Value == false) { double numInViewport = GridScroll.Height / ROW_HEIGHT; int scrollHeight = (firstNotDoneIndex - 6) * (ROW_HEIGHT); GridScroll.ScrollToVerticalOffset(scrollHeight); } else if (secondNotDoneIndex > -1 && IgnoreFirst.IsChecked.Value == true) { double numInViewport = GridScroll.Height / ROW_HEIGHT; int scrollHeight = (secondNotDoneIndex - 6) * (ROW_HEIGHT); GridScroll.ScrollToVerticalOffset(scrollHeight); } }
private void updateWindow(string[] routeLines, string saveFile, string[] crimeInProgressLines) { DisplayGrid.Children.Clear(); DisplayGrid.RowDefinitions.Clear(); DisplayGrid.ColumnDefinitions.Clear(); DisplayGrid.ShowGridLines = true; DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(210) }); DisplayGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40) }); StringBuilder builder = new StringBuilder(); int saveFileSuffix = 2; string filename = saveFile + saveFileSuffix; while (File.Exists(filename)) { builder.Append(System.IO.File.ReadAllText(filename)); saveFileSuffix++; filename = saveFile + saveFileSuffix; } string uncompressedSaveFile = builder.ToString(); int lineCount = 1; int firstNotDone = -1; int numDone = 0; for (int index = 0; index < routeLines.Length; index++) { if (index == 0) { continue; } string line = routeLines[index]; string[] lineComponents = line.Split('\t'); DisplayGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(ROW_HEIGHT) }); TextBlock txt0 = new TextBlock(); txt0.Text = lineComponents[0]; txt0.TextWrapping = TextWrapping.Wrap; Grid.SetColumn(txt0, 0); Grid.SetRow(txt0, lineCount - 1); DisplayGrid.Children.Add(txt0); string type = lineComponents[1].Trim(); string saveFileKey = lineComponents[2].Trim(); string alternateSaveFileKey = lineComponents[3].Trim(); string metadata = lineComponents[4].Trim(); bool markedDone = false; if (!String.IsNullOrEmpty(saveFileKey) && (reverseCondition(type) ^ hasMatch(saveFileKey, alternateSaveFileKey, uncompressedSaveFile, metadata))) { TextBlock txt1 = new TextBlock(); txt1.Text = "Done"; Grid.SetColumn(txt1, 1); Grid.SetRow(txt1, lineCount - 1); DisplayGrid.Children.Add(txt1); markedDone = true; numDone++; } if (firstNotDone == -1 && !markedDone) { firstNotDone = lineCount; } lineCount++; } if (firstNotDone > -1) { double numInViewport = GridScroll.Height / ROW_HEIGHT; int scrollHeight = (firstNotDone - 4) * (ROW_HEIGHT); GridScroll.ScrollToVerticalOffset(scrollHeight); } CrimeInProgressGrid.Children.Clear(); CrimeInProgressGrid.RowDefinitions.Clear(); CrimeInProgressGrid.ColumnDefinitions.Clear(); CrimeInProgressGrid.ShowGridLines = true; CrimeInProgressGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(210) }); CrimeInProgressGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40) }); for (int index = 0; index < crimeInProgressLines.Length; index++) { if (index == 0) { continue; } string line = crimeInProgressLines[index]; string[] lineComponents = line.Split('\t'); CrimeInProgressGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(ROW_HEIGHT / 2) }); TextBlock txt0 = new TextBlock(); txt0.Text = lineComponents[0]; txt0.TextWrapping = TextWrapping.Wrap; Grid.SetColumn(txt0, 0); Grid.SetRow(txt0, index - 1); CrimeInProgressGrid.Children.Add(txt0); string saveFileKey = lineComponents[2].Trim(); if (!String.IsNullOrEmpty(saveFileKey) && (hasMatch(saveFileKey, "", uncompressedSaveFile, ""))) { TextBlock txt1 = new TextBlock(); txt1.Text = "Done"; Grid.SetColumn(txt1, 1); Grid.SetRow(txt1, index - 1); CrimeInProgressGrid.Children.Add(txt1); } } }