public Controller(ILevelDesignView view, IMapEditor model) { View = view; Model = model; MapChanged = new MapChangedHandler(setMap); View.MapChanged += MapChanged; }
/// <summary> /// Creates a new map with the selected value /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnGerar_Click(object sender, EventArgs e) { if (MapEditor != null) { ClearMap(); } int.TryParse(EixoX.Text, out int x); int.TryParse(EixoY.Text, out int y); int value = cbo_bioma.SelectedIndex == -1? 0 : cbo_bioma.SelectedIndex; x = x <= 0 ? 1 : x; y = y <= 0 ? 1 : y; EixoX.Text = $"{x}"; EixoY.Text = $"{y}"; if (x < 11 && y < 11) { MapEditor = new MapController(x, y, value); CreateTileControls(); } else { MessageBox.Show("Insert a value between 1 and 11"); } }
private void ModeMenu_Opening(object sender, CancelEventArgs e) { foreach (ToolStripMenuItem item in ModeMenu.Items) { IMapEditor editor = (IMapEditor)item.Tag; item.Checked = (editor == currentEditor); } }
private void Start() { _mapEditor = RealizationBox.Instance.MapEditor; _SearchAlgoritm = RealizationBox.Instance.SearchWayAlgorithm; _mapEditor.OnChangeStartPoint += ChangeStartItem; _mapEditor.OnChangeFinishPoint += ChangeFinishItem; }
public void RegisterEditor(IMapEditor editor, bool defaultEditor) { if (!editors.Contains(editor)) { editors.Add(editor); } if (defaultEditor || this.defaultEditor == null) { this.defaultEditor = editor; } }
private void ModeMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem == null) { return; } IMapEditor editor = (IMapEditor)e.ClickedItem.Tag; if (editor == null) { return; } Editor = editor; }
/// <summary> /// Remove all the tiles in the form and resets the IMapEditor class /// </summary> private void ClearMap() { if (MapEditor != null) { Tile[,] RemovedTiles = MapEditor.GetMap(); foreach (Tile item in RemovedTiles) { Controls.Remove(item); } MapEditor = null; } }
/// <summary> /// Import Click Event /// Remove all tiles and set to null the MapEditor /// After that, creates a new MapEditor with the default map in a .txt file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_imp_Click(object sender, EventArgs e) { ClearMap(); try { MapEditor = new MapController(FileManager.ImportMap()); } catch (Exception exc) { MapEditor = new MapController(5, 5, 1); MessageBox.Show("There is no map to be loaded"); } finally { CreateTileControls(); } }
public SimpleMapLoader(IMapEditor map, IServer server, IChunkFactory chunkFactory, IPlayer player, IChunkStorage chunkStorage) { if (map == null) { throw new ArgumentNullException("map"); } if (server == null) { throw new ArgumentNullException("server"); } if (chunkFactory == null) { throw new ArgumentNullException("chunkFactory"); } if (player == null) { throw new ArgumentNullException("player"); } _map = map; _server = server; _server.ClientConnection.ChunkReceived += ClientConnectionOnChunkReceived; _chunkFactory = chunkFactory; _player = player; _chunkStorage = chunkStorage; _chunkStorage.Retrieved += ChunkStorageOnRetrieved; _player.Moved += OnPlayerMoved; _oldPlayerChunkPosition = Chunk.ToChunkPosition(_player.Position.ToMapPosition()); foreach (var chunkPos in _map.Bounds) { if (!_map.IsChunkPresent(chunkPos)) { _server.ServerConnection.GetChunk(chunkPos); } } }
//==================================================================================================== // Constructor //==================================================================================================== public fMap(IController controller, Process process, Config config) { m_controller = controller; m_config = config; //Initialize form m_config.Suspend(); Editor = controller.Editors.Default; InitializeComponent(); InitializeLanguage(); //Add the supported editors to the mode list if (controller.Editors != null && controller.Editors.Count > 0) { //add supported editors to the mode selector foreach (IMapEditor editor in controller.Editors) { ToolStripItem item = new ToolStripMenuItem(editor.ToString()); item.Tag = editor; ModeMenu.Items.Add(item); } miModeMenu.Visible = true; } else { currentEditor = new MapNavigator(); miModeMenu.Visible = false; } //apply the configuration settings from the current profile ApplyConfig(); m_config.Resume(); //set the intial check state of the context menu toggles miOnTop.Checked = this.TopMost; miDraggable.Checked = this.Draggable; miResizable.Checked = this.Resizable; miClickThru.Checked = this.ClickThrough; //bind event handlers this.Paint += new PaintEventHandler(fMap_Paint); MapEngine.Updated += new GenericEvent(MapEngine_Updated); MapEngine.ClientRectangle = Bounds; MapMenu.Opening += new CancelEventHandler(MapMenu_Opening); miOnTop.CheckedChanged += new EventHandler(miOnTop_CheckedChanged); miDraggable.CheckedChanged += new EventHandler(miDraggable_CheckedChanged); miResizable.CheckedChanged += new EventHandler(miResizable_CheckedChanged); miClickThru.CheckedChanged += new EventHandler(miClickThru_CheckedChanged); //check the data path and inform the user if invalid bool dns = m_config.Get("DNS_MapPath", false); if(!dns && !Directory.Exists(MapEngine.Data.FilePath)) { int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappath_invalid_text"), MapEngine.Data.FilePath), Program.GetLang("msg_mappath_invalid_title"), new string[] { Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns); m_config["DNS_MapPath"] = dns; if(button == 0) { FolderBrowserDialog browse = new FolderBrowserDialog(); if(browse.ShowDialog(this) == DialogResult.OK) { MapEngine.Data.FilePath = browse.SelectedPath; m_config["MapPath"] = MapEngine.Data.FilePath; } } } //check the map pack path and inform the user if invalid dns = m_config.Get("DNS_MapPackPath", false); if(!dns && !File.Exists(MapPackPath + Program.MapIniFile)) { int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappack_invalid_text"), MapPackPath), Program.GetLang("msg_mappack_invalid_title"), new string[] { Program.GetLang("button_download"), Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns); m_config["DNS_MapPackPath"] = dns; if(button == 0) { System.Diagnostics.Process.Start(Program.ResGlobal.GetString("config_mappack_url")); MessageBox.Show(Program.GetLang("msg_pack_afterdownload_text"), Program.GetLang("msg_pack_afterdownload_title"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if(button == 1) { while(true) { FolderBrowserDialog browse = new FolderBrowserDialog(); if(browse.ShowDialog(this) == DialogResult.OK) { //if the user selected a path that does not contain the map.ini file then reject it and inform the user if(!File.Exists(browse.SelectedPath + "\\" + Program.MapIniFile)) { if(MessageBox.Show(string.Format(Program.GetLang("msg_mappack_badsel_text_alt"), browse.SelectedPath, Program.MapIniFile), Program.GetLang("msg_mappack_badsel_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) continue; break; } //lock the new map pack in MapPackPath = browse.SelectedPath; m_config["MapPackPath"] = MapPackPath; } break; } } } try { //initialize the game instance with the map engine m_game = controller.CreateInstance(process, this); if (m_game.Valid) { MapTimer.Tick += new EventHandler(MapTimer_Tick); MapTimer.Enabled = true; } } catch (InstanceException fex) { MessageBox.Show(fex.Message, "Unable to Initialize", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//==================================================================================================== // Constructor //==================================================================================================== public fMap(IController controller, Process process, Config config) { m_controller = controller; m_config = config; //Initialize form m_config.Suspend(); Editor = controller.Editors.Default; InitializeComponent(); InitializeLanguage(); //Add the supported editors to the mode list if (controller.Editors != null && controller.Editors.Count > 0) { //add supported editors to the mode selector foreach (IMapEditor editor in controller.Editors) { ToolStripItem item = new ToolStripMenuItem(editor.ToString()); item.Tag = editor; ModeMenu.Items.Add(item); } miModeMenu.Visible = true; } else { currentEditor = new MapNavigator(); miModeMenu.Visible = false; } //apply the configuration settings from the current profile ApplyConfig(); m_config.Resume(); //set the intial check state of the context menu toggles miOnTop.Checked = this.TopMost; miDraggable.Checked = this.Draggable; miResizable.Checked = this.Resizable; miClickThru.Checked = this.ClickThrough; //bind event handlers this.Paint += new PaintEventHandler(fMap_Paint); MapEngine.Updated += new GenericEvent(MapEngine_Updated); MapEngine.ClientRectangle = Bounds; MapMenu.Opening += new CancelEventHandler(MapMenu_Opening); miOnTop.CheckedChanged += new EventHandler(miOnTop_CheckedChanged); miDraggable.CheckedChanged += new EventHandler(miDraggable_CheckedChanged); miResizable.CheckedChanged += new EventHandler(miResizable_CheckedChanged); miClickThru.CheckedChanged += new EventHandler(miClickThru_CheckedChanged); //check the data path and inform the user if invalid bool dns = m_config.Get("DNS_MapPath", false); if (!dns && !Directory.Exists(MapEngine.Data.FilePath)) { int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappath_invalid_text"), MapEngine.Data.FilePath), Program.GetLang("msg_mappath_invalid_title"), new string[] { Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns); m_config["DNS_MapPath"] = dns; if (button == 0) { FolderBrowserDialog browse = new FolderBrowserDialog(); if (browse.ShowDialog(this) == DialogResult.OK) { MapEngine.Data.FilePath = browse.SelectedPath; m_config["MapPath"] = MapEngine.Data.FilePath; } } } //check the map pack path and inform the user if invalid dns = m_config.Get("DNS_MapPackPath", false); if (!dns && !File.Exists(MapPackPath + Program.MapIniFile)) { int button = MessageBoxEx.Show(string.Format(Program.GetLang("msg_mappack_invalid_text"), MapPackPath), Program.GetLang("msg_mappack_invalid_title"), new string[] { Program.GetLang("button_download"), Program.GetLang("button_browse"), Program.GetLang("button_ignore") }, MessageBoxIcon.Warning, out dns); m_config["DNS_MapPackPath"] = dns; if (button == 0) { System.Diagnostics.Process.Start(Program.ResGlobal.GetString("config_mappack_url")); MessageBox.Show(Program.GetLang("msg_pack_afterdownload_text"), Program.GetLang("msg_pack_afterdownload_title"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (button == 1) { while (true) { FolderBrowserDialog browse = new FolderBrowserDialog(); if (browse.ShowDialog(this) == DialogResult.OK) { //if the user selected a path that does not contain the map.ini file then reject it and inform the user if (!File.Exists(browse.SelectedPath + "\\" + Program.MapIniFile)) { if (MessageBox.Show(string.Format(Program.GetLang("msg_mappack_badsel_text_alt"), browse.SelectedPath, Program.MapIniFile), Program.GetLang("msg_mappack_badsel_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { continue; } break; } //lock the new map pack in MapPackPath = browse.SelectedPath; m_config["MapPackPath"] = MapPackPath; } break; } } } try { //initialize the game instance with the map engine m_game = controller.CreateInstance(process, this); if (m_game.Valid) { MapTimer.Tick += new EventHandler(MapTimer_Tick); MapTimer.Enabled = true; } } catch (InstanceException fex) { MessageBox.Show(fex.Message, "Unable to Initialize", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RegisterEditor(IMapEditor editor, bool defaultEditor) { if (!editors.Contains(editor)) editors.Add(editor); if (defaultEditor || this.defaultEditor == null) this.defaultEditor = editor; }
public void RegisterEditor(IMapEditor editor) { RegisterEditor(editor, false); }
public void RegisterEditor(IMapEditor editor) { RegisterEditor(editor, false); }