Exemplo n.º 1
0
        static public bool draw_latlong_raster(latlong_class center, latlong_class latlong1, latlong_class latlong2, Vector2 offset, double zoom, double current_zoom, int resolution, Rect screen, Color color, int width)
        {
            // map_latlong_center
            bool    result  = true;
            Vector2 vector  = Mathw.latlong_to_pixel(latlong1, center, current_zoom, new Vector2(screen.width, screen.height));
            Vector2 vector2 = Mathw.latlong_to_pixel(latlong2, center, current_zoom, new Vector2(screen.width, screen.height));
            Vector2 vector3 = vector2 - vector;

            vector  += new Vector2(-offset.x, offset.y);
            vector2 += new Vector2(-offset.x, offset.y);
            double num  = Mathf.Pow(2, (float)(zoom - current_zoom));
            float  num2 = (float)(resolution / num);

            if (Mathf.Abs(Mathf.Round(vector3.x / num2) - vector3.x / num2) > 0.01f || Mathf.Abs(Mathf.Round(vector3.y / num2) - vector3.y / num2) > 0.01f)
            {
                result = false;
                color  = Color.red;
            }
            for (float num3 = vector.x; num3 < vector.x + vector3.x; num3 += num2)
            {
                Drawing_tc1.DrawLine(new Vector2(num3, vector.y), new Vector2(num3, vector2.y), color, width, false, screen);
            }
            for (float num4 = vector.y; num4 < vector.y + vector3.y; num4 += num2)
            {
                Drawing_tc1.DrawLine(new Vector2(vector.x, num4), new Vector2(vector2.x, num4), color, width, false, screen);
            }
            return(result);
        }
Exemplo n.º 2
0
        static public void drawText(Rect rect, string text, bool background, Color color, Color backgroundColor, float fontSize, bool bold, int mode)
        {
            Vector2   vector    = new Vector2();
            int       fontSize2 = GUI.skin.label.fontSize;
            FontStyle fontStyle = GUI.skin.label.fontStyle;
            Color     color2    = GUI.color;
            Vector2   size      = new Vector2();

            if (background)
            {
                GUI.color = backgroundColor;
                EditorGUI.DrawPreviewTexture(new Rect(vector.x, vector.y, size.x, size.y), tex2);
            }
            GUI.color = color;
            GUI.skin.label.fontSize = (int)fontSize;
            if (bold)
            {
                GUI.skin.label.fontStyle = FontStyle.Bold;
            }
            else
            {
                GUI.skin.label.fontStyle = FontStyle.Normal;
            }
            size   = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(text));
            vector = Mathw.calc_rect_allign(rect, size, mode);
            GUI.Label(new Rect(vector.x, vector.y, size.x, size.y), text);
            GUI.skin.label.fontSize  = fontSize2;
            GUI.skin.label.fontStyle = fontStyle;
            GUI.color = color2;
        }
Exemplo n.º 3
0
        static public void draw_arrow(Vector2 point1, int length, int length_arrow, float rotation, Color color, int width, Rect screen)
        {
            length_arrow = (int)(Mathf.Sqrt(2f) * length_arrow);
            Vector2 vector  = Mathw.calc_rotation_pixel(point1.x, point1.y - length, point1.x, point1.y, rotation);
            Vector2 pointB  = Mathw.calc_rotation_pixel(vector.x - length_arrow, vector.y - length_arrow, vector.x, vector.y, -180 + rotation);
            Vector2 pointB2 = Mathw.calc_rotation_pixel(vector.x + length_arrow, vector.y - length_arrow, vector.x, vector.y, 180 + rotation);

            Drawing_tc1.DrawLine(point1, vector, color, width, false, screen);
            Drawing_tc1.DrawLine(vector, pointB, color, width, false, screen);
            Drawing_tc1.DrawLine(vector, pointB2, color, width, false, screen);
        }
