[Scummvm-git-logs] scummvm master -> 50c59252c79754ebfdab325bdd253687b46a520d
dreammaster
dreammaster at scummvm.org
Sat Aug 21 04:50:57 UTC 2021
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
460d362bff AGS: Replaced use of MAX_PATH macro with a constant
91fa6ee386 AGS: Removed check_font() from GUI, as font handling is now safer
3ec7897644 AGS: Fixed ListBox calling SetFont in Draw, causing GUI to reupdate
db783e1734 AGS: Mark GUI for redraw when a plugin font is set
6a8f1f9a71 AGS: More accurate notification of GUI control changes for redrawing
83388a11e2 AGS: Fixed ListBox items may become unaccessible after resize
994c67a3ed AGS: Updated build version (3.5.1.10)
50c59252c7 AGS: Added Bitmap::ResetClip() for simpler unsetting of clipping
Commit: 460d362bff2380fb89b32196fbdfbbbb9134cbc9
https://github.com/scummvm/scummvm/commit/460d362bff2380fb89b32196fbdfbbbb9134cbc9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Replaced use of MAX_PATH macro with a constant
>From upstream 68242e8b55f9f4dd5a8a82d3b3f80e99e26f4bb5
Changed paths:
engines/ags/engine/ac/global_dynamic_sprite.cpp
engines/ags/engine/ac/runtime_defines.h
engines/ags/shared/util/path.cpp
engines/ags/shared/util/stdio_compat.h
diff --git a/engines/ags/engine/ac/global_dynamic_sprite.cpp b/engines/ags/engine/ac/global_dynamic_sprite.cpp
index 3a9ce64ce3..f1781c5212 100644
--- a/engines/ags/engine/ac/global_dynamic_sprite.cpp
+++ b/engines/ags/engine/ac/global_dynamic_sprite.cpp
@@ -25,7 +25,6 @@
#include "ags/engine/ac/dynamic_sprite.h"
#include "ags/engine/ac/path_helper.h"
#include "ags/shared/ac/sprite_cache.h"
-#include "ags/engine/ac/runtime_defines.h" //MAX_PATH
#include "ags/engine/gfx/graphics_driver.h"
#include "ags/shared/gfx/bitmap.h"
#include "ags/globals.h"
diff --git a/engines/ags/engine/ac/runtime_defines.h b/engines/ags/engine/ac/runtime_defines.h
index a84f3c70e3..2105bec4d1 100644
--- a/engines/ags/engine/ac/runtime_defines.h
+++ b/engines/ags/engine/ac/runtime_defines.h
@@ -141,10 +141,6 @@ const int LegacyRoomVolumeFactor = 30;
#define MAX_PLUGIN_OBJECT_READERS 50
-#ifndef MAX_PATH
-#define MAX_PATH 260
-#endif
-
#define TRANS_ALPHA_CHANNEL 20000
#define TRANS_OPAQUE 20001
#define TRANS_RUN_PLUGIN 20002
diff --git a/engines/ags/shared/util/path.cpp b/engines/ags/shared/util/path.cpp
index 8aeee66fdc..fa916ed5b0 100644
--- a/engines/ags/shared/util/path.cpp
+++ b/engines/ags/shared/util/path.cpp
@@ -30,12 +30,6 @@
#include "ags/shared/util/stdio_compat.h"
namespace AGS3 {
-
-// TODO: implement proper portable path length
-#ifndef MAX_PATH
-#define MAX_PATH 512
-#endif
-
namespace AGS {
namespace Shared {
@@ -126,15 +120,15 @@ String GetDirectoryPath(const String &path) {
}
bool IsSameOrSubDir(const String &parent, const String &path) {
- char can_parent[MAX_PATH];
- char can_path[MAX_PATH];
- char relative[MAX_PATH];
+ char can_parent[MAX_PATH_SZ];
+ char can_path[MAX_PATH_SZ];
+ char relative[MAX_PATH_SZ];
// canonicalize_filename treats "." as "./." (file in working dir)
const char *use_parent = parent == "." ? "./" : parent.GetCStr();
const char *use_path = path == "." ? "./" : path.GetCStr();
- canonicalize_filename(can_parent, use_parent, MAX_PATH);
- canonicalize_filename(can_path, use_path, MAX_PATH);
- const char *pstr = make_relative_filename(relative, can_parent, can_path, MAX_PATH);
+ canonicalize_filename(can_parent, use_parent, sizeof(can_parent));
+ canonicalize_filename(can_path, use_path, sizeof(can_path));
+ const char *pstr = make_relative_filename(relative, can_parent, can_path, sizeof(relative));
if (!pstr)
return false;
for (pstr = strstr(pstr, ".."); pstr && *pstr; pstr = strstr(pstr, "..")) {
@@ -188,29 +182,29 @@ String MakeAbsolutePath(const String &path) {
#if AGS_PLATFORM_OS_WINDOWS
// NOTE: cannot use long path names in the engine, because it does not have unicode strings support
//
- //char long_path_buffer[MAX_PATH];
- //if (GetLongPathNameA(path, long_path_buffer, MAX_PATH) > 0)
+ //char long_path_buffer[MAX_PATH_SZ];
+ //if (GetLongPathNameA(path, long_path_buffer, MAX_PATH_SZ) > 0)
//{
// abs_path = long_path_buffer;
//}
#endif
- char buf[MAX_PATH];
- canonicalize_filename(buf, abs_path.GetCStr(), MAX_PATH);
+ char buf[MAX_PATH_SZ];
+ canonicalize_filename(buf, abs_path.GetCStr(), sizeof(buf));
abs_path = buf;
FixupPath(abs_path);
return abs_path;
}
String MakeRelativePath(const String &base, const String &path) {
- char can_parent[MAX_PATH];
- char can_path[MAX_PATH];
- char relative[MAX_PATH];
+ char can_parent[MAX_PATH_SZ];
+ char can_path[MAX_PATH_SZ];
+ char relative[MAX_PATH_SZ];
// canonicalize_filename treats "." as "./." (file in working dir)
const char *use_parent = base == "." ? "./" : base.GetCStr();
const char *use_path = path == "." ? "./" : path.GetCStr(); // FIXME?
- canonicalize_filename(can_parent, use_parent, MAX_PATH);
- canonicalize_filename(can_path, use_path, MAX_PATH);
- String rel_path = make_relative_filename(relative, can_parent, can_path, MAX_PATH);
+ canonicalize_filename(can_parent, use_parent, sizeof(can_parent));
+ canonicalize_filename(can_path, use_path, sizeof(can_path));
+ String rel_path = make_relative_filename(relative, can_parent, can_path, sizeof(relative));
FixupPath(rel_path);
return rel_path;
}
@@ -269,8 +263,8 @@ String FixupSharedFilename(const String &filename) {
String GetPathInASCII(const String &path) {
#if AGS_PLATFORM_OS_WINDOWS
- char ascii_buffer[MAX_PATH];
- if (GetShortPathNameA(path.GetCStr(), ascii_buffer, MAX_PATH) == 0)
+ char ascii_buffer[MAX_PATH_SZ];
+ if (GetShortPathNameA(path.GetCStr(), ascii_buffer, MAX_PATH_SZ) == 0)
return "";
return ascii_buffer;
#else
@@ -281,12 +275,12 @@ String GetPathInASCII(const String &path) {
#if AGS_PLATFORM_OS_WINDOWS
String WidePathNameToAnsi(LPCWSTR pathw) {
- WCHAR short_path[MAX_PATH];
- char ascii_buffer[MAX_PATH];
+ WCHAR short_path[MAX_PATH_SZ];
+ char ascii_buffer[MAX_PATH_SZ];
LPCWSTR arg_path = pathw;
- if (GetShortPathNameW(arg_path, short_path, MAX_PATH) == 0)
+ if (GetShortPathNameW(arg_path, short_path, MAX_PATH_SZ) == 0)
return "";
- WideCharToMultiByte(CP_ACP, 0, short_path, -1, ascii_buffer, MAX_PATH, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, short_path, -1, ascii_buffer, MAX_PATH_SZ, NULL, NULL);
return ascii_buffer;
}
#endif
diff --git a/engines/ags/shared/util/stdio_compat.h b/engines/ags/shared/util/stdio_compat.h
index 65e8371107..bcdad250ae 100644
--- a/engines/ags/shared/util/stdio_compat.h
+++ b/engines/ags/shared/util/stdio_compat.h
@@ -30,6 +30,9 @@ namespace AGS3 {
typedef int64 file_off_t;
+// Size of the buffer enough to accomodate a UTF-8 path
+const size_t MAX_PATH_SZ = 1024;
+
extern Common::FSNode getFSNode(const char *path);
extern int ags_fseek(Common::Stream *stream, file_off_t offset, int whence);
Commit: 91fa6ee386683f938c50ae4b2560b252dd85a431
https://github.com/scummvm/scummvm/commit/91fa6ee386683f938c50ae4b2560b252dd85a431
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Removed check_font() from GUI, as font handling is now safer
>From upstream dc24ac2493026cfecfd0664a057f61f99f4b28ae
Changed paths:
engines/ags/engine/gui/gui_engine.cpp
engines/ags/globals.h
engines/ags/shared/gui/gui_button.cpp
engines/ags/shared/gui/gui_label.cpp
engines/ags/shared/gui/gui_listbox.cpp
engines/ags/shared/gui/gui_main.h
engines/ags/shared/gui/gui_textbox.cpp
diff --git a/engines/ags/engine/gui/gui_engine.cpp b/engines/ags/engine/gui/gui_engine.cpp
index fe1d7ee297..802d155887 100644
--- a/engines/ags/engine/gui/gui_engine.cpp
+++ b/engines/ags/engine/gui/gui_engine.cpp
@@ -73,14 +73,6 @@ bool GUIMain::HasAlphaChannel() const {
_G(loaded_game_file_version) >= kGameVersion_320 && _GP(game).options[OPT_NEWGUIALPHA] != kGuiAlphaRender_Legacy;
}
-//=============================================================================
-// Engine-specific implementation split out of acgui.h
-//=============================================================================
-
-void check_font(int32_t *fontnum) {
- // do nothing
-}
-
//=============================================================================
// Engine-specific implementation split out of acgui.cpp
//=============================================================================
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 2f50ffaa12..df5d00f55e 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -24,6 +24,7 @@
#define AGS_GLOBALS_H
#include "ags/shared/ac/game_version.h"
+#include "ags/shared/util/stdio_compat.h"
#include "ags/shared/util/string.h"
#include "ags/shared/util/string_types.h"
#include "ags/shared/util/version.h"
@@ -1334,7 +1335,7 @@ public:
StringMap *_transtree = nullptr;
String _trans_name, _trans_filename;
long _lang_offs_start = 0;
- char _transFileName[MAX_PATH] = { 0 };
+ char _transFileName[MAX_PATH_SZ] = { 0 };
std::vector<uint16> _wcsbuf; // widechar buffer
std::vector<char> _mbbuf; // utf8 buffer
diff --git a/engines/ags/shared/gui/gui_button.cpp b/engines/ags/shared/gui/gui_button.cpp
index b6bea54f73..ac6efbd2c7 100644
--- a/engines/ags/shared/gui/gui_button.cpp
+++ b/engines/ags/shared/gui/gui_button.cpp
@@ -93,7 +93,6 @@ bool GUIButton::IsClippingImage() const {
void GUIButton::Draw(Bitmap *ds) {
bool draw_disabled = !IsGUIEnabled(this);
- check_font(&Font);
// if it's "Unchanged when disabled" or "GUI Off", don't grey out
if (_G(gui_disabled_style) == GUIDIS_UNCHANGED ||
_G(gui_disabled_style) == GUIDIS_GUIOFF) {
diff --git a/engines/ags/shared/gui/gui_label.cpp b/engines/ags/shared/gui/gui_label.cpp
index 6df36ca00b..935008de74 100644
--- a/engines/ags/shared/gui/gui_label.cpp
+++ b/engines/ags/shared/gui/gui_label.cpp
@@ -50,8 +50,6 @@ GUILabelMacro GUILabel::GetTextMacros() const {
}
void GUILabel::Draw(Shared::Bitmap *ds) {
- check_font(&Font);
-
// TODO: need to find a way to cache text prior to drawing;
// but that will require to update all gui controls when translation is changed in game
PrepareTextToDraw();
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index d9663660a5..b2d2630241 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -98,7 +98,6 @@ void GUIListBox::Draw(Shared::Bitmap *ds) {
const int height = Height - 1;
const int pixel_size = get_fixed_pixel_size(1);
- check_font(&Font);
color_t text_color = ds->GetCompatibleColor(TextColor);
color_t draw_color = ds->GetCompatibleColor(TextColor);
if (IsBorderShown()) {
@@ -256,7 +255,6 @@ void GUIListBox::OnMouseMove(int x_, int y_) {
void GUIListBox::OnResized() {
if (RowHeight == 0) {
- check_font(&Font);
SetFont(Font);
}
if (RowHeight > 0)
diff --git a/engines/ags/shared/gui/gui_main.h b/engines/ags/shared/gui/gui_main.h
index 3fb13d1736..d67b3ab345 100644
--- a/engines/ags/shared/gui/gui_main.h
+++ b/engines/ags/shared/gui/gui_main.h
@@ -250,7 +250,6 @@ extern AGS_INLINE int get_fixed_pixel_size(int pixels);
// Those function have distinct implementations in Engine and Editor
extern void wouttext_outline(Shared::Bitmap *ds, int xxp, int yyp, int usingfont, color_t text_color, const char *texx);
extern int wgettextwidth_compensate(Shared::Bitmap *ds, const char *tex, int font);
-extern void check_font(int32_t *fontnum);
extern void set_our_eip(int eip);
#define SET_EIP(x) set_our_eip(x);
diff --git a/engines/ags/shared/gui/gui_textbox.cpp b/engines/ags/shared/gui/gui_textbox.cpp
index 242e7b95e4..d8e08d7cc6 100644
--- a/engines/ags/shared/gui/gui_textbox.cpp
+++ b/engines/ags/shared/gui/gui_textbox.cpp
@@ -49,7 +49,6 @@ bool GUITextBox::IsBorderShown() const {
}
void GUITextBox::Draw(Bitmap *ds) {
- check_font(&Font);
color_t text_color = ds->GetCompatibleColor(TextColor);
color_t draw_color = ds->GetCompatibleColor(TextColor);
if (IsBorderShown()) {
Commit: 3ec7897644f00507c7f8890b0dada18a0838eb19
https://github.com/scummvm/scummvm/commit/3ec7897644f00507c7f8890b0dada18a0838eb19
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Fixed ListBox calling SetFont in Draw, causing GUI to reupdate
>From upstream 15bbe018e1f05a202de54ebebb335a5ee4611732
Changed paths:
engines/ags/shared/gui/gui_listbox.cpp
engines/ags/shared/gui/gui_listbox.h
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index b2d2630241..d6326df3da 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -108,8 +108,9 @@ void GUIListBox::Draw(Shared::Bitmap *ds) {
int right_hand_edge = (X + width) - pixel_size - 1;
- // use SetFont to update the RowHeight and VisibleItemCount
- SetFont(Font);
+ // update the RowHeight and VisibleItemCount
+ // FIXME: find a way to update this whenever relevant things change in the engine
+ UpdateMetrics();
// draw the scroll bar in if necessary
if (ItemCount > VisibleItemCount && IsBorderShown() && AreArrowsShown()) {
@@ -134,6 +135,7 @@ void GUIListBox::Draw(Shared::Bitmap *ds) {
right_hand_edge -= get_fixed_pixel_size(7);
}
+ // FIXME: cut this out, and let editor add real items for display
DrawItemsFix();
for (int item = 0; item < VisibleItemCount; ++item) {
@@ -219,8 +221,7 @@ void GUIListBox::SetSvgIndex(bool on) {
void GUIListBox::SetFont(int font) {
Font = font;
- RowHeight = getfontheight(Font) + get_fixed_pixel_size(2);
- VisibleItemCount = Height / RowHeight;
+ UpdateMetrics();
NotifyParentChanged();
}
@@ -254,11 +255,13 @@ void GUIListBox::OnMouseMove(int x_, int y_) {
}
void GUIListBox::OnResized() {
- if (RowHeight == 0) {
- SetFont(Font);
- }
- if (RowHeight > 0)
- VisibleItemCount = Height / RowHeight;
+ UpdateMetrics();
+ NotifyParentChanged();
+}
+
+void GUIListBox::UpdateMetrics() {
+ RowHeight = getfontheight(Font) + get_fixed_pixel_size(2);
+ VisibleItemCount = Height / RowHeight;
}
// TODO: replace string serialization with StrUtil::ReadString and WriteString
diff --git a/engines/ags/shared/gui/gui_listbox.h b/engines/ags/shared/gui/gui_listbox.h
index 76326d575d..9f7ee7daa4 100644
--- a/engines/ags/shared/gui/gui_listbox.h
+++ b/engines/ags/shared/gui/gui_listbox.h
@@ -86,6 +86,8 @@ public:
private:
int32_t ListBoxFlags;
+ // Updates dynamic metrics such as row height and others
+ void UpdateMetrics();
// A temporary solution for special drawing in the Editor
void DrawItemsFix();
void DrawItemsUnfix();
Commit: db783e17347b3cfdd12aa0d724d7ab46fb16f4bc
https://github.com/scummvm/scummvm/commit/db783e17347b3cfdd12aa0d724d7ab46fb16f4bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Mark GUI for redraw when a plugin font is set
>From upstream dfb82a2e36ea16e21a557afd9dffdbd7035ca527
Changed paths:
engines/ags/plugins/ags_plugin.cpp
engines/ags/shared/gui/gui_main.cpp
engines/ags/shared/gui/gui_main.h
diff --git a/engines/ags/plugins/ags_plugin.cpp b/engines/ags/plugins/ags_plugin.cpp
index d22c0f0542..02d5a0fb8b 100644
--- a/engines/ags/plugins/ags_plugin.cpp
+++ b/engines/ags/plugins/ags_plugin.cpp
@@ -733,7 +733,9 @@ void IAGSEngine::BreakIntoDebugger() {
}
IAGSFontRenderer *IAGSEngine::ReplaceFontRenderer(int fontNumber, IAGSFontRenderer *newRenderer) {
- return font_replace_renderer(fontNumber, newRenderer);
+ auto *old_render = font_replace_renderer(fontNumber, newRenderer);
+ GUI::MarkForFontUpdate(fontNumber);
+ return old_render;
}
void IAGSEngine::GetRenderStageDesc(AGSRenderStageDesc *desc) {
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index 05756d6d64..c446550e2c 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -657,6 +657,25 @@ void MarkAllGUIForUpdate() {
}
}
+void MarkForFontUpdate(int font) {
+ for (auto &btn : _GP(guibuts)) {
+ if (btn.Font == font)
+ btn.NotifyParentChanged();
+ }
+ for (auto &lbl : _GP(guilabels)) {
+ if (lbl.Font == font)
+ lbl.NotifyParentChanged();
+ }
+ for (auto &list : _GP(guilist)) {
+ if (list.Font == font)
+ list.NotifyParentChanged();
+ }
+ for (auto &tb : _GP(guitext)) {
+ if (tb.Font == font)
+ tb.NotifyParentChanged();
+ }
+}
+
void MarkSpecialLabelsForUpdate(GUILabelMacro macro) {
for (auto &lbl : _GP(guilabels)) {
if ((lbl.GetTextMacros() & macro) != 0) {
diff --git a/engines/ags/shared/gui/gui_main.h b/engines/ags/shared/gui/gui_main.h
index d67b3ab345..06ffcf6dbd 100644
--- a/engines/ags/shared/gui/gui_main.h
+++ b/engines/ags/shared/gui/gui_main.h
@@ -215,6 +215,8 @@ void DrawTextAlignedHor(Bitmap *ds, const char *text, int font, color_t text_col
// Mark all existing GUI for redraw
void MarkAllGUIForUpdate();
+// Mark all GUI which use the given font for redraw
+void MarkForFontUpdate(int font);
// Mark labels that acts as special text placeholders for redraw
void MarkSpecialLabelsForUpdate(GUILabelMacro macro);
// Mark inventory windows for redraw, optionally only ones linked to given character
Commit: 6a8f1f9a71c883cd11aee1996c06273419e84a11
https://github.com/scummvm/scummvm/commit/6a8f1f9a71c883cd11aee1996c06273419e84a11
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: More accurate notification of GUI control changes for redrawing
>From upstream fd7cb8dc822e50cc485aa0dfc937217ead1cb996
Changed paths:
engines/ags/engine/script/script.cpp
engines/ags/shared/gui/gui_button.cpp
engines/ags/shared/gui/gui_button.h
engines/ags/shared/gui/gui_listbox.cpp
engines/ags/shared/gui/gui_main.cpp
engines/ags/shared/gui/gui_textbox.cpp
diff --git a/engines/ags/engine/script/script.cpp b/engines/ags/engine/script/script.cpp
index ff5ece96c6..447bf91197 100644
--- a/engines/ags/engine/script/script.cpp
+++ b/engines/ags/engine/script/script.cpp
@@ -42,7 +42,6 @@
#include "ags/engine/ac/mouse.h"
#include "ags/engine/ac/room.h"
#include "ags/engine/ac/room_object.h"
-#include "ags/shared/gui/gui_main.h"
#include "ags/shared/script/cc_error.h"
#include "ags/shared/script/cc_options.h"
#include "ags/engine/debugging/debugger.h"
@@ -444,12 +443,6 @@ int RunTextScript2IParam(ccInstance *sci, const char *tsname, const RuntimeScrip
return toret;
}
- // response to a button click, better update guis
- if (ags_strnicmp(tsname, "interface_click", 15) == 0) {
- // interface_click(int interface, int button)
- _GP(guis)[iparam.IValue].MarkChanged();
- }
-
return RunScriptFunctionIfExists(sci, tsname, 2, params);
}
diff --git a/engines/ags/shared/gui/gui_button.cpp b/engines/ags/shared/gui/gui_button.cpp
index ac6efbd2c7..95c873fc4f 100644
--- a/engines/ags/shared/gui/gui_button.cpp
+++ b/engines/ags/shared/gui/gui_button.cpp
@@ -86,6 +86,10 @@ const String &GUIButton::GetText() const {
return _text;
}
+bool GUIButton::IsImageButton() const {
+ return Image != 0;
+}
+
bool GUIButton::IsClippingImage() const {
return (Flags & kGUICtrl_Clip) != 0;
}
@@ -107,7 +111,7 @@ void GUIButton::Draw(Bitmap *ds) {
return;
// CHECKME: why testing both CurrentImage and Image?
- if (CurrentImage > 0 && Image > 0)
+ if (CurrentImage > 0 && IsImageButton())
DrawImageButton(ds, draw_disabled);
// CHECKME: why don't draw frame if no Text? this will make button completely invisible!
else if (!_text.IsEmpty())
@@ -142,32 +146,48 @@ void GUIButton::SetText(const String &text) {
NotifyParentChanged();
}
+
bool GUIButton::OnMouseDown() {
- if (PushedImage > 0)
- CurrentImage = PushedImage;
+ int new_image = (PushedImage > 0) ? PushedImage : CurrentImage;
+ if (CurrentImage != new_image || !IsImageButton())
+ NotifyParentChanged();
+ CurrentImage = new_image;
IsPushed = true;
return false;
}
void GUIButton::OnMouseEnter() {
- CurrentImage = IsPushed ? PushedImage : MouseOverImage;
+ int new_image = (IsPushed && PushedImage > 0) ? PushedImage :
+ (MouseOverImage > 0) ? MouseOverImage : Image;
+ if ((CurrentImage != new_image) || (IsPushed && !IsImageButton())) {
+ CurrentImage = new_image;
+ NotifyParentChanged();
+ }
IsMouseOver = true;
}
void GUIButton::OnMouseLeave() {
- CurrentImage = Image;
+ if ((CurrentImage != Image) || (IsPushed && !IsImageButton())) {
+ CurrentImage = Image;
+ NotifyParentChanged();
+ }
IsMouseOver = false;
}
void GUIButton::OnMouseUp() {
+ int new_image;
if (IsMouseOver) {
- CurrentImage = MouseOverImage;
+ new_image = MouseOverImage;
if (IsGUIEnabled(this) && IsClickable())
IsActivated = true;
} else {
- CurrentImage = Image;
+ new_image = Image;
}
+ if ((CurrentImage != new_image) || (IsPushed && !IsImageButton())) {
+ CurrentImage = new_image;
+ NotifyParentChanged();
+ }
IsPushed = false;
}
diff --git a/engines/ags/shared/gui/gui_button.h b/engines/ags/shared/gui/gui_button.h
index 2983456a17..43e7eb581b 100644
--- a/engines/ags/shared/gui/gui_button.h
+++ b/engines/ags/shared/gui/gui_button.h
@@ -63,6 +63,7 @@ public:
GUIButton();
const String &GetText() const;
+ bool IsImageButton() const;
bool IsClippingImage() const;
// Operations
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index d6326df3da..69765f1817 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -234,17 +234,25 @@ void GUIListBox::SetItemText(int index, const String &text) {
bool GUIListBox::OnMouseDown() {
if (IsInRightMargin(MousePos.X)) {
+ int top_item = TopItem;
if (MousePos.Y < Height / 2 && TopItem > 0)
- TopItem--;
+ top_item = TopItem - 1;
if (MousePos.Y >= Height / 2 && ItemCount > TopItem + VisibleItemCount)
- TopItem++;
+ top_item = TopItem + 1;
+ if (TopItem != top_item) {
+ TopItem = top_item;
+ NotifyParentChanged();
+ }
return false;
}
int sel = GetItemAt(MousePos.X, MousePos.Y);
if (sel < 0)
return false;
- SelectedItem = sel;
+ if (sel != SelectedItem) {
+ SelectedItem = sel;
+ NotifyParentChanged();
+ }
IsActivated = true;
return false;
}
diff --git a/engines/ags/shared/gui/gui_main.cpp b/engines/ags/shared/gui/gui_main.cpp
index c446550e2c..85cf774863 100644
--- a/engines/ags/shared/gui/gui_main.cpp
+++ b/engines/ags/shared/gui/gui_main.cpp
@@ -313,7 +313,7 @@ void GUIMain::Poll() {
_controls[MouseOverCtrl]->OnMouseMove(_G(mousex), _G(mousey));
}
}
- MarkChanged(); // TODO: only do if anything really changed
+ //MarkChanged(); // TODO: only do if anything really changed
} else if (MouseOverCtrl >= 0)
_controls[MouseOverCtrl]->OnMouseMove(_G(mousex), _G(mousey));
}
@@ -460,7 +460,7 @@ void GUIMain::OnMouseButtonDown() {
if (_controls[MouseOverCtrl]->OnMouseDown())
MouseOverCtrl = MOVER_MOUSEDOWNLOCKED;
_controls[MouseDownCtrl]->OnMouseMove(_G(mousex) - X, _G(mousey) - Y);
- MarkChanged(); // TODO: only do if anything really changed
+ //MarkChanged(); // TODO: only do if anything really changed
}
void GUIMain::OnMouseButtonUp() {
@@ -476,7 +476,7 @@ void GUIMain::OnMouseButtonUp() {
_controls[MouseDownCtrl]->OnMouseUp();
MouseDownCtrl = -1;
- MarkChanged(); // TODO: only do if anything really changed
+ //MarkChanged(); // TODO: only do if anything really changed
}
void GUIMain::ReadFromFile(Stream *in, GuiVersion gui_version) {
diff --git a/engines/ags/shared/gui/gui_textbox.cpp b/engines/ags/shared/gui/gui_textbox.cpp
index d8e08d7cc6..2a9c6440f6 100644
--- a/engines/ags/shared/gui/gui_textbox.cpp
+++ b/engines/ags/shared/gui/gui_textbox.cpp
@@ -78,6 +78,11 @@ void GUITextBox::OnKeyPress(const KeyInput &ki) {
// other key, continue
if ((keycode >= 128) && (!font_supports_extended_characters(Font)))
return;
+ // return/enter
+ if (keycode == eAGSKeyCodeReturn) {
+ IsActivated = true;
+ return;
+ }
NotifyParentChanged();
// backspace, remove character
@@ -85,11 +90,6 @@ void GUITextBox::OnKeyPress(const KeyInput &ki) {
Backspace(Text);
return;
}
- // return/enter
- if (keycode == eAGSKeyCodeReturn) {
- IsActivated = true;
- return;
- }
Text.AppendChar(keycode);
// if the new string is too long, remove the new character
Commit: 83388a11e2b6abaa586c6f7b2990cfbb55d2d101
https://github.com/scummvm/scummvm/commit/83388a11e2b6abaa586c6f7b2990cfbb55d2d101
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Fixed ListBox items may become unaccessible after resize
>From upstream 6e2a1ff2d8ca0430099261e5b2eeb79e73c8012d
Changed paths:
engines/ags/shared/gui/gui_listbox.cpp
diff --git a/engines/ags/shared/gui/gui_listbox.cpp b/engines/ags/shared/gui/gui_listbox.cpp
index 69765f1817..043ae8fb0f 100644
--- a/engines/ags/shared/gui/gui_listbox.cpp
+++ b/engines/ags/shared/gui/gui_listbox.cpp
@@ -270,6 +270,8 @@ void GUIListBox::OnResized() {
void GUIListBox::UpdateMetrics() {
RowHeight = getfontheight(Font) + get_fixed_pixel_size(2);
VisibleItemCount = Height / RowHeight;
+ if (ItemCount <= VisibleItemCount)
+ TopItem = 0; // reset scroll if all items are visible
}
// TODO: replace string serialization with StrUtil::ReadString and WriteString
Commit: 994c67a3edf259f3e6efebf894dcfaf6c5e56ca6
https://github.com/scummvm/scummvm/commit/994c67a3edf259f3e6efebf894dcfaf6c5e56ca6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:38-07:00
Commit Message:
AGS: Updated build version (3.5.1.10)
>From upstream edd1eded7f5b1097511b986c7c2c3d944195ded9
This is despite the prior version being 3.6.0.7
Changed paths:
engines/ags/ags.h
diff --git a/engines/ags/ags.h b/engines/ags/ags.h
index 707626a4a1..c7e4f27865 100644
--- a/engines/ags/ags.h
+++ b/engines/ags/ags.h
@@ -50,8 +50,8 @@ namespace AGS {
* @brief Engine to run Adventure Game Studio games.
*/
-/* Synced up to upstream: 3.6.0.7
- * bcf598aa4ea6de69a84505b7c844f7bdcf44596b
+/* Synced up to upstream: 3.5.1.10
+ * edd1eded7f5b1097511b986c7c2c3d944195ded9
*/
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200
Commit: 50c59252c79754ebfdab325bdd253687b46a520d
https://github.com/scummvm/scummvm/commit/50c59252c79754ebfdab325bdd253687b46a520d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-08-20T21:49:39-07:00
Commit Message:
AGS: Added Bitmap::ResetClip() for simpler unsetting of clipping
>From upstream a0ad337a24ec2c25822949494c717529c57e56c3
Changed paths:
engines/ags/engine/ac/display.cpp
engines/ags/shared/gfx/allegro_bitmap.cpp
engines/ags/shared/gfx/allegro_bitmap.h
engines/ags/shared/gui/gui_button.cpp
diff --git a/engines/ags/engine/ac/display.cpp b/engines/ags/engine/ac/display.cpp
index 22db0fd2e4..4d06e6e223 100644
--- a/engines/ags/engine/ac/display.cpp
+++ b/engines/ags/engine/ac/display.cpp
@@ -606,7 +606,7 @@ void draw_button_background(Bitmap *ds, int xx1, int yy1, int xx2, int yy2, GUIM
bgoffsx += _GP(game).SpriteInfos[iep->BgImage].Width;
}
// return to normal clipping rectangle
- ds->SetClip(Rect(0, 0, ds->GetWidth() - 1, ds->GetHeight() - 1));
+ ds->ResetClip();
}
}
int uu;
diff --git a/engines/ags/shared/gfx/allegro_bitmap.cpp b/engines/ags/shared/gfx/allegro_bitmap.cpp
index b7ea8dfd08..8bbc9dad12 100644
--- a/engines/ags/shared/gfx/allegro_bitmap.cpp
+++ b/engines/ags/shared/gfx/allegro_bitmap.cpp
@@ -164,6 +164,10 @@ void Bitmap::SetClip(const Rect &rc) {
set_clip_rect(_alBitmap, rc.Left, rc.Top, rc.Right, rc.Bottom);
}
+void Bitmap::ResetClip() {
+ set_clip_rect(_alBitmap, 0, 0, _alBitmap->w - 1, _alBitmap->h - 1);
+}
+
Rect Bitmap::GetClip() const {
Rect temp;
get_clip_rect(_alBitmap, &temp.Left, &temp.Top, &temp.Right, &temp.Bottom);
diff --git a/engines/ags/shared/gfx/allegro_bitmap.h b/engines/ags/shared/gfx/allegro_bitmap.h
index cfb63fb246..eb594f7e5d 100644
--- a/engines/ags/shared/gfx/allegro_bitmap.h
+++ b/engines/ags/shared/gfx/allegro_bitmap.h
@@ -168,6 +168,7 @@ public:
// Clipping
//=========================================================================
void SetClip(const Rect &rc);
+ void ResetClip();
Rect GetClip() const;
//=========================================================================
diff --git a/engines/ags/shared/gui/gui_button.cpp b/engines/ags/shared/gui/gui_button.cpp
index 95c873fc4f..caf74b9b01 100644
--- a/engines/ags/shared/gui/gui_button.cpp
+++ b/engines/ags/shared/gui/gui_button.cpp
@@ -318,7 +318,7 @@ void GUIButton::DrawImageButton(Bitmap *ds, bool draw_disabled) {
_GP(spriteset)[CurrentImage]->GetWidth(),
_GP(spriteset)[CurrentImage]->GetHeight()));
}
- ds->SetClip(Rect(0, 0, ds->GetWidth() - 1, ds->GetHeight() - 1));
+ ds->ResetClip();
// Don't print Text of (INV) (INVSHR) (INVNS)
if (_placeholder == kButtonPlace_None && !_unnamed)
More information about the Scummvm-git-logs
mailing list