示例#1
0
//advance to next menu screen with current selection
void incrementMenuID(){
	clearLCD();
	previousMenuID = currentMenuID;
	//Coming From...
	//[Sleep]
	if (currentMenuID == 0 || currentMenuID == 1)
		currentMenuID = 10;
	
	//[Main Menu]
	else if (currentMenuID == 10){
		if(researchPeriod == 0){
			if (selectionInMenu == 0)
				currentMenuID = 20;
			else if (selectionInMenu == 1)
				currentMenuID = 30;
			else if (selectionInMenu == 2){
				currentMenuID = 40;
			}			
			else if (selectionInMenu == 3)
				currentMenuID = 70;
			else if (selectionInMenu == 4)
				currentMenuID = 0;
			else if (selectionInMenu == 5)
				currentMenuID = 80;
		}	
		else{
			if(selectionInMenu == 3 || selectionInMenu == 4 || selectionInMenu == 5){
				if (selectionInMenu == 3)
					currentMenuID = 70;
				else if(selectionInMenu == 4)
					currentMenuID = 0;
				else if(selectionInMenu == 5)
					currentMenuID = 80;
			}					
			else
				currentMenuID = 11;	
		}						
	}
	//[Log - Choose Activity]
	else if (currentMenuID == 20){
		selectedActivity = selectionInMenu;
		selectedYear = getTimeYear();
		selectedMonth = getTimeMonth();
		selectedDate = getTimeDate();
		selectedDay = getTimeDay();
		selectedHour = getTimeHour();
		selectedMinute = getTimeMinute();
		selectedSecond = getTimeSecond();
		currentMenuID++;
	}	
	//[Log - Choose Mood]	
	else if (currentMenuID == 21){
		selectedMood = selectionInMenu;
		currentMenuID++;		
	}
	//[Log - Confirm]
	else if (currentMenuID == 22){	

		insertRecord(selectedYear,selectedMonth,selectedDate, selectedDay, selectedHour,selectedMinute,selectedSecond,selectedActivity,selectedMood);
		currentMenuID = 10;	
	}
	//[View Timeline]
	else if (currentMenuID == 30){
		currentMenuID = 10;
	}
	
	//[Edit,Add,Remove]
	else if (currentMenuID == 40){
		uint8_t numberOfRecords = getUnencrpytedRecordCount();
		if (selectionInMenu == 0){
			if(numberOfRecords == 0){
				selectedYear = getTimeYear();
				selectedMonth = getTimeMonth();
				selectedDate = getTimeDate();
				selectedDay = getTimeDay();
				currentMenuID = 42;
			}	
			else{
				currentMenuID = 41;
			}							
		}
		else{				
			if(numberOfRecords == 0)
				currentMenuID = 43;
			else{
				if (selectionInMenu == 1)
				currentMenuID = 50;
				else if (selectionInMenu == 2)
				currentMenuID = 60;
			}				
		}				
	}
	
	//[Add]
	else if (currentMenuID == 41){
		uint8_t numberOfRecords = getUnencrpytedRecordCount();
		if(numberOfRecords != 0){
			iter = getMemMapStartIndex();
			selectedRecord = (selectionInMenu + iter) % maxRecNum;
			address = getMemMapElement(selectedRecord);
		}
		else{		
			selectedMinute = getTimeMinute();
			selectedSecond = getTimeSecond();
		}		
		selectedYear = getTimeYear();
		selectedMonth = getTimeMonth();
		selectedDate = getTimeDate();
		selectedDay = getTimeDay();
		selectedHour = getTimeHour();
		firstPass = 0;
		currentMenuID = 42;
	}
	
	//[Add - choose time]
	else if (currentMenuID == 42){
		if(timeSelection == HOUR)
			timeSelection = MINUTE;
		else
			currentMenuID = 44;	
	}
	
	//[Edit - NO RECORDS]
	else if (currentMenuID == 43){
		currentMenuID = 10;
	}

	//[Add - choose Activity]
	else if (currentMenuID == 44){
		selectedActivity = selectionInMenu;
		currentMenuID = 45;
	}
	
	//[Add - choose Mood]
	else if (currentMenuID == 45){
		selectedMood = selectionInMenu;
		currentMenuID = 46;
	}
	
	//[Add - Confirm]
	else if (currentMenuID == 46){
		
		insertRecord(selectedYear,selectedMonth,selectedDate, selectedDay, selectedHour,selectedMinute,0,selectedActivity,selectedMood);
		
		currentMenuID = 10;
	}
	
	//[Edit - choose time]
	else if (currentMenuID == 50){
		start = getMemMapStartIndex();
		selectedIndex = (selectionInMenu + start) % maxRecNum;
		address = getMemMapElement(selectedIndex);
		activityInRecord = getActivity(address);
		moodInRecord = getMood(address);
		selectedHour = getHour(address);
		selectedMinute = getMinute(address);
		currentMenuID = 51;
	}
	
	//[Edit - Mood or Act]
	else if (currentMenuID == 51){
		if (selectionInMenu == 0){
			firstPass = 0;
			currentMenuID = 52;
		}			
		else if (selectionInMenu == 1)
			currentMenuID = 56;
	}

	//[Edit - Act - Choose Time]
	else if (currentMenuID == 52){
		if(timeSelection == HOUR)
			timeSelection = MINUTE;
		else
		currentMenuID = 54;
	}

	//[Edit - Act - Choose Act]
	else if (currentMenuID == 54){
		selectedActivity = selectionInMenu;
		selectedMood = moodInRecord;
		currentMenuID = 55;
	}

	//[Edit - Act - Confirm]
	else if (currentMenuID == 55){
		setHourByAddress(address,selectedHour);
		setMinuteByAddress(address,selectedMinute);
		setActivityByAddress(address,selectedActivity);		
		currentMenuID = 10;
	}

	//[Edit - Mood - Choose Mood]
	else if (currentMenuID == 56){
		selectedMood = selectionInMenu;
		selectedActivity = activityInRecord;
		currentMenuID = 57;
	}

	//[Edit - Mood - Confirm]
	else if (currentMenuID == 57){
		setMoodByAddress(address,selectedMood);
		currentMenuID = 10;
	}
	
	//[Remove - choose record]
	else if (currentMenuID == 60){
		iter = getMemMapStartIndex();
		selectedRecord = (selectionInMenu + iter) % maxRecNum;
		address = getMemMapElement(selectedRecord);
		selectedActivity = getActivity(address);
		selectedMood = getMood(address);
		selectedHour = getHour(address);
		selectedMinute = getMinute(address);
		currentMenuID = 61;
	}

	//[Remove - confirm]
	else if (currentMenuID == 61){
		deleteRecord(selectedRecord);
		currentMenuID = 10;
	}

	//[Settings]
	else if (currentMenuID == 70){
		if(selectionInMenu == 0){
			firstPass = 0;
			currentMenuID = 71;	
		}			
		else if(selectionInMenu == 1)
			currentMenuID = 72;
		else if(selectionInMenu == 2)
			currentMenuID = 73;
	}
	
	//[Settings - modify Time]
	else if (currentMenuID == 71){
		if(timeSelection == HOUR)
			timeSelection = MINUTE;
		else if (timeSelection == MINUTE)
			timeSelection = DAY;
		else if (timeSelection == DAY)
			timeSelection = MONTH;
		else if (timeSelection == MONTH)
			timeSelection = YEAR;
		else{
			currentMenuID = 70;
			modifiedTimeFlag = 1;
		}			
	}

	//[Settings - Invert Screen]
	else if (currentMenuID == 72){
		invertColours = getInvertColourSetting();
		setInvertColourSetting(!invertColours);
		invertColours = !invertColours;
	}
	
	//[Settings - Reset]
	else if (currentMenuID == 73){
		currentMenuID = 74;
	}
	
	//[Settings - Reset]
	else if (currentMenuID == 74){
		resetRecords();
		currentMenuID = 70;
	}	
			
	//[Upload]
	else if (currentMenuID == 80){
		//currentMenuID = 10;
	}
	
	selectionInFrame = 0;
	selectionInMenu = 0;
}	
示例#2
0
/*
 * Adds an achievement to the user's save profile.
 * @param pointValue The point value of how many points
 * the achievement is worth.
 * @param gameID The identification for the game.  Should be
 * 8 characters long.
 * @param achievementTitle The title of the achievement.
 */
