예제 #1
0
        private void buttonOpenMap_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(LastOpenLocation))
            {
                openMapDialog.InitialDirectory = LastOpenLocation;
            }

            DialogResult result = openMapDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                LastOpenLocation = Path.GetDirectoryName(openMapDialog.FileName);

                Map.Clear();
                gridProblems.Rows.Clear();
                Problem.Problems.Clear();
                LuaMap.LoadMap(openMapDialog.FileName);

                Map.Path = openMapDialog.FileName;

                Program.Camera.ResetCamera();
                Program.main.UpdateProblems();
                Renderer.InvalidateMeshData();
                Renderer.InvalidateView();
                Renderer.Invalidate();
            }
        }
예제 #2
0
        private static void ParseSalvageType(string path)
        {
            lua = new Lua();
            lua.RegisterFunction("StartSalvageConfig", null, typeof(HWData).GetMethod("StartSalvageConfig"));
            lua.DoFile(path);

            string name = Path.GetFileNameWithoutExtension(path).ToLower();

            float   pixelSize     = 1;
            float   resourceValue = 0;
            Vector4 pixelColor    = Vector4.Zero;

            foreach (KeyValuePair <object, object> de in salvageConfig)
            {
                switch (de.Key.ToString())
                {
                case "pixelSize":
                    string text = de.Value.ToString();
                    text      = text.Replace(",", ".");
                    pixelSize = float.Parse(text, InvariantCulture);
                    break;

                case "resourceValue":
                    text          = de.Value.ToString();
                    text          = text.Replace(",", ".");
                    resourceValue = float.Parse(text, InvariantCulture);
                    break;

                case "pixelColour":
                    pixelColor = LuaMap.LuaTableToVector4((LuaTable)de.Value);
                    break;
                }
            }

            SalvageType existingType = null;

            foreach (SalvageType type in SalvageType.SalvageTypes)
            {
                if (type.Name == name)
                {
                    existingType = type;
                    break;
                }
            }

            //Check if a type with that name already exists (because of multiple data paths)
            if (existingType == null)
            {
                new SalvageType(name, pixelSize, resourceValue, pixelColor);
            }
            else
            {
                //Overwrite existing style
                existingType.Name          = name;
                existingType.PixelSize     = pixelSize;
                existingType.ResourceValue = resourceValue;
                existingType.PixelColor    = pixelColor;
            }
        }
예제 #3
0
        private static void ParseAsteroidType(string path)
        {
            lua = new Lua();
            Type classType = typeof(HWData);

            lua.RegisterFunction("StartAsteroidConfig", null, classType.GetMethod("StartAsteroidConfig"));
            lua.RegisterFunction("setCollisionDamageToModifier", null, classType.GetMethod("SetCollisionDamageToModifier"));
            lua.RegisterFunction("setCollisionDamageFromModifier", null, classType.GetMethod("SetCollisionDamageFromModifier"));
            lua.RegisterFunction("SpawnAsteroidOnDeath", null, classType.GetMethod("SpawnAsteroidOnDeath"));
            lua.RegisterFunction("resourceAttackMode", null, classType.GetMethod("ResourceAttackMode"));
            lua.DoFile(path);

            string name = Path.GetFileNameWithoutExtension(path).ToLower();

            Vector4 pixelColor    = Vector4.Zero;
            float   resourceValue = 0;

            foreach (KeyValuePair <object, object> de in asteroidConfig)
            {
                switch (de.Key.ToString())
                {
                case "pixelColour":
                    pixelColor = LuaMap.LuaTableToVector4((LuaTable)de.Value);
                    break;

                case "resourceValue":
                    string text = de.Value.ToString();
                    text          = text.Replace(",", ".");
                    resourceValue = float.Parse(text, InvariantCulture);
                    break;
                }
            }

            AsteroidType existingType = null;

            foreach (AsteroidType type in AsteroidType.AsteroidTypes)
            {
                if (type.Name == name)
                {
                    existingType = type;
                    break;
                }
            }

            //Check if a type with that name already exists (because of multiple data paths)
            if (existingType == null)
            {
                new AsteroidType(name, pixelColor, resourceValue);
            }
            else
            {
                //Overwrite existing style
                existingType.Name          = name;
                existingType.PixelColor    = pixelColor;
                existingType.ResourceValue = resourceValue;
            }
        }
