Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfd5fa163e | ||
|
|
a52fec80a9 | ||
|
|
40b00ddde1 | ||
|
|
16ce4dfbea | ||
|
|
2a23ec0923 |
@@ -40,6 +40,11 @@ ipch/
|
||||
*.log
|
||||
rpl4.log
|
||||
|
||||
# Where the game window and the exploded view's panes were last dragged
|
||||
# to (RP412MFDLAYOUT). Per-machine by nature - it is screen coordinates
|
||||
# on somebody's desk.
|
||||
mfd_layout.cfg
|
||||
|
||||
# Build-output static libs that land in lib/ (the two committed dependency
|
||||
# libs, OpenAL32.lib and libsndfile-1.lib, stay tracked).
|
||||
/lib/Munga_L4.lib
|
||||
|
||||
@@ -10,6 +10,74 @@ namespace
|
||||
|
||||
const int buttonGap = 4;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Sticky placement for the exploded view. See L4MFDVIEW.h; ported
|
||||
// from BT411's BT_GLASS_LAYOUT.
|
||||
//---------------------------------------------------------------
|
||||
enum { LayoutOff = 0, LayoutLoad, LayoutSave };
|
||||
|
||||
const char layoutFileName[] = "mfd_layout.cfg";
|
||||
|
||||
// every window taking part, so Save can walk them
|
||||
enum { maxLayoutWindows = 12 };
|
||||
struct LayoutWindow
|
||||
{
|
||||
void *window;
|
||||
const char *title;
|
||||
Logical withSize;
|
||||
Logical bare; // frame stripped, per the file
|
||||
};
|
||||
LayoutWindow layoutWindows[maxLayoutWindows];
|
||||
int layoutWindowCount = 0;
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Take a window's frame off: no title bar, no border, nothing to
|
||||
// drag it by. WS_SYSMENU stays - it draws nothing once the caption
|
||||
// is gone, but without one DefWindowProc will not honour Alt+F4,
|
||||
// and a bare window with no way to close it is a trap.
|
||||
//---------------------------------------------------------------
|
||||
void StripWindowFrame(HWND window)
|
||||
{
|
||||
LONG_PTR style = GetWindowLongPtrA(window, GWL_STYLE);
|
||||
style &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX |
|
||||
WS_MAXIMIZEBOX | WS_BORDER | WS_DLGFRAME);
|
||||
style |= WS_POPUP;
|
||||
SetWindowLongPtrA(window, GWL_STYLE, style);
|
||||
}
|
||||
|
||||
int LayoutMode()
|
||||
{
|
||||
static int mode = -1;
|
||||
if (mode < 0)
|
||||
{
|
||||
const char *setting = getenv("RP412MFDLAYOUT");
|
||||
if (setting == NULL || setting[0] == '\0')
|
||||
{
|
||||
mode = LayoutOff;
|
||||
}
|
||||
else if (!stricmp(setting, "off") || !stricmp(setting, "0"))
|
||||
{
|
||||
mode = LayoutOff;
|
||||
}
|
||||
else if (!stricmp(setting, "load") || !stricmp(setting, "restore"))
|
||||
{
|
||||
mode = LayoutLoad;
|
||||
}
|
||||
else // save / adjust / on / 1
|
||||
{
|
||||
mode = LayoutSave;
|
||||
}
|
||||
|
||||
if (mode != LayoutOff)
|
||||
{
|
||||
DEBUG_STREAM << "MFDLayout: RP412MFDLAYOUT="
|
||||
<< ((mode == LayoutSave) ? "save" : "load")
|
||||
<< " (" << layoutFileName << ")\n" << std::flush;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Button banks run UNDER the glass: a button reaches this far in
|
||||
// from the display edge, but only the indicator strip clears that
|
||||
@@ -108,6 +176,15 @@ namespace
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_EXITSIZEMOVE:
|
||||
//
|
||||
// A drag just finished. Write the whole arrangement now rather
|
||||
// than trusting teardown, so a hard kill still leaves the
|
||||
// layout that was on screen. No-op unless the mode is save.
|
||||
//
|
||||
RPWindowLayout_Save();
|
||||
return 0;
|
||||
|
||||
case WM_CLOSE:
|
||||
// Part of the cockpit; just hide it.
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
@@ -148,6 +225,8 @@ MFDSplitView::MFDSplitView(
|
||||
sourceHeight = source_height;
|
||||
buttonCount = 0;
|
||||
pressedIndex = -1;
|
||||
paneTitle = title;
|
||||
ownWindow = (parent == NULL) ? True : False;
|
||||
|
||||
pixels = new unsigned long[source_width * source_height];
|
||||
memset(pixels, 0, source_width * source_height * sizeof(unsigned long));
|
||||
@@ -230,6 +309,14 @@ MFDSplitView::MFDSplitView(
|
||||
{
|
||||
SetWindowLongPtrA((HWND) window, GWLP_USERDATA, (LONG_PTR) this);
|
||||
ShowWindow((HWND) window, SW_SHOWNOACTIVATE);
|
||||
|
||||
// only the exploded view's own windows can be dragged, so only
|
||||
// those have a placement worth remembering. Position only - see
|
||||
// RPWindowLayout_Register.
|
||||
if (ownWindow)
|
||||
{
|
||||
RPWindowLayout_Register(window, paneTitle, False);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -241,6 +328,9 @@ MFDSplitView::~MFDSplitView()
|
||||
{
|
||||
Check_Pointer(this);
|
||||
|
||||
// out of the layout registry before the window goes
|
||||
RPWindowLayout_Forget(window);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
SetWindowLongPtrA((HWND) window, GWLP_USERDATA, 0);
|
||||
@@ -259,6 +349,272 @@ Logical
|
||||
return pixels != NULL;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Join the saved layout. Registering twice just refreshes the entry, so
|
||||
// a window re-registering after being rebuilt is harmless.
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
RPWindowLayout_Register(void *window, const char *title, Logical with_size)
|
||||
{
|
||||
if (window == NULL || title == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < layoutWindowCount; ++i)
|
||||
{
|
||||
if (layoutWindows[i].window == window)
|
||||
{
|
||||
layoutWindows[i].title = title;
|
||||
layoutWindows[i].withSize = with_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (layoutWindowCount >= maxLayoutWindows)
|
||||
{
|
||||
return;
|
||||
}
|
||||
layoutWindows[layoutWindowCount].window = window;
|
||||
layoutWindows[layoutWindowCount].title = title;
|
||||
layoutWindows[layoutWindowCount].withSize = with_size;
|
||||
layoutWindows[layoutWindowCount].bare = False;
|
||||
++layoutWindowCount;
|
||||
}
|
||||
|
||||
void
|
||||
RPWindowLayout_Forget(void *window)
|
||||
{
|
||||
for (int i = 0; i < layoutWindowCount; ++i)
|
||||
{
|
||||
if (layoutWindows[i].window == window)
|
||||
{
|
||||
layoutWindows[i] = layoutWindows[--layoutWindowCount];
|
||||
layoutWindows[layoutWindowCount].window = NULL;
|
||||
layoutWindows[layoutWindowCount].title = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Sticky placement: restore the saved placement over the computed one.
|
||||
//
|
||||
// Called once everything has been built and placed, so a window the file
|
||||
// does not mention simply keeps where it was put. Size comes back only
|
||||
// for windows registered with it - see the header.
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
RPWindowLayout_Load()
|
||||
{
|
||||
if (LayoutMode() == LayoutOff || layoutWindowCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *file = fopen(layoutFileName, "rt");
|
||||
if (file == NULL)
|
||||
{
|
||||
DEBUG_STREAM << "MFDLayout: no " << layoutFileName
|
||||
<< " yet (using the computed arrangement)\n" << std::flush;
|
||||
return;
|
||||
}
|
||||
|
||||
int restored = 0;
|
||||
char line[256];
|
||||
while (fgets(line, sizeof(line), file) != NULL)
|
||||
{
|
||||
char *cursor = line;
|
||||
while (*cursor == ' ' || *cursor == '\t')
|
||||
{
|
||||
++cursor;
|
||||
}
|
||||
if (*cursor == '#' || *cursor == '\r' || *cursor == '\n' || *cursor == '\0')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// titles carry no '=', so the first one splits the line
|
||||
char *equals = strchr(cursor, '=');
|
||||
if (equals == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*equals = '\0';
|
||||
char *end = equals;
|
||||
while (end > cursor && (end[-1] == ' ' || end[-1] == '\t'))
|
||||
{
|
||||
--end;
|
||||
}
|
||||
*end = '\0';
|
||||
|
||||
int x = 0, y = 0, w = 0, h = 0;
|
||||
if (sscanf(equals + 1, "%d,%d,%d,%d", &x, &y, &w, &h) < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Optional trailing keyword, "x,y,w,h,noframe". Searched for
|
||||
// rather than parsed in place so a hand-edited line survives a
|
||||
// stray space or a missing comma.
|
||||
//
|
||||
Logical bare = (strstr(equals + 1, "noframe") != NULL) ? True : False;
|
||||
|
||||
for (int i = 0; i < layoutWindowCount; ++i)
|
||||
{
|
||||
LayoutWindow &entry = layoutWindows[i];
|
||||
if (entry.title == NULL || strcmp(entry.title, cursor) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HWND target = (HWND) entry.window;
|
||||
if (target == NULL || !IsWindow(target))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// a saved size of nothing is a corrupt line, not an instruction
|
||||
Logical size_it = (entry.withSize && w > 0 && h > 0) ? True : False;
|
||||
|
||||
//
|
||||
// Saved coordinates belong to whatever monitors were plugged
|
||||
// in that day. If the placement lands on none of today's, drop
|
||||
// it and keep the computed one - restoring the game window
|
||||
// somewhere invisible would leave nothing to drag back.
|
||||
//
|
||||
RECT landing;
|
||||
landing.left = x;
|
||||
landing.top = y;
|
||||
if (size_it)
|
||||
{
|
||||
landing.right = x + w;
|
||||
landing.bottom = y + h;
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT current;
|
||||
if (!GetWindowRect(target, ¤t))
|
||||
{
|
||||
break;
|
||||
}
|
||||
landing.right = x + (current.right - current.left);
|
||||
landing.bottom = y + (current.bottom - current.top);
|
||||
}
|
||||
if (MonitorFromRect(&landing, MONITOR_DEFAULTTONULL) == NULL)
|
||||
{
|
||||
DEBUG_STREAM << "MFDLayout: " << cursor << " was saved at "
|
||||
<< x << "," << y << " - off every monitor now, ignoring\n"
|
||||
<< std::flush;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Frame off, if the line asked. A bare window's rect IS its
|
||||
// client rect, so whatever client area it has now is the size
|
||||
// to hand back - which also makes the round trip stable: once
|
||||
// bare, what Save records is already the client.
|
||||
//
|
||||
entry.bare = bare;
|
||||
if (bare)
|
||||
{
|
||||
if (!size_it)
|
||||
{
|
||||
RECT client;
|
||||
if (GetClientRect(target, &client))
|
||||
{
|
||||
w = client.right;
|
||||
h = client.bottom;
|
||||
size_it = True;
|
||||
}
|
||||
}
|
||||
StripWindowFrame(target);
|
||||
}
|
||||
|
||||
SetWindowPos(target, NULL, x, y, w, h,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE |
|
||||
(size_it ? 0 : SWP_NOSIZE) | (bare ? SWP_FRAMECHANGED : 0));
|
||||
++restored;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
DEBUG_STREAM << "MFDLayout: restored " << restored << " window placement(s) from "
|
||||
<< layoutFileName << "\n" << std::flush;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Write where every registered window currently is. The whole file each
|
||||
// time - it is a handful of lines, and a rewrite leaves nothing
|
||||
// half-written for a hard kill to catch.
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
void
|
||||
RPWindowLayout_Save()
|
||||
{
|
||||
if (LayoutMode() != LayoutSave || layoutWindowCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FILE *file = fopen(layoutFileName, "wt");
|
||||
if (file == NULL)
|
||||
{
|
||||
DEBUG_STREAM << "MFDLayout: could not write " << layoutFileName
|
||||
<< "\n" << std::flush;
|
||||
return;
|
||||
}
|
||||
|
||||
fputs("# RP412 window placement. RP412MFDLAYOUT=save writes this on each\n"
|
||||
"# finished drag and on exit; =load restores it.\n"
|
||||
"# <title>=<x>,<y>,<w>,<h>. The game window gets its size back too;\n"
|
||||
"# for the display panes the size is reference only, since theirs\n"
|
||||
"# follows their content.\n"
|
||||
"# Append ,noframe to take that window's title bar and border off.\n"
|
||||
"# Put it where you want it first - a bare window has nothing to\n"
|
||||
"# drag by, so its line stops changing once the frame is gone.\n", file);
|
||||
|
||||
int wrote = 0;
|
||||
for (int i = 0; i < layoutWindowCount; ++i)
|
||||
{
|
||||
LayoutWindow &entry = layoutWindows[i];
|
||||
if (entry.title == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HWND entry_window = (HWND) entry.window;
|
||||
if (entry_window == NULL || !IsWindow(entry_window))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// rcNormalPosition rather than GetWindowRect: a minimised window
|
||||
// reports a nonsense rect and a maximised one reports the screen,
|
||||
// and neither is what to come back to. This is the restored
|
||||
// placement whatever state the window is in, so quitting from
|
||||
// maximised still records where the window will reappear.
|
||||
//
|
||||
WINDOWPLACEMENT placement;
|
||||
memset(&placement, 0, sizeof(placement));
|
||||
placement.length = sizeof(placement);
|
||||
if (!GetWindowPlacement(entry_window, &placement))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
RECT bounds = placement.rcNormalPosition;
|
||||
// the flag is the player's instruction, not something measured off
|
||||
// the window, so a rewrite has to carry it back out
|
||||
fprintf(file, "%s=%ld,%ld,%ld,%ld%s\n", entry.title,
|
||||
(long) bounds.left, (long) bounds.top,
|
||||
(long) (bounds.right - bounds.left),
|
||||
(long) (bounds.bottom - bounds.top),
|
||||
entry.bare ? ",noframe" : "");
|
||||
++wrote;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
DEBUG_STREAM << "MFDLayout: saved " << wrote << " window placement(s) to "
|
||||
<< layoutFileName << "\n" << std::flush;
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Compute the display rectangle and the button rectangles, growing the
|
||||
// client area to make room for the strips.
|
||||
|
||||
@@ -77,6 +77,14 @@ public:
|
||||
void
|
||||
Hide();
|
||||
|
||||
// caption and HWND, for the sticky-placement file
|
||||
const char *
|
||||
Title() const
|
||||
{ return paneTitle; }
|
||||
void *
|
||||
Window()
|
||||
{ return window; }
|
||||
|
||||
~MFDSplitView();
|
||||
|
||||
Logical
|
||||
@@ -147,4 +155,78 @@ protected:
|
||||
int
|
||||
buttonAnchorA,
|
||||
buttonAnchorB;
|
||||
|
||||
// the window caption, and the key this pane is saved under
|
||||
const char
|
||||
*paneTitle;
|
||||
// True for a pane of its own on the desktop (the exploded view); the
|
||||
// composited cockpit's panes are chrome-less children and cannot be
|
||||
// dragged, so there is nothing to remember for them.
|
||||
Logical
|
||||
ownWindow;
|
||||
};
|
||||
|
||||
//########################################################################
|
||||
// Sticky window placement.
|
||||
//
|
||||
// The game window and, in the exploded view, each display pane are all
|
||||
// draggable, but their placement is recomputed on every launch - so
|
||||
// putting a window somewhere useful never survived the menu-race-menu
|
||||
// loop. RP412MFDLAYOUT remembers it, in mfd_layout.cfg beside
|
||||
// bindings.txt:
|
||||
//
|
||||
// off / 0 / unset computed placement only, no file (default)
|
||||
// load / restore restore saved placement at startup, never write
|
||||
// save / adjust restore, then rewrite on each finished drag and
|
||||
// on teardown - the round trip
|
||||
//
|
||||
// One "<title>=x,y,w,h" line per window, plus an optional ",noframe"
|
||||
// that takes that window's title bar and border off - for a cockpit that
|
||||
// fills a monitor edge to edge without -fit's all-or-nothing, or an
|
||||
// exploded pane photographed without chrome. A bare window has nothing
|
||||
// to drag by, so place it first and add the flag after; Save carries the
|
||||
// flag back out, since it is an instruction rather than something
|
||||
// measured off the window. Windows are always built framed, so deleting
|
||||
// the flag is all it takes to get the frame back.
|
||||
//
|
||||
// Whether the size comes back depends on the window, which is why
|
||||
// Register takes it as a flag:
|
||||
//
|
||||
// display panes position only. A pane's size follows its content and
|
||||
// its button banks, so an old size from a different
|
||||
// build must not distort it.
|
||||
// the game window position and size. Nothing derives that size - -res
|
||||
// only decides how sharp the scene is, and the cockpit
|
||||
// fits itself to whatever client area it is given - so
|
||||
// a window sized to suit a monitor should come back
|
||||
// that way, and half-restoring it would be the strange
|
||||
// behaviour. RPL4.CPP registers it before the console
|
||||
// screen, so the saved placement is there from the
|
||||
// first frame rather than arriving when a race starts.
|
||||
//
|
||||
// A placement that lands on none of the monitors currently plugged in is
|
||||
// ignored rather than applied - restoring the game window off screen
|
||||
// would leave nothing to drag back.
|
||||
//
|
||||
// Lives here because the display panes were the first to need it; the
|
||||
// game window joined later rather than grow a second copy of the same
|
||||
// file format.
|
||||
//
|
||||
// Ported from BT411's BT_GLASS_LAYOUT.
|
||||
//########################################################################
|
||||
|
||||
// Take part in the saved layout. title is the key in the file and must
|
||||
// outlive the window (the callers pass string literals).
|
||||
void
|
||||
RPWindowLayout_Register(void *window, const char *title, Logical with_size);
|
||||
void
|
||||
RPWindowLayout_Forget(void *window);
|
||||
|
||||
// Apply the saved placement over the computed one. Call once everything
|
||||
// has been built and placed.
|
||||
void
|
||||
RPWindowLayout_Load();
|
||||
|
||||
// Write every registered window's placement. No-op unless mode is save.
|
||||
void
|
||||
RPWindowLayout_Save();
|
||||
|
||||
@@ -3839,6 +3839,11 @@ static LRESULT CALLBACK
|
||||
cockpit->LayoutCockpit(LOWORD(lParam), HIWORD(lParam));
|
||||
}
|
||||
}
|
||||
//
|
||||
// WM_EXITSIZEMOVE is not handled here: RPL4.CPP's own WndProc takes
|
||||
// it, and this chains straight through to that, so the shell saves on
|
||||
// every finished drag whether or not a cockpit has been built.
|
||||
//
|
||||
return CallWindowProcA(gCockpitBaseProc, hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
@@ -4457,6 +4462,15 @@ SVGA16::SVGA16(
|
||||
splitView[SplitMFDLowerRight]->SetPosition(
|
||||
work.left + right_x, work.top + bottom_y);
|
||||
splitView[SplitMap]->SetPosition(work.left + map_x, work.top + map_y);
|
||||
|
||||
//
|
||||
// ...and then let RP412MFDLAYOUT put everything back where it was
|
||||
// dragged to last time. Windows the file does not mention keep the
|
||||
// arrangement just computed above. The game window is registered
|
||||
// already - RPL4.CPP does that before the console screen ever
|
||||
// shows - so this picks it up alongside the panes.
|
||||
//
|
||||
RPWindowLayout_Load();
|
||||
}
|
||||
else if (splitViews)
|
||||
{
|
||||
@@ -4668,6 +4682,23 @@ SVGA16::SVGA16(
|
||||
// catch maximise / restore / drag-resize and re-fit
|
||||
gCockpitBaseProc = (WNDPROC) SetWindowLongPtrA(
|
||||
cockpit, GWLP_WNDPROC, (LONG_PTR) CockpitShellProc);
|
||||
|
||||
//
|
||||
// Sticky placement for the shell. Position AND size: nothing
|
||||
// derives that size here - -res only decides how sharp the
|
||||
// scene is - so a window sized to suit a monitor should come
|
||||
// back that way. RPL4.CPP registered it before the console
|
||||
// screen; this reload undoes the sizing just done above, and
|
||||
// runs after the subclass on purpose so its WM_SIZE puts
|
||||
// LayoutCockpit over the restored client area.
|
||||
//
|
||||
// -fit sits it borderless over the whole monitor, so there is
|
||||
// no placement of the player's to remember.
|
||||
//
|
||||
if (!fit_display)
|
||||
{
|
||||
RPWindowLayout_Load();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -4863,6 +4894,14 @@ SVGA16::~SVGA16()
|
||||
//---------------------------------------------------------
|
||||
//SVGASetSplitterClock(False);
|
||||
|
||||
//
|
||||
// Backstop for the sticky placement: every finished drag has already
|
||||
// been written, but a window moved and then closed straight away would
|
||||
// otherwise be missed. Must run before the panes go - it reads their
|
||||
// live window rects, and the game window's.
|
||||
//
|
||||
RPWindowLayout_Save();
|
||||
|
||||
for (int view = 0; view < SplitViewCount; ++view)
|
||||
{
|
||||
delete splitView[view];
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "rpl4lobby.h"
|
||||
#include "..\munga_l4\l4steamtransport.h"
|
||||
#include "..\munga_l4\l4splr.h"
|
||||
#include "..\munga_l4\l4mfdview.h" // RPWindowLayout_*
|
||||
#include "rpl4ver.h"
|
||||
#include "..\munga\resver.h"
|
||||
#include "..\munga\resource.h"
|
||||
@@ -123,6 +124,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_EXITSIZEMOVE:
|
||||
//
|
||||
// A drag or resize just finished. Here rather than in the
|
||||
// cockpit's subclass so it also covers the console screen, which
|
||||
// is where the window gets moved before there is any cockpit to
|
||||
// subclass. No-op unless RP412MFDLAYOUT is save.
|
||||
//
|
||||
RPWindowLayout_Save();
|
||||
return 0;
|
||||
}
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
@@ -254,6 +264,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
return FALSE;
|
||||
|
||||
ShowWindow(hWnd, nShowCmd);
|
||||
|
||||
//
|
||||
// Sticky placement, from the first frame the player sees. SVGA16 also
|
||||
// registers and reloads when it builds the cockpit, but that is not
|
||||
// until a mission starts - without this the console screen would come
|
||||
// up at the default rect with its title bar still on, and only jump
|
||||
// to the saved placement once a race began. -fit takes the whole
|
||||
// monitor and has no placement of the player's to restore.
|
||||
//
|
||||
if (!L4Application::GetFitDisplay() && !L4Application::GetFullscreen())
|
||||
{
|
||||
RPWindowLayout_Register(hWnd, "RPL4", True);
|
||||
RPWindowLayout_Load();
|
||||
}
|
||||
|
||||
#if !_DEBUG
|
||||
// Arcade pods have no mouse - but desktop/windowed play needs the
|
||||
// cursor for the on-screen cockpit buttons, so hide it only when
|
||||
@@ -475,6 +500,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Last word on the window's placement. Every finished drag has already
|
||||
// written it and SVGA16 writes again as the cockpit comes down, but a
|
||||
// session that never started a race has neither - and quitting from
|
||||
// the console screen is exactly how somebody would leave after moving
|
||||
// the window to where they want it. No-op unless the mode is save.
|
||||
//
|
||||
if (IsWindow(hWnd))
|
||||
{
|
||||
RPWindowLayout_Save();
|
||||
}
|
||||
RPWindowLayout_Forget(hWnd);
|
||||
|
||||
#if !_DEBUG
|
||||
// symmetric with the fullscreen-only hide at startup
|
||||
if (L4Application::GetFullscreen())
|
||||
|
||||
+61
-5
@@ -177,6 +177,7 @@ namespace
|
||||
GroupLaunch,
|
||||
GroupSteamHost, // buttons, not selections (Steam builds only)
|
||||
GroupSteamJoin,
|
||||
GroupExit,
|
||||
GroupCount
|
||||
};
|
||||
|
||||
@@ -413,8 +414,9 @@ namespace
|
||||
launch->rect.right = col3 + col_w;
|
||||
launch->rect.bottom = client_h - row_h;
|
||||
|
||||
// Steam lobby buttons (only when the Steam wire is live)
|
||||
if (RPL4Lobby_Available())
|
||||
// Steam lobby buttons, offered whenever environ.ini asked for Steam.
|
||||
// Painting greys them out and says so if the wire never came up.
|
||||
if (RPL4Lobby_Configured())
|
||||
{
|
||||
FEItem *host = &fe->items[fe->itemCount++];
|
||||
host->group = GroupSteamHost;
|
||||
@@ -433,6 +435,23 @@ namespace
|
||||
join->rect.bottom = client_h - (7 * row_h) / 2;
|
||||
}
|
||||
|
||||
//
|
||||
// Exit, bottom left. Diagonally opposite LAUNCH on purpose: it is
|
||||
// the one button on this screen you cannot undo, so it does not go
|
||||
// next to the one people are aiming for. Half width for the same
|
||||
// reason - it is a way out, not a peer of LAUNCH.
|
||||
//
|
||||
// The window frame used to be the way out, and mfd_layout.cfg's
|
||||
// ,noframe takes it away, so the screen has to offer its own.
|
||||
//
|
||||
FEItem *quit = &fe->items[fe->itemCount++];
|
||||
quit->group = GroupExit;
|
||||
quit->index = 0;
|
||||
quit->rect.left = col1;
|
||||
quit->rect.top = client_h - 2 * row_h;
|
||||
quit->rect.right = col1 + col_w / 2;
|
||||
quit->rect.bottom = client_h - row_h;
|
||||
|
||||
// pilot name edit sits at the top of column 3
|
||||
if (fe->nameEdit != NULL)
|
||||
{
|
||||
@@ -484,6 +503,7 @@ namespace
|
||||
case GroupLaunch: return "L A U N C H G A M E";
|
||||
case GroupSteamHost: return "HOST STEAM GAME";
|
||||
case GroupSteamJoin: return "JOIN STEAM GAME";
|
||||
case GroupExit: return "EXIT GAME";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -544,12 +564,38 @@ namespace
|
||||
RECT row = item->rect;
|
||||
if (item->group >= GroupLaunch)
|
||||
{
|
||||
HBRUSH launch_brush = CreateSolidBrush(kGreenBright);
|
||||
//
|
||||
// The lobby buttons are offered whenever environ.ini asked
|
||||
// for Steam, but they only work once the client is actually
|
||||
// there. Dim them and say why rather than leaving them out -
|
||||
// two buttons quietly missing looks like a broken build.
|
||||
//
|
||||
Logical steam_button =
|
||||
(item->group == GroupSteamHost || item->group == GroupSteamJoin);
|
||||
Logical dead = steam_button && !RPL4Lobby_Available();
|
||||
|
||||
COLORREF ink = dead ? kGreenDim : kGreenBright;
|
||||
HBRUSH launch_brush = CreateSolidBrush(ink);
|
||||
FrameRect(mem, &row, launch_brush);
|
||||
DeleteObject(launch_brush);
|
||||
SetTextColor(mem, kGreenBright);
|
||||
SetTextColor(mem, ink);
|
||||
DrawTextA(mem, ItemName(item->group, item->index), -1, &row,
|
||||
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
|
||||
//
|
||||
// The reason, on its own line above the pair. It does not
|
||||
// fit inside a button - they are about sixteen characters
|
||||
// wide and this is more than twice that.
|
||||
//
|
||||
if (dead && item->group == GroupSteamHost)
|
||||
{
|
||||
RECT notice = row;
|
||||
notice.bottom = row.top;
|
||||
notice.top = row.top - (row.bottom - row.top);
|
||||
SetTextColor(mem, kGreenDim);
|
||||
DrawTextA(mem, "STEAM NOT RUNNING", -1, ¬ice,
|
||||
DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -613,7 +659,17 @@ namespace
|
||||
}
|
||||
else if (item->group == GroupSteamHost || item->group == GroupSteamJoin)
|
||||
{
|
||||
fe->steamAction = (item->group == GroupSteamHost) ? 1 : 2;
|
||||
// dead until the Steam client is there; the button says so
|
||||
if (RPL4Lobby_Available())
|
||||
{
|
||||
fe->steamAction = (item->group == GroupSteamHost) ? 1 : 2;
|
||||
PostMessageA(fe->menuWindow, WM_NULL, 0, 0);
|
||||
}
|
||||
}
|
||||
else if (item->group == GroupExit)
|
||||
{
|
||||
// the same door closing the window goes through
|
||||
fe->closed = True;
|
||||
PostMessageA(fe->menuWindow, WM_NULL, 0, 0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
//########################################################################
|
||||
|
||||
Logical RPL4Lobby_Available() { return False; }
|
||||
Logical RPL4Lobby_Configured() { return False; }
|
||||
Logical RPL4Lobby_InRoom() { return False; }
|
||||
int RPL4Lobby_Host(HINSTANCE, HWND) { return LobbyRoomLeft; }
|
||||
int RPL4Lobby_Join(HINSTANCE, HWND) { return LobbyRoomLeft; }
|
||||
@@ -919,6 +920,18 @@ Logical
|
||||
return SteamNetTransport_GetFakeAddressString()[0] != '\0';
|
||||
}
|
||||
|
||||
//
|
||||
// The environ.ini switch, read the same way RPL4.CPP reads it to decide
|
||||
// whether to install the transport at all. Says nothing about whether the
|
||||
// Steam client was actually there.
|
||||
//
|
||||
Logical
|
||||
RPL4Lobby_Configured()
|
||||
{
|
||||
const char *steam_switch = getenv("RP412STEAM");
|
||||
return (steam_switch != NULL && atoi(steam_switch) != 0) ? True : False;
|
||||
}
|
||||
|
||||
Logical
|
||||
RPL4Lobby_InRoom()
|
||||
{
|
||||
|
||||
@@ -33,6 +33,15 @@ enum RPL4LobbyOutcome
|
||||
Logical
|
||||
RPL4Lobby_Available();
|
||||
|
||||
// True when this build has Steam and environ.ini asked for it, whether
|
||||
// or not it actually came up. The menu offers the lobby buttons on this
|
||||
// and greys them out on Available() - a player who turned Steam on and
|
||||
// then launched without the client running should be told so, not left
|
||||
// looking at a menu that quietly has two fewer buttons than the last
|
||||
// time they saw it.
|
||||
Logical
|
||||
RPL4Lobby_Configured();
|
||||
|
||||
// True while we sit in a lobby (races return to the room).
|
||||
Logical
|
||||
RPL4Lobby_InRoom();
|
||||
|
||||
@@ -166,6 +166,26 @@ L4PLASMA=SCREEN
|
||||
# 480x640 - decoded exactly as the pod's VDB split them, no downscale).
|
||||
L4MFDSPLIT=1
|
||||
|
||||
# The game window - and in the exploded view (L4MFDSPLIT=2) each display
|
||||
# window - is placed fresh every launch, so moving one somewhere useful
|
||||
# never survived the menu-race-menu loop. This remembers where you put
|
||||
# them, in mfd_layout.cfg beside this file:
|
||||
# off / 0 / unset computed placement only, no file (default)
|
||||
# load put the windows back where they were saved
|
||||
# save the same, and re-save on every finished drag
|
||||
# The game window gets its size back too, so you can size the cockpit to
|
||||
# suit your monitor once and keep it. The display windows get position
|
||||
# only: their size follows their content and their button banks, so an
|
||||
# old one is never restored over them. Arrange everything once with
|
||||
# save, then leave it on load.
|
||||
#
|
||||
# Each line in mfd_layout.cfg reads <title>=<x>,<y>,<w>,<h>, and you can
|
||||
# append ,noframe to take that window's title bar and border off - a
|
||||
# cockpit that fills the monitor edge to edge without -fit taking the
|
||||
# whole screen. Put the window where you want it first: a bare window
|
||||
# has nothing to drag by. Delete the flag to get the frame back.
|
||||
#RP412MFDLAYOUT=off
|
||||
|
||||
# Size of the six secondary displays in the glass cockpit, as a
|
||||
# percentage of their pod size. The pod bolted them down at one size;
|
||||
# on a big panel there is room to trade viewscreen for instrument, so
|
||||
|
||||
Reference in New Issue
Block a user