From: DeaDDooMER Date: Mon, 31 Jan 2022 19:44:53 +0000 (+0300) Subject: render: use only r_render to access render-specific info X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=0da9a438ff0d90e07b82d929065de68a106cb09e;p=d2df-sdl.git render: use only r_render to access render-specific info --- diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 734251a..e18b60d 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -17,51 +17,42 @@ unit g_gui; interface -uses - {$IFDEF USE_MEMPOOL}mempool,{$ENDIF} - g_base, e_input, e_log, g_playermodel, g_basic, MAPDEF, utils; + uses + {$IFDEF USE_MEMPOOL} + mempool, + {$ENDIF} + g_base, g_playermodel, MAPDEF, utils + ; const - MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255); + MAINMENU_ITEMS_COLOR: TRGB = (R:255; G:255; B:255); MAINMENU_UNACTIVEITEMS_COLOR: TRGB = (R:192; G:192; B:192); - MAINMENU_CLICKSOUND = 'MENU_SELECT'; - MAINMENU_CHANGESOUND = 'MENU_CHANGE'; + MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255); MAINMENU_SPACE = 4; - MAINMENU_MARKER1 = 'MAINMENU_MARKER1'; - MAINMENU_MARKER2 = 'MAINMENU_MARKER2'; MAINMENU_MARKERDELAY = 24; - WINDOW_CLOSESOUND = 'MENU_CLOSE'; - MENU_HEADERCOLOR: TRGB = (R:255; G:255; B:255); + MENU_ITEMSTEXT_COLOR: TRGB = (R:255; G:255; B:255); MENU_UNACTIVEITEMS_COLOR: TRGB = (R:128; G:128; B:128); MENU_ITEMSCTRL_COLOR: TRGB = (R:255; G:0; B:0); MENU_VSPACE = 2; MENU_HSPACE = 32; + MENU_MARKERDELAY = 24; + + MAPPREVIEW_WIDTH = 8; + MAPPREVIEW_HEIGHT = 8; + + KEYREAD_QUERY = '<...>'; + KEYREAD_CLEAR = '???'; + + WINDOW_CLOSESOUND = 'MENU_CLOSE'; + MAINMENU_CLICKSOUND = 'MENU_SELECT'; + MAINMENU_CHANGESOUND = 'MENU_CHANGE'; MENU_CLICKSOUND = 'MENU_SELECT'; MENU_CHANGESOUND = 'MENU_CHANGE'; - MENU_MARKERDELAY = 24; - SCROLL_LEFT = 'SCROLL_LEFT'; - SCROLL_RIGHT = 'SCROLL_RIGHT'; - SCROLL_MIDDLE = 'SCROLL_MIDDLE'; - SCROLL_MARKER = 'SCROLL_MARKER'; SCROLL_ADDSOUND = 'SCROLL_ADD'; SCROLL_SUBSOUND = 'SCROLL_SUB'; - EDIT_LEFT = 'EDIT_LEFT'; - EDIT_RIGHT = 'EDIT_RIGHT'; - EDIT_MIDDLE = 'EDIT_MIDDLE'; - EDIT_CURSORCOLOR: TRGB = (R:200; G:0; B:0); - EDIT_CURSORLEN = 10; - KEYREAD_QUERY = '<...>'; - KEYREAD_CLEAR = '???'; - KEYREAD_TIMEOUT = 24; - MAPPREVIEW_WIDTH = 8; - MAPPREVIEW_HEIGHT = 8; - BSCROLL_UPA = 'BSCROLL_UP_A'; - BSCROLL_UPU = 'BSCROLL_UP_U'; - BSCROLL_DOWNA = 'BSCROLL_DOWN_A'; - BSCROLL_DOWNU = 'BSCROLL_DOWN_U'; - BSCROLL_MIDDLE = 'BSCROLL_MIDDLE'; + WM_KEYDOWN = 101; WM_CHAR = 102; WM_USER = 110; @@ -538,8 +529,9 @@ uses g_system, {$ENDIF} {$IFDEF ENABLE_RENDER} - r_gui, + r_render, {$ENDIF} + e_input, e_log, g_sound, SysUtils, e_res, g_game, Math, StrUtils, g_player, g_options, g_map, g_weapons, xdynrec, wadreader; @@ -562,7 +554,7 @@ function GetLines (Text: string; BigFont: Boolean; MaxWidth: Word): SSArray; {$ENDIF} begin {$IFDEF ENABLE_RENDER} - r_GUI_GetStringSize(BigFont, GetLine(j, i), w, h); + r_Render_GetStringSize(BigFont, GetLine(j, i), w, h); Result := w; {$ELSE} Result := 0; @@ -883,7 +875,7 @@ end; {$ENDIF} begin {$IFDEF ENABLE_RENDER} - r_GUI_GetSize(Self, Result, h); + r_Render_GetControlSize(Self, Result, h); {$ELSE} Result := 0; {$ENDIF} @@ -895,7 +887,7 @@ end; {$ENDIF} begin {$IFDEF ENABLE_RENDER} - r_GUI_GetSize(Self, w, Result); + r_Render_GetControlSize(Self, w, Result); {$ELSE} Result := 0; {$ENDIF} @@ -954,11 +946,11 @@ end; function TGUIMainMenu.AddButton(fProc: Pointer; Caption: string; ShowWindow: string = ''): TGUITextButton; var {$IFDEF ENABLE_RENDER} - lw: Word = 0; + lw: Integer; {$ENDIF} a, _x: Integer; h, hh: Word; - lh: Word = 0; + lh: Integer; begin FIndex := 0; @@ -978,9 +970,11 @@ begin if FButtons[a] <> nil then _x := Min(_x, (gScreenWidth div 2)-(FButtons[a].GetWidth div 2)); + lw := 0; + lh := 0; {$IFDEF ENABLE_RENDER} if FHeader = nil then - r_GUI_GetLogoSize(lw, lh); + r_Render_GetLogoSize(lw, lh); {$ENDIF} hh := FButtons[High(FButtons)].GetHeight; @@ -1521,7 +1515,7 @@ begin else begin {$IFDEF ENABLE_RENDER} - r_GUI_GetMaxFontSize(FBigFont, fw, fh); + r_Render_GetMaxFontSize(FBigFont, fw, fh); h := h + fh; {$ENDIF} end; @@ -1579,7 +1573,7 @@ begin else begin {$IFDEF ENABLE_RENDER} - r_GUI_GetMaxFontSize(FBigFont, fw, fh); + r_Render_GetMaxFontSize(FBigFont, fw, fh); h := h + fh + MENU_VSPACE; {$ELSE} h := h + MENU_VSPACE; @@ -2239,13 +2233,13 @@ begin {$IFDEF ENABLE_RENDER} for a := 0 to 255 do begin - r_GUI_GetStringSize(BigFont, e_KeyNames[a], w, h); + r_Render_GetStringSize(BigFont, e_KeyNames[a], w, h); FMaxKeyNameWdt := Max(FMaxKeyNameWdt, w); end; FMaxKeyNameWdt := FMaxKeyNameWdt-(FMaxKeyNameWdt div 3); - r_GUI_GetStringSize(BigFont, KEYREAD_QUERY, w, h); + r_Render_GetStringSize(BigFont, KEYREAD_QUERY, w, h); if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; - r_GUI_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); + r_Render_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; {$ENDIF} end; diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas index 2c15447..414a30f 100644 --- a/src/game/g_holmes.pas +++ b/src/game/g_holmes.pas @@ -20,7 +20,7 @@ interface uses mempool, geom, e_log, e_input, - g_textures, g_basic, r_graphics, g_phys, g_grid, g_player, g_monsters, + g_basic, g_phys, g_grid, g_player, g_monsters, g_map, g_triggers, g_items, g_game, g_panel, g_console, xprofiler, sdlcarcass, diff --git a/src/game/opengl/r_gui.pas b/src/game/opengl/r_gui.pas index 8df2b40..00fb568 100644 --- a/src/game/opengl/r_gui.pas +++ b/src/game/opengl/r_gui.pas @@ -23,7 +23,7 @@ interface procedure r_GUI_Free; procedure r_GUI_GetSize (ctrl: TGUIControl; out w, h: Integer); - procedure r_GUI_GetLogoSize (out w, h: WORD); + procedure r_GUI_GetLogoSize (out w, h: Integer); procedure r_GUI_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); procedure r_GUI_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); @@ -50,6 +50,23 @@ implementation BOX8 = 'BOX8'; BOX9 = 'BOX9'; + MAINMENU_MARKER1 = 'MAINMENU_MARKER1'; + MAINMENU_MARKER2 = 'MAINMENU_MARKER2'; + SCROLL_LEFT = 'SCROLL_LEFT'; + SCROLL_RIGHT = 'SCROLL_RIGHT'; + SCROLL_MIDDLE = 'SCROLL_MIDDLE'; + SCROLL_MARKER = 'SCROLL_MARKER'; + EDIT_LEFT = 'EDIT_LEFT'; + EDIT_RIGHT = 'EDIT_RIGHT'; + EDIT_MIDDLE = 'EDIT_MIDDLE'; + EDIT_CURSORCOLOR: TRGB = (R:200; G:0; B:0); + EDIT_CURSORLEN = 10; + BSCROLL_UPA = 'BSCROLL_UP_A'; + BSCROLL_UPU = 'BSCROLL_UP_U'; + BSCROLL_DOWNA = 'BSCROLL_DOWN_A'; + BSCROLL_DOWNU = 'BSCROLL_DOWN_U'; + BSCROLL_MIDDLE = 'BSCROLL_MIDDLE'; + type TFontType = (Texture, Character); @@ -127,12 +144,15 @@ implementation h := hh; end; - procedure r_GUI_GetLogoSize (out w, h: WORD); + procedure r_GUI_GetLogoSize (out w, h: Integer); + var ww, hh: WORD; begin - w := 0; - h := 0; + ww := 0; + hh := 0; if LogoTex <> 0 then - e_GetTextureSize(LogoTex, @w, @h); + e_GetTextureSize(LogoTex, @ww, @hh); + w := ww; + h := hh; end; procedure r_GUI_Load; diff --git a/src/game/opengl/r_render.pas b/src/game/opengl/r_render.pas index 869b27f..e5ed348 100644 --- a/src/game/opengl/r_render.pas +++ b/src/game/opengl/r_render.pas @@ -17,7 +17,12 @@ unit r_render; interface - uses g_base; // TRectWH + uses + {$IFDEF ENABLE_MENU} + g_gui, + {$ENDIF} + g_base // TRectWH + ; procedure r_Render_Initialize; procedure r_Render_Finalize; @@ -49,6 +54,13 @@ interface procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean); {$ENDIF} + {$IFDEF ENABLE_MENU} + procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer); + procedure r_Render_GetLogoSize (out w, h: Integer); + procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); + {$ENDIF} + procedure r_Render_DrawLoading (force: Boolean); // !!! remove it implementation @@ -362,6 +374,28 @@ implementation end; {$ENDIF} +{$IFDEF ENABLE_MENU} + procedure r_Render_GetControlSize (ctrl: TGUIControl; out w, h: Integer); + begin + r_GUI_GetSize(ctrl, w, h) + end; + + procedure r_Render_GetLogoSize (out w, h: Integer); + begin + r_GUI_GetLogoSize(w, h) + end; + + procedure r_Render_GetMaxFontSize (BigFont: Boolean; out w, h: Integer); + begin + r_GUI_GetMaxFontSize(BigFont, w, h) + end; + + procedure r_Render_GetStringSize (BigFont: Boolean; str: String; out w, h: Integer); + begin + r_GUI_GetStringSize(BigFont, str, w, h) + end; +{$ENDIF} + procedure r_Render_DrawLoading (force: Boolean); begin r_Window_DrawLoading(force)