Exemplo n.º 1
0
 private void audioDeleteFromList_Click(object sender, RoutedEventArgs e)
 {
     foreach (AudioProperties audio in AudioInFrameProps.Where(audio => audio.Audio == sender))
     {
         AudioInFrameProps.Remove(audio);
     }
     resourcesSelectedItem_delete();
 }
Exemplo n.º 2
0
        private void selectFrame_Click(object sender, RoutedEventArgs e)
        {
            uncheckAll();
            addorselect  = false;
            currentFrame = sender as XFrame;
            setPreviousFrames();

            characterListView.SelectedItem = currentFrame.Character;
            characterSelector.SelectedItem = currentFrame.Character;
            currentCharacter = currentFrame.Character;
            textBox.Text     = currentFrame.Text;
            showCharacter();

            if (currentFrame.MenuOptions == null)
            {
                if (currentFrame.PauseFrame)
                {
                    convertToPause.Visibility = Visibility.Collapsed;
                    convertToFrame.Visibility = Visibility.Visible;
                }
                else
                {
                    convertToPause.Visibility = Visibility.Visible;
                    convertToFrame.Visibility = Visibility.Collapsed;
                }
                menuStack.Visibility = Visibility.Hidden;
                menuOptionsVisualList.ItemsSource = null;
            }
            else
            {
                convertToPause.Visibility         = Visibility.Visible;
                convertToFrame.Visibility         = Visibility.Visible;
                convertToMenu.Visibility          = Visibility.Collapsed;
                menuStack.Visibility              = Visibility.Visible;
                menuOptionsVisualList.ItemsSource = currentFrame.MenuOptions;
            }

            if (currentFrame.PauseFrame)
            {
                disableAll();
                characterSelector.Visibility = Visibility.Collapsed;
                characterLabel.Visibility    = Visibility.Collapsed;
                textBox.Visibility           = Visibility.Collapsed;
            }
            else
            {
                enableAll();
                characterSelector.Visibility = Visibility.Visible;
                characterLabel.Visibility    = Visibility.Visible;
                textBox.Visibility           = Visibility.Visible;
            }
            //ресурсы
            //при выборе фрейма сначала проверяется, есть ли пропы ТОЛЬКО предыдущих кадров включая нынешний, откидывается полностью часть пропов со стоп-маркерами в виде предыдущих же кадров
            //проще говоря, в списке оказываются только те пропы, у которых есть начало, но нет конца до нынешнего фрейма включительно
            List <ImageBackProperties> backgroundslist = BackInFrameProps.Where(back => previousFrames.Contains(back.Frame))
                                                         .Where(back => ((back.StopFrame == null && back.StopFrames == null) ||
                                                                         (back.StopFrame != null && !previousFrames.Contains(back.StopFrame)) ||
                                                                         (back.StopFrames != null && back.StopFrames.Intersect(previousFrames).Count() == 0))).ToList();
            List <ImageCharProperties> imageslist = ImageInFrameProps.Where(img => previousFrames.Contains(img.Frame))
                                                    .Where(img => ((img.StopFrame == null && img.StopFrames == null) ||
                                                                   (img.StopFrame != null && !previousFrames.Contains(img.StopFrame)) ||
                                                                   (img.StopFrames != null && img.StopFrames.Intersect(previousFrames).Count() == 0))).ToList();
            List <AudioProperties> audiolist = AudioInFrameProps.Where(mus => previousFrames.Contains(mus.Frame))
                                               .Where(mus => ((mus.StopFrame == null && mus.StopFrames == null) ||
                                                              (mus.StopFrame != null && !previousFrames.Contains(mus.StopFrame)) ||
                                                              (mus.StopFrames != null && mus.StopFrames.Intersect(previousFrames).Count() == 0))).ToList();

            //пропов будет всегда немного, потому по ним искать легче легкого и проще простого.
            backgroundslist.ForEach(backprops =>
            {
                if (backprops.Frame != currentFrame)
                {
                    backprops.Image.IsChecked = null;
                }
                else
                {
                    backprops.Image.IsChecked = true;
                }
                backprops.Image.Background = currentFrameResourceColor;
            });

            imageslist.ForEach(imageprops =>
            {
                if (imageprops.Frame != currentFrame)
                {
                    imageprops.Image.IsChecked = null;
                }
                else
                {
                    imageprops.Image.IsChecked = true;
                }
                imageprops.Image.Background = currentFrameResourceColor;
            });

            audiolist.ForEach(audprops =>
            {
                if (audprops.Frame != currentFrame)
                {
                    audprops.Audio.IsChecked = null;
                }
                else
                {
                    audprops.Audio.IsChecked = true;
                }
                audprops.Audio.Background = currentFrameResourceColor;
            });

            addorselect = true;
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        private void saveScript()
        {
            projectExpander.IsExpanded = false;
            createDirectories();
            FileStream   fs     = new FileStream(projectFolder + "script.rpy", FileMode.Create);
            StreamWriter writer = new StreamWriter(fs);

            writer.WriteLine(scriptstart + nextLine);
            //init
            writer.WriteLine(backgroundImages);
            foreach (XImage image in backImageListView.Items)
            {
                writer.WriteLine("image " + image.Alias + eQuote(image.Header));
            }

            writer.WriteLine(characterImages);
            foreach (XImage image in imageListView.Items)
            {
                writer.WriteLine("image " + image.Alias + eQuote(image.Header));
            }

            writer.WriteLine(musicAudio);
            foreach (XAudio audio in musicListView.Items)
            {
                writer.WriteLine(define + "audio." + audio.Alias + eQuote(musicFolder + audio.Header));
            }

            writer.WriteLine(soundsAudio);
            foreach (XAudio audio in soundListView.Items)
            {
                writer.WriteLine(define + "audio." + audio.Alias + eQuote(soundsFolder + audio.Header));
            }

            writer.WriteLine(voiceAudio);
            foreach (XAudio audio in voiceListView.Items)
            {
                writer.WriteLine(define + "audio." + audio.Alias + eQuote(voicesFolder + audio.Header));
            }

            writer.WriteLine(Movies);
            foreach (XMovie movie in movieListView.Items)
            {
                string mask = "";
                if (movie.MaskPath != null)
                {
                    mask = ", mask" + eQuote(moviesFolder + movie.MaskPath);
                }
                writer.WriteLine("image " + movie.Alias + "=Movie(play" + eQuote(moviesFolder + movie.Header) + mask + ")");
            }

            writer.WriteLine(Characters);
            for (int i = 4; i < characterList.Count; i++)
            {
                XCharacter chosenCharacter = characterList[i] as XCharacter;
                string     icon = "", color = "", nvl = "", bold = "", italic = "", what_color = "", what_bold = "", what_italic = "";
                if (chosenCharacter.IsNvl)
                {
                    nvl = ", kind=nvl";
                }
                if (chosenCharacter.Icon != null)
                {
                    icon = ", image" + eQuote(chosenCharacter.Alias); writer.WriteLine("image side " + chosenCharacter.Alias + eQuote(chosenCharacter.Content.ToString()));
                }
                if (chosenCharacter.NameColor.ToString() != "")
                {
                    color = ", color" + eQuote(chosenCharacter.NameColor.ToString().Remove(1, 2));
                }
                if (chosenCharacter.NameIsBold)
                {
                    bold = ", who_bold=True";
                }
                if (chosenCharacter.NameIsItalic)
                {
                    italic = ", who_italic=True";
                }
                if (chosenCharacter.TextColor.ToString() != "")
                {
                    what_color = ", what_color" + eQuote(chosenCharacter.TextColor.ToString().Remove(1, 2));
                }
                if (chosenCharacter.TextIsBold)
                {
                    what_bold = ", what_bold=True";
                }
                if (chosenCharacter.TextIsItalic)
                {
                    what_italic = ", what_italic=True";
                }
                writer.WriteLine(define + chosenCharacter.Alias + character + quote(chosenCharacter.Content.ToString()) + nvl + icon + color + bold + italic + what_color + what_bold + what_italic + ")");
            }

            //end init
            //labels

            for (int chosenLabelNumber = 0; chosenLabelNumber < tabControlStruct.Items.Count - 1; chosenLabelNumber++)
            {
                writer.WriteLine(nextLine + label + (tabControlStruct.Items[chosenLabelNumber] as XLabel).Text + ':');

                for (int chosenFrameNumber = 0; chosenFrameNumber < ((tabControlStruct.Items[chosenLabelNumber] as XLabel).Content as ListView).Items.Count; chosenFrameNumber++)
                {
                    //все что касается конкретного кадра
                    XFrame chosenFrame = ((tabControlStruct.Items[chosenLabelNumber] as XLabel).Content as ListView).Items[chosenFrameNumber] as XFrame;
                    //background
                    ImageBackProperties BackProp;

                    if (BackInFrameProps.Any(prop => prop.StopFrame == chosenFrame))
                    {
                        BackProp = BackInFrameProps.First(prop => prop.StopFrame == chosenFrame);
                        string animationType = "";
                        if (BackProp.AnimationOutType != 0)
                        {
                            animationType = " with " + animationOutTypeComboBox.Items[BackProp.AnimationOutType];
                        }
                        writer.WriteLine(tab + "hide " + BackProp.Image.Alias + animationType);
                    }
                    if (BackInFrameProps.Any(prop => prop.Frame == chosenFrame))
                    {
                        BackProp = BackInFrameProps.First(prop => prop.Frame == chosenFrame);
                        string animationType = "";
                        if (BackProp.AnimationInType != 0)
                        {
                            animationType = " with " + animationInTypeComboBox.Items[BackProp.AnimationInType];
                        }
                        writer.WriteLine(tab + "scene " + BackProp.Image.Alias + animationType);
                    }

                    //images
                    if (ImageInFrameProps.Any(prop => prop.StopFrame == chosenFrame))
                    {
                        foreach (ImageCharProperties property in ImageInFrameProps.Where(prop => prop.StopFrame == chosenFrame))
                        {
                            string animationType = "";
                            if (property.AnimationOutType != 0)
                            {
                                animationType = " with " + animationOutTypeComboBox.Items[property.AnimationOutType];
                            }
                            writer.WriteLine(tab + "hide " + property.Image.Alias + animationType);
                        }
                    }
                    if (ImageInFrameProps.Any(prop => prop.Frame == chosenFrame))
                    {
                        foreach (ImageCharProperties property in ImageInFrameProps.Where(prop => prop.Frame == chosenFrame))
                        {
                            string align         = "";
                            string animationType = "";
                            if (property.Align != 0)
                            {
                                align = " at " + alignComboBox.Items[property.Align];
                            }
                            if (property.AnimationInType != 0)
                            {
                                animationType = " with " + animationInTypeComboBox.Items[property.AnimationInType];
                            }
                            writer.WriteLine(tab + "show " + property.Image.Alias + align + animationType);
                        }
                    }

                    //audio
                    if (AudioInFrameProps.Any(mus => mus.StopFrame == chosenFrame))
                    {
                        foreach (AudioProperties property in AudioInFrameProps.Where(prop => (prop.StopFrame == chosenFrame)))
                        {
                            if (property.Audio.Type == "music ")
                            {
                                writer.WriteLine(tab + "stop music");
                            }
                            else if (property.Audio.Type == "sound ")
                            {
                                writer.WriteLine(tab + "stop sound");
                            }
                            else
                            {
                                writer.WriteLine(tab + "stop voice");
                            }
                        }
                    }
                    if (AudioInFrameProps.Any(mus => mus.Frame == chosenFrame))
                    {
                        string fadein  = "";
                        string fadeout = "";
                        string loop    = "";
                        foreach (AudioProperties property in AudioInFrameProps.Where(prop => (prop.Frame == chosenFrame)))
                        {
                            if (property.FadeIn != 0)
                            {
                                fadein = " fadein " + property.FadeIn;
                            }
                            if (property.FadeOut != 0)
                            {
                                fadeout = " fadeout " + property.FadeOut;
                            }
                            if (!property.Loop && property.Audio.Type == "music ")
                            {
                                loop = " noloop";
                            }
                            else if (property.Loop && !(property.Audio.Type == "music "))
                            {
                                loop = " loop";
                            }
                            writer.WriteLine(tab + "play " + property.Audio.Type + property.Audio.Alias + fadein + fadeout + loop);
                        }
                    }

                    //movie
                    if (chosenFrame.Movie != null)
                    {
                        writer.WriteLine(tab + "$ renpy.movie_cutscene(" + quote(chosenFrame.Movie.Content.ToString()) + ")");
                    }

                    //menu
                    if (chosenFrame.MenuOptions != null)
                    {
                        writer.WriteLine(tab + "menu:");
                        if (chosenFrame.Text != "")
                        {
                            writer.WriteLine(tab + tab + quote(chosenFrame.Text));
                        }
                        foreach (XMenuOption option in chosenFrame.MenuOptions)
                        {
                            string optionLabel = "";
                            writer.WriteLine(tab + tab + quote(option.Choice) + ':');
                            if (option.MenuAction.SelectedItem != passAction)
                            {
                                optionLabel = " " + (option.ActionLabel.SelectedItem as ComboBoxItem).Content.ToString();
                            }
                            writer.WriteLine(tab + tab + tab + (option.MenuAction.SelectedItem as ComboBoxItem).Content + optionLabel);
                        }
                    }
                    else
                    {
                        //Character and text
                        string character = "";
                        if (chosenFrame.Character != charNone)
                        {
                            character = chosenFrame.Character.Alias + " ";
                        }
                        writer.WriteLine(tab + character + quote(chosenFrame.Text));
                    }
                }
                writer.WriteLine(tab + Return);
            }
            writer.Close();
            fs.Close();
        }