void Draw(Rect a)
    {
        GUI.skin = skin;
        GUI.skin.FontSize(fontSize);

        GUIContent c;

        if (tex == null)
        {
            c = new GUIContent(message);
        }
        else
        {
            c = new GUIContent(message, tex);
        }


        GUIF.Box(a, c);

        if (GUIF.Button(a.BottomCenter(.3f, .2f).MoveUp(.1f), "Ok"))
        {
            dismissed = true;
            slider.Slide(direction.Flip(), slidePower);
        }

        GUIF.InvisibleButton(ScreenF.all);
    }
Пример #2
0
 public new void Draw(Component caller)
 {
     clicked = false;
     if (GUIF.Button(area, content))
     {
         clicked = true; Call(caller);
     }
 }
    public static bool ToggleButton(Rect area, string str, bool val, float padding, string sound)
    {
        bool  ret   = val;
        Color color = GUI.color;
        Color c     = color;

        if (!val)
        {
            c = c.Half();
        }
        GUI.color = c;
        if (GUIF.Button(area, str, padding, sound))
        {
            ret = !ret;
        }
        GUI.color = color;
        return(ret);
    }
Пример #4
0
    public void OnSetSelectGUI()
    {
#if !UNITY_WEBPLAYER
        GUIF.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), "Quit", () => {
#if UNITY_EDITOR
            EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        });
#endif
        Rect  scrollArea = new Rect(Screen.width * 0.01f, Screen.height * 0.1f, Screen.width * 0.98f, Screen.height * 0.85f);
        float lineHeight = GUI.skin.button.LineSize() * 1.33f;
        Rect  brush      = new Rect(0.0f, 0.0f, scrollArea.width - 24, lineHeight);
        scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * soundSets.Count)); {
            brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f);
            for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < soundSets.Count; i++)
            {
                string set = soundSets[i];
                GUIF.Button(brush, set, () => {
                    if (!scrolling)
                    {
                        //currentSet = (Transform.Instantiate(Resources.Load<Transform>(set) as Transform) as Transform).GetComponent<SoundSetGO>();
                        Application.LoadLevel(set);
                        menuState            = MenuState.ListingPhrases;
                        scrollPos            = new Vector2();
                        scrollFling          = 0;
                        searchString         = "";
                        previousSearchString = "";
                    }
                });
                brush = brush.Move(0.0f, 1.05f);
            }
        } GUI.EndScrollView();
        GUI.Label(new Rect(Screen.width * 0.05f, Screen.height * 0.95f, Screen.width * 0.9f, lineHeight), "Made by 005");
    }
