Mods

Post new mods and scenarios here.

Moderator: Shannon V. OKeets

Post Reply
User avatar
WarHunter
Posts: 1174
Joined: Sun Mar 21, 2004 6:27 pm

Mods

Post by WarHunter »

I don't want to cause problems with the game engine by renaming land units or air units. So far i have seen no evidence that has happened so far.

Attached is the excel file recently uploaded in the mod forum. Would it be possible to get a word on its compatibility? If there is a problem can it be pointed out to allow me to fix it for general use as a mod for players.

When the renaming of the air units is complete. Before posting for general use. I will be posting here first with it to get approval.
Attachments
STANDARDUNITSLND.zip
(13.92 KiB) Downloaded 16 times
Image
“We never felt like we were losing until we were actually dead.”
Marcus Luttrell
User avatar
Dabrion
Posts: 740
Joined: Tue Nov 05, 2013 10:26 am
Location: Northpole

RE: Mods

Post by Dabrion »

You can do it ingame using the rclick menu.

Guess it is ok (but who knows..)

Image
Attachments
mwiferror259.jpg
mwiferror259.jpg (109.98 KiB) Viewed 176 times
"If we come to a minefield, our infantry attacks exactly as it were not there." ~ Georgy Zhukov
Shannon V. OKeets
Posts: 22165
Joined: Wed May 18, 2005 11:51 pm
Location: Honolulu, Hawaii
Contact:

RE: Mods

Post by Shannon V. OKeets »

ORIGINAL: WarHunter

I don't want to cause problems with the game engine by renaming land units or air units. So far i have seen no evidence that has happened so far.

Attached is the excel file recently uploaded in the mod forum. Would it be possible to get a word on its compatibility? If there is a problem can it be pointed out to allow me to fix it for general use as a mod for players.

When the renaming of the air units is complete. Before posting for general use. I will be posting here first with it to get approval.
What is strange about the air unit names is that they are split into 4 possible locations on the counter. Some have two lines above the plane graphic, some have a line below the graphic. And some place part of the name to the left of the graphic. Which air units do what depends on the unit type and nationality. Different nations used different nomenclature for their air units (and the US gave alternate names for the Japanese planes). The program is sensitive to the placement of periods and blanks in some of the names when determining in which of the 4 possible positions different portions of the air unit names are placed.

What you should be aware of are the first two functions in the code below.

===
function SplitName(const NameIn: String; out Nam1, Nam2, KA1, KA2: String):
Integer;
// ****************************************************************************
// This function splits the name into 1, 2, or 3 pieces. The first piece is
// everything before the first blank. The second piece is separated by either
// a hyphen or a second blank. The hyphen is retained, the blank is discarded.
//
// There are different rules for air units from Germany and its allies (Finland,
// Rumania, Czechoslovakia), which also apply to lend leased units for Italy.
// ****************************************************************************
var
TempName: String;
TempName2: String;
Leng: Integer;
begin
if ((Country in [Germany.ID, Finland.ID, Rumania.ID, Czechoslovakia.ID]) or
(LendLeaseSource = Germany.ID)) and
(UnitType <> utVWeapon) then
begin // Germany and its allies (names for V weapons are normal)
TempName := NameIn;
TempName2 := TrimString(TempName, ' '); // 2nd blank divides official name
TempName2 := TrimString(TempName, ' '); // from KnownAs
KA1 := TempName; // Text to the right of 2nd blank

if KA1 = '' then Nam1 := NameIn
else
begin
Leng := Length(NameIn) - Succ(Length(KA1)); // Length of official name
Nam1 := LeftStr(NameIn, Leng);
end;

TempName := Nam1;
Nam1 := TrimString(TempName, '-'); // Split on hyphen
Nam2 := TempName;

if Nam2 <> '' then
begin // Take the letter before the hyphen and add it to Nam2
Nam2 := RightStr(Nam1, 1) + '-' + Nam2; // Add letter and hyphen
Leng := Length(Nam1);
Nam1 := LeftStr(Nam1, Leng - 1); // Trim off last letter
end;

if KA1 = '' then Result := 1 // Only offical name
else Result := 2; // AKA is never split for Germany
end
else
begin // Non-German air units
TempName := NameIn;
Nam1 := TrimString(TempName, ' '); // Blank divides Official from KnownAs
Nam2 := ''; // Always true, unless abbreviated

