getBookRect() public method

public getBookRect ( ) : Rect
return Rect
Ejemplo n.º 1
0
    public void displayScaledPage(HalfBook halfbook)
    {
        Rect textRect = halfbook.getTextRect();
        Rect bookRect = halfbook.getBookRect();

        half_code_style.fontSize = (int) (code_style.fontSize * bookRect.width / Screen.width);
        float fontScale = half_code_style.fontSize / ((float) code_style.fontSize);
        //float fontScale = bookRect.width / Screen.width;

        //GUI.SetNextControlName("SpellbookPage");
        GUI.DrawTexture(bookRect,currentPage().texture);
        //if (GUI.Button(bookRect,currentPage().texture))
        //    halfbook.setFocus();

        //GUI.SetNextControlName("ReferenceCode");
        GUILayout.BeginArea(textRect);
        scroll_position = GUILayout.BeginScrollView (scroll_position, GUILayout.Width(textRect.width), GUILayout.Height(textRect.height)); // Should vary the size of the last rect by how much text we have??

        foreach (Tuple<Rect, Texture2D> tup in (new Highlight()).highlightPage(currentPage().code)) {
            //since we changed the font size, need to rescale the highlighting
            Rect h = tup.Item1;
            h.x = (h.x) * fontScale;
            h.y = (h.y+2) /23 * half_code_style.lineHeight - 2*fontScale;
            h.width *= fontScale;
            h.height *= fontScale;
            GUI.DrawTexture(h, tup.Item2);
        }

        GUILayout.TextArea(currentPage().code, half_code_style);
        //GUILayout.Label(currentPage().code, code_style);
        //GUILayout.Box(currentPage().code, code_style);

        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }
Ejemplo n.º 2
0
    public void displayScaledPage(HalfBook halfbook)
    {
        Rect textRect = halfbook.getTextRect();
        Rect bookRect = halfbook.getBookRect();

        half_code_style.fontSize = (int)(code_style.fontSize * bookRect.width / Screen.width);
        float fontScale = half_code_style.fontSize / ((float)code_style.fontSize);

        //float fontScale = bookRect.width / Screen.width;

        //GUI.SetNextControlName("SpellbookPage");
        GUI.DrawTexture(bookRect, currentPage().texture);
        //if (GUI.Button(bookRect,currentPage().texture))
        //    halfbook.setFocus();

        //GUI.SetNextControlName("ReferenceCode");
        GUILayout.BeginArea(textRect);
        scroll_position = GUILayout.BeginScrollView(scroll_position, GUILayout.Width(textRect.width), GUILayout.Height(textRect.height));          // Should vary the size of the last rect by how much text we have??

        foreach (Tuple <Rect, Texture2D> tup in (new Highlight()).highlightPage(currentPage().code))
        {
            //since we changed the font size, need to rescale the highlighting
            Rect h = tup.Item1;
            h.x       = (h.x) * fontScale;
            h.y       = (h.y + 2) / 23 * half_code_style.lineHeight - 2 * fontScale;
            h.width  *= fontScale;
            h.height *= fontScale;
            GUI.DrawTexture(h, tup.Item2);
        }

        GUILayout.TextArea(currentPage().code, half_code_style);
        //GUILayout.Label(currentPage().code, code_style);
        //GUILayout.Box(currentPage().code, code_style);

        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }
Ejemplo n.º 3
0
    void OnGUI()
    {
        GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), background_texture);

        // this must come before the TextEditor line below
        halfbook.draw();

        GUI.SetNextControlName("EditableCode");
        stateObj = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl) as TextEditor;
        //GUI.FocusControl("EditableCode");

        // Give the appropriate text area keyboard control -> this prevents us from moving the player while in the IDE
//      if (Event.current.rawType == EventType.MouseDown) {
//          Debug.Log("caught mousedown event");
//          if (editorPanel.isWithin(Event.current.mousePosition))
//              GUI.FocusControl("EditableCode");
//          else
//              GUI.FocusControl("ReferenceCode");
//          Debug.Log("focus control: "+GUI.GetNameOfFocusedControl());
//      }



        if (shouldPopup)
        {
//      GUI.DrawTexture(editorPanel.getRect(),left_panel_background);
//      //GUI.DrawTexture(new Rect(0,0,Screen.width*3/4,Screen.height),left_panel_background);
//      GUILayout.BeginArea(new Rect(120,40,Screen.width*3/4,Screen.height));
//
//      scroll_position = GUILayout.BeginScrollView (scroll_position, GUILayout.Width(Screen.width*3/4-200), GUILayout.Height(Screen.height-60 )); // Should vary the size of the last rect by how much text we have??
//
//      GUILayout.EndScrollView ();
//      GUILayout.EndArea();

            editorPanel.draw(false);

            int      boxWidth  = 300;
            int      boxHeight = 75;
            GUIStyle style     = GUI.skin.box;
            style.alignment = TextAnchor.UpperCenter;
            GUI.Box(new Rect(Screen.width / 2 - boxWidth / 2, Screen.height / 2 - boxHeight / 2, boxWidth, boxHeight), "Are you sure you want to delete your script?", style);

            if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + box_height / 2 - 20, 50, 30), "Yes"))
            {
                no_edit      = false;
                shouldRemove = true;
                shouldPopup  = false;
            }

            if (GUI.Button(new Rect(Screen.width / 2 + 30, Screen.height / 2 + box_height / 2 - 20, 50, 30), "No"))
            {
                no_edit     = false;
                shouldPopup = false;
            }
        }
        else
        {
            //leftPanel();
            editorPanel.draw(true);
        }

        if (shouldRemove)
        {
            removeScript();
        }

        //rightPanel();
        errorPanel.draw();
        buttonPanel.draw();

        if (GUI.GetNameOfFocusedControl() == "EditableCode")
        {
            adjustScroll();

            catchTabs();

            detectKeyboardActivity();

            logKeyboardActivity();
        }

        // check if the spellbook (outside of the code region) was clicked
        //      if so, we want to make it full screen
        if (Event.current.type == EventType.MouseDown)
        {
            Vector2 pos = Event.current.mousePosition;
            if (halfbook.getBookRect().Contains(pos) && !halfbook.getTextRect().Contains(pos) && !errorPanel.getErrorRect().Contains(pos) && !editorPanel.getEditorRect().Contains(pos))
            {
                spellbook.setNoCopyDisplay(true);
                spellbook.show(GameObject.Find("IDE"));
            }
        }

        // make it so that we can't click through to the game
        // NOTE: This must appear LAST in the OnGUI. Otherwise, other buttons won't work!
        GUI.Button(new Rect(0, 0, Screen.width, Screen.height), "", empty_style);
    }