X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_gui.pas;h=e18b60dd89e837125fbd2bbbaf48d32babf001cd;hb=0da9a438ff0d90e07b82d929065de68a106cb09e;hp=988d0909fd5afe24c1cc4501824e6855130e11df;hpb=09e7681fd86c15d7553b8b8535775b703c5516aa;p=d2df-sdl.git diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 988d090..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; @@ -557,10 +549,16 @@ function GetLines (Text: string; BigFont: Boolean; MaxWidth: Word): SSArray; end; function GetWidth (j, i: Integer): Integer; - var w, h: Integer; + {$IFDEF ENABLE_RENDER} + var w, h: Integer; + {$ENDIF} begin - r_GUI_GetStringSize(BigFont, GetLine(j, i), w, h); - result := w + {$IFDEF ENABLE_RENDER} + r_Render_GetStringSize(BigFont, GetLine(j, i), w, h); + Result := w; + {$ELSE} + Result := 0; + {$ENDIF} end; begin @@ -877,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} @@ -889,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} @@ -946,11 +944,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; @@ -970,8 +970,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); + lw := 0; + lh := 0; + {$IFDEF ENABLE_RENDER} + 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) @@ -1436,10 +1440,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; @@ -1507,8 +1514,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; @@ -1563,8 +1572,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; @@ -2202,7 +2215,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(); @@ -2215,21 +2230,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;