if Length(TempName) = 0 then
begin // No blank in name; no Known As portion of name
Result := 1;
Exit;
end;

TempName := TrimString(TempName, '('); // Remove all text in parentheses
KA1 := TempName;

if UnitType <> utLandAir then
begin // Only land air units are analyzed further
KA2 := '';
Result := 2;
Exit;
end;

TempName2 := TempName;
KA1 := TrimString(TempName, ' '); // Search for second blank

if (Length(TempName) = 0) or (Country in CommonwealthCountries) then
begin // No 2nd blank; unified Known As portion
KA1 := TempName2;
Result := 2;
Exit;
end;

KA2 := TempName; // Blank found and used to split Known As portion
Result := 3;
end;
end;

function SplitNameA(const NameIn: String; out Nam1, Nam2, KA1, KA2: String):
Integer;
// ****************************************************************************
// This function is only used for names with abbreviations.
// It splits the name into 1, 2, 3, or 4 pieces. The first piece is
// everything before the first plus sign. The second piece follows up to the
// 2nd plus sign. And so on for the 3rd and 4th pieces.
// ****************************************************************************
var
TempName: String;
begin
TempName := NameIn;
Nam1 := TrimString(TempName, '+'); // 1st + divides Official name in 2.
Nam2 := TrimString(TempName, '+'); // 2nd + divides Official from KnownAs.
KA1 := TrimString(TempName, '+'); // 3rd + divides KnownAs name in 2.
KA2 := TempName;
Result := 3;
end;

begin
// ****************************************************************************
// TAirUnit.Draw.
// ****************************************************************************
try
inherited Draw(Canvas, X, Y); // TUnit.Draw.
// ****************************************************************************
// Make zoom level a local variable; handle units review form separately.
// ****************************************************************************
ZLevel := 7;

if (MapWindows <> nil) and
(MapWindows.SelectedMapArea <> nil) and
(MapWindows.SelectedMapArea.Parent <> nil) and
(MapWindows.SelectedMapArea.Parent.ClassType = TDetailedMapForm) and
(UnitSizeControl = 4) then
ZLevel := TDetailedMapForm(MapWindows.SelectedMapArea.Parent).ZoomLevel
else if UnitSizeControl = 3 then // 200% is arbitrary default.
ZLevel := 7
else if UnitSizeControl = 1 then
ZLevel := UnitSizeZoomLevel; // ZLevel ranges from 0 to 7.
// ****************************************************************************
// Font size depends on both unit resolution and UnitSizeControl.
// ****************************************************************************
if CurrUnitResolution = urHigh then
begin
FontSize1 := USzFontSizeA3;
FontSize2 := USzFontSizeL3;
end
else
begin // Larger fonts for medium resolution.
FontSize1 := USzFontSizeA3Med;
FontSize2 := USzFontSizeL3Med;
end;
// ****************************************************************************
// Set font size and color (for air to air strength).
// ****************************************************************************
Canvas.Font.Color := TSubCountry(Countries[Country]).TextColor1;
Canvas.Font.Size := MulDiv(FontSize1, 96, Screen.PixelsPerInch);
// ****************************************************************************
// Set X and Y values for left, right, top, and bottom factors.
// ****************************************************************************
XLeft := X + USzAirXLeftOff;
XRight := X + USzAirXRightOff;
YTop := Y + USzAirYTopOff;
YBottom := Y + USzAirYBottomOff - Canvas.TextHeight('1');
TopOfBottom := YBottom; // Initialization.
XAbb := XLeft; // For the compiler.
YAbb := YBottom; // For the compiler.
CountryNameColor := clWhite; // For the compiler.
// ****************************************************************************
// Air to air strength (upper left).
// ****************************************************************************
if NoAttack then AStr := Format('(%d)', [AirAir])
else if NoIntercept then AStr := '*'
else
begin
// ****************************************************************************
// Reduce air to air strength of fighter-bombers flying as bombers.
// ****************************************************************************
if OptRules.FighterBombers and
(UnitType = utFighter) and
(Role = rBomber) then
ATA := Max(0, Pred(AirAir))
else
ATA := AirAir;

