index d445dcb6a3f5ada784171cc44353140ab4d3ba7c..0b67e2d0b1561f92ed89ef24fb9b63ac7cca6944 100644 (file)
{$ENDIF}
SysUtils, Classes, Math,
g_basic,
- e_log, utils, wadreader,
- g_game, g_map, g_options, g_console, g_player, g_weapons, g_language, g_triggers,
+ e_log, utils, wadreader, mapdef,
+ g_game, g_map, g_panel, g_options, g_console, g_player, g_weapons, g_language, g_triggers, g_monsters,
g_net, g_netmaster,
r_draw, r_textures, r_fonts, r_common, r_console, r_map
;
end;
procedure r_Render_DrawView (x, y, w, h: Integer; p: TPlayer);
- var l, t, r, b: Integer;
+ var l, t, r, b, xx, yy: Integer;
begin
r_Draw_GetRect(l, t, r, b);
r_Draw_SetRect(x, y, x + w, y + h);
+ r_Common_GetCameraPos(p, true, xx, yy);
if p <> nil then
begin
- r_Map_Draw(x, y, w, h, p.obj.x + PLAYER_RECT_CX, p.obj.y + PLAYER_RECT_CY, p);
+ r_Map_Draw(x, y, w, h, xx, yy, p);
r_Render_DrawStatsView(x, y, w, h, p);
if p.Spectator and p.NoRespawn then
r_Common_DrawText(_lc[I_PLAYER_SPECT4], x div 2 + w div 2, y div 2 + h div 2, 255, 255, 255, 255, stdfont, TBasePoint.BP_CENTER);
end
else
begin
- r_Map_Draw(x, y, w, h, 0, 0, nil);
+ r_Map_Draw(x, y, w, h, xx, yy, nil);
end;
r_Draw_SetRect(l, t, r, b);
result := p;
end;
+ procedure r_Render_DrawMinimap (x, y: Integer; alpha: Byte);
+ const scale = 16;
+
+ function IsMinimapPanel (const p: TPanel): Boolean;
+ begin
+ result := (p <> nil) and p.Enabled;
+ if result then
+ begin
+ case p.PanelType of
+ PANEL_WALL, PANEL_WATER, PANEL_ACID1, PANEL_ACID2,
+ PANEL_STEP, PANEL_OPENDOOR, PANEL_CLOSEDOOR,
+ PANEL_LIFTUP, PANEL_LIFTDOWN, PANEL_LIFTLEFT, PANEL_LIFTRIGHT:
+ result := true;
+ otherwise
+ result := false;
+ end;
+ end;
+ end;
+
+ procedure DrawObject (xx, yy, ww, hh: Integer; r, g, b: Byte);
+ var x0, y0, x1, y1: Integer;
+ begin
+ x0 := x + xx div scale;
+ y0 := y + yy div scale;
+ x1 := x + (xx + ww - 1) div scale;
+ y1 := y + (yy + hh - 1) div scale;
+ r_Draw_FillRect(x0, y0, x1, y1, r, g, b, alpha);
+ end;
+
+ procedure DrawPanels (const a: TPanelArray);
+ var i: Integer; p: TPanel; c: TRGB;
+ begin
+ if a <> nil then
+ begin
+ for i := 0 to HIGH(a) do
+ begin
+ p := a[i];
+ if IsMinimapPanel(p) then
+ begin
+ case p.PanelType of
+ PANEL_WALL: c := _RGB(208, 208, 208);
+ PANEL_OPENDOOR: c := _RGB(160, 160, 160);
+ PANEL_CLOSEDOOR: c := _RGB(160, 160, 160);
+ PANEL_STEP: c := _RGB(128, 128, 128);
+ PANEL_LIFTUP, PANEL_LIFTDOWN, PANEL_LIFTLEFT, PANEL_LIFTRIGHT:
+ case p.LiftType of
+ LIFTTYPE_UP: c := _RGB(116, 72, 36);
+ LIFTTYPE_DOWN: c := _RGB(116, 124, 96);
+ LIFTTYPE_LEFT: c := _RGB(116, 200, 80);
+ LIFTTYPE_RIGHT: c := _RGB(116, 252, 140);
+ otherwise c := _RGB(255, 0, 0);
+ end;
+ PANEL_WATER: c := _RGB(0, 0, 192);
+ PANEL_ACID1: c := _RGB(0, 176, 0);
+ PANEL_ACID2: c := _RGB(176, 0, 0);
+ otherwise c := _RGB(255, 0, 0);
+ end;
+ DrawObject(p.x, p.y, p.width, p.height, c.r, c.g, c.b);
+ end;
+ end;
+ end;
+ end;
+
+ procedure DrawPlayers;
+ var i: Integer; p: TPlayer; c: TRGB;
+ begin
+ if gPlayers <> nil then
+ begin
+ for i := 0 to HIGH(gPlayers) do
+ begin
+ p := gPlayers[i];
+ if p.Alive then
+ begin
+ case p.Team of
+ TEAM_RED: c := _RGB(255, 0, 0);
+ TEAM_BLUE: c := _RGB(0, 0, 255);
+ otherwise c := _RGB(255, 128, 0);
+ end;
+ DrawObject(p.obj.x, p.obj.y, p.obj.rect.width, p.obj.rect.height, c.r, c.g, c.b);
+ end;
+ end;
+ end;
+ end;
+
+ function DrawMonster (m: TMonster): Boolean;
+ begin
+ result := false; // don't stop
+ if m.alive then
+ DrawObject(m.obj.x, m.obj.y, m.obj.rect.width, m.obj.rect.height, 255, 255, 0);
+ end;
+
+ begin
+ r_Draw_FillRect(x, y, (x + gMapInfo.Width - 1) div scale, (y + gMapInfo.Height - 1) div scale, 0, 0, 0, alpha);
+ DrawPanels(gSteps);
+ DrawPanels(gLifts);
+ DrawPanels(gWater);
+ DrawPanels(gAcid1);
+ DrawPanels(gAcid2);
+ DrawPanels(gWalls);
+ g_Mons_ForEach(DrawMonster);
+ DrawPlayers;
+ end;
+
procedure r_Render_Draw;
var p1, p2: TPlayer;
begin
r_Render_DrawPlayerView(0, 0, gScreenWidth, gScreenHeight, p2);
end;
+ if gShowMap then
+ r_Render_DrawMiniMap(0, 0, 160);
+
// TODO draw holmes inspector
if MessageText <> '' then