Exemplo n.º 4
0
        static public void draw_scale_grid(Rect rect, Vector2 offset, float zoom, float scale, Color color, int width, bool draw_center, Rect screen)
        {
            Vector2 vector = new Vector2(screen.width, screen.height) / 2 + offset;
            float   num2   = vector.x - rect.x;
            float   num3   = vector.y - rect.y;
            int     num4   = (int)(num2 / zoom);

            num4 = (int)(num2 - num4 * zoom);
            num4 = (int)(num4 + rect.x);
            int num5 = Mathw.calc_rest_value((vector.x - num4) / zoom, 10);

            if (num5 < 0)
            {
                num5 = -9 - num5;
            }
            else
            {
                num5 = 9 - num5;
            }
            int num7 = (int)(num3 / zoom);

            num7 = (int)(num3 - num7 * zoom);
            num7 = (int)(num7 + rect.y);
            for (float num8 = num4; num8 <= rect.xMax; num8 += zoom)
            {
                Drawing_tc1.DrawLine(new Vector2(num8, rect.y), new Vector2(num8, rect.yMax), color, width, false, screen);
                if (num5 > 9)
                {
                    num5 = 0;
                }
                num5++;
            }
            for (float num9 = num7; num9 <= rect.yMax; num9 += zoom)
            {
                Drawing_tc1.DrawLine(new Vector2(rect.x, num9), new Vector2(rect.xMax, num9), color, width, false, screen);
            }
            if (draw_center)
            {
                Drawing_tc1.DrawLine(new Vector2(vector.x, rect.y), new Vector2(vector.x, rect.yMax), color, width + 2, false, screen);
                Drawing_tc1.DrawLine(new Vector2(rect.x, vector.y), new Vector2(rect.xMax, vector.y), color, width + 2, false, screen);
            }
        }
Exemplo n.º 5
0
        static public bool drawText(Rect rect, edit_class edit, bool background, Color color, Color backgroundColor, float fontSize, bool bold, int mode)
        {
            Vector2   vector = new Vector2();
            int       fontSize2;
            FontStyle fontStyle;
            Color     color2 = GUI.color;
            Vector2   size   = new Vector2();

            if (background)
            {
                GUI.color = backgroundColor;
                EditorGUI.DrawPreviewTexture(new Rect(vector.x, vector.y, size.x, size.y), tex2);
            }
            GUI.color = color;
            if (!edit.edit)
            {
                fontSize2 = GUI.skin.label.fontSize;
                fontStyle = GUI.skin.label.fontStyle;
                GUI.skin.label.fontSize = (int)fontSize;
                if (bold)
                {
                    GUI.skin.label.fontStyle = FontStyle.Bold;
                }
                else
                {
                    GUI.skin.label.fontStyle = FontStyle.Normal;
                }
                size   = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(edit.default_text));
                vector = Mathw.calc_rect_allign(rect, size, mode);
                GUI.Label(new Rect(vector.x, vector.y, size.x, size.y), edit.default_text);
                GUI.skin.label.fontSize  = fontSize2;
                GUI.skin.label.fontStyle = fontStyle;
            }
            else
            {
                fontSize2 = GUI.skin.textField.fontSize;
                fontStyle = GUI.skin.textField.fontStyle;
                GUI.skin.textField.fontSize = (int)fontSize;
                if (bold)
                {
                    GUI.skin.textField.fontStyle = FontStyle.Bold;
                }
                else
                {
                    GUI.skin.textField.fontStyle = FontStyle.Normal;
                }
                size = GUI.skin.GetStyle("TextField").CalcSize(new GUIContent(edit.text));
                if (size.x < rect.width)
                {
                    size.x = rect.width;
                }
                size.x   += 10;
                vector    = Mathw.calc_rect_allign(rect, size, mode);
                edit.text = GUI.TextField(new Rect(vector.x, vector.y, size.x, size.y), edit.text);
                GUI.skin.textField.fontSize  = fontSize2;
                GUI.skin.textField.fontStyle = fontStyle;
            }
            if (Event.current.button == 0 && Event.current.clickCount == 2 && Event.current.type == 0 && new Rect(vector.x, vector.y, size.x, size.y).Contains(Event.current.mousePosition))
            {
                edit.edit = !edit.edit;
            }
            bool arg_330_0;

            if (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.Escape)
            {
                edit.edit = false;
                GUI.color = color2;
                arg_330_0 = true;
            }
            else
            {
                GUI.color = color2;
                arg_330_0 = false;
            }
            return(arg_330_0);
        }