/// <summary> /// 初期化 /// </summary> public void Initialize() { isEndFlag = false; field = new LineField(device, this); field.Load("LineField.csv", "./csv/"); //フィールド元のファイルの読み込み field.Initialize(); score = new Score(); removeLineBoard = new RemoveLineBoard(); levelBoard = new LevelBoard(); }
// Use this for initialization protected override void Start() { textField_ = GetComponentInParent <LineField>(); verticalLine_ = GetComponentInChildren <UIGaugeRenderer>(includeInactive: true); onValueChanged.AsObservable().Subscribe(x => { Line line = textField_.BindedLine; bool isFolded = !isOn; if (line != null && line.IsFolded != isFolded) { line.Tree.OnFoldUpdated(line, isFolded); } }).AddTo(this); }
public override void OnUpdateSelected(BaseEventData eventData) { if (!isFocused || BindedLine == null || BindedLine.Tree == null) { return; } bool consumedEvent = false; int compositionBugCount = -1; Event popEvent = new Event(); List <Event> currentEvents = new List <Event>(); while (Event.PopEvent(popEvent)) { currentEvents.Add(new Event(popEvent)); } if (currentEvents.Find((Event e) => e.rawType == EventType.MouseDown) != null) { compositionBugCount = 0; foreach (Event maybeDuplicatedEvent in currentEvents) { if (maybeDuplicatedEvent.rawType == EventType.keyDown) { ++compositionBugCount; } } } foreach (Event processingEvent in currentEvents) { if (processingEvent.rawType == EventType.KeyDown) { consumedEvent = true; var currentEventModifiers = processingEvent.modifiers; bool ctrl = SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX ? (currentEventModifiers & EventModifiers.Command) != 0 : (currentEventModifiers & EventModifiers.Control) != 0; bool shift = (currentEventModifiers & EventModifiers.Shift) != 0; bool alt = (currentEventModifiers & EventModifiers.Alt) != 0; bool ctrlOnly = ctrl && !alt && !shift; cachedCaretPos_ = m_CaretSelectPosition; switch (processingEvent.keyCode) { case KeyCode.V: if (ctrlOnly) { // process in ownerTree } break; case KeyCode.Space: if (ctrlOnly) { // process in ownerTree } else { KeyPressed(processingEvent); } break; case KeyCode.C: case KeyCode.X: if (ctrlOnly && isSelected_) { // process in ownerTree } else { KeyPressed(processingEvent); } break; case KeyCode.Semicolon: if (ctrlOnly && BindedLine.Tree.HasSelection == false) { DateTime now = DateTime.Now; string oldText = text; BindedLine.Tree.ActionManager.Execute(new Action( execute: () => { Paste(now.ToString(GameContext.Config.TimeFormat)); }, undo: () => { text = oldText; } )); } break; case KeyCode.Colon: case KeyCode.Equals: //日本語キーボードだとこっちになってるらしい。どうしたものか。Configにするか。 if (ctrlOnly && BindedLine.Tree.HasSelection == false) { DateTime date = DateTime.Now; string oldText = text; BindedLine.Tree.ActionManager.Execute(new Action( execute: () => { Paste(date.ToString(GameContext.Config.DateFormat)); }, undo: () => { text = oldText; } )); } break; case KeyCode.Delete: { if (BindedLine.Tree.HasSelection) { // process in ownerTree } else { bool use = cachedCaretPos_ < text.Length; KeyPressed(processingEvent); if (use) { BindedLine.Tree.OnDeleteKeyConsumed(); } } } break; case KeyCode.Backspace: { if (BindedLine.Tree.HasSelection) { // process in ownerTree } else { KeyPressed(processingEvent); } } break; case KeyCode.DownArrow: { if (BindedLine.NextVisibleLine != null) { // process in ownerTree } else { KeyPressed(processingEvent); BindedLine.FixTextInputAction(); } } break; case KeyCode.UpArrow: { if (BindedLine.PrevVisibleLine != null) { // process in ownerTree } else { KeyPressed(processingEvent); BindedLine.FixTextInputAction(); } } break; case KeyCode.RightArrow: case KeyCode.LeftArrow: { KeyPressed(processingEvent); desiredCaretPos_ = m_CaretSelectPosition; BindedLine.FixTextInputAction(); if (GameContext.Window.TagIncrementalDialog.IsActive) { if (Line.GetTagInCaretPosition(BindedLine.Text, desiredCaretPos_) == null) { GameContext.Window.TagIncrementalDialog.Close(); } } } break; case KeyCode.Home: case KeyCode.End: { KeyPressed(processingEvent); desiredCaretPos_ = m_CaretSelectPosition; BindedLine.FixTextInputAction(); } break; default: if (ctrlOnly && processingEvent.keyCode == KeyCode.None && processingEvent.character.ToString() == " ") { // process in ownerTree } else if (ctrl == false && alt == false && processingEvent.keyCode == KeyCode.None && BindedLine.Tree.HasSelection && processingEvent.character.ToString() != Line.TabString) { LineField newField = BindedLine.Tree.DeleteSelection().Field; newField.KeyPressed(processingEvent); newField.CaretPosision = newField.text.Length; } else { if (compositionBugCount >= 0 && compositionBugCount % 2 == 0) { if (compositionBugCount == 0) { continue; } compositionBugCount -= 2; } KeyPressed(processingEvent); } break; } } } // ひらがな入力で、変換の最後の1文字だけ、BackspaceのKeyDownが来ない問題 bool compositionStringDeleted = (compositionString.Length > 0 && Input.compositionString.Length == 0); if (consumedEvent || compositionStringDeleted) { UpdateLabel(); } compositionString = Input.compositionString; eventData.Use(); }