From a446cdb5194f2715011b7e6d8d5f74d6a0666fd7 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Fri, 22 Nov 2024 14:01:00 +0100 Subject: [PATCH 1/2] String Pictures: Respect the transparency flag Proper fix for #2961 Before this was unconditional and broke rendering of the system frame. Fix #2961 (Proper) Fix #3284 (Regression fix) --- src/game_windows.cpp | 7 +++---- src/window.cpp | 6 ++++-- src/window.h | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/game_windows.cpp b/src/game_windows.cpp index 2a3850722a..25511e6ee3 100644 --- a/src/game_windows.cpp +++ b/src/game_windows.cpp @@ -355,15 +355,15 @@ void Game_Windows::Window_User::Refresh(bool& async_wait) { window->SetVisible(false); BitmapRef system; - // FIXME: Transparency setting is currently not applied to the system graphic - // Disabling transparency breaks the rendering of the system graphic if (!data.system_name.empty()) { system = Cache::System(data.system_name); } else { system = Cache::SystemOrBlack(); } - window->SetWindowskin(system); + auto& pic = Main_Data::game_pictures->GetPicture(data.ID); + + window->SetWindowskin(system, pic.data.use_transparent_color); window->SetStretch(data.message_stretch == lcf::rpg::System::Stretch_stretch); if (data.message_stretch == lcf::rpg::System::Stretch_easyrpg_none) { @@ -455,7 +455,6 @@ void Game_Windows::Window_User::Refresh(bool& async_wait) { } // Add to picture - auto& pic = Main_Data::game_pictures->GetPicture(data.ID); pic.AttachWindow(*window); } diff --git a/src/window.cpp b/src/window.cpp index 6fc4dcba4b..4c89ebe722 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -178,7 +178,7 @@ void Window::Draw(Bitmap& dst) { void Window::RefreshBackground() { background_needs_refresh = false; - BitmapRef bitmap = Bitmap::Create(width, height); + BitmapRef bitmap = Bitmap::Create(width, height, background_alpha); if (stretch) { bitmap->StretchBlit(*windowskin, Rect(0, 0, 32, 32), 255); @@ -326,10 +326,12 @@ void Window::Update() { } } -void Window::SetWindowskin(BitmapRef const& nwindowskin) { +void Window::SetWindowskin(BitmapRef const& nwindowskin, bool transparent) { if (windowskin == nwindowskin) { return; } + + background_alpha = transparent; background_needs_refresh = true; frame_needs_refresh = true; cursor_needs_refresh = true; diff --git a/src/window.h b/src/window.h index 3f9700f360..12c088fed6 100644 --- a/src/window.h +++ b/src/window.h @@ -35,7 +35,7 @@ class Window : public Drawable { virtual void Update(); BitmapRef const& GetWindowskin() const; - void SetWindowskin(BitmapRef const& nwindowskin); + void SetWindowskin(BitmapRef const& nwindowskin, bool transparent = false); BitmapRef GetContents() const; void SetContents(BitmapRef const& ncontents); bool GetStretch() const; @@ -129,6 +129,7 @@ class Window : public Drawable { void RefreshFrame(); void RefreshCursor(); + bool background_alpha = false; bool background_needs_refresh; bool frame_needs_refresh; bool cursor_needs_refresh; From 830d70e93f3453ce8c164cffb12746a81d4b389d Mon Sep 17 00:00:00 2001 From: Ghabry Date: Fri, 22 Nov 2024 14:01:49 +0100 Subject: [PATCH 2/2] Fix name scene showing the incorrect face graphic Wow, another silent integer to Pointer conversion When will this end... Fix #3286 --- src/game_interpreter_map.cpp | 8 +++++++- src/scene_name.cpp | 32 ++++++++++---------------------- src/scene_name.h | 5 +++-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/game_interpreter_map.cpp b/src/game_interpreter_map.cpp index d26586ebbe..5b37d66b05 100644 --- a/src/game_interpreter_map.cpp +++ b/src/game_interpreter_map.cpp @@ -558,7 +558,13 @@ bool Game_Interpreter_Map::CommandEnterHeroName(lcf::rpg::EventCommand const& co auto charset = com.parameters[1]; auto use_default_name = com.parameters[2]; - auto scene = std::make_shared(actor_id, charset, use_default_name); + Game_Actor* actor = Main_Data::game_actors->GetActor(actor_id); + if (!actor) { + Output::Warning("EnterHeroName: Invalid actor ID {}", actor_id); + return true; + } + + auto scene = std::make_shared(*actor, charset, use_default_name); Scene::instance->SetRequestedScene(std::move(scene)); ++index; diff --git a/src/scene_name.cpp b/src/scene_name.cpp index 1dad0252fc..994226858c 100644 --- a/src/scene_name.cpp +++ b/src/scene_name.cpp @@ -24,23 +24,14 @@ #include "player.h" #include "output.h" -Scene_Name::Scene_Name(int actor_id, int charset, bool use_default_name) - : actor_id(actor_id), layout_index(charset), use_default_name(use_default_name) +Scene_Name::Scene_Name(Game_Actor& actor, int charset, bool use_default_name) + : actor(actor), layout_index(charset), use_default_name(use_default_name) { Scene::type = Scene::Name; - - auto *actor = Main_Data::game_actors->GetActor(actor_id); - if (!actor) { - Output::Error("EnterHeroName: Invalid actor ID {}", actor_id); - } } void Scene_Name::Start() { // Create the windows - - auto *actor = Main_Data::game_actors->GetActor(actor_id); - assert(actor); - int margin_x = 32; int margin_y = 8; int window_face_width = 64; @@ -51,11 +42,11 @@ void Scene_Name::Start() { int window_keyboard_height = 160; face_window.reset(new Window_Face(Player::menu_offset_x + margin_x, Player::menu_offset_y + margin_y, window_face_width, window_face_height)); - face_window->Set(actor_id); + face_window->Set(actor); face_window->Refresh(); name_window.reset(new Window_Name(Player::menu_offset_x + window_face_width + margin_x, Player::menu_offset_y + margin_y + 32, window_name_width, window_name_height)); - name_window->Set(use_default_name ? ToString(actor->GetName()) : ""); + name_window->Set(use_default_name ? ToString(actor.GetName()) : ""); name_window->Refresh(); const char* done = Window_Keyboard::DONE; @@ -118,15 +109,12 @@ void Scene_Name::vUpdate() { assert(!s.empty()); if (s == Window_Keyboard::DONE) { - auto* actor = Main_Data::game_actors->GetActor(actor_id); - if (actor != nullptr) { - if (name_window->Get().empty()) { - name_window->Set(ToString(actor->GetName())); - name_window->Refresh(); - } else { - actor->SetName(name_window->Get()); - Scene::Pop(); - } + if (name_window->Get().empty()) { + name_window->Set(ToString(actor.GetName())); + name_window->Refresh(); + } else { + actor.SetName(name_window->Get()); + Scene::Pop(); } } else if (s == Window_Keyboard::NEXT_PAGE) { ++layout_index; diff --git a/src/scene_name.h b/src/scene_name.h index c3ec1e696b..f65f4deb79 100644 --- a/src/scene_name.h +++ b/src/scene_name.h @@ -32,18 +32,19 @@ class Scene_Name : public Scene { /** * Constructor. */ - Scene_Name(int actor_id, int charset, bool use_default_name); + Scene_Name(Game_Actor& actor, int charset, bool use_default_name); void Start() override; void vUpdate() override; protected: std::vector layouts; - int actor_id = 0; int layout_index = 0; bool use_default_name = false; private: + Game_Actor& actor; + std::unique_ptr kbd_window; std::unique_ptr name_window; std::unique_ptr face_window;