private void openFileDialog2_FileOk(object sender, CancelEventArgs e) { creationGame.close(); BinaryFormatter bf = new BinaryFormatter(); FileStream f = new FileStream(openFileDialog2.FileName, FileMode.Open); List <Object> ents = (List <Object>)bf.Deserialize(f); float levelWidth = ( float )ents[0]; float levelHeight = ( float )ents[1]; changeMainPanelSize(( int )levelWidth, ( int )levelHeight); creationGame = new CreationGame(pnlMain.CreateGraphics(), ( int )levelWidth, ( int )levelHeight); creationGame.getCurrentLevel().vars.editForm = this; //if (!sysManagerInit) sysManager = new SystemManager(this); //sysManagerInit = true; for (int i = 2; i < ents.Count; i++) { Entity ent = ( Entity )ents[i]; ent.level = creationGame.getCurrentLevel(); creationGame.getCurrentLevel().addEntity(ent.randId, ent); } }
private void FormEditor_Load(object sender, EventArgs e) { Type type = typeof(Entity); foreach (Type t in this.GetType().Assembly.GetTypes()) { if (type.IsAssignableFrom(t) && type != t && t != typeof(EntityTemplate) && t != typeof(ProtoEntity)) { EntityListItem i = new EntityListItem(t); lstEntities.Items.Add(i); } } //Add key handlers to the main panel (pnlMain as Control).KeyPress += new KeyPressEventHandler(panelKeyPressEventHandler); (pnlMain as Control).KeyDown += new KeyEventHandler(panelKeyDownEventHandler); (pnlMain as Control).KeyUp += new KeyEventHandler(panelKeyUpEventHandler); (pnlMain as Control).MouseMove += new MouseEventHandler(MouseMoveHandler); (pnlMain as Control).MouseLeave += new EventHandler(MouseLeaveHandler); pnlMainContainer.AutoScroll = true; changeMainPanelSize(pnlMainContainer.Width, pnlMainContainer.Height); creationGame = new CreationGame(pnlMain.CreateGraphics(), pnlMain.Width, pnlMain.Height); creationGame.getCurrentLevel().vars.editForm = this; }
private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { creationGame.close(); Size s = Bitmap.FromFile(openFileDialog1.FileName).Size; changeMainPanelSize(( int )(s.Width * GlobalVars.LEVEL_READER_TILE_WIDTH), ( int )(s.Height * GlobalVars.LEVEL_READER_TILE_HEIGHT)); creationGame = new CreationGame(pnlMain.CreateGraphics(), ( int )(s.Width * GlobalVars.LEVEL_READER_TILE_WIDTH), ( int )(s.Height * GlobalVars.LEVEL_READER_TILE_HEIGHT), openFileDialog1.FileName); creationGame.getCurrentLevel().vars.editForm = this; btnLoadFromPaint.Enabled = false; }