コード例 #1
0
        private static void RebuildUV(UIRenderData renderData, RenderOptions options)
        {
            Rect region            = options.spriteInfo.region;
            PoolList <Vector2> uvs = renderData.uvs;

            uvs.Add(new Vector2(region.x, region.yMax));
            uvs.Add(new Vector2(region.xMax, region.yMax));
            uvs.Add(new Vector2(region.xMax, region.y));
            uvs.Add(new Vector2(region.x, region.y));
            Vector2 value = Vector2.zero;

            if (options.flip.IsFlagSet(UISpriteFlip.FlipHorizontal))
            {
                value  = uvs[1];
                uvs[1] = uvs[0];
                uvs[0] = value;
                value  = uvs[3];
                uvs[3] = uvs[2];
                uvs[2] = value;
            }
            if (options.flip.IsFlagSet(UISpriteFlip.FlipVertical))
            {
                value  = uvs[0];
                uvs[0] = uvs[3];
                uvs[3] = value;
                value  = uvs[1];
                uvs[1] = uvs[2];
                uvs[2] = value;
            }
        }
コード例 #2
0
 private static void AddUVCoords(PoolList <Vector2> uvs, CharacterInfo glyph)
 {
     uvs.Add(glyph.uvTopLeft);
     uvs.Add(glyph.uvTopRight);
     uvs.Add(glyph.uvBottomRight);
     uvs.Add(glyph.uvBottomLeft);
 }
コード例 #3
0
        private static void RebuildColors(UIRenderData renderData, RenderOptions options)
        {
            Color32            item   = options.color.linear;
            PoolList <Color32> colors = renderData.colors;

            for (int i = 0; i < 4; i++)
            {
                colors.Add(item);
            }
        }
コード例 #4
0
        private static void AddTriangleIndices(PoolList <Vector3> verts, PoolList <int> triangles)
        {
            int count = verts.Count;

            int[] array = kTriangleIndices;
            for (int i = 0; i < array.Length; i++)
            {
                triangles.Add(count + array[i]);
            }
        }
コード例 #5
0
        private static void RebuildTriangles(UIRenderData renderData, RenderOptions options)
        {
            int            baseIndex = options.baseIndex;
            PoolList <int> triangles = renderData.triangles;

            triangles.EnsureCapacity(triangles.Count + kTriangleIndices.Length);
            for (int i = 0; i < kTriangleIndices.Length; i++)
            {
                triangles.Add(baseIndex + kTriangleIndices[i]);
            }
        }
コード例 #6
0
        private static Rect RebuildVertices(UIRenderData renderData, RenderOptions options)
        {
            PoolList <Vector3> vertices = renderData.vertices;
            int   baseIndex             = options.baseIndex;
            float x  = 0f;
            float y  = 0f;
            float x2 = Mathf.Ceil(options.size.x);
            float y2 = Mathf.Ceil(-options.size.y);

            vertices.Add(new Vector3(x, y, 0f) * options.pixelsToUnits);
            vertices.Add(new Vector3(x2, y, 0f) * options.pixelsToUnits);
            vertices.Add(new Vector3(x2, y2, 0f) * options.pixelsToUnits);
            vertices.Add(new Vector3(x, y2, 0f) * options.pixelsToUnits);
            Vector3 b = (options.offset * 10).RoundToInt() * options.pixelsToUnits / 10;

            for (int i = 0; i < 4; i++)
            {
                vertices[baseIndex + i] = (vertices[baseIndex + i] + b).Quantize(options.pixelsToUnits);
            }
            return(new Rect(vertices[0], vertices[2]));
        }
コード例 #7
0
 //文字を追加
 protected virtual void AddCharData(CharData data)
 {
     CharList.Add(data);
     PoolList.Add(data);
     parsingInfo.ClearOnNextChar();
 }
