mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-24 23:32:06 +00:00
LaunchAPPLServer: optional embedded debug console
This commit is contained in:
parent
71660defd6
commit
360c364bf9
@ -25,10 +25,17 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
option(LAUNCHAPPLSERVER_DEBUG_CONSOLE "Add a debug console to LaunchAPPLServer" FALSE)
|
||||
|
||||
set(MAYBE_CONSOLE)
|
||||
if(LAUNCHAPPLSERVER_DEBUG_CONSOLE)
|
||||
set(MAYBE_CONSOLE "CONSOLE")
|
||||
endif()
|
||||
|
||||
add_application(LaunchAPPLServer
|
||||
TYPE "APPL"
|
||||
CREATOR "R68L"
|
||||
${MAYBE_CONSOLE}
|
||||
|
||||
LaunchAPPLServer.r
|
||||
LauncherIcon.r
|
||||
@ -46,6 +53,9 @@ add_application(LaunchAPPLServer
|
||||
|
||||
${CONNECTION_SOURCES}
|
||||
)
|
||||
if(LAUNCHAPPLSERVER_DEBUG_CONSOLE)
|
||||
target_compile_definitions(LaunchAPPLServer PRIVATE DEBUG_CONSOLE)
|
||||
endif()
|
||||
|
||||
target_link_libraries(LaunchAPPLServer LaunchAPPLCommon)
|
||||
set_target_properties(LaunchAPPLServer PROPERTIES
|
||||
|
@ -300,6 +300,9 @@ public:
|
||||
|
||||
size_t onReceive(const uint8_t* p, size_t n)
|
||||
{
|
||||
#ifdef DEBUG_CONSOLE
|
||||
printf("Received %d bytes in state %d.\n", (int)n, (int)state);
|
||||
#endif
|
||||
switch(state)
|
||||
{
|
||||
case State::command:
|
||||
@ -309,6 +312,7 @@ public:
|
||||
command = (RemoteCommand)p[0];
|
||||
if(command == RemoteCommand::launchApp || command == RemoteCommand::upgradeLauncher)
|
||||
state = State::header;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -458,6 +462,9 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_CONSOLE
|
||||
printf("Failed to Launch.\n");
|
||||
#endif
|
||||
connection->resume();
|
||||
onReset();
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ resource 'WIND' (128, "About") {
|
||||
|
||||
resource 'WIND' (129, "Main") {
|
||||
{50, 10, 200, 400}, noGrowDocProc;
|
||||
visible;
|
||||
invisible;
|
||||
noGoAway;
|
||||
0, "Retro68 Application Launching Server";
|
||||
centerMainScreen;
|
||||
|
@ -72,6 +72,22 @@ StatusDisplay::StatusDisplay()
|
||||
tableTop + (i/2+1) * tableLineHeight);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CONSOLE
|
||||
short consoleTop = tableTop + (nValues+1)/2 * tableLineHeight + 10;
|
||||
SetRect(&consoleRect, 10, consoleTop,
|
||||
bounds.right - 10, consoleTop + 150);
|
||||
#if TARGET_API_MAC_CARBON
|
||||
console = retro::Console(GetWindowPort(statusWindow), consoleRect);
|
||||
#else
|
||||
console = retro::Console(statusWindow, consoleRect);
|
||||
#endif
|
||||
retro::Console::currentInstance = &console;
|
||||
|
||||
bounds.bottom = consoleRect.bottom + 10;
|
||||
#else
|
||||
bounds.bottom = tableTop + (nValues+1)/2 * tableLineHeight + 10;
|
||||
#endif
|
||||
|
||||
RgnHandle tmp = NewRgn();
|
||||
background = NewRgn();
|
||||
RectRgn(background, &bounds);
|
||||
@ -82,6 +98,11 @@ StatusDisplay::StatusDisplay()
|
||||
RectRgn(tmp, &valueRects[i]);
|
||||
DiffRgn(background, tmp, background);
|
||||
}
|
||||
#ifdef DEBUG_CONSOLE
|
||||
RectRgn(tmp, &consoleRect);
|
||||
DiffRgn(background, tmp, background);
|
||||
#endif
|
||||
|
||||
DisposeRgn(tmp);
|
||||
|
||||
if(hasColorQD)
|
||||
@ -89,6 +110,9 @@ StatusDisplay::StatusDisplay()
|
||||
progressBg = GetPixPat(128);
|
||||
progressFg = GetPixPat(129);
|
||||
}
|
||||
|
||||
SizeWindow(statusWindow, bounds.right, bounds.bottom, false);
|
||||
ShowWindow(statusWindow);
|
||||
}
|
||||
|
||||
StatusDisplay::~StatusDisplay()
|
||||
@ -199,6 +223,21 @@ void StatusDisplay::Update()
|
||||
DrawValue(Stat::timeRemaining, timeRemaining);
|
||||
DrawValue(Stat::transmissionErrors, errorCount);
|
||||
|
||||
#ifdef DEBUG_CONSOLE
|
||||
Rect updateRect;
|
||||
#if TARGET_API_MAC_CARBON
|
||||
RgnHandle rgn = NewRgn();
|
||||
GetPortVisibleRegion(GetWindowPort(statusWindow), rgn);
|
||||
GetRegionBounds(rgn, &updateRect);
|
||||
DisposeRgn(rgn);
|
||||
#else
|
||||
updateRect = (*qd.thePort->visRgn)->rgnBBox; // Life was simple back then.
|
||||
#endif
|
||||
|
||||
console.Draw(updateRect);
|
||||
FrameRect(&consoleRect);
|
||||
#endif
|
||||
|
||||
EndUpdate(statusWindow);
|
||||
}
|
||||
|
||||
@ -244,6 +283,11 @@ void StatusDisplay::SetStatus(AppStatus stat)
|
||||
startTime = TickCount();
|
||||
GetIndString(statusString,128,(short)stat);
|
||||
Inval(statusRect);
|
||||
|
||||
#ifdef DEBUG_CONSOLE
|
||||
statusString[statusString[0]+1] = 0;
|
||||
printf("%s\n", (const char*)statusString+1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,9 @@
|
||||
#include <TextUtils.h>
|
||||
|
||||
#include "Window.h"
|
||||
#ifdef DEBUG_CONSOLE
|
||||
#include <retro/Console.h>
|
||||
#endif
|
||||
|
||||
enum class AppStatus
|
||||
{
|
||||
@ -39,6 +42,11 @@ class StatusDisplay : public Window
|
||||
|
||||
PixPatHandle progressBg, progressFg;
|
||||
|
||||
#ifdef DEBUG_CONSOLE
|
||||
Rect consoleRect;
|
||||
retro::Console console;
|
||||
#endif
|
||||
|
||||
enum class Stat : short;
|
||||
|
||||
void DrawValue(Stat stat, ConstStr255Param str);
|
||||
|
Loading…
Reference in New Issue
Block a user