Пример #1
0
	IEnumerator Start()
	{
		assember = Assembler.GetInstance();
		
		assember.OnFinishLoading += HandleOnFinishLoading;
		
		yield return new WaitForSeconds(3);
		
		string avatar = "zs";
		
		//AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "weapon0001", "", "wing", "zs_wing_0001");
        //AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "", "", "", "");
		//AssemblerInfo info2 = new AssemblerInfo(1, avatar, avatar + "_head_0001", avatar + "_body_0001", "", "weapon0001", "", "wing", "zs_wing_0001");
		
        //_id = assember.Create(info1, this);
//		assember.Create(info2);
		
        for(int i = 0; i < 20; ++i)
        {
            AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "", "", "", "");

            assember.Create(info1, this);

            yield return Random.Range(0, 30);
        }
	}
Пример #2
0
        /// <summary>
        /// Populates the assembler combo box.  Attempts to match the defaultAsm arg with
        /// the entries to configure the initial value.
        /// </summary>
        private void PopulateAssemblerComboBox(string defaultAsm)
        {
            //assemblerComboBox.DisplayMember = "Name";   // show this property

            assemblerComboBox.Items.Clear();
            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();
            bool foundMatch = false;

            while (iter.MoveNext())
            {
                AssemblerInfo    info    = iter.Current;
                AssemblerVersion version = AssemblerVersionCache.GetVersion(info.AssemblerId);
                AsmComboItem     item    = new AsmComboItem(info, version);
                assemblerComboBox.Items.Add(item);
                if (item.AssemblerId.ToString() == defaultAsm)
                {
                    Debug.WriteLine("matched current " + defaultAsm);
                    assemblerComboBox.SelectedItem = item;
                    foundMatch = true;
                }
            }
            if (!foundMatch)
            {
                // Need to do this or box will show empty.
                assemblerComboBox.SelectedIndex = 0;
            }
        }
Пример #3
0
    IEnumerator Start()
    {
        assember = Assembler.GetInstance();

        assember.OnFinishLoading += HandleOnFinishLoading;

        yield return(new WaitForSeconds(3));

        string avatar = "zs";

        //AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "weapon0001", "", "wing", "zs_wing_0001");
        //AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "", "", "", "");
        //AssemblerInfo info2 = new AssemblerInfo(1, avatar, avatar + "_head_0001", avatar + "_body_0001", "", "weapon0001", "", "wing", "zs_wing_0001");

        //_id = assember.Create(info1, this);
//		assember.Create(info2);

        for (int i = 0; i < 20; ++i)
        {
            AssemblerInfo info1 = new AssemblerInfo(0, avatar, avatar + "_head_0000", avatar + "_body_0000", "", "", "", "", "");

            assember.Create(info1, this);

            yield return(Random.Range(0, 30));
        }
    }
Пример #4
0
    public void Disassemble()
    {
        lastPosition = this.transform.position;

        if (isAssembled)
        {
            targets.ForEach(hT =>
            {
                AssemblerInfo info = targetsInfo[hT];

                //
                Transform parent    = hT.transform.parent;
                Vector3 position    = hT.transform.localPosition;
                Quaternion rotation = hT.transform.localRotation;
                Vector3 scale       = hT.transform.localScale;

                info.originalPosition = position;
                info.originalRotation = rotation;
                info.originalScale    = scale;
                //

                hT.transform.parent = null;

                info.generatedCollider.enabled = true;

                Vector3 explosionForce = UnityEngine.Random.Range(MinExplosionForce, MaxExplosionForce) * UnityEngine.Random.onUnitSphere;

                Rigidbody hRb;
                if (!info.hasInitialRigidbody)
                {
                    hRb          = hT.AddComponent <Rigidbody>();
                    hRb.mass     = MassForeachElement;
                    hRb.velocity = explosionForce;
                }
                else
                {
                    hRb          = hT.GetComponent <Rigidbody>();
                    hRb.mass     = MassForeachElement;
                    hRb.velocity = explosionForce;
                }
            });
        }
        if (remainingColliders != null)
        {
            if (remainingColliders.Count != 0)
            {
                remainingColliders.ForEach(hC => hC.enabled = false);
            }
        }
        isAssembled = false;

        if (rootCollider != null)
        {
            if (!RootColliderAlwaysOn)
            {
                rootCollider.enabled = false;
            }
        }
    }
