X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_menu.pas;h=015c1e2556f31c61b0905dc464af6633e45ee029;hb=b8db17f63a79d8f79ddde6405fabbc9919f51678;hp=231737bb1db45fba057737caf4bf4feee5a3cdfd;hpb=002448a291229b79e2ee941ec6e287f731c56104;p=d2df-sdl.git diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 231737b..015c1e2 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -33,6 +33,57 @@ uses e_textures, GL, GLExt, g_language, g_net, g_netmsg, g_netmaster, g_items, e_input; + +type TYNCallback = procedure (yes:Boolean); + +procedure YNKeyDownProc (win: TGUIWindow; Key: Byte); +begin + if win.UserData = nil then exit; + case Key of + IK_Y, IK_SPACE: TYNCallback(win.UserData)(true); + IK_N: TYNCallback(win.UserData)(false); + end; +end; + +function CreateYNMenu (Name, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow; +var + a: Integer; + h, _x: Word; + lines: SArray; +begin + Result := TGUIWindow.Create(Name); + with Result do + begin + OnKeyDownEx := @YNKeyDownProc; + UserData := @ActionProc; + lines := GetLines(Text, FontID, MaxLen); + h := e_CharFont_GetMaxHeight(FontID); + _x := (gScreenHeight div 2)-(h*Length(lines) div 2); + if lines <> nil then + begin + for a := 0 to High(lines) do + begin + with TGUILabel(Result.AddChild(TGUILabel.Create(lines[a], FontID))) do + begin + X := (gScreenWidth div 2)-(GetWidth div 2); + Y := _x; + Color := _RGB(255, 0, 0); + _x := _x+h; + end; + end; + with TGUILabel(Result.AddChild(TGUILabel.Create('(Y/N)', FontID))) do + begin + X := (gScreenWidth div 2)-(GetWidth div 2); + Y := _x; + Color := _RGB(255, 0, 0); + end; + end; + DefControl := ''; + SetActive(nil); + end; +end; + + procedure ProcChangeColor(Sender: TGUIControl); forward; procedure ProcSelectModel(Sender: TGUIControl); forward; @@ -49,6 +100,7 @@ begin gBPP := 32; gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0; gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0; + glLegacyNPOT := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0); menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu')); @@ -214,6 +266,9 @@ begin with TGUISwitch(menu.GetControl('swVSync')) do if gVSync then ItemIndex := 0 else ItemIndex := 1; + with TGUISwitch(menu.GetControl('swLegacyNPOT')) do + if not glLegacyNPOT then ItemIndex := 0 else ItemIndex := 1; + menu := TGUIMenu(g_GUI_GetWindow('OptionsSoundMenu').GetControl('mOptionsSoundMenu')); TGUIScroll(menu.GetControl('scSoundLevel')).Value := Round(gSoundLevel/16); @@ -883,13 +938,13 @@ begin gMusic.Play(); end; -procedure ProcExitMenuKeyDown(Key: Byte); +procedure ProcExitMenuKeyDown (yes: Boolean); var s: ShortString; snd: TPlayableSound; res: Boolean; begin - if Key = IK_Y then + if yes then begin g_Game_StopAllSounds(True); case (Random(18)) of @@ -911,24 +966,18 @@ begin 15: s := 'SOUND_MONSTER_SPIDER_ALERT'; else s := 'SOUND_PLAYER_FALL'; end; - snd := TPlayableSound.Create(); res := snd.SetByName(s); - if not res then - res := snd.SetByName('SOUND_PLAYER_FALL'); - + if not res then res := snd.SetByName('SOUND_PLAYER_FALL'); if res then begin snd.Play(True); - while snd.IsPlaying() do - ; + while snd.IsPlaying() do begin end; end; - g_Game_Quit(); - end - else - if Key = IK_N then - g_GUI_HideWindow(); + exit; + end; + g_GUI_HideWindow(); end; procedure ProcLoadMenu(); @@ -1128,25 +1177,20 @@ begin if Direction = D_LEFT then Direction := D_RIGHT else Direction := D_LEFT; end; -procedure ProcDefaultMenuKeyDown(Key: Byte); +procedure ProcDefaultMenuKeyDown (yes: Boolean); begin - if Key = Ord('y') then + if yes then begin g_Options_SetDefault(); ReadOptions(); - g_GUI_HideWindow(); - end else - if Key = Ord('n') then g_GUI_HideWindow; + end; + g_GUI_HideWindow(); end; -procedure ProcSavedMenuKeyDown(Key: Byte); +procedure ProcSavedMenuKeyDown (yes: Boolean); begin - if Key = Ord('y') then - begin - ReadOptions(); - g_GUI_HideWindow(); - end else - if Key = Ord('n') then g_GUI_HideWindow; + if yes then ReadOptions(); + g_GUI_HideWindow(); end; procedure ProcAuthorsClose(); @@ -1309,16 +1353,14 @@ begin g_Game_Pause(False); end; -procedure ProcRestartMenuKeyDown(Key: Byte); +procedure ProcRestartMenuKeyDown (yes: Boolean); begin - if Key = Ord('y') then g_Game_Restart() - else if Key = Ord('n') then g_GUI_HideWindow; + if yes then g_Game_Restart() else g_GUI_HideWindow; end; -procedure ProcEndMenuKeyDown(Key: Byte); +procedure ProcEndMenuKeyDown (yes: Boolean); begin - if Key = Ord('y') then gExit := EXIT_SIMPLE - else if Key = Ord('n') then g_GUI_HideWindow; + if yes then gExit := EXIT_SIMPLE else g_GUI_HideWindow; end; procedure ProcSetRussianLanguage(); @@ -1581,48 +1623,6 @@ begin ProcApplyOptions(); end; -function CreateYNMenu(Name, Text: String; MaxLen: Word; FontID: DWORD; - KeyDownProc: Pointer): TGUIWindow; -var - a: Integer; - h, _x: Word; - lines: SArray; -begin - Result := TGUIWindow.Create(Name); - - with Result do - begin - OnKeyDown := KeyDownProc; - - lines := GetLines(Text, FontID, MaxLen); - - h := e_CharFont_GetMaxHeight(FontID); - _x := (gScreenHeight div 2)-(h*Length(lines) div 2); - - if lines <> nil then - begin - for a := 0 to High(lines) do - with TGUILabel(Result.AddChild(TGUILabel.Create(lines[a], FontID))) do - begin - X := (gScreenWidth div 2)-(GetWidth div 2); - Y := _x; - Color := _RGB(255, 0, 0); - _x := _x+h; - end; - - with TGUILabel(Result.AddChild(TGUILabel.Create('(Y\N)', FontID))) do - begin - X := (gScreenWidth div 2)-(GetWidth div 2); - Y := _x; - Color := _RGB(255, 0, 0); - end; - end; - - DefControl := ''; - SetActive(nil); - end; -end; - procedure ProcSetFirstRussianLanguage(); begin gLanguage := LANGUAGE_RUSSIAN; @@ -2176,7 +2176,7 @@ begin Sort := True; Dirs := True; - FileMask := '*.wad'; + FileMask := '*.wad|*.pk3|*.zip'; SetBase(MapsDir+'megawads/'); end; @@ -2231,7 +2231,7 @@ begin Sort := True; Dirs := True; - FileMask := '*.wad'; + FileMask := '*.wad|*.pk3|*.zip'; SetBase(MapsDir); end; with AddList(_lc[I_MENU_MAP_RESOURCE], 12, 4) do @@ -2333,6 +2333,12 @@ begin AddItem(_lc[I_MENU_YES]); AddItem(_lc[I_MENU_NO]); end; + with AddSwitch(_lc[I_MENU_VIDEO_LEGACY_COMPATIBLE]) do + begin + Name := 'swLegacyNPOT'; + AddItem(_lc[I_MENU_NO]); + AddItem(_lc[I_MENU_YES]); + end; AddSpace(); AddText(_lc[I_MENU_VIDEO_NEED_RESTART], Round(gScreenWidth*0.6)); ReAlign(); @@ -2683,6 +2689,13 @@ begin _y := _y+22; end; with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_1], gMenuSmallFont))) do + begin + Color := _RGB(255, 255, 255); + X := cx+32; + Y := _y; + _y := _y+22; + end; + with TGUILabel(Menu.AddChild(TGUILabel.Create(_lc[I_CREDITS_A_2_2], gMenuSmallFont))) do begin Color := _RGB(255, 255, 255); X := cx+32;