mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-23 09:20:19 +01:00
Compare commits
No commits in common. "3c6e1c9d47445d0f27cf2044dd02b095b5bbba5d" and "4ec30cf4726ae6c75fbffdaa5464c40209e96a31" have entirely different histories.
3c6e1c9d47
...
4ec30cf472
7 changed files with 20 additions and 88 deletions
|
@ -1,7 +1,6 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "DebugOverlay.h"
|
#include "DebugOverlay.h"
|
||||||
|
|
||||||
#include "loader.h"
|
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
#include "proj.h"
|
#include "proj.h"
|
||||||
#include "winmain.h"
|
#include "winmain.h"
|
||||||
|
@ -119,10 +118,6 @@ void DebugOverlay::DrawOverlay()
|
||||||
if (options::Options.DebugOverlaySounds)
|
if (options::Options.DebugOverlaySounds)
|
||||||
DrawSoundPositions();
|
DrawSoundPositions();
|
||||||
|
|
||||||
// Draw ball depth cutoff steps that determine sprite size.
|
|
||||||
if (options::Options.DebugOverlayBallDepthGrid)
|
|
||||||
DrawBallDepthSteps();
|
|
||||||
|
|
||||||
// Restore render target
|
// Restore render target
|
||||||
SDL_SetRenderTarget(winmain::Renderer, initialRenderTarget);
|
SDL_SetRenderTarget(winmain::Renderer, initialRenderTarget);
|
||||||
SDL_SetRenderDrawColor(winmain::Renderer,
|
SDL_SetRenderDrawColor(winmain::Renderer,
|
||||||
|
@ -248,29 +243,6 @@ void DebugOverlay::DrawSoundPositions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugOverlay::DrawBallDepthSteps()
|
|
||||||
{
|
|
||||||
auto& edgeMan = *TTableLayer::edge_manager;
|
|
||||||
SDL_SetRenderDrawColor(winmain::Renderer, 200, 100, 0, 255);
|
|
||||||
|
|
||||||
for (auto ball : pb::MainTable->BallList)
|
|
||||||
{
|
|
||||||
auto visualCount = loader::query_visual_states(ball->GroupIndex);
|
|
||||||
for (auto index = 0; index < visualCount; ++index)
|
|
||||||
{
|
|
||||||
auto depthPt = reinterpret_cast<vector3*>(loader::query_float_attribute(ball->GroupIndex, index, 501));
|
|
||||||
auto pt = proj::xform_to_2d(*depthPt);
|
|
||||||
|
|
||||||
// Snap X coordinate to edge box sides
|
|
||||||
auto x1 = proj::xform_to_2d(vector2{edgeMan.MinX, depthPt->Y}).X;
|
|
||||||
auto x2 = proj::xform_to_2d(vector2{edgeMan.MaxBoxX * edgeMan.AdvanceX + edgeMan.MinX, depthPt->Y}).X;
|
|
||||||
auto ff = proj::xform_to_2d(vector2{ edgeMan.MaxBoxX * edgeMan.AdvanceX + edgeMan.MinX, depthPt->Y });
|
|
||||||
SDL_RenderDrawLine(winmain::Renderer, x1, pt.Y, x2, pt.Y);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugOverlay::DrawCicleType(circle_type& circle)
|
void DebugOverlay::DrawCicleType(circle_type& circle)
|
||||||
{
|
{
|
||||||
vector2 linePt{ circle.Center.X + sqrt(circle.RadiusSq), circle.Center.Y };
|
vector2 linePt{ circle.Center.X + sqrt(circle.RadiusSq), circle.Center.Y };
|
||||||
|
|
|
@ -21,5 +21,4 @@ private:
|
||||||
static void DrawBallInfo();
|
static void DrawBallInfo();
|
||||||
static void DrawAllSprites();
|
static void DrawAllSprites();
|
||||||
static void DrawSoundPositions();
|
static void DrawSoundPositions();
|
||||||
static void DrawBallDepthSteps();
|
|
||||||
};
|
};
|
|
@ -54,7 +54,6 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
|
||||||
RenderSprite = new render_sprite(VisualTypes::Ball, nullptr, nullptr, 0, 0, nullptr);
|
RenderSprite = new render_sprite(VisualTypes::Ball, nullptr, nullptr, 0, 0, nullptr);
|
||||||
PinballTable->CollisionCompOffset = Offset;
|
PinballTable->CollisionCompOffset = Offset;
|
||||||
Position.Z = Offset;
|
Position.Z = Offset;
|
||||||
GroupIndex = groupIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TBall::Repaint()
|
void TBall::Repaint()
|
||||||
|
|
|
@ -117,7 +117,6 @@ void options::InitPrimary()
|
||||||
Options.DebugOverlaySounds = get_int("Debug Overlay Sounds", true);
|
Options.DebugOverlaySounds = get_int("Debug Overlay Sounds", true);
|
||||||
translations::SetCurrentLanguage(get_string("Language", translations::GetCurrentLanguage()->ShortName).c_str());
|
translations::SetCurrentLanguage(get_string("Language", translations::GetCurrentLanguage()->ShortName).c_str());
|
||||||
Options.FontFileName = get_string("FontFileName", "");
|
Options.FontFileName = get_string("FontFileName", "");
|
||||||
Options.DebugOverlayBallDepthGrid = get_int("Debug Overlay Ball Depth Grid", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void options::InitSecondary()
|
void options::InitSecondary()
|
||||||
|
@ -168,7 +167,6 @@ void options::uninit()
|
||||||
set_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
|
set_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
|
||||||
set_string("Language", translations::GetCurrentLanguage()->ShortName);
|
set_string("Language", translations::GetCurrentLanguage()->ShortName);
|
||||||
set_string("FontFileName", Options.FontFileName.c_str());
|
set_string("FontFileName", Options.FontFileName.c_str());
|
||||||
set_int("Debug Overlay Ball Depth Grid", Options.DebugOverlayBallDepthGrid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@ struct optionsStruct
|
||||||
bool DebugOverlayCollisionMask;
|
bool DebugOverlayCollisionMask;
|
||||||
bool DebugOverlaySprites;
|
bool DebugOverlaySprites;
|
||||||
bool DebugOverlaySounds;
|
bool DebugOverlaySounds;
|
||||||
bool DebugOverlayBallDepthGrid;
|
|
||||||
std::string FontFileName;
|
std::string FontFileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ bool winmain::LaunchBallEnabled = true;
|
||||||
bool winmain::HighScoresEnabled = true;
|
bool winmain::HighScoresEnabled = true;
|
||||||
bool winmain::DemoActive = false;
|
bool winmain::DemoActive = false;
|
||||||
int winmain::MainMenuHeight = 0;
|
int winmain::MainMenuHeight = 0;
|
||||||
std::string winmain::FpsDetails, winmain::PrevSdlError;
|
std::string winmain::FpsDetails;
|
||||||
unsigned winmain::PrevSdlErrorCount = 0;
|
|
||||||
double winmain::UpdateToFrameRatio;
|
double winmain::UpdateToFrameRatio;
|
||||||
winmain::DurationMs winmain::TargetFrameTime;
|
winmain::DurationMs winmain::TargetFrameTime;
|
||||||
optionsStruct& winmain::Options = options::Options;
|
optionsStruct& winmain::Options = options::Options;
|
||||||
|
@ -116,7 +115,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
// First step: just load the options
|
// First step: just load the options
|
||||||
options::InitPrimary();
|
options::InitPrimary();
|
||||||
|
|
||||||
if (!Options.FontFileName.empty())
|
if(!Options.FontFileName.empty())
|
||||||
{
|
{
|
||||||
ImGuiSDL::Deinitialize();
|
ImGuiSDL::Deinitialize();
|
||||||
io.Fonts->Clear();
|
io.Fonts->Clear();
|
||||||
|
@ -254,8 +253,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
if (xMod != 0 || yMod != 0)
|
if (xMod != 0 || yMod != 0)
|
||||||
{
|
{
|
||||||
// Mouse warp does not work over remote desktop or in some VMs
|
// Mouse warp does not work over remote desktop or in some VMs
|
||||||
x = abs(x - xMod);
|
x = abs(x - xMod); y = abs(y - yMod);
|
||||||
y = abs(y - yMod);
|
|
||||||
SDL_WarpMouseInWindow(window, x, y);
|
SDL_WarpMouseInWindow(window, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,28 +310,10 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sdlError = SDL_GetError();
|
auto sdlError = SDL_GetError();
|
||||||
if (sdlError[0] || !PrevSdlError.empty())
|
if (sdlError[0])
|
||||||
{
|
{
|
||||||
if (sdlError[0])
|
SDL_ClearError();
|
||||||
SDL_ClearError();
|
printf("SDL Error: %s\n", sdlError);
|
||||||
|
|
||||||
// Rate limit duplicate SDL error messages.
|
|
||||||
if (sdlError != PrevSdlError)
|
|
||||||
{
|
|
||||||
PrevSdlError = sdlError;
|
|
||||||
if (PrevSdlErrorCount > 0)
|
|
||||||
{
|
|
||||||
printf("SDL Error: ^ Previous Error Repeated %u Times\n", PrevSdlErrorCount + 1);
|
|
||||||
PrevSdlErrorCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sdlError[0])
|
|
||||||
printf("SDL Error: %s\n", sdlError);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PrevSdlErrorCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto updateEnd = Clock::now();
|
auto updateEnd = Clock::now();
|
||||||
|
@ -354,19 +334,13 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit duration to 2 * target time
|
// Limit duration to 2 * target time
|
||||||
sleepRemainder = Clamp(DurationMs(frameEnd - updateEnd) - targetTimeDelta, -TargetFrameTime,
|
sleepRemainder = Clamp(DurationMs(frameEnd - updateEnd) - targetTimeDelta, -TargetFrameTime, TargetFrameTime);
|
||||||
TargetFrameTime);
|
|
||||||
frameDuration = std::min<DurationMs>(DurationMs(frameEnd - frameStart), 2 * TargetFrameTime);
|
frameDuration = std::min<DurationMs>(DurationMs(frameEnd - frameStart), 2 * TargetFrameTime);
|
||||||
frameStart = frameEnd;
|
frameStart = frameEnd;
|
||||||
UpdateToFrameCounter++;
|
UpdateToFrameCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrevSdlErrorCount > 0)
|
|
||||||
{
|
|
||||||
printf("SDL Error: ^ Previous Error Repeated %u Times\n", PrevSdlErrorCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_free(basePath);
|
SDL_free(basePath);
|
||||||
SDL_free(prefPath);
|
SDL_free(prefPath);
|
||||||
delete gfr_display;
|
delete gfr_display;
|
||||||
|
@ -507,7 +481,7 @@ void winmain::RenderUi()
|
||||||
if (ImGui::BeginMenu("Language"))
|
if (ImGui::BeginMenu("Language"))
|
||||||
{
|
{
|
||||||
auto currentLanguage = translations::GetCurrentLanguage();
|
auto currentLanguage = translations::GetCurrentLanguage();
|
||||||
for (auto& item : translations::Languages)
|
for (auto &item : translations::Languages)
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem(item.DisplayName, nullptr, currentLanguage->Language == item.Language))
|
if (ImGui::MenuItem(item.DisplayName, nullptr, currentLanguage->Language == item.Language))
|
||||||
{
|
{
|
||||||
|
@ -530,15 +504,14 @@ void winmain::RenderUi()
|
||||||
options::toggle(Menu1::SoundStereo);
|
options::toggle(Menu1::SoundStereo);
|
||||||
}
|
}
|
||||||
ImGui::TextUnformatted("Sound Volume");
|
ImGui::TextUnformatted("Sound Volume");
|
||||||
if (ImGui::SliderInt("##Sound Volume", &Options.SoundVolume, options::MinVolume, options::MaxVolume,
|
if (ImGui::SliderInt("##Sound Volume", &Options.SoundVolume, options::MinVolume, options::MaxVolume, "%d",
|
||||||
"%d",
|
ImGuiSliderFlags_AlwaysClamp))
|
||||||
ImGuiSliderFlags_AlwaysClamp))
|
|
||||||
{
|
{
|
||||||
Sound::SetVolume(Options.SoundVolume);
|
Sound::SetVolume(Options.SoundVolume);
|
||||||
}
|
}
|
||||||
ImGui::TextUnformatted("Sound Channels");
|
ImGui::TextUnformatted("Sound Channels");
|
||||||
if (ImGui::SliderInt("##Sound Channels", &Options.SoundChannels, options::MinSoundChannels,
|
if (ImGui::SliderInt("##Sound Channels", &Options.SoundChannels, options::MinSoundChannels,
|
||||||
options::MaxSoundChannels, "%d", ImGuiSliderFlags_AlwaysClamp))
|
options::MaxSoundChannels, "%d", ImGuiSliderFlags_AlwaysClamp))
|
||||||
{
|
{
|
||||||
Sound::SetChannels(Options.SoundChannels);
|
Sound::SetChannels(Options.SoundChannels);
|
||||||
}
|
}
|
||||||
|
@ -549,9 +522,8 @@ void winmain::RenderUi()
|
||||||
options::toggle(Menu1::Music);
|
options::toggle(Menu1::Music);
|
||||||
}
|
}
|
||||||
ImGui::TextUnformatted("Music Volume");
|
ImGui::TextUnformatted("Music Volume");
|
||||||
if (ImGui::SliderInt("##Music Volume", &Options.MusicVolume, options::MinVolume, options::MaxVolume,
|
if (ImGui::SliderInt("##Music Volume", &Options.MusicVolume, options::MinVolume, options::MaxVolume, "%d",
|
||||||
"%d",
|
ImGuiSliderFlags_AlwaysClamp))
|
||||||
ImGuiSliderFlags_AlwaysClamp))
|
|
||||||
{
|
{
|
||||||
midi::SetVolume(Options.MusicVolume);
|
midi::SetVolume(Options.MusicVolume);
|
||||||
}
|
}
|
||||||
|
@ -625,14 +597,10 @@ void winmain::RenderUi()
|
||||||
char buffer[20]{};
|
char buffer[20]{};
|
||||||
Msg resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
Msg resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
||||||
|
|
||||||
switch (fullscrn::GetMaxResolution())
|
switch(fullscrn::GetMaxResolution()) {
|
||||||
{
|
case 0: resolutionStringId = Msg::Menu1_UseMaxResolution_640x480; break;
|
||||||
case 0: resolutionStringId = Msg::Menu1_UseMaxResolution_640x480;
|
case 1: resolutionStringId = Msg::Menu1_UseMaxResolution_800x600; break;
|
||||||
break;
|
case 2: resolutionStringId = Msg::Menu1_UseMaxResolution_1024x768; break;
|
||||||
case 1: resolutionStringId = Msg::Menu1_UseMaxResolution_800x600;
|
|
||||||
break;
|
|
||||||
case 2: resolutionStringId = Msg::Menu1_UseMaxResolution_1024x768;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto maxResText = pb::get_rc_string(resolutionStringId);
|
auto maxResText = pb::get_rc_string(resolutionStringId);
|
||||||
|
@ -689,8 +657,6 @@ void winmain::RenderUi()
|
||||||
{
|
{
|
||||||
if (ImGui::MenuItem("Box Grid", nullptr, Options.DebugOverlayGrid))
|
if (ImGui::MenuItem("Box Grid", nullptr, Options.DebugOverlayGrid))
|
||||||
Options.DebugOverlayGrid ^= true;
|
Options.DebugOverlayGrid ^= true;
|
||||||
if (ImGui::MenuItem("Ball Depth Grid", nullptr, Options.DebugOverlayBallDepthGrid))
|
|
||||||
Options.DebugOverlayBallDepthGrid ^= true;
|
|
||||||
if (ImGui::MenuItem("Sprite Positions", nullptr, Options.DebugOverlaySprites))
|
if (ImGui::MenuItem("Sprite Positions", nullptr, Options.DebugOverlaySprites))
|
||||||
Options.DebugOverlaySprites ^= true;
|
Options.DebugOverlaySprites ^= true;
|
||||||
if (ImGui::MenuItem("All Edges", nullptr, Options.DebugOverlayAllEdges))
|
if (ImGui::MenuItem("All Edges", nullptr, Options.DebugOverlayAllEdges))
|
||||||
|
|
|
@ -90,7 +90,7 @@ private:
|
||||||
static int mouse_down, last_mouse_x, last_mouse_y;
|
static int mouse_down, last_mouse_x, last_mouse_y;
|
||||||
static bool no_time_loss, activated, bQuit, has_focus, DispGRhistory;
|
static bool no_time_loss, activated, bQuit, has_focus, DispGRhistory;
|
||||||
static gdrv_bitmap8* gfr_display;
|
static gdrv_bitmap8* gfr_display;
|
||||||
static std::string FpsDetails, PrevSdlError;
|
static std::string FpsDetails;
|
||||||
static bool restart;
|
static bool restart;
|
||||||
static bool ShowAboutDialog;
|
static bool ShowAboutDialog;
|
||||||
static bool ShowImGuiDemo;
|
static bool ShowImGuiDemo;
|
||||||
|
@ -100,7 +100,6 @@ private:
|
||||||
static struct optionsStruct& Options;
|
static struct optionsStruct& Options;
|
||||||
static DurationMs SpinThreshold;
|
static DurationMs SpinThreshold;
|
||||||
static WelfordState SleepState;
|
static WelfordState SleepState;
|
||||||
static unsigned PrevSdlErrorCount;
|
|
||||||
|
|
||||||
static void RenderUi();
|
static void RenderUi();
|
||||||
static void RenderFrameTimeDialog();
|
static void RenderFrameTimeDialog();
|
||||||
|
|
Loading…
Reference in a new issue