AStr := IntToStr(ATA);
end;
// ****************************************************************************
// Record the number of digits in air-to-air for centering the name later.
// ****************************************************************************
if Length(AStr) > 1 then TwoDigits := True
else TwoDigits := False;
// ****************************************************************************
// Background and foreground colors for air-to-air number.
// ****************************************************************************
if Night or TwinEngine then
begin
// ****************************************************************************
// Both ifs below can't fail, because the above if is true. The combination of
// white on white can never happen.
// ****************************************************************************
if TwinEngine then CurrFColor := clOrange // Foreground/text color.
else CurrFColor := clWhite; // Allow margin of 2 from top for circle.

if Night then // Night is orange or white font inside a black circle.
DrawColoredCircle(Canvas, XLeft, YTop, NightCircle, AStr,
CurrFColor, CurrSourceUnitColor)
else
begin // Twin engine is orange font inside a white circle.
DrawColoredCircle(Canvas, XLeft, YTop, TwinCircle, AStr,
CurrFColor, CurrSourceUnitColor)
end;
end
else
begin
Canvas.Brush.Style := bsClear;
Canvas.TextOut(XLeft, YTop, AStr); // No special background color.
end;
// ****************************************************************************
// Air-to-sea strength (upper right).
// ****************************************************************************
Canvas.Font.Color := CurrTextColor1; // Reset default font color.

if AirSea = 0 then AStr := '*' // Air to sea strength.
else AStr := IntToStr(AirSea);

CircleDiameter :=
Max(Canvas.TextHeight(AStr) - 2, Canvas.TextWidth(AStr) + 2);

XStart := X + USzAirXRightOff - CircleDiameter;

if CurrUnitResolution <> urHigh then Inc(XStart, 2); // Closer to edge.

if FlyingBoat then // Flying boats' naval air is white on blue.
begin // Position on right side of counter.
if AirSeaType = 1 then // Pink.
DrawColoredCircle(Canvas, XStart, YTop, FlyingBoatCircle, AStr,
clFuchsia, CurrSourceUnitColor)
else if AirSeaType = 2 then // Red
DrawColoredCircle(Canvas, XStart, YTop, FlyingBoatCircle, AStr,
clRed, CurrSourceUnitColor)
else DrawColoredCircle(Canvas, XStart, YTop, FlyingBoatCircle, AStr,
clWhite, CurrSourceUnitColor);
end
else
begin
if AirSeaType = 1 then // Pink.
DrawColoredCircle(Canvas, XStart, YTop, LightASWCircle, AStr,
clWhite, CurrSourceUnitColor)
else if (AirSeaType = 2) and (Country = Japan.ID) then // Red & Japan.
DrawColoredCircle(Canvas, XStart, YTop, HeavyASWCircleJapan,
AStr, clWhite, CurrSourceUnitColor)
else if AirSeaType = 2 then // Red & not Japan
DrawColoredCircle(Canvas, XStart, YTop, HeavyASWCircle, AStr,
clWhite, CurrSourceUnitColor)
else Canvas.TextOut(XRight - Canvas.TextWidth(AStr), YTop, AStr);
end; // Last choice is nothing special
// ****************************************************************************
// The top center area shows special capabilities.
// ****************************************************************************
if (UnitType = utVWeapon) and (Move <> 0) then
begin // V weapon: placed at bottom of unit using land unit values
AStr := Format('0-%d', [Move]);
Canvas.Font.Size := MulDiv(FontSize2, 96, Screen.PixelsPerInch);

Canvas.TextOut(X + (UnitSize - Canvas.TextWidth(AStr)) div 2,
Y + USzLandYStart, AStr);

Canvas.Font.Size := MulDiv(FontSize1, 96, Screen.PixelsPerInch);
end
else if OptRules.CarrierPlanes and (AClass <> 0) then
begin // Carrier plane
AStr := IntToStr(AClass);
DrawSquareValue(Canvas, (X + (UnitSize - Canvas.TextWidth(AStr)) div 2) -
USzAirXTopCenterOff, YTop, AStr, clWhite, ClassColor[AClass]);
end;
// ****************************************************************************
// Strategic bombing strength (lower right).
// ****************************************************************************
Canvas.Font.Color := CurrTextColor1; // Reset def. font color.

if Strategic = 0 then
AStr := '*'
else if IsTempCarrierPlane then
AStr := FloatToStrNoLeadingZero(Strategic / 4)
else if NightMission then
AStr := FloatToStrNoLeadingZero(Strategic / 2)
else AStr := IntToStr(Strategic);

