hedgewars/uWorld.pas
changeset 11945 156f1866b8bd
parent 11944 c7ec309cd685
child 12077 10aad1cafc10
--- a/hedgewars/uWorld.pas	Mon May 09 22:49:31 2016 +0200
+++ b/hedgewars/uWorld.pas	Tue May 10 01:33:23 2016 +0200
@@ -61,6 +61,7 @@
     , uCursor
     , uCommands
     , uTeams
+    , uDebug
 {$IFDEF USE_VIDEO_RECORDING}
     , uVideoRec
 {$ENDIF}
@@ -1952,9 +1953,26 @@
 procedure SetAmmoTexts(ammoType: TAmmoType; name: ansistring; caption: ansistring; description: ansistring);
 var
     ammoStrId: TAmmoStrId;
+    ammoStr: ansistring;
+    tmpsurf: PSDL_Surface;
 begin
     ammoStrId := Ammoz[ammoType].NameId;
+
     trluaammo[ammoStrId] := name;
+    if length(trluaammo[ammoStrId]) > 0 then
+        ammoStr:= trluaammo[ammoStrId]
+    else
+        ammoStr:= trammo[ammoStrId];
+
+    if checkFails(length(ammoStr) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ammoType)) + '!',true) then exit;
+        
+    tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(ammoStr,fnt16)].Handle, PChar(ammoStr), cWhiteColorChannels);
+    if checkFails(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ammoType)) + ' failed!',true) then exit;
+    tmpsurf:= doSurfaceConversion(tmpsurf);
+    FreeAndNilTexture(Ammoz[ammoType].NameTex);
+    Ammoz[ammoType].NameTex:= Surface2Tex(tmpsurf, false);
+    SDL_FreeSurface(tmpsurf);
+
     trluaammoc[ammoStrId] := caption;
     trluaammod[ammoStrId] := description;
 end;