Switching activities is now a separate function.
This commit is contained in:
30
main.c
30
main.c
@@ -162,6 +162,19 @@ Hours break_time(U64 seconds)
|
||||
return hours;
|
||||
}
|
||||
|
||||
void switch_activity(activity *activities, U32 *current_activity, activity_type type, U64 time)
|
||||
{
|
||||
if((activities[*current_activity].type != type) && (0 <= type && type < activity_type_COUNT)) {
|
||||
(*current_activity)++;
|
||||
|
||||
activities[*current_activity].type = type;
|
||||
activities[*current_activity].color =
|
||||
activity_type_color_representation[type];
|
||||
activities[*current_activity].began = time;
|
||||
activities[*current_activity].ended = time;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
@@ -317,15 +330,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
for(U32 i = 0; i < activity_type_COUNT; i++) {
|
||||
if(IsKeyPressed(KEY_ONE + i)) {
|
||||
current_activity++;
|
||||
|
||||
activities[current_activity].type = i;
|
||||
activities[current_activity].color =
|
||||
activity_type_color_representation[i];
|
||||
activities[current_activity].began = now_s;
|
||||
activities[current_activity].ended = now_s;
|
||||
switch_activity(activities, ¤t_activity, i, now_s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
activities[current_activity].ended = now_s;
|
||||
@@ -375,13 +381,7 @@ int main(int argc, char *argv[])
|
||||
activity_type_color_representation[i]))
|
||||
{
|
||||
if(activities[current_activity].type != i) {
|
||||
current_activity++;
|
||||
|
||||
activities[current_activity].type = i;
|
||||
activities[current_activity].color =
|
||||
activity_type_color_representation[i];
|
||||
activities[current_activity].began = now_s;
|
||||
activities[current_activity].ended = now_s;
|
||||
switch_activity(activities, ¤t_activity, i, now_s);
|
||||
}
|
||||
}
|
||||
if(activities[current_activity].type == i)
|
||||
|
||||
Reference in New Issue
Block a user