/** * @brief Opens the mission computer window. */ static void misn_open( unsigned int wid ) { int w, h; int y; /* Mark as generated. */ land_tabGenerate(LAND_WINDOW_MISSION); /* Get window dimensions. */ window_dimWindow( wid, &w, &h ); /* Set window functions. */ window_onClose( wid, misn_close ); /* buttons */ window_addButtonKey( wid, -20, 20, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnCloseMission", "Take Off", land_buttonTakeoff, SDLK_t ); window_addButtonKey( wid, -20, 40+LAND_BUTTON_HEIGHT, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnAcceptMission", "Accept Mission", misn_accept, SDLK_a ); /* text */ y = -60; window_addText( wid, w/2 + 10, y, w/2 - 30, 40, 0, "txtSDate", NULL, &cDConsole, "Date:\n" "Free Space:"); window_addText( wid, w/2 + 110, y, w/2 - 90, 40, 0, "txtDate", NULL, &cBlack, NULL ); y -= 2 * gl_defFont.h + 50; window_addText( wid, w/2 + 10, y, w/2 - 30, 20, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, w/2 + 70, y, w/2 - 90, 20, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); y -= 20; window_addText( wid, w/2 + 10, y, w/2 - 30, h/2-90, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* map */ map_show( wid, 20, 20, w/2 - 30, h/2 - 35, 0.75 ); misn_genList(wid, 1); /* Set default keyboard focuse to the list */ window_setFocus( wid , "lstMission" ); }
/** * @brief Opens the mission computer window. */ static void misn_open( unsigned int wid ) { int w, h; int y; /* Get window dimensions. */ window_dimWindow( wid, &w, &h ); /* Set window functions. */ window_onClose( wid, misn_close ); /* buttons */ window_addButton( wid, -20, 20, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnCloseMission", "Takeoff", land_buttonTakeoff ); window_addButton( wid, -20, 40+LAND_BUTTON_HEIGHT, LAND_BUTTON_WIDTH,LAND_BUTTON_HEIGHT, "btnAcceptMission", "Accept Mission", misn_accept ); /* text */ y = -60; window_addText( wid, w/2 + 10, y, w/2 - 30, 40, 0, "txtSDate", NULL, &cDConsole, "Date:\n" "Free Space:"); window_addText( wid, w/2 + 110, y, w/2 - 90, 40, 0, "txtDate", NULL, &cBlack, NULL ); y -= 2 * gl_defFont.h + 50; window_addText( wid, w/2 + 10, y, w/2 - 30, 20, 0, "txtSReward", &gl_smallFont, &cDConsole, "Reward:" ); window_addText( wid, w/2 + 70, y, w/2 - 90, 20, 0, "txtReward", &gl_smallFont, &cBlack, NULL ); y -= 20; window_addText( wid, w/2 + 10, y, w/2 - 30, h/2-90, 0, "txtDesc", &gl_smallFont, &cBlack, NULL ); /* map */ map_show( wid, 20, 20, w/2 - 30, h/2 - 35, 0.75 ); misn_genList(wid, 1); }
/** * @brief Accepts the selected mission. * @param wid Window of the mission computer. * @param str Unused. */ static void misn_accept( unsigned int wid, char* str ) { (void) str; char* misn_name; Mission* misn; int pos; int i, ret; misn_name = toolkit_getList( wid, "lstMission" ); /* Make sure you have missions. */ if (strcmp(misn_name,"No Missions")==0) return; /* Make sure player can accept the mission. */ for (i=0; i<MISSION_MAX; i++) if (player_missions[i].data == NULL) break; if (i >= MISSION_MAX) { dialogue_alert("You have too many active missions."); return; } if (dialogue_YesNo("Accept Mission", "Are you sure you want to accept this mission?")) { pos = toolkit_getListPos( wid, "lstMission" ); misn = &mission_computer[pos]; ret = mission_accept( misn ); if ((ret==0) || (ret==2) || (ret==-1)) { /* success in accepting the mission */ if (ret==-1) mission_cleanup( &mission_computer[pos] ); memmove( &mission_computer[pos], &mission_computer[pos+1], sizeof(Mission) * (mission_ncomputer-pos-1) ); mission_ncomputer--; /* Regenerate list. */ misn_genList(wid, 0); /* Add position persistancey after a mission has been accepted */ /* NOTE: toolkit_setListPos protects us from a bad position by clamping */ toolkit_setListPos( wid, "lstMission", pos-1 ); /*looks better without the -1, makes more sense with*/ } /* Reset markers. */ mission_sysMark(); } }