X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=blobdiff_plain;f=src%2Fgame%2Fg_menu.pas;h=23e9629666c3a91727a73c2829b8ce74dd283072;hp=015c1e2556f31c61b0905dc464af6633e45ee029;hb=f20e858e5220f471cbb5cca0043f51a209c0ddd4;hpb=97f895c7c328756a955090820189b86724968edc diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 015c1e2..23e9629 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -45,40 +45,38 @@ begin end; end; -function CreateYNMenu (Name, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow; +procedure YesButtonCB (ctl: TGUITextButton); +begin + if ctl.UserData = nil then exit; + TYNCallback(ctl.UserData)(true); +end; + +procedure NoButtonCB (ctl: TGUITextButton); +begin + if ctl.UserData = nil then exit; + TYNCallback(ctl.UserData)(false); +end; + +function CreateYNMenu (WinName, Text: String; MaxLen: Word; FontID: DWORD; ActionProc: TYNCallback): TGUIWindow; var - a: Integer; - h, _x: Word; - lines: SArray; + menu: TGUIMenu; begin - Result := TGUIWindow.Create(Name); + //if length(Text) = 0 then exit; + Result := TGUIWindow.Create(WinName); 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 + //OnKeyDownEx := @YNKeyDownProc; + //UserData := @ActionProc; + menu := TGUIMenu(Result.AddChild(TGUIMenu.Create(gMenuSmallFont, gMenuSmallFont, ''))); + with menu do 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; + Name := '__temp_yes_no_menu:'+WinName; + YesNo := true; + AddText(Text, MaxLen); + with AddButton(nil, 'Yes') do begin ProcEx := @YesButtonCB; UserData := @ActionProc; end; + with AddButton(nil, 'No') do begin ProcEx := @NoButtonCB; UserData := @ActionProc; end; end; - DefControl := ''; + DefControl := '__temp_yes_no_menu:'+WinName; SetActive(nil); end; end;