X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_gui.pas;h=c6b22b8e82d3cbc3b3af1615a38921ee07c4e442;hb=0c447046675a6de0d4cfb88e3cfc31b885138ba1;hp=51a9371099e7783fe10fb4b20378363ec4220244;hpb=20823ffa670faaf9016e3f35efe4df9ab741df51;p=d2df-sdl.git diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 51a9371..c6b22b8 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_console, g_map, g_weapons, xdynrec, wadreader; @@ -572,10 +564,16 @@ function GetLines (text: string; BigFont: Boolean; MaxWidth: Word): SSArray; end; function LineWidth (): Integer; inline; - var w, h: Integer; + {$IFDEF ENABLE_RENDER} + var w, h: Integer; + {$ENDIF} begin - r_GUI_GetStringSize(BigFont, GetLine(i, False), w, h); - Result := w; + {$IFDEF ENABLE_RENDER} + r_Render_GetStringSize(BigFont, GetLine(i, False), w, h); + Result := w; + {$ELSE} + Result := 0; + {$ENDIF} end; begin @@ -899,7 +897,7 @@ end; {$ENDIF} begin {$IFDEF ENABLE_RENDER} - r_GUI_GetSize(Self, Result, h); + r_Render_GetControlSize(Self, Result, h); {$ELSE} Result := 0; {$ENDIF} @@ -911,7 +909,7 @@ end; {$ENDIF} begin {$IFDEF ENABLE_RENDER} - r_GUI_GetSize(Self, w, Result); + r_Render_GetControlSize(Self, w, Result); {$ELSE} Result := 0; {$ENDIF} @@ -968,11 +966,13 @@ end; { TGUIMainMenu } function TGUIMainMenu.AddButton(fProc: Pointer; Caption: string; ShowWindow: string = ''): TGUITextButton; -var - a, _x: Integer; - h, hh: Word; - lw: Word = 0; - lh: Word = 0; + var + {$IFDEF ENABLE_RENDER} + lw: Integer; + {$ENDIF} + a, _x: Integer; + h, hh: Word; + lh: Integer; begin FIndex := 0; @@ -992,8 +992,12 @@ begin if FButtons[a] <> nil then _x := Min(_x, (gScreenWidth div 2)-(FButtons[a].GetWidth div 2)); - if FHeader = nil then - r_GUI_GetLogoSize(lw, lh); + lh := 0; + {$IFDEF ENABLE_RENDER} + lw := 0; + if FHeader = nil then + r_Render_GetLogoSize(lw, lh); + {$ENDIF} hh := FButtons[High(FButtons)].GetHeight; if FHeader = nil then h := lh + hh * (1 + Length(FButtons)) + MAINMENU_SPACE * (Length(FButtons) - 1) @@ -1458,10 +1462,13 @@ begin end; procedure TGUIMenu.ReAlign(); -var - a, tx, cx, w, h, fw, fh: Integer; - cww: array of Integer; // cached widths - maxcww: Integer; + var + {$IFDEF ENABLE_RENDER} + fw, fh: Integer; + {$ENDIF} + a, tx, cx, w, h: Integer; + cww: array of Integer; // cached widths + maxcww: Integer; begin if FItems = nil then Exit; @@ -1529,8 +1536,10 @@ begin h := h+(FItems[a].Control as TGUIListBox).GetHeight() else begin - r_GUI_GetMaxFontSize(FBigFont, fw, fh); - h := h + fh; + {$IFDEF ENABLE_RENDER} + r_Render_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh; + {$ENDIF} end; end; end; @@ -1585,8 +1594,12 @@ begin else if ControlType = TGUIMemo then Inc(h, (Control as TGUIMemo).GetHeight+MENU_VSPACE) else begin - r_GUI_GetMaxFontSize(FBigFont, fw, fh); - h := h + fh + MENU_VSPACE; + {$IFDEF ENABLE_RENDER} + r_Render_GetMaxFontSize(FBigFont, fw, fh); + h := h + fh + MENU_VSPACE; + {$ELSE} + h := h + MENU_VSPACE; + {$ENDIF} end; end; end; @@ -2206,7 +2219,9 @@ end; { TGUIKeyRead2 } constructor TGUIKeyRead2.Create(BigFont: Boolean); - var a: Byte; w, h: Integer; + {$IFDEF ENABLE_RENDER} + var a: Byte; w, h: Integer; + {$ENDIF} begin inherited Create(); @@ -2219,21 +2234,18 @@ begin FMaxKeyNameWdt := 0; - FMaxKeyNameWdt := 0; - - for a := 0 to 255 do - begin - r_GUI_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); - if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; - - r_GUI_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); - if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + {$IFDEF ENABLE_RENDER} + for a := 0 to 255 do + begin + r_Render_GetStringSize(BigFont, e_KeyNames[a], w, h); + FMaxKeyNameWdt := Max(FMaxKeyNameWdt, w); + end; + FMaxKeyNameWdt := FMaxKeyNameWdt-(FMaxKeyNameWdt div 3); + r_Render_GetStringSize(BigFont, KEYREAD_QUERY, w, h); + if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + r_Render_GetStringSize(BigFont, KEYREAD_CLEAR, w, h); + if w > FMaxKeyNameWdt then FMaxKeyNameWdt := w; + {$ENDIF} end; function TGUIKeyRead2.WantActivationKey (key: LongInt): Boolean;