コード例 #1
0
ファイル: DesignerForm.cs プロジェクト: outrera/game-creator
        public DesignerForm()
        {
            InitializeComponent();
            PopulateNewResourceTree();
            //
            //ScriptResourceView res = new ScriptResourceView(Program.ScriptIncremental);
            //Program.Scripts.Add(Program.ScriptIncremental++, res);
            //res.Code = Properties.Resources.scr_main;
            //AddResource(Scripts.Node, res, "scr_main", -1, false, false, false);
            //
            SpriteResourceView spr = new SpriteResourceView(Program.SpriteIncremental);

            Program.Sprites.Add(Program.SpriteIncremental++, spr);
            //spr.SubImages = new Bitmap[] { new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb) };
            //Graphics.FromImage(spr.SubImages.First()).Clear(Color.Red);
            using (Bitmap temp = Properties.Resources.Earth) // make temp a temporary copy
            {
                spr.Animation = new FrameBasedAnimation(temp, false, false, false);
            }
            AddResource(Sprites.Node, spr, "spr_earth", -1, false, false, false);
            //
            ObjectResourceView obj = new ObjectResourceView(Program.ObjectIncremental);

            Program.Objects.Add(Program.ObjectIncremental++, obj);
            obj.Sprite = 0;
            obj.events.Add(new ObjectEvent(EventType.Create, 0));
            // I'm likin' linq! First time using it ^^
            ActionDefinition setVariable =
                (from lib in Program.Library
                 where lib.TabCaption == "control"
                 select lib.Actions into actions
                 from action in actions
                 where action.Name == "Variable"
                 select action).First();

            // yea let's use our setVariable action we found with linq :)
            obj.events[0].Actions.Add(new ActionDeclaration(setVariable));
            obj.events[0].Actions[0].Arguments[0] = "image_speed";
            obj.events[0].Actions[0].Arguments[1] = ".5";
            obj.events[0].Actions.Add(new ActionDeclaration(setVariable));
            obj.events[0].Actions[1].Arguments[0] = "image_xscale";
            obj.events[0].Actions[1].Arguments[1] = "3.2";
            obj.events[0].Actions.Add(new ActionDeclaration(setVariable));
            obj.events[0].Actions[2].Arguments[0] = "image_yscale";
            obj.events[0].Actions[2].Arguments[1] = "2.4";
            //obj.events[0].Actions.Add(new ActionDeclaration(Program.Library[3].Actions[20])); // 'Execute Code' action in 'Control' lib, by index
            //obj.events[0].Actions[1].Arguments[0] = "show_message(\r\n \"hspeed: \" +	string(hspeed) +  \r\n \"#vspeed: \" +	string(vspeed) + \r\n \"#speed: \" +	string(speed) + \r\n \"#dir: \" +	string(direction) \r\n);";
            AddResource(Objects.Node, obj, "object0", -1, false, false, false);
            //
            TreeNode         RoomsNode = treeView1.Nodes["Rooms"];
            RoomResourceView res1      = new RoomResourceView(Program.RoomIncremental);

            res1.CreationCode = "instance_create(0, 0, object0)";//\r\nscr_main();";
            Program.Rooms.Add(Program.RoomIncremental, res1);
            AddResource(Rooms.Node, res1, "room" + Program.RoomIncremental++, -1, false, false, false);
        }
コード例 #2
0
 public ActionDeclaration(ActionDefinition kind, System.Windows.Forms.ListBox lb, int li)
 {
     Kind      = kind;
     Relative  = false;
     Not       = false;
     AppliesTo = -1;
     Indent    = 0;
     ListBox   = lb;
     ListIndex = li;
     Arguments = new List <string>();
     for (int i = 0; i < Kind.ArgumentCount; i++)
     {
         Arguments.Add(Kind.Arguments[i].DefaultValue);
     }
 }