コード例 #8
0
        private static void RenderText(DynamicFontRenderer renderer, string text, Vector3 position, float rescale, UIRenderData renderData, float textScale, Color textColor, Color outlineColor)
        {
            var                uidynamicFont = (UIDynamicFont)renderer.font;
            float              size          = ((UIDynamicFont)renderer.font).baseline * textScale;
            FontStyle          style         = FontStyle.Normal;
            int                descent       = uidynamicFont.Descent * 2;
            int                ascent        = renderer.font.baseFont.ascent * 2;
            PoolList <Vector3> vertices      = renderData.vertices;
            PoolList <int>     triangles     = renderData.triangles;
            PoolList <Vector2> uvs           = renderData.uvs;
            PoolList <Color32> colors        = renderData.colors;
            float              x             = position.x;
            float              y             = position.y;

            renderData.material = uidynamicFont.material;
            Color color2 = ApplyOpacity(renderer, textColor);
            Color c      = color2;

            if (renderer.bottomColor != null)
            {
                c = ApplyOpacity(renderer, textColor);
            }
            for (int i = 0; i < text.Length; i++)
            {
                if (i > 0)
                {
                    x += renderer.characterSpacing * textScale;
                }
                if (uidynamicFont.baseFont.GetCharacterInfo(text[i], out CharacterInfo glyph, Mathf.CeilToInt(size) * 2, style))
                {
                    float   num3    = (glyph.maxY / 2f);
                    float   minX    = x + (glyph.minX / 2f);
                    float   maxY    = y + num3;
                    float   maxX    = minX + (glyph.glyphWidth * rescale / 2f);
                    float   minY    = maxY - (glyph.glyphHeight / 2f);
                    Vector3 vector  = new Vector3(minX, maxY) * renderer.pixelRatio;
                    Vector3 vector2 = new Vector3(maxX, maxY) * renderer.pixelRatio;
                    Vector3 vector3 = new Vector3(maxX, minY) * renderer.pixelRatio;
                    Vector3 vector4 = new Vector3(minX, minY) * renderer.pixelRatio;
                    if (renderer.shadow)
                    {
                        AddTriangleIndices(vertices, triangles);
                        Vector3 b = renderer.shadowOffset * renderer.pixelRatio;
                        vertices.Add(vector + b);
                        vertices.Add(vector2 + b);
                        vertices.Add(vector3 + b);
                        vertices.Add(vector4 + b);
                        Color   c2   = ApplyOpacity(renderer, renderer.shadowColor);
                        Color32 item = c2.linear;
                        colors.Add(item);
                        colors.Add(item);
                        colors.Add(item);
                        colors.Add(item);
                        AddUVCoords(uvs, glyph);
                    }
                    if (outlineColor != default)
                    {
                        for (int j = 0; j < kOutlineOffsets.Length; j++)
                        {
                            AddTriangleIndices(vertices, triangles);
                            Vector3 b2 = kOutlineOffsets[j] * renderer.outlineSize * renderer.pixelRatio;
                            vertices.Add(vector + b2);
                            vertices.Add(vector2 + b2);
                            vertices.Add(vector3 + b2);
                            vertices.Add(vector4 + b2);
                            Color   c3    = ApplyOpacity(renderer, outlineColor);
                            Color32 item2 = c3.linear;
                            colors.Add(item2);
                            colors.Add(item2);
                            colors.Add(item2);
                            colors.Add(item2);
                            AddUVCoords(uvs, glyph);
                        }
                    }
                    AddTriangleIndices(vertices, triangles);
                    vertices.Add(vector);
                    vertices.Add(vector2);
                    vertices.Add(vector3);
                    vertices.Add(vector4);
                    Color32 item3 = color2.linear;
                    Color32 item4 = c.linear;
                    colors.Add(item3);
                    colors.Add(item3);
                    colors.Add(item4);
                    colors.Add(item4);
                    AddUVCoords(uvs, glyph);
                    x += glyph.maxX / 2f * rescale;
                }
            }
        }