Пример #5
0
        /// <summary>
        /// Gets a copy of the AppSettings with a standard set of formatting options (e.g. lower
        /// case for everything).
        /// </summary>
        /// <returns>New app settings object.</returns>
        private AppSettings CreateNormalizedSettings()
        {
            AppSettings settings = AppSettings.Global.GetCopy();

            // Override all asm formatting options.  We can ignore ShiftBeforeAdjust and the
            // pseudo-op names because those are set by the generators.
            settings.SetBool(AppSettings.FMT_UPPER_HEX_DIGITS, false);
            settings.SetBool(AppSettings.FMT_UPPER_OP_MNEMONIC, false);
            settings.SetBool(AppSettings.FMT_UPPER_PSEUDO_OP_MNEMONIC, false);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_A, true);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_S, true);
            settings.SetBool(AppSettings.FMT_UPPER_OPERAND_XY, false);
            settings.SetBool(AppSettings.FMT_ADD_SPACE_FULL_COMMENT, false);

            // Don't show the assembler ident line.  You can make a case for this being
            // mandatory, since the generated code is only guaranteed to work with the
            // assembler for which it was targeted, but I expect we'll quickly get to a
            // place where we don't have to work around assembler bugs, and this will just
            // become a nuisance.
            settings.SetBool(AppSettings.SRCGEN_ADD_IDENT_COMMENT, false);

            // Don't break lines with long labels.  That way we can redefine "long"
            // without breaking our tests.  (This is purely cosmetic.)
            settings.SetBool(AppSettings.SRCGEN_LONG_LABEL_NEW_LINE, false);

            // This could be on or off.  Off seems less distracting.
            settings.SetBool(AppSettings.SRCGEN_SHOW_CYCLE_COUNTS, false);

            // Disable label localization.  We want to be able to play with this a bit
            // without disrupting all the other tests.  Use a test-only feature to enable
            // it for the localization test.
            settings.SetBool(AppSettings.SRCGEN_DISABLE_LABEL_LOCALIZATION, true);

            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

            while (iter.MoveNext())
            {
                AssemblerInfo.Id asmId     = iter.Current.AssemblerId;
                AssemblerConfig  curConfig =
                    AssemblerConfig.GetConfig(settings, asmId);
                AssemblerConfig defConfig =
                    AssemblerInfo.GetAssembler(asmId).GetDefaultConfig();

                // Merge the two together.  We want the default assembler config for most
                // things, but the executable path from the current config.
                defConfig.ExecutablePath = curConfig.ExecutablePath;

                // Write it into the test settings.
                AssemblerConfig.SetConfig(settings, asmId, defConfig);
            }

            return(settings);
        }
Пример #6
0
        private void PrintAsmVersions()
        {
            ReportProgress("\nTested assemblers:");
            IEnumerator <AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

            while (iter.MoveNext())
            {
                AssemblerInfo    info    = iter.Current;
                AssemblerVersion version = AssemblerVersionCache.GetVersion(info.AssemblerId);
                ReportProgress("  " + info.Name + " v" + version.VersionStr);
            }
            ReportProgress("\n");
        }
Пример #7
0
    /// <summary>
    /// 根据AssemblerInfo创建一个
    /// </summary>
    public uint Create(AssemblerInfo info, object obj, uint id = 0)
    {
        if (id == 0)
        {
            id = GetID();
        }

        Update(id, info);

        //Debug.Log(".Create  " + id + " " + obj.ToString());

        return(id);
    }
    public AssemblerInfo Clone()
    {
        AssemblerInfo assemblerInfo = new AssemblerInfo();

        assemblerInfo.m_ID          = this.m_ID;
        assemblerInfo.m_Character   = this.m_Character;
        assemblerInfo.m_HeadElement = this.m_HeadElement;
        assemblerInfo.m_BodyElement = this.m_BodyElement;
        assemblerInfo.m_WeaponR     = this.m_WeaponR;
        assemblerInfo.m_WeaponL     = this.m_WeaponL;
        assemblerInfo.m_WeaponB     = this.m_WeaponB;
        assemblerInfo.m_Wing        = this.m_Wing;
        assemblerInfo.m_WingElement = this.m_WingElement;
        assemblerInfo.m_IsDone      = false;
        return(assemblerInfo);
    }
    public AssemblerInfo(ref AssemblerInfo info)
    {
        this.m_ID     = info.m_ID;// id;
        this.m_IsDone = false;

        this.m_Character = info.m_Character;

        this.m_HeadElement = info.m_HeadElement;
        this.m_BodyElement = info.m_BodyElement;
        //m_FootElement = _FootElement;

        this.m_WeaponR = info.m_WeaponR;
        this.m_WeaponL = info.m_WeaponL;
        this.m_WeaponB = info.m_WeaponB;

        this.m_Wing        = info.m_Wing;
        this.m_WingElement = info.m_WingElement;
    }
Пример #10
0
    void Reassemble()
    {
        isAssembled = true;

        this.transform.position = lastPosition;

        targets.ForEach(hT =>
        {
            AssemblerInfo info = targetsInfo[hT];

            hT.transform.parent        = info.originalParent;
            hT.transform.localPosition = info.originalPosition;
            hT.transform.localRotation = info.originalRotation;
            hT.transform.localScale    = info.originalScale;

            MeshCollider collider = info.generatedCollider;
            if (!info.hasInitialCollider)
            {
                collider.enabled = false;
            }

            if (!info.hasInitialRigidbody)
            {
                Rigidbody hRb       = hT.GetComponent <Rigidbody>();
                hRb.velocity        = Vector3.zero;
                hRb.angularVelocity = Vector3.zero;
                Destroy(hRb);
            }
        });

        rootRigidbody.velocity        = Vector3.zero;
        rootRigidbody.angularVelocity = Vector3.zero;

        remainingColliders.ForEach(hC => hC.enabled = true);

        if (rootCollider != null)
        {
            if (!RootColliderAlwaysOn)
            {
                rootCollider.enabled = true;
            }
        }
    }
