MDS_DATA StopwatchMsgProc(void *obj, int message, MDS_DATA extra_data) { Stopwatch *stopwatch = (Stopwatch *)obj; if (!stopwatch->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(stopwatch->pos.x, stopwatch->pos.y); if (extra_data.integer == 0) { char *buffer = (char *)malloc(stopwatch->size.x + 1); int s = stopwatch->msec / 1000; if (buffer == NULL) break; sprintf(buffer, "%02i:%02i:%02i", s / 3600, (s % 3600) / 60, s % 60); if (stopwatch->active) con_outTxt("<%*s>", stopwatch->size.x-2, buffer); else con_outTxt("[%*s]", stopwatch->size.x-2, buffer); free(buffer); } else con_outTxt("%*s", stopwatch->size.x, ""); break; case MESSAGE_MOVE: move_object((Object *)stopwatch, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: process_keys((Object *)stopwatch, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)stopwatch, extra_data.integer); break; case MESSAGE_STOPWATCH_START: stopwatch->running = !stopwatch->running; if (stopwatch->running) { ++(stopwatch->msg_id.integer); MDS_postMessage(stopwatch, MESSAGE_STOPWATCH_INC, stopwatch->msg_id, STOPWATCH_INC); } break; case MESSAGE_STOPWATCH_INC: if (extra_data.integer == stopwatch->msg_id.integer) { stopwatch->msec += STOPWATCH_INC; if (stopwatch->running) MDS_postMessage(stopwatch, MESSAGE_STOPWATCH_INC, stopwatch->msg_id, STOPWATCH_INC); } break; } return NULL_DATA; }
void StimulusGroup::set_pattern_activity(unsigned int i) { type_pattern current = stimuli[i]; type_pattern::iterator iter; if ( binary_patterns ) { for ( iter = current.begin() ; iter != current.end() ; ++iter ) { set_activity(iter->i,scale); } } else { for ( iter = current.begin() ; iter != current.end() ; ++iter ) { set_activity(iter->i,scale*iter->gamma); } } }
void Airspaces::set_activity(const AirspaceActivity mask) { if (!mask.equals(m_day)) { m_day = mask; for (auto v = airspace_tree.begin(); v != airspace_tree.end(); ++v) v->set_activity(mask); } }
void StimulusGroup::set_pattern_activity(unsigned int i,AurynFloat setrate) { type_pattern current = stimuli[i]; type_pattern::iterator iter; for ( iter = current.begin() ; iter != current.end() ; ++iter ) { set_activity(iter->i,setrate); } }
void Entity::reload_prep(int uid) { Item* it = ref_item_uid(uid); if (!it || !it->can_reload()) { return; } Item ammo = pick_ammo_for(it); if (ammo.is_real()) { set_activity(PLAYER_ACTIVITY_RELOAD, it->time_to_reload(), it->get_uid(), ammo.get_uid()); } }
MDS_DATA ClockMsgProc(void *obj, int message, MDS_DATA extra_data) { Clock *clock = (Clock *)obj; if (!clock->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(clock->pos.x, clock->pos.y); if (extra_data.integer == 0) { time_t curr_time; struct tm * curr_time_tm; char *buffer = (char *)malloc(clock->size.x + 1); if (buffer == NULL) break; time(&curr_time); curr_time_tm = localtime(&curr_time); strftime(buffer, clock->size.x + 1, "%H:%M:%S", curr_time_tm); if (clock->active) con_outTxt("<%*s>", clock->size.x-2, buffer); else con_outTxt("[%*s]", clock->size.x-2, buffer); free(buffer); } else con_outTxt("%*s", clock->size.x, ""); break; case MESSAGE_MOVE: move_object((Object *)clock, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: process_keys((Object *)clock, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)clock, extra_data.integer); break; } return NULL_DATA; }
MDS_DATA BufferMsgProc(void *obj, int message, MDS_DATA extra_data) { Buffer *buffer = (Buffer *)obj; if (!buffer->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 con_gotoXY(buffer->pos.x, buffer->pos.y); if (extra_data.integer == -1) { con_outTxt("%*s", buffer->size.x, ""); } else { if (buffer->active) con_outTxt("<%*s>", buffer->text_len, buffer->text); else con_outTxt("[%*s]", buffer->text_len, buffer->text); } break; case MESSAGE_MOVE: move_object((Object *)buffer, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)buffer, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: if (!process_keys((Object *)buffer, extra_data.integer)) { if (extra_data.integer >= 32 && extra_data.integer <= 255) add_char(buffer, extra_data.integer); else if (extra_data.integer == CON_KEY_BACKSPACE) del_char(buffer); } break; } return NULL_DATA; }
MDS_DATA ButtonMsgProc(void *obj, int message, MDS_DATA extra_data) { Button *button = (Button *)obj; if (!button->alive) return NULL_DATA; switch (message) { case MESSAGE_RENDER: // single rendering if extra_data == 0 // erasing rendering if extra_data == -1 if (extra_data.integer == -1) { int i; for (i = 0; i < button->size.y; ++i) { con_gotoXY(button->pos.x, button->pos.y + i); con_outTxt("%*s", button->size.x, ""); } } else { char borders[5]; char *buf = (char *)malloc(button->size.x-2 + 1); if (buf == NULL) return NULL_DATA; // border format: // 02222221 // 3 text 3 // 12222220 if (button->active) strcpy(borders, " --"); else strcpy(borders, "/\\-|"); memset(buf, borders[2], button->size.x-2); buf[button->size.x-2] = '\0'; con_gotoXY(button->pos.x, button->pos.y); con_outTxt("%c%s%c", borders[0], buf, borders[1]); con_gotoXY(button->pos.x, button->pos.y + 1); con_outTxt("%c %s %c", borders[3], button->caption, borders[3]); con_gotoXY(button->pos.x, button->pos.y + 2); con_outTxt("%c%s%c", borders[1], buf, borders[0]); free(buf); } break; case MESSAGE_MOVE: move_object((Object *)button, extra_data.integer); break; case MESSAGE_FOCUS: set_activity((Object *)button, extra_data.integer); break; case MDS_MESSAGE_KEY_PRESSED: if (!process_keys((Object *)button, extra_data.integer)) if (extra_data.integer == ' ') MDS_postMessage(button->msg.receiver, button->msg.message, button->msg.extra_data, 0); break; } return NULL_DATA; }