Beispiel #1
0
        private void SaveWorld()
        {
            _world.CompressedData = _compressionService.CompressWorld(_world);
            _worldService.SaveWorld(_world);

            AlertWindow.Alert(_world.Name + " has been saved!");
        }
Beispiel #2
0
        private void _ProjectPanel_RomSaved()
        {
            if (_config.LastRomPath == null || !File.Exists(_config.LastRomPath) || (Keyboard.Modifiers == ModifierKeys.Control))
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    _config.LastRomPath = openFileDialog.FileName;
                }
            }

            if (_config.LastRomPath != null)
            {
                try
                {
                    _romService.CompileRom(_config.LastRomPath);

                    if (_errorService.CurrentLog.Count > 0)
                    {
                        AlertWindow.Alert("Rom compiled but with the following errors: " + string.Join("\n-", _errorService.CurrentLog));
                    }
                    else
                    {
                        AlertWindow.Alert("Rom compiled!");
                    }

                    SaveConfiguration();
                }
                catch (Exception e)
                {
                    AlertWindow.Alert("Error occurred when attempting to compile rom. \nException:\n" + e.Message);
                }
            }
        }
Beispiel #3
0
        public static void Alert(string text)
        {
            AlertWindow window = new AlertWindow();

            window.DisplayText.Text      = text;
            window.Owner                 = GlobalPanels.MainWindow;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
Beispiel #4
0
        private void Rename_Click(object sender, RoutedEventArgs e)
        {
            if (WorldTree.SelectedItem != null)
            {
                object dataContext = ((TreeViewItem)WorldTree.SelectedItem).DataContext;

                if (dataContext is LevelInfo)
                {
                    LevelInfo levelInfo    = dataContext as LevelInfo;
                    string    previousName = levelInfo.Name;

                    string newName = InputWindow.GetInput("Rename level", levelInfo.Name);
                    if (newName != null)
                    {
                        LevelInfo existingInfo = _levelService.AllLevels().Where(l => l.Name.Equals(newName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (existingInfo == null)
                        {
                            _levelService.RenameLevel(levelInfo.Name, newName);
                            levelInfo.Name = newName;

                            _levelService.NotifyUpdate(levelInfo);
                            NameUpdated(new NameUpdate((IInfo)levelInfo, previousName, levelInfo.Name));
                            ((TreeViewItem)WorldTree.SelectedItem).Header = levelInfo.Name;
                        }
                        else
                        {
                            AlertWindow.Alert(newName + " already exists!");
                        }
                    }
                }
                else if (dataContext is WorldInfo)
                {
                    WorldInfo worldInfo    = dataContext as WorldInfo;
                    string    previousName = worldInfo.Name;

                    string newName = InputWindow.GetInput("Rename map", worldInfo.Name);
                    if (newName != null)
                    {
                        WorldInfo existingInfo = _worldService.AllWorlds().Where(w => w.Name.Equals(newName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (existingInfo == null)
                        {
                            _worldService.RenameWorld(worldInfo.Name, newName);
                            worldInfo.Name = newName;

                            NameUpdated(new NameUpdate((IInfo)worldInfo, previousName, worldInfo.Name));
                            ((TreeViewItem)WorldTree.SelectedItem).Header = worldInfo.Name;
                        }
                        else
                        {
                            AlertWindow.Alert(newName + " already exists!");
                        }
                    }
                }
            }
        }
 private void LoadPalette_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         OpenFileDialog openFileDialog = new OpenFileDialog();
         if (openFileDialog.ShowDialog() == true)
         {
             byte[] rgbBytes = File.ReadAllBytes(openFileDialog.FileName);
             for (int i = 0; i < 0x40; i++)
             {
                 int byteIndex    = i * 3;
                 int paletteIndex = i;
                 _rgbEditors[i].RgbColor = System.Drawing.Color.FromArgb(rgbBytes[byteIndex], rgbBytes[byteIndex + 1], rgbBytes[byteIndex + 2]);
             }
         }
     }
     catch (Exception ex)
     {
         AlertWindow.Alert("Error loading new palette: " + ex.Message);
     }
 }
 private void SaveProjectButton_Click(object sender, RoutedEventArgs e)
 {
     ProjectService.SaveProject();
     AlertWindow.Alert("Project saved.");
 }