diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas
index 08ecee3316b007a783f681974e47f58785f7fbe3..cd9d3b93244a371f0c89cc751575f78bb0106474 100644 (file)
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
+{$MODE DELPHI}
unit g_gui;
interface
uses
unit g_gui;
interface
uses
- e_graphics, e_input, g_playermodel, g_basic, MAPSTRUCT, WADEDITOR;
+ e_graphics, e_input, g_playermodel, g_basic, MAPSTRUCT, wadreader;
const
MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255);
const
MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255);
FEnabled: Boolean;
FWindow : TGUIWindow;
FName: string;
FEnabled: Boolean;
FWindow : TGUIWindow;
FName: string;
+ FUserData: Pointer;
public
constructor Create;
procedure OnMessage(var Msg: TMessage); virtual;
public
constructor Create;
procedure OnMessage(var Msg: TMessage); virtual;
property Y: Integer read FY write FY;
property Enabled: Boolean read FEnabled write FEnabled;
property Name: string read FName write FName;
property Y: Integer read FY write FY;
property Enabled: Boolean read FEnabled write FEnabled;
property Name: string read FName write FName;
+ property UserData: Pointer read FUserData write FUserData;
end;
TGUIWindow = class
end;
TGUIWindow = class
FShowWindow: string;
public
Proc: procedure;
FShowWindow: string;
public
Proc: procedure;
+ ProcEx: procedure (sender: TGUITextButton);
constructor Create(Proc: Pointer; FontID: DWORD; Text: string);
destructor Destroy(); override;
procedure OnMessage(var Msg: TMessage); override;
constructor Create(Proc: Pointer; FontID: DWORD; Text: string);
destructor Destroy(); override;
procedure OnMessage(var Msg: TMessage); override;
FCounter: Byte;
FAlign: Boolean;
FLeft: Integer;
FCounter: Byte;
FAlign: Boolean;
FLeft: Integer;
+ FYesNo: Boolean;
function NewItem(): Integer;
public
constructor Create(HeaderFont, ItemsFont: DWORD; Header: string);
function NewItem(): Integer;
public
constructor Create(HeaderFont, ItemsFont: DWORD; Header: string);
procedure UpdateIndex();
property Align: Boolean read FAlign write FAlign;
property Left: Integer read FLeft write FLeft;
procedure UpdateIndex();
property Align: Boolean read FAlign write FAlign;
property Left: Integer read FLeft write FLeft;
+ property YesNo: Boolean read FYesNo write FYesNo;
end;
var
end;
var
procedure TGUITextButton.Click(Silent: Boolean = False);
begin
procedure TGUITextButton.Click(Silent: Boolean = False);
begin
- if (FSound <> '') and (not Silent) then
- g_Sound_PlayEx(FSound);
+ if (FSound <> '') and (not Silent) then g_Sound_PlayEx(FSound);
+
+ if @Proc <> nil then Proc();
+ if @ProcEx <> nil then ProcEx(self);
- if @Proc <> nil then
- Proc();
- if FShowWindow <> '' then
- g_GUI_ShowWindow(FShowWindow);
+ if FShowWindow <> '' then g_GUI_ShowWindow(FShowWindow);
end;
constructor TGUITextButton.Create(Proc: Pointer; FontID: DWORD; Text: string);
end;
constructor TGUITextButton.Create(Proc: Pointer; FontID: DWORD; Text: string);
inherited Create();
Self.Proc := Proc;
inherited Create();
Self.Proc := Proc;
+ ProcEx := nil;
FFont := TFont.Create(FontID, FONT_CHAR);
FFont := TFont.Create(FontID, FONT_CHAR);
with FItems[i] do
begin
Text := TGUILabel.Create(l[a], FFontID);
with FItems[i] do
begin
Text := TGUILabel.Create(l[a], FFontID);
- with Text do
+ if FYesNo then
begin
begin
- FColor := MENU_ITEMSTEXT_COLOR;
+ with Text do begin FColor := _RGB(255, 0, 0); end;
+ end
+ else
+ begin
+ with Text do begin FColor := MENU_ITEMSTEXT_COLOR; end;
end;
Control := nil;
end;
Control := nil;
FFontID := ItemsFont;
FCounter := MENU_MARKERDELAY;
FAlign := True;
FFontID := ItemsFont;
FCounter := MENU_MARKERDELAY;
FAlign := True;
+ FYesNo := false;
FHeader := TGUILabel.Create(Header, HeaderFont);
with FHeader do
FHeader := TGUILabel.Create(Header, HeaderFont);
with FHeader do
IK_RETURN, IK_KPRETURN:
begin
if FIndex <> -1 then
IK_RETURN, IK_KPRETURN:
begin
if FIndex <> -1 then
- if FItems[FIndex].Control <> nil then
- FItems[FIndex].Control.OnMessage(Msg);
-
+ begin
+ if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg);
+ end;
g_Sound_PlayEx(MENU_CLICKSOUND);
end;
g_Sound_PlayEx(MENU_CLICKSOUND);
end;
+ // dirty hacks
+ IK_Y:
+ if FYesNo and (length(FItems) > 1) then
+ begin
+ Msg.wParam := IK_RETURN; // to register keypress
+ FIndex := High(FItems)-1;
+ if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg);
+ end;
+ IK_N:
+ if FYesNo and (length(FItems) > 1) then
+ begin
+ Msg.wParam := IK_RETURN; // to register keypress
+ FIndex := High(FItems);
+ if FItems[FIndex].Control <> nil then FItems[FIndex].Control.OnMessage(Msg);
+ end;
end;
end;
end;
end;
end;
end;
cx := 0;
for a := 0 to High(FItems) do
cx := 0;
for a := 0 to High(FItems) do
+ begin
with FItems[a] do
begin
if (Text <> nil) and (Control = nil) then Continue;
with FItems[a] do
begin
if (Text <> nil) and (Control = nil) then Continue;
-
w := 0;
if Text <> nil then w := tx+Text.GetWidth;
w := 0;
if Text <> nil then w := tx+Text.GetWidth;
-
if w > cx then cx := w;
end;
if w > cx then cx := w;
end;
+ end;
cx := cx+MENU_HSPACE;
h := FHeader.GetHeight*2+MENU_VSPACE*(Length(FItems)-1);
for a := 0 to High(FItems) do
cx := cx+MENU_HSPACE;
h := FHeader.GetHeight*2+MENU_VSPACE*(Length(FItems)-1);
for a := 0 to High(FItems) do
+ begin
with FItems[a] do
begin
if (ControlType = TGUIListBox) or (ControlType = TGUIFileListBox) then
with FItems[a] do
begin
if (ControlType = TGUIListBox) or (ControlType = TGUIFileListBox) then
else
h := h+e_CharFont_GetMaxHeight(FFontID);
end;
else
h := h+e_CharFont_GetMaxHeight(FFontID);
end;
+ end;
h := (gScreenHeight div 2)-(h div 2);
h := (gScreenHeight div 2)-(h div 2);
else
Inc(h, e_CharFont_GetMaxHeight(FFontID)+MENU_VSPACE);
end;
else
Inc(h, e_CharFont_GetMaxHeight(FFontID)+MENU_VSPACE);
end;
+
+ // another ugly hack
+ if FYesNo and (length(FItems) > 1) then
+ begin
+ w := -1;
+ for a := High(FItems)-1 to High(FItems) do
+ begin
+ if (FItems[a].Control <> nil) and (FItems[a].ControlType = TGUITextButton) then
+ begin
+ cx := (FItems[a].Control as TGUITextButton).GetWidth;
+ if cx > w then w := cx;
+ end;
+ end;
+ if w > 0 then
+ begin
+ for a := High(FItems)-1 to High(FItems) do
+ begin
+ if (FItems[a].Control <> nil) and (FItems[a].ControlType = TGUITextButton) then
+ begin
+ FItems[a].Control.FX := (gScreenWidth-w) div 2;
+ end;
+ end;
+ end;
+ end;
end;
function TGUIMenu.AddScroll(fText: string): TGUIScroll;
end;
function TGUIMenu.AddScroll(fText: string): TGUIScroll;
procedure TGUIMapPreview.SetMap(Res: string);
var
procedure TGUIMapPreview.SetMap(Res: string);
var
- WAD: TWADEditor_1;
+ WAD: TWADFile;
MapReader: TMapReader_1;
panels: TPanelsRec1Array;
header: TMapHeaderRec_1;
a: Integer;
MapReader: TMapReader_1;
panels: TPanelsRec1Array;
header: TMapHeaderRec_1;
a: Integer;
- FileName, SectionName, ResName: string;
+ FileName: string;
Data: Pointer;
Len: Integer;
rX, rY: Single;
begin
Data: Pointer;
Len: Integer;
rX, rY: Single;
begin
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(Res);
- WAD := TWADEditor_1.Create();
+ WAD := TWADFile.Create();
if not WAD.ReadFile(FileName) then
begin
WAD.Free();
Exit;
end;
if not WAD.ReadFile(FileName) then
begin
WAD.Free();
Exit;
end;
- if not WAD.GetResource('', ResName, Data, Len) then
+ //k8: ignores path again
+ if not WAD.GetMapResource(g_ExtractFileName(Res), Data, Len) then
begin
WAD.Free();
Exit;
begin
WAD.Free();
Exit;