Пример #11
0
        private void GenerateButton_Click(object sender, RoutedEventArgs e)
        {
            IGenerator gen = AssemblerInfo.GetGenerator(mSelectedAssemblerId);

            if (gen == null)
            {
                Debug.WriteLine("Unable to get generator for " + mSelectedAssemblerId);
                return;
            }
            gen.Configure(mProject, mWorkDirectory, mBaseFileName,
                          AssemblerVersionCache.GetVersion(mSelectedAssemblerId), AppSettings.Global);

            GenWorker    gw  = new GenWorker(gen);
            WorkProgress dlg = new WorkProgress(this, gw, false);

            dlg.ShowDialog();
            //Debug.WriteLine("Dialog returned: " + dlg.DialogResult);

            GenerationResults res = gw.Results;

            if (res == null)
            {
                // error or cancelation; errors already reported
                return;
            }

            ResetElements();
            mGenerationResults = res;
            previewFileComboBox.Items.Clear();
            foreach (string str in res.PathNames)
            {
                previewFileComboBox.Items.Add(new ComboPath(str));
            }
            previewFileComboBox.SelectedIndex = 0;      // should trigger update

            UpdateAssemblerControls();
        }
Пример #12
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region |DEFINE IMAGE IF EXISTS|
                Entity preImage = null;
                if (context.PreEntityImages.Contains("PreImage") && context.PreEntityImages["PreImage"] is Entity)
                {
                    preImage = (Entity)context.PreEntityImages["PreImage"];
                }

                #endregion

                #region | VARIABLES |
                string customerFirstName   = null;
                string customerLastName    = null;
                string customerMobilePhone = null;
                string customerFullName    = null;
                string assemblerFullName   = null;

                int statusCode    = 0;
                int oldStatusCode = 0;

                AssemblerInfo     assemblerInfo = null;
                List <ScoreLimit> lstLimits     = new List <ScoreLimit>();

                EntityReference portal = null;
                EntityReference user   = null;

                if (preImage.Contains("new_portalid") && preImage["new_portalid"] != null)
                {
                    portal = (EntityReference)preImage["new_portalid"];
                }

                if (preImage.Contains("new_userid") && preImage["new_userid"] != null)
                {
                    user = (EntityReference)preImage["new_userid"];

                    MsCrmResultObj <AssemblerInfo> resultAssembler = AssemblyRequestHelper.GetAssemblerInfo(user.Id, sda);

                    if (resultAssembler.Success)
                    {
                        assemblerInfo = resultAssembler.ReturnObject;
                    }
                    else
                    {
                        throw new Exception("Anahtarcı bilgisi alınamadı.Hata:" + resultAssembler.Result);
                    }
                }

                if (preImage.Contains("new_firstname") && preImage["new_firstname"] != null)
                {
                    customerFirstName = preImage["new_firstname"].ToString();
                }

                if (preImage.Contains("new_lastname") && preImage["new_lastname"] != null)
                {
                    customerLastName = preImage["new_lastname"].ToString();
                }

                if (preImage.Contains("new_mobilephone") && preImage["new_mobilephone"] != null)
                {
                    customerMobilePhone = preImage["new_mobilephone"].ToString();
                }

                if (!string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName))
                {
                    customerFullName = customerFirstName + " " + customerLastName;
                }

                if (entity.Contains("statuscode") && entity["statuscode"] != null)
                {
                    statusCode = ((OptionSetValue)entity["statuscode"]).Value;
                }

                if (preImage.Contains("statuscode") && preImage["statuscode"] != null)
                {
                    oldStatusCode = ((OptionSetValue)preImage["statuscode"]).Value;
                }
                #endregion

                if (statusCode != oldStatusCode && (statusCode == (int)DiscoveryFormStatus.CrmConfirmed || statusCode == (int)DiscoveryFormStatus.Result_Negative))
                {
                    string statusText = string.Empty;

                    if (statusCode == (int)DiscoveryFormStatus.CrmConfirmed)
                    {
                        statusText = "Kale Onayladı";
                    }
                    else if (statusCode == (int)DiscoveryFormStatus.Result_Negative)
                    {
                        statusText = "Sonuç Olumsuz";
                    }

                    string customerSmsText = @"Sayın {0}, {1} müşterisine ait Ücretsiz Keşif Formu durumu {2} olarak değişmiştir. Bilgilerinize.";

                    Entity ent = new Entity("new_sms");
                    ent["new_message"]     = string.Format(customerSmsText, assemblerFullName, customerFullName, statusText);
                    ent["new_phonenumber"] = assemblerInfo.MobilePhoneNumber;
                    ent["new_name"]        = customerFirstName + " " + customerLastName + "|KGS Formu Durum Değişimi";
                    ent["new_userid"]      = user;

                    service.Create(ent);
                }

                if (entity.Contains("statuscode") && entity["statuscode"] != null &&
                    ((OptionSetValue)entity["statuscode"]).Value == (int)DiscoveryFormStatus.CrmConfirmed)
                {
                    MsCrmResultObject limitRes = ScoreHelper.GetScoreLimitsByType(ScoreType.KGSSales, sda);

                    if (limitRes.Success)
                    {
                        lstLimits = (List <ScoreLimit>)limitRes.ReturnObject;

                        for (int i = 0; i < lstLimits.Count; i++)
                        {
                            Score sc = new Score()
                            {
                                Point     = lstLimits[i].Point,
                                Portal    = portal,
                                User      = user,
                                ScoreType = ScoreType.KGSSales
                            };

                            MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);

                            if (scoreRes.Success)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //LOG
                throw new InvalidPluginExecutionException(ex.Message);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }
Пример #13
0
        public void Execute(IServiceProvider serviceProvider)
        {
            SqlDataAccess sda = null;

            try
            {
                sda = new SqlDataAccess();
                sda.openConnection(Globals.ConnectionString);

                #region | SERVICE |
                IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

                #region | Validate Request |
                //Target yoksa veya Entity tipinde değilse, devam etme.
                if (!context.InputParameters.Contains("Target") || !(context.InputParameters["Target"] is Entity))
                {
                    return;
                }
                #endregion

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                #endregion

                Entity entity = (Entity)context.InputParameters["Target"];

                #region | VARIABLES |

                EntityReference userId        = null;
                EntityReference cityId        = null;
                EntityReference townId        = null;
                AssemblerInfo   assemblerInfo = null;

                string customerFirstName   = null;
                string customerLastName    = null;
                string customerMobilePhone = null;
                string customerFullName    = null;
                string assemblerFullName   = null;

                if (entity.Contains("new_userid") && entity["new_userid"] != null)
                {
                    userId = (EntityReference)entity["new_userid"];

                    MsCrmResultObj <AssemblerInfo> resultAssembler = AssemblyRequestHelper.GetAssemblerInfo(userId.Id, sda);

                    if (resultAssembler.Success)
                    {
                        assemblerInfo = resultAssembler.ReturnObject;
                    }
                    else
                    {
                        throw new Exception("Anahtarcı bilgisi alınamadı.Hata:" + resultAssembler.Result);
                    }
                }

                if (entity.Contains("new_cityid") && entity["new_cityid"] != null)
                {
                    cityId = (EntityReference)entity["new_cityid"];
                }

                if (entity.Contains("new_townid") && entity["new_townid"] != null)
                {
                    townId = (EntityReference)entity["new_townid"];
                }

                if (entity.Contains("new_firstname") && entity["new_firstname"] != null)
                {
                    customerFirstName = entity["new_firstname"].ToString();
                }

                if (entity.Contains("new_lastname") && entity["new_lastname"] != null)
                {
                    customerLastName = entity["new_lastname"].ToString();
                }

                if (entity.Contains("new_mobilephone") && entity["new_mobilephone"] != null)
                {
                    customerMobilePhone = entity["new_mobilephone"].ToString();
                }

                if (!string.IsNullOrWhiteSpace(customerFirstName) && !string.IsNullOrWhiteSpace(customerLastName))
                {
                    customerFullName = customerFirstName + " " + customerLastName;
                }

                if (assemblerInfo != null && !string.IsNullOrWhiteSpace(assemblerInfo.FirstName) && !string.IsNullOrWhiteSpace(assemblerInfo.LastName))
                {
                    assemblerFullName = assemblerInfo.FirstName + " " + assemblerInfo.LastName;
                }

                #endregion

                #region | CREATE SMSs |

                if (!string.IsNullOrWhiteSpace(customerMobilePhone) && !string.IsNullOrWhiteSpace(customerFirstName) &&
                    !string.IsNullOrWhiteSpace(customerLastName) && assemblerInfo != null)
                {
                    string customerSmsText = @"Sayın {0}, www.kalekilitesatis.com.tr sitemizden yaptığınız alışveriş için teşekkür ederiz. Montaj için anahtarcı bilgileri: {1}, Tel: {2}";

                    Entity ent = new Entity("new_sms");
                    ent["new_message"]     = string.Format(customerSmsText, customerFullName, assemblerFullName, assemblerInfo.MobilePhoneNumber);
                    ent["new_phonenumber"] = customerMobilePhone;
                    ent["new_name"]        = customerFirstName + " " + customerLastName + "|Montaj Talebi Mesajı";

                    service.Create(ent);
                }

                if (!string.IsNullOrWhiteSpace(assemblerInfo.MobilePhoneNumber) && !string.IsNullOrWhiteSpace(customerFirstName) &&
                    !string.IsNullOrWhiteSpace(customerLastName) && assemblerInfo != null && userId != null)
                {
                    string customerSmsText = @"Sayın {0}, www.kalekilitesatis.com.tr sitemizden satışı yapılan ürünün montajı için müşteri bilgileri: {1} Tel: {2} şeklindedir. Müşterimizle irtibata geçmenizi rica ederiz.";

                    Entity ent = new Entity("new_sms");
                    ent["new_message"]     = string.Format(customerSmsText, assemblerFullName, customerFullName, customerMobilePhone);
                    ent["new_phonenumber"] = assemblerInfo.MobilePhoneNumber;
                    ent["new_name"]        = customerFirstName + " " + customerLastName + "|Montaj Talebi Mesajı";
                    ent["new_userid"]      = userId;

                    service.Create(ent);
                }


                #endregion

                #region | CREATE NPS Survey |

                Entity entSurvey = new Entity("new_npssurvey");
                entSurvey["new_name"]             = customerFullName + "|" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");
                entSurvey["new_asseblyrequestid"] = entity.ToEntityReference();

                service.Create(entSurvey);

                #endregion
            }
            catch (Exception ex)
            {
                //LOG
                throw new InvalidPluginExecutionException(ex.Message + "->>>" + ex.StackTrace);
            }
            finally
            {
                if (sda != null)
                {
                    sda.closeConnection();
                }
            }
        }
Пример #14
0
        private void RunAssemblerButton_Click(object sender, RoutedEventArgs e)
        {
            IAssembler asm = AssemblerInfo.GetAssembler(mSelectedAssemblerId);

            if (asm == null)
            {
                Debug.WriteLine("Unable to get assembler for " + mSelectedAssemblerId);
                return;
            }

            asm.Configure(mGenerationResults, mWorkDirectory);

            AsmWorker    aw  = new AsmWorker(asm);
            WorkProgress dlg = new WorkProgress(this, aw, true);

            dlg.ShowDialog();
            //Debug.WriteLine("Dialog returned: " + dlg.DialogResult);
            if (dlg.DialogResult != true)
            {
                // Canceled, or failed to even run the assembler.
                return;
            }

            AssemblerResults results = aw.Results;

            if (results == null)
            {
                Debug.WriteLine("Dialog returned OK, but no assembler results found");
                Debug.Assert(false);
                return;
            }

            StringBuilder sb =
                new StringBuilder(results.Stdout.Length + results.Stderr.Length + 200);

            sb.Append(results.CommandLine);
            sb.Append("\r\n");
            sb.AppendFormat("ExitCode={0} - ", results.ExitCode);
            if (results.ExitCode == 0)
            {
                FileInfo fi = new FileInfo(results.OutputPathName);
                if (!fi.Exists)
                {
                    MessageBox.Show(this, Res.Strings.ASM_OUTPUT_NOT_FOUND,
                                    Res.Strings.ASM_MISMATCH_CAPTION,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    sb.Append(Res.Strings.ASM_MATCH_FAILURE);
                }
                else if (!CommonUtil.FileUtil.CompareBinaryFile(mProject.FileData,
                                                                results.OutputPathName, out int offset, out byte fileVal))
                {
                    if (fi.Length != mProject.FileData.Length &&
                        offset == fi.Length || offset == mProject.FileData.Length)
                    {
                        // The files matched up to the point where one ended.
                        string msg = string.Format(Res.Strings.ASM_MISMATCH_LENGTH_FMT,
                                                   fi.Length, mProject.FileData.Length);
                        MessageBox.Show(msg, Res.Strings.ASM_MISMATCH_CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        sb.Append(msg);
                    }
                    else
                    {
                        string msg = string.Format(Res.Strings.ASM_MISMATCH_DATA_FMT,
                                                   offset, fileVal, mProject.FileData[offset]);
                        MessageBox.Show(msg, Res.Strings.ASM_MISMATCH_CAPTION,
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                        sb.Append(msg);
                    }
                }
                else
                {
                    sb.Append(Res.Strings.ASM_MATCH_SUCCESS);
                }
            }
Пример #15
0
    public void CleanByScene()
    {
        //Debug.Log("Assembler.Clean ");

        mCorout_isRunning = false;

        this.StopCoroutine("LoadCoroutine");

        //StopAllCoroutines();

        foreach (var gameObj in m_Objects.Values)
        {
            GameObject go = (GameObject)gameObj;
            if (go != null)
            {
                go.SetActive(true);
                UnityEngine.Object.DestroyImmediate(go);
                go = null;
            }
        }
        m_Objects.Clear();

        foreach (CharacterLoader item in s_CharacterLoaders.Values)
        {
            CharacterLoader loader = (CharacterLoader)item;
            loader.Dispose();
            loader = null;
        }
        s_CharacterLoaders.Clear();

        foreach (ModelLoader item in s_ModelLoaders.Values)
        {
            ModelLoader loader = (ModelLoader)item;
            loader.Dispose();
            loader = null;
        }
        s_ModelLoaders.Clear();

        foreach (CharacterElementLoader item in s_CharacterElementLoaders.Values)
        {
            CharacterElementLoader loader = (CharacterElementLoader)item;
            loader.Dispose();
            loader = null;
        }
        s_CharacterElementLoaders.Clear();

        foreach (AnimationLoader item in s_AnimationAssemblers.Values)
        {
            AnimationLoader loader = (AnimationLoader)item;
            loader.Dispose();
            loader = null;
        }
        s_AnimationAssemblers.Clear();

        foreach (var item in m_Assemblers.Values)
        {
            AssemblerInfo loader = (AssemblerInfo)item;
            loader = null;
        }
        m_Assemblers.Clear();

        mUniqueID = 1;

        OnFinishLoading = null;
    }
Пример #16
0
 public AsmComboItem(AssemblerInfo info, AssemblerVersion version)
 {
     AssemblerId = info.AssemblerId;
     Name        = info.Name;
     AsmVersion  = version;
 }
Пример #17
0
    public void Update(uint id, AssemblerInfo info)
    {
        if (info == null) return;

        //Debug.Log(".Update  " + id + " " + JsonWriter.Serialize(info));

        info.m_ID = id;

        if (!string.IsNullOrEmpty(info.m_Character)
            && !s_CharacterLoaders.ContainsKey(info.m_Character))
        {
            CharacterLoader cl = new CharacterLoader(info.m_Character + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_Character, cl);
        }

        if (!string.IsNullOrEmpty(info.m_HeadElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_HeadElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_HeadElement, info.m_HeadElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_HeadElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_BodyElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_BodyElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_BodyElement, info.m_BodyElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_BodyElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_FootElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_FootElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_FootElement, info.m_FootElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_FootElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_Character)
            && !s_AnimationAssemblers.ContainsKey(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX))
        {
            AnimationLoader aa = new AnimationLoader(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX, aa);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponR)
            && !s_ModelLoaders.ContainsKey(info.m_WeaponR))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponR + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponR, ml);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponL)
            && !s_ModelLoaders.ContainsKey(info.m_WeaponL))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponL + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponL, ml);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_CharacterLoaders.ContainsKey(info.m_Wing))
        //{

        //}

        if (!string.IsNullOrEmpty(info.m_WingElement)
            && !s_CharacterElementLoaders.ContainsKey(info.m_WingElement))
        {

            CharacterLoader ml = new CharacterLoader(info.m_WingElement + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_WingElement, ml);

            AnimationLoader aa = new AnimationLoader(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX, aa);

            CharacterElementLoader cel = new CharacterElementLoader(info.m_WingElement, info.m_WingElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_WingElement, cel);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_AnimationAssemblers.ContainsKey(info.m_Wing + AssemblerConstant.ANIMATION_SUFFIX))
        //{

        //}

        info.m_IsDone = false;
        if (m_Assemblers.ContainsKey(id))
        {
            m_Assemblers[id] = new AssemblerInfo(ref info);
            //m_Assemblers.Remove(id);
        }
        else
        {
            m_Assemblers.Add(id, info);
        }

        if (!mCorout_isRunning)
        {
            mCorout_isRunning = true;
            StartCoroutine(LoadCoroutine());
        }

        //Debug.Log("Create assemble: " + DecToHex(id) + " status: " + info.m_IsDone);

        return;
    }