コード例 #9
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            initializing = true;
            headerLogger.Info("");

            // Setup Loading text
            logger.Info("Loading...");
            LoadingText = "Loading...";

            // Check for Updates
            LoadingText = "Checking for Updates...";
            logger.Info("Checking for Updates...");
            try
            {
                // TODO: Make it so it applies major updates immediately
                // TODO: Change this to use a URL instead
                using (UpdateManager manager = new UpdateManager(@"D:\Projects\VS Projects\EasyGarlic\EasyGarlic\Releases"))
                {
                    await manager.UpdateApp();
                }
            }
            catch (Exception error)
            {
                // Don't show this error in debug mode because it's always gonna happen
                if (error.Message == "Update.exe not found, not a Squirrel-installed app?")
                {
#if !DEBUG
                    logger.Error("Updater: " + error);
                    LoadingText = "Could not check for updates.";
#endif
                }
                else
                {
                    logger.Error("Updater: " + error);
                    LoadingText = "Could not check for updates.";
                }
            }

            LoadingText = "Loading...";

            bool skipAPI = false;

            // Loading progress for the Linker
            Progress <ProgressReport> loadingProgress = new Progress <ProgressReport>((data) =>
            {
                LoadingText = data.message;

                // If there was an error
                if (data.error != null)
                {
                    // Problem while fetching API data
                    if (data.error.GetType() == typeof(System.Net.WebException))
                    {
                        logger.Error(data.message);
                        logger.Error(data.error);
                        skipAPI          = true;
                        ConnectionErrors = true;
                    }
                }
            });

            // Setup Managers & Linkers
            linker = new Linker();
            await linker.Setup(loadingProgress);

            // Start Output Window
            if (linker.minerManager.data.openConsole)
            {
                OpenDebugConsole();
            }

            // Get Pool List
            logger.Info("Loading Pool List...");
            PoolList = new List <PoolData>();
            // If there were no issues contacting Online Data
            if (!skipAPI)
            {
                // Fetch Pool List
                try
                {
                    PoolList = new List <PoolData>(await linker.networkManager.GetPoolData(linker.networkManager.data.pools));
                }
                // If there were issues contacting Pool List
                catch (System.Net.WebException err)
                {
                    // Report error
                    ((IProgress <ProgressReport>)loadingProgress).Report(new ProgressReport("Could not load Pool Data at " + linker.networkManager.data.pools, err));

                    // Create an empty list
                    PoolList = new List <PoolData>();
                }
            }
            // Add Custom item to the Pool List
            PoolList.Add(PoolData.Custom);

            // Select Pool List Item if LocalData.savedPool is set
            if (linker.minerManager.data.savedPool != null)
            {
                PoolData saved = linker.minerManager.data.savedPool;
                int      index = saved.id;

                // If that object is actually a custom
                if (saved.name == "Custom")
                {
                    // Use it as a custom (last index)
                    index = PoolList.Count - 1;
                    PoolList[index].stratum = saved.stratum;
                }

                PoolListIndex = index;
                logger.Info("Using saved pool: " + saved);
            }

            // Check Saved Address
            AddressInput = linker.minerManager.GetSavedAddress();
            logger.Info("Using saved address: " + AddressInput);

            logger.Info("Miners Installed: " + String.Join(", ", linker.minerManager.data.installed.Keys.ToArray()));

            // Set Default values
            ReadyToShow    = true;
            ShowStats      = false;
            ShowStop       = false;
            EnableAdvanced = true;
            ShowCustomPool = false;
            InfoText       = "Ready!";

            // Tell it we're done
            logger.Info("Finished Loading.");
            initializing = false;
        }
