private void ProcessKey(Keys key) { LayoutListMania ll = stage.LayoutList; if (ll.Selected < 0) { ll.Insert(0); ll.Selected = 0; stage.CopyBindingToLayout(ll.Layout); } ManiaLayoutAccess access = cBindAlternateKeys.Checked ? ManiaLayoutAccess.AlternateKeys : ManiaLayoutAccess.Keys; ll.Layout[keys[currentBindingColumn].TagNumeric, access] = key; stage.RebindColumnKeys(); for (int i = 0; i < currentKeyConfig; i++) { if (keys[i] != null) { keys[i].Text = getKeyText(i); } } while (++currentBindingColumn < currentKeyConfig && keys[currentBindingColumn] == null) { } if (currentBindingColumn >= currentKeyConfig) { if (incrementKeyConfig(ref currentKeyConfig) > StageMania.MAX_COLUMNS) { currentKeyConfig = 1; } dKeyConfig.SetSelected(currentKeyConfig, false); } else { arrow.MoveToX(keys[currentBindingColumn].Position.X, 300, EasingTypes.Out); } }
internal void LoadKeys(bool setDefaultSplitStages = false) { currentBindingColumn = 0; spriteManager.SpriteList.FindAll(s => s.Tag == this).ForEach(s => { s.FadeOut(50); s.AlwaysDraw = false; spriteManager.Remove(s); }); disposeManiaStage(); SkinMania skin = SkinManager.LoadManiaSkin(currentKeyConfig); cSplitLayout.Enabled = currentKeyConfig > 1 && skin.SplitStagesFromSkin == null; if (!setDefaultSplitStages) { skin.SplitStages = cSplitLayout.Checked; } cSplitLayout.SetStatusQuietly(skin.SplitStages); dKeyConfig.SpriteMainBox.Text = getKeyOptionText(currentKeyConfig, skin.SplitStages); stage = new StageMania(skin, true); //Validate the layout by recopying it to itself stage.CopyBindingToLayout(stage.LayoutList.Layout); dSpecialStyle.Enabled = stage.AllowSpecialStyle; switch (stage.SpecialStyle) { case ManiaSpecialStyle.Left: dSpecialStyle.SetSelected(1, true); break; case ManiaSpecialStyle.Right: dSpecialStyle.SetSelected(2, true); break; default: dSpecialStyle.SetSelected(0, true); break; } cBindAlternateKeys.Enabled = stage.SpecialStyle != ManiaSpecialStyle.None; if (stage.SpecialStyle == ManiaSpecialStyle.None) { cBindAlternateKeys.SetStatusQuietly(false); } cJudgementLine.SetStatusQuietly(skin.JudgementLine); cUpsideDown.SetStatusQuietly(skin.UpsideDown); float delta = 40f; float separation = skin.SplitStages ? 1f : 0f; float totalWidth = (currentKeyConfig + separation) * delta; //Scale down if the keys are too wide to fit on the screen float scale = Math.Min(1f, GameBase.WindowManager.WidthScaled / totalWidth); totalWidth *= scale; delta *= scale; float start = (GameBase.WindowManager.WidthScaled - totalWidth) / 2; arrow = new pSprite(TextureManager.LoadFirstAvailable(new[] { @"arrow-generic", @"play-warningarrow" }, SkinSource.Osu), Fields.TopLeft, Origins.CentreLeft, Clocks.Game, new Vector2(0, 100), 0.92f, true, GameBase.NewGraphicsAvailable ? Color.SkyBlue : Color.White); arrow.Tag = this; arrow.Rotation = OsuMathHelper.PiOver2; spriteManager.Add(arrow); keys = new pText[currentKeyConfig]; int layoutIndex = 0; for (int i = 0; i < currentKeyConfig; i++) { bool skip = false; if (cBindAlternateKeys.Checked) { skip = true; foreach (StageMania s in stage) { if (i == s.Columns[s.SpecialColumn]) { skip = false; } } } if (!skip) { pSprite p = new pSprite(TextureManager.Load(@"mania-key1D", SkinSource.Osu), Fields.TopLeft, Origins.TopLeft, Clocks.Game, new Vector2(start, 192), 0.92f, true, stage.Columns[i].Colour); p.VectorScale = 1.3f * new Vector2(scale, 1f); p.Tag = this; spriteManager.Add(p); keys[i] = new pText(getKeyText(i), Math.Max(1, (int)Math.Round(14 * scale)), new Vector2(start + delta / 2f, 192 + 40), 0.93f, true, Color.White); keys[i].TextBorder = true; keys[i].Origin = Origins.Centre; keys[i].Tag = this; keys[i].TagNumeric = layoutIndex; spriteManager.Add(keys[i]); //Found the first non-skipped key if (layoutIndex++ == 0) { currentBindingColumn = i; arrow.Position.X = start + delta / 2; } } start += delta + delta * (i == stage.PrimaryStageColumns - 1 ? separation : 0); } }