这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ set(SOURCE_FILES
SpaceCadetPinball/control.h
SpaceCadetPinball/EmbeddedData.cpp
SpaceCadetPinball/EmbeddedData.h
SpaceCadetPinball/font_selection.cpp
SpaceCadetPinball/font_selection.h
SpaceCadetPinball/fullscrn.cpp
SpaceCadetPinball/fullscrn.h
SpaceCadetPinball/gdrv.cpp
Expand Down Expand Up @@ -131,6 +133,8 @@ set(SOURCE_FILES
SpaceCadetPinball/TPopupTarget.h
SpaceCadetPinball/TRamp.cpp
SpaceCadetPinball/TRamp.h
SpaceCadetPinball/translations.cpp
SpaceCadetPinball/translations.h
SpaceCadetPinball/TRollover.cpp
SpaceCadetPinball/TRollover.h
SpaceCadetPinball/TSink.cpp
Expand Down Expand Up @@ -177,7 +181,7 @@ set(SOURCE_FILES
# On Windows, include resource file with the icon
if(WIN32)
set_source_files_properties(SpaceCadetPinball/SpaceCadetPinball.rc LANGUAGE RC)
list(APPEND SOURCE_FILES SpaceCadetPinball/SpaceCadetPinball.rc)
list(APPEND SOURCE_FILES SpaceCadetPinball/SpaceCadetPinball.rc)
endif(WIN32)

add_executable(SpaceCadetPinball ${SOURCE_FILES})
Expand Down
36 changes: 18 additions & 18 deletions SpaceCadetPinball/TPinballTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,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_string(Msg::STRING136), -1.0);
loader::play_sound(SoundIndex3, nullptr, "TPinballTable1");
TiltTimeoutTimer = timer::set(30.0, this, tilt_timeout);

Expand All @@ -315,7 +315,7 @@ void TPinballTable::port_draw()

int TPinballTable::Message(int code, float value)
{
LPSTR rc_text;
const char* rc_text;
switch (code)
{
case 1000:
Expand Down Expand Up @@ -369,9 +369,9 @@ int TPinballTable::Message(int code, float value)
LightGroup->Message(20, 0.0);
Plunger->Message(1016, 0.0);
if (Demo && Demo->ActiveFlag)
rc_text = pinball::get_rc_string(30, 0);
rc_text = pinball::get_rc_string(Msg::STRING131);
else
rc_text = pinball::get_rc_string(26, 0);
rc_text = pinball::get_rc_string(Msg::STRING127);
pinball::InfoTextBox->Display(rc_text, -1.0);
if (Demo)
Demo->Message(1014, 0.0);
Expand Down Expand Up @@ -466,11 +466,11 @@ int TPinballTable::Message(int code, float value)
{
if (PlayerCount <= 1)
{
char* textboxText;
const char* textboxText;
if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(30, 0);
textboxText = pinball::get_rc_string(Msg::STRING131);
else
textboxText = pinball::get_rc_string(26, 0);
textboxText = pinball::get_rc_string(Msg::STRING127);
pinball::InfoTextBox->Display(textboxText, -1.0);
break;
}
Expand Down Expand Up @@ -507,32 +507,32 @@ int TPinballTable::Message(int code, float value)
component->Message(1020, static_cast<float>(nextPlayer));
}

char* textboxText = nullptr;
const char* textboxText = nullptr;
switch (nextPlayer)
{
case 0:
if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(30, 0);
textboxText = pinball::get_rc_string(Msg::STRING131);
else
textboxText = pinball::get_rc_string(26, 0);
textboxText = pinball::get_rc_string(Msg::STRING127);
break;
case 1:
if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(31, 0);
textboxText = pinball::get_rc_string(Msg::STRING132);
else
textboxText = pinball::get_rc_string(27, 0);
textboxText = pinball::get_rc_string(Msg::STRING128);
break;
case 2:
if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(32, 0);
textboxText = pinball::get_rc_string(Msg::STRING133);
else
textboxText = pinball::get_rc_string(28, 0);
textboxText = pinball::get_rc_string(Msg::STRING129);
break;
case 3:
if (Demo->ActiveFlag)
textboxText = pinball::get_rc_string(33, 0);
textboxText = pinball::get_rc_string(Msg::STRING134);
else
textboxText = pinball::get_rc_string(29, 0);
textboxText = pinball::get_rc_string(Msg::STRING130);
break;
default:
break;
Expand All @@ -549,7 +549,7 @@ int TPinballTable::Message(int code, float value)
case 1022:
loader::play_sound(SoundIndex2, nullptr, "TPinballTable3");
pinball::MissTextBox->Clear();
pinball::InfoTextBox->Display(pinball::get_rc_string(34, 0), -1.0);
pinball::InfoTextBox->Display(pinball::get_rc_string(Msg::STRING135), -1.0);
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
break;
case 1024:
Expand Down Expand Up @@ -661,7 +661,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_string(Msg::STRING125), -1.0);
}

void TPinballTable::LightShow_timeout(int timerId, void* caller)
Expand Down
45 changes: 38 additions & 7 deletions SpaceCadetPinball/TTextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,43 @@ void TTextBox::Display(const char* text, float time)
}
}

void TTextBox::DrawImGui()
{
// Do nothing when using a font (the text will be rendered to VScreen in TTextBox::Draw)
if (Font || !Message1)
return;

char windowName[64];
SDL_Rect rect;
ImGuiWindowFlags window_flags =
ImGuiWindowFlags_NoBackground |
ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoInputs;

rect.x = OffsetX;
rect.y = OffsetY;
rect.w = Width;
rect.h = Height;

rect = fullscrn::GetScreenRectFromPinballRect(rect);

ImGui::SetNextWindowPos(ImVec2(rect.x, rect.y));
ImGui::SetNextWindowSize(ImVec2(rect.w, rect.h));

// Use the pointer to generate a window unique name per text box
snprintf(windowName, sizeof(windowName), "TTextBox_%p", this);
if (ImGui::Begin(windowName, nullptr, window_flags))
{
ImGui::SetWindowFontScale(fullscrn::GetScreenToPinballRatio());

// ToDo: centered text in FT
ImGui::TextWrapped("%s", Message1->Text);
}
ImGui::End();
}

void TTextBox::Draw()
{
auto bmp = BgBmp;
Expand Down Expand Up @@ -189,13 +226,7 @@ void TTextBox::Draw()
{
if (!Font)
{
gdrv::grtext_draw_ttext_in_box(
Message1->Text,
render::vscreen->XPosition + OffsetX,
render::vscreen->YPosition + OffsetY,
Width,
Height,
255);
// Immediate mode drawing using system font is handled by TTextBox::DrawImGui
return;
}

Expand Down
1 change: 1 addition & 0 deletions SpaceCadetPinball/TTextBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TTextBox :
int Message(int code, float value) override;
void Clear();
void Display(const char* text, float time);
void DrawImGui();

private:
struct LayoutResult
Expand Down
Loading