TTextBoxMessage v1, ready.

TTextBox v1.
This commit is contained in:
oz 2020-12-03 17:47:36 +03:00
parent 9ffab95d8e
commit fe66d33768
22 changed files with 419 additions and 57 deletions

Binary file not shown.

View File

@ -18,14 +18,15 @@
int main() int main()
{ {
std::cout << "Hello World!\n";
{ {
// Testing with UI // Testing with UI
char cmdLine[1]{}; char cmdLine[1]{};
pb::init(); pb::init();
WinMain(pinball::hinst, 0, cmdLine, 10); WinMain(winmain::hinst, 0, cmdLine, 10);
return 0;
} }
std::cout << "Hello World!\n";
gdrv::init(0, 0); gdrv::init(0, 0);
auto dib = gdrv::DibCreate(8, 1, 1); auto dib = gdrv::DibCreate(8, 1, 1);
gdrv::DibSetUsage(dib, 0, 1); gdrv::DibSetUsage(dib, 0, 1);

View File

@ -206,6 +206,7 @@
<ClInclude Include="TSound.h" /> <ClInclude Include="TSound.h" />
<ClInclude Include="TTableLayer.h" /> <ClInclude Include="TTableLayer.h" />
<ClInclude Include="TTextBox.h" /> <ClInclude Include="TTextBox.h" />
<ClInclude Include="TTextBoxMessage.h" />
<ClInclude Include="TTimer.h" /> <ClInclude Include="TTimer.h" />
<ClInclude Include="TTripwire.h" /> <ClInclude Include="TTripwire.h" />
<ClInclude Include="TWall.h" /> <ClInclude Include="TWall.h" />
@ -271,6 +272,7 @@
<ClCompile Include="TSound.cpp" /> <ClCompile Include="TSound.cpp" />
<ClCompile Include="TTableLayer.cpp" /> <ClCompile Include="TTableLayer.cpp" />
<ClCompile Include="TTextBox.cpp" /> <ClCompile Include="TTextBox.cpp" />
<ClCompile Include="TTextBoxMessage.cpp" />
<ClCompile Include="TTimer.cpp" /> <ClCompile Include="TTimer.cpp" />
<ClCompile Include="TTripwire.cpp" /> <ClCompile Include="TTripwire.cpp" />
<ClCompile Include="TWall.cpp" /> <ClCompile Include="TWall.cpp" />

View File

@ -207,6 +207,9 @@
<ClInclude Include="nudge.h"> <ClInclude Include="nudge.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="TTextBoxMessage.h">
<Filter>Header Files\TPinballComponent</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="pch.cpp"> <ClCompile Include="pch.cpp">
@ -380,6 +383,9 @@
<ClCompile Include="nudge.cpp"> <ClCompile Include="nudge.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="TTextBoxMessage.cpp">
<Filter>Source Files\TPinballComponent</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Natvis Include="NatvisFile.natvis" /> <Natvis Include="NatvisFile.natvis" />

View File

@ -87,10 +87,10 @@ TPinballComponent::~TPinballComponent()
} }
int TPinballComponent::Message(int message1, float message2) int TPinballComponent::Message(int code, float value)
{ {
MessageField = message1; MessageField = code;
if (message1 == 1024) if (code == 1024)
MessageField = 0; MessageField = 0;
return 0; return 0;
} }
@ -108,3 +108,7 @@ int TPinballComponent::get_scoring(int score1)
{ {
return 0; return 0;
} }
void TPinballComponent::control_handler(int code, TPinballComponent* cmp)
{
}

View File

@ -9,10 +9,11 @@ class TPinballComponent
public: public:
TPinballComponent(TPinballTable* table, int groupIndex, bool loadVisuals); TPinballComponent(TPinballTable* table, int groupIndex, bool loadVisuals);
virtual ~TPinballComponent(); virtual ~TPinballComponent();
virtual int Message(int message1, float message2); virtual int Message(int code, float value);
virtual void port_draw(); virtual void port_draw();
virtual void put_scoring(int score1, int score2); virtual void put_scoring(int score1, int score2);
virtual int get_scoring(int score1); virtual int get_scoring(int score1);
static void control_handler(int code, TPinballComponent* cmp);
int VfTable; int VfTable;
__int8 UnknownBaseFlag1; __int8 UnknownBaseFlag1;

View File