Пример #18
0
    /// <summary>
    /// 根据AssemblerInfo创建一个   
    /// </summary>
    public uint Create(AssemblerInfo info, object obj, uint id = 0)
    {
        if(id == 0)
        {
            id = GetID();
        }

        Update(id, info);

        //Debug.Log(".Create  " + id + " " + obj.ToString());

        return id;
    }
Пример #19
0
    public AssemblerInfo(ref AssemblerInfo info)
    {
        this.m_ID = info.m_ID;// id;
        this.m_IsDone = false;

        this.m_Character = info.m_Character;

        this.m_HeadElement = info.m_HeadElement;
        this.m_BodyElement = info.m_BodyElement;
        //m_FootElement = _FootElement;	

        this.m_WeaponR = info.m_WeaponR;
        this.m_WeaponL = info.m_WeaponL;
        this.m_WeaponB = info.m_WeaponB;

        this.m_Wing = info.m_Wing;
        this.m_WingElement = info.m_WingElement;
    }
Пример #20
0
 public AssemblerInfo Clone()
 {
     AssemblerInfo assemblerInfo = new AssemblerInfo();
     assemblerInfo.m_ID = this.m_ID;
     assemblerInfo.m_Character = this.m_Character;
     assemblerInfo.m_HeadElement = this.m_HeadElement;
     assemblerInfo.m_BodyElement = this.m_BodyElement;
     assemblerInfo.m_WeaponR = this.m_WeaponR;
     assemblerInfo.m_WeaponL = this.m_WeaponL;
     assemblerInfo.m_WeaponB = this.m_WeaponB;
     assemblerInfo.m_Wing = this.m_Wing;
     assemblerInfo.m_WingElement = this.m_WingElement;
     assemblerInfo.m_IsDone = false;
     return assemblerInfo;
 }
