# HG changeset patch # User Wuzzy # Date 1462836803 -7200 # Node ID 156f1866b8bdae664f16f5ac4c054affe5cd8d8b # Parent c7ec309cd685ed3892d3da589bdaeb9fe740b6f7 Make SetAmmoTexts update ammo menu weapon name, too Lua API warning: SetAmmoTexts can not be called in onGameInit diff -r c7ec309cd685 -r 156f1866b8bd hedgewars/uWorld.pas --- 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;