mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-12 16:21:04 +02:00
106 lines
2.7 KiB
C++
106 lines
2.7 KiB
C++
/*
|
|
===========================================================================
|
|
|
|
IceTech GPL Source Code
|
|
Copyright (C) 2026 Justin Marshall
|
|
|
|
This file is part of the IceTech GPL Source Code.
|
|
|
|
===========================================================================
|
|
*/
|
|
|
|
#include "precompiled.h"
|
|
#pragma hdrstop
|
|
|
|
#include "Window.h"
|
|
#include "UserInterfaceLocal.h"
|
|
#include "MinigameWindow.h"
|
|
|
|
idMinigameWindow::idMinigameWindow( idUserInterfaceLocal *g ) : idWindow( g ) {
|
|
CommonInit();
|
|
}
|
|
|
|
idMinigameWindow::idMinigameWindow( idDeviceContext *d, idUserInterfaceLocal *g ) : idWindow( d, g ) {
|
|
CommonInit();
|
|
}
|
|
|
|
idMinigameWindow::~idMinigameWindow() {
|
|
instance.Shutdown();
|
|
}
|
|
|
|
void idMinigameWindow::CommonInit() {
|
|
minigameName = "";
|
|
imageName = "_minigame";
|
|
commandLine = "";
|
|
autoStart = true;
|
|
SetFlag( WIN_CANFOCUS | WIN_HOLDCAPTURE );
|
|
}
|
|
|
|
void idMinigameWindow::PostParse() {
|
|
idWindow::PostParse();
|
|
EnsureStarted();
|
|
}
|
|
|
|
void idMinigameWindow::EnsureStarted() {
|
|
if ( !autoStart || instance.IsStarted() || instance.HasFailed() || !minigameName.c_str()[0] ) {
|
|
return;
|
|
}
|
|
instance.Start( minigameName.c_str(), imageName.c_str(), commandLine.c_str() );
|
|
}
|
|
|
|
void idMinigameWindow::DrawBackground( const idRectangle &drawRect ) {
|
|
EnsureStarted();
|
|
instance.SetActive( true );
|
|
instance.UploadFramebuffer();
|
|
idWindow::DrawBackground( drawRect );
|
|
}
|
|
|
|
const char *idMinigameWindow::HandleEvent( const sysEvent_t *event, bool *updateVisuals ) {
|
|
EnsureStarted();
|
|
if ( instance.IsStarted() ) {
|
|
instance.SetActive( true );
|
|
instance.QueueEvent( event, gui->GetTime() );
|
|
if ( updateVisuals ) {
|
|
*updateVisuals = true;
|
|
}
|
|
return "";
|
|
}
|
|
return idWindow::HandleEvent( event, updateVisuals );
|
|
}
|
|
|
|
const char *idMinigameWindow::RouteMouseCoords( float xd, float yd ) {
|
|
EnsureStarted();
|
|
if ( instance.IsStarted() ) {
|
|
instance.SetActive( true );
|
|
sysEvent_t event = sys->GenerateMouseMoveEvent( idMath::Ftoi( xd ), idMath::Ftoi( yd ) );
|
|
instance.QueueEvent( &event, gui->GetTime() );
|
|
return "";
|
|
}
|
|
return idWindow::RouteMouseCoords( xd, yd );
|
|
}
|
|
|
|
bool idMinigameWindow::ParseInternalVar( const char *_name, idParser *src ) {
|
|
idStr parsedString;
|
|
|
|
if ( idStr::Icmp( _name, "minigame" ) == 0 || idStr::Icmp( _name, "module" ) == 0 ) {
|
|
ParseString( src, parsedString );
|
|
minigameName = parsedString;
|
|
return true;
|
|
}
|
|
if ( idStr::Icmp( _name, "image" ) == 0 ) {
|
|
ParseString( src, parsedString );
|
|
imageName = parsedString;
|
|
return true;
|
|
}
|
|
if ( idStr::Icmp( _name, "commandLine" ) == 0 ) {
|
|
ParseString( src, parsedString );
|
|
commandLine = parsedString;
|
|
return true;
|
|
}
|
|
if ( idStr::Icmp( _name, "autoStart" ) == 0 ) {
|
|
autoStart = src->ParseBool();
|
|
return true;
|
|
}
|
|
return idWindow::ParseInternalVar( _name, src );
|
|
}
|