예제 #1
0
String DateTime::FormatTime(DateFormat format) const
{
	StringBuilder sbFinal;
	wchar szBuffer[12];

	FormatInt32(m_hour, szBuffer, 2, '0');
	sbFinal += szBuffer;

	if( format != DateFormat::Compact )
	{
		sbFinal += ":";
	}
	FormatInt32(m_minute, szBuffer, 2, '0');
	sbFinal += szBuffer;


	if( format != DateFormat::Compact )
	{
		sbFinal += ":";
	}
	FormatInt32(m_second, szBuffer, 2, '0');
	sbFinal += szBuffer;

	return sbFinal.ToString();
}
예제 #2
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveFactory(FFlareFactorySave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetBoolField("Active", Data->Active);
	JsonObject->SetStringField("CostReserved", FormatInt32(Data->CostReserved));
	JsonObject->SetStringField("ProductedDuration", FormatInt64(Data->ProductedDuration));
	JsonObject->SetBoolField("InfiniteCycle", Data->InfiniteCycle);
	JsonObject->SetStringField("CycleCount", FormatInt32(Data->CycleCount));
	JsonObject->SetStringField("TargetShipClass", Data->TargetShipClass.ToString());
	JsonObject->SetStringField("TargetShipCompany", Data->TargetShipCompany.ToString());
	JsonObject->SetStringField("OrderShipClass", Data->OrderShipClass.ToString());
	JsonObject->SetStringField("OrderShipCompany", Data->OrderShipCompany.ToString());
	JsonObject->SetStringField("OrderShipAdvancePayment", FormatInt32(Data->OrderShipAdvancePayment));

	TArray< TSharedPtr<FJsonValue> > ResourceReserved;
	for(int i = 0; i < Data->ResourceReserved.Num(); i++)
	{
		ResourceReserved.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->ResourceReserved[i]))));
	}
	JsonObject->SetArrayField("ResourceReserved", ResourceReserved);

	TArray< TSharedPtr<FJsonValue> > OutputCargoLimit;
	for(int i = 0; i < Data->OutputCargoLimit.Num(); i++)
	{
		OutputCargoLimit.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->OutputCargoLimit[i]))));
	}
	JsonObject->SetArrayField("OutputCargoLimit", OutputCargoLimit);

	return JsonObject;
}
예제 #3
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveSpacecraft(FFlareSpacecraftSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Immatriculation", Data->Immatriculation.ToString());
	JsonObject->SetStringField("NickName", Data->NickName.ToString());
	JsonObject->SetStringField("Identifier", Data->Identifier.ToString());
	JsonObject->SetStringField("CompanyIdentifier", Data->CompanyIdentifier.ToString());
	JsonObject->SetStringField("Location", FormatVector(Data->Location));
	JsonObject->SetStringField("Rotation", FormatRotator(Data->Rotation));
	JsonObject->SetStringField("SpawnMode", FormatEnum<EFlareSpawnMode::Type>("EFlareSpawnMode",Data->SpawnMode));
	JsonObject->SetStringField("LinearVelocity", FormatVector(Data->LinearVelocity));
	JsonObject->SetStringField("AngularVelocity", FormatVector(Data->AngularVelocity));
	JsonObject->SetStringField("DockedTo", Data->DockedTo.ToString());
	JsonObject->SetStringField("DockedAt", FormatInt32(Data->DockedAt));
	SaveFloat(JsonObject,"Heat", Data->Heat);
	SaveFloat(JsonObject,"PowerOutageDelay", Data->PowerOutageDelay);
	SaveFloat(JsonObject,"PowerOutageAcculumator", Data->PowerOutageAcculumator);
	JsonObject->SetStringField("DynamicComponentStateIdentifier", Data->DynamicComponentStateIdentifier.ToString());
	SaveFloat(JsonObject,"DynamicComponentStateProgress", Data->DynamicComponentStateProgress);
	JsonObject->SetStringField("Level", FormatInt32(Data->Level));
	JsonObject->SetBoolField("IsTrading", Data->IsTrading);
	JsonObject->SetObjectField("Pilot", SavePilot(&Data->Pilot));
	JsonObject->SetObjectField("Asteroid", SaveAsteroid(&Data->AsteroidData));

	TArray< TSharedPtr<FJsonValue> > Components;
	for(int i = 0; i < Data->Components.Num(); i++)
	{
		Components.Add(MakeShareable(new FJsonValueObject(SaveSpacecraftComponent(&Data->Components[i]))));
	}
	JsonObject->SetArrayField("Components", Components);

	TArray< TSharedPtr<FJsonValue> > Cargo;
	for(int i = 0; i < Data->Cargo.Num(); i++)
	{
		Cargo.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->Cargo[i]))));
	}
	JsonObject->SetArrayField("Cargo", Cargo);

	TArray< TSharedPtr<FJsonValue> > FactoryStates;
	for(int i = 0; i < Data->FactoryStates.Num(); i++)
	{
		FactoryStates.Add(MakeShareable(new FJsonValueObject(SaveFactory(&Data->FactoryStates[i]))));
	}
	JsonObject->SetArrayField("FactoryStates", FactoryStates);


	TArray< TSharedPtr<FJsonValue> > SalesExcludedResources;
	for(int i = 0; i < Data->SalesExcludedResources.Num(); i++)
	{
		SalesExcludedResources.Add(MakeShareable(new FJsonValueString(Data->SalesExcludedResources[i].ToString())));
	}
	JsonObject->SetArrayField("SalesExcludedResources", SalesExcludedResources);

	return JsonObject;
}
예제 #4
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveTradeOperation(FFlareTradeRouteSectorOperationSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("ResourceIdentifier", Data->ResourceIdentifier.ToString());
	JsonObject->SetStringField("MaxQuantity", FormatInt32(Data->MaxQuantity));
	JsonObject->SetStringField("MaxWait", FormatInt32(Data->MaxWait));
	JsonObject->SetStringField("Type", FormatEnum<EFlareTradeRouteOperation::Type>("EFlareTradeRouteOperation",Data->Type));

	return JsonObject;
}
예제 #5
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveCompanyDescription(FFlareCompanyDescription* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Name", Data->Name.ToString());
	JsonObject->SetStringField("ShortName", Data->ShortName.ToString());
	JsonObject->SetStringField("Description", Data->Description.ToString());
	JsonObject->SetStringField("CustomizationBasePaintColorIndex", FormatInt32(Data->CustomizationBasePaintColorIndex));
	JsonObject->SetStringField("CustomizationPaintColorIndex", FormatInt32(Data->CustomizationPaintColorIndex));
	JsonObject->SetStringField("CustomizationOverlayColorIndex", FormatInt32(Data->CustomizationOverlayColorIndex));
	JsonObject->SetStringField("CustomizationLightColorIndex", FormatInt32(Data->CustomizationLightColorIndex));
	JsonObject->SetStringField("CustomizationPatternIndex", FormatInt32(Data->CustomizationPatternIndex));

	return JsonObject;
}
예제 #6
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveGame(UFlareSaveGame* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	// General stuff
	JsonObject->SetStringField("Game", "Helium Rain");
	JsonObject->SetStringField("SaveFormat", FormatInt32(1));

	// Game data
	JsonObject->SetObjectField("Player", SavePlayer(&Data->PlayerData));
	JsonObject->SetObjectField("PlayerCompanyDescription", SaveCompanyDescription(&Data->PlayerCompanyDescription));
	JsonObject->SetStringField("CurrentImmatriculationIndex", FormatInt32(Data->CurrentImmatriculationIndex));
	JsonObject->SetObjectField("World", SaveWorld(&Data->WorldData));

	return JsonObject;
}
예제 #7
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveSpacecraftComponentWeapon(FFlareSpacecraftComponentWeaponSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("FiredAmmo", FormatInt32(Data->FiredAmmo));

	return JsonObject;
}
예제 #8
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveFloatBuffer(FFlareFloatBuffer* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("MaxSize", FormatInt32(Data->MaxSize));
	JsonObject->SetStringField("WriteIndex", FormatInt32(Data->WriteIndex));



	TArray< TSharedPtr<FJsonValue> > Values;
	for(int i = 0; i < Data->Values.Num(); i++)
	{
		Values.Add(MakeShareable(new FJsonValueNumber(Data->Values[i])));
	}
	JsonObject->SetArrayField("Values", Values);

	return JsonObject;
}
예제 #9
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveCargo(FFlareCargoSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("ResourceIdentifier", Data->ResourceIdentifier.ToString());
	JsonObject->SetStringField("Quantity", FormatInt32(Data->Quantity));
	JsonObject->SetStringField("Lock", FormatEnum<EFlareResourceLock::Type>("EFlareResourceLock",Data->Lock));

	return JsonObject;
}
예제 #10
0
TSharedRef<FJsonObject> UFlareSaveWriter::SavePlayer(FFlarePlayerSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("ScenarioId", FormatInt32(Data->ScenarioId));
	JsonObject->SetStringField("CompanyIdentifier", Data->CompanyIdentifier.ToString());
	JsonObject->SetStringField("LastFlownShipIdentifier", Data->LastFlownShipIdentifier.ToString());
	JsonObject->SetObjectField("Quest", SaveQuest(&Data->QuestData));

	return JsonObject;
}
예제 #11
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveQuestStepProgress(FFlareQuestStepProgressSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("ConditionIdentifier", Data->ConditionIdentifier.ToString());
	JsonObject->SetStringField("CurrentProgression", FormatInt32(Data->CurrentProgression));
	JsonObject->SetStringField("InitialTransform", FormatTransform(Data->InitialTransform));
	SaveFloat(JsonObject,"InitialVelocity", Data->InitialVelocity);

	return JsonObject;
}
예제 #12
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveTradeRoute(FFlareTradeRouteSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Name", Data->Name.ToString());
	JsonObject->SetStringField("Identifier", Data->Identifier.ToString());
	JsonObject->SetStringField("FleetIdentifier", Data->FleetIdentifier.ToString());
	JsonObject->SetStringField("TargetSectorIdentifier", Data->TargetSectorIdentifier.ToString());
	JsonObject->SetStringField("CurrentOperationIndex", FormatInt32(Data->CurrentOperationIndex));
	JsonObject->SetStringField("CurrentOperationProgress", FormatInt32(Data->CurrentOperationProgress));
	JsonObject->SetStringField("CurrentOperationDuration", FormatInt32(Data->CurrentOperationDuration));
	JsonObject->SetBoolField("IsPaused", Data->IsPaused);

	TArray< TSharedPtr<FJsonValue> > Sectors;
	for(int i = 0; i < Data->Sectors.Num(); i++)
	{
		Sectors.Add(MakeShareable(new FJsonValueObject(SaveTradeRouteSector(&Data->Sectors[i]))));
	}
	JsonObject->SetArrayField("Sectors", Sectors);

	return JsonObject;
}
예제 #13
0
void Duration::FormatSmall(class String& str) const
{
	int days;
	int hours;
	int minutes;
	int seconds;
	int milliseconds;
	Split(days, hours, minutes, seconds, milliseconds);

	String strDays, strHours, strMinutes, strSeconds;
	wchar szBuffer[12];

	if( days > 0 )
	{
		FormatInt32(days, szBuffer);
		strDays = String(szBuffer) + " j";
	}

	if( hours > 0 )
	{
		FormatInt32(hours, szBuffer);
		strHours = String(szBuffer) + " h";
	}

	if( minutes > 0 )
	{
		FormatInt32(minutes, szBuffer);
		strMinutes = String(szBuffer) + " m";
	}
	
	if( seconds > 0 )
	{
		FormatInt32(seconds, szBuffer);
		strSeconds = String(szBuffer) + " s";
	}

	str = strDays + strHours + strMinutes + strSeconds;
}
예제 #14
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveAsteroid(FFlareAsteroidSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Identifier", Data->Identifier.ToString());
	JsonObject->SetStringField("Location", FormatVector(Data->Location));
	JsonObject->SetStringField("Rotation", FormatRotator(Data->Rotation));
	JsonObject->SetStringField("LinearVelocity", FormatVector(Data->LinearVelocity));
	JsonObject->SetStringField("AngularVelocity", FormatVector(Data->AngularVelocity));
	JsonObject->SetStringField("Scale", FormatVector(Data->Scale));
	JsonObject->SetStringField("AsteroidMeshID", FormatInt32(Data->AsteroidMeshID));

	return JsonObject;
}
예제 #15
0
//////////////////////////////////////////////////////////////////////
// Formats date only as YYYY-MM-DD (ISO 8601)
String DateTime::FormatDate(DateFormat format) const
{
	StringBuilder sbFinal;
	wchar szBuffer[12];

	FormatInt32(m_year, szBuffer, 4, '0');
	sbFinal += szBuffer;

	if( format != DateFormat::Compact )
	{
		sbFinal += "-";
	}
	FormatInt32(m_month, szBuffer, 2, '0');
	sbFinal += szBuffer;

	if( format != DateFormat::Compact )
	{
		sbFinal += "-";
	}
	FormatInt32(m_day, szBuffer, 2, '0');
	sbFinal += szBuffer;

	return sbFinal.ToString();
}
예제 #16
0
void Duration::FormatFrench(String& str) const
{
	int days, hours, minutes, seconds, milliseconds;
	Split(days, hours, minutes, seconds, milliseconds);

	String strDays, strHours, strMinutes, strSeconds;
	wchar szBuffer[12];

	if( days > 0 )
	{
		if( days == 1 )
		{
			strDays = "1 jour ";
		}
		else
		{
			FormatInt32(days, szBuffer);
			strDays = String(szBuffer) + " jours";
		}
	}

	if( hours > 0 )
	{
		if( hours == 1 )
		{
			strHours = "1 heure ";
		}
		else
		{
			FormatInt32(hours, szBuffer);
			strHours = String(szBuffer) + " heures";
		}
	}

	if( minutes > 0 )
	{
		if( minutes == 1 )
		{
			strMinutes = "1 minute ";
		}
		else
		{
			FormatInt32(minutes, szBuffer);
			strMinutes = String(szBuffer) + " minutes";
		}
	}
	
	if( seconds > 0 )
	{
		if( seconds == 1 )
		{
			strSeconds = "1 seconde";
		}
		else
		{
			FormatInt32(seconds, szBuffer);
			strSeconds = String(szBuffer) + " secondes";
		}
	}

	str = strDays + strHours + strMinutes + strSeconds;
}
예제 #17
0
TSharedRef<FJsonObject> UFlareSaveWriter::SavePeople(FFlarePeopleSave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Population", FormatInt32(Data->Population));
	JsonObject->SetStringField("FoodStock", FormatInt32(Data->FoodStock));
	JsonObject->SetStringField("FuelStock", FormatInt32(Data->FuelStock));
	JsonObject->SetStringField("ToolStock", FormatInt32(Data->ToolStock));
	JsonObject->SetStringField("TechStock", FormatInt32(Data->TechStock));
	SaveFloat(JsonObject,"FoodConsumption", Data->FoodConsumption);
	SaveFloat(JsonObject,"FuelConsumption", Data->FuelConsumption);
	SaveFloat(JsonObject,"ToolConsumption", Data->ToolConsumption);
	SaveFloat(JsonObject,"TechConsumption", Data->TechConsumption);
	JsonObject->SetStringField("Money", FormatInt32(Data->Money));
	JsonObject->SetStringField("Dept", FormatInt32(Data->Dept));
	JsonObject->SetStringField("BirthPoint", FormatInt32(Data->BirthPoint));
	JsonObject->SetStringField("DeathPoint", FormatInt32(Data->DeathPoint));
	JsonObject->SetStringField("HungerPoint", FormatInt32(Data->HungerPoint));
	JsonObject->SetStringField("HappinessPoint", FormatInt32(Data->HappinessPoint));

	TArray< TSharedPtr<FJsonValue> > CompanyReputations;
	for(int i = 0; i < Data->CompanyReputations.Num(); i++)
	{
		CompanyReputations.Add(MakeShareable(new FJsonValueObject(SaveCompanyReputation(&Data->CompanyReputations[i]))));
	}
	JsonObject->SetArrayField("CompanyReputations", CompanyReputations);


	return JsonObject;
}
예제 #18
0
TSharedRef<FJsonObject> UFlareSaveWriter::SaveCompany(FFlareCompanySave* Data)
{
	TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject());

	JsonObject->SetStringField("Identifier", Data->Identifier.ToString());
	JsonObject->SetStringField("CatalogIdentifier", FormatInt32(Data->CatalogIdentifier));
	JsonObject->SetStringField("Money", FormatInt64(Data->Money));
	JsonObject->SetStringField("CompanyValue", FormatInt64(Data->CompanyValue));
	JsonObject->SetStringField("FleetImmatriculationIndex", FormatInt32(Data->FleetImmatriculationIndex));
	JsonObject->SetStringField("TradeRouteImmatriculationIndex", FormatInt32(Data->TradeRouteImmatriculationIndex));
	JsonObject->SetObjectField("AI", SaveCompanyAI(&Data->AI));

	TArray< TSharedPtr<FJsonValue> > HostileCompanies;
	for(int i = 0; i < Data->HostileCompanies.Num(); i++)
	{
		HostileCompanies.Add(MakeShareable(new FJsonValueString(Data->HostileCompanies[i].ToString())));
	}
	JsonObject->SetArrayField("HostileCompanies", HostileCompanies);

	TArray< TSharedPtr<FJsonValue> > Ships;
	for(int i = 0; i < Data->ShipData.Num(); i++)
	{
		Ships.Add(MakeShareable(new FJsonValueObject(SaveSpacecraft(&Data->ShipData[i]))));
	}
	JsonObject->SetArrayField("Ships", Ships);

	TArray< TSharedPtr<FJsonValue> > Stations;
	for(int i = 0; i < Data->StationData.Num(); i++)
	{
		Stations.Add(MakeShareable(new FJsonValueObject(SaveSpacecraft(&Data->StationData[i]))));
	}
	JsonObject->SetArrayField("Stations", Stations);

	TArray< TSharedPtr<FJsonValue> > Fleets;
	for(int i = 0; i < Data->Fleets.Num(); i++)
	{
		Fleets.Add(MakeShareable(new FJsonValueObject(SaveFleet(&Data->Fleets[i]))));
	}
	JsonObject->SetArrayField("Fleets", Fleets);

	TArray< TSharedPtr<FJsonValue> > TradeRoutes;
	for(int i = 0; i < Data->TradeRoutes.Num(); i++)
	{
		TradeRoutes.Add(MakeShareable(new FJsonValueObject(SaveTradeRoute(&Data->TradeRoutes[i]))));
	}
	JsonObject->SetArrayField("TradeRoutes", TradeRoutes);


	TArray< TSharedPtr<FJsonValue> > SectorsKnowledge;
	for(int i = 0; i < Data->SectorsKnowledge.Num(); i++)
	{
		SectorsKnowledge.Add(MakeShareable(new FJsonValueObject(SaveSectorKnowledge(&Data->SectorsKnowledge[i]))));
	}
	JsonObject->SetArrayField("SectorsKnowledge", SectorsKnowledge);

	TArray< TSharedPtr<FJsonValue> > CompaniesReputation;
	for(int i = 0; i < Data->CompaniesReputation.Num(); i++)
	{
		CompaniesReputation.Add(MakeShareable(new FJsonValueObject(SaveCompanyReputation(&Data->CompaniesReputation[i]))));
	}
	JsonObject->SetArrayField("CompaniesReputation", CompaniesReputation);

	return JsonObject;
}