Chaos Project

General => Electronic and Computer Section => Programming / Scripting / Web => Topic started by: nathmatt on March 11, 2011, 02:13:20 pm

Title: Visual C# Express 2010 - Battle Dome Config help
Post by: nathmatt on March 11, 2011, 02:13:20 pm
ok i have almost completely rebuilt my Battle Dome Config program but im not sure if i should build the terrain config the same way as i did in python or if there if a better way in visual C#
Title: Re: Visual C# Express 2010
Post by: Blizzard on March 11, 2011, 02:24:19 pm
Use what you prefer. It's entirely up to you. I personally would use C# because I like it more. It is easier to make a functional GUI with it and it's faster to work with.
Title: Re: Visual C# Express 2010
Post by: nathmatt on March 11, 2011, 05:25:48 pm
oh thats not what i ment the layout of such this
Spoiler: ShowHide
(http://img638.imageshack.us/img638/1519/screenshotzhg.png)


which represents these 2 codes

Terrains[1] = [M,X,Y,D]


and

def self.Terrains(id)
 case id
 when 1 then return [list of maps]
 end
end


what i meant was is there a more effeciant or ezer to custimize way of doing that in c# thats done in python but c# should allow me to create a smaller aplication considering all they might need the latest .net
Title: Re: Visual C# Express 2010
Post by: ForeverZer0 on March 11, 2011, 11:12:40 pm
Do you mean you want the C# equivilant of those two snippets?
Title: Re: Visual C# Express 2010
Post by: nathmatt on March 11, 2011, 11:13:44 pm
not realy just trying to figure out a better way to do it im thinking maybe a tree view but i can't figure out how to add more items to it
Title: Re: Visual C# Express 2010
Post by: ForeverZer0 on March 11, 2011, 11:19:51 pm
Use a List. Use this reference:
using System.Collections.Generics


Make a class or struct for Terrains, then you can initialize a list like this:
List<Terrain> terrains = new List();


Then you can manipulate it very much like a Ruby array.
terrains.Add(new Terrain(M, X, Y, D) // Substitue them values, obviously
terrains.RemoveAt(Index)
...etc, etc


Intelisense will help you with all the methods and what not.
Title: Re: Visual C# Express 2010
Post by: nathmatt on March 11, 2011, 11:24:05 pm
as for the aplication should i keep the same look ? as the 1 done in python
Title: Re: Visual C# Express 2010
Post by: ForeverZer0 on March 11, 2011, 11:25:08 pm
Let me go check it out. I honestly don't remember you posting it. Give me a few minutes....

EDIT:
Personally I would expand the size of the window and do away with the tabs. You can then simply have the generated script pop up in a dialog, or even have a SaveFileDialog pop up and save the text doc to a file.

If you want, I can upload you a copy of my CCTS Config solution so you can check out a few examples. One good thing if you do this in C#, you should be able to take the filesize of your app from 16 MB to probably less than 1 MB.
Title: Re: Visual C# Express 2010
Post by: nathmatt on March 11, 2011, 11:36:53 pm
yea thats y i was making it in c# because by using python all the moduls i used had to be included but in c most if not all the moduls are already there.

and sure pm me or post ur CCTS Config project

edit ok i see what you mean i like that idea better i have a c# related question if i wanted to access the MapInfos to get lists of the names, ids, width, and, height what would i need to do.
Title: Re: Visual C# Express 2010 - Battle Dome Config help
Post by: ForeverZer0 on March 12, 2011, 04:06:38 pm
Do you mean the .rxdata?
If so, that is a little more complicated. You would need to embed Ruby or IronRuby and have it dump the Marshalled data, setting the classes using an .rb file you have created to emulate RPG::MapInfos. Although embedding IronRuby in C# isn't overly complicated, this is kind of over-complicating a simple problem, and one that won't be too difficult for the user to enter themselves.

It would be far easier to just have your program make the user type it in, and then be able to save the settings. Serialization in C# is really easy, you can find some examples in the CCTS Config solution you got. To make it easier, include some methods to "batch" setup maps to reduce the pain-in-the-ass factor.
Title: Re: Visual C# Express 2010 - Battle Dome Config help
Post by: nathmatt on March 15, 2011, 12:03:44 pm
ok so i have a list of classes and im tring to get it to send my data from the class with a specific id som i have

public static int[] Get_info(int id)
        {
            int m = 0;
            int x = 0;
            int y = 0;
            foreach (TerrainInfo t in TerrainInfos)
            {
                if (t.ID == id)
                {
                    m = t.Mapid; x = t.X; y = t.Y; int[] terrain = new int[] { m, x, y };
                    return terrain;
                }
            }
            return null;
        }


and i am trying to set the value of the numeric control with the value returned

int id = listTerrains.SelectedIndex;
Array terrain = Utility.Get_info(id);
TerrainMap.Value = terrain.GetValue(0);

but it says im getting an object and not a decimal what am i doing wrong
Title: Re: Visual C# Express 2010 - Battle Dome Config help
Post by: Blizzard on March 15, 2011, 12:17:25 pm
Decimal is a special data type and is not the same as float. Use decimal.something to convert it. I can't remember now the name of the method.

I also suggest you use lambda expressions. :)