Canvas.TextOut(XRight - Canvas.TextWidth(AStr), YBottom, AStr);
// ****************************************************************************
// Tactical strength (lower left).
// ****************************************************************************
if Tactical = 0 then AStr := '*'
else if IsTempCarrierPlane then
AStr := FloatToStrNoLeadingZero(Tactical / 2)
else if NightMission then AStr := FloatToStrNoLeadingZero(Tactical / 2)
else AStr := IntToStr(Tactical);

YStart := YBottom;
// ****************************************************************************
// Draw tank buster units with a red circle around their tactical factor.
// ****************************************************************************
if TankBuster then
begin // Tank busters tactical are white on red.
CircleDiameter :=
Max(Canvas.TextHeight(AStr) - 2, Canvas.TextWidth(AStr) + 2);

YStart := Y + USzAirYBottomOff - CircleDiameter;

if ZLevel = 3 then Dec(YStart, 2); // Minus 2 for 100% zoom.

if (Country = Japan.ID) then
DrawColoredCircle(Canvas, XLeft, YStart, TankBusterCircleJapan,
AStr, clWhite, CurrSourceUnitColor)
else
DrawColoredCircle(Canvas, XLeft, YStart, TankBusterCircle, AStr,
clWhite, CurrSourceUnitColor);

Canvas.Font.Color := CurrTextColor1; // Reset def. font color.
end
else Canvas.TextOut(XLeft, YStart, AStr); // Nothing special.

if YStart < TopOfBottom then TopOfBottom := YStart;
// ****************************************************************************
// Range.
// ****************************************************************************
Canvas.Font.Color := CurrTextColor1; // Reset default font color.

if Name <> 'A-Bomb' then // No range on the A-Bomb.
begin
R := Range; // Unit's basic range.

if (UnitType = utFighter) and
(Role = rBomber) and
(not AtSea) and
((not OnTheMove) or
(not MovingStack.PickUpPoint.AtSea)) and
(not (Game.Phase in [pNavalAir] + ReturnToBasePhases)) and
(not Game.NavalAirSupportSubphase) then
R := Succ(R) div 2; // Halve the range rounding up.

AStr := IntToStr(R);

CircleDiameter :=
Max(Canvas.TextHeight(AStr) - 2, Canvas.TextWidth(AStr) + 2);

if (UnitType = utFighter) or (CurrUnitResolution <> urHigh) then
begin // Position at bottom center of counter.
XStart := X + ((UnitSize - CircleDiameter) div 2);
YStart := Y + USzAirYBottomOff - CircleDiameter;

if ZLevel = 3 then Dec(YStart, 2); // Minus 2 for 100% zoom.

if YStart < TopOfBottom then TopOfBottom := YStart;
end
else
begin // Position on right side of counter.
SideOffset := Canvas.TextWidth(AStr) + Length(AStr);

if SideOffset < Canvas.TextHeight(AStr) then
SideOffset := Canvas.TextHeight(AStr);

XStart := XRight - (SideOffset + USzAirXSideOff);
YStart := YBottom + USzAirYSideOff - (Canvas.TextHeight(AStr));
end;
// ****************************************************************************
// Set background color: white for air transport, orange for extended range.
// Default color is yellow. All of these use a black font color.
// ****************************************************************************
// For fighter-bombers and carrier air units flying as bombers, the background
// color is gray with a white font.
// ****************************************************************************
if (UnitType in [utFighter, utCarrierAir]) and (Role = rBomber) then
DrawColoredCircle(Canvas, XStart, YStart, ArtilleryCircle,
AStr, clWhite, CurrSourceUnitColor)
else if (AirTransport <> atrNone) and (CurrUnitResolution = urHigh) then
begin // Reposition range for special air transport units.
if (AirTransport = atrLargeNoPara) or (AirTransport = atrLarge) then
begin
Dec(XStart, 8); // Down 8.
Inc(YStart, 8); // Left 8.
end;

DrawColoredCircle(Canvas, XStart, YStart, ATRCircle, AStr, clBlack,
CurrSourceUnitColor);
end
else if Extended then
begin // Note: draw number icon has different Y position.
if CurrUnitResolution = urHigh then
YStart := YStart + Canvas.TextHeight('1')
else
YStart := YStart + CircleDiameter;

