private void CloseTab_Click(object sender, RoutedEventArgs e) { TabItem tabItem = (TabItem)fsmTabs.SelectedItem; if (tabItem != null) { FsmDataInstance fsmInst = (FsmDataInstance)tabItem.Tag; tabItems.Remove(tabItem); loadedFsmDatas.Remove(fsmInst); fsmInst.canvasControls.Clear(); } }
private async void LoadFsm(string fileName) { await CreateAssetsManagerAndLoader(); List <AssetInfo> assetInfos = fsmLoader.LoadAllFSMsFromFile(fileName); FSMSelectionDialog selector = new FSMSelectionDialog(assetInfos); await selector.ShowDialog(this); long selectedId = selector.selectedID; if (selectedId == 0) { return; } fsmData = fsmLoader.LoadFSM(selectedId); loadedFsmDatas.Add(fsmData); TabItem newTabItem = new TabItem { Header = $"{fsmData.goName}-{fsmData.fsmName}", Tag = fsmData }; addingTabs = true; tabItems.Add(newTabItem); fsmTabs.SelectedIndex = tabItems.Count - 1; addingTabs = false; graphCanvas.Children.Clear(); fsmData.matrix = mt.Matrix; stateList.Children.Clear(); eventList.Children.Clear(); variableList.Children.Clear(); LoadStates(); LoadEvents(); LoadVariables(); }
public FsmNodeData(FsmDataInstance dataInst, FsmGlobalTransition transition) { isGlobal = true; FsmStateData toState = dataInst.states.FirstOrDefault(s => s.state.name == transition.toState); if (toState != null) { FsmNodeData toNode = toState.node; transform = new Rect(toNode.transform.X, toNode.transform.Y - 50, toNode.transform.Width, 18); } else { transform = new Rect(-100, -100, 100, 18); } stateColor = Constants.STATE_COLORS[transition.colorIndex]; transitionColor = Constants.TRANSITION_COLORS[transition.colorIndex]; name = transition.fsmEvent.name; transitions = new FsmTransition[1] { new FsmTransition(transition) }; }
private void FsmTabs_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!addingTabs) { graphCanvas.Children.Clear(); stateList.Children.Clear(); eventList.Children.Clear(); variableList.Children.Clear(); if (fsmTabs.SelectedItem != null) { var fsmDataInst = (FsmDataInstance)((TabItem)fsmTabs.SelectedItem).Tag; fsmData = fsmDataInst; mt.Matrix = fsmData.matrix; foreach (UINode uiNode in fsmData.nodes) { if (uiNode.Selected) { uiNode.Selected = false; uiNode.Selected = true; if (uiNode.stateData != null) { StateSidebarData(uiNode.stateData); } break; } } LoadStates(); LoadEvents(); LoadVariables(); } } }
public FsmDataInstance LoadFSM(long id) { AssetFileInfoEx info = curFile.table.GetAssetInfo(id); AssetTypeValueField baseField = am.GetMonoBaseFieldCached(curFile, info, Path.Combine(Path.GetDirectoryName(curFile.path), "Managed")); AssetNameResolver namer = new AssetNameResolver(am, curFile); FsmDataInstance dataInstance = new FsmDataInstance(); AssetTypeValueField fsm = baseField.Get("fsm"); AssetTypeValueField states = fsm.Get("states"); AssetTypeValueField events = fsm.Get("events"); AssetTypeValueField variables = fsm.Get("variables"); AssetTypeValueField globalTransitions = fsm.Get("globalTransitions"); AssetTypeValueField dataVersionField = fsm.Get("dataVersion"); dataInstance.fsmName = fsm.Get("name").GetValue().AsString(); AssetTypeInstance goAti = am.GetExtAsset(curFile, baseField.Get("m_GameObject")).instance; if (goAti != null) { string m_Name = goAti.GetBaseField().Get("m_Name").GetValue().AsString(); dataInstance.goName = m_Name; } if (dataVersionField.IsDummy()) { dataInstance.dataVersion = fsm.Get("version").GetValue().AsInt() + 1; } else { dataInstance.dataVersion = dataVersionField.GetValue().AsInt(); } dataInstance.states = new List <FsmStateData>(); for (int i = 0; i < states.GetChildrenCount(); i++) { FsmStateData stateData = new FsmStateData(); stateData.ActionData = new List <ActionScriptEntry>(); stateData.state = new FsmState(namer, states[i]); stateData.node = new FsmNodeData(stateData.state); GetActionData(stateData.ActionData, stateData.state.actionData, dataInstance.dataVersion); dataInstance.states.Add(stateData); } dataInstance.events = new List <FsmEventData>(); for (int i = 0; i < events.GetChildrenCount(); i++) { FsmEventData eventData = new FsmEventData(); eventData.Global = events[i].Get("isGlobal").GetValue().AsBool(); eventData.Name = events[i].Get("name").GetValue().AsString(); dataInstance.events.Add(eventData); } dataInstance.variables = new List <FsmVariableData>(); GetVariableValues(dataInstance.variables, namer, variables); dataInstance.globalTransitions = new List <FsmNodeData>(); for (int i = 0; i < globalTransitions.GetChildrenCount(); i++) { AssetTypeValueField globalTransitionField = globalTransitions[i]; FsmGlobalTransition globalTransition = new FsmGlobalTransition() { fsmEvent = new FsmEvent(globalTransitionField.Get("fsmEvent")), toState = globalTransitionField.Get("toState").GetValue().AsString(), linkStyle = globalTransitionField.Get("linkStyle").GetValue().AsInt(), linkConstraint = globalTransitionField.Get("linkConstraint").GetValue().AsInt(), colorIndex = (byte)globalTransitionField.Get("colorIndex").GetValue().AsInt() }; FsmNodeData node = new FsmNodeData(dataInstance, globalTransition); dataInstance.globalTransitions.Add(node); } //dataInstance.events = new List<FsmEventData>(); //for (int i = 0; i < events.GetChildrenCount(); i++) //{ // FsmEventData eventData = new FsmEventData(); // AssetTypeValueField evt = events[i]; // eventData.Name = evt.Get("name").GetValue().AsString(); // eventData.Global = evt.Get("isGlobal").GetValue().AsBool(); //} // //dataInstance.variables = new List<FsmVariableData>(); //for (int i = 0; i < variables.GetChildrenCount(); i++) //{ // FsmVariableData variableData = new FsmVariableData(); // AssetTypeValueField vars = events[i]; //} return(dataInstance); }