bool MenuCreateApplication::handleKeyPress(int key) {
    if (key == KEY_F(2)) {
        //TODO: verify
        StateType state = m_pWorkExperienceMenu->show();
        if (state == STATE_SUCCESS) {
            setReturnState(STATE_SUCCESS);
        }
        hide();
        return true;
    } else if (key == KEY_F(3)) {
        setReturnState(STATE_CANCEL);
        hide();
        return true;
    } else if (key == KEY_F(5)) {
        if (m_pApplication != 0) {
            m_pApplication->setStatus(STATUS_CLOSED);
            m_pApplication->saveToFile();
            setReturnState(STATE_CANCEL);
            hide();
            DialogYesNo* pDia = new DialogYesNo("Application closed.", DIALOG_MESSAGE);
            pDia->show();
            delete pDia;
            return true;            
        }
    }
    return false;
}
bool MenuWorkExperience::handleKeyPress(int key) {
    if (key == KEY_F(2)) {
        //TODO: verify
        setReturnState(STATE_SUCCESS);
        hide();
        return true;
    } else if (key == KEY_F(3)) {
        setReturnState(STATE_CANCEL);
        hide();
        return true;
    }
    return false;
}
/*
 * Constructor for create-style menu
 */
MenuCreateApplication::MenuCreateApplication(const std::string& course, const std::string& student, bool isGraduate)
: Panel("Create " + course + " Application: Enter Course Info", 70), m_strCourse(course), m_strStudentID(student) {
    setReturnState(STATE_ERROR);
    m_pApplication = 0;
    init(isGraduate);
    m_pWorkExperienceMenu = new MenuWorkExperience("Create " + m_strCourse + " Application: Enter Work Experience");
    if (pRelatedCoursesTable != 0) {
        add(pRelatedCoursesTable);
    }
    add(pTaCoursesTable);
}
Beispiel #4
0
	//--------------------------------------------------------------------------
	void AIController::onPursueResult( Bool isFinish )
	{
		if(!isFinish)
		{
			setReturnState();
			mIsContinuePursue = false;
			return;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
		}

		mFightState = FS_ATTACK;
		mAttackState = AS_STARTATTACK;
	}
Beispiel #5
0
DialogForm::DialogForm(const std::string &title, int numFields, bool allowEmpty) : Panel(title), m_numFields(numFields) {
    m_curField = 0;
    m_rows = 0;
    m_cols = 0;
    allowEmptyFields = allowEmpty;
    
    //Create field array, init to null
    m_pFields = new FIELD*[numFields + 1];
    for (int i = 0; i < numFields; i++) {
        m_pFields[i] = 0;
    }
    
    setReturnState(STATE_ERROR); //Default return is error
}
/*
 * Constructor for edit-style menu
 */