if Country = NationalistChina.ID then
DrawNumberIcon(Canvas, XStart, YStart, ExtendedCircleChina, AStr,
clBlack, CurrSourceUnitColor)
else
DrawNumberIcon(Canvas, XStart, YStart, ExtendedCircle, AStr, clBlack,
CurrSourceUnitColor);
end
else
begin
if AirTransport <> atrNone then
begin
DrawColoredCircle(Canvas, XStart, YStart, ATRCircle, AStr, clBlack,
CurrSourceUnitColor);
end
else
begin // Default color for range is yellow.
if Country = NationalistChina.ID then
DrawColoredCircle(Canvas, XStart, YStart, RangeCircleChina, AStr,
clBlack, CurrSourceUnitColor)
else
DrawColoredCircle(Canvas, XStart, YStart, RangeCircle, AStr, clBlack,
CurrSourceUnitColor);
end;
end;
end; // End of not A-bomb.
// ****************************************************************************
// Only continue on to names for high resolution depictions.
// ****************************************************************************
if CurrUnitResolution <> urHigh then Exit;
// ****************************************************************************
// Prepare for displaying the unit's names.
// ****************************************************************************
// 3 letter abbreviation for the name of the unit's original country.
// ****************************************************************************
ShownAbbr := TSubCountry(Countries[Country]).Abbrev;

if ShownAbbr <> '' then
begin
if TMinorCountry(Countries[Country]).ClassType = TMajorCountry then
ShownAbbr := ''; // Do not show abbreviation for major powers.

if Country in CommonwealthCountries then
begin
if Country = NewZealand.ID then CountryNameColor := clWhite
else if Country = India.ID then
CountryNameColor := TSubCountry(Countries[Country]).LandIconFColor
else
CountryNameColor := TSubCountry(Countries[Country]).LandIconBColor;
end
else CountryNameColor := CurrTextColor1;
end;
// ****************************************************************************
// Now figure out how to split the unit's name, which might involve an
// abbreviation of that name (differeent from the country name abbreviation)
// ****************************************************************************
if AbbreviatedName = '' then
NameParts := SplitName(Name, Named1, Named2, KnownAs1, KnownAs2)
else
NameParts :=
SplitNameA(AbbreviatedName, Named1, Named2, KnownAs1, KnownAs2);

Canvas.Font.Color := CurrTextColor1; // For all parts of the name.
Canvas.Font.Name := HighResFont;
Canvas.Font.Style := [fsBold];
XNamed1 := 0; // For the compiler.
YNamed1 := 0; // For the compiler.
XNamed2 := 0; // For the compiler.
YNamed2 := 0; // For the compiler.
XKA1 := 0; // For the compiler.
YKA1 := 0; // For the compiler.
XKA2:= 0; // For the compiler.
YKA2:= 0; // For the compiler.
// ****************************************************************************
// Establish location for offical name and Known As name pieces. The locations
// depend on the air unit's type.
// ****************************************************************************
case UnitType of
utFighter: // Use YTop for Y and center Named to set X.
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
// ****************************************************************************
// Move away from circles and two digits in air-to-air number.
// ****************************************************************************
if Night or TwinEngine or TwoDigits then Inc(XNamed1, 4);

if Named2 = '' then YNamed1 := YTop
else
begin // 2 parts means move top one up 3 pixels.
YNamed1 := YTop - 3;
YNamed2 := YTop + Canvas.TextHeight(Named1) - 8;

if NameParts = 1 then
XNamed2 := X + ((UnitSize - Canvas.TextWidth(Named2)) div 2)
else
// ****************************************************************************
// Change the size of the font for the second line of the offical name if there
// is an AKA name too. Space is at a premium.
// ****************************************************************************
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XNamed2 := X + ((UnitSize - Canvas.TextWidth(Named2)) div 2)
end;

if Night or TwinEngine or TwoDigits then Inc(XNamed2, 4);
end;

if NameParts > 1 then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XKA1 := XLeft + 2;
YKA1 := TopOfBottom - Canvas.TextHeight(KnownAs1);
// ****************************************************************************
// Make adjustments to text vertical placement based on zoom level
// ****************************************************************************
if ZLevel = 6 then Inc(YKA1)
else if ZLevel = 5 then Inc(YKA1, 2)
else if ZLevel = 4 then Inc(YKA1, 3);
end;
// ****************************************************************************
// Abbreviated country name for fighter
// ****************************************************************************
if ShownAbbr <> '' then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XAbb := X + USzFighterAbbrevXOff - Canvas.TextWidth(ShownAbbr);
YAbb := TopOfBottom - Canvas.TextHeight(ShownAbbr);
end;
end;

