bool BasePersistenceManager::readHeader(const Common::String &filename) {
	cleanup();

	_saving = false;

	_loadStream = g_system->getSavefileManager()->openForLoading(filename);
	//_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize);
	if (_loadStream) {
		uint32 magic;
		magic = getDWORD();

		if (magic != DCGF_MAGIC) {
			cleanup();
			return STATUS_FAILED;
		}

		magic = getDWORD();

		if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) {
			_savedVerMajor = _loadStream->readByte();
			_savedVerMinor = _loadStream->readByte();
			_savedExtMajor = _loadStream->readByte();
			_savedExtMinor = _loadStream->readByte();

			if (magic == SAVE_MAGIC_2) {
				_savedVerBuild = (byte)getDWORD();
				_savedName = getStringObj();

				// load thumbnail
				_thumbnailDataSize = getDWORD();
				if (_thumbnailDataSize > 0) {
					_thumbnailData = new byte[_thumbnailDataSize];
					if (_thumbnailData) {
						getBytes(_thumbnailData, _thumbnailDataSize);
					} else {
						_thumbnailDataSize = 0;
					}
				}
			} else {
				_savedVerBuild = 35;    // last build with ver1 savegames
			}

			uint32 dataOffset = getDWORD();

			_savedDescription = getString();
			_savedTimestamp = getTimeDate();
			_savedPlayTime = _loadStream->readUint32LE();

			_offset = dataOffset;

			return STATUS_OK;
		}
	}

	cleanup();
	return STATUS_FAILED;
}
示例#2
0
const std::string ZDAmsg::getMsg()const{
    std::ostringstream oss;
    boost::posix_time::time_duration utc_offset = zone.base_utc_offset();
    boost::posix_time::time_facet *timefacet = new boost::posix_time::time_facet("%H%M%S%F,%d,%m,%Y");
    boost::posix_time::time_facet *offsetfacet = new boost::posix_time::time_facet("");
    offsetfacet->time_duration_format("%+%H,%M");
    oss.imbue(std::locale(oss.getloc(), timefacet));
    oss << getTimeDate() << ",";
    oss.imbue(std::locale(oss.getloc(), offsetfacet));
    oss << utc_offset;
    return oss.str();
}
示例#3
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;
}	
示例#4
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);		
}
示例#5
0
void drawChooseStartTime(void){
	uint8_t modMinute = 0;
	uint8_t divMinute = 0;
	uint8_t numberOfRecords = getUnencrpytedRecordCount();
	iter = 0;
	printTime();
	printStringOnLine(1,"     Timeline     ", 1,NOBOXMENU);	
	printStringOnLine(2,"                  ", 0,NOBOXMENU);		
	
	iter = getMemMapStartIndex();
	iter = (iter + selectedRecord) % maxRecNum;
	
	if (firstPass == 0){
		timeSelection = 0;
		
		if(numberOfRecords != 0){
			//find closest time to selected time in time slot
			selectedYear = getYear(getMemMapElement(iter));
			selectedMonth = getMonth(getMemMapElement(iter));
			selectedDay = getTimeDate(getMemMapElement(iter));
			selectedDOW = getTimeDay(getMemMapElement(iter));
			selectedHour = getHour(getMemMapElement(iter));
			selectedMinute = getMinute(getMemMapElement(iter));
		}			
		
		modMinute = selectedMinute % 15;
		if(modMinute != 0){
			divMinute = selectedMinute/15;
			if(modMinute <=8)
				selectedMinute = divMinute*15;
			else
				selectedMinute = divMinute*15 + 15; 
			if(selectedMinute >= 60)
				selectedMinute = 0;
		}
		firstPass = 1;
	}
	if (timeSelection == HOUR){
		if (manipulateTime == INCREMENT){
			if ((selectedHour + 1) >= 24)
				selectedHour = 0;
			else
				selectedHour += 1;
			manipulateTime = NEUTRAL;
		}
		if (manipulateTime == DECREMENT){
			if ((selectedHour - 1) < 0)
				selectedHour = 23;
			else
				selectedHour -= 1;
			manipulateTime = NEUTRAL;		
		}
	}		
	else if (timeSelection == MINUTE){
		if (manipulateTime == INCREMENT){
			if ((selectedMinute + 15) >= 60)
				selectedMinute = 0;
			else
				selectedMinute += 15;
			manipulateTime = NEUTRAL;
		}
		else if (manipulateTime == DECREMENT){
			if ((selectedMinute - 15) < 0)
				selectedMinute = 45;
			else
				selectedMinute -= 15;
			manipulateTime = NEUTRAL;		
		}
	}	
	
	printTimeSelectionOnLine(3,selectedHour,selectedMinute,0,timeSelection);	
	
	printStringOnLine(4,"                  ", 0,NOBOXMENU);	
	printStringOnLine(5,"                  ", 1,NOBOXMENU);	
	printStringOnLine(6,"Choose Start Time ", 1,NOBOXMENU);	
	printStringOnLine(7,"                  ", 1,NOBOXMENU);	
	
}
示例#6
0
文件: Format.cpp 项目: LSTS/dune
 std::string
 Format::getTimeDate(void)
 {
   return getTimeDate(static_cast<double>(std::time(0)));
 }