@ -1,16 +1,231 @@
#include "pch.h" #include "pch.h"
#include "TTextBox.h" #include "TTextBox.h"
#include "loader.h"
#include "score.h"
#include "timer.h"
int TTextBox::Message(int a2, float a3) TTextBox::TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
{
OffsetX = 0;
OffsetY = 0;
Width = 0;
Height = 0;
BgBmp = render::background_bitmap;
Font = score::msg_fontp;
Message1 = nullptr;
Message2 = nullptr;
Timer = 0;
if (groupIndex > 0)
{
int arrLength;
auto dimensions = loader::query_iattribute(groupIndex, 1500, &arrLength);
OffsetX = dimensions[0];
OffsetY = dimensions[1];
Width = dimensions[2];
Height = dimensions[3];
}
}
TTextBox::~TTextBox()
{
if (Timer)
{
if (Timer != -1)
timer::kill(Timer);
Timer = 0;
}
while (Message1)
{
TTextBoxMessage* message = Message1;
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
Message1 = nextMessage;
}
}
int TTextBox::Message(int code, float value)
{ {
return 0; return 0;
} }
void TTextBox::TimerExpired(int a2, TTextBox* tb)
{
TTextBoxMessage* message = tb->Message1;
tb->Timer = 0;
if (message)
{
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
tb->Message1 = nextMessage;
tb->Draw();
control_handler(60, tb);
}
}
void TTextBox::Clear() void TTextBox::Clear()
{ {
gdrv_bitmap8* bmp = BgBmp;
if (bmp)
gdrv::copy_bitmap(
&render::vscreen,
Width,
Height,
OffsetX,
OffsetY,
bmp,
OffsetX,
OffsetY);
else
gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
gdrv::blit(
&render::vscreen,
OffsetX,
OffsetY,
OffsetX + render::vscreen.XPosition,
OffsetY + render::vscreen.YPosition,
Width,
Height);
if (Timer)
{
if (Timer != -1)
timer::kill(Timer);
Timer = 0;
}
while (Message1)
{
TTextBoxMessage* message = Message1;
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
Message1 = nextMessage;
}
} }
void TTextBox::Display(char* text, float time) void TTextBox::Display(char* text, float time)
{ {
if (!text)
return;
if (Message1 && !strcmp(text, Message2->Text))
{
Message2->Refresh(time);
if (Message2 == Message1)
{
if (Timer && Timer != -1)
timer::kill(Timer);
if (time == -1.0)
Timer = -1;
else
Timer = timer::set(time, (int)this, (int)TimerExpired);
}
}
else
{
if (Timer == -1)
Clear();
auto message = new TTextBoxMessage(text, time);
if (message)
{
if (message->Text)
{
if (Message1)
Message2->NextMessage = message;
else
Message1 = message;
Message2 = message;
if (Timer == 0)
Draw();
}
else
{
delete message;
}
}
}
}
void TTextBox::Draw()
{
TTextBoxMessage* nextMessage = nullptr;
auto this2 = this;
auto bmp = BgBmp;
if (bmp)
gdrv::copy_bitmap(
&render::vscreen,
Width,
Height,
OffsetX,
OffsetY,
bmp,
OffsetX,
OffsetY);
else
gdrv::fill_bitmap(&render::vscreen, Width, Height, OffsetX, OffsetY, 0);
while (this2->Message1)
{
auto message = this2->Message1;
if (message->Time == -1.0)
{
nextMessage = message->NextMessage;
if (!message->NextMessage)
{
this2->Timer = -1;
LABEL_18:
auto font = this2->Font;
if (!font)
{
gdrv::blit(
&render::vscreen,
this2->OffsetX,
this2->OffsetY,
this2->OffsetX + render::vscreen.XPosition,
this2->OffsetY + render::vscreen.YPosition,
this2->Width,
this2->Height);
gdrv::grtext_draw_ttext_in_box(
this2->Message1->Text,
render::vscreen.XPosition + this2->OffsetX,
render::vscreen.YPosition + this2->OffsetY,
this2->Width,
this2->Height,
255);
return;
}
}
}
else
{
auto timeLeft = (this2->Message1->TimeLeft());
if (timeLeft >= -2.0f)
{
int timer;
if (timeLeft >= 0.25f)
{
timer = timer::set(timeLeft, (int)this2, (int)TimerExpired);
}
else
{
timer = timer::set(0.25, (int)this2, (int)TimerExpired);
}
this2->Timer = timer;
goto LABEL_18;
}
nextMessage = message->NextMessage;
}
delete message;
this2->Message1 = nextMessage;
}
gdrv::blit(
&render::vscreen,
this2->OffsetX,
this2->OffsetY,
this2->OffsetX + render::vscreen.XPosition,
this2->OffsetY + render::vscreen.YPosition,
this2->Width,
this2->Height);
} }

