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; }
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); }
/// <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(); }