void Window_Message::Update() { Window_Selectable::Update(); number_input_window->Update(); if (visible && !Game_Message::visible) { // The Event Page ended but the MsgBox was used in this Event // It can be closed now. TerminateMessage(); SetCloseAnimation(5); // Remove this when the Close Animation is implemented // The close animation must set the visible false flag visible = false; } else if (pause) { WaitForInput(); } else if (active) { InputChoice(); } else if (number_input_window->GetVisible()) { InputNumber(); } else if (!text.empty()) { // Output the remaining text for the current page UpdateMessage(); } else if (IsNextMessagePossible()) { // Output a new page StartMessageProcessing(); //printf("Text: %s\n", text.c_str()); if (!visible) { // The MessageBox is not open yet but text output is needed SetOpenAnimation(5); visible = true; } Game_Message::visible = true; } }
void Window_Message::InputNumber() { if (Input::IsTriggered(Input::DECISION)) { Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision)); Game_Variables[Game_Message::num_input_variable_id] = number_input_window->GetNumber(); Game_Map::SetNeedRefresh(Game_Map::Refresh_Map); TerminateMessage(); number_input_window->SetNumber(0); } }
void Window_Message::InputChoice() { if (Input::IsTriggered(Input::CANCEL)) { if (Game_Message::choice_cancel_type > 0) { Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Cancel)); Game_Message::choice_result = Game_Message::choice_cancel_type - 1; // Cancel TerminateMessage(); } } else if (Input::IsTriggered(Input::DECISION)) { if (Game_Message::choice_disabled.test(index)) { Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Buzzer)); return; } Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision)); Game_Message::choice_result = index; TerminateMessage(); } }
void Window_Message::WaitForInput() { active = true; // Enables the Pause arrow if (Input::IsTriggered(Input::DECISION) || Input::IsTriggered(Input::CANCEL)) { active = false; pause = false; if (text.empty()) { TerminateMessage(); } else if (text_index != end && new_page_after_pause) { new_page_after_pause = false; InsertNewPage(); } } }
void Window_Message::FinishMessageProcessing() { if (Game_Message::choice_max > 0) { StartChoiceProcessing(); } else if (Game_Message::num_input_variable_id > 0) { StartNumberInputProcessing(); } else if (kill_message) { TerminateMessage(); } else { pause = true; } text.clear(); text_index = text.begin(); end = text.end(); }
void Window_Message::FinishMessageProcessing() { if (Game_Message::choice_max > 0) { StartChoiceProcessing(); } else if (Game_Message::num_input_variable_id > 0) { StartNumberInputProcessing(); } else if (kill_message) { TerminateMessage(); kill_message = false; } else { pause = true; } text.clear(); text_index = boost::u8_to_u32_iterator<std::string::const_iterator>(text.begin(), text.begin(), text.end()); end = boost::u8_to_u32_iterator<std::string::const_iterator>(text.end(), text.begin(), text.end()); }
Window_Message::~Window_Message() { TerminateMessage(); Game_Message::visible = false; }
/**************************************************************************** * Retrieve the process information. ****************************************************************************/ void GetProcessInfo() { struct prpsinfo info; DIR *procdir; struct dirent *entry; unsigned long currentLastSize; int fd; int x; if(!list) { listMax = BLOCK_SIZE; list = malloc(sizeof(ProcessType) * listMax); if(!list) { TerminateMessage("out of memory"); } } else if(!lastList) { lastListSize = listSize; lastList = malloc(sizeof(ProcessTimeType) * lastListSize); if(!lastList) { TerminateMessage("out of memory"); } } else if(lastListSize < listSize) { lastListSize = listSize; lastList = realloc(lastList, sizeof(ProcessTimeType) * lastListSize); if(!lastList) { TerminateMessage("out of memory"); } } for(x = 0; x < listSize; x++) { lastList[x].pid = list[x].pid; lastList[x].ms = list[x].ms; } currentLastSize = listSize; chdir(_PATH_PROCFSPI); procdir = opendir(_PATH_PROCFSPI); if(procdir < 0) { TerminateMessage(strerror(errno)); } listSize = 0; processTotal = 0; for(x = 0; x < STATES; x++) { state[x] = 0; } while((entry = readdir(procdir))) { fd = open(entry->d_name, O_RDONLY); if(fd < 0) { continue; } if(ioctl(fd, PIOCPSINFO, &info) < 0) { close(fd); continue; } close(fd); switch(info.pr_sname) { case 'S': ++state[STATE_SLEEP]; list[listSize].state = STATE_SLEEP; break; case 'R': case '0': if(info.pr_sonproc < 0) { ++state[STATE_READY]; list[listSize].state = STATE_READY; } else { ++state[STATE_RUN]; list[listSize].state = STATE_RUN; } break; case 'Z': ++state[STATE_ZOMBIE]; list[listSize].state = STATE_ZOMBIE; break; case 'T': ++state[STATE_STOP]; list[listSize].state = STATE_STOP; break; case 'I': case 'X': case 'C': ++state[STATE_WAIT]; list[listSize].state = STATE_WAIT; break; } list[listSize].cpu = info.pr_sonproc; list[listSize].pid = info.pr_pid; list[listSize].pgrp = info.pr_pgrp; list[listSize].priority = info.pr_pri; list[listSize].size = info.pr_size * pageSize; list[listSize].res = info.pr_rssize * pageSize; list[listSize].t = info.pr_time.tv_sec; list[listSize].threads = info.pr_thds; list[listSize].ms = info.pr_time.tv_sec * 100; list[listSize].ms += info.pr_time.tv_nsec / 10000; list[listSize].pcpu = 0; for(x = 0; x < currentLastSize; x++) { if(lastList[x].pid == info.pr_pid && lastList[x].ms) { list[listSize].pcpu = list[listSize].ms; list[listSize].pcpu -= lastList[x].ms; break; } } processTotal += list[listSize].pcpu; list[listSize].uid = info.pr_uid; list[listSize].username = GetUserName(info.pr_uid); strncpy(list[listSize].command, info.pr_fname, COMMAND_SIZE); list[listSize].command[COMMAND_SIZE] = 0; ++listSize; if(listSize >= listMax) { listMax += BLOCK_SIZE; list = realloc(list, sizeof(ProcessType) * listMax); if(!list) { TerminateMessage("out of memory"); } } } closedir(procdir); }