public override void Generate(int begin, int after) { int Label = EmitterNode.NewLabel(); _expression.Jumping(0, after); _node.EmitLabel(Label); _statement.Generate(Label, after); }
public override void Generate(int begin, int after) { int Label1 = EmitterNode.NewLabel(); int Label2 = EmitterNode.NewLabel(); _expression.Jumping(0, Label2); _node.EmitLabel(Label1); _statement1.Generate(Label1, after); _node.Emit($"goto L{after}"); _node.EmitLabel(Label2); _statement2.Generate(Label2, after); }
/// <summary> /// Called when the import effect menu item is clicked. /// </summary> /// <param name="sender">Object that caused this event to be triggered.</param> /// <param name="e">Arguments explaining why this event occured.</param> private void importEffectToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = Editor.GlobalInstance.EffectPath; dialog.Filter = "Effects files|*.fef"; dialog.Title = "Import effect"; dialog.RestoreDirectory = true; if (dialog.ShowDialog() == DialogResult.OK) { string file = dialog.FileName; if (file.ToLower().StartsWith(Editor.GlobalInstance.GamePath.ToLower() + "\\") == true) { file = file.Substring(Editor.GlobalInstance.GamePath.Length + 1); } if (file.ToLower().StartsWith(Editor.GlobalInstance.EffectPath.ToLower()) == false) { MessageBox.Show("Effect file must be within the effect directory or a sub directory of it.", "Relative Path Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Stream stream = StreamFactory.RequestStream(file, StreamMode.Open); BinaryReader reader = new BinaryReader(stream); if (reader.ReadByte() != 'F' || reader.ReadByte() != 'E' || reader.ReadByte() != 'F') { MessageBox.Show("Effect file has been corrupted, it could not be loaded.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } _emitterNode = new EmitterNode(); _emitterProperties.Emitter = _emitterNode; _emitterNode.Load(reader); reader.Close(); stream.Close(); SyncronizeTypes(); } }
/// <summary> /// Loads the next node in the given binary reader and returns it. /// </summary> /// <param name="reader">Binary reader to read node from.</param> /// <param name="getProgress">If set to true this node is used to judge the current progress.</param> /// <returns>Scene node that was loaded from the binary reader.</returns> private SceneNode LoadNode(BinaryReader reader, bool getProgress) { // Read in the name of this node's class. string name = reader.ReadString(); //HighPreformanceTimer timer = new HighPreformanceTimer(); // Create a new instance of this entity and tell it to load itself. // (See if its a known object first as its quicker to get it without reflection) SceneNode node = null; if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.entitynode")) { node = new EntityNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.scriptedentitynode")) { node = new ScriptedEntityNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.scenenode")) { node = new SceneNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.groupnode")) { node = new GroupNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.emitternode")) { node = new EmitterNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.tilemapsegmentnode")) { node = new TilemapSegmentNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.pathmarkernode")) { node = new PathMarkerNode(); } else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.tilenode")) { node = new TileNode(); } else { node = (SceneNode)ReflectionMethods.CreateObject(name); } //DebugLogger.WriteLog("Created scene graph node " + name + " in " + timer.DurationMillisecond + ".\n"); //timer.Restart(); // Load in this nodes details. node.UniqueID = (_uniqueIDTracker++); node.Load(reader); //DebugLogger.WriteLog("Loaded scene graph node " + name + " in " + timer.DurationMillisecond + ".\n"); // Read in all the children of this node, and attach // them to this node. DebugLogger.IncreaseIndent(); int childCount = reader.ReadInt32(); for (int i = 0; i < childCount; i++) { SceneNode childNode = LoadNode(reader); node.AddChild(childNode); if (getProgress == true) { _loadingProgress = (int)(((float)(i + 1) / (float)childCount) * 100.0f); } } DebugLogger.DecreaseIndent(); return(node); }
/// <summary> /// Called when the new effect button is clicked. /// </summary> /// <param name="sender">Object that caused this event to be triggered.</param> /// <param name="e">Arguments explaining why this event occured.</param> private void newEffectToolStripMenuItem_Click(object sender, EventArgs e) { _emitterNode = new EmitterNode(); SyncronizeTypes(); }