233 |
233 |
234 r.w:= 26; |
234 r.w:= 26; |
235 r.h:= 19; |
235 r.h:= 19; |
236 |
236 |
237 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
237 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); |
238 |
238 |
239 // overwrite flag for cpu teams and keep players from using it |
239 // overwrite flag for cpu teams and keep players from using it |
240 if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then |
240 if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then |
241 Flag:= 'cpu' |
241 Flag:= 'cpu' |
242 else if Flag = 'cpu' then |
242 else if Flag = 'cpu' then |
243 Flag:= 'hedgewars'; |
243 Flag:= 'hedgewars'; |
244 |
244 |
245 flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); |
245 flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); |
246 if flagsurf = nil then |
246 if flagsurf = nil then |
247 flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); |
247 flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); |
248 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
248 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
249 copyToXY(flagsurf, texsurf, 2, 2); |
249 copyToXY(flagsurf, texsurf, 2, 2); |
250 SDL_FreeSurface(flagsurf); |
250 SDL_FreeSurface(flagsurf); |
251 flagsurf:= nil; |
251 flagsurf:= nil; |
252 |
252 |
253 // restore black border pixels inside the flag |
253 // restore black border pixels inside the flag |
254 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
254 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
255 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
255 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
256 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
256 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
257 PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; |
257 PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; |
1121 {$ENDIF} |
1121 {$ENDIF} |
1122 begin |
1122 begin |
1123 // initialized here because when initModule is called cScreenWidth/Height are not yet set |
1123 // initialized here because when initModule is called cScreenWidth/Height are not yet set |
1124 if (uStore.wScreen = 0) and (uStore.hScreen = 0) then |
1124 if (uStore.wScreen = 0) and (uStore.hScreen = 0) then |
1125 begin |
1125 begin |
1126 uStore.wScreen:= cScreenWidth; |
1126 uStore.wScreen:= cScreenWidth; |
1127 uStore.hScreen:= cScreenHeight; |
1127 uStore.hScreen:= cScreenHeight; |
1128 end; |
1128 end; |
1129 |
1129 |
1130 {$IFDEF IPHONEOS} |
1130 {$IFDEF IPHONEOS} |
1131 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); // no double buffering |
1131 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); // no double buffering |
1212 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); |
1212 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); |
1213 // disable dithering |
1213 // disable dithering |
1214 glDisable(GL_DITHER); |
1214 glDisable(GL_DITHER); |
1215 // enable common states by default as they save a lot |
1215 // enable common states by default as they save a lot |
1216 glEnable(GL_TEXTURE_2D); |
1216 glEnable(GL_TEXTURE_2D); |
1217 glEnableClientState(GL_VERTEX_ARRAY); |
1217 glEnableClientState(GL_VERTEX_ARRAY); |
1218 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
1218 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
1219 end; |
1219 end; |
1220 |
1220 |
1221 procedure SetScale(f: GLfloat); |
1221 procedure SetScale(f: GLfloat); |
1222 begin |
1222 begin |
1223 // leave immediately if scale factor did not change |
1223 // leave immediately if scale factor did not change |
1246 begin |
1246 begin |
1247 WriteToConsole(msgLoading + 'progress sprite: '); |
1247 WriteToConsole(msgLoading + 'progress sprite: '); |
1248 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); |
1248 texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); |
1249 |
1249 |
1250 ProgrTex:= Surface2Tex(texsurf, false); |
1250 ProgrTex:= Surface2Tex(texsurf, false); |
1251 |
1251 |
1252 squaresize:= texsurf^.w shr 1; |
1252 squaresize:= texsurf^.w shr 1; |
1253 numsquares:= texsurf^.h div squaresize; |
1253 numsquares:= texsurf^.h div squaresize; |
1254 SDL_FreeSurface(texsurf); |
1254 SDL_FreeSurface(texsurf); |
1255 {$IFDEF IPHONEOS} |
1255 {$IFDEF IPHONEOS} |
1256 startSpinning(); |
1256 startSpinning(); |
1260 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
1260 TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); |
1261 |
1261 |
1262 glClear(GL_COLOR_BUFFER_BIT); |
1262 glClear(GL_COLOR_BUFFER_BIT); |
1263 if Step < numsquares then r.x:= 0 |
1263 if Step < numsquares then r.x:= 0 |
1264 else r.x:= squaresize; |
1264 else r.x:= squaresize; |
1265 |
1265 |
1266 r.y:= (Step mod numsquares) * squaresize; |
1266 r.y:= (Step mod numsquares) * squaresize; |
1267 r.w:= squaresize; |
1267 r.w:= squaresize; |
1268 r.h:= squaresize; |
1268 r.h:= squaresize; |
1269 |
1269 |
1270 DrawFromRect( -squaresize div 2, (hScreen - squaresize) shr 1, @r, ProgrTex); |
1270 DrawFromRect( -squaresize div 2, (hScreen - squaresize) shr 1, @r, ProgrTex); |
1271 |
1271 |
1272 SDL_GL_SwapBuffers(); |
1272 SDL_GL_SwapBuffers(); |
1273 {$IFDEF SDL13} |
1273 {$IFDEF SDL13} |
1274 SDL_RenderPresent(); |
1274 SDL_RenderPresent(); |
1419 // get extra label's dimensions |
1419 // get extra label's dimensions |
1420 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), i, j); |
1420 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), i, j); |
1421 if w < (i + wa) then w:= i + wa; |
1421 if w < (i + wa) then w:= i + wa; |
1422 inc(h, j + ha); |
1422 inc(h, j + ha); |
1423 end; |
1423 end; |
1424 |
1424 |
1425 // add borders space |
1425 // add borders space |
1426 inc(w, wa); |
1426 inc(w, wa); |
1427 inc(h, ha + 8); |
1427 inc(h, ha + 8); |
1428 |
1428 |
1429 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
1429 tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); |
1449 SplitByChar(tmpline, tmpdesc, '|'); |
1449 SplitByChar(tmpline, tmpdesc, '|'); |
1450 r2:= r; |
1450 r2:= r; |
1451 if tmpline <> '' then |
1451 if tmpline <> '' then |
1452 begin |
1452 begin |
1453 r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline); |
1453 r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline); |
1454 |
1454 |
1455 // render highlighted caption (if there's a ':') |
1455 // render highlighted caption (if there's a ':') |
1456 tmpline2:= ''; |
1456 tmpline2:= ''; |
1457 SplitByChar(tmpline, tmpline2, ':'); |
1457 SplitByChar(tmpline, tmpline2, ':'); |
1458 if tmpline2 <> '' then |
1458 if tmpline2 <> '' then |
1459 WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); |
1459 WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); |
1467 r.y:= FontBorder + 4; |
1467 r.y:= FontBorder + 4; |
1468 r.w:= 32; |
1468 r.w:= 32; |
1469 r.h:= 32; |
1469 r.h:= 32; |
1470 SDL_FillRect(tmpsurf, @r, $ffffffff); |
1470 SDL_FillRect(tmpsurf, @r, $ffffffff); |
1471 SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r); |
1471 SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r); |
1472 |
1472 |
1473 RenderHelpWindow:= Surface2Tex(tmpsurf, true); |
1473 RenderHelpWindow:= Surface2Tex(tmpsurf, true); |
1474 SDL_FreeSurface(tmpsurf) |
1474 SDL_FreeSurface(tmpsurf) |
1475 end; |
1475 end; |
1476 |
1476 |
1477 procedure RenderWeaponTooltip(atype: TAmmoType); |
1477 procedure RenderWeaponTooltip(atype: TAmmoType); |