Exemplo n.º 1
0
 private void btnChangePath_Click(object sender, EventArgs e)
 {
     if (dlgFolder.ShowDialog() == CommonFileDialogResult.Ok)
     {
         DataDirectory.SaveFile("Path", dlgFolder.FileName);
         WorkingDirectory.Path = dlgFolder.FileName;
         // Create directories
         DataDirectory.CreateDirectory("Images");
         DataDirectory.CreateDirectory(@"Images\Tilesets");
         DataDirectory.CreateDirectory(@"Images\Portraits");
         WorkingDirectory.CreateDirectory("Images");
         WorkingDirectory.CreateDirectory(@"Images\ClassMapSprites");
         WorkingDirectory.CreateDirectory(@"Images\ClassBattleAnimations");
     }
 }
Exemplo n.º 2
0
        // TBA - battle backgrounds

        public void LoadImages(FilesController workingDirectory)
        {
            workingDirectory.CreateDirectory(@"Images\Tilesets\" + Name);
            workingDirectory.CreateDirectory(@"Images\BattleBackgrounds\" + Name);
            for (int i = 0; i < Tiles.Count; i++)
            {
                Tiles[i].Image = Tiles[i].Image ??
                                 PalettedImage.FromFile(workingDirectory, @"Tilesets\" + Name + @"\" + i);
            }
            for (int i = 0; i < BattleBackgrounds.Count; i++)
            {
                BattleBackgrounds[i].Layer1 = BattleBackgrounds[i].Layer1 ??
                                              PartialPalettedImage.FromFile(workingDirectory, @"BattleBackgrounds\" + Name + @"\" + BattleBackgrounds[i].Name + "1");
                BattleBackgrounds[i].Layer2 = BattleBackgrounds[i].Layer2 ??
                                              PartialPalettedImage.FromFile(workingDirectory, @"BattleBackgrounds\" + Name + @"\" + BattleBackgrounds[i].Name + "2");
            }
        }
Exemplo n.º 3
0
 public void LoadImages(FilesController workingDirectory)
 {
     workingDirectory.CreateDirectory(@"Images\CGs\" + Name);
     BGImage1 = BGImage1 ?? PartialPalettedImage.FromFile(workingDirectory, @"CGs\" + Name + @"\BG1");
     BGImage2 = BGImage2 ?? PartialPalettedImage.FromFile(workingDirectory, @"CGs\" + Name + @"\BG2");
     FGImage1 = FGImage1 ?? PartialPalettedImage.FromFile(workingDirectory, @"CGs\" + Name + @"\FG1");
     FGImage2 = FGImage2 ?? PartialPalettedImage.FromFile(workingDirectory, @"CGs\" + Name + @"\FG2");
 }
Exemplo n.º 4
0
 private void frmConversationEditor_Load(object sender, EventArgs e)
 {
     // Find line width
     txtText.Text   = new string('-', CHARS_IN_LINE);
     FirstLineWidth = txtText.GetPositionFromCharIndex(txtText.Text.LastIndexOf('-')).X;
     // Find directory
     CurrentDirectory = new FilesController();
     CurrentDirectory.DefultFileFormat = ".txt";
     CurrentDirectory.Path             = WorkingDirectory.Path;
     CurrentDirectory.CreateDirectory("Conversations", true);
     flbFileBrowser.Directory        = CurrentDirectory;
     flbFileBrowser.TopMostDirectory = CurrentDirectory.Path;
     flbFileBrowser.OnFileSelected   = LoadFile;
     flbFileBrowser.UpdateList();
     // Init stuff
     copConversationPlayer.Init(WorkingDirectory, CHARS_IN_LINE, SetPreviewMode);
     txtText.Init(DataDirectory, this);
     this.ApplyPreferences(false);
     if (Preferences.Current.ZoomAmount > 1)
     {
         flbFileBrowser.ApplyPreferences();
         // Save anchors, move
         Dictionary <Control, AnchorStyles> anchors = new Dictionary <Control, AnchorStyles>();
         foreach (Control control in Controls)
         {
             if (control != flbFileBrowser)
             {
                 anchors.Add(control, control.Anchor);
                 control.Left  += flbFileBrowser.Width;
                 control.Anchor = AnchorStyles.Top | AnchorStyles.Left;
             }
         }
         // Resize
         Width += flbFileBrowser.Width;
         // Restore anchors
         foreach (Control control in Controls)
         {
             if (control != flbFileBrowser)
             {
                 control.Anchor = anchors[control];
             }
         }
         flbFileBrowser.Width = (int)(flbFileBrowser.Width * Preferences.Current.ZoomAmount);
         Width  = (int)(Width * Preferences.Current.ZoomAmount);
         Height = (int)(Height * Preferences.Current.ZoomAmount);
         RecenterForm();
         // Maximize if too big
         if (Width > Screen.GetWorkingArea(this).Width || Height > Screen.GetWorkingArea(this).Height)
         {
             WindowState = FormWindowState.Maximized;
         }
     }
     // Load empty conversation
     btnNew_Click(sender, e);
 }
Exemplo n.º 5
0
        private void btnNewFolder_Click(object sender, EventArgs e)
        {
            string folderName = InputBox.Show("New folder", "Enter folder name:", this);

            if ((folderName ?? "") == "")
            {
                return;
            }
            CurrentDirectory.CreateDirectory(folderName);
            flbFileBrowser.UpdateList();
        }
Exemplo n.º 6
0
 public static void SelectVoice(string voice)
 {
     if (voice == "")
     {
         CurrentVoiceFolder = null;
     }
     else
     {
         CurrentVoiceFolder      = new FilesController();
         CurrentVoiceFolder.Path = VoicesFolder.Path;
         CurrentVoiceFolder.CreateDirectory(voice, true);
     }
 }
Exemplo n.º 7
0
        public async void Returns_NotFoundObjectResult_when_ParentDirectoryNotExistsOrNotBelongsToUser()
        {
            StatusCode <DirectoryOut> status      = new StatusCode <DirectoryOut>(StatusCodes.Status404NotFound);
            Mock <IFileService>       fileService = new Mock <IFileService>();

            fileService.Setup(_ => _.CreateDirectoryByUser(It.IsAny <DirectoryPost>(), It.IsAny <string>()))
            .Returns(Task.FromResult(status));

            string username = "******";

            FilesController filesController = new FilesController(fileService.Object, UserManagerHelper.GetUserManager(username));

            filesController.Authenticate(username);

            IActionResult result = await filesController.CreateDirectory(new DirectoryPost());

            Assert.IsType <NotFoundObjectResult>(result);
        }
Exemplo n.º 8
0
 private void btnProjectImport_Click(object sender, EventArgs e)
 {
     if (dlgProjectImport.ShowDialog(this) == DialogResult.OK)
     {
         FilesController tempProject = new FilesController();
         tempProject.Path = WorkingDirectory.Path.Substring(0, WorkingDirectory.Path.LastIndexOf(@"\"));
         tempProject.CreateDirectory("TempData", true);
         if (System.IO.Directory.Exists(tempProject.Path))
         {
             System.IO.Directory.Delete(tempProject.Path, true);
         }
         System.IO.Compression.ZipFile.ExtractToDirectory(dlgProjectImport.FileName, tempProject.Path);
         if (System.IO.Directory.Exists(WorkingDirectory.Path))
         {
             System.IO.Directory.Delete(WorkingDirectory.Path, true);
         }
         System.IO.Directory.Move(tempProject.Path, WorkingDirectory.Path);
         MessageBox.Show("Done!");
     }
 }
Exemplo n.º 9
0
 public void Navigate(string place)
 {
     if (place[0] == @"\"[0])
     {
         if (place == @"\..")
         {
             Directory.Path = Directory.Path.Substring(0, Directory.Path.LastIndexOf(Directory.Seperator));
         }
         else
         {
             Directory.CreateDirectory(place.Substring(1), true);
         }
         UpdateList();
     }
     else
     {
         OnFileSelected(lstFiles.SelectedItem.ToString());
         VoiceAssist.Say("Open");
     }
 }
Exemplo n.º 10
0
        public async void Returns_CreatedAtActionResult201()
        {
            StatusCode <DirectoryOut> status = new StatusCode <DirectoryOut>(StatusCodes.Status201Created, new DirectoryOut
            {
                ID = Guid.NewGuid()
            });
            Mock <IFileService> fileService = new Mock <IFileService>();

            fileService.Setup(_ => _.CreateDirectoryByUser(It.IsAny <DirectoryPost>(), It.IsAny <string>()))
            .Returns(Task.FromResult(status));

            string username = "******";

            FilesController filesController = new FilesController(fileService.Object, UserManagerHelper.GetUserManager(username));

            filesController.Authenticate(username);

            IActionResult result = await filesController.CreateDirectory(new DirectoryPost());

            Assert.IsType <CreatedAtActionResult>(result);
        }
Exemplo n.º 11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Find directory
            CurrentDirectory      = new FilesController();
            CurrentDirectory.Path = WorkingDirectory.Path;
            CurrentDirectory.CreateDirectory("Maps", true);
            // Load levels
            CurrentDirectory.DefultFileFormat = ".txt";
            flbFiles.Directory        = CurrentDirectory;
            flbFiles.TopMostDirectory = CurrentDirectory.Path;
            flbFiles.OnFileSelected   = LoadFile;
            flbFiles.ShowDirectories  = true;
            flbFiles.UpdateList();
            // Load tiles
            Tilesets = WorkingDirectory.LoadFile("Tilesets", "", ".json").JsonToObject <List <TilesetData> >();
            if (Tilesets.Count < 1)
            {
                Close();
                MessageBox.Show("You must have at least 1 tileset!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            cmbTileSets.Items.AddRange(Tilesets.ConvertAll(a => a.Name).ToArray());
            cmbTileSets.SelectedIndex = 0;
            SetTileSet(Tilesets[0]);
            // Load palettes
            CachedSpritePalettes   = Palette.GetLevelSpritePalettes(WorkingDirectory);
            nudLevelNumber.Maximum = CachedSpritePalettes.Count - 1;
            // End load files
            // Generate UI
            UpdatePreview();
            Tiles = new MapTile[Size.X, Size.Y];
            int i;

            for (i = 0; i < Tiles.GetLength(0); i++)
            {
                for (int j = 0; j < Tiles.GetLength(1); j++)
                {
                    Tiles[i, j]     = new MapTile();
                    Tiles[i, j].Pos = new Point(i, j);
                }
            }
            Renderers = new PictureBox[Size.X, Size.Y];
            for (i = 0; i < Size.X; i++)
            {
                for (int j = 0; j < Size.Y; j++)
                {
                    PictureBox pictureBox = new PictureBox();
                    pictureBox.Width      = 16;
                    pictureBox.Height     = 16;
                    pictureBox.Left       = 16 * i;
                    pictureBox.Top        = 16 * j;
                    pictureBox.MouseMove += TileMouseMove;
                    pictureBox.MouseDown += TileMouseMove;
                    pictureBox.Capture    = false;
                    //pictureBox.BackgroundImageLayout = ImageLayout.Stretch; // Why was this even here?
                    pnlRenderer.Controls.Add(pictureBox);
                    Renderers[i, j] = pictureBox;
                }
            }
            Render();
            cmbAIType.SelectedIndex   = 0;
            cmbUnitTeam.SelectedIndex = 0;
            // Set dirty
            rdbDefeatBoss.CheckedChanged += DirtyFunc;
            rdbEscape.CheckedChanged     += DirtyFunc;
            rdbRout.CheckedChanged       += DirtyFunc;
            rdbSurvive.CheckedChanged    += DirtyFunc;
            txtLevelName.TextChanged     += DirtyFunc;
            nudLevelNumber.ValueChanged  += DirtyFunc;
            // Init stuff
            melMapEvents.Init(this, () => new MapEventData(), () => new UserControls.MapEventPanel(), (a) => a.Init(this, DataDirectory), false);
            this.ApplyPreferences();
            // Fix zoom mode - I don't know why it has so many bugs
            for (i = 0; i < Size.X; i++)
            {
                for (int j = 0; j < Size.Y; j++)
                {
                    Renderers[i, j].Height = Renderers[i, j].Width;
                    Renderers[i, j].Top    = Renderers[i, j].Height * j;
                }
            }
            pnlRenderer.Height = Renderers[0, 0].Height * Size.Y;
            picPreview.Top     = -1;
            picPreview.Height  = picPreview.Width;
            SetTileSet(Tilesets[0]);
        }
Exemplo n.º 12
0
 public void LoadImages(FilesController workingDirectory)
 {
     workingDirectory.CreateDirectory(@"Images\Portraits\" + Name);
     Background = Background ?? new PalettedImage(workingDirectory.LoadImage(@"Portraits\" + Name + @"\B") ?? new Bitmap(48, 48));
     Foreground = Foreground ?? new PalettedImage(workingDirectory.LoadImage(@"Portraits\" + Name + @"\F") ?? new Bitmap(48, 48));
 }