Fix hotkey detection

develop
Anuradha Dissanayake 2013-01-03 22:01:01 +13:00
parent 581a8dd955
commit 7b561f108b
1 changed files with 71 additions and 71 deletions

@ -1679,98 +1679,99 @@ namespace wf_ui
bool AdjustmentScreen::feed(set<df::interface_key> *input, ItemConstraint *cv, ProtectedJob *pj /* = NULL */) bool AdjustmentScreen::feed(set<df::interface_key> *input, ItemConstraint *cv, ProtectedJob *pj /* = NULL */)
{ {
if ((edit_limit || edit_gap)) if (input->count(interface_key::CUSTOM_T) && !edit_limit && !edit_gap)
{ {
df::interface_key last_token = *input->rbegin(); if (!cv)
if (last_token == interface_key::STRING_A000)
{ {
// Backspace // Add tracking
if (edit_string.length() > 0) return false;
{
edit_string.erase(edit_string.length()-1);
}
return true;
} }
if (edit_string.length() >= 6) // Remove tracking
return true; if (pj)
if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A057)
{ {
// Numeric character for (vector<ItemConstraint*>::iterator it = pj->constraints.begin(); it < pj->constraints.end(); it++)
edit_string += last_token - ascii_to_enum_offset; delete_constraint(*it);
}
else if (input->count(interface_key::SELECT) || input->count(interface_key::LEAVESCREEN))
{
if (input->count(interface_key::SELECT) && edit_string.length() > 0)
{
if (edit_limit)
cv->setGoalCount(atoi(edit_string.c_str()));
else
cv->setGoalGap(atoi(edit_string.c_str()));
onConstraintChanged(); forget_job(color_ostream_proxy(Core::getInstance().getConsole()), pj);
}
edit_string.clear();
edit_limit = false;
edit_gap = false;
} }
else if (last_token == interface_key::STRING_A000) else
{ {
// Backspace delete_constraint(cv);
if (edit_string.length() > 0)
{
edit_string.erase(edit_string.length()-1);
}
} }
onConstraintChanged();
return true; return true;
} }
else if (input->count(interface_key::CUSTOM_L))
{ if (cv)
edit_string = int_to_string(cv->goalCount());
edit_limit = true;
}
else if (input->count(interface_key::CUSTOM_G))
{
edit_string = int_to_string(cv->goalGap());
edit_gap = true;
}
else if (input->count(interface_key::CUSTOM_N))
{
cv->setGoalByCount(!cv->goalByCount());
onModeChanged();
}
else if (input->count(interface_key::CUSTOM_T))
{ {
if (cv) if (edit_limit || edit_gap)
{ {
// Remove tracking df::interface_key last_token = *input->rbegin();
if (pj) if (last_token == interface_key::STRING_A000)
{ {
for (vector<ItemConstraint*>::iterator it = pj->constraints.begin(); it < pj->constraints.end(); it++) // Backspace
delete_constraint(*it); if (edit_string.length() > 0)
{
edit_string.erase(edit_string.length()-1);
}
forget_job(color_ostream_proxy(Core::getInstance().getConsole()), pj); return true;
} }
else
delete_constraint(cv); if (edit_string.length() >= 6)
return true;
if (last_token >= interface_key::STRING_A048 && last_token <= interface_key::STRING_A057)
{
// Numeric character
edit_string += last_token - ascii_to_enum_offset;
}
else if (input->count(interface_key::SELECT) || input->count(interface_key::LEAVESCREEN))
{
if (input->count(interface_key::SELECT) && edit_string.length() > 0)
{
if (edit_limit)
cv->setGoalCount(atoi(edit_string.c_str()));
else
cv->setGoalGap(atoi(edit_string.c_str()));
onConstraintChanged();
}
edit_string.clear();
edit_limit = false;
edit_gap = false;
}
else if (last_token == interface_key::STRING_A000)
{
// Backspace
if (edit_string.length() > 0)
{
edit_string.erase(edit_string.length()-1);
}
}
return true;
} }
else else if (input->count(interface_key::CUSTOM_L))
{ {
// Add tracking edit_string = int_to_string(cv->goalCount());
return false; edit_limit = true;
}
else if (input->count(interface_key::CUSTOM_G))
{
edit_string = int_to_string(cv->goalGap());
edit_gap = true;
}
else if (input->count(interface_key::CUSTOM_N))
{
cv->setGoalByCount(!cv->goalByCount());
onModeChanged();
} }
onConstraintChanged();
}
else
{
return false;
} }
return true; return false;
} }
void AdjustmentScreen::render(ItemConstraint *cv, bool in_monitor) void AdjustmentScreen::render(ItemConstraint *cv, bool in_monitor)
@ -2934,7 +2935,6 @@ namespace wf_ui
last_job = job; last_job = job;
} }
return job != NULL; return job != NULL;
} }