Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
05de0eaf
Commit
05de0eaf
authored
Mar 29, 2019
by
K. S. Ernest (iFire) Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add editor screenshot on control - f12.
parent
e2bbf2cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
0 deletions
+95
-0
os.cpp
core/os/os.cpp
+29
-0
os.h
core/os/os.h
+1
-0
editor_node.cpp
editor/editor_node.cpp
+54
-0
editor_node.h
editor/editor_node.h
+11
-0
No files found.
core/os/os.cpp
View file @
05de0eaf
...
...
@@ -51,6 +51,35 @@ uint32_t OS::get_ticks_msec() const {
return
get_ticks_usec
()
/
1000
;
}
String
OS
::
get_iso_date_time
(
bool
local
)
const
{
OS
::
Date
date
=
get_date
(
local
);
OS
::
Time
time
=
get_time
(
local
);
String
timezone
;
if
(
!
local
)
{
TimeZoneInfo
zone
=
get_time_zone_info
();
if
(
zone
.
bias
>=
0
)
{
timezone
=
"+"
;
}
timezone
=
timezone
+
itos
(
zone
.
bias
/
60
).
pad_zeros
(
2
)
+
itos
(
zone
.
bias
%
60
).
pad_zeros
(
2
);
}
else
{
timezone
=
"Z"
;
}
return
itos
(
date
.
year
).
pad_zeros
(
2
)
+
"-"
+
itos
(
date
.
month
).
pad_zeros
(
2
)
+
"-"
+
itos
(
date
.
day
).
pad_zeros
(
2
)
+
"T"
+
itos
(
time
.
hour
).
pad_zeros
(
2
)
+
":"
+
itos
(
time
.
min
).
pad_zeros
(
2
)
+
":"
+
itos
(
time
.
sec
).
pad_zeros
(
2
)
+
timezone
;
}
uint64_t
OS
::
get_splash_tick_msec
()
const
{
return
_msec_splash
;
}
...
...
core/os/os.h
View file @
05de0eaf
...
...
@@ -336,6 +336,7 @@ public:
virtual
Date
get_date
(
bool
local
=
false
)
const
=
0
;
virtual
Time
get_time
(
bool
local
=
false
)
const
=
0
;
virtual
TimeZoneInfo
get_time_zone_info
()
const
=
0
;
virtual
String
get_iso_date_time
(
bool
local
=
false
)
const
;
virtual
uint64_t
get_unix_time
()
const
;
virtual
uint64_t
get_system_time_secs
()
const
;
virtual
uint64_t
get_system_time_msecs
()
const
;
...
...
editor/editor_node.cpp
View file @
05de0eaf
...
...
@@ -2485,7 +2485,16 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
bool
was_visible
=
OS
::
get_singleton
()
->
is_console_visible
();
OS
::
get_singleton
()
->
set_console_visible
(
!
was_visible
);
EditorSettings
::
get_singleton
()
->
set_setting
(
"interface/editor/hide_console_window"
,
!
was_visible
);
}
break
;
case
EDITOR_SCREENSHOT
:
{
screenshot_timer
->
start
();
}
break
;
case
EDITOR_OPEN_SCREENSHOT
:
{
bool
is_checked
=
settings_menu
->
get_popup
()
->
is_item_checked
(
settings_menu
->
get_popup
()
->
get_item_index
(
EDITOR_OPEN_SCREENSHOT
));
settings_menu
->
get_popup
()
->
set_item_checked
(
settings_menu
->
get_popup
()
->
get_item_index
(
EDITOR_OPEN_SCREENSHOT
),
!
is_checked
);
EditorSettings
::
get_singleton
()
->
set_project_metadata
(
"screenshot_options"
,
"open_screenshot"
,
!
is_checked
);
}
break
;
case
SETTINGS_PICK_MAIN_SCENE
:
{
...
...
@@ -2540,6 +2549,30 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
}
}
void
EditorNode
::
_request_screenshot
()
{
_screenshot
();
}
void
EditorNode
::
_screenshot
(
bool
p_use_utc
)
{
String
name
=
"editor_screenshot_"
+
OS
::
get_singleton
()
->
get_iso_date_time
(
p_use_utc
).
replace
(
":"
,
""
)
+
".png"
;
NodePath
path
=
String
(
"user://"
)
+
name
;
_save_screenshot
(
path
);
if
(
EditorSettings
::
get_singleton
()
->
get_project_metadata
(
"screenshot_options"
,
"open_screenshot"
,
true
))
{
OS
::
get_singleton
()
->
shell_open
(
String
(
"file://"
)
+
ProjectSettings
::
get_singleton
()
->
globalize_path
(
path
));
}
}
void
EditorNode
::
_save_screenshot
(
NodePath
p_path
)
{
Viewport
*
viewport
=
EditorInterface
::
get_singleton
()
->
get_editor_viewport
()
->
get_viewport
();
viewport
->
set_clear_mode
(
Viewport
::
CLEAR_MODE_ONLY_NEXT_FRAME
);
Ref
<
Image
>
img
=
viewport
->
get_texture
()
->
get_data
();
img
->
flip_y
();
viewport
->
set_clear_mode
(
Viewport
::
CLEAR_MODE_ALWAYS
);
Error
error
=
img
->
save_png
(
p_path
);
ERR_FAIL_COND
(
error
!=
OK
);
}
void
EditorNode
::
_tool_menu_option
(
int
p_idx
)
{
switch
(
tool_menu
->
get_item_id
(
p_idx
))
{
case
TOOLS_ORPHAN_RESOURCES
:
{
...
...
@@ -5160,6 +5193,10 @@ void EditorNode::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"_resources_changed"
),
&
EditorNode
::
_resources_changed
);
ClassDB
::
bind_method
(
D_METHOD
(
"_feature_profile_changed"
),
&
EditorNode
::
_feature_profile_changed
);
ClassDB
::
bind_method
(
"_screenshot"
,
&
EditorNode
::
_screenshot
);
ClassDB
::
bind_method
(
"_request_screenshot"
,
&
EditorNode
::
_request_screenshot
);
ClassDB
::
bind_method
(
"_save_screenshot"
,
&
EditorNode
::
_save_screenshot
);
ADD_SIGNAL
(
MethodInfo
(
"play_pressed"
));
ADD_SIGNAL
(
MethodInfo
(
"pause_pressed"
));
ADD_SIGNAL
(
MethodInfo
(
"stop_pressed"
));
...
...
@@ -5886,6 +5923,16 @@ EditorNode::EditorNode() {
editor_layouts
->
connect
(
"id_pressed"
,
this
,
"_layout_menu_option"
);
p
->
add_submenu_item
(
TTR
(
"Editor Layout"
),
"Layouts"
);
#ifdef OSX_ENABLED
p
->
add_shortcut
(
ED_SHORTCUT
(
"editor/take_screenshot"
,
TTR
(
"Take Screenshot"
),
KEY_MASK_CMD
|
KEY_F12
),
EDITOR_SCREENSHOT
);
#else
p
->
add_shortcut
(
ED_SHORTCUT
(
"editor/take_screenshot"
,
TTR
(
"Take Screenshot"
),
KEY_MASK_CTRL
|
KEY_F12
),
EDITOR_SCREENSHOT
);
#endif
p
->
set_item_tooltip
(
p
->
get_item_count
()
-
1
,
TTR
(
"Screenshots are stored in the Editor Data/Settings Folder."
));
p
->
add_check_shortcut
(
ED_SHORTCUT
(
"editor/open_screenshot"
,
TTR
(
"Automatically Open Screenshots"
)),
EDITOR_OPEN_SCREENSHOT
);
bool
is_open_screenshot
=
EditorSettings
::
get_singleton
()
->
get_project_metadata
(
"screenshot_options"
,
"open_screenshot"
,
true
);
p
->
set_item_checked
(
p
->
get_item_count
()
-
1
,
is_open_screenshot
);
p
->
set_item_tooltip
(
p
->
get_item_count
()
-
1
,
TTR
(
"Open in an external image editor."
));
#ifdef OSX_ENABLED
p
->
add_shortcut
(
ED_SHORTCUT
(
"editor/fullscreen_mode"
,
TTR
(
"Toggle Fullscreen"
),
KEY_MASK_CMD
|
KEY_MASK_CTRL
|
KEY_F
),
SETTINGS_TOGGLE_FULLSCREEN
);
#else
p
->
add_shortcut
(
ED_SHORTCUT
(
"editor/fullscreen_mode"
,
TTR
(
"Toggle Fullscreen"
),
KEY_MASK_SHIFT
|
KEY_F11
),
SETTINGS_TOGGLE_FULLSCREEN
);
...
...
@@ -6477,6 +6524,13 @@ EditorNode::EditorNode() {
ED_SHORTCUT
(
"editor/editor_assetlib"
,
TTR
(
"Open Asset Library"
));
ED_SHORTCUT
(
"editor/editor_next"
,
TTR
(
"Open the next Editor"
));
ED_SHORTCUT
(
"editor/editor_prev"
,
TTR
(
"Open the previous Editor"
));
screenshot_timer
=
memnew
(
Timer
);
screenshot_timer
->
set_one_shot
(
true
);
screenshot_timer
->
set_wait_time
(
settings_menu
->
get_popup
()
->
get_submenu_popup_delay
()
+
0.1
f
);
screenshot_timer
->
connect
(
"timeout"
,
this
,
"_request_screenshot"
);
add_child
(
screenshot_timer
);
screenshot_timer
->
set_owner
(
get_owner
());
}
EditorNode
::~
EditorNode
()
{
...
...
editor/editor_node.h
View file @
05de0eaf
...
...
@@ -199,6 +199,9 @@ private:
SETTINGS_HELP
,
SCENE_TAB_CLOSE
,
EDITOR_SCREENSHOT
,
EDITOR_OPEN_SCREENSHOT
,
HELP_SEARCH
,
HELP_DOCS
,
HELP_QA
,
...
...
@@ -280,6 +283,8 @@ private:
ToolButton
*
search_button
;
TextureProgress
*
audio_vu
;
Timer
*
screenshot_timer
;
PluginConfigDialog
*
plugin_config_dialog
;
RichTextLabel
*
load_errors
;
...
...
@@ -448,6 +453,11 @@ private:
void
_menu_option
(
int
p_option
);
void
_menu_confirm_current
();
void
_menu_option_confirm
(
int
p_option
,
bool
p_confirmed
);
void
_request_screenshot
();
void
_screenshot
(
bool
p_use_utc
=
false
);
void
_save_screenshot
(
NodePath
p_path
);
void
_tool_menu_option
(
int
p_idx
);
void
_update_debug_options
();
...
...
@@ -646,6 +656,7 @@ private:
protected
:
void
_notification
(
int
p_what
);
static
void
_bind_methods
();
protected
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment