Improve AutoCook feature UX

This commit is contained in:
TerraFaster 2022-08-07 17:04:50 +03:00
parent 47102ce621
commit 0826a79005
2 changed files with 39 additions and 13 deletions

View File

@ -14,6 +14,8 @@ namespace cheat::feature
app::Component_1* Profirency = nullptr;
}
static std::map<std::string, int> qualities{ {"Strange", 1}, {"Normal", 2}, {"Delicious", 3} };
static void PlayerModule_RequestPlayerCook(app::MoleMole_PlayerModule* __this, uint32_t recipeId, uint32_t avatarId, uint32_t qteQuality, uint32_t count, MethodInfo* method);
static void PlayerModule_OnPlayerCookRsp(app::MoleMole_PlayerModule* __this, app::PlayerCookRsp* rsp, MethodInfo* method);
static void CookingQtePageContext_UpdateProficiency(app::CookingQtePageContext* __this, MethodInfo* method);
@ -22,7 +24,7 @@ namespace cheat::feature
NF(f_Enabled, "Standart Cooking", "AutoCook", false),
NF(f_FastProficiency, "Fast Proficiency", "AutoCook", false),
NF(f_CountField, "Count Item", "AutoCook", 1),
NF(f_QualityField, "Quality", "AutoCook", 1)
NF(f_QualityField, "Quality", "AutoCook", "Normal")
{
HookManager::install(app::MoleMole_PlayerModule_RequestPlayerCook, PlayerModule_RequestPlayerCook);
HookManager::install(app::MoleMole_PlayerModule_OnPlayerCookRsp, PlayerModule_OnPlayerCookRsp);
@ -43,7 +45,19 @@ namespace cheat::feature
ConfigWidget("Count Item", f_CountField, 1, 1, 100,
"How much to cook at a time.\n" \
"(For standard mode only.)");
ConfigWidget("Quality Cooking", f_QualityField, 1, 1, 3, "Quality of the cook.");
if (ImGui::BeginCombo("Cooking Quality", f_QualityField.value().c_str()))
{
for (auto& [qualityName, quality] : qualities)
{
bool is_selected = (f_QualityField.value().c_str() == qualityName);
if (ImGui::Selectable(qualityName.c_str(), is_selected))
f_QualityField.value() = qualityName;
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
}
bool AutoCook::NeedStatusDraw() const
@ -53,7 +67,10 @@ namespace cheat::feature
void AutoCook::DrawStatus()
{
ImGui::Text("Auto Cooking [%s]", f_FastProficiency ? "Proficiency" : "Standart");
if (f_FastProficiency)
ImGui::Text("Auto Cooking [Proficiency]");
else
ImGui::Text("Auto Cooking [Standart, %s]", f_QualityField.value().c_str());
}
AutoCook& AutoCook::GetInstance()
@ -82,9 +99,14 @@ namespace cheat::feature
if (autoCook.f_Enabled || autoCook.f_FastProficiency)
{
autoCook.CookFoodMaxNum = app::MoleMole_Config_CookRecipeExcelConfig_CheckCookFoodMaxNum(recipeId, nullptr);
qteQuality = autoCook.f_QualityField;
if (!autoCook.f_FastProficiency && autoCook.f_Enabled){
// To prevent possible crashes
if (!qualities.count(autoCook.f_QualityField.value()))
autoCook.f_QualityField.value() = "Normal";
qteQuality = qualities.find(autoCook.f_QualityField.value())->second;
if (!autoCook.f_FastProficiency && autoCook.f_Enabled) {
count = autoCook.f_CountField;
if (autoCook.f_CountField > autoCook.CookFoodMaxNum)
count = autoCook.CookFoodMaxNum;
@ -127,7 +149,11 @@ namespace cheat::feature
AutoCook& autoCook = AutoCook::GetInstance();
if (autoCook.f_Enabled || autoCook.f_FastProficiency)
{
rsp->fields.qteQuality_ = autoCook.f_QualityField;
// To prevent possible crashes
if (!qualities.count(autoCook.f_QualityField.value()))
autoCook.f_QualityField.value() = "Normal";
rsp->fields.qteQuality_ = qualities.find(autoCook.f_QualityField.value())->second;
rsp->fields.cookCount_ = autoCook.f_CountField;
if (autoCook.f_FastProficiency)
rsp->fields.cookCount_ = 1;

View File

@ -12,7 +12,7 @@ namespace cheat::feature
config::Field<config::Toggle<Hotkey>> f_FastProficiency;
config::Field<int> f_CountField;
config::Field<int> f_QualityField;
config::Field<std::string> f_QualityField;
int CookFoodMaxNum; // Maximum quantity at a time
int CookCount;