コード例 #1
0
        //---------------------------------------------------------------------------
        private void btTemplateSaveClick(object sender, EventArgs e)
        {
            string wgtFile;

            if (CbVorlage.Text != "")
            {
                int idx = CbVorlage.FindStringExact(CbVorlage.Text);
                if (idx >= 0)
                {
                    string msg;
                    msg = string.Format((_("Eine Vorlage mit dem Name '%s' existiert bereits. Soll diese Überschrieben werden?")).Replace("%s", "{0}"), CbVorlage.Text);
                    if (Utils.MorasAskMessage(msg, _("Überschreiben?")) == (int)DialogResult.Yes)
                    {
                        CPlayerWeights pWeight = (CPlayerWeights)((TemplateItem)CbVorlage.Items[CbVorlage.SelectedIndex]).Tag;
                        AssignToWeight(pWeight);
                        pWeight.Save();
                    }
                }
                else
                {
                    CPlayerWeights pWeight = new CPlayerWeights();
                    AssignToWeight(pWeight);
                    wgtFile          = Unit.frmMain.DataPath + "weights\\" + CbVorlage.Text + ".wgt";
                    pWeight.FileName = wgtFile;
                    pWeight.Name     = CbVorlage.Text;
                    pWeight.Save();
                    CbVorlage.Items.Add(new TemplateItem(pWeight.Name, pWeight));
                }
            }
            else
            {
                Utils.MorasErrorMessage(_("Bitte gib der Vorlage einen Namen."), _("Vorlagenname"));
            }
        }
コード例 #2
0
        //---------------------------------------------------------------------------

        private void CbVorlageClick(object sender, EventArgs e)
        {
            if (CbVorlage.SelectedIndex == -1)
            {
                return;
            }
            CPlayerWeights pWeight = (CPlayerWeights)((TemplateItem)CbVorlage.Items[CbVorlage.SelectedIndex]).Tag;

            //	pWeight.WriteDebug();
            AssignToView(pWeight);
        }
コード例 #3
0
 //---------------------------------------------------------------------------
 private void AssignToWeight(CPlayerWeights pWeight)
 {
     for (int i = 0; i < Unit.xml_config.nAttributes; i++)
     {
         if (arWeightDisplays[i].iParentView >= 0)
         {
             Debug.Assert(arWeightDisplays[i].pTrackBar != null);
             pWeight.Weight[i] = arWeightDisplays[i].pTrackBar.Value;
         }
     }
 }
コード例 #4
0
        //---------------------------------------------------------------------------

        private void btTemplateDeleteClick(object sender, EventArgs e)
        {
            CPlayerWeights pWeight = (CPlayerWeights)((TemplateItem)CbVorlage.Items[CbVorlage.SelectedIndex]).Tag;
            string         msg;

            msg = string.Format((_("Soll die Vorlage '%s' wirklich gelöscht werden?")).Replace("%s", "{0}"), pWeight.Name);
            if (Utils.MorasAskMessage(msg, _("Vorlage löschen?")) == (int)DialogResult.Yes)
            {
                CbVorlage.Items.RemoveAt(CbVorlage.SelectedIndex);
                File.Delete(pWeight.FileName);
                pWeight = null;
            }
        }
コード例 #5
0
        //---------------------------------------------------------------------------

        public CPlayerWeights(CPlayerWeights rhs)
        {
            iClass      = rhs.iClass;
            bModified   = rhs.bModified;
            strName     = rhs.strName;
            strFileName = rhs.strFileName;

            arWeights.Length = rhs.arWeights.Length;
            for (int i = 0; i < arWeights.Length; i++)
            {
                arWeights[i] = rhs.arWeights[i];
            }
        }
コード例 #6
0
 //---------------------------------------------------------------------------
 private void AssignToView(CPlayerWeights pWeight)
 {
     //	string msg = IntToStr(xml_config.nAttributes) + " zu " + IntToStr(arWeightDisplays.Length);
     //	Utils.DebugPrint(msg);
     for (int i = 0; i < Unit.xml_config.nAttributes; i++)
     {
         //		Utils.DebugPrint(xml_config.arAttributes[i].id);
         if (arWeightDisplays[i].iParentView >= 0)
         {
             Debug.Assert(arWeightDisplays[i].pTrackBar != null);
             arWeightDisplays[i].pTrackBar.Value = pWeight.Weight[i];
             //			msg = "\t=> " + IntToStr(pWeight.Weight[i]);
             //			Utils.DebugPrint(msg);
         }
     }
 }
コード例 #7
0
 //---------------------------------------------------------------------------
 private void InitTemplates()
 {
     if (Directory.Exists(Unit.frmMain.DataPath + "weights\\"))
     {
         foreach (string wgtFile in Directory.EnumerateFiles(Unit.frmMain.DataPath + "weights\\", "*.wgt"))
         {
             CPlayerWeights pWeight = new CPlayerWeights();
             Debug.Assert(pWeight != null);
             pWeight.FileName = wgtFile;
             pWeight.Load();
             xWeights.Length++;
             xWeights[xWeights.Length - 1] = pWeight;
             CbVorlage.Items.Add(new TemplateItem(pWeight.Name, pWeight));
         }
     }
 }
コード例 #8
0
        //---------------------------------------------------------------------------
        public Single CalcGesamtNutzen(CPlayerWeights Weights)
        {
            double dTotalUtility = 0;

            // Erstmal alle Cap-Werte berechnen
            for (int i = 0; i < arAttributeStates.Length; i++)
            {
                if (arAttributeStates[i].bActive)
                {
                    int iEffMaxCap = Math.Min(arAttributeStates[i].iItemsCap, arAttributeStates[i].iPlayerCapIncCap);
                    if (arAttributeStates[i].iPlayerCapIncOvercap > 0) // use cap from over-cap only if this attribute has a cap in over-cap
                    {
                        iEffMaxCap = Math.Min(iEffMaxCap + arAttributeStates[i].iItemsOvercap, arAttributeStates[i].iPlayerCapIncOvercap);
                    }
                    int iEffCap = arAttributeStates[i].iPlayerCapBase + iEffMaxCap;
                    int iEffVal = Math.Min(arAttributeStates[i].iItemsValue, iEffCap);
                    dTotalUtility += Weights.UpV[i] * iEffVal;
                }
            }
            return((Single)dTotalUtility);
        }