コード例 #10
0
        private void UpdateNames()
        {
            UIFontManager.Invalidate(this.m_properties.m_areaNameFont);
            namesModifiedField.SetValue(this, false);
            UIRenderData destination  = UIRenderData.Obtain();
            UIRenderData uiRenderData = UIRenderData.Obtain();

            try
            {
                destination.Clear();
                uiRenderData.Clear();
                PoolList <Vector3> vertices1  = uiRenderData.vertices;
                PoolList <Vector3> normals1   = uiRenderData.normals;
                PoolList <Color32> colors1    = uiRenderData.colors;
                PoolList <Vector2> uvs1       = uiRenderData.uvs;
                PoolList <int>     triangles1 = uiRenderData.triangles;
                PoolList <Vector3> vertices2  = destination.vertices;
                PoolList <Vector3> normals2   = destination.normals;
                PoolList <Color32> colors2    = destination.colors;
                PoolList <Vector2> uvs2       = destination.uvs;
                PoolList <int>     triangles2 = destination.triangles;
                for (int district = 1; district < 128; ++district)
                {
                    if (this.m_districts.m_buffer[district].m_flags != District.Flags.None)
                    {
                        string text = this.GetDistrictName(district) + "\n";
                        PositionData <DistrictPolicies.Policies>[] orderedEnumData = Utils.GetOrderedEnumData <DistrictPolicies.Policies>();
                        for (int index = 0; index < orderedEnumData.Length; ++index)
                        {
                            if (this.IsDistrictPolicySet(orderedEnumData[index].enumValue, (byte)district))
                            {
                                string str = "IconPolicy" + orderedEnumData[index].enumName;
                                text = text + "<sprite " + str + "> ";
                            }
                        }
                        if (text != null)
                        {
                            int count1 = normals2.Count;
                            int count2 = normals1.Count;
                            using (UIFontRenderer renderer = this.m_properties.m_areaNameFont.ObtainRenderer())
                            {
                                UIDynamicFont.DynamicFontRenderer dynamicFontRenderer = renderer as UIDynamicFont.DynamicFontRenderer;
                                if (dynamicFontRenderer != null)
                                {
                                    dynamicFontRenderer.spriteAtlas  = this.m_properties.m_areaIconAtlas;
                                    dynamicFontRenderer.spriteBuffer = uiRenderData;
                                }
                                float x1 = 450f;
                                renderer.defaultColor  = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)64);
                                renderer.textScale     = 2f;
                                renderer.pixelRatio    = 1f;
                                renderer.processMarkup = true;
                                renderer.multiLine     = true;
                                renderer.wordWrap      = true;
                                renderer.textAlign     = UIHorizontalAlignment.Center;
                                renderer.maxSize       = new Vector2(x1, 900f);
                                renderer.shadow        = false;
                                renderer.shadowColor   = (Color32)Color.black;
                                renderer.shadowOffset  = Vector2.one;
                                Vector2 vector2 = renderer.MeasureString(text);
                                float   x2      = vector2.x;
                                if ((double)vector2.x > (double)x1)
                                {
                                    x2 = x1 + (float)(((double)vector2.x - (double)x1) * 0.5);
                                    x1 = vector2.x;
                                    renderer.maxSize = new Vector2(x1, 900f);
                                    vector2          = renderer.MeasureString(text);
                                }
                                this.m_districts.m_buffer[district].m_nameSize = vector2;
                                vertices2.Add(new Vector3(-x2, -vector2.y, 1f));
                                vertices2.Add(new Vector3(-x2, vector2.y, 1f));
                                vertices2.Add(new Vector3(x2, vector2.y, 1f));
                                vertices2.Add(new Vector3(x2, -vector2.y, 1f));
                                colors2.Add(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
                                colors2.Add(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
                                colors2.Add(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
                                colors2.Add(new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue));
                                uvs2.Add(new Vector2(-1f, -1f));
                                uvs2.Add(new Vector2(-1f, 1f));
                                uvs2.Add(new Vector2(1f, 1f));
                                uvs2.Add(new Vector2(1f, -1f));
                                triangles2.Add(vertices2.Count - 4);
                                triangles2.Add(vertices2.Count - 3);
                                triangles2.Add(vertices2.Count - 1);
                                triangles2.Add(vertices2.Count - 1);
                                triangles2.Add(vertices2.Count - 3);
                                triangles2.Add(vertices2.Count - 2);
                                renderer.vectorOffset = new Vector3(x1 * -0.5f, vector2.y * 0.5f, 0.0f);
                                renderer.Render(text, destination);
                            }
                            int     count3  = vertices2.Count;
                            int     count4  = normals2.Count;
                            Vector3 vector3 = this.m_districts.m_buffer[district].m_nameLocation;
                            for (int index = count1; index < count4; ++index)
                            {
                                normals2[index] = vector3;
                            }
                            for (int index = count4; index < count3; ++index)
                            {
                                normals2.Add(vector3);
                            }
                            int count5 = vertices1.Count;
                            int count6 = normals1.Count;
                            for (int index = count2; index < count6; ++index)
                            {
                                normals1[index] = vector3;
                            }
                            for (int index = count6; index < count5; ++index)
                            {
                                normals1.Add(vector3);
                            }
                        }
                    }
                }
                if ((Mesh)nameMeshField.GetValue(this) == null)
                {
                    nameMeshField.SetValue(this, new Mesh());
                }
                var nameMesh = (Mesh)nameMeshField.GetValue(this);
                nameMesh.Clear();
                nameMesh.vertices  = vertices2.ToArray();
                nameMesh.normals   = normals2.ToArray();
                nameMesh.colors32  = colors2.ToArray();
                nameMesh.uv        = uvs2.ToArray();
                nameMesh.triangles = triangles2.ToArray();
                //begin mod
                nameMesh.bounds = new Bounds(Vector3.zero, new Vector3(GRID * 19.2f, 1024f, GRID * 19.2f));
                //end mod
                if ((Mesh)iconMeshField.GetValue(this) == null)
                {
                    iconMeshField.SetValue(this, new Mesh());
                }
                var iconMesh = (Mesh)iconMeshField.GetValue(this);
                iconMesh.Clear();
                iconMesh.vertices  = vertices1.ToArray();
                iconMesh.normals   = normals1.ToArray();
                iconMesh.colors32  = colors1.ToArray();
                iconMesh.uv        = uvs1.ToArray();
                iconMesh.triangles = triangles1.ToArray();
                //begin mod
                iconMesh.bounds = new Bounds(Vector3.zero, new Vector3(GRID * 19.2f, 1024f, GRID * 19.2f));
                //end mod
            }
            finally
            {
                destination.Release();
                uiRenderData.Release();
            }
        }