View File

@ -1,15 +1,28 @@
#pragma once #pragma once
#include "score.h"
#include "TPinballComponent.h" #include "TPinballComponent.h"
#include "TTextBoxMessage.h"
class TTextBox : class TTextBox :
public TPinballComponent public TPinballComponent
{ {
public: public:
TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true) int OffsetX;
{ int OffsetY;
} int Width;
int Height;
int Timer;
gdrv_bitmap8* BgBmp;
score_msg_font_type* Font;
TTextBoxMessage* Message1;
TTextBoxMessage* Message2;
int Message(int a2, float a3) override; TTextBox(TPinballTable* table, int groupIndex);
~TTextBox() override;
int Message(int code, float value) override;
void Clear(); void Clear();
void Display(char* text, float time); void Display(char* text, float time);
void Draw();
static void TimerExpired(int a2, TTextBox* tb);
}; };

View File

@ -0,0 +1,37 @@
#include "pch.h"
#include "TTextBoxMessage.h"
#include "memory.h"
#include "pb.h"
TTextBoxMessage::TTextBoxMessage(char* text, float time)
{
NextMessage = nullptr;
Time = time;
EndTicks = pb::time_ticks + static_cast<int>(time * 1000.0f);
if (text)
{
const auto textLen = strlen(text) + 1;
Text = memory::allocate(textLen);
if (Text)
strcpy_s(Text, textLen, text);
}
else
Text = nullptr;
}
TTextBoxMessage::~TTextBoxMessage()
{
if (Text)
memory::free(Text);
}
float TTextBoxMessage::TimeLeft() const
{
return static_cast<float>(EndTicks - pb::time_ticks) * 0.001f;
}
void TTextBoxMessage::Refresh(float time)
{
this->Time = time;
this->EndTicks = pb::time_ticks + static_cast<int>(time * 1000.0f);
}

View File

@ -0,0 +1,14 @@
#pragma once
class TTextBoxMessage
{
public:
TTextBoxMessage* NextMessage;
char* Text;
float Time;
int EndTicks;
TTextBoxMessage(char* text, float time);
~TTextBoxMessage();
float TimeLeft() const;
void Refresh(float time);
};

View File

@ -1,6 +1,7 @@
#include "pch.h" #include "pch.h"
#include "gdrv.h" #include "gdrv.h"
#include "memory.h" #include "memory.h"
#include "pinball.h"
#include "winmain.h" #include "winmain.h"
HPALETTE gdrv::palette_handle = nullptr; HPALETTE gdrv::palette_handle = nullptr;
@ -10,6 +11,9 @@ LOGPALETTEx256 gdrv::current_palette{};
int gdrv::sequence_handle; int gdrv::sequence_handle;
HDC gdrv::sequence_hdc; HDC gdrv::sequence_hdc;
int gdrv::use_wing = 0; int gdrv::use_wing = 0;
int gdrv::grtext_blue = 0;
int gdrv::grtext_green = 0;
int gdrv::grtext_red = -1;
int gdrv::init(HINSTANCE hInst, HWND hWnd) int gdrv::init(HINSTANCE hInst, HWND hWnd)
@ -390,3 +394,30 @@ void gdrv::copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int heigh
dstPtr += dstBmp->Stride - width; dstPtr += dstBmp->Stride - width;
} }
} }
void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6)
{
tagRECT rc{};
HDC dc = GetDC(hwnd);
rc.left = xOff;
rc.right = width + xOff;
rc.top = yOff;
rc.bottom = height + yOff;
if (grtext_red < 0)
{
grtext_blue = 255;
grtext_green = 255;
grtext_red = 255;
const char* fontColor = pinball::get_rc_string(189, 0);
if (fontColor)
sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue);
}
int prevMode = SetBkMode(dc, 1);
COLORREF color = SetTextColor(dc, (grtext_red) | (grtext_green << 8) | (grtext_blue << 16));
DrawTextA(dc, text, lstrlenA(text), &rc, 0x810u);
SetBkMode(dc, prevMode);
SetTextColor(dc, color);
ReleaseDC(hwnd, dc);
}

