[Scummvm-git-logs] scummvm branch-2-6 -> a0b268a54c03ae7dfa180d389d034fb280095f13

criezy noreply at scummvm.org
Sun Oct 9 18:43:52 UTC 2022


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bebe52ba86 AGS: force update gui metrics on load and on game start
1d1ec14bda AGS: don't zero slider's HandleImage internally if sprite is missing
a0b268a54c AGS: fixed GUISlider::IsOverControl() comparing abs with rel coords


Commit: bebe52ba860f502104abc8b00d44f0e0071e5285
    https://github.com/scummvm/scummvm/commit/bebe52ba860f502104abc8b00d44f0e0071e5285
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-10-09T19:13:20+01:00

Commit Message:
AGS: force update gui metrics on load and on game start

This fixes some controls not reporting their metrics correctly until first displayed on screen.

>From upstream ea4e6762236a13621ba0771b9d5d8ac4bcf33ee8

Changed paths:
    engines/ags/engine/main/engine.cpp
    engines/ags/shared/gui/gui_listbox.cpp
    engines/ags/shared/gui/gui_main.cpp
    engines/ags/shared/gui/gui_main.h
    engines/ags/shared/gui/gui_slider.cpp


diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index 73ebbd5f8c8..b9bac69b578 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -559,18 +559,10 @@ void engine_init_game_settings() {
 	if (_G(playerchar)->view >= 0)
 		precache_view(_G(playerchar)->view);
 
-	/*  dummygui.guiId = -1;
-	dummyguicontrol.guin = -1;
-	dummyguicontrol.objn = -1;*/
-
 	_G(our_eip) = -6;
-	//  _GP(game).chars[0].talkview=4;
-	//init_language_text(_GP(game).langcodes[0]);
 
 	for (ee = 0; ee < MAX_ROOM_OBJECTS; ee++) {
 		_G(scrObj)[ee].id = ee;
-		// 64 bit: Using the id instead
-		// _G(scrObj)[ee].obj = NULL;
 	}
 
 	for (ee = 0; ee < _GP(game).numcharacters; ee++) {
@@ -750,6 +742,8 @@ void engine_init_game_settings() {
 
 	GUI::Options.DisabledStyle = static_cast<GuiDisableStyle>(_GP(game).options[OPT_DISABLEOFF]);
 	GUI::Options.ClipControls = _GP(game).options[OPT_CLIPGUICONTROLS] != 0;
+	// Force GUI metrics recalculation, accomodating for loaded fonts
+	GUI::MarkForFontUpdate(-1);
 
 	memset(&_GP(play).walkable_areas_on[0], 1, MAX_WALK_AREAS + 1);
 	memset(&_GP(play).script_timers[0], 0, MAX_TIMERS * sizeof(int));
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index c54740a8608..30b1a95e332 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -383,6 +383,8 @@ void GUIListBox::ReadFromFile(Stream *in, GuiVersion gui_version) {
 
 	if (TextColor == 0)
 		TextColor = 16;
+
+	UpdateMetrics();
 }
 
 void GUIListBox::ReadFromSavegame(Stream *in, GuiSvgVersion svg_ver) {
@@ -415,6 +417,8 @@ void GUIListBox::ReadFromSavegame(Stream *in, GuiSvgVersion svg_ver) {
 			SavedGameIndex[i] = in->ReadInt16();
 	TopItem = in->ReadInt32();
 	SelectedItem = in->ReadInt32();
+
+	UpdateMetrics();
 }
 
 void GUIListBox::WriteToSavegame(Stream *out) const {
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 77c9a17f024..b72025a9d35 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -705,21 +705,22 @@ void MarkForTranslationUpdate() {
 }
 
 void MarkForFontUpdate(int font) {
+	const bool update_all = (font < 0);
 	for (auto &btn : _GP(guibuts)) {
-		if (btn.Font == font)
-			btn.MarkChanged();
+		if (update_all || btn.Font == font)
+			btn.OnResized();
 	}
 	for (auto &lbl : _GP(guilabels)) {
-		if (lbl.Font == font)
-			lbl.MarkChanged();
+		if (update_all || lbl.Font == font)
+			lbl.OnResized();
 	}
 	for (auto &list : _GP(guilist)) {
-		if (list.Font == font)
-			list.MarkChanged();
+		if (update_all || list.Font == font)
+			list.OnResized();
 	}
 	for (auto &tb : _GP(guitext)) {
-		if (tb.Font == font)
-			tb.MarkChanged();
+		if (update_all || tb.Font == font)
+			tb.OnResized();
 	}
 }
 
diff --git a/engines/ags/shared/gui/gui_main.h b/engines/ags/shared/gui/gui_main.h
index 625f23681c1..6bcc115500b 100644
--- a/engines/ags/shared/gui/gui_main.h
+++ b/engines/ags/shared/gui/gui_main.h
@@ -231,7 +231,8 @@ void DrawTextAlignedHor(Bitmap *ds, const char *text, int font, color_t text_col
 void MarkAllGUIForUpdate();
 // Mark all translatable GUI controls for redraw
 void MarkForTranslationUpdate();
-// Mark all GUI which use the given font for redraw
+// Mark all GUI which use the given font for recalculate/redraw;
+// pass -1 to update all the textual controls together
 void MarkForFontUpdate(int font);
 // Mark labels that acts as special text placeholders for redraw
 void MarkSpecialLabelsForUpdate(GUILabelMacro macro);
diff --git a/engines/ags/shared/gui/gui_slider.cpp b/engines/ags/shared/gui/gui_slider.cpp
index 4efe00e743c..af52781806f 100644
--- a/engines/ags/shared/gui/gui_slider.cpp
+++ b/engines/ags/shared/gui/gui_slider.cpp
@@ -243,6 +243,8 @@ void GUISlider::ReadFromFile(Stream *in, GuiVersion gui_version) {
 		HandleOffset = 0;
 		BgImage = 0;
 	}
+
+	UpdateMetrics();
 }
 
 void GUISlider::WriteToFile(Stream *out) const {
@@ -263,6 +265,8 @@ void GUISlider::ReadFromSavegame(Stream *in, GuiSvgVersion svg_ver) {
 	MinValue = in->ReadInt32();
 	MaxValue = in->ReadInt32();
 	Value = in->ReadInt32();
+
+	UpdateMetrics();
 }
 
 void GUISlider::WriteToSavegame(Stream *out) const {


Commit: 1d1ec14bda7e35d55a46fe875783d3be46f97f68
    https://github.com/scummvm/scummvm/commit/1d1ec14bda7e35d55a46fe875783d3be46f97f68
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-10-09T19:30:11+01:00

Commit Message:
AGS: don't zero slider's HandleImage internally if sprite is missing

This may lead to unexpected effects when resources are not fully preloaded yet, but a Slider's "UpdateMetrics" was called.

>From upstream 5654fb52a64904a6b0cdcec674224f7a0d91a8eb

Changed paths:
    engines/ags/shared/gui/gui_slider.cpp


diff --git a/engines/ags/shared/gui/gui_slider.cpp b/engines/ags/shared/gui/gui_slider.cpp
index af52781806f..43182b0dc5c 100644
--- a/engines/ags/shared/gui/gui_slider.cpp
+++ b/engines/ags/shared/gui/gui_slider.cpp
@@ -82,10 +82,8 @@ void GUISlider::UpdateMetrics() {
 	if (MinValue >= MaxValue)
 		MaxValue = MinValue + 1;
 	Value = Math::Clamp(Value, MinValue, MaxValue);
-	// Test if sprite is available
-	// TODO: react to sprites initialization/deletion instead!
-	if (_GP(spriteset)[HandleImage] == nullptr)
-		HandleImage = 0;
+	// Test if sprite is available; // TODO: return a placeholder from spriteset instead!
+	const int handle_im = _GP(spriteset)[HandleImage] ? HandleImage : 0;
 
 	// Depending on slider's orientation, thickness is either Height or Width
 	const int thickness = IsHorizontal() ? Height : Width;
@@ -96,10 +94,10 @@ void GUISlider::UpdateMetrics() {
 
 	// Calculate handle size
 	Size handle_sz;
-	if (HandleImage > 0) // handle is a sprite
+	if (handle_im > 0) // handle is a sprite
 	{
-		handle_sz = Size(get_adjusted_spritewidth(HandleImage),
-			get_adjusted_spriteheight(HandleImage));
+		handle_sz = Size(get_adjusted_spritewidth(handle_im),
+			get_adjusted_spriteheight(handle_im));
 	} else // handle is a drawn rectangle
 	{
 		if (IsHorizontal())
@@ -180,9 +178,11 @@ void GUISlider::Draw(Bitmap *ds, int x, int y) {
 		ds->DrawLine(Line(bar.Left, bar.Bottom, bar.Right, bar.Bottom), draw_color);
 	}
 
-	if (HandleImage > 0) // handle is a sprite
+	// Test if sprite is available; // TODO: return a placeholder from spriteset instead!
+	const int handle_im = _GP(spriteset)[HandleImage] ? HandleImage : 0;
+	if (handle_im > 0) // handle is a sprite
 	{
-		draw_gui_sprite(ds, HandleImage, handle.Left, handle.Top, true);
+		draw_gui_sprite(ds, handle_im, handle.Left, handle.Top, true);
 	} else // handle is a drawn rectangle
 	{
 		// normal grey tracker handle


Commit: a0b268a54c03ae7dfa180d389d034fb280095f13
    https://github.com/scummvm/scummvm/commit/a0b268a54c03ae7dfa180d389d034fb280095f13
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-10-09T19:39:01+01:00

Commit Message:
AGS: fixed GUISlider::IsOverControl() comparing abs with rel coords

Was broken likely by dec832ad4 (upstream 9394a2d)

>From upstream 77c10eb3757029d8d185d9b161890d05203d90af

Changed paths:
    engines/ags/shared/gui/gui_slider.cpp


diff --git a/engines/ags/shared/gui/gui_slider.cpp b/engines/ags/shared/gui/gui_slider.cpp
index 43182b0dc5c..f161d13f9cc 100644
--- a/engines/ags/shared/gui/gui_slider.cpp
+++ b/engines/ags/shared/gui/gui_slider.cpp
@@ -58,7 +58,7 @@ bool GUISlider::IsOverControl(int x, int y, int leeway) const {
 	if (GUIObject::IsOverControl(x, y, leeway))
 		return true;
 	// now check the handle too
-	return _cachedHandle.IsInside(Point(x, y));
+	return _cachedHandle.IsInside(Point(x - X, y - Y));
 }
 
 Rect GUISlider::CalcGraphicRect(bool clipped) {




More information about the Scummvm-git-logs mailing list