void addAchievement(int pointValue, const char* gameID,
		const char* achievementTitle)
{
	/*
	 * A temporary holding spot for a file name.
	 */
	char fileName[65];
	/*
	 * Copies the current user name to the first part of the file name.
	 */
	strncpy(fileName, currentUser->name, 10);
	/*
	 * Copies the achievement extension (.ach) to the end of the file name.
	 */
	strncat(fileName, ".ach", 4);
	/*
	 * Makes the end of the file name null terminated.
	 */
	fileName[strlen(currentUser->name) + 4] = '\0';

	/*
	 * Changes the directory to the data directory and checks
	 * to make sure it changed correctly.
	 */
	if (chdir("data") != 0)
	{
		/*
		 * If it did not change correctly, then
		 * the data folder is created.
		 */
		mkdir("data", 0777);

		/*
		 * Then it is switched to again.
		 */
		chdir("data");
	}

	/*
	 * Changes the directory to the game's data directory and checks
	 * to make sure it changed correctly.
	 */
	if (chdir(GAME_TITLE) != 0)
	{
		/*
		 * If it did not change correctly, then
		 * the game's data folder is created.
		 */
		mkdir(GAME_TITLE, 0777);

		/*
		 * Then it is switched to again.
		 */
		chdir(GAME_TITLE);
	}

	/*
	 * The file is then opened for appending in binary mode.
	 */
	FILE* file = fopen(fileName, "a+b");

	/*
	 * Checks if the file was opened correctly.
	 */
	if (file != NULL)
	{
		/*
		 * Then, a temporary achievement is created.
		 */
		achievement_t* achievement = (achievement_t*) NULL;
		/*
		 * Then, variable i is created and set to 0.
		 */
		int i = 0;
		/*
		 * Then, i is incremented by 1 as long as
		 * i is < 8.
		 */
		for (i = 0; i < 8; i += 1)
		{
			/*
			 * Each time, a character from the game's id is set.
			 */
			achievement->gameID[i] = gameID[i];
		}
		/*
		 * Then, i is incremented by 1 as long as it is less then the max length
		 * of a achievement title.
		 */
		for (i = 0; i < MAX_ACHIEVEMENT_TITLE_LENGTH && i < strlen(
				achievementTitle); i += 1)
		{
			/*
			 * Each time, a character from the achievement title is set.
			 */
			achievement->achievementTitle[i] = achievementTitle[i];
		}
		/*
		 * The point value is then set.
		 */
		achievement->pointValue = pointValue;
		/*
		 * After that, the current day of the month as the unlocked date.
		 */
		achievement->unlockedDate.day = getTimeDayOfMonth();
		/*
		 * Then, the current month as the unlocked date.
		 */
		achievement->unlockedDate.month = getTimeMonth();
		/*
		 * Finally, the year that it was unlocked (aka: the current year) is set.
		 */
		achievement->unlockedDate.year = getTimeYear();

		/*
		 * Then, the end of the file is gone to.
		 */
		fseek(file, 0, SEEK_END);
		/*
		 * Then the achievement is written to the file.
		 */
		fwrite(achievement, 1, sizeof(achievement_t), file);
		/*
		 * After words, the file is closed.
		 */
		fclose(file);
	}
	/*
	 * Finally, the directory is changed back to the root directory.
	 */
	chdir("../../");
}
示例#3
0
//Allows user to configure the time
void drawChangeTime(void){
	selectedYear = getTimeYear();
	selectedMonth = getTimeMonth();
	selectedDay = getTimeDate();
	selectedDOW = getTimeDay();	
	selectedHour = getTimeHour();
	selectedMinute = getTimeMinute();
	selectedSecond = getTimeSecond();
	
	if(firstPass == 0){
		timeSelection = 0;
		firstPass = 1;
	}		
	
	if (timeSelection == HOUR){
		if (manipulateTime == INCREMENT){
			if ((selectedHour + 1) >= 24)
				selectedHour = 0;			
			else
				selectedHour += 1;
			setTimeHour(selectedHour);			
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedHour - 1) < 0)
				selectedHour = 23;
			else
				selectedHour -= 1;
			setTimeHour(selectedHour);
			manipulateTime = NEUTRAL;
		}
	}
	else if (timeSelection == MINUTE){
		if (manipulateTime == INCREMENT){
			if ((selectedMinute + 1) >= 60)
				selectedMinute = 0;
			else
				selectedMinute += 1;
			setTimeMinute(selectedMinute);
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedMinute - 1) < 0)
				selectedMinute = 59;
			else
				selectedMinute -= 1;
			setTimeMinute(selectedMinute);
			manipulateTime = NEUTRAL;
		}
	}		
	else if (timeSelection == DAY){
		if (manipulateTime == INCREMENT){
			if ((selectedDay + 1) >= monthDays[selectedMonth-1]+1)
				selectedDay = 1;
			else
				selectedDay += 1;
			setTimeDay(selectedDay);
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedDay - 1) < 1)
				selectedDay = monthDays[selectedMonth-1];
			else
				selectedDay -= 1;
			setTimeDay(selectedDay);
			manipulateTime = NEUTRAL;
		}
	}		
	else if (timeSelection == MONTH){
		if (manipulateTime == INCREMENT){
			if ((selectedMonth + 1) >= 13)
				selectedMonth = 1;
			else
				selectedMonth += 1;
			setTimeMonth(selectedMonth);
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedMonth - 1) < 1)
				selectedMonth = 12;
			else
				selectedMonth -= 1;
			setTimeMonth(selectedMonth);
			manipulateTime = NEUTRAL;
		}
		//selectedDay = getTimeDate();
		if(monthDays[selectedMonth-1] < selectedDay){
			selectedDay = monthDays[selectedMonth-1];
			setTimeDay(selectedDay);
		}			
	}		
	else if (timeSelection == YEAR){
		if (manipulateTime == INCREMENT){
			if ((selectedYear + 1) >= 100)
				selectedYear = 0;
			else
				selectedYear += 1;
			setTimeYear(selectedYear);
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedYear - 1) < 0)
				selectedYear = 99;
			else
				selectedYear -= 1;
			manipulateTime = NEUTRAL;
			setTimeYear(selectedYear);
		}
	}
	
	setTimeDOW(calculateDOW(selectedDay,selectedMonth,selectedYear));
	
	printTime();
	printStringOnLine(1,"  Time Settings   ", 1,NOBOXMENU);
	printStringOnLine(2,"                  ", 0,NOBOXMENU);		
	printTimeSelectionOnLine(3,selectedHour,selectedMinute,0,timeSelection);
	printDateSelectionOnLine(4,selectedDay,selectedMonth,selectedYear,0,timeSelection);
	printStringOnLine(5,"                  ", 1,NOBOXMENU);
	printStringOnLine(6,"  Set the Time    ", 1,NOBOXMENU);
	printStringOnLine(7,"                  ", 1,NOBOXMENU);		
}