Пример #21
0
    public void Update(uint id, AssemblerInfo info)
    {
        if (info == null)
        {
            return;
        }

        //Debug.Log(".Update  " + id + " " + JsonWriter.Serialize(info));

        info.m_ID = id;

        if (!string.IsNullOrEmpty(info.m_Character) &&
            !s_CharacterLoaders.ContainsKey(info.m_Character))
        {
            CharacterLoader cl = new CharacterLoader(info.m_Character + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_Character, cl);
        }

        if (!string.IsNullOrEmpty(info.m_HeadElement) &&
            !s_CharacterElementLoaders.ContainsKey(info.m_HeadElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_HeadElement, info.m_HeadElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_HeadElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_BodyElement) &&
            !s_CharacterElementLoaders.ContainsKey(info.m_BodyElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_BodyElement, info.m_BodyElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_BodyElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_FootElement) &&
            !s_CharacterElementLoaders.ContainsKey(info.m_FootElement))
        {
            CharacterElementLoader cel = new CharacterElementLoader(info.m_FootElement, info.m_FootElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_FootElement, cel);
        }

        if (!string.IsNullOrEmpty(info.m_Character) &&
            !s_AnimationAssemblers.ContainsKey(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX))
        {
            AnimationLoader aa = new AnimationLoader(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_Character + AssemblerConstant.ANIMATION_SUFFIX, aa);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponR) &&
            !s_ModelLoaders.ContainsKey(info.m_WeaponR))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponR + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponR, ml);
        }

        if (!string.IsNullOrEmpty(info.m_WeaponL) &&
            !s_ModelLoaders.ContainsKey(info.m_WeaponL))
        {
            ModelLoader ml = new ModelLoader(info.m_WeaponL + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_ModelLoaders.Add(info.m_WeaponL, ml);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_CharacterLoaders.ContainsKey(info.m_Wing))
        //{

        //}

        if (!string.IsNullOrEmpty(info.m_WingElement) &&
            !s_CharacterElementLoaders.ContainsKey(info.m_WingElement))
        {
            CharacterLoader ml = new CharacterLoader(info.m_WingElement + "_" + AssemblerConstant.CHARACTER_BASE_NAME + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterLoaders.Add(info.m_WingElement, ml);

            AnimationLoader aa = new AnimationLoader(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_AnimationAssemblers.Add(info.m_WingElement + AssemblerConstant.ANIMATION_SUFFIX, aa);

            CharacterElementLoader cel = new CharacterElementLoader(info.m_WingElement, info.m_WingElement + AssemblerConstant.ASSETBUNDLE_SUFFIX);
            s_CharacterElementLoaders.Add(info.m_WingElement, cel);
        }

        //if (!string.IsNullOrEmpty(info.m_Wing)
        //    && !s_AnimationAssemblers.ContainsKey(info.m_Wing + AssemblerConstant.ANIMATION_SUFFIX))
        //{

        //}

        info.m_IsDone = false;
        if (m_Assemblers.ContainsKey(id))
        {
            m_Assemblers[id] = new AssemblerInfo(ref info);
            //m_Assemblers.Remove(id);
        }
        else
        {
            m_Assemblers.Add(id, info);
        }

        if (!mCorout_isRunning)
        {
            mCorout_isRunning = true;
            StartCoroutine(LoadCoroutine());
        }

        //Debug.Log("Create assemble: " + DecToHex(id) + " status: " + info.m_IsDone);

        return;
    }
Пример #22
0
        /// <summary>
        /// Generates source code for the specified test case, assembles it, and compares
        /// the output of both steps to expected values.  The process is repeated for every
        /// known assembler.
        ///
        /// If an assembler is known but not configured, the assembly step is skipped, and
        /// does not count as a failure.
        /// </summary>
        /// <param name="pathName">Full path to test case.</param>
        /// <returns>True if all assemblers worked as expected.</returns>
        private bool GenerateAndAssemble(string pathName)
        {
            ReportProgress(Path.GetFileName(pathName) + "...\r\n");

            // Create DisasmProject object, either as a new project for a plain data file,
            // or from a project file.
            DisasmProject project = InstantiateProject(pathName,
                                                       out FileLoadReport projectLoadReport);

            if (project == null)
            {
                ReportFailure();
                return(false);
            }

            int testNum = GetTestNum(pathName);

            // Create a temporary directory to work in.
            string workDir = CreateWorkDirectory(pathName);

            if (string.IsNullOrEmpty(workDir))
            {
                ReportFailure();
                project.Cleanup();
                return(false);
            }

            AppSettings settings = CreateNormalizedSettings();

            ApplyProjectSettings(settings, project);

            // Iterate through all known assemblers.
            bool didFail = false;

            foreach (AssemblerInfo.Id asmId in
                     (AssemblerInfo.Id[])Enum.GetValues(typeof(AssemblerInfo.Id)))
            {
                if (asmId == AssemblerInfo.Id.Unknown)
                {
                    continue;
                }

                string    fileName = Path.GetFileName(pathName);
                TaskTimer timer    = new TaskTimer();
                timer.StartTask("Full Test Duration");

                // Create results object and add it to the list.  We'll add stuff to it for
                // as far as we get.
                GenTestResults results = new GenTestResults(pathName, asmId);
                mResults.Add(results);
                results.ProjectLoadReport = projectLoadReport;

                // Generate source code.
                ReportProgress("  " + asmId.ToString() + " generate...");
                IGenerator gen = AssemblerInfo.GetGenerator(asmId);
                if (gen == null)
                {
                    ReportErrMsg("generator unavailable");
                    ReportProgress("\r\n");
                    //didFail = true;
                    continue;
                }
                timer.StartTask("Generate Source");
                gen.Configure(project, workDir, fileName,
                              AssemblerVersionCache.GetVersion(asmId), settings);
                List <string> genPathNames = gen.GenerateSource(mWorker);
                timer.EndTask("Generate Source");
                if (mWorker.CancellationPending)
                {
                    // The generator will stop early if a cancellation is requested.  If we
                    // don't break here, the compare function will report a failure, which
                    // isn't too problematic but looks funny.
                    break;
                }

                ReportProgress(" verify...");
                timer.StartTask("Compare Source to Expected");
                bool match = CompareGeneratedToExpected(pathName, genPathNames);
                timer.EndTask("Compare Source to Expected");
                if (match)
                {
                    ReportSuccess();
                    results.GenerateOkay = true;
                }
                else
                {
                    ReportFailure();
                    didFail = true;

                    // The fact that it doesn't match the expected sources doesn't mean it's
                    // invalid.  Go ahead and try to build it.
                    //continue;
                }

                // Assemble code.
                ReportProgress("  " + asmId.ToString() + " assemble...");
                IAssembler asm = AssemblerInfo.GetAssembler(asmId);
                if (asm == null)
                {
                    ReportErrMsg("assembler unavailable");
                    ReportProgress("\r\n");
                    continue;
                }

                timer.StartTask("Assemble Source");
                asm.Configure(genPathNames, workDir);
                AssemblerResults asmResults = asm.RunAssembler(mWorker);
                timer.EndTask("Assemble Source");
                if (asmResults == null)
                {
                    ReportErrMsg("unable to run assembler");
                    ReportFailure();
                    didFail = true;
                    continue;
                }
                if (asmResults.ExitCode != 0)
                {
                    ReportErrMsg("assembler returned code=" + asmResults.ExitCode);
                    ReportFailure();
                    didFail = true;
                    continue;
                }

                results.AsmResults = asmResults;

                ReportProgress(" verify...");
                timer.StartTask("Compare Binary to Expected");
                FileInfo fi = new FileInfo(asmResults.OutputPathName);
                if (!fi.Exists)
                {
                    // This can happen if the assembler fails to generate output but doesn't
                    // report an error code (e.g. Merlin 32 in certain situations).
                    ReportErrMsg("asm output missing");
                    ReportFailure();
                    didFail = true;
                    continue;
                }
                else if (fi.Length != project.FileData.Length)
                {
                    ReportErrMsg("asm output mismatch: length is " + fi.Length + ", expected " +
                                 project.FileData.Length);
                    ReportFailure();
                    didFail = true;
                    continue;
                }
                else if (!FileUtil.CompareBinaryFile(project.FileData, asmResults.OutputPathName,
                                                     out int badOffset, out byte badFileVal))
                {
                    ReportErrMsg("asm output mismatch: offset +" + badOffset.ToString("x6") +
                                 " has value $" + badFileVal.ToString("x2") + ", expected $" +
                                 project.FileData[badOffset].ToString("x2"));
                    ReportFailure();
                    didFail = true;
                    continue;
                }
                timer.EndTask("Compare Binary to Expected");

                // Victory!
                results.AssembleOkay = true;
                ReportSuccess();

                timer.EndTask("Full Test Duration");
                results.Timer = timer;

                // We don't scrub the directory on success at this point.  We could, but we'd
                // need to remove only those files associated with the currently assembler.
                // Otherwise, a failure followed by a success would wipe out the unsuccessful
                // temporaries.
            }

            // If something failed, leave the bits around for examination.  Otherwise, try to
            // remove the directory and all its contents.
            if (!didFail && !RetainOutput)
            {
                ScrubWorkDirectory(workDir, testNum);
                RemoveWorkDirectory(workDir);
            }

            project.Cleanup();
            return(!didFail);
        }