Example #1
0
        private void TryLoadBooleanMod(VariableMod varMod)
        {
            if (varMod == null)
            {
                varMod = new BooleanVariableMod();
            }

            if (varMod.GetType() == typeof(BooleanVariableMod))
            {
                var mod = (BooleanVariableMod)varMod;

                optBooleanTrue.Checked  = mod.Value;
                optBooleanFalse.Checked = !mod.Value;

                if (mod.DuplicateVariableId != Guid.Empty)
                {
                    if (mod.DupVariableType == VariableTypes.PlayerVariable)
                    {
                        optBooleanClonePlayerVar.Checked       = true;
                        cmbBooleanClonePlayerVar.SelectedIndex = PlayerVariableBase.ListIndex(mod.DuplicateVariableId);
                    }
                    else
                    {
                        optBooleanCloneGlobalVar.Checked       = true;
                        cmbBooleanCloneGlobalVar.SelectedIndex = ServerVariableBase.ListIndex(mod.DuplicateVariableId);
                    }
                }
            }
        }
        //OLD
        //public class SetSwitchCommand : EventCommand
        //{
        //    public override EventCommandType Type { get; } = EventCommandType.SetSwitch;
        //    public SwitchTypes SwitchType { get; set; } = SwitchTypes.PlayerSwitch;
        //    public Guid SwitchId { get; set; }
        //    public bool Value { get; set; }
        //    public bool SyncParty { get; set; }
        //}

        private static JObject ConvertSetSwitchCommand(JObject obj)
        {
            var cmd = new SetVariableCommand();

            if (obj.ContainsKey("SwitchId"))
            {
                cmd.VariableId = Guid.Parse(obj["SwitchId"].ToString());
            }

            if (obj.ContainsKey("SwitchType") && int.Parse(obj["SwitchType"].ToString()) == 1)
            {
                cmd.VariableType = VariableTypes.ServerVariable;
            }
            else
            {
                cmd.VariableType = VariableTypes.PlayerVariable;
            }

            if (obj.ContainsKey("SyncParty") && bool.Parse(obj["SyncParty"].ToString()))
            {
                cmd.SyncParty = true;
            }
            else
            {
                cmd.SyncParty = false;
            }

            var mod = new BooleanVariableMod();

            cmd.Modification = mod;

            if (obj.ContainsKey("Value") && bool.Parse(obj["Value"].ToString()))
            {
                mod.Value = true;
            }
            else
            {
                mod.Value = false;
            }

            var newJson = JsonConvert.SerializeObject(
                cmd, typeof(EventCommand),
                new JsonSerializerSettings()
            {
                Formatting             = Formatting.None,
                TypeNameHandling       = TypeNameHandling.Auto,
                DefaultValueHandling   = DefaultValueHandling.IgnoreAndPopulate,
                ObjectCreationHandling = ObjectCreationHandling.Replace
            }
                );

            return(JObject.Parse(newJson));
        }
        private static string GetVariableModText(SetVariableCommand command, BooleanVariableMod mod)
        {
            var varvalue = "";

            if (mod.DuplicateVariableId != Guid.Empty)
            {
                if (mod.DupVariableType == VariableTypes.PlayerVariable)
                {
                    varvalue = Strings.EventCommandList.dupplayervariable.ToString(
                        PlayerVariableBase.GetName(mod.DuplicateVariableId)
                        );
                }

                else if (mod.DupVariableType == VariableTypes.ServerVariable)
                {
                    varvalue = Strings.EventCommandList.dupglobalvariable.ToString(
                        ServerVariableBase.GetName(mod.DuplicateVariableId)
                        );
                }
            }
            else
            {
                if (mod.Value == true)
                {
                    varvalue = Strings.EventCommandList.setvariable.ToString(Strings.EventCommandList.True);
                }
                else
                {
                    varvalue = Strings.EventCommandList.setvariable.ToString(Strings.EventCommandList.False);
                }
            }

            if (command.VariableType == VariableTypes.PlayerVariable)
            {
                return(Strings.EventCommandList.playervariable.ToString(
                           PlayerVariableBase.GetName(command.VariableId), varvalue
                           ));
            }

            if (command.VariableType == VariableTypes.ServerVariable)
            {
                return(Strings.EventCommandList.globalvariable.ToString(
                           ServerVariableBase.GetName(command.VariableId), varvalue
                           ));
            }

            return(Strings.EventCommandList.invalid);
        }
Example #4
0
        private BooleanVariableMod GetBooleanVariableMod()
        {
            var mod = new BooleanVariableMod();

            mod.Value = optBooleanTrue.Checked;

            if (optBooleanClonePlayerVar.Checked)
            {
                mod.DupVariableType     = VariableTypes.PlayerVariable;
                mod.DuplicateVariableId = PlayerVariableBase.IdFromList(cmbBooleanClonePlayerVar.SelectedIndex);
            }
            else if (optBooleanCloneGlobalVar.Checked)
            {
                mod.DupVariableType     = VariableTypes.ServerVariable;
                mod.DuplicateVariableId = ServerVariableBase.IdFromList(cmbBooleanCloneGlobalVar.SelectedIndex);
            }

            return(mod);
        }