示例#1
0
 private void clearAll()
 {
     projectExpander.IsExpanded = false;
     uncheckAll();
     for (int i = 2; i < imagegrid.Children.IndexOf(imageBorder);)
     {
         imagegrid.Children.RemoveAt(i);
     }
     foreach (TabItem tab in tabControlResources.Items)
     {
         (tab.Content as ListView).Items.Clear();
     }
     tabControlStruct.Items.Clear();
     tabControlStruct.Items.Add(addTab);
     BackInFrameProps.Clear();
     ImageInFrameProps.Clear();
     AudioInFrameProps.Clear();
     menuLabelList.Clear();
     characterList.Clear();
     disptimer.Stop();
     characterLabel.Content    = "none";
     textBox.Text              = "";
     characterLabel.Foreground = new SolidColorBrush(default_ColorHeaders.SelectedColor.Value);
     textBox.Foreground        = new SolidColorBrush(default_ColorText.SelectedColor.Value);
 }
示例#2
0
 private void audioDeleteFromList_Click(object sender, RoutedEventArgs e)
 {
     foreach (AudioProperties audio in AudioInFrameProps.Where(audio => audio.Audio == sender))
     {
         AudioInFrameProps.Remove(audio);
     }
     resourcesSelectedItem_delete();
 }
示例#3
0
        public void getAudioProperties(XAudio audio)
        {
            AudioProperties property = AudioInFrameProps.Find(prop => prop.Frame == currentFrame && prop.Audio == audio);

            fadeinTextBox.Text  = property.FadeIn.ToString();
            fadeoutTextBox.Text = property.FadeOut.ToString();
            //queueCheckBox.IsChecked = property.Queue;
            loopCheckBox.IsChecked     = property.Loop;
            imagePropsPanel.Visibility = Visibility.Hidden;
        }
示例#4
0
 private void selectOnlyCurrentaudio(XAudio previous, XAudio current)
 {
     if (previous != null && previous != current)
     {
         if (addorselect)
         {
             AudioInFrameProps.Last(prop => prop.Audio == previous && previousFrames.Contains(prop.Frame)).StopFrame = currentFrame;
         }
         previous.IsChecked = false;
     }
 }
示例#5
0
        private void audio_Checked(object sender, RoutedEventArgs e)
        {
            currentAudio = (sender as CheckBox).Tag as XAudio;
            bool isLooped = false;

            if (AudioInFrameProps.Any(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Audio == currentAudio))
            {
                AudioProperties audio = AudioInFrameProps.First(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Audio == currentAudio);
                if (audio.StopFrame == currentFrame)
                {
                    audio.StopFrame = null;
                }
                else
                {
                    audio.StopFrames.Remove(currentFrame);
                }
                (sender as CheckBox).IsChecked = null;
            }
            else
            {
                if (currentAudio.Type == "music ")
                {
                    isLooped = true;
                    selectOnlyCurrentaudio(lastMusicChecked, currentAudio);
                    lastMusicChecked = currentAudio;
                    addAudioToLayer(currentAudio.Path, music, panelMusic, labelMusic);
                }
                else if (currentAudio.Type == "sound ")
                {
                    selectOnlyCurrentaudio(lastSoundChecked, currentAudio);
                    lastSoundChecked = currentAudio;
                    addAudioToLayer(currentAudio.Path, sound, panelSound, labelSound);
                }
                else
                {
                    selectOnlyCurrentaudio(lastVoiceChecked, currentAudio);
                    lastVoiceChecked = currentAudio;
                    addAudioToLayer(currentAudio.Path, voice, panelVoice, labelVoice);
                }

                if (addorselect)
                {
                    AudioInFrameProps.Add(new AudioProperties()
                    {
                        Frame = currentFrame, Audio = currentAudio, Loop = isLooped
                    });
                }
                getAudioProperties(currentAudio);
            }

            audioPropsPanel.Visibility = Visibility.Visible;
            show       = true;
            waschecked = true;
        }
示例#6
0
        private void audio_Unchecked(object sender, RoutedEventArgs e)
        {
            XAudio selectedAudio = (sender as CheckBox).Tag as XAudio;

            if (waschecked)
            {
                if (removeorunselect)
                {
                    AudioInFrameProps.Remove(AudioInFrameProps.Find(i => i.Frame == currentFrame && i.Audio == selectedAudio));
                }
                waschecked = false;
            }
            else
            {
                AudioProperties audio = AudioInFrameProps.Last(i => previousFrames.Contains(i.Frame) && i.Audio == selectedAudio);
                if (removeorunselect)
                {
                    if (audio.Frame.MenuOptions == null)
                    {
                        audio.StopFrame = currentFrame;
                    }
                    else
                    {
                        audio.StopFrames.Add(currentFrame);
                    }
                }
            }

            if (selectedAudio.Type == "music ")
            {
                hideAudioLayer(music, panelMusic, labelMusic);
            }
            else if (selectedAudio.Type == "sound ")
            {
                hideAudioLayer(sound, panelSound, labelSound);
            }
            else
            {
                hideAudioLayer(voice, panelVoice, labelVoice);
            }

            audioPropsPanel.Visibility = Visibility.Hidden;
            show = false;
        }