コード例 #3
0
        public static ActionLibrary Load(System.IO.Stream s)
        {
            ActionLibrary lib = new ActionLibrary();

            System.IO.BinaryReader br = new System.IO.BinaryReader(s, Encoding.ASCII);
            lib.GameMakerVersion = br.ReadInt32();
            bool gm5 = lib.GameMakerVersion == 500;

            lib.TabCaption              = new string(br.ReadChars(br.ReadInt32()));
            lib.LibraryID               = br.ReadInt32();
            lib.Author                  = new string(br.ReadChars(br.ReadInt32()));
            lib.Version                 = br.ReadInt32();
            lib.LastChanged             = new DateTime(1899, 12, 30).AddDays(br.ReadDouble());
            lib.Info                    = new string(br.ReadChars(br.ReadInt32()));
            lib.InitializationCode      = new string(br.ReadChars(br.ReadInt32()));
            lib.AdvancedModeOnly        = br.ReadInt32() == 0 ? false : true;
            lib.ActionNumberIncremental = br.ReadInt32();
            for (int i = br.ReadInt32(); i > 0; i--)
            {
                int ver            = br.ReadInt32();
                ActionDefinition a = new ActionDefinition(lib, new string(br.ReadChars(br.ReadInt32())), br.ReadInt32());
                a.GameMakerVersion = ver;
                int size = br.ReadInt32();
                a.OriginalImage = new byte[size];
                br.Read(a.OriginalImage, 0, size);
                System.IO.MemoryStream ms = new System.IO.MemoryStream(a.OriginalImage);
                System.Drawing.Bitmap  b  = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(ms);
                a.Image = new System.Drawing.Bitmap(24, 24, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                using (var g = System.Drawing.Graphics.FromImage(a.Image))
                {
                    g.DrawImage(b, new System.Drawing.Rectangle(0, 0, b.Width, b.Height));
                }
                if (b.PixelFormat != System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                {
                    ((System.Drawing.Bitmap)a.Image).MakeTransparent(b.GetPixel(0, b.Height - 1));
                }
                ms.Close();
                b.Dispose();
                a.Hidden         = br.ReadInt32() == 0 ? false : true;
                a.Advanced       = br.ReadInt32() == 0 ? false : true;
                a.RegisteredOnly = ver == 500 || (br.ReadInt32() == 0) ? false : true;
                a.Description    = new string(br.ReadChars(br.ReadInt32()));
                a.ListText       = new string(br.ReadChars(br.ReadInt32()));
                a.HintText       = new string(br.ReadChars(br.ReadInt32()));
                a.Kind           = (ActionKind)br.ReadInt32();
                a.InterfaceKind  = (ActionInferfaceKind)br.ReadInt32();
                a.IsQuestion     = br.ReadInt32() == 0 ? false : true;
                a.ShowApplyTo    = br.ReadInt32() == 0 ? false : true;
                a.ShowRelative   = br.ReadInt32() == 0 ? false : true;
                a.ArgumentCount  = br.ReadInt32();
                int count = br.ReadInt32();
                if (a.Arguments.Length != count)
                {
                    a.Arguments = new ActionArgument[count];
                }
                for (int j = 0; j < count; j++)
                {
                    a.Arguments[j]              = new ActionArgument();
                    a.Arguments[j].Caption      = new string(br.ReadChars(br.ReadInt32()));
                    a.Arguments[j].Type         = (ActionArgumentType)br.ReadInt32();
                    a.Arguments[j].DefaultValue = new string(br.ReadChars(br.ReadInt32()));
                    a.Arguments[j].Menu         = new string(br.ReadChars(br.ReadInt32()));
                }
                a.ExecutionType = (ActionExecutionType)br.ReadInt32();
                a.FunctionName  = new string(br.ReadChars(br.ReadInt32()));
                a.Code          = new string(br.ReadChars(br.ReadInt32()));
                lib.Actions.Add(a);
            }
            //Hmm...
            //ActionDefinition d = new ActionDefinition(lib);
            //d.Description = "Font...";
            //d.ArgumentCount = 1;
            //d.Arguments[0] = new ActionArgument();
            //d.Arguments[0].Type = ActionArgumentType.FontString;
            //d.ListText = "@0";
            //lib.Actions.Add(d);
            //d.Arguments[0].DefaultValue = "\"Times New Roman\",10,0,0,0,0,0";
            return(lib);
        }
コード例 #4
0
 public ActionDeclaration(ActionDefinition kind) : this(kind, null, -1)
 {
 }