public bool RenderLeftColumn(SfxrParams parameters) { bool soundChanged = false; // Begin generator column GUILayout.BeginVertical("box", GUILayout.Width(110)); GUILayout.Label("合成器", EditorStyles.boldLabel); GUILayout.Space(8); if (GUILayout.Button("捡拾/金币")) { suggestedName = "PickupCoin"; parameters.GeneratePickupCoin(); soundChanged = true; } if (GUILayout.Button("激光/射击")) { suggestedName = "LaserShoot"; parameters.GenerateLaserShoot(); soundChanged = true; } if (GUILayout.Button("爆炸")) { suggestedName = "Explosion"; parameters.GenerateExplosion(); soundChanged = true; } if (GUILayout.Button("能量提升")) { suggestedName = "Powerup"; parameters.GeneratePowerup(); soundChanged = true; } if (GUILayout.Button("击中/受伤")) { suggestedName = "HitHurt"; parameters.GenerateHitHurt(); soundChanged = true; } if (GUILayout.Button("跳跃")) { suggestedName = "Jump"; parameters.GenerateJump(); soundChanged = true; } if (GUILayout.Button("选择/切换")) { suggestedName = "BlipSelect"; parameters.GenerateBlipSelect(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("MUTATE")) { parameters.Mutate(); soundChanged = true; } if (GUILayout.Button("随机")) { suggestedName = "Random"; parameters.Randomize(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("复制 (OLD)")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); } if (GUILayout.Button("复制")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); } if (GUILayout.Button("黏贴")) { suggestedName = null; parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("播放")) { PlaySound(); } GUILayout.Space(30); if (GUILayout.Button("导出")) { var path = EditorUtility.SaveFilePanel("导出为WAV", "", getSuggestedName() + ".wav", "wav"); if (path.Length != 0) { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(parameters.GetSettingsString()); File.WriteAllBytes(path, synth.GetWavFile()); } } // End generator column GUILayout.FlexibleSpace(); GUILayout.EndVertical(); return(soundChanged); }
public bool RenderLeftColumn(SfxrParams parameters) { bool soundChanged = false; // Begin generator column GUILayout.BeginVertical("box", GUILayout.Width(110)); GUILayout.Label("GENERATOR", EditorStyles.boldLabel); GUILayout.Space(8); if (GUILayout.Button("PICKUP/COIN")) { suggestedName = "PickupCoin"; parameters.GeneratePickupCoin(); soundChanged = true; } if (GUILayout.Button("LASER/SHOOT")) { suggestedName = "LaserShoot"; parameters.GenerateLaserShoot(); soundChanged = true; } if (GUILayout.Button("EXPLOSION")) { suggestedName = "Explosion"; parameters.GenerateExplosion(); soundChanged = true; } if (GUILayout.Button("POWERUP")) { suggestedName = "Powerup"; parameters.GeneratePowerup(); soundChanged = true; } if (GUILayout.Button("HIT/HURT")) { suggestedName = "HitHurt"; parameters.GenerateHitHurt(); soundChanged = true; } if (GUILayout.Button("JUMP")) { suggestedName = "Jump"; parameters.GenerateJump(); soundChanged = true; } if (GUILayout.Button("BLIP/SELECT")) { suggestedName = "BlipSelect"; parameters.GenerateBlipSelect(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("MUTATE")) { parameters.Mutate(); soundChanged = true; } if (GUILayout.Button("RANDOMIZE")) { suggestedName = "Random"; parameters.Randomize(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("COPY (OLD)")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); } if (GUILayout.Button("COPY")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); } if (GUILayout.Button("PASTE")) { suggestedName = null; parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("PLAY SOUND")) { PlaySound(); } GUILayout.Space(30); if (GUILayout.Button("EXPORT WAV")) { var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); if (path.Length != 0) { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(parameters.GetSettingsString()); File.WriteAllBytes(path, synth.GetWavFile()); } } // End generator column GUILayout.FlexibleSpace(); GUILayout.EndVertical(); return(soundChanged); }
public bool RenderLeftColumn(SfxrParams parameters) { bool soundChanged = false; // Begin generator column GUILayout.BeginVertical("box", GUILayout.Width(110)); GUILayout.Label("GENERATOR", EditorStyles.boldLabel); GUILayout.Space(8); if (GUILayout.Button("PICKUP/COIN")) { suggestedName = "PickupCoin"; parameters.GeneratePickupCoin(); soundChanged = true; } if (GUILayout.Button("LASER/SHOOT")) { suggestedName = "LaserShoot"; parameters.GenerateLaserShoot(); soundChanged = true; } if (GUILayout.Button("EXPLOSION")) { suggestedName = "Explosion"; parameters.GenerateExplosion(); soundChanged = true; } if (GUILayout.Button("POWERUP")) { suggestedName = "Powerup"; parameters.GeneratePowerup(); soundChanged = true; } if (GUILayout.Button("HIT/HURT")) { suggestedName = "HitHurt"; parameters.GenerateHitHurt(); soundChanged = true; } if (GUILayout.Button("JUMP")) { suggestedName = "Jump"; parameters.GenerateJump(); soundChanged = true; } if (GUILayout.Button("BLIP/SELECT")) { suggestedName = "BlipSelect"; parameters.GenerateBlipSelect(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("MUTATE")) { parameters.Mutate(); soundChanged = true; } if (GUILayout.Button("RANDOMIZE")) { suggestedName = "Random"; parameters.Randomize(); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("COPY (OLD)")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsStringLegacy(); } if (GUILayout.Button("COPY")) { EditorGUIUtility.systemCopyBuffer = parameters.GetSettingsString(); } if (GUILayout.Button("PASTE")) { suggestedName = null; parameters.SetSettingsString(EditorGUIUtility.systemCopyBuffer); soundChanged = true; } GUILayout.Space(30); if (GUILayout.Button("PLAY SOUND")) { PlaySound(); } GUILayout.Space(30); if (GUILayout.Button("EXPORT WAV")) { var path = EditorUtility.SaveFilePanel("Export as WAV", "", getSuggestedName() + ".wav", "wav"); if (path.Length != 0) { SfxrSynth synth = new SfxrSynth(); synth.parameters.SetSettingsString(parameters.GetSettingsString()); File.WriteAllBytes(path, synth.GetWavFile()); } } GUILayout.Space(30); soundTitle = GUILayout.TextField(soundTitle); bool canSave = !string.IsNullOrEmpty(soundTitle) && !soundTitle.Contains(";") && !soundTitle.Contains(":"); bool mustReplace = canSave && SoundContainer.Contains(soundTitle); string buttonName = "SAVE"; if (!canSave) { buttonName = "INVALID NAME"; } else if (mustReplace) { buttonName = "REPLACE"; } else { buttonName = "SAVE"; } if (!canSave) { bool prevVal = GUI.enabled; GUI.enabled = false; GUILayout.Button(buttonName); GUI.enabled = prevVal; } else { if (GUILayout.Button(buttonName)) { string soundParams = parameters.GetSettingsString(); if (mustReplace) { SoundContainer.ReplaceSound(soundTitle, soundParams); } else { SoundContainer.AddSound(soundTitle, soundParams); } } } if (canSave && mustReplace) { if (GUILayout.Button("LOAD")) { string soundParams = SoundContainer.GetSound(soundTitle); parameters.SetSettingsString(soundParams); soundChanged = true; } } else { bool prevVal = GUI.enabled; GUI.enabled = false; GUILayout.Button("LOAD"); GUI.enabled = prevVal; } if (canSave && mustReplace) { if (GUILayout.Button("DELETE")) { SoundContainer.DeleteSound(soundTitle); } } else { bool prevVal = GUI.enabled; GUI.enabled = false; GUILayout.Button("DELETE"); GUI.enabled = prevVal; } // End generator column GUILayout.FlexibleSpace(); GUILayout.EndVertical(); return(soundChanged); }