示例#7
0
        private void saveOptions()
        {
            containsMusic = AudioInFrameProps.Any(prop => prop.Audio.Type == "music ");
            containsSound = AudioInFrameProps.Any(prop => prop.Audio.Type == "sound ");
            containsVoice = AudioInFrameProps.Any(prop => prop.Audio.Type == "voice ");

            List <string> builder = new List <string> {
            };

            if (File.Exists(projectFolder + "options.rpy"))
            {
                FileStream   fs     = new FileStream(projectFolder + "options.rpy", FileMode.Open);
                StreamReader reader = new StreamReader(fs);
                string       singleLine;

                while (!reader.EndOfStream)
                {
                    singleLine = reader.ReadLine();
                    if (singleLine.StartsWith("define config.name"))
                    {
                        builder.Add("define config.name = _(" + quote(title.Text) + ')');
                    }
                    else if (singleLine.StartsWith("define gui.show_name"))
                    {
                        string show = "True"; if (titleVisible.IsChecked == false)
                        {
                            show = "False";
                        }
                        builder.Add("define gui.show_name = " + show);
                    }
                    else if (singleLine.StartsWith("define config.version"))
                    {
                        builder.Add("define config.version = " + quote(version.Text));
                    }
                    else if (singleLine.StartsWith("define gui.about"))
                    {
                        builder.Add("define gui.about = _p(\"\"\"" + about.Text);
                    }
                    else if (singleLine.StartsWith("define build.name"))
                    {
                        builder.Add("define build.name = " + quote(buildName.Content.ToString()));
                    }
                    else if (singleLine.StartsWith("define config.has_sound"))
                    {
                        string sound = "True"; if (containsSound == false)
                        {
                            sound = "False";
                        }
                        builder.Add("define config.has_sound = " + sound);
                    }
                    else if (singleLine.StartsWith("define config.has_music"))
                    {
                        string music = "True"; if (containsMusic == false)
                        {
                            music = "False";
                        }
                        builder.Add("define config.has_music = " + music);
                    }
                    else if (singleLine.StartsWith("define config.has_voice"))
                    {
                        string voice = "True"; if (containsVoice == false)
                        {
                            voice = "False";
                        }
                        builder.Add("define config.has_voice = " + voice);
                    }
                    else if (singleLine.StartsWith("default preferences.text_cps"))
                    {
                        builder.Add("default preferences.text_cps = " + textShowSpeed.Text);
                    }
                    else if (singleLine.StartsWith("default preferences.afm_time"))
                    {
                        builder.Add("default preferences.afm_time = " + autoReaderLatency.Text);
                    }
                    else if (singleLine.StartsWith("define config.enter_transition"))
                    {
                        builder.Add("define config.enter_transition = " + gameOpenTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.intra_transition"))
                    {
                        builder.Add("define config.intra_transition = " + gameIntraTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.exit_transition"))
                    {
                        builder.Add("define config.exit_transition = " + gameExitTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.after_load_transition"))
                    {
                        builder.Add("define config.after_load_transition = " + gameStartTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.end_game_transition"))
                    {
                        builder.Add("define config.end_game_transition = " + gameEndTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.window_show_transition"))
                    {
                        builder.Add("define config.window_show_transition = " + dialogShowTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.window_hide_transition"))
                    {
                        builder.Add("define config.window_hide_transition = " + dialogHideTransition.SelectedItem);
                    }
                    else if (singleLine.StartsWith("define config.window_icon"))
                    {
                        try { string iconPath = icon.Icon.Source.ToString(); builder.Add("define config.window_icon" + esQuote(iconPath.Substring(iconPath.IndexOf(game) + 6))); }
                        catch (Exception) { builder.Add(singleLine); }
                    }
                    else
                    {
                        builder.Add(singleLine);
                    }
                }
                reader.Close();
                fs.Close();
            }
            else
            {
                File.Create(projectFolder + "options.rpy").Close();
                builder.Add("define config.name = _(" + quote(title.Text) + ')');
                string show = "True"; if (titleVisible.IsChecked == false)
                {
                    show = "False";
                }
                builder.Add("define gui.show_name = " + show);
                builder.Add("define config.version = " + quote(version.Text));
                builder.Add("define gui.about = _p(\"\"\"" + about.Text);
                builder.Add("\"\"\")");
                builder.Add("define build.name = " + quote(buildName.Content.ToString()));
                string sound = "True"; if (containsSound == false)
                {
                    sound = "False";
                }
                builder.Add("define config.has_sound = " + sound);
                string music = "True"; if (containsMusic == false)
                {
                    music = "False";
                }
                builder.Add("define config.has_music = " + music);
                string voice = "True"; if (containsVoice == false)
                {
                    voice = "False";
                }
                builder.Add("define config.has_voice = " + voice);
                builder.Add("default preferences.text_cps = " + textShowSpeed.Text);
                builder.Add("default preferences.afm_time = " + autoReaderLatency.Text);
                builder.Add("define config.enter_transition = " + gameOpenTransition.SelectedItem);
                builder.Add("define config.intra_transition = " + gameIntraTransition.SelectedItem);
                builder.Add("define config.exit_transition = " + gameExitTransition.SelectedItem);
                builder.Add("define config.after_load_transition = " + gameStartTransition.SelectedItem);
                builder.Add("define config.end_game_transition = " + gameEndTransition.SelectedItem);
                builder.Add("define config.window_show_transition = " + dialogShowTransition.SelectedItem);
                builder.Add("define config.window_hide_transition = " + dialogHideTransition.SelectedItem);
                try
                { string iconPath = icon.Icon.Source.ToString();
                  builder.Add("define config.window_icon" + esQuote(iconPath.Substring(iconPath.IndexOf(game) + 6))); }
                catch (Exception) { };
            }
            File.WriteAllLines(projectFolder + "options.rpy", builder);
        }
示例#8
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;
        }
示例#9
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();
        }
示例#10
0
        private void loadScript()
        {
            //код для загрузки script.rpy
            FileStream fs = new FileStream(projectFolder + "script.rpy", FileMode.Open);

            StreamReader readerlabels = new StreamReader(fs);

            while (!readerlabels.EndOfStream)
            {
                string label = readerlabels.ReadLine().TrimStart(' ');
                if (label.StartsWith("label"))
                {
                    ListView newLabel = createLabel(label.Substring(6, label.Length - 7));
                }
            }
            readerlabels.Dispose(); fs.Dispose();

            fs = new FileStream(projectFolder + "script.rpy", FileMode.Open);
            StreamReader reader = new StreamReader(fs);
            //контент ОЧЕНЬ неоднозначен, потому для его правильного распознания нужен код и в init, и в метках
            string singleLine;

            while (!reader.EndOfStream)
            {
                singleLine = reader.ReadLine().TrimStart(' ');

                if (singleLine.StartsWith("define"))
                {
                    if (singleLine.Contains("Character"))
                    {
                        XCharacter character = loadCharacter(singleLine);
                        characterList.Add(character);
                    }
                    else if (singleLine.Contains("audio."))
                    {
                        XAudio audio = new XAudio();
                        audio.loadAudio(singleLine, projectFolder + game);
                        audioMouseActions(audio);
                        musicListView.Items.Add(audio);
                    }
                }
                else if (singleLine.StartsWith("image"))
                {
                    if (!singleLine.Contains("Movie"))
                    {
                        XImage image = new XImage();
                        image.loadImage(singleLine, projectFolder + "images\\");
                        imageMouseActions(image);
                        if (!singleLine.StartsWith("image side"))
                        {
                            backImageListView.Items.Add(image);
                        }
                        else
                        {
                            image.Checkbox.Visibility = Visibility.Hidden;
                            sideListView.Items.Add(image);
                        }
                    }
                    else
                    {
                        XMovie movie = new XMovie();
                        movie.loadMovie(singleLine, projectFolder + "movies\\");
                        movieMouseActions(movie);
                        movieListView.Items.Add(movie);
                    }
                }
                else if (singleLine.StartsWith("label"))
                {
                    XLabel selectedLabel = tabControlStruct.Items.OfType <XLabel>().First(label => label.Text == singleLine.Substring(6, singleLine.Length - 7));
                    selectedLabel.IsSelected = true;
                    XFrame frame;
                    bool   buildmenu  = false;
                    bool   firstframe = true;

                    singleLine = reader.ReadLine().Trim(' ');

                    while (singleLine != "return" && !reader.EndOfStream)
                    {
                        frame        = createFrame();
                        currentFrame = frame;
                        (selectedLabel.Content as ListView).Items.Add(frame);
                        if (firstframe)
                        {
                            setPreviousFrames(); firstframe = false;
                        }
                        else
                        {
                            previousFrames.Add(frame);
                        }

                        List <string> framebody = new List <string> {
                        };

                        while (singleLine != "return" && !reader.EndOfStream)
                        {
                            if (singleLine.StartsWith("menu"))
                            {
                                buildmenu         = true;
                                frame.MenuOptions = new ObservableCollection <XMenuOption> {
                                };
                            }
                            else if (Regex.IsMatch(singleLine, @"[\S\s]*""[\S\s]*"":$"))
                            {
                                XMenuOption newmenuoption = createMenuOption(frame.MenuOptions.Count == 0);
                                newmenuoption.Choice = value(singleLine);

                                singleLine = reader.ReadLine().Trim(' ');
                                if (singleLine.StartsWith("jump"))
                                {
                                    newmenuoption.MenuAction.SelectedItem   = jumpAction;
                                    newmenuoption.ActionLabel.SelectedIndex = menuLabelList.IndexOf(menuLabelList.First(label => label.Content.ToString() == singleLine.Substring(singleLine.IndexOf(' ') + 1)));
                                    (tabControlStruct.Items[newmenuoption.ActionLabel.SelectedIndex] as XLabel).MenuChoice = frame;
                                }
                                else if (singleLine.StartsWith("call"))
                                {
                                    newmenuoption.MenuAction.SelectedItem   = callAction;
                                    newmenuoption.ActionLabel.SelectedIndex = menuLabelList.IndexOf(menuLabelList.First(label => label.Content.ToString() == singleLine.Substring(singleLine.IndexOf(' ') + 1)));
                                    (tabControlStruct.Items[newmenuoption.ActionLabel.SelectedIndex] as XLabel).MenuChoice = frame;
                                }
                                else
                                {
                                    newmenuoption.MenuAction.SelectedItem = passAction;
                                }
                                frame.MenuOptions.Add(newmenuoption);
                            }
                            else if (Regex.IsMatch(singleLine, @"[\S\s]*""[\S\s]*""$"))
                            {
                                if (buildmenu && frame.MenuOptions.Count != 0)
                                {
                                    break;
                                }
                                loadText(frame, singleLine);
                                if (!buildmenu)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                if (!buildmenu)
                                {
                                    framebody.Add(singleLine);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            singleLine = reader.ReadLine().Trim(' ');
                        }

                        for (int line = 0; line < framebody.Count; line++)
                        {
                            if (framebody[line].StartsWith("scene"))
                            {
                                string[]            all           = framebody[line].Split(' ');
                                XImage              selectedImage = backImageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]);
                                ImageBackProperties BackProp      = new ImageBackProperties()
                                {
                                    Frame = frame, Image = selectedImage
                                };
                                if (all.Length > 2)
                                {
                                    if (all[2] == "with")
                                    {
                                        BackProp.AnimationInType = (byte)animationInTypeComboBox.Items.IndexOf(animationInTypeComboBox.Items.OfType <string>().First(item => item == all[3]));
                                    }
                                }
                                //секция поиска
                                if (BackInFrameProps.Any(prop => previousFrames.Contains(prop.Frame) && !previousFrames.Contains(prop.StopFrame)))
                                {
                                    ImageBackProperties previous = BackInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && !previousFrames.Contains(prop.StopFrame));
                                    //а вдруг меню, а мы неподготовлены? надо расставить все нужные метки
                                    if (previous.Frame.MenuOptions == null)
                                    {
                                        previous.StopFrame = frame;
                                    }
                                    else
                                    {
                                        if (previous.StopFrames == null)
                                        {
                                            previous.StopFrames = new List <XFrame> {
                                            }
                                        }
                                        ;
                                        previous.StopFrames.Add(frame);
                                    };
                                }                                //усьо
                                BackInFrameProps.Add(BackProp);
                            }
                            else if (framebody[line].StartsWith("show"))
                            {
                                string[] all = framebody[line].Split(' ');
                                XImage   selectedImage;
                                if (backImageListView.Items.OfType <XImage>().Any(item => item.Alias == all[1]))
                                {
                                    selectedImage = backImageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]);
                                    backImageListView.Items.Remove(selectedImage);
                                    imageListView.Items.Add(selectedImage);
                                }
                                else
                                {
                                    selectedImage = imageListView.Items.OfType <XImage>().First(item => item.Alias == all[1]);
                                }

                                ImageCharProperties props = new ImageCharProperties()
                                {
                                    Frame = frame, Image = selectedImage, Displayable = newDisplayable()
                                };
                                props.Displayable.Source = imageShow(selectedImage.Path);

                                for (int i = 2; i < all.Length; i++)
                                {
                                    if (all[i] == "with")
                                    {
                                        props.AnimationInType = (byte)animationInTypeComboBox.Items.IndexOf(animationInTypeComboBox.Items.OfType <string>().First(item => item == all[i + 1]));
                                    }
                                    else if (all[i] == "at")
                                    {
                                        props.Align = (byte)alignComboBox.Items.IndexOf(alignComboBox.Items.OfType <string>().First(item => item == all[i + 1]));
                                    }
                                }
                                ImageInFrameProps.Add(props);
                            }
                            else if (framebody[line].StartsWith("hide"))
                            {
                                string[] all = framebody[line].Split(' ');
                                if (backImageListView.Items.OfType <XImage>().Any(prop => prop.Alias == all[1]))
                                {
                                    ImageBackProperties previous = BackInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Image.Alias == all[1]);
                                    if (all.Length > 2)
                                    {
                                        if (all[2] == "with")
                                        {
                                            previous.AnimationOutType = (byte)animationOutTypeComboBox.Items.IndexOf(animationOutTypeComboBox.Items.OfType <string>().First(item => item == all[3]));
                                        }
                                    }
                                    if (previous.Frame.MenuOptions == null)
                                    {
                                        previous.StopFrame = frame;
                                    }
                                    else
                                    {
                                        if (previous.StopFrames == null)
                                        {
                                            previous.StopFrames = new List <XFrame> {
                                            }
                                        }
                                        ;
                                        previous.StopFrames.Add(frame);
                                    };
                                }
                                else
                                {
                                    ImageCharProperties previous = ImageInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Image.Alias == all[1]);
                                    if (all.Length > 2)
                                    {
                                        if (all[2] == "with")
                                        {
                                            previous.AnimationOutType = (byte)animationOutTypeComboBox.Items.IndexOf(animationOutTypeComboBox.Items.OfType <string>().First(item => item == all[3]));
                                        }
                                    }
                                    if (previous.Frame.MenuOptions == null)
                                    {
                                        previous.StopFrame = frame;
                                    }
                                    else
                                    {
                                        if (previous.StopFrames == null)
                                        {
                                            previous.StopFrames = new List <XFrame> {
                                            }
                                        }
                                        ;
                                        previous.StopFrames.Add(frame);
                                    };
                                }
                            }
                            else if (framebody[line].StartsWith("stop"))
                            {
                                string          type     = framebody[line].Substring(5) + " ";
                                AudioProperties previous = AudioInFrameProps.Last(prop => previousFrames.Contains(prop.Frame) && prop.Audio.Type == type);
                                if (previous.Frame.MenuOptions == null)
                                {
                                    previous.StopFrame = frame;
                                }
                                else
                                {
                                    if (previous.StopFrames == null)
                                    {
                                        previous.StopFrames = new List <XFrame> {
                                        }
                                    }
                                    ;
                                    previous.StopFrames.Add(frame);
                                };
                            }
                            else if (framebody[line].StartsWith("play"))
                            {
                                string[] all   = framebody[line].Split(' ');
                                XAudio   audio = musicListView.Items.OfType <XAudio>().First(item => item.Alias == all[2]);
                                if (all[1] != "music")
                                {
                                    musicListView.Items.Remove(audio);
                                    if (all[1] == "sound")
                                    {
                                        soundListView.Items.Add(audio);
                                    }
                                    else
                                    {
                                        voiceListView.Items.Add(audio);
                                    }
                                }
                                AudioProperties props = new AudioProperties()
                                {
                                    Frame = frame, Audio = audio
                                };
                                for (int i = 2; i < all.Length; i++)
                                {
                                    if (all[i] == "fadein")
                                    {
                                        props.FadeIn = float.Parse(all[i + 1]);
                                    }
                                    else if (all[i] == "fadeout")
                                    {
                                        props.FadeOut = float.Parse(all[i + 1]);
                                    }
                                    else if (all[i] == "noloop")
                                    {
                                        props.Loop = false;
                                    }
                                }
                                AudioInFrameProps.Add(props);
                            }
                        }

                        if (singleLine != "return")
                        {
                            if (buildmenu)
                            {
                                buildmenu = false;
                            }
                            else
                            {
                                frame.IsSelected = true; singleLine = reader.ReadLine().TrimStart(' ');
                            }
                        }
                    }
                }
            }
            previousFrames.Clear();
            fs.Close();
        }