MenuCreateApplication::MenuCreateApplication(TaApplication *pApp, bool isGraduate, bool editable) : Panel("Edit Application: Enter Course Info", 70) {
    setReturnState(STATE_ERROR);
    if (pApp == 0) {
        return;
    }
    m_pApplication = pApp;
    m_strCourse = pApp->getCourse();
    m_strStudentID = pApp->getStudentID();
    init(isGraduate, editable);
    //Add related courses to table
    {
        Node<TaApplication::RelatedCourse>* pCur = pApp->getRelatedCourses();
        while (pCur != 0) {
            std::string pData[4] = {pCur->value.m_course, StringUtil::itos(pCur->value.m_year), "", pCur->value.m_grade};
            pData[2] = pCur->value.m_term;
            pRelatedCoursesTable->addRow(pData);
            pCur = pCur->m_pNext;
        }
    }
    //Add ta'd courses to table
    {
        Node<TaApplication::TaCourse>* pCur = pApp->getTaCourses();
        while (pCur != 0) {
            std::string pData[4] = {pCur->value.m_course, StringUtil::itos(pCur->value.m_year), "", pCur->value.m_supervisor};
            pData[2] = pCur->value.m_term;
            pTaCoursesTable->addRow(pData);
            pCur = pCur->m_pNext;
        }
    }
    
    m_pWorkExperienceMenu = new MenuWorkExperience("Edit Application: Enter Work Experience", pApp, editable);
    if (pRelatedCoursesTable != 0) {
        add(pRelatedCoursesTable);
    }
    add(pTaCoursesTable);
    
    add(new Label(this, "Close Application: F5", 1, getHeight() - 3));
}
MenuWorkExperience::MenuWorkExperience(const std::string& title, TaApplication* pApp, bool editable) : Panel(title, 70) {
    setReturnState(STATE_ERROR);
    std::string labels[] = {"Job", "Description", "Start Date", "End Date"};
    int colWidths[] = {16, 32, 8, 8};
    
    m_pWorkExperienceTable = new Table(this, 1, 4, 16, 4, colWidths, labels, editable);
    if (pApp != 0) {
        //Add work exp. to table
        {
            Node<TaApplication::WorkExperience>* pCur = pApp->getWorkExperience();
            while (pCur != 0) {
                std::string pData[4] = {pCur->value.m_job, pCur->value.m_description, pCur->value.m_start, pCur->value.m_end};
                m_pWorkExperienceTable->addRow(pData);
                pCur = pCur->m_pNext;
            }
        }
    }
    add(m_pWorkExperienceTable);
    
    add(new Label(this, "Work Experience", m_pWorkExperienceTable->getX(), 3));
    add(new Label(this, "Cancel: F3", 1, getHeight() - 2));
    add(new Label(this, "Continue: F2", getWidth() - 13, getHeight() - 2));
}
Beispiel #8
0
/*
 * Overrides Panel's waitForInput().
 */
bool DialogForm::handleKeyPress(int key) {
    if (key == KEY_UP) {
        //Move up a field
        if (isFieldValid()) {
            form_driver(m_pForm, REQ_UP_FIELD);
            form_driver(m_pForm, REQ_END_LINE);
        }
    }
    else if (key == KEY_DOWN || key == 9) {
        //Move down a field
        if (isFieldValid()) {
            form_driver(m_pForm, REQ_NEXT_FIELD);
            form_driver(m_pForm, REQ_END_LINE);    
        }
    }
    else if (key == KEY_LEFT) {
        //Move left in field
        if (form_driver(m_pForm, REQ_LEFT_CHAR) != E_OK) {
            if (isFieldValid()) {
                form_driver(m_pForm, REQ_LEFT_FIELD);
                form_driver(m_pForm, REQ_END_LINE);
            }
        }
    }
    else if (key == KEY_RIGHT) {
        //TODO: Stop right arrow working as spacebar
        //Move right in field
        if (form_driver(m_pForm, REQ_RIGHT_CHAR) != E_OK) {
            if (isFieldValid()) {
                form_driver(m_pForm, REQ_RIGHT_FIELD);
                form_driver(m_pForm, REQ_END_LINE);
            }
        }  
    }
    else if (key == 9) { //Tab key
        //Move to next field
        if (isFieldValid()) {
            form_driver(m_pForm, REQ_NEXT_FIELD);
            form_driver(m_pForm, REQ_END_LINE);
        }
    }
    else if (key == KEY_BACKSPACE || key == 127) {
        //Delete prev. char
        form_driver(m_pForm, REQ_DEL_PREV);
    }
    else if (key == KEY_F(2)) {
        if (isDataValid()) {
            setReturnState(STATE_SUCCESS);
            hide();
            return true;
        }
    }
    else if (key == KEY_F(3)) {
        setReturnState(STATE_CANCEL);
        hide();
    }
    else {
        //Send key to form driver
        form_driver(m_pForm, key);
    }
    
    return true; //Always consume the event
}
Beispiel #9
0
	//-------------------------------------------------------------------------
	void AIController::onTargetDied()
	{
		setReturnState();
	}