public void UpdateSelectedMaidValues() { if (InvokeRequired) { InvokeAsync((Action)UpdateSelectedMaidValues); return; } MaidChangeType cType = 0; Debugger.Assert( () => { int processingQueue = currentQueue; currentQueue = 1 - currentQueue; if (valueUpdateQueue[processingQueue].Count <= 0) { return; } Debugger.WriteLine(LogLevel.Info, $"Updating values (Queue {processingQueue})..."); foreach (KeyValuePair <MaidChangeType, Action> type in valueUpdateQueue[processingQueue]) { cType = type.Key; type.Value(); } valueUpdateQueue[processingQueue].Clear(); }, $"Failed to update scheduled maid value. Type: {cType}"); }
private void AddRow(MaidChangeType type, DataGridView table, IDictionary<int, MaidChangeType> dic, bool addLock = true) { string key = EnumHelper.GetName(type); int index = addLock ? table.Rows.Add(key, 0, false) : table.Rows.Add(key, 0); dic.Add(index, type); Translation.AddTranslationAction(key, s => table.Rows[index].Cells[0].Value = s); MaidParameters.Add(type, table.Rows[index]); }
private void AddRow(MaidChangeType type, DataGridView table, IDictionary<int, MaidChangeType> dic, bool addLock = true) { int index = addLock ? table.Rows.Add(Resources.GetFieldText(EnumHelper.GetName(type)), 0, false) : table.Rows.Add(Resources.GetFieldText(EnumHelper.GetName(type)), 0); dic.Add(index, type); MaidParameters.Add(type, table.Rows[index]); }
private void AddRow(MaidChangeType type, DataGridView table, IDictionary <int, MaidChangeType> dic, bool addLock = true) { string key = EnumHelper.GetName(type); int index = addLock ? table.Rows.Add(key, 0, false) : table.Rows.Add(key, 0); dic.Add(index, type); Translation.AddTranslationAction(key, s => table.Rows[index].Cells[0].Value = s); MaidParameters.Add(type, table.Rows[index]); }
private void InitField(Label label, Control control, MaidChangeType type) { if (label != null) { Translation.AddTranslatableControl(label); } if (control is CheckBox) { Translation.AddTranslatableControl(control); } uiControls.Add(control, type); InitControl(control); }
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 PatchFuncEnum(MaidChangeType tag, MethodDefinition target, MethodDefinition hook) { MethodReference hookRef = target.Module.Import(hook); FieldReference maidFieldRef = target.Module.Import(target.DeclaringType.GetField("maid_")); Instruction start = target.Body.Instructions[0]; ILProcessor il = target.Body.GetILProcessor(); il.InsertBefore(start, il.Create(OpCodes.Ldc_I4, (int)tag)); il.InsertBefore(start, il.Create(OpCodes.Ldarg_0)); il.InsertBefore(start, il.Create(OpCodes.Ldflda, maidFieldRef)); il.InsertBefore(start, il.Create(OpCodes.Ldarg_1)); il.InsertBefore(start, il.Create(OpCodes.Call, hookRef)); }
public void Unlock(MaidChangeType type) { if (ValueLocks.ContainsKey(type)) ValueLocks[type] = false; }
private void InitField(Label label, Control control, MaidChangeType type) { if (label != null) label.Text = Resources.GetFieldText(EnumHelper.GetName(type)); if (control is CheckBox) control.Text = Resources.GetFieldText(EnumHelper.GetName(type)); uiControls.Add(control, type); InitControl(control); }
public void UpdateMiscStatus(MaidChangeType tag, int enumVal) { Debugger.Assert( () => { bool newVal; switch (tag) { case MaidChangeType.Feature: newVal = Maid.Param.status_.feature.Contains((Feature) (enumVal)); if (gui.checkedListBox_feature.GetItemChecked(enumVal - 1) != newVal) { gui.updateFeature = true; gui.checkedListBox_feature.SetItemChecked(enumVal - 1, newVal); gui.updateFeature = false; } break; case MaidChangeType.Propensity: newVal = Maid.Param.status_.propensity.Contains((Propensity) (enumVal)); if (gui.checkedListBox_propensity.GetItemChecked(enumVal - 1) != newVal) { gui.updatePropensity = true; gui.checkedListBox_propensity.SetItemChecked(enumVal - 1, newVal); gui.updatePropensity = false; } break; } }, $"Failed to update misc status of type {EnumHelper.GetName(tag)}. Attempted to update option check {enumVal - 1} "); }
public void UpdateMiscStatus(MaidChangeType tag, int enumVal, bool val) { Debugger.Assert( () => { switch (tag) { case MaidChangeType.Feature: gui.updateFeature = true; gui.checkedListBox_feature.SetItemChecked(enumVal - 1, val); gui.updateFeature = false; break; case MaidChangeType.Propensity: gui.updatePropensity = true; gui.checkedListBox_propensity.SetItemChecked(enumVal - 1, val); gui.updatePropensity = false; break; } }, $"Failed to update misc status of type {EnumHelper.GetName(tag)}. Attempted to update option {enumVal - 1} to {val}."); }
public void UpdateField(MaidChangeType type) { Debugger.Assert( () => { Debugger.WriteLine($"Updating value {EnumHelper.GetName(type)}"); gui.valueUpdate[type] = true; Action updateVal; Action<MaidChangeType> updateParam; if (UpdateFunctions.TryGetValue(type, out updateVal)) updateVal(); else if (maidParamsUpdaters.TryGetValue(type, out updateParam)) updateParam(type); else Debugger.WriteLine(LogLevel.Error, $"No update function found for {EnumHelper.GetName(type)}!"); gui.valueUpdate[type] = false; }, $"Failed to update maid field for type {EnumHelper.GetName(type)}"); }
public void UpdateField(MaidChangeType type, int id, int val = -1) { Debugger.Assert( () => { Debugger.WriteLine($"Updating value {EnumHelper.GetName(type)}"); gui.valueUpdate[type] = true; Action<int, int> updateValID; if (updateFunctionsID.TryGetValue(type, out updateValID)) updateValID(id, val); gui.valueUpdate[type] = false; }, $"Failed to update maid field for type {EnumHelper.GetName(type)}"); }
private void UpdateFeaturePropensityHash(MaidChangeType e) { Status maidStatus = Maid.Param.status_; switch (e) { case MaidChangeType.FeatureHash: gui.updateFeature = true; gui.checkedListBox_feature.ClearSelected(); foreach (Feature feature in maidStatus.feature) { gui.updateFeature = true; gui.checkedListBox_feature.SetItemChecked((int) feature - 1, true); gui.updateFeature = false; } gui.updateFeature = false; break; case MaidChangeType.PropensityHash: gui.updatePropensity = true; gui.checkedListBox_propensity.ClearSelected(); foreach (Propensity propensity in maidStatus.propensity) { gui.updatePropensity = true; gui.checkedListBox_propensity.SetItemChecked((int) propensity - 1, true); gui.updatePropensity = false; } gui.updatePropensity = false; break; } }
public void Lock(MaidChangeType type) { if (ValueLocks.ContainsKey(type)) ValueLocks[type] = true; }
public bool IsLocked(MaidChangeType type) { bool result = ValueLocks[type] && !TempUnlocks[type]; Debugger.WriteLine( $"Attempting to change the value of {EnumHelper.GetName(type)}. Is locked: {ValueLocks[type]}. Is temp unlock: {TempUnlocks[type]}."); TempUnlocks[type] = false; return result; }
public bool IsHardLocked(MaidChangeType type) { return ValueLocks[type]; }
private void UpdateMaidParam(MaidChangeType type) { gui.valueUpdate[type] = true; object val; Status maidStatus = Maid.Param.status_; switch (type) { case MaidChangeType.Care: val = maidStatus.care; break; case MaidChangeType.Charm: val = maidStatus.charm; break; case MaidChangeType.CurExcite: val = maidStatus.cur_excite; break; case MaidChangeType.CurMind: val = maidStatus.cur_mind; break; case MaidChangeType.CurReason: val = maidStatus.cur_reason; break; case MaidChangeType.Elegance: val = maidStatus.elegance; break; case MaidChangeType.Frustration: val = maidStatus.frustration; break; case MaidChangeType.Hentai: val = maidStatus.hentai; break; case MaidChangeType.Housi: val = maidStatus.housi; break; case MaidChangeType.Hp: val = maidStatus.hp; break; case MaidChangeType.Inyoku: val = maidStatus.inyoku; break; case MaidChangeType.Likability: val = maidStatus.likability; break; case MaidChangeType.Lovely: val = maidStatus.lovely; break; case MaidChangeType.MaidPoint: val = maidStatus.maid_point; break; case MaidChangeType.Mind: val = maidStatus.mind; break; case MaidChangeType.MValue: val = maidStatus.m_value; break; case MaidChangeType.OthersPlayCount: val = maidStatus.others_play_count; break; case MaidChangeType.PlayNumber: val = maidStatus.play_number; break; case MaidChangeType.Reason: val = maidStatus.reason; break; case MaidChangeType.Reception: val = maidStatus.reception; break; case MaidChangeType.StudyRate: val = maidStatus.study_rate; break; case MaidChangeType.TeachRate: val = maidStatus.teach_rate; break; case MaidChangeType.YotogiPlayCount: val = maidStatus.yotogi_play_count; break; case MaidChangeType.SexualBack: val = maidStatus.sexual.back; break; case MaidChangeType.SexualCuri: val = maidStatus.sexual.curi; break; case MaidChangeType.SexualFront: val = maidStatus.sexual.front; break; case MaidChangeType.SexualMouth: val = maidStatus.sexual.mouth; break; case MaidChangeType.SexualNipple: val = maidStatus.sexual.nipple; break; case MaidChangeType.SexualThroat: val = maidStatus.sexual.throat; break; case MaidChangeType.Sales: val = maidStatus.sales; break; case MaidChangeType.TotalSales: val = maidStatus.total_sales; break; case MaidChangeType.Evaluation: val = maidStatus.evaluation; break; case MaidChangeType.TotalEvaluation: val = maidStatus.total_sales; break; case MaidChangeType.CurHp: val = maidStatus.cur_hp; break; case MaidChangeType.PopularRank: val = maidStatus.popular_rank; break; case MaidChangeType.BonusCare: val = maidStatus.maid_class_bonus_status.care; break; case MaidChangeType.BonusCharm: val = maidStatus.maid_class_bonus_status.charm; break; case MaidChangeType.BonusElegance: val = maidStatus.maid_class_bonus_status.elegance; break; case MaidChangeType.BonusHentai: val = maidStatus.maid_class_bonus_status.hentai; break; case MaidChangeType.BonusHousi: val = maidStatus.maid_class_bonus_status.housi; break; case MaidChangeType.BonusHp: val = maidStatus.maid_class_bonus_status.hp; break; case MaidChangeType.BonusInyoku: val = maidStatus.maid_class_bonus_status.inyoku; break; case MaidChangeType.BonusLovely: val = maidStatus.maid_class_bonus_status.lovely; break; case MaidChangeType.BonusMind: val = maidStatus.maid_class_bonus_status.mind; break; case MaidChangeType.BonusMValue: val = maidStatus.maid_class_bonus_status.m_value; break; case MaidChangeType.BonusReception: val = maidStatus.maid_class_bonus_status.reception; break; case MaidChangeType.BonusTeachRate: val = maidStatus.maid_class_bonus_status.teach_rate; break; default: val = "ERROR"; break; } Debugger.Assert( () => { gui.MaidParameters[type].Cells[PARAMS_COLUMN_VALUE].Value = val; gui.valueUpdate[type] = false; }, $"Failed to update maid parameter {EnumHelper.GetName(type)} for maid {Maid.Param.status.first_name} {Maid.Param.status.last_name}"); }
public void UnlockTemp(MaidChangeType type) { if (TempUnlocks.ContainsKey(type)) TempUnlocks[type] = true; }
public void SetValue(MaidChangeType type, object val) { Debugger.Assert( () => { Debugger.WriteLine($"Setting {EnumHelper.GetName(type)} to {val}"); Action<int> setValInt; Action<long> setValLong; Action<string> setValString; Action<bool> setValBool; if (setFunctionsInt.TryGetValue(type, out setValInt)) { int v; string str = val as string; #pragma warning disable 642 if (str != null && int.TryParse(str, out v)) ; #pragma warning restore 642 else if (val is int) v = (int) val; else return; setValInt(v); } else if (setFunctionsLong.TryGetValue(type, out setValLong)) { long v; string str = val as string; if (str == null || !long.TryParse(str, out v)) return; setValLong(v); } else if (val is string && setFunctionsString.TryGetValue(type, out setValString)) setValString((string) val); else if (val is bool && setFunctionsBool.TryGetValue(type, out setValBool)) setValBool((bool) val); else Debugger.WriteLine(LogLevel.Error, $"No setter function found for {EnumHelper.GetName(type)}!"); }, $"Failed to set value for type {EnumHelper.GetName(type)} to {val}"); }
private void PatchFuncEnumBool(MaidChangeType tag, MethodDefinition target, MethodDefinition hook) { MethodReference hookRef = target.Module.Import(hook); FieldReference maidFieldRef = target.Module.Import(target.DeclaringType.GetField("maid_")); Instruction start = target.Body.Instructions[0]; ILProcessor il = target.Body.GetILProcessor(); il.InsertBefore(start, il.Create(OpCodes.Ldc_I4, (int) tag)); il.InsertBefore(start, il.Create(OpCodes.Ldarg_0)); il.InsertBefore(start, il.Create(OpCodes.Ldflda, maidFieldRef)); il.InsertBefore(start, il.Create(OpCodes.Ldarg_1)); il.InsertBefore(start, il.Create(OpCodes.Ldarg_2)); il.InsertBefore(start, il.Create(OpCodes.Call, hookRef)); }
private void InitField(Label label, Control control, MaidChangeType type) { if (label != null) Translation.AddTranslatableControl(label); if (control is CheckBox) Translation.AddTranslatableControl(control); uiControls.Add(control, type); InitControl(control); }