From: Joseph Stalin Date: Sat, 3 Aug 2019 18:38:49 +0000 (+0500) Subject: Corrected aspect for menu background X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=0d43461fbabe69392b0a841eac53710e4e6ca3ea;p=d2df-sdl.git Corrected aspect for menu background --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 8f659e8..41099da 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -142,6 +142,7 @@ procedure g_Game_StepLoading(Value: Integer = -1); procedure g_Game_ClearLoading(); procedure g_Game_SetDebugMode(); procedure DrawLoadingStat(); +procedure DrawMenuBackground(tex: AnsiString; ID: DWord); { procedure SetWinPause(Enable: Boolean); } @@ -1276,10 +1277,12 @@ begin sfsGCDisable(); // temporary disable removing of temporary volumes try + TEXTUREFILTER := GL_LINEAR; g_Texture_CreateWADEx('MENU_BACKGROUND', GameWAD+':TEXTURES\TITLE'); g_Texture_CreateWADEx('INTER', GameWAD+':TEXTURES\INTER'); g_Texture_CreateWADEx('ENDGAME_EN', GameWAD+':TEXTURES\ENDGAME_EN'); g_Texture_CreateWADEx('ENDGAME_RU', GameWAD+':TEXTURES\ENDGAME_RU'); + TEXTUREFILTER := GL_NEAREST; LoadStdFont('STDTXT', 'STDFONT', gStdFont); LoadFont('MENUTXT', 'MENUFONT', gMenuFont); @@ -3002,6 +3005,24 @@ begin end; end; +procedure DrawMenuBackground(tex: AnsiString; ID: DWord); +var + w, h: Word; + +begin + if g_Texture_Get(tex, ID) then + begin + e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + e_GetTextureSize(ID, @w, @h); + if w = h then + w := round(w * 1.333 * (gScreenHeight / h)) + else + w := trunc(w * (gScreenHeight / h)); + e_DrawSize(ID, (gScreenWidth - w) div 2, 0, 0, False, False, w, gScreenHeight); + end + else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); +end; + procedure DrawMinimap(p: TPlayer; RenderRect: e_graphics.TRect); var a, aX, aY, aX2, aY2, Scale, ScaleSz: Integer; @@ -3904,11 +3925,7 @@ begin begin if (gState = STATE_MENU) then begin - if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then - begin - if g_Texture_Get('MENU_BACKGROUND', ID) then e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) - else e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); - end; + if (g_ActiveWindow = nil) or (g_ActiveWindow.BackTexture = '') then DrawMenuBackground('MENU_BACKGROUND', ID); // F3 at menu will show game loading dialog if e_KeyPressed(IK_F3) then g_Menu_Show_LoadMenu(true); if (g_ActiveWindow <> nil) then @@ -3943,10 +3960,7 @@ begin else back := 'INTER'; - if g_Texture_Get(back, ID) then - e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) - else - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + DrawMenuBackground(back, ID); DrawCustomStat(); @@ -3967,10 +3981,7 @@ begin begin back := 'INTER'; - if g_Texture_Get(back, ID) then - e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) - else - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + DrawMenuBackground(back, ID); DrawSingleStat(); @@ -4002,12 +4013,13 @@ begin if gState = STATE_SLIST then begin - if g_Texture_Get('MENU_BACKGROUND', ID) then - begin - e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight); - //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end; +// if g_Texture_Get('MENU_BACKGROUND', ID) then +// begin +// e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight); +// //e_DrawFillQuad(0, 0, gScreenWidth-1, gScreenHeight-1, 48, 48, 48, 180); +// end; + DrawMenuBackground('MENU_BACKGROUND', ID); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); g_Serverlist_Draw(slCurrent, slTable); end; end; diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 07a03c1..ef56459 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -685,14 +685,14 @@ begin if len = 0 then Exit; -// Îêíî ñ ãëàâíûì ìåíþ: +// ���� � ������� ����: g_GUI_ShowWindow(Saved_Windows[len-1]); -// Íå ïåðåêëþ÷èëîñü (èëè íåêóäà äàëüøå): +// �� ������������� (��� ������ ������): if (len = 1) or (g_ActiveWindow = nil) then Exit; -// Èùåì êíîïêè â îñòàëüíûõ îêíàõ: +// ���� ������ � ��������� �����: for k := len-1 downto 1 do begin ok := False; @@ -726,7 +726,7 @@ begin Break; end; - // Íå ïåðåêëþ÷èëîñü: + // �� �������������: if (not ok) or (g_ActiveWindow.Name = Saved_Windows[k]) then Break; @@ -814,10 +814,19 @@ procedure TGUIWindow.Draw; var i: Integer; ID: DWORD; + tw, th: Word; begin - if FBackTexture <> '' then + if FBackTexture <> '' then // Here goes code duplication from g_game.pas:DrawMenuBackground() if g_Texture_Get(FBackTexture, ID) then - e_DrawSize(ID, 0, 0, 0, False, False, gScreenWidth, gScreenHeight) + begin + e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); + e_GetTextureSize(ID, @tw, @th); + if tw = th then + tw := round(tw * 1.333 * (gScreenHeight / th)) + else + tw := trunc(tw * (gScreenHeight / th)); + e_DrawSize(ID, (gScreenWidth - tw) div 2, 0, 0, False, False, tw, gScreenHeight); + end else e_Clear(GL_COLOR_BUFFER_BIT, 0.5, 0.5, 0.5); @@ -3232,7 +3241,7 @@ begin SetActive(Self) else begin - if FItems[FIndex][1] = #29 then // Ïàïêà + if FItems[FIndex][1] = #29 then // ����� begin OpenDir(FPath+Copy(FItems[FIndex], 2, 255)); FIndex := 0; @@ -3254,7 +3263,7 @@ begin if ( (Length(FItems[a]) > 0) and (LowerCase(FItems[a][1]) = LowerCase(Chr(wParam))) ) or ( (Length(FItems[a]) > 1) and - (FItems[a][1] = #29) and // Ïàïêà + (FItems[a][1] = #29) and // ����� (LowerCase(FItems[a][2]) = LowerCase(Chr(wParam))) ) then begin FIndex := a; @@ -3278,7 +3287,7 @@ begin path := IncludeTrailingPathDelimiter(path); path := ExpandFileName(path); - // Êàòàëîãè: + // ��������: if FDirs then begin if FindFirst(path+'*', faDirectory, SR) = 0 then @@ -3295,7 +3304,7 @@ begin FindClose(SR); end; - // Ôàéëû: + // �����: sm := FFileMask; while sm <> '' do begin diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 82107dc..fb3c240 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -826,15 +826,8 @@ begin if forceUpdate then begin - if g_Texture_Get('INTER', ID) then - begin - e_DrawSize(ID, 0, 0, 0, false, false, gScreenWidth, gScreenHeight); - e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); - end - else - begin - e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0); - end; + DrawMenuBackground('INTER', ID); + e_DarkenQuadWH(0, 0, gScreenWidth, gScreenHeight, 150); DrawLoadingStat(); SwapBuffers(); @@ -923,7 +916,7 @@ begin exit; end; - // Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ + // ����� ����������� ���������� if flag then begin Time_Old := Time-(Time_Delta mod 28); @@ -974,7 +967,7 @@ begin {$IFDEF USE_GLES1} SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); {$ELSE} SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); @@ -1179,10 +1172,10 @@ begin Init(); Time_Old := GetTimer(); - // Êîìàíäíàÿ ñòðîêà + // ��������� ������ if (ParamCount > 0) then g_Game_Process_Params(); - // Çàïðîñ ÿçûêà + // ������ ����� if (not gGameOn) and gAskLanguage then g_Menu_AskLanguage(); e_WriteLog('Entering the main loop', TMsgType.Notify);