예제 #4
0
        private void buttonExecute_Click(object sender, EventArgs e)
        {
            boxErrors.Clear();

            string[] errors = LuaMap.ExecuteCode(boxCode.Text);

            foreach (string error in errors)
            {
                boxErrors.AppendText(error + "\n");
            }
        }
예제 #5
0
        private static void ParseCloudType(string path)
        {
            lua = new Lua();
            lua.RegisterFunction("StartCloudConfig", null, typeof(HWData).GetMethod("StartCloudConfig"));

            /*lua.RegisterFunction("setCollisionDamageToModifier", this, GetType().GetMethod("SetCollisionDamageToModifier"));
             * lua.RegisterFunction("setCollisionDamageFromModifier", this, GetType().GetMethod("SetCollisionDamageFromModifier"));
             * lua.RegisterFunction("SpawnAsteroidOnDeath", this, GetType().GetMethod("SpawnAsteroidOnDeath"));
             * lua.RegisterFunction("resourceAttackMode", this, GetType().GetMethod("ResourceAttackMode"));*/
            lua.DoFile(path);

            string name = Path.GetFileNameWithoutExtension(path).ToLower();

            Vector4 pixelColor = Vector4.Zero;

            foreach (KeyValuePair <object, object> de in cloudConfig)
            {
                switch (de.Key.ToString())
                {
                case "pixelColour":
                    pixelColor = LuaMap.LuaTableToVector4((LuaTable)de.Value);
                    break;
                }
            }

            CloudType existingType = null;

            foreach (CloudType type in CloudType.CloudTypes)
            {
                if (type.Name == name)
                {
                    existingType = type;
                    break;
                }
            }

            //Check if a type with that name already exists (because of multiple data paths)
            if (existingType == null)
            {
                new CloudType(name, pixelColor);
            }
            else
            {
                //Overwrite existing style
                existingType.Name       = name;
                existingType.PixelColor = pixelColor;
            }
        }
예제 #6
0
        private void buttonSaveMap_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(LastSaveLocation))
            {
                saveMapDialog.InitialDirectory = LastSaveLocation;
            }

            DialogResult result = saveMapDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                LastSaveLocation = Path.GetDirectoryName(saveMapDialog.FileName);

                LuaMap.SaveMap(saveMapDialog.FileName);
                Map.Path = saveMapDialog.FileName;
            }
        }
예제 #7
0
        public void glControl_Load(object sender, EventArgs e)
        {
            Log.WriteLine("Initializing...");

            Texture.Init();
            Importer.Init();
            Renderer.Init();

            HWData.ParseDataPaths();

            Background.LoadBackgroundFades();

            Creation.Init();
            Selection.Init();

            LuaMap.SetupInterpreter();

            Application.Idle += glControl_Update;
            Program.DeltaCounter.Start();
            FPSCounter.LabelFPS = labelFPS;
            Loaded = true;

            gridProblems.RowTemplate.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            gridProblems.DefaultCellStyle.WrapMode             = DataGridViewTriState.True;
            gridProblems.Columns[0].DefaultCellStyle.WrapMode  = DataGridViewTriState.True;

            this.WindowState = Settings.LastWindowState;
            this.Location    = Settings.LastWindowLocation;
            this.Size        = Settings.LastWindowSize;

            Map.Clear();
            Program.Camera.ResetCamera();

            if (Updater.CheckForUpdatesOnStart)
            {
                Updater.CheckForUpdates();
            }

            Program.main.UpdateProblems();
            Renderer.InvalidateMeshData();
            Renderer.InvalidateView();
            Renderer.Invalidate();
        }