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

[pull] master from godotengine:master #129

Merged
merged 14 commits into from
Feb 3, 2025
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
5 changes: 2 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ if not env["platform"]:
env["platform"] = "windows"

if env["platform"]:
print(f'Automatically detected platform: {env["platform"]}')
print(f"Automatically detected platform: {env['platform']}")

# Deprecated aliases kept for compatibility.
if env["platform"] in compatibility_platform_aliases:
Expand Down Expand Up @@ -998,8 +998,7 @@ if env["disable_3d"]:
if env["disable_advanced_gui"]:
if env.editor_build:
print_error(
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, "
"only for export template builds."
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, only for export template builds."
)
Exit(255)
else:
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ String FileAccess::get_line() const {
uint8_t c = get_8();

while (!eof_reached()) {
if (c == '\n' || c == '\0') {
if (c == '\n' || c == '\0' || get_error() != OK) {
line.push_back(0);
return String::utf8(line.get_data());
} else if (c != '\r') {
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/FileAccess.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<method name="get_length" qualifiers="const">
<return type="int" />
<description>
Returns the size of the file in bytes.
Returns the size of the file in bytes. For a pipe, returns the number of bytes available for reading from the pipe.
</description>
</method>
<method name="get_line" qualifiers="const">
Expand Down
14 changes: 14 additions & 0 deletions doc/classes/Viewport.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@
If [member handle_input_locally] is set to [code]false[/code], this method will try finding the first parent viewport that is set to handle input locally, and return its value for [method is_input_handled] instead.
</description>
</method>
<method name="notify_mouse_entered">
<return type="void" />
<description>
Inform the Viewport that the mouse has entered its area. Use this function before sending an [InputEventMouseButton] or [InputEventMouseMotion] to the [Viewport] with [method Viewport.push_input]. See also [method notify_mouse_exited].
[b]Note:[/b] In most cases, it is not necessary to call this function because [SubViewport] nodes that are children of [SubViewportContainer] are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in [TextureRect] or with an [Area3D] that forwards input events.
</description>
</method>
<method name="notify_mouse_exited">
<return type="void" />
<description>
Inform the Viewport that the mouse has left its area. Use this function when the node that displays the viewport notices the mouse has left the area of the displayed viewport. See also [method notify_mouse_entered].
[b]Note:[/b] In most cases, it is not necessary to call this function because [SubViewport] nodes that are children of [SubViewportContainer] are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in [TextureRect] or with an [Area3D] that forwards input events.
</description>
</method>
<method name="push_input">
<return type="void" />
<param index="0" name="event" type="InputEvent" />
Expand Down
8 changes: 4 additions & 4 deletions doc/tools/make_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Ascendants
if class_def.inherits:
inherits = class_def.inherits.strip()
f.write(f'**{translate("Inherits:")}** ')
f.write(f"**{translate('Inherits:')}** ")
first = True
while inherits is not None:
if not first:
Expand All @@ -947,7 +947,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
inherited.append(c.name)

if len(inherited):
f.write(f'**{translate("Inherited By:")}** ')
f.write(f"**{translate('Inherited By:')}** ")
for i, child in enumerate(inherited):
if i > 0:
f.write(", ")
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def resolve_type(link_type: str) -> str:
return f"``{link_type}``"

if klass.endswith("[]"): # Typed array, strip [] to link to contained type.
return f":ref:`Array<class_Array>`\\[{resolve_type(klass[:-len('[]')])}\\]"
return f":ref:`Array<class_Array>`\\[{resolve_type(klass[: -len('[]')])}\\]"

if klass.startswith("Dictionary["): # Typed dictionary, split elements to link contained types.
parts = klass[len("Dictionary[") : -len("]")].partition(", ")
Expand Down Expand Up @@ -2542,7 +2542,7 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
for i, text in enumerate(row):
if column_sizes[i] == 0 and remove_empty_columns:
continue
row_text += f' {(text or "").ljust(column_sizes[i])} |'
row_text += f" {(text or '').ljust(column_sizes[i])} |"
row_text += "\n"

f.write(f" {row_text}")
Expand Down
9 changes: 9 additions & 0 deletions drivers/unix/file_access_unix_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -132,6 +133,14 @@ String FileAccessUnixPipe::get_path_absolute() const {
return path_src;
}

uint64_t FileAccessUnixPipe::get_length() const {
ERR_FAIL_COND_V_MSG(fd[0] < 0, 0, "Pipe must be opened before use.");

int buf_rem = 0;
ERR_FAIL_COND_V(ioctl(fd[0], FIONREAD, &buf_rem) != 0, 0);
return buf_rem;
}

uint64_t FileAccessUnixPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
ERR_FAIL_COND_V_MSG(fd[0] < 0, -1, "Pipe must be opened before use.");
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion drivers/unix/file_access_unix_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FileAccessUnixPipe : public FileAccess {
virtual void seek(uint64_t p_position) override {}
virtual void seek_end(int64_t p_position = 0) override {}
virtual uint64_t get_position() const override { return 0; }
virtual uint64_t get_length() const override { return 0; }
virtual uint64_t get_length() const override;

virtual bool eof_reached() const override { return false; }

Expand Down
8 changes: 8 additions & 0 deletions drivers/windows/file_access_windows_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ String FileAccessWindowsPipe::get_path_absolute() const {
return path_src;
}

uint64_t FileAccessWindowsPipe::get_length() const {
ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use.");

DWORD buf_rem = 0;
ERR_FAIL_COND_V(!PeekNamedPipe(fd[0], nullptr, 0, nullptr, &buf_rem, nullptr), 0);
return buf_rem;
}

uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use.");
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion drivers/windows/file_access_windows_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FileAccessWindowsPipe : public FileAccess {
virtual void seek(uint64_t p_position) override {}
virtual void seek_end(int64_t p_position = 0) override {}
virtual uint64_t get_position() const override { return 0; }
virtual uint64_t get_length() const override { return 0; }
virtual uint64_t get_length() const override;

virtual bool eof_reached() const override { return false; }

Expand Down
1 change: 0 additions & 1 deletion editor/editor_resource_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,6 @@ void EditorResourcePicker::_duplicate_selected_resources() {
EditorResourcePicker::EditorResourcePicker(bool p_hide_assign_button_controls) {
assign_button = memnew(Button);
assign_button->set_flat(true);
assign_button->set_action_mode(BaseButton::ACTION_MODE_BUTTON_PRESS);
assign_button->set_h_size_flags(SIZE_EXPAND_FILL);
assign_button->set_expand_icon(true);
assign_button->set_clip_text(true);
Expand Down
51 changes: 28 additions & 23 deletions editor/plugins/embedded_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ void EmbeddedProcess::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
window = get_window();
} break;
case NOTIFICATION_PROCESS: {
_check_focused_process_id();
_check_mouse_over();

// We need to detect when the control globally changes location or size on the screen.
// NOTIFICATION_RESIZED and NOTIFICATION_WM_POSITION_CHANGED are not enough to detect
// resized parent to siblings controls that can affect global position.
Rect2i new_global_rect = get_global_rect();
if (last_global_rect != new_global_rect) {
last_global_rect = new_global_rect;
queue_update_embedded_process();
}

} break;
case NOTIFICATION_DRAW: {
_draw();
} break;
Expand Down Expand Up @@ -192,7 +178,7 @@ void EmbeddedProcess::embed_process(OS::ProcessID p_pid) {
current_process_id = p_pid;
start_embedding_time = OS::get_singleton()->get_ticks_msec();
embedding_grab_focus = has_focus();
set_process(true);
timer_update_embedded_process->start();
set_notify_transform(true);

// Attempt to embed the process, but if it has just started and the window is not ready yet,
Expand All @@ -209,7 +195,7 @@ void EmbeddedProcess::reset() {
start_embedding_time = 0;
embedding_grab_focus = false;
timer_embedding->stop();
set_process(false);
timer_update_embedded_process->stop();
set_notify_transform(false);
queue_redraw();
}
Expand Down Expand Up @@ -242,18 +228,31 @@ bool EmbeddedProcess::_is_embedded_process_updatable() {
}

void EmbeddedProcess::queue_update_embedded_process() {
if (updated_embedded_process_queued || !_is_embedded_process_updatable()) {
return;
}

updated_embedded_process_queued = true;
}

callable_mp(this, &EmbeddedProcess::_update_embedded_process).call_deferred();
void EmbeddedProcess::_timer_update_embedded_process_timeout() {
_check_focused_process_id();
_check_mouse_over();

if (!updated_embedded_process_queued) {
// We need to detect when the control globally changes location or size on the screen.
// NOTIFICATION_RESIZED and NOTIFICATION_WM_POSITION_CHANGED are not enough to detect
// resized parent to siblings controls that can affect global position.
Rect2i new_global_rect = get_global_rect();
if (last_global_rect != new_global_rect) {
last_global_rect = new_global_rect;
queue_update_embedded_process();
}
}

if (updated_embedded_process_queued) {
updated_embedded_process_queued = false;
_update_embedded_process();
}
}

void EmbeddedProcess::_update_embedded_process() {
updated_embedded_process_queued = false;

if (!_is_embedded_process_updatable()) {
return;
}
Expand Down Expand Up @@ -352,6 +351,12 @@ EmbeddedProcess::EmbeddedProcess() {
timer_embedding->set_one_shot(true);
add_child(timer_embedding);
timer_embedding->connect("timeout", callable_mp(this, &EmbeddedProcess::_timer_embedding_timeout));

timer_update_embedded_process = memnew(Timer);
timer_update_embedded_process->set_wait_time(0.1);
add_child(timer_update_embedded_process);
timer_update_embedded_process->connect("timeout", callable_mp(this, &EmbeddedProcess::_timer_update_embedded_process_timeout));

set_focus_mode(FOCUS_ALL);
}

Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/embedded_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class EmbeddedProcess : public Control {

Window *window = nullptr;
Timer *timer_embedding = nullptr;
Timer *timer_update_embedded_process = nullptr;

const int embedding_timeout = 45000;

Expand All @@ -61,6 +62,7 @@ class EmbeddedProcess : public Control {
void _try_embed_process();
void _update_embedded_process();
void _timer_embedding_timeout();
void _timer_update_embedded_process_timeout();
void _draw();
void _check_mouse_over();
void _check_focused_process_id();
Expand Down
5 changes: 5 additions & 0 deletions editor/plugins/game_view_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,11 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
game_size_label = memnew(Label());
main_menu_hbox->add_child(game_size_label);
game_size_label->hide();
// Setting the minimum size prevents the game workspace from resizing indefinitely
// due to the label size oscillating by a few pixels when the game is in stretch mode
// and the game workspace is at its minimum size.
game_size_label->set_custom_minimum_size(Size2(80 * EDSCALE, 0));
game_size_label->set_horizontal_alignment(HorizontalAlignment::HORIZONTAL_ALIGNMENT_RIGHT);

panel = memnew(Panel);
add_child(panel);
Expand Down
2 changes: 1 addition & 1 deletion gles3_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def build_gles3_header(
fd.write("\t\t};\n\n")
variant_count = len(header_data.variant_defines)
else:
fd.write("\t\tstatic const char **_variant_defines[]={" "};\n")
fd.write('\t\tstatic const char **_variant_defines[]={" "};\n')

if header_data.texunits:
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
Expand Down
11 changes: 5 additions & 6 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import subprocess
import sys
from collections import OrderedDict
from io import StringIO, TextIOWrapper
from io import StringIO, TextIOBase
from pathlib import Path
from typing import Generator, List, Optional, Union, cast

Expand Down Expand Up @@ -1201,7 +1201,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
vsconf = ""
for a in vs_configuration["arches"]:
if arch == a["architecture"]:
vsconf = f'{target}|{a["platform"]}'
vsconf = f"{target}|{a['platform']}"
break

condition = "'$(GodotConfiguration)|$(GodotPlatform)'=='" + vsconf + "'"
Expand All @@ -1217,7 +1217,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
properties.append(
"<ActiveProjectItemList_%s>;%s;</ActiveProjectItemList_%s>" % (x, ";".join(itemlist[x]), x)
)
output = f'bin\\godot{env["PROGSUFFIX"]}'
output = f"bin\\godot{env['PROGSUFFIX']}"

with open("misc/msvs/props.template", "r", encoding="utf-8") as file:
props_template = file.read()
Expand Down Expand Up @@ -1453,7 +1453,7 @@ def generated_wrapper(
guard: Optional[bool] = None,
prefix: str = "",
suffix: str = "",
) -> Generator[TextIOWrapper, None, None]:
) -> Generator[TextIOBase, None, None]:
"""
Wrapper class to automatically handle copyright headers and header guards
for generated scripts. Meant to be invoked via `with` statement similar to
Expand All @@ -1475,8 +1475,7 @@ def generated_wrapper(
if isinstance(path, list):
if len(path) > 1:
print_warning(
"Attempting to use generated wrapper with multiple targets; "
f"will only use first entry: {path[0]}"
f"Attempting to use generated wrapper with multiple targets; will only use first entry: {path[0]}"
)
path = path[0]
if not hasattr(path, "get_abspath"):
Expand Down
Loading