utNavalAir:
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YBottom + 2;

if NameParts > 1 then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XKA1 := X + ((UnitSize - Canvas.TextWidth(KnownAs1)) div 2);
// ****************************************************************************
// Move name away from blue circle for air-to-sea number.
// ****************************************************************************
if FlyingBoat then Dec(XKA1, 4);

if (NameParts = 2) or (KnownAs2 = '') then YKA1 := YTop
else
begin // 3 parts means move top one up 3 pixels.
YKA1 := YTop - 3;
XKA2 := X + ((UnitSize - Canvas.TextWidth(KnownAs2)) div 2);
YKA2 := YTop + Canvas.TextHeight(KnownAs1) - 8;

if FlyingBoat then Dec(XKA2, 4);
end;
end;
// ****************************************************************************
// Abbreviated country name for naval air units.
// ****************************************************************************
if ShownAbbr <> '' then
begin
XAbb := X + USzNavAirAbbrevXOff;
YAbb := Y + USzNavAirAbbrevYOff;
end;
end;

utLandAir:
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YBottom + 2;
// ****************************************************************************
// Move name away from red circle for tactical factor
// ****************************************************************************
if TankBuster then Inc(XNamed1, 4);

if NameParts > 1 then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XKA1 := XLeft + 2;
YKA1 := TopOfBottom + 2 - (Canvas.TextHeight(KnownAs1) * 2);

if (NameParts = 3) and (KnownAs2 <> '') then
begin
XKA2 := XKA1;
YKA2 := TopOfBottom - Canvas.TextHeight(KnownAs1);
// ****************************************************************************
// Make adjustments to text vertical placement based on zoom level
// ****************************************************************************
if ZLevel = 6 then Inc(YKA1)
else if ZLevel = 5 then Inc(YKA1, 2)
else if ZLevel = 4 then Inc(YKA1, 3);
end;

if TankBuster then Inc(XNamed2, 4);
end;
// ****************************************************************************
// Abbreviated country name for land based bomber
// ****************************************************************************
if ShownAbbr <> '' then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XAbb := X + USzBomberAbbrevXOff;
YAbb := TopOfBottom - Canvas.TextHeight(ShownAbbr);
end;
end;

utAirTransport:
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YBottom + 2;

if NameParts > 1 then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XKA1 := XLeft + 2;

if (NameParts = 2) or (KnownAs2 = '') then
YKA1 := TopOfBottom - Canvas.TextHeight(KnownAs1)
else
begin // 3 parts means move top one up 1 text row
YKA1 := TopOfBottom + 8 - (Canvas.TextHeight(KnownAs1) * 2);
XKA2 := XLeft + 2;
YKA2 := TopOfBottom + 3 - Canvas.TextHeight(KnownAs2);
// ****************************************************************************
// Make adjustments to text vertical placement based on zoom level.
// ****************************************************************************
if ZLevel = 6 then Inc(YKA1)
else if ZLevel = 5 then Inc(YKA1, 2)
else if ZLevel = 4 then Inc(YKA1, 3);
end;
end;
end;

utCarrierAir:
begin
// ****************************************************************************
// Carrier air units have their class number at the top center and a single name
// at the bottom.
// But temporary carrier air units do not show their class number since it is
// always taken from their carrier. This leaves the top slot available for the
// name of the carrier - which is the name assigned to temporary carrier air
// units when they are created. Meanwhile the tactical and strategic factors
// can be fractions (e.g., 2.5 and 1.25) which leaves very little space at the
// bottom anyway. But additional information needs to be provided for temporary
// carrier air units: whether they are flying as fighters or bombers. Therefore
// a second named part is created for that and positioned at the bottom.
// ****************************************************************************
if IsTempCarrierPlane then
begin // Use smaller font for long carrier names & limited bottom space.
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YTop; // At top of depiction.
end
else
begin // Regular carrier air units.
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YBottom + 2;

if NameParts > 1 then
begin
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);
XKA1 := XLeft + 2;

