示例#1
0
 private void UpdateGameValue(Control c, object value)
 {
     if (uiControls.ContainsKey(c))
     {
         MaidInfo maid = SelectedMaid;
         if (maid == null)
         {
             return;
         }
         Debugger.Assert(
             () =>
         {
             MaidChangeType type = uiControls[c];
             if (type == MaidChangeType.YotogiClassType)
             {
                 value = EnumHelper.EnabledYotogiClasses[(int)value];
             }
             Debugger.WriteLine(
                 LogLevel.Info,
                 $"Attempting to update value {type} to {value}. Allowed: {!valueUpdate[type]}.");
             if (!valueUpdate[type])
             {
                 maid.SetValue(type, value);
             }
             valueUpdate[type] = false;
         },
             $"Failed to set maid value for {maid.Maid.Param.status.first_name} {maid.Maid.Param.status.last_name}");
     }
     else if (uiControlsPlayer.ContainsKey(c))
     {
         if (Player == null)
         {
             return;
         }
         Debugger.Assert(
             () =>
         {
             PlayerChangeType type = uiControlsPlayer[c];
             Debugger.WriteLine(
                 LogLevel.Info,
                 $"Attempting to update player value {type} to {value}. Allowed: {!valueUpdatePlayer[type]}.");
             if (!valueUpdatePlayer[type])
             {
                 Player.SetValue(type, value);
             }
             valueUpdatePlayer[type] = false;
         },
             "Failed to set player value");
     }
 }
        private void OnCellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (clearingTables || e.ColumnIndex == PARAMS_COLUMN_LOCK)
            {
                return;
            }
            DataGridView table = (DataGridView)sender;
            MaidInfo     maid  = SelectedMaid;

            if (SelectedMaid == null)
            {
                return;
            }

            MaidChangeType?type = null;

            if (table == dataGridView_params)
            {
                type = maidParamsTableDic[e.RowIndex];
            }
            else if (table == dataGridView_ero_zones)
            {
                type = maidEroTableDic[e.RowIndex];
            }
            else if (table == dataGridView_maid_params_bonus)
            {
                type = maidBonusStatsTableDic[e.RowIndex];
            }
            else if (table == dataGridView_statistics)
            {
                type = maidStatsTableDic[e.RowIndex];
            }
            if (type == null)
            {
                return;
            }

            if (valueUpdate[type.Value])
            {
                valueUpdate[type.Value] = false;
                return;
            }

            object val = table[e.ColumnIndex, e.RowIndex].Value;

            if (!(val is int) && !(val is long))
            {
                maid.UpdateField(type.Value);
                return;
            }

            if (maid.IsHardLocked(type.Value))
            {
                Debugger.WriteLine(
                    LogLevel.Info,
                    $"Value {EnumHelper.GetName(type.Value)} is locked! Unlocking temporarily...");
                maid.UnlockTemp(type.Value);
            }

            maid.SetValue(type.Value, val);
        }