public void ViewProblemSelect(List <ProblemInstance> instances, ProblemSelectedHandler handler, int perRow = 6) { var selh = Game.Screen.Height / VRPGame.SCREEN_MARGIN_WIDHT_RATIO; // int perRow = Math.Max(1,instances.Count/MAX_ROWS); double btnSize = (Game.Screen.Width - SPACING_BETWEEN_BTNS * (perRow + 3)) / perRow; var vl = new VerticalLayout(); vl.Spacing = SPACING_BETWEEN_BTNS; Widget vgrid = new Widget(vl); for (int i = 0; i < MAX_ROWS && i * perRow < instances.Count; i++) { var hl = new HorizontalLayout(); hl.Spacing = SPACING_BETWEEN_BTNS; Widget hgrid = new Widget(hl); for (int j = i * perRow; j < (i + 1) * perRow && j < instances.Count; j++) { var probI = instances[j]; PushButton selectThisProblemBtn = VRPProblemSelector.CreateInstanceButton(btnSize, probI.ProblemName, probI.Stars, probI.Locked); if (!probI.Locked) { selectThisProblemBtn.Clicked += () => handler(probI); selectThisProblemBtn.Clicked += () => game.Remove(vgrid); } hgrid.Add(selectThisProblemBtn); } vgrid.Add(hgrid); } game.Add(vgrid, -1); }
int ShowNewPersonalBest(int new_k, double new_totd) { string text = ""; int stars = 0; if (new_k <= instance.BKS_k) { if (new_totd <= instance.BKS_val * 1.05) { stars = 3; text += "Erinomaisesti reititetty."; if (new_totd == instance.BKS_val) { text += " Itseasiassa löysit optimiratkaisun, eli parhaan mahdollisen reitityksen."; } } else if (new_totd <= instance.BKS_val * 1.20) { stars = 2; text += "Hyvin reititetty. Reittejä voi kuitenkin vielä parantaa. Keksitkö miten?"; } else { stars = 1; text += "Kelpo reititys. Pystytkö muokkaamaan reitit lyhyemmiksi?"; } } else if (new_k - 1 == instance.BKS_k) { if (new_totd < instance.BKS_val * 1.20) { stars = 2; text += "Hyvin reititetty. Kujetukset voisi vielä silti tehdä pienemmällä määrällä autoja. Keksitkö miten?"; } else { stars = 1; text += "Kelpo reititys. Pystyt varmasti kuitenkin parantamaan sitä!"; } } if (stars > 0) { Widget levelCompleteWindow = new Widget(Screen.Width / 4, Screen.Height / 3); levelCompleteWindow.Layout = new VerticalLayout(); var instanceButton = VRPProblemSelector.CreateInstanceButton(Screen.Width / 4, currentInstanceMetadata.ProblemName, stars); levelCompleteWindow.Add(instanceButton); var infotext = new Label(text); infotext.SizeMode = TextSizeMode.Wrapped; levelCompleteWindow.Add(infotext); Widget continueOrNext = new Widget(new HorizontalLayout()); var continueBtn = new PushButton("Jatka yrittämistä"); continueBtn.Clicked += () => Remove(levelCompleteWindow); continueOrNext.Add(continueBtn); var nextBtn = new PushButton("Seuraava tehtävä"); nextBtn.Clicked += () => ChooseNextLevel(); continueOrNext.Add(nextBtn); levelCompleteWindow.Add(continueOrNext); Add(levelCompleteWindow, -1); StarXplosion(1, stars, instanceButton); // emulate mb release Timer.SingleShot(0.1, () => MouseBtnGoesUp()); } return(stars); }