Пример #5
0
    public void OnPhraseSelectGUI()
    {
        GUIF.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), "Back", () => {
            Application.LoadLevel("default");
            menuState    = MenuState.ListingSets;
            searchString = "";
            scrollPos    = new Vector2();
            scrollFling  = 0.0f;
        });
        string str;

        switch (mode)
        {
        case PlayMode.AlwaysInstant:
            str = "Always Play";
            break;

        case PlayMode.Override:
            str = "Override Playing";
            break;

        case PlayMode.Queue:
            str = "Queue";
            break;

        case PlayMode.Spam:
            str = "Spam";
            break;

        default:
            str = "Error";
            break;
        }
        GUIF.Button(new Rect(Screen.width * 0.59f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), str, () => {
            NextMode();
        });
        Rect  scrollArea = new Rect(Screen.width * 0.01f, Screen.height * 0.2f, Screen.width * 0.98f, Screen.height * 0.73f);
        float lineHeight = GUI.skin.button.LineSize() * 1.33f;
        Rect  brush      = new Rect(Screen.width * 0.01f, Screen.height * 0.1f, Screen.width * 0.93f, lineHeight);

        GUI.Label(brush.Left(0.2f), "Search");
        searchString = GUI.TextField(brush.Right(0.8f), searchString);
        GUIF.Button(new Rect(Screen.width * 0.94f, Screen.height * 0.1f, Screen.width * 0.05f, lineHeight), "X", () => {
            searchString = "";
        });
        brush       = brush.Move(0.0f, 1.0f);
        brush.width = Screen.width * 0.98f;
        switch (sortMode)
        {
        case SortMode.Alphabetic:
            str = "Alphabetic";
            break;

        case SortMode.MostPlayed:
            str = "Most Played";
            break;

        case SortMode.SearchRelevance:
            str = "Relevance";
            break;

        default:
            str = "Error";
            break;
        }
        GUIF.Button(brush, "Sort by: " + str, () => {
            NextSortMode();
            scrollPos   = new Vector2();
            scrollFling = 0.0f;
            if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString)))
            {
                currentSet.Sort();
            }
            else
            {
                searchResults.Sort((Phrase phrase1, Phrase phrase2) => {
                    if (sortMode == SortMode.Alphabetic)
                    {
                        return(phrase1.name.ToUpper().CompareTo(phrase2.name.ToUpper()));
                    }
                    else if (sortMode == SortMode.MostPlayed)
                    {
                        return(phrase2.timesPlayed - phrase1.timesPlayed);
                    }
                    else if (sortMode == SortMode.SearchRelevance)
                    {
                        return(SoundSet.ComparePhrasesBySearchRelevance(phrase1.name.ToUpper(), phrase2.name.ToUpper(), SoundSet.Searchify(searchString)));
                    }
                    else
                    {
                        return(0);
                    }
                });
            }
        });
        brush = new Rect(0.0f, 0.0f, scrollArea.width - 24, lineHeight);
        System.Func <Rect, string, System.Action, bool> buttonFunc;
        if (mode == PlayMode.Spam)
        {
            buttonFunc = GUIF.RepeatButton;
        }
        else
        {
            buttonFunc = GUIF.Button;
        }
        if (!System.String.IsNullOrEmpty(SoundSet.Searchify(searchString)))
        {
            scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * searchResults.Count)); {
                brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f);
                for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < searchResults.Count; i++)
                {
                    Phrase phrase = searchResults[i];
                    str = phrase.name;
                    if (phrase.clips.Count > 1)
                    {
                        str += " (" + phrase.clips.Count + ")";
                    }
                    buttonFunc(brush, str, () => {
                        if (!scrolling)
                        {
                            switch (mode)
                            {
                            case PlayMode.Queue:
                                clipQueue.Enqueue(phrase.clips.Choose <AudioClip>());
                                break;

                            case PlayMode.AlwaysInstant:
                            case PlayMode.Spam:
                                PlaySound(phrase.clips.Choose <AudioClip>());
                                break;

                            case PlayMode.Override:
                                if (currentSound != null)
                                {
                                    currentSound.Stop();
                                }
                                PlaySound(phrase.clips.Choose <AudioClip>());
                                break;
                            }
                        }
                    });
                    brush = brush.Move(0.0f, 1.05f);
                }
            } GUI.EndScrollView();
        }
        else
        {
            scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * currentSet.phrases.Count)); {
                brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f);
                for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < currentSet.phrases.Count; i++)
                {
                    Phrase phrase = currentSet.phrases[i];
                    str = phrase.name;
                    if (phrase.clips.Count > 1)
                    {
                        str += " (" + phrase.clips.Count + ")";
                    }
                    buttonFunc(brush, str, () => {
                        switch (mode)
                        {
                        case PlayMode.Queue:
                            clipQueue.Enqueue(phrase.clips.Choose <AudioClip>());
                            break;

                        case PlayMode.AlwaysInstant:
                        case PlayMode.Spam:
                            PlaySound(phrase.clips.Choose <AudioClip>());
                            break;

                        case PlayMode.Override:
                            if (currentSound != null)
                            {
                                currentSound.Stop();
                            }
                            PlaySound(phrase.clips.Choose <AudioClip>());
                            break;
                        }
                        phrase.timesPlayed += 1;
                    });
                    brush = brush.Move(0.0f, 1.05f);
                }
            } GUI.EndScrollView();
        }
        buttonFunc(new Rect(scrollArea.x, Screen.height * 0.95f, scrollArea.width, lineHeight), "[Random]", () => {
            List <Phrase> set;
            if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString)))
            {
                set = currentSet.phrases;
            }
            else
            {
                set = searchResults;
            }
            if (set.Count > 0)
            {
                Phrase phrase = set.Choose <Phrase>();
                switch (mode)
                {
                case PlayMode.Queue:
                    clipQueue.Enqueue(phrase.clips.Choose <AudioClip>());
                    break;

                case PlayMode.AlwaysInstant:
                case PlayMode.Spam:
                    PlaySound(phrase.clips.Choose <AudioClip>());
                    break;

                case PlayMode.Override:
                    if (currentSound != null)
                    {
                        currentSound.Stop();
                    }
                    PlaySound(phrase.clips.Choose <AudioClip>());
                    break;
                }
                phrase.timesPlayed += 1;
            }
        });
    }