--[[
HofBergmann
@author: Ifko[nator]
@date: 11.04.2017
@version: 1.0
@ logo usage in your modDesc file
<logos>
<logo filename="maps/hud/brand_HofBergmann.dds" textPosX="0.5" textPosY="0.015" textSize="0.02" textColor="1 1 1" useTextBold="true" posX="0.43" posY="0.01" width="0.15" height="0.13" startTime="0" endTime="800" textName="$l10n_logo_text"/>
...
</logos>
@ change fill type vaules usage in your modDesc file
<changeFillTypeValues>
<!-- possible values per fill type:
pricePerLiter
massPerLiter
maxPhysicalSurfaceAngle
maxSurfaceAngle
collisionScale
collisionBaseOffset
minCollisionOffset
maxCollisionOffset
allowsSmoothing
fillToGroundScale
showOnPriceTable
hudOverlayFilename
hudOverlayFilenameSmall
-->
<changeFillTypeValue fillType="milk" showOnPriceTable="true" />
...
</changeFillTypeValues>
]]
HofBergmann = {};
local HofBergmann_mt = Class(HofBergmann, Mission00);
function HofBergmann:new(baseDirectory, customMt)
local hofBergmann = customMt;
local modDesc = loadXMLFile("modDesc", baseDirectory .. "modDesc.xml");
local count = 0;
while true do
local baseText = string.format("modDesc.l10n.text(%d)", count);
if not hasXMLProperty(modDesc, baseText) then
break;
end;
local name = getXMLString(modDesc, baseText .. "#name");
local entry = getXMLString(modDesc, baseText .. "." .. g_languageShort);
if g_i18n.globalI18N.texts[name] == nil then
g_i18n.globalI18N.texts[name] = Utils.getNoNil(entry, g_i18n:getText(name));
end;
count = count + 1;
end;
count = 0;
while true do
local changeFillTypeValueKey = string.format("modDesc.changeFillTypeValues.changeFillTypeValue(%d)", count);
if not hasXMLProperty(modDesc, changeFillTypeValueKey) then
break;
end;
local fillType = getXMLString(modDesc, changeFillTypeValueKey .. "#fillType");
local pricePerLiter = getXMLString(modDesc, changeFillTypeValueKey .. "#pricePerLiter");
local massPerLiter = getXMLFloat(modDesc, changeFillTypeValueKey .. "#massPerLiter");
local maxPhysicalSurfaceAngle = getXMLFloat(modDesc, changeFillTypeValueKey .. "#maxPhysicalSurfaceAngle");
local maxSurfaceAngle = getXMLFloat(modDesc, changeFillTypeValueKey .. "#maxSurfaceAngle");
local collisionScale = getXMLFloat(modDesc, changeFillTypeValueKey .. "#collisionScale");
local collisionBaseOffset = getXMLFloat(modDesc, changeFillTypeValueKey .. "#collisionBaseOffset");
local minCollisionOffset = getXMLFloat(modDesc, changeFillTypeValueKey .. "#minCollisionOffset");
local maxCollisionOffset = getXMLFloat(modDesc, changeFillTypeValueKey .. "#maxCollisionOffset");
local allowsSmoothing = getXMLBool(modDesc, changeFillTypeValueKey .. "#allowsSmoothing");
local fillToGroundScale = getXMLString(modDesc, changeFillTypeValueKey .. "#fillToGroundScale");
local showOnPriceTable = getXMLBool(modDesc, changeFillTypeValueKey .. "#showOnPriceTable");
local hudOverlayFilename = getXMLString(modDesc, changeFillTypeValueKey .. "#hudOverlayFilename");
local hudOverlayFilenameSmall = getXMLString(modDesc, changeFillTypeValueKey .. "#hudOverlayFilenameSmall");
if fillType ~= nil then
if FillUtil["FILLTYPE_" .. string.upper(fillType)] ~= nil then
if pricePerLiter ~= nil then
FillUtil.fillTypeNameToDesc[fillType].pricePerLiter = pricePerLiter;
end;
if massPerLiter ~= nil then
FillUtil.fillTypeNameToDesc[fillType].massPerLiter = massPerLiter;
end;
if maxPhysicalSurfaceAngle ~= nil then
FillUtil.fillTypeNameToDesc[fillType].maxPhysicalSurfaceAngle = math.rad(maxPhysicalSurfaceAngle);
end;
if maxSurfaceAngle ~= nil then
FillUtil.fillTypeNameToDesc[fillType].maxSurfaceAngle = math.rad(maxSurfaceAngle);
end;
if collisionScale ~= nil then
FillUtil.fillTypeNameToDesc[fillType].collisionScale = collisionScale;
end;
if collisionBaseOffset ~= nil then
FillUtil.fillTypeNameToDesc[fillType].collisionBaseOffset = collisionBaseOffset;
end;
if minCollisionOffset ~= nil then
FillUtil.fillTypeNameToDesc[fillType].minCollisionOffset = minCollisionOffset;
end;
if maxCollisionOffset ~= nil then
FillUtil.fillTypeNameToDesc[fillType].maxCollisionOffset = maxCollisionOffset;
end;
if allowsSmoothing ~= nil then
FillUtil.fillTypeNameToDesc[fillType].allowsSmoothing = allowsSmoothing;
end;
if fillToGroundScale ~= nil then
local fillTypeToChange = FillUtil["FILLTYPE_" .. string.upper(fillType)];
TipUtil.fillTypeToHeightType[fillTypeToChange].fillToGroundScale = fillToGroundScale;
end;
if showOnPriceTable ~= nil then
FillUtil.fillTypeNameToDesc[fillType].showOnPriceTable = showOnPriceTable;
end;
if hudOverlayFilename ~= nil then
FillUtil.fillTypeNameToDesc[fillType].hudOverlayFilename = Utils.getFilename(hudOverlayFilename, baseDirectory);
end;
if hudOverlayFilenameSmall ~= nil then
FillUtil.fillTypeNameToDesc[fillType].hudOverlayFilenameSmall = Utils.getFilename(hudOverlayFilenameSmall, baseDirectory);
end;
else
print("[ERROR changeFillTypeValues]: Aborting change fillType Values for '" .. fillType .. "' now because the fillType is not registered!");
end;
else
print("[ERROR changeFillTypeValues]: Aborting change fillType Values now because missing the fillType value for TAG number " .. count);
end;
count = count + 1;
end;
self.logos = {};
count = 0;
while true do
local logoKey = string.format("modDesc.logos.logo(%d)", count);
if not hasXMLProperty(modDesc, logoKey) then
break;
end;
local filename = getXMLString(modDesc, logoKey .. "#filename");
local logo = {};
logo.textPosX = Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#textPosX"), 0.5);
logo.textPosY = Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#textPosY"), 0.015);
logo.textSize = Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#textSize"), 0.02);
logo.textName = Utils.getNoNil(getXMLString(modDesc, logoKey .. "#textName"), "");
logo.useTextBold = Utils.getNoNil(getXMLBool(modDesc, logoKey .. "#useTextBold"), true);
logo.showOnlyOnFirstStart = Utils.getNoNil(getXMLBool(modDesc, logoKey .. "#showOnlyOnFirstStart"), true);
logo.textColor = Utils.getNoNil(Utils.getVectorNFromString(getXMLString(modDesc, logoKey .. "#textColor"), 3), {1, 1, 1});
if logo.textName:sub(1, 6) == "$l10n_" then
logo.textName = g_i18n:getText(logo.textName:sub(7));
end;
logo.startTime = Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#startTime"), 0);
logo.endTime = Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#endTime"), 400);
logo.time = 0;
if count == 0 then
logo.alpha = 1;
else
logo.alpha = 0;
end;
if filename ~= nil then
logo.overlay = Overlay:new("Logo",
Utils.getFilename(getXMLString(modDesc, logoKey .. "#filename"), baseDirectory),
Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#posX"), 0.25),
Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#posY"), 0),
Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#width"), 0.15),
Utils.getNoNil(getXMLFloat(modDesc, logoKey .. "#height"), 0.1)
);
end;
table.insert(self.logos, logo);
count = count + 1;
end;
if hofBergmann == nil then
hofBergmann = HofBergmann_mt;
end;
local self = HofBergmann:superClass():new(baseDirectory, hofBergmann);
return self;
end;
function HofBergmann:loadHotspots(xmlFile)
local count = 0;
while true do
local hotspotKey = string.format("map.hotspots.hotspot(%d)", count);
if not hasXMLProperty(xmlFile, hotspotKey) then
break;
end;
local name = Utils.getNoNil(getXMLString(xmlFile, hotspotKey .. "#name"), "");
local fullName = Utils.getNoNil(getXMLString(xmlFile, hotspotKey .. "#fullName"), "");
if fullName:sub(1, 6) == "$l10n_" then
fullName = g_i18n:getText(fullName:sub(7));
end;
local imageFilename = getXMLString(xmlFile, hotspotKey .. "#imageFilename");
if imageFilename ~= nil then
imageFilename = Utils.getFilename(imageFilename, self.baseDirectory); --## LOOK @ GIANTS!!!! Use Utils.getFilename to get the filename of the image!!!!!!!
end;
local imageUVs = getNormalizedUVs(Utils.getVectorNFromString(getXMLString(xmlFile, hotspotKey .. "#imageUVs"), 4));
local baseColor = Utils.getVectorNFromString(getXMLString(xmlFile, hotspotKey .. "#baseColor"), 4);
local xMapPos = getXMLFloat(xmlFile, hotspotKey .. "#xMapPos");
local zMapPos = getXMLFloat(xmlFile, hotspotKey .. "#zMapPos");
local blinking = Utils.getNoNil(getXMLBool(xmlFile, hotspotKey .. "#blinking"), false);
local persistent = Utils.getNoNil(getXMLBool(xmlFile, hotspotKey .. "#persistent"), false);
local showName = Utils.getNoNil(getXMLBool(xmlFile, hotspotKey .. "#showName"), true);
local renderLast = Utils.getNoNil(getXMLBool(xmlFile, hotspotKey .. "#renderLast"), false);
local category = Utils.getNoNil(getXMLString(xmlFile, hotspotKey .. "#category"), "CATEGORY_TRIGGER");
local width, height = getNormalizedScreenValues(Utils.getNoNil(getXMLFloat(xmlFile, hotspotKey .. "#width"), 12), Utils.getNoNil(getXMLFloat(xmlFile, hotspotKey .. "#height"), 12))
if MapHotspot[category] ~= nil then
category = MapHotspot[category];
else
category = MapHotspot.CATEGORY_DEFAULT;
end;
local textSize = getXMLInt(xmlFile, hotspotKey .. "#textSize");
if textSize ~= nil then
_, textSize = getNormalizedScreenValues(0, textSize);
end;
local textOffsetY = getXMLInt(xmlFile, hotspotKey .. "#textOffsetY");
if textOffsetY ~= nil then
_, textOffsetY = getNormalizedScreenValues(0, textOffsetY);
end;
local textColor = Utils.getVectorNFromString(getXMLString(xmlFile, hotspotKey .. "#textColor"), 4);
self.ingameMap:createMapHotspot(name, fullName, imageFilename, imageUVs, baseColor, xMapPos, zMapPos, width, height, blinking, persistent, showName, nil, renderLast, category, textSize, textOffsetY, textColor);
count = count + 1;
end;
end;
Mission00.loadHotspots = Utils.overwrittenFunction(Mission00.loadHotspots, HofBergmann.loadHotspots);
function HofBergmann:onStartMission()
HofBergmann:superClass().onStartMission(self);
--[[
if g_currentMission:getIsServer() and not g_currentMission.missionInfo.isValid then
--## Der folgende Code wird NUR beim start eines NEUEN Savegames ausgeführt!
g_currentMission.missionStats.money = 0; --## Geld vom Standard Spiel löschen
if self.missionInfo.difficulty == 1 then
self:addSharedMoney(20000); --## Geld festlegen, das man bei Start eines leichten Spielstandes hat
g_currentMission.missionStats.loan = 1000; --## Schulden festlegen, die man bei Start eines leichten Spielstandes hat
elseif self.missionInfo.difficulty == 2 then
self:addSharedMoney(15000); --## Geld festlegen, das man bei Start eines mittleren Spielstandes hat
g_currentMission.missionStats.loan = 3000; --## Schulden festlegen, die man bei Start eines mittleren Spielstandes hat
elseif self.missionInfo.difficulty == 3 then
self:addSharedMoney(10000); --## Geld festlegen, das man bei Start eines schweren Spielstandes hat
g_currentMission.missionStats.loan = 9000; --## Schulden festlegen, die man bei Start eines schweren Spielstandes hat
end;
end;
]]
end;
function HofBergmann:draw()
HofBergmann:superClass().draw(self);
if g_gui.currentGui ~= nil or g_currentMission.isPlayerFrozen then
return;
end;
setTextAlignment(RenderText.ALIGN_CENTER);
for logoNumber = 1, #self.logos do
local logo = self.logos[logoNumber];
if (logo.showOnlyOnFirstStart and not g_currentMission.missionInfo.isValid) or not logo.showOnlyOnFirstStart then
logo.time = logo.time + 1;
if logo.startTime <= logo.time then
if logo.time > logo.endTime then
if logo.alpha > 0 then
logo.alpha = logo.alpha - 0.01;
end;
else
if logo.alpha < 1 then
logo.alpha = logo.alpha + 0.01;
end;
end;
if logo.alpha > 0 then
setTextColor(logo.textColor[1], logo.textColor[2], logo.textColor[3], logo.alpha);
if logo.overlay ~= nil then
logo.overlay:setColor(nil, nil, nil, logo.alpha);
logo.overlay:render();
end;
if logo.textName ~= "" then
setTextBold(logo.useTextBold);
renderText(logo.textPosX, logo.textPosY, getCorrectTextSize(logo.textSize), logo.textName);
end;
end;
end;
end;
end;
setTextColor(1.0, 1.0, 1.0, 1.0);
setTextBold(false);
setTextAlignment(RenderText.ALIGN_LEFT);
end;
local self = ModMap:superClass():new(baseDirectory, mt)
-- Number of additional channels that are used compared to the original setting (2)
local numAdditionalAngleChannels = 1;
self.terrainDetailAngleNumChannels = self.terrainDetailAngleNumChannels + numAdditionalAngleChannels;
self.terrainDetailAngleMaxValue = (2^self.terrainDetailAngleNumChannels) - 1;
self.sprayLevelFirstChannel = self.sprayLevelFirstChannel + numAdditionalAngleChannels;
self.ploughCounterFirstChannel = self.ploughCounterFirstChannel + numAdditionalAngleChannels;
return self
end
--print("TipUtil.NUM_HEIGHTTYPES = " .. TipUtil.NUM_HEIGHTTYPES);