Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression Fixes #3299

Merged
merged 2 commits into from
Nov 30, 2024
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
8 changes: 7 additions & 1 deletion src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scene_Name>(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<Scene_Name>(*actor, charset, use_default_name);
Scene::instance->SetRequestedScene(std::move(scene));

++index;
Expand Down
7 changes: 3 additions & 4 deletions src/game_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down
32 changes: 10 additions & 22 deletions src/scene_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/scene_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Window_Keyboard::Mode> layouts;
int actor_id = 0;
int layout_index = 0;
bool use_default_name = false;

private:
Game_Actor& actor;

std::unique_ptr<Window_Keyboard> kbd_window;
std::unique_ptr<Window_Name> name_window;
std::unique_ptr<Window_Face> face_window;
Expand Down
6 changes: 4 additions & 2 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading