void Initialize(Player player, Character actor, FieldSlot targetSlot, Attack attack) { _player = player; _actor = actor; _targetSlot = targetSlot; _attack = attack; }
private void InitFields(int count) { for (int i = 0; i < count; i++) { _fields[i] = new FieldSlot(null); } }
public static AttackCommand Create(Player player, Character actor, FieldSlot targetSlot, Attack attack) { var attackCommand = new GameObject("AttackCommand").AddComponent <AttackCommand>(); attackCommand.Initialize(player, actor, targetSlot, attack); return(attackCommand); }
public FieldSlotViewModel(OptionGame options) { FieldSlot fieldSlot = new FieldSlot(options.Count, options.BeginRange, options.EndRange); foreach (var it in fieldSlot.Numbers) { var np = new SlotViewModel(it); Add(np); } }
public override Slot CreateSlot(Slot instance) { var sym = SymbolTable.IdToString(_name); Slot s = new FieldSlot(instance, _storageType.GetField(sym)); if (_type != s.Type) { s = new CastSlot(s, _type); } return s; }
private void UpdateLabel(EditorTrackInfo track, FieldSlot slot) { Label label = slot.Label as Label; if (label != null && slot.LabelClosure != null) { string value = slot.LabelClosure(track, slot.Label); label.TextWithMnemonic = value ?? String.Empty; } }
private void UpdateConstantProperties() { foreach (Vector2 letterPos in this.letters) { FieldSlot fSlot = fieldSlots[(int)letterPos.x, (int)letterPos.y]; string name = fSlot.GetText(); string col = fSlot.GetColor(); string shape = fSlot.GetShape(); Constant c = this.constants[name]; c.properties.Clear(); if (shape.Length > 0) { c.properties.Add(shape); if (col.Length > 0) { c.properties.Add(col); } } } }
public void AssignSlot(FieldSlot slot) { Slot = slot; }
static void GenerateFields(object fields, string n, RecordTypeDescriptor rtd, TypeGen tg, object fieldtypes) { object[] f = RequiresNotNull <object[]>(fields); object[] ftypes = RequiresNotNull <object[]>(fieldtypes); List <FieldDescriptor> rtd_fields = new List <FieldDescriptor>(); for (int i = 0; i < f.Length; i++) { Cons c = (Cons)f[i]; Type t = ClrGenerator.ExtractTypeInfo(List(SymbolTable.StringToObject("quote"), ftypes[i])); if (t == null) { ClrGenerator.ClrSyntaxError("GenerateFields", "type not found", ftypes[i]); } string fname = SymbolTable.IdToString(RequiresNotNull <SymbolId>(Second(c))); // we use standard names here, they will be mapped to the given names string aname = n + "-" + fname; string mname = n + "-" + fname + "-set!"; var fd = new FieldDescriptor { Name = fname }; FieldAttributes fattrs = FieldAttributes.Public | FieldAttributes.InitOnly; if (c.car == SymbolTable.StringToObject("mutable")) { fd.mutable = true; fattrs &= ~FieldAttributes.InitOnly; } FieldSlot s = tg.AddField(t, fname, fattrs) as FieldSlot; fd.field = s.Field; PropertyBuilder pi = tg.TypeBuilder.DefineProperty(fname, PropertyAttributes.None, t, new Type[0]); // accesor MethodBuilder ab = tg.TypeBuilder.DefineMethod(aname, MethodAttributes.Public | MethodAttributes.Static, t, new Type[] { tg.TypeBuilder }); ab.DefineParameter(1, ParameterAttributes.None, n); ILGenerator agen = ab.GetILGenerator(); agen.Emit(OpCodes.Ldarg_0); //agen.Emit(OpCodes.Castclass, tg.TypeBuilder); agen.Emit(OpCodes.Ldfld, fd.field); agen.Emit(OpCodes.Ret); fd.accessor = ab; pi.SetGetMethod(ab); // mutator if (fd.mutable) { MethodBuilder mb = tg.TypeBuilder.DefineMethod(mname, MethodAttributes.Public | MethodAttributes.Static, typeof(object), new Type[] { tg.TypeBuilder, t }); mb.DefineParameter(1, ParameterAttributes.None, n); ILGenerator mgen = mb.GetILGenerator(); mgen.Emit(OpCodes.Ldarg_0); //mgen.Emit(OpCodes.Castclass, tg.TypeBuilder); mgen.Emit(OpCodes.Ldarg_1); mgen.Emit(OpCodes.Stfld, fd.field); mgen.Emit(OpCodes.Ldsfld, Compiler.Generator.Unspecified); mgen.Emit(OpCodes.Ret); fd.mutator = mb; pi.SetSetMethod(mb); } rtd_fields.Add(fd); } rtd.fields = rtd_fields.ToArray(); }
public void RemoveField(FieldSlot slot) { field_slots.Remove(slot); }
public FieldSlot AddField(Box parent, Widget label, Widget field, string syncTooltip, FieldLabelClosure labelClosure, FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldValueClosure syncClosure, FieldOptions options) { var editor_field = field as IEditorField; if (editor_field != null && dialog.Mode == EditorMode.View) { editor_field.SetAsReadOnly(); } FieldSlot slot = new FieldSlot(); slot.Parent = parent; slot.Label = label; slot.Field = field; slot.LabelClosure = labelClosure; slot.ReadClosure = readClosure; slot.WriteClosure = writeClosure; slot.SyncClosure = syncClosure; if (MultipleTracks && (options & FieldOptions.NoSync) == 0) { slot.Sync = delegate { dialog.ForeachNonCurrentTrack(delegate(EditorTrackInfo track) { (slot.SyncClosure ?? slot.WriteClosure)(track, slot.Field); }); }; } if (MultipleTracks && (options & FieldOptions.NoSync) == 0 && (options & FieldOptions.NoShowSync) == 0) { slot.SyncButton = new SyncButton(); if (syncTooltip != null) { TooltipSetter.Set(tooltip_host, slot.SyncButton, syncTooltip); } slot.SyncButton.Clicked += delegate { slot.Sync(); }; } Table table = new Table(1, 1, false); table.ColumnSpacing = 1; table.Attach(field, 0, 1, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0); if (editor_field != null) { editor_field.Changed += delegate { if (CurrentTrack != null) { slot.WriteClosure(CurrentTrack, slot.Field); } }; } if (slot.SyncButton != null) { table.Attach(slot.SyncButton, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0); } if (label != null) { if (label is Label) { ((Label)label).MnemonicWidget = field; } table.Attach(label, 0, table.NColumns, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); } table.ShowAll(); if ((options & FieldOptions.Shrink) == 0) { slot.Container = table; parent.PackStart(table, false, false, 0); } else { HBox shrink = new HBox(); shrink.Show(); slot.Container = shrink; shrink.PackStart(table, false, false, 0); parent.PackStart(shrink, false, false, 0); } field_slots.Add(slot); return(slot); }
private void UpdateLabel (EditorTrackInfo track, FieldSlot slot) { Label label = slot.Label as Label; if (label != null && slot.LabelClosure != null) { string value = slot.LabelClosure (track, slot.Label); label.TextWithMnemonic = value ?? String.Empty; } }
public void RemoveField (FieldSlot slot) { field_slots.Remove (slot); }
public FieldSlot AddField (Box parent, Widget label, Widget field, string syncTooltip, FieldLabelClosure labelClosure, FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldValueClosure syncClosure, FieldOptions options) { var editor_field = field as IEditorField; if (editor_field != null && dialog.Mode == EditorMode.View) { editor_field.SetAsReadOnly (); } FieldSlot slot = new FieldSlot (); slot.Parent = parent; slot.Label = label; slot.Field = field; slot.LabelClosure = labelClosure; slot.ReadClosure = readClosure; slot.WriteClosure = writeClosure; slot.SyncClosure = syncClosure; if (MultipleTracks && (options & FieldOptions.NoSync) == 0) { slot.Sync = delegate { dialog.ForeachNonCurrentTrack (delegate (EditorTrackInfo track) { (slot.SyncClosure ?? slot.WriteClosure) (track, slot.Field); }); }; } if (MultipleTracks && (options & FieldOptions.NoSync) == 0 && (options & FieldOptions.NoShowSync) == 0) { slot.SyncButton = new SyncButton (); if (syncTooltip != null) { TooltipSetter.Set (tooltip_host, slot.SyncButton, syncTooltip); } slot.SyncButton.Clicked += delegate { slot.Sync (); }; } Table table = new Table (1, 1, false); table.ColumnSpacing = 1; table.Attach (field, 0, 1, 1, 2, AttachOptions.Expand | AttachOptions.Fill, AttachOptions.Fill, 0, 0); if (editor_field != null) { editor_field.Changed += delegate { if (CurrentTrack != null) { slot.WriteClosure (CurrentTrack, slot.Field); } }; } if (slot.SyncButton != null) { table.Attach (slot.SyncButton, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0); } if (label != null) { if (label is Label) { ((Label)label).MnemonicWidget = field; } table.Attach (label, 0, table.NColumns, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill, 0, 0); } table.ShowAll (); if ((options & FieldOptions.Shrink) == 0) { slot.Container = table; parent.PackStart (table, false, false, 0); } else { HBox shrink = new HBox (); shrink.Show (); slot.Container = shrink; shrink.PackStart (table, false, false, 0); parent.PackStart (shrink, false, false, 0); } field_slots.Add (slot); return slot; }
public static string GetFindString(this FieldSlot fieldSlot) => $"`{fieldSlot.FieldName}`";