mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
parent
3c2fff9d07
commit
d0c1ac60b6
@ -303,7 +303,7 @@ void TPinballTable::tilt(float time)
|
||||
{
|
||||
pinball::InfoTextBox->Clear();
|
||||
pinball::MissTextBox->Clear();
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_string(35, 0), -1.0);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_Wstring(35, 0), -1.0);
|
||||
loader::play_sound(SoundIndex3);
|
||||
TiltTimeoutTimer = timer::set(30.0, this, tilt_timeout);
|
||||
|
||||
@ -328,7 +328,7 @@ void TPinballTable::port_draw()
|
||||
|
||||
int TPinballTable::Message(int code, float value)
|
||||
{
|
||||
LPSTR rc_text;
|
||||
LPWSTR rc_text;
|
||||
switch (code)
|
||||
{
|
||||
case 1000:
|
||||
@ -382,9 +382,9 @@ int TPinballTable::Message(int code, float value)
|
||||
LightGroup->Message(20, 0.0);
|
||||
Plunger->Message(1016, 0.0);
|
||||
if (Demo->ActiveFlag)
|
||||
rc_text = pinball::get_rc_string(30, 0);
|
||||
rc_text = pinball::get_rc_Wstring(30, 0);
|
||||
else
|
||||
rc_text = pinball::get_rc_string(26, 0);
|
||||
rc_text = pinball::get_rc_Wstring(26, 0);
|
||||
pinball::InfoTextBox->Display(rc_text, -1.0);
|
||||
if (Demo)
|
||||
Demo->Message(1014, 0.0);
|
||||
@ -477,11 +477,11 @@ int TPinballTable::Message(int code, float value)
|
||||
{
|
||||
if (PlayerCount <= 1)
|
||||
{
|
||||
char* textboxText;
|
||||
wchar_t* textboxText;
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(30, 0);
|
||||
textboxText = pinball::get_rc_Wstring(30, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(26, 0);
|
||||
textboxText = pinball::get_rc_Wstring(26, 0);
|
||||
pinball::InfoTextBox->Display(textboxText, -1.0);
|
||||
break;
|
||||
}
|
||||
@ -518,32 +518,32 @@ int TPinballTable::Message(int code, float value)
|
||||
ComponentList->Get(i)->Message(1020, static_cast<float>(nextPlayer));
|
||||
}
|
||||
|
||||
char* textboxText = nullptr;
|
||||
wchar_t* textboxText = nullptr;
|
||||
switch (nextPlayer)
|
||||
{
|
||||
case 0:
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(30, 0);
|
||||
textboxText = pinball::get_rc_Wstring(30, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(26, 0);
|
||||
textboxText = pinball::get_rc_Wstring(26, 0);
|
||||
break;
|
||||
case 1:
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(31, 0);
|
||||
textboxText = pinball::get_rc_Wstring(31, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(27, 0);
|
||||
textboxText = pinball::get_rc_Wstring(27, 0);
|
||||
break;
|
||||
case 2:
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(32, 0);
|
||||
textboxText = pinball::get_rc_Wstring(32, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(28, 0);
|
||||
textboxText = pinball::get_rc_Wstring(28, 0);
|
||||
break;
|
||||
case 3:
|
||||
if (Demo->ActiveFlag)
|
||||
textboxText = pinball::get_rc_string(33, 0);
|
||||
textboxText = pinball::get_rc_Wstring(33, 0);
|
||||
else
|
||||
textboxText = pinball::get_rc_string(29, 0);
|
||||
textboxText = pinball::get_rc_Wstring(29, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -560,7 +560,7 @@ int TPinballTable::Message(int code, float value)
|
||||
case 1022:
|
||||
loader::play_sound(SoundIndex2);
|
||||
pinball::MissTextBox->Clear();
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_string(34, 0), -1.0);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_Wstring(34, 0), -1.0);
|
||||
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
|
||||
break;
|
||||
case 1024:
|
||||
@ -615,7 +615,7 @@ void TPinballTable::EndGame_timeout(int timerId, void* caller)
|
||||
if (table->Demo)
|
||||
table->Demo->Message(1022, 0.0);
|
||||
control::handler(67, pinball::MissTextBox);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_string(24, 0), -1.0);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_Wstring(24, 0), -1.0);
|
||||
}
|
||||
|
||||
void TPinballTable::LightShow_timeout(int timerId, void* caller)
|
||||
|
@ -109,12 +109,12 @@ void TTextBox::Clear()
|
||||
}
|
||||
}
|
||||
|
||||
void TTextBox::Display(const char* text, float time)
|
||||
void TTextBox::Display(const wchar_t* text, float time)
|
||||
{
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
if (Message1 && !strcmp(text, Message2->Text))
|
||||
if (Message1 && !lstrcmpW(text, Message2->Text))
|
||||
{
|
||||
Message2->Refresh(time);
|
||||
if (Message2 == Message1)
|
||||
@ -223,7 +223,7 @@ void TTextBox::Draw()
|
||||
break;
|
||||
|
||||
auto totalWidth = 0;
|
||||
char* textEndSpace = nullptr;
|
||||
wchar_t* textEndSpace = nullptr;
|
||||
auto textEnd = text;
|
||||
while (true)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
~TTextBox() override;
|
||||
int Message(int code, float value) override;
|
||||
void Clear();
|
||||
void Display(const char* text, float time);
|
||||
void Display(const wchar_t* text, float time);
|
||||
void Draw();
|
||||
|
||||
static void TimerExpired(int timerId, void* tb);
|
||||
|
@ -3,17 +3,17 @@
|
||||
#include "memory.h"
|
||||
#include "pb.h"
|
||||
|
||||
TTextBoxMessage::TTextBoxMessage(const char* text, float time)
|
||||
TTextBoxMessage::TTextBoxMessage(const wchar_t* 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);
|
||||
const auto textLen = lstrlenW(text) + 1;
|
||||
Text = memory::allocate<wchar_t>(textLen);
|
||||
if (Text)
|
||||
strcpy_s(Text, textLen, text);
|
||||
lstrcpynW(Text, text, textLen);
|
||||
}
|
||||
else
|
||||
Text = nullptr;
|
||||
|
@ -3,11 +3,11 @@ class TTextBoxMessage
|
||||
{
|
||||
public:
|
||||
TTextBoxMessage* NextMessage;
|
||||
char* Text;
|
||||
wchar_t* Text;
|
||||
float Time;
|
||||
int EndTicks;
|
||||
|
||||
TTextBoxMessage(const char* text, float time);
|
||||
TTextBoxMessage(const wchar_t* text, float time);
|
||||
~TTextBoxMessage();
|
||||
float TimeLeft() const;
|
||||
void Refresh(float time);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@
|
||||
#include "options.h"
|
||||
#include "pinball.h"
|
||||
#include "winmain.h"
|
||||
#include <string>
|
||||
|
||||
HPALETTE gdrv::palette_handle = nullptr;
|
||||
HINSTANCE gdrv::hinst;
|
||||
@ -415,7 +414,7 @@ void gdrv::copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int heigh
|
||||
}
|
||||
|
||||
|
||||
void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height)
|
||||
void gdrv::grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width, int height)
|
||||
{
|
||||
// Original font was 16 points, used with lowest table resolution
|
||||
static const int fontSizes[3] =
|
||||
@ -447,7 +446,7 @@ void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width,
|
||||
sscanf_s(fontColor, "%d %d %d", &grtext_red, &grtext_green, &grtext_blue);
|
||||
}
|
||||
|
||||
std::string font;
|
||||
const char* font;
|
||||
switch (options::Options.Language)
|
||||
{
|
||||
case Languages::TraditionalChinese:
|
||||
@ -460,16 +459,15 @@ void gdrv::grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width,
|
||||
font = "Arial";
|
||||
}
|
||||
|
||||
// DEFAULT_CHARSET in unicode build.
|
||||
// Default font does not scale well
|
||||
auto hNewFont = CreateFont(fontSize, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE,
|
||||
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH | FF_SWISS, font.c_str());
|
||||
DEFAULT_PITCH | FF_SWISS, font);
|
||||
HFONT hOldFont = static_cast<HFONT>(SelectObject(dc, hNewFont));
|
||||
int prevMode = SetBkMode(dc, TRANSPARENT);
|
||||
COLORREF color = SetTextColor(dc, grtext_red | grtext_green << 8 | grtext_blue << 16);
|
||||
|
||||
DrawTextA(dc, text, lstrlenA(text), &rc, DT_NOPREFIX | DT_WORDBREAK);
|
||||
DrawTextW(dc, text, lstrlenW(text), &rc, DT_NOPREFIX | DT_WORDBREAK);
|
||||
|
||||
SelectObject(dc, hOldFont);
|
||||
DeleteObject(hNewFont);
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
int srcXOff, int srcYOff);
|
||||
static void copy_bitmap_w_transparency(gdrv_bitmap8* dstBmp, int width, int height, int xOff, int yOff,
|
||||
gdrv_bitmap8* srcBmp, int srcXOff, int srcYOff);
|
||||
static void grtext_draw_ttext_in_box(LPCSTR text, int xOff, int yOff, int width, int height);
|
||||
static void grtext_draw_ttext_in_box(LPCWSTR text, int xOff, int yOff, int width, int height);
|
||||
private:
|
||||
/*COLORONCOLOR or HALFTONE*/
|
||||
static const int stretchMode = COLORONCOLOR;
|
||||
|
@ -193,7 +193,7 @@ void pb::toggle_demo()
|
||||
MainTable->Message(1024, 0.0);
|
||||
mode_change(2);
|
||||
pinball::MissTextBox->Clear();
|
||||
auto text = pinball::get_rc_string(24, 0);
|
||||
auto text = pinball::get_rc_Wstring(24, 0);
|
||||
pinball::InfoTextBox->Display(text, -1.0);
|
||||
}
|
||||
else
|
||||
@ -272,7 +272,7 @@ int pb::frame(int time)
|
||||
{
|
||||
if (nudge::nudge_count > 0.5f)
|
||||
{
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_string(25, 0), 2.0);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_Wstring(25, 0), 2.0);
|
||||
}
|
||||
if (nudge::nudge_count > 1.0f)
|
||||
MainTable->tilt(time_now);
|
||||
@ -352,7 +352,7 @@ void pb::pause_continue()
|
||||
{
|
||||
if (MainTable)
|
||||
MainTable->Message(1008, time_now);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_string(22, 0), -1.0);
|
||||
pinball::InfoTextBox->Display(pinball::get_rc_Wstring(22, 0), -1.0);
|
||||
midi::music_stop();
|
||||
}
|
||||
else
|
||||
@ -361,17 +361,17 @@ void pb::pause_continue()
|
||||
MainTable->Message(1009, 0.0);
|
||||
if (!demo_mode)
|
||||
{
|
||||
char* text;
|
||||
wchar_t* text;
|
||||
float textTime;
|
||||
if (game_mode == 2)
|
||||
{
|
||||
textTime = -1.0;
|
||||
text = pinball::get_rc_string(24, 0);
|
||||
text = pinball::get_rc_Wstring(24, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
textTime = 5.0;
|
||||
text = pinball::get_rc_string(23, 0);
|
||||
text = pinball::get_rc_Wstring(23, 0);
|
||||
}
|
||||
pinball::InfoTextBox->Display(text, textTime);
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ int pinball::quickFlag = 0;
|
||||
TTextBox* pinball::InfoTextBox;
|
||||
TTextBox* pinball::MissTextBox;
|
||||
char pinball::getRcBuffer[6 * 256];
|
||||
int pinball::rc_string_slot = 0;
|
||||
wchar_t pinball::getRcWBuffer[256 * 6];
|
||||
int pinball::rc_string_slot = 0, pinball::rc_Wstring_slot = 0;
|
||||
int pinball::LeftShift = -1;
|
||||
int pinball::RightShift = -1;
|
||||
|
||||
@ -22,6 +23,16 @@ char* pinball::get_rc_string(int uID, int a2)
|
||||
return result;
|
||||
}
|
||||
|
||||
wchar_t* pinball::get_rc_Wstring(int uID, int a2)
|
||||
{
|
||||
auto result = &getRcWBuffer[256 * rc_Wstring_slot];
|
||||
if (!LoadStringW(winmain::hinst, uID, result, 255))
|
||||
*result = 0;
|
||||
if (++rc_Wstring_slot >= 6)
|
||||
rc_Wstring_slot = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
int pinball::get_rc_int(int uID, int* dst)
|
||||
{
|
||||
char buffer[255];
|
||||
|
@ -17,11 +17,13 @@ public:
|
||||
static int LeftShift;
|
||||
|
||||
static char* get_rc_string(int uID, int a2);
|
||||
static wchar_t* get_rc_Wstring(int uID, int a2);
|
||||
static int get_rc_int(int uID, int* dst);
|
||||
static void FindShiftKeys();
|
||||
static void adjust_priority(int priority);
|
||||
static int make_path_name(LPSTR lpFilename, LPCSTR lpString2, int nSize = 0x12Cu);
|
||||
private:
|
||||
static char getRcBuffer[256 * 6];
|
||||
static int rc_string_slot;
|
||||
static wchar_t getRcWBuffer[256 * 6];
|
||||
static int rc_string_slot, rc_Wstring_slot;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user