View File

@ -42,8 +42,6 @@ class gdrv
{ {
public: public:
static HPALETTE palette_handle; static HPALETTE palette_handle;
static HINSTANCE hinst;
static HWND hwnd;
static LOGPALETTEx256 current_palette; static LOGPALETTEx256 current_palette;
static int sequence_handle; static int sequence_handle;
static HDC sequence_hdc; static HDC sequence_hdc;
@ -70,5 +68,11 @@ public:
int srcXOff, int srcYOff); int srcXOff, int srcYOff);
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff, static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff); gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
static void grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height, int a6);
private: private:
static HWND hwnd;
static HINSTANCE hinst;
static int grtext_blue;
static int grtext_green;
static int grtext_red;
}; };

View File

@ -6,6 +6,7 @@
#include "midi.h" #include "midi.h"
#include "pinball.h" #include "pinball.h"
#include "Sound.h" #include "Sound.h"
#include "winmain.h"
LPCSTR options::OptionsRegPath; LPCSTR options::OptionsRegPath;
LPSTR options::OptionsRegPathCur; LPSTR options::OptionsRegPathCur;
@ -68,7 +69,7 @@ void options::init(HMENU menuHandle)
if (MenuHandle) if (MenuHandle)
{ {
DeleteMenu(MenuHandle, 0x195u, 0); DeleteMenu(MenuHandle, 0x195u, 0);
DrawMenuBar(pinball::hwnd_frame); DrawMenuBar(winmain::hwnd_frame);
} }
} }
memory::free(tmpBuf); memory::free(tmpBuf);
@ -240,7 +241,7 @@ void options::toggle(UINT uIDCheckItem)
void options::keyboard() void options::keyboard()
{ {
DialogBoxParamA(pinball::hinst, "KEYMAPPER", pinball::hwnd_frame, KeyMapDlgProc, 0); DialogBoxParamA(winmain::hinst, "KEYMAPPER", winmain::hwnd_frame, KeyMapDlgProc, 0);
} }
INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) INT_PTR _stdcall options::KeyMapDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)

View File

