Example #1
0
        private void showImagePropsBackground()
        {
            ImageBackProperties property = BackInFrameProps.Find(prop => prop.Frame == currentFrame);

            animationInTypeComboBox.SelectedIndex  = property.AnimationInType;
            animationOutTypeComboBox.SelectedIndex = property.AnimationOutType;
            audioPropsPanel.Visibility             = Visibility.Hidden;
            alignLabel.Visibility    = Visibility.Collapsed;
            alignComboBox.Visibility = Visibility.Collapsed;
        }
Example #2
0
        private void image_Checked(object sender, RoutedEventArgs e)
        {
            currentImage = (sender as CheckBox).Tag as XImage;

            if (currentImage.Parent == backImageListView)
            {
                //случай, когда эта же картинка имет этот же фрейм как стоп-маркер
                if (BackInFrameProps.Any(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Image == currentImage))
                {
                    ImageBackProperties back = BackInFrameProps.First(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Image == currentImage);
                    if (back.StopFrame == currentFrame)
                    {
                        back.StopFrame = null;
                    }
                    else
                    {
                        back.StopFrames.Remove(currentFrame);
                    }
                    (sender as CheckBox).IsChecked = null;
                }
                else
                {
                    if (lastBackChecked != null && lastBackChecked != currentImage)
                    {
                        if (addorselect)
                        {
                            BackInFrameProps.Last(prop => prop.Image == lastBackChecked && previousFrames.Contains(prop.Frame)).StopFrame = currentFrame;
                        }
                        lastBackChecked.IsChecked = false;
                    }
                    lastBackChecked = currentImage;

                    if (addorselect)
                    {
                        BackInFrameProps.Add(new ImageBackProperties()
                        {
                            Frame = currentFrame, Image = currentImage
                        });
                    }
                    imageBackground.Source = imageShow(currentImage.Path);
                    showImagePropsBackground();
                }
            }
            else
            {
                if (ImageInFrameProps.Any(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Image == currentImage))
                {
                    ImageCharProperties img = ImageInFrameProps.First(prop => (prop.StopFrame == currentFrame || (prop.StopFrames != null && prop.StopFrames.Intersect(previousFrames) == currentFrame)) && prop.Image == currentImage);
                    if (img.StopFrame == currentFrame)
                    {
                        img.StopFrame = null;
                    }
                    else
                    {
                        img.StopFrames.Remove(currentFrame);
                    }
                    (sender as CheckBox).IsChecked = null;
                }
                else
                {
                    if (addorselect)
                    {
                        ImageInFrameProps.Add(new ImageCharProperties()
                        {
                            Frame = currentFrame, Image = currentImage, Displayable = newDisplayable()
                        });
                    }
                    Image img = ImageInFrameProps.Find(prop => prop.Frame == currentFrame && prop.Image == currentImage).Displayable;
                    img.Source = imageShow(currentImage.Path);
                    imagegrid.Children.Insert(imagegrid.Children.IndexOf(imageBorder), img);
                    showImagePropsCharacter(currentImage);
                }
            }
            if (addorselect)
            {
                imagePropsPanel.Visibility = Visibility.Visible;
            }
            show       = true;
            waschecked = true;
        }
Example #3
0
        private void image_Unchecked(object sender, RoutedEventArgs e)
        {
            XImage selectedImage = (sender as CheckBox).Tag as XImage;

            //Теперь INDETERMINATE определяет удаление пропа. UNCHECKED определяет присутствие стоп-маркера.
            if (waschecked)
            {
                if (selectedImage.Parent == backImageListView)
                {
                    if (removeorunselect)
                    {
                        BackInFrameProps.Remove(BackInFrameProps.First(i => i.Frame == currentFrame && i.Image == selectedImage));
                    }
                    imageBackground.Source = null;
                }
                else
                {
                    ImageCharProperties imgtoremove = ImageInFrameProps.First(i => i.Frame == currentFrame && i.Image == selectedImage);
                    imagegrid.Children.Remove(imgtoremove.Displayable);
                    if (removeorunselect)
                    {
                        ImageInFrameProps.Remove(imgtoremove);
                    }
                }
                waschecked = false;
            }
            else
            {
                if (selectedImage.Parent == backImageListView)
                {
                    if (BackInFrameProps.Any(i => previousFrames.Contains(i.Frame) && i.Image == selectedImage))
                    {
                        ImageBackProperties imgtostop = BackInFrameProps.Last(i => previousFrames.Contains(i.Frame) && i.Image == selectedImage);
                        if (removeorunselect)
                        {
                            if (imgtostop.Frame.MenuOptions == null)
                            {
                                imgtostop.StopFrame = currentFrame;
                            }
                            else
                            {
                                imgtostop.StopFrames.Add(currentFrame);
                            }
                        }
                    }
                    imageBackground.Source = null;
                }
                else
                {
                    if (ImageInFrameProps.Any(i => previousFrames.Contains(i.Frame) && i.Image == selectedImage))
                    {
                        ImageCharProperties imgtostop = ImageInFrameProps.Last(i => previousFrames.Contains(i.Frame) && i.Image == selectedImage);
                        if (removeorunselect)
                        {
                            if (imgtostop.Frame.MenuOptions == null)
                            {
                                imgtostop.StopFrame = currentFrame;
                            }
                            else
                            {
                                imgtostop.StopFrames.Add(currentFrame);
                            }
                        }
                        imagegrid.Children.Remove(imgtostop.Displayable);
                    }
                }
            }
            imagePropsPanel.Visibility = Visibility.Hidden;
            show = false;
        }
Example #4
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();
        }