if (NameParts = 2) or (KnownAs2 = '') then
YKA1 := TopOfBottom - Canvas.TextHeight(KnownAs1)
else
begin // 3 parts means move top one up 1 text row.
YKA1 := TopOfBottom + 8 - (Canvas.TextHeight(KnownAs1) * 2);
XKA2 := XLeft + 2;
YKA2 := TopOfBottom + 3 - Canvas.TextHeight(KnownAs2);
// ****************************************************************************
// Make adjustments to text vertical placement based on zoom level.
// ****************************************************************************
if ZLevel in [5, 6] then Inc(YKA1)
else if ZLevel = 4 then Inc(YKA1, 3);
end;
end;
end;
end;

utVWeapon:
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YTop;
end;

utABomb:
begin
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
XNamed1 := X + ((UnitSize - Canvas.TextWidth(Named1)) div 2);
YNamed1 := YTop;
end;
end; // End of case statement.
// ****************************************************************************
// Display the offical name.
// ****************************************************************************
if IsTempCarrierPlane then
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch)
else
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);

Canvas.TextOut(XNamed1, YNamed1, Named1); // Nothing special.

if Named2 <> '' then
begin
if (NameParts > 1) or IsTempCarrierPlane then
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);

Canvas.TextOut(XNamed2, YNamed2, Named2);
end;
// ****************************************************************************
// Display the first portion of the Known As name.
// ****************************************************************************
Canvas.Font.Size := MulDiv(USzFontSizeA2, 96, Screen.PixelsPerInch);

if NameParts > 1 then Canvas.TextOut(XKA1, YKA1, KnownAs1);
// ****************************************************************************
// Display the second portion of the Known As name.
// ****************************************************************************
if (NameParts = 3) and (KnownAs2 <> '') then
Canvas.TextOut(XKA2, YKA2, KnownAs2);
// ****************************************************************************
// For temporary carrier air units that are flying, show their role as a text
// string. This is not done for fighter-bonmbers and non-temporary carrier air
// units, since the counter is too congested for writing the text.
// ****************************************************************************
if IsTempCarrierPlane then
begin
if Role = rBomber then Named2 := rsBomber2
else if Role = rFighter then Named2 := rsFighter2
else Named2 := rsUndecided2;

XNamed2 := XLeft + 2; // Left, below air-to-air number.
YNamed2 := YTop + Canvas.TextHeight(Named2);
// ****************************************************************************
// Make adjustments to text vertical placement based on zoom level.
// ****************************************************************************
if ZLevel in [3, 7, 8] then Inc(YNamed2, 2)
else if ZLevel = 4 then Inc(YNamed2, 3);

Canvas.TextOut(XNamed2, YNamed2, Named2);
end;
// ****************************************************************************
// Only for abbreviated country names.
// ****************************************************************************
if ShownAbbr <> '' then
begin
Canvas.Font.Color := CountryNameColor;
Canvas.Font.Size := MulDiv(USzFontSizeA1, 96, Screen.PixelsPerInch);
Canvas.TextOut(XAbb, YAbb, ShownAbbr);
end;
finally
end;
end;
===
Steve

Perfection is an elusive goal.
User avatar
WarHunter
Posts: 1174
Joined: Sun Mar 21, 2004 6:27 pm

RE: Mods

Post by WarHunter »

The program is sensitive to the placement of periods and blanks in some of the names when determining in which of the 4 possible positions different portions of the air unit names are placed.


If your intention was to pour freezing water over my head in an attempt to wake me up to the ramifacations of renaming air units. A simple don't mess with the excel file would have been enough.

I understand being extra careful is bottom line critical. What i do not understand is how to identify the sensitive parts of renaming that i must be aware of.

I'm guessing here.
The code if i could readily understand its meaning tells within the 2 functions what to avoid and the limitations. My ignorance prevents me from finding these clues.

Renaming is not as simple as replacing letter combination "B-17G Flying Fortress" with "Pilot 666Hell". No? Yes? Only by players who also understand the code?


Within my own solo games i have been renaming air units willy nilly. I've become somewhat comfortable in identifying the 4 different positions where the names will appear. I even understand short names need more spaces to allow unit designation to appear without looking like crap.

Moving onto the excel file is a big jump from just fiddling with the in game renaming. I understand that. Renaming in game is not a way to share a MOD.

The real question for me. Is it worth the time even as i was figuring over 2 months to complete it, before reading this post.

Thanks for the info. Time to meditate.
Image
“We never felt like we were losing until we were actually dead.”
Marcus Luttrell
Post Reply

Return to “Mods and Scenarios”