@ -58,7 +58,7 @@ int pb::init()
} }
render::init(nullptr, zMin, zScaler, tableSize[0], tableSize[1]); render::init(nullptr, zMin, zScaler, tableSize[0], tableSize[1]);
gdrv::fill_bitmap(&render::vscreen, render::vscreen.Width, render::vscreen.Height, 0, 0, 0xff); // temp gdrv::fill_bitmap(&render::vscreen, render::vscreen.Width, render::vscreen.Height, 0, 0, (char)0xff); // temp
gdrv::copy_bitmap( gdrv::copy_bitmap(
&render::vscreen, &render::vscreen,
backgroundBmp->Width, backgroundBmp->Width,
@ -323,7 +323,7 @@ void pb::keydown(int key)
case 'M': case 'M':
char buffer[20]; char buffer[20];
sprintf_s(buffer, "%ld", memory::use_total); sprintf_s(buffer, "%ld", memory::use_total);
MessageBoxA(pinball::hwnd_frame, buffer, "Mem:", 0x2000u); MessageBoxA(winmain::hwnd_frame, buffer, "Mem:", 0x2000u);
break; break;
case 'R': case 'R':
cheat_bump_rank(); cheat_bump_rank();

View File

@ -1,6 +1,7 @@
#include "pch.h" #include "pch.h"
#include "pinball.h" #include "pinball.h"
#include "memory.h" #include "memory.h"
#include "winmain.h"
int pinball::quickFlag = 0; int pinball::quickFlag = 0;
@ -8,17 +9,14 @@ TTextBox* pinball::InfoTextBox;
TTextBox* pinball::MissTextBox; TTextBox* pinball::MissTextBox;
char pinball::getRcBuffer[6 * 256]; char pinball::getRcBuffer[6 * 256];
int pinball::rc_string_slot = 0; int pinball::rc_string_slot = 0;
HINSTANCE pinball::hinst;
char pinball::WindowName[2]{}; char pinball::WindowName[2]{};
int pinball::LeftShift = -1; int pinball::LeftShift = -1;
int pinball::RightShift = -1; int pinball::RightShift = -1;
HWND pinball::hwnd_frame = nullptr;
char* pinball::get_rc_string(int uID, int a2) char* pinball::get_rc_string(int uID, int a2)
{ {
char* result = &getRcBuffer[256 * rc_string_slot]; char* result = &getRcBuffer[256 * rc_string_slot];
if (!LoadStringA(hinst, uID, &getRcBuffer[256 * rc_string_slot], 255)) if (!LoadStringA(winmain::hinst, uID, &getRcBuffer[256 * rc_string_slot], 255))
*result = 0; *result = 0;
if (++rc_string_slot >= 6) if (++rc_string_slot >= 6)
rc_string_slot = 0; rc_string_slot = 0;
@ -28,7 +26,7 @@ char* pinball::get_rc_string(int uID, int a2)
int pinball::get_rc_int(int uID, int* dst) int pinball::get_rc_int(int uID, int* dst)
{ {
char buffer[50]; char buffer[50];
int result = LoadStringA(hinst, uID, buffer, 255); int result = LoadStringA(winmain::hinst, uID, buffer, 255);
if (!result) if (!result)
return result; return result;
*dst = atoi(buffer); *dst = atoi(buffer);

View File

@ -7,11 +7,9 @@ public:
static int quickFlag; static int quickFlag;
static TTextBox* InfoTextBox; static TTextBox* InfoTextBox;
static TTextBox* MissTextBox; static TTextBox* MissTextBox;
static HINSTANCE hinst;
static char WindowName[2]; static char WindowName[2];
static int RightShift; static int RightShift;
static int LeftShift; static int LeftShift;
static HWND hwnd_frame;
static char* get_rc_string(int uID, int a2); static char* get_rc_string(int uID, int a2);
static int get_rc_int(int uID, int* dst); static int get_rc_int(int uID, int* dst);

View File

@ -4,6 +4,7 @@
#include "memory.h" #include "memory.h"
#include "partman.h" #include "partman.h"
score_msg_font_type* score::msg_fontp;
int score::init() int score::init()
{ {

View File

@ -22,9 +22,15 @@ struct scoreStruct
char* Bitmap8Bit10; char* Bitmap8Bit10;
}; };
struct score_msg_font_type
{
};
class score class score
{ {
public: public:
static score_msg_font_type* msg_fontp;
static int init(); static int init();
static scoreStruct* create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp); static scoreStruct* create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp);
static scoreStruct* dup(scoreStruct* score, int scoreIndex); static scoreStruct* dup(scoreStruct* score, int scoreIndex);

View File

@ -36,3 +36,13 @@ int timer::init(int count)
timer_struct.buffer2 = buf; timer_struct.buffer2 = buf;
return 0; return 0;
} }
int timer::kill(int timer)
{
return 0;
}
int timer::set(float time, int caller, int callback)
{
return 0;
}

View File

@ -14,6 +14,8 @@ class timer
{ {
public: public:
static int init(int count); static int init(int count);
static int kill(int timer);
static int set(float time, int caller, int callback);
private: private:
static timer_struct timer_struct; static timer_struct timer_struct;

View File

@ -9,15 +9,30 @@
#include "pb.h" #include "pb.h"
#include "Sound.h" #include "Sound.h"
int winmain::return_value = 0, winmain::bQuit = 0, winmain::activated; HINSTANCE winmain::hinst = nullptr;
DWORD winmain::then, winmain::now; HWND winmain::hwnd_frame = nullptr;
UINT winmain::iFrostUniqueMsg;
gdrv_bitmap8 winmain::gfr_display{};
int winmain::DispFrameRate = 1, winmain::DispGRhistory = 1, winmain::single_step = 0;
int winmain::has_focus = 1, winmain::last_mouse_x, winmain::last_mouse_y, winmain::mouse_down, winmain::no_time_loss;
char winmain::DatFileName[300]{};
HCURSOR winmain::mouse_hsave; HCURSOR winmain::mouse_hsave;
int winmain::return_value = 0;
int winmain::bQuit = 0;
int winmain::activated;
int winmain::DispFrameRate = 1;
int winmain::DispGRhistory = 0;
int winmain::single_step = 0;
int winmain::has_focus = 1;
int winmain::last_mouse_x;
int winmain::last_mouse_y;
int winmain::mouse_down;
int winmain::no_time_loss;
DWORD winmain::then;
DWORD winmain::now;
UINT winmain::iFrostUniqueMsg;
gdrv_bitmap8 winmain::gfr_display{};
char winmain::DatFileName[300]{};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{ {
return winmain::WinMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd); return winmain::WinMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
@ -41,7 +56,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
} }
options::set_int(regSpaceCadet, "Table Version", 1u); options::set_int(regSpaceCadet, "Table Version", 1u);
GetModuleFileNameA(pinball::hinst, tmpBuf, 0x1F4u); GetModuleFileNameA(hinst, tmpBuf, 0x1F4u);
options::set_string(regSpaceCadet, "Table Exe", tmpBuf); options::set_string(regSpaceCadet, "Table Exe", tmpBuf);
options::set_string(regSpaceCadet, "Table Name", pinball::get_rc_string(169, 0)); options::set_string(regSpaceCadet, "Table Name", pinball::get_rc_string(169, 0));
options::set_string(nullptr, "Last Table Played", regSpaceCadet); options::set_string(nullptr, "Last Table Played", regSpaceCadet);
@ -92,7 +107,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
--memory::critical_allocation; --memory::critical_allocation;
pinball::quickFlag = strstr(lpCmdLine, "-quick") != nullptr; pinball::quickFlag = strstr(lpCmdLine, "-quick") != nullptr;
pinball::hinst = hInstance; hinst = hInstance;
options::get_string(regSpaceCadet, "Pinball Data", DatFileName, pinball::get_rc_string(168, 0), 300); options::get_string(regSpaceCadet, "Pinball Data", DatFileName, pinball::get_rc_string(168, 0), 300);
iFrostUniqueMsg = RegisterWindowMessageA("PinballThemeSwitcherUniqueMsgString"); iFrostUniqueMsg = RegisterWindowMessageA("PinballThemeSwitcherUniqueMsgString");
@ -132,7 +147,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
lstrcpyA(windowName, pinball::get_rc_string(38, 0)); lstrcpyA(windowName, pinball::get_rc_string(38, 0));
windowHandle = CreateWindowExA(0, windowClass, windowName, 0x3CA0000u, 0, 0, 640, 480, nullptr, nullptr, hInstance, windowHandle = CreateWindowExA(0, windowClass, windowName, 0x3CA0000u, 0, 0, 640, 480, nullptr, nullptr, hInstance,
nullptr); nullptr);
pinball::hwnd_frame = windowHandle; hwnd_frame = windowHandle;
if (!windowHandle) if (!windowHandle)
{ {
PostQuitMessage(0); PostQuitMessage(0);
@ -150,9 +165,9 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
options::menu_check(0x193u, 1); options::menu_check(0x193u, 1);
} }
ShowWindow(pinball::hwnd_frame, nShowCmd); ShowWindow(hwnd_frame, nShowCmd);
fullscrn::set_screen_mode(options::Options.FullScreen); fullscrn::set_screen_mode(options::Options.FullScreen);
UpdateWindow(pinball::hwnd_frame); UpdateWindow(hwnd_frame);
/*if (tmpBuf) //Close splash /*if (tmpBuf) //Close splash
{ {
@ -163,8 +178,8 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
pinball::adjust_priority(options::Options.PriorityAdj); pinball::adjust_priority(options::Options.PriorityAdj);
const auto startTime = timeGetTime(); const auto startTime = timeGetTime();
MSG wndMessage{}; MSG wndMessage{};
while (timeGetTime() >= startTime && timeGetTime() - startTime < 2000) while (timeGetTime() >= startTime && timeGetTime() - startTime < 0)// Don't wait for now, was 2000
PeekMessageA(&wndMessage, pinball::hwnd_frame, 0, 0, 1u); PeekMessageA(&wndMessage, hwnd_frame, 0, 0, 1u);
if (strstr(lpCmdLine, "-demo")) if (strstr(lpCmdLine, "-demo"))
pb::toggle_demo(); pb::toggle_demo();
@ -185,7 +200,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
{ {
char buf[60]; char buf[60];
sprintf_s(buf, "Frames/sec = %02.02f", 300.0f / (static_cast<float>(curTime - prevTime) * 0.001f)); sprintf_s(buf, "Frames/sec = %02.02f", 300.0f / (static_cast<float>(curTime - prevTime) * 0.001f));
SetWindowTextA(pinball::hwnd_frame, buf); SetWindowTextA(hwnd_frame, buf);
if (DispGRhistory) if (DispGRhistory)
{ {
@ -326,10 +341,10 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
pb::window_size(&width, &height); pb::window_size(&width, &height);
auto prevCursor = SetCursor(LoadCursorA(nullptr, (LPCSTR)IDC_WAIT)); auto prevCursor = SetCursor(LoadCursorA(nullptr, (LPCSTR)IDC_WAIT));
gdrv::init(pinball::hinst, hWnd); gdrv::init(hinst, hWnd);
auto voiceCount = options::get_int(nullptr, "Voices", 8); auto voiceCount = options::get_int(nullptr, "Voices", 8);
if (!Sound::Init(pinball::hinst, voiceCount, nullptr)) if (!Sound::Init(hinst, voiceCount, nullptr))
options::menu_set(0xC9u, 0); options::menu_set(0xC9u, 0);
Sound::Activate(); Sound::Activate();
@ -417,10 +432,10 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case VK_ESCAPE: case VK_ESCAPE:
if (options::Options.FullScreen) if (options::Options.FullScreen)
options::toggle(0x193u); options::toggle(0x193u);
SendMessageA(pinball::hwnd_frame, 0x112u, 0xF020u, 0); SendMessageA(hwnd_frame, 0x112u, 0xF020u, 0);
break; break;
case VK_F1: case VK_F1:
help_introduction(pinball::hinst, hWnd); help_introduction(hinst, hWnd);
break; break;
case VK_F2: case VK_F2:
new_game(); new_game();
@ -465,6 +480,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case SC_MOVE: case SC_MOVE:
if (fullscrn::screen_mode) if (fullscrn::screen_mode)
return 0; return 0;
break;
case SC_MINIMIZE: case SC_MINIMIZE:
if (!single_step) if (!single_step)
pause(); pause();
@ -513,20 +529,20 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
"%s %s%lX %s%lX", "%s %s%lX %s%lX",
tmpBuf, tmpBuf,
"select=", "select=",
(int)pinball::hwnd_frame, (int)hwnd_frame,
"confirm=", "confirm=",
(int)pinball::hwnd_frame (int)hwnd_frame
* (int)pinball::hwnd_frame * (int)hwnd_frame
* (int)pinball::hwnd_frame * (int)hwnd_frame
* (int)pinball::hwnd_frame * (int)hwnd_frame
* (int)pinball::hwnd_frame * (int)hwnd_frame
* (int)pinball::hwnd_frame * (int)hwnd_frame
* (int)pinball::hwnd_frame); * (int)hwnd_frame);
if (static_cast<int>(WinExec(cmdLine, 5u)) < 32) if (static_cast<int>(WinExec(cmdLine, 5u)) < 32)
{ {
auto caption = pinball::get_rc_string(170, 0); auto caption = pinball::get_rc_string(170, 0);
auto text = pinball::get_rc_string(171, 0); auto text = pinball::get_rc_string(171, 0);
MessageBoxA(pinball::hwnd_frame, text, caption, 0x2010u); MessageBoxA(hwnd_frame, text, caption, 0x2010u);
} }
memory::free(tmpBuf); memory::free(tmpBuf);
} }
@ -547,7 +563,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case 301: case 301:
if (!single_step) if (!single_step)
pause(); pause();
help_introduction(pinball::hinst, hWnd); help_introduction(hinst, hWnd);
return DefWindowProcA(hWnd, Msg, wParam, lParam); return DefWindowProcA(hWnd, Msg, wParam, lParam);
case 0x6A: case 0x6A:
pb::end_game(); pb::end_game();
@ -572,7 +588,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
case 0x66u: case 0x66u:
if (!single_step) if (!single_step)
pause(); pause();
a_dialog(pinball::hinst, hWnd); a_dialog(hinst, hWnd);
return DefWindowProcA(hWnd, Msg, wParam, lParam); return DefWindowProcA(hWnd, Msg, wParam, lParam);
case 0x67u: case 0x67u:
if (!single_step) if (!single_step)
@ -655,7 +671,7 @@ int winmain::ProcessWindowMessages()
} }
return 1; return 1;
} }
GetMessageA(&Msg, pinball::hwnd_frame, 0, 0); GetMessageA(&Msg, hwnd_frame, 0, 0);
TranslateMessage(&Msg); TranslateMessage(&Msg);
DispatchMessageA(&Msg); DispatchMessageA(&Msg);
if (Msg.message == 18) if (Msg.message == 18)

View File

@ -6,6 +6,8 @@ class winmain
public: public:
static char DatFileName[300]; static char DatFileName[300];
static int single_step; static int single_step;
static HINSTANCE hinst;
static HWND hwnd_frame;
static int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd); static int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd);
static LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);